@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,70 @@
1
+ /**
2
+ * UTF-8 byte measurement and boundary-safe slicing.
3
+ *
4
+ * JavaScript indexes strings in UTF-16 code units, while every bound this
5
+ * harness presents to a model and records in a journal is stated in UTF-8
6
+ * bytes. These helpers keep that unit honest without ever cutting a code point
7
+ * into an invalid string.
8
+ *
9
+ * @since 0.1.0
10
+ * @private
11
+ */
12
+
13
+ const encoder = new TextEncoder()
14
+
15
+ /**
16
+ * Measures a string in UTF-8 bytes.
17
+ *
18
+ * @category conversions
19
+ * @since 0.1.0
20
+ * @private
21
+ */
22
+ export const size = (text: string): number => encoder.encode(text).byteLength
23
+
24
+ /**
25
+ * Returns the longest code-point-aligned prefix no wider than `limit` UTF-8 bytes.
26
+ *
27
+ * @category conversions
28
+ * @since 0.1.0
29
+ * @private
30
+ */
31
+ export const headSlice = (text: string, limit: number): string => {
32
+ let end = 0
33
+ let used = 0
34
+ for (const character of text) {
35
+ const next = used + size(character)
36
+ if (next > limit) break
37
+ used = next
38
+ end = end + character.length
39
+ }
40
+ return text.slice(0, end)
41
+ }
42
+
43
+ /**
44
+ * Returns the longest code-point-aligned suffix no wider than `limit` UTF-8 bytes.
45
+ *
46
+ * @category conversions
47
+ * @since 0.1.0
48
+ * @private
49
+ */
50
+ export const tailSlice = (text: string, limit: number): string => {
51
+ let start = text.length
52
+ let used = 0
53
+ // Inspect only the suffix: a large print must not allocate an array for
54
+ // the discarded prefix or a TextEncoder buffer for each retained character.
55
+ while (start > 0) {
56
+ const last = text.charCodeAt(start - 1)
57
+ let units = 1
58
+ if (last >= 0xdc00 && last <= 0xdfff && start > 1) {
59
+ const previous = text.charCodeAt(start - 2)
60
+ if (previous >= 0xd800 && previous <= 0xdbff) units = 2
61
+ }
62
+ // Lone surrogates use three UTF-8 bytes, like TextEncoder's replacement.
63
+ const width = units === 2 ? 4 : last < 0x80 ? 1 : last < 0x800 ? 2 : 3
64
+ const next = used + width
65
+ if (next > limit) break
66
+ used = next
67
+ start = start - units
68
+ }
69
+ return text.slice(start)
70
+ }
@@ -0,0 +1,337 @@
1
+ /**
2
+ * The one contract the cell-first harness teaches a model.
3
+ *
4
+ * This contract is plain JavaScript over `ctx.call`, shaped to look like the
5
+ * Claude Code workflow API, and that is a ruling rather than an accident: will
6
+ * ruled on 2026-08-20 that the model authoring surface stays this shape,
7
+ * because agents perform better on the shape they are trained on. Effect.ts is
8
+ * the language of the code we maintain, not the language the model writes. Do
9
+ * not port this contract onto `Flow`/`Action`/`Node`; that was built out under
10
+ * a 2026-08-12 ruling and reversed. It may be tested later as a benchmark arm
11
+ * and is adopted only if it benchmarks better.
12
+ *
13
+ * There is one contract, and it is the REPL's. The surface it replaced — a cell
14
+ * as the body of its own async function, filing JSON into `state` and choosing
15
+ * its successor's `context` by hand — is recorded as a design error rather than
16
+ * as an arm that lost: it made the model do the realm's job, which is why it
17
+ * never worked like a REPL. will ruled it out on 2026-08-24. The evidence and
18
+ * the ruling are in `../../docs/concepts.md#repl-realm`.
19
+ *
20
+ * The teaching here is measured, not preferred, and the measurement has now run
21
+ * both ways. The merged optimal-trace program
22
+ * predicted that more teaching
23
+ * would buy verdicts, and grew the contract it replaced from 8,197 to 11,312
24
+ * characters across changes 2, 9 and 10. The re-run that settles those
25
+ * predictions says it did not:
26
+ * resolved fell 35/45 to 30/45, cost rose 59 %, and five instances spent a whole
27
+ * 1,200 s budget without editing one byte, held there by an unconditional
28
+ * pre-edit reproduction rule. The same wave shows every *tool* change paying.
29
+ * That is why the rules below carry their traces and why a teaching change is
30
+ * made one at a time.
31
+ *
32
+ * The exception rule 8 used to state — "when the command will not bootstrap,
33
+ * edit on the diagnosis you have and establish the proof afterwards" — is gone,
34
+ * and it is gone because the thing it was managing no longer exists. It existed
35
+ * to relieve an *ordering*: a baseline had to be taken before the edit, so a
36
+ * baseline that could not be taken yet blocked the edit. Checkpoints remove the
37
+ * ordering outright (will, 2026-08-24). The baseline is now taken after the
38
+ * edit, against `ctx.base`, so there is nothing left to make conditional and a
39
+ * sentence offering relief from a constraint the contract no longer imposes is
40
+ * teaching a shape that is not the shape.
41
+ *
42
+ * The same ruling is why the worked examples put the edit first and the
43
+ * baseline second. That ordering is the whole of the failure it kills: on
44
+ * `sympy__sympy-13878` the r95repl lane applied one byte-identical
45
+ * 4,789-character patch five times, four of those applications preceded by
46
+ * `git checkout -- sympy/stats/crv_types.py`, because a clean fails-before
47
+ * proof required reverting the very work it was meant to prove. Models imitate
48
+ * the example, and the example now shows a run that never gives its work back.
49
+ *
50
+ * The environment facts a host can compute (change 9) stay in full: they cost
51
+ * the agent nothing to read and removed a whole class of archaeology.
52
+ *
53
+ * Each rule below carries the failure it was written against; do not soften one
54
+ * without the trace that says the failure stopped happening, and do not add one
55
+ * without a trace that says teaching — rather than a tool — is the gap.
56
+ *
57
+ * Governing design: `../../docs/concepts.md#model-authoring-surface` (the
58
+ * ruling) and `../../docs/concepts.md#agent-cell-context` (the surface).
59
+ *
60
+ * @since 0.1.0
61
+ */
62
+
63
+ import * as Digest from "@smthrs/core/Digest"
64
+ import * as CanonicalJson from "@smthrs/model/CanonicalJson"
65
+ import type * as Descriptor from "@smthrs/registry/Descriptor"
66
+ import { Option } from "effect"
67
+ import type * as AgentEvent from "../AgentEvent.ts"
68
+ import type * as Cell from "../Cell.ts"
69
+ import * as Monitor from "../Monitor.ts"
70
+ import { untrustedData } from "./untrustedData.ts"
71
+
72
+ /**
73
+ * One rendered prompt section, with the digest that identifies its
74
+ * content.
75
+ *
76
+ * @since 0.1.0
77
+ * @private
78
+ * @slop
79
+ */
80
+ export interface Section {
81
+ readonly id: "cell-contract" | "cell-stance" | "cell-environment" | "cell-jev" | "cell-catalog"
82
+ readonly text: string
83
+ readonly digest: string
84
+ }
85
+
86
+ /**
87
+ * Facts about the container a run executes in, computed by the harness.
88
+ *
89
+ * Every field is something the host can read off the environment without
90
+ * knowing anything about the task, which is the whole admission rule: the
91
+ * program that motivated this section rejects instance-specific teaching
92
+ * outright, so the shape is a closed set of typed fields rather than free
93
+ * prose a caller could smuggle an answer into. Facts that are absent are not
94
+ * rendered; the run discovers them the ordinary way.
95
+ *
96
+ * @category models
97
+ * @since 0.1.0
98
+ * @slop
99
+ */
100
+ export interface Environment {
101
+ /** The container's locale and encoding, as `LANG`/`LC_ALL` report it. */
102
+ readonly locale?: string
103
+ /** Tools a run will reach for that this image does not install. */
104
+ readonly absentTools?: ReadonlyArray<string>
105
+ }
106
+
107
+ /**
108
+ * The contract every run is taught.
109
+ *
110
+ * It is the contract that replaced the filing one, and the difference is exactly
111
+ * the difference in the surface: there is no returned object to describe, no
112
+ * `state` to file, no manifest to read, and no `render`/`recall` to name,
113
+ * because the variable is the memory and the print is the summary.
114
+ *
115
+ * Every rule with a trace behind it was carried across byte-similar when the
116
+ * surface changed, and that was deliberate: the r91 rerun grew the old contract
117
+ * from 8,197 to 11,312 characters and dropped resolved from 35/45 to 30/45 at
118
+ * 59 % more cost, which says teaching changes are expensive and must be measured
119
+ * one at a time. A wave that changed the realm *and* re-cut the doctrine could
120
+ * not attribute its own result. Cutting further is its own arm, with its own
121
+ * wave.
122
+ *
123
+ * The second worked example is the golf report's own prescription — its
124
+ * class-(a) finding is that the contract's only worked example is a three-line
125
+ * toy, and models imitate the example.
126
+ *
127
+ * It moved a second time on 2026-08-24, when checkpoints landed: the baseline
128
+ * moved after the edit in the example and rule 9 names `ctx.base`. Both pinned
129
+ * numbers moved with it.
130
+ *
131
+ * The completion teaching first moved after the first REPL wave, and the change
132
+ * is stated rather than smuggled. What died is the see-then-attest rule
133
+ * ("complete only once you have SEEN that identical command pass"): it asked for
134
+ * a memory of a result and got one, and `sympy__sympy-13878` ended by claiming
135
+ * in `output` that a suite "exited 0 and printed its passing test summary" one
136
+ * frame after its own guarded `ctx.done` had declined to fire because that suite
137
+ * exited 1. What replaces it is the shape the model had already written and
138
+ * abandoned: complete behind a check of the result, `if (after.exitCode === 0)
139
+ * ctx.done(...)`, so the verdict is read from the call rather than remembered
140
+ * across a turn. An unguarded completion stays legal — sometimes nothing in the
141
+ * image can be made to flip — and is named for what it is, a claim nobody
142
+ * checked. That is will's ruling of 2026-08-23, and it is why the pinned length
143
+ * in `test/CellPrompt.test.ts` moved.
144
+ *
145
+ * Task scoping moved on 2026-09-19 after a chat request to answer only A spent
146
+ * twelve frames printing and then looking for an unrelated failing test.
147
+ * The host already taught same-cell completion, but these rules required an
148
+ * edit and a proving command unconditionally. The scoped contract completed
149
+ * the retained natural-language opening in six of six probes, against four
150
+ * of six for the old contract. A seeded six-print loop still did not recover
151
+ * the exact answer; the unchanged read-only cap remains necessary. The edit,
152
+ * baseline and tree-review requirements remain for requested workspace work.
153
+ *
154
+ * Rule 10 and rule 4's `jev` clause moved to the `cell-jev` section on
155
+ * 2026-09-25 (#1929), so a run with no `jev` bound is not taught it.
156
+ *
157
+ * On 2026-09-30 will ruled for token economy: every rule stays, prose becomes
158
+ * fragments, 9,715 → 5,553 characters. No wave has measured this wording yet.
159
+ *
160
+ * Governing design: `../../docs/concepts.md#repl-realm`.
161
+ */
162
+ const replContract = `JavaScript REPL, one cell per turn, alive for the whole run.
163
+
164
+ Every reply MUST contain a fenced \`cell\` block, JavaScript only. Several blocks in one reply run as ONE program.
165
+
166
+ Top-level bindings persist across cells, as in any REPL. \`console.log\` output opens your next turn and stays in context; unprinted values stay in their variables.
167
+
168
+ Example bug fix, two cells. Names illustrative; call what \`ctx.flows\` lists.
169
+
170
+ \`\`\`cell
171
+ const found = await ctx.call("grep", { pattern: "return value", root: "src/units", limit: 5 })
172
+ const hit = found.ok === false ? undefined : found.matches[0] // failed calls resolve, never throw
173
+ const region = await ctx.call("read", { path: hit.file, offset: Math.max(1, hit.line - 20), limit: 40 })
174
+ console.log(region.content)
175
+ \`\`\`
176
+
177
+ \`\`\`cell
178
+ const verification = { flow: "bash", input: { command: "run-tests tests/test_widen.py::test_keeps_unit" } }
179
+ const anchor = hit.text // text a call returned, never typed from memory
180
+ const applied = await ctx.call("edit", { path: hit.file, oldString: anchor, newString: anchor.replace("return value", "return widen(value)") })
181
+ const before = await ctx.call(verification.flow, verification.input, { at: ctx.base }) // opening tree; edit stays
182
+ const after = await ctx.call(verification.flow, verification.input)
183
+ console.log(applied.ok === false ? applied.error.message : applied.hunk, before.exitCode, after.exitCode, after.stdout)
184
+ if (before.exitCode !== 0 && after.exitCode === 0) ctx.done(verification.input.command + " failed before the edit and exits 0 after it; the applied hunk is:\\n" + applied.hunk)
185
+ \`\`\`
186
+
187
+ Many calls per cell; one call per frame wastes turns.
188
+
189
+ Rules:
190
+
191
+ 1. Bindings: \`ctx\`, \`console\`, earlier cells' names. \`ctx.call(name, input)\` runs a flow; \`ctx.flows\` lists them. No imports, require, fetch, filesystem, process, Date, Math.random; anything else throws. Strings passed to flows are data (a Python heredoc is fine).
192
+ 2. Every effect is a flow: files, commands, memory, questions, subagents.
193
+ 3. A failed call does not throw: resolves \`{ ok: false, error: { code, message, hint } }\`; test \`.ok === false\` where you are unsure. Success resolves the result unwrapped. A throwing cell keeps names already assigned. Long calls spend the flow's budget, not the cell's. Output is capped: a result flagged truncated is a fragment. Restore files with git checkout or git restore; never route file content through captured stdout (a write of bytes a call returned truncated is refused).
194
+ 4. Print only what you must read; keep the rest in variables. Each turn opens with your last print, bound names, and one line per settled call (tree writes and repeats flagged). Prints are re-paid every turn: ≤40 lines a cell; never whole listings, search results, files or intermediates. Counts and paths first (\`console.log(hits.matches.length, files.slice(0, 15))\`, not \`console.log(hits)\`), then read only the chosen region. Structures print as JSON; record lists as tables.
195
+ 5. Finish by calling. \`ctx.done(output)\` ends the run; \`output\` is the answer. \`ctx.park(reason, message)\` waits durably for a human; reason "waiting-input" | "waiting-event" | "waiting-quota"; refused when nobody listens. Both take effect at that line; later calls in the cell resolve \`{ ok: false, error: { code: "run_completed" } }\`. Conversational or read-only request: \`ctx.done(answer)\` directly; no edit, command, baseline or tree review. \`console.log\` alone does not finish. Workspace change: finish behind the deciding check, \`if (after.exitCode === 0) ctx.done(...)\`. Let the guard read the tree too: \`git status --porcelain\` and \`git diff\` in the completing cell; finish silently only when the check passes AND the diff holds exactly the files you meant to change, else \`console.log\` that diff. A bare \`ctx.done\` is allowed but is a claim nobody checked: say what is unverified. Name each claimed check's exact command and output. A cell calling neither ends the turn.
196
+ 6. Resume re-executes cells from the top; settled calls replay recorded results.
197
+ 7. Bug-fix evidence: a command counts only after you SEE it fail on the unmodified tree FOR THE RIGHT REASON (the bug). A probe naming a test, file, module or program that does not exist reproduces nothing; \`invalidProbe\` flags some. Fix such a probe before you rely on it. Keep the check as \`verification = { flow, input }\`; reuse it unchanged after edits.
198
+ 8. Workspace change: read broadly in ONE cell, then edit. Too many frames without a write stop the run; near the limit, edit or \`ctx.justify("<missing evidence, the call that gets it, what changes next>")\`. An edit answers with the hunk it applied: print it in the same cell (a bad edit costs one glance there). Then run whatever language-aware checker \`ctx.flows\` and this image actually offer (compiler, ruff, eslint/tsc) through the shell flow. Fix undefined names before broad suites. No checker: say so; never regex-guess.
199
+ 9. Bug-fix proof, fewest frames: ONE cell edits, runs the baseline at \`{ at: ctx.base }\` (opening tree), reruns the identical check. NEVER undo your own edit to re-prove a baseline. \`ctx.checkpoint()\` pins the current tree for your own baseline; a checkpoint is read-only, so a flow that writes is refused at one. Let code decide: \`if (before.exitCode !== 0 && after.exitCode === 0) ctx.done(...)\`. An already-green suite or a probe that misses its target proves nothing.
200
+
201
+ Cell throws: you are told, next turn. If a cell does not PARSE nothing ran at all; you are asked again inside the SAME frame with the error and line.`
202
+
203
+ /**
204
+ * How a cell uses the `jev` flow, taught only when the catalog binds it.
205
+ *
206
+ * It was rule 10 of the contract and a clause of rule 4 until 2026-09-25, when
207
+ * will asked for Jev to be used strongly in the cells a model writes (#1929).
208
+ * A rule that names a flow the catalog may not hold teaches a call that
209
+ * resolves `unknown_flow`, so the teaching moved into a section of its own
210
+ * that exists exactly when the flow does. It is constant for a run, so it sits
211
+ * between the environment and the catalog without breaking the cached prefix.
212
+ *
213
+ * The floors are the owner's: act on a boolean at probability 0.8, and on a
214
+ * choice or score at the provider's confidence 0.7. A choice's own
215
+ * `.confidence` is the largest probability in its distribution and reads 1
216
+ * when none was sent, so the teaching names the provider's number instead.
217
+ *
218
+ * The one worked example is run verbatim by `test/CellFlows.test.ts` against
219
+ * the real `grep` and `jev` bindings, because a model copies the example.
220
+ */
221
+ const jevText =
222
+ `1. Use \`jev\` for any judgment over >3 items and any yes/no, pick-one or score you would otherwise make by printing and reading (relevant files, related failures, rankings, which subtask needs a worker). ONE call: items in \`state:\`, one question per item keyed by your id. Hundreds take ~300 ms.
223
+ 2. Never make one call per item; never ask \`jev\` for text, code or quotes.
224
+ 3. Failure resolves \`{ ok: false }\`: print \`error.message\`; do not decide in its place.
225
+ 4. Act on booleans when \`answers[id].probability >= 0.8\`; on choice or score when \`judged.confidence?.[id] >= 0.7\` (provider confidence; absent = uncertain). Never use a choice's own \`.confidence\` (reads 1 without a distribution). Print uncertain items; don't decide them.
226
+
227
+ \`\`\`cell
228
+ const found = await ctx.call("grep", { pattern: "timeout", root: "src", limit: 200 })
229
+ const files = found.ok === false ? [] : [...new Set(found.matches.map((m) => m.file))]
230
+ const judged = await ctx.call("jev", { state: { task: "the timeout ignores its setting", files }, questions: Object.fromEntries(files.map((f) => [f, { type: "boolean", instructions: "Must " + f + " change?" }])) })
231
+ const p = (f) => judged.answers[f].probability
232
+ const kept = judged.ok === false ? [] : files.filter((f) => p(f) >= 0.8)
233
+ const uncertain = judged.ok === false ? [] : files.filter((f) => p(f) > 0.2 && p(f) < 0.8)
234
+ console.log(found.ok === false ? found.error.message : judged.ok === false ? judged.error.message : { count: files.length, kept, uncertain })
235
+ \`\`\``
236
+
237
+ /**
238
+ * The one line a judged run is taught about its stance: the Monitor mood text,
239
+ * verbatim, so the static stance and the delivered mood never disagree.
240
+ */
241
+ const stanceText = (stance: typeof AgentEvent.Stance.Type): string =>
242
+ stance === "paranoid" ? Monitor.paranoidText : Monitor.carefulText
243
+
244
+ const historyFact =
245
+ `the checkout ends at the commit you were given; no branch, tag, stash or reflog here holds a later fix, so \`git log --all\` or \`-S\` hunting costs a frame and returns nothing. The harness keeps its own attempt and durability snapshots in a repository of its own. A dangling commit is this harness pinning your own tree for a checkpoint: \`git fsck\` reports your edit and never a fix. Backwards history pays: \`git blame\` or \`git log -S\` on a line says what an assertion was written for; given a last-known-good release, \`git log <tag>..HEAD -- <paths>\`.`
246
+
247
+ const environmentText = (environment: Environment): string => {
248
+ const lines = [`- History: ${historyFact}`]
249
+ if (environment.locale !== undefined) {
250
+ lines.push(
251
+ `- Locale: ${environment.locale}; output and files decode as that.`
252
+ )
253
+ }
254
+ const absent = environment.absentTools === undefined ? [] : [...environment.absentTools].sort()
255
+ if (absent.length > 0) {
256
+ lines.push(
257
+ `- Not installed: ${absent.join(", ")}. Calls to them fail; use \`ctx.flows\`.`
258
+ )
259
+ }
260
+ return `Harness-computed facts about the checkout and container, not the task.\n${lines.join("\n")}`
261
+ }
262
+
263
+ const digest = (id: Section["id"], text: string): string => Digest.digest(CanonicalJson.stringify({ id, text }))
264
+
265
+ type CatalogProjection = Cell.FlowProjection & Partial<Pick<Descriptor.FlowDescriptor, "provenance" | "path">>
266
+
267
+ const catalogText = (flows: Readonly<Record<string, CatalogProjection>>): string => {
268
+ const names = Object.keys(flows).sort()
269
+ if (names.length === 0) {
270
+ return "No flows are callable in this run. Complete or park; ctx.call has nothing to reach."
271
+ }
272
+ const lines = names.map((name) => {
273
+ const projection = flows[name]!
274
+ const capabilities = projection.capabilities.length === 0
275
+ ? ""
276
+ : ` capabilities=${[...projection.capabilities].sort().join(",")}`
277
+ const origin = JSON.stringify({
278
+ source: projection.provenance?.source ?? "unknown",
279
+ root: projection.provenance?.root,
280
+ path: projection.path
281
+ })
282
+ const heading = `- ${name} (${projection.tier})${capabilities}: ${projection.description}\n provenance: ${origin}`
283
+ // The input schema is the difference between choosing a call and guessing
284
+ // one. A rejected input costs a whole frame, so a catalog that names a
285
+ // flow without saying what it takes spends the run's frame budget on
286
+ // trial and error.
287
+ return Option.isNone(projection.input)
288
+ ? heading
289
+ : `${heading}\n input: ${JSON.stringify(projection.input.value)}`
290
+ })
291
+ return `Flows callable with ctx.call in this frame:\n${
292
+ untrustedData(lines.join("\n"), "flow catalog (descriptor provenance follows)")
293
+ }`
294
+ }
295
+
296
+ /**
297
+ * Builds the cell-contract teaching sections for one frame.
298
+ *
299
+ * The order is by how often each section changes, because every one of them is
300
+ * a prefix segment and a prefix is only cached up to its first edit: the
301
+ * contract is constant for the life of the binary, the environment and the
302
+ * `jev` teaching for the life of a run, and the catalog can differ frame to
303
+ * frame. The `jev` teaching is rendered only when `flows` binds `jev`.
304
+ *
305
+ * `stance` renders a one-line `cell-stance` section between the contract and
306
+ * the environment. It is constant for the run, so the cached prefix holds;
307
+ * with no stance nothing is rendered and the prompt is unchanged.
308
+ *
309
+ * `environment` carries what the host measured about the container. It is
310
+ * optional because the epoch fact — a checkout has no future in it — holds
311
+ * everywhere and is stated with or without a host that measures anything else.
312
+ *
313
+ * @category constructors
314
+ * @since 0.1.0
315
+ * @slop
316
+ */
317
+ export const make = (
318
+ flows: Readonly<Record<string, CatalogProjection>>,
319
+ environment: Environment = {},
320
+ stance?: typeof AgentEvent.Stance.Type
321
+ ): ReadonlyArray<Section> => {
322
+ const facts = environmentText(environment)
323
+ const catalog = catalogText(flows)
324
+ const taught = replContract
325
+ const stanced = stance === undefined ? undefined : stanceText(stance)
326
+ return [
327
+ { id: "cell-contract", text: taught, digest: digest("cell-contract", taught) },
328
+ ...(stanced === undefined
329
+ ? []
330
+ : [{ id: "cell-stance" as const, text: stanced, digest: digest("cell-stance", stanced) }]),
331
+ { id: "cell-environment", text: facts, digest: digest("cell-environment", facts) },
332
+ ...(flows.jev === undefined
333
+ ? []
334
+ : [{ id: "cell-jev" as const, text: jevText, digest: digest("cell-jev", jevText) }]),
335
+ { id: "cell-catalog", text: catalog, digest: digest("cell-catalog", catalog) }
336
+ ]
337
+ }
@@ -0,0 +1,76 @@
1
+ /**
2
+ * The segments a compaction may replace.
3
+ *
4
+ * A window's system and instruction segments are what the next turn is still
5
+ * addressed to, so only the conversational kinds are eligible. `ContextWindow`
6
+ * selects the prefix and `Compaction` declares one against the same selection;
7
+ * two spellings of this filter that drifted would let a declared prefix name
8
+ * segments the window would never replace.
9
+ *
10
+ * @since 1.0.0-rc.0
11
+ * @private
12
+ */
13
+
14
+ import type * as ContextWindow from "../ContextWindow.ts"
15
+
16
+ /**
17
+ * The tokens the compaction trigger leaves free below the context window.
18
+ *
19
+ * @since 1.0.0-rc.0
20
+ * @private
21
+ */
22
+ export const defaultReserve = 16_000
23
+
24
+ /**
25
+ * The tokens of recent segments a compaction keeps whole.
26
+ *
27
+ * @since 1.0.0-rc.0
28
+ * @private
29
+ */
30
+ export const defaultKeepRecent = 20_000
31
+
32
+ /**
33
+ * The transcript, summary and steering segments of a window, in order.
34
+ *
35
+ * @since 1.0.0-rc.0
36
+ * @private
37
+ */
38
+ export const compactable = (
39
+ segments: ReadonlyArray<ContextWindow.Segment>
40
+ ): ReadonlyArray<ContextWindow.Segment> =>
41
+ segments.filter((segment) =>
42
+ segment.kind === "transcript" || segment.kind === "summary" || segment.kind === "steering"
43
+ )
44
+
45
+ /**
46
+ * The boundaries a cut may not fall on: every boundary between a tool call
47
+ * and its result, when the two sit in different segments of `segments`.
48
+ * Boundary `b` lies between `segments[b - 1]` and `segments[b]`.
49
+ *
50
+ * @since 1.0.0-rc.0
51
+ * @private
52
+ */
53
+ export const pairBoundaries = (segments: ReadonlyArray<ContextWindow.Segment>): ReadonlySet<number> => {
54
+ const calls = new Map<string, number>()
55
+ const results = new Map<string, number>()
56
+ for (const [index, segment] of segments.entries()) {
57
+ for (const item of segment.content) {
58
+ if ("role" in item && item.role === "assistant") {
59
+ for (const part of item.content) {
60
+ if (part.type === "tool-call") calls.set(part.id, index)
61
+ }
62
+ } else if ("role" in item && item.role === "tool") {
63
+ for (const part of item.content) results.set(part.toolCallId, index)
64
+ }
65
+ }
66
+ }
67
+ const unsafe = new Set<number>()
68
+ for (const [callId, callIndex] of calls) {
69
+ const resultIndex = results.get(callId)
70
+ if (resultIndex === undefined) continue
71
+ const first = Math.min(callIndex, resultIndex)
72
+ const last = Math.max(callIndex, resultIndex)
73
+ for (let boundary = first + 1; boundary <= last; boundary++) unsafe.add(boundary)
74
+ }
75
+ return unsafe
76
+ }