@github/copilot-sdk 1.0.9-preview.3 → 1.0.10-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 CHANGED
@@ -131,10 +131,11 @@ Create a new conversation session.
131
131
 
132
132
  - `sessionId?: string` - Custom session ID.
133
133
  - `model?: string` - Model to use ("gpt-5", "claude-sonnet-4.5", etc.). **Required when using custom provider.**
134
- - `reasoningEffort?: "low" | "medium" | "high" | "xhigh"` - Reasoning effort level for models that support it. Use `listModels()` to check which models support this option.
134
+ - `reasoningEffort?: "low" | "medium" | "high" | "xhigh" | "max"` - Reasoning effort level for models that support it. Use `listModels()` to check which models support this option.
135
135
  - `tools?: Tool[]` - Custom tools exposed to the CLI. Tools without `handler` are declaration-only and must be resolved via pending tool-call RPCs.
136
136
  - `systemMessage?: SystemMessageConfig` - System message customization (see below)
137
137
  - `infiniteSessions?: InfiniteSessionConfig` - Configure automatic context compaction (see below)
138
+ - `workingDirectory?: string` - Working directory for the session (default: runtime process cwd).
138
139
  - `enableSessionStore?: boolean` - Enables the cross-session store for search and retrieval across sessions. When unset in `"copilot-cli"` mode, the runtime default applies (enabled). In `"empty"` mode, defaults to disabled.
