dsh-github-copilot 0.4.0-alpha.52 → 0.4.0-alpha.54

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,6 +1,6 @@
1
1
  # GitHub Copilot Auto model routing MVP
2
2
 
3
- **Tracking:** [#174](https://github.com/cloga/dsh-github-copilot/issues/174), [#192](https://github.com/cloga/dsh-github-copilot/issues/192)
3
+ **Tracking:** [#174](https://github.com/cloga/dsh-github-copilot/issues/174), [#192](https://github.com/cloga/dsh-github-copilot/issues/192), [#199](https://github.com/cloga/dsh-github-copilot/issues/199)
4
4
 
5
5
  **Target:** official DSH and Windows Desktop `0.2.0-rc.2`
6
6
 
@@ -22,37 +22,52 @@ Selecting Auto uses normal Core selection behavior, including saving it as the f
22
22
 
23
23
  A Goal does not become one indefinitely frozen Auto decision. Each automatic continuation that Core opens as a new turn is classified independently. Tool steps inside that turn do not trigger another decision.
24
24
 
25
- ## MVP routing policy
25
+ ## Routing policy and input fit
26
26
 
27
27
  The account `/models` catalog is authoritative for entitlement and hard capabilities: protocol, context and output limits, image input, tool support, reasoning efforts, and server policy. Unknown or incomplete capability metadata fails closed.
28
28
 
29
- The catalog does not provide trustworthy quality, latency, price, or global-health rankings. The MVP therefore does **not** infer model quality from a marketing name, model-ID prefix, provider order, or token price. It does not claim to reproduce GitHub's private Auto algorithm.
29
+ The catalog does not provide trustworthy quality, latency, price, or global-health rankings. The routing policy therefore does **not** infer model quality from a marketing name, model-ID prefix, provider order, or token price. It does not claim to reproduce GitHub's private Auto algorithm.
30
30
 
31
- The initial deterministic policy classifies only the latest user turn:
31
+ ### Hard input fit check before preference
32
32
 
33
- | Class | Structural signal | Selection |
34
- | --- | --- | --- |
35
- | Fast | short text turn with little structured content | lowest eligible advertised capacity |
36
- | Balanced | ordinary text turn or image turn | median eligible advertised capacity |
37
- | Strong | large or highly structured text turn | highest eligible advertised capacity |
33
+ Before applying soft preferences, routing checks whether each candidate can accommodate the estimated input tokens of the current turn:
38
34
 
39
- Capacity ordering is based on account-advertised reasoning range, context window, and output capacity, with model ID used only as a deterministic tie-breaker. Capacity is not presented as a quality, latency, or cost fact. The policy is intentionally replaceable by reviewed benchmark evidence later.
35
+ 1. **Input estimate:** `estimateTurnInputTokens` measures current conversation messages using `@earendil-works/pi-ai/utils/estimate` (`estimateMessageTokens` and `estimateContextTokens`).
36
+ 2. **Hard candidate budget:** For each candidate model, `calculateRequestBudget` calculates `hardInputLimit` given the model context window, output reservation, and safety allowance.
37
+ 3. **Headroom filtering:** Candidates with insufficient headroom (`estimatedInputTokens > hardInputLimit`) are filtered out. If one or more fitting candidates exist, soft preference selects among the `fitting` subset.
38
+ 4. **No-fit and compaction recovery:** If no candidate can fit the current messages:
39
+ - Auto selects the candidate with the **largest input capacity** to give Core compaction maximum headroom.
40
+ - It records a structured diagnostic in the decision event:
41
+ - `fixed-content-cannot-fit`: the latest user turn alone exceeds maximum capacity and cannot be compacted away.
42
+ - `compaction-unavailable`: compaction is disabled or has zero retries configured.
43
+ - `attempted-but-still-oversized`: a compaction summary already exists in history and the turn remains oversized.
44
+ - `compaction-eligible`: prior history is compressible and downstream dispatch will trigger compaction pressure.
45
+ 5. **Final framing limitation:** At routing time, only messages are estimated; downstream `system-prompt/assemble` injects system prompt instructions and tool schemas. If final framing pushes a near-limit request over the budget, the native provider guard (`inspectRequest`) truthfully rejects the request with `COPILOT_CONTEXT_BUDGET_EXCEEDED` without bypassing safety boundaries.
40
46
 
41
- The MVP makes no additional model call to classify a turn. It does not retry another model after provider output begins, replay tool side effects, or implement wire-time fallback.
47
+ ### Soft capacity preferences across candidate bands
42
48
 
43
- ### Soft capacity preferences
49
+ All three virtual preferences use the *same* eligible account models. Account entitlement, verified input capability (including image input), and input headroom are hard filters; preference changes where the routing policy lands in the deterministic, advertised-capacity order across candidate bands:
44
50
 
45
- All three virtual preferences use the *same* eligible account models. Account entitlement and verified input capability (including image input) are hard filters; preference only changes where the routing policy lands in the deterministic, advertised-capacity order. It cannot turn an ineligible model into a candidate. The initial measurable matrix, with `low`, `middle = floor((n - 1) / 2)`, and `high = n - 1` indices for `n` eligible models, is:
51
+ - **Intelligence:** Biased toward higher advertised capacity across the upper candidate band.
52
+ - **Efficiency:** Biased toward lower advertised capacity across the lower candidate band, though demanding tasks allow higher capacity.
53
+ - **Balance:** Central candidate band.
54
+
55
+ To avoid monopolizing a single top candidate (such as Grok 4.7) across all turns and Sessions, band selection uses an in-memory deterministic seed derived from `${sessionId}:${turn}` (or turn content when Session context is absent). This guarantees:
56
+
57
+ - Selection is **100% frozen** across all steps and retries within the same turn.
58
+ - Unrelated Sessions or turns sample across the candidate band rather than concentrating on one model.
59
+ - No sensitive prompt text or seed hashes are persisted or sent over the network.
60
+ - When only a single candidate is eligible or fitting, it is returned unchanged.
46
61
 
47
62
  | Latest-turn class | Efficiency | Balance (`auto`) | Intelligence |
48
63
  | --- | --- | --- | --- |
49
- | Fast | low | low | middle |
50
- | Balanced | low | middle | high |
51
- | Strong | min(high, max(1, middle)) | high | high |
64
+ | Fast | low band (index 0) | low band (index 0) | middle band |
65
+ | Balanced | lower band | center band | upper band |
66
+ | Strong | center band | upper band | upper band |
52
67
 
53
- For a single candidate every cell selects it; for two candidates a strong turn still selects the higher-capacity one even with Efficiency. Intelligence can use a lighter model for a short turn, and Efficiency can use a higher-capacity model for a demanding turn. These are **capacity preferences**, not measured quality, speed, price or inference-cost preferences. They cannot promise that Intelligence is smarter or Efficiency faster or cheaper. The actual request-budget and compaction checks still apply after selection; no cost or speed metadata is fabricated.
68
+ These are **capacity preferences**, not measured quality, speed, price, or inference-cost preferences. They cannot promise that Intelligence is smarter or Efficiency faster or cheaper. The actual request-budget and compaction checks still apply after selection; no cost or speed metadata is fabricated.
54
69
 
55
- The exact virtual preference stays in the Session's pending selection across turns, while each real request header and transport record the chosen account model. The durable decision event also records the preference; historical events without that field remain Balance for display. Switching to a real model ends automatic routing for subsequent turns.
70
+ The exact virtual preference stays in the Session's pending selection across turns, while each real request header and transport record the chosen account model. Switching to a real model ends automatic routing for subsequent turns. New turns no longer write a separate decision event; compatible historical events without a preference field remain Balance for display.
56
71
 
57
72
  ## Images
58
73
 
@@ -89,9 +104,13 @@ Chat Auto does not own or alter the independent `github-copilot-hosted` search p
89
104
 
90
105
  ## Attribution and explanation
91
106
 
107
+ **Compatibility fix (alpha.54):** new turns omit the plugin-specific Auto footer. Official `0.2.0-rc.2` cannot set an `ignorable` envelope through public `Session.append()`, and its reader rejects unknown required plugin events. The plugin therefore stops writing `github-copilot/auto-model-decision` rather than patching Core, mutating event objects, or borrowing an unrelated event type. Core's actual model/usage provenance and Auto routing remain unchanged. Restore new attribution only when a supported public informational-event or equivalent storage seam has proven cold-read compatibility.
108
+
109
+ The following presentation remains available for compatible historical decision events; absence of such an event produces no plugin attribution or guessed explanation.
110
+
92
111
  Core already places route and usage details at the end of a completed turn. The MVP follows that interaction pattern rather than adding provider/model tags above the answer.
93
112
 
94
- For a completed Auto response, the attribution sits on the same footer row as Core's usage and clock, after the end time. It stays hidden until the message is hovered or focused, matching that chrome. It is not a separate line above the answer.
113
+ For a completed Auto response, the attribution sits on the same footer row as Core's usage and clock, after the end time. It stays hidden until the message is hovered or focused, matching that chrome. It is not a separate line above the answer. The turn-tail display is:
95
114
 
96
115
  ```text
97
116
  [actions] [usage] [time] Auto · <actual model> ?
@@ -103,20 +122,41 @@ The `?` opens a compact explanation using normalized facts such as:
103
122
  - standard turn;
104
123
  - large structured turn;
105
124
  - image capability required;
106
- - number of eligible account models.
125
+ - number of eligible account models;
126
+ - number of models that can fit turn context (when restricted by input headroom).
127
+
128
+ Earlier releases recorded a credential-free `github-copilot/auto-model-decision` Session event before Core persisted the real request header. Historical attribution is derived from that durable decision, never from the current picker or a later catalog snapshot. Raw prompts, credentials, provider response bodies, and guessed prices are never disclosed.
129
+
130
+ ### Recovering affected histories
131
+
132
+ Upgrading prevents new incompatible events but does **not** rewrite existing logs. Repeated restarts cannot repair a stored missing marker.
133
+
134
+ From a source checkout of this version, with Node 24 LTS and the pinned dependencies installed using `pnpm install --frozen-lockfile`, run:
135
+
136
+ ```powershell
137
+ # Read-only validation; prints counts, affected sequence numbers and hashes, never conversation content.
138
+ node scripts\repair-auto-model-history.mjs 'C:\absolute\path\session.v4.jsonl.zstd'
139
+
140
+ # Optional: create a NEW private recovery directory outside the live Session directory.
141
+ node scripts\repair-auto-model-history.mjs 'C:\absolute\path\session.v4.jsonl.zstd' --write-copy 'C:\private\new-recovery-directory'
142
+ ```
143
+
144
+ This is an explicit offline maintenance utility, not an installed plugin hook. It reads all concatenated zstd frames, uses the exact published official `0.2.0-rc.2` format catalog for strict whole-history validation, and adds only `ignorable: true` to recognized Auto decision envelopes. It preserves type, sequence, time, data and all other rows. Unknown required events, invalid decisions, torn tails, invalid relationships, non-v4 input and compressed/decoded inputs over 128 MiB fail closed. It never repairs or drops other errors.
145
+
146
+ Copy mode creates `original.session.v4.jsonl.zstd` (byte-exact backup), `session.v4.jsonl.zstd` (validated repaired copy), and `repair.json` (SHA-256 receipt). It refuses existing destinations and never writes the source. Keep the directory private: both logs contain conversation history. A check/copy can become stale if an active writer appends later.
107
147
 
108
- The plugin records a credential-free `github-copilot/auto-model-decision` Session event before Core persists the real request header. Historical attribution is derived from that durable decision plus assistant/request provenance, never from the current picker or a later catalog snapshot. Raw prompts, credentials, provider response bodies, and guessed prices are never disclosed.
148
+ **Applying a copy requires separate operator approval:** first stop all writers for that Session, verify the fixed plugin will load before resuming, and recheck the live log against `originalSha256`. If it changed, regenerate and validate a fresh copy. Preserve the backup, replace only the exact affected log, verify its hash against `repairedSha256`, then use the normal official history reader to reopen it. Do not replay business requests as a test. If recovery fails, stop writers before restoring the exact original backup. Neither this utility nor the plugin installs itself, replaces a live file, restarts Desktop, clears credentials, or automatically migrates histories.
109
149
 
110
- ## Subagents
150
+ ## Subagents and Agent Teams
111
151
 
112
152
  General native subagent Auto inheritance is **not** in the base MVP.
113
153
 
114
- Core currently creates a native child from the parent's effective real request configuration. Continuable descriptors retain the merged provider/model/effort but do not preserve enough public evidence to distinguish inherited Auto intent from an explicit child override that happens to equal the same real model. The plugin must not relabel that concrete child route as Auto or write a fabricated child selection.
154
+ In official DSH 0.2.0-rc.2, `TeamRoster.spawn` calls `ctx.subagents.startContinuable` without `request.agentOptions`. Core's `resolveChildAgentOptions` snapshots the parent's resolved concrete route into the teammate's options and durable descriptor. Public Core evidence cannot distinguish an inherited concrete snapshot from an explicit concrete override. The plugin must not relabel that concrete child route as Auto or write a fabricated child selection.
115
155
 
116
- The MVP therefore preserves native behavior:
156
+ The implementation preserves native behavior:
117
157
 
118
158
  - a child with an explicit model override uses that model;
119
- - a child without an override inherits Core's resolved concrete route;
159
+ - a child or Team teammate without an override inherits Core's resolved concrete route;
120
160
  - the child UI shows the real model truthfully;
121
161
  - no plugin code claims independent child Auto classification.
122
162
 
@@ -140,7 +180,7 @@ For an otherwise unselected Session that inherits Auto from the global default,
140
180
 
141
181
  ## Acceptance criteria
142
182
 
143
- The MVP is accepted only when unchanged official Core contract tests prove:
183
+ The implementation is accepted only when unchanged official Core contract tests prove:
144
184
 
145
185
  1. Auto appears only in the managed Copilot provider and explicit real/provider selections remain untouched.
146
186
  2. Core's downstream model-selection result is visible to the prepended plugin listener, and the committed request header contains the resolved real model.
@@ -150,8 +190,10 @@ The MVP is accepted only when unchanged official Core contract tests prove:
150
190
  6. image admission and real candidate filtering agree, including the no-image-candidate failure.
151
191
  7. choosing a smaller-context model can trigger the existing local pressure signal, Core compaction, and same-model retry without sending the oversized request.
152
192
  8. hosted search remains independent and never receives the virtual Auto ID as a transport model.
153
- 9. the turn-tail attribution is derived from durable decision/provenance data and is hidden for explicit model turns.
154
- 10. no Core file, dependency artifact, private registry, shared model catalog, or live history is modified.
193
+ 9. no new unknown required attribution event is written; compatible historical attribution is retained, while missing decision events produce no guessed footer.
194
+ 10. input fit check filters out candidates with insufficient hard input headroom before soft preference.
195
+ 11. soft preferences distribute across upper/lower/center candidate bands without monopolizing one top model.
196
+ 12. no Core file, dependency artifact, private registry, shared model catalog, or live history is modified.
155
197
 
156
198
  Synthetic tests prove composition and contracts only. They do not prove a live account's model availability, provider quality, pricing, OAuth readiness, Desktop activation, or real transport success.
157
199
 
@@ -161,7 +203,7 @@ Synthetic tests prove composition and contracts only. They do not prove a live a
161
203
  - GitHub health signals or GitHub's private Auto service;
162
204
  - user-managed exclusions of individual account models and custom picker grouping;
163
205
  - cross-provider routing;
164
- - native subagent Auto inheritance;
206
+ - native subagent and Team Auto inheritance;
165
207
  - model fallback after a provider failure;
166
208
  - side-effect replay;
167
209
  - automatic changes to existing Session selections, settings, or histories.
@@ -14,7 +14,7 @@ Normal discovery needs neither manual model definitions nor routine refresh clic
14
14
 
15
15
  The alpha.7 last-success timestamp (`snapshot.discoveredAt`) appears once beside the count outside **Manage**: English relative text with a full local date/time/zone tooltip and accessible semantic `time`. Missing/invalid timestamps or no account hide it; future values use absolute text. Pending/error preserves the last success, a successful refresh supplies a new time and sign-out clears it. The display timer is disposed with the timestamp or unmount; it does not alter cache/discovery behavior.
16
16
 
17
- Last same-account metadata may display during TTL refresh/loading/error, never authorize requests. Credential/account/permission invalidation or proof expiry immediately revokes evidence; TTL does not extend tokens. Definitive `UNKNOWN_MODEL` triggers one bounded metadata refresh, with no message replay or model switching; generic HTTP/network errors are not guessed to mean unknown models. New models still require supported account metadata. The README's primary alpha.7 model-freshness/model-refreshing PNGs show the built Client in isolated Edge with synthetic Remote/provider-shell data, not live Core or production authorization. Host TTL/cooldown timing requires unit tests, not screenshots. The provider-entry/authorization PNGs remain historical alpha.5 and older compact-account GIF/PNGs alpha.3.
17
+ Last same-account metadata may display during TTL refresh/loading/error, never authorize requests. Credential/account/permission invalidation or proof expiry immediately revokes evidence; TTL does not extend tokens. Definitive `UNKNOWN_MODEL` triggers one bounded metadata refresh, with no message replay or model switching; generic HTTP/network errors are not guessed to mean unknown models. New models still require supported account metadata. README screenshots are presentation-only synthetic evidence; Host TTL/cooldown timing requires unit tests, not screenshots.
18
18
 
19
19
  Existing `llm-pi-ai.providers.github-copilot` profiles are not automatically removed. Until you explicitly remove a reviewed legacy profile, both real routes may remain listed. This guide removes that configuration, not merely its display: after removal and catalog refresh, the composer picker and `/model` both list only the managed Copilot group. Discovery failures produce diagnostics; they do not enable a fallback static catalog.
20
20
 
@@ -74,7 +74,7 @@ A previously stuck **Deleting…** dialog is not proof the configuration was or
74
74
 
75
75
  alpha.7 的上次成功时间(`snapshot.discoveredAt`)只在模型数量旁、**Manage** 外显示一次:相对文字为英文,tooltip 和可访问语义 `time` 提供完整本地日期、时间及时区。缺失/无效/无账号时隐藏,未来时间显示绝对值。等待/失败保留上次成功时间,刷新成功才更新,退出登录清除;时间消失或卸载时清理显示定时器。缓存和发现生命周期不变。
76
76
 
77
- 同账号旧元数据可在 TTL 刷新/loading/error 时展示,但不能授权请求。凭据/账号/权限失效或 proof 到期立即撤销证据,TTL 不延长 token。明确 `UNKNOWN_MODEL` 只触发一次有界元数据刷新,不重放消息或切换模型;普通 HTTP/网络错误不能猜成模型不存在。新模型仍需支持的账号元数据。README 首先展示的 alpha.7 model-freshness/model-refreshing PNG 来自实际构建 Client 的隔离 Edge 与合成 Remote/provider-shell 数据,不是真实 Core 或生产授权。Host TTL/冷却时序需单元测试,不能靠截图证明。provider-entry/authorization PNG 仍为 alpha.5 历史示意,旧紧凑账号 GIF/PNG 为 alpha.3。
77
+ 同账号旧元数据可在 TTL 刷新/loading/error 时展示,但不能授权请求。凭据/账号/权限失效或 proof 到期立即撤销证据,TTL 不延长 token。明确 `UNKNOWN_MODEL` 只触发一次有界元数据刷新,不重放消息或切换模型;普通 HTTP/网络错误不能猜成模型不存在。新模型仍需支持的账号元数据。README 截图只提供合成展示证据;Host TTL/冷却时序需单元测试,不能靠截图证明。
78
78
 
79
79
  升级不会自动删除已有 `llm-pi-ai.providers.github-copilot`。只有用户真正移除经过审核的旧配置后,composer 与 `/model` 才都会只列出托管 Copilot 分组,不是仅隐藏第二条路由。始终保留 `llm-pi-ai` 插件、授权服务和唯一 OAuth record `llm-pi-ai/github-copilot`;不要退出登录、删除凭据或卸载授权插件来隐藏分组,也不要用 `models: []` 冒充禁用。
80
80
 
package/lib/client.js CHANGED
@@ -6018,7 +6018,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6018
6018
  ...event.data.preference === void 0 ? {} : { preference: event.data.preference },
6019
6019
  taskClass: event.data.taskClass,
6020
6020
  reason: event.data.reason,
6021
- candidateCount: event.data.candidateCount
6021
+ candidateCount: event.data.candidateCount,
6022
+ ...sequence(event.data.fittingCandidateCount) ? { fittingCandidateCount: event.data.fittingCandidateCount } : {},
6023
+ ...sequence(event.data.estimatedInputTokens) ? { estimatedInputTokens: event.data.estimatedInputTokens } : {},
6024
+ ...sequence(event.data.selectedInputBudget) ? { selectedInputBudget: event.data.selectedInputBudget } : {},
6025
+ ...typeof event.data.inputFitDiagnostic === "string" ? { inputFitDiagnostic: event.data.inputFitDiagnostic } : {}
6022
6026
  }
6023
6027
  };
6024
6028
  }
@@ -6043,7 +6047,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6043
6047
  if (scope !== "turn") return null;
6044
6048
  const state = context.state ?? context.matches.map((match) => attribution(match.event)).find((value) => value !== void 0);
6045
6049
  if (state === void 0) return null;
6046
- if (previous?.turn === state.turn && previous.key === "github-copilot-auto-model-attribution" && previous.value.provider === state.value.provider && previous.value.model === state.value.model && previous.value.reason === state.value.reason && previous.value.taskClass === state.value.taskClass && previous.value.preference === state.value.preference && previous.value.candidateCount === state.value.candidateCount) return previous;
6050
+ if (previous?.turn === state.turn && previous.key === "github-copilot-auto-model-attribution" && previous.value.provider === state.value.provider && previous.value.model === state.value.model && previous.value.reason === state.value.reason && previous.value.taskClass === state.value.taskClass && previous.value.preference === state.value.preference && previous.value.candidateCount === state.value.candidateCount && previous.value.fittingCandidateCount === state.value.fittingCandidateCount && previous.value.inputFitDiagnostic === state.value.inputFitDiagnostic) return previous;
6047
6051
  return {
6048
6052
  kind: "turn",
6049
6053
  turn: state.turn,
@@ -6082,7 +6086,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6082
6086
  document.head.appendChild(style);
6083
6087
  }
6084
6088
  function reasonText(value) {
6085
- return `${value.reason === "short-text-turn" ? "Short text turn" : value.reason === "large-structured-turn" ? "Large structured turn" : value.reason === "image-capability" ? "Image-capable model required" : "Standard turn"}; ${value.preference ?? "balance"} capacity preference; selected from ${value.candidateCount} eligible account model${value.candidateCount === 1 ? "" : "s"}.`;
6089
+ const reason = value.reason === "short-text-turn" ? "Short text turn" : value.reason === "large-structured-turn" ? "Large structured turn" : value.reason === "image-capability" ? "Image-capable model required" : "Standard turn";
6090
+ const fitInfo = value.fittingCandidateCount !== void 0 && value.fittingCandidateCount < value.candidateCount ? `; ${value.fittingCandidateCount} of ${value.candidateCount} models can fit turn context` : "";
6091
+ return `${reason}; ${value.preference ?? "balance"} capacity preference; selected from ${value.candidateCount} eligible account model${value.candidateCount === 1 ? "" : "s"}${fitInfo}.`;
6086
6092
  }
6087
6093
  function Attribution(props) {
6088
6094
  const source = sourceOf(props);