akribes 0.21.17

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 (100) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/LICENSE +21 -0
  3. package/README.md +160 -0
  4. package/dist/client.d.ts +240 -0
  5. package/dist/client.d.ts.map +1 -0
  6. package/dist/client.js +272 -0
  7. package/dist/client.js.map +1 -0
  8. package/dist/errors.d.ts +196 -0
  9. package/dist/errors.d.ts.map +1 -0
  10. package/dist/errors.js +274 -0
  11. package/dist/errors.js.map +1 -0
  12. package/dist/execution/index.d.ts +3 -0
  13. package/dist/execution/index.d.ts.map +1 -0
  14. package/dist/execution/index.js +3 -0
  15. package/dist/execution/index.js.map +1 -0
  16. package/dist/execution/replay.d.ts +37 -0
  17. package/dist/execution/replay.d.ts.map +1 -0
  18. package/dist/execution/replay.js +59 -0
  19. package/dist/execution/replay.js.map +1 -0
  20. package/dist/execution/steps.d.ts +327 -0
  21. package/dist/execution/steps.d.ts.map +1 -0
  22. package/dist/execution/steps.js +1068 -0
  23. package/dist/execution/steps.js.map +1 -0
  24. package/dist/http.d.ts +53 -0
  25. package/dist/http.d.ts.map +1 -0
  26. package/dist/http.js +141 -0
  27. package/dist/http.js.map +1 -0
  28. package/dist/index.d.ts +36 -0
  29. package/dist/index.d.ts.map +1 -0
  30. package/dist/index.js +38 -0
  31. package/dist/index.js.map +1 -0
  32. package/dist/runStream.d.ts +176 -0
  33. package/dist/runStream.d.ts.map +1 -0
  34. package/dist/runStream.js +408 -0
  35. package/dist/runStream.js.map +1 -0
  36. package/dist/sse.d.ts +46 -0
  37. package/dist/sse.d.ts.map +1 -0
  38. package/dist/sse.js +218 -0
  39. package/dist/sse.js.map +1 -0
  40. package/dist/sub/bench.d.ts +182 -0
  41. package/dist/sub/bench.d.ts.map +1 -0
  42. package/dist/sub/bench.js +420 -0
  43. package/dist/sub/bench.js.map +1 -0
  44. package/dist/sub/channels.d.ts +22 -0
  45. package/dist/sub/channels.d.ts.map +1 -0
  46. package/dist/sub/channels.js +32 -0
  47. package/dist/sub/channels.js.map +1 -0
  48. package/dist/sub/clients.d.ts +79 -0
  49. package/dist/sub/clients.d.ts.map +1 -0
  50. package/dist/sub/clients.js +190 -0
  51. package/dist/sub/clients.js.map +1 -0
  52. package/dist/sub/documents.d.ts +113 -0
  53. package/dist/sub/documents.d.ts.map +1 -0
  54. package/dist/sub/documents.js +329 -0
  55. package/dist/sub/documents.js.map +1 -0
  56. package/dist/sub/evals.d.ts +71 -0
  57. package/dist/sub/evals.d.ts.map +1 -0
  58. package/dist/sub/evals.js +86 -0
  59. package/dist/sub/evals.js.map +1 -0
  60. package/dist/sub/events.d.ts +65 -0
  61. package/dist/sub/events.d.ts.map +1 -0
  62. package/dist/sub/events.js +154 -0
  63. package/dist/sub/events.js.map +1 -0
  64. package/dist/sub/executions.d.ts +255 -0
  65. package/dist/sub/executions.d.ts.map +1 -0
  66. package/dist/sub/executions.js +322 -0
  67. package/dist/sub/executions.js.map +1 -0
  68. package/dist/sub/mcp.d.ts +51 -0
  69. package/dist/sub/mcp.d.ts.map +1 -0
  70. package/dist/sub/mcp.js +42 -0
  71. package/dist/sub/mcp.js.map +1 -0
  72. package/dist/sub/projects.d.ts +73 -0
  73. package/dist/sub/projects.d.ts.map +1 -0
  74. package/dist/sub/projects.js +101 -0
  75. package/dist/sub/projects.js.map +1 -0
  76. package/dist/sub/scripts.d.ts +58 -0
  77. package/dist/sub/scripts.d.ts.map +1 -0
  78. package/dist/sub/scripts.js +82 -0
  79. package/dist/sub/scripts.js.map +1 -0
  80. package/dist/sub/tokens.d.ts +126 -0
  81. package/dist/sub/tokens.d.ts.map +1 -0
  82. package/dist/sub/tokens.js +105 -0
  83. package/dist/sub/tokens.js.map +1 -0
  84. package/dist/sub/versions.d.ts +29 -0
  85. package/dist/sub/versions.d.ts.map +1 -0
  86. package/dist/sub/versions.js +52 -0
  87. package/dist/sub/versions.js.map +1 -0
  88. package/dist/tokenSafety.d.ts +15 -0
  89. package/dist/tokenSafety.d.ts.map +1 -0
  90. package/dist/tokenSafety.js +24 -0
  91. package/dist/tokenSafety.js.map +1 -0
  92. package/dist/types.d.ts +1147 -0
  93. package/dist/types.d.ts.map +1 -0
  94. package/dist/types.js +132 -0
  95. package/dist/types.js.map +1 -0
  96. package/dist/workflowEvents.d.ts +297 -0
  97. package/dist/workflowEvents.d.ts.map +1 -0
  98. package/dist/workflowEvents.js +612 -0
  99. package/dist/workflowEvents.js.map +1 -0
  100. package/package.json +57 -0
