Go SDK API review fixes - #1360
Conversation
- 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>
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>
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>
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>
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>
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>
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>
This comment has been minimized.
This comment has been minimized.
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>
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR applies the cross-language (C# / TypeScript) API review decisions to the Go SDK, including the new discriminated RuntimeConnection configuration model, multiple naming/shape alignments, and synchronized updates across Go tests, scenarios, samples, and documentation.
Changes:
- Introduces
RuntimeConnection(StdioConnection/TcpConnection/UriConnection) and migrates callers away fromCLIPath/CLIUrl/UseStdio/Portfields. - Updates Go SDK API shapes for parity (e.g.,
Streaming *bool, hook timestamps totime.Time,GetMessages→GetEvents, provider/session fs renames). - Migrates Go E2E/unit tests, scenario apps, samples, and docs to the new API.
Show a summary per file
| File | Description |
|---|---|
| test/scenarios/transport/tcp/go/main.go | Updates scenario to use ClientOptions.Connection with UriConnection. |
| test/scenarios/transport/reconnect/go/main.go | Updates scenario to use ClientOptions.Connection with UriConnection. |
| test/scenarios/sessions/streaming/go/main.go | Updates scenario to use Streaming: copilot.Bool(true). |
| test/scenarios/bundling/container-proxy/go/main.go | Updates scenario to use ClientOptions.Connection with UriConnection. |
| test/scenarios/bundling/app-direct-server/go/main.go | Updates scenario to use ClientOptions.Connection with UriConnection. |
| test/scenarios/bundling/app-backend-to-server/go/main.go | Updates backend scenario to use ClientOptions.Connection with UriConnection. |
| go/types.go | Adds RuntimeConnection types; aligns config/event types (timestamps, streaming pointers, renames) and MCP tool-list tagging. |
| go/types_test.go | Updates provider-config JSON test for MaxPromptTokens. |
| go/session.go | Adds SendPrompt/SendPromptAndWait, renames APIs (GetEvents, handler types, UiInputOptions), removes deprecated Destroy. |
| go/session_fs_provider.go | Renames session fs provider methods and updates adapter to call renamed methods. |
| go/samples/manual_tool_resume/main.go | Migrates sample to StdioConnection{Path: ...}. |
| go/samples/chat.go | Migrates sample to StdioConnection{Path: ...}. |
| go/README.md | Documents new Connection model, RuntimePort, Streaming *bool, and related renames. |
| go/internal/e2e/testharness/helper.go | Migrates helper to GetEvents. |
| go/internal/e2e/testharness/context.go | Updates test harness default client options to use StdioConnection. |
| go/internal/e2e/suspend_e2e_test.go | Migrates suspend tests to UriConnection + connection token. |
| go/internal/e2e/streaming_fidelity_e2e_test.go | Migrates streaming tests to Streaming: copilot.Bool(...) and GetEvents. |
| go/internal/e2e/session_fs_sqlite_e2e_test.go | Migrates fs sqlite tests to renamed fs methods + CreateSessionFsProvider. |
| go/internal/e2e/session_fs_e2e_test.go | Migrates fs tests to new connection model, RuntimePort, renamed fs APIs, and GetEvents. |
| go/internal/e2e/session_e2e_test.go | Migrates session tests to GetEvents and time.Time metadata assertions. |
| go/internal/e2e/session_config_e2e_test.go | Migrates config tests to GetEvents. |
| go/internal/e2e/rpc_shell_and_fleet_e2e_test.go | Migrates polling logic to GetEvents. |
| go/internal/e2e/rpc_session_state_e2e_test.go | Migrates session state tests to GetEvents. |
| go/internal/e2e/rpc_mcp_and_skills_e2e_test.go | Updates CLI arg injection to flow via StdioConnection.Args. |
| go/internal/e2e/rpc_event_side_effects_e2e_test.go | Migrates event side-effect tests to GetEvents. |
| go/internal/e2e/rpc_e2e_test.go | Migrates RPC E2E tests to StdioConnection. |
| go/internal/e2e/per_session_auth_e2e_test.go | Migrates auth test client creation to StdioConnection. |
| go/internal/e2e/pending_work_resume_e2e_test.go | Migrates resume tests to UriConnection, RuntimePort, SuppressResumeEvent, GetEvents. |
| go/internal/e2e/multi_client_e2e_test.go | Migrates multi-client tests to TcpConnection/UriConnection and RuntimePort. |
| go/internal/e2e/mode_handlers_e2e_test.go | Migrates mode handler names to OnExitPlanModeRequest / OnAutoModeSwitchRequest. |
| go/internal/e2e/event_fidelity_e2e_test.go | Migrates fidelity checks to GetEvents and updated error messages. |
| go/internal/e2e/error_resilience_e2e_test.go | Migrates resilience checks to GetEvents. |
| go/internal/e2e/connection_token_test.go | Migrates token tests to TcpConnection/UriConnection and RuntimePort. |
| go/internal/e2e/commands_and_elicitation_e2e_test.go | Migrates commands/UI elicitation multi-client tests to new connection model and renames. |
| go/internal/e2e/client_options_e2e_test.go | Updates options tests to new connection model and removes state-based assertions. |
| go/internal/e2e/client_lifecycle_e2e_test.go | Removes state assertions after State() API removal. |
| go/internal/e2e/client_e2e_test.go | Migrates client E2E tests to new connection model and removes state assertions. |
| go/internal/e2e/agent_and_compact_rpc_e2e_test.go | Migrates agent-selection tests to StdioConnection. |
| go/internal/e2e/abort_e2e_test.go | Migrates abort test to Streaming: copilot.Bool(true). |
| go/client.go | Implements RuntimeConnection resolution, drops public state API, updates runtime spawning/args/log-level semantics. |
| go/client_test.go | Updates unit tests for new connection model (but currently has formatting issues). |
| docs/troubleshooting/debugging.md | Updates Go guidance to refer to Connection (UriConnection) (but still claims no extra-args support). |
| docs/setup/local-cli.md | Updates Go examples to Connection, but also changes some cross-language wording. |
| docs/setup/bundled-cli.md | Updates Go note to refer to Connection. |
| docs/setup/backend-services.md | Updates Go backend-services example to use UriConnection. |
| docs/getting-started.md | Updates Go examples to use Streaming: copilot.Bool(true) and UriConnection. |
| docs/features/streaming-events.md | Updates Go streaming example to use Streaming: copilot.Bool(true). |
Copilot's findings
Comments suppressed due to low confidence (1)
docs/setup/local-cli.md:16
- The prose here says Node.js/Python/.NET can override the bundled CLI using the
Connectionoption, but the Node and Python examples below still usecliPath/cli_path(and the diagram arrow is labeledcliPath). Consider rewording to be language-specific (e.g., Node:cliPath, Python:cli_path, .NET:Connection) to avoid confusing readers.
## How it works
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.
```mermaid
flowchart LR
subgraph YourMachine["Your Machine"]
App["Your App"] --> SDK["SDK Client"]
SDK -- "cliPath" --> CLI["Copilot CLI<br/>(your own binary)"]
CLI --> Keychain["🔐 System Keychain<br/>(stored credentials)"]
- Files reviewed: 47/47 changed files
- Comments generated: 4
| func TestClient_URLParsing(t *testing.T) { | ||
| t.Run("should parse port-only URL format", func(t *testing.T) { | ||
| client := NewClient(&ClientOptions{ | ||
| CLIUrl: "8080", | ||
| Connection: UriConnection{URL: "8080"}, | ||
| }) | ||
|
|
||
| if client.actualPort != 8080 { | ||
| t.Errorf("Expected port 8080, got %d", client.actualPort) | ||
| } |
This comment has been minimized.
This comment has been minimized.
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>
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>
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>
This comment has been minimized.
This comment has been minimized.
Cross-SDK Consistency ReviewThis PR applies the Go API review fixes in lockstep with C# (#1343) and TypeScript (#1357). Overall, the alignment is very strong — most renamed fields, config properties, and behavioral changes match exactly. ✅ Confirmed consistent with TypeScript and C#
|
There was a problem hiding this comment.
Generated by SDK Consistency Review Agent for issue #1360 · ● 2M
|
|
||
| // StdioConnection spawns a runtime child process and communicates over its | ||
| // stdin/stdout pipes. This is the default when no connection is configured. | ||
| type StdioConnection struct { |
There was a problem hiding this comment.
Cross-SDK naming note: The concrete connection struct names in Go (StdioConnection, TcpConnection, UriConnection) differ from the TypeScript and C# equivalents (StdioRuntimeConnection, TcpRuntimeConnection, UriRuntimeConnection).
Unlike TS/C# where users call factory functions (RuntimeConnection.forStdio(...), RuntimeConnection.ForStdio(...)) and rarely write the concrete type names, Go users will write these struct names directly in their code:
Connection: copilot.StdioConnection{Path: "..."}The shorter Go names are arguably cleaner (the interface is already RuntimeConnection), but it's worth noting this difference explicitly since it means a developer switching SDKs won't find a StdioRuntimeConnection in Go. The PR description doesn't call this out as a deliberate divergence — just flagging it for the team to decide if this is intentional.
The remote sessions guide told users to enable Mission Control remote sessions with a client option named `remote` (TypeScript) / `Remote` (Go, C#). No such option exists. It was renamed to `enableRemoteSessions` / `EnableRemoteSessions` during the per-language API reviews (github#1343, github#1357, github#1360), none of which updated this guide. The Rust (github#1367) and Python (github#1376) reviews did update their own tabs, which is why those two were already correct. As a result, the documented client construction does not compile in TypeScript, Go or C#. - Correct the option name in the section lead-in and in the TypeScript, Go and C# examples. - Fix the Go example's return arity on the same line: NewClient returns a single value. - Correct the Notes bullet, which named the same nonexistent option and also said the option applies only when the SDK spawns the CLI process. It is honored on both the child-process and in-process host paths. Co-authored-by: examon <examon@users.noreply.github.com>
* 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>
The remote sessions guide told users to enable Mission Control remote sessions with a client option named `remote` (TypeScript) / `Remote` (Go, C#). No such option exists. It was renamed to `enableRemoteSessions` / `EnableRemoteSessions` during the per-language API reviews (#1343, #1357, #1360), none of which updated this guide. The Rust (#1367) and Python (#1376) reviews did update their own tabs, which is why those two were already correct. As a result, the documented client construction does not compile in TypeScript, Go or C#. - Correct the option name in the section lead-in and in the TypeScript, Go and C# examples. - Fix the Go example's return arity on the same line: NewClient returns a single value. - Correct the Notes bullet, which named the same nonexistent option and also said the option applies only when the SDK spawns the CLI process. It is honored on both the child-process and in-process host paths. Co-authored-by: examon <examon@users.noreply.github.com>
* 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>
The remote sessions guide told users to enable Mission Control remote sessions with a client option named `remote` (TypeScript) / `Remote` (Go, C#). No such option exists. It was renamed to `enableRemoteSessions` / `EnableRemoteSessions` during the per-language API reviews (#1343, #1357, #1360), none of which updated this guide. The Rust (#1367) and Python (#1376) reviews did update their own tabs, which is why those two were already correct. As a result, the documented client construction does not compile in TypeScript, Go or C#. - Correct the option name in the section lead-in and in the TypeScript, Go and C# examples. - Fix the Go example's return arity on the same line: NewClient returns a single value. - Correct the Notes bullet, which named the same nonexistent option and also said the option applies only when the SDK spawns the CLI process. It is honored on both the child-process and in-process host paths. Co-authored-by: examon <examon@users.noreply.github.com>
Applies the equivalent of the C# (#1343) and TypeScript (#1357) API review fixes to the Go SDK, plus the Go-specific items from
api_review_go.md.This is a breaking-change PR by design, intentionally landed in one pass before the SDK is declared stable. All unit tests, e2e tests, samples, docs, and the Go scenario apps under
test/scenarios/**/gowere migrated in lockstep with the source changes. (E2E suites still need the local nodejs CLI install to actually run — they migrate cleanly but I haven't executed them locally.)Cross-language parity note for reviewers
Please assess consistency against C# and TypeScript only at this point. Python and Rust haven't been touched yet; once we're happy with the Go shape we'll port the equivalent changes there.
Phases
Each phase is a self-contained commit. After every phase:
go build ./... && go vet ./... && go test . ./rpc(andgo build ./...ingo/samples/and every scenariogo/).SessionConfig/ResumeSessionConfigrenamesOnExitPlanMode→OnExitPlanModeRequest,OnAutoModeSwitch→OnAutoModeSwitchRequestExitPlanModeHandler→ExitPlanModeRequestHandler,AutoModeSwitchHandler→AutoModeSwitchRequestHandlerSession.GetMessages→Session.GetEventsResumeSessionConfig.DisableResume→SuppressResumeEventStreaming bool→*boolon both configsProviderConfig.MaxInputTokens→MaxPromptTokens(matches the wire namemaxPromptTokens)MCPStdioServerConfig.Tools/MCPHTTPServerConfig.Tools: JSON tag →tools,omitempty.nilslice now means "all tools" (matches TS/C#).RuntimeConnectiondiscriminated config (the largest change)CLIPath/CLIArgs/CLIUrl/UseStdio/Port/TCPConnectionToken/AutoStart/AutoRestartonClientOptionswith a singleConnection RuntimeConnectionfield, constructed from one of:StdioConnection{Path, Args}TcpConnection{Port, ConnectionToken, Path, Args}UriConnection{URL, ConnectionToken}CopilotHome→BaseDirectoryRemote→EnableRemoteSessionsClient.ActualPort()→Client.RuntimePort()ConnectionState,State*constants,Client.State()— purely-internal state remainsLogLevelno longer defaults to"info": when empty, the SDK does not pass--log-levelto the runtime at all (matches TS).SessionMetadata/SessionLifecycleEventMetadata:StartTime/ModifiedTimestring→time.Time(wire is ISO 8601, parsed bytime.Time's default JSON unmarshal)Timestamp int64→time.Time, withMarshalJSON/UnmarshalJSONpairs that serialize to/from Unix milliseconds on the wireInputOptions→UiInputOptionsSession.SendPrompt(ctx, prompt)andSession.SendPromptAndWait(ctx, prompt)SessionFsProvidermethod renames (Go-specific):Mkdir→MakeDirectory,Readdir→ReadDirectory,ReaddirWithTypes→ReadDirectoryWithTypes,Rm→Remove. The adapter still implements the wire-protocol method names onrpc.SessionFsHandlerunchanged.CreateSessionFsHandlerfield →CreateSessionFsProviderSession.Destroy()(callers must useSession.Disconnect())Items explicitly NOT in this PR
Documented in the session plan:
func(...)— named handler types are idiomatic in Go and not noise the way C#delegatedeclarations are.SessionCreatedEventetc.) — keeping the flatSessionLifecycleEventwith aTypediscriminator. Without sum-type narrowing in Go, a discriminated interface adds friction (forced type-switches at every callsite) without changing the wire shape.LogLevelvalue-object — kept asstring(TS/Go), but did drop the"info"default as part of Phase D.AsyncDisposable— N/A;Disconnect()/Stop()are idiomatic._internalConnection/joinSession— feature not exposed in Go yet.Already correct (no change needed)
GitHubTokencasing, no"local"MCP alias, hidden session constructor, cleanStop()exit, MCP broadcast handling.