agentoom-pi-spending-guard

内容来源:README.md(说明文档) · 原始地址 · 查看安装指南

原始内容

@agentoom/pi-spending-guard

Track LLM spending per task and pause when a configurable threshold is reached for pi by agentoom.com.

When your spending limit is hit, spending-guard pauses the task and asks you to choose: continue (double the limit or reset the counter), refine the prompt, or stop entirely — so you never lose control of your API costs.

Install

pi install npm:@agentoom/pi-spending-guard

Quick start

Out of the box, spending-guard is enabled with a $3.00 default limit. Start pi and spend away — it'll pause automatically at $3.00.

Usage

Commands

Command Description
/spending Show current spending, limit, and enabled state
/spending limit [amount] Set or view the spending limit (e.g. /spending limit 5)
/spending toggle [on|off] Enable/disable tracking; no argument toggles
/spending-limit [amount] Shortcut: set or view the limit
/spending-toggle [on|off] Shortcut: enable/disable
/spending-status Shortcut: show current status

Threshold dialog

When accumulated cost reaches the configured limit, spending-guard pauses and presents a 4-option dialog:

Option Behaviour
Continue (double the limit) Raises the cap to 2× the current limit and keeps going
Continue (reset counter) Keeps the same limit, resets accumulated cost to $0.00
Refine the prompt Opens an input field so you can write a more focused prompt
Stop the task Gracefully shuts down pi

Cost display

While tracking is enabled, current spending is shown live in the footer status bar:

💵 $1.23 / $3.00

Configuration

Spending-guard reads from these files (project takes priority):

  1. .pi/spending-guard.json — project-local
  2. ~/.pi/agent/spending-guard.json — global

If neither file exists, it defaults to enabled with a $3.00 limit.

Config format

{
  "enabled": true,
  "limit": 5.00
}
Key Type Default Description
enabled boolean true Whether tracking starts active
limit number 3.00 Spending threshold in USD

Per-project vs global

  • Place the extension globally to track spending across all projects:
    pi install npm:@agentoom/pi-spending-guard
    
  • Place a .pi/spending-guard.json in a specific project to override the default for that project only.

Development

spending/
├── package.json
├── index.ts          # Extension entry point
├── .gitignore
└── README.md

Run against a local path:

pi install ./spending

Links