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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (476) hide show
  1. package/CHANGELOG.md +387 -0
  2. package/LICENSE +21 -0
  3. package/README.md +138 -2
  4. package/dist/cjs/AgentEvent.d.ts +3092 -0
  5. package/dist/cjs/AgentEvent.d.ts.map +1 -0
  6. package/dist/cjs/AgentEvent.js +1116 -0
  7. package/dist/cjs/AgentEvent.js.map +7 -0
  8. package/dist/cjs/CallLedger.d.ts +378 -0
  9. package/dist/cjs/CallLedger.d.ts.map +1 -0
  10. package/dist/cjs/CallLedger.js +240 -0
  11. package/dist/cjs/CallLedger.js.map +7 -0
  12. package/dist/cjs/Cell.d.ts +774 -0
  13. package/dist/cjs/Cell.d.ts.map +1 -0
  14. package/dist/cjs/Cell.js +431 -0
  15. package/dist/cjs/Cell.js.map +7 -0
  16. package/dist/cjs/CellCalls.d.ts +115 -0
  17. package/dist/cjs/CellCalls.d.ts.map +1 -0
  18. package/dist/cjs/CellCalls.js +98 -0
  19. package/dist/cjs/CellCalls.js.map +7 -0
  20. package/dist/cjs/CellHistory.d.ts +102 -0
  21. package/dist/cjs/CellHistory.d.ts.map +1 -0
  22. package/dist/cjs/CellHistory.js +54 -0
  23. package/dist/cjs/CellHistory.js.map +7 -0
  24. package/dist/cjs/CellTurn.d.ts +1071 -0
  25. package/dist/cjs/CellTurn.d.ts.map +1 -0
  26. package/dist/cjs/CellTurn.js +2618 -0
  27. package/dist/cjs/CellTurn.js.map +7 -0
  28. package/dist/cjs/CellValidation.d.ts +94 -0
  29. package/dist/cjs/CellValidation.d.ts.map +1 -0
  30. package/dist/cjs/CellValidation.js +218 -0
  31. package/dist/cjs/CellValidation.js.map +7 -0
  32. package/dist/cjs/Compaction.d.ts +158 -0
  33. package/dist/cjs/Compaction.d.ts.map +1 -0
  34. package/dist/cjs/Compaction.js +189 -0
  35. package/dist/cjs/Compaction.js.map +7 -0
  36. package/dist/cjs/CompletionClaim.d.ts +801 -0
  37. package/dist/cjs/CompletionClaim.d.ts.map +1 -0
  38. package/dist/cjs/CompletionClaim.js +303 -0
  39. package/dist/cjs/CompletionClaim.js.map +7 -0
  40. package/dist/cjs/ContextWindow.d.ts +435 -0
  41. package/dist/cjs/ContextWindow.d.ts.map +1 -0
  42. package/dist/cjs/ContextWindow.js +319 -0
  43. package/dist/cjs/ContextWindow.js.map +7 -0
  44. package/dist/cjs/EngineLike.d.ts +546 -0
  45. package/dist/cjs/EngineLike.d.ts.map +1 -0
  46. package/dist/cjs/EngineLike.js +114 -0
  47. package/dist/cjs/EngineLike.js.map +7 -0
  48. package/dist/cjs/ExternalTranscript.d.ts +349 -0
  49. package/dist/cjs/ExternalTranscript.d.ts.map +1 -0
  50. package/dist/cjs/ExternalTranscript.js +826 -0
  51. package/dist/cjs/ExternalTranscript.js.map +7 -0
  52. package/dist/cjs/FailedCall.d.ts +132 -0
  53. package/dist/cjs/FailedCall.d.ts.map +1 -0
  54. package/dist/cjs/FailedCall.js +53 -0
  55. package/dist/cjs/FailedCall.js.map +7 -0
  56. package/dist/cjs/FlowBinding.d.ts +289 -0
  57. package/dist/cjs/FlowBinding.d.ts.map +1 -0
  58. package/dist/cjs/FlowBinding.js +251 -0
  59. package/dist/cjs/FlowBinding.js.map +7 -0
  60. package/dist/cjs/HarnessError.d.ts +57 -0
  61. package/dist/cjs/HarnessError.d.ts.map +1 -0
  62. package/dist/cjs/HarnessError.js +75 -0
  63. package/dist/cjs/HarnessError.js.map +7 -0
  64. package/dist/cjs/Judgement.d.ts +289 -0
  65. package/dist/cjs/Judgement.d.ts.map +1 -0
  66. package/dist/cjs/Judgement.js +240 -0
  67. package/dist/cjs/Judgement.js.map +7 -0
  68. package/dist/cjs/Monitor.d.ts +374 -0
  69. package/dist/cjs/Monitor.d.ts.map +1 -0
  70. package/dist/cjs/Monitor.js +233 -0
  71. package/dist/cjs/Monitor.js.map +7 -0
  72. package/dist/cjs/NarrowedCheck.d.ts +523 -0
  73. package/dist/cjs/NarrowedCheck.d.ts.map +1 -0
  74. package/dist/cjs/NarrowedCheck.js +263 -0
  75. package/dist/cjs/NarrowedCheck.js.map +7 -0
  76. package/dist/cjs/Notifications.d.ts +42 -0
  77. package/dist/cjs/Notifications.d.ts.map +1 -0
  78. package/dist/cjs/Notifications.js +177 -0
  79. package/dist/cjs/Notifications.js.map +7 -0
  80. package/dist/cjs/Plan.d.ts +127 -0
  81. package/dist/cjs/Plan.d.ts.map +1 -0
  82. package/dist/cjs/Plan.js +77 -0
  83. package/dist/cjs/Plan.js.map +7 -0
  84. package/dist/cjs/QuickJSSandbox.d.ts +151 -0
  85. package/dist/cjs/QuickJSSandbox.d.ts.map +1 -0
  86. package/dist/cjs/QuickJSSandbox.js +987 -0
  87. package/dist/cjs/QuickJSSandbox.js.map +7 -0
  88. package/dist/cjs/Relevance.d.ts +213 -0
  89. package/dist/cjs/Relevance.d.ts.map +1 -0
  90. package/dist/cjs/Relevance.js +183 -0
  91. package/dist/cjs/Relevance.js.map +7 -0
  92. package/dist/cjs/Sandbox.d.ts +637 -0
  93. package/dist/cjs/Sandbox.d.ts.map +1 -0
  94. package/dist/cjs/Sandbox.js +260 -0
  95. package/dist/cjs/Sandbox.js.map +7 -0
  96. package/dist/cjs/Steering.d.ts +464 -0
  97. package/dist/cjs/Steering.d.ts.map +1 -0
  98. package/dist/cjs/Steering.js +153 -0
  99. package/dist/cjs/Steering.js.map +7 -0
  100. package/dist/cjs/StructuredOutput.d.ts +252 -0
  101. package/dist/cjs/StructuredOutput.d.ts.map +1 -0
  102. package/dist/cjs/StructuredOutput.js +266 -0
  103. package/dist/cjs/StructuredOutput.js.map +7 -0
  104. package/dist/cjs/Sufficiency.d.ts +195 -0
  105. package/dist/cjs/Sufficiency.d.ts.map +1 -0
  106. package/dist/cjs/Sufficiency.js +110 -0
  107. package/dist/cjs/Sufficiency.js.map +7 -0
  108. package/dist/cjs/Supervisor.d.ts +719 -0
  109. package/dist/cjs/Supervisor.d.ts.map +1 -0
  110. package/dist/cjs/Supervisor.js +313 -0
  111. package/dist/cjs/Supervisor.js.map +7 -0
  112. package/dist/cjs/Tokens.d.ts +86 -0
  113. package/dist/cjs/Tokens.d.ts.map +1 -0
  114. package/dist/cjs/Tokens.js +72 -0
  115. package/dist/cjs/Tokens.js.map +7 -0
  116. package/dist/cjs/Transcript.d.ts +171 -0
  117. package/dist/cjs/Transcript.d.ts.map +1 -0
  118. package/dist/cjs/Transcript.js +342 -0
  119. package/dist/cjs/Transcript.js.map +7 -0
  120. package/dist/cjs/TruncatedOutput.d.ts +186 -0
  121. package/dist/cjs/TruncatedOutput.d.ts.map +1 -0
  122. package/dist/cjs/TruncatedOutput.js +143 -0
  123. package/dist/cjs/TruncatedOutput.js.map +7 -0
  124. package/dist/cjs/UnmovedTree.d.ts +113 -0
  125. package/dist/cjs/UnmovedTree.d.ts.map +1 -0
  126. package/dist/cjs/UnmovedTree.js +38 -0
  127. package/dist/cjs/UnmovedTree.js.map +7 -0
  128. package/dist/cjs/UnresolvedFailure.d.ts +196 -0
  129. package/dist/cjs/UnresolvedFailure.d.ts.map +1 -0
  130. package/dist/cjs/UnresolvedFailure.js +77 -0
  131. package/dist/cjs/UnresolvedFailure.js.map +7 -0
  132. package/dist/cjs/VacuousVerification.d.ts +237 -0
  133. package/dist/cjs/VacuousVerification.d.ts.map +1 -0
  134. package/dist/cjs/VacuousVerification.js +91 -0
  135. package/dist/cjs/VacuousVerification.js.map +7 -0
  136. package/dist/cjs/VariablesPanel.d.ts +117 -0
  137. package/dist/cjs/VariablesPanel.d.ts.map +1 -0
  138. package/dist/cjs/VariablesPanel.js +108 -0
  139. package/dist/cjs/VariablesPanel.js.map +7 -0
  140. package/dist/cjs/index.d.ts +172 -0
  141. package/dist/cjs/index.d.ts.map +1 -0
  142. package/dist/cjs/index.js +99 -0
  143. package/dist/cjs/index.js.map +7 -0
  144. package/dist/cjs/internal/bytes.d.ts +36 -0
  145. package/dist/cjs/internal/bytes.d.ts.map +1 -0
  146. package/dist/cjs/internal/bytes.js +57 -0
  147. package/dist/cjs/internal/bytes.js.map +7 -0
  148. package/dist/cjs/internal/cellPrompt.d.ts +122 -0
  149. package/dist/cjs/internal/cellPrompt.d.ts.map +1 -0
  150. package/dist/cjs/internal/cellPrompt.js +146 -0
  151. package/dist/cjs/internal/cellPrompt.js.map +7 -0
  152. package/dist/cjs/internal/compactable.d.ts +44 -0
  153. package/dist/cjs/internal/compactable.d.ts.map +1 -0
  154. package/dist/cjs/internal/compactable.js +56 -0
  155. package/dist/cjs/internal/compactable.js.map +7 -0
  156. package/dist/cjs/internal/compactionMarks.d.ts +278 -0
  157. package/dist/cjs/internal/compactionMarks.d.ts.map +1 -0
  158. package/dist/cjs/internal/compactionMarks.js +212 -0
  159. package/dist/cjs/internal/compactionMarks.js.map +7 -0
  160. package/dist/cjs/internal/demandText.d.ts +95 -0
  161. package/dist/cjs/internal/demandText.d.ts.map +1 -0
  162. package/dist/cjs/internal/demandText.js +70 -0
  163. package/dist/cjs/internal/demandText.js.map +7 -0
  164. package/dist/cjs/internal/elide.d.ts +109 -0
  165. package/dist/cjs/internal/elide.d.ts.map +1 -0
  166. package/dist/cjs/internal/elide.js +59 -0
  167. package/dist/cjs/internal/elide.js.map +7 -0
  168. package/dist/cjs/internal/frame.d.ts +463 -0
  169. package/dist/cjs/internal/frame.d.ts.map +1 -0
  170. package/dist/cjs/internal/frame.js +514 -0
  171. package/dist/cjs/internal/frame.js.map +7 -0
  172. package/dist/cjs/internal/nonNegativeSafeInt.d.ts +20 -0
  173. package/dist/cjs/internal/nonNegativeSafeInt.d.ts.map +1 -0
  174. package/dist/cjs/internal/nonNegativeSafeInt.js +29 -0
  175. package/dist/cjs/internal/nonNegativeSafeInt.js.map +7 -0
  176. package/dist/cjs/internal/paidUsage.d.ts +52 -0
  177. package/dist/cjs/internal/paidUsage.d.ts.map +1 -0
  178. package/dist/cjs/internal/paidUsage.js +70 -0
  179. package/dist/cjs/internal/paidUsage.js.map +7 -0
  180. package/dist/cjs/internal/printChannel.d.ts +233 -0
  181. package/dist/cjs/internal/printChannel.d.ts.map +1 -0
  182. package/dist/cjs/internal/printChannel.js +165 -0
  183. package/dist/cjs/internal/printChannel.js.map +7 -0
  184. package/dist/cjs/internal/printsObservation.d.ts +26 -0
  185. package/dist/cjs/internal/printsObservation.d.ts.map +1 -0
  186. package/dist/cjs/internal/printsObservation.js +27 -0
  187. package/dist/cjs/internal/printsObservation.js.map +7 -0
  188. package/dist/cjs/internal/refusal.d.ts +40 -0
  189. package/dist/cjs/internal/refusal.d.ts.map +1 -0
  190. package/dist/cjs/internal/refusal.js +45 -0
  191. package/dist/cjs/internal/refusal.js.map +7 -0
  192. package/dist/cjs/internal/supervision.d.ts +174 -0
  193. package/dist/cjs/internal/supervision.d.ts.map +1 -0
  194. package/dist/cjs/internal/supervision.js +402 -0
  195. package/dist/cjs/internal/supervision.js.map +7 -0
  196. package/dist/cjs/internal/unfinishedWork.d.ts +99 -0
  197. package/dist/cjs/internal/unfinishedWork.d.ts.map +1 -0
  198. package/dist/cjs/internal/unfinishedWork.js +80 -0
  199. package/dist/cjs/internal/unfinishedWork.js.map +7 -0
  200. package/dist/cjs/internal/unobservedCall.d.ts +112 -0
  201. package/dist/cjs/internal/unobservedCall.d.ts.map +1 -0
  202. package/dist/cjs/internal/unobservedCall.js +345 -0
  203. package/dist/cjs/internal/unobservedCall.js.map +7 -0
  204. package/dist/cjs/internal/untrustedData.d.ts +14 -0
  205. package/dist/cjs/internal/untrustedData.d.ts.map +1 -0
  206. package/dist/cjs/internal/untrustedData.js +30 -0
  207. package/dist/cjs/internal/untrustedData.js.map +7 -0
  208. package/dist/cjs/package.json +1 -0
  209. package/dist/esm/AgentEvent.d.ts +3092 -0
  210. package/dist/esm/AgentEvent.d.ts.map +1 -0
  211. package/dist/esm/AgentEvent.js +1610 -0
  212. package/dist/esm/AgentEvent.js.map +1 -0
  213. package/dist/esm/CallLedger.d.ts +378 -0
  214. package/dist/esm/CallLedger.d.ts.map +1 -0
  215. package/dist/esm/CallLedger.js +506 -0
  216. package/dist/esm/CallLedger.js.map +1 -0
  217. package/dist/esm/Cell.d.ts +774 -0
  218. package/dist/esm/Cell.d.ts.map +1 -0
  219. package/dist/esm/Cell.js +772 -0
  220. package/dist/esm/Cell.js.map +1 -0
  221. package/dist/esm/CellCalls.d.ts +115 -0
  222. package/dist/esm/CellCalls.d.ts.map +1 -0
  223. package/dist/esm/CellCalls.js +97 -0
  224. package/dist/esm/CellCalls.js.map +1 -0
  225. package/dist/esm/CellHistory.d.ts +102 -0
  226. package/dist/esm/CellHistory.d.ts.map +1 -0
  227. package/dist/esm/CellHistory.js +91 -0
  228. package/dist/esm/CellHistory.js.map +1 -0
  229. package/dist/esm/CellTurn.d.ts +1071 -0
  230. package/dist/esm/CellTurn.d.ts.map +1 -0
  231. package/dist/esm/CellTurn.js +3410 -0
  232. package/dist/esm/CellTurn.js.map +1 -0
  233. package/dist/esm/CellValidation.d.ts +94 -0
  234. package/dist/esm/CellValidation.d.ts.map +1 -0
  235. package/dist/esm/CellValidation.js +335 -0
  236. package/dist/esm/CellValidation.js.map +1 -0
  237. package/dist/esm/Compaction.d.ts +158 -0
  238. package/dist/esm/Compaction.d.ts.map +1 -0
  239. package/dist/esm/Compaction.js +216 -0
  240. package/dist/esm/Compaction.js.map +1 -0
  241. package/dist/esm/CompletionClaim.d.ts +801 -0
  242. package/dist/esm/CompletionClaim.d.ts.map +1 -0
  243. package/dist/esm/CompletionClaim.js +833 -0
  244. package/dist/esm/CompletionClaim.js.map +1 -0
  245. package/dist/esm/ContextWindow.d.ts +435 -0
  246. package/dist/esm/ContextWindow.d.ts.map +1 -0
  247. package/dist/esm/ContextWindow.js +427 -0
  248. package/dist/esm/ContextWindow.js.map +1 -0
  249. package/dist/esm/EngineLike.d.ts +546 -0
  250. package/dist/esm/EngineLike.d.ts.map +1 -0
  251. package/dist/esm/EngineLike.js +218 -0
  252. package/dist/esm/EngineLike.js.map +1 -0
  253. package/dist/esm/ExternalTranscript.d.ts +349 -0
  254. package/dist/esm/ExternalTranscript.d.ts.map +1 -0
  255. package/dist/esm/ExternalTranscript.js +985 -0
  256. package/dist/esm/ExternalTranscript.js.map +1 -0
  257. package/dist/esm/FailedCall.d.ts +132 -0
  258. package/dist/esm/FailedCall.d.ts.map +1 -0
  259. package/dist/esm/FailedCall.js +131 -0
  260. package/dist/esm/FailedCall.js.map +1 -0
  261. package/dist/esm/FlowBinding.d.ts +289 -0
  262. package/dist/esm/FlowBinding.d.ts.map +1 -0
  263. package/dist/esm/FlowBinding.js +376 -0
  264. package/dist/esm/FlowBinding.js.map +1 -0
  265. package/dist/esm/HarnessError.d.ts +57 -0
  266. package/dist/esm/HarnessError.d.ts.map +1 -0
  267. package/dist/esm/HarnessError.js +85 -0
  268. package/dist/esm/HarnessError.js.map +1 -0
  269. package/dist/esm/Judgement.d.ts +289 -0
  270. package/dist/esm/Judgement.d.ts.map +1 -0
  271. package/dist/esm/Judgement.js +305 -0
  272. package/dist/esm/Judgement.js.map +1 -0
  273. package/dist/esm/Monitor.d.ts +374 -0
  274. package/dist/esm/Monitor.d.ts.map +1 -0
  275. package/dist/esm/Monitor.js +370 -0
  276. package/dist/esm/Monitor.js.map +1 -0
  277. package/dist/esm/NarrowedCheck.d.ts +523 -0
  278. package/dist/esm/NarrowedCheck.d.ts.map +1 -0
  279. package/dist/esm/NarrowedCheck.js +612 -0
  280. package/dist/esm/NarrowedCheck.js.map +1 -0
  281. package/dist/esm/Notifications.d.ts +42 -0
  282. package/dist/esm/Notifications.d.ts.map +1 -0
  283. package/dist/esm/Notifications.js +215 -0
  284. package/dist/esm/Notifications.js.map +1 -0
  285. package/dist/esm/Plan.d.ts +127 -0
  286. package/dist/esm/Plan.d.ts.map +1 -0
  287. package/dist/esm/Plan.js +97 -0
  288. package/dist/esm/Plan.js.map +1 -0
  289. package/dist/esm/QuickJSSandbox.d.ts +151 -0
  290. package/dist/esm/QuickJSSandbox.d.ts.map +1 -0
  291. package/dist/esm/QuickJSSandbox.js +1364 -0
  292. package/dist/esm/QuickJSSandbox.js.map +1 -0
  293. package/dist/esm/Relevance.d.ts +213 -0
  294. package/dist/esm/Relevance.d.ts.map +1 -0
  295. package/dist/esm/Relevance.js +254 -0
  296. package/dist/esm/Relevance.js.map +1 -0
  297. package/dist/esm/Sandbox.d.ts +637 -0
  298. package/dist/esm/Sandbox.d.ts.map +1 -0
  299. package/dist/esm/Sandbox.js +464 -0
  300. package/dist/esm/Sandbox.js.map +1 -0
  301. package/dist/esm/Steering.d.ts +464 -0
  302. package/dist/esm/Steering.d.ts.map +1 -0
  303. package/dist/esm/Steering.js +193 -0
  304. package/dist/esm/Steering.js.map +1 -0
  305. package/dist/esm/StructuredOutput.d.ts +252 -0
  306. package/dist/esm/StructuredOutput.d.ts.map +1 -0
  307. package/dist/esm/StructuredOutput.js +430 -0
  308. package/dist/esm/StructuredOutput.js.map +1 -0
  309. package/dist/esm/Sufficiency.d.ts +195 -0
  310. package/dist/esm/Sufficiency.d.ts.map +1 -0
  311. package/dist/esm/Sufficiency.js +207 -0
  312. package/dist/esm/Sufficiency.js.map +1 -0
  313. package/dist/esm/Supervisor.d.ts +719 -0
  314. package/dist/esm/Supervisor.d.ts.map +1 -0
  315. package/dist/esm/Supervisor.js +575 -0
  316. package/dist/esm/Supervisor.js.map +1 -0
  317. package/dist/esm/Tokens.d.ts +86 -0
  318. package/dist/esm/Tokens.d.ts.map +1 -0
  319. package/dist/esm/Tokens.js +92 -0
  320. package/dist/esm/Tokens.js.map +1 -0
  321. package/dist/esm/Transcript.d.ts +171 -0
  322. package/dist/esm/Transcript.d.ts.map +1 -0
  323. package/dist/esm/Transcript.js +424 -0
  324. package/dist/esm/Transcript.js.map +1 -0
  325. package/dist/esm/TruncatedOutput.d.ts +186 -0
  326. package/dist/esm/TruncatedOutput.d.ts.map +1 -0
  327. package/dist/esm/TruncatedOutput.js +257 -0
  328. package/dist/esm/TruncatedOutput.js.map +1 -0
  329. package/dist/esm/UnmovedTree.d.ts +113 -0
  330. package/dist/esm/UnmovedTree.d.ts.map +1 -0
  331. package/dist/esm/UnmovedTree.js +90 -0
  332. package/dist/esm/UnmovedTree.js.map +1 -0
  333. package/dist/esm/UnresolvedFailure.d.ts +196 -0
  334. package/dist/esm/UnresolvedFailure.d.ts.map +1 -0
  335. package/dist/esm/UnresolvedFailure.js +218 -0
  336. package/dist/esm/UnresolvedFailure.js.map +1 -0
  337. package/dist/esm/VacuousVerification.d.ts +237 -0
  338. package/dist/esm/VacuousVerification.d.ts.map +1 -0
  339. package/dist/esm/VacuousVerification.js +245 -0
  340. package/dist/esm/VacuousVerification.js.map +1 -0
  341. package/dist/esm/VariablesPanel.d.ts +117 -0
  342. package/dist/esm/VariablesPanel.d.ts.map +1 -0
  343. package/dist/esm/VariablesPanel.js +142 -0
  344. package/dist/esm/VariablesPanel.js.map +1 -0
  345. package/dist/esm/index.d.ts +172 -0
  346. package/dist/esm/index.d.ts.map +1 -0
  347. package/dist/esm/index.js +172 -0
  348. package/dist/esm/index.js.map +1 -0
  349. package/dist/esm/internal/bytes.d.ts +36 -0
  350. package/dist/esm/internal/bytes.d.ts.map +1 -0
  351. package/dist/esm/internal/bytes.js +70 -0
  352. package/dist/esm/internal/bytes.js.map +1 -0
  353. package/dist/esm/internal/cellPrompt.d.ts +122 -0
  354. package/dist/esm/internal/cellPrompt.d.ts.map +1 -0
  355. package/dist/esm/internal/cellPrompt.js +276 -0
  356. package/dist/esm/internal/cellPrompt.js.map +1 -0
  357. package/dist/esm/internal/compactable.d.ts +44 -0
  358. package/dist/esm/internal/compactable.d.ts.map +1 -0
  359. package/dist/esm/internal/compactable.js +71 -0
  360. package/dist/esm/internal/compactable.js.map +1 -0
  361. package/dist/esm/internal/compactionMarks.d.ts +278 -0
  362. package/dist/esm/internal/compactionMarks.d.ts.map +1 -0
  363. package/dist/esm/internal/compactionMarks.js +317 -0
  364. package/dist/esm/internal/compactionMarks.js.map +1 -0
  365. package/dist/esm/internal/demandText.d.ts +95 -0
  366. package/dist/esm/internal/demandText.d.ts.map +1 -0
  367. package/dist/esm/internal/demandText.js +128 -0
  368. package/dist/esm/internal/demandText.js.map +1 -0
  369. package/dist/esm/internal/elide.d.ts +109 -0
  370. package/dist/esm/internal/elide.d.ts.map +1 -0
  371. package/dist/esm/internal/elide.js +123 -0
  372. package/dist/esm/internal/elide.js.map +1 -0
  373. package/dist/esm/internal/frame.d.ts +463 -0
  374. package/dist/esm/internal/frame.d.ts.map +1 -0
  375. package/dist/esm/internal/frame.js +861 -0
  376. package/dist/esm/internal/frame.js.map +1 -0
  377. package/dist/esm/internal/nonNegativeSafeInt.d.ts +20 -0
  378. package/dist/esm/internal/nonNegativeSafeInt.d.ts.map +1 -0
  379. package/dist/esm/internal/nonNegativeSafeInt.js +20 -0
  380. package/dist/esm/internal/nonNegativeSafeInt.js.map +1 -0
  381. package/dist/esm/internal/paidUsage.d.ts +52 -0
  382. package/dist/esm/internal/paidUsage.d.ts.map +1 -0
  383. package/dist/esm/internal/paidUsage.js +72 -0
  384. package/dist/esm/internal/paidUsage.js.map +1 -0
  385. package/dist/esm/internal/printChannel.d.ts +233 -0
  386. package/dist/esm/internal/printChannel.d.ts.map +1 -0
  387. package/dist/esm/internal/printChannel.js +376 -0
  388. package/dist/esm/internal/printChannel.js.map +1 -0
  389. package/dist/esm/internal/printsObservation.d.ts +26 -0
  390. package/dist/esm/internal/printsObservation.d.ts.map +1 -0
  391. package/dist/esm/internal/printsObservation.js +29 -0
  392. package/dist/esm/internal/printsObservation.js.map +1 -0
  393. package/dist/esm/internal/refusal.d.ts +40 -0
  394. package/dist/esm/internal/refusal.d.ts.map +1 -0
  395. package/dist/esm/internal/refusal.js +47 -0
  396. package/dist/esm/internal/refusal.js.map +1 -0
  397. package/dist/esm/internal/supervision.d.ts +174 -0
  398. package/dist/esm/internal/supervision.d.ts.map +1 -0
  399. package/dist/esm/internal/supervision.js +485 -0
  400. package/dist/esm/internal/supervision.js.map +1 -0
  401. package/dist/esm/internal/unfinishedWork.d.ts +99 -0
  402. package/dist/esm/internal/unfinishedWork.d.ts.map +1 -0
  403. package/dist/esm/internal/unfinishedWork.js +85 -0
  404. package/dist/esm/internal/unfinishedWork.js.map +1 -0
  405. package/dist/esm/internal/unobservedCall.d.ts +112 -0
  406. package/dist/esm/internal/unobservedCall.d.ts.map +1 -0
  407. package/dist/esm/internal/unobservedCall.js +501 -0
  408. package/dist/esm/internal/unobservedCall.js.map +1 -0
  409. package/dist/esm/internal/untrustedData.d.ts +14 -0
  410. package/dist/esm/internal/untrustedData.d.ts.map +1 -0
  411. package/dist/esm/internal/untrustedData.js +15 -0
  412. package/dist/esm/internal/untrustedData.js.map +1 -0
  413. package/docs/README.md +129 -0
  414. package/docs/api.md +1869 -0
  415. package/docs/concepts.md +238 -0
  416. package/docs/external-transcripts.md +245 -0
  417. package/docs/guides/bind-flows.md +167 -0
  418. package/docs/guides/drive-the-loop.md +265 -0
  419. package/docs/guides/run-cells.md +262 -0
  420. package/docs/guides/workerd.md +144 -0
  421. package/docs/installation.md +69 -0
  422. package/docs/quickstart.md +121 -0
  423. package/docs/reference.md +954 -0
  424. package/docs/troubleshooting.md +177 -0
  425. package/package.json +463 -3
  426. package/src/AgentEvent.ts +1772 -0
  427. package/src/CallLedger.ts +560 -0
  428. package/src/Cell.ts +926 -0
  429. package/src/CellCalls.ts +198 -0
  430. package/src/CellHistory.ts +128 -0
  431. package/src/CellTurn.ts +4450 -0
  432. package/src/CellValidation.ts +382 -0
  433. package/src/Compaction.ts +330 -0
  434. package/src/CompletionClaim.ts +1013 -0
  435. package/src/ContextWindow.ts +669 -0
  436. package/src/EngineLike.ts +614 -0
  437. package/src/ExternalTranscript.ts +1142 -0
  438. package/src/FailedCall.ts +163 -0
  439. package/src/FlowBinding.ts +603 -0
  440. package/src/HarnessError.ts +98 -0
  441. package/src/Judgement.ts +526 -0
  442. package/src/Monitor.ts +579 -0
  443. package/src/NarrowedCheck.ts +694 -0
  444. package/src/Notifications.ts +262 -0
  445. package/src/Plan.ts +113 -0
  446. package/src/QuickJSSandbox.ts +1557 -0
  447. package/src/Relevance.ts +352 -0
  448. package/src/Sandbox.ts +908 -0
  449. package/src/Steering.ts +405 -0
  450. package/src/StructuredOutput.ts +484 -0
  451. package/src/Sufficiency.ts +247 -0
  452. package/src/Supervisor.ts +798 -0
  453. package/src/Tokens.ts +108 -0
  454. package/src/Transcript.ts +513 -0
  455. package/src/TruncatedOutput.ts +297 -0
  456. package/src/UnmovedTree.ts +121 -0
  457. package/src/UnresolvedFailure.ts +240 -0
  458. package/src/VacuousVerification.ts +280 -0
  459. package/src/VariablesPanel.ts +165 -0
  460. package/src/index.ts +204 -0
  461. package/src/internal/bytes.ts +70 -0
  462. package/src/internal/cellPrompt.ts +337 -0
  463. package/src/internal/compactable.ts +76 -0
  464. package/src/internal/compactionMarks.ts +454 -0
  465. package/src/internal/demandText.ts +145 -0
  466. package/src/internal/elide.ts +130 -0
  467. package/src/internal/frame.ts +1178 -0
  468. package/src/internal/nonNegativeSafeInt.ts +24 -0
  469. package/src/internal/paidUsage.ts +90 -0
  470. package/src/internal/printChannel.ts +434 -0
  471. package/src/internal/printsObservation.ts +31 -0
  472. package/src/internal/refusal.ts +53 -0
  473. package/src/internal/supervision.ts +652 -0
  474. package/src/internal/unfinishedWork.ts +123 -0
  475. package/src/internal/unobservedCall.ts +536 -0
  476. package/src/internal/untrustedData.ts +19 -0
