@lucascouts/claude-agent-tui 0.1.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/LICENSE +191 -0
- package/NOTICE +14 -0
- package/README.md +50 -0
- package/dist/acp-agent.d.ts +594 -0
- package/dist/acp-agent.d.ts.map +1 -0
- package/dist/acp-agent.js +2139 -0
- package/dist/ansi-mirror.d.ts +42 -0
- package/dist/ansi-mirror.d.ts.map +1 -0
- package/dist/ansi-mirror.js +61 -0
- package/dist/besteffort.d.ts +44 -0
- package/dist/besteffort.d.ts.map +1 -0
- package/dist/besteffort.js +100 -0
- package/dist/billing/entrypoint-guard.d.ts +97 -0
- package/dist/billing/entrypoint-guard.d.ts.map +1 -0
- package/dist/billing/entrypoint-guard.js +166 -0
- package/dist/claude-path.d.ts +12 -0
- package/dist/claude-path.d.ts.map +1 -0
- package/dist/claude-path.js +61 -0
- package/dist/diff-enriched-reader.d.ts +41 -0
- package/dist/diff-enriched-reader.d.ts.map +1 -0
- package/dist/diff-enriched-reader.js +106 -0
- package/dist/diff-source.d.ts +104 -0
- package/dist/diff-source.d.ts.map +1 -0
- package/dist/diff-source.js +164 -0
- package/dist/end-of-turn.d.ts +172 -0
- package/dist/end-of-turn.d.ts.map +1 -0
- package/dist/end-of-turn.js +415 -0
- package/dist/engine-lifecycle.d.ts +222 -0
- package/dist/engine-lifecycle.d.ts.map +1 -0
- package/dist/engine-lifecycle.js +236 -0
- package/dist/engine-pty.d.ts +143 -0
- package/dist/engine-pty.d.ts.map +1 -0
- package/dist/engine-pty.js +222 -0
- package/dist/engine-watcher.d.ts +83 -0
- package/dist/engine-watcher.d.ts.map +1 -0
- package/dist/engine-watcher.js +173 -0
- package/dist/engine.d.ts +30 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +34 -0
- package/dist/event-switch.d.ts +164 -0
- package/dist/event-switch.d.ts.map +1 -0
- package/dist/event-switch.js +206 -0
- package/dist/gate/port.d.ts +38 -0
- package/dist/gate/port.d.ts.map +1 -0
- package/dist/gate/port.js +126 -0
- package/dist/gate/settings-writer.d.ts +130 -0
- package/dist/gate/settings-writer.d.ts.map +1 -0
- package/dist/gate/settings-writer.js +349 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +106 -0
- package/dist/jsonl.d.ts +267 -0
- package/dist/jsonl.d.ts.map +1 -0
- package/dist/jsonl.js +527 -0
- package/dist/lib.d.ts +6 -0
- package/dist/lib.d.ts.map +1 -0
- package/dist/lib.js +5 -0
- package/dist/linearize.d.ts +219 -0
- package/dist/linearize.d.ts.map +1 -0
- package/dist/linearize.js +444 -0
- package/dist/live-diff-env.d.ts +7 -0
- package/dist/live-diff-env.d.ts.map +1 -0
- package/dist/live-diff-env.js +18 -0
- package/dist/live-subagent-env.d.ts +7 -0
- package/dist/live-subagent-env.d.ts.map +1 -0
- package/dist/live-subagent-env.js +19 -0
- package/dist/permissions/allow-inject.d.ts +67 -0
- package/dist/permissions/allow-inject.d.ts.map +1 -0
- package/dist/permissions/allow-inject.js +85 -0
- package/dist/permissions/deny.d.ts +60 -0
- package/dist/permissions/deny.d.ts.map +1 -0
- package/dist/permissions/deny.js +81 -0
- package/dist/permissions/gate-wiring.d.ts +112 -0
- package/dist/permissions/gate-wiring.d.ts.map +1 -0
- package/dist/permissions/gate-wiring.js +350 -0
- package/dist/permissions/hook-server.d.ts +72 -0
- package/dist/permissions/hook-server.d.ts.map +1 -0
- package/dist/permissions/hook-server.js +179 -0
- package/dist/permissions/permission-mode.d.ts +67 -0
- package/dist/permissions/permission-mode.d.ts.map +1 -0
- package/dist/permissions/permission-mode.js +100 -0
- package/dist/permissions/request-permission.d.ts +102 -0
- package/dist/permissions/request-permission.d.ts.map +1 -0
- package/dist/permissions/request-permission.js +124 -0
- package/dist/settings.d.ts +68 -0
- package/dist/settings.d.ts.map +1 -0
- package/dist/settings.js +182 -0
- package/dist/stop-reason-map.d.ts +17 -0
- package/dist/stop-reason-map.d.ts.map +1 -0
- package/dist/stop-reason-map.js +33 -0
- package/dist/subagent-source.d.ts +63 -0
- package/dist/subagent-source.d.ts.map +1 -0
- package/dist/subagent-source.js +132 -0
- package/dist/subagent-watcher.d.ts +40 -0
- package/dist/subagent-watcher.d.ts.map +1 -0
- package/dist/subagent-watcher.js +108 -0
- package/dist/tools.d.ts +119 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +729 -0
- package/dist/usage-env.d.ts +7 -0
- package/dist/usage-env.d.ts.map +1 -0
- package/dist/usage-env.js +16 -0
- package/dist/usage.d.ts +54 -0
- package/dist/usage.d.ts.map +1 -0
- package/dist/usage.js +53 -0
- package/dist/utils.d.ts +16 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +83 -0
- package/dist/zed-register.d.ts +26 -0
- package/dist/zed-register.d.ts.map +1 -0
- package/dist/zed-register.js +106 -0
- package/package.json +79 -0
package/dist/jsonl.d.ts
ADDED
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build the absolute glob pattern used to locate a session's transcript:
|
|
3
|
+
* the `<sessionId>.jsonl` basename anywhere under `~/.claude/projects`, with `~` expanded via os.homedir
|
|
4
|
+
* (globSync does NOT perform tilde expansion). Exposed so callers can report the
|
|
5
|
+
* EXACT pattern they globbed in a not-found/ambiguity diagnostic without
|
|
6
|
+
* re-deriving (and risking drift from) the string used by findTranscript (R1.3).
|
|
7
|
+
*
|
|
8
|
+
* @param sessionId the session id; equals the transcript filename basename.
|
|
9
|
+
* @returns the absolute glob pattern findTranscript passes to globSync.
|
|
10
|
+
*/
|
|
11
|
+
export declare function transcriptGlob(sessionId: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* Find Claude transcript file(s) for a given session id.
|
|
14
|
+
*
|
|
15
|
+
* Globs the `<sessionId>.jsonl` basename anywhere under `~/.claude/projects` (`~` expanded via os.homedir)
|
|
16
|
+
* so the file is found independent of the cwd→dir encoding (R1.1). Returns ALL
|
|
17
|
+
* matches (normally one) as absolute paths; an empty array means "not found".
|
|
18
|
+
*
|
|
19
|
+
* @param sessionId the session id; equals the transcript filename basename.
|
|
20
|
+
* @returns absolute paths to matching `<sessionId>.jsonl` files (possibly empty).
|
|
21
|
+
*/
|
|
22
|
+
export declare function findTranscript(sessionId: string): string[];
|
|
23
|
+
/**
|
|
24
|
+
* The file-discovery watchdog window (ms): how long {@link locateTranscript} keeps polling the
|
|
25
|
+
* glob for the transcript to appear before failing with a not-found diagnostic (R1.3).
|
|
26
|
+
*
|
|
27
|
+
* DISTINCT from the 5583 ms turn watchdog — never conflate them. This story uses ONLY the
|
|
28
|
+
* file-discovery watchdog.
|
|
29
|
+
*/
|
|
30
|
+
export declare const FILE_DISCOVERY_WATCHDOG_MS = 2000;
|
|
31
|
+
/** Default polling interval (ms) between glob attempts while waiting for the transcript. */
|
|
32
|
+
export declare const DEFAULT_POLL_INTERVAL_MS = 50;
|
|
33
|
+
/** Options for {@link locateTranscript} / {@link resolveWatchTarget}. */
|
|
34
|
+
export interface LocateOptions {
|
|
35
|
+
/** File-discovery watchdog window (ms); defaults to {@link FILE_DISCOVERY_WATCHDOG_MS}. */
|
|
36
|
+
watchdogMs?: number;
|
|
37
|
+
/** Poll interval (ms) between glob attempts; defaults to {@link DEFAULT_POLL_INTERVAL_MS}. */
|
|
38
|
+
pollIntervalMs?: number;
|
|
39
|
+
/** Injected for tests: returns matches for a sessionId. Default: {@link findTranscript}. */
|
|
40
|
+
glob?: (sessionId: string) => string[];
|
|
41
|
+
/** Injected for tests: monotonic clock in ms. Default: a `performance.now`-based clock. */
|
|
42
|
+
now?: () => number;
|
|
43
|
+
/** Injected for tests: `sleep(ms)`. Default: a `setTimeout`-based sleep. */
|
|
44
|
+
sleep?: (ms: number) => Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Optional abort handle for a (possibly unbounded — see `watchdogMs: Infinity`) poll. Checked each
|
|
47
|
+
* iteration; when it aborts mid-poll the poll rejects with an AbortError sentinel (`.name ===
|
|
48
|
+
* "AbortError"`) — NOT the not-found fault — so a caller can swallow exactly the
|
|
49
|
+
* cancelled-before-the-transcript-appears case and surface everything else (R1.2).
|
|
50
|
+
*/
|
|
51
|
+
signal?: AbortSignal;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Poll the glob until EXACTLY ONE match appears or the file-discovery watchdog elapses (R1.1,
|
|
55
|
+
* R1.3, R1.4). Deterministic/test-friendly via injected `glob`/`now`/`sleep` so tests never wait
|
|
56
|
+
* a real 2000 ms.
|
|
57
|
+
*
|
|
58
|
+
* - 0 matches at watchdog expiry → throw a not-found error whose message carries the EXACT glob
|
|
59
|
+
* pattern AND the elapsed ms (R1.3).
|
|
60
|
+
* - >1 matches → throw a multi-match error listing EVERY matched path, so the ambiguity is loud
|
|
61
|
+
* rather than silently resolved (R1.4).
|
|
62
|
+
* - exactly 1 → resolve `{ transcriptPath }`.
|
|
63
|
+
*
|
|
64
|
+
* @param sessionId the session id; equals the transcript filename basename.
|
|
65
|
+
* @param opts injectable watchdog/poll/glob/clock/sleep seams.
|
|
66
|
+
*/
|
|
67
|
+
export declare function locateTranscript(sessionId: string, opts?: LocateOptions): Promise<{
|
|
68
|
+
transcriptPath: string;
|
|
69
|
+
}>;
|
|
70
|
+
/**
|
|
71
|
+
* Read the runtime cwd from the `.cwd` field of the FIRST event inside the file that carries it
|
|
72
|
+
* (R1.2). NEVER decode the directory name — the cwd→dir transform is irreversible, so the encoded
|
|
73
|
+
* dir is not a reliable cwd source.
|
|
74
|
+
*
|
|
75
|
+
* Scans complete lines top-to-bottom and returns the first record whose `.cwd` is a non-empty
|
|
76
|
+
* string. Returns `undefined` when the file has no complete line yet, or no event carries `.cwd`
|
|
77
|
+
* yet — the caller should DEFER (re-read after more lines land) rather than guess from the dir
|
|
78
|
+
* name. Corrupted/partial lines are skipped without throwing.
|
|
79
|
+
*
|
|
80
|
+
* @param transcriptPath absolute path to a `.jsonl` transcript (the path {@link locateTranscript}
|
|
81
|
+
* resolved).
|
|
82
|
+
* @returns the inside `.cwd` value, or `undefined` if none is present yet.
|
|
83
|
+
*/
|
|
84
|
+
export declare function readCwdFromInside(transcriptPath: string): string | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* Convenience: {@link locateTranscript} + {@link readCwdFromInside} → the resolved watch target
|
|
87
|
+
* for the read-only tail watcher (R1.1, R1.2).
|
|
88
|
+
*
|
|
89
|
+
* Adopts the single globbed path as the watch target and sources the runtime cwd from an event
|
|
90
|
+
* INSIDE that file. `cwd` may be `undefined` when no event has carried `.cwd` yet — the caller
|
|
91
|
+
* DEFERS reading it until the first complete line provides it, rather than decoding the dir name.
|
|
92
|
+
*
|
|
93
|
+
* @param sessionId the session id; equals the transcript filename basename.
|
|
94
|
+
* @param opts injectable watchdog/poll/glob/clock/sleep seams (forwarded to locateTranscript).
|
|
95
|
+
*/
|
|
96
|
+
export declare function resolveWatchTarget(sessionId: string, opts?: LocateOptions): Promise<{
|
|
97
|
+
transcriptPath: string;
|
|
98
|
+
cwd: string | undefined;
|
|
99
|
+
}>;
|
|
100
|
+
/** Callback invoked once per newly-completed, top-level-parseable record (the append/write signal). */
|
|
101
|
+
export type RecordHandler = (record: unknown) => void;
|
|
102
|
+
/**
|
|
103
|
+
* Stateful line reader. Feed it raw chunks via {@link LineReader.push}; it forwards (via the
|
|
104
|
+
* `onRecord` passed to {@link createLineReader}) only the `\n`-terminated COMPLETE lines, carrying
|
|
105
|
+
* the trailing partial residue across pushes. Each complete line is `JSON.parse`'d in try/catch —
|
|
106
|
+
* a corrupt line is SKIPPED (continue), never throws (R2.2, R2.3, R3.1, R3.2).
|
|
107
|
+
*/
|
|
108
|
+
export interface LineReader {
|
|
109
|
+
/** Append a raw chunk; flush every now-complete `\n`-terminated line through onRecord. */
|
|
110
|
+
push(chunk: string): void;
|
|
111
|
+
/** The current buffered trailing partial (text after the last `\n`). Exposed for test introspection. */
|
|
112
|
+
readonly residue: string;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Create a stateful {@link LineReader}. Maintains a single residue buffer across {@link
|
|
116
|
+
* LineReader.push} calls: each push appends to the buffer, splits on `\n`, holds the final segment
|
|
117
|
+
* back as the new residue (it may be a partial write), and forwards every COMPLETE line through
|
|
118
|
+
* `onRecord` (skipping any that fail `JSON.parse`).
|
|
119
|
+
*
|
|
120
|
+
* This is the deterministic, filesystem-free core the 2.1/2.2 scenarios drive directly.
|
|
121
|
+
*
|
|
122
|
+
* @param onRecord invoked once per newly-completed, top-level-parseable record.
|
|
123
|
+
*/
|
|
124
|
+
export declare function createLineReader(onRecord: RecordHandler): LineReader;
|
|
125
|
+
/**
|
|
126
|
+
* Feed an explicit sequence of chunks through a fresh {@link LineReader} (residue buffered ACROSS
|
|
127
|
+
* chunks), then flush the final residue as a last line. Exposed so the cross-chunk buffering +
|
|
128
|
+
* corrupt-skip logic is directly unit-testable WITHOUT touching the filesystem — mirrors how the
|
|
129
|
+
* experiments harness exposes `feedChunks`.
|
|
130
|
+
*
|
|
131
|
+
* Note the trailing flush: unlike a live tail (where a partial residue MUST stay withheld until its
|
|
132
|
+
* `\n` arrives), a finite chunk sequence is "closed", so a final non-`\n`-terminated record is
|
|
133
|
+
* treated as complete here. Tests that assert residue-withholding therefore drive {@link
|
|
134
|
+
* createLineReader} directly (and inspect `.residue`) rather than going through `feedChunks`.
|
|
135
|
+
*
|
|
136
|
+
* @param chunks ordered text fragments (a record may straddle two fragments).
|
|
137
|
+
* @param onRecord invoked once per successfully parsed record.
|
|
138
|
+
*/
|
|
139
|
+
export declare function feedChunks(chunks: Iterable<string>, onRecord: RecordHandler): void;
|
|
140
|
+
/** Handle returned by {@link tailTranscript}; `stop()` detaches the watcher and drops the buffer. */
|
|
141
|
+
export interface TranscriptTail {
|
|
142
|
+
stop(): void;
|
|
143
|
+
}
|
|
144
|
+
/** Options for {@link tailTranscript}. */
|
|
145
|
+
export interface TailOptions {
|
|
146
|
+
/** Invoked once per newly-completed, top-level-parseable record (the append/write signal). */
|
|
147
|
+
onRecord: RecordHandler;
|
|
148
|
+
/** Injected for deterministic tests; default {@link defaultWatch} (fs.watch). Returns a closable subscription. */
|
|
149
|
+
watch?: (path: string, onChange: () => void) => {
|
|
150
|
+
close(): void;
|
|
151
|
+
};
|
|
152
|
+
/** Injected for tests; default {@link defaultReadSlice} reads bytes `[fromByte, EOF)` of `path` as utf8. */
|
|
153
|
+
readSlice?: (path: string, fromByte: number) => string;
|
|
154
|
+
/** Injected for tests; default {@link defaultFileSize} is `fs.statSync(path).size`. */
|
|
155
|
+
fileSize?: (path: string) => number;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Attach an fs.watch/tail-F to `path`. On each growth, read the appended bytes from the last byte
|
|
159
|
+
* offset, push them through a {@link LineReader}, and forward complete records via `opts.onRecord`.
|
|
160
|
+
* Tracks the read offset so each byte is read exactly once. Returns a {@link TranscriptTail} whose
|
|
161
|
+
* `stop()` detaches the watcher and drops the buffer.
|
|
162
|
+
*
|
|
163
|
+
* The residue buffer makes a large NON-ATOMIC append safe: a ~630 KB base64 `image` line split
|
|
164
|
+
* across two writes is withheld until its terminating `\n` is read, so the split can not corrupt
|
|
165
|
+
* parsing (R2.3). A complete line that fails `JSON.parse` is skipped, never thrown (R3.1).
|
|
166
|
+
*
|
|
167
|
+
* Seams (`watch`/`readSlice`/`fileSize`) are injectable so the wiring is testable without real
|
|
168
|
+
* fs.watch event timing; in production they default to fs.watch + a byte-offset read.
|
|
169
|
+
*
|
|
170
|
+
* @param path absolute path to the resolved transcript (what {@link locateTranscript} resolved).
|
|
171
|
+
* @param opts onRecord sink plus injectable watch/readSlice/fileSize seams.
|
|
172
|
+
*/
|
|
173
|
+
export declare function tailTranscript(path: string, opts: TailOptions): TranscriptTail;
|
|
174
|
+
/**
|
|
175
|
+
* A typed Degrau-1 conversation event, projected from a `getSessionMessages` message.
|
|
176
|
+
*
|
|
177
|
+
* Fields the SDK return provides are populated directly; the rest are OPTIONAL (undefined in
|
|
178
|
+
* Degrau-1 — forward-compat — because they live only in the raw JSONL record, not in the REUSE-live
|
|
179
|
+
* source) and are populated only if the input happens to carry them (see {@link projectEvent}).
|
|
180
|
+
*/
|
|
181
|
+
export interface JsonlEvent {
|
|
182
|
+
/** Message uuid (the dedupe key upstream). Kept as-is; empty string if the input lacks one. */
|
|
183
|
+
uuid: string;
|
|
184
|
+
/** Message type, carried through verbatim — the taxonomy `switch(.type)` is story 016. */
|
|
185
|
+
type: string;
|
|
186
|
+
/** ISO timestamp, when present on the input. */
|
|
187
|
+
timestamp?: string;
|
|
188
|
+
/** Session id — projected from the input's `session_id`. */
|
|
189
|
+
sessionId?: string;
|
|
190
|
+
/** The API message object; `message.content` may be an ARRAY of blocks OR a raw STRING. */
|
|
191
|
+
message: unknown;
|
|
192
|
+
/** Projected from the input's `parent_tool_use_id`. */
|
|
193
|
+
parentToolUseId?: string | null;
|
|
194
|
+
/** Hardcoded `'external'` — the story asserts the user type is always external. */
|
|
195
|
+
userType?: "external";
|
|
196
|
+
parentUuid?: string | null;
|
|
197
|
+
cwd?: string;
|
|
198
|
+
gitBranch?: string;
|
|
199
|
+
version?: string;
|
|
200
|
+
isSidechain?: boolean;
|
|
201
|
+
entrypoint?: string;
|
|
202
|
+
/** assistant-only request id. */
|
|
203
|
+
requestId?: string;
|
|
204
|
+
/** user-only prompt id. */
|
|
205
|
+
promptId?: string;
|
|
206
|
+
/** user-only tool-use result payload. */
|
|
207
|
+
toolUseResult?: unknown;
|
|
208
|
+
/** user-only permission mode. */
|
|
209
|
+
permissionMode?: string;
|
|
210
|
+
}
|
|
211
|
+
/** Options for {@link projectEvent}. */
|
|
212
|
+
export interface ProjectOptions {
|
|
213
|
+
/**
|
|
214
|
+
* Byte threshold above which an `image` block's base64 `source.data` is skipped (so a heavy
|
|
215
|
+
* ~630 KB PNG does not back-pressure the streaming read). Defaults to {@link DEFAULT_IMAGE_SKIP_BYTES}.
|
|
216
|
+
* Set `Infinity` to keep ALL image data inline.
|
|
217
|
+
*/
|
|
218
|
+
imageSkipBytes?: number;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Default byte threshold for {@link stripHeavyImages} / {@link projectEvent}: an `image` block's
|
|
222
|
+
* base64 `source.data` larger than this (~64 KB) is skipped, while a small inline image is kept.
|
|
223
|
+
* Chosen so a ~630 KB PNG is dropped but a typical small icon survives.
|
|
224
|
+
*/
|
|
225
|
+
export declare const DEFAULT_IMAGE_SKIP_BYTES: number;
|
|
226
|
+
/**
|
|
227
|
+
* Standalone heavy-image stripper (used by {@link projectEvent}; exported for direct testing).
|
|
228
|
+
*
|
|
229
|
+
* When `message.content` is an ARRAY, returns a SHALLOW-CLONED message whose content array has any
|
|
230
|
+
* heavy `image` block's base64 `source.data` replaced by a skipped marker — PRESERVING the block's
|
|
231
|
+
* `type`, `source.type`, `source.media_type`, adding `source.skipped = true` and `source.bytes =
|
|
232
|
+
* <original byte length>` so downstream stays structurally valid and keeps a size hint. Non-image
|
|
233
|
+
* blocks (e.g. `text`) and images below the threshold pass through UNCHANGED. When `message.content`
|
|
234
|
+
* is a raw STRING (or `message` is not an object / has no array content), the input is returned
|
|
235
|
+
* untouched. The input message and its blocks are NEVER mutated in place (the watcher may hold
|
|
236
|
+
* references) — only the heavy blocks are cloned (others are shared by reference, which is safe
|
|
237
|
+
* because we never mutate them).
|
|
238
|
+
*
|
|
239
|
+
* "Heavy" = `source.data` is a string whose UTF-8 byte length exceeds `imageSkipBytes`
|
|
240
|
+
* (default {@link DEFAULT_IMAGE_SKIP_BYTES}). A `data` getter could provide TRUE laziness, but a
|
|
241
|
+
* skip marker is sufficient for Degrau-1 and keeps the event serializable.
|
|
242
|
+
*
|
|
243
|
+
* @param message the API message object (or any value — non-matching shapes pass through).
|
|
244
|
+
* @param imageSkipBytes byte threshold; `source.data` larger than this is skipped.
|
|
245
|
+
* @returns the message with heavy image data skipped, or the original value untouched.
|
|
246
|
+
*/
|
|
247
|
+
export declare function stripHeavyImages(message: unknown, imageSkipBytes?: number): unknown;
|
|
248
|
+
/**
|
|
249
|
+
* Project a `getSessionMessages` message (or a raw-shaped event) into a typed {@link JsonlEvent}.
|
|
250
|
+
*
|
|
251
|
+
* Maps the SDK-shape fields: `session_id → sessionId`, `parent_tool_use_id → parentToolUseId`,
|
|
252
|
+
* carries `uuid` / `type` / `timestamp` / `message` through, and hardcodes `userType: 'external'`.
|
|
253
|
+
* Every OPTIONAL universal field and per-type extra (parentUuid, cwd, gitBranch, version,
|
|
254
|
+
* isSidechain, entrypoint, requestId, promptId, toolUseResult, permissionMode) is passed through
|
|
255
|
+
* ONLY if it is present on the input (defensive forward-compat), else left `undefined`. Tolerates
|
|
256
|
+
* `message.content` as an ARRAY or a raw STRING. By default also strips heavy `image` base64 data
|
|
257
|
+
* via {@link stripHeavyImages} (see `opts.imageSkipBytes`; raw-string content is left untouched).
|
|
258
|
+
*
|
|
259
|
+
* Never throws on unusual input: a missing `uuid` becomes `''`; a non-object input yields an event
|
|
260
|
+
* with empty `uuid`, `type === ''`, and `message === undefined`.
|
|
261
|
+
*
|
|
262
|
+
* @param message a `getSessionMessages` message (or raw-shaped event); any value is tolerated.
|
|
263
|
+
* @param opts projection options (the heavy-image byte threshold).
|
|
264
|
+
* @returns the typed {@link JsonlEvent}.
|
|
265
|
+
*/
|
|
266
|
+
export declare function projectEvent(message: unknown, opts?: ProjectOptions): JsonlEvent;
|
|
267
|
+
//# sourceMappingURL=jsonl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonl.d.ts","sourceRoot":"","sources":["../src/jsonl.ts"],"names":[],"mappings":"AAwBA;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAExD;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAK1D;AAED;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,OAAO,CAA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