@namzu/cli 51.1.0 → 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.
- package/CHANGELOG.md +16 -0
- package/dist/bin.js +1 -1
- package/dist/chunks/{acp-YH3ORAMX.js → acp-HCVLUS7I.js} +106 -71
- package/dist/chunks/acp-HCVLUS7I.js.map +6 -0
- package/dist/chunks/{activity-command-6SLWX5O6.js → activity-command-I3OMRZ2T.js} +12 -12
- package/dist/chunks/{add-5DU7SP37.js → add-A65AU46H.js} +23 -23
- package/dist/chunks/{agent-IN76G7FR.js → agent-3A66KRCM.js} +39 -37
- package/dist/chunks/agent-session-LJZO5VIZ.js +71 -0
- package/dist/chunks/{archive-X5OO3HYU.js → archive-IWWDLSAO.js} +10 -10
- package/dist/chunks/{bin-main-MJURSFNJ.js → bin-main-CRX2U7A6.js} +8 -8
- package/dist/chunks/{binding-6EX5H32J.js → binding-4AMPOED7.js} +3 -3
- package/dist/chunks/{browser-UUSAOFML.js → browser-SAS7YPVD.js} +6 -6
- package/dist/chunks/{chat-J2DRST74.js → chat-ANHTX7D5.js} +15 -15
- package/dist/chunks/{chunk-BNIO5NNW.js → chunk-2HB47MDS.js} +57 -39
- package/dist/chunks/chunk-2HB47MDS.js.map +6 -0
- package/dist/chunks/{chunk-4MDH3G7P.js → chunk-3D52GNVJ.js} +4 -4
- package/dist/chunks/{chunk-DQGDG63U.js → chunk-3MJ3YKNV.js} +5 -5
- package/dist/chunks/chunk-3YM3IWPW.js +221 -0
- package/dist/chunks/chunk-3YM3IWPW.js.map +6 -0
- package/dist/chunks/{chunk-QN4WGK62.js → chunk-45Z4OPC6.js} +3 -3
- package/dist/chunks/{chunk-4GQ5ACCZ.js → chunk-52YXYXRG.js} +2 -2
- package/dist/chunks/{chunk-ASITCNWM.js → chunk-56ZS6OTK.js} +4 -4
- package/dist/chunks/{chunk-M3O7WEJF.js → chunk-57QGQNRI.js} +2 -2
- package/dist/chunks/{chunk-PYRMWOCP.js → chunk-5TPQGNYN.js} +4 -4
- package/dist/chunks/{chunk-N7COW4QY.js → chunk-5U42MB6F.js} +10 -10
- package/dist/chunks/{chunk-HSSTV5SF.js → chunk-5YMIK3VP.js} +3 -3
- package/dist/chunks/{chunk-YWKZQABS.js → chunk-6CKU4TCF.js} +2 -2
- package/dist/chunks/{chunk-KBLICB2N.js → chunk-6I4V7I5M.js} +2 -2
- package/dist/chunks/{chunk-VIJFICIC.js → chunk-6MI4Q5QQ.js} +4 -4
- package/dist/chunks/{chunk-76HAMOHW.js → chunk-6S4L4SAU.js} +6 -6
- package/dist/chunks/{chunk-CB7VORLS.js → chunk-AGC67H4M.js} +4 -4
- package/dist/chunks/{chunk-BZC5JPMB.js → chunk-ALXE3SUZ.js} +3 -3
- package/dist/chunks/{chunk-6J6AEQA4.js → chunk-ANVIYMV6.js} +3 -3
- package/dist/chunks/chunk-BBTPD3DU.js +19 -0
- package/dist/chunks/chunk-BBTPD3DU.js.map +6 -0
- package/dist/chunks/{chunk-S4HDKI6L.js → chunk-BC3IZXTY.js} +2 -2
- package/dist/chunks/{chunk-K4BMTUBH.js → chunk-BN32BPU6.js} +2 -2
- package/dist/chunks/chunk-BUP54TBX.js +214 -0
- package/dist/chunks/chunk-BUP54TBX.js.map +6 -0
- package/dist/chunks/{chunk-YUDCUW4N.js → chunk-CYCUJOAD.js} +3 -3
- package/dist/chunks/{chunk-ZJQYNG27.js → chunk-DLVHJFXI.js} +2 -2
- package/dist/chunks/{chunk-MJW6FQAW.js → chunk-DNOI4BL2.js} +2 -2
- package/dist/chunks/{chunk-FI5EMDFZ.js → chunk-DOPHHI6C.js} +3 -3
- package/dist/chunks/{chunk-NEKCM2HR.js → chunk-E5OETSRN.js} +6 -6
- package/dist/chunks/{chunk-HFLX3ZLT.js → chunk-E7IXVEOQ.js} +3 -3
- package/dist/chunks/{chunk-ZKOEUHCF.js → chunk-FKQOGEKL.js} +3 -3
- package/dist/chunks/{chunk-LNIM2TS3.js → chunk-FLPT7I7I.js} +4 -4
- package/dist/chunks/{chunk-DE4WWSBB.js → chunk-FMAUDMYL.js} +12 -12
- package/dist/chunks/{chunk-H32MIHLE.js → chunk-FSS72QJP.js} +2 -2
- package/dist/chunks/chunk-G4N43E6M.js +62 -0
- package/dist/chunks/chunk-G4N43E6M.js.map +6 -0
- package/dist/chunks/{chunk-VPIFXAL6.js → chunk-H56PLZHW.js} +2 -2
- package/dist/chunks/{chunk-2XXEIH7D.js → chunk-HHLWXGOG.js} +2 -2
- package/dist/chunks/{chunk-EK74R563.js → chunk-HQ4WFN7B.js} +732 -544
- package/dist/chunks/chunk-HQ4WFN7B.js.map +6 -0
- package/dist/chunks/{chunk-BGT2BABA.js → chunk-HXPRWMLH.js} +4 -4
- package/dist/chunks/{chunk-MPLS4I5N.js → chunk-ILPXZDTW.js} +116 -79
- package/dist/chunks/chunk-ILPXZDTW.js.map +6 -0
- package/dist/chunks/{chunk-UHYZ64ET.js → chunk-IPTWZUSV.js} +2 -2
- package/dist/chunks/{chunk-4DYB42HG.js → chunk-ITY5SBAS.js} +2 -2
- package/dist/chunks/{chunk-J4QN36GJ.js → chunk-JUN4VUC6.js} +64 -224
- package/dist/chunks/chunk-JUN4VUC6.js.map +6 -0
- package/dist/chunks/{chunk-ZYRABJ7J.js → chunk-K52DES57.js} +2 -2
- package/dist/chunks/chunk-KD6WL3W7.js +10 -0
- package/dist/chunks/chunk-KD6WL3W7.js.map +6 -0
- package/dist/chunks/{chunk-3KNUUOMF.js → chunk-KJ7Q3BC3.js} +2 -2
- package/dist/chunks/{chunk-AROJAFON.js → chunk-KJVRHBMX.js} +3 -3
- package/dist/chunks/{chunk-VDQQE3Q6.js → chunk-KZHMLRKY.js} +4 -4
- package/dist/chunks/{chunk-MFRWOJCD.js → chunk-LAXSPXNP.js} +4 -3
- package/dist/chunks/{chunk-MFRWOJCD.js.map → chunk-LAXSPXNP.js.map} +1 -1
- package/dist/chunks/{chunk-5HS5WIS3.js → chunk-LGH2T6KL.js} +2 -2
- package/dist/chunks/{chunk-2OGJPIGN.js → chunk-LQJ3TB5E.js} +14 -14
- package/dist/chunks/{chunk-TF6ZSM2M.js → chunk-LYPEV765.js} +2 -2
- package/dist/chunks/chunk-LYUY2FK2.js +141 -0
- package/dist/chunks/chunk-LYUY2FK2.js.map +6 -0
- package/dist/chunks/{chunk-YU65OZTC.js → chunk-M44I7P3H.js} +2 -2
- package/dist/chunks/{chunk-HAHNDC7N.js → chunk-NAWIOVUH.js} +3 -3
- package/dist/chunks/{chunk-WWC6L5WC.js → chunk-NGE7TNCY.js} +2 -2
- package/dist/chunks/{chunk-CSWUOY5K.js → chunk-NXJQTDVT.js} +17 -17
- package/dist/chunks/{chunk-QZDNCVK4.js → chunk-NY3I4WL7.js} +185 -363
- package/dist/chunks/chunk-NY3I4WL7.js.map +6 -0
- package/dist/chunks/{chunk-O6QJXKWZ.js → chunk-OEKCCZ7I.js} +5 -5
- package/dist/chunks/{chunk-3VKSD45U.js → chunk-OL5SKFPM.js} +4 -4
- package/dist/chunks/{chunk-MPUHBR73.js → chunk-OMP25UWR.js} +2 -2
- package/dist/chunks/{chunk-GTRG5VXA.js → chunk-P53E77KS.js} +3 -3
- package/dist/chunks/{chunk-P6CNFKJC.js → chunk-PI6KC5CD.js} +5 -5
- package/dist/chunks/{chunk-RZXNXGRE.js → chunk-Q5DW33F4.js} +2 -2
- package/dist/chunks/{chunk-RQKE2URW.js → chunk-QS65X7D6.js} +3 -3
- package/dist/chunks/{chunk-BIWDWFAK.js → chunk-QZ4V25KD.js} +3 -3
- package/dist/chunks/{chunk-JBQATPG3.js → chunk-RCLTSI6G.js} +2 -2
- package/dist/chunks/{chunk-ZRM2NW77.js → chunk-RDWVNVZS.js} +5 -5
- package/dist/chunks/{chunk-J267C5O6.js → chunk-SMX5YHRV.js} +2 -2
- package/dist/chunks/{chunk-YOCPU3WT.js → chunk-SQWFNFEX.js} +3 -3
- package/dist/chunks/{chunk-PR3HSIXG.js → chunk-SR75L2R5.js} +4 -4
- package/dist/chunks/{chunk-G2DGASUC.js → chunk-T5X3GYBF.js} +2 -2
- package/dist/chunks/{chunk-GN4BLP6C.js → chunk-TJSGSC2W.js} +9 -9
- package/dist/chunks/{chunk-B4M4IEOE.js → chunk-TTXZK3BR.js} +3 -3
- package/dist/chunks/{chunk-F2I6X667.js → chunk-U7AQ4OQJ.js} +4 -3
- package/dist/chunks/{chunk-VONTYDZ3.js → chunk-UPSI724V.js} +3 -3
- package/dist/chunks/{chunk-SRBCU3IJ.js → chunk-V23HHK5D.js} +2 -2
- package/dist/chunks/{chunk-R77WPUUF.js → chunk-VQHVH7X2.js} +3 -3
- package/dist/chunks/{chunk-FJZL4BJN.js → chunk-WJ4YRFPQ.js} +2 -2
- package/dist/chunks/{chunk-64CDTVEM.js → chunk-WJXVNXJZ.js} +12 -12
- package/dist/chunks/{chunk-DXFPBLQV.js → chunk-WOX4KI7C.js} +3 -3
- package/dist/chunks/{chunk-3MUNYBIF.js → chunk-X3L6N5RM.js} +11 -11
- package/dist/chunks/{chunk-JE2S7MW2.js → chunk-XFMGW2C5.js} +2 -2
- package/dist/chunks/{chunk-W5IR3SD3.js → chunk-XPCRLKFO.js} +6 -6
- package/dist/chunks/{chunk-XCDXSRY7.js → chunk-XYT53O3Z.js} +2 -2
- package/dist/chunks/{chunk-LJ4DIGHQ.js → chunk-YSV633T5.js} +9 -9
- package/dist/chunks/{chunk-LRLMZTZ3.js → chunk-ZXFEHB7N.js} +2 -2
- package/dist/chunks/{cli-runtime-YUFSSYYG.js → cli-runtime-5UE6P2QW.js} +19 -16
- package/dist/chunks/cli-runtime-5UE6P2QW.js.map +6 -0
- package/dist/chunks/{commands-J7XAMJC5.js → commands-IOHIM2PX.js} +5 -5
- package/dist/chunks/cost-MYSYQTT3.js +755 -0
- package/dist/chunks/cost-MYSYQTT3.js.map +6 -0
- package/dist/chunks/{crash-report-3GPFLNQX.js → crash-report-WLLGI2U4.js} +6 -6
- package/dist/chunks/day-CU5J7UAK.js +22 -0
- package/dist/chunks/{dist-2EQ3MAWA.js → dist-33QU2MGT.js} +2 -2
- package/dist/chunks/{dist-IS662MSA.js → dist-6G55RC27.js} +2 -2
- package/dist/chunks/{dist-5LXAFF2H.js → dist-CFPNJCLJ.js} +2 -2
- package/dist/chunks/{dist-CO47MPO4.js → dist-E2PF4PGO.js} +2 -2
- package/dist/chunks/{dist-4TO2X6U4.js → dist-FZYKXUR4.js} +2 -2
- package/dist/chunks/{dist-UXUFCGIX.js → dist-IXAUMLZH.js} +2 -2
- package/dist/chunks/{dist-EGCYKNFG.js → dist-MBVPANQB.js} +24 -2
- package/dist/chunks/{dist-F36KOHDP.js → dist-PKKDBDSA.js} +2 -2
- package/dist/chunks/{doctor-YC6Z7P3P.js → doctor-BXRPVVKL.js} +18 -18
- package/dist/chunks/{drain-5BQHD3KW.js → drain-EWKGL77B.js} +9 -9
- package/dist/chunks/{entry-ZJWR3CSL.js → entry-XPXHELKT.js} +6 -6
- package/dist/chunks/{eval-JHNFGVGA.js → eval-OLNNJGUO.js} +2 -2
- package/dist/chunks/{exec-YADZELFF.js → exec-XNMHHHTZ.js} +46 -42
- package/dist/chunks/exec-XNMHHHTZ.js.map +6 -0
- package/dist/chunks/{home-EBXWUU6C.js → home-T4ZVXIEX.js} +3 -3
- package/dist/chunks/{host-JU76NQJY.js → host-LQ6V4NJS.js} +10 -10
- package/dist/chunks/{host-queries-6TO7AIZE.js → host-queries-LEPTBKZK.js} +15 -15
- package/dist/chunks/{learn-YGTIACD6.js → learn-WOZKPYR4.js} +11 -11
- package/dist/chunks/{learn-builtin-FND7NEEV.js → learn-builtin-BVJFZF4R.js} +14 -14
- package/dist/chunks/{lifecycle-VBNEAO74.js → lifecycle-KKIDSRJV.js} +32 -32
- package/dist/chunks/{list-GQEKL3MC.js → list-ZWIXNGJV.js} +15 -15
- package/dist/chunks/{live-N3PPNKW6.js → live-4GQNVGPU.js} +17 -17
- package/dist/chunks/{login-KEFAKXJZ.js → login-MBXPJW6F.js} +13 -13
- package/dist/chunks/{logs-JZEIQMOQ.js → logs-7GVMBYAQ.js} +5 -5
- package/dist/chunks/{mcp-7CBDNNY3.js → mcp-45UUEZMF.js} +23 -23
- package/dist/chunks/{message-command-JAKH5U6B.js → message-command-YVAI3SLS.js} +47 -45
- package/dist/chunks/message-command-YVAI3SLS.js.map +6 -0
- package/dist/chunks/{open-Q63ZNCNO.js → open-UG6VAHDW.js} +8 -8
- package/dist/chunks/{operator-tools-SEK3DCMJ.js → operator-tools-M4SMIAYS.js} +13 -13
- package/dist/chunks/{output-schema-ROCYTWMQ.js → output-schema-MZ6X4WQ2.js} +3 -3
- package/dist/chunks/{pal-XOMURPYQ.js → pal-R4RSZP2U.js} +16 -16
- package/dist/chunks/{peers-GY5QNN5F.js → peers-6TIMGPGR.js} +7 -7
- package/dist/chunks/{peers-JILQNRCW.js → peers-T5SXNFYU.js} +6 -6
- package/dist/chunks/plugin-SAQJPDKX.js +1043 -0
- package/dist/chunks/plugin-SAQJPDKX.js.map +6 -0
- package/dist/chunks/{providers-NMMTLTEC.js → providers-CPHEQZCV.js} +11 -11
- package/dist/chunks/{pty-KR5RNX54.js → pty-YAFV4ZA6.js} +3 -3
- package/dist/chunks/render-QFCCPEEL.js +14 -0
- package/dist/chunks/resume-GZGHY4UR.js +23 -0
- package/dist/chunks/{resume-command-WOG47T6A.js → resume-command-WJH7SKYB.js} +5 -5
- package/dist/chunks/{schedule-V3OHZVHK.js → schedule-I7ZNWSN3.js} +8 -8
- package/dist/chunks/{service-XPJSCHPW.js → service-ZRXXXJW7.js} +36 -36
- package/dist/chunks/{skills-PGO6KGCD.js → skills-RIJBOCKN.js} +8 -8
- package/dist/chunks/{start-check-CLSVKYRW.js → start-check-5DQL76YU.js} +2 -2
- package/dist/chunks/{startup-failure-WN5PCOIE.js → startup-failure-7KMOAOXE.js} +2 -2
- package/dist/chunks/{state-W72YF7CF.js → state-QNSG3QWY.js} +2 -2
- package/dist/chunks/{store-4RNQ47OD.js → store-7NXFZTW7.js} +6 -6
- package/dist/chunks/{store-SQINHTJO.js → store-IDSNTJRG.js} +10 -10
- package/dist/chunks/{store-7SESBCUG.js → store-NE2I4H7E.js} +3 -3
- package/dist/chunks/store-NE2I4H7E.js.map +6 -0
- package/dist/chunks/{store-J4CYKAFS.js → store-TY2ZO2EP.js} +4 -4
- package/dist/chunks/store-TY2ZO2EP.js.map +6 -0
- package/dist/chunks/{tui-HYKE4V4J.js → tui-DLUH6HQ4.js} +78 -74
- package/dist/chunks/tui-DLUH6HQ4.js.map +6 -0
- package/dist/chunks/{upgrade-HE5NIE2M.js → upgrade-UZTPAIDF.js} +7 -7
- package/dist/chunks/{watch-C5YQJNHV.js → watch-AAZHSSIE.js} +71 -67
- package/dist/chunks/watch-AAZHSSIE.js.map +6 -0
- package/dist/chunks/{workspaces-CPOLSOKE.js → workspaces-KLYC5537.js} +16 -16
- package/dist/chunks/{worktree-TUBWOHUQ.js → worktree-4PKAJ7LT.js} +12 -12
- package/dist/cli.d.ts.map +1 -1
- package/dist/commands/acp.d.ts +20 -1
- package/dist/commands/acp.d.ts.map +1 -1
- package/dist/commands/cost.d.ts +26 -0
- package/dist/commands/cost.d.ts.map +1 -0
- package/dist/commands/desktop-host.d.ts.map +1 -1
- package/dist/commands/manifest.d.ts +2 -0
- package/dist/commands/manifest.d.ts.map +1 -1
- package/dist/commands/plugin.d.ts +18 -0
- package/dist/commands/plugin.d.ts.map +1 -0
- package/dist/desktop-contract.d.ts +21 -0
- package/dist/desktop-contract.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +31 -27
- package/dist/integrations/auto-update/install-kind.d.ts.map +1 -1
- package/dist/integrations/plugins/check-hint.d.ts +5 -0
- package/dist/integrations/plugins/check-hint.d.ts.map +1 -0
- package/dist/integrations/plugins/files.d.ts +17 -0
- package/dist/integrations/plugins/files.d.ts.map +1 -1
- package/dist/integrations/plugins/validate.d.ts +75 -0
- package/dist/integrations/plugins/validate.d.ts.map +1 -0
- package/dist/integrations/spend/day.d.ts +26 -0
- package/dist/integrations/spend/day.d.ts.map +1 -0
- package/dist/integrations/spend/fold.d.ts +136 -0
- package/dist/integrations/spend/fold.d.ts.map +1 -0
- package/dist/integrations/spend/ledger.d.ts +74 -0
- package/dist/integrations/spend/ledger.d.ts.map +1 -0
- package/dist/integrations/spend/render.d.ts +6 -0
- package/dist/integrations/spend/render.d.ts.map +1 -0
- package/dist/integrations/spend/report.d.ts +110 -0
- package/dist/integrations/spend/report.d.ts.map +1 -0
- package/dist/integrations/telemetry/otlp-export.d.ts +3 -0
- package/dist/integrations/telemetry/otlp-export.d.ts.map +1 -1
- package/dist/tui/App.d.ts.map +1 -1
- package/dist/tui/agent.d.ts.map +1 -1
- package/dist/tui/slashCommands.d.ts +5 -0
- package/dist/tui/slashCommands.d.ts.map +1 -1
- package/dist/user-commands/store.d.ts +14 -0
- package/dist/user-commands/store.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/chunks/acp-YH3ORAMX.js.map +0 -6
- package/dist/chunks/agent-session-5T4QOI6T.js +0 -69
- package/dist/chunks/chunk-BNIO5NNW.js.map +0 -6
- package/dist/chunks/chunk-EK74R563.js.map +0 -6
- package/dist/chunks/chunk-J4QN36GJ.js.map +0 -6
- package/dist/chunks/chunk-MPLS4I5N.js.map +0 -6
- package/dist/chunks/chunk-QZDNCVK4.js.map +0 -6
- package/dist/chunks/cli-runtime-YUFSSYYG.js.map +0 -6
- package/dist/chunks/exec-YADZELFF.js.map +0 -6
- package/dist/chunks/message-command-JAKH5U6B.js.map +0 -6
- package/dist/chunks/resume-A3XPV4Z5.js +0 -23
- package/dist/chunks/tui-HYKE4V4J.js.map +0 -6
- package/dist/chunks/watch-C5YQJNHV.js.map +0 -6
- /package/dist/chunks/{activity-command-6SLWX5O6.js.map → activity-command-I3OMRZ2T.js.map} +0 -0
- /package/dist/chunks/{add-5DU7SP37.js.map → add-A65AU46H.js.map} +0 -0
- /package/dist/chunks/{agent-IN76G7FR.js.map → agent-3A66KRCM.js.map} +0 -0
- /package/dist/chunks/{agent-session-5T4QOI6T.js.map → agent-session-LJZO5VIZ.js.map} +0 -0
- /package/dist/chunks/{archive-X5OO3HYU.js.map → archive-IWWDLSAO.js.map} +0 -0
- /package/dist/chunks/{bin-main-MJURSFNJ.js.map → bin-main-CRX2U7A6.js.map} +0 -0
- /package/dist/chunks/{binding-6EX5H32J.js.map → binding-4AMPOED7.js.map} +0 -0
- /package/dist/chunks/{browser-UUSAOFML.js.map → browser-SAS7YPVD.js.map} +0 -0
- /package/dist/chunks/{chat-J2DRST74.js.map → chat-ANHTX7D5.js.map} +0 -0
- /package/dist/chunks/{chunk-4MDH3G7P.js.map → chunk-3D52GNVJ.js.map} +0 -0
- /package/dist/chunks/{chunk-DQGDG63U.js.map → chunk-3MJ3YKNV.js.map} +0 -0
- /package/dist/chunks/{chunk-QN4WGK62.js.map → chunk-45Z4OPC6.js.map} +0 -0
- /package/dist/chunks/{chunk-4GQ5ACCZ.js.map → chunk-52YXYXRG.js.map} +0 -0
- /package/dist/chunks/{chunk-ASITCNWM.js.map → chunk-56ZS6OTK.js.map} +0 -0
- /package/dist/chunks/{chunk-M3O7WEJF.js.map → chunk-57QGQNRI.js.map} +0 -0
- /package/dist/chunks/{chunk-PYRMWOCP.js.map → chunk-5TPQGNYN.js.map} +0 -0
- /package/dist/chunks/{chunk-N7COW4QY.js.map → chunk-5U42MB6F.js.map} +0 -0
- /package/dist/chunks/{chunk-HSSTV5SF.js.map → chunk-5YMIK3VP.js.map} +0 -0
- /package/dist/chunks/{chunk-YWKZQABS.js.map → chunk-6CKU4TCF.js.map} +0 -0
- /package/dist/chunks/{chunk-KBLICB2N.js.map → chunk-6I4V7I5M.js.map} +0 -0
- /package/dist/chunks/{chunk-VIJFICIC.js.map → chunk-6MI4Q5QQ.js.map} +0 -0
- /package/dist/chunks/{chunk-76HAMOHW.js.map → chunk-6S4L4SAU.js.map} +0 -0
- /package/dist/chunks/{chunk-CB7VORLS.js.map → chunk-AGC67H4M.js.map} +0 -0
- /package/dist/chunks/{chunk-BZC5JPMB.js.map → chunk-ALXE3SUZ.js.map} +0 -0
- /package/dist/chunks/{chunk-6J6AEQA4.js.map → chunk-ANVIYMV6.js.map} +0 -0
- /package/dist/chunks/{chunk-S4HDKI6L.js.map → chunk-BC3IZXTY.js.map} +0 -0
- /package/dist/chunks/{chunk-K4BMTUBH.js.map → chunk-BN32BPU6.js.map} +0 -0
- /package/dist/chunks/{chunk-YUDCUW4N.js.map → chunk-CYCUJOAD.js.map} +0 -0
- /package/dist/chunks/{chunk-ZJQYNG27.js.map → chunk-DLVHJFXI.js.map} +0 -0
- /package/dist/chunks/{chunk-MJW6FQAW.js.map → chunk-DNOI4BL2.js.map} +0 -0
- /package/dist/chunks/{chunk-FI5EMDFZ.js.map → chunk-DOPHHI6C.js.map} +0 -0
- /package/dist/chunks/{chunk-NEKCM2HR.js.map → chunk-E5OETSRN.js.map} +0 -0
- /package/dist/chunks/{chunk-HFLX3ZLT.js.map → chunk-E7IXVEOQ.js.map} +0 -0
- /package/dist/chunks/{chunk-ZKOEUHCF.js.map → chunk-FKQOGEKL.js.map} +0 -0
- /package/dist/chunks/{chunk-LNIM2TS3.js.map → chunk-FLPT7I7I.js.map} +0 -0
- /package/dist/chunks/{chunk-DE4WWSBB.js.map → chunk-FMAUDMYL.js.map} +0 -0
- /package/dist/chunks/{chunk-H32MIHLE.js.map → chunk-FSS72QJP.js.map} +0 -0
- /package/dist/chunks/{chunk-VPIFXAL6.js.map → chunk-H56PLZHW.js.map} +0 -0
- /package/dist/chunks/{chunk-2XXEIH7D.js.map → chunk-HHLWXGOG.js.map} +0 -0
- /package/dist/chunks/{chunk-BGT2BABA.js.map → chunk-HXPRWMLH.js.map} +0 -0
- /package/dist/chunks/{chunk-UHYZ64ET.js.map → chunk-IPTWZUSV.js.map} +0 -0
- /package/dist/chunks/{chunk-4DYB42HG.js.map → chunk-ITY5SBAS.js.map} +0 -0
- /package/dist/chunks/{chunk-ZYRABJ7J.js.map → chunk-K52DES57.js.map} +0 -0
- /package/dist/chunks/{chunk-3KNUUOMF.js.map → chunk-KJ7Q3BC3.js.map} +0 -0
- /package/dist/chunks/{chunk-AROJAFON.js.map → chunk-KJVRHBMX.js.map} +0 -0
- /package/dist/chunks/{chunk-VDQQE3Q6.js.map → chunk-KZHMLRKY.js.map} +0 -0
- /package/dist/chunks/{chunk-5HS5WIS3.js.map → chunk-LGH2T6KL.js.map} +0 -0
- /package/dist/chunks/{chunk-2OGJPIGN.js.map → chunk-LQJ3TB5E.js.map} +0 -0
- /package/dist/chunks/{chunk-TF6ZSM2M.js.map → chunk-LYPEV765.js.map} +0 -0
- /package/dist/chunks/{chunk-YU65OZTC.js.map → chunk-M44I7P3H.js.map} +0 -0
- /package/dist/chunks/{chunk-HAHNDC7N.js.map → chunk-NAWIOVUH.js.map} +0 -0
- /package/dist/chunks/{chunk-WWC6L5WC.js.map → chunk-NGE7TNCY.js.map} +0 -0
- /package/dist/chunks/{chunk-CSWUOY5K.js.map → chunk-NXJQTDVT.js.map} +0 -0
- /package/dist/chunks/{chunk-O6QJXKWZ.js.map → chunk-OEKCCZ7I.js.map} +0 -0
- /package/dist/chunks/{chunk-3VKSD45U.js.map → chunk-OL5SKFPM.js.map} +0 -0
- /package/dist/chunks/{chunk-MPUHBR73.js.map → chunk-OMP25UWR.js.map} +0 -0
- /package/dist/chunks/{chunk-GTRG5VXA.js.map → chunk-P53E77KS.js.map} +0 -0
- /package/dist/chunks/{chunk-P6CNFKJC.js.map → chunk-PI6KC5CD.js.map} +0 -0
- /package/dist/chunks/{chunk-RZXNXGRE.js.map → chunk-Q5DW33F4.js.map} +0 -0
- /package/dist/chunks/{chunk-RQKE2URW.js.map → chunk-QS65X7D6.js.map} +0 -0
- /package/dist/chunks/{chunk-BIWDWFAK.js.map → chunk-QZ4V25KD.js.map} +0 -0
- /package/dist/chunks/{chunk-JBQATPG3.js.map → chunk-RCLTSI6G.js.map} +0 -0
- /package/dist/chunks/{chunk-ZRM2NW77.js.map → chunk-RDWVNVZS.js.map} +0 -0
- /package/dist/chunks/{chunk-J267C5O6.js.map → chunk-SMX5YHRV.js.map} +0 -0
- /package/dist/chunks/{chunk-YOCPU3WT.js.map → chunk-SQWFNFEX.js.map} +0 -0
- /package/dist/chunks/{chunk-PR3HSIXG.js.map → chunk-SR75L2R5.js.map} +0 -0
- /package/dist/chunks/{chunk-G2DGASUC.js.map → chunk-T5X3GYBF.js.map} +0 -0
- /package/dist/chunks/{chunk-GN4BLP6C.js.map → chunk-TJSGSC2W.js.map} +0 -0
- /package/dist/chunks/{chunk-B4M4IEOE.js.map → chunk-TTXZK3BR.js.map} +0 -0
- /package/dist/chunks/{chunk-F2I6X667.js.map → chunk-U7AQ4OQJ.js.map} +0 -0
- /package/dist/chunks/{chunk-VONTYDZ3.js.map → chunk-UPSI724V.js.map} +0 -0
- /package/dist/chunks/{chunk-SRBCU3IJ.js.map → chunk-V23HHK5D.js.map} +0 -0
- /package/dist/chunks/{chunk-R77WPUUF.js.map → chunk-VQHVH7X2.js.map} +0 -0
- /package/dist/chunks/{chunk-FJZL4BJN.js.map → chunk-WJ4YRFPQ.js.map} +0 -0
- /package/dist/chunks/{chunk-64CDTVEM.js.map → chunk-WJXVNXJZ.js.map} +0 -0
- /package/dist/chunks/{chunk-DXFPBLQV.js.map → chunk-WOX4KI7C.js.map} +0 -0
- /package/dist/chunks/{chunk-3MUNYBIF.js.map → chunk-X3L6N5RM.js.map} +0 -0
- /package/dist/chunks/{chunk-JE2S7MW2.js.map → chunk-XFMGW2C5.js.map} +0 -0
- /package/dist/chunks/{chunk-W5IR3SD3.js.map → chunk-XPCRLKFO.js.map} +0 -0
- /package/dist/chunks/{chunk-XCDXSRY7.js.map → chunk-XYT53O3Z.js.map} +0 -0
- /package/dist/chunks/{chunk-LJ4DIGHQ.js.map → chunk-YSV633T5.js.map} +0 -0
- /package/dist/chunks/{chunk-LRLMZTZ3.js.map → chunk-ZXFEHB7N.js.map} +0 -0
- /package/dist/chunks/{commands-J7XAMJC5.js.map → commands-IOHIM2PX.js.map} +0 -0
- /package/dist/chunks/{crash-report-3GPFLNQX.js.map → crash-report-WLLGI2U4.js.map} +0 -0
- /package/dist/chunks/{dist-EGCYKNFG.js.map → day-CU5J7UAK.js.map} +0 -0
- /package/dist/chunks/{dist-2EQ3MAWA.js.map → dist-33QU2MGT.js.map} +0 -0
- /package/dist/chunks/{dist-IS662MSA.js.map → dist-6G55RC27.js.map} +0 -0
- /package/dist/chunks/{dist-5LXAFF2H.js.map → dist-CFPNJCLJ.js.map} +0 -0
- /package/dist/chunks/{dist-CO47MPO4.js.map → dist-E2PF4PGO.js.map} +0 -0
- /package/dist/chunks/{dist-4TO2X6U4.js.map → dist-FZYKXUR4.js.map} +0 -0
- /package/dist/chunks/{dist-UXUFCGIX.js.map → dist-IXAUMLZH.js.map} +0 -0
- /package/dist/chunks/{doctor-YC6Z7P3P.js.map → dist-MBVPANQB.js.map} +0 -0
- /package/dist/chunks/{dist-F36KOHDP.js.map → dist-PKKDBDSA.js.map} +0 -0
- /package/dist/chunks/{home-EBXWUU6C.js.map → doctor-BXRPVVKL.js.map} +0 -0
- /package/dist/chunks/{drain-5BQHD3KW.js.map → drain-EWKGL77B.js.map} +0 -0
- /package/dist/chunks/{entry-ZJWR3CSL.js.map → entry-XPXHELKT.js.map} +0 -0
- /package/dist/chunks/{eval-JHNFGVGA.js.map → eval-OLNNJGUO.js.map} +0 -0
- /package/dist/chunks/{host-JU76NQJY.js.map → home-T4ZVXIEX.js.map} +0 -0
- /package/dist/chunks/{lifecycle-VBNEAO74.js.map → host-LQ6V4NJS.js.map} +0 -0
- /package/dist/chunks/{host-queries-6TO7AIZE.js.map → host-queries-LEPTBKZK.js.map} +0 -0
- /package/dist/chunks/{learn-YGTIACD6.js.map → learn-WOZKPYR4.js.map} +0 -0
- /package/dist/chunks/{learn-builtin-FND7NEEV.js.map → learn-builtin-BVJFZF4R.js.map} +0 -0
- /package/dist/chunks/{live-N3PPNKW6.js.map → lifecycle-KKIDSRJV.js.map} +0 -0
- /package/dist/chunks/{list-GQEKL3MC.js.map → list-ZWIXNGJV.js.map} +0 -0
- /package/dist/chunks/{login-KEFAKXJZ.js.map → live-4GQNVGPU.js.map} +0 -0
- /package/dist/chunks/{open-Q63ZNCNO.js.map → login-MBXPJW6F.js.map} +0 -0
- /package/dist/chunks/{logs-JZEIQMOQ.js.map → logs-7GVMBYAQ.js.map} +0 -0
- /package/dist/chunks/{mcp-7CBDNNY3.js.map → mcp-45UUEZMF.js.map} +0 -0
- /package/dist/chunks/{output-schema-ROCYTWMQ.js.map → open-UG6VAHDW.js.map} +0 -0
- /package/dist/chunks/{operator-tools-SEK3DCMJ.js.map → operator-tools-M4SMIAYS.js.map} +0 -0
- /package/dist/chunks/{peers-JILQNRCW.js.map → output-schema-MZ6X4WQ2.js.map} +0 -0
- /package/dist/chunks/{pal-XOMURPYQ.js.map → pal-R4RSZP2U.js.map} +0 -0
- /package/dist/chunks/{peers-GY5QNN5F.js.map → peers-6TIMGPGR.js.map} +0 -0
- /package/dist/chunks/{providers-NMMTLTEC.js.map → peers-T5SXNFYU.js.map} +0 -0
- /package/dist/chunks/{pty-KR5RNX54.js.map → providers-CPHEQZCV.js.map} +0 -0
- /package/dist/chunks/{resume-A3XPV4Z5.js.map → pty-YAFV4ZA6.js.map} +0 -0
- /package/dist/chunks/{resume-command-WOG47T6A.js.map → render-QFCCPEEL.js.map} +0 -0
- /package/dist/chunks/{start-check-CLSVKYRW.js.map → resume-GZGHY4UR.js.map} +0 -0
- /package/dist/chunks/{store-4RNQ47OD.js.map → resume-command-WJH7SKYB.js.map} +0 -0
- /package/dist/chunks/{schedule-V3OHZVHK.js.map → schedule-I7ZNWSN3.js.map} +0 -0
- /package/dist/chunks/{service-XPJSCHPW.js.map → service-ZRXXXJW7.js.map} +0 -0
- /package/dist/chunks/{skills-PGO6KGCD.js.map → skills-RIJBOCKN.js.map} +0 -0
- /package/dist/chunks/{store-7SESBCUG.js.map → start-check-5DQL76YU.js.map} +0 -0
- /package/dist/chunks/{startup-failure-WN5PCOIE.js.map → startup-failure-7KMOAOXE.js.map} +0 -0
- /package/dist/chunks/{state-W72YF7CF.js.map → state-QNSG3QWY.js.map} +0 -0
- /package/dist/chunks/{store-J4CYKAFS.js.map → store-7NXFZTW7.js.map} +0 -0
- /package/dist/chunks/{store-SQINHTJO.js.map → store-IDSNTJRG.js.map} +0 -0
- /package/dist/chunks/{upgrade-HE5NIE2M.js.map → upgrade-UZTPAIDF.js.map} +0 -0
- /package/dist/chunks/{workspaces-CPOLSOKE.js.map → workspaces-KLYC5537.js.map} +0 -0
- /package/dist/chunks/{worktree-TUBWOHUQ.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
|