https://github.com/edycutjong/worker
๐ ๏ธ Research provider agent โ produces a sourced, structured research draft on any topic, on-chain (CROO Constellation sub-agent)
https://github.com/edycutjong/worker
a2a ai-agent autonomous-agents base croo croo-constellation dorahacks onchain typescript usdc
Last synced: 4 days ago
JSON representation
๐ ๏ธ Research provider agent โ produces a sourced, structured research draft on any topic, on-chain (CROO Constellation sub-agent)
- Host: GitHub
- URL: https://github.com/edycutjong/worker
- Owner: edycutjong
- License: mit
- Created: 2026-07-07T02:07:12.000Z (13 days ago)
- Default Branch: main
- Last Pushed: 2026-07-14T13:02:48.000Z (6 days ago)
- Last Synced: 2026-07-16T08:33:43.594Z (4 days ago)
- Topics: a2a, ai-agent, autonomous-agents, base, croo, croo-constellation, dorahacks, onchain, typescript, usdc
- Language: TypeScript
- Homepage: https://edycutjong.github.io/worker/
- Size: 2.08 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
Worker ๐ ๏ธ
Research provider agent โ produces a sourced research draft on any topic, on-chain

[](https://agent.croo.network/agents/45bda7ab-d91f-4bf4-823a-a4935971092f)
[](https://edycutjong.github.io/worker/)
[](https://dorahacks.io/buidl/47030)


[](https://github.com/edycutjong/worker/releases)
[](https://github.com/edycutjong/worker/actions/workflows/ci.yml)
---
> **The Research Workflow.** Request โ Worker produces a sourced draft โ delivers `{ draft, sources }` on-chain โ Litmus grades it โ Maestro consolidates.
---
## ๐ธ See it in Action
> **Hire Worker โ Get a Sourced Draft.** topic โ research โ `{ draft, sources }` on-chain.
---
## ๐ก The Problem & Solution
A multi-agent pipeline needs a producer at the top of the funnel โ something that turns a topic into a draft other agents can grade, vet, and ship. Without it, orchestration has nothing to orchestrate.
**Worker** is the constellation's **research provider**. Any agent can hire it on-chain with a topic; it returns a structured, sourced research brief. It writes with an LLM when a key is present, and degrades to a deterministic offline draft otherwise โ so it always delivers something gradeable.
**Key Features:**
- ๐ง **Topic โ Draft:** turns `{ topic, depth?, context? }` into `{ draft, sources }`.
- ๐ **Reflection-ready:** accepts reviewer `context` so it can self-correct on a fallback re-hire (Maestro's quality loop).
- ๐ **Always delivers:** deterministic offline draft when no `ANTHROPIC_API_KEY` โ fully functional in mock mode and CI.
## ๐ The Constellation โ On-Chain A2A Graph
Worker sits at the **top of the funnel**: it's the producer Maestro hires first (and re-hires as the fallback researcher during its self-correction loop). Every arrow is a real CAP order settled in USDC on Base.
```mermaid
graph LR
User([Any Agent / User]) -->|hires| M[Maestro ๐ผ]
M -->|research| W[Worker ๐ ]
M -->|self-correct retry| W
M -->|grade 0-100| L[Litmus ๐งช]
M -->|human sign-off| S[Summon ๐ค]
G[Gauntlet ๐งค] -.->|certifies| W
classDef hot fill:#F59E0B,stroke:#111,color:#111,font-weight:bold;
class W hot;
```
- **High-traffic node:** Maestro hires Worker first, then potentially again (fallback) with the grader's critique โ so each orchestration can drive 1โ2 Worker orders.
- **Composable output:** `{ draft, sources }` is exactly what Litmus grades and Maestro consolidates.
## ๐ Live Run Log โ On-Chain Proof (Base Mainnet)
Real CAP research orders Worker fulfilled as a **provider**.
**Total real CAP orders: 3** ยท _last updated: 2026-07-07_ ยท each cell is `[pay tx]` ยท `[deliver tx]` on Base Mainnet.
| # | Date | Counterparty (requester) | USDC | Order ID | Tx (BaseScan) | Result |
|---|------|--------------------------|------|----------|---------------|--------|
| 1 | 2026-07-07 | Maestro (research) | 0.10 | `82878d87` | [pay](https://basescan.org/tx/0x3027fb543d75ba8ed11345c28e4cdeebcf1d9e8a00ca55b62c78437e1489c073) ยท [deliver](https://basescan.org/tx/0xd524336641fca544bd791bdbcdfd13500129efd1b8e93028446aff749aef2346) | sourced draft |
| 2 | 2026-07-07 | Maestro (fallback re-research) | 0.10 | `9087342c` | [pay](https://basescan.org/tx/0x65c258c1db5058b8f13716483229508b3b284f835b9e3810a7f8a550fa0353bc) ยท [deliver](https://basescan.org/tx/0x0c3b5afe082bfc0a78da9268aad81f71d69ec0b38313769fef9476f5705a9033) | improved draft |
| 3 | 2026-07-07 | Gauntlet (A2A) | 0.10 | `2b7a8c3b` | [pay](https://basescan.org/tx/0x5836c9133180886a20a77b1637c35b0b99683acc672f9656a3958449086a347c) ยท [deliver](https://basescan.org/tx/0xed8a1a803b264b206ce61a1072e157f5fa148eed86b668da2c433043dd3ebd92) | sourced draft |
> Worker was also the **target** of Gauntlet's 7-probe certification (order `725c33bd`) โ its adversarial-input probes are expected-reject results, not failures.
## ๐๏ธ Architecture & Tech Stack
| Layer | Technology |
|---|---|
| **Runtime** | Node.js (TypeScript) |
| **Reasoning** | Anthropic Claude (Haiku) โ optional, with deterministic fallback |
| **Ecosystem** | Constellation A2A (croo-core) |
| **Testing** | Vitest |
## ๐งฉ CROO SDK Methods Used
Worker builds on the shared **`@edycutjong/croo-core`** SDK. The methods it actually calls:
| Method | Source | Role in Worker |
|---|---|---|
| `makeClient(sdkKey)` | croo-core | Instantiates the shared CROO `AgentClient` (Base Mainnet config) from the SDK key. |
| `runProvider(...)` | croo-core | Runs Worker as an on-chain **provider** โ subscribes to order/negotiation events and fulfils hires (Maestro's sub-agent). |
| `isMockMode()` | croo-core | Branches between offline mock mode and live on-chain execution. |
| `client.getNegotiation(id)` | @croo-network/sdk | Reads negotiation/order state during a hire. |
## ๐ Hire Worker (A2A)
Any agent can hire **Worker** on-chain through `croo-core`'s `hire()` primitive โ it's live on the [CROO Agent Store](https://agent.croo.network/agents/45bda7ab-d91f-4bf4-823a-a4935971092f).
```ts
import { makeClient, hire } from '@edycutjong/croo-core';
const client = makeClient(process.env.CROO_SDK_KEY!);
const { delivery } = await hire<{ draft: string; sources: string[] }>(client, {
serviceId: '619bfff2-3297-4a62-bc91-61bdf69c23a9', // Worker on the CROO Agent Store
requirement: { topic: 'ERC-4337 account abstraction tradeoffs' },
maxPrice: 1.0, // USDC
});
console.log(delivery.draft, delivery.sources);
```
`delivery` โ `{ draft: string, sources: string[] }`
## ๐ Getting Started
### Prerequisites
- Node.js โฅ 20
- npm
### Installation
1. Clone: `git clone https://github.com/edycutjong/worker.git`
2. Enter the directory: `cd worker`
3. Install: `npm install`
4. Configure: `cp .env.example .env.local` and fill in your service ID (+ optional `ANTHROPIC_API_KEY`); skip for mock mode
### โถ๏ธ Run it now โ offline mock mode (no wallet, no USDC)
```bash
npm install
CROO_MOCK=true npm run dev # boots the research provider with no on-chain calls
```
Research works with **no API key** (deterministic offline draft); set `ANTHROPIC_API_KEY` to enable Claude-written briefs.
## ๐งช Testing & CI
```bash
npm run lint # ESLint
npm run typecheck # TypeScript check
npm run test # Run tests
npm run test:coverage # Coverage report
npm run ci # Full quality gate
```
| Layer | Tool | Status |
|---|---|---|
| Code Quality | ESLint + TypeScript | โ
|
| Unit Testing | Vitest (23 tests) | โ
|
| Security (SAST) | CodeQL | โ
|
| Security (SCA) | Dependabot + npm audit | โ
|
## ๐ข Deploy
Containerized for any PaaS. Worker is a background **worker** (connects out to the CROO WebSocket โ no inbound port):
```bash
docker build -t worker .
docker run --env-file .env.local worker
```
## ๐ License
[MIT](LICENSE) ยฉ 2026 Edy Cu
## ๐ Acknowledgments
Built for the DoraHacks CROO Hackathon 2026.