@smthrs/harness 0.0.0-stage → 1.0.0-rc.3

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 (476) hide show
  1. package/CHANGELOG.md +387 -0
  2. package/LICENSE +21 -0
  3. package/README.md +138 -2
  4. package/dist/cjs/AgentEvent.d.ts +3092 -0
  5. package/dist/cjs/AgentEvent.d.ts.map +1 -0
  6. package/dist/cjs/AgentEvent.js +1116 -0
  7. package/dist/cjs/AgentEvent.js.map +7 -0
  8. package/dist/cjs/CallLedger.d.ts +378 -0
  9. package/dist/cjs/CallLedger.d.ts.map +1 -0
  10. package/dist/cjs/CallLedger.js +240 -0
  11. package/dist/cjs/CallLedger.js.map +7 -0
  12. package/dist/cjs/Cell.d.ts +774 -0
  13. package/dist/cjs/Cell.d.ts.map +1 -0
  14. package/dist/cjs/Cell.js +431 -0
  15. package/dist/cjs/Cell.js.map +7 -0
  16. package/dist/cjs/CellCalls.d.ts +115 -0
  17. package/dist/cjs/CellCalls.d.ts.map +1 -0
  18. package/dist/cjs/CellCalls.js +98 -0
  19. package/dist/cjs/CellCalls.js.map +7 -0
  20. package/dist/cjs/CellHistory.d.ts +102 -0
  21. package/dist/cjs/CellHistory.d.ts.map +1 -0
  22. package/dist/cjs/CellHistory.js +54 -0
  23. package/dist/cjs/CellHistory.js.map +7 -0
  24. package/dist/cjs/CellTurn.d.ts +1071 -0
  25. package/dist/cjs/CellTurn.d.ts.map +1 -0
  26. package/dist/cjs/CellTurn.js +2618 -0
  27. package/dist/cjs/CellTurn.js.map +7 -0
  28. package/dist/cjs/CellValidation.d.ts +94 -0
  29. package/dist/cjs/CellValidation.d.ts.map +1 -0
  30. package/dist/cjs/CellValidation.js +218 -0
  31. package/dist/cjs/CellValidation.js.map +7 -0
  32. package/dist/cjs/Compaction.d.ts +158 -0
  33. package/dist/cjs/Compaction.d.ts.map +1 -0
  34. package/dist/cjs/Compaction.js +189 -0
  35. package/dist/cjs/Compaction.js.map +7 -0
  36. package/dist/cjs/CompletionClaim.d.ts +801 -0
  37. package/dist/cjs/CompletionClaim.d.ts.map +1 -0
  38. package/dist/cjs/CompletionClaim.js +303 -0
  39. package/dist/cjs/CompletionClaim.js.map +7 -0
  40. package/dist/cjs/ContextWindow.d.ts +435 -0
  41. package/dist/cjs/ContextWindow.d.ts.map +1 -0
  42. package/dist/cjs/ContextWindow.js +319 -0
  43. package/dist/cjs/ContextWindow.js.map +7 -0
  44. package/dist/cjs/EngineLike.d.ts +546 -0
  45. package/dist/cjs/EngineLike.d.ts.map +1 -0
  46. package/dist/cjs/EngineLike.js +114 -0
  47. package/dist/cjs/EngineLike.js.map +7 -0
  48. package/dist/cjs/ExternalTranscript.d.ts +349 -0
  49. package/dist/cjs/ExternalTranscript.d.ts.map +1 -0
  50. package/dist/cjs/ExternalTranscript.js +826 -0
  51. package/dist/cjs/ExternalTranscript.js.map +7 -0
  52. package/dist/cjs/FailedCall.d.ts +132 -0
  53. package/dist/cjs/FailedCall.d.ts.map +1 -0
  54. package/dist/cjs/FailedCall.js +53 -0
  55. package/dist/cjs/FailedCall.js.map +7 -0
  56. package/dist/cjs/FlowBinding.d.ts +289 -0
  57. package/dist/cjs/FlowBinding.d.ts.map +1 -0
  58. package/dist/cjs/FlowBinding.js +251 -0
  59. package/dist/cjs/FlowBinding.js.map +7 -0
  60. package/dist/cjs/HarnessError.d.ts +57 -0
  61. package/dist/cjs/HarnessError.d.ts.map +1 -0
  62. package/dist/cjs/HarnessError.js +75 -0
  63. package/dist/cjs/HarnessError.js.map +7 -0
  64. package/dist/cjs/Judgement.d.ts +289 -0
  65. package/dist/cjs/Judgement.d.ts.map +1 -0
  66. package/dist/cjs/Judgement.js +240 -0
  67. package/dist/cjs/Judgement.js.map +7 -0
  68. package/dist/cjs/Monitor.d.ts +374 -0
  69. package/dist/cjs/Monitor.d.ts.map +1 -0
  70. package/dist/cjs/Monitor.js +233 -0
  71. package/dist/cjs/Monitor.js.map +7 -0
  72. package/dist/cjs/NarrowedCheck.d.ts +523 -0
  73. package/dist/cjs/NarrowedCheck.d.ts.map +1 -0
  74. package/dist/cjs/NarrowedCheck.js +263 -0
  75. package/dist/cjs/NarrowedCheck.js.map +7 -0
  76. package/dist/cjs/Notifications.d.ts +42 -0
  77. package/dist/cjs/Notifications.d.ts.map +1 -0
  78. package/dist/cjs/Notifications.js +177 -0
  79. package/dist/cjs/Notifications.js.map +7 -0
  80. package/dist/cjs/Plan.d.ts +127 -0
  81. package/dist/cjs/Plan.d.ts.map +1 -0
  82. package/dist/cjs/Plan.js +77 -0
  83. package/dist/cjs/Plan.js.map +7 -0
  84. package/dist/cjs/QuickJSSandbox.d.ts +151 -0
  85. package/dist/cjs/QuickJSSandbox.d.ts.map +1 -0
  86. package/dist/cjs/QuickJSSandbox.js +987 -0
  87. package/dist/cjs/QuickJSSandbox.js.map +7 -0
  88. package/dist/cjs/Relevance.d.ts +213 -0
  89. package/dist/cjs/Relevance.d.ts.map +1 -0
  90. package/dist/cjs/Relevance.js +183 -0
  91. package/dist/cjs/Relevance.js.map +7 -0
  92. package/dist/cjs/Sandbox.d.ts +637 -0
  93. package/dist/cjs/Sandbox.d.ts.map +1 -0
  94. package/dist/cjs/Sandbox.js +260 -0
  95. package/dist/cjs/Sandbox.js.map +7 -0
  96. package/dist/cjs/Steering.d.ts +464 -0
  97. package/dist/cjs/Steering.d.ts.map +1 -0
  98. package/dist/cjs/Steering.js +153 -0
  99. package/dist/cjs/Steering.js.map +7 -0
  100. package/dist/cjs/StructuredOutput.d.ts +252 -0
  101. package/dist/cjs/StructuredOutput.d.ts.map +1 -0
  102. package/dist/cjs/StructuredOutput.js +266 -0
  103. package/dist/cjs/StructuredOutput.js.map +7 -0
  104. package/dist/cjs/Sufficiency.d.ts +195 -0
  105. package/dist/cjs/Sufficiency.d.ts.map +1 -0
  106. package/dist/cjs/Sufficiency.js +110 -0
  107. package/dist/cjs/Sufficiency.js.map +7 -0
  108. package/dist/cjs/Supervisor.d.ts +719 -0
  109. package/dist/cjs/Supervisor.d.ts.map +1 -0
  110. package/dist/cjs/Supervisor.js +313 -0
  111. package/dist/cjs/Supervisor.js.map +7 -0
  112. package/dist/cjs/Tokens.d.ts +86 -0
  113. package/dist/cjs/Tokens.d.ts.map +1 -0
  114. package/dist/cjs/Tokens.js +72 -0
  115. package/dist/cjs/Tokens.js.map +7 -0
  116. package/dist/cjs/Transcript.d.ts +171 -0
  117. package/dist/cjs/Transcript.d.ts.map +1 -0
  118. package/dist/cjs/Transcript.js +342 -0
  119. package/dist/cjs/Transcript.js.map +7 -0
  120. package/dist/cjs/TruncatedOutput.d.ts +186 -0
  121. package/dist/cjs/TruncatedOutput.d.ts.map +1 -0
  122. package/dist/cjs/TruncatedOutput.js +143 -0
  123. package/dist/cjs/TruncatedOutput.js.map +7 -0
  124. package/dist/cjs/UnmovedTree.d.ts +113 -0
  125. package/dist/cjs/UnmovedTree.d.ts.map +1 -0
  126. package/dist/cjs/UnmovedTree.js +38 -0
  127. package/dist/cjs/UnmovedTree.js.map +7 -0
  128. package/dist/cjs/UnresolvedFailure.d.ts +196 -0
  129. package/dist/cjs/UnresolvedFailure.d.ts.map +1 -0
  130. package/dist/cjs/UnresolvedFailure.js +77 -0
  131. package/dist/cjs/UnresolvedFailure.js.map +7 -0
  132. package/dist/cjs/VacuousVerification.d.ts +237 -0
  133. package/dist/cjs/VacuousVerification.d.ts.map +1 -0
  134. package/dist/cjs/VacuousVerification.js +91 -0
  135. package/dist/cjs/VacuousVerification.js.map +7 -0
  136. package/dist/cjs/VariablesPanel.d.ts +117 -0
  137. package/dist/cjs/VariablesPanel.d.ts.map +1 -0
  138. package/dist/cjs/VariablesPanel.js +108 -0
  139. package/dist/cjs/VariablesPanel.js.map +7 -0
  140. package/dist/cjs/index.d.ts +172 -0
  141. package/dist/cjs/index.d.ts.map +1 -0
  142. package/dist/cjs/index.js +99 -0
  143. package/dist/cjs/index.js.map +7 -0
  144. package/dist/cjs/internal/bytes.d.ts +36 -0
  145. package/dist/cjs/internal/bytes.d.ts.map +1 -0
  146. package/dist/cjs/internal/bytes.js +57 -0
  147. package/dist/cjs/internal/bytes.js.map +7 -0
  148. package/dist/cjs/internal/cellPrompt.d.ts +122 -0
  149. package/dist/cjs/internal/cellPrompt.d.ts.map +1 -0
  150. package/dist/cjs/internal/cellPrompt.js +146 -0
  151. package/dist/cjs/internal/cellPrompt.js.map +7 -0
  152. package/dist/cjs/internal/compactable.d.ts +44 -0
  153. package/dist/cjs/internal/compactable.d.ts.map +1 -0
  154. package/dist/cjs/internal/compactable.js +56 -0
  155. package/dist/cjs/internal/compactable.js.map +7 -0
  156. package/dist/cjs/internal/compactionMarks.d.ts +278 -0
  157. package/dist/cjs/internal/compactionMarks.d.ts.map +1 -0
  158. package/dist/cjs/internal/compactionMarks.js +212 -0
  159. package/dist/cjs/internal/compactionMarks.js.map +7 -0
  160. package/dist/cjs/internal/demandText.d.ts +95 -0
  161. package/dist/cjs/internal/demandText.d.ts.map +1 -0
  162. package/dist/cjs/internal/demandText.js +70 -0
  163. package/dist/cjs/internal/demandText.js.map +7 -0
  164. package/dist/cjs/internal/elide.d.ts +109 -0
  165. package/dist/cjs/internal/elide.d.ts.map +1 -0
  166. package/dist/cjs/internal/elide.js +59 -0
  167. package/dist/cjs/internal/elide.js.map +7 -0
  168. package/dist/cjs/internal/frame.d.ts +463 -0
  169. package/dist/cjs/internal/frame.d.ts.map +1 -0
  170. package/dist/cjs/internal/frame.js +514 -0
  171. package/dist/cjs/internal/frame.js.map +7 -0
  172. package/dist/cjs/internal/nonNegativeSafeInt.d.ts +20 -0
  173. package/dist/cjs/internal/nonNegativeSafeInt.d.ts.map +1 -0
  174. package/dist/cjs/internal/nonNegativeSafeInt.js +29 -0
  175. package/dist/cjs/internal/nonNegativeSafeInt.js.map +7 -0
  176. package/dist/cjs/internal/paidUsage.d.ts +52 -0
  177. package/dist/cjs/internal/paidUsage.d.ts.map +1 -0
  178. package/dist/cjs/internal/paidUsage.js +70 -0
  179. package/dist/cjs/internal/paidUsage.js.map +7 -0
  180. package/dist/cjs/internal/printChannel.d.ts +233 -0
  181. package/dist/cjs/internal/printChannel.d.ts.map +1 -0
  182. package/dist/cjs/internal/printChannel.js +165 -0
  183. package/dist/cjs/internal/printChannel.js.map +7 -0
  184. package/dist/cjs/internal/printsObservation.d.ts +26 -0
  185. package/dist/cjs/internal/printsObservation.d.ts.map +1 -0
  186. package/dist/cjs/internal/printsObservation.js +27 -0
  187. package/dist/cjs/internal/printsObservation.js.map +7 -0
  188. package/dist/cjs/internal/refusal.d.ts +40 -0
  189. package/dist/cjs/internal/refusal.d.ts.map +1 -0
  190. package/dist/cjs/internal/refusal.js +45 -0
  191. package/dist/cjs/internal/refusal.js.map +7 -0
  192. package/dist/cjs/internal/supervision.d.ts +174 -0
  193. package/dist/cjs/internal/supervision.d.ts.map +1 -0
  194. package/dist/cjs/internal/supervision.js +402 -0
  195. package/dist/cjs/internal/supervision.js.map +7 -0
  196. package/dist/cjs/internal/unfinishedWork.d.ts +99 -0
  197. package/dist/cjs/internal/unfinishedWork.d.ts.map +1 -0
  198. package/dist/cjs/internal/unfinishedWork.js +80 -0
  199. package/dist/cjs/internal/unfinishedWork.js.map +7 -0
  200. package/dist/cjs/internal/unobservedCall.d.ts +112 -0
  201. package/dist/cjs/internal/unobservedCall.d.ts.map +1 -0
  202. package/dist/cjs/internal/unobservedCall.js +345 -0
  203. package/dist/cjs/internal/unobservedCall.js.map +7 -0
  204. package/dist/cjs/internal/untrustedData.d.ts +14 -0
  205. package/dist/cjs/internal/untrustedData.d.ts.map +1 -0
  206. package/dist/cjs/internal/untrustedData.js +30 -0
  207. package/dist/cjs/internal/untrustedData.js.map +7 -0
  208. package/dist/cjs/package.json +1 -0
  209. package/dist/esm/AgentEvent.d.ts +3092 -0
  210. package/dist/esm/AgentEvent.d.ts.map +1 -0
  211. package/dist/esm/AgentEvent.js +1610 -0
  212. package/dist/esm/AgentEvent.js.map +1 -0
  213. package/dist/esm/CallLedger.d.ts +378 -0
  214. package/dist/esm/CallLedger.d.ts.map +1 -0
  215. package/dist/esm/CallLedger.js +506 -0
  216. package/dist/esm/CallLedger.js.map +1 -0
  217. package/dist/esm/Cell.d.ts +774 -0
  218. package/dist/esm/Cell.d.ts.map +1 -0
  219. package/dist/esm/Cell.js +772 -0
  220. package/dist/esm/Cell.js.map +1 -0
  221. package/dist/esm/CellCalls.d.ts +115 -0
  222. package/dist/esm/CellCalls.d.ts.map +1 -0
  223. package/dist/esm/CellCalls.js +97 -0
  224. package/dist/esm/CellCalls.js.map +1 -0
  225. package/dist/esm/CellHistory.d.ts +102 -0
  226. package/dist/esm/CellHistory.d.ts.map +1 -0
  227. package/dist/esm/CellHistory.js +91 -0
  228. package/dist/esm/CellHistory.js.map +1 -0
  229. package/dist/esm/CellTurn.d.ts +1071 -0
  230. package/dist/esm/CellTurn.d.ts.map +1 -0
  231. package/dist/esm/CellTurn.js +3410 -0
  232. package/dist/esm/CellTurn.js.map +1 -0
  233. package/dist/esm/CellValidation.d.ts +94 -0
  234. package/dist/esm/CellValidation.d.ts.map +1 -0
  235. package/dist/esm/CellValidation.js +335 -0
  236. package/dist/esm/CellValidation.js.map +1 -0
  237. package/dist/esm/Compaction.d.ts +158 -0
  238. package/dist/esm/Compaction.d.ts.map +1 -0
  239. package/dist/esm/Compaction.js +216 -0
  240. package/dist/esm/Compaction.js.map +1 -0
  241. package/dist/esm/CompletionClaim.d.ts +801 -0
  242. package/dist/esm/CompletionClaim.d.ts.map +1 -0
  243. package/dist/esm/CompletionClaim.js +833 -0
  244. package/dist/esm/CompletionClaim.js.map +1 -0
  245. package/dist/esm/ContextWindow.d.ts +435 -0
  246. package/dist/esm/ContextWindow.d.ts.map +1 -0
  247. package/dist/esm/ContextWindow.js +427 -0
  248. package/dist/esm/ContextWindow.js.map +1 -0
  249. package/dist/esm/EngineLike.d.ts +546 -0
  250. package/dist/esm/EngineLike.d.ts.map +1 -0
  251. package/dist/esm/EngineLike.js +218 -0
  252. package/dist/esm/EngineLike.js.map +1 -0
  253. package/dist/esm/ExternalTranscript.d.ts +349 -0
  254. package/dist/esm/ExternalTranscript.d.ts.map +1 -0
  255. package/dist/esm/ExternalTranscript.js +987 -0
  256. package/dist/esm/ExternalTranscript.js.map +1 -0
  257. package/dist/esm/FailedCall.d.ts +132 -0
  258. package/dist/esm/FailedCall.d.ts.map +1 -0
  259. package/dist/esm/FailedCall.js +131 -0
  260. package/dist/esm/FailedCall.js.map +1 -0
  261. package/dist/esm/FlowBinding.d.ts +289 -0
  262. package/dist/esm/FlowBinding.d.ts.map +1 -0
  263. package/dist/esm/FlowBinding.js +376 -0
  264. package/dist/esm/FlowBinding.js.map +1 -0
  265. package/dist/esm/HarnessError.d.ts +57 -0
  266. package/dist/esm/HarnessError.d.ts.map +1 -0
  267. package/dist/esm/HarnessError.js +85 -0
  268. package/dist/esm/HarnessError.js.map +1 -0
  269. package/dist/esm/Judgement.d.ts +289 -0
  270. package/dist/esm/Judgement.d.ts.map +1 -0
  271. package/dist/esm/Judgement.js +305 -0
  272. package/dist/esm/Judgement.js.map +1 -0
  273. package/dist/esm/Monitor.d.ts +374 -0
  274. package/dist/esm/Monitor.d.ts.map +1 -0
  275. package/dist/esm/Monitor.js +370 -0
  276. package/dist/esm/Monitor.js.map +1 -0
  277. package/dist/esm/NarrowedCheck.d.ts +523 -0
  278. package/dist/esm/NarrowedCheck.d.ts.map +1 -0
  279. package/dist/esm/NarrowedCheck.js +612 -0
  280. package/dist/esm/NarrowedCheck.js.map +1 -0
  281. package/dist/esm/Notifications.d.ts +42 -0
  282. package/dist/esm/Notifications.d.ts.map +1 -0
  283. package/dist/esm/Notifications.js +215 -0
  284. package/dist/esm/Notifications.js.map +1 -0
  285. package/dist/esm/Plan.d.ts +127 -0
  286. package/dist/esm/Plan.d.ts.map +1 -0
  287. package/dist/esm/Plan.js +97 -0
  288. package/dist/esm/Plan.js.map +1 -0
  289. package/dist/esm/QuickJSSandbox.d.ts +151 -0
  290. package/dist/esm/QuickJSSandbox.d.ts.map +1 -0
  291. package/dist/esm/QuickJSSandbox.js +1364 -0
  292. package/dist/esm/QuickJSSandbox.js.map +1 -0
  293. package/dist/esm/Relevance.d.ts +213 -0
  294. package/dist/esm/Relevance.d.ts.map +1 -0
  295. package/dist/esm/Relevance.js +254 -0
  296. package/dist/esm/Relevance.js.map +1 -0
  297. package/dist/esm/Sandbox.d.ts +637 -0
  298. package/dist/esm/Sandbox.d.ts.map +1 -0
  299. package/dist/esm/Sandbox.js +464 -0
  300. package/dist/esm/Sandbox.js.map +1 -0
  301. package/dist/esm/Steering.d.ts +464 -0
  302. package/dist/esm/Steering.d.ts.map +1 -0
  303. package/dist/esm/Steering.js +193 -0
  304. package/dist/esm/Steering.js.map +1 -0
  305. package/dist/esm/StructuredOutput.d.ts +252 -0
  306. package/dist/esm/StructuredOutput.d.ts.map +1 -0
  307. package/dist/esm/StructuredOutput.js +430 -0
  308. package/dist/esm/StructuredOutput.js.map +1 -0
  309. package/dist/esm/Sufficiency.d.ts +195 -0
  310. package/dist/esm/Sufficiency.d.ts.map +1 -0
  311. package/dist/esm/Sufficiency.js +207 -0
  312. package/dist/esm/Sufficiency.js.map +1 -0
  313. package/dist/esm/Supervisor.d.ts +719 -0
  314. package/dist/esm/Supervisor.d.ts.map +1 -0
  315. package/dist/esm/Supervisor.js +575 -0
  316. package/dist/esm/Supervisor.js.map +1 -0
  317. package/dist/esm/Tokens.d.ts +86 -0
  318. package/dist/esm/Tokens.d.ts.map +1 -0
  319. package/dist/esm/Tokens.js +92 -0
  320. package/dist/esm/Tokens.js.map +1 -0
  321. package/dist/esm/Transcript.d.ts +171 -0
  322. package/dist/esm/Transcript.d.ts.map +1 -0
  323. package/dist/esm/Transcript.js +424 -0
  324. package/dist/esm/Transcript.js.map +1 -0
  325. package/dist/esm/TruncatedOutput.d.ts +186 -0
  326. package/dist/esm/TruncatedOutput.d.ts.map +1 -0
  327. package/dist/esm/TruncatedOutput.js +257 -0
  328. package/dist/esm/TruncatedOutput.js.map +1 -0
  329. package/dist/esm/UnmovedTree.d.ts +113 -0
  330. package/dist/esm/UnmovedTree.d.ts.map +1 -0
  331. package/dist/esm/UnmovedTree.js +90 -0
  332. package/dist/esm/UnmovedTree.js.map +1 -0
  333. package/dist/esm/UnresolvedFailure.d.ts +196 -0
  334. package/dist/esm/UnresolvedFailure.d.ts.map +1 -0
  335. package/dist/esm/UnresolvedFailure.js +218 -0
  336. package/dist/esm/UnresolvedFailure.js.map +1 -0
  337. package/dist/esm/VacuousVerification.d.ts +237 -0
  338. package/dist/esm/VacuousVerification.d.ts.map +1 -0
  339. package/dist/esm/VacuousVerification.js +245 -0
  340. package/dist/esm/VacuousVerification.js.map +1 -0
  341. package/dist/esm/VariablesPanel.d.ts +117 -0
  342. package/dist/esm/VariablesPanel.d.ts.map +1 -0
  343. package/dist/esm/VariablesPanel.js +142 -0
  344. package/dist/esm/VariablesPanel.js.map +1 -0
  345. package/dist/esm/index.d.ts +172 -0
  346. package/dist/esm/index.d.ts.map +1 -0
  347. package/dist/esm/index.js +172 -0
  348. package/dist/esm/index.js.map +1 -0
  349. package/dist/esm/internal/bytes.d.ts +36 -0
  350. package/dist/esm/internal/bytes.d.ts.map +1 -0
  351. package/dist/esm/internal/bytes.js +70 -0
  352. package/dist/esm/internal/bytes.js.map +1 -0
  353. package/dist/esm/internal/cellPrompt.d.ts +122 -0
  354. package/dist/esm/internal/cellPrompt.d.ts.map +1 -0
  355. package/dist/esm/internal/cellPrompt.js +276 -0
  356. package/dist/esm/internal/cellPrompt.js.map +1 -0
  357. package/dist/esm/internal/compactable.d.ts +44 -0
  358. package/dist/esm/internal/compactable.d.ts.map +1 -0
  359. package/dist/esm/internal/compactable.js +71 -0
  360. package/dist/esm/internal/compactable.js.map +1 -0
  361. package/dist/esm/internal/compactionMarks.d.ts +278 -0
  362. package/dist/esm/internal/compactionMarks.d.ts.map +1 -0
  363. package/dist/esm/internal/compactionMarks.js +317 -0
  364. package/dist/esm/internal/compactionMarks.js.map +1 -0
  365. package/dist/esm/internal/demandText.d.ts +95 -0
  366. package/dist/esm/internal/demandText.d.ts.map +1 -0
  367. package/dist/esm/internal/demandText.js +128 -0
  368. package/dist/esm/internal/demandText.js.map +1 -0
  369. package/dist/esm/internal/elide.d.ts +109 -0
  370. package/dist/esm/internal/elide.d.ts.map +1 -0
  371. package/dist/esm/internal/elide.js +123 -0
  372. package/dist/esm/internal/elide.js.map +1 -0
  373. package/dist/esm/internal/frame.d.ts +463 -0
  374. package/dist/esm/internal/frame.d.ts.map +1 -0
  375. package/dist/esm/internal/frame.js +861 -0
  376. package/dist/esm/internal/frame.js.map +1 -0
  377. package/dist/esm/internal/nonNegativeSafeInt.d.ts +20 -0
  378. package/dist/esm/internal/nonNegativeSafeInt.d.ts.map +1 -0
  379. package/dist/esm/internal/nonNegativeSafeInt.js +20 -0
  380. package/dist/esm/internal/nonNegativeSafeInt.js.map +1 -0
  381. package/dist/esm/internal/paidUsage.d.ts +52 -0
  382. package/dist/esm/internal/paidUsage.d.ts.map +1 -0
  383. package/dist/esm/internal/paidUsage.js +72 -0
  384. package/dist/esm/internal/paidUsage.js.map +1 -0
  385. package/dist/esm/internal/printChannel.d.ts +233 -0
  386. package/dist/esm/internal/printChannel.d.ts.map +1 -0
  387. package/dist/esm/internal/printChannel.js +376 -0
  388. package/dist/esm/internal/printChannel.js.map +1 -0
  389. package/dist/esm/internal/printsObservation.d.ts +26 -0
  390. package/dist/esm/internal/printsObservation.d.ts.map +1 -0
  391. package/dist/esm/internal/printsObservation.js +29 -0
  392. package/dist/esm/internal/printsObservation.js.map +1 -0
  393. package/dist/esm/internal/refusal.d.ts +40 -0
  394. package/dist/esm/internal/refusal.d.ts.map +1 -0
  395. package/dist/esm/internal/refusal.js +47 -0
  396. package/dist/esm/internal/refusal.js.map +1 -0
  397. package/dist/esm/internal/supervision.d.ts +174 -0
  398. package/dist/esm/internal/supervision.d.ts.map +1 -0
  399. package/dist/esm/internal/supervision.js +485 -0
  400. package/dist/esm/internal/supervision.js.map +1 -0
  401. package/dist/esm/internal/unfinishedWork.d.ts +99 -0
  402. package/dist/esm/internal/unfinishedWork.d.ts.map +1 -0
  403. package/dist/esm/internal/unfinishedWork.js +85 -0
  404. package/dist/esm/internal/unfinishedWork.js.map +1 -0
  405. package/dist/esm/internal/unobservedCall.d.ts +112 -0
  406. package/dist/esm/internal/unobservedCall.d.ts.map +1 -0
  407. package/dist/esm/internal/unobservedCall.js +501 -0
  408. package/dist/esm/internal/unobservedCall.js.map +1 -0
  409. package/dist/esm/internal/untrustedData.d.ts +14 -0
  410. package/dist/esm/internal/untrustedData.d.ts.map +1 -0
  411. package/dist/esm/internal/untrustedData.js +15 -0
  412. package/dist/esm/internal/untrustedData.js.map +1 -0
  413. package/docs/README.md +129 -0
  414. package/docs/api.md +1869 -0
  415. package/docs/concepts.md +238 -0
  416. package/docs/external-transcripts.md +245 -0
  417. package/docs/guides/bind-flows.md +167 -0
  418. package/docs/guides/drive-the-loop.md +265 -0
  419. package/docs/guides/run-cells.md +262 -0
  420. package/docs/guides/workerd.md +144 -0
  421. package/docs/installation.md +69 -0
  422. package/docs/quickstart.md +121 -0
  423. package/docs/reference.md +954 -0
  424. package/docs/troubleshooting.md +177 -0
  425. package/package.json +463 -3
  426. package/src/AgentEvent.ts +1772 -0
  427. package/src/CallLedger.ts +560 -0
  428. package/src/Cell.ts +926 -0
  429. package/src/CellCalls.ts +198 -0
  430. package/src/CellHistory.ts +128 -0
  431. package/src/CellTurn.ts +4450 -0
  432. package/src/CellValidation.ts +382 -0
  433. package/src/Compaction.ts +330 -0
  434. package/src/CompletionClaim.ts +1013 -0
  435. package/src/ContextWindow.ts +669 -0
  436. package/src/EngineLike.ts +614 -0
  437. package/src/ExternalTranscript.ts +1143 -0
  438. package/src/FailedCall.ts +163 -0
  439. package/src/FlowBinding.ts +603 -0
  440. package/src/HarnessError.ts +98 -0
  441. package/src/Judgement.ts +526 -0
  442. package/src/Monitor.ts +579 -0
  443. package/src/NarrowedCheck.ts +694 -0
  444. package/src/Notifications.ts +262 -0
  445. package/src/Plan.ts +113 -0
  446. package/src/QuickJSSandbox.ts +1557 -0
  447. package/src/Relevance.ts +352 -0
  448. package/src/Sandbox.ts +908 -0
  449. package/src/Steering.ts +405 -0
  450. package/src/StructuredOutput.ts +484 -0
  451. package/src/Sufficiency.ts +247 -0
  452. package/src/Supervisor.ts +798 -0
  453. package/src/Tokens.ts +108 -0
  454. package/src/Transcript.ts +513 -0
  455. package/src/TruncatedOutput.ts +297 -0
  456. package/src/UnmovedTree.ts +121 -0
  457. package/src/UnresolvedFailure.ts +240 -0
  458. package/src/VacuousVerification.ts +280 -0
  459. package/src/VariablesPanel.ts +165 -0
  460. package/src/index.ts +204 -0
  461. package/src/internal/bytes.ts +70 -0
  462. package/src/internal/cellPrompt.ts +337 -0
  463. package/src/internal/compactable.ts +76 -0
  464. package/src/internal/compactionMarks.ts +454 -0
  465. package/src/internal/demandText.ts +145 -0
  466. package/src/internal/elide.ts +130 -0
  467. package/src/internal/frame.ts +1178 -0
  468. package/src/internal/nonNegativeSafeInt.ts +24 -0
  469. package/src/internal/paidUsage.ts +90 -0
  470. package/src/internal/printChannel.ts +434 -0
  471. package/src/internal/printsObservation.ts +31 -0
  472. package/src/internal/refusal.ts +53 -0
  473. package/src/internal/supervision.ts +652 -0
  474. package/src/internal/unfinishedWork.ts +123 -0
  475. package/src/internal/unobservedCall.ts +536 -0
  476. package/src/internal/untrustedData.ts +19 -0
