@kontourai/flow-agents 3.12.0 → 4.0.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 (1029) hide show
  1. package/.github/workflows/ci.yml +76 -0
  2. package/CHANGELOG.md +48 -0
  3. package/build/generated/capability-declarations.json +177 -0
  4. package/build/src/builder-flow-runtime.d.ts +37 -0
  5. package/build/src/builder-flow-runtime.js +71 -1
  6. package/build/src/builder-gate-action-envelope.d.ts +59 -7
  7. package/build/src/builder-gate-action-envelope.js +163 -30
  8. package/build/src/builder-lifecycle-authority.d.ts +26 -0
  9. package/build/src/builder-lifecycle-authority.js +38 -0
  10. package/build/src/cli/builder-run.js +71 -2
  11. package/build/src/cli/narrative-render.d.ts +95 -0
  12. package/build/src/cli/narrative-render.js +466 -0
  13. package/build/src/cli/narrative-sources.d.ts +2 -0
  14. package/build/src/cli/narrative-sources.js +282 -0
  15. package/build/src/cli/public-contracts.d.ts +257 -0
  16. package/build/src/cli/public-contracts.js +87 -0
  17. package/build/src/cli/workflow-sidecar.d.ts +28 -12
  18. package/build/src/cli/workflow-sidecar.js +599 -180
  19. package/build/src/cli/workflow.js +11 -1
  20. package/build/src/cli.js +8 -0
  21. package/build/src/continuation-driver.d.ts +12 -0
  22. package/build/src/continuation-driver.js +16 -2
  23. package/build/src/continuation-validation.js +349 -3
  24. package/build/src/flow-kit/action-metadata.js +21 -1
  25. package/build/src/index.d.ts +33 -2
  26. package/build/src/index.js +24 -0
  27. package/build/src/lib/capability-declarations.d.ts +83 -0
  28. package/build/src/lib/capability-declarations.js +209 -0
  29. package/build/src/narrative/envelope.d.ts +111 -0
  30. package/build/src/narrative/envelope.js +590 -0
  31. package/build/src/narrative/eval-result.d.ts +60 -0
  32. package/build/src/narrative/eval-result.js +158 -0
  33. package/build/src/narrative/grounding-validator.d.ts +104 -0
  34. package/build/src/narrative/grounding-validator.js +472 -0
  35. package/build/src/narrative/integrity.d.ts +17 -0
  36. package/build/src/narrative/integrity.js +39 -0
  37. package/build/src/narrative/intent-economics.d.ts +42 -0
  38. package/build/src/narrative/intent-economics.js +82 -0
  39. package/build/src/narrative/intent.d.ts +94 -0
  40. package/build/src/narrative/intent.js +132 -0
  41. package/build/src/narrative/policy-filter.d.ts +15 -0
  42. package/build/src/narrative/policy-filter.js +58 -0
  43. package/build/src/narrative/projection.d.ts +58 -0
  44. package/build/src/narrative/projection.js +502 -0
  45. package/build/src/narrative/readers.d.ts +84 -0
  46. package/build/src/narrative/readers.js +406 -0
  47. package/build/src/narrative/render.d.ts +3 -0
  48. package/build/src/narrative/render.js +83 -0
  49. package/build/src/narrative/resolver.d.ts +52 -0
  50. package/build/src/narrative/resolver.js +190 -0
  51. package/build/src/narrative/snapshot.d.ts +90 -0
  52. package/build/src/narrative/snapshot.js +325 -0
  53. package/build/src/narrative/source-ids.d.ts +121 -0
  54. package/build/src/narrative/source-ids.js +201 -0
  55. package/build/src/narrative/statements.d.ts +84 -0
  56. package/build/src/narrative/statements.js +347 -0
  57. package/build/src/narrative/turn-spine.d.ts +19 -0
  58. package/build/src/narrative/turn-spine.js +73 -0
  59. package/build/src/tools/build-universal-bundles.js +8 -0
  60. package/build/src/tools/generate-capability-matrix.d.ts +7 -0
  61. package/build/src/tools/generate-capability-matrix.js +207 -0
  62. package/build/src/tools/validate-source-tree.js +5 -1
  63. package/context/scripts/hooks/stop-goal-fit.js +182 -9
  64. package/context/scripts/hooks/workflow-steering.js +160 -19
  65. package/context/scripts/telemetry/lib/session.sh +3 -0
  66. package/context/scripts/telemetry/lib/transport.sh +12 -3
  67. package/context/scripts/telemetry/telemetry.sh +480 -59
  68. package/dist/base/build/generated/capability-declarations.json +177 -0
  69. package/dist/base/build/package.json +1 -1
  70. package/dist/base/build/src/builder-flow-runtime.d.ts +37 -0
  71. package/dist/base/build/src/builder-flow-runtime.js +71 -1
  72. package/dist/base/build/src/builder-gate-action-envelope.d.ts +59 -7
  73. package/dist/base/build/src/builder-gate-action-envelope.js +163 -30
  74. package/dist/base/build/src/builder-lifecycle-authority.d.ts +26 -0
  75. package/dist/base/build/src/builder-lifecycle-authority.js +38 -0
  76. package/dist/base/build/src/cli/builder-run.js +71 -2
  77. package/dist/base/build/src/cli/narrative-render.d.ts +95 -0
  78. package/dist/base/build/src/cli/narrative-render.js +466 -0
  79. package/dist/base/build/src/cli/narrative-sources.d.ts +2 -0
  80. package/dist/base/build/src/cli/narrative-sources.js +282 -0
  81. package/dist/base/build/src/cli/public-contracts.d.ts +257 -0
  82. package/dist/base/build/src/cli/public-contracts.js +87 -0
  83. package/dist/base/build/src/cli/workflow-sidecar.d.ts +28 -12
  84. package/dist/base/build/src/cli/workflow-sidecar.js +599 -180
  85. package/dist/base/build/src/cli/workflow.js +11 -1
  86. package/dist/base/build/src/cli.js +8 -0
  87. package/dist/base/build/src/continuation-driver.d.ts +12 -0
  88. package/dist/base/build/src/continuation-driver.js +16 -2
  89. package/dist/base/build/src/continuation-validation.js +349 -3
  90. package/dist/base/build/src/flow-kit/action-metadata.js +21 -1
  91. package/dist/base/build/src/index.d.ts +33 -2
  92. package/dist/base/build/src/index.js +24 -0
  93. package/dist/base/build/src/lib/capability-declarations.d.ts +83 -0
  94. package/dist/base/build/src/lib/capability-declarations.js +209 -0
  95. package/dist/base/build/src/narrative/envelope.d.ts +111 -0
  96. package/dist/base/build/src/narrative/envelope.js +590 -0
  97. package/dist/base/build/src/narrative/eval-result.d.ts +60 -0
  98. package/dist/base/build/src/narrative/eval-result.js +158 -0
  99. package/dist/base/build/src/narrative/grounding-validator.d.ts +104 -0
  100. package/dist/base/build/src/narrative/grounding-validator.js +472 -0
  101. package/dist/base/build/src/narrative/integrity.d.ts +17 -0
  102. package/dist/base/build/src/narrative/integrity.js +39 -0
  103. package/dist/base/build/src/narrative/intent-economics.d.ts +42 -0
  104. package/dist/base/build/src/narrative/intent-economics.js +82 -0
  105. package/dist/base/build/src/narrative/intent.d.ts +94 -0
  106. package/dist/base/build/src/narrative/intent.js +132 -0
  107. package/dist/base/build/src/narrative/policy-filter.d.ts +15 -0
  108. package/dist/base/build/src/narrative/policy-filter.js +58 -0
  109. package/dist/base/build/src/narrative/projection.d.ts +58 -0
  110. package/dist/base/build/src/narrative/projection.js +502 -0
  111. package/dist/base/build/src/narrative/readers.d.ts +84 -0
  112. package/dist/base/build/src/narrative/readers.js +406 -0
  113. package/dist/base/build/src/narrative/render.d.ts +3 -0
  114. package/dist/base/build/src/narrative/render.js +83 -0
  115. package/dist/base/build/src/narrative/resolver.d.ts +52 -0
  116. package/dist/base/build/src/narrative/resolver.js +190 -0
  117. package/dist/base/build/src/narrative/snapshot.d.ts +90 -0
  118. package/dist/base/build/src/narrative/snapshot.js +325 -0
  119. package/dist/base/build/src/narrative/source-ids.d.ts +121 -0
  120. package/dist/base/build/src/narrative/source-ids.js +201 -0
  121. package/dist/base/build/src/narrative/statements.d.ts +84 -0
  122. package/dist/base/build/src/narrative/statements.js +347 -0
  123. package/dist/base/build/src/narrative/turn-spine.d.ts +19 -0
  124. package/dist/base/build/src/narrative/turn-spine.js +73 -0
  125. package/dist/base/build/src/tools/build-universal-bundles.js +8 -0
  126. package/dist/base/build/src/tools/generate-capability-matrix.d.ts +7 -0
  127. package/dist/base/build/src/tools/generate-capability-matrix.js +207 -0
  128. package/dist/base/build/src/tools/validate-source-tree.js +5 -1
  129. package/dist/base/context/scripts/hooks/stop-goal-fit.js +182 -9
  130. package/dist/base/context/scripts/hooks/workflow-steering.js +160 -19
  131. package/dist/base/context/scripts/telemetry/lib/session.sh +3 -0
  132. package/dist/base/context/scripts/telemetry/lib/transport.sh +12 -3
  133. package/dist/base/context/scripts/telemetry/telemetry.sh +480 -59
  134. package/dist/base/docs/context-map.md +4 -0
  135. package/dist/base/docs/decisions/index.md +1 -0
  136. package/dist/base/docs/decisions/writer-observed-execution.md +51 -0
  137. package/dist/base/docs/fixture-ownership.md +5 -1
  138. package/dist/base/docs/migrations.md +20 -0
  139. package/dist/base/docs/public-workflow-cli.md +9 -0
  140. package/dist/base/docs/spec/builder-flow-runtime.md +49 -8
  141. package/dist/base/docs/spec/runtime-hook-surface.md +29 -1
  142. package/dist/base/docs/specs/economics-record-contract.md +1 -1
  143. package/dist/base/docs/specs/harness-capability-matrix.md +63 -21
  144. package/dist/base/docs/workflow-usage-guide.md +4 -1
  145. package/dist/base/evals/ci/run-baseline.sh +38 -0
  146. package/dist/base/evals/fixtures/narrative-evals/README.md +62 -0
  147. package/dist/base/evals/fixtures/narrative-evals/corpus.json +129 -0
  148. package/dist/base/evals/fixtures/narrative-evals/scorer.mjs +522 -0
  149. package/dist/base/evals/fixtures/narrative-grounding-validator/corpus.json +20 -0
  150. package/dist/base/evals/fixtures/narrative-grounding-validator/prompt-injection-adversarial.txt +1 -0
  151. package/dist/base/evals/fixtures/narrative-grounding-validator/prompt-injection-control.txt +1 -0
  152. package/dist/base/evals/fixtures/narrative-grounding-validator/scorer.mjs +201 -0
  153. package/dist/base/evals/fixtures/narrative-prose-renderer/corpus.json +15 -0
  154. package/dist/base/evals/fixtures/narrative-prose-renderer/scorer.mjs +201 -0
  155. package/dist/base/evals/fixtures/narrative-sources/expected-capture-completeness.json +13 -0
  156. package/dist/base/evals/fixtures/narrative-sources/flow/runs/run-fixture/report.json +1 -0
  157. package/dist/base/evals/fixtures/narrative-sources/flow/runs/run-fixture/state.json +1 -0
  158. package/dist/base/evals/fixtures/narrative-sources/flow/runs/run-runtime/state.json +1 -0
  159. package/dist/base/evals/fixtures/narrative-sources/repo/created.txt +1 -0
  160. package/dist/base/evals/fixtures/narrative-sources/repo/fixture.txt +1 -0
  161. package/dist/base/evals/fixtures/narrative-sources/session/agents/agent-fixture/events.jsonl +2 -0
  162. package/dist/base/evals/fixtures/narrative-sources/session/agents/nested-worker/events.jsonl +1 -0
  163. package/dist/base/evals/fixtures/narrative-sources/session/trust.bundle +1 -0
  164. package/dist/base/evals/fixtures/narrative-sources/telemetry/full.jsonl +3 -0
  165. package/dist/base/evals/fixtures/narrative-sources/telemetry/runtime.jsonl +4 -0
  166. package/dist/base/evals/fixtures/narrative-sources/transcripts/session.txt +1 -0
  167. package/dist/base/evals/integration/test_capability_declarations.sh +183 -0
  168. package/dist/base/evals/integration/test_economics_record.sh +42 -0
  169. package/dist/base/evals/integration/test_fixture_retirement_audit.sh +2 -2
  170. package/dist/base/evals/integration/test_gate_review_inquiry_records.sh +42 -35
  171. package/dist/base/evals/integration/test_goal_fit_hook.sh +13 -5
  172. package/dist/base/evals/integration/test_goal_fit_narrative_exclusion.sh +68 -0
  173. package/dist/base/evals/integration/test_narrative_evals.sh +174 -0
  174. package/dist/base/evals/integration/test_narrative_grounded_envelope.sh +280 -0
  175. package/dist/base/evals/integration/test_narrative_grounding_validator.sh +166 -0
  176. package/dist/base/evals/integration/test_narrative_intent_annotation.sh +205 -0
  177. package/dist/base/evals/integration/test_narrative_prose_renderer.sh +239 -0
  178. package/dist/base/evals/integration/test_narrative_redaction_failclosed.sh +120 -0
  179. package/dist/base/evals/integration/test_narrative_runtime_projection.sh +146 -0
  180. package/dist/base/evals/integration/test_narrative_source_contract.sh +228 -0
  181. package/dist/base/evals/integration/test_narrative_trust_isolation.sh +408 -0
  182. package/dist/base/evals/integration/test_plain_stop_messaging.sh +91 -0
  183. package/dist/base/evals/integration/test_session_resume_roundtrip.sh +228 -0
  184. package/dist/base/evals/integration/test_telemetry_action_class.sh +265 -0
  185. package/dist/base/evals/integration/test_telemetry_delegation.sh +291 -0
  186. package/dist/base/evals/integration/test_telemetry_sanitize_usage.sh +155 -0
  187. package/dist/base/evals/integration/test_telemetry_task_slug.sh +158 -0
  188. package/dist/base/evals/integration/test_telemetry_tool_outcome.sh +279 -0
  189. package/dist/base/evals/integration/test_workflow_sidecar_writer.sh +111 -2
  190. package/dist/base/evals/run.sh +12 -0
  191. package/dist/base/evals/static/test_library_exports.sh +5 -0
  192. package/dist/base/install.sh +1 -1
  193. package/dist/base/schemas/grounded-execution-narrative.schema.json +292 -0
  194. package/dist/base/schemas/narrative-eval-result.schema.json +205 -0
  195. package/dist/base/schemas/narrative-runtime-projection.schema.json +134 -0
  196. package/dist/base/schemas/narrative-source-manifest.schema.json +294 -0
  197. package/dist/base/scripts/check-hachure-boundary.mjs +81 -0
  198. package/dist/base/scripts/hooks/stop-goal-fit.js +182 -9
  199. package/dist/base/scripts/hooks/workflow-steering.js +160 -19
  200. package/dist/base/scripts/telemetry/economics-record.schema.json +1 -1
  201. package/dist/base/scripts/telemetry/economics-record.sh +47 -3
  202. package/dist/base/scripts/telemetry/lib/session.sh +3 -0
  203. package/dist/base/scripts/telemetry/lib/transport.sh +12 -3
  204. package/dist/base/scripts/telemetry/telemetry.sh +480 -59
  205. package/dist/claude-code/build/generated/capability-declarations.json +177 -0
  206. package/dist/claude-code/build/package.json +1 -1
  207. package/dist/claude-code/build/src/builder-flow-runtime.d.ts +37 -0
  208. package/dist/claude-code/build/src/builder-flow-runtime.js +71 -1
  209. package/dist/claude-code/build/src/builder-gate-action-envelope.d.ts +59 -7
  210. package/dist/claude-code/build/src/builder-gate-action-envelope.js +163 -30
  211. package/dist/claude-code/build/src/builder-lifecycle-authority.d.ts +26 -0
  212. package/dist/claude-code/build/src/builder-lifecycle-authority.js +38 -0
  213. package/dist/claude-code/build/src/cli/builder-run.js +71 -2
  214. package/dist/claude-code/build/src/cli/narrative-render.d.ts +95 -0
  215. package/dist/claude-code/build/src/cli/narrative-render.js +466 -0
  216. package/dist/claude-code/build/src/cli/narrative-sources.d.ts +2 -0
  217. package/dist/claude-code/build/src/cli/narrative-sources.js +282 -0
  218. package/dist/claude-code/build/src/cli/public-contracts.d.ts +257 -0
  219. package/dist/claude-code/build/src/cli/public-contracts.js +87 -0
  220. package/dist/claude-code/build/src/cli/workflow-sidecar.d.ts +28 -12
  221. package/dist/claude-code/build/src/cli/workflow-sidecar.js +599 -180
  222. package/dist/claude-code/build/src/cli/workflow.js +11 -1
  223. package/dist/claude-code/build/src/cli.js +8 -0
  224. package/dist/claude-code/build/src/continuation-driver.d.ts +12 -0
  225. package/dist/claude-code/build/src/continuation-driver.js +16 -2
  226. package/dist/claude-code/build/src/continuation-validation.js +349 -3
  227. package/dist/claude-code/build/src/flow-kit/action-metadata.js +21 -1
  228. package/dist/claude-code/build/src/index.d.ts +33 -2
  229. package/dist/claude-code/build/src/index.js +24 -0
  230. package/dist/claude-code/build/src/lib/capability-declarations.d.ts +83 -0
  231. package/dist/claude-code/build/src/lib/capability-declarations.js +209 -0
  232. package/dist/claude-code/build/src/narrative/envelope.d.ts +111 -0
  233. package/dist/claude-code/build/src/narrative/envelope.js +590 -0
  234. package/dist/claude-code/build/src/narrative/eval-result.d.ts +60 -0
  235. package/dist/claude-code/build/src/narrative/eval-result.js +158 -0
  236. package/dist/claude-code/build/src/narrative/grounding-validator.d.ts +104 -0
  237. package/dist/claude-code/build/src/narrative/grounding-validator.js +472 -0
  238. package/dist/claude-code/build/src/narrative/integrity.d.ts +17 -0
  239. package/dist/claude-code/build/src/narrative/integrity.js +39 -0
  240. package/dist/claude-code/build/src/narrative/intent-economics.d.ts +42 -0
  241. package/dist/claude-code/build/src/narrative/intent-economics.js +82 -0
  242. package/dist/claude-code/build/src/narrative/intent.d.ts +94 -0
  243. package/dist/claude-code/build/src/narrative/intent.js +132 -0
  244. package/dist/claude-code/build/src/narrative/policy-filter.d.ts +15 -0
  245. package/dist/claude-code/build/src/narrative/policy-filter.js +58 -0
  246. package/dist/claude-code/build/src/narrative/projection.d.ts +58 -0
  247. package/dist/claude-code/build/src/narrative/projection.js +502 -0
  248. package/dist/claude-code/build/src/narrative/readers.d.ts +84 -0
  249. package/dist/claude-code/build/src/narrative/readers.js +406 -0
  250. package/dist/claude-code/build/src/narrative/render.d.ts +3 -0
  251. package/dist/claude-code/build/src/narrative/render.js +83 -0
  252. package/dist/claude-code/build/src/narrative/resolver.d.ts +52 -0
  253. package/dist/claude-code/build/src/narrative/resolver.js +190 -0
  254. package/dist/claude-code/build/src/narrative/snapshot.d.ts +90 -0
  255. package/dist/claude-code/build/src/narrative/snapshot.js +325 -0
  256. package/dist/claude-code/build/src/narrative/source-ids.d.ts +121 -0
  257. package/dist/claude-code/build/src/narrative/source-ids.js +201 -0
  258. package/dist/claude-code/build/src/narrative/statements.d.ts +84 -0
  259. package/dist/claude-code/build/src/narrative/statements.js +347 -0
  260. package/dist/claude-code/build/src/narrative/turn-spine.d.ts +19 -0
  261. package/dist/claude-code/build/src/narrative/turn-spine.js +73 -0
  262. package/dist/claude-code/build/src/tools/build-universal-bundles.js +8 -0
  263. package/dist/claude-code/build/src/tools/generate-capability-matrix.d.ts +7 -0
  264. package/dist/claude-code/build/src/tools/generate-capability-matrix.js +207 -0
  265. package/dist/claude-code/build/src/tools/validate-source-tree.js +5 -1
  266. package/dist/claude-code/context/scripts/hooks/stop-goal-fit.js +182 -9
  267. package/dist/claude-code/context/scripts/hooks/workflow-steering.js +160 -19
  268. package/dist/claude-code/context/scripts/telemetry/lib/session.sh +3 -0
  269. package/dist/claude-code/context/scripts/telemetry/lib/transport.sh +12 -3
  270. package/dist/claude-code/context/scripts/telemetry/telemetry.sh +480 -59
  271. package/dist/claude-code/docs/context-map.md +4 -0
  272. package/dist/claude-code/docs/decisions/index.md +1 -0
  273. package/dist/claude-code/docs/decisions/writer-observed-execution.md +51 -0
  274. package/dist/claude-code/docs/fixture-ownership.md +5 -1
  275. package/dist/claude-code/docs/migrations.md +20 -0
  276. package/dist/claude-code/docs/public-workflow-cli.md +9 -0
  277. package/dist/claude-code/docs/spec/builder-flow-runtime.md +49 -8
  278. package/dist/claude-code/docs/spec/runtime-hook-surface.md +29 -1
  279. package/dist/claude-code/docs/specs/economics-record-contract.md +1 -1
  280. package/dist/claude-code/docs/specs/harness-capability-matrix.md +63 -21
  281. package/dist/claude-code/docs/workflow-usage-guide.md +4 -1
  282. package/dist/claude-code/evals/ci/run-baseline.sh +38 -0
  283. package/dist/claude-code/evals/fixtures/narrative-evals/README.md +62 -0
  284. package/dist/claude-code/evals/fixtures/narrative-evals/corpus.json +129 -0
  285. package/dist/claude-code/evals/fixtures/narrative-evals/scorer.mjs +522 -0
  286. package/dist/claude-code/evals/fixtures/narrative-grounding-validator/corpus.json +20 -0
  287. package/dist/claude-code/evals/fixtures/narrative-grounding-validator/prompt-injection-adversarial.txt +1 -0
  288. package/dist/claude-code/evals/fixtures/narrative-grounding-validator/prompt-injection-control.txt +1 -0
  289. package/dist/claude-code/evals/fixtures/narrative-grounding-validator/scorer.mjs +201 -0
  290. package/dist/claude-code/evals/fixtures/narrative-prose-renderer/corpus.json +15 -0
  291. package/dist/claude-code/evals/fixtures/narrative-prose-renderer/scorer.mjs +201 -0
  292. package/dist/claude-code/evals/fixtures/narrative-sources/expected-capture-completeness.json +13 -0
  293. package/dist/claude-code/evals/fixtures/narrative-sources/flow/runs/run-fixture/report.json +1 -0
  294. package/dist/claude-code/evals/fixtures/narrative-sources/flow/runs/run-fixture/state.json +1 -0
  295. package/dist/claude-code/evals/fixtures/narrative-sources/flow/runs/run-runtime/state.json +1 -0
  296. package/dist/claude-code/evals/fixtures/narrative-sources/repo/created.txt +1 -0
  297. package/dist/claude-code/evals/fixtures/narrative-sources/repo/fixture.txt +1 -0
  298. package/dist/claude-code/evals/fixtures/narrative-sources/session/agents/agent-fixture/events.jsonl +2 -0
  299. package/dist/claude-code/evals/fixtures/narrative-sources/session/agents/nested-worker/events.jsonl +1 -0
  300. package/dist/claude-code/evals/fixtures/narrative-sources/session/trust.bundle +1 -0
  301. package/dist/claude-code/evals/fixtures/narrative-sources/telemetry/full.jsonl +3 -0
  302. package/dist/claude-code/evals/fixtures/narrative-sources/telemetry/runtime.jsonl +4 -0
  303. package/dist/claude-code/evals/fixtures/narrative-sources/transcripts/session.txt +1 -0
  304. package/dist/claude-code/evals/integration/test_capability_declarations.sh +183 -0
  305. package/dist/claude-code/evals/integration/test_economics_record.sh +42 -0
  306. package/dist/claude-code/evals/integration/test_fixture_retirement_audit.sh +2 -2
  307. package/dist/claude-code/evals/integration/test_gate_review_inquiry_records.sh +42 -35
  308. package/dist/claude-code/evals/integration/test_goal_fit_hook.sh +13 -5
  309. package/dist/claude-code/evals/integration/test_goal_fit_narrative_exclusion.sh +68 -0
  310. package/dist/claude-code/evals/integration/test_narrative_evals.sh +174 -0
  311. package/dist/claude-code/evals/integration/test_narrative_grounded_envelope.sh +280 -0
  312. package/dist/claude-code/evals/integration/test_narrative_grounding_validator.sh +166 -0
  313. package/dist/claude-code/evals/integration/test_narrative_intent_annotation.sh +205 -0
  314. package/dist/claude-code/evals/integration/test_narrative_prose_renderer.sh +239 -0
  315. package/dist/claude-code/evals/integration/test_narrative_redaction_failclosed.sh +120 -0
  316. package/dist/claude-code/evals/integration/test_narrative_runtime_projection.sh +146 -0
  317. package/dist/claude-code/evals/integration/test_narrative_source_contract.sh +228 -0
  318. package/dist/claude-code/evals/integration/test_narrative_trust_isolation.sh +408 -0
  319. package/dist/claude-code/evals/integration/test_plain_stop_messaging.sh +91 -0
  320. package/dist/claude-code/evals/integration/test_session_resume_roundtrip.sh +228 -0
  321. package/dist/claude-code/evals/integration/test_telemetry_action_class.sh +265 -0
  322. package/dist/claude-code/evals/integration/test_telemetry_delegation.sh +291 -0
  323. package/dist/claude-code/evals/integration/test_telemetry_sanitize_usage.sh +155 -0
  324. package/dist/claude-code/evals/integration/test_telemetry_task_slug.sh +158 -0
  325. package/dist/claude-code/evals/integration/test_telemetry_tool_outcome.sh +279 -0
  326. package/dist/claude-code/evals/integration/test_workflow_sidecar_writer.sh +111 -2
  327. package/dist/claude-code/evals/run.sh +12 -0
  328. package/dist/claude-code/evals/static/test_library_exports.sh +5 -0
  329. package/dist/claude-code/install.sh +1 -1
  330. package/dist/claude-code/schemas/grounded-execution-narrative.schema.json +292 -0
  331. package/dist/claude-code/schemas/narrative-eval-result.schema.json +205 -0
  332. package/dist/claude-code/schemas/narrative-runtime-projection.schema.json +134 -0
  333. package/dist/claude-code/schemas/narrative-source-manifest.schema.json +294 -0
  334. package/dist/claude-code/scripts/check-hachure-boundary.mjs +81 -0
  335. package/dist/claude-code/scripts/hooks/stop-goal-fit.js +182 -9
  336. package/dist/claude-code/scripts/hooks/workflow-steering.js +160 -19
  337. package/dist/claude-code/scripts/telemetry/economics-record.schema.json +1 -1
  338. package/dist/claude-code/scripts/telemetry/economics-record.sh +47 -3
  339. package/dist/claude-code/scripts/telemetry/lib/session.sh +3 -0
  340. package/dist/claude-code/scripts/telemetry/lib/transport.sh +12 -3
  341. package/dist/claude-code/scripts/telemetry/telemetry.sh +480 -59
  342. package/dist/codex/build/generated/capability-declarations.json +177 -0
  343. package/dist/codex/build/package.json +1 -1
  344. package/dist/codex/build/src/builder-flow-runtime.d.ts +37 -0
  345. package/dist/codex/build/src/builder-flow-runtime.js +71 -1
  346. package/dist/codex/build/src/builder-gate-action-envelope.d.ts +59 -7
  347. package/dist/codex/build/src/builder-gate-action-envelope.js +163 -30
  348. package/dist/codex/build/src/builder-lifecycle-authority.d.ts +26 -0
  349. package/dist/codex/build/src/builder-lifecycle-authority.js +38 -0
  350. package/dist/codex/build/src/cli/builder-run.js +71 -2
  351. package/dist/codex/build/src/cli/narrative-render.d.ts +95 -0
  352. package/dist/codex/build/src/cli/narrative-render.js +466 -0
  353. package/dist/codex/build/src/cli/narrative-sources.d.ts +2 -0
  354. package/dist/codex/build/src/cli/narrative-sources.js +282 -0
  355. package/dist/codex/build/src/cli/public-contracts.d.ts +257 -0
  356. package/dist/codex/build/src/cli/public-contracts.js +87 -0
  357. package/dist/codex/build/src/cli/workflow-sidecar.d.ts +28 -12
  358. package/dist/codex/build/src/cli/workflow-sidecar.js +599 -180
  359. package/dist/codex/build/src/cli/workflow.js +11 -1
  360. package/dist/codex/build/src/cli.js +8 -0
  361. package/dist/codex/build/src/continuation-driver.d.ts +12 -0
  362. package/dist/codex/build/src/continuation-driver.js +16 -2
  363. package/dist/codex/build/src/continuation-validation.js +349 -3
  364. package/dist/codex/build/src/flow-kit/action-metadata.js +21 -1
  365. package/dist/codex/build/src/index.d.ts +33 -2
  366. package/dist/codex/build/src/index.js +24 -0
  367. package/dist/codex/build/src/lib/capability-declarations.d.ts +83 -0
  368. package/dist/codex/build/src/lib/capability-declarations.js +209 -0
  369. package/dist/codex/build/src/narrative/envelope.d.ts +111 -0
  370. package/dist/codex/build/src/narrative/envelope.js +590 -0
  371. package/dist/codex/build/src/narrative/eval-result.d.ts +60 -0
  372. package/dist/codex/build/src/narrative/eval-result.js +158 -0
  373. package/dist/codex/build/src/narrative/grounding-validator.d.ts +104 -0
  374. package/dist/codex/build/src/narrative/grounding-validator.js +472 -0
  375. package/dist/codex/build/src/narrative/integrity.d.ts +17 -0
  376. package/dist/codex/build/src/narrative/integrity.js +39 -0
  377. package/dist/codex/build/src/narrative/intent-economics.d.ts +42 -0
  378. package/dist/codex/build/src/narrative/intent-economics.js +82 -0
  379. package/dist/codex/build/src/narrative/intent.d.ts +94 -0
  380. package/dist/codex/build/src/narrative/intent.js +132 -0
  381. package/dist/codex/build/src/narrative/policy-filter.d.ts +15 -0
  382. package/dist/codex/build/src/narrative/policy-filter.js +58 -0
  383. package/dist/codex/build/src/narrative/projection.d.ts +58 -0
  384. package/dist/codex/build/src/narrative/projection.js +502 -0
  385. package/dist/codex/build/src/narrative/readers.d.ts +84 -0
  386. package/dist/codex/build/src/narrative/readers.js +406 -0
  387. package/dist/codex/build/src/narrative/render.d.ts +3 -0
  388. package/dist/codex/build/src/narrative/render.js +83 -0
  389. package/dist/codex/build/src/narrative/resolver.d.ts +52 -0
  390. package/dist/codex/build/src/narrative/resolver.js +190 -0
  391. package/dist/codex/build/src/narrative/snapshot.d.ts +90 -0
  392. package/dist/codex/build/src/narrative/snapshot.js +325 -0
  393. package/dist/codex/build/src/narrative/source-ids.d.ts +121 -0
  394. package/dist/codex/build/src/narrative/source-ids.js +201 -0
  395. package/dist/codex/build/src/narrative/statements.d.ts +84 -0
  396. package/dist/codex/build/src/narrative/statements.js +347 -0
  397. package/dist/codex/build/src/narrative/turn-spine.d.ts +19 -0
  398. package/dist/codex/build/src/narrative/turn-spine.js +73 -0
  399. package/dist/codex/build/src/tools/build-universal-bundles.js +8 -0
  400. package/dist/codex/build/src/tools/generate-capability-matrix.d.ts +7 -0
  401. package/dist/codex/build/src/tools/generate-capability-matrix.js +207 -0
  402. package/dist/codex/build/src/tools/validate-source-tree.js +5 -1
  403. package/dist/codex/context/scripts/hooks/stop-goal-fit.js +182 -9
  404. package/dist/codex/context/scripts/hooks/workflow-steering.js +160 -19
  405. package/dist/codex/context/scripts/telemetry/lib/session.sh +3 -0
  406. package/dist/codex/context/scripts/telemetry/lib/transport.sh +12 -3
  407. package/dist/codex/context/scripts/telemetry/telemetry.sh +480 -59
  408. package/dist/codex/docs/context-map.md +4 -0
  409. package/dist/codex/docs/decisions/index.md +1 -0
  410. package/dist/codex/docs/decisions/writer-observed-execution.md +51 -0
  411. package/dist/codex/docs/fixture-ownership.md +5 -1
  412. package/dist/codex/docs/migrations.md +20 -0
  413. package/dist/codex/docs/public-workflow-cli.md +9 -0
  414. package/dist/codex/docs/spec/builder-flow-runtime.md +49 -8
  415. package/dist/codex/docs/spec/runtime-hook-surface.md +29 -1
  416. package/dist/codex/docs/specs/economics-record-contract.md +1 -1
  417. package/dist/codex/docs/specs/harness-capability-matrix.md +63 -21
  418. package/dist/codex/docs/workflow-usage-guide.md +4 -1
  419. package/dist/codex/evals/ci/run-baseline.sh +38 -0
  420. package/dist/codex/evals/fixtures/narrative-evals/README.md +62 -0
  421. package/dist/codex/evals/fixtures/narrative-evals/corpus.json +129 -0
  422. package/dist/codex/evals/fixtures/narrative-evals/scorer.mjs +522 -0
  423. package/dist/codex/evals/fixtures/narrative-grounding-validator/corpus.json +20 -0
  424. package/dist/codex/evals/fixtures/narrative-grounding-validator/prompt-injection-adversarial.txt +1 -0
  425. package/dist/codex/evals/fixtures/narrative-grounding-validator/prompt-injection-control.txt +1 -0
  426. package/dist/codex/evals/fixtures/narrative-grounding-validator/scorer.mjs +201 -0
  427. package/dist/codex/evals/fixtures/narrative-prose-renderer/corpus.json +15 -0
  428. package/dist/codex/evals/fixtures/narrative-prose-renderer/scorer.mjs +201 -0
  429. package/dist/codex/evals/fixtures/narrative-sources/expected-capture-completeness.json +13 -0
  430. package/dist/codex/evals/fixtures/narrative-sources/flow/runs/run-fixture/report.json +1 -0
  431. package/dist/codex/evals/fixtures/narrative-sources/flow/runs/run-fixture/state.json +1 -0
  432. package/dist/codex/evals/fixtures/narrative-sources/flow/runs/run-runtime/state.json +1 -0
  433. package/dist/codex/evals/fixtures/narrative-sources/repo/created.txt +1 -0
  434. package/dist/codex/evals/fixtures/narrative-sources/repo/fixture.txt +1 -0
  435. package/dist/codex/evals/fixtures/narrative-sources/session/agents/agent-fixture/events.jsonl +2 -0
  436. package/dist/codex/evals/fixtures/narrative-sources/session/agents/nested-worker/events.jsonl +1 -0
  437. package/dist/codex/evals/fixtures/narrative-sources/session/trust.bundle +1 -0
  438. package/dist/codex/evals/fixtures/narrative-sources/telemetry/full.jsonl +3 -0
  439. package/dist/codex/evals/fixtures/narrative-sources/telemetry/runtime.jsonl +4 -0
  440. package/dist/codex/evals/fixtures/narrative-sources/transcripts/session.txt +1 -0
  441. package/dist/codex/evals/integration/test_capability_declarations.sh +183 -0
  442. package/dist/codex/evals/integration/test_economics_record.sh +42 -0
  443. package/dist/codex/evals/integration/test_fixture_retirement_audit.sh +2 -2
  444. package/dist/codex/evals/integration/test_gate_review_inquiry_records.sh +42 -35
  445. package/dist/codex/evals/integration/test_goal_fit_hook.sh +13 -5
  446. package/dist/codex/evals/integration/test_goal_fit_narrative_exclusion.sh +68 -0
  447. package/dist/codex/evals/integration/test_narrative_evals.sh +174 -0
  448. package/dist/codex/evals/integration/test_narrative_grounded_envelope.sh +280 -0
  449. package/dist/codex/evals/integration/test_narrative_grounding_validator.sh +166 -0
  450. package/dist/codex/evals/integration/test_narrative_intent_annotation.sh +205 -0
  451. package/dist/codex/evals/integration/test_narrative_prose_renderer.sh +239 -0
  452. package/dist/codex/evals/integration/test_narrative_redaction_failclosed.sh +120 -0
  453. package/dist/codex/evals/integration/test_narrative_runtime_projection.sh +146 -0
  454. package/dist/codex/evals/integration/test_narrative_source_contract.sh +228 -0
  455. package/dist/codex/evals/integration/test_narrative_trust_isolation.sh +408 -0
  456. package/dist/codex/evals/integration/test_plain_stop_messaging.sh +91 -0
  457. package/dist/codex/evals/integration/test_session_resume_roundtrip.sh +228 -0
  458. package/dist/codex/evals/integration/test_telemetry_action_class.sh +265 -0
  459. package/dist/codex/evals/integration/test_telemetry_delegation.sh +291 -0
  460. package/dist/codex/evals/integration/test_telemetry_sanitize_usage.sh +155 -0
  461. package/dist/codex/evals/integration/test_telemetry_task_slug.sh +158 -0
  462. package/dist/codex/evals/integration/test_telemetry_tool_outcome.sh +279 -0
  463. package/dist/codex/evals/integration/test_workflow_sidecar_writer.sh +111 -2
  464. package/dist/codex/evals/run.sh +12 -0
  465. package/dist/codex/evals/static/test_library_exports.sh +5 -0
  466. package/dist/codex/install.sh +1 -1
  467. package/dist/codex/schemas/grounded-execution-narrative.schema.json +292 -0
  468. package/dist/codex/schemas/narrative-eval-result.schema.json +205 -0
  469. package/dist/codex/schemas/narrative-runtime-projection.schema.json +134 -0
  470. package/dist/codex/schemas/narrative-source-manifest.schema.json +294 -0
  471. package/dist/codex/scripts/check-hachure-boundary.mjs +81 -0
  472. package/dist/codex/scripts/hooks/stop-goal-fit.js +182 -9
  473. package/dist/codex/scripts/hooks/workflow-steering.js +160 -19
  474. package/dist/codex/scripts/telemetry/economics-record.schema.json +1 -1
  475. package/dist/codex/scripts/telemetry/economics-record.sh +47 -3
  476. package/dist/codex/scripts/telemetry/lib/session.sh +3 -0
  477. package/dist/codex/scripts/telemetry/lib/transport.sh +12 -3
  478. package/dist/codex/scripts/telemetry/telemetry.sh +480 -59
  479. package/dist/kiro/build/generated/capability-declarations.json +177 -0
  480. package/dist/kiro/build/package.json +1 -1
  481. package/dist/kiro/build/src/builder-flow-runtime.d.ts +37 -0
  482. package/dist/kiro/build/src/builder-flow-runtime.js +71 -1
  483. package/dist/kiro/build/src/builder-gate-action-envelope.d.ts +59 -7
  484. package/dist/kiro/build/src/builder-gate-action-envelope.js +163 -30
  485. package/dist/kiro/build/src/builder-lifecycle-authority.d.ts +26 -0
  486. package/dist/kiro/build/src/builder-lifecycle-authority.js +38 -0
  487. package/dist/kiro/build/src/cli/builder-run.js +71 -2
  488. package/dist/kiro/build/src/cli/narrative-render.d.ts +95 -0
  489. package/dist/kiro/build/src/cli/narrative-render.js +466 -0
  490. package/dist/kiro/build/src/cli/narrative-sources.d.ts +2 -0
  491. package/dist/kiro/build/src/cli/narrative-sources.js +282 -0
  492. package/dist/kiro/build/src/cli/public-contracts.d.ts +257 -0
  493. package/dist/kiro/build/src/cli/public-contracts.js +87 -0
  494. package/dist/kiro/build/src/cli/workflow-sidecar.d.ts +28 -12
  495. package/dist/kiro/build/src/cli/workflow-sidecar.js +599 -180
  496. package/dist/kiro/build/src/cli/workflow.js +11 -1
  497. package/dist/kiro/build/src/cli.js +8 -0
  498. package/dist/kiro/build/src/continuation-driver.d.ts +12 -0
  499. package/dist/kiro/build/src/continuation-driver.js +16 -2
  500. package/dist/kiro/build/src/continuation-validation.js +349 -3
  501. package/dist/kiro/build/src/flow-kit/action-metadata.js +21 -1
  502. package/dist/kiro/build/src/index.d.ts +33 -2
  503. package/dist/kiro/build/src/index.js +24 -0
  504. package/dist/kiro/build/src/lib/capability-declarations.d.ts +83 -0
  505. package/dist/kiro/build/src/lib/capability-declarations.js +209 -0
  506. package/dist/kiro/build/src/narrative/envelope.d.ts +111 -0
  507. package/dist/kiro/build/src/narrative/envelope.js +590 -0
  508. package/dist/kiro/build/src/narrative/eval-result.d.ts +60 -0
  509. package/dist/kiro/build/src/narrative/eval-result.js +158 -0
  510. package/dist/kiro/build/src/narrative/grounding-validator.d.ts +104 -0
  511. package/dist/kiro/build/src/narrative/grounding-validator.js +472 -0
  512. package/dist/kiro/build/src/narrative/integrity.d.ts +17 -0
  513. package/dist/kiro/build/src/narrative/integrity.js +39 -0
  514. package/dist/kiro/build/src/narrative/intent-economics.d.ts +42 -0
  515. package/dist/kiro/build/src/narrative/intent-economics.js +82 -0
  516. package/dist/kiro/build/src/narrative/intent.d.ts +94 -0
  517. package/dist/kiro/build/src/narrative/intent.js +132 -0
  518. package/dist/kiro/build/src/narrative/policy-filter.d.ts +15 -0
  519. package/dist/kiro/build/src/narrative/policy-filter.js +58 -0
  520. package/dist/kiro/build/src/narrative/projection.d.ts +58 -0
  521. package/dist/kiro/build/src/narrative/projection.js +502 -0
  522. package/dist/kiro/build/src/narrative/readers.d.ts +84 -0
  523. package/dist/kiro/build/src/narrative/readers.js +406 -0
  524. package/dist/kiro/build/src/narrative/render.d.ts +3 -0
  525. package/dist/kiro/build/src/narrative/render.js +83 -0
  526. package/dist/kiro/build/src/narrative/resolver.d.ts +52 -0
  527. package/dist/kiro/build/src/narrative/resolver.js +190 -0
  528. package/dist/kiro/build/src/narrative/snapshot.d.ts +90 -0
  529. package/dist/kiro/build/src/narrative/snapshot.js +325 -0
  530. package/dist/kiro/build/src/narrative/source-ids.d.ts +121 -0
  531. package/dist/kiro/build/src/narrative/source-ids.js +201 -0
  532. package/dist/kiro/build/src/narrative/statements.d.ts +84 -0
  533. package/dist/kiro/build/src/narrative/statements.js +347 -0
  534. package/dist/kiro/build/src/narrative/turn-spine.d.ts +19 -0
  535. package/dist/kiro/build/src/narrative/turn-spine.js +73 -0
  536. package/dist/kiro/build/src/tools/build-universal-bundles.js +8 -0
  537. package/dist/kiro/build/src/tools/generate-capability-matrix.d.ts +7 -0
  538. package/dist/kiro/build/src/tools/generate-capability-matrix.js +207 -0
  539. package/dist/kiro/build/src/tools/validate-source-tree.js +5 -1
  540. package/dist/kiro/context/scripts/hooks/stop-goal-fit.js +182 -9
  541. package/dist/kiro/context/scripts/hooks/workflow-steering.js +160 -19
  542. package/dist/kiro/context/scripts/telemetry/lib/session.sh +3 -0
  543. package/dist/kiro/context/scripts/telemetry/lib/transport.sh +12 -3
  544. package/dist/kiro/context/scripts/telemetry/telemetry.sh +480 -59
  545. package/dist/kiro/docs/context-map.md +4 -0
  546. package/dist/kiro/docs/decisions/index.md +1 -0
  547. package/dist/kiro/docs/decisions/writer-observed-execution.md +51 -0
  548. package/dist/kiro/docs/fixture-ownership.md +5 -1
  549. package/dist/kiro/docs/migrations.md +20 -0
  550. package/dist/kiro/docs/public-workflow-cli.md +9 -0
  551. package/dist/kiro/docs/spec/builder-flow-runtime.md +49 -8
  552. package/dist/kiro/docs/spec/runtime-hook-surface.md +29 -1
  553. package/dist/kiro/docs/specs/economics-record-contract.md +1 -1
  554. package/dist/kiro/docs/specs/harness-capability-matrix.md +63 -21
  555. package/dist/kiro/docs/workflow-usage-guide.md +4 -1
  556. package/dist/kiro/evals/ci/run-baseline.sh +38 -0
  557. package/dist/kiro/evals/fixtures/narrative-evals/README.md +62 -0
  558. package/dist/kiro/evals/fixtures/narrative-evals/corpus.json +129 -0
  559. package/dist/kiro/evals/fixtures/narrative-evals/scorer.mjs +522 -0
  560. package/dist/kiro/evals/fixtures/narrative-grounding-validator/corpus.json +20 -0
  561. package/dist/kiro/evals/fixtures/narrative-grounding-validator/prompt-injection-adversarial.txt +1 -0
  562. package/dist/kiro/evals/fixtures/narrative-grounding-validator/prompt-injection-control.txt +1 -0
  563. package/dist/kiro/evals/fixtures/narrative-grounding-validator/scorer.mjs +201 -0
  564. package/dist/kiro/evals/fixtures/narrative-prose-renderer/corpus.json +15 -0
  565. package/dist/kiro/evals/fixtures/narrative-prose-renderer/scorer.mjs +201 -0
  566. package/dist/kiro/evals/fixtures/narrative-sources/expected-capture-completeness.json +13 -0
  567. package/dist/kiro/evals/fixtures/narrative-sources/flow/runs/run-fixture/report.json +1 -0
  568. package/dist/kiro/evals/fixtures/narrative-sources/flow/runs/run-fixture/state.json +1 -0
  569. package/dist/kiro/evals/fixtures/narrative-sources/flow/runs/run-runtime/state.json +1 -0
  570. package/dist/kiro/evals/fixtures/narrative-sources/repo/created.txt +1 -0
  571. package/dist/kiro/evals/fixtures/narrative-sources/repo/fixture.txt +1 -0
  572. package/dist/kiro/evals/fixtures/narrative-sources/session/agents/agent-fixture/events.jsonl +2 -0
  573. package/dist/kiro/evals/fixtures/narrative-sources/session/agents/nested-worker/events.jsonl +1 -0
  574. package/dist/kiro/evals/fixtures/narrative-sources/session/trust.bundle +1 -0
  575. package/dist/kiro/evals/fixtures/narrative-sources/telemetry/full.jsonl +3 -0
  576. package/dist/kiro/evals/fixtures/narrative-sources/telemetry/runtime.jsonl +4 -0
  577. package/dist/kiro/evals/fixtures/narrative-sources/transcripts/session.txt +1 -0
  578. package/dist/kiro/evals/integration/test_capability_declarations.sh +183 -0
  579. package/dist/kiro/evals/integration/test_economics_record.sh +42 -0
  580. package/dist/kiro/evals/integration/test_fixture_retirement_audit.sh +2 -2
  581. package/dist/kiro/evals/integration/test_gate_review_inquiry_records.sh +42 -35
  582. package/dist/kiro/evals/integration/test_goal_fit_hook.sh +13 -5
  583. package/dist/kiro/evals/integration/test_goal_fit_narrative_exclusion.sh +68 -0
  584. package/dist/kiro/evals/integration/test_narrative_evals.sh +174 -0
  585. package/dist/kiro/evals/integration/test_narrative_grounded_envelope.sh +280 -0
  586. package/dist/kiro/evals/integration/test_narrative_grounding_validator.sh +166 -0
  587. package/dist/kiro/evals/integration/test_narrative_intent_annotation.sh +205 -0
  588. package/dist/kiro/evals/integration/test_narrative_prose_renderer.sh +239 -0
  589. package/dist/kiro/evals/integration/test_narrative_redaction_failclosed.sh +120 -0
  590. package/dist/kiro/evals/integration/test_narrative_runtime_projection.sh +146 -0
  591. package/dist/kiro/evals/integration/test_narrative_source_contract.sh +228 -0
  592. package/dist/kiro/evals/integration/test_narrative_trust_isolation.sh +408 -0
  593. package/dist/kiro/evals/integration/test_plain_stop_messaging.sh +91 -0
  594. package/dist/kiro/evals/integration/test_session_resume_roundtrip.sh +228 -0
  595. package/dist/kiro/evals/integration/test_telemetry_action_class.sh +265 -0
  596. package/dist/kiro/evals/integration/test_telemetry_delegation.sh +291 -0
  597. package/dist/kiro/evals/integration/test_telemetry_sanitize_usage.sh +155 -0
  598. package/dist/kiro/evals/integration/test_telemetry_task_slug.sh +158 -0
  599. package/dist/kiro/evals/integration/test_telemetry_tool_outcome.sh +279 -0
  600. package/dist/kiro/evals/integration/test_workflow_sidecar_writer.sh +111 -2
  601. package/dist/kiro/evals/run.sh +12 -0
  602. package/dist/kiro/evals/static/test_library_exports.sh +5 -0
  603. package/dist/kiro/install.sh +1 -1
  604. package/dist/kiro/schemas/grounded-execution-narrative.schema.json +292 -0
  605. package/dist/kiro/schemas/narrative-eval-result.schema.json +205 -0
  606. package/dist/kiro/schemas/narrative-runtime-projection.schema.json +134 -0
  607. package/dist/kiro/schemas/narrative-source-manifest.schema.json +294 -0
  608. package/dist/kiro/scripts/check-hachure-boundary.mjs +81 -0
  609. package/dist/kiro/scripts/hooks/stop-goal-fit.js +182 -9
  610. package/dist/kiro/scripts/hooks/workflow-steering.js +160 -19
  611. package/dist/kiro/scripts/telemetry/economics-record.schema.json +1 -1
  612. package/dist/kiro/scripts/telemetry/economics-record.sh +47 -3
  613. package/dist/kiro/scripts/telemetry/lib/session.sh +3 -0
  614. package/dist/kiro/scripts/telemetry/lib/transport.sh +12 -3
  615. package/dist/kiro/scripts/telemetry/telemetry.sh +480 -59
  616. package/dist/opencode/build/generated/capability-declarations.json +177 -0
  617. package/dist/opencode/build/package.json +1 -1
  618. package/dist/opencode/build/src/builder-flow-runtime.d.ts +37 -0
  619. package/dist/opencode/build/src/builder-flow-runtime.js +71 -1
  620. package/dist/opencode/build/src/builder-gate-action-envelope.d.ts +59 -7
  621. package/dist/opencode/build/src/builder-gate-action-envelope.js +163 -30
  622. package/dist/opencode/build/src/builder-lifecycle-authority.d.ts +26 -0
  623. package/dist/opencode/build/src/builder-lifecycle-authority.js +38 -0
  624. package/dist/opencode/build/src/cli/builder-run.js +71 -2
  625. package/dist/opencode/build/src/cli/narrative-render.d.ts +95 -0
  626. package/dist/opencode/build/src/cli/narrative-render.js +466 -0
  627. package/dist/opencode/build/src/cli/narrative-sources.d.ts +2 -0
  628. package/dist/opencode/build/src/cli/narrative-sources.js +282 -0
  629. package/dist/opencode/build/src/cli/public-contracts.d.ts +257 -0
  630. package/dist/opencode/build/src/cli/public-contracts.js +87 -0
  631. package/dist/opencode/build/src/cli/workflow-sidecar.d.ts +28 -12
  632. package/dist/opencode/build/src/cli/workflow-sidecar.js +599 -180
  633. package/dist/opencode/build/src/cli/workflow.js +11 -1
  634. package/dist/opencode/build/src/cli.js +8 -0
  635. package/dist/opencode/build/src/continuation-driver.d.ts +12 -0
  636. package/dist/opencode/build/src/continuation-driver.js +16 -2
  637. package/dist/opencode/build/src/continuation-validation.js +349 -3
  638. package/dist/opencode/build/src/flow-kit/action-metadata.js +21 -1
  639. package/dist/opencode/build/src/index.d.ts +33 -2
  640. package/dist/opencode/build/src/index.js +24 -0
  641. package/dist/opencode/build/src/lib/capability-declarations.d.ts +83 -0
  642. package/dist/opencode/build/src/lib/capability-declarations.js +209 -0
  643. package/dist/opencode/build/src/narrative/envelope.d.ts +111 -0
  644. package/dist/opencode/build/src/narrative/envelope.js +590 -0
  645. package/dist/opencode/build/src/narrative/eval-result.d.ts +60 -0
  646. package/dist/opencode/build/src/narrative/eval-result.js +158 -0
  647. package/dist/opencode/build/src/narrative/grounding-validator.d.ts +104 -0
  648. package/dist/opencode/build/src/narrative/grounding-validator.js +472 -0
  649. package/dist/opencode/build/src/narrative/integrity.d.ts +17 -0
  650. package/dist/opencode/build/src/narrative/integrity.js +39 -0
  651. package/dist/opencode/build/src/narrative/intent-economics.d.ts +42 -0
  652. package/dist/opencode/build/src/narrative/intent-economics.js +82 -0
  653. package/dist/opencode/build/src/narrative/intent.d.ts +94 -0
  654. package/dist/opencode/build/src/narrative/intent.js +132 -0
  655. package/dist/opencode/build/src/narrative/policy-filter.d.ts +15 -0
  656. package/dist/opencode/build/src/narrative/policy-filter.js +58 -0
  657. package/dist/opencode/build/src/narrative/projection.d.ts +58 -0
  658. package/dist/opencode/build/src/narrative/projection.js +502 -0
  659. package/dist/opencode/build/src/narrative/readers.d.ts +84 -0
  660. package/dist/opencode/build/src/narrative/readers.js +406 -0
  661. package/dist/opencode/build/src/narrative/render.d.ts +3 -0
  662. package/dist/opencode/build/src/narrative/render.js +83 -0
  663. package/dist/opencode/build/src/narrative/resolver.d.ts +52 -0
  664. package/dist/opencode/build/src/narrative/resolver.js +190 -0
  665. package/dist/opencode/build/src/narrative/snapshot.d.ts +90 -0
  666. package/dist/opencode/build/src/narrative/snapshot.js +325 -0
  667. package/dist/opencode/build/src/narrative/source-ids.d.ts +121 -0
  668. package/dist/opencode/build/src/narrative/source-ids.js +201 -0
  669. package/dist/opencode/build/src/narrative/statements.d.ts +84 -0
  670. package/dist/opencode/build/src/narrative/statements.js +347 -0
  671. package/dist/opencode/build/src/narrative/turn-spine.d.ts +19 -0
  672. package/dist/opencode/build/src/narrative/turn-spine.js +73 -0
  673. package/dist/opencode/build/src/tools/build-universal-bundles.js +8 -0
  674. package/dist/opencode/build/src/tools/generate-capability-matrix.d.ts +7 -0
  675. package/dist/opencode/build/src/tools/generate-capability-matrix.js +207 -0
  676. package/dist/opencode/build/src/tools/validate-source-tree.js +5 -1
  677. package/dist/opencode/context/scripts/hooks/stop-goal-fit.js +182 -9
  678. package/dist/opencode/context/scripts/hooks/workflow-steering.js +160 -19
  679. package/dist/opencode/context/scripts/telemetry/lib/session.sh +3 -0
  680. package/dist/opencode/context/scripts/telemetry/lib/transport.sh +12 -3
  681. package/dist/opencode/context/scripts/telemetry/telemetry.sh +480 -59
  682. package/dist/opencode/docs/context-map.md +4 -0
  683. package/dist/opencode/docs/decisions/index.md +1 -0
  684. package/dist/opencode/docs/decisions/writer-observed-execution.md +51 -0
  685. package/dist/opencode/docs/fixture-ownership.md +5 -1
  686. package/dist/opencode/docs/migrations.md +20 -0
  687. package/dist/opencode/docs/public-workflow-cli.md +9 -0
  688. package/dist/opencode/docs/spec/builder-flow-runtime.md +49 -8
  689. package/dist/opencode/docs/spec/runtime-hook-surface.md +29 -1
  690. package/dist/opencode/docs/specs/economics-record-contract.md +1 -1
  691. package/dist/opencode/docs/specs/harness-capability-matrix.md +63 -21
  692. package/dist/opencode/docs/workflow-usage-guide.md +4 -1
  693. package/dist/opencode/evals/ci/run-baseline.sh +38 -0
  694. package/dist/opencode/evals/fixtures/narrative-evals/README.md +62 -0
  695. package/dist/opencode/evals/fixtures/narrative-evals/corpus.json +129 -0
  696. package/dist/opencode/evals/fixtures/narrative-evals/scorer.mjs +522 -0
  697. package/dist/opencode/evals/fixtures/narrative-grounding-validator/corpus.json +20 -0
  698. package/dist/opencode/evals/fixtures/narrative-grounding-validator/prompt-injection-adversarial.txt +1 -0
  699. package/dist/opencode/evals/fixtures/narrative-grounding-validator/prompt-injection-control.txt +1 -0
  700. package/dist/opencode/evals/fixtures/narrative-grounding-validator/scorer.mjs +201 -0
  701. package/dist/opencode/evals/fixtures/narrative-prose-renderer/corpus.json +15 -0
  702. package/dist/opencode/evals/fixtures/narrative-prose-renderer/scorer.mjs +201 -0
  703. package/dist/opencode/evals/fixtures/narrative-sources/expected-capture-completeness.json +13 -0
  704. package/dist/opencode/evals/fixtures/narrative-sources/flow/runs/run-fixture/report.json +1 -0
  705. package/dist/opencode/evals/fixtures/narrative-sources/flow/runs/run-fixture/state.json +1 -0
  706. package/dist/opencode/evals/fixtures/narrative-sources/flow/runs/run-runtime/state.json +1 -0
  707. package/dist/opencode/evals/fixtures/narrative-sources/repo/created.txt +1 -0
  708. package/dist/opencode/evals/fixtures/narrative-sources/repo/fixture.txt +1 -0
  709. package/dist/opencode/evals/fixtures/narrative-sources/session/agents/agent-fixture/events.jsonl +2 -0
  710. package/dist/opencode/evals/fixtures/narrative-sources/session/agents/nested-worker/events.jsonl +1 -0
  711. package/dist/opencode/evals/fixtures/narrative-sources/session/trust.bundle +1 -0
  712. package/dist/opencode/evals/fixtures/narrative-sources/telemetry/full.jsonl +3 -0
  713. package/dist/opencode/evals/fixtures/narrative-sources/telemetry/runtime.jsonl +4 -0
  714. package/dist/opencode/evals/fixtures/narrative-sources/transcripts/session.txt +1 -0
  715. package/dist/opencode/evals/integration/test_capability_declarations.sh +183 -0
  716. package/dist/opencode/evals/integration/test_economics_record.sh +42 -0
  717. package/dist/opencode/evals/integration/test_fixture_retirement_audit.sh +2 -2
  718. package/dist/opencode/evals/integration/test_gate_review_inquiry_records.sh +42 -35
  719. package/dist/opencode/evals/integration/test_goal_fit_hook.sh +13 -5
  720. package/dist/opencode/evals/integration/test_goal_fit_narrative_exclusion.sh +68 -0
  721. package/dist/opencode/evals/integration/test_narrative_evals.sh +174 -0
  722. package/dist/opencode/evals/integration/test_narrative_grounded_envelope.sh +280 -0
  723. package/dist/opencode/evals/integration/test_narrative_grounding_validator.sh +166 -0
  724. package/dist/opencode/evals/integration/test_narrative_intent_annotation.sh +205 -0
  725. package/dist/opencode/evals/integration/test_narrative_prose_renderer.sh +239 -0
  726. package/dist/opencode/evals/integration/test_narrative_redaction_failclosed.sh +120 -0
  727. package/dist/opencode/evals/integration/test_narrative_runtime_projection.sh +146 -0
  728. package/dist/opencode/evals/integration/test_narrative_source_contract.sh +228 -0
  729. package/dist/opencode/evals/integration/test_narrative_trust_isolation.sh +408 -0
  730. package/dist/opencode/evals/integration/test_plain_stop_messaging.sh +91 -0
  731. package/dist/opencode/evals/integration/test_session_resume_roundtrip.sh +228 -0
  732. package/dist/opencode/evals/integration/test_telemetry_action_class.sh +265 -0
  733. package/dist/opencode/evals/integration/test_telemetry_delegation.sh +291 -0
  734. package/dist/opencode/evals/integration/test_telemetry_sanitize_usage.sh +155 -0
  735. package/dist/opencode/evals/integration/test_telemetry_task_slug.sh +158 -0
  736. package/dist/opencode/evals/integration/test_telemetry_tool_outcome.sh +279 -0
  737. package/dist/opencode/evals/integration/test_workflow_sidecar_writer.sh +111 -2
  738. package/dist/opencode/evals/run.sh +12 -0
  739. package/dist/opencode/evals/static/test_library_exports.sh +5 -0
  740. package/dist/opencode/install.sh +1 -1
  741. package/dist/opencode/schemas/grounded-execution-narrative.schema.json +292 -0
  742. package/dist/opencode/schemas/narrative-eval-result.schema.json +205 -0
  743. package/dist/opencode/schemas/narrative-runtime-projection.schema.json +134 -0
  744. package/dist/opencode/schemas/narrative-source-manifest.schema.json +294 -0
  745. package/dist/opencode/scripts/check-hachure-boundary.mjs +81 -0
  746. package/dist/opencode/scripts/hooks/stop-goal-fit.js +182 -9
  747. package/dist/opencode/scripts/hooks/workflow-steering.js +160 -19
  748. package/dist/opencode/scripts/telemetry/economics-record.schema.json +1 -1
  749. package/dist/opencode/scripts/telemetry/economics-record.sh +47 -3
  750. package/dist/opencode/scripts/telemetry/lib/session.sh +3 -0
  751. package/dist/opencode/scripts/telemetry/lib/transport.sh +12 -3
  752. package/dist/opencode/scripts/telemetry/telemetry.sh +480 -59
  753. package/dist/pi/build/generated/capability-declarations.json +177 -0
  754. package/dist/pi/build/package.json +1 -1
  755. package/dist/pi/build/src/builder-flow-runtime.d.ts +37 -0
  756. package/dist/pi/build/src/builder-flow-runtime.js +71 -1
  757. package/dist/pi/build/src/builder-gate-action-envelope.d.ts +59 -7
  758. package/dist/pi/build/src/builder-gate-action-envelope.js +163 -30
  759. package/dist/pi/build/src/builder-lifecycle-authority.d.ts +26 -0
  760. package/dist/pi/build/src/builder-lifecycle-authority.js +38 -0
  761. package/dist/pi/build/src/cli/builder-run.js +71 -2
  762. package/dist/pi/build/src/cli/narrative-render.d.ts +95 -0
  763. package/dist/pi/build/src/cli/narrative-render.js +466 -0
  764. package/dist/pi/build/src/cli/narrative-sources.d.ts +2 -0
  765. package/dist/pi/build/src/cli/narrative-sources.js +282 -0
  766. package/dist/pi/build/src/cli/public-contracts.d.ts +257 -0
  767. package/dist/pi/build/src/cli/public-contracts.js +87 -0
  768. package/dist/pi/build/src/cli/workflow-sidecar.d.ts +28 -12
  769. package/dist/pi/build/src/cli/workflow-sidecar.js +599 -180
  770. package/dist/pi/build/src/cli/workflow.js +11 -1
  771. package/dist/pi/build/src/cli.js +8 -0
  772. package/dist/pi/build/src/continuation-driver.d.ts +12 -0
  773. package/dist/pi/build/src/continuation-driver.js +16 -2
  774. package/dist/pi/build/src/continuation-validation.js +349 -3
  775. package/dist/pi/build/src/flow-kit/action-metadata.js +21 -1
  776. package/dist/pi/build/src/index.d.ts +33 -2
  777. package/dist/pi/build/src/index.js +24 -0
  778. package/dist/pi/build/src/lib/capability-declarations.d.ts +83 -0
  779. package/dist/pi/build/src/lib/capability-declarations.js +209 -0
  780. package/dist/pi/build/src/narrative/envelope.d.ts +111 -0
  781. package/dist/pi/build/src/narrative/envelope.js +590 -0
  782. package/dist/pi/build/src/narrative/eval-result.d.ts +60 -0
  783. package/dist/pi/build/src/narrative/eval-result.js +158 -0
  784. package/dist/pi/build/src/narrative/grounding-validator.d.ts +104 -0
  785. package/dist/pi/build/src/narrative/grounding-validator.js +472 -0
  786. package/dist/pi/build/src/narrative/integrity.d.ts +17 -0
  787. package/dist/pi/build/src/narrative/integrity.js +39 -0
  788. package/dist/pi/build/src/narrative/intent-economics.d.ts +42 -0
  789. package/dist/pi/build/src/narrative/intent-economics.js +82 -0
  790. package/dist/pi/build/src/narrative/intent.d.ts +94 -0
  791. package/dist/pi/build/src/narrative/intent.js +132 -0
  792. package/dist/pi/build/src/narrative/policy-filter.d.ts +15 -0
  793. package/dist/pi/build/src/narrative/policy-filter.js +58 -0
  794. package/dist/pi/build/src/narrative/projection.d.ts +58 -0
  795. package/dist/pi/build/src/narrative/projection.js +502 -0
  796. package/dist/pi/build/src/narrative/readers.d.ts +84 -0
  797. package/dist/pi/build/src/narrative/readers.js +406 -0
  798. package/dist/pi/build/src/narrative/render.d.ts +3 -0
  799. package/dist/pi/build/src/narrative/render.js +83 -0
  800. package/dist/pi/build/src/narrative/resolver.d.ts +52 -0
  801. package/dist/pi/build/src/narrative/resolver.js +190 -0
  802. package/dist/pi/build/src/narrative/snapshot.d.ts +90 -0
  803. package/dist/pi/build/src/narrative/snapshot.js +325 -0
  804. package/dist/pi/build/src/narrative/source-ids.d.ts +121 -0
  805. package/dist/pi/build/src/narrative/source-ids.js +201 -0
  806. package/dist/pi/build/src/narrative/statements.d.ts +84 -0
  807. package/dist/pi/build/src/narrative/statements.js +347 -0
  808. package/dist/pi/build/src/narrative/turn-spine.d.ts +19 -0
  809. package/dist/pi/build/src/narrative/turn-spine.js +73 -0
  810. package/dist/pi/build/src/tools/build-universal-bundles.js +8 -0
  811. package/dist/pi/build/src/tools/generate-capability-matrix.d.ts +7 -0
  812. package/dist/pi/build/src/tools/generate-capability-matrix.js +207 -0
  813. package/dist/pi/build/src/tools/validate-source-tree.js +5 -1
  814. package/dist/pi/context/scripts/hooks/stop-goal-fit.js +182 -9
  815. package/dist/pi/context/scripts/hooks/workflow-steering.js +160 -19
  816. package/dist/pi/context/scripts/telemetry/lib/session.sh +3 -0
  817. package/dist/pi/context/scripts/telemetry/lib/transport.sh +12 -3
  818. package/dist/pi/context/scripts/telemetry/telemetry.sh +480 -59
  819. package/dist/pi/docs/context-map.md +4 -0
  820. package/dist/pi/docs/decisions/index.md +1 -0
  821. package/dist/pi/docs/decisions/writer-observed-execution.md +51 -0
  822. package/dist/pi/docs/fixture-ownership.md +5 -1
  823. package/dist/pi/docs/migrations.md +20 -0
  824. package/dist/pi/docs/public-workflow-cli.md +9 -0
  825. package/dist/pi/docs/spec/builder-flow-runtime.md +49 -8
  826. package/dist/pi/docs/spec/runtime-hook-surface.md +29 -1
  827. package/dist/pi/docs/specs/economics-record-contract.md +1 -1
  828. package/dist/pi/docs/specs/harness-capability-matrix.md +63 -21
  829. package/dist/pi/docs/workflow-usage-guide.md +4 -1
  830. package/dist/pi/evals/ci/run-baseline.sh +38 -0
  831. package/dist/pi/evals/fixtures/narrative-evals/README.md +62 -0
  832. package/dist/pi/evals/fixtures/narrative-evals/corpus.json +129 -0
  833. package/dist/pi/evals/fixtures/narrative-evals/scorer.mjs +522 -0
  834. package/dist/pi/evals/fixtures/narrative-grounding-validator/corpus.json +20 -0
  835. package/dist/pi/evals/fixtures/narrative-grounding-validator/prompt-injection-adversarial.txt +1 -0
  836. package/dist/pi/evals/fixtures/narrative-grounding-validator/prompt-injection-control.txt +1 -0
  837. package/dist/pi/evals/fixtures/narrative-grounding-validator/scorer.mjs +201 -0
  838. package/dist/pi/evals/fixtures/narrative-prose-renderer/corpus.json +15 -0
  839. package/dist/pi/evals/fixtures/narrative-prose-renderer/scorer.mjs +201 -0
  840. package/dist/pi/evals/fixtures/narrative-sources/expected-capture-completeness.json +13 -0
  841. package/dist/pi/evals/fixtures/narrative-sources/flow/runs/run-fixture/report.json +1 -0
  842. package/dist/pi/evals/fixtures/narrative-sources/flow/runs/run-fixture/state.json +1 -0
  843. package/dist/pi/evals/fixtures/narrative-sources/flow/runs/run-runtime/state.json +1 -0
  844. package/dist/pi/evals/fixtures/narrative-sources/repo/created.txt +1 -0
  845. package/dist/pi/evals/fixtures/narrative-sources/repo/fixture.txt +1 -0
  846. package/dist/pi/evals/fixtures/narrative-sources/session/agents/agent-fixture/events.jsonl +2 -0
  847. package/dist/pi/evals/fixtures/narrative-sources/session/agents/nested-worker/events.jsonl +1 -0
  848. package/dist/pi/evals/fixtures/narrative-sources/session/trust.bundle +1 -0
  849. package/dist/pi/evals/fixtures/narrative-sources/telemetry/full.jsonl +3 -0
  850. package/dist/pi/evals/fixtures/narrative-sources/telemetry/runtime.jsonl +4 -0
  851. package/dist/pi/evals/fixtures/narrative-sources/transcripts/session.txt +1 -0
  852. package/dist/pi/evals/integration/test_capability_declarations.sh +183 -0
  853. package/dist/pi/evals/integration/test_economics_record.sh +42 -0
  854. package/dist/pi/evals/integration/test_fixture_retirement_audit.sh +2 -2
  855. package/dist/pi/evals/integration/test_gate_review_inquiry_records.sh +42 -35
  856. package/dist/pi/evals/integration/test_goal_fit_hook.sh +13 -5
  857. package/dist/pi/evals/integration/test_goal_fit_narrative_exclusion.sh +68 -0
  858. package/dist/pi/evals/integration/test_narrative_evals.sh +174 -0
  859. package/dist/pi/evals/integration/test_narrative_grounded_envelope.sh +280 -0
  860. package/dist/pi/evals/integration/test_narrative_grounding_validator.sh +166 -0
  861. package/dist/pi/evals/integration/test_narrative_intent_annotation.sh +205 -0
  862. package/dist/pi/evals/integration/test_narrative_prose_renderer.sh +239 -0
  863. package/dist/pi/evals/integration/test_narrative_redaction_failclosed.sh +120 -0
  864. package/dist/pi/evals/integration/test_narrative_runtime_projection.sh +146 -0
  865. package/dist/pi/evals/integration/test_narrative_source_contract.sh +228 -0
  866. package/dist/pi/evals/integration/test_narrative_trust_isolation.sh +408 -0
  867. package/dist/pi/evals/integration/test_plain_stop_messaging.sh +91 -0
  868. package/dist/pi/evals/integration/test_session_resume_roundtrip.sh +228 -0
  869. package/dist/pi/evals/integration/test_telemetry_action_class.sh +265 -0
  870. package/dist/pi/evals/integration/test_telemetry_delegation.sh +291 -0
  871. package/dist/pi/evals/integration/test_telemetry_sanitize_usage.sh +155 -0
  872. package/dist/pi/evals/integration/test_telemetry_task_slug.sh +158 -0
  873. package/dist/pi/evals/integration/test_telemetry_tool_outcome.sh +279 -0
  874. package/dist/pi/evals/integration/test_workflow_sidecar_writer.sh +111 -2
  875. package/dist/pi/evals/run.sh +12 -0
  876. package/dist/pi/evals/static/test_library_exports.sh +5 -0
  877. package/dist/pi/install.sh +1 -1
  878. package/dist/pi/schemas/grounded-execution-narrative.schema.json +292 -0
  879. package/dist/pi/schemas/narrative-eval-result.schema.json +205 -0
  880. package/dist/pi/schemas/narrative-runtime-projection.schema.json +134 -0
  881. package/dist/pi/schemas/narrative-source-manifest.schema.json +294 -0
  882. package/dist/pi/scripts/check-hachure-boundary.mjs +81 -0
  883. package/dist/pi/scripts/hooks/stop-goal-fit.js +182 -9
  884. package/dist/pi/scripts/hooks/workflow-steering.js +160 -19
  885. package/dist/pi/scripts/telemetry/economics-record.schema.json +1 -1
  886. package/dist/pi/scripts/telemetry/economics-record.sh +47 -3
  887. package/dist/pi/scripts/telemetry/lib/session.sh +3 -0
  888. package/dist/pi/scripts/telemetry/lib/transport.sh +12 -3
  889. package/dist/pi/scripts/telemetry/telemetry.sh +480 -59
  890. package/docs/context-map.md +4 -0
  891. package/docs/decisions/index.md +1 -0
  892. package/docs/decisions/writer-observed-execution.md +51 -0
  893. package/docs/fixture-ownership.md +5 -1
  894. package/docs/migrations.md +20 -0
  895. package/docs/public-workflow-cli.md +9 -0
  896. package/docs/spec/builder-flow-runtime.md +49 -8
  897. package/docs/spec/runtime-hook-surface.md +29 -1
  898. package/docs/specs/economics-record-contract.md +1 -1
  899. package/docs/specs/harness-capability-matrix.md +63 -21
  900. package/docs/workflow-usage-guide.md +4 -1
  901. package/evals/ci/run-baseline.sh +38 -0
  902. package/evals/fixtures/narrative-evals/README.md +62 -0
  903. package/evals/fixtures/narrative-evals/corpus.json +129 -0
  904. package/evals/fixtures/narrative-evals/scorer.mjs +522 -0
  905. package/evals/fixtures/narrative-grounding-validator/corpus.json +20 -0
  906. package/evals/fixtures/narrative-grounding-validator/prompt-injection-adversarial.txt +1 -0
  907. package/evals/fixtures/narrative-grounding-validator/prompt-injection-control.txt +1 -0
  908. package/evals/fixtures/narrative-grounding-validator/scorer.mjs +201 -0
  909. package/evals/fixtures/narrative-prose-renderer/corpus.json +15 -0
  910. package/evals/fixtures/narrative-prose-renderer/scorer.mjs +201 -0
  911. package/evals/fixtures/narrative-sources/expected-capture-completeness.json +13 -0
  912. package/evals/fixtures/narrative-sources/flow/runs/run-fixture/report.json +1 -0
  913. package/evals/fixtures/narrative-sources/flow/runs/run-fixture/state.json +1 -0
  914. package/evals/fixtures/narrative-sources/flow/runs/run-runtime/state.json +1 -0
  915. package/evals/fixtures/narrative-sources/repo/created.txt +1 -0
  916. package/evals/fixtures/narrative-sources/repo/fixture.txt +1 -0
  917. package/evals/fixtures/narrative-sources/session/agents/agent-fixture/events.jsonl +2 -0
  918. package/evals/fixtures/narrative-sources/session/agents/nested-worker/events.jsonl +1 -0
  919. package/evals/fixtures/narrative-sources/session/trust.bundle +1 -0
  920. package/evals/fixtures/narrative-sources/telemetry/full.jsonl +3 -0
  921. package/evals/fixtures/narrative-sources/telemetry/runtime.jsonl +4 -0
  922. package/evals/fixtures/narrative-sources/transcripts/session.txt +1 -0
  923. package/evals/integration/test_capability_declarations.sh +183 -0
  924. package/evals/integration/test_economics_record.sh +42 -0
  925. package/evals/integration/test_fixture_retirement_audit.sh +2 -2
  926. package/evals/integration/test_gate_review_inquiry_records.sh +42 -35
  927. package/evals/integration/test_goal_fit_hook.sh +13 -5
  928. package/evals/integration/test_goal_fit_narrative_exclusion.sh +68 -0
  929. package/evals/integration/test_narrative_evals.sh +174 -0
  930. package/evals/integration/test_narrative_grounded_envelope.sh +280 -0
  931. package/evals/integration/test_narrative_grounding_validator.sh +166 -0
  932. package/evals/integration/test_narrative_intent_annotation.sh +205 -0
  933. package/evals/integration/test_narrative_prose_renderer.sh +239 -0
  934. package/evals/integration/test_narrative_redaction_failclosed.sh +120 -0
  935. package/evals/integration/test_narrative_runtime_projection.sh +146 -0
  936. package/evals/integration/test_narrative_source_contract.sh +228 -0
  937. package/evals/integration/test_narrative_trust_isolation.sh +408 -0
  938. package/evals/integration/test_plain_stop_messaging.sh +91 -0
  939. package/evals/integration/test_session_resume_roundtrip.sh +228 -0
  940. package/evals/integration/test_telemetry_action_class.sh +265 -0
  941. package/evals/integration/test_telemetry_delegation.sh +291 -0
  942. package/evals/integration/test_telemetry_sanitize_usage.sh +155 -0
  943. package/evals/integration/test_telemetry_task_slug.sh +158 -0
  944. package/evals/integration/test_telemetry_tool_outcome.sh +279 -0
  945. package/evals/integration/test_workflow_sidecar_writer.sh +111 -2
  946. package/evals/run.sh +12 -0
  947. package/evals/static/test_library_exports.sh +5 -0
  948. package/package.json +9 -5
  949. package/schemas/grounded-execution-narrative.schema.json +292 -0
  950. package/schemas/narrative-eval-result.schema.json +205 -0
  951. package/schemas/narrative-runtime-projection.schema.json +134 -0
  952. package/schemas/narrative-source-manifest.schema.json +294 -0
  953. package/scripts/check-hachure-boundary.mjs +81 -0
  954. package/scripts/hooks/stop-goal-fit.js +182 -9
  955. package/scripts/hooks/workflow-steering.js +160 -19
  956. package/scripts/telemetry/economics-record.schema.json +1 -1
  957. package/scripts/telemetry/economics-record.sh +47 -3
  958. package/scripts/telemetry/lib/session.sh +3 -0
  959. package/scripts/telemetry/lib/transport.sh +12 -3
  960. package/scripts/telemetry/telemetry.sh +480 -59
  961. package/src/builder-flow-runtime.ts +102 -1
  962. package/src/builder-gate-action-envelope.ts +216 -37
  963. package/src/builder-lifecycle-authority.ts +48 -0
  964. package/src/cli/builder-flow-runtime.test.mjs +220 -7
  965. package/src/cli/builder-run.ts +71 -1
  966. package/src/cli/capability-declarations.test.mjs +117 -0
  967. package/src/cli/continuation-driver.test.mjs +332 -10
  968. package/src/cli/kit-metadata-security.test.mjs +90 -2
  969. package/src/cli/narrative-arch-isolation.test.mjs +198 -0
  970. package/src/cli/narrative-envelope.test.mjs +367 -0
  971. package/src/cli/narrative-grounding-validator.test.mjs +322 -0
  972. package/src/cli/narrative-intent.test.mjs +177 -0
  973. package/src/cli/narrative-policy-filter.test.mjs +66 -0
  974. package/src/cli/narrative-projection.test.mjs +236 -0
  975. package/src/cli/narrative-readers.test.mjs +196 -0
  976. package/src/cli/narrative-render.test.mjs +221 -0
  977. package/src/cli/narrative-render.ts +589 -0
  978. package/src/cli/narrative-resolver.test.mjs +114 -0
  979. package/src/cli/narrative-snapshot.test.mjs +149 -0
  980. package/src/cli/narrative-source-ids.test.mjs +84 -0
  981. package/src/cli/narrative-sources.ts +276 -0
  982. package/src/cli/narrative-statements.test.mjs +369 -0
  983. package/src/cli/narrative-turn-spine.test.mjs +74 -0
  984. package/src/cli/public-api.test.mjs +17 -0
  985. package/src/cli/public-contracts.ts +95 -0
  986. package/src/cli/sidecar-pure-helpers.test.mjs +216 -24
  987. package/src/cli/trust-bundle-policy-order.test.mjs +134 -1
  988. package/src/cli/workflow-sidecar.ts +563 -167
  989. package/src/cli/workflow.ts +15 -1
  990. package/src/cli/writer-observed-execution.test.mjs +102 -0
  991. package/src/cli.ts +8 -0
  992. package/src/continuation-driver.ts +32 -3
  993. package/src/continuation-validation.ts +362 -4
  994. package/src/flow-kit/action-metadata.ts +20 -1
  995. package/src/index.ts +241 -0
  996. package/src/lib/capability-declarations.ts +261 -0
  997. package/src/narrative/envelope.ts +624 -0
  998. package/src/narrative/eval-result.ts +175 -0
  999. package/src/narrative/grounding-validator.ts +610 -0
  1000. package/src/narrative/integrity.ts +53 -0
  1001. package/src/narrative/intent-economics.ts +119 -0
  1002. package/src/narrative/intent.ts +216 -0
  1003. package/src/narrative/policy-filter.ts +66 -0
  1004. package/src/narrative/projection.ts +530 -0
  1005. package/src/narrative/readers.ts +427 -0
  1006. package/src/narrative/render.ts +82 -0
  1007. package/src/narrative/resolver.ts +195 -0
  1008. package/src/narrative/snapshot.ts +365 -0
  1009. package/src/narrative/source-ids.ts +294 -0
  1010. package/src/narrative/statements.ts +423 -0
  1011. package/src/narrative/turn-spine.ts +99 -0
  1012. package/src/tools/build-universal-bundles.ts +8 -0
  1013. package/src/tools/generate-capability-matrix.ts +215 -0
  1014. package/src/tools/validate-source-tree.ts +5 -1
  1015. package/build/src/cli/sidecar-claim-explain.d.ts +0 -45
  1016. package/build/src/cli/sidecar-claim-explain.js +0 -87
  1017. package/dist/base/build/src/cli/sidecar-claim-explain.d.ts +0 -45
  1018. package/dist/base/build/src/cli/sidecar-claim-explain.js +0 -87
  1019. package/dist/claude-code/build/src/cli/sidecar-claim-explain.d.ts +0 -45
  1020. package/dist/claude-code/build/src/cli/sidecar-claim-explain.js +0 -87
  1021. package/dist/codex/build/src/cli/sidecar-claim-explain.d.ts +0 -45
  1022. package/dist/codex/build/src/cli/sidecar-claim-explain.js +0 -87
  1023. package/dist/kiro/build/src/cli/sidecar-claim-explain.d.ts +0 -45
  1024. package/dist/kiro/build/src/cli/sidecar-claim-explain.js +0 -87
  1025. package/dist/opencode/build/src/cli/sidecar-claim-explain.d.ts +0 -45
  1026. package/dist/opencode/build/src/cli/sidecar-claim-explain.js +0 -87
  1027. package/dist/pi/build/src/cli/sidecar-claim-explain.d.ts +0 -45
  1028. package/dist/pi/build/src/cli/sidecar-claim-explain.js +0 -87
  1029. package/src/cli/sidecar-claim-explain.ts +0 -130
