@github/copilot-sdk-win32-x64 1.0.14 → 1.0.15-preview.1
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/builtin/discover-resources/SKILL.md +10 -0
- package/builtin-skills/discover-resources/SKILL.md +10 -0
- package/copilot-sdk/cliVersion.d.ts +1 -1
- package/copilot-sdk/client.d.ts +2 -0
- package/copilot-sdk/docs/extensions.md +1 -0
- package/copilot-sdk/docs/workflows.md +257 -0
- package/copilot-sdk/extension.d.ts +22 -8
- package/copilot-sdk/extension.js +1845 -230
- package/copilot-sdk/generated/rpc.d.ts +3141 -302
- package/copilot-sdk/generated/session-events.d.ts +756 -31
- package/copilot-sdk/index.d.ts +3 -1
- package/copilot-sdk/index.js +1839 -228
- package/copilot-sdk/schema.d.ts +4 -0
- package/copilot-sdk/session.d.ts +26 -3
- package/copilot-sdk/types.d.ts +37 -5
- package/copilot-sdk/workflow.d.ts +364 -0
- package/definitions/explore.agent.yaml +4 -1
- package/definitions/research.agent.yaml +1 -1
- package/definitions/task.agent.yaml +4 -1
- package/package.json +1 -1
- package/plugins/computer-use/CopilotComputerUse.exe +0 -0
- package/plugins/computer-use/computer-use-mcp.exe +0 -0
- package/plugins/computer-use/{.mcp.json → mcp.json} +2 -1
- package/plugins/computer-use/plugin.json +6 -0
- package/prebuilds/win32-x64/OneAuthInterop.dll +0 -0
- package/prebuilds/win32-x64/copilot-runtime.exe +0 -0
- package/prebuilds/win32-x64/msal-node-runtime.node +0 -0
- package/prebuilds/win32-x64/msalruntime.dll +0 -0
- package/prebuilds/win32-x64/runtime.node +2 -2
- package/preloads/extension_bootstrap.mjs +3 -4
- package/ripgrep/bin/win32-x64/rg.exe +0 -0
- package/schemas/api.schema.json +5252 -77
- package/schemas/session-events.schema.json +946 -1
- package/sdk/index.js +275 -286
- package/tgrep/bin/win32-x64/tgrep.exe +0 -0
- package/plugins/computer-use/.plugin/plugin.json +0 -6
package/copilot-sdk/index.js
CHANGED
|
@@ -53,9 +53,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
53
53
|
mod
|
|
54
54
|
));
|
|
55
55
|
|
|
56
|
-
//
|
|
56
|
+
// src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/is.js
|
|
57
57
|
var require_is = __commonJS({
|
|
58
|
-
"
|
|
58
|
+
"src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/is.js"(exports) {
|
|
59
59
|
"use strict";
|
|
60
60
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
61
61
|
exports.stringArray = exports.array = exports.func = exports.error = exports.number = exports.string = exports.boolean = void 0;
|
|
@@ -90,9 +90,9 @@ var require_is = __commonJS({
|
|
|
90
90
|
}
|
|
91
91
|
});
|
|
92
92
|
|
|
93
|
-
//
|
|
93
|
+
// src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/messages.js
|
|
94
94
|
var require_messages = __commonJS({
|
|
95
|
-
"
|
|
95
|
+
"src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/messages.js"(exports) {
|
|
96
96
|
"use strict";
|
|
97
97
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
98
98
|
exports.Message = exports.NotificationType9 = exports.NotificationType8 = exports.NotificationType7 = exports.NotificationType6 = exports.NotificationType5 = exports.NotificationType4 = exports.NotificationType3 = exports.NotificationType2 = exports.NotificationType1 = exports.NotificationType0 = exports.NotificationType = exports.RequestType9 = exports.RequestType8 = exports.RequestType7 = exports.RequestType6 = exports.RequestType5 = exports.RequestType4 = exports.RequestType3 = exports.RequestType2 = exports.RequestType1 = exports.RequestType = exports.RequestType0 = exports.AbstractMessageSignature = exports.ParameterStructures = exports.ResponseError = exports.ErrorCodes = void 0;
|
|
@@ -328,9 +328,9 @@ var require_messages = __commonJS({
|
|
|
328
328
|
}
|
|
329
329
|
});
|
|
330
330
|
|
|
331
|
-
//
|
|
331
|
+
// src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/linkedMap.js
|
|
332
332
|
var require_linkedMap = __commonJS({
|
|
333
|
-
"
|
|
333
|
+
"src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/linkedMap.js"(exports) {
|
|
334
334
|
"use strict";
|
|
335
335
|
var _a;
|
|
336
336
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -698,9 +698,9 @@ var require_linkedMap = __commonJS({
|
|
|
698
698
|
}
|
|
699
699
|
});
|
|
700
700
|
|
|
701
|
-
//
|
|
701
|
+
// src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/disposable.js
|
|
702
702
|
var require_disposable = __commonJS({
|
|
703
|
-
"
|
|
703
|
+
"src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/disposable.js"(exports) {
|
|
704
704
|
"use strict";
|
|
705
705
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
706
706
|
exports.Disposable = void 0;
|
|
@@ -716,9 +716,9 @@ var require_disposable = __commonJS({
|
|
|
716
716
|
}
|
|
717
717
|
});
|
|
718
718
|
|
|
719
|
-
//
|
|
719
|
+
// src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/ral.js
|
|
720
720
|
var require_ral = __commonJS({
|
|
721
|
-
"
|
|
721
|
+
"src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/ral.js"(exports) {
|
|
722
722
|
"use strict";
|
|
723
723
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
724
724
|
var _ral;
|
|
@@ -741,9 +741,9 @@ var require_ral = __commonJS({
|
|
|
741
741
|
}
|
|
742
742
|
});
|
|
743
743
|
|
|
744
|
-
//
|
|
744
|
+
// src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/events.js
|
|
745
745
|
var require_events = __commonJS({
|
|
746
|
-
"
|
|
746
|
+
"src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/events.js"(exports) {
|
|
747
747
|
"use strict";
|
|
748
748
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
749
749
|
exports.Emitter = exports.Event = void 0;
|
|
@@ -870,9 +870,9 @@ var require_events = __commonJS({
|
|
|
870
870
|
}
|
|
871
871
|
});
|
|
872
872
|
|
|
873
|
-
//
|
|
873
|
+
// src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/cancellation.js
|
|
874
874
|
var require_cancellation = __commonJS({
|
|
875
|
-
"
|
|
875
|
+
"src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/cancellation.js"(exports) {
|
|
876
876
|
"use strict";
|
|
877
877
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
878
878
|
exports.CancellationTokenSource = exports.CancellationToken = void 0;
|
|
@@ -959,9 +959,9 @@ var require_cancellation = __commonJS({
|
|
|
959
959
|
}
|
|
960
960
|
});
|
|
961
961
|
|
|
962
|
-
//
|
|
962
|
+
// src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/sharedArrayCancellation.js
|
|
963
963
|
var require_sharedArrayCancellation = __commonJS({
|
|
964
|
-
"
|
|
964
|
+
"src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/sharedArrayCancellation.js"(exports) {
|
|
965
965
|
"use strict";
|
|
966
966
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
967
967
|
exports.SharedArrayReceiverStrategy = exports.SharedArraySenderStrategy = void 0;
|
|
@@ -1037,9 +1037,9 @@ var require_sharedArrayCancellation = __commonJS({
|
|
|
1037
1037
|
}
|
|
1038
1038
|
});
|
|
1039
1039
|
|
|
1040
|
-
//
|
|
1040
|
+
// src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/semaphore.js
|
|
1041
1041
|
var require_semaphore = __commonJS({
|
|
1042
|
-
"
|
|
1042
|
+
"src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/semaphore.js"(exports) {
|
|
1043
1043
|
"use strict";
|
|
1044
1044
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1045
1045
|
exports.Semaphore = void 0;
|
|
@@ -1105,9 +1105,9 @@ var require_semaphore = __commonJS({
|
|
|
1105
1105
|
}
|
|
1106
1106
|
});
|
|
1107
1107
|
|
|
1108
|
-
//
|
|
1108
|
+
// src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/messageReader.js
|
|
1109
1109
|
var require_messageReader = __commonJS({
|
|
1110
|
-
"
|
|
1110
|
+
"src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/messageReader.js"(exports) {
|
|
1111
1111
|
"use strict";
|
|
1112
1112
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1113
1113
|
exports.ReadableStreamMessageReader = exports.AbstractMessageReader = exports.MessageReader = void 0;
|
|
@@ -1294,9 +1294,9 @@ ${JSON.stringify(Object.fromEntries(headers))}`));
|
|
|
1294
1294
|
}
|
|
1295
1295
|
});
|
|
1296
1296
|
|
|
1297
|
-
//
|
|
1297
|
+
// src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/messageWriter.js
|
|
1298
1298
|
var require_messageWriter = __commonJS({
|
|
1299
|
-
"
|
|
1299
|
+
"src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/messageWriter.js"(exports) {
|
|
1300
1300
|
"use strict";
|
|
1301
1301
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1302
1302
|
exports.WriteableStreamMessageWriter = exports.AbstractMessageWriter = exports.MessageWriter = void 0;
|
|
@@ -1406,9 +1406,9 @@ var require_messageWriter = __commonJS({
|
|
|
1406
1406
|
}
|
|
1407
1407
|
});
|
|
1408
1408
|
|
|
1409
|
-
//
|
|
1409
|
+
// src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/messageBuffer.js
|
|
1410
1410
|
var require_messageBuffer = __commonJS({
|
|
1411
|
-
"
|
|
1411
|
+
"src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/messageBuffer.js"(exports) {
|
|
1412
1412
|
"use strict";
|
|
1413
1413
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1414
1414
|
exports.AbstractMessageBuffer = void 0;
|
|
@@ -1554,9 +1554,9 @@ ${header}`);
|
|
|
1554
1554
|
}
|
|
1555
1555
|
});
|
|
1556
1556
|
|
|
1557
|
-
//
|
|
1557
|
+
// src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/connection.js
|
|
1558
1558
|
var require_connection = __commonJS({
|
|
1559
|
-
"
|
|
1559
|
+
"src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/connection.js"(exports) {
|
|
1560
1560
|
"use strict";
|
|
1561
1561
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1562
1562
|
exports.createMessageConnection = exports.ConnectionOptions = exports.MessageStrategy = exports.CancellationStrategy = exports.CancellationSenderStrategy = exports.CancellationReceiverStrategy = exports.RequestCancellationReceiverStrategy = exports.IdCancellationReceiverStrategy = exports.ConnectionStrategy = exports.ConnectionError = exports.ConnectionErrors = exports.LogTraceNotification = exports.SetTraceNotification = exports.TraceFormat = exports.TraceValues = exports.Trace = exports.NullLogger = exports.ProgressType = exports.ProgressToken = void 0;
|
|
@@ -1785,7 +1785,7 @@ var require_connection = __commonJS({
|
|
|
1785
1785
|
let sequenceNumber = 0;
|
|
1786
1786
|
let notificationSequenceNumber = 0;
|
|
1787
1787
|
let unknownResponseSequenceNumber = 0;
|
|
1788
|
-
const
|
|
1788
|
+
const version2 = "2.0";
|
|
1789
1789
|
let starRequestHandler = void 0;
|
|
1790
1790
|
const requestHandlers = /* @__PURE__ */ new Map();
|
|
1791
1791
|
let starNotificationHandler = void 0;
|
|
@@ -1933,7 +1933,7 @@ var require_connection = __commonJS({
|
|
|
1933
1933
|
}
|
|
1934
1934
|
function reply(resultOrError, method, startTime2) {
|
|
1935
1935
|
const message = {
|
|
1936
|
-
jsonrpc:
|
|
1936
|
+
jsonrpc: version2,
|
|
1937
1937
|
id: requestMessage.id
|
|
1938
1938
|
};
|
|
1939
1939
|
if (resultOrError instanceof messages_1.ResponseError) {
|
|
@@ -1946,7 +1946,7 @@ var require_connection = __commonJS({
|
|
|
1946
1946
|
}
|
|
1947
1947
|
function replyError(error, method, startTime2) {
|
|
1948
1948
|
const message = {
|
|
1949
|
-
jsonrpc:
|
|
1949
|
+
jsonrpc: version2,
|
|
1950
1950
|
id: requestMessage.id,
|
|
1951
1951
|
error: error.toJson()
|
|
1952
1952
|
};
|
|
@@ -1958,7 +1958,7 @@ var require_connection = __commonJS({
|
|
|
1958
1958
|
result = null;
|
|
1959
1959
|
}
|
|
1960
1960
|
const message = {
|
|
1961
|
-
jsonrpc:
|
|
1961
|
+
jsonrpc: version2,
|
|
1962
1962
|
id: requestMessage.id,
|
|
1963
1963
|
result
|
|
1964
1964
|
};
|
|
@@ -2428,7 +2428,7 @@ ${JSON.stringify(message, null, 4)}`);
|
|
|
2428
2428
|
messageParams = computeMessageParams(type, params);
|
|
2429
2429
|
}
|
|
2430
2430
|
const notificationMessage = {
|
|
2431
|
-
jsonrpc:
|
|
2431
|
+
jsonrpc: version2,
|
|
2432
2432
|
method,
|
|
2433
2433
|
params: messageParams
|
|
2434
2434
|
};
|
|
@@ -2536,7 +2536,7 @@ ${JSON.stringify(message, null, 4)}`);
|
|
|
2536
2536
|
});
|
|
2537
2537
|
}
|
|
2538
2538
|
const requestMessage = {
|
|
2539
|
-
jsonrpc:
|
|
2539
|
+
jsonrpc: version2,
|
|
2540
2540
|
id,
|
|
2541
2541
|
method,
|
|
2542
2542
|
params: messageParams
|
|
@@ -2683,9 +2683,9 @@ ${JSON.stringify(message, null, 4)}`);
|
|
|
2683
2683
|
}
|
|
2684
2684
|
});
|
|
2685
2685
|
|
|
2686
|
-
//
|
|
2686
|
+
// src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/api.js
|
|
2687
2687
|
var require_api = __commonJS({
|
|
2688
|
-
"
|
|
2688
|
+
"src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/api.js"(exports) {
|
|
2689
2689
|
"use strict";
|
|
2690
2690
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2691
2691
|
exports.ProgressType = exports.ProgressToken = exports.createMessageConnection = exports.NullLogger = exports.ConnectionOptions = exports.ConnectionStrategy = exports.AbstractMessageBuffer = exports.WriteableStreamMessageWriter = exports.AbstractMessageWriter = exports.MessageWriter = exports.ReadableStreamMessageReader = exports.AbstractMessageReader = exports.MessageReader = exports.SharedArrayReceiverStrategy = exports.SharedArraySenderStrategy = exports.CancellationToken = exports.CancellationTokenSource = exports.Emitter = exports.Event = exports.Disposable = exports.LRUCache = exports.Touch = exports.LinkedMap = exports.ParameterStructures = exports.NotificationType9 = exports.NotificationType8 = exports.NotificationType7 = exports.NotificationType6 = exports.NotificationType5 = exports.NotificationType4 = exports.NotificationType3 = exports.NotificationType2 = exports.NotificationType1 = exports.NotificationType0 = exports.NotificationType = exports.ErrorCodes = exports.ResponseError = exports.RequestType9 = exports.RequestType8 = exports.RequestType7 = exports.RequestType6 = exports.RequestType5 = exports.RequestType4 = exports.RequestType3 = exports.RequestType2 = exports.RequestType1 = exports.RequestType0 = exports.RequestType = exports.Message = exports.RAL = void 0;
|
|
@@ -2885,9 +2885,9 @@ var require_api = __commonJS({
|
|
|
2885
2885
|
}
|
|
2886
2886
|
});
|
|
2887
2887
|
|
|
2888
|
-
//
|
|
2888
|
+
// src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/node/ril.js
|
|
2889
2889
|
var require_ril = __commonJS({
|
|
2890
|
-
"
|
|
2890
|
+
"src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/node/ril.js"(exports) {
|
|
2891
2891
|
"use strict";
|
|
2892
2892
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2893
2893
|
var util_1 = __require("util");
|
|
@@ -3041,9 +3041,9 @@ var require_ril = __commonJS({
|
|
|
3041
3041
|
}
|
|
3042
3042
|
});
|
|
3043
3043
|
|
|
3044
|
-
//
|
|
3044
|
+
// src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/node/main.js
|
|
3045
3045
|
var require_main = __commonJS({
|
|
3046
|
-
"
|
|
3046
|
+
"src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/node/main.js"(exports) {
|
|
3047
3047
|
"use strict";
|
|
3048
3048
|
var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
3049
3049
|
if (k2 === void 0) k2 = k;
|
|
@@ -3301,24 +3301,398 @@ var require_main = __commonJS({
|
|
|
3301
3301
|
}
|
|
3302
3302
|
});
|
|
3303
3303
|
|
|
3304
|
-
//
|
|
3304
|
+
// src/sdk/nodejs/node_modules/vscode-jsonrpc/node.js
|
|
3305
3305
|
var require_node = __commonJS({
|
|
3306
|
-
"
|
|
3306
|
+
"src/sdk/nodejs/node_modules/vscode-jsonrpc/node.js"(exports, module) {
|
|
3307
3307
|
"use strict";
|
|
3308
3308
|
module.exports = require_main();
|
|
3309
3309
|
}
|
|
3310
3310
|
});
|
|
3311
3311
|
|
|
3312
|
-
//
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3312
|
+
// src/sdk/nodejs/node_modules/koffi/src/koffi/src/static.js
|
|
3313
|
+
import { createRequire as createRequire2 } from "node:module";
|
|
3314
|
+
function loadStatic(pkg2) {
|
|
3315
|
+
let native2 = null;
|
|
3316
|
+
if (pkg2 == "linux-arm") {
|
|
3317
|
+
try {
|
|
3318
|
+
native2 = require3("@koromix/koffi-linux-arm");
|
|
3319
|
+
} catch (err) {
|
|
3320
|
+
}
|
|
3321
|
+
}
|
|
3322
|
+
if (pkg2 == "linux-arm64") {
|
|
3323
|
+
try {
|
|
3324
|
+
native2 = require3("@koromix/koffi-linux-arm64");
|
|
3325
|
+
} catch (err) {
|
|
3326
|
+
}
|
|
3327
|
+
}
|
|
3328
|
+
if (pkg2 == "linux-ia32") {
|
|
3329
|
+
try {
|
|
3330
|
+
native2 = require3("@koromix/koffi-linux-ia32");
|
|
3331
|
+
} catch (err) {
|
|
3332
|
+
}
|
|
3333
|
+
}
|
|
3334
|
+
if (pkg2 == "linux-x64") {
|
|
3335
|
+
try {
|
|
3336
|
+
native2 = require3("@koromix/koffi-linux-x64");
|
|
3337
|
+
} catch (err) {
|
|
3338
|
+
}
|
|
3339
|
+
}
|
|
3340
|
+
if (pkg2 == "linux-riscv64") {
|
|
3341
|
+
try {
|
|
3342
|
+
native2 = require3("@koromix/koffi-linux-riscv64");
|
|
3343
|
+
} catch (err) {
|
|
3344
|
+
}
|
|
3345
|
+
}
|
|
3346
|
+
if (pkg2 == "freebsd-ia32") {
|
|
3347
|
+
try {
|
|
3348
|
+
native2 = require3("@koromix/koffi-freebsd-ia32");
|
|
3349
|
+
} catch (err) {
|
|
3350
|
+
}
|
|
3351
|
+
}
|
|
3352
|
+
if (pkg2 == "freebsd-x64") {
|
|
3353
|
+
try {
|
|
3354
|
+
native2 = require3("@koromix/koffi-freebsd-x64");
|
|
3355
|
+
} catch (err) {
|
|
3356
|
+
}
|
|
3357
|
+
}
|
|
3358
|
+
if (pkg2 == "freebsd-arm64") {
|
|
3359
|
+
try {
|
|
3360
|
+
native2 = require3("@koromix/koffi-freebsd-arm64");
|
|
3361
|
+
} catch (err) {
|
|
3362
|
+
}
|
|
3363
|
+
}
|
|
3364
|
+
if (pkg2 == "openbsd-ia32") {
|
|
3365
|
+
try {
|
|
3366
|
+
native2 = require3("@koromix/koffi-openbsd-ia32");
|
|
3367
|
+
} catch (err) {
|
|
3368
|
+
}
|
|
3369
|
+
}
|
|
3370
|
+
if (pkg2 == "openbsd-x64") {
|
|
3371
|
+
try {
|
|
3372
|
+
native2 = require3("@koromix/koffi-openbsd-x64");
|
|
3373
|
+
} catch (err) {
|
|
3374
|
+
}
|
|
3375
|
+
}
|
|
3376
|
+
if (pkg2 == "win32-ia32") {
|
|
3377
|
+
try {
|
|
3378
|
+
native2 = require3("@koromix/koffi-win32-ia32");
|
|
3379
|
+
} catch (err) {
|
|
3380
|
+
}
|
|
3381
|
+
}
|
|
3382
|
+
if (pkg2 == "win32-x64") {
|
|
3383
|
+
try {
|
|
3384
|
+
native2 = require3("@koromix/koffi-win32-x64");
|
|
3385
|
+
} catch (err) {
|
|
3386
|
+
}
|
|
3387
|
+
}
|
|
3388
|
+
if (pkg2 == "win32-arm64") {
|
|
3389
|
+
try {
|
|
3390
|
+
native2 = require3("@koromix/koffi-win32-arm64");
|
|
3391
|
+
} catch (err) {
|
|
3392
|
+
}
|
|
3393
|
+
}
|
|
3394
|
+
if (pkg2 == "darwin-x64") {
|
|
3395
|
+
try {
|
|
3396
|
+
native2 = require3("@koromix/koffi-darwin-x64");
|
|
3397
|
+
} catch (err) {
|
|
3398
|
+
}
|
|
3399
|
+
}
|
|
3400
|
+
if (pkg2 == "darwin-arm64") {
|
|
3401
|
+
try {
|
|
3402
|
+
native2 = require3("@koromix/koffi-darwin-arm64");
|
|
3403
|
+
} catch (err) {
|
|
3404
|
+
}
|
|
3405
|
+
}
|
|
3406
|
+
if (pkg2 == "linux-loong64") {
|
|
3407
|
+
try {
|
|
3408
|
+
native2 = require3("@koromix/koffi-linux-loong64");
|
|
3409
|
+
} catch (err) {
|
|
3410
|
+
}
|
|
3411
|
+
}
|
|
3412
|
+
if (pkg2 == "android-arm64") {
|
|
3413
|
+
try {
|
|
3414
|
+
native2 = require3("@koromix/koffi-android-arm64");
|
|
3415
|
+
} catch (err) {
|
|
3416
|
+
}
|
|
3417
|
+
}
|
|
3418
|
+
if (pkg2 == "android-x64") {
|
|
3419
|
+
try {
|
|
3420
|
+
native2 = require3("@koromix/koffi-android-x64");
|
|
3421
|
+
} catch (err) {
|
|
3422
|
+
}
|
|
3423
|
+
}
|
|
3424
|
+
return native2;
|
|
3425
|
+
}
|
|
3426
|
+
var require3;
|
|
3427
|
+
var init_static = __esm({
|
|
3428
|
+
"src/sdk/nodejs/node_modules/koffi/src/koffi/src/static.js"() {
|
|
3429
|
+
require3 = createRequire2(import.meta.url);
|
|
3430
|
+
}
|
|
3431
|
+
});
|
|
3432
|
+
|
|
3433
|
+
// src/sdk/nodejs/node_modules/koffi/src/koffi/index.js
|
|
3434
|
+
import util from "node:util";
|
|
3435
|
+
import fs2 from "node:fs";
|
|
3436
|
+
import { createRequire as createRequire3 } from "node:module";
|
|
3437
|
+
import fs from "node:fs";
|
|
3438
|
+
function determineAbi() {
|
|
3439
|
+
let abi = process.arch.toString();
|
|
3440
|
+
if (abi == "riscv32" || abi == "riscv64") {
|
|
3441
|
+
let file = openFile(process.execPath, "r");
|
|
3442
|
+
try {
|
|
3443
|
+
let header = readElfHeader(file);
|
|
3444
|
+
let float_abi = header.e_flags & 6;
|
|
3445
|
+
switch (float_abi) {
|
|
3446
|
+
case 0:
|
|
3447
|
+
{
|
|
3448
|
+
}
|
|
3449
|
+
break;
|
|
3450
|
+
case 2:
|
|
3451
|
+
{
|
|
3452
|
+
abi += "f";
|
|
3453
|
+
}
|
|
3454
|
+
break;
|
|
3455
|
+
case 4:
|
|
3456
|
+
{
|
|
3457
|
+
abi += "d";
|
|
3458
|
+
}
|
|
3459
|
+
break;
|
|
3460
|
+
case 6:
|
|
3461
|
+
{
|
|
3462
|
+
abi += "q";
|
|
3463
|
+
}
|
|
3464
|
+
break;
|
|
3465
|
+
}
|
|
3466
|
+
} finally {
|
|
3467
|
+
file.close();
|
|
3468
|
+
}
|
|
3469
|
+
} else if (abi == "arm") {
|
|
3470
|
+
let file = openFile(process.execPath, "r");
|
|
3471
|
+
try {
|
|
3472
|
+
let header = readElfHeader(file);
|
|
3473
|
+
if (header.e_flags & 1024) {
|
|
3474
|
+
abi += "hf";
|
|
3475
|
+
} else if (header.e_flags & 512) {
|
|
3476
|
+
abi += "sf";
|
|
3477
|
+
} else {
|
|
3478
|
+
throw new Error("Unknown ARM floating-point ABI");
|
|
3479
|
+
}
|
|
3480
|
+
} finally {
|
|
3481
|
+
file.close();
|
|
3482
|
+
}
|
|
3483
|
+
}
|
|
3484
|
+
return abi;
|
|
3485
|
+
}
|
|
3486
|
+
function readElfHeader(file, offset = 0) {
|
|
3487
|
+
let buf = file.read(offset, 512);
|
|
3488
|
+
if (buf.length < 16)
|
|
3489
|
+
throw new Error("Truncated header");
|
|
3490
|
+
if (buf[0] != 127 || buf[1] != 69 || buf[2] != 76 || buf[3] != 70)
|
|
3491
|
+
throw new Error("Invalid magic number");
|
|
3492
|
+
if (buf[6] != 1)
|
|
3493
|
+
throw new Error("Invalid ELF version");
|
|
3494
|
+
if (buf[5] != 1)
|
|
3495
|
+
throw new Error("Big-endian architectures are not supported");
|
|
3496
|
+
switch (buf[4]) {
|
|
3497
|
+
case 1:
|
|
3498
|
+
{
|
|
3499
|
+
if (buf.length < 68)
|
|
3500
|
+
throw new Error("Truncated ELF header");
|
|
3501
|
+
return {
|
|
3502
|
+
ei_class: 32,
|
|
3503
|
+
e_machine: buf.readUInt16LE(18),
|
|
3504
|
+
e_flags: buf.readUInt32LE(36),
|
|
3505
|
+
e_phoff: buf.readUInt32LE(28),
|
|
3506
|
+
e_phentsize: buf.readUInt16LE(42),
|
|
3507
|
+
e_phnum: buf.readUInt16LE(44)
|
|
3508
|
+
};
|
|
3509
|
+
}
|
|
3510
|
+
break;
|
|
3511
|
+
case 2:
|
|
3512
|
+
{
|
|
3513
|
+
if (buf.length < 120)
|
|
3514
|
+
throw new Error("Truncated ELF header");
|
|
3515
|
+
return {
|
|
3516
|
+
ei_class: 64,
|
|
3517
|
+
e_machine: buf.readUInt16LE(18),
|
|
3518
|
+
e_flags: buf.readUInt32LE(48),
|
|
3519
|
+
e_phoff: buf.readBigUInt64LE(32),
|
|
3520
|
+
e_phentsize: buf.readUInt16LE(54),
|
|
3521
|
+
e_phnum: buf.readUInt16LE(56)
|
|
3522
|
+
};
|
|
3523
|
+
}
|
|
3524
|
+
break;
|
|
3525
|
+
default:
|
|
3526
|
+
throw new Error("Invalid ELF class");
|
|
3527
|
+
}
|
|
3528
|
+
}
|
|
3529
|
+
function openFile(filename, flags) {
|
|
3530
|
+
let fd = fs.openSync(filename, flags);
|
|
3531
|
+
return new FileHandle(fd);
|
|
3532
|
+
}
|
|
3533
|
+
function detectPlatform() {
|
|
3534
|
+
if (process.versions.napi == null || process.versions.napi < package_default.cnoke.napi) {
|
|
3535
|
+
let major = parseInt(process.versions.node, 10);
|
|
3536
|
+
throw new Error(`This engine is based on Node ${process.versions.node}, but ${package_default.name} does not support the Node ${major}.x branch (Node-API < ${package_default.cnoke.napi})`);
|
|
3537
|
+
}
|
|
3538
|
+
let abi = determineAbi();
|
|
3539
|
+
let pkg2 = `${process.platform}-${process.arch}`;
|
|
3540
|
+
let triplets2 = [`${process.platform}_${abi}`];
|
|
3541
|
+
if (process.platform == "linux")
|
|
3542
|
+
triplets2.push(`musl_${abi}`);
|
|
3543
|
+
return [package_default.version, pkg2, triplets2];
|
|
3544
|
+
}
|
|
3545
|
+
function loadDynamic(dirname3, pkg2, triplets2) {
|
|
3546
|
+
let suffix = "/../../build/koffi";
|
|
3547
|
+
let root = dirname3 + suffix;
|
|
3548
|
+
let roots = [root];
|
|
3549
|
+
let native2 = null;
|
|
3550
|
+
let err = null;
|
|
3551
|
+
if (process["resourcesPath"] != null) {
|
|
3552
|
+
let suffixes = [
|
|
3553
|
+
"/koffi",
|
|
3554
|
+
"/koffi/build",
|
|
3555
|
+
"/node_modules/koffi/build"
|
|
3556
|
+
];
|
|
3557
|
+
for (let suffix2 of suffixes)
|
|
3558
|
+
roots.push(process["resourcesPath"] + suffix2);
|
|
3559
|
+
}
|
|
3560
|
+
let names = [
|
|
3561
|
+
`${import.meta.dirname}/../../../@koromix/koffi-${pkg2}`,
|
|
3562
|
+
...triplets2.flatMap((triplet) => roots.map((dir) => `${dir}/${triplet}/koffi.node`))
|
|
3563
|
+
];
|
|
3564
|
+
for (let name of names) {
|
|
3565
|
+
if (!fs2.existsSync(name))
|
|
3566
|
+
continue;
|
|
3567
|
+
try {
|
|
3568
|
+
native2 = require22(name);
|
|
3569
|
+
break;
|
|
3570
|
+
} catch (e) {
|
|
3571
|
+
err ??= e;
|
|
3572
|
+
}
|
|
3573
|
+
}
|
|
3574
|
+
if (native2 == null && err != null)
|
|
3575
|
+
throw err;
|
|
3576
|
+
return native2;
|
|
3577
|
+
}
|
|
3578
|
+
function wrapNative(native2, version2) {
|
|
3579
|
+
if (native2 == null)
|
|
3580
|
+
throw new Error("Cannot find the native Koffi module; did you bundle it correctly?");
|
|
3581
|
+
if (native2.version != version2)
|
|
3582
|
+
throw new Error("Mismatched native Koffi modules");
|
|
3583
|
+
let load = native2.load;
|
|
3584
|
+
let register = native2.register;
|
|
3585
|
+
let introspect = native2.type;
|
|
3586
|
+
native2.sizeof = (spec) => introspect(spec).size;
|
|
3587
|
+
native2.alignof = (spec) => introspect(spec).alignment;
|
|
3588
|
+
native2.offsetof = (spec, name) => {
|
|
3589
|
+
let info = introspect(spec);
|
|
3590
|
+
if (info.primitive != "Record")
|
|
3591
|
+
throw new TypeError("The offsetof() function can only be used with record types");
|
|
3592
|
+
let member = info.members[name];
|
|
3593
|
+
if (member == null)
|
|
3594
|
+
throw new Error(`Record type ${info.name} does not have member '${name}'`);
|
|
3595
|
+
return member.offset;
|
|
3596
|
+
};
|
|
3597
|
+
native2.register = (...args) => {
|
|
3598
|
+
if (args.length >= 3 && typeof args[1] == "function") {
|
|
3599
|
+
process.emitWarning("Using koffi.register() with a custom this value was deprecated in Koffi 2.17, use function.bind() instead", "DeprecationWarning", "KOFFI009");
|
|
3600
|
+
args[1] = args[1].bind(args[0]);
|
|
3601
|
+
args = args.slice(1);
|
|
3602
|
+
}
|
|
3603
|
+
return register(...args);
|
|
3604
|
+
};
|
|
3605
|
+
native2.load = (...args) => {
|
|
3606
|
+
let lib = load(...args);
|
|
3607
|
+
lib.cdecl = util.deprecate((...args2) => lib.func("__cdecl", ...args2), "The koffi.cdecl() function was deprecated in Koffi 2.7, use koffi.func(...) instead", "KOFFI003");
|
|
3608
|
+
lib.stdcall = util.deprecate((...args2) => lib.func("__stdcall", ...args2), 'The koffi.stdcall() function was deprecated in Koffi 2.7, use koffi.func("__stdcall", ...) instead', "KOFFI004");
|
|
3609
|
+
lib.fastcall = util.deprecate((...args2) => lib.func("__fastcall", ...args2), 'The koffi.fastcall() function was deprecated in Koffi 2.7, use koffi.func("__fastcall", ...) instead', "KOFFI005");
|
|
3610
|
+
lib.thiscall = util.deprecate((...args2) => lib.func("__thiscall", ...args2), 'The koffi.thiscall() function was deprecated in Koffi 2.7, use koffi.func("__thiscall", ...) instead', "KOFFI006");
|
|
3611
|
+
return lib;
|
|
3612
|
+
};
|
|
3613
|
+
native2.resolve = util.deprecate(native2.type, "The koffi.resolve() function was deprecated in Koffi 3.0, use koffi.type() instead", "KOFFI007");
|
|
3614
|
+
native2.introspect = util.deprecate(native2.type, "The koffi.introspect() function was deprecated in Koffi 3.0, use koffi.type() instead", "KOFFI008");
|
|
3615
|
+
}
|
|
3616
|
+
var FileHandle, package_default, require22, version, pkg, triplets, native, mod_LibraryHandle, mod_TypeObject, mod_Union, mod_address, mod_alias, mod_alignof, mod_alloc, mod_array, mod_as, mod_call, mod_config, mod_decode, mod_disposable, mod_encode, mod_enumeration, mod_errno, mod_extension, mod_free, mod_in, mod_inout, mod_introspect, mod_load, mod_node, mod_offsetof, mod_opaque, mod_os, mod_out, mod_pack, mod_pointer, mod_proto, mod_register, mod_reset, mod_resolve, mod_sizeof, mod_stats, mod_struct, mod_type, mod_types, mod_union, mod_unregister, mod_version, mod_view, index_default;
|
|
3617
|
+
var init_koffi = __esm({
|
|
3618
|
+
"src/sdk/nodejs/node_modules/koffi/src/koffi/index.js"() {
|
|
3619
|
+
init_static();
|
|
3620
|
+
FileHandle = class {
|
|
3621
|
+
constructor(fd) {
|
|
3622
|
+
this.fd = fd;
|
|
3623
|
+
}
|
|
3624
|
+
close() {
|
|
3625
|
+
fs.closeSync(this.fd);
|
|
3626
|
+
}
|
|
3627
|
+
[Symbol.dispose]() {
|
|
3628
|
+
fs.closeSync(this.fd);
|
|
3629
|
+
}
|
|
3630
|
+
read(offset, len) {
|
|
3631
|
+
let buf = Buffer.allocUnsafe(len);
|
|
3632
|
+
let read = fs.readSync(this.fd, buf, 0, len, offset);
|
|
3633
|
+
return buf.subarray(0, read);
|
|
3634
|
+
}
|
|
3317
3635
|
};
|
|
3636
|
+
package_default = { name: "koffi", version: "3.2.1", cnoke: { api: "../../vendor/node-api-headers", output: "../../bin/Koffi/{{ toolchain }}", node: 16, napi: 8 } };
|
|
3637
|
+
require22 = createRequire3(import.meta.url);
|
|
3638
|
+
[version, pkg, triplets] = detectPlatform();
|
|
3639
|
+
native = loadStatic(pkg) ?? loadDynamic(import.meta.dirname, pkg, triplets);
|
|
3640
|
+
wrapNative(native, version);
|
|
3641
|
+
mod_LibraryHandle = native.LibraryHandle;
|
|
3642
|
+
mod_TypeObject = native.TypeObject;
|
|
3643
|
+
mod_Union = native.Union;
|
|
3644
|
+
mod_address = native.address;
|
|
3645
|
+
mod_alias = native.alias;
|
|
3646
|
+
mod_alignof = native.alignof;
|
|
3647
|
+
mod_alloc = native.alloc;
|
|
3648
|
+
mod_array = native.array;
|
|
3649
|
+
mod_as = native.as;
|
|
3650
|
+
mod_call = native.call;
|
|
3651
|
+
mod_config = native.config;
|
|
3652
|
+
mod_decode = native.decode;
|
|
3653
|
+
mod_disposable = native.disposable;
|
|
3654
|
+
mod_encode = native.encode;
|
|
3655
|
+
mod_enumeration = native.enumeration;
|
|
3656
|
+
mod_errno = native.errno;
|
|
3657
|
+
mod_extension = native.extension;
|
|
3658
|
+
mod_free = native.free;
|
|
3659
|
+
mod_in = native.in;
|
|
3660
|
+
mod_inout = native.inout;
|
|
3661
|
+
mod_introspect = native.introspect;
|
|
3662
|
+
mod_load = native.load;
|
|
3663
|
+
mod_node = native.node;
|
|
3664
|
+
mod_offsetof = native.offsetof;
|
|
3665
|
+
mod_opaque = native.opaque;
|
|
3666
|
+
mod_os = native.os;
|
|
3667
|
+
mod_out = native.out;
|
|
3668
|
+
mod_pack = native.pack;
|
|
3669
|
+
mod_pointer = native.pointer;
|
|
3670
|
+
mod_proto = native.proto;
|
|
3671
|
+
mod_register = native.register;
|
|
3672
|
+
mod_reset = native.reset;
|
|
3673
|
+
mod_resolve = native.resolve;
|
|
3674
|
+
mod_sizeof = native.sizeof;
|
|
3675
|
+
mod_stats = native.stats;
|
|
3676
|
+
mod_struct = native.struct;
|
|
3677
|
+
mod_type = native.type;
|
|
3678
|
+
mod_types = native.types;
|
|
3679
|
+
mod_union = native.union;
|
|
3680
|
+
mod_unregister = native.unregister;
|
|
3681
|
+
mod_version = native.version;
|
|
3682
|
+
mod_view = native.view;
|
|
3683
|
+
index_default = native;
|
|
3684
|
+
}
|
|
3685
|
+
});
|
|
3686
|
+
|
|
3687
|
+
// src/sdk/nodejs/node_modules/koffi/index.js
|
|
3688
|
+
var init_koffi2 = __esm({
|
|
3689
|
+
"src/sdk/nodejs/node_modules/koffi/index.js"() {
|
|
3690
|
+
init_koffi();
|
|
3691
|
+
init_koffi();
|
|
3318
3692
|
}
|
|
3319
3693
|
});
|
|
3320
3694
|
|
|
3321
|
-
//
|
|
3695
|
+
// src/sdk/nodejs/dist/ffiRuntimeHost.js
|
|
3322
3696
|
var ffiRuntimeHost_exports = {};
|
|
3323
3697
|
__export(ffiRuntimeHost_exports, {
|
|
3324
3698
|
FfiRuntimeHost: () => FfiRuntimeHost
|
|
@@ -3335,9 +3709,9 @@ function loadLibrary(libraryPath) {
|
|
|
3335
3709
|
}
|
|
3336
3710
|
return loadedLibrary;
|
|
3337
3711
|
}
|
|
3338
|
-
const lib =
|
|
3339
|
-
const outboundCallbackType =
|
|
3340
|
-
|
|
3712
|
+
const lib = index_default.load(libraryPath);
|
|
3713
|
+
const outboundCallbackType = index_default.pointer(
|
|
3714
|
+
index_default.proto(
|
|
3341
3715
|
`void ${SYMBOL_PREFIX}outbound(void *userData, uint8 *bytesPtr, size_t bytesLen)`
|
|
3342
3716
|
)
|
|
3343
3717
|
);
|
|
@@ -3391,10 +3765,11 @@ function buildEnvJson(environment) {
|
|
|
3391
3765
|
}
|
|
3392
3766
|
return Buffer.from(JSON.stringify(obj), "utf8");
|
|
3393
3767
|
}
|
|
3394
|
-
var
|
|
3768
|
+
var SYMBOL_PREFIX, KEEP_ALIVE_INTERVAL_MS, CLEANUP_RETRY_INTERVAL_MS, loadedLibraryPath, loadedLibrary, FfiRuntimeHost;
|
|
3395
3769
|
var init_ffiRuntimeHost = __esm({
|
|
3396
|
-
"
|
|
3397
|
-
|
|
3770
|
+
"src/sdk/nodejs/dist/ffiRuntimeHost.js"() {
|
|
3771
|
+
"use strict";
|
|
3772
|
+
init_koffi2();
|
|
3398
3773
|
SYMBOL_PREFIX = "copilot_runtime_";
|
|
3399
3774
|
KEEP_ALIVE_INTERVAL_MS = 1 << 30;
|
|
3400
3775
|
CLEANUP_RETRY_INTERVAL_MS = 100;
|
|
@@ -3484,7 +3859,7 @@ var init_ffiRuntimeHost = __esm({
|
|
|
3484
3859
|
if (this.disposed) {
|
|
3485
3860
|
throw new Error("The in-process runtime host was disposed during startup.");
|
|
3486
3861
|
}
|
|
3487
|
-
this.outboundCallback =
|
|
3862
|
+
this.outboundCallback = index_default.register(
|
|
3488
3863
|
(_userData, bytesPtr, bytesLen) => this.feedInbound(bytesPtr, bytesLen),
|
|
3489
3864
|
this.lib.outboundCallbackType
|
|
3490
3865
|
);
|
|
@@ -3538,9 +3913,9 @@ var init_ffiRuntimeHost = __esm({
|
|
|
3538
3913
|
if (!bytesPtr || length <= 0) {
|
|
3539
3914
|
return;
|
|
3540
3915
|
}
|
|
3541
|
-
const bytes =
|
|
3916
|
+
const bytes = index_default.decode(
|
|
3542
3917
|
bytesPtr,
|
|
3543
|
-
|
|
3918
|
+
index_default.array("uint8", length, "Typed")
|
|
3544
3919
|
);
|
|
3545
3920
|
this.receiveStream.write(Buffer.from(bytes));
|
|
3546
3921
|
} catch (error) {
|
|
@@ -3555,7 +3930,7 @@ var init_ffiRuntimeHost = __esm({
|
|
|
3555
3930
|
}
|
|
3556
3931
|
const callback = this.outboundCallback;
|
|
3557
3932
|
try {
|
|
3558
|
-
|
|
3933
|
+
index_default.unregister(callback);
|
|
3559
3934
|
this.outboundCallback = void 0;
|
|
3560
3935
|
return true;
|
|
3561
3936
|
} catch (error) {
|
|
@@ -3655,7 +4030,7 @@ var init_ffiRuntimeHost = __esm({
|
|
|
3655
4030
|
}
|
|
3656
4031
|
});
|
|
3657
4032
|
|
|
3658
|
-
//
|
|
4033
|
+
// src/sdk/nodejs/dist/client.js
|
|
3659
4034
|
var import_node2 = __toESM(require_node(), 1);
|
|
3660
4035
|
import { spawn } from "node:child_process";
|
|
3661
4036
|
import { randomUUID } from "node:crypto";
|
|
@@ -3663,7 +4038,7 @@ import { existsSync as existsSync3 } from "node:fs";
|
|
|
3663
4038
|
import { isIPv6, Socket } from "node:net";
|
|
3664
4039
|
import { dirname as dirname2, isAbsolute, join as join2, resolve as resolve2 } from "node:path";
|
|
3665
4040
|
|
|
3666
|
-
//
|
|
4041
|
+
// src/sdk/nodejs/dist/generated/rpc.js
|
|
3667
4042
|
function createServerRpc(connection) {
|
|
3668
4043
|
return {
|
|
3669
4044
|
/**
|
|
@@ -3863,7 +4238,15 @@ function createServerRpc(connection) {
|
|
|
3863
4238
|
*
|
|
3864
4239
|
* @returns Outcome of a catalog.search call: either bounded inert candidates, or one typed refusal. Never a partial success.
|
|
3865
4240
|
*/
|
|
3866
|
-
search: async (params) => connection.sendRequest("catalog.search", params)
|
|
4241
|
+
search: async (params) => connection.sendRequest("catalog.search", params),
|
|
4242
|
+
/**
|
|
4243
|
+
* Terminates one retained catalog selection group. A selected outcome returns the native host a fresh single-use candidate handle plus the original searchId for a later explicit mcp.planInstall call; non-selected outcomes release the group without producing a planning input. Candidate state, cards, URLs, credentials and private identifiers remain inside the runtime. The model-facing catalog_select tool projects the result separately and never exposes the candidate handle or searchId.
|
|
4244
|
+
*
|
|
4245
|
+
* @param params Terminates one retained catalog selection group through an opaque reference previously returned by the model-safe search projection.
|
|
4246
|
+
*
|
|
4247
|
+
* @returns Typed outcome of catalog.select. Only the selected host result carries a fresh candidate handle; the model-facing projection removes both that handle and searchId.
|
|
4248
|
+
*/
|
|
4249
|
+
select: async (params) => connection.sendRequest("catalog.select", params)
|
|
3867
4250
|
},
|
|
3868
4251
|
/** @experimental */
|
|
3869
4252
|
plugins: {
|
|
@@ -4094,7 +4477,7 @@ function createServerRpc(connection) {
|
|
|
4094
4477
|
/**
|
|
4095
4478
|
* Registers an SDK client as the session filesystem provider.
|
|
4096
4479
|
*
|
|
4097
|
-
* @param params Initial working directory, session-state path layout, and path conventions used to register the calling SDK client as the session filesystem provider.
|
|
4480
|
+
* @param params Initial working directory, session-state path layout, and path conventions used to register the calling SDK client as the session filesystem provider. A registered provider is authoritative for path interpretation and filesystem facts used by workspace permission validation. Paths are interpreted lexically; home-relative paths (`~` and `~/...`) and Windows drive-relative paths such as `C:foo` are unsupported. Until provider-side canonicalization is supported, providers must not expose symlinks inside allowed roots that escape those roots.
|
|
4098
4481
|
*
|
|
4099
4482
|
* @returns Indicates whether the calling client was registered as the session filesystem provider.
|
|
4100
4483
|
*/
|
|
@@ -4398,15 +4781,7 @@ function createInternalServerRpc(connection) {
|
|
|
4398
4781
|
*/
|
|
4399
4782
|
getBoardEntryCount: async (params) => connection.sendRequest("sessions.getBoardEntryCount", params),
|
|
4400
4783
|
/**
|
|
4401
|
-
*
|
|
4402
|
-
*
|
|
4403
|
-
* @param params Params to attach an extension loader's tools to a session.
|
|
4404
|
-
*
|
|
4405
|
-
* @returns Handle for releasing the extension tool registration.
|
|
4406
|
-
*/
|
|
4407
|
-
registerExtensionToolsOnSession: async (params) => connection.sendRequest("sessions.registerExtensionToolsOnSession", params),
|
|
4408
|
-
/**
|
|
4409
|
-
* Attaches (or detaches) an in-process ExtensionController delegate for the given session, used by shared-API surfaces that need to query or modify the session's extension state. Pass `controller: undefined` to detach. Marked internal because the controller is an in-process object that cannot cross the JSON-RPC boundary. Disappears alongside `registerExtensionToolsOnSession`: once the runtime owns extension management, the public surface exposes list/enable/disable/reload as dedicated RPCs served by the runtime.
|
|
4784
|
+
* Attaches (or detaches) an in-process ExtensionController delegate for the given session in a local host adapter. Pass `controller: undefined` to detach. Internal because the controller cannot cross the JSON-RPC boundary; the runtime manages its own session extension service.
|
|
4410
4785
|
*
|
|
4411
4786
|
* @param params Params to attach or detach an in-process ExtensionController delegate.
|
|
4412
4787
|
*/
|
|
@@ -4515,11 +4890,11 @@ function createSessionRpc(connection, sessionId) {
|
|
|
4515
4890
|
/** @experimental */
|
|
4516
4891
|
debug: {
|
|
4517
4892
|
/**
|
|
4518
|
-
* Collects a
|
|
4893
|
+
* 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.
|
|
4519
4894
|
*
|
|
4520
|
-
* @param params Options for collecting a
|
|
4895
|
+
* @param params Options for collecting a session debug bundle with configurable redaction.
|
|
4521
4896
|
*
|
|
4522
|
-
* @returns Result of collecting a
|
|
4897
|
+
* @returns Result of collecting a session debug bundle.
|
|
4523
4898
|
*/
|
|
4524
4899
|
collectLogs: async (params) => connection.sendRequest("session.debug.collectLogs", { sessionId, ...params })
|
|
4525
4900
|
},
|
|
@@ -4666,6 +5041,108 @@ function createSessionRpc(connection, sessionId) {
|
|
|
4666
5041
|
}
|
|
4667
5042
|
},
|
|
4668
5043
|
/** @experimental */
|
|
5044
|
+
workflow: {
|
|
5045
|
+
/**
|
|
5046
|
+
* Runs a registered dynamic workflow by name at the top level.
|
|
5047
|
+
*
|
|
5048
|
+
* @param params Parameters for invoking a registered workflow.
|
|
5049
|
+
*
|
|
5050
|
+
* @returns Complete current or terminal workflow run envelope.
|
|
5051
|
+
*/
|
|
5052
|
+
run: async (params) => connection.sendRequest("session.workflow.run", { sessionId, ...params }),
|
|
5053
|
+
/**
|
|
5054
|
+
* Resumes a dynamic workflow run using its persisted name, arguments, journal, and accounting.
|
|
5055
|
+
*
|
|
5056
|
+
* @param params Parameters for resuming a workflow run from its persisted identity.
|
|
5057
|
+
*
|
|
5058
|
+
* @returns Resolved persisted workflow identity and resumed run envelope.
|
|
5059
|
+
*/
|
|
5060
|
+
resume: async (params) => connection.sendRequest("session.workflow.resume", { sessionId, ...params }),
|
|
5061
|
+
/**
|
|
5062
|
+
* Gets the current or settled envelope for a dynamic workflow run.
|
|
5063
|
+
*
|
|
5064
|
+
* @param params Parameters for retrieving a workflow run.
|
|
5065
|
+
*
|
|
5066
|
+
* @returns Complete current or terminal workflow run envelope.
|
|
5067
|
+
*/
|
|
5068
|
+
getRun: async (params) => connection.sendRequest("session.workflow.getRun", { sessionId, ...params }),
|
|
5069
|
+
/**
|
|
5070
|
+
* Lists durable dynamic workflow runs for this session in creation order.
|
|
5071
|
+
*
|
|
5072
|
+
* @param params Parameters for paging workflow runs.
|
|
5073
|
+
*
|
|
5074
|
+
* @returns A page of workflow runs in durable creation order.
|
|
5075
|
+
*/
|
|
5076
|
+
listRuns: async (params) => connection.sendRequest("session.workflow.listRuns", { sessionId, ...params }),
|
|
5077
|
+
/**
|
|
5078
|
+
* Gets durable and live observability detail for one dynamic workflow run.
|
|
5079
|
+
*
|
|
5080
|
+
* @param params Parameters for retrieving a workflow run.
|
|
5081
|
+
*
|
|
5082
|
+
* @returns Full workflow run observability detail.
|
|
5083
|
+
*/
|
|
5084
|
+
getRunDetail: async (params) => connection.sendRequest("session.workflow.getRunDetail", { sessionId, ...params }),
|
|
5085
|
+
/**
|
|
5086
|
+
* Pages durable progress for one dynamic workflow run.
|
|
5087
|
+
*
|
|
5088
|
+
* @param params Parameters for paging workflow progress.
|
|
5089
|
+
*
|
|
5090
|
+
* @returns A bidirectional page of workflow progress.
|
|
5091
|
+
*/
|
|
5092
|
+
getRunProgress: async (params) => connection.sendRequest("session.workflow.getRunProgress", { sessionId, ...params }),
|
|
5093
|
+
/**
|
|
5094
|
+
* Requests cancellation of a dynamic workflow run and returns its run envelope.
|
|
5095
|
+
*
|
|
5096
|
+
* @param params Parameters for cancelling a workflow run.
|
|
5097
|
+
*
|
|
5098
|
+
* @returns Complete current or terminal workflow run envelope.
|
|
5099
|
+
*/
|
|
5100
|
+
cancel: async (params) => connection.sendRequest("session.workflow.cancel", { sessionId, ...params }),
|
|
5101
|
+
/**
|
|
5102
|
+
* Pauses a running dynamic workflow and returns its settled run envelope.
|
|
5103
|
+
*
|
|
5104
|
+
* @param params Parameters for pausing a running workflow.
|
|
5105
|
+
*
|
|
5106
|
+
* @returns Complete current or terminal workflow run envelope.
|
|
5107
|
+
*/
|
|
5108
|
+
pause: async (params) => connection.sendRequest("session.workflow.pause", { sessionId, ...params }),
|
|
5109
|
+
/**
|
|
5110
|
+
* Records a batch of ordered dynamic workflow progress lines.
|
|
5111
|
+
*
|
|
5112
|
+
* @param params Parameters for recording workflow progress.
|
|
5113
|
+
*
|
|
5114
|
+
* @returns Acknowledgement that a workflow request was accepted.
|
|
5115
|
+
*/
|
|
5116
|
+
log: async (params) => connection.sendRequest("session.workflow.log", { sessionId, ...params }),
|
|
5117
|
+
/**
|
|
5118
|
+
* Runs one dynamic-workflow-scoped subagent and returns its result.
|
|
5119
|
+
*
|
|
5120
|
+
* @param params Parameters for one workflow-scoped subagent call.
|
|
5121
|
+
*
|
|
5122
|
+
* @returns Result of one workflow-scoped subagent call.
|
|
5123
|
+
*/
|
|
5124
|
+
agent: async (params) => connection.sendRequest("session.workflow.agent", { sessionId, ...params }),
|
|
5125
|
+
/** @experimental */
|
|
5126
|
+
journal: {
|
|
5127
|
+
/**
|
|
5128
|
+
* Reads a memoized dynamic workflow journal entry.
|
|
5129
|
+
*
|
|
5130
|
+
* @param params Parameters for reading a workflow journal entry.
|
|
5131
|
+
*
|
|
5132
|
+
* @returns Result of reading a workflow journal entry.
|
|
5133
|
+
*/
|
|
5134
|
+
get: async (params) => connection.sendRequest("session.workflow.journal.get", { sessionId, ...params }),
|
|
5135
|
+
/**
|
|
5136
|
+
* Stores a memoized dynamic workflow journal entry.
|
|
5137
|
+
*
|
|
5138
|
+
* @param params Parameters for storing a workflow journal entry.
|
|
5139
|
+
*
|
|
5140
|
+
* @returns Acknowledgement that a workflow request was accepted.
|
|
5141
|
+
*/
|
|
5142
|
+
put: async (params) => connection.sendRequest("session.workflow.journal.put", { sessionId, ...params })
|
|
5143
|
+
}
|
|
5144
|
+
},
|
|
5145
|
+
/** @experimental */
|
|
4669
5146
|
model: {
|
|
4670
5147
|
/**
|
|
4671
5148
|
* Gets the session's authoritative model snapshot, including the committed Auto preference and any newer unclaimed Auto preference waiting for a future user turn.
|
|
@@ -4829,6 +5306,32 @@ function createSessionRpc(connection, sessionId) {
|
|
|
4829
5306
|
* @param params Relative path and UTF-8 content for the workspace file to create or overwrite.
|
|
4830
5307
|
*/
|
|
4831
5308
|
createFile: async (params) => connection.sendRequest("session.workspaces.createFile", { sessionId, ...params }),
|
|
5309
|
+
/**
|
|
5310
|
+
* Returns metadata for a file or directory in the session workspace files directory.
|
|
5311
|
+
*
|
|
5312
|
+
* @param params Relative path of the workspace file or directory to inspect.
|
|
5313
|
+
*
|
|
5314
|
+
* @returns Filesystem metadata for a path in the session workspace files directory.
|
|
5315
|
+
*/
|
|
5316
|
+
statFile: async (params) => connection.sendRequest("session.workspaces.statFile", { sessionId, ...params }),
|
|
5317
|
+
/**
|
|
5318
|
+
* Creates a directory in the session workspace files directory.
|
|
5319
|
+
*
|
|
5320
|
+
* @param params Directory to create within the session workspace files directory.
|
|
5321
|
+
*/
|
|
5322
|
+
createDirectory: async (params) => connection.sendRequest("session.workspaces.createDirectory", { sessionId, ...params }),
|
|
5323
|
+
/**
|
|
5324
|
+
* Removes a file or directory from the session workspace files directory.
|
|
5325
|
+
*
|
|
5326
|
+
* @param params File or directory to remove from the session workspace files directory.
|
|
5327
|
+
*/
|
|
5328
|
+
removePath: async (params) => connection.sendRequest("session.workspaces.removePath", { sessionId, ...params }),
|
|
5329
|
+
/**
|
|
5330
|
+
* Renames a file or directory within the session workspace files directory.
|
|
5331
|
+
*
|
|
5332
|
+
* @param params Source and destination paths for a rename within the session workspace files directory.
|
|
5333
|
+
*/
|
|
5334
|
+
renamePath: async (params) => connection.sendRequest("session.workspaces.renamePath", { sessionId, ...params }),
|
|
4832
5335
|
/**
|
|
4833
5336
|
* Lists workspace checkpoints in chronological order.
|
|
4834
5337
|
*
|
|
@@ -5345,83 +5848,246 @@ function createSessionRpc(connection, sessionId) {
|
|
|
5345
5848
|
}
|
|
5346
5849
|
},
|
|
5347
5850
|
/** @experimental */
|
|
5348
|
-
|
|
5851
|
+
connectors: {
|
|
5349
5852
|
/**
|
|
5350
|
-
*
|
|
5853
|
+
* Returns feature availability and bounded polling limits for the EXPERIMENTAL session connector API. This method never performs a Connector service request.
|
|
5351
5854
|
*
|
|
5352
|
-
* @returns
|
|
5855
|
+
* @returns Feature detection and hard polling limits for the EXPERIMENTAL session connector API.
|
|
5353
5856
|
*/
|
|
5354
|
-
|
|
5857
|
+
getCapabilities: async () => connection.sendRequest("session.connectors.getCapabilities", { sessionId }),
|
|
5355
5858
|
/**
|
|
5356
|
-
*
|
|
5859
|
+
* Returns authoritative session Connector state from current availability, pinned account selection, cached catalog, and live MCP projection without performing a Connector service request.
|
|
5357
5860
|
*
|
|
5358
|
-
* @
|
|
5861
|
+
* @returns Authoritative session connector state. Account IDs are opaque routing identifiers and credentials are never included.
|
|
5359
5862
|
*/
|
|
5360
|
-
|
|
5361
|
-
},
|
|
5362
|
-
/** @experimental */
|
|
5363
|
-
provider: {
|
|
5863
|
+
getStatus: async () => connection.sendRequest("session.connectors.getStatus", { sessionId }),
|
|
5364
5864
|
/**
|
|
5365
|
-
* Returns the
|
|
5865
|
+
* Returns the cached Connector catalog for the pinned opaque account selection, fetching it only when this session has no cached catalog.
|
|
5366
5866
|
*
|
|
5367
|
-
* @param params
|
|
5867
|
+
* @param params Pins a Connector operation to one host-owned GitHub account through its opaque selection ID. Provider tokens are never accepted.
|
|
5368
5868
|
*
|
|
5369
|
-
* @returns
|
|
5869
|
+
* @returns Validated Connector catalog snapshot cached by the session.
|
|
5370
5870
|
*/
|
|
5371
|
-
|
|
5871
|
+
list: async (params) => connection.sendRequest("session.connectors.list", { sessionId, ...params }),
|
|
5372
5872
|
/**
|
|
5373
|
-
*
|
|
5873
|
+
* Refreshes and validates the Connector catalog for the pinned opaque account selection.
|
|
5374
5874
|
*
|
|
5375
|
-
* @param params
|
|
5875
|
+
* @param params Pins a Connector operation to one host-owned GitHub account through its opaque selection ID. Provider tokens are never accepted.
|
|
5376
5876
|
*
|
|
5377
|
-
* @returns
|
|
5877
|
+
* @returns Validated Connector catalog snapshot cached by the session.
|
|
5378
5878
|
*/
|
|
5379
|
-
|
|
5380
|
-
},
|
|
5381
|
-
/** @experimental */
|
|
5382
|
-
options: {
|
|
5879
|
+
refresh: async (params) => connection.sendRequest("session.connectors.refresh", { sessionId, ...params }),
|
|
5383
5880
|
/**
|
|
5384
|
-
*
|
|
5881
|
+
* Initiates an idempotent Connector connection request without opening a browser. Returns connected when the service is immediately authoritative, consent_required with a validated URL, or pending with an opaque continuation ID.
|
|
5385
5882
|
*
|
|
5386
|
-
* @param params
|
|
5883
|
+
* @param params Selects one Connector and the pinned host-owned account used for its service and MCP authorization.
|
|
5387
5884
|
*
|
|
5388
|
-
* @returns
|
|
5885
|
+
* @returns Typed result of initiating or continuing a Connector connection.
|
|
5389
5886
|
*/
|
|
5390
|
-
|
|
5391
|
-
},
|
|
5392
|
-
/** @experimental */
|
|
5393
|
-
lsp: {
|
|
5887
|
+
connect: async (params) => connection.sendRequest("session.connectors.connect", { sessionId, ...params }),
|
|
5394
5888
|
/**
|
|
5395
|
-
*
|
|
5889
|
+
* Re-initiates an idempotent Connector connection request without browser or UI effects, with the same typed outcomes as connect.
|
|
5396
5890
|
*
|
|
5397
|
-
* @param params
|
|
5891
|
+
* @param params Selects one Connector and the pinned host-owned account used for its service and MCP authorization.
|
|
5892
|
+
*
|
|
5893
|
+
* @returns Typed result of initiating or continuing a Connector connection.
|
|
5398
5894
|
*/
|
|
5399
|
-
|
|
5400
|
-
},
|
|
5401
|
-
/** @experimental */
|
|
5402
|
-
extensions: {
|
|
5895
|
+
reconnect: async (params) => connection.sendRequest("session.connectors.reconnect", { sessionId, ...params }),
|
|
5403
5896
|
/**
|
|
5404
|
-
*
|
|
5897
|
+
* Continues a pending Connector connection with caller-supplied attempt, interval, and deadline bounds. The runtime never opens the returned consent URL.
|
|
5405
5898
|
*
|
|
5406
|
-
* @
|
|
5899
|
+
* @param params Explicitly bounded continuation of a pending Connector connection.
|
|
5900
|
+
*
|
|
5901
|
+
* @returns Typed result of initiating or continuing a Connector connection.
|
|
5407
5902
|
*/
|
|
5408
|
-
|
|
5903
|
+
continueConnection: async (params) => connection.sendRequest("session.connectors.continueConnection", { sessionId, ...params }),
|
|
5409
5904
|
/**
|
|
5410
|
-
*
|
|
5905
|
+
* Disconnects one Connector for the pinned opaque account selection, refreshes the authoritative catalog, and removes its session-owned MCP projection.
|
|
5411
5906
|
*
|
|
5412
|
-
* @param params
|
|
5907
|
+
* @param params Selects one Connector and the pinned host-owned account used for its service and MCP authorization.
|
|
5908
|
+
*
|
|
5909
|
+
* @returns Authoritative result after disconnect and MCP reconciliation.
|
|
5413
5910
|
*/
|
|
5414
|
-
|
|
5911
|
+
disconnect: async (params) => connection.sendRequest("session.connectors.disconnect", { sessionId, ...params }),
|
|
5415
5912
|
/**
|
|
5416
|
-
*
|
|
5913
|
+
* Reconciles the authoritative cached or freshly requested Connector catalog into the session Connector MCP projection and returns live status.
|
|
5417
5914
|
*
|
|
5418
|
-
* @param params
|
|
5915
|
+
* @param params Requests authoritative Connector-to-MCP reconciliation for the pinned account.
|
|
5916
|
+
*
|
|
5917
|
+
* @returns Authoritative session connector state. Account IDs are opaque routing identifiers and credentials are never included.
|
|
5419
5918
|
*/
|
|
5420
|
-
|
|
5919
|
+
reconcile: async (params) => connection.sendRequest("session.connectors.reconcile", { sessionId, ...params })
|
|
5920
|
+
},
|
|
5921
|
+
/** @experimental */
|
|
5922
|
+
managedSettings: {
|
|
5421
5923
|
/**
|
|
5422
|
-
*
|
|
5924
|
+
* Waits for the live session's in-flight managed-settings application, then returns the retained effective snapshot used by runtime enforcement and by `session.managed_settings_resolved`. It does not perform another account, device, or server resolution, and rejects when resolution has not produced a snapshot.
|
|
5925
|
+
*
|
|
5926
|
+
* @returns Enterprise managed-settings resolution: the effective managed settings the session applied and which channels contributed, so SDK clients can show users what is enterprise-managed. Fires whenever managed policy is (re)applied — at session start, on resume, and on account switch. This is an ephemeral live snapshot (delivered to subscribers but not persisted to the session event log), because at session start it resolves before `session.start` is emitted. Device values take precedence over server values, then the policy helper, per ordinary key, while permissions compose restrictively across device, server, policy-helper, and SDK-client layers. The account-scoped `getManagedSettings()` API does not include session-local client injection. Marked experimental while the managed-settings surface stabilizes.
|
|
5423
5927
|
*/
|
|
5424
|
-
|
|
5928
|
+
get: async () => connection.sendRequest("session.managedSettings.get", { sessionId })
|
|
5929
|
+
},
|
|
5930
|
+
/** @experimental */
|
|
5931
|
+
plugins: {
|
|
5932
|
+
/**
|
|
5933
|
+
* Lists globally installed, live, built-in, and enterprise-managed desired plugins using the live session's authoritative account, working directory, and retained managed policy.
|
|
5934
|
+
*
|
|
5935
|
+
* @returns Plugins installed for the session, with their enabled state and version metadata.
|
|
5936
|
+
*/
|
|
5937
|
+
list: async () => connection.sendRequest("session.plugins.list", { sessionId }),
|
|
5938
|
+
/**
|
|
5939
|
+
* Installs a plugin using the live session's authoritative account, working directory, and retained managed policy.
|
|
5940
|
+
*
|
|
5941
|
+
* @param params Plugin source resolved relative to the session's authoritative working directory.
|
|
5942
|
+
*
|
|
5943
|
+
* @returns Result of installing a plugin.
|
|
5944
|
+
*/
|
|
5945
|
+
install: async (params) => connection.sendRequest("session.plugins.install", { sessionId, ...params }),
|
|
5946
|
+
/**
|
|
5947
|
+
* Uninstalls a plugin when permitted by the live session's retained managed policy.
|
|
5948
|
+
*
|
|
5949
|
+
* @param params Name (or spec) of the plugin to uninstall.
|
|
5950
|
+
*/
|
|
5951
|
+
uninstall: async (params) => connection.sendRequest("session.plugins.uninstall", { sessionId, ...params }),
|
|
5952
|
+
/**
|
|
5953
|
+
* Updates an installed plugin using the live session's authoritative account, working directory, and retained managed policy.
|
|
5954
|
+
*
|
|
5955
|
+
* @param params Name (or spec) of the plugin to update.
|
|
5956
|
+
*
|
|
5957
|
+
* @returns Result of updating a single plugin.
|
|
5958
|
+
*/
|
|
5959
|
+
update: async (params) => connection.sendRequest("session.plugins.update", { sessionId, ...params }),
|
|
5960
|
+
/**
|
|
5961
|
+
* Enables installed plugins when permitted by the live session's retained managed policy.
|
|
5962
|
+
*
|
|
5963
|
+
* @param params Plugin names (or specs) to enable in the session's authoritative working directory.
|
|
5964
|
+
*/
|
|
5965
|
+
enable: async (params) => connection.sendRequest("session.plugins.enable", { sessionId, ...params }),
|
|
5966
|
+
/**
|
|
5967
|
+
* Disables installed plugins when permitted by the live session's retained managed policy.
|
|
5968
|
+
*
|
|
5969
|
+
* @param params Plugin names (or specs) to disable in the session's authoritative working directory.
|
|
5970
|
+
*/
|
|
5971
|
+
disable: async (params) => connection.sendRequest("session.plugins.disable", { sessionId, ...params }),
|
|
5972
|
+
/** @experimental */
|
|
5973
|
+
marketplaces: {
|
|
5974
|
+
/**
|
|
5975
|
+
* Lists registered and enterprise-managed desired marketplaces using the live session's retained policy.
|
|
5976
|
+
*
|
|
5977
|
+
* @returns All registered marketplaces, including built-in defaults.
|
|
5978
|
+
*/
|
|
5979
|
+
list: async () => connection.sendRequest("session.plugins.marketplaces.list", { sessionId }),
|
|
5980
|
+
/**
|
|
5981
|
+
* Adds a marketplace when permitted by the live session's retained managed policy.
|
|
5982
|
+
*
|
|
5983
|
+
* @param params Marketplace source and optional working directory for relative-path resolution.
|
|
5984
|
+
*
|
|
5985
|
+
* @returns Result of registering a new marketplace.
|
|
5986
|
+
*/
|
|
5987
|
+
add: async (params) => connection.sendRequest("session.plugins.marketplaces.add", { sessionId, ...params }),
|
|
5988
|
+
/**
|
|
5989
|
+
* Removes a marketplace when permitted by the live session's retained managed policy.
|
|
5990
|
+
*
|
|
5991
|
+
* @param params Name of the marketplace to remove and an optional force flag.
|
|
5992
|
+
*
|
|
5993
|
+
* @returns Outcome of the remove attempt, including dependent-plugin info when applicable.
|
|
5994
|
+
*/
|
|
5995
|
+
remove: async (params) => connection.sendRequest("session.plugins.marketplaces.remove", { sessionId, ...params }),
|
|
5996
|
+
/**
|
|
5997
|
+
* Browses a marketplace resolved through the live session's working directory and retained managed policy.
|
|
5998
|
+
*
|
|
5999
|
+
* @param params Name of the marketplace whose plugin catalog to fetch.
|
|
6000
|
+
*
|
|
6001
|
+
* @returns Plugins advertised by the marketplace.
|
|
6002
|
+
*/
|
|
6003
|
+
browse: async (params) => connection.sendRequest("session.plugins.marketplaces.browse", { sessionId, ...params }),
|
|
6004
|
+
/**
|
|
6005
|
+
* Refreshes marketplaces resolved through the live session's working directory and retained managed policy.
|
|
6006
|
+
*
|
|
6007
|
+
* @param params Optional marketplace name; omit to refresh all.
|
|
6008
|
+
*
|
|
6009
|
+
* @returns Result of refreshing one or more marketplace catalogs.
|
|
6010
|
+
*/
|
|
6011
|
+
refresh: async (params) => connection.sendRequest("session.plugins.marketplaces.refresh", { sessionId, ...params })
|
|
6012
|
+
},
|
|
6013
|
+
/**
|
|
6014
|
+
* Reloads the session's plugin set, refreshing MCP servers, custom agents, hooks, and skills cache so SDK-driven changes via `server.plugins.*` take effect immediately.
|
|
6015
|
+
*
|
|
6016
|
+
* @param params Optional flags controlling which side effects the reload performs.
|
|
6017
|
+
*/
|
|
6018
|
+
reload: async (params) => connection.sendRequest("session.plugins.reload", { sessionId, ...params })
|
|
6019
|
+
},
|
|
6020
|
+
/** @experimental */
|
|
6021
|
+
provider: {
|
|
6022
|
+
/**
|
|
6023
|
+
* Returns the provider endpoint and credentials the session is currently configured to talk to, so the caller can make inference calls directly against the same backend the session uses.
|
|
6024
|
+
*
|
|
6025
|
+
* @param params Optional model identifier to scope the endpoint snapshot to.
|
|
6026
|
+
*
|
|
6027
|
+
* @returns A snapshot of the provider endpoint the session is currently configured to talk to.
|
|
6028
|
+
*/
|
|
6029
|
+
getEndpoint: async (params) => connection.sendRequest("session.provider.getEndpoint", { sessionId, ...params }),
|
|
6030
|
+
/**
|
|
6031
|
+
* Adds BYOK providers and/or models to the session's registry at runtime, extending the additive registry built from the session's `providers`/`models` options. Both fields are optional, so a call may add providers only, models only, or both. Within a single call providers are registered before models, so a model may reference a provider added in the same call; across calls a model may reference any provider already registered (from session creation or a prior add). A model whose referenced provider is not registered by the end of the call is rejected. Newly added models become selectable via `model.list` / `model.switchTo` and are inherited by sub-agents spawned afterwards.
|
|
6032
|
+
*
|
|
6033
|
+
* @param params BYOK providers and/or models to add to the session's registry at runtime. Both fields are optional; provide providers, models, or both.
|
|
6034
|
+
*
|
|
6035
|
+
* @returns The selectable model entries synthesized for the models added by this call.
|
|
6036
|
+
*/
|
|
6037
|
+
add: async (params) => connection.sendRequest("session.provider.add", { sessionId, ...params }),
|
|
6038
|
+
/**
|
|
6039
|
+
* Atomically updates the session's BYOK provider and model registry by applying the supplied snapshot, replacing existing entries, updating models, or removing entries absent from the snapshot.
|
|
6040
|
+
*
|
|
6041
|
+
* @param params Authoritative BYOK provider and model registry snapshot to apply atomically to the session.
|
|
6042
|
+
*
|
|
6043
|
+
* @returns The selectable model entries and selection ids synthesized for the synchronized BYOK models.
|
|
6044
|
+
*/
|
|
6045
|
+
sync: async (params) => connection.sendRequest("session.provider.sync", { sessionId, ...params })
|
|
6046
|
+
},
|
|
6047
|
+
/** @experimental */
|
|
6048
|
+
options: {
|
|
6049
|
+
/**
|
|
6050
|
+
* Patches the genuinely-mutable subset of session options.
|
|
6051
|
+
*
|
|
6052
|
+
* @param params Patch of mutable session options to apply to the running session.
|
|
6053
|
+
*
|
|
6054
|
+
* @returns Indicates whether the session options patch was applied successfully.
|
|
6055
|
+
*/
|
|
6056
|
+
update: async (params) => connection.sendRequest("session.options.update", { sessionId, ...params })
|
|
6057
|
+
},
|
|
6058
|
+
/** @experimental */
|
|
6059
|
+
lsp: {
|
|
6060
|
+
/**
|
|
6061
|
+
* Loads the merged LSP configuration set for the session's working directory.
|
|
6062
|
+
*
|
|
6063
|
+
* @param params Parameters for (re)loading the merged LSP configuration set.
|
|
6064
|
+
*/
|
|
6065
|
+
initialize: async (params) => connection.sendRequest("session.lsp.initialize", { sessionId, ...params })
|
|
6066
|
+
},
|
|
6067
|
+
/** @experimental */
|
|
6068
|
+
extensions: {
|
|
6069
|
+
/**
|
|
6070
|
+
* Lists extensions discovered for the session and their current status.
|
|
6071
|
+
*
|
|
6072
|
+
* @returns Extensions discovered for the session, with their current status.
|
|
6073
|
+
*/
|
|
6074
|
+
list: async () => connection.sendRequest("session.extensions.list", { sessionId }),
|
|
6075
|
+
/**
|
|
6076
|
+
* Enables an extension for the session.
|
|
6077
|
+
*
|
|
6078
|
+
* @param params Source-qualified extension identifier to enable for the session.
|
|
6079
|
+
*/
|
|
6080
|
+
enable: async (params) => connection.sendRequest("session.extensions.enable", { sessionId, ...params }),
|
|
6081
|
+
/**
|
|
6082
|
+
* Disables an extension for the session.
|
|
6083
|
+
*
|
|
6084
|
+
* @param params Source-qualified extension identifier to disable for the session.
|
|
6085
|
+
*/
|
|
6086
|
+
disable: async (params) => connection.sendRequest("session.extensions.disable", { sessionId, ...params }),
|
|
6087
|
+
/**
|
|
6088
|
+
* Reloads extension definitions and processes for the session.
|
|
6089
|
+
*/
|
|
6090
|
+
reload: async () => connection.sendRequest("session.extensions.reload", { sessionId }),
|
|
5425
6091
|
/**
|
|
5426
6092
|
* Push attachments into the next user-message turn from an extension. The host should surface them as composer pills and forward them via the next session.send call. Callable only by extension-owned connections.
|
|
5427
6093
|
*
|
|
@@ -5702,9 +6368,9 @@ function createSessionRpc(connection, sessionId) {
|
|
|
5702
6368
|
*/
|
|
5703
6369
|
setRequired: async (params) => connection.sendRequest("session.permissions.setRequired", { sessionId, ...params }),
|
|
5704
6370
|
/**
|
|
5705
|
-
* Clears session-scoped tool
|
|
6371
|
+
* Clears session-scoped tool approvals and, for full resets, exact session-approved paths.
|
|
5706
6372
|
*
|
|
5707
|
-
* @param params Clears session-scoped tool
|
|
6373
|
+
* @param params Clears session-scoped tool approvals and optionally clears location-scoped approvals and exact session-approved paths.
|
|
5708
6374
|
*
|
|
5709
6375
|
* @returns Indicates whether the operation succeeded.
|
|
5710
6376
|
*/
|
|
@@ -5720,9 +6386,9 @@ function createSessionRpc(connection, sessionId) {
|
|
|
5720
6386
|
/** @experimental */
|
|
5721
6387
|
paths: {
|
|
5722
6388
|
/**
|
|
5723
|
-
* Returns the session's
|
|
6389
|
+
* Returns the session's recursive directory grants, exact session-approved paths, and primary working directory.
|
|
5724
6390
|
*
|
|
5725
|
-
* @returns Snapshot of the session's
|
|
6391
|
+
* @returns Snapshot of the session's recursive directory grants, exact session-approved paths, and primary working directory.
|
|
5726
6392
|
*/
|
|
5727
6393
|
list: async () => connection.sendRequest("session.permissions.paths.list", { sessionId }),
|
|
5728
6394
|
/**
|
|
@@ -6060,6 +6726,22 @@ function createSessionRpc(connection, sessionId) {
|
|
|
6060
6726
|
* @returns Result of editing a queued message.
|
|
6061
6727
|
*/
|
|
6062
6728
|
updateText: async (params) => connection.sendRequest("session.queue.updateText", { sessionId, ...params }),
|
|
6729
|
+
/**
|
|
6730
|
+
* Atomically withdraws an unchanged, unconsumed user message from the local queued or steering lane. A client retaining the original draft may restore it only when removed is true. Does not interrupt the running turn.
|
|
6731
|
+
*
|
|
6732
|
+
* @param params Conditional withdrawal of a single user message, before the runtime claims it for delivery.
|
|
6733
|
+
*
|
|
6734
|
+
* @returns Result of removing a queued item.
|
|
6735
|
+
*/
|
|
6736
|
+
withdrawMessage: async (params) => connection.sendRequest("session.queue.withdrawMessage", { sessionId, ...params }),
|
|
6737
|
+
/**
|
|
6738
|
+
* Atomically appends text and attachments to an unchanged, unconsumed local steering message. Returns updated=false if delivery or withdrawal already claimed the message.
|
|
6739
|
+
*
|
|
6740
|
+
* @param params Append to one pending steering message without changing its identity or delivery position.
|
|
6741
|
+
*
|
|
6742
|
+
* @returns Result of editing a queued message.
|
|
6743
|
+
*/
|
|
6744
|
+
appendSteering: async (params) => connection.sendRequest("session.queue.appendSteering", { sessionId, ...params }),
|
|
6063
6745
|
/**
|
|
6064
6746
|
* Duplicates an addressable queued item immediately after its source.
|
|
6065
6747
|
*
|
|
@@ -6314,6 +6996,31 @@ function createInternalSessionRpc(connection, sessionId) {
|
|
|
6314
6996
|
pauseAtCheckpoint: async (params) => connection.sendRequest("session.factory.pauseAtCheckpoint", { sessionId, ...params })
|
|
6315
6997
|
},
|
|
6316
6998
|
/** @experimental */
|
|
6999
|
+
workflow: {
|
|
7000
|
+
/**
|
|
7001
|
+
* Internal tool-originated dynamic workflow invocation.
|
|
7002
|
+
*
|
|
7003
|
+
* @param params Internal parameters for invoking a registered workflow from a tool.
|
|
7004
|
+
*
|
|
7005
|
+
* @returns Complete current or terminal workflow run envelope.
|
|
7006
|
+
*/
|
|
7007
|
+
runFromTool: async (params) => connection.sendRequest("session.workflow.runFromTool", { sessionId, ...params }),
|
|
7008
|
+
/**
|
|
7009
|
+
* Internal tool-originated dynamic workflow resume.
|
|
7010
|
+
*
|
|
7011
|
+
* @param params Internal parameters for resuming a workflow run from a tool.
|
|
7012
|
+
*
|
|
7013
|
+
* @returns Resolved persisted workflow identity and resumed run envelope.
|
|
7014
|
+
*/
|
|
7015
|
+
resumeFromTool: async (params) => connection.sendRequest("session.workflow.resumeFromTool", { sessionId, ...params }),
|
|
7016
|
+
/**
|
|
7017
|
+
* Atomically pauses an owned dynamic workflow attempt at a durable checkpoint.
|
|
7018
|
+
*
|
|
7019
|
+
* @param params Parameters for an owned durable pause checkpoint.
|
|
7020
|
+
*/
|
|
7021
|
+
pauseAtCheckpoint: async (params) => connection.sendRequest("session.workflow.pauseAtCheckpoint", { sessionId, ...params })
|
|
7022
|
+
},
|
|
7023
|
+
/** @experimental */
|
|
6317
7024
|
model: {
|
|
6318
7025
|
/**
|
|
6319
7026
|
* Resolves and applies organization-managed and repository model overlays.
|
|
@@ -6356,6 +7063,23 @@ function createInternalSessionRpc(connection, sessionId) {
|
|
|
6356
7063
|
unregisterExternalClient: async (params) => connection.sendRequest("session.mcp.unregisterExternalClient", { sessionId, ...params })
|
|
6357
7064
|
},
|
|
6358
7065
|
/** @experimental */
|
|
7066
|
+
connectors: {
|
|
7067
|
+
/**
|
|
7068
|
+
* Reconciles the authoritative Connector catalog into the session MCP projection during startup with a bounded deadline and fail-closed cleanup.
|
|
7069
|
+
*
|
|
7070
|
+
* @param params Pins a Connector operation to one host-owned GitHub account through its opaque selection ID. Provider tokens are never accepted.
|
|
7071
|
+
*
|
|
7072
|
+
* @returns Authoritative session connector state. Account IDs are opaque routing identifiers and credentials are never included.
|
|
7073
|
+
*/
|
|
7074
|
+
reconcileForStartup: async (params) => connection.sendRequest("session.connectors.reconcileForStartup", { sessionId, ...params }),
|
|
7075
|
+
/**
|
|
7076
|
+
* Removes the runtime-owned Connector MCP projection without changing service-side connections.
|
|
7077
|
+
*
|
|
7078
|
+
* @returns Authoritative session connector state. Account IDs are opaque routing identifiers and credentials are never included.
|
|
7079
|
+
*/
|
|
7080
|
+
withdrawProjection: async () => connection.sendRequest("session.connectors.withdrawProjection", { sessionId })
|
|
7081
|
+
},
|
|
7082
|
+
/** @experimental */
|
|
6359
7083
|
commands: {
|
|
6360
7084
|
/**
|
|
6361
7085
|
* Finalizes persistence associated with a client-applied slash-command effect.
|
|
@@ -6509,6 +7233,16 @@ function registerClientSessionApiHandlers(connection, getHandlers) {
|
|
|
6509
7233
|
if (!handler) throw new Error(`No factory handler registered for session: ${params.sessionId}`);
|
|
6510
7234
|
return handler.abort(params);
|
|
6511
7235
|
});
|
|
7236
|
+
connection.onRequest("workflow.execute", async (params) => {
|
|
7237
|
+
const handler = getHandlers(params.sessionId).workflow;
|
|
7238
|
+
if (!handler) throw new Error(`No workflow handler registered for session: ${params.sessionId}`);
|
|
7239
|
+
return handler.execute(params);
|
|
7240
|
+
});
|
|
7241
|
+
connection.onRequest("workflow.abort", async (params) => {
|
|
7242
|
+
const handler = getHandlers(params.sessionId).workflow;
|
|
7243
|
+
if (!handler) throw new Error(`No workflow handler registered for session: ${params.sessionId}`);
|
|
7244
|
+
return handler.abort(params);
|
|
7245
|
+
});
|
|
6512
7246
|
connection.onRequest("tasks.cancel", async (params) => {
|
|
6513
7247
|
const handler = getHandlers(params.sessionId).tasks;
|
|
6514
7248
|
if (!handler) throw new Error(`No tasks handler registered for session: ${params.sessionId}`);
|
|
@@ -6623,17 +7357,17 @@ function registerClientGlobalApiHandlers(connection, handlers) {
|
|
|
6623
7357
|
});
|
|
6624
7358
|
}
|
|
6625
7359
|
|
|
6626
|
-
//
|
|
7360
|
+
// src/sdk/nodejs/dist/sdkProtocolVersion.js
|
|
6627
7361
|
var SDK_PROTOCOL_VERSION = 3;
|
|
6628
7362
|
function getSdkProtocolVersion() {
|
|
6629
7363
|
return SDK_PROTOCOL_VERSION;
|
|
6630
7364
|
}
|
|
6631
7365
|
|
|
6632
|
-
//
|
|
7366
|
+
// src/sdk/nodejs/dist/session.js
|
|
6633
7367
|
var import_node = __toESM(require_node(), 1);
|
|
6634
7368
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
6635
7369
|
|
|
6636
|
-
//
|
|
7370
|
+
// src/sdk/nodejs/dist/canvas.js
|
|
6637
7371
|
var CanvasError = class _CanvasError extends Error {
|
|
6638
7372
|
constructor(code, message) {
|
|
6639
7373
|
super(message);
|
|
@@ -6680,7 +7414,7 @@ function createCanvas(options) {
|
|
|
6680
7414
|
return new Canvas(options);
|
|
6681
7415
|
}
|
|
6682
7416
|
|
|
6683
|
-
//
|
|
7417
|
+
// src/sdk/nodejs/dist/telemetry.js
|
|
6684
7418
|
async function getTraceContext(provider) {
|
|
6685
7419
|
if (!provider) return {};
|
|
6686
7420
|
try {
|
|
@@ -6690,7 +7424,18 @@ async function getTraceContext(provider) {
|
|
|
6690
7424
|
}
|
|
6691
7425
|
}
|
|
6692
7426
|
|
|
6693
|
-
//
|
|
7427
|
+
// src/sdk/nodejs/dist/schema.js
|
|
7428
|
+
function isZodSchema(value) {
|
|
7429
|
+
return typeof value === "object" && value !== null && "toJSONSchema" in value && typeof value.toJSONSchema === "function";
|
|
7430
|
+
}
|
|
7431
|
+
function toJsonSchema(schema) {
|
|
7432
|
+
return isZodSchema(schema) ? schema.toJSONSchema() : schema;
|
|
7433
|
+
}
|
|
7434
|
+
function isResponseSchema(value) {
|
|
7435
|
+
return isZodSchema(value) && "parse" in value && typeof value.parse === "function";
|
|
7436
|
+
}
|
|
7437
|
+
|
|
7438
|
+
// src/sdk/nodejs/dist/sessionFsProvider.js
|
|
6694
7439
|
var SessionFsSqliteTransactionFailure = class extends Error {
|
|
6695
7440
|
/** Failure classification reported to the runtime. */
|
|
6696
7441
|
errorClass;
|
|
@@ -6861,9 +7606,10 @@ function toSqliteTransactionError(err) {
|
|
|
6861
7606
|
};
|
|
6862
7607
|
}
|
|
6863
7608
|
|
|
6864
|
-
//
|
|
7609
|
+
// src/sdk/nodejs/dist/copilotRequestHandler.js
|
|
6865
7610
|
var sharedTextDecoder = new TextDecoder("utf-8", { fatal: false });
|
|
6866
7611
|
var sharedTextEncoder = new TextEncoder();
|
|
7612
|
+
var HTTP_RESPONSE_READ_AHEAD_BYTES = 32 * 1024;
|
|
6867
7613
|
var kBridge = /* @__PURE__ */ Symbol("copilotWebSocketResponseBridge");
|
|
6868
7614
|
var kCompletion = /* @__PURE__ */ Symbol("copilotWebSocketCompletion");
|
|
6869
7615
|
var kOpen = /* @__PURE__ */ Symbol("copilotWebSocketOpen");
|
|
@@ -7102,7 +7848,9 @@ function createCopilotRequestAdapter(handler, getServerRpc) {
|
|
|
7102
7848
|
const message = err instanceof Error ? err.message : String(err);
|
|
7103
7849
|
await finalize(exchange, 502, message);
|
|
7104
7850
|
} finally {
|
|
7105
|
-
pending.
|
|
7851
|
+
if (pending.get(exchange.requestId) === exchange) {
|
|
7852
|
+
pending.delete(exchange.requestId);
|
|
7853
|
+
}
|
|
7106
7854
|
}
|
|
7107
7855
|
}
|
|
7108
7856
|
return {
|
|
@@ -7115,6 +7863,13 @@ function createCopilotRequestAdapter(handler, getServerRpc) {
|
|
|
7115
7863
|
async httpRequestChunk(params) {
|
|
7116
7864
|
routeChunk(getOrCreate(params.requestId), params);
|
|
7117
7865
|
return {};
|
|
7866
|
+
},
|
|
7867
|
+
cancelPending() {
|
|
7868
|
+
const exchanges = [...pending.values()];
|
|
7869
|
+
pending.clear();
|
|
7870
|
+
for (const exchange of exchanges) {
|
|
7871
|
+
exchange.pushCancel("RPC connection closed");
|
|
7872
|
+
}
|
|
7118
7873
|
}
|
|
7119
7874
|
};
|
|
7120
7875
|
}
|
|
@@ -7363,32 +8118,158 @@ async function drainAsync(stream) {
|
|
|
7363
8118
|
return out;
|
|
7364
8119
|
}
|
|
7365
8120
|
async function streamResponse(response, exchange) {
|
|
7366
|
-
|
|
7367
|
-
status: response.status,
|
|
7368
|
-
statusText: response.statusText || void 0,
|
|
7369
|
-
headers: headersToMultiMap(response.headers)
|
|
7370
|
-
});
|
|
7371
|
-
const body = response.body;
|
|
7372
|
-
if (!body) {
|
|
7373
|
-
await exchange.endResponse();
|
|
7374
|
-
return;
|
|
7375
|
-
}
|
|
7376
|
-
const reader = body.getReader();
|
|
8121
|
+
const reader = response.body ? new HttpResponseReader(response.body, exchange.signal) : void 0;
|
|
7377
8122
|
try {
|
|
7378
|
-
|
|
7379
|
-
|
|
7380
|
-
|
|
7381
|
-
|
|
7382
|
-
|
|
7383
|
-
|
|
7384
|
-
|
|
8123
|
+
await exchange.startResponse({
|
|
8124
|
+
status: response.status,
|
|
8125
|
+
statusText: response.statusText || void 0,
|
|
8126
|
+
headers: headersToMultiMap(response.headers)
|
|
8127
|
+
});
|
|
8128
|
+
if (reader) {
|
|
8129
|
+
for (; ; ) {
|
|
8130
|
+
const chunk = await reader.nextChunk();
|
|
8131
|
+
if (!chunk) {
|
|
8132
|
+
break;
|
|
8133
|
+
}
|
|
8134
|
+
await exchange.writeResponse(chunk);
|
|
7385
8135
|
}
|
|
7386
8136
|
}
|
|
7387
8137
|
await exchange.endResponse();
|
|
7388
8138
|
} finally {
|
|
7389
|
-
reader
|
|
8139
|
+
await reader?.dispose();
|
|
7390
8140
|
}
|
|
7391
8141
|
}
|
|
8142
|
+
var HttpResponseReader = class {
|
|
8143
|
+
#reader;
|
|
8144
|
+
#signal;
|
|
8145
|
+
#frames = [];
|
|
8146
|
+
#pump;
|
|
8147
|
+
#onAbort;
|
|
8148
|
+
#queued = 0;
|
|
8149
|
+
#done = false;
|
|
8150
|
+
#cancelled = false;
|
|
8151
|
+
#hasError = false;
|
|
8152
|
+
#error;
|
|
8153
|
+
#dataWaker;
|
|
8154
|
+
#spaceWaker;
|
|
8155
|
+
#cancelPromise;
|
|
8156
|
+
constructor(body, signal) {
|
|
8157
|
+
this.#reader = body.getReader();
|
|
8158
|
+
this.#signal = signal;
|
|
8159
|
+
this.#onAbort = () => {
|
|
8160
|
+
void this.cancel(signal.reason);
|
|
8161
|
+
};
|
|
8162
|
+
signal.addEventListener("abort", this.#onAbort, { once: true });
|
|
8163
|
+
this.#pump = this.#pumpSource();
|
|
8164
|
+
if (signal.aborted) {
|
|
8165
|
+
this.#onAbort();
|
|
8166
|
+
}
|
|
8167
|
+
}
|
|
8168
|
+
async nextChunk() {
|
|
8169
|
+
while (this.#frames.length === 0 && !this.#done && !this.#hasError) {
|
|
8170
|
+
await new Promise((resolve3) => {
|
|
8171
|
+
this.#dataWaker = resolve3;
|
|
8172
|
+
});
|
|
8173
|
+
}
|
|
8174
|
+
if (this.#frames.length > 0) {
|
|
8175
|
+
const chunk = this.#takeQueued();
|
|
8176
|
+
this.#wakeSpace();
|
|
8177
|
+
return chunk;
|
|
8178
|
+
}
|
|
8179
|
+
if (this.#hasError) {
|
|
8180
|
+
this.#hasError = false;
|
|
8181
|
+
throw this.#error;
|
|
8182
|
+
}
|
|
8183
|
+
return void 0;
|
|
8184
|
+
}
|
|
8185
|
+
#takeQueued() {
|
|
8186
|
+
const frames = this.#frames;
|
|
8187
|
+
const total = this.#queued;
|
|
8188
|
+
this.#queued = 0;
|
|
8189
|
+
if (frames.length === 1) {
|
|
8190
|
+
return frames.pop();
|
|
8191
|
+
}
|
|
8192
|
+
const chunk = new Uint8Array(total);
|
|
8193
|
+
let offset = 0;
|
|
8194
|
+
for (const frame of frames) {
|
|
8195
|
+
chunk.set(frame, offset);
|
|
8196
|
+
offset += frame.byteLength;
|
|
8197
|
+
}
|
|
8198
|
+
frames.length = 0;
|
|
8199
|
+
return chunk;
|
|
8200
|
+
}
|
|
8201
|
+
async dispose() {
|
|
8202
|
+
this.#signal.removeEventListener("abort", this.#onAbort);
|
|
8203
|
+
if (!this.#done) {
|
|
8204
|
+
await this.cancel();
|
|
8205
|
+
} else if (this.#cancelPromise) {
|
|
8206
|
+
await this.#cancelPromise;
|
|
8207
|
+
}
|
|
8208
|
+
await this.#pump;
|
|
8209
|
+
}
|
|
8210
|
+
cancel(reason) {
|
|
8211
|
+
if (this.#done) {
|
|
8212
|
+
return Promise.resolve();
|
|
8213
|
+
}
|
|
8214
|
+
if (!this.#cancelPromise) {
|
|
8215
|
+
this.#cancelled = true;
|
|
8216
|
+
this.#done = true;
|
|
8217
|
+
this.#hasError = true;
|
|
8218
|
+
this.#error = reason instanceof Error ? reason : new Error("HTTP response body cancelled.");
|
|
8219
|
+
this.#frames.length = 0;
|
|
8220
|
+
this.#queued = 0;
|
|
8221
|
+
this.#wakeData();
|
|
8222
|
+
this.#wakeSpace();
|
|
8223
|
+
this.#cancelPromise = this.#reader.cancel(reason).catch(() => void 0);
|
|
8224
|
+
}
|
|
8225
|
+
return this.#cancelPromise;
|
|
8226
|
+
}
|
|
8227
|
+
async #pumpSource() {
|
|
8228
|
+
try {
|
|
8229
|
+
while (!this.#cancelled) {
|
|
8230
|
+
while (this.#queued >= HTTP_RESPONSE_READ_AHEAD_BYTES && !this.#cancelled) {
|
|
8231
|
+
await new Promise((resolve3) => {
|
|
8232
|
+
this.#spaceWaker = resolve3;
|
|
8233
|
+
});
|
|
8234
|
+
}
|
|
8235
|
+
if (this.#cancelled) {
|
|
8236
|
+
return;
|
|
8237
|
+
}
|
|
8238
|
+
const { value, done } = await this.#reader.read();
|
|
8239
|
+
if (done) {
|
|
8240
|
+
return;
|
|
8241
|
+
}
|
|
8242
|
+
if (value.byteLength > 0) {
|
|
8243
|
+
this.#frames.push(value);
|
|
8244
|
+
this.#queued += value.byteLength;
|
|
8245
|
+
this.#wakeData();
|
|
8246
|
+
continue;
|
|
8247
|
+
}
|
|
8248
|
+
await new Promise((resolve3) => setImmediate(resolve3));
|
|
8249
|
+
}
|
|
8250
|
+
} catch (error) {
|
|
8251
|
+
if (!this.#cancelled) {
|
|
8252
|
+
this.#hasError = true;
|
|
8253
|
+
this.#error = error;
|
|
8254
|
+
}
|
|
8255
|
+
} finally {
|
|
8256
|
+
this.#done = true;
|
|
8257
|
+
this.#wakeData();
|
|
8258
|
+
this.#wakeSpace();
|
|
8259
|
+
this.#reader.releaseLock();
|
|
8260
|
+
}
|
|
8261
|
+
}
|
|
8262
|
+
#wakeData() {
|
|
8263
|
+
const waker = this.#dataWaker;
|
|
8264
|
+
this.#dataWaker = void 0;
|
|
8265
|
+
waker?.();
|
|
8266
|
+
}
|
|
8267
|
+
#wakeSpace() {
|
|
8268
|
+
const waker = this.#spaceWaker;
|
|
8269
|
+
this.#spaceWaker = void 0;
|
|
8270
|
+
waker?.();
|
|
8271
|
+
}
|
|
8272
|
+
};
|
|
7392
8273
|
function headersToMultiMap(headers) {
|
|
7393
8274
|
const out = {};
|
|
7394
8275
|
headers.forEach((value, name) => {
|
|
@@ -7466,7 +8347,7 @@ var CopilotWebSocketResponseBridge = class {
|
|
|
7466
8347
|
}
|
|
7467
8348
|
};
|
|
7468
8349
|
|
|
7469
|
-
//
|
|
8350
|
+
// src/sdk/nodejs/dist/types.js
|
|
7470
8351
|
var RuntimeConnection = {
|
|
7471
8352
|
/**
|
|
7472
8353
|
* Spawn a runtime child process and communicate over its stdin/stdout.
|
|
@@ -7602,7 +8483,7 @@ var DisableBypassPermissionsModes = {
|
|
|
7602
8483
|
AllowAutoOnly: "allow-auto-only"
|
|
7603
8484
|
};
|
|
7604
8485
|
|
|
7605
|
-
//
|
|
8486
|
+
// src/sdk/nodejs/dist/factory.js
|
|
7606
8487
|
var FACTORY_TERMINAL_STATUSES = /* @__PURE__ */ new Set([
|
|
7607
8488
|
"completed",
|
|
7608
8489
|
"halted",
|
|
@@ -7703,29 +8584,151 @@ function getFactoryDefinition(handle) {
|
|
|
7703
8584
|
return definition;
|
|
7704
8585
|
}
|
|
7705
8586
|
|
|
7706
|
-
//
|
|
7707
|
-
|
|
7708
|
-
|
|
8587
|
+
// src/sdk/nodejs/dist/workflow.js
|
|
8588
|
+
var WORKFLOW_TERMINAL_STATUSES = /* @__PURE__ */ new Set([
|
|
8589
|
+
"completed",
|
|
8590
|
+
"halted",
|
|
8591
|
+
"paused",
|
|
8592
|
+
"cancelled",
|
|
8593
|
+
"error"
|
|
8594
|
+
]);
|
|
8595
|
+
function isWorkflowRunTerminal(status) {
|
|
8596
|
+
return WORKFLOW_TERMINAL_STATUSES.has(status);
|
|
7709
8597
|
}
|
|
7710
|
-
|
|
7711
|
-
|
|
7712
|
-
|
|
7713
|
-
|
|
8598
|
+
var WORKFLOW_AGENT_OPTION_KEYS = [
|
|
8599
|
+
"label",
|
|
8600
|
+
"schema",
|
|
8601
|
+
"model",
|
|
8602
|
+
"reasoningEffort",
|
|
8603
|
+
"contextTier",
|
|
8604
|
+
"agent"
|
|
8605
|
+
];
|
|
8606
|
+
var WorkflowResumeError = class extends Error {
|
|
8607
|
+
constructor(code, message) {
|
|
8608
|
+
super(message);
|
|
8609
|
+
this.code = code;
|
|
8610
|
+
this.name = "WorkflowResumeError";
|
|
7714
8611
|
}
|
|
7715
|
-
|
|
7716
|
-
|
|
7717
|
-
|
|
7718
|
-
|
|
7719
|
-
|
|
7720
|
-
|
|
7721
|
-
|
|
8612
|
+
code;
|
|
8613
|
+
};
|
|
8614
|
+
var workflowHandles = /* @__PURE__ */ new WeakMap();
|
|
8615
|
+
var MAX_WORKFLOW_TIMEOUT_SECONDS = 2147483647e-3;
|
|
8616
|
+
var NANO_AIU_PER_AIU2 = 1e9;
|
|
8617
|
+
function deepFreeze2(value) {
|
|
8618
|
+
if (value !== null && typeof value === "object" && !Object.isFrozen(value)) {
|
|
8619
|
+
Object.freeze(value);
|
|
8620
|
+
for (const nested of Object.values(value)) {
|
|
8621
|
+
deepFreeze2(nested);
|
|
8622
|
+
}
|
|
7722
8623
|
}
|
|
8624
|
+
return value;
|
|
7723
8625
|
}
|
|
7724
|
-
function
|
|
7725
|
-
const
|
|
7726
|
-
|
|
7727
|
-
|
|
7728
|
-
|
|
8626
|
+
function validateLimits2(meta) {
|
|
8627
|
+
const limits = meta.limits;
|
|
8628
|
+
if (!limits) {
|
|
8629
|
+
return;
|
|
8630
|
+
}
|
|
8631
|
+
for (const field of ["maxConcurrentSubagents", "maxTotalSubagents"]) {
|
|
8632
|
+
const value = limits[field];
|
|
8633
|
+
if (value !== void 0 && (!Number.isInteger(value) || value <= 0)) {
|
|
8634
|
+
throw new Error(`Workflow limit "${field}" must be a positive integer`);
|
|
8635
|
+
}
|
|
8636
|
+
}
|
|
8637
|
+
if (limits.timeoutSeconds !== void 0 && (!Number.isFinite(limits.timeoutSeconds) || limits.timeoutSeconds <= 0)) {
|
|
8638
|
+
throw new Error(
|
|
8639
|
+
'Workflow limit "timeoutSeconds" must be a positive, finite number of seconds'
|
|
8640
|
+
);
|
|
8641
|
+
}
|
|
8642
|
+
if (limits.timeoutSeconds !== void 0 && limits.timeoutSeconds > MAX_WORKFLOW_TIMEOUT_SECONDS) {
|
|
8643
|
+
throw new Error(
|
|
8644
|
+
`Workflow limit "timeoutSeconds" must not exceed ${MAX_WORKFLOW_TIMEOUT_SECONDS} seconds`
|
|
8645
|
+
);
|
|
8646
|
+
}
|
|
8647
|
+
if (limits.maxAiCredits !== void 0) {
|
|
8648
|
+
const maxNanoAiu = Math.round(limits.maxAiCredits * NANO_AIU_PER_AIU2);
|
|
8649
|
+
if (!Number.isFinite(limits.maxAiCredits) || limits.maxAiCredits <= 0 || !Number.isSafeInteger(maxNanoAiu) || maxNanoAiu < 1) {
|
|
8650
|
+
throw new Error(
|
|
8651
|
+
'Workflow limit "maxAiCredits" must be a positive, finite number that rounds to a safe positive integer nano-AIU ceiling'
|
|
8652
|
+
);
|
|
8653
|
+
}
|
|
8654
|
+
}
|
|
8655
|
+
}
|
|
8656
|
+
function validatePhases2(meta) {
|
|
8657
|
+
const titles = /* @__PURE__ */ new Set();
|
|
8658
|
+
for (const phase of meta.phases) {
|
|
8659
|
+
if (phase.title.trim().length === 0) {
|
|
8660
|
+
throw new Error("Workflow phase titles must not be empty");
|
|
8661
|
+
}
|
|
8662
|
+
if (titles.has(phase.title)) {
|
|
8663
|
+
throw new Error(`Workflow phase title "${phase.title}" is declared more than once`);
|
|
8664
|
+
}
|
|
8665
|
+
titles.add(phase.title);
|
|
8666
|
+
}
|
|
8667
|
+
}
|
|
8668
|
+
function defineWorkflow(definition) {
|
|
8669
|
+
const meta = deepFreeze2(structuredClone(definition.meta));
|
|
8670
|
+
validateLimits2(meta);
|
|
8671
|
+
validatePhases2(meta);
|
|
8672
|
+
const stored = {
|
|
8673
|
+
meta,
|
|
8674
|
+
run: definition.run
|
|
8675
|
+
};
|
|
8676
|
+
const handle = Object.freeze({ meta });
|
|
8677
|
+
workflowHandles.set(handle, stored);
|
|
8678
|
+
return handle;
|
|
8679
|
+
}
|
|
8680
|
+
function getWorkflowDefinition(handle) {
|
|
8681
|
+
const definition = workflowHandles.get(handle);
|
|
8682
|
+
if (!definition) {
|
|
8683
|
+
throw new Error("Invalid workflow handle");
|
|
8684
|
+
}
|
|
8685
|
+
return definition;
|
|
8686
|
+
}
|
|
8687
|
+
|
|
8688
|
+
// src/sdk/nodejs/dist/session.js
|
|
8689
|
+
function isFactoryResumeErrorCode(value) {
|
|
8690
|
+
return value === "not_found" || value === "non_resumable" || value === "already_active" || value === "factory_already_running" || value === "factory_limits_invalid" || value === "factory_session_disposed" || value === "factory_storage_unavailable" || value === "factory_storage_corrupt";
|
|
8691
|
+
}
|
|
8692
|
+
function copyDefinedFactoryAgentOption(source, target, key) {
|
|
8693
|
+
const value = source[key];
|
|
8694
|
+
if (value !== void 0) {
|
|
8695
|
+
target[key] = value;
|
|
8696
|
+
}
|
|
8697
|
+
}
|
|
8698
|
+
function isWorkflowResumeErrorCode(value) {
|
|
8699
|
+
return value === "not_found" || value === "non_resumable" || value === "workflow_run_not_resumable" || value === "already_active" || value === "workflow_already_running" || value === "workflow_limits_invalid" || value === "workflow_session_disposed" || value === "workflow_storage_unavailable" || value === "workflow_storage_corrupt";
|
|
8700
|
+
}
|
|
8701
|
+
function copyDefinedWorkflowAgentOption(source, target, key) {
|
|
8702
|
+
const value = source[key];
|
|
8703
|
+
if (value !== void 0) {
|
|
8704
|
+
target[key] = value;
|
|
8705
|
+
}
|
|
8706
|
+
}
|
|
8707
|
+
var factoryExecutionStore = new AsyncLocalStorage();
|
|
8708
|
+
function throwIfFactoryExecutionIsActive() {
|
|
8709
|
+
if (factoryExecutionStore.getStore()?.active) {
|
|
8710
|
+
throw new Error(
|
|
8711
|
+
"factory.run, factory.resume, and factory.pause are not allowed while a factory body is running on this call path."
|
|
8712
|
+
);
|
|
8713
|
+
}
|
|
8714
|
+
}
|
|
8715
|
+
var workflowExecutionStore = new AsyncLocalStorage();
|
|
8716
|
+
function throwIfWorkflowExecutionIsActive() {
|
|
8717
|
+
if (workflowExecutionStore.getStore()?.active) {
|
|
8718
|
+
throw new Error(
|
|
8719
|
+
"workflow.run, workflow.resume, and workflow.pause are not allowed while a workflow body is running on this call path."
|
|
8720
|
+
);
|
|
8721
|
+
}
|
|
8722
|
+
}
|
|
8723
|
+
function runInWorkflowHelperScope(helperScope, callback) {
|
|
8724
|
+
const current = workflowExecutionStore.getStore();
|
|
8725
|
+
return workflowExecutionStore.run({ active: current?.active ?? false, helperScope }, callback);
|
|
8726
|
+
}
|
|
8727
|
+
function runInFactoryHelperScope(helperScope, callback) {
|
|
8728
|
+
const current = factoryExecutionStore.getStore();
|
|
8729
|
+
return factoryExecutionStore.run({ active: current?.active ?? false, helperScope }, callback);
|
|
8730
|
+
}
|
|
8731
|
+
function deserializeHookInput(raw) {
|
|
7729
8732
|
if (!raw || typeof raw !== "object" || typeof raw.timestamp !== "number") {
|
|
7730
8733
|
return raw;
|
|
7731
8734
|
}
|
|
@@ -7802,6 +8805,54 @@ async function runFactoryPipeline(items, ...stages) {
|
|
|
7802
8805
|
})
|
|
7803
8806
|
);
|
|
7804
8807
|
}
|
|
8808
|
+
async function runWorkflowParallel(thunks) {
|
|
8809
|
+
if (!Array.isArray(thunks)) {
|
|
8810
|
+
throw new Error(
|
|
8811
|
+
"parallel() expects an array of functions, not promises. Wrap each call: () => agent(...)"
|
|
8812
|
+
);
|
|
8813
|
+
}
|
|
8814
|
+
assertFactoryFanoutSize("parallel", thunks.length);
|
|
8815
|
+
if (thunks.some((thunk) => typeof thunk !== "function")) {
|
|
8816
|
+
throw new Error(
|
|
8817
|
+
"parallel() expects an array of functions, not promises. Wrap each call: () => agent(...)"
|
|
8818
|
+
);
|
|
8819
|
+
}
|
|
8820
|
+
return Promise.all(
|
|
8821
|
+
thunks.map(
|
|
8822
|
+
(thunk) => Promise.resolve().then(() => runInWorkflowHelperScope("parallel", thunk)).catch((error) => {
|
|
8823
|
+
if (isFactoryFatalError(error)) {
|
|
8824
|
+
throw error;
|
|
8825
|
+
}
|
|
8826
|
+
return null;
|
|
8827
|
+
})
|
|
8828
|
+
)
|
|
8829
|
+
);
|
|
8830
|
+
}
|
|
8831
|
+
async function runWorkflowPipeline(items, ...stages) {
|
|
8832
|
+
if (!Array.isArray(items)) {
|
|
8833
|
+
throw new Error("pipeline(items, ...stages): items must be an array");
|
|
8834
|
+
}
|
|
8835
|
+
assertFactoryFanoutSize("pipeline", items.length);
|
|
8836
|
+
return Promise.all(
|
|
8837
|
+
items.map(async (item, index) => {
|
|
8838
|
+
let previous = item;
|
|
8839
|
+
for (const stage of stages) {
|
|
8840
|
+
try {
|
|
8841
|
+
previous = await runInWorkflowHelperScope(
|
|
8842
|
+
"pipeline",
|
|
8843
|
+
() => stage(previous, item, index)
|
|
8844
|
+
);
|
|
8845
|
+
} catch (error) {
|
|
8846
|
+
if (isFactoryFatalError(error)) {
|
|
8847
|
+
throw error;
|
|
8848
|
+
}
|
|
8849
|
+
return null;
|
|
8850
|
+
}
|
|
8851
|
+
}
|
|
8852
|
+
return previous;
|
|
8853
|
+
})
|
|
8854
|
+
);
|
|
8855
|
+
}
|
|
7805
8856
|
var FactoryProgressBuffer = class {
|
|
7806
8857
|
constructor(send) {
|
|
7807
8858
|
this.send = send;
|
|
@@ -7881,6 +8932,85 @@ var FactoryProgressBuffer = class {
|
|
|
7881
8932
|
}
|
|
7882
8933
|
}
|
|
7883
8934
|
};
|
|
8935
|
+
var WorkflowProgressBuffer = class {
|
|
8936
|
+
constructor(send) {
|
|
8937
|
+
this.send = send;
|
|
8938
|
+
}
|
|
8939
|
+
send;
|
|
8940
|
+
nextSeq = 0;
|
|
8941
|
+
pending = [];
|
|
8942
|
+
flushTimer;
|
|
8943
|
+
flushTail = Promise.resolve();
|
|
8944
|
+
flushError;
|
|
8945
|
+
flushFailed = false;
|
|
8946
|
+
closed = false;
|
|
8947
|
+
enqueue(kind, text) {
|
|
8948
|
+
if (this.closed) {
|
|
8949
|
+
throw new Error("Cannot log after the workflow run has settled");
|
|
8950
|
+
}
|
|
8951
|
+
this.pending.push({ seq: this.nextSeq++, kind, text });
|
|
8952
|
+
this.scheduleFlush();
|
|
8953
|
+
}
|
|
8954
|
+
async flush() {
|
|
8955
|
+
this.clearFlushTimer();
|
|
8956
|
+
const lines = this.pending.splice(0);
|
|
8957
|
+
if (lines.length > 0) {
|
|
8958
|
+
this.flushTail = this.flushTail.then(async () => {
|
|
8959
|
+
try {
|
|
8960
|
+
await this.send(lines);
|
|
8961
|
+
} catch (error) {
|
|
8962
|
+
if (!this.flushFailed) {
|
|
8963
|
+
this.flushFailed = true;
|
|
8964
|
+
this.flushError = error;
|
|
8965
|
+
}
|
|
8966
|
+
}
|
|
8967
|
+
});
|
|
8968
|
+
}
|
|
8969
|
+
await this.flushTail;
|
|
8970
|
+
if (this.flushFailed) {
|
|
8971
|
+
throw this.flushError;
|
|
8972
|
+
}
|
|
8973
|
+
}
|
|
8974
|
+
async close() {
|
|
8975
|
+
this.closed = true;
|
|
8976
|
+
this.clearFlushTimer();
|
|
8977
|
+
const lines = this.pending.splice(0);
|
|
8978
|
+
await this.flushTail;
|
|
8979
|
+
if (this.flushFailed) {
|
|
8980
|
+
console.warn(
|
|
8981
|
+
"Ignoring a background workflow progress flush failure after the workflow body settled",
|
|
8982
|
+
this.flushError
|
|
8983
|
+
);
|
|
8984
|
+
}
|
|
8985
|
+
if (lines.length > 0) {
|
|
8986
|
+
try {
|
|
8987
|
+
await this.send(lines);
|
|
8988
|
+
} catch (error) {
|
|
8989
|
+
console.warn(
|
|
8990
|
+
"Failed to flush final workflow progress after the workflow body settled",
|
|
8991
|
+
error
|
|
8992
|
+
);
|
|
8993
|
+
}
|
|
8994
|
+
}
|
|
8995
|
+
}
|
|
8996
|
+
scheduleFlush() {
|
|
8997
|
+
if (this.flushTimer !== void 0) {
|
|
8998
|
+
return;
|
|
8999
|
+
}
|
|
9000
|
+
this.flushTimer = setTimeout(() => {
|
|
9001
|
+
this.flushTimer = void 0;
|
|
9002
|
+
void this.flush().catch(() => {
|
|
9003
|
+
});
|
|
9004
|
+
}, FACTORY_LOG_FLUSH_DELAY_MS);
|
|
9005
|
+
this.flushTimer.unref?.();
|
|
9006
|
+
}
|
|
9007
|
+
clearFlushTimer() {
|
|
9008
|
+
if (this.flushTimer !== void 0) {
|
|
9009
|
+
clearTimeout(this.flushTimer);
|
|
9010
|
+
this.flushTimer = void 0;
|
|
9011
|
+
}
|
|
9012
|
+
}
|
|
9013
|
+
};
|
|
7884
9014
|
async function awaitFactoryOperation(operation, signal) {
|
|
7885
9015
|
let rejectAbort;
|
|
7886
9016
|
const abortPromise = new Promise((_resolve, reject) => {
|
|
@@ -7895,11 +9025,19 @@ async function awaitFactoryOperation(operation, signal) {
|
|
|
7895
9025
|
signal.removeEventListener("abort", onAbort);
|
|
7896
9026
|
}
|
|
7897
9027
|
}
|
|
9028
|
+
async function awaitWorkflowOperation(operation, signal) {
|
|
9029
|
+
return awaitFactoryOperation(operation, signal);
|
|
9030
|
+
}
|
|
7898
9031
|
function throwIfFactoryAborted(signal) {
|
|
7899
9032
|
if (signal.aborted) {
|
|
7900
9033
|
throw signal.reason ?? new DOMException("Factory run was aborted", "AbortError");
|
|
7901
9034
|
}
|
|
7902
9035
|
}
|
|
9036
|
+
function throwIfWorkflowAborted(signal) {
|
|
9037
|
+
if (signal.aborted) {
|
|
9038
|
+
throw signal.reason ?? new DOMException("Workflow run was aborted", "AbortError");
|
|
9039
|
+
}
|
|
9040
|
+
}
|
|
7903
9041
|
function isFactoryAbortError(error) {
|
|
7904
9042
|
return typeof error === "object" && error !== null && "name" in error && error.name === "AbortError";
|
|
7905
9043
|
}
|
|
@@ -7938,6 +9076,8 @@ var CopilotSession = class {
|
|
|
7938
9076
|
commandHandlers = /* @__PURE__ */ new Map();
|
|
7939
9077
|
factories = /* @__PURE__ */ new Map();
|
|
7940
9078
|
factoryAbortControllers = /* @__PURE__ */ new Map();
|
|
9079
|
+
workflows = /* @__PURE__ */ new Map();
|
|
9080
|
+
workflowAbortControllers = /* @__PURE__ */ new Map();
|
|
7941
9081
|
permissionHandler;
|
|
7942
9082
|
mcpAuthHandler;
|
|
7943
9083
|
userInputHandler;
|
|
@@ -7953,6 +9093,7 @@ var CopilotSession = class {
|
|
|
7953
9093
|
_capabilities = {};
|
|
7954
9094
|
openCanvasInstances = [];
|
|
7955
9095
|
disconnected = false;
|
|
9096
|
+
pendingStructuredWaits = /* @__PURE__ */ new Set();
|
|
7956
9097
|
disconnecting = false;
|
|
7957
9098
|
onDisconnected;
|
|
7958
9099
|
/** @internal Client session API handlers, populated by CopilotClient during create/resume. */
|
|
@@ -8002,39 +9143,169 @@ var CopilotSession = class {
|
|
|
8002
9143
|
throw new FactoryResumeError(code, error.message);
|
|
8003
9144
|
}
|
|
8004
9145
|
}
|
|
8005
|
-
throw error;
|
|
9146
|
+
throw error;
|
|
9147
|
+
}
|
|
9148
|
+
return this.settleFactoryRun(response.run);
|
|
9149
|
+
}),
|
|
9150
|
+
getRun: async (runId) => this.rpc.factory.getRun({ runId }),
|
|
9151
|
+
waitForRun: (runId, options) => this.waitForFactoryRun(runId, options?.signal),
|
|
9152
|
+
listRuns: (async (options) => {
|
|
9153
|
+
const page = await this.rpc.factory.listRuns(options ?? {});
|
|
9154
|
+
return options === void 0 ? page.runs : page;
|
|
9155
|
+
}),
|
|
9156
|
+
getRunDetail: (runId) => this.rpc.factory.getRunDetail({ runId }),
|
|
9157
|
+
getRunProgress: (runId, options = {}) => this.rpc.factory.getRunProgress({ runId, ...options }),
|
|
9158
|
+
pause: async (runId) => {
|
|
9159
|
+
throwIfFactoryExecutionIsActive();
|
|
9160
|
+
return this.rpc.factory.pause({ runId });
|
|
9161
|
+
},
|
|
9162
|
+
cancel: async (runId) => this.rpc.factory.cancel({ runId })
|
|
9163
|
+
};
|
|
9164
|
+
workflow = {
|
|
9165
|
+
run: (async (nameOrHandle, options) => {
|
|
9166
|
+
throwIfWorkflowExecutionIsActive();
|
|
9167
|
+
const name = typeof nameOrHandle === "string" ? nameOrHandle : getWorkflowDefinition(nameOrHandle).meta.name;
|
|
9168
|
+
const envelope = await this.rpc.workflow.run({
|
|
9169
|
+
name,
|
|
9170
|
+
args: options?.args === void 0 ? {} : options.args,
|
|
9171
|
+
options: {
|
|
9172
|
+
limits: options?.limits,
|
|
9173
|
+
notifyOnComplete: options?.notifyOnComplete,
|
|
9174
|
+
logPhaseNames: options?.logPhaseNames
|
|
9175
|
+
}
|
|
9176
|
+
});
|
|
9177
|
+
return this.settleWorkflowRun(envelope);
|
|
9178
|
+
}),
|
|
9179
|
+
resume: (async (runId, options) => {
|
|
9180
|
+
throwIfWorkflowExecutionIsActive();
|
|
9181
|
+
let response;
|
|
9182
|
+
try {
|
|
9183
|
+
response = await this.rpc.workflow.resume({
|
|
9184
|
+
runId,
|
|
9185
|
+
limits: options?.limits,
|
|
9186
|
+
notifyOnComplete: options?.notifyOnComplete,
|
|
9187
|
+
logPhaseNames: options?.logPhaseNames
|
|
9188
|
+
});
|
|
9189
|
+
} catch (error) {
|
|
9190
|
+
if (error instanceof import_node.ResponseError && typeof error.data === "object" && error.data !== null) {
|
|
9191
|
+
const code = error.data.code;
|
|
9192
|
+
if (isWorkflowResumeErrorCode(code)) {
|
|
9193
|
+
throw new WorkflowResumeError(code, error.message);
|
|
9194
|
+
}
|
|
9195
|
+
}
|
|
9196
|
+
throw error;
|
|
9197
|
+
}
|
|
9198
|
+
return this.settleWorkflowRun(response.run);
|
|
9199
|
+
}),
|
|
9200
|
+
getRun: async (runId) => this.rpc.workflow.getRun({ runId }),
|
|
9201
|
+
waitForRun: (runId, options) => this.waitForWorkflowRun(runId, options?.signal),
|
|
9202
|
+
listRuns: (async (options) => {
|
|
9203
|
+
const page = await this.rpc.workflow.listRuns(options ?? {});
|
|
9204
|
+
return options === void 0 ? page.runs : page;
|
|
9205
|
+
}),
|
|
9206
|
+
getRunDetail: (runId) => this.rpc.workflow.getRunDetail({ runId }),
|
|
9207
|
+
getRunProgress: (runId, options = {}) => this.rpc.workflow.getRunProgress({ runId, ...options }),
|
|
9208
|
+
pause: async (runId) => {
|
|
9209
|
+
throwIfWorkflowExecutionIsActive();
|
|
9210
|
+
return this.rpc.workflow.pause({ runId });
|
|
9211
|
+
},
|
|
9212
|
+
cancel: async (runId) => this.rpc.workflow.cancel({ runId })
|
|
9213
|
+
};
|
|
9214
|
+
/**
|
|
9215
|
+
* Resolve a start/resume envelope into the terminal envelope callers expect.
|
|
9216
|
+
*
|
|
9217
|
+
* The CLI may answer `session.factory.run` and `session.factory.resume`
|
|
9218
|
+
* before the run settles, so a non-terminal envelope is followed by a wait
|
|
9219
|
+
* on the run's terminal state.
|
|
9220
|
+
*/
|
|
9221
|
+
settleFactoryRun(envelope) {
|
|
9222
|
+
if (isFactoryRunTerminal(envelope.status)) {
|
|
9223
|
+
return Promise.resolve(envelope);
|
|
9224
|
+
}
|
|
9225
|
+
return this.waitForFactoryRun(envelope.runId);
|
|
9226
|
+
}
|
|
9227
|
+
/**
|
|
9228
|
+
* Resolve when a factory run reaches a terminal status.
|
|
9229
|
+
*
|
|
9230
|
+
* The subscription is installed *before* the first read so a transition
|
|
9231
|
+
* landing between the two cannot be missed, and re-reads are serialized so
|
|
9232
|
+
* overlapping invalidation events cannot interleave — the run's revision
|
|
9233
|
+
* advances once per operation, so a burst of events is common and must
|
|
9234
|
+
* collapse into a single in-flight read. A bounded periodic re-read keeps a
|
|
9235
|
+
* dropped invalidation from leaving the wait pending forever.
|
|
9236
|
+
*/
|
|
9237
|
+
waitForFactoryRun(runId, signal) {
|
|
9238
|
+
const abortError = () => signal?.reason ?? new DOMException("Factory run wait was aborted", "AbortError");
|
|
9239
|
+
if (signal?.aborted === true) {
|
|
9240
|
+
return Promise.reject(abortError());
|
|
9241
|
+
}
|
|
9242
|
+
return new Promise((resolve3, reject) => {
|
|
9243
|
+
let settled = false;
|
|
9244
|
+
let reading = false;
|
|
9245
|
+
let rereadRequested = false;
|
|
9246
|
+
let pollHandle;
|
|
9247
|
+
let unsubscribe;
|
|
9248
|
+
let onAbort;
|
|
9249
|
+
const finish = (complete) => {
|
|
9250
|
+
if (settled) {
|
|
9251
|
+
return;
|
|
9252
|
+
}
|
|
9253
|
+
settled = true;
|
|
9254
|
+
if (pollHandle !== void 0) {
|
|
9255
|
+
clearInterval(pollHandle);
|
|
9256
|
+
}
|
|
9257
|
+
unsubscribe?.();
|
|
9258
|
+
if (onAbort !== void 0) {
|
|
9259
|
+
signal?.removeEventListener("abort", onAbort);
|
|
9260
|
+
}
|
|
9261
|
+
complete();
|
|
9262
|
+
};
|
|
9263
|
+
const read = async () => {
|
|
9264
|
+
if (settled) {
|
|
9265
|
+
return;
|
|
9266
|
+
}
|
|
9267
|
+
if (reading) {
|
|
9268
|
+
rereadRequested = true;
|
|
9269
|
+
return;
|
|
9270
|
+
}
|
|
9271
|
+
reading = true;
|
|
9272
|
+
try {
|
|
9273
|
+
do {
|
|
9274
|
+
rereadRequested = false;
|
|
9275
|
+
const envelope = await this.rpc.factory.getRun({ runId });
|
|
9276
|
+
if (isFactoryRunTerminal(envelope.status)) {
|
|
9277
|
+
finish(() => resolve3(envelope));
|
|
9278
|
+
return;
|
|
9279
|
+
}
|
|
9280
|
+
} while (rereadRequested && !settled);
|
|
9281
|
+
} catch (error) {
|
|
9282
|
+
finish(() => reject(error));
|
|
9283
|
+
} finally {
|
|
9284
|
+
reading = false;
|
|
9285
|
+
}
|
|
9286
|
+
};
|
|
9287
|
+
if (signal !== void 0) {
|
|
9288
|
+
onAbort = () => finish(() => reject(abortError()));
|
|
9289
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
8006
9290
|
}
|
|
8007
|
-
|
|
8008
|
-
|
|
8009
|
-
|
|
8010
|
-
|
|
8011
|
-
|
|
8012
|
-
|
|
8013
|
-
|
|
8014
|
-
|
|
8015
|
-
|
|
8016
|
-
|
|
8017
|
-
|
|
8018
|
-
|
|
8019
|
-
return this.rpc.factory.pause({ runId });
|
|
8020
|
-
},
|
|
8021
|
-
cancel: async (runId) => this.rpc.factory.cancel({ runId })
|
|
8022
|
-
};
|
|
8023
|
-
/**
|
|
8024
|
-
* Resolve a start/resume envelope into the terminal envelope callers expect.
|
|
8025
|
-
*
|
|
8026
|
-
* The CLI may answer `session.factory.run` and `session.factory.resume`
|
|
8027
|
-
* before the run settles, so a non-terminal envelope is followed by a wait
|
|
8028
|
-
* on the run's terminal state.
|
|
8029
|
-
*/
|
|
8030
|
-
settleFactoryRun(envelope) {
|
|
8031
|
-
if (isFactoryRunTerminal(envelope.status)) {
|
|
9291
|
+
unsubscribe = this.on("factory.run_updated", (event) => {
|
|
9292
|
+
if (event.data.runId === runId) {
|
|
9293
|
+
void read();
|
|
9294
|
+
}
|
|
9295
|
+
});
|
|
9296
|
+
pollHandle = setInterval(() => void read(), 5e3);
|
|
9297
|
+
pollHandle.unref?.();
|
|
9298
|
+
void read();
|
|
9299
|
+
});
|
|
9300
|
+
}
|
|
9301
|
+
settleWorkflowRun(envelope) {
|
|
9302
|
+
if (isWorkflowRunTerminal(envelope.status)) {
|
|
8032
9303
|
return Promise.resolve(envelope);
|
|
8033
9304
|
}
|
|
8034
|
-
return this.
|
|
9305
|
+
return this.waitForWorkflowRun(envelope.runId);
|
|
8035
9306
|
}
|
|
8036
9307
|
/**
|
|
8037
|
-
* Resolve when a
|
|
9308
|
+
* Resolve when a workflow run reaches a terminal status.
|
|
8038
9309
|
*
|
|
8039
9310
|
* The subscription is installed *before* the first read so a transition
|
|
8040
9311
|
* landing between the two cannot be missed, and re-reads are serialized so
|
|
@@ -8043,8 +9314,8 @@ var CopilotSession = class {
|
|
|
8043
9314
|
* collapse into a single in-flight read. A bounded periodic re-read keeps a
|
|
8044
9315
|
* dropped invalidation from leaving the wait pending forever.
|
|
8045
9316
|
*/
|
|
8046
|
-
|
|
8047
|
-
const abortError = () => signal?.reason ?? new DOMException("
|
|
9317
|
+
waitForWorkflowRun(runId, signal) {
|
|
9318
|
+
const abortError = () => signal?.reason ?? new DOMException("Workflow run wait was aborted", "AbortError");
|
|
8048
9319
|
if (signal?.aborted === true) {
|
|
8049
9320
|
return Promise.reject(abortError());
|
|
8050
9321
|
}
|
|
@@ -8081,8 +9352,8 @@ var CopilotSession = class {
|
|
|
8081
9352
|
try {
|
|
8082
9353
|
do {
|
|
8083
9354
|
rereadRequested = false;
|
|
8084
|
-
const envelope = await this.rpc.
|
|
8085
|
-
if (
|
|
9355
|
+
const envelope = await this.rpc.workflow.getRun({ runId });
|
|
9356
|
+
if (isWorkflowRunTerminal(envelope.status)) {
|
|
8086
9357
|
finish(() => resolve3(envelope));
|
|
8087
9358
|
return;
|
|
8088
9359
|
}
|
|
@@ -8169,13 +9440,54 @@ var CopilotSession = class {
|
|
|
8169
9440
|
attachments: options.attachments,
|
|
8170
9441
|
mode: options.mode,
|
|
8171
9442
|
agentMode: options.agentMode,
|
|
8172
|
-
requestHeaders: options.requestHeaders
|
|
9443
|
+
requestHeaders: options.requestHeaders,
|
|
9444
|
+
...options.responseSchema ? {
|
|
9445
|
+
responseFormat: {
|
|
9446
|
+
type: "json_schema",
|
|
9447
|
+
jsonSchema: {
|
|
9448
|
+
name: "response",
|
|
9449
|
+
strict: true,
|
|
9450
|
+
schema: toJsonSchema(options.responseSchema)
|
|
9451
|
+
}
|
|
9452
|
+
}
|
|
9453
|
+
} : {}
|
|
8173
9454
|
});
|
|
8174
9455
|
return response.messageId;
|
|
8175
9456
|
}
|
|
8176
|
-
async sendAndWait(optionsOrPrompt, timeout) {
|
|
9457
|
+
async sendAndWait(optionsOrPrompt, schemaOrTimeout, timeout) {
|
|
8177
9458
|
const options = typeof optionsOrPrompt === "string" ? { prompt: optionsOrPrompt } : optionsOrPrompt;
|
|
8178
|
-
const
|
|
9459
|
+
const typedSchema = isResponseSchema(schemaOrTimeout) ? schemaOrTimeout : void 0;
|
|
9460
|
+
if (schemaOrTimeout !== void 0 && typeof schemaOrTimeout !== "number" && !typedSchema) {
|
|
9461
|
+
throw new TypeError(
|
|
9462
|
+
"The second argument must be a timeout or a schema with toJSONSchema() and parse(). Pass raw JSON Schema in options.responseSchema instead."
|
|
9463
|
+
);
|
|
9464
|
+
}
|
|
9465
|
+
const effectiveTimeout = (typeof schemaOrTimeout === "number" ? schemaOrTimeout : timeout) ?? 6e4;
|
|
9466
|
+
if (typedSchema && options.responseSchema) {
|
|
9467
|
+
throw new Error(
|
|
9468
|
+
"Do not specify responseSchema in options when requesting a typed response."
|
|
9469
|
+
);
|
|
9470
|
+
}
|
|
9471
|
+
if (typedSchema && options.mode === "immediate") {
|
|
9472
|
+
throw new Error(
|
|
9473
|
+
"Structured output cannot be requested on an immediate steering message."
|
|
9474
|
+
);
|
|
9475
|
+
}
|
|
9476
|
+
if (typedSchema || options.responseSchema) {
|
|
9477
|
+
const message = await this.sendAndWaitForStructuredMessage(
|
|
9478
|
+
typedSchema ? { ...options, responseSchema: typedSchema } : options,
|
|
9479
|
+
effectiveTimeout
|
|
9480
|
+
);
|
|
9481
|
+
if (typedSchema) {
|
|
9482
|
+
if (!message) {
|
|
9483
|
+
throw new Error(
|
|
9484
|
+
"The requested run completed without a structured assistant response."
|
|
9485
|
+
);
|
|
9486
|
+
}
|
|
9487
|
+
return typedSchema.parse(JSON.parse(message.data.content));
|
|
9488
|
+
}
|
|
9489
|
+
return message;
|
|
9490
|
+
}
|
|
8179
9491
|
let resolveOutcome;
|
|
8180
9492
|
const outcomePromise = new Promise((resolve3) => {
|
|
8181
9493
|
resolveOutcome = resolve3;
|
|
@@ -8217,12 +9529,95 @@ var CopilotSession = class {
|
|
|
8217
9529
|
unsubscribe();
|
|
8218
9530
|
}
|
|
8219
9531
|
}
|
|
9532
|
+
async sendAndWaitForStructuredMessage(options, timeout) {
|
|
9533
|
+
if (this.disconnected) {
|
|
9534
|
+
throw new Error("Session is disconnected");
|
|
9535
|
+
}
|
|
9536
|
+
let resolveOutcome;
|
|
9537
|
+
const outcomePromise = new Promise((resolve3) => {
|
|
9538
|
+
resolveOutcome = resolve3;
|
|
9539
|
+
});
|
|
9540
|
+
const fail = (error) => resolveOutcome({ kind: "error", error });
|
|
9541
|
+
let messageId;
|
|
9542
|
+
let consumed = false;
|
|
9543
|
+
let lastMessage;
|
|
9544
|
+
const buffered = [];
|
|
9545
|
+
const observe = (event) => {
|
|
9546
|
+
if (event.agentId) return;
|
|
9547
|
+
if (event.type === "user.message" && event.data.messageId === messageId) {
|
|
9548
|
+
consumed = true;
|
|
9549
|
+
} else if (event.type === "assistant.message" && event.data.originatingMessageId === messageId) {
|
|
9550
|
+
consumed = true;
|
|
9551
|
+
lastMessage = event.data.toolRequests?.length ? void 0 : event;
|
|
9552
|
+
} else if (consumed && event.type === "session.idle" && event.data.mode !== "autopilot") {
|
|
9553
|
+
if (event.data.aborted) {
|
|
9554
|
+
fail(
|
|
9555
|
+
new Error(
|
|
9556
|
+
"The requested run was aborted before a structured result was completed."
|
|
9557
|
+
)
|
|
9558
|
+
);
|
|
9559
|
+
} else {
|
|
9560
|
+
resolveOutcome({ kind: "idle", message: lastMessage });
|
|
9561
|
+
}
|
|
9562
|
+
} else if (consumed && event.type === "session.error") {
|
|
9563
|
+
const error = new Error(event.data.message);
|
|
9564
|
+
error.stack = event.data.stack;
|
|
9565
|
+
fail(error);
|
|
9566
|
+
}
|
|
9567
|
+
};
|
|
9568
|
+
const unsubscribe = this.on((event) => {
|
|
9569
|
+
if (event.type !== "user.message" && event.type !== "assistant.message" && event.type !== "session.idle" && event.type !== "session.error") {
|
|
9570
|
+
return;
|
|
9571
|
+
}
|
|
9572
|
+
if (messageId === void 0) {
|
|
9573
|
+
buffered.push(event);
|
|
9574
|
+
} else {
|
|
9575
|
+
observe(event);
|
|
9576
|
+
}
|
|
9577
|
+
});
|
|
9578
|
+
this.pendingStructuredWaits.add(fail);
|
|
9579
|
+
const timer = setTimeout(
|
|
9580
|
+
() => fail(new Error(`Timeout after ${timeout}ms waiting for the structured response`)),
|
|
9581
|
+
timeout
|
|
9582
|
+
);
|
|
9583
|
+
try {
|
|
9584
|
+
const sendOutcome = this.send(options).then(
|
|
9585
|
+
(id) => {
|
|
9586
|
+
if (!id) {
|
|
9587
|
+
throw new Error(
|
|
9588
|
+
"The runtime did not return a message ID for the structured send."
|
|
9589
|
+
);
|
|
9590
|
+
}
|
|
9591
|
+
messageId = id;
|
|
9592
|
+
for (const event of buffered) observe(event);
|
|
9593
|
+
buffered.length = 0;
|
|
9594
|
+
return outcomePromise;
|
|
9595
|
+
},
|
|
9596
|
+
(error) => ({
|
|
9597
|
+
kind: "error",
|
|
9598
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
9599
|
+
})
|
|
9600
|
+
);
|
|
9601
|
+
const outcome = await Promise.race([sendOutcome, outcomePromise]);
|
|
9602
|
+
if (outcome.kind === "error") throw outcome.error;
|
|
9603
|
+
return outcome.message;
|
|
9604
|
+
} finally {
|
|
9605
|
+
clearTimeout(timer);
|
|
9606
|
+
buffered.length = 0;
|
|
9607
|
+
unsubscribe();
|
|
9608
|
+
this.pendingStructuredWaits.delete(fail);
|
|
9609
|
+
}
|
|
9610
|
+
}
|
|
8220
9611
|
/** @internal */
|
|
8221
9612
|
_markDisconnected() {
|
|
8222
9613
|
if (this.disconnected) {
|
|
8223
9614
|
return;
|
|
8224
9615
|
}
|
|
8225
9616
|
this.disconnected = true;
|
|
9617
|
+
for (const fail of this.pendingStructuredWaits) {
|
|
9618
|
+
fail(new Error("Session disconnected while waiting for a structured response"));
|
|
9619
|
+
}
|
|
9620
|
+
this.pendingStructuredWaits.clear();
|
|
8226
9621
|
for (const controller of this.pendingExternalTools.values()) {
|
|
8227
9622
|
controller.abort();
|
|
8228
9623
|
}
|
|
@@ -8245,6 +9640,13 @@ var CopilotSession = class {
|
|
|
8245
9640
|
}
|
|
8246
9641
|
}
|
|
8247
9642
|
this.factoryAbortControllers.clear();
|
|
9643
|
+
this.workflows.clear();
|
|
9644
|
+
for (const controllersForRun of this.workflowAbortControllers.values()) {
|
|
9645
|
+
for (const controller of controllersForRun.values()) {
|
|
9646
|
+
controller.abort();
|
|
9647
|
+
}
|
|
9648
|
+
}
|
|
9649
|
+
this.workflowAbortControllers.clear();
|
|
8248
9650
|
this.transformCallbacks?.clear();
|
|
8249
9651
|
}
|
|
8250
9652
|
/** @internal */
|
|
@@ -8878,6 +10280,192 @@ var CopilotSession = class {
|
|
|
8878
10280
|
}
|
|
8879
10281
|
};
|
|
8880
10282
|
}
|
|
10283
|
+
/**
|
|
10284
|
+
* Registers workflow closures and reverse-RPC handlers for this session.
|
|
10285
|
+
*
|
|
10286
|
+
* @param workflows - Workflow handles declared by the joining extension.
|
|
10287
|
+
* @internal Called by the SDK when an extension joins a session.
|
|
10288
|
+
*/
|
|
10289
|
+
registerWorkflows(workflows) {
|
|
10290
|
+
this.workflows.clear();
|
|
10291
|
+
if (!workflows || workflows.length === 0) {
|
|
10292
|
+
delete this.clientSessionApis.workflow;
|
|
10293
|
+
return;
|
|
10294
|
+
}
|
|
10295
|
+
for (const handle of workflows) {
|
|
10296
|
+
const definition = getWorkflowDefinition(handle);
|
|
10297
|
+
if (this.workflows.has(definition.meta.name)) {
|
|
10298
|
+
throw new Error(
|
|
10299
|
+
`Duplicate workflow name "${definition.meta.name}". Workflow names must be unique within a joinSession call.`
|
|
10300
|
+
);
|
|
10301
|
+
}
|
|
10302
|
+
this.workflows.set(definition.meta.name, definition);
|
|
10303
|
+
}
|
|
10304
|
+
const self = this;
|
|
10305
|
+
this.clientSessionApis.workflow = {
|
|
10306
|
+
async execute(params) {
|
|
10307
|
+
const definition = self.workflows.get(params.name);
|
|
10308
|
+
if (!definition) {
|
|
10309
|
+
const message = `No workflow registered with name "${params.name}"`;
|
|
10310
|
+
throw new import_node.ResponseError(import_node.ErrorCodes.InvalidParams, message, {
|
|
10311
|
+
code: "workflow_not_found",
|
|
10312
|
+
name: params.name
|
|
10313
|
+
});
|
|
10314
|
+
}
|
|
10315
|
+
const controller = new AbortController();
|
|
10316
|
+
let controllersForRun = self.workflowAbortControllers.get(params.runId);
|
|
10317
|
+
if (controllersForRun === void 0) {
|
|
10318
|
+
controllersForRun = /* @__PURE__ */ new Map();
|
|
10319
|
+
self.workflowAbortControllers.set(params.runId, controllersForRun);
|
|
10320
|
+
}
|
|
10321
|
+
controllersForRun.set(params.executionToken, controller);
|
|
10322
|
+
const progress = new WorkflowProgressBuffer(async (lines) => {
|
|
10323
|
+
await self.rpc.workflow.log({
|
|
10324
|
+
runId: params.runId,
|
|
10325
|
+
executionToken: params.executionToken,
|
|
10326
|
+
lines
|
|
10327
|
+
});
|
|
10328
|
+
});
|
|
10329
|
+
try {
|
|
10330
|
+
const context = {
|
|
10331
|
+
runId: params.runId,
|
|
10332
|
+
args: params.args,
|
|
10333
|
+
session: self,
|
|
10334
|
+
signal: controller.signal,
|
|
10335
|
+
phase: (title) => {
|
|
10336
|
+
throwIfWorkflowAborted(controller.signal);
|
|
10337
|
+
progress.enqueue("phase", title);
|
|
10338
|
+
},
|
|
10339
|
+
log: (message) => {
|
|
10340
|
+
throwIfWorkflowAborted(controller.signal);
|
|
10341
|
+
progress.enqueue("log", message);
|
|
10342
|
+
},
|
|
10343
|
+
agent: async (prompt, options = {}) => {
|
|
10344
|
+
await progress.flush();
|
|
10345
|
+
const opts = {};
|
|
10346
|
+
for (const key of WORKFLOW_AGENT_OPTION_KEYS) {
|
|
10347
|
+
copyDefinedWorkflowAgentOption(options, opts, key);
|
|
10348
|
+
}
|
|
10349
|
+
const response = await awaitWorkflowOperation(
|
|
10350
|
+
() => self.rpc.workflow.agent({
|
|
10351
|
+
workflowRunId: params.runId,
|
|
10352
|
+
executionToken: params.executionToken,
|
|
10353
|
+
prompt,
|
|
10354
|
+
opts
|
|
10355
|
+
}),
|
|
10356
|
+
controller.signal
|
|
10357
|
+
);
|
|
10358
|
+
return response.result ?? null;
|
|
10359
|
+
},
|
|
10360
|
+
step: async (key, producer, options = {}) => {
|
|
10361
|
+
await progress.flush();
|
|
10362
|
+
if (options.volatile) {
|
|
10363
|
+
throwIfWorkflowAborted(controller.signal);
|
|
10364
|
+
return producer();
|
|
10365
|
+
}
|
|
10366
|
+
const cached = await awaitWorkflowOperation(
|
|
10367
|
+
() => self.rpc.workflow.journal.get({
|
|
10368
|
+
runId: params.runId,
|
|
10369
|
+
executionToken: params.executionToken,
|
|
10370
|
+
key
|
|
10371
|
+
}),
|
|
10372
|
+
controller.signal
|
|
10373
|
+
);
|
|
10374
|
+
if (cached.hit) {
|
|
10375
|
+
if (cached.resultJson === void 0) {
|
|
10376
|
+
throw new Error(
|
|
10377
|
+
`step("${key}") journal returned a hit without a result`
|
|
10378
|
+
);
|
|
10379
|
+
}
|
|
10380
|
+
assertWorkflowStepResult(cached.resultJson, key);
|
|
10381
|
+
return cached.resultJson;
|
|
10382
|
+
}
|
|
10383
|
+
const result2 = await producer();
|
|
10384
|
+
assertWorkflowStepResult(result2, key);
|
|
10385
|
+
await awaitWorkflowOperation(
|
|
10386
|
+
() => self.rpc.workflow.journal.put({
|
|
10387
|
+
runId: params.runId,
|
|
10388
|
+
executionToken: params.executionToken,
|
|
10389
|
+
key,
|
|
10390
|
+
resultJson: result2
|
|
10391
|
+
}),
|
|
10392
|
+
controller.signal
|
|
10393
|
+
);
|
|
10394
|
+
return result2;
|
|
10395
|
+
},
|
|
10396
|
+
pause: async (key) => {
|
|
10397
|
+
if (typeof key !== "string" || key.length === 0) {
|
|
10398
|
+
throw new Error("Workflow pause checkpoint key must not be empty");
|
|
10399
|
+
}
|
|
10400
|
+
const helperScope = workflowExecutionStore.getStore()?.helperScope;
|
|
10401
|
+
if (helperScope !== void 0) {
|
|
10402
|
+
throw new Error(
|
|
10403
|
+
`Workflow pause checkpoints are not allowed inside ${helperScope}() branches`
|
|
10404
|
+
);
|
|
10405
|
+
}
|
|
10406
|
+
await progress.flush();
|
|
10407
|
+
const response = await awaitWorkflowOperation(
|
|
10408
|
+
() => self.internalRpc.workflow.pauseAtCheckpoint({
|
|
10409
|
+
runId: params.runId,
|
|
10410
|
+
executionToken: params.executionToken,
|
|
10411
|
+
key
|
|
10412
|
+
}),
|
|
10413
|
+
controller.signal
|
|
10414
|
+
);
|
|
10415
|
+
switch (response.action) {
|
|
10416
|
+
case "continue":
|
|
10417
|
+
return;
|
|
10418
|
+
case "pause":
|
|
10419
|
+
await awaitWorkflowOperation(
|
|
10420
|
+
() => new Promise(() => {
|
|
10421
|
+
}),
|
|
10422
|
+
controller.signal
|
|
10423
|
+
);
|
|
10424
|
+
}
|
|
10425
|
+
},
|
|
10426
|
+
parallel: runWorkflowParallel,
|
|
10427
|
+
pipeline: runWorkflowPipeline,
|
|
10428
|
+
workflow: async () => {
|
|
10429
|
+
throw new Error("nested workflows are not supported");
|
|
10430
|
+
}
|
|
10431
|
+
};
|
|
10432
|
+
const execution = { active: true };
|
|
10433
|
+
const result = await workflowExecutionStore.run(execution, async () => {
|
|
10434
|
+
try {
|
|
10435
|
+
return await definition.run(context);
|
|
10436
|
+
} finally {
|
|
10437
|
+
execution.active = false;
|
|
10438
|
+
}
|
|
10439
|
+
});
|
|
10440
|
+
if (result === void 0) {
|
|
10441
|
+
return {};
|
|
10442
|
+
}
|
|
10443
|
+
assertWorkflowResult(result);
|
|
10444
|
+
return { result };
|
|
10445
|
+
} finally {
|
|
10446
|
+
try {
|
|
10447
|
+
await progress.close();
|
|
10448
|
+
} finally {
|
|
10449
|
+
const controllersForRun2 = self.workflowAbortControllers.get(params.runId);
|
|
10450
|
+
if (controllersForRun2?.get(params.executionToken) === controller) {
|
|
10451
|
+
controllersForRun2.delete(params.executionToken);
|
|
10452
|
+
if (controllersForRun2.size === 0) {
|
|
10453
|
+
self.workflowAbortControllers.delete(params.runId);
|
|
10454
|
+
}
|
|
10455
|
+
}
|
|
10456
|
+
}
|
|
10457
|
+
}
|
|
10458
|
+
},
|
|
10459
|
+
async abort(params) {
|
|
10460
|
+
const controllersForRun = self.workflowAbortControllers.get(params.runId);
|
|
10461
|
+
const controller = controllersForRun?.get(params.executionToken);
|
|
10462
|
+
if (controller !== void 0) {
|
|
10463
|
+
controller.abort(new DOMException("Workflow run was aborted", "AbortError"));
|
|
10464
|
+
}
|
|
10465
|
+
return {};
|
|
10466
|
+
}
|
|
10467
|
+
};
|
|
10468
|
+
}
|
|
8881
10469
|
/**
|
|
8882
10470
|
* Registers per-provider {@link BearerTokenProvider} callbacks for BYOK providers
|
|
8883
10471
|
* configured with managed-identity / on-demand bearer-token auth.
|
|
@@ -9572,8 +11160,22 @@ function assertFactoryStepResult(value, key) {
|
|
|
9572
11160
|
allowTopLevelUndefined: false
|
|
9573
11161
|
});
|
|
9574
11162
|
}
|
|
11163
|
+
function assertWorkflowResult(value) {
|
|
11164
|
+
assertStrictJson(value, {
|
|
11165
|
+
code: "workflow_result_not_json",
|
|
11166
|
+
label: "Workflow result",
|
|
11167
|
+
allowTopLevelUndefined: true
|
|
11168
|
+
});
|
|
11169
|
+
}
|
|
11170
|
+
function assertWorkflowStepResult(value, key) {
|
|
11171
|
+
assertStrictJson(value, {
|
|
11172
|
+
code: "workflow_step_not_json",
|
|
11173
|
+
label: `Workflow step "${key}" result`,
|
|
11174
|
+
allowTopLevelUndefined: false
|
|
11175
|
+
});
|
|
11176
|
+
}
|
|
9575
11177
|
|
|
9576
|
-
//
|
|
11178
|
+
// src/sdk/nodejs/dist/runtimeArtifacts.js
|
|
9577
11179
|
import {
|
|
9578
11180
|
chmodSync,
|
|
9579
11181
|
copyFileSync,
|
|
@@ -9591,11 +11193,11 @@ import { createRequire } from "node:module";
|
|
|
9591
11193
|
import { homedir } from "node:os";
|
|
9592
11194
|
import { dirname, join, relative, sep } from "node:path";
|
|
9593
11195
|
|
|
9594
|
-
//
|
|
9595
|
-
var COPILOT_CLI_VERSION = "
|
|
11196
|
+
// src/sdk/nodejs/dist/cliVersion.js
|
|
11197
|
+
var COPILOT_CLI_VERSION = "0.0.0-dev";
|
|
9596
11198
|
var COPILOT_CLI_USE_NPM_PACKAGE = false;
|
|
9597
11199
|
|
|
9598
|
-
//
|
|
11200
|
+
// src/sdk/nodejs/dist/runtimeArtifacts.js
|
|
9599
11201
|
var require2 = createRequire(typeof __filename === "string" ? __filename : import.meta.url);
|
|
9600
11202
|
var EXCLUDED_TOP_LEVEL = /* @__PURE__ */ new Set([
|
|
9601
11203
|
"app.js",
|
|
@@ -9748,13 +11350,13 @@ function getRuntimePackageName(platform) {
|
|
|
9748
11350
|
function resolvePackageRoot(packageName, searchPaths = require2.resolve.paths(packageName) ?? []) {
|
|
9749
11351
|
return searchPaths.map((base) => join(base, ...packageName.split("/"))).find((candidate) => existsSync(join(candidate, "package.json")));
|
|
9750
11352
|
}
|
|
9751
|
-
async function ensureRuntimeBundle(
|
|
11353
|
+
async function ensureRuntimeBundle(version2, options = {}) {
|
|
9752
11354
|
const platform = options.platform ?? getRuntimePlatform();
|
|
9753
11355
|
if (COPILOT_CLI_USE_NPM_PACKAGE) {
|
|
9754
11356
|
const packageName2 = `@github/copilot-${platform}`;
|
|
9755
11357
|
const packageRoot2 = resolvePackageRoot(packageName2, options.packageSearchPaths);
|
|
9756
11358
|
if (!packageRoot2) {
|
|
9757
|
-
throw new Error(`Could not resolve ${packageName2} for Copilot CLI ${
|
|
11359
|
+
throw new Error(`Could not resolve ${packageName2} for Copilot CLI ${version2}.`);
|
|
9758
11360
|
}
|
|
9759
11361
|
validateFile(
|
|
9760
11362
|
join(packageRoot2, "prebuilds", platform, "runtime.node"),
|
|
@@ -9763,7 +11365,7 @@ async function ensureRuntimeBundle(version, options = {}) {
|
|
|
9763
11365
|
return materializeRuntimeBundle(
|
|
9764
11366
|
{ packageRoot: packageRoot2, platform },
|
|
9765
11367
|
options.cacheRoot,
|
|
9766
|
-
`${
|
|
11368
|
+
`${version2}-${platform}`
|
|
9767
11369
|
);
|
|
9768
11370
|
}
|
|
9769
11371
|
const packageName = getRuntimePackageName(platform);
|
|
@@ -9788,7 +11390,7 @@ async function ensureRuntimeBundle(version, options = {}) {
|
|
|
9788
11390
|
return wrapper;
|
|
9789
11391
|
}
|
|
9790
11392
|
|
|
9791
|
-
//
|
|
11393
|
+
// src/sdk/nodejs/dist/toolSet.js
|
|
9792
11394
|
var VALID_TOOL_NAME = /^[a-zA-Z0-9_-]+$/;
|
|
9793
11395
|
function validateName(kind, name) {
|
|
9794
11396
|
if (name === "*") {
|
|
@@ -9868,12 +11470,9 @@ var BuiltInTools = {
|
|
|
9868
11470
|
]
|
|
9869
11471
|
};
|
|
9870
11472
|
|
|
9871
|
-
//
|
|
11473
|
+
// src/sdk/nodejs/dist/client.js
|
|
9872
11474
|
var MIN_PROTOCOL_VERSION = 3;
|
|
9873
11475
|
var RUNTIME_SHUTDOWN_TIMEOUT_MS = 1e4;
|
|
9874
|
-
function isZodSchema(value) {
|
|
9875
|
-
return value != null && typeof value === "object" && "toJSONSchema" in value && typeof value.toJSONSchema === "function";
|
|
9876
|
-
}
|
|
9877
11476
|
async function withTimeout(promise, timeoutMs, message) {
|
|
9878
11477
|
let timeout;
|
|
9879
11478
|
try {
|
|
@@ -9918,13 +11517,6 @@ async function waitForChildExit(child, timeoutMs) {
|
|
|
9918
11517
|
}
|
|
9919
11518
|
});
|
|
9920
11519
|
}
|
|
9921
|
-
function toJsonSchema(parameters) {
|
|
9922
|
-
if (!parameters) return void 0;
|
|
9923
|
-
if (isZodSchema(parameters)) {
|
|
9924
|
-
return parameters.toJSONSchema();
|
|
9925
|
-
}
|
|
9926
|
-
return parameters;
|
|
9927
|
-
}
|
|
9928
11520
|
var DEFAULT_PROVIDER_NAME = "default";
|
|
9929
11521
|
function extractBearerTokenProviders(provider, providers) {
|
|
9930
11522
|
const callbacks = /* @__PURE__ */ new Map();
|
|
@@ -10057,6 +11649,7 @@ var CopilotClient = class _CopilotClient {
|
|
|
10057
11649
|
cliProcess = null;
|
|
10058
11650
|
ffiHost = null;
|
|
10059
11651
|
connection = null;
|
|
11652
|
+
requestAdapter = null;
|
|
10060
11653
|
messageWriter = null;
|
|
10061
11654
|
connectionClosed = false;
|
|
10062
11655
|
socket = null;
|
|
@@ -10094,6 +11687,7 @@ var CopilotClient = class _CopilotClient {
|
|
|
10094
11687
|
/** Connection-level session filesystem config, set via constructor option. */
|
|
10095
11688
|
sessionFsConfig = null;
|
|
10096
11689
|
requestHandler = null;
|
|
11690
|
+
extensionLaunchProvider;
|
|
10097
11691
|
builtinPluginDirectories = [];
|
|
10098
11692
|
onGitHubTelemetry;
|
|
10099
11693
|
clientGlobalHandlers = {};
|
|
@@ -10251,6 +11845,7 @@ var CopilotClient = class _CopilotClient {
|
|
|
10251
11845
|
this.onGetTraceContext = options.onGetTraceContext;
|
|
10252
11846
|
this.sessionFsConfig = options.sessionFs ?? null;
|
|
10253
11847
|
this.requestHandler = options.requestHandler ?? null;
|
|
11848
|
+
this.extensionLaunchProvider = options.extensionLaunchProvider;
|
|
10254
11849
|
this.onGitHubTelemetry = options.onGitHubTelemetry;
|
|
10255
11850
|
this.setupClientGlobalHandlers();
|
|
10256
11851
|
const connEnv = conn.kind === "stdio" || conn.kind === "tcp" ? conn.env : void 0;
|
|
@@ -10353,14 +11948,16 @@ var CopilotClient = class _CopilotClient {
|
|
|
10353
11948
|
}
|
|
10354
11949
|
setupClientGlobalHandlers() {
|
|
10355
11950
|
const handlers = {};
|
|
11951
|
+
handlers.extensionLaunchProvider = this.extensionLaunchProvider;
|
|
10356
11952
|
if (this.requestHandler) {
|
|
10357
|
-
|
|
11953
|
+
this.requestAdapter = createCopilotRequestAdapter(this.requestHandler, () => {
|
|
10358
11954
|
if (!this.connection) {
|
|
10359
11955
|
return void 0;
|
|
10360
11956
|
}
|
|
10361
11957
|
this._rpc ??= createServerRpc(this.connection);
|
|
10362
11958
|
return this._rpc;
|
|
10363
11959
|
});
|
|
11960
|
+
handlers.llmInference = this.requestAdapter;
|
|
10364
11961
|
}
|
|
10365
11962
|
if (this.onGitHubTelemetry) {
|
|
10366
11963
|
const onGitHubTelemetry = this.onGitHubTelemetry;
|
|
@@ -10465,6 +12062,9 @@ var CopilotClient = class _CopilotClient {
|
|
|
10465
12062
|
}
|
|
10466
12063
|
await this.connectToServer();
|
|
10467
12064
|
await this.verifyProtocolVersion();
|
|
12065
|
+
if (this.extensionLaunchProvider) {
|
|
12066
|
+
await this.rpc.registerExtensionLaunchProvider();
|
|
12067
|
+
}
|
|
10468
12068
|
if (this.builtinPluginDirectories.length > 0) {
|
|
10469
12069
|
try {
|
|
10470
12070
|
await this.connection.sendRequest("plugins.builtin.set", {
|
|
@@ -10553,6 +12153,7 @@ var CopilotClient = class _CopilotClient {
|
|
|
10553
12153
|
}
|
|
10554
12154
|
this.sessions.clear();
|
|
10555
12155
|
this.githubTokenProviders.clear();
|
|
12156
|
+
this.requestAdapter?.cancelPending();
|
|
10556
12157
|
if (this.connection && !this.connectionClosed && (this.cliProcess || this.ffiHost) && !this.isExternalServer) {
|
|
10557
12158
|
const runtimeShutdownStart = Date.now();
|
|
10558
12159
|
const shutdownPromise = this.rpc.runtime.shutdown();
|
|
@@ -10708,6 +12309,7 @@ var CopilotClient = class _CopilotClient {
|
|
|
10708
12309
|
}
|
|
10709
12310
|
this.sessions.clear();
|
|
10710
12311
|
this.githubTokenProviders.clear();
|
|
12312
|
+
this.requestAdapter?.cancelPending();
|
|
10711
12313
|
if (this.messageWriter) {
|
|
10712
12314
|
this.messageWriter.suppressWriteErrors = true;
|
|
10713
12315
|
}
|
|
@@ -11158,11 +12760,14 @@ var CopilotClient = class _CopilotClient {
|
|
|
11158
12760
|
async resumeSession(sessionId, config) {
|
|
11159
12761
|
return this.resumeSessionInternal(sessionId, config);
|
|
11160
12762
|
}
|
|
11161
|
-
|
|
11162
|
-
|
|
11163
|
-
return this.resumeSessionInternal(sessionId, config, factories, extensionOptions);
|
|
12763
|
+
async resumeSessionForExtension(sessionId, config, contributions = {}, extensionOptions) {
|
|
12764
|
+
return this.resumeSessionInternal(sessionId, config, contributions, extensionOptions);
|
|
11164
12765
|
}
|
|
11165
|
-
async resumeSessionInternal(sessionId, config,
|
|
12766
|
+
async resumeSessionInternal(sessionId, config, contributions = {}, extensionOptions) {
|
|
12767
|
+
const { factories, workflows } = Array.isArray(contributions) ? { factories: contributions, workflows: void 0 } : contributions;
|
|
12768
|
+
if (factories !== void 0 && workflows !== void 0) {
|
|
12769
|
+
throw new Error("Session configuration cannot include both factories and workflows");
|
|
12770
|
+
}
|
|
11166
12771
|
if (config.gitHubToken !== void 0 && config.gitHubTokenProvider !== void 0) {
|
|
11167
12772
|
throw new Error("gitHubToken and gitHubTokenProvider are mutually exclusive");
|
|
11168
12773
|
}
|
|
@@ -11183,6 +12788,7 @@ var CopilotClient = class _CopilotClient {
|
|
|
11183
12788
|
session.registerCanvases(config.canvases);
|
|
11184
12789
|
session.registerCommands(config.commands);
|
|
11185
12790
|
session.registerFactories(factories);
|
|
12791
|
+
session.registerWorkflows(workflows);
|
|
11186
12792
|
const {
|
|
11187
12793
|
wireProvider: bearerWireProvider,
|
|
11188
12794
|
wireProviders: bearerWireProviders,
|
|
@@ -11264,6 +12870,7 @@ var CopilotClient = class _CopilotClient {
|
|
|
11264
12870
|
toolSearch: config.toolSearch,
|
|
11265
12871
|
canvases: config.canvases?.map((canvas) => canvas.declaration),
|
|
11266
12872
|
factories: factories?.map((factory) => factory.meta),
|
|
12873
|
+
workflows: workflows?.map((workflow) => workflow.meta),
|
|
11267
12874
|
requestCanvasRenderer: config.requestCanvasRenderer,
|
|
11268
12875
|
requestExtensions: config.requestExtensions,
|
|
11269
12876
|
extensionSdkPath: config.extensionSdkPath,
|
|
@@ -12116,6 +13723,7 @@ stderr: ${stderrOutput}` : ""}`
|
|
|
12116
13723
|
}
|
|
12117
13724
|
this.sessions.clear();
|
|
12118
13725
|
this.githubTokenProviders.clear();
|
|
13726
|
+
this.requestAdapter?.cancelPending();
|
|
12119
13727
|
};
|
|
12120
13728
|
this.connection.onClose(markDisconnected);
|
|
12121
13729
|
this.connection.onError(() => {
|
|
@@ -12250,6 +13858,7 @@ export {
|
|
|
12250
13858
|
SYSTEM_MESSAGE_SECTIONS,
|
|
12251
13859
|
SessionFsSqliteTransactionFailure,
|
|
12252
13860
|
ToolSet,
|
|
13861
|
+
WorkflowResumeError,
|
|
12253
13862
|
approveAll,
|
|
12254
13863
|
convertMcpCallToolResult,
|
|
12255
13864
|
createAttributedPermissionResult,
|
|
@@ -12257,5 +13866,7 @@ export {
|
|
|
12257
13866
|
createSessionFsAdapter,
|
|
12258
13867
|
defineFactory,
|
|
12259
13868
|
defineTool,
|
|
12260
|
-
|
|
13869
|
+
defineWorkflow,
|
|
13870
|
+
isFactoryRunTerminal,
|
|
13871
|
+
isWorkflowRunTerminal
|
|
12261
13872
|
};
|