@inflexa-ai/harness 0.44.0 → 0.45.1

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 (187) hide show
  1. package/dist/agents/conversation-agent.d.ts +10 -0
  2. package/dist/agents/conversation-agent.js +19 -1
  3. package/dist/agents/sandbox/shared.d.ts +23 -2
  4. package/dist/agents/sandbox/shared.js +51 -18
  5. package/dist/agents/sandbox/translational-safety-agent.js +26 -0
  6. package/dist/agents/sandbox/types.d.ts +24 -1
  7. package/dist/agents/sandbox-catalog.d.ts +14 -0
  8. package/dist/agents/sandbox-catalog.js +19 -0
  9. package/dist/app/approve-plan.d.ts +51 -0
  10. package/dist/app/approve-plan.js +84 -0
  11. package/dist/app/chat-turn.js +6 -3
  12. package/dist/app/data-profile-view.d.ts +1 -1
  13. package/dist/app/run-activity.js +4 -6
  14. package/dist/config/environment-stores.d.ts +4 -2
  15. package/dist/contracts/chat-events.d.ts +14 -2
  16. package/dist/contracts/chat-events.js +1 -1
  17. package/dist/contracts/chat-frame.d.ts +7 -0
  18. package/dist/contracts/chat-frame.js +24 -6
  19. package/dist/contracts/chat-parts.d.ts +73 -2
  20. package/dist/contracts/chat-parts.js +3 -1
  21. package/dist/contracts/index.d.ts +4 -2
  22. package/dist/contracts/index.js +1 -0
  23. package/dist/contracts/part-registry.js +3 -0
  24. package/dist/contracts/schemas/chat-events.d.ts +38 -0
  25. package/dist/contracts/schemas/chat-events.js +8 -0
  26. package/dist/contracts/schemas/chat-parts.d.ts +239 -15
  27. package/dist/contracts/schemas/chat-parts.js +80 -12
  28. package/dist/contracts/schemas/index.d.ts +2 -2
  29. package/dist/contracts/schemas/index.js +2 -2
  30. package/dist/contracts/subagent-activity.d.ts +12 -0
  31. package/dist/contracts/subagent-activity.js +76 -0
  32. package/dist/execution/artifact-metadata.js +1 -3
  33. package/dist/execution/dbos-workflow-purger.d.ts +2 -0
  34. package/dist/execution/dbos-workflow-purger.js +21 -14
  35. package/dist/execution/run-canceler.d.ts +33 -11
  36. package/dist/execution/run-canceler.js +130 -28
  37. package/dist/execution/run-end-record.d.ts +30 -0
  38. package/dist/execution/run-end-record.js +27 -0
  39. package/dist/execution/run-event-parts.d.ts +6 -5
  40. package/dist/execution/run-event-parts.js +6 -5
  41. package/dist/execution/run-event-stream.d.ts +18 -6
  42. package/dist/execution/run-event-stream.js +67 -17
  43. package/dist/execution/run-synthesis.d.ts +21 -0
  44. package/dist/execution/run-synthesis.js +77 -3
  45. package/dist/index.d.ts +28 -10
  46. package/dist/index.js +26 -2
  47. package/dist/lib/hooks.d.ts +1 -1
  48. package/dist/lib/metrics.d.ts +2 -2
  49. package/dist/loop/call-guard.d.ts +50 -0
  50. package/dist/loop/call-guard.js +90 -0
  51. package/dist/loop/compaction.d.ts +5 -0
  52. package/dist/loop/compaction.js +17 -0
  53. package/dist/loop/run-agent.d.ts +9 -0
  54. package/dist/loop/run-agent.js +16 -1
  55. package/dist/loop/run-to-terminal.js +4 -1
  56. package/dist/loop/types.d.ts +8 -0
  57. package/dist/memory/card-builders.d.ts +11 -0
  58. package/dist/memory/card-builders.js +35 -21
  59. package/dist/memory/conversation-display-recorder.d.ts +2 -2
  60. package/dist/memory/conversation-display-recorder.js +38 -4
  61. package/dist/memory/conversation-display-storage.d.ts +9 -2
  62. package/dist/memory/conversation-display-storage.js +18 -3
  63. package/dist/memory/thread-history.d.ts +42 -8
  64. package/dist/memory/thread-history.js +164 -45
  65. package/dist/memory/thread-store.d.ts +13 -0
  66. package/dist/memory/thread-store.js +15 -1
  67. package/dist/prompts/briefing.d.ts +57 -3
  68. package/dist/prompts/briefing.js +129 -2
  69. package/dist/prompts/conversation.d.ts +1 -1
  70. package/dist/prompts/conversation.js +3 -1
  71. package/dist/prompts/planner.js +13 -2
  72. package/dist/provenance/seam.d.ts +39 -20
  73. package/dist/provenance/seam.js +7 -5
  74. package/dist/providers/ai-sdk.js +93 -11
  75. package/dist/providers/types.d.ts +6 -0
  76. package/dist/reference-data/catalog.js +141 -2
  77. package/dist/report-model/authoring-grammar.d.ts +26 -26
  78. package/dist/report-model/pin-snapshot.d.ts +1 -1
  79. package/dist/report-model/pin-snapshot.js +2 -50
  80. package/dist/runtime/assemble.d.ts +8 -1
  81. package/dist/runtime/assemble.js +11 -0
  82. package/dist/runtime/boot.d.ts +3 -0
  83. package/dist/runtime/boot.js +10 -1
  84. package/dist/sandbox/image-packages.d.ts +26 -4
  85. package/dist/sandbox/image-packages.js +18 -4
  86. package/dist/sandbox/sandbox-step-translate.d.ts +23 -0
  87. package/dist/sandbox/sandbox-step-translate.js +24 -0
  88. package/dist/schemas/artifact-manifest.d.ts +1 -1
  89. package/dist/schemas/artifact-manifest.js +11 -9
  90. package/dist/schemas/data-profile-schemas.d.ts +12 -12
  91. package/dist/schemas/plan-schemas.d.ts +75 -21
  92. package/dist/schemas/plan-schemas.js +1 -1
  93. package/dist/schemas/run-synthesis.d.ts +2 -2
  94. package/dist/schemas/workflow-state.d.ts +113 -0
  95. package/dist/schemas/workflow-state.js +54 -0
  96. package/dist/state/analyses-metrics.d.ts +79 -7
  97. package/dist/state/analyses-metrics.js +141 -6
  98. package/dist/state/artifacts.d.ts +66 -3
  99. package/dist/state/artifacts.js +85 -7
  100. package/dist/state/data-profile.d.ts +4 -2
  101. package/dist/state/data-profile.js +7 -5
  102. package/dist/state/index.d.ts +9 -8
  103. package/dist/state/index.js +5 -5
  104. package/dist/state/migrations/20261012120000_index_the_runs_by_start.d.ts +8 -0
  105. package/dist/state/migrations/20261012120000_index_the_runs_by_start.js +12 -0
  106. package/dist/state/migrations/20261013120000_index_the_ended_runs_and_the_recent_threads.d.ts +8 -0
  107. package/dist/state/migrations/20261013120000_index_the_ended_runs_and_the_recent_threads.js +13 -0
  108. package/dist/state/migrations/20261013180000_narrow_the_active_run_index.d.ts +8 -0
  109. package/dist/state/migrations/20261013180000_narrow_the_active_run_index.js +13 -0
  110. package/dist/state/migrations/20261014120000_index_the_plans_by_parent_and_the_runs_by_plan.d.ts +8 -0
  111. package/dist/state/migrations/20261014120000_index_the_plans_by_parent_and_the_runs_by_plan.js +13 -0
  112. package/dist/state/migrations/index.js +8 -0
  113. package/dist/state/plans.d.ts +21 -0
  114. package/dist/state/plans.js +25 -0
  115. package/dist/state/runs.d.ts +79 -14
  116. package/dist/state/runs.js +150 -33
  117. package/dist/state/schema.d.ts +2 -0
  118. package/dist/state/step-executions.d.ts +9 -0
  119. package/dist/state/step-executions.js +22 -0
  120. package/dist/tasks/data-profile-activity.d.ts +7 -1
  121. package/dist/tasks/data-profile-activity.js +18 -9
  122. package/dist/tasks/data-profile.d.ts +15 -1
  123. package/dist/tasks/data-profile.js +16 -11
  124. package/dist/tools/ad-hoc-router.d.ts +2 -0
  125. package/dist/tools/ad-hoc-router.js +18 -2
  126. package/dist/tools/approval/gateway.js +28 -5
  127. package/dist/tools/capability-data.d.ts +36 -0
  128. package/dist/tools/capability-data.js +73 -0
  129. package/dist/tools/display/show-user.d.ts +1 -1
  130. package/dist/tools/execute-analysis.d.ts +80 -1
  131. package/dist/tools/execute-analysis.js +352 -110
  132. package/dist/tools/knowledge/check.d.ts +60 -0
  133. package/dist/tools/knowledge/check.js +92 -0
  134. package/dist/tools/knowledge/client.d.ts +382 -0
  135. package/dist/tools/knowledge/client.js +302 -0
  136. package/dist/tools/knowledge/environment.d.ts +78 -0
  137. package/dist/tools/knowledge/environment.js +105 -0
  138. package/dist/tools/knowledge/index.d.ts +49 -0
  139. package/dist/tools/knowledge/index.js +70 -0
  140. package/dist/tools/knowledge/local-slots.d.ts +62 -0
  141. package/dist/tools/knowledge/local-slots.js +177 -0
  142. package/dist/tools/knowledge/pin.d.ts +14 -0
  143. package/dist/tools/knowledge/pin.js +17 -0
  144. package/dist/tools/knowledge/recommend.d.ts +92 -0
  145. package/dist/tools/knowledge/recommend.js +98 -0
  146. package/dist/tools/knowledge/situation.d.ts +143 -0
  147. package/dist/tools/knowledge/situation.js +164 -0
  148. package/dist/tools/knowledge/skeleton.d.ts +69 -0
  149. package/dist/tools/knowledge/skeleton.js +202 -0
  150. package/dist/tools/knowledge/template.d.ts +137 -0
  151. package/dist/tools/knowledge/template.js +267 -0
  152. package/dist/tools/research/generate-plan.d.ts +23 -0
  153. package/dist/tools/research/generate-plan.js +203 -12
  154. package/dist/tools/research/guarded-address.d.ts +20 -0
  155. package/dist/tools/research/guarded-address.js +148 -0
  156. package/dist/tools/research/inspect-data-profile.d.ts +1 -1
  157. package/dist/tools/research/inspect-run.d.ts +1 -1
  158. package/dist/tools/research/inspect-run.js +7 -7
  159. package/dist/tools/research/searxng-engine.d.ts +40 -0
  160. package/dist/tools/research/searxng-engine.js +120 -0
  161. package/dist/tools/research/web-fetch.d.ts +124 -0
  162. package/dist/tools/research/web-fetch.js +627 -0
  163. package/dist/tools/research/web-search.d.ts +75 -0
  164. package/dist/tools/research/web-search.js +112 -0
  165. package/dist/tools/sandbox/list-available-packages.d.ts +7 -4
  166. package/dist/tools/sandbox/list-available-packages.js +12 -4
  167. package/dist/tools/sandbox/list-available-refs.d.ts +21 -0
  168. package/dist/tools/sandbox/list-available-refs.js +60 -3
  169. package/dist/tools/sandbox/report-blocker.js +5 -1
  170. package/dist/tools/terminal-text.d.ts +11 -0
  171. package/dist/tools/terminal-text.js +19 -0
  172. package/dist/tools/workspace/decision-record.d.ts +81 -0
  173. package/dist/tools/workspace/decision-record.js +117 -0
  174. package/dist/tools/workspace/edit-file.d.ts +3 -1
  175. package/dist/tools/workspace/edit-file.js +20 -2
  176. package/dist/tools/workspace/execute-command.d.ts +17 -0
  177. package/dist/tools/workspace/execute-command.js +28 -1
  178. package/dist/tools/workspace/index.d.ts +1 -0
  179. package/dist/tools/workspace/index.js +1 -0
  180. package/dist/tools/workspace/mutator.d.ts +1 -1
  181. package/dist/workflows/execute-analysis.d.ts +62 -21
  182. package/dist/workflows/execute-analysis.js +307 -79
  183. package/dist/workflows/plan/graph.d.ts +16 -0
  184. package/dist/workflows/plan/graph.js +36 -0
  185. package/dist/workflows/sandbox-step.d.ts +12 -0
  186. package/dist/workflows/sandbox-step.js +14 -12
  187. package/package.json +5 -1