139
140
  - `provider?: ProviderConfig` - Custom API provider configuration (BYOK - Bring Your Own Key). See [Custom Providers](#custom-providers) section.
140
141
  - `onPermissionRequest?: PermissionHandler` - Optional handler called before each tool execution to approve or deny it. When omitted, permission requests are emitted as events and left pending for manual resolution. `approveAll` approves requests when managed settings are disabled and throws when `enableManagedSettings` is true. Custom handlers can inspect `managedApprovalRequired` for human-facing confirmation logic. See [Permission Handling](#permission-handling) section.
@@ -1108,6 +1109,21 @@ try {
1108
1109
  }
1109
1110
  ```
1110
1111
 
1112
+ ## Development
1113
+
1114
+ From the repository root:
1115
+
1116
+ ```bash
1117
+ cd test/harness
1118
+ npm ci
1119
+ ```
1120
+
1121
+ ```bash
1122
+ cd nodejs
1123
+ npm ci
1124
+ npm test
1125
+ ```
1126
+
1111
1127
  ## License
1112
1128
 
1113
1129
  MIT
@@ -1027,7 +1027,7 @@ class CopilotClient {
1027
1027
  this.onGetTraceContext,
1028
1028
  {
1029
1029
  mcpAuthHandler: config.onMcpAuthRequest,
1030
- managedSettingsEnabled: config.enableManagedSettings
1030
+ managedSettingsEnabled: config.enableManagedSettings === true || config.managedSettings !== void 0
1031
1031
  }
1032
1032
  );
1033
1033
  s.registerTools(config.tools);
@@ -1086,7 +1086,8 @@ class CopilotClient {
1086
1086
  overridesBuiltInTool: tool.overridesBuiltInTool,
1087
1087
  skipPermission: tool.skipPermission,
1088
1088
  defer: tool.defer,
1089
- metadata: tool.metadata
1089
+ metadata: tool.metadata,
1090
+ isTerminal: tool.isTerminal
1090
1091
  })),
1091
1092
  toolSearch: config.toolSearch,
1092
1093
  canvases: config.canvases?.map((canvas) => canvas.declaration),
@@ -1147,13 +1148,15 @@ class CopilotClient {
1147
1148
  pluginDirectories: config.pluginDirectories,
1148
1149
  instructionDirectories: config.instructionDirectories,
1149
1150
  disabledSkills: config.disabledSkills,
1151
+ disabledMcpServers: config.disabledMcpServers,
1150
1152
  infiniteSessions: config.infiniteSessions,
1151
1153
  memory: config.memory,
1152
1154
  gitHubToken: config.gitHubToken,
1153
1155
  remoteSession: config.remoteSession,
1154
1156
  cloud: config.cloud,
1155
1157
  expAssignments: config.expAssignments,
1156
- enableManagedSettings: config.enableManagedSettings
1158
+ enableManagedSettings: config.enableManagedSettings,
1159
+ managedSettings: config.managedSettings
1157
1160
  });
1158
1161
  const {
1159
1162
  sessionId: returnedSessionId,
@@ -1231,7 +1234,7 @@ class CopilotClient {
1231
1234
  this.onGetTraceContext,
1232
1235
  {
1233
1236
  mcpAuthHandler: config.onMcpAuthRequest,
1234
- managedSettingsEnabled: config.enableManagedSettings
1237
+ managedSettingsEnabled: config.enableManagedSettings === true || config.managedSettings !== void 0
1235
1238
  }
1236
1239
  );
1237
1240
  session.registerTools(config.tools);
@@ -1303,7 +1306,8 @@ class CopilotClient {
1303
1306
  overridesBuiltInTool: tool.overridesBuiltInTool,
1304
1307
  skipPermission: tool.skipPermission,
1305
1308
  defer: tool.defer,
1306
- metadata: tool.metadata
1309
+ metadata: tool.metadata,
1310
+ isTerminal: tool.isTerminal
1307
1311
  })),
1308
1312
  toolSearch: config.toolSearch,
1309
1313
  canvases: config.canvases?.map((canvas) => canvas.declaration),
@@ -1357,6 +1361,7 @@ class CopilotClient {
1357
1361
  pluginDirectories: config.pluginDirectories,
1358
1362
  instructionDirectories: config.instructionDirectories,
1359
1363
  disabledSkills: config.disabledSkills,
1364
+ disabledMcpServers: config.disabledMcpServers,
1360
1365
  infiniteSessions: config.infiniteSessions,
1361
1366
  memory: config.memory,
1362
1367
  disableResume: config.suppressResumeEvent,
@@ -1365,7 +1370,8 @@ class CopilotClient {
1365
1370
  remoteSession: config.remoteSession,
1366
1371
  openCanvases: config.openCanvases,
1367
1372
  expAssignments: config.expAssignments,
1368
- enableManagedSettings: config.enableManagedSettings
1373
+ enableManagedSettings: config.enableManagedSettings,
1374
+ managedSettings: config.managedSettings
1369
1375
  });
1370
1376
  const { workspacePath, capabilities, openCanvases } = response;
1371
1377
  session["_workspacePath"] = workspacePath;
@@ -191,6 +191,12 @@ function createServerRpc(connection) {
191
191
  */
192
192
  disable: async (params) => connection.sendRequest("extensions.disable", params)
193
193
  },
194
+ /**
195
+ * Registers the calling SDK client as the per-entrypoint extension launch provider. Call before creating any sessions. When omitted, the runtime temporarily falls back to its built-in Node launcher for backward compatibility.
196
+ *
197
+ * @experimental
198
+ */
199
+ registerExtensionLaunchProvider: async () => connection.sendRequest("registerExtensionLaunchProvider", {}),
194
200
  /** @experimental */
195
201
  plugins: {
196
202
  /**
@@ -381,6 +387,15 @@ function createServerRpc(connection) {
381
387
  }
382
388
  },
383
389
  /** @experimental */
390
+ managedSettings: {
391
+ /**
392
+ * Discovers device-managed settings from production MDM and managed-file sources, validates them against the runtime-owned managed-settings schema, and returns the canonical JSON without requiring a session.
393
+ *
394
+ * @returns Validated device-managed settings discovered before a session exists.
395
+ */
396
+ read: async () => connection.sendRequest("managedSettings.read", {})
397
+ },
398
+ /** @experimental */
384
399
  runtime: {
385
400
  /**
386
401
  * Gracefully shuts down an SDK-owned runtime. The response is sent only after cleanup completes; callers may then terminate the owned runtime process.
@@ -2623,6 +2638,11 @@ function registerClientSessionApiHandlers(connection, getHandlers) {
2623
2638
  });
2624
2639
  }
2625
2640
  function registerClientGlobalApiHandlers(connection, handlers) {
2641
+ connection.onRequest("extensionLaunchProvider.resolve", async (params) => {
2642
+ const handler = handlers.extensionLaunchProvider;
2643
+ if (!handler) throw new Error("No extensionLaunchProvider client-global handler registered");
2644
+ return handler.resolve(params);
2645
+ });
2626
2646
  connection.onRequest("llmInference.httpRequestStart", async (params) => {
2627
2647
  const handler = handlers.llmInference;
2628
2648
  if (!handler) throw new Error("No llmInference client-global handler registered");
@@ -449,22 +449,20 @@ class CopilotSession {
449
449
  async sendAndWait(optionsOrPrompt, timeout) {
450
450
  const options = typeof optionsOrPrompt === "string" ? { prompt: optionsOrPrompt } : optionsOrPrompt;
451
451
  const effectiveTimeout = timeout ?? 6e4;
452
- let resolveIdle;
453
- let rejectWithError;
454
- const idlePromise = new Promise((resolve, reject) => {
455
- resolveIdle = resolve;
456
- rejectWithError = reject;
452
+ let resolveOutcome;
453
+ const outcomePromise = new Promise((resolve) => {
454
+ resolveOutcome = resolve;
457
455
  });
458
456
  let lastAssistantMessage;
459
457
  const unsubscribe = this.on((event) => {
460
458
  if (event.type === "assistant.message") {
461
459
  lastAssistantMessage = event;
462
460
  } else if (event.type === "session.idle") {
463
- resolveIdle();
461
+ resolveOutcome({ kind: "idle" });
464
462
  } else if (event.type === "session.error") {
465
463
  const error = new Error(event.data.message);
466
464
  error.stack = event.data.stack;
467
- rejectWithError(error);
465
+ resolveOutcome({ kind: "error", error });
468
466
  }
469
467
  });
470
468
  let timeoutId;
@@ -480,7 +478,10 @@ class CopilotSession {
480
478
  effectiveTimeout
481
479
  );
482
480
  });
483
- await Promise.race([idlePromise, timeoutPromise]);
481
+ const outcome = await Promise.race([outcomePromise, timeoutPromise]);
482
+ if (outcome.kind === "error") {
483
+ throw outcome.error;
484
+ }
484
485
  return lastAssistantMessage;
485
486
  } finally {
486
487
  if (timeoutId !== void 0) {
@@ -1382,6 +1383,7 @@ class CopilotSession {
1382
1383
  postToolUse: this.hooks.onPostToolUse,
1383
1384
  postToolUseFailure: this.hooks.onPostToolUseFailure,
1384
1385
  userPromptSubmitted: this.hooks.onUserPromptSubmitted,
1386
+ userPromptTransformed: this.hooks.onUserPromptTransformed,
1385
1387
  sessionStart: this.hooks.onSessionStart,
1386
1388
  sessionEnd: this.hooks.onSessionEnd,
1387
1389
  errorOccurred: this.hooks.onErrorOccurred,
package/dist/client.js CHANGED
@@ -1004,7 +1004,7 @@ class CopilotClient {
1004
1004
  this.onGetTraceContext,
1005
1005
  {
1006
1006
  mcpAuthHandler: config.onMcpAuthRequest,
1007
- managedSettingsEnabled: config.enableManagedSettings
1007
+ managedSettingsEnabled: config.enableManagedSettings === true || config.managedSettings !== void 0
1008
1008
  }
1009
1009
  );
1010
1010
  s.registerTools(config.tools);
@@ -1063,7 +1063,8 @@ class CopilotClient {
1063
1063
  overridesBuiltInTool: tool.overridesBuiltInTool,
1064
1064
  skipPermission: tool.skipPermission,
1065
1065
  defer: tool.defer,
1066
- metadata: tool.metadata
1066
+ metadata: tool.metadata,
1067
+ isTerminal: tool.isTerminal
1067
1068
  })),
1068
1069
  toolSearch: config.toolSearch,
1069
1070
  canvases: config.canvases?.map((canvas) => canvas.declaration),
@@ -1124,13 +1125,15 @@ class CopilotClient {
1124
1125
  pluginDirectories: config.pluginDirectories,
1125
1126
  instructionDirectories: config.instructionDirectories,
1126
1127
  disabledSkills: config.disabledSkills,
1128
+ disabledMcpServers: config.disabledMcpServers,
1127
1129
  infiniteSessions: config.infiniteSessions,
1128
1130
  memory: config.memory,
1129
1131
  gitHubToken: config.gitHubToken,
1130
1132
  remoteSession: config.remoteSession,
1131
1133
  cloud: config.cloud,
1132
1134
  expAssignments: config.expAssignments,
1133
- enableManagedSettings: config.enableManagedSettings
1135
+ enableManagedSettings: config.enableManagedSettings,
1136
+ managedSettings: config.managedSettings
1134
1137
  });
1135
1138
  const {
1136
1139
  sessionId: returnedSessionId,
@@ -1208,7 +1211,7 @@ class CopilotClient {
1208
1211
  this.onGetTraceContext,
1209
1212
  {
1210
1213
  mcpAuthHandler: config.onMcpAuthRequest,
1211
- managedSettingsEnabled: config.enableManagedSettings
1214
+ managedSettingsEnabled: config.enableManagedSettings === true || config.managedSettings !== void 0
1212
1215
  }
1213
1216
  );
1214
1217
  session.registerTools(config.tools);
@@ -1280,7 +1283,8 @@ class CopilotClient {
1280
1283
  overridesBuiltInTool: tool.overridesBuiltInTool,
1281
1284
  skipPermission: tool.skipPermission,
1282
1285
  defer: tool.defer,
1283
- metadata: tool.metadata
1286
+ metadata: tool.metadata,
1287
+ isTerminal: tool.isTerminal
1284
1288
  })),
1285
1289
  toolSearch: config.toolSearch,
1286
1290
  canvases: config.canvases?.map((canvas) => canvas.declaration),
@@ -1334,6 +1338,7 @@ class CopilotClient {
1334
1338
  pluginDirectories: config.pluginDirectories,
1335
1339
  instructionDirectories: config.instructionDirectories,
1336
1340
  disabledSkills: config.disabledSkills,
1341
+ disabledMcpServers: config.disabledMcpServers,
1337
1342
  infiniteSessions: config.infiniteSessions,
1338
1343
  memory: config.memory,
1339
1344
  disableResume: config.suppressResumeEvent,
@@ -1342,7 +1347,8 @@ class CopilotClient {
1342
1347
  remoteSession: config.remoteSession,
1343
1348
  openCanvases: config.openCanvases,
1344
1349
  expAssignments: config.expAssignments,
1345
- enableManagedSettings: config.enableManagedSettings
1350
+ enableManagedSettings: config.enableManagedSettings,
1351
+ managedSettings: config.managedSettings
1346
1352
  });
1347
1353
  const { workspacePath, capabilities, openCanvases } = response;
1348
1354
  session["_workspacePath"] = workspacePath;
@@ -398,6 +398,8 @@ export type DebugCollectLogsResultKind =
398
398
  "archive"
399
399
  /** A directory containing redacted files was written. */
400
400
  | "directory";
401
+ /** @experimental */
402
+ export type DisableBypassPermissionsMode = "disable";
401
403
  /**
402
404
  * Persisted extension discovery source
403
405
  *
@@ -1183,6 +1185,63 @@ export type SessionContextAttribution = {
1183
1185
  * Total token count of the current context window the entries are measured against (system message + conversation messages + tool definitions — the same total reported by /context). Divide an entry's `tokens` by this to derive its share.
1184
1186
  */
1185
1187
  totalTokens: number;
1188
+ /**
1189
+ * The concrete model id the entire breakdown was tokenized against (feeds the per-model token multiplier). Under `Auto` (Free/Student) this is the resolved model, not the literal `auto` sentinel, so totals are not undercounted. A single-model approximation of a potentially multi-model Auto session.
1190
+ */
1191
+ modelId: string;
1192
+ /**
1193
+ * How `modelId` was chosen. Not a closed set — tolerate unknown values. Known values today: `autoResolved` (the model Auto resolved to), `selected` (the user's explicitly selected model), `default` (a fallback before any model is known).
1194
+ */
1195
+ modelSource: string;
1196
+ /**
1197
+ * Maximum prompt tokens the resolved model accepts — the denominator for a `##k/###k` context-usage display. Mirrors `SessionContextInfo.promptTokenLimit`.
1198
+ */
1199
+ promptTokenLimit: number;
1200
+ /**
1201
+ * Prompt limit plus the model's output reserve: the full context window `categories.freeSpace` and `categories.buffer` are measured against. Mirrors `SessionContextInfo.limit`.
1202
+ */
1203
+ limit: number;
1204
+ /**
1205
+ * Output reserve plus the tokens past the buffer-exhaustion blocking threshold. Mirrors `SessionContextInfo.bufferTokens`.
1206
+ */
1207
+ bufferTokens: number;
1208
+ /**
1209
+ * Token count at which background compaction starts. Mirrors `SessionContextInfo.compactionThreshold`.
1210
+ */
1211
+ compactionThreshold: number;
1212
+ /**
1213
+ * The six normalized `/context` header buckets, computed from the same tokenization as `entries` so the two never disagree. Convenience rollups: `freeSpace` and `buffer` describe window capacity rather than occupied context, so the values do not sum to `totalTokens`.
1214
+ */
1215
+ categories: {
1216
+ /**
1217
+ * System prompt tokens, excluding custom instructions.
1218
+ */
1219
+ systemPrompt: number;
1220
+ /**
1221
+ * Custom-instructions tokens (0 when none are configured).
1222
+ */
1223
+ customInstructions: number;
1224
+ /**
1225
+ * Non-MCP tool-definition tokens.
1226
+ */
1227
+ systemTools: number;
1228
+ /**
1229
+ * MCP tool-definition tokens.
1230
+ */
1231
+ mcpTools: number;
1232
+ /**
1233
+ * Conversation (user/assistant/tool) message tokens.
1234
+ */
1235
+ messages: number;
1236
+ /**
1237
+ * Remaining unused window capacity (clamped at 0).
1238
+ */
1239
+ freeSpace: number;
1240
+ /**
1241
+ * Output reserve plus post-blocking-threshold buffer.
1242
+ */
1243
+ buffer: number;
1244
+ };
1186
1245
  /**
1187
1246
  * Flat list of per-source attribution entries. Group by `kind` and render unrecognized kinds generically. Nesting and rollups are expressed via `parentId`.
1188
1247
  */
@@ -1494,6 +1553,52 @@ export type PermissionDecisionApproveForSessionApproval = PermissionDecisionAppr
1494
1553
  */
1495
1554
  /** @experimental */
1496
1555
  export type PermissionDecisionApproveForLocationApproval = PermissionDecisionApproveForLocationApprovalCommands | PermissionDecisionApproveForLocationApprovalRead | PermissionDecisionApproveForLocationApprovalWrite | PermissionDecisionApproveForLocationApprovalMcp | PermissionDecisionApproveForLocationApprovalMcpSampling | PermissionDecisionApproveForLocationApprovalMemory | PermissionDecisionApproveForLocationApprovalCustomTool | PermissionDecisionApproveForLocationApprovalExtensionManagement | PermissionDecisionApproveForLocationApprovalFactory | PermissionDecisionApproveForLocationApprovalExtensionPermissionAccess;
1556
+ /**
1557
+ * Disposition of a permission request as observed by the responding client.
1558
+ *
1559
+ * This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
1560
+ * via the `definition` "PermissionDecisionOutcome".
1561
+ */
1562
+ /** @experimental */
1563
+ export type PermissionDecisionOutcome =
1564
+ /** The request was approved automatically without a new human decision. */
1565
+ "auto_approved"
1566
+ /** The request was denied without an interactive user decision; source records why. */
1567
+ | "autopilot_denied"
1568
+ /** The response came from an interactive user prompt. */
1569
+ | "prompted_user";
1570
+ /**
1571
+ * Controlled reason or actor responsible for a permission response.
1572
+ *
1573
+ * This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
1574
+ * via the `definition` "PermissionDecisionSource".
1575
+ */
1576
+ /** @experimental */
1577
+ export type PermissionDecisionSource =
1578
+ /** The response followed the auto-approval judge recommendation. */
1579
+ "judge_recommendation"
1580
+ /** A human supplied the response through an interactive prompt. */
1581
+ | "human_response"
1582
+ /** The host applied a standing policy or override rather than a judge recommendation or human decision. */
1583
+ | "host_policy"
1584
+ /** The host denied the request because no interactive user response was available. */
1585
+ | "unattended_fallback";
1586
+ /**
1587
+ * Client surface that submitted a permission response.
1588
+ *
1589
+ * This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
1590
+ * via the `definition` "PermissionDecisionSurface".
1591
+ */
1592
+ /** @experimental */
1593
+ export type PermissionDecisionSurface =
1594
+ /** The interactive Copilot CLI terminal UI. */
1595
+ "tui"
1596
+ /** The non-interactive Copilot CLI prompt mode. */
1597
+ | "prompt_mode"
1598
+ /** The Copilot App client. */
1599
+ | "copilot_app"
1600
+ /** A generic Copilot SDK client. */
1601
+ | "sdk";
1497
1602
  /**
1498
1603
  * Tool approval to persist and apply
1499
1604
  *
@@ -4935,6 +5040,61 @@ export interface ExtensionContextPushInput {
4935
5040
  [k: string]: unknown | undefined;
4936
5041
  };
4937
5042
  }
5043
+ /**
5044
+ * Opaque integrator-owned process launch profile for one extension entrypoint.
5045
+ *
5046
+ * This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
5047
+ * via the `definition` "ExtensionLaunchProfile".
5048
+ */
5049
+ /** @experimental */
5050
+ export interface ExtensionLaunchProfile {
5051
+ /**
5052
+ * Executable used to launch the extension entrypoint.
5053
+ */
5054
+ executable: string;
5055
+ /**
5056
+ * Opaque integrator-defined arguments passed to the executable. The runtime does not append the extension entrypoint.
5057
+ */
5058
+ args: string[];
5059
+ /**
5060
+ * Opaque integrator-defined environment variables. Runtime-owned COPILOT_SDK_PATH, SESSION_ID, and COPILOT_EXTENSION_PARENT_PID values take precedence.
5061
+ */
5062
+ env: {
5063
+ [k: string]: string | undefined;
5064
+ };
5065
+ }
5066
+ /**
5067
+ * A discovered extension entrypoint that the registered integrator may classify and resolve to an opaque launch profile.
5068
+ *
5069
+ * This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
5070
+ * via the `definition` "ExtensionLaunchProviderResolveRequest".
5071
+ */
5072
+ /** @experimental */
5073
+ export interface ExtensionLaunchProviderResolveRequest {
5074
+ /**
5075
+ * Source-qualified extension identifier.
5076
+ */
5077
+ id: string;
5078
+ /**
5079
+ * Human-readable extension name.
5080
+ */
5081
+ name: string;
5082
+ /**
5083
+ * Absolute path to the discovered extension entrypoint.
5084
+ */
5085
+ modulePath: string;
5086
+ source: ExtensionSource;
5087
+ }
5088
+ /**
5089
+ * The launch profile for a supported entrypoint. Omit launch when the provider does not support the entrypoint.
5090
+ *
5091
+ * This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
5092
+ * via the `definition` "ExtensionLaunchProviderResolveResult".
5093
+ */
5094
+ /** @experimental */
5095
+ export interface ExtensionLaunchProviderResolveResult {
5096
+ launch?: ExtensionLaunchProfile;
5097
+ }
4938
5098
  /**
4939
5099
  * Extensions discovered for the session, with their current status.
4940
5100
  *
@@ -7041,6 +7201,25 @@ export interface LspInitializeRequest {
7041
7201
  */
7042
7202
  force?: boolean;
7043
7203
  }
7204
+ /**
7205
+ * Validated device-managed settings discovered before a session exists.
7206
+ *
7207
+ * This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
7208
+ * via the `definition` "ManagedSettingsReadResult".
7209
+ */
7210
+ /** @experimental */
7211
+ export interface ManagedSettingsReadResult {
7212
+ /**
7213
+ * Validated, canonical managed-settings JSON. Omitted when no managed settings were discovered or when discovered settings failed validation.
7214
+ */
7215
+ settingsJson?: {
7216
+ [k: string]: unknown | undefined;
7217
+ };
7218
+ /**
7219
+ * Discovery or validation error text when managed settings could not be read safely.
7220
+ */
7221
+ errorMessage?: string;
7222
+ }
7044
7223
  /**
7045
7224
  * Result of registering a new marketplace.
7046
7225
  *
@@ -9957,6 +10136,18 @@ export interface PermissionDecisionDeniedByPermissionRequestHook {
9957
10136
  */
9958
10137
  interrupt?: boolean;
9959
10138
  }
