dsh-github-copilot 0.4.2-alpha.11 → 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.
@@ -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-qvtuvM5E.js";
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;
@@ -48,14 +48,52 @@ function excludedModelSet(value) {
48
48
  }
49
49
  //#endregion
50
50
  //#region lib/types/auto-allocation.js
51
- const AUTO_ALLOCATION_POLICIES = ["high-cost-v1", "high-cost-v2"];
52
- const AUTO_ALLOCATION_POLICY = "high-cost-v2";
51
+ const AUTO_ALLOCATION_POLICIES = [
52
+ "high-cost-v1",
53
+ "high-cost-v2",
54
+ "high-cost-v3",
55
+ "high-cost-v4"
56
+ ];
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
+ }
53
84
  const AutoAllocationSchema = z.object({
54
85
  policyVersion: z.enum(AUTO_ALLOCATION_POLICIES),
86
+ targetCategory: z.enum([
87
+ "powerful",
88
+ "versatile",
89
+ "lightweight"
90
+ ]).optional(),
55
91
  deferredHighCostCount: z.number().int().min(0).max(511).optional(),
56
92
  selectedModelId: z.string().min(1).max(512),
57
93
  candidates: z.array(z.object({
58
94
  modelId: z.string().min(1).max(512),
95
+ category: z.enum(categories).optional(),
96
+ categoryWeight: z.number().positive().max(1).optional(),
59
97
  highCost: z.boolean(),
60
98
  previous: z.boolean(),
61
99
  weight: z.number().positive().max(1.5),
@@ -64,7 +102,11 @@ const AutoAllocationSchema = z.object({
64
102
  }).strict().refine((value) => {
65
103
  const total = value.candidates.reduce((sum, row) => sum + row.weight, 0);
66
104
  const legacy = value.policyVersion === "high-cost-v1";
67
- return (legacy ? 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)) && 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 === (row.highCost ? 2 : 10) * (row.previous && (legacy || !row.highCost) ? 1.5 : 1) / 10 && Math.abs(row.expectedShare - row.weight / total) <= 1e-12);
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);
68
110
  }, { message: "Invalid allocation policy evidence" });
69
111
  function normalizeHighCostModelIds(value) {
70
112
  try {
@@ -75,17 +117,19 @@ function normalizeHighCostModelIds(value) {
75
117
  }
76
118
  }
77
119
  /** Integer policy units avoid cumulative decimal drift; avalanche sequential turn seeds. */
78
- function allocateAutoModel(pool, highCostModelIds, previousModelId, seed) {
120
+ function allocateAutoModel(pool, highCostModelIds, previousModelId, seed, targetCategory = "powerful") {
79
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");
80
122
  const marked = new Set(normalizeHighCostModelIds(highCostModelIds));
81
- const unmarked = pool.filter((model) => !marked.has(model.id));
82
- const participating = unmarked.length > 0 ? unmarked : pool;
83
- const rows = participating.map((model) => {
123
+ const rows = pool.map((model) => {
84
124
  const highCost = marked.has(model.id);
85
125
  const previous = model.id === previousModelId;
86
- const units = (highCost ? 2 : 10) * (previous && !highCost ? 1.5 : 1);
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);
87
129
  return {
88
130
  modelId: model.id,
131
+ category,
132
+ categoryWeight,
89
133
  highCost,
90
134
  previous,
91
135
  units
@@ -103,11 +147,11 @@ function allocateAutoModel(pool, highCostModelIds, previousModelId, seed) {
103
147
  });
104
148
  return Object.freeze({
105
149
  policyVersion: AUTO_ALLOCATION_POLICY,
106
- deferredHighCostCount: pool.length - participating.length,
150
+ targetCategory,
107
151
  selectedModelId: selected.modelId,
108
152
  candidates: Object.freeze(rows.map(({ units, ...row }) => Object.freeze({
109
153
  ...row,
110
- weight: units / 10,
154
+ weight: units / 1e4,
111
155
  expectedShare: units / total
112
156
  })))
113
157
  });
@@ -254,7 +298,7 @@ var AutoAllocationDiagnosticsCollector = class {
254
298
  this.data.observationStart = this.data.observationStart === null ? day : Math.min(this.data.observationStart, day);
255
299
  this.data.observationEnd = this.data.observationEnd === null ? day : Math.max(this.data.observationEnd, day);
256
300
  if (explanation.method === "no-fit") {
257
- const row = this.data.noFitRows.find((item) => item.day === day && item.version === this.version && item.policyVersion === "high-cost-v2" && item.targetCategory === explanation.targetCategory && item.category === explanation.selectedCategory && item.demand === explanation.assessment.demand && item.assessmentSource === explanation.assessment.source && item.assessmentOutcome === outcome);
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);
258
302
  if (row) row.decisions = this.add(row.decisions, 1);
259
303
  else if (this.data.rows.length + this.data.noFitRows.length < 1024) this.data.noFitRows.push({
260
304
  day,
@@ -277,14 +321,15 @@ var AutoAllocationDiagnosticsCollector = class {
277
321
  }
278
322
  if (explanation.method !== "weighted-distribution" && explanation.method !== "only-candidate") return;
279
323
  const parsed = AutoAllocationSchema.safeParse(explanation.allocation);
280
- if (!parsed.success || parsed.data.policyVersion !== "high-cost-v2") {
324
+ if (!parsed.success || parsed.data.policyVersion !== "high-cost-v4") {
281
325
  this.data.dropped = this.add(this.data.dropped, 1);
282
326
  this.changed();
283
327
  return;
284
328
  }
285
329
  const allocation = parsed.data;
286
330
  for (const candidate of allocation.candidates) {
287
- 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 === explanation.selectedCategory && 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);
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);
288
333
  if (row) {
289
334
  row.opportunities = this.add(row.opportunities, 1);
290
335
  row.expectedSelections = Math.min(Number.MAX_SAFE_INTEGER, row.expectedSelections + candidate.expectedShare);
@@ -295,7 +340,7 @@ var AutoAllocationDiagnosticsCollector = class {
295
340
  policyVersion: allocation.policyVersion,
296
341
  modelId: candidate.modelId,
297
342
  targetCategory: explanation.targetCategory,
298
- category: explanation.selectedCategory,
343
+ category,
299
344
  demand: explanation.assessment.demand,
300
345
  assessmentSource: explanation.assessment.source,
301
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-qvtuvM5E.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-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.11",
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
- * Prefer the unmarked tier, with finite ordinary continuity, inside the fitting category.
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 selectedCategory = order.find((category) => fitting.some((model) => (model.category ?? "unknown") === category));
12387
- const pool = fitting.filter((model) => (model.category ?? "unknown") === selectedCategory);
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: selectedCategory !== target,
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-v2") ? AUTO_ALLOCATION_POLICY : explanations.find((row) => row.allocation !== void 0)?.allocation?.policyVersion ?? "high-cost-v2";
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
- explanation.selectedCategory,
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: explanation.selectedCategory,
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-qvtuvM5E.js";
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
@@ -320,13 +320,51 @@ const TaskAssessmentSchema = z.object({
320
320
  }).strict();
321
321
  //#endregion
322
322
  //#region lib/types/auto-allocation.js
323
- const AUTO_ALLOCATION_POLICIES = ["high-cost-v1", "high-cost-v2"];
323
+ const AUTO_ALLOCATION_POLICIES = [
324
+ "high-cost-v1",
325
+ "high-cost-v2",
326
+ "high-cost-v3",
327
+ "high-cost-v4"
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
+ }
324
355
  const AutoAllocationSchema = z.object({
325
356
  policyVersion: z.enum(AUTO_ALLOCATION_POLICIES),
357
+ targetCategory: z.enum([
358
+ "powerful",
359
+ "versatile",
360
+ "lightweight"
361
+ ]).optional(),
326
362
  deferredHighCostCount: z.number().int().min(0).max(511).optional(),
327
363
  selectedModelId: z.string().min(1).max(512),
328
364
  candidates: z.array(z.object({
329
365
  modelId: z.string().min(1).max(512),
366
+ category: z.enum(categories).optional(),
367
+ categoryWeight: z.number().positive().max(1).optional(),
330
368
  highCost: z.boolean(),
331
369
  previous: z.boolean(),
332
370
  weight: z.number().positive().max(1.5),
@@ -335,7 +373,11 @@ const AutoAllocationSchema = z.object({
335
373
  }).strict().refine((value) => {
336
374
  const total = value.candidates.reduce((sum, row) => sum + row.weight, 0);
337
375
  const legacy = value.policyVersion === "high-cost-v1";
338
- return (legacy ? 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)) && 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 === (row.highCost ? 2 : 10) * (row.previous && (legacy || !row.highCost) ? 1.5 : 1) / 10 && Math.abs(row.expectedShare - row.weight / total) <= 1e-12);
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);
339
381
  }, { message: "Invalid allocation policy evidence" });
340
382
  //#endregion
341
383
  //#region lib/types/auto-allocation-evidence.js
@@ -369,6 +411,7 @@ const AutoAllocationSummarySchema = z.object({
369
411
  //#endregion
370
412
  //#region lib/types/turn-selection.js
371
413
  const ExplanationSchema = z.object({
414
+ allocationPolicy: z.literal("high-cost-v4").optional(),
372
415
  assessment: TaskAssessmentSchema.extend({
373
416
  source: z.enum(["local", "semantic"]),
374
417
  diagnostic: z.enum([
@@ -4,6 +4,8 @@ export declare const AutoAllocationSummarySchema: z.ZodObject<{
4
4
  policyVersion: z.ZodEnum<{
5
5
  "high-cost-v1": "high-cost-v1";
6
6
  "high-cost-v2": "high-cost-v2";
7
+ "high-cost-v3": "high-cost-v3";
8
+ "high-cost-v4": "high-cost-v4";
7
9
  }>;
8
10
  scope: z.ZodLiteral<"viewed-session-host-lifetime">;
9
11
  status: z.ZodEnum<{
@@ -1,15 +1,32 @@
1
1
  import { z } from 'zod';
2
- export declare const AUTO_ALLOCATION_POLICIES: readonly ["high-cost-v1", "high-cost-v2"];
3
- export declare const AUTO_ALLOCATION_POLICY = "high-cost-v2";
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";
11
+ "high-cost-v3": "high-cost-v3";
12
+ "high-cost-v4": "high-cost-v4";
8
13
  }>;
14
+ targetCategory: z.ZodOptional<z.ZodEnum<{
15
+ powerful: "powerful";
16
+ versatile: "versatile";
17
+ lightweight: "lightweight";
18
+ }>>;
9
19
  deferredHighCostCount: z.ZodOptional<z.ZodNumber>;
10
20
  selectedModelId: z.ZodString;
11
21
  candidates: z.ZodArray<z.ZodObject<{
12
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>;
13
30
  highCost: z.ZodBoolean;
14
31
  previous: z.ZodBoolean;
15
32
  weight: z.ZodNumber;
@@ -24,6 +41,7 @@ export declare function normalizeHighCostModelIds(value: unknown): readonly stri
24
41
  /** Integer policy units avoid cumulative decimal drift; avalanche sequential turn seeds. */
25
42
  export declare function allocateAutoModel(pool: readonly {
26
43
  readonly id: string;
27
- }[], highCostModelIds: unknown, previousModelId: string | undefined, seed: number): AutoAllocation;
44
+ readonly category?: Exclude<Category, 'unknown'>;
45
+ }[], highCostModelIds: unknown, previousModelId: string | undefined, seed: number, targetCategory?: Exclude<Category, 'unknown'>): AutoAllocation;
28
46
  export {};
29
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
- * Prefer the unmarked tier, with finite ordinary continuity, inside the fitting category.
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";
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";
@@ -131,11 +132,25 @@ export declare const TurnSelectionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
131
132
  policyVersion: z.ZodEnum<{
132
133
  "high-cost-v1": "high-cost-v1";
133
134
  "high-cost-v2": "high-cost-v2";
135
+ "high-cost-v3": "high-cost-v3";
136
+ "high-cost-v4": "high-cost-v4";
134
137
  }>;
138
+ targetCategory: z.ZodOptional<z.ZodEnum<{
139
+ powerful: "powerful";
140
+ versatile: "versatile";
141
+ lightweight: "lightweight";
142
+ }>>;
135
143
  deferredHighCostCount: z.ZodOptional<z.ZodNumber>;
136
144
  selectedModelId: z.ZodString;
137
145
  candidates: z.ZodArray<z.ZodObject<{
138
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>;
139
154
  highCost: z.ZodBoolean;
140
155
  previous: z.ZodBoolean;
141
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.11",
4
+ "version": "0.4.2-alpha.13",
5
5
  "releaseNotes": "CHANGELOG.md",
6
6
  "publishConfig": {
7
7
  "access": "public",