@jmtrin/opencode-kevin 0.6.0 → 0.8.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 (83) hide show
  1. package/README.md +771 -580
  2. package/dist/migrations/001_initial.sql +91 -91
  3. package/dist/migrations/003_v02_signal.sql +57 -57
  4. package/dist/migrations/004_v03_knowledge.sql +138 -138
  5. package/dist/migrations/005_v04_signal.sql +57 -57
  6. package/dist/migrations/006_v05_glassbox.sql +118 -118
  7. package/dist/migrations/007_v06_pull.sql +144 -144
  8. package/dist/migrations/008_v07_truth.sql +124 -0
  9. package/dist/migrations/009_v08_team.sql +100 -0
  10. package/dist/plugin/ArtifactWriter.d.ts +28 -0
  11. package/dist/plugin/ArtifactWriter.js +35 -2
  12. package/dist/plugin/ArtifactWriter.js.map +1 -1
  13. package/dist/plugin/ConflictDetector.d.ts +35 -0
  14. package/dist/plugin/ConflictDetector.js +283 -0
  15. package/dist/plugin/ConflictDetector.js.map +1 -0
  16. package/dist/plugin/ContextInjector.d.ts +9 -0
  17. package/dist/plugin/ContextInjector.js +14 -3
  18. package/dist/plugin/ContextInjector.js.map +1 -1
  19. package/dist/plugin/ConventionMiner.d.ts +35 -0
  20. package/dist/plugin/ConventionMiner.js +243 -0
  21. package/dist/plugin/ConventionMiner.js.map +1 -0
  22. package/dist/plugin/Curator.d.ts +22 -2
  23. package/dist/plugin/Curator.js +101 -28
  24. package/dist/plugin/Curator.js.map +1 -1
  25. package/dist/plugin/InjectionLedger.d.ts +6 -0
  26. package/dist/plugin/InjectionLedger.js +6 -0
  27. package/dist/plugin/InjectionLedger.js.map +1 -1
  28. package/dist/plugin/Materializer.d.ts +4 -5
  29. package/dist/plugin/Materializer.js +9 -6
  30. package/dist/plugin/Materializer.js.map +1 -1
  31. package/dist/plugin/MemoryService.d.ts +49 -2
  32. package/dist/plugin/MemoryService.js +306 -8
  33. package/dist/plugin/MemoryService.js.map +1 -1
  34. package/dist/plugin/Migrate.js +61 -2
  35. package/dist/plugin/Migrate.js.map +1 -1
  36. package/dist/plugin/Reflector.js +13 -0
  37. package/dist/plugin/Reflector.js.map +1 -1
  38. package/dist/plugin/RepoIdentity.d.ts +113 -0
  39. package/dist/plugin/RepoIdentity.js +266 -0
  40. package/dist/plugin/RepoIdentity.js.map +1 -0
  41. package/dist/plugin/RepoTruth.d.ts +80 -0
  42. package/dist/plugin/RepoTruth.js +600 -0
  43. package/dist/plugin/RepoTruth.js.map +1 -0
  44. package/dist/plugin/Retrospective.js +17 -0
  45. package/dist/plugin/Retrospective.js.map +1 -1
  46. package/dist/plugin/SharedLayer.d.ts +159 -0
  47. package/dist/plugin/SharedLayer.js +463 -0
  48. package/dist/plugin/SharedLayer.js.map +1 -0
  49. package/dist/plugin/index.d.ts +36 -2
  50. package/dist/plugin/index.js +591 -10
  51. package/dist/plugin/index.js.map +1 -1
  52. package/dist/plugin/kevin_approve.js +7 -4
  53. package/dist/plugin/kevin_approve.js.map +1 -1
  54. package/dist/plugin/kevin_audit.d.ts +59 -1
  55. package/dist/plugin/kevin_audit.js +190 -3
  56. package/dist/plugin/kevin_audit.js.map +1 -1
  57. package/dist/plugin/kevin_conflicts.d.ts +9 -0
  58. package/dist/plugin/kevin_conflicts.js +51 -0
  59. package/dist/plugin/kevin_conflicts.js.map +1 -0
  60. package/dist/plugin/kevin_facts.d.ts +42 -0
  61. package/dist/plugin/kevin_facts.js +37 -0
  62. package/dist/plugin/kevin_facts.js.map +1 -0
  63. package/dist/plugin/metrics.d.ts +3 -3
  64. package/dist/plugin/metrics.js +21 -2
  65. package/dist/plugin/metrics.js.map +1 -1
  66. package/dist/plugin/okf-export.d.ts +2 -2
  67. package/dist/plugin/okf-export.js +15 -7
  68. package/dist/plugin/okf-export.js.map +1 -1
  69. package/dist/plugin/okf.d.ts +107 -0
  70. package/dist/plugin/okf.js +304 -0
  71. package/dist/plugin/okf.js.map +1 -0
  72. package/dist/plugin/replay-types.d.ts +29 -287
  73. package/dist/plugin/replay-types.js +145 -53
  74. package/dist/plugin/replay-types.js.map +1 -1
  75. package/migrations/001_initial.sql +91 -91
  76. package/migrations/003_v02_signal.sql +57 -57
  77. package/migrations/004_v03_knowledge.sql +138 -138
  78. package/migrations/005_v04_signal.sql +57 -57
  79. package/migrations/006_v05_glassbox.sql +118 -118
  80. package/migrations/007_v06_pull.sql +144 -144
  81. package/migrations/008_v07_truth.sql +124 -0
  82. package/migrations/009_v08_team.sql +100 -0
  83. package/package.json +4 -4
