dsh-github-copilot 0.4.0-alpha.96 → 0.4.0-alpha.98
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 +12 -0
- package/README.md +10 -6
- package/README.zh.md +10 -6
- package/deployment-baseline.json +22 -1
- package/docs/automatic-model-routing.md +13 -2
- package/docs/copilot-compaction.md +4 -0
- package/lib/index.js +328 -121
- package/lib/types/auto-model-intent.d.ts +36 -0
- package/lib/types/request-body-evidence.d.ts +2 -0
- package/lib/types/request-upload-evidence.d.ts +23 -0
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -19,6 +19,8 @@ import { credentialRef } from "@deepseek-ai/dsh-credentials";
|
|
|
19
19
|
import { Config as Config$1, PiAiAdapter } from "@deepseek-ai/dsh-llm-pi-ai";
|
|
20
20
|
import { estimateContextTokens, estimateMessageTokens } from "@earendil-works/pi-ai/utils/estimate";
|
|
21
21
|
import { buildCopilotDynamicHeaders, hasCopilotVisionInput } from "@earendil-works/pi-ai/api/github-copilot-headers";
|
|
22
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
23
|
+
import { channel } from "node:diagnostics_channel";
|
|
22
24
|
//#region lib/types/dual-model-host.js
|
|
23
25
|
/** Retired planner/executor entry points; retained policies stay enforceable without migration. */
|
|
24
26
|
var __runInitializers$5 = function(thisArg, initializers, value) {
|
|
@@ -193,12 +195,12 @@ function fail$1(reason, creation) {
|
|
|
193
195
|
function creationOf(error) {
|
|
194
196
|
return ownRemoteFailure(error)?.creation ?? "uncertain";
|
|
195
197
|
}
|
|
196
|
-
function object$
|
|
198
|
+
function object$7(value) {
|
|
197
199
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
198
200
|
}
|
|
199
201
|
function api$1(ctx, key, methods) {
|
|
200
202
|
const value = ctx.get(key);
|
|
201
|
-
return object$
|
|
203
|
+
return object$7(value) && methods.every((method) => typeof value[method] === "function") ? value : void 0;
|
|
202
204
|
}
|
|
203
205
|
function revision(value) {
|
|
204
206
|
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
@@ -223,7 +225,7 @@ const ERROR_REASONS = /* @__PURE__ */ new Set([
|
|
|
223
225
|
/** Remote errors cross bundle/realm boundaries; constructor identity is not a protocol. */
|
|
224
226
|
function ownRemoteFailure(error) {
|
|
225
227
|
try {
|
|
226
|
-
if (!object$
|
|
228
|
+
if (!object$7(error) || error.isDSHRemoteError !== true || error.code !== "copilot/dual-model" || !object$7(error.details)) return void 0;
|
|
227
229
|
const reason = error.details.reason;
|
|
228
230
|
if (typeof reason !== "string" || !ERROR_REASONS.has(reason)) return void 0;
|
|
229
231
|
const creation = error.details.creation;
|
|
@@ -239,7 +241,7 @@ function reasonOf(error, fallback) {
|
|
|
239
241
|
const own = ownRemoteFailure(error);
|
|
240
242
|
if (own) return own.reason;
|
|
241
243
|
try {
|
|
242
|
-
if (object$
|
|
244
|
+
if (object$7(error) && error.code === "SETTINGS_CONFLICT") return "DUAL_MODEL_REVISION_CONFLICT";
|
|
243
245
|
} catch {}
|
|
244
246
|
return fallback;
|
|
245
247
|
}
|
|
@@ -367,7 +369,7 @@ let GitHubCopilotDualModel = (() => {
|
|
|
367
369
|
}, { prepend: true });
|
|
368
370
|
ctx.on("system-prompt/assemble", async (_assembly, context, next) => {
|
|
369
371
|
const candidate = context.scope;
|
|
370
|
-
if (!candidate || !object$
|
|
372
|
+
if (!candidate || !object$7(candidate.session) || !object$7(candidate.session.header) || !dedicatedAddress(candidate)) return next();
|
|
371
373
|
const rehydrating = !this.overlays.has(candidate);
|
|
372
374
|
if (rehydrating) this.restore(candidate);
|
|
373
375
|
const installed = this.overlays.get(candidate);
|
|
@@ -1654,14 +1656,14 @@ function isZeroContextUsage(usage) {
|
|
|
1654
1656
|
//#endregion
|
|
1655
1657
|
//#region lib/types/context-evidence.js
|
|
1656
1658
|
const COPILOT_CONTEXT_EVIDENCE = "githubCopilotContextEvidence";
|
|
1657
|
-
const count = z$1.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
|
|
1659
|
+
const count$2 = z$1.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
|
|
1658
1660
|
const routeSchema = z$1.object({
|
|
1659
1661
|
provider: z$1.string().min(1),
|
|
1660
1662
|
model: z$1.string().min(1)
|
|
1661
1663
|
}).strict();
|
|
1662
1664
|
const sampleSchema = z$1.object({
|
|
1663
|
-
tokens: count,
|
|
1664
|
-
seq: count,
|
|
1665
|
+
tokens: count$2,
|
|
1666
|
+
seq: count$2,
|
|
1665
1667
|
route: routeSchema
|
|
1666
1668
|
}).strict();
|
|
1667
1669
|
const ContextEvidenceSchema = z$1.object({
|
|
@@ -1677,14 +1679,14 @@ const ContextEvidenceSchema = z$1.object({
|
|
|
1677
1679
|
])
|
|
1678
1680
|
}).strict();
|
|
1679
1681
|
const usageSchema = z$1.object({
|
|
1680
|
-
inputTokens: count,
|
|
1681
|
-
outputTokens: count,
|
|
1682
|
-
cacheReadTokens: count.optional(),
|
|
1683
|
-
cacheWriteTokens: count.optional(),
|
|
1684
|
-
totalTokens: count.optional(),
|
|
1685
|
-
reasoningTokens: count.optional()
|
|
1682
|
+
inputTokens: count$2,
|
|
1683
|
+
outputTokens: count$2,
|
|
1684
|
+
cacheReadTokens: count$2.optional(),
|
|
1685
|
+
cacheWriteTokens: count$2.optional(),
|
|
1686
|
+
totalTokens: count$2.optional(),
|
|
1687
|
+
reasoningTokens: count$2.optional()
|
|
1686
1688
|
});
|
|
1687
|
-
function record$
|
|
1689
|
+
function record$10(value) {
|
|
1688
1690
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1689
1691
|
}
|
|
1690
1692
|
function sameRoute$1(left, right) {
|
|
@@ -1703,10 +1705,10 @@ function initialContextEvidence() {
|
|
|
1703
1705
|
}
|
|
1704
1706
|
/** Read only counts and routing leaves; never message content or opaque replay. */
|
|
1705
1707
|
function foldContextEvidence(state, event) {
|
|
1706
|
-
if (!record$
|
|
1708
|
+
if (!record$10(event) || typeof event.type !== "string" || !record$10(event.data)) return state;
|
|
1707
1709
|
if (event.type === "request/header" || event.type === "model/selection") {
|
|
1708
|
-
const raw = event.type === "request/header" ? record$
|
|
1709
|
-
if (!record$
|
|
1710
|
+
const raw = event.type === "request/header" ? record$10(event.data.header) ? event.data.header.config : void 0 : event.data;
|
|
1711
|
+
if (!record$10(raw)) return {
|
|
1710
1712
|
...state,
|
|
1711
1713
|
route: null,
|
|
1712
1714
|
sample: null,
|
|
@@ -1745,7 +1747,7 @@ function foldContextEvidence(state, event) {
|
|
|
1745
1747
|
if (!copilot(state.route)) return state;
|
|
1746
1748
|
if (event.type === "assistant/message" && event.data.source !== void 0) {
|
|
1747
1749
|
const source = event.data.source;
|
|
1748
|
-
const parsed = routeSchema.safeParse(record$
|
|
1750
|
+
const parsed = routeSchema.safeParse(record$10(source) ? {
|
|
1749
1751
|
provider: source.provider,
|
|
1750
1752
|
model: source.model
|
|
1751
1753
|
} : source);
|
|
@@ -1761,13 +1763,13 @@ function foldContextEvidence(state, event) {
|
|
|
1761
1763
|
const settledUsage = usage !== void 0;
|
|
1762
1764
|
let terminal;
|
|
1763
1765
|
for (const entry of stream) {
|
|
1764
|
-
if (!record$
|
|
1766
|
+
if (!record$10(entry) || entry.type !== "chunk" || !record$10(entry.chunk)) continue;
|
|
1765
1767
|
if (!settledUsage && entry.chunk.type === "usage") usage = entry.chunk.usage;
|
|
1766
1768
|
if (entry.chunk.type === "finish") terminal = entry.chunk.reason;
|
|
1767
1769
|
}
|
|
1768
1770
|
if (usage === void 0) return state;
|
|
1769
1771
|
const parsed = usageSchema.safeParse(usage);
|
|
1770
|
-
if (!parsed.success || !count.safeParse(event.seq).success) return {
|
|
1772
|
+
if (!parsed.success || !count$2.safeParse(event.seq).success) return {
|
|
1771
1773
|
...state,
|
|
1772
1774
|
sample: null,
|
|
1773
1775
|
invalid: true,
|
|
@@ -1775,7 +1777,7 @@ function foldContextEvidence(state, event) {
|
|
|
1775
1777
|
};
|
|
1776
1778
|
const value = parsed.data;
|
|
1777
1779
|
const zero = isZeroContextUsage(value);
|
|
1778
|
-
const successful = record$
|
|
1780
|
+
const successful = record$10(terminal) && (terminal.kind === "stop" || terminal.kind === "max-tokens" || terminal.kind === "tool-calls");
|
|
1779
1781
|
if (zero && !successful) {
|
|
1780
1782
|
const reason = state.sample !== null || state.reason === "none" ? "failed-zero" : state.reason;
|
|
1781
1783
|
return {
|
|
@@ -1795,7 +1797,7 @@ function foldContextEvidence(state, event) {
|
|
|
1795
1797
|
...state,
|
|
1796
1798
|
sample: {
|
|
1797
1799
|
tokens,
|
|
1798
|
-
seq: count.parse(event.seq),
|
|
1800
|
+
seq: count$2.parse(event.seq),
|
|
1799
1801
|
route: state.route
|
|
1800
1802
|
},
|
|
1801
1803
|
invalid: false,
|
|
@@ -1817,7 +1819,7 @@ const contextEvidenceDefinition = {
|
|
|
1817
1819
|
function installContextEvidence(ctx) {
|
|
1818
1820
|
ctx.inject(["sessionProjections"], (scope) => {
|
|
1819
1821
|
const registry = scope.get("sessionProjections");
|
|
1820
|
-
if (!record$
|
|
1822
|
+
if (!record$10(registry) || typeof registry.register !== "function") {
|
|
1821
1823
|
scope.logger.warn("[github-copilot] COPILOT_CONTEXT_PROJECTION_UNAVAILABLE");
|
|
1822
1824
|
return;
|
|
1823
1825
|
}
|
|
@@ -1831,7 +1833,7 @@ function installContextEvidence(ctx) {
|
|
|
1831
1833
|
//#endregion
|
|
1832
1834
|
//#region package.json
|
|
1833
1835
|
var name$1 = "dsh-github-copilot";
|
|
1834
|
-
var version = "0.4.0-alpha.
|
|
1836
|
+
var version = "0.4.0-alpha.98";
|
|
1835
1837
|
//#endregion
|
|
1836
1838
|
//#region lib/types/probe.js
|
|
1837
1839
|
/**
|
|
@@ -2843,7 +2845,7 @@ function buildAnthropicWireBody(request, cfg, model) {
|
|
|
2843
2845
|
}
|
|
2844
2846
|
//#endregion
|
|
2845
2847
|
//#region lib/types/responses-reasoning-text.js
|
|
2846
|
-
function record$
|
|
2848
|
+
function record$9(value) {
|
|
2847
2849
|
return typeof value === "object" && value !== null;
|
|
2848
2850
|
}
|
|
2849
2851
|
function responseIndex(value) {
|
|
@@ -2901,13 +2903,13 @@ var ResponsesReasoningText = class {
|
|
|
2901
2903
|
}
|
|
2902
2904
|
/** Only recognized public text fields are examined; no copying of the item. */
|
|
2903
2905
|
snapshot(item) {
|
|
2904
|
-
if (!record$
|
|
2906
|
+
if (!record$9(item) || item.type !== "reasoning") return "";
|
|
2905
2907
|
let delta = "";
|
|
2906
2908
|
for (const family of ["summary", "raw"]) {
|
|
2907
2909
|
const value = family === "summary" ? item.summary : item.content;
|
|
2908
2910
|
if (!Array.isArray(value)) continue;
|
|
2909
2911
|
for (const [index, part] of value.entries()) {
|
|
2910
|
-
if (!record$
|
|
2912
|
+
if (!record$9(part) || part.type !== (family === "summary" ? "summary_text" : "reasoning_text")) continue;
|
|
2911
2913
|
delta += this.update(family, index, part.text, true);
|
|
2912
2914
|
}
|
|
2913
2915
|
}
|
|
@@ -4027,19 +4029,19 @@ var TemporaryRouteConflictError = class extends Error {
|
|
|
4027
4029
|
this.name = "TemporaryRouteConflictError";
|
|
4028
4030
|
}
|
|
4029
4031
|
};
|
|
4030
|
-
function object$
|
|
4032
|
+
function object$6(value) {
|
|
4031
4033
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
4032
4034
|
}
|
|
4033
4035
|
function profileAt(value) {
|
|
4034
|
-
return object$
|
|
4036
|
+
return object$6(object$6(object$6(value)?.providers)?.["github-copilot"]);
|
|
4035
4037
|
}
|
|
4036
4038
|
/** Bounded comparison; never stringify or copy unknown model extras or headers. */
|
|
4037
4039
|
function equalJson(a, b, depth = 0) {
|
|
4038
4040
|
if (a === b) return true;
|
|
4039
4041
|
if (depth > 12) return false;
|
|
4040
4042
|
if (Array.isArray(a) || Array.isArray(b)) return Array.isArray(a) && Array.isArray(b) && a.length <= 512 && a.length === b.length && a.every((value, i) => equalJson(value, b[i], depth + 1));
|
|
4041
|
-
const left = object$
|
|
4042
|
-
const right = object$
|
|
4043
|
+
const left = object$6(a);
|
|
4044
|
+
const right = object$6(b);
|
|
4043
4045
|
if (!left || !right) return false;
|
|
4044
4046
|
const keys = Object.keys(left);
|
|
4045
4047
|
return keys.length <= 512 && keys.length === Object.keys(right).length && keys.every((key) => Object.hasOwn(right, key) && equalJson(left[key], right[key], depth + 1));
|
|
@@ -4048,7 +4050,7 @@ const MAX_BACKUP = 131072;
|
|
|
4048
4050
|
function safeModels(value) {
|
|
4049
4051
|
if (!Array.isArray(value) || value.length > 512) throw new TemporaryRouteConflictError();
|
|
4050
4052
|
return value.map((entry) => {
|
|
4051
|
-
const model = object$
|
|
4053
|
+
const model = object$6(entry);
|
|
4052
4054
|
if (!model || typeof model.id !== "string" || !/^[a-zA-Z0-9._:/-]{1,200}$/.test(model.id)) throw new TemporaryRouteConflictError();
|
|
4053
4055
|
const overlay = temporaryGitHubCopilotModel(model.id, /* @__PURE__ */ new Map());
|
|
4054
4056
|
if (overlay && Object.keys(model).some((key) => key !== "id" && key !== "api")) {
|
|
@@ -4079,10 +4081,10 @@ function readBackup(value) {
|
|
|
4079
4081
|
if (value === void 0) return void 0;
|
|
4080
4082
|
if (typeof value !== "string" || value.length > MAX_BACKUP) throw new TemporaryRouteConflictError("TEMPORARY_ROUTE_INVALID_BACKUP");
|
|
4081
4083
|
try {
|
|
4082
|
-
const decoded = object$
|
|
4084
|
+
const decoded = object$6(JSON.parse(value));
|
|
4083
4085
|
if (!decoded) throw new Error();
|
|
4084
4086
|
if (decoded.version === void 0 || decoded.version === 2 && decoded.sourceEpoch === void 0) throw new TemporaryRouteConflictError("TEMPORARY_ROUTE_LEGACY_CONFLICT");
|
|
4085
|
-
if (decoded.version !== 2 || typeof decoded.providerExisted !== "boolean" || typeof decoded.sourceEpoch !== "string" || !/^[a-f0-9-]{36}$/.test(decoded.sourceEpoch) || !Number.isSafeInteger(decoded.sourceRevision) || Number(decoded.sourceRevision) < 0 || !["overlay", "restoring"].includes(String(decoded.phase)) || !object$
|
|
4087
|
+
if (decoded.version !== 2 || typeof decoded.providerExisted !== "boolean" || typeof decoded.sourceEpoch !== "string" || !/^[a-f0-9-]{36}$/.test(decoded.sourceEpoch) || !Number.isSafeInteger(decoded.sourceRevision) || Number(decoded.sourceRevision) < 0 || !["overlay", "restoring"].includes(String(decoded.phase)) || !object$6(decoded.preimage) || !object$6(decoded.postimage) || !object$6(decoded.ownedHeaders) || Object.keys(decoded).some((key) => ![
|
|
4086
4088
|
"version",
|
|
4087
4089
|
"providerExisted",
|
|
4088
4090
|
"preimage",
|
|
@@ -4099,15 +4101,15 @@ function readBackup(value) {
|
|
|
4099
4101
|
decoded.postimage,
|
|
4100
4102
|
...decoded.phase === "restoring" ? [decoded.target] : []
|
|
4101
4103
|
]) {
|
|
4102
|
-
const record = object$
|
|
4104
|
+
const record = object$6(leaf);
|
|
4103
4105
|
if (!record || !equalJson(record, leavesOf(record))) throw new Error();
|
|
4104
4106
|
}
|
|
4105
|
-
const models = object$
|
|
4107
|
+
const models = object$6(decoded.postimage)?.models ?? [];
|
|
4106
4108
|
const knownHeaders = Object.assign({}, ...models.flatMap((model) => {
|
|
4107
4109
|
const overlay = temporaryGitHubCopilotModelFromProfile(model);
|
|
4108
4110
|
return overlay ? [overlay.headers] : [];
|
|
4109
4111
|
}));
|
|
4110
|
-
if (!Object.entries(object$
|
|
4112
|
+
if (!Object.entries(object$6(decoded.ownedHeaders)).every(([name, header]) => knownHeaders[name] === header)) throw new Error();
|
|
4111
4113
|
if (decoded.removeProfile !== void 0 && typeof decoded.removeProfile !== "boolean") throw new Error();
|
|
4112
4114
|
return decoded;
|
|
4113
4115
|
} catch (error) {
|
|
@@ -4133,7 +4135,7 @@ function settingsSnapshot(settings) {
|
|
|
4133
4135
|
hasOwnedSecrets,
|
|
4134
4136
|
routeRevision: route.revision,
|
|
4135
4137
|
markerRevision: marker.revision,
|
|
4136
|
-
backup: readBackup(object$
|
|
4138
|
+
backup: readBackup(object$6(marker.value)?.temporaryRouteBackup)
|
|
4137
4139
|
};
|
|
4138
4140
|
}
|
|
4139
4141
|
function assertOwned(current, backup) {
|
|
@@ -4166,7 +4168,7 @@ function leafOperations(current, target) {
|
|
|
4166
4168
|
}]);
|
|
4167
4169
|
}
|
|
4168
4170
|
function ownedHeaderRemoval(current, backup) {
|
|
4169
|
-
return Object.entries(object$
|
|
4171
|
+
return Object.entries(object$6(current?.headers) ?? {}).flatMap(([name, value]) => Object.entries(backup.ownedHeaders).some(([ownedName, ownedValue]) => name.toLowerCase() === ownedName.toLowerCase() && value === ownedValue) ? [{
|
|
4170
4172
|
op: "unset",
|
|
4171
4173
|
path: [
|
|
4172
4174
|
"providers",
|
|
@@ -4188,7 +4190,7 @@ function wholeProfileOwned(snapshot, backup) {
|
|
|
4188
4190
|
//#endregion
|
|
4189
4191
|
//#region lib/types/migration-status.js
|
|
4190
4192
|
const LIMIT = 1024;
|
|
4191
|
-
function object$
|
|
4193
|
+
function object$5(value) {
|
|
4192
4194
|
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error("Invalid evidence");
|
|
4193
4195
|
return value;
|
|
4194
4196
|
}
|
|
@@ -4197,7 +4199,7 @@ function text$2(value) {
|
|
|
4197
4199
|
return value;
|
|
4198
4200
|
}
|
|
4199
4201
|
function selection(value, omitDefaultEffort = false) {
|
|
4200
|
-
const item = object$
|
|
4202
|
+
const item = object$5(value);
|
|
4201
4203
|
const provider = text$2(item.provider), model = text$2(item.model), effort = item.reasoningEffort;
|
|
4202
4204
|
if (effort !== void 0) text$2(effort);
|
|
4203
4205
|
return {
|
|
@@ -4212,7 +4214,7 @@ function array(value) {
|
|
|
4212
4214
|
}
|
|
4213
4215
|
function api(ctx, name, methods) {
|
|
4214
4216
|
try {
|
|
4215
|
-
const candidate = object$
|
|
4217
|
+
const candidate = object$5(ctx.get(name));
|
|
4216
4218
|
return methods.every((key) => typeof candidate[key] === "function") ? candidate : void 0;
|
|
4217
4219
|
} catch {
|
|
4218
4220
|
return;
|
|
@@ -4282,26 +4284,26 @@ function migrationStatus(ctx) {
|
|
|
4282
4284
|
const rows = [], ids = /* @__PURE__ */ new Set();
|
|
4283
4285
|
let complete = projections !== void 0;
|
|
4284
4286
|
for (const candidate of array(call(agents, "list"))) {
|
|
4285
|
-
const agent = object$
|
|
4287
|
+
const agent = object$5(candidate), id = text$2(agent.id), status = agent.status;
|
|
4286
4288
|
if (ids.has(id) || status !== "idle" && status !== "running") throw new Error("Invalid agent inventory");
|
|
4287
4289
|
ids.add(id);
|
|
4288
|
-
const session = object$
|
|
4290
|
+
const session = object$5(agent.session);
|
|
4289
4291
|
if (text$2(session.id) !== id) throw new Error("Invalid agent identity");
|
|
4290
4292
|
const header = call(session, "requestHeader");
|
|
4291
|
-
const request = header === void 0 ? null : selection(object$
|
|
4293
|
+
const request = header === void 0 ? null : selection(object$5(header).config);
|
|
4292
4294
|
let effective = null, source = "unknown";
|
|
4293
4295
|
if (projections) {
|
|
4294
4296
|
const state = call(projections, "stateOf", session, "modelSelection");
|
|
4295
4297
|
if (state !== void 0) {
|
|
4296
|
-
const pending = object$
|
|
4298
|
+
const pending = object$5(state).pending;
|
|
4297
4299
|
if (pending !== null) {
|
|
4298
4300
|
effective = selection(pending);
|
|
4299
4301
|
source = "pending";
|
|
4300
4302
|
} else if (header !== void 0) {
|
|
4301
|
-
const defaults = object$
|
|
4302
|
-
const defaultEffort = defaults === void 0 ? false : object$
|
|
4303
|
+
const defaults = object$5(header).adapterDefaults;
|
|
4304
|
+
const defaultEffort = defaults === void 0 ? false : object$5(defaults).reasoningEffort;
|
|
4303
4305
|
if (defaultEffort !== void 0 && typeof defaultEffort !== "boolean") throw new Error("Invalid adapter defaults");
|
|
4304
|
-
effective = selection(object$
|
|
4306
|
+
effective = selection(object$5(header).config, defaultEffort === true);
|
|
4305
4307
|
source = "request-header";
|
|
4306
4308
|
} else if (result.complete.defaultSelection) {
|
|
4307
4309
|
effective = result.defaultSelection;
|
|
@@ -4325,23 +4327,23 @@ function migrationStatus(ctx) {
|
|
|
4325
4327
|
const descriptors = array(call(settings, "describe", { redactSecrets: true }));
|
|
4326
4328
|
const found = /* @__PURE__ */ new Set();
|
|
4327
4329
|
for (const value of descriptors) {
|
|
4328
|
-
const descriptor = object$
|
|
4330
|
+
const descriptor = object$5(value);
|
|
4329
4331
|
const ns = text$2(descriptor.ns);
|
|
4330
4332
|
if (ns !== "llm-pi-ai" && ns !== "github-copilot") continue;
|
|
4331
4333
|
if (found.has(ns) || !Number.isSafeInteger(descriptor.revision) || descriptor.revision < 0) throw new Error("Invalid settings evidence");
|
|
4332
4334
|
found.add(ns);
|
|
4333
4335
|
}
|
|
4334
4336
|
if (found.size !== 2) throw new Error("Unregistered settings");
|
|
4335
|
-
const config = object$
|
|
4336
|
-
const profile = (config.providers === void 0 ? void 0 : object$
|
|
4337
|
-
if (profile !== void 0) object$
|
|
4337
|
+
const config = object$5(call(settings, "get", "llm-pi-ai"));
|
|
4338
|
+
const profile = (config.providers === void 0 ? void 0 : object$5(config.providers))?.[GITHUB_COPILOT_PROVIDER_ID];
|
|
4339
|
+
if (profile !== void 0) object$5(profile);
|
|
4338
4340
|
result.capabilities.settingsCas = true;
|
|
4339
4341
|
result.routes.nativeConfigured = profile !== void 0;
|
|
4340
4342
|
} catch {}
|
|
4341
4343
|
if (llm) try {
|
|
4342
4344
|
const ids = /* @__PURE__ */ new Set();
|
|
4343
4345
|
for (const value of array(call(llm, "listProviders"))) {
|
|
4344
|
-
const id = text$2(object$
|
|
4346
|
+
const id = text$2(object$5(value).id);
|
|
4345
4347
|
if (ids.has(id)) throw new Error("Invalid registry evidence");
|
|
4346
4348
|
ids.add(id);
|
|
4347
4349
|
}
|
|
@@ -4543,7 +4545,7 @@ function modelPreferencesView(ctx, accountModels, error) {
|
|
|
4543
4545
|
if (!Number.isSafeInteger(descriptor.revision) || descriptor.revision < 0) return unavailable("COPILOT_MODEL_SETTINGS_INVALID");
|
|
4544
4546
|
let excludedModelIds;
|
|
4545
4547
|
try {
|
|
4546
|
-
const raw = object$
|
|
4548
|
+
const raw = object$6(descriptor.value);
|
|
4547
4549
|
if (raw === void 0) return unavailable("COPILOT_MODEL_SETTINGS_INVALID");
|
|
4548
4550
|
excludedModelIds = normalizeExcludedModelIds(raw.excludedModelIds);
|
|
4549
4551
|
} catch {
|
|
@@ -4660,7 +4662,7 @@ async function repairGitHubCopilotProviderProfile(ctx) {
|
|
|
4660
4662
|
try {
|
|
4661
4663
|
await settings.mutate(namespace, operations, revision);
|
|
4662
4664
|
} catch (error) {
|
|
4663
|
-
if (object$
|
|
4665
|
+
if (object$6(error)?.code === "SETTINGS_CONFLICT") throw new TemporaryRouteConflictError();
|
|
4664
4666
|
throw error;
|
|
4665
4667
|
}
|
|
4666
4668
|
};
|
|
@@ -5086,7 +5088,7 @@ let GitHubCopilotAuthorizationController = (() => {
|
|
|
5086
5088
|
}], current.revision);
|
|
5087
5089
|
this.modelPreferenceFailure = void 0;
|
|
5088
5090
|
} catch (cause) {
|
|
5089
|
-
const record = object$
|
|
5091
|
+
const record = object$6(cause);
|
|
5090
5092
|
this.modelPreferenceFailure = record?.code === "SETTINGS_CONFLICT" || cause instanceof Error && /conflict/i.test(cause.message) ? "COPILOT_MODEL_EXCLUSION_CONFLICT" : "COPILOT_MODEL_EXCLUSION_SAVE_FAILED";
|
|
5091
5093
|
}
|
|
5092
5094
|
return view();
|
|
@@ -5231,7 +5233,7 @@ const levels = [
|
|
|
5231
5233
|
"xhigh",
|
|
5232
5234
|
"max"
|
|
5233
5235
|
];
|
|
5234
|
-
function object$
|
|
5236
|
+
function object$4(value) {
|
|
5235
5237
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
5236
5238
|
}
|
|
5237
5239
|
function unavailable() {
|
|
@@ -5240,18 +5242,18 @@ function unavailable() {
|
|
|
5240
5242
|
/** Resolve only the selected model's declared/native efforts, with the same precedence as Core. */
|
|
5241
5243
|
function resolveCopilotResponsesReasoning(ctx, request, candidate) {
|
|
5242
5244
|
if (request.provider !== "github-copilot" || candidate.protocol !== "openai-responses" || candidate.model !== request.model) return unavailable();
|
|
5243
|
-
const profile = object$
|
|
5245
|
+
const profile = object$4(object$4(object$4(readSettingsNamespace(ctx, "llm-pi-ai"))?.providers)?.["github-copilot"]);
|
|
5244
5246
|
const effort = request.reasoningEffort ?? profile?.reasoning;
|
|
5245
5247
|
if (effort === void 0) return void 0;
|
|
5246
5248
|
const level = levels.find((value) => value === effort);
|
|
5247
5249
|
if (level === void 0 || profile === void 0) return unavailable();
|
|
5248
5250
|
const configured = Array.isArray(profile.models) ? profile.models : [];
|
|
5249
|
-
const entry = configured.length > 0 ? object$
|
|
5251
|
+
const entry = configured.length > 0 ? object$4(configured.find((value) => object$4(value)?.id === request.model)) : object$4(object$4(profile.modelOverrides)?.[request.model]);
|
|
5250
5252
|
if (configured.length > 0 && entry === void 0) return unavailable();
|
|
5251
5253
|
const declared = entry?.reasoningEfforts;
|
|
5252
5254
|
if (declared !== void 0) {
|
|
5253
5255
|
if (declared === false) return level === "off" ? void 0 : unavailable();
|
|
5254
|
-
const mapping = object$
|
|
5256
|
+
const mapping = object$4(declared);
|
|
5255
5257
|
if (mapping === void 0) return unavailable();
|
|
5256
5258
|
const wire = mapping[level];
|
|
5257
5259
|
if (level === "off" && (wire === null || typeof wire === "string" && wire.length > 0)) return void 0;
|
|
@@ -5285,7 +5287,7 @@ var EvidenceParseError = class extends Error {
|
|
|
5285
5287
|
this.state = state;
|
|
5286
5288
|
}
|
|
5287
5289
|
};
|
|
5288
|
-
function object$
|
|
5290
|
+
function object$3(value) {
|
|
5289
5291
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5290
5292
|
}
|
|
5291
5293
|
/** Diagnostic-only traversal of the original JSON spans; never reserializes or changes a request. */
|
|
@@ -5331,7 +5333,7 @@ function requestBodyEvidence(body, protocol) {
|
|
|
5331
5333
|
}
|
|
5332
5334
|
const conversationKey = protocol === "openai-responses" ? "input" : "messages";
|
|
5333
5335
|
const systemKey = protocol === "openai-responses" ? "instructions" : protocol === "anthropic-messages" ? "system" : void 0;
|
|
5334
|
-
if (!object$
|
|
5336
|
+
if (!object$3(parsed) || !Array.isArray(parsed[conversationKey])) return {
|
|
5335
5337
|
state: "unsupported-shape",
|
|
5336
5338
|
totalBytes
|
|
5337
5339
|
};
|
|
@@ -5350,7 +5352,7 @@ function requestBodyEvidence(body, protocol) {
|
|
|
5350
5352
|
}
|
|
5351
5353
|
throw new EvidenceParseError("invalid-json");
|
|
5352
5354
|
};
|
|
5353
|
-
const isImage = (value) => protocol === "anthropic-messages" ? value.type === "image" && object$
|
|
5355
|
+
const isImage = (value) => protocol === "anthropic-messages" ? value.type === "image" && object$3(value.source) && (value.source.type === "base64" && typeof value.source.data === "string" || value.source.type === "url" && typeof value.source.url === "string") : protocol === "openai-responses" ? value.type === "input_image" && (typeof value.image_url === "string" || typeof value.file_id === "string") : value.type === "image_url" && object$3(value.image_url) && typeof value.image_url.url === "string";
|
|
5354
5356
|
const isOpaque = (parent, key, location) => protocol === "openai-responses" ? location === "conversation" && parent.type === "reasoning" && key === "encrypted_content" : location === "content" && protocol === "anthropic-messages" && (parent.type === "thinking" && key === "signature" || parent.type === "redacted_thinking" && key === "data");
|
|
5355
5357
|
const visit = (value, depth, location) => {
|
|
5356
5358
|
if (++values > REQUEST_BODY_EVIDENCE_LIMITS.values || depth > REQUEST_BODY_EVIDENCE_LIMITS.depth) throw new EvidenceParseError("work-limit");
|
|
@@ -5370,7 +5372,7 @@ function requestBodyEvidence(body, protocol) {
|
|
|
5370
5372
|
}
|
|
5371
5373
|
whitespace();
|
|
5372
5374
|
if (body[position++] !== "]") throw new EvidenceParseError("invalid-json");
|
|
5373
|
-
} else if (object$
|
|
5375
|
+
} else if (object$3(value)) {
|
|
5374
5376
|
if (body[position++] !== "{") throw new EvidenceParseError("invalid-json");
|
|
5375
5377
|
const imageBlock = location === "content" && isImage(value);
|
|
5376
5378
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -5454,13 +5456,13 @@ function requestBodyEvidence(body, protocol) {
|
|
|
5454
5456
|
}
|
|
5455
5457
|
//#endregion
|
|
5456
5458
|
//#region lib/types/replay-recovery.js
|
|
5457
|
-
function record$
|
|
5459
|
+
function record$8(value) {
|
|
5458
5460
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
5459
5461
|
}
|
|
5460
5462
|
function parsed(body) {
|
|
5461
5463
|
if (requestBodyEvidence(body, "openai-responses").state !== "complete" || body === void 0) throw new Error("COPILOT_REPLAY_RECOVERY_EVIDENCE_UNAVAILABLE");
|
|
5462
5464
|
const payload = JSON.parse(body);
|
|
5463
|
-
if (!record$
|
|
5465
|
+
if (!record$8(payload) || !Array.isArray(payload.input) || !payload.input.every(record$8)) throw new Error("COPILOT_REPLAY_RECOVERY_INVALID_PAYLOAD");
|
|
5464
5466
|
return {
|
|
5465
5467
|
input: payload.input,
|
|
5466
5468
|
payload
|
|
@@ -5556,7 +5558,7 @@ var ReplayRecoveryStore = class {
|
|
|
5556
5558
|
const value = hash(item);
|
|
5557
5559
|
return value === void 0 || !admitted.has(value);
|
|
5558
5560
|
}).length === decoded.input.length) return payload;
|
|
5559
|
-
if (!record$
|
|
5561
|
+
if (!record$8(payload) || !Array.isArray(payload.input)) throw new Error("COPILOT_REPLAY_RECOVERY_INVALID_PAYLOAD");
|
|
5560
5562
|
const input = payload.input.filter((_, index) => {
|
|
5561
5563
|
const item = decoded.input[index];
|
|
5562
5564
|
const value = hash(item);
|
|
@@ -6050,21 +6052,121 @@ async function isCopilotInputItemScopeError(response, signal) {
|
|
|
6050
6052
|
//#region lib/types/request-body-timeout-marker.js
|
|
6051
6053
|
const REQUEST_BODY_TIMEOUT_MARKER = "COPILOT_REQUEST_BODY_TIMEOUT: Copilot returned HTTP 408 / user_request_timeout while reading the request body; this is not context-window overflow.";
|
|
6052
6054
|
//#endregion
|
|
6055
|
+
//#region lib/types/request-upload-evidence.js
|
|
6056
|
+
function object$2(value) {
|
|
6057
|
+
return typeof value === "object" && value !== null;
|
|
6058
|
+
}
|
|
6059
|
+
function count$1(value) {
|
|
6060
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : void 0;
|
|
6061
|
+
}
|
|
6062
|
+
/** Observe public native events only; never read request fields, mutate transport or imply remote receipt. */
|
|
6063
|
+
function createRequestUploadObserver() {
|
|
6064
|
+
const scope = new AsyncLocalStorage(), token = {}, requests = /* @__PURE__ */ new WeakMap();
|
|
6065
|
+
let startedAt;
|
|
6066
|
+
let requestCount = 0, closed = false, bodyWrite = false;
|
|
6067
|
+
let bodyWriteCompleteMs, nativeResponseHeadersMs;
|
|
6068
|
+
let socket;
|
|
6069
|
+
let connectionAmbiguous = false, socketBoundToRequest = false;
|
|
6070
|
+
let alpn = "unavailable", nodeWritableBufferBytes;
|
|
6071
|
+
const elapsed = () => startedAt === void 0 ? void 0 : count$1(Math.round(performance.now() - startedAt));
|
|
6072
|
+
const request = (data) => !closed && object$2(data) && object$2(data.request) ? requests.get(data.request) : void 0;
|
|
6073
|
+
const connected = (data, boundToRequest = false) => {
|
|
6074
|
+
if (closed || !object$2(data) || !object$2(data.socket)) return;
|
|
6075
|
+
if (!boundToRequest) {
|
|
6076
|
+
if (socketBoundToRequest || connectionAmbiguous) return;
|
|
6077
|
+
if (socket !== void 0 && socket !== data.socket) {
|
|
6078
|
+
connectionAmbiguous = true;
|
|
6079
|
+
socket = void 0;
|
|
6080
|
+
alpn = "unavailable";
|
|
6081
|
+
nodeWritableBufferBytes = void 0;
|
|
6082
|
+
return;
|
|
6083
|
+
}
|
|
6084
|
+
}
|
|
6085
|
+
socketBoundToRequest = boundToRequest;
|
|
6086
|
+
socket = data.socket;
|
|
6087
|
+
alpn = socket.encrypted === true && (socket.alpnProtocol === "h2" || socket.alpnProtocol === "http/1.1") ? socket.alpnProtocol : "unavailable";
|
|
6088
|
+
};
|
|
6089
|
+
const handlers = {
|
|
6090
|
+
"undici:request:create": (data) => {
|
|
6091
|
+
if (closed || scope.getStore() !== token || !object$2(data) || !object$2(data.request)) return;
|
|
6092
|
+
if (requests.has(data.request) || requestCount > 8) return;
|
|
6093
|
+
requestCount++;
|
|
6094
|
+
if (requestCount <= 8) requests.set(data.request, requestCount);
|
|
6095
|
+
},
|
|
6096
|
+
"undici:client:connected": (data) => {
|
|
6097
|
+
if (scope.getStore() === token && requestCount === 1) connected(data);
|
|
6098
|
+
},
|
|
6099
|
+
"undici:client:sendHeaders": (data) => {
|
|
6100
|
+
if (request(data) === 1) connected(data, true);
|
|
6101
|
+
},
|
|
6102
|
+
"undici:request:bodySent": (data) => {
|
|
6103
|
+
if (request(data) !== 1 || bodyWrite) return;
|
|
6104
|
+
bodyWrite = true;
|
|
6105
|
+
bodyWriteCompleteMs = elapsed();
|
|
6106
|
+
nodeWritableBufferBytes = count$1(socket?.writableLength);
|
|
6107
|
+
},
|
|
6108
|
+
"undici:request:headers": (data) => {
|
|
6109
|
+
if (request(data) === 1 && nativeResponseHeadersMs === void 0) nativeResponseHeadersMs = elapsed();
|
|
6110
|
+
}
|
|
6111
|
+
};
|
|
6112
|
+
for (const [name, handler] of Object.entries(handlers)) channel(name).subscribe(handler);
|
|
6113
|
+
return {
|
|
6114
|
+
run: (operation) => {
|
|
6115
|
+
if (closed) throw new Error("COPILOT_UPLOAD_OBSERVER_CLOSED");
|
|
6116
|
+
startedAt ??= performance.now();
|
|
6117
|
+
return scope.run(token, operation);
|
|
6118
|
+
},
|
|
6119
|
+
snapshot: () => {
|
|
6120
|
+
if (requestCount === 0) return { state: "unavailable" };
|
|
6121
|
+
if (requestCount > 8) return { state: "work-limit" };
|
|
6122
|
+
if (requestCount !== 1) return {
|
|
6123
|
+
state: "ambiguous",
|
|
6124
|
+
requestCount
|
|
6125
|
+
};
|
|
6126
|
+
return {
|
|
6127
|
+
state: "observed",
|
|
6128
|
+
bodyWrite: bodyWrite ? "observed" : "not-observed",
|
|
6129
|
+
alpn,
|
|
6130
|
+
...bodyWriteCompleteMs === void 0 ? {} : { bodyWriteCompleteMs },
|
|
6131
|
+
...nativeResponseHeadersMs === void 0 ? {} : { nativeResponseHeadersMs },
|
|
6132
|
+
...nodeWritableBufferBytes === void 0 ? {} : { nodeWritableBufferBytes }
|
|
6133
|
+
};
|
|
6134
|
+
},
|
|
6135
|
+
close: () => {
|
|
6136
|
+
if (closed) return;
|
|
6137
|
+
closed = true;
|
|
6138
|
+
for (const [name, handler] of Object.entries(handlers)) channel(name).unsubscribe(handler);
|
|
6139
|
+
socket = void 0;
|
|
6140
|
+
scope.disable();
|
|
6141
|
+
}
|
|
6142
|
+
};
|
|
6143
|
+
}
|
|
6144
|
+
function formatRequestUploadEvidence(evidence) {
|
|
6145
|
+
if (evidence === void 0 || evidence.state === "unavailable") return "Client transport evidence unavailable (no matching native diagnostic events).";
|
|
6146
|
+
if (evidence.state === "ambiguous") return `Client transport evidence unavailable (ambiguous: ${evidence.requestCount} native requests; no combined timings).`;
|
|
6147
|
+
if (evidence.state === "work-limit") return "Client transport evidence unavailable (work-limit; no partial timings).";
|
|
6148
|
+
const body = evidence.bodyWrite === "not-observed" ? "local body-write completion not observed (not proof of incomplete upload)" : evidence.bodyWriteCompleteMs === void 0 ? "local body-write completion observed; timing unavailable" : `local body-write complete at ${evidence.bodyWriteCompleteMs} ms`;
|
|
6149
|
+
const headers = evidence.nativeResponseHeadersMs === void 0 ? "native response-header timing unavailable" : `native response headers at ${evidence.nativeResponseHeadersMs} ms`;
|
|
6150
|
+
const buffer = evidence.nodeWritableBufferBytes === void 0 ? "Node writable-buffer count unavailable" : `Node writable buffer at local body-write completion ${evidence.nodeWritableBufferBytes} bytes`;
|
|
6151
|
+
return `Client transport evidence: ${body}; ${headers}; TLS ALPN ${evidence.alpn}; ${buffer}. Local submission only, not upload duration, kernel ACK, supplier receipt or execution.`;
|
|
6152
|
+
}
|
|
6153
|
+
//#endregion
|
|
6053
6154
|
//#region lib/types/request-body-timeout.js
|
|
6054
6155
|
const observedMessage = "Timed out reading request body. Try again, or use a smaller request size.";
|
|
6055
|
-
function record$
|
|
6156
|
+
function record$7(value) {
|
|
6056
6157
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6057
6158
|
}
|
|
6058
6159
|
/** Verified provider evidence, not guessed capabilities, token limits or network cause. */
|
|
6059
6160
|
async function requestBodyTimeoutDiagnostic(response, body, signal, dispatch) {
|
|
6060
6161
|
if (response.status !== 408 || signal?.aborted) return void 0;
|
|
6061
6162
|
const value = await readResponseErrorJson(response, signal);
|
|
6062
|
-
if (signal?.aborted || !record$
|
|
6163
|
+
if (signal?.aborted || !record$7(value)) return void 0;
|
|
6063
6164
|
const error = Object.hasOwn(value, "error") ? value.error : value;
|
|
6064
|
-
if (!record$
|
|
6165
|
+
if (!record$7(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;
|
|
6065
6166
|
const size = body === void 0 ? "Request body size unavailable." : `Request body: ${Buffer.byteLength(body, "utf8")} UTF-8 bytes (not context tokens).`;
|
|
6066
6167
|
const composition = formatRequestBodyEvidence(dispatch === void 0 ? { state: "unavailable" } : requestBodyEvidence(body, dispatch.protocol), dispatch?.responseHeadersMs);
|
|
6067
|
-
|
|
6168
|
+
const upload = formatRequestUploadEvidence(dispatch?.upload);
|
|
6169
|
+
return `${REQUEST_BODY_TIMEOUT_MARKER} ${size} ${composition} ${upload} Native retry policy is unchanged. If retries exhaust, use these numbers to choose an explicit attachment/image-offload budget change or native compaction for compressible history; tool definitions and opaque replay may remain. Also check network/proxy health and GitHub service status. Composition alone does not establish a cause or supplier size limit. A larger client timeout does not change this server timeout. No history was trimmed or model switched.`;
|
|
6068
6170
|
}
|
|
6069
6171
|
//#endregion
|
|
6070
6172
|
//#region lib/types/copilot-stream-liveness.js
|
|
@@ -6417,19 +6519,23 @@ function createAccountProvider(descriptors, guard, baseURL) {
|
|
|
6417
6519
|
clientRequestHeader: replayHeaders?.has("x-client-request-id")
|
|
6418
6520
|
} : void 0;
|
|
6419
6521
|
let response;
|
|
6522
|
+
const upload = guard.onRequestBodyTimeout === void 0 ? void 0 : createRequestUploadObserver();
|
|
6420
6523
|
const startedAt = performance.now();
|
|
6421
6524
|
try {
|
|
6422
|
-
response = await fetch(input, init);
|
|
6525
|
+
response = await (upload === void 0 ? fetch(input, init) : upload.run(() => fetch(input, init)));
|
|
6423
6526
|
} catch (error) {
|
|
6424
6527
|
retry?.observe(void 0, 0);
|
|
6425
6528
|
throw error;
|
|
6529
|
+
} finally {
|
|
6530
|
+
upload?.close();
|
|
6426
6531
|
}
|
|
6427
6532
|
const responseHeadersMs = performance.now() - startedAt;
|
|
6428
6533
|
retry?.observe(typeof init?.body === "string" ? init.body : void 0, response.status);
|
|
6429
6534
|
if (response.status === 408 && guard.onRequestBodyTimeout !== void 0) {
|
|
6430
6535
|
const diagnostic = await requestBodyTimeoutDiagnostic(response, typeof init?.body === "string" ? init.body : void 0, lease.signal, {
|
|
6431
6536
|
protocol: entry.api,
|
|
6432
|
-
responseHeadersMs
|
|
6537
|
+
responseHeadersMs,
|
|
6538
|
+
...upload === void 0 ? {} : { upload: upload.snapshot() }
|
|
6433
6539
|
});
|
|
6434
6540
|
if (!lease.signal.aborted && !options.signal?.aborted) guard.onRequestBodyTimeout(diagnostic);
|
|
6435
6541
|
}
|
|
@@ -6544,7 +6650,7 @@ var Budget = class {
|
|
|
6544
6650
|
if (this.consumed > ACCOUNT_MODEL_CATALOG_LIMITS.maxBytes) fail("CATALOG_TOO_LARGE", true);
|
|
6545
6651
|
}
|
|
6546
6652
|
};
|
|
6547
|
-
function record$
|
|
6653
|
+
function record$6(value, code) {
|
|
6548
6654
|
if (typeof value !== "object" || value === null || Array.isArray(value)) fail(code);
|
|
6549
6655
|
return value;
|
|
6550
6656
|
}
|
|
@@ -6597,11 +6703,11 @@ function normalizeModel(raw, id, options, budget) {
|
|
|
6597
6703
|
if (options.availableModelIds?.has(id) !== true) fail("MISSING_POLICY");
|
|
6598
6704
|
policySource = "account-available-id";
|
|
6599
6705
|
} else {
|
|
6600
|
-
if (text$1(field(record$
|
|
6706
|
+
if (text$1(field(record$6(rawPolicy, "INVALID_POLICY"), "state", budget), 64, "INVALID_POLICY", budget) !== "enabled") fail("POLICY_NOT_ENABLED");
|
|
6601
6707
|
policySource = "server-enabled";
|
|
6602
6708
|
}
|
|
6603
|
-
const capabilities = record$
|
|
6604
|
-
const supports = record$
|
|
6709
|
+
const capabilities = record$6(field(raw, "capabilities", budget), "INVALID_CAPABILITIES");
|
|
6710
|
+
const supports = record$6(field(capabilities, "supports", budget), "INVALID_SUPPORTS");
|
|
6605
6711
|
const streaming = field(supports, "streaming", budget);
|
|
6606
6712
|
if (streaming === false) fail("STREAMING_UNSUPPORTED");
|
|
6607
6713
|
if (streaming !== true) fail("INVALID_SUPPORTS");
|
|
@@ -6622,7 +6728,7 @@ function normalizeModel(raw, id, options, budget) {
|
|
|
6622
6728
|
if (selected === void 0) fail(unsupportedEndpointCount === 0 && endpoints.includes("ws:/responses") ? "WEBSOCKET_ONLY" : "UNSUPPORTED_ENDPOINTS");
|
|
6623
6729
|
const rawLimits = field(capabilities, "limits", budget);
|
|
6624
6730
|
if (rawLimits === void 0) fail("MISSING_LIMITS");
|
|
6625
|
-
const limits = record$
|
|
6731
|
+
const limits = record$6(rawLimits, "INVALID_LIMITS");
|
|
6626
6732
|
const maxContext = optionalPositive(limits, "max_context_window_tokens", "INVALID_LIMITS", budget);
|
|
6627
6733
|
const maxInputTokens = optionalPositive(limits, "max_prompt_tokens", "INVALID_LIMITS", budget);
|
|
6628
6734
|
if (maxContext === void 0 && maxInputTokens === void 0) fail("MISSING_CONTEXT_LIMIT");
|
|
@@ -6640,7 +6746,7 @@ function normalizeModel(raw, id, options, budget) {
|
|
|
6640
6746
|
if (vision === true) {
|
|
6641
6747
|
const rawVisionLimits = field(limits, "vision", budget);
|
|
6642
6748
|
if (rawVisionLimits !== void 0) {
|
|
6643
|
-
const rawMediaTypes = field(record$
|
|
6749
|
+
const rawMediaTypes = field(record$6(rawVisionLimits, "INVALID_VISION_LIMITS"), "supported_media_types", budget);
|
|
6644
6750
|
if (rawMediaTypes !== void 0) {
|
|
6645
6751
|
const mediaTypes = stringList(rawMediaTypes, ACCOUNT_MODEL_CATALOG_LIMITS.maxMediaTypes, 128, "INVALID_VISION_LIMITS", budget);
|
|
6646
6752
|
const mime = /^[a-z0-9][a-z0-9!#$%&'*+.^_`|~-]*\/[a-z0-9][a-z0-9!#$%&'*+.^_`|~-]*$/iu;
|
|
@@ -6702,7 +6808,7 @@ function normalizeAccountModelCatalog(raw, options = {}) {
|
|
|
6702
6808
|
fail("INVALID_JSON", true);
|
|
6703
6809
|
}
|
|
6704
6810
|
}
|
|
6705
|
-
const data = field(record$
|
|
6811
|
+
const data = field(record$6(raw, "INVALID_CATALOG"), "data", budget);
|
|
6706
6812
|
if (!Array.isArray(data)) fail("INVALID_CATALOG");
|
|
6707
6813
|
const count = field(data, "length", budget);
|
|
6708
6814
|
if (typeof count !== "number" || !Number.isSafeInteger(count) || count < 0) fail("INVALID_CATALOG");
|
|
@@ -6725,7 +6831,7 @@ function normalizeAccountModelCatalog(raw, options = {}) {
|
|
|
6725
6831
|
for (let index = 0; index < count; index++) {
|
|
6726
6832
|
let id;
|
|
6727
6833
|
try {
|
|
6728
|
-
const candidate = record$
|
|
6834
|
+
const candidate = record$6(field(data, String(index), budget), "INVALID_MODEL");
|
|
6729
6835
|
const candidateId = text$1(field(candidate, "id", budget), ACCOUNT_MODEL_CATALOG_LIMITS.maxIdLength, "INVALID_ID", budget);
|
|
6730
6836
|
if (!identifier.test(candidateId)) fail("INVALID_ID");
|
|
6731
6837
|
id = candidateId;
|
|
@@ -7157,7 +7263,7 @@ function createAccountModelSource(dependencies) {
|
|
|
7157
7263
|
}
|
|
7158
7264
|
//#endregion
|
|
7159
7265
|
//#region lib/types/agent-compaction.js
|
|
7160
|
-
function record$
|
|
7266
|
+
function record$5(value) {
|
|
7161
7267
|
return typeof value === "object" && value !== null;
|
|
7162
7268
|
}
|
|
7163
7269
|
/** Resolve the owning preset's service without reaching into Core's service registry. */
|
|
@@ -7165,7 +7271,7 @@ function agentCompaction(agent) {
|
|
|
7165
7271
|
if (typeof agent.ctx?.get !== "function") throw new LlmError("COPILOT_COMPACTION_AGENT_CONTEXT_UNAVAILABLE", "INVALID_REQUEST");
|
|
7166
7272
|
const presets = agent.ctx.get("agentPresets");
|
|
7167
7273
|
if (presets !== void 0) {
|
|
7168
|
-
if (!record$
|
|
7274
|
+
if (!record$5(presets) || typeof presets.composedPreset !== "function" || typeof presets.serviceFor !== "function") throw new LlmError("COPILOT_COMPACTION_PRESET_LOOKUP_UNAVAILABLE", "INVALID_REQUEST");
|
|
7169
7275
|
const preset = presets.composedPreset(agent.ctx);
|
|
7170
7276
|
if (preset !== void 0) {
|
|
7171
7277
|
if (typeof preset !== "string" || preset.trim().length === 0) throw new LlmError("COPILOT_COMPACTION_PRESET_LOOKUP_UNAVAILABLE", "INVALID_REQUEST");
|
|
@@ -7288,14 +7394,14 @@ function installCopilotCompactionPressure(ctx, callbacks) {
|
|
|
7288
7394
|
}
|
|
7289
7395
|
//#endregion
|
|
7290
7396
|
//#region lib/types/pre-step-pressure.js
|
|
7291
|
-
function record$
|
|
7397
|
+
function record$4(value) {
|
|
7292
7398
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7293
7399
|
}
|
|
7294
7400
|
function positive(value) {
|
|
7295
7401
|
return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
7296
7402
|
}
|
|
7297
7403
|
function isEngine(value) {
|
|
7298
|
-
return record$
|
|
7404
|
+
return record$4(value) && record$4(value.config) && typeof value.compactIfNeeded === "function";
|
|
7299
7405
|
}
|
|
7300
7406
|
/**
|
|
7301
7407
|
* Prevent a continuing, unchanged route's known pressure from becoming an
|
|
@@ -7316,12 +7422,12 @@ function installCopilotPreStepPressure(ctx, callbacks) {
|
|
|
7316
7422
|
const header = agent.session.requestHeader();
|
|
7317
7423
|
if (header?.config.provider !== "github-copilot-preview" || !isPluginPreviewProvider(ctx, header.config.provider)) return decision;
|
|
7318
7424
|
const projections = ctx.get("sessionProjections");
|
|
7319
|
-
if (!record$
|
|
7425
|
+
if (!record$4(projections) || typeof projections.stateOf !== "function") {
|
|
7320
7426
|
unavailable();
|
|
7321
7427
|
return decision;
|
|
7322
7428
|
}
|
|
7323
7429
|
const selection = projections.stateOf(agent.session, "modelSelection");
|
|
7324
|
-
if (!record$
|
|
7430
|
+
if (!record$4(selection) || !Object.hasOwn(selection, "pending")) {
|
|
7325
7431
|
unavailable();
|
|
7326
7432
|
return decision;
|
|
7327
7433
|
}
|
|
@@ -7343,20 +7449,20 @@ function installCopilotPreStepPressure(ctx, callbacks) {
|
|
|
7343
7449
|
unavailable();
|
|
7344
7450
|
return decision;
|
|
7345
7451
|
}
|
|
7346
|
-
const policy = Array.isArray(config.modelPolicies) ? config.modelPolicies.find((value) => record$
|
|
7347
|
-
const retries = record$
|
|
7452
|
+
const policy = Array.isArray(config.modelPolicies) ? config.modelPolicies.find((value) => record$4(value) && value.provider === header.config.provider && value.model === header.config.model) : void 0;
|
|
7453
|
+
const retries = record$4(policy) ? policy.maxOverflowRetries ?? config.maxOverflowRetries : config.maxOverflowRetries;
|
|
7348
7454
|
if (retries === 0) return decision;
|
|
7349
7455
|
if (!positive(retries)) {
|
|
7350
7456
|
unavailable();
|
|
7351
7457
|
return decision;
|
|
7352
7458
|
}
|
|
7353
7459
|
const meter = ctx.get("tokenMeter");
|
|
7354
|
-
if (!record$
|
|
7460
|
+
if (!record$4(meter) || typeof meter.measure !== "function") {
|
|
7355
7461
|
unavailable();
|
|
7356
7462
|
return decision;
|
|
7357
7463
|
}
|
|
7358
7464
|
const measured = meter.measure(agent.session);
|
|
7359
|
-
if (!record$
|
|
7465
|
+
if (!record$4(measured) || typeof measured.totalTokens !== "number" || !Number.isSafeInteger(measured.totalTokens) || measured.totalTokens < 0) {
|
|
7360
7466
|
unavailable();
|
|
7361
7467
|
return decision;
|
|
7362
7468
|
}
|
|
@@ -7474,17 +7580,17 @@ const TaskAssessmentSchema = z$1.object({
|
|
|
7474
7580
|
"insufficient-evidence"
|
|
7475
7581
|
])).max(7)
|
|
7476
7582
|
}).strict();
|
|
7477
|
-
function record$
|
|
7583
|
+
function record$3(value) {
|
|
7478
7584
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7479
7585
|
}
|
|
7480
7586
|
function text(message) {
|
|
7481
|
-
if (!record$
|
|
7482
|
-
return message.content.flatMap((block) => record$
|
|
7587
|
+
if (!record$3(message) || !Array.isArray(message.content)) return "";
|
|
7588
|
+
return message.content.flatMap((block) => record$3(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("\n");
|
|
7483
7589
|
}
|
|
7484
7590
|
function user(message) {
|
|
7485
|
-
if (!record$
|
|
7486
|
-
if (record$
|
|
7487
|
-
return message.role === "user" || record$
|
|
7591
|
+
if (!record$3(message)) return false;
|
|
7592
|
+
if (record$3(message.source) && message.source.kind === "model-selection") return false;
|
|
7593
|
+
return message.role === "user" || record$3(message.source) && message.source.kind === "user";
|
|
7488
7594
|
}
|
|
7489
7595
|
function difficult(current) {
|
|
7490
7596
|
return /\b(prove|proof|theorem|debug|investigate|diagnose)\b|证明|定理|调试|排查|根因|调查/iu.test(current);
|
|
@@ -7501,8 +7607,8 @@ function assessTaskLocally(messages) {
|
|
|
7501
7607
|
const last = messages.findLast(user);
|
|
7502
7608
|
const current = text(last).trim();
|
|
7503
7609
|
const history = messages.slice(0, last === void 0 ? 0 : messages.lastIndexOf(last));
|
|
7504
|
-
const hasWork = history.some((message) => record$
|
|
7505
|
-
const nonText = record$
|
|
7610
|
+
const hasWork = history.some((message) => record$3(message) && (message.role === "assistant" || message.role === "tool" || user(message) || record$3(message.source) && message.source.kind === "model"));
|
|
7611
|
+
const nonText = record$3(last) && Array.isArray(last.content) && last.content.some((block) => !record$3(block) || block.type !== "text");
|
|
7506
7612
|
if (!hasWork && !nonText && /^(hello|hi|hey|你好|您好|嗨)[!!。.\s]*$/iu.test(current)) return {
|
|
7507
7613
|
demand: "simple",
|
|
7508
7614
|
source: "local",
|
|
@@ -7544,7 +7650,7 @@ function assessTaskLocally(messages) {
|
|
|
7544
7650
|
/** Separate text-only projection for assessment; never mutates the chat request. */
|
|
7545
7651
|
function assessmentInput(messages) {
|
|
7546
7652
|
let omitted = false;
|
|
7547
|
-
const context = messages.filter((message) => !record$
|
|
7653
|
+
const context = messages.filter((message) => !record$3(message) || message.role !== "system" && message.role !== "developer" && !(record$3(message.source) && message.source.kind === "model-selection"));
|
|
7548
7654
|
const lastUser = context.findLastIndex(user);
|
|
7549
7655
|
const priorUser = context.slice(0, lastUser < 0 ? 0 : lastUser).findLastIndex(user);
|
|
7550
7656
|
const priority = [.../* @__PURE__ */ new Set([
|
|
@@ -7556,13 +7662,13 @@ function assessmentInput(messages) {
|
|
|
7556
7662
|
let length = 0;
|
|
7557
7663
|
for (const index of priority) {
|
|
7558
7664
|
const message = context[index];
|
|
7559
|
-
if (!record$
|
|
7665
|
+
if (!record$3(message)) {
|
|
7560
7666
|
omitted = true;
|
|
7561
7667
|
continue;
|
|
7562
7668
|
}
|
|
7563
7669
|
if (!Array.isArray(message.content)) omitted = true;
|
|
7564
7670
|
const content = text(message);
|
|
7565
|
-
if (Array.isArray(message.content) && message.content.some((block) => !record$
|
|
7671
|
+
if (Array.isArray(message.content) && message.content.some((block) => !record$3(block) || block.type !== "text")) omitted = true;
|
|
7566
7672
|
if (content.length > 1600) omitted = true;
|
|
7567
7673
|
const role = typeof message.role === "string" && [
|
|
7568
7674
|
"user",
|
|
@@ -7694,14 +7800,14 @@ var AutoModelRoutingError = class extends Error {
|
|
|
7694
7800
|
this.name = "AutoModelRoutingError";
|
|
7695
7801
|
}
|
|
7696
7802
|
};
|
|
7697
|
-
function record$
|
|
7803
|
+
function record$2(value) {
|
|
7698
7804
|
return typeof value === "object" && value !== null;
|
|
7699
7805
|
}
|
|
7700
7806
|
function userMessage(value) {
|
|
7701
|
-
if (!record$
|
|
7702
|
-
if (record$
|
|
7807
|
+
if (!record$2(value)) return false;
|
|
7808
|
+
if (record$2(value.source) && value.source.kind === "model-selection") return false;
|
|
7703
7809
|
if (value.role === "user") return true;
|
|
7704
|
-
return record$
|
|
7810
|
+
return record$2(value.source) && value.source.kind === "user";
|
|
7705
7811
|
}
|
|
7706
7812
|
function latestUserContent(messages) {
|
|
7707
7813
|
for (let index = messages.length - 1; index >= 0; index--) {
|
|
@@ -7712,9 +7818,9 @@ function latestUserContent(messages) {
|
|
|
7712
7818
|
}
|
|
7713
7819
|
function classifyAutoModelTurn(messages) {
|
|
7714
7820
|
let text = "";
|
|
7715
|
-
const requiresImage = messages.some((message) => record$
|
|
7821
|
+
const requiresImage = messages.some((message) => record$2(message) && Array.isArray(message.content) && message.content.some((block) => record$2(block) && block.type === "image" && block.offloaded !== true));
|
|
7716
7822
|
for (const block of latestUserContent(messages)) {
|
|
7717
|
-
if (!record$
|
|
7823
|
+
if (!record$2(block)) continue;
|
|
7718
7824
|
if (block.type === "text" && typeof block.text === "string") text += `${block.text}\n`;
|
|
7719
7825
|
}
|
|
7720
7826
|
const codeFenceCount = text.match(/```/gu)?.length ?? 0;
|
|
@@ -7764,7 +7870,7 @@ function resolveSeed(messages, context) {
|
|
|
7764
7870
|
if (typeof context?.seed === "string" && context.seed.length > 0) return fnv1a(context.seed);
|
|
7765
7871
|
if (context?.sessionId !== void 0) return fnv1a(`${context.sessionId}:${context.turn ?? 1}`);
|
|
7766
7872
|
let text = "";
|
|
7767
|
-
for (const block of latestUserContent(messages)) if (record$
|
|
7873
|
+
for (const block of latestUserContent(messages)) if (record$2(block) && typeof block.text === "string") text += block.text;
|
|
7768
7874
|
return fnv1a(text || "default-auto-seed");
|
|
7769
7875
|
}
|
|
7770
7876
|
function targetCategory(assessment, preference) {
|
|
@@ -8168,6 +8274,60 @@ function resolveParentModel(child, bindings, lookup, followAll = false) {
|
|
|
8168
8274
|
}
|
|
8169
8275
|
}
|
|
8170
8276
|
//#endregion
|
|
8277
|
+
//#region lib/types/auto-model-intent.js
|
|
8278
|
+
const AUTO_MODEL_INTENT_PROJECTION = "githubCopilotAutoModelIntent";
|
|
8279
|
+
const count = z$1.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
|
|
8280
|
+
const selectionSchema = z$1.object({
|
|
8281
|
+
provider: z$1.string().min(1),
|
|
8282
|
+
model: z$1.string().min(1)
|
|
8283
|
+
}).strict();
|
|
8284
|
+
const AutoModelIntentSchema = z$1.object({
|
|
8285
|
+
inherited: count,
|
|
8286
|
+
selection: selectionSchema.nullable(),
|
|
8287
|
+
blocked: z$1.boolean()
|
|
8288
|
+
}).strict();
|
|
8289
|
+
function record$1(value) {
|
|
8290
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8291
|
+
}
|
|
8292
|
+
function initialAutoModelIntent(inherited = 0) {
|
|
8293
|
+
return {
|
|
8294
|
+
inherited,
|
|
8295
|
+
selection: null,
|
|
8296
|
+
blocked: false
|
|
8297
|
+
};
|
|
8298
|
+
}
|
|
8299
|
+
/** Request headers describe execution, not replacement of an explicit picker intent. */
|
|
8300
|
+
function foldAutoModelIntent(state, event) {
|
|
8301
|
+
if (!record$1(event) || event.type !== "model/selection") return state;
|
|
8302
|
+
if (!Number.isSafeInteger(event.seq) || Number(event.seq) < 0) return {
|
|
8303
|
+
...state,
|
|
8304
|
+
selection: null,
|
|
8305
|
+
blocked: true
|
|
8306
|
+
};
|
|
8307
|
+
if (Number(event.seq) < state.inherited) return state;
|
|
8308
|
+
const data = event.data;
|
|
8309
|
+
const parsed = selectionSchema.safeParse(record$1(data) ? {
|
|
8310
|
+
provider: data.provider,
|
|
8311
|
+
model: data.model
|
|
8312
|
+
} : data);
|
|
8313
|
+
return parsed.success ? {
|
|
8314
|
+
...state,
|
|
8315
|
+
selection: parsed.data,
|
|
8316
|
+
blocked: false
|
|
8317
|
+
} : {
|
|
8318
|
+
...state,
|
|
8319
|
+
selection: null,
|
|
8320
|
+
blocked: true
|
|
8321
|
+
};
|
|
8322
|
+
}
|
|
8323
|
+
const autoModelIntentDefinition = {
|
|
8324
|
+
key: AUTO_MODEL_INTENT_PROJECTION,
|
|
8325
|
+
stateVersion: 1,
|
|
8326
|
+
stateSchema: AutoModelIntentSchema,
|
|
8327
|
+
init: (_header, inherited = 0) => initialAutoModelIntent(inherited),
|
|
8328
|
+
apply: foldAutoModelIntent
|
|
8329
|
+
};
|
|
8330
|
+
//#endregion
|
|
8171
8331
|
//#region lib/types/auto-model-host.js
|
|
8172
8332
|
function failure$1(code, kind = "INVALID_REQUEST") {
|
|
8173
8333
|
return new LlmError(code, kind);
|
|
@@ -8226,13 +8386,6 @@ function buildRoutingContext(ctx, agent, turn, messages, budgetPolicyConfig) {
|
|
|
8226
8386
|
previousModelId: requestHeader?.config.provider === "github-copilot-preview" ? requestHeader.config.model : void 0
|
|
8227
8387
|
};
|
|
8228
8388
|
}
|
|
8229
|
-
function pendingAuto(ctx, agent) {
|
|
8230
|
-
const candidate = ctx.get("sessionProjections");
|
|
8231
|
-
if (!record(candidate) || typeof candidate.stateOf !== "function") return void 0;
|
|
8232
|
-
const state = candidate.stateOf(agent.session, "modelSelection");
|
|
8233
|
-
if (!record(state) || !record(state.pending) || state.pending.provider !== "github-copilot-preview") return void 0;
|
|
8234
|
-
return typeof state.pending.model === "string" && autoModelPreference(state.pending.model) !== void 0 ? state.pending.model : void 0;
|
|
8235
|
-
}
|
|
8236
8389
|
function modelSelectionNotice(value) {
|
|
8237
8390
|
return record(value) && record(value.source) && value.source.kind === "model-selection";
|
|
8238
8391
|
}
|
|
@@ -8265,6 +8418,31 @@ function installAutoModelRouting(ctx, dependencies) {
|
|
|
8265
8418
|
const pendingDecisions = /* @__PURE__ */ new WeakMap();
|
|
8266
8419
|
const activeDecisions = /* @__PURE__ */ new Set();
|
|
8267
8420
|
let active = true;
|
|
8421
|
+
let removeIntentProjection;
|
|
8422
|
+
const retainedAuto = (registry, session) => {
|
|
8423
|
+
if (typeof registry.register !== "function" || typeof registry.stateOf !== "function") throw failure$1("COPILOT_AUTO_INTENT_PROJECTIONS_UNAVAILABLE");
|
|
8424
|
+
if (!removeIntentProjection) {
|
|
8425
|
+
const remove = registry.register(autoModelIntentDefinition);
|
|
8426
|
+
if (typeof remove !== "function") throw failure$1("COPILOT_AUTO_INTENT_DISPOSER_UNAVAILABLE");
|
|
8427
|
+
removeIntentProjection = () => {
|
|
8428
|
+
remove();
|
|
8429
|
+
};
|
|
8430
|
+
}
|
|
8431
|
+
const intent = AutoModelIntentSchema.safeParse(registry.stateOf(session, AUTO_MODEL_INTENT_PROJECTION));
|
|
8432
|
+
if (!intent.success || intent.data.blocked) throw failure$1("COPILOT_AUTO_INTENT_UNAVAILABLE");
|
|
8433
|
+
const selection = intent.data.selection;
|
|
8434
|
+
return selection?.provider === "github-copilot-preview" && autoModelPreference(selection.model) !== void 0 ? selection.model : void 0;
|
|
8435
|
+
};
|
|
8436
|
+
const pendingAuto = (agent) => {
|
|
8437
|
+
const registry = ctx.get("sessionProjections");
|
|
8438
|
+
if (!record(registry) || typeof registry.stateOf !== "function") return void 0;
|
|
8439
|
+
const native = registry.stateOf(agent.session, "modelSelection");
|
|
8440
|
+
if (!record(native)) return void 0;
|
|
8441
|
+
const selection = native.pending;
|
|
8442
|
+
if (selection === null && agent.session.requestHeader()?.config.provider === "github-copilot-preview") return retainedAuto(registry, agent.session);
|
|
8443
|
+
if (!record(selection) || selection.provider !== "github-copilot-preview") return void 0;
|
|
8444
|
+
return typeof selection.model === "string" && autoModelPreference(selection.model) !== void 0 ? selection.model : void 0;
|
|
8445
|
+
};
|
|
8268
8446
|
const decisionFor = (agent, turn, messages, preference, signal) => {
|
|
8269
8447
|
if (!active || signal.aborted) return Promise.reject(signal.reason ?? failure$1("COPILOT_AUTO_DISPOSED", "ABORTED"));
|
|
8270
8448
|
const completed = routed.get(agent);
|
|
@@ -8354,13 +8532,18 @@ function installAutoModelRouting(ctx, dependencies) {
|
|
|
8354
8532
|
const pending = selection.pending === null ? null : followSelection(selection.pending);
|
|
8355
8533
|
if (pending === void 0) throw failure$1("COPILOT_PARENT_MODEL_SELECTION_UNAVAILABLE");
|
|
8356
8534
|
const header = session.requestHeader();
|
|
8535
|
+
const recorded = record(header) ? followSelection(header.config) : void 0;
|
|
8536
|
+
const retained = pending === null && recorded?.provider === "github-copilot-preview" ? retainedAuto(projections, session) : void 0;
|
|
8357
8537
|
return {
|
|
8358
8538
|
id: session.id,
|
|
8359
8539
|
parentId: typeof session.header.parentSession === "string" ? session.header.parentSession : void 0,
|
|
8360
8540
|
origin: typeof session.header.origin === "string" ? session.header.origin : void 0,
|
|
8361
8541
|
state: parsed.data,
|
|
8362
8542
|
pending,
|
|
8363
|
-
recorded:
|
|
8543
|
+
recorded: retained === void 0 ? recorded : {
|
|
8544
|
+
provider: GITHUB_COPILOT_PREVIEW_PROVIDER_ID,
|
|
8545
|
+
model: retained
|
|
8546
|
+
}
|
|
8364
8547
|
};
|
|
8365
8548
|
};
|
|
8366
8549
|
const child = readSubject(agent);
|
|
@@ -8391,7 +8574,7 @@ function installAutoModelRouting(ctx, dependencies) {
|
|
|
8391
8574
|
const effectiveAuto = (agent) => {
|
|
8392
8575
|
const inherited = followIntent(agent);
|
|
8393
8576
|
if (inherited !== void 0) return autoModelPreference(inherited.model) !== void 0 ? inherited.model : void 0;
|
|
8394
|
-
return pendingAuto(
|
|
8577
|
+
return pendingAuto(agent);
|
|
8395
8578
|
};
|
|
8396
8579
|
const installAgent = (agent) => {
|
|
8397
8580
|
if (agentDisposers.has(agent)) return;
|
|
@@ -8406,7 +8589,7 @@ function installAutoModelRouting(ctx, dependencies) {
|
|
|
8406
8589
|
model: inherited.model
|
|
8407
8590
|
}
|
|
8408
8591
|
};
|
|
8409
|
-
const pending = pendingAuto(
|
|
8592
|
+
const pending = pendingAuto(agent);
|
|
8410
8593
|
if (pending === void 0) return assembled;
|
|
8411
8594
|
return {
|
|
8412
8595
|
...assembled,
|
|
@@ -8424,6 +8607,15 @@ function installAutoModelRouting(ctx, dependencies) {
|
|
|
8424
8607
|
turn,
|
|
8425
8608
|
messages: entered
|
|
8426
8609
|
});
|
|
8610
|
+
const admitted = routed.get(agent);
|
|
8611
|
+
if (result.kind === "enter" && !signal.aborted && admitted?.turn === turn && admitted.admitted !== void 0) {
|
|
8612
|
+
const filtered = result.messages.filter((message) => !modelSelectionNotice(message));
|
|
8613
|
+
const notice = actualNotice(agent, admitted.decision.model.id);
|
|
8614
|
+
return {
|
|
8615
|
+
...result,
|
|
8616
|
+
messages: notice === void 0 ? filtered : [...filtered, notice]
|
|
8617
|
+
};
|
|
8618
|
+
}
|
|
8427
8619
|
const pending = effectiveAuto(agent);
|
|
8428
8620
|
const preference = pending === void 0 ? void 0 : autoModelPreference(pending);
|
|
8429
8621
|
const inherited = followIntent(agent);
|
|
@@ -8473,6 +8665,15 @@ function installAutoModelRouting(ctx, dependencies) {
|
|
|
8473
8665
|
const removeRequest = ctx.on("agent/request", async ({ agent, turn, signal }, next) => {
|
|
8474
8666
|
installAgent(agent);
|
|
8475
8667
|
const native = await next();
|
|
8668
|
+
const admitted = routed.get(agent);
|
|
8669
|
+
if (admitted?.turn === turn && admitted.admitted !== void 0) {
|
|
8670
|
+
if (!signal.aborted) dependencies.admitModel?.(agent, turn, admitted.decision.model.id, signal);
|
|
8671
|
+
const { reasoningEffort: _changedEffort, ...current } = native;
|
|
8672
|
+
return {
|
|
8673
|
+
...current,
|
|
8674
|
+
...admitted.admitted
|
|
8675
|
+
};
|
|
8676
|
+
}
|
|
8476
8677
|
const inherited = followIntent(agent);
|
|
8477
8678
|
const { reasoningEffort: _nativeEffort, ...withoutEffort } = native;
|
|
8478
8679
|
const resolved = inherited === void 0 ? native : {
|
|
@@ -8518,6 +8719,11 @@ function installAutoModelRouting(ctx, dependencies) {
|
|
|
8518
8719
|
}
|
|
8519
8720
|
if (!signal.aborted) {
|
|
8520
8721
|
dependencies.admitModel?.(agent, turn, state.decision.model.id, signal);
|
|
8722
|
+
state.admitted = {
|
|
8723
|
+
provider: resolved.provider,
|
|
8724
|
+
model: state.decision.model.id,
|
|
8725
|
+
...resolved.reasoningEffort === void 0 ? {} : { reasoningEffort: resolved.reasoningEffort }
|
|
8726
|
+
};
|
|
8521
8727
|
selections.record(agent, turn, {
|
|
8522
8728
|
mode: "auto",
|
|
8523
8729
|
preference: state.decision.preference,
|
|
@@ -8540,6 +8746,7 @@ function installAutoModelRouting(ctx, dependencies) {
|
|
|
8540
8746
|
removeDisposed();
|
|
8541
8747
|
removeRequest();
|
|
8542
8748
|
removeFollowProjection?.();
|
|
8749
|
+
removeIntentProjection?.();
|
|
8543
8750
|
for (const dispose of activeDisposers) dispose();
|
|
8544
8751
|
activeDisposers.clear();
|
|
8545
8752
|
selections.clear();
|