@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,772 @@
1
+ /**
2
+ * The cell contract.
3
+ *
4
+ * A Smithers frame is `model -> generated cell -> realm evaluation ->
5
+ * individually durable flow calls -> next transition`. This module owns the
6
+ * serializable half of that sentence: the cell source the model emits, the
7
+ * transition the cell settled, the typed outcomes a cell may settle with, and
8
+ * the identity carried by every flow call made inside one.
9
+ *
10
+ * Nothing here executes anything. Execution is `Sandbox`; durability is
11
+ * `EngineLike.call`; the loop is `CellTurn`.
12
+ *
13
+ * A cell does not *return* its transition. The realm is a REPL that outlives
14
+ * the cell, so a cell states its intent by calling `ctx.done` or `ctx.park` and
15
+ * `Sandbox.replTransition` builds the value; there is no returned object to
16
+ * decode.
17
+ *
18
+ * Governing design: `../docs/concepts.md#durable-cell-loop`,
19
+ * `../docs/concepts.md#repl-realm` and
20
+ * `../docs/concepts.md#agent-cell-context`.
21
+ *
22
+ * @since 0.1.0
23
+ */
24
+ import * as Digest from "@smthrs/core/Digest";
25
+ import * as CanonicalJson from "@smthrs/model/CanonicalJson";
26
+ import * as Descriptor from "@smthrs/registry/Descriptor";
27
+ import { Cause, Effect, Option, Result, Schema } from "effect";
28
+ import { HarnessError } from "./HarnessError.js";
29
+ import { NonNegativeSafeInt } from "./internal/nonNegativeSafeInt.js";
30
+ /**
31
+ * The source language a cell is written in.
32
+ *
33
+ * Both shipped bindings run a `typescript` cell by erasing its type-only
34
+ * syntax — never by emitting new runtime behaviour, so a construct that needs
35
+ * JavaScript emit is a `compile_failed` rejection rather than a silent
36
+ * transform. A binding that cannot compile at all rejects with
37
+ * `unsupported_language`; neither shipped binding needs to.
38
+ *
39
+ * @category models
40
+ * @since 0.1.0
41
+ * @slop
42
+ */
43
+ export const Language = Schema.Literals(["javascript", "typescript"]);
44
+ /**
45
+ * One unit of agent-authored source and its stable content digest.
46
+ *
47
+ * The digest is part of every call identity produced inside the cell, so
48
+ * editing one character of the source re-keys every boundary within it.
49
+ *
50
+ * @category models
51
+ * @since 0.1.0
52
+ * @slop
53
+ */
54
+ export class Source extends Schema.Class("flows/harness/Cell/Source")({
55
+ language: Language,
56
+ text: Schema.String,
57
+ digest: Schema.String
58
+ }) {
59
+ }
60
+ /**
61
+ * Computes the stable digest of cell source.
62
+ *
63
+ * @category constructors
64
+ * @since 0.1.0
65
+ * @slop
66
+ */
67
+ export const digestOf = (language, text) => Digest.digest(CanonicalJson.stringify({ kind: "flows/harness/Cell/Source", language, text }));
68
+ /**
69
+ * Constructs cell source with its computed digest.
70
+ *
71
+ * @category constructors
72
+ * @since 0.1.0
73
+ * @slop
74
+ */
75
+ export const source = (text, language = "javascript") => new Source({ language, text, digest: digestOf(language, text) });
76
+ /**
77
+ * The cell's turn ended without settling the run.
78
+ *
79
+ * A REPL cell that calls neither `ctx.done` nor `ctx.park` gets another frame,
80
+ * and this is what that frame is journaled as. The only thing it carries is a
81
+ * justification; all other bookkeeping belongs to the realm.
82
+ *
83
+ * @category models
84
+ * @since 0.1.0
85
+ * @slop
86
+ */
87
+ export class Continue extends Schema.TaggedClass("flows/harness/Cell/Continue")("continue", {
88
+ /**
89
+ * Why this frame changed nothing, when the controller demanded that it
90
+ * either mutate or say why not.
91
+ *
92
+ * The field exists because prose in the prompt did not stop a run from
93
+ * reading for its whole budget: a benchmark instance spent 100 frames and
94
+ * 132 calls without one edit attempt and then claimed the fix was
95
+ * implemented. A justification is the typed way out of the read-only cap —
96
+ * it is recorded, it buys a bounded grace, and it does not reset the
97
+ * counter that eventually stops the run. A cell writes one by calling
98
+ * `ctx.justify`.
99
+ */
100
+ justification: Schema.optional(Schema.String)
101
+ }) {
102
+ }
103
+ /**
104
+ * The cell declares the task finished and supplies its final output.
105
+ *
106
+ * A completion carries no self-reported proof. The run's evidence is the calls
107
+ * it actually made — every one journaled as `cell-call-settled` with its real
108
+ * input and result — and a field in which the model restates which of them
109
+ * proved the work would be a claim about a check rather than the check.
110
+ *
111
+ * @category models
112
+ * @since 0.1.0
113
+ * @slop
114
+ */
115
+ export class Complete extends Schema.TaggedClass("flows/harness/Cell/Complete")("complete", {
116
+ output: Schema.String,
117
+ value: Schema.optional(Schema.Json)
118
+ }) {
119
+ }
120
+ /**
121
+ * The cell asks the controller to park the run durably.
122
+ *
123
+ * @category models
124
+ * @since 0.1.0
125
+ * @slop
126
+ */
127
+ export class Park extends Schema.TaggedClass("flows/harness/Cell/Park")("park", {
128
+ reason: Schema.Literals(["waiting-input", "waiting-event", "waiting-quota"]),
129
+ message: Schema.String
130
+ }) {
131
+ }
132
+ /**
133
+ * The serializable decision one cell returns.
134
+ *
135
+ * @category models
136
+ * @since 0.1.0
137
+ * @slop
138
+ */
139
+ export const Transition = Schema.Union([Continue, Complete, Park]).pipe(Schema.toTaggedUnion("_tag"));
140
+ /**
141
+ * Renders a projected value as the text one context entry carries.
142
+ *
143
+ * A string is itself. Everything else is canonical JSON, which is the whole of
144
+ * the "render structs as JSON, always" rule: a structured value reaches the
145
+ * next model turn as the value it is.
146
+ *
147
+ * @category conversions
148
+ * @since 0.1.0
149
+ * @slop
150
+ */
151
+ export const renderText = (value) => typeof value === "string" ? value : CanonicalJson.stringify(value);
152
+ /**
153
+ * Stable reasons a cell failed to produce a transition.
154
+ *
155
+ * Every one of these is a durable observation the model may correct on a later
156
+ * frame; none of them is a harness crash.
157
+ *
158
+ * `imports_forbidden` names module syntax the cell itself uses, which
159
+ * `Sandbox.compile` finds by parsing. A quoted mention of an import is data:
160
+ * cells routinely carry a `bash` command whose heredoc imports a Python module,
161
+ * and those cells run.
162
+ *
163
+ * @category models
164
+ * @since 0.1.0
165
+ * @slop
166
+ */
167
+ export const RejectionCode = Schema.Literals([
168
+ "no_cell",
169
+ "output_truncated",
170
+ "imports_forbidden",
171
+ "compile_failed",
172
+ "invalid_transition",
173
+ "unsupported_language",
174
+ "limit_exceeded",
175
+ "stalled"
176
+ ]);
177
+ /**
178
+ * The cell ran and returned a well-formed transition.
179
+ *
180
+ * @category models
181
+ * @since 0.1.0
182
+ * @slop
183
+ */
184
+ export class Settled extends Schema.TaggedClass("flows/harness/Cell/Settled")("settled", {
185
+ transition: Transition
186
+ }) {
187
+ }
188
+ /**
189
+ * The cell ran and threw. The thrown value is projected into stable text so it
190
+ * survives the journal and the next frame's context.
191
+ *
192
+ * @category models
193
+ * @since 0.1.0
194
+ * @slop
195
+ */
196
+ export class Raised extends Schema.TaggedClass("flows/harness/Cell/Raised")("raised", {
197
+ name: Schema.String,
198
+ message: Schema.String
199
+ }) {
200
+ }
201
+ /**
202
+ * The cell never ran, or ran and returned something that is not a transition.
203
+ *
204
+ * @category models
205
+ * @since 0.1.0
206
+ * @slop
207
+ */
208
+ export class Rejected extends Schema.TaggedClass("flows/harness/Cell/Rejected")("rejected", {
209
+ code: RejectionCode,
210
+ message: Schema.String,
211
+ /** The spent resource when `code` is `limit_exceeded`. */
212
+ reason: Schema.optional(Schema.Literals(["heap"]))
213
+ }) {
214
+ }
215
+ /**
216
+ * Everything one cell evaluation may settle with.
217
+ *
218
+ * @category models
219
+ * @since 0.1.0
220
+ * @slop
221
+ */
222
+ export const Outcome = Schema.Union([Settled, Raised, Rejected]).pipe(Schema.toTaggedUnion("_tag"));
223
+ /**
224
+ * The read-only projection of one callable flow handed to a cell.
225
+ *
226
+ * This is exactly what `ctx.flows` exposes: enough for the model to choose a
227
+ * call and for the cell to reason about it, and nothing that carries authority.
228
+ *
229
+ * @category models
230
+ * @since 0.1.0
231
+ * @slop
232
+ */
233
+ export class FlowProjection extends Schema.Class("flows/harness/Cell/FlowProjection")({
234
+ name: Schema.String,
235
+ description: Schema.String,
236
+ capabilities: Schema.Array(Schema.String),
237
+ tier: Descriptor.EffectTier,
238
+ placement: Schema.Option(Descriptor.Placement),
239
+ /**
240
+ * The call's input schema, as a JSON Schema document, when the descriptor
241
+ * carries one by value.
242
+ *
243
+ * Without it a cell can only guess an input shape from prose, and every
244
+ * guess costs a whole frame: a rejected call is one model turn, so learning
245
+ * `bash` takes `{ command, mode, reads, writes }` cost four turns of pure
246
+ * trial and error before any work began.
247
+ */
248
+ input: Schema.Option(Schema.Json).pipe(Schema.withConstructorDefault(Effect.succeed(Option.none())), Schema.withDecodingDefaultKey(Effect.succeed(Option.none())))
249
+ }) {
250
+ }
251
+ /**
252
+ * Projects a discovered descriptor into the cell-visible catalog entry.
253
+ *
254
+ * @category conversions
255
+ * @since 0.1.0
256
+ * @slop
257
+ */
258
+ export const project = (descriptor) => new FlowProjection({
259
+ name: descriptor.name,
260
+ description: descriptor.description,
261
+ capabilities: descriptor.capabilities,
262
+ tier: descriptor.effects.tier,
263
+ placement: descriptor.placement,
264
+ input: descriptor.input._tag === "Inline" ? Option.some(descriptor.input.document) : Option.none()
265
+ });
266
+ /**
267
+ * Why one flow call failed, as a closed set a cell may branch on.
268
+ *
269
+ * Every member is a refusal or a budget the harness itself owns, plus one for
270
+ * everything a flow reports about its own work. Add a member; never repurpose
271
+ * one — a cell reads these, and so does a grader counting failure classes in a
272
+ * journal.
273
+ *
274
+ * @category models
275
+ * @since 0.1.0
276
+ * @slop
277
+ */
278
+ export const CallFailureCode = Schema.Literals([
279
+ "unknown_flow",
280
+ "capability_refused",
281
+ "truncated_write",
282
+ "declaration_changed",
283
+ "invalid_input",
284
+ "unimplemented",
285
+ "timeout",
286
+ "run_completed",
287
+ "checkpoint_unavailable",
288
+ "checkpoint_exhausted",
289
+ "checkpoint_readonly",
290
+ "checkpoint_unsupported",
291
+ "flow_failed",
292
+ "flow_withheld"
293
+ ]);
294
+ /**
295
+ * The code a failure carries when nothing classified it.
296
+ *
297
+ * @category constants
298
+ * @since 0.1.0
299
+ * @slop
300
+ */
301
+ export const defaultCallFailureCode = "flow_failed";
302
+ /**
303
+ * The one action that recovers each failure class, stated to the cell.
304
+ *
305
+ * A code says what happened; the hint says what to do next, in the same frame.
306
+ * They are here rather than at each raising site so the same class always reads
307
+ * the same way whichever boundary refused.
308
+ *
309
+ * @category constants
310
+ * @since 0.1.0
311
+ * @slop
312
+ */
313
+ export const callFailureHint = Object.freeze({
314
+ unknown_flow: "Read ctx.flows and call one of the names it lists.",
315
+ capability_refused: "This run cannot reach that flow. Do the work with a flow ctx.flows lists.",
316
+ truncated_write: "The bytes you passed were a fragment. Restore from source control instead of writing captured output.",
317
+ declaration_changed: "Read ctx.flows again and reissue the call with the shape it now declares.",
318
+ invalid_input: "Fix the input against the flow's declared schema in ctx.flows and call it again in this cell.",
319
+ unimplemented: "This host cannot run that flow. Choose another one from ctx.flows.",
320
+ timeout: "Narrow the call — a smaller root, a tighter pattern, a shorter command — and issue it again in this cell.",
321
+ checkpoint_unavailable: "This host pins no checkpoint you can run against. Drop at; for a baseline, run the check before your edit, then again after it.",
322
+ checkpoint_exhausted: "Reuse a checkpoint you already hold, or ctx.base, instead of minting another one.",
323
+ checkpoint_readonly: "A checkpoint is a read-only view of a tree that has already been. Drop at and make the change on the live tree.",
324
+ checkpoint_unsupported: "This flow names what it touches rather than where it runs, so it cannot be pointed at a checkpoint. Drop at, or run the same work through a shell flow, which takes a working directory.",
325
+ run_completed: "The run is over, so nothing after this line runs. If that was early, guard the ctx.done or ctx.park on the check that decides it.",
326
+ flow_failed: "Read error.message: the flow itself says what went wrong, and it is usually fixable in this same cell.",
327
+ flow_withheld: "End this cell and reissue the call in the next one; ctx.flows lists the flow there."
328
+ });
329
+ /**
330
+ * Which version of the live tree a sealed call reads; see `Call.epoch`.
331
+ *
332
+ * @category models
333
+ * @since 1.0.0-rc.1
334
+ */
335
+ export const TreeEpoch = Schema.Struct({
336
+ /** Earlier frames of this run that changed the workspace. */
337
+ frames: NonNegativeSafeInt,
338
+ /** Calls of this frame that may write, issued before this one. */
339
+ calls: NonNegativeSafeInt,
340
+ /** Digest of those calls, chained in issue order: which writes, not only how many. */
341
+ writes: Schema.optional(Schema.String),
342
+ /** Digest of the whole-tree measurement the frame opened on. */
343
+ tree: Schema.optional(Schema.String),
344
+ /** The run, when no whole-tree measurement exists: the reading is reused only inside it. */
345
+ session: Schema.optional(Schema.String),
346
+ /** The frame, beside `session`: an unmeasured tree may change during a model wait. */
347
+ frame: Schema.optional(NonNegativeSafeInt)
348
+ });
349
+ /**
350
+ * The complete identity of one flow call made inside one cell.
351
+ *
352
+ * Identity is what makes a mid-cell crash replayable. Re-executing the cell
353
+ * source reaches the same lexical call in the same order with the same
354
+ * declaration, so the boundary keys identically and replays; anything that
355
+ * differs — a new frame, an edited cell, a different resolved layer set — keys
356
+ * differently and executes.
357
+ *
358
+ * @category models
359
+ * @since 0.1.0
360
+ * @slop
361
+ */
362
+ export class CallIdentity extends Schema.Class("flows/harness/Cell/CallIdentity")({
363
+ /** The durable session/lineage the frame belongs to. */
364
+ session: Schema.String,
365
+ /** The controller frame that produced the cell. */
366
+ frame: NonNegativeSafeInt,
367
+ /** The digest of the cell source being executed. */
368
+ cell: Schema.String,
369
+ /** The zero-based execution ordinal of this call within the cell. */
370
+ ordinal: NonNegativeSafeInt,
371
+ /** The digest of the resolved flow declaration being invoked. */
372
+ declaration: Schema.String,
373
+ /** The resolved layer set in effect at the boundary. */
374
+ layers: Schema.Array(Schema.String)
375
+ }) {
376
+ }
377
+ /**
378
+ * Computes the declaration digest folded into a call identity.
379
+ *
380
+ * Re-exported from `@smthrs/registry`, which owns `FlowDescriptor` and
381
+ * therefore owns what one declaration hashes to. It is the same number
382
+ * `@smthrs/chain` keys its catalog entries with, so a declaration has one
383
+ * identity across the boundary rather than one per package.
384
+ *
385
+ * @category constructors
386
+ * @since 0.1.0
387
+ * @slop
388
+ */
389
+ export const declarationDigest = Descriptor.declarationDigest;
390
+ /**
391
+ * One flow call requested from inside a cell.
392
+ *
393
+ * @category models
394
+ * @since 0.1.0
395
+ * @slop
396
+ */
397
+ export class Call extends Schema.Class("flows/harness/Cell/Call")({
398
+ flowName: Schema.String,
399
+ input: Schema.Json,
400
+ capabilities: Schema.Array(Schema.String),
401
+ effects: Descriptor.EffectDeclaration,
402
+ placement: Schema.Option(Descriptor.Placement),
403
+ identity: CallIdentity,
404
+ /**
405
+ * The checkpoint this call runs against, when the cell named one.
406
+ *
407
+ * Absent is the ordinary case and means the live workspace. Present names a
408
+ * tree the run already pinned, and the host materializes that tree somewhere
409
+ * of its own choosing and runs the call there. It is journaled on the call
410
+ * because it is the difference between a reading of the tree as it is and a
411
+ * reading of the tree as it was, and a grader that cannot tell those apart
412
+ * cannot grade a fails-before proof at all.
413
+ */
414
+ at: Schema.optional(Schema.String),
415
+ /**
416
+ * Which version of the live tree a sealed reading is taken against.
417
+ *
418
+ * A sealed call is content-addressed on what it asked, and "the same path
419
+ * against the tree as it stands" is the same question only until something
420
+ * has written to the tree. Without this, the second of two identical reads
421
+ * around a write replays the first's answer and a run reports the pre-edit
422
+ * text after its own edit. `frames` is the run's frame clock — the count of
423
+ * earlier frames that changed the workspace, measured where the host can
424
+ * measure — and `calls` is how many calls of this frame that may write
425
+ * were issued before this one, with `writes` chaining what they asked, so
426
+ * two runs that wrote differently read different questions. All are derived
427
+ * from the journaled call
428
+ * sequence, so a replayed frame derives the same epoch and replays.
429
+ *
430
+ * The counters restart with every run, so they cannot tell a later run's
431
+ * read from an earlier run's across an edit made between them. `tree` is
432
+ * the digest of a journaled measurement taken after the model wait, which
433
+ * can; without a whole measurement, `session` and `frame` keep the reading
434
+ * to the frame that took it.
435
+ *
436
+ * Absent on every call that is not a sealed reading of the live tree: a
437
+ * checkpoint is immutable, and a non-sealed call already keys on its ordinal.
438
+ */
439
+ epoch: Schema.optional(TreeEpoch),
440
+ /**
441
+ * What the resolved declaration says a call to this flow does.
442
+ *
443
+ * Carried on the call rather than looked up later, because the reader of a
444
+ * run is not the host that resolved it: a card reading a journal months
445
+ * afterwards holds the record and nothing else, and a flow name is not a
446
+ * meaning. Absent is unknown, and unknown stays unknown.
447
+ */
448
+ activity: Schema.optional(Descriptor.FlowActivity),
449
+ /**
450
+ * How the resolved declaration says one recorded call to this flow reads.
451
+ *
452
+ * Display authority only. Neither this field nor `activity` enters a key:
453
+ * {@link callMaterial} and the durable call key name the fields they hash,
454
+ * and both digests in `@smthrs/registry` exclude these two, so enriching a
455
+ * declaration with them can neither replay nor re-approve anything.
456
+ */
457
+ presentation: Schema.optional(Descriptor.CallPresentation)
458
+ }) {
459
+ }
460
+ /**
461
+ * Builds the call one resolved declaration and one cell invocation make.
462
+ *
463
+ * A constructor rather than an object literal at the boundary: what a call
464
+ * carries about its declaration is a contract two producers project into a
465
+ * journal (`AgentSession.trace` and the native `CallFact`), and a reader can
466
+ * only be as complete as this. A field copied from a descriptor onto a call
467
+ * belongs here, where the copy is stated once.
468
+ *
469
+ * @category constructors
470
+ * @since 1.0.0-rc.0
471
+ */
472
+ export const callOf = (descriptor, options) => new Call({
473
+ flowName: descriptor.name,
474
+ input: options.input,
475
+ capabilities: descriptor.capabilities,
476
+ effects: descriptor.effects,
477
+ placement: descriptor.placement,
478
+ identity: options.identity,
479
+ ...(options.at === undefined ? {} : { at: options.at }),
480
+ ...(options.epoch === undefined ? {} : { epoch: options.epoch }),
481
+ ...(descriptor.activity === undefined ? {} : { activity: descriptor.activity }),
482
+ ...(descriptor.presentation === undefined ? {} : { presentation: descriptor.presentation })
483
+ });
484
+ /**
485
+ * The display projection one recorded call carries for whoever reads it back.
486
+ *
487
+ * `undefined` when the declaration claimed neither field, so the record stays
488
+ * byte-identical to the one an undeclared flow produces and a reader's
489
+ * compatibility table still applies to it. The name travels with the fields so
490
+ * a reader can refuse metadata that belongs to a different flow.
491
+ *
492
+ * @category projections
493
+ * @since 1.0.0-rc.0
494
+ */
495
+ export const displayDescriptor = (call) => call.activity === undefined && call.presentation === undefined ? undefined : {
496
+ name: call.flowName,
497
+ ...(call.activity === undefined ? {} : { activity: call.activity }),
498
+ ...(call.presentation === undefined ? {} : {
499
+ presentation: {
500
+ verb: { ...call.presentation.verb },
501
+ subject: call.presentation.subject,
502
+ result: call.presentation.result
503
+ }
504
+ })
505
+ };
506
+ /**
507
+ * The id naming the tree a run opened on, pinned for free and always present.
508
+ *
509
+ * The dominant use of a checkpoint is a fails-before proof, and the frame that
510
+ * wants one is almost never the frame that could have foreseen it: by the time
511
+ * a run knows which command reproduces the bug it has usually already edited.
512
+ * So this id exists without anybody minting it. A host resolves it to whatever
513
+ * it recorded as the run's opening tree — for the SWE-bench rig, the
514
+ * `refs/flows/capture-base` commit its own setup wrote — and a host with no
515
+ * such record answers `checkpoint_unavailable` like any other.
516
+ *
517
+ * @category constants
518
+ * @since 0.1.0
519
+ */
520
+ export const baseCheckpoint = "base";
521
+ /**
522
+ * The wire shape of the value `ctx.checkpoint()` resolves with.
523
+ *
524
+ * A handle is an opaque record rather than a bare string so a cell cannot pass
525
+ * an arbitrary string as `at` by accident, and so a future host can carry more
526
+ * beside the id without changing what a cell writes.
527
+ */
528
+ const Handle = Schema.Struct({ checkpoint: Schema.NonEmptyString });
529
+ /**
530
+ * Builds the handle a cell holds for one checkpoint.
531
+ *
532
+ * @category constructors
533
+ * @since 0.1.0
534
+ */
535
+ export const checkpoint = (id) => ({ checkpoint: id });
536
+ /**
537
+ * Reads the checkpoint id out of whatever a cell passed as `at`.
538
+ *
539
+ * `undefined` means "that was not a checkpoint", which the boundary answers as
540
+ * an ordinary `invalid_input` failure rather than by guessing. It is
541
+ * deliberately strict: a handle is the only thing that names a tree, and a
542
+ * string that happens to look like an id would let a cell address a snapshot
543
+ * the run never took.
544
+ *
545
+ * @category conversions
546
+ * @since 0.1.0
547
+ */
548
+ export const checkpointOf = (value) => {
549
+ const decoded = Schema.decodeUnknownResult(Handle)(value);
550
+ return decoded._tag === "Success" ? decoded.success.checkpoint : undefined;
551
+ };
552
+ /**
553
+ * The settled outcome of one flow call.
554
+ *
555
+ * A `failure` resolves in the cell as a `{ ok: false, error }` envelope that
556
+ * it may inspect and recover from; it does not throw and is never a harness
557
+ * failure. Anything the cell cannot see, such as a permission park or an abort,
558
+ * travels in the effect's error channel instead.
559
+ *
560
+ * @category models
561
+ * @since 0.1.0
562
+ * @slop
563
+ */
564
+ export class CallResult extends Schema.Class("flows/harness/Cell/CallResult")(Schema.Struct({
565
+ outcome: Schema.Literals(["success", "failure"]),
566
+ value: Schema.Json,
567
+ message: Schema.optional(Schema.String),
568
+ /**
569
+ * Why a failed call failed, from the closed set the cell may branch on.
570
+ *
571
+ * Prose is what a boundary says; a code is what a program reads. Without one
572
+ * the only way for a cell to tell "that flow does not exist" from "that
573
+ * command timed out" was to match the message, so cells did not tell them
574
+ * apart at all. Absent means {@link defaultCallFailureCode}, which is what a
575
+ * flow's own failure gets: the flow said why in `message` and the harness
576
+ * does not classify it.
577
+ */
578
+ code: Schema.optional(CallFailureCode)
579
+ })) {
580
+ constructor(props, options) {
581
+ // The encoded schema is the durable wire contract used in sealed keys.
582
+ // Refining its AST would re-key valid recorded results. Admission checks
583
+ // belong here and in decodeCallResult, which also revalidates instances.
584
+ super(CallResultVariant.make(props), options);
585
+ }
586
+ }
587
+ /**
588
+ * A successful call cannot carry a failure code. The wire field names remain
589
+ * the same as current CallResult records.
590
+ *
591
+ * @category schemas
592
+ * @since 1.0.0-rc.0
593
+ */
594
+ export const CallSuccess = Schema.Struct({
595
+ outcome: Schema.Literal("success"),
596
+ value: Schema.Json,
597
+ message: Schema.optional(Schema.String),
598
+ code: Schema.optionalKey(Schema.Never)
599
+ });
600
+ /**
601
+ * A failed call, with the existing absent-code meaning of flow_failed.
602
+ *
603
+ * @category schemas
604
+ * @since 1.0.0-rc.0
605
+ */
606
+ export const CallFailure = Schema.Struct({
607
+ outcome: Schema.Literal("failure"),
608
+ value: Schema.Json,
609
+ message: Schema.optional(Schema.String),
610
+ code: Schema.optional(CallFailureCode)
611
+ });
612
+ /**
613
+ * Discriminated result at a decoded persistence or host boundary.
614
+ *
615
+ * @category schemas
616
+ * @since 1.0.0-rc.0
617
+ */
618
+ export const CallResultVariant = Schema.Union([CallSuccess, CallFailure]);
619
+ const decodeBoundary = (schema, name) => (value) => Effect.suspend(() => Effect.gen(function* () {
620
+ const encoded = yield* Schema.decodeUnknownEffect(Schema.toEncoded(schema), { onExcessProperty: "error" })(value);
621
+ return yield* Schema.decodeUnknownEffect(schema, { onExcessProperty: "error" })(encoded);
622
+ })).pipe(Effect.catchCause((cause) => Effect.fail(new HarnessError({
623
+ code: "engine_failed",
624
+ message: `Invalid recorded cell ${name}`,
625
+ cause: Cause.squash(cause)
626
+ }))));
627
+ /**
628
+ * Decode a host or persisted result before the cell can observe it.
629
+ *
630
+ * @category decoders
631
+ * @since 1.0.0-rc.0
632
+ */
633
+ export const decodeCallResult = decodeBoundary(CallResultVariant, "call result");
634
+ /**
635
+ * Refuse contradictory or incomplete recorded evaluation outcomes.
636
+ *
637
+ * @category decoders
638
+ * @since 1.0.0-rc.0
639
+ */
640
+ export const decodeOutcome = decodeBoundary(Outcome, "outcome");
641
+ /**
642
+ * Refuse contradictory or incomplete recorded transitions.
643
+ *
644
+ * @category decoders
645
+ * @since 1.0.0-rc.0
646
+ */
647
+ export const decodeTransition = decodeBoundary(Transition, "transition");
648
+ /**
649
+ * The failure envelope a cell observes when a flow call does not succeed.
650
+ *
651
+ * A failed call **resolves** with this value; it does not throw. That is the
652
+ * whole of change 8: an unrecoverable rejection turned every failed call into a
653
+ * lost frame, because the recovery branch the model had already written sat
654
+ * behind the throw and never ran, and every sibling call the cell had already
655
+ * paid for went with it. `psf__requests-2317` lost two settled greps and a
656
+ * probe to one call against a directory that did not exist; `django-14351`
657
+ * spent ~$0.46 on the same class across five frames.
658
+ *
659
+ * The shape is fixed and small — `{ ok: false, error: { code, message, hint } }`
660
+ * — because a cell branches on `.ok` and reads `.error.code`. A successful call
661
+ * still resolves with the flow's own value, unwrapped, so the ordinary
662
+ * `result.stdout` shape a cell is trained on is unchanged.
663
+ *
664
+ * @category conversions
665
+ * @since 0.1.0
666
+ * @slop
667
+ */
668
+ export const callFailure = (result) => {
669
+ const code = result.code ?? defaultCallFailureCode;
670
+ return {
671
+ ok: false,
672
+ error: {
673
+ code,
674
+ message: result.message ?? "The flow call failed",
675
+ hint: callFailureHint[code]
676
+ }
677
+ };
678
+ };
679
+ const fenced = /^```(?<info>[^\n`]*)\r?\n(?<body>[\s\S]*?)(?:\n?(?<close>^```[ \t]*(?=\r?$))|(?![\s\S]))/gm;
680
+ const languageOf = (info) => {
681
+ const tokens = new Set(info.trim().toLowerCase().split(/\s+/).filter((token) => token.length > 0));
682
+ if (tokens.has("ts") || tokens.has("typescript"))
683
+ return "typescript";
684
+ if (tokens.has("cell") || tokens.has("js") || tokens.has("javascript"))
685
+ return "javascript";
686
+ return undefined;
687
+ };
688
+ /**
689
+ * Extracts the cell program one model settlement emitted.
690
+ *
691
+ * Every fenced block tagged as a cell is kept, in reply order, and the blocks
692
+ * are joined with newlines into one global async script in the persistent
693
+ * realm. Top-level `await` is supported; top-level `return` is invalid. Blocks
694
+ * execute in order. The first `ctx.done` or `ctx.park` that records an intent
695
+ * seals the frame; later `ctx.done` and `ctx.park` calls do nothing. Ordinary
696
+ * JavaScript in later blocks continues running, but later `ctx.call` and
697
+ * `ctx.checkpoint` calls resolve with a `run_completed` failure envelope
698
+ * without dispatching host work.
699
+ *
700
+ * Keeping only the *last* block is what this replaces, and the cost of that
701
+ * rule was measured: on one graded instance the model wrote a near-par program
702
+ * as seven blocks in a single reply — recon, probe, edit-plus-diagnostics,
703
+ * suite, rehydrate, guarded replay, completion — and the harness executed block
704
+ * seven, the imagined completion, against a tree where blocks one through six
705
+ * had never run. Empty patch, run over in two frames. Multi-block replies were
706
+ * 2 of 91 replies in that wave: rare, and instance-deciding when they land.
707
+ *
708
+ * A byte-identical repeat of a block is dropped rather than concatenated. Both
709
+ * multi-block replies in that wave are in the journals, and the second one is a
710
+ * model that emitted the same block twice: joining the duplicate would declare
711
+ * its names twice and turn a frame that runs today into a `compile_failed`. A
712
+ * repeat is the model restating one program, never a second step — a second
713
+ * step that genuinely re-runs the same code would still have to differ
714
+ * somewhere, if only in what it does with the result.
715
+ *
716
+ * Distinct blocks are joined as they were written, so a value bound in one is
717
+ * bound for the ones after it. One program therefore means one set of
718
+ * declarations, and two blocks that both declare the same name are a
719
+ * `SyntaxError` the compiler reports — a durable observation the next frame can
720
+ * fix, unlike silently running one block of seven, which is not observable at
721
+ * all. The contract states the rule so a model that batches writes blocks that
722
+ * compose, and `CellTurn` names the block count when such a program fails to
723
+ * compile.
724
+ *
725
+ * The program is `typescript` when any block declared a typed fence, because
726
+ * both bindings run TypeScript by erasing type-only syntax and erasure is
727
+ * harmless to a plain-JavaScript block.
728
+ *
729
+ * Extraction reads text and never judges syntax. Whether the source uses module
730
+ * syntax is a question about JavaScript, and it is answered by parsing the cell
731
+ * in `Sandbox.compile`, which is also where an `imports_forbidden` rejection is
732
+ * raised.
733
+ *
734
+ * @category conversions
735
+ * @since 0.1.0
736
+ * @slop
737
+ */
738
+ export const extract = (text) => {
739
+ const bodies = [];
740
+ const distinct = new Set();
741
+ let typed = false;
742
+ fenced.lastIndex = 0;
743
+ for (const match of text.matchAll(fenced)) {
744
+ /* v8 ignore next -- `info` is a mandatory group of `fenced`, outside any alternation or quantifier, so it participates in every match; the default only discharges the optional type TypeScript gives `RegExpMatchArray.groups` */
745
+ const candidate = languageOf(match.groups?.info ?? "");
746
+ if (candidate === undefined)
747
+ continue;
748
+ if (match.groups?.close === undefined) {
749
+ return Result.fail(new Rejected({
750
+ code: "output_truncated",
751
+ message: "The response contains an unterminated cell fence. No blocks ran. Emit the complete program with every fence closed."
752
+ }));
753
+ }
754
+ if (candidate === "typescript")
755
+ typed = true;
756
+ /* v8 ignore next -- `body` is likewise mandatory in `fenced`; a match that reached here already produced `info`, so `groups` is present and carries both */
757
+ const body = match.groups?.body ?? "";
758
+ bodies.push(body);
759
+ distinct.add(body);
760
+ }
761
+ if (bodies.length === 0) {
762
+ return Result.fail(new Rejected({
763
+ code: "no_cell",
764
+ message: "No cell was found in the response. Emit a fenced ```cell block containing the JavaScript for this transition."
765
+ }));
766
+ }
767
+ return Result.succeed({
768
+ source: source([...distinct].join("\n"), typed ? "typescript" : "javascript"),
769
+ blocks: bodies.length
770
+ });
771
+ };
772
+ //# sourceMappingURL=Cell.js.map