Building an Agent Delegation Broker: scoped signing authority for TAP agents A developer built the Agent Delegation Broker, an open-source reference implementation that lets a main TAP agent mint signed, policy-bound Ed25519 tokens for sub-agents, with the broker verifying signatures, enforcing per-request policy such as endpoint and spend caps, revoking tokens on demand, and maintaining an audit trail. The MVP runs on Node.js 22 with Hono and tweetnacl, stores tokens and audits in in-memory Maps with no database, and ships with an interactive browser demo; the developer notes it lacks auth, replay protection and persistent keys, and also documented an ESM/CJS interop fix for tweetnacl-util on Node 22. Every app in the TAP ecosystem gets its own agent. But there's no delegation primitive: a main agent can't spawn sub-agents with scoped permissions. Without delegation, every sub-agent would need its own key and its own card step — which doesn't scale to multi-agent workflows. The Agent Delegation Broker is a small runnable reference that closes that gap. A main agent mints a signed, policy-bound token for a sub-agent; the broker verifies the signature, enforces the policy on each request, revokes on demand, and keeps an audit trail. I also built an interactive browser demo so the flow is visible rather than abstract, and fixed an ESM/CJS interop bug along the way that's worth documenting for anyone shipping tweetnacl-util on Node 22. Status: MVP, not production. Keys are in-memory, no auth, no replay protection. See the roadmap at the end. | Layer | Technology | Reason | |---|---|---| | Runtime | Node.js 22 | LTS, native crypto.randomUUID | | Language | TypeScript 5.5 strict, NodeNext ESM | Type-safe service layer | | HTTP | Hono 4 + @hono/node-server | Tiny, fast, serveStatic for the demo | | Crypto | tweetnacl Ed25519 + tweetnacl-util | Small, audited base64 + signing helpers | | Tooling | tsx, Vitest, ESLint, drizzle-kit | Hot reload, tests, lint, migrations | | Extras installed | Zod, pino, Drizzle + postgres.js | Ready to wire in later | | Demo | Vanilla HTML/CSS/JS | No build step, same-origin | | Packaging | Multi-stage Docker node:22-alpine | Slim runtime with dist/ + demo/ | Deliberate choice: no database . Three in-memory Map s tokens , audits remove all setup friction for a reference. src/db.ts is scaffolding for the day persistence is needed. ┌─────────────────────┐ fetch JSON ┌──────────────────────────────┐ │ Browser demo UI │ ───────────────────────► │ Hono app src/server.ts │ │ demo/index.html │ ◄─────────────────────── │ REST routes + serveStatic │ └─────────────────────┘ JSON responses └──────────────┬───────────────┘ │ imports ▼ ┌──────────────────────────────┐ │ Service layer │ │ src/services/delegation.ts │ │ Ed25519 sign/verify, Maps, │ │ policy logic, audit log │ └──────────────┬───────────────┘ ▼ ┌──────────────────────────────┐ │ tweetnacl / tweetnacl-util │ │ Types src/types.ts │ └──────────────────────────────┘ Lifecycle: Main agent Broker routes Service layer Maps │ │ │ │── POST /delegate ──────►│ │ │ │── mintToken ──────────────►│ sign JSON token │◄── { token + signature }│◄─────────────────────────────│ tokens.set id,… │ Sub-agent presents token │ audits.push mint │── GET /verify/:id ─────►│── verifyToken ────────────►│ verify signature │◄── { chain, verified } ─│◄─────────────────────────────│ audits.push verify │── POST /check ─────────►│── checkPolicy ────────────►│ endpoint + spendCap │◄── { allowed } ─────────│◄─────────────────────────────│ audits.push violation? │── POST /revoke/:id ────►│── revokeToken ────────────►│ revoked = true │◄── { revoked } ─────────│◄─────────────────────────────│ audits.push revoke Three decisions worth calling out: server.ts checks required fields and delegates. Business logic is testable over HTTP-free. services/delegation.ts , which owns the keypair and every sign/verify call. serveStatic serves demo/index.html from the same Hono process — no CORS, no second dev server. python // src/index.ts import { serve } from '@hono/node-server' import app from './server.js' const PORT = Number process.env.PORT || 3000 serve { fetch: app.fetch, port: PORT }, info = { console.log Agent Delegation Broker listening on :${info.port} } js // src/server.ts excerpt const app = new Hono app.use '/demo/ ', serveStatic { root: './' } app.get '/demo', serveStatic { path: './demo/index.html' } app.post '/delegate', async c: Context = { const body = await c.req.json const { mainAgentId, subAgentId, policy } = body if mainAgentId || subAgentId || policy { return c.json { code: 'invalid request', detail: 'Missing …' }, 400 } const token = mintToken mainAgentId, subAgentId, policy return c.json { token }, 201 } Small details like 201 Created and a 401 on invalid tokens make the API feel real to consumers and to the demo. python // src/services/delegation.ts excerpt import nacl from 'tweetnacl' import naclUtil from 'tweetnacl-util' // tweetnacl-util is CommonJS export = util ; Node's ESM loader cannot // provide named exports, so use the default namespace import instead. const { encodeBase64, decodeBase64 } = naclUtil const keyPair = nacl.sign.keyPair function signToken token: Omit