dsh-github-copilot 0.4.0-alpha.108 → 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/AGENTS.md +3 -1
- package/CHANGELOG.md +7 -0
- package/README.md +11 -7
- package/README.zh.md +11 -7
- package/deployment-baseline.json +24 -2
- package/docs/account-management-experience.md +93 -0
- package/docs/copilot-accounts.md +11 -4
- package/docs/mockups/copilot-account-management.html +393 -0
- package/docs/session-continuation.md +87 -0
- package/lib/client.js +980 -133
- package/lib/client.js.map +1 -1
- package/lib/index.js +541 -85
- package/lib/remote.js +68 -7
- package/lib/types/client.d.ts +3 -0
- package/lib/types/composer-notice-style.d.ts +2 -0
- package/lib/types/config.d.ts +19 -2
- package/lib/types/copilot-accounts-card.d.ts +13 -2
- package/lib/types/copilot-usage-card.d.ts +6 -0
- package/lib/types/replay-recovery-ui.d.ts +3 -1
- package/lib/types/responses-replay-compat.d.ts +1 -1
- package/lib/types/session-continuation-host.d.ts +42 -0
- package/lib/types/session-continuation-remote.d.ts +22 -0
- package/lib/types/session-continuation-types.d.ts +35 -0
- package/lib/types/session-continuation-ui.d.ts +47 -0
- package/lib/types/session-continuation.d.ts +13 -0
- package/package.json +4 -1
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
1408
|
-
const supports = record$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
2558
|
+
if (signal?.aborted || !record$12(value)) return void 0;
|
|
2558
2559
|
const error = Object.hasOwn(value, "error") ? value.error : value;
|
|
2559
|
-
if (!record$
|
|
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
|
-
|
|
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.
|
|
2996
|
+
version: "0.4.0-alpha.109",
|
|
2995
2997
|
publishConfig: {
|
|
2996
2998
|
"access": "public",
|
|
2997
2999
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -3057,6 +3059,9 @@ 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",
|
|
3060
3065
|
"docs/automatic-model-routing.md",
|
|
3061
3066
|
"docs/auto-task-routing.md",
|
|
3062
3067
|
"docs/image-input-compatibility.md",
|
|
@@ -3375,12 +3380,12 @@ const COPILOT_ACCOUNT_ID_PATTERN = /^(?:canonical|[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a
|
|
|
3375
3380
|
const GITHUB_ACCOUNT_LOGIN_PATTERN = /^[a-zA-Z0-9](?:[a-zA-Z0-9_-]*[a-zA-Z0-9])?$/u;
|
|
3376
3381
|
//#endregion
|
|
3377
3382
|
//#region lib/types/copilot-accounts-host.js
|
|
3378
|
-
var __runInitializers$
|
|
3383
|
+
var __runInitializers$6 = function(thisArg, initializers, value) {
|
|
3379
3384
|
var useValue = arguments.length > 2;
|
|
3380
3385
|
for (var i = 0; i < initializers.length; i++) value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
3381
3386
|
return useValue ? value : void 0;
|
|
3382
3387
|
};
|
|
3383
|
-
var __esDecorate$
|
|
3388
|
+
var __esDecorate$6 = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
3384
3389
|
function accept(f) {
|
|
3385
3390
|
if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected");
|
|
3386
3391
|
return f;
|
|
@@ -4223,7 +4228,7 @@ let GitHubCopilotAccountsController = (() => {
|
|
|
4223
4228
|
_reauthorize_decorators = [Remote];
|
|
4224
4229
|
_switchAccount_decorators = [Remote];
|
|
4225
4230
|
_removeAccount_decorators = [Remote];
|
|
4226
|
-
__esDecorate$
|
|
4231
|
+
__esDecorate$6(this, null, _get_decorators, {
|
|
4227
4232
|
kind: "method",
|
|
4228
4233
|
name: "get",
|
|
4229
4234
|
static: false,
|
|
@@ -4234,7 +4239,7 @@ let GitHubCopilotAccountsController = (() => {
|
|
|
4234
4239
|
},
|
|
4235
4240
|
metadata: _metadata
|
|
4236
4241
|
}, null, _instanceExtraInitializers);
|
|
4237
|
-
__esDecorate$
|
|
4242
|
+
__esDecorate$6(this, null, _refreshIdentity_decorators, {
|
|
4238
4243
|
kind: "method",
|
|
4239
4244
|
name: "refreshIdentity",
|
|
4240
4245
|
static: false,
|
|
@@ -4245,7 +4250,7 @@ let GitHubCopilotAccountsController = (() => {
|
|
|
4245
4250
|
},
|
|
4246
4251
|
metadata: _metadata
|
|
4247
4252
|
}, null, _instanceExtraInitializers);
|
|
4248
|
-
__esDecorate$
|
|
4253
|
+
__esDecorate$6(this, null, _ensureIdentity_decorators, {
|
|
4249
4254
|
kind: "method",
|
|
4250
4255
|
name: "ensureIdentity",
|
|
4251
4256
|
static: false,
|
|
@@ -4256,7 +4261,7 @@ let GitHubCopilotAccountsController = (() => {
|
|
|
4256
4261
|
},
|
|
4257
4262
|
metadata: _metadata
|
|
4258
4263
|
}, null, _instanceExtraInitializers);
|
|
4259
|
-
__esDecorate$
|
|
4264
|
+
__esDecorate$6(this, null, _add_decorators, {
|
|
4260
4265
|
kind: "method",
|
|
4261
4266
|
name: "add",
|
|
4262
4267
|
static: false,
|
|
@@ -4267,7 +4272,7 @@ let GitHubCopilotAccountsController = (() => {
|
|
|
4267
4272
|
},
|
|
4268
4273
|
metadata: _metadata
|
|
4269
4274
|
}, null, _instanceExtraInitializers);
|
|
4270
|
-
__esDecorate$
|
|
4275
|
+
__esDecorate$6(this, null, _cancel_decorators, {
|
|
4271
4276
|
kind: "method",
|
|
4272
4277
|
name: "cancel",
|
|
4273
4278
|
static: false,
|
|
@@ -4278,7 +4283,7 @@ let GitHubCopilotAccountsController = (() => {
|
|
|
4278
4283
|
},
|
|
4279
4284
|
metadata: _metadata
|
|
4280
4285
|
}, null, _instanceExtraInitializers);
|
|
4281
|
-
__esDecorate$
|
|
4286
|
+
__esDecorate$6(this, null, _reauthorize_decorators, {
|
|
4282
4287
|
kind: "method",
|
|
4283
4288
|
name: "reauthorize",
|
|
4284
4289
|
static: false,
|
|
@@ -4289,7 +4294,7 @@ let GitHubCopilotAccountsController = (() => {
|
|
|
4289
4294
|
},
|
|
4290
4295
|
metadata: _metadata
|
|
4291
4296
|
}, null, _instanceExtraInitializers);
|
|
4292
|
-
__esDecorate$
|
|
4297
|
+
__esDecorate$6(this, null, _switchAccount_decorators, {
|
|
4293
4298
|
kind: "method",
|
|
4294
4299
|
name: "switchAccount",
|
|
4295
4300
|
static: false,
|
|
@@ -4300,7 +4305,7 @@ let GitHubCopilotAccountsController = (() => {
|
|
|
4300
4305
|
},
|
|
4301
4306
|
metadata: _metadata
|
|
4302
4307
|
}, null, _instanceExtraInitializers);
|
|
4303
|
-
__esDecorate$
|
|
4308
|
+
__esDecorate$6(this, null, _removeAccount_decorators, {
|
|
4304
4309
|
kind: "method",
|
|
4305
4310
|
name: "removeAccount",
|
|
4306
4311
|
static: false,
|
|
@@ -4318,7 +4323,7 @@ let GitHubCopilotAccountsController = (() => {
|
|
|
4318
4323
|
value: _metadata
|
|
4319
4324
|
});
|
|
4320
4325
|
}
|
|
4321
|
-
host = __runInitializers$
|
|
4326
|
+
host = __runInitializers$6(this, _instanceExtraInitializers);
|
|
4322
4327
|
constructor(ctx) {
|
|
4323
4328
|
super(ctx, "githubCopilotAccounts");
|
|
4324
4329
|
this.host = new CopilotAccountsHost(ctx);
|
|
@@ -4356,12 +4361,12 @@ let GitHubCopilotAccountsController = (() => {
|
|
|
4356
4361
|
})();
|
|
4357
4362
|
//#endregion
|
|
4358
4363
|
//#region lib/types/copilot-usage-host.js
|
|
4359
|
-
var __runInitializers$
|
|
4364
|
+
var __runInitializers$5 = function(thisArg, initializers, value) {
|
|
4360
4365
|
var useValue = arguments.length > 2;
|
|
4361
4366
|
for (var i = 0; i < initializers.length; i++) value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
4362
4367
|
return useValue ? value : void 0;
|
|
4363
4368
|
};
|
|
4364
|
-
var __esDecorate$
|
|
4369
|
+
var __esDecorate$5 = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
4365
4370
|
function accept(f) {
|
|
4366
4371
|
if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected");
|
|
4367
4372
|
return f;
|
|
@@ -4705,7 +4710,7 @@ let GitHubCopilotUsageController = (() => {
|
|
|
4705
4710
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
4706
4711
|
_get_decorators = [Remote];
|
|
4707
4712
|
_refresh_decorators = [Remote];
|
|
4708
|
-
__esDecorate$
|
|
4713
|
+
__esDecorate$5(this, null, _get_decorators, {
|
|
4709
4714
|
kind: "method",
|
|
4710
4715
|
name: "get",
|
|
4711
4716
|
static: false,
|
|
@@ -4716,7 +4721,7 @@ let GitHubCopilotUsageController = (() => {
|
|
|
4716
4721
|
},
|
|
4717
4722
|
metadata: _metadata
|
|
4718
4723
|
}, null, _instanceExtraInitializers);
|
|
4719
|
-
__esDecorate$
|
|
4724
|
+
__esDecorate$5(this, null, _refresh_decorators, {
|
|
4720
4725
|
kind: "method",
|
|
4721
4726
|
name: "refresh",
|
|
4722
4727
|
static: false,
|
|
@@ -4734,7 +4739,7 @@ let GitHubCopilotUsageController = (() => {
|
|
|
4734
4739
|
value: _metadata
|
|
4735
4740
|
});
|
|
4736
4741
|
}
|
|
4737
|
-
accountSources = (__runInitializers$
|
|
4742
|
+
accountSources = (__runInitializers$5(this, _instanceExtraInitializers), /* @__PURE__ */ new Map());
|
|
4738
4743
|
source;
|
|
4739
4744
|
accountSignature;
|
|
4740
4745
|
sourceInitialized = false;
|
|
@@ -5009,12 +5014,12 @@ var SessionAccountsHost = class {
|
|
|
5009
5014
|
};
|
|
5010
5015
|
//#endregion
|
|
5011
5016
|
//#region lib/types/session-accounts-controller.js
|
|
5012
|
-
var __runInitializers$
|
|
5017
|
+
var __runInitializers$4 = function(thisArg, initializers, value) {
|
|
5013
5018
|
var useValue = arguments.length > 2;
|
|
5014
5019
|
for (var i = 0; i < initializers.length; i++) value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
5015
5020
|
return useValue ? value : void 0;
|
|
5016
5021
|
};
|
|
5017
|
-
var __esDecorate$
|
|
5022
|
+
var __esDecorate$4 = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
5018
5023
|
function accept(f) {
|
|
5019
5024
|
if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected");
|
|
5020
5025
|
return f;
|
|
@@ -5069,7 +5074,7 @@ let SessionAccountController = (() => {
|
|
|
5069
5074
|
_usage_decorators = [Remote];
|
|
5070
5075
|
_refreshUsage_decorators = [Remote];
|
|
5071
5076
|
_turn_decorators = [Remote];
|
|
5072
|
-
__esDecorate$
|
|
5077
|
+
__esDecorate$4(this, null, _get_decorators, {
|
|
5073
5078
|
kind: "method",
|
|
5074
5079
|
name: "get",
|
|
5075
5080
|
static: false,
|
|
@@ -5080,7 +5085,7 @@ let SessionAccountController = (() => {
|
|
|
5080
5085
|
},
|
|
5081
5086
|
metadata: _metadata
|
|
5082
5087
|
}, null, _instanceExtraInitializers);
|
|
5083
|
-
__esDecorate$
|
|
5088
|
+
__esDecorate$4(this, null, _set_decorators, {
|
|
5084
5089
|
kind: "method",
|
|
5085
5090
|
name: "set",
|
|
5086
5091
|
static: false,
|
|
@@ -5091,7 +5096,7 @@ let SessionAccountController = (() => {
|
|
|
5091
5096
|
},
|
|
5092
5097
|
metadata: _metadata
|
|
5093
5098
|
}, null, _instanceExtraInitializers);
|
|
5094
|
-
__esDecorate$
|
|
5099
|
+
__esDecorate$4(this, null, _refreshIdentity_decorators, {
|
|
5095
5100
|
kind: "method",
|
|
5096
5101
|
name: "refreshIdentity",
|
|
5097
5102
|
static: false,
|
|
@@ -5102,7 +5107,7 @@ let SessionAccountController = (() => {
|
|
|
5102
5107
|
},
|
|
5103
5108
|
metadata: _metadata
|
|
5104
5109
|
}, null, _instanceExtraInitializers);
|
|
5105
|
-
__esDecorate$
|
|
5110
|
+
__esDecorate$4(this, null, _ensureIdentity_decorators, {
|
|
5106
5111
|
kind: "method",
|
|
5107
5112
|
name: "ensureIdentity",
|
|
5108
5113
|
static: false,
|
|
@@ -5113,7 +5118,7 @@ let SessionAccountController = (() => {
|
|
|
5113
5118
|
},
|
|
5114
5119
|
metadata: _metadata
|
|
5115
5120
|
}, null, _instanceExtraInitializers);
|
|
5116
|
-
__esDecorate$
|
|
5121
|
+
__esDecorate$4(this, null, _usage_decorators, {
|
|
5117
5122
|
kind: "method",
|
|
5118
5123
|
name: "usage",
|
|
5119
5124
|
static: false,
|
|
@@ -5124,7 +5129,7 @@ let SessionAccountController = (() => {
|
|
|
5124
5129
|
},
|
|
5125
5130
|
metadata: _metadata
|
|
5126
5131
|
}, null, _instanceExtraInitializers);
|
|
5127
|
-
__esDecorate$
|
|
5132
|
+
__esDecorate$4(this, null, _refreshUsage_decorators, {
|
|
5128
5133
|
kind: "method",
|
|
5129
5134
|
name: "refreshUsage",
|
|
5130
5135
|
static: false,
|
|
@@ -5135,7 +5140,7 @@ let SessionAccountController = (() => {
|
|
|
5135
5140
|
},
|
|
5136
5141
|
metadata: _metadata
|
|
5137
5142
|
}, null, _instanceExtraInitializers);
|
|
5138
|
-
__esDecorate$
|
|
5143
|
+
__esDecorate$4(this, null, _turn_decorators, {
|
|
5139
5144
|
kind: "method",
|
|
5140
5145
|
name: "turn",
|
|
5141
5146
|
static: false,
|
|
@@ -5153,7 +5158,7 @@ let SessionAccountController = (() => {
|
|
|
5153
5158
|
value: _metadata
|
|
5154
5159
|
});
|
|
5155
5160
|
}
|
|
5156
|
-
owner = __runInitializers$
|
|
5161
|
+
owner = __runInitializers$4(this, _instanceExtraInitializers);
|
|
5157
5162
|
constructor(ctx, owner) {
|
|
5158
5163
|
super(ctx, "githubCopilotSessionAccount");
|
|
5159
5164
|
this.owner = owner;
|
|
@@ -5259,7 +5264,7 @@ const usageSchema = z$1.object({
|
|
|
5259
5264
|
totalTokens: count$2.optional(),
|
|
5260
5265
|
reasoningTokens: count$2.optional()
|
|
5261
5266
|
});
|
|
5262
|
-
function record$
|
|
5267
|
+
function record$11(value) {
|
|
5263
5268
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5264
5269
|
}
|
|
5265
5270
|
function sameRoute$1(left, right) {
|
|
@@ -5278,10 +5283,10 @@ function initialContextEvidence() {
|
|
|
5278
5283
|
}
|
|
5279
5284
|
/** Read only counts and routing leaves; never message content or opaque replay. */
|
|
5280
5285
|
function foldContextEvidence(state, event) {
|
|
5281
|
-
if (!record$
|
|
5286
|
+
if (!record$11(event) || typeof event.type !== "string" || !record$11(event.data)) return state;
|
|
5282
5287
|
if (event.type === "request/header" || event.type === "model/selection") {
|
|
5283
|
-
const raw = event.type === "request/header" ? record$
|
|
5284
|
-
if (!record$
|
|
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 {
|
|
5285
5290
|
...state,
|
|
5286
5291
|
route: null,
|
|
5287
5292
|
sample: null,
|
|
@@ -5320,7 +5325,7 @@ function foldContextEvidence(state, event) {
|
|
|
5320
5325
|
if (!copilot(state.route)) return state;
|
|
5321
5326
|
if (event.type === "assistant/message" && event.data.source !== void 0) {
|
|
5322
5327
|
const source = event.data.source;
|
|
5323
|
-
const parsed = routeSchema.safeParse(record$
|
|
5328
|
+
const parsed = routeSchema.safeParse(record$11(source) ? {
|
|
5324
5329
|
provider: source.provider,
|
|
5325
5330
|
model: source.model
|
|
5326
5331
|
} : source);
|
|
@@ -5336,7 +5341,7 @@ function foldContextEvidence(state, event) {
|
|
|
5336
5341
|
const settledUsage = usage !== void 0;
|
|
5337
5342
|
let terminal;
|
|
5338
5343
|
for (const entry of stream) {
|
|
5339
|
-
if (!record$
|
|
5344
|
+
if (!record$11(entry) || entry.type !== "chunk" || !record$11(entry.chunk)) continue;
|
|
5340
5345
|
if (!settledUsage && entry.chunk.type === "usage") usage = entry.chunk.usage;
|
|
5341
5346
|
if (entry.chunk.type === "finish") terminal = entry.chunk.reason;
|
|
5342
5347
|
}
|
|
@@ -5350,7 +5355,7 @@ function foldContextEvidence(state, event) {
|
|
|
5350
5355
|
};
|
|
5351
5356
|
const value = parsed.data;
|
|
5352
5357
|
const zero = isZeroContextUsage(value);
|
|
5353
|
-
const successful = record$
|
|
5358
|
+
const successful = record$11(terminal) && (terminal.kind === "stop" || terminal.kind === "max-tokens" || terminal.kind === "tool-calls");
|
|
5354
5359
|
if (zero && !successful) {
|
|
5355
5360
|
const reason = state.sample !== null || state.reason === "none" ? "failed-zero" : state.reason;
|
|
5356
5361
|
return {
|
|
@@ -5392,7 +5397,7 @@ const contextEvidenceDefinition = {
|
|
|
5392
5397
|
function installContextEvidence(ctx) {
|
|
5393
5398
|
ctx.inject(["sessionProjections"], (scope) => {
|
|
5394
5399
|
const registry = scope.get("sessionProjections");
|
|
5395
|
-
if (!record$
|
|
5400
|
+
if (!record$11(registry) || typeof registry.register !== "function") {
|
|
5396
5401
|
scope.logger.warn("[github-copilot] COPILOT_CONTEXT_PROJECTION_UNAVAILABLE");
|
|
5397
5402
|
return;
|
|
5398
5403
|
}
|
|
@@ -5739,8 +5744,20 @@ function readInlineConfig(config) {
|
|
|
5739
5744
|
const exclusions = readConfigValue(config.excludedModelIds);
|
|
5740
5745
|
const bindings = readConfigValue(config.parentModelFollow);
|
|
5741
5746
|
const accounts = readConfigValue(config.sessionAccounts);
|
|
5747
|
+
const continuation = readConfigValue(config.sessionContinuation);
|
|
5748
|
+
const defaults = readConfigValue(config.continuationDefaultHistory);
|
|
5742
5749
|
return {
|
|
5743
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
|
+
})),
|
|
5744
5761
|
activeAccountId: readConfigValue(config.activeAccountId),
|
|
5745
5762
|
sessionAccounts: accounts === void 0 ? void 0 : Array.from(accounts, (account) => ({
|
|
5746
5763
|
sessionId: account.sessionId,
|
|
@@ -5779,6 +5796,16 @@ const Config = z.object({
|
|
|
5779
5796
|
sessionId: z.string().min(1).max(256),
|
|
5780
5797
|
accountId: z.string().min(1).max(36)
|
|
5781
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(),
|
|
5782
5809
|
followParentModel: z.boolean().default(false).volatile(),
|
|
5783
5810
|
autoSemanticAssessment: z.boolean().default(true),
|
|
5784
5811
|
parentModelFollow: z.array(z.object({
|
|
@@ -6425,7 +6452,7 @@ function buildAnthropicWireBody(request, cfg, model) {
|
|
|
6425
6452
|
}
|
|
6426
6453
|
//#endregion
|
|
6427
6454
|
//#region lib/types/responses-reasoning-text.js
|
|
6428
|
-
function record$
|
|
6455
|
+
function record$10(value) {
|
|
6429
6456
|
return typeof value === "object" && value !== null;
|
|
6430
6457
|
}
|
|
6431
6458
|
function responseIndex(value) {
|
|
@@ -6483,13 +6510,13 @@ var ResponsesReasoningText = class {
|
|
|
6483
6510
|
}
|
|
6484
6511
|
/** Only recognized public text fields are examined; no copying of the item. */
|
|
6485
6512
|
snapshot(item) {
|
|
6486
|
-
if (!record$
|
|
6513
|
+
if (!record$10(item) || item.type !== "reasoning") return "";
|
|
6487
6514
|
let delta = "";
|
|
6488
6515
|
for (const family of ["summary", "raw"]) {
|
|
6489
6516
|
const value = family === "summary" ? item.summary : item.content;
|
|
6490
6517
|
if (!Array.isArray(value)) continue;
|
|
6491
6518
|
for (const [index, part] of value.entries()) {
|
|
6492
|
-
if (!record$
|
|
6519
|
+
if (!record$10(part) || part.type !== (family === "summary" ? "summary_text" : "reasoning_text")) continue;
|
|
6493
6520
|
delta += this.update(family, index, part.text, true);
|
|
6494
6521
|
}
|
|
6495
6522
|
}
|
|
@@ -7819,12 +7846,12 @@ function excludedModelSet(value) {
|
|
|
7819
7846
|
* Host-side bridge between the Models-page companion UI and DSH's neutral
|
|
7820
7847
|
* authorization, credential-record, and settings seams.
|
|
7821
7848
|
*/
|
|
7822
|
-
var __runInitializers$
|
|
7849
|
+
var __runInitializers$3 = function(thisArg, initializers, value) {
|
|
7823
7850
|
var useValue = arguments.length > 2;
|
|
7824
7851
|
for (var i = 0; i < initializers.length; i++) value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
7825
7852
|
return useValue ? value : void 0;
|
|
7826
7853
|
};
|
|
7827
|
-
var __esDecorate$
|
|
7854
|
+
var __esDecorate$3 = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
7828
7855
|
function accept(f) {
|
|
7829
7856
|
if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected");
|
|
7830
7857
|
return f;
|
|
@@ -8154,7 +8181,7 @@ let GitHubCopilotAuthorizationController = (() => {
|
|
|
8154
8181
|
_start_decorators = [Remote];
|
|
8155
8182
|
_cancel_decorators = [Remote];
|
|
8156
8183
|
_signOut_decorators = [Remote];
|
|
8157
|
-
__esDecorate$
|
|
8184
|
+
__esDecorate$3(this, null, _migrationStatus_decorators, {
|
|
8158
8185
|
kind: "method",
|
|
8159
8186
|
name: "migrationStatus",
|
|
8160
8187
|
static: false,
|
|
@@ -8165,7 +8192,7 @@ let GitHubCopilotAuthorizationController = (() => {
|
|
|
8165
8192
|
},
|
|
8166
8193
|
metadata: _metadata
|
|
8167
8194
|
}, null, _instanceExtraInitializers);
|
|
8168
|
-
__esDecorate$
|
|
8195
|
+
__esDecorate$3(this, null, _status_decorators, {
|
|
8169
8196
|
kind: "method",
|
|
8170
8197
|
name: "status",
|
|
8171
8198
|
static: false,
|
|
@@ -8176,7 +8203,7 @@ let GitHubCopilotAuthorizationController = (() => {
|
|
|
8176
8203
|
},
|
|
8177
8204
|
metadata: _metadata
|
|
8178
8205
|
}, null, _instanceExtraInitializers);
|
|
8179
|
-
__esDecorate$
|
|
8206
|
+
__esDecorate$3(this, null, _excludeModel_decorators, {
|
|
8180
8207
|
kind: "method",
|
|
8181
8208
|
name: "excludeModel",
|
|
8182
8209
|
static: false,
|
|
@@ -8187,7 +8214,7 @@ let GitHubCopilotAuthorizationController = (() => {
|
|
|
8187
8214
|
},
|
|
8188
8215
|
metadata: _metadata
|
|
8189
8216
|
}, null, _instanceExtraInitializers);
|
|
8190
|
-
__esDecorate$
|
|
8217
|
+
__esDecorate$3(this, null, _restoreModel_decorators, {
|
|
8191
8218
|
kind: "method",
|
|
8192
8219
|
name: "restoreModel",
|
|
8193
8220
|
static: false,
|
|
@@ -8198,7 +8225,7 @@ let GitHubCopilotAuthorizationController = (() => {
|
|
|
8198
8225
|
},
|
|
8199
8226
|
metadata: _metadata
|
|
8200
8227
|
}, null, _instanceExtraInitializers);
|
|
8201
|
-
__esDecorate$
|
|
8228
|
+
__esDecorate$3(this, null, _setModelExcluded_decorators, {
|
|
8202
8229
|
kind: "method",
|
|
8203
8230
|
name: "setModelExcluded",
|
|
8204
8231
|
static: false,
|
|
@@ -8209,7 +8236,7 @@ let GitHubCopilotAuthorizationController = (() => {
|
|
|
8209
8236
|
},
|
|
8210
8237
|
metadata: _metadata
|
|
8211
8238
|
}, null, _instanceExtraInitializers);
|
|
8212
|
-
__esDecorate$
|
|
8239
|
+
__esDecorate$3(this, null, _discoverModels_decorators, {
|
|
8213
8240
|
kind: "method",
|
|
8214
8241
|
name: "discoverModels",
|
|
8215
8242
|
static: false,
|
|
@@ -8220,7 +8247,7 @@ let GitHubCopilotAuthorizationController = (() => {
|
|
|
8220
8247
|
},
|
|
8221
8248
|
metadata: _metadata
|
|
8222
8249
|
}, null, _instanceExtraInitializers);
|
|
8223
|
-
__esDecorate$
|
|
8250
|
+
__esDecorate$3(this, null, _ensureModels_decorators, {
|
|
8224
8251
|
kind: "method",
|
|
8225
8252
|
name: "ensureModels",
|
|
8226
8253
|
static: false,
|
|
@@ -8231,7 +8258,7 @@ let GitHubCopilotAuthorizationController = (() => {
|
|
|
8231
8258
|
},
|
|
8232
8259
|
metadata: _metadata
|
|
8233
8260
|
}, null, _instanceExtraInitializers);
|
|
8234
|
-
__esDecorate$
|
|
8261
|
+
__esDecorate$3(this, null, _reconcile_decorators, {
|
|
8235
8262
|
kind: "method",
|
|
8236
8263
|
name: "reconcile",
|
|
8237
8264
|
static: false,
|
|
@@ -8242,7 +8269,7 @@ let GitHubCopilotAuthorizationController = (() => {
|
|
|
8242
8269
|
},
|
|
8243
8270
|
metadata: _metadata
|
|
8244
8271
|
}, null, _instanceExtraInitializers);
|
|
8245
|
-
__esDecorate$
|
|
8272
|
+
__esDecorate$3(this, null, _start_decorators, {
|
|
8246
8273
|
kind: "method",
|
|
8247
8274
|
name: "start",
|
|
8248
8275
|
static: false,
|
|
@@ -8253,7 +8280,7 @@ let GitHubCopilotAuthorizationController = (() => {
|
|
|
8253
8280
|
},
|
|
8254
8281
|
metadata: _metadata
|
|
8255
8282
|
}, null, _instanceExtraInitializers);
|
|
8256
|
-
__esDecorate$
|
|
8283
|
+
__esDecorate$3(this, null, _cancel_decorators, {
|
|
8257
8284
|
kind: "method",
|
|
8258
8285
|
name: "cancel",
|
|
8259
8286
|
static: false,
|
|
@@ -8264,7 +8291,7 @@ let GitHubCopilotAuthorizationController = (() => {
|
|
|
8264
8291
|
},
|
|
8265
8292
|
metadata: _metadata
|
|
8266
8293
|
}, null, _instanceExtraInitializers);
|
|
8267
|
-
__esDecorate$
|
|
8294
|
+
__esDecorate$3(this, null, _signOut_decorators, {
|
|
8268
8295
|
kind: "method",
|
|
8269
8296
|
name: "signOut",
|
|
8270
8297
|
static: false,
|
|
@@ -8282,7 +8309,7 @@ let GitHubCopilotAuthorizationController = (() => {
|
|
|
8282
8309
|
value: _metadata
|
|
8283
8310
|
});
|
|
8284
8311
|
}
|
|
8285
|
-
notices = (__runInitializers$
|
|
8312
|
+
notices = (__runInitializers$3(this, _instanceExtraInitializers), []);
|
|
8286
8313
|
failure;
|
|
8287
8314
|
reconciliationFailed = false;
|
|
8288
8315
|
attempt;
|
|
@@ -8737,13 +8764,13 @@ function resolveCopilotResponsesReasoning(ctx, request, candidate) {
|
|
|
8737
8764
|
}
|
|
8738
8765
|
//#endregion
|
|
8739
8766
|
//#region lib/types/replay-recovery.js
|
|
8740
|
-
function record$
|
|
8767
|
+
function record$9(value) {
|
|
8741
8768
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
8742
8769
|
}
|
|
8743
8770
|
function parsed(body) {
|
|
8744
8771
|
if (requestBodyEvidence(body, "openai-responses").state !== "complete" || body === void 0) throw new Error("COPILOT_REPLAY_RECOVERY_EVIDENCE_UNAVAILABLE");
|
|
8745
8772
|
const payload = JSON.parse(body);
|
|
8746
|
-
if (!record$
|
|
8773
|
+
if (!record$9(payload) || !Array.isArray(payload.input) || !payload.input.every(record$9)) throw new Error("COPILOT_REPLAY_RECOVERY_INVALID_PAYLOAD");
|
|
8747
8774
|
return {
|
|
8748
8775
|
input: payload.input,
|
|
8749
8776
|
payload
|
|
@@ -8839,7 +8866,7 @@ var ReplayRecoveryStore = class {
|
|
|
8839
8866
|
const value = hash(item);
|
|
8840
8867
|
return value === void 0 || !admitted.has(value);
|
|
8841
8868
|
}).length === decoded.input.length) return payload;
|
|
8842
|
-
if (!record$
|
|
8869
|
+
if (!record$9(payload) || !Array.isArray(payload.input)) throw new Error("COPILOT_REPLAY_RECOVERY_INVALID_PAYLOAD");
|
|
8843
8870
|
const input = payload.input.filter((_, index) => {
|
|
8844
8871
|
const item = decoded.input[index];
|
|
8845
8872
|
const value = hash(item);
|
|
@@ -8860,12 +8887,12 @@ var ReplayRecoveryStore = class {
|
|
|
8860
8887
|
};
|
|
8861
8888
|
//#endregion
|
|
8862
8889
|
//#region lib/types/replay-recovery-host.js
|
|
8863
|
-
var __runInitializers$
|
|
8890
|
+
var __runInitializers$2 = function(thisArg, initializers, value) {
|
|
8864
8891
|
var useValue = arguments.length > 2;
|
|
8865
8892
|
for (var i = 0; i < initializers.length; i++) value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
8866
8893
|
return useValue ? value : void 0;
|
|
8867
8894
|
};
|
|
8868
|
-
var __esDecorate$
|
|
8895
|
+
var __esDecorate$2 = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
8869
8896
|
function accept(f) {
|
|
8870
8897
|
if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected");
|
|
8871
8898
|
return f;
|
|
@@ -8912,7 +8939,7 @@ let ReplayRecoveryController = (() => {
|
|
|
8912
8939
|
_get_decorators = [Remote];
|
|
8913
8940
|
_setEnabled_decorators = [Remote];
|
|
8914
8941
|
_authorize_decorators = [Remote];
|
|
8915
|
-
__esDecorate$
|
|
8942
|
+
__esDecorate$2(this, null, _get_decorators, {
|
|
8916
8943
|
kind: "method",
|
|
8917
8944
|
name: "get",
|
|
8918
8945
|
static: false,
|
|
@@ -8923,7 +8950,7 @@ let ReplayRecoveryController = (() => {
|
|
|
8923
8950
|
},
|
|
8924
8951
|
metadata: _metadata
|
|
8925
8952
|
}, null, _instanceExtraInitializers);
|
|
8926
|
-
__esDecorate$
|
|
8953
|
+
__esDecorate$2(this, null, _setEnabled_decorators, {
|
|
8927
8954
|
kind: "method",
|
|
8928
8955
|
name: "setEnabled",
|
|
8929
8956
|
static: false,
|
|
@@ -8934,7 +8961,7 @@ let ReplayRecoveryController = (() => {
|
|
|
8934
8961
|
},
|
|
8935
8962
|
metadata: _metadata
|
|
8936
8963
|
}, null, _instanceExtraInitializers);
|
|
8937
|
-
__esDecorate$
|
|
8964
|
+
__esDecorate$2(this, null, _authorize_decorators, {
|
|
8938
8965
|
kind: "method",
|
|
8939
8966
|
name: "authorize",
|
|
8940
8967
|
static: false,
|
|
@@ -8952,7 +8979,7 @@ let ReplayRecoveryController = (() => {
|
|
|
8952
8979
|
value: _metadata
|
|
8953
8980
|
});
|
|
8954
8981
|
}
|
|
8955
|
-
store = __runInitializers$
|
|
8982
|
+
store = __runInitializers$2(this, _instanceExtraInitializers);
|
|
8956
8983
|
proof;
|
|
8957
8984
|
busy;
|
|
8958
8985
|
constructor(ctx, store, proof, busy) {
|
|
@@ -9038,6 +9065,419 @@ function installReplayRecovery(ctx, proof) {
|
|
|
9038
9065
|
};
|
|
9039
9066
|
}
|
|
9040
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
|
|
9041
9481
|
//#region lib/types/agent-compaction.js
|
|
9042
9482
|
function record$7(value) {
|
|
9043
9483
|
return typeof value === "object" && value !== null;
|
|
@@ -11795,11 +12235,27 @@ function apply$1(ctx, config = {}) {
|
|
|
11795
12235
|
};
|
|
11796
12236
|
const currentRuntime = (signal) => runtimeFor(requestBinding(signal));
|
|
11797
12237
|
const directoryRuntime = () => runtimeFor(globalBinding());
|
|
11798
|
-
const
|
|
12238
|
+
const temporaryRecovery = installReplayRecovery(ctx, (agent, request) => {
|
|
11799
12239
|
const accounts = ctx.get("githubCopilotSessionAccounts");
|
|
11800
12240
|
const binding = agent !== void 0 && accounts !== void 0 ? accounts.bindingForAccount((accounts.turns.current(agent.session) ?? accounts.selected(agent)).accountId) : requestBinding(request?.signal);
|
|
11801
12241
|
return runtimeFor(binding).proof();
|
|
11802
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
|
+
};
|
|
11803
12259
|
const initial = directoryRuntime();
|
|
11804
12260
|
const registration = ctx.llm.registerAdapter([GITHUB_COPILOT_PREVIEW_PROVIDER_ID], new AccountRoutingAdapter(initial.optionsFor(), currentRuntime));
|
|
11805
12261
|
publish = () => {
|