@github/copilot-sdk 1.0.0-beta.5 → 1.0.0-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -79,18 +79,17 @@ new CopilotClient(options?: CopilotClientOptions)
79
79
 
80
80
  **Options:**
81
81
 
82
- - `cliPath?: string` - Path to CLI executable (default: uses COPILOT_CLI_PATH env var or bundled instance)
83
- - `cliArgs?: string[]` - Extra arguments prepended before SDK-managed flags (e.g. `["./dist-cli/index.js"]` when using `node`)
84
- - `cliUrl?: string` - URL of existing CLI server to connect to (e.g., `"localhost:8080"`, `"http://127.0.0.1:9000"`, or just `"8080"`). When provided, the client will not spawn a CLI process.
85
- - `port?: number` - Server port (default: 0 for random)
86
- - `useStdio?: boolean` - Use stdio transport instead of TCP (default: true)
87
- - `logLevel?: string` - Log level (default: "info")
88
- - `autoStart?: boolean` - Auto-start server (default: true)
82
+ - `connection?: RuntimeConnection` - How to connect to the Copilot runtime. Construct via the factory functions on `RuntimeConnection`:
83
+ - `RuntimeConnection.forStdio({ path?, args? })` (default) — spawn the runtime and communicate over its stdin/stdout.
84
+ - `RuntimeConnection.forTcp({ port?, connectionToken?, path?, args? })` — spawn the runtime as a TCP server.
85
+ - `RuntimeConnection.forUri(url, { connectionToken? })` — connect to an already-running runtime (mutually exclusive with `gitHubToken`/`useLoggedInUser`).
86
+ - `cwd?: string` - Working directory for the runtime process (default: current process cwd).
87
+ - `baseDirectory?: string` - Base directory for Copilot data (session state, config, etc.). Sets `COPILOT_HOME` on the spawned runtime. When not set, the runtime defaults to `~/.copilot`. Ignored when connecting via `RuntimeConnection.forUri`.
88
+ - `logLevel?: string` - Log level. When omitted, the runtime uses its own default (currently `"info"`).
89
89
  - `gitHubToken?: string` - GitHub token for authentication. When provided, takes priority over other auth methods.
