@shipfox/api-logs-dto 2.0.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.
Files changed (51) hide show
  1. package/.turbo/turbo-build.log +2 -0
  2. package/.turbo/turbo-type$colon$emit.log +1 -0
  3. package/.turbo/turbo-type.log +1 -0
  4. package/CHANGELOG.md +42 -0
  5. package/LICENSE +21 -0
  6. package/dist/events.d.ts +23 -0
  7. package/dist/events.d.ts.map +1 -0
  8. package/dist/events.js +15 -0
  9. package/dist/events.js.map +1 -0
  10. package/dist/index.d.ts +3 -0
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +4 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/schemas/append.d.ts +29 -0
  15. package/dist/schemas/append.d.ts.map +1 -0
  16. package/dist/schemas/append.js +25 -0
  17. package/dist/schemas/append.js.map +1 -0
  18. package/dist/schemas/index.d.ts +5 -0
  19. package/dist/schemas/index.d.ts.map +1 -0
  20. package/dist/schemas/index.js +6 -0
  21. package/dist/schemas/index.js.map +1 -0
  22. package/dist/schemas/read.d.ts +34 -0
  23. package/dist/schemas/read.d.ts.map +1 -0
  24. package/dist/schemas/read.js +48 -0
  25. package/dist/schemas/read.js.map +1 -0
  26. package/dist/schemas/record.d.ts +178 -0
  27. package/dist/schemas/record.d.ts.map +1 -0
  28. package/dist/schemas/record.js +136 -0
  29. package/dist/schemas/record.js.map +1 -0
  30. package/dist/schemas/session-view.d.ts +178 -0
  31. package/dist/schemas/session-view.d.ts.map +1 -0
  32. package/dist/schemas/session-view.js +73 -0
  33. package/dist/schemas/session-view.js.map +1 -0
  34. package/dist/tsconfig.test.tsbuildinfo +1 -0
  35. package/package.json +55 -0
  36. package/src/events.ts +22 -0
  37. package/src/index.ts +46 -0
  38. package/src/schemas/append.test.ts +50 -0
  39. package/src/schemas/append.ts +55 -0
  40. package/src/schemas/index.ts +45 -0
  41. package/src/schemas/read.test.ts +69 -0
  42. package/src/schemas/read.ts +84 -0
  43. package/src/schemas/record.test.ts +275 -0
  44. package/src/schemas/record.ts +151 -0
  45. package/src/schemas/session-view.test.ts +96 -0
  46. package/src/schemas/session-view.ts +89 -0
  47. package/tsconfig.build.json +9 -0
  48. package/tsconfig.build.tsbuildinfo +1 -0
  49. package/tsconfig.json +3 -0
  50. package/tsconfig.test.json +8 -0
  51. package/vitest.config.ts +3 -0
