taximeter 0.2.2 → 0.3.1
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 +12 -0
- package/README.md +177 -34
- package/dist/{chunk-DJPLFDD7.js → chunk-LNGF6BWJ.js} +261 -68
- package/dist/cli/index.js +607 -95
- package/dist/index.d.ts +27 -12
- package/dist/index.js +1 -1
- package/dist/ui/assets/index-CFYVdWCt.js +101 -0
- package/dist/ui/index.html +1 -1
- package/docs/SDK.md +20 -9
- package/docs/dashboard.png +0 -0
- package/package.json +3 -2
- package/dist/ui/assets/index-DSVhxCXF.js +0 -101
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Taximeter
|
|
2
2
|
|
|
3
|
+
## 0.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Add a dashboard screenshot to the GitHub and npm README, include the image in the package, and publish the reorganized installation and source quickstarts with clearer documentation headings.
|
|
8
|
+
|
|
9
|
+
## 0.3.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- Show effective configuration and source layers in doctor, add validated atomic config editing with exact human amount inputs, and expose temporary start overrides. Enforce optional payment-count budgets using a schema-3 incremental cache with pre-migration backups, and return executable advisory fix hints for blocked payments. The dashboard remains read-only and displays count usage alongside amount usage.
|
|
14
|
+
|
|
3
15
|
## 0.2.2
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
A taximeter for your AI agents.
|
|
4
4
|
|
|
5
|
-
```sh
|
|
6
|
-
npx taximeter start
|
|
7
|
-
```
|
|
8
|
-
|
|
9
5
|
Taximeter records supported agent payments, checks budgets before forwarding them,
|
|
10
|
-
and keeps an exact local ledger.
|
|
11
|
-
|
|
6
|
+
and keeps an exact local ledger. Follow the [quickstart](#quickstart) to install
|
|
7
|
+
the package or run a source checkout. Requires Node 20 or newer and npm.
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
Built with AI, with an auditable record of [protocol corrections](https://github.com/Ding808/taximeter/blob/main/SPEC-NOTES.md), [decisions](https://github.com/Ding808/taximeter/blob/main/DECISIONS.md), [verification](https://github.com/Ding808/taximeter/blob/main/VERIFICATION.md), and [reproducible benchmarks](https://github.com/Ding808/taximeter/tree/main/benchmarks).
|
|
12
12
|
|
|
13
13
|
## A 20-second demo
|
|
14
14
|
|
|
@@ -32,30 +32,48 @@ It adds exact rolling budgets, attribution, and a statement you can keep.
|
|
|
32
32
|
|
|
33
33
|
## Quickstart
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
Choose one of the two setup paths below, then open the dashboard and connect your
|
|
36
|
+
agent.
|
|
36
37
|
|
|
37
|
-
|
|
38
|
+
### Install (recommended)
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
```sh
|
|
41
|
+
npm install -g taximeter
|
|
42
|
+
taximeter start
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The npm package includes the built CLI and dashboard; no build step is needed.
|
|
46
|
+
Use `taximeter` or its shorter alias `txm` for the commands below.
|
|
47
|
+
|
|
48
|
+
### Run from source
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
git clone https://github.com/Ding808/taximeter.git
|
|
52
|
+
cd taximeter
|
|
53
|
+
npm install
|
|
54
|
+
npm run build
|
|
55
|
+
node dist/cli/index.js start
|
|
56
|
+
```
|
|
42
57
|
|
|
43
|
-
|
|
58
|
+
Cloning and installing dependencies do not add this checkout's CLI to your global
|
|
59
|
+
commands. For **every command below**, replace `taximeter` (or `txm`) with
|
|
60
|
+
`node dist/cli/index.js` while in this checkout. For example, in another terminal:
|
|
44
61
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
62
|
+
```sh
|
|
63
|
+
node dist/cli/index.js doctor
|
|
64
|
+
node dist/cli/index.js config get budgets.global.amount
|
|
65
|
+
```
|
|
48
66
|
|
|
49
|
-
|
|
67
|
+
To make the global `taximeter` and `txm` commands run this checkout, run `npm link`
|
|
68
|
+
after building. A separately installed global command otherwise runs its own
|
|
69
|
+
installed copy.
|
|
50
70
|
|
|
51
|
-
|
|
52
|
-
node dist/cli/index.js start
|
|
53
|
-
```
|
|
71
|
+
### Open the dashboard
|
|
54
72
|
|
|
55
73
|
You should now see:
|
|
56
74
|
|
|
57
75
|
```text
|
|
58
|
-
Taximeter 0.
|
|
76
|
+
Taximeter 0.3.1
|
|
59
77
|
Proxy: http://127.0.0.1:8402
|
|
60
78
|
Dashboard: http://127.0.0.1:8403
|
|
61
79
|
Point an HTTP-proxy-aware agent at http://127.0.0.1:8402.
|
|
@@ -64,9 +82,10 @@ HTTPS CONNECT is unmetered; use --upstream or withMeter for HTTPS payments.
|
|
|
64
82
|
|
|
65
83
|
Open [the local dashboard](http://127.0.0.1:8403). It explains how to connect an
|
|
66
84
|
agent before the first payment arrives. Stop the process with Ctrl+C.
|
|
67
|
-
The prebuilt npm package starts directly; installing it does not build the frontend.
|
|
68
85
|
Dependency download time depends on the connection.
|
|
69
86
|
|
|
87
|
+
### Connect your agent
|
|
88
|
+
|
|
70
89
|
Choose the connection mode your agent supports:
|
|
71
90
|
|
|
72
91
|
| Mode | How to connect | What is visible |
|
|
@@ -82,8 +101,10 @@ does not universally honor proxy environment variables. SDK transports can also
|
|
|
82
101
|
follow redirects or retry internally: these hidden requests are outside host policy
|
|
83
102
|
checks. Use `redirect: "error"` when each destination must be checked.
|
|
84
103
|
|
|
85
|
-
|
|
86
|
-
|
|
104
|
+
### CLI commands
|
|
105
|
+
|
|
106
|
+
These examples use the installed `taximeter` command. Source users should follow
|
|
107
|
+
the command substitution in [Run from source](#run-from-source).
|
|
87
108
|
|
|
88
109
|
| Command | Result |
|
|
89
110
|
| --- | --- |
|
|
@@ -93,9 +114,117 @@ or `txm` command. The CLI provides:
|
|
|
93
114
|
| `taximeter export --csv statement.csv` | A new CSV file; refuses to overwrite an existing file. |
|
|
94
115
|
| `taximeter export --json statement.json` | Event history, raw authorizations, and totals. With no format, JSON goes to stdout. |
|
|
95
116
|
| `taximeter export --invoice statement.html` | A printable HTML spending statement. |
|
|
96
|
-
| `taximeter doctor` |
|
|
117
|
+
| `taximeter doctor [--json]` | Effective configuration, source layers, and SQLite checks; no network probes. |
|
|
118
|
+
| `taximeter config path` | Configuration layers and the default file to edit. |
|
|
119
|
+
| `taximeter config show [--json]` | The merged effective configuration. |
|
|
120
|
+
| `taximeter config get <key>` | One effective value by dot path. |
|
|
121
|
+
| `taximeter config set <key> <value>` | Validate and save a setting; restart to apply it. |
|
|
122
|
+
| `taximeter config unset <key>` | Remove a file override and inherit the lower layer. |
|
|
97
123
|
| `taximeter reset --yes` | Archives the ledger. Stop **all CLI and SDK writers** first. |
|
|
98
124
|
|
|
125
|
+
## Changing limits
|
|
126
|
+
|
|
127
|
+
### Inspect and edit limits
|
|
128
|
+
|
|
129
|
+
Check the effective configuration first, then change the limit and restart:
|
|
130
|
+
|
|
131
|
+
```sh
|
|
132
|
+
taximeter doctor
|
|
133
|
+
taximeter config set budgets.global.amount 200USDC
|
|
134
|
+
taximeter config set budgets.perTask.maxPayments 200
|
|
135
|
+
taximeter config set budgets.perAgent.maxPayments 1000
|
|
136
|
+
taximeter config get budgets.global.amount
|
|
137
|
+
# 200000000
|
|
138
|
+
taximeter start
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Stop the previous process before starting it again. There is no hot reload.
|
|
142
|
+
`doctor --json` includes the same resolved configuration used by that command,
|
|
143
|
+
the source layers, and local checks. It does not inspect an already-running
|
|
144
|
+
process or recover the flags used to start it. `config show --json` prints just
|
|
145
|
+
the resolved configuration.
|
|
146
|
+
|
|
147
|
+
### Amounts and payment counts
|
|
148
|
+
|
|
149
|
+
Use human units for amounts: `5USDC`, `"5 USDC"`, and `5usdc` all store
|
|
150
|
+
`"5000000"`; `0.001USDC` stores `"1000"`. A bare integer such as `5000000` is
|
|
151
|
+
always an atomic-unit value. Conversion uses the offline asset registry and
|
|
152
|
+
rejects unknown symbols, mismatched assets, or excess decimal places; it never
|
|
153
|
+
guesses decimals or rounds. For an unknown asset, use an exact atomic integer.
|
|
154
|
+
Payment counts are positive integers without units.
|
|
155
|
+
|
|
156
|
+
Amount budgets stop spending too much. Payment-count budgets stop an agent from
|
|
157
|
+
making an excessive number of tiny payments while spending little. Each scope
|
|
158
|
+
checks amount first, then count, with the same asset, network, and rolling window.
|
|
159
|
+
Unknown settlements reserve both; blocked or known-failed payments consume neither.
|
|
160
|
+
Zero-amount payments still count. Reusing the same reservation does not count twice.
|
|
161
|
+
Count limits are optional and off by default; they are rolling budgets, not a
|
|
162
|
+
payments-per-second rate limiter.
|
|
163
|
+
|
|
164
|
+
### Configuration files and precedence
|
|
165
|
+
|
|
166
|
+
Keep conservative defaults in `~/.taximeter/config.json`, then override selected
|
|
167
|
+
values per project in `taximeter.config.json`. Files merge **key by key**, so a
|
|
168
|
+
project amount change retains the home's count limit and window. The priority is:
|
|
169
|
+
flags → environment → `--config` → cwd file → home file → built-in defaults.
|
|
170
|
+
`config path` and `doctor` show which files exist, which contribute, and which
|
|
171
|
+
keys are overridden. An omitted field inherits; `unset` removes the target file's
|
|
172
|
+
override. `null` disables a whole budget or the nullable single-payment cap:
|
|
173
|
+
|
|
174
|
+
```sh
|
|
175
|
+
taximeter config set policy.maxSinglePayment 0.5USDC
|
|
176
|
+
taximeter config set policy.allowHosts api.example.com,data.example.com
|
|
177
|
+
taximeter config set budgets.perTask null
|
|
178
|
+
taximeter config unset policy.allowHosts
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
An empty allow-list allows all hosts or recipients. A populated allow-list allows
|
|
182
|
+
only its listed entries; host matching is exact and case-insensitive.
|
|
183
|
+
|
|
184
|
+
`set` and `unset` write the existing cwd file, otherwise the home file. Use
|
|
185
|
+
`--file <path>` to choose a destination. `--config <path>` selects an additional
|
|
186
|
+
**read layer**, so pass `--file` too when editing that explicit file. Writes validate
|
|
187
|
+
both the patch and the merged result before replacing the file atomically through
|
|
188
|
+
a temporary file in the same directory, created with mode `0o600`. Invalid values
|
|
189
|
+
or unknown keys leave the original file unchanged; misspelled keys get a suggestion.
|
|
190
|
+
|
|
191
|
+
### Temporary overrides
|
|
192
|
+
|
|
193
|
+
For a single run, override limits without saving them:
|
|
194
|
+
|
|
195
|
+
```sh
|
|
196
|
+
taximeter start --budget-global 200USDC --max-payments-global 1000 --max-single 0.5USDC
|
|
197
|
+
taximeter start --allow-host api.example.com --allow-host data.example.com
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
Also available: `--budget-task`, `--budget-agent`, `--max-payments-task`,
|
|
201
|
+
`--max-payments-agent`, and repeatable `--deny-host`. Host flags replace that
|
|
202
|
+
list for the run. Startup prints every active flag override. A flag can enable
|
|
203
|
+
a disabled budget; when no asset is inherited, it uses USDC.
|
|
204
|
+
|
|
205
|
+
### Count-only budgets
|
|
206
|
+
|
|
207
|
+
A fully resolved budget can contain only `maxPayments`, with no amount limit.
|
|
208
|
+
Because file omissions inherit lower settings, adding `maxPayments` alone does
|
|
209
|
+
not remove an inherited amount limit. To establish a count-only budget across
|
|
210
|
+
layers, disable that scope in the lower file, then set `{ "asset": "USDC",
|
|
211
|
+
"maxPayments": 200 }` in the higher file. Alternatively, disable the stored scope
|
|
212
|
+
and enable it for one run with `--max-payments-global 200` (or its task/agent flag).
|
|
213
|
+
Use `doctor` to confirm the resulting amount and window before starting.
|
|
214
|
+
|
|
215
|
+
### Suggested fixes for blocked payments
|
|
216
|
+
|
|
217
|
+
Blocked responses include an advisory `fix` command; the terminal prints it once
|
|
218
|
+
per reason per process. Numeric hints raise the affected bound enough for that
|
|
219
|
+
payment. At the largest representable limit, the hint disables the affected
|
|
220
|
+
budget. Host/recipient hints clear the relevant list, and `unknown_asset` suggests
|
|
221
|
+
an explicit opt-in. Review those policy changes before running them. Hints never
|
|
222
|
+
execute automatically. After editing, restart without conflicting override flags;
|
|
223
|
+
when using `--config`, edit the selected file with `--file` as needed.
|
|
224
|
+
|
|
225
|
+
**The dashboard is read-only by design.** It shows amount and payment-count usage
|
|
226
|
+
but has no configuration write endpoints: a web page cannot relax spending limits.
|
|
227
|
+
|
|
99
228
|
## How it works
|
|
100
229
|
|
|
101
230
|
```text
|
|
@@ -120,7 +249,7 @@ their amount before forwarding the payment replay.
|
|
|
120
249
|
Policy evaluation and reservation share one SQLite transaction, so concurrent
|
|
121
250
|
payments cannot all consume the same remaining capacity.
|
|
122
251
|
Append-only payment, outcome, and diagnostic records derive every total with BigInt.
|
|
123
|
-
Payment checks use an incrementally maintained index of exact budget sums, avoiding
|
|
252
|
+
Payment checks use an incrementally maintained index of exact budget sums and counts, avoiding
|
|
124
253
|
a replay of all prior payments. The index can be rebuilt from the original log.
|
|
125
254
|
The local dashboard polls that ledger every second and exports the same counted amounts.
|
|
126
255
|
|
|
@@ -144,22 +273,28 @@ as text to prevent a spreadsheet application from rounding them.
|
|
|
144
273
|
|
|
145
274
|
## Configuration
|
|
146
275
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
276
|
+
### Upgrade and rollback
|
|
277
|
+
|
|
278
|
+
Before upgrading, stop **all proxy and SDK writers**, then upgrade them together.
|
|
279
|
+
Opening a schema-1 (0.1.x) or schema-2 (0.2.x) ledger prints `Migrating ledger…`,
|
|
280
|
+
saves a standalone backup beside it at
|
|
281
|
+
`<database>.backup-v<original schema>-<unique suffix>/ledger.db`, and prints the
|
|
282
|
+
backup path before migration. Schema 3 adds payment counts to the existing
|
|
283
|
+
prefix index and rebuilds both projections from the audit log. The backup includes committed WAL records;
|
|
151
284
|
if it cannot be completed, the upgrade stops. Large ledgers take longer on this
|
|
152
285
|
first open. Fresh databases and already-upgraded ledgers do not create backups.
|
|
153
286
|
|
|
154
|
-
The source log is preserved, but older 0.1.x clients cannot reopen the upgraded
|
|
287
|
+
The source log is preserved, but older 0.1.x/0.2.x clients cannot reopen the upgraded
|
|
155
288
|
database. To roll back, stop all CLI and SDK writers, copy the saved `ledger.db`
|
|
156
|
-
to a **new database path**, and start
|
|
289
|
+
to a **new database path**, and start the matching older version with `--db` pointing there. Keep the
|
|
157
290
|
upgraded database: the backup does not contain payments made after migration.
|
|
158
291
|
Backups are retained until you remove them; a `ledger.partial.db` file means the
|
|
159
292
|
backup did not finish and must not be used for rollback. Progress goes to stderr,
|
|
160
293
|
so JSON report/export output stays machine-readable. Parsed unknown assets now
|
|
161
294
|
require an explicit opt-in as described below.
|
|
162
295
|
|
|
296
|
+
### Defaults and overrides
|
|
297
|
+
|
|
163
298
|
No file is required. Start from [the example](taximeter.config.example.json) when
|
|
164
299
|
needed. Precedence, highest first: flags, environment, explicit `--config` file,
|
|
165
300
|
`taximeter.config.json` in the working directory, `~/.taximeter/config.json`, defaults.
|
|
@@ -171,7 +306,8 @@ invalid values are rejected with Zod.
|
|
|
171
306
|
| `budgets.perTask` | `{"amount":"5000000","asset":"USDC"}` | 5 USDC per task, all time. `null` disables it. |
|
|
172
307
|
| `budgets.perAgent` | `{"amount":"50000000","asset":"USDC","window":"24h"}` | 50 USDC per agent in a rolling 24 hours. `null` disables it. |
|
|
173
308
|
| `budgets.global` | `{"amount":"100000000","asset":"USDC","window":"24h"}` | 100 USDC per network/asset in a rolling 24 hours. `null` disables it. |
|
|
174
|
-
| Each budget's `amount` | Scope default above |
|
|
309
|
+
| Each budget's `amount` | Scope default above | Optional nonnegative integer string in atomic units, at most 78 digits. At least `amount` or `maxPayments` must be present in a resolved budget. |
|
|
310
|
+
| Each budget's `maxPayments` | Omitted | Optional positive safe integer, at most 9007199254740991. Counts the same payments as spend within the scope's window. |
|
|
175
311
|
| Each budget's `asset` | `USDC` | Trusted local symbol or exact contract address. |
|
|
176
312
|
| Each budget's `network` | Omitted | Optional exact network such as `eip155:8453`; otherwise evaluate each network separately. |
|
|
177
313
|
| Each budget's `window` | Scope default above | `1h`, `24h`, `7d`, or `30d`; omitted means all time. |
|
|
@@ -190,6 +326,8 @@ All commands accept `--db` and `--config`. Start also accepts `--proxy-port`,
|
|
|
190
326
|
`--dashboard-port`, and `--upstream`. Environment overrides are `TAXIMETER_DB`,
|
|
191
327
|
`TAXIMETER_PORT`, and `TAXIMETER_DASHBOARD_PORT`.
|
|
192
328
|
|
|
329
|
+
### Asset matching and attribution
|
|
330
|
+
|
|
193
331
|
Missing task/agent labels share an **Unattributed** bucket. Supply `Taximeter-Task`
|
|
194
332
|
and `Taximeter-Agent` headers, or SDK options. The offline asset registry recognizes
|
|
195
333
|
USDC by its network and contract on Base and Base Sepolia. Parsed payments for
|
|
@@ -202,6 +340,8 @@ unknown assets, which remain separate atomic-unit balances with unknown decimals
|
|
|
202
340
|
Configure budgets using the exact contract address and, when needed, its network.
|
|
203
341
|
Default USDC budgets do not cap these assets; only matching budgets and caps apply.
|
|
204
342
|
|
|
343
|
+
### Blocked responses
|
|
344
|
+
|
|
205
345
|
A denied replay receives HTTP 402 before it reaches the upstream. For a cap of
|
|
206
346
|
140 atomic units already fully consumed, the response is:
|
|
207
347
|
|
|
@@ -211,12 +351,15 @@ A denied replay receives HTTP 402 before it reaches the upstream. For a cap of
|
|
|
211
351
|
"reason": "global_budget",
|
|
212
352
|
"budget": "140",
|
|
213
353
|
"spent": "140",
|
|
214
|
-
"remaining": "0"
|
|
354
|
+
"remaining": "0",
|
|
355
|
+
"fix": "taximeter config set budgets.global.amount 147"
|
|
215
356
|
}
|
|
216
357
|
```
|
|
217
358
|
|
|
218
359
|
Reasons are `host_denied`, `host_not_allowed`, `recipient_not_allowed`, `unknown_asset`,
|
|
219
|
-
`max_single_payment`, `per_task_budget`, `per_agent_budget`,
|
|
360
|
+
`max_single_payment`, `per_task_budget`, `per_agent_budget`, `global_budget`,
|
|
361
|
+
`per_task_payment_count`, `per_agent_payment_count`, and `global_payment_count`.
|
|
362
|
+
Count denials use decimal count strings in `budget`, `spent`, and `remaining`.
|
|
220
363
|
Host, recipient, and unknown-asset denials have `budget: null`, `spent: "0"`, and
|
|
221
364
|
`remaining: null`.
|
|
222
365
|
|