dsh-github-copilot 0.4.0-alpha.108 → 0.4.0-alpha.110

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -23,12 +23,12 @@ import { Config as Config$1, PiAiAdapter } from "@deepseek-ai/dsh-llm-pi-ai";
23
23
  import { estimateContextTokens, estimateMessageTokens } from "@earendil-works/pi-ai/utils/estimate";
24
24
  //#region lib/types/dual-model-host.js
25
25
  /** Retired planner/executor entry points; retained policies stay enforceable without migration. */
26
- var __runInitializers$7 = function(thisArg, initializers, value) {
26
+ var __runInitializers$8 = function(thisArg, initializers, value) {
27
27
  var useValue = arguments.length > 2;
28
28
  for (var i = 0; i < initializers.length; i++) value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
29
29
  return useValue ? value : void 0;
30
30
  };
31
- var __esDecorate$7 = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
31
+ var __esDecorate$8 = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
32
32
  function accept(f) {
33
33
  if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected");
34
34
  return f;
@@ -274,7 +274,7 @@ let GitHubCopilotDualModel = (() => {
274
274
  _view_decorators = [Remote];
275
275
  _save_decorators = [Remote];
276
276
  _create_decorators = [Remote];
277
- __esDecorate$7(this, null, _view_decorators, {
277
+ __esDecorate$8(this, null, _view_decorators, {
278
278
  kind: "method",
279
279
  name: "view",
280
280
  static: false,
@@ -285,7 +285,7 @@ let GitHubCopilotDualModel = (() => {
285
285
  },
286
286
  metadata: _metadata
287
287
  }, null, _instanceExtraInitializers);
288
- __esDecorate$7(this, null, _save_decorators, {
288
+ __esDecorate$8(this, null, _save_decorators, {
289
289
  kind: "method",
290
290
  name: "save",
291
291
  static: false,
@@ -296,7 +296,7 @@ let GitHubCopilotDualModel = (() => {
296
296
  },
297
297
  metadata: _metadata
298
298
  }, null, _instanceExtraInitializers);
299
- __esDecorate$7(this, null, _create_decorators, {
299
+ __esDecorate$8(this, null, _create_decorators, {
300
300
  kind: "method",
301
301
  name: "create",
302
302
  static: false,
@@ -314,7 +314,7 @@ let GitHubCopilotDualModel = (() => {
314
314
  value: _metadata
315
315
  });
316
316
  }
317
- owner = __runInitializers$7(this, _instanceExtraInitializers);
317
+ owner = __runInitializers$8(this, _instanceExtraInitializers);
318
318
  lifetime = new AbortController();
319
319
  creates = /* @__PURE__ */ new Map();
320
320
  overlays = /* @__PURE__ */ new Map();
@@ -742,12 +742,12 @@ const SearchProviderCatalogSchema = z$1.object({
742
742
  }).strict();
743
743
  //#endregion
744
744
  //#region lib/types/search-routing-host.js
745
- var __runInitializers$6 = function(thisArg, initializers, value) {
745
+ var __runInitializers$7 = function(thisArg, initializers, value) {
746
746
  var useValue = arguments.length > 2;
747
747
  for (var i = 0; i < initializers.length; i++) value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
748
748
  return useValue ? value : void 0;
749
749
  };
750
- var __esDecorate$6 = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
750
+ var __esDecorate$7 = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
751
751
  function accept(f) {
752
752
  if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected");
753
753
  return f;
@@ -790,7 +790,7 @@ let SearchRoutingController = (() => {
790
790
  static {
791
791
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
792
792
  _providers_decorators = [Remote];
793
- __esDecorate$6(this, null, _providers_decorators, {
793
+ __esDecorate$7(this, null, _providers_decorators, {
794
794
  kind: "method",
795
795
  name: "providers",
796
796
  static: false,
@@ -810,7 +810,7 @@ let SearchRoutingController = (() => {
810
810
  }
811
811
  constructor(ctx) {
812
812
  super(ctx, "githubCopilotSearchRouting");
813
- __runInitializers$6(this, _instanceExtraInitializers);
813
+ __runInitializers$7(this, _instanceExtraInitializers);
814
814
  }
815
815
  providers() {
816
816
  const unavailable = {
@@ -1348,7 +1348,7 @@ var Budget = class {
1348
1348
  if (this.consumed > ACCOUNT_MODEL_CATALOG_LIMITS.maxBytes) fail$1("CATALOG_TOO_LARGE", true);
1349
1349
  }
1350
1350
  };
1351
- function record$12(value, code) {
1351
+ function record$13(value, code) {
1352
1352
  if (typeof value !== "object" || value === null || Array.isArray(value)) fail$1(code);
1353
1353
  return value;
1354
1354
  }
@@ -1401,11 +1401,11 @@ function normalizeModel(raw, id, options, budget) {
1401
1401
  if (options.availableModelIds?.has(id) !== true) fail$1("MISSING_POLICY");
1402
1402
  policySource = "account-available-id";
1403
1403
  } else {
1404
- if (text$2(field(record$12(rawPolicy, "INVALID_POLICY"), "state", budget), 64, "INVALID_POLICY", budget) !== "enabled") fail$1("POLICY_NOT_ENABLED");
1404
+ if (text$2(field(record$13(rawPolicy, "INVALID_POLICY"), "state", budget), 64, "INVALID_POLICY", budget) !== "enabled") fail$1("POLICY_NOT_ENABLED");
1405
1405
  policySource = "server-enabled";
1406
1406
  }
1407
- const capabilities = record$12(field(raw, "capabilities", budget), "INVALID_CAPABILITIES");
1408
- const supports = record$12(field(capabilities, "supports", budget), "INVALID_SUPPORTS");
1407
+ const capabilities = record$13(field(raw, "capabilities", budget), "INVALID_CAPABILITIES");
1408
+ const supports = record$13(field(capabilities, "supports", budget), "INVALID_SUPPORTS");
1409
1409
  const streaming = field(supports, "streaming", budget);
1410
1410
  if (streaming === false) fail$1("STREAMING_UNSUPPORTED");
1411
1411
  if (streaming !== true) fail$1("INVALID_SUPPORTS");
@@ -1426,7 +1426,7 @@ function normalizeModel(raw, id, options, budget) {
1426
1426
  if (selected === void 0) fail$1(unsupportedEndpointCount === 0 && endpoints.includes("ws:/responses") ? "WEBSOCKET_ONLY" : "UNSUPPORTED_ENDPOINTS");
1427
1427
  const rawLimits = field(capabilities, "limits", budget);
1428
1428
  if (rawLimits === void 0) fail$1("MISSING_LIMITS");
1429
- const limits = record$12(rawLimits, "INVALID_LIMITS");
1429
+ const limits = record$13(rawLimits, "INVALID_LIMITS");
1430
1430
  const maxContext = optionalPositive(limits, "max_context_window_tokens", "INVALID_LIMITS", budget);
1431
1431
  const maxInputTokens = optionalPositive(limits, "max_prompt_tokens", "INVALID_LIMITS", budget);
1432
1432
  if (maxContext === void 0 && maxInputTokens === void 0) fail$1("MISSING_CONTEXT_LIMIT");
@@ -1444,7 +1444,7 @@ function normalizeModel(raw, id, options, budget) {
1444
1444
  if (vision === true) {
1445
1445
  const rawVisionLimits = field(limits, "vision", budget);
1446
1446
  if (rawVisionLimits !== void 0) {
1447
- const rawMediaTypes = field(record$12(rawVisionLimits, "INVALID_VISION_LIMITS"), "supported_media_types", budget);
1447
+ const rawMediaTypes = field(record$13(rawVisionLimits, "INVALID_VISION_LIMITS"), "supported_media_types", budget);
1448
1448
  if (rawMediaTypes !== void 0) {
1449
1449
  const mediaTypes = stringList(rawMediaTypes, ACCOUNT_MODEL_CATALOG_LIMITS.maxMediaTypes, 128, "INVALID_VISION_LIMITS", budget);
1450
1450
  const mime = /^[a-z0-9][a-z0-9!#$%&'*+.^_`|~-]*\/[a-z0-9][a-z0-9!#$%&'*+.^_`|~-]*$/iu;
@@ -1506,7 +1506,7 @@ function normalizeAccountModelCatalog(raw, options = {}) {
1506
1506
  fail$1("INVALID_JSON", true);
1507
1507
  }
1508
1508
  }
1509
- const data = field(record$12(raw, "INVALID_CATALOG"), "data", budget);
1509
+ const data = field(record$13(raw, "INVALID_CATALOG"), "data", budget);
1510
1510
  if (!Array.isArray(data)) fail$1("INVALID_CATALOG");
1511
1511
  const count = field(data, "length", budget);
1512
1512
  if (typeof count !== "number" || !Number.isSafeInteger(count) || count < 0) fail$1("INVALID_CATALOG");
@@ -1529,7 +1529,7 @@ function normalizeAccountModelCatalog(raw, options = {}) {
1529
1529
  for (let index = 0; index < count; index++) {
1530
1530
  let id;
1531
1531
  try {
1532
- const candidate = record$12(field(data, String(index), budget), "INVALID_MODEL");
1532
+ const candidate = record$13(field(data, String(index), budget), "INVALID_MODEL");
1533
1533
  const candidateId = text$2(field(candidate, "id", budget), ACCOUNT_MODEL_CATALOG_LIMITS.maxIdLength, "INVALID_ID", budget);
1534
1534
  if (!identifier.test(candidateId)) fail$1("INVALID_ID");
1535
1535
  id = candidateId;
@@ -2354,7 +2354,7 @@ var ResponsesRetryReplay = class {
2354
2354
  let finished = false;
2355
2355
  let observed = false;
2356
2356
  return {
2357
- normalize: (payload) => {
2357
+ normalize: (payload, transform) => {
2358
2358
  if (this.disposed || signal?.aborted) throw new CopilotResponsesReplayError();
2359
2359
  const rawBytes = cacheBytes(payload);
2360
2360
  let normalized;
@@ -2395,6 +2395,7 @@ var ResponsesRetryReplay = class {
2395
2395
  normalized = JSON.parse(eligible.normalized);
2396
2396
  reused = true;
2397
2397
  }
2398
+ if (transform !== void 0) normalized = transform(normalized);
2398
2399
  payloadBytes = cacheBytes(normalized);
2399
2400
  candidate = signal === void 0 || !sessionId || !modelId || contextBytes === void 0 || rawBytes === void 0 || payloadBytes === void 0 ? void 0 : {
2400
2401
  raw: JSON.parse(rawBytes),
@@ -2547,16 +2548,16 @@ function formatRequestUploadEvidence(evidence) {
2547
2548
  //#endregion
2548
2549
  //#region lib/types/request-body-timeout.js
2549
2550
  const observedMessage = "Timed out reading request body. Try again, or use a smaller request size.";
2550
- function record$11(value) {
2551
+ function record$12(value) {
2551
2552
  return typeof value === "object" && value !== null && !Array.isArray(value);
2552
2553
  }
2553
2554
  /** Verified provider evidence, not guessed capabilities, token limits or network cause. */
2554
2555
  async function requestBodyTimeoutDiagnostic(response, body, signal, dispatch) {
2555
2556
  if (response.status !== 408 || signal?.aborted) return void 0;
2556
2557
  const value = await readResponseErrorJson(response, signal);
2557
- if (signal?.aborted || !record$11(value)) return void 0;
2558
+ if (signal?.aborted || !record$12(value)) return void 0;
2558
2559
  const error = Object.hasOwn(value, "error") ? value.error : value;
2559
- if (!record$11(error) || error.code !== "user_request_timeout" || error.message !== observedMessage || value.code !== void 0 && value.code !== error.code || value.message !== void 0 && value.message !== error.message) return void 0;
2560
+ if (!record$12(error) || error.code !== "user_request_timeout" || error.message !== observedMessage || value.code !== void 0 && value.code !== error.code || value.message !== void 0 && value.message !== error.message) return void 0;
2560
2561
  const size = body === void 0 ? "Request body size unavailable." : `Request body: ${Buffer.byteLength(body, "utf8")} UTF-8 bytes (not context tokens).`;
2561
2562
  const composition = formatRequestBodyEvidence(dispatch === void 0 ? { state: "unavailable" } : requestBodyEvidence(body, dispatch.protocol), dispatch?.responseHeadersMs);
2562
2563
  const upload = formatRequestUploadEvidence(dispatch?.upload);
@@ -2895,7 +2896,8 @@ function createAccountProvider(descriptors, guard, baseURL) {
2895
2896
  if (lease.signal.aborted || options.signal?.aborted) throw new Error("COPILOT_MANAGED_ABORTED");
2896
2897
  try {
2897
2898
  const effective = replacement === void 0 ? payload : replacement;
2898
- const normalized = retry === void 0 ? normalizeCopilotResponsesPayload(effective) : retry.normalize(effective);
2899
+ if (retry !== void 0) return retry.normalize(effective, guard.recoverReplay);
2900
+ const normalized = normalizeCopilotResponsesPayload(effective);
2899
2901
  return guard.recoverReplay === void 0 ? normalized : guard.recoverReplay(normalized);
2900
2902
  } catch (error) {
2901
2903
  if (error instanceof CopilotResponsesReplayError) reportReplayFailure(error);
@@ -2991,7 +2993,7 @@ function createAccountProvider(descriptors, guard, baseURL) {
2991
2993
  var package_default = {
2992
2994
  name: "dsh-github-copilot",
2993
2995
  description: "DSH companion for GitHub Copilot sign-in, account-aware model profiles, tool compatibility, and provider-hosted search.",
2994
- version: "0.4.0-alpha.108",
2996
+ version: "0.4.0-alpha.110",
2995
2997
  publishConfig: {
2996
2998
  "access": "public",
2997
2999
  "registry": "https://registry.npmjs.org/",
@@ -3057,6 +3059,10 @@ var package_default = {
3057
3059
  "docs/manual-compaction-recovery.md",
3058
3060
  "docs/copilot-usage.md",
3059
3061
  "docs/copilot-accounts.md",
3062
+ "docs/session-continuation.md",
3063
+ "docs/account-management-experience.md",
3064
+ "docs/mockups/copilot-account-management.html",
3065
+ "docs/mockups/copilot-account-dropdown.html",
3060
3066
  "docs/automatic-model-routing.md",
3061
3067
  "docs/auto-task-routing.md",
3062
3068
  "docs/image-input-compatibility.md",
@@ -3375,12 +3381,12 @@ const COPILOT_ACCOUNT_ID_PATTERN = /^(?:canonical|[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a
3375
3381
  const GITHUB_ACCOUNT_LOGIN_PATTERN = /^[a-zA-Z0-9](?:[a-zA-Z0-9_-]*[a-zA-Z0-9])?$/u;
3376
3382
  //#endregion
3377
3383
  //#region lib/types/copilot-accounts-host.js
3378
- var __runInitializers$5 = function(thisArg, initializers, value) {
3384
+ var __runInitializers$6 = function(thisArg, initializers, value) {
3379
3385
  var useValue = arguments.length > 2;
3380
3386
  for (var i = 0; i < initializers.length; i++) value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
3381
3387
  return useValue ? value : void 0;
3382
3388
  };
3383
- var __esDecorate$5 = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3389
+ var __esDecorate$6 = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3384
3390
  function accept(f) {
3385
3391
  if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected");
3386
3392
  return f;
@@ -4223,7 +4229,7 @@ let GitHubCopilotAccountsController = (() => {
4223
4229
  _reauthorize_decorators = [Remote];
4224
4230
  _switchAccount_decorators = [Remote];
4225
4231
  _removeAccount_decorators = [Remote];
4226
- __esDecorate$5(this, null, _get_decorators, {
4232
+ __esDecorate$6(this, null, _get_decorators, {
4227
4233
  kind: "method",
4228
4234
  name: "get",
4229
4235
  static: false,
@@ -4234,7 +4240,7 @@ let GitHubCopilotAccountsController = (() => {
4234
4240
  },
4235
4241
  metadata: _metadata
4236
4242
  }, null, _instanceExtraInitializers);
4237
- __esDecorate$5(this, null, _refreshIdentity_decorators, {
4243
+ __esDecorate$6(this, null, _refreshIdentity_decorators, {
4238
4244
  kind: "method",
4239
4245
  name: "refreshIdentity",
4240
4246
  static: false,
@@ -4245,7 +4251,7 @@ let GitHubCopilotAccountsController = (() => {
4245
4251
  },
4246
4252
  metadata: _metadata
4247
4253
  }, null, _instanceExtraInitializers);
4248
- __esDecorate$5(this, null, _ensureIdentity_decorators, {
4254
+ __esDecorate$6(this, null, _ensureIdentity_decorators, {
4249
4255
  kind: "method",
4250
4256
  name: "ensureIdentity",
4251
4257
  static: false,
@@ -4256,7 +4262,7 @@ let GitHubCopilotAccountsController = (() => {
4256
4262
  },
4257
4263
  metadata: _metadata
4258
4264
  }, null, _instanceExtraInitializers);
4259
- __esDecorate$5(this, null, _add_decorators, {
4265
+ __esDecorate$6(this, null, _add_decorators, {
4260
4266
  kind: "method",
4261
4267
  name: "add",
4262
4268
  static: false,
@@ -4267,7 +4273,7 @@ let GitHubCopilotAccountsController = (() => {
4267
4273
  },
4268
4274
  metadata: _metadata
4269
4275
  }, null, _instanceExtraInitializers);
4270
- __esDecorate$5(this, null, _cancel_decorators, {
4276
+ __esDecorate$6(this, null, _cancel_decorators, {
4271
4277
  kind: "method",
4272
4278
  name: "cancel",
4273
4279
  static: false,
@@ -4278,7 +4284,7 @@ let GitHubCopilotAccountsController = (() => {
4278
4284
  },
4279
4285
  metadata: _metadata
4280
4286
  }, null, _instanceExtraInitializers);
4281
- __esDecorate$5(this, null, _reauthorize_decorators, {
4287
+ __esDecorate$6(this, null, _reauthorize_decorators, {
4282
4288
  kind: "method",
4283
4289
  name: "reauthorize",
4284
4290
  static: false,
@@ -4289,7 +4295,7 @@ let GitHubCopilotAccountsController = (() => {
4289
4295
  },
4290
4296
  metadata: _metadata
4291
4297
  }, null, _instanceExtraInitializers);
4292
- __esDecorate$5(this, null, _switchAccount_decorators, {
4298
+ __esDecorate$6(this, null, _switchAccount_decorators, {
4293
4299
  kind: "method",
4294
4300
  name: "switchAccount",
4295
4301
  static: false,
@@ -4300,7 +4306,7 @@ let GitHubCopilotAccountsController = (() => {
4300
4306
  },
4301
4307
  metadata: _metadata
4302
4308
  }, null, _instanceExtraInitializers);
4303
- __esDecorate$5(this, null, _removeAccount_decorators, {
4309
+ __esDecorate$6(this, null, _removeAccount_decorators, {
4304
4310
  kind: "method",
4305
4311
  name: "removeAccount",
4306
4312
  static: false,
@@ -4318,7 +4324,7 @@ let GitHubCopilotAccountsController = (() => {
4318
4324
  value: _metadata
4319
4325
  });
4320
4326
  }
4321
- host = __runInitializers$5(this, _instanceExtraInitializers);
4327
+ host = __runInitializers$6(this, _instanceExtraInitializers);
4322
4328
  constructor(ctx) {
4323
4329
  super(ctx, "githubCopilotAccounts");
4324
4330
  this.host = new CopilotAccountsHost(ctx);
@@ -4356,12 +4362,12 @@ let GitHubCopilotAccountsController = (() => {
4356
4362
  })();
4357
4363
  //#endregion
4358
4364
  //#region lib/types/copilot-usage-host.js
4359
- var __runInitializers$4 = function(thisArg, initializers, value) {
4365
+ var __runInitializers$5 = function(thisArg, initializers, value) {
4360
4366
  var useValue = arguments.length > 2;
4361
4367
  for (var i = 0; i < initializers.length; i++) value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
4362
4368
  return useValue ? value : void 0;
4363
4369
  };
4364
- var __esDecorate$4 = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
4370
+ var __esDecorate$5 = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
4365
4371
  function accept(f) {
4366
4372
  if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected");
4367
4373
  return f;
@@ -4705,7 +4711,7 @@ let GitHubCopilotUsageController = (() => {
4705
4711
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
4706
4712
  _get_decorators = [Remote];
4707
4713
  _refresh_decorators = [Remote];
4708
- __esDecorate$4(this, null, _get_decorators, {
4714
+ __esDecorate$5(this, null, _get_decorators, {
4709
4715
  kind: "method",
4710
4716
  name: "get",
4711
4717
  static: false,
@@ -4716,7 +4722,7 @@ let GitHubCopilotUsageController = (() => {
4716
4722
  },
4717
4723
  metadata: _metadata
4718
4724
  }, null, _instanceExtraInitializers);
4719
- __esDecorate$4(this, null, _refresh_decorators, {
4725
+ __esDecorate$5(this, null, _refresh_decorators, {
4720
4726
  kind: "method",
4721
4727
  name: "refresh",
4722
4728
  static: false,
@@ -4734,7 +4740,7 @@ let GitHubCopilotUsageController = (() => {
4734
4740
  value: _metadata
4735
4741
  });
4736
4742
  }
4737
- accountSources = (__runInitializers$4(this, _instanceExtraInitializers), /* @__PURE__ */ new Map());
4743
+ accountSources = (__runInitializers$5(this, _instanceExtraInitializers), /* @__PURE__ */ new Map());
4738
4744
  source;
4739
4745
  accountSignature;
4740
4746
  sourceInitialized = false;
@@ -5009,12 +5015,12 @@ var SessionAccountsHost = class {
5009
5015
  };
5010
5016
  //#endregion
5011
5017
  //#region lib/types/session-accounts-controller.js
5012
- var __runInitializers$3 = function(thisArg, initializers, value) {
5018
+ var __runInitializers$4 = function(thisArg, initializers, value) {
5013
5019
  var useValue = arguments.length > 2;
5014
5020
  for (var i = 0; i < initializers.length; i++) value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
5015
5021
  return useValue ? value : void 0;
5016
5022
  };
5017
- var __esDecorate$3 = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
5023
+ var __esDecorate$4 = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
5018
5024
  function accept(f) {
5019
5025
  if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected");
5020
5026
  return f;
@@ -5069,7 +5075,7 @@ let SessionAccountController = (() => {
5069
5075
  _usage_decorators = [Remote];
5070
5076
  _refreshUsage_decorators = [Remote];
5071
5077
  _turn_decorators = [Remote];
5072
- __esDecorate$3(this, null, _get_decorators, {
5078
+ __esDecorate$4(this, null, _get_decorators, {
5073
5079
  kind: "method",
5074
5080
  name: "get",
5075
5081
  static: false,
@@ -5080,7 +5086,7 @@ let SessionAccountController = (() => {
5080
5086
  },
5081
5087
  metadata: _metadata
5082
5088
  }, null, _instanceExtraInitializers);
5083
- __esDecorate$3(this, null, _set_decorators, {
5089
+ __esDecorate$4(this, null, _set_decorators, {
5084
5090
  kind: "method",
5085
5091
  name: "set",
5086
5092
  static: false,
@@ -5091,7 +5097,7 @@ let SessionAccountController = (() => {
5091
5097
  },
5092
5098
  metadata: _metadata
5093
5099
  }, null, _instanceExtraInitializers);
5094
- __esDecorate$3(this, null, _refreshIdentity_decorators, {
5100
+ __esDecorate$4(this, null, _refreshIdentity_decorators, {
5095
5101
  kind: "method",
5096
5102
  name: "refreshIdentity",
5097
5103
  static: false,
@@ -5102,7 +5108,7 @@ let SessionAccountController = (() => {
5102
5108
  },
5103
5109
  metadata: _metadata
5104
5110
  }, null, _instanceExtraInitializers);
5105
- __esDecorate$3(this, null, _ensureIdentity_decorators, {
5111
+ __esDecorate$4(this, null, _ensureIdentity_decorators, {
5106
5112
  kind: "method",
5107
5113
  name: "ensureIdentity",
5108
5114
  static: false,
@@ -5113,7 +5119,7 @@ let SessionAccountController = (() => {
5113
5119
  },
5114
5120
  metadata: _metadata
5115
5121
  }, null, _instanceExtraInitializers);
5116
- __esDecorate$3(this, null, _usage_decorators, {
5122
+ __esDecorate$4(this, null, _usage_decorators, {
5117
5123
  kind: "method",
5118
5124
  name: "usage",
5119
5125
  static: false,
@@ -5124,7 +5130,7 @@ let SessionAccountController = (() => {
5124
5130
  },
5125
5131
  metadata: _metadata
5126
5132
  }, null, _instanceExtraInitializers);
5127
- __esDecorate$3(this, null, _refreshUsage_decorators, {
5133
+ __esDecorate$4(this, null, _refreshUsage_decorators, {
5128
5134
  kind: "method",
5129
5135
  name: "refreshUsage",
5130
5136
  static: false,
@@ -5135,7 +5141,7 @@ let SessionAccountController = (() => {
5135
5141
  },
5136
5142
  metadata: _metadata
5137
5143
  }, null, _instanceExtraInitializers);
5138
- __esDecorate$3(this, null, _turn_decorators, {
5144
+ __esDecorate$4(this, null, _turn_decorators, {
5139
5145
  kind: "method",
5140
5146
  name: "turn",
5141
5147
  static: false,
@@ -5153,7 +5159,7 @@ let SessionAccountController = (() => {
5153
5159
  value: _metadata
5154
5160
  });
5155
5161
  }
5156
- owner = __runInitializers$3(this, _instanceExtraInitializers);
5162
+ owner = __runInitializers$4(this, _instanceExtraInitializers);
5157
5163
  constructor(ctx, owner) {
5158
5164
  super(ctx, "githubCopilotSessionAccount");
5159
5165
  this.owner = owner;
@@ -5259,7 +5265,7 @@ const usageSchema = z$1.object({
5259
5265
  totalTokens: count$2.optional(),
5260
5266
  reasoningTokens: count$2.optional()
5261
5267
  });
5262
- function record$10(value) {
5268
+ function record$11(value) {
5263
5269
  return typeof value === "object" && value !== null && !Array.isArray(value);
5264
5270
  }
5265
5271
  function sameRoute$1(left, right) {
@@ -5278,10 +5284,10 @@ function initialContextEvidence() {
5278
5284
  }
5279
5285
  /** Read only counts and routing leaves; never message content or opaque replay. */
5280
5286
  function foldContextEvidence(state, event) {
5281
- if (!record$10(event) || typeof event.type !== "string" || !record$10(event.data)) return state;
5287
+ if (!record$11(event) || typeof event.type !== "string" || !record$11(event.data)) return state;
5282
5288
  if (event.type === "request/header" || event.type === "model/selection") {
5283
- const raw = event.type === "request/header" ? record$10(event.data.header) ? event.data.header.config : void 0 : event.data;
5284
- if (!record$10(raw)) return {
5289
+ const raw = event.type === "request/header" ? record$11(event.data.header) ? event.data.header.config : void 0 : event.data;
5290
+ if (!record$11(raw)) return {
5285
5291
  ...state,
5286
5292
  route: null,
5287
5293
  sample: null,
@@ -5320,7 +5326,7 @@ function foldContextEvidence(state, event) {
5320
5326
  if (!copilot(state.route)) return state;
5321
5327
  if (event.type === "assistant/message" && event.data.source !== void 0) {
5322
5328
  const source = event.data.source;
5323
- const parsed = routeSchema.safeParse(record$10(source) ? {
5329
+ const parsed = routeSchema.safeParse(record$11(source) ? {
5324
5330
  provider: source.provider,
5325
5331
  model: source.model
5326
5332
  } : source);
@@ -5336,7 +5342,7 @@ function foldContextEvidence(state, event) {
5336
5342
  const settledUsage = usage !== void 0;
5337
5343
  let terminal;
5338
5344
  for (const entry of stream) {
5339
- if (!record$10(entry) || entry.type !== "chunk" || !record$10(entry.chunk)) continue;
5345
+ if (!record$11(entry) || entry.type !== "chunk" || !record$11(entry.chunk)) continue;
5340
5346
  if (!settledUsage && entry.chunk.type === "usage") usage = entry.chunk.usage;
5341
5347
  if (entry.chunk.type === "finish") terminal = entry.chunk.reason;
5342
5348
  }
@@ -5350,7 +5356,7 @@ function foldContextEvidence(state, event) {
5350
5356
  };
5351
5357
  const value = parsed.data;
5352
5358
  const zero = isZeroContextUsage(value);
5353
- const successful = record$10(terminal) && (terminal.kind === "stop" || terminal.kind === "max-tokens" || terminal.kind === "tool-calls");
5359
+ const successful = record$11(terminal) && (terminal.kind === "stop" || terminal.kind === "max-tokens" || terminal.kind === "tool-calls");
5354
5360
  if (zero && !successful) {
5355
5361
  const reason = state.sample !== null || state.reason === "none" ? "failed-zero" : state.reason;
5356
5362
  return {
@@ -5392,7 +5398,7 @@ const contextEvidenceDefinition = {
5392
5398
  function installContextEvidence(ctx) {
5393
5399
  ctx.inject(["sessionProjections"], (scope) => {
5394
5400
  const registry = scope.get("sessionProjections");
5395
- if (!record$10(registry) || typeof registry.register !== "function") {
5401
+ if (!record$11(registry) || typeof registry.register !== "function") {
5396
5402
  scope.logger.warn("[github-copilot] COPILOT_CONTEXT_PROJECTION_UNAVAILABLE");
5397
5403
  return;
5398
5404
  }
@@ -5739,8 +5745,20 @@ function readInlineConfig(config) {
5739
5745
  const exclusions = readConfigValue(config.excludedModelIds);
5740
5746
  const bindings = readConfigValue(config.parentModelFollow);
5741
5747
  const accounts = readConfigValue(config.sessionAccounts);
5748
+ const continuation = readConfigValue(config.sessionContinuation);
5749
+ const defaults = readConfigValue(config.continuationDefaultHistory);
5742
5750
  return {
5743
5751
  ...config,
5752
+ continuationDefaultHistory: defaults === void 0 ? void 0 : Array.from(defaults, (row) => ({
5753
+ enabled: row.enabled,
5754
+ changedAt: row.changedAt
5755
+ })),
5756
+ sessionContinuation: continuation === void 0 ? void 0 : Array.from(continuation, (row) => ({
5757
+ sessionId: row.sessionId,
5758
+ version: row.version,
5759
+ consentedAt: row.consentedAt,
5760
+ ...row.enabled === void 0 ? {} : { enabled: row.enabled }
5761
+ })),
5744
5762
  activeAccountId: readConfigValue(config.activeAccountId),
5745
5763
  sessionAccounts: accounts === void 0 ? void 0 : Array.from(accounts, (account) => ({
5746
5764
  sessionId: account.sessionId,
@@ -5779,6 +5797,16 @@ const Config = z.object({
5779
5797
  sessionId: z.string().min(1).max(256),
5780
5798
  accountId: z.string().min(1).max(36)
5781
5799
  })).default([]).hidden().volatile(),
5800
+ sessionContinuation: z.array(z.object({
5801
+ sessionId: z.string().min(1).max(256),
5802
+ version: z.const(1),
5803
+ consentedAt: z.number().step(1).min(0).max(Number.MAX_SAFE_INTEGER),
5804
+ enabled: z.boolean()
5805
+ })).default([]).hidden().volatile(),
5806
+ continuationDefaultHistory: z.array(z.object({
5807
+ enabled: z.boolean(),
5808
+ changedAt: z.number().step(1).min(0).max(Number.MAX_SAFE_INTEGER)
5809
+ })).default([]).hidden().volatile(),
5782
5810
  followParentModel: z.boolean().default(false).volatile(),
5783
5811
  autoSemanticAssessment: z.boolean().default(true),
5784
5812
  parentModelFollow: z.array(z.object({
@@ -6425,7 +6453,7 @@ function buildAnthropicWireBody(request, cfg, model) {
6425
6453
  }
6426
6454
  //#endregion
6427
6455
  //#region lib/types/responses-reasoning-text.js
6428
- function record$9(value) {
6456
+ function record$10(value) {
6429
6457
  return typeof value === "object" && value !== null;
6430
6458
  }
6431
6459
  function responseIndex(value) {
@@ -6483,13 +6511,13 @@ var ResponsesReasoningText = class {
6483
6511
  }
6484
6512
  /** Only recognized public text fields are examined; no copying of the item. */
6485
6513
  snapshot(item) {
6486
- if (!record$9(item) || item.type !== "reasoning") return "";
6514
+ if (!record$10(item) || item.type !== "reasoning") return "";
6487
6515
  let delta = "";
6488
6516
  for (const family of ["summary", "raw"]) {
6489
6517
  const value = family === "summary" ? item.summary : item.content;
6490
6518
  if (!Array.isArray(value)) continue;
6491
6519
  for (const [index, part] of value.entries()) {
6492
- if (!record$9(part) || part.type !== (family === "summary" ? "summary_text" : "reasoning_text")) continue;
6520
+ if (!record$10(part) || part.type !== (family === "summary" ? "summary_text" : "reasoning_text")) continue;
6493
6521
  delta += this.update(family, index, part.text, true);
6494
6522
  }
6495
6523
  }
@@ -7819,12 +7847,12 @@ function excludedModelSet(value) {
7819
7847
  * Host-side bridge between the Models-page companion UI and DSH's neutral
7820
7848
  * authorization, credential-record, and settings seams.
7821
7849
  */
7822
- var __runInitializers$2 = function(thisArg, initializers, value) {
7850
+ var __runInitializers$3 = function(thisArg, initializers, value) {
7823
7851
  var useValue = arguments.length > 2;
7824
7852
  for (var i = 0; i < initializers.length; i++) value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
7825
7853
  return useValue ? value : void 0;
7826
7854
  };
7827
- var __esDecorate$2 = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
7855
+ var __esDecorate$3 = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
7828
7856
  function accept(f) {
7829
7857
  if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected");
7830
7858
  return f;
@@ -8154,7 +8182,7 @@ let GitHubCopilotAuthorizationController = (() => {
8154
8182
  _start_decorators = [Remote];
8155
8183
  _cancel_decorators = [Remote];
8156
8184
  _signOut_decorators = [Remote];
8157
- __esDecorate$2(this, null, _migrationStatus_decorators, {
8185
+ __esDecorate$3(this, null, _migrationStatus_decorators, {
8158
8186
  kind: "method",
8159
8187
  name: "migrationStatus",
8160
8188
  static: false,
@@ -8165,7 +8193,7 @@ let GitHubCopilotAuthorizationController = (() => {
8165
8193
  },
8166
8194
  metadata: _metadata
8167
8195
  }, null, _instanceExtraInitializers);
8168
- __esDecorate$2(this, null, _status_decorators, {
8196
+ __esDecorate$3(this, null, _status_decorators, {
8169
8197
  kind: "method",
8170
8198
  name: "status",
8171
8199
  static: false,
@@ -8176,7 +8204,7 @@ let GitHubCopilotAuthorizationController = (() => {
8176
8204
  },
8177
8205
  metadata: _metadata
8178
8206
  }, null, _instanceExtraInitializers);
8179
- __esDecorate$2(this, null, _excludeModel_decorators, {
8207
+ __esDecorate$3(this, null, _excludeModel_decorators, {
8180
8208
  kind: "method",
8181
8209
  name: "excludeModel",
8182
8210
  static: false,
@@ -8187,7 +8215,7 @@ let GitHubCopilotAuthorizationController = (() => {
8187
8215
  },
8188
8216
  metadata: _metadata
8189
8217
  }, null, _instanceExtraInitializers);
8190
- __esDecorate$2(this, null, _restoreModel_decorators, {
8218
+ __esDecorate$3(this, null, _restoreModel_decorators, {
8191
8219
  kind: "method",
8192
8220
  name: "restoreModel",
8193
8221
  static: false,
@@ -8198,7 +8226,7 @@ let GitHubCopilotAuthorizationController = (() => {
8198
8226
  },
8199
8227
  metadata: _metadata
8200
8228
  }, null, _instanceExtraInitializers);
8201
- __esDecorate$2(this, null, _setModelExcluded_decorators, {
8229
+ __esDecorate$3(this, null, _setModelExcluded_decorators, {
8202
8230
  kind: "method",
8203
8231
  name: "setModelExcluded",
8204
8232
  static: false,
@@ -8209,7 +8237,7 @@ let GitHubCopilotAuthorizationController = (() => {
8209
8237
  },
8210
8238
  metadata: _metadata
8211
8239
  }, null, _instanceExtraInitializers);
8212
- __esDecorate$2(this, null, _discoverModels_decorators, {
8240
+ __esDecorate$3(this, null, _discoverModels_decorators, {
8213
8241
  kind: "method",
8214
8242
  name: "discoverModels",
8215
8243
  static: false,
@@ -8220,7 +8248,7 @@ let GitHubCopilotAuthorizationController = (() => {
8220
8248
  },
8221
8249
  metadata: _metadata
8222
8250
  }, null, _instanceExtraInitializers);
8223
- __esDecorate$2(this, null, _ensureModels_decorators, {
8251
+ __esDecorate$3(this, null, _ensureModels_decorators, {
8224
8252
  kind: "method",
8225
8253
  name: "ensureModels",
8226
8254
  static: false,
@@ -8231,7 +8259,7 @@ let GitHubCopilotAuthorizationController = (() => {
8231
8259
  },
8232
8260
  metadata: _metadata
8233
8261
  }, null, _instanceExtraInitializers);
8234
- __esDecorate$2(this, null, _reconcile_decorators, {
8262
+ __esDecorate$3(this, null, _reconcile_decorators, {
8235
8263
  kind: "method",
8236
8264
  name: "reconcile",
8237
8265
  static: false,
@@ -8242,7 +8270,7 @@ let GitHubCopilotAuthorizationController = (() => {
8242
8270
  },
8243
8271
  metadata: _metadata
8244
8272
  }, null, _instanceExtraInitializers);
8245
- __esDecorate$2(this, null, _start_decorators, {
8273
+ __esDecorate$3(this, null, _start_decorators, {
8246
8274
  kind: "method",
8247
8275
  name: "start",
8248
8276
  static: false,
@@ -8253,7 +8281,7 @@ let GitHubCopilotAuthorizationController = (() => {
8253
8281
  },
8254
8282
  metadata: _metadata
8255
8283
  }, null, _instanceExtraInitializers);
8256
- __esDecorate$2(this, null, _cancel_decorators, {
8284
+ __esDecorate$3(this, null, _cancel_decorators, {
8257
8285
  kind: "method",
8258
8286
  name: "cancel",
8259
8287
  static: false,
@@ -8264,7 +8292,7 @@ let GitHubCopilotAuthorizationController = (() => {
8264
8292
  },
8265
8293
  metadata: _metadata
8266
8294
  }, null, _instanceExtraInitializers);
8267
- __esDecorate$2(this, null, _signOut_decorators, {
8295
+ __esDecorate$3(this, null, _signOut_decorators, {
8268
8296
  kind: "method",
8269
8297
  name: "signOut",
8270
8298
  static: false,
@@ -8282,7 +8310,7 @@ let GitHubCopilotAuthorizationController = (() => {
8282
8310
  value: _metadata
8283
8311
  });
8284
8312
  }
8285
- notices = (__runInitializers$2(this, _instanceExtraInitializers), []);
8313
+ notices = (__runInitializers$3(this, _instanceExtraInitializers), []);
8286
8314
  failure;
8287
8315
  reconciliationFailed = false;
8288
8316
  attempt;
@@ -8737,13 +8765,13 @@ function resolveCopilotResponsesReasoning(ctx, request, candidate) {
8737
8765
  }
8738
8766
  //#endregion
8739
8767
  //#region lib/types/replay-recovery.js
8740
- function record$8(value) {
8768
+ function record$9(value) {
8741
8769
  return value !== null && typeof value === "object" && !Array.isArray(value);
8742
8770
  }
8743
8771
  function parsed(body) {
8744
8772
  if (requestBodyEvidence(body, "openai-responses").state !== "complete" || body === void 0) throw new Error("COPILOT_REPLAY_RECOVERY_EVIDENCE_UNAVAILABLE");
8745
8773
  const payload = JSON.parse(body);
8746
- if (!record$8(payload) || !Array.isArray(payload.input) || !payload.input.every(record$8)) throw new Error("COPILOT_REPLAY_RECOVERY_INVALID_PAYLOAD");
8774
+ if (!record$9(payload) || !Array.isArray(payload.input) || !payload.input.every(record$9)) throw new Error("COPILOT_REPLAY_RECOVERY_INVALID_PAYLOAD");
8747
8775
  return {
8748
8776
  input: payload.input,
8749
8777
  payload
@@ -8839,7 +8867,7 @@ var ReplayRecoveryStore = class {
8839
8867
  const value = hash(item);
8840
8868
  return value === void 0 || !admitted.has(value);
8841
8869
  }).length === decoded.input.length) return payload;
8842
- if (!record$8(payload) || !Array.isArray(payload.input)) throw new Error("COPILOT_REPLAY_RECOVERY_INVALID_PAYLOAD");
8870
+ if (!record$9(payload) || !Array.isArray(payload.input)) throw new Error("COPILOT_REPLAY_RECOVERY_INVALID_PAYLOAD");
8843
8871
  const input = payload.input.filter((_, index) => {
8844
8872
  const item = decoded.input[index];
8845
8873
  const value = hash(item);
@@ -8860,12 +8888,12 @@ var ReplayRecoveryStore = class {
8860
8888
  };
8861
8889
  //#endregion
8862
8890
  //#region lib/types/replay-recovery-host.js
8863
- var __runInitializers$1 = function(thisArg, initializers, value) {
8891
+ var __runInitializers$2 = function(thisArg, initializers, value) {
8864
8892
  var useValue = arguments.length > 2;
8865
8893
  for (var i = 0; i < initializers.length; i++) value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
8866
8894
  return useValue ? value : void 0;
8867
8895
  };
8868
- var __esDecorate$1 = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
8896
+ var __esDecorate$2 = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
8869
8897
  function accept(f) {
8870
8898
  if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected");
8871
8899
  return f;
@@ -8912,7 +8940,7 @@ let ReplayRecoveryController = (() => {
8912
8940
  _get_decorators = [Remote];
8913
8941
  _setEnabled_decorators = [Remote];
8914
8942
  _authorize_decorators = [Remote];
8915
- __esDecorate$1(this, null, _get_decorators, {
8943
+ __esDecorate$2(this, null, _get_decorators, {
8916
8944
  kind: "method",
8917
8945
  name: "get",
8918
8946
  static: false,
@@ -8923,7 +8951,7 @@ let ReplayRecoveryController = (() => {
8923
8951
  },
8924
8952
  metadata: _metadata
8925
8953
  }, null, _instanceExtraInitializers);
8926
- __esDecorate$1(this, null, _setEnabled_decorators, {
8954
+ __esDecorate$2(this, null, _setEnabled_decorators, {
8927
8955
  kind: "method",
8928
8956
  name: "setEnabled",
8929
8957
  static: false,
@@ -8934,7 +8962,7 @@ let ReplayRecoveryController = (() => {
8934
8962
  },
8935
8963
  metadata: _metadata
8936
8964
  }, null, _instanceExtraInitializers);
8937
- __esDecorate$1(this, null, _authorize_decorators, {
8965
+ __esDecorate$2(this, null, _authorize_decorators, {
8938
8966
  kind: "method",
8939
8967
  name: "authorize",
8940
8968
  static: false,
@@ -8952,7 +8980,7 @@ let ReplayRecoveryController = (() => {
8952
8980
  value: _metadata
8953
8981
  });
8954
8982
  }
8955
- store = __runInitializers$1(this, _instanceExtraInitializers);
8983
+ store = __runInitializers$2(this, _instanceExtraInitializers);
8956
8984
  proof;
8957
8985
  busy;
8958
8986
  constructor(ctx, store, proof, busy) {
@@ -9038,6 +9066,419 @@ function installReplayRecovery(ctx, proof) {
9038
9066
  };
9039
9067
  }
9040
9068
  //#endregion
9069
+ //#region lib/types/session-continuation.js
9070
+ const SESSION_CONTINUATION_LIMITS = Object.freeze({
9071
+ items: 4096,
9072
+ values: 65536,
9073
+ depth: 64,
9074
+ bytes: 16777216
9075
+ });
9076
+ function record$8(value) {
9077
+ return typeof value === "object" && value !== null && !Array.isArray(value);
9078
+ }
9079
+ function fingerprint(item) {
9080
+ if (!record$8(item)) throw new Error("COPILOT_CONTINUATION_INVALID_PAYLOAD");
9081
+ if (item.type !== "reasoning") return void 0;
9082
+ if (typeof item.encrypted_content !== "string" || !item.encrypted_content || item.status !== void 0 && item.status !== "completed") throw new Error("COPILOT_CONTINUATION_UNSUPPORTED_REASONING");
9083
+ return createHash("sha256").update(item.encrypted_content).digest("hex");
9084
+ }
9085
+ /** One admitted turn; fingerprints never become durable history or account provenance. */
9086
+ var SessionContinuationTurn = class {
9087
+ baseline;
9088
+ get initialized() {
9089
+ return this.baseline !== void 0;
9090
+ }
9091
+ transform(payload) {
9092
+ if (!record$8(payload) || !Array.isArray(payload.input) || payload.input.length > SESSION_CONTINUATION_LIMITS.values) throw new Error("COPILOT_CONTINUATION_INVALID_PAYLOAD");
9093
+ const pending = [{
9094
+ value: payload,
9095
+ depth: 0
9096
+ }];
9097
+ let values = 0, stringBytes = 0;
9098
+ while (pending.length) {
9099
+ const { value, depth } = pending.pop();
9100
+ if (++values > SESSION_CONTINUATION_LIMITS.values || depth > SESSION_CONTINUATION_LIMITS.depth) throw new Error("COPILOT_CONTINUATION_WORK_LIMIT");
9101
+ if (typeof value === "string") stringBytes += Buffer.byteLength(value);
9102
+ else if (Array.isArray(value)) {
9103
+ if (pending.length + value.length > SESSION_CONTINUATION_LIMITS.values) throw new Error("COPILOT_CONTINUATION_WORK_LIMIT");
9104
+ for (const child of value) pending.push({
9105
+ value: child,
9106
+ depth: depth + 1
9107
+ });
9108
+ } else if (record$8(value)) {
9109
+ const entries = Object.entries(value);
9110
+ if (pending.length + entries.length > SESSION_CONTINUATION_LIMITS.values) throw new Error("COPILOT_CONTINUATION_WORK_LIMIT");
9111
+ for (const [key, child] of entries) {
9112
+ stringBytes += Buffer.byteLength(key);
9113
+ pending.push({
9114
+ value: child,
9115
+ depth: depth + 1
9116
+ });
9117
+ }
9118
+ }
9119
+ if (stringBytes > SESSION_CONTINUATION_LIMITS.bytes) throw new Error("COPILOT_CONTINUATION_PAYLOAD_LIMIT");
9120
+ }
9121
+ let bytes;
9122
+ try {
9123
+ bytes = JSON.stringify(payload);
9124
+ } catch {
9125
+ throw new Error("COPILOT_CONTINUATION_INVALID_PAYLOAD");
9126
+ }
9127
+ if (Buffer.byteLength(bytes) > SESSION_CONTINUATION_LIMITS.bytes) throw new Error("COPILOT_CONTINUATION_PAYLOAD_LIMIT");
9128
+ const hashes = payload.input.map(fingerprint);
9129
+ const present = new Set(hashes.filter((value) => value !== void 0));
9130
+ if (present.size > SESSION_CONTINUATION_LIMITS.items) throw new Error("COPILOT_CONTINUATION_ITEM_LIMIT");
9131
+ this.baseline ??= present;
9132
+ const input = payload.input.filter((_, index) => hashes[index] === void 0 || !this.baseline.has(hashes[index]));
9133
+ return input.length === payload.input.length ? payload : {
9134
+ ...payload,
9135
+ input
9136
+ };
9137
+ }
9138
+ };
9139
+ //#endregion
9140
+ //#region lib/types/session-continuation-types.js
9141
+ const SessionContinuationPreferenceSchema = z$1.object({
9142
+ sessionId: z$1.string().min(1).max(256).refine((value) => !/[\p{Cc}\p{Cf}]/u.test(value)),
9143
+ version: z$1.literal(1),
9144
+ consentedAt: z$1.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
9145
+ enabled: z$1.boolean().optional()
9146
+ }).strict();
9147
+ const SessionContinuationPreferencesSchema = z$1.array(SessionContinuationPreferenceSchema).max(2048).refine((rows) => new Set(rows.map((row) => row.sessionId)).size === rows.length);
9148
+ const ContinuationDefaultHistorySchema = z$1.array(z$1.object({
9149
+ enabled: z$1.boolean(),
9150
+ changedAt: z$1.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER)
9151
+ }).strict()).max(2048).refine((rows) => rows.every((row, index) => index === 0 || row.changedAt > rows[index - 1].changedAt));
9152
+ z$1.object({
9153
+ enabled: z$1.boolean(),
9154
+ revision: z$1.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER)
9155
+ }).strict();
9156
+ z$1.object({
9157
+ enabled: z$1.boolean(),
9158
+ revision: z$1.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
9159
+ activeTurnEnabled: z$1.boolean().optional(),
9160
+ source: z$1.enum(["default", "session"]).optional(),
9161
+ nextTurnAuthorized: z$1.boolean().optional()
9162
+ }).strict();
9163
+ //#endregion
9164
+ //#region lib/types/session-continuation-host.js
9165
+ var __runInitializers$1 = function(thisArg, initializers, value) {
9166
+ var useValue = arguments.length > 2;
9167
+ for (var i = 0; i < initializers.length; i++) value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
9168
+ return useValue ? value : void 0;
9169
+ };
9170
+ var __esDecorate$1 = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
9171
+ function accept(f) {
9172
+ if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected");
9173
+ return f;
9174
+ }
9175
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
9176
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
9177
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
9178
+ var _, done = false;
9179
+ for (var i = decorators.length - 1; i >= 0; i--) {
9180
+ var context = {};
9181
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
9182
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
9183
+ context.addInitializer = function(f) {
9184
+ if (done) throw new TypeError("Cannot add initializers after decoration has completed");
9185
+ extraInitializers.push(accept(f || null));
9186
+ };
9187
+ var result = (0, decorators[i])(kind === "accessor" ? {
9188
+ get: descriptor.get,
9189
+ set: descriptor.set
9190
+ } : descriptor[key], context);
9191
+ if (kind === "accessor") {
9192
+ if (result === void 0) continue;
9193
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
9194
+ if (_ = accept(result.get)) descriptor.get = _;
9195
+ if (_ = accept(result.set)) descriptor.set = _;
9196
+ if (_ = accept(result.init)) initializers.unshift(_);
9197
+ } else if (_ = accept(result)) {
9198
+ if (kind === "field") initializers.unshift(_);
9199
+ else descriptor[key] = _;
9200
+ }
9201
+ }
9202
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
9203
+ done = true;
9204
+ };
9205
+ function preferences(value) {
9206
+ if (typeof value !== "object" || value === null) throw new Error("COPILOT_CONTINUATION_SETTINGS_UNAVAILABLE");
9207
+ const raw = "sessionContinuation" in value ? value.sessionContinuation : [];
9208
+ const parsed = SessionContinuationPreferencesSchema.safeParse(raw);
9209
+ if (!parsed.success) throw new Error("COPILOT_CONTINUATION_SETTINGS_INVALID");
9210
+ return parsed.data;
9211
+ }
9212
+ let SessionContinuationController = (() => {
9213
+ let _classSuper = TypertRemoteService;
9214
+ let _instanceExtraInitializers = [];
9215
+ let _get_decorators;
9216
+ let _set_decorators;
9217
+ let _authorizeNext_decorators;
9218
+ let _defaults_decorators;
9219
+ let _setDefault_decorators;
9220
+ return class SessionContinuationController extends _classSuper {
9221
+ static {
9222
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
9223
+ _get_decorators = [Remote];
9224
+ _set_decorators = [Remote];
9225
+ _authorizeNext_decorators = [Remote];
9226
+ _defaults_decorators = [Remote];
9227
+ _setDefault_decorators = [Remote];
9228
+ __esDecorate$1(this, null, _get_decorators, {
9229
+ kind: "method",
9230
+ name: "get",
9231
+ static: false,
9232
+ private: false,
9233
+ access: {
9234
+ has: (obj) => "get" in obj,
9235
+ get: (obj) => obj.get
9236
+ },
9237
+ metadata: _metadata
9238
+ }, null, _instanceExtraInitializers);
9239
+ __esDecorate$1(this, null, _set_decorators, {
9240
+ kind: "method",
9241
+ name: "set",
9242
+ static: false,
9243
+ private: false,
9244
+ access: {
9245
+ has: (obj) => "set" in obj,
9246
+ get: (obj) => obj.set
9247
+ },
9248
+ metadata: _metadata
9249
+ }, null, _instanceExtraInitializers);
9250
+ __esDecorate$1(this, null, _authorizeNext_decorators, {
9251
+ kind: "method",
9252
+ name: "authorizeNext",
9253
+ static: false,
9254
+ private: false,
9255
+ access: {
9256
+ has: (obj) => "authorizeNext" in obj,
9257
+ get: (obj) => obj.authorizeNext
9258
+ },
9259
+ metadata: _metadata
9260
+ }, null, _instanceExtraInitializers);
9261
+ __esDecorate$1(this, null, _defaults_decorators, {
9262
+ kind: "method",
9263
+ name: "defaults",
9264
+ static: false,
9265
+ private: false,
9266
+ access: {
9267
+ has: (obj) => "defaults" in obj,
9268
+ get: (obj) => obj.defaults
9269
+ },
9270
+ metadata: _metadata
9271
+ }, null, _instanceExtraInitializers);
9272
+ __esDecorate$1(this, null, _setDefault_decorators, {
9273
+ kind: "method",
9274
+ name: "setDefault",
9275
+ static: false,
9276
+ private: false,
9277
+ access: {
9278
+ has: (obj) => "setDefault" in obj,
9279
+ get: (obj) => obj.setDefault
9280
+ },
9281
+ metadata: _metadata
9282
+ }, null, _instanceExtraInitializers);
9283
+ if (_metadata) Object.defineProperty(this, Symbol.metadata, {
9284
+ enumerable: true,
9285
+ configurable: true,
9286
+ writable: true,
9287
+ value: _metadata
9288
+ });
9289
+ }
9290
+ active = __runInitializers$1(this, _instanceExtraInitializers);
9291
+ once;
9292
+ ready;
9293
+ constructor(ctx, active, once = /* @__PURE__ */ new Set(), ready = Promise.resolve()) {
9294
+ super(ctx, "githubCopilotSessionContinuation");
9295
+ this.active = active;
9296
+ this.once = once;
9297
+ this.ready = ready;
9298
+ }
9299
+ async get(agent) {
9300
+ await this.ready;
9301
+ const entry = this.ctx.get("settings")?.describe({ redactSecrets: true }).find((row) => row.ns === "github-copilot");
9302
+ if (!entry) throw new Error("COPILOT_CONTINUATION_SETTINGS_UNAVAILABLE");
9303
+ const admission = this.active.get(agent.session);
9304
+ const explicit = preferences(entry.value).find((row) => row.sessionId === agent.session.id);
9305
+ return {
9306
+ enabled: resolveEnabled(agent, entry.value),
9307
+ source: explicit ? "session" : "default",
9308
+ nextTurnAuthorized: this.once.has(agent.session),
9309
+ revision: entry.revision,
9310
+ ...admission ? { activeTurnEnabled: admission.enabled } : {}
9311
+ };
9312
+ }
9313
+ async set(agent, revision, enabled) {
9314
+ await this.ready;
9315
+ const settings = this.ctx.get("settings");
9316
+ const entry = settings?.describe({ redactSecrets: true }).find((row) => row.ns === "github-copilot");
9317
+ if (!settings || !entry) throw new Error("COPILOT_CONTINUATION_SETTINGS_UNAVAILABLE");
9318
+ if (entry.revision !== revision) throw new Error("COPILOT_CONTINUATION_CONFLICT");
9319
+ const next = preferences(entry.value).filter((row) => row.sessionId !== agent.session.id);
9320
+ if (enabled !== null) next.push({
9321
+ sessionId: agent.session.id,
9322
+ version: 1,
9323
+ consentedAt: Date.now(),
9324
+ enabled
9325
+ });
9326
+ if (!SessionContinuationPreferencesSchema.safeParse(next).success) throw new Error("COPILOT_CONTINUATION_SETTINGS_LIMIT");
9327
+ await settings.mutate("github-copilot", [{
9328
+ op: "set",
9329
+ path: ["sessionContinuation"],
9330
+ value: next
9331
+ }], revision);
9332
+ const actual = await this.get(agent);
9333
+ if (enabled !== null && actual.enabled !== enabled || enabled === null && actual.source !== "default") throw new Error("COPILOT_CONTINUATION_COMMIT_UNCERTAIN");
9334
+ this.once.delete(agent.session);
9335
+ return {
9336
+ ...actual,
9337
+ nextTurnAuthorized: false
9338
+ };
9339
+ }
9340
+ async authorizeNext(agent, revision, enabled) {
9341
+ if ((await this.get(agent)).revision !== revision) throw new Error("COPILOT_CONTINUATION_CONFLICT");
9342
+ if (enabled && !this.once.has(agent.session) && this.once.size >= 2048) throw new Error("COPILOT_CONTINUATION_CONSENT_LIMIT");
9343
+ if (enabled) this.once.add(agent.session);
9344
+ else this.once.delete(agent.session);
9345
+ return this.get(agent);
9346
+ }
9347
+ async defaults() {
9348
+ await this.ready;
9349
+ const entry = this.ctx.get("settings")?.describe({ redactSecrets: true }).find((row) => row.ns === "github-copilot");
9350
+ if (!entry) throw new Error("COPILOT_CONTINUATION_SETTINGS_UNAVAILABLE");
9351
+ return {
9352
+ enabled: defaultHistory(entry.value).at(-1)?.enabled ?? false,
9353
+ revision: entry.revision
9354
+ };
9355
+ }
9356
+ async setDefault(revision, enabled) {
9357
+ await this.ready;
9358
+ const settings = this.ctx.get("settings");
9359
+ const entry = settings?.describe({ redactSecrets: true }).find((row) => row.ns === "github-copilot");
9360
+ if (!settings || !entry) throw new Error("COPILOT_CONTINUATION_SETTINGS_UNAVAILABLE");
9361
+ if (entry.revision !== revision) throw new Error("COPILOT_CONTINUATION_CONFLICT");
9362
+ const history = defaultHistory(entry.value);
9363
+ if ((history.at(-1)?.enabled ?? false) === enabled) return this.defaults();
9364
+ const changedAt = Math.max(Date.now(), (history.at(-1)?.changedAt ?? -1) + 1);
9365
+ const next = [...history, {
9366
+ enabled,
9367
+ changedAt
9368
+ }];
9369
+ if (!ContinuationDefaultHistorySchema.safeParse(next).success) throw new Error("COPILOT_CONTINUATION_SETTINGS_LIMIT");
9370
+ await settings.mutate("github-copilot", [{
9371
+ op: "set",
9372
+ path: ["continuationDefaultHistory"],
9373
+ value: next
9374
+ }], revision);
9375
+ const actual = await this.defaults();
9376
+ if (actual.enabled !== enabled) throw new Error("COPILOT_CONTINUATION_COMMIT_UNCERTAIN");
9377
+ return actual;
9378
+ }
9379
+ };
9380
+ })();
9381
+ function defaultHistory(value) {
9382
+ if (typeof value !== "object" || value === null) throw new Error("COPILOT_CONTINUATION_SETTINGS_UNAVAILABLE");
9383
+ const parsed = ContinuationDefaultHistorySchema.safeParse("continuationDefaultHistory" in value ? value.continuationDefaultHistory : []);
9384
+ if (!parsed.success) throw new Error("COPILOT_CONTINUATION_SETTINGS_INVALID");
9385
+ return parsed.data;
9386
+ }
9387
+ function resolveEnabled(agent, value) {
9388
+ const explicit = preferences(value).find((row) => row.sessionId === agent.session.id);
9389
+ if (explicit) return explicit.enabled ?? true;
9390
+ const history = defaultHistory(value);
9391
+ const header = agent.session.header;
9392
+ if (!header || header.isSeeded !== false || !Number.isSafeInteger(header.createdAt)) return false;
9393
+ return history.findLast((row) => row.changedAt < header.createdAt)?.enabled ?? false;
9394
+ }
9395
+ function installSessionContinuation(ctx) {
9396
+ if (!ctx.get("settings")) {
9397
+ ctx.logger.warn("COPILOT_CONTINUATION_SETTINGS_UNAVAILABLE: continuation integration is not active");
9398
+ return {
9399
+ ready: Promise.resolve(),
9400
+ prepare: () => void 0,
9401
+ dispose() {}
9402
+ };
9403
+ }
9404
+ const active = /* @__PURE__ */ new Map();
9405
+ const once = /* @__PURE__ */ new Set();
9406
+ const requests = /* @__PURE__ */ new WeakMap();
9407
+ const ready = (async () => {
9408
+ const settings = ctx.get("settings");
9409
+ const entry = settings?.describe({ redactSecrets: true }).find((row) => row.ns === "github-copilot");
9410
+ if (!settings || !entry) throw new Error("COPILOT_CONTINUATION_SETTINGS_UNAVAILABLE");
9411
+ if (defaultHistory(entry.value).length) return;
9412
+ await settings.mutate("github-copilot", [{
9413
+ op: "set",
9414
+ path: ["continuationDefaultHistory"],
9415
+ value: [{
9416
+ enabled: true,
9417
+ changedAt: Date.now()
9418
+ }]
9419
+ }], entry.revision);
9420
+ if (!defaultHistory(readSettingsNamespace(ctx, "github-copilot")).length) throw new Error("COPILOT_CONTINUATION_COMMIT_UNCERTAIN");
9421
+ })();
9422
+ ready.catch(() => ctx.logger.warn("COPILOT_CONTINUATION_INITIALIZATION_FAILED"));
9423
+ new SessionContinuationController(ctx, active, once, ready);
9424
+ const removeRequest = ctx.on("agent/request", async ({ agent, turn, step, signal }, next) => {
9425
+ const result = await next();
9426
+ if (signal.aborted || result.provider !== "github-copilot-preview") return result;
9427
+ await ready;
9428
+ if (signal.aborted) return result;
9429
+ if (!Number.isSafeInteger(turn) || turn < 0) throw new Error("COPILOT_CONTINUATION_TURN_INVALID");
9430
+ let admission = active.get(agent.session);
9431
+ if (admission && admission.turn !== turn) throw new Error("COPILOT_CONTINUATION_TURN_UNSETTLED");
9432
+ if (!admission) {
9433
+ admission = {
9434
+ turn,
9435
+ step,
9436
+ enabled: resolveEnabled(agent, readSettingsNamespace(ctx, "github-copilot")) || once.has(agent.session),
9437
+ filter: new SessionContinuationTurn(),
9438
+ signal
9439
+ };
9440
+ active.set(agent.session, admission);
9441
+ once.delete(agent.session);
9442
+ }
9443
+ admission.signal = signal;
9444
+ admission.step = step;
9445
+ requests.set(signal, agent.session);
9446
+ return result;
9447
+ });
9448
+ const removeEvents = ctx.on("session/event", (session, event) => {
9449
+ if (event.type === "turn/end" && active.get(session)?.turn === event.data.turn) active.delete(session);
9450
+ });
9451
+ const removeAgent = ctx.on("agent/disposed", ({ agent }) => {
9452
+ active.delete(agent.session);
9453
+ once.delete(agent.session);
9454
+ });
9455
+ let disposed = false;
9456
+ return {
9457
+ ready,
9458
+ prepare(request) {
9459
+ if (request.provider !== "github-copilot-preview" || request.purpose !== void 0 || !request.signal) return void 0;
9460
+ const session = requests.get(request.signal);
9461
+ const admission = session && active.get(session);
9462
+ if (!session || session.id !== request.sessionId || !admission?.enabled) return void 0;
9463
+ if (!admission.filter.initialized && admission.step !== 1) throw new Error("COPILOT_CONTINUATION_TURN_BOUNDARY_UNAVAILABLE");
9464
+ const current = () => !disposed && !request.signal.aborted && active.get(session) === admission && admission.signal === request.signal;
9465
+ if (!current()) throw new Error("COPILOT_CONTINUATION_REVOKED");
9466
+ return (payload) => {
9467
+ if (!current()) throw new Error("COPILOT_CONTINUATION_REVOKED");
9468
+ return admission.filter.transform(payload);
9469
+ };
9470
+ },
9471
+ dispose() {
9472
+ disposed = true;
9473
+ removeRequest();
9474
+ removeEvents();
9475
+ removeAgent();
9476
+ active.clear();
9477
+ once.clear();
9478
+ }
9479
+ };
9480
+ }
9481
+ //#endregion
9041
9482
  //#region lib/types/agent-compaction.js
9042
9483
  function record$7(value) {
9043
9484
  return typeof value === "object" && value !== null;
@@ -11795,11 +12236,27 @@ function apply$1(ctx, config = {}) {
11795
12236
  };
11796
12237
  const currentRuntime = (signal) => runtimeFor(requestBinding(signal));
11797
12238
  const directoryRuntime = () => runtimeFor(globalBinding());
11798
- const replayRecovery = installReplayRecovery(ctx, (agent, request) => {
12239
+ const temporaryRecovery = installReplayRecovery(ctx, (agent, request) => {
11799
12240
  const accounts = ctx.get("githubCopilotSessionAccounts");
11800
12241
  const binding = agent !== void 0 && accounts !== void 0 ? accounts.bindingForAccount((accounts.turns.current(agent.session) ?? accounts.selected(agent)).accountId) : requestBinding(request?.signal);
11801
12242
  return runtimeFor(binding).proof();
11802
12243
  });
12244
+ const continuation = installSessionContinuation(ctx);
12245
+ const replayRecovery = {
12246
+ prepare(request) {
12247
+ const portable = continuation.prepare(request);
12248
+ const temporary = temporaryRecovery.prepare(request);
12249
+ if (!portable) return temporary;
12250
+ return {
12251
+ transform: portable,
12252
+ rejected: (body) => temporary?.rejected(body)
12253
+ };
12254
+ },
12255
+ dispose() {
12256
+ temporaryRecovery.dispose();
12257
+ continuation.dispose();
12258
+ }
12259
+ };
11803
12260
  const initial = directoryRuntime();
11804
12261
  const registration = ctx.llm.registerAdapter([GITHUB_COPILOT_PREVIEW_PROVIDER_ID], new AccountRoutingAdapter(initial.optionsFor(), currentRuntime));
11805
12262
  publish = () => {