@@ -0,0 +1,304 @@
1
+ // ============================================================
2
+ // Kevin 0.8.0 — OKF v2 codec (F2, K8-010 … K8-015)
3
+ // ============================================================
4
+ // The Open Kevin Format: the committed, shareable artifact of the
5
+ // shared layer (plan §3.3). Everything in this module is a pure
6
+ // function — no database, no filesystem, no clock. The format is
7
+ // the release: if `join()` is not a semilattice then silent git
8
+ // merges, order-independent imports and correct both-sides
9
+ // conflict resolution all evaporate.
10
+ //
11
+ // Entry ids are deliberately the THIRD fingerprint identity
12
+ // dimension in the codebase (v0.7.0's Principle 26; plan §3.3's
13
+ // table). The first is `fingerprint()` (error text, salted with
14
+ // `project_id`, normalized) and the second is the convention /
15
+ // decision fingerprints of v0.7.0 (derived from the normalized
16
+ // statement). This one is unsalted and un-normalized, and it is
17
+ // the ONLY cross-machine-stable dimension in the schema.
18
+ // ============================================================
19
+ import { computeConfidence } from "./confidence.js";
20
+ import { fnv1a64 } from "./fingerprint.js";
21
+ /** OKF v2 format version marker, written on the first header line. */
22
+ export const OKF_VERSION = 2;
23
+ /** A single canonicalized entry line may not exceed this many bytes. */
24
+ export const MAX_LINE_BYTES = 4096;
25
+ /** A serialized corpus may not exceed this many entries. */
26
+ export const MAX_ENTRIES = 2000;
27
+ const OKF_KEY_ORDER = [
28
+ "author_hash",
29
+ "created_at",
30
+ "entry_id",
31
+ "evidence",
32
+ "op",
33
+ "origin",
34
+ "recurrence",
35
+ "scope",
36
+ "statement",
37
+ "supersedes",
38
+ "type",
39
+ ];
40
+ /**
41
+ * Canonical JSON of an entry: keys in alphabetical order, no space
42
+ * argument, integers only (no float is ever written — plan §5.3).
43
+ * The object is constructed explicitly so the source object's
44
+ * insertion order can never leak into the bytes.
45
+ */
46
+ export function canonicalize(e) {
47
+ const ordered = {};
48
+ for (const key of OKF_KEY_ORDER) {
49
+ ordered[key] = e[key];
50
+ }
51
+ return JSON.stringify(ordered);
52
+ }
53
+ /**
54
+ * Emit the v2 file: three `#` header lines, then every entry sorted
55
+ * ascending by `entry_id`, one per line, LF endings, exactly one
56
+ * terminating newline. Entries over MAX_LINE_BYTES (measured in
57
+ * BYTES — a Japanese statement passes a `.length` check and fails a
58
+ * byte check) and corpora over MAX_ENTRIES are refused, not
59
+ * truncated (plan §5.3, physical rules).
60
+ */
61
+ export function serialize(entries, repoId, version) {
62
+ if (entries.length > MAX_ENTRIES) {
63
+ throw new Error(`okf: corpus of ${entries.length} entries exceeds MAX_ENTRIES (${MAX_ENTRIES})`);
64
+ }
65
+ const sorted = [...entries].sort((a, b) => a.entry_id < b.entry_id ? -1 : a.entry_id > b.entry_id ? 1 : 0);
66
+ const lines = [
67
+ `#okf ${OKF_VERSION}`,
68
+ `#repo ${repoId}`,
69
+ `#generated-by opencode-kevin/${version}`,
70
+ ];
71
+ for (const e of sorted) {
72
+ const line = canonicalize(e);
73
+ if (Buffer.byteLength(line, "utf8") > MAX_LINE_BYTES) {
74
+ throw new Error(`okf: entry ${e.entry_id} canonicalizes to ${Buffer.byteLength(line, "utf8")} bytes, over MAX_LINE_BYTES (${MAX_LINE_BYTES})`);
75
+ }
76
+ lines.push(line);
77
+ }
78
+ return `${lines.join("\n")}\n`;
79
+ }
80
+ /**
81
+ * Group both corpora by `entry_id`, fold each group through `join()`,
82
+ * and return the result sorted ascending by `entry_id`. Order of the
83
+ * inputs does not matter: join() is commutative, and the fold order is
84
+ * the only place input order could leak in — it cannot, by algebra.
85
+ */
86
+ export function merge(a, b) {
87
+ const byId = new Map();
88
+ for (const e of [...a, ...b]) {
89
+ const existing = byId.get(e.entry_id);
90
+ byId.set(e.entry_id, existing ? join(existing, e) : e);
91
+ }
92
+ return [...byId.values()].sort((x, y) => x.entry_id < y.entry_id ? -1 : x.entry_id > y.entry_id ? 1 : 0);
93
+ }
94
+ /**
95
+ * Derived, never serialized — reuses the v0.4.0 two-sided confidence
96
+ * formula verbatim (plan §5.4). A lesson that keeps recurring is
97
+ * DEMOTED rather than merely un-promoted; shared and local memories
98
+ * are repriced identically by the same formula.
99
+ */
100
+ export function deriveConfidence(e) {
101
+ return computeConfidence(e.evidence, e.recurrence);
102
+ }
103
+ const OKF_TYPES = new Set(["decision", "rule", "pattern", "solution"]);
104
+ function pickMin(a, b) {
105
+ if (a === null)
106
+ return b;
107
+ if (b === null)
108
+ return a;
109
+ return a <= b ? a : b;
110
+ }
111
+ /**
112
+ * v0.8.0 (K8-013 / plan §5.4, D8-13) — the field lattice. Every field
113
+ * resolves through a max, a min, or an absorbing boolean OR over a
114
+ * totally ordered set; there is no "prefer the newer" anywhere.
115
+ * Precondition: `a.entry_id === b.entry_id`.
116
+ */
117
+ export function join(a, b) {
118
+ return {
119
+ entry_id: a.entry_id,
120
+ // Equal by construction unless a hash collision — resolve by
121
+ // lexicographic min so the function stays total and deterministic.
122
+ type: a.type <= b.type ? a.type : b.type,
123
+ statement: a.statement <= b.statement ? a.statement : b.statement,
124
+ scope: pickMin(a.scope, b.scope),
125
+ evidence: Math.max(a.evidence, b.evidence),
126
+ recurrence: Math.max(a.recurrence, b.recurrence),
127
+ origin: a.origin <= b.origin ? a.origin : b.origin,
128
+ author_hash: pickMin(a.author_hash, b.author_hash),
129
+ // Tombstone absorbs: no undelete, no timestamp tiebreak (D8-09).
130
+ op: a.op === "tombstone" || b.op === "tombstone" ? "tombstone" : "assert",
131
+ // Birthday semantics: min is the only choice stable under replay.
132
+ created_at: a.created_at <= b.created_at ? a.created_at : b.created_at,
133
+ supersedes: pickMin(a.supersedes, b.supersedes),
134
+ };
135
+ }
136
+ /**
137
+ * parse() is a TOTAL function — it never throws, on any input,
138
+ * including binary (D8-14). The file is expected to arrive damaged:
139
+ * a conflict resolution leaves `<<<<<<< HEAD` markers, an editor
140
+ * truncates the last line, a merge tool mangles an encoding. Every
141
+ * unusable line becomes a `RejectedLine`; the good entries survive.
142
+ *
143
+ * Reason taxonomy (closed): not_okf, version_ahead, bad_json,
144
+ * missing_field, wrong_type, id_mismatch, unknown_op, line_too_long,
145
+ * corpus_too_large.
146
+ */
147
+ export function parse(text) {
148
+ const rejected = [];
149
+ const reject = (line, reason) => {
150
+ rejected.push({ line, reason });
151
+ };
152
+ // A UTF-8 BOM breaks the `#okf ` prefix check; strip it first.
153
+ const body = text.replace(/^\uFEFF/, "");
154
+ const lines = body.split(/\r\n|\r|\n/);
155
+ let version = 0;
156
+ let repoId = null;
157
+ if (!(lines[0]?.startsWith("#okf ") ?? false)) {
158
+ reject(1, "not_okf");
159
+ return { version, repoId, entries: [], rejected, folded: 0 };
160
+ }
161
+ const declared = Number(lines[0].slice(5));
162
+ version = Number.isInteger(declared) && declared >= 0 ? declared : 0;
163
+ if (version > OKF_VERSION) {
164
+ // Guessing at a future format's semantics is how corpora get
165
+ // corrupted — refuse the whole file, never a best-effort parse.
166
+ return {
167
+ version,
168
+ repoId: null,
169
+ entries: [],
170
+ rejected: [{ line: 1, reason: "version_ahead" }],
171
+ folded: 0,
172
+ };
173
+ }
174
+ if (lines[1]?.startsWith("#repo ")) {
175
+ repoId = lines[1].slice(6) || null;
176
+ }
177
+ const byId = new Map();
178
+ let folded = 0;
179
+ let accepted = 0;
180
+ for (let i = 2; i < lines.length; i++) {
181
+ const line = lines[i];
182
+ if (line === "")
183
+ continue; // trailing newline / blank lines
184
+ if (line.startsWith("#"))
185
+ continue; // header/comment lines
186
+ const lineNo = i + 1;
187
+ if (Buffer.byteLength(line, "utf8") > MAX_LINE_BYTES) {
188
+ reject(lineNo, "line_too_long");
189
+ continue;
190
+ }
191
+ let raw;
192
+ try {
193
+ raw = JSON.parse(line);
194
+ }
195
+ catch {
196
+ reject(lineNo, "bad_json");
197
+ continue;
198
+ }
199
+ if (typeof raw !== "object" || raw === null) {
200
+ reject(lineNo, "bad_json");
201
+ continue;
202
+ }
203
+ const o = raw;
204
+ const missing = (k) => o[k] === undefined;
205
+ const wrong = (k, ok) => !missing(k) && !ok(o[k]);
206
+ const stringField = (k) => !wrong(k, (v) => typeof v === "string");
207
+ const nullableString = (k) => !wrong(k, (v) => v === null || typeof v === "string");
208
+ const intField = (k) => !wrong(k, (v) => typeof v === "number" && Number.isInteger(v) && v >= 0);
209
+ if (missing("entry_id"))
210
+ reject(lineNo, "missing_field");
211
+ else if (!stringField("entry_id"))
212
+ reject(lineNo, "wrong_type");
213
+ else if (missing("type"))
214
+ reject(lineNo, "missing_field");
215
+ else if (typeof o.type !== "string" || !OKF_TYPES.has(o.type))
216
+ reject(lineNo, "wrong_type");
217
+ else if (missing("statement"))
218
+ reject(lineNo, "missing_field");
219
+ else if (!stringField("statement"))
220
+ reject(lineNo, "wrong_type");
221
+ else if (!nullableString("scope"))
222
+ reject(lineNo, "wrong_type");
223
+ else if (missing("evidence"))
224
+ reject(lineNo, "missing_field");
225
+ else if (!intField("evidence"))
226
+ reject(lineNo, "wrong_type");
227
+ else if (missing("recurrence"))
228
+ reject(lineNo, "missing_field");
229
+ else if (!intField("recurrence"))
230
+ reject(lineNo, "wrong_type");
231
+ else if (missing("origin"))
232
+ reject(lineNo, "missing_field");
233
+ else if (!stringField("origin"))
234
+ reject(lineNo, "wrong_type");
235
+ else if (!nullableString("author_hash"))
236
+ reject(lineNo, "wrong_type");
237
+ else if (missing("op"))
238
+ reject(lineNo, "missing_field");
239
+ else if (o.op !== "assert" && o.op !== "tombstone")
240
+ reject(lineNo, "unknown_op");
241
+ else if (missing("created_at"))
242
+ reject(lineNo, "missing_field");
243
+ else if (!stringField("created_at"))
244
+ reject(lineNo, "wrong_type");
245
+ else if (!nullableString("supersedes"))
246
+ reject(lineNo, "wrong_type");
247
+ else {
248
+ // The tamper-evident check: a hand-edited statement without
249
+ // an updated entry_id is caught here, not silently ranked.
250
+ const recomputed = computeEntryId(o.type, o.statement, (o.scope ?? null));
251
+ if (recomputed !== o.entry_id) {
252
+ reject(lineNo, "id_mismatch");
253
+ continue;
254
+ }
255
+ const e = {
256
+ entry_id: o.entry_id,
257
+ type: o.type,
258
+ statement: o.statement,
259
+ scope: (o.scope ?? null),
260
+ evidence: o.evidence,
261
+ recurrence: o.recurrence,
262
+ origin: o.origin,
263
+ author_hash: (o.author_hash ?? null),
264
+ op: o.op,
265
+ created_at: o.created_at,
266
+ supersedes: (o.supersedes ?? null),
267
+ };
268
+ const existing = byId.get(e.entry_id);
269
+ if (existing) {
270
+ byId.set(e.entry_id, join(existing, e));
271
+ folded++;
272
+ continue;
273
+ }
274
+ if (accepted >= MAX_ENTRIES) {
275
+ reject(lineNo, "corpus_too_large");
276
+ continue;
277
+ }
278
+ byId.set(e.entry_id, e);
279
+ accepted++;
280
+ }
281
+ }
282
+ const entries = [...byId.values()].sort((a, b) => a.entry_id < b.entry_id ? -1 : a.entry_id > b.entry_id ? 1 : 0);
283
+ return { version, repoId, entries, rejected, folded };
284
+ }
285
+ /**
286
+ * Compute the identity of an OKF entry: `fnv1a64("okf:v2\0" + type +
287
+ * "\0" + statement + "\0" + (scope ?? ""))`.
288
+ *
289
+ * D8-05 — deliberately NOT `fingerprint()`:
290
+ * - it salts with `project_id`, so every clone would produce a
291
+ * different id for the same rule, the shared file would accumulate
292
+ * one entry per developer per rule, and the merge fold would never
293
+ * once fire;
294
+ * - it runs `normalize()`, which lowercases and rewrites
295
+ * `path.ext:line:col` — both destructive for a curated statement,
296
+ * where casing and file paths carry meaning.
297
+ *
298
+ * NUL separators keep (`rule`, "ab", "c") distinct from
299
+ * ("rule", "a", "bc") — plain concatenation could never.
300
+ */
301
+ export function computeEntryId(type, statement, scope) {
302
+ return fnv1a64(`okf:v2\u0000${type}\u0000${statement}\u0000${scope ?? ""}`);
303
+ }
304
+ //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CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;YACxB,QAAQ,EAAE,CAAC;QACZ,CAAC;IACF,CAAC;IAED,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAChD,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAC9D,CAAC;IACF,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;AACvD,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,cAAc,CAC7B,IAAY,EACZ,SAAiB,EACjB,KAAqB;IAErB,OAAO,OAAO,CAAC,eAAe,IAAI,SAAS,SAAS,SAAS,KAAK,IAAI,EAAE,EAAE,CAAC,CAAC;AAC7E,CAAC"}
@@ -1,4 +1,3 @@
1
- import { z } from "zod";
2
1
  /**
3
2
  * v0.5.0 (K5-018 / plan §5.8) — replay transcript format.
4
3
  *
@@ -6,318 +5,48 @@ import { z } from "zod";
6
5
  * plugin's components and read the outcome distribution. `at` is an
7
6
  * ISO-8601 string and is the ONLY source of time during replay:
8
7
  * `Date.now()` must not be called anywhere in the replay path.
8
+ *
9
+ * v0.7.0 — hand-rolled validation: the zod dependency was removed
10
+ * (docs/Kevin_v0.9.0_Plan.md D9-05). This module has no zod import.
9
11
  */