@@ -15,6 +15,19 @@ export declare const PlanStepSchema: z.ZodObject<{
15
15
  count: z.ZodNumber;
16
16
  }, z.core.$strip>>;
17
17
  }, z.core.$strip>>;
18
+ grounding: z.ZodOptional<z.ZodObject<{
19
+ status: z.ZodString;
20
+ snapshot: z.ZodString;
21
+ claims: z.ZodArray<z.ZodString>;
22
+ template: z.ZodOptional<z.ZodString>;
23
+ settings: z.ZodOptional<z.ZodArray<z.ZodObject<{
24
+ step: z.ZodString;
25
+ name: z.ZodString;
26
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString>]>;
27
+ source: z.ZodOptional<z.ZodString>;
28
+ }, z.core.$strip>>>;
29
+ reason: z.ZodString;
30
+ }, z.core.$strip>>;
18
31
  maxSteps: z.ZodNumber;
19
32
  track: z.ZodOptional<z.ZodString>;
20
33
  step_type: z.ZodOptional<z.ZodString>;
@@ -91,6 +104,7 @@ export declare const PlanPartSchema: z.ZodObject<{
91
104
  type: z.ZodLiteral<"data-plan">;
92
105
  id: z.ZodString;
93
106
  planId: z.ZodString;
107
+ parentPlanId: z.ZodOptional<z.ZodString>;
94
108
  title: z.ZodOptional<z.ZodString>;
95
109
  steps: z.ZodOptional<z.ZodArray<z.ZodObject<{
96
110
  id: z.ZodString;
@@ -105,6 +119,19 @@ export declare const PlanPartSchema: z.ZodObject<{
105
119
  count: z.ZodNumber;
106
120
  }, z.core.$strip>>;
107
121
  }, z.core.$strip>>;
122
+ grounding: z.ZodOptional<z.ZodObject<{
123
+ status: z.ZodString;
124
+ snapshot: z.ZodString;
125
+ claims: z.ZodArray<z.ZodString>;
126
+ template: z.ZodOptional<z.ZodString>;
127
+ settings: z.ZodOptional<z.ZodArray<z.ZodObject<{
128
+ step: z.ZodString;
129
+ name: z.ZodString;
130
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString>]>;
131
+ source: z.ZodOptional<z.ZodString>;
132
+ }, z.core.$strip>>>;
133
+ reason: z.ZodString;
134
+ }, z.core.$strip>>;
108
135
  maxSteps: z.ZodNumber;