10139
+ /**
10140
+ * Optional informational context describing how and where the permission decision was made. This does not affect permission behavior.
10141
+ *
10142
+ * This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
10143
+ * via the `definition` "PermissionDecisionContext".
10144
+ */
10145
+ /** @experimental */
10146
+ export interface PermissionDecisionContext {
10147
+ outcome: PermissionDecisionOutcome;
10148
+ source: PermissionDecisionSource;
10149
+ surface: PermissionDecisionSurface;
10150
+ }
9960
10151
  /**
9961
10152
  * Pending permission request ID and the decision to apply (approve/reject and scope).
9962
10153
  *
@@ -9970,6 +10161,7 @@ export interface PermissionDecisionRequest {
9970
10161
  */
9971
10162
  requestId: string;
9972
10163
  result: PermissionDecision;
10164
+ decisionContext?: PermissionDecisionContext;
9973
10165
  }
9974
10166
  /**
9975
10167
  * Location-scoped tool approval to persist.
@@ -12598,9 +12790,9 @@ export interface SandboxConfig {
12598
12790
  */
12599
12791
  ghAuth?: boolean;
12600
12792
  /**
12601
- * Whether to auto-grant read access to common developer-tool caches, registries, and toolchains in their default home locations (cargo, go, npm, Maven, and more), plus read-write access to (and, on Unix, up-front creation of) the scratch caches builds write on every run (go-build, ccache, sccache, Gradle caches, Cargo lock/tracker files), so builds work without exporting CARGO_HOME/GOPATH/etc. Default: true (enabled by default; set to false to opt out).
12793
+ * Whether to auto-grant read access to common developer-tool caches, registries, and toolchains in their default home locations (cargo, go, npm, Maven, and more), plus read-write access to (and, on Unix, up-front creation of) the scratch caches builds write on every run (go-build, ccache, sccache, Gradle caches, Cargo lock/tracker files), so builds work without extra configuration; a relocated CARGO_HOME additionally gets its Cargo lock files granted read-write. Default: true (enabled by default; set to false to opt out).
12602
12794
  */
