@github/copilot-sdk-win32-x64 1.0.17-preview.3 → 1.0.17-preview.4

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.
@@ -4151,7 +4151,48 @@ function createServerRpc(connection) {
4151
4151
  *
4152
4152
  * @returns Whether the host running this runtime can run the command sandbox. The runtime checks `supported` once per process. A capability answer can change while the process runs, for example after the user installs a missing package.
4153
4153
  */
4154
- getHostSupport: async () => connection.sendRequest("sandbox.getHostSupport", {})
4154
+ getHostSupport: async () => connection.sendRequest("sandbox.getHostSupport", {}),
4155
+ /** @experimental */
4156
+ proxyCa: {
4157
+ /**
4158
+ * Reports whether the persistent certificate authority of the sandbox credential proxy exists, whether OS trust includes it, and whether it must be rotated. Changes nothing.
4159
+ *
4160
+ * @param params Identifies the credential hosts that the persistent certificate authority of the sandbox credential proxy must cover. The runtime always adds the hosts from the saved user settings.
4161
+ *
4162
+ * @returns Status of the persistent certificate authority of the sandbox credential proxy.
4163
+ */
4164
+ getStatus: async (params) => connection.sendRequest("sandbox.proxyCa.getStatus", params),
4165
+ /**
4166
+ * Creates the persistent certificate authority of the sandbox credential proxy if none is stored, without changing OS trust, and returns the path of its public certificate. Keeps an existing certificate authority, even one that must be rotated. Fails where OS trust is unsupported. Trust it with sandbox.proxyCa.trust: the CLI trusts only the hosts in the saved user settings, so it refuses a certificate authority that also covers hosts from sandboxConfig.
4167
+ *
4168
+ * @param params Identifies the credential hosts that the persistent certificate authority of the sandbox credential proxy must cover. The runtime always adds the hosts from the saved user settings.
4169
+ *
4170
+ * @returns Result of creating the persistent certificate authority of the sandbox credential proxy.
4171
+ */
4172
+ create: async (params) => connection.sendRequest("sandbox.proxyCa.create", params),
4173
+ /**
4174
+ * Replaces the persistent certificate authority of the sandbox credential proxy with a new one for the current credential hosts. If OS trust included the old one, removes it and trusts the new one, which can show an OS authentication prompt. Running sandboxed tools keep the old certificate authority until they restart.
4175
+ *
4176
+ * @param params Identifies the credential hosts that the persistent certificate authority of the sandbox credential proxy must cover. The runtime always adds the hosts from the saved user settings.
4177
+ *
4178
+ * @returns Status of the persistent certificate authority of the sandbox credential proxy.
4179
+ */
4180
+ rotate: async (params) => connection.sendRequest("sandbox.proxyCa.rotate", params),
4181
+ /**
4182
+ * Adds the persistent certificate authority of the sandbox credential proxy to OS trust, so sandboxed clients that read only OS trust accept the proxy. Call create first. Refuses a certificate authority that is not constrained to the current credential hosts. Can show an OS authentication prompt.
4183
+ *
4184
+ * @param params Identifies the credential hosts that the persistent certificate authority of the sandbox credential proxy must cover. The runtime always adds the hosts from the saved user settings.
4185
+ *
4186
+ * @returns Status of the persistent certificate authority of the sandbox credential proxy.
4187
+ */
4188
+ trust: async (params) => connection.sendRequest("sandbox.proxyCa.trust", params),
4189
+ /**
4190
+ * Removes the persistent certificate authority of the sandbox credential proxy from OS trust. Keeps the stored certificate authority. Can show an OS authentication prompt. Sandboxed clients that read only OS trust then reject the proxy; clients that read the per-process certificate bundle continue to work.
4191
+ *
4192
+ * @returns Status of the persistent certificate authority of the sandbox credential proxy.
4193
+ */
4194
+ remove: async () => connection.sendRequest("sandbox.proxyCa.remove", {})
4195
+ }
4155
4196
  },
4156
4197
  /** @experimental */
