@github/copilot-sdk 1.0.23 → 1.0.24-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
@@ -387,9 +387,9 @@ Create a new conversation session.
387
387
  - `systemMessage?: SystemMessageConfig` - System message customization (see below)
388
388
  - `infiniteSessions?: InfiniteSessionConfig` - Configure automatic context compaction (see below)
389
389
  - `workingDirectory?: string` - Working directory for the session (default: runtime process cwd).
390
+ - `trustWorkingDirectory?: "session" | "user"` - Grant trust to the canonical working directory during session creation. `"session"` trusts it only for this session; `"user"` persists trust for later sessions. Omit to leave trust unchanged. Not available on resume.
390
391
  - `refreshCustomInstructions?: boolean` - Invalidates the process-wide custom-instruction discovery cache before creating this session, so instruction-file edits made in the same runtime are read again. Defaults to `false` (cache reuse). Other sessions in this runtime may observe updated instructions on later turns or discovery. This does not watch files or enable disabled instruction loading. Available on `SessionConfig`, not `ResumeSessionConfig`.
391
392
  - `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.
392
- - `enableGitHubCacheStore?: boolean` - Requests the read-only GitHub cache store (`github-cache-store` capability) on create or resume. The runtime registers the `github_sql` tool only when its `GITHUB_CACHE_STORE` feature flag is also on. Defaults to disabled in every mode.
393
393
  - `gitHubTokenProvider?: GitHubTokenProvider` - Acquires rotating, session-scoped GitHub tokens. Token results require a positive `expiresIn` value in seconds remaining when the callback completes; production tokens typically last eight hours. Cannot be combined with `gitHubToken`.
394
394
  - `provider?: ProviderConfig` - Custom API provider configuration (BYOK - Bring Your Own Key). See [Custom Providers](#custom-providers) section.
395
395
  - `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.