109
136
  track: z.ZodOptional<z.ZodString>;
110
137
  step_type: z.ZodOptional<z.ZodString>;
@@ -124,6 +151,12 @@ export declare const RunCardPartSchema: z.ZodObject<{
124
151
  title: z.ZodString;
125
152
  stepCount: z.ZodNumber;
126
153
  }, z.core.$strip>;
154
+ export declare const PlanApprovalPartSchema: z.ZodObject<{
155
+ type: z.ZodLiteral<"data-plan-approval">;
156
+ planId: z.ZodString;
157
+ runId: z.ZodString;
158
+ approvedAt: z.ZodISODateTime;
159
+ }, z.core.$strip>;
127
160
  export declare const FileReferenceEntrySchema: z.ZodObject<{
128
161
  path: z.ZodString;
129
162
  runId: z.ZodOptional<z.ZodString>;
@@ -159,6 +192,11 @@ export declare const AskPartSchema: z.ZodObject<{
159
192
  rejected: "rejected";
160
193
  expired: "expired";
161
194
  }>;
195
+ reply: z.ZodOptional<z.ZodEnum<{
196
+ once: "once";
197
+ always: "always";
198
+ reject: "reject";
199
+ }>>;
162
200
  }, z.core.$strip>;
163
201
  export declare const RunStartedPartSchema: z.ZodObject<{
164
202
  type: z.ZodLiteral<"data-run-started">;
@@ -217,6 +255,18 @@ export declare const DagStatePartSchema: z.ZodObject<{
217
255
  error: z.ZodOptional<z.ZodString>;
218
256
  }, z.core.$strict>>;
219
257
  }, z.core.$strict>;
