@eddyskywalker/dsh-chatgpt-subscription 0.46.1 → 0.47.0
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/CHANGELOG.md +46 -0
- package/README.md +22 -1
- package/lib/client.js +2639 -571
- package/lib/client.js.map +1 -1
- package/lib/index.js +12000 -3591
- package/lib/plan-mode-pipeline.js +419 -0
- package/lib/types/client/hub/brand-icons.d.ts +1 -1
- package/lib/types/client/hub/brand-icons.d.ts.map +1 -1
- package/lib/types/client/hub/brand-svg.d.ts +4 -0
- package/lib/types/client/hub/brand-svg.d.ts.map +1 -1
- package/lib/types/client/hub/providers.d.ts.map +1 -1
- package/lib/types/client/index.d.ts +2 -0
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/client/locales-ru/index.d.ts.map +1 -1
- package/lib/types/client/locales-ru/progress-updates.d.ts.map +1 -1
- package/lib/types/client/locales-ru/workbuddy.d.ts +10 -0
- package/lib/types/client/locales-ru/workbuddy.d.ts.map +1 -0
- package/lib/types/client/progress-updates/locales.d.ts +23 -5
- package/lib/types/client/progress-updates/locales.d.ts.map +1 -1
- package/lib/types/client/progress-updates/settings-binding.d.ts +13 -1
- package/lib/types/client/progress-updates/settings-binding.d.ts.map +1 -1
- package/lib/types/client/progress-updates/settings-section.d.ts +1 -1
- package/lib/types/client/progress-updates/settings-section.d.ts.map +1 -1
- package/lib/types/client/workbuddy/WorkBuddyComposerQuota.d.ts +34 -0
- package/lib/types/client/workbuddy/WorkBuddyComposerQuota.d.ts.map +1 -0
- package/lib/types/client/workbuddy/WorkBuddySection.d.ts +91 -0
- package/lib/types/client/workbuddy/WorkBuddySection.d.ts.map +1 -0
- package/lib/types/client/workbuddy/locales.d.ts +768 -0
- package/lib/types/client/workbuddy/locales.d.ts.map +1 -0
- package/lib/types/client/workbuddy/styles.d.ts +21 -0
- package/lib/types/client/workbuddy/styles.d.ts.map +1 -0
- package/lib/types/client/workbuddy/useWorkBuddySection.d.ts +149 -0
- package/lib/types/client/workbuddy/useWorkBuddySection.d.ts.map +1 -0
- package/lib/types/compat.d.ts +1 -1
- package/lib/types/entry-plan-mode-pipeline.d.ts +191 -0
- package/lib/types/entry-plan-mode-pipeline.d.ts.map +1 -0
- package/lib/types/host/agent-preset.d.ts.map +1 -1
- package/lib/types/host/cache-warmup/contracts.d.ts +5 -1
- package/lib/types/host/cache-warmup/contracts.d.ts.map +1 -1
- package/lib/types/host/cache-warmup/install.d.ts.map +1 -1
- package/lib/types/host/cache-warmup/projection.d.ts.map +1 -1
- package/lib/types/host/cache-warmup/retrieval-intent.d.ts +18 -0
- package/lib/types/host/cache-warmup/retrieval-intent.d.ts.map +1 -0
- package/lib/types/host/cache-warmup/settings.d.ts +9 -2
- package/lib/types/host/cache-warmup/settings.d.ts.map +1 -1
- package/lib/types/host/common/capabilities.d.ts.map +1 -1
- package/lib/types/host/common/model-request-control.d.ts +1 -1
- package/lib/types/host/common/model-request-control.d.ts.map +1 -1
- package/lib/types/host/common/request-diagnostics.d.ts +1 -1
- package/lib/types/host/common/request-diagnostics.d.ts.map +1 -1
- package/lib/types/host/compaction-prompt.d.ts +129 -0
- package/lib/types/host/compaction-prompt.d.ts.map +1 -0
- package/lib/types/host/preset-sync.d.ts.map +1 -1
- package/lib/types/host/workbuddy/account-pool.d.ts +389 -0
- package/lib/types/host/workbuddy/account-pool.d.ts.map +1 -0
- package/lib/types/host/workbuddy/adapter.d.ts +249 -0
- package/lib/types/host/workbuddy/adapter.d.ts.map +1 -0
- package/lib/types/host/workbuddy/atrest.d.ts +98 -0
- package/lib/types/host/workbuddy/atrest.d.ts.map +1 -0
- package/lib/types/host/workbuddy/checkin.d.ts +150 -0
- package/lib/types/host/workbuddy/checkin.d.ts.map +1 -0
- package/lib/types/host/workbuddy/client.d.ts +214 -0
- package/lib/types/host/workbuddy/client.d.ts.map +1 -0
- package/lib/types/host/workbuddy/dsml.d.ts +55 -0
- package/lib/types/host/workbuddy/dsml.d.ts.map +1 -0
- package/lib/types/host/workbuddy/guardrails.d.ts +111 -0
- package/lib/types/host/workbuddy/guardrails.d.ts.map +1 -0
- package/lib/types/host/workbuddy/identity.d.ts +71 -0
- package/lib/types/host/workbuddy/identity.d.ts.map +1 -0
- package/lib/types/host/workbuddy/mapper.d.ts +238 -0
- package/lib/types/host/workbuddy/mapper.d.ts.map +1 -0
- package/lib/types/host/workbuddy/model-catalog.d.ts +217 -0
- package/lib/types/host/workbuddy/model-catalog.d.ts.map +1 -0
- package/lib/types/host/workbuddy/oauth.d.ts +47 -0
- package/lib/types/host/workbuddy/oauth.d.ts.map +1 -0
- package/lib/types/host/workbuddy/outbound-identity.d.ts +139 -0
- package/lib/types/host/workbuddy/outbound-identity.d.ts.map +1 -0
- package/lib/types/host/workbuddy/routes.d.ts +56 -0
- package/lib/types/host/workbuddy/routes.d.ts.map +1 -0
- package/lib/types/host/workbuddy/token-store.d.ts +370 -0
- package/lib/types/host/workbuddy/token-store.d.ts.map +1 -0
- package/lib/types/host/workbuddy/types.d.ts +179 -0
- package/lib/types/host/workbuddy/types.d.ts.map +1 -0
- package/lib/types/index.d.ts +35 -0
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/shared/workbuddy-contracts.d.ts +531 -0
- package/lib/types/shared/workbuddy-contracts.d.ts.map +1 -0
- package/package.json +6 -2
- package/presets/dispatch/README.md +57 -3
- package/presets/dispatch/agent.cordis.yml +42 -13
|
@@ -0,0 +1,531 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire contracts between the WorkBuddy host routes and the browser settings
|
|
3
|
+
* card. Everything here is public: no credential ever crosses this boundary.
|
|
4
|
+
*/
|
|
5
|
+
import type { AccountPoolStatusDto, PoolAccountSummaryDto } from './account-pool-contracts.ts';
|
|
6
|
+
import type { PoolStorageDto } from './contracts.ts';
|
|
7
|
+
/**
|
|
8
|
+
* Which deployment region an account belongs to.
|
|
9
|
+
*
|
|
10
|
+
* The two regions are separate backends serving overlapping-but-different model
|
|
11
|
+
* catalogs, and a model asked of the wrong region answers 400 `code 11102`
|
|
12
|
+
* ("service info not found") rather than failing over. The region is therefore
|
|
13
|
+
* a property of the credential, not of the request.
|
|
14
|
+
*/
|
|
15
|
+
export type WorkBuddyRegion = 'cn' | 'intl';
|
|
16
|
+
/**
|
|
17
|
+
* Local quota guardrails, as the settings card edits them.
|
|
18
|
+
*
|
|
19
|
+
* The host owns the enforcement; this is the wire shape. `0` means OFF for every
|
|
20
|
+
* field, and all-off is the default, so an untouched install behaves exactly as
|
|
21
|
+
* before the guardrails existed.
|
|
22
|
+
*/
|
|
23
|
+
export interface WorkBuddyGuardrailsDto {
|
|
24
|
+
/** Stop serving an account whose remaining credits are below this. */
|
|
25
|
+
reserveCredits: number;
|
|
26
|
+
/** Stop serving an account for the rest of the local day at this many tokens. */
|
|
27
|
+
dailyTokens: number;
|
|
28
|
+
/** Stop serving one model for the rest of the local day at this many tokens. */
|
|
29
|
+
modelDailyTokens: number;
|
|
30
|
+
}
|
|
31
|
+
/** Client families this line can present to the gateway. */
|
|
32
|
+
export type WorkBuddyOutboundProduct = 'cli' | 'workbuddy' | 'vscode';
|
|
33
|
+
/**
|
|
34
|
+
* Stored preference for which client family requests present.
|
|
35
|
+
*
|
|
36
|
+
* `auto` assigns one product per account and keeps it for that account's whole
|
|
37
|
+
* life; every other value pins it line-wide. The shipped default (`cli`) is the
|
|
38
|
+
* identity this line has always sent.
|
|
39
|
+
*/
|
|
40
|
+
export type WorkBuddyOutboundSetting = 'auto' | WorkBuddyOutboundProduct;
|
|
41
|
+
/**
|
|
42
|
+
* Consumption multiplier of one model, per region.
|
|
43
|
+
*
|
|
44
|
+
* The subscription publishes a \`credits\` string per model in its own
|
|
45
|
+
* \`/v3/config\` catalog — \`x0.79 credits\`, \`x6.67\` — which is the relative rate at
|
|
46
|
+
* which that model consumes the package allowance. The official CodeBuddy
|
|
47
|
+
* client renders it as \`6.67x\` beside the model in its picker; this route
|
|
48
|
+
* carries the same fact to the settings card, so a model's cost is visible at
|
|
49
|
+
* the moment it is chosen rather than only on the bill.
|
|
50
|
+
*
|
|
51
|
+
* Keyed by region because the two backends do not always agree: measured
|
|
52
|
+
* 2026-10-09, \`deepseek-v4.1-flash\` is \`0.11\` on cn against \`0.00\` on intl. A
|
|
53
|
+
* region the catalog did not name for this model is absent rather than guessed,
|
|
54
|
+
* and a model whose publisher declares no usable rate (\`default-model\` ships an
|
|
55
|
+
* empty string) carries no entry at all.
|
|
56
|
+
*
|
|
57
|
+
* Values are the bare numeric form (\`'0.79'\`), never the wire spelling: the
|
|
58
|
+
* label and the \`x\` suffix belong to whichever surface renders it.
|
|
59
|
+
*/
|
|
60
|
+
export type WorkBuddyModelCredits = Partial<Record<WorkBuddyRegion, string>>;
|
|
61
|
+
/**
|
|
62
|
+
* Parse one gateway \`credits\` string into the bare multiplier it names.
|
|
63
|
+
*
|
|
64
|
+
* Measured shapes: \`x6.67\` (intl), \`x0.79 credits\` (cn), and \`''\` for a model
|
|
65
|
+
* whose publisher declares no rate. \`x0.00\` is deliberately kept — it is a real
|
|
66
|
+
* declaration ("this model does not consume allowance"), not a missing value,
|
|
67
|
+
* so it must not be confused with the empty string that means nothing is known.
|
|
68
|
+
*
|
|
69
|
+
* The return is \`null\` rather than \`0\` for anything unparseable, so a caller can
|
|
70
|
+
* tell "no rate published" from "a rate of zero".
|
|
71
|
+
*/
|
|
72
|
+
export declare function parseWorkBuddyCreditMultiplier(raw: unknown): string | null;
|
|
73
|
+
/**
|
|
74
|
+
* Reasoning levels this route can name.
|
|
75
|
+
*
|
|
76
|
+
* Deliberately the widest set any model declares, so a saved default is not
|
|
77
|
+
* discarded merely because the model that suggested it is no longer selected.
|
|
78
|
+
* The settings card renders the subset the account's models actually declare.
|
|
79
|
+
*/
|
|
80
|
+
export type WorkBuddyReasoningEffort = 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';
|
|
81
|
+
/**
|
|
82
|
+
* Every level this route can name, in escalating order (the card's sort key).
|
|
83
|
+
*
|
|
84
|
+
* `none` is the one level that is not a rung of any ladder: it is the measured
|
|
85
|
+
* spelling that turns the reasoning trace OFF upstream (`reasoning_effort:
|
|
86
|
+
* "none"`, the value the sibling gateway sends on its own cheap calls). It is
|
|
87
|
+
* only ever offered on a model the catalog marks `canDisableThinking`, so it
|
|
88
|
+
* sorts below everything and is never used to converge a level onto a ladder.
|
|
89
|
+
*/
|
|
90
|
+
export declare const WORKBUDDY_REASONING_EFFORTS: readonly WorkBuddyReasoningEffort[];
|
|
91
|
+
/**
|
|
92
|
+
* Ladder of a WorkBuddy model that leaves the level choice to the gateway.
|
|
93
|
+
*
|
|
94
|
+
* `/v3/config` publishes a model's ladder in two shapes: an explicit
|
|
95
|
+
* `supportedEfforts` list, or a lone `{ effort }` field that names only the
|
|
96
|
+
* DEFAULT. Conflating them was a real bug — the lone field first became a
|
|
97
|
+
* one-entry ladder, which rejected an explicit `low`; widening it to every
|
|
98
|
+
* level this route can name then advertised `minimal`/`xhigh` on a model that
|
|
99
|
+
* has three. Measured against the live gateway, such a model accepts exactly
|
|
100
|
+
* `low`/`high`/`max` — the same three `glm-5.3-flash` and
|
|
101
|
+
* `kimi-k2.8-preview` declare explicitly — and every other value is routed
|
|
102
|
+
* into the nearest of them rather than honoured as a level of its own.
|
|
103
|
+
*/
|
|
104
|
+
export declare const WORKBUDDY_STANDARD_EFFORTS: readonly WorkBuddyReasoningEffort[];
|
|
105
|
+
/**
|
|
106
|
+
* Snap a level onto the nearest rung a model's ladder actually exposes.
|
|
107
|
+
*
|
|
108
|
+
* The gateway names a default from a wider vocabulary than the ladder it
|
|
109
|
+
* publishes for the same model: an effort-only entry (minimax-m3, kimi-k3,
|
|
110
|
+
* `glm-5.3` in the cn region) reports `effort: 'medium'` while exposing only
|
|
111
|
+
* `low`/`high`/`max`. Letting that value through is not cosmetic — a default
|
|
112
|
+
* outside the ladder is discarded by the level-resolution step, the request
|
|
113
|
+
* then carries no `reasoning_effort`, and the model returns an EMPTY
|
|
114
|
+
* `reasoning_content` (measured on minimax-m3: 0 characters across three
|
|
115
|
+
* samples, versus 282-659 with the field). Ties resolve upward, which is the
|
|
116
|
+
* mapping the sibling Kimi line documents for `medium`. A ladder that names
|
|
117
|
+
* no level (a text-only model) yields nothing to converge to.
|
|
118
|
+
*/
|
|
119
|
+
export declare function convergeWorkBuddyEffort(effort: string, ladder: readonly string[]): WorkBuddyReasoningEffort | null;
|
|
120
|
+
/** One model offered by the WorkBuddy subscription. */
|
|
121
|
+
export interface WorkBuddyModelOption {
|
|
122
|
+
id: string;
|
|
123
|
+
name: string;
|
|
124
|
+
/** Enabled models are the ones DSH offers in the conversation model picker. */
|
|
125
|
+
enabled: boolean;
|
|
126
|
+
/** Context window this route assumes when the caller saves no override. */
|
|
127
|
+
defaultContextWindow: number;
|
|
128
|
+
/** Effective context window: the override when one is saved, else the default. */
|
|
129
|
+
contextWindow: number;
|
|
130
|
+
/** Maximum output tokens this route requests when a caller omits one. */
|
|
131
|
+
defaultMaxTokens: number;
|
|
132
|
+
/** Reasoning levels this route exposes; absent for non-reasoning models. */
|
|
133
|
+
reasoningEfforts?: string[];
|
|
134
|
+
/** Whether the model accepts image input on this route. */
|
|
135
|
+
supportsImage: boolean;
|
|
136
|
+
/** Regions that serve this model; the account's own region must be listed. */
|
|
137
|
+
regions: WorkBuddyRegion[];
|
|
138
|
+
/**
|
|
139
|
+
* Consumption multiplier per region, as the gateway declares it.
|
|
140
|
+
*
|
|
141
|
+
* Absent when nothing usable was published for this model — an unreachable
|
|
142
|
+
* gateway served by the shipped fallback for a model it does not rate, or an
|
|
143
|
+
* account whose region is not among the keys. The card must then show no
|
|
144
|
+
* multiplier rather than a placeholder: a guessed rate on a spend figure is
|
|
145
|
+
* worse than a missing one.
|
|
146
|
+
*/
|
|
147
|
+
credits?: WorkBuddyModelCredits;
|
|
148
|
+
/** One-line description shown beside the model in the settings card. */
|
|
149
|
+
description?: string;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Daily check-in preference for the CN-region billing activity.
|
|
153
|
+
*
|
|
154
|
+
* The activity is CN-only: the international deployment answers no check-in
|
|
155
|
+
* surface, so the scheduler skips those accounts outright. There is no window
|
|
156
|
+
* to configure: the first tick after the host starts is the daily run.
|
|
157
|
+
*/
|
|
158
|
+
export interface WorkBuddyCheckinSettings {
|
|
159
|
+
/** Whether the in-process scheduler signs eligible accounts in. */
|
|
160
|
+
enabled: boolean;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Aggregate check-in state the settings card renders.
|
|
164
|
+
*
|
|
165
|
+
* Deliberately account-less: the card shows one line ("checked in x/y today"),
|
|
166
|
+
* not a per-account breakdown, so no account identity crosses here either.
|
|
167
|
+
*/
|
|
168
|
+
export interface WorkBuddyCheckinSummary {
|
|
169
|
+
enabled: boolean;
|
|
170
|
+
/** CN-region accounts eligible for the check-in activity. */
|
|
171
|
+
totalAccounts: number;
|
|
172
|
+
/** Accounts confirmed signed in today (already signed, or signed by a run). */
|
|
173
|
+
doneToday: number;
|
|
174
|
+
/**
|
|
175
|
+
* Accounts whose activity reported no entitlement today.
|
|
176
|
+
*
|
|
177
|
+
* Kept apart from {@link doneToday} because "the activity is inactive" is not
|
|
178
|
+
* "you are checked in": counting them together let the card claim a sign-in
|
|
179
|
+
* that never happened.
|
|
180
|
+
*/
|
|
181
|
+
skippedToday: number;
|
|
182
|
+
/** Accounts that exhausted today's retry cap without signing in. */
|
|
183
|
+
failedToday: number;
|
|
184
|
+
/** Unix milliseconds the scheduler last ran, automatic or manual. */
|
|
185
|
+
lastRunAt: number | null;
|
|
186
|
+
}
|
|
187
|
+
/** One credit allowance reported by the billing service. */
|
|
188
|
+
export interface WorkBuddyMeter {
|
|
189
|
+
id: string;
|
|
190
|
+
label: string;
|
|
191
|
+
/** Used fraction in [0, 1] when the service reports a bounded allowance. */
|
|
192
|
+
usedFraction: number | null;
|
|
193
|
+
/** Remaining fraction in [0, 1], when the service reports one. */
|
|
194
|
+
remainingFraction: number | null;
|
|
195
|
+
used: string | null;
|
|
196
|
+
limit: string | null;
|
|
197
|
+
/** Unix milliseconds the meter resets, when reported. */
|
|
198
|
+
resetsAt: number | null;
|
|
199
|
+
description: string | null;
|
|
200
|
+
}
|
|
201
|
+
/** Account identity read from the local CodeBuddy credential file. */
|
|
202
|
+
export interface WorkBuddyAccount {
|
|
203
|
+
/** Stable, non-secret selection key derived from region + account identity. */
|
|
204
|
+
id: string;
|
|
205
|
+
uid: string | null;
|
|
206
|
+
nickname: string | null;
|
|
207
|
+
/** Tencent UIN, masked by the card rather than sent in full. */
|
|
208
|
+
uin: string | null;
|
|
209
|
+
/** Account kind the client reports, e.g. `personal`. */
|
|
210
|
+
accountType: string | null;
|
|
211
|
+
/** Enterprise/tenant id when the account is an enterprise one. */
|
|
212
|
+
enterpriseId: string | null;
|
|
213
|
+
region: WorkBuddyRegion;
|
|
214
|
+
/** Backend base URL this account's region resolves to. */
|
|
215
|
+
backend: string;
|
|
216
|
+
/** Auth domain recorded in the credential, e.g. `copilot.tencent.com`. */
|
|
217
|
+
domain: string;
|
|
218
|
+
/** Unix milliseconds the access token expires. */
|
|
219
|
+
expiresAt: number | null;
|
|
220
|
+
/** File the credential was read from; null for plugin-managed accounts. */
|
|
221
|
+
sourceFile: string | null;
|
|
222
|
+
/** Desktop credentials are external; managed credentials belong to this plugin. */
|
|
223
|
+
source: 'desktop' | 'managed';
|
|
224
|
+
/** Managed credentials may be deleted; desktop credentials may only be hidden. */
|
|
225
|
+
removable: boolean;
|
|
226
|
+
/** Hidden desktop accounts do not participate in automatic selection. */
|
|
227
|
+
hidden: boolean;
|
|
228
|
+
}
|
|
229
|
+
/** One WorkBuddy account as the shared pool card renders it. Never carries a token. */
|
|
230
|
+
export interface WorkBuddyAccountSummaryDto extends PoolAccountSummaryDto {
|
|
231
|
+
region: WorkBuddyRegion;
|
|
232
|
+
/** Which store owns the credential; only managed accounts may be deleted. */
|
|
233
|
+
source: 'desktop' | 'managed';
|
|
234
|
+
/** Whether the card may offer Delete for this account. */
|
|
235
|
+
removable: boolean;
|
|
236
|
+
nickname?: string;
|
|
237
|
+
/** Tencent UIN, masked by the card rather than shown in full. */
|
|
238
|
+
uin?: string;
|
|
239
|
+
/** IDE file a desktop account was adopted from. */
|
|
240
|
+
sourceFile?: string;
|
|
241
|
+
/** Auth domain recorded in the credential, e.g. `copilot.tencent.com`. */
|
|
242
|
+
domain?: string;
|
|
243
|
+
/** Backend base URL the account's region resolves to. */
|
|
244
|
+
backend?: string;
|
|
245
|
+
/** Account kind the client reports, e.g. `personal`. */
|
|
246
|
+
accountType?: string;
|
|
247
|
+
/**
|
|
248
|
+
* Whether the plugin currently routes to this account.
|
|
249
|
+
*
|
|
250
|
+
* Distinct from the pool's `activeAccountId`: a hidden account keeps its
|
|
251
|
+
* place in the pool but is not offered for routing while hidden.
|
|
252
|
+
*/
|
|
253
|
+
hidden?: boolean;
|
|
254
|
+
/**
|
|
255
|
+
* Models this account is parked on, as the line's pool knows them.
|
|
256
|
+
*
|
|
257
|
+
* Line-private on purpose: the shared `PoolAccountSummaryDto` carries no
|
|
258
|
+
* per-model cooldown, because a model park is a fact about THIS gateway's
|
|
259
|
+
* account × model metering and nothing else. Widening the shared DTO would
|
|
260
|
+
* make every other line answer a field it never fills; this extension keeps
|
|
261
|
+
* the fact where it belongs and still reaches the routes and the card.
|
|
262
|
+
*/
|
|
263
|
+
modelCooldowns?: WorkBuddyModelCooldownDto[];
|
|
264
|
+
/**
|
|
265
|
+
* Account-scoped refusal the gateway reported, when it reported one.
|
|
266
|
+
*
|
|
267
|
+
* Distinct from both cooldowns above: a cooldown lifts on its own and parks
|
|
268
|
+
* one model or one account for a while, while a restriction says the account
|
|
269
|
+
* itself may not be served at all and the pool must stop selecting it.
|
|
270
|
+
*/
|
|
271
|
+
restriction?: WorkBuddyAccountRestrictionDto;
|
|
272
|
+
}
|
|
273
|
+
/** One point-in-time quota snapshot for the signed-in WorkBuddy account. */
|
|
274
|
+
export interface WorkBuddyAccountQuota {
|
|
275
|
+
account: WorkBuddyAccount;
|
|
276
|
+
/** Package name the billing service reports, e.g. `Free Plan Subscription`. */
|
|
277
|
+
packageName: string | null;
|
|
278
|
+
/** Total credits the package grants, as reported. */
|
|
279
|
+
totalCredits: number | null;
|
|
280
|
+
/** Credits remaining in the current cycle. */
|
|
281
|
+
remainingCredits: number | null;
|
|
282
|
+
/** Credits consumed in the current cycle. */
|
|
283
|
+
cycleUsedCredits: number | null;
|
|
284
|
+
/** Cycle allowance, when the service reports a per-cycle cap. */
|
|
285
|
+
cycleCredits: number | null;
|
|
286
|
+
/** Start of the current billing cycle, as Unix milliseconds. */
|
|
287
|
+
cycleStartsAt: number | null;
|
|
288
|
+
/** End of the current billing cycle, as Unix milliseconds. */
|
|
289
|
+
cycleEndsAt: number | null;
|
|
290
|
+
meters: WorkBuddyMeter[];
|
|
291
|
+
/** When this snapshot was read. */
|
|
292
|
+
fetchedAt: number;
|
|
293
|
+
/** Billing routes that answered, for diagnostics in the settings card. */
|
|
294
|
+
sources: string[];
|
|
295
|
+
}
|
|
296
|
+
/** Everything the settings card and the composer badge render. */
|
|
297
|
+
export interface WorkBuddyWebStatus extends Partial<AccountPoolStatusDto> {
|
|
298
|
+
enabled?: boolean;
|
|
299
|
+
authenticated: boolean;
|
|
300
|
+
hasCredentials: boolean;
|
|
301
|
+
/** Where credentials are read from; the local CodeBuddy auth directory. */
|
|
302
|
+
authDirectory: string;
|
|
303
|
+
/** Storage description for the plugin's own settings file. */
|
|
304
|
+
storagePath: string;
|
|
305
|
+
account: WorkBuddyAccount | null;
|
|
306
|
+
quota: WorkBuddyAccountQuota | null;
|
|
307
|
+
lastFetchedAt: number | null;
|
|
308
|
+
/**
|
|
309
|
+
* Whether a quota refresh is running behind this answer.
|
|
310
|
+
*
|
|
311
|
+
* The card renders the snapshot it already had instead of waiting on the
|
|
312
|
+
* upstream request; when this is true the client asks again shortly so the
|
|
313
|
+
* refreshed snapshot reaches the UI.
|
|
314
|
+
*/
|
|
315
|
+
quotaRefreshing?: boolean;
|
|
316
|
+
models: WorkBuddyModelOption[];
|
|
317
|
+
contextWindowOverrides: Record<string, number>;
|
|
318
|
+
defaultReasoningEffort: WorkBuddyReasoningEffort | null;
|
|
319
|
+
/** Account selected for model discovery and all requests; null means automatic. */
|
|
320
|
+
selectedAccountId: string | null;
|
|
321
|
+
/** Encrypted storage used for accounts added from this plugin. */
|
|
322
|
+
managedStoragePath: string;
|
|
323
|
+
/** Route the plugin currently serves; false when another plugin owns it. */
|
|
324
|
+
serving: boolean;
|
|
325
|
+
/** Diagnostic when the route is owned by a different adapter family. */
|
|
326
|
+
conflict: string | null;
|
|
327
|
+
/** Pool summaries the shared account card renders; empty without a pool. */
|
|
328
|
+
accounts?: WorkBuddyAccountSummaryDto[];
|
|
329
|
+
/** Aggregate daily check-in state; absent when the host predates check-in. */
|
|
330
|
+
checkin?: WorkBuddyCheckinSummary | null;
|
|
331
|
+
/** Which client identity chat requests present. */
|
|
332
|
+
outboundIdentity?: WorkBuddyOutboundSetting;
|
|
333
|
+
/** Local quota guardrails currently armed (all zero when off). */
|
|
334
|
+
guardrails?: WorkBuddyGuardrailsDto;
|
|
335
|
+
/**
|
|
336
|
+
* Whether this process holds the key that opens `$wbEncrypted` credentials.
|
|
337
|
+
*
|
|
338
|
+
* False with {@link sealedAccounts} above zero is the actionable state: the
|
|
339
|
+
* desktop client has sealed its tokens and nothing can read them yet.
|
|
340
|
+
*/
|
|
341
|
+
atRestKeySet?: boolean;
|
|
342
|
+
/** Sealed desktop credential files the last scan met. */
|
|
343
|
+
sealedAccounts?: number;
|
|
344
|
+
/** Why the last sealed file refused to open, when one did. */
|
|
345
|
+
sealedAccountsError?: string | null;
|
|
346
|
+
/**
|
|
347
|
+
* Whole-pool state: pause, restricted accounts, and where the pool is kept.
|
|
348
|
+
*
|
|
349
|
+
* Absent means the host predates pool persistence, which is not the same as
|
|
350
|
+
* "not paused" — a card must render nothing rather than "running".
|
|
351
|
+
*/
|
|
352
|
+
pool?: WorkBuddyPoolStateDto;
|
|
353
|
+
}
|
|
354
|
+
/** Patch accepted by the models/settings route. */
|
|
355
|
+
export interface WorkBuddySettingsUpdateDto {
|
|
356
|
+
enabled?: boolean;
|
|
357
|
+
enabledModelIds?: string[];
|
|
358
|
+
/** A number sets an override for that model; `null` restores the catalog default. */
|
|
359
|
+
contextWindowOverrides?: Record<string, number | null>;
|
|
360
|
+
defaultReasoningEffort?: WorkBuddyReasoningEffort | null;
|
|
361
|
+
selectedAccountId?: string | null;
|
|
362
|
+
/** Partial check-in update; omitted fields keep their stored value. */
|
|
363
|
+
checkin?: Partial<WorkBuddyCheckinSettings>;
|
|
364
|
+
/** Which client identity chat requests present. */
|
|
365
|
+
outboundIdentity?: WorkBuddyOutboundSetting;
|
|
366
|
+
/** Partial guardrail update; omitted fields keep their stored value. */
|
|
367
|
+
guardrails?: Partial<WorkBuddyGuardrailsDto>;
|
|
368
|
+
}
|
|
369
|
+
/** Result of a connection test against the upstream chat endpoint. */
|
|
370
|
+
export interface WorkBuddyConnectionDto {
|
|
371
|
+
connected: boolean;
|
|
372
|
+
account: WorkBuddyAccount | null;
|
|
373
|
+
/** Round-trip time of the probe request. */
|
|
374
|
+
latencyMs: number;
|
|
375
|
+
/** Model the probe asked for. */
|
|
376
|
+
model: string;
|
|
377
|
+
checkedAt: number;
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Gateway code for an account the subscription itself refuses to serve.
|
|
381
|
+
*
|
|
382
|
+
* Distinct from every code the host names elsewhere: `11102` is one model the
|
|
383
|
+
* region does not serve and `6004` is a usage window, while this one bars the
|
|
384
|
+
* ACCOUNT — the pool must stop selecting it rather than park one model on it.
|
|
385
|
+
*
|
|
386
|
+
* PROVENANCE — read from upstream source, not inferred:
|
|
387
|
+
*
|
|
388
|
+
* - `magpie-community/plugins` @ `1e7122e1`, `packages/workbuddy/index.mjs`
|
|
389
|
+
* L2770-2780 defines the code as the gateway's restricted-account signal
|
|
390
|
+
* (`RESTRICTED_CODE = 11140`) together with the wording a restricted account
|
|
391
|
+
* is answered with — the account is barred from being served, not one model
|
|
392
|
+
* parked.
|
|
393
|
+
* - `ardeyouxipianyi/workbuddy2api-hub` @ `1ea7f61e`, `wb_proxy.py`
|
|
394
|
+
* L14253-14333 handles the same code, so the classification (account-scoped
|
|
395
|
+
* rather than model-scoped) is corroborated by two independent clients rather
|
|
396
|
+
* than by a single reading.
|
|
397
|
+
*
|
|
398
|
+
* Still open, and stated as open: the exact `msg` text and the reset instant a
|
|
399
|
+
* LIVE gateway attaches to the code are a measurement this wave does not make.
|
|
400
|
+
* Treat `11140` as "account barred" — do not parse its message for a duration.
|
|
401
|
+
*/
|
|
402
|
+
export declare const WORKBUDDY_RESTRICTED_ACCOUNT_CODE: 11140;
|
|
403
|
+
/**
|
|
404
|
+
* One model an account is parked on, inside the account's own eligibility.
|
|
405
|
+
*
|
|
406
|
+
* The account can still serve every model NOT named here, which is why this is
|
|
407
|
+
* a list on the account rather than a second account-level cooldown: a card
|
|
408
|
+
* that only drew `cooldownUntil` would report the account as available while
|
|
409
|
+
* the one model the request wants is the one that is refused.
|
|
410
|
+
*/
|
|
411
|
+
export interface WorkBuddyModelCooldownDto {
|
|
412
|
+
/** Model id in the vocabulary of the catalog the pool routed with. */
|
|
413
|
+
model: string;
|
|
414
|
+
/** Unix milliseconds the park lifts; a past value is already lifted. */
|
|
415
|
+
cooldownUntil: number;
|
|
416
|
+
}
|
|
417
|
+
/** An account-scoped refusal, as the settings card reports it. */
|
|
418
|
+
export interface WorkBuddyAccountRestrictionDto {
|
|
419
|
+
/**
|
|
420
|
+
* Gateway code. {@link WORKBUDDY_RESTRICTED_ACCOUNT_CODE} is the one that
|
|
421
|
+
* bars the account itself; `11158` is the same shape for a single model an
|
|
422
|
+
* account has no entitlement for.
|
|
423
|
+
*/
|
|
424
|
+
code: number;
|
|
425
|
+
/** Upstream `msg` when one came with the code. Never a credential. */
|
|
426
|
+
message?: string;
|
|
427
|
+
/** Unix milliseconds the refusal lifts, when the gateway names one. */
|
|
428
|
+
until?: number;
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Whole-pool state the settings card and the composer badge read.
|
|
432
|
+
*
|
|
433
|
+
* A pause is a decision about the POOL — nothing is routable right now — and no
|
|
434
|
+
* per-account field can express it. Drawing "3 accounts available" while the
|
|
435
|
+
* pool is stopped for one restricted account is exactly the lie this exists to
|
|
436
|
+
* prevent, so the pause is reported on its own and the card renders it first.
|
|
437
|
+
*/
|
|
438
|
+
export interface WorkBuddyPoolStateDto {
|
|
439
|
+
/** Whether new requests are refused right now. */
|
|
440
|
+
paused: boolean;
|
|
441
|
+
/** Why the pool is paused, when it is. Composed by the host, never a token. */
|
|
442
|
+
pauseReason?: string;
|
|
443
|
+
/** Unix milliseconds the pause began. */
|
|
444
|
+
pausedSince?: number;
|
|
445
|
+
/**
|
|
446
|
+
* Unix milliseconds the pause lifts on its own. Absent means it does not lift
|
|
447
|
+
* without the user (every account restricted, or a manual pause).
|
|
448
|
+
*/
|
|
449
|
+
pausedUntil?: number;
|
|
450
|
+
/** Account ids currently barred by a {@link WorkBuddyAccountRestrictionDto}. */
|
|
451
|
+
restrictedAccountIds?: string[];
|
|
452
|
+
/**
|
|
453
|
+
* Which backend holds the pool document, and whether it encrypts it at rest.
|
|
454
|
+
*
|
|
455
|
+
* Deliberately the SHARED `PoolStorageDto` (`src/shared/contracts.ts`), not a
|
|
456
|
+
* line-private copy. The account-pool storage choice is one deployment fact —
|
|
457
|
+
* `mode: 'keyring' | 'credentials'` resolved to `backend: 'keyring' |
|
|
458
|
+
* 'credentials' | 'dpapi' | 'keychain'`, with `encrypted` and an
|
|
459
|
+
* `unavailable` reason code — and every line's card has to answer it the same
|
|
460
|
+
* way. A line-private shape would let a card name a store the host is not
|
|
461
|
+
* actually using, which is the one thing this field exists to prevent.
|
|
462
|
+
*
|
|
463
|
+
* Absent means the host predates pool persistence — not "unencrypted".
|
|
464
|
+
*/
|
|
465
|
+
storage?: PoolStorageDto;
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* The parks of one account that have not lifted yet.
|
|
469
|
+
*
|
|
470
|
+
* `now` is a parameter rather than a hidden `Date.now()` so one render walks a
|
|
471
|
+
* consistent instant. An expired park is dropped rather than reported: a card
|
|
472
|
+
* that lists a park that already lifted tells the user an eligible account is
|
|
473
|
+
* unavailable.
|
|
474
|
+
*/
|
|
475
|
+
export declare function liveWorkBuddyModelCooldowns(cooldowns: readonly WorkBuddyModelCooldownDto[] | undefined, now: number): WorkBuddyModelCooldownDto[];
|
|
476
|
+
/**
|
|
477
|
+
* Which wire protocol one model is served on.
|
|
478
|
+
*
|
|
479
|
+
* The subscription speaks two. OpenAI chat completions serves its own models;
|
|
480
|
+
* Anthropic's Messages shape serves the Claude models of the CHINA deployment,
|
|
481
|
+
* beside them on the same host. Everything downstream — routes, adapter,
|
|
482
|
+
* mapper — picks its path and its reasoning field from here, never from a model
|
|
483
|
+
* name spelled out again, so the two vocabularies cannot drift apart.
|
|
484
|
+
*/
|
|
485
|
+
export type WorkBuddyModelProtocol = 'chat-completions' | 'anthropic-messages';
|
|
486
|
+
/**
|
|
487
|
+
* Regions that answer `/v1/messages`.
|
|
488
|
+
*
|
|
489
|
+
* Measured on 2026-10-24: only the China deployment (`copilot.tencent.com`)
|
|
490
|
+
* serves Messages. The international deployment answers "404 Route Not Found"
|
|
491
|
+
* to `/v1/messages`, `/v2/messages` and `/v1/messages?beta=true` whatever
|
|
492
|
+
* the model, so a Claude model there stays on chat completions.
|
|
493
|
+
*
|
|
494
|
+
* Source: `magpie-community/plugins@1e7122e1`, `packages/workbuddy/index.mjs`
|
|
495
|
+
* L132-157 (`apiMessages` = `<endpoint>/v1`, `nativeOf`, and the 404 note).
|
|
496
|
+
*/
|
|
497
|
+
export declare const WORKBUDDY_MESSAGES_REGIONS: readonly WorkBuddyRegion[];
|
|
498
|
+
/**
|
|
499
|
+
* How each protocol accepts a reasoning level.
|
|
500
|
+
*
|
|
501
|
+
* This difference is why a Claude model is not merely a path change: chat
|
|
502
|
+
* completions takes a `reasoning_effort` field, while Anthropic's shape asks
|
|
503
|
+
* for thinking (`thinking.type: adaptive` plus `output_config.effort`). The
|
|
504
|
+
* upstream client measured the chat endpoint answering the same at every level,
|
|
505
|
+
* which is the other half of the same fact.
|
|
506
|
+
*
|
|
507
|
+
* Source: same file, L134-139.
|
|
508
|
+
*/
|
|
509
|
+
export declare const WORKBUDDY_PROTOCOL_REASONING: Readonly<Record<WorkBuddyModelProtocol, 'chat-effort' | 'anthropic-thinking'>>;
|
|
510
|
+
/** One model's route on one region, frozen for the mapper wave to consume. */
|
|
511
|
+
export interface WorkBuddyModelRouteDto {
|
|
512
|
+
/** Model id, in whichever vocabulary the caller resolved it. */
|
|
513
|
+
model: string;
|
|
514
|
+
region: WorkBuddyRegion;
|
|
515
|
+
protocol: WorkBuddyModelProtocol;
|
|
516
|
+
/** Reasoning field this protocol honours (see {@link WORKBUDDY_PROTOCOL_REASONING}). */
|
|
517
|
+
reasoning: 'chat-effort' | 'anthropic-thinking';
|
|
518
|
+
}
|
|
519
|
+
/** Whether a model id is Anthropic's own, which is what Messages routability keys on. */
|
|
520
|
+
export declare function isWorkBuddyClaudeModel(model: string): boolean;
|
|
521
|
+
/**
|
|
522
|
+
* Route one model on one region.
|
|
523
|
+
*
|
|
524
|
+
* The rule is the upstream client's own (`nativeOf`): a Claude model on a
|
|
525
|
+
* deployment that serves Messages goes to Messages; everything else — and every
|
|
526
|
+
* model on the international deployment — stays on chat completions. Total and
|
|
527
|
+
* pure, so the mapper wave never has to ask the network which path a model takes
|
|
528
|
+
* or re-derive the rule privately.
|
|
529
|
+
*/
|
|
530
|
+
export declare function workBuddyModelRoute(model: string, region: WorkBuddyRegion): WorkBuddyModelRouteDto;
|
|
531
|
+
//# sourceMappingURL=workbuddy-contracts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workbuddy-contracts.d.ts","sourceRoot":"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E,MAAM,EAAE,CAAA;IAC/B;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;CACzB;AAED;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,SAAS,yBAAyB,EAAE,GAAG,SAAS,EAC3D,GAAG,EAAE,MAAM,GACV,yBAAyB,EAAE,CAE7B;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,sBAAsB,GAAG,kBAAkB,GAAG,oBAAoB,CAAA;AAE9E;;;;;;;;;;GAUG;AACH,eAAO,MAAM,0BAA0B,EAAE,SAAS,eAAe,EAAW,CAAA;AAE5E;;;;;;;;;;GAUG;AACH,eAAO,MAAM,4BAA4B,EAAE,QAAQ,CACjD,MAAM,CAAC,sBAAsB,EAAE,aAAa,GAAG,oBAAoB,CAAC,CAIrE,CAAA;AAED,8EAA8E;AAC9E,MAAM,WAAW,sBAAsB;IACrC,gEAAgE;IAChE,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,eAAe,CAAA;IACvB,QAAQ,EAAE,sBAAsB,CAAA;IAChC,wFAAwF;IACxF,SAAS,EAAE,aAAa,GAAG,oBAAoB,CAAA;CAChD;AAED,yFAAyF;AACzF,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE7D;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,eAAe,GACtB,sBAAsB,CAMxB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eddyskywalker/dsh-chatgpt-subscription",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.47.0",
|
|
4
4
|
"description": "DSH provider plugin for Codex access through a ChatGPT subscription.",
|
|
5
5
|
"icon": "./icon.svg",
|
|
6
6
|
"author": {
|
|
@@ -46,7 +46,11 @@
|
|
|
46
46
|
"default": "./lib/progress-updates.js"
|
|
47
47
|
},
|
|
48
48
|
"./progress-updates/locale/*.json": "./locale/progress-updates/*.json",
|
|
49
|
-
"./progress-updates/icon": "./progress-updates.svg"
|
|
49
|
+
"./progress-updates/icon": "./progress-updates.svg",
|
|
50
|
+
"./plan-mode-pipeline": {
|
|
51
|
+
"types": "./lib/types/entry-plan-mode-pipeline.d.ts",
|
|
52
|
+
"default": "./lib/plan-mode-pipeline.js"
|
|
53
|
+
}
|
|
50
54
|
},
|
|
51
55
|
"dsh": {
|
|
52
56
|
"bundle": {
|
|
@@ -6,8 +6,9 @@
|
|
|
6
6
|
## 运行骨架
|
|
7
7
|
|
|
8
8
|
```
|
|
9
|
-
分诊(Triage) → 澄清访谈(Grill) → 规划(Plan) → 派发(Dispatch) → 审查(Review) → 验收(Accept) → 文档(Docs)
|
|
10
|
-
│ │
|
|
9
|
+
分诊(Triage) → 澄清访谈(Grill) → 计划模式(Plan Mode) → 规划(Plan) → 审批(Approve) → 派发(Dispatch) → 审查(Review) → 验收(Accept) → 文档(Docs)
|
|
10
|
+
│ │ │
|
|
11
|
+
│ │ └─ R9:只读探索与 decision-complete 计划都在计划模式内写,exit_plan_mode 是唯一审批出口
|
|
11
12
|
│ └─ 仅 L2 强制;L1 轻量;L0 跳过
|
|
12
13
|
└─ R0:判定 L0 / L1 / L2,决定后面阶段是否展开
|
|
13
14
|
```
|
|
@@ -32,6 +33,7 @@
|
|
|
32
33
|
| R7 | 主代理维护任务清单、决策记录与访谈结论 |
|
|
33
34
|
| R8 | 兜底需说明原因;**任务级、非会话级**——只覆盖触发它的那一个任务,下一个任务按 R0 重新分诊并恢复派发 |
|
|
34
35
|
| R-W | 回合边界纪律:等待靠完成通知而非 sleep/轮询;不主动建目标(清单走 `todo_write`);需要拍板一律用提问工具 |
|
|
36
|
+
| R9 | 计划模式管线:仅 L2 且 R-G 已收敛(前沿为空 + 用户明确确认)时立刻 `enter_plan_mode`;进入这一步只完成进入,下一步才做只读探索并在计划模式内写出 decision-complete 计划,`exit_plan_mode` 是该轮唯一且最后的调用;打回(Keep planning)= 按反馈修订后再呈交,放弃计划须用户明确表示并带 reason 调 `leave_plan_mode`(它不是审批出口);旧代或开关关闭时降级为用一次 `ask_user_question` 请用户输入 `/plan` |
|
|
35
37
|
|
|
36
38
|
## 回合边界(R-W)
|
|
37
39
|
|
|
@@ -78,7 +80,59 @@
|
|
|
78
80
|
自判身份,从而不套用面向调度者的 R0/R-G/R1/R2/R4/R5。若需要真正的子代理专属提示词,
|
|
79
81
|
需要在 DSH 侧扩展(`tool-subagent` 的 `persona` 只能整段覆盖,不适用于此)。
|
|
80
82
|
|
|
83
|
+
**计划模式管线的工具作用域 = preset 行**:`enter_plan_mode` / `leave_plan_mode` 由
|
|
84
|
+
`plan-mode-pipeline` 这一行在 `planning` 隔离组内注册(与 `plan-mode` 同一个 realm,排在其后),
|
|
85
|
+
所以它们只属于挂载了本 preset 的会话。换用其它 preset 的会话拿不到这两个工具,R9 在那里也无从执行。
|
|
86
|
+
|
|
87
|
+
**子代理不进入计划模式**:子代理由本会话 spawn,因此继承同一份 preset 组成,`enter_plan_mode` /
|
|
88
|
+
`leave_plan_mode` 在它的工具列表里**是可见的**——可见不等于可用。桥接能拦到哪一步取决于 harness 代际:
|
|
89
|
+
|
|
90
|
+
- **新代(能判定存活根)**——`agents` 服务在场且 `agents.roots()` 可用时,存活子代理的调用会以
|
|
91
|
+
`DELEGATED_CALLER` 被拒(这是该错误码唯一的抛出点);
|
|
92
|
+
- **老代(判不了根)**——`agents` 缺失,或有 `agents` 但 `roots` 不是函数时,桥接只判存活、判不了根
|
|
93
|
+
就**放行**,子代理的调用会真的切换它自己的计划模式。
|
|
94
|
+
|
|
95
|
+
所以**不要依赖这道拒绝**:子代理无论如何都不得自行进入计划模式、也不得提交计划,必须把未决决定
|
|
96
|
+
——包括「要不要进入计划模式」这个请求——带回调度者,由调度者走 R9;persona 的 R9 段末有一条同名条款
|
|
97
|
+
钉住这件事。任务书里不要要求子代理「进入计划模式」,它是执行者,只按任务书干活并回报证据。
|
|
98
|
+
|
|
99
|
+
**旧代 harness 或开关关闭时降级**:工具列表里没有 `enter_plan_mode`(插件不支持该行的旧代 harness,
|
|
100
|
+
或 `planModePipeline` 开关关闭导致该行不注册工具)时,退化路径是用一次 `ask_user_question` 请用户手动
|
|
101
|
+
输入 `/plan`,然后按已配置的 `plan-mode` section 继续;不得把计划直接贴在普通回复里代替审批。
|
|
102
|
+
|
|
103
|
+
## 缓存成本与两处压缩
|
|
104
|
+
|
|
105
|
+
Kimi 线路按请求内容前缀命中缓存:**同一会话内 system 段或工具列表一变,整个前缀缓存归零**
|
|
106
|
+
(见根 `README.md`)。「进入计划模式」这一步两样都会变——`plan-mode` 的 section 换新,
|
|
107
|
+
`exit_plan_mode` 第一次进入工具表——所以这一次重建**无法避免**,换任何写法都躲不掉。
|
|
108
|
+
|
|
109
|
+
能压的只有**重建之后每一步都还要重发的字节**。于是做了两处压缩:
|
|
110
|
+
|
|
111
|
+
| 位置 | 改前 | 改后 | 性质 |
|
|
112
|
+
|---|---|---|---|
|
|
113
|
+
| `agent.cordis.yml` 的 `plan-mode` section | 2627 字符(约 660 tokens) | 309 字符(一句话,保留五条护栏) | 计划模式期间**每一步**都渲染 |
|
|
114
|
+
| `enter_plan_mode` / `leave_plan_mode` 工具描述 | 772 / 424 字符 | ≤ 380 / ≤ 220 字符 | 常驻(随每一步的工具表重发) |
|
|
115
|
+
| `enter_plan_mode` 的返回文本 | 约 400 字符 | ≤ 1400 字符 | **末尾追加**,不破坏前缀 |
|
|
116
|
+
|
|
117
|
+
- **section 压成一句话**:它同时是**用户手动 `/plan` 那条路径上唯一的护栏**(那条路没有工具返回
|
|
118
|
+
兜底),所以五条规则原样留在句子里——留在计划模式直到经 `exit_plan_mode` 提交计划;「去实现」
|
|
119
|
+
按「去规划」处理;对话里的确认只是一个设计决定,不是批准计划;只读探索(不改文件、不跑会重写
|
|
120
|
+
已跟踪文件的命令);批准前不实施。
|
|
121
|
+
- **只读与「批准前不实施」为什么留在 section 而不是只搬去工具返回**:`enter_plan_mode` 的返回里
|
|
122
|
+
确实有这两条,但那条返回只有模型调用工具时才会出现。而用户手动 `/plan` 是 R9 写明的**显式降级入口**
|
|
123
|
+
(旧代 harness 没有 `enter_plan_mode`,或 `planModePipeline` 开关关闭),那条路上永远没有
|
|
124
|
+
工具返回。只把这两条放在返回里,等于把用户送上一条没有「不许写文件」提示的路。所以 section 保留
|
|
125
|
+
一份压缩副本,长度预算从 ≤220 放宽到 **≤360**:多付约 105 字符(≈26 tokens),且只在计划模式
|
|
126
|
+
期间渲染。
|
|
127
|
+
- **详细指引搬进工具返回**:只读探索的完整版(不改文件、不跑会重写工作区文件的命令)、decision-complete
|
|
128
|
+
计划清单、`exit_plan_mode` 是该轮唯一且最后的调用、被打回则按反馈修订后再呈交、批准前不实施
|
|
129
|
+
不派发,都写在 `enter_plan_mode` 的返回里。工具结果是末尾追加,不改变已发前缀,所以这份详细
|
|
130
|
+
指引只付一次,进入之后的每一步都还能看到它。
|
|
131
|
+
- **工具描述只留判定条件**:能不能调用(仅调度模式、仅 L2 且 R-G 已收敛、本步只完成进入、L0/L1
|
|
132
|
+
或访谈未收敛时不得调用)留在描述里,其余交给 persona 的 R9——persona 反正常驻,搬过去不增加
|
|
133
|
+
新的常驻成本。
|
|
134
|
+
|
|
81
135
|
## 刻意不配置的项
|
|
82
136
|
|
|
83
137
|
- `tool-subagent.config.agentOptions` — 硬绑 `provider`/`model` 会架空 R2。
|
|
84
|
-
- `tool-subagent.config.persona` — 会给所有子代理强行打同一角色,违反 R4。
|
|
138
|
+
- `tool-subagent.config.persona` — 会给所有子代理强行打同一角色,违反 R4。
|