@github/copilot-sdk-win32-x64 1.0.15-preview.2 → 1.0.15-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.
@@ -115,7 +115,7 @@ var require_messages = __commonJS({
115
115
  ErrorCodes4.jsonrpcReservedErrorRangeEnd = -32e3;
116
116
  ErrorCodes4.serverErrorEnd = -32e3;
117
117
  })(ErrorCodes3 || (exports.ErrorCodes = ErrorCodes3 = {}));
118
- var ResponseError3 = class _ResponseError extends Error {
118
+ var ResponseError4 = class _ResponseError extends Error {
119
119
  constructor(code, message, data) {
120
120
  super(message);
121
121
  this.code = is.number(code) ? code : ErrorCodes3.UnknownErrorCode;
@@ -133,7 +133,7 @@ var require_messages = __commonJS({
133
133
  return result;
134
134
  }
135
135
  };
136
- exports.ResponseError = ResponseError3;
136
+ exports.ResponseError = ResponseError4;
137
137
  var ParameterStructures = class _ParameterStructures {
138
138
  constructor(kind) {
139
139
  this.kind = kind;
@@ -933,7 +933,7 @@ var require_cancellation = __commonJS({
933
933
  }
934
934
  }
935
935
  };
936
- var CancellationTokenSource = class {
936
+ var CancellationTokenSource2 = class {
937
937
  get token() {
938
938
  if (!this._token) {
939
939
  this._token = new MutableToken();
@@ -955,7 +955,7 @@ var require_cancellation = __commonJS({
955
955
  }
956
956
  }
957
957
  };
958
- exports.CancellationTokenSource = CancellationTokenSource;
958
+ exports.CancellationTokenSource = CancellationTokenSource2;
959
959
  }
960
960
  });
961
961
 
@@ -4031,7 +4031,7 @@ var init_ffiRuntimeHost = __esm({
4031
4031
  });
4032
4032
 
4033
4033
  // src/sdk/nodejs/dist/client.js
4034
- var import_node2 = __toESM(require_node(), 1);
4034
+ var import_node3 = __toESM(require_node(), 1);
4035
4035
  import { spawn } from "node:child_process";
4036
4036
  import { randomUUID } from "node:crypto";
4037
4037
  import { existsSync as existsSync3 } from "node:fs";
@@ -4080,6 +4080,15 @@ function createServerRpc(connection) {
4080
4080
  getBuiltInCatalog: async () => connection.sendRequest("models.getBuiltInCatalog", {})
4081
4081
  },
4082
4082
  /** @experimental */
4083
+ sandbox: {
4084
+ /**
4085
+ * Reports whether the host running this runtime can run the command sandbox, without starting a session or spawning a sandboxed command.
4086
+ *
4087
+ * @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.
4088
+ */
4089
+ getHostSupport: async () => connection.sendRequest("sandbox.getHostSupport", {})
4090
+ },
4091
+ /** @experimental */
4083
4092
  tools: {
4084
4093
  /**
4085
4094
  * Lists built-in tools available for a model.
@@ -4200,7 +4209,74 @@ function createServerRpc(connection) {
4200
4209
  *
4201
4210
  * @returns Outcome of an mcp.planInstall call: either a normalised plan, or one typed refusal. Nothing is written in either case.
4202
4211
  */
4203
- planInstall: async (params) => connection.sendRequest("mcp.planInstall", params)
4212
+ planInstall: async (params) => connection.sendRequest("mcp.planInstall", params),
4213
+ /**
4214
+ * Consumes a bound catalogue plan and retains one exact fully resolved personal remote MCP operation requiring no supplied values or configured secrets. Returns its runtime operation ID and original expiry before any confirmation, activation, writer initialisation or installation effect. Register the original connection, operation and selected-session binding before calling applyInstall. Missing lower owned admission is unavailable, never a raw-config fallback.
4215
+ *
4216
+ * @param params Side-effect-free preparation of one original bound remote MCP choice.
4217
+ *
4218
+ * @returns Management result with contract receipt, or a typed request/negotiation refusal.
4219
+ */
4220
+ prepareInstall: async (params) => connection.sendRequest("mcp.prepareInstall", params),
4221
+ /**
4222
+ * Consumes a retained prepared MCP operation once, revalidates its original authority, requests explicit human consent through installations.confirm on the original connection, then revalidates source and applies the sealed transaction. An uncertain result requires original-operation inspection or recovery, never replay.
4223
+ *
4224
+ * @param params Applies exactly one previously prepared operation on its original connection.
4225
+ *
4226
+ * @returns An installation result together with the exact honoured contract, or a negotiation refusal.
4227
+ */
4228
+ applyInstall: async (params) => connection.sendRequest("mcp.applyInstall", params),
4229
+ /**
4230
+ * Prepares a read-only removal plan for an exact owned receipt under the selected existing session. Returns the original operation ID before confirmation; neither planning nor abandonment changes configuration or shared OAuth credentials.
4231
+ *
4232
+ * @param params Read-only preparation of one owned removal under fresh selected-session authority.
4233
+ *
4234
+ * @returns Management result with contract receipt, or a typed request/negotiation refusal.
4235
+ */
4236
+ planUninstall: async (params) => connection.sendRequest("mcp.planUninstall", params),
4237
+ /**
4238
+ * Consumes the original owned-removal plan once and requests fresh exact human confirmation on its original connection. Drift is refused; unrelated manual configuration and shared OAuth credentials are preserved.
4239
+ *
4240
+ * @param params One-use application of the exact retained removal plan.
4241
+ *
4242
+ * @returns An installation result together with the exact honoured contract, or a negotiation refusal.
4243
+ */
4244
+ applyUninstall: async (params) => connection.sendRequest("mcp.applyUninstall", params),
4245
+ /** @experimental */
4246
+ installations: {
4247
+ /**
4248
+ * Reads receipt-owned MCP inventory for the selected account and host without activating servers or reconstructing missing ownership. Configuration ownership does not prove session-specific usability.
4249
+ *
4250
+ * @param params New-work inventory or recovery request under an explicitly selected existing session.
4251
+ *
4252
+ * @returns Management result with contract receipt, or a typed request/negotiation refusal.
4253
+ */
4254
+ list: async (params) => connection.sendRequest("mcp.installations.list", params),
4255
+ /**
4256
+ * Reconciles already-confirmed durable MCP transactions, then inspects owned inventory. Does not replay apply or reconstruct deleted ownership metadata; unresolved or unsafe evidence remains an explicit refusal.
4257
+ *
4258
+ * @param params New-work inventory or recovery request under an explicitly selected existing session.
4259
+ *
4260
+ * @returns Management result with contract receipt, or a typed request/negotiation refusal.
4261
+ */
4262
+ recover: async (params) => connection.sendRequest("mcp.installations.recover", params),
4263
+ /**
4264
+ * Inspects a known operation only on its original connection. Remains available after account or selected-session loss; does not acquire new authority or rebind an operation.
4265
+ *
4266
+ * @param params Existing-operation control. A new session selector is deliberately not accepted.
4267
+ *
4268
+ * @returns Management result with contract receipt, or a typed request/negotiation refusal.
4269
+ */
4270
+ status: async (params) => connection.sendRequest("mcp.installations.status", params),
4271
+ /**
4272
+ * Requests cancellation of a known operation on its original connection, including before apply or confirmation. Already-started effects retain their transaction lease and report an honest terminal or recovery outcome.
4273
+ *
4274
+ * @param params Existing-operation control. A new session selector is deliberately not accepted.
4275
+ *
4276
+ * @returns Management result with contract receipt, or a typed request/negotiation refusal.
4277
+ */
4278
+ cancel: async (params) => connection.sendRequest("mcp.installations.cancel", params)
4279
+ }
4204
4280
  },
4205
4281
  /** @experimental */
4206
4282
  extensions: {
@@ -4223,6 +4299,115 @@ function createServerRpc(connection) {
4223
4299
  */
4224
4300
  disable: async (params) => connection.sendRequest("extensions.disable", params)
4225
4301
  },
4302
+ /** @experimental */
4303
+ skills: {
4304
+ /**
4305
+ * Plans installation of a verified Agent Finder Skill candidate without writing files. The returned review is safe to present to a user and installing always leaves the Skill disabled until separately enabled.
4306
+ *
4307
+ * @param params Side-effect-free planning of one verified Agent Finder Skill candidate.
4308
+ *
4309
+ * @returns Skill installation management result with the honoured contract, or a typed refusal.
4310
+ */
4311
+ planInstall: async (params) => connection.sendRequest("skills.planInstall", params),
4312
+ /**
4313
+ * Consumes one verified Skill installation plan, requests explicit human consent through installations.confirm on the original connection, then revalidates and installs the Skill disabled.
4314
+ *
4315
+ * @param params Applies exactly one retained verified Skill installation plan.
4316
+ *
4317
+ * @returns Skill installation result with the honoured contract, or a typed request/negotiation refusal.
4318
+ */
4319
+ applyInstall: async (params) => connection.sendRequest("skills.applyInstall", params),
4320
+ /** @experimental */
4321
+ installations: {
4322
+ /**
4323
+ * Lists owned verified Agent Finder Skill installations for the selected existing session. Listing is never gated by the Skill-install feature flag.
4324
+ *
4325
+ * @param params Inventory request under an explicitly selected existing session.
4326
+ *
4327
+ * @returns Skill installation management result with the honoured contract, or a typed refusal.
4328
+ */
4329
+ list: async (params) => connection.sendRequest("skills.installations.list", params),
4330
+ /**
4331
+ * Reconciles interrupted owned Skill installation work for the selected existing session, then inspects owned inventory. Recovery is never gated by the Skill-install feature flag.
4332
+ *
4333
+ * @param params Inventory request under an explicitly selected existing session.
4334
+ *
4335
+ * @returns Skill installation management result with the honoured contract, or a typed refusal.
4336
+ */
4337
+ recover: async (params) => connection.sendRequest("skills.installations.recover", params),
4338
+ /**
4339
+ * Inspects a known Skill installation operation on its original runtime connection. Status is never gated by the Skill-install feature flag.
4340
+ *
4341
+ * @param params Existing-operation control. A new session selector is deliberately not accepted.
4342
+ *
4343
+ * @returns Skill installation management result with the honoured contract, or a typed refusal.
4344
+ */
4345
+ status: async (params) => connection.sendRequest("skills.installations.status", params),
4346
+ /**
4347
+ * Requests cancellation of a known Skill installation operation before commit. Already-started durable work requires recovery instead of silent replay.
4348
+ *
4349
+ * @param params Existing-operation control. A new session selector is deliberately not accepted.
4350
+ *
4351
+ * @returns Skill installation management result with the honoured contract, or a typed refusal.
4352
+ */
4353
+ cancel: async (params) => connection.sendRequest("skills.installations.cancel", params),
4354
+ /**
4355
+ * Atomically persists enablement for one owned Agent Finder Skill and reconciles the selected bound session. Enablement is installation-scoped by receipt identity and is never gated by the Skill-install feature flag.
4356
+ *
4357
+ * @param params Persisted enablement update for one owned Skill installation.
4358
+ *
4359
+ * @returns Skill installation management result with the honoured contract, or a typed refusal.
4360
+ */
4361
+ setEnabled: async (params) => connection.sendRequest("skills.installations.setEnabled", params)
4362
+ },
4363
+ /**
4364
+ * Prepares a read-only removal plan for an owned verified Agent Finder Skill installation. Uninstall planning is never gated by the Skill-install feature flag.
4365
+ *
4366
+ * @param params Read-only preparation of one owned Skill removal under fresh selected-session authority.
4367
+ *
4368
+ * @returns Skill installation management result with the honoured contract, or a typed refusal.
4369
+ */
4370
+ planUninstall: async (params) => connection.sendRequest("skills.planUninstall", params),
4371
+ /**
4372
+ * Consumes an owned Skill removal plan, requests explicit human consent through installations.confirm, refuses drift, and removes the exact owned files through quarantine.
4373
+ *
4374
+ * @param params One-use application of the exact retained Skill removal plan.
4375
+ *
4376
+ * @returns Skill installation result with the honoured contract, or a typed request/negotiation refusal.
4377
+ */
4378
+ applyUninstall: async (params) => connection.sendRequest("skills.applyUninstall", params),
4379
+ /** @experimental */
4380
+ config: {
4381
+ /**
4382
+ * Replaces the global list of disabled skills.
4383
+ *
4384
+ * @param params Skill names to mark as disabled in global configuration, replacing any previous list.
4385
+ */
4386
+ setDisabledSkills: async (params) => connection.sendRequest("skills.config.setDisabledSkills", params),
4387
+ /**
4388
+ * Atomically adds or removes one skill from the disabled list.
4389
+ *
4390
+ * @param params Adds or removes a single skill from the global disabled list, leaving every other entry untouched.
4391
+ */
4392
+ setSkillDisabled: async (params) => connection.sendRequest("skills.config.setSkillDisabled", params)
4393
+ },
4394
+ /**
4395
+ * Discovers skills across global and project sources.
4396
+ *
4397
+ * @param params Optional project paths and additional skill directories to include in discovery.
4398
+ *
4399
+ * @returns Skills discovered across global and project sources.
4400
+ */
4401
+ discover: async (params) => connection.sendRequest("skills.discover", params),
4402
+ /**
4403
+ * Returns the canonical directories where a client may create skills that the runtime will recognize, including ones that do not exist yet. Project directories become active once created.
4404
+ *
4405
+ * @param params Optional project paths to enumerate.
4406
+ *
4407
+ * @returns Canonical locations where skills can be created so the runtime will recognize them.
4408
+ */
4409
+ getDiscoveryPaths: async (params) => connection.sendRequest("skills.getDiscoveryPaths", params)
4410
+ },
4226
4411
  /**
4227
4412
  * Registers the calling SDK client as the per-entrypoint extension launch provider. Call before creating any sessions. When omitted, the runtime uses its built-in extension launcher.
4228
4413
  *
@@ -4348,40 +4533,6 @@ function createServerRpc(connection) {
4348
4533
  }
4349
4534
  },
4350
4535
  /** @experimental */
4351
- skills: {
4352
- /** @experimental */
4353
- config: {
4354
- /**
4355
- * Replaces the global list of disabled skills.
4356
- *
4357
- * @param params Skill names to mark as disabled in global configuration, replacing any previous list.
4358
- */
4359
- setDisabledSkills: async (params) => connection.sendRequest("skills.config.setDisabledSkills", params),
4360
- /**
4361
- * Atomically adds or removes one skill from the disabled list.
4362
- *
4363
- * @param params Adds or removes a single skill from the global disabled list, leaving every other entry untouched.
4364
- */
4365
- setSkillDisabled: async (params) => connection.sendRequest("skills.config.setSkillDisabled", params)
4366
- },
4367
- /**
4368
- * Discovers skills across global and project sources.
4369
- *
4370
- * @param params Optional project paths and additional skill directories to include in discovery.
4371
- *
4372
- * @returns Skills discovered across global and project sources.
4373
- */
4374
- discover: async (params) => connection.sendRequest("skills.discover", params),
4375
- /**
4376
- * Returns the canonical directories where a client may create skills that the runtime will recognize, including ones that do not exist yet. Project directories become active once created.
4377
- *
4378
- * @param params Optional project paths to enumerate.
4379
- *
4380
- * @returns Canonical locations where skills can be created so the runtime will recognize them.
4381
- */
4382
- getDiscoveryPaths: async (params) => connection.sendRequest("skills.getDiscoveryPaths", params)
4383
- },
4384
- /** @experimental */
4385
4536
  agents: {
4386
4537
  /**
4387
4538
  * Discovers custom agents across user, project, plugin, and remote sources.
@@ -4786,6 +4937,17 @@ function createInternalServerRpc(connection) {
4786
4937
  * @param params Params to attach or detach an in-process ExtensionController delegate.
4787
4938
  */
4788
4939
  configureSessionExtensions: async (params) => connection.sendRequest("sessions.configureSessionExtensions", params)
4940
+ },
4941
+ /** @experimental */
4942
+ accounts: {
4943
+ /**
4944
+ * 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).
4945
+ *
4946
+ * @param params OneAuth token request supplied by a trusted host application.
4947
+ *
4948
+ * @returns Result of a OneAuth token acquisition.
4949
+ */
4950
+ acquireEntraToken: async (params) => connection.sendRequest("accounts.acquireEntraToken", params)
4789
4951
  }
4790
4952
  };
4791
4953
  }
@@ -4888,6 +5050,58 @@ function createSessionRpc(connection, sessionId) {
4888
5050
  setCredentials: async (params) => connection.sendRequest("session.gitHubAuth.setCredentials", { sessionId, ...params })
4889
5051
  },
4890
5052
  /** @experimental */
5053
+ accounts: {
5054
+ /**
5055
+ * Enumerate a typed accounts collection: the signed-in accounts, or the providers offered for interactive login.
5056
+ *
5057
+ * @param params Enumerate request carrying the typed collection query.
5058
+ *
5059
+ * @returns The enumerated collection, keyed by the same selector as the query.
5060
+ */
5061
+ enumerate: async (params) => connection.sendRequest("session.accounts.enumerate", { sessionId, ...params }),
5062
+ /**
5063
+ * Read one typed accounts datum: the active account, a neutral status summary, or the last authentication errors.
5064
+ *
5065
+ * @param params Read request carrying the typed datum query.
5066
+ *
5067
+ * @returns The read result, keyed by the same selector as the query.
5068
+ */
5069
+ get: async (params) => connection.sendRequest("session.accounts.get", { sessionId, ...params }),
5070
+ /**
5071
+ * Apply one non-interactive accounts mutation: switch the active account, log an account out, or set credentials from a token.
5072
+ *
5073
+ * @param params Mutation request carrying the typed write command.
5074
+ *
5075
+ * @returns Result of a non-interactive accounts mutation.
5076
+ */
5077
+ set: async (params) => connection.sendRequest("session.accounts.set", { sessionId, ...params }),
5078
+ /** @experimental */
5079
+ login: {
5080
+ /**
5081
+ * Begin an interactive login flow for a provider kind (dispatch is kind-only) and return its opaque flow id and first step.
5082
+ *
5083
+ * @param params Begin an interactive login flow for a provider kind. Dispatch is kind-only.
5084
+ *
5085
+ * @returns A started login flow: its opaque id and first step.
5086
+ */
5087
+ begin: async (params) => connection.sendRequest("session.accounts.login.begin", { sessionId, ...params }),
5088
+ /**
5089
+ * Advance an in-flight login flow, optionally fulfilling an input-required step, and return the next step.
5090
+ *
5091
+ * @param params Advance an in-flight login flow, optionally fulfilling an input-required step.
5092
+ *
5093
+ * @returns One step in an interactive login flow. The consumer acts on the step and calls advance to proceed. Browser-open is encoded as two distinct steps by design: `open-url` is CONSUMER-driven (the provider surfaces the authorize URL and the consumer opens it — github.com/GHEC web), while `needs-interaction` is PROVIDER-driven (the provider opens the browser or broker UI itself and does not surface a URL — Entra).
5094
+ */
5095
+ advance: async (params) => connection.sendRequest("session.accounts.login.advance", { sessionId, ...params }),
5096
+ /**
5097
+ * Cancel an in-flight login flow and release its resources.
5098
+ *
5099
+ * @param params Cancel an in-flight login flow.
5100
+ */
5101
+ cancel: async (params) => connection.sendRequest("session.accounts.login.cancel", { sessionId, ...params })
5102
+ }
5103
+ },
5104
+ /** @experimental */
4891
5105
  debug: {
4892
5106
  /**
4893
5107
  * Collects a session debug log bundle into a local archive or staging directory. Logs are redacted by default; redaction can be configured per caller-provided diagnostic entry. The runtime includes session-owned logs by default and accepts caller-provided diagnostic entries so host applications can add their own files without changing this API shape.
@@ -4939,108 +5153,6 @@ function createSessionRpc(connection, sessionId) {
4939
5153
  }
4940
5154
  },
4941
5155
  /** @experimental */
4942
- factory: {
4943
- /**
4944
- * Runs a registered factory by name at the top level.
4945
- *
4946
- * @param params Parameters for invoking a registered factory.
4947
- *
4948
- * @returns Complete current or terminal factory run envelope.
4949
- */
4950
- run: async (params) => connection.sendRequest("session.factory.run", { sessionId, ...params }),
4951
- /**
4952
- * Resumes a factory run using its persisted name, arguments, journal, and accounting.
4953
- *
4954
- * @param params Parameters for resuming a factory run from its persisted identity.
4955
- *
4956
- * @returns Resolved persisted factory identity and resumed run envelope.
4957
- */
4958
- resume: async (params) => connection.sendRequest("session.factory.resume", { sessionId, ...params }),
4959
- /**
4960
- * Gets the current or settled envelope for a factory run.
4961
- *
4962
- * @param params Parameters for retrieving a factory run.
4963
- *
4964
- * @returns Complete current or terminal factory run envelope.
4965
- */
4966
- getRun: async (params) => connection.sendRequest("session.factory.getRun", { sessionId, ...params }),
4967
- /**
4968
- * Lists durable factory runs for this session in creation order.
4969
- *
4970
- * @param params Parameters for paging factory runs.
4971
- *
4972
- * @returns A page of factory runs in durable creation order.
4973
- */
4974
- listRuns: async (params) => connection.sendRequest("session.factory.listRuns", { sessionId, ...params }),
4975
- /**
4976
- * Gets durable and live observability detail for one factory run.
4977
- *
4978
- * @param params Parameters for retrieving a factory run.
4979
- *
4980
- * @returns Full factory run observability detail.
4981
- */
4982
- getRunDetail: async (params) => connection.sendRequest("session.factory.getRunDetail", { sessionId, ...params }),
4983
- /**
4984
- * Pages durable progress for one factory run.
4985
- *
4986
- * @param params Parameters for paging factory progress.
4987
- *
4988
- * @returns A bidirectional page of factory progress.
4989
- */
4990
- getRunProgress: async (params) => connection.sendRequest("session.factory.getRunProgress", { sessionId, ...params }),
4991
- /**
4992
- * Requests cancellation of a factory run and returns its run envelope.
4993
- *
4994
- * @param params Parameters for cancelling a factory run.
4995
- *
4996
- * @returns Complete current or terminal factory run envelope.
4997
- */
4998
- cancel: async (params) => connection.sendRequest("session.factory.cancel", { sessionId, ...params }),
4999
- /**
5000
- * Pauses a running factory and returns its settled run envelope.
5001
- *
5002
- * @param params Parameters for pausing a running factory.
5003
- *
5004
- * @returns Complete current or terminal factory run envelope.
5005
- */
5006
- pause: async (params) => connection.sendRequest("session.factory.pause", { sessionId, ...params }),
5007
- /**
5008
- * Records a batch of ordered factory progress lines.
5009
- *
5010
- * @param params Parameters for recording factory progress.
5011
- *
5012
- * @returns Acknowledgement that a factory request was accepted.
5013
- */
5014
- log: async (params) => connection.sendRequest("session.factory.log", { sessionId, ...params }),
5015
- /**
5016
- * Runs one factory-scoped subagent and returns its result.
5017
- *
5018
- * @param params Parameters for one factory-scoped subagent call.
5019
- *
5020
- * @returns Result of one factory-scoped subagent call.
5021
- */
5022
- agent: async (params) => connection.sendRequest("session.factory.agent", { sessionId, ...params }),
5023
- /** @experimental */
5024
- journal: {
5025
- /**
5026
- * Reads a memoized factory journal entry.
5027
- *
5028
- * @param params Parameters for reading a factory journal entry.
5029
- *
5030
- * @returns Result of reading a factory journal entry.
5031
- */
5032
- get: async (params) => connection.sendRequest("session.factory.journal.get", { sessionId, ...params }),
5033
- /**
5034
- * Stores a memoized factory journal entry.
5035
- *
5036
- * @param params Parameters for storing a factory journal entry.
5037
- *
5038
- * @returns Acknowledgement that a factory request was accepted.
5039
- */
5040
- put: async (params) => connection.sendRequest("session.factory.journal.put", { sessionId, ...params })
5041
- }
5042
- },
5043
- /** @experimental */
5044
5156
  workflow: {
5045
5157
  /**
5046
5158
  * Runs a registered dynamic workflow by name at the top level.
@@ -5438,7 +5550,20 @@ function createSessionRpc(connection, sessionId) {
5438
5550
  *
5439
5551
  * @returns Instruction sources loaded for the session, in merge order.
5440
5552
  */
5441
- getSources: async () => connection.sendRequest("session.instructions.getSources", { sessionId })
5553
+ getSources: async () => connection.sendRequest("session.instructions.getSources", { sessionId }),
5554
+ /**
5555
+ * Invalidates cached custom-instruction discovery so subsequent turns and source reads observe instruction files currently on disk.
5556
+ */
5557
+ reload: async () => connection.sendRequest("session.instructions.reload", { sessionId })
5558
+ },
5559
+ /** @experimental */
5560
+ customizations: {
5561
+ /**
5562
+ * 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.
5563
+ *
5564
+ * @returns Diagnostics from reloading skill definitions, with warnings and errors as separate lists.
5565
+ */
5566
+ reload: async () => connection.sendRequest("session.customizations.reload", { sessionId })
5442
5567
  },
5443
5568
  /** @experimental */
5444
5569
  fleet: {
@@ -5737,7 +5862,15 @@ function createSessionRpc(connection, sessionId) {
5737
5862
  */
5738
5863
  authenticationStateChanged: async (params) => connection.sendRequest("session.mcp.oauth.authenticationStateChanged", { sessionId, ...params }),
5739
5864
  /**
5740
- * Starts OAuth authentication for a remote MCP server.
5865
+ * Prepares an inert, expiring owned OAuth login bound to the original session requester and exact installation. Does not activate, connect, read credentials or open a browser.
5866
+ *
5867
+ * @param params Effect-free preparation bound to the existing local session, requester and installation, with frozen options.
5868
+ *
5869
+ * @returns An inert runtime-issued login handle. Preparation alone performs no activation or OAuth work.
5870
+ */
5871
+ prepareLogin: async (params) => connection.sendRequest("session.mcp.oauth.prepareLogin", { sessionId, ...params }),
5872
+ /**
5873
+ * Starts OAuth authentication for a remote MCP server. Owned servers require the original one-use prepareLogin handle and exact installation ID; manual servers retain the existing direct login behaviour.
5741
5874
  *
5742
5875
  * @param params Remote MCP server name and optional overrides controlling reauthentication, OAuth client display name, callback success-page copy, and static OAuth client selection.
5743
5876
  *
@@ -5752,6 +5885,14 @@ function createSessionRpc(connection, sessionId) {
5752
5885
  * @returns Passive MCP OAuth probe result. `authenticated` means the server accepted the probe request while an OAuth-origin access token was attached; it does not prove the server required or independently validated that token. The probe does not make a second unauthenticated request. Failed is an expected probe-domain outcome; JSON-RPC errors are reserved for API-call failures.
5753
5886
  */
5754
5887
  probe: async (params) => connection.sendRequest("session.mcp.oauth.probe", { sessionId, ...params }),
5888
+ /**
5889
+ * Cancels the exact owned OAuth login issued to this original session requester, without clearing shared credentials.
5890
+ *
5891
+ * @param params Targets only the original prepared/applying owned login on this exact session requester.
5892
+ *
5893
+ * @returns Honest terminal cancellation result; persistence or recovery failures remain RPC errors.
5894
+ */
5895
+ cancelLogin: async (params) => connection.sendRequest("session.mcp.oauth.cancelLogin", { sessionId, ...params }),
5755
5896
  /**
5756
5897
  * Responds to a pending MCP OAuth authorization request by its request id.
5757
5898
  *
@@ -5848,17 +5989,36 @@ function createSessionRpc(connection, sessionId) {
5848
5989
  }
5849
5990
  },
5850
5991
  /** @experimental */
5851
- connectors: {
5992
+ diagnostics: {
5852
5993
  /**
5853
- * Returns feature availability and bounded polling limits for the EXPERIMENTAL session connector API. This method never performs a Connector service request.
5994
+ * Patches configured session diagnostic sources without restarting their producers. Setting a source level to off clears its retained diagnostics and invalidates cursors selecting that source.
5854
5995
  *
5855
- * @returns Feature detection and hard polling limits for the EXPERIMENTAL session connector API.
5996
+ * @param params Patch session diagnostic thresholds for explicitly supplied sources.
5997
+ *
5998
+ * @returns Per-source session diagnostics configuration.
5856
5999
  */
5857
- getCapabilities: async () => connection.sendRequest("session.connectors.getCapabilities", { sessionId }),
6000
+ configure: async (params) => connection.sendRequest("session.diagnostics.configure", { sessionId, ...params }),
5858
6001
  /**
5859
- * Returns authoritative session Connector state from current availability, pinned account selection, cached catalog, and live MCP projection without performing a Connector service request.
6002
+ * Reads a bounded batch of retained session diagnostics for the selected sources. Records are never consumed and each reader advances independently through its opaque cursor.
5860
6003
  *
5861
- * @returns Authoritative session connector state. Account IDs are opaque routing identifiers and credentials are never included.
6004
+ * @param params Cursor-based request for session diagnostics. The default limit is 100 (maximum 500); the default waitMs is zero (maximum 30000).
6005
+ *
6006
+ * @returns One cursor-addressed page of retained session diagnostics.
6007
+ */
6008
+ read: async (params) => connection.sendRequest("session.diagnostics.read", { sessionId, ...params })
6009
+ },
6010
+ /** @experimental */
6011
+ connectors: {
6012
+ /**
6013
+ * Returns feature availability and bounded polling limits for the EXPERIMENTAL session connector API. This method never performs a Connector service request.
6014
+ *
6015
+ * @returns Feature detection and hard polling limits for the EXPERIMENTAL session connector API.
6016
+ */
6017
+ getCapabilities: async () => connection.sendRequest("session.connectors.getCapabilities", { sessionId }),
6018
+ /**
6019
+ * Returns authoritative session Connector state from current availability, pinned account selection, cached catalog, and live MCP projection without performing a Connector service request.
6020
+ *
6021
+ * @returns Authoritative session connector state. Account IDs are opaque routing identifiers and credentials are never included.
5862
6022
  */
5863
6023
  getStatus: async () => connection.sendRequest("session.connectors.getStatus", { sessionId }),
5864
6024
  /**
@@ -6727,11 +6887,11 @@ function createSessionRpc(connection, sessionId) {
6727
6887
  */
6728
6888
  updateText: async (params) => connection.sendRequest("session.queue.updateText", { sessionId, ...params }),
6729
6889
  /**
6730
- * Atomically withdraws an unchanged, unconsumed user message from the local queued or steering lane. A client retaining the original draft may restore it only when removed is true. Does not interrupt the running turn.
6890
+ * Atomically withdraws an unchanged user message of a local session: from the queued or steering lane while unconsumed, or from the running turn it started while the model has not answered it and nothing the user sent after it is pending. Withdrawing from the running turn interrupts that turn and removes its events from history. A client retaining the original draft may restore it only when removed is true.
6731
6891
  *
6732
- * @param params Conditional withdrawal of a single user message, before the runtime claims it for delivery.
6892
+ * @param params Conditional withdrawal of a single user message, from its queue or from the running turn it started.
6733
6893
  *
6734
- * @returns Result of removing a queued item.
6894
+ * @returns Result of withdrawing a user message.
6735
6895
  */
6736
6896
  withdrawMessage: async (params) => connection.sendRequest("session.queue.withdrawMessage", { sessionId, ...params }),
6737
6897
  /**
@@ -6971,31 +7131,6 @@ function createInternalSessionRpc(connection, sessionId) {
6971
7131
  }
6972
7132
  },
6973
7133
  /** @experimental */
6974
- factory: {
6975
- /**
6976
- * Internal tool-originated factory invocation.
6977
- *
6978
- * @param params Internal parameters for invoking a registered factory from a tool.
6979
- *
6980
- * @returns Complete current or terminal factory run envelope.
6981
- */
6982
- runFromTool: async (params) => connection.sendRequest("session.factory.runFromTool", { sessionId, ...params }),
6983
- /**
6984
- * Internal tool-originated factory resume.
6985
- *
6986
- * @param params Internal parameters for resuming a factory run from a tool.
6987
- *
6988
- * @returns Resolved persisted factory identity and resumed run envelope.
6989
- */
6990
- resumeFromTool: async (params) => connection.sendRequest("session.factory.resumeFromTool", { sessionId, ...params }),
6991
- /**
6992
- * Atomically pauses an owned factory attempt at a durable checkpoint.
6993
- *
6994
- * @param params Parameters for an owned durable pause checkpoint.
6995
- */
6996
- pauseAtCheckpoint: async (params) => connection.sendRequest("session.factory.pauseAtCheckpoint", { sessionId, ...params })
6997
- },
6998
- /** @experimental */
6999
7134
  workflow: {
7000
7135
  /**
7001
7136
  * Internal tool-originated dynamic workflow invocation.
@@ -7223,16 +7358,6 @@ function registerClientSessionApiHandlers(connection, getHandlers) {
7223
7358
  if (!handler) throw new Error(`No providerToken handler registered for session: ${params.sessionId}`);
7224
7359
  return handler.getToken(params);
7225
7360
  });
7226
- connection.onRequest("factory.execute", async (params) => {
7227
- const handler = getHandlers(params.sessionId).factory;
7228
- if (!handler) throw new Error(`No factory handler registered for session: ${params.sessionId}`);
7229
- return handler.execute(params);
7230
- });
7231
- connection.onRequest("factory.abort", async (params) => {
7232
- const handler = getHandlers(params.sessionId).factory;
7233
- if (!handler) throw new Error(`No factory handler registered for session: ${params.sessionId}`);
7234
- return handler.abort(params);
7235
- });
7236
7361
  connection.onRequest("workflow.execute", async (params) => {
7237
7362
  const handler = getHandlers(params.sessionId).workflow;
7238
7363
  if (!handler) throw new Error(`No workflow handler registered for session: ${params.sessionId}`);
@@ -7355,6 +7480,11 @@ function registerClientGlobalApiHandlers(connection, handlers) {
7355
7480
  if (!handler) throw new Error("No gitHubToken client-global handler registered");
7356
7481
  return handler.getToken(params);
7357
7482
  });
7483
+ connection.onRequest("installations.confirm", async (params) => {
7484
+ const handler = handlers.installations;
7485
+ if (!handler) throw new Error("No installations client-global handler registered");
7486
+ return handler.confirm(params);
7487
+ });
7358
7488
  }
7359
7489
 
7360
7490
  // src/sdk/nodejs/dist/sdkProtocolVersion.js
@@ -8483,107 +8613,6 @@ var DisableBypassPermissionsModes = {
8483
8613
  AllowAutoOnly: "allow-auto-only"
8484
8614
  };
8485
8615
 
8486
- // src/sdk/nodejs/dist/factory.js
8487
- var FACTORY_TERMINAL_STATUSES = /* @__PURE__ */ new Set([
8488
- "completed",
8489
- "halted",
8490
- "paused",
8491
- "cancelled",
8492
- "error"
8493
- ]);
8494
- function isFactoryRunTerminal(status) {
8495
- return FACTORY_TERMINAL_STATUSES.has(status);
8496
- }
8497
- var FACTORY_AGENT_OPTION_KEYS = [
8498
- "label",
8499
- "schema",
8500
- "model",
8501
- "reasoningEffort",
8502
- "contextTier",
8503
- "agent"
8504
- ];
8505
- var FactoryResumeError = class extends Error {
8506
- constructor(code, message) {
8507
- super(message);
8508
- this.code = code;
8509
- this.name = "FactoryResumeError";
8510
- }
8511
- code;
8512
- };
8513
- var factoryHandles = /* @__PURE__ */ new WeakMap();
8514
- var MAX_FACTORY_TIMEOUT_SECONDS = 2147483647e-3;
8515
- var NANO_AIU_PER_AIU = 1e9;
8516
- function deepFreeze(value) {
8517
- if (value !== null && typeof value === "object" && !Object.isFrozen(value)) {
8518
- Object.freeze(value);
8519
- for (const nested of Object.values(value)) {
8520
- deepFreeze(nested);
8521
- }
8522
- }
8523
- return value;
8524
- }
8525
- function validateLimits(meta) {
8526
- const limits = meta.limits;
8527
- if (!limits) {
8528
- return;
8529
- }
8530
- for (const field of ["maxConcurrentSubagents", "maxTotalSubagents"]) {
8531
- const value = limits[field];
8532
- if (value !== void 0 && (!Number.isInteger(value) || value <= 0)) {
8533
- throw new Error(`Factory limit "${field}" must be a positive integer`);
8534
- }
8535
- }
8536
- if (limits.timeoutSeconds !== void 0 && (!Number.isFinite(limits.timeoutSeconds) || limits.timeoutSeconds <= 0)) {
8537
- throw new Error(
8538
- 'Factory limit "timeoutSeconds" must be a positive, finite number of seconds'
8539
- );
8540
- }
8541
- if (limits.timeoutSeconds !== void 0 && limits.timeoutSeconds > MAX_FACTORY_TIMEOUT_SECONDS) {
8542
- throw new Error(
8543
- `Factory limit "timeoutSeconds" must not exceed ${MAX_FACTORY_TIMEOUT_SECONDS} seconds`
8544
- );
8545
- }
8546
- if (limits.maxAiCredits !== void 0) {
8547
- const maxNanoAiu = Math.round(limits.maxAiCredits * NANO_AIU_PER_AIU);
8548
- if (!Number.isFinite(limits.maxAiCredits) || limits.maxAiCredits <= 0 || !Number.isSafeInteger(maxNanoAiu) || maxNanoAiu < 1) {
8549
- throw new Error(
8550
- 'Factory limit "maxAiCredits" must be a positive, finite number that rounds to a safe positive integer nano-AIU ceiling'
8551
- );
8552
- }
8553
- }
8554
- }
8555
- function validatePhases(meta) {
8556
- const titles = /* @__PURE__ */ new Set();
8557
- for (const phase of meta.phases) {
8558
- if (phase.title.trim().length === 0) {
8559
- throw new Error("Factory phase titles must not be empty");
8560
- }
8561
- if (titles.has(phase.title)) {
8562
- throw new Error(`Factory phase title "${phase.title}" is declared more than once`);
8563
- }
8564
- titles.add(phase.title);
8565
- }
8566
- }
8567
- function defineFactory(definition) {
8568
- const meta = deepFreeze(structuredClone(definition.meta));
8569
- validateLimits(meta);
8570
- validatePhases(meta);
8571
- const stored = {
8572
- meta,
8573
- run: definition.run
8574
- };
8575
- const handle = Object.freeze({ meta });
8576
- factoryHandles.set(handle, stored);
8577
- return handle;
8578
- }
8579
- function getFactoryDefinition(handle) {
8580
- const definition = factoryHandles.get(handle);
8581
- if (!definition) {
8582
- throw new Error("Invalid factory handle");
8583
- }
8584
- return definition;
8585
- }
8586
-
8587
8616
  // src/sdk/nodejs/dist/workflow.js
8588
8617
  var WORKFLOW_TERMINAL_STATUSES = /* @__PURE__ */ new Set([
8589
8618
  "completed",
@@ -8613,17 +8642,17 @@ var WorkflowResumeError = class extends Error {
8613
8642
  };
8614
8643
  var workflowHandles = /* @__PURE__ */ new WeakMap();
8615
8644
  var MAX_WORKFLOW_TIMEOUT_SECONDS = 2147483647e-3;
8616
- var NANO_AIU_PER_AIU2 = 1e9;
8617
- function deepFreeze2(value) {
8645
+ var NANO_AIU_PER_AIU = 1e9;
8646
+ function deepFreeze(value) {
8618
8647
  if (value !== null && typeof value === "object" && !Object.isFrozen(value)) {
8619
8648
  Object.freeze(value);
8620
8649
  for (const nested of Object.values(value)) {
8621
- deepFreeze2(nested);
8650
+ deepFreeze(nested);
8622
8651
  }
8623
8652
  }
8624
8653
  return value;
8625
8654
  }
8626
- function validateLimits2(meta) {
8655
+ function validateLimits(meta) {
8627
8656
  const limits = meta.limits;
8628
8657
  if (!limits) {
8629
8658
  return;
@@ -8645,7 +8674,7 @@ function validateLimits2(meta) {
8645
8674
  );
8646
8675
  }
8647
8676
  if (limits.maxAiCredits !== void 0) {
8648
- const maxNanoAiu = Math.round(limits.maxAiCredits * NANO_AIU_PER_AIU2);
8677
+ const maxNanoAiu = Math.round(limits.maxAiCredits * NANO_AIU_PER_AIU);
8649
8678
  if (!Number.isFinite(limits.maxAiCredits) || limits.maxAiCredits <= 0 || !Number.isSafeInteger(maxNanoAiu) || maxNanoAiu < 1) {
8650
8679
  throw new Error(
8651
8680
  'Workflow limit "maxAiCredits" must be a positive, finite number that rounds to a safe positive integer nano-AIU ceiling'
@@ -8653,7 +8682,7 @@ function validateLimits2(meta) {
8653
8682
  }
8654
8683
  }
8655
8684
  }
8656
- function validatePhases2(meta) {
8685
+ function validatePhases(meta) {
8657
8686
  const titles = /* @__PURE__ */ new Set();
8658
8687
  for (const phase of meta.phases) {
8659
8688
  if (phase.title.trim().length === 0) {
@@ -8666,9 +8695,9 @@ function validatePhases2(meta) {
8666
8695
  }
8667
8696
  }
8668
8697
  function defineWorkflow(definition) {
8669
- const meta = deepFreeze2(structuredClone(definition.meta));
8670
- validateLimits2(meta);
8671
- validatePhases2(meta);
8698
+ const meta = deepFreeze(structuredClone(definition.meta));
8699
+ validateLimits(meta);
8700
+ validatePhases(meta);
8672
8701
  const stored = {
8673
8702
  meta,
8674
8703
  run: definition.run
@@ -8686,15 +8715,6 @@ function getWorkflowDefinition(handle) {
8686
8715
  }
8687
8716
 
8688
8717
  // src/sdk/nodejs/dist/session.js
8689
- function isFactoryResumeErrorCode(value) {
8690
- return value === "not_found" || value === "non_resumable" || value === "already_active" || value === "factory_already_running" || value === "factory_limits_invalid" || value === "factory_session_disposed" || value === "factory_storage_unavailable" || value === "factory_storage_corrupt";
8691
- }
8692
- function copyDefinedFactoryAgentOption(source, target, key) {
8693
- const value = source[key];
8694
- if (value !== void 0) {
8695
- target[key] = value;
8696
- }
8697
- }
8698
8718
  function isWorkflowResumeErrorCode(value) {
8699
8719
  return value === "not_found" || value === "non_resumable" || value === "workflow_run_not_resumable" || value === "already_active" || value === "workflow_already_running" || value === "workflow_limits_invalid" || value === "workflow_session_disposed" || value === "workflow_storage_unavailable" || value === "workflow_storage_corrupt";
8700
8720
  }
@@ -8704,14 +8724,6 @@ function copyDefinedWorkflowAgentOption(source, target, key) {
8704
8724
  target[key] = value;
8705
8725
  }
8706
8726
  }
8707
- var factoryExecutionStore = new AsyncLocalStorage();
8708
- function throwIfFactoryExecutionIsActive() {
8709
- if (factoryExecutionStore.getStore()?.active) {
8710
- throw new Error(
8711
- "factory.run, factory.resume, and factory.pause are not allowed while a factory body is running on this call path."
8712
- );
8713
- }
8714
- }
8715
8727
  var workflowExecutionStore = new AsyncLocalStorage();
8716
8728
  function throwIfWorkflowExecutionIsActive() {
8717
8729
  if (workflowExecutionStore.getStore()?.active) {
@@ -8724,10 +8736,6 @@ function runInWorkflowHelperScope(helperScope, callback) {
8724
8736
  const current = workflowExecutionStore.getStore();
8725
8737
  return workflowExecutionStore.run({ active: current?.active ?? false, helperScope }, callback);
8726
8738
  }
8727
- function runInFactoryHelperScope(helperScope, callback) {
8728
- const current = factoryExecutionStore.getStore();
8729
- return factoryExecutionStore.run({ active: current?.active ?? false, helperScope }, callback);
8730
- }
8731
8739
  function deserializeHookInput(raw) {
8732
8740
  if (!raw || typeof raw !== "object" || typeof raw.timestamp !== "number") {
8733
8741
  return raw;
@@ -8750,68 +8758,20 @@ function isOpenCanvasInstance(value) {
8750
8758
  }
8751
8759
  var FACTORY_LOG_FLUSH_DELAY_MS = 10;
8752
8760
  var MAX_FACTORY_FANOUT_ITEMS = 4096;
8753
- function assertFactoryFanoutSize(kind, size) {
8761
+ function assertWorkflowFanoutSize(kind, size) {
8754
8762
  if (size > MAX_FACTORY_FANOUT_ITEMS) {
8755
8763
  throw new Error(
8756
8764
  `${kind}() accepts at most ${MAX_FACTORY_FANOUT_ITEMS} items; got ${size}.`
8757
8765
  );
8758
8766
  }
8759
8767
  }
8760
- async function runFactoryParallel(thunks) {
8761
- if (!Array.isArray(thunks)) {
8762
- throw new Error(
8763
- "parallel() expects an array of functions, not promises. Wrap each call: () => agent(...)"
8764
- );
8765
- }
8766
- assertFactoryFanoutSize("parallel", thunks.length);
8767
- if (thunks.some((thunk) => typeof thunk !== "function")) {
8768
- throw new Error(
8769
- "parallel() expects an array of functions, not promises. Wrap each call: () => agent(...)"
8770
- );
8771
- }
8772
- return Promise.all(
8773
- thunks.map(
8774
- (thunk) => Promise.resolve().then(() => runInFactoryHelperScope("parallel", thunk)).catch((error) => {
8775
- if (isFactoryFatalError(error)) {
8776
- throw error;
8777
- }
8778
- return null;
8779
- })
8780
- )
8781
- );
8782
- }
8783
- async function runFactoryPipeline(items, ...stages) {
8784
- if (!Array.isArray(items)) {
8785
- throw new Error("pipeline(items, ...stages): items must be an array");
8786
- }
8787
- assertFactoryFanoutSize("pipeline", items.length);
8788
- return Promise.all(
8789
- items.map(async (item, index) => {
8790
- let previous = item;
8791
- for (const stage of stages) {
8792
- try {
8793
- previous = await runInFactoryHelperScope(
8794
- "pipeline",
8795
- () => stage(previous, item, index)
8796
- );
8797
- } catch (error) {
8798
- if (isFactoryFatalError(error)) {
8799
- throw error;
8800
- }
8801
- return null;
8802
- }
8803
- }
8804
- return previous;
8805
- })
8806
- );
8807
- }
8808
8768
  async function runWorkflowParallel(thunks) {
8809
8769
  if (!Array.isArray(thunks)) {
8810
8770
  throw new Error(
8811
8771
  "parallel() expects an array of functions, not promises. Wrap each call: () => agent(...)"
8812
8772
  );
8813
8773
  }
8814
- assertFactoryFanoutSize("parallel", thunks.length);
8774
+ assertWorkflowFanoutSize("parallel", thunks.length);
8815
8775
  if (thunks.some((thunk) => typeof thunk !== "function")) {
8816
8776
  throw new Error(
8817
8777
  "parallel() expects an array of functions, not promises. Wrap each call: () => agent(...)"
@@ -8820,7 +8780,7 @@ async function runWorkflowParallel(thunks) {
8820
8780
  return Promise.all(
8821
8781
  thunks.map(
8822
8782
  (thunk) => Promise.resolve().then(() => runInWorkflowHelperScope("parallel", thunk)).catch((error) => {
8823
- if (isFactoryFatalError(error)) {
8783
+ if (isWorkflowFatalError(error)) {
8824
8784
  throw error;
8825
8785
  }
8826
8786
  return null;
@@ -8832,7 +8792,7 @@ async function runWorkflowPipeline(items, ...stages) {
8832
8792
  if (!Array.isArray(items)) {
8833
8793
  throw new Error("pipeline(items, ...stages): items must be an array");
8834
8794
  }
8835
- assertFactoryFanoutSize("pipeline", items.length);
8795
+ assertWorkflowFanoutSize("pipeline", items.length);
8836
8796
  return Promise.all(
8837
8797
  items.map(async (item, index) => {
8838
8798
  let previous = item;
@@ -8843,7 +8803,7 @@ async function runWorkflowPipeline(items, ...stages) {
8843
8803
  () => stage(previous, item, index)
8844
8804
  );
8845
8805
  } catch (error) {
8846
- if (isFactoryFatalError(error)) {
8806
+ if (isWorkflowFatalError(error)) {
8847
8807
  throw error;
8848
8808
  }
8849
8809
  return null;
@@ -8853,85 +8813,6 @@ async function runWorkflowPipeline(items, ...stages) {
8853
8813
  })
8854
8814
  );
8855
8815
  }
8856
- var FactoryProgressBuffer = class {
8857
- constructor(send) {
8858
- this.send = send;
8859
- }
8860
- send;
8861
- nextSeq = 0;
8862
- pending = [];
8863
- flushTimer;
8864
- flushTail = Promise.resolve();
8865
- flushError;
8866
- flushFailed = false;
8867
- closed = false;
8868
- enqueue(kind, text) {
8869
- if (this.closed) {
8870
- throw new Error("Cannot log after the factory run has settled");
8871
- }
8872
- this.pending.push({ seq: this.nextSeq++, kind, text });
8873
- this.scheduleFlush();
8874
- }
8875
- async flush() {
8876
- this.clearFlushTimer();
8877
- const lines = this.pending.splice(0);
8878
- if (lines.length > 0) {
8879
- this.flushTail = this.flushTail.then(async () => {
8880
- try {
8881
- await this.send(lines);
8882
- } catch (error) {
8883
- if (!this.flushFailed) {
8884
- this.flushFailed = true;
8885
- this.flushError = error;
8886
- }
8887
- }
8888
- });
8889
- }
8890
- await this.flushTail;
8891
- if (this.flushFailed) {
8892
- throw this.flushError;
8893
- }
8894
- }
8895
- async close() {
8896
- this.closed = true;
8897
- this.clearFlushTimer();
8898
- const lines = this.pending.splice(0);
8899
- await this.flushTail;
8900
- if (this.flushFailed) {
8901
- console.warn(
8902
- "Ignoring a background factory progress flush failure after the factory body settled",
8903
- this.flushError
8904
- );
8905
- }
8906
- if (lines.length > 0) {
8907
- try {
8908
- await this.send(lines);
8909
- } catch (error) {
8910
- console.warn(
8911
- "Failed to flush final factory progress after the factory body settled",
8912
- error
8913
- );
8914
- }
8915
- }
8916
- }
8917
- scheduleFlush() {
8918
- if (this.flushTimer !== void 0) {
8919
- return;
8920
- }
8921
- this.flushTimer = setTimeout(() => {
8922
- this.flushTimer = void 0;
8923
- void this.flush().catch(() => {
8924
- });
8925
- }, FACTORY_LOG_FLUSH_DELAY_MS);
8926
- this.flushTimer.unref?.();
8927
- }
8928
- clearFlushTimer() {
8929
- if (this.flushTimer !== void 0) {
8930
- clearTimeout(this.flushTimer);
8931
- this.flushTimer = void 0;
8932
- }
8933
- }
8934
- };
8935
8816
  var WorkflowProgressBuffer = class {
8936
8817
  constructor(send) {
8937
8818
  this.send = send;
@@ -9011,38 +8892,30 @@ var WorkflowProgressBuffer = class {
9011
8892
  }
9012
8893
  }
9013
8894
  };
9014
- async function awaitFactoryOperation(operation, signal) {
8895
+ async function awaitWorkflowOperation(operation, signal) {
9015
8896
  let rejectAbort;
9016
8897
  const abortPromise = new Promise((_resolve, reject) => {
9017
8898
  rejectAbort = reject;
9018
8899
  });
9019
- const onAbort = () => rejectAbort?.(signal.reason ?? new DOMException("Factory run was aborted", "AbortError"));
8900
+ const onAbort = () => rejectAbort?.(signal.reason ?? new DOMException("Workflow run was aborted", "AbortError"));
9020
8901
  signal.addEventListener("abort", onAbort, { once: true });
9021
8902
  try {
9022
- throwIfFactoryAborted(signal);
8903
+ throwIfWorkflowAborted(signal);
9023
8904
  return await Promise.race([operation(), abortPromise]);
9024
8905
  } finally {
9025
8906
  signal.removeEventListener("abort", onAbort);
9026
8907
  }
9027
8908
  }
9028
- async function awaitWorkflowOperation(operation, signal) {
9029
- return awaitFactoryOperation(operation, signal);
9030
- }
9031
- function throwIfFactoryAborted(signal) {
9032
- if (signal.aborted) {
9033
- throw signal.reason ?? new DOMException("Factory run was aborted", "AbortError");
9034
- }
9035
- }
9036
8909
  function throwIfWorkflowAborted(signal) {
9037
8910
  if (signal.aborted) {
9038
8911
  throw signal.reason ?? new DOMException("Workflow run was aborted", "AbortError");
9039
8912
  }
9040
8913
  }
9041
- function isFactoryAbortError(error) {
8914
+ function isWorkflowAbortError(error) {
9042
8915
  return typeof error === "object" && error !== null && "name" in error && error.name === "AbortError";
9043
8916
  }
9044
- function isFactoryFatalError(error) {
9045
- return isFactoryAbortError(error) || error instanceof import_node.ResponseError || error instanceof import_node.ConnectionError;
8917
+ function isWorkflowFatalError(error) {
8918
+ return isWorkflowAbortError(error) || error instanceof import_node.ResponseError || error instanceof import_node.ConnectionError;
9046
8919
  }
9047
8920
  var TOOL_SEARCH_TOOL_NAME = "tool_search_tool";
9048
8921
  var CopilotSession = class {
@@ -9074,8 +8947,6 @@ var CopilotSession = class {
9074
8947
  canvases = /* @__PURE__ */ new Map();
9075
8948
  bearerTokenProviders = /* @__PURE__ */ new Map();
9076
8949
  commandHandlers = /* @__PURE__ */ new Map();
9077
- factories = /* @__PURE__ */ new Map();
9078
- factoryAbortControllers = /* @__PURE__ */ new Map();
9079
8950
  workflows = /* @__PURE__ */ new Map();
9080
8951
  workflowAbortControllers = /* @__PURE__ */ new Map();
9081
8952
  permissionHandler;
@@ -9093,74 +8964,17 @@ var CopilotSession = class {
9093
8964
  _capabilities = {};
9094
8965
  openCanvasInstances = [];
9095
8966
  disconnected = false;
9096
- pendingStructuredWaits = /* @__PURE__ */ new Set();
9097
- disconnecting = false;
9098
- onDisconnected;
9099
- /** @internal Client session API handlers, populated by CopilotClient during create/resume. */
9100
- clientSessionApis = {};
9101
- /**
9102
- * Friendly factory API for running registered factories by name or handle.
9103
- *
9104
- * @experimental Part of the experimental Agent Factories surface and may
9105
- * change or be removed in future SDK or CLI releases.
9106
- */
9107
- factory = {
9108
- run: (async (nameOrHandle, options) => {
9109
- throwIfFactoryExecutionIsActive();
9110
- const name = typeof nameOrHandle === "string" ? nameOrHandle : getFactoryDefinition(nameOrHandle).meta.name;
9111
- if (options?.resumeFromRunId !== void 0) {
9112
- return this.factory.resume(options.resumeFromRunId, {
9113
- limits: options.limits,
9114
- notifyOnComplete: options.notifyOnComplete,
9115
- logPhaseNames: options.logPhaseNames
9116
- });
9117
- }
9118
- const envelope = await this.rpc.factory.run({
9119
- name,
9120
- args: options?.args === void 0 ? {} : options.args,
9121
- options: {
9122
- limits: options?.limits,
9123
- notifyOnComplete: options?.notifyOnComplete,
9124
- logPhaseNames: options?.logPhaseNames
9125
- }
9126
- });
9127
- return this.settleFactoryRun(envelope);
9128
- }),
9129
- resume: (async (runId, options) => {
9130
- throwIfFactoryExecutionIsActive();
9131
- let response;
9132
- try {
9133
- response = await this.rpc.factory.resume({
9134
- runId,
9135
- limits: options?.limits,
9136
- notifyOnComplete: options?.notifyOnComplete,
9137
- logPhaseNames: options?.logPhaseNames
9138
- });
9139
- } catch (error) {
9140
- if (error instanceof import_node.ResponseError && typeof error.data === "object" && error.data !== null) {
9141
- const code = error.data.code;
9142
- if (isFactoryResumeErrorCode(code)) {
9143
- throw new FactoryResumeError(code, error.message);
9144
- }
9145
- }
9146
- throw error;
9147
- }
9148
- return this.settleFactoryRun(response.run);
9149
- }),
9150
- getRun: async (runId) => this.rpc.factory.getRun({ runId }),
9151
- waitForRun: (runId, options) => this.waitForFactoryRun(runId, options?.signal),
9152
- listRuns: (async (options) => {
9153
- const page = await this.rpc.factory.listRuns(options ?? {});
9154
- return options === void 0 ? page.runs : page;
9155
- }),
9156
- getRunDetail: (runId) => this.rpc.factory.getRunDetail({ runId }),
9157
- getRunProgress: (runId, options = {}) => this.rpc.factory.getRunProgress({ runId, ...options }),
9158
- pause: async (runId) => {
9159
- throwIfFactoryExecutionIsActive();
9160
- return this.rpc.factory.pause({ runId });
9161
- },
9162
- cancel: async (runId) => this.rpc.factory.cancel({ runId })
9163
- };
8967
+ pendingStructuredWaits = /* @__PURE__ */ new Set();
8968
+ disconnecting = false;
8969
+ onDisconnected;
8970
+ /** @internal Client session API handlers, populated by CopilotClient during create/resume. */
8971
+ clientSessionApis = {};
8972
+ /**
8973
+ * Friendly workflow API for running registered workflows by name or handle.
8974
+ *
8975
+ * @experimental Part of the experimental Dynamic Workflows surface and may
8976
+ * change or be removed in future SDK or CLI releases.
8977
+ */
9164
8978
  workflow = {
9165
8979
  run: (async (nameOrHandle, options) => {
9166
8980
  throwIfWorkflowExecutionIsActive();
@@ -9211,93 +9025,6 @@ var CopilotSession = class {
9211
9025
  },
9212
9026
  cancel: async (runId) => this.rpc.workflow.cancel({ runId })
9213
9027
  };
9214
- /**
9215
- * Resolve a start/resume envelope into the terminal envelope callers expect.
9216
- *
9217
- * The CLI may answer `session.factory.run` and `session.factory.resume`
9218
- * before the run settles, so a non-terminal envelope is followed by a wait
9219
- * on the run's terminal state.
9220
- */
9221
- settleFactoryRun(envelope) {
9222
- if (isFactoryRunTerminal(envelope.status)) {
9223
- return Promise.resolve(envelope);
9224
- }
9225
- return this.waitForFactoryRun(envelope.runId);
9226
- }
9227
- /**
9228
- * Resolve when a factory run reaches a terminal status.
9229
- *
9230
- * The subscription is installed *before* the first read so a transition
9231
- * landing between the two cannot be missed, and re-reads are serialized so
9232
- * overlapping invalidation events cannot interleave — the run's revision
9233
- * advances once per operation, so a burst of events is common and must
9234
- * collapse into a single in-flight read. A bounded periodic re-read keeps a
9235
- * dropped invalidation from leaving the wait pending forever.
9236
- */
9237
- waitForFactoryRun(runId, signal) {
9238
- const abortError = () => signal?.reason ?? new DOMException("Factory run wait was aborted", "AbortError");
9239
- if (signal?.aborted === true) {
9240
- return Promise.reject(abortError());
9241
- }
9242
- return new Promise((resolve3, reject) => {
9243
- let settled = false;
9244
- let reading = false;
9245
- let rereadRequested = false;
9246
- let pollHandle;
9247
- let unsubscribe;
9248
- let onAbort;
9249
- const finish = (complete) => {
9250
- if (settled) {
9251
- return;
9252
- }
9253
- settled = true;
9254
- if (pollHandle !== void 0) {
9255
- clearInterval(pollHandle);
9256
- }
9257
- unsubscribe?.();
9258
- if (onAbort !== void 0) {
9259
- signal?.removeEventListener("abort", onAbort);
9260
- }
9261
- complete();
9262
- };
9263
- const read = async () => {
9264
- if (settled) {
9265
- return;
9266
- }
9267
- if (reading) {
9268
- rereadRequested = true;
9269
- return;
9270
- }
9271
- reading = true;
9272
- try {
9273
- do {
9274
- rereadRequested = false;
9275
- const envelope = await this.rpc.factory.getRun({ runId });
9276
- if (isFactoryRunTerminal(envelope.status)) {
9277
- finish(() => resolve3(envelope));
9278
- return;
9279
- }
9280
- } while (rereadRequested && !settled);
9281
- } catch (error) {
9282
- finish(() => reject(error));
9283
- } finally {
9284
- reading = false;
9285
- }
9286
- };
9287
- if (signal !== void 0) {
9288
- onAbort = () => finish(() => reject(abortError()));
9289
- signal.addEventListener("abort", onAbort, { once: true });
9290
- }
9291
- unsubscribe = this.on("factory.run_updated", (event) => {
9292
- if (event.data.runId === runId) {
9293
- void read();
9294
- }
9295
- });
9296
- pollHandle = setInterval(() => void read(), 5e3);
9297
- pollHandle.unref?.();
9298
- void read();
9299
- });
9300
- }
9301
9028
  settleWorkflowRun(envelope) {
9302
9029
  if (isWorkflowRunTerminal(envelope.status)) {
9303
9030
  return Promise.resolve(envelope);
@@ -9368,7 +9095,7 @@ var CopilotSession = class {
9368
9095
  onAbort = () => finish(() => reject(abortError()));
9369
9096
  signal.addEventListener("abort", onAbort, { once: true });
9370
9097
  }
9371
- unsubscribe = this.on("factory.run_updated", (event) => {
9098
+ unsubscribe = this.on("workflow.run_updated", (event) => {
9372
9099
  if (event.data.runId === runId) {
9373
9100
  void read();
9374
9101
  }
@@ -9494,6 +9221,7 @@ var CopilotSession = class {
9494
9221
  });
9495
9222
  let lastAssistantMessage;
9496
9223
  const unsubscribe = this.on((event) => {
9224
+ if (event.agentId) return;
9497
9225
  if (event.type === "assistant.message") {
9498
9226
  lastAssistantMessage = event;
9499
9227
  } else if (event.type === "session.idle" && event.data.mode !== "autopilot") {
@@ -9633,13 +9361,6 @@ var CopilotSession = class {
9633
9361
  this.autoModeSwitchHandler = void 0;
9634
9362
  this.commandHandlers.clear();
9635
9363
  this.canvases.clear();
9636
- this.factories.clear();
9637
- for (const controllersForRun of this.factoryAbortControllers.values()) {
9638
- for (const controller of controllersForRun.values()) {
9639
- controller.abort();
9640
- }
9641
- }
9642
- this.factoryAbortControllers.clear();
9643
9364
  this.workflows.clear();
9644
9365
  for (const controllersForRun of this.workflowAbortControllers.values()) {
9645
9366
  for (const controller of controllersForRun.values()) {
@@ -10094,192 +9815,6 @@ var CopilotSession = class {
10094
9815
  }
10095
9816
  };
10096
9817
  }
10097
- /**
10098
- * Registers factory closures and reverse-RPC handlers for this session.
10099
- *
10100
- * @param factories - Factory handles declared by the joining extension.
10101
- * @internal Called by the SDK when an extension joins a session.
10102
- */
10103
- registerFactories(factories) {
10104
- this.factories.clear();
10105
- if (!factories || factories.length === 0) {
10106
- delete this.clientSessionApis.factory;
10107
- return;
10108
- }
10109
- for (const handle of factories) {
10110
- const definition = getFactoryDefinition(handle);
10111
- if (this.factories.has(definition.meta.name)) {
10112
- throw new Error(
10113
- `Duplicate factory name "${definition.meta.name}". Factory names must be unique within a joinSession call.`
10114
- );
10115
- }
10116
- this.factories.set(definition.meta.name, definition);
10117
- }
10118
- const self = this;
10119
- this.clientSessionApis.factory = {
10120
- async execute(params) {
10121
- const definition = self.factories.get(params.name);
10122
- if (!definition) {
10123
- const message = `No factory registered with name "${params.name}"`;
10124
- throw new import_node.ResponseError(import_node.ErrorCodes.InvalidParams, message, {
10125
- code: "factory_not_found",
10126
- name: params.name
10127
- });
10128
- }
10129
- const controller = new AbortController();
10130
- let controllersForRun = self.factoryAbortControllers.get(params.runId);
10131
- if (controllersForRun === void 0) {
10132
- controllersForRun = /* @__PURE__ */ new Map();
10133
- self.factoryAbortControllers.set(params.runId, controllersForRun);
10134
- }
10135
- controllersForRun.set(params.executionToken, controller);
10136
- const progress = new FactoryProgressBuffer(async (lines) => {
10137
- await self.rpc.factory.log({
10138
- runId: params.runId,
10139
- executionToken: params.executionToken,
10140
- lines
10141
- });
10142
- });
10143
- try {
10144
- const context = {
10145
- runId: params.runId,
10146
- args: params.args,
10147
- session: self,
10148
- signal: controller.signal,
10149
- phase: (title) => {
10150
- throwIfFactoryAborted(controller.signal);
10151
- progress.enqueue("phase", title);
10152
- },
10153
- log: (message) => {
10154
- throwIfFactoryAborted(controller.signal);
10155
- progress.enqueue("log", message);
10156
- },
10157
- agent: async (prompt, options = {}) => {
10158
- await progress.flush();
10159
- const opts = {};
10160
- for (const key of FACTORY_AGENT_OPTION_KEYS) {
10161
- copyDefinedFactoryAgentOption(options, opts, key);
10162
- }
10163
- const response = await awaitFactoryOperation(
10164
- () => self.rpc.factory.agent({
10165
- factoryRunId: params.runId,
10166
- executionToken: params.executionToken,
10167
- prompt,
10168
- opts
10169
- }),
10170
- controller.signal
10171
- );
10172
- return response.result ?? null;
10173
- },
10174
- step: async (key, producer, options = {}) => {
10175
- await progress.flush();
10176
- if (options.volatile) {
10177
- throwIfFactoryAborted(controller.signal);
10178
- return producer();
10179
- }
10180
- const cached = await awaitFactoryOperation(
10181
- () => self.rpc.factory.journal.get({
10182
- runId: params.runId,
10183
- executionToken: params.executionToken,
10184
- key
10185
- }),
10186
- controller.signal
10187
- );
10188
- if (cached.hit) {
10189
- if (cached.resultJson === void 0) {
10190
- throw new Error(
10191
- `step("${key}") journal returned a hit without a result`
10192
- );
10193
- }
10194
- assertFactoryStepResult(cached.resultJson, key);
10195
- return cached.resultJson;
10196
- }
10197
- const result2 = await producer();
10198
- assertFactoryStepResult(result2, key);
10199
- await awaitFactoryOperation(
10200
- () => self.rpc.factory.journal.put({
10201
- runId: params.runId,
10202
- executionToken: params.executionToken,
10203
- key,
10204
- resultJson: result2
10205
- }),
10206
- controller.signal
10207
- );
10208
- return result2;
10209
- },
10210
- pause: async (key) => {
10211
- if (typeof key !== "string" || key.length === 0) {
10212
- throw new Error("Factory pause checkpoint key must not be empty");
10213
- }
10214
- const helperScope = factoryExecutionStore.getStore()?.helperScope;
10215
- if (helperScope !== void 0) {
10216
- throw new Error(
10217
- `Factory pause checkpoints are not allowed inside ${helperScope}() branches`
10218
- );
10219
- }
10220
- await progress.flush();
10221
- const response = await awaitFactoryOperation(
10222
- () => self.internalRpc.factory.pauseAtCheckpoint({
10223
- runId: params.runId,
10224
- executionToken: params.executionToken,
10225
- key
10226
- }),
10227
- controller.signal
10228
- );
10229
- switch (response.action) {
10230
- case "continue":
10231
- return;
10232
- case "pause":
10233
- await awaitFactoryOperation(
10234
- () => new Promise(() => {
10235
- }),
10236
- controller.signal
10237
- );
10238
- }
10239
- },
10240
- parallel: runFactoryParallel,
10241
- pipeline: runFactoryPipeline,
10242
- factory: async () => {
10243
- throw new Error("nested factories are not supported");
10244
- }
10245
- };
10246
- const execution = { active: true };
10247
- const result = await factoryExecutionStore.run(execution, async () => {
10248
- try {
10249
- return await definition.run(context);
10250
- } finally {
10251
- execution.active = false;
10252
- }
10253
- });
10254
- if (result === void 0) {
10255
- return {};
10256
- }
10257
- assertFactoryResult(result);
10258
- return { result };
10259
- } finally {
10260
- try {
10261
- await progress.close();
10262
- } finally {
10263
- const controllersForRun2 = self.factoryAbortControllers.get(params.runId);
10264
- if (controllersForRun2?.get(params.executionToken) === controller) {
10265
- controllersForRun2.delete(params.executionToken);
10266
- if (controllersForRun2.size === 0) {
10267
- self.factoryAbortControllers.delete(params.runId);
10268
- }
10269
- }
10270
- }
10271
- }
10272
- },
10273
- async abort(params) {
10274
- const controllersForRun = self.factoryAbortControllers.get(params.runId);
10275
- const controller = controllersForRun?.get(params.executionToken);
10276
- if (controller !== void 0) {
10277
- controller.abort(new DOMException("Factory run was aborted", "AbortError"));
10278
- }
10279
- return {};
10280
- }
10281
- };
10282
- }
10283
9818
  /**
10284
9819
  * Registers workflow closures and reverse-RPC handlers for this session.
10285
9820
  *
@@ -11146,20 +10681,6 @@ function assertStrictJson(value, context) {
11146
10681
  };
11147
10682
  visit(value, "$", context.allowTopLevelUndefined);
11148
10683
  }
11149
- function assertFactoryResult(value) {
11150
- assertStrictJson(value, {
11151
- code: "factory_result_not_json",
11152
- label: "Factory result",
11153
- allowTopLevelUndefined: true
11154
- });
11155
- }
11156
- function assertFactoryStepResult(value, key) {
11157
- assertStrictJson(value, {
11158
- code: "factory_step_not_json",
11159
- label: `Factory step "${key}" result`,
11160
- allowTopLevelUndefined: false
11161
- });
11162
- }
11163
10684
  function assertWorkflowResult(value) {
11164
10685
  assertStrictJson(value, {
11165
10686
  code: "workflow_result_not_json",
@@ -11390,6 +10911,79 @@ async function ensureRuntimeBundle(version2, options = {}) {
11390
10911
  return wrapper;
11391
10912
  }
11392
10913
 
10914
+ // src/sdk/nodejs/dist/installationConfirmation.js
10915
+ var import_node2 = __toESM(require_node(), 1);
10916
+ function createInstallationConfirmationAdapter(connection, handler) {
10917
+ const closed = new import_node2.CancellationTokenSource();
10918
+ const closeSubscription = connection.onClose(() => closed.cancel());
10919
+ const disposeSubscription = connection.onDispose(() => {
10920
+ closed.cancel();
10921
+ closed.dispose();
10922
+ closeSubscription.dispose();
10923
+ disposeSubscription.dispose();
10924
+ });
10925
+ return {
10926
+ async confirm(request, token) {
10927
+ if (!token) {
10928
+ throw new Error("Installation confirmation request cancellation is unavailable");
10929
+ }
10930
+ const { confirmationId, reviewFingerprint } = request;
10931
+ const combined = new import_node2.CancellationTokenSource();
10932
+ const subscriptions = [];
10933
+ const cancelRequest = () => combined.cancel();
10934
+ const cancelConnection = () => combined.cancel();
10935
+ const checkCancellation = () => {
10936
+ if (closed.token.isCancellationRequested) {
10937
+ throw new Error("Installation confirmation connection closed");
10938
+ }
10939
+ if (token.isCancellationRequested) {
10940
+ throw new import_node2.ResponseError(-32800, "Installation confirmation request cancelled");
10941
+ }
10942
+ };
10943
+ try {
10944
+ subscriptions.push(
10945
+ token.onCancellationRequested(cancelRequest),
10946
+ closed.token.onCancellationRequested(cancelConnection)
10947
+ );
10948
+ if (token.isCancellationRequested || closed.token.isCancellationRequested) {
10949
+ combined.cancel();
10950
+ }
10951
+ checkCancellation();
10952
+ const cancelled = new Promise((_resolve, reject) => {
10953
+ subscriptions.push(
10954
+ token.onCancellationRequested(
10955
+ () => reject(
10956
+ new import_node2.ResponseError(
10957
+ -32800,
10958
+ "Installation confirmation request cancelled"
10959
+ )
10960
+ )
10961
+ ),
10962
+ closed.token.onCancellationRequested(
10963
+ () => reject(new Error("Installation confirmation connection closed"))
10964
+ )
10965
+ );
10966
+ });
10967
+ const decision = await Promise.race([
10968
+ Promise.resolve().then(() => {
10969
+ checkCancellation();
10970
+ return handler(request, combined.token);
10971
+ }),
10972
+ cancelled
10973
+ ]);
10974
+ checkCancellation();
10975
+ if (decision !== "confirm" && decision !== "decline" && decision !== "cancel") {
10976
+ throw new Error("Invalid installation confirmation decision");
10977
+ }
10978
+ return { confirmationId, reviewFingerprint, decision };
10979
+ } finally {
10980
+ for (const subscription of subscriptions) subscription.dispose();
10981
+ combined.dispose();
10982
+ }
10983
+ }
10984
+ };
10985
+ }
10986
+
11393
10987
  // src/sdk/nodejs/dist/toolSet.js
11394
10988
  var VALID_TOOL_NAME = /^[a-zA-Z0-9_-]+$/;
11395
10989
  function validateName(kind, name) {
@@ -11632,7 +11226,7 @@ function getNodeExecPath() {
11632
11226
  function getBundledRuntimePath() {
11633
11227
  return ensureRuntimeBundle(COPILOT_CLI_VERSION);
11634
11228
  }
11635
- var TeardownResilientStreamMessageWriter = class extends import_node2.StreamMessageWriter {
11229
+ var TeardownResilientStreamMessageWriter = class extends import_node3.StreamMessageWriter {
11636
11230
  suppressWriteErrors = false;
11637
11231
  async write(msg) {
11638
11232
  try {
@@ -11688,6 +11282,7 @@ var CopilotClient = class _CopilotClient {
11688
11282
  sessionFsConfig = null;
11689
11283
  requestHandler = null;
11690
11284
  extensionLaunchProvider;
11285
+ installationConfirmationHandler;
11691
11286
  builtinPluginDirectories = [];
11692
11287
  onGitHubTelemetry;
11693
11288
  clientGlobalHandlers = {};
@@ -11846,6 +11441,7 @@ var CopilotClient = class _CopilotClient {
11846
11441
  this.sessionFsConfig = options.sessionFs ?? null;
11847
11442
  this.requestHandler = options.requestHandler ?? null;
11848
11443
  this.extensionLaunchProvider = options.extensionLaunchProvider;
11444
+ this.installationConfirmationHandler = options.installationConfirmationHandler;
11849
11445
  this.onGitHubTelemetry = options.onGitHubTelemetry;
11850
11446
  this.setupClientGlobalHandlers();
11851
11447
  const connEnv = conn.kind === "stdio" || conn.kind === "tcp" ? conn.env : void 0;
@@ -12660,6 +12256,7 @@ var CopilotClient = class _CopilotClient {
12660
12256
  includeSubAgentStreamingEvents: config.includeSubAgentStreamingEvents ?? true,
12661
12257
  ...this.onGitHubTelemetry != null ? { enableGitHubTelemetryForwarding: true } : {},
12662
12258
  mcpServers: toWireMcpServers(config.mcpServers),
12259
+ ...config.diagnostics !== void 0 ? { diagnostics: config.diagnostics } : {},
12663
12260
  mcpOAuthTokenStorage: config.mcpOAuthTokenStorage,
12664
12261
  authClientIdMetadataUrl: config.authClientIdMetadataUrl,
12665
12262
  envValueMode: "direct",
@@ -12669,6 +12266,7 @@ var CopilotClient = class _CopilotClient {
12669
12266
  agent: config.agent,
12670
12267
  configDir: config.configDirectory,
12671
12268
  enableConfigDiscovery: config.enableConfigDiscovery,
12269
+ refreshCustomInstructions: config.refreshCustomInstructions,
12672
12270
  skipEmbeddingRetrieval: config.skipEmbeddingRetrieval,
12673
12271
  embeddingCacheStorage: config.embeddingCacheStorage,
12674
12272
  organizationCustomInstructions: config.organizationCustomInstructions,
@@ -12760,14 +12358,12 @@ var CopilotClient = class _CopilotClient {
12760
12358
  async resumeSession(sessionId, config) {
12761
12359
  return this.resumeSessionInternal(sessionId, config);
12762
12360
  }
12361
+ /** @internal */
12763
12362
  async resumeSessionForExtension(sessionId, config, contributions = {}, extensionOptions) {
12764
12363
  return this.resumeSessionInternal(sessionId, config, contributions, extensionOptions);
12765
12364
  }
12766
12365
  async resumeSessionInternal(sessionId, config, contributions = {}, extensionOptions) {
12767
- const { factories, workflows } = Array.isArray(contributions) ? { factories: contributions, workflows: void 0 } : contributions;
12768
- if (factories !== void 0 && workflows !== void 0) {
12769
- throw new Error("Session configuration cannot include both factories and workflows");
12770
- }
12366
+ const { workflows } = contributions;
12771
12367
  if (config.gitHubToken !== void 0 && config.gitHubTokenProvider !== void 0) {
12772
12368
  throw new Error("gitHubToken and gitHubTokenProvider are mutually exclusive");
12773
12369
  }
@@ -12787,7 +12383,6 @@ var CopilotClient = class _CopilotClient {
12787
12383
  session.registerTools(config.tools);
12788
12384
  session.registerCanvases(config.canvases);
12789
12385
  session.registerCommands(config.commands);
12790
- session.registerFactories(factories);
12791
12386
  session.registerWorkflows(workflows);
12792
12387
  const {
12793
12388
  wireProvider: bearerWireProvider,
@@ -12869,7 +12464,6 @@ var CopilotClient = class _CopilotClient {
12869
12464
  })),
12870
12465
  toolSearch: config.toolSearch,
12871
12466
  canvases: config.canvases?.map((canvas) => canvas.declaration),
12872
- factories: factories?.map((factory) => factory.meta),
12873
12467
  workflows: workflows?.map((workflow) => workflow.meta),
12874
12468
  requestCanvasRenderer: config.requestCanvasRenderer,
12875
12469
  requestExtensions: config.requestExtensions,
@@ -12911,6 +12505,7 @@ var CopilotClient = class _CopilotClient {
12911
12505
  includeSubAgentStreamingEvents: config.includeSubAgentStreamingEvents ?? true,
12912
12506
  ...this.onGitHubTelemetry != null ? { enableGitHubTelemetryForwarding: true } : {},
12913
12507
  mcpServers: toWireMcpServers(config.mcpServers),
12508
+ ...config.diagnostics !== void 0 ? { diagnostics: config.diagnostics } : {},
12914
12509
  mcpOAuthTokenStorage: config.mcpOAuthTokenStorage,
12915
12510
  authClientIdMetadataUrl: config.authClientIdMetadataUrl,
12916
12511
  envValueMode: "direct",
@@ -13091,7 +12686,7 @@ var CopilotClient = class _CopilotClient {
13091
12686
  const result = await raceAgainstExit(this.internalRpc.connect(connectParams));
13092
12687
  serverVersion = result.protocolVersion;
13093
12688
  } catch (err) {
13094
- if (err instanceof import_node2.ResponseError && (err.code === import_node2.ErrorCodes.MethodNotFound || err.message === "Unhandled method connect")) {
12689
+ if (err instanceof import_node3.ResponseError && (err.code === import_node3.ErrorCodes.MethodNotFound || err.message === "Unhandled method connect")) {
13095
12690
  serverVersion = (await raceAgainstExit(this.ping())).protocolVersion;
13096
12691
  } else {
13097
12692
  throw err;
@@ -13331,6 +12926,9 @@ var CopilotClient = class _CopilotClient {
13331
12926
  if (this.options.mode === "empty") {
13332
12927
  env.COPILOT_DISABLE_KEYTAR = "1";
13333
12928
  }
12929
+ if (this.options.mode !== "empty") {
12930
+ env.COPILOT_RUNTIME_PROCESS_FILE_LOGGING = "1";
12931
+ }
13334
12932
  if (this.options.telemetry) {
13335
12933
  const t = this.options.telemetry;
13336
12934
  env.COPILOT_OTEL_ENABLED = "true";
@@ -13566,8 +13164,8 @@ stderr: ${stderrOutput}`
13566
13164
  throw new Error("In-process FFI runtime host not started");
13567
13165
  }
13568
13166
  this.messageWriter = new TeardownResilientStreamMessageWriter(this.ffiHost.sendStream);
13569
- this.connection = (0, import_node2.createMessageConnection)(
13570
- new import_node2.StreamMessageReader(this.ffiHost.receiveStream),
13167
+ this.connection = (0, import_node3.createMessageConnection)(
13168
+ new import_node3.StreamMessageReader(this.ffiHost.receiveStream),
13571
13169
  this.messageWriter
13572
13170
  );
13573
13171
  this.attachConnectionHandlers();
@@ -13620,8 +13218,8 @@ stderr: ${stderrOutput}` : ""}`
13620
13218
  }
13621
13219
  });
13622
13220
  this.messageWriter = new TeardownResilientStreamMessageWriter(this.cliProcess.stdin);
13623
- this.connection = (0, import_node2.createMessageConnection)(
13624
- new import_node2.StreamMessageReader(this.cliProcess.stdout),
13221
+ this.connection = (0, import_node3.createMessageConnection)(
13222
+ new import_node3.StreamMessageReader(this.cliProcess.stdout),
13625
13223
  this.messageWriter
13626
13224
  );
13627
13225
  this.attachConnectionHandlers();
@@ -13635,8 +13233,8 @@ stderr: ${stderrOutput}` : ""}`
13635
13233
  throw new Error("CLI child process was unexpectedly started in parent process mode");
13636
13234
  }
13637
13235
  this.messageWriter = new TeardownResilientStreamMessageWriter(process.stdout);
13638
- this.connection = (0, import_node2.createMessageConnection)(
13639
- new import_node2.StreamMessageReader(process.stdin),
13236
+ this.connection = (0, import_node3.createMessageConnection)(
13237
+ new import_node3.StreamMessageReader(process.stdin),
13640
13238
  this.messageWriter
13641
13239
  );
13642
13240
  this.attachConnectionHandlers();
@@ -13658,8 +13256,8 @@ stderr: ${stderrOutput}` : ""}`
13658
13256
  this.socket.connect(this.runtimePort, this.actualHost, () => {
13659
13257
  clearTimeout(connectionTimeout);
13660
13258
  this.messageWriter = new TeardownResilientStreamMessageWriter(this.socket);
13661
- this.connection = (0, import_node2.createMessageConnection)(
13662
- new import_node2.StreamMessageReader(this.socket),
13259
+ this.connection = (0, import_node3.createMessageConnection)(
13260
+ new import_node3.StreamMessageReader(this.socket),
13663
13261
  this.messageWriter
13664
13262
  );
13665
13263
  this.attachConnectionHandlers();
@@ -13705,6 +13303,16 @@ stderr: ${stderrOutput}` : ""}`
13705
13303
  return session.clientSessionApis;
13706
13304
  });
13707
13305
  registerClientGlobalApiHandlers(this.connection, this.clientGlobalHandlers);
13306
+ if (this.installationConfirmationHandler) {
13307
+ const confirmation = createInstallationConfirmationAdapter(
13308
+ this.connection,
13309
+ this.installationConfirmationHandler
13310
+ );
13311
+ this.connection.onRequest(
13312
+ "installations.confirm",
13313
+ (params, token) => confirmation.confirm(params, token)
13314
+ );
13315
+ }
13708
13316
  this.connection.onRequest(
13709
13317
  "hooks.invoke",
13710
13318
  async (params) => {
@@ -13853,7 +13461,6 @@ export {
13853
13461
  CopilotWebSocketForwarder,
13854
13462
  CopilotWebSocketHandler,
13855
13463
  DisableBypassPermissionsModes,
13856
- FactoryResumeError,
13857
13464
  RuntimeConnection,
13858
13465
  SYSTEM_MESSAGE_SECTIONS,
13859
13466
  SessionFsSqliteTransactionFailure,
@@ -13864,9 +13471,7 @@ export {
13864
13471
  createAttributedPermissionResult,
13865
13472
  createCanvas,
13866
13473
  createSessionFsAdapter,
13867
- defineFactory,
13868
13474
  defineTool,
13869
13475
  defineWorkflow,
13870
- isFactoryRunTerminal,
13871
13476
  isWorkflowRunTerminal
13872
13477
  };