@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,376 @@
1
+ /**
2
+ * The print channel: how a REPL frame's `console.log` calls become the bytes
3
+ * its successor reads.
4
+ *
5
+ * Two jobs live here, and both were priced off the `rerun-r95repl` lane rather
6
+ * than chosen.
7
+ *
8
+ * Every number here is a count of UTF-8 bytes, which is what the frame bound
9
+ * and the retention ceiling both mean by "bytes": the notices this module writes
10
+ * carry a `…`, three bytes wide and one UTF-16 unit, and counting them in units
11
+ * put a frame one byte over its own ceiling.
12
+ *
13
+ * **Sharing the frame budget.** Statements used to cap independently at 4 KiB
14
+ * each, head-first, under a 16 KiB frame bound that almost nobody reached: 197
15
+ * of the lane's 357 printing frames had a statement cut, 191 of those while the
16
+ * frame bound sat mostly unspent, and 3.06 MB went to per-statement caps against
17
+ * 6 frames that ever reached the frame one. Head-first is the part that cost
18
+ * verdicts — `sympy__sympy-13878` fused one `console.log` of 38,928 bytes whose
19
+ * head was a Python deprecation banner, so what it lost was the tail: the result
20
+ * of a three-minute test suite the same frame had just paid for, and the `git
21
+ * diff` that would have shown it the edit was already in the tree. It re-ran
22
+ * that suite four frames later. So the statements of a frame share one budget,
23
+ * each is elided from the middle, and no ceiling moves: 16 KiB was the most a
24
+ * frame could deliver before and it is the most now.
25
+ *
26
+ * **Compacting a printed structure.** A result printed whole is mostly repeated
27
+ * keys — a grep hit names `file`, `line`, `text` once per match — so an array of
28
+ * matches renders as file groups with numbered hits and context; other records
29
+ * render as a table with the union of keys named once. It is keyed on the shape
30
+ * and nothing else — this module knows no flow. Repeated keys save bytes;
31
+ * sparse records with mostly distinct keys can cost more as a table.
32
+ *
33
+ * @since 0.1.0
34
+ * @private
35
+ * @slop
36
+ */
37
+ import { isRecord } from "@smthrs/canonical/Record";
38
+ import * as CanonicalJson from "@smthrs/model/CanonicalJson";
39
+ import * as bytes from "./bytes.js";
40
+ import * as elide from "./elide.js";
41
+ /**
42
+ * How many UTF-8 bytes of one frame's whole print buffer reach the next model turn.
43
+ *
44
+ * This is the only ceiling on the channel. A frame's statements *share* it:
45
+ * each is middle-elided to the share it is apportioned, and a statement short
46
+ * of its share hands the remainder back to the statements that are over theirs.
47
+ *
48
+ * They used to cap independently at 4 KiB each, head-first, and the r95repl
49
+ * lane priced that: 197 of its 357 printing frames had a statement cut, 191 of
50
+ * them while this frame budget sat mostly unspent, and 3.06 MB went to
51
+ * per-statement caps against 6 frames that ever reached this one. The
52
+ * `sympy__sympy-13878` run fused one `console.log` of 38,928 bytes; it was
53
+ * shown the first 4,096 and lost the tail, which held the result of a
54
+ * three-minute test suite the frame had already paid for. It ran that suite
55
+ * again four frames later. Sharing the budget shows that frame 16 KiB from both
56
+ * ends instead of 4 KiB from the head, and moves no ceiling: 16 KiB was the
57
+ * most a frame could ever deliver before, and it is the most now.
58
+ *
59
+ * Every elision is from the middle with the dropped byte count stated, because
60
+ * the head and the tail of a log are where it identifies itself, and the notices
61
+ * are reserved out of this budget before any of it is apportioned — so the
62
+ * assembled buffer is bounded outright and nothing has to shorten it a second
63
+ * time. Sized against the `recall` budget it replaces, and delivered once rather
64
+ * than re-rendered every frame.
65
+ *
66
+ * @category constants
67
+ * @since 0.1.0
68
+ */
69
+ export const printFrameBytes = 16 * 1024;
70
+ /**
71
+ * The smallest UTF-8-byte share of {@link printFrameBytes} one print statement is given.
72
+ *
73
+ * A share below this is all notice and no value — a middle elision of 80 bytes
74
+ * says less than the sentence explaining it — so a frame that printed more
75
+ * statements than the budget can floor drops whole statements from the middle
76
+ * and states how many, rather than cutting every one of them to nothing. That
77
+ * is the same shape the frame bound already had, applied a statement at a time
78
+ * so nothing is cut mid-line.
79
+ *
80
+ * It bounds how many statements are *kept*, but it is not a division of the
81
+ * budget: how many a frame can carry is priced off the statements it actually
82
+ * printed, so a statement at or under this size is shown whole and costs only
83
+ * itself. Two hundred eight-byte lines cost eighteen hundred bytes and all two
84
+ * hundred survive; sixty statements of four times this size do not, and whole
85
+ * ones go from the middle rather than every one of them being cut to a notice.
86
+ *
87
+ * @category constants
88
+ * @since 0.1.0
89
+ * @slop
90
+ */
91
+ export const printStatementFloor = 512;
92
+ /**
93
+ * How many UTF-8 bytes of one frame's print buffer the host keeps while the cell still runs.
94
+ *
95
+ * {@link printFrameBytes} bounds what the model is shown; this bounds what the
96
+ * host holds to show it from, and the two are different numbers because they
97
+ * answer different questions. A cell printing in a loop hands the host one
98
+ * payload per statement, and every payload is copied out of the sandbox's heap
99
+ * and decoded before anything can judge it surplus, so the frame budget alone
100
+ * bounds the answer while leaving the work unbounded. Sixteen times the frame
101
+ * budget is far past any honest use and still a fixed ceiling: past it the
102
+ * payload is not read at all, and the count of what went unread is stated in the
103
+ * buffer rather than dropped in silence.
104
+ *
105
+ * A statement is held at no more than {@link printFrameBytes} — the two ends of
106
+ * it, with the size it had — because a whole frame's budget is the most any one
107
+ * statement could ever be shown. So this ceiling holds at least sixteen
108
+ * statements whatever a cell prints, and a cell that prints many small values
109
+ * reaches it only after hundreds of them.
110
+ *
111
+ * @category constants
112
+ * @since 0.1.0
113
+ */
114
+ export const printRetainedBytes = 256 * 1024;
115
+ /**
116
+ * The fewest records an array needs before it is rendered as a table.
117
+ *
118
+ * Two rows do not repay a header line, and one row is not a table at all.
119
+ *
120
+ * @since 0.1.0
121
+ * @private
122
+ * @slop
123
+ */
124
+ export const tableRows = 3;
125
+ /**
126
+ * What the model is told when a print was cut: the value is still bound.
127
+ *
128
+ * @since 0.1.0
129
+ * @private
130
+ * @slop
131
+ */
132
+ export const recall = "print a narrower slice of this value; it is still bound in the realm";
133
+ const cell = (value) => typeof value === "string" && !value.includes("\n") && !value.includes("|")
134
+ ? value
135
+ : CanonicalJson.stringify(value);
136
+ const isMatchLine = (value) => isRecord(value) && Object.keys(value).length === 2 &&
137
+ Number.isInteger(value.line) && typeof value.text === "string";
138
+ const isMatchSymbol = (value) => isRecord(value) && Object.keys(value).length === 4 &&
139
+ typeof value.kind === "string" && typeof value.name === "string" &&
140
+ Number.isInteger(value.startLine) && Number.isInteger(value.endLine);
141
+ const isMatch = (value) => isRecord(value) &&
142
+ typeof value.file === "string" && Number.isInteger(value.line) && typeof value.text === "string" &&
143
+ Object.keys(value).every((key) => ["file", "line", "text", "before", "after", "symbol"].includes(key)) &&
144
+ (!Object.hasOwn(value, "before") || Array.isArray(value.before) && value.before.every(isMatchLine)) &&
145
+ (!Object.hasOwn(value, "after") || Array.isArray(value.after) && value.after.every(isMatchLine)) &&
146
+ (!Object.hasOwn(value, "symbol") || isMatchSymbol(value.symbol));
147
+ /** Renders nonempty match lists in consecutive file groups, using rg's line markers. */
148
+ const matchList = (value) => {
149
+ if (!Array.isArray(value) || value.length === 0 || !value.every(isMatch))
150
+ return undefined;
151
+ const lines = [];
152
+ let previousFile;
153
+ let previousLine = 0;
154
+ for (const match of value) {
155
+ const before = match.before ?? [];
156
+ const after = match.after ?? [];
157
+ if (match.file !== previousFile)
158
+ lines.push(match.file);
159
+ else if ((before[0]?.line ?? match.line) > previousLine + 1)
160
+ lines.push("--");
161
+ for (const context of before)
162
+ lines.push(`${context.line}-${context.text}`);
163
+ const symbol = match.symbol;
164
+ const suffix = symbol === undefined ? "" : ` ‹${symbol.kind} ${symbol.name} ${symbol.startLine}-${symbol.endLine}›`;
165
+ lines.push(`${match.line}:${match.text}${suffix}`);
166
+ for (const context of after)
167
+ lines.push(`${context.line}-${context.text}`);
168
+ previousFile = match.file;
169
+ previousLine = after.at(-1)?.line ?? match.line;
170
+ }
171
+ return lines.join("\n");
172
+ };
173
+ /**
174
+ * Renders an array of records as a table, or nothing.
175
+ *
176
+ * Columns are the union of keys in first-seen order. An absent member is an
177
+ * empty cell; explicit null, empty arrays and empty objects stay `null`, `[]`
178
+ * and `{}`. Cells are the string itself where that is unambiguous — no newline,
179
+ * no column separator — and canonical JSON everywhere else. An empty string
180
+ * still looks absent, and a string spelling a JSON literal still looks like
181
+ * that value: this is a log rather than a wire format, so it is not paid for in
182
+ * quoting every cell.
183
+ *
184
+ * @since 0.1.0
185
+ * @private
186
+ * @slop
187
+ */
188
+ export const table = (value) => {
189
+ if (!Array.isArray(value) || value.length < tableRows)
190
+ return undefined;
191
+ if (!value.every((isRecord)))
192
+ return undefined;
193
+ const columns = [...new Set(value.flatMap((element) => Object.keys(element)))];
194
+ if (columns.length < 2)
195
+ return undefined;
196
+ const rows = value.map((element) => columns.map((column) => Object.hasOwn(element, column) ? cell(element[column]) : "").join(" | "));
197
+ return `${columns.join(" | ")}\n${rows.join("\n")}`;
198
+ };
199
+ /**
200
+ * Renders one printed JSON value compactly.
201
+ *
202
+ * A match list becomes numbered source lines; other records become a table.
203
+ * An object with exactly one such member becomes that object's other members
204
+ * as JSON, then the member's name, count and rendered list. An exact failed-call
205
+ * envelope becomes its code, message and optional hint. Everything else is
206
+ * canonical JSON as before.
207
+ *
208
+ * Tables save repeated keys but pay for every column boundary, including
209
+ * absent members. The three-row, two-column floor saves bytes for uniform
210
+ * records; it does not guarantee savings for sparse records. Rendering stays
211
+ * shape-based rather than comparing both encodings.
212
+ *
213
+ * @since 0.1.0
214
+ * @private
215
+ * @slop
216
+ */
217
+ export const render = (value) => {
218
+ // A string is itself, which is what `Cell.renderText` promises everywhere
219
+ // else the harness renders a projected value. The prelude sends a primitive
220
+ // string down the `text` side, so this arm answers only for a boxed one.
221
+ if (typeof value === "string")
222
+ return value;
223
+ const flat = matchList(value) ?? table(value);
224
+ if (flat !== undefined)
225
+ return flat;
226
+ if (!isRecord(value))
227
+ return CanonicalJson.stringify(value);
228
+ const error = value.error;
229
+ if (Object.keys(value).length === 2 && value.ok === false &&
230
+ isRecord(error) &&
231
+ typeof error.code === "string" && typeof error.message === "string" &&
232
+ Object.keys(error).every((key) => key === "code" || key === "message" || key === "hint") &&
233
+ (!Object.hasOwn(error, "hint") || typeof error.hint === "string")) {
234
+ return `failed (${error.code}): ${error.message}${Object.hasOwn(error, "hint") ? ` — hint: ${error.hint}` : ""}`;
235
+ }
236
+ const tabled = Object.entries(value).flatMap(([key, member]) => {
237
+ const rendered = matchList(member) ?? table(member);
238
+ return rendered === undefined ? [] : [[key, member, rendered]];
239
+ });
240
+ if (tabled.length !== 1)
241
+ return CanonicalJson.stringify(value);
242
+ const [key, member, rendered] = tabled[0];
243
+ const rest = Object.fromEntries(Object.entries(value).filter(([name]) => name !== key));
244
+ return `${Object.keys(rest).length === 0 ? "" : `${CanonicalJson.stringify(rest)}\n`}${key} (${member.length}):\n${rendered}`;
245
+ };
246
+ /**
247
+ * Apportions one budget across statements of the given sizes.
248
+ *
249
+ * Short statements take what they need and hand the remainder back, so a frame
250
+ * that printed one long value and three short ones spends the budget on the long
251
+ * one. Allocation runs shortest first, which is what makes the hand-back
252
+ * possible, and the result is in the order the sizes were given.
253
+ *
254
+ * @since 0.1.0
255
+ * @private
256
+ * @slop
257
+ */
258
+ export const shares = (sizes, budget) => {
259
+ const order = sizes.map((size, index) => ({ size, index })).sort((left, right) => left.size === right.size ? left.index - right.index : left.size - right.size);
260
+ const allotted = new Array(sizes.length).fill(0);
261
+ let remaining = budget;
262
+ let left = sizes.length;
263
+ for (const { index, size } of order) {
264
+ const fair = Math.floor(remaining / left);
265
+ const given = Math.min(size, fair);
266
+ allotted[index] = given;
267
+ remaining = remaining - given;
268
+ left = left - 1;
269
+ }
270
+ return allotted;
271
+ };
272
+ /** The line a frame writes about the statements it dropped whole. */
273
+ const droppedNotice = (count) => `… ${count} print statements elided from the middle of this frame; the values are still bound in the realm.`;
274
+ /** The line a frame writes about the statements the host never copied out. */
275
+ const unreadNotice = (count) => `… ${count} further print statements were not kept: this frame printed more than the harness holds.`;
276
+ /**
277
+ * What keeping one statement costs the budget: its floor, its notice, its newline.
278
+ *
279
+ * A statement at or under {@link printStatementFloor} costs only itself
280
+ * and no notice, because {@link buffer} shows it whole and a whole statement has
281
+ * nothing to say about what it lost. One over the floor is promised the floor,
282
+ * and the notice that shortening it prints is charged with it.
283
+ */
284
+ const price = (statement) => Math.min(statement.bytes, printStatementFloor) +
285
+ (statement.bytes > printStatementFloor ? elide.noticeCost(statement.bytes, recall) : 0) + 1;
286
+ /**
287
+ * How many of *these* statements a budget can keep at the floor, head first.
288
+ *
289
+ * A count of the statements in hand rather than a constant, because what a
290
+ * statement costs is what it is. Taken as `printFrameBytes / printStatementFloor`
291
+ * it was 32 whatever a frame printed, so a frame of two hundred eight-byte lines
292
+ * dropped a hundred and sixty-eight of them while fifteen of its sixteen
293
+ * kilobytes went unspent — the failure the shared budget exists to end,
294
+ * reintroduced one level up. Two hundred lines that cost nine bytes each cost
295
+ * eighteen hundred, and the budget keeps every one of them.
296
+ *
297
+ * The walk takes the head, then the tail, then the head again, which is the
298
+ * order {@link buffer} assembles them in, so a budget that affords an odd number
299
+ * spends the odd one on the earlier statement.
300
+ *
301
+ * @since 0.1.0
302
+ * @private
303
+ * @slop
304
+ */
305
+ export const capacity = (statements, budget) => {
306
+ let left = budget;
307
+ let kept = 0;
308
+ while (kept < statements.length) {
309
+ const statement = kept % 2 === 0 ? statements[kept / 2] : statements[statements.length - 1 - (kept - 1) / 2];
310
+ const cost = price(statement);
311
+ if (cost > left)
312
+ break;
313
+ left = left - cost;
314
+ kept = kept + 1;
315
+ }
316
+ return kept;
317
+ };
318
+ /**
319
+ * Assembles what a frame printed, bounded by {@link printFrameBytes}.
320
+ *
321
+ * `unread` is the count of statements the host stopped copying out of the realm
322
+ * because the frame had already handed over more than it holds. It is stated
323
+ * rather than dropped, because a buffer that simply stopped reads as a cell that
324
+ * simply stopped printing.
325
+ *
326
+ * The bound holds by construction rather than by a second pass over the result,
327
+ * because a second pass would cut a notice in half and that is the one thing a
328
+ * bound may not do. {@link capacity} charges every kept statement the floor it is
329
+ * promised, the notice it would print and its newline; what survives that walk is
330
+ * therefore affordable, and the apportionment below spends only what the walk
331
+ * left. A statement at or under the floor is shown whole and reserves no notice
332
+ * at all — reserving one apiece is what left a frame of short lines nothing to
333
+ * spend on the lines themselves.
334
+ *
335
+ * @since 0.1.0
336
+ * @private
337
+ * @slop
338
+ */
339
+ export const buffer = (statements, unread) => {
340
+ if (statements.length === 0 && unread === 0)
341
+ return "";
342
+ // The count-lines come out of the budget before the statements are counted,
343
+ // and the drop line only where there is a drop — so it is priced by asking
344
+ // twice, rather than by charging every frame for a line most never print.
345
+ const overhead = unread === 0 ? 0 : bytes.size(unreadNotice(unread)) + 1;
346
+ const roomy = capacity(statements, printFrameBytes - overhead);
347
+ const affordable = roomy === statements.length
348
+ ? roomy
349
+ : capacity(statements, printFrameBytes - overhead - bytes.size(droppedNotice(statements.length)) - 1);
350
+ // More statements than the budget can floor: whole statements go from the
351
+ // middle, counted, rather than every one of them being cut to a notice.
352
+ const head = Math.ceil(affordable / 2);
353
+ const kept = statements.length === affordable
354
+ ? statements
355
+ : [...statements.slice(0, head), ...statements.slice(statements.length - Math.floor(affordable / 2))];
356
+ const dropped = statements.length - kept.length;
357
+ const notices = [
358
+ ...(dropped === 0 ? [] : [droppedNotice(dropped)]),
359
+ ...(unread === 0 ? [] : [unreadNotice(unread)])
360
+ ];
361
+ // What the budget cannot spend on values: the count-lines, the newline between
362
+ // every pair, and one elision notice for each statement the floor does not
363
+ // cover whole.
364
+ const sizes = kept.map((statement) => statement.bytes);
365
+ const reserve = kept.reduce((sum, statement) => sum + (statement.bytes > printStatementFloor ? elide.noticeCost(statement.bytes, recall) : 0), 0) +
366
+ notices.reduce((sum, line) => sum + bytes.size(line), 0) +
367
+ Math.max(0, kept.length + notices.length - 1);
368
+ const allotted = shares(sizes, Math.max(0, printFrameBytes - reserve));
369
+ const lines = kept.map((statement, index) => elide.middleFrom(statement.text, statement.bytes, allotted[index], recall));
370
+ return [
371
+ ...lines.slice(0, dropped === 0 ? lines.length : head),
372
+ ...(dropped === 0 ? [] : [notices[0], ...lines.slice(head)]),
373
+ ...(unread === 0 ? [] : [notices[notices.length - 1]])
374
+ ].join("\n");
375
+ };
376
+ //# sourceMappingURL=printChannel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"printChannel.js","sourceRoot":"","sources":["../../../src/internal/printChannel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AACnD,OAAO,KAAK,aAAa,MAAM,6BAA6B,CAAA;AAE5D,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AAEnC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,GAAG,IAAI,CAAA;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,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACxD,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IAC/C,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,CAAC,CAAA;IACtE,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE,CAC1C,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAE,EAAE,MAAM,CAAC,CAC5E,CAAA;IACD,OAAO;QACL,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;QACtD,GAAG,CAAC,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAE,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;QAC7D,GAAG,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAE,CAAC,CAAC;KACxD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACd,CAAC,CAAA","sourcesContent":["/**\n * The print channel: how a REPL frame's `console.log` calls become the bytes\n * its successor reads.\n *\n * Two jobs live here, and both were priced off the `rerun-r95repl` lane rather\n * than chosen.\n *\n * Every number here is a count of UTF-8 bytes, which is what the frame bound\n * and the retention ceiling both mean by \"bytes\": the notices this module writes\n * carry a `…`, three bytes wide and one UTF-16 unit, and counting them in units\n * put a frame one byte over its own ceiling.\n *\n * **Sharing the frame budget.** Statements used to cap independently at 4 KiB\n * each, head-first, under a 16 KiB frame bound that almost nobody reached: 197\n * of the lane's 357 printing frames had a statement cut, 191 of those while the\n * frame bound sat mostly unspent, and 3.06 MB went to per-statement caps against\n * 6 frames that ever reached the frame one. Head-first is the part that cost\n * verdicts — `sympy__sympy-13878` fused one `console.log` of 38,928 bytes whose\n * head was a Python deprecation banner, so what it lost was the tail: the result\n * of a three-minute test suite the same frame had just paid for, and the `git\n * diff` that would have shown it the edit was already in the tree. It re-ran\n * that suite four frames later. So the statements of a frame share one budget,\n * each is elided from the middle, and no ceiling moves: 16 KiB was the most a\n * frame could deliver before and it is the most now.\n *\n * **Compacting a printed structure.** A result printed whole is mostly repeated\n * keys — a grep hit names `file`, `line`, `text` once per match — so an array of\n * matches renders as file groups with numbered hits and context; other records\n * render as a table with the union of keys named once. It is keyed on the shape\n * and nothing else — this module knows no flow. Repeated keys save bytes;\n * sparse records with mostly distinct keys can cost more as a table.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\n\nimport { isRecord } from \"@smthrs/canonical/Record\"\nimport * as CanonicalJson from \"@smthrs/model/CanonicalJson\"\nimport type { Schema } from \"effect\"\nimport * as bytes from \"./bytes.ts\"\nimport * as elide from \"./elide.ts\"\n\n/**\n * How many UTF-8 bytes of one frame's whole print buffer reach the next model turn.\n *\n * This is the only ceiling on the channel. A frame's statements *share* it:\n * each is middle-elided to the share it is apportioned, and a statement short\n * of its share hands the remainder back to the statements that are over theirs.\n *\n * They used to cap independently at 4 KiB each, head-first, and the r95repl\n * lane priced that: 197 of its 357 printing frames had a statement cut, 191 of\n * them while this frame budget sat mostly unspent, and 3.06 MB went to\n * per-statement caps against 6 frames that ever reached this one. The\n * `sympy__sympy-13878` run fused one `console.log` of 38,928 bytes; it was\n * shown the first 4,096 and lost the tail, which held the result of a\n * three-minute test suite the frame had already paid for. It ran that suite\n * again four frames later. Sharing the budget shows that frame 16 KiB from both\n * ends instead of 4 KiB from the head, and moves no ceiling: 16 KiB was the\n * most a frame could ever deliver before, and it is the most now.\n *\n * Every elision is from the middle with the dropped byte count stated, because\n * the head and the tail of a log are where it identifies itself, and the notices\n * are reserved out of this budget before any of it is apportioned — so the\n * assembled buffer is bounded outright and nothing has to shorten it a second\n * time. Sized against the `recall` budget it replaces, and delivered once rather\n * than re-rendered every frame.\n *\n * @category constants\n * @since 0.1.0\n */\nexport const printFrameBytes = 16 * 1024\n\n/**\n * The smallest UTF-8-byte share of {@link printFrameBytes} one print statement is given.\n *\n * A share below this is all notice and no value — a middle elision of 80 bytes\n * says less than the sentence explaining it — so a frame that printed more\n * statements than the budget can floor drops whole statements from the middle\n * and states how many, rather than cutting every one of them to nothing. That\n * is the same shape the frame bound already had, applied a statement at a time\n * so nothing is cut mid-line.\n *\n * It bounds how many statements are *kept*, but it is not a division of the\n * budget: how many a frame can carry is priced off the statements it actually\n * printed, so a statement at or under this size is shown whole and costs only\n * itself. Two hundred eight-byte lines cost eighteen hundred bytes and all two\n * hundred survive; sixty statements of four times this size do not, and whole\n * ones go from the middle rather than every one of them being cut to a notice.\n *\n * @category constants\n * @since 0.1.0\n * @slop\n */\nexport const printStatementFloor = 512\n\n/**\n * How many UTF-8 bytes of one frame's print buffer the host keeps while the cell still runs.\n *\n * {@link printFrameBytes} bounds what the model is shown; this bounds what the\n * host holds to show it from, and the two are different numbers because they\n * answer different questions. A cell printing in a loop hands the host one\n * payload per statement, and every payload is copied out of the sandbox's heap\n * and decoded before anything can judge it surplus, so the frame budget alone\n * bounds the answer while leaving the work unbounded. Sixteen times the frame\n * budget is far past any honest use and still a fixed ceiling: past it the\n * payload is not read at all, and the count of what went unread is stated in the\n * buffer rather than dropped in silence.\n *\n * A statement is held at no more than {@link printFrameBytes} — the two ends of\n * it, with the size it had — because a whole frame's budget is the most any one\n * statement could ever be shown. So this ceiling holds at least sixteen\n * statements whatever a cell prints, and a cell that prints many small values\n * reaches it only after hundreds of them.\n *\n * @category constants\n * @since 0.1.0\n */\nexport const printRetainedBytes = 256 * 1024\n\n/**\n * The fewest records an array needs before it is rendered as a table.\n *\n * Two rows do not repay a header line, and one row is not a table at all.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const tableRows = 3\n\n/**\n * What the model is told when a print was cut: the value is still bound.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const recall = \"print a narrower slice of this value; it is still bound in the realm\"\n\n/**\n * One `console.log` call, as the host kept it.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport interface Statement {\n /** The head and tail the host kept, in order and possibly the whole thing. */\n readonly text: string\n /** What the statement rendered to before anything was dropped. */\n readonly bytes: number\n}\n\nconst cell = (value: Schema.Json): string =>\n typeof value === \"string\" && !value.includes(\"\\n\") && !value.includes(\"|\")\n ? value\n : CanonicalJson.stringify(value)\n\n/** A source line, shared by hits and their context. */\ntype MatchLine = { readonly line: number; readonly text: string }\n\n/** The optional symbol attached to a source hit. */\ntype MatchSymbol = {\n readonly kind: string\n readonly name: string\n readonly startLine: number\n readonly endLine: number\n}\n\n/** The exact match shape; additional data must survive in the generic table. */\ntype Match = MatchLine & {\n readonly file: string\n readonly before?: ReadonlyArray<MatchLine>\n readonly after?: ReadonlyArray<MatchLine>\n readonly symbol?: MatchSymbol\n}\n\nconst isMatchLine = (value: Schema.Json): value is MatchLine =>\n isRecord<Schema.Json>(value) && Object.keys(value).length === 2 &&\n Number.isInteger(value.line) && typeof value.text === \"string\"\n\nconst isMatchSymbol = (value: Schema.Json | undefined): value is MatchSymbol =>\n isRecord<Schema.Json>(value) && Object.keys(value).length === 4 &&\n typeof value.kind === \"string\" && typeof value.name === \"string\" &&\n Number.isInteger(value.startLine) && Number.isInteger(value.endLine)\n\nconst isMatch = (value: Schema.Json): value is Match =>\n isRecord<Schema.Json>(value) &&\n typeof value.file === \"string\" && Number.isInteger(value.line) && typeof value.text === \"string\" &&\n Object.keys(value).every((key) => [\"file\", \"line\", \"text\", \"before\", \"after\", \"symbol\"].includes(key)) &&\n (!Object.hasOwn(value, \"before\") || Array.isArray(value.before) && value.before.every(isMatchLine)) &&\n (!Object.hasOwn(value, \"after\") || Array.isArray(value.after) && value.after.every(isMatchLine)) &&\n (!Object.hasOwn(value, \"symbol\") || isMatchSymbol(value.symbol))\n\n/** Renders nonempty match lists in consecutive file groups, using rg's line markers. */\nconst matchList = (value: Schema.Json): string | undefined => {\n if (!Array.isArray(value) || value.length === 0 || !value.every(isMatch)) return undefined\n const lines: Array<string> = []\n let previousFile: string | undefined\n let previousLine = 0\n for (const match of value) {\n const before = match.before ?? []\n const after = match.after ?? []\n if (match.file !== previousFile) lines.push(match.file)\n else if ((before[0]?.line ?? match.line) > previousLine + 1) lines.push(\"--\")\n for (const context of before) lines.push(`${context.line}-${context.text}`)\n const symbol = match.symbol\n const suffix = symbol === undefined ? \"\" : ` ‹${symbol.kind} ${symbol.name} ${symbol.startLine}-${symbol.endLine}›`\n lines.push(`${match.line}:${match.text}${suffix}`)\n for (const context of after) lines.push(`${context.line}-${context.text}`)\n previousFile = match.file\n previousLine = after.at(-1)?.line ?? match.line\n }\n return lines.join(\"\\n\")\n}\n\n/**\n * Renders an array of records as a table, or nothing.\n *\n * Columns are the union of keys in first-seen order. An absent member is an\n * empty cell; explicit null, empty arrays and empty objects stay `null`, `[]`\n * and `{}`. Cells are the string itself where that is unambiguous — no newline,\n * no column separator — and canonical JSON everywhere else. An empty string\n * still looks absent, and a string spelling a JSON literal still looks like\n * that value: this is a log rather than a wire format, so it is not paid for in\n * quoting every cell.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const table = (value: Schema.Json): string | undefined => {\n if (!Array.isArray(value) || value.length < tableRows) return undefined\n if (!value.every(isRecord<Schema.Json>)) return undefined\n const columns = [...new Set(value.flatMap((element) => Object.keys(element)))]\n if (columns.length < 2) return undefined\n const rows = value.map((element) =>\n columns.map((column) => Object.hasOwn(element, column) ? cell(element[column]!) : \"\").join(\" | \")\n )\n return `${columns.join(\" | \")}\\n${rows.join(\"\\n\")}`\n}\n\n/**\n * Renders one printed JSON value compactly.\n *\n * A match list becomes numbered source lines; other records become a table.\n * An object with exactly one such member becomes that object's other members\n * as JSON, then the member's name, count and rendered list. An exact failed-call\n * envelope becomes its code, message and optional hint. Everything else is\n * canonical JSON as before.\n *\n * Tables save repeated keys but pay for every column boundary, including\n * absent members. The three-row, two-column floor saves bytes for uniform\n * records; it does not guarantee savings for sparse records. Rendering stays\n * shape-based rather than comparing both encodings.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const render = (value: Schema.Json): string => {\n // A string is itself, which is what `Cell.renderText` promises everywhere\n // else the harness renders a projected value. The prelude sends a primitive\n // string down the `text` side, so this arm answers only for a boxed one.\n if (typeof value === \"string\") return value\n const flat = matchList(value) ?? table(value)\n if (flat !== undefined) return flat\n if (!isRecord<Schema.Json>(value)) return CanonicalJson.stringify(value)\n const error = value.error\n if (\n Object.keys(value).length === 2 && value.ok === false &&\n isRecord<Schema.Json>(error) &&\n typeof error.code === \"string\" && typeof error.message === \"string\" &&\n Object.keys(error).every((key) => key === \"code\" || key === \"message\" || key === \"hint\") &&\n (!Object.hasOwn(error, \"hint\") || typeof error.hint === \"string\")\n ) {\n return `failed (${error.code}): ${error.message}${Object.hasOwn(error, \"hint\") ? ` — hint: ${error.hint}` : \"\"}`\n }\n const tabled = Object.entries(value).flatMap(([key, member]) => {\n const rendered = matchList(member) ?? table(member)\n return rendered === undefined ? [] : [[key, member as ReadonlyArray<unknown>, rendered] as const]\n })\n if (tabled.length !== 1) return CanonicalJson.stringify(value)\n const [key, member, rendered] = tabled[0]!\n const rest = Object.fromEntries(Object.entries(value).filter(([name]) => name !== key))\n return `${\n Object.keys(rest).length === 0 ? \"\" : `${CanonicalJson.stringify(rest)}\\n`\n }${key} (${member.length}):\\n${rendered}`\n}\n\n/**\n * Apportions one budget across statements of the given sizes.\n *\n * Short statements take what they need and hand the remainder back, so a frame\n * that printed one long value and three short ones spends the budget on the long\n * one. Allocation runs shortest first, which is what makes the hand-back\n * possible, and the result is in the order the sizes were given.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const shares = (sizes: ReadonlyArray<number>, budget: number): ReadonlyArray<number> => {\n const order = sizes.map((size, index) => ({ size, index })).sort((left, right) =>\n left.size === right.size ? left.index - right.index : left.size - right.size\n )\n const allotted = new Array<number>(sizes.length).fill(0)\n let remaining = budget\n let left = sizes.length\n for (const { index, size } of order) {\n const fair = Math.floor(remaining / left)\n const given = Math.min(size, fair)\n allotted[index] = given\n remaining = remaining - given\n left = left - 1\n }\n return allotted\n}\n\n/** The line a frame writes about the statements it dropped whole. */\nconst droppedNotice = (count: number): string =>\n `… ${count} print statements elided from the middle of this frame; the values are still bound in the realm.`\n\n/** The line a frame writes about the statements the host never copied out. */\nconst unreadNotice = (count: number): string =>\n `… ${count} further print statements were not kept: this frame printed more than the harness holds.`\n\n/**\n * What keeping one statement costs the budget: its floor, its notice, its newline.\n *\n * A statement at or under {@link printStatementFloor} costs only itself\n * and no notice, because {@link buffer} shows it whole and a whole statement has\n * nothing to say about what it lost. One over the floor is promised the floor,\n * and the notice that shortening it prints is charged with it.\n */\nconst price = (statement: Statement): number =>\n Math.min(statement.bytes, printStatementFloor) +\n (statement.bytes > printStatementFloor ? elide.noticeCost(statement.bytes, recall) : 0) + 1\n\n/**\n * How many of *these* statements a budget can keep at the floor, head first.\n *\n * A count of the statements in hand rather than a constant, because what a\n * statement costs is what it is. Taken as `printFrameBytes / printStatementFloor`\n * it was 32 whatever a frame printed, so a frame of two hundred eight-byte lines\n * dropped a hundred and sixty-eight of them while fifteen of its sixteen\n * kilobytes went unspent — the failure the shared budget exists to end,\n * reintroduced one level up. Two hundred lines that cost nine bytes each cost\n * eighteen hundred, and the budget keeps every one of them.\n *\n * The walk takes the head, then the tail, then the head again, which is the\n * order {@link buffer} assembles them in, so a budget that affords an odd number\n * spends the odd one on the earlier statement.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const capacity = (statements: ReadonlyArray<Statement>, budget: number): number => {\n let left = budget\n let kept = 0\n while (kept < statements.length) {\n const statement = kept % 2 === 0 ? statements[kept / 2]! : statements[statements.length - 1 - (kept - 1) / 2]!\n const cost = price(statement)\n if (cost > left) break\n left = left - cost\n kept = kept + 1\n }\n return kept\n}\n\n/**\n * Assembles what a frame printed, bounded by {@link printFrameBytes}.\n *\n * `unread` is the count of statements the host stopped copying out of the realm\n * because the frame had already handed over more than it holds. It is stated\n * rather than dropped, because a buffer that simply stopped reads as a cell that\n * simply stopped printing.\n *\n * The bound holds by construction rather than by a second pass over the result,\n * because a second pass would cut a notice in half and that is the one thing a\n * bound may not do. {@link capacity} charges every kept statement the floor it is\n * promised, the notice it would print and its newline; what survives that walk is\n * therefore affordable, and the apportionment below spends only what the walk\n * left. A statement at or under the floor is shown whole and reserves no notice\n * at all — reserving one apiece is what left a frame of short lines nothing to\n * spend on the lines themselves.\n *\n * @since 0.1.0\n * @private\n * @slop\n */\nexport const buffer = (statements: ReadonlyArray<Statement>, unread: number): string => {\n if (statements.length === 0 && unread === 0) return \"\"\n // The count-lines come out of the budget before the statements are counted,\n // and the drop line only where there is a drop — so it is priced by asking\n // twice, rather than by charging every frame for a line most never print.\n const overhead = unread === 0 ? 0 : bytes.size(unreadNotice(unread)) + 1\n const roomy = capacity(statements, printFrameBytes - overhead)\n const affordable = roomy === statements.length\n ? roomy\n : capacity(statements, printFrameBytes - overhead - bytes.size(droppedNotice(statements.length)) - 1)\n // More statements than the budget can floor: whole statements go from the\n // middle, counted, rather than every one of them being cut to a notice.\n const head = Math.ceil(affordable / 2)\n const kept = statements.length === affordable\n ? statements\n : [...statements.slice(0, head), ...statements.slice(statements.length - Math.floor(affordable / 2))]\n const dropped = statements.length - kept.length\n const notices = [\n ...(dropped === 0 ? [] : [droppedNotice(dropped)]),\n ...(unread === 0 ? [] : [unreadNotice(unread)])\n ]\n // What the budget cannot spend on values: the count-lines, the newline between\n // every pair, and one elision notice for each statement the floor does not\n // cover whole.\n const sizes = kept.map((statement) => statement.bytes)\n const reserve = kept.reduce(\n (sum, statement) => sum + (statement.bytes > printStatementFloor ? elide.noticeCost(statement.bytes, recall) : 0),\n 0\n ) +\n notices.reduce((sum, line) => sum + bytes.size(line), 0) +\n Math.max(0, kept.length + notices.length - 1)\n const allotted = shares(sizes, Math.max(0, printFrameBytes - reserve))\n const lines = kept.map((statement, index) =>\n elide.middleFrom(statement.text, statement.bytes, allotted[index]!, recall)\n )\n return [\n ...lines.slice(0, dropped === 0 ? lines.length : head),\n ...(dropped === 0 ? [] : [notices[0]!, ...lines.slice(head)]),\n ...(unread === 0 ? [] : [notices[notices.length - 1]!])\n ].join(\"\\n\")\n}\n"]}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The one rendering of a frame's print buffer into the turn that reads it.
3
+ *
4
+ * The controller journals the RAW buffer as `AgentEvent.CellPrinted` and sends
5
+ * this rendering to the model, so a projection that replays the raw text
6
+ * rebuilds a window the run never had. Both callers go through here for that
7
+ * reason: `CellTurn` when it builds the next turn, and `Transcript` when it
8
+ * rebuilds one from the journal.
9
+ *
10
+ * An empty buffer is a message and not a silence. A cell that printed nothing
11
+ * still opened a turn, and the turn it opened says so — dropping it loses a
12
+ * user message the model actually read, and the model is told the realm still
13
+ * holds everything the cell bound, which is the recovery it needs.
14
+ *
15
+ * @since 0.1.0
16
+ * @private
17
+ */
18
+ /**
19
+ * Renders one frame's print buffer as the user turn its successor read.
20
+ *
21
+ * @category conversions
22
+ * @since 0.1.0
23
+ * @private
24
+ */
25
+ export declare const printsObservation: (prints: string) => string;
26
+ //# sourceMappingURL=printsObservation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"printsObservation.d.ts","sourceRoot":"","sources":["../../../src/internal/printsObservation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAAI,QAAQ,MAAM,KAAG,MAGoE,CAAA"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * The one rendering of a frame's print buffer into the turn that reads it.
3
+ *
4
+ * The controller journals the RAW buffer as `AgentEvent.CellPrinted` and sends
5
+ * this rendering to the model, so a projection that replays the raw text
6
+ * rebuilds a window the run never had. Both callers go through here for that
7
+ * reason: `CellTurn` when it builds the next turn, and `Transcript` when it
8
+ * rebuilds one from the journal.
9
+ *
10
+ * An empty buffer is a message and not a silence. A cell that printed nothing
11
+ * still opened a turn, and the turn it opened says so — dropping it loses a
12
+ * user message the model actually read, and the model is told the realm still
13
+ * holds everything the cell bound, which is the recovery it needs.
14
+ *
15
+ * @since 0.1.0
16
+ * @private
17
+ */
18
+ import { untrustedData } from "./untrustedData.js";
19
+ /**
20
+ * Renders one frame's print buffer as the user turn its successor read.
21
+ *
22
+ * @category conversions
23
+ * @since 0.1.0
24
+ * @private
25
+ */
26
+ export const printsObservation = (prints) => prints === ""
27
+ ? "Your cell printed nothing, so this turn opens with nothing new to read. Everything it bound is still in the realm; print what you need to look at."
28
+ : untrustedData(`What your cell printed:\n${prints}`, "cell print buffer (may contain repository and tool output)");
29
+ //# sourceMappingURL=printsObservation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"printsObservation.js","sourceRoot":"","sources":["../../../src/internal/printsObservation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,MAAc,EAAU,EAAE,CAC1D,MAAM,KAAK,EAAE;IACX,CAAC,CAAC,oJAAoJ;IACtJ,CAAC,CAAC,aAAa,CAAC,4BAA4B,MAAM,EAAE,EAAE,4DAA4D,CAAC,CAAA","sourcesContent":["/**\n * The one rendering of a frame's print buffer into the turn that reads it.\n *\n * The controller journals the RAW buffer as `AgentEvent.CellPrinted` and sends\n * this rendering to the model, so a projection that replays the raw text\n * rebuilds a window the run never had. Both callers go through here for that\n * reason: `CellTurn` when it builds the next turn, and `Transcript` when it\n * rebuilds one from the journal.\n *\n * An empty buffer is a message and not a silence. A cell that printed nothing\n * still opened a turn, and the turn it opened says so — dropping it loses a\n * user message the model actually read, and the model is told the realm still\n * holds everything the cell bound, which is the recovery it needs.\n *\n * @since 0.1.0\n * @private\n */\n\nimport { untrustedData } from \"./untrustedData.ts\"\n\n/**\n * Renders one frame's print buffer as the user turn its successor read.\n *\n * @category conversions\n * @since 0.1.0\n * @private\n */\nexport const printsObservation = (prints: string): string =>\n prints === \"\"\n ? \"Your cell printed nothing, so this turn opens with nothing new to read. Everything it bound is still in the realm; print what you need to look at.\"\n : untrustedData(`What your cell printed:\\n${prints}`, \"cell print buffer (may contain repository and tool output)\")\n"]}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * The one constructor for a refusal a cell observes as a resolved envelope.
3
+ *
4
+ * A failed call **resolves** with a `failure` `Cell.CallResult`; it does not
5
+ * throw, and `Cell.callFailure` renders it as `{ ok: false, error }`. The shape
6
+ * is fixed — `value` is `null`, because a refusal has no value to hand back,
7
+ * except a timeout's, which records the limit it ran past (see {@link timedOut})
8
+ * — so every boundary that refuses a call builds it here rather than repeating
9
+ * the literal. The cell never sees `value` on a failure. An absent `code` is left absent rather than written as
10
+ * `undefined`: the encoded result is the durable wire contract used in sealed
11
+ * keys, and it means {@link Cell.defaultCallFailureCode}.
12
+ *
13
+ * @since 1.0.0-rc.0
14
+ * @private
15
+ */
16
+ import { type CallFailureCode, CallResult } from "../Cell.ts";
17
+ /**
18
+ * A refusal the cell observes as a resolved `{ ok: false, error }` envelope.
19
+ *
20
+ * @since 1.0.0-rc.0
21
+ * @private
22
+ */
23
+ export declare const refusal: (code: CallFailureCode | undefined, message: string) => CallResult;
24
+ /**
25
+ * A timeout refusal: the `timeout` code, with the limit the call ran past
26
+ * recorded as `{ limitMillis }` in `value`, so a host that guards timeouts
27
+ * parks the run on the exact limit whichever clock enforced it.
28
+ *
29
+ * @since 1.0.0-rc.1
30
+ * @private
31
+ */
32
+ export declare const timedOut: (message: string, limitMillis: number) => CallResult;
33
+ /**
34
+ * The limit a {@link timedOut} refusal recorded, when it recorded one.
35
+ *
36
+ * @since 1.0.0-rc.1
37
+ * @private
38
+ */
39
+ export declare const limitOf: (result: CallResult) => number | undefined;
40
+ //# sourceMappingURL=refusal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refusal.d.ts","sourceRoot":"","sources":["../../../src/internal/refusal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,KAAK,eAAe,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE7D;;;;;GAKG;AACH,eAAO,MAAM,OAAO,GAAI,MAAM,eAAe,GAAG,SAAS,EAAE,SAAS,MAAM,KAAG,UAGL,CAAA;AAExE;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,GAAI,SAAS,MAAM,EAAE,aAAa,MAAM,KAAG,UAC0B,CAAA;AAE1F;;;;;GAKG;AACH,eAAO,MAAM,OAAO,GAAI,QAAQ,UAAU,KAAG,MAAM,GAAG,SAGrD,CAAA"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * The one constructor for a refusal a cell observes as a resolved envelope.
3
+ *
4
+ * A failed call **resolves** with a `failure` `Cell.CallResult`; it does not
5
+ * throw, and `Cell.callFailure` renders it as `{ ok: false, error }`. The shape
6
+ * is fixed — `value` is `null`, because a refusal has no value to hand back,
7
+ * except a timeout's, which records the limit it ran past (see {@link timedOut})
8
+ * — so every boundary that refuses a call builds it here rather than repeating
9
+ * the literal. The cell never sees `value` on a failure. An absent `code` is left absent rather than written as
10
+ * `undefined`: the encoded result is the durable wire contract used in sealed
11
+ * keys, and it means {@link Cell.defaultCallFailureCode}.
12
+ *
13
+ * @since 1.0.0-rc.0
14
+ * @private
15
+ */
16
+ import * as Schema from "effect/Schema";
17
+ import { CallResult } from "../Cell.js";
18
+ /**
19
+ * A refusal the cell observes as a resolved `{ ok: false, error }` envelope.
20
+ *
21
+ * @since 1.0.0-rc.0
22
+ * @private
23
+ */
24
+ export const refusal = (code, message) => code === undefined
25
+ ? new CallResult({ outcome: "failure", value: null, message })
26
+ : new CallResult({ outcome: "failure", value: null, code, message });
27
+ /**
28
+ * A timeout refusal: the `timeout` code, with the limit the call ran past
29
+ * recorded as `{ limitMillis }` in `value`, so a host that guards timeouts
30
+ * parks the run on the exact limit whichever clock enforced it.
31
+ *
32
+ * @since 1.0.0-rc.1
33
+ * @private
34
+ */
35
+ export const timedOut = (message, limitMillis) => new CallResult({ outcome: "failure", value: { limitMillis }, code: "timeout", message });
36
+ /**
37
+ * The limit a {@link timedOut} refusal recorded, when it recorded one.
38
+ *
39
+ * @since 1.0.0-rc.1
40
+ * @private
41
+ */
42
+ export const limitOf = (result) => {
43
+ const recorded = decodeLimit(result.value);
44
+ return recorded._tag === "Success" ? recorded.success.limitMillis : undefined;
45
+ };
46
+ const decodeLimit = Schema.decodeUnknownResult(Schema.Struct({ limitMillis: Schema.Number }));
47
+ //# sourceMappingURL=refusal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refusal.js","sourceRoot":"","sources":["../../../src/internal/refusal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAwB,UAAU,EAAE,MAAM,YAAY,CAAA;AAE7D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,IAAiC,EAAE,OAAe,EAAc,EAAE,CACxF,IAAI,KAAK,SAAS;IAChB,CAAC,CAAC,IAAI,UAAU,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IAC9D,CAAC,CAAC,IAAI,UAAU,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAA;AAExE;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,OAAe,EAAE,WAAmB,EAAc,EAAE,CAC3E,IAAI,UAAU,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAA;AAE1F;;;;;GAKG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,MAAkB,EAAsB,EAAE;IAChE,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IAC1C,OAAO,QAAQ,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAA;AAC/E,CAAC,CAAA;AAED,MAAM,WAAW,GAAG,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA","sourcesContent":["/**\n * The one constructor for a refusal a cell observes as a resolved envelope.\n *\n * A failed call **resolves** with a `failure` `Cell.CallResult`; it does not\n * throw, and `Cell.callFailure` renders it as `{ ok: false, error }`. The shape\n * is fixed — `value` is `null`, because a refusal has no value to hand back,\n * except a timeout's, which records the limit it ran past (see {@link timedOut})\n * — so every boundary that refuses a call builds it here rather than repeating\n * the literal. The cell never sees `value` on a failure. An absent `code` is left absent rather than written as\n * `undefined`: the encoded result is the durable wire contract used in sealed\n * keys, and it means {@link Cell.defaultCallFailureCode}.\n *\n * @since 1.0.0-rc.0\n * @private\n */\n\nimport * as Schema from \"effect/Schema\"\nimport { type CallFailureCode, CallResult } from \"../Cell.ts\"\n\n/**\n * A refusal the cell observes as a resolved `{ ok: false, error }` envelope.\n *\n * @since 1.0.0-rc.0\n * @private\n */\nexport const refusal = (code: CallFailureCode | undefined, message: string): CallResult =>\n code === undefined\n ? new CallResult({ outcome: \"failure\", value: null, message })\n : new CallResult({ outcome: \"failure\", value: null, code, message })\n\n/**\n * A timeout refusal: the `timeout` code, with the limit the call ran past\n * recorded as `{ limitMillis }` in `value`, so a host that guards timeouts\n * parks the run on the exact limit whichever clock enforced it.\n *\n * @since 1.0.0-rc.1\n * @private\n */\nexport const timedOut = (message: string, limitMillis: number): CallResult =>\n new CallResult({ outcome: \"failure\", value: { limitMillis }, code: \"timeout\", message })\n\n/**\n * The limit a {@link timedOut} refusal recorded, when it recorded one.\n *\n * @since 1.0.0-rc.1\n * @private\n */\nexport const limitOf = (result: CallResult): number | undefined => {\n const recorded = decodeLimit(result.value)\n return recorded._tag === \"Success\" ? recorded.success.limitMillis : undefined\n}\n\nconst decodeLimit = Schema.decodeUnknownResult(Schema.Struct({ limitMillis: Schema.Number }))\n"]}