@github/copilot-sdk 1.0.29 → 1.0.30-preview.1
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 +98 -7
- package/dist/cjs/cliVersion.js +1 -1
- package/dist/cjs/client.js +651 -96
- 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 +113 -9
- package/dist/cliVersion.d.ts +1 -1
- package/dist/cliVersion.js +1 -1
- package/dist/client.d.ts +38 -3
- package/dist/client.js +653 -96
- package/dist/decisions.d.ts +65 -0
- package/dist/decisions.js +113 -0
- package/dist/generated/rpc.d.ts +1432 -130
- 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 +12 -2
- package/dist/session.js +113 -9
- package/dist/types.d.ts +143 -28
- package/docs/agent-author.md +1 -1
- package/docs/examples.md +77 -17
- package/package.json +14 -13
package/README.md
CHANGED
|
@@ -51,13 +51,26 @@ 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
|
|
|
@@ -71,7 +84,8 @@ import { CopilotClient } from "@github/copilot-sdk";
|
|
|
71
84
|
await using client = new CopilotClient();
|
|
72
85
|
await client.start();
|
|
73
86
|
const host = await client.startAhpHost({
|
|
74
|
-
localServer: {},
|
|
87
|
+
localServer: {},
|
|
88
|
+
authentication: { mode: "github" },
|
|
75
89
|
onExit: (exit) => {
|
|
76
90
|
if (exit.error) console.error(exit.error);
|
|
77
91
|
},
|
|
@@ -141,7 +155,8 @@ import { approveAll, CopilotClient, defineTool } from "@github/copilot-sdk";
|
|
|
141
155
|
|
|
142
156
|
await using client = new CopilotClient();
|
|
143
157
|
await using host = await client.startAhpHost({
|
|
144
|
-
localServer: {},
|
|
158
|
+
localServer: {},
|
|
159
|
+
authentication: { mode: "github" },
|
|
145
160
|
createSession: ({ config, signal }) => {
|
|
146
161
|
signal.throwIfAborted();
|
|
147
162
|
return client.createSession({
|
|
@@ -221,6 +236,7 @@ npm start
|
|
|
221
236
|
## Quick Start
|
|
222
237
|
|
|
223
238
|
<!-- docs-validate: strict -->
|
|
239
|
+
|
|
224
240
|
```typescript
|
|
225
241
|
import { CopilotClient, approveAll } from "@github/copilot-sdk";
|
|
226
242
|
|
|
@@ -256,6 +272,7 @@ await client.stop();
|
|
|
256
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+):
|
|
257
273
|
|
|
258
274
|
<!-- docs-validate: strict -->
|
|
275
|
+
|
|
259
276
|
```typescript
|
|
260
277
|
import { approveAll } from "@github/copilot-sdk";
|
|
261
278
|
|
|
@@ -419,6 +436,7 @@ Create a new conversation session.
|
|
|
419
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.
|
|
420
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`.
|
|
421
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.
|
|
422
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.
|
|
423
441
|
- `hooks?: SessionHooks` - Hook handlers for session lifecycle events. See [Session Hooks](#session-hooks) section.
|
|
424
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).
|
|
@@ -565,6 +583,7 @@ Send a message to the session. Returns immediately after the message is queued;
|
|
|
565
583
|
- `source?: MessageSource` - `"user"`, `"system"`, or `` `agent-${string}` `` provenance; omitted by default
|
|
566
584
|
- `attachments?: Array<{type, path, displayName}>` - File attachments
|
|
567
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))
|
|
568
587
|
|
|
569
588
|
Returns the message ID.
|
|
570
589
|
|
|
@@ -617,6 +636,7 @@ Sub-agent events are still delivered to listeners, but do not complete the wait
|
|
|
617
636
|
- `source?: MessageSource` - Same optional provenance as `send`
|
|
618
637
|
- `attachments?: Array<{type, path, displayName}>` - File attachments
|
|
619
638
|
- `mode?: "enqueue" | "immediate"` - Delivery mode
|
|
639
|
+
- `clientTurnId?: string` - Same optional turn ID as `send`
|
|
620
640
|
- `timeout?: number` - Optional timeout in milliseconds
|
|
621
641
|
|
|
622
642
|
Returns the final assistant message event, or undefined if none was received.
|
|
@@ -986,6 +1006,7 @@ The SDK supports image attachments via the `attachments` parameter. You can atta
|
|
|
986
1006
|
|
|
987
1007
|
<!-- docs-validate: strict -->
|
|
988
1008
|
<!-- docs-validate: hidden -->
|
|
1009
|
+
|
|
989
1010
|
```typescript
|
|
990
1011
|
import type { CopilotSession } from "@github/copilot-sdk";
|
|
991
1012
|
|
|
@@ -1015,7 +1036,9 @@ await session.send({
|
|
|
1015
1036
|
],
|
|
1016
1037
|
});
|
|
1017
1038
|
```
|
|
1039
|
+
|
|
1018
1040
|
<!-- /docs-validate: hidden -->
|
|
1041
|
+
|
|
1019
1042
|
```typescript
|
|
1020
1043
|
// File attachment — runtime reads from disk
|
|
1021
1044
|
await session.send({
|
|
@@ -1045,6 +1068,7 @@ Supported image formats are PNG, JPEG, WebP, and GIF. Images in other formats, s
|
|
|
1045
1068
|
|
|
1046
1069
|
<!-- docs-validate: strict -->
|
|
1047
1070
|
<!-- docs-validate: hidden -->
|
|
1071
|
+
|
|
1048
1072
|
```typescript
|
|
1049
1073
|
import type { CopilotSession } from "@github/copilot-sdk";
|
|
1050
1074
|
|
|
@@ -1052,7 +1076,9 @@ declare const session: CopilotSession;
|
|
|
1052
1076
|
|
|
1053
1077
|
await session.send({ prompt: "What does the most recent jpg in this directory portray?" });
|
|
1054
1078
|
```
|
|
1079
|
+
|
|
1055
1080
|
<!-- /docs-validate: hidden -->
|
|
1081
|
+
|
|
1056
1082
|
```typescript
|
|
1057
1083
|
await session.send({ prompt: "What does the most recent jpg in this directory portray?" });
|
|
1058
1084
|
```
|
|
@@ -1063,6 +1089,7 @@ Enable streaming to receive assistant response chunks as they're generated:
|
|
|
1063
1089
|
|
|
1064
1090
|
<!-- docs-validate: strict -->
|
|
1065
1091
|
<!-- docs-validate: hidden -->
|
|
1092
|
+
|
|
1066
1093
|
```typescript
|
|
1067
1094
|
import { approveAll } from "@github/copilot-sdk";
|
|
1068
1095
|
|
|
@@ -1105,7 +1132,9 @@ const done = new Promise<void>((resolve) => {
|
|
|
1105
1132
|
await session.send({ prompt: "Tell me a short story" });
|
|
1106
1133
|
await done; // Wait for streaming to complete
|
|
1107
1134
|
```
|
|
1135
|
+
|
|
1108
1136
|
<!-- /docs-validate: hidden -->
|
|
1137
|
+
|
|
1109
1138
|
```typescript
|
|
1110
1139
|
const session = await client.createSession({
|
|
1111
1140
|
model: "gpt-5",
|
|
@@ -1160,6 +1189,7 @@ Note: `assistant.message` and `assistant.reasoning` (final events) are always se
|
|
|
1160
1189
|
### Manual Server Control
|
|
1161
1190
|
|
|
1162
1191
|
<!-- docs-validate: strict -->
|
|
1192
|
+
|
|
1163
1193
|
```typescript
|
|
1164
1194
|
import { CopilotClient } from "@github/copilot-sdk";
|
|
1165
1195
|
|
|
@@ -1180,6 +1210,7 @@ You can let the CLI call back into your process when the model needs capabilitie
|
|
|
1180
1210
|
|
|
1181
1211
|
<!-- docs-validate: strict -->
|
|
1182
1212
|
<!-- docs-validate: hidden -->
|
|
1213
|
+
|
|
1183
1214
|
```ts
|
|
1184
1215
|
import { z } from "zod";
|
|
1185
1216
|
import { defineTool } from "@github/copilot-sdk";
|
|
@@ -1202,7 +1233,9 @@ const session = await client.createSession({
|
|
|
1202
1233
|
],
|
|
1203
1234
|
});
|
|
1204
1235
|
```
|
|
1236
|
+
|
|
1205
1237
|
<!-- /docs-validate: hidden -->
|
|
1238
|
+
|
|
1206
1239
|
```ts
|
|
1207
1240
|
import { z } from "zod";
|
|
1208
1241
|
import { CopilotClient, defineTool } from "@github/copilot-sdk";
|
|
@@ -1232,6 +1265,7 @@ If you register a tool with the same name as a built-in CLI tool (e.g. `edit_fil
|
|
|
1232
1265
|
|
|
1233
1266
|
<!-- docs-validate: strict -->
|
|
1234
1267
|
<!-- docs-validate: hidden -->
|
|
1268
|
+
|
|
1235
1269
|
```ts
|
|
1236
1270
|
import { z } from "zod";
|
|
1237
1271
|
import { defineTool } from "@github/copilot-sdk";
|
|
@@ -1245,7 +1279,9 @@ defineTool("edit_file", {
|
|
|
1245
1279
|
},
|
|
1246
1280
|
});
|
|
1247
1281
|
```
|
|
1282
|
+
|
|
1248
1283
|
<!-- /docs-validate: hidden -->
|
|
1284
|
+
|
|
1249
1285
|
```ts
|
|
1250
1286
|
defineTool("edit_file", {
|
|
1251
1287
|
description: "Custom file editor with project-specific validation",
|
|
@@ -1264,6 +1300,7 @@ dispatching to any SDK. Both a Zod-inferred Node handler and
|
|
|
1264
1300
|
|
|
1265
1301
|
<!-- docs-validate: strict -->
|
|
1266
1302
|
<!-- docs-validate: hidden -->
|
|
1303
|
+
|
|
1267
1304
|
```ts
|
|
1268
1305
|
import { z } from "zod";
|
|
1269
1306
|
import { defineTool } from "@github/copilot-sdk";
|
|
@@ -1274,7 +1311,9 @@ defineTool("apply_patch", {
|
|
|
1274
1311
|
handler: (patch) => patch.trim(),
|
|
1275
1312
|
});
|
|
1276
1313
|
```
|
|
1314
|
+
|
|
1277
1315
|
<!-- /docs-validate: hidden -->
|
|
1316
|
+
|
|
1278
1317
|
```ts
|
|
1279
1318
|
defineTool("apply_patch", {
|
|
1280
1319
|
parameters: z.string(),
|
|
@@ -1292,6 +1331,7 @@ Set `skipPermission: true` on a tool definition to allow it to execute without t
|
|
|
1292
1331
|
|
|
1293
1332
|
<!-- docs-validate: strict -->
|
|
1294
1333
|
<!-- docs-validate: hidden -->
|
|
1334
|
+
|
|
1295
1335
|
```ts
|
|
1296
1336
|
import { z } from "zod";
|
|
1297
1337
|
import { defineTool } from "@github/copilot-sdk";
|
|
@@ -1305,7 +1345,9 @@ defineTool("safe_lookup", {
|
|
|
1305
1345
|
},
|
|
1306
1346
|
});
|
|
1307
1347
|
```
|
|
1348
|
+
|
|
1308
1349
|
<!-- /docs-validate: hidden -->
|
|
1350
|
+
|
|
1309
1351
|
```ts
|
|
1310
1352
|
defineTool("safe_lookup", {
|
|
1311
1353
|
description: "A read-only lookup that needs no confirmation",
|
|
@@ -1323,6 +1365,7 @@ Set `defer` to control whether a tool may be loaded lazily via tool search rathe
|
|
|
1323
1365
|
|
|
1324
1366
|
<!-- docs-validate: strict -->
|
|
1325
1367
|
<!-- docs-validate: hidden -->
|
|
1368
|
+
|
|
1326
1369
|
```ts
|
|
1327
1370
|
import { z } from "zod";
|
|
1328
1371
|
import { defineTool } from "@github/copilot-sdk";
|
|
@@ -1336,7 +1379,9 @@ defineTool("lookup_issue", {
|
|
|
1336
1379
|
},
|
|
1337
1380
|
});
|
|
1338
1381
|
```
|
|
1382
|
+
|
|
1339
1383
|
<!-- /docs-validate: hidden -->
|
|
1384
|
+
|
|
1340
1385
|
```ts
|
|
1341
1386
|
defineTool("lookup_issue", {
|
|
1342
1387
|
description: "Fetch issue details",
|
|
@@ -1354,6 +1399,7 @@ Register slash commands so that users of the CLI's TUI can invoke custom actions
|
|
|
1354
1399
|
|
|
1355
1400
|
<!-- docs-validate: strict -->
|
|
1356
1401
|
<!-- docs-validate: hidden -->
|
|
1402
|
+
|
|
1357
1403
|
```ts
|
|
1358
1404
|
import { approveAll } from "@github/copilot-sdk";
|
|
1359
1405
|
|
|
@@ -1371,7 +1417,9 @@ const session = await client.createSession({
|
|
|
1371
1417
|
],
|
|
1372
1418
|
});
|
|
1373
1419
|
```
|
|
1420
|
+
|
|
1374
1421
|
<!-- /docs-validate: hidden -->
|
|
1422
|
+
|
|
1375
1423
|
```ts
|
|
1376
1424
|
const session = await client.createSession({
|
|
1377
1425
|
onPermissionRequest: approveAll,
|
|
@@ -1400,6 +1448,7 @@ When the session has elicitation support — either from the CLI's TUI or from a
|
|
|
1400
1448
|
|
|
1401
1449
|
<!-- docs-validate: strict -->
|
|
1402
1450
|
<!-- docs-validate: hidden -->
|
|
1451
|
+
|
|
1403
1452
|
```ts
|
|
1404
1453
|
import { approveAll } from "@github/copilot-sdk";
|
|
1405
1454
|
|
|
@@ -1435,7 +1484,9 @@ if (session.capabilities.ui?.elicitation) {
|
|
|
1435
1484
|
// result.content: { region: "us-east", dryRun: true } (when accepted)
|
|
1436
1485
|
}
|
|
1437
1486
|
```
|
|
1487
|
+
|
|
1438
1488
|
<!-- /docs-validate: hidden -->
|
|
1489
|
+
|
|
1439
1490
|
```ts
|
|
1440
1491
|
const session = await client.createSession({ onPermissionRequest: approveAll });
|
|
1441
1492
|
|
|
@@ -1477,6 +1528,7 @@ All UI methods throw if elicitation is not supported by the host.
|
|
|
1477
1528
|
Control the system prompt using `systemMessage` in session config:
|
|
1478
1529
|
|
|
1479
1530
|
<!-- docs-validate: strict -->
|
|
1531
|
+
|
|
1480
1532
|
```typescript
|
|
1481
1533
|
const session = await client.createSession({
|
|
1482
1534
|
model: "gpt-5",
|
|
@@ -1498,6 +1550,7 @@ The SDK auto-injects environment context, tool instructions, and security guardr
|
|
|
1498
1550
|
Use `mode: "customize"` to selectively override individual sections of the prompt while preserving the rest:
|
|
1499
1551
|
|
|
1500
1552
|
<!-- docs-validate: strict -->
|
|
1553
|
+
|
|
1501
1554
|
```typescript
|
|
1502
1555
|
import { SYSTEM_MESSAGE_SECTIONS } from "@github/copilot-sdk";
|
|
1503
1556
|
import type { SectionOverride, SystemMessageSection } from "@github/copilot-sdk";
|
|
@@ -1546,6 +1599,7 @@ Unknown section IDs are handled gracefully: content from `replace`/`append`/`pre
|
|
|
1546
1599
|
For full control (removes all guardrails), use `mode: "replace"`:
|
|
1547
1600
|
|
|
1548
1601
|
<!-- docs-validate: strict -->
|
|
1602
|
+
|
|
1549
1603
|
```typescript
|
|
1550
1604
|
const session = await client.createSession({
|
|
1551
1605
|
model: "gpt-5",
|
|
@@ -1562,6 +1616,7 @@ By default, sessions use **infinite sessions** which automatically manage contex
|
|
|
1562
1616
|
|
|
1563
1617
|
<!-- docs-validate: strict -->
|
|
1564
1618
|
<!-- docs-validate: hidden -->
|
|
1619
|
+
|
|
1565
1620
|
```typescript
|
|
1566
1621
|
// Default: infinite sessions enabled with default thresholds
|
|
1567
1622
|
const session = await client.createSession({ model: "gpt-5" });
|
|
@@ -1586,7 +1641,9 @@ const disabled = await client.createSession({
|
|
|
1586
1641
|
infiniteSessions: { enabled: false },
|
|
1587
1642
|
});
|
|
1588
1643
|
```
|
|
1644
|
+
|
|
1589
1645
|
<!-- /docs-validate: hidden -->
|
|
1646
|
+
|
|
1590
1647
|
```typescript
|
|
1591
1648
|
// Default: infinite sessions enabled with default thresholds
|
|
1592
1649
|
const session = await client.createSession({ model: "gpt-5" });
|
|
@@ -1628,6 +1685,7 @@ For more background, see [About GitHub Copilot Memory](https://docs.github.com/e
|
|
|
1628
1685
|
|
|
1629
1686
|
<!-- docs-validate: strict -->
|
|
1630
1687
|
<!-- docs-validate: hidden -->
|
|
1688
|
+
|
|
1631
1689
|
```typescript
|
|
1632
1690
|
// Enable memory for a session
|
|
1633
1691
|
const enabled = await client.createSession({
|
|
@@ -1641,7 +1699,9 @@ const disabled = await client.createSession({
|
|
|
1641
1699
|
memory: { enabled: false },
|
|
1642
1700
|
});
|
|
1643
1701
|
```
|
|
1702
|
+
|
|
1644
1703
|
<!-- /docs-validate: hidden -->
|
|
1704
|
+
|
|
1645
1705
|
```typescript
|
|
1646
1706
|
// Enable memory for a session
|
|
1647
1707
|
const enabled = await client.createSession({
|
|
@@ -1664,12 +1724,16 @@ files on disk. Provider skills join the session's skill catalog and load on dema
|
|
|
1664
1724
|
|
|
1665
1725
|
<!-- docs-validate: strict -->
|
|
1666
1726
|
<!-- docs-validate: hidden -->
|
|
1727
|
+
|
|
1667
1728
|
```typescript
|
|
1668
1729
|
import { approveAll } from "@github/copilot-sdk";
|
|
1669
1730
|
import type { SkillProvider } from "@github/copilot-sdk";
|
|
1670
1731
|
|
|
1671
1732
|
declare const db: {
|
|
1672
|
-
findSkill(
|
|
1733
|
+
findSkill(
|
|
1734
|
+
name: string,
|
|
1735
|
+
options: { signal: AbortSignal }
|
|
1736
|
+
): Promise<{ markdown: string } | undefined>;
|
|
1673
1737
|
};
|
|
1674
1738
|
|
|
1675
1739
|
const skillProvider: SkillProvider = {
|
|
@@ -1684,7 +1748,9 @@ const session = await client.createSession({
|
|
|
1684
1748
|
skillProvider,
|
|
1685
1749
|
});
|
|
1686
1750
|
```
|
|
1751
|
+
|
|
1687
1752
|
<!-- /docs-validate: hidden -->
|
|
1753
|
+
|
|
1688
1754
|
```typescript
|
|
1689
1755
|
import type { SkillProvider } from "@github/copilot-sdk";
|
|
1690
1756
|
|
|
@@ -1739,6 +1805,7 @@ See [Supporting files](../docs/features/skills.md#supporting-files-experimental)
|
|
|
1739
1805
|
### Multiple Sessions
|
|
1740
1806
|
|
|
1741
1807
|
<!-- docs-validate: strict -->
|
|
1808
|
+
|
|
1742
1809
|
```typescript
|
|
1743
1810
|
const session1 = await client.createSession({ model: "gpt-5" });
|
|
1744
1811
|
const session2 = await client.createSession({ model: "claude-sonnet-4.5" });
|
|
@@ -1751,6 +1818,7 @@ await session2.sendAndWait({ prompt: "Hello from session 2" });
|
|
|
1751
1818
|
### Custom Session IDs
|
|
1752
1819
|
|
|
1753
1820
|
<!-- docs-validate: strict -->
|
|
1821
|
+
|
|
1754
1822
|
```typescript
|
|
1755
1823
|
const session = await client.createSession({
|
|
1756
1824
|
sessionId: "my-custom-session-id",
|
|
@@ -1762,6 +1830,7 @@ const session = await client.createSession({
|
|
|
1762
1830
|
|
|
1763
1831
|
<!-- docs-validate: strict -->
|
|
1764
1832
|
<!-- docs-validate: hidden -->
|
|
1833
|
+
|
|
1765
1834
|
```typescript
|
|
1766
1835
|
import { approveAll } from "@github/copilot-sdk";
|
|
1767
1836
|
|
|
@@ -1778,7 +1847,9 @@ await session.send({
|
|
|
1778
1847
|
],
|
|
1779
1848
|
});
|
|
1780
1849
|
```
|
|
1850
|
+
|
|
1781
1851
|
<!-- /docs-validate: hidden -->
|
|
1852
|
+
|
|
1782
1853
|
```typescript
|
|
1783
1854
|
await session.send({
|
|
1784
1855
|
prompt: "Analyze this file",
|
|
@@ -1808,6 +1879,7 @@ The SDK supports custom OpenAI-compatible API providers (BYOK - Bring Your Own K
|
|
|
1808
1879
|
**Example with Ollama:**
|
|
1809
1880
|
|
|
1810
1881
|
<!-- docs-validate: strict -->
|
|
1882
|
+
|
|
1811
1883
|
```typescript
|
|
1812
1884
|
const session = await client.createSession({
|
|
1813
1885
|
model: "deepseek-coder-v2:16b", // Required when using custom provider
|
|
@@ -1824,6 +1896,7 @@ await session.sendAndWait({ prompt: "Hello!" });
|
|
|
1824
1896
|
**Example with custom OpenAI-compatible API:**
|
|
1825
1897
|
|
|
1826
1898
|
<!-- docs-validate: strict -->
|
|
1899
|
+
|
|
1827
1900
|
```typescript
|
|
1828
1901
|
const session = await client.createSession({
|
|
1829
1902
|
model: "gpt-4",
|
|
@@ -1838,6 +1911,7 @@ const session = await client.createSession({
|
|
|
1838
1911
|
**Example with Azure OpenAI:**
|
|
1839
1912
|
|
|
1840
1913
|
<!-- docs-validate: strict -->
|
|
1914
|
+
|
|
1841
1915
|
```typescript
|
|
1842
1916
|
const session = await client.createSession({
|
|
1843
1917
|
model: "gpt-4",
|
|
@@ -1863,6 +1937,7 @@ const session = await client.createSession({
|
|
|
1863
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:
|
|
1864
1938
|
|
|
1865
1939
|
<!-- docs-validate: strict -->
|
|
1940
|
+
|
|
1866
1941
|
```typescript
|
|
1867
1942
|
import { CopilotClient } from "@github/copilot-sdk";
|
|
1868
1943
|
|
|
@@ -1919,6 +1994,7 @@ Use the built-in `approveAll` helper when managed settings are disabled:
|
|
|
1919
1994
|
|
|
1920
1995
|
<!-- docs-validate: strict -->
|
|
1921
1996
|
<!-- docs-validate: hidden -->
|
|
1997
|
+
|
|
1922
1998
|
```typescript
|
|
1923
1999
|
import { approveAll } from "@github/copilot-sdk";
|
|
1924
2000
|
|
|
@@ -1927,7 +2003,9 @@ const session = await client.createSession({
|
|
|
1927
2003
|
onPermissionRequest: approveAll,
|
|
1928
2004
|
});
|
|
1929
2005
|
```
|
|
2006
|
+
|
|
1930
2007
|
<!-- /docs-validate: hidden -->
|
|
2008
|
+
|
|
1931
2009
|
```typescript
|
|
1932
2010
|
import { CopilotClient, approveAll } from "@github/copilot-sdk";
|
|
1933
2011
|
|
|
@@ -1944,6 +2022,7 @@ When `enableManagedSettings` is true for the session, `approveAll` throws. Use a
|
|
|
1944
2022
|
Provide your own function to inspect each request and apply custom logic. Check `managedApprovalRequired` before any automatic approval:
|
|
1945
2023
|
|
|
1946
2024
|
<!-- docs-validate: strict -->
|
|
2025
|
+
|
|
1947
2026
|
```typescript
|
|
1948
2027
|
import type { PermissionRequest, PermissionRequestResult } from "@github/copilot-sdk";
|
|
1949
2028
|
|
|
@@ -2019,6 +2098,7 @@ and sanitize `helpLink` before navigation.
|
|
|
2019
2098
|
|
|
2020
2099
|
<!-- docs-validate: strict -->
|
|
2021
2100
|
<!-- docs-validate: hidden -->
|
|
2101
|
+
|
|
2022
2102
|
```typescript
|
|
2023
2103
|
import type { CopilotSession } from "@github/copilot-sdk";
|
|
2024
2104
|
|
|
@@ -2036,7 +2116,9 @@ if (snapshot.policyHelperCapabilities?.recheck === true) {
|
|
|
2036
2116
|
console.log(refreshed.policyHelperFailure ?? "Policy Helper recovered");
|
|
2037
2117
|
}
|
|
2038
2118
|
```
|
|
2119
|
+
|
|
2039
2120
|
<!-- /docs-validate: hidden -->
|
|
2121
|
+
|
|
2040
2122
|
```typescript
|
|
2041
2123
|
const snapshot = await session.rpc.managedSettings.get();
|
|
2042
2124
|
|
|
@@ -2077,6 +2159,7 @@ You may pass `onPermissionRequest` when resuming a session too:
|
|
|
2077
2159
|
|
|
2078
2160
|
<!-- docs-validate: strict -->
|
|
2079
2161
|
<!-- docs-validate: hidden -->
|
|
2162
|
+
|
|
2080
2163
|
```typescript
|
|
2081
2164
|
import { approveAll } from "@github/copilot-sdk";
|
|
2082
2165
|
|
|
@@ -2084,7 +2167,9 @@ const session = await client.resumeSession("session-id", {
|
|
|
2084
2167
|
onPermissionRequest: approveAll,
|
|
2085
2168
|
});
|
|
2086
2169
|
```
|
|
2170
|
+
|
|
2087
2171
|
<!-- /docs-validate: hidden -->
|
|
2172
|
+
|
|
2088
2173
|
```typescript
|
|
2089
2174
|
const session = await client.resumeSession("session-id", {
|
|
2090
2175
|
onPermissionRequest: approveAll,
|
|
@@ -2100,6 +2185,7 @@ To let a specific custom tool bypass the permission prompt entirely, set `skipPe
|
|
|
2100
2185
|
Enable the legacy question-and-answer `ask_user` tool by providing an `onUserInputRequest` handler:
|
|
2101
2186
|
|
|
2102
2187
|
<!-- docs-validate: strict -->
|
|
2188
|
+
|
|
2103
2189
|
```typescript
|
|
2104
2190
|
const session = await client.createSession({
|
|
2105
2191
|
model: "gpt-5",
|
|
@@ -2128,6 +2214,7 @@ const session = await client.createSession({
|
|
|
2128
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.
|
|
2129
2215
|
|
|
2130
2216
|
<!-- docs-validate: strict -->
|
|
2217
|
+
|
|
2131
2218
|
```typescript
|
|
2132
2219
|
import { approveAll } from "@github/copilot-sdk";
|
|
2133
2220
|
|
|
@@ -2173,6 +2260,7 @@ Hook into session lifecycle events by providing handlers in the `hooks` configur
|
|
|
2173
2260
|
|
|
2174
2261
|
<!-- docs-validate: strict -->
|
|
2175
2262
|
<!-- docs-validate: hidden -->
|
|
2263
|
+
|
|
2176
2264
|
```typescript
|
|
2177
2265
|
declare function needsMoreWork(): boolean;
|
|
2178
2266
|
|
|
@@ -2264,7 +2352,9 @@ const session = await client.createSession({
|
|
|
2264
2352
|
},
|
|
2265
2353
|
});
|
|
2266
2354
|
```
|
|
2355
|
+
|
|
2267
2356
|
<!-- /docs-validate: hidden -->
|
|
2357
|
+
|
|
2268
2358
|
```typescript
|
|
2269
2359
|
const session = await client.createSession({
|
|
2270
2360
|
model: "gpt-5",
|
|
@@ -2371,6 +2461,7 @@ const session = await client.createSession({
|
|
|
2371
2461
|
## Error Handling
|
|
2372
2462
|
|
|
2373
2463
|
<!-- docs-validate: strict -->
|
|
2464
|
+
|
|
2374
2465
|
```typescript
|
|
2375
2466
|
try {
|
|
2376
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-1";
|
|
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 = {
|