@@ -21,6 +21,83 @@ normalize_tool_name() {
21
21
  esac
22
22
  }
23
23
 
24
+ # classify_action_class — normalized cross-runtime activity taxonomy (#582).
25
+ # Given a RAW tool_name and its compact tool_input JSON, echoes ONE of the
26
+ # action classes {edit, search, test, git, build, web, read}, or empty when the
27
+ # tool is not classifiable (delegation / unknown / ambiguous shell -> no class;
28
+ # the field is then ABSENT, never fabricated). Additive & orthogonal to
29
+ # normalize_tool_name (canonical tool identity): this describes WHAT KIND of
30
+ # activity the tool performs. Privacy: for shell tools the command is read
31
+ # transiently ONLY to extract the leading (and 2nd/3rd) verb token; the raw
32
+ # command/args are never stored to derive the class. Any jq hiccup degrades to
33
+ # empty and never blocks the event.
34
+ classify_action_class() {
35
+ local tool_name="$1" tool_input="$2"
36
+ [[ -z "$tool_input" ]] && tool_input="null"
37
+ case "$tool_name" in
38
+ Edit|Write|MultiEdit|NotebookEdit|apply_patch|fs_write|write|code)
39
+ echo "edit" ;;
40
+ Grep|Glob|find|search)
41
+ echo "search" ;;
42
+ Read|fs_read|NotebookRead)
43
+ echo "read" ;;
44
+ WebFetch|WebSearch|web_search|web_fetch)
45
+ echo "web" ;;
46
+ Bash|bash|shell|execute_bash)
47
+ # Bash-family verb sub-classification. Reuses #581's leading-token
48
+ # extraction (resolve_delegation_targets): peel one bash/sh/zsh -c
49
+ # wrapper, strip leading VAR=val env-assignments, then match the WHOLE
50
+ # leading token (word-boundary: gitfoo / /path/git-helper / echo git MUST
51
+ # NOT match git). test-vs-build for pkg-runners (npm/pnpm/yarn/bun) is
52
+ # disambiguated by the 2nd (and 3rd for `run <script>`) token; a bare
53
+ # runner / unknown script -> empty (NO guess). The command is read
54
+ # transiently and never stored (privacy).
55
+ echo "$tool_input" | jq -r '
56
+ ((.command // "") | if type=="string" then . else "" end) as $cmd
57
+ | ($cmd | gsub("^\\s+|\\s+$";"")) as $s
58
+ | if $s=="" then ""
59
+ else
60
+ ( if ($s|test("^(?:bash|sh|zsh)\\s+-\\S*c\\s+\\x27[\\s\\S]*\\x27\\s*$"))
61
+ then ($s|capture("^(?:bash|sh|zsh)\\s+-\\S*c\\s+\\x27(?<i>[\\s\\S]*)\\x27\\s*$")|.i)
62
+ elif ($s|test("^(?:bash|sh|zsh)\\s+-\\S*c\\s+\\x22[\\s\\S]*\\x22\\s*$"))
63
+ then ($s|capture("^(?:bash|sh|zsh)\\s+-\\S*c\\s+\\x22(?<i>[\\s\\S]*)\\x22\\s*$")|.i)
64
+ else $s end
65
+ ) as $inner0
66
+ | ($inner0 | gsub("^\\s+|\\s+$";"")) as $inner
67
+ | ( {r:$inner}
68
+ | until( (.r|test("^[A-Za-z_][A-Za-z0-9_]*=\\S*\\s+\\S")|not);
69
+ .r |= (capture("^[A-Za-z_][A-Za-z0-9_]*=\\S*\\s+(?<rest>\\S[\\s\\S]*)$")|.rest) )
70
+ | .r ) as $rest
71
+ | ($rest | gsub("^\\s+|\\s+$";"")) as $rt
72
+ | (if $rt=="" then [] else [$rt | splits("\\s+")] end) as $toks
73
+ | ($toks[0] // "") as $t0
74
+ | ($toks[1] // "") as $t1
75
+ | ($toks[2] // "") as $t2
76
+ | if $t0=="git" then "git"
77
+ elif ($t0=="npm" or $t0=="pnpm" or $t0=="yarn" or $t0=="bun") then
78
+ ( if $t1=="test" then "test"
79
+ elif ($t1=="run" and ($t2|test("^test([:_-]|$)"))) then "test"
80
+ elif ($t1=="run" and ($t2|test("^build([:_-]|$)"))) then "build"
81
+ else "" end )
82
+ elif ($t0=="pytest" or $t0=="jest" or $t0=="vitest" or $t0=="mocha" or $t0=="tox") then "test"
83
+ elif $t0=="go" then (if $t1=="test" then "test" elif $t1=="build" then "build" else "" end)
84
+ elif $t0=="cargo" then (if $t1=="test" then "test" elif $t1=="build" then "build" else "" end)
85
+ elif $t0=="make" then
86
+ ( if $t1=="" then "build"
87
+ elif ($t1|test("^test([:_-]|$)")) then "test"
88
+ elif ($t1|test("^build([:_-]|$)")) then "build"
89
+ else "" end )
90
+ elif ($t0=="tsc" or $t0=="webpack") then "build"
91
+ elif ($t0=="vite" and $t1=="build") then "build"
92
+ else "" end
93
+ end
94
+ ' 2>/dev/null || echo ""
95
+ ;;
96
+ *)
97
+ echo "" ;;
98
+ esac
99
+ }
100
+
24
101
  telemetry_session_id() {
25
102
  local event_type="$1" agent_name="$2"
26
103
  local session_id=""
@@ -107,8 +184,20 @@ build_base_event() {
107
184
 
108
185
  add_hook_context() {
109
186
  local event="$1" event_type="$2" stdin_json="$3"
110
- local cwd tty_name pid runtime_session_id runtime_turn_id transcript_path hook_event_name model_name source stop_hook_active last_assistant_message raw_hook_input
187
+ local cwd tty_name pid runtime_session_id runtime_turn_id transcript_path hook_event_name model_name source stop_hook_active last_assistant_message raw_hook_input task_slug
111
188
  cwd=$(echo "$stdin_json" | jq -r '.cwd // ""')
189
+ # Work-item attribution: stamp the active Builder run's slug (from the same
190
+ # current.json .active_slug the economics relay reads) so tool/turn events can
191
+ # be grouped per work item downstream. Absent for non-Builder sessions — never
192
+ # fabricated. Only the slug string is stored; no prompt/args/file content.
193
+ task_slug=""
194
+ if [[ -n "$cwd" ]]; then
195
+ if [[ -f "$cwd/.kontourai/flow-agents/current.json" ]]; then
196
+ task_slug=$(jq -r '.active_slug // .artifact_dir // empty' "$cwd/.kontourai/flow-agents/current.json" 2>/dev/null)
197
+ elif [[ -f "$cwd/.flow-agents/current.json" ]]; then
198
+ task_slug=$(jq -r '.active_slug // .artifact_dir // empty' "$cwd/.flow-agents/current.json" 2>/dev/null)
199
+ fi
200
+ fi
112
201
  runtime_session_id=$(echo "$stdin_json" | jq -r '.session_id // ""')
113
202
  runtime_turn_id=$(echo "$stdin_json" | jq -r '.turn_id // ""')
114
203
  transcript_path=$(echo "$stdin_json" | jq -r '.transcript_path // ""')
@@ -133,6 +222,7 @@ add_hook_context() {
133
222
  --arg source "$source" \
134
223
  --arg stop_hook_active "$stop_hook_active" \
135
224
  --arg last_assistant_message "$last_assistant_message" \
225
+ --arg task_slug "$task_slug" \
136
226
  --argjson raw "$raw_hook_input" \
137
227
  '. + {
138
228
  hook: {
@@ -146,7 +236,8 @@ add_hook_context() {
146
236
  last_assistant_message: $last_assistant_message,
147
237
  raw_input: $raw
148
238
  }
149
- }'
239
+ }
240
+ + (if $task_slug == "" then {} else {task_slug: $task_slug} end)'
150
241
  }
151
242
 
152
243
  add_runtime_context() {
@@ -200,100 +291,408 @@ add_user_prompt_data() {
200
291
 
201
292
  add_tool_event_data() {
202
293
  local event="$1" event_type="$2" stdin_json="$3"
203
- local tool_name tool_normalized_name tool_input tool_output permission_description
294
+ local tool_name tool_normalized_name tool_input tool_output permission_description tool_action
204
295
  tool_name=$(echo "$stdin_json" | jq -r '.tool_name // ""')
205
296
  tool_normalized_name=$(normalize_tool_name "$tool_name")
206
297
  tool_input=$(echo "$stdin_json" | jq -c '.tool_input // null')
207
298
  tool_output=$(echo "$stdin_json" | jq -c '.tool_response // null')
208
299
  permission_description=$(echo "$stdin_json" | jq -r '.tool_input.description // ""')
300
+ # #582: normalized action class {edit,search,test,git,build,web,read}, or
301
+ # empty when unclassifiable. Stamped additively inside .tool below (guarded so
302
+ # a classifier hiccup degrades to NO .tool.action, never a dropped event).
303
+ tool_action=$(classify_action_class "$tool_name" "$tool_input")
209
304
 
210
305
  if [[ "$event_type" == "preToolUse" ]]; then
211
306
  event=$(echo "$event" | jq -c \
212
307
  --arg tn "$tool_name" \
213
308
  --arg nn "$tool_normalized_name" \
309
+ --arg ac "$tool_action" \
214
310
  --argjson ti "$tool_input" \
215
- '. + {tool: {name: $tn, normalized_name: $nn, input: $ti}}')
311
+ '. + {tool: ({name: $tn, normalized_name: $nn, input: $ti} + (if $ac == "" then {} else {action: $ac} end))}')
216
312
  elif [[ "$event_type" == "permissionRequest" || "$event_type" == "PermissionRequest" ]]; then
217
313
  event=$(echo "$event" | jq -c \
218
314
  --arg tn "$tool_name" \
219
315
  --arg nn "$tool_normalized_name" \
316
+ --arg ac "$tool_action" \
220
317
  --argjson ti "$tool_input" \
221
318
  --arg desc "$permission_description" \
222
- '. + {tool: {name: $tn, normalized_name: $nn, input: $ti}, permission: {description: $desc}}')
319
+ '. + {tool: ({name: $tn, normalized_name: $nn, input: $ti} + (if $ac == "" then {} else {action: $ac} end)), permission: {description: $desc}}')
223
320
  else
224
321
  event=$(echo "$event" | jq -c \
225
322
  --arg tn "$tool_name" \
226
323
  --arg nn "$tool_normalized_name" \
324
+ --arg ac "$tool_action" \
227
325
  --argjson to "$tool_output" \
228
- '. + {tool: {name: $tn, normalized_name: $nn, output: $to}}')
326
+ '. + {tool: ({name: $tn, normalized_name: $nn, output: $to} + (if $ac == "" then {} else {action: $ac} end))}')
229
327
  fi
230
328
 
231
329
  echo "$event"
232
330
  }
233
331
 
332
+ # resolve_delegation_targets — single source of truth for the delegation
333
+ # vocabulary (#581 D1). Given a RAW tool_name and its compact tool_input JSON,
334
+ # echoes a JSON array of delegation target identities, or [] when the tool does
335
+ # not delegate. Both the standalone agent.delegate event (emit_delegation_event)
336
+ # and the additive on-record .delegation enrichment (add_tool_data_and_emit_
337
+ # delegation) call this, so the two can never drift. Privacy: only target
338
+ # identities (agent type / "codex") are produced — never command args or prompt
339
+ # content. Any jq hiccup degrades to [] and never blocks the event.
340
+ resolve_delegation_targets() {
341
+ local tool_name="$1" tool_input="$2"
342
+ [[ -z "$tool_input" ]] && tool_input="null"
343
+ case "$tool_name" in
344
+ InvokeSubagents)
345
+ echo "$tool_input" | jq -c '.targets // []' 2>/dev/null || echo '[]'
346
+ ;;
347
+ spawn_agent)
348
+ echo "$tool_input" | jq -c '
349
+ ((.agent_type // "default") | tostring) as $t
350
+ | if ($t != "" and $t != "null") then [$t] else [] end
351
+ ' 2>/dev/null || echo '[]'
352
+ ;;
353
+ use_subagent|subagent|"delegate to a specialist agent")
354
+ echo "$tool_input" | jq -c '
355
+ if (.targets? | type) == "array" then .targets
356
+ elif (.subagents? | type) == "array" then .subagents | map(.agent_name // .agent // .subagent_type // .name // "subagent")
357
+ elif (.content.subagents? | type) == "array" then .content.subagents | map(.agent_name // .agent // .subagent_type // .name // "subagent")
358
+ elif (.agent_name? // .agent? // .subagent_type? // empty) != "" then [(.agent_name // .agent // .subagent_type)]
359
+ else ["subagent"]
360
+ end
361
+ ' 2>/dev/null || echo '[]'
362
+ ;;
363
+ Task|Agent)
364
+ echo "$tool_input" | jq -c '
365
+ ((.subagent_type // .agent_type // .agent // "general-purpose") | tostring) as $t
366
+ | if ($t != "" and $t != "null") then [$t] else [] end
367
+ ' 2>/dev/null || echo '[]'
368
+ ;;
369
+ Bash|bash|shell|execute_bash)
370
+ # Direct-CLI Codex (#581 D3): target is "codex" iff the command's FIRST
371
+ # real shell token is exactly `codex`. Mirrors _is_ambiguous_absence's
372
+ # unwrap/strip discipline — peel one `bash -lc '...'` / `sh -c "..."`
373
+ # wrapper, strip leading VAR=val env-assignments, then match the WHOLE
374
+ # first token (word-boundary: codexfoo, mycodex, /x/codex-helper MUST NOT
375
+ # match). The command is read transiently and never stored (privacy).
376
+ echo "$tool_input" | jq -c '
377
+ ((.command // "") | if type=="string" then . else "" end) as $cmd
378
+ | ($cmd | gsub("^\\s+|\\s+$";"")) as $s
379
+ | if $s=="" then []
380
+ else
381
+ ( if ($s|test("^(?:bash|sh|zsh)\\s+-\\S*c\\s+\\x27[\\s\\S]*\\x27\\s*$"))
382
+ then ($s|capture("^(?:bash|sh|zsh)\\s+-\\S*c\\s+\\x27(?<i>[\\s\\S]*)\\x27\\s*$")|.i)
383
+ elif ($s|test("^(?:bash|sh|zsh)\\s+-\\S*c\\s+\\x22[\\s\\S]*\\x22\\s*$"))
384
+ then ($s|capture("^(?:bash|sh|zsh)\\s+-\\S*c\\s+\\x22(?<i>[\\s\\S]*)\\x22\\s*$")|.i)
385
+ else $s end
386
+ ) as $inner0
387
+ | ($inner0 | gsub("^\\s+|\\s+$";"")) as $inner
388
+ | ( {r:$inner}
389
+ | until( (.r|test("^[A-Za-z_][A-Za-z0-9_]*=\\S*\\s+\\S")|not);
390
+ .r |= (capture("^[A-Za-z_][A-Za-z0-9_]*=\\S*\\s+(?<rest>\\S[\\s\\S]*)$")|.rest) )
391
+ | .r ) as $rest
392
+ | (($rest|gsub("^\\s+|\\s+$";"")) as $rt | (first($rt|splits("\\s+")) // "")) as $first
393
+ | if $first=="codex" then ["codex"] else [] end
394
+ end
395
+ ' 2>/dev/null || echo '[]'
396
+ ;;
397
+ *)
398
+ echo '[]'
399
+ ;;
400
+ esac
401
+ }
402
+
234
403
  emit_delegation_event() {
235
404
  local event="$1" event_type="$2" stdin_json="$3"
236
- local tool_name tool_input
405
+ # The standalone agent.delegate event stays preToolUse-only (#581 D4) with
406
+ # targets IDENTICAL to pre-#581 for every existing vocabulary case.
407
+ case "$event_type" in
408
+ preToolUse|PreToolUse) ;;
409
+ *) return 0 ;;
410
+ esac
411
+ local tool_name
237
412
  tool_name=$(echo "$stdin_json" | jq -r '.tool_name // ""')
413
+ # Direct-CLI Codex is a Bash-family tool that never produced an agent.delegate
414
+ # event before #581; it is surfaced SOLELY via the additive on-record
415
+ # .delegation, so the agent.delegate stream (and delegation COUNTS) stay
416
+ # byte-identical to before. Only the subagent-tool vocabulary emits here.
417
+ case "$tool_name" in
418
+ Bash|bash|shell|execute_bash) return 0 ;;
419
+ esac
420
+ local tool_input targets
238
421
  tool_input=$(echo "$stdin_json" | jq -c '.tool_input // null')
239
-
240
- if [[ "$tool_name" == "InvokeSubagents" && "$event_type" == "preToolUse" ]]; then
241
- local targets
242
- targets=$(echo "$tool_input" | jq -c '.targets // []')
243
- if [[ "$targets" != "[]" ]]; then
244
- local delegate_event
245
- delegate_event=$(echo "$event" | jq -c \
246
- --argjson targets "$targets" \
247
- '.event_type = "agent.delegate" | . + {delegation: {targets: $targets}} | del(.tool)')
248
- transport_emit "$delegate_event"
249
- fi
250
- elif [[ "$tool_name" == "spawn_agent" && "$event_type" == "preToolUse" ]]; then
251
- local target
252
- target=$(echo "$tool_input" | jq -r '.agent_type // "default"')
253
- if [[ -n "$target" && "$target" != "null" ]]; then
254
- local delegate_event
255
- delegate_event=$(echo "$event" | jq -c \
256
- --arg target "$target" \
257
- '.event_type = "agent.delegate" | . + {delegation: {targets: [$target]}} | del(.tool)')
258
- transport_emit "$delegate_event"
259
- fi
260
- elif [[ "$tool_name" == "use_subagent" || "$tool_name" == "subagent" || "$tool_name" == "delegate to a specialist agent" ]] && [[ "$event_type" == "preToolUse" ]]; then
261
- local targets
262
- targets=$(echo "$tool_input" | jq -c '
263
- if (.targets? | type) == "array" then .targets
264
- elif (.subagents? | type) == "array" then .subagents | map(.agent_name // .agent // .subagent_type // .name // "subagent")
265
- elif (.content.subagents? | type) == "array" then .content.subagents | map(.agent_name // .agent // .subagent_type // .name // "subagent")
266
- elif (.agent_name? // .agent? // .subagent_type? // empty) != "" then [(.agent_name // .agent // .subagent_type)]
267
- else ["subagent"]
268
- end
269
- ')
270
- if [[ "$targets" != "[]" ]]; then
271
- local delegate_event
272
- delegate_event=$(echo "$event" | jq -c \
273
- --argjson targets "$targets" \
274
- '.event_type = "agent.delegate" | . + {delegation: {targets: $targets}} | del(.tool)')
275
- transport_emit "$delegate_event"
276
- fi
277
- elif [[ "$tool_name" == "Task" || "$tool_name" == "Agent" ]] && [[ "$event_type" == "preToolUse" ]]; then
278
- local target
279
- target=$(echo "$tool_input" | jq -r '.subagent_type // .agent_type // .agent // "general-purpose"')
280
- if [[ -n "$target" && "$target" != "null" ]]; then
281
- local delegate_event
282
- delegate_event=$(echo "$event" | jq -c \
283
- --arg target "$target" \
284
- '.event_type = "agent.delegate" | . + {delegation: {targets: [$target]}} | del(.tool)')
285
- transport_emit "$delegate_event"
286
- fi
422
+ targets=$(resolve_delegation_targets "$tool_name" "$tool_input")
423
+ if [[ -n "$targets" && "$targets" != "[]" ]]; then
424
+ local delegate_event
425
+ delegate_event=$(echo "$event" | jq -c \
426
+ --argjson targets "$targets" \
427
+ '.event_type = "agent.delegate" | . + {delegation: {targets: $targets}} | del(.tool)')
428
+ transport_emit "$delegate_event"
287
429
  fi
288
430
  }
289
431
 
290
432
  add_tool_data_and_emit_delegation() {
291
433
  local event="$1" event_type="$2" stdin_json="$3"
292
434
  event=$(add_tool_event_data "$event" "$event_type" "$stdin_json")
435
+
436
+ # Emit the standalone agent.delegate event FIRST, from the UN-stamped tool
437
+ # event, so its shape stays byte-identical to pre-#581 (the on-record
438
+ # .delegation below is strictly additive — #581 D4).
293
439
  emit_delegation_event "$event" "$event_type" "$stdin_json"
440
+
441
+ # #581 W2: stamp .delegation = {targets, target} on the tool event whenever the
442
+ # invoked tool delegates (subagent tools OR direct-CLI codex).
443
+ # resolve_delegation_targets is the shared vocabulary source (D1). Guarded
444
+ # --argjson so a resolution hiccup degrades to no .delegation and never
445
+ # blackholes the event (D5). Privacy: target identities only.
446
+ local tool_name tool_input dtargets
447
+ tool_name=$(echo "$stdin_json" | jq -r '.tool_name // ""')
448
+ tool_input=$(echo "$stdin_json" | jq -c '.tool_input // null')
449
+ dtargets=$(resolve_delegation_targets "$tool_name" "$tool_input")
450
+ if [[ -n "$dtargets" && "$dtargets" != "[]" ]]; then
451
+ local stamped
452
+ stamped=$(echo "$event" | jq -c --argjson t "$dtargets" \
453
+ '. + {delegation: {targets: $t, target: ($t[0])}}' 2>/dev/null) || stamped=""
454
+ [[ -n "$stamped" ]] && event="$stamped"
455
+ fi
456
+
294
457
  echo "$event"
295
458
  }
296
459
 
460
+ # --- #580 tool.result enrichment: duration_ms / outcome / status -------------
461
+ # These three fields are added to the existing .tool object of tool.result
462
+ # records only (co-located with .tool.name/.tool.output). tool.invoke has no
463
+ # result yet and tool.permission_request is not a tool result, so neither is
464
+ # touched. Every unavailable signal degrades to null/ambiguous — never a
465
+ # fabricated value.
466
+
467
+ # Shared jq definitions for the deterministic outcome tri-state. This is a
468
+ # faithful port of scripts/hooks/evidence-capture.js `observeResult` (the
469
+ # canonical contract, docs/spec/runtime-hook-surface.md §2.5) into jq so the
470
+ # Claude hot path stays hermetic (no node subprocess). A drift-guard test
471
+ # (evals/integration/test_telemetry_tool_outcome.sh) feeds a shared fixture
472
+ # battery through BOTH this jq path and node observeResult and asserts they
473
+ # agree, so the port can never silently diverge from the canonical source.
474
+ # Regex note: \x27 / \x22 are the single/double quote chars (avoids embedding a
475
+ # literal quote inside this single-quoted bash string).
476
+ _TOOL_OUTCOME_JQ_DEFS='
477
+ def _clean(v):
478
+ (v) as $x
479
+ | if ($x|type)=="number" then (if $x==($x|floor) then $x else null end)
480
+ elif ($x|type)=="string"
481
+ then (($x|gsub("^\\s+|\\s+$";"")) as $t | if ($t|test("^-?[0-9]+$")) then ($t|tonumber) else null end)
482
+ else null end;
483
+ def _is_ambiguous_absence($text):
484
+ (($text | if type=="string" then . else "" end) | gsub("^\\s+|\\s+$";"")) as $s
485
+ | if $s=="" then false
486
+ else
487
+ ( if ($s|test("^(?:bash|sh|zsh)\\s+-\\S*c\\s+\\x27[\\s\\S]*\\x27\\s*$"))
488
+ then ($s|capture("^(?:bash|sh|zsh)\\s+-\\S*c\\s+\\x27(?<i>[\\s\\S]*)\\x27\\s*$")|.i)
489
+ elif ($s|test("^(?:bash|sh|zsh)\\s+-\\S*c\\s+\\x22[\\s\\S]*\\x22\\s*$"))
490
+ then ($s|capture("^(?:bash|sh|zsh)\\s+-\\S*c\\s+\\x22(?<i>[\\s\\S]*)\\x22\\s*$")|.i)
491
+ else $s end
492
+ ) as $inner0
493
+ | ($inner0 | gsub("^\\s+|\\s+$";"")) as $inner
494
+ | if $inner=="" then false
495
+ elif ($inner|test("^!\\s*")) then false
496
+ elif (($inner|test("\\|\\|")) or ($inner|test("&&"))) then false
497
+ else
498
+ ( {r:$inner}
499
+ | until( (.r|test("^[A-Za-z_][A-Za-z0-9_]*=\\S*\\s+\\S")|not);
500
+ .r |= (capture("^[A-Za-z_][A-Za-z0-9_]*=\\S*\\s+(?<rest>\\S[\\s\\S]*)$")|.rest) )
501
+ | .r ) as $rest
502
+ | if ($rest|test("\\|")) then false
503
+ else ( ($rest|gsub("^\\s+|\\s+$";"")) as $rt
504
+ | ([$rt|splits("\\s+")][0] // "") as $first
505
+ | ($first=="grep" or $first=="diff") )
506
+ end
507
+ end
508
+ end;
509
+ def _is_failure:
510
+ (.error) as $err
511
+ | ( ($err|type=="string") and (($err|gsub("^\\s+|\\s+$";""))|length>0) ) as $e1
512
+ | ( ($err|type=="object" or type=="array") and (($err|length)>0) ) as $e2
513
+ | ( [ (.tool_response // null), (.tool_output // null) ]
514
+ | map(select(type=="object"))
515
+ | any(
516
+ (.success==false)
517
+ or (.failed==true) or (.is_error==true) or (.isError==true)
518
+ or ((.error|type=="string") and ((.error|gsub("^\\s+|\\s+$";""))|length>0))
519
+ or ( ($err==null)
520
+ and (.stderr|type=="string")
521
+ and ((.stderr|gsub("^\\s+|\\s+$";""))|length>0)
522
+ and ( ((if (.stdout|type)=="string" then .stdout else "" end)|gsub("^\\s+|\\s+$";"")|length)==0 ) )
523
+ ) ) as $e3
524
+ | ($e1 or $e2 or $e3);
525
+ '
526
+
527
+ # Main program: derives {exitCode, observedResult} from the hook payload,
528
+ # folding a PostToolUseFailure event to fail. Consumes $et (event_type).
529
+ _TOOL_OUTCOME_JQ_MAIN='
530
+ ( [ (.tool_response // null), (.tool_output // null) ]
531
+ | map(select(type=="object"))
532
+ | [ .[] | (.exitCode, .exit_code, .exitcode, .status, .code, .returnCode, .return_code) ] ) as $srcCands
533
+ | ( $srcCands + [ .exitCode, .exit_code, .status, .code ] ) as $cands
534
+ | ( first( $cands[] | _clean(.) | select(.!=null) ) // null ) as $exit
535
+ | ((.tool_input.command // "") | if type=="string" then . else "" end) as $cmd
536
+ | ( if $exit != null
537
+ then ( if ($exit==1 and $cmd!="" and _is_ambiguous_absence($cmd))
538
+ then {exitCode:$exit, observedResult:"ambiguous"}
539
+ else {exitCode:$exit, observedResult:(if $exit==0 then "pass" else "fail" end)} end )
540
+ else ( if _is_failure then {exitCode:null, observedResult:"fail"} else {exitCode:null, observedResult:"ambiguous"} end )
541
+ end ) as $base
542
+ | ( if ($et=="PostToolUseFailure") then ($base + {observedResult:"fail"}) else $base end )
543
+ '
544
+
545
+ # Codex re-derivation: given a host-banner $code and $cmd, produce the
546
+ # observedResult string via the SAME tri-state (incl. the #362 grep/diff
547
+ # carve-out) so the codex path can never diverge from the jq/node contract.
548
+ _TOOL_OUTCOME_JQ_CODEX='
549
+ ( if ($code==0) then "pass"
550
+ elif ($code==1 and ($cmd|length)>0 and _is_ambiguous_absence($cmd)) then "ambiguous"
551
+ else "fail" end )
552
+ '
553
+
554
+ # now_epoch_ms — portable millisecond wall clock. Prefer bash5 $EPOCHREALTIME
555
+ # (µs precision) -> ms; else GNU `date +%s%3N` when it returns pure digits
556
+ # (BSD/macOS date echoes a literal "%3N", which is rejected); else the
557
+ # second-granular `date +%s`*1000 fallback (resolution-honest).
558
+ now_epoch_ms() {
559
+ local er="${EPOCHREALTIME:-}"
560
+ if [[ "$er" =~ ^([0-9]+)[.,]([0-9]{3}) ]]; then
561
+ printf '%s%s\n' "${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}"
562
+ return
563
+ fi
564
+ local gnu
565
+ gnu=$(date +%s%3N 2>/dev/null)
566
+ if [[ "$gnu" =~ ^[0-9]+$ ]]; then
567
+ printf '%s\n' "$gnu"
568
+ return
569
+ fi
570
+ printf '%s000\n' "$(date +%s)"
571
+ }
572
+
573
+ # tool_call_correlation_key — a best-effort key that is stable across a tool's
574
+ # invoke and its result. Prefers a host-provided call id; else a content hash
575
+ # of tool_name + compact(tool_input) via whichever portable hasher is present.
576
+ # Output is filesystem-safe (any char outside [A-Za-z0-9._-] -> '_'). The
577
+ # content-hash fallback can theoretically collide for two identical tool+input
578
+ # runs with overlapping lifetimes (the disclosed start_record_liveness gap) —
579
+ # correlation is best-effort and yields null rather than a wrong number.
580
+ tool_call_correlation_key() {
581
+ local stdin_json="$1"
582
+ local call_id key
583
+ call_id=$(printf '%s' "$stdin_json" | jq -r '.tool_use_id // .tool_call_id // .call_id // .id // ""' 2>/dev/null)
584
+ if [[ -n "$call_id" && "$call_id" != "null" ]]; then
585
+ key="id:${call_id}"
586
+ else
587
+ local tool_name tool_input hash
588
+ tool_name=$(printf '%s' "$stdin_json" | jq -r '.tool_name // ""' 2>/dev/null)
589
+ tool_input=$(printf '%s' "$stdin_json" | jq -c '.tool_input // null' 2>/dev/null)
590
+ hash=$(printf '%s%s' "$tool_name" "$tool_input" | { shasum 2>/dev/null || sha256sum 2>/dev/null || cksum; } | awk '{print $1}')
591
+ key="sha:${hash}"
592
+ fi
593
+ printf '%s' "$key" | tr -c 'A-Za-z0-9._-' '_'
594
+ }
595
+
596
+ tool_start_record_path() {
597
+ printf '%s\n' "${TELEMETRY_SESSION_DIR}/toolstart-${session_id}-$1"
598
+ }
599
+
600
+ # write_tool_start_record — records the tool's start ms on preToolUse so the
601
+ # matching result can compute duration_ms. Best-effort/non-blocking: any
602
+ # failure is swallowed and simply yields duration_ms:null downstream. The
603
+ # stored value is a timestamp only — never any args/output content (privacy).
604
+ write_tool_start_record() {
605
+ local stdin_json="$1"
606
+ [[ -z "${TELEMETRY_SESSION_DIR:-}" ]] && return 0
607
+ local key path
608
+ key=$(tool_call_correlation_key "$stdin_json") || return 0
609
+ [[ -z "$key" ]] && return 0
610
+ path=$(tool_start_record_path "$key")
611
+ mkdir -p "${TELEMETRY_SESSION_DIR}" 2>/dev/null || true
612
+ now_epoch_ms >"$path" 2>/dev/null || true
613
+ return 0
614
+ }
615
+
616
+ # add_tool_result_meta — enriches a tool.result event with the three #580
617
+ # fields on its existing .tool object: duration_ms (wall-clock ms since the
618
+ # matching invoke, or null when the start record is absent), outcome
619
+ # (deterministic pass|fail|ambiguous), and status (host exit code int or null).
620
+ # Never fails the hook.
621
+ add_tool_result_meta() {
622
+ local event="$1" event_type="$2" stdin_json="$3"
623
+
624
+ # --- duration_ms: read + unlink the matching start record ---
625
+ local duration_ms="null"
626
+ if [[ -n "${TELEMETRY_SESSION_DIR:-}" ]]; then
627
+ local key path start_ms end_ms
628
+ key=$(tool_call_correlation_key "$stdin_json")
629
+ if [[ -n "$key" ]]; then
630
+ path=$(tool_start_record_path "$key")
631
+ if [[ -f "$path" ]]; then
632
+ start_ms=$(cat "$path" 2>/dev/null)
633
+ rm -f "$path" 2>/dev/null || true
634
+ if [[ "$start_ms" =~ ^[0-9]+$ ]]; then
635
+ end_ms=$(now_epoch_ms)
636
+ if [[ "$end_ms" =~ ^[0-9]+$ ]]; then
637
+ duration_ms=$(( end_ms - start_ms ))
638
+ (( duration_ms < 0 )) && duration_ms=0
639
+ fi
640
+ fi
641
+ fi
642
+ fi
643
+ fi
644
+
645
+ # --- outcome/status: hermetic jq tri-state (canonical observeResult port) ---
646
+ local verdict outcome status
647
+ verdict=$(printf '%s' "$stdin_json" | jq -c --arg et "$event_type" \
648
+ "${_TOOL_OUTCOME_JQ_DEFS}${_TOOL_OUTCOME_JQ_MAIN}" 2>/dev/null)
649
+ [[ -z "$verdict" ]] && verdict='{"exitCode":null,"observedResult":"ambiguous"}'
650
+ status=$(printf '%s' "$verdict" | jq -c '.exitCode' 2>/dev/null)
651
+ outcome=$(printf '%s' "$verdict" | jq -r '.observedResult' 2>/dev/null)
652
+ [[ -z "$status" ]] && status="null"
653
+ [[ -z "$outcome" ]] && outcome="ambiguous"
654
+
655
+ # --- Codex-only exit-code resolution when the payload carried no clean code.
656
+ # Codex surfaces its exit code in the rollout banner, not the hook payload, so
657
+ # the jq scan alone yields ambiguous/null. Gated strictly to the codex runtime
658
+ # so the Claude path stays 100% hermetic (jq only, no node). An unreadable
659
+ # rollout leaves the honest ambiguous/null verdict untouched.
660
+ if [[ "${FLOW_AGENTS_TELEMETRY_RUNTIME:-}" == "codex" && "$status" == "null" ]]; then
661
+ local codex_lib
662
+ codex_lib="${TELEMETRY_DIR}/../hooks/lib/codex-exit-code.js"
663
+ if [[ -f "$codex_lib" ]]; then
664
+ local tpath call_id cmd code
665
+ tpath=$(printf '%s' "$stdin_json" | jq -r '.transcript_path // ""' 2>/dev/null)
666
+ call_id=$(printf '%s' "$stdin_json" | jq -r '.call_id // .tool_call_id // .id // ""' 2>/dev/null)
667
+ cmd=$(printf '%s' "$stdin_json" | jq -r '.tool_input.command // ""' 2>/dev/null)
668
+ if [[ -n "$tpath" ]]; then
669
+ code=$(FLOW_CODEX_LIB="$codex_lib" FLOW_TPATH="$tpath" FLOW_CALLID="$call_id" FLOW_CMD="$cmd" node -e '
670
+ try {
671
+ const m = require(process.env.FLOW_CODEX_LIB);
672
+ const c = m.readExitCodeFromRollout(process.env.FLOW_TPATH, {
673
+ callId: process.env.FLOW_CALLID || undefined,
674
+ command: process.env.FLOW_CMD || undefined,
675
+ });
676
+ if (Number.isInteger(c)) process.stdout.write(String(c));
677
+ } catch (e) {}
678
+ ' 2>/dev/null)
679
+ if [[ "$code" =~ ^-?[0-9]+$ ]]; then
680
+ status="$code"
681
+ outcome=$(jq -nr --argjson code "$code" --arg cmd "$cmd" \
682
+ "${_TOOL_OUTCOME_JQ_DEFS}${_TOOL_OUTCOME_JQ_CODEX}" 2>/dev/null)
683
+ [[ -z "$outcome" ]] && outcome="fail"
684
+ fi
685
+ fi
686
+ fi
687
+ fi
688
+
689
+ echo "$event" | jq -c \
690
+ --argjson dm "$duration_ms" \
691
+ --argjson st "$status" \
692
+ --arg oc "$outcome" \
693
+ '.tool = ((.tool // {}) + {duration_ms: $dm, outcome: $oc, status: $st})'
694
+ }
695
+
297
696
  # add_tool_usage_data — populates .usage on tool.invoke/tool.result events
298
697
  # (preToolUse/postToolUse only; see add_event_specific_data's explicit
299
698
  # permissionRequest exclusion) with the model/token/cost usage of the turn
@@ -315,14 +714,20 @@ add_tool_usage_data() {
315
714
  transcript_path=$(echo "$event" | jq -r '.hook.transcript_path // ""')
316
715
  hook_model=$(echo "$event" | jq -r '.hook.model // ""')
317
716
 
318
- local turn_usage
717
+ local turn_usage joined
319
718
  turn_usage=""
320
719
  if [[ -n "$transcript_path" ]]; then
321
720
  turn_usage=$(usage_last_turn_usage "$transcript_path")
322
721
  fi
323
722
 
324
723
  if [[ -n "$turn_usage" ]]; then
325
- echo "$event" | jq -c --argjson tu "$turn_usage" '. + {
724
+ # Guard the transcript-join jq. usage_last_turn_usage is well-formed today,
725
+ # but if it ever emits non-JSON (a future regression), `--argjson tu` errors
726
+ # to empty stdout, which would blackhole the ENTIRE tool event downstream
727
+ # (transport_emit drops an empty event). Degrade to the model-only / full-
728
+ # null tiers below instead of losing the record — consistent with this
729
+ # feature's "never invent, always degrade gracefully, never block" contract.
730
+ joined=$(echo "$event" | jq -c --argjson tu "$turn_usage" '. + {
326
731
  usage: {
327
732
  model: $tu.model,
328
733
  input_tokens: $tu.input_tokens,
@@ -332,8 +737,14 @@ add_tool_usage_data() {
332
737
  estimated_cost_usd: $tu.estimated_cost_usd,
333
738
  pricing_version: $tu.pricing_version
334
739
  }
335
- }'
336
- elif [[ -n "$hook_model" && "$hook_model" != "unknown" ]]; then
740
+ }' 2>/dev/null) || joined=""
741
+ if [[ -n "$joined" ]]; then
742
+ printf '%s\n' "$joined"
743
+ return
744
+ fi
745
+ fi
746
+
747
+ if [[ -n "$hook_model" && "$hook_model" != "unknown" ]]; then
337
748
  echo "$event" | jq -c --arg m "$hook_model" '. + {
338
749
  usage: {
339
750
  model: $m,
@@ -467,6 +878,16 @@ add_event_specific_data() {
467
878
  ;;
468
879
  preToolUse|PreToolUse|postToolUse|PostToolUse|PostToolUseFailure)
469
880
  event=$(add_tool_data_and_emit_delegation "$event" "$event_type" "$stdin_json")
881
+ case "$event_type" in
882
+ preToolUse|PreToolUse)
883
+ # #580: record the tool's start ms so its result can compute duration.
884
+ write_tool_start_record "$stdin_json"
885
+ ;;
886
+ postToolUse|PostToolUse|PostToolUseFailure)
887
+ # #580: add .tool.duration_ms / .tool.outcome / .tool.status.
888
+ event=$(add_tool_result_meta "$event" "$event_type" "$stdin_json")
889
+ ;;
890
+ esac
470
891
  if [[ "$TELEMETRY_USAGE_TRACKING" == "true" ]]; then
471
892
  event=$(add_tool_usage_data "$event")
472
893
  fi
@@ -59,7 +59,11 @@ Machine-readable workflow state lives beside Markdown artifacts in `.kontourai/f
59
59
  | builder-lifecycle-authorization.schema.json | Builder Lifecycle Authorization | https://kontourai.dev/schemas/builder-lifecycle-authorization.schema.json |
60
60
  | decision-record.schema.json | Flow Agents Decision Record | https://flow-agents.dev/schemas/decision-record.schema.json |
61
61
  | flow-agents-settings.schema.json | Flow Agents Settings | https://flow-agents.dev/schemas/flow-agents-settings.schema.json |
62
+ | grounded-execution-narrative.schema.json | Flow Agents Grounded Execution Narrative | https://flow-agents.dev/schemas/grounded-execution-narrative.schema.json |
62
63
  | lifecycle-authority-keys.schema.json | Lifecycle Authority Key Registry | https://kontourai.dev/schemas/lifecycle-authority-keys.schema.json |
64
+ | narrative-eval-result.schema.json | Flow Agents Narrative Eval Result | https://flow-agents.dev/schemas/narrative-eval-result.schema.json |
65
+ | narrative-runtime-projection.schema.json | Flow Agents Grounded Runtime Projection | https://flow-agents.dev/schemas/narrative-runtime-projection.schema.json |
66
+ | narrative-source-manifest.schema.json | Flow Agents Narrative Source Manifest | https://flow-agents.dev/schemas/narrative-source-manifest.schema.json |
63
67
  | workflow-acceptance.schema.json | Flow Agents Workflow Acceptance | https://flow-agents.dev/schemas/workflow-acceptance.schema.json |
64
68
  | workflow-critique.schema.json | Flow Agents Workflow Critique | https://flow-agents.dev/schemas/workflow-critique.schema.json |
65
69
  | workflow-evidence.schema.json | Flow Agents Workflow Evidence | https://flow-agents.dev/schemas/workflow-evidence.schema.json |
@@ -36,3 +36,4 @@ Numbered ADRs under `docs/adr/` are frozen history and are not listed here.
36
36
  | [typescript-source-policy](./typescript-source-policy.md) | current | TypeScript-first source policy |
37
37
  | [workflow-enforcement](./workflow-enforcement.md) | current | Workflow Enforcement |
38
38
  | [workflow-trust-state](./workflow-trust-state.md) | needs-decision | Workflow trust state |
39
+ | [writer-observed-execution](./writer-observed-execution.md) | current | Writer-observed execution |