Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/auth/byok.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func main() {
Provider: &copilot.ProviderConfig{
Type: "openai",
BaseURL: "https://your-resource.openai.azure.com/openai/v1/",
WireApi: "responses", // Use "completions" for older models
WireAPI: "responses", // Use "completions" for older models
APIKey: os.Getenv("FOUNDRY_API_KEY"),
},
})
Expand Down
10 changes: 5 additions & 5 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -2000,9 +2000,9 @@ import (
func main() {
ctx := context.Background()

client := copilot.NewClient(&copilot.ClientOptions{
Connection: copilot.UriConnection{URL: "localhost:4321"},
})
client := copilot.NewClient(&copilot.ClientOptions{
Connection: copilot.URIConnection{URL: "localhost:4321"},
})

if err := client.Start(ctx); err != nil {
log.Fatal(err)
Expand All @@ -2021,7 +2021,7 @@ func main() {
import copilot "github.com/github/copilot-sdk/go"

client := copilot.NewClient(&copilot.ClientOptions{
Connection: copilot.UriConnection{URL: "localhost:4321"},
Connection: copilot.URIConnection{URL: "localhost:4321"},
})

if err := client.Start(ctx); err != nil {
Expand Down Expand Up @@ -2105,7 +2105,7 @@ var session = client.createSession(

</details>

**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.
**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.

## Telemetry and observability

Expand Down
10 changes: 5 additions & 5 deletions docs/setup/backend-services.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Run the Copilot SDK in server-side applications—APIs, web backends, microservi

## How it works

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`).
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`).

```mermaid
flowchart TB
Expand Down Expand Up @@ -183,9 +183,9 @@ func main() {
userID := "user1"
message := "Hello"

client := copilot.NewClient(&copilot.ClientOptions{
Connection: copilot.UriConnection{URL: "localhost:4321"},
})
client := copilot.NewClient(&copilot.ClientOptions{
Connection: copilot.URIConnection{URL: "localhost:4321"},
})
client.Start(ctx)
defer client.Stop()

Expand All @@ -202,7 +202,7 @@ func main() {

```go
client := copilot.NewClient(&copilot.ClientOptions{
Connection: copilot.UriConnection{URL: "localhost:4321"},
Connection: copilot.URIConnection{URL: "localhost:4321"},
})
client.Start(ctx)
defer client.Stop()
Expand Down
18 changes: 9 additions & 9 deletions docs/setup/multi-tenancy.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ func main() {
requestID := "req-1"
user := appUser{ID: "alice", GitHubToken: "gho_xxx"}

client := copilot.NewClient(&copilot.ClientOptions{
Mode: copilot.ModeEmpty,
BaseDirectory: fmt.Sprintf("/var/lib/my-app/copilot/%s", runtimeInstanceID),
SessionIdleTimeoutSeconds: 900,
Connection: copilot.UriConnection{URL: runtimeURL},
})
client := copilot.NewClient(&copilot.ClientOptions{
Mode: copilot.ModeEmpty,
BaseDirectory: fmt.Sprintf("/var/lib/my-app/copilot/%s", runtimeInstanceID),
SessionIdleTimeoutSeconds: 900,
Connection: copilot.URIConnection{URL: runtimeURL},
})

session, err := client.CreateSession(ctx, &copilot.SessionConfig{
SessionID: fmt.Sprintf("user-%s-%s", user.ID, requestID),
Expand All @@ -132,7 +132,7 @@ client := copilot.NewClient(&copilot.ClientOptions{
Mode: copilot.ModeEmpty,
BaseDirectory: fmt.Sprintf("/var/lib/my-app/copilot/%s", runtimeInstanceID),
SessionIdleTimeoutSeconds: 900,
Connection: copilot.UriConnection{URL: runtimeURL},
Connection: copilot.URIConnection{URL: runtimeURL},
})

session, err := client.CreateSession(ctx, &copilot.SessionConfig{
Expand Down Expand Up @@ -338,7 +338,7 @@ Verified public SDK surfaces:
|----------|---------------------|----------------------|
| TypeScript | `sessionFs` | `createSessionFsAdapter` / provider callbacks |
| Python | `session_fs` | `create_session_fs_handler` |
| Go | `SessionFs` | `CreateSessionFsProvider` |
| Go | `SessionFS` | `CreateSessionFSProvider` |
| .NET | `SessionFs` | `CreateSessionFsProvider` |
| Rust | `with_session_fs(...)` | `with_session_fs_provider(...)` |

Expand All @@ -352,7 +352,7 @@ Use an external runtime connection when multiple SDK clients should share one al
|----------|-----------------------------|
| TypeScript | `RuntimeConnection.forUri(url)` |
| Python | `RuntimeConnection.for_uri(url)` |
| Go | `copilot.UriConnection{URL: url}` |
| Go | `copilot.URIConnection{URL: url}` |
| .NET | `RuntimeConnection.ForUri(url)` |
| Java | `setCliUrl(url)` |
| Rust | `Transport::External { host, port, connection_token }` |
Expand Down
14 changes: 7 additions & 7 deletions go/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,17 @@ Event types: `SessionLifecycleCreated`, `SessionLifecycleDeleted`, `SessionLifec

- `Connection` (RuntimeConnection): How the SDK connects to the runtime. Construct via one of:
- `StdioConnection{Path, Args}` — spawn a runtime over stdio (the default if `Connection` is nil)
- `TcpConnection{Port, ConnectionToken, Path, Args}` — spawn a runtime that listens on TCP
- `UriConnection{URL, ConnectionToken}` — connect to an already-running runtime (no process spawned)
- `TCPConnection{Port, ConnectionToken, Path, Args}` — spawn a runtime that listens on TCP
- `URIConnection{URL, ConnectionToken}` — connect to an already-running runtime (no process spawned)

When `Path` is empty for stdio/tcp, the SDK uses the bundled CLI (or `COPILOT_CLI_PATH` env var).
- `WorkingDirectory` (string): Working directory for the runtime process
- `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.
- `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.
- `LogLevel` (string): Log level. When empty (default), the runtime uses its own default level (the SDK does not pass `--log-level`).
- `Env` ([]string): Environment variables for the runtime process (default: inherits from current process)
- `GitHubToken` (string): GitHub token for authentication. When provided, takes priority over other auth methods.
- `UseLoggedInUser` (\*bool): Whether to use logged-in user for authentication (default: true, but false when `GitHubToken` is provided). Cannot be used with `UriConnection`.
- `EnableRemoteSessions` (bool): Enable remote session support (Mission Control integration). Ignored with `UriConnection`.
- `UseLoggedInUser` (\*bool): Whether to use logged-in user for authentication (default: true, but false when `GitHubToken` is provided). Cannot be used with `URIConnection`.
- `EnableRemoteSessions` (bool): Enable remote session support (Mission Control integration). Ignored with `URIConnection`.
- `Telemetry` (\*TelemetryConfig): OpenTelemetry configuration for the runtime. Providing this enables telemetry — no separate flag needed. See [Telemetry](#telemetry) below.

**SessionConfig:**
Expand Down Expand Up @@ -495,7 +495,7 @@ The SDK supports custom OpenAI-compatible API providers (BYOK - Bring Your Own K
- `BaseURL` (string): API endpoint URL (required)
- `APIKey` (string): API key (optional for local providers like Ollama)
- `BearerToken` (string): Bearer token for authentication (takes precedence over APIKey)
- `WireApi` (string): API format for OpenAI/Azure - "completions" or "responses" (default: "completions")
- `WireAPI` (string): API format for OpenAI/Azure - "completions" or "responses" (default: "completions")
- `Azure.APIVersion` (string): Azure API version (default: "2024-10-21")

**Example with Ollama:**
Expand Down Expand Up @@ -802,7 +802,7 @@ confirmed, err := ui.Confirm(ctx, "Deploy to production?")
choice, ok, err := ui.Select(ctx, "Pick an environment", []string{"staging", "production"})

// Text input — returns (text, ok bool, error)
name, ok, err := ui.Input(ctx, "Enter the release name", &copilot.UiInputOptions{
name, ok, err := ui.Input(ctx, "Enter the release name", &copilot.UIInputOptions{
Title: "Release Name",
Description: "A short name for the release",
MinLength: copilot.Int(1),
Expand Down
22 changes: 11 additions & 11 deletions go/canvas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func TestCanvasAdapter_DispatchesToHandler(t *testing.T) {
session := newTestCanvasSession("s1")
session.registerCanvasHandler(handler)

openResp, err := session.clientSessionApis.Canvas.Open(&rpc.CanvasProviderOpenRequest{
openResp, err := session.clientSessionAPIs.Canvas.Open(&rpc.CanvasProviderOpenRequest{
SessionID: "s1",
ExtensionID: "project:echo",
CanvasID: "echo",
Expand All @@ -156,7 +156,7 @@ func TestCanvasAdapter_DispatchesToHandler(t *testing.T) {
t.Fatalf("response URL not propagated: %+v", openResp)
}

actionResp, err := session.clientSessionApis.Canvas.Invoke(&rpc.CanvasProviderInvokeActionRequest{
actionResp, err := session.clientSessionAPIs.Canvas.Invoke(&rpc.CanvasProviderInvokeActionRequest{
SessionID: "s1",
ExtensionID: "project:echo",
CanvasID: "echo",
Expand All @@ -178,7 +178,7 @@ func TestCanvasAdapter_DispatchesToHandler(t *testing.T) {
t.Fatalf("unexpected action result: %#v", actionResp)
}

closeResp, err := session.clientSessionApis.Canvas.Close(&rpc.CanvasProviderCloseRequest{
closeResp, err := session.clientSessionAPIs.Canvas.Close(&rpc.CanvasProviderCloseRequest{
SessionID: "s1",
ExtensionID: "project:echo",
CanvasID: "echo",
Expand All @@ -198,7 +198,7 @@ func TestCanvasAdapter_DispatchesToHandler(t *testing.T) {
func TestCanvasAdapter_NoHandler_ReturnsUnsetError(t *testing.T) {
session := newTestCanvasSession("s1")

_, err := session.clientSessionApis.Canvas.Open(&rpc.CanvasProviderOpenRequest{SessionID: "s1"})
_, err := session.clientSessionAPIs.Canvas.Open(&rpc.CanvasProviderOpenRequest{SessionID: "s1"})
assertCanvasJSONRPCError(t, err, "canvas_handler_unset", "")
}

Expand All @@ -208,7 +208,7 @@ func TestCanvasAdapter_HandlerCanvasError_Wired(t *testing.T) {
openErr: NewCanvasError("permission_denied", "nope"),
})

_, err := session.clientSessionApis.Canvas.Open(&rpc.CanvasProviderOpenRequest{SessionID: "s1"})
_, err := session.clientSessionAPIs.Canvas.Open(&rpc.CanvasProviderOpenRequest{SessionID: "s1"})
assertCanvasJSONRPCError(t, err, "permission_denied", "nope")
}

Expand All @@ -218,11 +218,11 @@ func TestCanvasAdapter_HandlerGenericError_WrappedAsCanvasHandlerError(t *testin
openErr: errors.New("boom"),
})

_, err := session.clientSessionApis.Canvas.Open(&rpc.CanvasProviderOpenRequest{SessionID: "s1"})
_, err := session.clientSessionAPIs.Canvas.Open(&rpc.CanvasProviderOpenRequest{SessionID: "s1"})
assertCanvasJSONRPCError(t, err, "canvas_handler_error", "boom")
}

func TestCanvasRegisterClientSessionApiHandlers_RawJSONRoundTrip(t *testing.T) {
func TestCanvasRegisterClientSessionAPIHandlers_RawJSONRoundTrip(t *testing.T) {
clientToServerReader, clientToServerWriter := io.Pipe()
serverToClientReader, serverToClientWriter := io.Pipe()

Expand All @@ -233,9 +233,9 @@ func TestCanvasRegisterClientSessionApiHandlers_RawJSONRoundTrip(t *testing.T) {
openResult: rpc.CanvasProviderOpenResult{Status: strPtr("ready")},
actionResult: map[string]any{"count": float64(2)},
})
rpc.RegisterClientSessionApiHandlers(server, func(sessionID string) *rpc.ClientSessionApiHandlers {
rpc.RegisterClientSessionAPIHandlers(server, func(sessionID string) *rpc.ClientSessionAPIHandlers {
if sessionID == "s1" {
return session.clientSessionApis
return session.clientSessionAPIs
}
return nil
})
Expand Down Expand Up @@ -417,9 +417,9 @@ func assertCanvasJSONRPCError(t *testing.T, err error, wantCode, wantMessage str
func newTestCanvasSession(sessionID string) *Session {
session := &Session{
SessionID: sessionID,
clientSessionApis: &rpc.ClientSessionApiHandlers{},
clientSessionAPIs: &rpc.ClientSessionAPIHandlers{},
}
session.clientSessionApis.Canvas = newCanvasClientSessionAdapter(session)
session.clientSessionAPIs.Canvas = newCanvasClientSessionAdapter(session)
return session
}

Expand Down
Loading
Loading