claude-code-jsonl-parser 0.1.4-beta.23 → 0.1.4-beta.25
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 +44 -43
- package/dist/index.cjs +64 -66
- package/dist/index.d.cts +95 -95
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +95 -95
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +64 -66
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* claude-code-jsonl-parser
|
|
2
|
+
* claude-code-jsonl-parser: type-safe parser for Claude Code JSONL conversation logs.
|
|
3
3
|
*
|
|
4
4
|
* @example
|
|
5
5
|
* ```ts
|
|
@@ -16,16 +16,15 @@
|
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
18
|
/**
|
|
19
|
-
* Claude Code JSONL
|
|
20
|
-
* 形状の根拠は実サンプルコーパスの調査結果。
|
|
19
|
+
* Type definitions of the Claude Code JSONL entries.
|
|
21
20
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
21
|
+
* This file is maintained by hand.
|
|
22
|
+
* claude-code-jsonl-generator emits `types.generated.ts` for a corpus; diff that output against this file and merge intentionally.
|
|
23
|
+
* Content blocks and message shapes are curated by hand, so never overwrite them wholesale.
|
|
25
24
|
*/
|
|
26
|
-
/** parser
|
|
25
|
+
/** Internal discriminator added by the parser. Separate from the `type` field. */
|
|
27
26
|
type ParsedKind = 'known' | 'unknown' | 'error';
|
|
28
|
-
/** assistant / user / attachment / system
|
|
27
|
+
/** Required metadata shared by assistant / user / attachment / system. */
|
|
29
28
|
interface EntryBase {
|
|
30
29
|
cwd: string;
|
|
31
30
|
entrypoint: string;
|
|
@@ -37,7 +36,7 @@ interface EntryBase {
|
|
|
37
36
|
userType: string;
|
|
38
37
|
uuid: string;
|
|
39
38
|
version: string;
|
|
40
|
-
/**
|
|
39
|
+
/** Optional sidechain / sub-agent related fields (as observed) */
|
|
41
40
|
agentId?: string;
|
|
42
41
|
agentName?: string;
|
|
43
42
|
teamName?: string;
|
|
@@ -45,7 +44,7 @@ interface EntryBase {
|
|
|
45
44
|
sessionKind?: string;
|
|
46
45
|
session_id?: string;
|
|
47
46
|
}
|
|
48
|
-
/** `type: "assistant"
|
|
47
|
+
/** `type: "assistant"`: assistant response (wraps an Anthropic API message). */
|
|
49
48
|
interface AssistantEntry extends EntryBase {
|
|
50
49
|
_kind: 'known';
|
|
51
50
|
type: 'assistant';
|
|
@@ -60,13 +59,13 @@ interface AssistantEntry extends EntryBase {
|
|
|
60
59
|
attributionMcpServer?: string;
|
|
61
60
|
attributionMcpTool?: string;
|
|
62
61
|
}
|
|
63
|
-
/** `user.origin
|
|
62
|
+
/** `user.origin`: kind of origin and accompanying information. */
|
|
64
63
|
interface UserOrigin {
|
|
65
64
|
kind: string;
|
|
66
65
|
from?: string;
|
|
67
66
|
senderTaskId?: string;
|
|
68
67
|
}
|
|
69
|
-
/** `type: "user"
|
|
68
|
+
/** `type: "user"`: wraps user input / tool results. */
|
|
70
69
|
interface UserEntry extends EntryBase {
|
|
71
70
|
_kind: 'known';
|
|
72
71
|
type: 'user';
|
|
@@ -88,13 +87,13 @@ interface UserEntry extends EntryBase {
|
|
|
88
87
|
toolDenialKind?: string;
|
|
89
88
|
toolEndsTurn?: boolean;
|
|
90
89
|
}
|
|
91
|
-
/** `type: "attachment"
|
|
90
|
+
/** `type: "attachment"`: attached data. */
|
|
92
91
|
interface AttachmentEntry extends EntryBase {
|
|
93
92
|
_kind: 'known';
|
|
94
93
|
type: 'attachment';
|
|
95
94
|
attachment: Record<string, unknown>;
|
|
96
95
|
}
|
|
97
|
-
/** `type: "system"
|
|
96
|
+
/** `type: "system"`: system event (refined by `subtype`). */
|
|
98
97
|
interface SystemEntry extends EntryBase {
|
|
99
98
|
_kind: 'known';
|
|
100
99
|
type: 'system';
|
|
@@ -149,7 +148,7 @@ interface AgentNameEntry {
|
|
|
149
148
|
agentName: string;
|
|
150
149
|
sessionId: string;
|
|
151
150
|
}
|
|
152
|
-
/** `type: "agent-setting"
|
|
151
|
+
/** `type: "agent-setting"`: `agentSetting` is a string. */
|
|
153
152
|
interface AgentSettingEntry {
|
|
154
153
|
_kind: 'known';
|
|
155
154
|
type: 'agent-setting';
|
|
@@ -163,7 +162,7 @@ interface RelocatedEntry {
|
|
|
163
162
|
relocatedCwd: string;
|
|
164
163
|
sessionId: string;
|
|
165
164
|
}
|
|
166
|
-
/** `type: "last-prompt"
|
|
165
|
+
/** `type: "last-prompt"`: `lastPrompt` is optional. */
|
|
167
166
|
interface LastPromptEntry {
|
|
168
167
|
_kind: 'known';
|
|
169
168
|
type: 'last-prompt';
|
|
@@ -171,7 +170,7 @@ interface LastPromptEntry {
|
|
|
171
170
|
sessionId: string;
|
|
172
171
|
lastPrompt?: string;
|
|
173
172
|
}
|
|
174
|
-
/** `type: "worktree-state"
|
|
173
|
+
/** `type: "worktree-state"`: `worktreeSession` is an object or null. */
|
|
175
174
|
interface WorktreeStateEntry {
|
|
176
175
|
_kind: 'known';
|
|
177
176
|
type: 'worktree-state';
|
|
@@ -186,7 +185,7 @@ interface BridgeSessionEntry {
|
|
|
186
185
|
lastSequenceNum: number;
|
|
187
186
|
sessionId: string;
|
|
188
187
|
}
|
|
189
|
-
/** `type: "queue-operation"
|
|
188
|
+
/** `type: "queue-operation"`: `content` is optional. */
|
|
190
189
|
interface QueueOperationEntry {
|
|
191
190
|
_kind: 'known';
|
|
192
191
|
type: 'queue-operation';
|
|
@@ -214,7 +213,7 @@ interface FrameLinkEntry {
|
|
|
214
213
|
sessionId: string;
|
|
215
214
|
timestamp: string;
|
|
216
215
|
}
|
|
217
|
-
/** `type: "file-history-snapshot"
|
|
216
|
+
/** `type: "file-history-snapshot"`: has no sessionId. */
|
|
218
217
|
interface FileHistorySnapshotEntry {
|
|
219
218
|
_kind: 'known';
|
|
220
219
|
type: 'file-history-snapshot';
|
|
@@ -222,14 +221,14 @@ interface FileHistorySnapshotEntry {
|
|
|
222
221
|
messageId: string;
|
|
223
222
|
snapshot: Record<string, unknown>;
|
|
224
223
|
}
|
|
225
|
-
/** `type: "started"
|
|
224
|
+
/** `type: "started"`: comes from the workflow journal. Has no sessionId. */
|
|
226
225
|
interface StartedEntry {
|
|
227
226
|
_kind: 'known';
|
|
228
227
|
type: 'started';
|
|
229
228
|
key: string;
|
|
230
229
|
agentId: string;
|
|
231
230
|
}
|
|
232
|
-
/** `type: "result"
|
|
231
|
+
/** `type: "result"`: comes from the workflow journal. `result` has an arbitrary shape. */
|
|
233
232
|
interface ResultEntry {
|
|
234
233
|
_kind: 'known';
|
|
235
234
|
type: 'result';
|
|
@@ -237,26 +236,26 @@ interface ResultEntry {
|
|
|
237
236
|
agentId: string;
|
|
238
237
|
result: unknown;
|
|
239
238
|
}
|
|
240
|
-
/**
|
|
239
|
+
/** All entries of known types. */
|
|
241
240
|
type KnownEntry = AssistantEntry | UserEntry | AttachmentEntry | SystemEntry | ModeEntry | PermissionModeEntry | AiTitleEntry | AgentNameEntry | AgentSettingEntry | RelocatedEntry | LastPromptEntry | WorktreeStateEntry | BridgeSessionEntry | QueueOperationEntry | PrLinkEntry | FrameLinkEntry | FileHistorySnapshotEntry | StartedEntry | ResultEntry;
|
|
242
|
-
/** type
|
|
241
|
+
/** A line with an unknown type, or a known type whose shape did not match. Keeps the raw JSON. */
|
|
243
242
|
interface UnknownEntry {
|
|
244
243
|
_kind: 'unknown';
|
|
245
244
|
lineNumber: number;
|
|
246
245
|
raw: unknown;
|
|
247
|
-
/**
|
|
246
|
+
/** The type value when a guard exists for it but the shape did not match. `undefined` for an unknown type. */
|
|
248
247
|
typeHint?: string;
|
|
249
|
-
/** `typeHint`
|
|
248
|
+
/** When `typeHint` is set, a diagnostic message naming the fields that caused the mismatch. */
|
|
250
249
|
reason?: string;
|
|
251
250
|
}
|
|
252
|
-
/** JSON
|
|
251
|
+
/** A line with a JSON syntax error. */
|
|
253
252
|
interface LineParseError {
|
|
254
253
|
_kind: 'error';
|
|
255
254
|
lineNumber: number;
|
|
256
255
|
rawLine: string;
|
|
257
256
|
message: string;
|
|
258
257
|
}
|
|
259
|
-
/**
|
|
258
|
+
/** Parse result of one line. */
|
|
260
259
|
type ParsedLine = KnownEntry | UnknownEntry | LineParseError;
|
|
261
260
|
/** `{ type: "text", text }`。 */
|
|
262
261
|
interface TextBlock {
|
|
@@ -280,7 +279,7 @@ interface ToolUseBlock {
|
|
|
280
279
|
input: unknown;
|
|
281
280
|
caller?: unknown;
|
|
282
281
|
}
|
|
283
|
-
/**
|
|
282
|
+
/** `{ type: "image", source }` inside a tool_result. */
|
|
284
283
|
interface ImageBlock {
|
|
285
284
|
_kind: 'known';
|
|
286
285
|
type: 'image';
|
|
@@ -290,13 +289,13 @@ interface ImageBlock {
|
|
|
290
289
|
data: string;
|
|
291
290
|
};
|
|
292
291
|
}
|
|
293
|
-
/**
|
|
292
|
+
/** `{ type: "tool_reference", tool_name }` inside a tool_result. */
|
|
294
293
|
interface ToolReferenceBlock {
|
|
295
294
|
_kind: 'known';
|
|
296
295
|
type: 'tool_reference';
|
|
297
296
|
tool_name: string;
|
|
298
297
|
}
|
|
299
|
-
/** tool_result
|
|
298
|
+
/** Union of the elements of a tool_result content array. */
|
|
300
299
|
type ToolResultContentBlock = TextBlock | ImageBlock | ToolReferenceBlock | UnknownContentBlock;
|
|
301
300
|
/** `{ type: "tool_result", tool_use_id, content, is_error? }`。 */
|
|
302
301
|
interface ToolResultBlock {
|
|
@@ -307,20 +306,20 @@ interface ToolResultBlock {
|
|
|
307
306
|
is_error?: boolean;
|
|
308
307
|
}
|
|
309
308
|
/**
|
|
310
|
-
* content
|
|
311
|
-
* `_kind`
|
|
312
|
-
*
|
|
313
|
-
* (
|
|
309
|
+
* Partial fallback for a content block that matches no known shape.
|
|
310
|
+
* `_kind` is the same discriminator as on known blocks: check it for `'unknown'`
|
|
311
|
+
* first, and the known side can then be narrowed safely with `.type`
|
|
312
|
+
* (e.g. `if (block._kind === 'unknown') {...} else if (block.type === 'text') {...}`).
|
|
314
313
|
*/
|
|
315
314
|
interface UnknownContentBlock {
|
|
316
315
|
_kind: 'unknown';
|
|
317
316
|
raw: unknown;
|
|
318
317
|
}
|
|
319
|
-
/** assistant `message.content[]
|
|
318
|
+
/** Union of the elements of assistant `message.content[]`. */
|
|
320
319
|
type AssistantContentBlock = TextBlock | ThinkingBlock | ToolUseBlock | UnknownContentBlock;
|
|
321
|
-
/** user `message.content[]`
|
|
320
|
+
/** Union of the elements of user `message.content[]` (when content is an array). */
|
|
322
321
|
type UserContentBlock = TextBlock | ToolResultBlock | UnknownContentBlock;
|
|
323
|
-
/**
|
|
322
|
+
/** The Anthropic API message of an assistant entry. */
|
|
324
323
|
interface AssistantMessage {
|
|
325
324
|
id: string;
|
|
326
325
|
type: string;
|
|
@@ -335,7 +334,7 @@ interface AssistantMessage {
|
|
|
335
334
|
container?: unknown;
|
|
336
335
|
context_management?: unknown;
|
|
337
336
|
}
|
|
338
|
-
/**
|
|
337
|
+
/** User message. `content` is a string or an array. */
|
|
339
338
|
interface UserMessage {
|
|
340
339
|
role: string;
|
|
341
340
|
content: string | UserContentBlock[];
|
|
@@ -343,9 +342,9 @@ interface UserMessage {
|
|
|
343
342
|
/**
|
|
344
343
|
* Zero-dependency Result / ResultAsync implementation.
|
|
345
344
|
*
|
|
346
|
-
* neverthrow
|
|
345
|
+
* Offers neverthrow-like ergonomics without any external dependency.
|
|
347
346
|
*/
|
|
348
|
-
/**
|
|
347
|
+
/** A success. Holds `value`. */
|
|
349
348
|
interface OkResult<T> {
|
|
350
349
|
readonly isOk: true;
|
|
351
350
|
readonly isErr: false;
|
|
@@ -356,7 +355,7 @@ interface OkResult<T> {
|
|
|
356
355
|
match<U>(onOk: (value: T) => U, _onErr: (error: never) => U): U;
|
|
357
356
|
unwrapOr(_fallback: T): T;
|
|
358
357
|
}
|
|
359
|
-
/**
|
|
358
|
+
/** A failure. Holds `error`. */
|
|
360
359
|
interface ErrResult<E> {
|
|
361
360
|
readonly isOk: false;
|
|
362
361
|
readonly isErr: true;
|
|
@@ -367,120 +366,119 @@ interface ErrResult<E> {
|
|
|
367
366
|
match<U>(_onOk: (value: never) => U, onErr: (error: E) => U): U;
|
|
368
367
|
unwrapOr<T>(fallback: T): T;
|
|
369
368
|
}
|
|
370
|
-
/** `OkResult<T>`
|
|
369
|
+
/** Either `OkResult<T>` or `ErrResult<E>`. */
|
|
371
370
|
type Result<T, E> = OkResult<T> | ErrResult<E>;
|
|
372
371
|
/**
|
|
373
|
-
*
|
|
372
|
+
* Creates a success `Result<T, never>`.
|
|
374
373
|
*
|
|
375
|
-
* @param value -
|
|
374
|
+
* @param value - Success value
|
|
376
375
|
*/
|
|
377
376
|
export declare function ok<T>(value: T): OkResult<T>;
|
|
378
377
|
/**
|
|
379
|
-
*
|
|
378
|
+
* Creates a failure `Result<never, E>`.
|
|
380
379
|
*
|
|
381
|
-
* @param error -
|
|
380
|
+
* @param error - Error value
|
|
382
381
|
*/
|
|
383
382
|
export declare function err<E>(error: E): ErrResult<E>;
|
|
384
383
|
/**
|
|
385
|
-
* `
|
|
384
|
+
* A `PromiseLike<Result<T, E>>` that can be awaited and chained with `map` / `mapErr` / `andThen`.
|
|
386
385
|
*/
|
|
387
386
|
export declare class ResultAsync<T, E> implements PromiseLike<Result<T, E>> {
|
|
388
387
|
private readonly _promise;
|
|
389
388
|
constructor(promise: Promise<Result<T, E>>);
|
|
390
389
|
then<TResult1 = Result<T, E>, TResult2 = never>(onfulfilled?: ((value: Result<T, E>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): PromiseLike<TResult1 | TResult2>;
|
|
391
390
|
/**
|
|
392
|
-
* `Promise<T>`
|
|
391
|
+
* Wraps a `Promise<T>` in a `ResultAsync<T, E>`. A rejection is mapped to `E` with `onError`.
|
|
393
392
|
*
|
|
394
|
-
* @param promise -
|
|
395
|
-
* @param onError -
|
|
393
|
+
* @param promise - Target promise
|
|
394
|
+
* @param onError - Error mapper
|
|
396
395
|
*/
|
|
397
396
|
static fromPromise<T, E>(promise: Promise<T>, onError: (reason: unknown) => E): ResultAsync<T, E>;
|
|
398
397
|
/**
|
|
399
|
-
*
|
|
398
|
+
* Wraps a resolved `Result<T, E>` in a `ResultAsync<T, E>`.
|
|
400
399
|
*
|
|
401
|
-
* @param result -
|
|
400
|
+
* @param result - Target result
|
|
402
401
|
*/
|
|
403
402
|
static fromResult<T, E>(result: Result<T, E>): ResultAsync<T, E>;
|
|
404
403
|
/**
|
|
405
|
-
*
|
|
404
|
+
* Transforms the success value.
|
|
406
405
|
*
|
|
407
|
-
* @param fn -
|
|
406
|
+
* @param fn - Synchronous mapper
|
|
408
407
|
*/
|
|
409
408
|
map<U>(fn: (value: T) => U): ResultAsync<U, E>;
|
|
410
409
|
/**
|
|
411
|
-
*
|
|
410
|
+
* Transforms the error value.
|
|
412
411
|
*
|
|
413
|
-
* @param fn -
|
|
412
|
+
* @param fn - Synchronous error mapper
|
|
414
413
|
*/
|
|
415
414
|
mapErr<F>(fn: (error: E) => F): ResultAsync<T, F>;
|
|
416
415
|
/**
|
|
417
|
-
*
|
|
416
|
+
* Chains a step that may fail.
|
|
418
417
|
*
|
|
419
|
-
* @param fn - `ResultAsync<U, F>`
|
|
418
|
+
* @param fn - Mapper returning a `ResultAsync<U, F>` or `Result<U, F>`
|
|
420
419
|
*/
|
|
421
420
|
andThen<U, F>(fn: (value: T) => ResultAsync<U, F> | Result<U, F>): ResultAsync<U, E | F>;
|
|
422
421
|
/**
|
|
423
|
-
*
|
|
422
|
+
* Pattern-matches on success / failure.
|
|
424
423
|
*
|
|
425
|
-
* @param onOk -
|
|
426
|
-
* @param onErr -
|
|
424
|
+
* @param onOk - Success handler
|
|
425
|
+
* @param onErr - Error handler
|
|
427
426
|
*/
|
|
428
427
|
match<U>(onOk: (value: T) => U | Promise<U>, onErr: (error: E) => U | Promise<U>): Promise<U>;
|
|
429
428
|
/**
|
|
430
|
-
*
|
|
429
|
+
* Returns the value on success, or `fallback` on failure.
|
|
431
430
|
*
|
|
432
|
-
* @param fallback -
|
|
431
|
+
* @param fallback - Fallback value
|
|
433
432
|
*/
|
|
434
433
|
unwrapOr(fallback: T): Promise<T>;
|
|
435
434
|
}
|
|
436
|
-
/**
|
|
435
|
+
/** An error caused by file I/O. JSON syntax errors and unknown types are not included. */
|
|
437
436
|
interface FileReadError {
|
|
438
437
|
_tag: 'FileReadError';
|
|
439
438
|
path: string;
|
|
440
|
-
/** Node.js
|
|
439
|
+
/** Node.js error code (`ENOENT`, `EACCES`, ...). `undefined` if unavailable. */
|
|
441
440
|
code?: string;
|
|
442
441
|
message: string;
|
|
443
442
|
}
|
|
444
443
|
/**
|
|
445
|
-
* FileReadError
|
|
444
|
+
* Creates a `FileReadError`.
|
|
446
445
|
*
|
|
447
|
-
* @param path -
|
|
448
|
-
* @param error -
|
|
446
|
+
* @param path - Target path
|
|
447
|
+
* @param error - Caught exception
|
|
449
448
|
*/
|
|
450
449
|
export declare function fileReadError(path: string, error: unknown): FileReadError;
|
|
451
450
|
/**
|
|
452
|
-
* JSONL
|
|
453
|
-
* `text.split('\n')
|
|
454
|
-
* 追加メモリは 1 行分にとどまる (全行配列分の追加確保が発生しない)。
|
|
451
|
+
* Synchronous iterator that parses a JSONL string line by line.
|
|
452
|
+
* It slices one line at a time with `indexOf` instead of building a full line array with `text.split('\n')`, so the extra memory stays at one line.
|
|
455
453
|
*
|
|
456
|
-
*
|
|
454
|
+
* Blank lines (empty after trimming) are skipped and not counted in line numbers.
|
|
457
455
|
*
|
|
458
|
-
* @param text - JSONL
|
|
456
|
+
* @param text - Whole JSONL text
|
|
459
457
|
*/
|
|
460
458
|
export declare function parseJsonlLines(text: string): Iterable<ParsedLine>;
|
|
461
459
|
/**
|
|
462
|
-
* JSONL
|
|
463
|
-
*
|
|
460
|
+
* Parses a whole JSONL string and returns the lines as an array.
|
|
461
|
+
* Per-line errors are represented as array elements, so this function never returns `Err`.
|
|
464
462
|
*
|
|
465
|
-
* @param text - JSONL
|
|
463
|
+
* @param text - Whole JSONL text
|
|
466
464
|
*/
|
|
467
465
|
export declare function parseJsonl(text: string): Result<ParsedLine[], never>;
|
|
468
466
|
/**
|
|
469
|
-
*
|
|
470
|
-
* I/O
|
|
467
|
+
* Asynchronous iterator that reads and parses a file line by line (constant memory).
|
|
468
|
+
* An I/O error is thrown as a `FileReadError` during iteration.
|
|
471
469
|
*
|
|
472
|
-
* @param path - JSONL
|
|
470
|
+
* @param path - JSONL file path
|
|
473
471
|
*/
|
|
474
472
|
export declare function parseJsonlFileStream(path: string): AsyncIterable<ParsedLine>;
|
|
475
473
|
/**
|
|
476
|
-
*
|
|
474
|
+
* Reads a whole file and parses it at once. Only I/O errors become `Err`.
|
|
477
475
|
*
|
|
478
|
-
* @param path - JSONL
|
|
476
|
+
* @param path - JSONL file path
|
|
479
477
|
*/
|
|
480
478
|
export declare function parseJsonlFile(path: string): ResultAsync<ParsedLine[], FileReadError>;
|
|
481
479
|
/**
|
|
482
|
-
*
|
|
483
|
-
*
|
|
480
|
+
* Result of a guard. When `ok` is false, `reason` holds a diagnostic message such
|
|
481
|
+
* as the names of the mismatching fields, so consumers can see what caused the mismatch.
|
|
484
482
|
*/
|
|
485
483
|
interface GuardResult {
|
|
486
484
|
ok: boolean;
|
|
@@ -505,7 +503,7 @@ declare function isFrameLink(v: unknown): GuardResult;
|
|
|
505
503
|
declare function isFileHistorySnapshot(v: unknown): GuardResult;
|
|
506
504
|
declare function isStarted(v: unknown): GuardResult;
|
|
507
505
|
declare function isResult(v: unknown): GuardResult;
|
|
508
|
-
/** type
|
|
506
|
+
/** Map from type string to guard function. */
|
|
509
507
|
export declare const guards: {
|
|
510
508
|
readonly assistant: typeof isAssistant;
|
|
511
509
|
readonly user: typeof isUser;
|
|
@@ -527,28 +525,30 @@ export declare const guards: {
|
|
|
527
525
|
readonly started: typeof isStarted;
|
|
528
526
|
readonly result: typeof isResult;
|
|
529
527
|
};
|
|
530
|
-
/**
|
|
528
|
+
/** Names of the known types. */
|
|
531
529
|
export declare const KNOWN_TYPES: (keyof typeof guards)[];
|
|
532
530
|
/**
|
|
533
|
-
*
|
|
534
|
-
*
|
|
535
|
-
*
|
|
531
|
+
* Applies the guard of the given type, or returns undefined if no guard exists for it.
|
|
532
|
+
* Returns `{ ok: true }` on a match and `{ ok: false, reason }` on a mismatch, where
|
|
533
|
+
* `reason` names the fields that caused it.
|
|
536
534
|
*
|
|
537
|
-
* @param type -
|
|
538
|
-
* @param v -
|
|
535
|
+
* @param type - Discriminator
|
|
536
|
+
* @param v - Raw JSON to check
|
|
539
537
|
*/
|
|
540
538
|
export declare function guardByType(type: string, v: unknown): GuardResult | undefined;
|
|
541
539
|
/**
|
|
542
|
-
*
|
|
543
|
-
*
|
|
540
|
+
* Normalizes the message.content of an assistant entry.
|
|
541
|
+
* Known blocks are kept as is; unknown ones are demoted to `UnknownContentBlock`.
|
|
542
|
+
* A non-array value becomes a single `UnknownContentBlock`.
|
|
544
543
|
*
|
|
545
|
-
* @param content -
|
|
544
|
+
* @param content - Raw content
|
|
546
545
|
*/
|
|
547
546
|
export declare function normalizeAssistantContent(content: unknown): AssistantContentBlock[];
|
|
548
547
|
/**
|
|
549
|
-
*
|
|
548
|
+
* Normalizes the message.content of a user entry. A string is returned as is and an array is normalized per element.
|
|
549
|
+
* Any other value becomes a single `UnknownContentBlock`.
|
|
550
550
|
*
|
|
551
|
-
* @param content -
|
|
551
|
+
* @param content - Raw content (string or array)
|
|
552
552
|
*/
|
|
553
553
|
export declare function normalizeUserContent(content: unknown): string | UserContentBlock[];
|
|
554
554
|
export type { AgentNameEntry, AgentSettingEntry, AiTitleEntry, AssistantContentBlock, AssistantEntry, AssistantMessage, AttachmentEntry, BridgeSessionEntry, EntryBase, ErrResult, FileHistorySnapshotEntry, FileReadError, FrameLinkEntry, GuardResult, ImageBlock, KnownEntry, LastPromptEntry, LineParseError, ModeEntry, OkResult, ParsedKind, ParsedLine, PermissionModeEntry, PrLinkEntry, QueueOperationEntry, RelocatedEntry, Result, ResultEntry, StartedEntry, SystemEntry, TextBlock, ThinkingBlock, ToolReferenceBlock, ToolResultBlock, ToolResultContentBlock, ToolUseBlock, UnknownContentBlock, UnknownEntry, UserContentBlock, UserEntry, UserMessage, WorktreeStateEntry };
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/generated/types.ts","../src/result.ts","../src/errors.ts","../src/parse.ts","../src/generated/guards.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/generated/types.ts","../src/result.ts","../src/errors.ts","../src/parse.ts","../src/generated/guards.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;KAaY;;UAOK;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;;;UAQe,uBAAuB;EACtC;EACA;EACA,SAAS;EACT;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;UAIe;EACf;EACA;EACA;;;UAIe,kBAAkB;EACjC;EACA;EACA,SAAS;EACT;EACA;EACA;EACA,SAAS;EACT;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;UAIe,wBAAwB;EACvC;EACA;EACA,YAAY;;;UAIG,oBAAoB;EACnC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;UAQe;EACf;EACA;EACA;EACA;;;UAIe;EACf;EACA;EACA;EACA;;;UAIe;EACf;EACA;EACA;EACA;;;UAIe;EACf;EACA;EACA;EACA;;;UAIe;EACf;EACA;EACA;EACA;;;UAIe;EACf;EACA;EACA;EACA;;;UAIe;EACf;EACA;EACA;EACA;EACA;;;UAIe;EACf;EACA;EACA,iBAAiB;EACjB;;;UAIe;EACf;EACA;EACA;EACA;EACA;;;UAIe;EACf;EACA;EACA;EACA;EACA;EACA;;;UAIe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;;;UAIe;EACf;EACA;EACA;EACA;EACA;EACA;;;UAIe;EACf;EACA;EACA;EACA;EACA,UAAU;;;UAIK;EACf;EACA;EACA;EACA;;;UAIe;EACf;EACA;EACA;EACA;EACA;;;KAQU,aACR,iBACA,YACA,kBACA,cACA,YACA,sBACA,eACA,iBACA,oBACA,iBACA,kBACA,qBACA,qBACA,sBACA,cACA,iBACA,2BACA,eACA;;UAGa;EACf;EACA;EACA;;EAEA;;EAEA;;;UAIe;EACf;EACA;EACA;EACA;;;KAIU,aAAa,aAAa,eAAe;;UAOpC;EACf;EACA;EACA;;;UAIe;EACf;EACA;EACA;EACA;;;UAIe;EACf;EACA;EACA;EACA;EACA;EACA;;;UAIe;EACf;EACA;EACA;IACE;IACA;IACA;;;;UAKa;EACf;EACA;EACA;;;KAIU,yBACR,YACA,aACA,qBACA;;UAGa;EACf;EACA;EACA;EACA,kBAAkB;EAClB;;;;;;;;UASe;EACf;EACA;;;KAIU,wBACR,YACA,gBACA,eACA;;KAGQ,mBAAmB,YAAY,kBAAkB;;UAO5C;EACf;EACA;EACA;EACA;EACA,SAAS;EACT;EACA;EACA;EACA;EACA;EACA;EACA;;;UAIe;EACf;EACA,kBAAkB;;;;;;;;UCpZH,SAAS;WACf;WACA;WACA,OAAO;EAChB,IAAI,GAAG,KAAK,OAAO,MAAM,IAAI,SAAS;EAEtC,OAAO,GAAG,MAAM,iBAAiB,IAAI,SAAS;EAC9C,QAAQ,GAAG,GAAG,KAAK,OAAO,MAAM,OAAO,GAAG,KAAK,OAAO,GAAG;EACzD,MAAM,GAAG,OAAO,OAAO,MAAM,GAAG,SAAS,iBAAiB,IAAI;EAC9D,SAAS,WAAW,IAAI;;;UAIT,UAAU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