dsh-github-copilot 0.4.2-alpha.12 → 0.4.2-alpha.13
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 +9 -4
- package/CHANGELOG.md +12 -1
- package/README.md +9 -9
- package/README.zh.md +11 -8
- package/deployment-baseline.json +5 -3
- package/docs/auto-high-cost.md +68 -8
- package/docs/auto-iteration-review.json +6 -6
- package/docs/auto-task-routing.md +14 -9
- package/docs/automatic-model-routing.md +3 -1
- package/lib/client.js +46 -7
- package/lib/client.js.map +1 -1
- package/lib/diagnostics-analysis.js +1 -1
- package/lib/{diagnostics-types-DEo3UrOO.js → diagnostics-types-D5T4fto9.js} +54 -11
- package/lib/index.js +13 -28
- package/lib/manual-compaction-recovery.js +1 -1
- package/lib/remote.js +41 -3
- package/lib/types/auto-allocation-evidence.d.ts +1 -0
- package/lib/types/auto-allocation.d.ts +20 -3
- package/lib/types/auto-model-routing.d.ts +2 -1
- package/lib/types/turn-selection-host.d.ts +1 -1
- package/lib/types/turn-selection.d.ts +14 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as DiagnosticsPendingSchema, c as DiagnosticsViewSchema, n as DIAGNOSTICS_OPERATIONS, r as DIAGNOSTICS_REASONS, s as DiagnosticsSnapshotSchema } from "./diagnostics-types-
|
|
1
|
+
import { a as DiagnosticsPendingSchema, c as DiagnosticsViewSchema, n as DIAGNOSTICS_OPERATIONS, r as DIAGNOSTICS_REASONS, s as DiagnosticsSnapshotSchema } from "./diagnostics-types-D5T4fto9.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
//#region lib/types/diagnostics-analysis.js
|
|
4
4
|
const RETENTION_MS = 12096e5;
|
|
@@ -51,15 +51,49 @@ function excludedModelSet(value) {
|
|
|
51
51
|
const AUTO_ALLOCATION_POLICIES = [
|
|
52
52
|
"high-cost-v1",
|
|
53
53
|
"high-cost-v2",
|
|
54
|
-
"high-cost-v3"
|
|
54
|
+
"high-cost-v3",
|
|
55
|
+
"high-cost-v4"
|
|
55
56
|
];
|
|
56
|
-
const AUTO_ALLOCATION_POLICY = "high-cost-
|
|
57
|
+
const AUTO_ALLOCATION_POLICY = "high-cost-v4";
|
|
58
|
+
const categories = [
|
|
59
|
+
"powerful",
|
|
60
|
+
"versatile",
|
|
61
|
+
"lightweight",
|
|
62
|
+
"unknown"
|
|
63
|
+
];
|
|
64
|
+
function autoCategoryWeight(category, target) {
|
|
65
|
+
if (category === "unknown") return .02;
|
|
66
|
+
return [
|
|
67
|
+
1,
|
|
68
|
+
.25,
|
|
69
|
+
.05
|
|
70
|
+
][(target === "powerful" ? [
|
|
71
|
+
"powerful",
|
|
72
|
+
"versatile",
|
|
73
|
+
"lightweight"
|
|
74
|
+
] : target === "lightweight" ? [
|
|
75
|
+
"lightweight",
|
|
76
|
+
"versatile",
|
|
77
|
+
"powerful"
|
|
78
|
+
] : [
|
|
79
|
+
"versatile",
|
|
80
|
+
"powerful",
|
|
81
|
+
"lightweight"
|
|
82
|
+
]).indexOf(category)];
|
|
83
|
+
}
|
|
57
84
|
const AutoAllocationSchema = z.object({
|
|
58
85
|
policyVersion: z.enum(AUTO_ALLOCATION_POLICIES),
|
|
86
|
+
targetCategory: z.enum([
|
|
87
|
+
"powerful",
|
|
88
|
+
"versatile",
|
|
89
|
+
"lightweight"
|
|
90
|
+
]).optional(),
|
|
59
91
|
deferredHighCostCount: z.number().int().min(0).max(511).optional(),
|
|
60
92
|
selectedModelId: z.string().min(1).max(512),
|
|
61
93
|
candidates: z.array(z.object({
|
|
62
94
|
modelId: z.string().min(1).max(512),
|
|
95
|
+
category: z.enum(categories).optional(),
|
|
96
|
+
categoryWeight: z.number().positive().max(1).optional(),
|
|
63
97
|
highCost: z.boolean(),
|
|
64
98
|
previous: z.boolean(),
|
|
65
99
|
weight: z.number().positive().max(1.5),
|
|
@@ -68,8 +102,11 @@ const AutoAllocationSchema = z.object({
|
|
|
68
102
|
}).strict().refine((value) => {
|
|
69
103
|
const total = value.candidates.reduce((sum, row) => sum + row.weight, 0);
|
|
70
104
|
const legacy = value.policyVersion === "high-cost-v1";
|
|
71
|
-
const
|
|
72
|
-
|
|
105
|
+
const soft = value.policyVersion === "high-cost-v4";
|
|
106
|
+
const decay = value.policyVersion === "high-cost-v3" || soft;
|
|
107
|
+
const categoryValid = soft ? value.targetCategory !== void 0 && value.candidates.every((row) => row.category !== void 0 && row.categoryWeight === autoCategoryWeight(row.category, value.targetCategory)) : value.targetCategory === void 0 && value.candidates.every((row) => row.category === void 0 && row.categoryWeight === void 0);
|
|
108
|
+
const tierValid = legacy || decay ? value.deferredHighCostCount === void 0 : value.deferredHighCostCount !== void 0 && value.candidates.length + value.deferredHighCostCount <= 512 && value.candidates.every((row) => row.highCost === value.candidates[0].highCost) && (!value.candidates[0].highCost || value.deferredHighCostCount === 0);
|
|
109
|
+
return categoryValid && tierValid && new Set(value.candidates.map((row) => row.modelId)).size === value.candidates.length && value.candidates.some((row) => row.modelId === value.selectedModelId) && value.candidates.filter((row) => row.previous).length <= 1 && value.candidates.every((row) => row.weight === (decay && row.highCost && row.previous ? 2 : (row.highCost ? 20 : 100) * (row.previous && (legacy || !row.highCost) ? 1.5 : 1)) * (soft ? Math.round(row.categoryWeight * 100) : 100) / 1e4 && Math.abs(row.expectedShare - row.weight / total) <= 1e-12);
|
|
73
110
|
}, { message: "Invalid allocation policy evidence" });
|
|
74
111
|
function normalizeHighCostModelIds(value) {
|
|
75
112
|
try {
|
|
@@ -80,15 +117,19 @@ function normalizeHighCostModelIds(value) {
|
|
|
80
117
|
}
|
|
81
118
|
}
|
|
82
119
|
/** Integer policy units avoid cumulative decimal drift; avalanche sequential turn seeds. */
|
|
83
|
-
function allocateAutoModel(pool, highCostModelIds, previousModelId, seed) {
|
|
120
|
+
function allocateAutoModel(pool, highCostModelIds, previousModelId, seed, targetCategory = "powerful") {
|
|
84
121
|
if (!Number.isSafeInteger(seed) || pool.length === 0 || pool.length > 512 || normalizeExcludedModelIds(pool.map((model) => model.id)).length !== pool.length) throw new Error("COPILOT_AUTO_ALLOCATION_INVALID");
|
|
85
122
|
const marked = new Set(normalizeHighCostModelIds(highCostModelIds));
|
|
86
123
|
const rows = pool.map((model) => {
|
|
87
124
|
const highCost = marked.has(model.id);
|
|
88
125
|
const previous = model.id === previousModelId;
|
|
89
|
-
const
|
|
126
|
+
const category = model.category ?? "unknown";
|
|
127
|
+
const categoryWeight = autoCategoryWeight(category, targetCategory);
|
|
128
|
+
const units = (highCost ? previous ? 2 : 20 : previous ? 150 : 100) * Math.round(categoryWeight * 100);
|
|
90
129
|
return {
|
|
91
130
|
modelId: model.id,
|
|
131
|
+
category,
|
|
132
|
+
categoryWeight,
|
|
92
133
|
highCost,
|
|
93
134
|
previous,
|
|
94
135
|
units
|
|
@@ -106,10 +147,11 @@ function allocateAutoModel(pool, highCostModelIds, previousModelId, seed) {
|
|
|
106
147
|
});
|
|
107
148
|
return Object.freeze({
|
|
108
149
|
policyVersion: AUTO_ALLOCATION_POLICY,
|
|
150
|
+
targetCategory,
|
|
109
151
|
selectedModelId: selected.modelId,
|
|
110
152
|
candidates: Object.freeze(rows.map(({ units, ...row }) => Object.freeze({
|
|
111
153
|
...row,
|
|
112
|
-
weight: units /
|
|
154
|
+
weight: units / 1e4,
|
|
113
155
|
expectedShare: units / total
|
|
114
156
|
})))
|
|
115
157
|
});
|
|
@@ -256,7 +298,7 @@ var AutoAllocationDiagnosticsCollector = class {
|
|
|
256
298
|
this.data.observationStart = this.data.observationStart === null ? day : Math.min(this.data.observationStart, day);
|
|
257
299
|
this.data.observationEnd = this.data.observationEnd === null ? day : Math.max(this.data.observationEnd, day);
|
|
258
300
|
if (explanation.method === "no-fit") {
|
|
259
|
-
const row = this.data.noFitRows.find((item) => item.day === day && item.version === this.version && item.policyVersion === "high-cost-
|
|
301
|
+
const row = this.data.noFitRows.find((item) => item.day === day && item.version === this.version && item.policyVersion === "high-cost-v4" && item.targetCategory === explanation.targetCategory && item.category === explanation.selectedCategory && item.demand === explanation.assessment.demand && item.assessmentSource === explanation.assessment.source && item.assessmentOutcome === outcome);
|
|
260
302
|
if (row) row.decisions = this.add(row.decisions, 1);
|
|
261
303
|
else if (this.data.rows.length + this.data.noFitRows.length < 1024) this.data.noFitRows.push({
|
|
262
304
|
day,
|
|
@@ -279,14 +321,15 @@ var AutoAllocationDiagnosticsCollector = class {
|
|
|
279
321
|
}
|
|
280
322
|
if (explanation.method !== "weighted-distribution" && explanation.method !== "only-candidate") return;
|
|
281
323
|
const parsed = AutoAllocationSchema.safeParse(explanation.allocation);
|
|
282
|
-
if (!parsed.success || parsed.data.policyVersion !== "high-cost-
|
|
324
|
+
if (!parsed.success || parsed.data.policyVersion !== "high-cost-v4") {
|
|
283
325
|
this.data.dropped = this.add(this.data.dropped, 1);
|
|
284
326
|
this.changed();
|
|
285
327
|
return;
|
|
286
328
|
}
|
|
287
329
|
const allocation = parsed.data;
|
|
288
330
|
for (const candidate of allocation.candidates) {
|
|
289
|
-
const
|
|
331
|
+
const category = candidate.category ?? explanation.selectedCategory;
|
|
332
|
+
const row = this.data.rows.find((item) => item.day === day && item.version === this.version && item.policyVersion === allocation.policyVersion && item.modelId === candidate.modelId && item.targetCategory === explanation.targetCategory && item.category === category && item.demand === explanation.assessment.demand && item.assessmentSource === explanation.assessment.source && item.assessmentOutcome === outcome && item.method === explanation.method && item.fallback === explanation.fallback && item.highCost === candidate.highCost && item.previous === candidate.previous && item.weight === candidate.weight);
|
|
290
333
|
if (row) {
|
|
291
334
|
row.opportunities = this.add(row.opportunities, 1);
|
|
292
335
|
row.expectedSelections = Math.min(Number.MAX_SAFE_INTEGER, row.expectedSelections + candidate.expectedShare);
|
|
@@ -297,7 +340,7 @@ var AutoAllocationDiagnosticsCollector = class {
|
|
|
297
340
|
policyVersion: allocation.policyVersion,
|
|
298
341
|
modelId: candidate.modelId,
|
|
299
342
|
targetCategory: explanation.targetCategory,
|
|
300
|
-
category
|
|
343
|
+
category,
|
|
301
344
|
demand: explanation.assessment.demand,
|
|
302
345
|
assessmentSource: explanation.assessment.source,
|
|
303
346
|
method: explanation.method,
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as GITHUB_COPILOT_PREVIEW_PROVIDER_ID, i as GITHUB_COPILOT_CREDENTIAL_KEY, n as GITHUB_COPILOT_AUTO_INTELLIGENCE_MODEL_ID, o as GITHUB_COPILOT_PROVIDER_ID, r as GITHUB_COPILOT_AUTO_MODEL_ID, s as autoModelPreference, t as GITHUB_COPILOT_AUTO_EFFICIENCY_MODEL_ID } from "./copilot-identity-DRZY_d2X.js";
|
|
2
|
-
import { C as excludedModelSet, S as ModelExclusionTurns, _ as AUTO_ALLOCATION_POLICIES, b as allocateAutoModel, c as DiagnosticsViewSchema, d as diagnosticsReason, f as CredentialChangeSchema, g as emptyAutoAllocationDiagnostics, h as AutoAllocationDiagnosticsCollector, i as DIAGNOSTICS_RETENTION_MS, l as diagnosticsBucket, m as RequestDiagnosticSchema, o as DiagnosticsRowSchema, p as REQUEST_DIAGNOSTICS_RETENTION_MS, s as DiagnosticsSnapshotSchema, u as diagnosticsOutcome, v as AUTO_ALLOCATION_POLICY, w as normalizeExcludedModelIds, x as normalizeHighCostModelIds, y as AutoAllocationSchema } from "./diagnostics-types-
|
|
2
|
+
import { C as excludedModelSet, S as ModelExclusionTurns, _ as AUTO_ALLOCATION_POLICIES, b as allocateAutoModel, c as DiagnosticsViewSchema, d as diagnosticsReason, f as CredentialChangeSchema, g as emptyAutoAllocationDiagnostics, h as AutoAllocationDiagnosticsCollector, i as DIAGNOSTICS_RETENTION_MS, l as diagnosticsBucket, m as RequestDiagnosticSchema, o as DiagnosticsRowSchema, p as REQUEST_DIAGNOSTICS_RETENTION_MS, s as DiagnosticsSnapshotSchema, u as diagnosticsOutcome, v as AUTO_ALLOCATION_POLICY, w as normalizeExcludedModelIds, x as normalizeHighCostModelIds, y as AutoAllocationSchema } from "./diagnostics-types-D5T4fto9.js";
|
|
3
3
|
import { C as providerErrorMessage, D as onSettingsNamespaceUpdated, E as readCopilotCatalog, O as readConfigValue, S as isAbortError, T as isPluginPreviewProvider, _ as sameCandidates, a as COPILOT_HOSTED_SEARCH_PROVIDER_ID, b as currentSearchSelection, c as applyRequestAuth, d as ANTHROPIC_WEB_SEARCH_TOOL_TYPE, f as GITHUB_COPILOT_CREDENTIAL_KEY$1, g as candidatesForRoute, h as WEB_SEARCH_TOOL_TYPE, i as describeSearchBackend, k as readSettingsNamespace, l as normalizeRequestAuth, m as SearchPlan, n as routeSessionSearch, o as GITHUB_COPILOT_HOSTED_SEARCH_PROVIDER_ID, p as RESPONSES_WEB_SEARCH_TOOL_TYPE, r as DescribedSearchFallbackError, s as createTraditionalSearchProvider, t as isCopilotSearchSelection, u as providerRequestHeaders, v as currentChatRoute, w as readBounded, x as abortable$1, y as currentSearchInitiator } from "./search-routing-CV2hs8as.js";
|
|
4
4
|
import { a as selectCompactionReasoning, i as resolveRequestBudgetPolicy, n as assessRequestBudget, r as calculateRequestBudget, t as DEFAULT_REQUEST_BUDGET_POLICY } from "./request-budget-DLY_aRq0.js";
|
|
5
5
|
import { Remote, RemoteError, TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
|
|
@@ -581,7 +581,7 @@ const result$1 = strictRemoteCodec("dsh-github-copilot#DiagnosticsView", Diagnos
|
|
|
581
581
|
var package_default = {
|
|
582
582
|
name: "dsh-github-copilot",
|
|
583
583
|
description: "DSH companion for GitHub Copilot sign-in, account-aware model profiles, tool compatibility, and provider-hosted search.",
|
|
584
|
-
version: "0.4.2-alpha.
|
|
584
|
+
version: "0.4.2-alpha.13",
|
|
585
585
|
releaseNotes: "CHANGELOG.md",
|
|
586
586
|
publishConfig: {
|
|
587
587
|
"access": "public",
|
|
@@ -12343,7 +12343,7 @@ function targetCategory(assessment, preference) {
|
|
|
12343
12343
|
}
|
|
12344
12344
|
/**
|
|
12345
12345
|
* Filter input headroom before task-aware supplier categories.
|
|
12346
|
-
* Apply
|
|
12346
|
+
* Apply soft category, cost and recency weights across every fitting candidate.
|
|
12347
12347
|
* Preserves Core compaction ownership if no candidate currently fits.
|
|
12348
12348
|
*/
|
|
12349
12349
|
function selectAutoModel(models, messages, preference = "balance", context) {
|
|
@@ -12362,38 +12362,21 @@ function selectAutoModel(models, messages, preference = "balance", context) {
|
|
|
12362
12362
|
const seed = resolveSeed(messages, context);
|
|
12363
12363
|
const assessment = context?.assessment ?? assessTaskLocally(messages);
|
|
12364
12364
|
const target = targetCategory(assessment, preference);
|
|
12365
|
-
const order = target === "powerful" ? [
|
|
12366
|
-
"powerful",
|
|
12367
|
-
"versatile",
|
|
12368
|
-
"lightweight",
|
|
12369
|
-
"unknown"
|
|
12370
|
-
] : target === "lightweight" ? [
|
|
12371
|
-
"lightweight",
|
|
12372
|
-
"versatile",
|
|
12373
|
-
"powerful",
|
|
12374
|
-
"unknown"
|
|
12375
|
-
] : [
|
|
12376
|
-
"versatile",
|
|
12377
|
-
"powerful",
|
|
12378
|
-
"lightweight",
|
|
12379
|
-
"unknown"
|
|
12380
|
-
];
|
|
12381
12365
|
let selectedModel;
|
|
12382
12366
|
let inputFitDiagnostic;
|
|
12383
12367
|
let selectedInputBudget;
|
|
12384
12368
|
let explanation;
|
|
12385
12369
|
if (fitting.length > 0) {
|
|
12386
|
-
const
|
|
12387
|
-
|
|
12388
|
-
const allocation = allocateAutoModel(pool, context?.highCostModelIds, context?.previousModelId, seed);
|
|
12389
|
-
selectedModel = pool.find((model) => model.id === allocation.selectedModelId);
|
|
12370
|
+
const allocation = allocateAutoModel(fitting, context?.highCostModelIds, context?.previousModelId, seed, target);
|
|
12371
|
+
selectedModel = fitting.find((model) => model.id === allocation.selectedModelId);
|
|
12390
12372
|
explanation = {
|
|
12373
|
+
allocationPolicy: "high-cost-v4",
|
|
12391
12374
|
assessment,
|
|
12392
12375
|
targetCategory: target,
|
|
12393
|
-
selectedCategory,
|
|
12376
|
+
selectedCategory: selectedModel.category ?? "unknown",
|
|
12394
12377
|
categoryCandidateCount: allocation.candidates.length,
|
|
12395
12378
|
method: allocation.candidates.length === 1 ? "only-candidate" : "weighted-distribution",
|
|
12396
|
-
fallback:
|
|
12379
|
+
fallback: !fitting.some((model) => model.category === target),
|
|
12397
12380
|
...context?.collectAllocationEvidence === false ? {} : { allocation }
|
|
12398
12381
|
};
|
|
12399
12382
|
selectedInputBudget = candidateInputLimit(selectedModel, requestedMaxTokens, policy);
|
|
@@ -12481,7 +12464,7 @@ function summarizeAutoAllocations(explanations, window) {
|
|
|
12481
12464
|
let noFitDecisions = 0;
|
|
12482
12465
|
let retainedDecisions = 0;
|
|
12483
12466
|
let rowsTruncated = false;
|
|
12484
|
-
const policyVersion = explanations.some((row) => row.allocation?.policyVersion === "high-cost-
|
|
12467
|
+
const policyVersion = explanations.some((row) => row.allocation?.policyVersion === "high-cost-v4") ? AUTO_ALLOCATION_POLICY : explanations.find((row) => row.allocation !== void 0)?.allocation?.policyVersion ?? "high-cost-v4";
|
|
12485
12468
|
let omittedPolicyDecisions = 0;
|
|
12486
12469
|
for (const explanation of explanations) {
|
|
12487
12470
|
if (explanation.method === "no-fit") {
|
|
@@ -12496,9 +12479,10 @@ function summarizeAutoAllocations(explanations, window) {
|
|
|
12496
12479
|
}
|
|
12497
12480
|
retainedDecisions++;
|
|
12498
12481
|
for (const row of allocation.candidates) {
|
|
12482
|
+
const category = row.category ?? explanation.selectedCategory;
|
|
12499
12483
|
const key = JSON.stringify([
|
|
12500
12484
|
row.modelId,
|
|
12501
|
-
|
|
12485
|
+
category,
|
|
12502
12486
|
row.highCost,
|
|
12503
12487
|
row.previous,
|
|
12504
12488
|
row.weight
|
|
@@ -12511,7 +12495,7 @@ function summarizeAutoAllocations(explanations, window) {
|
|
|
12511
12495
|
}
|
|
12512
12496
|
aggregate = {
|
|
12513
12497
|
modelId: row.modelId,
|
|
12514
|
-
category
|
|
12498
|
+
category,
|
|
12515
12499
|
highCost: row.highCost,
|
|
12516
12500
|
previous: row.previous,
|
|
12517
12501
|
weight: row.weight,
|
|
@@ -12543,6 +12527,7 @@ function summarizeAutoAllocations(explanations, window) {
|
|
|
12543
12527
|
//#endregion
|
|
12544
12528
|
//#region lib/types/turn-selection.js
|
|
12545
12529
|
const ExplanationSchema = z.object({
|
|
12530
|
+
allocationPolicy: z.literal("high-cost-v4").optional(),
|
|
12546
12531
|
assessment: TaskAssessmentSchema.extend({
|
|
12547
12532
|
source: z.enum(["local", "semantic"]),
|
|
12548
12533
|
diagnostic: z.enum([
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./copilot-identity-DRZY_d2X.js";
|
|
2
|
-
import { d as diagnosticsReason, u as diagnosticsOutcome } from "./diagnostics-types-
|
|
2
|
+
import { d as diagnosticsReason, u as diagnosticsOutcome } from "./diagnostics-types-D5T4fto9.js";
|
|
3
3
|
import { i as resolveRequestBudgetPolicy, r as calculateRequestBudget } from "./request-budget-DLY_aRq0.js";
|
|
4
4
|
import z from "@deepseek-ai/schemastery";
|
|
5
5
|
import { LlmError, createUserMessage } from "@deepseek-ai/dsh-llm";
|
package/lib/remote.js
CHANGED
|
@@ -323,14 +323,48 @@ const TaskAssessmentSchema = z.object({
|
|
|
323
323
|
const AUTO_ALLOCATION_POLICIES = [
|
|
324
324
|
"high-cost-v1",
|
|
325
325
|
"high-cost-v2",
|
|
326
|
-
"high-cost-v3"
|
|
326
|
+
"high-cost-v3",
|
|
327
|
+
"high-cost-v4"
|
|
327
328
|
];
|
|
329
|
+
const categories = [
|
|
330
|
+
"powerful",
|
|
331
|
+
"versatile",
|
|
332
|
+
"lightweight",
|
|
333
|
+
"unknown"
|
|
334
|
+
];
|
|
335
|
+
function autoCategoryWeight(category, target) {
|
|
336
|
+
if (category === "unknown") return .02;
|
|
337
|
+
return [
|
|
338
|
+
1,
|
|
339
|
+
.25,
|
|
340
|
+
.05
|
|
341
|
+
][(target === "powerful" ? [
|
|
342
|
+
"powerful",
|
|
343
|
+
"versatile",
|
|
344
|
+
"lightweight"
|
|
345
|
+
] : target === "lightweight" ? [
|
|
346
|
+
"lightweight",
|
|
347
|
+
"versatile",
|
|
348
|
+
"powerful"
|
|
349
|
+
] : [
|
|
350
|
+
"versatile",
|
|
351
|
+
"powerful",
|
|
352
|
+
"lightweight"
|
|
353
|
+
]).indexOf(category)];
|
|
354
|
+
}
|
|
328
355
|
const AutoAllocationSchema = z.object({
|
|
329
356
|
policyVersion: z.enum(AUTO_ALLOCATION_POLICIES),
|
|
357
|
+
targetCategory: z.enum([
|
|
358
|
+
"powerful",
|
|
359
|
+
"versatile",
|
|
360
|
+
"lightweight"
|
|
361
|
+
]).optional(),
|
|
330
362
|
deferredHighCostCount: z.number().int().min(0).max(511).optional(),
|
|
331
363
|
selectedModelId: z.string().min(1).max(512),
|
|
332
364
|
candidates: z.array(z.object({
|
|
333
365
|
modelId: z.string().min(1).max(512),
|
|
366
|
+
category: z.enum(categories).optional(),
|
|
367
|
+
categoryWeight: z.number().positive().max(1).optional(),
|
|
334
368
|
highCost: z.boolean(),
|
|
335
369
|
previous: z.boolean(),
|
|
336
370
|
weight: z.number().positive().max(1.5),
|
|
@@ -339,8 +373,11 @@ const AutoAllocationSchema = z.object({
|
|
|
339
373
|
}).strict().refine((value) => {
|
|
340
374
|
const total = value.candidates.reduce((sum, row) => sum + row.weight, 0);
|
|
341
375
|
const legacy = value.policyVersion === "high-cost-v1";
|
|
342
|
-
const
|
|
343
|
-
|
|
376
|
+
const soft = value.policyVersion === "high-cost-v4";
|
|
377
|
+
const decay = value.policyVersion === "high-cost-v3" || soft;
|
|
378
|
+
const categoryValid = soft ? value.targetCategory !== void 0 && value.candidates.every((row) => row.category !== void 0 && row.categoryWeight === autoCategoryWeight(row.category, value.targetCategory)) : value.targetCategory === void 0 && value.candidates.every((row) => row.category === void 0 && row.categoryWeight === void 0);
|
|
379
|
+
const tierValid = legacy || decay ? value.deferredHighCostCount === void 0 : value.deferredHighCostCount !== void 0 && value.candidates.length + value.deferredHighCostCount <= 512 && value.candidates.every((row) => row.highCost === value.candidates[0].highCost) && (!value.candidates[0].highCost || value.deferredHighCostCount === 0);
|
|
380
|
+
return categoryValid && tierValid && new Set(value.candidates.map((row) => row.modelId)).size === value.candidates.length && value.candidates.some((row) => row.modelId === value.selectedModelId) && value.candidates.filter((row) => row.previous).length <= 1 && value.candidates.every((row) => row.weight === (decay && row.highCost && row.previous ? 2 : (row.highCost ? 20 : 100) * (row.previous && (legacy || !row.highCost) ? 1.5 : 1)) * (soft ? Math.round(row.categoryWeight * 100) : 100) / 1e4 && Math.abs(row.expectedShare - row.weight / total) <= 1e-12);
|
|
344
381
|
}, { message: "Invalid allocation policy evidence" });
|
|
345
382
|
//#endregion
|
|
346
383
|
//#region lib/types/auto-allocation-evidence.js
|
|
@@ -374,6 +411,7 @@ const AutoAllocationSummarySchema = z.object({
|
|
|
374
411
|
//#endregion
|
|
375
412
|
//#region lib/types/turn-selection.js
|
|
376
413
|
const ExplanationSchema = z.object({
|
|
414
|
+
allocationPolicy: z.literal("high-cost-v4").optional(),
|
|
377
415
|
assessment: TaskAssessmentSchema.extend({
|
|
378
416
|
source: z.enum(["local", "semantic"]),
|
|
379
417
|
diagnostic: z.enum([
|
|
@@ -5,6 +5,7 @@ export declare const AutoAllocationSummarySchema: z.ZodObject<{
|
|
|
5
5
|
"high-cost-v1": "high-cost-v1";
|
|
6
6
|
"high-cost-v2": "high-cost-v2";
|
|
7
7
|
"high-cost-v3": "high-cost-v3";
|
|
8
|
+
"high-cost-v4": "high-cost-v4";
|
|
8
9
|
}>;
|
|
9
10
|
scope: z.ZodLiteral<"viewed-session-host-lifetime">;
|
|
10
11
|
status: z.ZodEnum<{
|
|
@@ -1,16 +1,32 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export declare const AUTO_ALLOCATION_POLICIES: readonly ["high-cost-v1", "high-cost-v2", "high-cost-v3"];
|
|
3
|
-
export declare const AUTO_ALLOCATION_POLICY = "high-cost-
|
|
2
|
+
export declare const AUTO_ALLOCATION_POLICIES: readonly ["high-cost-v1", "high-cost-v2", "high-cost-v3", "high-cost-v4"];
|
|
3
|
+
export declare const AUTO_ALLOCATION_POLICY = "high-cost-v4";
|
|
4
|
+
declare const categories: readonly ["powerful", "versatile", "lightweight", "unknown"];
|
|
5
|
+
type Category = typeof categories[number];
|
|
6
|
+
export declare function autoCategoryWeight(category: Category, target: Exclude<Category, 'unknown'>): number;
|
|
4
7
|
export declare const AutoAllocationSchema: z.ZodObject<{
|
|
5
8
|
policyVersion: z.ZodEnum<{
|
|
6
9
|
"high-cost-v1": "high-cost-v1";
|
|
7
10
|
"high-cost-v2": "high-cost-v2";
|
|
8
11
|
"high-cost-v3": "high-cost-v3";
|
|
12
|
+
"high-cost-v4": "high-cost-v4";
|
|
9
13
|
}>;
|
|
14
|
+
targetCategory: z.ZodOptional<z.ZodEnum<{
|
|
15
|
+
powerful: "powerful";
|
|
16
|
+
versatile: "versatile";
|
|
17
|
+
lightweight: "lightweight";
|
|
18
|
+
}>>;
|
|
10
19
|
deferredHighCostCount: z.ZodOptional<z.ZodNumber>;
|
|
11
20
|
selectedModelId: z.ZodString;
|
|
12
21
|
candidates: z.ZodArray<z.ZodObject<{
|
|
13
22
|
modelId: z.ZodString;
|
|
23
|
+
category: z.ZodOptional<z.ZodEnum<{
|
|
24
|
+
unknown: "unknown";
|
|
25
|
+
powerful: "powerful";
|
|
26
|
+
versatile: "versatile";
|
|
27
|
+
lightweight: "lightweight";
|
|
28
|
+
}>>;
|
|
29
|
+
categoryWeight: z.ZodOptional<z.ZodNumber>;
|
|
14
30
|
highCost: z.ZodBoolean;
|
|
15
31
|
previous: z.ZodBoolean;
|
|
16
32
|
weight: z.ZodNumber;
|
|
@@ -25,6 +41,7 @@ export declare function normalizeHighCostModelIds(value: unknown): readonly stri
|
|
|
25
41
|
/** Integer policy units avoid cumulative decimal drift; avalanche sequential turn seeds. */
|
|
26
42
|
export declare function allocateAutoModel(pool: readonly {
|
|
27
43
|
readonly id: string;
|
|
28
|
-
|
|
44
|
+
readonly category?: Exclude<Category, 'unknown'>;
|
|
45
|
+
}[], highCostModelIds: unknown, previousModelId: string | undefined, seed: number, targetCategory?: Exclude<Category, 'unknown'>): AutoAllocation;
|
|
29
46
|
export {};
|
|
30
47
|
//# sourceMappingURL=auto-allocation.d.ts.map
|
|
@@ -24,6 +24,7 @@ export interface AutoModelDecision {
|
|
|
24
24
|
readonly explanation: AutoSelectionExplanation;
|
|
25
25
|
}
|
|
26
26
|
export interface AutoSelectionExplanation {
|
|
27
|
+
readonly allocationPolicy?: 'high-cost-v4';
|
|
27
28
|
readonly assessment: TaskAssessment;
|
|
28
29
|
readonly targetCategory: AccountModelCategory;
|
|
29
30
|
readonly selectedCategory: AccountModelCategory | 'unknown';
|
|
@@ -55,7 +56,7 @@ export declare function classifyAutoModelTurn(messages: readonly unknown[]): Aut
|
|
|
55
56
|
export declare function estimateTurnInputTokens(messages: readonly unknown[], estimateMessage?: (message: unknown) => number): number;
|
|
56
57
|
/**
|
|
57
58
|
* Filter input headroom before task-aware supplier categories.
|
|
58
|
-
* Apply
|
|
59
|
+
* Apply soft category, cost and recency weights across every fitting candidate.
|
|
59
60
|
* Preserves Core compaction ownership if no candidate currently fits.
|
|
60
61
|
*/
|
|
61
62
|
export declare function selectAutoModel(models: readonly AccountModelDescriptor[], messages: readonly unknown[], preference?: AutoModelPreference, context?: AutoModelRoutingContext): AutoModelDecision;
|
|
@@ -9,7 +9,7 @@ export declare class TurnSelectionController extends TypertRemoteService {
|
|
|
9
9
|
constructor(ctx: Context, selections: TurnSelectionStore);
|
|
10
10
|
get(agent: Agent, turn: number): TurnSelection;
|
|
11
11
|
allocationSummary(agent: Agent): {
|
|
12
|
-
policyVersion: "high-cost-v1" | "high-cost-v2" | "high-cost-v3";
|
|
12
|
+
policyVersion: "high-cost-v1" | "high-cost-v2" | "high-cost-v3" | "high-cost-v4";
|
|
13
13
|
scope: "viewed-session-host-lifetime";
|
|
14
14
|
status: "observed" | "not-collected";
|
|
15
15
|
retainedDecisions: number;
|
|
@@ -22,6 +22,7 @@ export declare const TurnSelectionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
22
22
|
candidateCount: z.ZodNumber;
|
|
23
23
|
fittingCandidateCount: z.ZodOptional<z.ZodNumber>;
|
|
24
24
|
explanation: z.ZodOptional<z.ZodObject<{
|
|
25
|
+
allocationPolicy: z.ZodOptional<z.ZodLiteral<"high-cost-v4">>;
|
|
25
26
|
assessment: z.ZodObject<{
|
|
26
27
|
demand: z.ZodEnum<{
|
|
27
28
|
unknown: "unknown";
|
|
@@ -132,11 +133,24 @@ export declare const TurnSelectionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
132
133
|
"high-cost-v1": "high-cost-v1";
|
|
133
134
|
"high-cost-v2": "high-cost-v2";
|
|
134
135
|
"high-cost-v3": "high-cost-v3";
|
|
136
|
+
"high-cost-v4": "high-cost-v4";
|
|
135
137
|
}>;
|
|
138
|
+
targetCategory: z.ZodOptional<z.ZodEnum<{
|
|
139
|
+
powerful: "powerful";
|
|
140
|
+
versatile: "versatile";
|
|
141
|
+
lightweight: "lightweight";
|
|
142
|
+
}>>;
|
|
136
143
|
deferredHighCostCount: z.ZodOptional<z.ZodNumber>;
|
|
137
144
|
selectedModelId: z.ZodString;
|
|
138
145
|
candidates: z.ZodArray<z.ZodObject<{
|
|
139
146
|
modelId: z.ZodString;
|
|
147
|
+
category: z.ZodOptional<z.ZodEnum<{
|
|
148
|
+
unknown: "unknown";
|
|
149
|
+
powerful: "powerful";
|
|
150
|
+
versatile: "versatile";
|
|
151
|
+
lightweight: "lightweight";
|
|
152
|
+
}>>;
|
|
153
|
+
categoryWeight: z.ZodOptional<z.ZodNumber>;
|
|
140
154
|
highCost: z.ZodBoolean;
|
|
141
155
|
previous: z.ZodBoolean;
|
|
142
156
|
weight: z.ZodNumber;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-github-copilot",
|
|
3
3
|
"description": "DSH companion for GitHub Copilot sign-in, account-aware model profiles, tool compatibility, and provider-hosted search.",
|
|
4
|
-
"version": "0.4.2-alpha.
|
|
4
|
+
"version": "0.4.2-alpha.13",
|
|
5
5
|
"releaseNotes": "CHANGELOG.md",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public",
|