@@ -0,0 +1,1772 @@
1
+ /**
2
+ * Serializable events emitted by harness adapters.
3
+ *
4
+ * @since 0.1.0
5
+ */
6
+
7
+ import * as Permission from "@smthrs/capability/Permission"
8
+ import type * as Classifier from "@smthrs/model/Classifier"
9
+ import * as Evaluator from "@smthrs/model/Evaluator"
10
+ import * as ModelError from "@smthrs/model/ModelError"
11
+ import * as ModelEvent from "@smthrs/model/ModelEvent"
12
+ import * as ModelRequest from "@smthrs/model/ModelRequest"
13
+ import * as Pricing from "@smthrs/model/Pricing"
14
+ import { Context, Effect, Schema } from "effect"
15
+ import * as Cell from "./Cell.ts"
16
+ import * as EngineLike from "./EngineLike.ts"
17
+ import { NonNegativeSafeInt } from "./internal/nonNegativeSafeInt.ts"
18
+ import * as Sandbox from "./Sandbox.ts"
19
+
20
+ /**
21
+ * Observes an event before the controller advances or parks. Durable hosts
22
+ * finish their checkpoint here; stream consumers may lag behind the source.
23
+ * @category services
24
+ * @since 1.0.0-rc.0
25
+ */
26
+ export const Observer = Context.Reference<(event: AgentEvent) => Effect.Effect<void>>(
27
+ "@smthrs/harness/AgentEvent/Observer",
28
+ { defaultValue: () => () => Effect.void }
29
+ )
30
+
31
+ /**
32
+ * Journals an event into the run whose cell called the current flow. The
33
+ * controller provides it around each flow call, so a flow that asks Jev
34
+ * itself journals its receipts beside the run's own. Outside a run there is
35
+ * no journal, and it does nothing.
36
+ * @category services
37
+ * @since 1.0.0-rc.0
38
+ */
39
+ export const Journal = Context.Reference<(event: AgentEvent) => Effect.Effect<void>>(
40
+ "@smthrs/harness/AgentEvent/Journal",
41
+ { defaultValue: () => () => Effect.void }
42
+ )
43
+
44
+ /**
45
+ * The kind of a human-provided item a relevance reading may withhold.
46
+ *
47
+ * @category models
48
+ * @since 1.0.0-rc.0
49
+ */
50
+ export const RelevanceKind = Schema.Literals(["flow", "skill", "instruction", "memory"])
51
+
52
+ /**
53
+ * What a compaction reading did with one replaced message.
54
+ *
55
+ * @category models
56
+ * @since 1.0.0-rc.0
57
+ */
58
+ export const CompactionMark = Schema.Literals(["keep", "squash", "remove"])
59
+
60
+ /**
61
+ * The invariant that kept a message from being removed, whatever it was marked.
62
+ *
63
+ * @category models
64
+ * @since 1.0.0-rc.0
65
+ */
66
+ export const CompactionPin = Schema.Literals(["summary", "person", "steering", "mutated", "failing", "pair", "budget"])
67
+
68
+ /**
69
+ * Why a compaction ran: the context `budget` was crossed, or a drained
70
+ * supervisor reading found the run carrying `outdated_context` or
71
+ * `irrelevant_context`.
72
+ *
73
+ * @category models
74
+ * @since 1.0.0-rc.0
75
+ */
76
+ export const CompactionCause = Schema.Literals(["budget", "outdated_context", "irrelevant_context"])
77
+
78
+ /**
79
+ * What a supervisor monitor watches for.
80
+ *
81
+ * @category models
82
+ * @since 1.0.0-rc.0
83
+ */
84
+ export const MonitorKind = Schema.Literals(["mood", "skill", "lint"])
85
+
86
+ /**
87
+ * The static stance a run's monitors deliver under.
88
+ *
89
+ * @category models
90
+ * @since 1.0.0-rc.0
91
+ */
92
+ export const Stance = Schema.Literals(["careful", "paranoid"])
93
+
94
+ /**
95
+ * Why a crossed monitor was not delivered.
96
+ *
97
+ * @category models
98
+ * @since 1.0.0-rc.0
99
+ */
100
+ export const Suppression = Schema.Literals(["streak", "cooldown", "limit", "slot"])
101
+
102
+ /**
103
+ * Why a reading could not be judged: `unconfigured`, `interrupted`, or the
104
+ * transport's own error code.
105
+ *
106
+ * @category models
107
+ * @since 1.0.0-rc.0
108
+ */
109
+ export const UnjudgedReason = Schema.Literals(["interrupted", ...Evaluator.EvaluatorErrorCode.literals])
110
+
111
+ /**
112
+ * Token usage an evaluator reported for one reading, and the model that read
113
+ * it when the transport named it: what prices the reading (#3010).
114
+ */
115
+ const Usage = Schema.Struct({
116
+ inputTokens: Schema.Number,
117
+ outputTokens: Schema.Number,
118
+ modelId: Schema.optional(Schema.String)
119
+ })
120
+
121
+ /**
122
+ * The loop discipline a run was armed with, journaled once when it starts.
123
+ *
124
+ * Arming used to be observable only through the events a disciplined run
125
+ * *reaches*: the read-cap failure proves the cap was armed, and a run that
126
+ * times out before it fires proves nothing — so a grader could not tell "armed
127
+ * but never reached" from "never armed", which is exactly what the 2026-08-19
128
+ * SWE-bench wave could not decide about its django instance. This event is the
129
+ * positive record: it says what was armed, before anything has had a chance to
130
+ * fire.
131
+ *
132
+ * @category events
133
+ * @since 0.1.0
134
+ * @slop
135
+ */
136
+ export class DisciplineArmed extends Schema.TaggedClass<DisciplineArmed>(
137
+ "flows/harness/AgentEvent/DisciplineArmed"
138
+ )("discipline-armed", {
139
+ eventType: Schema.Literal("flows.harness.discipline-armed.v1"),
140
+ /** Consecutive read-only frames allowed; zero means the cap is disarmed. */
141
+ readOnlyCap: Schema.Number,
142
+ /** The frame budget the run stops at. */
143
+ maxFrames: Schema.Number,
144
+ /**
145
+ * Whether a human can answer this run.
146
+ *
147
+ * False says nothing is listening: a `park` transition is refused and
148
+ * answered in the frame that returned it, because a run that waits for an
149
+ * answer nobody will give has stopped working with its budget unspent.
150
+ */
151
+ approvalChannel: Schema.Boolean,
152
+ /**
153
+ * Wall-clock milliseconds one model call may spend; zero means disarmed.
154
+ *
155
+ * Every other budget here caps the cell — the calls it makes, the memory and
156
+ * time its code spends, the run's frames. This one caps the step in between,
157
+ * which was the only unbounded thing the loop did.
158
+ */
159
+ modelCallMs: Schema.Number,
160
+ /**
161
+ * Consecutive repeat-observation frames allowed; zero disarms the demand.
162
+ *
163
+ * Armed here for the same reason the read-only cap is: a run that never
164
+ * reaches a control proves nothing about whether the control was armed, and
165
+ * a grader must be able to tell "armed and never needed" from "never armed".
166
+ */
167
+ repeatCap: Schema.Number,
168
+ /**
169
+ * Completions this run may have bounced for narrowed evidence; zero disarms.
170
+ *
171
+ * Journaled with the rest because the demand it governs fires at most once
172
+ * in a run and often not at all, so its absence from a wave says nothing on
173
+ * its own. One is the armed default: the loop names the missing check once,
174
+ * and the answer that comes back is the answer that stands.
175
+ */
176
+ narrowingCap: Schema.Number,
177
+ /**
178
+ * Completions this run may have bounced for an unmoved tree; zero disarms.
179
+ *
180
+ * Journaled for the same reason as the other two completion caps: the demand
181
+ * fires at most once and usually not at all, so a wave that records none must
182
+ * be able to say whether the control was armed and never needed.
183
+ */
184
+ unmovedCap: Schema.Number,
185
+ /**
186
+ * Times one frame may answer its own unparseable cell before ending; zero
187
+ * disarms the answer.
188
+ *
189
+ * Journaled with the rest because a wave that records no
190
+ * `cell-rejected-in-frame` must be able to say whether the answer was armed
191
+ * and never needed or never armed at all.
192
+ */
193
+ revalidations: Schema.Number.pipe(
194
+ Schema.withConstructorDefault(Effect.succeed(0)),
195
+ Schema.withDecodingDefaultKey(Effect.succeed(0))
196
+ ),
197
+ /**
198
+ * Completions this run may have bounced for a failing check it replaced
199
+ * rather than answered; zero disarms.
200
+ */
201
+ unresolvedCap: Schema.Number,
202
+ /**
203
+ * Completions this run may have bounced for a claim its own record does not
204
+ * support; zero disarms.
205
+ *
206
+ * Journaled with the other completion caps, and it says less than they do on
207
+ * its own: the control it arms is also a no-op wherever no `Evaluator` is
208
+ * bound, so an armed cap and no `claim-demanded` event anywhere in a run
209
+ * means either that nothing was asked or that everything asked came back
210
+ * inside the thresholds. Defaulted so journals written before this control
211
+ * existed decode unchanged. See `CompletionClaim`.
212
+ */
213
+ claimCap: Schema.Number.pipe(
214
+ Schema.withConstructorDefault(Effect.succeed(0)),
215
+ Schema.withDecodingDefaultKey(Effect.succeed(0))
216
+ ),
217
+ /**
218
+ * Whether a supervisor reading could nudge the run, as journals written
219
+ * before {@link judged} said it. Later writers omit it: `judged` says the
220
+ * same.
221
+ */
222
+ supervisorSteer: Schema.optional(Schema.Boolean),
223
+ /** Maximum calls per cell, when this binding can enforce one. */
224
+ calls: Schema.optional(Schema.Number),
225
+ /** Maximum sandbox heap, when this binding can enforce one. */
226
+ memoryBytes: Schema.optional(Schema.Number),
227
+ /** Maximum interpreter steps, when this binding can enforce one. */
228
+ steps: Schema.optional(Schema.Number),
229
+ /** Maximum cell-compute time, when this binding can enforce one. */
230
+ timeMs: Schema.optional(Schema.Number),
231
+ /** Maximum whole-evaluation time, when this binding can enforce one. */
232
+ totalMs: Schema.optional(Schema.Number),
233
+ /** Maximum wall-clock time for one flow call. */
234
+ callMs: Schema.optional(Schema.Number),
235
+ /** Whether a judge was bound, so Jev's readings run. Absent before it existed. */
236
+ judged: Schema.optional(Schema.Boolean),
237
+ /** The relevance gate: the withhold threshold and the item ids never offered to it. */
238
+ relevance: Schema.optional(Schema.Struct({ withholdAt: Schema.Number, pinned: Schema.Array(Schema.String) })),
239
+ /** The supervisor monitors armed, with their delivery gates. */
240
+ monitors: Schema.optional(Schema.Array(Schema.Struct({
241
+ id: Schema.String,
242
+ kind: MonitorKind,
243
+ /** The probability at or above which the monitor crosses. */
244
+ at: Schema.Number,
245
+ /** Consecutive crossed readings required before a delivery. */
246
+ consecutive: NonNegativeSafeInt,
247
+ /** Frames after a delivery during which the monitor is not delivered again. */
248
+ cooldownFrames: NonNegativeSafeInt,
249
+ /** Deliveries allowed in one run. */
250
+ limit: NonNegativeSafeInt
251
+ }))),
252
+ /** The static stance the monitors deliver under. */
253
+ stance: Schema.optional(Stance)
254
+ }) {}
255
+
256
+ /**
257
+ * The serializable snapshot fixed when a turn opens.
258
+ *
259
+ * @category events
260
+ * @since 0.1.0
261
+ * @slop
262
+ */
263
+ export class TurnOpened extends Schema.TaggedClass<TurnOpened>(
264
+ "flows/harness/AgentEvent/TurnOpened"
265
+ )("turn-opened", {
266
+ eventType: Schema.Literal("flows.harness.turn-opened.v1"),
267
+ seat: Schema.String,
268
+ modelParams: ModelRequest.GenerationParams,
269
+ /**
270
+ * The tool set the turn opened with, which the cell-first controller always
271
+ * opens empty: it declares no provider tools. The field stays on the event
272
+ * so journals written before the provider-tool loop was retired keep
273
+ * decoding, and so a foreign-adapter loop has somewhere to put one.
274
+ */
275
+ activeToolNames: Schema.Array(Schema.String),
276
+ contextDigest: Schema.String
277
+ }) {}
278
+
279
+ /**
280
+ * What one model call was asked, written before the call is made.
281
+ *
282
+ * `model-settled` journals what a call answered and what it cost, and until
283
+ * this event nothing journaled what it was asked: the request existed only in
284
+ * the sealed step's key material, as a digest. A reader that wants to open one
285
+ * step and run it again needs the request itself, so this is the request
286
+ * itself, carried whole here and bounded where it is journaled.
287
+ *
288
+ * It is written when the call is OPENED rather than when it settles, so a call
289
+ * that never settles (a deadline, a refusal, a process that died mid-stream)
290
+ * still leaves what it asked on the record.
291
+ *
292
+ * `scope`, `frame` and `attempt` are the join keys, and they are on the record
293
+ * because position is not one. `scope` is the run's session, which for a
294
+ * module step is the step's recorded scope; `frame` is the controller's own
295
+ * frame number; `attempt` counts the model calls one frame made, from one,
296
+ * and is the same number `cell-rejected-in-frame` names when it refuses that
297
+ * call's answer. A compaction call runs before its frame's `turn-opened`, so a
298
+ * reader counting turns would file it under the frame before; `purpose` and
299
+ * `frame` say where it belongs.
300
+ *
301
+ * Credential-free by construction. The request is the provider-neutral
302
+ * `ModelRequest`, which has no member a credential can occupy, and
303
+ * {@link EngineLike.Binding} carries two names read off the prepared request
304
+ * that exists before any secret is signed on.
305
+ *
306
+ * @category events
307
+ * @since 1.0.0-rc.0
308
+ */
309
+ export class ModelRequested extends Schema.TaggedClass<ModelRequested>(
310
+ "flows/harness/AgentEvent/ModelRequested"
311
+ )("model-requested", {
312
+ eventType: Schema.Literal("flows.harness.model-requested.v1"),
313
+ /** The run's session, which is the recorded scope of the step that made the call. */
314
+ scope: Schema.String,
315
+ /** The controller's frame number for the turn this call belongs to. */
316
+ frame: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
317
+ /** Which model call of that frame and purpose this is, counting from one. */
318
+ attempt: Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)),
319
+ /** What the call is for: the frame's own turn, or the compaction ahead of it. */
320
+ purpose: Schema.Literals(["frame", "compaction"]),
321
+ /** The seat the frame ran on, as `turn-opened` names it. */
322
+ seat: Schema.String,
323
+ /** The route the host resolved, absent where the host names none. */
324
+ binding: Schema.optional(EngineLike.Binding),
325
+ /** The request the provider is sent, whole: after any rewrite the host applies. */
326
+ request: ModelRequest.ModelRequest
327
+ }) {}
328
+
329
+ /**
330
+ * The host selected the seat that will receive this capacity attempt.
331
+ * @category events
332
+ * @since 1.0.0-rc.1
333
+ */
334
+ export class ModelSelected extends Schema.TaggedClass<ModelSelected>(
335
+ "flows/harness/AgentEvent/ModelSelected"
336
+ )("model-selected", {
337
+ eventType: Schema.Literal("flows.harness.model-selected.v1"),
338
+ seat: Schema.String
339
+ }) {}
340
+
341
+ /**
342
+ * A capacity refusal moved the current frame to another seat.
343
+ * @category events
344
+ * @since 1.0.0-rc.1
345
+ */
346
+ export class SeatFailedOver extends Schema.TaggedClass<SeatFailedOver>(
347
+ "flows/harness/AgentEvent/SeatFailedOver"
348
+ )("seat-failed-over", {
349
+ eventType: Schema.Literal("flows.harness.seat-failed-over.v1"),
350
+ from: Schema.String,
351
+ to: Schema.String,
352
+ code: ModelError.ModelErrorCode,
353
+ resetAtEpochMillis: Schema.optional(Schema.Number),
354
+ retryAfterMillis: Schema.optional(Schema.Number),
355
+ httpStatus: Schema.optional(Schema.Number),
356
+ quotaScope: Schema.optional(Schema.Literals(["account", "model"]))
357
+ }) {}
358
+
359
+ /**
360
+ * All configured model seats are cooling until this instant.
361
+ * @category events
362
+ * @since 1.0.0-rc.1
363
+ */
364
+ export class ModelParked extends Schema.TaggedClass<ModelParked>(
365
+ "flows/harness/AgentEvent/ModelParked"
366
+ )("model-parked", {
367
+ eventType: Schema.Literal("flows.harness.model-parked.v1"),
368
+ seat: Schema.String,
369
+ wakeAt: Schema.Number,
370
+ source: Schema.Literals(["reset", "retry-after", "default"]),
371
+ code: ModelError.ModelErrorCode
372
+ }) {}
373
+
374
+ /**
375
+ * A parked model frame may issue a new request.
376
+ * @category events
377
+ * @since 1.0.0-rc.1
378
+ */
379
+ export class ModelUnparked extends Schema.TaggedClass<ModelUnparked>(
380
+ "flows/harness/AgentEvent/ModelUnparked"
381
+ )("model-unparked", {
382
+ eventType: Schema.Literal("flows.harness.model-unparked.v1"),
383
+ seat: Schema.String,
384
+ at: Schema.Number
385
+ }) {}
386
+
387
+ /**
388
+ * One provider-neutral model progress event.
389
+ *
390
+ * @category events
391
+ * @since 0.1.0
392
+ * @slop
393
+ */
394
+ export class ModelDelta extends Schema.TaggedClass<ModelDelta>(
395
+ "flows/harness/AgentEvent/ModelDelta"
396
+ )("model-delta", {
397
+ eventType: Schema.Literal("flows.harness.model-delta.v1"),
398
+ delta: ModelEvent.ModelEvent
399
+ }) {}
400
+
401
+ /**
402
+ * A transport-only model retry taken before the sealed step settled.
403
+ *
404
+ * @category events
405
+ * @since 0.1.0
406
+ */
407
+ export class ModelRetried extends Schema.TaggedClass<ModelRetried>(
408
+ "flows/harness/AgentEvent/ModelRetried"
409
+ )("model-retried", {
410
+ eventType: Schema.Literal("flows.harness.model-retried.v1"),
411
+ attempt: Schema.Int,
412
+ code: Schema.String,
413
+ /**
414
+ * Milliseconds the boundary waited before this attempt.
415
+ *
416
+ * Every retry of one sealed step is journaled at the moment the step
417
+ * settles, so the event timestamps cannot show the schedule. This carries
418
+ * it. Zero is what an unscheduled retry, or a record written before the
419
+ * field existed, reports.
420
+ */
421
+ delayMillis: Schema.Number.pipe(
422
+ Schema.withConstructorDefault(Effect.succeed(0)),
423
+ Schema.withDecodingDefaultKey(Effect.succeed(0))
424
+ )
425
+ }) {}
426
+
427
+ /**
428
+ * The complete recorded model settlement and usage.
429
+ *
430
+ * @category events
431
+ * @since 0.1.0
432
+ * @slop
433
+ */
434
+ export class ModelSettled extends Schema.TaggedClass<ModelSettled>(
435
+ "flows/harness/AgentEvent/ModelSettled"
436
+ )("model-settled", {
437
+ eventType: Schema.Literal("flows.harness.model-settled.v1"),
438
+ message: ModelRequest.AssistantMessage,
439
+ usage: ModelEvent.Usage,
440
+ /**
441
+ * The call's USD cost: the provider's reported charge, or its usage priced
442
+ * under the model's rate card. Absent for an unpriced model.
443
+ */
444
+ costUsd: Schema.optional(Schema.Number),
445
+ /** Where {@link costUsd} came from. */
446
+ costSource: Schema.optional(Pricing.CostSource),
447
+ /** The vendor session that answered, for a wrapped CLI seat: `claude --resume <sessionId>`. */
448
+ sessionId: Schema.optional(Schema.String),
449
+ /**
450
+ * Wall-clock milliseconds the sealed step took, measured on the injected
451
+ * clock.
452
+ *
453
+ * Usage alone answers what a call cost, never how long it took, so a
454
+ * benchmark could compare tokens per run but not seconds per call — and
455
+ * speed was the larger half of the gap the first head-to-head measured.
456
+ * Zero is what an event carries when nothing timed it.
457
+ */
458
+ durationMillis: Schema.Number.pipe(
459
+ Schema.withConstructorDefault(Effect.succeed(0)),
460
+ Schema.withDecodingDefaultKey(Effect.succeed(0))
461
+ )
462
+ }) {}
463
+
464
+ /**
465
+ * The cell source recovered from one model settlement.
466
+ *
467
+ * The source itself is durable evidence: replay re-executes exactly this text,
468
+ * and every call identity inside the frame folds in its digest.
469
+ *
470
+ * @category events
471
+ * @since 0.1.0
472
+ * @slop
473
+ */
474
+ export class CellProduced extends Schema.TaggedClass<CellProduced>(
475
+ "flows/harness/AgentEvent/CellProduced"
476
+ )("cell-produced", {
477
+ eventType: Schema.Literal("flows.harness.cell-produced.v1"),
478
+ cell: Cell.Source,
479
+ /**
480
+ * How many fenced cell blocks the reply was written in.
481
+ *
482
+ * Journaled because it is the only record of how the model laid its frame
483
+ * out, and because the count above one is the shape whose whole program the
484
+ * harness used to discard. See `Cell.extract`.
485
+ */
486
+ blocks: Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)).pipe(
487
+ Schema.withConstructorDefault(Effect.succeed(1)),
488
+ Schema.withDecodingDefaultKey(Effect.succeed(1))
489
+ )
490
+ }) {}
491
+
492
+ /**
493
+ * One reply the boundary parse refused, answered inside the frame it arrived
494
+ * in rather than by ending the frame.
495
+ *
496
+ * Journaled because it is spend: a re-prompt is a real model call, cached
497
+ * prefix or not, and a wave counting cost per frame would otherwise see the
498
+ * output of an answer it has no record of asking for. It is also the only
499
+ * measure of whether validating at the boundary is worth what it costs — the
500
+ * ratio of this event to `cell-settled` rejections says how often one re-ask
501
+ * recovers a frame.
502
+ *
503
+ * @category events
504
+ * @since 0.1.0
505
+ * @slop
506
+ */
507
+ export class CellRejectedInFrame extends Schema.TaggedClass<CellRejectedInFrame>(
508
+ "flows/harness/AgentEvent/CellRejectedInFrame"
509
+ )("cell-rejected-in-frame", {
510
+ eventType: Schema.Literal("flows.harness.cell-rejected-in-frame.v1"),
511
+ /** Which attempt of this frame was refused, counting from one. */
512
+ attempt: Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)),
513
+ /** Why the parse refused it. */
514
+ code: Cell.RejectionCode,
515
+ /** What the frame told the model, verbatim. */
516
+ message: Schema.String
517
+ }) {}
518
+
519
+ /**
520
+ * One flow call opened from inside a running cell.
521
+ *
522
+ * @category events
523
+ * @since 0.1.0
524
+ * @slop
525
+ */
526
+ export class CellCallStarted extends Schema.TaggedClass<CellCallStarted>(
527
+ "flows/harness/AgentEvent/CellCallStarted"
528
+ )("cell-call-started", {
529
+ eventType: Schema.Literal("flows.harness.cell-call-started.v1"),
530
+ call: Cell.Call
531
+ }) {}
532
+
533
+ /**
534
+ * One settled flow call made from inside a running cell.
535
+ *
536
+ * @category events
537
+ * @since 0.1.0
538
+ * @slop
539
+ */
540
+ export class CellCallSettled extends Schema.TaggedClass<CellCallSettled>(
541
+ "flows/harness/AgentEvent/CellCallSettled"
542
+ )("cell-call-settled", {
543
+ eventType: Schema.Literal("flows.harness.cell-call-settled.v1"),
544
+ flowName: Schema.String,
545
+ identity: Cell.CallIdentity,
546
+ result: Cell.CallResult
547
+ }) {}
548
+
549
+ /**
550
+ * What one REPL cell printed, as the next model turn will read it.
551
+ *
552
+ * The print buffer is the whole of the context channel in REPL mode, so it is
553
+ * journaled rather than derived: a transcript projection rebuilds a resumed
554
+ * run's window from the journal without re-running anything, exactly as it does
555
+ * for the context a filing cell projected. Bounded before it is emitted, so the
556
+ * journal carries what the model saw and nothing larger.
557
+ *
558
+ * @category events
559
+ * @since 0.1.0
560
+ */
561
+ export class CellPrinted extends Schema.TaggedClass<CellPrinted>(
562
+ "flows/harness/AgentEvent/CellPrinted"
563
+ )("cell-printed", {
564
+ eventType: Schema.Literal("flows.harness.cell-printed.v1"),
565
+ /** The digest of the cell whose prints these are. */
566
+ cell: Schema.String,
567
+ /** The frame's whole print buffer, already bounded; empty when it printed nothing. */
568
+ text: Schema.String
569
+ }) {}
570
+
571
+ /**
572
+ * The outcome of executing one cell, whether it settled, threw, or was
573
+ * rejected before it ran.
574
+ *
575
+ * @category events
576
+ * @since 0.1.0
577
+ * @slop
578
+ */
579
+ export class CellSettled extends Schema.TaggedClass<CellSettled>(
580
+ "flows/harness/AgentEvent/CellSettled"
581
+ )("cell-settled", {
582
+ eventType: Schema.Literal("flows.harness.cell-settled.v1"),
583
+ cell: Schema.String,
584
+ outcome: Cell.Outcome,
585
+ /** Absent in journals written before execution frontiers were recorded. */
586
+ boundary: Schema.optional(Sandbox.FrameBoundary)
587
+ }) {}
588
+
589
+ /**
590
+ * The durable transition the controller applied after a cell settled.
591
+ *
592
+ * @category events
593
+ * @since 0.1.0
594
+ * @slop
595
+ */
596
+ export class TransitionApplied extends Schema.TaggedClass<TransitionApplied>(
597
+ "flows/harness/AgentEvent/TransitionApplied"
598
+ )("transition-applied", {
599
+ eventType: Schema.Literal("flows.harness.transition-applied.v1"),
600
+ transition: Cell.Transition
601
+ }) {}
602
+
603
+ /**
604
+ * The controller issuing a read-cap intervention to the next frame.
605
+ *
606
+ * Kept separately from {@link ReadOnlyDemanded}: this event records the user
607
+ * message entering the model transcript, while that event records how a later
608
+ * frame answered it. A crash between those boundaries must retain the demand.
609
+ *
610
+ * @category events
611
+ * @since 1.0.0-rc.0
612
+ */
613
+ export class ReadOnlyDemandIssued extends Schema.TaggedClass<ReadOnlyDemandIssued>(
614
+ "flows/harness/AgentEvent/ReadOnlyDemandIssued"
615
+ )("read-only-demand-issued", {
616
+ eventType: Schema.Literal("flows.harness.read-only-demand-issued.v1"),
617
+ /** Consecutive read-only frames the run had spent. */
618
+ streak: Schema.Int,
619
+ /** The armed threshold that streak reached. */
620
+ cap: Schema.Int,
621
+ /** The frame the demand was attached to, which is the one that must answer it. */
622
+ nextFrame: Schema.Int
623
+ }) {}
624
+
625
+ /**
626
+ * The outcome of the frame immediately following a read-cap intervention.
627
+ *
628
+ * @category events
629
+ * @since 0.1.0
630
+ */
631
+ export class ReadOnlyDemanded extends Schema.TaggedClass<ReadOnlyDemanded>(
632
+ "flows/harness/AgentEvent/ReadOnlyDemanded"
633
+ )("read-only-demanded", {
634
+ eventType: Schema.Literal("flows.harness.read-only-demanded.v1"),
635
+ streak: Schema.Int,
636
+ cap: Schema.Int,
637
+ nextFrame: Schema.Int,
638
+ nextAction: Schema.Literals(["write", "justification", "read-only", "park"])
639
+ }) {}
640
+
641
+ /**
642
+ * The controller telling a run it has stopped learning anything.
643
+ *
644
+ * Written when a run reaches its repeat-observation threshold: consecutive
645
+ * frames that issued calls, issued none the run had not already issued, and
646
+ * changed nothing. Both this and {@link ReadOnlyDemandIssued} are written when
647
+ * their demand is issued; {@link ReadOnlyDemanded} additionally records the
648
+ * read-cap demand's later answer because that answer is a field on a
649
+ * transition. A repeat demand is answered by the shape of the next frame's
650
+ * calls, which the journal already writes one by one.
651
+ *
652
+ * @category events
653
+ * @since 0.1.0
654
+ */
655
+ export class RepeatDemanded extends Schema.TaggedClass<RepeatDemanded>(
656
+ "flows/harness/AgentEvent/RepeatDemanded"
657
+ )("repeat-demanded", {
658
+ eventType: Schema.Literal("flows.harness.repeat-demanded.v1"),
659
+ /** Consecutive repeat-observation frames the run had spent. */
660
+ frames: Schema.Int,
661
+ /** The armed threshold that streak reached. */
662
+ cap: Schema.Int,
663
+ /** The frame the demand was attached to, which is the one that must answer it. */
664
+ nextFrame: Schema.Int
665
+ }) {}
666
+
667
+ /**
668
+ * The controller refusing one completion whose evidence was narrowed.
669
+ *
670
+ * Written when a frame returns `complete` while the check it ran is a strict
671
+ * narrowing of one the run had already run in full, over a tree that has since
672
+ * changed and never re-run since. Written when the demand is *issued*, like the
673
+ * repeat demand and unlike the read-cap one, because what answers it is the
674
+ * shape of the next frame's calls and its output — both of which the journal
675
+ * already writes.
676
+ *
677
+ * The event is the whole audit trail for the bounce. `broader` and `narrower`
678
+ * quote the two inputs as the run wrote them, and the two digests say which
679
+ * trees they were measured over, so a grader can decide after the fact whether
680
+ * the demand was right without replaying anything.
681
+ *
682
+ * @category events
683
+ * @since 0.1.0
684
+ */
685
+ export class NarrowedDemanded extends Schema.TaggedClass<NarrowedDemanded>(
686
+ "flows/harness/AgentEvent/NarrowedDemanded"
687
+ )("narrowed-demanded", {
688
+ eventType: Schema.Literal("flows.harness.narrowed-demanded.v1"),
689
+ /** The flow both checks named. */
690
+ flow: Schema.String,
691
+ /** The broader check's input as the run wrote it, clipped. */
692
+ broader: Schema.String,
693
+ /** The narrowing check's input as the run wrote it, clipped. */
694
+ narrower: Schema.String,
695
+ /** Workspace digest the broader check was last run over. */
696
+ broaderDigest: Schema.String,
697
+ /** Workspace digest the completing frame closed on. */
698
+ currentDigest: Schema.String,
699
+ /** The frame the demand was attached to, which is the one that must answer it. */
700
+ nextFrame: Schema.Int
701
+ }) {}
702
+
703
+ /**
704
+ * The controller refusing one completion with no change behind it.
705
+ *
706
+ * Written when a frame returns `complete` while the tree it closed on is
707
+ * byte-for-byte the tree the run opened on. Written when the demand is
708
+ * *issued*, like the narrowing demand, because what answers it is the next
709
+ * frame's own record — an edit that moves the digest, or a second completion
710
+ * saying no change was needed — and the journal already writes both.
711
+ *
712
+ * The two digests are the whole audit trail: a grader can decide after the fact
713
+ * whether the demand was right by comparing them to the run's
714
+ * `mutation-observed` record, without replaying anything.
715
+ *
716
+ * @category events
717
+ * @since 0.1.0
718
+ */
719
+ export class UnmovedDemanded extends Schema.TaggedClass<UnmovedDemanded>(
720
+ "flows/harness/AgentEvent/UnmovedDemanded"
721
+ )("unmoved-demanded", {
722
+ eventType: Schema.Literal("flows.harness.unmoved-demanded.v1"),
723
+ /** Workspace digest the run opened on. */
724
+ openedDigest: Schema.String,
725
+ /** Workspace digest the completing frame closed on, equal to the first. */
726
+ currentDigest: Schema.String,
727
+ /** The frame the demand was attached to, which is the one that must answer it. */
728
+ nextFrame: Schema.Int
729
+ }) {}
730
+
731
+ /**
732
+ * The controller refusing one completion that stepped around a failing check.
733
+ *
734
+ * Written when a frame returns `complete` while a check recorded over the same
735
+ * tree reported a failing exit status, was never re-run, and a later check went
736
+ * back to the same subject with a different command.
737
+ *
738
+ * `failed` and `instead` quote the two inputs as the run wrote them, and
739
+ * `currentDigest` is the tree both were measured over, so the record says which
740
+ * reading the completion stands on and which one replaced it.
741
+ *
742
+ * @category events
743
+ * @since 0.1.0
744
+ */
745
+ export class UnresolvedDemanded extends Schema.TaggedClass<UnresolvedDemanded>(
746
+ "flows/harness/AgentEvent/UnresolvedDemanded"
747
+ )("unresolved-demanded", {
748
+ eventType: Schema.Literal("flows.harness.unresolved-demanded.v1"),
749
+ /** The flow both checks named. */
750
+ flow: Schema.String,
751
+ /** The failing check's input as the run wrote it, clipped. */
752
+ failed: Schema.String,
753
+ /** The input of the reading the run took instead, clipped. */
754
+ instead: Schema.String,
755
+ /** Workspace digest both checks were recorded over, and the frame closed on. */
756
+ currentDigest: Schema.String,
757
+ /** The frame the demand was attached to, which is the one that must answer it. */
758
+ nextFrame: Schema.Int
759
+ }) {}
760
+
761
+ /**
762
+ * The controller handing back a completion its own cell wrote before a call
763
+ * in that cell failed.
764
+ *
765
+ * `failures` quotes each failed call's flow and message as the flow reported
766
+ * them, so the record says which results the completion was written without.
767
+ * See `FailedCall`.
768
+ *
769
+ * @category events
770
+ * @since 1.0.0-rc.1
771
+ */
772
+ export class FailedCallDemanded extends Schema.TaggedClass<FailedCallDemanded>(
773
+ "flows/harness/AgentEvent/FailedCallDemanded"
774
+ )("failed-call-demanded", {
775
+ eventType: Schema.Literal("flows.harness.failed-call-demanded.v1"),
776
+ /** The calls the completing frame settled as failures, oldest first. */
777
+ failures: Schema.Array(Schema.Struct({ flow: Schema.String, message: Schema.String })),
778
+ /** The frame the demand was attached to, which is the one that must answer it. */
779
+ nextFrame: Schema.Int
780
+ }) {}
781
+
782
+ /**
783
+ * The controller handing back a completion whose output does not fit the
784
+ * shape the host declared for it.
785
+ *
786
+ * `note` is the correction the run was shown, verbatim, so a transcript
787
+ * rebuilt from the journal holds what the model read. The same session
788
+ * answers it, with everything its earlier frames bound still in scope.
789
+ *
790
+ * @category events
791
+ * @since 1.0.0-rc.1
792
+ */
793
+ export class OutputDemanded extends Schema.TaggedClass<OutputDemanded>(
794
+ "flows/harness/AgentEvent/OutputDemanded"
795
+ )("output-demanded", {
796
+ eventType: Schema.Literal("flows.harness.output-demanded.v1"),
797
+ /** The correction handed back with the completion. */
798
+ note: Schema.String,
799
+ /** The frame the demand was attached to, which is the one that must answer it. */
800
+ nextFrame: Schema.Int
801
+ }) {}
802
+
803
+ /**
804
+ * The controller handing back a completion its own cell wrote before reading
805
+ * the calls it made.
806
+ *
807
+ * `calls` names each call the completing frame settled, in ledger order, with
808
+ * the head of the result the next frame was shown, so the record says which
809
+ * results the completion was written without.
810
+ *
811
+ * @category events
812
+ * @since 1.0.0-rc.1
813
+ */
814
+ export class UnobservedDemanded extends Schema.TaggedClass<UnobservedDemanded>(
815
+ "flows/harness/AgentEvent/UnobservedDemanded"
816
+ )("unobserved-demanded", {
817
+ eventType: Schema.Literal("flows.harness.unobserved-demanded.v1"),
818
+ /** The calls the completion was written without reading, oldest first. */
819
+ calls: Schema.Array(
820
+ Schema.Struct({ flow: Schema.String, ordinal: Schema.Int, ok: Schema.Boolean, summary: Schema.String })
821
+ ),
822
+ /** The frame the demand was attached to, which is the one that must answer it. */
823
+ nextFrame: Schema.Int
824
+ }) {}
825
+
826
+ /**
827
+ * The controller refusing one completion that holds a single reading.
828
+ *
829
+ * Written when a frame returns `complete` while the last check it ran names
830
+ * subjects no other check of the run covers together, and the run never issued
831
+ * that exact call before. The sibling of `narrowed-demanded`, from the other
832
+ * side: that one fires when a broader check exists in the ledger and was not
833
+ * re-run, this one when no broader check was ever taken.
834
+ *
835
+ * `check` quotes the input as the run wrote it and `targets` names the subjects
836
+ * the demand is about, so a grader can decide after the fact whether the demand
837
+ * was right without replaying anything.
838
+ *
839
+ * @category events
840
+ * @since 0.1.0
841
+ */
842
+ export class NarrowOnlyDemanded extends Schema.TaggedClass<NarrowOnlyDemanded>(
843
+ "flows/harness/AgentEvent/NarrowOnlyDemanded"
844
+ )("narrow-only-demanded", {
845
+ eventType: Schema.Literal("flows.harness.narrow-only-demanded.v1"),
846
+ /** The flow the check named. */
847
+ flow: Schema.String,
848
+ /** The check's input as the run wrote it, clipped. */
849
+ check: Schema.String,
850
+ /** The subjects it names, sorted. */
851
+ targets: Schema.Array(Schema.String),
852
+ /** Workspace digest the completing frame closed on; empty when unmeasured. */
853
+ currentDigest: Schema.String,
854
+ /** The frame the demand was attached to, which is the one that must answer it. */
855
+ nextFrame: Schema.Int
856
+ }) {}
857
+
858
+ /**
859
+ * What Jev read off one completion claim, whether or not it braked.
860
+ *
861
+ * The only demand event written on every evaluation rather than only on a
862
+ * firing, and it is written that way on purpose: the other five demands are
863
+ * derived from facts a grader can recompute from the journal, and this one is
864
+ * a model's reading that exists nowhere else. Without the passing readings the
865
+ * record would answer "how often did it fire" and could never answer "how
866
+ * often did it agree", which is the only question that says whether arming it
867
+ * was right. `demanded` is the field that separates them, and it says exactly one
868
+ * thing: whether this reading handed the completion back for a frame. A
869
+ * reading comes out three ways, not two. It passes, and cost the run nothing.
870
+ * It demands, and cost the run a frame. Or it reads against a run with no
871
+ * bounce left to spend, where `demanded` is false and the run ends on
872
+ * `CompletionClaim.unproven`: the verdict is in the run's failure, and the two
873
+ * probabilities here are what a grader re-applies a threshold to either way.
874
+ *
875
+ * `complete` and `overclaims` are the transport's probabilities for the
876
+ * classifier's two questions, verbatim, so a grader can re-apply any
877
+ * threshold to a whole wave without re-asking. `latencyMs` is what the
878
+ * evaluation cost in wall clock on the hot path of a completion. No event is
879
+ * written where the brake is disarmed (`claimCap` of zero), where the
880
+ * transport failed, or where there was no task and no claim to ask about:
881
+ * nothing was read, so there is nothing to record. A spent cap is no longer
882
+ * one of those cases — the reading still happens, and it is the reading that
883
+ * ends the run. See `CompletionClaim`.
884
+ *
885
+ * @category events
886
+ * @since 1.0.0-rc.0
887
+ */
888
+ export class ClaimDemanded extends Schema.TaggedClass<ClaimDemanded>(
889
+ "flows/harness/AgentEvent/ClaimDemanded"
890
+ )("claim-demanded", {
891
+ eventType: Schema.Literal("flows.harness.claim-demanded.v1"),
892
+ /** Probability the transport gave to "the task as stated is done"; journaled, decides nothing. */
893
+ complete: Schema.Number,
894
+ /** Probability it gave to "the claim asserts what the evidence does not show"; journaled, decides nothing. */
895
+ overclaims: Schema.Number,
896
+ /** Probability it gave to "the claim reports a command or a result the evidence does not record"; the one that decides. */
897
+ invented: Schema.Number,
898
+ /** Wall-clock milliseconds the evaluation took. */
899
+ latencyMs: Schema.Int,
900
+ /** Token usage reported by the evaluator, absent from older journal entries. */
901
+ usage: Schema.optional(Usage),
902
+ /** Whether this reading handed the completion back. */
903
+ demanded: Schema.Boolean,
904
+ /**
905
+ * Whether this reading ended the run instead of handing the completion back.
906
+ *
907
+ * The third of the three ways a reading comes out, and the one that had no
908
+ * field. `demanded` false meant both "the claim stands" and "the claim is
909
+ * refused and the run is over", which a projection cannot tell apart, so the
910
+ * refusal wrote no card and the sentence it refused was nowhere a person
911
+ * could read. Absent from older journal entries, where it decodes false: a
912
+ * journal written before this field carries its verdict in the run's
913
+ * failure, which is where it always was.
914
+ */
915
+ refused: Schema.Boolean.pipe(
916
+ Schema.withConstructorDefault(Effect.succeed(false)),
917
+ Schema.withDecodingDefaultKey(Effect.succeed(false))
918
+ ),
919
+ /** Workspace digest the completing frame closed on; empty when unmeasured. */
920
+ currentDigest: Schema.String,
921
+ /** The frame the demand was attached to, which is the one that must answer it. */
922
+ nextFrame: Schema.Int
923
+ }) {}
924
+
925
+ const Probability = Schema.Number.check(Schema.isBetween({ minimum: 0, maximum: 1 }))
926
+
927
+ /**
928
+ * One classifier answer as `decision-settled` journals it, tagged by kind.
929
+ *
930
+ * `confidence` is the PROVIDER's number, `Evaluator.Response.confidence`, and
931
+ * it is absent whenever the provider sent none. It is never the largest
932
+ * probability wearing the name: `Classifier.confidence` reads 1 for an answer
933
+ * that carried no distribution at all, so a record that filled the field from
934
+ * it would report certainty exactly where the provider reported nothing. A
935
+ * boolean has no such field because its probability is the whole answer.
936
+ *
937
+ * @category models
938
+ * @since 1.0.0-rc.0
939
+ */
940
+ export const DecisionAnswer = Schema.Union([
941
+ Schema.Struct({
942
+ kind: Schema.Literal("boolean"),
943
+ /** The probability the transport gave to yes. */
944
+ p: Probability
945
+ }),
946
+ Schema.Struct({
947
+ kind: Schema.Literal("choice"),
948
+ /** The option chosen. */
949
+ value: Schema.String,
950
+ probabilities: Schema.Record(Schema.String, Probability),
951
+ /** The provider's own number, unchecked: it is theirs to define, and a record must not fail a run. */
952
+ confidence: Schema.optionalKey(Schema.Number)
953
+ }),
954
+ Schema.Struct({
955
+ kind: Schema.Literal("score"),
956
+ /** The score as the transport gave it, interpolated over rung indexes. */
957
+ value: Schema.Number,
958
+ /** The label of the nearest rung. */
959
+ label: Schema.String,
960
+ probabilities: Schema.Record(Schema.String, Probability),
961
+ /** The provider's own number, unchecked: it is theirs to define, and a record must not fail a run. */
962
+ confidence: Schema.optionalKey(Schema.Number)
963
+ })
964
+ ])
965
+
966
+ /**
967
+ * The decoded form of {@link DecisionAnswer}.
968
+ *
969
+ * @category models
970
+ * @since 1.0.0-rc.0
971
+ */
972
+ export type DecisionAnswer = typeof DecisionAnswer.Type
973
+
974
+ /**
975
+ * The answers of one evaluation in the shape {@link DecisionSettled} carries.
976
+ *
977
+ * `confidence` is `Evaluator.Response.confidence`, passed through per question
978
+ * and left out per question: see {@link DecisionAnswer}.
979
+ *
980
+ * @category conversions
981
+ * @since 1.0.0-rc.0
982
+ */
983
+ export const decisionAnswers = (
984
+ answers: Readonly<Record<string, Classifier.Answer>>,
985
+ confidence: Readonly<Record<string, number>> | undefined
986
+ ): Readonly<Record<string, DecisionAnswer>> =>
987
+ Object.fromEntries(
988
+ Object.entries(answers).map(([id, answer]): readonly [string, DecisionAnswer] => {
989
+ if ("probability" in answer) return [id, { kind: "boolean", p: answer.probability }]
990
+ const reported = confidence !== undefined && Object.hasOwn(confidence, id) ? confidence[id] : undefined
991
+ const provided = reported === undefined ? {} : { confidence: reported }
992
+ return "label" in answer
993
+ ? [id, {
994
+ kind: "score",
995
+ value: answer.value,
996
+ label: answer.label,
997
+ probabilities: answer.probabilities,
998
+ ...provided
999
+ }]
1000
+ : [id, { kind: "choice", value: answer.value, probabilities: answer.probabilities, ...provided }]
1001
+ })
1002
+ )
1003
+
1004
+ /**
1005
+ * One decision a classifier made, with everything a reader needs to make it
1006
+ * again: the state it read, the questions it was asked, and what it answered.
1007
+ *
1008
+ * The generalisation of {@link ClaimDemanded}, which stays. That event is three
1009
+ * probabilities and a verdict, and it cannot say what the probabilities were
1010
+ * probabilities OF: the evidence the brake assembled exists nowhere else, so a
1011
+ * reading could be re-thresholded and never re-asked. This one carries the
1012
+ * evidence. It is written beside `claim-demanded` rather than instead of it,
1013
+ * because every projection that counts readings counts that event.
1014
+ *
1015
+ * `classifier` is the declaration's stable id, never its description, and
1016
+ * `digest` is `Classifier.digest`, so a reader can tell a decision made under
1017
+ * questions that have since been reworded from one it can reproduce.
1018
+ * `questions` are the wire shapes the transport was sent.
1019
+ *
1020
+ * `acted` says whether the decision changed what the run did next. For the
1021
+ * completion brake that is a completion handed back or a run ended; a reading
1022
+ * that let the claim stand is `false`, and it is journaled all the same,
1023
+ * because the passing decisions are what say whether asking was right.
1024
+ *
1025
+ * `decidedBy` names who answered: `jev` for the decision-only model behind
1026
+ * `Evaluator`, `seat` for a generation seat asked to judge, `human` for a
1027
+ * person. Only `jev` is written today.
1028
+ *
1029
+ * `scope` and `frame` are the join keys {@link ModelRequested} carries, for the
1030
+ * reason it carries them.
1031
+ *
1032
+ * An emitter must produce the reading inside a recorded boundary, as the
1033
+ * completion brake does, and emit what the record holds. The answers are a
1034
+ * model's and the latency is a clock's, so a replayed frame that asked again
1035
+ * would journal a second, different decision at the same coordinates.
1036
+ *
1037
+ * @category events
1038
+ * @since 1.0.0-rc.0
1039
+ */
1040
+ export class DecisionSettled extends Schema.TaggedClass<DecisionSettled>(
1041
+ "flows/harness/AgentEvent/DecisionSettled"
1042
+ )("decision-settled", {
1043
+ eventType: Schema.Literal("flows.harness.decision-settled.v1"),
1044
+ /** The run's session, which is the recorded scope of the step that decided. */
1045
+ scope: Schema.String,
1046
+ /** The controller's frame number for the turn the decision was made in. */
1047
+ frame: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
1048
+ /** The classifier's stable id. */
1049
+ classifier: Schema.String,
1050
+ /** `Classifier.digest`: the canonical hash of the id and the questions. */
1051
+ digest: Schema.String,
1052
+ /** The encoded state the questions were asked about, as the transport was sent it. */
1053
+ state: Schema.Json,
1054
+ /** The questions as they crossed the wire, keyed by question id. */
1055
+ questions: Schema.Record(Schema.String, Evaluator.Question),
1056
+ /** One answer per question id, tagged by kind. */
1057
+ answers: Schema.Record(Schema.String, DecisionAnswer),
1058
+ /** Wall-clock milliseconds the evaluation took. */
1059
+ latencyMs: Schema.Int,
1060
+ /** Whether this decision changed what the run did next. */
1061
+ acted: Schema.Boolean,
1062
+ /** Who answered. */
1063
+ decidedBy: Schema.Literals(["jev", "seat", "human"]),
1064
+ /** Token usage reported by the evaluator, absent when it supplied none. */
1065
+ usage: Schema.optional(Usage)
1066
+ }) {}
1067
+
1068
+ const Level = Schema.Literals(["none", "mild", "strong"])
1069
+
1070
+ /**
1071
+ * What Jev read off one frame of a running run, whether or not it nudged.
1072
+ *
1073
+ * Written by the supervisor fiber for every snapshot it read, at some time
1074
+ * after the frame it is a reading of closed: the reading is taken off the
1075
+ * cell loop's hot path, so its position among the frame's other events is not
1076
+ * fixed and `scope` and `frame` are its coordinates. `frame` is the frame the
1077
+ * snapshot was built from, not the frame that will read any nudge.
1078
+ *
1079
+ * `thrashing`, `onTarget` and `suspect` are the transport's probabilities
1080
+ * verbatim, so a wave re-applies any threshold without re-asking. The five
1081
+ * levels and `needsHelp` are the transport's words: nothing here is a default
1082
+ * a failed reading fills in, because a failed reading writes
1083
+ * {@link SupervisorUnjudged} and never this. `crossed` says whether the
1084
+ * reading passed a nudge threshold; `nudged` whether a nudge was handed to
1085
+ * the next boundary, which needs the host to have armed steering. The
1086
+ * recalled rows are judged by Relevance and journaled beside this as
1087
+ * `relevance-settled`. `decision-settled` beside this carries the snapshot
1088
+ * and every answer.
1089
+ *
1090
+ * @category events
1091
+ * @since 1.0.0-rc.0
1092
+ */
1093
+ export class SupervisorSettled extends Schema.TaggedClass<SupervisorSettled>(
1094
+ "flows/harness/AgentEvent/SupervisorSettled"
1095
+ )("supervisor-settled", {
1096
+ eventType: Schema.Literal("flows.harness.supervisor-settled.v1"),
1097
+ /** The run's session. */
1098
+ scope: Schema.String,
1099
+ /** The frame the snapshot was built from. */
1100
+ frame: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
1101
+ /** Probability the run is repeating itself without converging. */
1102
+ thrashing: Schema.Number,
1103
+ /** Probability the run is still working on the task as stated. */
1104
+ onTarget: Schema.Number,
1105
+ /** Probability the run's evidence is suspect. */
1106
+ suspect: Schema.Number,
1107
+ /** Probability visible earlier context is contradicted by later evidence. */
1108
+ outdatedContext: Schema.optional(Schema.Number),
1109
+ /** Probability visible earlier context is no longer useful for this task. */
1110
+ irrelevantContext: Schema.optional(Schema.Number),
1111
+ frustrated: Level,
1112
+ anxious: Level,
1113
+ scared: Level,
1114
+ confused: Level,
1115
+ confident: Level,
1116
+ /** The one word a person is shown. */
1117
+ needsHelp: Schema.Literals(["none", "clarification", "permission", "stuck", "risky_action"]),
1118
+ /** Whether the reading crossed a nudge threshold. */
1119
+ crossed: Schema.Boolean,
1120
+ /** Whether a nudge was handed to the next boundary. */
1121
+ nudged: Schema.Boolean,
1122
+ /**
1123
+ * Whether steering was armed for this reading. `discipline-armed` states it
1124
+ * once, at a run's first frame; a resumed run may be armed differently, and
1125
+ * this is where the journal says what the reading actually ran under.
1126
+ * Absent from readings journaled before it existed.
1127
+ */
1128
+ steer: Schema.optional(Schema.Boolean),
1129
+ /**
1130
+ * Whether the snapshot had more uncalled skills than `Supervisor.skillLimit`,
1131
+ * so some were not scored. Absent when every one was.
1132
+ */
1133
+ skillsCapped: Schema.optional(Schema.Boolean),
1134
+ /** Wall-clock milliseconds the evaluation took. */
1135
+ latencyMs: Schema.Int,
1136
+ /** Token usage reported by the evaluator, absent when it supplied none. */
1137
+ usage: Schema.optional(Usage),
1138
+ /** Each armed monitor's probability in this reading, and whether it crossed. */
1139
+ monitors: Schema.optional(Schema.Array(Schema.Struct({
1140
+ id: Schema.String,
1141
+ kind: MonitorKind,
1142
+ p: Schema.Number,
1143
+ crossed: Schema.Boolean
1144
+ })))
1145
+ }) {}
1146
+
1147
+ /**
1148
+ * A supervisor snapshot nobody could judge, and why.
1149
+ *
1150
+ * Written instead of {@link SupervisorSettled}, never beside it: no
1151
+ * evaluator on the host, a refusal, a deadline, an answer that does not
1152
+ * decode, a run that ended with the reading in flight. `reason` is
1153
+ * `unconfigured`, `interrupted`, or the transport's own error code. A reading
1154
+ * that fails inserts nothing and reports no level, so a
1155
+ * wave counting calm runs counts only runs Jev read. An `interrupted` reading
1156
+ * was asked and may have cost a call, so a wave counting Jev's cost counts it.
1157
+ *
1158
+ * @category events
1159
+ * @since 1.0.0-rc.0
1160
+ */
1161
+ export class SupervisorUnjudged extends Schema.TaggedClass<SupervisorUnjudged>(
1162
+ "flows/harness/AgentEvent/SupervisorUnjudged"
1163
+ )("supervisor-unjudged", {
1164
+ eventType: Schema.Literal("flows.harness.supervisor-unjudged.v1"),
1165
+ /** The run's session. */
1166
+ scope: Schema.String,
1167
+ /** The frame the snapshot was built from. */
1168
+ frame: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
1169
+ /** `unconfigured`, `interrupted`, or the transport's own error code. */
1170
+ reason: UnjudgedReason,
1171
+ /** What went wrong, safe to journal: see `Evaluator.publicMessage`. */
1172
+ detail: Schema.String,
1173
+ /** What each request of the failed reading paid; absent when none was metered. */
1174
+ usage: Schema.optional(Schema.Array(Usage))
1175
+ }) {}
1176
+
1177
+ /**
1178
+ * A Jev reading that could not be judged, outside the supervisor.
1179
+ *
1180
+ * Written by a relevance, compaction or routing reading instead of its
1181
+ * settlement. The caller then keeps everything it would have filtered, so the
1182
+ * receipt is what says the filter did not run. `items` is how many items the
1183
+ * failed reading covered.
1184
+ *
1185
+ * @category events
1186
+ * @since 1.0.0-rc.0
1187
+ */
1188
+ export class DecisionUnjudged extends Schema.TaggedClass<DecisionUnjudged>(
1189
+ "flows/harness/AgentEvent/DecisionUnjudged"
1190
+ )("decision-unjudged", {
1191
+ eventType: Schema.Literal("flows.harness.decision-unjudged.v1"),
1192
+ /** The run's session. */
1193
+ scope: Schema.String,
1194
+ /** The frame the reading was asked in. */
1195
+ frame: NonNegativeSafeInt,
1196
+ /** The classifier's stable id. */
1197
+ classifier: Schema.String,
1198
+ /** `unconfigured`, `interrupted`, or the transport's own error code. */
1199
+ reason: UnjudgedReason,
1200
+ /** What went wrong, safe to journal: see `Evaluator.publicMessage`. */
1201
+ detail: Schema.String,
1202
+ /** Items the failed reading covered. */
1203
+ items: NonNegativeSafeInt,
1204
+ /** What each request of the failed reading paid; absent when none was metered. */
1205
+ usage: Schema.optional(Schema.Array(Usage))
1206
+ }) {}
1207
+
1208
+ const RelevanceItem = Schema.Struct({
1209
+ kind: RelevanceKind,
1210
+ id: Schema.String,
1211
+ /** Digest of the item's text; the text itself is never journaled. */
1212
+ digest: Schema.String,
1213
+ /** Probability the item is unnecessary for the task as stated. */
1214
+ p: Schema.Number
1215
+ })
1216
+
1217
+ /**
1218
+ * Which human-provided items a relevance reading kept and which it withheld.
1219
+ *
1220
+ * An item is withheld only at or above `withholdAt`. Ids and digests, never
1221
+ * item text.
1222
+ *
1223
+ * @category events
1224
+ * @since 1.0.0-rc.0
1225
+ */
1226
+ export class RelevanceSettled extends Schema.TaggedClass<RelevanceSettled>(
1227
+ "flows/harness/AgentEvent/RelevanceSettled"
1228
+ )("relevance-settled", {
1229
+ eventType: Schema.Literal("flows.harness.relevance-settled.v1"),
1230
+ /** The run's session. */
1231
+ scope: Schema.String,
1232
+ /** The frame the reading was asked in. */
1233
+ frame: NonNegativeSafeInt,
1234
+ /**
1235
+ * `run` for the gate at run start, `supervisor` for recalled memory,
1236
+ * `recall` for a recall the model called.
1237
+ */
1238
+ source: Schema.Literals(["run", "supervisor", "recall"]),
1239
+ /** The probability at or above which an item is withheld. */
1240
+ withholdAt: Schema.Number,
1241
+ kept: Schema.Array(RelevanceItem),
1242
+ withheld: Schema.Array(RelevanceItem),
1243
+ /** Wall-clock milliseconds the evaluation took. */
1244
+ latencyMs: NonNegativeSafeInt,
1245
+ /** Token usage reported by the evaluator, absent when it supplied none. */
1246
+ usage: Schema.optional(Usage)
1247
+ }) {}
1248
+
1249
+ /**
1250
+ * A withheld flow restored because the run called it by name.
1251
+ *
1252
+ * @category events
1253
+ * @since 1.0.0-rc.0
1254
+ */
1255
+ export class RelevanceRestored extends Schema.TaggedClass<RelevanceRestored>(
1256
+ "flows/harness/AgentEvent/RelevanceRestored"
1257
+ )("relevance-restored", {
1258
+ eventType: Schema.Literal("flows.harness.relevance-restored.v1"),
1259
+ /** The run's session. */
1260
+ scope: Schema.String,
1261
+ /** The frame whose call restored it. */
1262
+ frame: NonNegativeSafeInt,
1263
+ /** The flow restored. */
1264
+ flow: Schema.String
1265
+ }) {}
1266
+
1267
+ /**
1268
+ * A panel a routed run fans out to: each member seat, with the backups it
1269
+ * fails over to, answers the task, and `merger` merges their answers.
1270
+ *
1271
+ * @category schemas
1272
+ * @since 1.0.0-rc.0
1273
+ */
1274
+ export const SeatPanel = Schema.Struct({
1275
+ seats: Schema.Array(Schema.Struct({ seat: Schema.String, backups: Schema.Array(Schema.String) })),
1276
+ merger: Schema.String
1277
+ })
1278
+
1279
+ /**
1280
+ * The seat a run with no declared model was routed to, and who chose it.
1281
+ *
1282
+ * `decidedBy` is `jev` when Jev answered the routing questions. Rows written
1283
+ * before the routing graph may say `only` and carry the seat choice's
1284
+ * `confidence`.
1285
+ *
1286
+ * @category events
1287
+ * @since 1.0.0-rc.0
1288
+ */
1289
+ export class SeatRouted extends Schema.TaggedClass<SeatRouted>(
1290
+ "flows/harness/AgentEvent/SeatRouted"
1291
+ )("seat-routed", {
1292
+ eventType: Schema.Literal("flows.harness.seat-routed.v1"),
1293
+ /** The run's session. */
1294
+ scope: Schema.String,
1295
+ /** What the flow declared, such as `auto`. */
1296
+ declared: Schema.String,
1297
+ /** The seat chosen. */
1298
+ seat: Schema.String,
1299
+ /** The chosen seat's model. */
1300
+ modelId: Schema.String,
1301
+ /** The system-prompt variant chosen with it, when one was. */
1302
+ variant: Schema.NullOr(Schema.String),
1303
+ /** The seats offered. */
1304
+ candidates: Schema.Array(Schema.String),
1305
+ decidedBy: Schema.Literals(["jev", "only"]),
1306
+ /** The provider's own number, absent when it sent none. */
1307
+ confidence: Schema.optional(Schema.Number),
1308
+ /** Wall-clock milliseconds the routing took. */
1309
+ latencyMs: NonNegativeSafeInt,
1310
+ /** The seats `seat` fails over to, in order; absent when there are none. */
1311
+ backups: Schema.optionalKey(Schema.Array(Schema.String)),
1312
+ /** The panel the task was routed to, whose merger is `seat`; absent for one seat. */
1313
+ panel: Schema.optionalKey(SeatPanel)
1314
+ }) {}
1315
+
1316
+ /**
1317
+ * A memory read or write the store refused.
1318
+ *
1319
+ * A `recall` is written by the supervisor fiber beside the reading it belongs
1320
+ * to, never instead of it: a memory fault is not a supervisor fault, and the
1321
+ * reading still settles. A `remember` is written at run end by the transcript
1322
+ * miner, for a fact Jev accepted that the store did not keep, and the run
1323
+ * still ends as it would have. `operation` says which side failed; `detail`
1324
+ * is the store's own account. A wave counts these rather than reading a log, because a
1325
+ * concurrent writer that loses a lock looks exactly like a run that
1326
+ * remembered nothing.
1327
+ *
1328
+ * @category events
1329
+ * @since 1.0.0-rc.0
1330
+ */
1331
+ export class SupervisorMemoryFailed extends Schema.TaggedClass<SupervisorMemoryFailed>(
1332
+ "flows/harness/AgentEvent/SupervisorMemoryFailed"
1333
+ )("supervisor-memory-failed", {
1334
+ eventType: Schema.Literal("flows.harness.supervisor-memory-failed.v1"),
1335
+ /** The run's session. */
1336
+ scope: Schema.String,
1337
+ /** The frame whose reading asked; for a `remember`, the run's last frame. */
1338
+ frame: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
1339
+ /** `recall` for a read, `remember` for a write. */
1340
+ operation: Schema.Literals(["recall", "remember"]),
1341
+ /** The store's own account of the failure. */
1342
+ detail: Schema.String
1343
+ }) {}
1344
+
1345
+ /**
1346
+ * The controller telling a run that its own evidence is complete.
1347
+ *
1348
+ * The one control that is not a brake, and the only one written for a frame
1349
+ * that has done nothing wrong: the run watched a check fail before it changed
1350
+ * anything and watched the same check, or a broader one, pass after. Written
1351
+ * when the observation is *issued*, at most once per run, because what answers
1352
+ * it is the next frame's transition and the journal already writes that.
1353
+ *
1354
+ * `failed` and `passed` quote the two inputs as the run wrote them, and `epoch`
1355
+ * is the run's count of mutating frames when the failure was recorded, so the
1356
+ * ordering the observation asserts is checkable after the fact. Nothing is
1357
+ * refused and no cap is spent, so there is no cap field to record.
1358
+ *
1359
+ * @category events
1360
+ * @since 0.1.0
1361
+ */
1362
+ export class SufficiencyObserved extends Schema.TaggedClass<SufficiencyObserved>(
1363
+ "flows/harness/AgentEvent/SufficiencyObserved"
1364
+ )("sufficiency-observed", {
1365
+ eventType: Schema.Literal("flows.harness.sufficiency-observed.v1"),
1366
+ /** The flow that ran the failing check. */
1367
+ flow: Schema.String,
1368
+ /** The failing check's input as the run wrote it, clipped. */
1369
+ failed: Schema.String,
1370
+ /** The input of the passing check that answered it, clipped. */
1371
+ passed: Schema.String,
1372
+ /** Mutating frames the run had spent when the failure was recorded. */
1373
+ epoch: Schema.Int,
1374
+ /** The frame the observation was attached to. */
1375
+ nextFrame: Schema.Int
1376
+ }) {}
1377
+
1378
+ /**
1379
+ * The controller telling a run that its stored proof was already green.
1380
+ *
1381
+ * **Nothing emits this.** `VacuousVerification` is unwired from `CellTurn`;
1382
+ * the event stays declared so the r93 journals that carry it keep decoding and
1383
+ * so a controlled re-measure needs no schema change. See `VacuousVerification`
1384
+ * for the evidence that turned the arm off.
1385
+ *
1386
+ * The second control in this package that is not a brake, and the narrower of
1387
+ * the two: a cell stored `state.verification` naming a call this run had
1388
+ * already watched pass over the tree it was handed, before any frame changed a
1389
+ * byte. Written when the observation is issued, at most once per distinct
1390
+ * verification input, and delivered on the `invalidProbe` channel because it is
1391
+ * the same class of fact — a result that reads identically on a broken tree and
1392
+ * on a fixed one.
1393
+ *
1394
+ * `check` quotes the stored input as the run wrote it, and `callDigest` is the
1395
+ * controller's own identity for that call, so a reader can reconcile the
1396
+ * observation against the run's own `cell-call-settled` rows without replaying
1397
+ * anything. Nothing is refused and no cap is spent, so there is no cap field.
1398
+ *
1399
+ * It is named for what it is -- the digest of `{ flow, input }`, nothing signs
1400
+ * it -- rather than `signature`, the controller's own word for it everywhere
1401
+ * else. The journal redacts by field name, and `signature` names a credential
1402
+ * often enough in this repository (an HMAC over share claims, a grant
1403
+ * envelope, a webhook header) that the rule stays. A field this row exists to
1404
+ * be reconciled by cannot be written as `[REDACTED]`, so the field carries the
1405
+ * honest word and the rule keeps its reach.
1406
+ *
1407
+ * @category events
1408
+ * @since 0.1.0
1409
+ */
1410
+ export class VacuousVerificationObserved extends Schema.TaggedClass<VacuousVerificationObserved>(
1411
+ "flows/harness/AgentEvent/VacuousVerificationObserved"
1412
+ )("vacuous-verification-observed", {
1413
+ eventType: Schema.Literal("flows.harness.vacuous-verification-observed.v1"),
1414
+ /** The flow the stored check named. */
1415
+ flow: Schema.String,
1416
+ /** The stored check's input as the run wrote it, clipped. */
1417
+ check: Schema.String,
1418
+ /** The controller's identity for that call: the digest of its flow and input. */
1419
+ callDigest: Schema.String,
1420
+ /** The frame the observation was attached to. */
1421
+ nextFrame: Schema.Int
1422
+ }) {}
1423
+
1424
+ /**
1425
+ * What one frame did to the workspace, and how the controller knows.
1426
+ *
1427
+ * Emitted once per frame that ran a cell. It is the frame's own answer to the
1428
+ * question every later audit asks — "did this frame change anything" — written
1429
+ * before any control acts on it, so a run that never trips the cap still leaves
1430
+ * the evidence behind.
1431
+ *
1432
+ * `basis` is the field that keeps the record honest. `observed` means the frame
1433
+ * had two measurements around it that each covered the whole workspace, so the
1434
+ * tree itself could answer. `partial` means a measurement was taken and stopped
1435
+ * at a bound before it covered the tree, so it is set aside: a prefix chosen by
1436
+ * sort order cannot say the files being edited outside it held still, and its
1437
+ * own movement is as likely to be a tool's churn as work. `declared` means the
1438
+ * host measured nothing at all.
1439
+ * Under the last two, `mutated` is only what the frame's calls claimed about
1440
+ * themselves — which is exactly the signal that missed a shell redirect over a
1441
+ * tracked source file.
1442
+ *
1443
+ * `mutated` is the union of the two signals, with one exception. A declaration
1444
+ * by a call that *succeeded* stands even where the measurement cannot see the
1445
+ * path it touched, because the alternative is failing a run that has been
1446
+ * editing all along on the strength of a walk that never looked at its files.
1447
+ * A declaration by a call that *failed* is a claim about what it would have
1448
+ * written, and where `basis` is `observed` and the digest did not move, the
1449
+ * tree has answered that claim: nothing was written, and the frame is not
1450
+ * counted as a write. So `declaredWrites: 1` beside `mutated: false` under
1451
+ * `observed` is a declaration the measurement vetoed, and both numbers stay in
1452
+ * the record.
1453
+ *
1454
+ * @category events
1455
+ * @since 0.1.0
1456
+ */
1457
+ export class MutationObserved extends Schema.TaggedClass<MutationObserved>(
1458
+ "flows/harness/AgentEvent/MutationObserved"
1459
+ )("mutation-observed", {
1460
+ eventType: Schema.Literal("flows.harness.mutation-observed.v1"),
1461
+ /** What the frame had to decide with: a full measurement, a partial one, or paperwork. */
1462
+ basis: Schema.Literals(["observed", "partial", "declared"]),
1463
+ /** Whether this frame changed anything: the tree said so, or a call declared it. */
1464
+ mutated: Schema.Boolean,
1465
+ /** Content address of the workspace as the frame left it; empty when unobserved. */
1466
+ digest: Schema.String,
1467
+ /** Paths the closing measurement covered; zero when unobserved. */
1468
+ paths: Schema.Int,
1469
+ /**
1470
+ * Calls this frame made that DECLARED a write, whether or not they landed.
1471
+ *
1472
+ * Journaled beside the observed answer rather than instead of it, because
1473
+ * the gap between the two numbers is the accounting defect itself: a frame
1474
+ * with `declaredWrites: 0` and `mutated: true` is a shell mutation nothing
1475
+ * else in the run can see, and a frame with `declaredWrites: 1` and
1476
+ * `mutated: false` under `observed` is a failed call whose declaration the
1477
+ * measurement contradicted.
1478
+ */
1479
+ declaredWrites: Schema.Int
1480
+ }) {}
1481
+
1482
+ /**
1483
+ * One tree this run pinned, and the store's own name for it.
1484
+ *
1485
+ * Journaled at the mint rather than only at its use, because the two are
1486
+ * frames apart by design: a run pins the tree it is about to change and reads
1487
+ * against it later, and a journal that recorded only the reading could not say
1488
+ * which tree it was a reading of. `ref` is the host's vocabulary and the
1489
+ * controller never interprets it; a grader reconciles it against the store by
1490
+ * hand. See `EngineLike` `Snapshot`.
1491
+ *
1492
+ * @category events
1493
+ * @since 0.1.0
1494
+ */
1495
+ export class CheckpointMinted extends Schema.TaggedClass<CheckpointMinted>(
1496
+ "flows/harness/AgentEvent/CheckpointMinted"
1497
+ )("checkpoint-minted", {
1498
+ eventType: Schema.Literal("flows.harness.checkpoint-minted.v1"),
1499
+ /** The handle the cell holds, and what a later call names in its `at`. */
1500
+ id: Schema.String,
1501
+ /** What the host recorded, in the host's own vocabulary. */
1502
+ ref: Schema.String,
1503
+ /** The cell that minted it, and where in that cell. */
1504
+ cell: Schema.String,
1505
+ ordinal: Schema.Int
1506
+ }) {}
1507
+
1508
+ /**
1509
+ * The durable reason a cell execution parked.
1510
+ *
1511
+ * @category events
1512
+ * @since 0.1.0
1513
+ * @slop
1514
+ */
1515
+ export class Suspended extends Schema.TaggedClass<Suspended>(
1516
+ "flows/harness/AgentEvent/Suspended"
1517
+ )("suspended", {
1518
+ eventType: Schema.Literal("flows.harness.suspended.v1"),
1519
+ reason: EngineLike.SuspendReason
1520
+ }) {}
1521
+
1522
+ /**
1523
+ * A sealed compaction summary and the prefix it replaces.
1524
+ *
1525
+ * @category events
1526
+ * @since 0.1.0
1527
+ * @slop
1528
+ */
1529
+ export class CompactionSettled extends Schema.TaggedClass<CompactionSettled>(
1530
+ "flows/harness/AgentEvent/CompactionSettled"
1531
+ )("compaction-settled", {
1532
+ eventType: Schema.Literal("flows.harness.compaction-settled.v1"),
1533
+ replacedPrefixDigest: Schema.String,
1534
+ // Counts messages, not segments: one live transcript segment can contain
1535
+ // both an assistant turn and its observations. Absent in older journals.
1536
+ retainedMessageCount: Schema.optional(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))),
1537
+ /** Absent when nothing replaced was squashed. */
1538
+ summary: Schema.optional(ModelRequest.Message),
1539
+ /** Replaced messages carried over verbatim, after the summary. */
1540
+ kept: Schema.optional(Schema.Array(ModelRequest.Message)),
1541
+ /** What a reading marked each replaced segment, by segment digest. */
1542
+ marks: Schema.optional(Schema.Array(Schema.Struct({
1543
+ digest: Schema.String,
1544
+ mark: CompactionMark,
1545
+ /** The invariant that overrode a `remove`, when one did. */
1546
+ pinned: Schema.optional(CompactionPin)
1547
+ }))),
1548
+ /** Estimated tokens the removed messages held. */
1549
+ removedTokens: Schema.optional(NonNegativeSafeInt),
1550
+ /**
1551
+ * True when a judged run could not mark: its facts do not describe every
1552
+ * transcript segment, as in state written before marks, so every replaced
1553
+ * message was squashed.
1554
+ */
1555
+ unaligned: Schema.optional(Schema.Boolean),
1556
+ /** Why the compaction ran, budget first. Absent in older journals, which compacted on the budget alone. */
1557
+ causes: Schema.optional(Schema.Array(CompactionCause))
1558
+ }) {}
1559
+
1560
+ /**
1561
+ * Steering messages drained at a turn boundary.
1562
+ *
1563
+ * @category events
1564
+ * @since 0.1.0
1565
+ * @slop
1566
+ */
1567
+ export class SteeringDrained extends Schema.TaggedClass<SteeringDrained>(
1568
+ "flows/harness/AgentEvent/SteeringDrained"
1569
+ )("steering-drained", {
1570
+ eventType: Schema.Literal("flows.harness.steering-drained.v1"),
1571
+ /** What the person sent, in admission order. */
1572
+ messages: Schema.Array(ModelRequest.Message),
1573
+ /**
1574
+ * What the run's supervisor delivered at the same boundary: a nudge or a
1575
+ * recalled row. The model reads these above the person's messages; they
1576
+ * never join the task the completion brake or the supervisor reads.
1577
+ */
1578
+ supervisor: Schema.optional(Schema.Array(ModelRequest.Message)),
1579
+ /** The monitor whose delivery `supervisor` carries, when one's does. */
1580
+ monitor: Schema.optional(Schema.String),
1581
+ /** Crossed monitors not delivered at this boundary, and why. */
1582
+ suppressed: Schema.optional(Schema.Array(Schema.Struct({ id: Schema.String, reason: Suppression }))),
1583
+ /** Keys of the memory rows delivered at this boundary. */
1584
+ memory: Schema.optional(Schema.Array(Schema.String))
1585
+ }) {}
1586
+
1587
+ /**
1588
+ * The terminal decision made at a turn boundary.
1589
+ *
1590
+ * @category events
1591
+ * @since 0.1.0
1592
+ * @slop
1593
+ */
1594
+ export class TurnClosed extends Schema.TaggedClass<TurnClosed>(
1595
+ "flows/harness/AgentEvent/TurnClosed"
1596
+ )("turn-closed", {
1597
+ eventType: Schema.Literal("flows.harness.turn-closed.v1"),
1598
+ stopReason: ModelRequest.StopReason,
1599
+ outcome: Schema.Literals(["continue", "resolved", "aborted", "suspended"])
1600
+ }) {}
1601
+
1602
+ /**
1603
+ * A permission request reported for engine-owned suspension and resolution.
1604
+ *
1605
+ * @category events
1606
+ * @since 0.1.0
1607
+ * @slop
1608
+ */
1609
+ export class PermissionRequired extends Schema.TaggedClass<PermissionRequired>(
1610
+ "flows/harness/AgentEvent/PermissionRequired"
1611
+ )("permission-required", {
1612
+ eventType: Schema.Literal("flows.harness.permission-required.v1"),
1613
+ request: Permission.PermissionRequired
1614
+ }) {}
1615
+
1616
+ /**
1617
+ * A normalized harness abort.
1618
+ *
1619
+ * @category events
1620
+ * @since 0.1.0
1621
+ * @slop
1622
+ */
1623
+ export class Aborted extends Schema.TaggedClass<Aborted>(
1624
+ "flows/harness/AgentEvent/Aborted"
1625
+ )("aborted", {
1626
+ eventType: Schema.Literal("flows.harness.aborted.v1"),
1627
+ reason: Schema.String
1628
+ }) {}
1629
+
1630
+ /**
1631
+ * The final assistant message produced by the harness.
1632
+ *
1633
+ * @category events
1634
+ * @since 0.1.0
1635
+ * @slop
1636
+ */
1637
+ export class Resolved extends Schema.TaggedClass<Resolved>(
1638
+ "flows/harness/AgentEvent/Resolved"
1639
+ )("resolved", {
1640
+ eventType: Schema.Literal("flows.harness.resolved.v1"),
1641
+ message: ModelRequest.AssistantMessage
1642
+ }) {}
1643
+
1644
+ /**
1645
+ * All normalized events emitted by a harness adapter.
1646
+ *
1647
+ * @category events
1648
+ * @since 0.1.0
1649
+ * @slop
1650
+ */
1651
+ export const AgentEvent = Schema.Union([
1652
+ DisciplineArmed,
1653
+ TurnOpened,
1654
+ ModelDelta,
1655
+ ModelRequested,
1656
+ ModelSelected,
1657
+ SeatFailedOver,
1658
+ ModelParked,
1659
+ ModelUnparked,
1660
+ ModelRetried,
1661
+ ModelSettled,
1662
+ CellProduced,
1663
+ CellRejectedInFrame,
1664
+ CellCallStarted,
1665
+ CellCallSettled,
1666
+ CellPrinted,
1667
+ CellSettled,
1668
+ TransitionApplied,
1669
+ MutationObserved,
1670
+ CheckpointMinted,
1671
+ ReadOnlyDemandIssued,
1672
+ ReadOnlyDemanded,
1673
+ RepeatDemanded,
1674
+ NarrowedDemanded,
1675
+ NarrowOnlyDemanded,
1676
+ UnmovedDemanded,
1677
+ UnresolvedDemanded,
1678
+ FailedCallDemanded,
1679
+ UnobservedDemanded,
1680
+ OutputDemanded,
1681
+ ClaimDemanded,
1682
+ DecisionSettled,
1683
+ SupervisorSettled,
1684
+ SupervisorUnjudged,
1685
+ SupervisorMemoryFailed,
1686
+ DecisionUnjudged,
1687
+ RelevanceSettled,
1688
+ RelevanceRestored,
1689
+ SeatRouted,
1690
+ SufficiencyObserved,
1691
+ VacuousVerificationObserved,
1692
+ Suspended,
1693
+ CompactionSettled,
1694
+ SteeringDrained,
1695
+ TurnClosed,
1696
+ PermissionRequired,
1697
+ Aborted,
1698
+ Resolved
1699
+ ]).pipe(Schema.toTaggedUnion("_tag"))
1700
+
1701
+ /**
1702
+ * All normalized events emitted by a harness adapter.
1703
+ *
1704
+ * @category events
1705
+ * @since 0.1.0
1706
+ * @slop
1707
+ */
1708
+ export type AgentEvent = typeof AgentEvent.Type
1709
+
1710
+ /**
1711
+ * The journal event type of every member of {@link AgentEvent}, by tag.
1712
+ *
1713
+ * One table, because the literal used to be written three times: on the class,
1714
+ * in `CellTurn`'s emitter, and again in `Transcript`'s decoder. A projection
1715
+ * that reads a literal the emitter no longer writes silently returns an empty
1716
+ * transcript, and nothing failed when the two drifted. `CellTurn` and
1717
+ * `Transcript` both read this, and `Contracts.test.ts` pins it against the
1718
+ * union, so an event added without a row here fails a test rather than a run.
1719
+ *
1720
+ * @category events
1721
+ * @since 0.1.0
1722
+ * @slop
1723
+ */
1724
+ export const eventType = {
1725
+ aborted: "flows.harness.aborted.v1",
1726
+ cellCallSettled: "flows.harness.cell-call-settled.v1",
1727
+ cellCallStarted: "flows.harness.cell-call-started.v1",
1728
+ cellPrinted: "flows.harness.cell-printed.v1",
1729
+ cellProduced: "flows.harness.cell-produced.v1",
1730
+ cellRejectedInFrame: "flows.harness.cell-rejected-in-frame.v1",
1731
+ cellSettled: "flows.harness.cell-settled.v1",
1732
+ checkpointMinted: "flows.harness.checkpoint-minted.v1",
1733
+ claimDemanded: "flows.harness.claim-demanded.v1",
1734
+ compactionSettled: "flows.harness.compaction-settled.v1",
1735
+ decisionSettled: "flows.harness.decision-settled.v1",
1736
+ decisionUnjudged: "flows.harness.decision-unjudged.v1",
1737
+ disciplineArmed: "flows.harness.discipline-armed.v1",
1738
+ modelDelta: "flows.harness.model-delta.v1",
1739
+ modelRequested: "flows.harness.model-requested.v1",
1740
+ modelSelected: "flows.harness.model-selected.v1",
1741
+ seatFailedOver: "flows.harness.seat-failed-over.v1",
1742
+ modelParked: "flows.harness.model-parked.v1",
1743
+ modelUnparked: "flows.harness.model-unparked.v1",
1744
+ modelRetried: "flows.harness.model-retried.v1",
1745
+ modelSettled: "flows.harness.model-settled.v1",
1746
+ mutationObserved: "flows.harness.mutation-observed.v1",
1747
+ narrowOnlyDemanded: "flows.harness.narrow-only-demanded.v1",
1748
+ narrowedDemanded: "flows.harness.narrowed-demanded.v1",
1749
+ permissionRequired: "flows.harness.permission-required.v1",
1750
+ readOnlyDemandIssued: "flows.harness.read-only-demand-issued.v1",
1751
+ readOnlyDemanded: "flows.harness.read-only-demanded.v1",
1752
+ relevanceRestored: "flows.harness.relevance-restored.v1",
1753
+ relevanceSettled: "flows.harness.relevance-settled.v1",
1754
+ repeatDemanded: "flows.harness.repeat-demanded.v1",
1755
+ resolved: "flows.harness.resolved.v1",
1756
+ seatRouted: "flows.harness.seat-routed.v1",
1757
+ steeringDrained: "flows.harness.steering-drained.v1",
1758
+ sufficiencyObserved: "flows.harness.sufficiency-observed.v1",
1759
+ supervisorSettled: "flows.harness.supervisor-settled.v1",
1760
+ supervisorUnjudged: "flows.harness.supervisor-unjudged.v1",
1761
+ supervisorMemoryFailed: "flows.harness.supervisor-memory-failed.v1",
1762
+ suspended: "flows.harness.suspended.v1",
1763
+ transitionApplied: "flows.harness.transition-applied.v1",
1764
+ turnClosed: "flows.harness.turn-closed.v1",
1765
+ turnOpened: "flows.harness.turn-opened.v1",
1766
+ unmovedDemanded: "flows.harness.unmoved-demanded.v1",
1767
+ unresolvedDemanded: "flows.harness.unresolved-demanded.v1",
1768
+ failedCallDemanded: "flows.harness.failed-call-demanded.v1",
1769
+ unobservedDemanded: "flows.harness.unobserved-demanded.v1",
1770
+ outputDemanded: "flows.harness.output-demanded.v1",
1771
+ vacuousVerificationObserved: "flows.harness.vacuous-verification-observed.v1"
1772
+ } as const