@smthrs/gateway 0.35.0 → 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 (605) hide show
  1. package/CHANGELOG.md +198 -0
  2. package/LICENSE +1 -1
  3. package/README.md +92 -0
  4. package/dist/cjs/Diagnosis.d.ts +275 -0
  5. package/dist/cjs/Diagnosis.d.ts.map +1 -0
  6. package/dist/cjs/Diagnosis.js +476 -0
  7. package/dist/cjs/Diagnosis.js.map +7 -0
  8. package/dist/cjs/EngineTrace.d.ts +76 -0
  9. package/dist/cjs/EngineTrace.d.ts.map +1 -0
  10. package/dist/cjs/EngineTrace.js +501 -0
  11. package/dist/cjs/EngineTrace.js.map +7 -0
  12. package/dist/cjs/GatewayError.d.ts +54 -0
  13. package/dist/cjs/GatewayError.d.ts.map +1 -0
  14. package/dist/cjs/GatewayError.js +51 -0
  15. package/dist/cjs/GatewayError.js.map +7 -0
  16. package/dist/cjs/GatewayProjection.d.ts +480 -0
  17. package/dist/cjs/GatewayProjection.d.ts.map +1 -0
  18. package/dist/cjs/GatewayProjection.js +462 -0
  19. package/dist/cjs/GatewayProjection.js.map +7 -0
  20. package/dist/cjs/GatewayRpcs.d.ts +1886 -0
  21. package/dist/cjs/GatewayRpcs.d.ts.map +1 -0
  22. package/dist/cjs/GatewayRpcs.js +121 -0
  23. package/dist/cjs/GatewayRpcs.js.map +7 -0
  24. package/dist/cjs/GatewaySchema.d.ts +3274 -0
  25. package/dist/cjs/GatewaySchema.d.ts.map +1 -0
  26. package/dist/cjs/GatewaySchema.js +141 -0
  27. package/dist/cjs/GatewaySchema.js.map +7 -0
  28. package/dist/cjs/GatewayServer.d.ts +427 -0
  29. package/dist/cjs/GatewayServer.d.ts.map +1 -0
  30. package/dist/cjs/GatewayServer.js +428 -0
  31. package/dist/cjs/GatewayServer.js.map +7 -0
  32. package/dist/cjs/HostBranchPresence.d.ts +12 -0
  33. package/dist/cjs/HostBranchPresence.d.ts.map +1 -0
  34. package/dist/cjs/HostBranchPresence.js +82 -0
  35. package/dist/cjs/HostBranchPresence.js.map +7 -0
  36. package/dist/cjs/Projections.d.ts +209 -0
  37. package/dist/cjs/Projections.d.ts.map +1 -0
  38. package/dist/cjs/Projections.js +906 -0
  39. package/dist/cjs/Projections.js.map +7 -0
  40. package/dist/cjs/RunDevTools.d.ts +181 -0
  41. package/dist/cjs/RunDevTools.d.ts.map +1 -0
  42. package/dist/cjs/RunDevTools.js +195 -0
  43. package/dist/cjs/RunDevTools.js.map +7 -0
  44. package/dist/cjs/RunHistory.d.ts +185 -0
  45. package/dist/cjs/RunHistory.d.ts.map +1 -0
  46. package/dist/cjs/RunHistory.js +68 -0
  47. package/dist/cjs/RunHistory.js.map +7 -0
  48. package/dist/cjs/RunTrace.d.ts +753 -0
  49. package/dist/cjs/RunTrace.d.ts.map +1 -0
  50. package/dist/cjs/RunTrace.js +1593 -0
  51. package/dist/cjs/RunTrace.js.map +7 -0
  52. package/dist/cjs/RuntimeBridge.d.ts +1386 -0
  53. package/dist/cjs/RuntimeBridge.d.ts.map +1 -0
  54. package/dist/cjs/RuntimeBridge.js +598 -0
  55. package/dist/cjs/RuntimeBridge.js.map +7 -0
  56. package/dist/cjs/bun/BunGateway.d.ts +20 -0
  57. package/dist/cjs/bun/BunGateway.d.ts.map +1 -0
  58. package/dist/cjs/bun/BunGateway.js +62 -0
  59. package/dist/cjs/bun/BunGateway.js.map +7 -0
  60. package/dist/cjs/index.d.ts +65 -0
  61. package/dist/cjs/index.d.ts.map +1 -0
  62. package/dist/cjs/index.js +59 -0
  63. package/dist/cjs/index.js.map +7 -0
  64. package/dist/cjs/internal/NativeGateway.d.ts +176 -0
  65. package/dist/cjs/internal/NativeGateway.d.ts.map +1 -0
  66. package/dist/cjs/internal/NativeGateway.js +187 -0
  67. package/dist/cjs/internal/NativeGateway.js.map +7 -0
  68. package/dist/cjs/internal/actionRenderings.d.ts +2 -0
  69. package/dist/cjs/internal/actionRenderings.d.ts.map +1 -0
  70. package/dist/cjs/internal/actionRenderings.js +224 -0
  71. package/dist/cjs/internal/actionRenderings.js.map +7 -0
  72. package/dist/cjs/internal/callEvents.d.ts +97 -0
  73. package/dist/cjs/internal/callEvents.d.ts.map +1 -0
  74. package/dist/cjs/internal/callEvents.js +169 -0
  75. package/dist/cjs/internal/callEvents.js.map +7 -0
  76. package/dist/cjs/internal/digestIndex.d.ts +31 -0
  77. package/dist/cjs/internal/digestIndex.d.ts.map +1 -0
  78. package/dist/cjs/internal/digestIndex.js +105 -0
  79. package/dist/cjs/internal/digestIndex.js.map +7 -0
  80. package/dist/cjs/internal/digestMemory.d.ts +19 -0
  81. package/dist/cjs/internal/digestMemory.d.ts.map +1 -0
  82. package/dist/cjs/internal/digestMemory.js +33 -0
  83. package/dist/cjs/internal/digestMemory.js.map +7 -0
  84. package/dist/cjs/internal/inspectLabels.d.ts +8 -0
  85. package/dist/cjs/internal/inspectLabels.d.ts.map +1 -0
  86. package/dist/cjs/internal/inspectLabels.js +29 -0
  87. package/dist/cjs/internal/inspectLabels.js.map +7 -0
  88. package/dist/cjs/internal/nativeResolution.d.ts +41 -0
  89. package/dist/cjs/internal/nativeResolution.d.ts.map +1 -0
  90. package/dist/cjs/internal/nativeResolution.js +62 -0
  91. package/dist/cjs/internal/nativeResolution.js.map +7 -0
  92. package/dist/cjs/internal/nodeEvents.d.ts +47 -0
  93. package/dist/cjs/internal/nodeEvents.d.ts.map +1 -0
  94. package/dist/cjs/internal/nodeEvents.js +60 -0
  95. package/dist/cjs/internal/nodeEvents.js.map +7 -0
  96. package/dist/cjs/node/NodeGateway.d.ts +16 -0
  97. package/dist/cjs/node/NodeGateway.d.ts.map +1 -0
  98. package/dist/cjs/node/NodeGateway.js +48 -0
  99. package/dist/cjs/node/NodeGateway.js.map +7 -0
  100. package/dist/cjs/package.json +1 -0
  101. package/dist/esm/Diagnosis.d.ts +275 -0
  102. package/dist/esm/Diagnosis.d.ts.map +1 -0
  103. package/dist/esm/Diagnosis.js +697 -0
  104. package/dist/esm/Diagnosis.js.map +1 -0
  105. package/dist/esm/EngineTrace.d.ts +76 -0
  106. package/dist/esm/EngineTrace.d.ts.map +1 -0
  107. package/dist/esm/EngineTrace.js +548 -0
  108. package/dist/esm/EngineTrace.js.map +1 -0
  109. package/dist/esm/GatewayError.d.ts +54 -0
  110. package/dist/esm/GatewayError.d.ts.map +1 -0
  111. package/dist/esm/GatewayError.js +60 -0
  112. package/dist/esm/GatewayError.js.map +1 -0
  113. package/dist/esm/GatewayProjection.d.ts +480 -0
  114. package/dist/esm/GatewayProjection.d.ts.map +1 -0
  115. package/dist/esm/GatewayProjection.js +792 -0
  116. package/dist/esm/GatewayProjection.js.map +1 -0
  117. package/dist/esm/GatewayRpcs.d.ts +1886 -0
  118. package/dist/esm/GatewayRpcs.d.ts.map +1 -0
  119. package/dist/esm/GatewayRpcs.js +145 -0
  120. package/dist/esm/GatewayRpcs.js.map +1 -0
  121. package/dist/esm/GatewaySchema.d.ts +3274 -0
  122. package/dist/esm/GatewaySchema.d.ts.map +1 -0
  123. package/dist/esm/GatewaySchema.js +244 -0
  124. package/dist/esm/GatewaySchema.js.map +1 -0
  125. package/dist/esm/GatewayServer.d.ts +427 -0
  126. package/dist/esm/GatewayServer.d.ts.map +1 -0
  127. package/dist/esm/GatewayServer.js +725 -0
  128. package/dist/esm/GatewayServer.js.map +1 -0
  129. package/dist/esm/HostBranchPresence.d.ts +12 -0
  130. package/dist/esm/HostBranchPresence.d.ts.map +1 -0
  131. package/dist/esm/HostBranchPresence.js +54 -0
  132. package/dist/esm/HostBranchPresence.js.map +1 -0
  133. package/dist/esm/Projections.d.ts +209 -0
  134. package/dist/esm/Projections.d.ts.map +1 -0
  135. package/dist/esm/Projections.js +1254 -0
  136. package/dist/esm/Projections.js.map +1 -0
  137. package/dist/esm/RunDevTools.d.ts +181 -0
  138. package/dist/esm/RunDevTools.d.ts.map +1 -0
  139. package/dist/esm/RunDevTools.js +281 -0
  140. package/dist/esm/RunDevTools.js.map +1 -0
  141. package/dist/esm/RunHistory.d.ts +185 -0
  142. package/dist/esm/RunHistory.d.ts.map +1 -0
  143. package/dist/esm/RunHistory.js +109 -0
  144. package/dist/esm/RunHistory.js.map +1 -0
  145. package/dist/esm/RunTrace.d.ts +753 -0
  146. package/dist/esm/RunTrace.d.ts.map +1 -0
  147. package/dist/esm/RunTrace.js +2105 -0
  148. package/dist/esm/RunTrace.js.map +1 -0
  149. package/dist/esm/RuntimeBridge.d.ts +1386 -0
  150. package/dist/esm/RuntimeBridge.d.ts.map +1 -0
  151. package/dist/esm/RuntimeBridge.js +659 -0
  152. package/dist/esm/RuntimeBridge.js.map +1 -0
  153. package/dist/esm/bun/BunGateway.d.ts +20 -0
  154. package/dist/esm/bun/BunGateway.d.ts.map +1 -0
  155. package/dist/esm/bun/BunGateway.js +32 -0
  156. package/dist/esm/bun/BunGateway.js.map +1 -0
  157. package/dist/esm/index.d.ts +65 -0
  158. package/dist/esm/index.d.ts.map +1 -0
  159. package/dist/esm/index.js +65 -0
  160. package/dist/esm/index.js.map +1 -0
  161. package/dist/esm/internal/NativeGateway.d.ts +176 -0
  162. package/dist/esm/internal/NativeGateway.d.ts.map +1 -0
  163. package/dist/esm/internal/NativeGateway.js +268 -0
  164. package/dist/esm/internal/NativeGateway.js.map +1 -0
  165. package/dist/esm/internal/actionRenderings.d.ts +2 -0
  166. package/dist/esm/internal/actionRenderings.d.ts.map +1 -0
  167. package/dist/esm/internal/actionRenderings.js +202 -0
  168. package/dist/esm/internal/actionRenderings.js.map +1 -0
  169. package/dist/esm/internal/callEvents.d.ts +97 -0
  170. package/dist/esm/internal/callEvents.d.ts.map +1 -0
  171. package/dist/esm/internal/callEvents.js +206 -0
  172. package/dist/esm/internal/callEvents.js.map +1 -0
  173. package/dist/esm/internal/digestIndex.d.ts +31 -0
  174. package/dist/esm/internal/digestIndex.d.ts.map +1 -0
  175. package/dist/esm/internal/digestIndex.js +87 -0
  176. package/dist/esm/internal/digestIndex.js.map +1 -0
  177. package/dist/esm/internal/digestMemory.d.ts +19 -0
  178. package/dist/esm/internal/digestMemory.d.ts.map +1 -0
  179. package/dist/esm/internal/digestMemory.js +23 -0
  180. package/dist/esm/internal/digestMemory.js.map +1 -0
  181. package/dist/esm/internal/inspectLabels.d.ts +8 -0
  182. package/dist/esm/internal/inspectLabels.d.ts.map +1 -0
  183. package/dist/esm/internal/inspectLabels.js +12 -0
  184. package/dist/esm/internal/inspectLabels.js.map +1 -0
  185. package/dist/esm/internal/nativeResolution.d.ts +41 -0
  186. package/dist/esm/internal/nativeResolution.d.ts.map +1 -0
  187. package/dist/esm/internal/nativeResolution.js +78 -0
  188. package/dist/esm/internal/nativeResolution.js.map +1 -0
  189. package/dist/esm/internal/nodeEvents.d.ts +47 -0
  190. package/dist/esm/internal/nodeEvents.d.ts.map +1 -0
  191. package/dist/esm/internal/nodeEvents.js +60 -0
  192. package/dist/esm/internal/nodeEvents.js.map +1 -0
  193. package/dist/esm/node/NodeGateway.d.ts +16 -0
  194. package/dist/esm/node/NodeGateway.d.ts.map +1 -0
  195. package/dist/esm/node/NodeGateway.js +13 -0
  196. package/dist/esm/node/NodeGateway.js.map +1 -0
  197. package/dist/vendor/adapters.json +2707 -0
  198. package/dist/vendor/bun/BunChildProcessSpawner.d.ts +7 -0
  199. package/dist/vendor/bun/BunChildProcessSpawner.js +14 -0
  200. package/dist/vendor/bun/BunClusterHttp.d.ts +83 -0
  201. package/dist/vendor/bun/BunClusterHttp.js +39 -0
  202. package/dist/vendor/bun/BunClusterSocket.d.ts +65 -0
  203. package/dist/vendor/bun/BunClusterSocket.js +22 -0
  204. package/dist/vendor/bun/BunCrypto.d.ts +10 -0
  205. package/dist/vendor/bun/BunCrypto.js +8 -0
  206. package/dist/vendor/bun/BunFileSystem.d.ts +10 -0
  207. package/dist/vendor/bun/BunFileSystem.js +9 -0
  208. package/dist/vendor/bun/BunHttpClient.d.ts +9 -0
  209. package/dist/vendor/bun/BunHttpClient.js +1 -0
  210. package/dist/vendor/bun/BunHttpPlatform.d.ts +10 -0
  211. package/dist/vendor/bun/BunHttpPlatform.js +11 -0
  212. package/dist/vendor/bun/BunHttpServer.d.ts +142 -0
  213. package/dist/vendor/bun/BunHttpServer.js +38 -0
  214. package/dist/vendor/bun/BunHttpServerRequest.d.ts +18 -0
  215. package/dist/vendor/bun/BunHttpServerRequest.js +7 -0
  216. package/dist/vendor/bun/BunMultipart.d.ts +31 -0
  217. package/dist/vendor/bun/BunMultipart.js +12 -0
  218. package/dist/vendor/bun/BunPath.d.ts +24 -0
  219. package/dist/vendor/bun/BunPath.js +12 -0
  220. package/dist/vendor/bun/BunRedis.d.ts +49 -0
  221. package/dist/vendor/bun/BunRedis.js +11 -0
  222. package/dist/vendor/bun/BunRuntime.d.ts +85 -0
  223. package/dist/vendor/bun/BunRuntime.js +8 -0
  224. package/dist/vendor/bun/BunServices.d.ts +34 -0
  225. package/dist/vendor/bun/BunServices.js +23 -0
  226. package/dist/vendor/bun/BunSink.d.ts +8 -0
  227. package/dist/vendor/bun/BunSink.js +12 -0
  228. package/dist/vendor/bun/BunSocket.d.ts +40 -0
  229. package/dist/vendor/bun/BunSocket.js +29 -0
  230. package/dist/vendor/bun/BunSocketServer.d.ts +8 -0
  231. package/dist/vendor/bun/BunSocketServer.js +21 -0
  232. package/dist/vendor/bun/BunStdio.d.ts +11 -0
  233. package/dist/vendor/bun/BunStdio.js +10 -0
  234. package/dist/vendor/bun/BunStream.d.ts +19 -0
  235. package/dist/vendor/bun/BunStream.js +30 -0
  236. package/dist/vendor/bun/BunTerminal.d.ts +21 -0
  237. package/dist/vendor/bun/BunTerminal.js +10 -0
  238. package/dist/vendor/bun/BunWorker.d.ts +20 -0
  239. package/dist/vendor/bun/BunWorker.js +9 -0
  240. package/dist/vendor/bun/BunWorkerRunner.d.ts +12 -0
  241. package/dist/vendor/bun/BunWorkerRunner.js +7 -0
  242. package/dist/vendor/bun/LICENSE +21 -0
  243. package/dist/vendor/bun/index.d.ts +92 -0
  244. package/dist/vendor/bun/index.js +107 -0
  245. package/dist/vendor/chunk-2GCOZTTW.js +48 -0
  246. package/dist/vendor/chunk-37CUR3PO.js +81 -0
  247. package/dist/vendor/chunk-3ARKKENZ.js +45 -0
  248. package/dist/vendor/chunk-3NV2UDBI.js +7 -0
  249. package/dist/vendor/chunk-3OSW7CT7.js +143 -0
  250. package/dist/vendor/chunk-62R63L74.js +62 -0
  251. package/dist/vendor/chunk-6AQLBC2I.js +118 -0
  252. package/dist/vendor/chunk-6C5H7S6B.js +18 -0
  253. package/dist/vendor/chunk-6DY5RBZD.js +85 -0
  254. package/dist/vendor/chunk-6UPBD47P.js +53 -0
  255. package/dist/vendor/chunk-AVVVN75Z.js +96 -0
  256. package/dist/vendor/chunk-B4DHEMBB.js +14 -0
  257. package/dist/vendor/chunk-BCK3NJOX.js +15 -0
  258. package/dist/vendor/chunk-BFBIHJ6X.js +0 -0
  259. package/dist/vendor/chunk-CES4OUM4.js +63 -0
  260. package/dist/vendor/chunk-D64L6YND.js +59 -0
  261. package/dist/vendor/chunk-DS2R6WOM.js +18 -0
  262. package/dist/vendor/chunk-DX4Z23DM.js +65 -0
  263. package/dist/vendor/chunk-DZ2VOUDP.js +564 -0
  264. package/dist/vendor/chunk-FOXN6JPJ.js +61 -0
  265. package/dist/vendor/chunk-FPQF7CR5.js +55 -0
  266. package/dist/vendor/chunk-FUTCTCEG.js +20 -0
  267. package/dist/vendor/chunk-GUPAV2YZ.js +18 -0
  268. package/dist/vendor/chunk-H2Z2Y4QH.js +70 -0
  269. package/dist/vendor/chunk-HAEDVSSM.js +129 -0
  270. package/dist/vendor/chunk-HY7BBL3K.js +93 -0
  271. package/dist/vendor/chunk-IFTTT6D5.js +31 -0
  272. package/dist/vendor/chunk-KQDSNB7M.js +26 -0
  273. package/dist/vendor/chunk-LIHLXXGQ.js +26 -0
  274. package/dist/vendor/chunk-LKCGQEE5.js +28 -0
  275. package/dist/vendor/chunk-MH2J3BYB.js +0 -0
  276. package/dist/vendor/chunk-ML2NAFH2.js +131 -0
  277. package/dist/vendor/chunk-MLFIZ5O2.js +0 -0
  278. package/dist/vendor/chunk-MLKGABMK.js +9 -0
  279. package/dist/vendor/chunk-MSCLEMYX.js +71 -0
  280. package/dist/vendor/chunk-OBWXQKVP.js +57 -0
  281. package/dist/vendor/chunk-QR557K66.js +20 -0
  282. package/dist/vendor/chunk-R4QUY7DH.js +18 -0
  283. package/dist/vendor/chunk-RGECXXJS.js +18 -0
  284. package/dist/vendor/chunk-TFY7W6D4.js +36 -0
  285. package/dist/vendor/chunk-TGPIVY4A.js +104 -0
  286. package/dist/vendor/chunk-TGXCX6W3.js +398 -0
  287. package/dist/vendor/chunk-TOHSFXMV.js +437 -0
  288. package/dist/vendor/chunk-UHIDPUFF.js +34 -0
  289. package/dist/vendor/chunk-ULT6CWUI.js +109 -0
  290. package/dist/vendor/chunk-UXBGYQR3.js +18 -0
  291. package/dist/vendor/chunk-V6LUGQ7O.js +21 -0
  292. package/dist/vendor/chunk-W4OASVX6.js +92 -0
  293. package/dist/vendor/chunk-WAII54GA.js +18 -0
  294. package/dist/vendor/chunk-WECQDT36.js +426 -0
  295. package/dist/vendor/chunk-WHKMOC7Z.js +28 -0
  296. package/dist/vendor/chunk-WVFOZ2UL.js +40 -0
  297. package/dist/vendor/chunk-X73E2UPI.js +18 -0
  298. package/dist/vendor/chunk-XCYARUII.js +63 -0
  299. package/dist/vendor/chunk-XFEVTDVD.js +34 -0
  300. package/dist/vendor/chunk-XFZZYSJ4.js +22 -0
  301. package/dist/vendor/chunk-XJWJXLXJ.js +18 -0
  302. package/dist/vendor/chunk-XY3Q62EO.js +18 -0
  303. package/dist/vendor/chunk-YDASSC75.js +394 -0
  304. package/dist/vendor/chunk-Z6C7SO5Z.js +507 -0
  305. package/dist/vendor/chunk-Z7QNPJEB.js +229 -0
  306. package/dist/vendor/chunk-Z7QPP4YH.js +249 -0
  307. package/dist/vendor/chunk-ZCHYLHJH.js +86 -0
  308. package/dist/vendor/chunk-ZIQVYVMA.js +22 -0
  309. package/dist/vendor/chunk-ZPIG2CUA.js +34 -0
  310. package/dist/vendor/cjs/bun/BunChildProcessSpawner.d.ts +7 -0
  311. package/dist/vendor/cjs/bun/BunChildProcessSpawner.js +1 -0
  312. package/dist/vendor/cjs/bun/BunClusterHttp.d.ts +83 -0
  313. package/dist/vendor/cjs/bun/BunClusterHttp.js +1 -0
  314. package/dist/vendor/cjs/bun/BunClusterSocket.d.ts +65 -0
  315. package/dist/vendor/cjs/bun/BunClusterSocket.js +1 -0
  316. package/dist/vendor/cjs/bun/BunCrypto.d.ts +10 -0
  317. package/dist/vendor/cjs/bun/BunCrypto.js +1 -0
  318. package/dist/vendor/cjs/bun/BunFileSystem.d.ts +10 -0
  319. package/dist/vendor/cjs/bun/BunFileSystem.js +1 -0
  320. package/dist/vendor/cjs/bun/BunHttpClient.d.ts +9 -0
  321. package/dist/vendor/cjs/bun/BunHttpClient.js +1 -0
  322. package/dist/vendor/cjs/bun/BunHttpPlatform.d.ts +10 -0
  323. package/dist/vendor/cjs/bun/BunHttpPlatform.js +1 -0
  324. package/dist/vendor/cjs/bun/BunHttpServer.d.ts +142 -0
  325. package/dist/vendor/cjs/bun/BunHttpServer.js +1 -0
  326. package/dist/vendor/cjs/bun/BunHttpServerRequest.d.ts +18 -0
  327. package/dist/vendor/cjs/bun/BunHttpServerRequest.js +1 -0
  328. package/dist/vendor/cjs/bun/BunMultipart.d.ts +31 -0
  329. package/dist/vendor/cjs/bun/BunMultipart.js +1 -0
  330. package/dist/vendor/cjs/bun/BunPath.d.ts +24 -0
  331. package/dist/vendor/cjs/bun/BunPath.js +1 -0
  332. package/dist/vendor/cjs/bun/BunRedis.d.ts +49 -0
  333. package/dist/vendor/cjs/bun/BunRedis.js +1 -0
  334. package/dist/vendor/cjs/bun/BunRuntime.d.ts +85 -0
  335. package/dist/vendor/cjs/bun/BunRuntime.js +1 -0
  336. package/dist/vendor/cjs/bun/BunServices.d.ts +34 -0
  337. package/dist/vendor/cjs/bun/BunServices.js +1 -0
  338. package/dist/vendor/cjs/bun/BunSink.d.ts +8 -0
  339. package/dist/vendor/cjs/bun/BunSink.js +1 -0
  340. package/dist/vendor/cjs/bun/BunSocket.d.ts +40 -0
  341. package/dist/vendor/cjs/bun/BunSocket.js +1 -0
  342. package/dist/vendor/cjs/bun/BunSocketServer.d.ts +8 -0
  343. package/dist/vendor/cjs/bun/BunSocketServer.js +1 -0
  344. package/dist/vendor/cjs/bun/BunStdio.d.ts +11 -0
  345. package/dist/vendor/cjs/bun/BunStdio.js +1 -0
  346. package/dist/vendor/cjs/bun/BunStream.d.ts +19 -0
  347. package/dist/vendor/cjs/bun/BunStream.js +1 -0
  348. package/dist/vendor/cjs/bun/BunTerminal.d.ts +21 -0
  349. package/dist/vendor/cjs/bun/BunTerminal.js +1 -0
  350. package/dist/vendor/cjs/bun/BunWorker.d.ts +20 -0
  351. package/dist/vendor/cjs/bun/BunWorker.js +1 -0
  352. package/dist/vendor/cjs/bun/BunWorkerRunner.d.ts +12 -0
  353. package/dist/vendor/cjs/bun/BunWorkerRunner.js +1 -0
  354. package/dist/vendor/cjs/bun/index.d.ts +92 -0
  355. package/dist/vendor/cjs/bun/index.js +1 -0
  356. package/dist/vendor/cjs/node/NodeChildProcessSpawner.d.ts +7 -0
  357. package/dist/vendor/cjs/node/NodeChildProcessSpawner.js +1 -0
  358. package/dist/vendor/cjs/node/NodeClusterHttp.d.ts +63 -0
  359. package/dist/vendor/cjs/node/NodeClusterHttp.js +1 -0
  360. package/dist/vendor/cjs/node/NodeClusterSocket.d.ts +79 -0
  361. package/dist/vendor/cjs/node/NodeClusterSocket.js +1 -0
  362. package/dist/vendor/cjs/node/NodeCrypto.d.ts +10 -0
  363. package/dist/vendor/cjs/node/NodeCrypto.js +1 -0
  364. package/dist/vendor/cjs/node/NodeFileSystem.d.ts +10 -0
  365. package/dist/vendor/cjs/node/NodeFileSystem.js +1 -0
  366. package/dist/vendor/cjs/node/NodeHttpClient.d.ts +179 -0
  367. package/dist/vendor/cjs/node/NodeHttpClient.js +1 -0
  368. package/dist/vendor/cjs/node/NodeHttpIncomingMessage.d.ts +62 -0
  369. package/dist/vendor/cjs/node/NodeHttpIncomingMessage.js +1 -0
  370. package/dist/vendor/cjs/node/NodeHttpPlatform.d.ts +36 -0
  371. package/dist/vendor/cjs/node/NodeHttpPlatform.js +1 -0
  372. package/dist/vendor/cjs/node/NodeHttpServer.d.ts +120 -0
  373. package/dist/vendor/cjs/node/NodeHttpServer.js +1 -0
  374. package/dist/vendor/cjs/node/NodeHttpServerRequest.d.ts +29 -0
  375. package/dist/vendor/cjs/node/NodeHttpServerRequest.js +1 -0
  376. package/dist/vendor/cjs/node/NodeMultipart.d.ts +46 -0
  377. package/dist/vendor/cjs/node/NodeMultipart.js +1 -0
  378. package/dist/vendor/cjs/node/NodeMultipartParser.d.ts +97 -0
  379. package/dist/vendor/cjs/node/NodeMultipartParser.js +1 -0
  380. package/dist/vendor/cjs/node/NodePath.d.ts +27 -0
  381. package/dist/vendor/cjs/node/NodePath.js +1 -0
  382. package/dist/vendor/cjs/node/NodeRedis.d.ts +74 -0
  383. package/dist/vendor/cjs/node/NodeRedis.js +1 -0
  384. package/dist/vendor/cjs/node/NodeRuntime.d.ts +85 -0
  385. package/dist/vendor/cjs/node/NodeRuntime.js +1 -0
  386. package/dist/vendor/cjs/node/NodeServices.d.ts +34 -0
  387. package/dist/vendor/cjs/node/NodeServices.js +1 -0
  388. package/dist/vendor/cjs/node/NodeSink.d.ts +8 -0
  389. package/dist/vendor/cjs/node/NodeSink.js +1 -0
  390. package/dist/vendor/cjs/node/NodeSocket.d.ts +38 -0
  391. package/dist/vendor/cjs/node/NodeSocket.js +1 -0
  392. package/dist/vendor/cjs/node/NodeSocketServer.d.ts +8 -0
  393. package/dist/vendor/cjs/node/NodeSocketServer.js +1 -0
  394. package/dist/vendor/cjs/node/NodeStdio.d.ts +11 -0
  395. package/dist/vendor/cjs/node/NodeStdio.js +1 -0
  396. package/dist/vendor/cjs/node/NodeStream.d.ts +8 -0
  397. package/dist/vendor/cjs/node/NodeStream.js +1 -0
  398. package/dist/vendor/cjs/node/NodeTerminal.d.ts +21 -0
  399. package/dist/vendor/cjs/node/NodeTerminal.js +1 -0
  400. package/dist/vendor/cjs/node/NodeWorker.d.ts +22 -0
  401. package/dist/vendor/cjs/node/NodeWorker.js +1 -0
  402. package/dist/vendor/cjs/node/NodeWorkerRunner.d.ts +12 -0
  403. package/dist/vendor/cjs/node/NodeWorkerRunner.js +1 -0
  404. package/dist/vendor/cjs/node/Undici.d.ts +28 -0
  405. package/dist/vendor/cjs/node/Undici.js +1 -0
  406. package/dist/vendor/cjs/node/index.d.ts +100 -0
  407. package/dist/vendor/cjs/node/index.js +1 -0
  408. package/dist/vendor/cjs/node-shared/NodeChildProcessSpawner.d.ts +57 -0
  409. package/dist/vendor/cjs/node-shared/NodeChildProcessSpawner.js +1 -0
  410. package/dist/vendor/cjs/node-shared/NodeClusterSocket.d.ts +22 -0
  411. package/dist/vendor/cjs/node-shared/NodeClusterSocket.js +1 -0
  412. package/dist/vendor/cjs/node-shared/NodeCrypto.d.ts +27 -0
  413. package/dist/vendor/cjs/node-shared/NodeCrypto.js +1 -0
  414. package/dist/vendor/cjs/node-shared/NodeFileSystem.d.ts +11 -0
  415. package/dist/vendor/cjs/node-shared/NodeFileSystem.js +1 -0
  416. package/dist/vendor/cjs/node-shared/NodeHttpCompression.d.ts +36 -0
  417. package/dist/vendor/cjs/node-shared/NodeHttpCompression.js +1 -0
  418. package/dist/vendor/cjs/node-shared/NodePath.d.ts +27 -0
  419. package/dist/vendor/cjs/node-shared/NodePath.js +1 -0
  420. package/dist/vendor/cjs/node-shared/NodeRuntime.d.ts +47 -0
  421. package/dist/vendor/cjs/node-shared/NodeRuntime.js +1 -0
  422. package/dist/vendor/cjs/node-shared/NodeSink.d.ts +69 -0
  423. package/dist/vendor/cjs/node-shared/NodeSink.js +1 -0
  424. package/dist/vendor/cjs/node-shared/NodeSocket.d.ts +134 -0
  425. package/dist/vendor/cjs/node-shared/NodeSocket.js +1 -0
  426. package/dist/vendor/cjs/node-shared/NodeSocketServer.d.ts +80 -0
  427. package/dist/vendor/cjs/node-shared/NodeSocketServer.js +1 -0
  428. package/dist/vendor/cjs/node-shared/NodeStdio.d.ts +12 -0
  429. package/dist/vendor/cjs/node-shared/NodeStdio.js +1 -0
  430. package/dist/vendor/cjs/node-shared/NodeStream.d.ts +179 -0
  431. package/dist/vendor/cjs/node-shared/NodeStream.js +1 -0
  432. package/dist/vendor/cjs/node-shared/NodeTerminal.d.ts +22 -0
  433. package/dist/vendor/cjs/node-shared/NodeTerminal.js +1 -0
  434. package/dist/vendor/cjs/node-shared/index.d.ts +56 -0
  435. package/dist/vendor/cjs/node-shared/index.js +1 -0
  436. package/dist/vendor/cjs/node-shared/internal/nodeChildProcessSpawner.d.ts +4 -0
  437. package/dist/vendor/cjs/node-shared/internal/nodeChildProcessSpawner.js +1 -0
  438. package/dist/vendor/cjs/node-shared/internal/utils.d.ts +2 -0
  439. package/dist/vendor/cjs/node-shared/internal/utils.js +1 -0
  440. package/dist/vendor/cjs/package.json +1 -0
  441. package/dist/vendor/cjs/platform-bun.d.ts +92 -0
  442. package/dist/vendor/cjs/platform-bun.js +1 -0
  443. package/dist/vendor/cjs/platform-node-shared.d.ts +56 -0
  444. package/dist/vendor/cjs/platform-node-shared.js +1 -0
  445. package/dist/vendor/cjs/platform-node.d.ts +100 -0
  446. package/dist/vendor/cjs/platform-node.js +1 -0
  447. package/dist/vendor/node/LICENSE +21 -0
  448. package/dist/vendor/node/NodeChildProcessSpawner.d.ts +7 -0
  449. package/dist/vendor/node/NodeChildProcessSpawner.js +14 -0
  450. package/dist/vendor/node/NodeClusterHttp.d.ts +63 -0
  451. package/dist/vendor/node/NodeClusterHttp.js +43 -0
  452. package/dist/vendor/node/NodeClusterSocket.d.ts +79 -0
  453. package/dist/vendor/node/NodeClusterSocket.js +30 -0
  454. package/dist/vendor/node/NodeCrypto.d.ts +10 -0
  455. package/dist/vendor/node/NodeCrypto.js +8 -0
  456. package/dist/vendor/node/NodeFileSystem.d.ts +10 -0
  457. package/dist/vendor/node/NodeFileSystem.js +9 -0
  458. package/dist/vendor/node/NodeHttpClient.d.ts +179 -0
  459. package/dist/vendor/node/NodeHttpClient.js +46 -0
  460. package/dist/vendor/node/NodeHttpIncomingMessage.d.ts +62 -0
  461. package/dist/vendor/node/NodeHttpIncomingMessage.js +10 -0
  462. package/dist/vendor/node/NodeHttpPlatform.d.ts +36 -0
  463. package/dist/vendor/node/NodeHttpPlatform.js +16 -0
  464. package/dist/vendor/node/NodeHttpServer.d.ts +120 -0
  465. package/dist/vendor/node/NodeHttpServer.js +46 -0
  466. package/dist/vendor/node/NodeHttpServerRequest.d.ts +29 -0
  467. package/dist/vendor/node/NodeHttpServerRequest.js +9 -0
  468. package/dist/vendor/node/NodeMultipart.d.ts +46 -0
  469. package/dist/vendor/node/NodeMultipart.js +15 -0
  470. package/dist/vendor/node/NodeMultipartParser.d.ts +97 -0
  471. package/dist/vendor/node/NodeMultipartParser.js +11 -0
  472. package/dist/vendor/node/NodePath.d.ts +27 -0
  473. package/dist/vendor/node/NodePath.js +12 -0
  474. package/dist/vendor/node/NodeRedis.d.ts +74 -0
  475. package/dist/vendor/node/NodeRedis.js +11 -0
  476. package/dist/vendor/node/NodeRuntime.d.ts +85 -0
  477. package/dist/vendor/node/NodeRuntime.js +8 -0
  478. package/dist/vendor/node/NodeServices.d.ts +34 -0
  479. package/dist/vendor/node/NodeServices.js +23 -0
  480. package/dist/vendor/node/NodeSink.d.ts +8 -0
  481. package/dist/vendor/node/NodeSink.js +12 -0
  482. package/dist/vendor/node/NodeSocket.d.ts +38 -0
  483. package/dist/vendor/node/NodeSocket.js +31 -0
  484. package/dist/vendor/node/NodeSocketServer.d.ts +8 -0
  485. package/dist/vendor/node/NodeSocketServer.js +21 -0
  486. package/dist/vendor/node/NodeStdio.d.ts +11 -0
  487. package/dist/vendor/node/NodeStdio.js +10 -0
  488. package/dist/vendor/node/NodeStream.d.ts +8 -0
  489. package/dist/vendor/node/NodeStream.js +27 -0
  490. package/dist/vendor/node/NodeTerminal.d.ts +21 -0
  491. package/dist/vendor/node/NodeTerminal.js +10 -0
  492. package/dist/vendor/node/NodeWorker.d.ts +22 -0
  493. package/dist/vendor/node/NodeWorker.js +9 -0
  494. package/dist/vendor/node/NodeWorkerRunner.d.ts +12 -0
  495. package/dist/vendor/node/NodeWorkerRunner.js +7 -0
  496. package/dist/vendor/node/Undici.d.ts +28 -0
  497. package/dist/vendor/node/Undici.js +9 -0
  498. package/dist/vendor/node/index.d.ts +100 -0
  499. package/dist/vendor/node/index.js +115 -0
  500. package/dist/vendor/node-shared/LICENSE +21 -0
  501. package/dist/vendor/node-shared/NodeChildProcessSpawner.d.ts +57 -0
  502. package/dist/vendor/node-shared/NodeChildProcessSpawner.js +13 -0
  503. package/dist/vendor/node-shared/NodeClusterSocket.d.ts +22 -0
  504. package/dist/vendor/node-shared/NodeClusterSocket.js +11 -0
  505. package/dist/vendor/node-shared/NodeCrypto.d.ts +27 -0
  506. package/dist/vendor/node-shared/NodeCrypto.js +9 -0
  507. package/dist/vendor/node-shared/NodeFileSystem.d.ts +11 -0
  508. package/dist/vendor/node-shared/NodeFileSystem.js +8 -0
  509. package/dist/vendor/node-shared/NodeHttpCompression.d.ts +36 -0
  510. package/dist/vendor/node-shared/NodeHttpCompression.js +13 -0
  511. package/dist/vendor/node-shared/NodePath.d.ts +27 -0
  512. package/dist/vendor/node-shared/NodePath.js +11 -0
  513. package/dist/vendor/node-shared/NodeRuntime.d.ts +47 -0
  514. package/dist/vendor/node-shared/NodeRuntime.js +7 -0
  515. package/dist/vendor/node-shared/NodeSink.d.ts +69 -0
  516. package/dist/vendor/node-shared/NodeSink.js +11 -0
  517. package/dist/vendor/node-shared/NodeSocket.d.ts +134 -0
  518. package/dist/vendor/node-shared/NodeSocket.js +23 -0
  519. package/dist/vendor/node-shared/NodeSocketServer.d.ts +80 -0
  520. package/dist/vendor/node-shared/NodeSocketServer.js +20 -0
  521. package/dist/vendor/node-shared/NodeStdio.d.ts +12 -0
  522. package/dist/vendor/node-shared/NodeStdio.js +9 -0
  523. package/dist/vendor/node-shared/NodeStream.d.ts +179 -0
  524. package/dist/vendor/node-shared/NodeStream.js +26 -0
  525. package/dist/vendor/node-shared/NodeTerminal.d.ts +22 -0
  526. package/dist/vendor/node-shared/NodeTerminal.js +9 -0
  527. package/dist/vendor/node-shared/index.d.ts +56 -0
  528. package/dist/vendor/node-shared/index.js +58 -0
  529. package/dist/vendor/node-shared/internal/nodeChildProcessSpawner.d.ts +4 -0
  530. package/dist/vendor/node-shared/internal/nodeChildProcessSpawner.js +7 -0
  531. package/dist/vendor/node-shared/internal/utils.d.ts +2 -0
  532. package/dist/vendor/node-shared/internal/utils.js +7 -0
  533. package/dist/vendor/platform-bun.d.ts +92 -0
  534. package/dist/vendor/platform-bun.js +107 -0
  535. package/dist/vendor/platform-node-shared.d.ts +56 -0
  536. package/dist/vendor/platform-node-shared.js +58 -0
  537. package/dist/vendor/platform-node.d.ts +100 -0
  538. package/dist/vendor/platform-node.js +115 -0
  539. package/docs/README.md +158 -0
  540. package/docs/api.md +601 -0
  541. package/docs/concepts/projections.md +250 -0
  542. package/docs/concepts/subscriptions.md +204 -0
  543. package/docs/concepts/trust-boundary.md +256 -0
  544. package/docs/guides/diagnose-a-run.md +115 -0
  545. package/docs/guides/follow-a-run.md +150 -0
  546. package/docs/guides/host-the-gateway.md +153 -0
  547. package/docs/guides/read-a-projection.md +138 -0
  548. package/docs/guides/serve-beyond-loopback.md +166 -0
  549. package/docs/guides/submit-an-approval.md +187 -0
  550. package/docs/guides/testing.md +148 -0
  551. package/docs/installation.md +89 -0
  552. package/docs/quickstart.md +200 -0
  553. package/docs/troubleshooting.md +355 -0
  554. package/package.json +264 -32
  555. package/src/Diagnosis.ts +892 -0
  556. package/src/EngineTrace.ts +605 -0
  557. package/src/GatewayError.ts +71 -0
  558. package/src/GatewayProjection.ts +948 -0
  559. package/src/GatewayRpcs.ts +179 -0
  560. package/src/GatewaySchema.ts +516 -0
  561. package/src/GatewayServer.ts +932 -0
  562. package/src/HostBranchPresence.ts +72 -0
  563. package/src/Projections.ts +1735 -0
  564. package/src/RunDevTools.ts +394 -0
  565. package/src/RunHistory.ts +174 -0
  566. package/src/RunTrace.ts +2793 -0
  567. package/src/RuntimeBridge.ts +835 -0
  568. package/src/bun/BunGateway.ts +52 -0
  569. package/src/index.ts +77 -0
  570. package/src/internal/NativeGateway.ts +360 -0
  571. package/src/internal/actionRenderings.ts +201 -0
  572. package/src/internal/callEvents.ts +257 -0
  573. package/src/internal/digestIndex.ts +134 -0
  574. package/src/internal/digestMemory.ts +27 -0
  575. package/src/internal/inspectLabels.ts +13 -0
  576. package/src/internal/nativeResolution.ts +103 -0
  577. package/src/internal/nodeEvents.ts +100 -0
  578. package/src/node/NodeGateway.ts +30 -0
  579. package/openapi.yaml +0 -29945
  580. package/src/README.md +0 -39
  581. package/src/api/README.md +0 -23
  582. package/src/api/apiCollectionNames.js +0 -10
  583. package/src/api/index.d.ts +0 -126
  584. package/src/api/index.js +0 -14
  585. package/src/api/normalizeApiRow.js +0 -36
  586. package/src/api/serializeAccountRow.js +0 -10
  587. package/src/api/serializeApprovalRow.js +0 -53
  588. package/src/api/serializeComparisonScoreRow.js +0 -18
  589. package/src/api/serializeCronRow.js +0 -30
  590. package/src/api/serializeDocRow.js +0 -20
  591. package/src/api/serializeMemoryFactRow.js +0 -21
  592. package/src/api/serializePromptRow.js +0 -10
  593. package/src/api/serializeRunEventRow.js +0 -28
  594. package/src/api/serializeRunRow.js +0 -93
  595. package/src/api/serializeScoreDetailRow.js +0 -25
  596. package/src/api/serializeScoreRow.js +0 -26
  597. package/src/api/serializeTicketRow.js +0 -20
  598. package/src/api/serializeWorkflowRow.js +0 -10
  599. package/src/auth/scopes.d.ts +0 -19
  600. package/src/auth/scopes.js +0 -164
  601. package/src/index.d.ts +0 -316
  602. package/src/index.js +0 -108
  603. package/src/rpc/gatewayRpcTypes.ts +0 -186
  604. package/src/rpc/index.d.ts +0 -223
  605. package/src/rpc/index.js +0 -2527
