@huanlin/dsh-plugin-yet-another-subagent 0.3.0 → 0.4.1

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.
@@ -1,214 +1,200 @@
1
- /**
2
- * Two session projections (design doc §3.6):
3
- *
4
- * - `subagentProfile` (parent session): fold `tool/call` (name `subagent`,
5
- * profile in `arguments.profile`) + the matching `tool/result.subagentId`,
6
- * building a `childId → profileId` map. Used as a cross-check / fallback
7
- * for SubagentCard (which usually reads `profileLabel` straight from the
8
- * result content).
9
- *
10
- * - `yaSubagentProgress` (child session): toolcall count, token usage,
11
- * and lifecycle state. Pushed over the projection frame so the parent's
12
- * SubagentCard can subscribe even though client runtime drops non-current
13
- * `session/event` frames (single-stage model).
14
- *
15
- * Both units are pure synchronous folds; the framework drives them and the
16
- * host wire layer ships the validated views.
17
- *
18
- * Alpha.3 change-feed contract (`@deepseek-ai/dsh-session-projection`): the
19
- * drive publishes a client view only when its raw output changes by
20
- * `Object.is`, so an object-valued view MUST reuse its reference while the
21
- * wire content is unchanged — a fresh object per call republishes on every
22
- * internal-only state change (e.g. the excluded `streamingText`
23
- * accumulator). Both `view`s below go through {@link memoizeView} for that
24
- * reference-stability guarantee.
25
- *
26
- * @module @huanlin/dsh-plugin-yet-another-subagent/projection
27
- */
28
- import { z } from 'zod';
29
- import type { SessionEvent } from '@deepseek-ai/dsh-session';
30
- /** `subagentProfile` wire shape: childId → profileId, plus callId → childId. */
31
- export interface SubagentProfileProjection {
32
- /** childId profileId (durable). */
33
- readonly children: Record<string, string>;
34
- /** callId → childId (for foreground calls where the result text has no embedded id). */
35
- readonly calls: Record<string, string>;
36
- }
37
- /**
38
- * Internal fold state for `subagentProfile`. Plain JSON only (the persisted
39
- * projection-cache precondition), so the pending callId map is a Record,
40
- * not a Map.
41
- */
42
- interface ProfileState {
43
- /** callId → profileId, awaiting the matching `tool/result`. */
44
- readonly pending: Record<string, string>;
45
- /** childId profileId (the durable mapping). */
46
- readonly mapping: Record<string, string>;
47
- /** callId childId (survives after the pending entry is consumed). */
48
- readonly callToChild: Record<string, string>;
49
- }
50
- /**
51
- * Fold the parent session's `tool/call` + `tool/result` for tool name
52
- * `subagent`. The profile id is carried in `tool/call.arguments.profile`
53
- * (JSON-encoded). The result content embeds `subagentId` (continuable branch)
54
- * or `runId` (foreground branch); the continuable branch is the durable
55
- * child identity that survives across activations.
56
- */
57
- export declare const subagentProfileProjection: {
58
- key: "subagentProfile";
59
- stateSchema: z.ZodObject<{
60
- pending: z.ZodRecord<z.ZodString, z.ZodString>;
61
- mapping: z.ZodRecord<z.ZodString, z.ZodString>;
62
- callToChild: z.ZodRecord<z.ZodString, z.ZodString>;
63
- }, z.core.$strict>;
64
- stateVersion: number;
65
- init: () => {
66
- pending: {};
67
- mapping: {};
68
- callToChild: {};
69
- };
70
- apply: (state: NoInfer<ProfileState>, event: SessionEvent) => ProfileState;
71
- wire: {
72
- viewSchema: z.ZodObject<{
73
- children: z.ZodRecord<z.ZodString, z.ZodString>;
74
- calls: z.ZodRecord<z.ZodString, z.ZodString>;
75
- }, z.core.$strict>;
76
- view: (state: NoInfer<ProfileState>) => {
77
- children: Record<string, string>;
78
- calls: Record<string, string>;
79
- };
80
- };
81
- };
82
- /** `yaSubagentProgress` wire shape: live child progress for the parent's card. */
83
- export interface YaSubagentProgressProjection {
84
- /** Number of `tool/call` events folded so far. */
85
- readonly toolCallCount: number;
86
- /** Cumulative token usage folded from `assistant/message.usage`. */
87
- readonly tokens: {
88
- readonly input: number;
89
- readonly output: number;
90
- readonly cacheRead: number;
91
- readonly cacheWrite: number;
92
- readonly reasoning: number;
93
- };
94
- /** Lifecycle state derived from turn boundaries. */
95
- readonly state: 'running' | 'idle' | 'settled';
96
- /** Latest activity: streaming text, tool call, or finalized message text. */
97
- readonly activity?: Activity;
98
- }
99
- /** Discriminated activity union: text or tool call. */
100
- export type Activity = {
101
- readonly kind: 'text';
102
- readonly text: string;
103
- } | {
104
- readonly kind: 'tool';
105
- readonly name: string;
106
- readonly args?: string;
107
- };
108
- interface ProgressState {
109
- readonly toolCallCount: number;
110
- readonly tokens: {
111
- readonly input: number;
112
- readonly output: number;
113
- readonly cacheRead: number;
114
- readonly cacheWrite: number;
115
- readonly reasoning: number;
116
- };
117
- readonly state: 'running' | 'idle' | 'settled';
118
- /** Accumulator for the current text block's streaming deltas. */
119
- readonly streamingText: string;
120
- readonly activity?: Activity;
121
- }
122
- /**
123
- * Fold the child session's own events into a compact progress view. Token
124
- * usage accumulates from `assistant/message.usage` (cache fields are
125
- * optional); tool calls are counted; lifecycle follows turn boundaries.
126
- */
127
- export declare const yaSubagentProgressProjection: {
128
- key: "yaSubagentProgress";
129
- stateSchema: z.ZodObject<{
130
- toolCallCount: z.ZodNumber;
131
- tokens: z.ZodObject<{
132
- input: z.ZodNumber;
133
- output: z.ZodNumber;
134
- cacheRead: z.ZodNumber;
135
- cacheWrite: z.ZodNumber;
136
- reasoning: z.ZodNumber;
137
- }, z.core.$strict>;
138
- state: z.ZodUnion<readonly [z.ZodLiteral<"running">, z.ZodLiteral<"idle">, z.ZodLiteral<"settled">]>;
139
- activity: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
140
- kind: z.ZodLiteral<"text">;
141
- text: z.ZodString;
142
- }, z.core.$strict>, z.ZodObject<{
143
- kind: z.ZodLiteral<"tool">;
144
- name: z.ZodString;
145
- args: z.ZodOptional<z.ZodString>;
146
- }, z.core.$strict>]>>;
147
- streamingText: z.ZodString;
148
- }, z.core.$strict>;
149
- stateVersion: number;
150
- init: () => {
151
- toolCallCount: number;
152
- tokens: {
153
- input: number;
154
- output: number;
155
- cacheRead: number;
156
- cacheWrite: number;
157
- reasoning: number;
158
- };
159
- state: "idle";
160
- streamingText: string;
161
- };
162
- apply: (state: NoInfer<ProgressState>, event: SessionEvent) => ProgressState;
163
- wire: {
164
- viewSchema: z.ZodObject<{
165
- toolCallCount: z.ZodNumber;
166
- tokens: z.ZodObject<{
167
- input: z.ZodNumber;
168
- output: z.ZodNumber;
169
- cacheRead: z.ZodNumber;
170
- cacheWrite: z.ZodNumber;
171
- reasoning: z.ZodNumber;
172
- }, z.core.$strict>;
173
- state: z.ZodUnion<readonly [z.ZodLiteral<"running">, z.ZodLiteral<"idle">, z.ZodLiteral<"settled">]>;
174
- activity: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
175
- kind: z.ZodLiteral<"text">;
176
- text: z.ZodString;
177
- }, z.core.$strict>, z.ZodObject<{
178
- kind: z.ZodLiteral<"tool">;
179
- name: z.ZodString;
180
- args: z.ZodOptional<z.ZodString>;
181
- }, z.core.$strict>]>>;
182
- }, z.core.$strict>;
183
- view: (state: NoInfer<ProgressState>) => {
184
- toolCallCount: number;
185
- tokens: {
186
- readonly input: number;
187
- readonly output: number;
188
- readonly cacheRead: number;
189
- readonly cacheWrite: number;
190
- readonly reasoning: number;
191
- };
192
- state: "running" | "idle" | "settled";
193
- activity?: Activity;
194
- };
195
- };
196
- };
197
- /** Convenience: the projection keys registered by this plugin. */
198
- export declare const PROJECTION_KEYS: readonly ["subagentProfile", "yaSubagentProgress"];
199
- /** Type-side declaration merges so consumers can read these keys via the projection registry. */
200
- declare module '@deepseek-ai/dsh-session-projection/types' {
201
- interface SessionProjectionMap {
202
- /** Parent-session map of childId → profileId. */
203
- subagentProfile: SubagentProfileProjection;
204
- /** Child-session live progress (toolcall count + token usage + state). */
205
- yaSubagentProgress: YaSubagentProgressProjection;
206
- }
207
- interface SessionProjectionStateMap {
208
- /** Host fold state behind {@link SubagentProfileProjection}. */
209
- subagentProfile: ProfileState;
210
- /** Host fold state behind {@link YaSubagentProgressProjection}. */
211
- yaSubagentProgress: ProgressState;
212
- }
213
- }
214
- export type { SessionEvent };
1
+ /**
2
+ * Two session projections (design doc §3.6):
3
+ *
4
+ * - `subagentProfile` (parent session): fold `tool/call` (name `subagent`,
5
+ * profile in `arguments.profile`) + the matching `tool/result.subagentId`,
6
+ * building a `childId → profileId` map. Used as a cross-check / fallback
7
+ * for SubagentCard (which usually reads `profileLabel` straight from the
8
+ * result content).
9
+ *
10
+ * - `yaSubagentProgress` (child session): toolcall count, token usage,
11
+ * and lifecycle state. Pushed over the projection frame so the parent's
12
+ * SubagentCard can subscribe even though client runtime drops non-current
13
+ * `session/event` frames (single-stage model).
14
+ *
15
+ * Both units are pure synchronous folds; the framework drives them and the
16
+ * host wire layer ships the validated views.
17
+ *
18
+ * Change-feed contract (`@deepseek-ai/dsh-session-projection`): the drive
19
+ * publishes a client view only when its raw output changes by `Object.is`, so
20
+ * an object-valued view MUST reuse its reference while the wire content is
21
+ * unchanged — a fresh object per call republishes on every internal-only
22
+ * state change. Both `view`s below go through {@link memoizeView} for that
23
+ * reference-stability guarantee.
24
+ *
25
+ * @module @huanlin/dsh-plugin-yet-another-subagent/projection
26
+ */
27
+ import { z } from 'zod';
28
+ import type { SessionEvent } from '@deepseek-ai/dsh-session';
29
+ /** `subagentProfile` wire shape: childId profileId, plus callId → childId. */
30
+ export interface SubagentProfileProjection {
31
+ /** childId profileId (durable). */
32
+ readonly children: Record<string, string>;
33
+ /** callId childId (for foreground calls where the result text has no embedded id). */
34
+ readonly calls: Record<string, string>;
35
+ }
36
+ /**
37
+ * Internal fold state for `subagentProfile`. Plain JSON only (the persisted
38
+ * projection-cache precondition), so the pending callId map is a Record,
39
+ * not a Map.
40
+ */
41
+ interface ProfileState {
42
+ /** callId → profileId, awaiting the matching `tool/result`. */
43
+ readonly pending: Record<string, string>;
44
+ /** childId profileId (the durable mapping). */
45
+ readonly mapping: Record<string, string>;
46
+ /** callId childId (survives after the pending entry is consumed). */
47
+ readonly callToChild: Record<string, string>;
48
+ }
49
+ /**
50
+ * Fold the parent session's `tool/call` + `tool/result` for tool name
51
+ * `subagent`. The profile id is carried in `tool/call.arguments.profile`
52
+ * (JSON-encoded). The result content embeds `subagentId` (continuable branch)
53
+ * or `runId` (foreground branch); the continuable branch is the durable
54
+ * child identity that survives across activations.
55
+ */
56
+ export declare const subagentProfileProjection: {
57
+ key: "subagentProfile";
58
+ stateSchema: z.ZodObject<{
59
+ pending: z.ZodRecord<z.ZodString, z.ZodString>;
60
+ mapping: z.ZodRecord<z.ZodString, z.ZodString>;
61
+ callToChild: z.ZodRecord<z.ZodString, z.ZodString>;
62
+ }, z.core.$strict>;
63
+ stateVersion: number;
64
+ init: () => {
65
+ pending: {};
66
+ mapping: {};
67
+ callToChild: {};
68
+ };
69
+ apply: (state: NoInfer<ProfileState>, event: SessionEvent) => ProfileState;
70
+ wire: {
71
+ viewSchema: z.ZodObject<{
72
+ children: z.ZodRecord<z.ZodString, z.ZodString>;
73
+ calls: z.ZodRecord<z.ZodString, z.ZodString>;
74
+ }, z.core.$strict>;
75
+ view: (state: NoInfer<ProfileState>) => {
76
+ children: Record<string, string>;
77
+ calls: Record<string, string>;
78
+ };
79
+ };
80
+ };
81
+ /** `yaSubagentProgress` wire shape: live child progress for the parent's card. */
82
+ export interface YaSubagentProgressProjection {
83
+ /** Number of `tool/call` events folded so far. */
84
+ readonly toolCallCount: number;
85
+ /** Cumulative token usage folded from `assistant/message.usage`. */
86
+ readonly tokens: {
87
+ readonly input: number;
88
+ readonly output: number;
89
+ readonly cacheRead: number;
90
+ readonly cacheWrite: number;
91
+ readonly reasoning: number;
92
+ };
93
+ /** Lifecycle state derived from turn boundaries. */
94
+ readonly state: 'running' | 'idle' | 'settled';
95
+ /** Latest activity: a tool call or the finalized message text. */
96
+ readonly activity?: Activity;
97
+ }
98
+ /** Discriminated activity union: text or tool call. */
99
+ export type Activity = {
100
+ readonly kind: 'text';
101
+ readonly text: string;
102
+ } | {
103
+ readonly kind: 'tool';
104
+ readonly name: string;
105
+ readonly args?: string;
106
+ };
107
+ interface ProgressState {
108
+ readonly toolCallCount: number;
109
+ readonly tokens: {
110
+ readonly input: number;
111
+ readonly output: number;
112
+ readonly cacheRead: number;
113
+ readonly cacheWrite: number;
114
+ readonly reasoning: number;
115
+ };
116
+ readonly state: 'running' | 'idle' | 'settled';
117
+ readonly activity?: Activity;
118
+ }
119
+ /**
120
+ * Fold the child session's own events into a compact progress view. Token
121
+ * usage accumulates from `assistant/message.usage` (cache fields are
122
+ * optional); tool calls are counted; lifecycle follows turn boundaries.
123
+ * Since dsh 0.1.5 the session log carries no streaming events activity
124
+ * text updates only when a message finalizes.
125
+ */
126
+ export declare const yaSubagentProgressProjection: {
127
+ key: "yaSubagentProgress";
128
+ stateSchema: z.ZodObject<{
129
+ toolCallCount: z.ZodNumber;
130
+ tokens: z.ZodObject<{
131
+ input: z.ZodNumber;
132
+ output: z.ZodNumber;
133
+ cacheRead: z.ZodNumber;
134
+ cacheWrite: z.ZodNumber;
135
+ reasoning: z.ZodNumber;
136
+ }, z.core.$strict>;
137
+ state: z.ZodUnion<readonly [z.ZodLiteral<"running">, z.ZodLiteral<"idle">, z.ZodLiteral<"settled">]>;
138
+ activity: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
139
+ kind: z.ZodLiteral<"text">;
140
+ text: z.ZodString;
141
+ }, z.core.$strict>, z.ZodObject<{
142
+ kind: z.ZodLiteral<"tool">;
143
+ name: z.ZodString;
144
+ args: z.ZodOptional<z.ZodString>;
145
+ }, z.core.$strict>]>>;
146
+ }, z.core.$strict>;
147
+ stateVersion: number;
148
+ init: () => {
149
+ toolCallCount: number;
150
+ tokens: {
151
+ input: number;
152
+ output: number;
153
+ cacheRead: number;
154
+ cacheWrite: number;
155
+ reasoning: number;
156
+ };
157
+ state: "idle";
158
+ };
159
+ apply: (state: NoInfer<ProgressState>, event: SessionEvent) => ProgressState;
160
+ wire: {
161
+ viewSchema: z.ZodObject<{
162
+ toolCallCount: z.ZodNumber;
163
+ tokens: z.ZodObject<{
164
+ input: z.ZodNumber;
165
+ output: z.ZodNumber;
166
+ cacheRead: z.ZodNumber;
167
+ cacheWrite: z.ZodNumber;
168
+ reasoning: z.ZodNumber;
169
+ }, z.core.$strict>;
170
+ state: z.ZodUnion<readonly [z.ZodLiteral<"running">, z.ZodLiteral<"idle">, z.ZodLiteral<"settled">]>;
171
+ activity: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
172
+ kind: z.ZodLiteral<"text">;
173
+ text: z.ZodString;
174
+ }, z.core.$strict>, z.ZodObject<{
175
+ kind: z.ZodLiteral<"tool">;
176
+ name: z.ZodString;
177
+ args: z.ZodOptional<z.ZodString>;
178
+ }, z.core.$strict>]>>;
179
+ }, z.core.$strict>;
180
+ view: (state: NoInfer<ProgressState>) => ProgressState;
181
+ };
182
+ };
183
+ /** Convenience: the projection keys registered by this plugin. */
184
+ export declare const PROJECTION_KEYS: readonly ["subagentProfile", "yaSubagentProgress"];
185
+ /** Type-side declaration merges so consumers can read these keys via the projection registry. */
186
+ declare module '@deepseek-ai/dsh-session-projection/types' {
187
+ interface SessionProjectionMap {
188
+ /** Parent-session map of childId → profileId. */
189
+ subagentProfile: SubagentProfileProjection;
190
+ /** Child-session live progress (toolcall count + token usage + state). */
191
+ yaSubagentProgress: YaSubagentProgressProjection;
192
+ }
193
+ interface SessionProjectionStateMap {
194
+ /** Host fold state behind {@link SubagentProfileProjection}. */
195
+ subagentProfile: ProfileState;
196
+ /** Host fold state behind {@link YaSubagentProgressProjection}. */
197
+ yaSubagentProgress: ProgressState;
198
+ }
199
+ }
200
+ export type { SessionEvent };
@@ -1,66 +1,66 @@
1
- /**
2
- * One-shot session-log repair: physically REMOVE legacy `ya-subagent/started`
3
- * event rows so the harness persistence read path (`assertEventsSupported`)
4
- * loads the log again.
5
- *
6
- * Background: plugin versions ≤0.1.2 appended `ya-subagent/started` via
7
- * `session.append(...)`. `KNOWN_SESSION_EVENT_TYPES` is code-generated with no
8
- * plugin registration surface, and v0.1.2-alpha.1 refuses EVERY log row whose
9
- * type is outside that set — the old `ignorable` envelope flag no longer
10
- * exists, so stamping it (the ≤0.1.5 repair) cannot help. The only repair is
11
- * removal.
12
- *
13
- * Rows cannot simply be deleted: the read path enforces contiguous `seq`
14
- * numbers. This module therefore rewrites the log in place (after a `.bak`
15
- * backup):
16
- *
17
- * - drops every `ya-subagent/started` row;
18
- * - decrements the `seq` of every later ordinary event row (packed
19
- * `text-chunks` / `reasoning-chunks` / `tool-call-chunks` storage rows
20
- * shift their `seq0` instead);
21
- * - shifts every `sourceEventSeqs` citation by the number of dropped rows
22
- * ahead of it (dropped rows are never cited: only surface events carry
23
- * provenance and they cite assistant chunks / surface nodes, which a
24
- * plugin row never is).
25
- *
26
- * Two physical encodings (mirrors `session-persistence-jsonl`):
27
- * - `.jsonl` — plaintext, one JSON record per line.
28
- * - `.jsonl.zstd` — concatenated independent Zstandard frames: the first
29
- * frame holds the session header line, subsequent
30
- * frames each hold one append batch of event lines.
31
- * Each frame is independently decodable + checksummed.
32
- * The first frame containing a dropped row and every
33
- * frame after it are recompressed (their rows renumber);
34
- * untouched earlier frames are copied verbatim.
35
- *
36
- * Modified rows are re-encoded with `JSON.stringify`, which reproduces the
37
- * write path's canonical single-line form and preserves the parsed key order;
38
- * untouched lines stay byte-identical.
39
- *
40
- * Idempotent: a log with no target rows is left untouched (no backup, no
41
- * rewrite). A corrupt (unparsable) line is left untouched — that is the
42
- * harness's refusal job, not ours.
43
- *
44
- * @module @huanlin/dsh-plugin-yet-another-subagent/repair
45
- */
46
- /** Aggregate result of one repair run. */
47
- export interface RepairStats {
48
- /** Session log files examined (`.jsonl` + `.jsonl.zstd`). */
49
- readonly scanned: number;
50
- /** Files rewritten because at least one target row was removed. */
51
- readonly repaired: number;
52
- /** Files with no target rows (already clean). */
53
- readonly skipped: number;
54
- /** Per-file errors (path + message); empty on a clean run. */
55
- readonly errors: readonly {
56
- readonly path: string;
57
- readonly message: string;
58
- }[];
59
- }
60
- /**
61
- * Recursively repair every session log under `sessionsRoot`.
62
- *
63
- * @param sessionsRoot - absolute path to `$DSH_HOME/sessions`.
64
- * @returns aggregate stats. Never throws — per-file failures land in `errors`.
65
- */
66
- export declare function repairSessions(sessionsRoot: string): Promise<RepairStats>;
1
+ /**
2
+ * One-shot session-log repair: physically REMOVE legacy `ya-subagent/started`
3
+ * event rows so the harness persistence read path (`assertEventsSupported`)
4
+ * loads the log again.
5
+ *
6
+ * Background: plugin versions ≤0.1.2 appended `ya-subagent/started` via
7
+ * `session.append(...)`. `KNOWN_SESSION_EVENT_TYPES` is code-generated with no
8
+ * plugin registration surface, and v0.1.2-alpha.1 refuses EVERY log row whose
9
+ * type is outside that set — the old `ignorable` envelope flag no longer
10
+ * exists, so stamping it (the ≤0.1.5 repair) cannot help. The only repair is
11
+ * removal.
12
+ *
13
+ * Rows cannot simply be deleted: the read path enforces contiguous `seq`
14
+ * numbers. This module therefore rewrites the log in place (after a `.bak`
15
+ * backup):
16
+ *
17
+ * - drops every `ya-subagent/started` row;
18
+ * - decrements the `seq` of every later ordinary event row (packed
19
+ * `text-chunks` / `reasoning-chunks` / `tool-call-chunks` storage rows
20
+ * shift their `seq0` instead);
21
+ * - shifts every `sourceEventSeqs` citation by the number of dropped rows
22
+ * ahead of it (dropped rows are never cited: only surface events carry
23
+ * provenance and they cite assistant chunks / surface nodes, which a
24
+ * plugin row never is).
25
+ *
26
+ * Two physical encodings (mirrors `session-persistence-jsonl`):
27
+ * - `.jsonl` — plaintext, one JSON record per line.
28
+ * - `.jsonl.zstd` — concatenated independent Zstandard frames: the first
29
+ * frame holds the session header line, subsequent
30
+ * frames each hold one append batch of event lines.
31
+ * Each frame is independently decodable + checksummed.
32
+ * The first frame containing a dropped row and every
33
+ * frame after it are recompressed (their rows renumber);
34
+ * untouched earlier frames are copied verbatim.
35
+ *
36
+ * Modified rows are re-encoded with `JSON.stringify`, which reproduces the
37
+ * write path's canonical single-line form and preserves the parsed key order;
38
+ * untouched lines stay byte-identical.
39
+ *
40
+ * Idempotent: a log with no target rows is left untouched (no backup, no
41
+ * rewrite). A corrupt (unparsable) line is left untouched — that is the
42
+ * harness's refusal job, not ours.
43
+ *
44
+ * @module @huanlin/dsh-plugin-yet-another-subagent/repair
45
+ */
46
+ /** Aggregate result of one repair run. */
47
+ export interface RepairStats {
48
+ /** Session log files examined (`.jsonl` + `.jsonl.zstd`). */
49
+ readonly scanned: number;
50
+ /** Files rewritten because at least one target row was removed. */
51
+ readonly repaired: number;
52
+ /** Files with no target rows (already clean). */
53
+ readonly skipped: number;
54
+ /** Per-file errors (path + message); empty on a clean run. */
55
+ readonly errors: readonly {
56
+ readonly path: string;
57
+ readonly message: string;
58
+ }[];
59
+ }
60
+ /**
61
+ * Recursively repair every session log under `sessionsRoot`.
62
+ *
63
+ * @param sessionsRoot - absolute path to `$DSH_HOME/sessions`.
64
+ * @returns aggregate stats. Never throws — per-file failures land in `errors`.
65
+ */
66
+ export declare function repairSessions(sessionsRoot: string): Promise<RepairStats>;