@namzu/cli 51.0.1 → 51.2.0

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 (451) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/dist/bin.js +1 -1
  3. package/dist/chunks/{acp-OKCSCFH2.js → acp-HCVLUS7I.js} +125 -72
  4. package/dist/chunks/acp-HCVLUS7I.js.map +6 -0
  5. package/dist/chunks/{activity-command-SJGXPUYE.js → activity-command-I3OMRZ2T.js} +13 -13
  6. package/dist/chunks/{add-H4FUTHAQ.js → add-A65AU46H.js} +90 -24
  7. package/dist/chunks/add-A65AU46H.js.map +6 -0
  8. package/dist/chunks/{agent-U4YLYJ4N.js → agent-3A66KRCM.js} +40 -38
  9. package/dist/chunks/agent-session-LJZO5VIZ.js +71 -0
  10. package/dist/chunks/{archive-O236ZKWI.js → archive-IWWDLSAO.js} +11 -11
  11. package/dist/chunks/{bin-main-YS3HF46K.js → bin-main-CRX2U7A6.js} +9 -9
  12. package/dist/chunks/{binding-SS7YOEIZ.js → binding-4AMPOED7.js} +3 -3
  13. package/dist/chunks/{browser-OA2KB5Z2.js → browser-SAS7YPVD.js} +7 -7
  14. package/dist/chunks/{chat-EBNDAIRO.js → chat-ANHTX7D5.js} +16 -16
  15. package/dist/chunks/{chunk-F3QD24YN.js → chunk-2HB47MDS.js} +70 -41
  16. package/dist/chunks/chunk-2HB47MDS.js.map +6 -0
  17. package/dist/chunks/{chunk-YGLJBR4L.js → chunk-3D52GNVJ.js} +4 -4
  18. package/dist/chunks/{chunk-BPZQYXLI.js → chunk-3MJ3YKNV.js} +5 -5
  19. package/dist/chunks/chunk-3YM3IWPW.js +221 -0
  20. package/dist/chunks/chunk-3YM3IWPW.js.map +6 -0
  21. package/dist/chunks/{chunk-KN3FKKYY.js → chunk-45Z4OPC6.js} +3 -3
  22. package/dist/chunks/{chunk-MTY3SZOT.js → chunk-52YXYXRG.js} +2 -2
  23. package/dist/chunks/{chunk-XMYFIXCP.js → chunk-56ZS6OTK.js} +4 -4
  24. package/dist/chunks/{chunk-KUVGN7VF.js → chunk-57QGQNRI.js} +2 -2
  25. package/dist/chunks/{chunk-HXWIEKOB.js → chunk-5TPQGNYN.js} +4 -4
  26. package/dist/chunks/{chunk-WCMXLFUB.js → chunk-5U42MB6F.js} +10 -10
  27. package/dist/chunks/{chunk-LMLCGIQR.js → chunk-5YMIK3VP.js} +3 -3
  28. package/dist/chunks/{chunk-ZIUKLIUS.js → chunk-6CKU4TCF.js} +8 -3
  29. package/dist/chunks/chunk-6CKU4TCF.js.map +6 -0
  30. package/dist/chunks/{chunk-Y5D6542Z.js → chunk-6I4V7I5M.js} +2 -2
  31. package/dist/chunks/{chunk-R6ZDPAEV.js → chunk-6MI4Q5QQ.js} +4 -4
  32. package/dist/chunks/{chunk-JHLJJDNJ.js → chunk-6S4L4SAU.js} +7 -7
  33. package/dist/chunks/{chunk-UBOE47YI.js → chunk-AGC67H4M.js} +4 -4
  34. package/dist/chunks/{chunk-WD45OZPT.js → chunk-ALXE3SUZ.js} +3 -3
  35. package/dist/chunks/{chunk-4HGQJYDZ.js → chunk-ANVIYMV6.js} +3 -3
  36. package/dist/chunks/chunk-BBTPD3DU.js +19 -0
  37. package/dist/chunks/chunk-BBTPD3DU.js.map +6 -0
  38. package/dist/chunks/{chunk-HAIXGRRS.js → chunk-BC3IZXTY.js} +2 -2
  39. package/dist/chunks/{chunk-7J3IMJKF.js → chunk-BN32BPU6.js} +2 -2
  40. package/dist/chunks/chunk-BUP54TBX.js +214 -0
  41. package/dist/chunks/chunk-BUP54TBX.js.map +6 -0
  42. package/dist/chunks/chunk-CYCUJOAD.js +313 -0
  43. package/dist/chunks/chunk-CYCUJOAD.js.map +6 -0
  44. package/dist/chunks/{chunk-HDBTTV2S.js → chunk-DLVHJFXI.js} +2 -2
  45. package/dist/chunks/{chunk-CIHHPULI.js → chunk-DNOI4BL2.js} +2 -2
  46. package/dist/chunks/{chunk-PWNFXNFK.js → chunk-DOPHHI6C.js} +3 -65
  47. package/dist/chunks/chunk-DOPHHI6C.js.map +6 -0
  48. package/dist/chunks/{chunk-UNQYPFDZ.js → chunk-E5OETSRN.js} +6 -6
  49. package/dist/chunks/{chunk-YM5DH66D.js → chunk-E7IXVEOQ.js} +3 -3
  50. package/dist/chunks/{chunk-GUZEB3KN.js → chunk-FKQOGEKL.js} +3 -3
  51. package/dist/chunks/{chunk-JEEF7UIH.js → chunk-FLPT7I7I.js} +4 -4
  52. package/dist/chunks/{chunk-QY4UUQQT.js → chunk-FMAUDMYL.js} +12 -12
  53. package/dist/chunks/{chunk-TQG7WZI5.js → chunk-FSS72QJP.js} +2 -2
  54. package/dist/chunks/{chunk-YMWHDGCW.js → chunk-FTMONTUX.js} +3 -1
  55. package/dist/chunks/chunk-FTMONTUX.js.map +6 -0
  56. package/dist/chunks/chunk-G4N43E6M.js +62 -0
  57. package/dist/chunks/chunk-G4N43E6M.js.map +6 -0
  58. package/dist/chunks/{chunk-OLI35PTE.js → chunk-H56PLZHW.js} +2 -2
  59. package/dist/chunks/{chunk-2E3ALKOF.js → chunk-HHLWXGOG.js} +3 -3
  60. package/dist/chunks/{chunk-VVMRXGQ6.js → chunk-HQ4WFN7B.js} +4649 -2177
  61. package/dist/chunks/chunk-HQ4WFN7B.js.map +6 -0
  62. package/dist/chunks/{chunk-P52PAWBP.js → chunk-HXPRWMLH.js} +4 -4
  63. package/dist/chunks/{tui-L4BRR4H5.js → chunk-ILPXZDTW.js} +699 -1390
  64. package/dist/chunks/chunk-ILPXZDTW.js.map +6 -0
  65. package/dist/chunks/{chunk-FA2ZVSEU.js → chunk-IPTWZUSV.js} +2 -2
  66. package/dist/chunks/{chunk-LLR7GHVU.js → chunk-ITY5SBAS.js} +2 -2
  67. package/dist/chunks/{chunk-TXP6SOA7.js → chunk-JR6EFL7G.js} +5 -4
  68. package/dist/chunks/chunk-JR6EFL7G.js.map +6 -0
  69. package/dist/chunks/{chunk-JVIS6M37.js → chunk-JUN4VUC6.js} +64 -224
  70. package/dist/chunks/chunk-JUN4VUC6.js.map +6 -0
  71. package/dist/chunks/{chunk-22PMPEFX.js → chunk-K52DES57.js} +3 -3
  72. package/dist/chunks/chunk-KD6WL3W7.js +10 -0
  73. package/dist/chunks/chunk-KD6WL3W7.js.map +6 -0
  74. package/dist/chunks/{chunk-BK5AJ7TL.js → chunk-KJ7Q3BC3.js} +2 -2
  75. package/dist/chunks/{chunk-F7ECNFNX.js → chunk-KJVRHBMX.js} +9 -4
  76. package/dist/chunks/chunk-KJVRHBMX.js.map +6 -0
  77. package/dist/chunks/{chunk-MV2T5HFQ.js → chunk-KZHMLRKY.js} +4 -4
  78. package/dist/chunks/{chunk-FSPBJ5VF.js → chunk-LAXSPXNP.js} +4 -3
  79. package/dist/chunks/{chunk-FSPBJ5VF.js.map → chunk-LAXSPXNP.js.map} +1 -1
  80. package/dist/chunks/{chunk-D3ITBQ7T.js → chunk-LGH2T6KL.js} +2 -2
  81. package/dist/chunks/{chunk-3XIWMQLP.js → chunk-LQJ3TB5E.js} +10 -10
  82. package/dist/chunks/{chunk-6GITBOHO.js → chunk-LYPEV765.js} +2 -2
  83. package/dist/chunks/chunk-LYUY2FK2.js +141 -0
  84. package/dist/chunks/chunk-LYUY2FK2.js.map +6 -0
  85. package/dist/chunks/{chunk-O53H43CX.js → chunk-M44I7P3H.js} +2 -2
  86. package/dist/chunks/{chunk-MOGE5ZMI.js → chunk-NAWIOVUH.js} +3 -3
  87. package/dist/chunks/{chunk-ZNC5BEFK.js → chunk-NGE7TNCY.js} +2 -2
  88. package/dist/chunks/{chunk-AJHNH4WR.js → chunk-NXJQTDVT.js} +121 -90
  89. package/dist/chunks/chunk-NXJQTDVT.js.map +6 -0
  90. package/dist/chunks/{chunk-NWIOFCDB.js → chunk-NY3I4WL7.js} +217 -372
  91. package/dist/chunks/chunk-NY3I4WL7.js.map +6 -0
  92. package/dist/chunks/{chunk-JABCT4RQ.js → chunk-OEKCCZ7I.js} +5 -5
  93. package/dist/chunks/{chunk-HFY2647W.js → chunk-OG2MLME3.js} +2 -1
  94. package/dist/chunks/{chunk-HFY2647W.js.map → chunk-OG2MLME3.js.map} +1 -1
  95. package/dist/chunks/{chunk-DWFJETFP.js → chunk-OL5SKFPM.js} +4 -4
  96. package/dist/chunks/{chunk-V4WSIY32.js → chunk-OMP25UWR.js} +6 -2
  97. package/dist/chunks/chunk-OMP25UWR.js.map +6 -0
  98. package/dist/chunks/{chunk-VLE4DKQR.js → chunk-P53E77KS.js} +3 -3
  99. package/dist/chunks/{chunk-PV4TEEGI.js → chunk-PI6KC5CD.js} +5 -5
  100. package/dist/chunks/{chunk-O62YM5KA.js → chunk-Q5DW33F4.js} +2 -2
  101. package/dist/chunks/{chunk-V5DDXBVW.js → chunk-QS65X7D6.js} +4 -4
  102. package/dist/chunks/{chunk-P5OZ7YN6.js → chunk-QZ4V25KD.js} +8 -3
  103. package/dist/chunks/chunk-QZ4V25KD.js.map +6 -0
  104. package/dist/chunks/chunk-RCLTSI6G.js +102 -0
  105. package/dist/chunks/chunk-RCLTSI6G.js.map +6 -0
  106. package/dist/chunks/{chunk-WEUXBFYG.js → chunk-RDWVNVZS.js} +51 -93
  107. package/dist/chunks/chunk-RDWVNVZS.js.map +6 -0
  108. package/dist/chunks/{chunk-PKGMZRUT.js → chunk-SMX5YHRV.js} +2 -2
  109. package/dist/chunks/{chunk-R6P5H47N.js → chunk-SQWFNFEX.js} +3 -3
  110. package/dist/chunks/{chunk-RTDE5QSZ.js → chunk-SR75L2R5.js} +4 -4
  111. package/dist/chunks/{chunk-FUVWMCRY.js → chunk-T5X3GYBF.js} +2 -2
  112. package/dist/chunks/{chunk-YY6RFZ2L.js → chunk-TJSGSC2W.js} +9 -9
  113. package/dist/chunks/{chunk-O7J6EFVD.js → chunk-TTXZK3BR.js} +3 -3
  114. package/dist/chunks/{chunk-77RA2AU7.js → chunk-U7AQ4OQJ.js} +4 -3
  115. package/dist/chunks/{chunk-635U2FDK.js → chunk-UPSI724V.js} +3 -3
  116. package/dist/chunks/{chunk-56SPZGFT.js → chunk-V23HHK5D.js} +3 -3
  117. package/dist/chunks/{chunk-C5P7OAML.js → chunk-VQHVH7X2.js} +3 -3
  118. package/dist/chunks/{chunk-HARFWJBQ.js → chunk-WJ4YRFPQ.js} +2 -2
  119. package/dist/chunks/{chunk-DFFTGAS7.js → chunk-WJXVNXJZ.js} +22 -22
  120. package/dist/chunks/{chunk-PR2EE4G4.js → chunk-WOX4KI7C.js} +3 -3
  121. package/dist/chunks/{chunk-CDDXHKSP.js → chunk-X3L6N5RM.js} +36 -11
  122. package/dist/chunks/{chunk-CDDXHKSP.js.map → chunk-X3L6N5RM.js.map} +1 -1
  123. package/dist/chunks/{chunk-ONVXBWB5.js → chunk-XFMGW2C5.js} +2 -2
  124. package/dist/chunks/{chunk-RTFC2VXR.js → chunk-XPCRLKFO.js} +7 -6
  125. package/dist/chunks/{chunk-MEZUNP2E.js → chunk-XYT53O3Z.js} +2 -2
  126. package/dist/chunks/{chunk-EB7AS2K4.js → chunk-YSV633T5.js} +10 -10
  127. package/dist/chunks/{chunk-PN2UBL2H.js → chunk-ZXFEHB7N.js} +2 -2
  128. package/dist/chunks/{cli-runtime-5GEVVA3K.js → cli-runtime-5UE6P2QW.js} +20 -17
  129. package/dist/chunks/cli-runtime-5UE6P2QW.js.map +6 -0
  130. package/dist/chunks/{commands-Y37MKMRJ.js → commands-IOHIM2PX.js} +6 -6
  131. package/dist/chunks/{computer-UE2AN7NW.js → computer-ZWTWBY67.js} +2 -2
  132. package/dist/chunks/cost-MYSYQTT3.js +755 -0
  133. package/dist/chunks/cost-MYSYQTT3.js.map +6 -0
  134. package/dist/chunks/{crash-report-S6W5DXCO.js → crash-report-WLLGI2U4.js} +6 -6
  135. package/dist/chunks/day-CU5J7UAK.js +22 -0
  136. package/dist/chunks/{dist-YO357DAD.js → dist-33QU2MGT.js} +2 -2
  137. package/dist/chunks/{dist-5E47CZZT.js → dist-6G55RC27.js} +2 -2
  138. package/dist/chunks/{dist-HCI4L6AO.js → dist-CFPNJCLJ.js} +2 -2
  139. package/dist/chunks/{dist-3FVIUYVA.js → dist-E2PF4PGO.js} +2 -2
  140. package/dist/chunks/{dist-4ATGJMUC.js → dist-FZYKXUR4.js} +2 -2
  141. package/dist/chunks/{dist-2RVY7QOH.js → dist-IXAUMLZH.js} +2 -2
  142. package/dist/chunks/{dist-DODOSCTW.js → dist-MBVPANQB.js} +106 -2
  143. package/dist/chunks/{dist-IPQPISKD.js → dist-PKKDBDSA.js} +2 -2
  144. package/dist/chunks/{doctor-EZEJEK6B.js → doctor-BXRPVVKL.js} +20 -20
  145. package/dist/chunks/{drain-VVEMLN3L.js → drain-EWKGL77B.js} +10 -10
  146. package/dist/chunks/{entry-CZ63UJYN.js → entry-XPXHELKT.js} +6 -6
  147. package/dist/chunks/eval-OLNNJGUO.js +351 -0
  148. package/dist/chunks/eval-OLNNJGUO.js.map +6 -0
  149. package/dist/chunks/{exec-DYAFXHZM.js → exec-XNMHHHTZ.js} +81 -53
  150. package/dist/chunks/exec-XNMHHHTZ.js.map +6 -0
  151. package/dist/chunks/{github-VCUDZDGI.js → github-FQAXV2KP.js} +2 -2
  152. package/dist/chunks/{home-UVU2HRDB.js → home-T4ZVXIEX.js} +3 -3
  153. package/dist/chunks/{host-Q3YNLTNL.js → host-LQ6V4NJS.js} +10 -10
  154. package/dist/chunks/{host-queries-Z4BSL457.js → host-queries-LEPTBKZK.js} +15 -15
  155. package/dist/chunks/{learn-SAZ3JOK3.js → learn-WOZKPYR4.js} +12 -12
  156. package/dist/chunks/{learn-builtin-SQ2BTDFH.js → learn-builtin-BVJFZF4R.js} +15 -15
  157. package/dist/chunks/{lifecycle-24A5HH4I.js → lifecycle-KKIDSRJV.js} +34 -33
  158. package/dist/chunks/{list-HAI55KLQ.js → list-ZWIXNGJV.js} +27 -17
  159. package/dist/chunks/list-ZWIXNGJV.js.map +6 -0
  160. package/dist/chunks/{live-EIQ666TU.js → live-4GQNVGPU.js} +18 -18
  161. package/dist/chunks/{login-YJ6L7KSY.js → login-MBXPJW6F.js} +14 -14
  162. package/dist/chunks/{logs-RWGXFRMN.js → logs-7GVMBYAQ.js} +6 -6
  163. package/dist/chunks/{mcp-DO454555.js → mcp-45UUEZMF.js} +24 -24
  164. package/dist/chunks/{message-command-AJOTC3UK.js → message-command-YVAI3SLS.js} +48 -46
  165. package/dist/chunks/message-command-YVAI3SLS.js.map +6 -0
  166. package/dist/chunks/{open-LEAR5UBX.js → open-UG6VAHDW.js} +8 -8
  167. package/dist/chunks/{operator-tools-AHP32F2J.js → operator-tools-M4SMIAYS.js} +13 -13
  168. package/dist/chunks/{output-schema-YDKTNTMM.js → output-schema-MZ6X4WQ2.js} +3 -3
  169. package/dist/chunks/{pal-XPZD6PAO.js → pal-R4RSZP2U.js} +17 -17
  170. package/dist/chunks/{peers-MRKWY3MG.js → peers-6TIMGPGR.js} +8 -8
  171. package/dist/chunks/{peers-NLUBD4IW.js → peers-T5SXNFYU.js} +6 -6
  172. package/dist/chunks/plugin-SAQJPDKX.js +1043 -0
  173. package/dist/chunks/plugin-SAQJPDKX.js.map +6 -0
  174. package/dist/chunks/{providers-QPESWN6K.js → providers-CPHEQZCV.js} +11 -11
  175. package/dist/chunks/{pty-BDOOEOCB.js → pty-YAFV4ZA6.js} +3 -3
  176. package/dist/chunks/render-QFCCPEEL.js +14 -0
  177. package/dist/chunks/resume-GZGHY4UR.js +23 -0
  178. package/dist/chunks/{resume-command-KIXKOEM3.js → resume-command-WJH7SKYB.js} +5 -5
  179. package/dist/chunks/{schedule-6BKCRYAT.js → schedule-I7ZNWSN3.js} +15 -10
  180. package/dist/chunks/schedule-I7ZNWSN3.js.map +6 -0
  181. package/dist/chunks/{service-ENTDZAVD.js → service-ZRXXXJW7.js} +34 -33
  182. package/dist/chunks/service-ZRXXXJW7.js.map +6 -0
  183. package/dist/chunks/{skills-MG2BRTPV.js → skills-RIJBOCKN.js} +9 -9
  184. package/dist/chunks/{start-check-7WYNSBON.js → start-check-5DQL76YU.js} +2 -2
  185. package/dist/chunks/{startup-failure-EWWYKPVE.js → startup-failure-7KMOAOXE.js} +2 -2
  186. package/dist/chunks/{state-6UVY4EHA.js → state-QNSG3QWY.js} +3 -3
  187. package/dist/chunks/{store-OKK7A6ZE.js → store-7NXFZTW7.js} +6 -6
  188. package/dist/chunks/{store-UFUDXZG6.js → store-IDSNTJRG.js} +10 -10
  189. package/dist/chunks/{store-ASWK7TVD.js → store-NE2I4H7E.js} +3 -3
  190. package/dist/chunks/store-NE2I4H7E.js.map +6 -0
  191. package/dist/chunks/{store-XU4PITDA.js → store-TY2ZO2EP.js} +4 -4
  192. package/dist/chunks/store-TY2ZO2EP.js.map +6 -0
  193. package/dist/chunks/tui-DLUH6HQ4.js +1034 -0
  194. package/dist/chunks/tui-DLUH6HQ4.js.map +6 -0
  195. package/dist/chunks/{upgrade-IJFMAW3T.js → upgrade-UZTPAIDF.js} +8 -8
  196. package/dist/chunks/watch-AAZHSSIE.js +982 -0
  197. package/dist/chunks/watch-AAZHSSIE.js.map +6 -0
  198. package/dist/chunks/{workspaces-KVFY66IC.js → workspaces-KLYC5537.js} +16 -16
  199. package/dist/chunks/{worktree-7JTMEYRX.js → worktree-4PKAJ7LT.js} +13 -13
  200. package/dist/cli.d.ts.map +1 -1
  201. package/dist/commands/acp.d.ts +20 -1
  202. package/dist/commands/acp.d.ts.map +1 -1
  203. package/dist/commands/cost.d.ts +26 -0
  204. package/dist/commands/cost.d.ts.map +1 -0
  205. package/dist/commands/desktop-host.d.ts.map +1 -1
  206. package/dist/commands/eval.d.ts.map +1 -1
  207. package/dist/commands/exec-flags.d.ts +2 -0
  208. package/dist/commands/exec-flags.d.ts.map +1 -1
  209. package/dist/commands/exec-json.d.ts.map +1 -1
  210. package/dist/commands/exec.d.ts.map +1 -1
  211. package/dist/commands/manifest.d.ts +3 -0
  212. package/dist/commands/manifest.d.ts.map +1 -1
  213. package/dist/commands/plugin.d.ts +18 -0
  214. package/dist/commands/plugin.d.ts.map +1 -0
  215. package/dist/commands/schedule.d.ts.map +1 -1
  216. package/dist/commands/watch.d.ts +41 -0
  217. package/dist/commands/watch.d.ts.map +1 -0
  218. package/dist/config/load.d.ts.map +1 -1
  219. package/dist/config/schema.d.ts +25 -0
  220. package/dist/config/schema.d.ts.map +1 -1
  221. package/dist/config/settings-descriptors.d.ts.map +1 -1
  222. package/dist/config/turn-guards.d.ts +5 -2
  223. package/dist/config/turn-guards.d.ts.map +1 -1
  224. package/dist/desktop-contract.d.ts +21 -0
  225. package/dist/desktop-contract.d.ts.map +1 -0
  226. package/dist/exit-codes.d.ts +9 -1
  227. package/dist/exit-codes.d.ts.map +1 -1
  228. package/dist/index.d.ts +1 -0
  229. package/dist/index.d.ts.map +1 -1
  230. package/dist/index.js +37 -33
  231. package/dist/integrations/auto-update/install-kind.d.ts.map +1 -1
  232. package/dist/integrations/plugins/check-hint.d.ts +5 -0
  233. package/dist/integrations/plugins/check-hint.d.ts.map +1 -0
  234. package/dist/integrations/plugins/files.d.ts +17 -0
  235. package/dist/integrations/plugins/files.d.ts.map +1 -1
  236. package/dist/integrations/plugins/validate.d.ts +75 -0
  237. package/dist/integrations/plugins/validate.d.ts.map +1 -0
  238. package/dist/integrations/sessions/session-watch.d.ts +127 -0
  239. package/dist/integrations/sessions/session-watch.d.ts.map +1 -0
  240. package/dist/integrations/sessions/watch-view.d.ts +73 -0
  241. package/dist/integrations/sessions/watch-view.d.ts.map +1 -0
  242. package/dist/integrations/sessions/watch-wait.d.ts +32 -0
  243. package/dist/integrations/sessions/watch-wait.d.ts.map +1 -0
  244. package/dist/integrations/spend/day.d.ts +26 -0
  245. package/dist/integrations/spend/day.d.ts.map +1 -0
  246. package/dist/integrations/spend/fold.d.ts +136 -0
  247. package/dist/integrations/spend/fold.d.ts.map +1 -0
  248. package/dist/integrations/spend/ledger.d.ts +74 -0
  249. package/dist/integrations/spend/ledger.d.ts.map +1 -0
  250. package/dist/integrations/spend/render.d.ts +6 -0
  251. package/dist/integrations/spend/render.d.ts.map +1 -0
  252. package/dist/integrations/spend/report.d.ts +110 -0
  253. package/dist/integrations/spend/report.d.ts.map +1 -0
  254. package/dist/integrations/telemetry/otlp-export.d.ts +3 -0
  255. package/dist/integrations/telemetry/otlp-export.d.ts.map +1 -1
  256. package/dist/schedule/build.d.ts +12 -0
  257. package/dist/schedule/build.d.ts.map +1 -1
  258. package/dist/schedule/changes.d.ts.map +1 -1
  259. package/dist/schedule/commands/add.d.ts +1 -1
  260. package/dist/schedule/commands/add.d.ts.map +1 -1
  261. package/dist/schedule/commands/list.d.ts +2 -0
  262. package/dist/schedule/commands/list.d.ts.map +1 -1
  263. package/dist/schedule/daemon/daemon.d.ts.map +1 -1
  264. package/dist/schedule/daemon/notify.d.ts +7 -2
  265. package/dist/schedule/daemon/notify.d.ts.map +1 -1
  266. package/dist/schedule/delivery.d.ts.map +1 -1
  267. package/dist/schedule/fire/calls.d.ts +2 -0
  268. package/dist/schedule/fire/calls.d.ts.map +1 -1
  269. package/dist/schedule/fire/fire.d.ts +3 -0
  270. package/dist/schedule/fire/fire.d.ts.map +1 -1
  271. package/dist/schedule/fire/run-script.d.ts +4 -0
  272. package/dist/schedule/fire/run-script.d.ts.map +1 -1
  273. package/dist/schedule/fire/unattended-note.d.ts +5 -0
  274. package/dist/schedule/fire/unattended-note.d.ts.map +1 -1
  275. package/dist/schedule/gate.d.ts +73 -0
  276. package/dist/schedule/gate.d.ts.map +1 -0
  277. package/dist/schedule/store/jobs.d.ts +2 -2
  278. package/dist/schedule/store/jobs.d.ts.map +1 -1
  279. package/dist/schedule/types.d.ts +60 -1
  280. package/dist/schedule/types.d.ts.map +1 -1
  281. package/dist/tui/App.d.ts.map +1 -1
  282. package/dist/tui/Markdown.d.ts +5 -1
  283. package/dist/tui/Markdown.d.ts.map +1 -1
  284. package/dist/tui/ScheduleReviewOverlay.d.ts.map +1 -1
  285. package/dist/tui/agent.d.ts +14 -1
  286. package/dist/tui/agent.d.ts.map +1 -1
  287. package/dist/tui/fullscreen/markdown-rows.d.ts.map +1 -1
  288. package/dist/tui/markdown-structure.d.ts +24 -0
  289. package/dist/tui/markdown-structure.d.ts.map +1 -0
  290. package/dist/tui/markdownParser.d.ts +11 -0
  291. package/dist/tui/markdownParser.d.ts.map +1 -1
  292. package/dist/tui/outcome-line.d.ts +29 -1
  293. package/dist/tui/outcome-line.d.ts.map +1 -1
  294. package/dist/tui/restored-rows.d.ts +8 -1
  295. package/dist/tui/restored-rows.d.ts.map +1 -1
  296. package/dist/tui/schedule/host-commands.d.ts.map +1 -1
  297. package/dist/tui/schedule/source-deliveries.d.ts.map +1 -1
  298. package/dist/tui/schedule/tool-host.d.ts.map +1 -1
  299. package/dist/tui/slashCommands.d.ts +5 -0
  300. package/dist/tui/slashCommands.d.ts.map +1 -1
  301. package/dist/tui/tool-end-rows.d.ts +1 -1
  302. package/dist/tui/tool-end-rows.d.ts.map +1 -1
  303. package/dist/tui/types.d.ts +5 -1
  304. package/dist/tui/types.d.ts.map +1 -1
  305. package/dist/user-commands/store.d.ts +14 -0
  306. package/dist/user-commands/store.d.ts.map +1 -1
  307. package/package.json +5 -5
  308. package/skills/schedule-task/SKILL.md +8 -0
  309. package/dist/chunks/acp-OKCSCFH2.js.map +0 -6
  310. package/dist/chunks/add-H4FUTHAQ.js.map +0 -6
  311. package/dist/chunks/agent-session-YNUAPMAL.js +0 -69
  312. package/dist/chunks/chunk-AJHNH4WR.js.map +0 -6
  313. package/dist/chunks/chunk-F3QD24YN.js.map +0 -6
  314. package/dist/chunks/chunk-F7ECNFNX.js.map +0 -6
  315. package/dist/chunks/chunk-JVIS6M37.js.map +0 -6
  316. package/dist/chunks/chunk-NWIOFCDB.js.map +0 -6
  317. package/dist/chunks/chunk-P5OZ7YN6.js.map +0 -6
  318. package/dist/chunks/chunk-PWNFXNFK.js.map +0 -6
  319. package/dist/chunks/chunk-TXP6SOA7.js.map +0 -6
  320. package/dist/chunks/chunk-V4WSIY32.js.map +0 -6
  321. package/dist/chunks/chunk-VVMRXGQ6.js.map +0 -6
  322. package/dist/chunks/chunk-WEUXBFYG.js.map +0 -6
  323. package/dist/chunks/chunk-YMWHDGCW.js.map +0 -6
  324. package/dist/chunks/chunk-ZIUKLIUS.js.map +0 -6
  325. package/dist/chunks/cli-runtime-5GEVVA3K.js.map +0 -6
  326. package/dist/chunks/eval-ZOF3EXZS.js +0 -187
  327. package/dist/chunks/eval-ZOF3EXZS.js.map +0 -6
  328. package/dist/chunks/exec-DYAFXHZM.js.map +0 -6
  329. package/dist/chunks/list-HAI55KLQ.js.map +0 -6
  330. package/dist/chunks/message-command-AJOTC3UK.js.map +0 -6
  331. package/dist/chunks/resume-ZS3VS5OQ.js +0 -23
  332. package/dist/chunks/schedule-6BKCRYAT.js.map +0 -6
  333. package/dist/chunks/service-ENTDZAVD.js.map +0 -6
  334. package/dist/chunks/tui-L4BRR4H5.js.map +0 -6
  335. /package/dist/chunks/{activity-command-SJGXPUYE.js.map → activity-command-I3OMRZ2T.js.map} +0 -0
  336. /package/dist/chunks/{agent-U4YLYJ4N.js.map → agent-3A66KRCM.js.map} +0 -0
  337. /package/dist/chunks/{agent-session-YNUAPMAL.js.map → agent-session-LJZO5VIZ.js.map} +0 -0
  338. /package/dist/chunks/{archive-O236ZKWI.js.map → archive-IWWDLSAO.js.map} +0 -0
  339. /package/dist/chunks/{bin-main-YS3HF46K.js.map → bin-main-CRX2U7A6.js.map} +0 -0
  340. /package/dist/chunks/{binding-SS7YOEIZ.js.map → binding-4AMPOED7.js.map} +0 -0
  341. /package/dist/chunks/{browser-OA2KB5Z2.js.map → browser-SAS7YPVD.js.map} +0 -0
  342. /package/dist/chunks/{chat-EBNDAIRO.js.map → chat-ANHTX7D5.js.map} +0 -0
  343. /package/dist/chunks/{chunk-YGLJBR4L.js.map → chunk-3D52GNVJ.js.map} +0 -0
  344. /package/dist/chunks/{chunk-BPZQYXLI.js.map → chunk-3MJ3YKNV.js.map} +0 -0
  345. /package/dist/chunks/{chunk-KN3FKKYY.js.map → chunk-45Z4OPC6.js.map} +0 -0
  346. /package/dist/chunks/{chunk-MTY3SZOT.js.map → chunk-52YXYXRG.js.map} +0 -0
  347. /package/dist/chunks/{chunk-XMYFIXCP.js.map → chunk-56ZS6OTK.js.map} +0 -0
  348. /package/dist/chunks/{chunk-KUVGN7VF.js.map → chunk-57QGQNRI.js.map} +0 -0
  349. /package/dist/chunks/{chunk-HXWIEKOB.js.map → chunk-5TPQGNYN.js.map} +0 -0
  350. /package/dist/chunks/{chunk-WCMXLFUB.js.map → chunk-5U42MB6F.js.map} +0 -0
  351. /package/dist/chunks/{chunk-LMLCGIQR.js.map → chunk-5YMIK3VP.js.map} +0 -0
  352. /package/dist/chunks/{chunk-Y5D6542Z.js.map → chunk-6I4V7I5M.js.map} +0 -0
  353. /package/dist/chunks/{chunk-R6ZDPAEV.js.map → chunk-6MI4Q5QQ.js.map} +0 -0
  354. /package/dist/chunks/{chunk-JHLJJDNJ.js.map → chunk-6S4L4SAU.js.map} +0 -0
  355. /package/dist/chunks/{chunk-UBOE47YI.js.map → chunk-AGC67H4M.js.map} +0 -0
  356. /package/dist/chunks/{chunk-WD45OZPT.js.map → chunk-ALXE3SUZ.js.map} +0 -0
  357. /package/dist/chunks/{chunk-4HGQJYDZ.js.map → chunk-ANVIYMV6.js.map} +0 -0
  358. /package/dist/chunks/{chunk-HAIXGRRS.js.map → chunk-BC3IZXTY.js.map} +0 -0
  359. /package/dist/chunks/{chunk-7J3IMJKF.js.map → chunk-BN32BPU6.js.map} +0 -0
  360. /package/dist/chunks/{chunk-HDBTTV2S.js.map → chunk-DLVHJFXI.js.map} +0 -0
  361. /package/dist/chunks/{chunk-CIHHPULI.js.map → chunk-DNOI4BL2.js.map} +0 -0
  362. /package/dist/chunks/{chunk-UNQYPFDZ.js.map → chunk-E5OETSRN.js.map} +0 -0
  363. /package/dist/chunks/{chunk-YM5DH66D.js.map → chunk-E7IXVEOQ.js.map} +0 -0
  364. /package/dist/chunks/{chunk-GUZEB3KN.js.map → chunk-FKQOGEKL.js.map} +0 -0
  365. /package/dist/chunks/{chunk-JEEF7UIH.js.map → chunk-FLPT7I7I.js.map} +0 -0
  366. /package/dist/chunks/{chunk-QY4UUQQT.js.map → chunk-FMAUDMYL.js.map} +0 -0
  367. /package/dist/chunks/{chunk-TQG7WZI5.js.map → chunk-FSS72QJP.js.map} +0 -0
  368. /package/dist/chunks/{chunk-OLI35PTE.js.map → chunk-H56PLZHW.js.map} +0 -0
  369. /package/dist/chunks/{chunk-2E3ALKOF.js.map → chunk-HHLWXGOG.js.map} +0 -0
  370. /package/dist/chunks/{chunk-P52PAWBP.js.map → chunk-HXPRWMLH.js.map} +0 -0
  371. /package/dist/chunks/{chunk-FA2ZVSEU.js.map → chunk-IPTWZUSV.js.map} +0 -0
  372. /package/dist/chunks/{chunk-LLR7GHVU.js.map → chunk-ITY5SBAS.js.map} +0 -0
  373. /package/dist/chunks/{chunk-22PMPEFX.js.map → chunk-K52DES57.js.map} +0 -0
  374. /package/dist/chunks/{chunk-BK5AJ7TL.js.map → chunk-KJ7Q3BC3.js.map} +0 -0
  375. /package/dist/chunks/{chunk-MV2T5HFQ.js.map → chunk-KZHMLRKY.js.map} +0 -0
  376. /package/dist/chunks/{chunk-D3ITBQ7T.js.map → chunk-LGH2T6KL.js.map} +0 -0
  377. /package/dist/chunks/{chunk-3XIWMQLP.js.map → chunk-LQJ3TB5E.js.map} +0 -0
  378. /package/dist/chunks/{chunk-6GITBOHO.js.map → chunk-LYPEV765.js.map} +0 -0
  379. /package/dist/chunks/{chunk-O53H43CX.js.map → chunk-M44I7P3H.js.map} +0 -0
  380. /package/dist/chunks/{chunk-MOGE5ZMI.js.map → chunk-NAWIOVUH.js.map} +0 -0
  381. /package/dist/chunks/{chunk-ZNC5BEFK.js.map → chunk-NGE7TNCY.js.map} +0 -0
  382. /package/dist/chunks/{chunk-JABCT4RQ.js.map → chunk-OEKCCZ7I.js.map} +0 -0
  383. /package/dist/chunks/{chunk-DWFJETFP.js.map → chunk-OL5SKFPM.js.map} +0 -0
  384. /package/dist/chunks/{chunk-VLE4DKQR.js.map → chunk-P53E77KS.js.map} +0 -0
  385. /package/dist/chunks/{chunk-PV4TEEGI.js.map → chunk-PI6KC5CD.js.map} +0 -0
  386. /package/dist/chunks/{chunk-O62YM5KA.js.map → chunk-Q5DW33F4.js.map} +0 -0
  387. /package/dist/chunks/{chunk-V5DDXBVW.js.map → chunk-QS65X7D6.js.map} +0 -0
  388. /package/dist/chunks/{chunk-PKGMZRUT.js.map → chunk-SMX5YHRV.js.map} +0 -0
  389. /package/dist/chunks/{chunk-R6P5H47N.js.map → chunk-SQWFNFEX.js.map} +0 -0
  390. /package/dist/chunks/{chunk-RTDE5QSZ.js.map → chunk-SR75L2R5.js.map} +0 -0
  391. /package/dist/chunks/{chunk-FUVWMCRY.js.map → chunk-T5X3GYBF.js.map} +0 -0
  392. /package/dist/chunks/{chunk-YY6RFZ2L.js.map → chunk-TJSGSC2W.js.map} +0 -0
  393. /package/dist/chunks/{chunk-O7J6EFVD.js.map → chunk-TTXZK3BR.js.map} +0 -0
  394. /package/dist/chunks/{chunk-77RA2AU7.js.map → chunk-U7AQ4OQJ.js.map} +0 -0
  395. /package/dist/chunks/{chunk-635U2FDK.js.map → chunk-UPSI724V.js.map} +0 -0
  396. /package/dist/chunks/{chunk-56SPZGFT.js.map → chunk-V23HHK5D.js.map} +0 -0
  397. /package/dist/chunks/{chunk-C5P7OAML.js.map → chunk-VQHVH7X2.js.map} +0 -0
  398. /package/dist/chunks/{chunk-HARFWJBQ.js.map → chunk-WJ4YRFPQ.js.map} +0 -0
  399. /package/dist/chunks/{chunk-DFFTGAS7.js.map → chunk-WJXVNXJZ.js.map} +0 -0
  400. /package/dist/chunks/{chunk-PR2EE4G4.js.map → chunk-WOX4KI7C.js.map} +0 -0
  401. /package/dist/chunks/{chunk-ONVXBWB5.js.map → chunk-XFMGW2C5.js.map} +0 -0
  402. /package/dist/chunks/{chunk-RTFC2VXR.js.map → chunk-XPCRLKFO.js.map} +0 -0
  403. /package/dist/chunks/{chunk-MEZUNP2E.js.map → chunk-XYT53O3Z.js.map} +0 -0
  404. /package/dist/chunks/{chunk-EB7AS2K4.js.map → chunk-YSV633T5.js.map} +0 -0
  405. /package/dist/chunks/{chunk-PN2UBL2H.js.map → chunk-ZXFEHB7N.js.map} +0 -0
  406. /package/dist/chunks/{commands-Y37MKMRJ.js.map → commands-IOHIM2PX.js.map} +0 -0
  407. /package/dist/chunks/{computer-UE2AN7NW.js.map → computer-ZWTWBY67.js.map} +0 -0
  408. /package/dist/chunks/{crash-report-S6W5DXCO.js.map → crash-report-WLLGI2U4.js.map} +0 -0
  409. /package/dist/chunks/{dist-DODOSCTW.js.map → day-CU5J7UAK.js.map} +0 -0
  410. /package/dist/chunks/{dist-YO357DAD.js.map → dist-33QU2MGT.js.map} +0 -0
  411. /package/dist/chunks/{dist-5E47CZZT.js.map → dist-6G55RC27.js.map} +0 -0
  412. /package/dist/chunks/{dist-HCI4L6AO.js.map → dist-CFPNJCLJ.js.map} +0 -0
  413. /package/dist/chunks/{dist-3FVIUYVA.js.map → dist-E2PF4PGO.js.map} +0 -0
  414. /package/dist/chunks/{dist-4ATGJMUC.js.map → dist-FZYKXUR4.js.map} +0 -0
  415. /package/dist/chunks/{dist-2RVY7QOH.js.map → dist-IXAUMLZH.js.map} +0 -0
  416. /package/dist/chunks/{doctor-EZEJEK6B.js.map → dist-MBVPANQB.js.map} +0 -0
  417. /package/dist/chunks/{dist-IPQPISKD.js.map → dist-PKKDBDSA.js.map} +0 -0
  418. /package/dist/chunks/{home-UVU2HRDB.js.map → doctor-BXRPVVKL.js.map} +0 -0
  419. /package/dist/chunks/{drain-VVEMLN3L.js.map → drain-EWKGL77B.js.map} +0 -0
  420. /package/dist/chunks/{entry-CZ63UJYN.js.map → entry-XPXHELKT.js.map} +0 -0
  421. /package/dist/chunks/{github-VCUDZDGI.js.map → github-FQAXV2KP.js.map} +0 -0
  422. /package/dist/chunks/{host-Q3YNLTNL.js.map → home-T4ZVXIEX.js.map} +0 -0
  423. /package/dist/chunks/{lifecycle-24A5HH4I.js.map → host-LQ6V4NJS.js.map} +0 -0
  424. /package/dist/chunks/{host-queries-Z4BSL457.js.map → host-queries-LEPTBKZK.js.map} +0 -0
  425. /package/dist/chunks/{learn-SAZ3JOK3.js.map → learn-WOZKPYR4.js.map} +0 -0
  426. /package/dist/chunks/{learn-builtin-SQ2BTDFH.js.map → learn-builtin-BVJFZF4R.js.map} +0 -0
  427. /package/dist/chunks/{live-EIQ666TU.js.map → lifecycle-KKIDSRJV.js.map} +0 -0
  428. /package/dist/chunks/{login-YJ6L7KSY.js.map → live-4GQNVGPU.js.map} +0 -0
  429. /package/dist/chunks/{open-LEAR5UBX.js.map → login-MBXPJW6F.js.map} +0 -0
  430. /package/dist/chunks/{logs-RWGXFRMN.js.map → logs-7GVMBYAQ.js.map} +0 -0
  431. /package/dist/chunks/{mcp-DO454555.js.map → mcp-45UUEZMF.js.map} +0 -0
  432. /package/dist/chunks/{output-schema-YDKTNTMM.js.map → open-UG6VAHDW.js.map} +0 -0
  433. /package/dist/chunks/{operator-tools-AHP32F2J.js.map → operator-tools-M4SMIAYS.js.map} +0 -0
  434. /package/dist/chunks/{peers-NLUBD4IW.js.map → output-schema-MZ6X4WQ2.js.map} +0 -0
  435. /package/dist/chunks/{pal-XPZD6PAO.js.map → pal-R4RSZP2U.js.map} +0 -0
  436. /package/dist/chunks/{peers-MRKWY3MG.js.map → peers-6TIMGPGR.js.map} +0 -0
  437. /package/dist/chunks/{providers-QPESWN6K.js.map → peers-T5SXNFYU.js.map} +0 -0
  438. /package/dist/chunks/{pty-BDOOEOCB.js.map → providers-CPHEQZCV.js.map} +0 -0
  439. /package/dist/chunks/{resume-ZS3VS5OQ.js.map → pty-YAFV4ZA6.js.map} +0 -0
  440. /package/dist/chunks/{resume-command-KIXKOEM3.js.map → render-QFCCPEEL.js.map} +0 -0
  441. /package/dist/chunks/{start-check-7WYNSBON.js.map → resume-GZGHY4UR.js.map} +0 -0
  442. /package/dist/chunks/{store-ASWK7TVD.js.map → resume-command-WJH7SKYB.js.map} +0 -0
  443. /package/dist/chunks/{skills-MG2BRTPV.js.map → skills-RIJBOCKN.js.map} +0 -0
  444. /package/dist/chunks/{store-OKK7A6ZE.js.map → start-check-5DQL76YU.js.map} +0 -0
  445. /package/dist/chunks/{startup-failure-EWWYKPVE.js.map → startup-failure-7KMOAOXE.js.map} +0 -0
  446. /package/dist/chunks/{state-6UVY4EHA.js.map → state-QNSG3QWY.js.map} +0 -0
  447. /package/dist/chunks/{store-UFUDXZG6.js.map → store-7NXFZTW7.js.map} +0 -0
  448. /package/dist/chunks/{store-XU4PITDA.js.map → store-IDSNTJRG.js.map} +0 -0
  449. /package/dist/chunks/{upgrade-IJFMAW3T.js.map → upgrade-UZTPAIDF.js.map} +0 -0
  450. /package/dist/chunks/{workspaces-KVFY66IC.js.map → workspaces-KLYC5537.js.map} +0 -0
  451. /package/dist/chunks/{worktree-7JTMEYRX.js.map → worktree-4PKAJ7LT.js.map} +0 -0
