@github/copilot-sdk-win32-x64 1.0.15-preview.0 → 1.0.15-preview.2

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.
@@ -53,9 +53,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
53
53
  mod
54
54
  ));
55
55
 
56
- // node_modules/.pnpm/vscode-jsonrpc@8.2.1/node_modules/vscode-jsonrpc/lib/common/is.js
56
+ // src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/is.js
57
57
  var require_is = __commonJS({
58
- "node_modules/.pnpm/vscode-jsonrpc@8.2.1/node_modules/vscode-jsonrpc/lib/common/is.js"(exports) {
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
- // node_modules/.pnpm/vscode-jsonrpc@8.2.1/node_modules/vscode-jsonrpc/lib/common/messages.js
93
+ // src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/messages.js
94
94
  var require_messages = __commonJS({
95
- "node_modules/.pnpm/vscode-jsonrpc@8.2.1/node_modules/vscode-jsonrpc/lib/common/messages.js"(exports) {
95
+ "src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/messages.js"(exports) {
96
96
  "use strict";
97
97
  Object.defineProperty(exports, "__esModule", { value: true });
98
98
  exports.Message = exports.NotificationType9 = exports.NotificationType8 = exports.NotificationType7 = exports.NotificationType6 = exports.NotificationType5 = exports.NotificationType4 = exports.NotificationType3 = exports.NotificationType2 = exports.NotificationType1 = exports.NotificationType0 = exports.NotificationType = exports.RequestType9 = exports.RequestType8 = exports.RequestType7 = exports.RequestType6 = exports.RequestType5 = exports.RequestType4 = exports.RequestType3 = exports.RequestType2 = exports.RequestType1 = exports.RequestType = exports.RequestType0 = exports.AbstractMessageSignature = exports.ParameterStructures = exports.ResponseError = exports.ErrorCodes = void 0;
@@ -328,9 +328,9 @@ var require_messages = __commonJS({
328
328
  }
329
329
  });
330
330
 
331
- // node_modules/.pnpm/vscode-jsonrpc@8.2.1/node_modules/vscode-jsonrpc/lib/common/linkedMap.js
331
+ // src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/linkedMap.js
332
332
  var require_linkedMap = __commonJS({
333
- "node_modules/.pnpm/vscode-jsonrpc@8.2.1/node_modules/vscode-jsonrpc/lib/common/linkedMap.js"(exports) {
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
- // node_modules/.pnpm/vscode-jsonrpc@8.2.1/node_modules/vscode-jsonrpc/lib/common/disposable.js
701
+ // src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/disposable.js
702
702
  var require_disposable = __commonJS({
703
- "node_modules/.pnpm/vscode-jsonrpc@8.2.1/node_modules/vscode-jsonrpc/lib/common/disposable.js"(exports) {
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
- // node_modules/.pnpm/vscode-jsonrpc@8.2.1/node_modules/vscode-jsonrpc/lib/common/ral.js
719
+ // src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/ral.js
720
720
  var require_ral = __commonJS({
721
- "node_modules/.pnpm/vscode-jsonrpc@8.2.1/node_modules/vscode-jsonrpc/lib/common/ral.js"(exports) {
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
- // node_modules/.pnpm/vscode-jsonrpc@8.2.1/node_modules/vscode-jsonrpc/lib/common/events.js
744
+ // src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/events.js
745
745
  var require_events = __commonJS({
746
- "node_modules/.pnpm/vscode-jsonrpc@8.2.1/node_modules/vscode-jsonrpc/lib/common/events.js"(exports) {
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
- // node_modules/.pnpm/vscode-jsonrpc@8.2.1/node_modules/vscode-jsonrpc/lib/common/cancellation.js
873
+ // src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/cancellation.js
874
874
  var require_cancellation = __commonJS({
875
- "node_modules/.pnpm/vscode-jsonrpc@8.2.1/node_modules/vscode-jsonrpc/lib/common/cancellation.js"(exports) {
875
+ "src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/cancellation.js"(exports) {
876
876
  "use strict";
877
877
  Object.defineProperty(exports, "__esModule", { value: true });
878
878
  exports.CancellationTokenSource = exports.CancellationToken = void 0;
@@ -959,9 +959,9 @@ var require_cancellation = __commonJS({
959
959
  }
960
960
  });
961
961
 
962
- // node_modules/.pnpm/vscode-jsonrpc@8.2.1/node_modules/vscode-jsonrpc/lib/common/sharedArrayCancellation.js
962
+ // src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/sharedArrayCancellation.js
963
963
  var require_sharedArrayCancellation = __commonJS({
964
- "node_modules/.pnpm/vscode-jsonrpc@8.2.1/node_modules/vscode-jsonrpc/lib/common/sharedArrayCancellation.js"(exports) {
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
- // node_modules/.pnpm/vscode-jsonrpc@8.2.1/node_modules/vscode-jsonrpc/lib/common/semaphore.js
1040
+ // src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/semaphore.js
1041
1041
  var require_semaphore = __commonJS({
1042
- "node_modules/.pnpm/vscode-jsonrpc@8.2.1/node_modules/vscode-jsonrpc/lib/common/semaphore.js"(exports) {
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
- // node_modules/.pnpm/vscode-jsonrpc@8.2.1/node_modules/vscode-jsonrpc/lib/common/messageReader.js
1108
+ // src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/messageReader.js
1109
1109
  var require_messageReader = __commonJS({
1110
- "node_modules/.pnpm/vscode-jsonrpc@8.2.1/node_modules/vscode-jsonrpc/lib/common/messageReader.js"(exports) {
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
- // node_modules/.pnpm/vscode-jsonrpc@8.2.1/node_modules/vscode-jsonrpc/lib/common/messageWriter.js
1297
+ // src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/messageWriter.js
1298
1298
  var require_messageWriter = __commonJS({
1299
- "node_modules/.pnpm/vscode-jsonrpc@8.2.1/node_modules/vscode-jsonrpc/lib/common/messageWriter.js"(exports) {
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
- // node_modules/.pnpm/vscode-jsonrpc@8.2.1/node_modules/vscode-jsonrpc/lib/common/messageBuffer.js
1409
+ // src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/messageBuffer.js
1410
1410
  var require_messageBuffer = __commonJS({
1411
- "node_modules/.pnpm/vscode-jsonrpc@8.2.1/node_modules/vscode-jsonrpc/lib/common/messageBuffer.js"(exports) {
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
- // node_modules/.pnpm/vscode-jsonrpc@8.2.1/node_modules/vscode-jsonrpc/lib/common/connection.js
1557
+ // src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/connection.js
1558
1558
  var require_connection = __commonJS({
1559
- "node_modules/.pnpm/vscode-jsonrpc@8.2.1/node_modules/vscode-jsonrpc/lib/common/connection.js"(exports) {
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 version = "2.0";
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: version,
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: version,
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: version,
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: version,
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: version,
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
- // node_modules/.pnpm/vscode-jsonrpc@8.2.1/node_modules/vscode-jsonrpc/lib/common/api.js
2686
+ // src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/common/api.js
2687
2687
  var require_api = __commonJS({
2688
- "node_modules/.pnpm/vscode-jsonrpc@8.2.1/node_modules/vscode-jsonrpc/lib/common/api.js"(exports) {
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
- // node_modules/.pnpm/vscode-jsonrpc@8.2.1/node_modules/vscode-jsonrpc/lib/node/ril.js
2888
+ // src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/node/ril.js
2889
2889
  var require_ril = __commonJS({
2890
- "node_modules/.pnpm/vscode-jsonrpc@8.2.1/node_modules/vscode-jsonrpc/lib/node/ril.js"(exports) {
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
- // node_modules/.pnpm/vscode-jsonrpc@8.2.1/node_modules/vscode-jsonrpc/lib/node/main.js
3044
+ // src/sdk/nodejs/node_modules/vscode-jsonrpc/lib/node/main.js
3045
3045
  var require_main = __commonJS({
3046
- "node_modules/.pnpm/vscode-jsonrpc@8.2.1/node_modules/vscode-jsonrpc/lib/node/main.js"(exports) {
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
- // node_modules/.pnpm/vscode-jsonrpc@8.2.1/node_modules/vscode-jsonrpc/node.js
3304
+ // src/sdk/nodejs/node_modules/vscode-jsonrpc/node.js
3305
3305
  var require_node = __commonJS({
3306
- "node_modules/.pnpm/vscode-jsonrpc@8.2.1/node_modules/vscode-jsonrpc/node.js"(exports, module) {
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
- // node_modules/.pnpm/empty-npm-package@1.0.0/node_modules/empty-npm-package/index.js
3313
- var require_empty_npm_package = __commonJS({
3314
- "node_modules/.pnpm/empty-npm-package@1.0.0/node_modules/empty-npm-package/index.js"(exports) {
3315
- exports.printMsg = function() {
3316
- console.log("This is a message from the demo package");
3312
+ // src/sdk/nodejs/node_modules/koffi/src/koffi/src/static.js
3313
+ import { createRequire as createRequire2 } from "node:module";
3314
+ function loadStatic(pkg2) {
3315
+ let native2 = null;
3316
+ if (pkg2 == "linux-arm") {
3317
+ try {
3318
+ native2 = require3("@koromix/koffi-linux-arm");
3319
+ } catch (err) {
3320
+ }
3321
+ }
3322
+ if (pkg2 == "linux-arm64") {
3323
+ try {
3324
+ native2 = require3("@koromix/koffi-linux-arm64");
3325
+ } catch (err) {
3326
+ }
3327
+ }
3328
+ if (pkg2 == "linux-ia32") {
3329
+ try {
3330
+ native2 = require3("@koromix/koffi-linux-ia32");
3331
+ } catch (err) {
3332
+ }
3333
+ }
3334
+ if (pkg2 == "linux-x64") {
3335
+ try {
3336
+ native2 = require3("@koromix/koffi-linux-x64");
3337
+ } catch (err) {
3338
+ }
3339
+ }
3340
+ if (pkg2 == "linux-riscv64") {
3341
+ try {
3342
+ native2 = require3("@koromix/koffi-linux-riscv64");
3343
+ } catch (err) {
3344
+ }
3345
+ }
3346
+ if (pkg2 == "freebsd-ia32") {
3347
+ try {
3348
+ native2 = require3("@koromix/koffi-freebsd-ia32");
3349
+ } catch (err) {
3350
+ }
3351
+ }
3352
+ if (pkg2 == "freebsd-x64") {
3353
+ try {
3354
+ native2 = require3("@koromix/koffi-freebsd-x64");
3355
+ } catch (err) {
3356
+ }
3357
+ }
3358
+ if (pkg2 == "freebsd-arm64") {
3359
+ try {
3360
+ native2 = require3("@koromix/koffi-freebsd-arm64");
3361
+ } catch (err) {
3362
+ }
3363
+ }
3364
+ if (pkg2 == "openbsd-ia32") {
3365
+ try {
3366
+ native2 = require3("@koromix/koffi-openbsd-ia32");
3367
+ } catch (err) {
3368
+ }
3369
+ }
3370
+ if (pkg2 == "openbsd-x64") {
3371
+ try {
3372
+ native2 = require3("@koromix/koffi-openbsd-x64");
3373
+ } catch (err) {
3374
+ }
3375
+ }
3376
+ if (pkg2 == "win32-ia32") {
3377
+ try {
3378
+ native2 = require3("@koromix/koffi-win32-ia32");
3379
+ } catch (err) {
3380
+ }
3381
+ }
3382
+ if (pkg2 == "win32-x64") {
3383
+ try {
3384
+ native2 = require3("@koromix/koffi-win32-x64");
3385
+ } catch (err) {
3386
+ }
3387
+ }
3388
+ if (pkg2 == "win32-arm64") {
3389
+ try {
3390
+ native2 = require3("@koromix/koffi-win32-arm64");
3391
+ } catch (err) {
3392
+ }
3393
+ }
3394
+ if (pkg2 == "darwin-x64") {
3395
+ try {
3396
+ native2 = require3("@koromix/koffi-darwin-x64");
3397
+ } catch (err) {
3398
+ }
3399
+ }
3400
+ if (pkg2 == "darwin-arm64") {
3401
+ try {
3402
+ native2 = require3("@koromix/koffi-darwin-arm64");
3403
+ } catch (err) {
3404
+ }
3405
+ }
3406
+ if (pkg2 == "linux-loong64") {
3407
+ try {
3408
+ native2 = require3("@koromix/koffi-linux-loong64");
3409
+ } catch (err) {
3410
+ }
3411
+ }
3412
+ if (pkg2 == "android-arm64") {
3413
+ try {
3414
+ native2 = require3("@koromix/koffi-android-arm64");
3415
+ } catch (err) {
3416
+ }
3417
+ }
3418
+ if (pkg2 == "android-x64") {
3419
+ try {
3420
+ native2 = require3("@koromix/koffi-android-x64");
3421
+ } catch (err) {
3422
+ }
3423
+ }
3424
+ return native2;
3425
+ }
3426
+ var require3;
3427
+ var init_static = __esm({
3428
+ "src/sdk/nodejs/node_modules/koffi/src/koffi/src/static.js"() {
3429
+ require3 = createRequire2(import.meta.url);
3430
+ }
3431
+ });
3432
+
3433
+ // src/sdk/nodejs/node_modules/koffi/src/koffi/index.js
3434
+ import util from "node:util";
3435
+ import fs2 from "node:fs";
3436
+ import { createRequire as createRequire3 } from "node:module";
3437
+ import fs from "node:fs";
3438
+ function determineAbi() {
3439
+ let abi = process.arch.toString();
3440
+ if (abi == "riscv32" || abi == "riscv64") {
3441
+ let file = openFile(process.execPath, "r");
3442
+ try {
3443
+ let header = readElfHeader(file);
3444
+ let float_abi = header.e_flags & 6;
3445
+ switch (float_abi) {
3446
+ case 0:
3447
+ {
3448
+ }
3449
+ break;
3450
+ case 2:
3451
+ {
3452
+ abi += "f";
3453
+ }
3454
+ break;
3455
+ case 4:
3456
+ {
3457
+ abi += "d";
3458
+ }
3459
+ break;
3460
+ case 6:
3461
+ {
3462
+ abi += "q";
3463
+ }
3464
+ break;
3465
+ }
3466
+ } finally {
3467
+ file.close();
3468
+ }
3469
+ } else if (abi == "arm") {
3470
+ let file = openFile(process.execPath, "r");
3471
+ try {
3472
+ let header = readElfHeader(file);
3473
+ if (header.e_flags & 1024) {
3474
+ abi += "hf";
3475
+ } else if (header.e_flags & 512) {
3476
+ abi += "sf";
3477
+ } else {
3478
+ throw new Error("Unknown ARM floating-point ABI");
3479
+ }
3480
+ } finally {
3481
+ file.close();
3482
+ }
3483
+ }
3484
+ return abi;
3485
+ }
3486
+ function readElfHeader(file, offset = 0) {
3487
+ let buf = file.read(offset, 512);
3488
+ if (buf.length < 16)
3489
+ throw new Error("Truncated header");
3490
+ if (buf[0] != 127 || buf[1] != 69 || buf[2] != 76 || buf[3] != 70)
3491
+ throw new Error("Invalid magic number");
3492
+ if (buf[6] != 1)
3493
+ throw new Error("Invalid ELF version");
3494
+ if (buf[5] != 1)
3495
+ throw new Error("Big-endian architectures are not supported");
3496
+ switch (buf[4]) {
3497
+ case 1:
3498
+ {
3499
+ if (buf.length < 68)
3500
+ throw new Error("Truncated ELF header");
3501
+ return {
3502
+ ei_class: 32,
3503
+ e_machine: buf.readUInt16LE(18),
3504
+ e_flags: buf.readUInt32LE(36),
3505
+ e_phoff: buf.readUInt32LE(28),
3506
+ e_phentsize: buf.readUInt16LE(42),
3507
+ e_phnum: buf.readUInt16LE(44)
3508
+ };
3509
+ }
3510
+ break;
3511
+ case 2:
3512
+ {
3513
+ if (buf.length < 120)
3514
+ throw new Error("Truncated ELF header");
3515
+ return {
3516
+ ei_class: 64,
3517
+ e_machine: buf.readUInt16LE(18),
3518
+ e_flags: buf.readUInt32LE(48),
3519
+ e_phoff: buf.readBigUInt64LE(32),
3520
+ e_phentsize: buf.readUInt16LE(54),
3521
+ e_phnum: buf.readUInt16LE(56)
3522
+ };
3523
+ }
3524
+ break;
3525
+ default:
3526
+ throw new Error("Invalid ELF class");
3527
+ }
3528
+ }
3529
+ function openFile(filename, flags) {
3530
+ let fd = fs.openSync(filename, flags);
3531
+ return new FileHandle(fd);
3532
+ }
3533
+ function detectPlatform() {
3534
+ if (process.versions.napi == null || process.versions.napi < package_default.cnoke.napi) {
3535
+ let major = parseInt(process.versions.node, 10);
3536
+ throw new Error(`This engine is based on Node ${process.versions.node}, but ${package_default.name} does not support the Node ${major}.x branch (Node-API < ${package_default.cnoke.napi})`);
3537
+ }
3538
+ let abi = determineAbi();
3539
+ let pkg2 = `${process.platform}-${process.arch}`;
3540
+ let triplets2 = [`${process.platform}_${abi}`];
3541
+ if (process.platform == "linux")
3542
+ triplets2.push(`musl_${abi}`);
3543
+ return [package_default.version, pkg2, triplets2];
3544
+ }
3545
+ function loadDynamic(dirname3, pkg2, triplets2) {
3546
+ let suffix = "/../../build/koffi";
3547
+ let root = dirname3 + suffix;
3548
+ let roots = [root];
3549
+ let native2 = null;
3550
+ let err = null;
3551
+ if (process["resourcesPath"] != null) {
3552
+ let suffixes = [
3553
+ "/koffi",
3554
+ "/koffi/build",
3555
+ "/node_modules/koffi/build"
3556
+ ];
3557
+ for (let suffix2 of suffixes)
3558
+ roots.push(process["resourcesPath"] + suffix2);
3559
+ }
3560
+ let names = [
3561
+ `${import.meta.dirname}/../../../@koromix/koffi-${pkg2}`,
3562
+ ...triplets2.flatMap((triplet) => roots.map((dir) => `${dir}/${triplet}/koffi.node`))
3563
+ ];
3564
+ for (let name of names) {
3565
+ if (!fs2.existsSync(name))
3566
+ continue;
3567
+ try {
3568
+ native2 = require22(name);
3569
+ break;
3570
+ } catch (e) {
3571
+ err ??= e;
3572
+ }
3573
+ }
3574
+ if (native2 == null && err != null)
3575
+ throw err;
3576
+ return native2;
3577
+ }
3578
+ function wrapNative(native2, version2) {
3579
+ if (native2 == null)
3580
+ throw new Error("Cannot find the native Koffi module; did you bundle it correctly?");
3581
+ if (native2.version != version2)
3582
+ throw new Error("Mismatched native Koffi modules");
3583
+ let load = native2.load;
3584
+ let register = native2.register;
3585
+ let introspect = native2.type;
3586
+ native2.sizeof = (spec) => introspect(spec).size;
3587
+ native2.alignof = (spec) => introspect(spec).alignment;
3588
+ native2.offsetof = (spec, name) => {
3589
+ let info = introspect(spec);
3590
+ if (info.primitive != "Record")
3591
+ throw new TypeError("The offsetof() function can only be used with record types");
3592
+ let member = info.members[name];
3593
+ if (member == null)
3594
+ throw new Error(`Record type ${info.name} does not have member '${name}'`);
3595
+ return member.offset;
3596
+ };
3597
+ native2.register = (...args) => {
3598
+ if (args.length >= 3 && typeof args[1] == "function") {
3599
+ process.emitWarning("Using koffi.register() with a custom this value was deprecated in Koffi 2.17, use function.bind() instead", "DeprecationWarning", "KOFFI009");
3600
+ args[1] = args[1].bind(args[0]);
3601
+ args = args.slice(1);
3602
+ }
3603
+ return register(...args);
3604
+ };
3605
+ native2.load = (...args) => {
3606
+ let lib = load(...args);
3607
+ lib.cdecl = util.deprecate((...args2) => lib.func("__cdecl", ...args2), "The koffi.cdecl() function was deprecated in Koffi 2.7, use koffi.func(...) instead", "KOFFI003");
3608
+ lib.stdcall = util.deprecate((...args2) => lib.func("__stdcall", ...args2), 'The koffi.stdcall() function was deprecated in Koffi 2.7, use koffi.func("__stdcall", ...) instead', "KOFFI004");
3609
+ lib.fastcall = util.deprecate((...args2) => lib.func("__fastcall", ...args2), 'The koffi.fastcall() function was deprecated in Koffi 2.7, use koffi.func("__fastcall", ...) instead', "KOFFI005");
3610
+ lib.thiscall = util.deprecate((...args2) => lib.func("__thiscall", ...args2), 'The koffi.thiscall() function was deprecated in Koffi 2.7, use koffi.func("__thiscall", ...) instead', "KOFFI006");
3611
+ return lib;
3612
+ };
3613
+ native2.resolve = util.deprecate(native2.type, "The koffi.resolve() function was deprecated in Koffi 3.0, use koffi.type() instead", "KOFFI007");
3614
+ native2.introspect = util.deprecate(native2.type, "The koffi.introspect() function was deprecated in Koffi 3.0, use koffi.type() instead", "KOFFI008");
3615
+ }
3616
+ var FileHandle, package_default, require22, version, pkg, triplets, native, mod_LibraryHandle, mod_TypeObject, mod_Union, mod_address, mod_alias, mod_alignof, mod_alloc, mod_array, mod_as, mod_call, mod_config, mod_decode, mod_disposable, mod_encode, mod_enumeration, mod_errno, mod_extension, mod_free, mod_in, mod_inout, mod_introspect, mod_load, mod_node, mod_offsetof, mod_opaque, mod_os, mod_out, mod_pack, mod_pointer, mod_proto, mod_register, mod_reset, mod_resolve, mod_sizeof, mod_stats, mod_struct, mod_type, mod_types, mod_union, mod_unregister, mod_version, mod_view, index_default;
3617
+ var init_koffi = __esm({
3618
+ "src/sdk/nodejs/node_modules/koffi/src/koffi/index.js"() {
3619
+ init_static();
3620
+ FileHandle = class {
3621
+ constructor(fd) {
3622
+ this.fd = fd;
3623
+ }
3624
+ close() {
3625
+ fs.closeSync(this.fd);
3626
+ }
3627
+ [Symbol.dispose]() {
3628
+ fs.closeSync(this.fd);
3629
+ }
3630
+ read(offset, len) {
3631
+ let buf = Buffer.allocUnsafe(len);
3632
+ let read = fs.readSync(this.fd, buf, 0, len, offset);
3633
+ return buf.subarray(0, read);
3634
+ }
3317
3635
  };
3636
+ package_default = { name: "koffi", version: "3.2.1", cnoke: { api: "../../vendor/node-api-headers", output: "../../bin/Koffi/{{ toolchain }}", node: 16, napi: 8 } };
3637
+ require22 = createRequire3(import.meta.url);
3638
+ [version, pkg, triplets] = detectPlatform();
3639
+ native = loadStatic(pkg) ?? loadDynamic(import.meta.dirname, pkg, triplets);
3640
+ wrapNative(native, version);
3641
+ mod_LibraryHandle = native.LibraryHandle;
3642
+ mod_TypeObject = native.TypeObject;
3643
+ mod_Union = native.Union;
3644
+ mod_address = native.address;
3645
+ mod_alias = native.alias;
3646
+ mod_alignof = native.alignof;
3647
+ mod_alloc = native.alloc;
3648
+ mod_array = native.array;
3649
+ mod_as = native.as;
3650
+ mod_call = native.call;
3651
+ mod_config = native.config;
3652
+ mod_decode = native.decode;
3653
+ mod_disposable = native.disposable;
3654
+ mod_encode = native.encode;
3655
+ mod_enumeration = native.enumeration;
3656
+ mod_errno = native.errno;
3657
+ mod_extension = native.extension;
3658
+ mod_free = native.free;
3659
+ mod_in = native.in;
3660
+ mod_inout = native.inout;
3661
+ mod_introspect = native.introspect;
3662
+ mod_load = native.load;
3663
+ mod_node = native.node;
3664
+ mod_offsetof = native.offsetof;
3665
+ mod_opaque = native.opaque;
3666
+ mod_os = native.os;
3667
+ mod_out = native.out;
3668
+ mod_pack = native.pack;
3669
+ mod_pointer = native.pointer;
3670
+ mod_proto = native.proto;
3671
+ mod_register = native.register;
3672
+ mod_reset = native.reset;
3673
+ mod_resolve = native.resolve;
3674
+ mod_sizeof = native.sizeof;
3675
+ mod_stats = native.stats;
3676
+ mod_struct = native.struct;
3677
+ mod_type = native.type;
3678
+ mod_types = native.types;
3679
+ mod_union = native.union;
3680
+ mod_unregister = native.unregister;
3681
+ mod_version = native.version;
3682
+ mod_view = native.view;
3683
+ index_default = native;
3684
+ }
3685
+ });
3686
+
3687
+ // src/sdk/nodejs/node_modules/koffi/index.js
3688
+ var init_koffi2 = __esm({
3689
+ "src/sdk/nodejs/node_modules/koffi/index.js"() {
3690
+ init_koffi();
3691
+ init_koffi();
3318
3692
  }
3319
3693
  });
3320
3694
 
3321
- // node_modules/.pnpm/@github+copilot-sdk@1.0.14-preview.1/node_modules/@github/copilot-sdk/dist/ffiRuntimeHost.js
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 = import_koffi.default.load(libraryPath);
3339
- const outboundCallbackType = import_koffi.default.pointer(
3340
- import_koffi.default.proto(
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 import_koffi, SYMBOL_PREFIX, KEEP_ALIVE_INTERVAL_MS, CLEANUP_RETRY_INTERVAL_MS, loadedLibraryPath, loadedLibrary, FfiRuntimeHost;
3768
+ var SYMBOL_PREFIX, KEEP_ALIVE_INTERVAL_MS, CLEANUP_RETRY_INTERVAL_MS, loadedLibraryPath, loadedLibrary, FfiRuntimeHost;
3395
3769
  var init_ffiRuntimeHost = __esm({
3396
- "node_modules/.pnpm/@github+copilot-sdk@1.0.14-preview.1/node_modules/@github/copilot-sdk/dist/ffiRuntimeHost.js"() {
3397
- import_koffi = __toESM(require_empty_npm_package(), 1);
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 = import_koffi.default.register(
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 = import_koffi.default.decode(
3916
+ const bytes = index_default.decode(
3542
3917
  bytesPtr,
3543
- import_koffi.default.array("uint8", length, "Typed")
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
- import_koffi.default.unregister(callback);
3933
+ index_default.unregister(callback);
3559
3934
  this.outboundCallback = void 0;
3560
3935
  return true;
3561
3936
  } catch (error) {
@@ -3655,7 +4030,7 @@ var init_ffiRuntimeHost = __esm({
3655
4030
  }
3656
4031
  });
3657
4032
 
3658
- // node_modules/.pnpm/@github+copilot-sdk@1.0.14-preview.1/node_modules/@github/copilot-sdk/dist/client.js
4033
+ // src/sdk/nodejs/dist/client.js
3659
4034
  var import_node2 = __toESM(require_node(), 1);
3660
4035
  import { spawn } from "node:child_process";
3661
4036
  import { randomUUID } from "node:crypto";
@@ -3663,7 +4038,7 @@ import { existsSync as existsSync3 } from "node:fs";
3663
4038
  import { isIPv6, Socket } from "node:net";
3664
4039
  import { dirname as dirname2, isAbsolute, join as join2, resolve as resolve2 } from "node:path";
3665
4040
 
3666
- // node_modules/.pnpm/@github+copilot-sdk@1.0.14-preview.1/node_modules/@github/copilot-sdk/dist/generated/rpc.js
4041
+ // src/sdk/nodejs/dist/generated/rpc.js
3667
4042
  function createServerRpc(connection) {
3668
4043
  return {
3669
4044
  /**
@@ -3863,7 +4238,15 @@ function createServerRpc(connection) {
3863
4238
  *
3864
4239
  * @returns Outcome of a catalog.search call: either bounded inert candidates, or one typed refusal. Never a partial success.
3865
4240
  */
3866
- search: async (params) => connection.sendRequest("catalog.search", params)
4241
+ search: async (params) => connection.sendRequest("catalog.search", params),
4242
+ /**
4243
+ * Terminates one retained catalog selection group. A selected outcome returns the native host a fresh single-use candidate handle plus the original searchId for a later explicit mcp.planInstall call; non-selected outcomes release the group without producing a planning input. Candidate state, cards, URLs, credentials and private identifiers remain inside the runtime. The model-facing catalog_select tool projects the result separately and never exposes the candidate handle or searchId.
4244
+ *
4245
+ * @param params Terminates one retained catalog selection group through an opaque reference previously returned by the model-safe search projection.
4246
+ *
4247
+ * @returns Typed outcome of catalog.select. Only the selected host result carries a fresh candidate handle; the model-facing projection removes both that handle and searchId.
4248
+ */
4249
+ select: async (params) => connection.sendRequest("catalog.select", params)
3867
4250
  },
3868
4251
  /** @experimental */
3869
4252
  plugins: {
@@ -4094,7 +4477,7 @@ function createServerRpc(connection) {
4094
4477
  /**
4095
4478
  * Registers an SDK client as the session filesystem provider.
4096
4479
  *
4097
- * @param params Initial working directory, session-state path layout, and path conventions used to register the calling SDK client as the session filesystem provider.
4480
+ * @param params Initial working directory, session-state path layout, and path conventions used to register the calling SDK client as the session filesystem provider. A registered provider is authoritative for path interpretation and filesystem facts used by workspace permission validation. Paths are interpreted lexically; home-relative paths (`~` and `~/...`) and Windows drive-relative paths such as `C:foo` are unsupported. Until provider-side canonicalization is supported, providers must not expose symlinks inside allowed roots that escape those roots.
4098
4481
  *
4099
4482
  * @returns Indicates whether the calling client was registered as the session filesystem provider.
4100
4483
  */
@@ -4398,15 +4781,7 @@ function createInternalServerRpc(connection) {
4398
4781
  */
4399
4782
  getBoardEntryCount: async (params) => connection.sendRequest("sessions.getBoardEntryCount", params),
4400
4783
  /**
4401
- * Registers extension-provided tools on the given session, gated by an optional `enabled` callback. Returns an opaque unsubscribe function the caller must invoke to deregister the tools when the extension is torn down. Marked internal because `loader`, `enabled`, and the returned `unsubscribe` are in-process handles that cannot cross the JSON-RPC boundary. Disappears once extension discovery / launch / tool registration are owned by the runtime: SDK consumers will pass pure config (search paths, disabled ids) via `SessionOptions` and the runtime will resolve, launch, register, and tear down extensions itself.
4402
- *
4403
- * @param params Params to attach an extension loader's tools to a session.
4404
- *
4405
- * @returns Handle for releasing the extension tool registration.
4406
- */
4407
- registerExtensionToolsOnSession: async (params) => connection.sendRequest("sessions.registerExtensionToolsOnSession", params),
4408
- /**
4409
- * Attaches (or detaches) an in-process ExtensionController delegate for the given session, used by shared-API surfaces that need to query or modify the session's extension state. Pass `controller: undefined` to detach. Marked internal because the controller is an in-process object that cannot cross the JSON-RPC boundary. Disappears alongside `registerExtensionToolsOnSession`: once the runtime owns extension management, the public surface exposes list/enable/disable/reload as dedicated RPCs served by the runtime.
4784
+ * Attaches (or detaches) an in-process ExtensionController delegate for the given session in a local host adapter. Pass `controller: undefined` to detach. Internal because the controller cannot cross the JSON-RPC boundary; the runtime manages its own session extension service.
4410
4785
  *
4411
4786
  * @param params Params to attach or detach an in-process ExtensionController delegate.
4412
4787
  */
@@ -4515,11 +4890,11 @@ function createSessionRpc(connection, sessionId) {
4515
4890
  /** @experimental */
4516
4891
  debug: {
4517
4892
  /**
4518
- * Collects a redacted session debug log bundle into a local archive or staging directory. 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.
4893
+ * Collects a session debug log bundle into a local archive or staging directory. Logs are redacted by default; redaction can be configured per caller-provided diagnostic entry. The runtime includes session-owned logs by default and accepts caller-provided diagnostic entries so host applications can add their own files without changing this API shape.
4519
4894
  *
4520
- * @param params Options for collecting a redacted session debug bundle.
4895
+ * @param params Options for collecting a session debug bundle with configurable redaction.
4521
4896
  *
4522
- * @returns Result of collecting a redacted debug bundle.
4897
+ * @returns Result of collecting a session debug bundle.
4523
4898
  */
4524
4899
  collectLogs: async (params) => connection.sendRequest("session.debug.collectLogs", { sessionId, ...params })
4525
4900
  },
@@ -4666,6 +5041,108 @@ function createSessionRpc(connection, sessionId) {
4666
5041
  }
4667
5042
  },
4668
5043
  /** @experimental */
5044
+ workflow: {
5045
+ /**
5046
+ * Runs a registered dynamic workflow by name at the top level.
5047
+ *
5048
+ * @param params Parameters for invoking a registered workflow.
5049
+ *
5050
+ * @returns Complete current or terminal workflow run envelope.
5051
+ */
5052
+ run: async (params) => connection.sendRequest("session.workflow.run", { sessionId, ...params }),
5053
+ /**
5054
+ * Resumes a dynamic workflow run using its persisted name, arguments, journal, and accounting.
5055
+ *
5056
+ * @param params Parameters for resuming a workflow run from its persisted identity.
5057
+ *
5058
+ * @returns Resolved persisted workflow identity and resumed run envelope.
5059
+ */
5060
+ resume: async (params) => connection.sendRequest("session.workflow.resume", { sessionId, ...params }),
5061
+ /**
5062
+ * Gets the current or settled envelope for a dynamic workflow run.
5063
+ *
5064
+ * @param params Parameters for retrieving a workflow run.
5065
+ *
5066
+ * @returns Complete current or terminal workflow run envelope.
5067
+ */
5068
+ getRun: async (params) => connection.sendRequest("session.workflow.getRun", { sessionId, ...params }),
5069
+ /**
5070
+ * Lists durable dynamic workflow runs for this session in creation order.
5071
+ *
5072
+ * @param params Parameters for paging workflow runs.
5073
+ *
5074
+ * @returns A page of workflow runs in durable creation order.
5075
+ */
5076
+ listRuns: async (params) => connection.sendRequest("session.workflow.listRuns", { sessionId, ...params }),
5077
+ /**
5078
+ * Gets durable and live observability detail for one dynamic workflow run.
5079
+ *
5080
+ * @param params Parameters for retrieving a workflow run.
5081
+ *
5082
+ * @returns Full workflow run observability detail.
5083
+ */
5084
+ getRunDetail: async (params) => connection.sendRequest("session.workflow.getRunDetail", { sessionId, ...params }),
5085
+ /**
5086
+ * Pages durable progress for one dynamic workflow run.
5087
+ *
5088
+ * @param params Parameters for paging workflow progress.
5089
+ *
5090
+ * @returns A bidirectional page of workflow progress.
5091
+ */
5092
+ getRunProgress: async (params) => connection.sendRequest("session.workflow.getRunProgress", { sessionId, ...params }),
5093
+ /**
5094
+ * Requests cancellation of a dynamic workflow run and returns its run envelope.
5095
+ *
5096
+ * @param params Parameters for cancelling a workflow run.
5097
+ *
5098
+ * @returns Complete current or terminal workflow run envelope.
5099
+ */
5100
+ cancel: async (params) => connection.sendRequest("session.workflow.cancel", { sessionId, ...params }),
5101
+ /**
5102
+ * Pauses a running dynamic workflow and returns its settled run envelope.
5103
+ *
5104
+ * @param params Parameters for pausing a running workflow.
5105
+ *
5106
+ * @returns Complete current or terminal workflow run envelope.
5107
+ */
5108
+ pause: async (params) => connection.sendRequest("session.workflow.pause", { sessionId, ...params }),
5109
+ /**
5110
+ * Records a batch of ordered dynamic workflow progress lines.
5111
+ *
5112
+ * @param params Parameters for recording workflow progress.
5113
+ *
5114
+ * @returns Acknowledgement that a workflow request was accepted.
5115
+ */
5116
+ log: async (params) => connection.sendRequest("session.workflow.log", { sessionId, ...params }),
5117
+ /**
5118
+ * Runs one dynamic-workflow-scoped subagent and returns its result.
5119
+ *
5120
+ * @param params Parameters for one workflow-scoped subagent call.
5121
+ *
5122
+ * @returns Result of one workflow-scoped subagent call.
5123
+ */
5124
+ agent: async (params) => connection.sendRequest("session.workflow.agent", { sessionId, ...params }),
5125
+ /** @experimental */
5126
+ journal: {
5127
+ /**
5128
+ * Reads a memoized dynamic workflow journal entry.
5129
+ *
5130
+ * @param params Parameters for reading a workflow journal entry.
5131
+ *
5132
+ * @returns Result of reading a workflow journal entry.
5133
+ */
5134
+ get: async (params) => connection.sendRequest("session.workflow.journal.get", { sessionId, ...params }),
5135
+ /**
5136
+ * Stores a memoized dynamic workflow journal entry.
5137
+ *
5138
+ * @param params Parameters for storing a workflow journal entry.
5139
+ *
5140
+ * @returns Acknowledgement that a workflow request was accepted.
5141
+ */
5142
+ put: async (params) => connection.sendRequest("session.workflow.journal.put", { sessionId, ...params })
5143
+ }
5144
+ },
5145
+ /** @experimental */
4669
5146
  model: {
4670
5147
  /**
4671
5148
  * Gets the session's authoritative model snapshot, including the committed Auto preference and any newer unclaimed Auto preference waiting for a future user turn.
@@ -4829,6 +5306,32 @@ function createSessionRpc(connection, sessionId) {
4829
5306
  * @param params Relative path and UTF-8 content for the workspace file to create or overwrite.
4830
5307
  */
4831
5308
  createFile: async (params) => connection.sendRequest("session.workspaces.createFile", { sessionId, ...params }),
5309
+ /**
5310
+ * Returns metadata for a file or directory in the session workspace files directory.
5311
+ *
5312
+ * @param params Relative path of the workspace file or directory to inspect.
5313
+ *
5314
+ * @returns Filesystem metadata for a path in the session workspace files directory.
5315
+ */
5316
+ statFile: async (params) => connection.sendRequest("session.workspaces.statFile", { sessionId, ...params }),
5317
+ /**
5318
+ * Creates a directory in the session workspace files directory.
5319
+ *
5320
+ * @param params Directory to create within the session workspace files directory.
5321
+ */
5322
+ createDirectory: async (params) => connection.sendRequest("session.workspaces.createDirectory", { sessionId, ...params }),
5323
+ /**
5324
+ * Removes a file or directory from the session workspace files directory.
5325
+ *
5326
+ * @param params File or directory to remove from the session workspace files directory.
5327
+ */
5328
+ removePath: async (params) => connection.sendRequest("session.workspaces.removePath", { sessionId, ...params }),
5329
+ /**
5330
+ * Renames a file or directory within the session workspace files directory.
5331
+ *
5332
+ * @param params Source and destination paths for a rename within the session workspace files directory.
5333
+ */
5334
+ renamePath: async (params) => connection.sendRequest("session.workspaces.renamePath", { sessionId, ...params }),
4832
5335
  /**
4833
5336
  * Lists workspace checkpoints in chronological order.
4834
5337
  *
@@ -5345,83 +5848,246 @@ function createSessionRpc(connection, sessionId) {
5345
5848
  }
5346
5849
  },
5347
5850
  /** @experimental */
5348
- plugins: {
5851
+ connectors: {
5349
5852
  /**
5350
- * Lists plugins installed for the session.
5853
+ * Returns feature availability and bounded polling limits for the EXPERIMENTAL session connector API. This method never performs a Connector service request.
5351
5854
  *
5352
- * @returns Plugins installed for the session, with their enabled state and version metadata.
5855
+ * @returns Feature detection and hard polling limits for the EXPERIMENTAL session connector API.
5353
5856
  */
5354
- list: async () => connection.sendRequest("session.plugins.list", { sessionId }),
5857
+ getCapabilities: async () => connection.sendRequest("session.connectors.getCapabilities", { sessionId }),
5355
5858
  /**
5356
- * 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.
5859
+ * Returns authoritative session Connector state from current availability, pinned account selection, cached catalog, and live MCP projection without performing a Connector service request.
5357
5860
  *
5358
- * @param params Optional flags controlling which side effects the reload performs.
5861
+ * @returns Authoritative session connector state. Account IDs are opaque routing identifiers and credentials are never included.
5359
5862
  */
5360
- reload: async (params) => connection.sendRequest("session.plugins.reload", { sessionId, ...params })
5361
- },
5362
- /** @experimental */
5363
- provider: {
5863
+ getStatus: async () => connection.sendRequest("session.connectors.getStatus", { sessionId }),
5364
5864
  /**
5365
- * Returns the provider endpoint and credentials the session is currently configured to talk to, so the caller can make inference calls directly against the same backend the session uses.
5865
+ * Returns the cached Connector catalog for the pinned opaque account selection, fetching it only when this session has no cached catalog.
5366
5866
  *
5367
- * @param params Optional model identifier to scope the endpoint snapshot to.
5867
+ * @param params Pins a Connector operation to one host-owned GitHub account through its opaque selection ID. Provider tokens are never accepted.
5368
5868
  *
5369
- * @returns A snapshot of the provider endpoint the session is currently configured to talk to.
5869
+ * @returns Validated Connector catalog snapshot cached by the session.
5370
5870
  */
5371
- getEndpoint: async (params) => connection.sendRequest("session.provider.getEndpoint", { sessionId, ...params }),
5871
+ list: async (params) => connection.sendRequest("session.connectors.list", { sessionId, ...params }),
5372
5872
  /**
5373
- * Adds BYOK providers and/or models to the session's registry at runtime, extending the additive registry built from the session's `providers`/`models` options. Both fields are optional, so a call may add providers only, models only, or both. Within a single call providers are registered before models, so a model may reference a provider added in the same call; across calls a model may reference any provider already registered (from session creation or a prior add). A model whose referenced provider is not registered by the end of the call is rejected. Newly added models become selectable via `model.list` / `model.switchTo` and are inherited by sub-agents spawned afterwards.
5873
+ * Refreshes and validates the Connector catalog for the pinned opaque account selection.
5374
5874
  *
5375
- * @param params BYOK providers and/or models to add to the session's registry at runtime. Both fields are optional; provide providers, models, or both.
5875
+ * @param params Pins a Connector operation to one host-owned GitHub account through its opaque selection ID. Provider tokens are never accepted.
5376
5876
  *
5377
- * @returns The selectable model entries synthesized for the models added by this call.
5877
+ * @returns Validated Connector catalog snapshot cached by the session.
5378
5878
  */
5379
- add: async (params) => connection.sendRequest("session.provider.add", { sessionId, ...params })
5380
- },
5381
- /** @experimental */
5382
- options: {
5879
+ refresh: async (params) => connection.sendRequest("session.connectors.refresh", { sessionId, ...params }),
5383
5880
  /**
5384
- * Patches the genuinely-mutable subset of session options.
5881
+ * Initiates an idempotent Connector connection request without opening a browser. Returns connected when the service is immediately authoritative, consent_required with a validated URL, or pending with an opaque continuation ID.
5385
5882
  *
5386
- * @param params Patch of mutable session options to apply to the running session.
5883
+ * @param params Selects one Connector and the pinned host-owned account used for its service and MCP authorization.
5387
5884
  *
5388
- * @returns Indicates whether the session options patch was applied successfully.
5885
+ * @returns Typed result of initiating or continuing a Connector connection.
5389
5886
  */
5390
- update: async (params) => connection.sendRequest("session.options.update", { sessionId, ...params })
5391
- },
5392
- /** @experimental */
5393
- lsp: {
5887
+ connect: async (params) => connection.sendRequest("session.connectors.connect", { sessionId, ...params }),
5394
5888
  /**
5395
- * Loads the merged LSP configuration set for the session's working directory.
5889
+ * Re-initiates an idempotent Connector connection request without browser or UI effects, with the same typed outcomes as connect.
5396
5890
  *
5397
- * @param params Parameters for (re)loading the merged LSP configuration set.
5891
+ * @param params Selects one Connector and the pinned host-owned account used for its service and MCP authorization.
5892
+ *
5893
+ * @returns Typed result of initiating or continuing a Connector connection.
5398
5894
  */
5399
- initialize: async (params) => connection.sendRequest("session.lsp.initialize", { sessionId, ...params })
5400
- },
5401
- /** @experimental */
5402
- extensions: {
5895
+ reconnect: async (params) => connection.sendRequest("session.connectors.reconnect", { sessionId, ...params }),
5403
5896
  /**
5404
- * Lists extensions discovered for the session and their current status.
5897
+ * Continues a pending Connector connection with caller-supplied attempt, interval, and deadline bounds. The runtime never opens the returned consent URL.
5405
5898
  *
5406
- * @returns Extensions discovered for the session, with their current status.
5899
+ * @param params Explicitly bounded continuation of a pending Connector connection.
5900
+ *
5901
+ * @returns Typed result of initiating or continuing a Connector connection.
5407
5902
  */
5408
- list: async () => connection.sendRequest("session.extensions.list", { sessionId }),
5903
+ continueConnection: async (params) => connection.sendRequest("session.connectors.continueConnection", { sessionId, ...params }),
5409
5904
  /**
5410
- * Enables an extension for the session.
5905
+ * Disconnects one Connector for the pinned opaque account selection, refreshes the authoritative catalog, and removes its session-owned MCP projection.
5411
5906
  *
5412
- * @param params Source-qualified extension identifier to enable for the session.
5907
+ * @param params Selects one Connector and the pinned host-owned account used for its service and MCP authorization.
5908
+ *
5909
+ * @returns Authoritative result after disconnect and MCP reconciliation.
5413
5910
  */
5414
- enable: async (params) => connection.sendRequest("session.extensions.enable", { sessionId, ...params }),
5911
+ disconnect: async (params) => connection.sendRequest("session.connectors.disconnect", { sessionId, ...params }),
5415
5912
  /**
5416
- * Disables an extension for the session.
5913
+ * Reconciles the authoritative cached or freshly requested Connector catalog into the session Connector MCP projection and returns live status.
5417
5914
  *
5418
- * @param params Source-qualified extension identifier to disable for the session.
5915
+ * @param params Requests authoritative Connector-to-MCP reconciliation for the pinned account.
5916
+ *
5917
+ * @returns Authoritative session connector state. Account IDs are opaque routing identifiers and credentials are never included.
5419
5918
  */
5420
- disable: async (params) => connection.sendRequest("session.extensions.disable", { sessionId, ...params }),
5919
+ reconcile: async (params) => connection.sendRequest("session.connectors.reconcile", { sessionId, ...params })
5920
+ },
5921
+ /** @experimental */
5922
+ managedSettings: {
5421
5923
  /**
5422
- * Reloads extension definitions and processes for the session.
5924
+ * Waits for the live session's in-flight managed-settings application, then returns the retained effective snapshot used by runtime enforcement and by `session.managed_settings_resolved`. It does not perform another account, device, or server resolution, and rejects when resolution has not produced a snapshot.
5925
+ *
5926
+ * @returns Enterprise managed-settings resolution: the effective managed settings the session applied and which channels contributed, so SDK clients can show users what is enterprise-managed. Fires whenever managed policy is (re)applied — at session start, on resume, and on account switch. This is an ephemeral live snapshot (delivered to subscribers but not persisted to the session event log), because at session start it resolves before `session.start` is emitted. Device values take precedence over server values, then the policy helper, per ordinary key, while permissions compose restrictively across device, server, policy-helper, and SDK-client layers. The account-scoped `getManagedSettings()` API does not include session-local client injection. Marked experimental while the managed-settings surface stabilizes.
5423
5927
  */
5424
- reload: async () => connection.sendRequest("session.extensions.reload", { sessionId }),
5928
+ get: async () => connection.sendRequest("session.managedSettings.get", { sessionId })
5929
+ },
5930
+ /** @experimental */
5931
+ plugins: {
5932
+ /**
5933
+ * Lists globally installed, live, built-in, and enterprise-managed desired plugins using the live session's authoritative account, working directory, and retained managed policy.
5934
+ *
5935
+ * @returns Plugins installed for the session, with their enabled state and version metadata.
5936
+ */
5937
+ list: async () => connection.sendRequest("session.plugins.list", { sessionId }),
5938
+ /**
5939
+ * Installs a plugin using the live session's authoritative account, working directory, and retained managed policy.
5940
+ *
5941
+ * @param params Plugin source resolved relative to the session's authoritative working directory.
5942
+ *
5943
+ * @returns Result of installing a plugin.
5944
+ */
5945
+ install: async (params) => connection.sendRequest("session.plugins.install", { sessionId, ...params }),
5946
+ /**
5947
+ * Uninstalls a plugin when permitted by the live session's retained managed policy.
5948
+ *
5949
+ * @param params Name (or spec) of the plugin to uninstall.
5950
+ */
5951
+ uninstall: async (params) => connection.sendRequest("session.plugins.uninstall", { sessionId, ...params }),
5952
+ /**
5953
+ * Updates an installed plugin using the live session's authoritative account, working directory, and retained managed policy.
5954
+ *
5955
+ * @param params Name (or spec) of the plugin to update.
5956
+ *
5957
+ * @returns Result of updating a single plugin.
5958
+ */
5959
+ update: async (params) => connection.sendRequest("session.plugins.update", { sessionId, ...params }),
5960
+ /**
5961
+ * Enables installed plugins when permitted by the live session's retained managed policy.
5962
+ *
5963
+ * @param params Plugin names (or specs) to enable in the session's authoritative working directory.
5964
+ */
5965
+ enable: async (params) => connection.sendRequest("session.plugins.enable", { sessionId, ...params }),
5966
+ /**
5967
+ * Disables installed plugins when permitted by the live session's retained managed policy.
5968
+ *
5969
+ * @param params Plugin names (or specs) to disable in the session's authoritative working directory.
5970
+ */
5971
+ disable: async (params) => connection.sendRequest("session.plugins.disable", { sessionId, ...params }),
5972
+ /** @experimental */
5973
+ marketplaces: {
5974
+ /**
5975
+ * Lists registered and enterprise-managed desired marketplaces using the live session's retained policy.
5976
+ *
5977
+ * @returns All registered marketplaces, including built-in defaults.
5978
+ */
5979
+ list: async () => connection.sendRequest("session.plugins.marketplaces.list", { sessionId }),
5980
+ /**
5981
+ * Adds a marketplace when permitted by the live session's retained managed policy.
5982
+ *
5983
+ * @param params Marketplace source and optional working directory for relative-path resolution.
5984
+ *
5985
+ * @returns Result of registering a new marketplace.
5986
+ */
5987
+ add: async (params) => connection.sendRequest("session.plugins.marketplaces.add", { sessionId, ...params }),
5988
+ /**
5989
+ * Removes a marketplace when permitted by the live session's retained managed policy.
5990
+ *
5991
+ * @param params Name of the marketplace to remove and an optional force flag.
5992
+ *
5993
+ * @returns Outcome of the remove attempt, including dependent-plugin info when applicable.
5994
+ */
5995
+ remove: async (params) => connection.sendRequest("session.plugins.marketplaces.remove", { sessionId, ...params }),
5996
+ /**
5997
+ * Browses a marketplace resolved through the live session's working directory and retained managed policy.
5998
+ *
5999
+ * @param params Name of the marketplace whose plugin catalog to fetch.
6000
+ *
6001
+ * @returns Plugins advertised by the marketplace.
6002
+ */
6003
+ browse: async (params) => connection.sendRequest("session.plugins.marketplaces.browse", { sessionId, ...params }),
6004
+ /**
6005
+ * Refreshes marketplaces resolved through the live session's working directory and retained managed policy.
6006
+ *
6007
+ * @param params Optional marketplace name; omit to refresh all.
6008
+ *
6009
+ * @returns Result of refreshing one or more marketplace catalogs.
6010
+ */
6011
+ refresh: async (params) => connection.sendRequest("session.plugins.marketplaces.refresh", { sessionId, ...params })
6012
+ },
6013
+ /**
6014
+ * Reloads the session's plugin set, refreshing MCP servers, custom agents, hooks, and skills cache so SDK-driven changes via `server.plugins.*` take effect immediately.
6015
+ *
6016
+ * @param params Optional flags controlling which side effects the reload performs.
6017
+ */
6018
+ reload: async (params) => connection.sendRequest("session.plugins.reload", { sessionId, ...params })
6019
+ },
6020
+ /** @experimental */
6021
+ provider: {
6022
+ /**
6023
+ * Returns the provider endpoint and credentials the session is currently configured to talk to, so the caller can make inference calls directly against the same backend the session uses.
6024
+ *
6025
+ * @param params Optional model identifier to scope the endpoint snapshot to.
6026
+ *
6027
+ * @returns A snapshot of the provider endpoint the session is currently configured to talk to.
6028
+ */
6029
+ getEndpoint: async (params) => connection.sendRequest("session.provider.getEndpoint", { sessionId, ...params }),
6030
+ /**
6031
+ * Adds BYOK providers and/or models to the session's registry at runtime, extending the additive registry built from the session's `providers`/`models` options. Both fields are optional, so a call may add providers only, models only, or both. Within a single call providers are registered before models, so a model may reference a provider added in the same call; across calls a model may reference any provider already registered (from session creation or a prior add). A model whose referenced provider is not registered by the end of the call is rejected. Newly added models become selectable via `model.list` / `model.switchTo` and are inherited by sub-agents spawned afterwards.
6032
+ *
6033
+ * @param params BYOK providers and/or models to add to the session's registry at runtime. Both fields are optional; provide providers, models, or both.
6034
+ *
6035
+ * @returns The selectable model entries synthesized for the models added by this call.
6036
+ */
6037
+ add: async (params) => connection.sendRequest("session.provider.add", { sessionId, ...params }),
6038
+ /**
6039
+ * Atomically updates the session's BYOK provider and model registry by applying the supplied snapshot, replacing existing entries, updating models, or removing entries absent from the snapshot.
6040
+ *
6041
+ * @param params Authoritative BYOK provider and model registry snapshot to apply atomically to the session.
6042
+ *
6043
+ * @returns The selectable model entries and selection ids synthesized for the synchronized BYOK models.
6044
+ */
6045
+ sync: async (params) => connection.sendRequest("session.provider.sync", { sessionId, ...params })
6046
+ },
6047
+ /** @experimental */
6048
+ options: {
6049
+ /**
6050
+ * Patches the genuinely-mutable subset of session options.
6051
+ *
6052
+ * @param params Patch of mutable session options to apply to the running session.
6053
+ *
6054
+ * @returns Indicates whether the session options patch was applied successfully.
6055
+ */
6056
+ update: async (params) => connection.sendRequest("session.options.update", { sessionId, ...params })
6057
+ },
6058
+ /** @experimental */
6059
+ lsp: {
6060
+ /**
6061
+ * Loads the merged LSP configuration set for the session's working directory.
6062
+ *
6063
+ * @param params Parameters for (re)loading the merged LSP configuration set.
6064
+ */
6065
+ initialize: async (params) => connection.sendRequest("session.lsp.initialize", { sessionId, ...params })
6066
+ },
6067
+ /** @experimental */
6068
+ extensions: {
6069
+ /**
6070
+ * Lists extensions discovered for the session and their current status.
6071
+ *
6072
+ * @returns Extensions discovered for the session, with their current status.
6073
+ */
6074
+ list: async () => connection.sendRequest("session.extensions.list", { sessionId }),
6075
+ /**
6076
+ * Enables an extension for the session.
6077
+ *
6078
+ * @param params Source-qualified extension identifier to enable for the session.
6079
+ */
6080
+ enable: async (params) => connection.sendRequest("session.extensions.enable", { sessionId, ...params }),
6081
+ /**
6082
+ * Disables an extension for the session.
6083
+ *
6084
+ * @param params Source-qualified extension identifier to disable for the session.
6085
+ */
6086
+ disable: async (params) => connection.sendRequest("session.extensions.disable", { sessionId, ...params }),
6087
+ /**
6088
+ * Reloads extension definitions and processes for the session.
6089
+ */
6090
+ reload: async () => connection.sendRequest("session.extensions.reload", { sessionId }),
5425
6091
  /**
5426
6092
  * Push attachments into the next user-message turn from an extension. The host should surface them as composer pills and forward them via the next session.send call. Callable only by extension-owned connections.
5427
6093
  *
@@ -5702,9 +6368,9 @@ function createSessionRpc(connection, sessionId) {
5702
6368
  */
5703
6369
  setRequired: async (params) => connection.sendRequest("session.permissions.setRequired", { sessionId, ...params }),
5704
6370
  /**
5705
- * Clears session-scoped tool permission approvals.
6371
+ * Clears session-scoped tool approvals and, for full resets, exact session-approved paths.
5706
6372
  *
5707
- * @param params Clears session-scoped tool permission approvals, and optionally the location-scoped ones.
6373
+ * @param params Clears session-scoped tool approvals and optionally clears location-scoped approvals and exact session-approved paths.
5708
6374
  *
5709
6375
  * @returns Indicates whether the operation succeeded.
5710
6376
  */
@@ -5720,9 +6386,9 @@ function createSessionRpc(connection, sessionId) {
5720
6386
  /** @experimental */
5721
6387
  paths: {
5722
6388
  /**
5723
- * Returns the session's allowed directories and primary working directory.
6389
+ * Returns the session's recursive directory grants, exact session-approved paths, and primary working directory.
5724
6390
  *
5725
- * @returns Snapshot of the session's allow-listed directories and primary working directory.
6391
+ * @returns Snapshot of the session's recursive directory grants, exact session-approved paths, and primary working directory.
5726
6392
  */
5727
6393
  list: async () => connection.sendRequest("session.permissions.paths.list", { sessionId }),
5728
6394
  /**
@@ -6060,6 +6726,22 @@ function createSessionRpc(connection, sessionId) {
6060
6726
  * @returns Result of editing a queued message.
6061
6727
  */
6062
6728
  updateText: async (params) => connection.sendRequest("session.queue.updateText", { sessionId, ...params }),
6729
+ /**
6730
+ * Atomically withdraws an unchanged, unconsumed user message from the local queued or steering lane. A client retaining the original draft may restore it only when removed is true. Does not interrupt the running turn.
6731
+ *
6732
+ * @param params Conditional withdrawal of a single user message, before the runtime claims it for delivery.
6733
+ *
6734
+ * @returns Result of removing a queued item.
6735
+ */
6736
+ withdrawMessage: async (params) => connection.sendRequest("session.queue.withdrawMessage", { sessionId, ...params }),
6737
+ /**
6738
+ * Atomically appends text and attachments to an unchanged, unconsumed local steering message. Returns updated=false if delivery or withdrawal already claimed the message.
6739
+ *
6740
+ * @param params Append to one pending steering message without changing its identity or delivery position.
6741
+ *
6742
+ * @returns Result of editing a queued message.
6743
+ */
6744
+ appendSteering: async (params) => connection.sendRequest("session.queue.appendSteering", { sessionId, ...params }),
6063
6745
  /**
6064
6746
  * Duplicates an addressable queued item immediately after its source.
6065
6747
  *
@@ -6314,6 +6996,31 @@ function createInternalSessionRpc(connection, sessionId) {
6314
6996
  pauseAtCheckpoint: async (params) => connection.sendRequest("session.factory.pauseAtCheckpoint", { sessionId, ...params })
6315
6997
  },
6316
6998
  /** @experimental */
6999
+ workflow: {
7000
+ /**
7001
+ * Internal tool-originated dynamic workflow invocation.
7002
+ *
7003
+ * @param params Internal parameters for invoking a registered workflow from a tool.
7004
+ *
7005
+ * @returns Complete current or terminal workflow run envelope.
7006
+ */
7007
+ runFromTool: async (params) => connection.sendRequest("session.workflow.runFromTool", { sessionId, ...params }),
7008
+ /**
7009
+ * Internal tool-originated dynamic workflow resume.
7010
+ *
7011
+ * @param params Internal parameters for resuming a workflow run from a tool.
7012
+ *
7013
+ * @returns Resolved persisted workflow identity and resumed run envelope.
7014
+ */
7015
+ resumeFromTool: async (params) => connection.sendRequest("session.workflow.resumeFromTool", { sessionId, ...params }),
7016
+ /**
7017
+ * Atomically pauses an owned dynamic workflow attempt at a durable checkpoint.
7018
+ *
7019
+ * @param params Parameters for an owned durable pause checkpoint.
7020
+ */
7021
+ pauseAtCheckpoint: async (params) => connection.sendRequest("session.workflow.pauseAtCheckpoint", { sessionId, ...params })
7022
+ },
7023
+ /** @experimental */
6317
7024
  model: {
6318
7025
  /**
6319
7026
  * Resolves and applies organization-managed and repository model overlays.
@@ -6356,6 +7063,23 @@ function createInternalSessionRpc(connection, sessionId) {
6356
7063
  unregisterExternalClient: async (params) => connection.sendRequest("session.mcp.unregisterExternalClient", { sessionId, ...params })
6357
7064
  },
6358
7065
  /** @experimental */
7066
+ connectors: {
7067
+ /**
7068
+ * Reconciles the authoritative Connector catalog into the session MCP projection during startup with a bounded deadline and fail-closed cleanup.
7069
+ *
7070
+ * @param params Pins a Connector operation to one host-owned GitHub account through its opaque selection ID. Provider tokens are never accepted.
7071
+ *
7072
+ * @returns Authoritative session connector state. Account IDs are opaque routing identifiers and credentials are never included.
7073
+ */
7074
+ reconcileForStartup: async (params) => connection.sendRequest("session.connectors.reconcileForStartup", { sessionId, ...params }),
7075
+ /**
7076
+ * Removes the runtime-owned Connector MCP projection without changing service-side connections.
7077
+ *
7078
+ * @returns Authoritative session connector state. Account IDs are opaque routing identifiers and credentials are never included.
7079
+ */
7080
+ withdrawProjection: async () => connection.sendRequest("session.connectors.withdrawProjection", { sessionId })
7081
+ },
7082
+ /** @experimental */
6359
7083
  commands: {
6360
7084
  /**
6361
7085
  * Finalizes persistence associated with a client-applied slash-command effect.
@@ -6509,6 +7233,16 @@ function registerClientSessionApiHandlers(connection, getHandlers) {
6509
7233
  if (!handler) throw new Error(`No factory handler registered for session: ${params.sessionId}`);
6510
7234
  return handler.abort(params);
6511
7235
  });
7236
+ connection.onRequest("workflow.execute", async (params) => {
7237
+ const handler = getHandlers(params.sessionId).workflow;
7238
+ if (!handler) throw new Error(`No workflow handler registered for session: ${params.sessionId}`);
7239
+ return handler.execute(params);
7240
+ });
7241
+ connection.onRequest("workflow.abort", async (params) => {
7242
+ const handler = getHandlers(params.sessionId).workflow;
7243
+ if (!handler) throw new Error(`No workflow handler registered for session: ${params.sessionId}`);
7244
+ return handler.abort(params);
7245
+ });
6512
7246
  connection.onRequest("tasks.cancel", async (params) => {
6513
7247
  const handler = getHandlers(params.sessionId).tasks;
6514
7248
  if (!handler) throw new Error(`No tasks handler registered for session: ${params.sessionId}`);
@@ -6623,17 +7357,17 @@ function registerClientGlobalApiHandlers(connection, handlers) {
6623
7357
  });
6624
7358
  }
6625
7359
 
6626
- // node_modules/.pnpm/@github+copilot-sdk@1.0.14-preview.1/node_modules/@github/copilot-sdk/dist/sdkProtocolVersion.js
7360
+ // src/sdk/nodejs/dist/sdkProtocolVersion.js
6627
7361
  var SDK_PROTOCOL_VERSION = 3;
6628
7362
  function getSdkProtocolVersion() {
6629
7363
  return SDK_PROTOCOL_VERSION;
6630
7364
  }
6631
7365
 
6632
- // node_modules/.pnpm/@github+copilot-sdk@1.0.14-preview.1/node_modules/@github/copilot-sdk/dist/session.js
7366
+ // src/sdk/nodejs/dist/session.js
6633
7367
  var import_node = __toESM(require_node(), 1);
6634
7368
  import { AsyncLocalStorage } from "node:async_hooks";
6635
7369
 
6636
- // node_modules/.pnpm/@github+copilot-sdk@1.0.14-preview.1/node_modules/@github/copilot-sdk/dist/canvas.js
7370
+ // src/sdk/nodejs/dist/canvas.js
6637
7371
  var CanvasError = class _CanvasError extends Error {
6638
7372
  constructor(code, message) {
6639
7373
  super(message);
@@ -6680,7 +7414,7 @@ function createCanvas(options) {
6680
7414
  return new Canvas(options);
6681
7415
  }
6682
7416
 
6683
- // node_modules/.pnpm/@github+copilot-sdk@1.0.14-preview.1/node_modules/@github/copilot-sdk/dist/telemetry.js
7417
+ // src/sdk/nodejs/dist/telemetry.js
6684
7418
  async function getTraceContext(provider) {
6685
7419
  if (!provider) return {};
6686
7420
  try {
@@ -6690,7 +7424,18 @@ async function getTraceContext(provider) {
6690
7424
  }
6691
7425
  }
6692
7426
 
6693
- // node_modules/.pnpm/@github+copilot-sdk@1.0.14-preview.1/node_modules/@github/copilot-sdk/dist/sessionFsProvider.js
7427
+ // src/sdk/nodejs/dist/schema.js
7428
+ function isZodSchema(value) {
7429
+ return typeof value === "object" && value !== null && "toJSONSchema" in value && typeof value.toJSONSchema === "function";
7430
+ }
7431
+ function toJsonSchema(schema) {
7432
+ return isZodSchema(schema) ? schema.toJSONSchema() : schema;
7433
+ }
7434
+ function isResponseSchema(value) {
7435
+ return isZodSchema(value) && "parse" in value && typeof value.parse === "function";
7436
+ }
7437
+
7438
+ // src/sdk/nodejs/dist/sessionFsProvider.js
6694
7439
  var SessionFsSqliteTransactionFailure = class extends Error {
6695
7440
  /** Failure classification reported to the runtime. */
6696
7441
  errorClass;
@@ -6861,9 +7606,10 @@ function toSqliteTransactionError(err) {
6861
7606
  };
6862
7607
  }
6863
7608
 
6864
- // node_modules/.pnpm/@github+copilot-sdk@1.0.14-preview.1/node_modules/@github/copilot-sdk/dist/copilotRequestHandler.js
7609
+ // src/sdk/nodejs/dist/copilotRequestHandler.js
6865
7610
  var sharedTextDecoder = new TextDecoder("utf-8", { fatal: false });
6866
7611
  var sharedTextEncoder = new TextEncoder();
7612
+ var HTTP_RESPONSE_READ_AHEAD_BYTES = 32 * 1024;
6867
7613
  var kBridge = /* @__PURE__ */ Symbol("copilotWebSocketResponseBridge");
6868
7614
  var kCompletion = /* @__PURE__ */ Symbol("copilotWebSocketCompletion");
6869
7615
  var kOpen = /* @__PURE__ */ Symbol("copilotWebSocketOpen");
@@ -7102,7 +7848,9 @@ function createCopilotRequestAdapter(handler, getServerRpc) {
7102
7848
  const message = err instanceof Error ? err.message : String(err);
7103
7849
  await finalize(exchange, 502, message);
7104
7850
  } finally {
7105
- pending.delete(exchange.requestId);
7851
+ if (pending.get(exchange.requestId) === exchange) {
7852
+ pending.delete(exchange.requestId);
7853
+ }
7106
7854
  }
7107
7855
  }
7108
7856
  return {
@@ -7115,6 +7863,13 @@ function createCopilotRequestAdapter(handler, getServerRpc) {
7115
7863
  async httpRequestChunk(params) {
7116
7864
  routeChunk(getOrCreate(params.requestId), params);
7117
7865
  return {};
7866
+ },
7867
+ cancelPending() {
7868
+ const exchanges = [...pending.values()];
7869
+ pending.clear();
7870
+ for (const exchange of exchanges) {
7871
+ exchange.pushCancel("RPC connection closed");
7872
+ }
7118
7873
  }
7119
7874
  };
7120
7875
  }
@@ -7363,32 +8118,158 @@ async function drainAsync(stream) {
7363
8118
  return out;
7364
8119
  }
7365
8120
  async function streamResponse(response, exchange) {
7366
- await exchange.startResponse({
7367
- status: response.status,
7368
- statusText: response.statusText || void 0,
7369
- headers: headersToMultiMap(response.headers)
7370
- });
7371
- const body = response.body;
7372
- if (!body) {
7373
- await exchange.endResponse();
7374
- return;
7375
- }
7376
- const reader = body.getReader();
8121
+ const reader = response.body ? new HttpResponseReader(response.body, exchange.signal) : void 0;
7377
8122
  try {
7378
- for (; ; ) {
7379
- const { value, done } = await reader.read();
7380
- if (done) {
7381
- break;
7382
- }
7383
- if (value && value.byteLength > 0) {
7384
- await exchange.writeResponse(value);
8123
+ await exchange.startResponse({
8124
+ status: response.status,
8125
+ statusText: response.statusText || void 0,
8126
+ headers: headersToMultiMap(response.headers)
8127
+ });
8128
+ if (reader) {
8129
+ for (; ; ) {
8130
+ const chunk = await reader.nextChunk();
8131
+ if (!chunk) {
8132
+ break;
8133
+ }
8134
+ await exchange.writeResponse(chunk);
7385
8135
  }
7386
8136
  }
7387
8137
  await exchange.endResponse();
7388
8138
  } finally {
7389
- reader.releaseLock();
8139
+ await reader?.dispose();
7390
8140
  }
7391
8141
  }
8142
+ var HttpResponseReader = class {
8143
+ #reader;
8144
+ #signal;
8145
+ #frames = [];
8146
+ #pump;
8147
+ #onAbort;
8148
+ #queued = 0;
8149
+ #done = false;
8150
+ #cancelled = false;
8151
+ #hasError = false;
8152
+ #error;
8153
+ #dataWaker;
8154
+ #spaceWaker;
8155
+ #cancelPromise;
8156
+ constructor(body, signal) {
8157
+ this.#reader = body.getReader();
8158
+ this.#signal = signal;
8159
+ this.#onAbort = () => {
8160
+ void this.cancel(signal.reason);
8161
+ };
8162
+ signal.addEventListener("abort", this.#onAbort, { once: true });
8163
+ this.#pump = this.#pumpSource();
8164
+ if (signal.aborted) {
8165
+ this.#onAbort();
8166
+ }
8167
+ }
8168
+ async nextChunk() {
8169
+ while (this.#frames.length === 0 && !this.#done && !this.#hasError) {
8170
+ await new Promise((resolve3) => {
8171
+ this.#dataWaker = resolve3;
8172
+ });
8173
+ }
8174
+ if (this.#frames.length > 0) {
8175
+ const chunk = this.#takeQueued();
8176
+ this.#wakeSpace();
8177
+ return chunk;
8178
+ }
8179
+ if (this.#hasError) {
8180
+ this.#hasError = false;
8181
+ throw this.#error;
8182
+ }
8183
+ return void 0;
8184
+ }
8185
+ #takeQueued() {
8186
+ const frames = this.#frames;
8187
+ const total = this.#queued;
8188
+ this.#queued = 0;
8189
+ if (frames.length === 1) {
8190
+ return frames.pop();
8191
+ }
8192
+ const chunk = new Uint8Array(total);
8193
+ let offset = 0;
8194
+ for (const frame of frames) {
8195
+ chunk.set(frame, offset);
8196
+ offset += frame.byteLength;
8197
+ }
8198
+ frames.length = 0;
8199
+ return chunk;
8200
+ }
8201
+ async dispose() {
8202
+ this.#signal.removeEventListener("abort", this.#onAbort);
8203
+ if (!this.#done) {
8204
+ await this.cancel();
8205
+ } else if (this.#cancelPromise) {
8206
+ await this.#cancelPromise;
8207
+ }
8208
+ await this.#pump;
8209
+ }
8210
+ cancel(reason) {
8211
+ if (this.#done) {
8212
+ return Promise.resolve();
8213
+ }
8214
+ if (!this.#cancelPromise) {
8215
+ this.#cancelled = true;
8216
+ this.#done = true;
8217
+ this.#hasError = true;
8218
+ this.#error = reason instanceof Error ? reason : new Error("HTTP response body cancelled.");
8219
+ this.#frames.length = 0;
8220
+ this.#queued = 0;
8221
+ this.#wakeData();
8222
+ this.#wakeSpace();
8223
+ this.#cancelPromise = this.#reader.cancel(reason).catch(() => void 0);
8224
+ }
8225
+ return this.#cancelPromise;
8226
+ }
8227
+ async #pumpSource() {
8228
+ try {
8229
+ while (!this.#cancelled) {
8230
+ while (this.#queued >= HTTP_RESPONSE_READ_AHEAD_BYTES && !this.#cancelled) {
8231
+ await new Promise((resolve3) => {
8232
+ this.#spaceWaker = resolve3;
8233
+ });
8234
+ }
8235
+ if (this.#cancelled) {
8236
+ return;
8237
+ }
8238
+ const { value, done } = await this.#reader.read();
8239
+ if (done) {
8240
+ return;
8241
+ }
8242
+ if (value.byteLength > 0) {
8243
+ this.#frames.push(value);
8244
+ this.#queued += value.byteLength;
8245
+ this.#wakeData();
8246
+ continue;
8247
+ }
8248
+ await new Promise((resolve3) => setImmediate(resolve3));
8249
+ }
8250
+ } catch (error) {
8251
+ if (!this.#cancelled) {
8252
+ this.#hasError = true;
8253
+ this.#error = error;
8254
+ }
8255
+ } finally {
8256
+ this.#done = true;
8257
+ this.#wakeData();
8258
+ this.#wakeSpace();
8259
+ this.#reader.releaseLock();
8260
+ }
8261
+ }
8262
+ #wakeData() {
8263
+ const waker = this.#dataWaker;
8264
+ this.#dataWaker = void 0;
8265
+ waker?.();
8266
+ }
8267
+ #wakeSpace() {
8268
+ const waker = this.#spaceWaker;
8269
+ this.#spaceWaker = void 0;
8270
+ waker?.();
8271
+ }
8272
+ };
7392
8273
  function headersToMultiMap(headers) {
7393
8274
  const out = {};
7394
8275
  headers.forEach((value, name) => {
@@ -7466,7 +8347,7 @@ var CopilotWebSocketResponseBridge = class {
7466
8347
  }
7467
8348
  };
7468
8349
 
7469
- // node_modules/.pnpm/@github+copilot-sdk@1.0.14-preview.1/node_modules/@github/copilot-sdk/dist/types.js
8350
+ // src/sdk/nodejs/dist/types.js
7470
8351
  function isAttributedPermissionResult(result) {
7471
8352
  return result.kind === "attributed";
7472
8353
  }
@@ -7474,7 +8355,7 @@ var defaultJoinSessionPermissionHandler = () => ({
7474
8355
  kind: "no-result"
7475
8356
  });
7476
8357
 
7477
- // node_modules/.pnpm/@github+copilot-sdk@1.0.14-preview.1/node_modules/@github/copilot-sdk/dist/factory.js
8358
+ // src/sdk/nodejs/dist/factory.js
7478
8359
  var FACTORY_TERMINAL_STATUSES = /* @__PURE__ */ new Set([
7479
8360
  "completed",
7480
8361
  "halted",
@@ -7575,30 +8456,152 @@ function getFactoryDefinition(handle) {
7575
8456
  return definition;
7576
8457
  }
7577
8458
 
7578
- // node_modules/.pnpm/@github+copilot-sdk@1.0.14-preview.1/node_modules/@github/copilot-sdk/dist/session.js
7579
- function isFactoryResumeErrorCode(value) {
7580
- return value === "not_found" || value === "non_resumable" || value === "already_active" || value === "factory_already_running" || value === "factory_limits_invalid" || value === "factory_session_disposed" || value === "factory_storage_unavailable" || value === "factory_storage_corrupt";
8459
+ // src/sdk/nodejs/dist/workflow.js
8460
+ var WORKFLOW_TERMINAL_STATUSES = /* @__PURE__ */ new Set([
8461
+ "completed",
8462
+ "halted",
8463
+ "paused",
8464
+ "cancelled",
8465
+ "error"
8466
+ ]);
8467
+ function isWorkflowRunTerminal(status) {
8468
+ return WORKFLOW_TERMINAL_STATUSES.has(status);
7581
8469
  }
7582
- function copyDefinedFactoryAgentOption(source, target, key) {
7583
- const value = source[key];
7584
- if (value !== void 0) {
7585
- target[key] = value;
8470
+ var WORKFLOW_AGENT_OPTION_KEYS = [
8471
+ "label",
8472
+ "schema",
8473
+ "model",
8474
+ "reasoningEffort",
8475
+ "contextTier",
8476
+ "agent"
8477
+ ];
8478
+ var WorkflowResumeError = class extends Error {
8479
+ constructor(code, message) {
8480
+ super(message);
8481
+ this.code = code;
8482
+ this.name = "WorkflowResumeError";
7586
8483
  }
7587
- }
7588
- var factoryExecutionStore = new AsyncLocalStorage();
7589
- function throwIfFactoryExecutionIsActive() {
7590
- if (factoryExecutionStore.getStore()?.active) {
7591
- throw new Error(
7592
- "factory.run, factory.resume, and factory.pause are not allowed while a factory body is running on this call path."
7593
- );
8484
+ code;
8485
+ };
8486
+ var workflowHandles = /* @__PURE__ */ new WeakMap();
8487
+ var MAX_WORKFLOW_TIMEOUT_SECONDS = 2147483647e-3;
8488
+ var NANO_AIU_PER_AIU2 = 1e9;
8489
+ function deepFreeze2(value) {
8490
+ if (value !== null && typeof value === "object" && !Object.isFrozen(value)) {
8491
+ Object.freeze(value);
8492
+ for (const nested of Object.values(value)) {
8493
+ deepFreeze2(nested);
8494
+ }
7594
8495
  }
8496
+ return value;
7595
8497
  }
7596
- function runInFactoryHelperScope(helperScope, callback) {
7597
- const current = factoryExecutionStore.getStore();
7598
- return factoryExecutionStore.run({ active: current?.active ?? false, helperScope }, callback);
7599
- }
7600
- function deserializeHookInput(raw) {
7601
- if (!raw || typeof raw !== "object" || typeof raw.timestamp !== "number") {
8498
+ function validateLimits2(meta) {
8499
+ const limits = meta.limits;
8500
+ if (!limits) {
8501
+ return;
8502
+ }
8503
+ for (const field of ["maxConcurrentSubagents", "maxTotalSubagents"]) {
8504
+ const value = limits[field];
8505
+ if (value !== void 0 && (!Number.isInteger(value) || value <= 0)) {
8506
+ throw new Error(`Workflow limit "${field}" must be a positive integer`);
8507
+ }
8508
+ }
8509
+ if (limits.timeoutSeconds !== void 0 && (!Number.isFinite(limits.timeoutSeconds) || limits.timeoutSeconds <= 0)) {
8510
+ throw new Error(
8511
+ 'Workflow limit "timeoutSeconds" must be a positive, finite number of seconds'
8512
+ );
8513
+ }
8514
+ if (limits.timeoutSeconds !== void 0 && limits.timeoutSeconds > MAX_WORKFLOW_TIMEOUT_SECONDS) {
8515
+ throw new Error(
8516
+ `Workflow limit "timeoutSeconds" must not exceed ${MAX_WORKFLOW_TIMEOUT_SECONDS} seconds`
8517
+ );
8518
+ }
8519
+ if (limits.maxAiCredits !== void 0) {
8520
+ const maxNanoAiu = Math.round(limits.maxAiCredits * NANO_AIU_PER_AIU2);
8521
+ if (!Number.isFinite(limits.maxAiCredits) || limits.maxAiCredits <= 0 || !Number.isSafeInteger(maxNanoAiu) || maxNanoAiu < 1) {
8522
+ throw new Error(
8523
+ 'Workflow limit "maxAiCredits" must be a positive, finite number that rounds to a safe positive integer nano-AIU ceiling'
8524
+ );
8525
+ }
8526
+ }
8527
+ }
8528
+ function validatePhases2(meta) {
8529
+ const titles = /* @__PURE__ */ new Set();
8530
+ for (const phase of meta.phases) {
8531
+ if (phase.title.trim().length === 0) {
8532
+ throw new Error("Workflow phase titles must not be empty");
8533
+ }
8534
+ if (titles.has(phase.title)) {
8535
+ throw new Error(`Workflow phase title "${phase.title}" is declared more than once`);
8536
+ }
8537
+ titles.add(phase.title);
8538
+ }
8539
+ }
8540
+ function defineWorkflow(definition) {
8541
+ const meta = deepFreeze2(structuredClone(definition.meta));
8542
+ validateLimits2(meta);
8543
+ validatePhases2(meta);
8544
+ const stored = {
8545
+ meta,
8546
+ run: definition.run
8547
+ };
8548
+ const handle = Object.freeze({ meta });
8549
+ workflowHandles.set(handle, stored);
8550
+ return handle;
8551
+ }
8552
+ function getWorkflowDefinition(handle) {
8553
+ const definition = workflowHandles.get(handle);
8554
+ if (!definition) {
8555
+ throw new Error("Invalid workflow handle");
8556
+ }
8557
+ return definition;
8558
+ }
8559
+
8560
+ // src/sdk/nodejs/dist/session.js
8561
+ function isFactoryResumeErrorCode(value) {
8562
+ return value === "not_found" || value === "non_resumable" || value === "already_active" || value === "factory_already_running" || value === "factory_limits_invalid" || value === "factory_session_disposed" || value === "factory_storage_unavailable" || value === "factory_storage_corrupt";
8563
+ }
8564
+ function copyDefinedFactoryAgentOption(source, target, key) {
8565
+ const value = source[key];
8566
+ if (value !== void 0) {
8567
+ target[key] = value;
8568
+ }
8569
+ }
8570
+ function isWorkflowResumeErrorCode(value) {
8571
+ return value === "not_found" || value === "non_resumable" || value === "workflow_run_not_resumable" || value === "already_active" || value === "workflow_already_running" || value === "workflow_limits_invalid" || value === "workflow_session_disposed" || value === "workflow_storage_unavailable" || value === "workflow_storage_corrupt";
8572
+ }
8573
+ function copyDefinedWorkflowAgentOption(source, target, key) {
8574
+ const value = source[key];
8575
+ if (value !== void 0) {
8576
+ target[key] = value;
8577
+ }
8578
+ }
8579
+ var factoryExecutionStore = new AsyncLocalStorage();
8580
+ function throwIfFactoryExecutionIsActive() {
8581
+ if (factoryExecutionStore.getStore()?.active) {
8582
+ throw new Error(
8583
+ "factory.run, factory.resume, and factory.pause are not allowed while a factory body is running on this call path."
8584
+ );
8585
+ }
8586
+ }
8587
+ var workflowExecutionStore = new AsyncLocalStorage();
8588
+ function throwIfWorkflowExecutionIsActive() {
8589
+ if (workflowExecutionStore.getStore()?.active) {
8590
+ throw new Error(
8591
+ "workflow.run, workflow.resume, and workflow.pause are not allowed while a workflow body is running on this call path."
8592
+ );
8593
+ }
8594
+ }
8595
+ function runInWorkflowHelperScope(helperScope, callback) {
8596
+ const current = workflowExecutionStore.getStore();
8597
+ return workflowExecutionStore.run({ active: current?.active ?? false, helperScope }, callback);
8598
+ }
8599
+ function runInFactoryHelperScope(helperScope, callback) {
8600
+ const current = factoryExecutionStore.getStore();
8601
+ return factoryExecutionStore.run({ active: current?.active ?? false, helperScope }, callback);
8602
+ }
8603
+ function deserializeHookInput(raw) {
8604
+ if (!raw || typeof raw !== "object" || typeof raw.timestamp !== "number") {
7602
8605
  return raw;
7603
8606
  }
7604
8607
  const obj = raw;
@@ -7674,6 +8677,54 @@ async function runFactoryPipeline(items, ...stages) {
7674
8677
  })
7675
8678
  );
7676
8679
  }
8680
+ async function runWorkflowParallel(thunks) {
8681
+ if (!Array.isArray(thunks)) {
8682
+ throw new Error(
8683
+ "parallel() expects an array of functions, not promises. Wrap each call: () => agent(...)"
8684
+ );
8685
+ }
8686
+ assertFactoryFanoutSize("parallel", thunks.length);
8687
+ if (thunks.some((thunk) => typeof thunk !== "function")) {
8688
+ throw new Error(
8689
+ "parallel() expects an array of functions, not promises. Wrap each call: () => agent(...)"
8690
+ );
8691
+ }
8692
+ return Promise.all(
8693
+ thunks.map(
8694
+ (thunk) => Promise.resolve().then(() => runInWorkflowHelperScope("parallel", thunk)).catch((error) => {
8695
+ if (isFactoryFatalError(error)) {
8696
+ throw error;
8697
+ }
8698
+ return null;
8699
+ })
8700
+ )
8701
+ );
8702
+ }
8703
+ async function runWorkflowPipeline(items, ...stages) {
8704
+ if (!Array.isArray(items)) {
8705
+ throw new Error("pipeline(items, ...stages): items must be an array");
8706
+ }
8707
+ assertFactoryFanoutSize("pipeline", items.length);
8708
+ return Promise.all(
8709
+ items.map(async (item, index) => {
8710
+ let previous = item;
8711
+ for (const stage of stages) {
8712
+ try {
8713
+ previous = await runInWorkflowHelperScope(
8714
+ "pipeline",
8715
+ () => stage(previous, item, index)
8716
+ );
8717
+ } catch (error) {
8718
+ if (isFactoryFatalError(error)) {
8719
+ throw error;
8720
+ }
8721
+ return null;
8722
+ }
8723
+ }
8724
+ return previous;
8725
+ })
8726
+ );
8727
+ }
7677
8728
  var FactoryProgressBuffer = class {
7678
8729
  constructor(send) {
7679
8730
  this.send = send;
@@ -7753,6 +8804,85 @@ var FactoryProgressBuffer = class {
7753
8804
  }
7754
8805
  }
7755
8806
  };
8807
+ var WorkflowProgressBuffer = class {
8808
+ constructor(send) {
8809
+ this.send = send;
8810
+ }
8811
+ send;
8812
+ nextSeq = 0;
8813
+ pending = [];
8814
+ flushTimer;
8815
+ flushTail = Promise.resolve();
8816
+ flushError;
8817
+ flushFailed = false;
8818
+ closed = false;
8819
+ enqueue(kind, text) {
8820
+ if (this.closed) {
8821
+ throw new Error("Cannot log after the workflow run has settled");
8822
+ }
8823
+ this.pending.push({ seq: this.nextSeq++, kind, text });
8824
+ this.scheduleFlush();
8825
+ }
8826
+ async flush() {
8827
+ this.clearFlushTimer();
8828
+ const lines = this.pending.splice(0);
8829
+ if (lines.length > 0) {
8830
+ this.flushTail = this.flushTail.then(async () => {
8831
+ try {
8832
+ await this.send(lines);
8833
+ } catch (error) {
8834
+ if (!this.flushFailed) {
8835
+ this.flushFailed = true;
8836
+ this.flushError = error;
8837
+ }
8838
+ }
8839
+ });
8840
+ }
8841
+ await this.flushTail;
8842
+ if (this.flushFailed) {
8843
+ throw this.flushError;
8844
+ }
8845
+ }
8846
+ async close() {
8847
+ this.closed = true;
8848
+ this.clearFlushTimer();
8849
+ const lines = this.pending.splice(0);
8850
+ await this.flushTail;
8851
+ if (this.flushFailed) {
8852
+ console.warn(
8853
+ "Ignoring a background workflow progress flush failure after the workflow body settled",
8854
+ this.flushError
8855
+ );
8856
+ }
8857
+ if (lines.length > 0) {
8858
+ try {
8859
+ await this.send(lines);
8860
+ } catch (error) {
8861
+ console.warn(
8862
+ "Failed to flush final workflow progress after the workflow body settled",
8863
+ error
8864
+ );
8865
+ }
8866
+ }
8867
+ }
8868
+ scheduleFlush() {
8869
+ if (this.flushTimer !== void 0) {
8870
+ return;
8871
+ }
8872
+ this.flushTimer = setTimeout(() => {
8873
+ this.flushTimer = void 0;
8874
+ void this.flush().catch(() => {
8875
+ });
8876
+ }, FACTORY_LOG_FLUSH_DELAY_MS);
8877
+ this.flushTimer.unref?.();
8878
+ }
8879
+ clearFlushTimer() {
8880
+ if (this.flushTimer !== void 0) {
8881
+ clearTimeout(this.flushTimer);
8882
+ this.flushTimer = void 0;
8883
+ }
8884
+ }
8885
+ };
7756
8886
  async function awaitFactoryOperation(operation, signal) {
7757
8887
  let rejectAbort;
7758
8888
  const abortPromise = new Promise((_resolve, reject) => {
@@ -7767,11 +8897,19 @@ async function awaitFactoryOperation(operation, signal) {
7767
8897
  signal.removeEventListener("abort", onAbort);
7768
8898
  }
7769
8899
  }
8900
+ async function awaitWorkflowOperation(operation, signal) {
8901
+ return awaitFactoryOperation(operation, signal);
8902
+ }
7770
8903
  function throwIfFactoryAborted(signal) {
7771
8904
  if (signal.aborted) {
7772
8905
  throw signal.reason ?? new DOMException("Factory run was aborted", "AbortError");
7773
8906
  }
7774
8907
  }
8908
+ function throwIfWorkflowAborted(signal) {
8909
+ if (signal.aborted) {
8910
+ throw signal.reason ?? new DOMException("Workflow run was aborted", "AbortError");
8911
+ }
8912
+ }
7775
8913
  function isFactoryAbortError(error) {
7776
8914
  return typeof error === "object" && error !== null && "name" in error && error.name === "AbortError";
7777
8915
  }
@@ -7810,6 +8948,8 @@ var CopilotSession = class {
7810
8948
  commandHandlers = /* @__PURE__ */ new Map();
7811
8949
  factories = /* @__PURE__ */ new Map();
7812
8950
  factoryAbortControllers = /* @__PURE__ */ new Map();
8951
+ workflows = /* @__PURE__ */ new Map();
8952
+ workflowAbortControllers = /* @__PURE__ */ new Map();
7813
8953
  permissionHandler;
7814
8954
  mcpAuthHandler;
7815
8955
  userInputHandler;
@@ -7825,6 +8965,7 @@ var CopilotSession = class {
7825
8965
  _capabilities = {};
7826
8966
  openCanvasInstances = [];
7827
8967
  disconnected = false;
8968
+ pendingStructuredWaits = /* @__PURE__ */ new Set();
7828
8969
  disconnecting = false;
7829
8970
  onDisconnected;
7830
8971
  /** @internal Client session API handlers, populated by CopilotClient during create/resume. */
@@ -7874,39 +9015,169 @@ var CopilotSession = class {
7874
9015
  throw new FactoryResumeError(code, error.message);
7875
9016
  }
7876
9017
  }
7877
- throw error;
9018
+ throw error;
9019
+ }
9020
+ return this.settleFactoryRun(response.run);
9021
+ }),
9022
+ getRun: async (runId) => this.rpc.factory.getRun({ runId }),
9023
+ waitForRun: (runId, options) => this.waitForFactoryRun(runId, options?.signal),
9024
+ listRuns: (async (options) => {
9025
+ const page = await this.rpc.factory.listRuns(options ?? {});
9026
+ return options === void 0 ? page.runs : page;
9027
+ }),
9028
+ getRunDetail: (runId) => this.rpc.factory.getRunDetail({ runId }),
9029
+ getRunProgress: (runId, options = {}) => this.rpc.factory.getRunProgress({ runId, ...options }),
9030
+ pause: async (runId) => {
9031
+ throwIfFactoryExecutionIsActive();
9032
+ return this.rpc.factory.pause({ runId });
9033
+ },
9034
+ cancel: async (runId) => this.rpc.factory.cancel({ runId })
9035
+ };
9036
+ workflow = {
9037
+ run: (async (nameOrHandle, options) => {
9038
+ throwIfWorkflowExecutionIsActive();
9039
+ const name = typeof nameOrHandle === "string" ? nameOrHandle : getWorkflowDefinition(nameOrHandle).meta.name;
9040
+ const envelope = await this.rpc.workflow.run({
9041
+ name,
9042
+ args: options?.args === void 0 ? {} : options.args,
9043
+ options: {
9044
+ limits: options?.limits,
9045
+ notifyOnComplete: options?.notifyOnComplete,
9046
+ logPhaseNames: options?.logPhaseNames
9047
+ }
9048
+ });
9049
+ return this.settleWorkflowRun(envelope);
9050
+ }),
9051
+ resume: (async (runId, options) => {
9052
+ throwIfWorkflowExecutionIsActive();
9053
+ let response;
9054
+ try {
9055
+ response = await this.rpc.workflow.resume({
9056
+ runId,
9057
+ limits: options?.limits,
9058
+ notifyOnComplete: options?.notifyOnComplete,
9059
+ logPhaseNames: options?.logPhaseNames
9060
+ });
9061
+ } catch (error) {
9062
+ if (error instanceof import_node.ResponseError && typeof error.data === "object" && error.data !== null) {
9063
+ const code = error.data.code;
9064
+ if (isWorkflowResumeErrorCode(code)) {
9065
+ throw new WorkflowResumeError(code, error.message);
9066
+ }
9067
+ }
9068
+ throw error;
9069
+ }
9070
+ return this.settleWorkflowRun(response.run);
9071
+ }),
9072
+ getRun: async (runId) => this.rpc.workflow.getRun({ runId }),
9073
+ waitForRun: (runId, options) => this.waitForWorkflowRun(runId, options?.signal),
9074
+ listRuns: (async (options) => {
9075
+ const page = await this.rpc.workflow.listRuns(options ?? {});
9076
+ return options === void 0 ? page.runs : page;
9077
+ }),
9078
+ getRunDetail: (runId) => this.rpc.workflow.getRunDetail({ runId }),
9079
+ getRunProgress: (runId, options = {}) => this.rpc.workflow.getRunProgress({ runId, ...options }),
9080
+ pause: async (runId) => {
9081
+ throwIfWorkflowExecutionIsActive();
9082
+ return this.rpc.workflow.pause({ runId });
9083
+ },
9084
+ cancel: async (runId) => this.rpc.workflow.cancel({ runId })
9085
+ };
9086
+ /**
9087
+ * Resolve a start/resume envelope into the terminal envelope callers expect.
9088
+ *
9089
+ * The CLI may answer `session.factory.run` and `session.factory.resume`
9090
+ * before the run settles, so a non-terminal envelope is followed by a wait
9091
+ * on the run's terminal state.
9092
+ */
9093
+ settleFactoryRun(envelope) {
9094
+ if (isFactoryRunTerminal(envelope.status)) {
9095
+ return Promise.resolve(envelope);
9096
+ }
9097
+ return this.waitForFactoryRun(envelope.runId);
9098
+ }
9099
+ /**
9100
+ * Resolve when a factory run reaches a terminal status.
9101
+ *
9102
+ * The subscription is installed *before* the first read so a transition
9103
+ * landing between the two cannot be missed, and re-reads are serialized so
9104
+ * overlapping invalidation events cannot interleave — the run's revision
9105
+ * advances once per operation, so a burst of events is common and must
9106
+ * collapse into a single in-flight read. A bounded periodic re-read keeps a
9107
+ * dropped invalidation from leaving the wait pending forever.
9108
+ */
9109
+ waitForFactoryRun(runId, signal) {
9110
+ const abortError = () => signal?.reason ?? new DOMException("Factory run wait was aborted", "AbortError");
9111
+ if (signal?.aborted === true) {
9112
+ return Promise.reject(abortError());
9113
+ }
9114
+ return new Promise((resolve3, reject) => {
9115
+ let settled = false;
9116
+ let reading = false;
9117
+ let rereadRequested = false;
9118
+ let pollHandle;
9119
+ let unsubscribe;
9120
+ let onAbort;
9121
+ const finish = (complete) => {
9122
+ if (settled) {
9123
+ return;
9124
+ }
9125
+ settled = true;
9126
+ if (pollHandle !== void 0) {
9127
+ clearInterval(pollHandle);
9128
+ }
9129
+ unsubscribe?.();
9130
+ if (onAbort !== void 0) {
9131
+ signal?.removeEventListener("abort", onAbort);
9132
+ }
9133
+ complete();
9134
+ };
9135
+ const read = async () => {
9136
+ if (settled) {
9137
+ return;
9138
+ }
9139
+ if (reading) {
9140
+ rereadRequested = true;
9141
+ return;
9142
+ }
9143
+ reading = true;
9144
+ try {
9145
+ do {
9146
+ rereadRequested = false;
9147
+ const envelope = await this.rpc.factory.getRun({ runId });
9148
+ if (isFactoryRunTerminal(envelope.status)) {
9149
+ finish(() => resolve3(envelope));
9150
+ return;
9151
+ }
9152
+ } while (rereadRequested && !settled);
9153
+ } catch (error) {
9154
+ finish(() => reject(error));
9155
+ } finally {
9156
+ reading = false;
9157
+ }
9158
+ };
9159
+ if (signal !== void 0) {
9160
+ onAbort = () => finish(() => reject(abortError()));
9161
+ signal.addEventListener("abort", onAbort, { once: true });
7878
9162
  }
7879
- return this.settleFactoryRun(response.run);
7880
- }),
7881
- getRun: async (runId) => this.rpc.factory.getRun({ runId }),
7882
- waitForRun: (runId, options) => this.waitForFactoryRun(runId, options?.signal),
7883
- listRuns: (async (options) => {
7884
- const page = await this.rpc.factory.listRuns(options ?? {});
7885
- return options === void 0 ? page.runs : page;
7886
- }),
7887
- getRunDetail: (runId) => this.rpc.factory.getRunDetail({ runId }),
7888
- getRunProgress: (runId, options = {}) => this.rpc.factory.getRunProgress({ runId, ...options }),
7889
- pause: async (runId) => {
7890
- throwIfFactoryExecutionIsActive();
7891
- return this.rpc.factory.pause({ runId });
7892
- },
7893
- cancel: async (runId) => this.rpc.factory.cancel({ runId })
7894
- };
7895
- /**
7896
- * Resolve a start/resume envelope into the terminal envelope callers expect.
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)) {
9163
+ unsubscribe = this.on("factory.run_updated", (event) => {
9164
+ if (event.data.runId === runId) {
9165
+ void read();
9166
+ }
9167
+ });
9168
+ pollHandle = setInterval(() => void read(), 5e3);
9169
+ pollHandle.unref?.();
9170
+ void read();
9171
+ });
9172
+ }
9173
+ settleWorkflowRun(envelope) {
9174
+ if (isWorkflowRunTerminal(envelope.status)) {
7904
9175
  return Promise.resolve(envelope);
7905
9176
  }
7906
- return this.waitForFactoryRun(envelope.runId);
9177
+ return this.waitForWorkflowRun(envelope.runId);
7907
9178
  }
7908
9179
  /**
7909
- * Resolve when a factory run reaches a terminal status.
9180
+ * Resolve when a workflow run reaches a terminal status.
7910
9181
  *
7911
9182
  * The subscription is installed *before* the first read so a transition
7912
9183
  * landing between the two cannot be missed, and re-reads are serialized so
@@ -7915,8 +9186,8 @@ var CopilotSession = class {
7915
9186
  * collapse into a single in-flight read. A bounded periodic re-read keeps a
7916
9187
  * dropped invalidation from leaving the wait pending forever.
7917
9188
  */
7918
- waitForFactoryRun(runId, signal) {
7919
- const abortError = () => signal?.reason ?? new DOMException("Factory run wait was aborted", "AbortError");
9189
+ waitForWorkflowRun(runId, signal) {
9190
+ const abortError = () => signal?.reason ?? new DOMException("Workflow run wait was aborted", "AbortError");
7920
9191
  if (signal?.aborted === true) {
7921
9192
  return Promise.reject(abortError());
7922
9193
  }
@@ -7953,8 +9224,8 @@ var CopilotSession = class {
7953
9224
  try {
7954
9225
  do {
7955
9226
  rereadRequested = false;
7956
- const envelope = await this.rpc.factory.getRun({ runId });
7957
- if (isFactoryRunTerminal(envelope.status)) {
9227
+ const envelope = await this.rpc.workflow.getRun({ runId });
9228
+ if (isWorkflowRunTerminal(envelope.status)) {
7958
9229
  finish(() => resolve3(envelope));
7959
9230
  return;
7960
9231
  }
@@ -8041,13 +9312,54 @@ var CopilotSession = class {
8041
9312
  attachments: options.attachments,
8042
9313
  mode: options.mode,
8043
9314
  agentMode: options.agentMode,
8044
- requestHeaders: options.requestHeaders
9315
+ requestHeaders: options.requestHeaders,
9316
+ ...options.responseSchema ? {
9317
+ responseFormat: {
9318
+ type: "json_schema",
9319
+ jsonSchema: {
9320
+ name: "response",
9321
+ strict: true,
9322
+ schema: toJsonSchema(options.responseSchema)
9323
+ }
9324
+ }
9325
+ } : {}
8045
9326
  });
8046
9327
  return response.messageId;
8047
9328
  }
8048
- async sendAndWait(optionsOrPrompt, timeout) {
9329
+ async sendAndWait(optionsOrPrompt, schemaOrTimeout, timeout) {
8049
9330
  const options = typeof optionsOrPrompt === "string" ? { prompt: optionsOrPrompt } : optionsOrPrompt;
8050
- const effectiveTimeout = timeout ?? 6e4;
9331
+ const typedSchema = isResponseSchema(schemaOrTimeout) ? schemaOrTimeout : void 0;
9332
+ if (schemaOrTimeout !== void 0 && typeof schemaOrTimeout !== "number" && !typedSchema) {
9333
+ throw new TypeError(
9334
+ "The second argument must be a timeout or a schema with toJSONSchema() and parse(). Pass raw JSON Schema in options.responseSchema instead."
9335
+ );
9336
+ }
9337
+ const effectiveTimeout = (typeof schemaOrTimeout === "number" ? schemaOrTimeout : timeout) ?? 6e4;
9338
+ if (typedSchema && options.responseSchema) {
9339
+ throw new Error(
9340
+ "Do not specify responseSchema in options when requesting a typed response."
9341
+ );
9342
+ }
9343
+ if (typedSchema && options.mode === "immediate") {
9344
+ throw new Error(
9345
+ "Structured output cannot be requested on an immediate steering message."
9346
+ );
9347
+ }
9348
+ if (typedSchema || options.responseSchema) {
9349
+ const message = await this.sendAndWaitForStructuredMessage(
9350
+ typedSchema ? { ...options, responseSchema: typedSchema } : options,
9351
+ effectiveTimeout
9352
+ );
9353
+ if (typedSchema) {
9354
+ if (!message) {
9355
+ throw new Error(
9356
+ "The requested run completed without a structured assistant response."
9357
+ );
9358
+ }
9359
+ return typedSchema.parse(JSON.parse(message.data.content));
9360
+ }
9361
+ return message;
9362
+ }
8051
9363
  let resolveOutcome;
8052
9364
  const outcomePromise = new Promise((resolve3) => {
8053
9365
  resolveOutcome = resolve3;
@@ -8089,12 +9401,95 @@ var CopilotSession = class {
8089
9401
  unsubscribe();
8090
9402
  }
8091
9403
  }
9404
+ async sendAndWaitForStructuredMessage(options, timeout) {
9405
+ if (this.disconnected) {
9406
+ throw new Error("Session is disconnected");
9407
+ }
9408
+ let resolveOutcome;
9409
+ const outcomePromise = new Promise((resolve3) => {
9410
+ resolveOutcome = resolve3;
9411
+ });
9412
+ const fail = (error) => resolveOutcome({ kind: "error", error });
9413
+ let messageId;
9414
+ let consumed = false;
9415
+ let lastMessage;
9416
+ const buffered = [];
9417
+ const observe = (event) => {
9418
+ if (event.agentId) return;
9419
+ if (event.type === "user.message" && event.data.messageId === messageId) {
9420
+ consumed = true;
9421
+ } else if (event.type === "assistant.message" && event.data.originatingMessageId === messageId) {
9422
+ consumed = true;
9423
+ lastMessage = event.data.toolRequests?.length ? void 0 : event;
9424
+ } else if (consumed && event.type === "session.idle" && event.data.mode !== "autopilot") {
9425
+ if (event.data.aborted) {
9426
+ fail(
9427
+ new Error(
9428
+ "The requested run was aborted before a structured result was completed."
9429
+ )
9430
+ );
9431
+ } else {
9432
+ resolveOutcome({ kind: "idle", message: lastMessage });
9433
+ }
9434
+ } else if (consumed && event.type === "session.error") {
9435
+ const error = new Error(event.data.message);
9436
+ error.stack = event.data.stack;
9437
+ fail(error);
9438
+ }
9439
+ };
9440
+ const unsubscribe = this.on((event) => {
9441
+ if (event.type !== "user.message" && event.type !== "assistant.message" && event.type !== "session.idle" && event.type !== "session.error") {
9442
+ return;
9443
+ }
9444
+ if (messageId === void 0) {
9445
+ buffered.push(event);
9446
+ } else {
9447
+ observe(event);
9448
+ }
9449
+ });
9450
+ this.pendingStructuredWaits.add(fail);
9451
+ const timer = setTimeout(
9452
+ () => fail(new Error(`Timeout after ${timeout}ms waiting for the structured response`)),
9453
+ timeout
9454
+ );
9455
+ try {
9456
+ const sendOutcome = this.send(options).then(
9457
+ (id) => {
9458
+ if (!id) {
9459
+ throw new Error(
9460
+ "The runtime did not return a message ID for the structured send."
9461
+ );
9462
+ }
9463
+ messageId = id;
9464
+ for (const event of buffered) observe(event);
9465
+ buffered.length = 0;
9466
+ return outcomePromise;
9467
+ },
9468
+ (error) => ({
9469
+ kind: "error",
9470
+ error: error instanceof Error ? error : new Error(String(error))
9471
+ })
9472
+ );
9473
+ const outcome = await Promise.race([sendOutcome, outcomePromise]);
9474
+ if (outcome.kind === "error") throw outcome.error;
9475
+ return outcome.message;
9476
+ } finally {
9477
+ clearTimeout(timer);
9478
+ buffered.length = 0;
9479
+ unsubscribe();
9480
+ this.pendingStructuredWaits.delete(fail);
9481
+ }
9482
+ }
8092
9483
  /** @internal */
8093
9484
  _markDisconnected() {
8094
9485
  if (this.disconnected) {
8095
9486
  return;
8096
9487
  }
8097
9488
  this.disconnected = true;
9489
+ for (const fail of this.pendingStructuredWaits) {
9490
+ fail(new Error("Session disconnected while waiting for a structured response"));
9491
+ }
9492
+ this.pendingStructuredWaits.clear();
8098
9493
  for (const controller of this.pendingExternalTools.values()) {
8099
9494
  controller.abort();
8100
9495
  }
@@ -8117,6 +9512,13 @@ var CopilotSession = class {
8117
9512
  }
8118
9513
  }
8119
9514
  this.factoryAbortControllers.clear();
9515
+ this.workflows.clear();
9516
+ for (const controllersForRun of this.workflowAbortControllers.values()) {
9517
+ for (const controller of controllersForRun.values()) {
9518
+ controller.abort();
9519
+ }
9520
+ }
9521
+ this.workflowAbortControllers.clear();
8120
9522
  this.transformCallbacks?.clear();
8121
9523
  }
8122
9524
  /** @internal */
@@ -8750,6 +10152,192 @@ var CopilotSession = class {
8750
10152
  }
8751
10153
  };
8752
10154
  }
10155
+ /**
10156
+ * Registers workflow closures and reverse-RPC handlers for this session.
10157
+ *
10158
+ * @param workflows - Workflow handles declared by the joining extension.
10159
+ * @internal Called by the SDK when an extension joins a session.
10160
+ */
10161
+ registerWorkflows(workflows) {
10162
+ this.workflows.clear();
10163
+ if (!workflows || workflows.length === 0) {
10164
+ delete this.clientSessionApis.workflow;
10165
+ return;
10166
+ }
10167
+ for (const handle of workflows) {
10168
+ const definition = getWorkflowDefinition(handle);
10169
+ if (this.workflows.has(definition.meta.name)) {
10170
+ throw new Error(
10171
+ `Duplicate workflow name "${definition.meta.name}". Workflow names must be unique within a joinSession call.`
10172
+ );
10173
+ }
10174
+ this.workflows.set(definition.meta.name, definition);
10175
+ }
10176
+ const self = this;
10177
+ this.clientSessionApis.workflow = {
10178
+ async execute(params) {
10179
+ const definition = self.workflows.get(params.name);
10180
+ if (!definition) {
10181
+ const message = `No workflow registered with name "${params.name}"`;
10182
+ throw new import_node.ResponseError(import_node.ErrorCodes.InvalidParams, message, {
10183
+ code: "workflow_not_found",
10184
+ name: params.name
10185
+ });
10186
+ }
10187
+ const controller = new AbortController();
10188
+ let controllersForRun = self.workflowAbortControllers.get(params.runId);
10189
+ if (controllersForRun === void 0) {
10190
+ controllersForRun = /* @__PURE__ */ new Map();
10191
+ self.workflowAbortControllers.set(params.runId, controllersForRun);
10192
+ }
10193
+ controllersForRun.set(params.executionToken, controller);
10194
+ const progress = new WorkflowProgressBuffer(async (lines) => {
10195
+ await self.rpc.workflow.log({
10196
+ runId: params.runId,
10197
+ executionToken: params.executionToken,
10198
+ lines
10199
+ });
10200
+ });
10201
+ try {
10202
+ const context = {
10203
+ runId: params.runId,
10204
+ args: params.args,
10205
+ session: self,
10206
+ signal: controller.signal,
10207
+ phase: (title) => {
10208
+ throwIfWorkflowAborted(controller.signal);
10209
+ progress.enqueue("phase", title);
10210
+ },
10211
+ log: (message) => {
10212
+ throwIfWorkflowAborted(controller.signal);
10213
+ progress.enqueue("log", message);
10214
+ },
10215
+ agent: async (prompt, options = {}) => {
10216
+ await progress.flush();
10217
+ const opts = {};
10218
+ for (const key of WORKFLOW_AGENT_OPTION_KEYS) {
10219
+ copyDefinedWorkflowAgentOption(options, opts, key);
10220
+ }
10221
+ const response = await awaitWorkflowOperation(
10222
+ () => self.rpc.workflow.agent({
10223
+ workflowRunId: params.runId,
10224
+ executionToken: params.executionToken,
10225
+ prompt,
10226
+ opts
10227
+ }),
10228
+ controller.signal
10229
+ );
10230
+ return response.result ?? null;
10231
+ },
10232
+ step: async (key, producer, options = {}) => {
10233
+ await progress.flush();
10234
+ if (options.volatile) {
10235
+ throwIfWorkflowAborted(controller.signal);
10236
+ return producer();
10237
+ }
10238
+ const cached = await awaitWorkflowOperation(
10239
+ () => self.rpc.workflow.journal.get({
10240
+ runId: params.runId,
10241
+ executionToken: params.executionToken,
10242
+ key
10243
+ }),
10244
+ controller.signal
10245
+ );
10246
+ if (cached.hit) {
10247
+ if (cached.resultJson === void 0) {
10248
+ throw new Error(
10249
+ `step("${key}") journal returned a hit without a result`
10250
+ );
10251
+ }
10252
+ assertWorkflowStepResult(cached.resultJson, key);
10253
+ return cached.resultJson;
10254
+ }
10255
+ const result2 = await producer();
10256
+ assertWorkflowStepResult(result2, key);
10257
+ await awaitWorkflowOperation(
10258
+ () => self.rpc.workflow.journal.put({
10259
+ runId: params.runId,
10260
+ executionToken: params.executionToken,
10261
+ key,
10262
+ resultJson: result2
10263
+ }),
10264
+ controller.signal
10265
+ );
10266
+ return result2;
10267
+ },
10268
+ pause: async (key) => {
10269
+ if (typeof key !== "string" || key.length === 0) {
10270
+ throw new Error("Workflow pause checkpoint key must not be empty");
10271
+ }
10272
+ const helperScope = workflowExecutionStore.getStore()?.helperScope;
10273
+ if (helperScope !== void 0) {
10274
+ throw new Error(
10275
+ `Workflow pause checkpoints are not allowed inside ${helperScope}() branches`
10276
+ );
10277
+ }
10278
+ await progress.flush();
10279
+ const response = await awaitWorkflowOperation(
10280
+ () => self.internalRpc.workflow.pauseAtCheckpoint({
10281
+ runId: params.runId,
10282
+ executionToken: params.executionToken,
10283
+ key
10284
+ }),
10285
+ controller.signal
10286
+ );
10287
+ switch (response.action) {
10288
+ case "continue":
10289
+ return;
10290
+ case "pause":
10291
+ await awaitWorkflowOperation(
10292
+ () => new Promise(() => {
10293
+ }),
10294
+ controller.signal
10295
+ );
10296
+ }
10297
+ },
10298
+ parallel: runWorkflowParallel,
10299
+ pipeline: runWorkflowPipeline,
10300
+ workflow: async () => {
10301
+ throw new Error("nested workflows are not supported");
10302
+ }
10303
+ };
10304
+ const execution = { active: true };
10305
+ const result = await workflowExecutionStore.run(execution, async () => {
10306
+ try {
10307
+ return await definition.run(context);
10308
+ } finally {
10309
+ execution.active = false;
10310
+ }
10311
+ });
10312
+ if (result === void 0) {
10313
+ return {};
10314
+ }
10315
+ assertWorkflowResult(result);
10316
+ return { result };
10317
+ } finally {
10318
+ try {
10319
+ await progress.close();
10320
+ } finally {
10321
+ const controllersForRun2 = self.workflowAbortControllers.get(params.runId);
10322
+ if (controllersForRun2?.get(params.executionToken) === controller) {
10323
+ controllersForRun2.delete(params.executionToken);
10324
+ if (controllersForRun2.size === 0) {
10325
+ self.workflowAbortControllers.delete(params.runId);
10326
+ }
10327
+ }
10328
+ }
10329
+ }
10330
+ },
10331
+ async abort(params) {
10332
+ const controllersForRun = self.workflowAbortControllers.get(params.runId);
10333
+ const controller = controllersForRun?.get(params.executionToken);
10334
+ if (controller !== void 0) {
10335
+ controller.abort(new DOMException("Workflow run was aborted", "AbortError"));
10336
+ }
10337
+ return {};
10338
+ }
10339
+ };
10340
+ }
8753
10341
  /**
8754
10342
  * Registers per-provider {@link BearerTokenProvider} callbacks for BYOK providers
8755
10343
  * configured with managed-identity / on-demand bearer-token auth.
@@ -9444,8 +11032,22 @@ function assertFactoryStepResult(value, key) {
9444
11032
  allowTopLevelUndefined: false
9445
11033
  });
9446
11034
  }
11035
+ function assertWorkflowResult(value) {
11036
+ assertStrictJson(value, {
11037
+ code: "workflow_result_not_json",
11038
+ label: "Workflow result",
11039
+ allowTopLevelUndefined: true
11040
+ });
11041
+ }
11042
+ function assertWorkflowStepResult(value, key) {
11043
+ assertStrictJson(value, {
11044
+ code: "workflow_step_not_json",
11045
+ label: `Workflow step "${key}" result`,
11046
+ allowTopLevelUndefined: false
11047
+ });
11048
+ }
9447
11049
 
9448
- // node_modules/.pnpm/@github+copilot-sdk@1.0.14-preview.1/node_modules/@github/copilot-sdk/dist/runtimeArtifacts.js
11050
+ // src/sdk/nodejs/dist/runtimeArtifacts.js
9449
11051
  import {
9450
11052
  chmodSync,
9451
11053
  copyFileSync,
@@ -9463,11 +11065,11 @@ import { createRequire } from "node:module";
9463
11065
  import { homedir } from "node:os";
9464
11066
  import { dirname, join, relative, sep } from "node:path";
9465
11067
 
9466
- // node_modules/.pnpm/@github+copilot-sdk@1.0.14-preview.1/node_modules/@github/copilot-sdk/dist/cliVersion.js
9467
- var COPILOT_CLI_VERSION = "1.0.84-5";
11068
+ // src/sdk/nodejs/dist/cliVersion.js
11069
+ var COPILOT_CLI_VERSION = "0.0.0-dev";
9468
11070
  var COPILOT_CLI_USE_NPM_PACKAGE = false;
9469
11071
 
9470
- // node_modules/.pnpm/@github+copilot-sdk@1.0.14-preview.1/node_modules/@github/copilot-sdk/dist/runtimeArtifacts.js
11072
+ // src/sdk/nodejs/dist/runtimeArtifacts.js
9471
11073
  var require2 = createRequire(typeof __filename === "string" ? __filename : import.meta.url);
9472
11074
  var EXCLUDED_TOP_LEVEL = /* @__PURE__ */ new Set([
9473
11075
  "app.js",
@@ -9620,13 +11222,13 @@ function getRuntimePackageName(platform) {
9620
11222
  function resolvePackageRoot(packageName, searchPaths = require2.resolve.paths(packageName) ?? []) {
9621
11223
  return searchPaths.map((base) => join(base, ...packageName.split("/"))).find((candidate) => existsSync(join(candidate, "package.json")));
9622
11224
  }
9623
- async function ensureRuntimeBundle(version, options = {}) {
11225
+ async function ensureRuntimeBundle(version2, options = {}) {
9624
11226
  const platform = options.platform ?? getRuntimePlatform();
9625
11227
  if (COPILOT_CLI_USE_NPM_PACKAGE) {
9626
11228
  const packageName2 = `@github/copilot-${platform}`;
9627
11229
  const packageRoot2 = resolvePackageRoot(packageName2, options.packageSearchPaths);
9628
11230
  if (!packageRoot2) {
9629
- throw new Error(`Could not resolve ${packageName2} for Copilot CLI ${version}.`);
11231
+ throw new Error(`Could not resolve ${packageName2} for Copilot CLI ${version2}.`);
9630
11232
  }
9631
11233
  validateFile(
9632
11234
  join(packageRoot2, "prebuilds", platform, "runtime.node"),
@@ -9635,7 +11237,7 @@ async function ensureRuntimeBundle(version, options = {}) {
9635
11237
  return materializeRuntimeBundle(
9636
11238
  { packageRoot: packageRoot2, platform },
9637
11239
  options.cacheRoot,
9638
- `${version}-${platform}`
11240
+ `${version2}-${platform}`
9639
11241
  );
9640
11242
  }
9641
11243
  const packageName = getRuntimePackageName(platform);
@@ -9660,7 +11262,7 @@ async function ensureRuntimeBundle(version, options = {}) {
9660
11262
  return wrapper;
9661
11263
  }
9662
11264
 
9663
- // node_modules/.pnpm/@github+copilot-sdk@1.0.14-preview.1/node_modules/@github/copilot-sdk/dist/toolSet.js
11265
+ // src/sdk/nodejs/dist/toolSet.js
9664
11266
  var VALID_TOOL_NAME = /^[a-zA-Z0-9_-]+$/;
9665
11267
  function validateName(kind, name) {
9666
11268
  if (name === "*") {
@@ -9715,12 +11317,9 @@ var ToolSet = class {
9715
11317
  }
9716
11318
  };
9717
11319
 
9718
- // node_modules/.pnpm/@github+copilot-sdk@1.0.14-preview.1/node_modules/@github/copilot-sdk/dist/client.js
11320
+ // src/sdk/nodejs/dist/client.js
9719
11321
  var MIN_PROTOCOL_VERSION = 3;
9720
11322
  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
11323
  async function withTimeout(promise, timeoutMs, message) {
9725
11324
  let timeout;
9726
11325
  try {
@@ -9765,13 +11364,6 @@ async function waitForChildExit(child, timeoutMs) {
9765
11364
  }
9766
11365
  });
9767
11366
  }
9768
- function toJsonSchema(parameters) {
9769
- if (!parameters) return void 0;
9770
- if (isZodSchema(parameters)) {
9771
- return parameters.toJSONSchema();
9772
- }
9773
- return parameters;
9774
- }
9775
11367
  var DEFAULT_PROVIDER_NAME = "default";
9776
11368
  function extractBearerTokenProviders(provider, providers) {
9777
11369
  const callbacks = /* @__PURE__ */ new Map();
@@ -9904,6 +11496,7 @@ var CopilotClient = class _CopilotClient {
9904
11496
  cliProcess = null;
9905
11497
  ffiHost = null;
9906
11498
  connection = null;
11499
+ requestAdapter = null;
9907
11500
  messageWriter = null;
9908
11501
  connectionClosed = false;
9909
11502
  socket = null;
@@ -9941,6 +11534,7 @@ var CopilotClient = class _CopilotClient {
9941
11534
  /** Connection-level session filesystem config, set via constructor option. */
9942
11535
  sessionFsConfig = null;
9943
11536
  requestHandler = null;
11537
+ extensionLaunchProvider;
9944
11538
  builtinPluginDirectories = [];
9945
11539
  onGitHubTelemetry;
9946
11540
  clientGlobalHandlers = {};
@@ -10098,6 +11692,7 @@ var CopilotClient = class _CopilotClient {
10098
11692
  this.onGetTraceContext = options.onGetTraceContext;
10099
11693
  this.sessionFsConfig = options.sessionFs ?? null;
10100
11694
  this.requestHandler = options.requestHandler ?? null;
11695
+ this.extensionLaunchProvider = options.extensionLaunchProvider;
10101
11696
  this.onGitHubTelemetry = options.onGitHubTelemetry;
10102
11697
  this.setupClientGlobalHandlers();
10103
11698
  const connEnv = conn.kind === "stdio" || conn.kind === "tcp" ? conn.env : void 0;
@@ -10200,14 +11795,16 @@ var CopilotClient = class _CopilotClient {
10200
11795
  }
10201
11796
  setupClientGlobalHandlers() {
10202
11797
  const handlers = {};
11798
+ handlers.extensionLaunchProvider = this.extensionLaunchProvider;
10203
11799
  if (this.requestHandler) {
10204
- handlers.llmInference = createCopilotRequestAdapter(this.requestHandler, () => {
11800
+ this.requestAdapter = createCopilotRequestAdapter(this.requestHandler, () => {
10205
11801
  if (!this.connection) {
10206
11802
  return void 0;
10207
11803
  }
10208
11804
  this._rpc ??= createServerRpc(this.connection);
10209
11805
  return this._rpc;
10210
11806
  });
11807
+ handlers.llmInference = this.requestAdapter;
10211
11808
  }
10212
11809
  if (this.onGitHubTelemetry) {
10213
11810
  const onGitHubTelemetry = this.onGitHubTelemetry;
@@ -10312,6 +11909,9 @@ var CopilotClient = class _CopilotClient {
10312
11909
  }
10313
11910
  await this.connectToServer();
10314
11911
  await this.verifyProtocolVersion();
11912
+ if (this.extensionLaunchProvider) {
11913
+ await this.rpc.registerExtensionLaunchProvider();
11914
+ }
10315
11915
  if (this.builtinPluginDirectories.length > 0) {
10316
11916
  try {
10317
11917
  await this.connection.sendRequest("plugins.builtin.set", {
@@ -10400,6 +12000,7 @@ var CopilotClient = class _CopilotClient {
10400
12000
  }
10401
12001
  this.sessions.clear();
10402
12002
  this.githubTokenProviders.clear();
12003
+ this.requestAdapter?.cancelPending();
10403
12004
  if (this.connection && !this.connectionClosed && (this.cliProcess || this.ffiHost) && !this.isExternalServer) {
10404
12005
  const runtimeShutdownStart = Date.now();
10405
12006
  const shutdownPromise = this.rpc.runtime.shutdown();
@@ -10555,6 +12156,7 @@ var CopilotClient = class _CopilotClient {
10555
12156
  }
10556
12157
  this.sessions.clear();
10557
12158
  this.githubTokenProviders.clear();
12159
+ this.requestAdapter?.cancelPending();
10558
12160
  if (this.messageWriter) {
10559
12161
  this.messageWriter.suppressWriteErrors = true;
10560
12162
  }
@@ -11005,11 +12607,14 @@ var CopilotClient = class _CopilotClient {
11005
12607
  async resumeSession(sessionId, config) {
11006
12608
  return this.resumeSessionInternal(sessionId, config);
11007
12609
  }
11008
- /** @internal */
11009
- async resumeSessionForExtension(sessionId, config, factories, extensionOptions) {
11010
- return this.resumeSessionInternal(sessionId, config, factories, extensionOptions);
12610
+ async resumeSessionForExtension(sessionId, config, contributions = {}, extensionOptions) {
12611
+ return this.resumeSessionInternal(sessionId, config, contributions, extensionOptions);
11011
12612
  }
11012
- async resumeSessionInternal(sessionId, config, factories, extensionOptions) {
12613
+ async resumeSessionInternal(sessionId, config, contributions = {}, extensionOptions) {
12614
+ const { factories, workflows } = Array.isArray(contributions) ? { factories: contributions, workflows: void 0 } : contributions;
12615
+ if (factories !== void 0 && workflows !== void 0) {
12616
+ throw new Error("Session configuration cannot include both factories and workflows");
12617
+ }
11013
12618
  if (config.gitHubToken !== void 0 && config.gitHubTokenProvider !== void 0) {
11014
12619
  throw new Error("gitHubToken and gitHubTokenProvider are mutually exclusive");
11015
12620
  }
@@ -11030,6 +12635,7 @@ var CopilotClient = class _CopilotClient {
11030
12635
  session.registerCanvases(config.canvases);
11031
12636
  session.registerCommands(config.commands);
11032
12637
  session.registerFactories(factories);
12638
+ session.registerWorkflows(workflows);
11033
12639
  const {
11034
12640
  wireProvider: bearerWireProvider,
11035
12641
  wireProviders: bearerWireProviders,
@@ -11111,6 +12717,7 @@ var CopilotClient = class _CopilotClient {
11111
12717
  toolSearch: config.toolSearch,
11112
12718
  canvases: config.canvases?.map((canvas) => canvas.declaration),
11113
12719
  factories: factories?.map((factory) => factory.meta),
12720
+ workflows: workflows?.map((workflow) => workflow.meta),
11114
12721
  requestCanvasRenderer: config.requestCanvasRenderer,
11115
12722
  requestExtensions: config.requestExtensions,
11116
12723
  extensionSdkPath: config.extensionSdkPath,
@@ -11963,6 +13570,7 @@ stderr: ${stderrOutput}` : ""}`
11963
13570
  }
11964
13571
  this.sessions.clear();
11965
13572
  this.githubTokenProviders.clear();
13573
+ this.requestAdapter?.cancelPending();
11966
13574
  };
11967
13575
  this.connection.onClose(markDisconnected);
11968
13576
  this.connection.onError(() => {
@@ -12082,7 +13690,7 @@ stderr: ${stderrOutput}` : ""}`
12082
13690
  }
12083
13691
  };
12084
13692
 
12085
- // node_modules/.pnpm/@github+copilot-sdk@1.0.14-preview.1/node_modules/@github/copilot-sdk/dist/extension.js
13693
+ // src/sdk/nodejs/dist/extension.js
12086
13694
  async function joinSession(config = {}) {
12087
13695
  const sessionId = process.env.SESSION_ID;
12088
13696
  if (!sessionId) {
@@ -12094,10 +13702,14 @@ async function joinSession(config = {}) {
12094
13702
  const {
12095
13703
  extensionSdkPath: _stripped,
12096
13704
  factories,
13705
+ workflows,
12097
13706
  requestedEnvironmentVariables,
12098
13707
  ...rest
12099
13708
  } = config;
12100
13709
  void _stripped;
13710
+ if (factories !== void 0 && workflows !== void 0) {
13711
+ throw new Error("joinSession cannot register both factories and workflows");
13712
+ }
12101
13713
  return client.resumeSessionForExtension(
12102
13714
  sessionId,
12103
13715
  {
@@ -12105,7 +13717,7 @@ async function joinSession(config = {}) {
12105
13717
  onPermissionRequest: config.onPermissionRequest ?? defaultJoinSessionPermissionHandler,
12106
13718
  suppressResumeEvent: config.suppressResumeEvent ?? true
12107
13719
  },
12108
- factories,
13720
+ { factories, workflows },
12109
13721
  requestedEnvironmentVariables?.length ? { requestedEnvironmentVariables } : void 0
12110
13722
  );
12111
13723
  }
@@ -12113,8 +13725,11 @@ export {
12113
13725
  Canvas,
12114
13726
  CanvasError,
12115
13727
  FactoryResumeError,
13728
+ WorkflowResumeError,
12116
13729
  createCanvas,
12117
13730
  defineFactory,
13731
+ defineWorkflow,
12118
13732
  isFactoryRunTerminal,
13733
+ isWorkflowRunTerminal,
12119
13734
  joinSession
12120
13735
  };