dsh-context 0.54.4 → 0.56.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/lib/index.d.ts CHANGED
@@ -1,37 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import "@deepseek-ai/dsh-session";
3
+ import z$1 from "@deepseek-ai/schemastery";
3
4
  import { Context } from "@deepseek-ai/cordis";
4
- //#region src/host/config.d.ts
5
- export interface Config {
6
- /** Cap on kept per-step request records (the hard step backstop). */
7
- maxRequestSteps?: number;
8
- /** Newest whole-turn window kept; trimming crosses whole turns, never mid-turn. */
9
- maxKeptTurns?: number;
10
- maxEvents?: number;
11
- /**
12
- * Served surface nodes (newest carry the signal; live inject nodes are pinned — they land first and are few). Deliberately generous:
13
- * auto-compaction keeps healthy surfaces far below it, so the browser effectively lists every live node; the bound is a
14
- * pathological-session backstop (each push ships the whole value, ~150B/node).
15
- */
16
- maxNodes?: number;
17
- /** Removed (shadowed) surface nodes kept for per-step reconstruction. */
18
- maxArchiveNodes?: number;
19
- /** Fold-derived file-operation records kept (the File Activity card's raw material). */
20
- maxFileOps?: number;
21
- }
22
- /**
23
- * The cordis `Config` validator: strict on keys, defaults on the schema fields; tolerates `undefined` (a patch row without a `config:`
24
- * block — defaults win).
25
- */
26
- export declare const Config: z.ZodPreprocess<z.ZodObject<{
27
- maxRequestSteps: z.ZodDefault<z.ZodNumber>;
28
- maxKeptTurns: z.ZodDefault<z.ZodNumber>;
29
- maxEvents: z.ZodDefault<z.ZodNumber>;
30
- maxNodes: z.ZodDefault<z.ZodNumber>;
31
- maxArchiveNodes: z.ZodDefault<z.ZodNumber>;
32
- maxFileOps: z.ZodDefault<z.ZodNumber>;
33
- }, z.core.$strict>>;
34
- //#endregion
35
5
  //#region src/host/activity.d.ts
36
6
  /** The persisted fold state (the registry's `stateSchema` contract). */
