@github/copilot-sdk 1.0.29-preview.9 → 1.0.30-preview.0
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 +100 -7
- package/dist/cjs/cliVersion.js +1 -1
- package/dist/cjs/client.js +619 -93
- package/dist/cjs/decisions.js +139 -0
- package/dist/cjs/generated/rpc.js +164 -14
- package/dist/cjs/index.js +7 -0
- package/dist/cjs/session.js +102 -10
- package/dist/cliVersion.d.ts +1 -1
- package/dist/cliVersion.js +1 -1
- package/dist/client.d.ts +36 -3
- package/dist/client.js +621 -93
- package/dist/decisions.d.ts +65 -0
- package/dist/decisions.js +113 -0
- package/dist/generated/rpc.d.ts +1429 -127
- package/dist/generated/rpc.js +164 -14
- package/dist/generated/session-events.d.ts +213 -19
- package/dist/index.d.ts +4 -2
- package/dist/index.js +8 -0
- package/dist/session.d.ts +11 -2
- package/dist/session.js +102 -10
- package/dist/types.d.ts +141 -22
- package/docs/agent-author.md +5 -4
- package/docs/examples.md +77 -17
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -51,26 +51,41 @@ Configured BYOK and older, unattributed rows omit `provider`; do not infer Copil
|
|
|
51
51
|
branding from a model ID or fill it from the active account. This metadata identifies
|
|
52
52
|
the model source, not the agent harness, an account, or a new routing/selection API.
|
|
53
53
|
|
|
54
|
-
##
|
|
54
|
+
## Network callbacks (experimental)
|
|
55
55
|
|
|
56
|
-
Provide `
|
|
56
|
+
Provide `network` in `CopilotClientOptions` when the SDK host should take over parts of the runtime's networking, for example when the runtime runs in WSL or a container and should use VS Code's proxy settings and the host's Kerberos tickets. Registration happens during `start()`, before sessions can be created. Without this option, or for a callback you leave out, the runtime handles that part itself.
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
- `resolveProxy({ url }, signal)` decides the proxies for every request the runtime would otherwise route by ambient proxy settings: proxy environment variables, `NO_PROXY` and operating-system proxy settings are not consulted unless it returns `undefined`. `url` is the request target as a PAC script sees it: without credentials or fragment, and for `https` and `wss` also without path and query. Return a PAC-style list such as `PROXY proxy.example:8080; HTTPS proxy.example:443; DIRECT` (the format of Electron's `session.resolveProxy`); return `DIRECT` for a direct connection, or `undefined` to let the runtime resolve the proxy itself, as if no callback were registered. Entry types the runtime doesn't support, such as SOCKS and QUIC, are skipped. If the callback fails, the request fails rather than connecting directly. Requests to loopback targets, and requests with an explicitly configured proxy, never consult it. The runtime caches answers, including `undefined`, for 5 seconds and waits at most 10 seconds for the callback.
|
|
59
|
+
- `authenticateNegotiate({ spn }, signal)` supplies the Kerberos token for a proxy's Negotiate challenge instead of the runtime's native credential lookup. `spn` is a service principal in the platform-independent `service/host[@REALM]` form; validate it before issuing credentials. Return a fresh base64 SPNEGO token without the `Negotiate ` prefix, or `undefined` when credentials are unavailable, which fails the request. The runtime waits at most 30 seconds for the callback (less when the request's own deadline is sooner). Tokens are not cached and must not be logged or persisted. The callback supplies the initial SPNEGO token only; exchanges requiring continuation tokens are not supported. Proxies chosen by `resolveProxy` are authenticated the same way.
|
|
59
60
|
|
|
60
|
-
|
|
61
|
+
Each callback's `signal` aborts when the runtime stops waiting (it cancels the request, for example after its timeout, or the connection closes); the SDK then stops awaiting the callback and ignores any later result.
|
|
62
|
+
|
|
63
|
+
By default the callbacks serve only requests made for sessions this client creates or resumes. With `scope: "runtime"` they also serve the runtime's shared traffic, such as catalog refreshes, telemetry and remote MCP server connections; only one connection at a time can hold that scope, so startup fails if another client holds it. The registration ends when the connection closes.
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
const client = new CopilotClient({
|
|
67
|
+
network: {
|
|
68
|
+
scope: "runtime",
|
|
69
|
+
resolveProxy: async ({ url }) => session.resolveProxy(url),
|
|
70
|
+
authenticateNegotiate: async ({ spn }, signal) => acquireToken(spn, signal),
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
```
|
|
61
74
|
|
|
62
75
|
## Runtime-supervised AHP host (experimental)
|
|
63
76
|
|
|
64
77
|
`startAhpHost()` requires `authentication`: `github`, or direct-only `none` / `custom`
|
|
65
78
|
(`requireIdentity` and a validator returning `{identity,expiresAt}` or `null`):
|
|
66
79
|
|
|
80
|
+
<!-- docs-validate: strict -->
|
|
67
81
|
```typescript
|
|
68
82
|
import { CopilotClient } from "@github/copilot-sdk";
|
|
69
83
|
|
|
70
84
|
await using client = new CopilotClient();
|
|
71
85
|
await client.start();
|
|
72
86
|
const host = await client.startAhpHost({
|
|
73
|
-
localServer: {},
|
|
87
|
+
localServer: {},
|
|
88
|
+
authentication: { mode: "github" },
|
|
74
89
|
onExit: (exit) => {
|
|
75
90
|
if (exit.error) console.error(exit.error);
|
|
76
91
|
},
|
|
@@ -134,12 +149,14 @@ by the SDK. Published sessions remain discoverable after hosting stops.
|
|
|
134
149
|
|
|
135
150
|
Supply `createSession` to materialize fresh AHP sessions in your application:
|
|
136
151
|
|
|
152
|
+
<!-- docs-validate: strict -->
|
|
137
153
|
```typescript
|
|
138
154
|
import { approveAll, CopilotClient, defineTool } from "@github/copilot-sdk";
|
|
139
155
|
|
|
140
156
|
await using client = new CopilotClient();
|
|
141
157
|
await using host = await client.startAhpHost({
|
|
142
|
-
localServer: {},
|
|
158
|
+
localServer: {},
|
|
159
|
+
authentication: { mode: "github" },
|
|
143
160
|
createSession: ({ config, signal }) => {
|
|
144
161
|
signal.throwIfAborted();
|
|
145
162
|
return client.createSession({
|
|
@@ -219,6 +236,7 @@ npm start
|
|
|
219
236
|
## Quick Start
|
|
220
237
|
|
|
221
238
|
<!-- docs-validate: strict -->
|
|
239
|
+
|
|
222
240
|
```typescript
|
|
223
241
|
import { CopilotClient, approveAll } from "@github/copilot-sdk";
|
|
224
242
|
|
|
@@ -254,6 +272,7 @@ await client.stop();
|
|
|
254
272
|
Sessions also support `Symbol.asyncDispose` for use with [`await using`](https://github.com/tc39/proposal-explicit-resource-management) (TypeScript 5.2+ / Node.js 20+):
|
|
255
273
|
|
|
256
274
|
<!-- docs-validate: strict -->
|
|
275
|
+
|
|
257
276
|
```typescript
|
|
258
277
|
import { approveAll } from "@github/copilot-sdk";
|
|
259
278
|
|
|
@@ -417,6 +436,7 @@ Create a new conversation session.
|
|
|
417
436
|
- `onUserInputRequest?: UserInputHandler` - Handler for legacy question-and-answer requests from the agent. Enables the legacy `ask_user` tool. See [User Input Requests](#user-input-requests) section.
|
|
418
437
|
- `askUserVariant?: "legacy" | "elicitation"` - Selects the model-facing `ask_user` tool shape when creating or cold-resuming a session. Defaults to `"legacy"`; use `"elicitation"` with `onElicitationRequest`.
|
|
419
438
|
- `interactiveUser?: boolean` - Declares that a person types this session's messages, as in an editor chat panel. Enables the runtime's user-message analysis telemetry for user-authored messages; automated messages stay excluded. Defaults to `false`. Ignored for cloud sessions. Re-supply it when cold-resuming a session; it is ignored when resuming a session that is already active.
|
|
439
|
+
- `permissionMode?: PermissionMode` - Applies `"manual"`, `"assisted"`, or `"allow-all"` before the session's first turn: before `createSession` returns, and before a resume continues pending work. Uses the same checks as `session.rpc.permissions.setMode`; `session.permissionModeResult` reports whether it was applied and the authoritative mode. Not supported for cloud sessions.
|
|
420
440
|
- `onElicitationRequest?: ElicitationHandler` - Handler for elicitation requests dispatched by the server. Enables this client to present form-based UI dialogs on behalf of the agent or other session participants. See [Elicitation Requests](#elicitation-requests) section.
|
|
421
441
|
- `hooks?: SessionHooks` - Hook handlers for session lifecycle events. See [Session Hooks](#session-hooks) section.
|
|
422
442
|
- `skillProvider?: SkillProvider` - **Experimental.** Serves skills from host storage instead of skill directories. Not persisted; pass it again on resume. See [Skill providers](#skill-providers-experimental).
|
|
@@ -563,6 +583,7 @@ Send a message to the session. Returns immediately after the message is queued;
|
|
|
563
583
|
- `source?: MessageSource` - `"user"`, `"system"`, or `` `agent-${string}` `` provenance; omitted by default
|
|
564
584
|
- `attachments?: Array<{type, path, displayName}>` - File attachments
|
|
565
585
|
- `mode?: "enqueue" | "immediate"` - Delivery mode
|
|
586
|
+
- `clientTurnId?: string` - Opaque turn ID the runtime adds to MCP `tools/call` requests in this turn as `_meta["com.github.copilot/turnId"]` and echoes on this message's `user.message` event as `clientTurnId` (see [Tool call and turn IDs in `_meta`](../docs/hooks/pre-mcp-tool-call.md#tool-call-and-turn-ids-in-_meta))
|
|
566
587
|
|
|
567
588
|
Returns the message ID.
|
|
568
589
|
|
|
@@ -615,6 +636,7 @@ Sub-agent events are still delivered to listeners, but do not complete the wait
|
|
|
615
636
|
- `source?: MessageSource` - Same optional provenance as `send`
|
|
616
637
|
- `attachments?: Array<{type, path, displayName}>` - File attachments
|
|
617
638
|
- `mode?: "enqueue" | "immediate"` - Delivery mode
|
|
639
|
+
- `clientTurnId?: string` - Same optional turn ID as `send`
|
|
618
640
|
- `timeout?: number` - Optional timeout in milliseconds
|
|
619
641
|
|
|
620
642
|
Returns the final assistant message event, or undefined if none was received.
|
|
@@ -984,6 +1006,7 @@ The SDK supports image attachments via the `attachments` parameter. You can atta
|
|
|
984
1006
|
|
|
985
1007
|
<!-- docs-validate: strict -->
|
|
986
1008
|
<!-- docs-validate: hidden -->
|
|
1009
|
+
|
|
987
1010
|
```typescript
|
|
988
1011
|
import type { CopilotSession } from "@github/copilot-sdk";
|
|
989
1012
|
|
|
@@ -1013,7 +1036,9 @@ await session.send({
|
|
|
1013
1036
|
],
|
|
1014
1037
|
});
|
|
1015
1038
|
```
|
|
1039
|
+
|
|
1016
1040
|
<!-- /docs-validate: hidden -->
|
|
1041
|
+
|
|
1017
1042
|
```typescript
|
|
1018
1043
|
// File attachment — runtime reads from disk
|
|
1019
1044
|
await session.send({
|
|
@@ -1043,6 +1068,7 @@ Supported image formats are PNG, JPEG, WebP, and GIF. Images in other formats, s
|
|
|
1043
1068
|
|
|
1044
1069
|
<!-- docs-validate: strict -->
|
|
1045
1070
|
<!-- docs-validate: hidden -->
|
|
1071
|
+
|
|
1046
1072
|
```typescript
|
|
1047
1073
|
import type { CopilotSession } from "@github/copilot-sdk";
|
|
1048
1074
|
|
|
@@ -1050,7 +1076,9 @@ declare const session: CopilotSession;
|
|
|
1050
1076
|
|
|
1051
1077
|
await session.send({ prompt: "What does the most recent jpg in this directory portray?" });
|
|
1052
1078
|
```
|
|
1079
|
+
|
|
1053
1080
|
<!-- /docs-validate: hidden -->
|
|
1081
|
+
|
|
1054
1082
|
```typescript
|
|
1055
1083
|
await session.send({ prompt: "What does the most recent jpg in this directory portray?" });
|
|
1056
1084
|
```
|
|
@@ -1061,6 +1089,7 @@ Enable streaming to receive assistant response chunks as they're generated:
|
|
|
1061
1089
|
|
|
1062
1090
|
<!-- docs-validate: strict -->
|
|
1063
1091
|
<!-- docs-validate: hidden -->
|
|
1092
|
+
|
|
1064
1093
|
```typescript
|
|
1065
1094
|
import { approveAll } from "@github/copilot-sdk";
|
|
1066
1095
|
|
|
@@ -1103,7 +1132,9 @@ const done = new Promise<void>((resolve) => {
|
|
|
1103
1132
|
await session.send({ prompt: "Tell me a short story" });
|
|
1104
1133
|
await done; // Wait for streaming to complete
|
|
1105
1134
|
```
|
|
1135
|
+
|
|
1106
1136
|
<!-- /docs-validate: hidden -->
|
|
1137
|
+
|
|
1107
1138
|
```typescript
|
|
1108
1139
|
const session = await client.createSession({
|
|
1109
1140
|
model: "gpt-5",
|
|
@@ -1158,6 +1189,7 @@ Note: `assistant.message` and `assistant.reasoning` (final events) are always se
|
|
|
1158
1189
|
### Manual Server Control
|
|
1159
1190
|
|
|
1160
1191
|
<!-- docs-validate: strict -->
|
|
1192
|
+
|
|
1161
1193
|
```typescript
|
|
1162
1194
|
import { CopilotClient } from "@github/copilot-sdk";
|
|
1163
1195
|
|
|
@@ -1178,6 +1210,7 @@ You can let the CLI call back into your process when the model needs capabilitie
|
|
|
1178
1210
|
|
|
1179
1211
|
<!-- docs-validate: strict -->
|
|
1180
1212
|
<!-- docs-validate: hidden -->
|
|
1213
|
+
|
|
1181
1214
|
```ts
|
|
1182
1215
|
import { z } from "zod";
|
|
1183
1216
|
import { defineTool } from "@github/copilot-sdk";
|
|
@@ -1200,7 +1233,9 @@ const session = await client.createSession({
|
|
|
1200
1233
|
],
|
|
1201
1234
|
});
|
|
1202
1235
|
```
|
|
1236
|
+
|
|
1203
1237
|
<!-- /docs-validate: hidden -->
|
|
1238
|
+
|
|
1204
1239
|
```ts
|
|
1205
1240
|
import { z } from "zod";
|
|
1206
1241
|
import { CopilotClient, defineTool } from "@github/copilot-sdk";
|
|
@@ -1230,6 +1265,7 @@ If you register a tool with the same name as a built-in CLI tool (e.g. `edit_fil
|
|
|
1230
1265
|
|
|
1231
1266
|
<!-- docs-validate: strict -->
|
|
1232
1267
|
<!-- docs-validate: hidden -->
|
|
1268
|
+
|
|
1233
1269
|
```ts
|
|
1234
1270
|
import { z } from "zod";
|
|
1235
1271
|
import { defineTool } from "@github/copilot-sdk";
|
|
@@ -1243,7 +1279,9 @@ defineTool("edit_file", {
|
|
|
1243
1279
|
},
|
|
1244
1280
|
});
|
|
1245
1281
|
```
|
|
1282
|
+
|
|
1246
1283
|
<!-- /docs-validate: hidden -->
|
|
1284
|
+
|
|
1247
1285
|
```ts
|
|
1248
1286
|
defineTool("edit_file", {
|
|
1249
1287
|
description: "Custom file editor with project-specific validation",
|
|
@@ -1262,6 +1300,7 @@ dispatching to any SDK. Both a Zod-inferred Node handler and
|
|
|
1262
1300
|
|
|
1263
1301
|
<!-- docs-validate: strict -->
|
|
1264
1302
|
<!-- docs-validate: hidden -->
|
|
1303
|
+
|
|
1265
1304
|
```ts
|
|
1266
1305
|
import { z } from "zod";
|
|
1267
1306
|
import { defineTool } from "@github/copilot-sdk";
|
|
@@ -1272,7 +1311,9 @@ defineTool("apply_patch", {
|
|
|
1272
1311
|
handler: (patch) => patch.trim(),
|
|
1273
1312
|
});
|
|
1274
1313
|
```
|
|
1314
|
+
|
|
1275
1315
|
<!-- /docs-validate: hidden -->
|
|
1316
|
+
|
|
1276
1317
|
```ts
|
|
1277
1318
|
defineTool("apply_patch", {
|
|
1278
1319
|
parameters: z.string(),
|
|
@@ -1290,6 +1331,7 @@ Set `skipPermission: true` on a tool definition to allow it to execute without t
|
|
|
1290
1331
|
|
|
1291
1332
|
<!-- docs-validate: strict -->
|
|
1292
1333
|
<!-- docs-validate: hidden -->
|
|
1334
|
+
|
|
1293
1335
|
```ts
|
|
1294
1336
|
import { z } from "zod";
|
|
1295
1337
|
import { defineTool } from "@github/copilot-sdk";
|
|
@@ -1303,7 +1345,9 @@ defineTool("safe_lookup", {
|
|
|
1303
1345
|
},
|
|
1304
1346
|
});
|
|
1305
1347
|
```
|
|
1348
|
+
|
|
1306
1349
|
<!-- /docs-validate: hidden -->
|
|
1350
|
+
|
|
1307
1351
|
```ts
|
|
1308
1352
|
defineTool("safe_lookup", {
|
|
1309
1353
|
description: "A read-only lookup that needs no confirmation",
|
|
@@ -1321,6 +1365,7 @@ Set `defer` to control whether a tool may be loaded lazily via tool search rathe
|
|
|
1321
1365
|
|
|
1322
1366
|
<!-- docs-validate: strict -->
|
|
1323
1367
|
<!-- docs-validate: hidden -->
|
|
1368
|
+
|
|
1324
1369
|
```ts
|
|
1325
1370
|
import { z } from "zod";
|
|
1326
1371
|
import { defineTool } from "@github/copilot-sdk";
|
|
@@ -1334,7 +1379,9 @@ defineTool("lookup_issue", {
|
|
|
1334
1379
|
},
|
|
1335
1380
|
});
|
|
1336
1381
|
```
|
|
1382
|
+
|
|
1337
1383
|
<!-- /docs-validate: hidden -->
|
|
1384
|
+
|
|
1338
1385
|
```ts
|
|
1339
1386
|
defineTool("lookup_issue", {
|
|
1340
1387
|
description: "Fetch issue details",
|
|
@@ -1352,6 +1399,7 @@ Register slash commands so that users of the CLI's TUI can invoke custom actions
|
|
|
1352
1399
|
|
|
1353
1400
|
<!-- docs-validate: strict -->
|
|
1354
1401
|
<!-- docs-validate: hidden -->
|
|
1402
|
+
|
|
1355
1403
|
```ts
|
|
1356
1404
|
import { approveAll } from "@github/copilot-sdk";
|
|
1357
1405
|
|
|
@@ -1369,7 +1417,9 @@ const session = await client.createSession({
|
|
|
1369
1417
|
],
|
|
1370
1418
|
});
|
|
1371
1419
|
```
|
|
1420
|
+
|
|
1372
1421
|
<!-- /docs-validate: hidden -->
|
|
1422
|
+
|
|
1373
1423
|
```ts
|
|
1374
1424
|
const session = await client.createSession({
|
|
1375
1425
|
onPermissionRequest: approveAll,
|
|
@@ -1398,6 +1448,7 @@ When the session has elicitation support — either from the CLI's TUI or from a
|
|
|
1398
1448
|
|
|
1399
1449
|
<!-- docs-validate: strict -->
|
|
1400
1450
|
<!-- docs-validate: hidden -->
|
|
1451
|
+
|
|
1401
1452
|
```ts
|
|
1402
1453
|
import { approveAll } from "@github/copilot-sdk";
|
|
1403
1454
|
|
|
@@ -1433,7 +1484,9 @@ if (session.capabilities.ui?.elicitation) {
|
|
|
1433
1484
|
// result.content: { region: "us-east", dryRun: true } (when accepted)
|
|
1434
1485
|
}
|
|
1435
1486
|
```
|
|
1487
|
+
|
|
1436
1488
|
<!-- /docs-validate: hidden -->
|
|
1489
|
+
|
|
1437
1490
|
```ts
|
|
1438
1491
|
const session = await client.createSession({ onPermissionRequest: approveAll });
|
|
1439
1492
|
|
|
@@ -1475,6 +1528,7 @@ All UI methods throw if elicitation is not supported by the host.
|
|
|
1475
1528
|
Control the system prompt using `systemMessage` in session config:
|
|
1476
1529
|
|
|
1477
1530
|
<!-- docs-validate: strict -->
|
|
1531
|
+
|
|
1478
1532
|
```typescript
|
|
1479
1533
|
const session = await client.createSession({
|
|
1480
1534
|
model: "gpt-5",
|
|
@@ -1496,6 +1550,7 @@ The SDK auto-injects environment context, tool instructions, and security guardr
|
|
|
1496
1550
|
Use `mode: "customize"` to selectively override individual sections of the prompt while preserving the rest:
|
|
1497
1551
|
|
|
1498
1552
|
<!-- docs-validate: strict -->
|
|
1553
|
+
|
|
1499
1554
|
```typescript
|
|
1500
1555
|
import { SYSTEM_MESSAGE_SECTIONS } from "@github/copilot-sdk";
|
|
1501
1556
|
import type { SectionOverride, SystemMessageSection } from "@github/copilot-sdk";
|
|
@@ -1544,6 +1599,7 @@ Unknown section IDs are handled gracefully: content from `replace`/`append`/`pre
|
|
|
1544
1599
|
For full control (removes all guardrails), use `mode: "replace"`:
|
|
1545
1600
|
|
|
1546
1601
|
<!-- docs-validate: strict -->
|
|
1602
|
+
|
|
1547
1603
|
```typescript
|
|
1548
1604
|
const session = await client.createSession({
|
|
1549
1605
|
model: "gpt-5",
|
|
@@ -1560,6 +1616,7 @@ By default, sessions use **infinite sessions** which automatically manage contex
|
|
|
1560
1616
|
|
|
1561
1617
|
<!-- docs-validate: strict -->
|
|
1562
1618
|
<!-- docs-validate: hidden -->
|
|
1619
|
+
|
|
1563
1620
|
```typescript
|
|
1564
1621
|
// Default: infinite sessions enabled with default thresholds
|
|
1565
1622
|
const session = await client.createSession({ model: "gpt-5" });
|
|
@@ -1584,7 +1641,9 @@ const disabled = await client.createSession({
|
|
|
1584
1641
|
infiniteSessions: { enabled: false },
|
|
1585
1642
|
});
|
|
1586
1643
|
```
|
|
1644
|
+
|
|
1587
1645
|
<!-- /docs-validate: hidden -->
|
|
1646
|
+
|
|
1588
1647
|
```typescript
|
|
1589
1648
|
// Default: infinite sessions enabled with default thresholds
|
|
1590
1649
|
const session = await client.createSession({ model: "gpt-5" });
|
|
@@ -1626,6 +1685,7 @@ For more background, see [About GitHub Copilot Memory](https://docs.github.com/e
|
|
|
1626
1685
|
|
|
1627
1686
|
<!-- docs-validate: strict -->
|
|
1628
1687
|
<!-- docs-validate: hidden -->
|
|
1688
|
+
|
|
1629
1689
|
```typescript
|
|
1630
1690
|
// Enable memory for a session
|
|
1631
1691
|
const enabled = await client.createSession({
|
|
@@ -1639,7 +1699,9 @@ const disabled = await client.createSession({
|
|
|
1639
1699
|
memory: { enabled: false },
|
|
1640
1700
|
});
|
|
1641
1701
|
```
|
|
1702
|
+
|
|
1642
1703
|
<!-- /docs-validate: hidden -->
|
|
1704
|
+
|
|
1643
1705
|
```typescript
|
|
1644
1706
|
// Enable memory for a session
|
|
1645
1707
|
const enabled = await client.createSession({
|
|
@@ -1662,12 +1724,16 @@ files on disk. Provider skills join the session's skill catalog and load on dema
|
|
|
1662
1724
|
|
|
1663
1725
|
<!-- docs-validate: strict -->
|
|
1664
1726
|
<!-- docs-validate: hidden -->
|
|
1727
|
+
|
|
1665
1728
|
```typescript
|
|
1666
1729
|
import { approveAll } from "@github/copilot-sdk";
|
|
1667
1730
|
import type { SkillProvider } from "@github/copilot-sdk";
|
|
1668
1731
|
|
|
1669
1732
|
declare const db: {
|
|
1670
|
-
findSkill(
|
|
1733
|
+
findSkill(
|
|
1734
|
+
name: string,
|
|
1735
|
+
options: { signal: AbortSignal }
|
|
1736
|
+
): Promise<{ markdown: string } | undefined>;
|
|
1671
1737
|
};
|
|
1672
1738
|
|
|
1673
1739
|
const skillProvider: SkillProvider = {
|
|
@@ -1682,7 +1748,9 @@ const session = await client.createSession({
|
|
|
1682
1748
|
skillProvider,
|
|
1683
1749
|
});
|
|
1684
1750
|
```
|
|
1751
|
+
|
|
1685
1752
|
<!-- /docs-validate: hidden -->
|
|
1753
|
+
|
|
1686
1754
|
```typescript
|
|
1687
1755
|
import type { SkillProvider } from "@github/copilot-sdk";
|
|
1688
1756
|
|
|
@@ -1737,6 +1805,7 @@ See [Supporting files](../docs/features/skills.md#supporting-files-experimental)
|
|
|
1737
1805
|
### Multiple Sessions
|
|
1738
1806
|
|
|
1739
1807
|
<!-- docs-validate: strict -->
|
|
1808
|
+
|
|
1740
1809
|
```typescript
|
|
1741
1810
|
const session1 = await client.createSession({ model: "gpt-5" });
|
|
1742
1811
|
const session2 = await client.createSession({ model: "claude-sonnet-4.5" });
|
|
@@ -1749,6 +1818,7 @@ await session2.sendAndWait({ prompt: "Hello from session 2" });
|
|
|
1749
1818
|
### Custom Session IDs
|
|
1750
1819
|
|
|
1751
1820
|
<!-- docs-validate: strict -->
|
|
1821
|
+
|
|
1752
1822
|
```typescript
|
|
1753
1823
|
const session = await client.createSession({
|
|
1754
1824
|
sessionId: "my-custom-session-id",
|
|
@@ -1760,6 +1830,7 @@ const session = await client.createSession({
|
|
|
1760
1830
|
|
|
1761
1831
|
<!-- docs-validate: strict -->
|
|
1762
1832
|
<!-- docs-validate: hidden -->
|
|
1833
|
+
|
|
1763
1834
|
```typescript
|
|
1764
1835
|
import { approveAll } from "@github/copilot-sdk";
|
|
1765
1836
|
|
|
@@ -1776,7 +1847,9 @@ await session.send({
|
|
|
1776
1847
|
],
|
|
1777
1848
|
});
|
|
1778
1849
|
```
|
|
1850
|
+
|
|
1779
1851
|
<!-- /docs-validate: hidden -->
|
|
1852
|
+
|
|
1780
1853
|
```typescript
|
|
1781
1854
|
await session.send({
|
|
1782
1855
|
prompt: "Analyze this file",
|
|
@@ -1806,6 +1879,7 @@ The SDK supports custom OpenAI-compatible API providers (BYOK - Bring Your Own K
|
|
|
1806
1879
|
**Example with Ollama:**
|
|
1807
1880
|
|
|
1808
1881
|
<!-- docs-validate: strict -->
|
|
1882
|
+
|
|
1809
1883
|
```typescript
|
|
1810
1884
|
const session = await client.createSession({
|
|
1811
1885
|
model: "deepseek-coder-v2:16b", // Required when using custom provider
|
|
@@ -1822,6 +1896,7 @@ await session.sendAndWait({ prompt: "Hello!" });
|
|
|
1822
1896
|
**Example with custom OpenAI-compatible API:**
|
|
1823
1897
|
|
|
1824
1898
|
<!-- docs-validate: strict -->
|
|
1899
|
+
|
|
1825
1900
|
```typescript
|
|
1826
1901
|
const session = await client.createSession({
|
|
1827
1902
|
model: "gpt-4",
|
|
@@ -1836,6 +1911,7 @@ const session = await client.createSession({
|
|
|
1836
1911
|
**Example with Azure OpenAI:**
|
|
1837
1912
|
|
|
1838
1913
|
<!-- docs-validate: strict -->
|
|
1914
|
+
|
|
1839
1915
|
```typescript
|
|
1840
1916
|
const session = await client.createSession({
|
|
1841
1917
|
model: "gpt-4",
|
|
@@ -1861,6 +1937,7 @@ const session = await client.createSession({
|
|
|
1861
1937
|
The SDK supports OpenTelemetry for distributed tracing. Provide a `telemetry` config to enable trace export from the CLI process — this is all most users need:
|
|
1862
1938
|
|
|
1863
1939
|
<!-- docs-validate: strict -->
|
|
1940
|
+
|
|
1864
1941
|
```typescript
|
|
1865
1942
|
import { CopilotClient } from "@github/copilot-sdk";
|
|
1866
1943
|
|
|
@@ -1917,6 +1994,7 @@ Use the built-in `approveAll` helper when managed settings are disabled:
|
|
|
1917
1994
|
|
|
1918
1995
|
<!-- docs-validate: strict -->
|
|
1919
1996
|
<!-- docs-validate: hidden -->
|
|
1997
|
+
|
|
1920
1998
|
```typescript
|
|
1921
1999
|
import { approveAll } from "@github/copilot-sdk";
|
|
1922
2000
|
|
|
@@ -1925,7 +2003,9 @@ const session = await client.createSession({
|
|
|
1925
2003
|
onPermissionRequest: approveAll,
|
|
1926
2004
|
});
|
|
1927
2005
|
```
|
|
2006
|
+
|
|
1928
2007
|
<!-- /docs-validate: hidden -->
|
|
2008
|
+
|
|
1929
2009
|
```typescript
|
|
1930
2010
|
import { CopilotClient, approveAll } from "@github/copilot-sdk";
|
|
1931
2011
|
|
|
@@ -1942,6 +2022,7 @@ When `enableManagedSettings` is true for the session, `approveAll` throws. Use a
|
|
|
1942
2022
|
Provide your own function to inspect each request and apply custom logic. Check `managedApprovalRequired` before any automatic approval:
|
|
1943
2023
|
|
|
1944
2024
|
<!-- docs-validate: strict -->
|
|
2025
|
+
|
|
1945
2026
|
```typescript
|
|
1946
2027
|
import type { PermissionRequest, PermissionRequestResult } from "@github/copilot-sdk";
|
|
1947
2028
|
|
|
@@ -2017,6 +2098,7 @@ and sanitize `helpLink` before navigation.
|
|
|
2017
2098
|
|
|
2018
2099
|
<!-- docs-validate: strict -->
|
|
2019
2100
|
<!-- docs-validate: hidden -->
|
|
2101
|
+
|
|
2020
2102
|
```typescript
|
|
2021
2103
|
import type { CopilotSession } from "@github/copilot-sdk";
|
|
2022
2104
|
|
|
@@ -2034,7 +2116,9 @@ if (snapshot.policyHelperCapabilities?.recheck === true) {
|
|
|
2034
2116
|
console.log(refreshed.policyHelperFailure ?? "Policy Helper recovered");
|
|
2035
2117
|
}
|
|
2036
2118
|
```
|
|
2119
|
+
|
|
2037
2120
|
<!-- /docs-validate: hidden -->
|
|
2121
|
+
|
|
2038
2122
|
```typescript
|
|
2039
2123
|
const snapshot = await session.rpc.managedSettings.get();
|
|
2040
2124
|
|
|
@@ -2075,6 +2159,7 @@ You may pass `onPermissionRequest` when resuming a session too:
|
|
|
2075
2159
|
|
|
2076
2160
|
<!-- docs-validate: strict -->
|
|
2077
2161
|
<!-- docs-validate: hidden -->
|
|
2162
|
+
|
|
2078
2163
|
```typescript
|
|
2079
2164
|
import { approveAll } from "@github/copilot-sdk";
|
|
2080
2165
|
|
|
@@ -2082,7 +2167,9 @@ const session = await client.resumeSession("session-id", {
|
|
|
2082
2167
|
onPermissionRequest: approveAll,
|
|
2083
2168
|
});
|
|
2084
2169
|
```
|
|
2170
|
+
|
|
2085
2171
|
<!-- /docs-validate: hidden -->
|
|
2172
|
+
|
|
2086
2173
|
```typescript
|
|
2087
2174
|
const session = await client.resumeSession("session-id", {
|
|
2088
2175
|
onPermissionRequest: approveAll,
|
|
@@ -2098,6 +2185,7 @@ To let a specific custom tool bypass the permission prompt entirely, set `skipPe
|
|
|
2098
2185
|
Enable the legacy question-and-answer `ask_user` tool by providing an `onUserInputRequest` handler:
|
|
2099
2186
|
|
|
2100
2187
|
<!-- docs-validate: strict -->
|
|
2188
|
+
|
|
2101
2189
|
```typescript
|
|
2102
2190
|
const session = await client.createSession({
|
|
2103
2191
|
model: "gpt-5",
|
|
@@ -2126,6 +2214,7 @@ const session = await client.createSession({
|
|
|
2126
2214
|
Register an `onElicitationRequest` handler to let your client act as an elicitation provider — presenting form-based UI dialogs on behalf of the agent. When provided, the server notifies your client whenever a tool or MCP server needs structured user input.
|
|
2127
2215
|
|
|
2128
2216
|
<!-- docs-validate: strict -->
|
|
2217
|
+
|
|
2129
2218
|
```typescript
|
|
2130
2219
|
import { approveAll } from "@github/copilot-sdk";
|
|
2131
2220
|
|
|
@@ -2171,6 +2260,7 @@ Hook into session lifecycle events by providing handlers in the `hooks` configur
|
|
|
2171
2260
|
|
|
2172
2261
|
<!-- docs-validate: strict -->
|
|
2173
2262
|
<!-- docs-validate: hidden -->
|
|
2263
|
+
|
|
2174
2264
|
```typescript
|
|
2175
2265
|
declare function needsMoreWork(): boolean;
|
|
2176
2266
|
|
|
@@ -2262,7 +2352,9 @@ const session = await client.createSession({
|
|
|
2262
2352
|
},
|
|
2263
2353
|
});
|
|
2264
2354
|
```
|
|
2355
|
+
|
|
2265
2356
|
<!-- /docs-validate: hidden -->
|
|
2357
|
+
|
|
2266
2358
|
```typescript
|
|
2267
2359
|
const session = await client.createSession({
|
|
2268
2360
|
model: "gpt-5",
|
|
@@ -2369,6 +2461,7 @@ const session = await client.createSession({
|
|
|
2369
2461
|
## Error Handling
|
|
2370
2462
|
|
|
2371
2463
|
<!-- docs-validate: strict -->
|
|
2464
|
+
|
|
2372
2465
|
```typescript
|
|
2373
2466
|
try {
|
|
2374
2467
|
const session = await client.createSession({});
|
package/dist/cjs/cliVersion.js
CHANGED
|
@@ -22,7 +22,7 @@ __export(cliVersion_exports, {
|
|
|
22
22
|
COPILOT_CLI_VERSION: () => COPILOT_CLI_VERSION
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(cliVersion_exports);
|
|
25
|
-
const COPILOT_CLI_VERSION = "1.0.
|
|
25
|
+
const COPILOT_CLI_VERSION = "1.0.108-0";
|
|
26
26
|
const COPILOT_CLI_USE_NPM_PACKAGE = false;
|
|
27
27
|
// Annotate the CommonJS export names for ESM import in node:
|
|
28
28
|
0 && (module.exports = {
|