dsh-github-copilot 0.4.0-alpha.107 → 0.4.0-alpha.109

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;
@@ -2220,14 +2220,16 @@ function requestBodyEvidence(body, protocol) {
2220
2220
  //#endregion
2221
2221
  //#region lib/types/responses-replay-compat.js
2222
2222
  const replayDiagnostics = {
2223
- "scope-mismatch": "COPILOT_RESPONSES_REPLAY_SCOPE_MISMATCH: Copilot Responses input references belong to a different connection.",
2223
+ "scope-mismatch": "COPILOT_RESPONSES_REPLAY_SCOPE_MISMATCH: Copilot rejected history tied to another account or connection. Review Replay recovery options, or start a new conversation. Recovery requires consent; stored history is unchanged.",
2224
2224
  unsupported: "COPILOT_RESPONSES_REPLAY_UNSUPPORTED: Copilot Responses input cannot be replayed safely without connection-scoped references.",
2225
2225
  "invalid-payload": "COPILOT_RESPONSES_REPLAY_INVALID_PAYLOAD: Copilot Responses payload has an invalid replay structure."
2226
2226
  };
2227
2227
  /** Fixed diagnostics and bounded counts only; never retain request or replay content. */
2228
2228
  var CopilotResponsesReplayError = class extends Error {
2229
+ dispatchEvidence;
2229
2230
  constructor(reason = "unsupported", dispatch) {
2230
- super(replayDiagnostics[reason] + (reason === "scope-mismatch" && dispatch !== void 0 ? ` ${replayDispatchEvidence(dispatch)}` : ""));
2231
+ super(replayDiagnostics[reason]);
2232
+ if (reason === "scope-mismatch" && dispatch !== void 0) this.dispatchEvidence = replayDispatchEvidence(dispatch);
2231
2233
  this.name = "CopilotResponsesReplayError";
2232
2234
  }
2233
2235
  };
@@ -2352,7 +2354,7 @@ var ResponsesRetryReplay = class {
2352
2354
  let finished = false;
2353
2355
  let observed = false;
2354
2356
  return {
2355
- normalize: (payload) => {
2357
+ normalize: (payload, transform) => {
2356
2358
  if (this.disposed || signal?.aborted) throw new CopilotResponsesReplayError();
2357
2359
  const rawBytes = cacheBytes(payload);
2358
2360
  let normalized;
@@ -2393,6 +2395,7 @@ var ResponsesRetryReplay = class {
2393
2395
  normalized = JSON.parse(eligible.normalized);
2394
2396
  reused = true;
2395
2397
  }
2398
+ if (transform !== void 0) normalized = transform(normalized);
2396
2399
  payloadBytes = cacheBytes(normalized);
2397
2400
  candidate = signal === void 0 || !sessionId || !modelId || contextBytes === void 0 || rawBytes === void 0 || payloadBytes === void 0 ? void 0 : {
2398
2401
  raw: JSON.parse(rawBytes),
@@ -2545,16 +2548,16 @@ function formatRequestUploadEvidence(evidence) {
2545
2548
  //#endregion
2546
2549
  //#region lib/types/request-body-timeout.js
2547
2550
  const observedMessage = "Timed out reading request body. Try again, or use a smaller request size.";
2548
- function record$11(value) {
2551
+ function record$12(value) {
2549
2552
  return typeof value === "object" && value !== null && !Array.isArray(value);
2550
2553
  }
2551
2554
  /** Verified provider evidence, not guessed capabilities, token limits or network cause. */
2552
2555
  async function requestBodyTimeoutDiagnostic(response, body, signal, dispatch) {
2553
2556
  if (response.status !== 408 || signal?.aborted) return void 0;
2554
2557
  const value = await readResponseErrorJson(response, signal);
2555
- if (signal?.aborted || !record$11(value)) return void 0;
2558
+ if (signal?.aborted || !record$12(value)) return void 0;
2556
2559
  const error = Object.hasOwn(value, "error") ? value.error : value;
2557
- 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;
2558
2561
  const size = body === void 0 ? "Request body size unavailable." : `Request body: ${Buffer.byteLength(body, "utf8")} UTF-8 bytes (not context tokens).`;
2559
2562
  const composition = formatRequestBodyEvidence(dispatch === void 0 ? { state: "unavailable" } : requestBodyEvidence(body, dispatch.protocol), dispatch?.responseHeadersMs);
2560
2563
  const upload = formatRequestUploadEvidence(dispatch?.upload);
@@ -2893,7 +2896,8 @@ function createAccountProvider(descriptors, guard, baseURL) {
2893
2896
  if (lease.signal.aborted || options.signal?.aborted) throw new Error("COPILOT_MANAGED_ABORTED");
2894
2897
  try {
2895
2898
  const effective = replacement === void 0 ? payload : replacement;
2896
- 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);
2897
2901
  return guard.recoverReplay === void 0 ? normalized : guard.recoverReplay(normalized);
2898
2902
  } catch (error) {
2899
2903
  if (error instanceof CopilotResponsesReplayError) reportReplayFailure(error);
@@ -2989,7 +2993,7 @@ function createAccountProvider(descriptors, guard, baseURL) {
2989
2993
  var package_default = {
2990
2994
  name: "dsh-github-copilot",
2991
2995
  description: "DSH companion for GitHub Copilot sign-in, account-aware model profiles, tool compatibility, and provider-hosted search.",
2992
- version: "0.4.0-alpha.107",
2996
+ version: "0.4.0-alpha.109",
2993
2997
  publishConfig: {
2994
2998
  "access": "public",
2995
2999
  "registry": "https://registry.npmjs.org/",
@@ -3055,6 +3059,9 @@ var package_default = {
3055
3059
  "docs/manual-compaction-recovery.md",
3056
3060
  "docs/copilot-usage.md",
3057
3061
  "docs/copilot-accounts.md",
3062
+ "docs/session-continuation.md",
3063
+ "docs/account-management-experience.md",
3064
+ "docs/mockups/copilot-account-management.html",
3058
3065
  "docs/automatic-model-routing.md",
3059
3066
  "docs/auto-task-routing.md",
3060
3067
  "docs/image-input-compatibility.md",
@@ -3373,12 +3380,12 @@ const COPILOT_ACCOUNT_ID_PATTERN = /^(?:canonical|[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a
3373
3380
  const GITHUB_ACCOUNT_LOGIN_PATTERN = /^[a-zA-Z0-9](?:[a-zA-Z0-9_-]*[a-zA-Z0-9])?$/u;
3374
3381
  //#endregion
3375
3382
  //#region lib/types/copilot-accounts-host.js
3376
- var __runInitializers$5 = function(thisArg, initializers, value) {
3383
+ var __runInitializers$6 = function(thisArg, initializers, value) {
3377
3384
  var useValue = arguments.length > 2;
3378
3385
  for (var i = 0; i < initializers.length; i++) value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
3379
3386
  return useValue ? value : void 0;
3380
3387
  };
3381
- var __esDecorate$5 = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3388
+ var __esDecorate$6 = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3382
3389
  function accept(f) {
3383
3390
  if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected");
3384
3391
  return f;
@@ -4221,7 +4228,7 @@ let GitHubCopilotAccountsController = (() => {
4221
4228
  _reauthorize_decorators = [Remote];
4222
4229
  _switchAccount_decorators = [Remote];
4223
4230
  _removeAccount_decorators = [Remote];
4224
- __esDecorate$5(this, null, _get_decorators, {
4231
+ __esDecorate$6(this, null, _get_decorators, {
4225
4232
  kind: "method",
4226
4233
  name: "get",
4227
4234
  static: false,
@@ -4232,7 +4239,7 @@ let GitHubCopilotAccountsController = (() => {
4232
4239
  },
4233
4240
  metadata: _metadata
4234
4241
  }, null, _instanceExtraInitializers);
4235
- __esDecorate$5(this, null, _refreshIdentity_decorators, {
4242
+ __esDecorate$6(this, null, _refreshIdentity_decorators, {
4236
4243
  kind: "method",
4237
4244
  name: "refreshIdentity",
4238
4245
  static: false,
@@ -4243,7 +4250,7 @@ let GitHubCopilotAccountsController = (() => {
4243
4250
  },
4244
4251
  metadata: _metadata
4245
4252
  }, null, _instanceExtraInitializers);
4246
- __esDecorate$5(this, null, _ensureIdentity_decorators, {
4253
+ __esDecorate$6(this, null, _ensureIdentity_decorators, {
4247
4254
  kind: "method",
4248
4255
  name: "ensureIdentity",
4249
4256
  static: false,
@@ -4254,7 +4261,7 @@ let GitHubCopilotAccountsController = (() => {
4254
4261
  },
4255
4262
  metadata: _metadata
4256
4263
  }, null, _instanceExtraInitializers);
4257
- __esDecorate$5(this, null, _add_decorators, {
4264
+ __esDecorate$6(this, null, _add_decorators, {
4258
4265
  kind: "method",
4259
4266
  name: "add",
4260
4267
  static: false,
@@ -4265,7 +4272,7 @@ let GitHubCopilotAccountsController = (() => {
4265
4272
  },
4266
4273
  metadata: _metadata
4267
4274
  }, null, _instanceExtraInitializers);
4268
- __esDecorate$5(this, null, _cancel_decorators, {
4275
+ __esDecorate$6(this, null, _cancel_decorators, {
4269
4276
  kind: "method",
4270
4277
  name: "cancel",
4271
4278
  static: false,
@@ -4276,7 +4283,7 @@ let GitHubCopilotAccountsController = (() => {
4276
4283
  },
4277
4284
  metadata: _metadata
4278
4285
  }, null, _instanceExtraInitializers);
4279
- __esDecorate$5(this, null, _reauthorize_decorators, {
4286
+ __esDecorate$6(this, null, _reauthorize_decorators, {
4280
4287
  kind: "method",
4281
4288
  name: "reauthorize",
4282
4289
  static: false,
@@ -4287,7 +4294,7 @@ let GitHubCopilotAccountsController = (() => {
4287
4294
  },
4288
4295
  metadata: _metadata
4289
4296
  }, null, _instanceExtraInitializers);
4290
- __esDecorate$5(this, null, _switchAccount_decorators, {
4297
+ __esDecorate$6(this, null, _switchAccount_decorators, {
4291
4298
  kind: "method",
4292
4299
  name: "switchAccount",
4293
4300
  static: false,
@@ -4298,7 +4305,7 @@ let GitHubCopilotAccountsController = (() => {
4298
4305
  },
4299
4306
  metadata: _metadata
4300
4307
  }, null, _instanceExtraInitializers);
4301
- __esDecorate$5(this, null, _removeAccount_decorators, {
4308
+ __esDecorate$6(this, null, _removeAccount_decorators, {
4302
4309
  kind: "method",
4303
4310
  name: "removeAccount",
4304
4311
  static: false,
@@ -4316,7 +4323,7 @@ let GitHubCopilotAccountsController = (() => {
4316
4323
  value: _metadata
4317
4324
  });
4318
4325
  }
4319
- host = __runInitializers$5(this, _instanceExtraInitializers);
4326
+ host = __runInitializers$6(this, _instanceExtraInitializers);
4320
4327
  constructor(ctx) {
4321
4328
  super(ctx, "githubCopilotAccounts");
4322
4329
  this.host = new CopilotAccountsHost(ctx);
@@ -4354,12 +4361,12 @@ let GitHubCopilotAccountsController = (() => {
4354
4361
  })();
4355
4362
  //#endregion
4356
4363
  //#region lib/types/copilot-usage-host.js
4357
- var __runInitializers$4 = function(thisArg, initializers, value) {
4364
+ var __runInitializers$5 = function(thisArg, initializers, value) {
4358
4365
  var useValue = arguments.length > 2;
4359
4366
  for (var i = 0; i < initializers.length; i++) value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
4360
4367
  return useValue ? value : void 0;
4361
4368
  };
4362
- var __esDecorate$4 = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
4369
+ var __esDecorate$5 = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
4363
4370
  function accept(f) {
4364
4371
  if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected");
4365
4372
  return f;
@@ -4703,7 +4710,7 @@ let GitHubCopilotUsageController = (() => {
4703
4710
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
4704
4711
  _get_decorators = [Remote];
4705
4712
  _refresh_decorators = [Remote];
4706
- __esDecorate$4(this, null, _get_decorators, {
4713
+ __esDecorate$5(this, null, _get_decorators, {
4707
4714
  kind: "method",
4708
4715
  name: "get",
4709
4716
  static: false,
@@ -4714,7 +4721,7 @@ let GitHubCopilotUsageController = (() => {
4714
4721
  },
4715
4722
  metadata: _metadata
4716
4723
  }, null, _instanceExtraInitializers);
4717
- __esDecorate$4(this, null, _refresh_decorators, {
4724
+ __esDecorate$5(this, null, _refresh_decorators, {
4718
4725
  kind: "method",
4719
4726
  name: "refresh",
4720
4727
  static: false,
@@ -4732,7 +4739,7 @@ let GitHubCopilotUsageController = (() => {
4732
4739
  value: _metadata
4733
4740
  });
4734
4741
  }
4735
- accountSources = (__runInitializers$4(this, _instanceExtraInitializers), /* @__PURE__ */ new Map());
4742
+ accountSources = (__runInitializers$5(this, _instanceExtraInitializers), /* @__PURE__ */ new Map());
4736
4743
  source;
4737
4744
  accountSignature;
4738
4745
  sourceInitialized = false;
@@ -5007,12 +5014,12 @@ var SessionAccountsHost = class {
5007
5014
  };
5008
5015
  //#endregion
5009
5016
  //#region lib/types/session-accounts-controller.js
5010
- var __runInitializers$3 = function(thisArg, initializers, value) {
5017
+ var __runInitializers$4 = function(thisArg, initializers, value) {
5011
5018
  var useValue = arguments.length > 2;
5012
5019
  for (var i = 0; i < initializers.length; i++) value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
5013
5020
  return useValue ? value : void 0;
5014
5021
  };
5015
- var __esDecorate$3 = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
5022
+ var __esDecorate$4 = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
5016
5023
  function accept(f) {
5017
5024
  if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected");
5018
5025
  return f;
@@ -5067,7 +5074,7 @@ let SessionAccountController = (() => {
5067
5074
  _usage_decorators = [Remote];
5068
5075
  _refreshUsage_decorators = [Remote];
5069
5076
  _turn_decorators = [Remote];
5070
- __esDecorate$3(this, null, _get_decorators, {
5077
+ __esDecorate$4(this, null, _get_decorators, {
5071
5078
  kind: "method",
5072
5079
  name: "get",
5073
5080
  static: false,
@@ -5078,7 +5085,7 @@ let SessionAccountController = (() => {
5078
5085
  },
5079
5086
  metadata: _metadata
5080
5087
  }, null, _instanceExtraInitializers);
5081
- __esDecorate$3(this, null, _set_decorators, {
5088
+ __esDecorate$4(this, null, _set_decorators, {
5082
5089
  kind: "method",
5083
5090
  name: "set",
5084
5091
  static: false,
@@ -5089,7 +5096,7 @@ let SessionAccountController = (() => {
5089
5096
  },
5090
5097
  metadata: _metadata
5091
5098
  }, null, _instanceExtraInitializers);
5092
- __esDecorate$3(this, null, _refreshIdentity_decorators, {
5099
+ __esDecorate$4(this, null, _refreshIdentity_decorators, {
5093
5100
  kind: "method",
5094
5101
  name: "refreshIdentity",
5095
5102
  static: false,
@@ -5100,7 +5107,7 @@ let SessionAccountController = (() => {
5100
5107
  },
5101
5108
  metadata: _metadata
5102
5109
  }, null, _instanceExtraInitializers);
5103
- __esDecorate$3(this, null, _ensureIdentity_decorators, {
5110
+ __esDecorate$4(this, null, _ensureIdentity_decorators, {
5104
5111
  kind: "method",
5105
5112
  name: "ensureIdentity",
5106
5113
  static: false,
@@ -5111,7 +5118,7 @@ let SessionAccountController = (() => {
5111
5118
  },
5112
5119
  metadata: _metadata
5113
5120
  }, null, _instanceExtraInitializers);
5114
- __esDecorate$3(this, null, _usage_decorators, {
5121
+ __esDecorate$4(this, null, _usage_decorators, {
5115
5122
  kind: "method",
5116
5123
  name: "usage",
5117
5124
  static: false,
@@ -5122,7 +5129,7 @@ let SessionAccountController = (() => {
5122
5129
  },
5123
5130
  metadata: _metadata
5124
5131
  }, null, _instanceExtraInitializers);
5125
- __esDecorate$3(this, null, _refreshUsage_decorators, {
5132
+ __esDecorate$4(this, null, _refreshUsage_decorators, {
5126
5133
  kind: "method",
5127
5134
  name: "refreshUsage",
5128
5135
  static: false,
@@ -5133,7 +5140,7 @@ let SessionAccountController = (() => {
5133
5140
  },
5134
5141
  metadata: _metadata
5135
5142
  }, null, _instanceExtraInitializers);
5136
- __esDecorate$3(this, null, _turn_decorators, {
5143
+ __esDecorate$4(this, null, _turn_decorators, {
5137
5144
  kind: "method",
5138
5145
  name: "turn",
5139
5146
  static: false,
@@ -5151,7 +5158,7 @@ let SessionAccountController = (() => {
5151
5158
  value: _metadata
5152
5159
  });
5153
5160
  }
5154
- owner = __runInitializers$3(this, _instanceExtraInitializers);
5161
+ owner = __runInitializers$4(this, _instanceExtraInitializers);
5155
5162
  constructor(ctx, owner) {
5156
5163
  super(ctx, "githubCopilotSessionAccount");
5157
5164
  this.owner = owner;
@@ -5257,7 +5264,7 @@ const usageSchema = z$1.object({
5257
5264
  totalTokens: count$2.optional(),
5258
5265
  reasoningTokens: count$2.optional()
5259
5266
  });
5260
- function record$10(value) {
5267
+ function record$11(value) {
5261
5268
  return typeof value === "object" && value !== null && !Array.isArray(value);
5262
5269
  }
5263
5270
  function sameRoute$1(left, right) {
@@ -5276,10 +5283,10 @@ function initialContextEvidence() {
5276
5283
  }
5277
5284
  /** Read only counts and routing leaves; never message content or opaque replay. */
5278
5285
  function foldContextEvidence(state, event) {
5279
- if (!record$10(event) || typeof event.type !== "string" || !record$10(event.data)) return state;
5286
+ if (!record$11(event) || typeof event.type !== "string" || !record$11(event.data)) return state;
5280
5287
  if (event.type === "request/header" || event.type === "model/selection") {
5281
- const raw = event.type === "request/header" ? record$10(event.data.header) ? event.data.header.config : void 0 : event.data;
5282
- if (!record$10(raw)) return {
5288
+ const raw = event.type === "request/header" ? record$11(event.data.header) ? event.data.header.config : void 0 : event.data;
5289
+ if (!record$11(raw)) return {
5283
5290
  ...state,
5284
5291
  route: null,
5285
5292
  sample: null,
@@ -5318,7 +5325,7 @@ function foldContextEvidence(state, event) {
5318
5325
  if (!copilot(state.route)) return state;
5319
5326
  if (event.type === "assistant/message" && event.data.source !== void 0) {
5320
5327
  const source = event.data.source;
5321
- const parsed = routeSchema.safeParse(record$10(source) ? {
5328
+ const parsed = routeSchema.safeParse(record$11(source) ? {
5322
5329
  provider: source.provider,
5323
5330
  model: source.model
5324
5331
  } : source);
@@ -5334,7 +5341,7 @@ function foldContextEvidence(state, event) {
5334
5341
  const settledUsage = usage !== void 0;
5335
5342
  let terminal;
5336
5343
  for (const entry of stream) {
5337
- if (!record$10(entry) || entry.type !== "chunk" || !record$10(entry.chunk)) continue;
5344
+ if (!record$11(entry) || entry.type !== "chunk" || !record$11(entry.chunk)) continue;
5338
5345
  if (!settledUsage && entry.chunk.type === "usage") usage = entry.chunk.usage;
5339
5346
  if (entry.chunk.type === "finish") terminal = entry.chunk.reason;
5340
5347
  }
@@ -5348,7 +5355,7 @@ function foldContextEvidence(state, event) {
5348
5355
  };
5349
5356
  const value = parsed.data;
5350
5357
  const zero = isZeroContextUsage(value);
5351
- const successful = record$10(terminal) && (terminal.kind === "stop" || terminal.kind === "max-tokens" || terminal.kind === "tool-calls");
5358
+ const successful = record$11(terminal) && (terminal.kind === "stop" || terminal.kind === "max-tokens" || terminal.kind === "tool-calls");
5352
5359
  if (zero && !successful) {
5353
5360
  const reason = state.sample !== null || state.reason === "none" ? "failed-zero" : state.reason;
5354
5361
  return {
@@ -5390,7 +5397,7 @@ const contextEvidenceDefinition = {
5390
5397
  function installContextEvidence(ctx) {
5391
5398
  ctx.inject(["sessionProjections"], (scope) => {
5392
5399
  const registry = scope.get("sessionProjections");
5393
- if (!record$10(registry) || typeof registry.register !== "function") {
5400
+ if (!record$11(registry) || typeof registry.register !== "function") {
5394
5401
  scope.logger.warn("[github-copilot] COPILOT_CONTEXT_PROJECTION_UNAVAILABLE");
5395
5402
  return;
5396
5403
  }
@@ -5737,8 +5744,20 @@ function readInlineConfig(config) {
5737
5744
  const exclusions = readConfigValue(config.excludedModelIds);
5738
5745
  const bindings = readConfigValue(config.parentModelFollow);
5739
5746
  const accounts = readConfigValue(config.sessionAccounts);
5747
+ const continuation = readConfigValue(config.sessionContinuation);
5748
+ const defaults = readConfigValue(config.continuationDefaultHistory);
5740
5749
  return {
5741
5750
  ...config,
5751
+ continuationDefaultHistory: defaults === void 0 ? void 0 : Array.from(defaults, (row) => ({
5752
+ enabled: row.enabled,
5753
+ changedAt: row.changedAt
5754
+ })),
5755
+ sessionContinuation: continuation === void 0 ? void 0 : Array.from(continuation, (row) => ({
5756
+ sessionId: row.sessionId,
5757
+ version: row.version,
5758
+ consentedAt: row.consentedAt,
5759
+ ...row.enabled === void 0 ? {} : { enabled: row.enabled }
5760
+ })),
5742
5761
  activeAccountId: readConfigValue(config.activeAccountId),
5743
5762
  sessionAccounts: accounts === void 0 ? void 0 : Array.from(accounts, (account) => ({
5744
5763
  sessionId: account.sessionId,
@@ -5777,6 +5796,16 @@ const Config = z.object({
5777
5796
  sessionId: z.string().min(1).max(256),
5778
5797
  accountId: z.string().min(1).max(36)
5779
5798
  })).default([]).hidden().volatile(),
5799
+ sessionContinuation: z.array(z.object({
5800
+ sessionId: z.string().min(1).max(256),
5801
+ version: z.const(1),
5802
+ consentedAt: z.number().step(1).min(0).max(Number.MAX_SAFE_INTEGER),
5803
+ enabled: z.boolean()
5804
+ })).default([]).hidden().volatile(),
5805
+ continuationDefaultHistory: z.array(z.object({
5806
+ enabled: z.boolean(),
5807
+ changedAt: z.number().step(1).min(0).max(Number.MAX_SAFE_INTEGER)
5808
+ })).default([]).hidden().volatile(),
5780
5809
  followParentModel: z.boolean().default(false).volatile(),
5781
5810
  autoSemanticAssessment: z.boolean().default(true),
5782
5811
  parentModelFollow: z.array(z.object({
@@ -6423,7 +6452,7 @@ function buildAnthropicWireBody(request, cfg, model) {
6423
6452
  }
6424
6453
  //#endregion
6425
6454
  //#region lib/types/responses-reasoning-text.js
6426
- function record$9(value) {
6455
+ function record$10(value) {
6427
6456
  return typeof value === "object" && value !== null;
6428
6457
  }
6429
6458
  function responseIndex(value) {
@@ -6481,13 +6510,13 @@ var ResponsesReasoningText = class {
6481
6510
  }
6482
6511
  /** Only recognized public text fields are examined; no copying of the item. */
6483
6512
  snapshot(item) {
6484
- if (!record$9(item) || item.type !== "reasoning") return "";
6513
+ if (!record$10(item) || item.type !== "reasoning") return "";
6485
6514
  let delta = "";
6486
6515
  for (const family of ["summary", "raw"]) {
6487
6516
  const value = family === "summary" ? item.summary : item.content;
6488
6517
  if (!Array.isArray(value)) continue;
6489
6518
  for (const [index, part] of value.entries()) {
6490
- if (!record$9(part) || part.type !== (family === "summary" ? "summary_text" : "reasoning_text")) continue;
6519
+ if (!record$10(part) || part.type !== (family === "summary" ? "summary_text" : "reasoning_text")) continue;
6491
6520
  delta += this.update(family, index, part.text, true);
6492
6521
  }
6493
6522
  }
@@ -7817,12 +7846,12 @@ function excludedModelSet(value) {
7817
7846
  * Host-side bridge between the Models-page companion UI and DSH's neutral
7818
7847
  * authorization, credential-record, and settings seams.
7819
7848
  */
7820
- var __runInitializers$2 = function(thisArg, initializers, value) {
7849
+ var __runInitializers$3 = function(thisArg, initializers, value) {
7821
7850
  var useValue = arguments.length > 2;
7822
7851
  for (var i = 0; i < initializers.length; i++) value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
7823
7852
  return useValue ? value : void 0;
7824
7853
  };
7825
- var __esDecorate$2 = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
7854
+ var __esDecorate$3 = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
7826
7855
  function accept(f) {
7827
7856
  if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected");
7828
7857
  return f;
@@ -8152,7 +8181,7 @@ let GitHubCopilotAuthorizationController = (() => {
8152
8181
  _start_decorators = [Remote];
8153
8182
  _cancel_decorators = [Remote];
8154
8183
  _signOut_decorators = [Remote];
8155
- __esDecorate$2(this, null, _migrationStatus_decorators, {
8184
+ __esDecorate$3(this, null, _migrationStatus_decorators, {
8156
8185
  kind: "method",
8157
8186
  name: "migrationStatus",
8158
8187
  static: false,
@@ -8163,7 +8192,7 @@ let GitHubCopilotAuthorizationController = (() => {
8163
8192
  },
8164
8193
  metadata: _metadata
8165
8194
  }, null, _instanceExtraInitializers);
8166
- __esDecorate$2(this, null, _status_decorators, {
8195
+ __esDecorate$3(this, null, _status_decorators, {
8167
8196
  kind: "method",
8168
8197
  name: "status",
8169
8198
  static: false,
@@ -8174,7 +8203,7 @@ let GitHubCopilotAuthorizationController = (() => {
8174
8203
  },
8175
8204
  metadata: _metadata
8176
8205
  }, null, _instanceExtraInitializers);
8177
- __esDecorate$2(this, null, _excludeModel_decorators, {
8206
+ __esDecorate$3(this, null, _excludeModel_decorators, {
8178
8207
  kind: "method",
8179
8208
  name: "excludeModel",
8180
8209
  static: false,
@@ -8185,7 +8214,7 @@ let GitHubCopilotAuthorizationController = (() => {
8185
8214
  },
8186
8215
  metadata: _metadata
8187
8216
  }, null, _instanceExtraInitializers);
8188
- __esDecorate$2(this, null, _restoreModel_decorators, {
8217
+ __esDecorate$3(this, null, _restoreModel_decorators, {
8189
8218
  kind: "method",
8190
8219
  name: "restoreModel",
8191
8220
  static: false,
@@ -8196,7 +8225,7 @@ let GitHubCopilotAuthorizationController = (() => {
8196
8225
  },
8197
8226
  metadata: _metadata
8198
8227
  }, null, _instanceExtraInitializers);
8199
- __esDecorate$2(this, null, _setModelExcluded_decorators, {
8228
+ __esDecorate$3(this, null, _setModelExcluded_decorators, {
8200
8229
  kind: "method",
8201
8230
  name: "setModelExcluded",
8202
8231
  static: false,
@@ -8207,7 +8236,7 @@ let GitHubCopilotAuthorizationController = (() => {
8207
8236
  },
8208
8237
  metadata: _metadata
8209
8238
  }, null, _instanceExtraInitializers);
8210
- __esDecorate$2(this, null, _discoverModels_decorators, {
8239
+ __esDecorate$3(this, null, _discoverModels_decorators, {
8211
8240
  kind: "method",
8212
8241
  name: "discoverModels",
8213
8242
  static: false,
@@ -8218,7 +8247,7 @@ let GitHubCopilotAuthorizationController = (() => {
8218
8247
  },
8219
8248
  metadata: _metadata
8220
8249
  }, null, _instanceExtraInitializers);
8221
- __esDecorate$2(this, null, _ensureModels_decorators, {
8250
+ __esDecorate$3(this, null, _ensureModels_decorators, {
8222
8251
  kind: "method",
8223
8252
  name: "ensureModels",
8224
8253
  static: false,
@@ -8229,7 +8258,7 @@ let GitHubCopilotAuthorizationController = (() => {
8229
8258
  },
8230
8259
  metadata: _metadata
8231
8260
  }, null, _instanceExtraInitializers);
8232
- __esDecorate$2(this, null, _reconcile_decorators, {
8261
+ __esDecorate$3(this, null, _reconcile_decorators, {
8233
8262
  kind: "method",
8234
8263
  name: "reconcile",
8235
8264
  static: false,
@@ -8240,7 +8269,7 @@ let GitHubCopilotAuthorizationController = (() => {
8240
8269
  },
8241
8270
  metadata: _metadata
8242
8271
  }, null, _instanceExtraInitializers);
8243
- __esDecorate$2(this, null, _start_decorators, {
8272
+ __esDecorate$3(this, null, _start_decorators, {
8244
8273
  kind: "method",
8245
8274
  name: "start",
8246
8275
  static: false,
@@ -8251,7 +8280,7 @@ let GitHubCopilotAuthorizationController = (() => {
8251
8280
  },
8252
8281
  metadata: _metadata
8253
8282
  }, null, _instanceExtraInitializers);
8254
- __esDecorate$2(this, null, _cancel_decorators, {
8283
+ __esDecorate$3(this, null, _cancel_decorators, {
8255
8284
  kind: "method",
8256
8285
  name: "cancel",
8257
8286
  static: false,
@@ -8262,7 +8291,7 @@ let GitHubCopilotAuthorizationController = (() => {
8262
8291
  },
8263
8292
  metadata: _metadata
8264
8293
  }, null, _instanceExtraInitializers);
8265
- __esDecorate$2(this, null, _signOut_decorators, {
8294
+ __esDecorate$3(this, null, _signOut_decorators, {
8266
8295
  kind: "method",
8267
8296
  name: "signOut",
8268
8297
  static: false,
@@ -8280,7 +8309,7 @@ let GitHubCopilotAuthorizationController = (() => {
8280
8309
  value: _metadata
8281
8310
  });
8282
8311
  }
8283
- notices = (__runInitializers$2(this, _instanceExtraInitializers), []);
8312
+ notices = (__runInitializers$3(this, _instanceExtraInitializers), []);
8284
8313
  failure;
8285
8314
  reconciliationFailed = false;
8286
8315
  attempt;
@@ -8735,13 +8764,13 @@ function resolveCopilotResponsesReasoning(ctx, request, candidate) {
8735
8764
  }
8736
8765
  //#endregion
8737
8766
  //#region lib/types/replay-recovery.js
8738
- function record$8(value) {
8767
+ function record$9(value) {
8739
8768
  return value !== null && typeof value === "object" && !Array.isArray(value);
8740
8769
  }
8741
8770
  function parsed(body) {
8742
8771
  if (requestBodyEvidence(body, "openai-responses").state !== "complete" || body === void 0) throw new Error("COPILOT_REPLAY_RECOVERY_EVIDENCE_UNAVAILABLE");
8743
8772
  const payload = JSON.parse(body);
8744
- if (!record$8(payload) || !Array.isArray(payload.input) || !payload.input.every(record$8)) throw new Error("COPILOT_REPLAY_RECOVERY_INVALID_PAYLOAD");
8773
+ if (!record$9(payload) || !Array.isArray(payload.input) || !payload.input.every(record$9)) throw new Error("COPILOT_REPLAY_RECOVERY_INVALID_PAYLOAD");
8745
8774
  return {
8746
8775
  input: payload.input,
8747
8776
  payload
@@ -8837,7 +8866,7 @@ var ReplayRecoveryStore = class {
8837
8866
  const value = hash(item);
8838
8867
  return value === void 0 || !admitted.has(value);
8839
8868
  }).length === decoded.input.length) return payload;
8840
- if (!record$8(payload) || !Array.isArray(payload.input)) throw new Error("COPILOT_REPLAY_RECOVERY_INVALID_PAYLOAD");
8869
+ if (!record$9(payload) || !Array.isArray(payload.input)) throw new Error("COPILOT_REPLAY_RECOVERY_INVALID_PAYLOAD");
8841
8870
  const input = payload.input.filter((_, index) => {
8842
8871
  const item = decoded.input[index];
8843
8872
  const value = hash(item);
@@ -8858,12 +8887,12 @@ var ReplayRecoveryStore = class {
8858
8887
  };
8859
8888
  //#endregion
8860
8889
  //#region lib/types/replay-recovery-host.js
8861
- var __runInitializers$1 = function(thisArg, initializers, value) {
8890
+ var __runInitializers$2 = function(thisArg, initializers, value) {
8862
8891
  var useValue = arguments.length > 2;
8863
8892
  for (var i = 0; i < initializers.length; i++) value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
8864
8893
  return useValue ? value : void 0;
8865
8894
  };
8866
- var __esDecorate$1 = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
8895
+ var __esDecorate$2 = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
8867
8896
  function accept(f) {
8868
8897
  if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected");
8869
8898
  return f;
@@ -8910,7 +8939,7 @@ let ReplayRecoveryController = (() => {
8910
8939
  _get_decorators = [Remote];
8911
8940
  _setEnabled_decorators = [Remote];
8912
8941
  _authorize_decorators = [Remote];
8913
- __esDecorate$1(this, null, _get_decorators, {
8942
+ __esDecorate$2(this, null, _get_decorators, {
8914
8943
  kind: "method",
8915
8944
  name: "get",
8916
8945
  static: false,
@@ -8921,7 +8950,7 @@ let ReplayRecoveryController = (() => {
8921
8950
  },
8922
8951
  metadata: _metadata
8923
8952
  }, null, _instanceExtraInitializers);
8924
- __esDecorate$1(this, null, _setEnabled_decorators, {
8953
+ __esDecorate$2(this, null, _setEnabled_decorators, {
8925
8954
  kind: "method",
8926
8955
  name: "setEnabled",
8927
8956
  static: false,
@@ -8932,7 +8961,7 @@ let ReplayRecoveryController = (() => {
8932
8961
  },
8933
8962
  metadata: _metadata
8934
8963
  }, null, _instanceExtraInitializers);
8935
- __esDecorate$1(this, null, _authorize_decorators, {
8964
+ __esDecorate$2(this, null, _authorize_decorators, {
8936
8965
  kind: "method",
8937
8966
  name: "authorize",
8938
8967
  static: false,
@@ -8950,7 +8979,7 @@ let ReplayRecoveryController = (() => {
8950
8979
  value: _metadata
8951
8980
  });
8952
8981
  }
8953
- store = __runInitializers$1(this, _instanceExtraInitializers);
8982
+ store = __runInitializers$2(this, _instanceExtraInitializers);
8954
8983
  proof;
8955
8984
  busy;
8956
8985
  constructor(ctx, store, proof, busy) {
@@ -9036,6 +9065,419 @@ function installReplayRecovery(ctx, proof) {
9036
9065
  };
9037
9066
  }
9038
9067
  //#endregion
9068
+ //#region lib/types/session-continuation.js
9069
+ const SESSION_CONTINUATION_LIMITS = Object.freeze({
9070
+ items: 4096,
9071
+ values: 65536,
9072
+ depth: 64,
9073
+ bytes: 16777216
9074
+ });
9075
+ function record$8(value) {
9076
+ return typeof value === "object" && value !== null && !Array.isArray(value);
9077
+ }
9078
+ function fingerprint(item) {
9079
+ if (!record$8(item)) throw new Error("COPILOT_CONTINUATION_INVALID_PAYLOAD");
9080
+ if (item.type !== "reasoning") return void 0;
9081
+ if (typeof item.encrypted_content !== "string" || !item.encrypted_content || item.status !== void 0 && item.status !== "completed") throw new Error("COPILOT_CONTINUATION_UNSUPPORTED_REASONING");
9082
+ return createHash("sha256").update(item.encrypted_content).digest("hex");
9083
+ }
9084
+ /** One admitted turn; fingerprints never become durable history or account provenance. */
9085
+ var SessionContinuationTurn = class {
9086
+ baseline;
9087
+ get initialized() {
9088
+ return this.baseline !== void 0;
9089
+ }
9090
+ transform(payload) {
9091
+ if (!record$8(payload) || !Array.isArray(payload.input) || payload.input.length > SESSION_CONTINUATION_LIMITS.values) throw new Error("COPILOT_CONTINUATION_INVALID_PAYLOAD");
9092
+ const pending = [{
9093
+ value: payload,
9094
+ depth: 0
9095
+ }];
9096
+ let values = 0, stringBytes = 0;
9097
+ while (pending.length) {
9098
+ const { value, depth } = pending.pop();
9099
+ if (++values > SESSION_CONTINUATION_LIMITS.values || depth > SESSION_CONTINUATION_LIMITS.depth) throw new Error("COPILOT_CONTINUATION_WORK_LIMIT");
9100
+ if (typeof value === "string") stringBytes += Buffer.byteLength(value);
9101
+ else if (Array.isArray(value)) {
9102
+ if (pending.length + value.length > SESSION_CONTINUATION_LIMITS.values) throw new Error("COPILOT_CONTINUATION_WORK_LIMIT");
9103
+ for (const child of value) pending.push({
9104
+ value: child,
9105
+ depth: depth + 1
9106
+ });
9107
+ } else if (record$8(value)) {
9108
+ const entries = Object.entries(value);
9109
+ if (pending.length + entries.length > SESSION_CONTINUATION_LIMITS.values) throw new Error("COPILOT_CONTINUATION_WORK_LIMIT");
9110
+ for (const [key, child] of entries) {
9111
+ stringBytes += Buffer.byteLength(key);
9112
+ pending.push({
9113
+ value: child,
9114
+ depth: depth + 1
9115
+ });
9116
+ }
9117
+ }
9118
+ if (stringBytes > SESSION_CONTINUATION_LIMITS.bytes) throw new Error("COPILOT_CONTINUATION_PAYLOAD_LIMIT");
9119
+ }
9120
+ let bytes;
9121
+ try {
9122
+ bytes = JSON.stringify(payload);
9123
+ } catch {
9124
+ throw new Error("COPILOT_CONTINUATION_INVALID_PAYLOAD");
9125
+ }
9126
+ if (Buffer.byteLength(bytes) > SESSION_CONTINUATION_LIMITS.bytes) throw new Error("COPILOT_CONTINUATION_PAYLOAD_LIMIT");
9127
+ const hashes = payload.input.map(fingerprint);
9128
+ const present = new Set(hashes.filter((value) => value !== void 0));
9129
+ if (present.size > SESSION_CONTINUATION_LIMITS.items) throw new Error("COPILOT_CONTINUATION_ITEM_LIMIT");
9130
+ this.baseline ??= present;
9131
+ const input = payload.input.filter((_, index) => hashes[index] === void 0 || !this.baseline.has(hashes[index]));
9132
+ return input.length === payload.input.length ? payload : {
9133
+ ...payload,
9134
+ input
9135
+ };
9136
+ }
9137
+ };
9138
+ //#endregion
9139
+ //#region lib/types/session-continuation-types.js
9140
+ const SessionContinuationPreferenceSchema = z$1.object({
9141
+ sessionId: z$1.string().min(1).max(256).refine((value) => !/[\p{Cc}\p{Cf}]/u.test(value)),
9142
+ version: z$1.literal(1),
9143
+ consentedAt: z$1.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
9144
+ enabled: z$1.boolean().optional()
9145
+ }).strict();
9146
+ const SessionContinuationPreferencesSchema = z$1.array(SessionContinuationPreferenceSchema).max(2048).refine((rows) => new Set(rows.map((row) => row.sessionId)).size === rows.length);
9147
+ const ContinuationDefaultHistorySchema = z$1.array(z$1.object({
9148
+ enabled: z$1.boolean(),
9149
+ changedAt: z$1.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER)
9150
+ }).strict()).max(2048).refine((rows) => rows.every((row, index) => index === 0 || row.changedAt > rows[index - 1].changedAt));
9151
+ z$1.object({
9152
+ enabled: z$1.boolean(),
9153
+ revision: z$1.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER)
9154
+ }).strict();
9155
+ z$1.object({
9156
+ enabled: z$1.boolean(),
9157
+ revision: z$1.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
9158
+ activeTurnEnabled: z$1.boolean().optional(),
9159
+ source: z$1.enum(["default", "session"]).optional(),
9160
+ nextTurnAuthorized: z$1.boolean().optional()
9161
+ }).strict();
9162
+ //#endregion
9163
+ //#region lib/types/session-continuation-host.js
9164
+ var __runInitializers$1 = function(thisArg, initializers, value) {
9165
+ var useValue = arguments.length > 2;
9166
+ for (var i = 0; i < initializers.length; i++) value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
9167
+ return useValue ? value : void 0;
9168
+ };
9169
+ var __esDecorate$1 = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
9170
+ function accept(f) {
9171
+ if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected");
9172
+ return f;
9173
+ }
9174
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
9175
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
9176
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
9177
+ var _, done = false;
9178
+ for (var i = decorators.length - 1; i >= 0; i--) {
9179
+ var context = {};
9180
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
9181
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
9182
+ context.addInitializer = function(f) {
9183
+ if (done) throw new TypeError("Cannot add initializers after decoration has completed");
9184
+ extraInitializers.push(accept(f || null));
9185
+ };
9186
+ var result = (0, decorators[i])(kind === "accessor" ? {
9187
+ get: descriptor.get,
9188
+ set: descriptor.set
9189
+ } : descriptor[key], context);
9190
+ if (kind === "accessor") {
9191
+ if (result === void 0) continue;
9192
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
9193
+ if (_ = accept(result.get)) descriptor.get = _;
9194
+ if (_ = accept(result.set)) descriptor.set = _;
9195
+ if (_ = accept(result.init)) initializers.unshift(_);
9196
+ } else if (_ = accept(result)) {
9197
+ if (kind === "field") initializers.unshift(_);
9198
+ else descriptor[key] = _;
9199
+ }
9200
+ }
9201
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
9202
+ done = true;
9203
+ };
9204
+ function preferences(value) {
9205
+ if (typeof value !== "object" || value === null) throw new Error("COPILOT_CONTINUATION_SETTINGS_UNAVAILABLE");
9206
+ const raw = "sessionContinuation" in value ? value.sessionContinuation : [];
9207
+ const parsed = SessionContinuationPreferencesSchema.safeParse(raw);
9208
+ if (!parsed.success) throw new Error("COPILOT_CONTINUATION_SETTINGS_INVALID");
9209
+ return parsed.data;
9210
+ }
9211
+ let SessionContinuationController = (() => {
9212
+ let _classSuper = TypertRemoteService;
9213
+ let _instanceExtraInitializers = [];
9214
+ let _get_decorators;
9215
+ let _set_decorators;
9216
+ let _authorizeNext_decorators;
9217
+ let _defaults_decorators;
9218
+ let _setDefault_decorators;
9219
+ return class SessionContinuationController extends _classSuper {
9220
+ static {
9221
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
9222
+ _get_decorators = [Remote];
9223
+ _set_decorators = [Remote];
9224
+ _authorizeNext_decorators = [Remote];
9225
+ _defaults_decorators = [Remote];
9226
+ _setDefault_decorators = [Remote];
9227
+ __esDecorate$1(this, null, _get_decorators, {
9228
+ kind: "method",
9229
+ name: "get",
9230
+ static: false,
9231
+ private: false,
9232
+ access: {
9233
+ has: (obj) => "get" in obj,
9234
+ get: (obj) => obj.get
9235
+ },
9236
+ metadata: _metadata
9237
+ }, null, _instanceExtraInitializers);
9238
+ __esDecorate$1(this, null, _set_decorators, {
9239
+ kind: "method",
9240
+ name: "set",
9241
+ static: false,
9242
+ private: false,
9243
+ access: {
9244
+ has: (obj) => "set" in obj,
9245
+ get: (obj) => obj.set
9246
+ },
9247
+ metadata: _metadata
9248
+ }, null, _instanceExtraInitializers);
9249
+ __esDecorate$1(this, null, _authorizeNext_decorators, {
9250
+ kind: "method",
9251
+ name: "authorizeNext",
9252
+ static: false,
9253
+ private: false,
9254
+ access: {
9255
+ has: (obj) => "authorizeNext" in obj,
9256
+ get: (obj) => obj.authorizeNext
9257
+ },
9258
+ metadata: _metadata
9259
+ }, null, _instanceExtraInitializers);
9260
+ __esDecorate$1(this, null, _defaults_decorators, {
9261
+ kind: "method",
9262
+ name: "defaults",
9263
+ static: false,
9264
+ private: false,
9265
+ access: {
9266
+ has: (obj) => "defaults" in obj,
9267
+ get: (obj) => obj.defaults
9268
+ },
9269
+ metadata: _metadata
9270
+ }, null, _instanceExtraInitializers);
9271
+ __esDecorate$1(this, null, _setDefault_decorators, {
9272
+ kind: "method",
9273
+ name: "setDefault",
9274
+ static: false,
9275
+ private: false,
9276
+ access: {
9277
+ has: (obj) => "setDefault" in obj,
9278
+ get: (obj) => obj.setDefault
9279
+ },
9280
+ metadata: _metadata
9281
+ }, null, _instanceExtraInitializers);
9282
+ if (_metadata) Object.defineProperty(this, Symbol.metadata, {
9283
+ enumerable: true,
9284
+ configurable: true,
9285
+ writable: true,
9286
+ value: _metadata
9287
+ });
9288
+ }
9289
+ active = __runInitializers$1(this, _instanceExtraInitializers);
9290
+ once;
9291
+ ready;
9292
+ constructor(ctx, active, once = /* @__PURE__ */ new Set(), ready = Promise.resolve()) {
9293
+ super(ctx, "githubCopilotSessionContinuation");
9294
+ this.active = active;
9295
+ this.once = once;
9296
+ this.ready = ready;
9297
+ }
9298
+ async get(agent) {
9299
+ await this.ready;
9300
+ const entry = this.ctx.get("settings")?.describe({ redactSecrets: true }).find((row) => row.ns === "github-copilot");
9301
+ if (!entry) throw new Error("COPILOT_CONTINUATION_SETTINGS_UNAVAILABLE");
9302
+ const admission = this.active.get(agent.session);
9303
+ const explicit = preferences(entry.value).find((row) => row.sessionId === agent.session.id);
9304
+ return {
9305
+ enabled: resolveEnabled(agent, entry.value),
9306
+ source: explicit ? "session" : "default",
9307
+ nextTurnAuthorized: this.once.has(agent.session),
9308
+ revision: entry.revision,
9309
+ ...admission ? { activeTurnEnabled: admission.enabled } : {}
9310
+ };
9311
+ }
9312
+ async set(agent, revision, enabled) {
9313
+ await this.ready;
9314
+ const settings = this.ctx.get("settings");
9315
+ const entry = settings?.describe({ redactSecrets: true }).find((row) => row.ns === "github-copilot");
9316
+ if (!settings || !entry) throw new Error("COPILOT_CONTINUATION_SETTINGS_UNAVAILABLE");
9317
+ if (entry.revision !== revision) throw new Error("COPILOT_CONTINUATION_CONFLICT");
9318
+ const next = preferences(entry.value).filter((row) => row.sessionId !== agent.session.id);
9319
+ if (enabled !== null) next.push({
9320
+ sessionId: agent.session.id,
9321
+ version: 1,
9322
+ consentedAt: Date.now(),
9323
+ enabled
9324
+ });
9325
+ if (!SessionContinuationPreferencesSchema.safeParse(next).success) throw new Error("COPILOT_CONTINUATION_SETTINGS_LIMIT");
9326
+ await settings.mutate("github-copilot", [{
9327
+ op: "set",
9328
+ path: ["sessionContinuation"],
9329
+ value: next
9330
+ }], revision);
9331
+ const actual = await this.get(agent);
9332
+ if (enabled !== null && actual.enabled !== enabled || enabled === null && actual.source !== "default") throw new Error("COPILOT_CONTINUATION_COMMIT_UNCERTAIN");
9333
+ this.once.delete(agent.session);
9334
+ return {
9335
+ ...actual,
9336
+ nextTurnAuthorized: false
9337
+ };
9338
+ }
9339
+ async authorizeNext(agent, revision, enabled) {
9340
+ if ((await this.get(agent)).revision !== revision) throw new Error("COPILOT_CONTINUATION_CONFLICT");
9341
+ if (enabled && !this.once.has(agent.session) && this.once.size >= 2048) throw new Error("COPILOT_CONTINUATION_CONSENT_LIMIT");
9342
+ if (enabled) this.once.add(agent.session);
9343
+ else this.once.delete(agent.session);
9344
+ return this.get(agent);
9345
+ }
9346
+ async defaults() {
9347
+ await this.ready;
9348
+ const entry = this.ctx.get("settings")?.describe({ redactSecrets: true }).find((row) => row.ns === "github-copilot");
9349
+ if (!entry) throw new Error("COPILOT_CONTINUATION_SETTINGS_UNAVAILABLE");
9350
+ return {
9351
+ enabled: defaultHistory(entry.value).at(-1)?.enabled ?? false,
9352
+ revision: entry.revision
9353
+ };
9354
+ }
9355
+ async setDefault(revision, enabled) {
9356
+ await this.ready;
9357
+ const settings = this.ctx.get("settings");
9358
+ const entry = settings?.describe({ redactSecrets: true }).find((row) => row.ns === "github-copilot");
9359
+ if (!settings || !entry) throw new Error("COPILOT_CONTINUATION_SETTINGS_UNAVAILABLE");
9360
+ if (entry.revision !== revision) throw new Error("COPILOT_CONTINUATION_CONFLICT");
9361
+ const history = defaultHistory(entry.value);
9362
+ if ((history.at(-1)?.enabled ?? false) === enabled) return this.defaults();
9363
+ const changedAt = Math.max(Date.now(), (history.at(-1)?.changedAt ?? -1) + 1);
9364
+ const next = [...history, {
9365
+ enabled,
9366
+ changedAt
9367
+ }];
9368
+ if (!ContinuationDefaultHistorySchema.safeParse(next).success) throw new Error("COPILOT_CONTINUATION_SETTINGS_LIMIT");
9369
+ await settings.mutate("github-copilot", [{
9370
+ op: "set",
9371
+ path: ["continuationDefaultHistory"],
9372
+ value: next
9373
+ }], revision);
9374
+ const actual = await this.defaults();
9375
+ if (actual.enabled !== enabled) throw new Error("COPILOT_CONTINUATION_COMMIT_UNCERTAIN");
9376
+ return actual;
9377
+ }
9378
+ };
9379
+ })();
9380
+ function defaultHistory(value) {
9381
+ if (typeof value !== "object" || value === null) throw new Error("COPILOT_CONTINUATION_SETTINGS_UNAVAILABLE");
9382
+ const parsed = ContinuationDefaultHistorySchema.safeParse("continuationDefaultHistory" in value ? value.continuationDefaultHistory : []);
9383
+ if (!parsed.success) throw new Error("COPILOT_CONTINUATION_SETTINGS_INVALID");
9384
+ return parsed.data;
9385
+ }
9386
+ function resolveEnabled(agent, value) {
9387
+ const explicit = preferences(value).find((row) => row.sessionId === agent.session.id);
9388
+ if (explicit) return explicit.enabled ?? true;
9389
+ const history = defaultHistory(value);
9390
+ const header = agent.session.header;
9391
+ if (!header || header.isSeeded !== false || !Number.isSafeInteger(header.createdAt)) return false;
9392
+ return history.findLast((row) => row.changedAt < header.createdAt)?.enabled ?? false;
9393
+ }
9394
+ function installSessionContinuation(ctx) {
9395
+ if (!ctx.get("settings")) {
9396
+ ctx.logger.warn("COPILOT_CONTINUATION_SETTINGS_UNAVAILABLE: continuation integration is not active");
9397
+ return {
9398
+ ready: Promise.resolve(),
9399
+ prepare: () => void 0,
9400
+ dispose() {}
9401
+ };
9402
+ }
9403
+ const active = /* @__PURE__ */ new Map();
9404
+ const once = /* @__PURE__ */ new Set();
9405
+ const requests = /* @__PURE__ */ new WeakMap();
9406
+ const ready = (async () => {
9407
+ const settings = ctx.get("settings");
9408
+ const entry = settings?.describe({ redactSecrets: true }).find((row) => row.ns === "github-copilot");
9409
+ if (!settings || !entry) throw new Error("COPILOT_CONTINUATION_SETTINGS_UNAVAILABLE");
9410
+ if (defaultHistory(entry.value).length) return;
9411
+ await settings.mutate("github-copilot", [{
9412
+ op: "set",
9413
+ path: ["continuationDefaultHistory"],
9414
+ value: [{
9415
+ enabled: true,
9416
+ changedAt: Date.now()
9417
+ }]
9418
+ }], entry.revision);
9419
+ if (!defaultHistory(readSettingsNamespace(ctx, "github-copilot")).length) throw new Error("COPILOT_CONTINUATION_COMMIT_UNCERTAIN");
9420
+ })();
9421
+ ready.catch(() => ctx.logger.warn("COPILOT_CONTINUATION_INITIALIZATION_FAILED"));
9422
+ new SessionContinuationController(ctx, active, once, ready);
9423
+ const removeRequest = ctx.on("agent/request", async ({ agent, turn, step, signal }, next) => {
9424
+ const result = await next();
9425
+ if (signal.aborted || result.provider !== "github-copilot-preview") return result;
9426
+ await ready;
9427
+ if (signal.aborted) return result;
9428
+ if (!Number.isSafeInteger(turn) || turn < 0) throw new Error("COPILOT_CONTINUATION_TURN_INVALID");
9429
+ let admission = active.get(agent.session);
9430
+ if (admission && admission.turn !== turn) throw new Error("COPILOT_CONTINUATION_TURN_UNSETTLED");
9431
+ if (!admission) {
9432
+ admission = {
9433
+ turn,
9434
+ step,
9435
+ enabled: resolveEnabled(agent, readSettingsNamespace(ctx, "github-copilot")) || once.has(agent.session),
9436
+ filter: new SessionContinuationTurn(),
9437
+ signal
9438
+ };
9439
+ active.set(agent.session, admission);
9440
+ once.delete(agent.session);
9441
+ }
9442
+ admission.signal = signal;
9443
+ admission.step = step;
9444
+ requests.set(signal, agent.session);
9445
+ return result;
9446
+ });
9447
+ const removeEvents = ctx.on("session/event", (session, event) => {
9448
+ if (event.type === "turn/end" && active.get(session)?.turn === event.data.turn) active.delete(session);
9449
+ });
9450
+ const removeAgent = ctx.on("agent/disposed", ({ agent }) => {
9451
+ active.delete(agent.session);
9452
+ once.delete(agent.session);
9453
+ });
9454
+ let disposed = false;
9455
+ return {
9456
+ ready,
9457
+ prepare(request) {
9458
+ if (request.provider !== "github-copilot-preview" || request.purpose !== void 0 || !request.signal) return void 0;
9459
+ const session = requests.get(request.signal);
9460
+ const admission = session && active.get(session);
9461
+ if (!session || session.id !== request.sessionId || !admission?.enabled) return void 0;
9462
+ if (!admission.filter.initialized && admission.step !== 1) throw new Error("COPILOT_CONTINUATION_TURN_BOUNDARY_UNAVAILABLE");
9463
+ const current = () => !disposed && !request.signal.aborted && active.get(session) === admission && admission.signal === request.signal;
9464
+ if (!current()) throw new Error("COPILOT_CONTINUATION_REVOKED");
9465
+ return (payload) => {
9466
+ if (!current()) throw new Error("COPILOT_CONTINUATION_REVOKED");
9467
+ return admission.filter.transform(payload);
9468
+ };
9469
+ },
9470
+ dispose() {
9471
+ disposed = true;
9472
+ removeRequest();
9473
+ removeEvents();
9474
+ removeAgent();
9475
+ active.clear();
9476
+ once.clear();
9477
+ }
9478
+ };
9479
+ }
9480
+ //#endregion
9039
9481
  //#region lib/types/agent-compaction.js
9040
9482
  function record$7(value) {
9041
9483
  return typeof value === "object" && value !== null;
@@ -11581,6 +12023,10 @@ function createAccountRuntime(ctx, config, binding, exclusionTurns, replayRecove
11581
12023
  const guard = {
11582
12024
  ...lifetime.guard(lease),
11583
12025
  ...hooks,
12026
+ onReplayFailure(error) {
12027
+ if (error.dispatchEvidence !== void 0) ctx.logger.warn(`[github-copilot] ${error.dispatchEvidence}`);
12028
+ hooks.onReplayFailure?.(error);
12029
+ },
11584
12030
  ...enabled ? { streamIdleTimeoutMs: idle } : {},
11585
12031
  onUnauthorized() {
11586
12032
  if (lease === void 0 || !lifetime.isCurrent(lease.revision) || source.readDisplaySnapshot() !== lease.snapshot || provenSnapshot !== lease.snapshot || snapshotProof !== lease.proof) return;
@@ -11789,11 +12235,27 @@ function apply$1(ctx, config = {}) {
11789
12235
  };
11790
12236
  const currentRuntime = (signal) => runtimeFor(requestBinding(signal));
11791
12237
  const directoryRuntime = () => runtimeFor(globalBinding());
11792
- const replayRecovery = installReplayRecovery(ctx, (agent, request) => {
12238
+ const temporaryRecovery = installReplayRecovery(ctx, (agent, request) => {
11793
12239
  const accounts = ctx.get("githubCopilotSessionAccounts");
11794
12240
  const binding = agent !== void 0 && accounts !== void 0 ? accounts.bindingForAccount((accounts.turns.current(agent.session) ?? accounts.selected(agent)).accountId) : requestBinding(request?.signal);
11795
12241
  return runtimeFor(binding).proof();
11796
12242
  });
12243
+ const continuation = installSessionContinuation(ctx);
12244
+ const replayRecovery = {
12245
+ prepare(request) {
12246
+ const portable = continuation.prepare(request);
12247
+ const temporary = temporaryRecovery.prepare(request);
12248
+ if (!portable) return temporary;
12249
+ return {
12250
+ transform: portable,
12251
+ rejected: (body) => temporary?.rejected(body)
12252
+ };
12253
+ },
12254
+ dispose() {
12255
+ temporaryRecovery.dispose();
12256
+ continuation.dispose();
12257
+ }
12258
+ };
11797
12259
  const initial = directoryRuntime();
11798
12260
  const registration = ctx.llm.registerAdapter([GITHUB_COPILOT_PREVIEW_PROVIDER_ID], new AccountRoutingAdapter(initial.optionsFor(), currentRuntime));
11799
12261
  publish = () => {