@linnlabs/linnkit 0.32.2 → 0.33.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 (78) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/dist/cli.cjs +312 -50
  3. package/dist/cli.cjs.map +1 -1
  4. package/dist/cli.js +312 -50
  5. package/dist/cli.js.map +1 -1
  6. package/dist/context-manager.cjs +1 -0
  7. package/dist/context-manager.cjs.map +1 -1
  8. package/dist/context-manager.js +1 -0
  9. package/dist/context-manager.js.map +1 -1
  10. package/dist/contracts/agentSpec.d.cts +30 -30
  11. package/dist/contracts/agentSpec.d.ts +30 -30
  12. package/dist/contracts/audit.d.cts +32 -32
  13. package/dist/contracts/audit.d.ts +32 -32
  14. package/dist/contracts/contextPolicy.d.cts +36 -36
  15. package/dist/contracts/contextPolicy.d.ts +36 -36
  16. package/dist/contracts/events.d.cts +968 -968
  17. package/dist/contracts/events.d.ts +968 -968
  18. package/dist/contracts/execution.d.cts +8 -8
  19. package/dist/contracts/execution.d.ts +8 -8
  20. package/dist/contracts/messages.d.cts +204 -204
  21. package/dist/contracts/messages.d.ts +204 -204
  22. package/dist/contracts/sse.d.cts +891 -891
  23. package/dist/contracts/sse.d.ts +891 -891
  24. package/dist/contracts/sub-run-trace-payload.d.cts +26 -26
  25. package/dist/contracts/sub-run-trace-payload.d.ts +26 -26
  26. package/dist/contracts/token-accounting.d.cts +28 -28
  27. package/dist/contracts/token-accounting.d.ts +28 -28
  28. package/dist/index.cjs +383 -66
  29. package/dist/index.cjs.map +1 -1
  30. package/dist/index.js +383 -66
  31. package/dist/index.js.map +1 -1
  32. package/dist/quickstart/toolRuntime.d.cts +1 -1
  33. package/dist/quickstart/toolRuntime.d.ts +1 -1
  34. package/dist/quickstart/types.d.cts +1 -1
  35. package/dist/quickstart/types.d.ts +1 -1
  36. package/dist/quickstart.cjs +312 -50
  37. package/dist/quickstart.cjs.map +1 -1
  38. package/dist/quickstart.js +312 -50
  39. package/dist/quickstart.js.map +1 -1
  40. package/dist/runtime-kernel/child-runs/childRunInvoker.d.cts +11 -0
  41. package/dist/runtime-kernel/child-runs/childRunInvoker.d.ts +11 -0
  42. package/dist/runtime-kernel/events/agentEvents.d.cts +98 -98
  43. package/dist/runtime-kernel/events/agentEvents.d.ts +98 -98
  44. package/dist/runtime-kernel/execution/eventBusEventPersistence.d.cts +15 -1
  45. package/dist/runtime-kernel/execution/eventBusEventPersistence.d.ts +15 -1
  46. package/dist/runtime-kernel/graph-engine/definitions/runContinuation.d.cts +34 -0
  47. package/dist/runtime-kernel/graph-engine/definitions/runContinuation.d.ts +34 -0
  48. package/dist/runtime-kernel/graph-engine/engine.d.cts +13 -2
  49. package/dist/runtime-kernel/graph-engine/engine.d.ts +13 -2
  50. package/dist/runtime-kernel/graph-engine/index.d.cts +2 -1
  51. package/dist/runtime-kernel/graph-engine/index.d.ts +2 -1
  52. package/dist/runtime-kernel/graph-engine/types.d.cts +8 -0
  53. package/dist/runtime-kernel/graph-engine/types.d.ts +8 -0
  54. package/dist/runtime-kernel/run-supervisor/definitions/runSupervisorContracts.d.cts +14 -2
  55. package/dist/runtime-kernel/run-supervisor/definitions/runSupervisorContracts.d.ts +14 -2
  56. package/dist/runtime-kernel/run-supervisor/memoryRunRegistryStore.d.cts +1 -0
  57. package/dist/runtime-kernel/run-supervisor/memoryRunRegistryStore.d.ts +1 -0
  58. package/dist/runtime-kernel/run-supervisor/runHandle.d.cts +9 -5
  59. package/dist/runtime-kernel/run-supervisor/runHandle.d.ts +9 -5
  60. package/dist/runtime-kernel/run-supervisor/runRegistryStorePort.d.cts +2 -0
  61. package/dist/runtime-kernel/run-supervisor/runRegistryStorePort.d.ts +2 -0
  62. package/dist/runtime-kernel/run-supervisor/runSupervisor.d.cts +7 -1
  63. package/dist/runtime-kernel/run-supervisor/runSupervisor.d.ts +7 -1
  64. package/dist/runtime-kernel.cjs +383 -66
  65. package/dist/runtime-kernel.cjs.map +1 -1
  66. package/dist/runtime-kernel.d.cts +2 -1
  67. package/dist/runtime-kernel.d.ts +2 -1
  68. package/dist/runtime-kernel.js +381 -67
  69. package/dist/runtime-kernel.js.map +1 -1
  70. package/dist/testkit.cjs +383 -66
  71. package/dist/testkit.cjs.map +1 -1
  72. package/dist/testkit.js +383 -66
  73. package/dist/testkit.js.map +1 -1
  74. package/docs/integration/01-installation.md +1 -1
  75. package/docs/integration/child-runs.md +12 -0
  76. package/docs/integration/persistence.md +23 -0
  77. package/docs/integration/run-supervisor.md +12 -2
  78. package/package.json +4 -4
