dsh-github-copilot 0.4.0-alpha.100
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 +312 -0
- package/CHANGELOG.md +479 -0
- package/CONTRIBUTING.md +46 -0
- package/LICENSE +21 -0
- package/README.md +203 -0
- package/README.zh.md +202 -0
- package/SECURITY.md +29 -0
- package/cordis.patch.yml +16 -0
- package/deployment-baseline.json +1299 -0
- package/docs/agent-readiness.md +110 -0
- package/docs/auto-task-routing.md +234 -0
- package/docs/automatic-model-routing.md +205 -0
- package/docs/copilot-accounts.md +236 -0
- package/docs/copilot-compaction.md +120 -0
- package/docs/copilot-usage.md +125 -0
- package/docs/dual-model.md +66 -0
- package/docs/image-input-compatibility.md +64 -0
- package/docs/images/copilot-accounts-credits.png +0 -0
- package/docs/images/copilot-accounts.png +0 -0
- package/docs/images/copilot-model-preferences.png +0 -0
- package/docs/images/copilot-search-routing.png +0 -0
- package/docs/images/dual-model-desktop.png +0 -0
- package/docs/images/dual-model-mobile.png +0 -0
- package/docs/images/dual-model-provenance.json +35 -0
- package/docs/images/parent-model-follow.png +0 -0
- package/docs/manual-compaction-recovery.md +64 -0
- package/docs/model-compatibility-acceptance.md +164 -0
- package/docs/npm-distribution.md +149 -0
- package/docs/official-first-016-alpha2.md +66 -0
- package/docs/official-first-020-rc1.md +32 -0
- package/docs/official-first-020-rc2.md +16 -0
- package/docs/session-search-routing.md +133 -0
- package/docs/single-route-migration.md +130 -0
- package/docs/web-lifecycle-rc2.md +55 -0
- package/lib/client.js +10822 -0
- package/lib/client.js.map +1 -0
- package/lib/copilot-identity-DRZY_d2X.js +15 -0
- package/lib/index.js +11689 -0
- package/lib/manual-compaction-recovery.js +315 -0
- package/lib/remote.js +734 -0
- package/lib/request-budget-DLY_aRq0.js +87 -0
- package/lib/routed-web.js +120 -0
- package/lib/search-routing-CqysPLve.js +792 -0
- package/lib/types/account-model-auth.d.ts +15 -0
- package/lib/types/account-model-catalog.d.ts +70 -0
- package/lib/types/account-model-source.d.ts +85 -0
- package/lib/types/agent-compaction.d.ts +4 -0
- package/lib/types/authorization-controller.d.ts +119 -0
- package/lib/types/auto-assessment-evidence.d.ts +46 -0
- package/lib/types/auto-model-host.d.ts +27 -0
- package/lib/types/auto-model-intent.d.ts +36 -0
- package/lib/types/auto-model-presentation.d.ts +57 -0
- package/lib/types/auto-model-routing.d.ts +59 -0
- package/lib/types/auto-selection-explanation.d.ts +9 -0
- package/lib/types/auto-task-assessment.d.ts +47 -0
- package/lib/types/auto-task-classifier.d.ts +9 -0
- package/lib/types/background-compaction.d.ts +30 -0
- package/lib/types/client.d.ts +115 -0
- package/lib/types/compact-account.d.ts +42 -0
- package/lib/types/compaction-pressure.d.ts +23 -0
- package/lib/types/compatibility.d.ts +17 -0
- package/lib/types/config.d.ts +89 -0
- package/lib/types/content-file.d.ts +10 -0
- package/lib/types/context-evidence-ui.d.ts +11 -0
- package/lib/types/context-evidence.d.ts +108 -0
- package/lib/types/context-usage.d.ts +4 -0
- package/lib/types/copilot-account-presentation.d.ts +7 -0
- package/lib/types/copilot-accounts-card.d.ts +30 -0
- package/lib/types/copilot-accounts-host.d.ts +75 -0
- package/lib/types/copilot-accounts-remote.d.ts +77 -0
- package/lib/types/copilot-accounts-types.d.ts +42 -0
- package/lib/types/copilot-auth.d.ts +25 -0
- package/lib/types/copilot-grant.d.ts +11 -0
- package/lib/types/copilot-identity.d.ts +11 -0
- package/lib/types/copilot-request.d.ts +11 -0
- package/lib/types/copilot-stream-liveness.d.ts +23 -0
- package/lib/types/copilot-usage-card.d.ts +30 -0
- package/lib/types/copilot-usage-host.d.ts +58 -0
- package/lib/types/copilot-usage-normalize.d.ts +9 -0
- package/lib/types/copilot-usage-remote.d.ts +63 -0
- package/lib/types/copilot-usage-types.d.ts +20 -0
- package/lib/types/copilot-usage-ui.d.ts +4 -0
- package/lib/types/current-provider.d.ts +59 -0
- package/lib/types/deepseek-search-fallback.d.ts +11 -0
- package/lib/types/dual-model-host.d.ts +119 -0
- package/lib/types/dual-model-remote.d.ts +63 -0
- package/lib/types/dual-model-types.d.ts +34 -0
- package/lib/types/external-link.d.ts +3 -0
- package/lib/types/failure.d.ts +38 -0
- package/lib/types/http.d.ts +48 -0
- package/lib/types/image-input-admission.d.ts +5 -0
- package/lib/types/index.d.ts +39 -0
- package/lib/types/manual-compaction-recovery.d.ts +52 -0
- package/lib/types/migration-status.d.ts +50 -0
- package/lib/types/model-exclusions.d.ts +15 -0
- package/lib/types/model-preferences-card.d.ts +9 -0
- package/lib/types/model-protocol.d.ts +31 -0
- package/lib/types/native-select-style.d.ts +4 -0
- package/lib/types/parent-model-follow-card.d.ts +41 -0
- package/lib/types/parent-model-follow.d.ts +44 -0
- package/lib/types/pi-provider-bridge.d.ts +22 -0
- package/lib/types/plan.d.ts +148 -0
- package/lib/types/pre-step-pressure.d.ts +8 -0
- package/lib/types/preview-provider.d.ts +66 -0
- package/lib/types/preview-route.d.ts +74 -0
- package/lib/types/probe.d.ts +39 -0
- package/lib/types/reasoning-presentation.d.ts +55 -0
- package/lib/types/remote-codec.d.ts +10 -0
- package/lib/types/remote.d.ts +199 -0
- package/lib/types/replay-recovery-host.d.ts +28 -0
- package/lib/types/replay-recovery-remote.d.ts +14 -0
- package/lib/types/replay-recovery-types.d.ts +24 -0
- package/lib/types/replay-recovery-ui.d.ts +26 -0
- package/lib/types/replay-recovery.d.ts +17 -0
- package/lib/types/request-body-evidence.d.ts +34 -0
- package/lib/types/request-body-timeout-marker.d.ts +2 -0
- package/lib/types/request-body-timeout.d.ts +4 -0
- package/lib/types/request-budget.d.ts +58 -0
- package/lib/types/request-upload-evidence.d.ts +23 -0
- package/lib/types/response-error-body.d.ts +3 -0
- package/lib/types/responses-reasoning-text.d.ts +24 -0
- package/lib/types/responses-reasoning.d.ts +7 -0
- package/lib/types/responses-replay-compat.d.ts +30 -0
- package/lib/types/route-ownership.d.ts +70 -0
- package/lib/types/routed-web.d.ts +50 -0
- package/lib/types/search-backend.d.ts +16 -0
- package/lib/types/search-routing-host.d.ts +19 -0
- package/lib/types/search-routing-policy.d.ts +18 -0
- package/lib/types/search-routing-remote.d.ts +20 -0
- package/lib/types/search-routing.d.ts +43 -0
- package/lib/types/search-tool-routing.d.ts +22 -0
- package/lib/types/serialize.d.ts +106 -0
- package/lib/types/settings-reader.d.ts +16 -0
- package/lib/types/sse.d.ts +28 -0
- package/lib/types/temporary-models.d.ts +25 -0
- package/lib/types/tool-schema-compat.d.ts +17 -0
- package/lib/types/traditional-search.d.ts +17 -0
- package/lib/types/turn-model-provenance.d.ts +45 -0
- package/lib/types/turn-selection-card.d.ts +10 -0
- package/lib/types/turn-selection-host.d.ts +11 -0
- package/lib/types/turn-selection-remote.d.ts +13 -0
- package/lib/types/turn-selection.d.ts +119 -0
- package/lib/types/turn-usage-evidence.d.ts +66 -0
- package/lib/types/turn-usage-notice.d.ts +7 -0
- package/lib/types/types.d.ts +69 -0
- package/lib/types/usage.d.ts +26 -0
- package/lib/types/watchdog.d.ts +22 -0
- package/lib/types/web-delegate.d.ts +12 -0
- package/lib/types/web-search-routing-card.d.ts +16 -0
- package/lib/types/web-search-routing-config.d.ts +12 -0
- package/lib/types/wire-anthropic.d.ts +37 -0
- package/lib/types/wire.d.ts +56 -0
- package/lib/web-delegate.js +9 -0
- package/output/auto-model-mockup/index.html +207 -0
- package/package.json +236 -0
- package/scripts/check-search-composition.mjs +191 -0
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
# Copilot accounts
|
|
2
|
+
|
|
3
|
+
## Delivery status
|
|
4
|
+
|
|
5
|
+
This document records the approved requirements and implementation design for
|
|
6
|
+
issue #297. Multi-account behavior is not released or installed until the
|
|
7
|
+
acceptance gates below complete. The existing single-account behavior remains
|
|
8
|
+
the compatibility baseline. The current source candidate is `0.4.0-alpha.100`;
|
|
9
|
+
publication, installation and loaded runtime state are separate evidence.
|
|
10
|
+
|
|
11
|
+
## Requirements
|
|
12
|
+
|
|
13
|
+
- Keep multiple independently authorized GitHub Copilot accounts in one DSH
|
|
14
|
+
profile. Exactly one account is active for subsequent managed Copilot work.
|
|
15
|
+
This is not per-Session simultaneous account routing.
|
|
16
|
+
- Models is the only account management and switching surface. Existing Credits
|
|
17
|
+
details show the current GitHub identity read-only; do not add a Chat switcher
|
|
18
|
+
or replace the DSH application identity.
|
|
19
|
+
- Persist OAuth grants through the existing DSH credentials service. Use
|
|
20
|
+
official pi-ai login, refresh and transport, not copied credentials, a token
|
|
21
|
+
backup/refill scheme, a separate credential store, a second wire or Core edits.
|
|
22
|
+
- Preserve the existing `llm-pi-ai/github-copilot` record without moving or
|
|
23
|
+
copying it. It is the compatibility account when no active account is stored.
|
|
24
|
+
Newly added accounts are directly authorized into plugin-owned records.
|
|
25
|
+
- Changing the account must not change Session histories, selected models,
|
|
26
|
+
future global defaults, model exclusions or billing/Usage records. A selected
|
|
27
|
+
model unavailable to the new account fails explicitly, without substitution.
|
|
28
|
+
- Block switches while relevant operations are admitted. Never cancel a running
|
|
29
|
+
answer automatically. Explain that encrypted historical replay can be
|
|
30
|
+
account-bound; do not silently remove replay or replay a message.
|
|
31
|
+
- No automatic fallback to another account on quota exhaustion, authorization
|
|
32
|
+
failure, missing records or invalid settings.
|
|
33
|
+
|
|
34
|
+
## Public API evidence
|
|
35
|
+
|
|
36
|
+
Official DSH `0.2.0-rc.2`, commit
|
|
37
|
+
`639ed015397290b3745d163aafe02ffee4aa3f84`, exposes
|
|
38
|
+
`PiAiAdapterOptions.auth.credentials`. Its adapter source was compared
|
|
39
|
+
byte-for-byte with that commit. DSH `authorization.registerFlow()` registers a
|
|
40
|
+
flow per credential key; `credentials.modifyRecord()` serializes mutations.
|
|
41
|
+
|
|
42
|
+
Published pi-ai `0.87.1` accepts a public `CredentialStore` in `createModels()`.
|
|
43
|
+
`Models.login()` persists directly through that store. `Models.getAuth()`
|
|
44
|
+
refreshes OAuth under its serialized mutation; each account can supply an
|
|
45
|
+
independent store binding without changing provider IDs or model IDs.
|
|
46
|
+
|
|
47
|
+
An isolated experiment with unchanged pi-ai and synthetic in-memory stores
|
|
48
|
+
verified independent native login, no refresh for valid tokens, parallel
|
|
49
|
+
account-local refresh, captured-store stability after selection changes,
|
|
50
|
+
preservation after refresh failure, and independent logout. All HTTP was
|
|
51
|
+
mocked. This is SDK composition evidence, not live OAuth, DSH durable storage,
|
|
52
|
+
native gateway or model-call proof.
|
|
53
|
+
|
|
54
|
+
GitHub's authenticated `GET /user` returns the identity corresponding to the
|
|
55
|
+
GitHub authorization token. The current native OAuth requests `read:user`.
|
|
56
|
+
Its `refresh` field holds that GitHub token; the short-lived `access` field
|
|
57
|
+
holds a different Copilot request token. Never exchange their purposes.
|
|
58
|
+
|
|
59
|
+
The Copilot SDK `account.getQuota` contract at commit
|
|
60
|
+
`ef04633cc84e4ba8e79888a39259ca276f5de732` returns quota snapshots and accepts
|
|
61
|
+
an account selection identifier or GitHub token. It is an experimental
|
|
62
|
+
SDK/runtime RPC, not a pi-ai API or proof of cross-application AI credits.
|
|
63
|
+
This feature does not introduce another CLI runtime to obtain quota.
|
|
64
|
+
|
|
65
|
+
## Ownership extension
|
|
66
|
+
|
|
67
|
+
The user explicitly approved this limited extension of the previous
|
|
68
|
+
single-record policy:
|
|
69
|
+
|
|
70
|
+
- Official canonical credentials remain under their existing owner.
|
|
71
|
+
- The plugin may own additional `github-copilot/account-<opaque-id>` records,
|
|
72
|
+
obtained by official OAuth writing directly into the target record.
|
|
73
|
+
- All records use the existing DSH credentials service and documented grant
|
|
74
|
+
normalization. No credentials enter Settings, Client, Remotes, logs or docs.
|
|
75
|
+
- Official pi-ai remains the OAuth and refresh implementation owner. The plugin
|
|
76
|
+
owns only account addressing, selection, lifecycle and safe presentation.
|
|
77
|
+
- This does not authorize Core changes, credential cloning, ambient credential
|
|
78
|
+
discovery, copied upstream catalogs or a second general transport adapter.
|
|
79
|
+
|
|
80
|
+
## Account binding and persistence
|
|
81
|
+
|
|
82
|
+
Settings contain only an opaque active account identifier, written with a
|
|
83
|
+
path-level compare-and-swap in the existing `github-copilot` namespace. An
|
|
84
|
+
absent selector means the canonical compatibility account. An invalid selector
|
|
85
|
+
or missing selected record is an error, not permission to use canonical.
|
|
86
|
+
There is no persisted membership list: native `credentials.listRecords()`
|
|
87
|
+
enumerates record keys and kinds, while public identity stays in bounded
|
|
88
|
+
Host-memory cache. No usernames, grants or auxiliary account list are stored
|
|
89
|
+
in Settings.
|
|
90
|
+
|
|
91
|
+
A request captures an immutable account identifier, record key and selection
|
|
92
|
+
generation. Its `CredentialStore.read/modify/delete` methods all refer to that
|
|
93
|
+
record. A mutable active-account lookup inside each store method is forbidden:
|
|
94
|
+
an A refresh must never commit into B after a switch.
|
|
95
|
+
|
|
96
|
+
Account identity uses GitHub host plus stable numeric user ID for duplicate
|
|
97
|
+
detection, not usernames or token strings. Identity reads are bounded,
|
|
98
|
+
Host-only, redirect-refusing and cancellation-aware. Normalize only required
|
|
99
|
+
public identity fields, discard unrelated `/user` fields, and reject results
|
|
100
|
+
whose credential/selection evidence changed during the read.
|
|
101
|
+
|
|
102
|
+
Token refresh remains lazy. Inactive accounts need not hold fresh Copilot
|
|
103
|
+
tokens. Refresh uses native `Models.getAuth()` and the corresponding DSH record
|
|
104
|
+
mutation. Failure preserves the account's stored grant and does not affect
|
|
105
|
+
other records. Reauthorization targets the same account slot and must detect
|
|
106
|
+
unexpected identity replacement before activating it.
|
|
107
|
+
|
|
108
|
+
## Add and switch transactions
|
|
109
|
+
|
|
110
|
+
Adding an account runs native OAuth in an independent slot. It does not
|
|
111
|
+
overwrite or change the active account. Identity and model metadata validation
|
|
112
|
+
must complete before the new slot can be selected. Partial authorization is
|
|
113
|
+
reported truthfully and can be retried or explicitly removed.
|
|
114
|
+
|
|
115
|
+
Switching has a preparation phase and a commit phase:
|
|
116
|
+
|
|
117
|
+
1. Capture the selector revision and verify managed-only route eligibility.
|
|
118
|
+
2. Validate target identity, refresh authorization as needed and check account
|
|
119
|
+
model metadata without publishing it as the active account.
|
|
120
|
+
3. Refuse if an operation is active; hold an admission fence during commit so
|
|
121
|
+
a new operation cannot race the final activity check.
|
|
122
|
+
4. CAS the selector, read back committed settings and confirm target evidence.
|
|
123
|
+
5. Revoke old model, Auto, search, quota, identity and recovery evidence and
|
|
124
|
+
update the directory and UI without model/history/default writes.
|
|
125
|
+
|
|
126
|
+
Failed preparation leaves the old selector unchanged. A committed selector
|
|
127
|
+
followed by failed readback is reported as uncertain, never successful and
|
|
128
|
+
never automatically rolled back. Cross-process/external mutations are guarded
|
|
129
|
+
by revisions and evidence checks; an in-process fence is not a cross-namespace
|
|
130
|
+
or cross-process transaction guarantee.
|
|
131
|
+
|
|
132
|
+
Operations include model preparation, Auto assessment, model discovery,
|
|
133
|
+
native auth refresh, managed answer streams and hosted search. Release leases
|
|
134
|
+
on completion, failure, cancellation and disposal. Switching never terminates
|
|
135
|
+
native retries, rewrites native retry policy or manufactures Usage.
|
|
136
|
+
An abandoned signal-free prepared call has no public completion/cancellation
|
|
137
|
+
evidence; it conservatively retains its barrier until disposal. A guessed idle
|
|
138
|
+
timeout must not permit switching under potentially live work.
|
|
139
|
+
|
|
140
|
+
## Route compatibility
|
|
141
|
+
|
|
142
|
+
Core's canonical route still reads its canonical record. Do not intercept
|
|
143
|
+
Core's store, mutate its prototypes or mirror selected grants into its record.
|
|
144
|
+
The first multi-account delivery therefore requires a managed-only profile.
|
|
145
|
+
Existing canonical configuration, running/selected legacy routes, or
|
|
146
|
+
incomplete route evidence blocks switching with a named diagnostic.
|
|
147
|
+
|
|
148
|
+
Any migration uses the existing separately approved, explicit configuration
|
|
149
|
+
workflow. Enabling accounts does not remove native profiles, rewrite stored
|
|
150
|
+
Sessions or silently migrate their route IDs.
|
|
151
|
+
|
|
152
|
+
Sign-out deletes only the selected record. Inactive records remain intact.
|
|
153
|
+
For a noncanonical selection, the selector remains unchanged after sign-out:
|
|
154
|
+
the missing selected slot fails explicitly, never falls back to canonical.
|
|
155
|
+
In a managed-only profile with complete route/Session evidence and no admitted
|
|
156
|
+
activity, Models still permits an explicit CAS switch to a stored valid account
|
|
157
|
+
or Add into a new inactive slot. The missing-slot view remains an error even
|
|
158
|
+
when `switchable` is true for that recovery. Existing Sign in never recreates
|
|
159
|
+
the missing slot with an unverified replacement identity; use Add then Switch.
|
|
160
|
+
|
|
161
|
+
## Presentation and quota
|
|
162
|
+
|
|
163
|
+
Models shows current identity and available accounts, Add, Switch and explicit
|
|
164
|
+
authorization recovery. Switch confirmation describes profile-wide impact and
|
|
165
|
+
history/replay risks. Activity and route blockers remain visible.
|
|
166
|
+
|
|
167
|
+