@@ -0,0 +1,1147 @@
1
+ export type EngineEvent = {
2
+ type: string;
3
+ payload: unknown;
4
+ };
5
+ export type RegistryEvent = {
6
+ type: 'ProjectCreated';
7
+ payload: {
8
+ project_id: number;
9
+ project: Project;
10
+ };
11
+ } | {
12
+ type: 'ProjectUpdated';
13
+ payload: {
14
+ project_id: number;
15
+ project: Project;
16
+ };
17
+ } | {
18
+ type: 'ProjectDeleted';
19
+ payload: number;
20
+ } | {
21
+ type: 'ScriptCreated';
22
+ payload: {
23
+ project_id: number;
24
+ script: Script;
25
+ };
26
+ } | {
27
+ type: 'ScriptUpdated';
28
+ payload: {
29
+ project_id: number;
30
+ script_name: string;
31
+ version_id: number;
32
+ channel: string | null;
33
+ };
34
+ } | {
35
+ type: 'ScriptDeleted';
36
+ payload: {
37
+ project_id: number;
38
+ script_name: string;
39
+ };
40
+ };
41
+ export type EvalEvent = {
42
+ type: 'RunStarted';
43
+ payload: {
44
+ project_id: number;
45
+ script_name: string;
46
+ run: EvalRun;
47
+ };
48
+ } | {
49
+ type: 'RunProgress';
50
+ payload: {
51
+ project_id: number;
52
+ script_name: string;
53
+ run_id: number;
54
+ completed_cases: number;
55
+ total_cases: number | null;
56
+ average_score: number | null;
57
+ latest_result: EvalCaseReport | null;
58
+ };
59
+ } | {
60
+ type: 'RunFinished';
61
+ payload: {
62
+ project_id: number;
63
+ script_name: string;
64
+ run: EvalRun;
65
+ };
66
+ };
67
+ export type HubEvent = {
68
+ type: 'Execution';
69
+ payload: {
70
+ project_id: number;
71
+ script_name: string;
72
+ execution_id: string;
73
+ event: EngineEvent;
74
+ /** Monotonic per-execution sequence number. Starts at 1; matches the
75
+ * `execution_events.id` ordering for the same execution. Optional
76
+ * for forward-compat with older servers that don't yet stamp it. */
77
+ seq?: number;
78
+ /** Server-side RFC3339 timestamp with ms precision (e.g.
79
+ * `"2026-05-07T10:23:42.187Z"`). Optional for forward-compat. */
80
+ at?: string;
81
+ };
82
+ } | {
83
+ type: 'Registry';
84
+ payload: RegistryEvent;
85
+ } | {
86
+ type: 'Eval';
87
+ payload: EvalEvent;
88
+ };
89
+ export type Project = {
90
+ id: number;
91
+ name: string;
92
+ sort_order: number;
93
+ created_at: string;
94
+ };
95
+ export type Script = {
96
+ id: number;
97
+ project_id: number;
98
+ name: string;
99
+ sort_order: number;
100
+ created_at: string;
101
+ };
102
+ export type ClientInterest = {
103
+ script_name: string;
104
+ inputs: Record<string, string>;
105
+ channel?: string;
106
+ lifetime?: 'session' | 'perma';
107
+ strict?: boolean;
108
+ };
109
+ export type RegisteredInterest = {
110
+ script_name: string;
111
+ channel: string;
112
+ bound_version_id: number | null;
113
+ input_schema: [string, string][];
114
+ };
115
+ export type RegisterClientResponse = {
116
+ interests: RegisteredInterest[];
117
+ };
118
+ export type SchemaMismatch = {
119
+ missing: [string, string][];
120
+ wrong_type: [string, string, string][];
121
+ extra: string[];
122
+ };
123
+ export type ContractLockInfo = {
124
+ id: number;
125
+ client_id: string;
126
+ client_name: string;
127
+ script_name: string;
128
+ channel: string;
129
+ bound_version_id: number | null;
130
+ lifetime: string;
131
+ drifted: boolean;
132
+ created_by: string | null;
133
+ created_at: string;
134
+ input_schema: string;
135
+ };
136
+ export type ContractWarning = {
137
+ client_id: string;
138
+ client_name: string;
139
+ channel: string;
140
+ mismatch: SchemaMismatch;
141
+ };
142
+ /** Structural representation of a declared Akribes type. Nested `inner` handles
143
+ * parameterized types like `list[str]` or `list[Profile]`. `choices` is
144
+ * populated for `choice[...]` types. */
145
+ export type TypeRef = {
146
+ name: string;
147
+ inner?: TypeRef | null;
148
+ choices?: string[] | null;
149
+ };
150
+ /** Token consumption breakdown for a single task execution, mirroring the
151
+ * Rust `TokenUsage` struct in `akribes-core`. */
152
+ export type TokenUsage = {
153
+ input_tokens: number;
154
+ output_tokens: number;
155
+ model: string;
156
+ provider: string;
157
+ cached_input_tokens: number;
158
+ /** Cache-creation (write) tokens. Anthropic-only today: `cache_creation_input_tokens`
159
+ * from the Messages API usage block, billed by the server at 1.25x base
160
+ * input (5-minute TTL). OpenAI and Gemini always emit 0. Older servers
161
+ * that predate this field emit it as 0 via serde default. */
162
+ cache_write_input_tokens: number;
163
+ };
164
+ /** Known discriminants of `TaskEndPayload.variant` (issue #206). A future
165
+ * engine may add more (e.g. `"partial"` for #205); consumers MUST tolerate
166
+ * other string values via a catch-all.
167
+ */
168
+ export type KnownTaskEndVariant = 'success' | 'unable' | 'failed';
169
+ /** Wire shape of `TaskEndPayload.variant` — one of the {@link KnownTaskEndVariant}s
170
+ * today, or any other `snake_case` string from a newer server. Consumers
171
+ * should narrow on the known set and fall through for unknowns so the stream
172
+ * keeps flowing across SDK upgrades. Mirrors `akribes_core::event::TaskEndVariant`
173
+ * which uses `#[serde(other)]` for the same forward-compat contract. */
174
+ export type TaskEndVariant = KnownTaskEndVariant | (string & {});
175
+ /** Payload of a `TaskEnd` engine event. */
176
+ export type TaskEndPayload = {
177
+ task: string;
178
+ on_error_label: string | null;
179
+ value: unknown;
180
+ value_type: TypeRef | null;
181
+ /** serde-serialized `std::time::Duration` */
182
+ duration: {
183
+ secs: number;
184
+ nanos: number;
185
+ };
186
+ /** 1-indexed attempt number (u8) */
187
+ attempt: number;
188
+ usage: TokenUsage | null;
189
+ /** How the task finished (issue #206). `"success"` is the wire default
190
+ * emitted by the server; absence on the wire indicates a pre-#206
191
+ * server and should be treated as `"success"`. */
192
+ variant?: TaskEndVariant;
193
+ };
194
+ /**
195
+ * Studio-facing projection of an `input ... by <ref>(args)` clause (Track C).
196
+ *
197
+ * `display` is the source-form workflow ref (e.g. `epopy/fetch@production`).
198
+ * `explicit_args` lists the names of arguments the resolver clause binds
199
+ * literally — Studio uses this to know which slots are deterministic on
200
+ * the parent side vs. propagated implicitly from same-named parent inputs.
201
+ */
202
+ export type InputResolver = {
203
+ display: string;
204
+ explicit_args: string[];
205
+ };
206
+ /** A single `input <name>: <ty>` declaration as emitted by the draft endpoint. */
207
+ export type InputDecl = {
208
+ name: string;
209
+ ty: TypeRef;
210
+ /** Optional `##` doc-comment attached to the input. */
211
+ docs?: string | null;
212
+ /** Track C: optional fallback resolver attached via `input X: T by ref(args)`. */
213
+ resolver?: InputResolver | null;
214
+ };
215
+ /** A single field on a `type` declaration. */
216
+ export type TypeField = {
217
+ name: string;
218
+ ty: TypeRef;
219
+ /** Optional `##` doc-comment attached to the field. */
220
+ docs?: string | null;
221
+ };
222
+ export type PutDraftResponse = {
223
+ schema_warnings: ContractWarning[];
224
+ inputs: InputDecl[];
225
+ type_defs: Record<string, TypeField[]>;
226
+ };
227
+ export type BreakingInterest = {
228
+ client_id: string;
229
+ client_name: string;
230
+ channel: string;
231
+ lifetime: string;
232
+ mismatch: SchemaMismatch;
233
+ };
234
+ export type DryRunResult = {
235
+ dry_run: true;
236
+ would_break: number;
237
+ breaking_interests: BreakingInterest[];
238
+ };
239
+ export type ScriptVersion = {
240
+ id: number;
241
+ script_id: number;
242
+ source: string;
243
+ label: string | null;
244
+ published_by: string | null;
245
+ created_at: string;
246
+ };
247
+ export type ScriptVersionResponse = ScriptVersion & {
248
+ inputs: [string, string][];
249
+ };
250
+ export type ScriptChannel = {
251
+ id: number;
252
+ script_id: number;
253
+ name: string;
254
+ version_id: number | null;
255
+ updated_at: string | null;
256
+ };
257
+ export type RunResult = {
258
+ execution_id: string;
259
+ /** Event-log watermark a subscriber should pass as `last_event_id` on
260
+ * the FIRST `events.subscribe(...)` call after this run. Always `0`
261
+ * on a fresh spawn — the server's catchup path then replays every
262
+ * buffered event with `id > 0` so no event is dropped between the
263
+ * spawn response and the SSE/WS attach (#807). Optional for
264
+ * back-compat with pre-0.21.13 servers; treat `undefined` as `0`. */
265
+ since_id?: number;
266
+ };
267
+ export type ErrorKind = 'RateLimit' | 'AuthError' | 'TokenLimit' | 'ServerError' | 'ServerError500' | 'BadGateway502' | 'ServiceUnavailable503' | 'GatewayTimeout504' | 'NetworkError' | 'ParseError' | 'Cancelled' | 'ScriptError';
268
+ /** A document reference returned when S3 persistence is active. */
269
+ export type DocumentRef = {
270
+ document_id: string;
271
+ filename: string;
272
+ };
273
+ export type ExecutionStatus = {
274
+ id: string;
275
+ project_id: number;
276
+ script_name: string;
277
+ status: 'running' | 'completed' | 'failed' | 'cancelled';
278
+ started_at: string | null;
279
+ finished_at: string | null;
280
+ version_id: number | null;
281
+ channel: string | null;
282
+ error: string | null;
283
+ error_kind: ErrorKind | null;
284
+ result: unknown;
285
+ /** When S3 is enabled: `{ inputName: DocumentRef }`. Without S3: `{ inputName: markdownString }`. */
286
+ documents: Record<string, string | DocumentRef> | null;
287
+ triggered_by: string | null;
288
+ input_tokens: number;
289
+ output_tokens: number;
290
+ /** Tokens consumed by tool-response payloads (task 39b). */
291
+ tool_tokens?: number;
292
+ cost_usd: number | null;
293
+ /** Declared record types from the source the execution ran against,
294
+ * keyed by `type Name:` identifier. Lets clients render results back to
295
+ * their declared shape (named records, typed columns) instead of
296
+ * falling through to JSON shape inference. Empty object when the
297
+ * source couldn't be parsed; `undefined` from older servers. */
298
+ type_defs?: Record<string, TypeField[]>;
299
+ /** Workflow's declared return `TypeRef`, when statically resolvable from
300
+ * the source. Populated when the workflow ends in
301
+ * `return <task>(...)` or `return <flow>(...)` and the callee's
302
+ * signature is local. Lets the renderer dispatch straight into the
303
+ * typed path (e.g. `list[Patent]` → typed `RecordTable`) instead of
304
+ * inferring from `value`. `null` / `undefined` for older servers,
305
+ * unparseable source, or workflows whose final expression isn't a
306
+ * resolvable call. */
307
+ result_type?: TypeRef | null;
308
+ /** ID of the parent execution that spawned this one via `spawn_child_execution`.
309
+ * Null for top-level executions. Forward-looking for v1 (typically null until
310
+ * a host wires the spawn callback). */
311
+ parent_execution_id?: string | null;
312
+ /** The node ID within the parent execution at which this child was spawned.
313
+ * Null when `parent_execution_id` is null or when the node id is unavailable. */
314
+ parent_node_id?: string | null;
315
+ };
316
+ export type ExecutionOutput = {
317
+ status: 'running' | 'completed' | 'failed' | 'cancelled';
318
+ error: string | null;
319
+ error_kind: ErrorKind | null;
320
+ result: unknown;
321
+ };
322
+ export type CostByVersion = {
323
+ version_id: number | null;
324
+ executions: number;
325
+ total_cost_usd: number;
326
+ avg_cost_usd: number;
327
+ unknown_cost_executions: number;
328
+ };
329
+ export type CostByChannel = {
330
+ /** `"unknown"` when the execution row's channel column was NULL. */
331
+ channel: string;
332
+ executions: number;
333
+ total_cost_usd: number;
334
+ avg_cost_usd: number;
335
+ unknown_cost_executions: number;
336
+ };
337
+ export type CostByScript = {
338
+ script_name: string;
339
+ executions: number;
340
+ total_cost_usd: number;
341
+ avg_cost_usd: number;
342
+ unknown_cost_executions: number;
343
+ };
344
+ export type ScriptCost = {
345
+ total_executions: number;
346
+ total_cost_usd: number;
347
+ avg_cost_usd: number;
348
+ total_input_tokens: number;
349
+ total_output_tokens: number;
350
+ /** Executions whose model wasn't in the server's pricing table — their tokens
351
+ * are still counted but they contribute `0` to cost totals. */
352
+ unknown_cost_executions: number;
353
+ by_version: CostByVersion[];
354
+ by_channel: CostByChannel[];
355
+ };
356
+ export type ProjectCost = {
357
+ project_id: number;
358
+ total_executions: number;
359
+ total_cost_usd: number;
360
+ avg_cost_usd: number;
361
+ total_input_tokens: number;
362
+ total_output_tokens: number;
363
+ unknown_cost_executions: number;
364
+ by_script: CostByScript[];
365
+ by_channel: CostByChannel[];
366
+ };
367
+ export type ExecutionEvents = {
368
+ execution_id: string;
369
+ status: string;
370
+ complete: boolean;
371
+ events: EngineEvent[];
372
+ next_after_id: number | null;
373
+ has_more: boolean;
374
+ };
375
+ export type TokenInfo = {
376
+ id: string;
377
+ label: string;
378
+ user_email: string | null;
379
+ scopes: {
380
+ projects: '*' | number[];
381
+ role: 'admin' | 'editor' | 'viewer';
382
+ scripts?: string[];
383
+ executions?: string[];
384
+ can_mint: boolean;
385
+ };
386
+ minted_by: string;
387
+ expires_at: string;
388
+ revoked: boolean;
389
+ created_at: string;
390
+ last_used_at: string | null;
391
+ };
392
+ export type MintTokenResponse = {
393
+ token: string;
394
+ token_id: string;
395
+ expires_at: string;
396
+ };
397
+ export type ClientInfo = {
398
+ id: string;
399
+ name: string;
400
+ last_seen: string;
401
+ scripts: string[];
402
+ };
403
+ export type DraftResponse = {
404
+ source: string;
405
+ inputs: InputDecl[];
406
+ type_defs: Record<string, TypeField[]>;
407
+ };
408
+ /** Execution DAG graph returned by the /graph endpoint. */
409
+ export type ScriptGraph = {
410
+ nodes: ScriptGraphNode[];
411
+ edges: ScriptGraphEdge[];
412
+ };
413
+ export type ScriptGraphNode = {
414
+ id: number;
415
+ op_type: string;
416
+ op_name: string | null;
417
+ target_var: string | null;
418
+ reads: string[];
419
+ line: number;
420
+ col: number;
421
+ };
422
+ export type ScriptGraphEdge = {
423
+ from: number;
424
+ to: number;
425
+ };
426
+ /** S3 document reference via pre-signed URL. */
427
+ export type S3PresignedRef = {
428
+ presigned_url: string;
429
+ };
430
+ /** S3 document reference via temporary credentials. */
431
+ export type S3CredentialsRef = {
432
+ bucket: string;
433
+ key: string;
434
+ region?: string;
435
+ access_key_id: string;
436
+ secret_access_key: string;
437
+ session_token?: string;
438
+ };
439
+ /** S3 document reference — either a pre-signed URL or bucket/key with temp credentials. */
440
+ export type S3DocumentRef = S3PresignedRef | S3CredentialsRef;
441
+ /** Response from the /convert endpoint. */
442
+ export type ConvertResult = {
443
+ markdown: string;
444
+ /** Present when the server has S3 persistence enabled. Pass this back as a
445
+ * document input on subsequent runs to skip re-upload + reconversion. */
446
+ document_id?: string;
447
+ filename?: string;
448
+ };
449
+ export type EvalSuite = {
450
+ id: number;
451
+ script_id: number;
452
+ name: string;
453
+ runner_url: string;
454
+ config: Record<string, unknown>;
455
+ auto_run_channels: string[];
456
+ created_at: string;
457
+ };
458
+ export type EvalRun = {
459
+ id: number;
460
+ suite_id: number;
461
+ script_id: number;
462
+ version_id: number | null;
463
+ channel: string | null;
464
+ source_hash: string;
465
+ status: 'pending' | 'running' | 'completed' | 'failed' | 'canceled';
466
+ total_cases: number | null;
467
+ completed_cases: number;
468
+ average_score: number | null;
469
+ runner_run_id: string | null;
470
+ detail_url: string | null;
471
+ triggered_by: string | null;
472
+ started_at: string;
473
+ finished_at: string | null;
474
+ error: string | null;
475
+ };
476
+ export type EvalResult = {
477
+ id: number;
478
+ run_id: number;
479
+ case_id: string;
480
+ score: number | null;
481
+ status: string;
482
+ metadata: Record<string, unknown> | null;
483
+ execution_id: string | null;
484
+ created_at: string;
485
+ };
486
+ export type EvalCaseReport = {
487
+ case_id: string;
488
+ score: number | null;
489
+ status: string;
490
+ metadata: Record<string, unknown> | null;
491
+ execution_id: string | null;
492
+ };
493
+ export type EvalSuiteSummary = {
494
+ suite_id: number;
495
+ script_id: number;
496
+ script_name: string;
497
+ suite_name: string;
498
+ latest_run_id: number | null;
499
+ latest_run_at: string | null;
500
+ latest_avg_score: number | null;
501
+ prior_avg_score: number | null;
502
+ };
503
+ /** Wire status of a bench run. */
504
+ export type BenchStatus = 'pending' | 'running' | 'completed' | 'failed' | 'canceled';
505
+ /** Wire status of a single per-case result row. */
506
+ export type BenchResultStatus = 'ok' | 'workflow_failed' | 'judge_failed' | 'skipped' | 'cached';
507
+ /** Per-case compare flag emitted by `GET /bench-runs/{a}/compare/{b}`. */
508
+ export type CompareFlag = 'improved' | 'regressed' | 'unchanged' | 'missing_a' | 'missing_b';
509
+ /** A single typed value flowing through a bench case (input value, expected
510
+ * output, ground truth, judge score, workflow output). Shape is determined
511
+ * dynamically by the corresponding `TypeRef` from the script signature;
512
+ * consumers narrow via the schema. Matches Studio's `AkribesValue`. */
513
+ export type AkribesValue = unknown;
514
+ /** Per-input typed value bag — keys match the script's declared inputs (or
515
+ * outputs), values follow each field's `TypeRef`. Opaque at the SDK level
516
+ * because keys are dynamic per script; the server validates the payload
517
+ * against the script's signature on every write path. */
518
+ export type AkribesValueBag = Record<string, unknown>;
519
+ /** Free-form bench-runtime knobs. Not script IO — this is for the
520
+ * coordinator's own configuration (e.g. `concurrency`, `retry_policy`).
521
+ * The server tolerates extra keys for forward compat. */
522
+ export type BenchConfig = {
523
+ /** Max parallel case executions; defaults to 10 server-side. */
524
+ concurrency?: number;
525
+ [extra: string]: unknown;
526
+ };
527
+ /** Per-script bench configuration. One row per `scripts.id`.
528
+ * `judge_script_id` is nullable while the bench is still being authored. */
529
+ export type Bench = {
530
+ id: number;
531
+ script_id: number;
532
+ judge_script_id: number | null;
533
+ judge_channel: string;
534
+ config: BenchConfig;
535
+ created_at: string;
536
+ updated_at: string;
537
+ };
538
+ /** Aggregated per-bench summary backing the project-level evals landing
539
+ * page. Returned by `GET /projects/{id}/benches`. */
540
+ export type ProjectBenchSummary = {
541
+ bench_id: number;
542
+ script_id: number;
543
+ script_name: string;
544
+ judge_script_id: number | null;
545
+ judge_script_name: string | null;
546
+ judge_channel: string;
547
+ case_count: number;
548
+ latest_run_id: number | null;
549
+ latest_run_status: BenchStatus | null;
550
+ latest_run_channel: string | null;
551
+ latest_run_workflow_version_id: number | null;
552
+ latest_run_at: string | null;
553
+ latest_run_mean_score: number | null;
554
+ latest_run_cost_usd: number | null;
555
+ updated_at: string;
556
+ };
557
+ /** A single bench-run row. `workflow_version_id` / `judge_version_id` are
558
+ * resolved at trigger time so a later channel publish doesn't change what
559
+ * this run represents. */
560
+ export type BenchRun = {
561
+ id: number;
562
+ bench_id: number;
563
+ channel: string;
564
+ workflow_version_id: number;
565
+ judge_version_id: number;
566
+ status: BenchStatus;
567
+ triggered_by: string | null;
568
+ triggered_at: string;
569
+ completed_at: string | null;
570
+ total_cost_usd: number;
571
+ total_cases: number;
572
+ cache_hit_cases: number;
573
+ notes: string | null;
574
+ mcp_session_id?: string | null;
575
+ /** Subset of case IDs this run targets. `null` / absent = every case in
576
+ * the bench. */
577
+ case_filter?: string[] | null;
578
+ /** Mean headline_score across cases with `status='ok'|'cached'`. Populated
579
+ * by the list-runs aggregate query; bare GET-run leaves it absent. */
580
+ mean_headline_score?: number | null;
581
+ /** Count of results with `status='ok'|'cached'`. Paired with
582
+ * `mean_headline_score`. */
583
+ ok_cases?: number | null;
584
+ /** Per-`BenchResultStatus` row count for this run. Populated alongside
585
+ * `mean_headline_score` / `ok_cases` by the list-runs and get-run
586
+ * aggregate queries (#753). Statuses with zero rows may be absent
587
+ * rather than serialised as `0`. Use the headline `ok_cases` for the
588
+ * ok+cached total — the breakdown lets the rail split the rest into
589
+ * `workflow_failed` / `judge_failed` / `skipped`. */
590
+ status_breakdown?: Partial<Record<BenchResultStatus, number>>;
591
+ /** Pre-flight warnings populated by the trigger endpoint only — e.g.
592
+ * "OPENAI_API_KEY missing; N cases will likely fail". Empty / absent on
593
+ * every other read path. */
594
+ warnings?: string[];
595
+ /** Name of the judge script whose version produced this run, joined in by
596
+ * `get_run` and `list_runs` so consumers can deep-link to the judge's
597
+ * source at `judge_version_id` without an N+1 lookup. Absent on
598
+ * coordinator-inserted rows and on benches with no judge wired up. */
599
+ judge_script_name?: string | null;
600
+ };
601
+ /** One per-case score row for a bench run. Carries the workflow execution's
602
+ * typed output alongside the judge's score blob so the studio's typed
603
+ * renderers don't need a second fetch. */
604
+ export type BenchResult = {
605
+ id: number;
606
+ bench_run_id: number;
607
+ case_id: string;
608
+ workflow_execution_id: string | null;
609
+ judge_execution_id: string | null;
610
+ /** Full judge output — shape is dictated by the judge's declared output
611
+ * `TypeRef`. */
612
+ score: AkribesValue | null;
613
+ /** Workflow execution's actual output value, joined in on the read path
614
+ * from `executions.result`. `null` when the workflow failed, was
615
+ * canceled, or this row is a pure cache-hit. */
616
+ workflow_output: AkribesValue | null;
617
+ headline_score: number | null;
618
+ status: BenchResultStatus;
619
+ cost_usd: number;
620
+ duration_ms: number | null;
621
+ cache_hit: boolean;
622
+ input_hash?: string | null;
623
+ /** Human-readable error captured on `workflow_failed` / `judge_failed`
624
+ * rows. `null` on `ok` / `cached`. */
625
+ error?: string | null;
626
+ created_at: string;
627
+ };
628
+ /** Server-side projection of an `executions` row with `kind='case'`. */
629
+ export type BenchCase = {
630
+ /** `executions.id` for the underlying frozen execution row. */
631
+ id: string;
632
+ project_id: number;
633
+ script_name: string;
634
+ bench_id: number | null;
635
+ kind: string;
636
+ frozen: boolean;
637
+ case_name: string | null;
638
+ inputs: AkribesValueBag | null;
639
+ expected_output: AkribesValue | null;
640
+ ground_truth: AkribesValue | null;
641
+ /** SHA-256 hex of `canonical_json(inputs)`. Nullable on legacy rows. */
642
+ input_hash?: string | null;
643
+ created_at: string;
644
+ };
645
+ export type CompareCase = {
646
+ case_id: string;
647
+ case_label: string;
648
+ score_a: number | null;
649
+ score_b: number | null;
650
+ delta: number | null;
651
+ /** One of {@link CompareFlag} or any future server-emitted string. */
652
+ flag: CompareFlag | string;
653
+ };
654
+ export type CompareAggregate = {
655
+ mean_score_delta: number;
656
+ cost_delta_usd: number;
657
+ n_regressed: number;
658
+ n_improved: number;
659
+ n_unchanged: number;
660
+ };
661
+ export type CompareReport = {
662
+ run_a_id: number;
663
+ run_b_id: number;
664
+ aggregate: CompareAggregate;
665
+ per_case: CompareCase[];
666
+ };
667
+ export type DriftedCase = {
668
+ case_id: string;
669
+ label: string;
670
+ what_broke: string;
671
+ };
672
+ export type DriftReport = {
673
+ drifted: DriftedCase[];
674
+ /** `null` when the script has never been published. */
675
+ script_version_id: number | null;
676
+ published_at: string | null;
677
+ published_by: string | null;
678
+ /** Single-line summary suitable for inline display. Empty when no drift. */
679
+ summary: string;
680
+ };
681
+ /** Receipt returned by `PATCH /bench-runs/{id}/tag-session`. */
682
+ export type BenchRunTagSessionResponse = {
683
+ tagged: boolean;
684
+ run_id: number;
685
+ mcp_session_id: string;
686
+ };
687
+ /** Page of bench-run events emitted by the JSON form of
688
+ * `GET /bench-runs/{id}/events`. The MCP layer polls this for incremental
689
+ * updates; live UIs use the SSE form (same path). */
690
+ export type BenchRunEventsPage = {
691
+ events: unknown[];
692
+ complete?: boolean;
693
+ };
694
+ export type CreateOrUpdateBenchRequest = {
695
+ judge_script_id?: number | null;
696
+ judge_channel?: string;
697
+ config?: BenchConfig;
698
+ };
699
+ export type CreateBenchCaseRequest = {
700
+ /** Per-input typed value bag. Keys match the script's declared inputs;
701
+ * each value's shape follows the input's `TypeRef`. */
702
+ inputs: AkribesValueBag;
703
+ /** Optional expected output. Shape follows the script's declared output
704
+ * `TypeRef`. When omitted, the judge must work off `ground_truth`. */
705
+ expected_output?: AkribesValue;
706
+ /** Free-form judge ground-truth payload (no contract). */
707
+ ground_truth?: AkribesValue;
708
+ name?: string;
709
+ };
710
+ export type PatchBenchCaseRequest = {
711
+ inputs?: AkribesValueBag;
712
+ expected_output?: AkribesValue;
713
+ ground_truth?: AkribesValue;
714
+ name?: string;
715
+ };
716
+ export type PromoteCaseEdits = {
717
+ inputs?: AkribesValueBag;
718
+ expected_output?: AkribesValue;
719
+ ground_truth?: AkribesValue;
720
+ };
721
+ export type PromoteExecutionRequest = {
722
+ /** Override any of the source execution's inputs / outputs before
723
+ * freezing into a case. All shape-typed against the script's signature
724
+ * on the server side. */
725
+ edits?: PromoteCaseEdits;
726
+ name?: string;
727
+ };
728
+ export type TriggerBenchRunRequest = {
729
+ channel: string;
730
+ notes?: string;
731
+ /** Subset of case IDs. Empty / omitted = run every case. */
732
+ case_ids?: string[];
733
+ };
734
+ /** A single field on a script's declared signature. `ty` is the SDK's
735
+ * structural `TypeRef`, matching what live `EngineEvent::TaskEnd` values
736
+ * carry on `value_type`. */
737
+ export type BenchSignatureField = {
738
+ path: string;
739
+ ty: TypeRef;
740
+ required: boolean;
741
+ annotations: string[];
742
+ };
743
+ /** Parsed script signature — used to render type-aware form fields.
744
+ * Returned by `GET /projects/{id}/scripts/{name}/signature`. */
745
+ export type ScriptSignature = {
746
+ inputs: BenchSignatureField[];
747
+ outputs: BenchSignatureField[];
748
+ /** Named record types declared in the script source, keyed by
749
+ * `type Name:` identifier. */
750
+ type_defs: Record<string, TypeField[]>;
751
+ };
752
+ /** Workflow + judge signature pair plus the structured `breaks` list.
753
+ * Returned by `GET /projects/{id}/scripts/{name}/bench/contract-preview`. */
754
+ export type ContractPreview = {
755
+ workflow: {
756
+ fields: BenchSignatureField[];
757
+ };
758
+ judge: {
759
+ fields: BenchSignatureField[];
760
+ };
761
+ breaks: string[];
762
+ };
763
+ export type ToolCallStartEvent = {
764
+ task_name: string;
765
+ tool_name: string;
766
+ server_name: string;
767
+ input: unknown;
768
+ tool_use_id?: string;
769
+ };
770
+ export type ToolCallEndEvent = {
771
+ task_name: string;
772
+ tool_name: string;
773
+ output: unknown;
774
+ duration_ms: number;
775
+ error?: string;
776
+ tool_use_id?: string;
777
+ };
778
+ export type McpServerDegradedEvent = {
779
+ alias: string;
780
+ reason: string;
781
+ };
782
+ export type McpServerRecoveredEvent = {
783
+ alias: string;
784
+ };
785
+ export type McpServerSummary = {
786
+ alias: string;
787
+ url: string;
788
+ origin: 'env' | 'script' | 'db';
789
+ is_registry: boolean;
790
+ status: 'connected' | 'degraded' | 'offline' | 'pinned_offline';
791
+ tool_count: number;
792
+ };
793
+ export type McpToolSummary = {
794
+ qualified_name: string;
795
+ server_alias: string;
796
+ description?: string;
797
+ input_schema: unknown;
798
+ };
799
+ /** Typed narrower: returns true if an `EngineEvent` is a `ToolCallStart` event. */
800
+ export declare function isToolCallStart(event: EngineEvent): event is {
801
+ type: 'ToolCallStart';
802
+ payload: ToolCallStartEvent;
803
+ };
804
+ /** Typed narrower: returns true if an `EngineEvent` is a `ToolCallEnd` event. */
805
+ export declare function isToolCallEnd(event: EngineEvent): event is {
806
+ type: 'ToolCallEnd';
807
+ payload: ToolCallEndEvent;
808
+ };
809
+ /** Typed narrower: returns true if an `EngineEvent` is an `McpServerDegraded` event. */
810
+ export declare function isMcpServerDegraded(event: EngineEvent): event is {
811
+ type: 'McpServerDegraded';
812
+ payload: McpServerDegradedEvent;
813
+ };
814
+ /** Typed narrower: returns true if an `EngineEvent` is an `McpServerRecovered` event. */
815
+ export declare function isMcpServerRecovered(event: EngineEvent): event is {
816
+ type: 'McpServerRecovered';
817
+ payload: McpServerRecoveredEvent;
818
+ };
819
+ /** Emitted exactly once when a `loop NAME(...) -> Ret` call begins.
820
+ * `max_turns` is the resolved upper-bound turn budget (declared
821
+ * `max_turns:` if present, else the engine's default). */
822
+ export type LoopStartEvent = {
823
+ name: string;
824
+ max_turns: number;
825
+ };
826
+ /** Emitted after every turn of a `loop` settles. `turn` is 1-indexed.
827
+ * `tool_calls` is the names of the tools the model invoked this turn,
828
+ * in dispatch order — including the synthetic `state_get`,
829
+ * `state_update`, `return`, and any user `tools:` entries. */
830
+ export type LoopTurnEvent = {
831
+ name: string;
832
+ turn: number;
833
+ tool_calls: string[];
834
+ };
835
+ /** Emitted exactly once when a `loop` exits. `value` is the agent's
836
+ * submitted return value (from `return(...)`), the final state on a
837
+ * natural `stop_when:` exit without a return, or a `FatalError`
838
+ * envelope when the loop exhausted its `max_turns` budget. */
839
+ export type LoopEndEvent = {
840
+ name: string;
841
+ turn_count: number;
842
+ value: unknown;
843
+ };
844
+ /** Typed narrower: returns true if an `EngineEvent` is a `LoopStart`. */
845
+ export declare function isLoopStart(event: EngineEvent): event is {
846
+ type: 'LoopStart';
847
+ payload: LoopStartEvent;
848
+ };
849
+ /** Typed narrower: returns true if an `EngineEvent` is a `LoopTurn`. */
850
+ export declare function isLoopTurn(event: EngineEvent): event is {
851
+ type: 'LoopTurn';
852
+ payload: LoopTurnEvent;
853
+ };
854
+ /** Typed narrower: returns true if an `EngineEvent` is a `LoopEnd`. */
855
+ export declare function isLoopEnd(event: EngineEvent): event is {
856
+ type: 'LoopEnd';
857
+ payload: LoopEndEvent;
858
+ };
859
+ /** Emitted once per primitive activation of the compaction chain. Mirrors
860
+ * `akribes_core::event::EngineEvent::ContextCompacted` — fired by the
861
+ * engine before/after a compaction step succeeds in shrinking the
862
+ * conversation under the configured cap. `provider_native: true` means
863
+ * Anthropic / OpenAI performed the compaction server-side; the engine
864
+ * surfaces the before/after counts from the response. `strategy` is the
865
+ * primitive name (`drop_thinking_blocks`, `drop_oldest_tool_results`,
866
+ * `summarize_to_state`, `provider_native`) or the user task name for a
867
+ * custom compactor task.
868
+ *
869
+ * See `docs/superpowers/specs/2026-05-12-compaction-design.md`
870
+ * ("Observability + cost") for the contract.
871
+ */
872
+ export type ContextCompactedEvent = {
873
+ agent: string;
874
+ /** UUID of the surrounding `loop` block when compaction fires mid-loop;
875
+ * `null` for compaction outside a loop. */
876
+ loop_id: string | null;
877
+ /** 1-indexed loop turn the compaction fired before, when applicable. */
878
+ turn: number | null;
879
+ /** Configured percent-of-window threshold (0-100), when the
880
+ * triggering rule was `at_pct`. */
881
+ threshold_pct: number | null;
882
+ /** Configured absolute-token threshold, when the triggering rule was
883
+ * `at_tokens`. */
884
+ threshold_abs: number | null;
885
+ /** Primitive name or user task name. */
886
+ strategy: string;
887
+ before_tokens: number;
888
+ after_tokens: number;
889
+ provider_native: boolean;
890
+ /** Cache TTL applied on the request that produced this compaction.
891
+ * `"1h"` on the Anthropic `provider_native` path (akribes-core pins
892
+ * `ttl: "1h"` via the `extended-cache-ttl-2025-04-11` beta header),
893
+ * `null` for OpenAI native compaction and every non-native primitive.
894
+ * Cost dashboards multiply cache-write tokens by the correct provider
895
+ * rate via this field — the 5m and 1h tiers price 60% apart
896
+ * (issue #1130). */
897
+ cache_ttl?: string | null;
898
+ };
899
+ /** Emitted when the compaction chain runs to exhaustion (or when
900
+ * `compaction: none` and the request would still exceed the model's
901
+ * context window). Mirrors
902
+ * `akribes_core::event::EngineEvent::ContextOverflow`. Carries the chain
903
+ * log so users can diagnose which primitives ran before the engine gave
904
+ * up. A `ContextCompactionExhausted` `Error` event follows.
905
+ */
906
+ export type ContextOverflowEvent = {
907
+ agent: string;
908
+ attempted_strategies: string[];
909
+ configured_cap_tokens: number;
910
+ model_context_window: number;
911
+ };
912
+ /** Typed narrower: returns true if an `EngineEvent` is a `ContextCompacted`. */
913
+ export declare function isContextCompacted(event: EngineEvent): event is {
914
+ type: 'ContextCompacted';
915
+ payload: ContextCompactedEvent;
916
+ };
917
+ /** Typed narrower: returns true if an `EngineEvent` is a `ContextOverflow`. */
918
+ export declare function isContextOverflow(event: EngineEvent): event is {
919
+ type: 'ContextOverflow';
920
+ payload: ContextOverflowEvent;
921
+ };
922
+ /** LLM provider response captured for durable replay. Carries the full
923
+ * response (text + tool-use blocks + usage) keyed by `(node_id, call_index)`.
924
+ * Consumed by the engine's replay cache; UX clients typically ignore it.
925
+ * Mirrors `akribes_core::event::EngineEvent::LLMResponse`. */
926
+ export type LLMResponseEvent = {
927
+ node_id: string;
928
+ call_index: number;
929
+ text: string;
930
+ tool_calls: {
931
+ tool_use_id: string;
932
+ name: string;
933
+ args: unknown;
934
+ }[];
935
+ usage?: unknown;
936
+ };
937
+ /** A child execution row was just inserted at the parent's `call(...)` node.
938
+ * Mirrors `akribes_core::event::EngineEvent::SubScriptSpawned`. */
939
+ export type SubScriptSpawnedEvent = {
940
+ child_execution_id: string;
941
+ parent_node_id: string;
942
+ args: unknown;
943
+ };
944
+ /** Child execution finished; the parent observed its terminal state.
945
+ * `outcome.kind` is `"Ok"` or `"Err"`. Mirrors
946
+ * `akribes_core::event::EngineEvent::SubScriptResult`. */
947
+ export type SubScriptResultEvent = {
948
+ parent_node_id: string;
949
+ child_execution_id: string;
950
+ outcome: {
951
+ kind: 'Ok';
952
+ detail: {
953
+ value: unknown;
954
+ };
955
+ } | {
956
+ kind: 'Err';
957
+ detail: {
958
+ kind: string;
959
+ message: string;
960
+ code?: string;
961
+ };
962
+ };
963
+ };
964
+ /** A `Suspended` checkpoint resolved — the durable record of a /resume payload.
965
+ * Mirrors `akribes_core::event::EngineEvent::CheckpointResolution`. */
966
+ export type CheckpointResolutionEvent = {
967
+ checkpoint_id: string;
968
+ payload: unknown;
969
+ };
970
+ /** Typed narrower: returns true if an `EngineEvent` is an `LLMResponse`. */
971
+ export declare function isLLMResponse(event: EngineEvent): event is {
972
+ type: 'LLMResponse';
973
+ payload: LLMResponseEvent;
974
+ };
975
+ /** Typed narrower: returns true if an `EngineEvent` is a `SubScriptSpawned`. */
976
+ export declare function isSubScriptSpawned(event: EngineEvent): event is {
977
+ type: 'SubScriptSpawned';
978
+ payload: SubScriptSpawnedEvent;
979
+ };
980
+ /** Typed narrower: returns true if an `EngineEvent` is a `SubScriptResult`. */
981
+ export declare function isSubScriptResult(event: EngineEvent): event is {
982
+ type: 'SubScriptResult';
983
+ payload: SubScriptResultEvent;
984
+ };
985
+ /** Typed narrower: returns true if an `EngineEvent` is a `CheckpointResolution`. */
986
+ export declare function isCheckpointResolution(event: EngineEvent): event is {
987
+ type: 'CheckpointResolution';
988
+ payload: CheckpointResolutionEvent;
989
+ };
990
+ /**
991
+ * Structured "I can't" response from an agent. Mirrors the Rust `Unable`
992
+ * record (`crates/akribes-core/src/unable.rs`) — see `UNABLE_TYPE_NAME`.
993
+ *
994
+ * The canonical wire envelope is `{ "unable": UnableRecord }`. Detect with
995
+ * {@link isUnableEnvelope}.
996
+ */
997
+ export type UnableRecord = {
998
+ reason: string;
999
+ missing: string[];
1000
+ category: string;
1001
+ };
1002
+ /** Wire-format twin of the Rust `ValidationErrorWire`. The `stage` string is
1003
+ * `"parse"` | `"schema"` | `"custom:<rule>"` — kept opaque here so SDK
1004
+ * consumers don't need to round-trip through the internal enum. */
1005
+ export type ValidationErrorWire = {
1006
+ stage: string;
1007
+ message: string;
1008
+ /** JSON-pointer-like path for schema errors. `null`/absent for parse. */
1009
+ path?: string | null;
1010
+ };
1011
+ /** Names of the `SuspendTrigger` variants the SDK knows how to normalize. */
1012
+ export type KnownSuspendTriggerKind = 'DagPosition' | 'ValidationExhausted' | 'AgentUnable';
1013
+ /** Forward-compat catch-all for unknown `SuspendTrigger` kinds. Emitted
1014
+ * verbatim from the wire (snake_case fields preserved) so a newer server
1015
+ * never crashes an older SDK. Callers that want to opt in inspect `raw`
1016
+ * directly — the SDK makes no typed guarantees about its contents. */
1017
+ export type UnknownSuspendTrigger = {
1018
+ kind: string;
1019
+ /** Opaque wire payload with all fields from the server preserved. */
1020
+ raw: Record<string, unknown>;
1021
+ };
1022
+ /**
1023
+ * Why the engine suspended at a checkpoint. Mirrors the Rust `SuspendTrigger`
1024
+ * (serde-tagged on `"kind"`, `crates/akribes-core/src/event.rs`).
1025
+ *
1026
+ * Callers should narrow on `kind` for the known variants and fall through to
1027
+ * {@link UnknownSuspendTrigger} for future server versions.
1028
+ */
1029
+ export type SuspendTrigger = {
1030
+ kind: 'DagPosition';
1031
+ } | {
1032
+ kind: 'ValidationExhausted';
1033
+ taskName: string;
1034
+ retryCount: number;
1035
+ lastAttempt: string;
1036
+ validationErrors: ValidationErrorWire[];
1037
+ } | {
1038
+ kind: 'AgentUnable';
1039
+ taskName: string;
1040
+ unable: UnableRecord;
1041
+ } | UnknownSuspendTrigger;
1042
+ /** Return true iff `v` is a `{ "unable": <object> }` envelope and nothing
1043
+ * else. Mirrors `is_unable_envelope` in `akribes-core/src/unable.rs`. */
1044
+ export declare function isUnableEnvelope(v: unknown): v is {
1045
+ unable: UnableRecord;
1046
+ };
1047
+ /** Typed narrower: returns true if an `EngineEvent` is a `TaskEnd` event. */
1048
+ export declare function isTaskEnd(event: EngineEvent): event is {
1049
+ type: 'TaskEnd';
1050
+ payload: TaskEndPayload;
1051
+ };
1052
+ /** Payload of a `ValidationFailure` engine event (issue #320). Emitted in
1053
+ * addition to the existing `Log` line on every structured-output validation
1054
+ * retry — the typed shape lets consumers render the model's actual
1055
+ * response, the schema-validator's structured error breakdown, and the
1056
+ * provider's `stop_reason` (so a `max_tokens` truncation isn't
1057
+ * misdiagnosed as a schema overflow). Mirrors
1058
+ * `akribes_core::event::EngineEvent::ValidationFailure`. */
1059
+ export type ValidationFailurePayload = {
1060
+ task_name: string;
1061
+ /** 1-indexed attempt number. */
1062
+ attempt: number;
1063
+ /** Raw text / JSON-serialized tool input the model emitted. */
1064
+ model_response: string;
1065
+ /** JSON-pointer paths to required fields the validator flagged as absent. */
1066
+ missing_fields: string[];
1067
+ /** Paths to fields rejected by `additionalProperties: false`. */
1068
+ extra_fields: string[];
1069
+ /** Human-readable type/value mismatches. */
1070
+ type_errors: string[];
1071
+ /** Provider stop_reason (`"max_tokens"` / `"end_turn"` / etc.) when known. */
1072
+ stop_reason: string | null;
1073
+ };
1074
+ /** Typed narrower: returns true if an `EngineEvent` is a `ValidationFailure`. */
1075
+ export declare function isValidationFailure(event: EngineEvent): event is {
1076
+ type: 'ValidationFailure';
1077
+ payload: ValidationFailurePayload;
1078
+ };
1079
+ /** Emitted exactly once when a `runtime` block begins executing. `language`
1080
+ * is the lowercase language token from the `language:` field
1081
+ * (`python` / `bash` / `node` / `rust` / `java`); `runtime_name` is the
1082
+ * declared block name (e.g. `run_python`). */
1083
+ export type RuntimeStartEvent = {
1084
+ task_name: string;
1085
+ runtime_name: string;
1086
+ language: string;
1087
+ };
1088
+ /** Streaming stdout chunk from a `runtime` block. `chunk` is the partial
1089
+ * text exactly as the sandbox saw it on the child process's stdout; the
1090
+ * engine doesn't buffer line-by-line, so consumers may need to coalesce
1091
+ * partial lines themselves. */
1092
+ export type RuntimeStdoutEvent = {
1093
+ task_name: string;
1094
+ chunk: string;
1095
+ };
1096
+ /** Streaming stderr chunk from a `runtime` block. Same shape as
1097
+ * {@link RuntimeStdoutEvent} — separated so consumers can colour-code
1098
+ * output without re-classifying. */
1099
+ export type RuntimeStderrEvent = {
1100
+ task_name: string;
1101
+ chunk: string;
1102
+ };
1103
+ /** Emitted exactly once when a `runtime` block exits cleanly (process
1104
+ * finished — exit_code 0 means success, non-zero is still a "clean" exit
1105
+ * from the sandbox's perspective). `duration_ms` is wall-clock time from
1106
+ * RuntimeStart to process exit. */
1107
+ export type RuntimeEndEvent = {
1108
+ task_name: string;
1109
+ exit_code: number;
1110
+ duration_ms: number;
1111
+ };
1112
+ /** Emitted exactly once when a `runtime` block fails to run to completion —
1113
+ * e.g. sandbox unavailable, timeout, OOM kill, or any other internal
1114
+ * error. `kind` mirrors the `RuntimeError` enum on the Rust side
1115
+ * (`Timeout`, `OomKilled`, `SandboxUnavailable`, `Internal`, `NotConfigured`);
1116
+ * callers should branch on the known set and fall through for unknowns. */
1117
+ export type RuntimeErrorEvent = {
1118
+ task_name: string;
1119
+ kind: string;
1120
+ message: string;
1121
+ };
1122
+ /** Typed narrower: returns true if an `EngineEvent` is a `RuntimeStart`. */
1123
+ export declare function isRuntimeStart(event: EngineEvent): event is {
1124
+ type: 'RuntimeStart';
1125
+ payload: RuntimeStartEvent;
1126
+ };
1127
+ /** Typed narrower: returns true if an `EngineEvent` is a `RuntimeStdout`. */
1128
+ export declare function isRuntimeStdout(event: EngineEvent): event is {
1129
+ type: 'RuntimeStdout';
1130
+ payload: RuntimeStdoutEvent;
1131
+ };
1132
+ /** Typed narrower: returns true if an `EngineEvent` is a `RuntimeStderr`. */
1133
+ export declare function isRuntimeStderr(event: EngineEvent): event is {
1134
+ type: 'RuntimeStderr';
1135
+ payload: RuntimeStderrEvent;
1136
+ };
1137
+ /** Typed narrower: returns true if an `EngineEvent` is a `RuntimeEnd`. */
1138
+ export declare function isRuntimeEnd(event: EngineEvent): event is {
1139
+ type: 'RuntimeEnd';
1140
+ payload: RuntimeEndEvent;
1141
+ };
1142
+ /** Typed narrower: returns true if an `EngineEvent` is a `RuntimeError`. */
1143
+ export declare function isRuntimeError(event: EngineEvent): event is {
1144
+ type: 'RuntimeError';
1145
+ payload: RuntimeErrorEvent;
1146
+ };
1147
+ //# sourceMappingURL=types.d.ts.map