@@ -12,19 +12,19 @@ declare const AgentEventSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"type", [z.
12
12
  meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
13
13
  thought_message_id: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
14
14
  }, "strict", z.ZodTypeAny, {
15
- id: string;
16
15
  type: "thought";
17
- content: string;
16
+ id: string;
18
17
  timestamp: number;
18
+ content: string;
19
19
  is_complete: boolean;
20
20
  thought_message_id?: string | undefined;
21
21
  delta?: string | undefined;
22
22
  meta?: Record<string, unknown> | undefined;
23
23
  }, {
24
- id: string;
25
24
  type: "thought";
26
- content: string;
25
+ id: string;
27
26
  timestamp: number;
27
+ content: string;
28
28
  is_complete: boolean;
29
29
  thought_message_id?: string | undefined;
30
30
  delta?: string | undefined;
@@ -329,6 +329,7 @@ declare const AgentEventSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"type", [z.
329
329
  }[] | undefined;
330
330
  }>]>, "many">>;
331
331
  }, "strict", z.ZodTypeAny, {
332
+ args?: Record<string, unknown> | undefined;
332
333
  tool_calls?: unknown[] | undefined;
333
334
  provider_continuations?: {
334
335
  kind: string;
@@ -388,8 +389,8 @@ declare const AgentEventSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"type", [z.
388
389
  payload: SerializableJsonValue;
389
390
  }[] | undefined;
390
391
  })[] | undefined;
391
- args?: Record<string, unknown> | undefined;
392
392
  }, {
393
+ args?: Record<string, unknown> | undefined;
393
394
  tool_calls?: unknown[] | undefined;
394
395
  provider_continuations?: {
395
396
  kind: string;
@@ -449,19 +450,19 @@ declare const AgentEventSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"type", [z.
449
450
  payload: SerializableJsonValue;
450
451
  }[] | undefined;
451
452
  })[] | undefined;
452
- args?: Record<string, unknown> | undefined;
453
453
  }>>;
454
454
  }, "strict", z.ZodTypeAny, {
455
+ type: "tool_call_decision";
455
456
  id: string;
457
+ timestamp: number;
456
458
  status: "error" | "loading" | "success";
457
- type: "tool_call_decision";
458
- tool_call_id: string & z.BRAND<"ToolCallId">;
459
459
  tool_name: string;
460
- timestamp: number;
461
- phase: "error" | "start" | "update" | "complete";
460
+ tool_call_id: string & z.BRAND<"ToolCallId">;
461
+ phase: "start" | "update" | "complete" | "error";
462
462
  tool_args: Record<string, unknown>;
463
463
  tool_calls?: unknown[] | undefined;
464
464
  payload?: {
465
+ args?: Record<string, unknown> | undefined;
465
466
  tool_calls?: unknown[] | undefined;
466
467
  provider_continuations?: {
467
468
  kind: string;
@@ -521,20 +522,20 @@ declare const AgentEventSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"type", [z.
521
522
  payload: SerializableJsonValue;
522
523
  }[] | undefined;
523
524
  })[] | undefined;
524
- args?: Record<string, unknown> | undefined;
525
525
  } | undefined;
526
526
  meta?: Record<string, unknown> | undefined;