@@ -0,0 +1,755 @@
1
+ import { createRequire as __namzuCreateRequire } from 'node:module';
2
+ const require = __namzuCreateRequire(import.meta.url);
3
+ import {
4
+ renderSpend
5
+ } from "./chunk-LYUY2FK2.js";
6
+ import {
7
+ DEFAULT_SPEND_DAYS,
8
+ MAX_SPEND_DAYS,
9
+ SLOT_MS,
10
+ createDayKeyer,
11
+ shiftDay,
12
+ slotOf,
13
+ systemClock
14
+ } from "./chunk-G4N43E6M.js";
15
+ import "./chunk-I4GTRFPK.js";
16
+ import {
17
+ createFormatter
18
+ } from "./chunk-KONYGNG6.js";
19
+ import "./chunk-U5UV2YRE.js";
20
+ import {
21
+ EXIT_FAIL,
22
+ EXIT_OK,
23
+ EXIT_USAGE
24
+ } from "./chunk-FTMONTUX.js";
25
+ import "./chunk-NGE7TNCY.js";
26
+ import {
27
+ VENDOR_RATES,
28
+ resolveModelPricing,
29
+ resolveNamzuHome
30
+ } from "./chunk-HQ4WFN7B.js";
31
+ import {
32
+ __name
33
+ } from "./chunk-76FLAFCG.js";
34
+
35
+ // src/integrations/spend/ledger.ts
36
+ import { randomUUID } from "node:crypto";
37
+ import { open, readFile, readdir, rename, rm, stat, writeFile } from "node:fs/promises";
38
+ import { join } from "node:path";
39
+
40
+ // src/integrations/spend/fold.ts
41
+ var KIND_REPLY = 0;
42
+ var KIND_COMPACTION = 1;
43
+ var KIND_INTERNAL = 2;
44
+ var ZERO = {
45
+ prompt: 0,
46
+ completion: 0,
47
+ total: 0,
48
+ cacheRead: 0,
49
+ cacheWrite: 0,
50
+ cost: 0,
51
+ unpriced: 0
52
+ };
53
+ var ModelTable = class {
54
+ static {
55
+ __name(this, "ModelTable");
56
+ }
57
+ list = [];
58
+ #index = /* @__PURE__ */ new Map();
59
+ constructor(initial = []) {
60
+ for (const key of initial) this.indexOf(key);
61
+ }
62
+ indexOf(key) {
63
+ const id = `${key.provider ?? ""}\0${key.model}`;
64
+ const hit = this.#index.get(id);
65
+ if (hit !== void 0) return hit;
66
+ this.list.push(key);
67
+ this.#index.set(id, this.list.length - 1);
68
+ return this.list.length - 1;
69
+ }
70
+ };
71
+ var INTERESTING = /"type":"(?:session_started|turn_started|request_envelope|provider_fallback|token_usage_updated|turn_completed|turn_failed)"/;
72
+ var num = /* @__PURE__ */ __name((value) => typeof value === "number" && Number.isFinite(value) ? value : 0, "num");
73
+ function cumulativeOf(usage, cost) {
74
+ const u = usage ?? {};
75
+ const c = cost ?? {};
76
+ return {
77
+ prompt: num(u.promptTokens),
78
+ completion: num(u.completionTokens),
79
+ total: num(u.totalTokens),
80
+ cacheRead: num(u.cachedTokens),
81
+ cacheWrite: num(u.cacheWriteTokens),
82
+ cost: num(c.totalCost),
83
+ unpriced: num(c.unpricedTokens)
84
+ };
85
+ }
86
+ __name(cumulativeOf, "cumulativeOf");
87
+ function minus(a, b) {
88
+ return {
89
+ prompt: a.prompt - b.prompt,
90
+ completion: a.completion - b.completion,
91
+ total: a.total - b.total,
92
+ cacheRead: a.cacheRead - b.cacheRead,
93
+ cacheWrite: a.cacheWrite - b.cacheWrite,
94
+ cost: a.cost - b.cost,
95
+ unpriced: a.unpriced - b.unpriced
96
+ };
97
+ }
98
+ __name(minus, "minus");
99
+ function isZero(d) {
100
+ return d.prompt === 0 && d.completion === 0 && d.total === 0 && d.cacheRead === 0 && d.cacheWrite === 0 && d.cost === 0 && d.unpriced === 0;
101
+ }
102
+ __name(isZero, "isZero");
103
+ function freshShare(delta, provider) {
104
+ if (delta.cacheRead === 0) return { fresh: delta.prompt, unknown: 0 };
105
+ const card = provider === null ? void 0 : resolveModelPricing(provider, delta.model);
106
+ if (card?.cache === void 0) return { fresh: 0, unknown: delta.prompt };
107
+ return {
108
+ fresh: card.cache.promptIncludesCacheReads ? Math.max(0, delta.prompt - delta.cacheRead) : delta.prompt,
109
+ unknown: 0
110
+ };
111
+ }
112
+ __name(freshShare, "freshShare");
113
+ var RowSink = class {
114
+ constructor(models) {
115
+ this.models = models;
116
+ }
117
+ models;
118
+ static {
119
+ __name(this, "RowSink");
120
+ }
121
+ #rows = /* @__PURE__ */ new Map();
122
+ add(delta, provider) {
123
+ const share = freshShare(delta, provider);
124
+ const model = this.models.indexOf({ provider, model: delta.model });
125
+ const key = `${delta.slot}:${delta.kind}:${model}`;
126
+ let row = this.#rows.get(key);
127
+ if (row === void 0) {
128
+ row = [delta.slot, delta.kind, model, 0, 0, 0, 0, 0, 0, 0, 0];
129
+ this.#rows.set(key, row);
130
+ }
131
+ row[3] = row[3] + delta.total;
132
+ row[4] = row[4] + share.fresh;
133
+ row[5] = row[5] + share.unknown;
134
+ row[6] = row[6] + delta.cacheRead;
135
+ row[7] = row[7] + delta.cacheWrite;
136
+ row[8] = row[8] + delta.completion;
137
+ row[9] = row[9] + delta.cost;
138
+ row[10] = row[10] + delta.unpriced;
139
+ }
140
+ rows() {
141
+ return [...this.#rows.values()];
142
+ }
143
+ };
144
+ function parseTs(value) {
145
+ if (typeof value !== "string") return void 0;
146
+ const ms = Date.parse(value);
147
+ return Number.isFinite(ms) ? ms : void 0;
148
+ }
149
+ __name(parseTs, "parseTs");
150
+ var LogFolder = class {
151
+ constructor(models, baseOffset) {
152
+ this.models = models;
153
+ this.#settledSink = new RowSink(models);
154
+ this.#openSink = new RowSink(models);
155
+ this.#tailOffset = baseOffset;
156
+ }
157
+ models;
158
+ static {
159
+ __name(this, "LogFolder");
160
+ }
161
+ #settledSink;
162
+ #openSink;
163
+ #facts = {};
164
+ #turn;
165
+ /** Bytes of a line that has not ended yet, and where it starts. */
166
+ #tail = Buffer.alloc(0);
167
+ #tailOffset;
168
+ feed(chunk) {
169
+ const buffer = this.#tail.length === 0 ? chunk : Buffer.concat([this.#tail, chunk]);
170
+ let position = 0;
171
+ while (position < buffer.length) {
172
+ const newline = buffer.indexOf(10, position);
173
+ if (newline === -1) break;
174
+ this.#line(buffer.toString("utf8", position, newline), this.#tailOffset + position);
175
+ position = newline + 1;
176
+ }
177
+ this.#tail = Buffer.from(buffer.subarray(position));
178
+ this.#tailOffset += position;
179
+ }
180
+ #settle(settlement, ts) {
181
+ const current = this.#turn;
182
+ if (current === void 0) return;
183
+ this.#turn = void 0;
184
+ let end;
185
+ if (settlement !== void 0) {
186
+ end = cumulativeOf(settlement.usage, settlement.cost);
187
+ const tail = minus(end, current.previous);
188
+ if (!isZero(tail)) {
189
+ current.deltas.push({
190
+ ...tail,
191
+ slot: slotOf(current.lastTs > ts ? current.lastTs : ts),
192
+ // A turn with no snapshot at all is known only by its settlement,
193
+ // and its calls were the replies; "internal" is what the settlement
194
+ // holds beyond the snapshots the turn did write.
195
+ kind: current.deltas.length === 0 ? KIND_REPLY : KIND_INTERNAL,
196
+ model: current.model,
197
+ provider: current.provider
198
+ });
199
+ }
200
+ }
201
+ const served = typeof settlement?.servingProvider === "string" ? settlement.servingProvider : void 0;
202
+ for (const delta of current.deltas) {
203
+ const provider = delta.provider ?? (current.fellBack ? current.earlyProvider : served) ?? null;
204
+ this.#settledSink.add(delta, provider);
205
+ }
206
+ }
207
+ #line(line, lineStart) {
208
+ if (!INTERESTING.test(line)) return;
209
+ let record;
210
+ try {
211
+ record = JSON.parse(line);
212
+ } catch {
213
+ return;
214
+ }
215
+ const ts = parseTs(record.ts);
216
+ switch (record.type) {
217
+ case "session_started": {
218
+ const parent = record.parent;
219
+ if (parent !== void 0 && typeof parent.kind === "string")
220
+ this.#facts.parentKind = parent.kind;
221
+ else if (parent !== void 0) this.#facts.parentKind = "agent_spawn";
222
+ if (typeof record.cwd === "string") this.#facts.cwd = record.cwd;
223
+ const harness = record.harness;
224
+ if (harness !== void 0 && typeof harness.engineId === "string") {
225
+ this.#facts.engineId = harness.engineId;
226
+ }
227
+ break;
228
+ }
229
+ case "turn_started": {
230
+ const config = record.config;
231
+ this.#turn = {
232
+ startOffset: lineStart,
233
+ deltas: [],
234
+ previous: ZERO,
235
+ model: typeof config?.model === "string" ? config.model : "unknown",
236
+ provider: void 0,
237
+ earlyProvider: void 0,
238
+ fellBack: false,
239
+ lastTs: ts ?? 0
240
+ };
241
+ break;
242
+ }
243
+ case "request_envelope": {
244
+ if (this.#turn !== void 0 && typeof record.model === "string")
245
+ this.#turn.model = record.model;
246
+ break;
247
+ }
248
+ case "provider_fallback": {
249
+ const turn = this.#turn;
250
+ if (turn === void 0) break;
251
+ if (!turn.fellBack) {
252
+ turn.fellBack = true;
253
+ turn.earlyProvider = typeof record.fromProviderId === "string" ? record.fromProviderId : void 0;
254
+ }
255
+ if (typeof record.toProviderId === "string") turn.provider = record.toProviderId;
256
+ if (typeof record.toModel === "string") turn.model = record.toModel;
257
+ break;
258
+ }
259
+ case "token_usage_updated": {
260
+ const turn = this.#turn;
261
+ if (turn === void 0 || ts === void 0) break;
262
+ const now = cumulativeOf(record.usage, record.cost);
263
+ const step = minus(now, turn.previous);
264
+ turn.previous = now;
265
+ turn.lastTs = ts;
266
+ if (isZero(step)) break;
267
+ turn.deltas.push({
268
+ ...step,
269
+ slot: slotOf(ts),
270
+ kind: record.contextMeasuredBy === "estimate" ? KIND_COMPACTION : KIND_REPLY,
271
+ model: turn.model,
272
+ provider: turn.provider
273
+ });
274
+ break;
275
+ }
276
+ case "turn_completed":
277
+ case "turn_failed": {
278
+ const settlement = record.settlement;
279
+ this.#settle(settlement, ts ?? this.#turn?.lastTs ?? 0);
280
+ break;
281
+ }
282
+ }
283
+ }
284
+ finish() {
285
+ let from = this.#tailOffset;
286
+ const turn = this.#turn;
287
+ if (turn !== void 0) {
288
+ from = turn.startOffset;
289
+ const served = turn.fellBack ? turn.earlyProvider : void 0;
290
+ for (const delta of turn.deltas) this.#openSink.add(delta, delta.provider ?? served ?? null);
291
+ }
292
+ return {
293
+ settled: this.#settledSink.rows(),
294
+ open: this.#openSink.rows(),
295
+ from,
296
+ facts: this.#facts
297
+ };
298
+ }
299
+ };
300
+
301
+ // src/integrations/spend/ledger.ts
302
+ var SPEND_LEDGER_VERSION = 3;
303
+ var SPEND_LEDGER_FILE = "spend-ledger.json";
304
+ var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
305
+ async function listDir(dir) {
306
+ try {
307
+ return await readdir(dir, { withFileTypes: true });
308
+ } catch {
309
+ return [];
310
+ }
311
+ }
312
+ __name(listDir, "listDir");
313
+ async function discoverProject(home, slug) {
314
+ const out = [];
315
+ const walk = /* @__PURE__ */ __name(async (dir, rel, nested) => {
316
+ const entries = await listDir(dir);
317
+ const dirs = [];
318
+ for (const entry of entries) {
319
+ if (entry.isFile() && entry.name.endsWith(".jsonl")) {
320
+ const id = entry.name.slice(0, -".jsonl".length);
321
+ if (UUID.test(id) || nested) out.push(`${rel}/${entry.name}`);
322
+ } else if (entry.isDirectory() && UUID.test(entry.name)) {
323
+ dirs.push(entry.name);
324
+ }
325
+ }
326
+ await mapLimit(dirs, 32, async (name) => {
327
+ await walk(join(dir, name, "subagents"), `${rel}/${name}/subagents`, true);
328
+ });
329
+ }, "walk");
330
+ await walk(join(home, "projects", slug), `projects/${slug}`, false);
331
+ return out;
332
+ }
333
+ __name(discoverProject, "discoverProject");
334
+ async function mapLimit(items, limit, run) {
335
+ let next = 0;
336
+ const workers = Array.from({ length: Math.min(limit, items.length) }, async () => {
337
+ while (next < items.length) {
338
+ const item = items[next++];
339
+ await run(item);
340
+ }
341
+ });
342
+ await Promise.all(workers);
343
+ }
344
+ __name(mapLimit, "mapLimit");
345
+ async function discoverLogs(home) {
346
+ const slugs = (await listDir(join(home, "projects"))).filter((e) => e.isDirectory());
347
+ const all = [];
348
+ await mapLimit(slugs, 8, async (slug) => {
349
+ all.push(...await discoverProject(home, slug.name));
350
+ });
351
+ return all.sort();
352
+ }
353
+ __name(discoverLogs, "discoverLogs");
354
+ async function loadLedger(home) {
355
+ let parsed;
356
+ try {
357
+ parsed = JSON.parse(await readFile(join(home, SPEND_LEDGER_FILE), "utf8"));
358
+ } catch {
359
+ return void 0;
360
+ }
361
+ if (parsed === null || typeof parsed !== "object" || parsed.version !== SPEND_LEDGER_VERSION || !Array.isArray(parsed.models) || typeof parsed.sessions !== "object" || parsed.sessions === null) {
362
+ return void 0;
363
+ }
364
+ const sessions = /* @__PURE__ */ new Map();
365
+ for (const [key, entry] of Object.entries(parsed.sessions)) {
366
+ if (!isLedgerSession(entry)) return void 0;
367
+ sessions.set(key, entry);
368
+ }
369
+ if (!parsed.models.every(
370
+ (m) => m !== null && typeof m === "object" && typeof m.model === "string"
371
+ )) {
372
+ return void 0;
373
+ }
374
+ return {
375
+ models: new ModelTable(parsed.models),
376
+ projects: new Map(Object.entries(parsed.projects ?? {})),
377
+ sessions
378
+ };
379
+ }
380
+ __name(loadLedger, "loadLedger");
381
+ var isRow = /* @__PURE__ */ __name((row) => Array.isArray(row) && row.length === 11 && row.every((n) => typeof n === "number" && Number.isFinite(n)), "isRow");
382
+ function isLedgerSession(entry) {
383
+ if (entry === null || typeof entry !== "object") return false;
384
+ const e = entry;
385
+ return typeof e.slug === "string" && typeof e.size === "number" && typeof e.mtimeMs === "number" && typeof e.from === "number" && Array.isArray(e.rows) && e.rows.every(isRow) && Array.isArray(e.open) && e.open.every(isRow);
386
+ }
387
+ __name(isLedgerSession, "isLedgerSession");
388
+ async function saveLedger(home, ledger) {
389
+ const file = {
390
+ version: SPEND_LEDGER_VERSION,
391
+ models: ledger.models.list,
392
+ projects: Object.fromEntries(ledger.projects),
393
+ sessions: Object.fromEntries(ledger.sessions)
394
+ };
395
+ const target = join(home, SPEND_LEDGER_FILE);
396
+ const temp = `${target}.${process.pid}.${randomUUID()}.tmp`;
397
+ try {
398
+ await writeFile(temp, JSON.stringify(file), { mode: 384 });
399
+ await rename(temp, target);
400
+ } catch (cause) {
401
+ await rm(temp, { force: true });
402
+ throw cause;
403
+ }
404
+ }
405
+ __name(saveLedger, "saveLedger");
406
+ var READ_CHUNK_BYTES = 1024 * 1024;
407
+ async function streamRange(path, from, to, folder, chunkBytes) {
408
+ const handle = await open(path, "r");
409
+ try {
410
+ const buffer = Buffer.allocUnsafe(Math.min(chunkBytes, Math.max(0, to - from)));
411
+ let position = from;
412
+ while (position < to) {
413
+ const { bytesRead } = await handle.read(
414
+ buffer,
415
+ 0,
416
+ Math.min(buffer.length, to - position),
417
+ position
418
+ );
419
+ if (bytesRead === 0) break;
420
+ folder.feed(buffer.subarray(0, bytesRead));
421
+ position += bytesRead;
422
+ }
423
+ return position - from;
424
+ } finally {
425
+ await handle.close();
426
+ }
427
+ }
428
+ __name(streamRange, "streamRange");
429
+ async function refreshLedger(options) {
430
+ const home = options.home;
431
+ const chunkBytes = Math.max(1, options.chunkBytes ?? READ_CHUNK_BYTES);
432
+ const loaded = await loadLedger(home);
433
+ const ledger = loaded ?? {
434
+ models: new ModelTable(),
435
+ projects: /* @__PURE__ */ new Map(),
436
+ sessions: /* @__PURE__ */ new Map()
437
+ };
438
+ const rebuilt = loaded === void 0;
439
+ const logs = await discoverLogs(home);
440
+ const present = new Set(logs);
441
+ let changed = rebuilt;
442
+ let read = 0;
443
+ let bytesRead = 0;
444
+ for (const key of [...ledger.sessions.keys()]) {
445
+ if (!present.has(key)) {
446
+ ledger.sessions.delete(key);
447
+ changed = true;
448
+ }
449
+ }
450
+ await mapLimit(logs, 32, async (key) => {
451
+ const path = join(home, key);
452
+ let info;
453
+ try {
454
+ info = await stat(path);
455
+ } catch {
456
+ return;
457
+ }
458
+ const slug = key.split("/")[1];
459
+ let entry = ledger.sessions.get(key);
460
+ if (entry !== void 0 && entry.size === info.size && entry.mtimeMs === info.mtimeMs) return;
461
+ if (entry === void 0 || info.size < entry.size) {
462
+ entry = { slug, size: 0, mtimeMs: 0, from: 0, rows: [], open: [] };
463
+ }
464
+ let result;
465
+ let size = 0;
466
+ try {
467
+ const folder = new LogFolder(ledger.models, entry.from);
468
+ size = await streamRange(path, entry.from, info.size, folder, chunkBytes);
469
+ result = folder.finish();
470
+ } catch {
471
+ return;
472
+ }
473
+ read += 1;
474
+ bytesRead += size;
475
+ const next = {
476
+ slug,
477
+ size: info.size,
478
+ mtimeMs: info.mtimeMs,
479
+ from: result.from,
480
+ rows: result.settled.length > 0 ? [...entry.rows, ...result.settled] : entry.rows,
481
+ open: result.open,
482
+ ...(result.facts.parentKind ?? entry.parentKind) !== void 0 ? { parentKind: result.facts.parentKind ?? entry.parentKind } : {},
483
+ ...(result.facts.engineId ?? entry.engineId) !== void 0 ? { engineId: result.facts.engineId ?? entry.engineId } : {}
484
+ };
485
+ ledger.sessions.set(key, next);
486
+ if (result.facts.cwd !== void 0 && !ledger.projects.has(slug)) {
487
+ ledger.projects.set(slug, result.facts.cwd);
488
+ }
489
+ changed = true;
490
+ });
491
+ let wrote = false;
492
+ if (changed && options.readOnly !== true) {
493
+ try {
494
+ await saveLedger(home, ledger);
495
+ wrote = true;
496
+ } catch {
497
+ }
498
+ }
499
+ return { ledger, stats: { logs: logs.length, read, bytesRead, wrote, rebuilt } };
500
+ }
501
+ __name(refreshLedger, "refreshLedger");
502
+
503
+ // src/integrations/spend/report.ts
504
+ var SPEND_REPORT_SCHEMA_VERSION = 1;
505
+ var TOP_CONVERSATIONS = 10;
506
+ var emptyTotals = /* @__PURE__ */ __name(() => ({
507
+ tokens: 0,
508
+ freshInputTokens: 0,
509
+ unsplitInputTokens: 0,
510
+ cacheReadTokens: 0,
511
+ cacheWriteTokens: 0,
512
+ outputTokens: 0,
513
+ estimatedCostUsd: 0,
514
+ unpricedTokens: 0
515
+ }), "emptyTotals");
516
+ function addRow(into, row) {
517
+ into.tokens += row[3];
518
+ into.freshInputTokens += row[4];
519
+ into.unsplitInputTokens += row[5];
520
+ into.cacheReadTokens += row[6];
521
+ into.cacheWriteTokens += row[7];
522
+ into.outputTokens += row[8];
523
+ into.estimatedCostUsd += row[9];
524
+ into.unpricedTokens += row[10];
525
+ }
526
+ __name(addRow, "addRow");
527
+ var UNMETERED = new Set(VENDOR_RATES.filter((v) => v.unmetered).map((v) => v.providerId));
528
+ function billingOf(provider) {
529
+ return provider !== null && UNMETERED.has(provider) ? "local" : "per-token";
530
+ }
531
+ __name(billingOf, "billingOf");
532
+ function conversationId(key) {
533
+ const name = key.slice(key.lastIndexOf("/") + 1);
534
+ return name.endsWith(".jsonl") ? name.slice(0, -".jsonl".length) : name;
535
+ }
536
+ __name(conversationId, "conversationId");
537
+ function rowsOf(session) {
538
+ return session.open.length === 0 ? session.rows : [...session.rows, ...session.open];
539
+ }
540
+ __name(rowsOf, "rowsOf");
541
+ function kindOf(session, row) {
542
+ if (session.parentKind !== void 0) return "subagents";
543
+ return row[1] === 1 ? "compaction" : row[1] === 2 ? "internal" : "replies";
544
+ }
545
+ __name(kindOf, "kindOf");
546
+ function slot(map, key) {
547
+ let totals = map.get(key);
548
+ if (totals === void 0) {
549
+ totals = emptyTotals();
550
+ map.set(key, totals);
551
+ }
552
+ return totals;
553
+ }
554
+ __name(slot, "slot");
555
+ function buildSpendReport(query) {
556
+ const days = Math.max(1, Math.min(MAX_SPEND_DAYS, Math.floor(query.days ?? DEFAULT_SPEND_DAYS)));
557
+ const { ledger, clock } = query;
558
+ const keyer = createDayKeyer(clock.timeZone);
559
+ const today = keyer(clock.nowMs());
560
+ const from = shiftDay(today, days - 1);
561
+ const total = emptyTotals();
562
+ const byDay = /* @__PURE__ */ new Map();
563
+ const byModel = /* @__PURE__ */ new Map();
564
+ const byProject = /* @__PURE__ */ new Map();
565
+ const byKind = /* @__PURE__ */ new Map();
566
+ const conversations = [];
567
+ const unpricedModelIds = /* @__PURE__ */ new Set();
568
+ let engineConversations = 0;
569
+ let unsplit = 0;
570
+ let ahead = 0;
571
+ for (const [key, session] of ledger.sessions) {
572
+ const mine = emptyTotals();
573
+ let touched = false;
574
+ for (const row of rowsOf(session)) {
575
+ const day = keyer(row[0] * SLOT_MS);
576
+ if (day < from) continue;
577
+ touched = true;
578
+ if (day > today) ahead += row[3];
579
+ addRow(total, row);
580
+ addRow(mine, row);
581
+ let dayEntry = byDay.get(day);
582
+ if (dayEntry === void 0) {
583
+ dayEntry = { totals: emptyTotals(), models: /* @__PURE__ */ new Map() };
584
+ byDay.set(day, dayEntry);
585
+ }
586
+ addRow(dayEntry.totals, row);
587
+ addRow(slot(dayEntry.models, row[2]), row);
588
+ addRow(slot(byModel, row[2]), row);
589
+ addRow(slot(byProject, session.slug), row);
590
+ addRow(slot(byKind, kindOf(session, row)), row);
591
+ if (row[10] > 0) unpricedModelIds.add(row[2]);
592
+ unsplit += row[5];
593
+ }
594
+ if (!touched) continue;
595
+ if (session.engineId !== void 0) engineConversations += 1;
596
+ conversations.push({
597
+ id: conversationId(key),
598
+ slug: session.slug,
599
+ subagent: session.parentKind ?? null,
600
+ ...mine
601
+ });
602
+ }
603
+ const modelRow = /* @__PURE__ */ __name((id, totals) => {
604
+ const key = ledger.models.list[id];
605
+ return {
606
+ provider: key.provider,
607
+ model: key.model,
608
+ billing: billingOf(key.provider),
609
+ priceKnown: totals.unpricedTokens === 0,
610
+ ...totals
611
+ };
612
+ }, "modelRow");
613
+ const byCostThenTokens = /* @__PURE__ */ __name((a, b, name) => b.estimatedCostUsd - a.estimatedCostUsd || b.tokens - a.tokens || (name(a) < name(b) ? -1 : name(a) > name(b) ? 1 : 0), "byCostThenTokens");
614
+ const modelName = /* @__PURE__ */ __name((row) => `${row.provider ?? ""}\0${row.model}`, "modelName");
615
+ const dayRows = [...byDay.entries()].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([date, entry]) => ({
616
+ date,
617
+ ...entry.totals,
618
+ models: [...entry.models.entries()].map(([id, totals]) => modelRow(id, totals)).sort((a, b) => byCostThenTokens(a, b, modelName))
619
+ }));
620
+ const models = [...byModel.entries()].map(([id, totals]) => modelRow(id, totals)).sort((a, b) => byCostThenTokens(a, b, modelName));
621
+ const projects = [...byProject.entries()].map(([slug, totals]) => ({ slug, path: ledger.projects.get(slug) ?? null, ...totals })).sort((a, b) => byCostThenTokens(a, b, (row) => row.slug));
622
+ const kindOrder = ["replies", "subagents", "compaction", "internal"];
623
+ const kinds = kindOrder.filter((kind) => byKind.has(kind)).map((kind) => ({ kind, ...byKind.get(kind) }));
624
+ const unpricedModels = [...unpricedModelIds].map((id) => {
625
+ const key = ledger.models.list[id];
626
+ return key.provider === null ? key.model : `${key.model} (${key.provider})`;
627
+ });
628
+ const notes = [];
629
+ if (unsplit > 0) {
630
+ notes.push(
631
+ `${unsplit.toLocaleString("en-US")} input tokens ran on a route whose rate card is not in the catalogue, so the record cannot say how many of them were read from the cache. They are listed as unsplit input.`
632
+ );
633
+ }
634
+ if (ahead > 0) {
635
+ notes.push(
636
+ `${ahead.toLocaleString("en-US")} tokens are recorded on days after today by this machine's clock (a log written ahead of it). They are included.`
637
+ );
638
+ }
639
+ if (engineConversations > 0) {
640
+ notes.push(
641
+ `${engineConversations} conversation${engineConversations === 1 ? "" : "s"} ran through an outside engine. The record does not say how that engine bills, so its tokens count and its price is shown only where one is known.`
642
+ );
643
+ }
644
+ notes.push(
645
+ "The record marks compaction passes and the replies of sub-agents, so those are shown apart. It does not mark other internal calls: one made between two replies is counted with the next reply, and only what the turn settled beyond its last reply is shown as internal.",
646
+ "Which subscription or free quota paid for a call is not recorded, so none is claimed. A route is called local only when the catalogue says it bills nothing per token."
647
+ );
648
+ return {
649
+ schemaVersion: SPEND_REPORT_SCHEMA_VERSION,
650
+ kind: "spend",
651
+ estimate: true,
652
+ currency: "USD",
653
+ window: { days, from, to: today, timeZone: clock.timeZone },
654
+ totals: {
655
+ ...total,
656
+ partial: total.unpricedTokens > 0,
657
+ unpricedModels,
658
+ conversations: conversations.length
659
+ },
660
+ days: dayRows,
661
+ models,
662
+ projects,
663
+ kinds,
664
+ topConversations: conversations.sort((a, b) => byCostThenTokens(a, b, (row) => row.id)).slice(0, TOP_CONVERSATIONS),
665
+ notes
666
+ };
667
+ }
668
+ __name(buildSpendReport, "buildSpendReport");
669
+
670
+ // src/commands/cost.ts
671
+ var HELP = `namzu cost \u2014 spend across conversations on this machine, by day and model
672
+
673
+ Usage:
674
+ namzu cost [--days <n>] [--json]
675
+
676
+ Shows the last ${DEFAULT_SPEND_DAYS} local days by default: totals by day, model and project,
677
+ and by kind of work (your replies, sub-agents, compaction, other internal calls),
678
+ with cache reads and writes apart from fresh input.
679
+
680
+ Money is an estimate from list prices. A model with no known price shows its
681
+ tokens and "price not known", and the total then says it is partial.
682
+
683
+ --days <n> Days to cover, today included (1 to ${MAX_SPEND_DAYS}).
684
+ --json Print the report as JSON (schemaVersion 1) instead of text.
685
+
686
+ For the latest reply only, use /cost in the terminal.
687
+ `;
688
+ function parseCostArgs(args) {
689
+ let days = DEFAULT_SPEND_DAYS;
690
+ let json = false;
691
+ for (let i = 0; i < args.length; i += 1) {
692
+ const arg = args[i];
693
+ if (arg === "--json") {
694
+ json = true;
695
+ } else if (arg === "--days" || arg.startsWith("--days=")) {
696
+ let value;
697
+ if (arg === "--days") {
698
+ i += 1;
699
+ value = args[i];
700
+ } else {
701
+ value = arg.slice("--days=".length);
702
+ }
703
+ if (value === void 0 || !/^[1-9]\d{0,3}$/.test(value)) return void 0;
704
+ days = Number(value);
705
+ if (days > MAX_SPEND_DAYS) return void 0;
706
+ } else {
707
+ return void 0;
708
+ }
709
+ }
710
+ return { days, json };
711
+ }
712
+ __name(parseCostArgs, "parseCostArgs");
713
+ async function buildCostReport(days, deps) {
714
+ const { ledger } = await refreshLedger({ home: deps.home });
715
+ return buildSpendReport({ ledger, clock: deps.clock, days });
716
+ }
717
+ __name(buildCostReport, "buildCostReport");
718
+ var costCommand = {
719
+ name: "cost",
720
+ description: "Show spend across conversations by day and model, from the session logs",
721
+ passThrough: true,
722
+ help: HELP,
723
+ handler: /* @__PURE__ */ __name(async ({ ctx, rawArgs }) => {
724
+ const parsed = parseCostArgs(rawArgs);
725
+ if (parsed === void 0) {
726
+ ctx.formatter.error({ message: HELP });
727
+ return EXIT_USAGE;
728
+ }
729
+ try {
730
+ const report = await buildCostReport(parsed.days, {
731
+ home: resolveNamzuHome(),
732
+ clock: systemClock()
733
+ });
734
+ if (parsed.json) {
735
+ createFormatter("json", { quiet: false }).print(report);
736
+ } else if (ctx.formatter.name === "text") {
737
+ ctx.formatter.print({ text: renderSpend(report) });
738
+ } else {
739
+ ctx.formatter.print(report);
740
+ }
741
+ return EXIT_OK;
742
+ } catch (cause) {
743
+ ctx.formatter.error({
744
+ message: `Could not read the spend: ${cause instanceof Error ? cause.message : String(cause)}`
745
+ });
746
+ return EXIT_FAIL;
747
+ }
748
+ }, "handler")
749
+ };
750
+ export {
751
+ buildCostReport,
752
+ costCommand,
753
+ parseCostArgs
754
+ };
755
+ //# sourceMappingURL=cost-MYSYQTT3.js.map