@@ -0,0 +1,1593 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var RunTrace_exports = {};
20
+ __export(RunTrace_exports, {
21
+ TRACE_FILTER_IDS: () => TRACE_FILTER_IDS,
22
+ callSemantics: () => callSemantics,
23
+ callSubject: () => callSubject,
24
+ durationWords: () => durationWords,
25
+ inspectLabel: () => import_inspectLabels2.inspectLabel,
26
+ isTraceFilter: () => isTraceFilter,
27
+ monitorFromJournal: () => monitorFromJournal,
28
+ phaseBandGeometry: () => phaseBandGeometry,
29
+ phaseExtent: () => phaseExtent,
30
+ runMemoryOf: () => runMemoryOf,
31
+ spanMatches: () => spanMatches,
32
+ spanPath: () => spanPath,
33
+ traceFiltersFor: () => traceFiltersFor,
34
+ traceFold: () => traceFold,
35
+ traceFoldModel: () => traceFoldModel,
36
+ traceFoldStep: () => traceFoldStep,
37
+ traceFoldSync: () => traceFoldSync,
38
+ traceFromJournal: () => traceFromJournal,
39
+ turnNarratives: () => turnNarratives,
40
+ waterfallGeometry: () => waterfallGeometry
41
+ });
42
+ module.exports = __toCommonJS(RunTrace_exports);
43
+ var import_journal = require("@smthrs/journal");
44
+ var import_Descriptor = require("@smthrs/registry/Descriptor");
45
+ var import_effect = require("effect");
46
+ var import_Diagnosis = require("./Diagnosis.js");
47
+ var import_EngineTrace = require("./EngineTrace.js");
48
+ var import_actionRenderings = require("./internal/actionRenderings.js");
49
+ var import_callEvents = require("./internal/callEvents.js");
50
+ var import_inspectLabels = require("./internal/inspectLabels.js");
51
+ var import_inspectLabels2 = require("./internal/inspectLabels.js");
52
+ const TERMINAL_RUN = /* @__PURE__ */ new Set(["completed", "failed", "cancelled", "no-capacity"]);
53
+ const asRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value) ? value : {};
54
+ const asString = (value) => typeof value === "string" ? value : void 0;
55
+ const asNumber = (value) => typeof value === "number" && Number.isFinite(value) ? value : void 0;
56
+ const timeOf = (record, payload) => asNumber(payload.at) ?? asNumber(record.occurredAt) ?? 0;
57
+ const textOf = (value) => {
58
+ if (value === void 0 || value === null) return void 0;
59
+ if (typeof value === "string") return value;
60
+ try {
61
+ return JSON.stringify(value);
62
+ } catch {
63
+ return String(value);
64
+ }
65
+ };
66
+ const restOf = (payload, shown) => {
67
+ const rest = {};
68
+ for (const [key, value] of Object.entries(payload)) {
69
+ if (shown.includes(key) || key === "at" || key === "journalVersion") continue;
70
+ rest[key] = value;
71
+ }
72
+ return Object.keys(rest).length === 0 ? void 0 : rest;
73
+ };
74
+ const builder = (id, kind, label, status, startedAt, detail) => ({ id, kind, label, status, startedAt, children: [], detail });
75
+ const legacy = (activity, pending, success, failure, subject, result) => ({
76
+ ...activity === void 0 ? {} : { activity },
77
+ presentation: { verb: { pending, success, failure }, subject, result }
78
+ });
79
+ const LEGACY_PRESENTATION = /* @__PURE__ */ new Map([
80
+ // `bash` has no compatibility activity for the same reason `@smthrs/std`
81
+ // declares none: what a shell call does is in the command, which the rule
82
+ // below reads off the record.
83
+ ["bash", legacy(void 0, "running", "ran", "failed to run", "command", "command")],
84
+ ["test", legacy("tests", "running", "ran", "failed to run", "selection", "tests")],
85
+ ["edit", legacy("writes", "editing", "edited", "failed to edit", "path", "edit")],
86
+ ["write", legacy("writes", "writing", "wrote", "failed to write", "path", "write")],
87
+ ["apply_patch", legacy("writes", "patching", "patched", "failed to patch", "patch", "patch")],
88
+ ["read", legacy("reads", "reading", "read", "failed to read", "path", "read")],
89
+ ["grep", legacy("reads", "searching", "searched", "failed to search", "pattern", "matches")],
90
+ ["glob", legacy("reads", "listing", "listed", "failed to list", "pattern", "paths")],
91
+ ["ls", legacy("reads", "listing", "listed", "failed to list", "path", "entries")]
92
+ ]);
93
+ const recordedMetadata = (value, flowName) => {
94
+ const descriptor = asRecord(value);
95
+ if (descriptor.name !== flowName) return void 0;
96
+ if (descriptor.activity === void 0 && descriptor.presentation === void 0) return void 0;
97
+ const activity = import_effect.Schema.is(import_Descriptor.FlowActivity)(descriptor.activity) ? descriptor.activity : void 0;
98
+ const presentation = import_effect.Schema.is(import_Descriptor.CallPresentation)(descriptor.presentation) ? descriptor.presentation : void 0;
99
+ return { activity, presentation };
100
+ };
101
+ const CHECKPOINT_FLOW = "checkpoint";
102
+ const commandOf = (input) => {
103
+ const fields = asRecord(input);
104
+ return asString(fields.command) ?? asString(fields.script);
105
+ };
106
+ const basename = (path) => path.split("/").filter((part) => part !== "").pop() ?? path;
107
+ const patchedPaths = (patch) => {
108
+ const paths = [];
109
+ for (const line of patch.split("\n")) {
110
+ const named = /^\*\*\* (?:Add|Delete|Update) File:\s*(\S.*)$/.exec(line.trim())?.[1];
111
+ if (named !== void 0) paths.push(named.trim());
112
+ }
113
+ return paths;
114
+ };
115
+ const filesLabel = (paths) => {
116
+ const first = paths[0];
117
+ if (first === void 0) return "";
118
+ return paths.length === 1 ? basename(first) : `${basename(first)} +${paths.length - 1}`;
119
+ };
120
+ const writtenPaths = (input) => {
121
+ const fields = asRecord(input);
122
+ const path = asString(fields.path);
123
+ if (path !== void 0) return [path];
124
+ const patch = asString(fields.input);
125
+ return patch === void 0 ? [] : patchedPaths(patch);
126
+ };
127
+ const callSubject = (input, format) => {
128
+ const fields = asRecord(input);
129
+ if (format === "none") return "";
130
+ if (format === "path") return asString(fields.path) === void 0 ? "" : basename(fields.path);
131
+ if (format === "command") return commandOf(input) ?? "";
132
+ if (format === "patch") return filesLabel(patchedPaths(asString(fields.input) ?? ""));
133
+ if (format === "pattern") return asString(fields.pattern) ?? "";
134
+ if (format === "selection") return stringList(fields.selection)?.join(" ") ?? "";
135
+ const path = asString(fields.path);
136
+ if (path !== void 0) return basename(path);
137
+ const command = commandOf(input);
138
+ if (command !== void 0) return command;
139
+ const patch = asString(fields.input);
140
+ if (patch !== void 0) {
141
+ const files = filesLabel(patchedPaths(patch));
142
+ if (files !== "") return files;
143
+ }
144
+ const selection = Array.isArray(fields.selection) ? fields.selection.filter((one) => typeof one === "string") : void 0;
145
+ if (selection !== void 0 && selection.length > 0) return selection.join(" ");
146
+ return asString(fields.pattern) ?? "";
147
+ };
148
+ const shellActivity = (command) => {
149
+ if (/[;&|<>`$\n\r]/.test(command)) return "other";
150
+ const words = command.trim().split(/\s+/);
151
+ const first = words[0];
152
+ if (["pytest", "vitest", "jest"].includes(first)) return "tests";
153
+ if (/^python[23]?$/.test(first) && words[1] === "-m" && ["pytest", "unittest"].includes(words[2] ?? "")) {
154
+ return "tests";
155
+ }
156
+ if (first === "bun" && words[1] === "test") return "tests";
157
+ if (["pnpm", "npm", "bun"].includes(first)) {
158
+ if (words[1] === "test" || words[1] === "run" && words[2] === "test") return "tests";
159
+ if (words[1] === "exec" && ["vitest", "jest"].includes(words[2] ?? "")) return "tests";
160
+ if (words[1] === "run" && ["check", "typecheck", "lint"].includes(words[2] ?? "")) return "checks";
161
+ }
162
+ if (first === "go" && words[1] === "test") return "tests";
163
+ if (first === "cargo" && words[1] === "test") return "tests";
164
+ if (first === "tsc") return "checks";
165
+ return "other";
166
+ };
167
+ const callSemantics = (flowName, payload) => {
168
+ const recorded = recordedMetadata(payload.descriptor, flowName);
169
+ const metadata = recorded ?? LEGACY_PRESENTATION.get(flowName);
170
+ const activity = metadata?.activity ?? (flowName === "bash" ? shellActivity(commandOf(payload.input) ?? "") : void 0);
171
+ return {
172
+ ...activity === void 0 ? {} : { activity },
173
+ ...metadata?.presentation === void 0 ? {} : { presentation: metadata.presentation }
174
+ };
175
+ };
176
+ const stringList = (value) => Array.isArray(value) && value.every((entry) => typeof entry === "string") ? value : void 0;
177
+ const countOf = (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : void 0;
178
+ const counted = (value, noun, plural = `${noun}s`) => `${value} ${value === 1 ? noun : plural}`;
179
+ const resultOf = (value, format) => {
180
+ if (format === "none") return "";
181
+ if (typeof value === "string") return clip(value) ?? "";
182
+ const fields = asRecord(value);
183
+ if (fields.truncated === true && typeof fields.digest === "string") return "";
184
+ switch (format) {
185
+ case "read": {
186
+ const start = countOf(fields.startLine);
187
+ const end = countOf(fields.endLine);
188
+ return start !== void 0 && start > 0 && end !== void 0 && end >= start - 1 ? counted(end - start + 1, "line") : "";
189
+ }
190
+ case "write":
191
+ return countOf(fields.bytesWritten) === void 0 ? "" : counted(fields.bytesWritten, "byte");
192
+ case "edit":
193
+ return countOf(fields.replacements) === void 0 ? "" : counted(fields.replacements, "replacement");
194
+ case "patch": {
195
+ const groups = [stringList(fields.added), stringList(fields.modified), stringList(fields.deleted)];
196
+ return groups.every((group) => group !== void 0) ? counted(new Set(groups.flat()).size, "file") : "";
197
+ }
198
+ case "tests": {
199
+ const passed = countOf(fields.passed);
200
+ const failed = stringList(fields.failed);
201
+ if (fields.parsed === true && passed !== void 0 && failed !== void 0 && fields.invalidProbe === void 0) {
202
+ const exit = countOf(fields.exitCode);
203
+ return `${passed} passed${failed.length > 0 ? ` \xB7 ${failed.length} failed` : exit !== void 0 && exit !== 0 ? ` \xB7 exit ${exit}` : ""}`;
204
+ }
205
+ return countOf(fields.exitCode) === void 0 ? "" : `exit ${fields.exitCode}`;
206
+ }
207
+ case "command":
208
+ return countOf(fields.exitCode) === void 0 ? "" : `exit ${fields.exitCode}`;
209
+ case "matches":
210
+ return Array.isArray(fields.matches) ? counted(fields.matches.length, "match", "matches") : "";
211
+ case "paths":
212
+ return stringList(fields.paths) === void 0 ? "" : counted(fields.paths.length, "file");
213
+ case "entries":
214
+ return Array.isArray(fields.entries) ? counted(fields.entries.length, "entry", "entries") : "";
215
+ default:
216
+ return "";
217
+ }
218
+ };
219
+ const bodyOf = (...sentences) => sentences.filter((sentence) => sentence !== void 0).join(" ");
220
+ const clip = (value) => {
221
+ const line = asString(value);
222
+ if (line === void 0 || line === "") return void 0;
223
+ return line.length <= 160 ? line : `${line.slice(0, 159).trimEnd()}\u2026`;
224
+ };
225
+ const madeAWrite = (entry) => entry.calls.some((call) => call.activity === "writes" && call.settled?.failed === false && !call.settled.denied);
226
+ const dominantCall = (entry) => entry.calls.find((one) => one.activity === "writes") ?? entry.calls.find((one) => one.activity === "checks" || one.activity === "tests") ?? entry.calls.find((one) => one.flowName !== CHECKPOINT_FLOW);
227
+ const disciplineInit = (runId) => ({
228
+ runId,
229
+ frames: [],
230
+ notes: [],
231
+ milestones: [],
232
+ owners: [],
233
+ open: [],
234
+ frame: void 0,
235
+ lastAt: 0,
236
+ lineOf: /* @__PURE__ */ new WeakMap()
237
+ });
238
+ const disciplineStep = (state, record) => {
239
+ const { runId, frames, notes, milestones, owners, open } = state;
240
+ let frame = state.frame;
241
+ const here = () => frame?.id ?? `run:${runId}`;
242
+ const note = (seq, tone, title, body, evidence) => {
243
+ const quoted = evidence.filter((line) => line !== void 0);
244
+ notes.push({ seq, spanId: here(), tone, title, body, ...quoted.length === 0 ? {} : { evidence: quoted } });
245
+ };
246
+ const pin = (seq, at, label, tone) => {
247
+ milestones.push({ seq, at, label, tone, spanId: here() });
248
+ };
249
+ {
250
+ const kind = record.kind ?? "";
251
+ const payload = asRecord(record.payload);
252
+ const at = timeOf(record, payload);
253
+ const seq = record.sequence ?? 0;
254
+ state.lastAt = Math.max(state.lastAt, at);
255
+ if (frame !== void 0) frame.endedAt = Math.max(frame.endedAt, at);
256
+ switch (kind) {
257
+ case "control.agent.turn-opened": {
258
+ frame = {
259
+ id: `frame-${frames.length + 1}`,
260
+ frame: frames.length + 1,
261
+ seq,
262
+ startedAt: at,
263
+ endedAt: at,
264
+ blocked: false,
265
+ calls: []
266
+ };
267
+ frames.push(frame);
268
+ break;
269
+ }
270
+ case "control.agent.cell-call-started": {
271
+ const flowName = asString(payload.flowName) ?? "";
272
+ const metadata = callSemantics(flowName, payload);
273
+ const call = {
274
+ flowName,
275
+ callId: asString(payload.callId),
276
+ input: payload.input,
277
+ activity: metadata.activity,
278
+ presentation: metadata.presentation,
279
+ signature: `${flowName} ${textOf(payload.input) ?? ""}`
280
+ };
281
+ open.push(call);
282
+ frame?.calls.push(call);
283
+ break;
284
+ }
285
+ case "control.agent.cell-call-settled": {
286
+ if (payload.outcome !== "success" && payload.outcome !== "failure") break;
287
+ const index = (0, import_Diagnosis.openCallIndex)(open, asString(payload.callId), asString(payload.flowName));
288
+ const call = index < 0 ? void 0 : open.splice(index, 1)[0];
289
+ if (call === void 0) break;
290
+ const failed = asString(payload.outcome) === "failure";
291
+ const denied = !failed && asRecord(payload.value).approved === false;
292
+ call.settled = {
293
+ failed,
294
+ result: (failed ? textOf(payload.message) : textOf(payload.value)) ?? "",
295
+ denied,
296
+ value: payload.value
297
+ };
298
+ if (denied && frame !== void 0) frame.blocked = true;
299
+ if (!failed && !denied && call.activity === "writes") {
300
+ const paths = [...new Set(writtenPaths(call.input))];
301
+ const minted = frame?.wrote;
302
+ if (minted !== void 0) {
303
+ for (const path of paths) if (!minted.paths.includes(path)) minted.paths.push(path);
304
+ milestones[minted.milestone] = { ...milestones[minted.milestone], label: filesLabel(minted.paths) };
305
+ } else if (paths.length > 0) {
306
+ if (frame !== void 0) frame.wrote = { milestone: milestones.length, paths };
307
+ pin(seq, at, filesLabel(paths), "brand");
308
+ }
309
+ }
310
+ break;
311
+ }
312
+ case "control.agent.mutation-observed": {
313
+ const mutated = payload.mutated === true;
314
+ if (frame !== void 0) frame.mutated = mutated;
315
+ if (frame !== void 0 && payload.basis === "observed" && typeof payload.mutated === "boolean") {
316
+ frame.observedMutation = payload.mutated;
317
+ }
318
+ if (mutated) {
319
+ note(
320
+ seq,
321
+ asString(payload.basis) === "observed" ? "good" : "warn",
322
+ "changed",
323
+ asString(payload.basis) ?? "",
324
+ []
325
+ );
326
+ }
327
+ break;
328
+ }
329
+ case "control.agent.permission-required": {
330
+ if (frame !== void 0) frame.blocked = true;
331
+ pin(seq, at, "permission", "warn");
332
+ break;
333
+ }
334
+ case "control.agent.suspended": {
335
+ if (frame !== void 0) frame.blocked = true;
336
+ break;
337
+ }
338
+ case "control.agent.checkpoint-minted": {
339
+ note(seq, "good", "checkpoint", asString(payload.ref) ?? "", []);
340
+ break;
341
+ }
342
+ case "control.agent.read-only-demanded": {
343
+ const streak = asNumber(payload.streak);
344
+ const cap = asNumber(payload.cap);
345
+ const nextFrame = asNumber(payload.nextFrame);
346
+ const nextAction = asString(payload.nextAction);
347
+ note(
348
+ seq,
349
+ "warn",
350
+ "read-only",
351
+ bodyOf(
352
+ streak === void 0 || cap === void 0 ? void 0 : `${streak} of ${cap} frames changed nothing.`,
353
+ nextFrame === void 0 || nextAction === void 0 ? void 0 : `Frame ${nextFrame}: ${nextAction}.`
354
+ ),
355
+ []
356
+ );
357
+ pin(seq, at, "read-only", "warn");
358
+ break;
359
+ }
360
+ case "control.agent.repeat-demanded": {
361
+ const spent = asNumber(payload.frames);
362
+ const cap = asNumber(payload.cap);
363
+ const nextFrame = asNumber(payload.nextFrame);
364
+ note(
365
+ seq,
366
+ "warn",
367
+ "repeat",
368
+ bodyOf(
369
+ spent === void 0 || cap === void 0 ? void 0 : `${spent} of ${cap} frames repeated calls.`,
370
+ nextFrame === void 0 ? void 0 : `Frame ${nextFrame}.`
371
+ ),
372
+ []
373
+ );
374
+ pin(seq, at, "repeat", "warn");
375
+ break;
376
+ }
377
+ case "control.agent.narrowed-demanded": {
378
+ const flow = asString(payload.flow);
379
+ const nextFrame = asNumber(payload.nextFrame);
380
+ note(
381
+ seq,
382
+ "bad",
383
+ "narrowed",
384
+ bodyOf(
385
+ flow === void 0 ? void 0 : `${flow} ran narrower than the reading it stands in for.`,
386
+ nextFrame === void 0 ? void 0 : `Frame ${nextFrame}.`
387
+ ),
388
+ [clip(payload.broader), clip(payload.narrower)]
389
+ );
390
+ pin(seq, at, "narrowed", "bad");
391
+ break;
392
+ }
393
+ case "control.agent.unmoved-demanded": {
394
+ const nextFrame = asNumber(payload.nextFrame);
395
+ const opened = clip(payload.openedDigest);
396
+ const current = clip(payload.currentDigest);
397
+ note(
398
+ seq,
399
+ "bad",
400
+ "unmoved",
401
+ bodyOf(
402
+ "The tree the run opened on is the tree it closed on.",
403
+ nextFrame === void 0 ? void 0 : `Frame ${nextFrame}.`
404
+ ),
405
+ opened === void 0 || current === void 0 ? [] : [opened, current]
406
+ );
407
+ pin(seq, at, "unmoved", "bad");
408
+ break;
409
+ }
410
+ case "control.agent.unresolved-demanded": {
411
+ const flow = asString(payload.flow);
412
+ const nextFrame = asNumber(payload.nextFrame);
413
+ note(
414
+ seq,
415
+ "bad",
416
+ "unresolved",
417
+ bodyOf(
418
+ flow === void 0 ? void 0 : `${flow} failed and was not answered.`,
419
+ nextFrame === void 0 ? void 0 : `Frame ${nextFrame}.`
420
+ ),
421
+ [clip(payload.failed), clip(payload.instead)]
422
+ );
423
+ pin(seq, at, "unresolved", "bad");
424
+ break;
425
+ }
426
+ case "control.agent.claim-demanded": {
427
+ if (payload.demanded !== true && payload.refused !== true) break;
428
+ const complete = asNumber(payload.complete);
429
+ const overclaims = asNumber(payload.overclaims);
430
+ const nextFrame = asNumber(payload.nextFrame);
431
+ note(
432
+ seq,
433
+ "bad",
434
+ payload.refused === true ? "claim refused" : "claim",
435
+ bodyOf(
436
+ complete === void 0 || overclaims === void 0 ? void 0 : `complete ${complete}, overclaims ${overclaims}.`,
437
+ nextFrame === void 0 ? void 0 : `Frame ${nextFrame}.`
438
+ ),
439
+ []
440
+ );
441
+ pin(seq, at, payload.refused === true ? "claim refused" : "claim", "bad");
442
+ break;
443
+ }
444
+ /*
445
+ * The five kinds `AgentSession`'s `default` arm once journaled with
446
+ * `payload: {}`, however rich their `AgentEvent` schema was:
447
+ * cell-rejected-in-frame, read-only-demand-issued,
448
+ * narrow-only-demanded, steering-drained and sufficiency-observed.
449
+ * Their whole payload is late (`AgentSession` `lateFields`), so one
450
+ * record carries every field or none, and each arm below reads what its
451
+ * record has: a legacy record still folds, and still says nothing the
452
+ * record does not carry. A note with no body and no evidence is a title
453
+ * on its own, so a fieldless record writes none.
454
+ */
455
+ case "control.agent.cell-rejected-in-frame": {
456
+ const attempt = asNumber(payload.attempt);
457
+ const code = asString(payload.code);
458
+ const body = bodyOf(
459
+ code === void 0 ? void 0 : `${code}.`,
460
+ attempt === void 0 ? void 0 : `Attempt ${attempt}.`
461
+ );
462
+ if (body !== "") note(seq, "warn", "rejected", body, [clip(payload.message)]);
463
+ break;
464
+ }
465
+ case "control.agent.read-only-demand-issued": {
466
+ const streak = asNumber(payload.streak);
467
+ const cap = asNumber(payload.cap);
468
+ const nextFrame = asNumber(payload.nextFrame);
469
+ const body = bodyOf(
470
+ streak === void 0 || cap === void 0 ? void 0 : `${streak} of ${cap} frames changed nothing.`,
471
+ nextFrame === void 0 ? void 0 : `Frame ${nextFrame}.`
472
+ );
473
+ if (body !== "") note(seq, "warn", "read-only", body, []);
474
+ pin(seq, at, "read-only", "warn");
475
+ break;
476
+ }
477
+ case "control.agent.narrow-only-demanded": {
478
+ const flow = asString(payload.flow);
479
+ const targets = Array.isArray(payload.targets) ? payload.targets.filter((one) => typeof one === "string") : [];
480
+ const nextFrame = asNumber(payload.nextFrame);
481
+ const body = bodyOf(
482
+ flow === void 0 || targets.length === 0 ? void 0 : `${flow} ran on ${targets.join(", ")} and nothing broader.`,
483
+ nextFrame === void 0 ? void 0 : `Frame ${nextFrame}.`
484
+ );
485
+ if (body !== "") note(seq, "warn", "narrow-only", body, [clip(payload.check)]);
486
+ pin(seq, at, "narrow-only", "warn");
487
+ break;
488
+ }
489
+ case "control.agent.steering-drained": {
490
+ const messages = Array.isArray(payload.messages) ? payload.messages : [];
491
+ if (messages.length === 0) break;
492
+ note(
493
+ seq,
494
+ "warn",
495
+ "steering",
496
+ messages.length === 1 ? "1 steer." : `${messages.length} steers.`,
497
+ messages.map((message) => clip(asRecord(message).text))
498
+ );
499
+ pin(seq, at, "steering", "warn");
500
+ break;
501
+ }
502
+ case "control.agent.sufficiency-observed": {
503
+ const flow = asString(payload.flow);
504
+ const nextFrame = asNumber(payload.nextFrame);
505
+ const body = bodyOf(
506
+ flow === void 0 ? void 0 : `${flow} failed before the change and passed after it.`,
507
+ nextFrame === void 0 ? void 0 : `Frame ${nextFrame}.`
508
+ );
509
+ if (body !== "") note(seq, "good", "sufficiency", body, [clip(payload.failed), clip(payload.passed)]);
510
+ pin(seq, at, "sufficiency", "good");
511
+ break;
512
+ }
513
+ case "control.run.completed":
514
+ case "control.run.failed":
515
+ case "control.run.cancelled": {
516
+ const verdict = kind.slice("control.run.".length);
517
+ if (verdict === "cancelled") pin(seq, at, "stopped", "muted");
518
+ else pin(seq, at, verdict, verdict === "completed" ? "good" : "bad");
519
+ break;
520
+ }
521
+ default:
522
+ break;
523
+ }
524
+ owners.push({ seq, spanId: here() });
525
+ }
526
+ state.frame = frame;
527
+ };
528
+ const disciplineModel = (state) => {
529
+ const { frames, lastAt } = state;
530
+ const notes = state.notes.slice();
531
+ const milestones = state.milestones.slice();
532
+ const owners = state.owners.slice();
533
+ const changed = frames.map((entry) => entry.observedMutation ?? (entry.mutated === true || madeAWrite(entry)));
534
+ const firstSeen = /* @__PURE__ */ new Map();
535
+ const repeatedFrom = /* @__PURE__ */ new Map();
536
+ const redundant = [];
537
+ frames.forEach((entry, index) => {
538
+ const calls = entry.calls.filter((call) => call.flowName !== CHECKPOINT_FLOW);
539
+ for (const call of calls) {
540
+ if (call.settled === void 0) continue;
541
+ call.reading ??= `${call.signature} ${JSON.stringify(call.settled)}`;
542
+ const reading = call.reading;
543
+ const seen = firstSeen.get(reading);
544
+ if (seen === void 0) firstSeen.set(reading, entry.frame);
545
+ else if (seen < entry.frame) repeatedFrom.set(call, seen);
546
+ }
547
+ redundant.push(calls.length > 0 && calls.every((call) => repeatedFrom.has(call)));
548
+ if (changed[index] === true) firstSeen.clear();
549
+ });
550
+ const stalling = frames.map((_frame, index) => redundant[index] === true && changed[index] !== true);
551
+ const stuck = stalling.map((flag, index) => flag && (stalling[index - 1] === true || stalling[index + 1] === true));
552
+ const phases = frames.map(
553
+ (entry, index) => entry.blocked ? "blocked" : stuck[index] === true ? "stuck" : changed[index] === true || entry.calls.some((call) => call.activity === "writes") ? "implementing" : entry.calls.some((call) => call.activity === "checks" || call.activity === "tests") ? "testing" : entry.calls.some((call) => call.activity === "reads") ? "researching" : "unrecorded"
554
+ );
555
+ const bands = [];
556
+ frames.forEach((entry, index) => {
557
+ const phase = phases[index];
558
+ const endedAt = frames[index + 1]?.startedAt ?? Math.max(entry.endedAt, lastAt);
559
+ const last = bands[bands.length - 1];
560
+ if (last !== void 0 && last.phase === phase) {
561
+ bands[bands.length - 1] = { ...last, endedAt, frames: [...last.frames, entry.id] };
562
+ return;
563
+ }
564
+ bands.push({ phase, startedAt: entry.startedAt, endedAt, frames: [entry.id], seq: entry.seq });
565
+ });
566
+ const lines = frames.flatMap((entry, index) => {
567
+ const call = dominantCall(entry);
568
+ if (call === void 0) return [];
569
+ const repeatOf = stuck[index] === true ? repeatedFrom.get(call) : void 0;
570
+ const held = state.lineOf.get(entry);
571
+ if (held !== void 0 && held.call === call && held.settled === call.settled && held.repeatOf === repeatOf) {
572
+ return [held.line];
573
+ }
574
+ const outcome = call.settled === void 0 ? "pending" : call.settled.failed || call.settled.denied ? "failure" : "success";
575
+ const line = {
576
+ spanId: entry.id,
577
+ frame: entry.frame,
578
+ verb: call.presentation?.verb[outcome] ?? `${call.flowName}${outcome === "pending" ? " pending" : outcome === "failure" ? " failed" : ""}`,
579
+ subject: callSubject(call.input, call.presentation?.subject),
580
+ // Read supported output fields through the descriptor's presentation.
581
+ // The selected call retains the raw value, including unsupported shapes.
582
+ result: call.settled?.failed === true ? clip(call.settled.result) ?? "" : resultOf(call.settled?.value, call.presentation?.result),
583
+ failed: call.settled?.failed === true,
584
+ wrote: call.activity === "writes" && call.settled?.failed === false && !call.settled.denied,
585
+ ...repeatOf === void 0 ? {} : { repeatOf }
586
+ };
587
+ state.lineOf.set(entry, { call, settled: call.settled, repeatOf, line });
588
+ return [line];
589
+ });
590
+ return { bands, milestones, lines, notes, owners };
591
+ };
592
+ const isEngineRow = (record) => record.kind === "control.engine.event" || record.kind === "control.engine.projection-gap";
593
+ const foldInit = (run) => ({
594
+ run,
595
+ root: builder(`run:${run.runId}`, "run", `run ${run.runId} \xB7 ${run.flowId}`, "running", 0, {
596
+ ...run.kind === void 0 ? {} : { fields: { kind: run.kind } }
597
+ }),
598
+ frame: void 0,
599
+ cell: void 0,
600
+ frames: 0,
601
+ calls: 0,
602
+ seat: void 0,
603
+ lastAt: 0,
604
+ count: 0,
605
+ verdict: void 0,
606
+ openCalls: [],
607
+ approvals: /* @__PURE__ */ new Map(),
608
+ discipline: disciplineInit(run.runId),
609
+ engine: [],
610
+ engineTrace: void 0,
611
+ frozen: /* @__PURE__ */ new WeakMap(),
612
+ dirty: /* @__PURE__ */ new Set(),
613
+ topOf: /* @__PURE__ */ new WeakMap()
614
+ });
615
+ const foldStep = (state, record) => {
616
+ if (isEngineRow(record)) {
617
+ state.engine.push(record);
618
+ state.engineTrace = void 0;
619
+ }
620
+ const { root, openCalls, approvals, dirty, topOf } = state;
621
+ let { frame, cell, frames, calls, seat } = state;
622
+ const top = frame ?? cell;
623
+ if (top !== void 0) dirty.add(top);
624
+ const touch = (span) => {
625
+ dirty.add(topOf.get(span));
626
+ };
627
+ const parent = () => cell ?? frame ?? root;
628
+ const closeCell = (at, status) => {
629
+ if (cell === void 0) return;
630
+ cell.endedAt = at;
631
+ cell.status = status;
632
+ cell = void 0;
633
+ };
634
+ const closeFrame = (at) => {
635
+ if (frame === void 0) return;
636
+ closeCell(at, cell?.children.some((child) => child.status === "failed") === true ? "failed" : "completed");
637
+ frame.endedAt = at;
638
+ frame.status = frame.children.some((child) => child.status === "failed") ? "failed" : "completed";
639
+ frame = void 0;
640
+ };
641
+ {
642
+ const kind = record.kind ?? "";
643
+ const payload = asRecord(record.payload);
644
+ const at = timeOf(record, payload);
645
+ if (state.count === 0) {
646
+ root.startedAt = at;
647
+ state.lastAt = at;
648
+ } else state.lastAt = Math.max(state.lastAt, at);
649
+ state.count += 1;
650
+ const opened = { sequence: record.sequence, event: kind };
651
+ switch (kind) {
652
+ case "control.engine.event":
653
+ case "control.engine.projection-gap":
654
+ case "control.engine.projection-started":
655
+ case "control.engine.projection-settled":
656
+ break;
657
+ case "control.agent.turn-opened": {
658
+ closeFrame(at);
659
+ frames += 1;
660
+ seat = asString(payload.seat) ?? seat;
661
+ frame = builder(
662
+ `frame-${frames}`,
663
+ "frame",
664
+ `frame ${frames}${seat === void 0 ? "" : ` \xB7 ${seat}`}`,
665
+ "running",
666
+ at,
667
+ {
668
+ ...opened,
669
+ ...seat === void 0 ? {} : { seat },
670
+ fields: restOf(payload, ["seat"])
671
+ }
672
+ );
673
+ root.children.push(frame);
674
+ break;
675
+ }
676
+ case "control.agent.model-settled": {
677
+ const usage = asRecord(payload.usage);
678
+ const duration = asNumber(payload.durationMillis);
679
+ const span = builder(
680
+ `model-${record.sequence ?? at}`,
681
+ "model",
682
+ "model",
683
+ "completed",
684
+ duration === void 0 ? at : at - duration,
685
+ {
686
+ ...opened,
687
+ ...seat === void 0 ? {} : { seat },
688
+ output: textOf(payload.text),
689
+ usage: { inputTokens: asNumber(usage.inputTokens), outputTokens: asNumber(usage.outputTokens) },
690
+ fields: restOf(payload, ["text", "usage", "durationMillis"])
691
+ }
692
+ );
693
+ span.endedAt = at;
694
+ (frame ?? root).children.push(span);
695
+ break;
696
+ }
697
+ case "control.agent.cell-produced": {
698
+ closeCell(at, "completed");
699
+ const language = asString(payload.language);
700
+ cell = builder(
701
+ `cell-${record.sequence ?? at}`,
702
+ "cell",
703
+ `cell${language === void 0 ? "" : ` \xB7 ${language}`}`,
704
+ "running",
705
+ at,
706
+ {
707
+ ...opened,
708
+ source: asString(payload.text),
709
+ fields: restOf(payload, ["text", "language"])
710
+ }
711
+ );
712
+ (frame ?? root).children.push(cell);
713
+ break;
714
+ }
715
+ case "control.agent.cell-call-started": {
716
+ calls += 1;
717
+ const recordedName = asString(payload.flowName);
718
+ const flowName = recordedName ?? `call-${calls}`;
719
+ const span = builder(`call-${calls}`, "call", (0, import_inspectLabels.inspectLabel)(flowName), "running", at, {
720
+ ...opened,
721
+ ...recordedName === void 0 ? {} : { flowName: recordedName },
722
+ input: payload.input,
723
+ fields: restOf(payload, ["flowName", "input"])
724
+ });
725
+ openCalls.push({ flowName, callId: asString(payload.callId), span });
726
+ topOf.set(span, frame ?? cell ?? span);
727
+ parent().children.push(span);
728
+ break;
729
+ }
730
+ case "control.agent.cell-call-settled": {
731
+ const index = (0, import_Diagnosis.openCallIndex)(openCalls, asString(payload.callId), asString(payload.flowName));
732
+ const settled = index < 0 ? void 0 : openCalls.splice(index, 1)[0];
733
+ if (settled === void 0) break;
734
+ const failed = asString(payload.outcome) === "failure";
735
+ touch(settled.span);
736
+ settled.span.endedAt = at;
737
+ settled.span.status = failed ? "failed" : "completed";
738
+ settled.span.detail = {
739
+ ...settled.span.detail,
740
+ ...failed ? { message: textOf(payload.message) } : { output: textOf(payload.value) },
741
+ ...!failed && settled.flowName === "agent/spawn" && asString(asRecord(payload.value).child) !== void 0 ? { childRunId: asString(asRecord(payload.value).child) } : {}
742
+ };
743
+ break;
744
+ }
745
+ case "control.agent.cell-printed": {
746
+ if (cell === void 0) {
747
+ parent().children.push(
748
+ builder(`printed-${record.sequence ?? at}`, "event", "printed", "completed", at, {
749
+ ...opened,
750
+ printed: textOf(payload.text)
751
+ })
752
+ );
753
+ break;
754
+ }
755
+ cell.detail = {
756
+ ...cell.detail,
757
+ printed: [cell.detail.printed, textOf(payload.text)].filter((text) => text !== void 0).join("\n")
758
+ };
759
+ break;
760
+ }
761
+ case "control.agent.cell-settled": {
762
+ closeCell(at, asString(payload.outcome) === "failure" ? "failed" : "completed");
763
+ break;
764
+ }
765
+ case "control.agent.resolved": {
766
+ const span = builder(`resolved-${record.sequence ?? at}`, "resolved", "resolved", "completed", at, {
767
+ ...opened,
768
+ output: textOf(payload.text)
769
+ });
770
+ span.endedAt = at;
771
+ (frame ?? root).children.push(span);
772
+ break;
773
+ }
774
+ case "control.approval.requested": {
775
+ const requestId = asString(payload.requestId) ?? `approval-${record.sequence ?? at}`;
776
+ const question = asString(payload.question);
777
+ const span = builder(
778
+ `approval-${requestId}`,
779
+ "approval",
780
+ `approval${question === void 0 ? "" : ` \xB7 ${question}`}`,
781
+ "waiting",
782
+ at,
783
+ {
784
+ ...opened,
785
+ fields: restOf(payload, ["question", "requestId", "payload", "runId"])
786
+ }
787
+ );
788
+ approvals.set(requestId, span);
789
+ topOf.set(span, frame ?? span);
790
+ (frame ?? root).children.push(span);
791
+ break;
792
+ }
793
+ case "control.approval.approved":
794
+ case "control.approval.denied": {
795
+ const decided = kind === "control.approval.approved" ? "approved" : "denied";
796
+ const key = asString(payload.tokenId) ?? asString(payload.requestId);
797
+ const span = key === void 0 ? [...approvals.values()].find((entry) => entry.status === "waiting") : approvals.get(key);
798
+ if (span === void 0) break;
799
+ touch(span);
800
+ span.status = decided;
801
+ span.endedAt = at;
802
+ break;
803
+ }
804
+ case "control.run.completed":
805
+ case "control.run.failed":
806
+ case "control.run.cancelled": {
807
+ closeFrame(at);
808
+ root.endedAt = at;
809
+ state.verdict = kind.slice("control.run.".length);
810
+ break;
811
+ }
812
+ default: {
813
+ if (!kind.startsWith("control.")) break;
814
+ const span = builder(
815
+ `event-${record.sequence ?? at}`,
816
+ "event",
817
+ kind.slice("control.".length),
818
+ "completed",
819
+ at,
820
+ {
821
+ ...opened,
822
+ fields: restOf(payload, [])
823
+ }
824
+ );
825
+ span.endedAt = at;
826
+ parent().children.push(span);
827
+ if (kind === "control.agent.turn-closed" && payload.step !== void 0) {
828
+ const closed = frame;
829
+ closeFrame(at);
830
+ if (closed !== void 0 && payload.outcome === "suspended") closed.status = "waiting";
831
+ if (closed !== void 0 && payload.outcome === "aborted") closed.status = "cancelled";
832
+ }
833
+ }
834
+ }
835
+ }
836
+ Object.assign(state, { frame, cell, frames, calls, seat });
837
+ const after = frame ?? cell;
838
+ if (after !== void 0) dirty.add(after);
839
+ disciplineStep(state.discipline, record);
840
+ };
841
+ const foldModel = (state, status, journal, engine) => {
842
+ const { root, frame, cell, lastAt } = state;
843
+ const closed = /* @__PURE__ */ new Map();
844
+ const statusOf = (node) => closed.get(node)?.status ?? node.status;
845
+ const terminal = TERMINAL_RUN.has(status);
846
+ if (terminal && frame !== void 0) {
847
+ if (cell !== void 0) {
848
+ closed.set(cell, {
849
+ status: cell.children.some((child) => child.status === "failed") ? "failed" : "completed",
850
+ endedAt: lastAt
851
+ });
852
+ }
853
+ closed.set(frame, {
854
+ status: frame.children.some((child) => statusOf(child) === "failed") ? "failed" : "completed",
855
+ endedAt: lastAt
856
+ });
857
+ }
858
+ if (engine === void 0 && state.engineTrace === void 0) state.engineTrace = (0, import_EngineTrace.engineTraceFromJournal)(state.engine);
859
+ const children = [...root.children, ...engine ?? state.engineTrace];
860
+ closed.set(root, {
861
+ status: state.verdict ?? status,
862
+ endedAt: root.endedAt ?? (terminal && state.count > 0 ? lastAt : Number.NaN)
863
+ });
864
+ const freeze = (node, depth, members) => freezeWith(node, depth, members.map((child) => freeze(child, depth + 1, child.children)));
865
+ const freezeWith = (node, depth, frozenChildren2) => {
866
+ const override = closed.get(node);
867
+ const nodeStatus = override?.status ?? node.status;
868
+ const endedAt = override === void 0 || Number.isNaN(override.endedAt) ? node.endedAt : override.endedAt;
869
+ const held = state.frozen.get(node);
870
+ if (held !== void 0 && held.depth === depth && held.label === node.label && held.status === nodeStatus && held.startedAt === node.startedAt && held.endedAt === endedAt && held.detail === node.detail && held.children.length === frozenChildren2.length && held.children.every((child, index) => child === frozenChildren2[index])) return held;
871
+ const span = {
872
+ id: node.id,
873
+ kind: node.kind,
874
+ label: node.label,
875
+ status: nodeStatus,
876
+ startedAt: node.startedAt,
877
+ ...endedAt === void 0 ? {} : { endedAt },
878
+ depth,
879
+ children: frozenChildren2,
880
+ detail: node.detail
881
+ };
882
+ state.frozen.set(node, span);
883
+ return span;
884
+ };
885
+ const settledChild = (child) => {
886
+ if (state.dirty.has(child) || closed.has(child)) return void 0;
887
+ const held = state.frozen.get(child);
888
+ return held?.depth === 1 ? held : void 0;
889
+ };
890
+ const frozenChildren = children.map((child) => settledChild(child) ?? freeze(child, 1, child.children));
891
+ state.dirty.clear();
892
+ const frozenRoot = freezeWith(root, 0, frozenChildren);
893
+ const rows = [];
894
+ const walk = (span) => {
895
+ rows.push(span);
896
+ for (const child of span.children) walk(child);
897
+ };
898
+ walk(frozenRoot);
899
+ let start = Number.POSITIVE_INFINITY;
900
+ let end = 0;
901
+ let running = 0;
902
+ let failed = 0;
903
+ for (const span of rows) {
904
+ start = Math.min(start, span.startedAt);
905
+ end = Math.max(end, span.endedAt ?? span.startedAt);
906
+ if (span.kind !== "run" && span.status === "running") running += 1;
907
+ if (span.kind !== "run" && span.status === "failed") failed += 1;
908
+ }
909
+ const extent = state.count === 0 || !Number.isFinite(start) ? { start: 0, end: 0 } : { start, end: Math.max(end, start) };
910
+ return {
911
+ journal,
912
+ root: frozenRoot,
913
+ rows,
914
+ extent,
915
+ counts: { spans: rows.length - 1, running, failed },
916
+ ...disciplineModel(state.discipline)
917
+ };
918
+ };
919
+ const sequenceOf = (record) => record.sequence ?? 0;
920
+ const TERMINAL_KINDS = /* @__PURE__ */ new Set([
921
+ "control.run.completed",
922
+ "control.run.failed",
923
+ "control.run.cancelled"
924
+ ]);
925
+ const route = (state, record) => {
926
+ if (record.kind?.startsWith("control.run.") === true && record.runId !== void 0 && record.runId !== state.run.runId) {
927
+ return;
928
+ }
929
+ state.firstAt = Math.min(state.firstAt, timeOf(record, asRecord(record.payload)));
930
+ if (TERMINAL_KINDS.has(record.kind ?? "")) state.terminal = record;
931
+ const scope = (0, import_Diagnosis.callScope)(record);
932
+ if (scope === void 0) return foldStep(state.base, record);
933
+ let group = state.groups.get(scope);
934
+ if (group === void 0) {
935
+ group = foldInit(state.run);
936
+ state.groups.set(scope, group);
937
+ }
938
+ foldStep(group, record);
939
+ };
940
+ const reseed = (state, arrived) => {
941
+ const journal = [...arrived].sort((left, right) => sequenceOf(left) - sequenceOf(right));
942
+ const filter = (0, import_callEvents.callEventFilter)();
943
+ for (const record of journal) filter.push(record);
944
+ Object.assign(state, {
945
+ arrived,
946
+ journal,
947
+ filter,
948
+ base: foldInit(state.run),
949
+ groups: /* @__PURE__ */ new Map(),
950
+ engine: journal.filter(isEngineRow),
951
+ engineTrace: void 0,
952
+ firstAt: Number.POSITIVE_INFINITY,
953
+ terminal: void 0,
954
+ memo: void 0
955
+ });
956
+ for (const record of (0, import_callEvents.uniqueCallEvents)(journal)) route(state, record);
957
+ };
958
+ const traceFold = (run, records = []) => {
959
+ const state = {
960
+ run: { runId: run.runId, flowId: run.flowId, ...run.kind === void 0 ? {} : { kind: run.kind } }
961
+ };
962
+ state.source = void 0;
963
+ reseed(state, [...records]);
964
+ return state;
965
+ };
966
+ const traceFoldStep = (fold, record) => {
967
+ const state = fold;
968
+ state.memo = void 0;
969
+ state.arrived.push(record);
970
+ const last = state.journal.at(-1);
971
+ if (last !== void 0 && !(sequenceOf(record) >= sequenceOf(last))) {
972
+ reseed(state, state.arrived);
973
+ return fold;
974
+ }
975
+ state.journal.push(record);
976
+ if (isEngineRow(record)) {
977
+ state.engine.push(record);
978
+ state.engineTrace = void 0;
979
+ }
980
+ const verdict = state.filter.push(record);
981
+ if (verdict._tag === "rewrite") reseed(state, state.arrived);
982
+ else if (verdict._tag === "keep") route(state, verdict.event);
983
+ return fold;
984
+ };
985
+ const traceFoldSync = (fold, run, records) => {
986
+ const held = fold;
987
+ const source = held?.source;
988
+ const extends_ = held !== void 0 && source !== void 0 && held.run.runId === run.runId && held.run.flowId === run.flowId && held.run.kind === run.kind && records.length >= source.length && source.every((record, index) => records[index] === record);
989
+ const next = extends_ ? held : traceFold(run);
990
+ for (let index = extends_ ? source.length : 0; index < records.length; index++) traceFoldStep(next, records[index]);
991
+ next.source = records.slice();
992
+ return next;
993
+ };
994
+ const traceFoldModel = (fold, status) => {
995
+ const state = fold;
996
+ if (state.memo?.status === status) return state.memo.model;
997
+ const model = mergeModel(state, status);
998
+ state.memo = { status, model };
999
+ return model;
1000
+ };
1001
+ const mergeModel = (state, status) => {
1002
+ const journal = state.journal.slice();
1003
+ if (state.groups.size === 0) {
1004
+ if (state.engineTrace === void 0) state.engineTrace = (0, import_EngineTrace.engineTraceFromJournal)(state.engine);
1005
+ return foldModel(state.base, status, journal, state.engineTrace);
1006
+ }
1007
+ const base = foldModel(state.base, status, journal);
1008
+ const children = [...base.root.children];
1009
+ const bands = [...base.bands];
1010
+ const milestones = [...base.milestones];
1011
+ const lines = [...base.lines];
1012
+ const notes = [...base.notes];
1013
+ const owners = [...base.owners];
1014
+ const terminal = state.terminal;
1015
+ const terminalAt = terminal === void 0 ? void 0 : timeOf(terminal, asRecord(terminal.payload));
1016
+ for (const [scope, group] of state.groups) {
1017
+ const prefix = `step:${encodeURIComponent(scope)}/`;
1018
+ const scoped = foldModel(group, "running", journal);
1019
+ const rename = (span) => ({
1020
+ ...span,
1021
+ id: `${prefix}${span.id}`,
1022
+ children: span.children.map(rename),
1023
+ ...span.status === "running" && TERMINAL_RUN.has(base.root.status) ? {
1024
+ // A terminal run proves work stopped. It does not prove which open
1025
+ // step succeeded or caused the run to fail.
1026
+ status: "stopped",
1027
+ ...terminalAt === void 0 ? {} : { endedAt: terminalAt }
1028
+ } : {}
1029
+ });
1030
+ children.push(...scoped.root.children.map(rename));
1031
+ bands.push(...scoped.bands.map((band) => ({ ...band, frames: band.frames.map((id) => `${prefix}${id}`) })));
1032
+ const owned = (spanId) => spanId === scoped.root.id ? base.root.id : `${prefix}${spanId}`;
1033
+ milestones.push(...scoped.milestones.map((one) => ({ ...one, spanId: owned(one.spanId) })));
1034
+ lines.push(...scoped.lines.map((line) => ({ ...line, spanId: `${prefix}${line.spanId}` })));
1035
+ notes.push(...scoped.notes.map((note) => ({ ...note, spanId: owned(note.spanId) })));
1036
+ owners.push(...scoped.owners.map((one) => ({ ...one, spanId: owned(one.spanId) })));
1037
+ }
1038
+ children.sort(
1039
+ (left, right) => left.startedAt - right.startedAt || (left.detail.sequence ?? 0) - (right.detail.sequence ?? 0)
1040
+ );
1041
+ const root = { ...base.root, startedAt: state.firstAt, children };
1042
+ const rows = [];
1043
+ const walk = (span) => {
1044
+ rows.push(span);
1045
+ span.children.forEach(walk);
1046
+ };
1047
+ walk(root);
1048
+ const positions = new Map(rows.map((span, index) => [span.id, index]));
1049
+ const merged = lines.sort((left, right) => positions.get(left.spanId) - positions.get(right.spanId));
1050
+ const stepOf = (spanId) => spanId.slice(0, spanId.lastIndexOf("/") + 1);
1051
+ const renumbered = new Map(merged.map((line, index) => [`${stepOf(line.spanId)}${line.frame}`, index + 1]));
1052
+ let start = Number.POSITIVE_INFINITY;
1053
+ let end = Number.NEGATIVE_INFINITY;
1054
+ for (const span of rows) {
1055
+ start = Math.min(start, span.startedAt);
1056
+ end = Math.max(end, span.endedAt ?? span.startedAt);
1057
+ }
1058
+ return {
1059
+ journal,
1060
+ root,
1061
+ rows,
1062
+ extent: { start, end },
1063
+ counts: {
1064
+ spans: rows.length - 1,
1065
+ running: rows.filter((span) => span.kind !== "run" && span.status === "running").length,
1066
+ failed: rows.filter((span) => span.kind !== "run" && span.status === "failed").length
1067
+ },
1068
+ bands: bands.sort((left, right) => left.startedAt - right.startedAt || left.seq - right.seq),
1069
+ milestones: milestones.sort((left, right) => left.seq - right.seq),
1070
+ lines: merged.map((line, index) => ({
1071
+ ...line,
1072
+ frame: index + 1,
1073
+ ...line.repeatOf === void 0 ? {} : { repeatOf: renumbered.get(`${stepOf(line.spanId)}${line.repeatOf}`) }
1074
+ })),
1075
+ notes: notes.sort((left, right) => left.seq - right.seq),
1076
+ owners: owners.sort((left, right) => left.seq - right.seq)
1077
+ };
1078
+ };
1079
+ const traceFromJournal = (run, records, _options = {}) => traceFoldModel(traceFold(run, records), run.status);
1080
+ const waterfallGeometry = (span, extent) => {
1081
+ const width = Math.max(extent.end - extent.start, 1);
1082
+ const from = span.startedAt;
1083
+ const to = span.endedAt ?? extent.end;
1084
+ const left = (from - extent.start) / width * 100;
1085
+ const bar = Math.max((to - from) / width * 100, 0);
1086
+ return { left: Math.round(left * 100) / 100, width: Math.round(bar * 100) / 100 };
1087
+ };
1088
+ const phaseExtent = (model) => {
1089
+ return model.bands.length === 0 ? model.extent : {
1090
+ start: Math.min(...model.bands.map((band) => band.startedAt)),
1091
+ end: Math.max(...model.bands.map((band) => band.endedAt))
1092
+ };
1093
+ };
1094
+ const phaseBandGeometry = (band, extent, index, count) => {
1095
+ const round = (value) => Math.round(value * 100) / 100;
1096
+ const axis = extent.end - extent.start;
1097
+ if (axis <= 0) {
1098
+ const share = 100 / Math.max(count, 1);
1099
+ return { left: round(index * share), width: round(share) };
1100
+ }
1101
+ return {
1102
+ left: round((band.startedAt - extent.start) / axis * 100),
1103
+ width: round(Math.max(band.endedAt - band.startedAt, 0) / axis * 100)
1104
+ };
1105
+ };
1106
+ const MESSAGE_FLOWS = /* @__PURE__ */ new Set(["agent/send", "agent/await"]);
1107
+ const spanMatches = (span, filter) => {
1108
+ const own = filter === "all" ? true : filter === "running" ? span.status === "running" || span.status === "waiting" : filter === "failed" ? span.status === "failed" : filter === "model" ? span.kind === "model" : filter === "flow" ? span.kind === "call" || span.kind === "execution" || span.kind === "attempt" : span.kind === "call" && MESSAGE_FLOWS.has(span.label);
1109
+ return own || span.children.some((child) => spanMatches(child, filter));
1110
+ };
1111
+ const TRACE_FILTER_IDS = [
1112
+ "all",
1113
+ "running",
1114
+ "failed",
1115
+ "model",
1116
+ "flow",
1117
+ "messages"
1118
+ ];
1119
+ const FILTER_LABELS = {
1120
+ all: "all",
1121
+ running: "running",
1122
+ failed: "failed",
1123
+ model: "model calls",
1124
+ flow: "flow calls",
1125
+ messages: "messages"
1126
+ };
1127
+ const traceFiltersFor = (kind) => (kind === "prototype" ? ["all", "messages", "failed"] : ["all", "running", "failed", "model", "flow"]).map((id) => [id, FILTER_LABELS[id]]);
1128
+ const isTraceFilter = (value) => TRACE_FILTER_IDS.includes(value);
1129
+ const proseLine = (text) => {
1130
+ if (text === void 0) return void 0;
1131
+ let fence;
1132
+ for (const line of text.split("\n")) {
1133
+ const trimmed = line.trim();
1134
+ const marker = /^(?:`{3,}|~{3,})/.exec(trimmed)?.[0];
1135
+ if (marker !== void 0) {
1136
+ if (fence === void 0) fence = marker;
1137
+ else if (marker[0] === fence[0] && marker.length >= fence.length) fence = void 0;
1138
+ continue;
1139
+ }
1140
+ if (fence !== void 0 || trimmed === "") continue;
1141
+ if (/^(?:[[{]|(?:const|let|var|await|import|export|function|return)\b)/.test(trimmed)) return void 0;
1142
+ const words = trimmed.replace(/^#{1,6}\s+|^[-*+]\s+|^>\s+/, "").replace(/\s+/g, " ");
1143
+ const sentence = words.match(/^.*?[.!?](?=\s|$)/)?.[0] ?? `${words}.`;
1144
+ return sentence.length <= 180 ? sentence : `${sentence.slice(0, 179).trimEnd()}\u2026`;
1145
+ }
1146
+ return void 0;
1147
+ };
1148
+ const turnNarratives = (model) => model.root.children.filter((span) => span.kind === "frame").map((frame, index) => {
1149
+ const text = frame.children.filter((span) => span.kind === "model").map((span) => proseLine(span.detail.output)).find((value) => value !== void 0);
1150
+ if (text !== void 0) return { frame, number: index + 1, text, source: "model" };
1151
+ const names = [];
1152
+ const walk = (span) => {
1153
+ if (span.kind === "call" && !names.includes(span.label)) names.push(span.label);
1154
+ for (const child of span.children) walk(child);
1155
+ };
1156
+ walk(frame);
1157
+ return names.length > 0 ? {
1158
+ frame,
1159
+ number: index + 1,
1160
+ text: `The agent called ${names.slice(0, 3).join(", ")}${names.length > 3 ? ` and ${names.length - 3} other flows` : ""}.`,
1161
+ source: "calls"
1162
+ } : {
1163
+ frame,
1164
+ number: index + 1,
1165
+ text: frame.children.some((span) => span.kind === "cell") ? "The agent produced a script; no flow calls were recorded in this turn." : frame.children.some((span) => span.kind === "model") ? "The model responded; no script or flow calls were recorded in this turn." : "The turn started; no model response or flow calls have been recorded.",
1166
+ source: "journal"
1167
+ };
1168
+ });
1169
+ const spanPath = (model, id) => {
1170
+ const visit = (span) => {
1171
+ if (span.id === id) return [span];
1172
+ for (const child of span.children) {
1173
+ const path = visit(child);
1174
+ if (path !== void 0) return [span, ...path];
1175
+ }
1176
+ return void 0;
1177
+ };
1178
+ return visit(model.root) ?? [model.root];
1179
+ };
1180
+ const durationWords = (ms) => {
1181
+ if (ms < 1e3) return `${Math.round(ms)}ms`;
1182
+ if (ms < 59950) return `${(ms / 1e3).toFixed(1)}s`;
1183
+ const total = Math.round(ms / 1e3);
1184
+ if (total < 3600) {
1185
+ const minutes2 = Math.floor(total / 60);
1186
+ return `${minutes2}m${String(total - minutes2 * 60).padStart(2, "0")}s`;
1187
+ }
1188
+ const minutes = Math.round(ms / 6e4);
1189
+ const hours = Math.floor(minutes / 60);
1190
+ return `${hours}h${String(minutes - hours * 60).padStart(2, "0")}m`;
1191
+ };
1192
+ const memoryItems = (value) => Array.isArray(value) ? value.flatMap((raw) => {
1193
+ const item = typeof raw === "object" && raw !== null ? raw : void 0;
1194
+ return item?.kind === "memory" && typeof item.id === "string" && typeof item.p === "number" ? [{ id: item.id, kind: "memory", relevance: 1 - item.p }] : [];
1195
+ }) : [];
1196
+ const runMemoryOf = (records) => {
1197
+ const kept = /* @__PURE__ */ new Map();
1198
+ const withheld = /* @__PURE__ */ new Map();
1199
+ let read = false;
1200
+ for (const record of records) {
1201
+ if (record.kind !== "control.agent.relevance-settled") continue;
1202
+ const payload = typeof record.payload === "object" && record.payload !== null ? record.payload : {};
1203
+ if (!Array.isArray(payload.kept) && !Array.isArray(payload.withheld)) continue;
1204
+ read = true;
1205
+ for (const item of memoryItems(payload.kept)) kept.set(item.id, item);
1206
+ for (const item of memoryItems(payload.withheld)) withheld.set(item.id, item);
1207
+ }
1208
+ if (!read) return void 0;
1209
+ const byRelevance = (left, right) => right.relevance - left.relevance || left.id.localeCompare(right.id);
1210
+ return {
1211
+ kept: [...kept.values()].sort(byRelevance),
1212
+ withheld: [...withheld.values()].filter((item) => !kept.has(item.id)).sort(byRelevance)
1213
+ };
1214
+ };
1215
+ const TASK_PREFIX = "The task for this run:\n\n";
1216
+ const taskOf = (request) => {
1217
+ const parts = Array.isArray(request.system) ? request.system : [];
1218
+ const part = parts.find((text) => typeof text === "string" && text.startsWith(TASK_PREFIX));
1219
+ const task = typeof request.task === "string" ? request.task : part?.slice(TASK_PREFIX.length);
1220
+ if (task === void 0) return void 0;
1221
+ try {
1222
+ return JSON.parse(task);
1223
+ } catch {
1224
+ return task;
1225
+ }
1226
+ };
1227
+ const hexDigest = /^[0-9a-f]{64}$/;
1228
+ const cellText = (value) => {
1229
+ const text = textOf(value);
1230
+ return text === void 0 || text.length <= 2e3 ? text : `${text.slice(0, 2e3)}\u2026`;
1231
+ };
1232
+ const callCellLabel = (started, failed) => {
1233
+ const descriptor = asRecord(started.descriptor);
1234
+ const presentation = asRecord(descriptor.presentation);
1235
+ const verbs = asRecord(presentation.verb);
1236
+ const name = started.flowName;
1237
+ const verb = asString(failed ? verbs.failure : verbs.success) ?? (failed ? `failed ${name}` : name);
1238
+ const subjectKey = asString(presentation.subject);
1239
+ const subject = subjectKey === void 0 ? void 0 : asString(asRecord(started.input)[subjectKey]);
1240
+ const text = subject === void 0 ? verb : `${verb} ${subject}`;
1241
+ return text.charAt(0).toUpperCase() + text.slice(1);
1242
+ };
1243
+ const callCellKind = (started) => {
1244
+ const activity = asString(asRecord(started.descriptor).activity);
1245
+ const name = started.flowName;
1246
+ return name === "ask" ? "ask" : activity === "reads" ? "read" : activity === "writes" ? "edit" : "run";
1247
+ };
1248
+ const decodeCallFact = import_effect.Schema.decodeUnknownOption(import_journal.CallFact.Fact);
1249
+ const callFactOf = (record) => {
1250
+ if (record.kind !== "control.engine.event") return void 0;
1251
+ const envelope = asRecord(record.payload);
1252
+ if (envelope.version !== 1 || envelope.eventType !== import_journal.CallFact.eventType || envelope.sourceSequence !== 0) {
1253
+ return void 0;
1254
+ }
1255
+ const fact = decodeCallFact(envelope.payload);
1256
+ if (fact._tag === "None" || envelope.sourceId !== `call-fact-v1:${fact.value.callId}:${fact.value.phase}`) {
1257
+ return void 0;
1258
+ }
1259
+ const stepId = /@([0-9a-f]{64}):\d+#\d+$/.exec(fact.value.identity.runId)?.[1];
1260
+ return stepId === void 0 ? void 0 : { stepId, fact: fact.value };
1261
+ };
1262
+ const stepTranscripts = (journal) => {
1263
+ const transcripts = /* @__PURE__ */ new Map();
1264
+ const entry = (key) => {
1265
+ let found = transcripts.get(key);
1266
+ if (found === void 0) transcripts.set(key, found = { cells: [], tokens: 0, models: 0 });
1267
+ return found;
1268
+ };
1269
+ const lastCell = /* @__PURE__ */ new Map();
1270
+ const calls = /* @__PURE__ */ new Map();
1271
+ for (const record of journal) {
1272
+ const sequence = record.sequence ?? 0;
1273
+ const step = (0, import_callEvents.nativeStepEvent)(record);
1274
+ if (step !== void 0) {
1275
+ const payload = asRecord(step.payload);
1276
+ const stepId = asString(asRecord(payload.step).stepId);
1277
+ const transcript = entry(stepId);
1278
+ if (step.kind === "control.agent.model-requested" && transcript.input === void 0) {
1279
+ const task = taskOf(payload);
1280
+ if (task !== void 0) transcript.input = task;
1281
+ } else if (step.kind === "control.agent.model-settled") {
1282
+ const usage = asRecord(payload.usage);
1283
+ const tokens = (asNumber(usage.inputTokens) ?? 0) + (asNumber(usage.outputTokens) ?? 0);
1284
+ const duration = asNumber(payload.durationMillis);
1285
+ const text = cellText(payload.text);
1286
+ transcript.tokens += tokens;
1287
+ transcript.models += 1;
1288
+ transcript.cells.push({
1289
+ id: `cell:${sequence}`,
1290
+ kind: "think",
1291
+ label: "Model reply",
1292
+ ...text === void 0 ? {} : { quote: text },
1293
+ tokens,
1294
+ ...duration === void 0 ? {} : { took_s: Math.max(0, duration) / 1e3 }
1295
+ });
1296
+ } else if (step.kind === "control.agent.cell-produced") {
1297
+ const code = cellText(payload.text);
1298
+ const cell = {
1299
+ id: `cell:${sequence}`,
1300
+ kind: "run",
1301
+ label: "Ran a cell",
1302
+ ...code === void 0 ? {} : { code }
1303
+ };
1304
+ transcript.cells.push(cell);
1305
+ lastCell.set(stepId, cell);
1306
+ } else if (step.kind === "control.agent.cell-printed") {
1307
+ const cell = lastCell.get(stepId);
1308
+ const printed = cellText(payload.text);
1309
+ if (cell !== void 0 && printed !== void 0 && printed !== "") {
1310
+ cell.output = cell.output === void 0 ? printed : `${cell.output}
1311
+ ${printed}`;
1312
+ }
1313
+ } else if (step.kind === "control.agent.cell-settled") {
1314
+ const cell = lastCell.get(stepId);
1315
+ if (cell !== void 0) cell.tone = asString(payload.outcome) === "failure" ? "fail" : "ok";
1316
+ }
1317
+ continue;
1318
+ }
1319
+ const call = callFactOf(record);
1320
+ if (call === void 0) continue;
1321
+ const handle = `${call.stepId}:${call.fact.callId}`;
1322
+ if (call.fact.phase === "invoked") {
1323
+ const input = cellText(call.fact.input);
1324
+ const cell = {
1325
+ id: `cell:${sequence}`,
1326
+ kind: callCellKind(call.fact),
1327
+ label: callCellLabel(call.fact, false),
1328
+ ...input === void 0 ? {} : { code: input },
1329
+ tone: "live"
1330
+ };
1331
+ entry(call.stepId).cells.push(cell);
1332
+ calls.set(handle, { cell, started: call.fact });
1333
+ continue;
1334
+ }
1335
+ const open = calls.get(handle);
1336
+ if (open === void 0) continue;
1337
+ const failed = call.fact.outcome === "failure";
1338
+ open.cell.label = callCellLabel(open.started, failed);
1339
+ open.cell.tone = failed ? "fail" : "ok";
1340
+ const result = failed ? cellText(call.fact.message) : cellText(call.fact.value);
1341
+ if (result !== void 0) open.cell.output = result;
1342
+ }
1343
+ return transcripts;
1344
+ };
1345
+ const nodeDispatches = (row) => {
1346
+ if (!row.id.startsWith("engine-node:")) return [];
1347
+ const fields = asRecord(row.detail.fields);
1348
+ const execution = asString(fields.executionId);
1349
+ const digests = asRecord(fields.payload).stepKeyDigests;
1350
+ if (execution === void 0 || !Array.isArray(digests)) return [];
1351
+ return [
1352
+ ...new Set(digests.filter((digest) => typeof digest === "string" && hexDigest.test(digest)))
1353
+ ].map((digest) => `${execution}:${digest}`);
1354
+ };
1355
+ const PLAN_STRUCTURE = /* @__PURE__ */ new Set([
1356
+ "Succeed",
1357
+ "Fail",
1358
+ "All",
1359
+ "Race",
1360
+ "Map",
1361
+ "AndThen",
1362
+ "Branch",
1363
+ "Catch",
1364
+ "FlowCall",
1365
+ "FunctionIdentity",
1366
+ "PlannedReference"
1367
+ ]);
1368
+ const RECEIPT_HEAD = /^\{"checkId":"[^"\\]*"(?:,"[A-Za-z]+":(?:"[^"\\]*"|-?\d+))*,"status":"(passed|failed|superseded)"/;
1369
+ const checkFailures = (output) => {
1370
+ if (output === void 0) return 0;
1371
+ const head = RECEIPT_HEAD.exec(output);
1372
+ if (head !== null) return head[1] === "failed" ? 1 : 0;
1373
+ let value;
1374
+ try {
1375
+ value = JSON.parse(output);
1376
+ } catch {
1377
+ return 0;
1378
+ }
1379
+ return (Array.isArray(value) ? value : []).filter((receipt) => {
1380
+ const record = asRecord(receipt);
1381
+ return typeof record.checkId === "string" && record.status === "failed";
1382
+ }).length;
1383
+ };
1384
+ const engineNodeShapes = (journal) => {
1385
+ const shapes = /* @__PURE__ */ new Map();
1386
+ for (const record of journal) {
1387
+ if (record.kind !== "control.engine.event") continue;
1388
+ const envelope = asRecord(record.payload);
1389
+ const executionId = asString(envelope.executionId);
1390
+ const generation = asNumber(envelope.generation);
1391
+ const payload = asRecord(envelope.payload);
1392
+ if (executionId === void 0 || generation === void 0) continue;
1393
+ const prefix = `engine-node:${encodeURIComponent(`${encodeURIComponent(executionId)}:${generation}`)}:`;
1394
+ if (envelope.eventType === "flows.engine.plan-recorded" || envelope.eventType === "flows.engine.subgraph-appended") {
1395
+ const nodes = asRecord(payload.graph).nodes;
1396
+ for (const node of Array.isArray(nodes) ? nodes : []) {
1397
+ const shape = asRecord(node);
1398
+ const id = asString(shape.id);
1399
+ if (id !== void 0) {
1400
+ shapes.set(prefix + encodeURIComponent(id), { kind: asString(shape.kind), action: asString(shape.action) });
1401
+ }
1402
+ }
1403
+ } else if (envelope.eventType === "flows.engine.node-scheduled") {
1404
+ const id = asString(payload.nodeId);
1405
+ if (id === void 0) continue;
1406
+ const known = shapes.get(prefix + encodeURIComponent(id));
1407
+ shapes.set(prefix + encodeURIComponent(id), {
1408
+ kind: asString(payload.kind) ?? known?.kind,
1409
+ action: asString(payload.action) ?? known?.action
1410
+ });
1411
+ }
1412
+ }
1413
+ return shapes;
1414
+ };
1415
+ const monitorFromJournal = (run, records, at) => {
1416
+ const last = records.reduce((last2, row) => Math.max(last2, row.sequence ?? 0), 0);
1417
+ const journal = at === void 0 ? records : records.filter((row) => (row.sequence ?? 0) <= at);
1418
+ const lifecycleRow = [...journal].reverse().find(
1419
+ (row) => /^control\.run\.(running|waiting-approval|paused|suspended|held|completed|failed|cancelled|interrupted)$/.test(
1420
+ row.kind ?? ""
1421
+ ) && (row.runId === void 0 || row.runId === run.runId)
1422
+ );
1423
+ const status = at === void 0 ? run.status : lifecycleRow?.kind?.split(".").at(-1) ?? "running";
1424
+ const state = (value) => value === "completed" || value === "done" ? "done" : value === "failed" ? "failed" : value === "cancelled" || value === "interrupted" ? "interrupted" : value === "held" ? "held" : value === "waiting" || value === "waiting-approval" || value === "paused" || value === "suspended" ? "waiting" : "running";
1425
+ const trace = traceFromJournal({ ...run, status }, journal);
1426
+ const engineLabel = (label) => import_actionRenderings.ACTION_RENDERINGS[label] === null || /^<(?:boundary:|quota-park>|structured-output-count>)/.test(label);
1427
+ const bookkeeping = (row) => engineLabel(row.label);
1428
+ const transcripts = stepTranscripts(journal);
1429
+ const dispatchesOf = new Map(trace.rows.map((row) => [row.id, nodeDispatches(row)]));
1430
+ const structural = (kind) => kind !== void 0 && PLAN_STRUCTURE.has(kind);
1431
+ const nodeShapes = engineNodeShapes(journal);
1432
+ const calls = trace.rows.filter((row) => {
1433
+ if (row.kind !== "call" || bookkeeping(row) || row.id.startsWith("step:")) return false;
1434
+ const shape = nodeShapes.get(row.id.replace(/#\d+$/, ""));
1435
+ return shape === void 0 || !structural(shape.kind);
1436
+ });
1437
+ const transcriptOf = (row) => {
1438
+ const parts = dispatchesOf.get(row.id).flatMap((dispatch) => {
1439
+ const found = transcripts.get(dispatch.slice(dispatch.lastIndexOf(":") + 1));
1440
+ return found === void 0 ? [] : [found];
1441
+ });
1442
+ return {
1443
+ cells: parts.flatMap((part) => part.cells).sort(
1444
+ (left, right) => Number(left.id.slice(5)) - Number(right.id.slice(5))
1445
+ ),
1446
+ tokens: parts.reduce((total, part) => total + part.tokens, 0),
1447
+ models: parts.reduce((total, part) => total + part.models, 0),
1448
+ input: parts.find((part) => part.input !== void 0)?.input
1449
+ };
1450
+ };
1451
+ const steps = calls.map((row) => {
1452
+ const meter = dispatchesOf.get(row.id);
1453
+ const transcript = transcriptOf(row);
1454
+ return {
1455
+ ...(() => {
1456
+ const matched = /^(engine-node:.*)#(\d+)$/.exec(row.id);
1457
+ const id = matched?.[1] ?? row.id;
1458
+ const k = Number(matched?.[2] ?? 1);
1459
+ return { key: `${id}#${k}`, id, k };
1460
+ })(),
1461
+ label: row.label,
1462
+ state: row.status,
1463
+ started_at: new Date(row.startedAt).toISOString(),
1464
+ ...row.endedAt === void 0 ? {} : { ended_at: new Date(row.endedAt).toISOString(), took_s: Math.max(0, row.endedAt - row.startedAt) / 1e3 },
1465
+ ...row.detail.input !== void 0 ? { input: row.detail.input } : transcript.input !== void 0 ? { input: transcript.input } : {},
1466
+ ...row.detail.output === void 0 ? {} : { output: row.detail.output },
1467
+ // The install prices these dispatches from its metered proxy rows and
1468
+ // replaces them with `usage`; the journal's own token count rides along.
1469
+ ...meter.length === 0 ? {} : { meter },
1470
+ ...transcript.models === 0 ? {} : { model_calls: transcript.models, tokens: transcript.tokens }
1471
+ };
1472
+ });
1473
+ const tone = (value) => value === "failed" ? "fail" : value === "completed" ? "ok" : value === "waiting" ? "wait" : "live";
1474
+ const phases = calls.map((row, index) => {
1475
+ const transcript = transcriptOf(row).cells;
1476
+ const failedChecks = checkFailures(row.detail.output);
1477
+ const cells = transcript.length > 0 ? transcript : [{
1478
+ id: `cell:${row.id}`,
1479
+ kind: /Edited/.test(row.label) ? "edit" : /Read/.test(row.label) ? "read" : "run",
1480
+ label: row.label,
1481
+ ...row.detail.output === void 0 ? {} : { output: row.detail.output },
1482
+ tone: tone(row.status)
1483
+ }];
1484
+ return {
1485
+ id: `phase:${row.id}`,
1486
+ step: steps[index].key,
1487
+ // The title is the Appendix C label plus the outcome its recorded
1488
+ // output reports: "Ran checks · 1 failed".
1489
+ title: failedChecks === 0 ? row.label : `${row.label} \xB7 ${failedChecks} failed`,
1490
+ took_s: Math.max(0, (row.endedAt ?? row.startedAt) - row.startedAt) / 1e3,
1491
+ tone: failedChecks === 0 ? tone(row.status) : "fail",
1492
+ cells
1493
+ };
1494
+ });
1495
+ const declaredGraph = (0, import_EngineTrace.engineExecutionEvidence)(journal).filter((execution) => execution.coherent).flatMap(
1496
+ (execution) => {
1497
+ const prefix = `engine-node:${encodeURIComponent(`${encodeURIComponent(execution.executionId)}:${execution.generation}`)}:`;
1498
+ const nodes = execution.graph?.nodes ?? [];
1499
+ const hidden = new Map(
1500
+ nodes.filter((node) => engineLabel(node.action ?? node.id) || structural(node.kind)).map((node) => [node.id, node])
1501
+ );
1502
+ const visibleDeps = (id, seen) => {
1503
+ const node = hidden.get(id);
1504
+ if (node === void 0) return [prefix + encodeURIComponent(id)];
1505
+ if (seen.has(id)) return [];
1506
+ return node.dependsOn.flatMap((dependency) => visibleDeps(dependency, /* @__PURE__ */ new Set([...seen, id])));
1507
+ };
1508
+ return nodes.filter((node) => !hidden.has(node.id)).map((node) => {
1509
+ const id = prefix + encodeURIComponent(node.id);
1510
+ const instances = calls.filter((row) => row.id.startsWith(`${id}#`));
1511
+ const current = instances.at(-1);
1512
+ return {
1513
+ id,
1514
+ label: (0, import_inspectLabels.inspectLabel)(node.action ?? node.id),
1515
+ // A branch not taken never ran: it stays next, even in a finished run.
1516
+ state: current === void 0 || current.status === "skipped" ? "next" : current.status === "completed" ? "done" : current.status === "failed" ? "failed" : current.status === "waiting" ? "waiting" : "current",
1517
+ deps: [...new Set(node.dependsOn.flatMap((dependency) => visibleDeps(dependency, /* @__PURE__ */ new Set([node.id]))))]
1518
+ };
1519
+ });
1520
+ }
1521
+ );
1522
+ const usageOf = (row) => (row.detail.usage?.inputTokens ?? 0) + (row.detail.usage?.outputTokens ?? 0);
1523
+ const tokens = trace.rows.reduce((total, row) => total + usageOf(row), 0);
1524
+ const unmetered = trace.rows.filter((row) => row.kind === "model" && asRecord(row.detail.fields).step === void 0).reduce((total, row) => total + usageOf(row), 0);
1525
+ const approvalWaits = trace.rows.filter((row) => row.kind === "approval").map((row) => ({
1526
+ id: row.id,
1527
+ kind: "approval",
1528
+ label: row.label,
1529
+ since: new Date(row.startedAt).toISOString(),
1530
+ ...row.endedAt === void 0 ? {} : {
1531
+ settled: { by: { kind: "system", color_index: 7 }, at: new Date(row.endedAt).toISOString() }
1532
+ }
1533
+ }));
1534
+ const custom = [...journal].reverse().find((row) => (row.runId === void 0 || row.runId === run.runId) && row.kind === "control.engine.event" && asRecord(row.payload).eventType === "flows.run.presentation");
1535
+ const presentation = asRecord(asRecord(custom?.payload).payload);
1536
+ const text = asString(presentation.text);
1537
+ const customView = presentation.kind === "text" && text !== void 0 && text.length <= 65536 && Object.keys(presentation).every((key) => key === "kind" || key === "text") ? { presentation: { kind: "text", text } } : {};
1538
+ return {
1539
+ ...customView,
1540
+ id: run.runId,
1541
+ flow: run.flowId,
1542
+ version: "",
1543
+ title: run.flowId,
1544
+ state: state(status),
1545
+ attempts: [{
1546
+ n: 1,
1547
+ run_id: run.runId,
1548
+ state: state(status),
1549
+ steps,
1550
+ phases,
1551
+ graph: declaredGraph.length > 0 ? declaredGraph : calls.map((row) => ({
1552
+ id: row.id,
1553
+ label: row.label,
1554
+ state: row.status === "skipped" ? "next" : row.status === "completed" ? "done" : row.status === "failed" ? "failed" : row.status === "waiting" ? "waiting" : "current",
1555
+ deps: []
1556
+ }))
1557
+ }],
1558
+ waits: [
1559
+ ...approvalWaits,
1560
+ ...(0, import_EngineTrace.engineExecutionEvidence)(journal).filter((execution) => execution.coherent).flatMap(
1561
+ (execution) => execution.waits.map((wait) => ({
1562
+ id: wait.id,
1563
+ kind: wait.kind,
1564
+ label: (0, import_inspectLabels.inspectLabel)("wait"),
1565
+ since: new Date(wait.since).toISOString(),
1566
+ ...wait.settledAt === void 0 ? {} : {
1567
+ settled: {
1568
+ by: { kind: "system", color_index: 7 },
1569
+ at: new Date(wait.settledAt).toISOString()
1570
+ }
1571
+ }
1572
+ }))
1573
+ )
1574
+ ],
1575
+ tokens,
1576
+ // Spend is priced where model calls are metered. The host never publishes
1577
+ // an unknown total as zero: a run with model tokens leaves cost to the install.
1578
+ time_s: Math.max(0, trace.extent.end - trace.extent.start) / 1e3,
1579
+ ...tokens === 0 ? { cost_usd: 0 } : {},
1580
+ ...unmetered === 0 ? {} : { unmetered_tokens: unmetered },
1581
+ engine: trace.rows.filter(
1582
+ (row) => row.kind === "event" || row.kind === "execution" || row.kind === "attempt" || bookkeeping(row)
1583
+ ).map((row) => ({ label: row.label, detail: row.detail.output ?? row.detail.message ?? "" })),
1584
+ journal: journal.map((row) => ({
1585
+ seq: row.sequence ?? 0,
1586
+ at: new Date(row.occurredAt ?? 0).toISOString(),
1587
+ type: row.kind ?? "event",
1588
+ text: JSON.stringify(row.payload) ?? "null"
1589
+ })),
1590
+ ...at === void 0 ? {} : { replay: { at: Math.min(at, last), last } }
1591
+ };
1592
+ };
1593
+ //# sourceMappingURL=RunTrace.js.map