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