feat(agentswarm): M4 — per-agent budget ledger + withBudget guard

BudgetLedger interface + InMemoryBudgetLedger reference impl (reserve/settle/
release with refund of unused holds; mirrors the b1dz budget+ledger concept).
withBudget() wraps any SwarmRunner: reserves up front (throws SwarmError 402 when
out of funds, before running), settles actual cost on success, releases on error.
AgentIdentity DID aligns with @logicsrc/agentstack.

8 new tests; 27/27 pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Anthony Ettinger 2026-06-25 17:45:19 +00:00
parent 925894359f
commit dd7fe0b5c4
3 changed files with 202 additions and 0 deletions

View file

@ -17,6 +17,8 @@ export type {
SwarmOptions,
LLMRouterOptions
} from "./swarm.js";
export { InMemoryBudgetLedger, withBudget } from "./budget.js";
export type { AgentIdentity, BudgetLedger, BudgetRunnerOptions } from "./budget.js";
export { createRubricRunner, createLLMJudge } from "./rubric.js";
export type {
RubricEvaluation,