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

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 +985 -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 +1142 -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,57 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var bytes_exports = {};
20
+ __export(bytes_exports, {
21
+ headSlice: () => headSlice,
22
+ size: () => size,
23
+ tailSlice: () => tailSlice
24
+ });
25
+ module.exports = __toCommonJS(bytes_exports);
26
+ const encoder = new TextEncoder();
27
+ const size = (text) => encoder.encode(text).byteLength;
28
+ const headSlice = (text, limit) => {
29
+ let end = 0;
30
+ let used = 0;
31
+ for (const character of text) {
32
+ const next = used + size(character);
33
+ if (next > limit) break;
34
+ used = next;
35
+ end = end + character.length;
36
+ }
37
+ return text.slice(0, end);
38
+ };
39
+ const tailSlice = (text, limit) => {
40
+ let start = text.length;
41
+ let used = 0;
42
+ while (start > 0) {
43
+ const last = text.charCodeAt(start - 1);
44
+ let units = 1;
45
+ if (last >= 56320 && last <= 57343 && start > 1) {
46
+ const previous = text.charCodeAt(start - 2);
47
+ if (previous >= 55296 && previous <= 56319) units = 2;
48
+ }
49
+ const width = units === 2 ? 4 : last < 128 ? 1 : last < 2048 ? 2 : 3;
50
+ const next = used + width;
51
+ if (next > limit) break;
52
+ used = next;
53
+ start = start - units;
54
+ }
55
+ return text.slice(start);
56
+ };
57
+ //# sourceMappingURL=bytes.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/internal/bytes.ts"],
4
+ "sourcesContent": ["/**\n * UTF-8 byte measurement and boundary-safe slicing.\n *\n * JavaScript indexes strings in UTF-16 code units, while every bound this\n * harness presents to a model and records in a journal is stated in UTF-8\n * bytes. These helpers keep that unit honest without ever cutting a code point\n * into an invalid string.\n *\n * @since 0.1.0\n * @private\n */\n\nconst encoder = new TextEncoder()\n\n/**\n * Measures a string in UTF-8 bytes.\n *\n * @category conversions\n * @since 0.1.0\n * @private\n */\nexport const size = (text: string): number => encoder.encode(text).byteLength\n\n/**\n * Returns the longest code-point-aligned prefix no wider than `limit` UTF-8 bytes.\n *\n * @category conversions\n * @since 0.1.0\n * @private\n */\nexport const headSlice = (text: string, limit: number): string => {\n let end = 0\n let used = 0\n for (const character of text) {\n const next = used + size(character)\n if (next > limit) break\n used = next\n end = end + character.length\n }\n return text.slice(0, end)\n}\n\n/**\n * Returns the longest code-point-aligned suffix no wider than `limit` UTF-8 bytes.\n *\n * @category conversions\n * @since 0.1.0\n * @private\n */\nexport const tailSlice = (text: string, limit: number): string => {\n let start = text.length\n let used = 0\n // Inspect only the suffix: a large print must not allocate an array for\n // the discarded prefix or a TextEncoder buffer for each retained character.\n while (start > 0) {\n const last = text.charCodeAt(start - 1)\n let units = 1\n if (last >= 0xdc00 && last <= 0xdfff && start > 1) {\n const previous = text.charCodeAt(start - 2)\n if (previous >= 0xd800 && previous <= 0xdbff) units = 2\n }\n // Lone surrogates use three UTF-8 bytes, like TextEncoder's replacement.\n const width = units === 2 ? 4 : last < 0x80 ? 1 : last < 0x800 ? 2 : 3\n const next = used + width\n if (next > limit) break\n used = next\n start = start - units\n }\n return text.slice(start)\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA,MAAM,UAAU,IAAI,YAAY;AASzB,MAAM,OAAO,CAAC,SAAyB,QAAQ,OAAO,IAAI,EAAE;AAS5D,MAAM,YAAY,CAAC,MAAc,UAA0B;AAChE,MAAI,MAAM;AACV,MAAI,OAAO;AACX,aAAW,aAAa,MAAM;AAC5B,UAAM,OAAO,OAAO,KAAK,SAAS;AAClC,QAAI,OAAO,MAAO;AAClB,WAAO;AACP,UAAM,MAAM,UAAU;AAAA,EACxB;AACA,SAAO,KAAK,MAAM,GAAG,GAAG;AAC1B;AASO,MAAM,YAAY,CAAC,MAAc,UAA0B;AAChE,MAAI,QAAQ,KAAK;AACjB,MAAI,OAAO;AAGX,SAAO,QAAQ,GAAG;AAChB,UAAM,OAAO,KAAK,WAAW,QAAQ,CAAC;AACtC,QAAI,QAAQ;AACZ,QAAI,QAAQ,SAAU,QAAQ,SAAU,QAAQ,GAAG;AACjD,YAAM,WAAW,KAAK,WAAW,QAAQ,CAAC;AAC1C,UAAI,YAAY,SAAU,YAAY,MAAQ,SAAQ;AAAA,IACxD;AAEA,UAAM,QAAQ,UAAU,IAAI,IAAI,OAAO,MAAO,IAAI,OAAO,OAAQ,IAAI;AACrE,UAAM,OAAO,OAAO;AACpB,QAAI,OAAO,MAAO;AAClB,WAAO;AACP,YAAQ,QAAQ;AAAA,EAClB;AACA,SAAO,KAAK,MAAM,KAAK;AACzB;",
6
+ "names": []
7
+ }
@@ -0,0 +1,122 @@
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
+ import type * as Descriptor from "@smthrs/registry/Descriptor";
63
+ import type * as AgentEvent from "../AgentEvent.ts";
64
+ import type * as Cell from "../Cell.ts";
65
+ /**
66
+ * One rendered prompt section, with the digest that identifies its
67
+ * content.
68
+ *
69
+ * @since 0.1.0
70
+ * @private
71
+ * @slop
72
+ */
73
+ export interface Section {
74
+ readonly id: "cell-contract" | "cell-stance" | "cell-environment" | "cell-jev" | "cell-catalog";
75
+ readonly text: string;
76
+ readonly digest: string;
77
+ }
78
+ /**
79
+ * Facts about the container a run executes in, computed by the harness.
80
+ *
81
+ * Every field is something the host can read off the environment without
82
+ * knowing anything about the task, which is the whole admission rule: the
83
+ * program that motivated this section rejects instance-specific teaching
84
+ * outright, so the shape is a closed set of typed fields rather than free
85
+ * prose a caller could smuggle an answer into. Facts that are absent are not
86
+ * rendered; the run discovers them the ordinary way.
87
+ *
88
+ * @category models
89
+ * @since 0.1.0
90
+ * @slop
91
+ */
92
+ export interface Environment {
93
+ /** The container's locale and encoding, as `LANG`/`LC_ALL` report it. */
94
+ readonly locale?: string;
95
+ /** Tools a run will reach for that this image does not install. */
96
+ readonly absentTools?: ReadonlyArray<string>;
97
+ }
98
+ type CatalogProjection = Cell.FlowProjection & Partial<Pick<Descriptor.FlowDescriptor, "provenance" | "path">>;
99
+ /**
100
+ * Builds the cell-contract teaching sections for one frame.
101
+ *
102
+ * The order is by how often each section changes, because every one of them is
103
+ * a prefix segment and a prefix is only cached up to its first edit: the
104
+ * contract is constant for the life of the binary, the environment and the
105
+ * `jev` teaching for the life of a run, and the catalog can differ frame to
106
+ * frame. The `jev` teaching is rendered only when `flows` binds `jev`.
107
+ *
108
+ * `stance` renders a one-line `cell-stance` section between the contract and
109
+ * the environment. It is constant for the run, so the cached prefix holds;
110
+ * with no stance nothing is rendered and the prompt is unchanged.
111
+ *
112
+ * `environment` carries what the host measured about the container. It is
113
+ * optional because the epoch fact — a checkout has no future in it — holds
114
+ * everywhere and is stated with or without a host that measures anything else.
115
+ *
116
+ * @category constructors
117
+ * @since 0.1.0
118
+ * @slop
119
+ */
120
+ export declare const make: (flows: Readonly<Record<string, CatalogProjection>>, environment?: Environment, stance?: typeof AgentEvent.Stance.Type) => ReadonlyArray<Section>;
121
+ export {};
122
+ //# sourceMappingURL=cellPrompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cellPrompt.d.ts","sourceRoot":"","sources":["../../../src/internal/cellPrompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AAIH,OAAO,KAAK,KAAK,UAAU,MAAM,6BAA6B,CAAA;AAE9D,OAAO,KAAK,KAAK,UAAU,MAAM,kBAAkB,CAAA;AACnD,OAAO,KAAK,KAAK,IAAI,MAAM,YAAY,CAAA;AAIvC;;;;;;;GAOG;AACH,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,EAAE,EAAE,eAAe,GAAG,aAAa,GAAG,kBAAkB,GAAG,UAAU,GAAG,cAAc,CAAA;IAC/F,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,WAAW;IAC1B,yEAAyE;IACzE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,mEAAmE;IACnE,QAAQ,CAAC,WAAW,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;CAC7C;AAgKD,KAAK,iBAAiB,GAAG,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,cAAc,EAAE,YAAY,GAAG,MAAM,CAAC,CAAC,CAAA;AA+B9G;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,IAAI,GACf,OAAO,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,EAClD,cAAa,WAAgB,EAC7B,SAAS,OAAO,UAAU,CAAC,MAAM,CAAC,IAAI,KACrC,aAAa,CAAC,OAAO,CAgBvB,CAAA"}
@@ -0,0 +1,146 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var cellPrompt_exports = {};
30
+ __export(cellPrompt_exports, {
31
+ make: () => make
32
+ });
33
+ module.exports = __toCommonJS(cellPrompt_exports);
34
+ var Digest = __toESM(require("@smthrs/core/Digest"), 1);
35
+ var CanonicalJson = __toESM(require("@smthrs/model/CanonicalJson"), 1);
36
+ var import_effect = require("effect");
37
+ var Monitor = __toESM(require("../Monitor.js"), 1);
38
+ var import_untrustedData = require("./untrustedData.js");
39
+ const replContract = `JavaScript REPL, one cell per turn, alive for the whole run.
40
+
41
+ Every reply MUST contain a fenced \`cell\` block, JavaScript only. Several blocks in one reply run as ONE program.
42
+
43
+ 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.
44
+
45
+ Example bug fix, two cells. Names illustrative; call what \`ctx.flows\` lists.
46
+
47
+ \`\`\`cell
48
+ const found = await ctx.call("grep", { pattern: "return value", root: "src/units", limit: 5 })
49
+ const hit = found.ok === false ? undefined : found.matches[0] // failed calls resolve, never throw
50
+ const region = await ctx.call("read", { path: hit.file, offset: Math.max(1, hit.line - 20), limit: 40 })
51
+ console.log(region.content)
52
+ \`\`\`
53
+
54
+ \`\`\`cell
55
+ const verification = { flow: "bash", input: { command: "run-tests tests/test_widen.py::test_keeps_unit" } }
56
+ const anchor = hit.text // text a call returned, never typed from memory
57
+ const applied = await ctx.call("edit", { path: hit.file, oldString: anchor, newString: anchor.replace("return value", "return widen(value)") })
58
+ const before = await ctx.call(verification.flow, verification.input, { at: ctx.base }) // opening tree; edit stays
59
+ const after = await ctx.call(verification.flow, verification.input)
60
+ console.log(applied.ok === false ? applied.error.message : applied.hunk, before.exitCode, after.exitCode, after.stdout)
61
+ 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)
62
+ \`\`\`
63
+
64
+ Many calls per cell; one call per frame wastes turns.
65
+
66
+ Rules:
67
+
68
+ 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).
69
+ 2. Every effect is a flow: files, commands, memory, questions, subagents.
70
+ 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).
71
+ 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: \u226440 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.
72
+ 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.
73
+ 6. Resume re-executes cells from the top; settled calls replay recorded results.
74
+ 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.
75
+ 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.
76
+ 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.
77
+
78
+ 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.`;
79
+ const jevText = `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.
80
+ 2. Never make one call per item; never ask \`jev\` for text, code or quotes.
81
+ 3. Failure resolves \`{ ok: false }\`: print \`error.message\`; do not decide in its place.
82
+ 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.
83
+
84
+ \`\`\`cell
85
+ const found = await ctx.call("grep", { pattern: "timeout", root: "src", limit: 200 })
86
+ const files = found.ok === false ? [] : [...new Set(found.matches.map((m) => m.file))]
87
+ 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?" }])) })
88
+ const p = (f) => judged.answers[f].probability
89
+ const kept = judged.ok === false ? [] : files.filter((f) => p(f) >= 0.8)
90
+ const uncertain = judged.ok === false ? [] : files.filter((f) => p(f) > 0.2 && p(f) < 0.8)
91
+ console.log(found.ok === false ? found.error.message : judged.ok === false ? judged.error.message : { count: files.length, kept, uncertain })
92
+ \`\`\``;
93
+ const stanceText = (stance) => stance === "paranoid" ? Monitor.paranoidText : Monitor.carefulText;
94
+ const historyFact = `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>\`.`;
95
+ const environmentText = (environment) => {
96
+ const lines = [`- History: ${historyFact}`];
97
+ if (environment.locale !== void 0) {
98
+ lines.push(
99
+ `- Locale: ${environment.locale}; output and files decode as that.`
100
+ );
101
+ }
102
+ const absent = environment.absentTools === void 0 ? [] : [...environment.absentTools].sort();
103
+ if (absent.length > 0) {
104
+ lines.push(
105
+ `- Not installed: ${absent.join(", ")}. Calls to them fail; use \`ctx.flows\`.`
106
+ );
107
+ }
108
+ return `Harness-computed facts about the checkout and container, not the task.
109
+ ${lines.join("\n")}`;
110
+ };
111
+ const digest = (id, text) => Digest.digest(CanonicalJson.stringify({ id, text }));
112
+ const catalogText = (flows) => {
113
+ const names = Object.keys(flows).sort();
114
+ if (names.length === 0) {
115
+ return "No flows are callable in this run. Complete or park; ctx.call has nothing to reach.";
116
+ }
117
+ const lines = names.map((name) => {
118
+ const projection = flows[name];
119
+ const capabilities = projection.capabilities.length === 0 ? "" : ` capabilities=${[...projection.capabilities].sort().join(",")}`;
120
+ const origin = JSON.stringify({
121
+ source: projection.provenance?.source ?? "unknown",
122
+ root: projection.provenance?.root,
123
+ path: projection.path
124
+ });
125
+ const heading = `- ${name} (${projection.tier})${capabilities}: ${projection.description}
126
+ provenance: ${origin}`;
127
+ return import_effect.Option.isNone(projection.input) ? heading : `${heading}
128
+ input: ${JSON.stringify(projection.input.value)}`;
129
+ });
130
+ return `Flows callable with ctx.call in this frame:
131
+ ${(0, import_untrustedData.untrustedData)(lines.join("\n"), "flow catalog (descriptor provenance follows)")}`;
132
+ };
133
+ const make = (flows, environment = {}, stance) => {
134
+ const facts = environmentText(environment);
135
+ const catalog = catalogText(flows);
136
+ const taught = replContract;
137
+ const stanced = stance === void 0 ? void 0 : stanceText(stance);
138
+ return [
139
+ { id: "cell-contract", text: taught, digest: digest("cell-contract", taught) },
140
+ ...stanced === void 0 ? [] : [{ id: "cell-stance", text: stanced, digest: digest("cell-stance", stanced) }],
141
+ { id: "cell-environment", text: facts, digest: digest("cell-environment", facts) },
142
+ ...flows.jev === void 0 ? [] : [{ id: "cell-jev", text: jevText, digest: digest("cell-jev", jevText) }],
143
+ { id: "cell-catalog", text: catalog, digest: digest("cell-catalog", catalog) }
144
+ ];
145
+ };
146
+ //# sourceMappingURL=cellPrompt.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/internal/cellPrompt.ts"],
4
+ "sourcesContent": ["/**\n * The one contract the cell-first harness teaches a model.\n *\n * This contract is plain JavaScript over `ctx.call`, shaped to look like the\n * Claude Code workflow API, and that is a ruling rather than an accident: will\n * ruled on 2026-08-20 that the model authoring surface stays this shape,\n * because agents perform better on the shape they are trained on. Effect.ts is\n * the language of the code we maintain, not the language the model writes. Do\n * not port this contract onto `Flow`/`Action`/`Node`; that was built out under\n * a 2026-08-12 ruling and reversed. It may be tested later as a benchmark arm\n * and is adopted only if it benchmarks better.\n *\n * There is one contract, and it is the REPL's. The surface it replaced \u2014 a cell\n * as the body of its own async function, filing JSON into `state` and choosing\n * its successor's `context` by hand \u2014 is recorded as a design error rather than\n * as an arm that lost: it made the model do the realm's job, which is why it\n * never worked like a REPL. will ruled it out on 2026-08-24. The evidence and\n * the ruling are in `../../docs/concepts.md#repl-realm`.\n *\n * The teaching here is measured, not preferred, and the measurement has now run\n * both ways. The merged optimal-trace program\n * predicted that more teaching\n * would buy verdicts, and grew the contract it replaced from 8,197 to 11,312\n * characters across changes 2, 9 and 10. The re-run that settles those\n * predictions says it did not:\n * resolved fell 35/45 to 30/45, cost rose 59 %, and five instances spent a whole\n * 1,200 s budget without editing one byte, held there by an unconditional\n * pre-edit reproduction rule. The same wave shows every *tool* change paying.\n * That is why the rules below carry their traces and why a teaching change is\n * made one at a time.\n *\n * The exception rule 8 used to state \u2014 \"when the command will not bootstrap,\n * edit on the diagnosis you have and establish the proof afterwards\" \u2014 is gone,\n * and it is gone because the thing it was managing no longer exists. It existed\n * to relieve an *ordering*: a baseline had to be taken before the edit, so a\n * baseline that could not be taken yet blocked the edit. Checkpoints remove the\n * ordering outright (will, 2026-08-24). The baseline is now taken after the\n * edit, against `ctx.base`, so there is nothing left to make conditional and a\n * sentence offering relief from a constraint the contract no longer imposes is\n * teaching a shape that is not the shape.\n *\n * The same ruling is why the worked examples put the edit first and the\n * baseline second. That ordering is the whole of the failure it kills: on\n * `sympy__sympy-13878` the r95repl lane applied one byte-identical\n * 4,789-character patch five times, four of those applications preceded by\n * `git checkout -- sympy/stats/crv_types.py`, because a clean fails-before\n * proof required reverting the very work it was meant to prove. Models imitate\n * the example, and the example now shows a run that never gives its work back.\n *\n * The environment facts a host can compute (change 9) stay in full: they cost\n * the agent nothing to read and removed a whole class of archaeology.\n *\n * Each rule below carries the failure it was written against; do not soften one\n * without the trace that says the failure stopped happening, and do not add one\n * without a trace that says teaching \u2014 rather than a tool \u2014 is the gap.\n *\n * Governing design: `../../docs/concepts.md#model-authoring-surface` (the\n * ruling) and `../../docs/concepts.md#agent-cell-context` (the surface).\n *\n * @since 0.1.0\n */\n\nimport * as Digest from \"@smthrs/core/Digest\"\nimport * as CanonicalJson from \"@smthrs/model/CanonicalJson\"\nimport type * as Descriptor from \"@smthrs/registry/Descriptor\"\nimport { Option } from \"effect\"\nimport type * as AgentEvent from \"../AgentEvent.ts\"\nimport type * as Cell from \"../Cell.ts\"\nimport * as Monitor from \"../Monitor.ts\"\nimport { untrustedData } from \"./untrustedData.ts\"\n\n/**\n * One rendered prompt section, with the digest that identifies its\n * content.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface Section {\n readonly id: \"cell-contract\" | \"cell-stance\" | \"cell-environment\" | \"cell-jev\" | \"cell-catalog\"\n readonly text: string\n readonly digest: string\n}\n\n/**\n * Facts about the container a run executes in, computed by the harness.\n *\n * Every field is something the host can read off the environment without\n * knowing anything about the task, which is the whole admission rule: the\n * program that motivated this section rejects instance-specific teaching\n * outright, so the shape is a closed set of typed fields rather than free\n * prose a caller could smuggle an answer into. Facts that are absent are not\n * rendered; the run discovers them the ordinary way.\n *\n * @category models\n * @since 0.1.0\n * @slop\n */\nexport interface Environment {\n /** The container's locale and encoding, as `LANG`/`LC_ALL` report it. */\n readonly locale?: string\n /** Tools a run will reach for that this image does not install. */\n readonly absentTools?: ReadonlyArray<string>\n}\n\n/**\n * The contract every run is taught.\n *\n * It is the contract that replaced the filing one, and the difference is exactly\n * the difference in the surface: there is no returned object to describe, no\n * `state` to file, no manifest to read, and no `render`/`recall` to name,\n * because the variable is the memory and the print is the summary.\n *\n * Every rule with a trace behind it was carried across byte-similar when the\n * surface changed, and that was deliberate: the r91 rerun grew the old contract\n * from 8,197 to 11,312 characters and dropped resolved from 35/45 to 30/45 at\n * 59 % more cost, which says teaching changes are expensive and must be measured\n * one at a time. A wave that changed the realm *and* re-cut the doctrine could\n * not attribute its own result. Cutting further is its own arm, with its own\n * wave.\n *\n * The second worked example is the golf report's own prescription \u2014 its\n * class-(a) finding is that the contract's only worked example is a three-line\n * toy, and models imitate the example.\n *\n * It moved a second time on 2026-08-24, when checkpoints landed: the baseline\n * moved after the edit in the example and rule 9 names `ctx.base`. Both pinned\n * numbers moved with it.\n *\n * The completion teaching first moved after the first REPL wave, and the change\n * is stated rather than smuggled. What died is the see-then-attest rule\n * (\"complete only once you have SEEN that identical command pass\"): it asked for\n * a memory of a result and got one, and `sympy__sympy-13878` ended by claiming\n * in `output` that a suite \"exited 0 and printed its passing test summary\" one\n * frame after its own guarded `ctx.done` had declined to fire because that suite\n * exited 1. What replaces it is the shape the model had already written and\n * abandoned: complete behind a check of the result, `if (after.exitCode === 0)\n * ctx.done(...)`, so the verdict is read from the call rather than remembered\n * across a turn. An unguarded completion stays legal \u2014 sometimes nothing in the\n * image can be made to flip \u2014 and is named for what it is, a claim nobody\n * checked. That is will's ruling of 2026-08-23, and it is why the pinned length\n * in `test/CellPrompt.test.ts` moved.\n *\n * Task scoping moved on 2026-09-19 after a chat request to answer only A spent\n * twelve frames printing and then looking for an unrelated failing test.\n * The host already taught same-cell completion, but these rules required an\n * edit and a proving command unconditionally. The scoped contract completed\n * the retained natural-language opening in six of six probes, against four\n * of six for the old contract. A seeded six-print loop still did not recover\n * the exact answer; the unchanged read-only cap remains necessary. The edit,\n * baseline and tree-review requirements remain for requested workspace work.\n *\n * Rule 10 and rule 4's `jev` clause moved to the `cell-jev` section on\n * 2026-09-25 (#1929), so a run with no `jev` bound is not taught it.\n *\n * On 2026-09-30 will ruled for token economy: every rule stays, prose becomes\n * fragments, 9,715 \u2192 5,553 characters. No wave has measured this wording yet.\n *\n * Governing design: `../../docs/concepts.md#repl-realm`.\n */\nconst replContract = `JavaScript REPL, one cell per turn, alive for the whole run.\n\nEvery reply MUST contain a fenced \\`cell\\` block, JavaScript only. Several blocks in one reply run as ONE program.\n\nTop-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.\n\nExample bug fix, two cells. Names illustrative; call what \\`ctx.flows\\` lists.\n\n\\`\\`\\`cell\nconst found = await ctx.call(\"grep\", { pattern: \"return value\", root: \"src/units\", limit: 5 })\nconst hit = found.ok === false ? undefined : found.matches[0] // failed calls resolve, never throw\nconst region = await ctx.call(\"read\", { path: hit.file, offset: Math.max(1, hit.line - 20), limit: 40 })\nconsole.log(region.content)\n\\`\\`\\`\n\n\\`\\`\\`cell\nconst verification = { flow: \"bash\", input: { command: \"run-tests tests/test_widen.py::test_keeps_unit\" } }\nconst anchor = hit.text // text a call returned, never typed from memory\nconst applied = await ctx.call(\"edit\", { path: hit.file, oldString: anchor, newString: anchor.replace(\"return value\", \"return widen(value)\") })\nconst before = await ctx.call(verification.flow, verification.input, { at: ctx.base }) // opening tree; edit stays\nconst after = await ctx.call(verification.flow, verification.input)\nconsole.log(applied.ok === false ? applied.error.message : applied.hunk, before.exitCode, after.exitCode, after.stdout)\nif (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)\n\\`\\`\\`\n\nMany calls per cell; one call per frame wastes turns.\n\nRules:\n\n1. 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).\n2. Every effect is a flow: files, commands, memory, questions, subagents.\n3. 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).\n4. 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: \u226440 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.\n5. 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.\n6. Resume re-executes cells from the top; settled calls replay recorded results.\n7. 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.\n8. 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.\n9. 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.\n\nCell 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.`\n\n/**\n * How a cell uses the `jev` flow, taught only when the catalog binds it.\n *\n * It was rule 10 of the contract and a clause of rule 4 until 2026-09-25, when\n * will asked for Jev to be used strongly in the cells a model writes (#1929).\n * A rule that names a flow the catalog may not hold teaches a call that\n * resolves `unknown_flow`, so the teaching moved into a section of its own\n * that exists exactly when the flow does. It is constant for a run, so it sits\n * between the environment and the catalog without breaking the cached prefix.\n *\n * The floors are the owner's: act on a boolean at probability 0.8, and on a\n * choice or score at the provider's confidence 0.7. A choice's own\n * `.confidence` is the largest probability in its distribution and reads 1\n * when none was sent, so the teaching names the provider's number instead.\n *\n * The one worked example is run verbatim by `test/CellFlows.test.ts` against\n * the real `grep` and `jev` bindings, because a model copies the example.\n */\nconst jevText =\n `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.\n2. Never make one call per item; never ask \\`jev\\` for text, code or quotes.\n3. Failure resolves \\`{ ok: false }\\`: print \\`error.message\\`; do not decide in its place.\n4. 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.\n\n\\`\\`\\`cell\nconst found = await ctx.call(\"grep\", { pattern: \"timeout\", root: \"src\", limit: 200 })\nconst files = found.ok === false ? [] : [...new Set(found.matches.map((m) => m.file))]\nconst 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?\" }])) })\nconst p = (f) => judged.answers[f].probability\nconst kept = judged.ok === false ? [] : files.filter((f) => p(f) >= 0.8)\nconst uncertain = judged.ok === false ? [] : files.filter((f) => p(f) > 0.2 && p(f) < 0.8)\nconsole.log(found.ok === false ? found.error.message : judged.ok === false ? judged.error.message : { count: files.length, kept, uncertain })\n\\`\\`\\``\n\n/**\n * The one line a judged run is taught about its stance: the Monitor mood text,\n * verbatim, so the static stance and the delivered mood never disagree.\n */\nconst stanceText = (stance: typeof AgentEvent.Stance.Type): string =>\n stance === \"paranoid\" ? Monitor.paranoidText : Monitor.carefulText\n\nconst historyFact =\n `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>\\`.`\n\nconst environmentText = (environment: Environment): string => {\n const lines = [`- History: ${historyFact}`]\n if (environment.locale !== undefined) {\n lines.push(\n `- Locale: ${environment.locale}; output and files decode as that.`\n )\n }\n const absent = environment.absentTools === undefined ? [] : [...environment.absentTools].sort()\n if (absent.length > 0) {\n lines.push(\n `- Not installed: ${absent.join(\", \")}. Calls to them fail; use \\`ctx.flows\\`.`\n )\n }\n return `Harness-computed facts about the checkout and container, not the task.\\n${lines.join(\"\\n\")}`\n}\n\nconst digest = (id: Section[\"id\"], text: string): string => Digest.digest(CanonicalJson.stringify({ id, text }))\n\ntype CatalogProjection = Cell.FlowProjection & Partial<Pick<Descriptor.FlowDescriptor, \"provenance\" | \"path\">>\n\nconst catalogText = (flows: Readonly<Record<string, CatalogProjection>>): string => {\n const names = Object.keys(flows).sort()\n if (names.length === 0) {\n return \"No flows are callable in this run. Complete or park; ctx.call has nothing to reach.\"\n }\n const lines = names.map((name) => {\n const projection = flows[name]!\n const capabilities = projection.capabilities.length === 0\n ? \"\"\n : ` capabilities=${[...projection.capabilities].sort().join(\",\")}`\n const origin = JSON.stringify({\n source: projection.provenance?.source ?? \"unknown\",\n root: projection.provenance?.root,\n path: projection.path\n })\n const heading = `- ${name} (${projection.tier})${capabilities}: ${projection.description}\\n provenance: ${origin}`\n // The input schema is the difference between choosing a call and guessing\n // one. A rejected input costs a whole frame, so a catalog that names a\n // flow without saying what it takes spends the run's frame budget on\n // trial and error.\n return Option.isNone(projection.input)\n ? heading\n : `${heading}\\n input: ${JSON.stringify(projection.input.value)}`\n })\n return `Flows callable with ctx.call in this frame:\\n${\n untrustedData(lines.join(\"\\n\"), \"flow catalog (descriptor provenance follows)\")\n }`\n}\n\n/**\n * Builds the cell-contract teaching sections for one frame.\n *\n * The order is by how often each section changes, because every one of them is\n * a prefix segment and a prefix is only cached up to its first edit: the\n * contract is constant for the life of the binary, the environment and the\n * `jev` teaching for the life of a run, and the catalog can differ frame to\n * frame. The `jev` teaching is rendered only when `flows` binds `jev`.\n *\n * `stance` renders a one-line `cell-stance` section between the contract and\n * the environment. It is constant for the run, so the cached prefix holds;\n * with no stance nothing is rendered and the prompt is unchanged.\n *\n * `environment` carries what the host measured about the container. It is\n * optional because the epoch fact \u2014 a checkout has no future in it \u2014 holds\n * everywhere and is stated with or without a host that measures anything else.\n *\n * @category constructors\n * @since 0.1.0\n * @slop\n */\nexport const make = (\n flows: Readonly<Record<string, CatalogProjection>>,\n environment: Environment = {},\n stance?: typeof AgentEvent.Stance.Type\n): ReadonlyArray<Section> => {\n const facts = environmentText(environment)\n const catalog = catalogText(flows)\n const taught = replContract\n const stanced = stance === undefined ? undefined : stanceText(stance)\n return [\n { id: \"cell-contract\", text: taught, digest: digest(\"cell-contract\", taught) },\n ...(stanced === undefined\n ? []\n : [{ id: \"cell-stance\" as const, text: stanced, digest: digest(\"cell-stance\", stanced) }]),\n { id: \"cell-environment\", text: facts, digest: digest(\"cell-environment\", facts) },\n ...(flows.jev === undefined\n ? []\n : [{ id: \"cell-jev\" as const, text: jevText, digest: digest(\"cell-jev\", jevText) }]),\n { id: \"cell-catalog\", text: catalog, digest: digest(\"cell-catalog\", catalog) }\n ]\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA8DA,aAAwB;AACxB,oBAA+B;AAE/B,oBAAuB;AAGvB,cAAyB;AACzB,2BAA8B;AA4F9B,MAAM,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA2DrB,MAAM,UACJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmBF,MAAM,aAAa,CAAC,WAClB,WAAW,aAAa,QAAQ,eAAe,QAAQ;AAEzD,MAAM,cACJ;AAEF,MAAM,kBAAkB,CAAC,gBAAqC;AAC5D,QAAM,QAAQ,CAAC,cAAc,WAAW,EAAE;AAC1C,MAAI,YAAY,WAAW,QAAW;AACpC,UAAM;AAAA,MACJ,aAAa,YAAY,MAAM;AAAA,IACjC;AAAA,EACF;AACA,QAAM,SAAS,YAAY,gBAAgB,SAAY,CAAC,IAAI,CAAC,GAAG,YAAY,WAAW,EAAE,KAAK;AAC9F,MAAI,OAAO,SAAS,GAAG;AACrB,UAAM;AAAA,MACJ,oBAAoB,OAAO,KAAK,IAAI,CAAC;AAAA,IACvC;AAAA,EACF;AACA,SAAO;AAAA,EAA2E,MAAM,KAAK,IAAI,CAAC;AACpG;AAEA,MAAM,SAAS,CAAC,IAAmB,SAAyB,OAAO,OAAO,cAAc,UAAU,EAAE,IAAI,KAAK,CAAC,CAAC;AAI/G,MAAM,cAAc,CAAC,UAA+D;AAClF,QAAM,QAAQ,OAAO,KAAK,KAAK,EAAE,KAAK;AACtC,MAAI,MAAM,WAAW,GAAG;AACtB,WAAO;AAAA,EACT;AACA,QAAM,QAAQ,MAAM,IAAI,CAAC,SAAS;AAChC,UAAM,aAAa,MAAM,IAAI;AAC7B,UAAM,eAAe,WAAW,aAAa,WAAW,IACpD,KACA,iBAAiB,CAAC,GAAG,WAAW,YAAY,EAAE,KAAK,EAAE,KAAK,GAAG,CAAC;AAClE,UAAM,SAAS,KAAK,UAAU;AAAA,MAC5B,QAAQ,WAAW,YAAY,UAAU;AAAA,MACzC,MAAM,WAAW,YAAY;AAAA,MAC7B,MAAM,WAAW;AAAA,IACnB,CAAC;AACD,UAAM,UAAU,KAAK,IAAI,KAAK,WAAW,IAAI,IAAI,YAAY,KAAK,WAAW,WAAW;AAAA,gBAAmB,MAAM;AAKjH,WAAO,qBAAO,OAAO,WAAW,KAAK,IACjC,UACA,GAAG,OAAO;AAAA,WAAc,KAAK,UAAU,WAAW,MAAM,KAAK,CAAC;AAAA,EACpE,CAAC;AACD,SAAO;AAAA,MACL,oCAAc,MAAM,KAAK,IAAI,GAAG,8CAA8C,CAChF;AACF;AAuBO,MAAM,OAAO,CAClB,OACA,cAA2B,CAAC,GAC5B,WAC2B;AAC3B,QAAM,QAAQ,gBAAgB,WAAW;AACzC,QAAM,UAAU,YAAY,KAAK;AACjC,QAAM,SAAS;AACf,QAAM,UAAU,WAAW,SAAY,SAAY,WAAW,MAAM;AACpE,SAAO;AAAA,IACL,EAAE,IAAI,iBAAiB,MAAM,QAAQ,QAAQ,OAAO,iBAAiB,MAAM,EAAE;AAAA,IAC7E,GAAI,YAAY,SACZ,CAAC,IACD,CAAC,EAAE,IAAI,eAAwB,MAAM,SAAS,QAAQ,OAAO,eAAe,OAAO,EAAE,CAAC;AAAA,IAC1F,EAAE,IAAI,oBAAoB,MAAM,OAAO,QAAQ,OAAO,oBAAoB,KAAK,EAAE;AAAA,IACjF,GAAI,MAAM,QAAQ,SACd,CAAC,IACD,CAAC,EAAE,IAAI,YAAqB,MAAM,SAAS,QAAQ,OAAO,YAAY,OAAO,EAAE,CAAC;AAAA,IACpF,EAAE,IAAI,gBAAgB,MAAM,SAAS,QAAQ,OAAO,gBAAgB,OAAO,EAAE;AAAA,EAC/E;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,44 @@
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
+ import type * as ContextWindow from "../ContextWindow.ts";
14
+ /**
15
+ * The tokens the compaction trigger leaves free below the context window.
16
+ *
17
+ * @since 1.0.0-rc.0
18
+ * @private
19
+ */
20
+ export declare const defaultReserve = 16000;
21
+ /**
22
+ * The tokens of recent segments a compaction keeps whole.
23
+ *
24
+ * @since 1.0.0-rc.0
25
+ * @private
26
+ */
27
+ export declare const defaultKeepRecent = 20000;
28
+ /**
29
+ * The transcript, summary and steering segments of a window, in order.
30
+ *
31
+ * @since 1.0.0-rc.0
32
+ * @private
33
+ */
34
+ export declare const compactable: (segments: ReadonlyArray<ContextWindow.Segment>) => ReadonlyArray<ContextWindow.Segment>;
35
+ /**
36
+ * The boundaries a cut may not fall on: every boundary between a tool call
37
+ * and its result, when the two sit in different segments of `segments`.
38
+ * Boundary `b` lies between `segments[b - 1]` and `segments[b]`.
39
+ *
40
+ * @since 1.0.0-rc.0
41
+ * @private
42
+ */
43
+ export declare const pairBoundaries: (segments: ReadonlyArray<ContextWindow.Segment>) => ReadonlySet<number>;
44
+ //# sourceMappingURL=compactable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compactable.d.ts","sourceRoot":"","sources":["../../../src/internal/compactable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,KAAK,aAAa,MAAM,qBAAqB,CAAA;AAEzD;;;;;GAKG;AACH,eAAO,MAAM,cAAc,QAAS,CAAA;AAEpC;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,QAAS,CAAA;AAEvC;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GACtB,UAAU,aAAa,CAAC,aAAa,CAAC,OAAO,CAAC,KAC7C,aAAa,CAAC,aAAa,CAAC,OAAO,CAGnC,CAAA;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,GAAI,UAAU,aAAa,CAAC,aAAa,CAAC,OAAO,CAAC,KAAG,WAAW,CAAC,MAAM,CAuBjG,CAAA"}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var compactable_exports = {};
20
+ __export(compactable_exports, {
21
+ compactable: () => compactable,
22
+ defaultKeepRecent: () => defaultKeepRecent,
23
+ defaultReserve: () => defaultReserve,
24
+ pairBoundaries: () => pairBoundaries
25
+ });
26
+ module.exports = __toCommonJS(compactable_exports);
27
+ const defaultReserve = 16e3;
28
+ const defaultKeepRecent = 2e4;
29
+ const compactable = (segments) => segments.filter(
30
+ (segment) => segment.kind === "transcript" || segment.kind === "summary" || segment.kind === "steering"
31
+ );
32
+ const pairBoundaries = (segments) => {
33
+ const calls = /* @__PURE__ */ new Map();
34
+ const results = /* @__PURE__ */ new Map();
35
+ for (const [index, segment] of segments.entries()) {
36
+ for (const item of segment.content) {
37
+ if ("role" in item && item.role === "assistant") {
38
+ for (const part of item.content) {
39
+ if (part.type === "tool-call") calls.set(part.id, index);
40
+ }
41
+ } else if ("role" in item && item.role === "tool") {
42
+ for (const part of item.content) results.set(part.toolCallId, index);
43
+ }
44
+ }
45
+ }
46
+ const unsafe = /* @__PURE__ */ new Set();
47
+ for (const [callId, callIndex] of calls) {
48
+ const resultIndex = results.get(callId);
49
+ if (resultIndex === void 0) continue;
50
+ const first = Math.min(callIndex, resultIndex);
51
+ const last = Math.max(callIndex, resultIndex);
52
+ for (let boundary = first + 1; boundary <= last; boundary++) unsafe.add(boundary);
53
+ }
54
+ return unsafe;
55
+ };
56
+ //# sourceMappingURL=compactable.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/internal/compactable.ts"],
4
+ "sourcesContent": ["/**\n * The segments a compaction may replace.\n *\n * A window's system and instruction segments are what the next turn is still\n * addressed to, so only the conversational kinds are eligible. `ContextWindow`\n * selects the prefix and `Compaction` declares one against the same selection;\n * two spellings of this filter that drifted would let a declared prefix name\n * segments the window would never replace.\n *\n * @since 1.0.0-rc.0\n * @private\n */\n\nimport type * as ContextWindow from \"../ContextWindow.ts\"\n\n/**\n * The tokens the compaction trigger leaves free below the context window.\n *\n * @since 1.0.0-rc.0\n * @private\n */\nexport const defaultReserve = 16_000\n\n/**\n * The tokens of recent segments a compaction keeps whole.\n *\n * @since 1.0.0-rc.0\n * @private\n */\nexport const defaultKeepRecent = 20_000\n\n/**\n * The transcript, summary and steering segments of a window, in order.\n *\n * @since 1.0.0-rc.0\n * @private\n */\nexport const compactable = (\n segments: ReadonlyArray<ContextWindow.Segment>\n): ReadonlyArray<ContextWindow.Segment> =>\n segments.filter((segment) =>\n segment.kind === \"transcript\" || segment.kind === \"summary\" || segment.kind === \"steering\"\n )\n\n/**\n * The boundaries a cut may not fall on: every boundary between a tool call\n * and its result, when the two sit in different segments of `segments`.\n * Boundary `b` lies between `segments[b - 1]` and `segments[b]`.\n *\n * @since 1.0.0-rc.0\n * @private\n */\nexport const pairBoundaries = (segments: ReadonlyArray<ContextWindow.Segment>): ReadonlySet<number> => {\n const calls = new Map<string, number>()\n const results = new Map<string, number>()\n for (const [index, segment] of segments.entries()) {\n for (const item of segment.content) {\n if (\"role\" in item && item.role === \"assistant\") {\n for (const part of item.content) {\n if (part.type === \"tool-call\") calls.set(part.id, index)\n }\n } else if (\"role\" in item && item.role === \"tool\") {\n for (const part of item.content) results.set(part.toolCallId, index)\n }\n }\n }\n const unsafe = new Set<number>()\n for (const [callId, callIndex] of calls) {\n const resultIndex = results.get(callId)\n if (resultIndex === undefined) continue\n const first = Math.min(callIndex, resultIndex)\n const last = Math.max(callIndex, resultIndex)\n for (let boundary = first + 1; boundary <= last; boundary++) unsafe.add(boundary)\n }\n return unsafe\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqBO,MAAM,iBAAiB;AAQvB,MAAM,oBAAoB;AAQ1B,MAAM,cAAc,CACzB,aAEA,SAAS;AAAA,EAAO,CAAC,YACf,QAAQ,SAAS,gBAAgB,QAAQ,SAAS,aAAa,QAAQ,SAAS;AAClF;AAUK,MAAM,iBAAiB,CAAC,aAAwE;AACrG,QAAM,QAAQ,oBAAI,IAAoB;AACtC,QAAM,UAAU,oBAAI,IAAoB;AACxC,aAAW,CAAC,OAAO,OAAO,KAAK,SAAS,QAAQ,GAAG;AACjD,eAAW,QAAQ,QAAQ,SAAS;AAClC,UAAI,UAAU,QAAQ,KAAK,SAAS,aAAa;AAC/C,mBAAW,QAAQ,KAAK,SAAS;AAC/B,cAAI,KAAK,SAAS,YAAa,OAAM,IAAI,KAAK,IAAI,KAAK;AAAA,QACzD;AAAA,MACF,WAAW,UAAU,QAAQ,KAAK,SAAS,QAAQ;AACjD,mBAAW,QAAQ,KAAK,QAAS,SAAQ,IAAI,KAAK,YAAY,KAAK;AAAA,MACrE;AAAA,IACF;AAAA,EACF;AACA,QAAM,SAAS,oBAAI,IAAY;AAC/B,aAAW,CAAC,QAAQ,SAAS,KAAK,OAAO;AACvC,UAAM,cAAc,QAAQ,IAAI,MAAM;AACtC,QAAI,gBAAgB,OAAW;AAC/B,UAAM,QAAQ,KAAK,IAAI,WAAW,WAAW;AAC7C,UAAM,OAAO,KAAK,IAAI,WAAW,WAAW;AAC5C,aAAS,WAAW,QAAQ,GAAG,YAAY,MAAM,WAAY,QAAO,IAAI,QAAQ;AAAA,EAClF;AACA,SAAO;AACT;",
6
+ "names": []
7
+ }