258
+ export declare const SynthesisPhaseSchema: z.ZodEnum<{
259
+ failed: "failed";
260
+ skipped: "skipped";
261
+ complete: "complete";
262
+ indexing: "indexing";
263
+ persisting: "persisting";
264
+ starting: "starting";
265
+ researching: "researching";
266
+ drafting: "drafting";
267
+ validating: "validating";
268
+ refining: "refining";
269
+ }>;
220
270
  export declare const StepPhaseSchema: z.ZodEnum<{
221
271
  failed: "failed";
222
272
  complete: "complete";
@@ -247,6 +297,38 @@ export declare const StepActivityPartSchema: z.ZodObject<{
247
297
  warning: "warning";
248
298
  }>;
249
299
  activity: z.ZodString;
300
+ at: z.ZodOptional<z.ZodString>;
301
+ }, z.core.$strip>;
302
+ export declare const ActivityEntryPartSchema: z.ZodObject<{
303
+ type: z.ZodLiteral<"data-activity-entry">;
304
+ id: z.ZodString;
305
+ runId: z.ZodString;
306
+ stepId: z.ZodString;
307
+ phase: z.ZodUnion<readonly [z.ZodEnum<{
308
+ failed: "failed";
309
+ complete: "complete";
310
+ "sandbox-init": "sandbox-init";
311
+ executing: "executing";
312
+ "generating-metadata": "generating-metadata";
313
+ "generating-summary": "generating-summary";
314
+ indexing: "indexing";
315
+ persisting: "persisting";
316
+ retrying: "retrying";
317
+ warning: "warning";
318
+ }>, z.ZodEnum<{
319
+ failed: "failed";
320
+ skipped: "skipped";
321
+ complete: "complete";
322
+ indexing: "indexing";
323
+ persisting: "persisting";
324
+ starting: "starting";
325
+ researching: "researching";
326
+ drafting: "drafting";
327
+ validating: "validating";
328
+ refining: "refining";
329
+ }>]>;
330
+ activity: z.ZodString;
331
+ at: z.ZodString;
250
332
  }, z.core.$strip>;
251
333
  export declare const FileTreeEntrySchema: z.ZodObject<{
252
334
  path: z.ZodString;
@@ -373,6 +455,17 @@ export declare const RunCompletedPartSchema: z.ZodObject<{
373
455
  reasoningTokens: z.ZodOptional<z.ZodNumber>;
374
456
  }, z.core.$strip>>;
375
457
  }, z.core.$strip>;
458
+ export declare const FindingReferenceSchema: z.ZodObject<{
459
+ pmid: z.ZodString;
460
+ citation: z.ZodString;
461
+ relevance: z.ZodString;
462
+ concordance: z.ZodEnum<{
463
+ supports: "supports";
464
+ contradicts: "contradicts";
465
+ extends: "extends";
466
+ contextualizes: "contextualizes";
467
+ }>;
468
+ }, z.core.$strip>;
376
469
  export declare const SynthesizedFindingSchema: z.ZodObject<{
377
470
  stepId: z.ZodString;
378
471
  title: z.ZodString;
@@ -383,13 +476,24 @@ export declare const SynthesizedFindingSchema: z.ZodObject<{
383
476
  high: "high";
384
477
  }>;
385
478
  noveltyStatus: z.ZodEnum<{
386
- expected: "expected";
387
479
  novel: "novel";
388
480
  confirmed: "confirmed";
389
481
  partially_confirmed: "partially_confirmed";
390
482
  contradicted: "contradicted";
483
+ expected: "expected";
391
484
  }>;
392
485
  literatureInterpretation: z.ZodString;
486
+ references: z.ZodArray<z.ZodObject<{
487
+ pmid: z.ZodString;
488
+ citation: z.ZodString;
489
+ relevance: z.ZodString;
490
+ concordance: z.ZodEnum<{
491
+ supports: "supports";
492
+ contradicts: "contradicts";
493
+ extends: "extends";
494
+ contextualizes: "contextualizes";
495
+ }>;
496
+ }, z.core.$strip>>;
393
497
  }, z.core.$strip>;
394
498
  export declare const BiologicalThemeSchema: z.ZodObject<{
395
499
  name: z.ZodString;
@@ -415,13 +519,24 @@ export declare const RunSynthesisPartSchema: z.ZodObject<{
415
519
  high: "high";
416
520
  }>;
417
521
  noveltyStatus: z.ZodEnum<{
418
- expected: "expected";
419
522
  novel: "novel";
420
523
  confirmed: "confirmed";
421
524
  partially_confirmed: "partially_confirmed";
422
525
  contradicted: "contradicted";
526
+ expected: "expected";
423
527
  }>;
424
528
  literatureInterpretation: z.ZodString;
529
+ references: z.ZodArray<z.ZodObject<{
530
+ pmid: z.ZodString;
531
+ citation: z.ZodString;
532
+ relevance: z.ZodString;
533
+ concordance: z.ZodEnum<{
534
+ supports: "supports";
535
+ contradicts: "contradicts";
536
+ extends: "extends";
537
+ contextualizes: "contextualizes";
538
+ }>;
539
+ }, z.core.$strip>>;
425
540
  }, z.core.$strip>>;
426
541
  themes: z.ZodArray<z.ZodObject<{
427
542
  name: z.ZodString;
@@ -438,18 +553,6 @@ export declare const RunSynthesisPartSchema: z.ZodObject<{
438
553
  description: z.ZodString;
439
554
  }, z.core.$strip>>;
440
555
  }, z.core.$strip>;
441
- export declare const SynthesisPhaseSchema: z.ZodEnum<{
442
- failed: "failed";
443
- skipped: "skipped";
444
- complete: "complete";
445
- indexing: "indexing";
446
- persisting: "persisting";
447
- starting: "starting";
448
- researching: "researching";
449
- drafting: "drafting";
450
- validating: "validating";
451
- refining: "refining";
452
- }>;
453
556
  export declare const SynthesisProgressPartSchema: z.ZodObject<{
454
557
  type: z.ZodLiteral<"data-synthesis-progress">;
455
558
  id: z.ZodString;
@@ -467,6 +570,7 @@ export declare const SynthesisProgressPartSchema: z.ZodObject<{
467
570
  refining: "refining";
468
571
  }>;
469
572
  activity: z.ZodString;
573
+ at: z.ZodOptional<z.ZodString>;
470
574
  delegationCount: z.ZodOptional<z.ZodNumber>;
471
575
  reason: z.ZodOptional<z.ZodString>;
472
576
  error: z.ZodOptional<z.ZodString>;
@@ -505,6 +609,40 @@ export declare const CompactionPartSchema: z.ZodObject<{
505
609
  "mid-turn": "mid-turn";
506
610
  }>>;
507
611
  }, z.core.$strip>;
