zidane 7.2.5 → 8.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (376) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +34 -6
  3. package/dist/{acp-D-tVyUjw.js → acp-DQDhi2dj.js} +230 -77
  4. package/dist/acp-DQDhi2dj.js.map +1 -0
  5. package/dist/acp-cli.d.ts +1 -1
  6. package/dist/acp-cli.js +9 -66
  7. package/dist/acp-cli.js.map +1 -1
  8. package/dist/acp.d.ts +10 -590
  9. package/dist/acp.d.ts.map +1 -1
  10. package/dist/acp.js +3 -3
  11. package/dist/{agent-D0zZnGbt.js → agent-DSLNmBp0.js} +14401 -13214
  12. package/dist/agent-DSLNmBp0.js.map +1 -0
  13. package/dist/agent.d.ts +1 -1
  14. package/dist/agent.js +3 -2
  15. package/dist/aliasing-lVFbm81n.js +217 -0
  16. package/dist/aliasing-lVFbm81n.js.map +1 -0
  17. package/dist/{anthropic-C2aole0G.js → anthropic-CD00LhUP.js} +1442 -1264
  18. package/dist/anthropic-CD00LhUP.js.map +1 -0
  19. package/dist/artifacts-CV2hUKnL.js.map +1 -1
  20. package/dist/{atomic-write-B7zr1ddF.js → atomic-write-Ijgf2Mhc.js} +13 -3
  21. package/dist/atomic-write-Ijgf2Mhc.js.map +1 -0
  22. package/dist/call-tool-dHlbGOIY.js +70 -0
  23. package/dist/call-tool-dHlbGOIY.js.map +1 -0
  24. package/dist/chat/pure.d.ts +372 -6
  25. package/dist/chat/pure.d.ts.map +1 -1
  26. package/dist/chat/pure.js +35 -244
  27. package/dist/chat/pure.js.map +1 -1
  28. package/dist/{approvals-DKaJZYlm.js → chat-JPJJ8uu5.js} +15879 -14631
  29. package/dist/chat-JPJJ8uu5.js.map +1 -0
  30. package/dist/chat.d.ts +4 -6
  31. package/dist/chat.js +23 -12
  32. package/dist/cli-shared-C-YCaglL.js +159 -0
  33. package/dist/cli-shared-C-YCaglL.js.map +1 -0
  34. package/dist/client-core-BQSyDALT.d.ts +2115 -0
  35. package/dist/client-core-BQSyDALT.d.ts.map +1 -0
  36. package/dist/codemode-worker.d.ts +1 -0
  37. package/dist/codemode-worker.js +155 -0
  38. package/dist/codemode-worker.js.map +1 -0
  39. package/dist/codemode.d.ts +352 -0
  40. package/dist/codemode.d.ts.map +1 -0
  41. package/dist/codemode.js +5 -0
  42. package/dist/connection-Dr-Js4yZ.d.ts +28 -0
  43. package/dist/connection-Dr-Js4yZ.d.ts.map +1 -0
  44. package/dist/connection-loop-gdh22LTI.js +112 -0
  45. package/dist/connection-loop-gdh22LTI.js.map +1 -0
  46. package/dist/context-segments-BHKlagL6.js +1016 -0
  47. package/dist/context-segments-BHKlagL6.js.map +1 -0
  48. package/dist/{context-transport-T_6AYIvy.js → context-transport-DSMTUsK1.js} +3 -3
  49. package/dist/{context-transport-T_6AYIvy.js.map → context-transport-DSMTUsK1.js.map} +1 -1
  50. package/dist/contexts/daytona.d.ts +19 -8
  51. package/dist/contexts/daytona.d.ts.map +1 -1
  52. package/dist/contexts/daytona.js +1 -440
  53. package/dist/contexts/docker.d.ts +36 -7
  54. package/dist/contexts/docker.d.ts.map +1 -1
  55. package/dist/contexts/docker.js +1 -456
  56. package/dist/contexts/e2b.d.ts +68 -13
  57. package/dist/contexts/e2b.d.ts.map +1 -1
  58. package/dist/contexts/e2b.js +1 -382
  59. package/dist/contexts/sandbox.d.ts +1 -1
  60. package/dist/contexts/sandbox.js +5 -0
  61. package/dist/contexts/sandbox.js.map +1 -1
  62. package/dist/{contexts-CRE9pw07.js → contexts-d7UolYot.js} +1059 -524
  63. package/dist/contexts-d7UolYot.js.map +1 -0
  64. package/dist/contexts.d.ts +3 -3
  65. package/dist/contexts.js +1 -1
  66. package/dist/cred-keys-GpBg71cP.js +105 -0
  67. package/dist/cred-keys-GpBg71cP.js.map +1 -0
  68. package/dist/{auth-BG2rVKSt.js → credentials-JttEuRON.js} +55 -206
  69. package/dist/credentials-JttEuRON.js.map +1 -0
  70. package/dist/{cursor-iojRXHF9.js → cursor-CdjaQTBW.js} +3 -3
  71. package/dist/{cursor-iojRXHF9.js.map → cursor-CdjaQTBW.js.map} +1 -1
  72. package/dist/daemon-cli.d.ts +1 -1
  73. package/dist/daemon-cli.js +3 -2
  74. package/dist/daemon-cli.js.map +1 -1
  75. package/dist/daytona-DG3omipZ.js +513 -0
  76. package/dist/daytona-DG3omipZ.js.map +1 -0
  77. package/dist/defaults-Cx3zvDOV.js +23 -0
  78. package/dist/defaults-Cx3zvDOV.js.map +1 -0
  79. package/dist/dispatcher-BMlu2BmZ.js +4941 -0
  80. package/dist/dispatcher-BMlu2BmZ.js.map +1 -0
  81. package/dist/docker-BZhMMJUp.js +727 -0
  82. package/dist/docker-BZhMMJUp.js.map +1 -0
  83. package/dist/e2b-CEVOdRib.js +480 -0
  84. package/dist/e2b-CEVOdRib.js.map +1 -0
  85. package/dist/edit-utils-EGosADZq.js +234 -0
  86. package/dist/edit-utils-EGosADZq.js.map +1 -0
  87. package/dist/environment-8wsKE2Ln.js +214 -0
  88. package/dist/environment-8wsKE2Ln.js.map +1 -0
  89. package/dist/eval-BNcvle_J.js +1595 -0
  90. package/dist/eval-BNcvle_J.js.map +1 -0
  91. package/dist/eval.d.ts +2 -2
  92. package/dist/eval.js +1 -1489
  93. package/dist/executor-Cx5-8yqi.js +621 -0
  94. package/dist/executor-Cx5-8yqi.js.map +1 -0
  95. package/dist/extension-authoring-DyGGmq9V.js +385 -0
  96. package/dist/extension-authoring-DyGGmq9V.js.map +1 -0
  97. package/dist/extensions.d.ts +2 -2
  98. package/dist/extensions.js +3 -3
  99. package/dist/{fetch-url-DX75gpL0.js → fetch-url-Ct2TjDWt.js} +4 -4
  100. package/dist/{fetch-url-DX75gpL0.js.map → fetch-url-Ct2TjDWt.js.map} +1 -1
  101. package/dist/{format-BF745pLL.js → format-C2NQEVUH.js} +39 -2
  102. package/dist/format-C2NQEVUH.js.map +1 -0
  103. package/dist/format-bytes-C7tfc3Zm.js +55 -0
  104. package/dist/format-bytes-C7tfc3Zm.js.map +1 -0
  105. package/dist/headless-C_rNUuYC.js +960 -0
  106. package/dist/headless-C_rNUuYC.js.map +1 -0
  107. package/dist/headless.d.ts +1 -1
  108. package/dist/headless.js +1 -413
  109. package/dist/{history-search-C4bk1Wz_.js → history-search-CcYzF8-0.js} +7 -3
  110. package/dist/history-search-CcYzF8-0.js.map +1 -0
  111. package/dist/history-search-worker.d.ts +1 -1
  112. package/dist/history-search-worker.js +1 -1
  113. package/dist/host-D7NrI03V.js +378 -0
  114. package/dist/host-D7NrI03V.js.map +1 -0
  115. package/dist/host-signals-BcP5QKUD.js +118 -0
  116. package/dist/host-signals-BcP5QKUD.js.map +1 -0
  117. package/dist/identity-CwfO8K-t.js +26 -0
  118. package/dist/identity-CwfO8K-t.js.map +1 -0
  119. package/dist/{index-BgN1T3lk.d.ts → index-BGe1fQT7.d.ts} +10987 -9320
  120. package/dist/index-BGe1fQT7.d.ts.map +1 -0
  121. package/dist/index-BVQsIKGn.d.ts +448 -0
  122. package/dist/index-BVQsIKGn.d.ts.map +1 -0
  123. package/dist/{index-C6NEd5y_.d.ts → index-CHABJd-L.d.ts} +3386 -502
  124. package/dist/index-CHABJd-L.d.ts.map +1 -0
  125. package/dist/{index-C37_ppWv.d.ts → index-D6a7qXpg.d.ts} +2 -3
  126. package/dist/index-D6a7qXpg.d.ts.map +1 -0
  127. package/dist/index.d.ts +6 -6
  128. package/dist/index.js +27 -23
  129. package/dist/{completion-core-BRo86R_L.js → inline-ghost-BVRQeGoL.js} +50 -2
  130. package/dist/inline-ghost-BVRQeGoL.js.map +1 -0
  131. package/dist/ipc/remote.d.ts +313 -0
  132. package/dist/ipc/remote.d.ts.map +1 -0
  133. package/dist/ipc/remote.js +4 -0
  134. package/dist/ipc.d.ts +6 -964
  135. package/dist/ipc.js +403 -4
  136. package/dist/ipc.js.map +1 -0
  137. package/dist/{isolation-Kfoof0MM.d.ts → isolation-D9L650W5.d.ts} +100 -15
  138. package/dist/isolation-D9L650W5.d.ts.map +1 -0
  139. package/dist/json-rpc--HXQti1E.js +350 -0
  140. package/dist/json-rpc--HXQti1E.js.map +1 -0
  141. package/dist/links-j8rED1sR.js +603 -0
  142. package/dist/links-j8rED1sR.js.map +1 -0
  143. package/dist/local-terminal-D8QThwo_.js +252 -0
  144. package/dist/local-terminal-D8QThwo_.js.map +1 -0
  145. package/dist/{logger--C1VQjwJ.js → logger-Gtqlayx8.js} +199 -173
  146. package/dist/logger-Gtqlayx8.js.map +1 -0
  147. package/dist/logs-view-CWG8aUAG.js.map +1 -1
  148. package/dist/{mcp-CgNd-f3F.js → mcp-_wecH9Qe.js} +608 -562
  149. package/dist/mcp-_wecH9Qe.js.map +1 -0
  150. package/dist/mcp.d.ts +2 -2
  151. package/dist/mcp.js +2 -2
  152. package/dist/media-sniff-UKijEaiQ.js.map +1 -1
  153. package/dist/{messages-2jcOA_5R.js → messages-BqiwcD2Q.js} +1017 -1014
  154. package/dist/messages-BqiwcD2Q.js.map +1 -0
  155. package/dist/{oauth-DxHO17JE.js → oauth-Px_pBB9W.js} +5 -5
  156. package/dist/{oauth-DxHO17JE.js.map → oauth-Px_pBB9W.js.map} +1 -1
  157. package/dist/{openai-compat-Dy56weK8.js → openai-compat-CFrpH7uq.js} +432 -589
  158. package/dist/openai-compat-CFrpH7uq.js.map +1 -0
  159. package/dist/orchestration-BCGmB8Ps.js +511 -0
  160. package/dist/orchestration-BCGmB8Ps.js.map +1 -0
  161. package/dist/output/stream-json.d.ts +1 -2
  162. package/dist/output/stream-json.d.ts.map +1 -1
  163. package/dist/output/stream-json.js +1 -1
  164. package/dist/output/terminal.d.ts +1 -2
  165. package/dist/output/terminal.d.ts.map +1 -1
  166. package/dist/output/terminal.js +13 -7
  167. package/dist/output/terminal.js.map +1 -1
  168. package/dist/{plugins-gbI7SBA6.js → plugins-DS7mahzZ.js} +20 -101
  169. package/dist/plugins-DS7mahzZ.js.map +1 -0
  170. package/dist/plugins.d.ts +1 -1
  171. package/dist/plugins.js +1 -2
  172. package/dist/prelude-Cxo4t74B.js +517 -0
  173. package/dist/prelude-Cxo4t74B.js.map +1 -0
  174. package/dist/presets.d.ts +1 -1
  175. package/dist/presets.js +1 -2
  176. package/dist/project-root-B8zADr4o.js +167 -0
  177. package/dist/project-root-B8zADr4o.js.map +1 -0
  178. package/dist/project-user-paths-BSgtrRxl.js +58 -0
  179. package/dist/project-user-paths-BSgtrRxl.js.map +1 -0
  180. package/dist/{prompts-Pqc3JdW_.d.ts → prompts-DYcvqShf.d.ts} +14 -11
  181. package/dist/prompts-DYcvqShf.d.ts.map +1 -0
  182. package/dist/protocol-DnhqqSmE.js +13 -0
  183. package/dist/protocol-DnhqqSmE.js.map +1 -0
  184. package/dist/providers/anthropic.d.ts +2 -2
  185. package/dist/providers/anthropic.js +1 -2
  186. package/dist/providers/arcee.d.ts +1 -1
  187. package/dist/providers/arcee.js +1 -1
  188. package/dist/providers/baseten.d.ts +1 -1
  189. package/dist/providers/baseten.js +1 -1
  190. package/dist/providers/cerebras.d.ts +1 -1
  191. package/dist/providers/cerebras.js +3 -2
  192. package/dist/providers/cerebras.js.map +1 -1
  193. package/dist/providers/local.d.ts +1 -1
  194. package/dist/providers/local.js +1 -1
  195. package/dist/providers/openai-compat.d.ts +1 -1
  196. package/dist/providers/openai-compat.js +1 -2
  197. package/dist/providers/openai.d.ts +1 -1
  198. package/dist/providers/openai.js +15 -12
  199. package/dist/providers/openai.js.map +1 -1
  200. package/dist/providers/openrouter.d.ts +1 -1
  201. package/dist/providers/openrouter.js +3 -2
  202. package/dist/providers/openrouter.js.map +1 -1
  203. package/dist/providers/xai.d.ts +1 -1
  204. package/dist/providers/xai.js +3 -3
  205. package/dist/{providers-BVhnFyiY.js → providers-XUR7F4Hi.js} +4 -4
  206. package/dist/{providers-BVhnFyiY.js.map → providers-XUR7F4Hi.js.map} +1 -1
  207. package/dist/providers.d.ts +1 -1
  208. package/dist/providers.js +4 -4
  209. package/dist/registry-D6ShBWJU.js +5234 -0
  210. package/dist/registry-D6ShBWJU.js.map +1 -0
  211. package/dist/remote-hosts-BtA_9ZGp.js +97 -0
  212. package/dist/remote-hosts-BtA_9ZGp.js.map +1 -0
  213. package/dist/restate.d.ts +2 -3
  214. package/dist/restate.d.ts.map +1 -1
  215. package/dist/restate.js +631 -572
  216. package/dist/restate.js.map +1 -1
  217. package/dist/run-summary-CklLiZ4y.js +288 -0
  218. package/dist/run-summary-CklLiZ4y.js.map +1 -0
  219. package/dist/{sandbox-BH0WQkXn.d.ts → sandbox-C5dR5DwQ.d.ts} +6 -3
  220. package/dist/sandbox-C5dR5DwQ.d.ts.map +1 -0
  221. package/dist/session/sqlite.d.ts +1 -2
  222. package/dist/session/sqlite.d.ts.map +1 -1
  223. package/dist/session/sqlite.js +1 -616
  224. package/dist/session-factory-BUGY5P40.js +1576 -0
  225. package/dist/session-factory-BUGY5P40.js.map +1 -0
  226. package/dist/{session-BqRP1hS7.js → session-xh9JXu6i.js} +94 -52
  227. package/dist/session-xh9JXu6i.js.map +1 -0
  228. package/dist/session.d.ts +1 -1
  229. package/dist/session.js +2 -2
  230. package/dist/settings-keys-Ckf29NeM.js +677 -0
  231. package/dist/settings-keys-Ckf29NeM.js.map +1 -0
  232. package/dist/shell-path-Dqaoow2J.js +412 -0
  233. package/dist/shell-path-Dqaoow2J.js.map +1 -0
  234. package/dist/{skills-BC3dodWp.js → skills-DKqZJm4X.js} +430 -470
  235. package/dist/skills-DKqZJm4X.js.map +1 -0
  236. package/dist/skills.d.ts +2 -2
  237. package/dist/skills.js +1 -2
  238. package/dist/source-mPExaUm8.js +381 -0
  239. package/dist/source-mPExaUm8.js.map +1 -0
  240. package/dist/sqlite-DV1DQzN2.js +698 -0
  241. package/dist/sqlite-DV1DQzN2.js.map +1 -0
  242. package/dist/{src-CkNQKFKr.js → src-BRMYRJib.js} +903 -1121
  243. package/dist/src-BRMYRJib.js.map +1 -0
  244. package/dist/{stdio-DPpBDPx5.js → stdio-C6YyoW3I.js} +4 -4
  245. package/dist/{stdio-DPpBDPx5.js.map → stdio-C6YyoW3I.js.map} +1 -1
  246. package/dist/{stdio-loader-Bbx19dMZ.js → stdio-loader-C830Vg-Z.js} +4 -4
  247. package/dist/{stdio-loader-Bbx19dMZ.js.map → stdio-loader-C830Vg-Z.js.map} +1 -1
  248. package/dist/system-prompt-MNVHatSD.d.ts.map +1 -1
  249. package/dist/timeout-DEaqslLO.d.ts.map +1 -1
  250. package/dist/todo-edits-Dn251YUP.js +1790 -0
  251. package/dist/todo-edits-Dn251YUP.js.map +1 -0
  252. package/dist/{turn-operations-DrbJlpq9.js → tool-formatters-IQFDrdrs.js} +1456 -2120
  253. package/dist/tool-formatters-IQFDrdrs.js.map +1 -0
  254. package/dist/tool-state-Dku6YqAB.js +989 -0
  255. package/dist/tool-state-Dku6YqAB.js.map +1 -0
  256. package/dist/tools/fetch-url.d.ts +1 -2
  257. package/dist/tools/fetch-url.d.ts.map +1 -1
  258. package/dist/tools/fetch-url.js +1 -2
  259. package/dist/tools/prompts.d.ts +1 -1
  260. package/dist/tools/prompts.js +7 -7
  261. package/dist/tools/prompts.js.map +1 -1
  262. package/dist/tools/web-search.d.ts +1 -2
  263. package/dist/tools/web-search.d.ts.map +1 -1
  264. package/dist/tools/web-search.js +2 -2
  265. package/dist/tools/web-search.js.map +1 -1
  266. package/dist/tools-_DnT3AGM.js +578 -0
  267. package/dist/tools-_DnT3AGM.js.map +1 -0
  268. package/dist/tools.d.ts +3 -3
  269. package/dist/tools.js +4 -2
  270. package/dist/tui.d.ts +534 -517
  271. package/dist/tui.d.ts.map +1 -1
  272. package/dist/tui.js +34933 -27243
  273. package/dist/tui.js.map +1 -1
  274. package/dist/turn-operations-B8sokwi5.js +333 -0
  275. package/dist/turn-operations-B8sokwi5.js.map +1 -0
  276. package/dist/turn-operations-DQX5ZZni.d.ts +3089 -0
  277. package/dist/turn-operations-DQX5ZZni.d.ts.map +1 -0
  278. package/dist/types-C7ZFOztE.d.ts +132 -0
  279. package/dist/types-C7ZFOztE.d.ts.map +1 -0
  280. package/dist/types-CH5XpIHw.js +114 -0
  281. package/dist/types-CH5XpIHw.js.map +1 -0
  282. package/dist/{types-CWgENVLY.js → types-Cu0ZGDu9.js} +10 -6
  283. package/dist/types-Cu0ZGDu9.js.map +1 -0
  284. package/dist/types-IqegbJEE.d.ts +624 -0
  285. package/dist/types-IqegbJEE.d.ts.map +1 -0
  286. package/dist/types.d.ts +4 -4
  287. package/dist/types.js +1 -1
  288. package/dist/url-D8HCl65b.js +1259 -0
  289. package/dist/url-D8HCl65b.js.map +1 -0
  290. package/dist/wasm-BVT-j5cl.js +33 -0
  291. package/dist/wasm-BVT-j5cl.js.map +1 -0
  292. package/dist/workspace-exec-stream-SV2R9d5S.js +355 -0
  293. package/dist/workspace-exec-stream-SV2R9d5S.js.map +1 -0
  294. package/dist/ws-CIHMvlSh.js +952 -0
  295. package/dist/ws-CIHMvlSh.js.map +1 -0
  296. package/dist/ws-client-N7NxzvQp.js +230 -0
  297. package/dist/ws-client-N7NxzvQp.js.map +1 -0
  298. package/dist/{xai-CazjStOK.js → xai-CvJTeLrI.js} +165 -5
  299. package/dist/xai-CvJTeLrI.js.map +1 -0
  300. package/dist/xdg-zweed0-t.js +117 -0
  301. package/dist/xdg-zweed0-t.js.map +1 -0
  302. package/docs/ACP.md +52 -0
  303. package/docs/ARCHITECTURE.md +103 -6
  304. package/docs/ARTIFACTS.md +8 -4
  305. package/docs/CHAT.md +165 -14
  306. package/docs/EXECUTION_CONTEXT.md +8 -0
  307. package/docs/EXTENSIONS.md +123 -2
  308. package/docs/HEADLESS.md +2 -0
  309. package/docs/IPC.md +775 -64
  310. package/docs/MACHINES.md +456 -0
  311. package/docs/PANELS.md +3 -0
  312. package/docs/README.md +4 -0
  313. package/docs/RESTATE.md +3 -2
  314. package/docs/RUN_IN_BACKGROUND.md +10 -2
  315. package/docs/SERVER.md +1085 -0
  316. package/docs/SKILL.md +6 -1
  317. package/docs/TERMINAL.md +75 -0
  318. package/docs/TUI.md +65 -14
  319. package/package.json +58 -26
  320. package/scripts/eval.ts +4 -0
  321. package/dist/acp-D-tVyUjw.js.map +0 -1
  322. package/dist/agent-D0zZnGbt.js.map +0 -1
  323. package/dist/anthropic-C2aole0G.js.map +0 -1
  324. package/dist/approvals-DKaJZYlm.js.map +0 -1
  325. package/dist/atomic-write-B7zr1ddF.js.map +0 -1
  326. package/dist/auth-BG2rVKSt.js.map +0 -1
  327. package/dist/completion-core-BRo86R_L.js.map +0 -1
  328. package/dist/contexts/daytona.js.map +0 -1
  329. package/dist/contexts/docker.js.map +0 -1
  330. package/dist/contexts/e2b.js.map +0 -1
  331. package/dist/contexts-CRE9pw07.js.map +0 -1
  332. package/dist/eval.js.map +0 -1
  333. package/dist/format-BF745pLL.js.map +0 -1
  334. package/dist/glob-DluQFSw1.js +0 -270
  335. package/dist/glob-DluQFSw1.js.map +0 -1
  336. package/dist/headless.js.map +0 -1
  337. package/dist/history-search-C4bk1Wz_.js.map +0 -1
  338. package/dist/index-BgN1T3lk.d.ts.map +0 -1
  339. package/dist/index-C37_ppWv.d.ts.map +0 -1
  340. package/dist/index-C6NEd5y_.d.ts.map +0 -1
  341. package/dist/ipc-BKVIIOqH.js +0 -331
  342. package/dist/ipc-BKVIIOqH.js.map +0 -1
  343. package/dist/ipc.d.ts.map +0 -1
  344. package/dist/isolation-Kfoof0MM.d.ts.map +0 -1
  345. package/dist/json-rpc-rSWMUh9b.js +0 -192
  346. package/dist/json-rpc-rSWMUh9b.js.map +0 -1
  347. package/dist/logger--C1VQjwJ.js.map +0 -1
  348. package/dist/mcp-CgNd-f3F.js.map +0 -1
  349. package/dist/messages-2jcOA_5R.js.map +0 -1
  350. package/dist/openai-compat-Dy56weK8.js.map +0 -1
  351. package/dist/output-cap-C9zukcCj.js +0 -100
  352. package/dist/output-cap-C9zukcCj.js.map +0 -1
  353. package/dist/panels-B6gRk4bf.js +0 -789
  354. package/dist/panels-B6gRk4bf.js.map +0 -1
  355. package/dist/plugins-gbI7SBA6.js.map +0 -1
  356. package/dist/prompts-Pqc3JdW_.d.ts.map +0 -1
  357. package/dist/run-summary-BU_NgwUT.js +0 -269
  358. package/dist/run-summary-BU_NgwUT.js.map +0 -1
  359. package/dist/sandbox-BH0WQkXn.d.ts.map +0 -1
  360. package/dist/session/sqlite.js.map +0 -1
  361. package/dist/session-BqRP1hS7.js.map +0 -1
  362. package/dist/shell-path-DfdXrGg9.js +0 -1549
  363. package/dist/shell-path-DfdXrGg9.js.map +0 -1
  364. package/dist/skills-BC3dodWp.js.map +0 -1
  365. package/dist/src-CkNQKFKr.js.map +0 -1
  366. package/dist/todo-edits-UOwgxGKu.js +0 -528
  367. package/dist/todo-edits-UOwgxGKu.js.map +0 -1
  368. package/dist/tool-formatters-DoRLnfuD.d.ts +0 -759
  369. package/dist/tool-formatters-DoRLnfuD.d.ts.map +0 -1
  370. package/dist/transcript-anchors-BeudMbXx.d.ts +0 -1762
  371. package/dist/transcript-anchors-BeudMbXx.d.ts.map +0 -1
  372. package/dist/turn-operations-C8bMBDl_.d.ts +0 -1258
  373. package/dist/turn-operations-C8bMBDl_.d.ts.map +0 -1
  374. package/dist/turn-operations-DrbJlpq9.js.map +0 -1
  375. package/dist/types-CWgENVLY.js.map +0 -1
  376. package/dist/xai-CazjStOK.js.map +0 -1
