@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,987 @@
1
+ /**
2
+ * The conversations of agents a person runs beside Smithers, decoded from the agent's own transcript file
3
+ * into ordered, read-only entries (mvp.md M-38, ui-components.md T-UI-07 S2).
4
+ *
5
+ * Every entry carries its origin, agent kind, format version, session, source record identity and
6
+ * `read_only: true`; who the owner and the agent participant are is the caller's to say, never the
7
+ * transcript's. Decoding is pure: the caller supplies bytes in any chunking and keeps the returned state,
8
+ * so a growing file is tailed by decoding only what was appended. An incomplete last line waits for more
9
+ * bytes. A complete line that is not a record, a transcript without a version, a version this module does
10
+ * not support, and a record, event, item or content block this module does not name are tagged errors,
11
+ * never a guess: every skipped kind is listed below by name.
12
+ *
13
+ * Codex: `rollout-*.jsonl` files under `$CODEX_HOME/sessions`, profile `codex-rollout/<major.minor>` from
14
+ * the CLI release in `session_meta`. Items come from `event_msg` `item_completed` rows. `response_item` rows
15
+ * repeat them for the model and are skipped, except three the items leave out: a message between agents
16
+ * (`agent_message`), whose encrypted body is one placeholder; a code-mode script that failed
17
+ * (`custom_tool_call_output`), with the request that started it; and nothing else.
18
+ *
19
+ * Claude Code: `<session>.jsonl` files under `~/.claude/projects/<project>`, profile `claude-code/<major.minor>`
20
+ * from the `version` every conversation record carries. A tool call becomes one entry when its result arrives;
21
+ * the named bookkeeping rows outside the conversation chain (no `uuid`) are skipped.
22
+ *
23
+ * @since 1.0.0-rc.1
24
+ */
25
+ import * as Fault from "@smthrs/flow/Fault";
26
+ import { Result, Schema } from "effect";
27
+ /**
28
+ * The agents whose transcripts decode here.
29
+ *
30
+ * @category models
31
+ * @since 1.0.0-rc.1
32
+ */
33
+ export const AgentKind = Schema.Literals(["codex", "claude-code"]);
34
+ /**
35
+ * One edited file as the agent reported it: its path, the kind of change and the unified diff.
36
+ *
37
+ * @category models
38
+ * @since 1.0.0-rc.1
39
+ */
40
+ export const EditedFile = Schema.Struct({
41
+ path: Schema.String,
42
+ change: Schema.Literals(["added", "modified", "deleted", "renamed"]),
43
+ renamed_to: Schema.optional(Schema.String),
44
+ diff: Schema.String
45
+ });
46
+ /**
47
+ * What one entry says. Tool parts keep the agent's correlation id; edits keep the path and the reported
48
+ * outcome; a body the agent encrypted is a placeholder in its place, never dropped.
49
+ *
50
+ * @category models
51
+ * @since 1.0.0-rc.1
52
+ */
53
+ export const Part = Schema.Union([
54
+ Schema.Struct({ type: Schema.Literal("prompt"), text: Schema.String }),
55
+ Schema.Struct({ type: Schema.Literal("goal"), objective: Schema.String, status: Schema.String }),
56
+ Schema.Struct({ type: Schema.Literal("text"), text: Schema.String, final: Schema.Boolean }),
57
+ Schema.Struct({ type: Schema.Literal("reasoning"), text: Schema.String }),
58
+ Schema.Struct({ type: Schema.Literal("encrypted") }),
59
+ Schema.Struct({
60
+ type: Schema.Literal("tool"),
61
+ call_id: Schema.String,
62
+ command: Schema.String,
63
+ /** Set when every part of the command only reads, searches or lists: "Read mvp.md". */
64
+ reads: Schema.Array(Schema.String),
65
+ status: Schema.Literals(["ok", "error", "running"]),
66
+ exit_code: Schema.optional(Schema.Number),
67
+ output: Schema.String,
68
+ duration_ms: Schema.Number
69
+ }),
70
+ Schema.Struct({
71
+ type: Schema.Literal("edit"),
72
+ call_id: Schema.String,
73
+ files: Schema.Array(EditedFile),
74
+ outcome: Schema.Literals(["applied", "failed"])
75
+ }),
76
+ Schema.Struct({ type: Schema.Literal("search"), call_id: Schema.String, query: Schema.String }),
77
+ Schema.Struct({
78
+ type: Schema.Literal("helper"),
79
+ call_id: Schema.String,
80
+ agent: Schema.String,
81
+ activity: Schema.String
82
+ }),
83
+ Schema.Struct({ type: Schema.Literal("compaction") }),
84
+ Schema.Struct({ type: Schema.Literal("error"), message: Schema.String })
85
+ ]);
86
+ /**
87
+ * One read-only entry of an external conversation, in source order.
88
+ *
89
+ * @category models
90
+ * @since 1.0.0-rc.1
91
+ */
92
+ export const Entry = Schema.Struct({
93
+ origin: Schema.Literal("external"),
94
+ agent_kind: AgentKind,
95
+ format_version: Schema.String,
96
+ session_id: Schema.String,
97
+ /**
98
+ * The record this entry came from: `<session>:<line>`. A record that yields several entries numbers the later
99
+ * ones `<session>:<line>#<n>`.
100
+ */
101
+ source_id: Schema.String,
102
+ read_only: Schema.Literal(true),
103
+ seq: Schema.Number,
104
+ /** Milliseconds since the epoch, from the record. */
105
+ at: Schema.Number,
106
+ turn_id: Schema.optional(Schema.String),
107
+ /** `user` entries are the owner's; `assistant` entries are the agent's. */
108
+ role: Schema.Literals(["user", "assistant"]),
109
+ part: Part
110
+ });
111
+ /**
112
+ * Why a transcript did not decode.
113
+ *
114
+ * @category errors
115
+ * @since 1.0.0-rc.1
116
+ */
117
+ export const ExternalTranscriptErrorCode = Schema.Literals([
118
+ "missing_version",
119
+ "unsupported_version",
120
+ "unsupported_record",
121
+ "malformed_record"
122
+ ]);
123
+ /**
124
+ * A transcript this module refuses to read, with the line it stopped at.
125
+ *
126
+ * @category errors
127
+ * @since 1.0.0-rc.1
128
+ */
129
+ export class ExternalTranscriptError extends Schema.TaggedError()("harness/ExternalTranscriptError", {
130
+ code: ExternalTranscriptErrorCode,
131
+ message: Schema.String,
132
+ line: Schema.Number
133
+ }) {
134
+ }
135
+ Fault.register("harness/ExternalTranscriptError", {
136
+ // The agent wrote a transcript this release cannot read: a format change outside Smithers.
137
+ missing_version: "dependency",
138
+ unsupported_version: "dependency",
139
+ unsupported_record: "dependency",
140
+ malformed_record: "dependency"
141
+ });
142
+ /**
143
+ * The Codex CLI releases whose rollout shape this module reads, by `major.minor`.
144
+ *
145
+ * @category constants
146
+ * @since 1.0.0-rc.1
147
+ */
148
+ export const codexReleases = ["0.159", "0.160"];
149
+ /**
150
+ * The state before the first byte.
151
+ *
152
+ * @category constructors
153
+ * @since 1.0.0-rc.1
154
+ */
155
+ export const codexStart = { pending: "", line: 0, seq: 0 };
156
+ const record = (value) => typeof value === "object" && value !== null && !Array.isArray(value) ? value : {};
157
+ const text = (value) => typeof value === "string" ? value : "";
158
+ const list = (value) => Array.isArray(value) ? value : [];
159
+ const basename = (path) => path.split("/").filter(Boolean).at(-1) ?? path;
160
+ /** One complete line as a JSON record, or `undefined` when it is not one. */
161
+ const parseRow = (raw) => {
162
+ try {
163
+ const parsed = JSON.parse(raw);
164
+ return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : undefined;
165
+ }
166
+ catch {
167
+ return undefined;
168
+ }
169
+ };
170
+ const helperName = (path) => basename(text(path)) || "helper";
171
+ const reads = (parsed) => {
172
+ const parts = list(parsed).map(record);
173
+ if (parts.length === 0 || parts.some((part) => !["read", "search", "list_files"].includes(text(part["type"])))) {
174
+ return [];
175
+ }
176
+ return parts.map((part) => part["type"] === "read"
177
+ ? `Read ${text(part["name"]) || basename(text(part["path"]))}`
178
+ : part["type"] === "search"
179
+ ? `Searched ${JSON.stringify(text(part["query"]))}${part["path"] ? ` in ${basename(text(part["path"]))}` : ""}`
180
+ : `Listed ${basename(text(part["path"])) || "files"}`);
181
+ };
182
+ /** Lines of an edit string, without the newline that ends the last one. */
183
+ const linesOf = (value) => value === "" ? [] : value.replace(/\n$/, "").split("\n");
184
+ /** An added or deleted file reports its content, not a diff: one hunk of the whole file, all `+` or all `-`. */
185
+ const wholeFile = (content, op) => {
186
+ const lines = linesOf(content);
187
+ if (lines.length === 0)
188
+ return "";
189
+ return `@@ ${op === "+" ? `-0,0 +1,${lines.length}` : `-1,${lines.length} +0,0`} @@\n${lines.map((line) => `${op}${line}`).join("\n")}\n`;
190
+ };
191
+ const changeOf = (change) => typeof change["move_path"] === "string"
192
+ ? "renamed"
193
+ : change["type"] === "add"
194
+ ? "added"
195
+ : change["type"] === "delete"
196
+ ? "deleted"
197
+ : "modified";
198
+ /**
199
+ * The Codex record, event and item kinds this module names. Each list is closed: a kind outside it is a tagged
200
+ * `unsupported_record`, so a new kind stops the import where a person can see it instead of vanishing.
201
+ */
202
+ const codexSkippedRows = [
203
+ "turn_context",
204
+ "world_state",
205
+ "token_usage_record",
206
+ "compacted",
207
+ "inter_agent_communication_metadata"
208
+ ];
209
+ const codexResponseItems = [
210
+ "message",
211
+ "reasoning",
212
+ "custom_tool_call",
213
+ "custom_tool_call_output",
214
+ "function_call",
215
+ "function_call_output",
216
+ "agent_message"
217
+ ];
218
+ const codexSkippedEvents = ["task_started", "token_count", "thread_settings_applied"];
219
+ const codexItems = [
220
+ "UserMessage",
221
+ "AgentMessage",
222
+ "Reasoning",
223
+ "CommandExecution",
224
+ "FileChange",
225
+ "ContextCompaction",
226
+ "SubAgentActivity",
227
+ "CollabAgentToolCall",
228
+ "Extension",
229
+ "McpToolCall",
230
+ "FunctionCallOutput",
231
+ "ImageView"
232
+ ];
233
+ /** The text of a list of `{type, text}` parts, as Codex and MCP servers write tool output. */
234
+ const partsText = (value) => typeof value === "string" ? value : list(value).map((each) => text(record(each)["text"])).filter(Boolean).join("\n");
235
+ /**
236
+ * One completed Codex item as the part it reports, or `undefined` for items with nothing to show. `took` is the
237
+ * wall time Codex recorded around the item (`completed_at_ms - started_at_ms`). The caller has checked the item's
238
+ * type against `codexItems`.
239
+ */
240
+ const itemPart = (item, took) => {
241
+ switch (item["type"]) {
242
+ case "UserMessage":
243
+ return {
244
+ role: "user",
245
+ part: { type: "prompt", text: list(item["content"]).map((each) => text(record(each)["text"])).join("\n") }
246
+ };
247
+ case "AgentMessage": {
248
+ const content = list(item["content"]).map(record);
249
+ const said = content.map((each) => text(each["text"])).filter(Boolean).join("\n");
250
+ if (content.some((each) => each["type"] === "encrypted_content")) {
251
+ return { role: "assistant", part: { type: "encrypted" } };
252
+ }
253
+ return { role: "assistant", part: { type: "text", text: said, final: item["phase"] === "final_answer" } };
254
+ }
255
+ case "Reasoning": {
256
+ // Codex keeps reasoning encrypted; only a summary it chose to write is readable.
257
+ const summary = list(item["summary_text"]).map(text).filter(Boolean).join("\n");
258
+ return summary === ""
259
+ ? (item["encrypted_content"] ? { role: "assistant", part: { type: "encrypted" } } : undefined)
260
+ : { role: "assistant", part: { type: "reasoning", text: summary } };
261
+ }
262
+ case "CommandExecution": {
263
+ const exit = typeof item["exit_code"] === "number" ? item["exit_code"] : undefined;
264
+ // Codex reports in_progress, completed, failed and declined; only a clean completion is ok.
265
+ const status = item["status"] === "in_progress"
266
+ ? "running"
267
+ : item["status"] === "completed" && (exit ?? 0) === 0
268
+ ? "ok"
269
+ : "error";
270
+ return {
271
+ role: "assistant",
272
+ part: {
273
+ type: "tool",
274
+ call_id: text(item["id"]),
275
+ command: list(item["command"]).map(text).at(-1) ?? "",
276
+ reads: reads(item["parsed_cmd"]),
277
+ status,
278
+ ...(exit === undefined ? {} : { exit_code: exit }),
279
+ output: text(item["aggregated_output"]) || text(item["formatted_output"]),
280
+ duration_ms: took
281
+ }
282
+ };
283
+ }
284
+ case "FileChange":
285
+ return {
286
+ role: "assistant",
287
+ part: {
288
+ type: "edit",
289
+ call_id: text(item["id"]),
290
+ outcome: item["status"] === "completed" ? "applied" : "failed",
291
+ files: Object.entries(record(item["changes"])).map(([path, value]) => {
292
+ const change = record(value);
293
+ return {
294
+ path,
295
+ change: changeOf(change),
296
+ ...(typeof change["move_path"] === "string" ? { renamed_to: change["move_path"] } : {}),
297
+ diff: text(change["unified_diff"]) ||
298
+ wholeFile(text(change["content"]), change["type"] === "delete" ? "-" : "+")
299
+ };
300
+ })
301
+ }
302
+ };
303
+ case "ContextCompaction":
304
+ return { role: "assistant", part: { type: "compaction" } };
305
+ case "SubAgentActivity":
306
+ return {
307
+ role: "assistant",
308
+ part: {
309
+ type: "helper",
310
+ call_id: text(item["id"]),
311
+ agent: helperName(item["agent_path"]),
312
+ activity: text(item["kind"])
313
+ }
314
+ };
315
+ case "CollabAgentToolCall": {
316
+ const agents = list(item["receiver_agents"]).map((each) => helperName(record(each)["agent_path"] ?? each));
317
+ return {
318
+ role: "assistant",
319
+ part: {
320
+ type: "helper",
321
+ call_id: text(item["id"]),
322
+ agent: agents.join(", ") || "helpers",
323
+ activity: text(item["tool"])
324
+ }
325
+ };
326
+ }
327
+ case "Extension": {
328
+ const action = record(item["action"]);
329
+ const query = text(item["query"]) || text(action["query"]) || text(action["pattern"]) || text(action["url"]);
330
+ return { role: "assistant", part: { type: "search", call_id: text(item["id"]), query } };
331
+ }
332
+ case "McpToolCall": {
333
+ // A tool another server ran for the agent: its request and the result the server reported.
334
+ const result = record(item["result"]);
335
+ const args = record(item["arguments"]);
336
+ const name = [text(item["server"]), text(item["tool"])].filter(Boolean).join(".");
337
+ const failed = item["status"] !== "completed" || result["isError"] === true;
338
+ return {
339
+ role: "assistant",
340
+ part: {
341
+ type: "tool",
342
+ call_id: text(item["id"]),
343
+ command: Object.keys(args).length === 0 ? name : `${name} ${JSON.stringify(args)}`,
344
+ reads: [],
345
+ status: item["status"] === "in_progress" ? "running" : failed ? "error" : "ok",
346
+ output: partsText(result["content"]) || text(record(item["error"])["message"]),
347
+ duration_ms: took
348
+ }
349
+ };
350
+ }
351
+ case "FunctionCallOutput":
352
+ return {
353
+ role: "assistant",
354
+ part: {
355
+ type: "tool",
356
+ call_id: text(item["id"]),
357
+ command: [text(item["namespace"]), text(item["name"])].filter(Boolean).join("."),
358
+ reads: [],
359
+ status: "ok",
360
+ output: partsText(item["output"]),
361
+ duration_ms: took
362
+ }
363
+ };
364
+ default:
365
+ // ImageView, the one kind of `codexItems` left: an image the agent looked at.
366
+ return {
367
+ role: "assistant",
368
+ part: {
369
+ type: "tool",
370
+ call_id: text(item["id"]),
371
+ command: `view_image ${text(item["path"])}`,
372
+ reads: [`Read ${basename(text(item["path"]))}`],
373
+ status: "ok",
374
+ output: "",
375
+ duration_ms: took
376
+ }
377
+ };
378
+ }
379
+ };
380
+ /**
381
+ * The first line of a code-mode output says how the script ended. A script that finished, or one still running in
382
+ * a cell, repeats what completed items already report; any other ending is a failure only this row records.
383
+ */
384
+ const scriptFailed = (output) => !/^Script (?:completed|running)\b/.test(output);
385
+ /** The file a failed `apply_patch` names, when the report is that failure. */
386
+ const failedPatchPath = (output) => /apply_patch verification failed: Failed to find expected lines in ([^\n]+):\n/.exec(output)?.[1];
387
+ /** The adapter profile `<profile>/<major.minor>` for a supported release, or `undefined`. */
388
+ const profileOf = (profile, releases, release) => {
389
+ const minor = /^(\d+\.\d+)\./.exec(release)?.[1];
390
+ return minor !== undefined && releases.includes(minor) ? `${profile}/${minor}` : undefined;
391
+ };
392
+ /**
393
+ * Decode the next chunk of a Codex rollout. Pass `codexStart` with the first chunk and the returned state
394
+ * with each following one; any partition of the same bytes yields the same entries.
395
+ *
396
+ * @category decoding
397
+ * @since 1.0.0-rc.1
398
+ */
399
+ export const decodeCodex = (state, chunk) => {
400
+ const lines = (state.pending + chunk).split("\n");
401
+ const pending = lines.pop();
402
+ let { line, seq, session, goal } = state;
403
+ const calls = new Map(Object.entries(state.calls ?? {}));
404
+ const entries = [];
405
+ const fail = (code, message) => Result.fail(new ExternalTranscriptError({ code, message, line }));
406
+ /** A kind outside the named lists; a kind that is not even a string is a record of another shape. */
407
+ const unread = (what, type) => typeof type === "string" && type !== ""
408
+ ? fail("unsupported_record", `Codex wrote ${what} this release does not read: ${type}`)
409
+ : fail("malformed_record", `Codex rollout line ${line} names no ${what.replace(/^an? /, "")} type.`);
410
+ for (const raw of lines) {
411
+ line++;
412
+ if (raw.trim() === "")
413
+ continue;
414
+ const row = parseRow(raw);
415
+ if (row === undefined)
416
+ return fail("malformed_record", `Codex rollout line ${line} is not a JSON record.`);
417
+ const payload = record(row["payload"]);
418
+ if (row["type"] === "session_meta") {
419
+ const release = text(payload["cli_version"]);
420
+ const format_version = profileOf("codex-rollout", codexReleases, release);
421
+ if (format_version === undefined) {
422
+ return fail("unsupported_version", `Codex ${release || "(no release)"} wrote this rollout; supported: ${codexReleases.join(", ")}.`);
423
+ }
424
+ session = { id: text(payload["id"]) || text(payload["session_id"]), format_version, cwd: text(payload["cwd"]) };
425
+ continue;
426
+ }
427
+ if (session === undefined) {
428
+ return fail("missing_version", `Codex rollout line ${line} comes before its session record.`);
429
+ }
430
+ const found = [];
431
+ if (row["type"] === "response_item") {
432
+ if (!codexResponseItems.includes(text(payload["type"])))
433
+ return unread("a response item", payload["type"]);
434
+ switch (payload["type"]) {
435
+ case "custom_tool_call": {
436
+ const id = payload["call_id"], name = payload["name"], input = payload["input"];
437
+ if (typeof id !== "string" || id === "" || typeof name !== "string" || typeof input !== "string") {
438
+ return fail("malformed_record", `Codex tool request on line ${line} names no call, tool or input.`);
439
+ }
440
+ calls.set(id, { name, input });
441
+ break;
442
+ }
443
+ case "custom_tool_call_output": {
444
+ const id = text(payload["call_id"]);
445
+ const call = calls.get(id);
446
+ calls.delete(id);
447
+ const output = partsText(payload["output"]);
448
+ // A script that finished repeats its completed items. One that failed has no item: keep its report with
449
+ // the request that started it, so a failed edit is never silently missing.
450
+ if (!scriptFailed(output))
451
+ break;
452
+ found.push({
453
+ role: "assistant",
454
+ part: {
455
+ type: "tool",
456
+ call_id: id,
457
+ command: call?.input ?? "",
458
+ reads: [],
459
+ status: "error",
460
+ output,
461
+ duration_ms: 0
462
+ }
463
+ });
464
+ const path = failedPatchPath(output);
465
+ if (path !== undefined) {
466
+ // The report names the file and no change: the diff is empty because nothing was observed to change.
467
+ found.push({
468
+ role: "assistant",
469
+ part: { type: "edit", call_id: id, files: [{ path, change: "modified", diff: "" }], outcome: "failed" }
470
+ });
471
+ }
472
+ break;
473
+ }
474
+ case "agent_message": {
475
+ // A message between this agent and one it works with. Codex encrypts the body; the header beside it
476
+ // names agents, and a name in a transcript confers nothing.
477
+ const content = payload["content"];
478
+ if (!Array.isArray(content)) {
479
+ return fail("malformed_record", `Codex agent message on line ${line} has no content list.`);
480
+ }
481
+ let encrypted = false;
482
+ const said = [];
483
+ for (const each of content) {
484
+ const block = record(each);
485
+ if (block["type"] === "encrypted_content") {
486
+ if (typeof block["encrypted_content"] !== "string" || block["encrypted_content"] === "") {
487
+ return fail("malformed_record", `Codex encrypted body on line ${line} is empty.`);
488
+ }
489
+ encrypted = true;
490
+ }
491
+ else if (block["type"] === "input_text" || block["type"] === "output_text") {
492
+ if (typeof block["text"] !== "string") {
493
+ return fail("malformed_record", `Codex agent message on line ${line} has a text part without text.`);
494
+ }
495
+ said.push(block["text"]);
496
+ }
497
+ else {
498
+ return unread("a message part", block["type"]);
499
+ }
500
+ }
501
+ const turn = text(record(payload["internal_chat_message_metadata_passthrough"])["turn_id"]);
502
+ // One placeholder stands for the whole body, header included: nothing readable is shown beside it.
503
+ if (encrypted)
504
+ found.push({ role: "assistant", part: { type: "encrypted" }, turn });
505
+ else if (said.join("\n") !== "") {
506
+ found.push({ role: "assistant", part: { type: "text", text: said.join("\n"), final: false }, turn });
507
+ }
508
+ break;
509
+ }
510
+ // message, reasoning, function_call, function_call_output: the model-facing copy of completed items.
511
+ }
512
+ }
513
+ else if (row["type"] === "event_msg") {
514
+ switch (payload["type"]) {
515
+ case "item_completed": {
516
+ const started = payload["started_at_ms"], completed = payload["completed_at_ms"];
517
+ const took = typeof started === "number" && typeof completed === "number" ? completed - started : 0;
518
+ const item = record(payload["item"]);
519
+ if (!codexItems.includes(text(item["type"])))
520
+ return unread("an item", item["type"]);
521
+ if (item["type"] === "UserMessage" || item["type"] === "AgentMessage") {
522
+ const content = item["content"];
523
+ if (!Array.isArray(content)) {
524
+ return fail("malformed_record", `Codex message on line ${line} has no content list.`);
525
+ }
526
+ // Ciphertext stands for the whole body, so the parts beside it are not read.
527
+ if (!content.some((each) => record(each)["type"] === "encrypted_content")) {
528
+ for (const each of content) {
529
+ const block = record(each);
530
+ if (block["type"] !== (item["type"] === "UserMessage" ? "text" : "Text")) {
531
+ return unread("a message part", block["type"]);
532
+ }
533
+ if (typeof block["text"] !== "string") {
534
+ return fail("malformed_record", `Codex message on line ${line} has a text part without text.`);
535
+ }
536
+ }
537
+ }
538
+ }
539
+ const part = itemPart(item, Number.isFinite(took) && took > 0 ? took : 0);
540
+ if (part !== undefined)
541
+ found.push({ ...part, turn: text(payload["turn_id"]) });
542
+ break;
543
+ }
544
+ case "thread_goal_updated": {
545
+ const update = record(payload["goal"]);
546
+ const key = `${text(update["status"])}:${text(update["objective"])}`;
547
+ // Codex repeats a goal on every usage update; only a new objective or status is news.
548
+ if (key !== goal) {
549
+ found.push({
550
+ role: "user",
551
+ part: { type: "goal", objective: text(update["objective"]), status: text(update["status"]) }
552
+ });
553
+ }
554
+ goal = key;
555
+ break;
556
+ }
557
+ case "task_complete": {
558
+ // A turn's end repeats its last message, and carries the failure when the turn ended in one: a usage
559
+ // limit, a model at capacity, a refused request.
560
+ if (payload["error"] === undefined || payload["error"] === null)
561
+ break;
562
+ const message = text(record(payload["error"])["message"]);
563
+ if (message === "")
564
+ return fail("malformed_record", `Codex failure on line ${line} gives no message.`);
565
+ found.push({ role: "assistant", part: { type: "error", message }, turn: text(payload["turn_id"]) });
566
+ break;
567
+ }
568
+ case "error":
569
+ case "turn_aborted": {
570
+ // What Codex said went wrong, or why the turn stopped ("interrupted").
571
+ const message = text(payload["message"]) || text(payload["reason"]);
572
+ if (message === "") {
573
+ return fail("malformed_record", `Codex failure on line ${line} gives no message or reason.`);
574
+ }
575
+ found.push({ role: "assistant", part: { type: "error", message }, turn: text(payload["turn_id"]) });
576
+ break;
577
+ }
578
+ default:
579
+ if (!codexSkippedEvents.includes(text(payload["type"])))
580
+ return unread("an event", payload["type"]);
581
+ }
582
+ }
583
+ else if (!codexSkippedRows.includes(text(row["type"]))) {
584
+ return unread("a record", row["type"]);
585
+ }
586
+ const at = Date.parse(text(row["timestamp"])) || 0;
587
+ const sessionId = session.id, format_version = session.format_version;
588
+ found.forEach(({ part, role, turn }, index) => {
589
+ entries.push({
590
+ origin: "external",
591
+ agent_kind: "codex",
592
+ format_version,
593
+ session_id: sessionId,
594
+ source_id: index === 0 ? `${sessionId}:${line}` : `${sessionId}:${line}#${index}`,
595
+ read_only: true,
596
+ seq: seq++,
597
+ at,
598
+ ...(turn ? { turn_id: turn } : {}),
599
+ role,
600
+ part
601
+ });
602
+ });
603
+ }
604
+ return Result.succeed({
605
+ state: { pending, line, seq, session, goal, ...(calls.size === 0 ? {} : { calls: Object.fromEntries(calls) }) },
606
+ entries
607
+ });
608
+ };
609
+ /**
610
+ * The Claude Code release lines whose transcript shape this module reads, by `major.minor`.
611
+ *
612
+ * @category constants
613
+ * @since 1.0.0-rc.1
614
+ */
615
+ export const claudeReleases = ["2.1"];
616
+ /**
617
+ * The state before the first byte.
618
+ *
619
+ * @category constructors
620
+ * @since 1.0.0-rc.1
621
+ */
622
+ export const claudeStart = { pending: "", line: 0, seq: 0, calls: {} };
623
+ /** Content as blocks: Claude Code writes a plain prompt as a string and everything else as a block list. */
624
+ const blocksOf = (content) => typeof content === "string" ? [{ type: "text", text: content }] : list(content).map(record);
625
+ const textOf = (blocks) => blocks.filter((block) => block["type"] === "text").map((block) => text(block["text"])).join("\n");
626
+ /** A user turn is the owner's when Claude Code classified it human or did not classify it. */
627
+ const byOwner = (origin) => origin === undefined || origin === null || record(origin)["kind"] === "human";
628
+ /**
629
+ * A requested replacement as one hunk. Claude Code reports no position for a replacement it did not apply, so the
630
+ * hunk starts at line 1.
631
+ */
632
+ const replacement = (before, after) => {
633
+ const removed = linesOf(before), added = linesOf(after);
634
+ if (removed.length + added.length === 0)
635
+ return "";
636
+ return `@@ -1,${removed.length} +1,${added.length} @@\n${[...removed.map((line) => `-${line}`), ...added.map((line) => `+${line}`)].join("\n")}\n`;
637
+ };
638
+ const count = (value) => typeof value === "number" ? value : 0;
639
+ /** The hunks Claude Code reported for an applied edit (`toolUseResult.structuredPatch`). */
640
+ const reportedPatch = (patch) => list(patch).map(record).map((hunk) => `@@ -${count(hunk["oldStart"])},${count(hunk["oldLines"])} +${count(hunk["newStart"])},${count(hunk["newLines"])} @@\n${list(hunk["lines"]).map(text).join("\n")}\n`).join("");
641
+ /** The edit the agent asked for, from the tool input, when Claude Code reported no hunks. */
642
+ const requestedPatch = (name, input) => {
643
+ switch (name) {
644
+ case "Write":
645
+ return wholeFile(text(input["content"]), "+");
646
+ case "NotebookEdit":
647
+ return wholeFile(text(input["new_source"]), "+");
648
+ case "MultiEdit":
649
+ return list(input["edits"]).map(record).map((edit) => replacement(text(edit["old_string"]), text(edit["new_string"]))).join("");
650
+ default:
651
+ return replacement(text(input["old_string"]), text(input["new_string"]));
652
+ }
653
+ };
654
+ /** The reads label of a tool that only reads, searches or lists, or none. */
655
+ const claudeReads = (name, input) => {
656
+ const path = text(input["path"]);
657
+ switch (name) {
658
+ case "Read":
659
+ return [`Read ${basename(text(input["file_path"]))}`];
660
+ case "Grep":
661
+ case "Glob":
662
+ return [`Searched ${JSON.stringify(text(input["pattern"]))}${path ? ` in ${basename(path)}` : ""}`];
663
+ case "LS":
664
+ return [`Listed ${basename(path) || "files"}`];
665
+ default:
666
+ return [];
667
+ }
668
+ };
669
+ /** One finished tool call: its `tool_use` (when this transcript holds it) and the `tool_result` that ended it. */
670
+ const claudeToolPart = (id, call, result) => {
671
+ const name = call?.name ?? "";
672
+ const input = record(call?.input);
673
+ switch (name) {
674
+ case "Edit":
675
+ case "Write":
676
+ case "MultiEdit":
677
+ case "NotebookEdit":
678
+ return {
679
+ type: "edit",
680
+ call_id: id,
681
+ files: [{
682
+ path: text(input["file_path"]) || text(input["notebook_path"]),
683
+ change: name === "Write" && result.report["type"] === "create" ? "added" : "modified",
684
+ diff: reportedPatch(result.report["structuredPatch"]) || requestedPatch(name, input)
685
+ }],
686
+ outcome: result.failed ? "failed" : "applied"
687
+ };
688
+ case "WebSearch":
689
+ return { type: "search", call_id: id, query: text(input["query"]) };
690
+ case "WebFetch":
691
+ return { type: "search", call_id: id, query: text(input["url"]) };
692
+ case "Task":
693
+ case "Agent":
694
+ return {
695
+ type: "helper",
696
+ call_id: id,
697
+ agent: text(input["subagent_type"]) || "general-purpose",
698
+ activity: text(input["description"])
699
+ };
700
+ }
701
+ const exit = result.failed ? /^Exit code (\d+)/.exec(result.output)?.[1] : undefined;
702
+ return {
703
+ type: "tool",
704
+ call_id: id,
705
+ command: name === "Bash"
706
+ ? text(input["command"])
707
+ : Object.keys(input).length === 0
708
+ ? name
709
+ : `${name} ${JSON.stringify(input)}`,
710
+ reads: claudeReads(name, input),
711
+ status: result.failed ? "error" : "ok",
712
+ ...(exit === undefined ? {} : { exit_code: Number(exit) }),
713
+ output: result.output,
714
+ duration_ms: result.took
715
+ };
716
+ };
717
+ /**
718
+ * The Claude Code record, status, attachment and block kinds this module names. Each list is closed: a kind
719
+ * outside it is a tagged `unsupported_record`, so a new kind stops the import where a person can see it.
720
+ */
721
+ /** Rows outside the conversation chain: session bookkeeping that names no speaker and says nothing. */
722
+ const claudeSkippedRows = [
723
+ "mode",
724
+ "permission-mode",
725
+ "atis-latch",
726
+ "last-prompt",
727
+ "ai-title",
728
+ "custom-title",
729
+ "agent-name",
730
+ "queue-operation",
731
+ "file-history-snapshot",
732
+ "file-history-delta",
733
+ "cost-state",
734
+ "pr-link",
735
+ "bridge-session"
736
+ ];
737
+ /** Status lines: turn timing, hook summaries, retries, model fallback and scheduled-task notices. */
738
+ const claudeSkippedStatus = [
739
+ "turn_duration",
740
+ "informational",
741
+ "stop_hook_summary",
742
+ "away_summary",
743
+ "api_error",
744
+ "local_command",
745
+ "scheduled_task_fire",
746
+ "agents_killed",
747
+ "model_refusal_fallback"
748
+ ];
749
+ /** Context Claude Code attaches for the model; `queued_command` alone can carry the owner's words. */
750
+ const claudeSkippedAttachments = [
751
+ "agent_listing_delta",
752
+ "auto_mode",
753
+ "bash_output_audience_note",
754
+ "batching_reminder_sent",
755
+ "budget_usd",
756
+ "command_permissions",
757
+ "compact_file_reference",
758
+ "credential_org",
759
+ "date",
760
+ "deferred_tools_delta",
761
+ "deferred_tools_record",
762
+ "diagnostics",
763
+ "directory",
764
+ "edited_text_file",
765
+ "environment",
766
+ "file",
767
+ "goal_status",
768
+ "hook_additional_context",
769
+ "hook_cancelled",
770
+ "hook_non_blocking_error",
771
+ "hook_system_message",
772
+ "instructions",
773
+ "invoked_skills",
774
+ "max_turns_reached",
775
+ "mcp_instructions_delta",
776
+ "model",
777
+ "nested_memory",
778
+ "plan_mode",
779
+ "prompt_snapshot",
780
+ "read_truncation_notice",
781
+ "remote_session_change",
782
+ "sandbox_instructions",
783
+ "session_context",
784
+ "silent_turn_reminder",
785
+ "skill_listing",
786
+ "skill_mention",
787
+ "task_reminder",
788
+ "task_status",
789
+ "thinking_drop",
790
+ "thinking_stripped",
791
+ "total_tokens_reminder",
792
+ "ultra_effort_enter",
793
+ "ultra_effort_exit",
794
+ "workflow_keyword_request"
795
+ ];
796
+ /** The owner's words in a user record, or `undefined` for Claude Code's own output of a local command. */
797
+ const ownerText = (said) => {
798
+ if (/^\[Request interrupted by user[^\]]*\]$/.test(said))
799
+ return { type: "error", message: said };
800
+ if (/^<(?:local-command-std(?:out|err)|bash-std(?:out|err))>/.test(said))
801
+ return undefined;
802
+ // Claude Code writes a slash command as tags that open the record; a prompt that mentions them stays as typed.
803
+ const command = /^<command-(?:name|message)>/.test(said)
804
+ ? /<command-name>([^<]*)<\/command-name>/.exec(said)?.[1]
805
+ : undefined;
806
+ if (command !== undefined) {
807
+ const args = /<command-args>([\s\S]*?)<\/command-args>/.exec(said)?.[1]?.trim();
808
+ return { type: "prompt", text: args ? `${command} ${args}` : command };
809
+ }
810
+ const shell = /^<bash-input>([\s\S]*)<\/bash-input>$/.exec(said)?.[1];
811
+ return { type: "prompt", text: shell === undefined ? said : `!${shell.trim()}` };
812
+ };
813
+ /**
814
+ * Decode the next chunk of a Claude Code session transcript. Pass `claudeStart` with the first chunk and the
815
+ * returned state with each following one; any partition of the same bytes yields the same entries.
816
+ *
817
+ * Entries follow the order of the records that complete them. A tool call is held in `state.calls` from its
818
+ * `tool_use` record until the `tool_result` with the same id arrives, and becomes one entry at the result's line;
819
+ * a call whose result never arrives emits nothing.
820
+ *
821
+ * @category decoding
822
+ * @since 1.0.0-rc.1
823
+ */
824
+ export const decodeClaude = (state, chunk) => {
825
+ const lines = (state.pending + chunk).split("\n");
826
+ const pending = lines.pop();
827
+ let { line, seq, session, turn } = state;
828
+ const calls = new Map(Object.entries(state.calls));
829
+ const entries = [];
830
+ const fail = (code, message) => Result.fail(new ExternalTranscriptError({ code, message, line }));
831
+ /** A kind outside the named lists; a kind that is not even a string is a record of another shape. */
832
+ const unread = (what, type) => typeof type === "string" && type !== ""
833
+ ? fail("unsupported_record", `Claude Code wrote ${what} this release does not read: ${type}`)
834
+ : fail("malformed_record", `Claude Code transcript line ${line} names no ${what.replace(/^an? /, "")} type.`);
835
+ for (const raw of lines) {
836
+ line++;
837
+ if (raw.trim() === "")
838
+ continue;
839
+ const row = parseRow(raw);
840
+ if (row === undefined)
841
+ return fail("malformed_record", `Claude Code transcript line ${line} is not a JSON record.`);
842
+ // Bookkeeping rows say nothing in the conversation, whether or not a release gives them a uuid.
843
+ if (claudeSkippedRows.includes(text(row["type"])))
844
+ continue;
845
+ if (!["user", "assistant", "system", "attachment"].includes(text(row["type"]))) {
846
+ return unread("a record", row["type"]);
847
+ }
848
+ // Conversation records chain by uuid: one without it is not the shape this profile reads.
849
+ if (typeof row["uuid"] !== "string") {
850
+ return fail("malformed_record", `Claude Code transcript line ${line} is a conversation record without a uuid.`);
851
+ }
852
+ const release = text(row["version"]);
853
+ if (release === "")
854
+ return fail("missing_version", `Claude Code transcript line ${line} names no release.`);
855
+ const format_version = profileOf("claude-code", claudeReleases, release);
856
+ if (format_version === undefined) {
857
+ return fail("unsupported_version", `Claude Code ${release} wrote this transcript; supported: ${claudeReleases.join(", ")}.`);
858
+ }
859
+ session ??= text(row["sessionId"]) || undefined;
860
+ if (session === undefined) {
861
+ return fail("malformed_record", `Claude Code transcript line ${line} names no session.`);
862
+ }
863
+ const sessionId = session;
864
+ // A subagent's records belong to its own transcript; the main one shows the call as a helper.
865
+ if (row["isSidechain"] === true)
866
+ continue;
867
+ const at = Date.parse(text(row["timestamp"])) || 0;
868
+ if (row["type"] === "user" && typeof row["promptId"] === "string" && row["promptId"] !== "") {
869
+ turn = row["promptId"];
870
+ }
871
+ const found = [];
872
+ const said = (part) => found.push({ role: "assistant", part });
873
+ const message = record(row["message"]);
874
+ if ((row["type"] === "user" || row["type"] === "assistant") && typeof message["content"] !== "string" &&
875
+ !Array.isArray(message["content"])) {
876
+ return fail("malformed_record", `Claude Code transcript line ${line} has no message content.`);
877
+ }
878
+ switch (row["type"]) {
879
+ case "user": {
880
+ const blocks = blocksOf(message["content"]);
881
+ for (const block of blocks) {
882
+ if (block["type"] === "tool_result") {
883
+ const callId = text(block["tool_use_id"]);
884
+ const call = calls.get(callId);
885
+ calls.delete(callId);
886
+ const content = block["content"];
887
+ said(claudeToolPart(callId, call, {
888
+ failed: block["is_error"] === true,
889
+ output: typeof content === "string" ? content : textOf(list(content).map(record)),
890
+ report: record(row["toolUseResult"]),
891
+ took: call !== undefined && call.at > 0 && at > call.at ? at - call.at : 0
892
+ }));
893
+ }
894
+ else if (block["type"] !== "text" && block["type"] !== "image") {
895
+ return unread("a content block", block["type"]);
896
+ }
897
+ }
898
+ const words = textOf(blocks);
899
+ // Skill bodies, caveats and summaries Claude Code injects are not the owner's; nor are task notifications
900
+ // or messages from other sessions.
901
+ if (words === "" || row["isMeta"] === true || row["isCompactSummary"] === true || !byOwner(row["origin"]))
902
+ break;
903
+ const part = ownerText(words);
904
+ if (part !== undefined)
905
+ found.push({ role: part.type === "prompt" ? "user" : "assistant", part });
906
+ break;
907
+ }
908
+ case "assistant": {
909
+ const blocks = blocksOf(message["content"]);
910
+ if (row["isApiErrorMessage"] === true) {
911
+ said({ type: "error", message: textOf(blocks) || text(row["error"]) });
912
+ break;
913
+ }
914
+ for (const block of blocks) {
915
+ switch (block["type"]) {
916
+ case "text":
917
+ if (text(block["text"]) !== "") {
918
+ said({ type: "text", text: text(block["text"]), final: message["stop_reason"] === "end_turn" });
919
+ }
920
+ break;
921
+ case "thinking":
922
+ // Claude Code keeps only the signature of most thinking; an empty body has nothing to show.
923
+ if (text(block["thinking"]) !== "")
924
+ said({ type: "reasoning", text: text(block["thinking"]) });
925
+ break;
926
+ case "redacted_thinking":
927
+ break;
928
+ case "fallback":
929
+ // A notice that Claude Code answered with another model: a status line, not something it said.
930
+ break;
931
+ case "tool_use":
932
+ if (typeof block["id"] !== "string" || block["id"] === "") {
933
+ return fail("malformed_record", `Claude Code tool request on line ${line} names no call.`);
934
+ }
935
+ calls.set(block["id"], { name: text(block["name"]), input: block["input"] ?? {}, at });
936
+ break;
937
+ default:
938
+ return unread("a content block", block["type"]);
939
+ }
940
+ }
941
+ break;
942
+ }
943
+ case "system":
944
+ if (row["subtype"] === "compact_boundary")
945
+ said({ type: "compaction" });
946
+ else if (!claudeSkippedStatus.includes(text(row["subtype"])))
947
+ return unread("a status record", row["subtype"]);
948
+ break;
949
+ case "attachment": {
950
+ // Context Claude Code attaches for the model, except a prompt the owner queued while the agent worked.
951
+ const attachment = record(row["attachment"]);
952
+ if (attachment["type"] !== "queued_command") {
953
+ if (!claudeSkippedAttachments.includes(text(attachment["type"]))) {
954
+ return unread("an attachment", attachment["type"]);
955
+ }
956
+ break;
957
+ }
958
+ if (attachment["commandMode"] === "prompt" && attachment["isMeta"] !== true && byOwner(attachment["origin"])) {
959
+ const words = textOf(blocksOf(attachment["prompt"]));
960
+ if (words !== "")
961
+ found.push({ role: "user", part: { type: "prompt", text: words } });
962
+ }
963
+ break;
964
+ }
965
+ }
966
+ found.forEach(({ part, role }, index) => {
967
+ entries.push({
968
+ origin: "external",
969
+ agent_kind: "claude-code",
970
+ format_version,
971
+ session_id: sessionId,
972
+ source_id: index === 0 ? `${sessionId}:${line}` : `${sessionId}:${line}#${index}`,
973
+ read_only: true,
974
+ seq: seq++,
975
+ at,
976
+ ...(turn === undefined ? {} : { turn_id: turn }),
977
+ role,
978
+ part
979
+ });
980
+ });
981
+ }
982
+ return Result.succeed({
983
+ state: { pending, line, seq, session, turn, calls: Object.fromEntries(calls) },
984
+ entries
985
+ });
986
+ };
987
+ //# sourceMappingURL=ExternalTranscript.js.map