@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.
- package/copilot-sdk/client.d.ts +1 -0
- package/copilot-sdk/docs/extensions.md +0 -1
- package/copilot-sdk/docs/workflows.md +2 -4
- package/copilot-sdk/extension.d.ts +10 -24
- package/copilot-sdk/extension.js +454 -853
- package/copilot-sdk/generated/rpc.d.ts +4455 -2788
- package/copilot-sdk/generated/session-events.d.ts +211 -120
- package/copilot-sdk/index.d.ts +2 -4
- package/copilot-sdk/index.js +454 -849
- package/copilot-sdk/installationConfirmation.d.ts +19 -0
- package/copilot-sdk/session.d.ts +3 -25
- package/copilot-sdk/types.d.ts +31 -66
- package/copilot-sdk/workflow.d.ts +5 -2
- package/package.json +1 -1
- package/prebuilds/win32-x64/OneAuthInterop.dll +0 -0
- package/prebuilds/win32-x64/copilot-runtime.exe +0 -0
- package/prebuilds/win32-x64/runtime.node +2 -2
- package/ripgrep/bin/win32-x64/rg.exe +0 -0
- package/schemas/api.schema.json +11116 -8682
- package/schemas/session-events.schema.json +998 -818
- package/tgrep/bin/win32-x64/tgrep.exe +0 -0
- package/copilot-sdk/docs/factories.md +0 -296
- package/copilot-sdk/docs/factory-patterns.md +0 -194
- package/copilot-sdk/factory.d.ts +0 -327
- package/prebuilds/win32-x64/msal-node-runtime.node +0 -0
- package/prebuilds/win32-x64/msalruntime.dll +0 -0
package/copilot-sdk/extension.js
CHANGED
|
@@ -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
|
|
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 =
|
|
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
|
|
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 =
|
|
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
|
|
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
|
-
*
|
|
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
|
-
|
|
5992
|
+
diagnostics: {
|
|
5852
5993
|
/**
|
|
5853
|
-
*
|
|
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
|
-
* @
|
|
5996
|
+
* @param params Patch session diagnostic thresholds for explicitly supplied sources.
|
|
5997
|
+
*
|
|
5998
|
+
* @returns Per-source session diagnostics configuration.
|
|
5856
5999
|
*/
|
|
5857
|
-
|
|
6000
|
+
configure: async (params) => connection.sendRequest("session.diagnostics.configure", { sessionId, ...params }),
|
|
5858
6001
|
/**
|
|
5859
|
-
*
|
|
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
|
-
* @
|
|
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
|
|
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,
|
|
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
|
|
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
|
|
@@ -8355,107 +8485,6 @@ var defaultJoinSessionPermissionHandler = () => ({
|
|
|
8355
8485
|
kind: "no-result"
|
|
8356
8486
|
});
|
|
8357
8487
|
|
|
8358
|
-
// src/sdk/nodejs/dist/factory.js
|
|
8359
|
-
var FACTORY_TERMINAL_STATUSES = /* @__PURE__ */ new Set([
|
|
8360
|
-
"completed",
|
|
8361
|
-
"halted",
|
|
8362
|
-
"paused",
|
|
8363
|
-
"cancelled",
|
|
8364
|
-
"error"
|
|
8365
|
-
]);
|
|
8366
|
-
function isFactoryRunTerminal(status) {
|
|
8367
|
-
return FACTORY_TERMINAL_STATUSES.has(status);
|
|
8368
|
-
}
|
|
8369
|
-
var FACTORY_AGENT_OPTION_KEYS = [
|
|
8370
|
-
"label",
|
|
8371
|
-
"schema",
|
|
8372
|
-
"model",
|
|
8373
|
-
"reasoningEffort",
|
|
8374
|
-
"contextTier",
|
|
8375
|
-
"agent"
|
|
8376
|
-
];
|
|
8377
|
-
var FactoryResumeError = class extends Error {
|
|
8378
|
-
constructor(code, message) {
|
|
8379
|
-
super(message);
|
|
8380
|
-
this.code = code;
|
|
8381
|
-
this.name = "FactoryResumeError";
|
|
8382
|
-
}
|
|
8383
|
-
code;
|
|
8384
|
-
};
|
|
8385
|
-
var factoryHandles = /* @__PURE__ */ new WeakMap();
|
|
8386
|
-
var MAX_FACTORY_TIMEOUT_SECONDS = 2147483647e-3;
|
|
8387
|
-
var NANO_AIU_PER_AIU = 1e9;
|
|
8388
|
-
function deepFreeze(value) {
|
|
8389
|
-
if (value !== null && typeof value === "object" && !Object.isFrozen(value)) {
|
|
8390
|
-
Object.freeze(value);
|
|
8391
|
-
for (const nested of Object.values(value)) {
|
|
8392
|
-
deepFreeze(nested);
|
|
8393
|
-
}
|
|
8394
|
-
}
|
|
8395
|
-
return value;
|
|
8396
|
-
}
|
|
8397
|
-
function validateLimits(meta) {
|
|
8398
|
-
const limits = meta.limits;
|
|
8399
|
-
if (!limits) {
|
|
8400
|
-
return;
|
|
8401
|
-
}
|
|
8402
|
-
for (const field of ["maxConcurrentSubagents", "maxTotalSubagents"]) {
|
|
8403
|
-
const value = limits[field];
|
|
8404
|
-
if (value !== void 0 && (!Number.isInteger(value) || value <= 0)) {
|
|
8405
|
-
throw new Error(`Factory limit "${field}" must be a positive integer`);
|
|
8406
|
-
}
|
|
8407
|
-
}
|
|
8408
|
-
if (limits.timeoutSeconds !== void 0 && (!Number.isFinite(limits.timeoutSeconds) || limits.timeoutSeconds <= 0)) {
|
|
8409
|
-
throw new Error(
|
|
8410
|
-
'Factory limit "timeoutSeconds" must be a positive, finite number of seconds'
|
|
8411
|
-
);
|
|
8412
|
-
}
|
|
8413
|
-
if (limits.timeoutSeconds !== void 0 && limits.timeoutSeconds > MAX_FACTORY_TIMEOUT_SECONDS) {
|
|
8414
|
-
throw new Error(
|
|
8415
|
-
`Factory limit "timeoutSeconds" must not exceed ${MAX_FACTORY_TIMEOUT_SECONDS} seconds`
|
|
8416
|
-
);
|
|
8417
|
-
}
|
|
8418
|
-
if (limits.maxAiCredits !== void 0) {
|
|
8419
|
-
const maxNanoAiu = Math.round(limits.maxAiCredits * NANO_AIU_PER_AIU);
|
|
8420
|
-
if (!Number.isFinite(limits.maxAiCredits) || limits.maxAiCredits <= 0 || !Number.isSafeInteger(maxNanoAiu) || maxNanoAiu < 1) {
|
|
8421
|
-
throw new Error(
|
|
8422
|
-
'Factory limit "maxAiCredits" must be a positive, finite number that rounds to a safe positive integer nano-AIU ceiling'
|
|
8423
|
-
);
|
|
8424
|
-
}
|
|
8425
|
-
}
|
|
8426
|
-
}
|
|
8427
|
-
function validatePhases(meta) {
|
|
8428
|
-
const titles = /* @__PURE__ */ new Set();
|
|
8429
|
-
for (const phase of meta.phases) {
|
|
8430
|
-
if (phase.title.trim().length === 0) {
|
|
8431
|
-
throw new Error("Factory phase titles must not be empty");
|
|
8432
|
-
}
|
|
8433
|
-
if (titles.has(phase.title)) {
|
|
8434
|
-
throw new Error(`Factory phase title "${phase.title}" is declared more than once`);
|
|
8435
|
-
}
|
|
8436
|
-
titles.add(phase.title);
|
|
8437
|
-
}
|
|
8438
|
-
}
|
|
8439
|
-
function defineFactory(definition) {
|
|
8440
|
-
const meta = deepFreeze(structuredClone(definition.meta));
|
|
8441
|
-
validateLimits(meta);
|
|
8442
|
-
validatePhases(meta);
|
|
8443
|
-
const stored = {
|
|
8444
|
-
meta,
|
|
8445
|
-
run: definition.run
|
|
8446
|
-
};
|
|
8447
|
-
const handle = Object.freeze({ meta });
|
|
8448
|
-
factoryHandles.set(handle, stored);
|
|
8449
|
-
return handle;
|
|
8450
|
-
}
|
|
8451
|
-
function getFactoryDefinition(handle) {
|
|
8452
|
-
const definition = factoryHandles.get(handle);
|
|
8453
|
-
if (!definition) {
|
|
8454
|
-
throw new Error("Invalid factory handle");
|
|
8455
|
-
}
|
|
8456
|
-
return definition;
|
|
8457
|
-
}
|
|
8458
|
-
|
|
8459
8488
|
// src/sdk/nodejs/dist/workflow.js
|
|
8460
8489
|
var WORKFLOW_TERMINAL_STATUSES = /* @__PURE__ */ new Set([
|
|
8461
8490
|
"completed",
|
|
@@ -8485,17 +8514,17 @@ var WorkflowResumeError = class extends Error {
|
|
|
8485
8514
|
};
|
|
8486
8515
|
var workflowHandles = /* @__PURE__ */ new WeakMap();
|
|
8487
8516
|
var MAX_WORKFLOW_TIMEOUT_SECONDS = 2147483647e-3;
|
|
8488
|
-
var
|
|
8489
|
-
function
|
|
8517
|
+
var NANO_AIU_PER_AIU = 1e9;
|
|
8518
|
+
function deepFreeze(value) {
|
|
8490
8519
|
if (value !== null && typeof value === "object" && !Object.isFrozen(value)) {
|
|
8491
8520
|
Object.freeze(value);
|
|
8492
8521
|
for (const nested of Object.values(value)) {
|
|
8493
|
-
|
|
8522
|
+
deepFreeze(nested);
|
|
8494
8523
|
}
|
|
8495
8524
|
}
|
|
8496
8525
|
return value;
|
|
8497
8526
|
}
|
|
8498
|
-
function
|
|
8527
|
+
function validateLimits(meta) {
|
|
8499
8528
|
const limits = meta.limits;
|
|
8500
8529
|
if (!limits) {
|
|
8501
8530
|
return;
|
|
@@ -8517,7 +8546,7 @@ function validateLimits2(meta) {
|
|
|
8517
8546
|
);
|
|
8518
8547
|
}
|
|
8519
8548
|
if (limits.maxAiCredits !== void 0) {
|
|
8520
|
-
const maxNanoAiu = Math.round(limits.maxAiCredits *
|
|
8549
|
+
const maxNanoAiu = Math.round(limits.maxAiCredits * NANO_AIU_PER_AIU);
|
|
8521
8550
|
if (!Number.isFinite(limits.maxAiCredits) || limits.maxAiCredits <= 0 || !Number.isSafeInteger(maxNanoAiu) || maxNanoAiu < 1) {
|
|
8522
8551
|
throw new Error(
|
|
8523
8552
|
'Workflow limit "maxAiCredits" must be a positive, finite number that rounds to a safe positive integer nano-AIU ceiling'
|
|
@@ -8525,7 +8554,7 @@ function validateLimits2(meta) {
|
|
|
8525
8554
|
}
|
|
8526
8555
|
}
|
|
8527
8556
|
}
|
|
8528
|
-
function
|
|
8557
|
+
function validatePhases(meta) {
|
|
8529
8558
|
const titles = /* @__PURE__ */ new Set();
|
|
8530
8559
|
for (const phase of meta.phases) {
|
|
8531
8560
|
if (phase.title.trim().length === 0) {
|
|
@@ -8538,9 +8567,9 @@ function validatePhases2(meta) {
|
|
|
8538
8567
|
}
|
|
8539
8568
|
}
|
|
8540
8569
|
function defineWorkflow(definition) {
|
|
8541
|
-
const meta =
|
|
8542
|
-
|
|
8543
|
-
|
|
8570
|
+
const meta = deepFreeze(structuredClone(definition.meta));
|
|
8571
|
+
validateLimits(meta);
|
|
8572
|
+
validatePhases(meta);
|
|
8544
8573
|
const stored = {
|
|
8545
8574
|
meta,
|
|
8546
8575
|
run: definition.run
|
|
@@ -8558,15 +8587,6 @@ function getWorkflowDefinition(handle) {
|
|
|
8558
8587
|
}
|
|
8559
8588
|
|
|
8560
8589
|
// src/sdk/nodejs/dist/session.js
|
|
8561
|
-
function isFactoryResumeErrorCode(value) {
|
|
8562
|
-
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";
|
|
8563
|
-
}
|
|
8564
|
-
function copyDefinedFactoryAgentOption(source, target, key) {
|
|
8565
|
-
const value = source[key];
|
|
8566
|
-
if (value !== void 0) {
|
|
8567
|
-
target[key] = value;
|
|
8568
|
-
}
|
|
8569
|
-
}
|
|
8570
8590
|
function isWorkflowResumeErrorCode(value) {
|
|
8571
8591
|
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";
|
|
8572
8592
|
}
|
|
@@ -8576,14 +8596,6 @@ function copyDefinedWorkflowAgentOption(source, target, key) {
|
|
|
8576
8596
|
target[key] = value;
|
|
8577
8597
|
}
|
|
8578
8598
|
}
|
|
8579
|
-
var factoryExecutionStore = new AsyncLocalStorage();
|
|
8580
|
-
function throwIfFactoryExecutionIsActive() {
|
|
8581
|
-
if (factoryExecutionStore.getStore()?.active) {
|
|
8582
|
-
throw new Error(
|
|
8583
|
-
"factory.run, factory.resume, and factory.pause are not allowed while a factory body is running on this call path."
|
|
8584
|
-
);
|
|
8585
|
-
}
|
|
8586
|
-
}
|
|
8587
8599
|
var workflowExecutionStore = new AsyncLocalStorage();
|
|
8588
8600
|
function throwIfWorkflowExecutionIsActive() {
|
|
8589
8601
|
if (workflowExecutionStore.getStore()?.active) {
|
|
@@ -8596,10 +8608,6 @@ function runInWorkflowHelperScope(helperScope, callback) {
|
|
|
8596
8608
|
const current = workflowExecutionStore.getStore();
|
|
8597
8609
|
return workflowExecutionStore.run({ active: current?.active ?? false, helperScope }, callback);
|
|
8598
8610
|
}
|
|
8599
|
-
function runInFactoryHelperScope(helperScope, callback) {
|
|
8600
|
-
const current = factoryExecutionStore.getStore();
|
|
8601
|
-
return factoryExecutionStore.run({ active: current?.active ?? false, helperScope }, callback);
|
|
8602
|
-
}
|
|
8603
8611
|
function deserializeHookInput(raw) {
|
|
8604
8612
|
if (!raw || typeof raw !== "object" || typeof raw.timestamp !== "number") {
|
|
8605
8613
|
return raw;
|
|
@@ -8622,68 +8630,20 @@ function isOpenCanvasInstance(value) {
|
|
|
8622
8630
|
}
|
|
8623
8631
|
var FACTORY_LOG_FLUSH_DELAY_MS = 10;
|
|
8624
8632
|
var MAX_FACTORY_FANOUT_ITEMS = 4096;
|
|
8625
|
-
function
|
|
8633
|
+
function assertWorkflowFanoutSize(kind, size) {
|
|
8626
8634
|
if (size > MAX_FACTORY_FANOUT_ITEMS) {
|
|
8627
8635
|
throw new Error(
|
|
8628
8636
|
`${kind}() accepts at most ${MAX_FACTORY_FANOUT_ITEMS} items; got ${size}.`
|
|
8629
8637
|
);
|
|
8630
8638
|
}
|
|
8631
8639
|
}
|
|
8632
|
-
async function runFactoryParallel(thunks) {
|
|
8633
|
-
if (!Array.isArray(thunks)) {
|
|
8634
|
-
throw new Error(
|
|
8635
|
-
"parallel() expects an array of functions, not promises. Wrap each call: () => agent(...)"
|
|
8636
|
-
);
|
|
8637
|
-
}
|
|
8638
|
-
assertFactoryFanoutSize("parallel", thunks.length);
|
|
8639
|
-
if (thunks.some((thunk) => typeof thunk !== "function")) {
|
|
8640
|
-
throw new Error(
|
|
8641
|
-
"parallel() expects an array of functions, not promises. Wrap each call: () => agent(...)"
|
|
8642
|
-
);
|
|
8643
|
-
}
|
|
8644
|
-
return Promise.all(
|
|
8645
|
-
thunks.map(
|
|
8646
|
-
(thunk) => Promise.resolve().then(() => runInFactoryHelperScope("parallel", thunk)).catch((error) => {
|
|
8647
|
-
if (isFactoryFatalError(error)) {
|
|
8648
|
-
throw error;
|
|
8649
|
-
}
|
|
8650
|
-
return null;
|
|
8651
|
-
})
|
|
8652
|
-
)
|
|
8653
|
-
);
|
|
8654
|
-
}
|
|
8655
|
-
async function runFactoryPipeline(items, ...stages) {
|
|
8656
|
-
if (!Array.isArray(items)) {
|
|
8657
|
-
throw new Error("pipeline(items, ...stages): items must be an array");
|
|
8658
|
-
}
|
|
8659
|
-
assertFactoryFanoutSize("pipeline", items.length);
|
|
8660
|
-
return Promise.all(
|
|
8661
|
-
items.map(async (item, index) => {
|
|
8662
|
-
let previous = item;
|
|
8663
|
-
for (const stage of stages) {
|
|
8664
|
-
try {
|
|
8665
|
-
previous = await runInFactoryHelperScope(
|
|
8666
|
-
"pipeline",
|
|
8667
|
-
() => stage(previous, item, index)
|
|
8668
|
-
);
|
|
8669
|
-
} catch (error) {
|
|
8670
|
-
if (isFactoryFatalError(error)) {
|
|
8671
|
-
throw error;
|
|
8672
|
-
}
|
|
8673
|
-
return null;
|
|
8674
|
-
}
|
|
8675
|
-
}
|
|
8676
|
-
return previous;
|
|
8677
|
-
})
|
|
8678
|
-
);
|
|
8679
|
-
}
|
|
8680
8640
|
async function runWorkflowParallel(thunks) {
|
|
8681
8641
|
if (!Array.isArray(thunks)) {
|
|
8682
8642
|
throw new Error(
|
|
8683
8643
|
"parallel() expects an array of functions, not promises. Wrap each call: () => agent(...)"
|
|
8684
8644
|
);
|
|
8685
8645
|
}
|
|
8686
|
-
|
|
8646
|
+
assertWorkflowFanoutSize("parallel", thunks.length);
|
|
8687
8647
|
if (thunks.some((thunk) => typeof thunk !== "function")) {
|
|
8688
8648
|
throw new Error(
|
|
8689
8649
|
"parallel() expects an array of functions, not promises. Wrap each call: () => agent(...)"
|
|
@@ -8692,7 +8652,7 @@ async function runWorkflowParallel(thunks) {
|
|
|
8692
8652
|
return Promise.all(
|
|
8693
8653
|
thunks.map(
|
|
8694
8654
|
(thunk) => Promise.resolve().then(() => runInWorkflowHelperScope("parallel", thunk)).catch((error) => {
|
|
8695
|
-
if (
|
|
8655
|
+
if (isWorkflowFatalError(error)) {
|
|
8696
8656
|
throw error;
|
|
8697
8657
|
}
|
|
8698
8658
|
return null;
|
|
@@ -8704,7 +8664,7 @@ async function runWorkflowPipeline(items, ...stages) {
|
|
|
8704
8664
|
if (!Array.isArray(items)) {
|
|
8705
8665
|
throw new Error("pipeline(items, ...stages): items must be an array");
|
|
8706
8666
|
}
|
|
8707
|
-
|
|
8667
|
+
assertWorkflowFanoutSize("pipeline", items.length);
|
|
8708
8668
|
return Promise.all(
|
|
8709
8669
|
items.map(async (item, index) => {
|
|
8710
8670
|
let previous = item;
|
|
@@ -8715,7 +8675,7 @@ async function runWorkflowPipeline(items, ...stages) {
|
|
|
8715
8675
|
() => stage(previous, item, index)
|
|
8716
8676
|
);
|
|
8717
8677
|
} catch (error) {
|
|
8718
|
-
if (
|
|
8678
|
+
if (isWorkflowFatalError(error)) {
|
|
8719
8679
|
throw error;
|
|
8720
8680
|
}
|
|
8721
8681
|
return null;
|
|
@@ -8725,85 +8685,6 @@ async function runWorkflowPipeline(items, ...stages) {
|
|
|
8725
8685
|
})
|
|
8726
8686
|
);
|
|
8727
8687
|
}
|
|
8728
|
-
var FactoryProgressBuffer = class {
|
|
8729
|
-
constructor(send) {
|
|
8730
|
-
this.send = send;
|
|
8731
|
-
}
|
|
8732
|
-
send;
|
|
8733
|
-
nextSeq = 0;
|
|
8734
|
-
pending = [];
|
|
8735
|
-
flushTimer;
|
|
8736
|
-
flushTail = Promise.resolve();
|
|
8737
|
-
flushError;
|
|
8738
|
-
flushFailed = false;
|
|
8739
|
-
closed = false;
|
|
8740
|
-
enqueue(kind, text) {
|
|
8741
|
-
if (this.closed) {
|
|
8742
|
-
throw new Error("Cannot log after the factory run has settled");
|
|
8743
|
-
}
|
|
8744
|
-
this.pending.push({ seq: this.nextSeq++, kind, text });
|
|
8745
|
-
this.scheduleFlush();
|
|
8746
|
-
}
|
|
8747
|
-
async flush() {
|
|
8748
|
-
this.clearFlushTimer();
|
|
8749
|
-
const lines = this.pending.splice(0);
|
|
8750
|
-
if (lines.length > 0) {
|
|
8751
|
-
this.flushTail = this.flushTail.then(async () => {
|
|
8752
|
-
try {
|
|
8753
|
-
await this.send(lines);
|
|
8754
|
-
} catch (error) {
|
|
8755
|
-
if (!this.flushFailed) {
|
|
8756
|
-
this.flushFailed = true;
|
|
8757
|
-
this.flushError = error;
|
|
8758
|
-
}
|
|
8759
|
-
}
|
|
8760
|
-
});
|
|
8761
|
-
}
|
|
8762
|
-
await this.flushTail;
|
|
8763
|
-
if (this.flushFailed) {
|
|
8764
|
-
throw this.flushError;
|
|
8765
|
-
}
|
|
8766
|
-
}
|
|
8767
|
-
async close() {
|
|
8768
|
-
this.closed = true;
|
|
8769
|
-
this.clearFlushTimer();
|
|
8770
|
-
const lines = this.pending.splice(0);
|
|
8771
|
-
await this.flushTail;
|
|
8772
|
-
if (this.flushFailed) {
|
|
8773
|
-
console.warn(
|
|
8774
|
-
"Ignoring a background factory progress flush failure after the factory body settled",
|
|
8775
|
-
this.flushError
|
|
8776
|
-
);
|
|
8777
|
-
}
|
|
8778
|
-
if (lines.length > 0) {
|
|
8779
|
-
try {
|
|
8780
|
-
await this.send(lines);
|
|
8781
|
-
} catch (error) {
|
|
8782
|
-
console.warn(
|
|
8783
|
-
"Failed to flush final factory progress after the factory body settled",
|
|
8784
|
-
error
|
|
8785
|
-
);
|
|
8786
|
-
}
|
|
8787
|
-
}
|
|
8788
|
-
}
|
|
8789
|
-
scheduleFlush() {
|
|
8790
|
-
if (this.flushTimer !== void 0) {
|
|
8791
|
-
return;
|
|
8792
|
-
}
|
|
8793
|
-
this.flushTimer = setTimeout(() => {
|
|
8794
|
-
this.flushTimer = void 0;
|
|
8795
|
-
void this.flush().catch(() => {
|
|
8796
|
-
});
|
|
8797
|
-
}, FACTORY_LOG_FLUSH_DELAY_MS);
|
|
8798
|
-
this.flushTimer.unref?.();
|
|
8799
|
-
}
|
|
8800
|
-
clearFlushTimer() {
|
|
8801
|
-
if (this.flushTimer !== void 0) {
|
|
8802
|
-
clearTimeout(this.flushTimer);
|
|
8803
|
-
this.flushTimer = void 0;
|
|
8804
|
-
}
|
|
8805
|
-
}
|
|
8806
|
-
};
|
|
8807
8688
|
var WorkflowProgressBuffer = class {
|
|
8808
8689
|
constructor(send) {
|
|
8809
8690
|
this.send = send;
|
|
@@ -8883,38 +8764,30 @@ var WorkflowProgressBuffer = class {
|
|
|
8883
8764
|
}
|
|
8884
8765
|
}
|
|
8885
8766
|
};
|
|
8886
|
-
async function
|
|
8767
|
+
async function awaitWorkflowOperation(operation, signal) {
|
|
8887
8768
|
let rejectAbort;
|
|
8888
8769
|
const abortPromise = new Promise((_resolve, reject) => {
|
|
8889
8770
|
rejectAbort = reject;
|
|
8890
8771
|
});
|
|
8891
|
-
const onAbort = () => rejectAbort?.(signal.reason ?? new DOMException("
|
|
8772
|
+
const onAbort = () => rejectAbort?.(signal.reason ?? new DOMException("Workflow run was aborted", "AbortError"));
|
|
8892
8773
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
8893
8774
|
try {
|
|
8894
|
-
|
|
8775
|
+
throwIfWorkflowAborted(signal);
|
|
8895
8776
|
return await Promise.race([operation(), abortPromise]);
|
|
8896
8777
|
} finally {
|
|
8897
8778
|
signal.removeEventListener("abort", onAbort);
|
|
8898
8779
|
}
|
|
8899
8780
|
}
|
|
8900
|
-
async function awaitWorkflowOperation(operation, signal) {
|
|
8901
|
-
return awaitFactoryOperation(operation, signal);
|
|
8902
|
-
}
|
|
8903
|
-
function throwIfFactoryAborted(signal) {
|
|
8904
|
-
if (signal.aborted) {
|
|
8905
|
-
throw signal.reason ?? new DOMException("Factory run was aborted", "AbortError");
|
|
8906
|
-
}
|
|
8907
|
-
}
|
|
8908
8781
|
function throwIfWorkflowAborted(signal) {
|
|
8909
8782
|
if (signal.aborted) {
|
|
8910
8783
|
throw signal.reason ?? new DOMException("Workflow run was aborted", "AbortError");
|
|
8911
8784
|
}
|
|
8912
8785
|
}
|
|
8913
|
-
function
|
|
8786
|
+
function isWorkflowAbortError(error) {
|
|
8914
8787
|
return typeof error === "object" && error !== null && "name" in error && error.name === "AbortError";
|
|
8915
8788
|
}
|
|
8916
|
-
function
|
|
8917
|
-
return
|
|
8789
|
+
function isWorkflowFatalError(error) {
|
|
8790
|
+
return isWorkflowAbortError(error) || error instanceof import_node.ResponseError || error instanceof import_node.ConnectionError;
|
|
8918
8791
|
}
|
|
8919
8792
|
var TOOL_SEARCH_TOOL_NAME = "tool_search_tool";
|
|
8920
8793
|
var CopilotSession = class {
|
|
@@ -8946,8 +8819,6 @@ var CopilotSession = class {
|
|
|
8946
8819
|
canvases = /* @__PURE__ */ new Map();
|
|
8947
8820
|
bearerTokenProviders = /* @__PURE__ */ new Map();
|
|
8948
8821
|
commandHandlers = /* @__PURE__ */ new Map();
|
|
8949
|
-
factories = /* @__PURE__ */ new Map();
|
|
8950
|
-
factoryAbortControllers = /* @__PURE__ */ new Map();
|
|
8951
8822
|
workflows = /* @__PURE__ */ new Map();
|
|
8952
8823
|
workflowAbortControllers = /* @__PURE__ */ new Map();
|
|
8953
8824
|
permissionHandler;
|
|
@@ -8966,73 +8837,16 @@ var CopilotSession = class {
|
|
|
8966
8837
|
openCanvasInstances = [];
|
|
8967
8838
|
disconnected = false;
|
|
8968
8839
|
pendingStructuredWaits = /* @__PURE__ */ new Set();
|
|
8969
|
-
disconnecting = false;
|
|
8970
|
-
onDisconnected;
|
|
8971
|
-
/** @internal Client session API handlers, populated by CopilotClient during create/resume. */
|
|
8972
|
-
clientSessionApis = {};
|
|
8973
|
-
/**
|
|
8974
|
-
* Friendly
|
|
8975
|
-
*
|
|
8976
|
-
* @experimental Part of the experimental
|
|
8977
|
-
* change or be removed in future SDK or CLI releases.
|
|
8978
|
-
*/
|
|
8979
|
-
factory = {
|
|
8980
|
-
run: (async (nameOrHandle, options) => {
|
|
8981
|
-
throwIfFactoryExecutionIsActive();
|
|
8982
|
-
const name = typeof nameOrHandle === "string" ? nameOrHandle : getFactoryDefinition(nameOrHandle).meta.name;
|
|
8983
|
-
if (options?.resumeFromRunId !== void 0) {
|
|
8984
|
-
return this.factory.resume(options.resumeFromRunId, {
|
|
8985
|
-
limits: options.limits,
|
|
8986
|
-
notifyOnComplete: options.notifyOnComplete,
|
|
8987
|
-
logPhaseNames: options.logPhaseNames
|
|
8988
|
-
});
|
|
8989
|
-
}
|
|
8990
|
-
const envelope = await this.rpc.factory.run({
|
|
8991
|
-
name,
|
|
8992
|
-
args: options?.args === void 0 ? {} : options.args,
|
|
8993
|
-
options: {
|
|
8994
|
-
limits: options?.limits,
|
|
8995
|
-
notifyOnComplete: options?.notifyOnComplete,
|
|
8996
|
-
logPhaseNames: options?.logPhaseNames
|
|
8997
|
-
}
|
|
8998
|
-
});
|
|
8999
|
-
return this.settleFactoryRun(envelope);
|
|
9000
|
-
}),
|
|
9001
|
-
resume: (async (runId, options) => {
|
|
9002
|
-
throwIfFactoryExecutionIsActive();
|
|
9003
|
-
let response;
|
|
9004
|
-
try {
|
|
9005
|
-
response = await this.rpc.factory.resume({
|
|
9006
|
-
runId,
|
|
9007
|
-
limits: options?.limits,
|
|
9008
|
-
notifyOnComplete: options?.notifyOnComplete,
|
|
9009
|
-
logPhaseNames: options?.logPhaseNames
|
|
9010
|
-
});
|
|
9011
|
-
} catch (error) {
|
|
9012
|
-
if (error instanceof import_node.ResponseError && typeof error.data === "object" && error.data !== null) {
|
|
9013
|
-
const code = error.data.code;
|
|
9014
|
-
if (isFactoryResumeErrorCode(code)) {
|
|
9015
|
-
throw new FactoryResumeError(code, error.message);
|
|
9016
|
-
}
|
|
9017
|
-
}
|
|
9018
|
-
throw error;
|
|
9019
|
-
}
|
|
9020
|
-
return this.settleFactoryRun(response.run);
|
|
9021
|
-
}),
|
|
9022
|
-
getRun: async (runId) => this.rpc.factory.getRun({ runId }),
|
|
9023
|
-
waitForRun: (runId, options) => this.waitForFactoryRun(runId, options?.signal),
|
|
9024
|
-
listRuns: (async (options) => {
|
|
9025
|
-
const page = await this.rpc.factory.listRuns(options ?? {});
|
|
9026
|
-
return options === void 0 ? page.runs : page;
|
|
9027
|
-
}),
|
|
9028
|
-
getRunDetail: (runId) => this.rpc.factory.getRunDetail({ runId }),
|
|
9029
|
-
getRunProgress: (runId, options = {}) => this.rpc.factory.getRunProgress({ runId, ...options }),
|
|
9030
|
-
pause: async (runId) => {
|
|
9031
|
-
throwIfFactoryExecutionIsActive();
|
|
9032
|
-
return this.rpc.factory.pause({ runId });
|
|
9033
|
-
},
|
|
9034
|
-
cancel: async (runId) => this.rpc.factory.cancel({ runId })
|
|
9035
|
-
};
|
|
8840
|
+
disconnecting = false;
|
|
8841
|
+
onDisconnected;
|
|
8842
|
+
/** @internal Client session API handlers, populated by CopilotClient during create/resume. */
|
|
8843
|
+
clientSessionApis = {};
|
|
8844
|
+
/**
|
|
8845
|
+
* Friendly workflow API for running registered workflows by name or handle.
|
|
8846
|
+
*
|
|
8847
|
+
* @experimental Part of the experimental Dynamic Workflows surface and may
|
|
8848
|
+
* change or be removed in future SDK or CLI releases.
|
|
8849
|
+
*/
|
|
9036
8850
|
workflow = {
|
|
9037
8851
|
run: (async (nameOrHandle, options) => {
|
|
9038
8852
|
throwIfWorkflowExecutionIsActive();
|
|
@@ -9083,93 +8897,6 @@ var CopilotSession = class {
|
|
|
9083
8897
|
},
|
|
9084
8898
|
cancel: async (runId) => this.rpc.workflow.cancel({ runId })
|
|
9085
8899
|
};
|
|
9086
|
-
/**
|
|
9087
|
-
* Resolve a start/resume envelope into the terminal envelope callers expect.
|
|
9088
|
-
*
|
|
9089
|
-
* The CLI may answer `session.factory.run` and `session.factory.resume`
|
|
9090
|
-
* before the run settles, so a non-terminal envelope is followed by a wait
|
|
9091
|
-
* on the run's terminal state.
|
|
9092
|
-
*/
|
|
9093
|
-
settleFactoryRun(envelope) {
|
|
9094
|
-
if (isFactoryRunTerminal(envelope.status)) {
|
|
9095
|
-
return Promise.resolve(envelope);
|
|
9096
|
-
}
|
|
9097
|
-
return this.waitForFactoryRun(envelope.runId);
|
|
9098
|
-
}
|
|
9099
|
-
/**
|
|
9100
|
-
* Resolve when a factory run reaches a terminal status.
|
|
9101
|
-
*
|
|
9102
|
-
* The subscription is installed *before* the first read so a transition
|
|
9103
|
-
* landing between the two cannot be missed, and re-reads are serialized so
|
|
9104
|
-
* overlapping invalidation events cannot interleave — the run's revision
|
|
9105
|
-
* advances once per operation, so a burst of events is common and must
|
|
9106
|
-
* collapse into a single in-flight read. A bounded periodic re-read keeps a
|
|
9107
|
-
* dropped invalidation from leaving the wait pending forever.
|
|
9108
|
-
*/
|
|
9109
|
-
waitForFactoryRun(runId, signal) {
|
|
9110
|
-
const abortError = () => signal?.reason ?? new DOMException("Factory run wait was aborted", "AbortError");
|
|
9111
|
-
if (signal?.aborted === true) {
|
|
9112
|
-
return Promise.reject(abortError());
|
|
9113
|
-
}
|
|
9114
|
-
return new Promise((resolve3, reject) => {
|
|
9115
|
-
let settled = false;
|
|
9116
|
-
let reading = false;
|
|
9117
|
-
let rereadRequested = false;
|
|
9118
|
-
let pollHandle;
|
|
9119
|
-
let unsubscribe;
|
|
9120
|
-
let onAbort;
|
|
9121
|
-
const finish = (complete) => {
|
|
9122
|
-
if (settled) {
|
|
9123
|
-
return;
|
|
9124
|
-
}
|
|
9125
|
-
settled = true;
|
|
9126
|
-
if (pollHandle !== void 0) {
|
|
9127
|
-
clearInterval(pollHandle);
|
|
9128
|
-
}
|
|
9129
|
-
unsubscribe?.();
|
|
9130
|
-
if (onAbort !== void 0) {
|
|
9131
|
-
signal?.removeEventListener("abort", onAbort);
|
|
9132
|
-
}
|
|
9133
|
-
complete();
|
|
9134
|
-
};
|
|
9135
|
-
const read = async () => {
|
|
9136
|
-
if (settled) {
|
|
9137
|
-
return;
|
|
9138
|
-
}
|
|
9139
|
-
if (reading) {
|
|
9140
|
-
rereadRequested = true;
|
|
9141
|
-
return;
|
|
9142
|
-
}
|
|
9143
|
-
reading = true;
|
|
9144
|
-
try {
|
|
9145
|
-
do {
|
|
9146
|
-
rereadRequested = false;
|
|
9147
|
-
const envelope = await this.rpc.factory.getRun({ runId });
|
|
9148
|
-
if (isFactoryRunTerminal(envelope.status)) {
|
|
9149
|
-
finish(() => resolve3(envelope));
|
|
9150
|
-
return;
|
|
9151
|
-
}
|
|
9152
|
-
} while (rereadRequested && !settled);
|
|
9153
|
-
} catch (error) {
|
|
9154
|
-
finish(() => reject(error));
|
|
9155
|
-
} finally {
|
|
9156
|
-
reading = false;
|
|
9157
|
-
}
|
|
9158
|
-
};
|
|
9159
|
-
if (signal !== void 0) {
|
|
9160
|
-
onAbort = () => finish(() => reject(abortError()));
|
|
9161
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
9162
|
-
}
|
|
9163
|
-
unsubscribe = this.on("factory.run_updated", (event) => {
|
|
9164
|
-
if (event.data.runId === runId) {
|
|
9165
|
-
void read();
|
|
9166
|
-
}
|
|
9167
|
-
});
|
|
9168
|
-
pollHandle = setInterval(() => void read(), 5e3);
|
|
9169
|
-
pollHandle.unref?.();
|
|
9170
|
-
void read();
|
|
9171
|
-
});
|
|
9172
|
-
}
|
|
9173
8900
|
settleWorkflowRun(envelope) {
|
|
9174
8901
|
if (isWorkflowRunTerminal(envelope.status)) {
|
|
9175
8902
|
return Promise.resolve(envelope);
|
|
@@ -9240,7 +8967,7 @@ var CopilotSession = class {
|
|
|
9240
8967
|
onAbort = () => finish(() => reject(abortError()));
|
|
9241
8968
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
9242
8969
|
}
|
|
9243
|
-
unsubscribe = this.on("
|
|
8970
|
+
unsubscribe = this.on("workflow.run_updated", (event) => {
|
|
9244
8971
|
if (event.data.runId === runId) {
|
|
9245
8972
|
void read();
|
|
9246
8973
|
}
|
|
@@ -9366,6 +9093,7 @@ var CopilotSession = class {
|
|
|
9366
9093
|
});
|
|
9367
9094
|
let lastAssistantMessage;
|
|
9368
9095
|
const unsubscribe = this.on((event) => {
|
|
9096
|
+
if (event.agentId) return;
|
|
9369
9097
|
if (event.type === "assistant.message") {
|
|
9370
9098
|
lastAssistantMessage = event;
|
|
9371
9099
|
} else if (event.type === "session.idle" && event.data.mode !== "autopilot") {
|
|
@@ -9505,13 +9233,6 @@ var CopilotSession = class {
|
|
|
9505
9233
|
this.autoModeSwitchHandler = void 0;
|
|
9506
9234
|
this.commandHandlers.clear();
|
|
9507
9235
|
this.canvases.clear();
|
|
9508
|
-
this.factories.clear();
|
|
9509
|
-
for (const controllersForRun of this.factoryAbortControllers.values()) {
|
|
9510
|
-
for (const controller of controllersForRun.values()) {
|
|
9511
|
-
controller.abort();
|
|
9512
|
-
}
|
|
9513
|
-
}
|
|
9514
|
-
this.factoryAbortControllers.clear();
|
|
9515
9236
|
this.workflows.clear();
|
|
9516
9237
|
for (const controllersForRun of this.workflowAbortControllers.values()) {
|
|
9517
9238
|
for (const controller of controllersForRun.values()) {
|
|
@@ -9966,192 +9687,6 @@ var CopilotSession = class {
|
|
|
9966
9687
|
}
|
|
9967
9688
|
};
|
|
9968
9689
|
}
|
|
9969
|
-
/**
|
|
9970
|
-
* Registers factory closures and reverse-RPC handlers for this session.
|
|
9971
|
-
*
|
|
9972
|
-
* @param factories - Factory handles declared by the joining extension.
|
|
9973
|
-
* @internal Called by the SDK when an extension joins a session.
|
|
9974
|
-
*/
|
|
9975
|
-
registerFactories(factories) {
|
|
9976
|
-
this.factories.clear();
|
|
9977
|
-
if (!factories || factories.length === 0) {
|
|
9978
|
-
delete this.clientSessionApis.factory;
|
|
9979
|
-
return;
|
|
9980
|
-
}
|
|
9981
|
-
for (const handle of factories) {
|
|
9982
|
-
const definition = getFactoryDefinition(handle);
|
|
9983
|
-
if (this.factories.has(definition.meta.name)) {
|
|
9984
|
-
throw new Error(
|
|
9985
|
-
`Duplicate factory name "${definition.meta.name}". Factory names must be unique within a joinSession call.`
|
|
9986
|
-
);
|
|
9987
|
-
}
|
|
9988
|
-
this.factories.set(definition.meta.name, definition);
|
|
9989
|
-
}
|
|
9990
|
-
const self = this;
|
|
9991
|
-
this.clientSessionApis.factory = {
|
|
9992
|
-
async execute(params) {
|
|
9993
|
-
const definition = self.factories.get(params.name);
|
|
9994
|
-
if (!definition) {
|
|
9995
|
-
const message = `No factory registered with name "${params.name}"`;
|
|
9996
|
-
throw new import_node.ResponseError(import_node.ErrorCodes.InvalidParams, message, {
|
|
9997
|
-
code: "factory_not_found",
|
|
9998
|
-
name: params.name
|
|
9999
|
-
});
|
|
10000
|
-
}
|
|
10001
|
-
const controller = new AbortController();
|
|
10002
|
-
let controllersForRun = self.factoryAbortControllers.get(params.runId);
|
|
10003
|
-
if (controllersForRun === void 0) {
|
|
10004
|
-
controllersForRun = /* @__PURE__ */ new Map();
|
|
10005
|
-
self.factoryAbortControllers.set(params.runId, controllersForRun);
|
|
10006
|
-
}
|
|
10007
|
-
controllersForRun.set(params.executionToken, controller);
|
|
10008
|
-
const progress = new FactoryProgressBuffer(async (lines) => {
|
|
10009
|
-
await self.rpc.factory.log({
|
|
10010
|
-
runId: params.runId,
|
|
10011
|
-
executionToken: params.executionToken,
|
|
10012
|
-
lines
|
|
10013
|
-
});
|
|
10014
|
-
});
|
|
10015
|
-
try {
|
|
10016
|
-
const context = {
|
|
10017
|
-
runId: params.runId,
|
|
10018
|
-
args: params.args,
|
|
10019
|
-
session: self,
|
|
10020
|
-
signal: controller.signal,
|
|
10021
|
-
phase: (title) => {
|
|
10022
|
-
throwIfFactoryAborted(controller.signal);
|
|
10023
|
-
progress.enqueue("phase", title);
|
|
10024
|
-
},
|
|
10025
|
-
log: (message) => {
|
|
10026
|
-
throwIfFactoryAborted(controller.signal);
|
|
10027
|
-
progress.enqueue("log", message);
|
|
10028
|
-
},
|
|
10029
|
-
agent: async (prompt, options = {}) => {
|
|
10030
|
-
await progress.flush();
|
|
10031
|
-
const opts = {};
|
|
10032
|
-
for (const key of FACTORY_AGENT_OPTION_KEYS) {
|
|
10033
|
-
copyDefinedFactoryAgentOption(options, opts, key);
|
|
10034
|
-
}
|
|
10035
|
-
const response = await awaitFactoryOperation(
|
|
10036
|
-
() => self.rpc.factory.agent({
|
|
10037
|
-
factoryRunId: params.runId,
|
|
10038
|
-
executionToken: params.executionToken,
|
|
10039
|
-
prompt,
|
|
10040
|
-
opts
|
|
10041
|
-
}),
|
|
10042
|
-
controller.signal
|
|
10043
|
-
);
|
|
10044
|
-
return response.result ?? null;
|
|
10045
|
-
},
|
|
10046
|
-
step: async (key, producer, options = {}) => {
|
|
10047
|
-
await progress.flush();
|
|
10048
|
-
if (options.volatile) {
|
|
10049
|
-
throwIfFactoryAborted(controller.signal);
|
|
10050
|
-
return producer();
|
|
10051
|
-
}
|
|
10052
|
-
const cached = await awaitFactoryOperation(
|
|
10053
|
-
() => self.rpc.factory.journal.get({
|
|
10054
|
-
runId: params.runId,
|
|
10055
|
-
executionToken: params.executionToken,
|
|
10056
|
-
key
|
|
10057
|
-
}),
|
|
10058
|
-
controller.signal
|
|
10059
|
-
);
|
|
10060
|
-
if (cached.hit) {
|
|
10061
|
-
if (cached.resultJson === void 0) {
|
|
10062
|
-
throw new Error(
|
|
10063
|
-
`step("${key}") journal returned a hit without a result`
|
|
10064
|
-
);
|
|
10065
|
-
}
|
|
10066
|
-
assertFactoryStepResult(cached.resultJson, key);
|
|
10067
|
-
return cached.resultJson;
|
|
10068
|
-
}
|
|
10069
|
-
const result2 = await producer();
|
|
10070
|
-
assertFactoryStepResult(result2, key);
|
|
10071
|
-
await awaitFactoryOperation(
|
|
10072
|
-
() => self.rpc.factory.journal.put({
|
|
10073
|
-
runId: params.runId,
|
|
10074
|
-
executionToken: params.executionToken,
|
|
10075
|
-
key,
|
|
10076
|
-
resultJson: result2
|
|
10077
|
-
}),
|
|
10078
|
-
controller.signal
|
|
10079
|
-
);
|
|
10080
|
-
return result2;
|
|
10081
|
-
},
|
|
10082
|
-
pause: async (key) => {
|
|
10083
|
-
if (typeof key !== "string" || key.length === 0) {
|
|
10084
|
-
throw new Error("Factory pause checkpoint key must not be empty");
|
|
10085
|
-
}
|
|
10086
|
-
const helperScope = factoryExecutionStore.getStore()?.helperScope;
|
|
10087
|
-
if (helperScope !== void 0) {
|
|
10088
|
-
throw new Error(
|
|
10089
|
-
`Factory pause checkpoints are not allowed inside ${helperScope}() branches`
|
|
10090
|
-
);
|
|
10091
|
-
}
|
|
10092
|
-
await progress.flush();
|
|
10093
|
-
const response = await awaitFactoryOperation(
|
|
10094
|
-
() => self.internalRpc.factory.pauseAtCheckpoint({
|
|
10095
|
-
runId: params.runId,
|
|
10096
|
-
executionToken: params.executionToken,
|
|
10097
|
-
key
|
|
10098
|
-
}),
|
|
10099
|
-
controller.signal
|
|
10100
|
-
);
|
|
10101
|
-
switch (response.action) {
|
|
10102
|
-
case "continue":
|
|
10103
|
-
return;
|
|
10104
|
-
case "pause":
|
|
10105
|
-
await awaitFactoryOperation(
|
|
10106
|
-
() => new Promise(() => {
|
|
10107
|
-
}),
|
|
10108
|
-
controller.signal
|
|
10109
|
-
);
|
|
10110
|
-
}
|
|
10111
|
-
},
|
|
10112
|
-
parallel: runFactoryParallel,
|
|
10113
|
-
pipeline: runFactoryPipeline,
|
|
10114
|
-
factory: async () => {
|
|
10115
|
-
throw new Error("nested factories are not supported");
|
|
10116
|
-
}
|
|
10117
|
-
};
|
|
10118
|
-
const execution = { active: true };
|
|
10119
|
-
const result = await factoryExecutionStore.run(execution, async () => {
|
|
10120
|
-
try {
|
|
10121
|
-
return await definition.run(context);
|
|
10122
|
-
} finally {
|
|
10123
|
-
execution.active = false;
|
|
10124
|
-
}
|
|
10125
|
-
});
|
|
10126
|
-
if (result === void 0) {
|
|
10127
|
-
return {};
|
|
10128
|
-
}
|
|
10129
|
-
assertFactoryResult(result);
|
|
10130
|
-
return { result };
|
|
10131
|
-
} finally {
|
|
10132
|
-
try {
|
|
10133
|
-
await progress.close();
|
|
10134
|
-
} finally {
|
|
10135
|
-
const controllersForRun2 = self.factoryAbortControllers.get(params.runId);
|
|
10136
|
-
if (controllersForRun2?.get(params.executionToken) === controller) {
|
|
10137
|
-
controllersForRun2.delete(params.executionToken);
|
|
10138
|
-
if (controllersForRun2.size === 0) {
|
|
10139
|
-
self.factoryAbortControllers.delete(params.runId);
|
|
10140
|
-
}
|
|
10141
|
-
}
|
|
10142
|
-
}
|
|
10143
|
-
}
|
|
10144
|
-
},
|
|
10145
|
-
async abort(params) {
|
|
10146
|
-
const controllersForRun = self.factoryAbortControllers.get(params.runId);
|
|
10147
|
-
const controller = controllersForRun?.get(params.executionToken);
|
|
10148
|
-
if (controller !== void 0) {
|
|
10149
|
-
controller.abort(new DOMException("Factory run was aborted", "AbortError"));
|
|
10150
|
-
}
|
|
10151
|
-
return {};
|
|
10152
|
-
}
|
|
10153
|
-
};
|
|
10154
|
-
}
|
|
10155
9690
|
/**
|
|
10156
9691
|
* Registers workflow closures and reverse-RPC handlers for this session.
|
|
10157
9692
|
*
|
|
@@ -11018,20 +10553,6 @@ function assertStrictJson(value, context) {
|
|
|
11018
10553
|
};
|
|
11019
10554
|
visit(value, "$", context.allowTopLevelUndefined);
|
|
11020
10555
|
}
|
|
11021
|
-
function assertFactoryResult(value) {
|
|
11022
|
-
assertStrictJson(value, {
|
|
11023
|
-
code: "factory_result_not_json",
|
|
11024
|
-
label: "Factory result",
|
|
11025
|
-
allowTopLevelUndefined: true
|
|
11026
|
-
});
|
|
11027
|
-
}
|
|
11028
|
-
function assertFactoryStepResult(value, key) {
|
|
11029
|
-
assertStrictJson(value, {
|
|
11030
|
-
code: "factory_step_not_json",
|
|
11031
|
-
label: `Factory step "${key}" result`,
|
|
11032
|
-
allowTopLevelUndefined: false
|
|
11033
|
-
});
|
|
11034
|
-
}
|
|
11035
10556
|
function assertWorkflowResult(value) {
|
|
11036
10557
|
assertStrictJson(value, {
|
|
11037
10558
|
code: "workflow_result_not_json",
|
|
@@ -11262,6 +10783,79 @@ async function ensureRuntimeBundle(version2, options = {}) {
|
|
|
11262
10783
|
return wrapper;
|
|
11263
10784
|
}
|
|
11264
10785
|
|
|
10786
|
+
// src/sdk/nodejs/dist/installationConfirmation.js
|
|
10787
|
+
var import_node2 = __toESM(require_node(), 1);
|
|
10788
|
+
function createInstallationConfirmationAdapter(connection, handler) {
|
|
10789
|
+
const closed = new import_node2.CancellationTokenSource();
|
|
10790
|
+
const closeSubscription = connection.onClose(() => closed.cancel());
|
|
10791
|
+
const disposeSubscription = connection.onDispose(() => {
|
|
10792
|
+
closed.cancel();
|
|
10793
|
+
closed.dispose();
|
|
10794
|
+
closeSubscription.dispose();
|
|
10795
|
+
disposeSubscription.dispose();
|
|
10796
|
+
});
|
|
10797
|
+
return {
|
|
10798
|
+
async confirm(request, token) {
|
|
10799
|
+
if (!token) {
|
|
10800
|
+
throw new Error("Installation confirmation request cancellation is unavailable");
|
|
10801
|
+
}
|
|
10802
|
+
const { confirmationId, reviewFingerprint } = request;
|
|
10803
|
+
const combined = new import_node2.CancellationTokenSource();
|
|
10804
|
+
const subscriptions = [];
|
|
10805
|
+
const cancelRequest = () => combined.cancel();
|
|
10806
|
+
const cancelConnection = () => combined.cancel();
|
|
10807
|
+
const checkCancellation = () => {
|
|
10808
|
+
if (closed.token.isCancellationRequested) {
|
|
10809
|
+
throw new Error("Installation confirmation connection closed");
|
|
10810
|
+
}
|
|
10811
|
+
if (token.isCancellationRequested) {
|
|
10812
|
+
throw new import_node2.ResponseError(-32800, "Installation confirmation request cancelled");
|
|
10813
|
+
}
|
|
10814
|
+
};
|
|
10815
|
+
try {
|
|
10816
|
+
subscriptions.push(
|
|
10817
|
+
token.onCancellationRequested(cancelRequest),
|
|
10818
|
+
closed.token.onCancellationRequested(cancelConnection)
|
|
10819
|
+
);
|
|
10820
|
+
if (token.isCancellationRequested || closed.token.isCancellationRequested) {
|
|
10821
|
+
combined.cancel();
|
|
10822
|
+
}
|
|
10823
|
+
checkCancellation();
|
|
10824
|
+
const cancelled = new Promise((_resolve, reject) => {
|
|
10825
|
+
subscriptions.push(
|
|
10826
|
+
token.onCancellationRequested(
|
|
10827
|
+
() => reject(
|
|
10828
|
+
new import_node2.ResponseError(
|
|
10829
|
+
-32800,
|
|
10830
|
+
"Installation confirmation request cancelled"
|
|
10831
|
+
)
|
|
10832
|
+
)
|
|
10833
|
+
),
|
|
10834
|
+
closed.token.onCancellationRequested(
|
|
10835
|
+
() => reject(new Error("Installation confirmation connection closed"))
|
|
10836
|
+
)
|
|
10837
|
+
);
|
|
10838
|
+
});
|
|
10839
|
+
const decision = await Promise.race([
|
|
10840
|
+
Promise.resolve().then(() => {
|
|
10841
|
+
checkCancellation();
|
|
10842
|
+
return handler(request, combined.token);
|
|
10843
|
+
}),
|
|
10844
|
+
cancelled
|
|
10845
|
+
]);
|
|
10846
|
+
checkCancellation();
|
|
10847
|
+
if (decision !== "confirm" && decision !== "decline" && decision !== "cancel") {
|
|
10848
|
+
throw new Error("Invalid installation confirmation decision");
|
|
10849
|
+
}
|
|
10850
|
+
return { confirmationId, reviewFingerprint, decision };
|
|
10851
|
+
} finally {
|
|
10852
|
+
for (const subscription of subscriptions) subscription.dispose();
|
|
10853
|
+
combined.dispose();
|
|
10854
|
+
}
|
|
10855
|
+
}
|
|
10856
|
+
};
|
|
10857
|
+
}
|
|
10858
|
+
|
|
11265
10859
|
// src/sdk/nodejs/dist/toolSet.js
|
|
11266
10860
|
var VALID_TOOL_NAME = /^[a-zA-Z0-9_-]+$/;
|
|
11267
10861
|
function validateName(kind, name) {
|
|
@@ -11479,7 +11073,7 @@ function getNodeExecPath() {
|
|
|
11479
11073
|
function getBundledRuntimePath() {
|
|
11480
11074
|
return ensureRuntimeBundle(COPILOT_CLI_VERSION);
|
|
11481
11075
|
}
|
|
11482
|
-
var TeardownResilientStreamMessageWriter = class extends
|
|
11076
|
+
var TeardownResilientStreamMessageWriter = class extends import_node3.StreamMessageWriter {
|
|
11483
11077
|
suppressWriteErrors = false;
|
|
11484
11078
|
async write(msg) {
|
|
11485
11079
|
try {
|
|
@@ -11535,6 +11129,7 @@ var CopilotClient = class _CopilotClient {
|
|
|
11535
11129
|
sessionFsConfig = null;
|
|
11536
11130
|
requestHandler = null;
|
|
11537
11131
|
extensionLaunchProvider;
|
|
11132
|
+
installationConfirmationHandler;
|
|
11538
11133
|
builtinPluginDirectories = [];
|
|
11539
11134
|
onGitHubTelemetry;
|
|
11540
11135
|
clientGlobalHandlers = {};
|
|
@@ -11693,6 +11288,7 @@ var CopilotClient = class _CopilotClient {
|
|
|
11693
11288
|
this.sessionFsConfig = options.sessionFs ?? null;
|
|
11694
11289
|
this.requestHandler = options.requestHandler ?? null;
|
|
11695
11290
|
this.extensionLaunchProvider = options.extensionLaunchProvider;
|
|
11291
|
+
this.installationConfirmationHandler = options.installationConfirmationHandler;
|
|
11696
11292
|
this.onGitHubTelemetry = options.onGitHubTelemetry;
|
|
11697
11293
|
this.setupClientGlobalHandlers();
|
|
11698
11294
|
const connEnv = conn.kind === "stdio" || conn.kind === "tcp" ? conn.env : void 0;
|
|
@@ -12507,6 +12103,7 @@ var CopilotClient = class _CopilotClient {
|
|
|
12507
12103
|
includeSubAgentStreamingEvents: config.includeSubAgentStreamingEvents ?? true,
|
|
12508
12104
|
...this.onGitHubTelemetry != null ? { enableGitHubTelemetryForwarding: true } : {},
|
|
12509
12105
|
mcpServers: toWireMcpServers(config.mcpServers),
|
|
12106
|
+
...config.diagnostics !== void 0 ? { diagnostics: config.diagnostics } : {},
|
|
12510
12107
|
mcpOAuthTokenStorage: config.mcpOAuthTokenStorage,
|
|
12511
12108
|
authClientIdMetadataUrl: config.authClientIdMetadataUrl,
|
|
12512
12109
|
envValueMode: "direct",
|
|
@@ -12516,6 +12113,7 @@ var CopilotClient = class _CopilotClient {
|
|
|
12516
12113
|
agent: config.agent,
|
|
12517
12114
|
configDir: config.configDirectory,
|
|
12518
12115
|
enableConfigDiscovery: config.enableConfigDiscovery,
|
|
12116
|
+
refreshCustomInstructions: config.refreshCustomInstructions,
|
|
12519
12117
|
skipEmbeddingRetrieval: config.skipEmbeddingRetrieval,
|
|
12520
12118
|
embeddingCacheStorage: config.embeddingCacheStorage,
|
|
12521
12119
|
organizationCustomInstructions: config.organizationCustomInstructions,
|
|
@@ -12607,14 +12205,12 @@ var CopilotClient = class _CopilotClient {
|
|
|
12607
12205
|
async resumeSession(sessionId, config) {
|
|
12608
12206
|
return this.resumeSessionInternal(sessionId, config);
|
|
12609
12207
|
}
|
|
12208
|
+
/** @internal */
|
|
12610
12209
|
async resumeSessionForExtension(sessionId, config, contributions = {}, extensionOptions) {
|
|
12611
12210
|
return this.resumeSessionInternal(sessionId, config, contributions, extensionOptions);
|
|
12612
12211
|
}
|
|
12613
12212
|
async resumeSessionInternal(sessionId, config, contributions = {}, extensionOptions) {
|
|
12614
|
-
const {
|
|
12615
|
-
if (factories !== void 0 && workflows !== void 0) {
|
|
12616
|
-
throw new Error("Session configuration cannot include both factories and workflows");
|
|
12617
|
-
}
|
|
12213
|
+
const { workflows } = contributions;
|
|
12618
12214
|
if (config.gitHubToken !== void 0 && config.gitHubTokenProvider !== void 0) {
|
|
12619
12215
|
throw new Error("gitHubToken and gitHubTokenProvider are mutually exclusive");
|
|
12620
12216
|
}
|
|
@@ -12634,7 +12230,6 @@ var CopilotClient = class _CopilotClient {
|
|
|
12634
12230
|
session.registerTools(config.tools);
|
|
12635
12231
|
session.registerCanvases(config.canvases);
|
|
12636
12232
|
session.registerCommands(config.commands);
|
|
12637
|
-
session.registerFactories(factories);
|
|
12638
12233
|
session.registerWorkflows(workflows);
|
|
12639
12234
|
const {
|
|
12640
12235
|
wireProvider: bearerWireProvider,
|
|
@@ -12716,7 +12311,6 @@ var CopilotClient = class _CopilotClient {
|
|
|
12716
12311
|
})),
|
|
12717
12312
|
toolSearch: config.toolSearch,
|
|
12718
12313
|
canvases: config.canvases?.map((canvas) => canvas.declaration),
|
|
12719
|
-
factories: factories?.map((factory) => factory.meta),
|
|
12720
12314
|
workflows: workflows?.map((workflow) => workflow.meta),
|
|
12721
12315
|
requestCanvasRenderer: config.requestCanvasRenderer,
|
|
12722
12316
|
requestExtensions: config.requestExtensions,
|
|
@@ -12758,6 +12352,7 @@ var CopilotClient = class _CopilotClient {
|
|
|
12758
12352
|
includeSubAgentStreamingEvents: config.includeSubAgentStreamingEvents ?? true,
|
|
12759
12353
|
...this.onGitHubTelemetry != null ? { enableGitHubTelemetryForwarding: true } : {},
|
|
12760
12354
|
mcpServers: toWireMcpServers(config.mcpServers),
|
|
12355
|
+
...config.diagnostics !== void 0 ? { diagnostics: config.diagnostics } : {},
|
|
12761
12356
|
mcpOAuthTokenStorage: config.mcpOAuthTokenStorage,
|
|
12762
12357
|
authClientIdMetadataUrl: config.authClientIdMetadataUrl,
|
|
12763
12358
|
envValueMode: "direct",
|
|
@@ -12938,7 +12533,7 @@ var CopilotClient = class _CopilotClient {
|
|
|
12938
12533
|
const result = await raceAgainstExit(this.internalRpc.connect(connectParams));
|
|
12939
12534
|
serverVersion = result.protocolVersion;
|
|
12940
12535
|
} catch (err) {
|
|
12941
|
-
if (err instanceof
|
|
12536
|
+
if (err instanceof import_node3.ResponseError && (err.code === import_node3.ErrorCodes.MethodNotFound || err.message === "Unhandled method connect")) {
|
|
12942
12537
|
serverVersion = (await raceAgainstExit(this.ping())).protocolVersion;
|
|
12943
12538
|
} else {
|
|
12944
12539
|
throw err;
|
|
@@ -13178,6 +12773,9 @@ var CopilotClient = class _CopilotClient {
|
|
|
13178
12773
|
if (this.options.mode === "empty") {
|
|
13179
12774
|
env.COPILOT_DISABLE_KEYTAR = "1";
|
|
13180
12775
|
}
|
|
12776
|
+
if (this.options.mode !== "empty") {
|
|
12777
|
+
env.COPILOT_RUNTIME_PROCESS_FILE_LOGGING = "1";
|
|
12778
|
+
}
|
|
13181
12779
|
if (this.options.telemetry) {
|
|
13182
12780
|
const t = this.options.telemetry;
|
|
13183
12781
|
env.COPILOT_OTEL_ENABLED = "true";
|
|
@@ -13413,8 +13011,8 @@ stderr: ${stderrOutput}`
|
|
|
13413
13011
|
throw new Error("In-process FFI runtime host not started");
|
|
13414
13012
|
}
|
|
13415
13013
|
this.messageWriter = new TeardownResilientStreamMessageWriter(this.ffiHost.sendStream);
|
|
13416
|
-
this.connection = (0,
|
|
13417
|
-
new
|
|
13014
|
+
this.connection = (0, import_node3.createMessageConnection)(
|
|
13015
|
+
new import_node3.StreamMessageReader(this.ffiHost.receiveStream),
|
|
13418
13016
|
this.messageWriter
|
|
13419
13017
|
);
|
|
13420
13018
|
this.attachConnectionHandlers();
|
|
@@ -13467,8 +13065,8 @@ stderr: ${stderrOutput}` : ""}`
|
|
|
13467
13065
|
}
|
|
13468
13066
|
});
|
|
13469
13067
|
this.messageWriter = new TeardownResilientStreamMessageWriter(this.cliProcess.stdin);
|
|
13470
|
-
this.connection = (0,
|
|
13471
|
-
new
|
|
13068
|
+
this.connection = (0, import_node3.createMessageConnection)(
|
|
13069
|
+
new import_node3.StreamMessageReader(this.cliProcess.stdout),
|
|
13472
13070
|
this.messageWriter
|
|
13473
13071
|
);
|
|
13474
13072
|
this.attachConnectionHandlers();
|
|
@@ -13482,8 +13080,8 @@ stderr: ${stderrOutput}` : ""}`
|
|
|
13482
13080
|
throw new Error("CLI child process was unexpectedly started in parent process mode");
|
|
13483
13081
|
}
|
|
13484
13082
|
this.messageWriter = new TeardownResilientStreamMessageWriter(process.stdout);
|
|
13485
|
-
this.connection = (0,
|
|
13486
|
-
new
|
|
13083
|
+
this.connection = (0, import_node3.createMessageConnection)(
|
|
13084
|
+
new import_node3.StreamMessageReader(process.stdin),
|
|
13487
13085
|
this.messageWriter
|
|
13488
13086
|
);
|
|
13489
13087
|
this.attachConnectionHandlers();
|
|
@@ -13505,8 +13103,8 @@ stderr: ${stderrOutput}` : ""}`
|
|
|
13505
13103
|
this.socket.connect(this.runtimePort, this.actualHost, () => {
|
|
13506
13104
|
clearTimeout(connectionTimeout);
|
|
13507
13105
|
this.messageWriter = new TeardownResilientStreamMessageWriter(this.socket);
|
|
13508
|
-
this.connection = (0,
|
|
13509
|
-
new
|
|
13106
|
+
this.connection = (0, import_node3.createMessageConnection)(
|
|
13107
|
+
new import_node3.StreamMessageReader(this.socket),
|
|
13510
13108
|
this.messageWriter
|
|
13511
13109
|
);
|
|
13512
13110
|
this.attachConnectionHandlers();
|
|
@@ -13552,6 +13150,16 @@ stderr: ${stderrOutput}` : ""}`
|
|
|
13552
13150
|
return session.clientSessionApis;
|
|
13553
13151
|
});
|
|
13554
13152
|
registerClientGlobalApiHandlers(this.connection, this.clientGlobalHandlers);
|
|
13153
|
+
if (this.installationConfirmationHandler) {
|
|
13154
|
+
const confirmation = createInstallationConfirmationAdapter(
|
|
13155
|
+
this.connection,
|
|
13156
|
+
this.installationConfirmationHandler
|
|
13157
|
+
);
|
|
13158
|
+
this.connection.onRequest(
|
|
13159
|
+
"installations.confirm",
|
|
13160
|
+
(params, token) => confirmation.confirm(params, token)
|
|
13161
|
+
);
|
|
13162
|
+
}
|
|
13555
13163
|
this.connection.onRequest(
|
|
13556
13164
|
"hooks.invoke",
|
|
13557
13165
|
async (params) => {
|
|
@@ -13701,15 +13309,11 @@ async function joinSession(config = {}) {
|
|
|
13701
13309
|
const client = new CopilotClient({ _internalConnection: { kind: "parent-process" } });
|
|
13702
13310
|
const {
|
|
13703
13311
|
extensionSdkPath: _stripped,
|
|
13704
|
-
factories,
|
|
13705
13312
|
workflows,
|
|
13706
13313
|
requestedEnvironmentVariables,
|
|
13707
13314
|
...rest
|
|
13708
13315
|
} = config;
|
|
13709
13316
|
void _stripped;
|
|
13710
|
-
if (factories !== void 0 && workflows !== void 0) {
|
|
13711
|
-
throw new Error("joinSession cannot register both factories and workflows");
|
|
13712
|
-
}
|
|
13713
13317
|
return client.resumeSessionForExtension(
|
|
13714
13318
|
sessionId,
|
|
13715
13319
|
{
|
|
@@ -13717,19 +13321,16 @@ async function joinSession(config = {}) {
|
|
|
13717
13321
|
onPermissionRequest: config.onPermissionRequest ?? defaultJoinSessionPermissionHandler,
|
|
13718
13322
|
suppressResumeEvent: config.suppressResumeEvent ?? true
|
|
13719
13323
|
},
|
|
13720
|
-
{
|
|
13324
|
+
{ workflows },
|
|
13721
13325
|
requestedEnvironmentVariables?.length ? { requestedEnvironmentVariables } : void 0
|
|
13722
13326
|
);
|
|
13723
13327
|
}
|
|
13724
13328
|
export {
|
|
13725
13329
|
Canvas,
|
|
13726
13330
|
CanvasError,
|
|
13727
|
-
FactoryResumeError,
|
|
13728
13331
|
WorkflowResumeError,
|
|
13729
13332
|
createCanvas,
|
|
13730
|
-
defineFactory,
|
|
13731
13333
|
defineWorkflow,
|
|
13732
|
-
isFactoryRunTerminal,
|
|
13733
13334
|
isWorkflowRunTerminal,
|
|
13734
13335
|
joinSession
|
|
13735
13336
|
};
|