612
+ export declare const SubAgentActivityEntrySchema: z.ZodObject<{
613
+ agentId: z.ZodString;
614
+ callPath: z.ZodArray<z.ZodString>;
615
+ tool: z.ZodString;
616
+ label: z.ZodOptional<z.ZodString>;
617
+ startedAt: z.ZodString;
618
+ endedAt: z.ZodOptional<z.ZodString>;
619
+ outcome: z.ZodOptional<z.ZodEnum<{
620
+ error: "error";
621
+ ok: "ok";
622
+ denied: "denied";
623
+ incomplete: "incomplete";
624
+ }>>;
625
+ }, z.core.$strip>;
626
+ export declare const SubAgentActivityPartSchema: z.ZodObject<{
627
+ type: z.ZodLiteral<"data-subagent-activity">;
628
+ id: z.ZodString;
629
+ toolCallId: z.ZodString;
630
+ entries: z.ZodArray<z.ZodObject<{
631
+ agentId: z.ZodString;
632
+ callPath: z.ZodArray<z.ZodString>;
633
+ tool: z.ZodString;
634
+ label: z.ZodOptional<z.ZodString>;
635
+ startedAt: z.ZodString;
636
+ endedAt: z.ZodOptional<z.ZodString>;
637
+ outcome: z.ZodOptional<z.ZodEnum<{
638
+ error: "error";
639
+ ok: "ok";
640
+ denied: "denied";
641
+ incomplete: "incomplete";
642
+ }>>;
643
+ }, z.core.$strip>>;
644
+ dropped: z.ZodNumber;
645
+ }, z.core.$strip>;
508
646
  export declare const ChatPartSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
509
647
  type: z.ZodLiteral<"data-presentation">;
510
648
  id: z.ZodString;
@@ -543,6 +681,7 @@ export declare const ChatPartSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
543
681
  type: z.ZodLiteral<"data-plan">;
544
682
  id: z.ZodString;
545
683
  planId: z.ZodString;
684
+ parentPlanId: z.ZodOptional<z.ZodString>;
546
685
  title: z.ZodOptional<z.ZodString>;
547
686
  steps: z.ZodOptional<z.ZodArray<z.ZodObject<{
548
687
  id: z.ZodString;
@@ -557,6 +696,19 @@ export declare const ChatPartSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
557
696
  count: z.ZodNumber;
558
697
  }, z.core.$strip>>;
559
698
  }, z.core.$strip>>;
699
+ grounding: z.ZodOptional<z.ZodObject<{
700
+ status: z.ZodString;
701
+ snapshot: z.ZodString;
702
+ claims: z.ZodArray<z.ZodString>;
703
+ template: z.ZodOptional<z.ZodString>;
704
+ settings: z.ZodOptional<z.ZodArray<z.ZodObject<{
705
+ step: z.ZodString;
706
+ name: z.ZodString;
707
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString>]>;
708
+ source: z.ZodOptional<z.ZodString>;
709
+ }, z.core.$strip>>>;
710
+ reason: z.ZodString;
711
+ }, z.core.$strip>>;
560
712
  maxSteps: z.ZodNumber;
561
713
  track: z.ZodOptional<z.ZodString>;
562
714
  step_type: z.ZodOptional<z.ZodString>;
@@ -574,6 +726,11 @@ export declare const ChatPartSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
574
726
  planId: z.ZodString;
575
727
  title: z.ZodString;
576
728
  stepCount: z.ZodNumber;
729
+ }, z.core.$strip>, z.ZodObject<{
730
+ type: z.ZodLiteral<"data-plan-approval">;
731
+ planId: z.ZodString;
732
+ runId: z.ZodString;
733
+ approvedAt: z.ZodISODateTime;
577
734
  }, z.core.$strip>, z.ZodObject<{
578
735
  type: z.ZodLiteral<"data-file-reference">;
579
736
  id: z.ZodString;
@@ -596,6 +753,11 @@ export declare const ChatPartSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
596
753
  rejected: "rejected";
597
754
  expired: "expired";
598
755
  }>;
756
+ reply: z.ZodOptional<z.ZodEnum<{
757
+ once: "once";
758
+ always: "always";
759
+ reject: "reject";
760
+ }>>;
599
761
  }, z.core.$strip>, z.ZodObject<{
600
762
  type: z.ZodLiteral<"data-run-started">;
601
763
  runId: z.ZodString;
@@ -642,6 +804,56 @@ export declare const ChatPartSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
642
804
  warning: "warning";
643
805
  }>;
644
806
  activity: z.ZodString;
