dsh-context 0.78.1 → 0.78.2
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/lib/client.js +25 -25
- package/lib/index.d.ts +7 -214
- package/lib/index.js +7 -7
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* dsh-context v0.78.
|
|
2
|
+
* dsh-context v0.78.2
|
|
3
3
|
* A DeepSeek Harness plugin for context insight and management, with context dashboard and context command, for understanding how the context is made of, and how it evolves.
|
|
4
4
|
* @author bowenliang123
|
|
5
5
|
* @license Apache-2.0
|
|
6
6
|
* @homepage https://github.com/bowenliang123/dsh-context
|
|
7
|
-
* @built 2026-10-
|
|
8
|
-
* @commit
|
|
9
|
-
* @commit-date 2026-10-
|
|
7
|
+
* @built 2026-10-30T01:32:55+00:00
|
|
8
|
+
* @commit 32982aa6aa2c
|
|
9
|
+
* @commit-date 2026-10-30T09:30:00+08:00
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import { z } from "zod";
|
|
@@ -19,17 +19,13 @@ interface ToolStart {
|
|
|
19
19
|
}
|
|
20
20
|
interface ActivityState {
|
|
21
21
|
days: Record<string, ActivityDay>;
|
|
22
|
-
/** The route in force (the last `request/header`'s config wins) — prices each settlement. */
|
|
23
22
|
model?: string;
|
|
24
23
|
provider?: string;
|
|
25
24
|
stepStart?: number;
|
|
26
|
-
/** The last turn whose first settlement was booked, so a multi-step turn counts once. */
|
|
27
25
|
lastTurn?: number;
|
|
28
26
|
toolStarts?: Record<string, ToolStart | undefined>;
|
|
29
|
-
/** Pending `skill`-tool call ids: the wrapper match alone is not trusted, or a `read` quoting it would book a load. */
|
|
30
27
|
skillCalls?: string[];
|
|
31
28
|
}
|
|
32
|
-
/** v1 rows carried the producer description and raw schema; later folds append metadata-only. */
|
|
33
29
|
interface StoredHeaderTool {
|
|
34
30
|
name: string;
|
|
35
31
|
tokens: number;
|
|
@@ -37,7 +33,6 @@ interface StoredHeaderTool {
|
|
|
37
33
|
plugin?: string;
|
|
38
34
|
schema?: unknown;
|
|
39
35
|
}
|
|
40
|
-
/** v1 rows carried `system`; later folds carry `systemTokens`. */
|
|
41
36
|
interface StoredHeaderRecord {
|
|
42
37
|
seq: number;
|
|
43
38
|
time: number;
|
|
@@ -48,121 +43,71 @@ interface StoredHeaderRecord {
|
|
|
48
43
|
interface HeadersState {
|
|
49
44
|
headers: StoredHeaderRecord[];
|
|
50
45
|
}
|
|
51
|
-
/** The state's command record: the wire record plus the callId the fold pairs result/job events on. Never served —
|
|
52
|
-
* `foldWire` strips it (optional precisely so the strip is a plain `delete`). */
|
|
53
46
|
interface CommandStateRecord extends CommandRecord {
|
|
54
47
|
call?: string;
|
|
55
48
|
}
|
|
56
49
|
interface TimelineState {
|
|
57
|
-
/** Model-visible surface, newest last. */
|
|
58
50
|
surface: SurfaceNode[];
|
|
59
51
|
sums: Record<Category, number>;
|
|
60
|
-
/** Live assistant-node reasoning price — a running subset of `sums.assistant` (the thinking split's prompt-side share). */
|
|
61
52
|
assistantReasoning: number;
|
|
62
|
-
/** Live assistant-node text price — a running subset of `sums.assistant` (the answers split's prompt-side share). */
|
|
63
53
|
assistantAnswerTokens: number;
|
|
64
|
-
/** Live assistant-node tool-call price — a running subset of `sums.assistant` (the tool-call split's prompt-side share). */
|
|
65
54
|
assistantCallTokens: number;
|
|
66
55
|
systemTokens: number;
|
|
67
|
-
/** The live system-prompt nodes, oldest first; `systemTokens` is the LAST nonempty one (the harness rule), so an empty dormant node
|
|
68
|
-
* keeps its position. Absent rows fall back to the header epoch's envelope figure. */
|
|
69
56
|
systems?: SystemPromptNode[];
|
|
70
57
|
toolsTokens: number;
|
|
71
|
-
/** The projection cache requires plain JSON: an `undefined`-valued property fails EVERY cache write for the session, so optional fields
|
|
72
|
-
* stay absent until a value is known. */
|
|
73
58
|
model?: string;
|
|
74
59
|
provider?: string;
|
|
75
|
-
/** Last-wins: a header without an effort clears it. */
|
|
76
60
|
reasoningEffort?: string;
|
|
77
61
|
lastModel?: string;
|
|
78
62
|
contextWindow?: number;
|
|
79
|
-
/** The newest `request/header` envelope's routed output cap (dsh materializes the adapter default into it). Last-wins: a header
|
|
80
|
-
* omitting the cap clears it. */
|
|
81
63
|
maxOutputTokens?: number;
|
|
82
64
|
requests: RequestRecord[];
|
|
83
|
-
/** Turn runs in `requests` (consecutive records sharing one `turn`), maintained at the single append site and recomputed on trim, so
|
|
84
|
-
* the cap check stays O(1); absent on older rows. */
|
|
85
65
|
turnRuns?: number;
|
|
86
66
|
events: ContextEventRecord[];
|
|
87
|
-
/** Removed surface nodes as stamped COPIES carrying `gone`, in removal order; bounded to `maxArchiveNodes` and pruned to removals after
|
|
88
|
-
* the oldest retained request. */
|
|
89
67
|
archived: SurfaceNode[];
|
|
90
|
-
/** Cumulative billed-token totals per (provider, model, period); never trimmed, so the estimate covers the COMPLETE log. */
|
|
91
68
|
cost?: SessionCostUsage;
|
|
92
|
-
/** Cumulative generated reasoning price over the COMPLETE log (the thinking split's output side); never trimmed. */
|
|
93
69
|
generatedReasoning?: number;
|
|
94
|
-
/** Cumulative generated text price over the COMPLETE log (the answers split's output side); never trimmed. */
|
|
95
70
|
generatedAnswerTokens?: number;
|
|
96
|
-
/** Cumulative generated tool-call price over the COMPLETE log (the tool-call split's output side); never trimmed. */
|
|
97
71
|
generatedCallTokens?: number;
|
|
98
72
|
humanInputs?: number;
|
|
99
73
|
answers?: number;
|
|
100
|
-
/** The user's newest own message as a bounded one-line preview. Last-wins: a text-less input keeps the previous line. */
|
|
101
74
|
lastUser?: string;
|
|
102
75
|
archiveFloor?: number;
|
|
103
|
-
/** Bumped when a fold mutates the served detail (requests, events, live surface, archive); the slim head carries it. */
|
|
104
76
|
detailRev?: number;
|
|
105
|
-
/** Whole-session timing totals, running sums over the COMPLETE log like `cost`. */
|
|
106
77
|
timing?: TimingTotals;
|
|
107
|
-
/** The open step's start instant, armed by `step/start` and consumed by the following `assistant/message` and `step/end`; one slot, not
|
|
108
|
-
* a map, so a hostile interleaved log degrades to skipped durations. */
|
|
109
78
|
stepStart?: {
|
|
110
79
|
time: number;
|
|
111
80
|
firstToken?: number;
|
|
112
81
|
};
|
|
113
|
-
/** The open step's CLOSED user-wait intervals; `step/end` subtracts their clamped union from the step window to price `activeMs`, then
|
|
114
|
-
* deletes the slot. */
|
|
115
82
|
stepWaits?: {
|
|
116
83
|
start: number;
|
|
117
84
|
end: number;
|
|
118
85
|
}[];
|
|
119
|
-
/** The open step's PENDING approval waits (request id → `approval/asked` instant); a crash mid-decision leaves the pair dangling, so
|
|
120
|
-
* `step/end` closes the survivors at its own instant. */
|
|
121
86
|
stepApprovals?: Record<string, number>;
|
|
122
|
-
/** The seq of the request record the open step's `assistant/message` committed — the back-pointer `step/end` stamps `activeMs` onto;
|
|
123
|
-
* nothing pushes between a step's message and its end, so the stamp is an O(1) tail write. */
|
|
124
87
|
stepRequestSeq?: number;
|
|
125
|
-
|
|
126
|
-
|
|
88
|
+
stepBeats?: number[];
|
|
89
|
+
stepBeatsFull?: boolean;
|
|
127
90
|
spans: TimingSpan[];
|
|
128
|
-
/** The open step's accumulated spans; `step/end` clamps them into the step window, de-overlaps first-wins (parallel runs paint their
|
|
129
|
-
* union), fills holes with the residue kind, then deletes the slot (plain-JSON precondition). */
|
|
130
91
|
stepSpans?: TimingSpan[];
|
|
131
|
-
/** Tool callId → name, start instant and raw arguments, armed by `tool/call` and DELETED when its `tool/result` folds in — the map
|
|
132
|
-
* stays at pending-call size instead of growing for the session's lifetime. */
|
|
133
92
|
callNames: Record<string, {
|
|
134
93
|
name: string;
|
|
135
94
|
start: number;
|
|
136
95
|
argsRaw?: string;
|
|
137
96
|
}>;
|
|
138
|
-
/** Seq list the next replacement shadows, armed by the metering event and consumed by the replacement that must follow synchronously;
|
|
139
|
-
* it can differ from the replacement's declared range (pruned nodes keep their own seqs). */
|
|
140
97
|
pendingShadowedSeqs?: number[];
|
|
141
|
-
/** The metering event whose `tokens` the shadowed path rewrites from gross shadow price to the NET freed amount. */
|
|
142
98
|
pendingShadowEventSeq?: number;
|
|
143
99
|
fileOps: FileOpRecord[];
|
|
144
|
-
/** The newest dropped op's seq (the card's coverage floor for the served op log). */
|
|
145
100
|
fileOpsFloor?: number;
|
|
146
|
-
/** The command log, in call order (creation at `tool/call`, settle in place at `tool/result`/`job/settled`). */
|
|
147
101
|
commands: CommandStateRecord[];
|
|
148
|
-
/** The newest dropped command record's seq (the panel's coverage floor). */
|
|
149
102
|
commandsFloor?: number;
|
|
150
|
-
/** Whole-log execution tallies; each record contributes exactly once, at its running → terminal transition. */
|
|
151
103
|
commandStats?: CommandStats;
|
|
152
|
-
/** Nested Code-Mode command records buffered by their top run_code call id until the parent's result folds
|
|
153
|
-
* (same lifecycle as `pendingCodeOps`). */
|
|
154
104
|
pendingCodeCmds?: Record<string, CommandStateRecord[]>;
|
|
155
|
-
/** Nested Code-Mode ops buffered by their top run_code call id until the parent's result folds (the dispatch events land BEFORE it).
|
|
156
|
-
* Bounded by PENDING_CODE_OPS_MAX, so a hostile log that never settles a run_code cannot grow it. */
|
|
157
105
|
pendingCodeOps?: Record<string, FileOpRecord[]>;
|
|
158
106
|
}
|
|
159
107
|
declare module '@deepseek-ai/dsh-session-projection/types' {
|
|
160
108
|
interface SessionProjectionMap {
|
|
161
|
-
/** Slim head on the split generation, inline value on channel-less hosts; key absence = no host half. */
|
|
162
109
|
contextTimeline: ContextTimeline;
|
|
163
|
-
/** Epoch metadata in its own unit so the hot timeline stays lean; key absence = an older host (tokens only). */
|
|
164
110
|
contextHeaders: ContextHeaders;
|
|
165
|
-
/** The per-day activity ledger; key absence = an older host (empty heatmap). */
|
|
166
111
|
contextActivity: ContextActivity;
|
|
167
112
|
}
|
|
168
113
|
interface SessionProjectionStateMap {
|
|
@@ -171,80 +116,56 @@ declare module '@deepseek-ai/dsh-session-projection/types' {
|
|
|
171
116
|
contextActivity: ActivityState;
|
|
172
117
|
}
|
|
173
118
|
}
|
|
174
|
-
/** `skill` is the harness-injected skill machinery: the `<available_skills>` digest, a `/name` invocation's instructions, and a
|
|
175
|
-
* `skill`-tool load. */
|
|
176
119
|
type Category = 'user' | 'inject' | 'skill' | 'assistant' | 'tool';
|
|
177
|
-
/** Its TEXT comes from the `system/message` event at `seq`; the effective figure is the LAST node with `tokens > 0`. */
|
|
178
120
|
interface SystemPromptNode {
|
|
179
121
|
seq: number;
|
|
180
122
|
time: number;
|
|
181
123
|
tokens: number;
|
|
182
124
|
}
|
|
183
|
-
/** Counts over the RETAINED records; `steps` is the retained request-record count. */
|
|
184
125
|
interface TimelineCounts {
|
|
185
126
|
turns: number;
|
|
186
127
|
steps: number;
|
|
187
128
|
injects: number;
|
|
188
129
|
compactions: number;
|
|
189
130
|
prunes: number;
|
|
190
|
-
/** Distinct names among the retained events tagged `sub: 'skill'`; the digest has none and never counts. Absent = 0. */
|
|
191
131
|
skills?: number;
|
|
192
132
|
}
|
|
193
|
-
/** The newest retained request record's billing summary. */
|
|
194
133
|
interface TimelineLast {
|
|
195
134
|
seq: number;
|
|
196
135
|
total: number;
|
|
197
136
|
prompt?: number;
|
|
198
137
|
}
|
|
199
138
|
interface ActivityDay {
|
|
200
|
-
/** Billed tokens that day (input + cache read/write + output); a settlement-less request counts only toward `requests`. */
|
|
201
139
|
tokens: number;
|
|
202
|
-
/** Completed model calls (assistant settlements) that day. */
|
|
203
140
|
requests: number;
|
|
204
|
-
/** Keyed provider → model → pricing period, scoped to the day the requests INITIATED. Absent = tokens-only bars. */
|
|
205
141
|
cost?: SessionCostUsage;
|
|
206
|
-
/** Turns whose FIRST settlement landed on this (step-initiation) day. */
|
|
207
142
|
turns?: number;
|
|
208
|
-
/** Completed tool runs whose step STARTED that day. */
|
|
209
143
|
toolCalls?: number;
|
|
210
|
-
/** Summed tool-run durations for those runs, in ms. */
|
|
211
144
|
toolsMs?: number;
|
|
212
|
-
/** Summed wall time of steps that ENDED, charged to the day their step STARTED, in ms. */
|
|
213
145
|
wallMs?: number;
|
|
214
|
-
/** Skill name → `{ n: loads, last: last-load instant in epoch ms }`; absent = an empty day. */
|
|
215
146
|
skills?: Record<string, {
|
|
216
147
|
n: number;
|
|
217
148
|
last: number;
|
|
218
149
|
}>;
|
|
219
150
|
}
|
|
220
|
-
/** Host-local day key (`YYYY-MM-DD`, shared/days.ts) → that day's billed volume; the Insights page merges every listed ledger. */
|
|
221
151
|
interface ContextActivity {
|
|
222
152
|
days: Record<string, ActivityDay>;
|
|
223
153
|
}
|
|
224
|
-
/** Served by `/api/dsh-context/skills` (host/skills.ts); every field but `name` is best-effort. */
|
|
225
154
|
interface SkillInfo {
|
|
226
|
-
/** Kebab-case identifier — the join key onto `ActivityDay.skills`. */
|
|
227
155
|
name: string;
|
|
228
156
|
description: string;
|
|
229
|
-
/** Absolute instruction file path, when the provider is filesystem-backed. */
|
|
230
157
|
path?: string;
|
|
231
|
-
/** Discovery source bucket ('project-agents', 'user-dsh', 'bundled', …). */
|
|
232
158
|
source?: string;
|
|
233
159
|
}
|
|
234
|
-
/** The ONE declaration shared by the Host Config schema (host/config.ts) and the Client's settings form. */
|
|
235
160
|
type DefaultGranularity = 'step' | 'turn';
|
|
236
161
|
type DefaultTrendMode = 'total' | 'delta';
|
|
237
|
-
/** The browser delta baseline: the immediately preceding record, or the previous turn's last step. */
|
|
238
162
|
type DefaultDeltaBase = 'step' | 'turn';
|
|
239
163
|
type DefaultFileSort = 'count' | 'lines' | 'latest' | 'path' | 'name';
|
|
240
164
|
type DefaultToolSort = 'size' | 'count' | 'name';
|
|
241
|
-
/** Where the Context panel mounts; 'hide' registers no surface. */
|
|
242
165
|
type DefaultPlacement = 'all' | 'tab' | 'sidebar' | 'hide';
|
|
243
166
|
type InsightsEntry = 'show' | 'hide';
|
|
244
167
|
type DefaultDurationCurve = 'show' | 'hide';
|
|
245
|
-
/** Retained-step count at which the trend turns its Overview ribbon on; 'off' never auto-switches. */
|
|
246
168
|
type OverviewAutoSteps = 'off' | '100' | '200' | '300';
|
|
247
|
-
/** The Insights page's rolling preset; a calendar-picked range replaces it for that visit only. */
|
|
248
169
|
type DefaultOverviewRange = 'today' | '7d' | '30d' | 'all';
|
|
249
170
|
type FleetTab = 'show' | 'hide';
|
|
250
171
|
interface PluginSettings {
|
|
@@ -259,26 +180,19 @@ interface PluginSettings {
|
|
|
259
180
|
overviewAutoSteps: OverviewAutoSteps;
|
|
260
181
|
defaultOverviewRange: DefaultOverviewRange;
|
|
261
182
|
fleetTab: FleetTab;
|
|
262
|
-
/** Free text joined ahead of the harness's assembled system prompt; empty disables. */
|
|
263
183
|
promptPrefix: string;
|
|
264
|
-
/** Free text joined behind the harness's assembled system prompt; empty disables. */
|
|
265
184
|
promptSuffix: string;
|
|
266
185
|
}
|
|
267
186
|
interface Snapshot {
|
|
268
187
|
ok: boolean;
|
|
269
|
-
/** Present ONLY below the supported baseline: the host folds nothing (all figures zero) and the client shows the upgrade gate. */
|
|
270
188
|
unsupported?: {
|
|
271
189
|
current: string;
|
|
272
190
|
minimum: string;
|
|
273
191
|
};
|
|
274
192
|
model?: string;
|
|
275
193
|
provider?: string;
|
|
276
|
-
/** The newest request envelope's materialized reasoning effort. Absent = no effort in force, or a row folded before the field
|
|
277
|
-
* existed. */
|
|
278
194
|
reasoningEffort?: string;
|
|
279
195
|
contextWindow?: number;
|
|
280
|
-
/** The newest request envelope's routed output cap (auto-compaction reserves it). Absent = no cap in the log, or a row folded before
|
|
281
|
-
* the field existed. */
|
|
282
196
|
maxOutputTokens?: number;
|
|
283
197
|
current: {
|
|
284
198
|
system: number;
|
|
@@ -287,77 +201,42 @@ interface Snapshot {
|
|
|
287
201
|
inject: number;
|
|
288
202
|
skill: number;
|
|
289
203
|
assistant: number;
|
|
290
|
-
/** Heuristic reasoning tokens INSIDE the live assistant nodes — a subset of `assistant` (the thinking split's prompt-side share).
|
|
291
|
-
* Absent on rows folded before the field existed, and on foreign hosts. */
|
|
292
204
|
assistantReasoning?: number;
|
|
293
|
-
/** Heuristic text-block tokens INSIDE the live assistant nodes — a subset of `assistant` (the answers split's prompt-side share).
|
|
294
|
-
* Absent on rows folded before the field existed, and on foreign hosts. */
|
|
295
205
|
assistantAnswerTokens?: number;
|
|
296
|
-
/** Heuristic tool-call tokens INSIDE the live assistant nodes — a subset of `assistant` (the tool-call split's prompt-side share).
|
|
297
|
-
* Absent on rows folded before the field existed, and on foreign hosts. */
|
|
298
206
|
assistantCallTokens?: number;
|
|
299
207
|
tool: number;
|
|
300
208
|
total: number;
|
|
301
209
|
};
|
|
302
|
-
/** Image blocks in the CURRENT context (uploads plus nested tool-result images). Absent = 0. */
|
|
303
210
|
images?: number;
|
|
304
|
-
/** Heuristic reasoning tokens GENERATED across the complete log (the thinking split's output side; a provider `reasoningTokens` count
|
|
305
|
-
* wins when reported). Absent = none. */
|
|
306
211
|
generatedReasoning?: number;
|
|
307
|
-
/** Heuristic text-block tokens GENERATED across the complete log (the answers split's output side). Absent = none. */
|
|
308
212
|
generatedAnswerTokens?: number;
|
|
309
|
-
/** Heuristic tool-call tokens GENERATED across the complete log (the tool-call split's output side). Absent = none. */
|
|
310
213
|
generatedCallTokens?: number;
|
|
311
|
-
/** Tool calls whose result is live (a `skill`-tool node keeps counting). Absent = 0. */
|
|
312
214
|
toolCalls?: number;
|
|
313
|
-
/** Whole-session tally of non-injection `user/message` plus answered `ask_user_question` over the COMPLETE log. Absent = 0. */
|
|
314
215
|
humanInputs?: number;
|
|
315
|
-
/** Whole-session replies: one per assistant message carrying non-blank text (tool-only steps are not replies). Absent = 0. */
|
|
316
216
|
answers?: number;
|
|
317
|
-
/** The newest own message as a one-line preview (first text block, whitespace collapsed, 80 chars max). Absent = hidden. */
|
|
318
217
|
lastUser?: string;
|
|
319
|
-
/** Split-generation head fields: present exactly when the host serves the slim head; `detailRev` bumps whenever the detail collections
|
|
320
|
-
* change. */
|
|
321
218
|
counts?: TimelineCounts;
|
|
322
219
|
last?: TimelineLast;
|
|
323
220
|
detailRev?: number;
|
|
324
|
-
/** The slim head serves these EMPTY (collections ride the detail channel): the client swaps in the detail payload's. */
|
|
325
221
|
requests: RequestRecord[];
|
|
326
222
|
events: ContextEventRecord[];
|
|
327
|
-
/** Cumulative session-cost raw material; absent until a request with a known model reports usage. */
|
|
328
223
|
cost?: SessionCostUsage;
|
|
329
|
-
/** Whole-session timing totals; absent until the first step lifecycle completes. */
|
|
330
224
|
timing?: TimingTotals;
|
|
331
|
-
/** The live system-prompt nodes, oldest first. Absent on rows folded before the field existed: the client then reads the header epoch's
|
|
332
|
-
* `systemTokens`. */
|
|
333
225
|
systems?: SystemPromptNode[];
|
|
334
|
-
/** The served live surface: the newest `maxNodes` tail PLUS every older live inject/skill node (they land first and are pinned).
|
|
335
|
-
* Seq-ordered, oldest first. */
|
|
336
226
|
nodes: SurfaceNode[];
|
|
337
|
-
/** Live nodes not served: the overflow beyond `maxNodes` minus the pinned inject/skill nodes. */
|
|
338
227
|
droppedNodes: number;
|
|
339
|
-
/** Recently REMOVED surface nodes stamped with `gone` (the replacing event's seq); a node belongs to request R when `seq < R.seq &&
|
|
340
|
-
* (gone undefined || gone > R.seq)`. */
|
|
341
228
|
archive: SurfaceNode[];
|
|
342
|
-
/** Newest seq among the `droppedNodes` nodes not served; present only when droppedNodes > 0. */
|
|
343
229
|
surfaceFloor?: number;
|
|
344
|
-
/** Newest `gone` among retention-dropped archive entries; steps below it may miss removed nodes. */
|
|
345
230
|
archiveFloor?: number;
|
|
346
|
-
/** The fold-derived file-op log and trim floor: INLINE value and detail payload only, never the slim head. */
|
|
347
231
|
fileOps?: FileOpRecord[];
|
|
348
232
|
fileOpsFloor?: number;
|
|
349
|
-
/** The fold-derived command log and its trim floor/coverage honesty, same channel as `fileOps`. */
|
|
350
233
|
commands?: CommandRecord[];
|
|
351
234
|
commandsFloor?: number;
|
|
352
|
-
/** Whole-log execution tallies behind the command panel's title; survives list trimming. */
|
|
353
235
|
commandStats?: CommandStats;
|
|
354
|
-
/** INLINE value and detail payload only; absent on rows folded before the collection existed. */
|
|
355
236
|
spans?: TimingSpan[];
|
|
356
237
|
}
|
|
357
|
-
/** The split generation's DETAIL payload (host/detail.ts); `rev` mirrors the head's `detailRev` and is the client's latest-wins cursor. */
|
|
358
238
|
interface ContextTimelineDetail {
|
|
359
239
|
rev: number;
|
|
360
|
-
/** The slim head at the SAME fold cut; a cold-listed session has no `contextTimeline` row, so the Agent network ring reads this. */
|
|
361
240
|
head?: ContextTimeline;
|
|
362
241
|
requests: RequestRecord[];
|
|
363
242
|
events: ContextEventRecord[];
|
|
@@ -366,87 +245,54 @@ interface ContextTimelineDetail {
|
|
|
366
245
|
archive: SurfaceNode[];
|
|
367
246
|
surfaceFloor?: number;
|
|
368
247
|
archiveFloor?: number;
|
|
369
|
-
/** The file-op log (shared/fileOps.ts) over the FULL log; Code-Mode nested dispatches book on their parent `run_code` result. */
|
|
370
248
|
fileOps?: FileOpRecord[];
|
|
371
|
-
/** The newest dropped op's seq when the op log trimmed (coverage honesty, same family as `archiveFloor`). */
|
|
372
249
|
fileOpsFloor?: number;
|
|
373
|
-
/** The command log (shared/commands.ts); nested Code-Mode dispatches flush on their parent `run_code` result. */
|
|
374
250
|
commands?: CommandRecord[];
|
|
375
|
-
/** The newest dropped record's seq when the command log trimmed. */
|
|
376
251
|
commandsFloor?: number;
|
|
377
252
|
commandStats?: CommandStats;
|
|
378
|
-
/** The completed steps' time slices in log order, positioned by their real instants. Absent = no strip. */
|
|
379
253
|
spans?: TimingSpan[];
|
|
380
254
|
}
|
|
381
255
|
type CommandStatus = 'running' | 'completed' | 'failed' | 'killed';
|
|
382
|
-
/** One shell/code execution, folded from `tool/call` (creation) paired with `tool/result` and — on hosts that log them —
|
|
383
|
-
* `job/registered` / `job/settled` (precise timing and outcome). Without job events the timing/exit are envelope-derived
|
|
384
|
-
* (`derived: true`). Nested Code-Mode dispatches carry `parent` (their run_code result's seq, the locate target).
|
|
385
|
-
* `gone` is client-joined, not host-stamped. */
|
|
386
256
|
interface CommandRecord {
|
|
387
|
-
/** The call event's seq — the record's stable identity. */
|
|
388
257
|
seq: number;
|
|
389
|
-
/** The result event's seq — the surface node a reveal targets. Absent while running and on nested Code-Mode records
|
|
390
|
-
* (those reveal on `parent`). */
|
|
391
258
|
resultSeq?: number;
|
|
392
|
-
/** The call event's instant — the list's chronological anchor. */
|
|
393
259
|
time: number;
|
|
394
260
|
tool: string;
|
|
395
|
-
/** The command text (a run_code record carries the program's source), capped at the fold's maxCommandChars. */
|
|
396
261
|
cmd: string;
|
|
397
262
|
cmdTruncated?: true;
|
|
398
|
-
/** The model-authored intent (bash/pwsh require it; persistent shells and run_code may omit it). */
|
|
399
263
|
description?: string;
|
|
400
|
-
/** The result meta's cwd when logged, else the workdir argument; absent = the session's cwd. */
|
|
401
264
|
cwd?: string;
|
|
402
265
|
timeoutMs?: number;
|
|
403
|
-
/** Dispatched to the background (an acked result with no outcome yet shows running until a `job/settled` lands). */
|
|
404
266
|
background?: true;
|
|
405
|
-
/** The requested sandbox escalation, when the call carried one. */
|
|
406
267
|
sandbox?: string;
|
|
407
|
-
/** A nested Code-Mode dispatch record. */
|
|
408
268
|
codeMode?: true;
|
|
409
269
|
parent?: number;
|
|
410
270
|
turn?: number;
|
|
411
271
|
step?: number;
|
|
412
|
-
/** job.startedAt when registered, else the call instant. */
|
|
413
272
|
start: number;
|
|
414
|
-
/** job.finishedAt when settled, else the result instant; absent while running. */
|
|
415
273
|
end?: number;
|
|
416
274
|
status: CommandStatus;
|
|
417
|
-
/** Explicit exit code from a marker or job detail; absent = unknown (never fabricate a 0). */
|
|
418
275
|
exit?: number;
|
|
419
|
-
/** The exit 0 was inferred from the ABSENCE of any marker (the shell tools omit the marker on a clean exit). */
|
|
420
276
|
exitInferred?: true;
|
|
421
277
|
signal?: string;
|
|
422
278
|
timedOut?: true;
|
|
423
279
|
stopped?: true;
|
|
424
280
|
denied?: true;
|
|
425
|
-
/** The result message's isError (an infrastructure failure, not a command failure). */
|
|
426
281
|
err: boolean;
|
|
427
282
|
outChars?: number;
|
|
428
283
|
outTruncated?: true;
|
|
429
284
|
stderr?: true;
|
|
430
|
-
/** Timing/exit derive from event envelopes — no job events on this log (parallel calls can overstate durations). */
|
|
431
285
|
derived?: true;
|
|
432
286
|
gone?: number;
|
|
433
287
|
}
|
|
434
|
-
/** Whole-log execution tallies, maintained incrementally: `runs`/`failed`/`ms` at each record's terminal transition,
|
|
435
|
-
* `bg` when a background dispatch becomes known (the argument at creation, else the hand-off ack). */
|
|
436
288
|
interface CommandStats {
|
|
437
289
|
runs: number;
|
|
438
|
-
/** Failed OR killed terminal outcomes. */
|
|
439
290
|
failed: number;
|
|
440
|
-
/** Summed execution ms over records with both endpoints known (concurrent runs double-count wall time). */
|
|
441
291
|
ms: number;
|
|
442
|
-
/** Runs dispatched to the background, whether or not they ever settle. */
|
|
443
292
|
bg: number;
|
|
444
293
|
}
|
|
445
|
-
/** Folded from the durable tool lifecycle (`tool/call` + `tool/result`, or a nested `tool/ptc-dispatch`); line deltas are estimates off
|
|
446
|
-
* the call ARGUMENTS. `gone` is client-joined, not host-stamped. */
|
|
447
294
|
interface FileOpRecord {
|
|
448
295
|
seq: number;
|
|
449
|
-
/** The op's file; for a pathless search the searched PATTERN (`pattern: true`). */
|
|
450
296
|
path: string;
|
|
451
297
|
kind: 'read' | 'write' | 'search';
|
|
452
298
|
tool: string;
|
|
@@ -454,11 +300,8 @@ interface FileOpRecord {
|
|
|
454
300
|
err: boolean;
|
|
455
301
|
added: number;
|
|
456
302
|
removed: number;
|
|
457
|
-
/** The searched pattern, with the include filter when one narrowed the call. */
|
|
458
303
|
detail?: string;
|
|
459
|
-
/** Meta-attributed search op only: matched lines the result reported for this file. */
|
|
460
304
|
hits?: number;
|
|
461
|
-
/** Read ops only: the exact 1-based window the result meta reported, else the `limit`-argument estimate (`est: true`). */
|
|
462
305
|
read?: {
|
|
463
306
|
start: number;
|
|
464
307
|
count: number;
|
|
@@ -466,26 +309,17 @@ interface FileOpRecord {
|
|
|
466
309
|
count: number;
|
|
467
310
|
est: true;
|
|
468
311
|
};
|
|
469
|
-
/** Nested Code-Mode op only: the run_code result node the op ran under (the locate target). */
|
|
470
312
|
parent?: number;
|
|
471
|
-
/** Nested Code-Mode op only: the run_code program's model-authored description. */
|
|
472
313
|
program?: string;
|
|
473
|
-
/** The searched-pattern marker: `path` is a pattern, not a file — display must not relativize it. */
|
|
474
314
|
pattern?: true;
|
|
475
|
-
/** Client-joined archive stamp (see the type note); absent on the wire. */
|
|
476
315
|
gone?: number;
|
|
477
316
|
}
|
|
478
|
-
/** The `contextTimeline` projection's whole value; `ok` is always `true` here (kept for wire compatibility). */
|
|
479
317
|
type ContextTimeline = Snapshot;
|
|
480
|
-
/** One painted span of the timing strip (TTFT wait, decode block, tool-run window, or residue gap); `start`/`end` are REAL instants,
|
|
481
|
-
* packed gapless in log order, and `end` > `start` always. */
|
|
482
318
|
interface TimingSpan {
|
|
483
|
-
/** The timing card's own slice vocabulary (same keys, same colors). */
|
|
484
319
|
kind: 'ttft' | 'reasoning' | 'text' | 'toolarg' | 'tools' | 'other';
|
|
485
320
|
start: number;
|
|
486
321
|
end: number;
|
|
487
322
|
}
|
|
488
|
-
/** One pricing bucket's cumulative billed tokens: a running total over the COMPLETE session log, never trimmed. */
|
|
489
323
|
interface CostBucketTotals {
|
|
490
324
|
uncached: number;
|
|
491
325
|
cacheRead: number;
|
|
@@ -496,10 +330,6 @@ interface ToolTimingTotals {
|
|
|
496
330
|
calls: number;
|
|
497
331
|
ms: number;
|
|
498
332
|
}
|
|
499
|
-
/** Whole-session totals over the COMPLETE log: `wallMs` whole steps, `ttftMs` step-start → decode-start, `genMs`
|
|
500
|
-
* decode-start → assistant-message, `toolsMs` per-call and `toolBusyMs` per-step union. The decode window opens at the
|
|
501
|
-
* first OBSERVABLE instant, so marker-tiled windows never double-count; speed* keep the first-token anchor;
|
|
502
|
-
* `calls`/`toolCalls` count messages/pairs. */
|
|
503
333
|
interface TimingTotals {
|
|
504
334
|
wallMs: number;
|
|
505
335
|
ttftMs: number;
|
|
@@ -514,21 +344,15 @@ interface TimingTotals {
|
|
|
514
344
|
speedMs?: number;
|
|
515
345
|
calls: number;
|
|
516
346
|
toolsMs: number;
|
|
517
|
-
/** Wall time with at least one tool running: parallel runs overlap once, and runs outside every step window price
|
|
518
|
-
* nothing. Absent on rows folded before the field existed (the card attributes the clamped per-call sum instead). */
|
|
519
347
|
toolBusyMs?: number;
|
|
348
|
+
idleMs?: number;
|
|
520
349
|
toolCalls: number;
|
|
521
|
-
/** Per-tool-name tallies behind the timing card's ranking (bounded). */
|
|
522
350
|
tools: Record<string, ToolTimingTotals>;
|
|
523
351
|
}
|
|
524
|
-
/** One billed model's totals split by pricing period: period-less providers book everything under `peak`; DeepSeek's `peak` prices at
|
|
525
|
-
* twice the list (off-peak) rate, `off` at list. */
|
|
526
352
|
interface CostModelUsage {
|
|
527
353
|
peak?: CostBucketTotals;
|
|
528
354
|
off?: CostBucketTotals;
|
|
529
355
|
}
|
|
530
|
-
/** Cumulative provider-reported billed tokens keyed by the request envelope's DSH provider id ('' when none) then model id — the faces
|
|
531
|
-
* the Client's models.dev price book resolves. */
|
|
532
356
|
interface SessionCostUsage {
|
|
533
357
|
[provider: string]: {
|
|
534
358
|
[model: string]: CostModelUsage;
|
|
@@ -539,19 +363,12 @@ interface SurfaceNode {
|
|
|
539
363
|
time?: number;
|
|
540
364
|
cat: Category;
|
|
541
365
|
tokens: number;
|
|
542
|
-
/** Reasoning-block price inside an assistant node (absent when zero); a subset of `tokens`. */
|
|
543
366
|
reasoning?: number;
|
|
544
|
-
/** Text-block price inside an assistant node (absent when zero); a subset of `tokens`. */
|
|
545
367
|
answerTokens?: number;
|
|
546
|
-
/** Tool-call price inside an assistant node (absent when zero); a subset of `tokens`. */
|
|
547
368
|
callTokens?: number;
|
|
548
|
-
/** Image blocks inside this node's message (absent when zero). */
|
|
549
369
|
imgs?: number;
|
|
550
|
-
/** Set only on `archive` entries: the seq of the replacement event that shadowed this node. */
|
|
551
370
|
gone?: number;
|
|
552
371
|
form?: string;
|
|
553
|
-
/** The producer identity the matching inject event names (host pricing.ts `injectionSourceName`); absent when unreadable or predating
|
|
554
|
-
* the stamp. */
|
|
555
372
|
name?: string;
|
|
556
373
|
text?: string;
|
|
557
374
|
tool?: string;
|
|
@@ -559,7 +376,6 @@ interface SurfaceNode {
|
|
|
559
376
|
skill?: string;
|
|
560
377
|
calls?: string[];
|
|
561
378
|
}
|
|
562
|
-
/** One answered model call (a step); consecutive records of one turn form it. */
|
|
563
379
|
interface RequestRecord {
|
|
564
380
|
turn?: number;
|
|
565
381
|
step?: number;
|
|
@@ -573,17 +389,11 @@ interface RequestRecord {
|
|
|
573
389
|
tool: number;
|
|
574
390
|
total: number;
|
|
575
391
|
prompt?: number;
|
|
576
|
-
/** Skill-machinery tokens of this request; absent on rows folded before the category existed (read as 0). */
|
|
577
392
|
skill?: number;
|
|
578
|
-
/** Billed cache-read (served) prompt tokens — the hit-rate numerator against `prompt`; absent on older hosts, and zero is a real value.
|
|
579
|
-
*/
|
|
580
393
|
cacheRead?: number;
|
|
581
394
|
output?: number;
|
|
582
|
-
/** The step's ACTIVE ms (`step/start` → `step/end` minus in-step user waits), stamped at `step/end`; absent while the step is open. */
|
|
583
395
|
activeMs?: number;
|
|
584
|
-
/** Turn-mode aggregate marker, set by the Client's aggregateByTurn (the Host never sets it). */
|
|
585
396
|
stepCount?: number;
|
|
586
|
-
/** Delta-mode signed net change, set by the Client's deltaOf (the Host never sets it). */
|
|
587
397
|
net?: number;
|
|
588
398
|
}
|
|
589
399
|
interface ContextEventRecord {
|
|
@@ -598,62 +408,45 @@ interface ContextEventRecord {
|
|
|
598
408
|
detail?: string;
|
|
599
409
|
from?: string;
|
|
600
410
|
to?: string;
|
|
601
|
-
/** Turn/step of the request logged right BEFORE the event (host-stamped). */
|
|
602
411
|
fromTurn?: number;
|
|
603
412
|
fromStep?: number;
|
|
604
|
-
/** Turn/step of the request this event contributed to (host-stamped). */
|
|
605
413
|
turn?: number;
|
|
606
414
|
step?: number;
|
|
607
415
|
}
|
|
608
416
|
interface HeaderTool {
|
|
609
417
|
name: string;
|
|
610
418
|
tokens: number;
|
|
611
|
-
/** The registering plugin's label: `mcp:<server>` for MCP tools, or the pinned first-party map; `UNKNOWN_TOOL_SOURCE` marks a boot-time
|
|
612
|
-
* tool, absent = no tag. */
|
|
613
419
|
plugin?: string;
|
|
614
420
|
}
|
|
615
|
-
/** One request-header epoch's METADATA, in force from this seq until the next. CONTENT is deliberately not projected (every list row
|
|
616
|
-
* would carry it) and is fetched as a {@link HeaderEpochContent}. */
|
|
617
421
|
interface HeaderRecord {
|
|
618
422
|
seq: number;
|
|
619
423
|
time: number;
|
|
620
|
-
/** The epoch's estimated system-prompt tokens; absent when it logged no system prompt. */
|
|
621
424
|
systemTokens?: number;
|
|
622
425
|
tools: HeaderTool[];
|
|
623
426
|
}
|
|
624
|
-
/** The `contextHeaders` projection value: the bounded epoch list (newest last). */
|
|
625
427
|
interface ContextHeaders {
|
|
626
428
|
headers: HeaderRecord[];
|
|
627
429
|
}
|
|
628
430
|
interface PlatformBalanceEntry {
|
|
629
|
-
/** The ISO code the platform reported (`CNY` / `USD`). */
|
|
630
431
|
currency: string;
|
|
631
|
-
/** `granted` + `toppedUp`, derived rather than read from the platform's `total_balance`, which rounds independently of its parts. */
|
|
632
432
|
total: number;
|
|
633
433
|
granted: number;
|
|
634
434
|
toppedUp: number;
|
|
635
435
|
}
|
|
636
|
-
/** The DeepSeek open-platform balance, served by `/api/dsh-context/balance`; `null` on the wire (nothing rendered) when unconfigured or
|
|
637
|
-
* the read fails. */
|
|
638
436
|
interface PlatformBalance {
|
|
639
437
|
isAvailable: boolean;
|
|
640
|
-
/** One entry per currency the account holds; at least one. */
|
|
641
438
|
balances: PlatformBalanceEntry[];
|
|
642
439
|
}
|
|
643
440
|
declare const DEFAULT_BOUNDS: {
|
|
644
441
|
maxRequestSteps: number;
|
|
645
|
-
/** Newest whole-turn window kept; trimming crosses whole turns, never mid-turn. */
|
|
646
442
|
maxKeptTurns: number;
|
|
647
443
|
maxEvents: number;
|
|
648
|
-
/** Pathological-session backstop only: each push ships the whole value (~150B/node). */
|
|
649
444
|
maxNodes: number;
|
|
650
445
|
maxArchiveNodes: number;
|
|
651
446
|
maxFileOps: number;
|
|
652
447
|
maxCommands: number;
|
|
653
|
-
/** The command text caps per record; the card offers the full text through the browser's message body. */
|
|
654
448
|
maxCommandChars: number;
|
|
655
449
|
};
|
|
656
|
-
/** The resolved fold bounds; derived from {@link DEFAULT_BOUNDS} so the two cannot drift. */
|
|
657
450
|
type FoldBounds = typeof DEFAULT_BOUNDS;
|
|
658
451
|
export type Config = Partial<FoldBounds> & Partial<PluginSettings>;
|
|
659
452
|
export declare const Config: z$1<Schemastery.ObjectS<NoInfer<{
|