@jmtrin/opencode-kevin 0.7.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.
- package/README.md +198 -9
- package/dist/migrations/009_v08_team.sql +100 -0
- package/dist/plugin/ArtifactWriter.d.ts +28 -0
- package/dist/plugin/ArtifactWriter.js +35 -2
- package/dist/plugin/ArtifactWriter.js.map +1 -1
- package/dist/plugin/ContextInjector.d.ts +9 -0
- package/dist/plugin/ContextInjector.js +14 -3
- package/dist/plugin/ContextInjector.js.map +1 -1
- package/dist/plugin/Curator.d.ts +22 -2
- package/dist/plugin/Curator.js +56 -14
- package/dist/plugin/Curator.js.map +1 -1
- package/dist/plugin/InjectionLedger.d.ts +6 -0
- package/dist/plugin/InjectionLedger.js +6 -0
- package/dist/plugin/InjectionLedger.js.map +1 -1
- package/dist/plugin/Materializer.d.ts +4 -5
- package/dist/plugin/Materializer.js +9 -6
- package/dist/plugin/Materializer.js.map +1 -1
- package/dist/plugin/MemoryService.d.ts +34 -5
- package/dist/plugin/MemoryService.js +215 -7
- package/dist/plugin/MemoryService.js.map +1 -1
- package/dist/plugin/Migrate.js +33 -3
- package/dist/plugin/Migrate.js.map +1 -1
- package/dist/plugin/RepoIdentity.d.ts +113 -0
- package/dist/plugin/RepoIdentity.js +266 -0
- package/dist/plugin/RepoIdentity.js.map +1 -0
- package/dist/plugin/Retrospective.js +9 -0
- package/dist/plugin/Retrospective.js.map +1 -1
- package/dist/plugin/SharedLayer.d.ts +159 -0
- package/dist/plugin/SharedLayer.js +463 -0
- package/dist/plugin/SharedLayer.js.map +1 -0
- package/dist/plugin/index.d.ts +30 -1
- package/dist/plugin/index.js +458 -10
- package/dist/plugin/index.js.map +1 -1
- package/dist/plugin/kevin_approve.js +7 -4
- package/dist/plugin/kevin_approve.js.map +1 -1
- package/dist/plugin/kevin_audit.d.ts +19 -1
- package/dist/plugin/kevin_audit.js +95 -3
- package/dist/plugin/kevin_audit.js.map +1 -1
- package/dist/plugin/metrics.d.ts +1 -1
- package/dist/plugin/metrics.js +9 -0
- package/dist/plugin/metrics.js.map +1 -1
- package/dist/plugin/okf-export.d.ts +2 -2
- package/dist/plugin/okf-export.js +15 -7
- package/dist/plugin/okf-export.js.map +1 -1
- package/dist/plugin/okf.d.ts +107 -0
- package/dist/plugin/okf.js +304 -0
- package/dist/plugin/okf.js.map +1 -0
- package/dist/plugin/replay-types.d.ts +29 -287
- package/dist/plugin/replay-types.js +145 -53
- package/dist/plugin/replay-types.js.map +1 -1
- package/migrations/009_v08_team.sql +100 -0
- package/package.json +2 -3
|
@@ -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
|
|
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
|
-
}
|
|
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
|
-
}
|
|
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
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
-
|
|
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
|
-
name: string;
|
|
240
|
-
version: 1;
|
|
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
|
-
name: string;
|
|
281
|
-
version: 1;
|
|
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 {};
|
|
@@ -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,60 +5,153 @@ 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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
kind:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
12
|
+
const EVENT_KINDS = [
|
|
13
|
+
"session.created",
|
|
14
|
+
"chat.message",
|
|
15
|
+
"tool.before",
|
|
16
|
+
"tool.after",
|
|
17
|
+
"system.transform",
|
|
18
|
+
"compacting",
|
|
19
|
+
"session.idle",
|
|
20
|
+
];
|
|
21
|
+
const ISO_DATETIME_RE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/;
|
|
22
|
+
function isObject(value) {
|
|
23
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24
|
+
}
|
|
25
|
+
function isIsoDatetime(value) {
|
|
26
|
+
return (typeof value === "string" &&
|
|
27
|
+
ISO_DATETIME_RE.test(value) &&
|
|
28
|
+
!Number.isNaN(Date.parse(value)));
|
|
29
|
+
}
|
|
30
|
+
function isNonEmptyString(value) {
|
|
31
|
+
return typeof value === "string" && value.length > 0;
|
|
32
|
+
}
|
|
33
|
+
function isInteger(value) {
|
|
34
|
+
return typeof value === "number" && Number.isInteger(value);
|
|
35
|
+
}
|
|
36
|
+
function parseEvent(value) {
|
|
37
|
+
if (!isObject(value)) {
|
|
38
|
+
throw new Error("replay event must be an object");
|
|
39
|
+
}
|
|
40
|
+
const kind = value.kind;
|
|
41
|
+
if (typeof kind !== "string" ||
|
|
42
|
+
!EVENT_KINDS.includes(kind)) {
|
|
43
|
+
throw new Error(`unknown replay event kind: ${String(kind)}`);
|
|
44
|
+
}
|
|
45
|
+
const at = value.at;
|
|
46
|
+
if (!isIsoDatetime(at)) {
|
|
47
|
+
throw new Error("replay event `at` must be an ISO-8601 datetime string");
|
|
48
|
+
}
|
|
49
|
+
const sessionId = value.sessionId;
|
|
50
|
+
if (!isNonEmptyString(sessionId)) {
|
|
51
|
+
throw new Error("replay event `sessionId` must be a non-empty string");
|
|
52
|
+
}
|
|
53
|
+
switch (kind) {
|
|
54
|
+
case "session.created":
|
|
55
|
+
case "system.transform":
|
|
56
|
+
case "compacting":
|
|
57
|
+
case "session.idle":
|
|
58
|
+
return { kind, at, sessionId };
|
|
59
|
+
case "chat.message": {
|
|
60
|
+
const text = value.text;
|
|
61
|
+
if (!isNonEmptyString(text)) {
|
|
62
|
+
throw new Error("chat.message `text` must be a non-empty string");
|
|
63
|
+
}
|
|
64
|
+
return { kind, at, sessionId, text };
|
|
65
|
+
}
|
|
66
|
+
case "tool.before": {
|
|
67
|
+
const callId = value.callId;
|
|
68
|
+
if (!isNonEmptyString(callId)) {
|
|
69
|
+
throw new Error("tool.before `callId` must be a non-empty string");
|
|
70
|
+
}
|
|
71
|
+
const tool = value.tool;
|
|
72
|
+
if (!isNonEmptyString(tool)) {
|
|
73
|
+
throw new Error("tool.before `tool` must be a non-empty string");
|
|
74
|
+
}
|
|
75
|
+
if (!isObject(value.args)) {
|
|
76
|
+
throw new Error("tool.before `args` must be an object");
|
|
77
|
+
}
|
|
78
|
+
return { kind, at, sessionId, callId, tool, args: value.args };
|
|
79
|
+
}
|
|
80
|
+
case "tool.after": {
|
|
81
|
+
const callId = value.callId;
|
|
82
|
+
if (!isNonEmptyString(callId)) {
|
|
83
|
+
throw new Error("tool.after `callId` must be a non-empty string");
|
|
84
|
+
}
|
|
85
|
+
if (typeof value.success !== "boolean") {
|
|
86
|
+
throw new Error("tool.after `success` must be a boolean");
|
|
87
|
+
}
|
|
88
|
+
const event = {
|
|
89
|
+
kind,
|
|
90
|
+
at,
|
|
91
|
+
sessionId,
|
|
92
|
+
callId,
|
|
93
|
+
success: value.success,
|
|
94
|
+
};
|
|
95
|
+
if (value.stdout !== undefined) {
|
|
96
|
+
if (!isNonEmptyString(value.stdout)) {
|
|
97
|
+
throw new Error("tool.after `stdout` must be a non-empty string");
|
|
98
|
+
}
|
|
99
|
+
event.stdout = value.stdout;
|
|
100
|
+
}
|
|
101
|
+
if (value.stderr !== undefined) {
|
|
102
|
+
if (!isNonEmptyString(value.stderr)) {
|
|
103
|
+
throw new Error("tool.after `stderr` must be a non-empty string");
|
|
104
|
+
}
|
|
105
|
+
event.stderr = value.stderr;
|
|
106
|
+
}
|
|
107
|
+
if (value.exitCode !== undefined) {
|
|
108
|
+
if (!isInteger(value.exitCode)) {
|
|
109
|
+
throw new Error("tool.after `exitCode` must be an integer");
|
|
110
|
+
}
|
|
111
|
+
event.exitCode = value.exitCode;
|
|
112
|
+
}
|
|
113
|
+
return event;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
throw new Error(`unhandled replay event kind: ${String(kind)}`);
|
|
117
|
+
}
|
|
61
118
|
/** Validates an unknown payload (e.g. a parsed JSON file) as a transcript. */
|
|
62
119
|
export function parseTranscript(json) {
|
|
63
|
-
|
|
120
|
+
if (!isObject(json)) {
|
|
121
|
+
throw new Error("replay transcript must be an object");
|
|
122
|
+
}
|
|
123
|
+
if (json.version !== 1) {
|
|
124
|
+
throw new Error("replay transcript `version` must be 1");
|
|
125
|
+
}
|
|
126
|
+
const name = json.name;
|
|
127
|
+
if (!isNonEmptyString(name)) {
|
|
128
|
+
throw new Error("replay transcript `name` must be a non-empty string");
|
|
129
|
+
}
|
|
130
|
+
if (!Array.isArray(json.events) || json.events.length === 0) {
|
|
131
|
+
throw new Error("replay transcript `events` must be a non-empty array");
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
version: 1,
|
|
135
|
+
name,
|
|
136
|
+
events: json.events.map(parseEvent),
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
function toSchema(parse) {
|
|
140
|
+
return {
|
|
141
|
+
parse,
|
|
142
|
+
safeParse(value) {
|
|
143
|
+
try {
|
|
144
|
+
return { success: true, data: parse(value) };
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
return {
|
|
148
|
+
success: false,
|
|
149
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
};
|
|
64
154
|
}
|
|
155
|
+
export const replayEventSchema = toSchema(parseEvent);
|
|
156
|
+
export const replayTranscriptSchema = toSchema(parseTranscript);
|
|
65
157
|
//# sourceMappingURL=replay-types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replay-types.js","sourceRoot":"","sources":["../../plugin/replay-types.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"replay-types.js","sourceRoot":"","sources":["../../plugin/replay-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,WAAW,GAAG;IACnB,iBAAiB;IACjB,cAAc;IACd,aAAa;IACb,YAAY;IACZ,kBAAkB;IAClB,YAAY;IACZ,cAAc;CACL,CAAC;AAmCX,MAAM,eAAe,GACpB,kEAAkE,CAAC;AAEpE,SAAS,QAAQ,CAAC,KAAc;IAC/B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC7E,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACpC,OAAO,CACN,OAAO,KAAK,KAAK,QAAQ;QACzB,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC;QAC3B,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAChC,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAc;IACvC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;AACtD,CAAC;AAED,SAAS,SAAS,CAAC,KAAc;IAChC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AAC7D,CAAC;AAED,SAAS,UAAU,CAAC,KAAc;IACjC,IAAI,CAAC,QAAQ,CAAC,KA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