@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 +22 -23
- package/dist/cjs/client.js +193 -134
- package/dist/cjs/extension.js +2 -2
- package/dist/cjs/generated/rpc.js +13 -1
- package/dist/cjs/index.js +9 -6
- package/dist/cjs/session.js +17 -58
- package/dist/cjs/types.js +30 -0
- package/dist/client.d.ts +43 -23
- package/dist/client.js +193 -134
- package/dist/extension.js +2 -2
- package/dist/generated/rpc.d.ts +67 -57
- package/dist/generated/rpc.js +13 -1
- package/dist/generated/session-events.d.ts +25 -9
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -0
- package/dist/session.d.ts +5 -212
- package/dist/session.js +17 -58
- package/dist/types.d.ts +239 -112
- package/dist/types.js +29 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -79,18 +79,17 @@ new CopilotClient(options?: CopilotClientOptions)
|
|
|
79
79
|
|
|
80
80
|
**Options:**
|
|
81
81
|
|
|
82
|
-
- `
|
|
83
|
-
- `
|
|
84
|
-
- `
|
|
85
|
-
- `
|
|
86
|
-
- `
|
|
87
|
-
- `
|
|
88
|
-
- `
|
|
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 `
|
|
91
|
-
- `
|
|
92
|
-
- `
|
|
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.
|
|
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.
|
|
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
|
-
##### `
|
|
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({
|
|
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
|
|
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
|
|
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
|
|
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 `
|
|
1028
|
+
- GitHub Copilot CLI installed and in PATH (or provide a custom `connection`)
|
|
1030
1029
|
|
|
1031
1030
|
## License
|
|
1032
1031
|
|