@@ -1,6 +1,194 @@
1
1
  import { r as formatLogLine } from "./logs-view-CWG8aUAG.js";
2
- import { dirname } from "node:path";
3
2
  import { createWriteStream, mkdirSync } from "node:fs";
3
+ import { dirname } from "node:path";
4
+ //#region src/logger-hooks.ts
5
+ /** Agent lifecycle + turn / stream handlers. */
6
+ function installLoggingRunHooks(hooks, unregisters, state) {
7
+ const { gatedRoot, includeLifecycle } = state;
8
+ unregisters.push(hooks.hook("agent:start", (ctx) => {
9
+ state.runLogger = gatedRoot.with({
10
+ runId: ctx.runId,
11
+ ...ctx.parentRunId ? { parentRunId: ctx.parentRunId } : {},
12
+ depth: ctx.depth,
13
+ ...ctx.agentName ? { agentName: ctx.agentName } : {}
14
+ });
15
+ state.turnLogger = state.runLogger;
16
+ if (includeLifecycle) state.runLogger.debug("agent run started");
17
+ }));
18
+ unregisters.push(hooks.hook("agent:done", (stats) => {
19
+ state.runLogger.info("agent run completed", {
20
+ turns: stats.turns,
21
+ totalIn: stats.totalIn,
22
+ totalOut: stats.totalOut,
23
+ ...typeof stats.cost === "number" ? { cost: stats.cost } : {},
24
+ elapsedMs: stats.elapsed,
25
+ ...typeof stats.timeTillFirstTokenMs === "number" ? { ttftMs: stats.timeTillFirstTokenMs } : {}
26
+ });
27
+ }));
28
+ unregisters.push(hooks.hook("agent:abort", () => {
29
+ state.runLogger.warn("agent run aborted");
30
+ }));
31
+ unregisters.push(hooks.hook("turn:before", (ctx) => {
32
+ state.turnLogger = state.runLogger.with({
33
+ turnId: ctx.turnId,
34
+ turn: ctx.turn
35
+ });
36
+ if (includeLifecycle) state.turnLogger.debug("turn started");
37
+ }));
38
+ unregisters.push(hooks.hook("turn:after", (ctx) => {
39
+ state.turnLogger.debug("turn ended", {
40
+ inputTokens: ctx.usage.input,
41
+ outputTokens: ctx.usage.output,
42
+ ...ctx.usage.finishReason ? { finishReason: ctx.usage.finishReason } : {},
43
+ ...ctx.usage.modelId ? { modelId: ctx.usage.modelId } : {},
44
+ ...typeof ctx.usage.timeToFirstTokenMs === "number" ? { ttftMs: ctx.usage.timeToFirstTokenMs } : {}
45
+ });
46
+ }));
47
+ unregisters.push(hooks.hook("stream:error", (ctx) => {
48
+ state.turnLogger.error("stream error", {
49
+ message: ctx.err instanceof Error ? ctx.err.message : String(ctx.err),
50
+ ...ctx.statusCode !== void 0 ? { statusCode: ctx.statusCode } : {},
51
+ ...ctx.requestId !== void 0 ? { requestId: ctx.requestId } : {}
52
+ });
53
+ }));
54
+ }
55
+ /** Tool call + budget handlers. */
56
+ function installLoggingToolHooks(hooks, unregisters, state) {
57
+ const { includeLifecycle } = state;
58
+ unregisters.push(hooks.hook("tool:before", (ctx) => {
59
+ if (!includeLifecycle) return;
60
+ state.turnLogger.debug("tool started", {
61
+ toolName: ctx.name,
62
+ displayName: ctx.displayName,
63
+ callId: ctx.callId
64
+ });
65
+ }));
66
+ unregisters.push(hooks.hook("tool:after", (ctx) => {
67
+ if (!includeLifecycle) return;
68
+ state.turnLogger.debug("tool ended", {
69
+ toolName: ctx.name,
70
+ callId: ctx.callId,
71
+ outputBytes: ctx.outputBytes
72
+ });
73
+ }));
74
+ unregisters.push(hooks.hook("tool:error", (ctx) => {
75
+ state.turnLogger.error("tool error", {
76
+ toolName: ctx.name,
77
+ callId: ctx.callId,
78
+ message: ctx.error.message
79
+ });
80
+ }));
81
+ unregisters.push(hooks.hook("tool:dispatched", (ctx) => {
82
+ const isAnomaly = ctx.outcome === "gate-block" || ctx.outcome === "unknown" || ctx.outcome === "invalid-input";
83
+ if (!isAnomaly && !includeLifecycle) return;
84
+ const lvl = isAnomaly ? "warn" : "debug";
85
+ state.turnLogger[lvl]("tool dispatched", {
86
+ toolName: ctx.name,
87
+ callId: ctx.callId,
88
+ outcome: ctx.outcome,
89
+ ...ctx.reason ? { reason: ctx.reason } : {}
90
+ });
91
+ }));
92
+ unregisters.push(hooks.hook("validation:reject", (ctx) => {
93
+ state.turnLogger.warn("tool input rejected", {
94
+ toolName: ctx.name,
95
+ callId: ctx.callId,
96
+ reason: ctx.reason
97
+ });
98
+ }));
99
+ unregisters.push(hooks.hook("budget:exceeded", (ctx) => {
100
+ state.turnLogger.warn("byte budget exceeded", {
101
+ bytes: ctx.bytes,
102
+ budget: ctx.budget
103
+ });
104
+ }));
105
+ unregisters.push(hooks.hook("tool-budget:exceeded", (ctx) => {
106
+ state.turnLogger.warn("tool budget exceeded", {
107
+ toolName: ctx.tool,
108
+ count: ctx.count,
109
+ max: ctx.max,
110
+ mode: ctx.mode
111
+ });
112
+ }));
113
+ }
114
+ /** MCP + spawn handlers. */
115
+ function installLoggingMcpSpawnHooks(hooks, unregisters, state) {
116
+ const { includeLifecycle } = state;
117
+ unregisters.push(hooks.hook("mcp:bootstrap:end", (ctx) => {
118
+ if (ctx.ok) {
119
+ if (includeLifecycle) state.runLogger.debug("mcp bootstrap ok", {
120
+ server: ctx.name,
121
+ transport: ctx.transport,
122
+ durationMs: ctx.durationMs,
123
+ toolCount: ctx.toolCount,
124
+ ...ctx.lazy ? { lazy: true } : {},
125
+ ...ctx.cached ? { cached: true } : {}
126
+ });
127
+ } else state.runLogger.warn("mcp bootstrap failed", {
128
+ server: ctx.name,
129
+ transport: ctx.transport,
130
+ durationMs: ctx.durationMs,
131
+ message: ctx.error.message
132
+ });
133
+ }));
134
+ unregisters.push(hooks.hook("mcp:error", (ctx) => {
135
+ state.runLogger.error("mcp error", {
136
+ server: ctx.name,
137
+ message: ctx.error.message
138
+ });
139
+ }));
140
+ unregisters.push(hooks.hook("mcp:warn", (ctx) => {
141
+ state.runLogger.warn("mcp warn", {
142
+ server: ctx.name,
143
+ message: ctx.message
144
+ });
145
+ }));
146
+ unregisters.push(hooks.hook("mcp:auth:required", (ctx) => {
147
+ state.runLogger.warn("mcp auth required", {
148
+ server: ctx.name,
149
+ transport: ctx.transport,
150
+ reason: ctx.reason
151
+ });
152
+ }));
153
+ unregisters.push(hooks.hook("mcp:tool:error", (ctx) => {
154
+ state.turnLogger.error("mcp tool error", {
155
+ server: ctx.server,
156
+ tool: ctx.displayName,
157
+ callId: ctx.callId,
158
+ message: ctx.error.message
159
+ });
160
+ }));
161
+ const onSpawnBefore = (ctx) => {
162
+ if (!includeLifecycle) return;
163
+ state.runLogger.debug("spawn started", {
164
+ childId: ctx.id,
165
+ depth: ctx.depth,
166
+ ...ctx.parentChildId ? { parentChildId: ctx.parentChildId } : {}
167
+ });
168
+ };
169
+ const onSpawnComplete = (ctx) => {
170
+ state.runLogger.info("spawn completed", {
171
+ childId: ctx.id,
172
+ ...ctx.depth ? { depth: ctx.depth } : {},
173
+ ...ctx.parentChildId ? { parentChildId: ctx.parentChildId } : {},
174
+ status: ctx.status ?? "completed",
175
+ turns: ctx.stats.turns,
176
+ totalIn: ctx.stats.totalIn,
177
+ totalOut: ctx.stats.totalOut,
178
+ ...typeof ctx.stats.cost === "number" ? { cost: ctx.stats.cost } : {}
179
+ });
180
+ };
181
+ const onSpawnError = (ctx) => {
182
+ state.runLogger.error("spawn error", {
183
+ childId: ctx.id,
184
+ ...ctx.depth ? { depth: ctx.depth } : {},
185
+ ...ctx.parentChildId ? { parentChildId: ctx.parentChildId } : {},
186
+ message: ctx.error.message
187
+ });
188
+ };
189
+ unregisters.push(hooks.hook("spawn:before", onSpawnBefore), hooks.hook("spawn:complete", onSpawnComplete), hooks.hook("spawn:error", onSpawnError), hooks.hook("child:spawn:before", onSpawnBefore), hooks.hook("child:spawn:complete", onSpawnComplete), hooks.hook("child:spawn:error", onSpawnError));
190
+ }
191
+ //#endregion
4
192
  //#region src/logger.ts