@@ -0,0 +1,826 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var ExternalTranscript_exports = {};
30
+ __export(ExternalTranscript_exports, {
31
+ AgentKind: () => AgentKind,
32
+ EditedFile: () => EditedFile,
33
+ Entry: () => Entry,
34
+ ExternalTranscriptError: () => ExternalTranscriptError,
35
+ ExternalTranscriptErrorCode: () => ExternalTranscriptErrorCode,
36
+ Part: () => Part,
37
+ claudeReleases: () => claudeReleases,
38
+ claudeStart: () => claudeStart,
39
+ codexReleases: () => codexReleases,
40
+ codexStart: () => codexStart,
41
+ decodeClaude: () => decodeClaude,
42
+ decodeCodex: () => decodeCodex
43
+ });
44
+ module.exports = __toCommonJS(ExternalTranscript_exports);
45
+ var Fault = __toESM(require("@smthrs/flow/Fault"), 1);
46
+ var import_effect = require("effect");
47
+ const AgentKind = import_effect.Schema.Literals(["codex", "claude-code"]);
48
+ const EditedFile = import_effect.Schema.Struct({
49
+ path: import_effect.Schema.String,
50
+ change: import_effect.Schema.Literals(["added", "modified", "deleted", "renamed"]),
51
+ renamed_to: import_effect.Schema.optional(import_effect.Schema.String),
52
+ diff: import_effect.Schema.String
53
+ });
54
+ const Part = import_effect.Schema.Union([
55
+ import_effect.Schema.Struct({ type: import_effect.Schema.Literal("prompt"), text: import_effect.Schema.String }),
56
+ import_effect.Schema.Struct({ type: import_effect.Schema.Literal("goal"), objective: import_effect.Schema.String, status: import_effect.Schema.String }),
57
+ import_effect.Schema.Struct({ type: import_effect.Schema.Literal("text"), text: import_effect.Schema.String, final: import_effect.Schema.Boolean }),
58
+ import_effect.Schema.Struct({ type: import_effect.Schema.Literal("reasoning"), text: import_effect.Schema.String }),
59
+ import_effect.Schema.Struct({ type: import_effect.Schema.Literal("encrypted") }),
60
+ import_effect.Schema.Struct({
61
+ type: import_effect.Schema.Literal("tool"),
62
+ call_id: import_effect.Schema.String,
63
+ command: import_effect.Schema.String,
64
+ /** Set when every part of the command only reads, searches or lists: "Read mvp.md". */
65
+ reads: import_effect.Schema.Array(import_effect.Schema.String),
66
+ status: import_effect.Schema.Literals(["ok", "error", "running"]),
67
+ exit_code: import_effect.Schema.optional(import_effect.Schema.Number),
68
+ output: import_effect.Schema.String,
69
+ duration_ms: import_effect.Schema.Number
70
+ }),
71
+ import_effect.Schema.Struct({
72
+ type: import_effect.Schema.Literal("edit"),
73
+ call_id: import_effect.Schema.String,
74
+ files: import_effect.Schema.Array(EditedFile),
75
+ outcome: import_effect.Schema.Literals(["applied", "failed"])
76
+ }),
77
+ import_effect.Schema.Struct({ type: import_effect.Schema.Literal("search"), call_id: import_effect.Schema.String, query: import_effect.Schema.String }),
78
+ import_effect.Schema.Struct({
79
+ type: import_effect.Schema.Literal("helper"),
80
+ call_id: import_effect.Schema.String,
81
+ agent: import_effect.Schema.String,
82
+ activity: import_effect.Schema.String
83
+ }),
84
+ import_effect.Schema.Struct({ type: import_effect.Schema.Literal("compaction") }),
85
+ import_effect.Schema.Struct({ type: import_effect.Schema.Literal("error"), message: import_effect.Schema.String })
86
+ ]);
87
+ const Entry = import_effect.Schema.Struct({
88
+ origin: import_effect.Schema.Literal("external"),
89
+ agent_kind: AgentKind,
90
+ format_version: import_effect.Schema.String,
91
+ session_id: import_effect.Schema.String,
92
+ /**
93
+ * The record this entry came from: `<session>:<line>`. A record that yields several entries numbers the later
94
+ * ones `<session>:<line>#<n>`.
95
+ */
96
+ source_id: import_effect.Schema.String,
97
+ read_only: import_effect.Schema.Literal(true),
98
+ seq: import_effect.Schema.Number,
99
+ /** Milliseconds since the epoch, from the record. */
100
+ at: import_effect.Schema.Number,
101
+ turn_id: import_effect.Schema.optional(import_effect.Schema.String),
102
+ /** `user` entries are the owner's; `assistant` entries are the agent's. */
103
+ role: import_effect.Schema.Literals(["user", "assistant"]),
104
+ part: Part
105
+ });
106
+ const ExternalTranscriptErrorCode = import_effect.Schema.Literals([
107
+ "missing_version",
108
+ "unsupported_version",
109
+ "unsupported_record",
110
+ "malformed_record"
111
+ ]);
112
+ class ExternalTranscriptError extends import_effect.Schema.TaggedError()("harness/ExternalTranscriptError", {
113
+ code: ExternalTranscriptErrorCode,
114
+ message: import_effect.Schema.String,
115
+ line: import_effect.Schema.Number
116
+ }) {
117
+ }
118
+ Fault.register(
119
+ "harness/ExternalTranscriptError",
120
+ {
121
+ // The agent wrote a transcript this release cannot read: a format change outside Smithers.
122
+ missing_version: "dependency",
123
+ unsupported_version: "dependency",
124
+ unsupported_record: "dependency",
125
+ malformed_record: "dependency"
126
+ }
127
+ );
128
+ const codexReleases = ["0.159", "0.160"];
129
+ const codexStart = { pending: "", line: 0, seq: 0 };
130
+ const record = (value) => typeof value === "object" && value !== null && !Array.isArray(value) ? value : {};
131
+ const text = (value) => typeof value === "string" ? value : "";
132
+ const list = (value) => Array.isArray(value) ? value : [];
133
+ const basename = (path) => path.split("/").filter(Boolean).at(-1) ?? path;
134
+ const parseRow = (raw) => {
135
+ try {
136
+ const parsed = JSON.parse(raw);
137
+ return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : void 0;
138
+ } catch {
139
+ return void 0;
140
+ }
141
+ };
142
+ const helperName = (path) => basename(text(path)) || "helper";
143
+ const reads = (parsed) => {
144
+ const parts = list(parsed).map(record);
145
+ if (parts.length === 0 || parts.some((part) => !["read", "search", "list_files"].includes(text(part["type"])))) {
146
+ return [];
147
+ }
148
+ return parts.map(
149
+ (part) => part["type"] === "read" ? `Read ${text(part["name"]) || basename(text(part["path"]))}` : part["type"] === "search" ? `Searched ${JSON.stringify(text(part["query"]))}${part["path"] ? ` in ${basename(text(part["path"]))}` : ""}` : `Listed ${basename(text(part["path"])) || "files"}`
150
+ );
151
+ };
152
+ const linesOf = (value) => value === "" ? [] : value.replace(/\n$/, "").split("\n");
153
+ const wholeFile = (content, op) => {
154
+ const lines = linesOf(content);
155
+ if (lines.length === 0) return "";
156
+ return `@@ ${op === "+" ? `-0,0 +1,${lines.length}` : `-1,${lines.length} +0,0`} @@
157
+ ${lines.map((line) => `${op}${line}`).join("\n")}
158
+ `;
159
+ };
160
+ const changeOf = (change) => typeof change["move_path"] === "string" ? "renamed" : change["type"] === "add" ? "added" : change["type"] === "delete" ? "deleted" : "modified";
161
+ const codexSkippedRows = [
162
+ "turn_context",
163
+ "world_state",
164
+ "token_usage_record",
165
+ "compacted",
166
+ "inter_agent_communication_metadata"
167
+ ];
168
+ const codexResponseItems = [
169
+ "message",
170
+ "reasoning",
171
+ "custom_tool_call",
172
+ "custom_tool_call_output",
173
+ "function_call",
174
+ "function_call_output",
175
+ "agent_message"
176
+ ];
177
+ const codexSkippedEvents = ["task_started", "token_count", "thread_settings_applied"];
178
+ const codexItems = [
179
+ "UserMessage",
180
+ "AgentMessage",
181
+ "Reasoning",
182
+ "CommandExecution",
183
+ "FileChange",
184
+ "ContextCompaction",
185
+ "SubAgentActivity",
186
+ "CollabAgentToolCall",
187
+ "Extension",
188
+ "McpToolCall",
189
+ "FunctionCallOutput",
190
+ "ImageView"
191
+ ];
192
+ const partsText = (value) => typeof value === "string" ? value : list(value).map((each) => text(record(each)["text"])).filter(Boolean).join("\n");
193
+ const itemPart = (item, took) => {
194
+ switch (item["type"]) {
195
+ case "UserMessage":
196
+ return {
197
+ role: "user",
198
+ part: { type: "prompt", text: list(item["content"]).map((each) => text(record(each)["text"])).join("\n") }
199
+ };
200
+ case "AgentMessage": {
201
+ const content = list(item["content"]).map(record);
202
+ const said = content.map((each) => text(each["text"])).filter(Boolean).join("\n");
203
+ if (content.some((each) => each["type"] === "encrypted_content")) {
204
+ return { role: "assistant", part: { type: "encrypted" } };
205
+ }
206
+ return { role: "assistant", part: { type: "text", text: said, final: item["phase"] === "final_answer" } };
207
+ }
208
+ case "Reasoning": {
209
+ const summary = list(item["summary_text"]).map(text).filter(Boolean).join("\n");
210
+ return summary === "" ? item["encrypted_content"] ? { role: "assistant", part: { type: "encrypted" } } : void 0 : { role: "assistant", part: { type: "reasoning", text: summary } };
211
+ }
212
+ case "CommandExecution": {
213
+ const exit = typeof item["exit_code"] === "number" ? item["exit_code"] : void 0;
214
+ const status = item["status"] === "in_progress" ? "running" : item["status"] === "completed" && (exit ?? 0) === 0 ? "ok" : "error";
215
+ return {
216
+ role: "assistant",
217
+ part: {
218
+ type: "tool",
219
+ call_id: text(item["id"]),
220
+ command: list(item["command"]).map(text).at(-1) ?? "",
221
+ reads: reads(item["parsed_cmd"]),
222
+ status,
223
+ ...exit === void 0 ? {} : { exit_code: exit },
224
+ output: text(item["aggregated_output"]) || text(item["formatted_output"]),
225
+ duration_ms: took
226
+ }
227
+ };
228
+ }
229
+ case "FileChange":
230
+ return {
231
+ role: "assistant",
232
+ part: {
233
+ type: "edit",
234
+ call_id: text(item["id"]),
235
+ outcome: item["status"] === "completed" ? "applied" : "failed",
236
+ files: Object.entries(record(item["changes"])).map(([path, value]) => {
237
+ const change = record(value);
238
+ return {
239
+ path,
240
+ change: changeOf(change),
241
+ ...typeof change["move_path"] === "string" ? { renamed_to: change["move_path"] } : {},
242
+ diff: text(change["unified_diff"]) || wholeFile(text(change["content"]), change["type"] === "delete" ? "-" : "+")
243
+ };
244
+ })
245
+ }
246
+ };
247
+ case "ContextCompaction":
248
+ return { role: "assistant", part: { type: "compaction" } };
249
+ case "SubAgentActivity":
250
+ return {
251
+ role: "assistant",
252
+ part: {
253
+ type: "helper",
254
+ call_id: text(item["id"]),
255
+ agent: helperName(item["agent_path"]),
256
+ activity: text(item["kind"])
257
+ }
258
+ };
259
+ case "CollabAgentToolCall": {
260
+ const agents = list(item["receiver_agents"]).map((each) => helperName(record(each)["agent_path"] ?? each));
261
+ return {
262
+ role: "assistant",
263
+ part: {
264
+ type: "helper",
265
+ call_id: text(item["id"]),
266
+ agent: agents.join(", ") || "helpers",
267
+ activity: text(item["tool"])
268
+ }
269
+ };
270
+ }
271
+ case "Extension": {
272
+ const action = record(item["action"]);
273
+ const query = text(item["query"]) || text(action["query"]) || text(action["pattern"]) || text(action["url"]);
274
+ return { role: "assistant", part: { type: "search", call_id: text(item["id"]), query } };
275
+ }
276
+ case "McpToolCall": {
277
+ const result = record(item["result"]);
278
+ const args = record(item["arguments"]);
279
+ const name = [text(item["server"]), text(item["tool"])].filter(Boolean).join(".");
280
+ const failed = item["status"] !== "completed" || result["isError"] === true;
281
+ return {
282
+ role: "assistant",
283
+ part: {
284
+ type: "tool",
285
+ call_id: text(item["id"]),
286
+ command: Object.keys(args).length === 0 ? name : `${name} ${JSON.stringify(args)}`,
287
+ reads: [],
288
+ status: item["status"] === "in_progress" ? "running" : failed ? "error" : "ok",
289
+ output: partsText(result["content"]) || text(record(item["error"])["message"]),
290
+ duration_ms: took
291
+ }
292
+ };
293
+ }
294
+ case "FunctionCallOutput":
295
+ return {
296
+ role: "assistant",
297
+ part: {
298
+ type: "tool",
299
+ call_id: text(item["id"]),
300
+ command: [text(item["namespace"]), text(item["name"])].filter(Boolean).join("."),
301
+ reads: [],
302
+ status: "ok",
303
+ output: partsText(item["output"]),
304
+ duration_ms: took
305
+ }
306
+ };
307
+ default:
308
+ return {
309
+ role: "assistant",
310
+ part: {
311
+ type: "tool",
312
+ call_id: text(item["id"]),
313
+ command: `view_image ${text(item["path"])}`,
314
+ reads: [`Read ${basename(text(item["path"]))}`],
315
+ status: "ok",
316
+ output: "",
317
+ duration_ms: took
318
+ }
319
+ };
320
+ }
321
+ };
322
+ const scriptFailed = (output) => !/^Script (?:completed|running)\b/.test(output);
323
+ const failedPatchPath = (output) => /apply_patch verification failed: Failed to find expected lines in ([^\n]+):\n/.exec(output)?.[1];
324
+ const profileOf = (profile, releases, release) => {
325
+ const minor = /^(\d+\.\d+)\./.exec(release)?.[1];
326
+ return minor !== void 0 && releases.includes(minor) ? `${profile}/${minor}` : void 0;
327
+ };
328
+ const decodeCodex = (state, chunk) => {
329
+ const lines = (state.pending + chunk).split("\n");
330
+ const pending = lines.pop();
331
+ let { line, seq, session, goal } = state;
332
+ const calls = new Map(Object.entries(state.calls ?? {}));
333
+ const entries = [];
334
+ const fail = (code, message) => import_effect.Result.fail(new ExternalTranscriptError({ code, message, line }));
335
+ const unread = (what, type) => typeof type === "string" && type !== "" ? fail("unsupported_record", `Codex wrote ${what} this release does not read: ${type}`) : fail("malformed_record", `Codex rollout line ${line} names no ${what.replace(/^an? /, "")} type.`);
336
+ for (const raw of lines) {
337
+ line++;
338
+ if (raw.trim() === "") continue;
339
+ const row = parseRow(raw);
340
+ if (row === void 0) return fail("malformed_record", `Codex rollout line ${line} is not a JSON record.`);
341
+ const payload = record(row["payload"]);
342
+ if (row["type"] === "session_meta") {
343
+ const release = text(payload["cli_version"]);
344
+ const format_version2 = profileOf("codex-rollout", codexReleases, release);
345
+ if (format_version2 === void 0) {
346
+ return fail(
347
+ "unsupported_version",
348
+ `Codex ${release || "(no release)"} wrote this rollout; supported: ${codexReleases.join(", ")}.`
349
+ );
350
+ }
351
+ session = { id: text(payload["id"]) || text(payload["session_id"]), format_version: format_version2, cwd: text(payload["cwd"]) };
352
+ continue;
353
+ }
354
+ if (session === void 0) {
355
+ return fail("missing_version", `Codex rollout line ${line} comes before its session record.`);
356
+ }
357
+ const found = [];
358
+ if (row["type"] === "response_item") {
359
+ if (!codexResponseItems.includes(text(payload["type"]))) return unread("a response item", payload["type"]);
360
+ switch (payload["type"]) {
361
+ case "custom_tool_call": {
362
+ const id = payload["call_id"], name = payload["name"], input = payload["input"];
363
+ if (typeof id !== "string" || id === "" || typeof name !== "string" || typeof input !== "string") {
364
+ return fail("malformed_record", `Codex tool request on line ${line} names no call, tool or input.`);
365
+ }
366
+ calls.set(id, { name, input });
367
+ break;
368
+ }
369
+ case "custom_tool_call_output": {
370
+ const id = text(payload["call_id"]);
371
+ const call = calls.get(id);
372
+ calls.delete(id);
373
+ const output = partsText(payload["output"]);
374
+ if (!scriptFailed(output)) break;
375
+ found.push({
376
+ role: "assistant",
377
+ part: {
378
+ type: "tool",
379
+ call_id: id,
380
+ command: call?.input ?? "",
381
+ reads: [],
382
+ status: "error",
383
+ output,
384
+ duration_ms: 0
385
+ }
386
+ });
387
+ const path = failedPatchPath(output);
388
+ if (path !== void 0) {
389
+ found.push({
390
+ role: "assistant",
391
+ part: { type: "edit", call_id: id, files: [{ path, change: "modified", diff: "" }], outcome: "failed" }
392
+ });
393
+ }
394
+ break;
395
+ }
396
+ case "agent_message": {
397
+ const content = payload["content"];
398
+ if (!Array.isArray(content)) {
399
+ return fail("malformed_record", `Codex agent message on line ${line} has no content list.`);
400
+ }
401
+ let encrypted = false;
402
+ const said = [];
403
+ for (const each of content) {
404
+ const block = record(each);
405
+ if (block["type"] === "encrypted_content") {
406
+ if (typeof block["encrypted_content"] !== "string" || block["encrypted_content"] === "") {
407
+ return fail("malformed_record", `Codex encrypted body on line ${line} is empty.`);
408
+ }
409
+ encrypted = true;
410
+ } else if (block["type"] === "input_text" || block["type"] === "output_text") {
411
+ if (typeof block["text"] !== "string") {
412
+ return fail("malformed_record", `Codex agent message on line ${line} has a text part without text.`);
413
+ }
414
+ said.push(block["text"]);
415
+ } else {
416
+ return unread("a message part", block["type"]);
417
+ }
418
+ }
419
+ const turn = text(record(payload["internal_chat_message_metadata_passthrough"])["turn_id"]);
420
+ if (encrypted) found.push({ role: "assistant", part: { type: "encrypted" }, turn });
421
+ else if (said.join("\n") !== "") {
422
+ found.push({ role: "assistant", part: { type: "text", text: said.join("\n"), final: false }, turn });
423
+ }
424
+ break;
425
+ }
426
+ }
427
+ } else if (row["type"] === "event_msg") {
428
+ switch (payload["type"]) {
429
+ case "item_completed": {
430
+ const started = payload["started_at_ms"], completed = payload["completed_at_ms"];
431
+ const took = typeof started === "number" && typeof completed === "number" ? completed - started : 0;
432
+ const item = record(payload["item"]);
433
+ if (!codexItems.includes(text(item["type"]))) return unread("an item", item["type"]);
434
+ if (item["type"] === "UserMessage" || item["type"] === "AgentMessage") {
435
+ const content = item["content"];
436
+ if (!Array.isArray(content)) {
437
+ return fail("malformed_record", `Codex message on line ${line} has no content list.`);
438
+ }
439
+ if (!content.some((each) => record(each)["type"] === "encrypted_content")) {
440
+ for (const each of content) {
441
+ const block = record(each);
442
+ if (block["type"] !== (item["type"] === "UserMessage" ? "text" : "Text")) {
443
+ return unread("a message part", block["type"]);
444
+ }
445
+ if (typeof block["text"] !== "string") {
446
+ return fail("malformed_record", `Codex message on line ${line} has a text part without text.`);
447
+ }
448
+ }
449
+ }
450
+ }
451
+ const part = itemPart(item, Number.isFinite(took) && took > 0 ? took : 0);
452
+ if (part !== void 0) found.push({ ...part, turn: text(payload["turn_id"]) });
453
+ break;
454
+ }
455
+ case "thread_goal_updated": {
456
+ const update = record(payload["goal"]);
457
+ const key = `${text(update["status"])}:${text(update["objective"])}`;
458
+ if (key !== goal) {
459
+ found.push({
460
+ role: "user",
461
+ part: { type: "goal", objective: text(update["objective"]), status: text(update["status"]) }
462
+ });
463
+ }
464
+ goal = key;
465
+ break;
466
+ }
467
+ case "task_complete": {
468
+ if (payload["error"] === void 0 || payload["error"] === null) break;
469
+ const message = text(record(payload["error"])["message"]);
470
+ if (message === "") return fail("malformed_record", `Codex failure on line ${line} gives no message.`);
471
+ found.push({ role: "assistant", part: { type: "error", message }, turn: text(payload["turn_id"]) });
472
+ break;
473
+ }
474
+ case "error":
475
+ case "turn_aborted": {
476
+ const message = text(payload["message"]) || text(payload["reason"]);
477
+ if (message === "") {
478
+ return fail("malformed_record", `Codex failure on line ${line} gives no message or reason.`);
479
+ }
480
+ found.push({ role: "assistant", part: { type: "error", message }, turn: text(payload["turn_id"]) });
481
+ break;
482
+ }
483
+ default:
484
+ if (!codexSkippedEvents.includes(text(payload["type"]))) return unread("an event", payload["type"]);
485
+ }
486
+ } else if (!codexSkippedRows.includes(text(row["type"]))) {
487
+ return unread("a record", row["type"]);
488
+ }
489
+ const at = Date.parse(text(row["timestamp"])) || 0;
490
+ const sessionId = session.id, format_version = session.format_version;
491
+ found.forEach(({ part, role, turn }, index) => {
492
+ entries.push({
493
+ origin: "external",
494
+ agent_kind: "codex",
495
+ format_version,
496
+ session_id: sessionId,
497
+ source_id: index === 0 ? `${sessionId}:${line}` : `${sessionId}:${line}#${index}`,
498
+ read_only: true,
499
+ seq: seq++,
500
+ at,
501
+ ...turn ? { turn_id: turn } : {},
502
+ role,
503
+ part
504
+ });
505
+ });
506
+ }
507
+ return import_effect.Result.succeed({
508
+ state: { pending, line, seq, session, goal, ...calls.size === 0 ? {} : { calls: Object.fromEntries(calls) } },
509
+ entries
510
+ });
511
+ };
512
+ const claudeReleases = ["2.1"];
513
+ const claudeStart = { pending: "", line: 0, seq: 0, calls: {} };
514
+ const blocksOf = (content) => typeof content === "string" ? [{ type: "text", text: content }] : list(content).map(record);
515
+ const textOf = (blocks) => blocks.filter((block) => block["type"] === "text").map((block) => text(block["text"])).join("\n");
516
+ const byOwner = (origin) => origin === void 0 || origin === null || record(origin)["kind"] === "human";
517
+ const replacement = (before, after) => {
518
+ const removed = linesOf(before), added = linesOf(after);
519
+ if (removed.length + added.length === 0) return "";
520
+ return `@@ -1,${removed.length} +1,${added.length} @@
521
+ ${[...removed.map((line) => `-${line}`), ...added.map((line) => `+${line}`)].join("\n")}
522
+ `;
523
+ };
524
+ const count = (value) => typeof value === "number" ? value : 0;
525
+ const reportedPatch = (patch) => list(patch).map(record).map(
526
+ (hunk) => `@@ -${count(hunk["oldStart"])},${count(hunk["oldLines"])} +${count(hunk["newStart"])},${count(hunk["newLines"])} @@
527
+ ${list(hunk["lines"]).map(text).join("\n")}
528
+ `
529
+ ).join("");
530
+ const requestedPatch = (name, input) => {
531
+ switch (name) {
532
+ case "Write":
533
+ return wholeFile(text(input["content"]), "+");
534
+ case "NotebookEdit":
535
+ return wholeFile(text(input["new_source"]), "+");
536
+ case "MultiEdit":
537
+ return list(input["edits"]).map(record).map(
538
+ (edit) => replacement(text(edit["old_string"]), text(edit["new_string"]))
539
+ ).join("");
540
+ default:
541
+ return replacement(text(input["old_string"]), text(input["new_string"]));
542
+ }
543
+ };
544
+ const claudeReads = (name, input) => {
545
+ const path = text(input["path"]);
546
+ switch (name) {
547
+ case "Read":
548
+ return [`Read ${basename(text(input["file_path"]))}`];
549
+ case "Grep":
550
+ case "Glob":
551
+ return [`Searched ${JSON.stringify(text(input["pattern"]))}${path ? ` in ${basename(path)}` : ""}`];
552
+ case "LS":
553
+ return [`Listed ${basename(path) || "files"}`];
554
+ default:
555
+ return [];
556
+ }
557
+ };
558
+ const claudeToolPart = (id, call, result) => {
559
+ const name = call?.name ?? "";
560
+ const input = record(call?.input);
561
+ switch (name) {
562
+ case "Edit":
563
+ case "Write":
564
+ case "MultiEdit":
565
+ case "NotebookEdit":
566
+ return {
567
+ type: "edit",
568
+ call_id: id,
569
+ files: [{
570
+ path: text(input["file_path"]) || text(input["notebook_path"]),
571
+ change: name === "Write" && result.report["type"] === "create" ? "added" : "modified",
572
+ diff: reportedPatch(result.report["structuredPatch"]) || requestedPatch(name, input)
573
+ }],
574
+ outcome: result.failed ? "failed" : "applied"
575
+ };
576
+ case "WebSearch":
577
+ return { type: "search", call_id: id, query: text(input["query"]) };
578
+ case "WebFetch":
579
+ return { type: "search", call_id: id, query: text(input["url"]) };
580
+ case "Task":
581
+ case "Agent":
582
+ return {
583
+ type: "helper",
584
+ call_id: id,
585
+ agent: text(input["subagent_type"]) || "general-purpose",
586
+ activity: text(input["description"])
587
+ };
588
+ }
589
+ const exit = result.failed ? /^Exit code (\d+)/.exec(result.output)?.[1] : void 0;
590
+ return {
591
+ type: "tool",
592
+ call_id: id,
593
+ command: name === "Bash" ? text(input["command"]) : Object.keys(input).length === 0 ? name : `${name} ${JSON.stringify(input)}`,
594
+ reads: claudeReads(name, input),
595
+ status: result.failed ? "error" : "ok",
596
+ ...exit === void 0 ? {} : { exit_code: Number(exit) },
597
+ output: result.output,
598
+ duration_ms: result.took
599
+ };
600
+ };
601
+ const claudeSkippedRows = [
602
+ "mode",
603
+ "permission-mode",
604
+ "atis-latch",
605
+ "last-prompt",
606
+ "ai-title",
607
+ "custom-title",
608
+ "agent-name",
609
+ "queue-operation",
610
+ "file-history-snapshot",
611
+ "file-history-delta",
612
+ "cost-state",
613
+ "pr-link",
614
+ "bridge-session"
615
+ ];
616
+ const claudeSkippedStatus = [
617
+ "turn_duration",
618
+ "informational",
619
+ "stop_hook_summary",
620
+ "away_summary",
621
+ "api_error",
622
+ "local_command",
623
+ "scheduled_task_fire",
624
+ "agents_killed",
625
+ "model_refusal_fallback"
626
+ ];
627
+ const claudeSkippedAttachments = [
628
+ "agent_listing_delta",
629
+ "auto_mode",
630
+ "bash_output_audience_note",
631
+ "batching_reminder_sent",
632
+ "budget_usd",
633
+ "command_permissions",
634
+ "compact_file_reference",
635
+ "credential_org",
636
+ "date",
637
+ "deferred_tools_delta",
638
+ "deferred_tools_record",
639
+ "diagnostics",
640
+ "directory",
641
+ "edited_text_file",
642
+ "environment",
643
+ "file",
644
+ "goal_status",
645
+ "hook_additional_context",
646
+ "hook_cancelled",
647
+ "hook_non_blocking_error",
648
+ "hook_system_message",
649
+ "instructions",
650
+ "invoked_skills",
651
+ "max_turns_reached",
652
+ "mcp_instructions_delta",
653
+ "model",
654
+ "nested_memory",
655
+ "plan_mode",
656
+ "prompt_snapshot",
657
+ "read_truncation_notice",
658
+ "remote_session_change",
659
+ "sandbox_instructions",
660
+ "session_context",
661
+ "silent_turn_reminder",
662
+ "skill_listing",
663
+ "skill_mention",
664
+ "task_reminder",
665
+ "task_status",
666
+ "thinking_drop",
667
+ "thinking_stripped",
668
+ "total_tokens_reminder",
669
+ "ultra_effort_enter",
670
+ "ultra_effort_exit",
671
+ "workflow_keyword_request"
672
+ ];
673
+ const ownerText = (said) => {
674
+ if (/^\[Request interrupted by user[^\]]*\]$/.test(said)) return { type: "error", message: said };
675
+ if (/^<(?:local-command-std(?:out|err)|bash-std(?:out|err))>/.test(said)) return void 0;
676
+ const command = /^<command-(?:name|message)>/.test(said) ? /<command-name>([^<]*)<\/command-name>/.exec(said)?.[1] : void 0;
677
+ if (command !== void 0) {
678
+ const args = /<command-args>([\s\S]*?)<\/command-args>/.exec(said)?.[1]?.trim();
679
+ return { type: "prompt", text: args ? `${command} ${args}` : command };
680
+ }
681
+ const shell = /^<bash-input>([\s\S]*)<\/bash-input>$/.exec(said)?.[1];
682
+ return { type: "prompt", text: shell === void 0 ? said : `!${shell.trim()}` };
683
+ };
684
+ const decodeClaude = (state, chunk) => {
685
+ const lines = (state.pending + chunk).split("\n");
686
+ const pending = lines.pop();
687
+ let { line, seq, session, turn } = state;
688
+ const calls = new Map(Object.entries(state.calls));
689
+ const entries = [];
690
+ const fail = (code, message) => import_effect.Result.fail(new ExternalTranscriptError({ code, message, line }));
691
+ const unread = (what, type) => typeof type === "string" && type !== "" ? fail("unsupported_record", `Claude Code wrote ${what} this release does not read: ${type}`) : fail("malformed_record", `Claude Code transcript line ${line} names no ${what.replace(/^an? /, "")} type.`);
692
+ for (const raw of lines) {
693
+ line++;
694
+ if (raw.trim() === "") continue;
695
+ const row = parseRow(raw);
696
+ if (row === void 0) return fail("malformed_record", `Claude Code transcript line ${line} is not a JSON record.`);
697
+ if (claudeSkippedRows.includes(text(row["type"]))) continue;
698
+ if (!["user", "assistant", "system", "attachment"].includes(text(row["type"]))) {
699
+ return unread("a record", row["type"]);
700
+ }
701
+ if (typeof row["uuid"] !== "string") {
702
+ return fail("malformed_record", `Claude Code transcript line ${line} is a conversation record without a uuid.`);
703
+ }
704
+ const release = text(row["version"]);
705
+ if (release === "") return fail("missing_version", `Claude Code transcript line ${line} names no release.`);
706
+ const format_version = profileOf("claude-code", claudeReleases, release);
707
+ if (format_version === void 0) {
708
+ return fail(
709
+ "unsupported_version",
710
+ `Claude Code ${release} wrote this transcript; supported: ${claudeReleases.join(", ")}.`
711
+ );
712
+ }
713
+ session ??= text(row["sessionId"]) || void 0;
714
+ if (session === void 0) {
715
+ return fail("malformed_record", `Claude Code transcript line ${line} names no session.`);
716
+ }
717
+ const sessionId = session;
718
+ if (row["isSidechain"] === true) continue;
719
+ const at = Date.parse(text(row["timestamp"])) || 0;
720
+ if (row["type"] === "user" && typeof row["promptId"] === "string" && row["promptId"] !== "") {
721
+ turn = row["promptId"];
722
+ }
723
+ const found = [];
724
+ const said = (part) => found.push({ role: "assistant", part });
725
+ const message = record(row["message"]);
726
+ if ((row["type"] === "user" || row["type"] === "assistant") && typeof message["content"] !== "string" && !Array.isArray(message["content"])) {
727
+ return fail("malformed_record", `Claude Code transcript line ${line} has no message content.`);
728
+ }
729
+ switch (row["type"]) {
730
+ case "user": {
731
+ const blocks = blocksOf(message["content"]);
732
+ for (const block of blocks) {
733
+ if (block["type"] === "tool_result") {
734
+ const callId = text(block["tool_use_id"]);
735
+ const call = calls.get(callId);
736
+ calls.delete(callId);
737
+ const content = block["content"];
738
+ said(claudeToolPart(callId, call, {
739
+ failed: block["is_error"] === true,
740
+ output: typeof content === "string" ? content : textOf(list(content).map(record)),
741
+ report: record(row["toolUseResult"]),
742
+ took: call !== void 0 && call.at > 0 && at > call.at ? at - call.at : 0
743
+ }));
744
+ } else if (block["type"] !== "text" && block["type"] !== "image") {
745
+ return unread("a content block", block["type"]);
746
+ }
747
+ }
748
+ const words = textOf(blocks);
749
+ if (words === "" || row["isMeta"] === true || row["isCompactSummary"] === true || !byOwner(row["origin"])) break;
750
+ const part = ownerText(words);
751
+ if (part !== void 0) found.push({ role: part.type === "prompt" ? "user" : "assistant", part });
752
+ break;
753
+ }
754
+ case "assistant": {
755
+ const blocks = blocksOf(message["content"]);
756
+ if (row["isApiErrorMessage"] === true) {
757
+ said({ type: "error", message: textOf(blocks) || text(row["error"]) });
758
+ break;
759
+ }
760
+ for (const block of blocks) {
761
+ switch (block["type"]) {
762
+ case "text":
763
+ if (text(block["text"]) !== "") {
764
+ said({ type: "text", text: text(block["text"]), final: message["stop_reason"] === "end_turn" });
765
+ }
766
+ break;
767
+ case "thinking":
768
+ if (text(block["thinking"]) !== "") said({ type: "reasoning", text: text(block["thinking"]) });
769
+ break;
770
+ case "redacted_thinking":
771
+ break;
772
+ case "fallback":
773
+ break;
774
+ case "tool_use":
775
+ if (typeof block["id"] !== "string" || block["id"] === "") {
776
+ return fail("malformed_record", `Claude Code tool request on line ${line} names no call.`);
777
+ }
778
+ calls.set(block["id"], { name: text(block["name"]), input: block["input"] ?? {}, at });
779
+ break;
780
+ default:
781
+ return unread("a content block", block["type"]);
782
+ }
783
+ }
784
+ break;
785
+ }
786
+ case "system":
787
+ if (row["subtype"] === "compact_boundary") said({ type: "compaction" });
788
+ else if (!claudeSkippedStatus.includes(text(row["subtype"]))) return unread("a status record", row["subtype"]);
789
+ break;
790
+ case "attachment": {
791
+ const attachment = record(row["attachment"]);
792
+ if (attachment["type"] !== "queued_command") {
793
+ if (!claudeSkippedAttachments.includes(text(attachment["type"]))) {
794
+ return unread("an attachment", attachment["type"]);
795
+ }
796
+ break;
797
+ }
798
+ if (attachment["commandMode"] === "prompt" && attachment["isMeta"] !== true && byOwner(attachment["origin"])) {
799
+ const words = textOf(blocksOf(attachment["prompt"]));
800
+ if (words !== "") found.push({ role: "user", part: { type: "prompt", text: words } });
801
+ }
802
+ break;
803
+ }
804
+ }
805
+ found.forEach(({ part, role }, index) => {
806
+ entries.push({
807
+ origin: "external",
808
+ agent_kind: "claude-code",
809
+ format_version,
810
+ session_id: sessionId,
811
+ source_id: index === 0 ? `${sessionId}:${line}` : `${sessionId}:${line}#${index}`,
812
+ read_only: true,
813
+ seq: seq++,
814
+ at,
815
+ ...turn === void 0 ? {} : { turn_id: turn },
816
+ role,
817
+ part
818
+ });
819
+ });
820
+ }
821
+ return import_effect.Result.succeed({
822
+ state: { pending, line, seq, session, turn, calls: Object.fromEntries(calls) },
823
+ entries
824
+ });
825
+ };
826
+ //# sourceMappingURL=ExternalTranscript.js.map