807
+ at: z.ZodOptional<z.ZodString>;
808
+ }, z.core.$strip>, z.ZodObject<{
809
+ type: z.ZodLiteral<"data-activity-entry">;
810
+ id: z.ZodString;
811
+ runId: z.ZodString;
812
+ stepId: z.ZodString;
813
+ phase: z.ZodUnion<readonly [z.ZodEnum<{
814
+ failed: "failed";
815
+ complete: "complete";
816
+ "sandbox-init": "sandbox-init";
817
+ executing: "executing";
818
+ "generating-metadata": "generating-metadata";
819
+ "generating-summary": "generating-summary";
820
+ indexing: "indexing";
821
+ persisting: "persisting";
822
+ retrying: "retrying";
823
+ warning: "warning";
824
+ }>, z.ZodEnum<{
825
+ failed: "failed";
826
+ skipped: "skipped";
827
+ complete: "complete";
828
+ indexing: "indexing";
829
+ persisting: "persisting";
830
+ starting: "starting";
831
+ researching: "researching";
832
+ drafting: "drafting";
833
+ validating: "validating";
834
+ refining: "refining";
835
+ }>]>;
836
+ activity: z.ZodString;
837
+ at: z.ZodString;
838
+ }, z.core.$strip>, z.ZodObject<{
839
+ type: z.ZodLiteral<"data-subagent-activity">;
840
+ id: z.ZodString;
841
+ toolCallId: z.ZodString;
842
+ entries: z.ZodArray<z.ZodObject<{
843
+ agentId: z.ZodString;
844
+ callPath: z.ZodArray<z.ZodString>;
845
+ tool: z.ZodString;
846
+ label: z.ZodOptional<z.ZodString>;
847
+ startedAt: z.ZodString;
848
+ endedAt: z.ZodOptional<z.ZodString>;
849
+ outcome: z.ZodOptional<z.ZodEnum<{
850
+ error: "error";
851
+ ok: "ok";
852
+ denied: "denied";
853
+ incomplete: "incomplete";
854
+ }>>;
855
+ }, z.core.$strip>>;
856
+ dropped: z.ZodNumber;
645
857
  }, z.core.$strip>, z.ZodObject<{
646
858
  type: z.ZodLiteral<"data-step-file-tree">;
647
859
  id: z.ZodString;
@@ -722,13 +934,24 @@ export declare const ChatPartSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
722
934
  high: "high";
723
935
  }>;
724
936
  noveltyStatus: z.ZodEnum<{
725
- expected: "expected";
726
937
  novel: "novel";
727
938
  confirmed: "confirmed";
728
939
  partially_confirmed: "partially_confirmed";
729
940
  contradicted: "contradicted";
941
+ expected: "expected";
730
942
  }>;
731
943
  literatureInterpretation: z.ZodString;
944
+ references: z.ZodArray<z.ZodObject<{
945
+ pmid: z.ZodString;
946
+ citation: z.ZodString;
947
+ relevance: z.ZodString;
948
+ concordance: z.ZodEnum<{
949
+ supports: "supports";
950
+ contradicts: "contradicts";
951
+ extends: "extends";
952
+ contextualizes: "contextualizes";
953
+ }>;
954
+ }, z.core.$strip>>;
732
955
  }, z.core.$strip>>;
733
956
  themes: z.ZodArray<z.ZodObject<{
734
957
  name: z.ZodString;
@@ -761,6 +984,7 @@ export declare const ChatPartSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
761
984
  refining: "refining";
762
985
  }>;
763
986
  activity: z.ZodString;
987
+ at: z.ZodOptional<z.ZodString>;
764
988
  delegationCount: z.ZodOptional<z.ZodNumber>;
765
989
  reason: z.ZodOptional<z.ZodString>;
766
990
  error: z.ZodOptional<z.ZodString>;
@@ -2,6 +2,7 @@
2
2
  * Zod schemas for chat data parts — validation at boundaries.
3
3
  */
4
4
  import { z } from "zod";
5
+ import { ToolCallOutcomeSchema } from "./chat-events.js";
5
6
  import { TokenUsageRollupSchema } from "./usage.js";
6
7
  // ── Presentation ────────────────────────────────────────────────────