@@ -0,0 +1,136 @@
1
+ import { z } from 'zod';
2
+ import { sessionViewRowSchema } from './session-view.js';
3
+ /**
4
+ * NDJSON log record contract — one JSON object per line, runner-framed.
5
+ *
6
+ * `offset` / `committed_length` are byte positions in the raw append NDJSON spool stream
7
+ * (envelope included) — the offset-CAS axis the runner tracks. The per-job accrual
8
+ * budget charges the normalized NDJSON bytes the server stores, so framing and control records
9
+ * count against it too. The per-record byte caps below bound each record so a single
10
+ * entry's overhead is known and a runner cannot grow storage without moving the
11
+ * budget: `data` is non-empty and <= MAX_RECORD_DATA_BYTES, the group `name` is
12
+ * <= MAX_RECORD_NAME_BYTES, the group ids are <= MAX_RECORD_GROUP_ID_BYTES, and every
13
+ * other field is fixed-shape.
14
+ *
15
+ * The envelope is `{v, ts}`, and every record is discriminated by a single flat
16
+ * `type`. The raw/write and stored/read unions are distinct types: the server-only
17
+ * `capped` / `runner_lost` tombstones are members of the read union only, so a forged
18
+ * tombstone cannot pass append validation.
19
+ *
20
+ * The append-side `agent_session` record carries one verbatim agent session entry line
21
+ * in `data`, forwarded opaquely by the runner. On successful ingest, the API normalizes
22
+ * that raw entry into one or more read-side `agent_session` records whose `row` is the
23
+ * canonical session view row. The raw and normalized records travel through the same log
24
+ * append/read pipe; only their contract at each boundary differs.
25
+ */ /** Largest decoded `data` payload per record. Longer lines are split by the runner. */ export const MAX_RECORD_DATA_BYTES = 16 * 1024;
26
+ /** Largest `group_start` name. Bounds the only variable-length control field. */ export const MAX_RECORD_NAME_BYTES = 1024;
27
+ /**
28
+ * Largest `group_id` / `parent_group_id`. The runner emits short monotonic ids (`g1`,
29
+ * `g2`, …); this only bounds a forged id from a lease-scoped writer so the ids stay a
30
+ * fixed-shape field like every other record field.
31
+ */ export const MAX_RECORD_GROUP_ID_BYTES = 256;
32
+ // UTF-8 byte length without node:buffer, so this shared DTO stays browser-safe (the
33
+ // client log viewer imports these types too). Identical to Buffer.byteLength(x, 'utf8').
34
+ const utf8Encoder = new TextEncoder();
35
+ const utf8ByteLength = (value)=>utf8Encoder.encode(value).length;
36
+ const groupId = z.string().min(1, {
37
+ message: 'group id must not be empty'
38
+ }).refine((value)=>utf8ByteLength(value) <= MAX_RECORD_GROUP_ID_BYTES, {
39
+ message: `group id exceeds ${MAX_RECORD_GROUP_ID_BYTES} bytes`
40
+ });
41
+ const envelope = {
42
+ v: z.literal(1),
43
+ /** Epoch milliseconds, assigned by the runner at capture. */ ts: z.number().int().nonnegative()
44
+ };
45
+ const logOutput = z.object({
46
+ ...envelope,
47
+ type: z.literal('output'),
48
+ stream: z.enum([
49
+ 'stdout',
50
+ 'stderr'
51
+ ]),
52
+ data: z.string().min(1, {
53
+ message: 'output data must not be empty'
54
+ }).refine((value)=>utf8ByteLength(value) <= MAX_RECORD_DATA_BYTES, {
55
+ message: `data exceeds ${MAX_RECORD_DATA_BYTES} payload bytes`
56
+ })
57
+ });
58
+ const logGroupStart = z.object({
59
+ ...envelope,
60
+ type: z.literal('group_start'),
61
+ group_id: groupId,
62
+ parent_group_id: groupId.nullable(),
63
+ name: z.string().refine((value)=>utf8ByteLength(value) <= MAX_RECORD_NAME_BYTES, {
64
+ message: `group name exceeds ${MAX_RECORD_NAME_BYTES} bytes`
65
+ })
66
+ });
67
+ const logGroupEnd = z.object({
68
+ ...envelope,
69
+ type: z.literal('group_end'),
70
+ group_id: groupId
71
+ });
72
+ const logEnd = z.object({
73
+ ...envelope,
74
+ type: z.literal('end'),
75
+ total_bytes: z.number().int().nonnegative()
76
+ });
77
+ const logGap = z.object({
78
+ ...envelope,
79
+ type: z.literal('gap'),
80
+ dropped_bytes: z.number().int().nonnegative()
81
+ });
82
+ // One verbatim agent session entry line, forwarded opaquely by the runner. `data` is
83
+ // intentionally uncapped here: the per-line byte limit is the server's configurable
84
+ // LOG_MAX_SESSION_LINE_BYTES (a Zod schema cannot read runtime config, and a static cap
85
+ // would collide with the body-limit invariant), enforced in the append write path.
86
+ const rawAgentSession = z.object({
87
+ ...envelope,
88
+ type: z.literal('agent_session'),
89
+ data: z.string().min(1, {
90
+ message: 'agent_session data must not be empty'
91
+ })
92
+ });
93
+ const agentSession = z.object({
94
+ ...envelope,
95
+ type: z.literal('agent_session'),
96
+ row: sessionViewRowSchema
97
+ });
98
+ // Server-only tombstones: NOT members of the raw write union.
99
+ const logCapped = z.object({
100
+ ...envelope,
101
+ type: z.literal('capped')
102
+ });
103
+ const logRunnerLost = z.object({
104
+ ...envelope,
105
+ type: z.literal('runner_lost')
106
+ });
107
+ /** Records a lease-scoped runner may append. The write path validates against this. */ export const rawLogRecordSchema = z.discriminatedUnion('type', [
108
+ logOutput,
109
+ logGroupStart,
110
+ logGroupEnd,
111
+ logEnd,
112
+ logGap,
113
+ rawAgentSession
114
+ ]);
115
+ /** Stored/read records: regular records, normalized agent sessions, and tombstones. */ export const logRecordSchema = z.discriminatedUnion('type', [
116
+ logOutput,
117
+ logGroupStart,
118
+ logGroupEnd,
119
+ logEnd,
120
+ logGap,
121
+ agentSession,
122
+ logCapped,
123
+ logRunnerLost
124
+ ]);
125
+ export function parseLogRecordLine(line) {
126
+ return logRecordSchema.parse(JSON.parse(line));
127
+ }
128
+ /**
129
+ * Parses one NDJSON line against the raw write union. A forged
130
+ * server-only `capped` / `runner_lost` record fails here even though it is valid
131
+ * under the read union — this is the write-path forgery guard.
132
+ */ export function parseRawLogRecordLine(line) {
133
+ return rawLogRecordSchema.parse(JSON.parse(line));
134
+ }
135
+
136
+ //# sourceMappingURL=record.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/schemas/record.ts"],"sourcesContent":["import {z} from 'zod';\nimport {sessionViewRowSchema} from './session-view.js';\n\n/**\n * NDJSON log record contract — one JSON object per line, runner-framed.\n *\n * `offset` / `committed_length` are byte positions in the raw append NDJSON spool stream\n * (envelope included) — the offset-CAS axis the runner tracks. The per-job accrual\n * budget charges the normalized NDJSON bytes the server stores, so framing and control records\n * count against it too. The per-record byte caps below bound each record so a single\n * entry's overhead is known and a runner cannot grow storage without moving the\n * budget: `data` is non-empty and <= MAX_RECORD_DATA_BYTES, the group `name` is\n * <= MAX_RECORD_NAME_BYTES, the group ids are <= MAX_RECORD_GROUP_ID_BYTES, and every\n * other field is fixed-shape.\n *\n * The envelope is `{v, ts}`, and every record is discriminated by a single flat\n * `type`. The raw/write and stored/read unions are distinct types: the server-only\n * `capped` / `runner_lost` tombstones are members of the read union only, so a forged\n * tombstone cannot pass append validation.\n *\n * The append-side `agent_session` record carries one verbatim agent session entry line\n * in `data`, forwarded opaquely by the runner. On successful ingest, the API normalizes\n * that raw entry into one or more read-side `agent_session` records whose `row` is the\n * canonical session view row. The raw and normalized records travel through the same log\n * append/read pipe; only their contract at each boundary differs.\n */\n\n/** Largest decoded `data` payload per record. Longer lines are split by the runner. */\nexport const MAX_RECORD_DATA_BYTES = 16 * 1024;\n\n/** Largest `group_start` name. Bounds the only variable-length control field. */\nexport const MAX_RECORD_NAME_BYTES = 1024;\n\n/**\n * Largest `group_id` / `parent_group_id`. The runner emits short monotonic ids (`g1`,\n * `g2`, …); this only bounds a forged id from a lease-scoped writer so the ids stay a\n * fixed-shape field like every other record field.\n */\nexport const MAX_RECORD_GROUP_ID_BYTES = 256;\n\n// UTF-8 byte length without node:buffer, so this shared DTO stays browser-safe (the\n// client log viewer imports these types too). Identical to Buffer.byteLength(x, 'utf8').\nconst utf8Encoder = new TextEncoder();\nconst utf8ByteLength = (value: string): number => utf8Encoder.encode(value).length;\n\nconst groupId = z\n .string()\n .min(1, {message: 'group id must not be empty'})\n .refine((value) => utf8ByteLength(value) <= MAX_RECORD_GROUP_ID_BYTES, {\n message: `group id exceeds ${MAX_RECORD_GROUP_ID_BYTES} bytes`,\n });\n\nconst envelope = {\n v: z.literal(1),\n /** Epoch milliseconds, assigned by the runner at capture. */\n ts: z.number().int().nonnegative(),\n};\n\nconst logOutput = z.object({\n ...envelope,\n type: z.literal('output'),\n stream: z.enum(['stdout', 'stderr']),\n data: z\n .string()\n .min(1, {message: 'output data must not be empty'})\n .refine((value) => utf8ByteLength(value) <= MAX_RECORD_DATA_BYTES, {\n message: `data exceeds ${MAX_RECORD_DATA_BYTES} payload bytes`,\n }),\n});\n\nconst logGroupStart = z.object({\n ...envelope,\n type: z.literal('group_start'),\n group_id: groupId,\n parent_group_id: groupId.nullable(),\n name: z.string().refine((value) => utf8ByteLength(value) <= MAX_RECORD_NAME_BYTES, {\n message: `group name exceeds ${MAX_RECORD_NAME_BYTES} bytes`,\n }),\n});\n\nconst logGroupEnd = z.object({...envelope, type: z.literal('group_end'), group_id: groupId});\n\nconst logEnd = z.object({\n ...envelope,\n type: z.literal('end'),\n total_bytes: z.number().int().nonnegative(),\n});\n\nconst logGap = z.object({\n ...envelope,\n type: z.literal('gap'),\n dropped_bytes: z.number().int().nonnegative(),\n});\n\n// One verbatim agent session entry line, forwarded opaquely by the runner. `data` is\n// intentionally uncapped here: the per-line byte limit is the server's configurable\n// LOG_MAX_SESSION_LINE_BYTES (a Zod schema cannot read runtime config, and a static cap\n// would collide with the body-limit invariant), enforced in the append write path.\nconst rawAgentSession = z.object({\n ...envelope,\n type: z.literal('agent_session'),\n data: z.string().min(1, {message: 'agent_session data must not be empty'}),\n});\n\nconst agentSession = z.object({\n ...envelope,\n type: z.literal('agent_session'),\n row: sessionViewRowSchema,\n});\n\n// Server-only tombstones: NOT members of the raw write union.\nconst logCapped = z.object({...envelope, type: z.literal('capped')});\nconst logRunnerLost = z.object({...envelope, type: z.literal('runner_lost')});\n\n/** Records a lease-scoped runner may append. The write path validates against this. */\nexport const rawLogRecordSchema = z.discriminatedUnion('type', [\n logOutput,\n logGroupStart,\n logGroupEnd,\n logEnd,\n logGap,\n rawAgentSession,\n]);\n\n/** Stored/read records: regular records, normalized agent sessions, and tombstones. */\nexport const logRecordSchema = z.discriminatedUnion('type', [\n logOutput,\n logGroupStart,\n logGroupEnd,\n logEnd,\n logGap,\n agentSession,\n logCapped,\n logRunnerLost,\n]);\n\nexport type RawLogRecord = z.infer<typeof rawLogRecordSchema>;\nexport type LogRecord = z.infer<typeof logRecordSchema>;\n\nexport function parseLogRecordLine(line: string): LogRecord {\n return logRecordSchema.parse(JSON.parse(line));\n}\n\n/**\n * Parses one NDJSON line against the raw write union. A forged\n * server-only `capped` / `runner_lost` record fails here even though it is valid\n * under the read union — this is the write-path forgery guard.\n */\nexport function parseRawLogRecordLine(line: string): RawLogRecord {\n return rawLogRecordSchema.parse(JSON.parse(line));\n}\n"],"names":["z","sessionViewRowSchema","MAX_RECORD_DATA_BYTES","MAX_RECORD_NAME_BYTES","MAX_RECORD_GROUP_ID_BYTES","utf8Encoder","TextEncoder","utf8ByteLength","value","encode","length","groupId","string","min","message","refine","envelope","v","literal","ts","number","int","nonnegative","logOutput","object","type","stream","enum","data","logGroupStart","group_id","parent_group_id","nullable","name","logGroupEnd","logEnd","total_bytes","logGap","dropped_bytes","rawAgentSession","agentSession","row","logCapped","logRunnerLost","rawLogRecordSchema","discriminatedUnion","logRecordSchema","parseLogRecordLine","line","parse","JSON","parseRawLogRecordLine"],"mappings":"AAAA,SAAQA,CAAC,QAAO,MAAM;AACtB,SAAQC,oBAAoB,QAAO,oBAAoB;AAEvD;;;;;;;;;;;;;;;;;;;;;;CAsBC,GAED,qFAAqF,GACrF,OAAO,MAAMC,wBAAwB,KAAK,KAAK;AAE/C,+EAA+E,GAC/E,OAAO,MAAMC,wBAAwB,KAAK;AAE1C;;;;CAIC,GACD,OAAO,MAAMC,4BAA4B,IAAI;AAE7C,oFAAoF;AACpF,yFAAyF;AACzF,MAAMC,cAAc,IAAIC;AACxB,MAAMC,iBAAiB,CAACC,QAA0BH,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AmBK,KAAK,CAACC,KAAKD,KAAK,CAACD;AAC7C"}
@@ -0,0 +1,178 @@
1
+ import { z } from 'zod';
2
+ export declare const SESSION_VIEW_VERSION = 1;
3
+ export declare const sessionViewRowMetaSchema: z.ZodObject<{
4
+ label: z.ZodString;
5
+ value: z.ZodString;
6
+ inline: z.ZodOptional<z.ZodBoolean>;
7
+ }, z.core.$strip>;
8
+ export declare const sessionViewMessageRowSchema: z.ZodObject<{
9
+ kind: z.ZodLiteral<"message">;
10
+ role: z.ZodString;
11
+ label: z.ZodString;
12
+ meta: z.ZodReadonly<z.ZodArray<z.ZodObject<{
13
+ label: z.ZodString;
14
+ value: z.ZodString;
15
+ inline: z.ZodOptional<z.ZodBoolean>;
16
+ }, z.core.$strip>>>;
17
+ text: z.ZodString;
18
+ terminalFailure: z.ZodBoolean;
19
+ timestamp: z.ZodNumber;
20
+ }, z.core.$strip>;
21
+ export declare const sessionViewThinkingRowSchema: z.ZodObject<{
22
+ kind: z.ZodLiteral<"thinking">;
23
+ text: z.ZodString;
24
+ timestamp: z.ZodNumber;
25
+ }, z.core.$strip>;
26
+ export declare const sessionViewToolCallRowSchema: z.ZodObject<{
27
+ kind: z.ZodLiteral<"tool-call">;
28
+ id: z.ZodNullable<z.ZodString>;
29
+ name: z.ZodString;
30
+ input: z.ZodString;
31
+ timestamp: z.ZodNumber;
32
+ }, z.core.$strip>;
33
+ export declare const sessionViewToolResultRowSchema: z.ZodObject<{
34
+ kind: z.ZodLiteral<"tool-result">;
35
+ toolCallId: z.ZodNullable<z.ZodString>;
36
+ toolName: z.ZodString;
37
+ output: z.ZodString;
38
+ isError: z.ZodBoolean;
39
+ timestamp: z.ZodNumber;
40
+ }, z.core.$strip>;
41
+ export declare const sessionViewLifecycleRowSchema: z.ZodObject<{
42
+ kind: z.ZodLiteral<"lifecycle">;
43
+ label: z.ZodString;
44
+ detail: z.ZodNullable<z.ZodString>;
45
+ meta: z.ZodReadonly<z.ZodArray<z.ZodObject<{
46
+ label: z.ZodString;
47
+ value: z.ZodString;
48
+ inline: z.ZodOptional<z.ZodBoolean>;
49
+ }, z.core.$strip>>>;
50
+ tone: z.ZodEnum<{
51
+ error: "error";
52
+ default: "default";
53
+ warning: "warning";
54
+ }>;
55
+ terminalFailure: z.ZodBoolean;
56
+ timestamp: z.ZodNumber;
57
+ }, z.core.$strip>;
58
+ export declare const sessionViewRawRowSchema: z.ZodObject<{
59
+ kind: z.ZodLiteral<"raw">;
60
+ label: z.ZodString;
61
+ raw: z.ZodString;
62
+ timestamp: z.ZodNumber;
63
+ }, z.core.$strip>;
64
+ export declare const sessionViewRowSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
65
+ kind: z.ZodLiteral<"message">;
66
+ role: z.ZodString;
67
+ label: z.ZodString;
68
+ meta: z.ZodReadonly<z.ZodArray<z.ZodObject<{
69
+ label: z.ZodString;
70
+ value: z.ZodString;
71
+ inline: z.ZodOptional<z.ZodBoolean>;
72
+ }, z.core.$strip>>>;
73
+ text: z.ZodString;
74
+ terminalFailure: z.ZodBoolean;
75
+ timestamp: z.ZodNumber;
76
+ }, z.core.$strip>, z.ZodObject<{
77
+ kind: z.ZodLiteral<"thinking">;
78
+ text: z.ZodString;
79
+ timestamp: z.ZodNumber;
80
+ }, z.core.$strip>, z.ZodObject<{
81
+ kind: z.ZodLiteral<"tool-call">;
82
+ id: z.ZodNullable<z.ZodString>;
83
+ name: z.ZodString;
84
+ input: z.ZodString;
85
+ timestamp: z.ZodNumber;
86
+ }, z.core.$strip>, z.ZodObject<{
87
+ kind: z.ZodLiteral<"tool-result">;
88
+ toolCallId: z.ZodNullable<z.ZodString>;
89
+ toolName: z.ZodString;
90
+ output: z.ZodString;
91
+ isError: z.ZodBoolean;
92
+ timestamp: z.ZodNumber;
93
+ }, z.core.$strip>, z.ZodObject<{
94
+ kind: z.ZodLiteral<"lifecycle">;
95
+ label: z.ZodString;
96
+ detail: z.ZodNullable<z.ZodString>;
97
+ meta: z.ZodReadonly<z.ZodArray<z.ZodObject<{
98
+ label: z.ZodString;
99
+ value: z.ZodString;
100
+ inline: z.ZodOptional<z.ZodBoolean>;
101
+ }, z.core.$strip>>>;
102
+ tone: z.ZodEnum<{
103
+ error: "error";
104
+ default: "default";
105
+ warning: "warning";
106
+ }>;
107
+ terminalFailure: z.ZodBoolean;
108
+ timestamp: z.ZodNumber;
109
+ }, z.core.$strip>, z.ZodObject<{
110
+ kind: z.ZodLiteral<"raw">;
111
+ label: z.ZodString;
112
+ raw: z.ZodString;
113
+ timestamp: z.ZodNumber;
114
+ }, z.core.$strip>], "kind">;
115
+ export declare const sessionViewSchema: z.ZodObject<{
116
+ v: z.ZodLiteral<1>;
117
+ rows: z.ZodReadonly<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
118
+ kind: z.ZodLiteral<"message">;
119
+ role: z.ZodString;
120
+ label: z.ZodString;
121
+ meta: z.ZodReadonly<z.ZodArray<z.ZodObject<{
122
+ label: z.ZodString;
123
+ value: z.ZodString;
124
+ inline: z.ZodOptional<z.ZodBoolean>;
125
+ }, z.core.$strip>>>;
126
+ text: z.ZodString;
127
+ terminalFailure: z.ZodBoolean;
128
+ timestamp: z.ZodNumber;
129
+ }, z.core.$strip>, z.ZodObject<{
130
+ kind: z.ZodLiteral<"thinking">;
131
+ text: z.ZodString;
132
+ timestamp: z.ZodNumber;
133
+ }, z.core.$strip>, z.ZodObject<{
134
+ kind: z.ZodLiteral<"tool-call">;
135
+ id: z.ZodNullable<z.ZodString>;
136
+ name: z.ZodString;
137
+ input: z.ZodString;
138
+ timestamp: z.ZodNumber;
139
+ }, z.core.$strip>, z.ZodObject<{
140
+ kind: z.ZodLiteral<"tool-result">;
141
+ toolCallId: z.ZodNullable<z.ZodString>;
142
+ toolName: z.ZodString;
143
+ output: z.ZodString;
144
+ isError: z.ZodBoolean;
145
+ timestamp: z.ZodNumber;
146
+ }, z.core.$strip>, z.ZodObject<{
147
+ kind: z.ZodLiteral<"lifecycle">;
148
+ label: z.ZodString;
149
+ detail: z.ZodNullable<z.ZodString>;
150
+ meta: z.ZodReadonly<z.ZodArray<z.ZodObject<{
151
+ label: z.ZodString;
152
+ value: z.ZodString;
153
+ inline: z.ZodOptional<z.ZodBoolean>;
154
+ }, z.core.$strip>>>;
155
+ tone: z.ZodEnum<{
156
+ error: "error";
157
+ default: "default";
158
+ warning: "warning";
159
+ }>;
160
+ terminalFailure: z.ZodBoolean;
161
+ timestamp: z.ZodNumber;
162
+ }, z.core.$strip>, z.ZodObject<{
163
+ kind: z.ZodLiteral<"raw">;
164
+ label: z.ZodString;
165
+ raw: z.ZodString;
166
+ timestamp: z.ZodNumber;
167
+ }, z.core.$strip>], "kind">>>;
168
+ }, z.core.$strip>;
169
+ export type SessionViewRowMeta = z.infer<typeof sessionViewRowMetaSchema>;
170
+ export type SessionViewMessageRow = z.infer<typeof sessionViewMessageRowSchema>;
171
+ export type SessionViewThinkingRow = z.infer<typeof sessionViewThinkingRowSchema>;
172
+ export type SessionViewToolCallRow = z.infer<typeof sessionViewToolCallRowSchema>;
173
+ export type SessionViewToolResultRow = z.infer<typeof sessionViewToolResultRowSchema>;
174
+ export type SessionViewLifecycleRow = z.infer<typeof sessionViewLifecycleRowSchema>;
175
+ export type SessionViewRawRow = z.infer<typeof sessionViewRawRowSchema>;
176
+ export type SessionViewRow = z.infer<typeof sessionViewRowSchema>;
177
+ export type SessionViewDto = z.infer<typeof sessionViewSchema>;
178
+ //# sourceMappingURL=session-view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-view.d.ts","sourceRoot":"","sources":["../../src/schemas/session-view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,eAAO,MAAM,oBAAoB,IAAI,CAAC;AAItC,eAAO,MAAM,wBAAwB;;;;iBAInC,CAAC;AAMH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;iBAQtC,CAAC;AAEH,eAAO,MAAM,4BAA4B;;;;iBAIvC,CAA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= z.number().int().nonnegative();
4
+ export const sessionViewRowMetaSchema = z.object({
5
+ label: z.string().min(1),
6
+ value: z.string(),
7
+ inline: z.boolean().optional()
8
+ });
9
+ const sessionViewRowBase = {
10
+ timestamp: timestampSchema
11
+ };
12
+ export const sessionViewMessageRowSchema = z.object({
13
+ ...sessionViewRowBase,
14
+ kind: z.literal('message'),
15
+ role: z.string().min(1),
16
+ label: z.string().min(1),
17
+ meta: z.array(sessionViewRowMetaSchema).readonly(),
18
+ text: z.string(),
19
+ terminalFailure: z.boolean()
20
+ });
21
+ export const sessionViewThinkingRowSchema = z.object({
22
+ ...sessionViewRowBase,
23
+ kind: z.literal('thinking'),
24
+ text: z.string()
25
+ });
26
+ export const sessionViewToolCallRowSchema = z.object({
27
+ ...sessionViewRowBase,
28
+ kind: z.literal('tool-call'),
29
+ id: z.string().nullable(),
30
+ name: z.string().min(1),
31
+ input: z.string()
32
+ });
33
+ export const sessionViewToolResultRowSchema = z.object({
34
+ ...sessionViewRowBase,
35
+ kind: z.literal('tool-result'),
36
+ toolCallId: z.string().nullable(),
37
+ toolName: z.string().min(1),
38
+ output: z.string(),
39
+ isError: z.boolean()
40
+ });
41
+ export const sessionViewLifecycleRowSchema = z.object({
42
+ ...sessionViewRowBase,
43
+ kind: z.literal('lifecycle'),
44
+ label: z.string().min(1),
45
+ detail: z.string().nullable(),
46
+ meta: z.array(sessionViewRowMetaSchema).readonly(),
47
+ tone: z.enum([
48
+ 'default',
49
+ 'warning',
50
+ 'error'
51
+ ]),
52
+ terminalFailure: z.boolean()
53
+ });
54
+ export const sessionViewRawRowSchema = z.object({
55
+ ...sessionViewRowBase,
56
+ kind: z.literal('raw'),
57
+ label: z.string().min(1),
58
+ raw: z.string()
59
+ });
60
+ export const sessionViewRowSchema = z.discriminatedUnion('kind', [
61
+ sessionViewMessageRowSchema,
62
+ sessionViewThinkingRowSchema,
63
+ sessionViewToolCallRowSchema,
64
+ sessionViewToolResultRowSchema,
65
+ sessionViewLifecycleRowSchema,
66
+ sessionViewRawRowSchema
67
+ ]);
68
+ export const sessionViewSchema = z.object({
69
+ v: z.literal(SESSION_VIEW_VERSION),
70
+ rows: z.array(sessionViewRowSchema).readonly()
71
+ });
72
+
73
+ //# sourceMappingURL=session-view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/schemas/session-view.ts"],"sourcesContent":["import {z} from 'zod';\n\nexport const SESSION_VIEW_VERSION = 1;\n\nconst timestampSchema = z.number().int().nonnegative();\n\nexport const sessionViewRowMetaSchema = z.object({\n label: z.string().min(1),\n value: z.string(),\n inline: z.boolean().optional(),\n});\n\nconst sessionViewRowBase = {\n timestamp: timestampSchema,\n};\n\nexport const sessionViewMessageRowSchema = z.object({\n ...sessionViewRowBase,\n kind: z.literal('message'),\n role: z.string().min(1),\n label: z.string().min(1),\n meta: z.array(sessionViewRowMetaSchema).readonly(),\n text: z.string(),\n terminalFailure: z.boolean(),\n});\n\nexport const sessionViewThinkingRowSchema = z.object({\n ...sessionViewRowBase,\n kind: z.literal('thinking'),\n text: z.string(),\n});\n\nexport const sessionViewToolCallRowSchema = z.object({\n ...sessionViewRowBase,\n kind: z.literal('tool-call'),\n id: z.string().nullable(),\n name: z.string().min(1),\n input: z.string(),\n});\n\nexport const sessionViewToolResultRowSchema = z.object({\n ...sessionViewRowBase,\n kind: z.literal('tool-result'),\n toolCallId: z.string().nullable(),\n toolName: z.string().min(1),\n output: z.string(),\n isError: z.boolean(),\n});\n\nexport const sessionViewLifecycleRowSchema = z.object({\n ...sessionViewRowBase,\n kind: z.literal('lifecycle'),\n label: z.string().min(1),\n detail: z.string().nullable(),\n meta: z.array(sessionViewRowMetaSchema).readonly(),\n tone: z.enum(['default', 'warning', 'error']),\n terminalFailure: z.boolean(),\n});\n\nexport const sessionViewRawRowSchema = z.object({\n ...sessionViewRowBase,\n kind: z.literal('raw'),\n label: z.string().min(1),\n raw: z.string(),\n});\n\nexport const sessionViewRowSchema = z.discriminatedUnion('kind', [\n sessionViewMessageRowSchema,\n sessionViewThinkingRowSchema,\n sessionViewToolCallRowSchema,\n sessionViewToolResultRowSchema,\n sessionViewLifecycleRowSchema,\n sessionViewRawRowSchema,\n]);\n\nexport const sessionViewSchema = z.object({\n v: z.literal(SESSION_VIEW_VERSION),\n rows: z.array(sessionViewRowSchema).readonly(),\n});\n\nexport type SessionViewRowMeta = z.infer<typeof sessionViewRowMetaSchema>;\nexport type SessionViewMessageRow = z.infer<typeof sessionViewMessageRowSchema>;\nexport type SessionViewThinkingRow = z.infer<typeof sessionViewThinkingRowSchema>;\nexport type SessionViewToolCallRow = z.infer<typeof sessionViewToolCallRowSchema>;\nexport type SessionViewToolResultRow = z.infer<typeof sessionViewToolResultRowSchema>;\nexport type SessionViewLifecycleRow = z.infer<typeof sessionViewLifecycleRowSchema>;\nexport type SessionViewRawRow = z.infer<typeof sessionViewRawRowSchema>;\nexport type SessionViewRow = z.infer<typeof sessionViewRowSchema>;\nexport type SessionViewDto = z.infer<typeof sessionViewSchema>;\n"],"names":["z","SESSION_VIEW_VERSION","timestampSchema","number","int","nonnegative","sessionViewRowMetaSchema","object","label","string","min","value","inline","boolean","optional","sessionViewRowBase","timestamp","sessionViewMessageRowSchema","kind","literal","role","meta","array","readonly","text","terminalFailure","sessionViewThinkingRowSchema","sessionViewToolCallRowSchema","id","nullable","name","input","sessionViewToolResultRowSchema","toolCallId","toolName","output","isError","sessionViewLifecycleRowSchema","detail","tone","enum","sessionViewRawRowSchema","raw","sessionViewRowSchema","discriminatedUnion","sessionViewSchema","v","rows"],"mappings":"AAAA,SAAQA,CAAC,QAAO,MAAM;AAEtB,OAAO,MAAMC,uBAAuB,EAAE;AAEtC,MAAMC,kBAAkBF,EAAEG,MAAM,GAAGC,GAAG,GAAGC,WAAW;AAEpD,OAAO,MAAMC,2BAA2BN,EAAEO,MAAM,CAAC;IAC/CC,OAAOR,EAAES,MAAM,GAAGC,GAAG,CAAC;IACtBC,OAAOX,EAAES,MAAM;IACfG,QAAQZ,EAAEa,O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