@github/copilot-sdk-darwin-arm64 1.0.15-unstable.35663726336.gcb2a8cc → 1.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/copilot-sdk/cliVersion.d.ts +1 -1
- package/copilot-sdk/client.d.ts +3 -0
- package/copilot-sdk/docs/extensions.md +1 -1
- package/copilot-sdk/docs/workflows.md +255 -0
- package/copilot-sdk/extension.d.ts +6 -6
- package/copilot-sdk/extension.js +1631 -415
- package/copilot-sdk/generated/rpc.d.ts +11905 -7399
- package/copilot-sdk/generated/session-events.d.ts +965 -143
- package/copilot-sdk/index.d.ts +3 -3
- package/copilot-sdk/index.js +1627 -411
- package/copilot-sdk/installationConfirmation.d.ts +19 -0
- package/copilot-sdk/schema.d.ts +4 -0
- package/copilot-sdk/session.d.ts +20 -19
- package/copilot-sdk/types.d.ts +66 -69
- package/copilot-sdk/workflow.d.ts +367 -0
- package/package.json +1 -1
- package/plugins/computer-use/Copilot Computer Use.app/Contents/CodeResources +0 -0
- package/plugins/computer-use/Copilot Computer Use.app/Contents/Info.plist +2 -2
- package/plugins/computer-use/Copilot Computer Use.app/Contents/MacOS/Copilot Computer Use +0 -0
- package/plugins/computer-use/Copilot Computer Use.app/Contents/Resources/Assets.car +0 -0
- package/plugins/computer-use/Copilot Computer Use.app/Contents/Resources/icon.icns +0 -0
- package/plugins/computer-use/Copilot Computer Use.app/Contents/_CodeSignature/CodeResources +4 -4
- package/plugins/computer-use/computer-use-mcp +0 -0
- package/plugins/computer-use/{.mcp.json → mcp.json} +2 -1
- package/plugins/computer-use/plugin.json +6 -0
- package/prebuilds/darwin-arm64/copilot-runtime +0 -0
- package/prebuilds/darwin-arm64/runtime.node +2 -2
- package/preloads/extension_bootstrap.mjs +3 -4
- package/ripgrep/bin/darwin-arm64/rg +0 -0
- package/schemas/api.schema.json +7448 -3952
- package/schemas/session-events.schema.json +1129 -820
- package/tgrep/bin/darwin-arm64/tgrep +0 -0
- package/copilot-sdk/docs/factories.md +0 -296
- package/copilot-sdk/docs/factory-patterns.md +0 -194
- package/copilot-sdk/factory.d.ts +0 -327
- package/plugins/computer-use/.plugin/plugin.json +0 -6
- package/sdk/index.js +0 -1465
package/copilot-sdk/extension.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;
|
|
@@ -115,7 +115,7 @@ var require_messages = __commonJS({
|
|
|
115
115
|
ErrorCodes4.jsonrpcReservedErrorRangeEnd = -32e3;
|
|
116
116
|
ErrorCodes4.serverErrorEnd = -32e3;
|
|
117
117
|
})(ErrorCodes3 || (exports.ErrorCodes = ErrorCodes3 = {}));
|
|
118
|
-
var
|
|
118
|
+
var ResponseError4 = class _ResponseError extends Error {
|
|
119
119
|
constructor(code, message, data) {
|
|
120
120
|
super(message);
|
|
121
121
|
this.code = is.number(code) ? code : ErrorCodes3.UnknownErrorCode;
|
|
@@ -133,7 +133,7 @@ var require_messages = __commonJS({
|
|
|
133
133
|
return result;
|
|
134
134
|
}
|
|
135
135
|
};
|
|
136
|
-
exports.ResponseError =
|
|
136
|
+
exports.ResponseError = ResponseError4;
|
|
137
137
|
var ParameterStructures = class _ParameterStructures {
|
|
138
138
|
constructor(kind) {
|
|
139
139
|
this.kind = kind;
|
|
@@ -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;
|
|
@@ -933,7 +933,7 @@ var require_cancellation = __commonJS({
|
|
|
933
933
|
}
|
|
934
934
|
}
|
|
935
935
|
};
|
|
936
|
-
var
|
|
936
|
+
var CancellationTokenSource2 = class {
|
|
937
937
|
get token() {
|
|
938
938
|
if (!this._token) {
|
|
939
939
|
this._token = new MutableToken();
|
|
@@ -955,13 +955,13 @@ var require_cancellation = __commonJS({
|
|
|
955
955
|
}
|
|
956
956
|
}
|
|
957
957
|
};
|
|
958
|
-
exports.CancellationTokenSource =
|
|
958
|
+
exports.CancellationTokenSource = CancellationTokenSource2;
|
|
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;
|
|
3318
3684
|
}
|
|
3319
3685
|
});
|
|
3320
3686
|
|
|
3321
|
-
//
|
|
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();
|
|
3692
|
+
}
|
|
3693
|
+
});
|
|
3694
|
+
|
|
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,15 +4030,15 @@ var init_ffiRuntimeHost = __esm({
|
|
|
3655
4030
|
}
|
|
3656
4031
|
});
|
|
3657
4032
|
|
|
3658
|
-
//
|
|
3659
|
-
var
|
|
4033
|
+
// src/sdk/nodejs/dist/client.js
|
|
4034
|
+
var import_node3 = __toESM(require_node(), 1);
|
|
3660
4035
|
import { spawn } from "node:child_process";
|
|
3661
4036
|
import { randomUUID } from "node:crypto";
|
|
3662
4037
|
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
|
/**
|
|
@@ -3705,6 +4080,15 @@ function createServerRpc(connection) {
|
|
|
3705
4080
|
getBuiltInCatalog: async () => connection.sendRequest("models.getBuiltInCatalog", {})
|
|
3706
4081
|
},
|
|
3707
4082
|
/** @experimental */
|
|
4083
|
+
sandbox: {
|
|
4084
|
+
/**
|
|
4085
|
+
* Reports whether the host running this runtime can run the command sandbox, without starting a session or spawning a sandboxed command.
|
|
4086
|
+
*
|
|
4087
|
+
* @returns Whether the host running this runtime can run the command sandbox. The runtime checks `supported` once per process. A capability answer can change while the process runs, for example after the user installs a missing package.
|
|
4088
|
+
*/
|
|
4089
|
+
getHostSupport: async () => connection.sendRequest("sandbox.getHostSupport", {})
|
|
4090
|
+
},
|
|
4091
|
+
/** @experimental */
|
|
3708
4092
|
tools: {
|
|
3709
4093
|
/**
|
|
3710
4094
|
* Lists built-in tools available for a model.
|
|
@@ -3825,7 +4209,74 @@ function createServerRpc(connection) {
|
|
|
3825
4209
|
*
|
|
3826
4210
|
* @returns Outcome of an mcp.planInstall call: either a normalised plan, or one typed refusal. Nothing is written in either case.
|
|
3827
4211
|
*/
|
|
3828
|
-
planInstall: async (params) => connection.sendRequest("mcp.planInstall", params)
|
|
4212
|
+
planInstall: async (params) => connection.sendRequest("mcp.planInstall", params),
|
|
4213
|
+
/**
|
|
4214
|
+
* Consumes a bound catalogue plan and retains one exact fully resolved personal remote MCP operation requiring no supplied values or configured secrets. Returns its runtime operation ID and original expiry before any confirmation, activation, writer initialisation or installation effect. Register the original connection, operation and selected-session binding before calling applyInstall. Missing lower owned admission is unavailable, never a raw-config fallback.
|
|
4215
|
+
*
|
|
4216
|
+
* @param params Side-effect-free preparation of one original bound remote MCP choice.
|
|
4217
|
+
*
|
|
4218
|
+
* @returns Management result with contract receipt, or a typed request/negotiation refusal.
|
|
4219
|
+
*/
|
|
4220
|
+
prepareInstall: async (params) => connection.sendRequest("mcp.prepareInstall", params),
|
|
4221
|
+
/**
|
|
4222
|
+
* Consumes a retained prepared MCP operation once, revalidates its original authority, requests explicit human consent through installations.confirm on the original connection, then revalidates source and applies the sealed transaction. An uncertain result requires original-operation inspection or recovery, never replay.
|
|
4223
|
+
*
|
|
4224
|
+
* @param params Applies exactly one previously prepared operation on its original connection.
|
|
4225
|
+
*
|
|
4226
|
+
* @returns An installation result together with the exact honoured contract, or a negotiation refusal.
|
|
4227
|
+
*/
|
|
4228
|
+
applyInstall: async (params) => connection.sendRequest("mcp.applyInstall", params),
|
|
4229
|
+
/**
|
|
4230
|
+
* Prepares a read-only removal plan for an exact owned receipt under the selected existing session. Returns the original operation ID before confirmation; neither planning nor abandonment changes configuration or shared OAuth credentials.
|
|
4231
|
+
*
|
|
4232
|
+
* @param params Read-only preparation of one owned removal under fresh selected-session authority.
|
|
4233
|
+
*
|
|
4234
|
+
* @returns Management result with contract receipt, or a typed request/negotiation refusal.
|
|
4235
|
+
*/
|
|
4236
|
+
planUninstall: async (params) => connection.sendRequest("mcp.planUninstall", params),
|
|
4237
|
+
/**
|
|
4238
|
+
* Consumes the original owned-removal plan once and requests fresh exact human confirmation on its original connection. Drift is refused; unrelated manual configuration and shared OAuth credentials are preserved.
|
|
4239
|
+
*
|
|
4240
|
+
* @param params One-use application of the exact retained removal plan.
|
|
4241
|
+
*
|
|
4242
|
+
* @returns An installation result together with the exact honoured contract, or a negotiation refusal.
|
|
4243
|
+
*/
|
|
4244
|
+
applyUninstall: async (params) => connection.sendRequest("mcp.applyUninstall", params),
|
|
4245
|
+
/** @experimental */
|
|
4246
|
+
installations: {
|
|
4247
|
+
/**
|
|
4248
|
+
* Reads receipt-owned MCP inventory for the selected account and host without activating servers or reconstructing missing ownership. Configuration ownership does not prove session-specific usability.
|
|
4249
|
+
*
|
|
4250
|
+
* @param params New-work inventory or recovery request under an explicitly selected existing session.
|
|
4251
|
+
*
|
|
4252
|
+
* @returns Management result with contract receipt, or a typed request/negotiation refusal.
|
|
4253
|
+
*/
|
|
4254
|
+
list: async (params) => connection.sendRequest("mcp.installations.list", params),
|
|
4255
|
+
/**
|
|
4256
|
+
* Reconciles already-confirmed durable MCP transactions, then inspects owned inventory. Does not replay apply or reconstruct deleted ownership metadata; unresolved or unsafe evidence remains an explicit refusal.
|
|
4257
|
+
*
|
|
4258
|
+
* @param params New-work inventory or recovery request under an explicitly selected existing session.
|
|
4259
|
+
*
|
|
4260
|
+
* @returns Management result with contract receipt, or a typed request/negotiation refusal.
|
|
4261
|
+
*/
|
|
4262
|
+
recover: async (params) => connection.sendRequest("mcp.installations.recover", params),
|
|
4263
|
+
/**
|
|
4264
|
+
* Inspects a known operation only on its original connection. Remains available after account or selected-session loss; does not acquire new authority or rebind an operation.
|
|
4265
|
+
*
|
|
4266
|
+
* @param params Existing-operation control. A new session selector is deliberately not accepted.
|
|
4267
|
+
*
|
|
4268
|
+
* @returns Management result with contract receipt, or a typed request/negotiation refusal.
|
|
4269
|
+
*/
|
|
4270
|
+
status: async (params) => connection.sendRequest("mcp.installations.status", params),
|
|
4271
|
+
/**
|
|
4272
|
+
* Requests cancellation of a known operation on its original connection, including before apply or confirmation. Already-started effects retain their transaction lease and report an honest terminal or recovery outcome.
|
|
4273
|
+
*
|
|
4274
|
+
* @param params Existing-operation control. A new session selector is deliberately not accepted.
|
|
4275
|
+
*
|
|
4276
|
+
* @returns Management result with contract receipt, or a typed request/negotiation refusal.
|
|
4277
|
+
*/
|
|
4278
|
+
cancel: async (params) => connection.sendRequest("mcp.installations.cancel", params)
|
|
4279
|
+
}
|
|
3829
4280
|
},
|
|
3830
4281
|
/** @experimental */
|
|
3831
4282
|
extensions: {
|
|
@@ -3848,6 +4299,115 @@ function createServerRpc(connection) {
|
|
|
3848
4299
|
*/
|
|
3849
4300
|
disable: async (params) => connection.sendRequest("extensions.disable", params)
|
|
3850
4301
|
},
|
|
4302
|
+
/** @experimental */
|
|
4303
|
+
skills: {
|
|
4304
|
+
/**
|
|
4305
|
+
* Plans installation of a verified Agent Finder Skill candidate without writing files. The returned review is safe to present to a user and installing always leaves the Skill disabled until separately enabled.
|
|
4306
|
+
*
|
|
4307
|
+
* @param params Side-effect-free planning of one verified Agent Finder Skill candidate.
|
|
4308
|
+
*
|
|
4309
|
+
* @returns Skill installation management result with the honoured contract, or a typed refusal.
|
|
4310
|
+
*/
|
|
4311
|
+
planInstall: async (params) => connection.sendRequest("skills.planInstall", params),
|
|
4312
|
+
/**
|
|
4313
|
+
* Consumes one verified Skill installation plan, requests explicit human consent through installations.confirm on the original connection, then revalidates and installs the Skill disabled.
|
|
4314
|
+
*
|
|
4315
|
+
* @param params Applies exactly one retained verified Skill installation plan.
|
|
4316
|
+
*
|
|
4317
|
+
* @returns Skill installation result with the honoured contract, or a typed request/negotiation refusal.
|
|
4318
|
+
*/
|
|
4319
|
+
applyInstall: async (params) => connection.sendRequest("skills.applyInstall", params),
|
|
4320
|
+
/** @experimental */
|
|
4321
|
+
installations: {
|
|
4322
|
+
/**
|
|
4323
|
+
* Lists owned verified Agent Finder Skill installations for the selected existing session. Listing is never gated by the Skill-install feature flag.
|
|
4324
|
+
*
|
|
4325
|
+
* @param params Inventory request under an explicitly selected existing session.
|
|
4326
|
+
*
|
|
4327
|
+
* @returns Skill installation management result with the honoured contract, or a typed refusal.
|
|
4328
|
+
*/
|
|
4329
|
+
list: async (params) => connection.sendRequest("skills.installations.list", params),
|
|
4330
|
+
/**
|
|
4331
|
+
* Reconciles interrupted owned Skill installation work for the selected existing session, then inspects owned inventory. Recovery is never gated by the Skill-install feature flag.
|
|
4332
|
+
*
|
|
4333
|
+
* @param params Inventory request under an explicitly selected existing session.
|
|
4334
|
+
*
|
|
4335
|
+
* @returns Skill installation management result with the honoured contract, or a typed refusal.
|
|
4336
|
+
*/
|
|
4337
|
+
recover: async (params) => connection.sendRequest("skills.installations.recover", params),
|
|
4338
|
+
/**
|
|
4339
|
+
* Inspects a known Skill installation operation on its original runtime connection. Status is never gated by the Skill-install feature flag.
|
|
4340
|
+
*
|
|
4341
|
+
* @param params Existing-operation control. A new session selector is deliberately not accepted.
|
|
4342
|
+
*
|
|
4343
|
+
* @returns Skill installation management result with the honoured contract, or a typed refusal.
|
|
4344
|
+
*/
|
|
4345
|
+
status: async (params) => connection.sendRequest("skills.installations.status", params),
|
|
4346
|
+
/**
|
|
4347
|
+
* Requests cancellation of a known Skill installation operation before commit. Already-started durable work requires recovery instead of silent replay.
|
|
4348
|
+
*
|
|
4349
|
+
* @param params Existing-operation control. A new session selector is deliberately not accepted.
|
|
4350
|
+
*
|
|
4351
|
+
* @returns Skill installation management result with the honoured contract, or a typed refusal.
|
|
4352
|
+
*/
|
|
4353
|
+
cancel: async (params) => connection.sendRequest("skills.installations.cancel", params),
|
|
4354
|
+
/**
|
|
4355
|
+
* Atomically persists enablement for one owned Agent Finder Skill and reconciles the selected bound session. Enablement is installation-scoped by receipt identity and is never gated by the Skill-install feature flag.
|
|
4356
|
+
*
|
|
4357
|
+
* @param params Persisted enablement update for one owned Skill installation.
|
|
4358
|
+
*
|
|
4359
|
+
* @returns Skill installation management result with the honoured contract, or a typed refusal.
|
|
4360
|
+
*/
|
|
4361
|
+
setEnabled: async (params) => connection.sendRequest("skills.installations.setEnabled", params)
|
|
4362
|
+
},
|
|
4363
|
+
/**
|
|
4364
|
+
* Prepares a read-only removal plan for an owned verified Agent Finder Skill installation. Uninstall planning is never gated by the Skill-install feature flag.
|
|
4365
|
+
*
|
|
4366
|
+
* @param params Read-only preparation of one owned Skill removal under fresh selected-session authority.
|
|
4367
|
+
*
|
|
4368
|
+
* @returns Skill installation management result with the honoured contract, or a typed refusal.
|
|
4369
|
+
*/
|
|
4370
|
+
planUninstall: async (params) => connection.sendRequest("skills.planUninstall", params),
|
|
4371
|
+
/**
|
|
4372
|
+
* Consumes an owned Skill removal plan, requests explicit human consent through installations.confirm, refuses drift, and removes the exact owned files through quarantine.
|
|
4373
|
+
*
|
|
4374
|
+
* @param params One-use application of the exact retained Skill removal plan.
|
|
4375
|
+
*
|
|
4376
|
+
* @returns Skill installation result with the honoured contract, or a typed request/negotiation refusal.
|
|
4377
|
+
*/
|
|
4378
|
+
applyUninstall: async (params) => connection.sendRequest("skills.applyUninstall", params),
|
|
4379
|
+
/** @experimental */
|
|
4380
|
+
config: {
|
|
4381
|
+
/**
|
|
4382
|
+
* Replaces the global list of disabled skills.
|
|
4383
|
+
*
|
|
4384
|
+
* @param params Skill names to mark as disabled in global configuration, replacing any previous list.
|
|
4385
|
+
*/
|
|
4386
|
+
setDisabledSkills: async (params) => connection.sendRequest("skills.config.setDisabledSkills", params),
|
|
4387
|
+
/**
|
|
4388
|
+
* Atomically adds or removes one skill from the disabled list.
|
|
4389
|
+
*
|
|
4390
|
+
* @param params Adds or removes a single skill from the global disabled list, leaving every other entry untouched.
|
|
4391
|
+
*/
|
|
4392
|
+
setSkillDisabled: async (params) => connection.sendRequest("skills.config.setSkillDisabled", params)
|
|
4393
|
+
},
|
|
4394
|
+
/**
|
|
4395
|
+
* Discovers skills across global and project sources.
|
|
4396
|
+
*
|
|
4397
|
+
* @param params Optional project paths and additional skill directories to include in discovery.
|
|
4398
|
+
*
|
|
4399
|
+
* @returns Skills discovered across global and project sources.
|
|
4400
|
+
*/
|
|
4401
|
+
discover: async (params) => connection.sendRequest("skills.discover", params),
|
|
4402
|
+
/**
|
|
4403
|
+
* Returns the canonical directories where a client may create skills that the runtime will recognize, including ones that do not exist yet. Project directories become active once created.
|
|
4404
|
+
*
|
|
4405
|
+
* @param params Optional project paths to enumerate.
|
|
4406
|
+
*
|
|
4407
|
+
* @returns Canonical locations where skills can be created so the runtime will recognize them.
|
|
4408
|
+
*/
|
|
4409
|
+
getDiscoveryPaths: async (params) => connection.sendRequest("skills.getDiscoveryPaths", params)
|
|
4410
|
+
},
|
|
3851
4411
|
/**
|
|
3852
4412
|
* Registers the calling SDK client as the per-entrypoint extension launch provider. Call before creating any sessions. When omitted, the runtime uses its built-in extension launcher.
|
|
3853
4413
|
*
|
|
@@ -3863,7 +4423,15 @@ function createServerRpc(connection) {
|
|
|
3863
4423
|
*
|
|
3864
4424
|
* @returns Outcome of a catalog.search call: either bounded inert candidates, or one typed refusal. Never a partial success.
|
|
3865
4425
|
*/
|
|
3866
|
-
search: async (params) => connection.sendRequest("catalog.search", params)
|
|
4426
|
+
search: async (params) => connection.sendRequest("catalog.search", params),
|
|
4427
|
+
/**
|
|
4428
|
+
* 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.
|
|
4429
|
+
*
|
|
4430
|
+
* @param params Terminates one retained catalog selection group through an opaque reference previously returned by the model-safe search projection.
|
|
4431
|
+
*
|
|
4432
|
+
* @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.
|
|
4433
|
+
*/
|
|
4434
|
+
select: async (params) => connection.sendRequest("catalog.select", params)
|
|
3867
4435
|
},
|
|
3868
4436
|
/** @experimental */
|
|
3869
4437
|
plugins: {
|
|
@@ -3965,40 +4533,6 @@ function createServerRpc(connection) {
|
|
|
3965
4533
|
}
|
|
3966
4534
|
},
|
|
3967
4535
|
/** @experimental */
|
|
3968
|
-
skills: {
|
|
3969
|
-
/** @experimental */
|
|
3970
|
-
config: {
|
|
3971
|
-
/**
|
|
3972
|
-
* Replaces the global list of disabled skills.
|
|
3973
|
-
*
|
|
3974
|
-
* @param params Skill names to mark as disabled in global configuration, replacing any previous list.
|
|
3975
|
-
*/
|
|
3976
|
-
setDisabledSkills: async (params) => connection.sendRequest("skills.config.setDisabledSkills", params),
|
|
3977
|
-
/**
|
|
3978
|
-
* Atomically adds or removes one skill from the disabled list.
|
|
3979
|
-
*
|
|
3980
|
-
* @param params Adds or removes a single skill from the global disabled list, leaving every other entry untouched.
|
|
3981
|
-
*/
|
|
3982
|
-
setSkillDisabled: async (params) => connection.sendRequest("skills.config.setSkillDisabled", params)
|
|
3983
|
-
},
|
|
3984
|
-
/**
|
|
3985
|
-
* Discovers skills across global and project sources.
|
|
3986
|
-
*
|
|
3987
|
-
* @param params Optional project paths and additional skill directories to include in discovery.
|
|
3988
|
-
*
|
|
3989
|
-
* @returns Skills discovered across global and project sources.
|
|
3990
|
-
*/
|
|
3991
|
-
discover: async (params) => connection.sendRequest("skills.discover", params),
|
|
3992
|
-
/**
|
|
3993
|
-
* Returns the canonical directories where a client may create skills that the runtime will recognize, including ones that do not exist yet. Project directories become active once created.
|
|
3994
|
-
*
|
|
3995
|
-
* @param params Optional project paths to enumerate.
|
|
3996
|
-
*
|
|
3997
|
-
* @returns Canonical locations where skills can be created so the runtime will recognize them.
|
|
3998
|
-
*/
|
|
3999
|
-
getDiscoveryPaths: async (params) => connection.sendRequest("skills.getDiscoveryPaths", params)
|
|
4000
|
-
},
|
|
4001
|
-
/** @experimental */
|
|
4002
4536
|
agents: {
|
|
4003
4537
|
/**
|
|
4004
4538
|
* Discovers custom agents across user, project, plugin, and remote sources.
|
|
@@ -4094,7 +4628,7 @@ function createServerRpc(connection) {
|
|
|
4094
4628
|
/**
|
|
4095
4629
|
* Registers an SDK client as the session filesystem provider.
|
|
4096
4630
|
*
|
|
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.
|
|
4631
|
+
* @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
4632
|
*
|
|
4099
4633
|
* @returns Indicates whether the calling client was registered as the session filesystem provider.
|
|
4100
4634
|
*/
|
|
@@ -4398,19 +4932,22 @@ function createInternalServerRpc(connection) {
|
|
|
4398
4932
|
*/
|
|
4399
4933
|
getBoardEntryCount: async (params) => connection.sendRequest("sessions.getBoardEntryCount", params),
|
|
4400
4934
|
/**
|
|
4401
|
-
*
|
|
4935
|
+
* 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.
|
|
4402
4936
|
*
|
|
4403
|
-
* @param params Params to attach
|
|
4404
|
-
*
|
|
4405
|
-
* @returns Handle for releasing the extension tool registration.
|
|
4937
|
+
* @param params Params to attach or detach an in-process ExtensionController delegate.
|
|
4406
4938
|
*/
|
|
4407
|
-
|
|
4939
|
+
configureSessionExtensions: async (params) => connection.sendRequest("sessions.configureSessionExtensions", params)
|
|
4940
|
+
},
|
|
4941
|
+
/** @experimental */
|
|
4942
|
+
accounts: {
|
|
4408
4943
|
/**
|
|
4409
|
-
*
|
|
4944
|
+
* Acquire a Microsoft Entra access token through the runtime's OneAuth broker. Account-scoped because it uses the same native broker as the account stack: a trusted host application mints a scoped Entra token for its own use, most notably to authenticate to a remote MCP server whose authorization server is Entra ID (in place of the generic browser-OAuth flow).
|
|
4410
4945
|
*
|
|
4411
|
-
* @param params
|
|
4946
|
+
* @param params OneAuth token request supplied by a trusted host application.
|
|
4947
|
+
*
|
|
4948
|
+
* @returns Result of a OneAuth token acquisition.
|
|
4412
4949
|
*/
|
|
4413
|
-
|
|
4950
|
+
acquireEntraToken: async (params) => connection.sendRequest("accounts.acquireEntraToken", params)
|
|
4414
4951
|
}
|
|
4415
4952
|
};
|
|
4416
4953
|
}
|
|
@@ -4513,13 +5050,65 @@ function createSessionRpc(connection, sessionId) {
|
|
|
4513
5050
|
setCredentials: async (params) => connection.sendRequest("session.gitHubAuth.setCredentials", { sessionId, ...params })
|
|
4514
5051
|
},
|
|
4515
5052
|
/** @experimental */
|
|
5053
|
+
accounts: {
|
|
5054
|
+
/**
|
|
5055
|
+
* Enumerate a typed accounts collection: the signed-in accounts, or the providers offered for interactive login.
|
|
5056
|
+
*
|
|
5057
|
+
* @param params Enumerate request carrying the typed collection query.
|
|
5058
|
+
*
|
|
5059
|
+
* @returns The enumerated collection, keyed by the same selector as the query.
|
|
5060
|
+
*/
|
|
5061
|
+
enumerate: async (params) => connection.sendRequest("session.accounts.enumerate", { sessionId, ...params }),
|
|
5062
|
+
/**
|
|
5063
|
+
* Read one typed accounts datum: the active account, a neutral status summary, or the last authentication errors.
|
|
5064
|
+
*
|
|
5065
|
+
* @param params Read request carrying the typed datum query.
|
|
5066
|
+
*
|
|
5067
|
+
* @returns The read result, keyed by the same selector as the query.
|
|
5068
|
+
*/
|
|
5069
|
+
get: async (params) => connection.sendRequest("session.accounts.get", { sessionId, ...params }),
|
|
5070
|
+
/**
|
|
5071
|
+
* Apply one non-interactive accounts mutation: switch the active account, log an account out, or set credentials from a token.
|
|
5072
|
+
*
|
|
5073
|
+
* @param params Mutation request carrying the typed write command.
|
|
5074
|
+
*
|
|
5075
|
+
* @returns Result of a non-interactive accounts mutation.
|
|
5076
|
+
*/
|
|
5077
|
+
set: async (params) => connection.sendRequest("session.accounts.set", { sessionId, ...params }),
|
|
5078
|
+
/** @experimental */
|
|
5079
|
+
login: {
|
|
5080
|
+
/**
|
|
5081
|
+
* Begin an interactive login flow for a provider kind (dispatch is kind-only) and return its opaque flow id and first step.
|
|
5082
|
+
*
|
|
5083
|
+
* @param params Begin an interactive login flow for a provider kind. Dispatch is kind-only.
|
|
5084
|
+
*
|
|
5085
|
+
* @returns A started login flow: its opaque id and first step.
|
|
5086
|
+
*/
|
|
5087
|
+
begin: async (params) => connection.sendRequest("session.accounts.login.begin", { sessionId, ...params }),
|
|
5088
|
+
/**
|
|
5089
|
+
* Advance an in-flight login flow, optionally fulfilling an input-required step, and return the next step.
|
|
5090
|
+
*
|
|
5091
|
+
* @param params Advance an in-flight login flow, optionally fulfilling an input-required step.
|
|
5092
|
+
*
|
|
5093
|
+
* @returns One step in an interactive login flow. The consumer acts on the step and calls advance to proceed. Browser-open is encoded as two distinct steps by design: `open-url` is CONSUMER-driven (the provider surfaces the authorize URL and the consumer opens it — github.com/GHEC web), while `needs-interaction` is PROVIDER-driven (the provider opens the browser or broker UI itself and does not surface a URL — Entra).
|
|
5094
|
+
*/
|
|
5095
|
+
advance: async (params) => connection.sendRequest("session.accounts.login.advance", { sessionId, ...params }),
|
|
5096
|
+
/**
|
|
5097
|
+
* Cancel an in-flight login flow and release its resources.
|
|
5098
|
+
*
|
|
5099
|
+
* @param params Cancel an in-flight login flow.
|
|
5100
|
+
*/
|
|
5101
|
+
cancel: async (params) => connection.sendRequest("session.accounts.login.cancel", { sessionId, ...params })
|
|
5102
|
+
}
|
|
5103
|
+
},
|
|
5104
|
+
/** @experimental */
|
|
4516
5105
|
debug: {
|
|
4517
5106
|
/**
|
|
4518
|
-
* Collects a
|
|
5107
|
+
* Collects a session debug log bundle into a local archive or staging directory. Logs are redacted by default; redaction can be configured per caller-provided diagnostic entry. The runtime includes session-owned logs by default and accepts caller-provided diagnostic entries so host applications can add their own files without changing this API shape.
|
|
4519
5108
|
*
|
|
4520
|
-
* @param params Options for collecting a
|
|
5109
|
+
* @param params Options for collecting a session debug bundle with configurable redaction.
|
|
4521
5110
|
*
|
|
4522
|
-
* @returns Result of collecting a
|
|
5111
|
+
* @returns Result of collecting a session debug bundle.
|
|
4523
5112
|
*/
|
|
4524
5113
|
collectLogs: async (params) => connection.sendRequest("session.debug.collectLogs", { sessionId, ...params })
|
|
4525
5114
|
},
|
|
@@ -4564,105 +5153,105 @@ function createSessionRpc(connection, sessionId) {
|
|
|
4564
5153
|
}
|
|
4565
5154
|
},
|
|
4566
5155
|
/** @experimental */
|
|
4567
|
-
|
|
5156
|
+
workflow: {
|
|
4568
5157
|
/**
|
|
4569
|
-
* Runs a registered
|
|
5158
|
+
* Runs a registered dynamic workflow by name at the top level.
|
|
4570
5159
|
*
|
|
4571
|
-
* @param params Parameters for invoking a registered
|
|
5160
|
+
* @param params Parameters for invoking a registered workflow.
|
|
4572
5161
|
*
|
|
4573
|
-
* @returns Complete current or terminal
|
|
5162
|
+
* @returns Complete current or terminal workflow run envelope.
|
|
4574
5163
|
*/
|
|
4575
|
-
run: async (params) => connection.sendRequest("session.
|
|
5164
|
+
run: async (params) => connection.sendRequest("session.workflow.run", { sessionId, ...params }),
|
|
4576
5165
|
/**
|
|
4577
|
-
* Resumes a
|
|
5166
|
+
* Resumes a dynamic workflow run using its persisted name, arguments, journal, and accounting.
|
|
4578
5167
|
*
|
|
4579
|
-
* @param params Parameters for resuming a
|
|
5168
|
+
* @param params Parameters for resuming a workflow run from its persisted identity.
|
|
4580
5169
|
*
|
|
4581
|
-
* @returns Resolved persisted
|
|
5170
|
+
* @returns Resolved persisted workflow identity and resumed run envelope.
|
|
4582
5171
|
*/
|
|
4583
|
-
resume: async (params) => connection.sendRequest("session.
|
|
5172
|
+
resume: async (params) => connection.sendRequest("session.workflow.resume", { sessionId, ...params }),
|
|
4584
5173
|
/**
|
|
4585
|
-
* Gets the current or settled envelope for a
|
|
5174
|
+
* Gets the current or settled envelope for a dynamic workflow run.
|
|
4586
5175
|
*
|
|
4587
|
-
* @param params Parameters for retrieving a
|
|
5176
|
+
* @param params Parameters for retrieving a workflow run.
|
|
4588
5177
|
*
|
|
4589
|
-
* @returns Complete current or terminal
|
|
5178
|
+
* @returns Complete current or terminal workflow run envelope.
|
|
4590
5179
|
*/
|
|
4591
|
-
getRun: async (params) => connection.sendRequest("session.
|
|
5180
|
+
getRun: async (params) => connection.sendRequest("session.workflow.getRun", { sessionId, ...params }),
|
|
4592
5181
|
/**
|
|
4593
|
-
* Lists durable
|
|
5182
|
+
* Lists durable dynamic workflow runs for this session in creation order.
|
|
4594
5183
|
*
|
|
4595
|
-
* @param params Parameters for paging
|
|
5184
|
+
* @param params Parameters for paging workflow runs.
|
|
4596
5185
|
*
|
|
4597
|
-
* @returns A page of
|
|
5186
|
+
* @returns A page of workflow runs in durable creation order.
|
|
4598
5187
|
*/
|
|
4599
|
-
listRuns: async (params) => connection.sendRequest("session.
|
|
5188
|
+
listRuns: async (params) => connection.sendRequest("session.workflow.listRuns", { sessionId, ...params }),
|
|
4600
5189
|
/**
|
|
4601
|
-
* Gets durable and live observability detail for one
|
|
5190
|
+
* Gets durable and live observability detail for one dynamic workflow run.
|
|
4602
5191
|
*
|
|
4603
|
-
* @param params Parameters for retrieving a
|
|
5192
|
+
* @param params Parameters for retrieving a workflow run.
|
|
4604
5193
|
*
|
|
4605
|
-
* @returns Full
|
|
5194
|
+
* @returns Full workflow run observability detail.
|
|
4606
5195
|
*/
|
|
4607
|
-
getRunDetail: async (params) => connection.sendRequest("session.
|
|
5196
|
+
getRunDetail: async (params) => connection.sendRequest("session.workflow.getRunDetail", { sessionId, ...params }),
|
|
4608
5197
|
/**
|
|
4609
|
-
* Pages durable progress for one
|
|
5198
|
+
* Pages durable progress for one dynamic workflow run.
|
|
4610
5199
|
*
|
|
4611
|
-
* @param params Parameters for paging
|
|
5200
|
+
* @param params Parameters for paging workflow progress.
|
|
4612
5201
|
*
|
|
4613
|
-
* @returns A bidirectional page of
|
|
5202
|
+
* @returns A bidirectional page of workflow progress.
|
|
4614
5203
|
*/
|
|
4615
|
-
getRunProgress: async (params) => connection.sendRequest("session.
|
|
5204
|
+
getRunProgress: async (params) => connection.sendRequest("session.workflow.getRunProgress", { sessionId, ...params }),
|
|
4616
5205
|
/**
|
|
4617
|
-
* Requests cancellation of a
|
|
5206
|
+
* Requests cancellation of a dynamic workflow run and returns its run envelope.
|
|
4618
5207
|
*
|
|
4619
|
-
* @param params Parameters for cancelling a
|
|
5208
|
+
* @param params Parameters for cancelling a workflow run.
|
|
4620
5209
|
*
|
|
4621
|
-
* @returns Complete current or terminal
|
|
5210
|
+
* @returns Complete current or terminal workflow run envelope.
|
|
4622
5211
|
*/
|
|
4623
|
-
cancel: async (params) => connection.sendRequest("session.
|
|
5212
|
+
cancel: async (params) => connection.sendRequest("session.workflow.cancel", { sessionId, ...params }),
|
|
4624
5213
|
/**
|
|
4625
|
-
* Pauses a running
|
|
5214
|
+
* Pauses a running dynamic workflow and returns its settled run envelope.
|
|
4626
5215
|
*
|
|
4627
|
-
* @param params Parameters for pausing a running
|
|
5216
|
+
* @param params Parameters for pausing a running workflow.
|
|
4628
5217
|
*
|
|
4629
|
-
* @returns Complete current or terminal
|
|
5218
|
+
* @returns Complete current or terminal workflow run envelope.
|
|
4630
5219
|
*/
|
|
4631
|
-
pause: async (params) => connection.sendRequest("session.
|
|
5220
|
+
pause: async (params) => connection.sendRequest("session.workflow.pause", { sessionId, ...params }),
|
|
4632
5221
|
/**
|
|
4633
|
-
* Records a batch of ordered
|
|
5222
|
+
* Records a batch of ordered dynamic workflow progress lines.
|
|
4634
5223
|
*
|
|
4635
|
-
* @param params Parameters for recording
|
|
5224
|
+
* @param params Parameters for recording workflow progress.
|
|
4636
5225
|
*
|
|
4637
|
-
* @returns Acknowledgement that a
|
|
5226
|
+
* @returns Acknowledgement that a workflow request was accepted.
|
|
4638
5227
|
*/
|
|
4639
|
-
log: async (params) => connection.sendRequest("session.
|
|
5228
|
+
log: async (params) => connection.sendRequest("session.workflow.log", { sessionId, ...params }),
|
|
4640
5229
|
/**
|
|
4641
|
-
* Runs one
|
|
5230
|
+
* Runs one dynamic-workflow-scoped subagent and returns its result.
|
|
4642
5231
|
*
|
|
4643
|
-
* @param params Parameters for one
|
|
5232
|
+
* @param params Parameters for one workflow-scoped subagent call.
|
|
4644
5233
|
*
|
|
4645
|
-
* @returns Result of one
|
|
5234
|
+
* @returns Result of one workflow-scoped subagent call.
|
|
4646
5235
|
*/
|
|
4647
|
-
agent: async (params) => connection.sendRequest("session.
|
|
5236
|
+
agent: async (params) => connection.sendRequest("session.workflow.agent", { sessionId, ...params }),
|
|
4648
5237
|
/** @experimental */
|
|
4649
5238
|
journal: {
|
|
4650
5239
|
/**
|
|
4651
|
-
* Reads a memoized
|
|
5240
|
+
* Reads a memoized dynamic workflow journal entry.
|
|
4652
5241
|
*
|
|
4653
|
-
* @param params Parameters for reading a
|
|
5242
|
+
* @param params Parameters for reading a workflow journal entry.
|
|
4654
5243
|
*
|
|
4655
|
-
* @returns Result of reading a
|
|
5244
|
+
* @returns Result of reading a workflow journal entry.
|
|
4656
5245
|
*/
|
|
4657
|
-
get: async (params) => connection.sendRequest("session.
|
|
5246
|
+
get: async (params) => connection.sendRequest("session.workflow.journal.get", { sessionId, ...params }),
|
|
4658
5247
|
/**
|
|
4659
|
-
* Stores a memoized
|
|
5248
|
+
* Stores a memoized dynamic workflow journal entry.
|
|
4660
5249
|
*
|
|
4661
|
-
* @param params Parameters for storing a
|
|
5250
|
+
* @param params Parameters for storing a workflow journal entry.
|
|
4662
5251
|
*
|
|
4663
|
-
* @returns Acknowledgement that a
|
|
5252
|
+
* @returns Acknowledgement that a workflow request was accepted.
|
|
4664
5253
|
*/
|
|
4665
|
-
put: async (params) => connection.sendRequest("session.
|
|
5254
|
+
put: async (params) => connection.sendRequest("session.workflow.journal.put", { sessionId, ...params })
|
|
4666
5255
|
}
|
|
4667
5256
|
},
|
|
4668
5257
|
/** @experimental */
|
|
@@ -4829,6 +5418,32 @@ function createSessionRpc(connection, sessionId) {
|
|
|
4829
5418
|
* @param params Relative path and UTF-8 content for the workspace file to create or overwrite.
|
|
4830
5419
|
*/
|
|
4831
5420
|
createFile: async (params) => connection.sendRequest("session.workspaces.createFile", { sessionId, ...params }),
|
|
5421
|
+
/**
|
|
5422
|
+
* Returns metadata for a file or directory in the session workspace files directory.
|
|
5423
|
+
*
|
|
5424
|
+
* @param params Relative path of the workspace file or directory to inspect.
|
|
5425
|
+
*
|
|
5426
|
+
* @returns Filesystem metadata for a path in the session workspace files directory.
|
|
5427
|
+
*/
|
|
5428
|
+
statFile: async (params) => connection.sendRequest("session.workspaces.statFile", { sessionId, ...params }),
|
|
5429
|
+
/**
|
|
5430
|
+
* Creates a directory in the session workspace files directory.
|
|
5431
|
+
*
|
|
5432
|
+
* @param params Directory to create within the session workspace files directory.
|
|
5433
|
+
*/
|
|
5434
|
+
createDirectory: async (params) => connection.sendRequest("session.workspaces.createDirectory", { sessionId, ...params }),
|
|
5435
|
+
/**
|
|
5436
|
+
* Removes a file or directory from the session workspace files directory.
|
|
5437
|
+
*
|
|
5438
|
+
* @param params File or directory to remove from the session workspace files directory.
|
|
5439
|
+
*/
|
|
5440
|
+
removePath: async (params) => connection.sendRequest("session.workspaces.removePath", { sessionId, ...params }),
|
|
5441
|
+
/**
|
|
5442
|
+
* Renames a file or directory within the session workspace files directory.
|
|
5443
|
+
*
|
|
5444
|
+
* @param params Source and destination paths for a rename within the session workspace files directory.
|
|
5445
|
+
*/
|
|
5446
|
+
renamePath: async (params) => connection.sendRequest("session.workspaces.renamePath", { sessionId, ...params }),
|
|
4832
5447
|
/**
|
|
4833
5448
|
* Lists workspace checkpoints in chronological order.
|
|
4834
5449
|
*
|
|
@@ -4935,7 +5550,20 @@ function createSessionRpc(connection, sessionId) {
|
|
|
4935
5550
|
*
|
|
4936
5551
|
* @returns Instruction sources loaded for the session, in merge order.
|
|
4937
5552
|
*/
|
|
4938
|
-
getSources: async () => connection.sendRequest("session.instructions.getSources", { sessionId })
|
|
5553
|
+
getSources: async () => connection.sendRequest("session.instructions.getSources", { sessionId }),
|
|
5554
|
+
/**
|
|
5555
|
+
* Invalidates cached custom-instruction discovery so subsequent turns and source reads observe instruction files currently on disk.
|
|
5556
|
+
*/
|
|
5557
|
+
reload: async () => connection.sendRequest("session.instructions.reload", { sessionId })
|
|
5558
|
+
},
|
|
5559
|
+
/** @experimental */
|
|
5560
|
+
customizations: {
|
|
5561
|
+
/**
|
|
5562
|
+
* Reloads all repository and user customizations for the active session: instructions, plugins and their MCP servers and hooks, custom agents, extensions, and skills. Returns diagnostics from the final skill reload.
|
|
5563
|
+
*
|
|
5564
|
+
* @returns Diagnostics from reloading skill definitions, with warnings and errors as separate lists.
|
|
5565
|
+
*/
|
|
5566
|
+
reload: async () => connection.sendRequest("session.customizations.reload", { sessionId })
|
|
4939
5567
|
},
|
|
4940
5568
|
/** @experimental */
|
|
4941
5569
|
fleet: {
|
|
@@ -5234,7 +5862,15 @@ function createSessionRpc(connection, sessionId) {
|
|
|
5234
5862
|
*/
|
|
5235
5863
|
authenticationStateChanged: async (params) => connection.sendRequest("session.mcp.oauth.authenticationStateChanged", { sessionId, ...params }),
|
|
5236
5864
|
/**
|
|
5237
|
-
*
|
|
5865
|
+
* Prepares an inert, expiring owned OAuth login bound to the original session requester and exact installation. Does not activate, connect, read credentials or open a browser.
|
|
5866
|
+
*
|
|
5867
|
+
* @param params Effect-free preparation bound to the existing local session, requester and installation, with frozen options.
|
|
5868
|
+
*
|
|
5869
|
+
* @returns An inert runtime-issued login handle. Preparation alone performs no activation or OAuth work.
|
|
5870
|
+
*/
|
|
5871
|
+
prepareLogin: async (params) => connection.sendRequest("session.mcp.oauth.prepareLogin", { sessionId, ...params }),
|
|
5872
|
+
/**
|
|
5873
|
+
* Starts OAuth authentication for a remote MCP server. Owned servers require the original one-use prepareLogin handle and exact installation ID; manual servers retain the existing direct login behaviour.
|
|
5238
5874
|
*
|
|
5239
5875
|
* @param params Remote MCP server name and optional overrides controlling reauthentication, OAuth client display name, callback success-page copy, and static OAuth client selection.
|
|
5240
5876
|
*
|
|
@@ -5244,11 +5880,19 @@ function createSessionRpc(connection, sessionId) {
|
|
|
5244
5880
|
/**
|
|
5245
5881
|
* Passively probes a configured remote MCP server to classify whether OAuth is required or a cached/override token is accepted. Does not start OAuth, emit pending OAuth requests, or mutate MCP connection state.
|
|
5246
5882
|
*
|
|
5247
|
-
* @param params Remote MCP server name for a passive OAuth status probe.
|
|
5883
|
+
* @param params Remote MCP server name for a passive OAuth status probe.
|
|
5884
|
+
*
|
|
5885
|
+
* @returns Passive MCP OAuth probe result. `authenticated` means the server accepted the probe request while an OAuth-origin access token was attached; it does not prove the server required or independently validated that token. The probe does not make a second unauthenticated request. Failed is an expected probe-domain outcome; JSON-RPC errors are reserved for API-call failures.
|
|
5886
|
+
*/
|
|
5887
|
+
probe: async (params) => connection.sendRequest("session.mcp.oauth.probe", { sessionId, ...params }),
|
|
5888
|
+
/**
|
|
5889
|
+
* Cancels the exact owned OAuth login issued to this original session requester, without clearing shared credentials.
|
|
5890
|
+
*
|
|
5891
|
+
* @param params Targets only the original prepared/applying owned login on this exact session requester.
|
|
5248
5892
|
*
|
|
5249
|
-
* @returns
|
|
5893
|
+
* @returns Honest terminal cancellation result; persistence or recovery failures remain RPC errors.
|
|
5250
5894
|
*/
|
|
5251
|
-
|
|
5895
|
+
cancelLogin: async (params) => connection.sendRequest("session.mcp.oauth.cancelLogin", { sessionId, ...params }),
|
|
5252
5896
|
/**
|
|
5253
5897
|
* Responds to a pending MCP OAuth authorization request by its request id.
|
|
5254
5898
|
*
|
|
@@ -5345,13 +5989,187 @@ function createSessionRpc(connection, sessionId) {
|
|
|
5345
5989
|
}
|
|
5346
5990
|
},
|
|
5347
5991
|
/** @experimental */
|
|
5992
|
+
diagnostics: {
|
|
5993
|
+
/**
|
|
5994
|
+
* Patches configured session diagnostic sources without restarting their producers. Setting a source level to off clears its retained diagnostics and invalidates cursors selecting that source.
|
|
5995
|
+
*
|
|
5996
|
+
* @param params Patch session diagnostic thresholds for explicitly supplied sources.
|
|
5997
|
+
*
|
|
5998
|
+
* @returns Per-source session diagnostics configuration.
|
|
5999
|
+
*/
|
|
6000
|
+
configure: async (params) => connection.sendRequest("session.diagnostics.configure", { sessionId, ...params }),
|
|
6001
|
+
/**
|
|
6002
|
+
* Reads a bounded batch of retained session diagnostics for the selected sources. Records are never consumed and each reader advances independently through its opaque cursor.
|
|
6003
|
+
*
|
|
6004
|
+
* @param params Cursor-based request for session diagnostics. The default limit is 100 (maximum 500); the default waitMs is zero (maximum 30000).
|
|
6005
|
+
*
|
|
6006
|
+
* @returns One cursor-addressed page of retained session diagnostics.
|
|
6007
|
+
*/
|
|
6008
|
+
read: async (params) => connection.sendRequest("session.diagnostics.read", { sessionId, ...params })
|
|
6009
|
+
},
|
|
6010
|
+
/** @experimental */
|
|
6011
|
+
connectors: {
|
|
6012
|
+
/**
|
|
6013
|
+
* Returns feature availability and bounded polling limits for the EXPERIMENTAL session connector API. This method never performs a Connector service request.
|
|
6014
|
+
*
|
|
6015
|
+
* @returns Feature detection and hard polling limits for the EXPERIMENTAL session connector API.
|
|
6016
|
+
*/
|
|
6017
|
+
getCapabilities: async () => connection.sendRequest("session.connectors.getCapabilities", { sessionId }),
|
|
6018
|
+
/**
|
|
6019
|
+
* Returns authoritative session Connector state from current availability, pinned account selection, cached catalog, and live MCP projection without performing a Connector service request.
|
|
6020
|
+
*
|
|
6021
|
+
* @returns Authoritative session connector state. Account IDs are opaque routing identifiers and credentials are never included.
|
|
6022
|
+
*/
|
|
6023
|
+
getStatus: async () => connection.sendRequest("session.connectors.getStatus", { sessionId }),
|
|
6024
|
+
/**
|
|
6025
|
+
* Returns the cached Connector catalog for the pinned opaque account selection, fetching it only when this session has no cached catalog.
|
|
6026
|
+
*
|
|
6027
|
+
* @param params Pins a Connector operation to one host-owned GitHub account through its opaque selection ID. Provider tokens are never accepted.
|
|
6028
|
+
*
|
|
6029
|
+
* @returns Validated Connector catalog snapshot cached by the session.
|
|
6030
|
+
*/
|
|
6031
|
+
list: async (params) => connection.sendRequest("session.connectors.list", { sessionId, ...params }),
|
|
6032
|
+
/**
|
|
6033
|
+
* Refreshes and validates the Connector catalog for the pinned opaque account selection.
|
|
6034
|
+
*
|
|
6035
|
+
* @param params Pins a Connector operation to one host-owned GitHub account through its opaque selection ID. Provider tokens are never accepted.
|
|
6036
|
+
*
|
|
6037
|
+
* @returns Validated Connector catalog snapshot cached by the session.
|
|
6038
|
+
*/
|
|
6039
|
+
refresh: async (params) => connection.sendRequest("session.connectors.refresh", { sessionId, ...params }),
|
|
6040
|
+
/**
|
|
6041
|
+
* 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.
|
|
6042
|
+
*
|
|
6043
|
+
* @param params Selects one Connector and the pinned host-owned account used for its service and MCP authorization.
|
|
6044
|
+
*
|
|
6045
|
+
* @returns Typed result of initiating or continuing a Connector connection.
|
|
6046
|
+
*/
|
|
6047
|
+
connect: async (params) => connection.sendRequest("session.connectors.connect", { sessionId, ...params }),
|
|
6048
|
+
/**
|
|
6049
|
+
* Re-initiates an idempotent Connector connection request without browser or UI effects, with the same typed outcomes as connect.
|
|
6050
|
+
*
|
|
6051
|
+
* @param params Selects one Connector and the pinned host-owned account used for its service and MCP authorization.
|
|
6052
|
+
*
|
|
6053
|
+
* @returns Typed result of initiating or continuing a Connector connection.
|
|
6054
|
+
*/
|
|
6055
|
+
reconnect: async (params) => connection.sendRequest("session.connectors.reconnect", { sessionId, ...params }),
|
|
6056
|
+
/**
|
|
6057
|
+
* Continues a pending Connector connection with caller-supplied attempt, interval, and deadline bounds. The runtime never opens the returned consent URL.
|
|
6058
|
+
*
|
|
6059
|
+
* @param params Explicitly bounded continuation of a pending Connector connection.
|
|
6060
|
+
*
|
|
6061
|
+
* @returns Typed result of initiating or continuing a Connector connection.
|
|
6062
|
+
*/
|
|
6063
|
+
continueConnection: async (params) => connection.sendRequest("session.connectors.continueConnection", { sessionId, ...params }),
|
|
6064
|
+
/**
|
|
6065
|
+
* Disconnects one Connector for the pinned opaque account selection, refreshes the authoritative catalog, and removes its session-owned MCP projection.
|
|
6066
|
+
*
|
|
6067
|
+
* @param params Selects one Connector and the pinned host-owned account used for its service and MCP authorization.
|
|
6068
|
+
*
|
|
6069
|
+
* @returns Authoritative result after disconnect and MCP reconciliation.
|
|
6070
|
+
*/
|
|
6071
|
+
disconnect: async (params) => connection.sendRequest("session.connectors.disconnect", { sessionId, ...params }),
|
|
6072
|
+
/**
|
|
6073
|
+
* Reconciles the authoritative cached or freshly requested Connector catalog into the session Connector MCP projection and returns live status.
|
|
6074
|
+
*
|
|
6075
|
+
* @param params Requests authoritative Connector-to-MCP reconciliation for the pinned account.
|
|
6076
|
+
*
|
|
6077
|
+
* @returns Authoritative session connector state. Account IDs are opaque routing identifiers and credentials are never included.
|
|
6078
|
+
*/
|
|
6079
|
+
reconcile: async (params) => connection.sendRequest("session.connectors.reconcile", { sessionId, ...params })
|
|
6080
|
+
},
|
|
6081
|
+
/** @experimental */
|
|
6082
|
+
managedSettings: {
|
|
6083
|
+
/**
|
|
6084
|
+
* 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.
|
|
6085
|
+
*
|
|
6086
|
+
* @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.
|
|
6087
|
+
*/
|
|
6088
|
+
get: async () => connection.sendRequest("session.managedSettings.get", { sessionId })
|
|
6089
|
+
},
|
|
6090
|
+
/** @experimental */
|
|
5348
6091
|
plugins: {
|
|
5349
6092
|
/**
|
|
5350
|
-
* Lists
|
|
6093
|
+
* Lists globally installed, live, built-in, and enterprise-managed desired plugins using the live session's authoritative account, working directory, and retained managed policy.
|
|
5351
6094
|
*
|
|
5352
6095
|
* @returns Plugins installed for the session, with their enabled state and version metadata.
|
|
5353
6096
|
*/
|
|
5354
6097
|
list: async () => connection.sendRequest("session.plugins.list", { sessionId }),
|
|
6098
|
+
/**
|
|
6099
|
+
* Installs a plugin using the live session's authoritative account, working directory, and retained managed policy.
|
|
6100
|
+
*
|
|
6101
|
+
* @param params Plugin source resolved relative to the session's authoritative working directory.
|
|
6102
|
+
*
|
|
6103
|
+
* @returns Result of installing a plugin.
|
|
6104
|
+
*/
|
|
6105
|
+
install: async (params) => connection.sendRequest("session.plugins.install", { sessionId, ...params }),
|
|
6106
|
+
/**
|
|
6107
|
+
* Uninstalls a plugin when permitted by the live session's retained managed policy.
|
|
6108
|
+
*
|
|
6109
|
+
* @param params Name (or spec) of the plugin to uninstall.
|
|
6110
|
+
*/
|
|
6111
|
+
uninstall: async (params) => connection.sendRequest("session.plugins.uninstall", { sessionId, ...params }),
|
|
6112
|
+
/**
|
|
6113
|
+
* Updates an installed plugin using the live session's authoritative account, working directory, and retained managed policy.
|
|
6114
|
+
*
|
|
6115
|
+
* @param params Name (or spec) of the plugin to update.
|
|
6116
|
+
*
|
|
6117
|
+
* @returns Result of updating a single plugin.
|
|
6118
|
+
*/
|
|
6119
|
+
update: async (params) => connection.sendRequest("session.plugins.update", { sessionId, ...params }),
|
|
6120
|
+
/**
|
|
6121
|
+
* Enables installed plugins when permitted by the live session's retained managed policy.
|
|
6122
|
+
*
|
|
6123
|
+
* @param params Plugin names (or specs) to enable in the session's authoritative working directory.
|
|
6124
|
+
*/
|
|
6125
|
+
enable: async (params) => connection.sendRequest("session.plugins.enable", { sessionId, ...params }),
|
|
6126
|
+
/**
|
|
6127
|
+
* Disables installed plugins when permitted by the live session's retained managed policy.
|
|
6128
|
+
*
|
|
6129
|
+
* @param params Plugin names (or specs) to disable in the session's authoritative working directory.
|
|
6130
|
+
*/
|
|
6131
|
+
disable: async (params) => connection.sendRequest("session.plugins.disable", { sessionId, ...params }),
|
|
6132
|
+
/** @experimental */
|
|
6133
|
+
marketplaces: {
|
|
6134
|
+
/**
|
|
6135
|
+
* Lists registered and enterprise-managed desired marketplaces using the live session's retained policy.
|
|
6136
|
+
*
|
|
6137
|
+
* @returns All registered marketplaces, including built-in defaults.
|
|
6138
|
+
*/
|
|
6139
|
+
list: async () => connection.sendRequest("session.plugins.marketplaces.list", { sessionId }),
|
|
6140
|
+
/**
|
|
6141
|
+
* Adds a marketplace when permitted by the live session's retained managed policy.
|
|
6142
|
+
*
|
|
6143
|
+
* @param params Marketplace source and optional working directory for relative-path resolution.
|
|
6144
|
+
*
|
|
6145
|
+
* @returns Result of registering a new marketplace.
|
|
6146
|
+
*/
|
|
6147
|
+
add: async (params) => connection.sendRequest("session.plugins.marketplaces.add", { sessionId, ...params }),
|
|
6148
|
+
/**
|
|
6149
|
+
* Removes a marketplace when permitted by the live session's retained managed policy.
|
|
6150
|
+
*
|
|
6151
|
+
* @param params Name of the marketplace to remove and an optional force flag.
|
|
6152
|
+
*
|
|
6153
|
+
* @returns Outcome of the remove attempt, including dependent-plugin info when applicable.
|
|
6154
|
+
*/
|
|
6155
|
+
remove: async (params) => connection.sendRequest("session.plugins.marketplaces.remove", { sessionId, ...params }),
|
|
6156
|
+
/**
|
|
6157
|
+
* Browses a marketplace resolved through the live session's working directory and retained managed policy.
|
|
6158
|
+
*
|
|
6159
|
+
* @param params Name of the marketplace whose plugin catalog to fetch.
|
|
6160
|
+
*
|
|
6161
|
+
* @returns Plugins advertised by the marketplace.
|
|
6162
|
+
*/
|
|
6163
|
+
browse: async (params) => connection.sendRequest("session.plugins.marketplaces.browse", { sessionId, ...params }),
|
|
6164
|
+
/**
|
|
6165
|
+
* Refreshes marketplaces resolved through the live session's working directory and retained managed policy.
|
|
6166
|
+
*
|
|
6167
|
+
* @param params Optional marketplace name; omit to refresh all.
|
|
6168
|
+
*
|
|
6169
|
+
* @returns Result of refreshing one or more marketplace catalogs.
|
|
6170
|
+
*/
|
|
6171
|
+
refresh: async (params) => connection.sendRequest("session.plugins.marketplaces.refresh", { sessionId, ...params })
|
|
6172
|
+
},
|
|
5355
6173
|
/**
|
|
5356
6174
|
* 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.
|
|
5357
6175
|
*
|
|
@@ -5376,7 +6194,15 @@ function createSessionRpc(connection, sessionId) {
|
|
|
5376
6194
|
*
|
|
5377
6195
|
* @returns The selectable model entries synthesized for the models added by this call.
|
|
5378
6196
|
*/
|
|
5379
|
-
add: async (params) => connection.sendRequest("session.provider.add", { sessionId, ...params })
|
|
6197
|
+
add: async (params) => connection.sendRequest("session.provider.add", { sessionId, ...params }),
|
|
6198
|
+
/**
|
|
6199
|
+
* 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.
|
|
6200
|
+
*
|
|
6201
|
+
* @param params Authoritative BYOK provider and model registry snapshot to apply atomically to the session.
|
|
6202
|
+
*
|
|
6203
|
+
* @returns The selectable model entries and selection ids synthesized for the synchronized BYOK models.
|
|
6204
|
+
*/
|
|
6205
|
+
sync: async (params) => connection.sendRequest("session.provider.sync", { sessionId, ...params })
|
|
5380
6206
|
},
|
|
5381
6207
|
/** @experimental */
|
|
5382
6208
|
options: {
|
|
@@ -5702,9 +6528,9 @@ function createSessionRpc(connection, sessionId) {
|
|
|
5702
6528
|
*/
|
|
5703
6529
|
setRequired: async (params) => connection.sendRequest("session.permissions.setRequired", { sessionId, ...params }),
|
|
5704
6530
|
/**
|
|
5705
|
-
* Clears session-scoped tool
|
|
6531
|
+
* Clears session-scoped tool approvals and, for full resets, exact session-approved paths.
|
|
5706
6532
|
*
|
|
5707
|
-
* @param params Clears session-scoped tool
|
|
6533
|
+
* @param params Clears session-scoped tool approvals and optionally clears location-scoped approvals and exact session-approved paths.
|
|
5708
6534
|
*
|
|
5709
6535
|
* @returns Indicates whether the operation succeeded.
|
|
5710
6536
|
*/
|
|
@@ -5720,9 +6546,9 @@ function createSessionRpc(connection, sessionId) {
|
|
|
5720
6546
|
/** @experimental */
|
|
5721
6547
|
paths: {
|
|
5722
6548
|
/**
|
|
5723
|
-
* Returns the session's
|
|
6549
|
+
* Returns the session's recursive directory grants, exact session-approved paths, and primary working directory.
|
|
5724
6550
|
*
|
|
5725
|
-
* @returns Snapshot of the session's
|
|
6551
|
+
* @returns Snapshot of the session's recursive directory grants, exact session-approved paths, and primary working directory.
|
|
5726
6552
|
*/
|
|
5727
6553
|
list: async () => connection.sendRequest("session.permissions.paths.list", { sessionId }),
|
|
5728
6554
|
/**
|
|
@@ -6060,6 +6886,22 @@ function createSessionRpc(connection, sessionId) {
|
|
|
6060
6886
|
* @returns Result of editing a queued message.
|
|
6061
6887
|
*/
|
|
6062
6888
|
updateText: async (params) => connection.sendRequest("session.queue.updateText", { sessionId, ...params }),
|
|
6889
|
+
/**
|
|
6890
|
+
* Atomically withdraws an unchanged user message of a local session: from the queued or steering lane while unconsumed, or from the running turn it started while the model has not answered it and nothing the user sent after it is pending. Withdrawing from the running turn interrupts that turn and removes its events from history. A client retaining the original draft may restore it only when removed is true.
|
|
6891
|
+
*
|
|
6892
|
+
* @param params Conditional withdrawal of a single user message, from its queue or from the running turn it started.
|
|
6893
|
+
*
|
|
6894
|
+
* @returns Result of withdrawing a user message.
|
|
6895
|
+
*/
|
|
6896
|
+
withdrawMessage: async (params) => connection.sendRequest("session.queue.withdrawMessage", { sessionId, ...params }),
|
|
6897
|
+
/**
|
|
6898
|
+
* Atomically appends text and attachments to an unchanged, unconsumed local steering message. Returns updated=false if delivery or withdrawal already claimed the message.
|
|
6899
|
+
*
|
|
6900
|
+
* @param params Append to one pending steering message without changing its identity or delivery position.
|
|
6901
|
+
*
|
|
6902
|
+
* @returns Result of editing a queued message.
|
|
6903
|
+
*/
|
|
6904
|
+
appendSteering: async (params) => connection.sendRequest("session.queue.appendSteering", { sessionId, ...params }),
|
|
6063
6905
|
/**
|
|
6064
6906
|
* Duplicates an addressable queued item immediately after its source.
|
|
6065
6907
|
*
|
|
@@ -6289,29 +7131,29 @@ function createInternalSessionRpc(connection, sessionId) {
|
|
|
6289
7131
|
}
|
|
6290
7132
|
},
|
|
6291
7133
|
/** @experimental */
|
|
6292
|
-
|
|
7134
|
+
workflow: {
|
|
6293
7135
|
/**
|
|
6294
|
-
* Internal tool-originated
|
|
7136
|
+
* Internal tool-originated dynamic workflow invocation.
|
|
6295
7137
|
*
|
|
6296
|
-
* @param params Internal parameters for invoking a registered
|
|
7138
|
+
* @param params Internal parameters for invoking a registered workflow from a tool.
|
|
6297
7139
|
*
|
|
6298
|
-
* @returns Complete current or terminal
|
|
7140
|
+
* @returns Complete current or terminal workflow run envelope.
|
|
6299
7141
|
*/
|
|
6300
|
-
runFromTool: async (params) => connection.sendRequest("session.
|
|
7142
|
+
runFromTool: async (params) => connection.sendRequest("session.workflow.runFromTool", { sessionId, ...params }),
|
|
6301
7143
|
/**
|
|
6302
|
-
* Internal tool-originated
|
|
7144
|
+
* Internal tool-originated dynamic workflow resume.
|
|
6303
7145
|
*
|
|
6304
|
-
* @param params Internal parameters for resuming a
|
|
7146
|
+
* @param params Internal parameters for resuming a workflow run from a tool.
|
|
6305
7147
|
*
|
|
6306
|
-
* @returns Resolved persisted
|
|
7148
|
+
* @returns Resolved persisted workflow identity and resumed run envelope.
|
|
6307
7149
|
*/
|
|
6308
|
-
resumeFromTool: async (params) => connection.sendRequest("session.
|
|
7150
|
+
resumeFromTool: async (params) => connection.sendRequest("session.workflow.resumeFromTool", { sessionId, ...params }),
|
|
6309
7151
|
/**
|
|
6310
|
-
* Atomically pauses an owned
|
|
7152
|
+
* Atomically pauses an owned dynamic workflow attempt at a durable checkpoint.
|
|
6311
7153
|
*
|
|
6312
7154
|
* @param params Parameters for an owned durable pause checkpoint.
|
|
6313
7155
|
*/
|
|
6314
|
-
pauseAtCheckpoint: async (params) => connection.sendRequest("session.
|
|
7156
|
+
pauseAtCheckpoint: async (params) => connection.sendRequest("session.workflow.pauseAtCheckpoint", { sessionId, ...params })
|
|
6315
7157
|
},
|
|
6316
7158
|
/** @experimental */
|
|
6317
7159
|
model: {
|
|
@@ -6356,6 +7198,23 @@ function createInternalSessionRpc(connection, sessionId) {
|
|
|
6356
7198
|
unregisterExternalClient: async (params) => connection.sendRequest("session.mcp.unregisterExternalClient", { sessionId, ...params })
|
|
6357
7199
|
},
|
|
6358
7200
|
/** @experimental */
|
|
7201
|
+
connectors: {
|
|
7202
|
+
/**
|
|
7203
|
+
* Reconciles the authoritative Connector catalog into the session MCP projection during startup with a bounded deadline and fail-closed cleanup.
|
|
7204
|
+
*
|
|
7205
|
+
* @param params Pins a Connector operation to one host-owned GitHub account through its opaque selection ID. Provider tokens are never accepted.
|
|
7206
|
+
*
|
|
7207
|
+
* @returns Authoritative session connector state. Account IDs are opaque routing identifiers and credentials are never included.
|
|
7208
|
+
*/
|
|
7209
|
+
reconcileForStartup: async (params) => connection.sendRequest("session.connectors.reconcileForStartup", { sessionId, ...params }),
|
|
7210
|
+
/**
|
|
7211
|
+
* Removes the runtime-owned Connector MCP projection without changing service-side connections.
|
|
7212
|
+
*
|
|
7213
|
+
* @returns Authoritative session connector state. Account IDs are opaque routing identifiers and credentials are never included.
|
|
7214
|
+
*/
|
|
7215
|
+
withdrawProjection: async () => connection.sendRequest("session.connectors.withdrawProjection", { sessionId })
|
|
7216
|
+
},
|
|
7217
|
+
/** @experimental */
|
|
6359
7218
|
commands: {
|
|
6360
7219
|
/**
|
|
6361
7220
|
* Finalizes persistence associated with a client-applied slash-command effect.
|
|
@@ -6499,14 +7358,14 @@ function registerClientSessionApiHandlers(connection, getHandlers) {
|
|
|
6499
7358
|
if (!handler) throw new Error(`No providerToken handler registered for session: ${params.sessionId}`);
|
|
6500
7359
|
return handler.getToken(params);
|
|
6501
7360
|
});
|
|
6502
|
-
connection.onRequest("
|
|
6503
|
-
const handler = getHandlers(params.sessionId).
|
|
6504
|
-
if (!handler) throw new Error(`No
|
|
7361
|
+
connection.onRequest("workflow.execute", async (params) => {
|
|
7362
|
+
const handler = getHandlers(params.sessionId).workflow;
|
|
7363
|
+
if (!handler) throw new Error(`No workflow handler registered for session: ${params.sessionId}`);
|
|
6505
7364
|
return handler.execute(params);
|
|
6506
7365
|
});
|
|
6507
|
-
connection.onRequest("
|
|
6508
|
-
const handler = getHandlers(params.sessionId).
|
|
6509
|
-
if (!handler) throw new Error(`No
|
|
7366
|
+
connection.onRequest("workflow.abort", async (params) => {
|
|
7367
|
+
const handler = getHandlers(params.sessionId).workflow;
|
|
7368
|
+
if (!handler) throw new Error(`No workflow handler registered for session: ${params.sessionId}`);
|
|
6510
7369
|
return handler.abort(params);
|
|
6511
7370
|
});
|
|
6512
7371
|
connection.onRequest("tasks.cancel", async (params) => {
|
|
@@ -6621,19 +7480,24 @@ function registerClientGlobalApiHandlers(connection, handlers) {
|
|
|
6621
7480
|
if (!handler) throw new Error("No gitHubToken client-global handler registered");
|
|
6622
7481
|
return handler.getToken(params);
|
|
6623
7482
|
});
|
|
7483
|
+
connection.onRequest("installations.confirm", async (params) => {
|
|
7484
|
+
const handler = handlers.installations;
|
|
7485
|
+
if (!handler) throw new Error("No installations client-global handler registered");
|
|
7486
|
+
return handler.confirm(params);
|
|
7487
|
+
});
|
|
6624
7488
|
}
|
|
6625
7489
|
|
|
6626
|
-
//
|
|
7490
|
+
// src/sdk/nodejs/dist/sdkProtocolVersion.js
|
|
6627
7491
|
var SDK_PROTOCOL_VERSION = 3;
|
|
6628
7492
|
function getSdkProtocolVersion() {
|
|
6629
7493
|
return SDK_PROTOCOL_VERSION;
|
|
6630
7494
|
}
|
|
6631
7495
|
|
|
6632
|
-
//
|
|
7496
|
+
// src/sdk/nodejs/dist/session.js
|
|
6633
7497
|
var import_node = __toESM(require_node(), 1);
|
|
6634
7498
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
6635
7499
|
|
|
6636
|
-
//
|
|
7500
|
+
// src/sdk/nodejs/dist/canvas.js
|
|
6637
7501
|
var CanvasError = class _CanvasError extends Error {
|
|
6638
7502
|
constructor(code, message) {
|
|
6639
7503
|
super(message);
|
|
@@ -6680,7 +7544,7 @@ function createCanvas(options) {
|
|
|
6680
7544
|
return new Canvas(options);
|
|
6681
7545
|
}
|
|
6682
7546
|
|
|
6683
|
-
//
|
|
7547
|
+
// src/sdk/nodejs/dist/telemetry.js
|
|
6684
7548
|
async function getTraceContext(provider) {
|
|
6685
7549
|
if (!provider) return {};
|
|
6686
7550
|
try {
|
|
@@ -6690,7 +7554,18 @@ async function getTraceContext(provider) {
|
|
|
6690
7554
|
}
|
|
6691
7555
|
}
|
|
6692
7556
|
|
|
6693
|
-
//
|
|
7557
|
+
// src/sdk/nodejs/dist/schema.js
|
|
7558
|
+
function isZodSchema(value) {
|
|
7559
|
+
return typeof value === "object" && value !== null && "toJSONSchema" in value && typeof value.toJSONSchema === "function";
|
|
7560
|
+
}
|
|
7561
|
+
function toJsonSchema(schema) {
|
|
7562
|
+
return isZodSchema(schema) ? schema.toJSONSchema() : schema;
|
|
7563
|
+
}
|
|
7564
|
+
function isResponseSchema(value) {
|
|
7565
|
+
return isZodSchema(value) && "parse" in value && typeof value.parse === "function";
|
|
7566
|
+
}
|
|
7567
|
+
|
|
7568
|
+
// src/sdk/nodejs/dist/sessionFsProvider.js
|
|
6694
7569
|
var SessionFsSqliteTransactionFailure = class extends Error {
|
|
6695
7570
|
/** Failure classification reported to the runtime. */
|
|
6696
7571
|
errorClass;
|
|
@@ -6861,9 +7736,10 @@ function toSqliteTransactionError(err) {
|
|
|
6861
7736
|
};
|
|
6862
7737
|
}
|
|
6863
7738
|
|
|
6864
|
-
//
|
|
7739
|
+
// src/sdk/nodejs/dist/copilotRequestHandler.js
|
|
6865
7740
|
var sharedTextDecoder = new TextDecoder("utf-8", { fatal: false });
|
|
6866
7741
|
var sharedTextEncoder = new TextEncoder();
|
|
7742
|
+
var HTTP_RESPONSE_READ_AHEAD_BYTES = 32 * 1024;
|
|
6867
7743
|
var kBridge = /* @__PURE__ */ Symbol("copilotWebSocketResponseBridge");
|
|
6868
7744
|
var kCompletion = /* @__PURE__ */ Symbol("copilotWebSocketCompletion");
|
|
6869
7745
|
var kOpen = /* @__PURE__ */ Symbol("copilotWebSocketOpen");
|
|
@@ -7102,7 +7978,9 @@ function createCopilotRequestAdapter(handler, getServerRpc) {
|
|
|
7102
7978
|
const message = err instanceof Error ? err.message : String(err);
|
|
7103
7979
|
await finalize(exchange, 502, message);
|
|
7104
7980
|
} finally {
|
|
7105
|
-
pending.
|
|
7981
|
+
if (pending.get(exchange.requestId) === exchange) {
|
|
7982
|
+
pending.delete(exchange.requestId);
|
|
7983
|
+
}
|
|
7106
7984
|
}
|
|
7107
7985
|
}
|
|
7108
7986
|
return {
|
|
@@ -7115,6 +7993,13 @@ function createCopilotRequestAdapter(handler, getServerRpc) {
|
|
|
7115
7993
|
async httpRequestChunk(params) {
|
|
7116
7994
|
routeChunk(getOrCreate(params.requestId), params);
|
|
7117
7995
|
return {};
|
|
7996
|
+
},
|
|
7997
|
+
cancelPending() {
|
|
7998
|
+
const exchanges = [...pending.values()];
|
|
7999
|
+
pending.clear();
|
|
8000
|
+
for (const exchange of exchanges) {
|
|
8001
|
+
exchange.pushCancel("RPC connection closed");
|
|
8002
|
+
}
|
|
7118
8003
|
}
|
|
7119
8004
|
};
|
|
7120
8005
|
}
|
|
@@ -7363,32 +8248,158 @@ async function drainAsync(stream) {
|
|
|
7363
8248
|
return out;
|
|
7364
8249
|
}
|
|
7365
8250
|
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();
|
|
8251
|
+
const reader = response.body ? new HttpResponseReader(response.body, exchange.signal) : void 0;
|
|
7377
8252
|
try {
|
|
7378
|
-
|
|
7379
|
-
|
|
7380
|
-
|
|
7381
|
-
|
|
7382
|
-
|
|
7383
|
-
|
|
7384
|
-
|
|
8253
|
+
await exchange.startResponse({
|
|
8254
|
+
status: response.status,
|
|
8255
|
+
statusText: response.statusText || void 0,
|
|
8256
|
+
headers: headersToMultiMap(response.headers)
|
|
8257
|
+
});
|
|
8258
|
+
if (reader) {
|
|
8259
|
+
for (; ; ) {
|
|
8260
|
+
const chunk = await reader.nextChunk();
|
|
8261
|
+
if (!chunk) {
|
|
8262
|
+
break;
|
|
8263
|
+
}
|
|
8264
|
+
await exchange.writeResponse(chunk);
|
|
7385
8265
|
}
|
|
7386
8266
|
}
|
|
7387
8267
|
await exchange.endResponse();
|
|
7388
8268
|
} finally {
|
|
7389
|
-
reader
|
|
8269
|
+
await reader?.dispose();
|
|
7390
8270
|
}
|
|
7391
8271
|
}
|
|
8272
|
+
var HttpResponseReader = class {
|
|
8273
|
+
#reader;
|
|
8274
|
+
#signal;
|
|
8275
|
+
#frames = [];
|
|
8276
|
+
#pump;
|
|
8277
|
+
#onAbort;
|
|
8278
|
+
#queued = 0;
|
|
8279
|
+
#done = false;
|
|
8280
|
+
#cancelled = false;
|
|
8281
|
+
#hasError = false;
|
|
8282
|
+
#error;
|
|
8283
|
+
#dataWaker;
|
|
8284
|
+
#spaceWaker;
|
|
8285
|
+
#cancelPromise;
|
|
8286
|
+
constructor(body, signal) {
|
|
8287
|
+
this.#reader = body.getReader();
|
|
8288
|
+
this.#signal = signal;
|
|
8289
|
+
this.#onAbort = () => {
|
|
8290
|
+
void this.cancel(signal.reason);
|
|
8291
|
+
};
|
|
8292
|
+
signal.addEventListener("abort", this.#onAbort, { once: true });
|
|
8293
|
+
this.#pump = this.#pumpSource();
|
|
8294
|
+
if (signal.aborted) {
|
|
8295
|
+
this.#onAbort();
|
|
8296
|
+
}
|
|
8297
|
+
}
|
|
8298
|
+
async nextChunk() {
|
|
8299
|
+
while (this.#frames.length === 0 && !this.#done && !this.#hasError) {
|
|
8300
|
+
await new Promise((resolve3) => {
|
|
8301
|
+
this.#dataWaker = resolve3;
|
|
8302
|
+
});
|
|
8303
|
+
}
|
|
8304
|
+
if (this.#frames.length > 0) {
|
|
8305
|
+
const chunk = this.#takeQueued();
|
|
8306
|
+
this.#wakeSpace();
|
|
8307
|
+
return chunk;
|
|
8308
|
+
}
|
|
8309
|
+
if (this.#hasError) {
|
|
8310
|
+
this.#hasError = false;
|
|
8311
|
+
throw this.#error;
|
|
8312
|
+
}
|
|
8313
|
+
return void 0;
|
|
8314
|
+
}
|
|
8315
|
+
#takeQueued() {
|
|
8316
|
+
const frames = this.#frames;
|
|
8317
|
+
const total = this.#queued;
|
|
8318
|
+
this.#queued = 0;
|
|
8319
|
+
if (frames.length === 1) {
|
|
8320
|
+
return frames.pop();
|
|
8321
|
+
}
|
|
8322
|
+
const chunk = new Uint8Array(total);
|
|
8323
|
+
let offset = 0;
|
|
8324
|
+
for (const frame of frames) {
|
|
8325
|
+
chunk.set(frame, offset);
|
|
8326
|
+
offset += frame.byteLength;
|
|
8327
|
+
}
|
|
8328
|
+
frames.length = 0;
|
|
8329
|
+
return chunk;
|
|
8330
|
+
}
|
|
8331
|
+
async dispose() {
|
|
8332
|
+
this.#signal.removeEventListener("abort", this.#onAbort);
|
|
8333
|
+
if (!this.#done) {
|
|
8334
|
+
await this.cancel();
|
|
8335
|
+
} else if (this.#cancelPromise) {
|
|
8336
|
+
await this.#cancelPromise;
|
|
8337
|
+
}
|
|
8338
|
+
await this.#pump;
|
|
8339
|
+
}
|
|
8340
|
+
cancel(reason) {
|
|
8341
|
+
if (this.#done) {
|
|
8342
|
+
return Promise.resolve();
|
|
8343
|
+
}
|
|
8344
|
+
if (!this.#cancelPromise) {
|
|
8345
|
+
this.#cancelled = true;
|
|
8346
|
+
this.#done = true;
|
|
8347
|
+
this.#hasError = true;
|
|
8348
|
+
this.#error = reason instanceof Error ? reason : new Error("HTTP response body cancelled.");
|
|
8349
|
+
this.#frames.length = 0;
|
|
8350
|
+
this.#queued = 0;
|
|
8351
|
+
this.#wakeData();
|
|
8352
|
+
this.#wakeSpace();
|
|
8353
|
+
this.#cancelPromise = this.#reader.cancel(reason).catch(() => void 0);
|
|
8354
|
+
}
|
|
8355
|
+
return this.#cancelPromise;
|
|
8356
|
+
}
|
|
8357
|
+
async #pumpSource() {
|
|
8358
|
+
try {
|
|
8359
|
+
while (!this.#cancelled) {
|
|
8360
|
+
while (this.#queued >= HTTP_RESPONSE_READ_AHEAD_BYTES && !this.#cancelled) {
|
|
8361
|
+
await new Promise((resolve3) => {
|
|
8362
|
+
this.#spaceWaker = resolve3;
|
|
8363
|
+
});
|
|
8364
|
+
}
|
|
8365
|
+
if (this.#cancelled) {
|
|
8366
|
+
return;
|
|
8367
|
+
}
|
|
8368
|
+
const { value, done } = await this.#reader.read();
|
|
8369
|
+
if (done) {
|
|
8370
|
+
return;
|
|
8371
|
+
}
|
|
8372
|
+
if (value.byteLength > 0) {
|
|
8373
|
+
this.#frames.push(value);
|
|
8374
|
+
this.#queued += value.byteLength;
|
|
8375
|
+
this.#wakeData();
|
|
8376
|
+
continue;
|
|
8377
|
+
}
|
|
8378
|
+
await new Promise((resolve3) => setImmediate(resolve3));
|
|
8379
|
+
}
|
|
8380
|
+
} catch (error) {
|
|
8381
|
+
if (!this.#cancelled) {
|
|
8382
|
+
this.#hasError = true;
|
|
8383
|
+
this.#error = error;
|
|
8384
|
+
}
|
|
8385
|
+
} finally {
|
|
8386
|
+
this.#done = true;
|
|
8387
|
+
this.#wakeData();
|
|
8388
|
+
this.#wakeSpace();
|
|
8389
|
+
this.#reader.releaseLock();
|
|
8390
|
+
}
|
|
8391
|
+
}
|
|
8392
|
+
#wakeData() {
|
|
8393
|
+
const waker = this.#dataWaker;
|
|
8394
|
+
this.#dataWaker = void 0;
|
|
8395
|
+
waker?.();
|
|
8396
|
+
}
|
|
8397
|
+
#wakeSpace() {
|
|
8398
|
+
const waker = this.#spaceWaker;
|
|
8399
|
+
this.#spaceWaker = void 0;
|
|
8400
|
+
waker?.();
|
|
8401
|
+
}
|
|
8402
|
+
};
|
|
7392
8403
|
function headersToMultiMap(headers) {
|
|
7393
8404
|
const out = {};
|
|
7394
8405
|
headers.forEach((value, name) => {
|
|
@@ -7466,7 +8477,7 @@ var CopilotWebSocketResponseBridge = class {
|
|
|
7466
8477
|
}
|
|
7467
8478
|
};
|
|
7468
8479
|
|
|
7469
|
-
//
|
|
8480
|
+
// src/sdk/nodejs/dist/types.js
|
|
7470
8481
|
function isAttributedPermissionResult(result) {
|
|
7471
8482
|
return result.kind === "attributed";
|
|
7472
8483
|
}
|
|
@@ -7474,18 +8485,18 @@ var defaultJoinSessionPermissionHandler = () => ({
|
|
|
7474
8485
|
kind: "no-result"
|
|
7475
8486
|
});
|
|
7476
8487
|
|
|
7477
|
-
//
|
|
7478
|
-
var
|
|
8488
|
+
// src/sdk/nodejs/dist/workflow.js
|
|
8489
|
+
var WORKFLOW_TERMINAL_STATUSES = /* @__PURE__ */ new Set([
|
|
7479
8490
|
"completed",
|
|
7480
8491
|
"halted",
|
|
7481
8492
|
"paused",
|
|
7482
8493
|
"cancelled",
|
|
7483
8494
|
"error"
|
|
7484
8495
|
]);
|
|
7485
|
-
function
|
|
7486
|
-
return
|
|
8496
|
+
function isWorkflowRunTerminal(status) {
|
|
8497
|
+
return WORKFLOW_TERMINAL_STATUSES.has(status);
|
|
7487
8498
|
}
|
|
7488
|
-
var
|
|
8499
|
+
var WORKFLOW_AGENT_OPTION_KEYS = [
|
|
7489
8500
|
"label",
|
|
7490
8501
|
"schema",
|
|
7491
8502
|
"model",
|
|
@@ -7493,16 +8504,16 @@ var FACTORY_AGENT_OPTION_KEYS = [
|
|
|
7493
8504
|
"contextTier",
|
|
7494
8505
|
"agent"
|
|
7495
8506
|
];
|
|
7496
|
-
var
|
|
8507
|
+
var WorkflowResumeError = class extends Error {
|
|
7497
8508
|
constructor(code, message) {
|
|
7498
8509
|
super(message);
|
|
7499
8510
|
this.code = code;
|
|
7500
|
-
this.name = "
|
|
8511
|
+
this.name = "WorkflowResumeError";
|
|
7501
8512
|
}
|
|
7502
8513
|
code;
|
|
7503
8514
|
};
|
|
7504
|
-
var
|
|
7505
|
-
var
|
|
8515
|
+
var workflowHandles = /* @__PURE__ */ new WeakMap();
|
|
8516
|
+
var MAX_WORKFLOW_TIMEOUT_SECONDS = 2147483647e-3;
|
|
7506
8517
|
var NANO_AIU_PER_AIU = 1e9;
|
|
7507
8518
|
function deepFreeze(value) {
|
|
7508
8519
|
if (value !== null && typeof value === "object" && !Object.isFrozen(value)) {
|
|
@@ -7521,24 +8532,24 @@ function validateLimits(meta) {
|
|
|
7521
8532
|
for (const field of ["maxConcurrentSubagents", "maxTotalSubagents"]) {
|
|
7522
8533
|
const value = limits[field];
|
|
7523
8534
|
if (value !== void 0 && (!Number.isInteger(value) || value <= 0)) {
|
|
7524
|
-
throw new Error(`
|
|
8535
|
+
throw new Error(`Workflow limit "${field}" must be a positive integer`);
|
|
7525
8536
|
}
|
|
7526
8537
|
}
|
|
7527
8538
|
if (limits.timeoutSeconds !== void 0 && (!Number.isFinite(limits.timeoutSeconds) || limits.timeoutSeconds <= 0)) {
|
|
7528
8539
|
throw new Error(
|
|
7529
|
-
'
|
|
8540
|
+
'Workflow limit "timeoutSeconds" must be a positive, finite number of seconds'
|
|
7530
8541
|
);
|
|
7531
8542
|
}
|
|
7532
|
-
if (limits.timeoutSeconds !== void 0 && limits.timeoutSeconds >
|
|
8543
|
+
if (limits.timeoutSeconds !== void 0 && limits.timeoutSeconds > MAX_WORKFLOW_TIMEOUT_SECONDS) {
|
|
7533
8544
|
throw new Error(
|
|
7534
|
-
`
|
|
8545
|
+
`Workflow limit "timeoutSeconds" must not exceed ${MAX_WORKFLOW_TIMEOUT_SECONDS} seconds`
|
|
7535
8546
|
);
|
|
7536
8547
|
}
|
|
7537
8548
|
if (limits.maxAiCredits !== void 0) {
|
|
7538
8549
|
const maxNanoAiu = Math.round(limits.maxAiCredits * NANO_AIU_PER_AIU);
|
|
7539
8550
|
if (!Number.isFinite(limits.maxAiCredits) || limits.maxAiCredits <= 0 || !Number.isSafeInteger(maxNanoAiu) || maxNanoAiu < 1) {
|
|
7540
8551
|
throw new Error(
|
|
7541
|
-
'
|
|
8552
|
+
'Workflow limit "maxAiCredits" must be a positive, finite number that rounds to a safe positive integer nano-AIU ceiling'
|
|
7542
8553
|
);
|
|
7543
8554
|
}
|
|
7544
8555
|
}
|
|
@@ -7547,15 +8558,15 @@ function validatePhases(meta) {
|
|
|
7547
8558
|
const titles = /* @__PURE__ */ new Set();
|
|
7548
8559
|
for (const phase of meta.phases) {
|
|
7549
8560
|
if (phase.title.trim().length === 0) {
|
|
7550
|
-
throw new Error("
|
|
8561
|
+
throw new Error("Workflow phase titles must not be empty");
|
|
7551
8562
|
}
|
|
7552
8563
|
if (titles.has(phase.title)) {
|
|
7553
|
-
throw new Error(`
|
|
8564
|
+
throw new Error(`Workflow phase title "${phase.title}" is declared more than once`);
|
|
7554
8565
|
}
|
|
7555
8566
|
titles.add(phase.title);
|
|
7556
8567
|
}
|
|
7557
8568
|
}
|
|
7558
|
-
function
|
|
8569
|
+
function defineWorkflow(definition) {
|
|
7559
8570
|
const meta = deepFreeze(structuredClone(definition.meta));
|
|
7560
8571
|
validateLimits(meta);
|
|
7561
8572
|
validatePhases(meta);
|
|
@@ -7564,38 +8575,38 @@ function defineFactory(definition) {
|
|
|
7564
8575
|
run: definition.run
|
|
7565
8576
|
};
|
|
7566
8577
|
const handle = Object.freeze({ meta });
|
|
7567
|
-
|
|
8578
|
+
workflowHandles.set(handle, stored);
|
|
7568
8579
|
return handle;
|
|
7569
8580
|
}
|
|
7570
|
-
function
|
|
7571
|
-
const definition =
|
|
8581
|
+
function getWorkflowDefinition(handle) {
|
|
8582
|
+
const definition = workflowHandles.get(handle);
|
|
7572
8583
|
if (!definition) {
|
|
7573
|
-
throw new Error("Invalid
|
|
8584
|
+
throw new Error("Invalid workflow handle");
|
|
7574
8585
|
}
|
|
7575
8586
|
return definition;
|
|
7576
8587
|
}
|
|
7577
8588
|
|
|
7578
|
-
//
|
|
7579
|
-
function
|
|
7580
|
-
return value === "not_found" || value === "non_resumable" || value === "already_active" || value === "
|
|
8589
|
+
// src/sdk/nodejs/dist/session.js
|
|
8590
|
+
function isWorkflowResumeErrorCode(value) {
|
|
8591
|
+
return value === "not_found" || value === "non_resumable" || value === "workflow_run_not_resumable" || value === "already_active" || value === "workflow_already_running" || value === "workflow_limits_invalid" || value === "workflow_session_disposed" || value === "workflow_storage_unavailable" || value === "workflow_storage_corrupt";
|
|
7581
8592
|
}
|
|
7582
|
-
function
|
|
8593
|
+
function copyDefinedWorkflowAgentOption(source, target, key) {
|
|
7583
8594
|
const value = source[key];
|
|
7584
8595
|
if (value !== void 0) {
|
|
7585
8596
|
target[key] = value;
|
|
7586
8597
|
}
|
|
7587
8598
|
}
|
|
7588
|
-
var
|
|
7589
|
-
function
|
|
7590
|
-
if (
|
|
8599
|
+
var workflowExecutionStore = new AsyncLocalStorage();
|
|
8600
|
+
function throwIfWorkflowExecutionIsActive() {
|
|
8601
|
+
if (workflowExecutionStore.getStore()?.active) {
|
|
7591
8602
|
throw new Error(
|
|
7592
|
-
"
|
|
8603
|
+
"workflow.run, workflow.resume, and workflow.pause are not allowed while a workflow body is running on this call path."
|
|
7593
8604
|
);
|
|
7594
8605
|
}
|
|
7595
8606
|
}
|
|
7596
|
-
function
|
|
7597
|
-
const current =
|
|
7598
|
-
return
|
|
8607
|
+
function runInWorkflowHelperScope(helperScope, callback) {
|
|
8608
|
+
const current = workflowExecutionStore.getStore();
|
|
8609
|
+
return workflowExecutionStore.run({ active: current?.active ?? false, helperScope }, callback);
|
|
7599
8610
|
}
|
|
7600
8611
|
function deserializeHookInput(raw) {
|
|
7601
8612
|
if (!raw || typeof raw !== "object" || typeof raw.timestamp !== "number") {
|
|
@@ -7619,20 +8630,20 @@ function isOpenCanvasInstance(value) {
|
|
|
7619
8630
|
}
|
|
7620
8631
|
var FACTORY_LOG_FLUSH_DELAY_MS = 10;
|
|
7621
8632
|
var MAX_FACTORY_FANOUT_ITEMS = 4096;
|
|
7622
|
-
function
|
|
8633
|
+
function assertWorkflowFanoutSize(kind, size) {
|
|
7623
8634
|
if (size > MAX_FACTORY_FANOUT_ITEMS) {
|
|
7624
8635
|
throw new Error(
|
|
7625
8636
|
`${kind}() accepts at most ${MAX_FACTORY_FANOUT_ITEMS} items; got ${size}.`
|
|
7626
8637
|
);
|
|
7627
8638
|
}
|
|
7628
8639
|
}
|
|
7629
|
-
async function
|
|
8640
|
+
async function runWorkflowParallel(thunks) {
|
|
7630
8641
|
if (!Array.isArray(thunks)) {
|
|
7631
8642
|
throw new Error(
|
|
7632
8643
|
"parallel() expects an array of functions, not promises. Wrap each call: () => agent(...)"
|
|
7633
8644
|
);
|
|
7634
8645
|
}
|
|
7635
|
-
|
|
8646
|
+
assertWorkflowFanoutSize("parallel", thunks.length);
|
|
7636
8647
|
if (thunks.some((thunk) => typeof thunk !== "function")) {
|
|
7637
8648
|
throw new Error(
|
|
7638
8649
|
"parallel() expects an array of functions, not promises. Wrap each call: () => agent(...)"
|
|
@@ -7640,8 +8651,8 @@ async function runFactoryParallel(thunks) {
|
|
|
7640
8651
|
}
|
|
7641
8652
|
return Promise.all(
|
|
7642
8653
|
thunks.map(
|
|
7643
|
-
(thunk) => Promise.resolve().then(() =>
|
|
7644
|
-
if (
|
|
8654
|
+
(thunk) => Promise.resolve().then(() => runInWorkflowHelperScope("parallel", thunk)).catch((error) => {
|
|
8655
|
+
if (isWorkflowFatalError(error)) {
|
|
7645
8656
|
throw error;
|
|
7646
8657
|
}
|
|
7647
8658
|
return null;
|
|
@@ -7649,22 +8660,22 @@ async function runFactoryParallel(thunks) {
|
|
|
7649
8660
|
)
|
|
7650
8661
|
);
|
|
7651
8662
|
}
|
|
7652
|
-
async function
|
|
8663
|
+
async function runWorkflowPipeline(items, ...stages) {
|
|
7653
8664
|
if (!Array.isArray(items)) {
|
|
7654
8665
|
throw new Error("pipeline(items, ...stages): items must be an array");
|
|
7655
8666
|
}
|
|
7656
|
-
|
|
8667
|
+
assertWorkflowFanoutSize("pipeline", items.length);
|
|
7657
8668
|
return Promise.all(
|
|
7658
8669
|
items.map(async (item, index) => {
|
|
7659
8670
|
let previous = item;
|
|
7660
8671
|
for (const stage of stages) {
|
|
7661
8672
|
try {
|
|
7662
|
-
previous = await
|
|
8673
|
+
previous = await runInWorkflowHelperScope(
|
|
7663
8674
|
"pipeline",
|
|
7664
8675
|
() => stage(previous, item, index)
|
|
7665
8676
|
);
|
|
7666
8677
|
} catch (error) {
|
|
7667
|
-
if (
|
|
8678
|
+
if (isWorkflowFatalError(error)) {
|
|
7668
8679
|
throw error;
|
|
7669
8680
|
}
|
|
7670
8681
|
return null;
|
|
@@ -7674,7 +8685,7 @@ async function runFactoryPipeline(items, ...stages) {
|
|
|
7674
8685
|
})
|
|
7675
8686
|
);
|
|
7676
8687
|
}
|
|
7677
|
-
var
|
|
8688
|
+
var WorkflowProgressBuffer = class {
|
|
7678
8689
|
constructor(send) {
|
|
7679
8690
|
this.send = send;
|
|
7680
8691
|
}
|
|
@@ -7688,7 +8699,7 @@ var FactoryProgressBuffer = class {
|
|
|
7688
8699
|
closed = false;
|
|
7689
8700
|
enqueue(kind, text) {
|
|
7690
8701
|
if (this.closed) {
|
|
7691
|
-
throw new Error("Cannot log after the
|
|
8702
|
+
throw new Error("Cannot log after the workflow run has settled");
|
|
7692
8703
|
}
|
|
7693
8704
|
this.pending.push({ seq: this.nextSeq++, kind, text });
|
|
7694
8705
|
this.scheduleFlush();
|
|
@@ -7720,7 +8731,7 @@ var FactoryProgressBuffer = class {
|
|
|
7720
8731
|
await this.flushTail;
|
|
7721
8732
|
if (this.flushFailed) {
|
|
7722
8733
|
console.warn(
|
|
7723
|
-
"Ignoring a background
|
|
8734
|
+
"Ignoring a background workflow progress flush failure after the workflow body settled",
|
|
7724
8735
|
this.flushError
|
|
7725
8736
|
);
|
|
7726
8737
|
}
|
|
@@ -7729,7 +8740,7 @@ var FactoryProgressBuffer = class {
|
|
|
7729
8740
|
await this.send(lines);
|
|
7730
8741
|
} catch (error) {
|
|
7731
8742
|
console.warn(
|
|
7732
|
-
"Failed to flush final
|
|
8743
|
+
"Failed to flush final workflow progress after the workflow body settled",
|
|
7733
8744
|
error
|
|
7734
8745
|
);
|
|
7735
8746
|
}
|
|
@@ -7753,30 +8764,30 @@ var FactoryProgressBuffer = class {
|
|
|
7753
8764
|
}
|
|
7754
8765
|
}
|
|
7755
8766
|
};
|
|
7756
|
-
async function
|
|
8767
|
+
async function awaitWorkflowOperation(operation, signal) {
|
|
7757
8768
|
let rejectAbort;
|
|
7758
8769
|
const abortPromise = new Promise((_resolve, reject) => {
|
|
7759
8770
|
rejectAbort = reject;
|
|
7760
8771
|
});
|
|
7761
|
-
const onAbort = () => rejectAbort?.(signal.reason ?? new DOMException("
|
|
8772
|
+
const onAbort = () => rejectAbort?.(signal.reason ?? new DOMException("Workflow run was aborted", "AbortError"));
|
|
7762
8773
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
7763
8774
|
try {
|
|
7764
|
-
|
|
8775
|
+
throwIfWorkflowAborted(signal);
|
|
7765
8776
|
return await Promise.race([operation(), abortPromise]);
|
|
7766
8777
|
} finally {
|
|
7767
8778
|
signal.removeEventListener("abort", onAbort);
|
|
7768
8779
|
}
|
|
7769
8780
|
}
|
|
7770
|
-
function
|
|
8781
|
+
function throwIfWorkflowAborted(signal) {
|
|
7771
8782
|
if (signal.aborted) {
|
|
7772
|
-
throw signal.reason ?? new DOMException("
|
|
8783
|
+
throw signal.reason ?? new DOMException("Workflow run was aborted", "AbortError");
|
|
7773
8784
|
}
|
|
7774
8785
|
}
|
|
7775
|
-
function
|
|
8786
|
+
function isWorkflowAbortError(error) {
|
|
7776
8787
|
return typeof error === "object" && error !== null && "name" in error && error.name === "AbortError";
|
|
7777
8788
|
}
|
|
7778
|
-
function
|
|
7779
|
-
return
|
|
8789
|
+
function isWorkflowFatalError(error) {
|
|
8790
|
+
return isWorkflowAbortError(error) || error instanceof import_node.ResponseError || error instanceof import_node.ConnectionError;
|
|
7780
8791
|
}
|
|
7781
8792
|
var TOOL_SEARCH_TOOL_NAME = "tool_search_tool";
|
|
7782
8793
|
var CopilotSession = class {
|
|
@@ -7808,8 +8819,8 @@ var CopilotSession = class {
|
|
|
7808
8819
|
canvases = /* @__PURE__ */ new Map();
|
|
7809
8820
|
bearerTokenProviders = /* @__PURE__ */ new Map();
|
|
7810
8821
|
commandHandlers = /* @__PURE__ */ new Map();
|
|
7811
|
-
|
|
7812
|
-
|
|
8822
|
+
workflows = /* @__PURE__ */ new Map();
|
|
8823
|
+
workflowAbortControllers = /* @__PURE__ */ new Map();
|
|
7813
8824
|
permissionHandler;
|
|
7814
8825
|
mcpAuthHandler;
|
|
7815
8826
|
userInputHandler;
|
|
@@ -7825,28 +8836,22 @@ var CopilotSession = class {
|
|
|
7825
8836
|
_capabilities = {};
|
|
7826
8837
|
openCanvasInstances = [];
|
|
7827
8838
|
disconnected = false;
|
|
8839
|
+
pendingStructuredWaits = /* @__PURE__ */ new Set();
|
|
7828
8840
|
disconnecting = false;
|
|
7829
8841
|
onDisconnected;
|
|
7830
8842
|
/** @internal Client session API handlers, populated by CopilotClient during create/resume. */
|
|
7831
8843
|
clientSessionApis = {};
|
|
7832
8844
|
/**
|
|
7833
|
-
* Friendly
|
|
8845
|
+
* Friendly workflow API for running registered workflows by name or handle.
|
|
7834
8846
|
*
|
|
7835
|
-
* @experimental Part of the experimental
|
|
8847
|
+
* @experimental Part of the experimental Dynamic Workflows surface and may
|
|
7836
8848
|
* change or be removed in future SDK or CLI releases.
|
|
7837
8849
|
*/
|
|
7838
|
-
|
|
8850
|
+
workflow = {
|
|
7839
8851
|
run: (async (nameOrHandle, options) => {
|
|
7840
|
-
|
|
7841
|
-
const name = typeof nameOrHandle === "string" ? nameOrHandle :
|
|
7842
|
-
|
|
7843
|
-
return this.factory.resume(options.resumeFromRunId, {
|
|
7844
|
-
limits: options.limits,
|
|
7845
|
-
notifyOnComplete: options.notifyOnComplete,
|
|
7846
|
-
logPhaseNames: options.logPhaseNames
|
|
7847
|
-
});
|
|
7848
|
-
}
|
|
7849
|
-
const envelope = await this.rpc.factory.run({
|
|
8852
|
+
throwIfWorkflowExecutionIsActive();
|
|
8853
|
+
const name = typeof nameOrHandle === "string" ? nameOrHandle : getWorkflowDefinition(nameOrHandle).meta.name;
|
|
8854
|
+
const envelope = await this.rpc.workflow.run({
|
|
7850
8855
|
name,
|
|
7851
8856
|
args: options?.args === void 0 ? {} : options.args,
|
|
7852
8857
|
options: {
|
|
@@ -7855,13 +8860,13 @@ var CopilotSession = class {
|
|
|
7855
8860
|
logPhaseNames: options?.logPhaseNames
|
|
7856
8861
|
}
|
|
7857
8862
|
});
|
|
7858
|
-
return this.
|
|
8863
|
+
return this.settleWorkflowRun(envelope);
|
|
7859
8864
|
}),
|
|
7860
8865
|
resume: (async (runId, options) => {
|
|
7861
|
-
|
|
8866
|
+
throwIfWorkflowExecutionIsActive();
|
|
7862
8867
|
let response;
|
|
7863
8868
|
try {
|
|
7864
|
-
response = await this.rpc.
|
|
8869
|
+
response = await this.rpc.workflow.resume({
|
|
7865
8870
|
runId,
|
|
7866
8871
|
limits: options?.limits,
|
|
7867
8872
|
notifyOnComplete: options?.notifyOnComplete,
|
|
@@ -7870,43 +8875,36 @@ var CopilotSession = class {
|
|
|
7870
8875
|
} catch (error) {
|
|
7871
8876
|
if (error instanceof import_node.ResponseError && typeof error.data === "object" && error.data !== null) {
|
|
7872
8877
|
const code = error.data.code;
|
|
7873
|
-
if (
|
|
7874
|
-
throw new
|
|
8878
|
+
if (isWorkflowResumeErrorCode(code)) {
|
|
8879
|
+
throw new WorkflowResumeError(code, error.message);
|
|
7875
8880
|
}
|
|
7876
8881
|
}
|
|
7877
8882
|
throw error;
|
|
7878
8883
|
}
|
|
7879
|
-
return this.
|
|
8884
|
+
return this.settleWorkflowRun(response.run);
|
|
7880
8885
|
}),
|
|
7881
|
-
getRun: async (runId) => this.rpc.
|
|
7882
|
-
waitForRun: (runId, options) => this.
|
|
8886
|
+
getRun: async (runId) => this.rpc.workflow.getRun({ runId }),
|
|
8887
|
+
waitForRun: (runId, options) => this.waitForWorkflowRun(runId, options?.signal),
|
|
7883
8888
|
listRuns: (async (options) => {
|
|
7884
|
-
const page = await this.rpc.
|
|
8889
|
+
const page = await this.rpc.workflow.listRuns(options ?? {});
|
|
7885
8890
|
return options === void 0 ? page.runs : page;
|
|
7886
8891
|
}),
|
|
7887
|
-
getRunDetail: (runId) => this.rpc.
|
|
7888
|
-
getRunProgress: (runId, options = {}) => this.rpc.
|
|
8892
|
+
getRunDetail: (runId) => this.rpc.workflow.getRunDetail({ runId }),
|
|
8893
|
+
getRunProgress: (runId, options = {}) => this.rpc.workflow.getRunProgress({ runId, ...options }),
|
|
7889
8894
|
pause: async (runId) => {
|
|
7890
|
-
|
|
7891
|
-
return this.rpc.
|
|
8895
|
+
throwIfWorkflowExecutionIsActive();
|
|
8896
|
+
return this.rpc.workflow.pause({ runId });
|
|
7892
8897
|
},
|
|
7893
|
-
cancel: async (runId) => this.rpc.
|
|
8898
|
+
cancel: async (runId) => this.rpc.workflow.cancel({ runId })
|
|
7894
8899
|
};
|
|
7895
|
-
|
|
7896
|
-
|
|
7897
|
-
*
|
|
7898
|
-
* The CLI may answer `session.factory.run` and `session.factory.resume`
|
|
7899
|
-
* before the run settles, so a non-terminal envelope is followed by a wait
|
|
7900
|
-
* on the run's terminal state.
|
|
7901
|
-
*/
|
|
7902
|
-
settleFactoryRun(envelope) {
|
|
7903
|
-
if (isFactoryRunTerminal(envelope.status)) {
|
|
8900
|
+
settleWorkflowRun(envelope) {
|
|
8901
|
+
if (isWorkflowRunTerminal(envelope.status)) {
|
|
7904
8902
|
return Promise.resolve(envelope);
|
|
7905
8903
|
}
|
|
7906
|
-
return this.
|
|
8904
|
+
return this.waitForWorkflowRun(envelope.runId);
|
|
7907
8905
|
}
|
|
7908
8906
|
/**
|
|
7909
|
-
* Resolve when a
|
|
8907
|
+
* Resolve when a workflow run reaches a terminal status.
|
|
7910
8908
|
*
|
|
7911
8909
|
* The subscription is installed *before* the first read so a transition
|
|
7912
8910
|
* landing between the two cannot be missed, and re-reads are serialized so
|
|
@@ -7915,8 +8913,8 @@ var CopilotSession = class {
|
|
|
7915
8913
|
* collapse into a single in-flight read. A bounded periodic re-read keeps a
|
|
7916
8914
|
* dropped invalidation from leaving the wait pending forever.
|
|
7917
8915
|
*/
|
|
7918
|
-
|
|
7919
|
-
const abortError = () => signal?.reason ?? new DOMException("
|
|
8916
|
+
waitForWorkflowRun(runId, signal) {
|
|
8917
|
+
const abortError = () => signal?.reason ?? new DOMException("Workflow run wait was aborted", "AbortError");
|
|
7920
8918
|
if (signal?.aborted === true) {
|
|
7921
8919
|
return Promise.reject(abortError());
|
|
7922
8920
|
}
|
|
@@ -7953,8 +8951,8 @@ var CopilotSession = class {
|
|
|
7953
8951
|
try {
|
|
7954
8952
|
do {
|
|
7955
8953
|
rereadRequested = false;
|
|
7956
|
-
const envelope = await this.rpc.
|
|
7957
|
-
if (
|
|
8954
|
+
const envelope = await this.rpc.workflow.getRun({ runId });
|
|
8955
|
+
if (isWorkflowRunTerminal(envelope.status)) {
|
|
7958
8956
|
finish(() => resolve3(envelope));
|
|
7959
8957
|
return;
|
|
7960
8958
|
}
|
|
@@ -7969,7 +8967,7 @@ var CopilotSession = class {
|
|
|
7969
8967
|
onAbort = () => finish(() => reject(abortError()));
|
|
7970
8968
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
7971
8969
|
}
|
|
7972
|
-
unsubscribe = this.on("
|
|
8970
|
+
unsubscribe = this.on("workflow.run_updated", (event) => {
|
|
7973
8971
|
if (event.data.runId === runId) {
|
|
7974
8972
|
void read();
|
|
7975
8973
|
}
|
|
@@ -8041,19 +9039,61 @@ var CopilotSession = class {
|
|
|
8041
9039
|
attachments: options.attachments,
|
|
8042
9040
|
mode: options.mode,
|
|
8043
9041
|
agentMode: options.agentMode,
|
|
8044
|
-
requestHeaders: options.requestHeaders
|
|
9042
|
+
requestHeaders: options.requestHeaders,
|
|
9043
|
+
...options.responseSchema ? {
|
|
9044
|
+
responseFormat: {
|
|
9045
|
+
type: "json_schema",
|
|
9046
|
+
jsonSchema: {
|
|
9047
|
+
name: "response",
|
|
9048
|
+
strict: true,
|
|
9049
|
+
schema: toJsonSchema(options.responseSchema)
|
|
9050
|
+
}
|
|
9051
|
+
}
|
|
9052
|
+
} : {}
|
|
8045
9053
|
});
|
|
8046
9054
|
return response.messageId;
|
|
8047
9055
|
}
|
|
8048
|
-
async sendAndWait(optionsOrPrompt, timeout) {
|
|
9056
|
+
async sendAndWait(optionsOrPrompt, schemaOrTimeout, timeout) {
|
|
8049
9057
|
const options = typeof optionsOrPrompt === "string" ? { prompt: optionsOrPrompt } : optionsOrPrompt;
|
|
8050
|
-
const
|
|
9058
|
+
const typedSchema = isResponseSchema(schemaOrTimeout) ? schemaOrTimeout : void 0;
|
|
9059
|
+
if (schemaOrTimeout !== void 0 && typeof schemaOrTimeout !== "number" && !typedSchema) {
|
|
9060
|
+
throw new TypeError(
|
|
9061
|
+
"The second argument must be a timeout or a schema with toJSONSchema() and parse(). Pass raw JSON Schema in options.responseSchema instead."
|
|
9062
|
+
);
|
|
9063
|
+
}
|
|
9064
|
+
const effectiveTimeout = (typeof schemaOrTimeout === "number" ? schemaOrTimeout : timeout) ?? 6e4;
|
|
9065
|
+
if (typedSchema && options.responseSchema) {
|
|
9066
|
+
throw new Error(
|
|
9067
|
+
"Do not specify responseSchema in options when requesting a typed response."
|
|
9068
|
+
);
|
|
9069
|
+
}
|
|
9070
|
+
if (typedSchema && options.mode === "immediate") {
|
|
9071
|
+
throw new Error(
|
|
9072
|
+
"Structured output cannot be requested on an immediate steering message."
|
|
9073
|
+
);
|
|
9074
|
+
}
|
|
9075
|
+
if (typedSchema || options.responseSchema) {
|
|
9076
|
+
const message = await this.sendAndWaitForStructuredMessage(
|
|
9077
|
+
typedSchema ? { ...options, responseSchema: typedSchema } : options,
|
|
9078
|
+
effectiveTimeout
|
|
9079
|
+
);
|
|
9080
|
+
if (typedSchema) {
|
|
9081
|
+
if (!message) {
|
|
9082
|
+
throw new Error(
|
|
9083
|
+
"The requested run completed without a structured assistant response."
|
|
9084
|
+
);
|
|
9085
|
+
}
|
|
9086
|
+
return typedSchema.parse(JSON.parse(message.data.content));
|
|
9087
|
+
}
|
|
9088
|
+
return message;
|
|
9089
|
+
}
|
|
8051
9090
|
let resolveOutcome;
|
|
8052
9091
|
const outcomePromise = new Promise((resolve3) => {
|
|
8053
9092
|
resolveOutcome = resolve3;
|
|
8054
9093
|
});
|
|
8055
9094
|
let lastAssistantMessage;
|
|
8056
9095
|
const unsubscribe = this.on((event) => {
|
|
9096
|
+
if (event.agentId) return;
|
|
8057
9097
|
if (event.type === "assistant.message") {
|
|
8058
9098
|
lastAssistantMessage = event;
|
|
8059
9099
|
} else if (event.type === "session.idle" && event.data.mode !== "autopilot") {
|
|
@@ -8089,12 +9129,95 @@ var CopilotSession = class {
|
|
|
8089
9129
|
unsubscribe();
|
|
8090
9130
|
}
|
|
8091
9131
|
}
|
|
9132
|
+
async sendAndWaitForStructuredMessage(options, timeout) {
|
|
9133
|
+
if (this.disconnected) {
|
|
9134
|
+
throw new Error("Session is disconnected");
|
|
9135
|
+
}
|
|
9136
|
+
let resolveOutcome;
|
|
9137
|
+
const outcomePromise = new Promise((resolve3) => {
|
|
9138
|
+
resolveOutcome = resolve3;
|
|
9139
|
+
});
|
|
9140
|
+
const fail = (error) => resolveOutcome({ kind: "error", error });
|
|
9141
|
+
let messageId;
|
|
9142
|
+
let consumed = false;
|
|
9143
|
+
let lastMessage;
|
|
9144
|
+
const buffered = [];
|
|
9145
|
+
const observe = (event) => {
|
|
9146
|
+
if (event.agentId) return;
|
|
9147
|
+
if (event.type === "user.message" && event.data.messageId === messageId) {
|
|
9148
|
+
consumed = true;
|
|
9149
|
+
} else if (event.type === "assistant.message" && event.data.originatingMessageId === messageId) {
|
|
9150
|
+
consumed = true;
|
|
9151
|
+
lastMessage = event.data.toolRequests?.length ? void 0 : event;
|
|
9152
|
+
} else if (consumed && event.type === "session.idle" && event.data.mode !== "autopilot") {
|
|
9153
|
+
if (event.data.aborted) {
|
|
9154
|
+
fail(
|
|
9155
|
+
new Error(
|
|
9156
|
+
"The requested run was aborted before a structured result was completed."
|
|
9157
|
+
)
|
|
9158
|
+
);
|
|
9159
|
+
} else {
|
|
9160
|
+
resolveOutcome({ kind: "idle", message: lastMessage });
|
|
9161
|
+
}
|
|
9162
|
+
} else if (consumed && event.type === "session.error") {
|
|
9163
|
+
const error = new Error(event.data.message);
|
|
9164
|
+
error.stack = event.data.stack;
|
|
9165
|
+
fail(error);
|
|
9166
|
+
}
|
|
9167
|
+
};
|
|
9168
|
+
const unsubscribe = this.on((event) => {
|
|
9169
|
+
if (event.type !== "user.message" && event.type !== "assistant.message" && event.type !== "session.idle" && event.type !== "session.error") {
|
|
9170
|
+
return;
|
|
9171
|
+
}
|
|
9172
|
+
if (messageId === void 0) {
|
|
9173
|
+
buffered.push(event);
|
|
9174
|
+
} else {
|
|
9175
|
+
observe(event);
|
|
9176
|
+
}
|
|
9177
|
+
});
|
|
9178
|
+
this.pendingStructuredWaits.add(fail);
|
|
9179
|
+
const timer = setTimeout(
|
|
9180
|
+
() => fail(new Error(`Timeout after ${timeout}ms waiting for the structured response`)),
|
|
9181
|
+
timeout
|
|
9182
|
+
);
|
|
9183
|
+
try {
|
|
9184
|
+
const sendOutcome = this.send(options).then(
|
|
9185
|
+
(id) => {
|
|
9186
|
+
if (!id) {
|
|
9187
|
+
throw new Error(
|
|
9188
|
+
"The runtime did not return a message ID for the structured send."
|
|
9189
|
+
);
|
|
9190
|
+
}
|
|
9191
|
+
messageId = id;
|
|
9192
|
+
for (const event of buffered) observe(event);
|
|
9193
|
+
buffered.length = 0;
|
|
9194
|
+
return outcomePromise;
|
|
9195
|
+
},
|
|
9196
|
+
(error) => ({
|
|
9197
|
+
kind: "error",
|
|
9198
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
9199
|
+
})
|
|
9200
|
+
);
|
|
9201
|
+
const outcome = await Promise.race([sendOutcome, outcomePromise]);
|
|
9202
|
+
if (outcome.kind === "error") throw outcome.error;
|
|
9203
|
+
return outcome.message;
|
|
9204
|
+
} finally {
|
|
9205
|
+
clearTimeout(timer);
|
|
9206
|
+
buffered.length = 0;
|
|
9207
|
+
unsubscribe();
|
|
9208
|
+
this.pendingStructuredWaits.delete(fail);
|
|
9209
|
+
}
|
|
9210
|
+
}
|
|
8092
9211
|
/** @internal */
|
|
8093
9212
|
_markDisconnected() {
|
|
8094
9213
|
if (this.disconnected) {
|
|
8095
9214
|
return;
|
|
8096
9215
|
}
|
|
8097
9216
|
this.disconnected = true;
|
|
9217
|
+
for (const fail of this.pendingStructuredWaits) {
|
|
9218
|
+
fail(new Error("Session disconnected while waiting for a structured response"));
|
|
9219
|
+
}
|
|
9220
|
+
this.pendingStructuredWaits.clear();
|
|
8098
9221
|
for (const controller of this.pendingExternalTools.values()) {
|
|
8099
9222
|
controller.abort();
|
|
8100
9223
|
}
|
|
@@ -8110,13 +9233,13 @@ var CopilotSession = class {
|
|
|
8110
9233
|
this.autoModeSwitchHandler = void 0;
|
|
8111
9234
|
this.commandHandlers.clear();
|
|
8112
9235
|
this.canvases.clear();
|
|
8113
|
-
this.
|
|
8114
|
-
for (const controllersForRun of this.
|
|
9236
|
+
this.workflows.clear();
|
|
9237
|
+
for (const controllersForRun of this.workflowAbortControllers.values()) {
|
|
8115
9238
|
for (const controller of controllersForRun.values()) {
|
|
8116
9239
|
controller.abort();
|
|
8117
9240
|
}
|
|
8118
9241
|
}
|
|
8119
|
-
this.
|
|
9242
|
+
this.workflowAbortControllers.clear();
|
|
8120
9243
|
this.transformCallbacks?.clear();
|
|
8121
9244
|
}
|
|
8122
9245
|
/** @internal */
|
|
@@ -8565,46 +9688,46 @@ var CopilotSession = class {
|
|
|
8565
9688
|
};
|
|
8566
9689
|
}
|
|
8567
9690
|
/**
|
|
8568
|
-
* Registers
|
|
9691
|
+
* Registers workflow closures and reverse-RPC handlers for this session.
|
|
8569
9692
|
*
|
|
8570
|
-
* @param
|
|
9693
|
+
* @param workflows - Workflow handles declared by the joining extension.
|
|
8571
9694
|
* @internal Called by the SDK when an extension joins a session.
|
|
8572
9695
|
*/
|
|
8573
|
-
|
|
8574
|
-
this.
|
|
8575
|
-
if (!
|
|
8576
|
-
delete this.clientSessionApis.
|
|
9696
|
+
registerWorkflows(workflows) {
|
|
9697
|
+
this.workflows.clear();
|
|
9698
|
+
if (!workflows || workflows.length === 0) {
|
|
9699
|
+
delete this.clientSessionApis.workflow;
|
|
8577
9700
|
return;
|
|
8578
9701
|
}
|
|
8579
|
-
for (const handle of
|
|
8580
|
-
const definition =
|
|
8581
|
-
if (this.
|
|
9702
|
+
for (const handle of workflows) {
|
|
9703
|
+
const definition = getWorkflowDefinition(handle);
|
|
9704
|
+
if (this.workflows.has(definition.meta.name)) {
|
|
8582
9705
|
throw new Error(
|
|
8583
|
-
`Duplicate
|
|
9706
|
+
`Duplicate workflow name "${definition.meta.name}". Workflow names must be unique within a joinSession call.`
|
|
8584
9707
|
);
|
|
8585
9708
|
}
|
|
8586
|
-
this.
|
|
9709
|
+
this.workflows.set(definition.meta.name, definition);
|
|
8587
9710
|
}
|
|
8588
9711
|
const self = this;
|
|
8589
|
-
this.clientSessionApis.
|
|
9712
|
+
this.clientSessionApis.workflow = {
|
|
8590
9713
|
async execute(params) {
|
|
8591
|
-
const definition = self.
|
|
9714
|
+
const definition = self.workflows.get(params.name);
|
|
8592
9715
|
if (!definition) {
|
|
8593
|
-
const message = `No
|
|
9716
|
+
const message = `No workflow registered with name "${params.name}"`;
|
|
8594
9717
|
throw new import_node.ResponseError(import_node.ErrorCodes.InvalidParams, message, {
|
|
8595
|
-
code: "
|
|
9718
|
+
code: "workflow_not_found",
|
|
8596
9719
|
name: params.name
|
|
8597
9720
|
});
|
|
8598
9721
|
}
|
|
8599
9722
|
const controller = new AbortController();
|
|
8600
|
-
let controllersForRun = self.
|
|
9723
|
+
let controllersForRun = self.workflowAbortControllers.get(params.runId);
|
|
8601
9724
|
if (controllersForRun === void 0) {
|
|
8602
9725
|
controllersForRun = /* @__PURE__ */ new Map();
|
|
8603
|
-
self.
|
|
9726
|
+
self.workflowAbortControllers.set(params.runId, controllersForRun);
|
|
8604
9727
|
}
|
|
8605
9728
|
controllersForRun.set(params.executionToken, controller);
|
|
8606
|
-
const progress = new
|
|
8607
|
-
await self.rpc.
|
|
9729
|
+
const progress = new WorkflowProgressBuffer(async (lines) => {
|
|
9730
|
+
await self.rpc.workflow.log({
|
|
8608
9731
|
runId: params.runId,
|
|
8609
9732
|
executionToken: params.executionToken,
|
|
8610
9733
|
lines
|
|
@@ -8617,22 +9740,22 @@ var CopilotSession = class {
|
|
|
8617
9740
|
session: self,
|
|
8618
9741
|
signal: controller.signal,
|
|
8619
9742
|
phase: (title) => {
|
|
8620
|
-
|
|
9743
|
+
throwIfWorkflowAborted(controller.signal);
|
|
8621
9744
|
progress.enqueue("phase", title);
|
|
8622
9745
|
},
|
|
8623
9746
|
log: (message) => {
|
|
8624
|
-
|
|
9747
|
+
throwIfWorkflowAborted(controller.signal);
|
|
8625
9748
|
progress.enqueue("log", message);
|
|
8626
9749
|
},
|
|
8627
9750
|
agent: async (prompt, options = {}) => {
|
|
8628
9751
|
await progress.flush();
|
|
8629
9752
|
const opts = {};
|
|
8630
|
-
for (const key of
|
|
8631
|
-
|
|
9753
|
+
for (const key of WORKFLOW_AGENT_OPTION_KEYS) {
|
|
9754
|
+
copyDefinedWorkflowAgentOption(options, opts, key);
|
|
8632
9755
|
}
|
|
8633
|
-
const response = await
|
|
8634
|
-
() => self.rpc.
|
|
8635
|
-
|
|
9756
|
+
const response = await awaitWorkflowOperation(
|
|
9757
|
+
() => self.rpc.workflow.agent({
|
|
9758
|
+
workflowRunId: params.runId,
|
|
8636
9759
|
executionToken: params.executionToken,
|
|
8637
9760
|
prompt,
|
|
8638
9761
|
opts
|
|
@@ -8644,11 +9767,11 @@ var CopilotSession = class {
|
|
|
8644
9767
|
step: async (key, producer, options = {}) => {
|
|
8645
9768
|
await progress.flush();
|
|
8646
9769
|
if (options.volatile) {
|
|
8647
|
-
|
|
9770
|
+
throwIfWorkflowAborted(controller.signal);
|
|
8648
9771
|
return producer();
|
|
8649
9772
|
}
|
|
8650
|
-
const cached = await
|
|
8651
|
-
() => self.rpc.
|
|
9773
|
+
const cached = await awaitWorkflowOperation(
|
|
9774
|
+
() => self.rpc.workflow.journal.get({
|
|
8652
9775
|
runId: params.runId,
|
|
8653
9776
|
executionToken: params.executionToken,
|
|
8654
9777
|
key
|
|
@@ -8661,13 +9784,13 @@ var CopilotSession = class {
|
|
|
8661
9784
|
`step("${key}") journal returned a hit without a result`
|
|
8662
9785
|
);
|
|
8663
9786
|
}
|
|
8664
|
-
|
|
9787
|
+
assertWorkflowStepResult(cached.resultJson, key);
|
|
8665
9788
|
return cached.resultJson;
|
|
8666
9789
|
}
|
|
8667
9790
|
const result2 = await producer();
|
|
8668
|
-
|
|
8669
|
-
await
|
|
8670
|
-
() => self.rpc.
|
|
9791
|
+
assertWorkflowStepResult(result2, key);
|
|
9792
|
+
await awaitWorkflowOperation(
|
|
9793
|
+
() => self.rpc.workflow.journal.put({
|
|
8671
9794
|
runId: params.runId,
|
|
8672
9795
|
executionToken: params.executionToken,
|
|
8673
9796
|
key,
|
|
@@ -8679,17 +9802,17 @@ var CopilotSession = class {
|
|
|
8679
9802
|
},
|
|
8680
9803
|
pause: async (key) => {
|
|
8681
9804
|
if (typeof key !== "string" || key.length === 0) {
|
|
8682
|
-
throw new Error("
|
|
9805
|
+
throw new Error("Workflow pause checkpoint key must not be empty");
|
|
8683
9806
|
}
|
|
8684
|
-
const helperScope =
|
|
9807
|
+
const helperScope = workflowExecutionStore.getStore()?.helperScope;
|
|
8685
9808
|
if (helperScope !== void 0) {
|
|
8686
9809
|
throw new Error(
|
|
8687
|
-
`
|
|
9810
|
+
`Workflow pause checkpoints are not allowed inside ${helperScope}() branches`
|
|
8688
9811
|
);
|
|
8689
9812
|
}
|
|
8690
9813
|
await progress.flush();
|
|
8691
|
-
const response = await
|
|
8692
|
-
() => self.internalRpc.
|
|
9814
|
+
const response = await awaitWorkflowOperation(
|
|
9815
|
+
() => self.internalRpc.workflow.pauseAtCheckpoint({
|
|
8693
9816
|
runId: params.runId,
|
|
8694
9817
|
executionToken: params.executionToken,
|
|
8695
9818
|
key
|
|
@@ -8700,21 +9823,21 @@ var CopilotSession = class {
|
|
|
8700
9823
|
case "continue":
|
|
8701
9824
|
return;
|
|
8702
9825
|
case "pause":
|
|
8703
|
-
await
|
|
9826
|
+
await awaitWorkflowOperation(
|
|
8704
9827
|
() => new Promise(() => {
|
|
8705
9828
|
}),
|
|
8706
9829
|
controller.signal
|
|
8707
9830
|
);
|
|
8708
9831
|
}
|
|
8709
9832
|
},
|
|
8710
|
-
parallel:
|
|
8711
|
-
pipeline:
|
|
8712
|
-
|
|
8713
|
-
throw new Error("nested
|
|
9833
|
+
parallel: runWorkflowParallel,
|
|
9834
|
+
pipeline: runWorkflowPipeline,
|
|
9835
|
+
workflow: async () => {
|
|
9836
|
+
throw new Error("nested workflows are not supported");
|
|
8714
9837
|
}
|
|
8715
9838
|
};
|
|
8716
9839
|
const execution = { active: true };
|
|
8717
|
-
const result = await
|
|
9840
|
+
const result = await workflowExecutionStore.run(execution, async () => {
|
|
8718
9841
|
try {
|
|
8719
9842
|
return await definition.run(context);
|
|
8720
9843
|
} finally {
|
|
@@ -8724,27 +9847,27 @@ var CopilotSession = class {
|
|
|
8724
9847
|
if (result === void 0) {
|
|
8725
9848
|
return {};
|
|
8726
9849
|
}
|
|
8727
|
-
|
|
9850
|
+
assertWorkflowResult(result);
|
|
8728
9851
|
return { result };
|
|
8729
9852
|
} finally {
|
|
8730
9853
|
try {
|
|
8731
9854
|
await progress.close();
|
|
8732
9855
|
} finally {
|
|
8733
|
-
const controllersForRun2 = self.
|
|
9856
|
+
const controllersForRun2 = self.workflowAbortControllers.get(params.runId);
|
|
8734
9857
|
if (controllersForRun2?.get(params.executionToken) === controller) {
|
|
8735
9858
|
controllersForRun2.delete(params.executionToken);
|
|
8736
9859
|
if (controllersForRun2.size === 0) {
|
|
8737
|
-
self.
|
|
9860
|
+
self.workflowAbortControllers.delete(params.runId);
|
|
8738
9861
|
}
|
|
8739
9862
|
}
|
|
8740
9863
|
}
|
|
8741
9864
|
}
|
|
8742
9865
|
},
|
|
8743
9866
|
async abort(params) {
|
|
8744
|
-
const controllersForRun = self.
|
|
9867
|
+
const controllersForRun = self.workflowAbortControllers.get(params.runId);
|
|
8745
9868
|
const controller = controllersForRun?.get(params.executionToken);
|
|
8746
9869
|
if (controller !== void 0) {
|
|
8747
|
-
controller.abort(new DOMException("
|
|
9870
|
+
controller.abort(new DOMException("Workflow run was aborted", "AbortError"));
|
|
8748
9871
|
}
|
|
8749
9872
|
return {};
|
|
8750
9873
|
}
|
|
@@ -9430,22 +10553,22 @@ function assertStrictJson(value, context) {
|
|
|
9430
10553
|
};
|
|
9431
10554
|
visit(value, "$", context.allowTopLevelUndefined);
|
|
9432
10555
|
}
|
|
9433
|
-
function
|
|
10556
|
+
function assertWorkflowResult(value) {
|
|
9434
10557
|
assertStrictJson(value, {
|
|
9435
|
-
code: "
|
|
9436
|
-
label: "
|
|
10558
|
+
code: "workflow_result_not_json",
|
|
10559
|
+
label: "Workflow result",
|
|
9437
10560
|
allowTopLevelUndefined: true
|
|
9438
10561
|
});
|
|
9439
10562
|
}
|
|
9440
|
-
function
|
|
10563
|
+
function assertWorkflowStepResult(value, key) {
|
|
9441
10564
|
assertStrictJson(value, {
|
|
9442
|
-
code: "
|
|
9443
|
-
label: `
|
|
10565
|
+
code: "workflow_step_not_json",
|
|
10566
|
+
label: `Workflow step "${key}" result`,
|
|
9444
10567
|
allowTopLevelUndefined: false
|
|
9445
10568
|
});
|
|
9446
10569
|
}
|
|
9447
10570
|
|
|
9448
|
-
//
|
|
10571
|
+
// src/sdk/nodejs/dist/runtimeArtifacts.js
|
|
9449
10572
|
import {
|
|
9450
10573
|
chmodSync,
|
|
9451
10574
|
copyFileSync,
|
|
@@ -9463,11 +10586,11 @@ import { createRequire } from "node:module";
|
|
|
9463
10586
|
import { homedir } from "node:os";
|
|
9464
10587
|
import { dirname, join, relative, sep } from "node:path";
|
|
9465
10588
|
|
|
9466
|
-
//
|
|
9467
|
-
var COPILOT_CLI_VERSION = "
|
|
10589
|
+
// src/sdk/nodejs/dist/cliVersion.js
|
|
10590
|
+
var COPILOT_CLI_VERSION = "0.0.0-dev";
|
|
9468
10591
|
var COPILOT_CLI_USE_NPM_PACKAGE = false;
|
|
9469
10592
|
|
|
9470
|
-
//
|
|
10593
|
+
// src/sdk/nodejs/dist/runtimeArtifacts.js
|
|
9471
10594
|
var require2 = createRequire(typeof __filename === "string" ? __filename : import.meta.url);
|
|
9472
10595
|
var EXCLUDED_TOP_LEVEL = /* @__PURE__ */ new Set([
|
|
9473
10596
|
"app.js",
|
|
@@ -9620,13 +10743,13 @@ function getRuntimePackageName(platform) {
|
|
|
9620
10743
|
function resolvePackageRoot(packageName, searchPaths = require2.resolve.paths(packageName) ?? []) {
|
|
9621
10744
|
return searchPaths.map((base) => join(base, ...packageName.split("/"))).find((candidate) => existsSync(join(candidate, "package.json")));
|
|
9622
10745
|
}
|
|
9623
|
-
async function ensureRuntimeBundle(
|
|
10746
|
+
async function ensureRuntimeBundle(version2, options = {}) {
|
|
9624
10747
|
const platform = options.platform ?? getRuntimePlatform();
|
|
9625
10748
|
if (COPILOT_CLI_USE_NPM_PACKAGE) {
|
|
9626
10749
|
const packageName2 = `@github/copilot-${platform}`;
|
|
9627
10750
|
const packageRoot2 = resolvePackageRoot(packageName2, options.packageSearchPaths);
|
|
9628
10751
|
if (!packageRoot2) {
|
|
9629
|
-
throw new Error(`Could not resolve ${packageName2} for Copilot CLI ${
|
|
10752
|
+
throw new Error(`Could not resolve ${packageName2} for Copilot CLI ${version2}.`);
|
|
9630
10753
|
}
|
|
9631
10754
|
validateFile(
|
|
9632
10755
|
join(packageRoot2, "prebuilds", platform, "runtime.node"),
|
|
@@ -9635,7 +10758,7 @@ async function ensureRuntimeBundle(version, options = {}) {
|
|
|
9635
10758
|
return materializeRuntimeBundle(
|
|
9636
10759
|
{ packageRoot: packageRoot2, platform },
|
|
9637
10760
|
options.cacheRoot,
|
|
9638
|
-
`${
|
|
10761
|
+
`${version2}-${platform}`
|
|
9639
10762
|
);
|
|
9640
10763
|
}
|
|
9641
10764
|
const packageName = getRuntimePackageName(platform);
|
|
@@ -9660,7 +10783,80 @@ async function ensureRuntimeBundle(version, options = {}) {
|
|
|
9660
10783
|
return wrapper;
|
|
9661
10784
|
}
|
|
9662
10785
|
|
|
9663
|
-
//
|
|
10786
|
+
// src/sdk/nodejs/dist/installationConfirmation.js
|
|
10787
|
+
var import_node2 = __toESM(require_node(), 1);
|
|
10788
|
+
function createInstallationConfirmationAdapter(connection, handler) {
|
|
10789
|
+
const closed = new import_node2.CancellationTokenSource();
|
|
10790
|
+
const closeSubscription = connection.onClose(() => closed.cancel());
|
|
10791
|
+
const disposeSubscription = connection.onDispose(() => {
|
|
10792
|
+
closed.cancel();
|
|
10793
|
+
closed.dispose();
|
|
10794
|
+
closeSubscription.dispose();
|
|
10795
|
+
disposeSubscription.dispose();
|
|
10796
|
+
});
|
|
10797
|
+
return {
|
|
10798
|
+
async confirm(request, token) {
|
|
10799
|
+
if (!token) {
|
|
10800
|
+
throw new Error("Installation confirmation request cancellation is unavailable");
|
|
10801
|
+
}
|
|
10802
|
+
const { confirmationId, reviewFingerprint } = request;
|
|
10803
|
+
const combined = new import_node2.CancellationTokenSource();
|
|
10804
|
+
const subscriptions = [];
|
|
10805
|
+
const cancelRequest = () => combined.cancel();
|
|
10806
|
+
const cancelConnection = () => combined.cancel();
|
|
10807
|
+
const checkCancellation = () => {
|
|
10808
|
+
if (closed.token.isCancellationRequested) {
|
|
10809
|
+
throw new Error("Installation confirmation connection closed");
|
|
10810
|
+
}
|
|
10811
|
+
if (token.isCancellationRequested) {
|
|
10812
|
+
throw new import_node2.ResponseError(-32800, "Installation confirmation request cancelled");
|
|
10813
|
+
}
|
|
10814
|
+
};
|
|
10815
|
+
try {
|
|
10816
|
+
subscriptions.push(
|
|
10817
|
+
token.onCancellationRequested(cancelRequest),
|
|
10818
|
+
closed.token.onCancellationRequested(cancelConnection)
|
|
10819
|
+
);
|
|
10820
|
+
if (token.isCancellationRequested || closed.token.isCancellationRequested) {
|
|
10821
|
+
combined.cancel();
|
|
10822
|
+
}
|
|
10823
|
+
checkCancellation();
|
|
10824
|
+
const cancelled = new Promise((_resolve, reject) => {
|
|
10825
|
+
subscriptions.push(
|
|
10826
|
+
token.onCancellationRequested(
|
|
10827
|
+
() => reject(
|
|
10828
|
+
new import_node2.ResponseError(
|
|
10829
|
+
-32800,
|
|
10830
|
+
"Installation confirmation request cancelled"
|
|
10831
|
+
)
|
|
10832
|
+
)
|
|
10833
|
+
),
|
|
10834
|
+
closed.token.onCancellationRequested(
|
|
10835
|
+
() => reject(new Error("Installation confirmation connection closed"))
|
|
10836
|
+
)
|
|
10837
|
+
);
|
|
10838
|
+
});
|
|
10839
|
+
const decision = await Promise.race([
|
|
10840
|
+
Promise.resolve().then(() => {
|
|
10841
|
+
checkCancellation();
|
|
10842
|
+
return handler(request, combined.token);
|
|
10843
|
+
}),
|
|
10844
|
+
cancelled
|
|
10845
|
+
]);
|
|
10846
|
+
checkCancellation();
|
|
10847
|
+
if (decision !== "confirm" && decision !== "decline" && decision !== "cancel") {
|
|
10848
|
+
throw new Error("Invalid installation confirmation decision");
|
|
10849
|
+
}
|
|
10850
|
+
return { confirmationId, reviewFingerprint, decision };
|
|
10851
|
+
} finally {
|
|
10852
|
+
for (const subscription of subscriptions) subscription.dispose();
|
|
10853
|
+
combined.dispose();
|
|
10854
|
+
}
|
|
10855
|
+
}
|
|
10856
|
+
};
|
|
10857
|
+
}
|
|
10858
|
+
|
|
10859
|
+
// src/sdk/nodejs/dist/toolSet.js
|
|
9664
10860
|
var VALID_TOOL_NAME = /^[a-zA-Z0-9_-]+$/;
|
|
9665
10861
|
function validateName(kind, name) {
|
|
9666
10862
|
if (name === "*") {
|
|
@@ -9715,12 +10911,9 @@ var ToolSet = class {
|
|
|
9715
10911
|
}
|
|
9716
10912
|
};
|
|
9717
10913
|
|
|
9718
|
-
//
|
|
10914
|
+
// src/sdk/nodejs/dist/client.js
|
|
9719
10915
|
var MIN_PROTOCOL_VERSION = 3;
|
|
9720
10916
|
var RUNTIME_SHUTDOWN_TIMEOUT_MS = 1e4;
|
|
9721
|
-
function isZodSchema(value) {
|
|
9722
|
-
return value != null && typeof value === "object" && "toJSONSchema" in value && typeof value.toJSONSchema === "function";
|
|
9723
|
-
}
|
|
9724
10917
|
async function withTimeout(promise, timeoutMs, message) {
|
|
9725
10918
|
let timeout;
|
|
9726
10919
|
try {
|
|
@@ -9765,13 +10958,6 @@ async function waitForChildExit(child, timeoutMs) {
|
|
|
9765
10958
|
}
|
|
9766
10959
|
});
|
|
9767
10960
|
}
|
|
9768
|
-
function toJsonSchema(parameters) {
|
|
9769
|
-
if (!parameters) return void 0;
|
|
9770
|
-
if (isZodSchema(parameters)) {
|
|
9771
|
-
return parameters.toJSONSchema();
|
|
9772
|
-
}
|
|
9773
|
-
return parameters;
|
|
9774
|
-
}
|
|
9775
10961
|
var DEFAULT_PROVIDER_NAME = "default";
|
|
9776
10962
|
function extractBearerTokenProviders(provider, providers) {
|
|
9777
10963
|
const callbacks = /* @__PURE__ */ new Map();
|
|
@@ -9887,7 +11073,7 @@ function getNodeExecPath() {
|
|
|
9887
11073
|
function getBundledRuntimePath() {
|
|
9888
11074
|
return ensureRuntimeBundle(COPILOT_CLI_VERSION);
|
|
9889
11075
|
}
|
|
9890
|
-
var TeardownResilientStreamMessageWriter = class extends
|
|
11076
|
+
var TeardownResilientStreamMessageWriter = class extends import_node3.StreamMessageWriter {
|
|
9891
11077
|
suppressWriteErrors = false;
|
|
9892
11078
|
async write(msg) {
|
|
9893
11079
|
try {
|
|
@@ -9904,6 +11090,7 @@ var CopilotClient = class _CopilotClient {
|
|
|
9904
11090
|
cliProcess = null;
|
|
9905
11091
|
ffiHost = null;
|
|
9906
11092
|
connection = null;
|
|
11093
|
+
requestAdapter = null;
|
|
9907
11094
|
messageWriter = null;
|
|
9908
11095
|
connectionClosed = false;
|
|
9909
11096
|
socket = null;
|
|
@@ -9941,6 +11128,8 @@ var CopilotClient = class _CopilotClient {
|
|
|
9941
11128
|
/** Connection-level session filesystem config, set via constructor option. */
|
|
9942
11129
|
sessionFsConfig = null;
|
|
9943
11130
|
requestHandler = null;
|
|
11131
|
+
extensionLaunchProvider;
|
|
11132
|
+
installationConfirmationHandler;
|
|
9944
11133
|
builtinPluginDirectories = [];
|
|
9945
11134
|
onGitHubTelemetry;
|
|
9946
11135
|
clientGlobalHandlers = {};
|
|
@@ -10098,6 +11287,8 @@ var CopilotClient = class _CopilotClient {
|
|
|
10098
11287
|
this.onGetTraceContext = options.onGetTraceContext;
|
|
10099
11288
|
this.sessionFsConfig = options.sessionFs ?? null;
|
|
10100
11289
|
this.requestHandler = options.requestHandler ?? null;
|
|
11290
|
+
this.extensionLaunchProvider = options.extensionLaunchProvider;
|
|
11291
|
+
this.installationConfirmationHandler = options.installationConfirmationHandler;
|
|
10101
11292
|
this.onGitHubTelemetry = options.onGitHubTelemetry;
|
|
10102
11293
|
this.setupClientGlobalHandlers();
|
|
10103
11294
|
const connEnv = conn.kind === "stdio" || conn.kind === "tcp" ? conn.env : void 0;
|
|
@@ -10200,14 +11391,16 @@ var CopilotClient = class _CopilotClient {
|
|
|
10200
11391
|
}
|
|
10201
11392
|
setupClientGlobalHandlers() {
|
|
10202
11393
|
const handlers = {};
|
|
11394
|
+
handlers.extensionLaunchProvider = this.extensionLaunchProvider;
|
|
10203
11395
|
if (this.requestHandler) {
|
|
10204
|
-
|
|
11396
|
+
this.requestAdapter = createCopilotRequestAdapter(this.requestHandler, () => {
|
|
10205
11397
|
if (!this.connection) {
|
|
10206
11398
|
return void 0;
|
|
10207
11399
|
}
|
|
10208
11400
|
this._rpc ??= createServerRpc(this.connection);
|
|
10209
11401
|
return this._rpc;
|
|
10210
11402
|
});
|
|
11403
|
+
handlers.llmInference = this.requestAdapter;
|
|
10211
11404
|
}
|
|
10212
11405
|
if (this.onGitHubTelemetry) {
|
|
10213
11406
|
const onGitHubTelemetry = this.onGitHubTelemetry;
|
|
@@ -10312,6 +11505,9 @@ var CopilotClient = class _CopilotClient {
|
|
|
10312
11505
|
}
|
|
10313
11506
|
await this.connectToServer();
|
|
10314
11507
|
await this.verifyProtocolVersion();
|
|
11508
|
+
if (this.extensionLaunchProvider) {
|
|
11509
|
+
await this.rpc.registerExtensionLaunchProvider();
|
|
11510
|
+
}
|
|
10315
11511
|
if (this.builtinPluginDirectories.length > 0) {
|
|
10316
11512
|
try {
|
|
10317
11513
|
await this.connection.sendRequest("plugins.builtin.set", {
|
|
@@ -10400,6 +11596,7 @@ var CopilotClient = class _CopilotClient {
|
|
|
10400
11596
|
}
|
|
10401
11597
|
this.sessions.clear();
|
|
10402
11598
|
this.githubTokenProviders.clear();
|
|
11599
|
+
this.requestAdapter?.cancelPending();
|
|
10403
11600
|
if (this.connection && !this.connectionClosed && (this.cliProcess || this.ffiHost) && !this.isExternalServer) {
|
|
10404
11601
|
const runtimeShutdownStart = Date.now();
|
|
10405
11602
|
const shutdownPromise = this.rpc.runtime.shutdown();
|
|
@@ -10555,6 +11752,7 @@ var CopilotClient = class _CopilotClient {
|
|
|
10555
11752
|
}
|
|
10556
11753
|
this.sessions.clear();
|
|
10557
11754
|
this.githubTokenProviders.clear();
|
|
11755
|
+
this.requestAdapter?.cancelPending();
|
|
10558
11756
|
if (this.messageWriter) {
|
|
10559
11757
|
this.messageWriter.suppressWriteErrors = true;
|
|
10560
11758
|
}
|
|
@@ -10905,6 +12103,7 @@ var CopilotClient = class _CopilotClient {
|
|
|
10905
12103
|
includeSubAgentStreamingEvents: config.includeSubAgentStreamingEvents ?? true,
|
|
10906
12104
|
...this.onGitHubTelemetry != null ? { enableGitHubTelemetryForwarding: true } : {},
|
|
10907
12105
|
mcpServers: toWireMcpServers(config.mcpServers),
|
|
12106
|
+
...config.diagnostics !== void 0 ? { diagnostics: config.diagnostics } : {},
|
|
10908
12107
|
mcpOAuthTokenStorage: config.mcpOAuthTokenStorage,
|
|
10909
12108
|
authClientIdMetadataUrl: config.authClientIdMetadataUrl,
|
|
10910
12109
|
envValueMode: "direct",
|
|
@@ -10914,6 +12113,7 @@ var CopilotClient = class _CopilotClient {
|
|
|
10914
12113
|
agent: config.agent,
|
|
10915
12114
|
configDir: config.configDirectory,
|
|
10916
12115
|
enableConfigDiscovery: config.enableConfigDiscovery,
|
|
12116
|
+
refreshCustomInstructions: config.refreshCustomInstructions,
|
|
10917
12117
|
skipEmbeddingRetrieval: config.skipEmbeddingRetrieval,
|
|
10918
12118
|
embeddingCacheStorage: config.embeddingCacheStorage,
|
|
10919
12119
|
organizationCustomInstructions: config.organizationCustomInstructions,
|
|
@@ -11006,10 +12206,11 @@ var CopilotClient = class _CopilotClient {
|
|
|
11006
12206
|
return this.resumeSessionInternal(sessionId, config);
|
|
11007
12207
|
}
|
|
11008
12208
|
/** @internal */
|
|
11009
|
-
async resumeSessionForExtension(sessionId, config,
|
|
11010
|
-
return this.resumeSessionInternal(sessionId, config,
|
|
12209
|
+
async resumeSessionForExtension(sessionId, config, contributions = {}, extensionOptions) {
|
|
12210
|
+
return this.resumeSessionInternal(sessionId, config, contributions, extensionOptions);
|
|
11011
12211
|
}
|
|
11012
|
-
async resumeSessionInternal(sessionId, config,
|
|
12212
|
+
async resumeSessionInternal(sessionId, config, contributions = {}, extensionOptions) {
|
|
12213
|
+
const { workflows } = contributions;
|
|
11013
12214
|
if (config.gitHubToken !== void 0 && config.gitHubTokenProvider !== void 0) {
|
|
11014
12215
|
throw new Error("gitHubToken and gitHubTokenProvider are mutually exclusive");
|
|
11015
12216
|
}
|
|
@@ -11029,7 +12230,7 @@ var CopilotClient = class _CopilotClient {
|
|
|
11029
12230
|
session.registerTools(config.tools);
|
|
11030
12231
|
session.registerCanvases(config.canvases);
|
|
11031
12232
|
session.registerCommands(config.commands);
|
|
11032
|
-
session.
|
|
12233
|
+
session.registerWorkflows(workflows);
|
|
11033
12234
|
const {
|
|
11034
12235
|
wireProvider: bearerWireProvider,
|
|
11035
12236
|
wireProviders: bearerWireProviders,
|
|
@@ -11110,7 +12311,7 @@ var CopilotClient = class _CopilotClient {
|
|
|
11110
12311
|
})),
|
|
11111
12312
|
toolSearch: config.toolSearch,
|
|
11112
12313
|
canvases: config.canvases?.map((canvas) => canvas.declaration),
|
|
11113
|
-
|
|
12314
|
+
workflows: workflows?.map((workflow) => workflow.meta),
|
|
11114
12315
|
requestCanvasRenderer: config.requestCanvasRenderer,
|
|
11115
12316
|
requestExtensions: config.requestExtensions,
|
|
11116
12317
|
extensionSdkPath: config.extensionSdkPath,
|
|
@@ -11151,6 +12352,7 @@ var CopilotClient = class _CopilotClient {
|
|
|
11151
12352
|
includeSubAgentStreamingEvents: config.includeSubAgentStreamingEvents ?? true,
|
|
11152
12353
|
...this.onGitHubTelemetry != null ? { enableGitHubTelemetryForwarding: true } : {},
|
|
11153
12354
|
mcpServers: toWireMcpServers(config.mcpServers),
|
|
12355
|
+
...config.diagnostics !== void 0 ? { diagnostics: config.diagnostics } : {},
|
|
11154
12356
|
mcpOAuthTokenStorage: config.mcpOAuthTokenStorage,
|
|
11155
12357
|
authClientIdMetadataUrl: config.authClientIdMetadataUrl,
|
|
11156
12358
|
envValueMode: "direct",
|
|
@@ -11331,7 +12533,7 @@ var CopilotClient = class _CopilotClient {
|
|
|
11331
12533
|
const result = await raceAgainstExit(this.internalRpc.connect(connectParams));
|
|
11332
12534
|
serverVersion = result.protocolVersion;
|
|
11333
12535
|
} catch (err) {
|
|
11334
|
-
if (err instanceof
|
|
12536
|
+
if (err instanceof import_node3.ResponseError && (err.code === import_node3.ErrorCodes.MethodNotFound || err.message === "Unhandled method connect")) {
|
|
11335
12537
|
serverVersion = (await raceAgainstExit(this.ping())).protocolVersion;
|
|
11336
12538
|
} else {
|
|
11337
12539
|
throw err;
|
|
@@ -11571,6 +12773,9 @@ var CopilotClient = class _CopilotClient {
|
|
|
11571
12773
|
if (this.options.mode === "empty") {
|
|
11572
12774
|
env.COPILOT_DISABLE_KEYTAR = "1";
|
|
11573
12775
|
}
|
|
12776
|
+
if (this.options.mode !== "empty") {
|
|
12777
|
+
env.COPILOT_RUNTIME_PROCESS_FILE_LOGGING = "1";
|
|
12778
|
+
}
|
|
11574
12779
|
if (this.options.telemetry) {
|
|
11575
12780
|
const t = this.options.telemetry;
|
|
11576
12781
|
env.COPILOT_OTEL_ENABLED = "true";
|
|
@@ -11806,8 +13011,8 @@ stderr: ${stderrOutput}`
|
|
|
11806
13011
|
throw new Error("In-process FFI runtime host not started");
|
|
11807
13012
|
}
|
|
11808
13013
|
this.messageWriter = new TeardownResilientStreamMessageWriter(this.ffiHost.sendStream);
|
|
11809
|
-
this.connection = (0,
|
|
11810
|
-
new
|
|
13014
|
+
this.connection = (0, import_node3.createMessageConnection)(
|
|
13015
|
+
new import_node3.StreamMessageReader(this.ffiHost.receiveStream),
|
|
11811
13016
|
this.messageWriter
|
|
11812
13017
|
);
|
|
11813
13018
|
this.attachConnectionHandlers();
|
|
@@ -11860,8 +13065,8 @@ stderr: ${stderrOutput}` : ""}`
|
|
|
11860
13065
|
}
|
|
11861
13066
|
});
|
|
11862
13067
|
this.messageWriter = new TeardownResilientStreamMessageWriter(this.cliProcess.stdin);
|
|
11863
|
-
this.connection = (0,
|
|
11864
|
-
new
|
|
13068
|
+
this.connection = (0, import_node3.createMessageConnection)(
|
|
13069
|
+
new import_node3.StreamMessageReader(this.cliProcess.stdout),
|
|
11865
13070
|
this.messageWriter
|
|
11866
13071
|
);
|
|
11867
13072
|
this.attachConnectionHandlers();
|
|
@@ -11875,8 +13080,8 @@ stderr: ${stderrOutput}` : ""}`
|
|
|
11875
13080
|
throw new Error("CLI child process was unexpectedly started in parent process mode");
|
|
11876
13081
|
}
|
|
11877
13082
|
this.messageWriter = new TeardownResilientStreamMessageWriter(process.stdout);
|
|
11878
|
-
this.connection = (0,
|
|
11879
|
-
new
|
|
13083
|
+
this.connection = (0, import_node3.createMessageConnection)(
|
|
13084
|
+
new import_node3.StreamMessageReader(process.stdin),
|
|
11880
13085
|
this.messageWriter
|
|
11881
13086
|
);
|
|
11882
13087
|
this.attachConnectionHandlers();
|
|
@@ -11898,8 +13103,8 @@ stderr: ${stderrOutput}` : ""}`
|
|
|
11898
13103
|
this.socket.connect(this.runtimePort, this.actualHost, () => {
|
|
11899
13104
|
clearTimeout(connectionTimeout);
|
|
11900
13105
|
this.messageWriter = new TeardownResilientStreamMessageWriter(this.socket);
|
|
11901
|
-
this.connection = (0,
|
|
11902
|
-
new
|
|
13106
|
+
this.connection = (0, import_node3.createMessageConnection)(
|
|
13107
|
+
new import_node3.StreamMessageReader(this.socket),
|
|
11903
13108
|
this.messageWriter
|
|
11904
13109
|
);
|
|
11905
13110
|
this.attachConnectionHandlers();
|
|
@@ -11945,6 +13150,16 @@ stderr: ${stderrOutput}` : ""}`
|
|
|
11945
13150
|
return session.clientSessionApis;
|
|
11946
13151
|
});
|
|
11947
13152
|
registerClientGlobalApiHandlers(this.connection, this.clientGlobalHandlers);
|
|
13153
|
+
if (this.installationConfirmationHandler) {
|
|
13154
|
+
const confirmation = createInstallationConfirmationAdapter(
|
|
13155
|
+
this.connection,
|
|
13156
|
+
this.installationConfirmationHandler
|
|
13157
|
+
);
|
|
13158
|
+
this.connection.onRequest(
|
|
13159
|
+
"installations.confirm",
|
|
13160
|
+
(params, token) => confirmation.confirm(params, token)
|
|
13161
|
+
);
|
|
13162
|
+
}
|
|
11948
13163
|
this.connection.onRequest(
|
|
11949
13164
|
"hooks.invoke",
|
|
11950
13165
|
async (params) => {
|
|
@@ -11963,6 +13178,7 @@ stderr: ${stderrOutput}` : ""}`
|
|
|
11963
13178
|
}
|
|
11964
13179
|
this.sessions.clear();
|
|
11965
13180
|
this.githubTokenProviders.clear();
|
|
13181
|
+
this.requestAdapter?.cancelPending();
|
|
11966
13182
|
};
|
|
11967
13183
|
this.connection.onClose(markDisconnected);
|
|
11968
13184
|
this.connection.onError(() => {
|
|
@@ -12082,7 +13298,7 @@ stderr: ${stderrOutput}` : ""}`
|
|
|
12082
13298
|
}
|
|
12083
13299
|
};
|
|
12084
13300
|
|
|
12085
|
-
//
|
|
13301
|
+
// src/sdk/nodejs/dist/extension.js
|
|
12086
13302
|
async function joinSession(config = {}) {
|
|
12087
13303
|
const sessionId = process.env.SESSION_ID;
|
|
12088
13304
|
if (!sessionId) {
|
|
@@ -12093,7 +13309,7 @@ async function joinSession(config = {}) {
|
|
|
12093
13309
|
const client = new CopilotClient({ _internalConnection: { kind: "parent-process" } });
|
|
12094
13310
|
const {
|
|
12095
13311
|
extensionSdkPath: _stripped,
|
|
12096
|
-
|
|
13312
|
+
workflows,
|
|
12097
13313
|
requestedEnvironmentVariables,
|
|
12098
13314
|
...rest
|
|
12099
13315
|
} = config;
|
|
@@ -12105,16 +13321,16 @@ async function joinSession(config = {}) {
|
|
|
12105
13321
|
onPermissionRequest: config.onPermissionRequest ?? defaultJoinSessionPermissionHandler,
|
|
12106
13322
|
suppressResumeEvent: config.suppressResumeEvent ?? true
|
|
12107
13323
|
},
|
|
12108
|
-
|
|
13324
|
+
{ workflows },
|
|
12109
13325
|
requestedEnvironmentVariables?.length ? { requestedEnvironmentVariables } : void 0
|
|
12110
13326
|
);
|
|
12111
13327
|
}
|
|
12112
13328
|
export {
|
|
12113
13329
|
Canvas,
|
|
12114
13330
|
CanvasError,
|
|
12115
|
-
|
|
13331
|
+
WorkflowResumeError,
|
|
12116
13332
|
createCanvas,
|
|
12117
|
-
|
|
12118
|
-
|
|
13333
|
+
defineWorkflow,
|
|
13334
|
+
isWorkflowRunTerminal,
|
|
12119
13335
|
joinSession
|
|
12120
13336
|
};
|