You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Go SDK API review: Phase A - SessionConfig/ResumeSessionConfig renames
- OnExitPlanMode -> OnExitPlanModeRequest
- OnAutoModeSwitch -> OnAutoModeSwitchRequest
- ExitPlanModeHandler -> ExitPlanModeRequestHandler
- AutoModeSwitchHandler -> AutoModeSwitchRequestHandler
- Session.GetMessages -> Session.GetEvents
- ResumeSessionConfig.DisableResume -> SuppressResumeEvent
- Streaming bool -> *bool on SessionConfig and ResumeSessionConfig
Wire-level RPC method (session.getMessages) and internal request types
are unchanged; only the public Go surface is renamed.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Go SDK API review: Phase B+C - ProviderConfig + MCP Tools tweaks
B. ProviderConfig.MaxInputTokens -> MaxPromptTokens (matches the wire
name 'maxPromptTokens' exactly).
C. MCPStdioServerConfig.Tools / MCPHTTPServerConfig.Tools: change JSON
tag from 'tools' to 'tools,omitempty'. Now nil/omitted slice means
'all tools' (CLI default), matching TS/Rust/C# semantics.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Go SDK API review: Phase D - RuntimeConnection refactor
Replaces the flat connection fields on ClientOptions with a single
discriminated Connection RuntimeConnection field constructed from one of:
StdioConnection{Path, Args}
TcpConnection{Port, ConnectionToken, Path, Args}
UriConnection{URL, ConnectionToken}
Removes:
- CLIPath, CLIArgs, CLIUrl, UseStdio, Port, TCPConnectionToken
- AutoStart, AutoRestart
- public ConnectionState type, State* constants, and Client.State() method
Renames:
- CopilotHome -> BaseDirectory
- Remote -> EnableRemoteSessions
- Client.ActualPort() -> Client.RuntimePort()
LogLevel no longer defaults to 'info'. When empty, the SDK does not
pass --log-level to the runtime, matching the TS SDK.
All unit tests, e2e tests, samples, and the Go scenario apps are
migrated. README updated.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Go SDK API review: Phase E - lifecycle timestamps as time.Time
SessionMetadata and SessionLifecycleEventMetadata: StartTime and
ModifiedTime change from string to time.Time. The runtime emits these
as ISO 8601 strings, which time.Time's default JSON unmarshal handles
natively.
Matches the equivalent C# (#1343) / TS (#1357) changes.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Go SDK API review: Phase F - hook timestamps as time.Time
All six hook input types (PreToolUseHookInput, PostToolUseHookInput,
UserPromptSubmittedHookInput, SessionStartHookInput, SessionEndHookInput,
ErrorOccurredHookInput): Timestamp changes from int64 to time.Time. Each
type gains a MarshalJSON/UnmarshalJSON pair that serializes Timestamp as
Unix milliseconds on the wire, matching the runtime protocol.
Mirrors the equivalent C# (#1343) UnixMillisecondsDateTimeOffsetConverter
and TS (#1357) Date-typed hook timestamps.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Go SDK API review: Phases G-K - misc renames and cleanups
G. InputOptions -> UiInputOptions on the Session.UI().Input convenience.
H. Add Session.SendPrompt(ctx, prompt) and Session.SendPromptAndWait(ctx, prompt)
convenience wrappers around the MessageOptions-based methods (mirrors the
string overloads added in C#/TS).
I. SessionFsProvider interface method renames (Go-specific): Mkdir ->
MakeDirectory, Readdir -> ReadDirectory, ReaddirWithTypes ->
ReadDirectoryWithTypes, Rm -> Remove. The adapter still implements the
wire-protocol method names (rpc.SessionFsHandler) unchanged.
J. SessionConfig/ResumeSessionConfig.CreateSessionFsHandler ->
CreateSessionFsProvider (matches the SessionFsProvider type it returns).
K. Remove deprecated Session.Destroy(); callers must use Session.Disconnect().
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Go SDK API review: Phase L - docs and scenario migrations
Update Go code samples in docs/ to use the new ClientOptions.Connection
shape (StdioConnection / UriConnection). Also migrate the streaming
scenario to copilot.Bool(true) for the new *bool Streaming field.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix Streaming: true in Go doc snippets after *bool change
CI docs-validate extracts Go code blocks and compiles them. Update the
remaining 4 sites (docs/getting-started.md x3, docs/features/streaming-events.md)
to use copilot.Bool(true) now that SessionConfig.Streaming is *bool.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Apply gofmt
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* MCP Tools: change []string to *[]string to preserve nil vs empty
With `json:"tools,omitempty"` on a bare []string, Go collapses both
nil and []string{} to "omitted", losing the documented distinction
between "all tools" (nil) and "no tools" (empty slice). Switch the
field type to *[]string so a non-nil pointer to an empty slice
serializes as `tools: []` on the wire, matching TS `tools?: string[]`
and C# `IList<string>?` with WhenWritingNull.
Callers use the standard Go idiom for pointer-to-slice literals:
Tools: &[]string{"*"} // explicit all tools
Tools: &[]string{} // no tools
Tools: &[]string{"a","b"} // only those tools
Tools: nil // (default) all tools, field omitted
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* docs: show StdioConnection.Args for Go --log-dir snippet
The Go SDK now supports extra runtime args via StdioConnection.Args /
TcpConnection.Args. Replace the outdated 'Go cannot pass args, run the
CLI manually' snippet with the actual idiomatic call.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Drop TS/C# reference from MCPStdioServerConfig doc comment
Go SDK source shouldn't reference other-language SDKs. Rephrase the
Tools field doc to explain the pointer-to-slice form purely in Go
terms.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@@ -2105,7 +2105,7 @@ var session = client.createSession(
2105
2105
2106
2106
</details>
2107
2107
2108
-
**Note:** When `cli_url` / `cliUrl` / `CLIUrl` is provided, or Rust uses `Transport::External`, the SDK will not spawn or manage a CLI process - it will only connect to the existing server at the specified URL.
2108
+
**Note:** When `cli_url` / `cliUrl` / Go's `UriConnection` is provided, or Rust uses `Transport::External`, the SDK will not spawn or manage a CLI process - it will only connect to the existing server at the specified URL.
Copy file name to clipboardExpand all lines: docs/setup/backend-services.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ Run the Copilot SDK in server-side applications—APIs, web backends, microservi
6
6
7
7
## How it works
8
8
9
-
Instead of the SDK spawning a CLI child process, you run the CLI independently in **headless server mode**. Your backend connects to it over TCP using the `cliUrl` option.
9
+
Instead of the SDK spawning a CLI child process, you run the CLI independently in **headless server mode**. Your backend connects to it over TCP using the `Connection` option (`UriConnection`).
Copy file name to clipboardExpand all lines: docs/setup/bundled-cli.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -71,7 +71,7 @@ await client.stop()
71
71
<summary><strong>Go</strong></summary>
72
72
73
73
> [!NOTE]
74
-
> The Go SDK does not bundle the CLI. You must install the CLI separately or set `CLIPath` to point to an existing binary. See [Local CLI Setup](./local-cli.md) for details.
74
+
> The Go SDK does not bundle the CLI. You must install the CLI separately or set `Connection` to point to an existing binary. See [Local CLI Setup](./local-cli.md) for details.
> The Java SDK does not bundle or embed the Copilot CLI. You must install the CLI separately and configure its path via `cliPath` or the `COPILOT_CLI_PATH` environment variable.
140
+
> The Java SDK does not bundle or embed the Copilot CLI. You must install the CLI separately and configure its path via `Connection` or the `COPILOT_CLI_PATH` environment variable.
Copy file name to clipboardExpand all lines: docs/setup/local-cli.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ Use a specific CLI binary instead of the SDK's bundled CLI. This is an advanced
6
6
7
7
## How it works
8
8
9
-
By default, the Node.js, Python, and .NET SDKs include their own CLI dependency (see [Default Setup](./bundled-cli.md)). If you need to override this—for example, to use a system-installed CLI—you can use the `cliPath` option.
9
+
By default, the Node.js, Python, and .NET SDKs include their own CLI dependency (see [Default Setup](./bundled-cli.md)). If you need to override this—for example, to use a system-installed CLI—you can use the `Connection` option.
10
10
11
11
```mermaid
12
12
flowchart LR
@@ -78,7 +78,7 @@ await client.stop()
78
78
<summary><strong>Go</strong></summary>
79
79
80
80
> [!NOTE]
81
-
> The Go SDK does not bundle a CLI, so you must always provide `CLIPath`.
81
+
> The Go SDK does not bundle a CLI, so you must always provide `Connection`.
Copy file name to clipboardExpand all lines: go/README.md
+22-21Lines changed: 22 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -94,7 +94,7 @@ Follow these steps to embed the CLI:
94
94
1. Run `go get -tool github.com/github/copilot-sdk/go/cmd/bundler`. This is a one-time setup step per project.
95
95
2. Run `go tool bundler` in your build environment just before building your application.
96
96
97
-
That's it! When your application calls `copilot.NewClient` without a `CLIPath` nor the`COPILOT_CLI_PATH` environment variable, the SDK will automatically install the embedded CLI to a cache directory and use it for all operations.
97
+
That's it! When your application calls `copilot.NewClient` without a `Connection` field (or with an empty `StdioConnection{}`) and no`COPILOT_CLI_PATH` environment variable, the SDK will automatically install the embedded CLI to a cache directory and use it for all operations.
98
98
99
99
## API Reference
100
100
@@ -110,8 +110,8 @@ That's it! When your application calls `copilot.NewClient` without a `CLIPath` n
110
110
-`ListSessions(filter *SessionListFilter) ([]SessionMetadata, error)` - List sessions (with optional filter)
111
111
-`DeleteSession(sessionID string) error` - Delete a session permanently
112
112
-`GetLastSessionID(ctx context.Context) (*string, error)` - Get the ID of the most recently updated session
113
-
-`GetState() ConnectionState` - Get connection state
114
113
-`Ping(message string) (*PingResponse, error)` - Ping the server
114
+
-`RuntimePort() int` - TCP port the runtime is listening on (0 if stdio)
115
115
-`GetForegroundSessionID(ctx context.Context) (*string, error)` - Get the session ID currently displayed in TUI (TUI+server mode only)
116
116
-`SetForegroundSessionID(ctx context.Context, sessionID string) error` - Request TUI to display a specific session (TUI+server mode only)
117
117
-`On(handler SessionLifecycleHandler) func()` - Subscribe to all lifecycle events; returns unsubscribe function
-`CLIPath` (string): Path to CLI executable (default: "copilot" or `COPILOT_CLI_PATH` env var)
140
-
-`CLIUrl` (string): URL of existing CLI server (e.g., `"localhost:8080"`, `"http://127.0.0.1:9000"`, or just `"8080"`). When provided, the client will not spawn a CLI process.
141
-
-`Cwd` (string): Working directory for CLI process
142
-
-`CopilotHome` (string): Base directory for Copilot data (session state, config, etc.). Sets `COPILOT_HOME` on the spawned CLI process. When empty, the CLI defaults to `~/.copilot`. Useful in restricted environments where only specific directories are writable. Ignored when using `CLIUrl`. This does **not** affect where the Go SDK extracts the embedded CLI binary; use `embeddedcli.Config.Dir` for the extraction/cache location. You can vary `CopilotHome` per client independently of the shared extracted binary location.
143
-
-`Port` (int): Server port for TCP mode (default: 0 for random)
144
-
-`UseStdio` (bool): Use stdio transport instead of TCP (default: true)
145
-
-`LogLevel` (string): Log level (default: "info")
146
-
-`AutoStart` (\*bool): Auto-start server on first use (default: true). Use `Bool(false)` to disable.
147
-
-`Env` ([]string): Environment variables for CLI process (default: inherits from current process)
139
+
-`Connection` (RuntimeConnection): How the SDK connects to the runtime. Construct via one of:
140
+
-`StdioConnection{Path, Args}` — spawn a runtime over stdio (the default if `Connection` is nil)
141
+
-`TcpConnection{Port, ConnectionToken, Path, Args}` — spawn a runtime that listens on TCP
142
+
-`UriConnection{URL, ConnectionToken}` — connect to an already-running runtime (no process spawned)
143
+
144
+
When `Path` is empty for stdio/tcp, the SDK uses the bundled CLI (or `COPILOT_CLI_PATH` env var).
145
+
-`Cwd` (string): Working directory for the runtime process
146
+
-`BaseDirectory` (string): Base directory for Copilot data (session state, config, etc.). Sets `COPILOT_HOME` on the spawned runtime. When empty, the runtime defaults to `~/.copilot`. Ignored with `UriConnection`. This does **not** affect where the Go SDK extracts the embedded CLI binary; use `embeddedcli.Config.Dir` for the extraction/cache location.
147
+
-`LogLevel` (string): Log level. When empty (default), the runtime uses its own default level (the SDK does not pass `--log-level`).
148
+
-`Env` ([]string): Environment variables for the runtime process (default: inherits from current process)
148
149
-`GitHubToken` (string): GitHub token for authentication. When provided, takes priority over other auth methods.
149
-
-`UseLoggedInUser` (\*bool): Whether to use logged-in user for authentication (default: true, but false when `GitHubToken` is provided). Cannot be used with `CLIUrl`.
150
-
-`Telemetry` (\*TelemetryConfig): OpenTelemetry configuration for the CLI process. Providing this enables telemetry — no separate flag needed. See [Telemetry](#telemetry) below.
150
+
-`UseLoggedInUser` (\*bool): Whether to use logged-in user for authentication (default: true, but false when `GitHubToken` is provided). Cannot be used with `UriConnection`.
151
+
-`EnableRemoteSessions` (bool): Enable remote session support (Mission Control integration). Ignored with `UriConnection`.
152
+
-`Telemetry` (\*TelemetryConfig): OpenTelemetry configuration for the runtime. Providing this enables telemetry — no separate flag needed. See [Telemetry](#telemetry) below.
-`OnPermissionRequest` (PermissionHandlerFunc): Optional handler called before each tool execution to approve or deny it. When nil, permission requests are emitted as events and left pending for manual resolution. Use `copilot.PermissionHandler.ApproveAll` to allow everything, or provide a custom function for fine-grained control. See [Permission Handling](#permission-handling) section.
166
168
-`OnUserInputRequest` (UserInputHandler): Handler for user input requests from the agent (enables ask_user tool). See [User Input Requests](#user-input-requests) section.
0 commit comments