@@ -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.100";
25
+ const COPILOT_CLI_VERSION = "1.0.101-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 = {
@@ -780,11 +780,19 @@ class CopilotClient {
780
780
  const sessionId = session.sessionId;
781
781
  let lastError = null;
782
782
  for (let attempt = 1; attempt <= 3; attempt++) {
783
+ if (this.connectionClosed) {
784
+ lastError = null;
785
+ break;
786
+ }
783
787
  try {
784
788
  await session.disconnect();
785
789
  lastError = null;
786
790
  break;
787
791
  } catch (error) {
792
+ if (this.connectionClosed) {
793
+ lastError = null;
794
+ break;
795
+ }
788
796
  lastError = error instanceof Error ? error : new Error(String(error));
789
797
  if (attempt < 3) {
790
798
  const delay = 100 * Math.pow(2, attempt - 1);
@@ -970,8 +978,10 @@ class CopilotClient {
970
978
  * - Clears all sessions immediately without destroying them
971
979
  * - Force closes the connection
972
980
  * - Sends SIGKILL to the CLI process (if spawned by this client)
981
+ * - Waits for the spawned CLI process to exit
973
982
  *
974
983
  * @returns A promise that resolves when the force stop is complete
984
+ * @throws If the spawned CLI process cannot be terminated
975
985
  *
976
986
  * @example
977
987
  * ```typescript
@@ -1018,13 +1028,6 @@ class CopilotClient {
1018
1028
  }
1019
1029
  this.socket = null;
1020
1030
  }
1021
- if (this.cliProcess && !this.isExternalServer) {
1022
- try {
1023
- this.cliProcess.kill("SIGKILL");
1024
- } catch {
1025
- }
1026
- this.cliProcess = null;
1027
- }
1028
1031
  if (this.ffiHost) {
1029
1032
  const host = this.ffiHost;
1030
1033
  this.ffiHost = null;
@@ -1041,6 +1044,20 @@ class CopilotClient {
1041
1044
  this.runtimePort = null;
1042
1045
  this.stderrBuffer = "";
1043
1046
  this.processExitPromise = null;
1047
+ if (this.cliProcess && !this.isExternalServer) {
1048
+ const child = this.cliProcess;
1049
+ if (child.exitCode == null && child.signalCode == null) {
1050
+ child.kill("SIGKILL");
1051
+ if (!await waitForChildExit(child, RUNTIME_SHUTDOWN_TIMEOUT_MS)) {
1052
+ throw new Error(
1053
+ `Timed out waiting for CLI process to exit after SIGKILL: ${RUNTIME_SHUTDOWN_TIMEOUT_MS}ms`
1054
+ );
1055
+ }
1056
+ }
1057
+ if (this.cliProcess === child) {
1058
+ this.cliProcess = null;
1059
+ }
1060
+ }
1044
1061
  }
1045
1062
  /**
1046
1063
  * Creates a new conversation session with the Copilot CLI.
@@ -1313,7 +1330,8 @@ class CopilotClient {
1313
1330
  skipPermission: tool.skipPermission,
1314
1331
  defer: tool.defer,
1315
1332
  metadata: tool.metadata,
1316
- isTerminal: tool.isTerminal
1333
+ isTerminal: tool.isTerminal,
1334
+ namespace: tool.namespace
1317
1335
  })),
1318
1336
  toolSearch: config.toolSearch,
1319
1337
  imageGeneration: config.imageGeneration,
@@ -1352,6 +1370,7 @@ class CopilotClient {
1352
1370
  requestAutoModeSwitch: !!config.onAutoModeSwitchRequest,
1353
1371
  hooks: !!(config.hooks && Object.values(config.hooks).some(Boolean)),
1354
1372
  workingDirectory: config.workingDirectory,
1373
+ trustWorkingDirectory: config.trustWorkingDirectory,
1355
1374
  additionalDirectories: config.additionalDirectories,
1356
1375
  streaming: config.streaming,
1357
1376
  includeSubAgentStreamingEvents: config.includeSubAgentStreamingEvents ?? true,
@@ -1375,7 +1394,6 @@ class CopilotClient {
1375
1394
  enableFileHooks: config.enableFileHooks,
1376
1395
  enableHostGitOperations: config.enableHostGitOperations,
1377
1396
  enableSessionStore: config.enableSessionStore,
1378
- enableGitHubCacheStore: config.enableGitHubCacheStore,
1379
1397
  enableSkills: config.enableSkills,
1380
1398
  skillDirectories: config.skillDirectories,
1381
1399
  ...config.skillProvider ? { hasSkillProvider: true } : {},
@@ -1594,7 +1612,8 @@ class CopilotClient {
1594
1612
  skipPermission: tool.skipPermission,
1595
1613
  defer: tool.defer,
1596
1614
  metadata: tool.metadata,
1597
- isTerminal: tool.isTerminal
1615
+ isTerminal: tool.isTerminal,
1616
+ namespace: tool.namespace
1598
1617
  })),
1599
1618
  toolSearch: config.toolSearch,
1600
1619
  imageGeneration: config.imageGeneration,
@@ -1635,7 +1654,6 @@ class CopilotClient {
1635
1654
  enableFileHooks: config.enableFileHooks,
1636
1655
  enableHostGitOperations: config.enableHostGitOperations,
1637
1656
  enableSessionStore: config.enableSessionStore,
1638
- enableGitHubCacheStore: config.enableGitHubCacheStore,
1639
1657
  enableSkills: config.enableSkills,
1640
1658
  streaming: config.streaming,
1641
1659
  includeSubAgentStreamingEvents: config.includeSubAgentStreamingEvents ?? true,
@@ -2436,7 +2454,13 @@ stderr: ${stderrOutput}`
2436
2454
  this.cliStartTimeout = setTimeout(() => {
2437
2455
  if (!resolved) {
2438
2456
  resolved = true;
2439
- reject(new Error("Timeout waiting for CLI server to start"));
2457
+ reject(
2458
+ new Error(
2459
+ `Timeout waiting for CLI server to start
2460
+ stdout: ${stdout.trim().slice(-8192) || "(empty)"}
2461
+ stderr: ${this.stderrBuffer.trim().slice(-8192) || "(empty)"}`
2462
+ )
2463
+ );
2440
2464
  }
2441
2465
  }, 3e4);
2442
2466
  });
@@ -2571,6 +2595,9 @@ stderr: ${stderrOutput}`
2571
2595
  stderr: ${stderrOutput}` : ""}`
2572
2596
  );
2573
2597
  this.logDebug(`stdin pipe error: ${reason}`);
2598
+ if (this.messageWriter) {
2599
+ this.messageWriter.suppressWriteErrors = true;
2600
+ }
2574
2601
  try {
2575
2602
  this.connection?.dispose();
2576
2603
  } catch {
@@ -47,7 +47,8 @@ function toToolDefinition(tool) {
47
47
  skipPermission: tool.skipPermission,
48
48
  defer: tool.defer,
49
49
  metadata: tool.metadata,
50
- isTerminal: tool.isTerminal
50
+ isTerminal: tool.isTerminal,
51
+ namespace: tool.namespace
51
52
  };
52
53
  }
53
54
  const workflowExecutionStore = new import_node_async_hooks.AsyncLocalStorage();
@@ -1,2 +1,2 @@
1
- export declare const COPILOT_CLI_VERSION = "1.0.100";
1
+ export declare const COPILOT_CLI_VERSION = "1.0.101-0";
2
2
  export declare const COPILOT_CLI_USE_NPM_PACKAGE = false;
@@ -1,4 +1,4 @@
1
- const COPILOT_CLI_VERSION = "1.0.100";
1
+ const COPILOT_CLI_VERSION = "1.0.101-0";
2
2
  const COPILOT_CLI_USE_NPM_PACKAGE = false;
3
3
  export {
4
4
  COPILOT_CLI_USE_NPM_PACKAGE,
package/dist/client.d.ts CHANGED
@@ -179,8 +179,10 @@ export declare class CopilotClient {
179
179
  * - Clears all sessions immediately without destroying them
180
180
  * - Force closes the connection
181
181
  * - Sends SIGKILL to the CLI process (if spawned by this client)
182
+ * - Waits for the spawned CLI process to exit
182
183
  *
183
184
  * @returns A promise that resolves when the force stop is complete
185
+ * @throws If the spawned CLI process cannot be terminated
184
186
  *
185
187
  * @example
186
188
  * ```typescript
package/dist/client.js CHANGED
@@ -760,11 +760,19 @@ class CopilotClient {
760
760
  const sessionId = session.sessionId;
761
761
  let lastError = null;
762
762
  for (let attempt = 1; attempt <= 3; attempt++) {
763
+ if (this.connectionClosed) {
764
+ lastError = null;
765
+ break;
766
+ }
763
767
  try {
764
768
  await session.disconnect();
765
769
  lastError = null;
766
770
  break;
767
771
  } catch (error) {
772
+ if (this.connectionClosed) {
773
+ lastError = null;
774
+ break;
775
+ }
768
776
  lastError = error instanceof Error ? error : new Error(String(error));
769
777
  if (attempt < 3) {
770
778
  const delay = 100 * Math.pow(2, attempt - 1);
@@ -950,8 +958,10 @@ class CopilotClient {
950
958
  * - Clears all sessions immediately without destroying them
951
959
  * - Force closes the connection
952
960
  * - Sends SIGKILL to the CLI process (if spawned by this client)
961
+ * - Waits for the spawned CLI process to exit
953
962
  *
954
963
  * @returns A promise that resolves when the force stop is complete
964
+ * @throws If the spawned CLI process cannot be terminated
955
965
  *
956
966
  * @example
957
967
  * ```typescript
@@ -998,13 +1008,6 @@ class CopilotClient {
998
1008
  }
999
1009
  this.socket = null;
1000
1010
  }
1001
- if (this.cliProcess && !this.isExternalServer) {
1002
- try {
1003
- this.cliProcess.kill("SIGKILL");
1004
- } catch {
1005
- }
1006
- this.cliProcess = null;
1007
- }
1008
1011
  if (this.ffiHost) {
1009
1012
  const host = this.ffiHost;
1010
1013
  this.ffiHost = null;
@@ -1021,6 +1024,20 @@ class CopilotClient {
1021
1024
  this.runtimePort = null;
1022
1025
  this.stderrBuffer = "";
1023
1026
  this.processExitPromise = null;
1027
+ if (this.cliProcess && !this.isExternalServer) {
1028
+ const child = this.cliProcess;
1029
+ if (child.exitCode == null && child.signalCode == null) {
1030
+ child.kill("SIGKILL");
1031
+ if (!await waitForChildExit(child, RUNTIME_SHUTDOWN_TIMEOUT_MS)) {
1032
+ throw new Error(
1033
+ `Timed out waiting for CLI process to exit after SIGKILL: ${RUNTIME_SHUTDOWN_TIMEOUT_MS}ms`
1034
+ );
1035
+ }
1036
+ }
1037
+ if (this.cliProcess === child) {
1038
+ this.cliProcess = null;
1039
+ }
1040
+ }
1024
1041
  }
1025
1042
  /**
1026
1043
  * Creates a new conversation session with the Copilot CLI.
@@ -1293,7 +1310,8 @@ class CopilotClient {
1293
1310
  skipPermission: tool.skipPermission,
1294
1311
  defer: tool.defer,
1295
1312
  metadata: tool.metadata,
1296
- isTerminal: tool.isTerminal
1313
+ isTerminal: tool.isTerminal,
1314
+ namespace: tool.namespace
1297
1315
  })),
1298
1316
  toolSearch: config.toolSearch,
1299
1317
  imageGeneration: config.imageGeneration,
@@ -1332,6 +1350,7 @@ class CopilotClient {
1332
1350
  requestAutoModeSwitch: !!config.onAutoModeSwitchRequest,
1333
1351
  hooks: !!(config.hooks && Object.values(config.hooks).some(Boolean)),
1334
1352
  workingDirectory: config.workingDirectory,
1353
+ trustWorkingDirectory: config.trustWorkingDirectory,
1335
1354
  additionalDirectories: config.additionalDirectories,
1336
1355
  streaming: config.streaming,
1337
1356
  includeSubAgentStreamingEvents: config.includeSubAgentStreamingEvents ?? true,
@@ -1355,7 +1374,6 @@ class CopilotClient {
1355
1374
  enableFileHooks: config.enableFileHooks,
1356
1375
  enableHostGitOperations: config.enableHostGitOperations,
1357
1376
  enableSessionStore: config.enableSessionStore,
1358
- enableGitHubCacheStore: config.enableGitHubCacheStore,
1359
1377
  enableSkills: config.enableSkills,
1360
1378
  skillDirectories: config.skillDirectories,
1361
1379
  ...config.skillProvider ? { hasSkillProvider: true } : {},
@@ -1574,7 +1592,8 @@ class CopilotClient {
1574
1592
  skipPermission: tool.skipPermission,
1575
1593
  defer: tool.defer,
1576
1594
  metadata: tool.metadata,
1577
- isTerminal: tool.isTerminal
1595
+ isTerminal: tool.isTerminal,
1596
+ namespace: tool.namespace
1578
1597
  })),
1579
1598
  toolSearch: config.toolSearch,
1580
1599
  imageGeneration: config.imageGeneration,
@@ -1615,7 +1634,6 @@ class CopilotClient {
1615
1634
  enableFileHooks: config.enableFileHooks,
1616
1635
  enableHostGitOperations: config.enableHostGitOperations,
1617
1636
  enableSessionStore: config.enableSessionStore,
1618
- enableGitHubCacheStore: config.enableGitHubCacheStore,
1619
1637
  enableSkills: config.enableSkills,
1620
1638
  streaming: config.streaming,
1621
1639
  includeSubAgentStreamingEvents: config.includeSubAgentStreamingEvents ?? true,
@@ -2416,7 +2434,13 @@ stderr: ${stderrOutput}`
2416
2434
  this.cliStartTimeout = setTimeout(() => {
2417
2435
  if (!resolved) {
2418
2436
  resolved = true;
2419
- reject(new Error("Timeout waiting for CLI server to start"));
2437
+ reject(
2438
+ new Error(
2439
+ `Timeout waiting for CLI server to start
2440
+ stdout: ${stdout.trim().slice(-8192) || "(empty)"}
2441
+ stderr: ${this.stderrBuffer.trim().slice(-8192) || "(empty)"}`
2442
+ )
2443
+ );
2420
2444
  }
2421
2445
  }, 3e4);
2422
2446
  });
@@ -2551,6 +2575,9 @@ stderr: ${stderrOutput}`
2551
2575
  stderr: ${stderrOutput}` : ""}`
2552
2576
  );
2553
2577
  this.logDebug(`stdin pipe error: ${reason}`);
2578
+ if (this.messageWriter) {
2579
+ this.messageWriter.suppressWriteErrors = true;
2580
+ }
2554
2581
  try {
2555
2582
  this.connection?.dispose();
2556
2583
  } catch {
@@ -5011,8 +5011,6 @@ export type SessionCapability =
5011
5011
  | "elicitation"
5012
5012
  /** Cross-session history tools and session-store SQL prompt/tool metadata. */
5013
5013
  | "session-store"
5014
- /** Read-only GitHub cache SQL tool (github_sql). */
5015
- | "github-cache-store"
5016
5014
  /** MCP Apps UI passthrough. */
5017
5015
  | "mcp-apps"
5018
5016
  /** Host-provided canvas rendering support. */
@@ -8246,6 +8244,49 @@ export interface AutopilotObjectiveState {
8246
8244
  creditCountNanoAiu: string;
8247
8245
  creditLimit?: AutopilotObjectiveCreditLimit;
8248
8246
  }
8247
+ /**
8248
+ * Billing information for a server-advertised routing preference.
8249
+ *
8250
+ * This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
8251
+ * via the `definition` "AutoTierBilling".
8252
+ */
8253
+ /** @experimental */
8254
+ export interface AutoTierBilling {
8255
+ promo?: AutoTierBillingPromo;
8256
+ }
8257
+ /**
8258
+ * Server-driven promotion for an Auto routing preference. It can be announced before it starts.
8259
+ *
8260
+ * This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
8261
+ * via the `definition` "AutoTierBillingPromo".
8262
+ */
8263
+ /** @experimental */
8264
+ export interface AutoTierBillingPromo {
8265
+ /**
8266
+ * Stable identifier for the promotion campaign.
8267
+ */
8268
+ id?: string;
8269
+ /**
8270
+ * Percentage discount (0-100) while the promotion is active. Absent or 0 means the promotion is an announcement only: do not present a discount.
8271
+ */
8272
+ discountPercent?: number;
8273
+ /**
8274
+ * UTC ISO 8601 timestamp marking when the promotion starts. The service can announce a promotion before it starts, so do not present the discount as active before this time. Absent means it has already started.
8275
+ */
8276
+ startsAt?: string;
8277
+ /**
8278
+ * UTC ISO 8601 timestamp marking when the promotion ends. Absent means open-ended. The runtime omits promotions that have already ended.
8279
+ */
8280
+ endsAt?: string;
8281
+ /**
8282
+ * Human-readable promotion message. Does not include the start or end timestamps.
8283
+ */
8284
+ message?: string;
8285
+ /**
8286
+ * Whether the service asked hosts to give this promotion a prominent surface, such as a banner. Absent means the service expressed no preference, so hosts should apply their own default rather than read it as `false`.
8287
+ */
8288
+ showBanner?: boolean;
8289
+ }
8249
8290
  /**
8250
8291
  * A server-advertised routing preference. Identifiers and execution types are extensible.
8251
8292
  *
@@ -8271,6 +8312,7 @@ export interface AutoTierDescriptor {
8271
8312
  */
8272
8313
  type: string;
8273
8314
  status: AutoTierStatus;
8315
+ billing?: AutoTierBilling;
8274
8316
  }
8275
8317
  /**
8276
8318
  * Availability of a server-advertised routing preference.
@@ -8284,6 +8326,10 @@ export interface AutoTierStatus {
8284
8326
  * Whether the provider permits selecting this preference.
8285
8327
  */
8286
8328
  enabled: boolean;
8329
+ /**
8330
+ * Whether hosts should list this preference in a picker. Absent means visible. A hidden preference can still be requested explicitly through the SDK.
8331
+ */
8332
+ pickerVisible?: boolean;
8287
8333
  /**
8288
8334
  * Extensible machine-readable unavailability reason.
8289
8335
  */
@@ -21300,6 +21346,10 @@ export interface PermissionsConfigureParams {
21300
21346
  * If specified, replaces the host-supplied GitHub Content Exclusion policies on the session (combined with natively-discovered policies when evaluating tool/file access). Omit to leave the current policies unchanged.
21301
21347
  */
21302
21348
  additionalContentExclusionPolicies?: PermissionsConfigureAdditionalContentExclusionPolicy[];
21349
+ /**
21350
+ * User-authored instructions appended verbatim to the assisted-approval judge's system prompt. Applies to subsequent judge requests in this local session without changing permission mode, pre-judge gates, or the coding agent's prompt. Omit to leave unchanged; an empty or whitespace-only string clears the instructions. Hosts must reapply their configuration after resuming a session. Remote sessions are not supported.
21351
+ */
21352
+ assistedApprovalInstructions?: string;
21303
21353
  }
21304
21354
  /**
21305
21355
  * If specified, replaces the session's URL-permission policy. The runtime constructs a fresh DefaultUrlManager based on these inputs. Omit to leave the current URL policy unchanged.
@@ -22233,6 +22283,24 @@ export interface ProtocolExternalToolDefinition {
22233
22283
  metadata?: {
22234
22284
  [k: string]: JsonValue | undefined;
22235
22285
  };
22286
+ namespace?: ProtocolExternalToolNamespace;
22287
+ }
22288
+ /**
22289
+ * Namespace that groups related caller-implemented tools for model tool discovery.
22290
+ *
22291
+ * This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
22292
+ * via the `definition` "ProtocolExternalToolNamespace".
22293
+ */
22294
+ /** @experimental */
22295
+ export interface ProtocolExternalToolNamespace {
22296
+ /**
22297
+ * Namespace name: 1-64 ASCII letters, digits, underscores, or hyphens.
22298
+ */
22299
+ name: string;
22300
+ /**
22301
+ * Optional model-visible explanation of the tools in this namespace.
22302
+ */
22303
+ description?: string;
22236
22304
  }
22237
22305
  /**
22238
22306
  * Opt into native CAPI image generation.
@@ -22246,6 +22314,16 @@ export interface ProtocolImageGenerationOptions {
22246
22314
  * Disabled by default for SDK sessions. CAPI model access and permissions still apply.
22247
22315
  */
22248
22316
  enabled?: boolean;
22317
+ /**
22318
+ * Experimental. Request a visible "Made with AI" label on generated and edited images.
22319
+ * This option may change or be removed in a future release.
22320
+ * Overrides the user's imageGenerationWatermark preference for this session;
22321
+ * otherwise that preference applies, defaulting to false. Re-supply after a
22322
+ * cold resume. Does not enable image generation or enforce enterprise policy.
22323
+ *
22324
+ * @experimental
22325
+ */
22326
+ watermark?: boolean;
22249
22327
  }
22250
22328
  /**
22251
22329
  * BYOK providers and/or models to add to the session's registry at runtime. Both fields are optional; provide providers, models, or both.
@@ -22296,6 +22374,10 @@ export interface ProviderConfig {
22296
22374
  * API key. Optional for local providers like Ollama.
22297
22375
  */
22298
22376
  apiKey?: string;
22377
+ /**
22378
+ * Command run by the runtime before each provider request to obtain a fresh API key. Credential-command failures fail the turn without sending a model request. Bearer authentication takes precedence.
22379
+ */
22380
+ apiKeyCommand?: string;
22299
22381
  /**
22300
22382
  * Bearer token for authentication. Sets the Authorization header directly. Takes precedence over apiKey when both are set.
22301
22383
  */
@@ -499,7 +499,7 @@ export type CompactionTrigger =
499
499
  | "manual"
500
500
  /** Emergency compaction triggered by high process memory usage. */
501
501
  | "memory_pressure"
502
- /** Compaction requested while switching to a model with a smaller context window. */
502
+ /** Compaction requested while switching to a model with a smaller context window, including a HydraFusion turn's routed root model. */
503
503
  | "model_switch";
504
504
  /**
505
505
  * Category of structured task blocker
@@ -3942,7 +3942,7 @@ export interface CompactionStartData {
3942
3942
  */
3943
3943
  model?: string;
3944
3944
  /**
3945
- * Destination model for a model-switch compaction when it differs from the compacting model
3945
+ * Destination model for a model-switch compaction when it differs from the compacting model; for a HydraFusion turn, the routed root model
3946
3946
  */
3947
3947
  switchTargetModel?: string;
3948
3948
  /**
@@ -4084,7 +4084,7 @@ export interface CompactionCompleteData {
4084
4084
  */
4085
4085
  summaryContent?: string;
4086
4086
  /**
4087
- * Destination model for a model-switch compaction when it differs from the compacting model
4087
+ * Destination model for a model-switch compaction when it differs from the compacting model; for a HydraFusion turn, the routed root model
4088
4088
  */
4089
4089
  switchTargetModel?: string;
4090
4090
  /**
@@ -6946,7 +6946,7 @@ export interface ModelCallFailureData {
6946
6946
  */
6947
6947
  durationMs?: number;
6948
6948
  /**
6949
- * For HTTP 400 failures only: the `code` from the CAPI error envelope (e.g. 'model_max_prompt_tokens_exceeded') identifying which deterministic validation failure occurred. Raw server-controlled string, emitted only through restricted telemetry. Absent for bodyless or non-400 failures.
6949
+ * The `code` from the CAPI error envelope of an HTTP failure of any status (e.g. 'model_max_prompt_tokens_exceeded' on a 400, 'model_overloaded' on a 5xx) identifying which upstream failure occurred. Raw server-controlled string, emitted only through restricted telemetry. Absent when the response carried no error envelope.
6950
6950
  */
6951
6951
  errorCode?: string;
6952
6952
  /**
@@ -6954,7 +6954,7 @@ export interface ModelCallFailureData {
6954
6954
  */
6955
6955
  errorMessage?: string;
6956
6956
  /**
6957
- * For HTTP 400 failures only: the `type` from the CAPI error envelope (e.g. 'websocket_error'), a coarser companion to errorCode for envelopes that carry no code. Raw server-controlled string, emitted only through restricted telemetry. Absent for bodyless or non-400 failures.
6957
+ * The `type` from the CAPI error envelope of an HTTP failure of any status (e.g. 'websocket_error'), a coarser companion to errorCode for envelopes that carry no code. Raw server-controlled string, emitted only through restricted telemetry. Absent when the response carried no error envelope.
6958
6958
  */
6959
6959
  errorType?: string;
6960
6960
  failureKind?: ModelCallFailureKind;
@@ -7069,6 +7069,10 @@ export interface ModelCallFailureData {
7069
7069
  * Content-free structural summary of the failing request for diagnosing malformed 4xx calls
7070
7070
  */
7071
7071
  export interface ModelCallFailureRequestFingerprint {
7072
+ /**
7073
+ * Free-form custom tool calls in the request history before request shaping, counted apart from named function calls (rejected by strict providers)
7074
+ */
7075
+ customToolCallCount?: number;
7072
7076
  /**
7073
7077
  * Summed byte length of opaque or encrypted reasoning payloads
7074
7078
  */
@@ -7097,6 +7101,10 @@ export interface ModelCallFailureRequestFingerprint {
7097
7101
  * Tool calls whose name is missing or empty (rejected by strict providers)
7098
7102
  */
7099
7103
  namelessToolCallCount: number;
7104
+ /**
7105
+ * Tool calls in the request history before request shaping that no later tool result message answers
7106
+ */
7107
+ orphanToolCallCount?: number;
7100
7108
  /**
7101
7109
  * Number of messages carrying opaque or encrypted reasoning
7102
7110
  */
@@ -7109,6 +7117,10 @@ export interface ModelCallFailureRequestFingerprint {
7109
7117
  * Number of "tool" result messages in the request
7110
7118
  */
7111
7119
  toolResultMessageCount: number;
7120
+ /**
7121
+ * Tool result messages in the request history before request shaping that answer no earlier unanswered tool call
7122
+ */
7123
+ unmatchedToolResultCount?: number;
7112
7124
  }
7113
7125
  /**
7114
7126
  * Session event "model.call_finished". Final lifecycle outcome for one logical model dispatch. A logical dispatch may include internal reconnect or fallback work, so event count is not provider HTTP-request count.
package/dist/index.d.ts CHANGED
@@ -13,5 +13,5 @@ export { defineWorkflow, WorkflowResumeError, isWorkflowRunTerminal } from "./wo
13
13
  export { Canvas, CanvasError, createCanvas, type CanvasAction, type CanvasDeclaration, type CanvasHostContext, type CanvasHostContextCapabilities, type CanvasJsonSchema, type CanvasOptions, } from "./canvas.js";
14
14
  export { defineTool, approveAll, createAttributedPermissionResult, convertMcpCallToolResult, createSessionFsAdapter, CopilotRequestHandler, CopilotWebSocketHandler, CopilotWebSocketCloseStatus, CopilotWebSocketForwarder, SessionFsSqliteTransactionFailure, SessionFsWriteFailure, SYSTEM_MESSAGE_SECTIONS, } from "./types.js";
15
15
  export type * from "./generated/session-events.js";
16
- export type { AskUserVariant, CommandContext, CommandDefinition, CommandHandler, CanvasProviderIdentity, CloudSessionOptions, CloudSessionRepository, AuthIdentityMetadata, AuthInfoType, ConnectorAccountRequest, ConnectorAvailability, ConnectorCapabilities, ConnectorCatalogEntry, ConnectorCatalogResult, ConnectorCatalogStatus, ConnectorConnectRequest, ConnectorConnectResult, ConnectorContinueRequest, ConnectorDisconnectResult, ConnectorMcpStatus, ConnectorReconcileRequest, ConnectorRuntimeStatus, ConnectorSessionAccount, ConnectorSessionAccountResult, ConnectorStatus, AutoModeSwitchHandler, AutoModeSwitchRequest, AutoModeSwitchResponse, AgentStopHandler, AgentStopHookInput, AgentStopHookOutput, SubagentStartHandler, SubagentStartHookInput, SubagentStartHookOutput, SubagentStopHandler, SubagentStopHookInput, SubagentStopHookOutput, UserPromptTransformedHandler, UserPromptTransformedHookInput, UserPromptTransformedHookOutput, CopilotClientInfo, CopilotClientMode, CopilotClientOptions, InstallationConfirmationHandler, InstallationConfirmationRequest, InstallationConfirmationResponse, InstallationDecision, InstallationReview, McpInstallationReview, CopilotExpAssignmentResponse, StdioRuntimeConnection, InProcessRuntimeConnection, TcpRuntimeConnection, UriRuntimeConnection, ChildProcessRuntimeConnection, CustomAgentConfig, ElicitationFieldValue, ElicitationHandler, ElicitationParams, ElicitationContext, ElicitationResult, ElicitationSchema, ElicitationSchemaField, ExpConfigEntry, ExpFlagValue, ExitPlanModeHandler, ExitPlanModeRequest, ExitPlanModeResult, ExtensionLaunchProfile, ExtensionLaunchProvider, ExtensionLaunchProviderResolveRequest, ExtensionLaunchProviderResolveResult, ExtensionInfo, ForegroundSessionInfo, GetAuthStatusResponse, GetStatusResponse, GitHubMcpToolConfig, GitHubTelemetryNotification, GitHubTelemetryEvent, GitHubTelemetryClientInfo, GitHubTokenAcquireReason, GitHubTokenAcquireResult, GitHubTokenProvider, GitHubTokenProviderArgs, GitHubTokenProviderResult, InfiniteSessionConfig, LargeToolOutputConfig, MemoryConfiguration, UiInputOptions, MCPStdioServerConfig, MCPHTTPServerConfig, MCPServerConfig, DefaultAgentConfig, BearerTokenProvider, ExtensionContextAttachment, MessageOptions, ResponseSchema, MessageSource, ManagedSettings, ManagedSettingsPermissions, ModelBilling, ModelBillingTokenPrices, ModelBillingTokenPricesLongContext, AutoTier, CapiSessionOptions, CurrentModel, ModelSwitchAutoTierResult, ModelSwitchAutoTierStatus, ModelCapabilities, ModelCapabilitiesOverride, ModelInfo, ModelPolicy, NamedProviderConfig, PermissionHandler, PermissionRequest, PermissionRequestedData, PermissionRequestedEvent, PermissionRequestResult, AttributedPermissionResult, PermissionDecisionContext, PermissionDecisionOutcome, PermissionDecisionSource, PermissionDecisionSurface, PermissionResponseCapability, ProviderConfig, ProviderConfigModelProvider, ProviderModelConfig, ProviderTokenArgs, RemoteSessionMode, SandboxConfigSource, ResumeSessionConfig, TranscriptRecovery, 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, SkillProvider, SkillProviderCallOptions, SkillProviderDescriptor, CopilotRequestContext, SystemMessageAppendConfig, SystemMessageConfig, SystemMessageCustomizeConfig, SystemMessageReplaceConfig, SystemMessageSection, TelemetryConfig, TraceContext, TraceContextProvider, Tool, ToolHandler, ToolInvocation, CurrentToolMetadata, ToolTelemetry, ToolResultObject, ToolSearchConfig, ImageGenerationConfig, TypedSessionEventHandler, TypedSessionLifecycleHandler, ZodSchema, } from "./types.js";
16
+ export type { AskUserVariant, CommandContext, CommandDefinition, CommandHandler, CanvasProviderIdentity, CloudSessionOptions, CloudSessionRepository, AuthIdentityMetadata, AuthInfoType, ConnectorAccountRequest, ConnectorAvailability, ConnectorCapabilities, ConnectorCatalogEntry, ConnectorCatalogResult, ConnectorCatalogStatus, ConnectorConnectRequest, ConnectorConnectResult, ConnectorContinueRequest, ConnectorDisconnectResult, ConnectorMcpStatus, ConnectorReconcileRequest, ConnectorRuntimeStatus, ConnectorSessionAccount, ConnectorSessionAccountResult, ConnectorStatus, AutoModeSwitchHandler, AutoModeSwitchRequest, AutoModeSwitchResponse, AgentStopHandler, AgentStopHookInput, AgentStopHookOutput, SubagentStartHandler, SubagentStartHookInput, SubagentStartHookOutput, SubagentStopHandler, SubagentStopHookInput, SubagentStopHookOutput, UserPromptTransformedHandler, UserPromptTransformedHookInput, UserPromptTransformedHookOutput, CopilotClientInfo, CopilotClientMode, CopilotClientOptions, InstallationConfirmationHandler, InstallationConfirmationRequest, InstallationConfirmationResponse, InstallationDecision, InstallationReview, McpInstallationReview, CopilotExpAssignmentResponse, StdioRuntimeConnection, InProcessRuntimeConnection, TcpRuntimeConnection, UriRuntimeConnection, ChildProcessRuntimeConnection, CustomAgentConfig, ElicitationFieldValue, ElicitationHandler, ElicitationParams, ElicitationContext, ElicitationResult, ElicitationSchema, ElicitationSchemaField, ExpConfigEntry, ExpFlagValue, ExitPlanModeHandler, ExitPlanModeRequest, ExitPlanModeResult, ExtensionLaunchProfile, ExtensionLaunchProvider, ExtensionLaunchProviderResolveRequest, ExtensionLaunchProviderResolveResult, ExtensionInfo, ForegroundSessionInfo, GetAuthStatusResponse, GetStatusResponse, GitHubMcpToolConfig, GitHubTelemetryNotification, GitHubTelemetryEvent, GitHubTelemetryClientInfo, GitHubTokenAcquireReason, GitHubTokenAcquireResult, GitHubTokenProvider, GitHubTokenProviderArgs, GitHubTokenProviderResult, InfiniteSessionConfig, LargeToolOutputConfig, MemoryConfiguration, UiInputOptions, MCPStdioServerConfig, MCPHTTPServerConfig, MCPServerConfig, DefaultAgentConfig, BearerTokenProvider, ExtensionContextAttachment, MessageOptions, ResponseSchema, MessageSource, ManagedSettings, ManagedSettingsPermissions, ModelBilling, ModelBillingTokenPrices, ModelBillingTokenPricesLongContext, AutoTier, CapiSessionOptions, CurrentModel, ModelSwitchAutoTierResult, ModelSwitchAutoTierStatus, ModelCapabilities, ModelCapabilitiesOverride, ModelInfo, ModelPolicy, NamedProviderConfig, PermissionHandler, PermissionRequest, PermissionRequestedData, PermissionRequestedEvent, PermissionRequestResult, AttributedPermissionResult, PermissionDecisionContext, PermissionDecisionOutcome, PermissionDecisionSource, PermissionDecisionSurface, PermissionResponseCapability, ProviderConfig, ProviderConfigModelProvider, ProviderModelConfig, ProviderTokenArgs, RemoteSessionMode, SandboxConfigSource, ResumeSessionConfig, TranscriptRecovery, SectionOverride, SectionOverrideAction, SectionTransformFn, SessionCapabilities, SessionConfig, SessionConfigBase, WorkingDirectoryTrust, 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, SkillProvider, SkillProviderCallOptions, SkillProviderDescriptor, CopilotRequestContext, SystemMessageAppendConfig, SystemMessageConfig, SystemMessageCustomizeConfig, SystemMessageReplaceConfig, SystemMessageSection, TelemetryConfig, TraceContext, TraceContextProvider, Tool, ToolHandler, ToolInvocation, ToolNamespace, CurrentToolMetadata, ToolTelemetry, ToolResultObject, ToolSearchConfig, ImageGenerationConfig, TypedSessionEventHandler, TypedSessionLifecycleHandler, ZodSchema, } from "./types.js";
17
17
  export type { JsonValue, WorkflowRunOptions, WorkflowResumeOptions, WorkflowLimitOverrides, WorkflowResumeErrorCode, SessionWorkflowApi, WorkflowAgentOptions, WorkflowContext, WorkflowDefinition, WorkflowHandle, WorkflowJsonSchema, WorkflowLimits, WorkflowMeta, WorkflowPipelineStage, WorkflowStepOptions, WorkflowRunResult, WorkflowRunStatus, WorkflowRunSummary, WorkflowListRunsOptions, WorkflowRunsPage, WorkflowRunDetail, WorkflowProgressPage, WorkflowProgressLine, WorkflowPhaseObservation, WorkflowPhaseStatus, WorkflowAgentSummary, } from "./workflow.js";
package/dist/session.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { createSessionRpc } from "./generated/rpc.js";
2
2
  import type { ModelSwitchAutoTierResult } from "./generated/rpc.js";
3
3
  import type { OpenCanvasInstance } from "./generated/rpc.js";
4
- import type { MessageOptions, ResponseSchema, ContextTier, ReasoningEffort, ReasoningSummary, AutoTier, ModelCapabilitiesOverride, SessionCapabilities, SessionEvent, SessionEventHandler, SessionEventType, SessionUiApi, Tool, TranscriptRecovery, TypedSessionEventHandler } from "./types.js";
4
+ import type { MessageOptions, ResponseSchema, ContextTier, ReasoningEffort, ReasoningSummary, AutoTier, ModelCapabilitiesOverride, SessionCapabilities, SessionConfig, SessionEvent, SessionEventHandler, SessionEventType, SessionUiApi, TranscriptRecovery, TypedSessionEventHandler } from "./types.js";
5
5
  import { type SessionWorkflowApi } from "./workflow.js";
6
6
  /** Assistant message event - the final response from the assistant. */
7
7
  export type AssistantMessageEvent = Extract<SessionEvent, {
@@ -417,7 +417,7 @@ export declare class CopilotSession {
417
417
  * ]);
418
418
  * ```
419
419
  */
420
- setTools(tools: Tool[]): Promise<void>;
420
+ setTools(tools: NonNullable<SessionConfig["tools"]>): Promise<void>;
421
421
  /**
422
422
  * Log a message to the session timeline.
423
423
  * The message appears in the session event stream and is visible to SDK consumers
package/dist/session.js CHANGED
@@ -29,7 +29,8 @@ function toToolDefinition(tool) {
29
29
  skipPermission: tool.skipPermission,
30
30
  defer: tool.defer,
31
31
  metadata: tool.metadata,
32
- isTerminal: tool.isTerminal
32
+ isTerminal: tool.isTerminal,
33
+ namespace: tool.namespace
33
34
  };
34
35
  }
35
36
  const workflowExecutionStore = new AsyncLocalStorage();
package/dist/types.d.ts CHANGED
@@ -6,10 +6,10 @@ import type { SessionFsProvider } from "./sessionFsProvider.js";
6
6
  import type { CopilotRequestHandler } from "./copilotRequestHandler.js";
7
7
  import type { InstallationConfirmationHandler } from "./installationConfirmation.js";
8
8
  export type { InstallationConfirmationHandler } from "./installationConfirmation.js";
9
- import type { AttachmentExtensionContext as GeneratedExtensionContextAttachment, AutoTier, PermissionRequest as GeneratedPermissionRequest, PermissionRequestedData as GeneratedPermissionRequestedData, PermissionRequestedEvent as GeneratedPermissionRequestedEvent, ReasoningSummary, SessionLimitsConfig, SessionEvent as GeneratedSessionEvent } from "./generated/session-events.js";
9
+ import type { AgentModelPolicy, AttachmentExtensionContext as GeneratedExtensionContextAttachment, AutoTier, PermissionRequest as GeneratedPermissionRequest, PermissionRequestedData as GeneratedPermissionRequestedData, PermissionRequestedEvent as GeneratedPermissionRequestedEvent, ReasoningSummary, SessionLimitsConfig, SessionEvent as GeneratedSessionEvent } from "./generated/session-events.js";
10
10
  import type { CopilotSession } from "./session.js";
11
11
  import type { JsonValue } from "./workflow.js";
12
- import type { ExtensionLaunchProviderHandler as GeneratedExtensionLaunchProvider, GitHubTokenAcquireRequest, GitHubTokenAcquireResult, GitHubTelemetryNotification, ModelBillingTokenPrices, DiagnosticsConfiguration, OpenCanvasInstance, RemoteSessionMode, CurrentToolMetadata } from "./generated/rpc.js";
12
+ import type { ExtensionLaunchProviderHandler as GeneratedExtensionLaunchProvider, GitHubTokenAcquireRequest, GitHubTokenAcquireResult, GitHubTelemetryNotification, ModelBillingTokenPrices, DiagnosticsConfiguration, OpenCanvasInstance, ProtocolExternalToolNamespace, RemoteSessionMode, CurrentToolMetadata } from "./generated/rpc.js";
13
13
  import type { ToolSet } from "./toolSet.js";
14
14
  export type { RemoteSessionMode } from "./generated/rpc.js";
15
15
  export type { CurrentToolMetadata } from "./generated/rpc.js";
@@ -608,7 +608,29 @@ export interface Tool<TArgs = unknown> {
608
608
  * continue from.
609
609
  */
610
610
  isTerminal?: boolean;
611
+ /**
612
+ * Groups this tool with related tools for model tool discovery.
613
+ *
614
+ * On models and providers that support native tool namespaces, deferred
615
+ * tools sharing a namespace are presented to the model as one group with
616
+ * this name and description, like the tools of an MCP server. Elsewhere,
617
+ * and for tools that are always loaded, the tool stays a flat function.
618
+ * The tool keeps its own name, so calls still reach this tool's handler
619
+ * by name.
620
+ *
621
+ * @experimental
622
+ */
623
+ namespace?: ToolNamespace;
611
624
  }
625
+ /**
626
+ * A namespace that groups related {@link Tool}s for model tool discovery.
627
+ * Tools sharing a name share a namespace. An invalid namespace is reported as a
628
+ * session warning and the tool is presented without it; a missing description
629
+ * defaults to a generic description of the namespace.
630
+ *
631
+ * @experimental
632
+ */
633
+ export type ToolNamespace = ProtocolExternalToolNamespace;
612
634
  /**
613
635
  * Helper to define a tool with Zod schema and get type inference for the handler.
614
636
  * Without this helper, TypeScript cannot infer handler argument types from Zod schemas.
@@ -622,6 +644,7 @@ export declare function defineTool<T = unknown>(name: string, config: {
622
644
  defer?: "auto" | "never";
623
645
  metadata?: Record<string, unknown>;
624
646
  isTerminal?: boolean;
647
+ namespace?: ToolNamespace;
625
648
  }): Tool<T>;
626
649
  /**
627
650
  * Non-persisted opt-in to image generation.
@@ -636,6 +659,13 @@ export interface ImageGenerationConfig {
636
659
  * apply. BYOK image generation is not supported.
637
660
  */
638
661
  enabled?: boolean;
662
+ /**
663
+ * Request a visible "Made with AI" label on generated and edited images.
664
+ * Overrides the user's imageGenerationWatermark preference, which defaults
665
+ * to false. Re-supply after cold resume. Does not enable image generation
666
+ * or enforce enterprise policy.
667
+ */
668
+ watermark?: boolean;
639
669
  }
640
670
  /**
641
671
  * SDK-supplied override for the runtime's built-in tool-search behavior.
@@ -1645,9 +1675,15 @@ export interface CustomAgentConfig {
1645
1675
  /**
1646
1676
  * Model identifier for this agent (e.g. "claude-haiku-4.5").
1647
1677
  * When set, the runtime will attempt to use this model for the agent,
1648
- * falling back to the parent session model if unavailable.
1678
+ * falling back to the parent session model if unavailable unless
1679
+ * `modelPolicy` is `"required"`.
1649
1680
  */
1650
1681
  model?: string;
1682
+ /**
1683
+ * Whether the authored model is a preference or a requirement for this agent.
1684
+ * Defaults to `"preferred"` when omitted.
1685
+ */
1686
+ modelPolicy?: AgentModelPolicy;
1651
1687
  /**
1652
1688
  * Reasoning effort level for this agent's model.
1653
1689
  * When omitted, the runtime resolves the effort from model configuration,
@@ -1735,6 +1771,10 @@ export type ReasoningEffort = "low" | "medium" | "high" | "xhigh" | "max";
1735
1771
  * long-context tier when the selected model supports it.
1736
1772
  */
1737
1773
  export type ContextTier = "default" | "long_context";
1774
+ /**
1775
+ * Scope of a working-directory trust grant made during session creation.
1776
+ */
1777
+ export type WorkingDirectoryTrust = "session" | "user";
1738
1778
  /** Parsed parameters from an MCP server's WWW-Authenticate response. */
1739
1779
  export interface McpAuthWwwAuthenticateParams {
1740
1780
  /** Parsed resource_metadata URL used for protected-resource metadata discovery, if present. */
@@ -2636,13 +2676,6 @@ export interface SessionConfigBase {
2636
2676
  * read from the shared session store.
2637
2677
  */
2638
2678
  enableSessionStore?: boolean;
2639
- /**
2640
- * When true, requests the read-only GitHub cache store for this session
2641
- * (the `github-cache-store` capability). The runtime registers the
2642
- * `github_sql` tool only when its `GITHUB_CACHE_STORE` feature flag is
2643
- * also on. Defaults to disabled.
2644
- */
2645
- enableGitHubCacheStore?: boolean;
2646
2679
  /**
2647
2680
  * When true, enables skill loading (including builtin skills and discovered
2648
2681
  * skill directories). When false, no skills are loaded regardless of
@@ -2693,6 +2726,12 @@ export interface SessionConfig extends SessionConfigBase {
2693
2726
  * Local sessions only: cloud creation rejects it.
2694
2727
  */
2695
2728
  name?: string;
2729
+ /**
2730
+ * Grants trust to the canonical working directory during session creation.
2731
+ * "session" applies only to this session; "user" persists the grant for later
2732
+ * sessions. Omit to leave directory trust unchanged. Not available on resume.
2733
+ */
2734
+ trustWorkingDirectory?: WorkingDirectoryTrust;
2696
2735
  /**
2697
2736
  * Invalidates the process-wide custom-instruction discovery cache before
2698
2737
  * creating this session. Use when instruction files changed in the same runtime.
@@ -2831,6 +2870,12 @@ export interface ProviderConfig {
2831
2870
  * API key. Optional for local providers like Ollama.
2832
2871
  */
2833
2872
  apiKey?: string;
2873
+ /**
2874
+ * Command run by the runtime before each provider request to obtain a fresh API key.
2875
+ * Command failures fail the turn before sending a model request.
2876
+ * Bearer authentication takes precedence; use {@link apiKey} for a static key.
2877
+ */
2878
+ apiKeyCommand?: string;
2834
2879
  /**
2835
2880
  * Bearer token for authentication. Sets the Authorization header directly.
2836
2881
  * Use this for services requiring bearer token auth instead of API key.
@@ -2842,10 +2887,10 @@ export interface ProviderConfig {
2842
2887
  * When set, the SDK keeps this function client-side (it is never serialized)
2843
2888
  * and the runtime calls back into this client to acquire a token before each
2844
2889
  * outbound request. The runtime does no caching of its own, so the callback
2845
- * owns token caching and refresh. When set alongside {@link apiKey} /
2846
- * {@link bearerToken}, this callback takes precedence: the runtime applies
2847
- * the token it returns as the `Authorization: Bearer` header for each
2848
- * request and does not send the static credential.
2890
+ * owns token caching and refresh. When set alongside {@link apiKey},
2891
+ * {@link apiKeyCommand}, or {@link bearerToken}, this callback takes precedence:
2892
+ * the runtime applies its token as the `Authorization: Bearer` header for each
2893
+ * request, without sending the static credential or running the command.
2849
2894
  *
2850
2895
  * @experimental
2851
2896
  */
package/docs/workflows.md CHANGED
@@ -102,7 +102,13 @@ if (!finding) return { finding: null };
102
102
 
103
103
  Cancellation and hard runtime failures — a reached limit, a durable-state failure — reject instead, aborting the run. When filtering results, prefer `v => v !== null` over `Boolean`, which also discards a valid `false`, `0`, or `""`.
104
104
 
105
- **`schema` is a structural subset of JSON Schema, not a validator.** Honored: `type`, `required`, `enum`, `const`, recursive `properties`/`items`, and `anyOf`/`oneOf`/`allOf` — where `oneOf` is treated as `anyOf`, meaning at least one branch matches rather than exactly one. Ignored and *not* enforced: `additionalProperties`, `pattern`, `minLength`/`maxLength`, `format`, numeric ranges, and boolean schemas. Do not rely on an ignored keyword to constrain a result. A schema call retries once on a parse or match failure, so it may spawn twice, and both spawns count toward `maxTotalSubagents`.
105
+ **`schema` is a structural subset of JSON Schema, not a validator.** Honored: `type`, `required`, `enum`, `const`, recursive `properties`/`items`, and `anyOf`/`oneOf`/`allOf` — where `oneOf` is treated as `anyOf`, meaning at least one branch matches rather than exactly one. Ignored and *not* enforced: `additionalProperties`, `pattern`, `minLength`/`maxLength`, `format`, numeric ranges, and boolean schemas. Do not rely on an ignored keyword to constrain a result.
106
+
107
+ The runtime always parses and validates the returned JSON against that workflow subset. On a parse or match failure, it sends up to two correction turns to the same subagent; it does not spawn replacement subagents or repeat the original task.
108
+
109
+ Eligible local first-party model routes also use provider-native structured output to strengthen generation. Native selection fails closed: the selected CAPI model must explicitly report structured-output support, the wire route must support native formats, and the schema must fit a conservative provider subset. That subset requires an object root, typed nodes, non-empty object properties, every property listed in `required`, `additionalProperties: false` on every object, object-shaped array items, and bounded depth, property count, enum size, and serialized size. It accepts nested `anyOf`, descriptions, and enums, but rejects root `anyOf`, references, boolean schemas, `allOf`, `oneOf`, `const`, and other unsupported keywords.
110
+
111
+ AHP subagents, HydraFusion-selected children, BYOK providers, models without the capability, unknown routes, and schemas outside the native subset keep prompt-based JSON coercion. They retain the same parsing, validation, and same-agent correction behavior, so workflow authors use one `ctx.agent(..., { schema })` API regardless of the selected path.
106
112
 
107
113
  ### Choosing between pipeline and parallel
108
114
 
package/package.json CHANGED
@@ -5,8 +5,8 @@
5
5
  "url": "https://github.com/github/copilot-agent-runtime.git",
6
6
  "directory": "src/sdk/nodejs"
7
7
  },
8
- "version": "1.0.23",
9
- "copilotCliVersion": "1.0.100",
8
+ "version": "1.0.24-preview.0",
9
+ "copilotCliVersion": "1.0.101-0",
10
10
  "description": "TypeScript SDK for programmatic control of GitHub Copilot CLI via JSON-RPC",
11
11
  "main": "./dist/cjs/index.js",
12
12
  "types": "./dist/index.d.ts",
@@ -87,15 +87,17 @@
87
87
  "glob": "^13.0.1",
88
88
  "json-schema": "^0.4.0",
89
89
  "json-schema-to-typescript": "^15.0.4",
90
+ "jsonc-parser": "^3.3.1",
90
91
  "prettier": "file:../../../third_party/build-tools/prettier-3.8.1",
91
92
  "rimraf": "^6.1.2",
92
93
  "semver": "^7.7.3",
93
94
  "tar": "^7.5.22",
94
- "tsx": "file:../../../third_party/build-tools/tsx-4.22.4",
95
+ "tsx": "file:../../../third_party/build-tools/tsx-4.23.13",
95
96
  "typescript": "^5.0.0",
96
97
  "vite": "file:../../../third_party/build-tools/vite-8.3.4",
97
98
  "vitest": "^4.1.11",
98
- "ws": "^8.21.0"
99
+ "ws": "^8.21.0",
100
+ "yaml": "^2.8.3"
99
101
  },
100
102
  "overrides": {
101
103
  "file-entry-cache": "$file-entry-cache",
@@ -112,18 +114,18 @@
112
114
  "README.md"
113
115
  ],
114
116
  "copilotRuntime": {
115
- "sourceSha": "7d20899fc4c8b13a405aa621066e75a9e78e04cd",
116
- "version": "1.0.100",
117
+ "sourceSha": "ed4bc1ffe4b9b2fbe2548be0e7472b74d18092ce",
118
+ "version": "1.0.101-0",
117
119
  "visibility": "public"
118
120
  },
119
121
  "optionalDependencies": {
120
- "@github/copilot-sdk-darwin-arm64": "1.0.23",
121
- "@github/copilot-sdk-darwin-x64": "1.0.23",
122
- "@github/copilot-sdk-linux-arm64": "1.0.23",
123
- "@github/copilot-sdk-linux-x64": "1.0.23",
124
- "@github/copilot-sdk-linuxmusl-arm64": "1.0.23",
125
- "@github/copilot-sdk-linuxmusl-x64": "1.0.23",
126
- "@github/copilot-sdk-win32-arm64": "1.0.23",
127
- "@github/copilot-sdk-win32-x64": "1.0.23"
122
+ "@github/copilot-sdk-darwin-arm64": "1.0.24-preview.0",
123
+ "@github/copilot-sdk-darwin-x64": "1.0.24-preview.0",
124
+ "@github/copilot-sdk-linux-arm64": "1.0.24-preview.0",
125
+ "@github/copilot-sdk-linux-x64": "1.0.24-preview.0",
126
+ "@github/copilot-sdk-linuxmusl-arm64": "1.0.24-preview.0",
127
+ "@github/copilot-sdk-linuxmusl-x64": "1.0.24-preview.0",
128
+ "@github/copilot-sdk-win32-arm64": "1.0.24-preview.0",
129
+ "@github/copilot-sdk-win32-x64": "1.0.24-preview.0"
128
130
  }
129
131
  }