90
- - `useLoggedInUser?: boolean` - Whether to use logged-in user for authentication (default: true, but false when `gitHubToken` is provided). Cannot be used with `cliUrl`.
91
- - `copilotHome?: string` - Base directory for Copilot data (session state, config, etc.). Sets `COPILOT_HOME` on the spawned CLI process. When not set, the CLI defaults to `~/.copilot`. Useful in restricted environments where only specific directories are writable. Ignored when using `cliUrl`.
92
- - `telemetry?: TelemetryConfig` - OpenTelemetry configuration for the CLI process. Providing this object enables telemetry — no separate flag needed. See [Telemetry](#telemetry) below.
93
- - `onGetTraceContext?: TraceContextProvider` - Advanced: callback for linking your application's own OpenTelemetry spans into the same distributed trace as the CLI's spans. Not needed for normal telemetry collection. See [Telemetry](#telemetry) below.
90
+ - `useLoggedInUser?: boolean` - Whether to use logged-in user for authentication (default: true, but false when `gitHubToken` is provided). Cannot be used with `RuntimeConnection.forUri`.
91
+ - `telemetry?: TelemetryConfig` - OpenTelemetry configuration for the runtime process. Providing this object enables telemetry — no separate flag needed. See [Telemetry](#telemetry) below.
92
+ - `onGetTraceContext?: TraceContextProvider` - Advanced: callback for linking your application's own OpenTelemetry spans into the same distributed trace as the runtime's spans. Not needed for normal telemetry collection. See [Telemetry](#telemetry) below.
94
93
 
95
94
  #### Methods
96
95
 
@@ -173,7 +172,7 @@ Request the TUI to switch to displaying the specified session. Only available in
173
172
  Subscribe to a specific session lifecycle event type. Returns an unsubscribe function.
174
173
 
175
174
  ```typescript
176
- const unsubscribe = client.on("session.foreground", (event) => {
175
+ const unsubscribe = client.onLifecycle("session.foreground", (event) => {
177
176
  console.log(`Session ${event.sessionId} is now in foreground`);
178
177
  });
179
178
  ```
@@ -183,7 +182,7 @@ const unsubscribe = client.on("session.foreground", (event) => {
183
182
  Subscribe to all session lifecycle events. Returns an unsubscribe function.
184
183
 
185
184
  ```typescript
186
- const unsubscribe = client.on((event) => {
185
+ const unsubscribe = client.onLifecycle((event) => {
187
186
  console.log(`${event.type}: ${event.sessionId}`);
188
187
  });
189
188
  ```
@@ -277,7 +276,7 @@ unsubscribe();
277
276
 
278
277
  Abort the currently processing message in this session.
279
278
 
280
- ##### `getMessages(): Promise<SessionEvent[]>`
279
+ ##### `getEvents(): Promise<SessionEvent[]>`
281
280
 
282
281
  Get all events/messages from this session.
283
282
 
@@ -415,7 +414,7 @@ Note: `assistant.message` and `assistant.reasoning` (final events) are always se
415
414
  ### Manual Server Control
416
415
 
417
416
  ```typescript
418
- const client = new CopilotClient({ autoStart: false });
417
+ const client = new CopilotClient({});
419
418
 
420
419
  // Start manually
421
420
  await client.start();
@@ -856,15 +855,15 @@ const session = await client.createSession({
856
855
 
857
856
  The handler must return one of the `PermissionDecision` shapes (or `{ kind: "no-result" }`). Approval scopes are present-tense — they describe the decision to apply, not the outcome reported back on session events:
858
857
 
859
- | Kind | Meaning | Extra fields |
860
- | ------------------------ | --------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
861
- | `"approve-once"` | Allow this single request | — |
862
- | `"approve-for-session"` | Allow this request and remember the approval for the rest of the session | `approval?` (rule to remember), `domain?` (for URL approvals) |
858
+ | Kind | Meaning | Extra fields |
859
+ | ------------------------ | -------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
860
+ | `"approve-once"` | Allow this single request | — |
861
+ | `"approve-for-session"` | Allow this request and remember the approval for the rest of the session | `approval?` (rule to remember), `domain?` (for URL approvals) |
863
862
  | `"approve-for-location"` | Allow this request and persist the approval for this project location (git root or cwd) | `approval` (rule to persist), `locationKey` (location to persist under) |
864
863
  | `"approve-permanently"` | Allow this request and persist the approval across sessions (currently used for URL domains) | `domain` (URL domain to approve) |
865
- | `"reject"` | Deny the request | `feedback?` (optional string surfaced to the agent) |
866
- | `"user-not-available"` | Deny the request because no user is available to confirm it | — |
867
- | `"no-result"` | Leave the request unanswered (only valid with protocol v1; rejected by protocol v2 servers) | — |
864
+ | `"reject"` | Deny the request | `feedback?` (optional string surfaced to the agent) |
865
+ | `"user-not-available"` | Deny the request because no user is available to confirm it | — |
866
+ | `"no-result"` | Leave the request unanswered (only valid with protocol v1; rejected by protocol v2 servers) | — |
868
867
 
869
868
  ### Resuming Sessions
870
869
 
@@ -1026,7 +1025,7 @@ try {
1026
1025
  ## Requirements
1027
1026
 
1028
1027
  - Node.js >= 18.0.0
1029
- - GitHub Copilot CLI installed and in PATH (or provide custom `cliPath`)
1028
+ - GitHub Copilot CLI installed and in PATH (or provide a custom `connection`)
1030
1029
 
1031
1030
  ## License
1032
1031