@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.
@@ -32,7 +32,12 @@ export interface CanvasAction {
32
32
  description?: string;
33
33
  /** Optional JSON Schema for the action's `input` payload. */
34
34
  inputSchema?: CanvasJsonSchema;
35
- /** Required per-action dispatch handler. */
35
+ /**
36
+ * Required per-action dispatch handler. The returned value becomes the
37
+ * `invoke_canvas_action` tool result. Return a `ToolResultObject`
38
+ * (with `binaryResultsForLlm`) to send text and images to the model, as a
39
+ * tool handler would; any other value is rendered to the model as JSON text.
40
+ */
36
41
  handler: (ctx: CanvasProviderInvokeActionRequest) => Promise<unknown> | unknown;
37
42
  }
38
43
  /**
@@ -122,10 +122,12 @@ hooks: {
122
122
  onSessionStart: async (input, invocation) => { ... },
123
123
  onSessionEnd: async (input, invocation) => { ... },
124
124
  onErrorOccurred: async (input, invocation) => { ... },
125
+ onSubagentStart: async (input, invocation) => { ... },
126
+ onSubagentStop: async (input, invocation) => { ... },
125
127
  }
126
128
  ```
127
129
 
128
- All hook inputs include `timestamp` (`Date`) and `workingDirectory`.
130
+ All hook inputs include `sessionId`, `timestamp` (`Date`) and `workingDirectory`.
129
131
  All handlers receive `invocation: { sessionId: string }` as the second argument.
130
132
  All handlers may return `void`/`undefined` (no-op) or an output object.
131
133
 
@@ -214,7 +216,32 @@ fire it.
214
216
  | `retryCount` | `number` | Max retries (when errorHandling is "retry") |
215
217
  | `userNotification` | `string` | Message shown to the user |
216
218
 
217
- ---
219
+ ### onSubagentStart
220
+
221
+ Fires before a sub-agent's first turn. The input's `sessionId` and the
222
+ invocation's `sessionId` identify the parent session, not the child.
223
+
224
+ **Input:** `{ sessionId: string, transcriptPath: string, agentName: string, agentDisplayName?: string, agentDescription?: string, timestamp, workingDirectory }`
225
+
226
+ **Output (optional):**
227
+ | Field | Type | Effect |
228
+ |-------|------|--------|
229
+ | `additionalContext` | `string` | Prepended to the child's initial prompt |
230
+
231
+ ### onSubagentStop
232
+
233
+ Fires after a sub-agent completes a turn. The input includes the child's last
234
+ assistant `response` and the parent's session metadata. `agentId` is available
235
+ when the task registry supplies one. This is distinct from `onAgentStop`, which
236
+ only runs for the top-level agent.
237
+
238
+ **Input:** `{ sessionId: string, transcriptPath: string, agentName: string, agentDisplayName?: string, agentDescription?: string, agentId?: string, agentType: string, stopReason: "end_turn", response: string, timestamp, workingDirectory }`
239
+
240
+ **Output (choose one, or return nothing):**
241
+ | Field | Type | Effect |
242
+ |-------|------|--------|
243
+ | `decision` and `reason` | `"block"` and `string` | Continue the child for another turn using `reason` |
244
+ | `modifiedResponse` | `string` | Replace the child's response reported to the parent |
218
245
 
219
246
  ## Session Object
220
247
 
@@ -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
  }
@@ -9827,7 +9995,20 @@ var CopilotSession = class {
9827
9995
  }
9828
9996
  for (const tool of tools) {
9829
9997
  if (tool.handler) {
9830
- this.toolHandlers.set(tool.name, tool.handler);
9998
+ const handler = tool.handler;
9999
+ if (tool.name === "apply_patch" && tool.overridesBuiltInTool && toJsonSchema(tool.parameters)?.type === "string") {
10000
+ this.toolHandlers.set(tool.name, (args, invocation) => {
10001
+ if (typeof args === "string") {
10002
+ return handler(args, invocation);
10003
+ }
10004
+ if (typeof args === "object" && args !== null && "input" in args && typeof args.input === "string") {
10005
+ return handler(args.input, invocation);
10006
+ }
10007
+ throw new TypeError("apply_patch string override requires a string input");
10008
+ });
10009
+ } else {
10010
+ this.toolHandlers.set(tool.name, handler);
10011
+ }
9831
10012
  }
9832
10013
  }
9833
10014
  }
@@ -10422,7 +10603,9 @@ var CopilotSession = class {
10422
10603
  sessionStart: this.hooks.onSessionStart,
10423
10604
  sessionEnd: this.hooks.onSessionEnd,
10424
10605
  errorOccurred: this.hooks.onErrorOccurred,
10425
- agentStop: this.hooks.onAgentStop
10606
+ agentStop: this.hooks.onAgentStop,
10607
+ subagentStart: this.hooks.onSubagentStart,
10608
+ subagentStop: this.hooks.onSubagentStop
10426
10609
  };
10427
10610
  const handler = handlerMap[hookType];
10428
10611
  if (!handler) {
@@ -10894,6 +11077,7 @@ var EXCLUDED_TOP_LEVEL = /* @__PURE__ */ new Set([
10894
11077
  "app.js",
10895
11078
  "assets",
10896
11079
  "changelog.json",
11080
+ "cli-main.js",
10897
11081
  "copilot",
10898
11082
  "copilot.exe",
10899
11083
  "foundry-local-sdk",
@@ -11212,6 +11396,7 @@ var ToolSet = class {
11212
11396
  // src/sdk/nodejs/dist/client.js
11213
11397
  var MIN_PROTOCOL_VERSION = 3;
11214
11398
  var RUNTIME_SHUTDOWN_TIMEOUT_MS = 1e4;
11399
+ var CLOUD_SESSION_CLEANUP_TIMEOUT_MS = 1e4;
11215
11400
  function createMessageConnection(reader, writer) {
11216
11401
  let dispatch;
11217
11402
  let finishDrain;
@@ -11740,6 +11925,11 @@ var CopilotClient = class _CopilotClient {
11740
11925
  "SessionFsConfig declares capabilities.sqlite but the provider does not implement sqlite."
11741
11926
  );
11742
11927
  }
11928
+ if (this.sessionFsConfig.capabilities?.binary && (!provider.readFileBytes || !provider.writeFileBytes)) {
11929
+ throw new Error(
11930
+ "SessionFsConfig declares capabilities.binary but the provider does not implement readFileBytes and writeFileBytes."
11931
+ );
11932
+ }
11743
11933
  session.clientSessionApis.sessionFs = createSessionFsAdapter(provider);
11744
11934
  }
11745
11935
  setupClientGlobalHandlers() {
@@ -12423,12 +12613,13 @@ var CopilotClient = class _CopilotClient {
12423
12613
  if (config.onEvent) {
12424
12614
  s.on(config.onEvent);
12425
12615
  }
12426
- this.sessions.set(sessionId, s);
12427
12616
  this.setupSessionFs(s, config);
12617
+ this.sessions.set(sessionId, s);
12428
12618
  return s;
12429
12619
  };
12430
12620
  let session;
12431
12621
  let registeredId;
12622
+ let uninitializedCloudSessionId;
12432
12623
  if (localSessionId !== void 0) {
12433
12624
  try {
12434
12625
  session = initializeSession(localSessionId);
@@ -12551,7 +12742,9 @@ var CopilotClient = class _CopilotClient {
12551
12742
  );
12552
12743
  }
12553
12744
  if (session === void 0) {
12745
+ uninitializedCloudSessionId = returnedSessionId;
12554
12746
  session = initializeSession(returnedSessionId);
12747
+ uninitializedCloudSessionId = void 0;
12555
12748
  registeredId = returnedSessionId;
12556
12749
  }
12557
12750
  this.assignGitHubTokenProvider(gitHubTokenProviderRegistrationId, returnedSessionId);
@@ -12573,6 +12766,20 @@ var CopilotClient = class _CopilotClient {
12573
12766
  if (gitHubTokenProviderRegistrationId !== void 0) {
12574
12767
  this.githubTokenProviders.delete(gitHubTokenProviderRegistrationId);
12575
12768
  }
12769
+ if (uninitializedCloudSessionId !== void 0) {
12770
+ try {
12771
+ await withTimeout(
12772
+ this.deleteSession(uninitializedCloudSessionId),
12773
+ CLOUD_SESSION_CLEANUP_TIMEOUT_MS,
12774
+ `session.delete timed out after ${CLOUD_SESSION_CLEANUP_TIMEOUT_MS}ms`
12775
+ );
12776
+ } catch (cleanupError) {
12777
+ throw new AggregateError(
12778
+ [e, cleanupError],
12779
+ "Failed to initialize and delete cloud session"
12780
+ );
12781
+ }
12782
+ }
12576
12783
  throw e;
12577
12784
  }
12578
12785
  for (const entry of this.hostHandoffs.values()) {
@@ -12672,8 +12879,8 @@ var CopilotClient = class _CopilotClient {
12672
12879
  if (config.onEvent) {
12673
12880
  session.on(config.onEvent);
12674
12881
  }
12675
- this.sessions.set(sessionId, session);
12676
12882
  this.setupSessionFs(session, config);
12883
+ this.sessions.set(sessionId, session);
12677
12884
  const toolFilterOptions = this.resolveToolFilterOptions(config);
12678
12885
  const gitHubTokenProviderRegistrationId = this.registerGitHubTokenProvider(
12679
12886
  config.gitHubTokenProvider,