@github/copilot-sdk-win32-x64 1.0.15-preview.3 → 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 +402 -846
- package/copilot-sdk/generated/rpc.d.ts +5960 -4645
- package/copilot-sdk/generated/session-events.d.ts +197 -118
- package/copilot-sdk/index.d.ts +2 -4
- package/copilot-sdk/index.js +392 -832
- package/copilot-sdk/installationConfirmation.d.ts +19 -0
- package/copilot-sdk/session.d.ts +2 -25
- package/copilot-sdk/types.d.ts +10 -65
- 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 +18134 -16248
- package/schemas/session-events.schema.json +932 -842
- 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";
|
|
@@ -4209,7 +4209,74 @@ function createServerRpc(connection) {
|
|
|
4209
4209
|
*
|
|
4210
4210
|
* @returns Outcome of an mcp.planInstall call: either a normalised plan, or one typed refusal. Nothing is written in either case.
|
|
4211
4211
|
*/
|
|
4212
|
-
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
|
+
}
|
|
4213
4280
|
},
|
|
4214
4281
|
/** @experimental */
|
|
4215
4282
|
extensions: {
|
|
@@ -4232,6 +4299,115 @@ function createServerRpc(connection) {
|
|
|
4232
4299
|
*/
|
|
4233
4300
|
disable: async (params) => connection.sendRequest("extensions.disable", params)
|
|
4234
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
|
+
},
|
|
4235
4411
|
/**
|
|
4236
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.
|
|
4237
4413
|
*
|
|
@@ -4357,40 +4533,6 @@ function createServerRpc(connection) {
|
|
|
4357
4533
|
}
|
|
4358
4534
|
},
|
|
4359
4535
|
/** @experimental */
|
|
4360
|
-
skills: {
|
|
4361
|
-
/** @experimental */
|
|
4362
|
-
config: {
|
|
4363
|
-
/**
|
|
4364
|
-
* Replaces the global list of disabled skills.
|
|
4365
|
-
*
|
|
4366
|
-
* @param params Skill names to mark as disabled in global configuration, replacing any previous list.
|
|
4367
|
-
*/
|
|
4368
|
-
setDisabledSkills: async (params) => connection.sendRequest("skills.config.setDisabledSkills", params),
|
|
4369
|
-
/**
|
|
4370
|
-
* Atomically adds or removes one skill from the disabled list.
|
|
4371
|
-
*
|
|
4372
|
-
* @param params Adds or removes a single skill from the global disabled list, leaving every other entry untouched.
|
|
4373
|
-
*/
|
|
4374
|
-
setSkillDisabled: async (params) => connection.sendRequest("skills.config.setSkillDisabled", params)
|
|
4375
|
-
},
|
|
4376
|
-
/**
|
|
4377
|
-
* Discovers skills across global and project sources.
|
|
4378
|
-
*
|
|
4379
|
-
* @param params Optional project paths and additional skill directories to include in discovery.
|
|
4380
|
-
*
|
|
4381
|
-
* @returns Skills discovered across global and project sources.
|
|
4382
|
-
*/
|
|
4383
|
-
discover: async (params) => connection.sendRequest("skills.discover", params),
|
|
4384
|
-
/**
|
|
4385
|
-
* 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.
|
|
4386
|
-
*
|
|
4387
|
-
* @param params Optional project paths to enumerate.
|
|
4388
|
-
*
|
|
4389
|
-
* @returns Canonical locations where skills can be created so the runtime will recognize them.
|
|
4390
|
-
*/
|
|
4391
|
-
getDiscoveryPaths: async (params) => connection.sendRequest("skills.getDiscoveryPaths", params)
|
|
4392
|
-
},
|
|
4393
|
-
/** @experimental */
|
|
4394
4536
|
agents: {
|
|
4395
4537
|
/**
|
|
4396
4538
|
* Discovers custom agents across user, project, plugin, and remote sources.
|
|
@@ -4795,6 +4937,17 @@ function createInternalServerRpc(connection) {
|
|
|
4795
4937
|
* @param params Params to attach or detach an in-process ExtensionController delegate.
|
|
4796
4938
|
*/
|
|
4797
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)
|
|
4798
4951
|
}
|
|
4799
4952
|
};
|
|
4800
4953
|
}
|
|
@@ -4897,6 +5050,58 @@ function createSessionRpc(connection, sessionId) {
|
|
|
4897
5050
|
setCredentials: async (params) => connection.sendRequest("session.gitHubAuth.setCredentials", { sessionId, ...params })
|
|
4898
5051
|
},
|
|
4899
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 */
|
|
4900
5105
|
debug: {
|
|
4901
5106
|
/**
|
|
4902
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.
|
|
@@ -4948,108 +5153,6 @@ function createSessionRpc(connection, sessionId) {
|
|
|
4948
5153
|
}
|
|
4949
5154
|
},
|
|
4950
5155
|
/** @experimental */
|
|
4951
|
-
factory: {
|
|
4952
|
-
/**
|
|
4953
|
-
* Runs a registered factory by name at the top level.
|
|
4954
|
-
*
|
|
4955
|
-
* @param params Parameters for invoking a registered factory.
|
|
4956
|
-
*
|
|
4957
|
-
* @returns Complete current or terminal factory run envelope.
|
|
4958
|
-
*/
|
|
4959
|
-
run: async (params) => connection.sendRequest("session.factory.run", { sessionId, ...params }),
|
|
4960
|
-
/**
|
|
4961
|
-
* Resumes a factory run using its persisted name, arguments, journal, and accounting.
|
|
4962
|
-
*
|
|
4963
|
-
* @param params Parameters for resuming a factory run from its persisted identity.
|
|
4964
|
-
*
|
|
4965
|
-
* @returns Resolved persisted factory identity and resumed run envelope.
|
|
4966
|
-
*/
|
|
4967
|
-
resume: async (params) => connection.sendRequest("session.factory.resume", { sessionId, ...params }),
|
|
4968
|
-
/**
|
|
4969
|
-
* Gets the current or settled envelope for a factory run.
|
|
4970
|
-
*
|
|
4971
|
-
* @param params Parameters for retrieving a factory run.
|
|
4972
|
-
*
|
|
4973
|
-
* @returns Complete current or terminal factory run envelope.
|
|
4974
|
-
*/
|
|
4975
|
-
getRun: async (params) => connection.sendRequest("session.factory.getRun", { sessionId, ...params }),
|
|
4976
|
-
/**
|
|
4977
|
-
* Lists durable factory runs for this session in creation order.
|
|
4978
|
-
*
|
|
4979
|
-
* @param params Parameters for paging factory runs.
|
|
4980
|
-
*
|
|
4981
|
-
* @returns A page of factory runs in durable creation order.
|
|
4982
|
-
*/
|
|
4983
|
-
listRuns: async (params) => connection.sendRequest("session.factory.listRuns", { sessionId, ...params }),
|
|
4984
|
-
/**
|
|
4985
|
-
* Gets durable and live observability detail for one factory run.
|
|
4986
|
-
*
|
|
4987
|
-
* @param params Parameters for retrieving a factory run.
|
|
4988
|
-
*
|
|
4989
|
-
* @returns Full factory run observability detail.
|
|
4990
|
-
*/
|
|
4991
|
-
getRunDetail: async (params) => connection.sendRequest("session.factory.getRunDetail", { sessionId, ...params }),
|
|
4992
|
-
/**
|
|
4993
|
-
* Pages durable progress for one factory run.
|
|
4994
|
-
*
|
|
4995
|
-
* @param params Parameters for paging factory progress.
|
|
4996
|
-
*
|
|
4997
|
-
* @returns A bidirectional page of factory progress.
|
|
4998
|
-
*/
|
|
4999
|
-
getRunProgress: async (params) => connection.sendRequest("session.factory.getRunProgress", { sessionId, ...params }),
|
|
5000
|
-
/**
|
|
5001
|
-
* Requests cancellation of a factory run and returns its run envelope.
|
|
5002
|
-
*
|
|
5003
|
-
* @param params Parameters for cancelling a factory run.
|
|
5004
|
-
*
|
|
5005
|
-
* @returns Complete current or terminal factory run envelope.
|
|
5006
|
-
*/
|
|
5007
|
-
cancel: async (params) => connection.sendRequest("session.factory.cancel", { sessionId, ...params }),
|
|
5008
|
-
/**
|
|
5009
|
-
* Pauses a running factory and returns its settled run envelope.
|
|
5010
|
-
*
|
|
5011
|
-
* @param params Parameters for pausing a running factory.
|
|
5012
|
-
*
|
|
5013
|
-
* @returns Complete current or terminal factory run envelope.
|
|
5014
|
-
*/
|
|
5015
|
-
pause: async (params) => connection.sendRequest("session.factory.pause", { sessionId, ...params }),
|
|
5016
|
-
/**
|
|
5017
|
-
* Records a batch of ordered factory progress lines.
|
|
5018
|
-
*
|
|
5019
|
-
* @param params Parameters for recording factory progress.
|
|
5020
|
-
*
|
|
5021
|
-
* @returns Acknowledgement that a factory request was accepted.
|
|
5022
|
-
*/
|
|
5023
|
-
log: async (params) => connection.sendRequest("session.factory.log", { sessionId, ...params }),
|
|
5024
|
-
/**
|
|
5025
|
-
* Runs one factory-scoped subagent and returns its result.
|
|
5026
|
-
*
|
|
5027
|
-
* @param params Parameters for one factory-scoped subagent call.
|
|
5028
|
-
*
|
|
5029
|
-
* @returns Result of one factory-scoped subagent call.
|
|
5030
|
-
*/
|
|
5031
|
-
agent: async (params) => connection.sendRequest("session.factory.agent", { sessionId, ...params }),
|
|
5032
|
-
/** @experimental */
|
|
5033
|
-
journal: {
|
|
5034
|
-
/**
|
|
5035
|
-
* Reads a memoized factory journal entry.
|
|
5036
|
-
*
|
|
5037
|
-
* @param params Parameters for reading a factory journal entry.
|
|
5038
|
-
*
|
|
5039
|
-
* @returns Result of reading a factory journal entry.
|
|
5040
|
-
*/
|
|
5041
|
-
get: async (params) => connection.sendRequest("session.factory.journal.get", { sessionId, ...params }),
|
|
5042
|
-
/**
|
|
5043
|
-
* Stores a memoized factory journal entry.
|
|
5044
|
-
*
|
|
5045
|
-
* @param params Parameters for storing a factory journal entry.
|
|
5046
|
-
*
|
|
5047
|
-
* @returns Acknowledgement that a factory request was accepted.
|
|
5048
|
-
*/
|
|
5049
|
-
put: async (params) => connection.sendRequest("session.factory.journal.put", { sessionId, ...params })
|
|
5050
|
-
}
|
|
5051
|
-
},
|
|
5052
|
-
/** @experimental */
|
|
5053
5156
|
workflow: {
|
|
5054
5157
|
/**
|
|
5055
5158
|
* Runs a registered dynamic workflow by name at the top level.
|
|
@@ -5759,7 +5862,15 @@ function createSessionRpc(connection, sessionId) {
|
|
|
5759
5862
|
*/
|
|
5760
5863
|
authenticationStateChanged: async (params) => connection.sendRequest("session.mcp.oauth.authenticationStateChanged", { sessionId, ...params }),
|
|
5761
5864
|
/**
|
|
5762
|
-
*
|
|
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.
|
|
5763
5874
|
*
|
|
5764
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.
|
|
5765
5876
|
*
|
|
@@ -5774,6 +5885,14 @@ function createSessionRpc(connection, sessionId) {
|
|
|
5774
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.
|
|
5775
5886
|
*/
|
|
5776
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 }),
|
|
5777
5896
|
/**
|
|
5778
5897
|
* Responds to a pending MCP OAuth authorization request by its request id.
|
|
5779
5898
|
*
|
|
@@ -7012,31 +7131,6 @@ function createInternalSessionRpc(connection, sessionId) {
|
|
|
7012
7131
|
}
|
|
7013
7132
|
},
|
|
7014
7133
|
/** @experimental */
|
|
7015
|
-
factory: {
|
|
7016
|
-
/**
|
|
7017
|
-
* Internal tool-originated factory invocation.
|
|
7018
|
-
*
|
|
7019
|
-
* @param params Internal parameters for invoking a registered factory from a tool.
|
|
7020
|
-
*
|
|
7021
|
-
* @returns Complete current or terminal factory run envelope.
|
|
7022
|
-
*/
|
|
7023
|
-
runFromTool: async (params) => connection.sendRequest("session.factory.runFromTool", { sessionId, ...params }),
|
|
7024
|
-
/**
|
|
7025
|
-
* Internal tool-originated factory resume.
|
|
7026
|
-
*
|
|
7027
|
-
* @param params Internal parameters for resuming a factory run from a tool.
|
|
7028
|
-
*
|
|
7029
|
-
* @returns Resolved persisted factory identity and resumed run envelope.
|
|
7030
|
-
*/
|
|
7031
|
-
resumeFromTool: async (params) => connection.sendRequest("session.factory.resumeFromTool", { sessionId, ...params }),
|
|
7032
|
-
/**
|
|
7033
|
-
* Atomically pauses an owned factory attempt at a durable checkpoint.
|
|
7034
|
-
*
|
|
7035
|
-
* @param params Parameters for an owned durable pause checkpoint.
|
|
7036
|
-
*/
|
|
7037
|
-
pauseAtCheckpoint: async (params) => connection.sendRequest("session.factory.pauseAtCheckpoint", { sessionId, ...params })
|
|
7038
|
-
},
|
|
7039
|
-
/** @experimental */
|
|
7040
7134
|
workflow: {
|
|
7041
7135
|
/**
|
|
7042
7136
|
* Internal tool-originated dynamic workflow invocation.
|
|
@@ -7264,16 +7358,6 @@ function registerClientSessionApiHandlers(connection, getHandlers) {
|
|
|
7264
7358
|
if (!handler) throw new Error(`No providerToken handler registered for session: ${params.sessionId}`);
|
|
7265
7359
|
return handler.getToken(params);
|
|
7266
7360
|
});
|
|
7267
|
-
connection.onRequest("factory.execute", async (params) => {
|
|
7268
|
-
const handler = getHandlers(params.sessionId).factory;
|
|
7269
|
-
if (!handler) throw new Error(`No factory handler registered for session: ${params.sessionId}`);
|
|
7270
|
-
return handler.execute(params);
|
|
7271
|
-
});
|
|
7272
|
-
connection.onRequest("factory.abort", async (params) => {
|
|
7273
|
-
const handler = getHandlers(params.sessionId).factory;
|
|
7274
|
-
if (!handler) throw new Error(`No factory handler registered for session: ${params.sessionId}`);
|
|
7275
|
-
return handler.abort(params);
|
|
7276
|
-
});
|
|
7277
7361
|
connection.onRequest("workflow.execute", async (params) => {
|
|
7278
7362
|
const handler = getHandlers(params.sessionId).workflow;
|
|
7279
7363
|
if (!handler) throw new Error(`No workflow handler registered for session: ${params.sessionId}`);
|
|
@@ -7396,6 +7480,11 @@ function registerClientGlobalApiHandlers(connection, handlers) {
|
|
|
7396
7480
|
if (!handler) throw new Error("No gitHubToken client-global handler registered");
|
|
7397
7481
|
return handler.getToken(params);
|
|
7398
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
|
+
});
|
|
7399
7488
|
}
|
|
7400
7489
|
|
|
7401
7490
|
// src/sdk/nodejs/dist/sdkProtocolVersion.js
|
|
@@ -8396,109 +8485,8 @@ var defaultJoinSessionPermissionHandler = () => ({
|
|
|
8396
8485
|
kind: "no-result"
|
|
8397
8486
|
});
|
|
8398
8487
|
|
|
8399
|
-
// src/sdk/nodejs/dist/
|
|
8400
|
-
var
|
|
8401
|
-
"completed",
|
|
8402
|
-
"halted",
|
|
8403
|
-
"paused",
|
|
8404
|
-
"cancelled",
|
|
8405
|
-
"error"
|
|
8406
|
-
]);
|
|
8407
|
-
function isFactoryRunTerminal(status) {
|
|
8408
|
-
return FACTORY_TERMINAL_STATUSES.has(status);
|
|
8409
|
-
}
|
|
8410
|
-
var FACTORY_AGENT_OPTION_KEYS = [
|
|
8411
|
-
"label",
|
|
8412
|
-
"schema",
|
|
8413
|
-
"model",
|
|
8414
|
-
"reasoningEffort",
|
|
8415
|
-
"contextTier",
|
|
8416
|
-
"agent"
|
|
8417
|
-
];
|
|
8418
|
-
var FactoryResumeError = class extends Error {
|
|
8419
|
-
constructor(code, message) {
|
|
8420
|
-
super(message);
|
|
8421
|
-
this.code = code;
|
|
8422
|
-
this.name = "FactoryResumeError";
|
|
8423
|
-
}
|
|
8424
|
-
code;
|
|
8425
|
-
};
|
|
8426
|
-
var factoryHandles = /* @__PURE__ */ new WeakMap();
|
|
8427
|
-
var MAX_FACTORY_TIMEOUT_SECONDS = 2147483647e-3;
|
|
8428
|
-
var NANO_AIU_PER_AIU = 1e9;
|
|
8429
|
-
function deepFreeze(value) {
|
|
8430
|
-
if (value !== null && typeof value === "object" && !Object.isFrozen(value)) {
|
|
8431
|
-
Object.freeze(value);
|
|
8432
|
-
for (const nested of Object.values(value)) {
|
|
8433
|
-
deepFreeze(nested);
|
|
8434
|
-
}
|
|
8435
|
-
}
|
|
8436
|
-
return value;
|
|
8437
|
-
}
|
|
8438
|
-
function validateLimits(meta) {
|
|
8439
|
-
const limits = meta.limits;
|
|
8440
|
-
if (!limits) {
|
|
8441
|
-
return;
|
|
8442
|
-
}
|
|
8443
|
-
for (const field of ["maxConcurrentSubagents", "maxTotalSubagents"]) {
|
|
8444
|
-
const value = limits[field];
|
|
8445
|
-
if (value !== void 0 && (!Number.isInteger(value) || value <= 0)) {
|
|
8446
|
-
throw new Error(`Factory limit "${field}" must be a positive integer`);
|
|
8447
|
-
}
|
|
8448
|
-
}
|
|
8449
|
-
if (limits.timeoutSeconds !== void 0 && (!Number.isFinite(limits.timeoutSeconds) || limits.timeoutSeconds <= 0)) {
|
|
8450
|
-
throw new Error(
|
|
8451
|
-
'Factory limit "timeoutSeconds" must be a positive, finite number of seconds'
|
|
8452
|
-
);
|
|
8453
|
-
}
|
|
8454
|
-
if (limits.timeoutSeconds !== void 0 && limits.timeoutSeconds > MAX_FACTORY_TIMEOUT_SECONDS) {
|
|
8455
|
-
throw new Error(
|
|
8456
|
-
`Factory limit "timeoutSeconds" must not exceed ${MAX_FACTORY_TIMEOUT_SECONDS} seconds`
|
|
8457
|
-
);
|
|
8458
|
-
}
|
|
8459
|
-
if (limits.maxAiCredits !== void 0) {
|
|
8460
|
-
const maxNanoAiu = Math.round(limits.maxAiCredits * NANO_AIU_PER_AIU);
|
|
8461
|
-
if (!Number.isFinite(limits.maxAiCredits) || limits.maxAiCredits <= 0 || !Number.isSafeInteger(maxNanoAiu) || maxNanoAiu < 1) {
|
|
8462
|
-
throw new Error(
|
|
8463
|
-
'Factory limit "maxAiCredits" must be a positive, finite number that rounds to a safe positive integer nano-AIU ceiling'
|
|
8464
|
-
);
|
|
8465
|
-
}
|
|
8466
|
-
}
|
|
8467
|
-
}
|
|
8468
|
-
function validatePhases(meta) {
|
|
8469
|
-
const titles = /* @__PURE__ */ new Set();
|
|
8470
|
-
for (const phase of meta.phases) {
|
|
8471
|
-
if (phase.title.trim().length === 0) {
|
|
8472
|
-
throw new Error("Factory phase titles must not be empty");
|
|
8473
|
-
}
|
|
8474
|
-
if (titles.has(phase.title)) {
|
|
8475
|
-
throw new Error(`Factory phase title "${phase.title}" is declared more than once`);
|
|
8476
|
-
}
|
|
8477
|
-
titles.add(phase.title);
|
|
8478
|
-
}
|
|
8479
|
-
}
|
|
8480
|
-
function defineFactory(definition) {
|
|
8481
|
-
const meta = deepFreeze(structuredClone(definition.meta));
|
|
8482
|
-
validateLimits(meta);
|
|
8483
|
-
validatePhases(meta);
|
|
8484
|
-
const stored = {
|
|
8485
|
-
meta,
|
|
8486
|
-
run: definition.run
|
|
8487
|
-
};
|
|
8488
|
-
const handle = Object.freeze({ meta });
|
|
8489
|
-
factoryHandles.set(handle, stored);
|
|
8490
|
-
return handle;
|
|
8491
|
-
}
|
|
8492
|
-
function getFactoryDefinition(handle) {
|
|
8493
|
-
const definition = factoryHandles.get(handle);
|
|
8494
|
-
if (!definition) {
|
|
8495
|
-
throw new Error("Invalid factory handle");
|
|
8496
|
-
}
|
|
8497
|
-
return definition;
|
|
8498
|
-
}
|
|
8499
|
-
|
|
8500
|
-
// src/sdk/nodejs/dist/workflow.js
|
|
8501
|
-
var WORKFLOW_TERMINAL_STATUSES = /* @__PURE__ */ new Set([
|
|
8488
|
+
// src/sdk/nodejs/dist/workflow.js
|
|
8489
|
+
var WORKFLOW_TERMINAL_STATUSES = /* @__PURE__ */ new Set([
|
|
8502
8490
|
"completed",
|
|
8503
8491
|
"halted",
|
|
8504
8492
|
"paused",
|
|
@@ -8526,17 +8514,17 @@ var WorkflowResumeError = class extends Error {
|
|
|
8526
8514
|
};
|
|
8527
8515
|
var workflowHandles = /* @__PURE__ */ new WeakMap();
|
|
8528
8516
|
var MAX_WORKFLOW_TIMEOUT_SECONDS = 2147483647e-3;
|
|
8529
|
-
var
|
|
8530
|
-
function
|
|
8517
|
+
var NANO_AIU_PER_AIU = 1e9;
|
|
8518
|
+
function deepFreeze(value) {
|
|
8531
8519
|
if (value !== null && typeof value === "object" && !Object.isFrozen(value)) {
|
|
8532
8520
|
Object.freeze(value);
|
|
8533
8521
|
for (const nested of Object.values(value)) {
|
|
8534
|
-
|
|
8522
|
+
deepFreeze(nested);
|
|
8535
8523
|
}
|
|
8536
8524
|
}
|
|
8537
8525
|
return value;
|
|
8538
8526
|
}
|
|
8539
|
-
function
|
|
8527
|
+
function validateLimits(meta) {
|
|
8540
8528
|
const limits = meta.limits;
|
|
8541
8529
|
if (!limits) {
|
|
8542
8530
|
return;
|
|
@@ -8558,7 +8546,7 @@ function validateLimits2(meta) {
|
|
|
8558
8546
|
);
|
|
8559
8547
|
}
|
|
8560
8548
|
if (limits.maxAiCredits !== void 0) {
|
|
8561
|
-
const maxNanoAiu = Math.round(limits.maxAiCredits *
|
|
8549
|
+
const maxNanoAiu = Math.round(limits.maxAiCredits * NANO_AIU_PER_AIU);
|
|
8562
8550
|
if (!Number.isFinite(limits.maxAiCredits) || limits.maxAiCredits <= 0 || !Number.isSafeInteger(maxNanoAiu) || maxNanoAiu < 1) {
|
|
8563
8551
|
throw new Error(
|
|
8564
8552
|
'Workflow limit "maxAiCredits" must be a positive, finite number that rounds to a safe positive integer nano-AIU ceiling'
|
|
@@ -8566,7 +8554,7 @@ function validateLimits2(meta) {
|
|
|
8566
8554
|
}
|
|
8567
8555
|
}
|
|
8568
8556
|
}
|
|
8569
|
-
function
|
|
8557
|
+
function validatePhases(meta) {
|
|
8570
8558
|
const titles = /* @__PURE__ */ new Set();
|
|
8571
8559
|
for (const phase of meta.phases) {
|
|
8572
8560
|
if (phase.title.trim().length === 0) {
|
|
@@ -8579,9 +8567,9 @@ function validatePhases2(meta) {
|
|
|
8579
8567
|
}
|
|
8580
8568
|
}
|
|
8581
8569
|
function defineWorkflow(definition) {
|
|
8582
|
-
const meta =
|
|
8583
|
-
|
|
8584
|
-
|
|
8570
|
+
const meta = deepFreeze(structuredClone(definition.meta));
|
|
8571
|
+
validateLimits(meta);
|
|
8572
|
+
validatePhases(meta);
|
|
8585
8573
|
const stored = {
|
|
8586
8574
|
meta,
|
|
8587
8575
|
run: definition.run
|
|
@@ -8599,15 +8587,6 @@ function getWorkflowDefinition(handle) {
|
|
|
8599
8587
|
}
|
|
8600
8588
|
|
|
8601
8589
|
// src/sdk/nodejs/dist/session.js
|
|
8602
|
-
function isFactoryResumeErrorCode(value) {
|
|
8603
|
-
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";
|
|
8604
|
-
}
|
|
8605
|
-
function copyDefinedFactoryAgentOption(source, target, key) {
|
|
8606
|
-
const value = source[key];
|
|
8607
|
-
if (value !== void 0) {
|
|
8608
|
-
target[key] = value;
|
|
8609
|
-
}
|
|
8610
|
-
}
|
|
8611
8590
|
function isWorkflowResumeErrorCode(value) {
|
|
8612
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";
|
|
8613
8592
|
}
|
|
@@ -8617,14 +8596,6 @@ function copyDefinedWorkflowAgentOption(source, target, key) {
|
|
|
8617
8596
|
target[key] = value;
|
|
8618
8597
|
}
|
|
8619
8598
|
}
|
|
8620
|
-
var factoryExecutionStore = new AsyncLocalStorage();
|
|
8621
|
-
function throwIfFactoryExecutionIsActive() {
|
|
8622
|
-
if (factoryExecutionStore.getStore()?.active) {
|
|
8623
|
-
throw new Error(
|
|
8624
|
-
"factory.run, factory.resume, and factory.pause are not allowed while a factory body is running on this call path."
|
|
8625
|
-
);
|
|
8626
|
-
}
|
|
8627
|
-
}
|
|
8628
8599
|
var workflowExecutionStore = new AsyncLocalStorage();
|
|
8629
8600
|
function throwIfWorkflowExecutionIsActive() {
|
|
8630
8601
|
if (workflowExecutionStore.getStore()?.active) {
|
|
@@ -8637,10 +8608,6 @@ function runInWorkflowHelperScope(helperScope, callback) {
|
|
|
8637
8608
|
const current = workflowExecutionStore.getStore();
|
|
8638
8609
|
return workflowExecutionStore.run({ active: current?.active ?? false, helperScope }, callback);
|
|
8639
8610
|
}
|
|
8640
|
-
function runInFactoryHelperScope(helperScope, callback) {
|
|
8641
|
-
const current = factoryExecutionStore.getStore();
|
|
8642
|
-
return factoryExecutionStore.run({ active: current?.active ?? false, helperScope }, callback);
|
|
8643
|
-
}
|
|
8644
8611
|
function deserializeHookInput(raw) {
|
|
8645
8612
|
if (!raw || typeof raw !== "object" || typeof raw.timestamp !== "number") {
|
|
8646
8613
|
return raw;
|
|
@@ -8663,68 +8630,20 @@ function isOpenCanvasInstance(value) {
|
|
|
8663
8630
|
}
|
|
8664
8631
|
var FACTORY_LOG_FLUSH_DELAY_MS = 10;
|
|
8665
8632
|
var MAX_FACTORY_FANOUT_ITEMS = 4096;
|
|
8666
|
-
function
|
|
8633
|
+
function assertWorkflowFanoutSize(kind, size) {
|
|
8667
8634
|
if (size > MAX_FACTORY_FANOUT_ITEMS) {
|
|
8668
8635
|
throw new Error(
|
|
8669
8636
|
`${kind}() accepts at most ${MAX_FACTORY_FANOUT_ITEMS} items; got ${size}.`
|
|
8670
8637
|
);
|
|
8671
8638
|
}
|
|
8672
8639
|
}
|
|
8673
|
-
async function runFactoryParallel(thunks) {
|
|
8674
|
-
if (!Array.isArray(thunks)) {
|
|
8675
|
-
throw new Error(
|
|
8676
|
-
"parallel() expects an array of functions, not promises. Wrap each call: () => agent(...)"
|
|
8677
|
-
);
|
|
8678
|
-
}
|
|
8679
|
-
assertFactoryFanoutSize("parallel", thunks.length);
|
|
8680
|
-
if (thunks.some((thunk) => typeof thunk !== "function")) {
|
|
8681
|
-
throw new Error(
|
|
8682
|
-
"parallel() expects an array of functions, not promises. Wrap each call: () => agent(...)"
|
|
8683
|
-
);
|
|
8684
|
-
}
|
|
8685
|
-
return Promise.all(
|
|
8686
|
-
thunks.map(
|
|
8687
|
-
(thunk) => Promise.resolve().then(() => runInFactoryHelperScope("parallel", thunk)).catch((error) => {
|
|
8688
|
-
if (isFactoryFatalError(error)) {
|
|
8689
|
-
throw error;
|
|
8690
|
-
}
|
|
8691
|
-
return null;
|
|
8692
|
-
})
|
|
8693
|
-
)
|
|
8694
|
-
);
|
|
8695
|
-
}
|
|
8696
|
-
async function runFactoryPipeline(items, ...stages) {
|
|
8697
|
-
if (!Array.isArray(items)) {
|
|
8698
|
-
throw new Error("pipeline(items, ...stages): items must be an array");
|
|
8699
|
-
}
|
|
8700
|
-
assertFactoryFanoutSize("pipeline", items.length);
|
|
8701
|
-
return Promise.all(
|
|
8702
|
-
items.map(async (item, index) => {
|
|
8703
|
-
let previous = item;
|
|
8704
|
-
for (const stage of stages) {
|
|
8705
|
-
try {
|
|
8706
|
-
previous = await runInFactoryHelperScope(
|
|
8707
|
-
"pipeline",
|
|
8708
|
-
() => stage(previous, item, index)
|
|
8709
|
-
);
|
|
8710
|
-
} catch (error) {
|
|
8711
|
-
if (isFactoryFatalError(error)) {
|
|
8712
|
-
throw error;
|
|
8713
|
-
}
|
|
8714
|
-
return null;
|
|
8715
|
-
}
|
|
8716
|
-
}
|
|
8717
|
-
return previous;
|
|
8718
|
-
})
|
|
8719
|
-
);
|
|
8720
|
-
}
|
|
8721
8640
|
async function runWorkflowParallel(thunks) {
|
|
8722
8641
|
if (!Array.isArray(thunks)) {
|
|
8723
8642
|
throw new Error(
|
|
8724
8643
|
"parallel() expects an array of functions, not promises. Wrap each call: () => agent(...)"
|
|
8725
8644
|
);
|
|
8726
8645
|
}
|
|
8727
|
-
|
|
8646
|
+
assertWorkflowFanoutSize("parallel", thunks.length);
|
|
8728
8647
|
if (thunks.some((thunk) => typeof thunk !== "function")) {
|
|
8729
8648
|
throw new Error(
|
|
8730
8649
|
"parallel() expects an array of functions, not promises. Wrap each call: () => agent(...)"
|
|
@@ -8733,7 +8652,7 @@ async function runWorkflowParallel(thunks) {
|
|
|
8733
8652
|
return Promise.all(
|
|
8734
8653
|
thunks.map(
|
|
8735
8654
|
(thunk) => Promise.resolve().then(() => runInWorkflowHelperScope("parallel", thunk)).catch((error) => {
|
|
8736
|
-
if (
|
|
8655
|
+
if (isWorkflowFatalError(error)) {
|
|
8737
8656
|
throw error;
|
|
8738
8657
|
}
|
|
8739
8658
|
return null;
|
|
@@ -8745,7 +8664,7 @@ async function runWorkflowPipeline(items, ...stages) {
|
|
|
8745
8664
|
if (!Array.isArray(items)) {
|
|
8746
8665
|
throw new Error("pipeline(items, ...stages): items must be an array");
|
|
8747
8666
|
}
|
|
8748
|
-
|
|
8667
|
+
assertWorkflowFanoutSize("pipeline", items.length);
|
|
8749
8668
|
return Promise.all(
|
|
8750
8669
|
items.map(async (item, index) => {
|
|
8751
8670
|
let previous = item;
|
|
@@ -8756,7 +8675,7 @@ async function runWorkflowPipeline(items, ...stages) {
|
|
|
8756
8675
|
() => stage(previous, item, index)
|
|
8757
8676
|
);
|
|
8758
8677
|
} catch (error) {
|
|
8759
|
-
if (
|
|
8678
|
+
if (isWorkflowFatalError(error)) {
|
|
8760
8679
|
throw error;
|
|
8761
8680
|
}
|
|
8762
8681
|
return null;
|
|
@@ -8766,85 +8685,6 @@ async function runWorkflowPipeline(items, ...stages) {
|
|
|
8766
8685
|
})
|
|
8767
8686
|
);
|
|
8768
8687
|
}
|
|
8769
|
-
var FactoryProgressBuffer = class {
|
|
8770
|
-
constructor(send) {
|
|
8771
|
-
this.send = send;
|
|
8772
|
-
}
|
|
8773
|
-
send;
|
|
8774
|
-
nextSeq = 0;
|
|
8775
|
-
pending = [];
|
|
8776
|
-
flushTimer;
|
|
8777
|
-
flushTail = Promise.resolve();
|
|
8778
|
-
flushError;
|
|
8779
|
-
flushFailed = false;
|
|
8780
|
-
closed = false;
|
|
8781
|
-
enqueue(kind, text) {
|
|
8782
|
-
if (this.closed) {
|
|
8783
|
-
throw new Error("Cannot log after the factory run has settled");
|
|
8784
|
-
}
|
|
8785
|
-
this.pending.push({ seq: this.nextSeq++, kind, text });
|
|
8786
|
-
this.scheduleFlush();
|
|
8787
|
-
}
|
|
8788
|
-
async flush() {
|
|
8789
|
-
this.clearFlushTimer();
|
|
8790
|
-
const lines = this.pending.splice(0);
|
|
8791
|
-
if (lines.length > 0) {
|
|
8792
|
-
this.flushTail = this.flushTail.then(async () => {
|
|
8793
|
-
try {
|
|
8794
|
-
await this.send(lines);
|
|
8795
|
-
} catch (error) {
|
|
8796
|
-
if (!this.flushFailed) {
|
|
8797
|
-
this.flushFailed = true;
|
|
8798
|
-
this.flushError = error;
|
|
8799
|
-
}
|
|
8800
|
-
}
|
|
8801
|
-
});
|
|
8802
|
-
}
|
|
8803
|
-
await this.flushTail;
|
|
8804
|
-
if (this.flushFailed) {
|
|
8805
|
-
throw this.flushError;
|
|
8806
|
-
}
|
|
8807
|
-
}
|
|
8808
|
-
async close() {
|
|
8809
|
-
this.closed = true;
|
|
8810
|
-
this.clearFlushTimer();
|
|
8811
|
-
const lines = this.pending.splice(0);
|
|
8812
|
-
await this.flushTail;
|
|
8813
|
-
if (this.flushFailed) {
|
|
8814
|
-
console.warn(
|
|
8815
|
-
"Ignoring a background factory progress flush failure after the factory body settled",
|
|
8816
|
-
this.flushError
|
|
8817
|
-
);
|
|
8818
|
-
}
|
|
8819
|
-
if (lines.length > 0) {
|
|
8820
|
-
try {
|
|
8821
|
-
await this.send(lines);
|
|
8822
|
-
} catch (error) {
|
|
8823
|
-
console.warn(
|
|
8824
|
-
"Failed to flush final factory progress after the factory body settled",
|
|
8825
|
-
error
|
|
8826
|
-
);
|
|
8827
|
-
}
|
|
8828
|
-
}
|
|
8829
|
-
}
|
|
8830
|
-
scheduleFlush() {
|
|
8831
|
-
if (this.flushTimer !== void 0) {
|
|
8832
|
-
return;
|
|
8833
|
-
}
|
|
8834
|
-
this.flushTimer = setTimeout(() => {
|
|
8835
|
-
this.flushTimer = void 0;
|
|
8836
|
-
void this.flush().catch(() => {
|
|
8837
|
-
});
|
|
8838
|
-
}, FACTORY_LOG_FLUSH_DELAY_MS);
|
|
8839
|
-
this.flushTimer.unref?.();
|
|
8840
|
-
}
|
|
8841
|
-
clearFlushTimer() {
|
|
8842
|
-
if (this.flushTimer !== void 0) {
|
|
8843
|
-
clearTimeout(this.flushTimer);
|
|
8844
|
-
this.flushTimer = void 0;
|
|
8845
|
-
}
|
|
8846
|
-
}
|
|
8847
|
-
};
|
|
8848
8688
|
var WorkflowProgressBuffer = class {
|
|
8849
8689
|
constructor(send) {
|
|
8850
8690
|
this.send = send;
|
|
@@ -8924,38 +8764,30 @@ var WorkflowProgressBuffer = class {
|
|
|
8924
8764
|
}
|
|
8925
8765
|
}
|
|
8926
8766
|
};
|
|
8927
|
-
async function
|
|
8767
|
+
async function awaitWorkflowOperation(operation, signal) {
|
|
8928
8768
|
let rejectAbort;
|
|
8929
8769
|
const abortPromise = new Promise((_resolve, reject) => {
|
|
8930
8770
|
rejectAbort = reject;
|
|
8931
8771
|
});
|
|
8932
|
-
const onAbort = () => rejectAbort?.(signal.reason ?? new DOMException("
|
|
8772
|
+
const onAbort = () => rejectAbort?.(signal.reason ?? new DOMException("Workflow run was aborted", "AbortError"));
|
|
8933
8773
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
8934
8774
|
try {
|
|
8935
|
-
|
|
8775
|
+
throwIfWorkflowAborted(signal);
|
|
8936
8776
|
return await Promise.race([operation(), abortPromise]);
|
|
8937
8777
|
} finally {
|
|
8938
8778
|
signal.removeEventListener("abort", onAbort);
|
|
8939
8779
|
}
|
|
8940
8780
|
}
|
|
8941
|
-
async function awaitWorkflowOperation(operation, signal) {
|
|
8942
|
-
return awaitFactoryOperation(operation, signal);
|
|
8943
|
-
}
|
|
8944
|
-
function throwIfFactoryAborted(signal) {
|
|
8945
|
-
if (signal.aborted) {
|
|
8946
|
-
throw signal.reason ?? new DOMException("Factory run was aborted", "AbortError");
|
|
8947
|
-
}
|
|
8948
|
-
}
|
|
8949
8781
|
function throwIfWorkflowAborted(signal) {
|
|
8950
8782
|
if (signal.aborted) {
|
|
8951
8783
|
throw signal.reason ?? new DOMException("Workflow run was aborted", "AbortError");
|
|
8952
8784
|
}
|
|
8953
8785
|
}
|
|
8954
|
-
function
|
|
8786
|
+
function isWorkflowAbortError(error) {
|
|
8955
8787
|
return typeof error === "object" && error !== null && "name" in error && error.name === "AbortError";
|
|
8956
8788
|
}
|
|
8957
|
-
function
|
|
8958
|
-
return
|
|
8789
|
+
function isWorkflowFatalError(error) {
|
|
8790
|
+
return isWorkflowAbortError(error) || error instanceof import_node.ResponseError || error instanceof import_node.ConnectionError;
|
|
8959
8791
|
}
|
|
8960
8792
|
var TOOL_SEARCH_TOOL_NAME = "tool_search_tool";
|
|
8961
8793
|
var CopilotSession = class {
|
|
@@ -8987,8 +8819,6 @@ var CopilotSession = class {
|
|
|
8987
8819
|
canvases = /* @__PURE__ */ new Map();
|
|
8988
8820
|
bearerTokenProviders = /* @__PURE__ */ new Map();
|
|
8989
8821
|
commandHandlers = /* @__PURE__ */ new Map();
|
|
8990
|
-
factories = /* @__PURE__ */ new Map();
|
|
8991
|
-
factoryAbortControllers = /* @__PURE__ */ new Map();
|
|
8992
8822
|
workflows = /* @__PURE__ */ new Map();
|
|
8993
8823
|
workflowAbortControllers = /* @__PURE__ */ new Map();
|
|
8994
8824
|
permissionHandler;
|
|
@@ -9006,74 +8836,17 @@ var CopilotSession = class {
|
|
|
9006
8836
|
_capabilities = {};
|
|
9007
8837
|
openCanvasInstances = [];
|
|
9008
8838
|
disconnected = false;
|
|
9009
|
-
pendingStructuredWaits = /* @__PURE__ */ new Set();
|
|
9010
|
-
disconnecting = false;
|
|
9011
|
-
onDisconnected;
|
|
9012
|
-
/** @internal Client session API handlers, populated by CopilotClient during create/resume. */
|
|
9013
|
-
clientSessionApis = {};
|
|
9014
|
-
/**
|
|
9015
|
-
* Friendly
|
|
9016
|
-
*
|
|
9017
|
-
* @experimental Part of the experimental
|
|
9018
|
-
* change or be removed in future SDK or CLI releases.
|
|
9019
|
-
*/
|
|
9020
|
-
factory = {
|
|
9021
|
-
run: (async (nameOrHandle, options) => {
|
|
9022
|
-
throwIfFactoryExecutionIsActive();
|
|
9023
|
-
const name = typeof nameOrHandle === "string" ? nameOrHandle : getFactoryDefinition(nameOrHandle).meta.name;
|
|
9024
|
-
if (options?.resumeFromRunId !== void 0) {
|
|
9025
|
-
return this.factory.resume(options.resumeFromRunId, {
|
|
9026
|
-
limits: options.limits,
|
|
9027
|
-
notifyOnComplete: options.notifyOnComplete,
|
|
9028
|
-
logPhaseNames: options.logPhaseNames
|
|
9029
|
-
});
|
|
9030
|
-
}
|
|
9031
|
-
const envelope = await this.rpc.factory.run({
|
|
9032
|
-
name,
|
|
9033
|
-
args: options?.args === void 0 ? {} : options.args,
|
|
9034
|
-
options: {
|
|
9035
|
-
limits: options?.limits,
|
|
9036
|
-
notifyOnComplete: options?.notifyOnComplete,
|
|
9037
|
-
logPhaseNames: options?.logPhaseNames
|
|
9038
|
-
}
|
|
9039
|
-
});
|
|
9040
|
-
return this.settleFactoryRun(envelope);
|
|
9041
|
-
}),
|
|
9042
|
-
resume: (async (runId, options) => {
|
|
9043
|
-
throwIfFactoryExecutionIsActive();
|
|
9044
|
-
let response;
|
|
9045
|
-
try {
|
|
9046
|
-
response = await this.rpc.factory.resume({
|
|
9047
|
-
runId,
|
|
9048
|
-
limits: options?.limits,
|
|
9049
|
-
notifyOnComplete: options?.notifyOnComplete,
|
|
9050
|
-
logPhaseNames: options?.logPhaseNames
|
|
9051
|
-
});
|
|
9052
|
-
} catch (error) {
|
|
9053
|
-
if (error instanceof import_node.ResponseError && typeof error.data === "object" && error.data !== null) {
|
|
9054
|
-
const code = error.data.code;
|
|
9055
|
-
if (isFactoryResumeErrorCode(code)) {
|
|
9056
|
-
throw new FactoryResumeError(code, error.message);
|
|
9057
|
-
}
|
|
9058
|
-
}
|
|
9059
|
-
throw error;
|
|
9060
|
-
}
|
|
9061
|
-
return this.settleFactoryRun(response.run);
|
|
9062
|
-
}),
|
|
9063
|
-
getRun: async (runId) => this.rpc.factory.getRun({ runId }),
|
|
9064
|
-
waitForRun: (runId, options) => this.waitForFactoryRun(runId, options?.signal),
|
|
9065
|
-
listRuns: (async (options) => {
|
|
9066
|
-
const page = await this.rpc.factory.listRuns(options ?? {});
|
|
9067
|
-
return options === void 0 ? page.runs : page;
|
|
9068
|
-
}),
|
|
9069
|
-
getRunDetail: (runId) => this.rpc.factory.getRunDetail({ runId }),
|
|
9070
|
-
getRunProgress: (runId, options = {}) => this.rpc.factory.getRunProgress({ runId, ...options }),
|
|
9071
|
-
pause: async (runId) => {
|
|
9072
|
-
throwIfFactoryExecutionIsActive();
|
|
9073
|
-
return this.rpc.factory.pause({ runId });
|
|
9074
|
-
},
|
|
9075
|
-
cancel: async (runId) => this.rpc.factory.cancel({ runId })
|
|
9076
|
-
};
|
|
8839
|
+
pendingStructuredWaits = /* @__PURE__ */ new Set();
|
|
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
|
+
*/
|
|
9077
8850
|
workflow = {
|
|
9078
8851
|
run: (async (nameOrHandle, options) => {
|
|
9079
8852
|
throwIfWorkflowExecutionIsActive();
|
|
@@ -9124,93 +8897,6 @@ var CopilotSession = class {
|
|
|
9124
8897
|
},
|
|
9125
8898
|
cancel: async (runId) => this.rpc.workflow.cancel({ runId })
|
|
9126
8899
|
};
|
|
9127
|
-
/**
|
|
9128
|
-
* Resolve a start/resume envelope into the terminal envelope callers expect.
|
|
9129
|
-
*
|
|
9130
|
-
* The CLI may answer `session.factory.run` and `session.factory.resume`
|
|
9131
|
-
* before the run settles, so a non-terminal envelope is followed by a wait
|
|
9132
|
-
* on the run's terminal state.
|
|
9133
|
-
*/
|
|
9134
|
-
settleFactoryRun(envelope) {
|
|
9135
|
-
if (isFactoryRunTerminal(envelope.status)) {
|
|
9136
|
-
return Promise.resolve(envelope);
|
|
9137
|
-
}
|
|
9138
|
-
return this.waitForFactoryRun(envelope.runId);
|
|
9139
|
-
}
|
|
9140
|
-
/**
|
|
9141
|
-
* Resolve when a factory run reaches a terminal status.
|
|
9142
|
-
*
|
|
9143
|
-
* The subscription is installed *before* the first read so a transition
|
|
9144
|
-
* landing between the two cannot be missed, and re-reads are serialized so
|
|
9145
|
-
* overlapping invalidation events cannot interleave — the run's revision
|
|
9146
|
-
* advances once per operation, so a burst of events is common and must
|
|
9147
|
-
* collapse into a single in-flight read. A bounded periodic re-read keeps a
|
|
9148
|
-
* dropped invalidation from leaving the wait pending forever.
|
|
9149
|
-
*/
|
|
9150
|
-
waitForFactoryRun(runId, signal) {
|
|
9151
|
-
const abortError = () => signal?.reason ?? new DOMException("Factory run wait was aborted", "AbortError");
|
|
9152
|
-
if (signal?.aborted === true) {
|
|
9153
|
-
return Promise.reject(abortError());
|
|
9154
|
-
}
|
|
9155
|
-
return new Promise((resolve3, reject) => {
|
|
9156
|
-
let settled = false;
|
|
9157
|
-
let reading = false;
|
|
9158
|
-
let rereadRequested = false;
|
|
9159
|
-
let pollHandle;
|
|
9160
|
-
let unsubscribe;
|
|
9161
|
-
let onAbort;
|
|
9162
|
-
const finish = (complete) => {
|
|
9163
|
-
if (settled) {
|
|
9164
|
-
return;
|
|
9165
|
-
}
|
|
9166
|
-
settled = true;
|
|
9167
|
-
if (pollHandle !== void 0) {
|
|
9168
|
-
clearInterval(pollHandle);
|
|
9169
|
-
}
|
|
9170
|
-
unsubscribe?.();
|
|
9171
|
-
if (onAbort !== void 0) {
|
|
9172
|
-
signal?.removeEventListener("abort", onAbort);
|
|
9173
|
-
}
|
|
9174
|
-
complete();
|
|
9175
|
-
};
|
|
9176
|
-
const read = async () => {
|
|
9177
|
-
if (settled) {
|
|
9178
|
-
return;
|
|
9179
|
-
}
|
|
9180
|
-
if (reading) {
|
|
9181
|
-
rereadRequested = true;
|
|
9182
|
-
return;
|
|
9183
|
-
}
|
|
9184
|
-
reading = true;
|
|
9185
|
-
try {
|
|
9186
|
-
do {
|
|
9187
|
-
rereadRequested = false;
|
|
9188
|
-
const envelope = await this.rpc.factory.getRun({ runId });
|
|
9189
|
-
if (isFactoryRunTerminal(envelope.status)) {
|
|
9190
|
-
finish(() => resolve3(envelope));
|
|
9191
|
-
return;
|
|
9192
|
-
}
|
|
9193
|
-
} while (rereadRequested && !settled);
|
|
9194
|
-
} catch (error) {
|
|
9195
|
-
finish(() => reject(error));
|
|
9196
|
-
} finally {
|
|
9197
|
-
reading = false;
|
|
9198
|
-
}
|
|
9199
|
-
};
|
|
9200
|
-
if (signal !== void 0) {
|
|
9201
|
-
onAbort = () => finish(() => reject(abortError()));
|
|
9202
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
9203
|
-
}
|
|
9204
|
-
unsubscribe = this.on("factory.run_updated", (event) => {
|
|
9205
|
-
if (event.data.runId === runId) {
|
|
9206
|
-
void read();
|
|
9207
|
-
}
|
|
9208
|
-
});
|
|
9209
|
-
pollHandle = setInterval(() => void read(), 5e3);
|
|
9210
|
-
pollHandle.unref?.();
|
|
9211
|
-
void read();
|
|
9212
|
-
});
|
|
9213
|
-
}
|
|
9214
8900
|
settleWorkflowRun(envelope) {
|
|
9215
8901
|
if (isWorkflowRunTerminal(envelope.status)) {
|
|
9216
8902
|
return Promise.resolve(envelope);
|
|
@@ -9281,7 +8967,7 @@ var CopilotSession = class {
|
|
|
9281
8967
|
onAbort = () => finish(() => reject(abortError()));
|
|
9282
8968
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
9283
8969
|
}
|
|
9284
|
-
unsubscribe = this.on("
|
|
8970
|
+
unsubscribe = this.on("workflow.run_updated", (event) => {
|
|
9285
8971
|
if (event.data.runId === runId) {
|
|
9286
8972
|
void read();
|
|
9287
8973
|
}
|
|
@@ -9547,13 +9233,6 @@ var CopilotSession = class {
|
|
|
9547
9233
|
this.autoModeSwitchHandler = void 0;
|
|
9548
9234
|
this.commandHandlers.clear();
|
|
9549
9235
|
this.canvases.clear();
|
|
9550
|
-
this.factories.clear();
|
|
9551
|
-
for (const controllersForRun of this.factoryAbortControllers.values()) {
|
|
9552
|
-
for (const controller of controllersForRun.values()) {
|
|
9553
|
-
controller.abort();
|
|
9554
|
-
}
|
|
9555
|
-
}
|
|
9556
|
-
this.factoryAbortControllers.clear();
|
|
9557
9236
|
this.workflows.clear();
|
|
9558
9237
|
for (const controllersForRun of this.workflowAbortControllers.values()) {
|
|
9559
9238
|
for (const controller of controllersForRun.values()) {
|
|
@@ -10008,192 +9687,6 @@ var CopilotSession = class {
|
|
|
10008
9687
|
}
|
|
10009
9688
|
};
|
|
10010
9689
|
}
|
|
10011
|
-
/**
|
|
10012
|
-
* Registers factory closures and reverse-RPC handlers for this session.
|
|
10013
|
-
*
|
|
10014
|
-
* @param factories - Factory handles declared by the joining extension.
|
|
10015
|
-
* @internal Called by the SDK when an extension joins a session.
|
|
10016
|
-
*/
|
|
10017
|
-
registerFactories(factories) {
|
|
10018
|
-
this.factories.clear();
|
|
10019
|
-
if (!factories || factories.length === 0) {
|
|
10020
|
-
delete this.clientSessionApis.factory;
|
|
10021
|
-
return;
|
|
10022
|
-
}
|
|
10023
|
-
for (const handle of factories) {
|
|
10024
|
-
const definition = getFactoryDefinition(handle);
|
|
10025
|
-
if (this.factories.has(definition.meta.name)) {
|
|
10026
|
-
throw new Error(
|
|
10027
|
-
`Duplicate factory name "${definition.meta.name}". Factory names must be unique within a joinSession call.`
|
|
10028
|
-
);
|
|
10029
|
-
}
|
|
10030
|
-
this.factories.set(definition.meta.name, definition);
|
|
10031
|
-
}
|
|
10032
|
-
const self = this;
|
|
10033
|
-
this.clientSessionApis.factory = {
|
|
10034
|
-
async execute(params) {
|
|
10035
|
-
const definition = self.factories.get(params.name);
|
|
10036
|
-
if (!definition) {
|
|
10037
|
-
const message = `No factory registered with name "${params.name}"`;
|
|
10038
|
-
throw new import_node.ResponseError(import_node.ErrorCodes.InvalidParams, message, {
|
|
10039
|
-
code: "factory_not_found",
|
|
10040
|
-
name: params.name
|
|
10041
|
-
});
|
|
10042
|
-
}
|
|
10043
|
-
const controller = new AbortController();
|
|
10044
|
-
let controllersForRun = self.factoryAbortControllers.get(params.runId);
|
|
10045
|
-
if (controllersForRun === void 0) {
|
|
10046
|
-
controllersForRun = /* @__PURE__ */ new Map();
|
|
10047
|
-
self.factoryAbortControllers.set(params.runId, controllersForRun);
|
|
10048
|
-
}
|
|
10049
|
-
controllersForRun.set(params.executionToken, controller);
|
|
10050
|
-
const progress = new FactoryProgressBuffer(async (lines) => {
|
|
10051
|
-
await self.rpc.factory.log({
|
|
10052
|
-
runId: params.runId,
|
|
10053
|
-
executionToken: params.executionToken,
|
|
10054
|
-
lines
|
|
10055
|
-
});
|
|
10056
|
-
});
|
|
10057
|
-
try {
|
|
10058
|
-
const context = {
|
|
10059
|
-
runId: params.runId,
|
|
10060
|
-
args: params.args,
|
|
10061
|
-
session: self,
|
|
10062
|
-
signal: controller.signal,
|
|
10063
|
-
phase: (title) => {
|
|
10064
|
-
throwIfFactoryAborted(controller.signal);
|
|
10065
|
-
progress.enqueue("phase", title);
|
|
10066
|
-
},
|
|
10067
|
-
log: (message) => {
|
|
10068
|
-
throwIfFactoryAborted(controller.signal);
|
|
10069
|
-
progress.enqueue("log", message);
|
|
10070
|
-
},
|
|
10071
|
-
agent: async (prompt, options = {}) => {
|
|
10072
|
-
await progress.flush();
|
|
10073
|
-
const opts = {};
|
|
10074
|
-
for (const key of FACTORY_AGENT_OPTION_KEYS) {
|
|
10075
|
-
copyDefinedFactoryAgentOption(options, opts, key);
|
|
10076
|
-
}
|
|
10077
|
-
const response = await awaitFactoryOperation(
|
|
10078
|
-
() => self.rpc.factory.agent({
|
|
10079
|
-
factoryRunId: params.runId,
|
|
10080
|
-
executionToken: params.executionToken,
|
|
10081
|
-
prompt,
|
|
10082
|
-
opts
|
|
10083
|
-
}),
|
|
10084
|
-
controller.signal
|
|
10085
|
-
);
|
|
10086
|
-
return response.result ?? null;
|
|
10087
|
-
},
|
|
10088
|
-
step: async (key, producer, options = {}) => {
|
|
10089
|
-
await progress.flush();
|
|
10090
|
-
if (options.volatile) {
|
|
10091
|
-
throwIfFactoryAborted(controller.signal);
|
|
10092
|
-
return producer();
|
|
10093
|
-
}
|
|
10094
|
-
const cached = await awaitFactoryOperation(
|
|
10095
|
-
() => self.rpc.factory.journal.get({
|
|
10096
|
-
runId: params.runId,
|
|
10097
|
-
executionToken: params.executionToken,
|
|
10098
|
-
key
|
|
10099
|
-
}),
|
|
10100
|
-
controller.signal
|
|
10101
|
-
);
|
|
10102
|
-
if (cached.hit) {
|
|
10103
|
-
if (cached.resultJson === void 0) {
|
|
10104
|
-
throw new Error(
|
|
10105
|
-
`step("${key}") journal returned a hit without a result`
|
|
10106
|
-
);
|
|
10107
|
-
}
|
|
10108
|
-
assertFactoryStepResult(cached.resultJson, key);
|
|
10109
|
-
return cached.resultJson;
|
|
10110
|
-
}
|
|
10111
|
-
const result2 = await producer();
|
|
10112
|
-
assertFactoryStepResult(result2, key);
|
|
10113
|
-
await awaitFactoryOperation(
|
|
10114
|
-
() => self.rpc.factory.journal.put({
|
|
10115
|
-
runId: params.runId,
|
|
10116
|
-
executionToken: params.executionToken,
|
|
10117
|
-
key,
|
|
10118
|
-
resultJson: result2
|
|
10119
|
-
}),
|
|
10120
|
-
controller.signal
|
|
10121
|
-
);
|
|
10122
|
-
return result2;
|
|
10123
|
-
},
|
|
10124
|
-
pause: async (key) => {
|
|
10125
|
-
if (typeof key !== "string" || key.length === 0) {
|
|
10126
|
-
throw new Error("Factory pause checkpoint key must not be empty");
|
|
10127
|
-
}
|
|
10128
|
-
const helperScope = factoryExecutionStore.getStore()?.helperScope;
|
|
10129
|
-
if (helperScope !== void 0) {
|
|
10130
|
-
throw new Error(
|
|
10131
|
-
`Factory pause checkpoints are not allowed inside ${helperScope}() branches`
|
|
10132
|
-
);
|
|
10133
|
-
}
|
|
10134
|
-
await progress.flush();
|
|
10135
|
-
const response = await awaitFactoryOperation(
|
|
10136
|
-
() => self.internalRpc.factory.pauseAtCheckpoint({
|
|
10137
|
-
runId: params.runId,
|
|
10138
|
-
executionToken: params.executionToken,
|
|
10139
|
-
key
|
|
10140
|
-
}),
|
|
10141
|
-
controller.signal
|
|
10142
|
-
);
|
|
10143
|
-
switch (response.action) {
|
|
10144
|
-
case "continue":
|
|
10145
|
-
return;
|
|
10146
|
-
case "pause":
|
|
10147
|
-
await awaitFactoryOperation(
|
|
10148
|
-
() => new Promise(() => {
|
|
10149
|
-
}),
|
|
10150
|
-
controller.signal
|
|
10151
|
-
);
|
|
10152
|
-
}
|
|
10153
|
-
},
|
|
10154
|
-
parallel: runFactoryParallel,
|
|
10155
|
-
pipeline: runFactoryPipeline,
|
|
10156
|
-
factory: async () => {
|
|
10157
|
-
throw new Error("nested factories are not supported");
|
|
10158
|
-
}
|
|
10159
|
-
};
|
|
10160
|
-
const execution = { active: true };
|
|
10161
|
-
const result = await factoryExecutionStore.run(execution, async () => {
|
|
10162
|
-
try {
|
|
10163
|
-
return await definition.run(context);
|
|
10164
|
-
} finally {
|
|
10165
|
-
execution.active = false;
|
|
10166
|
-
}
|
|
10167
|
-
});
|
|
10168
|
-
if (result === void 0) {
|
|
10169
|
-
return {};
|
|
10170
|
-
}
|
|
10171
|
-
assertFactoryResult(result);
|
|
10172
|
-
return { result };
|
|
10173
|
-
} finally {
|
|
10174
|
-
try {
|
|
10175
|
-
await progress.close();
|
|
10176
|
-
} finally {
|
|
10177
|
-
const controllersForRun2 = self.factoryAbortControllers.get(params.runId);
|
|
10178
|
-
if (controllersForRun2?.get(params.executionToken) === controller) {
|
|
10179
|
-
controllersForRun2.delete(params.executionToken);
|
|
10180
|
-
if (controllersForRun2.size === 0) {
|
|
10181
|
-
self.factoryAbortControllers.delete(params.runId);
|
|
10182
|
-
}
|
|
10183
|
-
}
|
|
10184
|
-
}
|
|
10185
|
-
}
|
|
10186
|
-
},
|
|
10187
|
-
async abort(params) {
|
|
10188
|
-
const controllersForRun = self.factoryAbortControllers.get(params.runId);
|
|
10189
|
-
const controller = controllersForRun?.get(params.executionToken);
|
|
10190
|
-
if (controller !== void 0) {
|
|
10191
|
-
controller.abort(new DOMException("Factory run was aborted", "AbortError"));
|
|
10192
|
-
}
|
|
10193
|
-
return {};
|
|
10194
|
-
}
|
|
10195
|
-
};
|
|
10196
|
-
}
|
|
10197
9690
|
/**
|
|
10198
9691
|
* Registers workflow closures and reverse-RPC handlers for this session.
|
|
10199
9692
|
*
|
|
@@ -11060,20 +10553,6 @@ function assertStrictJson(value, context) {
|
|
|
11060
10553
|
};
|
|
11061
10554
|
visit(value, "$", context.allowTopLevelUndefined);
|
|
11062
10555
|
}
|
|
11063
|
-
function assertFactoryResult(value) {
|
|
11064
|
-
assertStrictJson(value, {
|
|
11065
|
-
code: "factory_result_not_json",
|
|
11066
|
-
label: "Factory result",
|
|
11067
|
-
allowTopLevelUndefined: true
|
|
11068
|
-
});
|
|
11069
|
-
}
|
|
11070
|
-
function assertFactoryStepResult(value, key) {
|
|
11071
|
-
assertStrictJson(value, {
|
|
11072
|
-
code: "factory_step_not_json",
|
|
11073
|
-
label: `Factory step "${key}" result`,
|
|
11074
|
-
allowTopLevelUndefined: false
|
|
11075
|
-
});
|
|
11076
|
-
}
|
|
11077
10556
|
function assertWorkflowResult(value) {
|
|
11078
10557
|
assertStrictJson(value, {
|
|
11079
10558
|
code: "workflow_result_not_json",
|
|
@@ -11304,6 +10783,79 @@ async function ensureRuntimeBundle(version2, options = {}) {
|
|
|
11304
10783
|
return wrapper;
|
|
11305
10784
|
}
|
|
11306
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
|
+
|
|
11307
10859
|
// src/sdk/nodejs/dist/toolSet.js
|
|
11308
10860
|
var VALID_TOOL_NAME = /^[a-zA-Z0-9_-]+$/;
|
|
11309
10861
|
function validateName(kind, name) {
|
|
@@ -11521,7 +11073,7 @@ function getNodeExecPath() {
|
|
|
11521
11073
|
function getBundledRuntimePath() {
|
|
11522
11074
|
return ensureRuntimeBundle(COPILOT_CLI_VERSION);
|
|
11523
11075
|
}
|
|
11524
|
-
var TeardownResilientStreamMessageWriter = class extends
|
|
11076
|
+
var TeardownResilientStreamMessageWriter = class extends import_node3.StreamMessageWriter {
|
|
11525
11077
|
suppressWriteErrors = false;
|
|
11526
11078
|
async write(msg) {
|
|
11527
11079
|
try {
|
|
@@ -11577,6 +11129,7 @@ var CopilotClient = class _CopilotClient {
|
|
|
11577
11129
|
sessionFsConfig = null;
|
|
11578
11130
|
requestHandler = null;
|
|
11579
11131
|
extensionLaunchProvider;
|
|
11132
|
+
installationConfirmationHandler;
|
|
11580
11133
|
builtinPluginDirectories = [];
|
|
11581
11134
|
onGitHubTelemetry;
|
|
11582
11135
|
clientGlobalHandlers = {};
|
|
@@ -11735,6 +11288,7 @@ var CopilotClient = class _CopilotClient {
|
|
|
11735
11288
|
this.sessionFsConfig = options.sessionFs ?? null;
|
|
11736
11289
|
this.requestHandler = options.requestHandler ?? null;
|
|
11737
11290
|
this.extensionLaunchProvider = options.extensionLaunchProvider;
|
|
11291
|
+
this.installationConfirmationHandler = options.installationConfirmationHandler;
|
|
11738
11292
|
this.onGitHubTelemetry = options.onGitHubTelemetry;
|
|
11739
11293
|
this.setupClientGlobalHandlers();
|
|
11740
11294
|
const connEnv = conn.kind === "stdio" || conn.kind === "tcp" ? conn.env : void 0;
|
|
@@ -12651,14 +12205,12 @@ var CopilotClient = class _CopilotClient {
|
|
|
12651
12205
|
async resumeSession(sessionId, config) {
|
|
12652
12206
|
return this.resumeSessionInternal(sessionId, config);
|
|
12653
12207
|
}
|
|
12208
|
+
/** @internal */
|
|
12654
12209
|
async resumeSessionForExtension(sessionId, config, contributions = {}, extensionOptions) {
|
|
12655
12210
|
return this.resumeSessionInternal(sessionId, config, contributions, extensionOptions);
|
|
12656
12211
|
}
|
|
12657
12212
|
async resumeSessionInternal(sessionId, config, contributions = {}, extensionOptions) {
|
|
12658
|
-
const {
|
|
12659
|
-
if (factories !== void 0 && workflows !== void 0) {
|
|
12660
|
-
throw new Error("Session configuration cannot include both factories and workflows");
|
|
12661
|
-
}
|
|
12213
|
+
const { workflows } = contributions;
|
|
12662
12214
|
if (config.gitHubToken !== void 0 && config.gitHubTokenProvider !== void 0) {
|
|
12663
12215
|
throw new Error("gitHubToken and gitHubTokenProvider are mutually exclusive");
|
|
12664
12216
|
}
|
|
@@ -12678,7 +12230,6 @@ var CopilotClient = class _CopilotClient {
|
|
|
12678
12230
|
session.registerTools(config.tools);
|
|
12679
12231
|
session.registerCanvases(config.canvases);
|
|
12680
12232
|
session.registerCommands(config.commands);
|
|
12681
|
-
session.registerFactories(factories);
|
|
12682
12233
|
session.registerWorkflows(workflows);
|
|
12683
12234
|
const {
|
|
12684
12235
|
wireProvider: bearerWireProvider,
|
|
@@ -12760,7 +12311,6 @@ var CopilotClient = class _CopilotClient {
|
|
|
12760
12311
|
})),
|
|
12761
12312
|
toolSearch: config.toolSearch,
|
|
12762
12313
|
canvases: config.canvases?.map((canvas) => canvas.declaration),
|
|
12763
|
-
factories: factories?.map((factory) => factory.meta),
|
|
12764
12314
|
workflows: workflows?.map((workflow) => workflow.meta),
|
|
12765
12315
|
requestCanvasRenderer: config.requestCanvasRenderer,
|
|
12766
12316
|
requestExtensions: config.requestExtensions,
|
|
@@ -12983,7 +12533,7 @@ var CopilotClient = class _CopilotClient {
|
|
|
12983
12533
|
const result = await raceAgainstExit(this.internalRpc.connect(connectParams));
|
|
12984
12534
|
serverVersion = result.protocolVersion;
|
|
12985
12535
|
} catch (err) {
|
|
12986
|
-
if (err instanceof
|
|
12536
|
+
if (err instanceof import_node3.ResponseError && (err.code === import_node3.ErrorCodes.MethodNotFound || err.message === "Unhandled method connect")) {
|
|
12987
12537
|
serverVersion = (await raceAgainstExit(this.ping())).protocolVersion;
|
|
12988
12538
|
} else {
|
|
12989
12539
|
throw err;
|
|
@@ -13223,6 +12773,9 @@ var CopilotClient = class _CopilotClient {
|
|
|
13223
12773
|
if (this.options.mode === "empty") {
|
|
13224
12774
|
env.COPILOT_DISABLE_KEYTAR = "1";
|
|
13225
12775
|
}
|
|
12776
|
+
if (this.options.mode !== "empty") {
|
|
12777
|
+
env.COPILOT_RUNTIME_PROCESS_FILE_LOGGING = "1";
|
|
12778
|
+
}
|
|
13226
12779
|
if (this.options.telemetry) {
|
|
13227
12780
|
const t = this.options.telemetry;
|
|
13228
12781
|
env.COPILOT_OTEL_ENABLED = "true";
|
|
@@ -13458,8 +13011,8 @@ stderr: ${stderrOutput}`
|
|
|
13458
13011
|
throw new Error("In-process FFI runtime host not started");
|
|
13459
13012
|
}
|
|
13460
13013
|
this.messageWriter = new TeardownResilientStreamMessageWriter(this.ffiHost.sendStream);
|
|
13461
|
-
this.connection = (0,
|
|
13462
|
-
new
|
|
13014
|
+
this.connection = (0, import_node3.createMessageConnection)(
|
|
13015
|
+
new import_node3.StreamMessageReader(this.ffiHost.receiveStream),
|
|
13463
13016
|
this.messageWriter
|
|
13464
13017
|
);
|
|
13465
13018
|
this.attachConnectionHandlers();
|
|
@@ -13512,8 +13065,8 @@ stderr: ${stderrOutput}` : ""}`
|
|
|
13512
13065
|
}
|
|
13513
13066
|
});
|
|
13514
13067
|
this.messageWriter = new TeardownResilientStreamMessageWriter(this.cliProcess.stdin);
|
|
13515
|
-
this.connection = (0,
|
|
13516
|
-
new
|
|
13068
|
+
this.connection = (0, import_node3.createMessageConnection)(
|
|
13069
|
+
new import_node3.StreamMessageReader(this.cliProcess.stdout),
|
|
13517
13070
|
this.messageWriter
|
|
13518
13071
|
);
|
|
13519
13072
|
this.attachConnectionHandlers();
|
|
@@ -13527,8 +13080,8 @@ stderr: ${stderrOutput}` : ""}`
|
|
|
13527
13080
|
throw new Error("CLI child process was unexpectedly started in parent process mode");
|
|
13528
13081
|
}
|
|
13529
13082
|
this.messageWriter = new TeardownResilientStreamMessageWriter(process.stdout);
|
|
13530
|
-
this.connection = (0,
|
|
13531
|
-
new
|
|
13083
|
+
this.connection = (0, import_node3.createMessageConnection)(
|
|
13084
|
+
new import_node3.StreamMessageReader(process.stdin),
|
|
13532
13085
|
this.messageWriter
|
|
13533
13086
|
);
|
|
13534
13087
|
this.attachConnectionHandlers();
|
|
@@ -13550,8 +13103,8 @@ stderr: ${stderrOutput}` : ""}`
|
|
|
13550
13103
|
this.socket.connect(this.runtimePort, this.actualHost, () => {
|
|
13551
13104
|
clearTimeout(connectionTimeout);
|
|
13552
13105
|
this.messageWriter = new TeardownResilientStreamMessageWriter(this.socket);
|
|
13553
|
-
this.connection = (0,
|
|
13554
|
-
new
|
|
13106
|
+
this.connection = (0, import_node3.createMessageConnection)(
|
|
13107
|
+
new import_node3.StreamMessageReader(this.socket),
|
|
13555
13108
|
this.messageWriter
|
|
13556
13109
|
);
|
|
13557
13110
|
this.attachConnectionHandlers();
|
|
@@ -13597,6 +13150,16 @@ stderr: ${stderrOutput}` : ""}`
|
|
|
13597
13150
|
return session.clientSessionApis;
|
|
13598
13151
|
});
|
|
13599
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
|
+
}
|
|
13600
13163
|
this.connection.onRequest(
|
|
13601
13164
|
"hooks.invoke",
|
|
13602
13165
|
async (params) => {
|
|
@@ -13746,15 +13309,11 @@ async function joinSession(config = {}) {
|
|
|
13746
13309
|
const client = new CopilotClient({ _internalConnection: { kind: "parent-process" } });
|
|
13747
13310
|
const {
|
|
13748
13311
|
extensionSdkPath: _stripped,
|
|
13749
|
-
factories,
|
|
13750
13312
|
workflows,
|
|
13751
13313
|
requestedEnvironmentVariables,
|
|
13752
13314
|
...rest
|
|
13753
13315
|
} = config;
|
|
13754
13316
|
void _stripped;
|
|
13755
|
-
if (factories !== void 0 && workflows !== void 0) {
|
|
13756
|
-
throw new Error("joinSession cannot register both factories and workflows");
|
|
13757
|
-
}
|
|
13758
13317
|
return client.resumeSessionForExtension(
|
|
13759
13318
|
sessionId,
|
|
13760
13319
|
{
|
|
@@ -13762,19 +13321,16 @@ async function joinSession(config = {}) {
|
|
|
13762
13321
|
onPermissionRequest: config.onPermissionRequest ?? defaultJoinSessionPermissionHandler,
|
|
13763
13322
|
suppressResumeEvent: config.suppressResumeEvent ?? true
|
|
13764
13323
|
},
|
|
13765
|
-
{
|
|
13324
|
+
{ workflows },
|
|
13766
13325
|
requestedEnvironmentVariables?.length ? { requestedEnvironmentVariables } : void 0
|
|
13767
13326
|
);
|
|
13768
13327
|
}
|
|
13769
13328
|
export {
|
|
13770
13329
|
Canvas,
|
|
13771
13330
|
CanvasError,
|
|
13772
|
-
FactoryResumeError,
|
|
13773
13331
|
WorkflowResumeError,
|
|
13774
13332
|
createCanvas,
|
|
13775
|
-
defineFactory,
|
|
13776
13333
|
defineWorkflow,
|
|
13777
|
-
isFactoryRunTerminal,
|
|
13778
13334
|
isWorkflowRunTerminal,
|
|
13779
13335
|
joinSession
|
|
13780
13336
|
};
|