|
|
168
|
+
|
|
169
|
+

|
|
170
|
+
|
|
171
|
+
These images render the actual candidate components with synthetic accounts
|
|
172
|
+
and quota in an isolated browser. They are not real authorization, supplier
|
|
173
|
+
availability or loaded Desktop evidence.
|
|
174
|
+
|
|
175
|
+
The separate `githubCopilotAccounts` namespace exposes `get`,
|
|
176
|
+
`refreshIdentity`, `add`, `cancel`, `switchAccount`, `reauthorize` and
|
|
177
|
+
`removeAccount`. Existing Remote descriptors are retained. The removal method
|
|
178
|
+
cannot be named `remove`: official rc.2 reserves that inherited service name
|
|
179
|
+
and rejects the entire Client contribution.
|
|
180
|
+
|
|
181
|
+
Credits shows only the current identity under the title. No account selector,
|
|
182
|
+
Add, sign-out or switching action appears in Chat. Unknown identity is
|
|
183
|
+
unavailable, not a stale username presented as current.
|
|
184
|
+
|
|
185
|
+
Identity and quota have separate error states but must share account evidence.
|
|
186
|
+
Models account mutations invalidate mounted Credits presentation before the
|
|
187
|
+
request and reject late responses. A data-free plugin-owned notification causes
|
|
188
|
+
a fresh read after settlement; it does not cancel native work or broadcast
|
|
189
|
+
identity, grants or quota between surfaces. Failed reads never restore the
|
|
190
|
+
previous username as current.
|
|
191
|
+
Missing quota is not zero; pooled, stale, request-based and credit-based
|
|
192
|
+
snapshots retain their distinct meanings. Do not claim cross-app aggregation
|
|
193
|
+
or relabel request counts as AI credits. No new periodic account network poll
|
|
194
|
+
or inference is introduced.
|
|
195
|
+
|
|
196
|
+
## Acceptance gates
|
|
197
|
+
|
|
198
|
+
- Native public authorization and credentials services: independent writes,
|
|
199
|
+
cancellation, restart persistence, per-record serialization and strict grant
|
|
200
|
+
JSON. No changes to the official fixture implementation.
|
|
201
|
+
- Both public gateways and strict Client codecs: no credential fields, stable
|
|
202
|
+
descriptor identities, bounded arguments and visible errors.
|
|
203
|
+
- Exact published native adapter: correct account auth on all supported
|
|
204
|
+
protocols; account-local refresh and failure; no ambient fallback.
|
|
205
|
+
- Races: A refresh versus B selection, admission versus switch, external record
|
|
206
|
+
replacement, settings conflicts, disposal and late identity/quota responses.
|
|
207
|
+
- Behavior: absent-selector compatibility, missing-selector fail-closed,
|
|
208
|
+
duplicate identity, same-account renewal, canonical route blocker, selected
|
|
209
|
+
model missing, revoked permissions and account-bound replay.
|
|
210
|
+
- UI: Models-only switching, readonly Credits identity, dark/light/mobile,
|
|
211
|
+
keyboard interaction, loading/error states and no overlapping controllers.
|
|
212
|
+
- No native Usage filtering, history edits, default selection changes or
|
|
213
|
+
automatic model/account substitution.
|
|
214
|
+
- Full current rc.2 Windows/Linux CI, package and tarball gates, reviewed merge,
|
|
215
|
+
immutable GitHub Release and same-byte npm publication before claiming
|
|
216
|
+
delivery. Installation and restart need separate authorization.
|
|
217
|
+
|
|
218
|
+
## Current evidence and limits
|
|
219
|
+
|
|
220
|
+
Focused native adapter and gateway tests use unchanged rc.2 public APIs and
|
|
221
|
+
synthetic credentials/HTTP. They exercise Responses, Chat Completions and
|
|
222
|
+
Anthropic account dispatch, immutable refresh bindings, strict gateway
|
|
223
|
+
reachability, target CAS, admission and same-identity renewal.
|
|
224
|
+
|
|
225
|
+
The temporary-profile persistence fixture uses native `LocalCredentialProvider`,
|
|
226
|
+
profile boot/Loader, ConfigEditor, SettingsForms CAS, authorization and SDK.
|
|
227
|
+
Independent grants and the selector survive disposal/reopen; stale CAS does
|
|
228
|
+
not replace the config fiber; account A refresh never writes B. It injects
|
|
229
|
+
route/Session eligibility and model preflight, and mocks identity/provider
|
|
230
|
+
HTTP. It is not full production lifecycle or live OAuth qualification.
|
|
231
|
+
|
|
232
|
+
The local frozen install and full gate are blocked by HTTP 404s for unchanged
|
|
233
|
+
official rc.2 dependencies from the configured enterprise mirror. No package
|
|
234
|
+
versions, registry policy or Core artifacts were substituted. The complete
|
|
235
|
+
required Windows/Linux CI matrix remains the release gate; focused tests,
|
|
236
|
+
synthetic UI and persistence do not replace it or prove live model success.
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# Managed Copilot compaction budgets
|
|
2
|
+
|
|
3
|
+
Tracking: [#146](https://github.com/cloga/dsh-github-copilot/issues/146). This is a plugin-only implementation; publication, loaded-runtime state and live-provider acceptance remain separate evidence.
|
|
4
|
+
|
|
5
|
+
## Why two protections are needed
|
|
6
|
+
|
|
7
|
+
The motivating session recorded both `summarization truncated at the token cap (incomplete checkpoint)` and later HTTP 400 input-context overflow in automatic/manual compaction. A successful summary after an explicit model change used 7575 output tokens under an 8192-token cap. These observations do not establish hidden reasoning consumption, either model's contemporaneous capacity, or that simply changing the cap solves the problem.
|
|
8
|
+
|
|
9
|
+
The managed account catalog already retains three different facts: combined context capacity C, independent prompt ceiling I when supplied, and output capability O. Previously I produced a warning only. Stock Core exposes C and triggers normal pressure relative to C; that does not independently enforce I.
|
|
10
|
+
|
|
11
|
+
## Budget admission
|
|
12
|
+
|
|
13
|
+
`request-budget.ts` resolves validated operational policy without mutating catalog metadata:
|
|
14
|
+
|
|
15
|
+
```text
|
|
16
|
+
R = explicit requested output cap, otherwise advertised output capability O
|
|
17
|
+
hard input limit = min(I when supplied, C - R) - safetyTokens
|
|
18
|
+
pressure input limit = floor(hard input limit * pressureRatio)
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
An independent input ceiling does not include output, so output is subtracted from C, not twice from I. Missing I does not mean unlimited combined context. If catalog context was conservatively derived from prompt-only metadata, it retains that existing interpretation; the plugin does not invent an unadvertised larger combined capacity.
|
|
22
|
+
|
|
23
|
+
Invalid/nonpositive model capacities, invalid output caps, caps above O and nonpositive headroom fail explicitly. Impossible policy headroom is `INVALID_REQUEST`, not a request to compact an arbitrarily small history. An input estimate above a valid budget becomes `CONTEXT_WINDOW_EXCEEDED` with a plugin-owned, numeric diagnostic. This is a local estimated admission decision, not a fabricated provider rejection.
|
|
24
|
+
|
|
25
|
+
Final admission happens at the native provider boundary after Core conversion, before model transport. It uses the larger of native usage-anchored estimation and fresh current system/tool/message estimation, so a tiny historical usage anchor cannot hide a newly enlarged fixed prefix. Images and opaque native replay retain native representation and estimation; neither is decrypted, reconstructed or discarded. Token estimation is heuristic, not the provider's exact tokenizer. Safety allowance and genuine provider failure handling remain necessary.
|
|
26
|
+
|
|
27
|
+
The pinned SDK already has its own context-dependent output clamp. This plugin preserves the caller's requested cap rather than introducing another hidden rewrite. No second generic serializer, account-model table, credential lifecycle or native protocol transport is added.
|
|
28
|
+
|
|
29
|
+
## Earlier pressure and transaction ownership
|
|
30
|
+
|
|
31
|
+
For [#280](https://github.com/cloga/dsh-github-copilot/issues/280), a public `agent/pre-step` listener additionally prevents known continuing-step pressure before Core appends `step/start`. It awaits downstream decisions, delegates rejection/cancellation, and requires a committed plugin-owned managed route, no model-selection notice, and a readable native `modelSelection` projection with `pending: null`. First steps and unknown/pending selections delegate: a prior request header is not proof of the next selected route.
|
|
32
|
+
|
|
33
|
+
The account callback supplies only a current capacity threshold; an empty message array used for this lookup is not an input estimate. The public native token meter measures the existing surface. Above that threshold, the initiating Agent's currently bound engine runs one `compactIfNeeded(agent, 'context-overflow', signal)` transaction, respecting disabled auto and the effective zero/invalid overflow policy. Native failures and cancellation propagate before model-attempt admission; a null/no-progress result delegates to the retained final protections. The next native request is built from the replacement surface. No retry counter, history, usage sample or selected model is rewritten.
|
|
34
|
+
|
|
35
|
+
This is **partial prevention**, not general accounting repair. In the unchanged rc.2 synthetic AgentLoop fixture, the existing post-start pressure refusal creates an unsampled attempt and the strict native turn aggregate is unavailable, even after successful recovery. With pre-step reduction, the same two real model steps retain their complete native total without that attempt. Native turn-tail matches events by their recorded turn; compaction replacements for an earlier turn are not samples of the current turn. No samples are suppressed to produce the total.
|
|
36
|
+
|
|
37
|
+
Cold/first-step routes, pending model changes, later system/tool-prefix growth, unavailable evidence, indivisible oversized units and final converted hard-admission errors can still produce missing native turn Usage. Already-recorded totals remain unchanged. The plugin does not fabricate zero usage, display partial sums as full totals, or reinterpret transport failures as compaction pressure.
|
|
38
|
+
|
|
39
|
+
The public `llm/stream` listener sees a committed, frozen loop request. It requires:
|
|
40
|
+
|
|
41
|
+
- The exact plugin-owned managed route and an ordinary marked agent-loop call, not an auxiliary purpose.
|
|
42
|
+
- The public initiating Agent, matching Session ID, and complete matching committed call configuration.
|
|
43
|
+
- Current account-bound descriptor/proof and a valid operational budget.
|
|
44
|
+
- Optional token meter and stock automatic compaction with a positive effective overflow-retry policy.
|
|
45
|
+
|
|
46
|
+
Only then does it emit one terminal local pressure error before dispatch. Official `agent/request-error` recovery owns pruning, balanced-span selection, compaction locks, source checks, durable shrink and bounded retry. The next request is rebuilt from the replaced surface. The plugin never compacts inside a frozen request then sends the stale request, changes the retry counter, or registers a competing compaction service.
|
|
47
|
+
|
|
48
|
+
Disabled auto recovery or zero retries are respected. Missing/mismatching optional capabilities delegate unchanged and can produce one bounded unavailability diagnostic; the hard native guard remains. Cancellation before iteration wins over pressure. There is no polling, automatic metadata refresh from the pressure listener, or whole-Session dump.
|
|
49
|
+
|
|
50
|
+
On official `0.2.0-rc.2`, Desktop presets may isolate `compaction` inside a child group, invisible to both the global plugin context and a plain `agent.ctx.get('compaction')`. The plugin uses the public `agentPresets.composedPreset()` and `serviceFor(agent, 'compaction')` methods to resolve the initiating Agent's current preset engine. A bound preset with no engine remains unavailable; it never borrows another scope's policy. Only an Agent without a bound preset uses its own context lookup. The lookup is repeated rather than caching a replaced engine. Auto's recovery-availability diagnostic uses the same helper.
|
|
51
|
+
|
|
52
|
+
This fixes scope wiring, not a new automatic command: native pressure and `agent/request-error` still invoke the selected engine. Neither `/compact` nor `/copilot-compact` is called by this listener. If the optional manual recovery engine is selected, its automatic path remains the native single-summary path; segmented recovery stays manual-only. Ordinary timeout/transport failures do not become context overflow.
|
|
53
|
+
|
|
54
|
+
## Summary purpose policy
|
|
55
|
+
|
|
56
|
+
Official `GenerateOptions.purpose` permits adapter-specific generation policy. For `purpose: 'compaction'`, `prefer-low` selects supported `minimal`, otherwise supported `low`, only when no effort was supplied or materialized by Core/the configured native profile. Explicit and resolved defaults win; unsupported low controls preserve the provider default. `preserve` disables this purpose default. Normal conversations and other purposes keep their existing reasoning behavior.
|
|
57
|
+
|
|
58
|
+
The stock summary record takes its requested output cap from the owning compaction configuration. Therefore the plugin does not silently increase/decrease that cap in middleware or alter summary route identity. It preserves native `max-tokens` output truncation as failure, distinct from input overflow. Public summaries, encrypted replay and native stop reasons remain native-owned.
|
|
59
|
+
|
|
60
|
+
Each dispatch captures its own policy, descriptor lease and admission-failure state. SDK lazy-stream wrapping may retain only an exception's text; the outer adapter restores only the exact locally captured budget failure, never reclassifying unrelated auth/network errors by guesswork. Concurrent calls do not share mutable purpose or failure state, and cancellation/account invalidation still wins.
|
|
61
|
+
|
|
62
|
+
## Settings
|
|
63
|
+
|
|
64
|
+
All three keys belong to the existing `github-copilot` settings namespace:
|
|
65
|
+
|
|
66
|
+
| Key | Default | Contract |
|
|
67
|
+
| --- | --- | --- |
|
|
68
|
+
| `requestBudgetSafetyTokens` | 4096 | Non-negative safe integer; more allowance means less usable input. Lowering it trades away preventive headroom and does not change native SDK safeguards. |
|
|
69
|
+
| `requestBudgetPressureRatio` | 0.9 | 0.01 through 1, step 0.01, for eligible ordinary loop calls only. |
|
|
70
|
+
| `compactionReasoning` | `prefer-low` | Supported low-cost default for otherwise unspecified summary effort; `preserve` keeps existing defaults. |
|
|
71
|
+
|
|
72
|
+
The existing `enabled` switch remains hosted-search-only. These controls do not change global/default model selection, enable another account route, or transfer conversation data to another provider.
|
|
73
|
+
|
|
74
|
+
## Existing oversized history and recovery limits
|
|
75
|
+
|
|
76
|
+
HTTP `408 / user_request_timeout` is separate from input-budget overflow. For the exact observed request-body timeout response, the managed route supplies a safe `COPILOT_REQUEST_BODY_TIMEOUT` diagnostic and final JSON UTF-8 byte count when available, while preserving native failure classification and retries. These bytes include serialized messages, tools and replay/attachments; they are not token occupancy or an advertised HTTP-size limit. Repeated unchanged retries cannot reduce the request. After retries exhaust, an explicit native compaction may reduce compressible history, but giant fixed prefixes/attachments and network/service faults may remain. The existing optional manual recovery engine must be separately selected; installing the account plugin does not enable it. No 408 triggers automatic compaction, hidden history trimming, credential refresh, model switching, timeout changes or a second retry loop. Consult [GitHub troubleshooting](https://docs.github.com/en/copilot/how-tos/troubleshoot-copilot/troubleshoot-common-issues) and [service status](https://www.githubstatus.com/) without bypassing network policy.
|
|
77
|
+
|
|
78
|
+
For [#263](https://github.com/cloga/dsh-github-copilot/issues/263), the same public final-body fetch hook additionally captures a monotonic fetch-invocation-to-response-header duration, before clone observation. This is round-trip latency, not measured upload progress, throughput or time spent reading the body. Only a verified exact error triggers numeric composition analysis; successful requests are not analyzed or retained.
|
|
79
|
+
|
|
80
|
+
For #291, request-scoped public Node/Undici diagnostic channels also observe local body-write completion and native response-header timing, negotiated TLS ALPN when exposed, and a public Node writable-buffer count at body-write completion. Exactly one matching native request is required; no matching event, multiple requests (such as redirects), and more than eight request identities yield explicit unavailable, ambiguous or work-limited evidence, never combined partial timings. H2 connection evidence does not depend on H1-only header-write events; reused H2 sockets or custom transports may leave ALPN unavailable. Subscriptions stop when Fetch settles, including errors, before bounded response-clone analysis. Only an exact verified timeout emits these numeric observations; no request fields, headers, URLs, content, replay or credentials are retained or logged. The original Fetch arguments, signal, Response/error, dispatcher, proxy, connections and retries remain native-owned.
|
|
81
|
+
|
|
82
|
+
Local `bodySent` means the client reported body-write completion, **not** measured upload duration, kernel acknowledgement, supplier receipt or model execution. No completion event is not proof that upload was incomplete. A zero Node writable buffer is likewise not proof of remote receipt. This can correlate later real failures without changing their classification, but does not establish a supplier cause or cure recurring 408s; synthetic healthy requests are not live failure acceptance.
|
|
83
|
+
|
|
84
|
+
Original serialized value spans partition total bytes into `input`/`messages`, tool definitions, protocol-owned top-level `instructions`/`system` and residual keys/framing. Within conversation only, supported structural image blocks and opaque replay string spans form disjoint subsets; the rest includes text/tool history, framing and unknown representations. Completions system/developer messages stay in conversation. Image URLs and file references are counted as wire blocks, not fetched/decoded file sizes. Responses encrypted content and Anthropic signature/redacted data are counted without interpreting or decrypting replay; no raw contents, IDs, hashes or credentials are reported.
|
|
85
|
+
|
|
86
|
+
Responses tool pictures are also image blocks: the native SDK serializes them under `function_call_output.output[]`, separately from ordinary message `content[]`. Older plugin diagnostics incorrectly classified those spans as remaining history, so an old report of zero image bytes does not establish an image-free request. The corrected diagnostic applies only to newly observed failures; stored failures and history are not rewritten. Unknown output arrays remain residual, and the fix changes neither total bytes nor native image admission, offload budgets, replay or transport.
|
|
87
|
+
|
|
88
|
+
Analysis accepts at most 16 MiB of UTF-8 JSON, with a pre-parse depth/token bound (64 levels / 131072 tokens), followed by at most 65536 values and 128 serialized key characters. Missing, malformed, unsupported, size-limited and work-limited evidence has a named unavailable state with no partial success-shaped totals. Limits bound diagnostic cost and are **not supplier request limits or admission controls**. A reported 9 MiB body may be analyzed, but its size does not establish why a timeout occurred. If image blocks dominate, an explicitly selected smaller `chatMaxRequestImageBytes` can authorize native image offload; if compressible history dominates, explicit native compaction can help. Tool definitions and opaque replay may remain; small failing requests still warrant network/service investigation. Neither choice is performed automatically or guaranteed to reduce 408 frequency.
|
|
89
|
+
|
|
90
|
+
This implementation is preventive, not a general rescue summarizer. A manual summary whose full input already exceeds the hard budget fails before model transport. It does not silently trim, fabricate a partial checkpoint, or claim that refusing the request recovered the history. Giant fixed prefixes or an indivisible latest unit can also prevent useful reduction.
|
|
91
|
+
|
|
92
|
+
The #228 investigation confirmed a separate Auto undercount (#230): Core reasoning blocks caused the incompatible pi-ai estimator to throw and drop complete assistant messages. Auto now uses the native Core meter, without changing final native provider admission. This fixes candidate selection evidence, not a genuinely oversized summary. In the reported failure class, a roughly 508k-token summary input exceeded a roughly 368k-token input budget even with a 65,536-token output reservation. Reducing output reservation cannot remove an independently binding prompt ceiling.
|
|
93
|
+
|
|
94
|
+
On official `0.2.0-rc.2`, the stock summarizer uses an explicitly configured summary route, otherwise the latest committed request header, otherwise the Agent's initial options. Changing only a pending picker selection therefore does not necessarily change a manual `/compact` request's model. Repeating the same over-budget summary or disabling admission is not a recovery procedure.
|
|
95
|
+
|
|
96
|
+
Official configuration already supports a separate summary route and output cap. Selecting a suitable authorized route/cap is an explicit deployment choice, not an automatic fallback. Increasing the output cap consumes combined-context headroom; decreasing it can reproduce the observed incomplete-checkpoint failure.
|
|
97
|
+
|
|
98
|
+
An explicit, separately selected recovery engine for compressible already-oversized **manual** summaries is specified in [manual compaction recovery](./manual-compaction-recovery.md). The default Basic engine and the preventive request guard remain unchanged. No hidden wire interceptor or automatic summary retry is used; the native summary event is unmarked when several real calls contributed to one checkpoint.
|
|
99
|
+
|
|
100
|
+
## Official-first evidence and retirement
|
|
101
|
+
|
|
102
|
+
Exact target: official `ddefc45fbc7f8e46dd73185e68295696d1297887` (`0.1.6-alpha.2`).
|
|
103
|
+
|
|
104
|
+
- [Model context and purpose contract](https://github.com/deepseek-ai/deepseek-harness/blob/ddefc45fbc7f8e46dd73185e68295696d1297887/packages/llm/llm/src/types.ts): combined context metadata and purpose-specific adapter policy.
|
|
105
|
+
- [Basic compaction](https://github.com/deepseek-ai/deepseek-harness/blob/ddefc45fbc7f8e46dd73185e68295696d1297887/packages/compaction/compaction-basic/src/index.ts): official pressure/overflow/manual paths and summary extension.
|
|
106
|
+
- [Summary owner](https://github.com/deepseek-ai/deepseek-harness/blob/ddefc45fbc7f8e46dd73185e68295696d1297887/packages/compaction/compaction-basic/src/summarizer.ts): request prefix, purpose, output cap and truncated-output refusal.
|
|
107
|
+
|
|
108
|
+
Support is partial: official transactional compaction is reused, while independent Copilot input admission and summary-purpose default policy remain companion-owned. Retire the corresponding companion component only after official behavior covers both input/output constraints, correct request identity, cancellation, purpose handling and equivalent regression/unchanged-runtime acceptance. Do not remove official recovery or falsify contextWindow to reduce the diff.
|
|
109
|
+
|
|
110
|
+
Current scoped-recovery evidence additionally targets unchanged official `639ed015397290b3745d163aafe02ffee4aa3f84` (`0.2.0-rc.2`): [public Agent preset service lookup](https://github.com/deepseek-ai/deepseek-harness/blob/639ed015397290b3745d163aafe02ffee4aa3f84/packages/preset/agent-preset-registry/src/index.ts). Native service lookup is complete and reused; plugin pressure still needs the account input budget. Retire this helper when the official request-budget path supplies equivalent preset-owned admission and recovery evidence.
|
|
111
|
+
|
|
112
|
+
## Verification boundary
|
|
113
|
+
|
|
114
|
+
Managed HTTP/SSE liveness is separate from compaction and HTTP 408. Core's idle watchdog measures translated assistant chunks, not heartbeat bytes. The plugin observes actual nonempty bytes without parsing or fabricating output: the default byte-idle limit stays five minutes, while native semantic silence is bounded to ten minutes. Consumer think time does not count; endless heartbeats still fail. Caller cancellation and native retry ownership remain unchanged. Explicit WebSocket/auto transport and `chatStreamLiveness: false` retain native-only timing.
|
|
115
|
+
|
|
116
|
+
`github-copilot.chatMaxRequestImageBytes` exposes the existing native image projection budget with its unchanged 20971520-byte default. An explicit smaller budget can reduce outgoing image payloads by offloading older images into mapped read-only paths; original history is retained, but outgoing image visibility changes. This is not a total request cap, automatic compaction, or a supplier size limit. No live budget reduction is performed by installation or by a 408. Fixed text/tool prefixes and network/service faults may still cause upload timeouts.
|
|
117
|
+
|
|
118
|
+
Pure arithmetic and policy tests, public-middleware fixtures, and the real published native adapter/SDK with synthetic transport cover separate layers. Required cases include independent/combined bounds, changed prefixes, explicit/default output and effort, metadata/credential invalidation, direct/prepared parity, concurrent calls, cancellation, output truncation and oversized manual input. Existing full plugin gates and exact-Core compatibility fixtures remain required; source inventory is not their execution result.
|
|
119
|
+
|
|
120
|
+
No live model inference, local Desktop installation, activation or restart is implied by unit tests or publication. Preserve immutable GitHub/npm byte identity and coordinate Desktop/Ops pins separately after release verification.
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# Copilot account usage
|
|
2
|
+
|
|
3
|
+
The optional composer control separates three quantities:
|
|
4
|
+
|
|
5
|
+
| Quantity | Scope | Rule |
|
|
6
|
+
| --- | --- | --- |
|
|
7
|
+
| Context occupancy | Current native request/context window | Remains owned by DSH's native meter. |
|
|
8
|
+
| Account usage and remaining allocation | Authorized GitHub account quota snapshot | Display only validated provider quota data; identify stale snapshots explicitly. Do not claim cross-application aggregation. |
|
|
9
|
+
| Session credits | Complete provider-reported usage attributable to this DSH Session | Not displayed because the supported adapter does not supply it. Do not infer it from tokens, cost estimates or account balance changes. |
|
|
10
|
+
|
|
11
|
+
## Presentation
|
|
12
|
+
|
|
13
|
+
The control is an additive `conversation.composer.dock` contribution for the current Copilot Session. It does not replace the composer, move native DOM nodes, modify global defaults, switch a model or enroll other Sessions. Native context occupancy and the new account budget are not interchangeable.
|
|
14
|
+
|
|
15
|
+
The compact control shows reported usage and remaining allocation where available. Its details explain the unit, budget, reset timestamp, freshness and unavailable data. Legacy premium requests must never be relabeled AI credits. A pooled organization account can have absolute credits used without a personal denominator; it does not imply unlimited use or expose a knowable organization balance. Percentage-only data must not create falsely precise absolute amounts.
|
|
16
|
+
|
|
17
|
+
The account extension described in [Copilot accounts](./copilot-accounts.md)
|
|
18
|
+
adds a readonly GitHub identity under the details title. Account management and
|
|
19
|
+
switching remain in Models; no Chat switcher is added. Identity and quota must
|
|
20
|
+
carry matching active-account evidence before they are presented together.
|
|
21
|
+
Failure to read identity is not a different account or a zero balance.
|
|
22
|
+
|
|
23
|
+
Detailed amounts are rounded to two decimal places for display; a positive amount below 0.01 is shown as `<0.01`, not zero. GitHub billing remains authoritative. Known individual budgets at 90% used show a low-budget warning, not a spending restriction. The plan link uses the supported Desktop browser handoff with a selectable URL fallback. Details use the browser's native popover top layer when available and a fixed-position fallback otherwise; no additional ReactDOM copy or private Core DOM access is introduced.
|
|
24
|
+
|
|
25
|
+
Provider or Session changes, unmounting and missing supported runtime seams revoke the presentation's ownership. Optional capability failure must not disable sign-in, Models, search or ordinary chat. The installed/loaded Client determines the exact dock placement; the standalone design mockup is not proof of native placement.
|
|
26
|
+
|
|
27
|
+
## Historical context evidence
|
|
28
|
+
|
|
29
|
+
Official rc.2 can replace the native context-pressure sample with the adapter's all-zero usage on a failed attempt. The message breakdown is a separate heuristic projection, so a native `0%` reading can coexist with substantial message tokens. Neither that zero nor the breakdown proves the current exact occupancy.
|
|
30
|
+
|
|
31
|
+
The managed route preserves native usage chunks immediately, including all-zero samples before error or aborted finishes. Usage is shared accounting evidence, not a context-only signal. The former terminal-zero filter was removed in alpha.87 (#270): dropping a sample to protect context pressure also made Core's whole-turn accounting unavailable. Numeric zero alone cannot distinguish the SDK's default from an explicit supplier report, so the plugin neither deletes it nor certifies it as a billing receipt. Native context pressure may consequently show zero after failure; the separate disclosure explains uncertainty instead of modifying Core's meter. No retry, compaction, trimming or model switch is added.
|
|
32
|
+
|
|
33
|
+
Owned byte-idle and replay errors must also wait until the native terminal chunk before restoring their structured failure. Throwing as soon as the provider observer identifies that error can discard the SDK's preceding usage chunk, including real nonzero prompt usage. Restoring the error must not drop that sample or change the native chunk order. This correction does not manufacture a receipt when the SDK reports only zero.
|
|
34
|
+
|
|
35
|
+
The official rc.2 `contextPressure` projection uses the latest usage from both successful messages and failed attempts. A failed all-zero sample can therefore replace its numerator with zero while earlier cumulative Session tokens remain large. This display projection is separate from `TokenMeter.measure()`: the public request estimator checks a usage anchor against the complete surface estimate and reprices when that anchor is too small. A zero ring does not prove either an empty request or a zero admission estimate. The supported public APIs do not let this plugin replace that native ring; repairing its uncertainty presentation belongs to a separately authorized Core task.
|
|
36
|
+
|
|
37
|
+
The time beside **Retried model request** is the recorded retry backoff, not the duration of the preceding network request. A verified `408 / user_request_timeout` describes a supplier request-body timeout, whereas semantic/byte-idle, transport, rate-limit and local admission errors are distinct. Count failed `assistant/attempt` settlements rather than counting their repeated `llm/retry` diagnoses as additional network attempts. No screenshot with collapsed details or unrelated Session receipt establishes the exact supplier or proxy root cause. Native retry policy is retained; see [request-body timeout guidance](./copilot-compaction.md).
|
|
38
|
+
|
|
39
|
+
The separate, strict `githubCopilotContextEvidence` session projection reads only routing and numeric usage from ordinary durable events. It keeps the last applicable input-plus-cache sample when a failed all-zero attempt is replayed. Model changes, compaction, surface replacement, conflicting source attribution and invalid metadata revoke the sample. It never reads message content or opaque replay, registers under a Core key, changes the native pressure projection, or rewrites durable history.
|
|
40
|
+
|
|
41
|
+
An additive composer disclosure identifies missing or unreliable context evidence for the current open Copilot Session. Any retained count is explicitly a **historical input sample, not current occupancy**; no capacity or percentage is inferred. The native context ring and account Credits control remain separate and unchanged. Missing public projection/slot/runtime seams produce named diagnostics rather than guessed counts. Old histories can therefore still show native `0%`; the disclosure explains the uncertainty instead of claiming an in-place native-meter repair.
|
|
42
|
+
|
|
43
|
+
Local synthetic tests establish native-stream preservation, historical-fold and presentation behavior only. Exact published-adapter and public-registry acceptance, complete CI, publication and loaded Desktop state must be verified separately. No live provider call or Session restart is needed for these tests.
|
|
44
|
+
|
|
45
|
+
## Missing completed-turn Usage
|
|
46
|
+
|
|
47
|
+
### Observed plugin/Core integration gap (#259)
|
|
48
|
+
|
|
49
|
+
One observed completed turn contained 57 successful assistant messages with reported usage and one failed `assistant/attempt` without a usage sample. That attempt recorded the plugin's exact local estimated-input-budget diagnostic: 796299 estimated tokens exceeded a 781113-token input budget, before provider dispatch. Native compaction recovered and the subsequent steps completed. No conversation content, credentials or opaque replay is needed to explain this observation; the exact loaded plugin bytes were not independently attested.
|
|
50
|
+
|
|
51
|
+
Official rc.2 `deriveTurnTokenUsage` requires complete lifecycle and exact usage for every attempt. One attempt without a sample makes its whole-turn result unavailable, so `TurnTailNodeView` omits native Usage. This is Core's existing fail-closed accounting rule triggered by our preventive pressure path, not evidence that all requests had no usage and not a regression in single-model exclusion saves.
|
|
52
|
+
|
|
53
|
+
### Cancelled and failed terminal samples (#270)
|
|
54
|
+
|
|
55
|
+
Cancellation does not inherently disable official rc.2 turn accounting: a complete lifecycle with a valid sampled aborted attempt remains eligible. Before alpha.87, the managed terminal-zero filter removed such samples. For example, a successful 120-token step followed by a zero-sampled cancelled step retained Session cumulative counts but lost the entire turn total after filtering. The route now forwards native samples unchanged; historical context evidence still treats failed zero as unreliable, independently of accounting.
|
|
56
|
+
|
|
57
|
+
This is not a promise that every cancelled turn has complete or exact supplier usage. Responses may end before the supplier's final receipt and the SDK may emit its initialized zero. Missing lifecycle, unsampled attempts, pre-dispatch budget failures and native/plugin timeout interruption remain distinct limitations. No prior history is rewritten and no missing sample, partial total or billing amount is invented. Existing native usage already emitted before an error must not be removed for context-only diagnostics.
|
|
58
|
+
|
|
59
|
+
### Plugin-local explanation
|
|
60
|
+
|
|
61
|
+
A plugin-owned public conversation definition retains bounded counts of settlements without reported samples and finish-only attempts with the exact recorded local diagnostic. On a completed Copilot reply whose native tail has no `tokenUsage`, the additive assistant-actions control opens **Turn Usage incomplete** (previously **Turn Usage unavailable**). It uses the incumbent nonmodal popover pattern rather than expanding the native fixed-height footer.
|
|
62
|
+
|
|
63
|
+
The explanation distinguishes recorded local budget blocks, same-settlement request-body timeout diagnoses, other settlements without samples, and missing turn-start/projection evidence. A timeout is recognized only from the shared bounded plugin diagnostic marker on that settlement's unambiguous error finish, never from a neighboring message, generic `408` text or cancellation. The disclosure copies no raw failure text or payload. It retains at most eight timeout details containing only recorded step/event sequence numbers and a recovery boolean, while keeping the full saturating diagnostic count. These are original record coordinates, not invented attempt numbers or navigation links. Unknown coordinates remain unknown. Older count-only projections remain readable; projection state version 2 requests refolding without converting history.
|
|
64
|
+
|
|
65
|
+
A successful retry claim requires strictly increasing event sequences and the same turn/step through the failed `assistant/attempt`, `llm/retry`, matching `llm/retry-started` (same retry ID and ordinal), and an `assistant/message` with an unambiguous successful `stop` finish. Missing, interrupted or mismatched chains remain uncertain. A later arbitrary successful reply or another step is not recovery evidence. This intentionally conservative recognition does not claim that an unrecognized retry failed. Even a confirmed retry cannot fill the failed attempt's usage; the native whole-turn total stays unavailable and billing remains unknown.
|
|
66
|
+
|
|
67
|
+
Generic provider overflow is never labeled pre-dispatch. Invalid reported samples and missing lifecycle boundaries can also make native accounting unavailable; if no cause is established, the explanation remains unknown rather than reimplementing the native validator. Projection and selection Remote failures remain independent, with named diagnostics; Retry only rereads selection evidence, never inference or accounting.
|
|
68
|
+
|
|
69
|
+
The control is historical evidence, not current context occupancy, account credits, dispatch attestation or a supplier receipt. It adds no token sum or fabricated zero usage, changes no native projection key, reads no opaque replay, and rewrites no history. Native complete Usage suppresses the explanation. Ordinary pressure protection, compaction transactions, errors, cancellation and retry remain unchanged. Removing the plugin removes the explanation without a data migration.
|
|
70
|
+
|
|
71
|
+
Synthetic unit/UI tests and exact unchanged Core accounting/registry fixtures prove these boundaries, not live provider receipts or loaded Desktop behavior. A native representation for unbilled pre-dispatch attempts may eventually remove the gap, but would require a separately requested upstream scope; it is not a prerequisite for this plugin-local explanation. Retire the companion diagnostic when native public presentation communicates the same uncertainty and the supported-version acceptance is verified.
|
|
72
|
+
|
|
73
|
+
## Account data boundary
|
|
74
|
+
|
|
75
|
+
The Host uses the selected account's OAuth grant through public credential APIs,
|
|
76
|
+
with `llm-pi-ai/github-copilot` retained for canonical compatibility. GitHub's
|
|
77
|
+
`copilot_internal/user` endpoint uses the GitHub grant, not a quota-specific
|
|
78
|
+
sign-in or a newly pasted token. Access-token renewal remains owned by pi-ai;
|
|
79
|
+
quota inspection must not introduce a refresh implementation or credential
|
|
80
|
+
persistence. The account-record extension has its own explicit ownership
|
|
81
|
+
contract in [Copilot accounts](./copilot-accounts.md).
|
|
82
|
+
|
|
83
|
+
Quota requests are lazy, single-flight and bounded by timeout, response size and cache/failure policy. Account continuity is checked around asynchronous work and before releasing cached data. Authentication denial, sign-out, account invalidation or disposal must not release a previous account's snapshot. A same-account transient failure may expose a timestamped last-known snapshot, never a current balance. Responses and diagnostics exclude tokens and raw provider bodies. An opaque plugin account identifier may bind a snapshot to readonly identity; it is not a token fingerprint or billing identifier. Requests do not follow redirects with the credential; custom enterprise hosts are not guessed.
|
|
84
|
+
|
|
85
|
+
The plugin's default quota fetch lazily creates one request-scoped Undici agent for `https://api.github.com/copilot_internal/user`. It unions and deduplicates `tls.getCACertificates('default')` (including any configured extra CA certificates) and `tls.getCACertificates('system')`, with `rejectUnauthorized: true`. Node 22.19.0 provides both CA APIs; Undici 6 supports that runtime floor. The agent is reused for refreshes and destroyed on controller disposal. Injected test fetchers bypass the agent. No global dispatcher, environment variable, Desktop trust preference, model/search transport or credential owner is changed.
|
|
86
|
+
|
|
87
|
+
This removes reliance on a Desktop launcher inheriting `NODE_USE_SYSTEM_CA=1` for **quota requests only**. On a machine where Watt Toolkit / Steam++ installs a trusted Windows root, quota worked under a correctly environmented launch, then failed when a recovery launcher omitted the process variable despite its persistence in HKCU; a normal manual relaunch restored quota. That is operational evidence for the launcher-inheritance explanation, not proof that this new plugin build has been installed or loaded. Other Desktop traffic, including sign-in and models, still follows its existing process-level trust configuration. If system CA retrieval or agent creation fails, the quota shows `COPILOT_USAGE_TRUST_UNAVAILABLE` without issuing a request or weakening TLS. Certificate verification failures still show `COPILOT_USAGE_TLS`; other fetch failures remain `COPILOT_USAGE_NETWORK`. No diagnostic alone proves proxy routing, authorization or a live balance. Inspect approved Host trust/proxy settings without disabling TLS validation. When unavailable, details show guidance instead of implying a budget. The popover background is opaque even if the host's menu token contains transparency.
|
|
88
|
+
|
|
89
|
+
The Client receives only the separate strict `githubCopilotUsage` namespace (`get` and `refresh`). Existing authorization and migration methods retain their schemas. Refresh does not change settings, budget, plan, model selection or billing policy. This meter is informational and does not authorize spending or implement a budget enforcement loop.
|
|
90
|
+
|
|
91
|
+
## Source contracts and limitations
|
|
92
|
+
|
|
93
|
+
GitHub's internal client endpoint is not a stable public third-party REST contract. The existing grant may not be permitted to read it, and its schema may change. Failure must remain visible rather than falling back to an administrator token, another account, a browser token or fabricated numbers.
|
|
94
|
+
|
|
95
|
+
Verified reference sources:
|
|
96
|
+
|
|
97
|
+
- [Official VS Code account snapshot types](https://github.com/microsoft/vscode/blob/44825207bf4389c3bd17c92d3ec28cf784c324cc/src/vs/base/common/defaultAccount.ts).
|
|
98
|
+
- [Official quota normalization and pooled-account semantics](https://github.com/microsoft/vscode/blob/44825207bf4389c3bd17c92d3ec28cf784c324cc/src/vs/workbench/services/chat/common/chatEntitlementService.ts).
|
|
99
|
+
- [Official quota fetch and per-turn credit accounting](https://github.com/microsoft/vscode/blob/44825207bf4389c3bd17c92d3ec28cf784c324cc/extensions/copilot/src/platform/chat/common/chatQuotaServiceImpl.ts).
|
|
100
|
+
- [GitHub's public organization/enterprise usage reporting API](https://docs.github.com/en/rest/copilot/copilot-usage-metrics) and [report fields](https://docs.github.com/en/copilot/reference/copilot-usage-metrics/copilot-usage-metrics). Daily administrator reports are not a live personal balance API.
|
|
101
|
+
- [GitHub's explanation of used credits with no individual budget](https://github.blog/changelog/2026-07-20-copilot-users-can-now-see-ai-credits-used-per-billing-cycle/).
|
|
102
|
+
|
|
103
|
+
The internal client observes per-turn `copilot_usage.total_nano_aiu`, but existence in another client's wire response is not evidence that the supported DSH/pi adapter exposes complete session accounting to plugins. On the exact alpha.2 source, [`mapUsage`](https://github.com/deepseek-ai/deepseek-harness/blob/ddefc45fbc7f8e46dd73185e68295696d1297887/packages/llm/llm-pi-ai/src/stream.ts) maps only token counts and cache counts into the public [`StreamChunk` usage contract](https://github.com/deepseek-ai/deepseek-harness/blob/ddefc45fbc7f8e46dd73185e68295696d1297887/packages/llm/llm/src/types.ts). Opaque replay state is not an accounting escape hatch. Until an unchanged public seam provides attributable, deduplicated receipts for ordinary calls, retries and background activity, per-session credit values are not displayed.
|
|
104
|
+
|
|
105
|
+
Synthetic tests cover parsing, lifecycle, failure states, strict transport and UI. They do not establish production quota permissions, billing latency, live OAuth/model transport, installed Desktop bytes or loaded plugin state. No real account calls are made merely to generate test evidence.
|
|
106
|
+
|
|
107
|
+
## Current Session and responsive presentation
|
|
108
|
+
|
|
109
|
+
The control uses public `useSession(selector)` for only the current open,
|
|
110
|
+
non-removed Session, with public `useProjection('modelSelection')`. Acceptance
|
|
111
|
+
must include positive rendering on canonical and managed routes, reactive
|
|
112
|
+
provider/Session changes and disposal. A registered or hidden signed-out entry
|
|
113
|
+
alone proves neither rendering nor live account permission.
|
|
114
|
+
|
|
115
|
+
The unavailable Session credits section is omitted rather than permanently displaying a placeholder. Reset metadata is optional and independent from validated quota amounts: missing, malformed, zero or elapsed values are ignored. Select a supplier-reported next reset later than the snapshot observation, preferring the snapshot timestamp before valid UTC account, account or limited-user dates; never invent the next billing date. Invalid optional date metadata does not discard otherwise valid account amounts. The Client also hides reset rows without a known observation time or a later reset.
|
|
116
|
+
|
|
117
|
+
The compact control uses the native secondary font-size and line-height tokens, tertiary text color and pill padding. It stays one line within its allocated width, with ellipsis and a full-label tooltip if a single reading is wider than the available space. The complete reading remains its accessible button text; exact supplied amounts and account-wide scope remain available in the independent details dialog. Loading and unavailable text use the same bounds without extra quota requests.
|
|
118
|
+
|
|
119
|
+
The host owns placement of the existing public dock entries. On a shared-row host, the usage entry follows the native statistics group and can appear immediately after Cache hit; on an older stacked host, it retains that host's placement. The plugin neither relocates native DOM nor overrides native statistics styles, and it does not require a modified Core to activate. A separately authorized Desktop Client layout task owns wrapping and actual assembled native-statistics geometry checks.
|
|
120
|
+
|
|
121
|
+
Official rc.2 retains the shared dock row in [`InputBar.module.css`](https://github.com/deepseek-ai/deepseek-harness/blob/639ed015397290b3745d163aafe02ffee4aa3f84/packages/client/ui-conversation/src/client/skeleton/InputBar.module.css) and intrinsic native statistics group in [`StatsPills.module.css`](https://github.com/deepseek-ai/deepseek-harness/blob/639ed015397290b3745d163aafe02ffee4aa3f84/packages/client/ui-chat/src/client/chat/StatsPills.module.css). Reuse that official presentation primitive rather than inventing another statistics Slot or copying its token calculations. Wide/narrow layout and popup acceptance must use actual native components alongside the released Client; standalone plugin tests or a synthetic sibling label are not proof of native Cache hit alignment.
|
|
122
|
+
|
|
123
|
+
## Official-first retirement
|
|
124
|
+
|
|
125
|
+
Retain this bounded companion feature only while native DSH lacks equivalent public account-usage presentation for the required scope. Migrate to native functionality once equivalent data semantics, account invalidation, session attribution, accessible presentation and supported-version acceptance are verified. Do not require a Core patch or add a parallel model transport to complete this integration.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Retired Copilot model roles
|
|
2
|
+
|
|
3
|
+
Compatibility guide for existing planner/executor histories. **Model roles**
|
|
4
|
+
and dedicated-root creation are retired; they are not current setup features.
|
|
5
|
+
Use ordinary Sessions and native subagents for new work. The separate
|
|
6
|
+
[Follow parent model](./parent-model-follow.md) policy supports ordinary children
|
|
7
|
+
without restoring role UI or depending on upstream native rules/settings UI.
|
|
8
|
+
|
|
9
|
+
## Existing histories
|
|
10
|
+
|
|
11
|
+
- Saved `github-copilot-dual-model` settings stay intact but are not writable
|
|
12
|
+
through the retired role Remote. No migration/deletion runs on activation.
|
|
13
|
+
- Existing dedicated roots/children retain captured policy, routes and history.
|
|
14
|
+
Their `copilot_execute` tool is compatibility for existing work, not a way to
|
|
15
|
+
create new roots or enroll ordinary Sessions.
|
|
16
|
+
- Policy restrictions are workflow controls, not a shell-code sandbox.
|
|
17
|
+
Uninstalling the plugin is not a supported conversion to ordinary Sessions.
|
|
18
|
+
- Do not use the ordinary picker to change a dedicated role:
|
|
19
|
+
`DUAL_MODEL_SELECTION_LOCKED` remains. Start an ordinary Session rather than
|
|
20
|
+
stripping policy from history, replaying work or substituting another model.
|
|
21
|
+
|
|
22
|
+
## Legacy Remotes
|
|
23
|
+
|
|
24
|
+
Three strict descriptors retain their identities:
|
|
25
|
+
|
|
26
|
+
| Method | Current behavior |
|
|
27
|
+
|---|---|
|
|
28
|
+
| `view()` | Read-only `supported: false`, `writable: false`, `DUAL_MODEL_RETIRED`; no account discovery |
|
|
29
|
+
| `save()` | Validates input, then rejects `DUAL_MODEL_RETIRED`; no write |
|
|
30
|
+
| `create()` | Recovers only an already-created root matching original UUID, workspace and revision |
|
|
31
|
+
|
|
32
|
+
Conflicting/uncertain recovery is not evidence of absence or permission to
|
|
33
|
+
retry with another UUID. Exact recovery can complete the original attachment;
|
|
34
|
+
it creates no new root and is not automatic browser replay.
|
|
35
|
+
|
|
36
|
+
Native `subagent/descriptor` v3 is required; the old v1 assumption was a plugin
|
|
37
|
+
bug, not a history migration. Projection `stateVersion: 2` refolds without
|
|
38
|
+
conversion. Unknown/v1/v2, invalid or conflicting descriptors fail closed.
|
|
39
|
+
Never relabel them or fabricate policy provenance. Strict `create()` codec
|
|
40
|
+
factories and the retained `schema` bridge use the same parser.
|
|
41
|
+
|
|
42
|
+
## Evidence and historical material
|
|
43
|
+
|
|
44
|
+
Client tests prove removed role dependencies/slots alongside preserved account,
|
|
45
|
+
search and usage cleanup. Host/Gateway fixtures prove rejected new roots/writes,
|
|
46
|
+
original-request recovery and historical policy restoration. Synthetic tests
|
|
47
|
+
do not prove a particular Desktop's loaded state or live inference.
|
|
48
|
+
|
|
49
|
+
The [retirement issue](https://github.com/cloga/dsh-github-copilot/issues/158),
|
|
50
|
+
[original design](https://github.com/cloga/dsh-github-copilot/issues/127) and
|
|
51
|
+
[historical official-first review](./official-first-016-alpha2.md) retain context.
|
|
52
|
+
Old role images/provenance under `docs/images` are historical artifacts, not
|
|
53
|
+
current screenshots or installation instructions.
|
|
54
|
+
|
|
55
|
+
## 中文摘要
|
|
56
|
+
|
|
57
|
+
模型分工与新建专用根会话已退役;新工作使用普通 Session。独立的父模型跟随
|
|
58
|
+
开关不恢复旧角色界面,也不依赖上游原生规则 UI。已有专用历史、固定策略和
|
|
59
|
+
旧设置原样保留;旧 Remote 只读/拒绝保存,仅允许凭完全匹配原请求恢复已有根。
|
|
60
|
+
不转换历史、不静默换模型、不用新 UUID 绕过未知恢复,也不将卸载当作迁移。
|
|
61
|
+
发布、安装、加载和真实模型调用须分别验证。
|
|
62
|
+
## Alpha.25 descriptor and Remote compatibility
|
|
63
|
+
|
|
64
|
+
Retained native child compatibility uses descriptor v3 and strict Remote codecs.
|
|
65
|
+
Unknown/v1/v2 or invalid child descriptors fail closed without relabeling.
|
|
66
|
+
Projection `stateVersion: 2` refolds evidence; it does not convert history.
|