Skip to content

Releases: ashutosh887/stub

trystub 1.2.0

Choose a tag to compare

@github-actions github-actions released this 10 Aug 10:35

Added

  • Operator actions on StubClient. stub.sweep() reclaims reservations left held past the
    server's RESERVATION_TTL_SECONDS; stub.provisionShards(accountId, shards?) splits an
    account's current balance across shard rows for throughput. Both are operator-only: construct
    the client with the server's ADMIN_TOKEN as apiKey, not an agent's scoped key.
  • Stub server: reservation TTL sweep. A held reservation nobody ever settles or releases
    (a crashed agent) is reclaimed automatically past RESERVATION_TTL_SECONDS (default 900s), via
    npm run sweep or the new admin-gated POST /api/sweep. Idempotent: contends on the reservation
    row under OCC exactly like a normal release(), so it can never double-refund a hold another
    process is settling.

Fixed

  • Stub server: sharded accounts now enforce the same policy as everyone else. A sharded budget
    account previously skipped the frozen check, the policy engine, the velocity breaker, and
    ancestor hierarchy caps entirely — only the shard-level cap was enforced. Fixed to match the
    plain spend path exactly; /api/spend now dispatches to the sharded path automatically for any
    account provisioned with provisionShards.

trystub 1.1.0

Choose a tag to compare

@ashutosh887 ashutosh887 released this 31 Jul 04:54

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

trystub 1.0.2

Choose a tag to compare

@ashutosh887 ashutosh887 released this 05 Jul 09:06

SDK discoverability release (no API changes).

  • Expanded npm keywords (8 to 19) for better search ranking.
  • Added bugs URL and publishConfig.access.
  • README: status badges and a link to the build story.

Published on npm with provenance: https://www.npmjs.com/package/trystub/v/1.0.2

trystub 1.0.1

Choose a tag to compare

@ashutosh887 ashutosh887 released this 05 Jul 09:06

SDK documentation release.

  • README now leads with the tagline and clearer usage.

trystub 1.0.0

Choose a tag to compare

@ashutosh887 ashutosh887 released this 29 Jun 10:21

First public release of the trystub SDK — a drop-in budget gate for autonomous AI agents.

npm install trystub
  • StubClient: guard / spend / reserve / settle / release
  • payThroughStub (x402): reserve → pay once → settle, exactly-once around an irreversible payment
  • Dependency-free; works anywhere fetch exists

npm: https://www.npmjs.com/package/trystub