7
8
  export const PlanStepSchema = z.object({
@@ -11,6 +12,23 @@ export const PlanStepSchema = z.object({
11
12
  question: z.string(),
12
13
  depends_on: z.array(z.string()),
13
14
  resources: z.object({ cpu: z.number(), memoryGb: z.number(), gpu: z.object({ count: z.number() }).optional() }).optional(),
15
+ grounding: z
16
+ .object({
17
+ status: z.string(),
18
+ snapshot: z.string(),
19
+ claims: z.array(z.string()),
20
+ template: z.string().optional(),
21
+ settings: z
22
+ .array(z.object({
23
+ step: z.string(),
24
+ name: z.string(),
25
+ value: z.union([z.string(), z.number(), z.boolean(), z.array(z.string())]),
26
+ source: z.string().optional(),
27
+ }))
28
+ .optional(),
29
+ reason: z.string(),
30
+ })
31
+ .optional(),
14
32
  maxSteps: z.number(),
15
33
  track: z.string().optional(),
16
34
  step_type: z.string().optional(),
@@ -65,6 +83,10 @@ export const PlanPartSchema = z.object({
65
83
  type: z.literal("data-plan"),
66
84
  id: z.string(),
67
85
  planId: z.string().regex(/^pln-[a-f0-9]{8}$/),
86
+ parentPlanId: z
87
+ .string()
88
+ .regex(/^pln-[a-f0-9]{8}$/)
89
+ .optional(),
68
90
  title: z.string().optional(),
69
91
  steps: z.array(PlanStepSchema).optional(),
70
92
  analytical_narrative: z.string().optional(),
@@ -80,6 +102,13 @@ export const RunCardPartSchema = z.object({
80
102
  title: z.string(),
81
103
  stepCount: z.number(),
82
104
  });
105
+ // ── Plan approval ───────────────────────────────────────────────────
106
+ export const PlanApprovalPartSchema = z.object({
107
+ type: z.literal("data-plan-approval"),
108
+ planId: z.string().regex(/^pln-[a-f0-9]{8}$/),
109
+ runId: z.string(),
110
+ approvedAt: z.iso.datetime(),
111
+ });
83
112
  // ── File reference ──────────────────────────────────────────────────
84
113
  export const FileReferenceEntrySchema = z.object({
85
114
  path: z.string().min(1),
@@ -101,6 +130,7 @@ export const AskPartSchema = z.object({
101
130
  command: z.string(),
102
131
  detail: z.string().optional(),
103
132
  status: AskStatusSchema,
133
+ reply: z.enum(["once", "always", "reject"]).optional(),
104
134
  });
105
135
  // ── Run Started ─────────────────────────────────────────────────────
106
136
  export const RunStartedPartSchema = z.object({
@@ -134,6 +164,18 @@ export const DagStatePartSchema = z
134
164
  })
135
165
  .strict();
136
166
  // ── Step Activity ───────────────────────────────────────────────────
167
+ export const SynthesisPhaseSchema = z.enum([
168
+ "starting",
169
+ "researching",
170
+ "drafting",
171
+ "validating",
172
+ "refining",
173
+ "indexing",
174
+ "persisting",
175
+ "complete",
176
+ "skipped",
177
+ "failed",
178
+ ]);
137
179
  export const StepPhaseSchema = z.enum([
138
180
  "sandbox-init",
139
181
  "executing",
@@ -153,6 +195,16 @@ export const StepActivityPartSchema = z.object({
153
195
  stepId: z.string(),
154
196
  phase: StepPhaseSchema,
155
197
  activity: z.string(),
198
+ at: z.string().optional(),
199
+ });
200
+ export const ActivityEntryPartSchema = z.object({
201
+ type: z.literal("data-activity-entry"),
202
+ id: z.string(),
203
+ runId: z.string(),
204
+ stepId: z.string(),
205
+ phase: z.union([StepPhaseSchema, SynthesisPhaseSchema]),
206
+ activity: z.string(),
207
+ at: z.string(),
156
208
  });
157
209
  // ── Step File Tree ──────────────────────────────────────────────────
158
210
  export const FileTreeEntrySchema = z.object({
@@ -230,6 +282,12 @@ export const RunCompletedPartSchema = z.object({
230
282
  usage: TokenUsageRollupSchema.optional(),
231
283
  });
232
284
  // ── Run Synthesis ──────────────────────────────────────────────────
285
+ export const FindingReferenceSchema = z.object({
286
+ pmid: z.string(),
287
+ citation: z.string(),
288
+ relevance: z.string(),
289
+ concordance: z.enum(["supports", "contradicts", "extends", "contextualizes"]),
290
+ });
233
291
  export const SynthesizedFindingSchema = z.object({
234
292
  stepId: z.string(),
235
293
  title: z.string(),
@@ -237,6 +295,7 @@ export const SynthesizedFindingSchema = z.object({
237
295
  confidence: z.enum(["high", "medium", "low"]),
238
296
  noveltyStatus: z.enum(["novel", "confirmed", "partially_confirmed", "contradicted", "expected"]),
239
297
  literatureInterpretation: z.string(),
298
+ references: z.array(FindingReferenceSchema),
240
299
  });
241
300
  export const BiologicalThemeSchema = z.object({
242
301
  name: z.string(),
@@ -259,24 +318,13 @@ export const RunSynthesisPartSchema = z.object({
259
318
  })),
260
319
  });
261
320
  // ── Synthesis Progress ─────────────────────────────────────────────
262
- export const SynthesisPhaseSchema = z.enum([
263
- "starting",
264
- "researching",
265
- "drafting",
266
- "validating",
267
- "refining",
268
- "indexing",
269
- "persisting",
270
- "complete",
271
- "skipped",
272
- "failed",
273
- ]);
274
321
  export const SynthesisProgressPartSchema = z.object({
275
322
  type: z.literal("data-synthesis-progress"),
276
323
  id: z.string(),
277
324
  runId: z.string(),
278
325
  phase: SynthesisPhaseSchema,
279
326
  activity: z.string(),
327
+ at: z.string().optional(),
280
328
  delegationCount: z.number().int().nonnegative().optional(),
281
329
  reason: z.string().optional(),
282
330
  error: z.string().optional(),
@@ -314,16 +362,36 @@ export const CompactionPartSchema = z.object({
314
362
  durationMs: z.number().int().nonnegative().optional(),
315
363
  trigger: z.enum(["turn-start", "mid-turn"]).optional(),
316
364
  });
365
+ // ── Sub-agent activity ──────────────────────────────────────────────
366
+ export const SubAgentActivityEntrySchema = z.object({
367
+ agentId: z.string(),
368
+ callPath: z.array(z.string()),
369
+ tool: z.string(),
370
+ label: z.string().optional(),
371
+ startedAt: z.string(),
372
+ endedAt: z.string().optional(),
373
+ outcome: ToolCallOutcomeSchema.optional(),
374
+ });
375
+ export const SubAgentActivityPartSchema = z.object({
376
+ type: z.literal("data-subagent-activity"),
377
+ id: z.string(),
378
+ toolCallId: z.string(),
379
+ entries: z.array(SubAgentActivityEntrySchema),
380
+ dropped: z.number().int().nonnegative(),
381
+ });
317
382
  // ── Union ───────────────────────────────────────────────────────────
318
383
  export const ChatPartSchema = z.discriminatedUnion("type", [
319
384
  PresentationPartSchema,
320
385
  PlanPartSchema,
321
386
  RunCardPartSchema,
387
+ PlanApprovalPartSchema,
322
388
  FileReferencePartSchema,
323
389
  AskPartSchema,
324
390
  RunStartedPartSchema,
325
391
  DagStatePartSchema,
326
392
  StepActivityPartSchema,
393
+ ActivityEntryPartSchema,
394
+ SubAgentActivityPartSchema,
327
395
  StepFileTreePartSchema,
328
396
  StepOutputPartSchema,
329
397
  StepSummaryPartSchema,
@@ -1,3 +1,3 @@
1
- export { PlanStepSchema, PresentationContentSchema, PresentationPartSchema, PlanPartSchema, RunCardPartSchema, FileReferenceEntrySchema, FileReferencePartSchema, RunStartedPartSchema, StepStatusSchema, DagStepStateSchema, DagStatePartSchema, StepPhaseSchema, StepActivityPartSchema, FileTreeEntrySchema, StepFileTreePartSchema, StepOutputFileSchema, StepOutputPartSchema, StepSummaryPartSchema, StepUsagePartSchema, StepBlockedPartSchema, SynthesizedFindingSchema, BiologicalThemeSchema, RunSynthesisPartSchema, SynthesisPhaseSchema, SynthesisProgressPartSchema, RunCompletedFindingSchema, RunCompletedPartSchema, RunFailedPartSchema, ChatPartSchema, } from "./chat-parts.js";
2
- export { EventSourceSchema, TextDeltaEventSchema, IterationEventSchema, ToolStartedEventSchema, ToolFinishedEventSchema, FinishEventSchema, ChatErrorEventSchema, ChatEventSchema, } from "./chat-events.js";
1
+ export { PlanStepSchema, PresentationContentSchema, PresentationPartSchema, PlanPartSchema, RunCardPartSchema, PlanApprovalPartSchema, FileReferenceEntrySchema, FileReferencePartSchema, RunStartedPartSchema, StepStatusSchema, DagStepStateSchema, DagStatePartSchema, StepPhaseSchema, StepActivityPartSchema, ActivityEntryPartSchema, SubAgentActivityEntrySchema, SubAgentActivityPartSchema, FileTreeEntrySchema, StepFileTreePartSchema, StepOutputFileSchema, StepOutputPartSchema, StepSummaryPartSchema, StepUsagePartSchema, StepBlockedPartSchema, FindingReferenceSchema, SynthesizedFindingSchema, BiologicalThemeSchema, RunSynthesisPartSchema, SynthesisPhaseSchema, SynthesisProgressPartSchema, RunCompletedFindingSchema, RunCompletedPartSchema, RunFailedPartSchema, ChatPartSchema, } from "./chat-parts.js";
2
+ export { EventSourceSchema, TextDeltaEventSchema, IterationEventSchema, ToolStartedEventSchema, ToolFinishedEventSchema, FinishEventSchema, ChatErrorEventSchema, MessageStartEventSchema, ChatEventSchema, } from "./chat-events.js";
3
3
  export { TokenUsageRollupSchema } from "./usage.js";
@@ -1,3 +1,3 @@
1
- export { PlanStepSchema, PresentationContentSchema, PresentationPartSchema, PlanPartSchema, RunCardPartSchema, FileReferenceEntrySchema, FileReferencePartSchema, RunStartedPartSchema, StepStatusSchema, DagStepStateSchema, DagStatePartSchema, StepPhaseSchema, StepActivityPartSchema, FileTreeEntrySchema, StepFileTreePartSchema, StepOutputFileSchema, StepOutputPartSchema, StepSummaryPartSchema, StepUsagePartSchema, StepBlockedPartSchema, SynthesizedFindingSchema, BiologicalThemeSchema, RunSynthesisPartSchema, SynthesisPhaseSchema, SynthesisProgressPartSchema, RunCompletedFindingSchema, RunCompletedPartSchema, RunFailedPartSchema, ChatPartSchema, } from "./chat-parts.js";
2
- export { EventSourceSchema, TextDeltaEventSchema, IterationEventSchema, ToolStartedEventSchema, ToolFinishedEventSchema, FinishEventSchema, ChatErrorEventSchema, ChatEventSchema, } from "./chat-events.js";
1
+ export { PlanStepSchema, PresentationContentSchema, PresentationPartSchema, PlanPartSchema, RunCardPartSchema, PlanApprovalPartSchema, FileReferenceEntrySchema, FileReferencePartSchema, RunStartedPartSchema, StepStatusSchema, DagStepStateSchema, DagStatePartSchema, StepPhaseSchema, StepActivityPartSchema, ActivityEntryPartSchema, SubAgentActivityEntrySchema, SubAgentActivityPartSchema, FileTreeEntrySchema, StepFileTreePartSchema, StepOutputFileSchema, StepOutputPartSchema, StepSummaryPartSchema, StepUsagePartSchema, StepBlockedPartSchema, FindingReferenceSchema, SynthesizedFindingSchema, BiologicalThemeSchema, RunSynthesisPartSchema, SynthesisPhaseSchema, SynthesisProgressPartSchema, RunCompletedFindingSchema, RunCompletedPartSchema, RunFailedPartSchema, ChatPartSchema, } from "./chat-parts.js";
2
+ export { EventSourceSchema, TextDeltaEventSchema, IterationEventSchema, ToolStartedEventSchema, ToolFinishedEventSchema, FinishEventSchema, ChatErrorEventSchema, MessageStartEventSchema, ChatEventSchema, } from "./chat-events.js";
3
3
  export { TokenUsageRollupSchema } from "./usage.js";
@@ -0,0 +1,12 @@
1
+ import type { ChatFrame, ChatPartFrame } from "./chat-events.js";
2
+ /** The most entries that one root tool call holds. Each later call of its sub-agents only adds to `dropped`. */
3
+ export declare const SUBAGENT_ACTIVITY_MAX_ENTRIES = 200;
4
+ export interface SubAgentActivityTracker {
5
+ /**
6
+ * Read one frame of the turn, from the root agent or from a sub-agent, with the time of its receipt in
7
+ * milliseconds. Gives the new `data-subagent-activity` part frame (no source) when the frame changes the activity
8
+ * of a root tool call, else `null`.
9
+ */
10
+ track(frame: ChatFrame, nowMs: number): ChatPartFrame | null;
11
+ }
12
+ export declare function createSubAgentActivityTracker(): SubAgentActivityTracker;