527
527
  }, {
528
+ type: "tool_call_decision";
528
529
  id: string;
530
+ timestamp: number;
529
531
  status: "error" | "loading" | "success";
530
- type: "tool_call_decision";
531
- tool_call_id: string;
532
532
  tool_name: string;
533
- timestamp: number;
534
- phase: "error" | "start" | "update" | "complete";
533
+ tool_call_id: string;
534
+ phase: "start" | "update" | "complete" | "error";
535
535
  tool_args: Record<string, unknown>;
536
536
  tool_calls?: unknown[] | undefined;
537
537
  payload?: {
538
+ args?: Record<string, unknown> | undefined;
538
539
  tool_calls?: unknown[] | undefined;
539
540
  provider_continuations?: {
540
541
  kind: string;
@@ -594,7 +595,6 @@ declare const AgentEventSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"type", [z.
594
595
  payload: SerializableJsonValue;
595
596
  }[] | undefined;
596
597
  })[] | undefined;
597
- args?: Record<string, unknown> | undefined;
598
598
  } | undefined;
599
599
  meta?: Record<string, unknown> | undefined;
600
600
  }>, z.ZodObject<{
@@ -611,25 +611,25 @@ declare const AgentEventSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"type", [z.
611
611
  } & {
612
612
  type: z.ZodLiteral<"tool_process">;
613
613
  }, "strict", z.ZodTypeAny, {
614
+ type: "tool_process";
614
615
  id: string;
616
+ timestamp: number;
615
617
  status: "error" | "loading" | "success";
616
- type: "tool_process";
617
- tool_call_id: string & z.BRAND<"ToolCallId">;
618
618
  tool_name: string;
619
- timestamp: number;
620
- phase: "error" | "start" | "update" | "complete";
619
+ tool_call_id: string & z.BRAND<"ToolCallId">;
620
+ phase: "start" | "update" | "complete" | "error";
621
621
  tool_args: Record<string, unknown>;
622
622
  tool_calls?: unknown[] | undefined;
623
623
  payload?: Record<string, unknown> | undefined;
624
624
  meta?: Record<string, unknown> | undefined;
625
625
  }, {
626
+ type: "tool_process";
626
627
  id: string;
628
+ timestamp: number;
627
629
  status: "error" | "loading" | "success";
628
- type: "tool_process";
629
- tool_call_id: string;
630
630
  tool_name: string;
631
- timestamp: number;
632
- phase: "error" | "start" | "update" | "complete";
631
+ tool_call_id: string;
632
+ phase: "start" | "update" | "complete" | "error";
633
633
  tool_args: Record<string, unknown>;
634
634
  tool_calls?: unknown[] | undefined;
635
635
  payload?: Record<string, unknown> | undefined;
@@ -682,15 +682,13 @@ declare const AgentEventSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"type", [z.
682
682
  label?: string | undefined;
683
683
  }>, "many">>;
684
684
  }, "strict", z.ZodTypeAny, {
685
- id: string;
686
685
  type: "observation";
687
- tool_call_id: string & z.BRAND<"ToolCallId">;
688
- tool_name: string;
686
+ id: string;
689
687
  timestamp: number;
688
+ tool_name: string;
689
+ tool_call_id: string & z.BRAND<"ToolCallId">;
690
690
  success: boolean;
691
691
  observation: string;
692
- data?: unknown;
693
- error?: string | undefined;
694
692
  attachments?: {
695
693
  id: string;
696
694
  kind: "image";
@@ -703,18 +701,18 @@ declare const AgentEventSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"type", [z.
703
701
  fileName?: string | undefined;
704
702
  label?: string | undefined;
705
703
  }[] | undefined;
704
+ error?: string | undefined;
705
+ data?: unknown;
706
706
  error_code?: string | undefined;
707
707
  duration_ms?: number | undefined;
708
708
  }, {
709
- id: string;
710
709
  type: "observation";
711
- tool_call_id: string;
712
- tool_name: string;
710
+ id: string;
713
711
  timestamp: number;
712
+ tool_name: string;
713
+ tool_call_id: string;
714
714
  success: boolean;
715
715
  observation: string;
716
- data?: unknown;
717
- error?: string | undefined;
718
716
  attachments?: {
719
717
  id: string;
720
718
  kind: "image";
@@ -727,6 +725,8 @@ declare const AgentEventSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"type", [z.
727
725
  fileName?: string | undefined;
728
726
  label?: string | undefined;
729
727
  }[] | undefined;
728
+ error?: string | undefined;
729
+ data?: unknown;
730
730
  error_code?: string | undefined;
731
731
  duration_ms?: number | undefined;
732
732
  }>, z.ZodObject<{
@@ -1023,11 +1023,11 @@ declare const AgentEventSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"type", [z.
1023
1023
  }>]>, "many">>;
1024
1024
  meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1025
1025
  }, "strict", z.ZodTypeAny, {
1026
- id: string;
1027
1026
  type: "final_answer";
1028
- completion_reason: "tool_call" | "terminal" | "interrupted";
1027
+ id: string;
1029
1028
  timestamp: number;
1030
1029
  answer_id: string;
1030
+ completion_reason: "tool_call" | "terminal" | "interrupted";
1031
1031
  answer: string;
1032
1032
  provider_continuations?: {
1033
1033
  kind: string;
@@ -1089,11 +1089,11 @@ declare const AgentEventSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"type", [z.
1089
1089
  })[] | undefined;
1090
1090
  meta?: Record<string, unknown> | undefined;
1091
1091
  }, {
1092
- id: string;
1093
1092
  type: "final_answer";
1094
- completion_reason: "tool_call" | "terminal" | "interrupted";
1093
+ id: string;
1095
1094
  timestamp: number;
1096
1095
  answer_id: string;
1096
+ completion_reason: "tool_call" | "terminal" | "interrupted";
1097
1097
  answer: string;
1098
1098
  provider_continuations?: {
1099
1099
  kind: string;
@@ -1164,18 +1164,18 @@ declare const AgentEventSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"type", [z.
1164
1164
  retryable: z.ZodOptional<z.ZodBoolean>;
1165
1165
  details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1166
1166
  }, "strict", z.ZodTypeAny, {
1167
- id: string;
1168
1167
  type: "error";
1169
- error: string;
1168
+ id: string;
1170
1169
  timestamp: number;
1170
+ error: string;
1171
1171
  error_code?: string | undefined;
1172
1172
  details?: Record<string, unknown> | undefined;
1173
1173
  retryable?: boolean | undefined;
1174
1174
  }, {
1175
- id: string;
1176
1175
  type: "error";
1177
- error: string;
1176
+ id: string;
1178
1177
  timestamp: number;
1178
+ error: string;
1179
1179
  error_code?: string | undefined;
1180
1180
  details?: Record<string, unknown> | undefined;
1181
1181
  retryable?: boolean | undefined;
@@ -1189,18 +1189,18 @@ declare const AgentEventSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"type", [z.
1189
1189
  seq: z.ZodNumber;
1190
1190
  is_last: z.ZodOptional<z.ZodBoolean>;
1191
1191
  }, "strict", z.ZodTypeAny, {
1192
- id: string;
1193
1192
  type: "stream_chunk";
1194
- content: string;
1193
+ id: string;
1195
1194
  timestamp: number;
1195
+ content: string;
1196
1196
  answer_id: string;
1197
1197
  seq: number;
1198
1198
  is_last?: boolean | undefined;
1199
1199
  }, {
1200
- id: string;
1201
1200
  type: "stream_chunk";
1202
- content: string;
1201
+ id: string;
1203
1202
  timestamp: number;
1203
+ content: string;
1204
1204
  answer_id: string;
1205
1205
  seq: number;
1206
1206
  is_last?: boolean | undefined;
@@ -1212,14 +1212,14 @@ declare const AgentEventSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"type", [z.
1212
1212
  answer_id: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
1213
1213
  thought_message_ids: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
1214
1214
  }, "strict", z.ZodTypeAny, {
1215
- id: string;
1216
1215
  type: "stream_reset";
1216
+ id: string;
1217
1217
  timestamp: number;
1218
1218
  answer_id?: string | undefined;
1219
1219
  thought_message_ids?: string[] | undefined;
1220
1220
  }, {
1221
- id: string;
1222
1221
  type: "stream_reset";
1222
+ id: string;
1223
1223
  timestamp: number;
1224
1224
  answer_id?: string | undefined;
1225
1225
  thought_message_ids?: string[] | undefined;
@@ -1275,8 +1275,8 @@ declare const AgentEventSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"type", [z.
1275
1275
  payload: SerializableJsonValue;
1276
1276
  }>, "many">;
1277
1277
  }, "strict", z.ZodTypeAny, {
1278
- id: string;
1279
1278
  type: "provider_continuation";
1279
+ id: string;
1280
1280
  timestamp: number;
1281
1281
  continuations: {
1282
1282
  kind: string;
@@ -1291,8 +1291,8 @@ declare const AgentEventSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"type", [z.
1291
1291
  payload: SerializableJsonValue;
1292
1292
  }[];
1293
1293
  }, {
1294
- id: string;
1295
1294
  type: "provider_continuation";
1295
+ id: string;
1296
1296
  timestamp: number;
1297
1297
  continuations: {
1298
1298
  kind: string;
@@ -1307,25 +1307,26 @@ declare const AgentEventSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"type", [z.
1307
1307
  payload: SerializableJsonValue;
1308
1308
  }[];
1309
1309
  }>]>, {
1310
- id: string;
1311
1310
  type: "thought";
1312
- content: string;
1311
+ id: string;
1313
1312
  timestamp: number;
1313
+ content: string;
1314
1314
  is_complete: boolean;
1315
1315
  thought_message_id?: string | undefined;
1316
1316
  delta?: string | undefined;
1317
1317
  meta?: Record<string, unknown> | undefined;
1318
1318
  } | {
1319
+ type: "tool_call_decision";
1319
1320
  id: string;
1321
+ timestamp: number;
1320
1322
  status: "error" | "loading" | "success";
1321
- type: "tool_call_decision";
1322
- tool_call_id: string & z.BRAND<"ToolCallId">;
1323
1323
  tool_name: string;
1324
- timestamp: number;
1325
- phase: "error" | "start" | "update" | "complete";
1324
+ tool_call_id: string & z.BRAND<"ToolCallId">;
1325
+ phase: "start" | "update" | "complete" | "error";
1326
1326
  tool_args: Record<string, unknown>;
1327
1327
  tool_calls?: unknown[] | undefined;
1328
1328
  payload?: {
1329
+ args?: Record<string, unknown> | undefined;
1329
1330
  tool_calls?: unknown[] | undefined;
1330
1331
  provider_continuations?: {
1331
1332
  kind: string;
@@ -1385,31 +1386,28 @@ declare const AgentEventSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"type", [z.
1385
1386
  payload: SerializableJsonValue;
1386
1387
  }[] | undefined;
1387
1388
  })[] | undefined;
1388
- args?: Record<string, unknown> | undefined;
1389
1389
  } | undefined;
1390
1390
  meta?: Record<string, unknown> | undefined;
1391
1391
  } | {
1392
+ type: "tool_process";
1392
1393
  id: string;
1394
+ timestamp: number;
1393
1395
  status: "error" | "loading" | "success";
1394
- type: "tool_process";
1395
- tool_call_id: string & z.BRAND<"ToolCallId">;
1396
1396
  tool_name: string;
1397
- timestamp: number;
1398
- phase: "error" | "start" | "update" | "complete";
1397
+ tool_call_id: string & z.BRAND<"ToolCallId">;
1398
+ phase: "start" | "update" | "complete" | "error";
1399
1399
  tool_args: Record<string, unknown>;
1400
1400
  tool_calls?: unknown[] | undefined;
1401
1401
  payload?: Record<string, unknown> | undefined;
1402
1402
  meta?: Record<string, unknown> | undefined;
1403
1403
  } | {
1404
- id: string;
1405
1404
  type: "observation";
1406
- tool_call_id: string & z.BRAND<"ToolCallId">;
1407
- tool_name: string;
1405
+ id: string;
1408
1406
  timestamp: number;
1407
+ tool_name: string;
1408
+ tool_call_id: string & z.BRAND<"ToolCallId">;
1409
1409
  success: boolean;
1410
1410
  observation: string;
1411
- data?: unknown;
1412
- error?: string | undefined;
1413
1411
  attachments?: {
1414
1412
  id: string;
1415
1413
  kind: "image";
@@ -1422,14 +1420,16 @@ declare const AgentEventSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"type", [z.
1422
1420
  fileName?: string | undefined;
1423
1421
  label?: string | undefined;
1424
1422
  }[] | undefined;
1423
+ error?: string | undefined;
1424
+ data?: unknown;
1425
1425
  error_code?: string | undefined;
1426
1426
  duration_ms?: number | undefined;
1427
1427
  } | {
1428
- id: string;
1429
1428
  type: "final_answer";
1430
- completion_reason: "tool_call" | "terminal" | "interrupted";
1429
+ id: string;
1431
1430
  timestamp: number;
1432
1431
  answer_id: string;
1432
+ completion_reason: "tool_call" | "terminal" | "interrupted";
1433
1433
  answer: string;
1434
1434
  provider_continuations?: {
1435
1435
  kind: string;
@@ -1491,30 +1491,30 @@ declare const AgentEventSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"type", [z.
1491
1491
  })[] | undefined;
1492
1492
  meta?: Record<string, unknown> | undefined;
1493
1493
  } | {
1494
- id: string;
1495
1494
  type: "error";
1496
- error: string;
1495
+ id: string;
1497
1496
  timestamp: number;
1497
+ error: string;
1498
1498
  error_code?: string | undefined;
1499
1499
  details?: Record<string, unknown> | undefined;
1500
1500
  retryable?: boolean | undefined;
1501
1501
  } | {
1502
- id: string;
1503
1502
  type: "stream_chunk";
1504
- content: string;
1503
+ id: string;
1505
1504
  timestamp: number;
1505
+ content: string;
1506
1506
  answer_id: string;
1507
1507
  seq: number;
1508
1508
  is_last?: boolean | undefined;
1509
1509
  } | {
1510
- id: string;
1511
1510
  type: "stream_reset";
1511
+ id: string;
1512
1512
  timestamp: number;
1513
1513
  answer_id?: string | undefined;
1514
1514
  thought_message_ids?: string[] | undefined;
1515
1515
  } | {
1516
- id: string;
1517
1516
  type: "provider_continuation";
1517
+ id: string;
1518
1518
  timestamp: number;
1519
1519
  continuations: {
1520
1520
  kind: string;
@@ -1529,25 +1529,26 @@ declare const AgentEventSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"type", [z.
1529
1529
  payload: SerializableJsonValue;
1530
1530
  }[];
1531
1531
  }, {
1532
- id: string;
1533
1532
  type: "thought";
1534
- content: string;
1533
+ id: string;
1535
1534
  timestamp: number;
1535
+ content: string;
1536
1536
  is_complete: boolean;
1537
1537
  thought_message_id?: string | undefined;
1538
1538
  delta?: string | undefined;
1539
1539
  meta?: Record<string, unknown> | undefined;
1540
1540
  } | {
1541
+ type: "tool_call_decision";
1541
1542
  id: string;
1543
+ timestamp: number;
1542
1544
  status: "error" | "loading" | "success";
1543
- type: "tool_call_decision";
1544
- tool_call_id: string;
1545
1545
  tool_name: string;
1546
- timestamp: number;
1547
- phase: "error" | "start" | "update" | "complete";
1546
+ tool_call_id: string;
1547
+ phase: "start" | "update" | "complete" | "error";
1548
1548
  tool_args: Record<string, unknown>;
1549
1549
  tool_calls?: unknown[] | undefined;
1550
1550
  payload?: {
1551
+ args?: Record<string, unknown> | undefined;
1551
1552
  tool_calls?: unknown[] | undefined;
1552
1553
  provider_continuations?: {
1553
1554
  kind: string;
@@ -1607,31 +1608,28 @@ declare const AgentEventSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"type", [z.
1607
1608
  payload: SerializableJsonValue;
1608
1609
  }[] | undefined;
1609
1610
  })[] | undefined;
1610
- args?: Record<string, unknown> | undefined;
1611
1611
  } | undefined;
1612
1612
  meta?: Record<string, unknown> | undefined;
1613
1613
  } | {
1614
+ type: "tool_process";
1614
1615
  id: string;
1616
+ timestamp: number;
1615
1617
  status: "error" | "loading" | "success";
1616
- type: "tool_process";
1617
- tool_call_id: string;
1618
1618
  tool_name: string;
1619
- timestamp: number;
1620
- phase: "error" | "start" | "update" | "complete";
1619
+ tool_call_id: string;
1620
+ phase: "start" | "update" | "complete" | "error";
1621
1621
  tool_args: Record<string, unknown>;
1622
1622
  tool_calls?: unknown[] | undefined;
1623
1623
  payload?: Record<string, unknown> | undefined;
1624
1624
  meta?: Record<string, unknown> | undefined;
1625
1625
  } | {
1626
- id: string;
1627
1626
  type: "observation";
1628
- tool_call_id: string;
1629
- tool_name: string;
1627
+ id: string;
1630
1628
  timestamp: number;
1629
+ tool_name: string;
1630
+ tool_call_id: string;
1631
1631
  success: boolean;
1632
1632
  observation: string;
1633
- data?: unknown;
1634
- error?: string | undefined;
1635
1633
  attachments?: {
1636
1634
  id: string;
1637
1635
  kind: "image";
@@ -1644,14 +1642,16 @@ declare const AgentEventSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"type", [z.
1644
1642
  fileName?: string | undefined;
1645
1643
  label?: string | undefined;
1646
1644
  }[] | undefined;
1645
+ error?: string | undefined;
1646
+ data?: unknown;
1647
1647
  error_code?: string | undefined;
1648
1648
  duration_ms?: number | undefined;
1649
1649
  } | {
1650
- id: string;
1651
1650
  type: "final_answer";
1652
- completion_reason: "tool_call" | "terminal" | "interrupted";
1651
+ id: string;
1653
1652
  timestamp: number;
1654
1653
  answer_id: string;
1654
+ completion_reason: "tool_call" | "terminal" | "interrupted";
1655
1655
  answer: string;
1656
1656
  provider_continuations?: {
1657
1657
  kind: string;
@@ -1713,30 +1713,30 @@ declare const AgentEventSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"type", [z.
1713
1713
  })[] | undefined;
1714
1714
  meta?: Record<string, unknown> | undefined;
1715
1715
  } | {
1716
- id: string;
1717
1716
  type: "error";
1718
- error: string;
1717
+ id: string;
1719
1718
  timestamp: number;
1719
+ error: string;
1720
1720
  error_code?: string | undefined;
1721
1721
  details?: Record<string, unknown> | undefined;
1722
1722
  retryable?: boolean | undefined;
1723
1723
  } | {
1724
- id: string;
1725
1724
  type: "stream_chunk";
1726
- content: string;
1725
+ id: string;
1727
1726
  timestamp: number;
1727
+ content: string;
1728
1728
  answer_id: string;
1729
1729
  seq: number;
1730
1730
  is_last?: boolean | undefined;
1731
1731
  } | {
1732
- id: string;
1733
1732
  type: "stream_reset";
1733
+ id: string;
1734
1734
  timestamp: number;
1735
1735
  answer_id?: string | undefined;
1736
1736
  thought_message_ids?: string[] | undefined;
1737
1737
  } | {
1738
- id: string;
1739
1738
  type: "provider_continuation";
1739
+ id: string;
1740
1740
  timestamp: number;
1741
1741
  continuations: {
1742
1742
  kind: string;
@@ -1,11 +1,18 @@
1
1
  import { RoutedRuntimeEvent, RuntimeEvent } from '../../contracts/events.cjs';
2
- import { EventStore } from '../graph-engine/event-store/base.cjs';
2
+ import { EventStore, PersistedEvent } from '../graph-engine/event-store/base.cjs';
3
+ import { EngineState } from '../graph-engine/types.cjs';
3
4
  import { EventBus } from './event-bus.cjs';
4
5
 
5
6
  interface EventBusEventPersistenceOptions {
6
7
  eventBus: EventBus;
7
8
  eventStore: EventStore;
8
9
  nextEventStoreId: () => string;
10
+ /** 同一 SQLite 等短事务内提交已接纳事实与断点,并校验 activation 写入权。 */
11
+ checkpointWriter?: (input: {
12
+ readonly checkpointKey: string;
13
+ readonly checkpoint: EngineState;
14
+ readonly events: readonly PersistedEvent[];
15
+ }) => Promise<void>;
9
16
  }
10
17
  /**
11
18
  * EventBus durable consumer:按发布顺序串行写入事实,并在 run 进入终态前传播首个失败。
@@ -17,7 +24,13 @@ declare class EventBusEventPersistence {
17
24
  private writeTail;
18
25
  private firstWriteError;
19
26
  private connected;
27
+ private checkpointWritesActive;
28
+ private checkpointEvents;
20
29
  constructor(options: EventBusEventPersistenceOptions);
30
+ /** Graph 的执行边界复用同一有序队列;没有第二条事件写入链。 */
31
+ commitCheckpoint(checkpointKey: string, checkpoint: EngineState): Promise<void>;
32
+ /** 离开 Graph 后,未提交的 attempt 事实作废;随后 settlement metrics 走普通写入。 */
33
+ finishCheckpointWrites(): void;
21
34
  connect(): void;
22
35
  drain(): Promise<void>;
23
36
  /**
@@ -33,6 +46,7 @@ declare class EventBusEventPersistence {
33
46
  acknowledgePersisted(events: readonly RuntimeEvent[]): void;
34
47
  private readonly onEvent;
35
48
  private scheduleWrite;
49
+ private enqueueWrite;
36
50
  private readonly disconnect;
37
51
  }
38
52
 
@@ -1,11 +1,18 @@
1
1
  import { RoutedRuntimeEvent, RuntimeEvent } from '../../contracts/events.js';
2
- import { EventStore } from '../graph-engine/event-store/base.js';
2
+ import { EventStore, PersistedEvent } from '../graph-engine/event-store/base.js';
3
+ import { EngineState } from '../graph-engine/types.js';
3
4
  import { EventBus } from './event-bus.js';
4
5
 
5
6
  interface EventBusEventPersistenceOptions {
6
7
  eventBus: EventBus;
7
8
  eventStore: EventStore;
8
9
  nextEventStoreId: () => string;
10
+ /** 同一 SQLite 等短事务内提交已接纳事实与断点,并校验 activation 写入权。 */
11
+ checkpointWriter?: (input: {
12
+ readonly checkpointKey: string;
13
+ readonly checkpoint: EngineState;
14
+ readonly events: readonly PersistedEvent[];
15
+ }) => Promise<void>;
9
16
  }
10
17
  /**
11
18
  * EventBus durable consumer:按发布顺序串行写入事实,并在 run 进入终态前传播首个失败。
@@ -17,7 +24,13 @@ declare class EventBusEventPersistence {
17
24
  private writeTail;
18
25
  private firstWriteError;
19
26
  private connected;
27
+ private checkpointWritesActive;
28
+ private checkpointEvents;
20
29
  constructor(options: EventBusEventPersistenceOptions);
30
+ /** Graph 的执行边界复用同一有序队列;没有第二条事件写入链。 */
31
+ commitCheckpoint(checkpointKey: string, checkpoint: EngineState): Promise<void>;
32
+ /** 离开 Graph 后,未提交的 attempt 事实作废;随后 settlement metrics 走普通写入。 */
33
+ finishCheckpointWrites(): void;
21
34
  connect(): void;
22
35
  drain(): Promise<void>;
23
36
  /**
@@ -33,6 +46,7 @@ declare class EventBusEventPersistence {
33
46
  acknowledgePersisted(events: readonly RuntimeEvent[]): void;
34
47
  private readonly onEvent;
35
48
  private scheduleWrite;
49
+ private enqueueWrite;
36
50
  private readonly disconnect;
37
51
  }
38
52
 
@@ -0,0 +1,34 @@
1
+ import { StandardToolCall, EngineState } from '../types.cjs';
2
+ import { ToolExecutionContext } from '../../tools/toolExecutionContext.cjs';
3
+ import { ToolExecutionResult } from '../../tools/ports.cjs';
4
+
5
+ /** Host 在同一次提交中持久化已接纳事实与断点;不得跨 Provider / tool 调用持有事务。 */
6
+ interface ExecutionCheckpointPort {
7
+ commit(checkpointKey: string, checkpoint: EngineState): Promise<void>;
8
+ }
9
+ type ToolRecoveryDecision = {
10
+ readonly kind: 'retry';
11
+ } | {
12
+ readonly kind: 'settled';
13
+ readonly result: ToolExecutionResult;
14
+ } | {
15
+ readonly kind: 'blocked';
16
+ readonly reason: string;
17
+ };
18
+ /** 只有工具 owner 能证明未决外部动作的结果;参数相同不构成完成证据。 */
19
+ interface ToolRecoveryPort {
20
+ reconcile(call: StandardToolCall, context: ToolExecutionContext): Promise<ToolRecoveryDecision>;
21
+ }
22
+ declare class RunRecoveryBlockedError extends Error {
23
+ readonly code = "RUN_RECOVERY_BLOCKED";
24
+ constructor(message: string);
25
+ }
26
+ /** 可恢复中断与永久取消使用不同 signal reason,不为暂停补造工具失败终态。 */
27
+ declare class RunPauseRequested extends Error {
28
+ readonly code = "RUN_PAUSE_REQUESTED";
29
+ constructor(message?: string);
30
+ }
31
+ declare function isRunPauseSignal(signal: AbortSignal | undefined): boolean;
32
+
33
+ export { RunPauseRequested, RunRecoveryBlockedError, isRunPauseSignal };
34
+ export type { ExecutionCheckpointPort, ToolRecoveryDecision, ToolRecoveryPort };