Skip to content

ajanaku1/Guild

Repository files navigation

Guild

The coordination-and-trust layer for the CROO agent economy. Three pillars in one monorepo: a discovery Registry that agents can query, a general contractor (Foreman) that assembles a crew and delivers one synthesized result, and a verification oracle (Notary) that independently checks another agent's work before you trust it.

TypeScript Node Base Tests License: MIT

Built for the CROO Agent Hackathon. MIT licensed. Runs headless, no UI.

The gap Guild fills

CROO's own docs name two structural holes in the agent economy, and the store bears them out. It is full of single-shot leaf agents (pay 0.10 USDC, get one report) with nothing connecting them:

  1. An agent can't find another agent. CROO's store has a search box and a Navigator, but they're gated behind a human wallet-login session. An autonomous agent holds only its SDK-key, and that key gets 401 NOT_LOGIN from the discovery backend (/backend/v1/services) — verified. The SDK also exposes no listServices. Discovery exists for people, not for agents; there's nothing an agent can call at runtime to find a counterparty.
  2. There's no way to check a deliverable. CAP's only native proof is a keccak256 hash of the output. It proves what was delivered, not that it's correct, and delivery auto-settles with no quality arbitration.

Guild builds the missing pieces instead of assuming they exist. The Registry is the discovery layer (#1). Notary is the verification layer (#2). Foreman is the agent that ties them together, and the two agents are the live, on-chain proof that the Registry works.

How it fits together

flowchart LR
  Buyer([Buyer]) -->|hire: goal + budget| Foreman
  subgraph Guild
    Foreman -->|discover by skill/price/SLA| Registry[(Guild Registry)]
    Registry -->|ranked crew| Foreman
    Foreman -->|subcontract in parallel| Workers[External CROO agents]
    Workers -->|deliverable + hash| Foreman
    Foreman -->|verify each| Notary
    Notary -->|self-register| Registry
    Notary -->|verdict + on-chain hash check| Foreman
  end
  Foreman -->|one synthesized dossier + receipts| Buyer
Loading

The journey Foreman runs on every order:

  1. Plan. An LLM decomposes the goal + budget into subtasks with skill-tag queries.
  2. Discover. It queries the Guild Registry (discover()), which returns candidates ranked by a reverse auction: price × completion% × SLA.
  3. Subcontract. It hires the winners in parallel over CAP (negotiate, pay, deliver), bounded by a spend guard with integer micro-USDC math (per-order cap plus a pre-flight purse check).
  4. Verify. Every sub-deliverable is routed through Notary. It recomputes the keccak256 hash against the on-chain anchor (a deterministic tamper gate that never asks an LLM), then runs an adversarial critique and source cross-check.
  5. Synthesize. One dossier, with a clickable Base tx for every subcontract.

A sub-order that can't be discovered, budgeted, or delivered within its SLA slice becomes a noted gap in the dossier. It never crashes the run. Foreman's own SLA is split across the worker leg, the sequential Notary leg, and a synthesis buffer, so it always clears its promise to the buyer.

Tech Stack

Layer Technology
Language TypeScript 5.7 (strict, no any), Node 18+
Monorepo pnpm workspaces, TS project references
Agent protocol CROO CAP via @croo-network/sdk
Chain Base mainnet, USDC, keccak256 hashing (viem)
LLM Anthropic Messages API (plan / synthesize / critique)
Source check Tavily (Notary corroboration)
Tests Vitest (115 across the workspace)

Quickstart (offline, no credentials)

The whole coordination logic runs without CROO keys or a network. Only the CAP transport and the LLM are stubbed:

pnpm install
pnpm demo

You'll watch agents self-register, Foreman discover and hire a crew, Notary verify each result (including a tamper case caught by the hash gate), and a dossier get synthesized with receipts. See only the discovery layer with pnpm example:registry.

@guild/shared: the reusable CAP layer

Both agents are thin; the plumbing lives here.

Export What it does
RegistryClient register() / discover() / health() against the Registry
scoreCandidates / rankMatches reverse-auction scoring plus filter/rank
parseRegistration / isServiceEntry validate self-attested service entries
serve(client, handler) generic provider loop: accept, run handler, deliver
hire(client, req, opts) requester helper: negotiate, pay, getDelivery
SpendGuard per-order cap + cumulative purse gating (atomic reserve)
computeContentHash / verifyContentHash keccak256 deliverable hash + compare
readUsdcBalance live USDC purse read on Base (viem)
createLlm LLM messages wrapper
loadAgentConfig / createClient CROO AgentClient from env, per-agent key

Running live on CROO

Agent + service registration is Dashboard-only. See scripts/register-services.md for the full walk-through (create two agents, configure services, fund the AA wallets). Then:

cp .env.example .env    # fill in SDK keys, service IDs, LLM key, REGISTRY_URL
pnpm registry           # discovery service
pnpm notary             # self-registers into the Registry, then serves
pnpm foreman            # discovers its crew via the Registry, then serves
pnpm example:hire "Assess token XYZ for an investment memo"

Layout

packages/
  shared/    @guild/shared    reusable CAP + discovery layer (client, provider, hire,
                              registry client, scoring, spend guard, hash, llm)
  registry/  @guild/registry  the discovery service: store + router + server + seed
  foreman/   @guild/foreman   plan -> orchestrate -> dossier
  notary/    @guild/notary    verify (hash gate + critique + sources) + handler
scripts/     demo.ts · register-services.md
examples/    query-registry.ts · hire-foreman.ts

Tests

pnpm test        # vitest, all packages
pnpm typecheck   # tsc -b across the workspace

The suite covers the reverse-auction scoring, spend-guard math, the Notary tamper case (mismatched hash to fail), Foreman's SLA-cascade math, and graceful degradation when a sub-order times out.

Constraints Guild is built around

CAP fixes prices at the service level before work (flat tiers, no cost-plus); SLAs are at least 300s with auto-refund on timeout; delivery auto-settles with no dispute (which is why Notary exists); registration is Dashboard-only; Base mainnet only (USDC 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913), gas sponsored by the Paymaster.

License

MIT. See LICENSE.

About

Coordination-and-trust layer for the CROO agent economy: an agent-callable discovery Registry, a contractor agent (Foreman), and a verification oracle (Notary) on Base + USDC.

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors