@unpolarize/code-sessions-schema 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.
@@ -0,0 +1,625 @@
1
+ import * as zod from 'zod';
2
+ import { z } from 'zod';
3
+ import * as zod_to_json_schema from 'zod-to-json-schema';
4
+
5
+ /**
6
+ * Canonical, agent-neutral session record schemas.
7
+ *
8
+ * Every record carries a versioned `schema` tag so consumers can migrate the
9
+ * way the SQLite `user_version` pattern does. Native records are adapted INTO
10
+ * these shapes while the verbatim `raw` event is preserved for lossless resume.
11
+ */
12
+ declare const AGENTS: readonly ["claude-code", "codex", "grok", "unknown"];
13
+ declare const ROLES: readonly ["user", "assistant", "tool", "system"];
14
+ declare const UsageSchema: z.ZodObject<{
15
+ input_tokens: z.ZodDefault<z.ZodNumber>;
16
+ output_tokens: z.ZodDefault<z.ZodNumber>;
17
+ cache_read_tokens: z.ZodDefault<z.ZodNumber>;
18
+ cache_write_tokens: z.ZodDefault<z.ZodNumber>;
19
+ }, "strict", z.ZodTypeAny, {
20
+ input_tokens: number;
21
+ output_tokens: number;
22
+ cache_read_tokens: number;
23
+ cache_write_tokens: number;
24
+ }, {
25
+ input_tokens?: number | undefined;
26
+ output_tokens?: number | undefined;
27
+ cache_read_tokens?: number | undefined;
28
+ cache_write_tokens?: number | undefined;
29
+ }>;
30
+ declare const ToolCallSchema: z.ZodObject<{
31
+ name: z.ZodString;
32
+ input: z.ZodOptional<z.ZodUnknown>;
33
+ id: z.ZodOptional<z.ZodString>;
34
+ }, "strict", z.ZodTypeAny, {
35
+ name: string;
36
+ input?: unknown;
37
+ id?: string | undefined;
38
+ }, {
39
+ name: string;
40
+ input?: unknown;
41
+ id?: string | undefined;
42
+ }>;
43
+ declare const TelemetrySchema: z.ZodObject<{
44
+ latency_ms: z.ZodOptional<z.ZodNumber>;
45
+ cost_usd: z.ZodOptional<z.ZodNumber>;
46
+ }, "strict", z.ZodTypeAny, {
47
+ latency_ms?: number | undefined;
48
+ cost_usd?: number | undefined;
49
+ }, {
50
+ latency_ms?: number | undefined;
51
+ cost_usd?: number | undefined;
52
+ }>;
53
+ /** Immutable, write-once per-turn record: turns/NNNNNN.json */
54
+ declare const TurnSchema: z.ZodObject<{
55
+ schema: z.ZodLiteral<"session-store/turn@1">;
56
+ session_id: z.ZodString;
57
+ host: z.ZodString;
58
+ agent: z.ZodEnum<["claude-code", "codex", "grok", "unknown"]>;
59
+ turn_index: z.ZodNumber;
60
+ ts: z.ZodString;
61
+ role: z.ZodEnum<["user", "assistant", "tool", "system"]>;
62
+ text: z.ZodDefault<z.ZodString>;
63
+ tool_calls: z.ZodDefault<z.ZodArray<z.ZodObject<{
64
+ name: z.ZodString;
65
+ input: z.ZodOptional<z.ZodUnknown>;
66
+ id: z.ZodOptional<z.ZodString>;
67
+ }, "strict", z.ZodTypeAny, {
68
+ name: string;
69
+ input?: unknown;
70
+ id?: string | undefined;
71
+ }, {
72
+ name: string;
73
+ input?: unknown;
74
+ id?: string | undefined;
75
+ }>, "many">>;
76
+ usage: z.ZodDefault<z.ZodObject<{
77
+ input_tokens: z.ZodDefault<z.ZodNumber>;
78
+ output_tokens: z.ZodDefault<z.ZodNumber>;
79
+ cache_read_tokens: z.ZodDefault<z.ZodNumber>;
80
+ cache_write_tokens: z.ZodDefault<z.ZodNumber>;
81
+ }, "strict", z.ZodTypeAny, {
82
+ input_tokens: number;
83
+ output_tokens: number;
84
+ cache_read_tokens: number;
85
+ cache_write_tokens: number;
86
+ }, {
87
+ input_tokens?: number | undefined;
88
+ output_tokens?: number | undefined;
89
+ cache_read_tokens?: number | undefined;
90
+ cache_write_tokens?: number | undefined;
91
+ }>>;
92
+ telemetry: z.ZodOptional<z.ZodObject<{
93
+ latency_ms: z.ZodOptional<z.ZodNumber>;
94
+ cost_usd: z.ZodOptional<z.ZodNumber>;
95
+ }, "strict", z.ZodTypeAny, {
96
+ latency_ms?: number | undefined;
97
+ cost_usd?: number | undefined;
98
+ }, {
99
+ latency_ms?: number | undefined;
100
+ cost_usd?: number | undefined;
101
+ }>>;
102
+ /** true when secret-scrubbing redacted content in this turn */
103
+ scrubbed: z.ZodDefault<z.ZodBoolean>;
104
+ /** sha256 pointer when a large tool output was externalized to raw/ */
105
+ raw_ref: z.ZodDefault<z.ZodNullable<z.ZodString>>;
106
+ /** verbatim native event for lossless tier-1 resume */
107
+ raw: z.ZodOptional<z.ZodUnknown>;
108
+ }, "strict", z.ZodTypeAny, {
109
+ schema: "session-store/turn@1";
110
+ session_id: string;
111
+ host: string;
112
+ agent: "claude-code" | "codex" | "grok" | "unknown";
113
+ turn_index: number;
114
+ ts: string;
115
+ role: "user" | "assistant" | "tool" | "system";
116
+ text: string;
117
+ tool_calls: {
118
+ name: string;
119
+ input?: unknown;
120
+ id?: string | undefined;
121
+ }[];
122
+ usage: {
123
+ input_tokens: number;
124
+ output_tokens: number;
125
+ cache_read_tokens: number;
126
+ cache_write_tokens: number;
127
+ };
128
+ scrubbed: boolean;
129
+ raw_ref: string | null;
130
+ telemetry?: {
131
+ latency_ms?: number | undefined;
132
+ cost_usd?: number | undefined;
133
+ } | undefined;
134
+ raw?: unknown;
135
+ }, {
136
+ schema: "session-store/turn@1";
137
+ session_id: string;
138
+ host: string;
139
+ agent: "claude-code" | "codex" | "grok" | "unknown";
140
+ turn_index: number;
141
+ ts: string;
142
+ role: "user" | "assistant" | "tool" | "system";
143
+ text?: string | undefined;
144
+ tool_calls?: {
145
+ name: string;
146
+ input?: unknown;
147
+ id?: string | undefined;
148
+ }[] | undefined;
149
+ usage?: {
150
+ input_tokens?: number | undefined;
151
+ output_tokens?: number | undefined;
152
+ cache_read_tokens?: number | undefined;
153
+ cache_write_tokens?: number | undefined;
154
+ } | undefined;
155
+ telemetry?: {
156
+ latency_ms?: number | undefined;
157
+ cost_usd?: number | undefined;
158
+ } | undefined;
159
+ scrubbed?: boolean | undefined;
160
+ raw_ref?: string | null | undefined;
161
+ raw?: unknown;
162
+ }>;
163
+ declare const TotalsSchema: z.ZodObject<{
164
+ input_tokens: z.ZodDefault<z.ZodNumber>;
165
+ output_tokens: z.ZodDefault<z.ZodNumber>;
166
+ cost_usd: z.ZodDefault<z.ZodNumber>;
167
+ }, "strict", z.ZodTypeAny, {
168
+ input_tokens: number;
169
+ output_tokens: number;
170
+ cost_usd: number;
171
+ }, {
172
+ input_tokens?: number | undefined;
173
+ output_tokens?: number | undefined;
174
+ cost_usd?: number | undefined;
175
+ }>;
176
+ declare const NativeRefSchema: z.ZodObject<{
177
+ format: z.ZodString;
178
+ uuid: z.ZodString;
179
+ }, "strict", z.ZodTypeAny, {
180
+ format: string;
181
+ uuid: string;
182
+ }, {
183
+ format: string;
184
+ uuid: string;
185
+ }>;
186
+ /** Derived, rebuildable aggregate: session.json */
187
+ declare const SessionSchema: z.ZodObject<{
188
+ schema: z.ZodLiteral<"session-store/session@1">;
189
+ session_id: z.ZodString;
190
+ host: z.ZodString;
191
+ agent: z.ZodEnum<["claude-code", "codex", "grok", "unknown"]>;
192
+ project_path: z.ZodDefault<z.ZodString>;
193
+ git_branch: z.ZodOptional<z.ZodString>;
194
+ model: z.ZodOptional<z.ZodString>;
195
+ started_at: z.ZodOptional<z.ZodString>;
196
+ ended_at: z.ZodOptional<z.ZodString>;
197
+ turn_count: z.ZodDefault<z.ZodNumber>;
198
+ tool_call_count: z.ZodDefault<z.ZodNumber>;
199
+ totals: z.ZodDefault<z.ZodObject<{
200
+ input_tokens: z.ZodDefault<z.ZodNumber>;
201
+ output_tokens: z.ZodDefault<z.ZodNumber>;
202
+ cost_usd: z.ZodDefault<z.ZodNumber>;
203
+ }, "strict", z.ZodTypeAny, {
204
+ input_tokens: number;
205
+ output_tokens: number;
206
+ cost_usd: number;
207
+ }, {
208
+ input_tokens?: number | undefined;
209
+ output_tokens?: number | undefined;
210
+ cost_usd?: number | undefined;
211
+ }>>;
212
+ title: z.ZodOptional<z.ZodString>;
213
+ labels: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
214
+ native_ref: z.ZodObject<{
215
+ format: z.ZodString;
216
+ uuid: z.ZodString;
217
+ }, "strict", z.ZodTypeAny, {
218
+ format: string;
219
+ uuid: string;
220
+ }, {
221
+ format: string;
222
+ uuid: string;
223
+ }>;
224
+ }, "strict", z.ZodTypeAny, {
225
+ schema: "session-store/session@1";
226
+ session_id: string;
227
+ host: string;
228
+ agent: "claude-code" | "codex" | "grok" | "unknown";
229
+ project_path: string;
230
+ turn_count: number;
231
+ tool_call_count: number;
232
+ totals: {
233
+ input_tokens: number;
234
+ output_tokens: number;
235
+ cost_usd: number;
236
+ };
237
+ labels: string[];
238
+ native_ref: {
239
+ format: string;
240
+ uuid: string;
241
+ };
242
+ git_branch?: string | undefined;
243
+ model?: string | undefined;
244
+ started_at?: string | undefined;
245
+ ended_at?: string | undefined;
246
+ title?: string | undefined;
247
+ }, {
248
+ schema: "session-store/session@1";
249
+ session_id: string;
250
+ host: string;
251
+ agent: "claude-code" | "codex" | "grok" | "unknown";
252
+ native_ref: {
253
+ format: string;
254
+ uuid: string;
255
+ };
256
+ project_path?: string | undefined;
257
+ git_branch?: string | undefined;
258
+ model?: string | undefined;
259
+ started_at?: string | undefined;
260
+ ended_at?: string | undefined;
261
+ turn_count?: number | undefined;
262
+ tool_call_count?: number | undefined;
263
+ totals?: {
264
+ input_tokens?: number | undefined;
265
+ output_tokens?: number | undefined;
266
+ cost_usd?: number | undefined;
267
+ } | undefined;
268
+ title?: string | undefined;
269
+ labels?: string[] | undefined;
270
+ }>;
271
+ declare const SIGNAL_KINDS: readonly ["stuck-loop", "error-recovery", "high-cost-turn", "long-session", "affect-negative", "affect-positive", "tool-heavy", "other"];
272
+ declare const SignalSchema: z.ZodObject<{
273
+ kind: z.ZodEnum<["stuck-loop", "error-recovery", "high-cost-turn", "long-session", "affect-negative", "affect-positive", "tool-heavy", "other"]>;
274
+ severity: z.ZodDefault<z.ZodEnum<["info", "warn", "critical"]>>;
275
+ turn_index: z.ZodOptional<z.ZodNumber>;
276
+ note: z.ZodOptional<z.ZodString>;
277
+ }, "strict", z.ZodTypeAny, {
278
+ kind: "stuck-loop" | "error-recovery" | "high-cost-turn" | "long-session" | "affect-negative" | "affect-positive" | "tool-heavy" | "other";
279
+ severity: "info" | "warn" | "critical";
280
+ turn_index?: number | undefined;
281
+ note?: string | undefined;
282
+ }, {
283
+ kind: "stuck-loop" | "error-recovery" | "high-cost-turn" | "long-session" | "affect-negative" | "affect-positive" | "tool-heavy" | "other";
284
+ turn_index?: number | undefined;
285
+ severity?: "info" | "warn" | "critical" | undefined;
286
+ note?: string | undefined;
287
+ }>;
288
+ /** Derived insights: insights/labels.json (MVP-1.1) */
289
+ declare const InsightsSchema: z.ZodObject<{
290
+ schema: z.ZodLiteral<"session-store/insights@1">;
291
+ session_id: z.ZodString;
292
+ host: z.ZodString;
293
+ generated_at: z.ZodString;
294
+ provider: z.ZodString;
295
+ topic: z.ZodOptional<z.ZodString>;
296
+ tags: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
297
+ signals: z.ZodDefault<z.ZodArray<z.ZodObject<{
298
+ kind: z.ZodEnum<["stuck-loop", "error-recovery", "high-cost-turn", "long-session", "affect-negative", "affect-positive", "tool-heavy", "other"]>;
299
+ severity: z.ZodDefault<z.ZodEnum<["info", "warn", "critical"]>>;
300
+ turn_index: z.ZodOptional<z.ZodNumber>;
301
+ note: z.ZodOptional<z.ZodString>;
302
+ }, "strict", z.ZodTypeAny, {
303
+ kind: "stuck-loop" | "error-recovery" | "high-cost-turn" | "long-session" | "affect-negative" | "affect-positive" | "tool-heavy" | "other";
304
+ severity: "info" | "warn" | "critical";
305
+ turn_index?: number | undefined;
306
+ note?: string | undefined;
307
+ }, {
308
+ kind: "stuck-loop" | "error-recovery" | "high-cost-turn" | "long-session" | "affect-negative" | "affect-positive" | "tool-heavy" | "other";
309
+ turn_index?: number | undefined;
310
+ severity?: "info" | "warn" | "critical" | undefined;
311
+ note?: string | undefined;
312
+ }>, "many">>;
313
+ summary: z.ZodOptional<z.ZodString>;
314
+ }, "strict", z.ZodTypeAny, {
315
+ schema: "session-store/insights@1";
316
+ session_id: string;
317
+ host: string;
318
+ generated_at: string;
319
+ provider: string;
320
+ tags: string[];
321
+ signals: {
322
+ kind: "stuck-loop" | "error-recovery" | "high-cost-turn" | "long-session" | "affect-negative" | "affect-positive" | "tool-heavy" | "other";
323
+ severity: "info" | "warn" | "critical";
324
+ turn_index?: number | undefined;
325
+ note?: string | undefined;
326
+ }[];
327
+ topic?: string | undefined;
328
+ summary?: string | undefined;
329
+ }, {
330
+ schema: "session-store/insights@1";
331
+ session_id: string;
332
+ host: string;
333
+ generated_at: string;
334
+ provider: string;
335
+ topic?: string | undefined;
336
+ tags?: string[] | undefined;
337
+ signals?: {
338
+ kind: "stuck-loop" | "error-recovery" | "high-cost-turn" | "long-session" | "affect-negative" | "affect-positive" | "tool-heavy" | "other";
339
+ turn_index?: number | undefined;
340
+ severity?: "info" | "warn" | "critical" | undefined;
341
+ note?: string | undefined;
342
+ }[] | undefined;
343
+ summary?: string | undefined;
344
+ }>;
345
+ type Usage = z.infer<typeof UsageSchema>;
346
+ type ToolCall = z.infer<typeof ToolCallSchema>;
347
+ type Telemetry = z.infer<typeof TelemetrySchema>;
348
+ type Turn = z.infer<typeof TurnSchema>;
349
+ type Totals = z.infer<typeof TotalsSchema>;
350
+ type SessionEnvelope = z.infer<typeof SessionSchema>;
351
+ type Signal = z.infer<typeof SignalSchema>;
352
+ type Insights = z.infer<typeof InsightsSchema>;
353
+ type AgentKind = (typeof AGENTS)[number];
354
+ type Role = (typeof ROLES)[number];
355
+ type SignalKind = (typeof SIGNAL_KINDS)[number];
356
+ declare const SCHEMA_VERSIONS: {
357
+ readonly turn: "session-store/turn@1";
358
+ readonly session: "session-store/session@1";
359
+ readonly insights: "session-store/insights@1";
360
+ };
361
+
362
+ interface NormalizedEvent {
363
+ ts: string;
364
+ role: Role;
365
+ text: string;
366
+ tool_calls: ToolCall[];
367
+ usage: Usage;
368
+ raw: unknown;
369
+ }
370
+ interface BuildTurnContext {
371
+ session_id: string;
372
+ host: string;
373
+ agent: AgentKind;
374
+ turn_index: number;
375
+ }
376
+ /** Map a single native Claude line into a normalized event, or null if it is metadata. */
377
+ declare function normalizeClaudeEvent(raw: unknown, fallbackTs?: string): NormalizedEvent | null;
378
+ /** Assemble a complete, schema-valid Turn from a normalized event + identity context. */
379
+ declare function buildTurn(ev: NormalizedEvent, ctx: BuildTurnContext): Turn;
380
+ interface ClaudeSessionMeta {
381
+ session_id?: string;
382
+ model?: string;
383
+ project_path?: string;
384
+ git_branch?: string;
385
+ title?: string;
386
+ started_at?: string;
387
+ ended_at?: string;
388
+ }
389
+ /** Pull session-envelope metadata out of a batch of native Claude lines. */
390
+ declare function extractClaudeSessionMeta(rawLines: unknown[]): ClaudeSessionMeta;
391
+ /** Convenience: normalize a full batch of lines with sequential turn indices (for tests/backfill). */
392
+ declare function normalizeClaudeLines(rawLines: unknown[], ctx: {
393
+ session_id: string;
394
+ host: string;
395
+ agent: AgentKind;
396
+ startIndex?: number;
397
+ }): {
398
+ turns: Turn[];
399
+ meta: ClaudeSessionMeta;
400
+ };
401
+
402
+ /** JSON Schema (draft-07) representations for external (non-TS) consumers. */
403
+ declare const turnJsonSchema: zod_to_json_schema.JsonSchema7Type & {
404
+ $schema?: string | undefined;
405
+ definitions?: {
406
+ [key: string]: zod_to_json_schema.JsonSchema7Type;
407
+ } | undefined;
408
+ };
409
+ declare const sessionJsonSchema: zod_to_json_schema.JsonSchema7Type & {
410
+ $schema?: string | undefined;
411
+ definitions?: {
412
+ [key: string]: zod_to_json_schema.JsonSchema7Type;
413
+ } | undefined;
414
+ };
415
+ declare const insightsJsonSchema: zod_to_json_schema.JsonSchema7Type & {
416
+ $schema?: string | undefined;
417
+ definitions?: {
418
+ [key: string]: zod_to_json_schema.JsonSchema7Type;
419
+ } | undefined;
420
+ };
421
+ /** Parse + validate (throws on invalid). Applies schema defaults. */
422
+ declare const parseTurn: (data: unknown) => {
423
+ schema: "session-store/turn@1";
424
+ session_id: string;
425
+ host: string;
426
+ agent: "claude-code" | "codex" | "grok" | "unknown";
427
+ turn_index: number;
428
+ ts: string;
429
+ role: "user" | "assistant" | "tool" | "system";
430
+ text: string;
431
+ tool_calls: {
432
+ name: string;
433
+ input?: unknown;
434
+ id?: string | undefined;
435
+ }[];
436
+ usage: {
437
+ input_tokens: number;
438
+ output_tokens: number;
439
+ cache_read_tokens: number;
440
+ cache_write_tokens: number;
441
+ };
442
+ scrubbed: boolean;
443
+ raw_ref: string | null;
444
+ telemetry?: {
445
+ latency_ms?: number | undefined;
446
+ cost_usd?: number | undefined;
447
+ } | undefined;
448
+ raw?: unknown;
449
+ };
450
+ declare const parseSession: (data: unknown) => {
451
+ schema: "session-store/session@1";
452
+ session_id: string;
453
+ host: string;
454
+ agent: "claude-code" | "codex" | "grok" | "unknown";
455
+ project_path: string;
456
+ turn_count: number;
457
+ tool_call_count: number;
458
+ totals: {
459
+ input_tokens: number;
460
+ output_tokens: number;
461
+ cost_usd: number;
462
+ };
463
+ labels: string[];
464
+ native_ref: {
465
+ format: string;
466
+ uuid: string;
467
+ };
468
+ git_branch?: string | undefined;
469
+ model?: string | undefined;
470
+ started_at?: string | undefined;
471
+ ended_at?: string | undefined;
472
+ title?: string | undefined;
473
+ };
474
+ declare const parseInsights: (data: unknown) => {
475
+ schema: "session-store/insights@1";
476
+ session_id: string;
477
+ host: string;
478
+ generated_at: string;
479
+ provider: string;
480
+ tags: string[];
481
+ signals: {
482
+ kind: "stuck-loop" | "error-recovery" | "high-cost-turn" | "long-session" | "affect-negative" | "affect-positive" | "tool-heavy" | "other";
483
+ severity: "info" | "warn" | "critical";
484
+ turn_index?: number | undefined;
485
+ note?: string | undefined;
486
+ }[];
487
+ topic?: string | undefined;
488
+ summary?: string | undefined;
489
+ };
490
+ /** Non-throwing validation. */
491
+ declare const safeParseTurn: (data: unknown) => zod.SafeParseReturnType<{
492
+ schema: "session-store/turn@1";
493
+ session_id: string;
494
+ host: string;
495
+ agent: "claude-code" | "codex" | "grok" | "unknown";
496
+ turn_index: number;
497
+ ts: string;
498
+ role: "user" | "assistant" | "tool" | "system";
499
+ text?: string | undefined;
500
+ tool_calls?: {
501
+ name: string;
502
+ input?: unknown;
503
+ id?: string | undefined;
504
+ }[] | undefined;
505
+ usage?: {
506
+ input_tokens?: number | undefined;
507
+ output_tokens?: number | undefined;
508
+ cache_read_tokens?: number | undefined;
509
+ cache_write_tokens?: number | undefined;
510
+ } | undefined;
511
+ telemetry?: {
512
+ latency_ms?: number | undefined;
513
+ cost_usd?: number | undefined;
514
+ } | undefined;
515
+ scrubbed?: boolean | undefined;
516
+ raw_ref?: string | null | undefined;
517
+ raw?: unknown;
518
+ }, {
519
+ schema: "session-store/turn@1";
520
+ session_id: string;
521
+ host: string;
522
+ agent: "claude-code" | "codex" | "grok" | "unknown";
523
+ turn_index: number;
524
+ ts: string;
525
+ role: "user" | "assistant" | "tool" | "system";
526
+ text: string;
527
+ tool_calls: {
528
+ name: string;
529
+ input?: unknown;
530
+ id?: string | undefined;
531
+ }[];
532
+ usage: {
533
+ input_tokens: number;
534
+ output_tokens: number;
535
+ cache_read_tokens: number;
536
+ cache_write_tokens: number;
537
+ };
538
+ scrubbed: boolean;
539
+ raw_ref: string | null;
540
+ telemetry?: {
541
+ latency_ms?: number | undefined;
542
+ cost_usd?: number | undefined;
543
+ } | undefined;
544
+ raw?: unknown;
545
+ }>;
546
+ declare const safeParseSession: (data: unknown) => zod.SafeParseReturnType<{
547
+ schema: "session-store/session@1";
548
+ session_id: string;
549
+ host: string;
550
+ agent: "claude-code" | "codex" | "grok" | "unknown";
551
+ native_ref: {
552
+ format: string;
553
+ uuid: string;
554
+ };
555
+ project_path?: string | undefined;
556
+ git_branch?: string | undefined;
557
+ model?: string | undefined;
558
+ started_at?: string | undefined;
559
+ ended_at?: string | undefined;
560
+ turn_count?: number | undefined;
561
+ tool_call_count?: number | undefined;
562
+ totals?: {
563
+ input_tokens?: number | undefined;
564
+ output_tokens?: number | undefined;
565
+ cost_usd?: number | undefined;
566
+ } | undefined;
567
+ title?: string | undefined;
568
+ labels?: string[] | undefined;
569
+ }, {
570
+ schema: "session-store/session@1";
571
+ session_id: string;
572
+ host: string;
573
+ agent: "claude-code" | "codex" | "grok" | "unknown";
574
+ project_path: string;
575
+ turn_count: number;
576
+ tool_call_count: number;
577
+ totals: {
578
+ input_tokens: number;
579
+ output_tokens: number;
580
+ cost_usd: number;
581
+ };
582
+ labels: string[];
583
+ native_ref: {
584
+ format: string;
585
+ uuid: string;
586
+ };
587
+ git_branch?: string | undefined;
588
+ model?: string | undefined;
589
+ started_at?: string | undefined;
590
+ ended_at?: string | undefined;
591
+ title?: string | undefined;
592
+ }>;
593
+ declare const safeParseInsights: (data: unknown) => zod.SafeParseReturnType<{
594
+ schema: "session-store/insights@1";
595
+ session_id: string;
596
+ host: string;
597
+ generated_at: string;
598
+ provider: string;
599
+ topic?: string | undefined;
600
+ tags?: string[] | undefined;
601
+ signals?: {
602
+ kind: "stuck-loop" | "error-recovery" | "high-cost-turn" | "long-session" | "affect-negative" | "affect-positive" | "tool-heavy" | "other";
603
+ turn_index?: number | undefined;
604
+ severity?: "info" | "warn" | "critical" | undefined;
605
+ note?: string | undefined;
606
+ }[] | undefined;
607
+ summary?: string | undefined;
608
+ }, {
609
+ schema: "session-store/insights@1";
610
+ session_id: string;
611
+ host: string;
612
+ generated_at: string;
613
+ provider: string;
614
+ tags: string[];
615
+ signals: {
616
+ kind: "stuck-loop" | "error-recovery" | "high-cost-turn" | "long-session" | "affect-negative" | "affect-positive" | "tool-heavy" | "other";
617
+ severity: "info" | "warn" | "critical";
618
+ turn_index?: number | undefined;
619
+ note?: string | undefined;
620
+ }[];
621
+ topic?: string | undefined;
622
+ summary?: string | undefined;
623
+ }>;
624
+
625
+ export { AGENTS, type AgentKind, type BuildTurnContext, type ClaudeSessionMeta, type Insights, InsightsSchema, NativeRefSchema, type NormalizedEvent, ROLES, type Role, SCHEMA_VERSIONS, SIGNAL_KINDS, type SessionEnvelope, SessionSchema, type Signal, type SignalKind, SignalSchema, type Telemetry, TelemetrySchema, type ToolCall, ToolCallSchema, type Totals, TotalsSchema, type Turn, TurnSchema, type Usage, UsageSchema, buildTurn, extractClaudeSessionMeta, insightsJsonSchema, normalizeClaudeEvent, normalizeClaudeLines, parseInsights, parseSession, parseTurn, safeParseInsights, safeParseSession, safeParseTurn, sessionJsonSchema, turnJsonSchema };