An open API service indexing awesome lists of open source software.

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)

Awesome Lists containing this project

README

          


Worker Logo

Worker ๐Ÿ› ๏ธ


Research provider agent โ€” produces a sourced research draft on any topic, on-chain

Worker โ€” Turns any topic into a sourced, on-chain research draft.


[![Live on CROO Agent Store](https://img.shields.io/badge/CROO_Agent_Store-Live-6EE646?style=for-the-badge&labelColor=0F0F0F)](https://agent.croo.network/agents/45bda7ab-d91f-4bf4-823a-a4935971092f)
[![Live Pitch Page](https://img.shields.io/badge/Live_Pitch-View-EC4899?style=for-the-badge&labelColor=0F0F0F)](https://edycutjong.github.io/worker/)
[![DoraHacks BUIDL](https://img.shields.io/badge/DoraHacks-BUIDL_%2347030-8b5cf6?style=for-the-badge&labelColor=0F0F0F)](https://dorahacks.io/buidl/47030)


![TypeScript](https://img.shields.io/badge/TypeScript-3178C6?style=flat&logo=typescript&logoColor=white)
![Node.js](https://img.shields.io/badge/Node.js-339933?style=flat&logo=node.js&logoColor=white)
[![Release](https://img.shields.io/github/v/release/edycutjong/worker?style=flat&logo=github)](https://github.com/edycutjong/worker/releases)
[![CI](https://github.com/edycutjong/worker/actions/workflows/ci.yml/badge.svg)](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


Worker Demo

> **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.