12603
- allowDevToolCaches?: boolean;
12795
+ allowDevToolAccess?: boolean;
12604
12796
  }
12605
12797
  /**
12606
12798
  * User-managed sandbox policy fragment merged into the auto-discovered base policy.
@@ -13187,6 +13379,10 @@ export interface ServerSkill {
13187
13379
  * Unique identifier for the skill
13188
13380
  */
13189
13381
  name: string;
13382
+ /**
13383
+ * Canonical slash command name used to invoke the skill, without the leading '/'
13384
+ */
13385
+ commandName?: string;
13190
13386
  /**
13191
13387
  * Description of what the skill does
13192
13388
  */
@@ -14001,6 +14197,38 @@ export interface SessionLoadDeferredRepoHooksResult {
14001
14197
  */
14002
14198
  hookCount: number;
14003
14199
  }
14200
+ /**
14201
+ * Enterprise permission policy expressed with the runtime's managed permission-rule syntax.
14202
+ *
14203
+ * This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
14204
+ * via the `definition` "SessionManagedPermissions".
14205
+ */
14206
+ /** @experimental */
14207
+ export interface SessionManagedPermissions {
14208
+ disableBypassPermissionsMode?: DisableBypassPermissionsMode;
14209
+ /**
14210
+ * Permission rules that block matching operations. Deny has highest precedence.
14211
+ */
14212
+ deny?: string[];
14213
+ /**
14214
+ * Permission rules that require explicit human approval.
14215
+ */
14216
+ ask?: string[];
14217
+ /**
14218
+ * Permission rules that allow matching operations unless another managed source, deny, or ask rule restricts them.
14219
+ */
14220
+ allow?: string[];
14221
+ }
14222
+ /**
14223
+ * Managed settings an SDK host may inject at session startup. Only permissions are accepted in this initial contract.
14224
+ *
14225
+ * This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
14226
+ * via the `definition` "SessionManagedSettings".
14227
+ */
14228
+ /** @experimental */
14229
+ export interface SessionManagedSettings {
14230
+ permissions?: SessionManagedPermissions;
14231
+ }
14004
14232
  /**
14005
14233
  * Point-in-time snapshot of slow-changing session identifier and state fields
14006
14234
  *
@@ -14144,6 +14372,7 @@ export interface SessionOpenOptions {
14144
14372
  * Opt-in: self-fetch and enforce enterprise managed settings at session bootstrap.
14145
14373
  */
14146
14374
  enableManagedSettings?: boolean;
14375
+ managedSettings?: SessionManagedSettings;
14147
14376
  /**
14148
14377
  * Opt in to capturing file changes for session rewind and session diff. Capture cannot reconstruct changes made before it was enabled. On create it starts capture from the first turn. It is also honored on resume: for a session that already has tracked prior turns, tracking continues automatically even if this is omitted; passing it on resume additionally enables tracking for an eligible session that has no prior root turn yet. Resuming a session whose prior root turns were never tracked has no restorable baseline, so tracking stays disabled for it and rewind reports file change tracking as unavailable; the resume itself still succeeds, so sessions that predate tracking remain loadable. The opt-in is only rejected when the session can never track (a subagent session, or one without local session storage). It is intentionally absent from the mutable options update because enabling it after edits have occurred would create an incomplete, misleading baseline. Subagents share the parent session's capture store and are not tracked as separate rewind points: a file a subagent writes is attributed to whichever root user turn was open when the capture was staged, just before the tool body ran. A turn cannot open while a staged capture is still in flight, so a subagent tool that staged under the spawning turn stays attributed to it however late the write lands, while a capture it stages after the user's next message belongs to that later turn. Attribution decides which turn's rewind point counts and file preview include that write; it does not narrow which rewinds revert it, because a rewind restores every capture from the selected turn onward, so the earlier spawning turn reverts it as well.
14149
14378
  */
