@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 @@
1
+ {"version":3,"file":"Supervisor.js","sourceRoot":"","sources":["../../src/Supervisor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AAEH,OAAO,KAAK,UAAU,MAAM,0BAA0B,CAAA;AAEtD,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,O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AC,CAAA;IACjD,OAAO,IAAI,CAAC,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,2BAA2B,IAAI,EAAE,CAAA;AACrF,CAAC,CAAA;AAED,MAAM,UAAU,GAAG,mEAAmE,CAAA;AAEtF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAA","sourcesContent":["/**\n * The reading Jev takes of a run while it is still running.\n *\n * Every other control in this package reads a completion, or reads one fact\n * the harness measured: a tree that never moved, a check that was narrowed, a\n * frame that repeated itself. Each is exact, each fires late, and each is\n * silent about the run between its brakes. A run that edits the wrong file\n * for twenty frames, re-runs one failing check after every edit and never\n * once claims to be done trips none of them until its budget is gone.\n *\n * So this module asks Jev about the run's *shape* rather than its sentence.\n * One classifier, `supervisor/turn`, over a {@link Snapshot} the controller\n * assembles from what it already holds: the task, the newest frames, and the\n * counts the deterministic controls keep — read-only streak, repeat streak,\n * mutations, checks run and failing, unanswered failures, demands spent. It\n * re-derives none of them. Beside the run's state it carries the skills it has\n * not called, the flows it has, and whether it can call `jev`. One Jev call per\n * snapshot answers every question at once.\n *\n * Eleven questions are fixed. Five are about the run: whether it is\n * thrashing, whether it is still on the task, whether its evidence is\n * suspect, and whether it carries outdated or irrelevant context. Five are\n * operational states a person would recognise in a colleague, each scored\n * `none`, `mild` or `strong` against evidence the snapshot names, and\n * `needs_help` is the one word a person is shown. The five about the run are\n * the {@link triggers}: any one past its threshold crosses. Each monitor the\n * host arms may add one boolean of its own, under {@link monitorPrefix}.\n *\n * Rows recalled from {@link Memory} are not asked about here. Beside each\n * reading, the supervisor asks `Relevance` which of up to\n * {@link recalledLimit} rows, none already shown to the run, are unnecessary\n * for the task; the rest are shown at the next boundary as\n * {@link recalledInsert} renders them, and a row is shown to a run once.\n *\n * It is a supervisor and not a brake: nothing here ends a run, refuses a\n * completion, or decides anything on the cell loop's hot path. `CellTurn`\n * offers each frame's snapshot to a one-slot sliding queue and continues; a\n * forked fiber takes the newest snapshot, asks, journals what came back, and\n * hands the monitors' values and any recalled rows to the *next* turn boundary,\n * which decides there what the run is told. A reading that arrives after the boundary it was for is\n * journaled and never delivered, and a snapshot the fiber never reached is\n * dropped: the run is never told something about a frame two frames gone.\n *\n * It never falls back. A snapshot Jev could not read is journaled as\n * {@link AgentEvent.SupervisorUnjudged} with the transport's own reason; it\n * nudges nothing, and is never counted as a reading that\n * found the run calm or on target. A host with no judge (`unconfigured`) is\n * journaled once per streak rather than every frame; each reading still asks,\n * so a judge connected mid-run is used at once. Nothing here is a default value: every\n * level and every word on the settled event came back from the transport.\n *\n * What a reading says is delivered wherever the host holds a real judge\n * (`CellTurn.Input.judged`), and only through a monitor that crossed and\n * passed its gates; the text of the legacy nudge is {@link nudge}, which the\n * `supervisor` lint monitor says. The offline replay of archived journals\n * (`evals/swebench/lib/jev-replay.mjs`, which scores {@link triggers} itself\n * rather than a copy of it) measures their precision. The verdict is\n * journaled whenever an `Evaluator` is bound. The supervisor writes no\n * memory: a run's transcript is mined once, at run end, by `@smthrs/agent`'s\n * `MemoryMine`.\n *\n * @since 1.0.0-rc.0\n */\n\nimport * as Classifier from \"@smthrs/model/Classifier\"\nimport type * as Evaluator from \"@smthrs/model/Evaluator\"\nimport * as Context from \"effect/Context\"\nimport * as Effect from \"effect/Effect\"\nimport * as Schema from \"effect/Schema\"\nimport type * as AgentEvent from \"./AgentEvent.ts\"\nimport * as elide from \"./internal/elide.ts\"\nimport { NonNegativeSafeInt } from \"./internal/nonNegativeSafeInt.ts\"\nimport { untrustedData } from \"./internal/untrustedData.ts\"\nimport * as Judgement from \"./Judgement.ts\"\n\n/**\n * The most of one frame's cell, prose or prints the snapshot carries, in\n * UTF-8 bytes. The head of a cell and the tail of its prints: a cell states\n * its plan first and a runner states its verdict last.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const frameBytes = 1024\n\n/**\n * How many of the newest frames a snapshot carries.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const recentFrames = 3\n\n/**\n * The most rows one reading recalls from {@link Memory}.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const recalledLimit = 6\n\n/**\n * How long a run that ends with a reading in flight waits for it to settle\n * and journal, in milliseconds. A reading still unanswered then is interrupted\n * and journaled `supervisor-unjudged` with reason `interrupted`; the run never\n * waits longer than this for its supervisor.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const closeGraceMs = 1_500\n\n/**\n * At or above this probability of `thrashing`, the reading crosses.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const thrashingAt = 0.5\n\n/**\n * At or below this probability of `on_target`, the reading crosses.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const offTargetAt = 0.5\n\n/**\n * At or above this probability of `suspect`, the reading crosses.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const suspectAt = 0.5\n\n/**\n * At or above this probability of `outdated_context` or\n * `irrelevant_context`, a judged run compacts at its next frame.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const contextAt = 0.5\n\n/**\n * The three rungs every operational-state question is scored on.\n *\n * @category schemas\n * @since 1.0.0-rc.0\n */\nexport const Level = Schema.Literals([\"none\", \"mild\", \"strong\"])\n\n/**\n * The decoded form of {@link Level}.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type Level = typeof Level.Type\n\n/**\n * The rungs as the score question declares them, in order.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const levels = [\"none\", \"mild\", \"strong\"] as const\n\n/**\n * The one word a person is shown about a run.\n *\n * @category schemas\n * @since 1.0.0-rc.0\n */\nexport const Help = Schema.Literals([\"none\", \"clarification\", \"permission\", \"stuck\", \"risky_action\"])\n\n/**\n * The decoded form of {@link Help}.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type Help = typeof Help.Type\n\n/**\n * The five operational states, in the order they are asked and journaled.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const emotions = [\"frustrated\", \"anxious\", \"scared\", \"confused\", \"confident\"] as const\n\n/**\n * One of {@link emotions}.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type Emotion = typeof emotions[number]\n\n/**\n * One recent frame as the snapshot carries it: the cell the model wrote, the\n * prose around it, what the cell printed, and how it ended.\n *\n * @category schemas\n * @since 1.0.0-rc.0\n */\nexport const Frame = Schema.Struct({\n frame: NonNegativeSafeInt,\n cell: Schema.String.annotate({ description: \"The cell the model wrote, head kept\" }),\n prose: Schema.String.annotate({ description: \"What the model wrote outside the cell, head kept\" }),\n printed: Schema.String.annotate({ description: \"What the cell printed, newest bytes kept\" }),\n transition: Schema.Literals([\"continue\", \"complete\", \"park\", \"raised\", \"rejected\"]),\n mutated: Schema.Boolean.annotate({ description: \"Whether this frame changed the workspace\" })\n})\n\n/**\n * The decoded form of {@link Frame}.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type Frame = typeof Frame.Type\n\n/**\n * The counts the deterministic controls keep, handed over as they stand.\n *\n * Every field is read off `CellTurn.State` or the frame's accounting and none\n * is re-derived here: the supervisor is a reader of the harness's evidence,\n * not a second measurer of it.\n *\n * @category schemas\n * @since 1.0.0-rc.0\n */\nexport const Signals = Schema.Struct({\n frame: NonNegativeSafeInt.annotate({ description: \"The frame just closed, counting from zero\" }),\n maxFrames: NonNegativeSafeInt.annotate({ description: \"The frame budget; zero is unbounded\" }),\n readOnlyFrames: NonNegativeSafeInt.annotate({ description: \"Consecutive frames that changed nothing\" }),\n repeatFrames: NonNegativeSafeInt.annotate({\n description: \"Consecutive frames that issued only calls already issued and changed nothing\"\n }),\n mutations: NonNegativeSafeInt.annotate({ description: \"Frames that changed the workspace\" }),\n remoteMutations: NonNegativeSafeInt.annotate({ description: \"Writes recorded on trees the host cannot see\" }),\n treeMoved: Schema.Boolean.annotate({ description: \"Whether the workspace differs from the tree the run opened on\" }),\n paths: NonNegativeSafeInt.annotate({\n description: \"Paths the closing workspace measurement covered; zero unmeasured\"\n }),\n checksRun: NonNegativeSafeInt.annotate({ description: \"Distinct checks the run has run\" }),\n checksFailing: NonNegativeSafeInt.annotate({ description: \"Of those, how many last reported a failing status\" }),\n failuresUnanswered: NonNegativeSafeInt.annotate({\n description: \"Failing checks no later passing check has answered\"\n }),\n callsFailed: NonNegativeSafeInt.annotate({ description: \"Settled calls in the ledger that failed\" }),\n callsSettled: NonNegativeSafeInt.annotate({ description: \"Settled calls in the ledger\" }),\n narrowingDemands: NonNegativeSafeInt.annotate({ description: \"Completions bounced for narrowed evidence\" }),\n unmovedDemands: NonNegativeSafeInt.annotate({ description: \"Completions bounced for an unmoved tree\" }),\n unresolvedDemands: NonNegativeSafeInt.annotate({ description: \"Completions bounced for a stepped-around failure\" }),\n claimDemands: NonNegativeSafeInt.annotate({ description: \"Completions bounced for an unsupported claim\" }),\n sufficiencyStated: Schema.Boolean.annotate({ description: \"Whether the run was told its evidence is complete\" })\n})\n\n/**\n * The decoded form of {@link Signals}.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type Signals = typeof Signals.Type\n\n/**\n * One row recalled from memory.\n *\n * @category schemas\n * @since 1.0.0-rc.0\n */\nexport const Recalled = Schema.Struct({\n key: Schema.String,\n text: Schema.String\n})\n\n/**\n * The decoded form of {@link Recalled}.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type Recalled = typeof Recalled.Type\n\n/**\n * The most skills one snapshot offers.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const skillLimit = 12\n\n/**\n * The most of one skill's description a snapshot carries, in UTF-8 bytes.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const skillBytes = 256\n\n/**\n * The most distinct flow names {@link Snapshot} `called` carries.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const calledLimit = 64\n\n/**\n * One skill the run could read and has neither called nor read.\n *\n * @category schemas\n * @since 1.0.0-rc.0\n */\nexport const Skill = Schema.Struct({\n name: Schema.String,\n description: Schema.String.annotate({ description: \"The description's head, wrapped as untrusted data\" }),\n path: Schema.String.annotate({ description: \"Where the skill's Markdown body is\" })\n})\n\n/**\n * The decoded form of {@link Skill}.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type Skill = typeof Skill.Type\n\n/**\n * One skill as a snapshot offers it: its description's head within\n * {@link skillBytes}, wrapped as untrusted data.\n *\n * @category constructors\n * @since 1.0.0-rc.0\n */\nexport const skill = (name: string, description: string, path: string): Skill => ({\n name,\n description: untrustedData(elide.head(description, skillBytes, \"clipped\"), `description of skill ${name}`),\n path\n})\n\n/**\n * Everything one supervisor reading is a reading of.\n *\n * @category schemas\n * @since 1.0.0-rc.0\n */\nexport const Snapshot = Schema.Struct({\n task: Schema.String.annotate({ description: \"The task, as the person stated it\" }),\n frames: Schema.Array(Frame).annotate({ description: \"The newest frames, oldest first\" }),\n signals: Signals,\n skills: Schema.Array(Skill).annotate({\n description: \"Skills the run could read and has neither called nor read, by index\"\n }),\n called: Schema.Array(Schema.String).annotate({ description: \"Distinct flows the run has called\" }),\n jevAvailable: Schema.Boolean.annotate({ description: \"Whether the run can call the jev flow\" })\n})\n\n/**\n * The decoded form of {@link Snapshot}.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type Snapshot = typeof Snapshot.Type\n\n/**\n * The fixed questions, asked of every snapshot.\n *\n * Each criterion names the evidence it reads, so a reading is answerable from\n * the snapshot and never from what the transport imagines the repository holds.\n */\nconst fixedQuestions = {\n thrashing: Classifier.boolean({\n instructions:\n \"Is the run going in circles rather than converging? Compare the newest frames with each other and with signals.checksFailing, signals.failuresUnanswered, signals.readOnlyFrames and signals.repeatFrames. Any one sign below is enough.\",\n criteria: {\n true:\n \"a check fails again after an edit meant to fix it, an edit is redone or reverted, or the newest frames re-read or re-run what earlier frames already saw without learning anything new\",\n false:\n \"the newest frames learn something new or make progress: a failing check now passes, or a new cause is found and acted on\"\n }\n }),\n on_target: Classifier.boolean({\n instructions:\n \"Is the run still working on the task as stated? Read the task and the newest frames' cells and prose.\",\n criteria: {\n true: \"the newest frames read, edit or check the thing the task names\",\n false: \"the newest frames work on something the task does not ask for, or have drifted from it\"\n }\n }),\n suspect: Classifier.boolean({\n instructions:\n \"Is the run's evidence suspect? Read the newest frames for tests edited to pass, edits to a file the task does not concern, or prose claiming a result no printed output shows.\",\n criteria: {\n true:\n \"a test was changed rather than the code under test, the wrong file was edited, or a claim has no check behind it\",\n false: \"edits are to the code the task names and every claim has a printed result behind it\"\n }\n }),\n outdated_context: Classifier.boolean({\n instructions:\n \"Do the newest frames show earlier context that is now factually wrong or stale? Judge only evidence visible in the task and frames; do not assume unseen history is outdated.\",\n criteria: {\n true: \"a later observation explicitly contradicts an earlier assumption or file state in the visible frames\",\n false: \"no visible contradiction, or the earlier context is still accurate\"\n }\n }),\n irrelevant_context: Classifier.boolean({\n instructions:\n \"Do the newest frames show earlier context that is accurate but no longer useful for the task? Do not treat the task, a reusable PRD, or decisions still needed as irrelevant.\",\n criteria: {\n true: \"the visible frames explicitly move away from earlier work that will not be needed again\",\n false: \"the earlier work may still be needed, or the visible frames do not establish irrelevance\"\n }\n }),\n frustrated: Classifier.score({\n instructions:\n \"How frustrated is the run: the same check failing repeatedly, edits reverted, attempts not converging? Read signals.checksFailing, signals.failuresUnanswered, signals.repeatFrames, signals.readOnlyFrames and the newest frames.\",\n criteria: levels\n }),\n anxious: Classifier.score({\n instructions:\n \"How anxious is the run: its own prose hedges or expresses uncertainty while the evidence is thin? Read the frames' prose against signals.checksRun and signals.callsSettled.\",\n criteria: levels\n }),\n scared: Classifier.score({\n instructions:\n \"How scared should a person be: is the run taking or considering a destructive, irreversible or out-of-scope action, or hitting permission or sandbox refusals? Read the newest frames' cells, prints and failed calls.\",\n criteria: levels\n }),\n confused: Classifier.score({\n instructions:\n \"How confused is the run: the task is ambiguous or contradicted by the repository, and the run keeps switching interpretations or files? Read the task against the newest frames.\",\n criteria: levels\n }),\n confident: Classifier.score({\n instructions:\n \"How confident should a person be that the work converges on the task: checks pass and each frame builds on the last? Read signals.checksRun, signals.checksFailing, signals.mutations and the newest frames.\",\n criteria: levels\n }),\n needs_help: Classifier.choice({\n instructions:\n \"What, if anything, does the run need from a person right now? Read the states above and the newest frames.\",\n criteria: {\n none: \"nothing; the run can carry on\",\n clarification: \"the task is ambiguous or contradicted and a person must say which reading is meant\",\n permission: \"the run is blocked on a permission or sandbox refusal a person can grant\",\n stuck: \"the run is not converging and a person should intervene\",\n risky_action: \"the run is about to do something destructive, irreversible or out of scope\"\n }\n })\n} as const\n\n/**\n * The prefix of every question a monitor adds to a reading; the rest of the\n * id is the monitor's own.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const monitorPrefix = \"monitor_\"\n\n/**\n * The questions a snapshot's monitors add, by `monitor_<id>`.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type MonitorQuestions = Readonly<Record<`${typeof monitorPrefix}${string}`, Classifier.BooleanQuestion>>\n\nconst declare = (extra: MonitorQuestions) =>\n Classifier.make(\"supervisor/turn\", {\n description:\n \"Read one running agent's newest frames and the counts its harness keeps: whether it is thrashing, on the task and honest; its operational state in five scored words; and what it needs from a person.\",\n state: Snapshot,\n questions: { ...fixedQuestions, ...extra }\n })\n\nconst cache = new Map<string, { readonly extra: MonitorQuestions; readonly made: ReturnType<typeof declare> }>()\n\n/**\n * The classifier for a snapshot with these monitor questions.\n *\n * The fixed questions are the same for every snapshot and the monitors' follow\n * them, so a snapshot with no monitor questions asks the eleven fixed\n * questions and no others. Declared once per set of monitor ids, and again\n * when a monitor id asks a different question, because the digest is the\n * canonical hash of the questions and the journal names it.\n *\n * @category classifiers\n * @since 1.0.0-rc.0\n */\nexport const classifierFor = (extra: MonitorQuestions): ReturnType<typeof declare> => {\n const ids = Object.keys(extra).sort() as Array<keyof MonitorQuestions>\n const key = ids.join(\",\")\n const held = cache.get(key)\n if (held !== undefined && ids.every((id) => held.extra[id] === extra[id])) return held.made\n const made = declare(extra)\n cache.set(key, { extra, made })\n return made\n}\n\n/**\n * The classifier over a bare snapshot: the eleven fixed questions and no\n * monitor booleans. Its id is the id every shape shares.\n *\n * @category classifiers\n * @since 1.0.0-rc.0\n */\nexport const classifier = classifierFor({})\n\n/**\n * What one evaluation came back with, decoded.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport interface Reading {\n readonly thrashing: number\n readonly onTarget: number\n readonly suspect: number\n readonly outdatedContext: number\n readonly irrelevantContext: number\n readonly emotions: Readonly<Record<Emotion, Level>>\n readonly needsHelp: Help\n /** The probability of each monitor question asked, by monitor id. */\n readonly monitors: Readonly<Record<string, number>>\n readonly latencyMs: number\n readonly usage?: Evaluator.Usage | undefined\n /** What was asked and what came back, for `decision-settled`. */\n readonly asked: {\n readonly digest: string\n readonly questions: Classifier.Questions\n readonly state: Schema.Json\n readonly answers: Readonly<Record<string, AgentEvent.DecisionAnswer>>\n }\n}\n\n/**\n * Asks Jev about one snapshot, and the monitor questions `extra` adds.\n *\n * Fails, typed, whenever an answer could not be obtained: no evaluator bound,\n * a transport refusal, a deadline, an answer that does not decode. There is\n * no reading of a snapshot Jev did not read.\n *\n * @category conversions\n * @since 1.0.0-rc.0\n */\nexport const read = (snapshot: Snapshot, extra: MonitorQuestions): Effect.Effect<Reading, Judgement.Unjudged> =>\n Effect.gen(function*() {\n const { answers, asked } = yield* Judgement.read(classifierFor(extra), snapshot)\n const all = answers as Readonly<Record<string, Classifier.Answer>>\n // Every declared question is answered or the decode above failed, and a\n // monitor question is declared exactly for the ids read below.\n const bool = (id: string): number => (all[id] as Classifier.BooleanAnswer).probability\n return {\n thrashing: answers.thrashing.probability,\n onTarget: answers.on_target.probability,\n suspect: answers.suspect.probability,\n outdatedContext: answers.outdated_context.probability,\n irrelevantContext: answers.irrelevant_context.probability,\n emotions: {\n frustrated: answers.frustrated.label,\n anxious: answers.anxious.label,\n scared: answers.scared.label,\n confused: answers.confused.label,\n confident: answers.confident.label\n },\n needsHelp: answers.needs_help.value,\n monitors: Object.fromEntries(Object.keys(extra).map((id) => [id.slice(monitorPrefix.length), bool(id)])),\n latencyMs: asked.latencyMs,\n ...(asked.usage === undefined ? {} : { usage: asked.usage }),\n asked: { digest: asked.digest, questions: asked.questions, state: asked.state, answers: asked.answers }\n }\n })\n\n/**\n * The memory a supervisor reads rows from, and the run-end transcript miner\n * writes accepted facts to.\n *\n * A port, so this package needs no memory store: the production composition\n * adapts `@smthrs/memory` to it, and a test binds a recording double. The\n * default is {@link memoryNone}, which recalls nothing and writes nothing.\n *\n * @category services\n * @since 1.0.0-rc.0\n */\nexport interface Memory {\n /** Whether anything is behind this port; false is the default. */\n readonly bound: boolean\n /** Rows relevant to the query, most relevant first, bounded by the caller. */\n readonly recall: (query: string, limit: number) => Effect.Effect<ReadonlyArray<Recalled>, MemoryFailure>\n /**\n * Writes one accepted fact. A store that refuses it fails typed, and the\n * writer journals `supervisor-memory-failed` and carries on.\n */\n readonly remember: (text: string) => Effect.Effect<void, MemoryFailure>\n}\n\n/**\n * What a {@link Memory} fails with: the store's own account, safe to journal.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport interface MemoryFailure {\n readonly detail: string\n}\n\n/**\n * A memory with nothing behind it.\n *\n * @category constructors\n * @since 1.0.0-rc.0\n */\nexport const memoryNone: Memory = {\n bound: false,\n recall: () => Effect.succeed([]),\n remember: () => Effect.void\n}\n\n/**\n * The {@link Memory} reference, defaulting to {@link memoryNone}.\n *\n * @category services\n * @since 1.0.0-rc.0\n */\nexport const Memory = Context.Reference<Memory>(\"@smthrs/harness/Supervisor/Memory\", {\n defaultValue: () => memoryNone\n})\n\n/**\n * The five triggers a reading fires, by name, each with the inequality that\n * fires it. The one rule: the `supervisor` lint monitor crosses on it,\n * {@link nudge} names from it, {@link compacting} reads its context triggers,\n * and the offline replay scores it, so they cannot drift apart.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const triggers = {\n thrashing: (reading: Triggerable): boolean => reading.thrashing >= thrashingAt,\n off_target: (reading: Triggerable): boolean => reading.onTarget <= offTargetAt,\n suspect: (reading: Triggerable): boolean => reading.suspect >= suspectAt,\n outdated_context: (reading: Triggerable): boolean => reading.outdatedContext >= contextAt,\n irrelevant_context: (reading: Triggerable): boolean => reading.irrelevantContext >= contextAt\n} as const\n\n/**\n * The fields of a {@link Reading} the triggers read.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type Triggerable = Pick<Reading, \"thrashing\" | \"onTarget\" | \"suspect\" | \"outdatedContext\" | \"irrelevantContext\">\n\n/**\n * One of {@link triggers}.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type Trigger = keyof typeof triggers\n\n/**\n * The triggers one reading fires, in declaration order.\n *\n * @category conversions\n * @since 1.0.0-rc.0\n */\nexport const triggered = (reading: Triggerable): ReadonlyArray<Trigger> =>\n (Object.keys(triggers) as Array<Trigger>).filter((name) => triggers[name](reading))\n\n/**\n * The triggers that compact the run's context instead of nudging it.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const contextTriggers = [\"outdated_context\", \"irrelevant_context\"] as const\n\n/**\n * One of {@link contextTriggers}.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type ContextTrigger = typeof contextTriggers[number]\n\nconst isContext = (trigger: Trigger): trigger is ContextTrigger =>\n (contextTriggers as ReadonlyArray<Trigger>).includes(trigger)\n\n/**\n * Whether one reading crosses: any trigger but a context one fires. A context\n * trigger compacts the run's context at the next frame instead; see\n * {@link compacting}.\n *\n * @category conversions\n * @since 1.0.0-rc.0\n */\nexport const crosses = (reading: Triggerable): boolean => triggered(reading).some((trigger) => !isContext(trigger))\n\n/**\n * The context triggers one reading fires, in declaration order: why a judged\n * run that is sent this reading compacts at its next frame.\n *\n * @category conversions\n * @since 1.0.0-rc.0\n */\nexport const compacting = (reading: Triggerable): ReadonlyArray<ContextTrigger> => triggered(reading).filter(isContext)\n\n/**\n * The nudge a crossed reading puts in front of the run, naming its evidence.\n *\n * Concise on purpose, and built from counts rather than from the model's\n * prose: what the run is told is what the harness measured, and the reading's\n * probabilities say only which measurements to name.\n *\n * @category conversions\n * @since 1.0.0-rc.0\n */\nexport const nudge = (snapshot: Snapshot, reading: Reading): string => {\n const { signals } = snapshot\n const said: Record<Exclude<Trigger, ContextTrigger>, string> = {\n thrashing: `repeating itself (thrashing ${reading.thrashing.toFixed(2)})`,\n off_target: `drifting from the task (on target ${reading.onTarget.toFixed(2)})`,\n suspect: `standing on suspect evidence (suspect ${reading.suspect.toFixed(2)})`\n }\n const found = triggered(reading).flatMap((name) => isContext(name) ? [] : [said[name]])\n const evidence: Array<string> = []\n if (signals.checksFailing > 0) {\n evidence.push(`${signals.checksFailing} check${signals.checksFailing === 1 ? \"\" : \"s\"} last reported failing`)\n }\n if (signals.failuresUnanswered > 0) {\n evidence.push(\n `${signals.failuresUnanswered} failing check${\n signals.failuresUnanswered === 1 ? \"\" : \"s\"\n } never answered by a pass`\n )\n }\n if (signals.repeatFrames > 0) evidence.push(`${signals.repeatFrames} consecutive frames repeated earlier calls`)\n if (signals.readOnlyFrames > 0) evidence.push(`${signals.readOnlyFrames} consecutive frames changed nothing`)\n if (signals.callsFailed > 0) evidence.push(`${signals.callsFailed} of ${signals.callsSettled} calls failed`)\n evidence.push(`${signals.mutations} frame${signals.mutations === 1 ? \"\" : \"s\"} changed the workspace`)\n // The counts are the ones the run held when frame N closed; by the time the\n // run reads this it has written at least one frame more, so the frame is named.\n return `Supervisor: a reading of this run's last ${snapshot.frames.length} frames, through frame ${signals.frame}, finds it ${\n found.join(\", \")\n }. Evidence at frame ${signals.frame}: ${\n evidence.join(\"; \")\n }. Before the next call, state in one sentence which mechanism you now believe is wrong and which single call would show it; then make that call. Do not re-run a check over an unchanged tree, and do not edit a test to make it pass.`\n}\n\n/**\n * Renders one recalled row as the run reads it.\n *\n * @category conversions\n * @since 1.0.0-rc.0\n */\nexport const recalledInsert = (row: Recalled): string => `From memory of this repository (${row.key}):\\n${row.text}`\n\n/**\n * The head of a frame's cell or prose, bounded by {@link frameBytes}.\n *\n * @category conversions\n * @since 1.0.0-rc.0\n */\nexport const head = (text: string): string => elide.head(text.trim(), frameBytes, \"clipped\")\n\n/**\n * The newest {@link frameBytes} of a frame's prints.\n *\n * @category conversions\n * @since 1.0.0-rc.0\n */\nexport const tail = (text: string): string => {\n const trimmed = text.trim()\n const kept = elide.tailSlice(trimmed, frameBytes)\n return kept.length === trimmed.length ? trimmed : `[… older bytes elided]\\n${kept}`\n}\n\nconst fencedCell = /```(?:cell|typescript|ts|javascript|js)[^\\n]*\\n[\\s\\S]*?(?:```|$)/g\n\n/**\n * What the model wrote around its cell: the reply with every fenced cell\n * removed. The anxiety question reads it, and so does the run-end\n * transcript miner.\n *\n * @category conversions\n * @since 1.0.0-rc.0\n */\nexport const prose = (text: string): string => text.replace(fencedCell, \"\").trim()\n"]}
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Deterministic token accounting for context windows.
3
+ *
4
+ * @since 0.1.0
5
+ */
6
+ import { Schema } from "effect";
7
+ declare const Count_base: Schema.Class<Count, Schema.Struct<{
8
+ readonly value: Schema.Int;
9
+ readonly estimated: Schema.Boolean;
10
+ }>, {}>;
11
+ /**
12
+ * A token count, and whether it was estimated locally or reported by a
13
+ * provider. The flag travels with the number so a consumer never mistakes
14
+ * an approximation for billing data.
15
+ *
16
+ * @category models
17
+ * @since 0.1.0
18
+ * @slop
19
+ */
20
+ export declare class Count extends Count_base {
21
+ }
22
+ declare const Segment_base: Schema.Class<Segment, Schema.Struct<{
23
+ readonly digest: Schema.String;
24
+ readonly zone: Schema.Literals<readonly ["prefix", "tail"]>;
25
+ readonly tokens: typeof Count;
26
+ }>, {}>;
27
+ /**
28
+ * One segment's contribution to the accounting, keyed by its content
29
+ * digest so an unchanged segment keeps its count across turns.
30
+ *
31
+ * @category models
32
+ * @since 0.1.0
33
+ * @slop
34
+ */
35
+ export declare class Segment extends Segment_base {
36
+ }
37
+ declare const Accounting_base: Schema.Class<Accounting, Schema.Struct<{
38
+ readonly prefix: typeof Count;
39
+ readonly tail: typeof Count;
40
+ readonly total: typeof Count;
41
+ readonly bySegment: Schema.$Array<typeof Segment>;
42
+ }>, {}>;
43
+ /**
44
+ * The token totals of a whole context window, split by cache zone and
45
+ * broken down per segment.
46
+ *
47
+ * @category models
48
+ * @since 0.1.0
49
+ * @slop
50
+ */
51
+ export declare class Accounting extends Accounting_base {
52
+ }
53
+ /** A deterministic local approximation, not provider billing data.
54
+ * @category models
55
+ * @since 0.1.0
56
+ * @slop
57
+ */
58
+ export type Estimator = (text: string) => number;
59
+ /**
60
+ * Estimates tokens using four characters per token, with code punctuation and
61
+ * newline density accounting for the typically shorter tokens in source text.
62
+ *
63
+ * @category constructors
64
+ * @since 0.1.0
65
+ * @slop
66
+ */
67
+ export declare const estimate: Estimator;
68
+ /**
69
+ * Counts the tokens of `text`, defaulting to {@link estimate}. The result
70
+ * is always marked estimated.
71
+ *
72
+ * @category constructors
73
+ * @since 0.1.0
74
+ * @slop
75
+ */
76
+ export declare const count: (text: string, estimator?: Estimator) => Count;
77
+ /**
78
+ * Sums per-segment counts into one {@link Accounting}.
79
+ *
80
+ * @category combinators
81
+ * @since 0.1.0
82
+ * @slop
83
+ */
84
+ export declare const combine: (segments: ReadonlyArray<Segment>) => Accounting;
85
+ export {};
86
+ //# sourceMappingURL=Tokens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tokens.d.ts","sourceRoot":"","sources":["../../src/Tokens.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;;;;;AAE/B;;;;;;;;GAQG;AACH,qBAAa,KAAM,SAAQ,UAGzB;CAAG;;;;;;AAEL;;;;;;;GAOG;AACH,qBAAa,OAAQ,SAAQ,YAI3B;CAAG;;;;;;;AAEL;;;;;;;GAOG;AACH,qBAAa,UAAW,SAAQ,eAK9B;CAAG;AAEL;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAA;AAEhD;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,EAAE,SAKtB,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,GAAI,MAAM,MAAM,EAAE,YAAW,SAAoB,KAAG,KACU,CAAA;AAEhF;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,GAAI,UAAU,aAAa,CAAC,OAAO,CAAC,KAAG,UAgB1D,CAAA"}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Deterministic token accounting for context windows.
3
+ *
4
+ * @since 0.1.0
5
+ */
6
+ import { Schema } from "effect";
7
+ /**
8
+ * A token count, and whether it was estimated locally or reported by a
9
+ * provider. The flag travels with the number so a consumer never mistakes
10
+ * an approximation for billing data.
11
+ *
12
+ * @category models
13
+ * @since 0.1.0
14
+ * @slop
15
+ */
16
+ export class Count extends Schema.Class("flows/harness/Tokens/Count")({
17
+ value: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
18
+ estimated: Schema.Boolean
19
+ }) {
20
+ }
21
+ /**
22
+ * One segment's contribution to the accounting, keyed by its content
23
+ * digest so an unchanged segment keeps its count across turns.
24
+ *
25
+ * @category models
26
+ * @since 0.1.0
27
+ * @slop
28
+ */
29
+ export class Segment extends Schema.Class("flows/harness/Tokens/Segment")({
30
+ digest: Schema.String,
31
+ zone: Schema.Literals(["prefix", "tail"]),
32
+ tokens: Count
33
+ }) {
34
+ }
35
+ /**
36
+ * The token totals of a whole context window, split by cache zone and
37
+ * broken down per segment.
38
+ *
39
+ * @category models
40
+ * @since 0.1.0
41
+ * @slop
42
+ */
43
+ export class Accounting extends Schema.Class("flows/harness/Tokens/Accounting")({
44
+ prefix: Count,
45
+ tail: Count,
46
+ total: Count,
47
+ bySegment: Schema.Array(Segment)
48
+ }) {
49
+ }
50
+ /**
51
+ * Estimates tokens using four characters per token, with code punctuation and
52
+ * newline density accounting for the typically shorter tokens in source text.
53
+ *
54
+ * @category constructors
55
+ * @since 0.1.0
56
+ * @slop
57
+ */
58
+ export const estimate = (text) => {
59
+ if (text.length === 0)
60
+ return 0;
61
+ const codeCharacters = (text.match(/[{}()[\];=<>`]/g) ?? []).length;
62
+ const newlines = (text.match(/\n/g) ?? []).length;
63
+ return Math.ceil((text.length + codeCharacters * 0.75 + newlines * 1.5) / 4);
64
+ };
65
+ /**
66
+ * Counts the tokens of `text`, defaulting to {@link estimate}. The result
67
+ * is always marked estimated.
68
+ *
69
+ * @category constructors
70
+ * @since 0.1.0
71
+ * @slop
72
+ */
73
+ export const count = (text, estimator = estimate) => new Count({ value: Math.max(0, Math.ceil(estimator(text))), estimated: true });
74
+ /**
75
+ * Sums per-segment counts into one {@link Accounting}.
76
+ *
77
+ * @category combinators
78
+ * @since 0.1.0
79
+ * @slop
80
+ */
81
+ export const combine = (segments) => {
82
+ const prefix = segments.filter((segment) => segment.zone === "prefix").reduce((sum, segment) => sum + segment.tokens.value, 0);
83
+ const tail = segments.filter((segment) => segment.zone === "tail").reduce((sum, segment) => sum + segment.tokens.value, 0);
84
+ const estimated = segments.some((segment) => segment.tokens.estimated);
85
+ return new Accounting({
86
+ prefix: new Count({ value: prefix, estimated }),
87
+ tail: new Count({ value: tail, estimated }),
88
+ total: new Count({ value: prefix + tail, estimated }),
89
+ bySegment: segments
90
+ });
91
+ };
92
+ //# sourceMappingURL=Tokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tokens.js","sourceRoot":"","sources":["../../src/Tokens.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B;;;;;;;;GAQG;AACH,MAAM,OAAO,KAAM,SAAQ,MAAM,CAAC,KAAK,CAAQ,4BAA4B,CAAC,CAAC;IAC3E,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAA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0\n */\n\nimport { Schema } from \"effect\"\n\n/**\n * A token count, and whether it was estimated locally or reported by a\n * provider. The flag travels with the number so a consumer never mistakes\n * an approximation for billing data.\n *\n * @category models\n * @since 0.1.0\n * @slop\n */\nexport class Count extends Schema.Class<Count>(\"flows/harness/Tokens/Count\")({\n value: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),\n estimated: Schema.Boolean\n}) {}\n\n/**\n * One segment's contribution to the accounting, keyed by its content\n * digest so an unchanged segment keeps its count across turns.\n *\n * @category models\n * @since 0.1.0\n * @slop\n */\nexport class Segment extends Schema.Class<Segment>(\"flows/harness/Tokens/Segment\")({\n digest: Schema.String,\n zone: Schema.Literals([\"prefix\", \"tail\"]),\n tokens: Count\n}) {}\n\n/**\n * The token totals of a whole context window, split by cache zone and\n * broken down per segment.\n *\n * @category models\n * @since 0.1.0\n * @slop\n */\nexport class Accounting extends Schema.Class<Accounting>(\"flows/harness/Tokens/Accounting\")({\n prefix: Count,\n tail: Count,\n total: Count,\n bySegment: Schema.Array(Segment)\n}) {}\n\n/** A deterministic local approximation, not provider billing data.\n * @category models\n * @since 0.1.0\n * @slop\n */\nexport type Estimator = (text: string) => number\n\n/**\n * Estimates tokens using four characters per token, with code punctuation and\n * newline density accounting for the typically shorter tokens in source text.\n *\n * @category constructors\n * @since 0.1.0\n * @slop\n */\nexport const estimate: Estimator = (text) => {\n if (text.length === 0) return 0\n const codeCharacters = (text.match(/[{}()[\\];=<>`]/g) ?? []).length\n const newlines = (text.match(/\\n/g) ?? []).length\n return Math.ceil((text.length + codeCharacters * 0.75 + newlines * 1.5) / 4)\n}\n\n/**\n * Counts the tokens of `text`, defaulting to {@link estimate}. The result\n * is always marked estimated.\n *\n * @category constructors\n * @since 0.1.0\n * @slop\n */\nexport const count = (text: string, estimator: Estimator = estimate): Count =>\n new Count({ value: Math.max(0, Math.ceil(estimator(text))), estimated: true })\n\n/**\n * Sums per-segment counts into one {@link Accounting}.\n *\n * @category combinators\n * @since 0.1.0\n * @slop\n */\nexport const combine = (segments: ReadonlyArray<Segment>): Accounting => {\n const prefix = segments.filter((segment) => segment.zone === \"prefix\").reduce(\n (sum, segment) => sum + segment.tokens.value,\n 0\n )\n const tail = segments.filter((segment) => segment.zone === \"tail\").reduce(\n (sum, segment) => sum + segment.tokens.value,\n 0\n )\n const estimated = segments.some((segment) => segment.tokens.estimated)\n return new Accounting({\n prefix: new Count({ value: prefix, estimated }),\n tail: new Count({ value: tail, estimated }),\n total: new Count({ value: prefix + tail, estimated }),\n bySegment: segments\n })\n}\n"]}
@@ -0,0 +1,171 @@
1
+ /**
2
+ * Transcript projection from durable journal entries.
3
+ *
4
+ * The transcript grows: what the model saw is what it said plus what the
5
+ * harness answered, in journal order. A `continue` used to be able to replace
6
+ * the whole projection with a list of messages the cell had written for its
7
+ * successor, and that branch is gone with the surface that produced it — a
8
+ * journal from those waves still decodes, and its `context` entries are simply
9
+ * not read.
10
+ *
11
+ * @since 0.1.0
12
+ */
13
+ import type { JournalEvent } from "@smthrs/journal";
14
+ import { ModelRequest } from "@smthrs/model";
15
+ import { Result, Schema } from "effect";
16
+ import * as AgentEvent from "./AgentEvent.ts";
17
+ import type * as Cell from "./Cell.ts";
18
+ import type * as EngineLike from "./EngineLike.ts";
19
+ import { HarnessError } from "./HarnessError.ts";
20
+ /**
21
+ * Journal and model-key format after summaries became user context.
22
+ *
23
+ * @category constants
24
+ * @since 1.0.0-rc.0
25
+ */
26
+ export declare const journalVersion = 2;
27
+ /**
28
+ * The event-type namespace a session journals its controller events under.
29
+ *
30
+ * Resume validation reads only the entries under this prefix, and the writer
31
+ * that produces them lives in another package, so the prefix is exported here
32
+ * rather than spelled twice: a writer types its event types as
33
+ * {@link ControlEventType} and a rename fails to compile instead of silently
34
+ * emptying the set {@link validateJournal} inspects.
35
+ *
36
+ * @category constants
37
+ * @since 1.0.0-rc.0
38
+ */
39
+ export declare const controlEventPrefix = "control.agent.";
40
+ /**
41
+ * An event type {@link validateJournal} validates.
42
+ *
43
+ * @category models
44
+ * @since 1.0.0-rc.0
45
+ */
46
+ export type ControlEventType = `${typeof controlEventPrefix}${string}`;
47
+ /**
48
+ * Refuses history whose replay could address different sealed model steps.
49
+ * Historical display projection is separate from permission to resume.
50
+ *
51
+ * @category validation
52
+ * @since 1.0.0-rc.0
53
+ */
54
+ export declare const validateJournal: (entries: ReadonlyArray<JournalEvent.Entry>) => Result.Result<void, HarnessError>;
55
+ /**
56
+ * Stable failures produced while projecting a durable transcript.
57
+ *
58
+ * @category models
59
+ * @since 0.1.0
60
+ * @slop
61
+ */
62
+ export declare const TranscriptErrorCode: Schema.Literals<readonly ["projection_failed"]>;
63
+ /**
64
+ * Stable failures produced while projecting a durable transcript.
65
+ *
66
+ * @category models
67
+ * @since 0.1.0
68
+ * @slop
69
+ */
70
+ export type TranscriptErrorCode = typeof TranscriptErrorCode.Type;
71
+ declare const TranscriptError_base: Schema.Class<TranscriptError, Schema.TaggedStruct<"flows/harness/TranscriptError", {
72
+ readonly code: Schema.Literals<readonly ["projection_failed"]>;
73
+ readonly message: Schema.String;
74
+ readonly cause: Schema.optional<Schema.Defect>;
75
+ }>, import("effect/Cause").YieldableError>;
76
+ /**
77
+ * Stable failures produced while projecting a durable transcript.
78
+ *
79
+ * @category errors
80
+ * @since 0.1.0
81
+ * @slop
82
+ */
83
+ export declare class TranscriptError extends TranscriptError_base {
84
+ }
85
+ /**
86
+ * The kind and message of one projected transcript item.
87
+ *
88
+ * @category models
89
+ * @since 0.1.0
90
+ * @slop
91
+ */
92
+ export interface ProjectedMessage {
93
+ readonly kind: "transcript" | "summary" | "steering";
94
+ readonly message: ModelRequest.Message;
95
+ }
96
+ /**
97
+ * A projection with the compaction replacement identity, when one was recorded.
98
+ *
99
+ * @category models
100
+ * @since 0.1.0
101
+ * @slop
102
+ */
103
+ export interface ProjectedState {
104
+ readonly messages: ReadonlyArray<ProjectedMessage>;
105
+ readonly replaced?: string | undefined;
106
+ readonly cell: CellEvidence;
107
+ }
108
+ /**
109
+ * Schema-decoded cell evidence consumed while rebuilding a journal.
110
+ *
111
+ * @category models
112
+ * @since 0.1.0
113
+ * @slop
114
+ */
115
+ export interface CellEvidence {
116
+ readonly produced: ReadonlyArray<Cell.Source>;
117
+ /**
118
+ * What each frame printed, in journal order.
119
+ *
120
+ * The print buffer is the whole of the context channel: it is what the NEXT
121
+ * model turn reads, and `AgentEvent.CellPrinted` is journaled rather than
122
+ * derived precisely so a projection can rebuild that window without
123
+ * re-running anything. It was missing from this decoder, so a transcript
124
+ * projected from a harness-native journal could not reconstruct what the
125
+ * model saw.
126
+ */
127
+ readonly printed: ReadonlyArray<AgentEvent.CellPrinted>;
128
+ readonly callsStarted: ReadonlyArray<Cell.Call>;
129
+ readonly callsSettled: ReadonlyArray<AgentEvent.CellCallSettled>;
130
+ readonly settled: ReadonlyArray<AgentEvent.CellSettled>;
131
+ readonly transitions: ReadonlyArray<Cell.Transition>;
132
+ readonly suspensions: ReadonlyArray<EngineLike.SuspendReason>;
133
+ readonly aborts: ReadonlyArray<string>;
134
+ }
135
+ /**
136
+ * Projects journal events into their model-visible transcript state as typed
137
+ * data, preserving malformed payload failures instead of throwing.
138
+ *
139
+ * This rebuilds turn structure, the settlement's own message, and every
140
+ * journaled controller demand. The controller also folds frame-local
141
+ * settled-call salvage and the memory-probe alert into failure notes. A raised
142
+ * cell's `bindingPathMiss` hint is live-only, so the projection rebuilds a
143
+ * shorter note exactly where that hint would name a missed binding.
144
+ *
145
+ * A terminal frame has the opposite skew: `observe` appends no observation
146
+ * once the frame budget is spent, while this projection rebuilds its journaled
147
+ * print and settlement. On a run whose last frame was terminal, it therefore
148
+ * over-reports by one trailing user turn. `AgentEvent.TurnClosed.outcome` is the
149
+ * journaled signal a future projection would key on to drop it: `"resolved"`
150
+ * on the terminal frame and `"continue"` otherwise.
151
+ *
152
+ * @category projections
153
+ * @since 0.1.0
154
+ * @slop
155
+ */
156
+ export declare const projectStateResult: (entries: ReadonlyArray<JournalEvent.Entry>) => Result.Result<ProjectedState, TranscriptError>;
157
+ /**
158
+ * Projects model-visible messages in canonical journal sequence order.
159
+ *
160
+ * @category projections
161
+ * @since 0.1.0
162
+ * @slop
163
+ */
164
+ export declare const projectResult: (entries: ReadonlyArray<JournalEvent.Entry>) => Result.Result<ReadonlyArray<ModelRequest.Message>, TranscriptError>;
165
+ /**
166
+ * Pure external-source decoders; never create executable journal identities.
167
+ * @since 1.0.0-rc.1
168
+ */
169
+ export { decodeClaude, decodeCodex } from "./ExternalTranscript.ts";
170
+ export type { Entry as ExternalEntry, Decoded as ExternalDecoded } from "./ExternalTranscript.ts";
171
+ //# sourceMappingURL=Transcript.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Transcript.d.ts","sourceRoot":"","sources":["../../src/Transcript.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AACvC,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,KAAK,IAAI,MAAM,WAAW,CAAA;AACtC,OAAO,KAAK,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAElD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAKhD;;;;;GAKG;AACH,eAAO,MAAM,cAAc,IAAI,CAAA;AAE/B;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,kBAAkB,mBAAmB,CAAA;AAElD;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG,GAAG,OAAO,kBAAkB,GAAG,MAAM,EAAE,CAAA;AAEtE;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAC1B,SAAS,aAAa,CAAC,YAAY,CAAC,KAAK,CAAC,KACzC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,YAAY,CA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