{"_id":"@bacnh85/pi-budget","_rev":"8-47c3d96f1020ea13106960e3e9c0ddff","name":"@bacnh85/pi-budget","dist-tags":{"latest":"0.1.7"},"versions":{"0.1.0":{"name":"@bacnh85/pi-budget","version":"0.1.0","keywords":["pi-package","pi","budget","spend","cost","cap"],"license":"MIT","_id":"@bacnh85/pi-budget@0.1.0","maintainers":[{"name":"bacnh85","email":"mail@bacnh.com"}],"homepage":"https://github.com/bacnh85/pi-extensions#readme","bugs":{"url":"https://github.com/bacnh85/pi-extensions/issues"},"pi":{"extensions":["./extensions/index.js"]},"dist":{"shasum":"f8ada0d14df83d72e70942c7051eb1ba100736f0","tarball":"https://registry.npmjs.org/@bacnh85/pi-budget/-/pi-budget-0.1.0.tgz","fileCount":5,"integrity":"sha512-3miArwhbt9xcArsVScxrG58ZRbiphYlv+7xXk6R2dQ3Osi6FlUA2WONGYzZWOMNJOjW/9APoR+riur+k5PmvJg==","signatures":[{"sig":"MEUCIHyHFpwq6qCIyUL5CNJgaAtNHGRdD0+YcXncnAw/+ER3AiEAyW9cWqmM1oT0GlU2V8/7qVQBljgKNZw8cARY62U4ZlI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":8465},"gitHead":"efdf6a6c05d62538f636aca6b0433b7c0b5e9552","scripts":{"test":"node --test extensions/test/*.test.js"},"_npmUser":{"name":"bacnh85","email":"mail@bacnh.com"},"repository":{"url":"git+https://github.com/bacnh85/pi-extensions.git","type":"git"},"_npmVersion":"10.9.8","description":"Spend cap enforcement for Pi — halts the agent when session cost exceeds a --budget USD limit. Companion to pi-sub (which renders usage); this one enforces.","directories":{},"_nodeVersion":"22.23.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/pi-budget_0.1.0_1785920527677_0.2867616427982982","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@bacnh85/pi-budget","version":"0.1.1","keywords":["pi-package","pi","budget","spend","cost","cap"],"license":"MIT","_id":"@bacnh85/pi-budget@0.1.1","maintainers":[{"name":"bacnh85","email":"mail@bacnh.com"}],"homepage":"https://github.com/bacnh85/pi-extensions/tree/main/pi-budget","bugs":{"url":"https://github.com/bacnh85/pi-extensions/issues"},"pi":{"extensions":["./extensions/index.js"]},"dist":{"shasum":"83a3eaf5424873222eed9fdf229d9e67474ddb7b","tarball":"https://registry.npmjs.org/@bacnh85/pi-budget/-/pi-budget-0.1.1.tgz","fileCount":5,"integrity":"sha512-Fyzellm6Nj5PCRXfqzl+paNLe0RPbj8esRHS+oDSgW6w+Up3KPny0Nj3gr3CB85DNY1stGKUkTi7DTyVFYQmig==","signatures":[{"sig":"MEUCIQCKLirO0CIUl5dd1dwViWnZ/qAtbNWTglFm5oWX2GVxdQIgDmyprUGr2vkles6U13EHlHamvQ66xHiUa4D+iCY+73w=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":8632},"gitHead":"b6dc2aa08224976862793b502d6ec946c2b9b2d4","scripts":{"test":"node --test extensions/test/*.test.js"},"_npmUser":{"name":"bacnh85","email":"mail@bacnh.com"},"repository":{"url":"git+https://github.com/bacnh85/pi-extensions.git","type":"git"},"_npmVersion":"10.9.8","description":"Spend cap enforcement for Pi — halts the agent when session cost exceeds a --budget USD limit. Companion to pi-sub (which renders usage); this one enforces.","directories":{},"_nodeVersion":"22.23.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/pi-budget_0.1.1_1785926409556_0.7795521302862589","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@bacnh85/pi-budget","version":"0.1.2","keywords":["pi-package","pi","budget","spend","cost","cap"],"license":"MIT","_id":"@bacnh85/pi-budget@0.1.2","maintainers":[{"name":"bacnh85","email":"mail@bacnh.com"}],"homepage":"https://github.com/bacnh85/pi-extensions/tree/main/pi-budget","bugs":{"url":"https://github.com/bacnh85/pi-extensions/issues"},"pi":{"extensions":["./extensions/index.js"]},"dist":{"shasum":"f0fe7cec149be8fb2ba3fb5138712246353b05c1","tarball":"https://registry.npmjs.org/@bacnh85/pi-budget/-/pi-budget-0.1.2.tgz","fileCount":5,"integrity":"sha512-goqNAvroDiXBSfTpJ68QTcrTd8DnDHvwfRIdNm/zkouiuF+kHrX/q86PBpihcX0ZTYnsv4wPiaj+ys7r2aUPag==","signatures":[{"sig":"MEQCIAF1WFw8PRtHGP4U7jQsJKhl3BKXiKaMGuKgCyOIbp1LAiAsKztbCObTJ3guGpSf7t6LIcF+X/yKxuikqN5pOfEqzQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":9184},"gitHead":"d7e264d6a415cdb5bffdaabae8bfc24d064ed972","scripts":{"test":"node --test extensions/test/*.test.js"},"_npmUser":{"name":"bacnh85","email":"mail@bacnh.com"},"repository":{"url":"git+https://github.com/bacnh85/pi-extensions.git","type":"git"},"_npmVersion":"10.9.8","description":"Spend cap enforcement for Pi — halts the agent when session cost exceeds a --budget USD limit. Companion to pi-sub (which renders usage); this one enforces.","directories":{},"_nodeVersion":"22.23.2","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/pi-budget_0.1.2_1786768295683_0.7128029011115711","host":"s3://npm-registry-packages-npm-production"}},"0.1.3":{"name":"@bacnh85/pi-budget","version":"0.1.3","keywords":["pi-package","pi","budget","spend","cost","cap"],"license":"MIT","_id":"@bacnh85/pi-budget@0.1.3","maintainers":[{"name":"bacnh85","email":"mail@bacnh.com"}],"homepage":"https://github.com/bacnh85/pi-extensions/tree/main/pi-budget","bugs":{"url":"https://github.com/bacnh85/pi-extensions/issues"},"pi":{"extensions":["./extensions/index.js"]},"dist":{"shasum":"68def4b2da0b3089b4f9abe74ccd664300c19924","tarball":"https://registry.npmjs.org/@bacnh85/pi-budget/-/pi-budget-0.1.3.tgz","fileCount":5,"integrity":"sha512-qzBSCN4Lys3Vt8OupJtU2/8ZB8Yja+w1dWGWjOxqnMbk9FCINcoA7FkbuuoPBSGyylFHfcnYMFotcK6DpDk1Qg==","signatures":[{"sig":"MEUCIQDSKnsjpAqsOm2zReY414JWkl3TVWDEPRv1G7bAFVjwSwIgclkFuvxjFPZch2AEqoNrUFDr7BYlsq5poXcFt+sUOb8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEUCIBsFBGnghovWBCC2qFLlUKKFTqIbRbSFt1lEYER2JWvxAiEAwxKqLXxHZW9bYxrueu3eH5XUk5lFSkEHUajbFju4Pmg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":10118},"gitHead":"fc25702c6bed994da1dd5071c5ec8071bfd28393","scripts":{"test":"node --test extensions/test/*.test.js"},"_npmUser":{"name":"bacnh85","email":"mail@bacnh.com"},"repository":{"url":"git+https://github.com/bacnh85/pi-extensions.git","type":"git"},"_npmVersion":"10.9.8","description":"Spend cap enforcement for Pi — halts the agent when session cost exceeds a --budget USD limit. Companion to pi-sub (which renders usage); this one enforces.","directories":{},"_nodeVersion":"22.23.2","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/pi-budget_0.1.3_1789204338429_0.4879259893789527","host":"s3://npm-registry-packages-npm-production"}},"0.1.4":{"name":"@bacnh85/pi-budget","version":"0.1.4","keywords":["pi-package","pi","budget","spend","cost","cap"],"license":"MIT","_id":"@bacnh85/pi-budget@0.1.4","maintainers":[{"name":"bacnh85","email":"mail@bacnh.com"}],"homepage":"https://github.com/bacnh85/pi-extensions/tree/main/pi-budget","bugs":{"url":"https://github.com/bacnh85/pi-extensions/issues"},"pi":{"extensions":["./extensions/index.js"]},"dist":{"shasum":"b3a341260bde56323c704eb4360c4b43a2d66c8e","tarball":"https://registry.npmjs.org/@bacnh85/pi-budget/-/pi-budget-0.1.4.tgz","fileCount":5,"integrity":"sha512-3J4BwFQcnhO+ugjHDHmcjnQiC5pxBsqGeBacmynYgdnF81oznIzuLhGUNfrONxjDufCUEF6XZA8ShkT0j/TaCQ==","signatures":[{"sig":"MEUCIDV+S9gZ9IqJXIqxpXoIg214vMCndcnOjD2KHDq1GVlIAiEA3NuO1o1qt/ED67nEcbcuQNaxEcpONc9l+3eolB4OT+U=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEYCIQCsi432AQIcc4MtQCWkXPaF4tl71CwBoxQqi3CG1KpVCgIhAP1VoTpHJjEmtmWrsji79cLg8rdsOLTOBwJ45FtwtyI7","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":10438},"gitHead":"e0ab9215e2df54e5fa42f1c6cc6f616124fdea95","scripts":{"test":"node --test extensions/test/*.test.js"},"_npmUser":{"name":"bacnh85","email":"mail@bacnh.com"},"repository":{"url":"git+https://github.com/bacnh85/pi-extensions.git","type":"git"},"_npmVersion":"10.9.8","description":"Spend cap enforcement for Pi — halts the agent when session cost exceeds a --budget USD limit. Companion to pi-sub (which renders usage); this one enforces.","directories":{},"_nodeVersion":"22.23.2","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/pi-budget_0.1.4_1790123354423_0.7594292615810989","host":"s3://npm-registry-packages-npm-production"}},"0.1.5":{"name":"@bacnh85/pi-budget","version":"0.1.5","keywords":["pi-package","pi","budget","spend","cost","cap"],"license":"MIT","_id":"@bacnh85/pi-budget@0.1.5","maintainers":[{"name":"bacnh85","email":"mail@bacnh.com"}],"homepage":"https://github.com/bacnh85/pi-extensions/tree/main/pi-budget","bugs":{"url":"https://github.com/bacnh85/pi-extensions/issues"},"pi":{"extensions":["./extensions/index.js"]},"dist":{"shasum":"ef1f2b3cb2070edf889a0ace5f3cda28701704b6","tarball":"https://registry.npmjs.org/@bacnh85/pi-budget/-/pi-budget-0.1.5.tgz","fileCount":5,"integrity":"sha512-HrjLvFkxyW9bfYzMsahw0AilMDCAb2e8hX5mvwaOcBBooTVvuvvpX/vcK9J+mPX8Y6BXnnYkTVUB0iriXNKW/A==","signatures":[{"sig":"MEUCIBiXqA+ZjwQcF92ElmcadGk0NLo8V0l5qcxqHyscRavRAiEApI5pAVZr4A+UFbLwb/LPY6crOcByexw0r4VFr+L+GKg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEUCIQC2IkU3EoLxWEjxXvr0wnwFDcJ5OiUoJVNP6Os+5B/GowIgJMUWrqRDcaHZKnHz+41eVJDIkF+arX/wMCpluNauSis=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":10993},"gitHead":"47ee5073837a97916572d769f13d86f55d54ef00","scripts":{"test":"node --test extensions/test/*.test.js"},"_npmUser":{"name":"bacnh85","email":"mail@bacnh.com"},"repository":{"url":"git+https://github.com/bacnh85/pi-extensions.git","type":"git"},"_npmVersion":"10.9.8","description":"Spend cap enforcement for Pi — halts the agent when session cost exceeds a --budget USD limit. Companion to pi-sub (which renders usage); this one enforces.","directories":{},"_nodeVersion":"22.23.2","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/pi-budget_0.1.5_1790209500542_0.3421394943598768","host":"s3://npm-registry-packages-npm-production"}},"0.1.6":{"name":"@bacnh85/pi-budget","version":"0.1.6","keywords":["pi-package","pi","budget","spend","cost","cap"],"license":"MIT","_id":"@bacnh85/pi-budget@0.1.6","maintainers":[{"name":"bacnh85","email":"mail@bacnh.com"}],"homepage":"https://github.com/bacnh85/pi-extensions/tree/main/pi-budget","bugs":{"url":"https://github.com/bacnh85/pi-extensions/issues"},"pi":{"extensions":["./extensions/index.js"]},"dist":{"shasum":"c35f04214d058249b849f8b5674aa5a6c6b303ac","tarball":"https://registry.npmjs.org/@bacnh85/pi-budget/-/pi-budget-0.1.6.tgz","fileCount":5,"integrity":"sha512-UhygalQQ+1FAD5flk7o+Lcuh/zfuoIvqWdbiZ4qFPX4FC/q3e5cWoVVrx9dxZKSqhUJKpt29NN/fW23KpK5S7A==","signatures":[{"sig":"MEUCICBsqqrnvdCZWDhogwKEs0ZusczDqc8m59cUS7wD4Ih6AiEAxYglaXmwVw3FZtyViFDYglNbN25GWjcYdtpaGuI5fS0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEQCIEri+uJ1X4LOI6zyYSOq63RxUA3/pYX35Vxm5nMTMqjGAiBm5Y3kkzyEBaLzmsfqlJJyHgfimXIgYm5/fRnWYFlsuA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":11977},"gitHead":"90930b50f5fc0a4491a748ee1692db40f7ec358a","scripts":{"test":"node --test extensions/test/*.test.js"},"_npmUser":{"name":"bacnh85","email":"mail@bacnh.com"},"repository":{"url":"git+https://github.com/bacnh85/pi-extensions.git","type":"git"},"_npmVersion":"10.9.8","description":"Spend cap enforcement for Pi — halts the agent when session cost exceeds a --budget USD limit. Companion to pi-sub (which renders usage); this one enforces.","directories":{},"_nodeVersion":"22.23.2","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/pi-budget_0.1.6_1790555343452_0.323770486132682","host":"s3://npm-registry-packages-npm-production"}},"0.1.7":{"pi":{"extensions":["./extensions/index.js"]},"_id":"@bacnh85/pi-budget@0.1.7","bugs":{"url":"https://github.com/bacnh85/pi-extensions/issues"},"dist":{"shasum":"d3fd2b2c1c0e301dbebea376b036ff051035c429","tarball":"https://registry.npmjs.org/@bacnh85/pi-budget/-/pi-budget-0.1.7.tgz","fileCount":5,"integrity":"sha512-XwWPC3LYx+bJYJjpRs2yd6yCh2rPM/P2RMMBZqTKPEkwI4liHkhf+ZG9s+o47mXZ5OuyYs3FM1wXWYyy5w9OhQ==","signatures":[{"sig":"MEUCIQC/k4ML3Gt03NUj4WLtp2b9RK7wRoIgQsluJpxhfe6cywIgM5eR3A3XZhRYETIzNZ+KqrLbKNsCQ9Aq3MBs57ElOEQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIH7Q1NO8bYap5IXoI71St3voQ8/qdQXirKi3NQZuDLAbAiAnudC6x7XO+R+Yil4xF4pHwjFbM7wpW4SsIkp+qnVfOw=="}],"unpackedSize":13344},"name":"@bacnh85/pi-budget","gitHead":"5388a5f1987873fe1355064f72021452c4347c72","license":"MIT","scripts":{"test":"node --test extensions/test/*.test.js"},"version":"0.1.7","_npmUser":{"name":"bacnh85","email":"mail@bacnh.com"},"homepage":"https://github.com/bacnh85/pi-extensions/tree/main/pi-budget","keywords":["pi-package","pi","budget","spend","cost","cap"],"repository":{"url":"git+https://github.com/bacnh85/pi-extensions.git","type":"git"},"_npmVersion":"10.9.8","description":"Spend cap enforcement for Pi — halts the agent when session cost exceeds a --budget USD limit. Companion to pi-sub (which renders usage); this one enforces.","directories":{},"maintainers":[{"name":"bacnh85","email":"mail@bacnh.com"}],"_nodeVersion":"22.23.2","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/pi-budget_0.1.7_1790729277821_0.87946077148858"}}},"time":{"created":"2026-08-05T09:02:07.458Z","modified":"2026-09-30T00:47:58.073Z","0.1.0":"2026-08-05T09:02:07.819Z","0.1.1":"2026-08-05T10:40:09.706Z","0.1.2":"2026-08-15T04:31:35.811Z","0.1.3":"2026-09-12T09:12:18.530Z","0.1.4":"2026-09-23T00:29:14.504Z","0.1.5":"2026-09-24T00:25:00.644Z","0.1.6":"2026-09-28T00:29:03.547Z","0.1.7":"2026-09-30T00:47:57.909Z"},"bugs":{"url":"https://github.com/bacnh85/pi-extensions/issues"},"license":"MIT","homepage":"https://github.com/bacnh85/pi-extensions/tree/main/pi-budget","keywords":["pi-package","pi","budget","spend","cost","cap"],"repository":{"url":"git+https://github.com/bacnh85/pi-extensions.git","type":"git"},"description":"Spend cap enforcement for Pi — halts the agent when session cost exceeds a --budget USD limit. Companion to pi-sub (which renders usage); this one enforces.","maintainers":[{"name":"bacnh85","email":"mail@bacnh.com"}],"readme":"# pi-budget\n\nSpend cap enforcement for Pi — halts the agent when cumulative session cost\nexceeds a `--budget <usd>` limit. Companion to\n[`pi-sub`](https://www.npmjs.com/package/@bacnh85/pi-sub): pi-sub *renders*\nsubscription usage in the footer; pi-budget *enforces* a spend policy.\n\nZero dependencies. Plain JS.\n\n## Install\n\n```bash\npi install npm:@bacnh85/pi-budget\n```\n\n## Usage\n\n```bash\npi --budget 0.50          # abort the session once spend hits $0.50\npi --budget 5             # a whole-dollar cap works too\n```\n\nWhen the cumulative cost of assistant responses reaches the cap:\n\n- The current turn is aborted (`ctx.abort()`).\n- A warning notification is shown.\n- A `budget-exceeded` custom entry is appended to the session record.\n- The footer shows `Budget $X.XX / $Y.YY` (red when exceeded, yellow below 20%\n  remaining).\n\nThe budget resets on a **new session**. Context compaction does **not** reset it\n(compaction is mid-session). No cap set → the extension stays silent and shows\nno footer.\n\n## How it works\n\n- `pi.registerFlag(\"budget\")` reads `--budget <usd>` once at startup.\n- `message_end` events accumulate `message.usage.cost.total` for assistant\n  messages.\n- `ctx.abort()` stops the turn when the cap is crossed; an `exceeded` guard\n  ensures the abort fires exactly once per session.\n\n## Limitations\n\n- **Parent-session only.** pi-subagent children are separate sessions, so child\n  spend is not visible to this extension. Child aggregation from `tool_result`\n  is a possible follow-up (tracked in the CHANGELOG).\n- **Accuracy follows providers.** Enforcement is only as accurate as each\n  provider's `usage.cost.total` reporting.\n\n## Development\n\n```bash\nnpm test   # node --test (no framework)\n```\n\n## License\n\nMIT\n","readmeFilename":"README.md"}