trystub 1.1.0
LLM token metering
New trystub/llm entry point. Hold an estimate, run the call once, settle the real token cost. Reads OpenAI and Anthropic usage fields. Ships no price table on purpose, since a stale price inside a dependency quietly mis-bills you.
Retries that cannot double-charge
Per-call timeout, bounded retries on network errors, 429 and 5xx, and a generated idempotency key on every spend and reserve. A request retried after the server already committed resolves to the same single ledger entry.
Dual ESM and CommonJS
require("trystub") works now. Previously ESM only.
Runs on local Postgres
Set DATABASE_URL and Stub runs without an AWS account. Transactions run at SERIALIZABLE, so plain Postgres raises the same 40001 serialization failures as Aurora DSQL.
Sharded balances
core/sharded.ts splits a hot balance across shard rows for 1.2 to 2.8x throughput. No shard can go below zero, so the overspend invariant still holds. Opt-in via shardedSpend. npm run bench measures the contention ceiling.
npm i trystub