10
- export declare const replayEventSchema: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
11
- kind: z.ZodLiteral<"session.created">;
12
- at: z.ZodString;
13
- sessionId: z.ZodString;
14
- }, "strip", z.ZodTypeAny, {
15
- at: string;
16
- sessionId: string;
17
- kind: "session.created";
18
- }, {
19
- at: string;
20
- sessionId: string;
12
+ export type ReplayEvent = {
21
13
  kind: "session.created";
22
- }>, z.ZodObject<{
23
- kind: z.ZodLiteral<"chat.message">;
24
- at: z.ZodString;
25
- sessionId: z.ZodString;
26
- text: z.ZodString;
27
- }, "strip", z.ZodTypeAny, {
28
14
  at: string;
29
15
  sessionId: string;
16
+ } | {
30
17
  kind: "chat.message";
31
- text: string;
32
- }, {
33
18
  at: string;
34
19
  sessionId: string;
35
- kind: "chat.message";
36
20
  text: string;
37
- }>, z.ZodObject<{
38
- kind: z.ZodLiteral<"tool.before">;
39
- at: z.ZodString;
40
- sessionId: z.ZodString;
41
- callId: z.ZodString;
42
- tool: z.ZodString;
43
- args: z.ZodRecord<z.ZodString, z.ZodUnknown>;
44
- }, "strip", z.ZodTypeAny, {
45
- at: string;
46
- sessionId: string;
47
- tool: string;
21
+ } | {
48
22
  kind: "tool.before";
49
- callId: string;
50
- args: Record<string, unknown>;
51
- }, {
52
23
  at: string;
53
24
  sessionId: string;
54
- tool: string;
55
- kind: "tool.before";
56
25
  callId: string;
26
+ tool: string;
57
27
  args: Record<string, unknown>;
58
- }>, z.ZodObject<{
59
- kind: z.ZodLiteral<"tool.after">;
60
- at: z.ZodString;
61
- sessionId: z.ZodString;
62
- callId: z.ZodString;
63
- success: z.ZodBoolean;
64
- stdout: z.ZodOptional<z.ZodString>;
65
- stderr: z.ZodOptional<z.ZodString>;
66
- exitCode: z.ZodOptional<z.ZodNumber>;
67
- }, "strip", z.ZodTypeAny, {
68
- at: string;
69
- sessionId: string;
70
- success: boolean;
28
+ } | {
71
29
  kind: "tool.after";
72
- callId: string;
73
- exitCode?: number | undefined;
74
- stderr?: string | undefined;
75
- stdout?: string | undefined;
76
- }, {
77
30
  at: string;
78
31
  sessionId: string;
79
- success: boolean;
80
- kind: "tool.after";
81
32
  callId: string;
82
- exitCode?: number | undefined;
83
- stderr?: string | undefined;
84
- stdout?: string | undefined;
85
- }>, z.ZodObject<{
86
- kind: z.ZodLiteral<"system.transform">;
87
- at: z.ZodString;
88
- sessionId: z.ZodString;
89
- }, "strip", z.ZodTypeAny, {
90
- at: string;
91
- sessionId: string;
92
- kind: "system.transform";
93
- }, {
94
- at: string;
95
- sessionId: string;
33
+ success: boolean;
34
+ stdout?: string;
35
+ stderr?: string;
36
+ exitCode?: number;
37
+ } | {
96
38
  kind: "system.transform";
97
- }>, z.ZodObject<{
98
- kind: z.ZodLiteral<"compacting">;
99
- at: z.ZodString;
100
- sessionId: z.ZodString;
101
- }, "strip", z.ZodTypeAny, {
102
- at: string;
103
- sessionId: string;
104
- kind: "compacting";
105
- }, {
106
39
  at: string;
107
40
  sessionId: string;
41
+ } | {
108
42
  kind: "compacting";
109
- }>, z.ZodObject<{
110
- kind: z.ZodLiteral<"session.idle">;
111
- at: z.ZodString;
112
- sessionId: z.ZodString;
113
- }, "strip", z.ZodTypeAny, {
114
43
  at: string;
115
44
  sessionId: string;
45
+ } | {
116
46
  kind: "session.idle";
117
- }, {
118
47
  at: string;
119
48
  sessionId: string;
120
- kind: "session.idle";
121
- }>]>;
122
- export type ReplayEvent = z.infer<typeof replayEventSchema>;
123
- export declare const replayTranscriptSchema: z.ZodObject<{
124
- version: z.ZodLiteral<1>;
125
- name: z.ZodString;
126
- events: z.ZodArray<z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
127
- kind: z.ZodLiteral<"session.created">;
128
- at: z.ZodString;
129
- sessionId: z.ZodString;
130
- }, "strip", z.ZodTypeAny, {
131
- at: string;
132
- sessionId: string;
133
- kind: "session.created";
134
- }, {
135
- at: string;
136
- sessionId: string;
137
- kind: "session.created";
138
- }>, z.ZodObject<{
139
- kind: z.ZodLiteral<"chat.message">;
140
- at: z.ZodString;
141
- sessionId: z.ZodString;
142
- text: z.ZodString;
143
- }, "strip", z.ZodTypeAny, {
144
- at: string;
145
- sessionId: string;
146
- kind: "chat.message";
147
- text: string;
148
- }, {
149
- at: string;
150
- sessionId: string;
151
- kind: "chat.message";
152
- text: string;
153
- }>, z.ZodObject<{
154
- kind: z.ZodLiteral<"tool.before">;
155
- at: z.ZodString;
156
- sessionId: z.ZodString;
157
- callId: z.ZodString;
158
- tool: z.ZodString;
159
- args: z.ZodRecord<z.ZodString, z.ZodUnknown>;
160
- }, "strip", z.ZodTypeAny, {
161
- at: string;
162
- sessionId: string;
163
- tool: string;
164
- kind: "tool.before";
165
- callId: string;
166
- args: Record<string, unknown>;
167
- }, {
168
- at: string;
169
- sessionId: string;
170
- tool: string;
171
- kind: "tool.before";
172
- callId: string;
173
- args: Record<string, unknown>;
174
- }>, z.ZodObject<{
175
- kind: z.ZodLiteral<"tool.after">;
176
- at: z.ZodString;
177
- sessionId: z.ZodString;
178
- callId: z.ZodString;
179
- success: z.ZodBoolean;
180
- stdout: z.ZodOptional<z.ZodString>;
181
- stderr: z.ZodOptional<z.ZodString>;
182
- exitCode: z.ZodOptional<z.ZodNumber>;
183
- }, "strip", z.ZodTypeAny, {
184
- at: string;
185
- sessionId: string;
186
- success: boolean;
187
- kind: "tool.after";
188
- callId: string;
189
- exitCode?: number | undefined;
190
- stderr?: string | undefined;
191
- stdout?: string | undefined;
192
- }, {
193
- at: string;
194
- sessionId: string;
195
- success: boolean;
196
- kind: "tool.after";
197
- callId: string;
198
- exitCode?: number | undefined;
199
- stderr?: string | undefined;
200
- stdout?: string | undefined;
201
- }>, z.ZodObject<{
202
- kind: z.ZodLiteral<"system.transform">;
203
- at: z.ZodString;
204
- sessionId: z.ZodString;
205
- }, "strip", z.ZodTypeAny, {
206
- at: string;
207
- sessionId: string;
208
- kind: "system.transform";
209
- }, {
210
- at: string;
211
- sessionId: string;
212
- kind: "system.transform";
213
- }>, z.ZodObject<{
214
- kind: z.ZodLiteral<"compacting">;
215
- at: z.ZodString;
216
- sessionId: z.ZodString;
217
- }, "strip", z.ZodTypeAny, {
218
- at: string;
219
- sessionId: string;
220
- kind: "compacting";
221
- }, {
222
- at: string;
223
- sessionId: string;
224
- kind: "compacting";
225
- }>, z.ZodObject<{
226
- kind: z.ZodLiteral<"session.idle">;
227
- at: z.ZodString;
228
- sessionId: z.ZodString;
229
- }, "strip", z.ZodTypeAny, {
230
- at: string;
231
- sessionId: string;
232
- kind: "session.idle";
233
- }, {
234
- at: string;
235
- sessionId: string;
236
- kind: "session.idle";
237
- }>]>, "many">;
238
- }, "strip", z.ZodTypeAny, {
239
- version: 1;
240
- name: string;
241
- events: ({
242
- at: string;
243
- sessionId: string;
244
- kind: "session.created";
245
- } | {
246
- at: string;
247
- sessionId: string;
248
- kind: "chat.message";
249
- text: string;
250
- } | {
251
- at: string;
252
- sessionId: string;
253
- tool: string;
254
- kind: "tool.before";
255
- callId: string;
256
- args: Record<string, unknown>;
257
- } | {
258
- at: string;
259
- sessionId: string;
260
- success: boolean;
261
- kind: "tool.after";
262
- callId: string;
263
- exitCode?: number | undefined;
264
- stderr?: string | undefined;
265
- stdout?: string | undefined;
266
- } | {
267
- at: string;
268
- sessionId: string;
269
- kind: "system.transform";
270
- } | {
271
- at: string;
272
- sessionId: string;
273
- kind: "compacting";
274
- } | {
275
- at: string;
276
- sessionId: string;
277
- kind: "session.idle";
278
- })[];
279
- }, {
280
- version: 1;
281
- name: string;
282
- events: ({
283
- at: string;
284
- sessionId: string;
285
- kind: "session.created";
286
- } | {
287
- at: string;
288
- sessionId: string;
289
- kind: "chat.message";
290
- text: string;
291
- } | {
292
- at: string;
293
- sessionId: string;
294
- tool: string;
295
- kind: "tool.before";
296
- callId: string;
297
- args: Record<string, unknown>;
298
- } | {
299
- at: string;
300
- sessionId: string;
301
- success: boolean;
302
- kind: "tool.after";
303
- callId: string;
304
- exitCode?: number | undefined;
305
- stderr?: string | undefined;
306
- stdout?: string | undefined;
307
- } | {
308
- at: string;
309
- sessionId: string;
310
- kind: "system.transform";
311
- } | {
312
- at: string;
313
- sessionId: string;
314
- kind: "compacting";
315
- } | {
316
- at: string;
317
- sessionId: string;
318
- kind: "session.idle";
319
- })[];
320
- }>;
49
+ };
321
50
  export interface ReplayTranscript {
322
51
  readonly version: 1;
323
52
  readonly name: string;
@@ -325,3 +54,16 @@ export interface ReplayTranscript {
325
54
  }
326
55
  /** Validates an unknown payload (e.g. a parsed JSON file) as a transcript. */
327
56
  export declare function parseTranscript(json: unknown): ReplayTranscript;
57
+ interface SchemaLike<T> {
58
+ parse(value: unknown): T;
59
+ safeParse(value: unknown): {
60
+ success: true;
61
+ data: T;
62
+ } | {
63
+ success: false;
64
+ error: Error;
65
+ };
66
+ }
67
+ export declare const replayEventSchema: SchemaLike<ReplayEvent>;
68
+ export declare const replayTranscriptSchema: SchemaLike<ReplayTranscript>;
69
+ export {};