37
7
  interface ActivityState {
@@ -65,15 +35,6 @@ interface HeadersState {
65
35
  headers: StoredHeaderRecord[];
66
36
  }
67
37
  //#endregion
68
- //#region src/host/logShapes.d.ts
69
- /**
70
- * The decode bucket a stream's `block-start.blockType` names: the model's
71
- * thinking, the answer text, or the tool-call arguments. Undefined for an
72
- * unknown/hostile marker, whose interval then stays unattributed rather than
73
- * poisoning a bucket.
74
- */
75
- type DecodeKind = 'reasoning' | 'text' | 'toolarg';
76
- //#endregion
77
38
  //#region src/host/fold.d.ts
78
39
  /**
79
40
  * History retention bounds (configurable since 0.11 — see config.ts; these
@@ -91,9 +52,8 @@ interface TimelineState {
91
52
  sums: Record<Category, number>;
92
53
  systemTokens: number;
93
54
  /**
94
- * The live system-prompt nodes, oldest first — a V3 log's `system/message`
95
- * surface nodes, or the single entry a V0/V2 `request/header.header.system`
96
- * envelope defines. `systemTokens` is the LAST entry with tokens > 0 (the
55
+ * The live system-prompt nodes, oldest first — a log's `system/message`
56
+ * surface nodes. `systemTokens` is the LAST entry with tokens > 0 (the
97
57
  * harness's own "last nonempty surviving system" rule), so an empty dormant
98
58
  * node keeps its position without clearing the prompt. Bounded by
99
59
  * SYSTEM_NODES_MAX. ABSENT on rows folded before this field existed — the
@@ -101,16 +61,6 @@ interface TimelineState {
101
61
  * epoch's own envelope figure.
102
62
  */
103
63
  systems?: SystemPromptNode[];
104
- /**
105
- * Whether `systems` was built from the V0/V2 request ENVELOPE
106
- * (`header.system`) rather than from V3 `system/message` events. Only then
107
- * may a system-less header CLEAR the list: its canonical V0 meaning is
108
- * "this request has no system prompt", while a V3 header never carries one
109
- * (its prompt lives in the message history). Absent = log-sourced, and
110
- * never materialized as an `undefined`-valued property (plain-JSON
111
- * precondition — see the note above `model`).
112
- */
113
- systemsFromHeader?: true;
114
64
  toolsTokens: number;
115
65
  /**
116
66
  * The projection-cache precondition is plain JSON: a property whose value
@@ -127,6 +77,16 @@ interface TimelineState {
127
77
  lastModel?: string;
128
78
  contextWindow?: number;
129
79
  requests: RequestRecord[];
80
+ /**
81
+ * The number of turn runs in `requests` (a run = consecutive records
82
+ * sharing one `turn`). Maintained incrementally at the single append site
83
+ * and recomputed when a trim replaces the array, so the retention trim's
84
+ * cap check stays O(1) per event instead of walking every retained
85
+ * request. Absent on rows folded before the field existed — the first
86
+ * post-restore event recomputes it once (the same additive-optional shape
87
+ * as `detailRev`).
88
+ */
89
+ turnRuns?: number;
130
90
  events: ContextEventRecord[];
131
91
  /**
132
92
  * Recently removed surface nodes (stamped COPIES carrying `gone`), in
@@ -180,28 +140,16 @@ interface TimelineState {
180
140
  /**
181
141
  * The open step's start instant, armed by `step/start` and consumed by the
182
142
  * `assistant/message` (TTFT/generation split) and `step/end` (wall time)
183
- * that follow it; `assistant/chunk` stamps `firstToken` on the step's first
184
- * token delta — absent when the stream carried none (legacy or aborted
185
- * steps), which leaves that call's model time unattributed. One slot, not a
186
- * map: steps are sequential in the log, so the newest `step/start` is the
187
- * one those events close — a hostile interleaved log degrades to skipped
188
- * durations, never to unbounded state. Same arm/remove lifecycle as
189
- * `pendingShadowedSeqs`.
190
- *
191
- * `decode` and `block` carry the generation split (reasoning / answer text /
192
- * tool arguments — see TimingTotals): a V0 log's `assistant/chunk`
193
- * `block-start` markers open `block` and close the previous one into
194
- * `decode`; a V2+ log carries no such events, so `decode` stays absent and
195
- * `assistant/message` reads the spans off its embedded stream instead.
143
+ * that follow it; the message's embedded stream stamps `firstToken` —
144
+ * absent when the stream carried none (an aborted step), which leaves that
145
+ * call's model time unattributed. One slot, not a map: steps are sequential
146
+ * in the log, so the newest `step/start` is the one those events close — a
147
+ * hostile interleaved log degrades to skipped durations, never to
148
+ * unbounded state. Same arm/remove lifecycle as `pendingShadowedSeqs`.
196
149
  */
197
150
  stepStart?: {
198
151
  time: number;
199
152
  firstToken?: number;
200
- decode?: Record<DecodeKind, number>;
201
- block?: {
202
- kind: DecodeKind;
203
- since: number;
204
- };
205
153
  };
206
154
  /**
207
155
  * Tool callId → the call's name, start instant, and raw arguments, armed by
@@ -307,8 +255,7 @@ type Category = 'user' | 'inject' | 'skill' | 'assistant' | 'tool';
307
255
  /**
308
256
  * One live system-prompt node (Snapshot.systems) — the harness models the
309
257
  * system prompt as a surface node, so its TEXT is fetched on demand from the
310
- * event at `seq`: a V3 `system/message` event, or the V0/V2 `request/header`
311
- * whose envelope carried `header.system`. `tokens` is the node's heuristic
258
+ * `system/message` event at `seq`. `tokens` is the node's heuristic
312
259
  * price (0 for a dormant empty node, which the harness reads as "no system
313
260
  * prompt"); the effective figure is the LAST node with `tokens > 0`.
314
261
  */
@@ -362,6 +309,23 @@ interface ActivityDay {
362
309
  interface ContextActivity {
363
310
  days: Record<string, ActivityDay>;
364
311
  }
312
+ /**
313
+ * The per-user display-preference vocabulary of the `dsh-context` settings
314
+ * namespace — the ONE declaration both halves share: the Host registers the
315
+ * namespace schema against it (host/settings.ts), the Client binds the scope
316
+ * and edits fields by name (client/settings.ts). Type-only, so both bundles
317
+ * erase it.
318
+ */
319
+ type DefaultGranularity = 'step' | 'turn';
320
+ type DefaultTrendMode = 'total' | 'delta';
321
+ /** File Activity row order: most operations first, most-recently-touched first, or path ascending. */
322
+ type DefaultFileSort = 'count' | 'latest' | 'path';
323
+ /** Tool-definition row order: largest schema first, most call hits first, or name ascending. */
324
+ type DefaultToolSort = 'size' | 'count' | 'name';
325
+ /** Where the Context view is offered: the conversation tab, the right Sidebar, or both. */
326
+ type DefaultPlacement = 'all' | 'tab' | 'sidebar';
327
+ /** Whether the Context Insights panel's sidebar entry is offered at all. */
328
+ type InsightsEntry = 'show' | 'hide';
365
329
  interface Snapshot {
366
330
  ok: boolean;
367
331
  /**
@@ -450,9 +414,9 @@ interface Snapshot {
450
414
  timing?: TimingTotals;
451
415
  /**
452
416
  * The live system-prompt nodes, oldest first — the browser's per-step source
453
- * for the System section. Absent when the log carried no system prompt, and
454
- * on older plugin builds (the client then falls back to the header epoch's
455
- * own `systemTokens`, the pre-V3 shape).
417
+ * for the System section. Absent on rows folded before this field existed
418
+ * (older plugin builds; the client then falls back to the header epoch's
419
+ * own `systemTokens`, the legacy wire shape those builds served).
456
420
  */
457
421
  systems?: SystemPromptNode[];
458
422
  /**
@@ -534,7 +498,7 @@ interface ContextTimelineDetail {
534
498
  * One executed file operation (a settled file-tool call with a resolved
535
499
  * target), folded host-side from the durable tool lifecycle: the call's
536
500
  * name+arguments (`tool/call`), the result's presentation meta and error
537
- * (`tool/result`), or a nested Code-Mode settle (`tool/code-dispatch`,
501
+ * (`tool/result`), or a nested Code-Mode settle (`tool/ptc-dispatch`,
538
502
  * located on its parent run_code result via `parent` + `program`).
539
503
  *
540
504
  * `gone` is NOT host-stamped: the client joins it from the detail's archive
@@ -602,10 +566,9 @@ interface ToolTimingTotals {
602
566
  * Whole-session timing totals, host-folded from the durable `step/start` /
603
567
  * `step/end` / `tool/call` / `tool/result` lifecycle plus the model call's
604
568
  * first token (running totals over the COMPLETE session log — the same
605
- * never-trimmed framing as `cost`). The first token comes from a V0
606
- * `assistant/chunk` delta or from the call's own embedded stream
607
- * (`assistant/message.data.stream` / `assistant/attempt.data.stream`, the
608
- * V2+ settlement) — whichever the log carries, matching the harness's own
569
+ * never-trimmed framing as `cost`). The first token comes from the call's
570
+ * own embedded stream (`assistant/message.data.stream` /
571
+ * `assistant/attempt.data.stream`), matching the harness's own
609
572
  * session-stats fold. Durations are wall-clock milliseconds: `wallMs` sums
610
573
  * whole steps, `ttftMs` the step-start → first-token slice (the model wait)
611
574
  * and `genMs` the first-token → assistant-message slice (the generation) —
@@ -634,10 +597,22 @@ interface TimingTotals {
634
597
  genMs: number;
635
598
  /** Reasoning-decode slice of `genMs` (the model's thinking). */
636
599
  reasoningMs?: number;
600
+ /** Counted reasoning-decode blocks (the Thinking slice's tally). */
601
+ reasoningBlocks?: number;
637
602
  /** Answer-text decode slice of `genMs`. */
638
603
  textMs?: number;
604
+ /** Counted answer-text decode blocks (the Answer slice's tally). */
605
+ textBlocks?: number;
639
606
  /** Tool-call-argument decode slice of `genMs`. */
640
607
  toolArgMs?: number;
608
+ /**
609
+ * Counted tool-call-argument decode blocks — one per tool call whose
610
+ * arguments the stream decoded (the Tool args slice's tally). The counts are
611
+ * ADDITIVE-OPTIONAL like their spans: a row cached before they existed (or a
612
+ * call whose stream framed no blocks) carries none, and the card qualifies
613
+ * only what was actually counted.
614
+ */
615
+ toolArgBlocks?: number;
641
616
  /**
642
617
  * The decode-throughput seat, paired exactly as the harness's own
643
618
  * session-stats fold pairs them: `speedTokens` sums provider-reported
@@ -833,6 +808,65 @@ interface PlatformBalance {
833
808
  balances: PlatformBalanceEntry[];
834
809
  }
835
810
  //#endregion
811
+ //#region src/host/config.d.ts
812
+ export interface Config {
813
+ /** Cap on kept per-step request records (the hard step backstop). */
814
+ maxRequestSteps?: number;
815
+ /** Newest whole-turn window kept; trimming crosses whole turns, never mid-turn. */
816
+ maxKeptTurns?: number;
817
+ maxEvents?: number;
818
+ /**
819
+ * Served surface nodes (newest carry the signal; live inject nodes are pinned — they land first and are few). Deliberately generous:
820
+ * auto-compaction keeps healthy surfaces far below it, so the browser effectively lists every live node; the bound is a
821
+ * pathological-session backstop (each push ships the whole value, ~150B/node).
822
+ */
823
+ maxNodes?: number;
824
+ /** Removed (shadowed) surface nodes kept for per-step reconstruction. */
825
+ maxArchiveNodes?: number;
826
+ /** Fold-derived file-operation records kept (the File Activity card's raw material). */
827
+ maxFileOps?: number;
828
+ /** Where the Context view is offered (the conversation tab, the right Sidebar, or both). */
829
+ defaultPlacement?: DefaultPlacement;
830
+ /** Timeline default granularity (per step or per turn). */
831
+ defaultGranularity?: DefaultGranularity;
832
+ /** Timeline default trend mode (total or delta). */
833
+ defaultTrendMode?: DefaultTrendMode;
834
+ /** Tool-definition row default order. */
835
+ defaultToolSort?: DefaultToolSort;
836
+ /** File Activity row default order. */
837
+ defaultFileSort?: DefaultFileSort;
838
+ /** Whether the Context Insights panel's sidebar entry is offered. */
839
+ insightsEntry?: InsightsEntry;
840
+ }
841
+ /** The cordis `Config` validator and the Config-form generation's served schema. */
842
+ export declare const Config: z$1<Schemastery.ObjectS<NoInfer<{
843
+ maxRequestSteps: z$1<number, number, Mode extends "volatile" | "volatile-defined" ? "volatile-defined" : "defined">;
844
+ maxKeptTurns: z$1<number, number, Mode extends "volatile" | "volatile-defined" ? "volatile-defined" : "defined">;
845
+ maxEvents: z$1<number, number, Mode extends "volatile" | "volatile-defined" ? "volatile-defined" : "defined">;
846
+ maxNodes: z$1<number, number, Mode extends "volatile" | "volatile-defined" ? "volatile-defined" : "defined">;
847
+ maxArchiveNodes: z$1<number, number, Mode extends "volatile" | "volatile-defined" ? "volatile-defined" : "defined">;
848
+ maxFileOps: z$1<number, number, Mode extends "volatile" | "volatile-defined" ? "volatile-defined" : "defined">;
849
+ defaultPlacement: z$1<"all" | "sidebar" | "tab", "all" | "sidebar" | "tab", Mode>;
850
+ defaultGranularity: z$1<"step" | "turn", "step" | "turn", Mode>;
851
+ defaultTrendMode: z$1<"delta" | "total", "delta" | "total", Mode>;
852
+ defaultToolSort: z$1<"count" | "name" | "size", "count" | "name" | "size", Mode>;
853
+ defaultFileSort: z$1<"count" | "latest" | "path", "count" | "latest" | "path", Mode>;
854
+ insightsEntry: z$1<"hide" | "show", "hide" | "show", Mode>;
855
+ }>>, Schemastery.ObjectT<NoInfer<{
856
+ maxRequestSteps: z$1<number, number, Mode extends "volatile" | "volatile-defined" ? "volatile-defined" : "defined">;
857
+ maxKeptTurns: z$1<number, number, Mode extends "volatile" | "volatile-defined" ? "volatile-defined" : "defined">;
858
+ maxEvents: z$1<number, number, Mode extends "volatile" | "volatile-defined" ? "volatile-defined" : "defined">;
859
+ maxNodes: z$1<number, number, Mode extends "volatile" | "volatile-defined" ? "volatile-defined" : "defined">;
860
+ maxArchiveNodes: z$1<number, number, Mode extends "volatile" | "volatile-defined" ? "volatile-defined" : "defined">;
861
+ maxFileOps: z$1<number, number, Mode extends "volatile" | "volatile-defined" ? "volatile-defined" : "defined">;
862
+ defaultPlacement: z$1<"all" | "sidebar" | "tab", "all" | "sidebar" | "tab", Mode>;
863
+ defaultGranularity: z$1<"step" | "turn", "step" | "turn", Mode>;
864
+ defaultTrendMode: z$1<"delta" | "total", "delta" | "total", Mode>;
865
+ defaultToolSort: z$1<"count" | "name" | "size", "count" | "name" | "size", Mode>;
866
+ defaultFileSort: z$1<"count" | "latest" | "path", "count" | "latest" | "path", Mode>;
867
+ insightsEntry: z$1<"hide" | "show", "hide" | "show", Mode>;
868
+ }>>, "plain">;
869
+ //#endregion
836
870
  //#region src/host/index.d.ts
837
871
  export declare const name = "dsh-context";
838
872
  export declare const inject: string[];