@@ -14238,6 +14467,10 @@ export interface SessionOpenOptions {
14238
14467
  */
14239
14468
  logInteractiveShells?: boolean;
14240
14469
  envValueMode?: SessionOpenOptionsEnvValueMode;
14470
+ /**
14471
+ * MCP server names disabled for this session. Disabled servers are not started or authenticated on create or cold resume.
14472
+ */
14473
+ disabledMcpServers?: string[];
14241
14474
  /**
14242
14475
  * Whether to include instructions from every MCP server in the system prompt instead of only allowlisted servers.
14243
14476
  */
@@ -15689,6 +15922,10 @@ export interface Skill {
15689
15922
  * Unique identifier for the skill
15690
15923
  */
15691
15924
  name: string;
15925
+ /**
15926
+ * Canonical slash command name used to invoke the skill, without the leading '/'
15927
+ */
15928
+ commandName?: string;
15692
15929
  /**
15693
15930
  * Description of what the skill does
15694
15931
  */
@@ -18161,6 +18398,12 @@ export declare function createServerRpc(connection: MessageConnection): {
18161
18398
  */
18162
18399
  disable: (params: DiscoveredExtensionsDisableRequest) => Promise<void>;
18163
18400
  };
18401
+ /**
18402
+ * Registers the calling SDK client as the per-entrypoint extension launch provider. Call before creating any sessions. When omitted, the runtime temporarily falls back to its built-in Node launcher for backward compatibility.
18403
+ *
18404
+ * @experimental
18405
+ */
18406
+ registerExtensionLaunchProvider: () => Promise<void>;
18164
18407
  /** @experimental */
18165
18408
  plugins: {
18166
18409
  /**
@@ -18351,6 +18594,15 @@ export declare function createServerRpc(connection: MessageConnection): {
18351
18594
  };
18352
18595
  };
18353
18596
  /** @experimental */
18597
+ managedSettings: {
18598
+ /**
18599
+ * Discovers device-managed settings from production MDM and managed-file sources, validates them against the runtime-owned managed-settings schema, and returns the canonical JSON without requiring a session.
18600
+ *
18601
+ * @returns Validated device-managed settings discovered before a session exists.
18602
+ */
18603
+ read: () => Promise<ManagedSettingsReadResult>;
18604
+ };
18605
+ /** @experimental */
18354
18606
  runtime: {
18355
18607
  /**
18356
18608
  * Gracefully shuts down an SDK-owned runtime. The response is sent only after cleanup completes; callers may then terminate the owned runtime process.
@@ -20428,6 +20680,18 @@ export interface ClientSessionApiHandlers {
20428
20680
  * function uses `getHandlers` to resolve the session's handlers.
20429
20681
  */
20430
20682
  export declare function registerClientSessionApiHandlers(connection: MessageConnection, getHandlers: (sessionId: string) => ClientSessionApiHandlers): void;
20683
+ /** Handler for `extensionLaunchProvider` client global API methods. */
20684
+ /** @experimental */
20685
+ export interface ExtensionLaunchProviderHandler {
20686
+ /**
20687
+ * Asks the registered SDK client to resolve an opaque process launch profile for one discovered extension entrypoint immediately before launch or reload. The provider must respond within 15 seconds.
20688
+ *
20689
+ * @param params A discovered extension entrypoint that the registered integrator may classify and resolve to an opaque launch profile.
20690
+ *
20691
+ * @returns The launch profile for a supported entrypoint. Omit launch when the provider does not support the entrypoint.
20692
+ */
20693
+ resolve(params: ExtensionLaunchProviderResolveRequest): Promise<ExtensionLaunchProviderResolveResult>;
20694
+ }
20431
20695
  /** Handler for `llmInference` client global API methods. */
20432
20696
  /** @experimental */
20433
20697
  export interface LlmInferenceHandler {
@@ -20460,6 +20724,7 @@ export interface GitHubTelemetryHandler {
20460
20724
  }
20461
20725
  /** All client global API handler groups. */
20462
20726
  export interface ClientGlobalApiHandlers {
20727
+ extensionLaunchProvider?: ExtensionLaunchProviderHandler;
20463
20728
  llmInference?: LlmInferenceHandler;
20464
20729
  gitHubTelemetry?: GitHubTelemetryHandler;
20465
20730
  }
@@ -163,6 +163,12 @@ function createServerRpc(connection) {
163
163
  */
164
164
  disable: async (params) => connection.sendRequest("extensions.disable", params)
165
165
  },
166
+ /**
167
+ * Registers the calling SDK client as the per-entrypoint extension launch provider. Call before creating any sessions. When omitted, the runtime temporarily falls back to its built-in Node launcher for backward compatibility.
168
+ *
169
+ * @experimental
170
+ */
171
+ registerExtensionLaunchProvider: async () => connection.sendRequest("registerExtensionLaunchProvider", {}),
166
172
  /** @experimental */
167
173
  plugins: {
168
174
  /**
@@ -353,6 +359,15 @@ function createServerRpc(connection) {
353
359
  }
354
360
  },
355
361
  /** @experimental */
362
+ managedSettings: {
363
+ /**
364
+ * Discovers device-managed settings from production MDM and managed-file sources, validates them against the runtime-owned managed-settings schema, and returns the canonical JSON without requiring a session.
365
+ *
366
+ * @returns Validated device-managed settings discovered before a session exists.
367
+ */
368
+ read: async () => connection.sendRequest("managedSettings.read", {})
369
+ },
370
+ /** @experimental */
356
371
  runtime: {
357
372
  /**
358
373
  * Gracefully shuts down an SDK-owned runtime. The response is sent only after cleanup completes; callers may then terminate the owned runtime process.
@@ -2595,6 +2610,11 @@ function registerClientSessionApiHandlers(connection, getHandlers) {
2595
2610
  });
2596
2611
  }
2597
2612
  function registerClientGlobalApiHandlers(connection, handlers) {
2613
+ connection.onRequest("extensionLaunchProvider.resolve", async (params) => {
2614
+ const handler = handlers.extensionLaunchProvider;
2615
+ if (!handler) throw new Error("No extensionLaunchProvider client-global handler registered");
2616
+ return handler.resolve(params);
2617
+ });
2598
2618
  connection.onRequest("llmInference.httpRequestStart", async (params) => {
2599
2619
  const handler = handlers.llmInference;
2600
2620
  if (!handler) throw new Error("No llmInference client-global handler registered");
@@ -557,14 +557,18 @@ export type AutoModeResolvedReasoningBucket =
557
557
  /** The request looks high-reasoning; a stronger model is appropriate. */
558
558
  | "high";
559
559
  /**
560
- * Which channel supplied the effective enterprise managed settings (highest-authority present layer wins wholesale)
560
+ * Summary of which managed-settings channels contributed to the effective session policy. Use the per-channel booleans for exact provenance.
561
561
  */
562
562
  export type ManagedSettingsResolvedSource =
563
- /** Account/org policy self-fetched from the GitHub managed-settings endpoint (higher authority). */
563
+ /** Only the server/account channel contributed. */
564
564
  "server"
565
- /** Device-level MDM policy discovered from plist/registry/file (lower authority). */
565
+ /** Only the device MDM/plist/registry/file channel contributed. */
566
566
  | "device"
567
- /** No managed policy is in force (no layer contributed). */
567
+ /** Only session-local SDK-host injection contributed. */
568
+ | "client"
569
+ /** More than one channel contributed. Ordinary keys resolve device over server per key, while permissions compose restrictively across all present layers. */
570
+ | "mixed"
571
+ /** No managed policy is in force (no channel contributed). */
568
572
  | "none";
569
573
  /**
570
574
  * The category of runtime action that enterprise managed settings governed (blocked or capped)
@@ -8285,7 +8289,7 @@ export interface AutoModeResolvedData {
8285
8289
  stickyOverride?: boolean;
8286
8290
  }
8287
8291
  /**
8288
- * Session event "session.managed_settings_resolved". Enterprise managed-settings resolution: the effective managed settings the session applied and where they came from, so SDK clients can show users what is enterprise-managed and by which authority. Fires whenever managed policy is (re)applied — at session start, on resume, and on account switch. This is an ephemeral live snapshot (delivered to subscribers but not persisted to the session event log), because at session start it resolves before `session.start` is emitted; for a session-independent pull, use the SDK `getManagedSettings()` API, which returns the identical payload. Managed settings have a single authoritative source, so the highest-authority present layer (server > device) wins wholesale; `bypassPermissionsDisabled` is deny-wins across layers. Marked experimental while the managed-settings surface stabilizes.
8292
+ * Session event "session.managed_settings_resolved". Enterprise managed-settings resolution: the effective managed settings the session applied and which channels contributed, so SDK clients can show users what is enterprise-managed. Fires whenever managed policy is (re)applied — at session start, on resume, and on account switch. This is an ephemeral live snapshot (delivered to subscribers but not persisted to the session event log), because at session start it resolves before `session.start` is emitted. Device values take precedence over server values per ordinary key, while permissions compose restrictively across device, server, and SDK-client layers. The account-scoped `getManagedSettings()` API does not include session-local client injection. Marked experimental while the managed-settings surface stabilizes.
8289
8293
  */
8290
8294
  /** @experimental */
8291
8295
  export interface ManagedSettingsResolvedEvent {
@@ -8316,7 +8320,7 @@ export interface ManagedSettingsResolvedEvent {
8316
8320
  type: "session.managed_settings_resolved";
8317
8321
  }
8318
8322
  /**
8319
- * Enterprise managed-settings resolution: the effective managed settings the session applied and where they came from, so SDK clients can show users what is enterprise-managed and by which authority. Fires whenever managed policy is (re)applied — at session start, on resume, and on account switch. This is an ephemeral live snapshot (delivered to subscribers but not persisted to the session event log), because at session start it resolves before `session.start` is emitted; for a session-independent pull, use the SDK `getManagedSettings()` API, which returns the identical payload. Managed settings have a single authoritative source, so the highest-authority present layer (server > device) wins wholesale; `bypassPermissionsDisabled` is deny-wins across layers. Marked experimental while the managed-settings surface stabilizes.
8323
+ * Enterprise managed-settings resolution: the effective managed settings the session applied and which channels contributed, so SDK clients can show users what is enterprise-managed. Fires whenever managed policy is (re)applied — at session start, on resume, and on account switch. This is an ephemeral live snapshot (delivered to subscribers but not persisted to the session event log), because at session start it resolves before `session.start` is emitted. Device values take precedence over server values per ordinary key, while permissions compose restrictively across device, server, and SDK-client layers. The account-scoped `getManagedSettings()` API does not include session-local client injection. Marked experimental while the managed-settings surface stabilizes.
8320
8324
  */
8321
8325
  /** @experimental */
8322
8326
  export interface ManagedSettingsResolvedData {
@@ -8325,7 +8329,11 @@ export interface ManagedSettingsResolvedData {
8325
8329
  */
8326
8330
  bypassPermissionsDisabled: boolean;
8327
8331
  /**
8328
- * Whether the device (MDM/plist/registry/file) managed-settings layer was present
8332
+ * Whether a session-local permissions layer injected by the SDK host was present
8333
+ */
8334
+ clientManaged?: boolean;
8335
+ /**
8336
+ * Whether an actual device MDM/plist/registry/file managed-settings layer was present
8329
8337
  */
8330
8338
  deviceManaged: boolean;
8331
8339
  /**
@@ -8337,7 +8345,7 @@ export interface ManagedSettingsResolvedData {
8337
8345
  */
8338
8346
  managedKeys: string[];
8339
8347
  /**
8340
- * Whether server and device each supplied a permission allowlist, so enforcement intersects them and the flattened settings payload omits `permissions.allow`.
8348
+ * Whether at least two managed sources supplied permission allowlists, so enforcement intersects them and the flattened settings payload omits `permissions.allow`.
8341
8349
  */
8342
8350
  permissionsAllowIntersected?: boolean;
8343
8351
  /**
@@ -8775,6 +8783,10 @@ export interface SkillsLoadedSkill {
8775
8783
  * Optional freeform hint describing the skill's expected arguments, from the `argument-hint` frontmatter field
8776
8784
  */
8777
8785
  argumentHint?: string;
8786
+ /**
8787
+ * Canonical slash command name used to invoke the skill, without the leading '/'
8788
+ */
8789
+ commandName?: string;
8778
8790
  /**
8779
8791
  * Description of what the skill does
8780
8792
  */
package/dist/index.d.ts CHANGED
@@ -11,5 +11,5 @@ export { defineFactory, FactoryResumeError, isFactoryRunTerminal } from "./facto
11
11
  export { Canvas, CanvasError, createCanvas, type CanvasAction, type CanvasDeclaration, type CanvasHostContext, type CanvasHostContextCapabilities, type CanvasJsonSchema, type CanvasOptions, } from "./canvas.js";
12
12
  export { defineTool, approveAll, convertMcpCallToolResult, createSessionFsAdapter, CopilotRequestHandler, CopilotWebSocketHandler, CopilotWebSocketCloseStatus, CopilotWebSocketForwarder, SessionFsSqliteTransactionFailure, SYSTEM_MESSAGE_SECTIONS, } from "./types.js";
13
13
  export type * from "./generated/session-events.js";
14
- export type { CommandContext, CommandDefinition, CommandHandler, CanvasProviderIdentity, CloudSessionOptions, CloudSessionRepository, AutoModeSwitchHandler, AutoModeSwitchRequest, AutoModeSwitchResponse, AgentStopHandler, AgentStopHookInput, AgentStopHookOutput, CopilotClientMode, CopilotClientOptions, CopilotExpAssignmentResponse, StdioRuntimeConnection, InProcessRuntimeConnection, TcpRuntimeConnection, UriRuntimeConnection, ChildProcessRuntimeConnection, CustomAgentConfig, ElicitationFieldValue, ElicitationHandler, ElicitationParams, ElicitationContext, ElicitationResult, ElicitationSchema, ElicitationSchemaField, ExpConfigEntry, ExpFlagValue, ExitPlanModeHandler, ExitPlanModeRequest, ExitPlanModeResult, ExtensionInfo, ForegroundSessionInfo, GetAuthStatusResponse, GetStatusResponse, GitHubMcpToolConfig, GitHubTelemetryNotification, GitHubTelemetryEvent, GitHubTelemetryClientInfo, InfiniteSessionConfig, LargeToolOutputConfig, MemoryConfiguration, UiInputOptions, FactoryLimits, FactoryMeta, MCPStdioServerConfig, MCPHTTPServerConfig, MCPServerConfig, DefaultAgentConfig, BearerTokenProvider, MessageOptions, ModelBilling, ModelBillingTokenPrices, ModelBillingTokenPricesLongContext, CapiSessionOptions, ModelCapabilities, ModelCapabilitiesOverride, ModelInfo, ModelPolicy, NamedProviderConfig, PermissionHandler, PermissionRequest, PermissionRequestedData, PermissionRequestedEvent, PermissionRequestResult, ProviderConfig, ProviderModelConfig, ProviderTokenArgs, RemoteSessionMode, ResumeSessionConfig, SectionOverride, SectionOverrideAction, SectionTransformFn, SessionCapabilities, SessionConfig, SessionConfigBase, SessionEvent, SessionEventHandler, SessionEventPayload, SessionEventType, SessionLifecycleEvent, SessionLifecycleEventMetadata, SessionLifecycleEventType, SessionLifecycleHandler, SessionHooks, SessionCreatedEvent, SessionDeletedEvent, SessionUpdatedEvent, SessionForegroundEvent, SessionBackgroundEvent, SessionContext, SessionListFilter, SessionMetadata, SessionUiApi, SessionFsConfig, SessionFsProvider, SessionFsFileInfo, SessionFsSqliteQueryResult, SessionFsSqliteQueryType, SessionFsSqliteProvider, SessionFsSqliteStatement, SessionFsSqliteTransactionErrorClass, CopilotRequestContext, SystemMessageAppendConfig, SystemMessageConfig, SystemMessageCustomizeConfig, SystemMessageReplaceConfig, SystemMessageSection, TelemetryConfig, TraceContext, TraceContextProvider, Tool, ToolHandler, ToolInvocation, CurrentToolMetadata, ToolTelemetry, ToolResultObject, ToolSearchConfig, TypedSessionEventHandler, TypedSessionLifecycleHandler, ZodSchema, } from "./types.js";
14
+ export type { CommandContext, CommandDefinition, CommandHandler, CanvasProviderIdentity, CloudSessionOptions, CloudSessionRepository, AutoModeSwitchHandler, AutoModeSwitchRequest, AutoModeSwitchResponse, AgentStopHandler, AgentStopHookInput, AgentStopHookOutput, UserPromptTransformedHandler, UserPromptTransformedHookInput, UserPromptTransformedHookOutput, CopilotClientMode, CopilotClientOptions, CopilotExpAssignmentResponse, StdioRuntimeConnection, InProcessRuntimeConnection, TcpRuntimeConnection, UriRuntimeConnection, ChildProcessRuntimeConnection, CustomAgentConfig, ElicitationFieldValue, ElicitationHandler, ElicitationParams, ElicitationContext, ElicitationResult, ElicitationSchema, ElicitationSchemaField, ExpConfigEntry, ExpFlagValue, ExitPlanModeHandler, ExitPlanModeRequest, ExitPlanModeResult, ExtensionInfo, ForegroundSessionInfo, GetAuthStatusResponse, GetStatusResponse, GitHubMcpToolConfig, GitHubTelemetryNotification, GitHubTelemetryEvent, GitHubTelemetryClientInfo, InfiniteSessionConfig, LargeToolOutputConfig, MemoryConfiguration, UiInputOptions, FactoryLimits, FactoryMeta, MCPStdioServerConfig, MCPHTTPServerConfig, MCPServerConfig, DefaultAgentConfig, BearerTokenProvider, MessageOptions, ManagedSettings, ManagedSettingsPermissions, ModelBilling, ModelBillingTokenPrices, ModelBillingTokenPricesLongContext, CapiSessionOptions, ModelCapabilities, ModelCapabilitiesOverride, ModelInfo, ModelPolicy, NamedProviderConfig, PermissionHandler, PermissionRequest, PermissionRequestedData, PermissionRequestedEvent, PermissionRequestResult, ProviderConfig, ProviderModelConfig, ProviderTokenArgs, RemoteSessionMode, ResumeSessionConfig, SectionOverride, SectionOverrideAction, SectionTransformFn, SessionCapabilities, SessionConfig, SessionConfigBase, SessionEvent, SessionEventHandler, SessionEventPayload, SessionEventType, SessionLifecycleEvent, SessionLifecycleEventMetadata, SessionLifecycleEventType, SessionLifecycleHandler, SessionHooks, SessionCreatedEvent, SessionDeletedEvent, SessionUpdatedEvent, SessionForegroundEvent, SessionBackgroundEvent, SessionContext, SessionListFilter, SessionMetadata, SessionUiApi, SessionFsConfig, SessionFsProvider, SessionFsFileInfo, SessionFsSqliteQueryResult, SessionFsSqliteQueryType, SessionFsSqliteProvider, SessionFsSqliteStatement, SessionFsSqliteTransactionErrorClass, CopilotRequestContext, SystemMessageAppendConfig, SystemMessageConfig, SystemMessageCustomizeConfig, SystemMessageReplaceConfig, SystemMessageSection, TelemetryConfig, TraceContext, TraceContextProvider, Tool, ToolHandler, ToolInvocation, CurrentToolMetadata, ToolTelemetry, ToolResultObject, ToolSearchConfig, TypedSessionEventHandler, TypedSessionLifecycleHandler, ZodSchema, } from "./types.js";
15
15
  export type { RunOptions, ResumeOptions, FactoryResumeErrorCode, SessionFactoryApi, FactoryAgentOptions, FactoryContext, FactoryDefinition, FactoryHandle, FactoryJsonSchema, JsonValue, FactoryPipelineStage, FactoryStepOptions, FactoryRunResult, FactoryRunStatus, FactoryRunSummary, FactoryRunDetail, FactoryProgressPage, FactoryProgressLine, FactoryPhaseObservation, FactoryPhaseStatus, FactoryAgentSummary, } from "./factory.js";
package/dist/session.js CHANGED
@@ -430,22 +430,20 @@ class CopilotSession {
430
430
  async sendAndWait(optionsOrPrompt, timeout) {
431
431
  const options = typeof optionsOrPrompt === "string" ? { prompt: optionsOrPrompt } : optionsOrPrompt;
432
432
  const effectiveTimeout = timeout ?? 6e4;
433
- let resolveIdle;
434
- let rejectWithError;
435
- const idlePromise = new Promise((resolve, reject) => {
436
- resolveIdle = resolve;
437
- rejectWithError = reject;
433
+ let resolveOutcome;
434
+ const outcomePromise = new Promise((resolve) => {
435
+ resolveOutcome = resolve;
438
436
  });
439
437
  let lastAssistantMessage;
440
438
  const unsubscribe = this.on((event) => {
441
439
  if (event.type === "assistant.message") {
442
440
  lastAssistantMessage = event;
443
441
  } else if (event.type === "session.idle") {
444
- resolveIdle();
442
+ resolveOutcome({ kind: "idle" });
445
443
  } else if (event.type === "session.error") {
446
444
  const error = new Error(event.data.message);
447
445
  error.stack = event.data.stack;
448
- rejectWithError(error);
446
+ resolveOutcome({ kind: "error", error });
449
447
  }
450
448
  });
451
449
  let timeoutId;
@@ -461,7 +459,10 @@ class CopilotSession {
461
459
  effectiveTimeout
462
460
  );
463
461
  });
464
- await Promise.race([idlePromise, timeoutPromise]);
462
+ const outcome = await Promise.race([outcomePromise, timeoutPromise]);
463
+ if (outcome.kind === "error") {
464
+ throw outcome.error;
465
+ }
465
466
  return lastAssistantMessage;
466
467
  } finally {
467
468
  if (timeoutId !== void 0) {
@@ -1363,6 +1364,7 @@ class CopilotSession {
1363
1364
  postToolUse: this.hooks.onPostToolUse,
1364
1365
  postToolUseFailure: this.hooks.onPostToolUseFailure,
1365
1366
  userPromptSubmitted: this.hooks.onUserPromptSubmitted,
1367
+ userPromptTransformed: this.hooks.onUserPromptTransformed,
1366
1368
  sessionStart: this.hooks.onSessionStart,
1367
1369
  sessionEnd: this.hooks.onSessionEnd,
1368
1370
  errorOccurred: this.hooks.onErrorOccurred,
package/dist/types.d.ts CHANGED
@@ -484,6 +484,17 @@ export interface Tool<TArgs = unknown> {
484
484
  * Unknown keys are preserved and round-tripped untouched.
485
485
  */
486
486
  metadata?: Record<string, unknown>;
487
+ /**
488
+ * When true, a successful call to this tool ends the agent turn: the runtime's
489
+ * tool phase halts instead of feeding the tool result back to the model for
490
+ * another round. A failed call (for example input validation) leaves the loop
491
+ * running so the model can read the error and retry.
492
+ *
493
+ * Use this for tools whose whole purpose is to terminate the turn, such as a
494
+ * context clear that replaces the conversation the model would otherwise
495
+ * continue from.
496
+ */
497
+ isTerminal?: boolean;
487
498
  }
488
499
  /**
489
500
  * Helper to define a tool with Zod schema and get type inference for the handler.
@@ -497,6 +508,7 @@ export declare function defineTool<T = unknown>(name: string, config: {
497
508
  skipPermission?: boolean;
498
509
  defer?: "auto" | "never";
499
510
  metadata?: Record<string, unknown>;
511
+ isTerminal?: boolean;
500
512
  }): Tool<T>;
501
513
  /**
502
514
  * SDK-supplied override for the runtime's built-in tool-search behavior.
@@ -1110,6 +1122,29 @@ export interface UserPromptSubmittedHookOutput {
1110
1122
  export type UserPromptSubmittedHandler = (input: UserPromptSubmittedHookInput, invocation: {
1111
1123
  sessionId: string;
1112
1124
  }) => Promise<UserPromptSubmittedHookOutput | void> | UserPromptSubmittedHookOutput | void;
1125
+ /**
1126
+ * Input for the user-prompt-transformed hook.
1127
+ *
1128
+ * This hook runs after the runtime has transformed the submitted prompt with
1129
+ * generated context, but before it is persisted to session history or sent to
1130
+ * the model.
1131
+ */
1132
+ export interface UserPromptTransformedHookInput extends BaseHookInput {
1133
+ prompt: string;
1134
+ transformedPrompt: string;
1135
+ }
1136
+ /**
1137
+ * Output for the user-prompt-transformed hook.
1138
+ */
1139
+ export interface UserPromptTransformedHookOutput {
1140
+ modifiedTransformedPrompt?: string;
1141
+ }
1142
+ /**
1143
+ * Handler for the user-prompt-transformed hook.
1144
+ */
1145
+ export type UserPromptTransformedHandler = (input: UserPromptTransformedHookInput, invocation: {
1146
+ sessionId: string;
1147
+ }) => Promise<UserPromptTransformedHookOutput | void> | UserPromptTransformedHookOutput | void;
1113
1148
  /**
1114
1149
  * Input for session-start hook
1115
1150
  */
@@ -1245,6 +1280,10 @@ export interface SessionHooks {
1245
1280
  * Called when the user submits a prompt
1246
1281
  */
1247
1282
  onUserPromptSubmitted?: UserPromptSubmittedHandler;
1283
+ /**
1284
+ * Called after the runtime transforms a submitted prompt and before it is stored.
1285
+ */
1286
+ onUserPromptTransformed?: UserPromptTransformedHandler;
1248
1287
  /**
1249
1288
  * Called when a session starts
1250
1289
  */
@@ -1450,7 +1489,7 @@ export interface LargeToolOutputConfig {
1450
1489
  /**
1451
1490
  * Valid reasoning effort levels for models that support it.
1452
1491
  */
1453
- export type ReasoningEffort = "low" | "medium" | "high" | "xhigh";
1492
+ export type ReasoningEffort = "low" | "medium" | "high" | "xhigh" | "max";
1454
1493
  /**
1455
1494
  * Context window tier for the session. "long_context" pins the session to the
1456
1495
  * long-context tier when the selected model supports it.
@@ -1655,6 +1694,43 @@ export interface GitHubMcpToolConfig {
1655
1694
  enableInsidersMode?: boolean;
1656
1695
  disableFormDeferral?: boolean;
1657
1696
  }
1697
+ /**
1698
+ * Permissions-only managed policy injected by the host via
1699
+ * {@link SessionConfigBase.managedSettings}.
1700
+ *
1701
+ * Rule strings use the same vocabulary the runtime accepts for fetched managed
1702
+ * policy (e.g. `"Read(**)"`, `"Shell(git push *)"`); malformed rules are
1703
+ * rejected at session creation.
1704
+ */
1705
+ export interface ManagedSettingsPermissions {
1706
+ /**
1707
+ * When set to `"disable"`, bypass-permissions ("yolo") mode is turned off
1708
+ * for the session. This is deny-wins: it cannot be re-enabled by any other
1709
+ * layer.
1710
+ */
1711
+ disableBypassPermissionsMode?: "disable";
1712
+ /** Operations that must always be denied. Unioned across managed layers. */
1713
+ deny?: string[];
1714
+ /**
1715
+ * Operations that must prompt for approval. Unioned across managed layers.
1716
+ */
1717
+ ask?: string[];
1718
+ /**
1719
+ * Operations permitted without prompting. Every declared `allow` list
1720
+ * (across managed layers) must admit an operation for it to be allowed.
1721
+ */
1722
+ allow?: string[];
1723
+ }
1724
+ /**
1725
+ * Host-injected enterprise managed settings. The first supported contract is
1726
+ * permissions-only; unknown sibling keys are rejected by the runtime.
1727
+ *
1728
+ * @see {@link SessionConfigBase.managedSettings}
1729
+ */
1730
+ export interface ManagedSettings {
1731
+ /** Managed permission policy for the session. */
1732
+ permissions?: ManagedSettingsPermissions;
1733
+ }
1658
1734
  /**
1659
1735
  * Shared configuration fields used by both {@link SessionConfig} (for
1660
1736
  * creating a new session) and {@link ResumeSessionConfig} (for resuming
@@ -2057,6 +2133,12 @@ export interface SessionConfigBase {
2057
2133
  * List of skill names to disable.
2058
2134
  */
2059
2135
  disabledSkills?: string[];
2136
+ /**
2137
+ * Exact MCP server names to disable for this session. Disabled servers are not
2138
+ * started or authenticated when creating or cold-resuming a session. Supplying
2139
+ * this on a resident resume cannot stop servers that are already running.
2140
+ */
2141
+ disabledMcpServers?: string[];
2060
2142
  /**
2061
2143
  * Infinite session configuration for persistent workspaces and automatic compaction.
2062
2144
  * When enabled (default), sessions automatically manage context limits and persist state.
@@ -2085,6 +2167,30 @@ export interface SessionConfigBase {
2085
2167
  * if omitted, the runtime is expected to reject session creation (fail-closed).
2086
2168
  */
2087
2169
  enableManagedSettings?: boolean;
2170
+ /**
2171
+ * Host-injected enterprise managed settings for this session.
2172
+ *
2173
+ * Unlike {@link SessionConfigBase.enableManagedSettings} — which asks the
2174
+ * runtime to *self-fetch* account/org and device policy — this field lets
2175
+ * the host supply the managed policy directly. The runtime validates it
2176
+ * with the same managed-permission parser it uses for fetched policy and
2177
+ * composes it restrictively with any self-fetched (server) and
2178
+ * device-managed (MDM) layers: `deny`/`ask` rules are unioned, every
2179
+ * declared `allow` list must admit an operation, and
2180
+ * `disableBypassPermissionsMode: "disable"` is deny-wins.
2181
+ *
2182
+ * This is startup-only. It is **not** persisted: it must be re-supplied on
2183
+ * {@link CopilotClient.resumeSession | resume}, where it replaces the prior
2184
+ * injected layer (omitting it clears the layer, so warm and cold resume
2185
+ * behave identically). It may be combined with `enableManagedSettings`;
2186
+ * when both are supplied the injected, server, and device restrictions all
2187
+ * apply.
2188
+ *
2189
+ * Requires a Copilot runtime whose RPC schema includes `managedSettings`.
2190
+ * Older runtimes may ignore this additive field, so hosts must not rely on
2191
+ * injected policy until they ship a compatible runtime.
2192
+ */
2193
+ managedSettings?: ManagedSettings;
2088
2194
  /**
2089
2195
  * When true, skips embedding-based retrieval for this session.
2090
2196
  * Use in multitenant deployments to prevent cross-session information leakage
@@ -270,7 +270,7 @@ const unsub = session.on("tool.execution_complete", (event) => {
270
270
  | `tool.execution_start` | `toolCallId`, `toolName`, `arguments` |
271
271
  | `tool.execution_complete` | `toolCallId`, `success`, `result`, `error` |
272
272
  | `user.message` | `content`, `attachments`, `source` |
273
- | `session.idle` | `backgroundTasks` |
273
+ | `session.idle` | `aborted` |
274
274
  | `session.error` | `errorType`, `message`, `stack` |
275
275
  | `permission.requested` | `requestId`, `permissionRequest.kind` |
276
276
  | `session.shutdown` | `shutdownType`, `totalPremiumRequests` |
package/docs/examples.md CHANGED
@@ -419,7 +419,7 @@ session.on("assistant.message", (event) => {
419
419
  | `tool.execution_start` | A tool is about to run | `toolCallId`, `toolName`, `arguments` |
420
420
  | `tool.execution_complete` | A tool finished running | `toolCallId`, `success`, `result`, `error` |
421
421
  | `user.message` | User sent a message | `content`, `attachments`, `source` |
422
- | `session.idle` | Session finished processing a turn | `backgroundTasks` |
422
+ | `session.idle` | Session finished processing a turn | `aborted` |
423
423
  | `session.error` | An error occurred | `errorType`, `message`, `stack` |
424
424
  | `permission.requested` | Agent needs permission (shell, file write, etc.) | `requestId`, `permissionRequest.kind` |
425
425
  | `session.shutdown` | Session is ending | `shutdownType`, `totalPremiumRequests`, `codeChanges` |
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "type": "git",
5
5
  "url": "https://github.com/github/copilot-sdk.git"
6
6
  },
7
- "version": "1.0.9-preview.3",
7
+ "version": "1.0.10-preview.0",
8
8
  "description": "TypeScript SDK for programmatic control of GitHub Copilot CLI via JSON-RPC",
9
9
  "main": "./dist/cjs/index.js",
10
10
  "types": "./dist/index.d.ts",
@@ -56,7 +56,7 @@
56
56
  "author": "GitHub",
57
57
  "license": "MIT",
58
58
  "dependencies": {
59
- "@github/copilot": "^1.0.78",
59
+ "@github/copilot": "^1.0.79-6",
60
60
  "koffi": "^3.1.0",
61
61
  "vscode-jsonrpc": "^8.2.1",
62
62
  "zod": "^4.3.6"