5
193
  /**
6
194
  * Build a Logger from a sink. Stateless and cheap; create one per agent
@@ -206,177 +394,15 @@ function createLoggingHooks(options) {
206
394
  return { install(hooks) {
207
395
  const unregisters = [];
208
396
  const gatedRoot = gateLevel(root);
209
- let runLogger = gatedRoot;
210
- let turnLogger = gatedRoot;
211
- unregisters.push(hooks.hook("agent:start", (ctx) => {
212
- runLogger = gatedRoot.with({
213
- runId: ctx.runId,
214
- ...ctx.parentRunId ? { parentRunId: ctx.parentRunId } : {},
215
- depth: ctx.depth,
216
- ...ctx.agentName ? { agentName: ctx.agentName } : {}
217
- });
218
- turnLogger = runLogger;
219
- if (includeLifecycle) runLogger.debug("agent run started");
220
- }));
221
- unregisters.push(hooks.hook("agent:done", (stats) => {
222
- runLogger.info("agent run completed", {
223
- turns: stats.turns,
224
- totalIn: stats.totalIn,
225
- totalOut: stats.totalOut,
226
- ...typeof stats.cost === "number" ? { cost: stats.cost } : {},
227
- elapsedMs: stats.elapsed,
228
- ...typeof stats.timeTillFirstTokenMs === "number" ? { ttftMs: stats.timeTillFirstTokenMs } : {}
229
- });
230
- }));
231
- unregisters.push(hooks.hook("agent:abort", () => {
232
- runLogger.warn("agent run aborted");
233
- }));
234
- unregisters.push(hooks.hook("turn:before", (ctx) => {
235
- turnLogger = runLogger.with({
236
- turnId: ctx.turnId,
237
- turn: ctx.turn
238
- });
239
- if (includeLifecycle) turnLogger.debug("turn started");
240
- }));
241
- unregisters.push(hooks.hook("turn:after", (ctx) => {
242
- turnLogger.debug("turn ended", {
243
- inputTokens: ctx.usage.input,
244
- outputTokens: ctx.usage.output,
245
- ...ctx.usage.finishReason ? { finishReason: ctx.usage.finishReason } : {},
246
- ...ctx.usage.modelId ? { modelId: ctx.usage.modelId } : {},
247
- ...typeof ctx.usage.timeToFirstTokenMs === "number" ? { ttftMs: ctx.usage.timeToFirstTokenMs } : {}
248
- });
249
- }));
250
- unregisters.push(hooks.hook("stream:error", (ctx) => {
251
- turnLogger.error("stream error", {
252
- message: ctx.err instanceof Error ? ctx.err.message : String(ctx.err),
253
- ...ctx.statusCode !== void 0 ? { statusCode: ctx.statusCode } : {},
254
- ...ctx.requestId !== void 0 ? { requestId: ctx.requestId } : {}
255
- });
256
- }));
257
- unregisters.push(hooks.hook("tool:before", (ctx) => {
258
- if (!includeLifecycle) return;
259
- turnLogger.debug("tool started", {
260
- toolName: ctx.name,
261
- displayName: ctx.displayName,
262
- callId: ctx.callId
263
- });
264
- }));
265
- unregisters.push(hooks.hook("tool:after", (ctx) => {
266
- if (!includeLifecycle) return;
267
- turnLogger.debug("tool ended", {
268
- toolName: ctx.name,
269
- callId: ctx.callId,
270
- outputBytes: ctx.outputBytes
271
- });
272
- }));
273
- unregisters.push(hooks.hook("tool:error", (ctx) => {
274
- turnLogger.error("tool error", {
275
- toolName: ctx.name,
276
- callId: ctx.callId,
277
- message: ctx.error.message
278
- });
279
- }));
280
- unregisters.push(hooks.hook("tool:dispatched", (ctx) => {
281
- const isAnomaly = ctx.outcome === "gate-block" || ctx.outcome === "unknown" || ctx.outcome === "invalid-input";
282
- if (!isAnomaly && !includeLifecycle) return;
283
- turnLogger[isAnomaly ? "warn" : "debug"]("tool dispatched", {
284
- toolName: ctx.name,
285
- callId: ctx.callId,
286
- outcome: ctx.outcome,
287
- ...ctx.reason ? { reason: ctx.reason } : {}
288
- });
289
- }));
290
- unregisters.push(hooks.hook("validation:reject", (ctx) => {
291
- turnLogger.warn("tool input rejected", {
292
- toolName: ctx.name,
293
- callId: ctx.callId,
294
- reason: ctx.reason
295
- });
296
- }));
297
- unregisters.push(hooks.hook("budget:exceeded", (ctx) => {
298
- turnLogger.warn("byte budget exceeded", {
299
- bytes: ctx.bytes,
300
- budget: ctx.budget
301
- });
302
- }));
303
- unregisters.push(hooks.hook("tool-budget:exceeded", (ctx) => {
304
- turnLogger.warn("tool budget exceeded", {
305
- toolName: ctx.tool,
306
- count: ctx.count,
307
- max: ctx.max,
308
- mode: ctx.mode
309
- });
310
- }));
311
- unregisters.push(hooks.hook("mcp:bootstrap:end", (ctx) => {
312
- if (ctx.ok) {
313
- if (includeLifecycle) runLogger.debug("mcp bootstrap ok", {
314
- server: ctx.name,
315
- transport: ctx.transport,
316
- durationMs: ctx.durationMs,
317
- toolCount: ctx.toolCount,
318
- ...ctx.lazy ? { lazy: true } : {},
319
- ...ctx.cached ? { cached: true } : {}
320
- });
321
- } else runLogger.warn("mcp bootstrap failed", {
322
- server: ctx.name,
323
- transport: ctx.transport,
324
- durationMs: ctx.durationMs,
325
- message: ctx.error.message
326
- });
327
- }));
328
- unregisters.push(hooks.hook("mcp:error", (ctx) => {
329
- runLogger.error("mcp error", {
330
- server: ctx.name,
331
- message: ctx.error.message
332
- });
333
- }));
334
- unregisters.push(hooks.hook("mcp:warn", (ctx) => {
335
- runLogger.warn("mcp warn", {
336
- server: ctx.name,
337
- message: ctx.message
338
- });
339
- }));
340
- unregisters.push(hooks.hook("mcp:auth:required", (ctx) => {
341
- runLogger.warn("mcp auth required", {
342
- server: ctx.name,
343
- transport: ctx.transport,
344
- reason: ctx.reason
345
- });
346
- }));
347
- unregisters.push(hooks.hook("mcp:tool:error", (ctx) => {
348
- turnLogger.error("mcp tool error", {
349
- server: ctx.server,
350
- tool: ctx.displayName,
351
- callId: ctx.callId,
352
- message: ctx.error.message
353
- });
354
- }));
355
- unregisters.push(hooks.hook("spawn:before", (ctx) => {
356
- if (!includeLifecycle) return;
357
- runLogger.debug("spawn started", {
358
- childId: ctx.id,
359
- depth: ctx.depth
360
- });
361
- }));
362
- unregisters.push(hooks.hook("spawn:complete", (ctx) => {
363
- runLogger.info("spawn completed", {
364
- childId: ctx.id,
365
- ...ctx.depth ? { depth: ctx.depth } : {},
366
- status: ctx.status ?? "completed",
367
- turns: ctx.stats.turns,
368
- totalIn: ctx.stats.totalIn,
369
- totalOut: ctx.stats.totalOut,
370
- ...typeof ctx.stats.cost === "number" ? { cost: ctx.stats.cost } : {}
371
- });
372
- }));
373
- unregisters.push(hooks.hook("spawn:error", (ctx) => {
374
- runLogger.error("spawn error", {
375
- childId: ctx.id,
376
- ...ctx.depth ? { depth: ctx.depth } : {},
377
- message: ctx.error.message
378
- });
379
- }));
397
+ const state = {
398
+ gatedRoot,
399
+ includeLifecycle,
400
+ runLogger: gatedRoot,
401
+ turnLogger: gatedRoot
402
+ };
403
+ installLoggingRunHooks(hooks, unregisters, state);
404
+ installLoggingToolHooks(hooks, unregisters, state);
405
+ installLoggingMcpSpawnHooks(hooks, unregisters, state);
380
406
  let disposed = false;
381
407
  return function uninstall() {
382
408
  if (disposed) return;
@@ -390,4 +416,4 @@ function createLoggingHooks(options) {
390
416
  //#endregion
391
417
  export { createRingBufferSink as a, logFileTimestamp as c, createLoggingHooks as i, createFileSink as n, fanoutSink as o, createLogger as r, jsonSink as s, consoleSink as t };
392
418
 
393
- //# sourceMappingURL=logger--C1VQjwJ.js.map
419
+ //# sourceMappingURL=logger-Gtqlayx8.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger-Gtqlayx8.js","names":[],"sources":["../src/logger-hooks.ts","../src/logger.ts"],"sourcesContent":["/**\n * Hook-group installers behind {@link createLoggingHooks} (`./logger`).\n *\n * Each installer registers one contiguous slice of the original\n * registration sequence and pushes its unregister fns onto the shared\n * `unregisters` array, so calling them in order reproduces the exact\n * hook registration order of the single-function original.\n */\n\nimport type { Hookable } from 'hookable'\nimport type { AgentHooks } from './agent'\nimport type { Logger, LogLevel } from './logger'\nimport type { ChildRunStats } from './types'\n\n/**\n * Per-install attribution state. `runLogger` / `turnLogger` are refreshed on\n * `agent:start` / `turn:before`, so handlers read them through this object to\n * stay live.\n */\nexport interface LoggingInstallState {\n gatedRoot: Logger\n includeLifecycle: boolean\n runLogger: Logger\n turnLogger: Logger\n}\n\n/** Agent lifecycle + turn / stream handlers. */\nexport function installLoggingRunHooks(\n hooks: Hookable<AgentHooks>,\n unregisters: Array<() => void>,\n state: LoggingInstallState,\n): void {\n const { gatedRoot, includeLifecycle } = state\n\n // ---- Agent lifecycle --------------------------------------------\n\n unregisters.push(hooks.hook('agent:start', (ctx) => {\n state.runLogger = gatedRoot.with({\n runId: ctx.runId,\n ...(ctx.parentRunId ? { parentRunId: ctx.parentRunId } : {}),\n depth: ctx.depth,\n ...(ctx.agentName ? { agentName: ctx.agentName } : {}),\n })\n state.turnLogger = state.runLogger\n if (includeLifecycle)\n state.runLogger.debug('agent run started')\n }))\n\n unregisters.push(hooks.hook('agent:done', (stats) => {\n state.runLogger.info('agent run completed', {\n turns: stats.turns,\n totalIn: stats.totalIn,\n totalOut: stats.totalOut,\n ...(typeof stats.cost === 'number' ? { cost: stats.cost } : {}),\n elapsedMs: stats.elapsed,\n ...(typeof stats.timeTillFirstTokenMs === 'number' ? { ttftMs: stats.timeTillFirstTokenMs } : {}),\n })\n }))\n\n unregisters.push(hooks.hook('agent:abort', () => {\n state.runLogger.warn('agent run aborted')\n }))\n\n // ---- Turn / stream ---------------------------------------------\n\n unregisters.push(hooks.hook('turn:before', (ctx) => {\n state.turnLogger = state.runLogger.with({ turnId: ctx.turnId, turn: ctx.turn })\n if (includeLifecycle)\n state.turnLogger.debug('turn started')\n }))\n\n unregisters.push(hooks.hook('turn:after', (ctx) => {\n state.turnLogger.debug('turn ended', {\n inputTokens: ctx.usage.input,\n outputTokens: ctx.usage.output,\n ...(ctx.usage.finishReason ? { finishReason: ctx.usage.finishReason } : {}),\n ...(ctx.usage.modelId ? { modelId: ctx.usage.modelId } : {}),\n ...(typeof ctx.usage.timeToFirstTokenMs === 'number' ? { ttftMs: ctx.usage.timeToFirstTokenMs } : {}),\n })\n }))\n\n unregisters.push(hooks.hook('stream:error', (ctx) => {\n state.turnLogger.error('stream error', {\n message: ctx.err instanceof Error ? ctx.err.message : String(ctx.err),\n ...(ctx.statusCode !== undefined ? { statusCode: ctx.statusCode } : {}),\n ...(ctx.requestId !== undefined ? { requestId: ctx.requestId } : {}),\n })\n }))\n}\n\n/** Tool call + budget handlers. */\nexport function installLoggingToolHooks(\n hooks: Hookable<AgentHooks>,\n unregisters: Array<() => void>,\n state: LoggingInstallState,\n): void {\n const { includeLifecycle } = state\n\n // ---- Tool calls -------------------------------------------------\n\n unregisters.push(hooks.hook('tool:before', (ctx) => {\n if (!includeLifecycle)\n return\n state.turnLogger.debug('tool started', {\n toolName: ctx.name,\n displayName: ctx.displayName,\n callId: ctx.callId,\n })\n }))\n\n unregisters.push(hooks.hook('tool:after', (ctx) => {\n if (!includeLifecycle)\n return\n state.turnLogger.debug('tool ended', {\n toolName: ctx.name,\n callId: ctx.callId,\n outputBytes: ctx.outputBytes,\n })\n }))\n\n unregisters.push(hooks.hook('tool:error', (ctx) => {\n state.turnLogger.error('tool error', {\n toolName: ctx.name,\n callId: ctx.callId,\n message: ctx.error.message,\n })\n }))\n\n unregisters.push(hooks.hook('tool:dispatched', (ctx) => {\n // Successful + gate-substitute paths are routine — only log at\n // debug level. The three \"something refused / went wrong\" paths\n // (gate-block, unknown tool, invalid input) land at warn so they\n // surface in default-config dashboards without forcing debug.\n const isAnomaly = ctx.outcome === 'gate-block'\n || ctx.outcome === 'unknown'\n || ctx.outcome === 'invalid-input'\n if (!isAnomaly && !includeLifecycle)\n return\n const lvl: LogLevel = isAnomaly ? 'warn' : 'debug'\n state.turnLogger[lvl]('tool dispatched', {\n toolName: ctx.name,\n callId: ctx.callId,\n outcome: ctx.outcome,\n ...(ctx.reason ? { reason: ctx.reason } : {}),\n })\n }))\n\n unregisters.push(hooks.hook('validation:reject', (ctx) => {\n state.turnLogger.warn('tool input rejected', {\n toolName: ctx.name,\n callId: ctx.callId,\n reason: ctx.reason,\n })\n }))\n\n // ---- Budgets ----------------------------------------------------\n\n unregisters.push(hooks.hook('budget:exceeded', (ctx) => {\n state.turnLogger.warn('byte budget exceeded', {\n bytes: ctx.bytes,\n budget: ctx.budget,\n })\n }))\n\n unregisters.push(hooks.hook('tool-budget:exceeded', (ctx) => {\n state.turnLogger.warn('tool budget exceeded', {\n toolName: ctx.tool,\n count: ctx.count,\n max: ctx.max,\n mode: ctx.mode,\n })\n }))\n}\n\n/** MCP + spawn handlers. */\nexport function installLoggingMcpSpawnHooks(\n hooks: Hookable<AgentHooks>,\n unregisters: Array<() => void>,\n state: LoggingInstallState,\n): void {\n const { includeLifecycle } = state\n\n // ---- MCP --------------------------------------------------------\n\n unregisters.push(hooks.hook('mcp:bootstrap:end', (ctx) => {\n if (ctx.ok) {\n if (includeLifecycle) {\n state.runLogger.debug('mcp bootstrap ok', {\n server: ctx.name,\n transport: ctx.transport,\n durationMs: ctx.durationMs,\n toolCount: ctx.toolCount,\n ...(ctx.lazy ? { lazy: true } : {}),\n ...(ctx.cached ? { cached: true } : {}),\n })\n }\n }\n else {\n state.runLogger.warn('mcp bootstrap failed', {\n server: ctx.name,\n transport: ctx.transport,\n durationMs: ctx.durationMs,\n message: ctx.error.message,\n })\n }\n }))\n\n unregisters.push(hooks.hook('mcp:error', (ctx) => {\n state.runLogger.error('mcp error', {\n server: ctx.name,\n message: ctx.error.message,\n })\n }))\n\n unregisters.push(hooks.hook('mcp:warn', (ctx) => {\n state.runLogger.warn('mcp warn', {\n server: ctx.name,\n message: ctx.message,\n })\n }))\n\n unregisters.push(hooks.hook('mcp:auth:required', (ctx) => {\n state.runLogger.warn('mcp auth required', {\n server: ctx.name,\n transport: ctx.transport,\n reason: ctx.reason,\n })\n }))\n\n unregisters.push(hooks.hook('mcp:tool:error', (ctx) => {\n state.turnLogger.error('mcp tool error', {\n server: ctx.server,\n tool: ctx.displayName,\n callId: ctx.callId,\n message: ctx.error.message,\n })\n }))\n\n // ---- Spawn ------------------------------------------------------\n // Nested spawns (run BY a subagent) log the same records plus the spawner\n // (`parentChildId`), at the spawned agent's own depth.\n\n const onSpawnBefore = (ctx: { id: string, depth?: number, parentChildId?: string }): void => {\n if (!includeLifecycle)\n return\n state.runLogger.debug('spawn started', {\n childId: ctx.id,\n depth: ctx.depth,\n ...(ctx.parentChildId ? { parentChildId: ctx.parentChildId } : {}),\n })\n }\n\n const onSpawnComplete = (ctx: ChildRunStats & { parentChildId?: string }): void => {\n state.runLogger.info('spawn completed', {\n childId: ctx.id,\n ...(ctx.depth ? { depth: ctx.depth } : {}),\n ...(ctx.parentChildId ? { parentChildId: ctx.parentChildId } : {}),\n status: ctx.status ?? 'completed',\n turns: ctx.stats.turns,\n totalIn: ctx.stats.totalIn,\n totalOut: ctx.stats.totalOut,\n ...(typeof ctx.stats.cost === 'number' ? { cost: ctx.stats.cost } : {}),\n })\n }\n\n const onSpawnError = (ctx: { id: string, depth?: number, parentChildId?: string, error: Error }): void => {\n state.runLogger.error('spawn error', {\n childId: ctx.id,\n ...(ctx.depth ? { depth: ctx.depth } : {}),\n ...(ctx.parentChildId ? { parentChildId: ctx.parentChildId } : {}),\n message: ctx.error.message,\n })\n }\n\n unregisters.push(\n hooks.hook('spawn:before', onSpawnBefore),\n hooks.hook('spawn:complete', onSpawnComplete),\n hooks.hook('spawn:error', onSpawnError),\n hooks.hook('child:spawn:before', onSpawnBefore),\n hooks.hook('child:spawn:complete', onSpawnComplete),\n hooks.hook('child:spawn:error', onSpawnError),\n )\n}\n","/**\n * Structured logging primitive with auto-correlation.\n *\n * Every consumer of the harness used to roll its own logger; the TUI has\n * one, downstream apps have theirs, observability backends each want a\n * slightly different shape. This module ships the smallest reasonable\n * shared surface:\n *\n * - {@link Logger} — minimal level-tagged interface (`debug` / `info` /\n * `warn` / `error`) plus a `with(...)` method that returns a child\n * logger carrying baseline attributes (`runId`, `turnId`, `callId`,\n * `childId`, `depth`, anything you want).\n * - {@link createLogger} — builds a Logger from a {@link LogSink}.\n * - {@link consoleSink} / {@link jsonSink} — built-in sinks that cover\n * the common cases (human-readable to a terminal vs. one JSON object\n * per line to a log aggregator).\n * - {@link createLoggingHooks} — installs Logger-attached hook handlers\n * on an agent so every lifecycle event lands on the sink with the\n * right correlation ids already stamped in.\n *\n * Hosts that already own a logger (pino, winston, structlog binding,\n * platform-native) plug it in via a custom {@link LogSink} — the helper\n * itself does no I/O.\n */\n\nimport type { Hookable } from 'hookable'\nimport type { WriteStream } from 'node:fs'\nimport type { AgentHooks } from './agent'\nimport type { LoggingInstallState } from './logger-hooks'\nimport { createWriteStream, mkdirSync } from 'node:fs'\nimport { dirname } from 'node:path'\n\n// `formatLogLine` lives in the node-free `chat/logs-view` so the Electron\n// renderer's Logs tab can share it without pulling this module's `node:fs`\n// sinks (and, through the root barrel, the whole agent) into a browser bundle.\nimport { formatLogLine } from './chat/logs-view'\nimport { installLoggingMcpSpawnHooks, installLoggingRunHooks, installLoggingToolHooks } from './logger-hooks'\n\n// ---------------------------------------------------------------------------\n// Core types\n// ---------------------------------------------------------------------------\n\nexport type LogLevel = 'debug' | 'info' | 'warn' | 'error'\n\nexport interface LogRecord {\n level: LogLevel\n /** Unix ms — set by `Logger` at emit time. */\n timestamp: number\n /** Free-form message. Sinks render this as the human-facing line. */\n message: string\n /** Structured fields. Correlation ids land here automatically. */\n attrs: Record<string, unknown>\n}\n\nexport interface LogSink {\n emit: (record: LogRecord) => void\n}\n\nexport interface Logger {\n debug: (message: string, attrs?: Record<string, unknown>) => void\n info: (message: string, attrs?: Record<string, unknown>) => void\n warn: (message: string, attrs?: Record<string, unknown>) => void\n error: (message: string, attrs?: Record<string, unknown>) => void\n /**\n * Returns a child logger that prepends the given attributes onto every\n * subsequent emit. Equivalent to `pino.child` / `winston.child`. The\n * parent and child share the same sink — children are zero-cost.\n */\n with: (extra: Record<string, unknown>) => Logger\n /**\n * Inspectable baseline attributes — handy for tests and for hook\n * handlers that want to clone-with-extra without recursing.\n */\n readonly baseAttributes: Readonly<Record<string, unknown>>\n}\n\n// ---------------------------------------------------------------------------\n// createLogger\n// ---------------------------------------------------------------------------\n\n/**\n * Build a Logger from a sink. Stateless and cheap; create one per agent\n * (or per app) and use `.with()` to attach correlation ids per-call.\n */\nexport function createLogger(\n sink: LogSink,\n baseAttributes: Readonly<Record<string, unknown>> = {},\n): Logger {\n function emit(level: LogLevel, message: string, attrs?: Record<string, unknown>): void {\n try {\n sink.emit({\n level,\n timestamp: Date.now(),\n message,\n attrs: attrs ? { ...baseAttributes, ...attrs } : { ...baseAttributes },\n })\n }\n catch {\n // Sinks should never crash the run.\n }\n }\n\n return {\n debug: (m, a) => emit('debug', m, a),\n info: (m, a) => emit('info', m, a),\n warn: (m, a) => emit('warn', m, a),\n error: (m, a) => emit('error', m, a),\n with: extra => createLogger(sink, { ...baseAttributes, ...extra }),\n baseAttributes,\n }\n}\n\n// ---------------------------------------------------------------------------\n// Built-in sinks\n// ---------------------------------------------------------------------------\n\nexport interface ConsoleSinkOptions {\n /**\n * Minimum level to emit. Defaults to `'info'` — `debug` is dropped so\n * the harness's lifecycle logging is not noisy by default. Set to\n * `'debug'` to see every event.\n */\n minLevel?: LogLevel\n /** Custom output stream. Defaults to `process.stderr` so logs don't pollute stdout. */\n stream?: { write: (chunk: string) => void }\n}\n\nconst LEVEL_ORDER: Record<LogLevel, number> = {\n debug: 0,\n info: 1,\n warn: 2,\n error: 3,\n}\n\nexport { formatLogLine }\n\n/**\n * Human-readable terminal sink. Renders each record as\n * `<ISO timestamp> <LEVEL> <message> <attrs as kv pairs>`.\n *\n * Honors `process.stderr` by default so log lines don't interleave with\n * the agent's stdout-bound output (chat responses, JSON results).\n */\nexport function consoleSink(options: ConsoleSinkOptions = {}): LogSink {\n const min = LEVEL_ORDER[options.minLevel ?? 'info']\n const stream = options.stream ?? process.stderr\n return {\n emit(record) {\n if (LEVEL_ORDER[record.level] < min)\n return\n stream.write(`${formatLogLine(record)}\\n`)\n },\n }\n}\n\n/**\n * One-JSON-object-per-line sink. Suitable for piping into log aggregators\n * (Datadog Agent, Fluent Bit, Loki, Vector) that expect JSONL.\n */\nexport function jsonSink(options: ConsoleSinkOptions = {}): LogSink {\n const min = LEVEL_ORDER[options.minLevel ?? 'info']\n const stream = options.stream ?? process.stderr\n return {\n emit(record) {\n if (LEVEL_ORDER[record.level] < min)\n return\n try {\n stream.write(`${JSON.stringify(record)}\\n`)\n }\n catch {\n // Non-serializable attr (cycle, BigInt, etc.). Skip rather than throw.\n }\n },\n }\n}\n\n/**\n * Fan a single record out to several sinks. Each sink's `emit` is guarded\n * so one throwing sink can't starve the others (mirrors `createLogger`'s\n * \"a sink must never crash the run\" contract).\n */\nexport function fanoutSink(sinks: readonly LogSink[]): LogSink {\n return {\n emit(record) {\n for (const sink of sinks) {\n try {\n sink.emit(record)\n }\n catch {\n // A misbehaving sink must not block its siblings.\n }\n }\n },\n }\n}\n\n/** Live handle over a {@link createRingBufferSink} — the read side the logs viewer consumes. */\nexport interface RingBufferSink extends LogSink {\n /** The buffered records, oldest first — the live array, so treat it as read-only. Bounded by `capacity`. */\n getRecords: () => readonly LogRecord[]\n /**\n * Subscribe to appends. The callback fires after each retained record is\n * pushed. Returns an unsubscribe fn. Used by the TUI logs viewer to\n * re-render on new lines without polling.\n */\n subscribe: (listener: () => void) => () => void\n}\n\nexport interface RingBufferSinkOptions {\n /** Max records retained; oldest are evicted past this. Default 2000. */\n capacity?: number\n /** Minimum level to retain. Default `'debug'` (retain everything). */\n minLevel?: LogLevel\n}\n\n/**\n * In-memory bounded log buffer backing the in-TUI logs viewer. Always\n * capturing and never touches I/O, so it's safe on the logging hot path.\n * Retains the most recent `capacity` records, dropping the oldest on\n * overflow. Kept simple (a plain array trimmed with `splice`) — TUI log\n * volume is low, so a true head-indexed ring isn't worth the complexity.\n */\nexport function createRingBufferSink(options: RingBufferSinkOptions = {}): RingBufferSink {\n const capacity = Math.max(1, options.capacity ?? 2000)\n const min = LEVEL_ORDER[options.minLevel ?? 'debug']\n const records: LogRecord[] = []\n const listeners = new Set<() => void>()\n return {\n emit(record) {\n if (LEVEL_ORDER[record.level] < min)\n return\n records.push(record)\n if (records.length > capacity)\n records.splice(0, records.length - capacity)\n for (const listener of listeners) {\n try {\n listener()\n }\n catch {\n // A viewer re-render callback must not break log capture.\n }\n }\n },\n getRecords: () => records,\n subscribe(listener) {\n listeners.add(listener)\n return () => listeners.delete(listener)\n },\n }\n}\n\n/** A file sink plus a `close()` for best-effort flush on teardown. */\nexport interface FileSink extends LogSink {\n /** Flush + close the underlying stream. Idempotent. */\n close: () => void\n}\n\nexport interface FileSinkOptions {\n /** Absolute path to the log file. Parent dirs are created lazily. */\n path: string\n /** Minimum level to write. Default `'debug'`. */\n minLevel?: LogLevel\n /**\n * Live gate. When it returns false the sink is fully inert — no dir, no\n * file, no I/O — so an opt-in setting can flip logging on mid-session\n * without a relaunch. Default: always enabled.\n */\n enabled?: () => boolean\n}\n\n/**\n * Append-mode file sink. The parent directory and the write stream are\n * opened lazily on the first record that passes the `enabled()` gate +\n * `minLevel`, so a disabled sink never creates the file. Writes are\n * buffered by the stream (no sync I/O per log). A single open failure\n * disables the sink rather than throwing on the logging path.\n */\nexport function createFileSink(options: FileSinkOptions): FileSink {\n const min = LEVEL_ORDER[options.minLevel ?? 'debug']\n const enabled = options.enabled ?? (() => true)\n let stream: WriteStream | null = null\n let failed = false\n const open = (): WriteStream | null => {\n if (stream || failed)\n return stream\n try {\n mkdirSync(dirname(options.path), { recursive: true })\n stream = createWriteStream(options.path, { flags: 'a' })\n return stream\n }\n catch {\n // Unwritable path (permissions, read-only FS) — disable rather than\n // retry the mkdir/open on every subsequent log line.\n failed = true\n return null\n }\n }\n return {\n emit(record) {\n if (failed || LEVEL_ORDER[record.level] < min || !enabled())\n return\n const s = open()\n if (!s)\n return\n try {\n s.write(`${formatLogLine(record)}\\n`)\n }\n catch {\n // Disk full / stream closed — stop trying rather than throw per-line.\n failed = true\n }\n },\n close() {\n if (stream) {\n try {\n stream.end()\n }\n catch {\n // Already-destroyed stream — nothing to flush.\n }\n stream = null\n }\n },\n }\n}\n\n/**\n * Filesystem-safe timestamp for a per-session log filename. ISO 8601 with\n * `:` (illegal on Windows / awkward in shells) swapped for `-` and the\n * fractional millis dropped, e.g. `2026-07-01T10-34-14`.\n */\nexport function logFileTimestamp(date: Date = new Date()): string {\n return date.toISOString().replace(/\\.\\d+Z$/, '').replace(/:/g, '-')\n}\n\n// ---------------------------------------------------------------------------\n// createLoggingHooks\n// ---------------------------------------------------------------------------\n\nexport interface LoggingHooksOptions {\n logger: Logger\n /**\n * Minimum interesting level for harness-emitted lines. Default `'info'`.\n * Set to `'debug'` to see every tool dispatch / stream event. Set to\n * `'warn'` to mute the chatty ones and only see failures + budgets.\n */\n level?: LogLevel\n /**\n * When true (default), lifecycle events (`agent:start`, `turn:before`,\n * `tool:before`, `mcp:bootstrap:start`) emit at `debug` level so they\n * stay quiet by default. Set false to mute them entirely regardless of\n * the configured minimum level — useful when piping into a tracer\n * that already captures lifecycle.\n */\n includeLifecycle?: boolean\n}\n\nexport interface LoggingHookSet {\n install: (hooks: Hookable<AgentHooks>) => () => void\n}\n\n/**\n * Install a bundle of hook handlers that emit a structured line per\n * relevant lifecycle event, automatically attaching correlation ids\n * (`runId`, `turnId`, `callId`, `childId`, `depth`, `agentName`).\n *\n * @example\n * ```ts\n * const logger = createLogger(consoleSink({ minLevel: 'debug' }), { service: 'tui' })\n * const lh = createLoggingHooks({ logger })\n * const uninstall = lh.install(agent.hooks)\n * try { await agent.run({ prompt }) }\n * finally { uninstall() }\n * ```\n */\nexport function createLoggingHooks(options: LoggingHooksOptions): LoggingHookSet {\n const root = options.logger\n const includeLifecycle = options.includeLifecycle ?? true\n const minLevel = LEVEL_ORDER[options.level ?? 'info']\n\n /**\n * Wrap a Logger so emissions below `minLevel` are dropped before they\n * hit the sink. Lets us gate harness chatter without forcing every\n * `LogSink` to re-implement level filtering. Preserves `.with()`\n * composition (children inherit the filter).\n */\n function gateLevel(logger: Logger): Logger {\n const skip = (level: LogLevel): boolean => LEVEL_ORDER[level] < minLevel\n const wrap = (l: Logger): Logger => ({\n debug: (m, a) => {\n if (!skip('debug'))\n l.debug(m, a)\n },\n info: (m, a) => {\n if (!skip('info'))\n l.info(m, a)\n },\n warn: (m, a) => {\n if (!skip('warn'))\n l.warn(m, a)\n },\n error: (m, a) => {\n if (!skip('error'))\n l.error(m, a)\n },\n with: extra => wrap(l.with(extra)),\n baseAttributes: l.baseAttributes,\n })\n return wrap(logger)\n }\n\n return {\n install(hooks: Hookable<AgentHooks>): () => void {\n const unregisters: Array<() => void> = []\n // Per-install loggers, refreshed on `agent:start` / `turn:before`.\n // Scoped INSIDE install() so concurrent installs across different\n // agents don't share state — each call to `install()` gets its own\n // attribution state.\n const gatedRoot = gateLevel(root)\n const state: LoggingInstallState = {\n gatedRoot,\n includeLifecycle,\n runLogger: gatedRoot,\n turnLogger: gatedRoot,\n }\n\n installLoggingRunHooks(hooks, unregisters, state)\n installLoggingToolHooks(hooks, unregisters, state)\n installLoggingMcpSpawnHooks(hooks, unregisters, state)\n\n // -----------------------------------------------------------------\n // Disposal\n // -----------------------------------------------------------------\n\n let disposed = false\n return function uninstall() {\n if (disposed)\n return\n disposed = true\n for (const un of unregisters) {\n try {\n un()\n }\n catch { /* ignore */ }\n }\n }\n },\n }\n}\n"],"mappings":";;;;;AA2BA,SAAgB,uBACd,OACA,aACA,OACM;CACN,MAAM,EAAE,WAAW,qBAAqB;CAIxC,YAAY,KAAK,MAAM,KAAK,gBAAgB,QAAQ;EAClD,MA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AO,KAAK,MAAM;CACpB;CAEA,OAAO,EACL,QAAQ,OAAyC;EAC/C,MAAM,cAAiC,CAAC;EAKxC,MAAM,YAAY,UAAU,IAAI;EAChC,MAAM,QAA6B;GACjC;GACA;GACA,WAAW;GACX,YAAY;EACd;EAEA,uBAAuB,OAAO,aAAa,KAAK;EAChD,wBAAwB,OAAO,aAAa,KAAK;EACjD,4BAA4B,OAAO,aAAa,KAAK;EAMrD,IAAI,WAAW;EACf,OAAO,SAAS,YAAY;GAC1B,IAAI,UACF;GACF,WAAW;GACX,KAAK,MAAM,MAAM,aACf,IAAI;IACF,GAAG;GACL,QACM,CAAe;EAEzB;CACF,EACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"logs-view-CWG8aUAG.js","names":[],"sources":["../src/chat/logs-view.ts"],"sourcesContent":["/**\n * Pure helpers for the Settings \"Logs\" tab. Kept renderer-free so the\n * filtering / level-cycling logic is unit-testable without an OpenTUI\n * harness. The React view (`LogsList` in `settings-modal.tsx`) is a thin\n * shell over these.\n */\n\nimport type { LogLevel, LogRecord } from '../logger'\n\n/** Level order for the tab's min-level filter (matches the logger's ordering). */\nconst LEVEL_ORDER: Record<LogLevel, number> = { debug: 0, info: 1, warn: 2, error: 3 }\n\n/** The cycle order the `l` key walks through — coarsest last so it wraps back to \"everything\". */\nexport const LOG_LEVEL_CYCLE: readonly LogLevel[] = ['debug', 'info', 'warn', 'error']\n\n/** Next min-level in {@link LOG_LEVEL_CYCLE}, wrapping around. */\nexport function nextLogLevel(level: LogLevel): LogLevel {\n const i = LOG_LEVEL_CYCLE.indexOf(level)\n return LOG_LEVEL_CYCLE[(i + 1) % LOG_LEVEL_CYCLE.length]\n}\n\n/** Retain only records at or above `minLevel`. Preserves order. */\nexport function filterLogRecords(\n records: readonly LogRecord[],\n minLevel: LogLevel,\n): readonly LogRecord[] {\n const min = LEVEL_ORDER[minLevel]\n return records.filter(r => LEVEL_ORDER[r.level] >= min)\n}\n\n/**\n * Render a record as a single human-readable line (no trailing newline):\n * `<ISO timestamp> <LEVEL> <message> <attrs as kv pairs>`. Shared by the\n * console + file sinks, the TUI logs viewer, and the GUI Logs tab so every\n * surface presents a byte-identical line.\n *\n * Lives here rather than in `logger.ts` because that module imports\n * `node:fs` for its file sink; this one function is pure and is the only part\n * the renderer needs.\n */\nexport function formatLogLine(record: LogRecord): string {\n const ts = new Date(record.timestamp).toISOString()\n const kv = Object.entries(record.attrs)\n .filter(([, v]) => v !== undefined)\n .map(([k, v]) => `${k}=${typeof v === 'string' ? v : JSON.stringify(v)}`)\n .join(' ')\n return `${ts} ${record.level.toUpperCase().padEnd(5)} ${record.message}${kv ? ` ${kv}` : ''}`\n}\n"],"mappings":";;AAUA,MAAM,cAAwC;CAAE,OAAO;CAAG,MAAM;CAAG,MAAM;CAAG,OAAO;AAAE;;AAGrF,MAAa,kBAAuC;CAAC;CAAS;CAAQ;CAAQ;AAAO;;AAGrF,SAAgB,aAAa,OAA2B;CACtD,MAAM,IAAI,gBAAgB,QAAQ,KAAK;CACvC,OAAO,iBAAiB,IAAI,KAAK,gBAAgB;AACnD;;AAGA,SAAgB,iBACd,SACA,UACsB;CACtB,MAAM,MAAM,YAAY;CACxB,OAAO,QAAQ,QAAO,MAAK,YAAY,EAAE,UAAU,GAAG;AACxD;;;;;;;;;;;AAYA,SAAgB,cAAc,QAA2B;CACvD,MAAM,KAAK,IAAI,KAAK,OAAO,SAAS,CAAC,CAAC,YAAY;CAClD,MAAM,KAAK,OAAO,QAAQ,OAAO,KAAK,CAAC,CACpC,QAAQ,GAAG,OAAO,MAAM,KAAA,CAAS,CAAC,CAClC,KAAK,CAAC,GAAG,OAAO,GAAG,EAAE,GAAG,OAAO,MAAM,WAAW,IAAI,KAAK,UAAU,CAAC,GAAG,CAAC,CACxE,KAAK,GAAG;CACX,OAAO,GAAG,GAAG,GAAG,OAAO,MAAM,YAAY,CAAC,CAAC,OAAO,CAAC,EAAE,GAAG,OAAO,UAAU,KAAK,IAAI,OAAO;AAC3F"}
1
+ {"version":3,"file":"logs-view-CWG8aUAG.js","names":[],"sources":["../src/chat/logs-view.ts"],"sourcesContent":["/**\n * Pure helpers for the Settings \"Logs\" tab. Kept renderer-free so the\n * filtering / level-cycling logic is unit-testable without an OpenTUI\n * harness. The React view (`LogsList` in `tui/settings/logs-tab.tsx`) is a thin\n * shell over these.\n */\n\nimport type { LogLevel, LogRecord } from '../logger'\n\n/** Level order for the tab's min-level filter (matches the logger's ordering). */\nconst LEVEL_ORDER: Record<LogLevel, number> = { debug: 0, info: 1, warn: 2, error: 3 }\n\n/** The cycle order the `l` key walks through — coarsest last so it wraps back to \"everything\". */\nexport const LOG_LEVEL_CYCLE: readonly LogLevel[] = ['debug', 'info', 'warn', 'error']\n\n/** Next min-level in {@link LOG_LEVEL_CYCLE}, wrapping around. */\nexport function nextLogLevel(level: LogLevel): LogLevel {\n const i = LOG_LEVEL_CYCLE.indexOf(level)\n return LOG_LEVEL_CYCLE[(i + 1) % LOG_LEVEL_CYCLE.length]\n}\n\n/** Retain only records at or above `minLevel`. Preserves order. */\nexport function filterLogRecords(\n records: readonly LogRecord[],\n minLevel: LogLevel,\n): readonly LogRecord[] {\n const min = LEVEL_ORDER[minLevel]\n return records.filter(r => LEVEL_ORDER[r.level] >= min)\n}\n\n/**\n * Render a record as a single human-readable line (no trailing newline):\n * `<ISO timestamp> <LEVEL> <message> <attrs as kv pairs>`. Shared by the\n * console + file sinks, the TUI logs viewer, and the GUI Logs tab so every\n * surface presents a byte-identical line.\n *\n * Lives here rather than in `logger.ts` because that module imports\n * `node:fs` for its file sink; this one function is pure and is the only part\n * the renderer needs.\n */\nexport function formatLogLine(record: LogRecord): string {\n const ts = new Date(record.timestamp).toISOString()\n const kv = Object.entries(record.attrs)\n .filter(([, v]) => v !== undefined)\n .map(([k, v]) => `${k}=${typeof v === 'string' ? v : JSON.stringify(v)}`)\n .join(' ')\n return `${ts} ${record.level.toUpperCase().padEnd(5)} ${record.message}${kv ? ` ${kv}` : ''}`\n}\n"],"mappings":";;AAUA,MAAM,cAAwC;CAAE,OAAO;CAAG,MAAM;CAAG,MAAM;CAAG,OAAO;AAAE;;AAGrF,MAAa,kBAAuC;CAAC;CAAS;CAAQ;CAAQ;AAAO;;AAGrF,SAAgB,aAAa,OAA2B;CACtD,MAAM,IAAI,gBAAgB,QAAQ,KAAK;CACvC,OAAO,iBAAiB,IAAI,KAAK,gBAAgB;AACnD;;AAGA,SAAgB,iBACd,SACA,UACsB;CACtB,MAAM,MAAM,YAAY;CACxB,OAAO,QAAQ,QAAO,MAAK,YAAY,EAAE,UAAU,GAAG;AACxD;;;;;;;;;;;AAYA,SAAgB,cAAc,QAA2B;CACvD,MAAM,KAAK,IAAI,KAAK,OAAO,SAAS,CAAC,CAAC,YAAY;CAClD,MAAM,KAAK,OAAO,QAAQ,OAAO,KAAK,CAAC,CACpC,QAAQ,GAAG,OAAO,MAAM,KAAA,CAAS,CAAC,CAClC,KAAK,CAAC,GAAG,OAAO,GAAG,EAAE,GAAG,OAAO,MAAM,WAAW,IAAI,KAAK,UAAU,CAAC,GAAG,CAAC,CACxE,KAAK,GAAG;CACX,OAAO,GAAG,GAAG,GAAG,OAAO,MAAM,YAAY,CAAC,CAAC,OAAO,CAAC,EAAE,GAAG,OAAO,UAAU,KAAK,IAAI,OAAO;AAC3F"}