4157
4198
  tools: {
@@ -5071,22 +5112,55 @@ function createInternalServerRpc(connection) {
5071
5112
  * @param params Params to attach or detach an in-process ExtensionController delegate.
5072
5113
  */
5073
5114
  configureSessionExtensions: async (params) => connection.sendRequest("sessions.configureSessionExtensions", params)
5074
- },
5075
- /** @experimental */
5076
- accounts: {
5077
- /**
5078
- * Acquire a Microsoft Entra access token through the runtime's OneAuth broker. Account-scoped because it uses the same native broker as the account stack: a trusted host application mints a scoped Entra token for its own use, most notably to authenticate to a remote MCP server whose authorization server is Entra ID (in place of the generic browser-OAuth flow).
5079
- *
5080
- * @param params OneAuth token request supplied by a trusted host application.
5081
- *
5082
- * @returns Result of a OneAuth token acquisition.
5083
- */
5084
- acquireEntraToken: async (params) => connection.sendRequest("accounts.acquireEntraToken", params)
5085
5115
  }
5086
5116
  };
5087
5117
  }
5088
5118
  function createSessionRpc(connection, sessionId) {
5089
5119
  return {
5120
+ /** @experimental */
5121
+ providers: {
5122
+ /**
5123
+ * Returns adapter definitions and supported operations in this session's effective provider catalog, without running discovery. Does not list provider instances or select inference models.
5124
+ *
5125
+ * @returns Normalized model-provider adapter definitions available to the session, not discovered instances.
5126
+ */
5127
+ getCatalog: async () => connection.sendRequest("session.providers.getCatalog", { sessionId }),
5128
+ /**
5129
+ * Discovers reachable instances using an adapter from this session's effective provider catalog and provider-specific discovery input.
5130
+ *
5131
+ * @param params Provider discovery parameters.
5132
+ *
5133
+ * @returns Provider instances found by a discovery operation.
5134
+ */
5135
+ discover: async (params) => connection.sendRequest("session.providers.discover", { ...params, sessionId }),
5136
+ /**
5137
+ * Gets current health and version information for a discovered model-provider instance.
5138
+ *
5139
+ * @param params Provider status request parameters.
5140
+ *
5141
+ * @returns Current health information for a provider instance.
5142
+ */
5143
+ getStatus: async (params) => connection.sendRequest("session.providers.getStatus", { ...params, sessionId }),
5144
+ /** @experimental */
5145
+ models: {
5146
+ /**
5147
+ * Lists models installed or otherwise available from a discovered model-provider instance.
5148
+ *
5149
+ * @param params Provider model inventory request parameters.
5150
+ *
5151
+ * @returns Models offered for agent conversations by one provider instance. Adapters exclude known-incompatible models, but retain candidates with unknown capabilities. Listing does not guarantee compatibility.
5152
+ */
5153
+ list: async (params) => connection.sendRequest("session.providers.models.list", { ...params, sessionId }),
5154
+ /**
5155
+ * Translates a discovered model into the provider and model configuration needed to use it, and reports whether each is already registered in this session. Prepares only: it registers nothing, writes nothing, and performs no provider requests.
5156
+ *
5157
+ * @param params A discovered instance and one of its models to translate into provider configuration. Pass back the instance and model as returned by `session.providers.discover` and `session.providers.models.list`.
5158
+ *
5159
+ * @returns Provider configuration prepared from a discovered model. Preparing a plan changes nothing: it neither registers the model with the session nor writes durable configuration. To apply it, pass `provider` and `model` to `session.provider.add`, omitting whichever the dispositions report as already configured.
5160
+ */
5161
+ prepareConfiguration: async (params) => connection.sendRequest("session.providers.models.prepareConfiguration", { ...params, sessionId })
5162
+ }
5163
+ },
5090
5164
  /**
5091
5165
  * Suspends the session while preserving persisted state for later resume.
5092
5166
  *
@@ -5694,16 +5768,18 @@ function createSessionRpc(connection, sessionId) {
5694
5768
  */
5695
5769
  getSources: async () => connection.sendRequest("session.instructions.getSources", { sessionId }),
5696
5770
  /**
5697
- * Invalidates cached custom-instruction discovery so subsequent turns and source reads observe instruction files currently on disk.
5771
+ * For local sessions, invalidates instruction discovery and the model-facing prompt, then returns freshly discovered sources. The updated prompt takes effect on the next turn. Remote sessions must reload on their agent host instead.
5772
+ *
5773
+ * @returns Instruction sources loaded for the session, in merge order.
5698
5774
  */
5699
5775
  reload: async () => connection.sendRequest("session.instructions.reload", { sessionId })
5700
5776
  },
5701
5777
  /** @experimental */
5702
5778
  customizations: {
5703
5779
  /**
5704
- * Reloads all repository and user customizations for the active session: instructions, plugins and their MCP servers and hooks, custom agents, extensions, and skills. Returns diagnostics from the final skill reload.
5780
+ * For local sessions, reconciles repository context and discovered instructions, plugins, skills, agents, hooks, MCP servers, and extensions after files appear or change under the working directory. Independent component failures are returned in outcomes and errors; a rejected call can have partially applied earlier steps. Remote sessions must reload on their agent host instead. The model-facing context is rebuilt on the next turn.
5705
5781
  *
5706
- * @returns Diagnostics from reloading skill definitions, with warnings and errors as separate lists.
5782
+ * @returns Results of reloading discovered session customizations. Inspect outcomes for reloaded, skipped, or failed subsystems; a rejection may follow partial mutation. Changes to the model-facing prompt and tools apply on the next turn.
5707
5783
  */
5708
5784
  reload: async () => connection.sendRequest("session.customizations.reload", { sessionId })
5709
5785
  },
@@ -7407,6 +7483,33 @@ function createInternalSessionRpc(connection, sessionId) {
7407
7483
  finalizeInvocationEffect: async (params) => connection.sendRequest("session.commands.finalizeInvocationEffect", { ...params, sessionId })
7408
7484
  },
7409
7485
  /** @experimental */
7486
+ ui: {
7487
+ /**
7488
+ * Resolves a pending elicitation request after direct interaction in the trusted in-process client. Only an accepted response to the built-in ask_user tool can become trusted human evidence.
7489
+ *
7490
+ * @param params Pending elicitation request ID and the user's response (accept/decline/cancel + form values).
7491
+ *
7492
+ * @returns Indicates whether the elicitation response was accepted; false if it was already resolved by another client.
7493
+ */
7494
+ handleHumanAskUser: async (params) => connection.sendRequest("session.ui.handleHumanAskUser", { ...params, sessionId }),
7495
+ /**
7496
+ * Resolves a pending `user_input.requested` event after direct interaction in the trusted in-process client.
7497
+ *
7498
+ * @param params Request ID of a pending `user_input.requested` event and the user's response.
7499
+ *
7500
+ * @returns Indicates whether the pending UI request was resolved by this call.
7501
+ */
7502
+ handleHumanUserInput: async (params) => connection.sendRequest("session.ui.handleHumanUserInput", { ...params, sessionId }),
7503
+ /**
7504
+ * Resolves a pending `exit_plan_mode.requested` event after direct interaction in the trusted in-process client.
7505
+ *
7506
+ * @param params Request ID of a pending `exit_plan_mode.requested` event and the user's response.
7507
+ *
7508
+ * @returns Indicates whether the pending UI request was resolved by this call.
7509
+ */
7510
+ handleHumanExitPlanMode: async (params) => connection.sendRequest("session.ui.handleHumanExitPlanMode", { ...params, sessionId })
7511
+ },
7512
+ /** @experimental */
7410
7513
  settings: {
7411
7514
  /**
7412
7515
  * Returns a redacted snapshot of session runtime settings, with secrets and raw feature flags excluded. Internal: the runtime settings shape is a runtime-internal surface and is deliberately kept out of the public SDK, because consumers should not depend on the runtime's internal settings layout. It remains callable in-process and is expected to be reworked as the runtime internals are consolidated.
@@ -7559,11 +7662,21 @@ function registerClientSessionApiHandlers(connection, getHandlers) {
7559
7662
  if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
7560
7663
  return handler.readFile(params);
7561
7664
  });
7665
+ connection.onRequest("sessionFs.readFileBytes", async (params) => {
7666
+ const handler = getHandlers(params.sessionId).sessionFs;
7667
+ if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
7668
+ return handler.readFileBytes(params);
7669
+ });
7562
7670
  connection.onRequest("sessionFs.writeFile", async (params) => {
7563
7671
  const handler = getHandlers(params.sessionId).sessionFs;
7564
7672
  if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
7565
7673
  return handler.writeFile(params);
7566
7674
  });
7675
+ connection.onRequest("sessionFs.writeFileBytes", async (params) => {
7676
+ const handler = getHandlers(params.sessionId).sessionFs;
7677
+ if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
7678
+ return handler.writeFileBytes(params);
7679
+ });
7567
7680
  connection.onRequest("sessionFs.appendFile", async (params) => {
7568
7681
  const handler = getHandlers(params.sessionId).sessionFs;
7569
7682
  if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
@@ -7752,6 +7865,8 @@ function isResponseSchema(value) {
7752
7865
  }
7753
7866
 
7754
7867
  // src/sdk/nodejs/dist/sessionFsProvider.js
7868
+ var MAX_BINARY_BYTES = (64 * 1024 * 1024 - 1024) / 4 * 3;
7869
+ var MAX_BINARY_CONTENT_LENGTH = Math.ceil(MAX_BINARY_BYTES / 3) * 4;
7755
7870
  var SessionFsSqliteTransactionFailure = class extends Error {
7756
7871
  /** Failure classification reported to the runtime. */
7757
7872
  errorClass;
@@ -7761,6 +7876,9 @@ var SessionFsSqliteTransactionFailure = class extends Error {
7761
7876
  this.errorClass = errorClass;
7762
7877
  }
7763
7878
  };
7879
+ var SessionFsWriteFailure = class extends Error {
7880
+ writeChanged = true;
7881
+ };
7764
7882
  function normalizeSqliteParams(params) {
7765
7883
  if (!params) {
7766
7884
  return void 0;
@@ -7783,10 +7901,60 @@ function createSessionFsAdapter(provider) {
7783
7901
  return { content: "", error: toSessionFsError(err) };
7784
7902
  }
7785
7903
  },
7904
+ readFileBytes: async ({ path }) => {
7905
+ if (!provider.readFileBytes) {
7906
+ return {
7907
+ content: "",
7908
+ error: { code: "UNKNOWN", message: "Binary reads are not supported" }
7909
+ };
7910
+ }
7911
+ try {
7912
+ const bytes = await provider.readFileBytes(path);
7913
+ if (bytes.length > MAX_BINARY_BYTES) {
7914
+ return {
7915
+ content: "",
7916
+ error: {
7917
+ code: "UNKNOWN",
7918
+ message: "sessionFs.readFileBytes content exceeds the binary read limit"
7919
+ }
7920
+ };
7921
+ }
7922
+ return {
7923
+ content: Buffer.from(bytes).toString("base64")
7924
+ };
7925
+ } catch (err) {
7926
+ return { content: "", error: toSessionFsError(err) };
7927
+ }
7928
+ },
7786
7929
  writeFile: async ({ path, content, mode }) => {
7787
7930
  try {
7788
7931
  await provider.writeFile(path, content, mode);
7789
7932
  return void 0;
7933
+ } catch (err) {
7934
+ const error = toSessionFsError(err);
7935
+ return err instanceof SessionFsWriteFailure ? { ...error, writeChanged: true } : error;
7936
+ }
7937
+ },
7938
+ writeFileBytes: async ({ path, content, mode }) => {
7939
+ if (!provider.writeFileBytes) {
7940
+ return { code: "UNKNOWN", message: "Binary writes are not supported" };
7941
+ }
7942
+ if (content.length > MAX_BINARY_CONTENT_LENGTH) {
7943
+ return {
7944
+ code: "UNKNOWN",
7945
+ message: "sessionFs.writeFileBytes content exceeds the binary write limit"
7946
+ };
7947
+ }
7948
+ const bytes = Buffer.from(content, "base64");
7949
+ if (bytes.toString("base64") !== content || bytes.length > MAX_BINARY_BYTES) {
7950
+ return {
7951
+ code: "UNKNOWN",
7952
+ message: "invalid sessionFs.writeFileBytes base64 content"
7953
+ };
7954
+ }
7955
+ try {
7956
+ await provider.writeFileBytes(path, bytes, mode);
7957
+ return void 0;
7790
7958
  } catch (err) {
7791
7959
  return toSessionFsError(err);
7792
7960
  }
@@ -8764,10 +8932,10 @@ var SYSTEM_MESSAGE_SECTIONS = {
8764
8932
  tool_instructions: { description: "Per-tool usage instructions" },
8765
8933
  custom_instructions: { description: "Repository and organization custom instructions" },
8766
8934
  runtime_instructions: {
8767
- description: "Runtime-provided context and instructions (e.g. system notifications, memories, workspace context, mode-specific instructions, content-exclusion policy)"
8935
+ description: "Runtime-provided system-prompt context and instructions, such as system notifications, memories, workspace context, and content-exclusion policy. Mode-specific instructions can travel in transition messages instead."
8768
8936
  },
8769
8937
  last_instructions: {
8770
- description: "End-of-prompt instructions: parallel tool calling, persistence, task completion"
8938
+ description: "End-of-prompt instructions: parallel tool calling, persistence, task completion, and configured subagent-model guidance when the task tool is available"
8771
8939
  }
8772
8940
  };
8773
8941
  function isAttributedPermissionResult(result) {
@@ -9955,7 +10123,20 @@ var CopilotSession = class {
9955
10123
  }
9956
10124
  for (const tool of tools) {
9957
10125
  if (tool.handler) {
9958
- this.toolHandlers.set(tool.name, tool.handler);
10126
+ const handler = tool.handler;
10127
+ if (tool.name === "apply_patch" && tool.overridesBuiltInTool && toJsonSchema(tool.parameters)?.type === "string") {
10128
+ this.toolHandlers.set(tool.name, (args, invocation) => {
10129
+ if (typeof args === "string") {
10130
+ return handler(args, invocation);
10131
+ }
10132
+ if (typeof args === "object" && args !== null && "input" in args && typeof args.input === "string") {
10133
+ return handler(args.input, invocation);
10134
+ }
10135
+ throw new TypeError("apply_patch string override requires a string input");
10136
+ });
10137
+ } else {
10138
+ this.toolHandlers.set(tool.name, handler);
10139
+ }
9959
10140
  }
9960
10141
  }
9961
10142
  }
@@ -10550,7 +10731,9 @@ var CopilotSession = class {
10550
10731
  sessionStart: this.hooks.onSessionStart,
10551
10732
  sessionEnd: this.hooks.onSessionEnd,
10552
10733
  errorOccurred: this.hooks.onErrorOccurred,
10553
- agentStop: this.hooks.onAgentStop
10734
+ agentStop: this.hooks.onAgentStop,
10735
+ subagentStart: this.hooks.onSubagentStart,
10736
+ subagentStop: this.hooks.onSubagentStop
10554
10737
  };
10555
10738
  const handler = handlerMap[hookType];
10556
10739
  if (!handler) {
@@ -11022,6 +11205,7 @@ var EXCLUDED_TOP_LEVEL = /* @__PURE__ */ new Set([
11022
11205
  "app.js",
11023
11206
  "assets",
11024
11207
  "changelog.json",
11208
+ "cli-main.js",
11025
11209
  "copilot",
11026
11210
  "copilot.exe",
11027
11211
  "foundry-local-sdk",
@@ -11365,6 +11549,7 @@ var BuiltInTools = {
11365
11549
  // src/sdk/nodejs/dist/client.js
11366
11550
  var MIN_PROTOCOL_VERSION = 3;
11367
11551
  var RUNTIME_SHUTDOWN_TIMEOUT_MS = 1e4;
11552
+ var CLOUD_SESSION_CLEANUP_TIMEOUT_MS = 1e4;
11368
11553
  function createMessageConnection(reader, writer) {
11369
11554
  let dispatch;
11370
11555
  let finishDrain;
@@ -11893,6 +12078,11 @@ var CopilotClient = class _CopilotClient {
11893
12078
  "SessionFsConfig declares capabilities.sqlite but the provider does not implement sqlite."
11894
12079
  );
11895
12080
  }
12081
+ if (this.sessionFsConfig.capabilities?.binary && (!provider.readFileBytes || !provider.writeFileBytes)) {
12082
+ throw new Error(
12083
+ "SessionFsConfig declares capabilities.binary but the provider does not implement readFileBytes and writeFileBytes."
12084
+ );
12085
+ }
11896
12086
  session.clientSessionApis.sessionFs = createSessionFsAdapter(provider);
11897
12087
  }
11898
12088
  setupClientGlobalHandlers() {
@@ -12576,12 +12766,13 @@ var CopilotClient = class _CopilotClient {
12576
12766
  if (config.onEvent) {
12577
12767
  s.on(config.onEvent);
12578
12768
  }
12579
- this.sessions.set(sessionId, s);
12580
12769
  this.setupSessionFs(s, config);
12770
+ this.sessions.set(sessionId, s);
12581
12771
  return s;
12582
12772
  };
12583
12773
  let session;
12584
12774
  let registeredId;
12775
+ let uninitializedCloudSessionId;
12585
12776
  if (localSessionId !== void 0) {
12586
12777
  try {
12587
12778
  session = initializeSession(localSessionId);
@@ -12704,7 +12895,9 @@ var CopilotClient = class _CopilotClient {
12704
12895
  );
12705
12896
  }
12706
12897
  if (session === void 0) {
12898
+ uninitializedCloudSessionId = returnedSessionId;
12707
12899
  session = initializeSession(returnedSessionId);
12900
+ uninitializedCloudSessionId = void 0;
12708
12901
  registeredId = returnedSessionId;
12709
12902
  }
12710
12903
  this.assignGitHubTokenProvider(gitHubTokenProviderRegistrationId, returnedSessionId);
@@ -12726,6 +12919,20 @@ var CopilotClient = class _CopilotClient {
12726
12919
  if (gitHubTokenProviderRegistrationId !== void 0) {
12727
12920
  this.githubTokenProviders.delete(gitHubTokenProviderRegistrationId);
12728
12921
  }
12922
+ if (uninitializedCloudSessionId !== void 0) {
12923
+ try {
12924
+ await withTimeout(
12925
+ this.deleteSession(uninitializedCloudSessionId),
12926
+ CLOUD_SESSION_CLEANUP_TIMEOUT_MS,
12927
+ `session.delete timed out after ${CLOUD_SESSION_CLEANUP_TIMEOUT_MS}ms`
12928
+ );
12929
+ } catch (cleanupError) {
12930
+ throw new AggregateError(
12931
+ [e, cleanupError],
12932
+ "Failed to initialize and delete cloud session"
12933
+ );
12934
+ }
12935
+ }
12729
12936
  throw e;
12730
12937
  }
12731
12938
  for (const entry of this.hostHandoffs.values()) {
@@ -12825,8 +13032,8 @@ var CopilotClient = class _CopilotClient {
12825
13032
  if (config.onEvent) {
12826
13033
  session.on(config.onEvent);
12827
13034
  }
12828
- this.sessions.set(sessionId, session);
12829
13035
  this.setupSessionFs(session, config);
13036
+ this.sessions.set(sessionId, session);
12830
13037
  const toolFilterOptions = this.resolveToolFilterOptions(config);
12831
13038
  const gitHubTokenProviderRegistrationId = this.registerGitHubTokenProvider(
12832
13039
  config.gitHubTokenProvider,
@@ -14133,6 +14340,7 @@ export {
14133
14340
  RuntimeConnection,
14134
14341
  SYSTEM_MESSAGE_SECTIONS,
14135
14342
  SessionFsSqliteTransactionFailure,
14343
+ SessionFsWriteFailure,
14136
14344
  ToolSet,
14137
14345
  WorkflowResumeError,
14138
14346
  approveAll,
@@ -37,6 +37,10 @@ export declare class SessionFsSqliteTransactionFailure extends Error {
37
37
  readonly errorClass: SessionFsSqliteTransactionErrorClass;
38
38
  constructor(message: string, errorClass?: SessionFsSqliteTransactionErrorClass);
39
39
  }
40
+ /** Throw from `writeFile` only when the provider changed the target before failing. */
41
+ export declare class SessionFsWriteFailure extends Error {
42
+ readonly writeChanged = true;
43
+ }
40
44
  /**
41
45
  * SQLite operations for the per-session database.
42
46
  * Implementers provide query execution and existence checking.
@@ -78,7 +82,11 @@ export interface SessionFsSqliteProvider {
78
82
  export interface SessionFsProvider {
79
83
  /** Reads the full content of a file. Throw if the file does not exist. */
80
84
  readFile(path: string): Promise<string>;
81
- /** Writes content to a file, creating parent directories if needed. */
85
+ /** Read exact file bytes. Required when capabilities.binary is enabled. */
86
+ readFileBytes?(path: string): Promise<Uint8Array>;
87
+ /** Write exact file bytes. Required when capabilities.binary is enabled. */
88
+ writeFileBytes?(path: string, content: Uint8Array, mode?: number): Promise<void>;
89
+ /** Writes content to a file, creating parent directories if needed. Throw {@link SessionFsWriteFailure} if a failed write changed the target. */
82
90
  writeFile(path: string, content: string, mode?: number): Promise<void>;
83
91
  /** Appends content to a file, creating parent directories if needed. */
84
92
  appendFile(path: string, content: string, mode?: number): Promise<void>;
@@ -48,6 +48,7 @@ export type { SessionFsSqliteProvider } from "./sessionFsProvider.js";
48
48
  export type { SessionFsSqliteStatement } from "./sessionFsProvider.js";
49
49
  export type { SessionFsSqliteTransactionErrorClass } from "./sessionFsProvider.js";
50
50
  export { SessionFsSqliteTransactionFailure } from "./sessionFsProvider.js";
51
+ export { SessionFsWriteFailure } from "./sessionFsProvider.js";
51
52
  export type { LlmInferenceHeaders } from "./generated/rpc.js";
52
53
  export type { PermissionDecisionContext, PermissionDecisionOutcome, PermissionDecisionSurface, PermissionResponseCapability, } from "./generated/rpc.js";
53
54
  export type { PermissionDecisionSource } from "./generated/session-events.js";
@@ -922,6 +923,8 @@ export interface SystemMessageReplaceConfig {
922
923
  /**
923
924
  * Customize mode: Override individual sections of the system prompt.
924
925
  * Keeps the SDK-managed prompt structure while allowing targeted modifications.
926
+ * The `last_instructions` section includes configured subagent-model guidance.
927
+ * Its overrides and transforms control that prose, not runtime model selection or tool availability.
925
928
  */
926
929
  export interface SystemMessageCustomizeConfig {
927
930
  mode: "customize";
@@ -1098,8 +1101,9 @@ export type AutoModeSwitchHandler = (request: AutoModeSwitchRequest, invocation:
1098
1101
  * Base interface for all hook inputs
1099
1102
  */
1100
1103
  export interface BaseHookInput {
1101
- /** The runtime session ID of the session that triggered the hook.
1102
- * For sub-agent hooks this differs from `invocation.sessionId`. */
1104
+ /** The runtime session ID associated with the hook. Child tool hooks use
1105
+ * the child session ID; sub-agent lifecycle hooks use the parent session ID,
1106
+ * matching `invocation.sessionId`. */
1103
1107
  sessionId: string;
1104
1108
  /** Time at which the hook event was emitted by the runtime. */
1105
1109
  timestamp: Date;
@@ -1366,6 +1370,54 @@ export interface AgentStopHookOutput {
1366
1370
  export type AgentStopHandler = (input: AgentStopHookInput, invocation: {
1367
1371
  sessionId: string;
1368
1372
  }) => Promise<AgentStopHookOutput | void> | AgentStopHookOutput | void;
1373
+ /**
1374
+ * Input for the hook fired before a sub-agent's first turn.
1375
+ *
1376
+ * The session metadata belongs to the parent session, not the child.
1377
+ */
1378
+ export interface SubagentStartHookInput extends BaseHookInput {
1379
+ transcriptPath: string;
1380
+ agentName: string;
1381
+ agentDisplayName?: string;
1382
+ agentDescription?: string;
1383
+ }
1384
+ /** Output for the sub-agent start hook. Context is prepended to the child's initial prompt. */
1385
+ export interface SubagentStartHookOutput {
1386
+ additionalContext?: string;
1387
+ }
1388
+ /** Handler for the sub-agent start hook. */
1389
+ export type SubagentStartHandler = (input: SubagentStartHookInput, invocation: {
1390
+ sessionId: string;
1391
+ }) => Promise<SubagentStartHookOutput | void> | SubagentStartHookOutput | void;
1392
+ /**
1393
+ * Input for the hook fired after a sub-agent completes a turn.
1394
+ *
1395
+ * The response is the child's last assistant message before any hook rewrite.
1396
+ */
1397
+ export interface SubagentStopHookInput extends SubagentStartHookInput {
1398
+ agentId?: string;
1399
+ agentType: string;
1400
+ stopReason: "end_turn";
1401
+ response: string;
1402
+ }
1403
+ /**
1404
+ * Output for the sub-agent stop hook. `"block"` with a nonempty `reason` continues
1405
+ * the child; otherwise `modifiedResponse` replaces the response reported to the parent.
1406
+ * When both are supplied, a valid block takes precedence over the rewrite.
1407
+ */
1408
+ export type SubagentStopHookOutput = {
1409
+ decision: "block";
1410
+ reason: string;
1411
+ modifiedResponse?: string;
1412
+ } | {
1413
+ decision?: "allow";
1414
+ reason?: never;
1415
+ modifiedResponse?: string;
1416
+ };
1417
+ /** Handler for the sub-agent stop hook. */
1418
+ export type SubagentStopHandler = (input: SubagentStopHookInput, invocation: {
1419
+ sessionId: string;
1420
+ }) => Promise<SubagentStopHookOutput | void> | SubagentStopHookOutput | void;
1369
1421
  /**
1370
1422
  * Configuration for session hooks
1371
1423
  */
@@ -1422,6 +1474,13 @@ export interface SessionHooks {
1422
1474
  * agent stop.
1423
1475
  */
1424
1476
  onAgentStop?: AgentStopHandler;
1477
+ /** Called before a sub-agent's first turn. Return context to prepend to its prompt. */
1478
+ onSubagentStart?: SubagentStartHandler;
1479
+ /**
1480
+ * Called after a sub-agent completes a turn. Return a block reason to
1481
+ * continue the child, or a replacement response to report to the parent.
1482
+ */
1483
+ onSubagentStop?: SubagentStopHandler;
1425
1484
  }
1426
1485
  /**
1427
1486
  * Base interface for MCP server configuration.
@@ -2894,6 +2953,12 @@ export interface SessionFsConfig {
2894
2953
  * @default false
2895
2954
  */
2896
2955
  sqlite?: boolean;
2956
+ /**
2957
+ * Whether this provider supports exact binary reads and writes through readFileBytes and writeFileBytes.
2958
+ * Required to view images stored only in the provider.
2959
+ * @default false
2960
+ */
2961
+ binary?: boolean;
2897
2962
  };
2898
2963
  }
2899
2964
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@github/copilot-sdk-win32-x64",
3
- "version": "1.0.17-preview.3",
3
+ "version": "1.0.17-preview.4",
4
4
  "description": "Platform runtime for @github/copilot-sdk (win32-x64)",
5
5
  "repository": {
6
6
  "type": "git",
Binary file
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/prebuilds/win32-x64/runtime.node
3
- size: 105270048 bytes
4
- sha256: 76b430b432938b12f315a460f699e5bd780db29bcdf1f5767afca60b460f4c44
3
+ size: 106660128 bytes
4
+ sha256: 6e74b03f37cdb4ea6d6c9e4a756cd1324fc8867cc7060d48e0bf3f09eb997ba9
Binary file