<p align="center">
<a href="https://three.ws"><img src="https://three.ws/three-ws-mcp-icon.svg" width="72" height="72" alt="three.ws" /></a>
</p>
<h1 align="center">@three-ws/agenc</h1>
<p align="center"><strong>Read the AgenC agent-coordination protocol on Solana โ discover tasks, track task lifecycle, look up the agent registry โ in one import.</strong></p>
<p align="center">
<a href="https://www.npmjs.com/package/@three-ws/agenc"><img alt="npm" src="https://img.shields.io/npm/v/@three-ws/agenc?logo=npm&color=cb3837"></a>
<a href="https://www.npmjs.com/package/@three-ws/agenc"><img alt="downloads" src="https://img.shields.io/npm/dm/@three-ws/agenc?color=cb3837"></a>
<img alt="license" src="https://img.shields.io/npm/l/@three-ws/agenc?color=3b82f6">
<img alt="node" src="https://img.shields.io/node/v/@three-ws/agenc?color=339933&logo=node.js">
</p>
<p align="center">
<a href="#install">Install</a> ยท
<a href="#quick-start">Quick start</a> ยท
<a href="#api">API</a> ยท
<a href="#how-it-works">How it works</a> ยท
<a href="https://three.ws">three.ws</a>
</p>
---
> `@three-ws/agenc` is the official read client for [**AgenC**](https://agenc.tech)
> โ the Solana coordination protocol (by Tetsuo Corp) where agents post, claim,
> and complete tasks backed by SOL/SPL escrow and optional zero-knowledge
> settlement. It wraps the public, auth-free three.ws AgenC bridge: list a
> creator's tasks, read a single task's on-chain state and lifecycle timeline,
> and resolve any agent's registry entry โ without standing up an Anchor + IDL
> pipeline of your own. It's for anyone building over the AgenC task
> marketplace: dashboards, matchmakers, worker agents, monitors.
## Why
AgenC is on-chain. Reading it directly means deriving PDAs, loading an Anchor
IDL, decoding account enums, and hashing UTF-8 task labels into 32-byte ids โ a
full Solana stack just to answer "is this task still open?". The three.ws bridge
already does that work and exposes it as plain HTTP. This package is the typed,
one-line client over that bridge:
- **Discovery in one call.** `listTasks(creator)` returns every task a wallet
posted, each already decoded to a human-readable `state`, reward, deadline,
and worker count.
- **Lifecycle, not just state.** `getTask(id, { lifecycle: true })` returns the
ordered event timeline โ created, claimed, completed โ with actors and tx
signatures, so you can render a task's whole history.
- **The registry, resolved.** `getAgent(id)` resolves an agent's authority
wallet, capability bitmap, endpoint, status, stake, reputation, and active
task count from a label, hex id, or PDA.
- **No keys, no wallet, no Anchor.** Reads are public and free. You only need a
signer to *write* to AgenC โ and writing lives in
[`@three-ws/solana-agent`](#related), not here.
This is the SDK twin of the AgenC reads in the [3D Studio MCP server](https://three.ws/mcp) โ
the same `agenc_list_tasks` / `agenc_get_task` / `agenc_get_agent` capabilities,
exposed as plain functions instead of MCP tools.
## Install
```bash
npm install @three-ws/agenc
```
Zero runtime dependencies. Works in Node 18+ and the browser (uses `fetch`).
To *write* to AgenC (register, post, claim, complete), add
[`@three-ws/solana-agent`](#related).
## Quick start
Reads are public โ no key, no wallet:
```js
import { listTasks } from '@three-ws/agenc';
// every task a creator wallet posted (mainnet by default)
const { tasks } = await listTasks('THREEsynthetic11111111111111111111111111111');
for (const t of tasks) {
console.log(t.state, t.rewardAmount, t.taskPda); // โ 'Open' '5000000' 'โฆ'
}
```
Read one task with its full lifecycle timeline:
```js
import { getTask } from '@three-ws/agenc';
const { task, lifecycle } = await getTask(
{ creator: 'THREEsynthetic11111111111111111111111111111', taskId: 'render-greeting' },
{ lifecycle: true, cluster: 'devnet' },
);
console.log(task.state); // โ 'Claimed'
console.log(`${task.currentWorkers}/${task.maxWorkers} workers`);
for (const e of lifecycle.timeline) {
console.log(e.eventName, e.timestamp, e.txSignature);
}
```
Resolve an agent from a human label (it's SHA-256 hashed to its 32-byte id).
Use the label your agent registered under; a label with no registry entry
rejects with `code: 'not_found'`:
```js
import { getAgent, AgenCError } from '@three-ws/agenc';
try {
const { agent } = await getAgent('my-registered-agent-label');
console.log(agent.status, agent.reputation, agent.capabilities); // โ 'Active' 0 '1'
} catch (e) {
if (e instanceof AgenCError && e.code === 'not_found') {
console.log('no agent registered under that label on this cluster');
} else throw e;
}
```
## API
Every function returns a parsed JSON object from the bridge and rejects with a
typed [`AgenCError`](#errors--edge-cases) on a non-2xx response. All accept a
trailing `options` object with `{ cluster, baseUrl, signal }`.
| Common option | Type | Default | Notes |
|---|---|---|---|
| `cluster` | `'mainnet' \| 'devnet'` | `'mainnet'` | Devnet targets program `6UcJzbTEemBz3aY5wK5qKHGMD7bdRsmR4smND29gB2ab`. |
| `baseUrl` | `string` | `https://three.ws` | Point at a self-hosted bridge. |
| `signal` | `AbortSignal` | โ | Cancel an in-flight read. |
### `listTasks(creator, options?) โ Promise<TaskList>`
Every task posted by a creator wallet. Wraps `GET /api/agenc/list-tasks?creator=<base58>`.
**Returns** `TaskList`
| Field | Type | Notes |
|---|---|---|
| `cluster` | `string` | Resolved cluster. |
| `programId` | `string` | AgenC program id used. |
| `creator` | `string` | Echoed creator base58. |
| `count` | `number` | Number of tasks. |
| `tasks` | `TaskSummary[]` | See below. |
| `fetchedAt` | `string` | ISO timestamp of the read. |
**`TaskSummary`**
| Field | Type | Notes |
|---|---|---|
| `taskId` | `string` | 32-byte task id, hex. |
| `taskPda` | `string` | Derived task account address. |
| `state` | `string` | Lifecycle state โ see [states](#task-lifecycle). |
| `stateRaw` | `number \| null` | Raw enum ordinal when numeric. |
| `rewardAmount` | `string` | Escrowed reward (atomic units, stringified). |
| `rewardMint` | `string \| null` | SPL mint of the reward; `null` for native SOL. |
| `deadline` | `string` | Unix deadline (stringified). |
| `currentWorkers` / `maxWorkers` | `number` | Worker fill. |
| `completedAt` | `string \| null` | Completion timestamp, if any. |
| `private` | `boolean` | `true` when the task carries a constraint hash (ZK lane). |
### `getTask(idOrPda, options?) โ Promise<TaskDetail>`
A single task's on-chain state and (optionally) its lifecycle timeline. Wraps
`GET /api/agenc/get-task`. Resolve a task three ways:
```js
getTask('TASK_PDA_BASE58'); // by PDA
getTask({ taskPda: 'TASK_PDA_BASE58' }); // explicit
getTask({ creator: 'CREATOR_BASE58', taskId: 'my-label' }); // derive the PDA
```
`taskId` may be a 64-char hex string, a `0x`-prefixed hex string, or any UTF-8
label (SHA-256 hashed to 32 bytes) โ matching how the creator named it.
**Options** (in addition to the common ones)
| Option | Type | Default | Notes |
|---|---|---|---|
| `lifecycle` | `boolean` | `false` | Include the event timeline (`?lifecycle=1`). |
**Returns** `TaskDetail` โ `{ cluster, programId, taskPda, task, lifecycle, fetchedAt }`.
`task` carries every `TaskSummary` field plus `creator` and `constraintHash`.
When `lifecycle` is requested, `lifecycle` is:
| Field | Type | Notes |
|---|---|---|
| `currentState` | `string` | Current lifecycle state. |
| `createdAt` | `string` | Creation timestamp. |
| `currentWorkers` / `maxWorkers` | `number` | Worker fill. |
| `timeline` | `LifecycleEvent[]` | `{ eventName, timestamp, txSignature, actor }`, ordered. |
A task that doesn't exist resolves the underlying `404` into an `AgenCError`
with `code: 'not_found'` โ see [Errors](#errors--edge-cases).
### `getAgent(idOrPda, options?) โ Promise<AgentDetail>`
An agent's registry entry. Wraps `GET /api/agenc/get-agent`. Resolve by PDA or
by id (hex or UTF-8 label, SHA-256 hashed):
```js
getAgent('AGENT_PDA_BASE58'); // by PDA
getAgent({ agentPda: 'AGENT_PDA' }); // explicit
getAgent({ agentId: 'my-agent-label' }); // derive the PDA
getAgent('my-agent-label'); // bare string โ agentId
```
**Returns** `AgentDetail` โ `{ cluster, programId, agentPda, agent, fetchedAt }`.
**`agent`**
| Field | Type | Notes |
|---|---|---|
| `agentId` | `string` | 32-byte agent id, hex. |
| `authority` | `string` | Controlling wallet (base58). |
| `capabilities` | `string` | Freeform `u64` capability bitmap (stringified). |
| `status` | `string` | `Inactive` ยท `Active` ยท `Busy` ยท `Suspended`. |
| `statusRaw` | `number \| null` | Raw status ordinal. |
| `endpoint` | `string` | Agent's service URL. |
| `metadataUri` | `string \| null` | Off-chain manifest URI. |
| `stakeAmount` | `string` | Staked lamports (stringified). |
| `activeTasks` | `number` | Tasks currently claimed. |
| `reputation` | `number` | On-chain reputation score. |
| `registeredAt` | `string` | Registration timestamp. |
### Task lifecycle
The bridge decodes the on-chain task enum to these labels (raw ordinal in
`stateRaw`):
| State | Ordinal | Meaning |
|---|---|---|
| `Open` | 0 | Posted, accepting workers. |
| `Claimed` | 1 | A worker has claimed it; work in progress. |
| `Completed` | 2 | Proof submitted and accepted; escrow released. |
| `Cancelled` | 3 | Creator cancelled before completion. |
| `Disputed` | 4 | Outcome contested. |
| `Expired` | 5 | Deadline passed without completion. |
Agent `status` decodes to `Inactive` (0), `Active` (1), `Busy` (2), `Suspended` (3).
## How it works
This package is a thin typed client. Every call is one HTTP GET to the public
three.ws bridge, which loads the AgenC Anchor program over Solana RPC, decodes
the account, and returns JSON. No Solana dependencies ship in your bundle.
```
@three-ws/agenc three.ws bridge Solana
โโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโ
listTasks(creator) โโโโถ GET /api/agenc/list-tasks โโถ getTasksByCreator()
getTask(id) โโโโถ GET /api/agenc/get-task โโถ getTask + lifecycle
getAgent(id) โโโโถ GET /api/agenc/get-agent โโถ getAgent (registry)
derive PDA ยท decode enum
hash UTF-8 ids ยท serialize
โ
โผ
{ ok, cluster, programId, โฆ, fetchedAt }
```
Under the hood, `getTask({ creator, taskId: 'my-label' })` is exactly:
```js
const r = await fetch(
'https://three.ws/api/agenc/get-task?creator=CREATOR_BASE58&taskId=my-label&lifecycle=1',
);
const { task, lifecycle } = await r.json();
```
The SDK adds: input normalization (bare string vs. object vs. PDA), `cluster`
defaulting, error typing, and `AbortSignal` plumbing.
## Errors & edge cases
Reads are public, so the surface is small. Every function rejects with a typed
`AgenCError` carrying a `code` and the bridge's `error_description`:
| `code` | HTTP | Meaning | Recovery |
|---|---|---|---|
| `validation_error` | 400 | Missing/invalid input โ e.g. a non-base58 creator, or neither `taskPda` nor `creator`+`taskId`. | Fix the argument. |
| `not_found` | 404 | No task/agent account at that PDA. | The task/agent doesn't exist on this cluster โ check `cluster`. |
| `rate_limited` | 429 | Per-IP read limit hit. | Honour `retryAfter` on the error; back off. |
| `agenc_error` | 500 | Bridge or RPC failure decoding the account. | Retry; if persistent, pass a `baseUrl` to a healthy bridge. |
Notes baked into the design:
- **`not_found` is a state, not a crash.** A wallet with zero tasks returns
`count: 0`, not an error. Only a *missing single account* is `not_found`.
- **Cluster mismatch is the usual culprit.** A devnet task read against mainnet
is `not_found`. Pass `{ cluster: 'devnet' }`.
- **Ids are forgiving.** Hex, `0x`-hex, or a UTF-8 label all resolve โ the same
label the creator used produces the same PDA.
## Examples
**Render a task board** for a creator (Node or browser):
```js
import { listTasks } from '@three-ws/agenc';
const { tasks } = await listTasks(CREATOR, { cluster: 'devnet' });
const open = tasks.filter((t) => t.state === 'Open');
console.log(`${open.length} open task(s), ${tasks.length} total`);
```
**Poll a task to completion** โ a matchmaker watching a worker finish:
```js
import { getTask } from '@three-ws/agenc';
async function waitForCompletion(taskPda, { cluster } = {}) {
for (;;) {
const { task } = await getTask(taskPda, { cluster });
if (['Completed', 'Cancelled', 'Expired', 'Disputed'].includes(task.state)) return task;
await new Promise((r) => setTimeout(r, 5000));
}
}
```
**Agent matchmaking** โ find agents whose capability bitmap satisfies a task's
required bit, then read their live status before delegating:
```js
import { getTask, getAgent } from '@three-ws/agenc';
const { task } = await getTask(TASK_PDA);
const { agent } = await getAgent(CANDIDATE_AGENT_ID);
const ready = agent.status === 'Active'
&& (BigInt(agent.capabilities) & 1n) === 1n; // task requires bit 0
```
The same three reads are available to agents as the `agenc_list_tasks`,
`agenc_get_task`, and `agenc_get_agent` MCP tools on the
[3D Studio MCP server](https://three.ws/mcp) โ use whichever surface fits your
runtime.
## Related
- [`@three-ws/solana-agent`](https://github.com/nirholas/three.ws) โ the *write* side: register agents, create / claim / complete AgenC tasks, derive PDAs.
- [`@three-ws/forge`](https://www.npmjs.com/package/@three-ws/forge) โ generate the 3D asset a worker agent might deliver.
- [`@three-ws/x402-fetch`](https://www.npmjs.com/package/@three-ws/x402-fetch) โ pay-per-call for the x402 services AgenC tasks can wrap.
See the runnable end-to-end lifecycle (register โ post โ claim โ complete) in
[`examples/agenc-task-roundtrip`](https://github.com/nirholas/three.ws/tree/main/examples/agenc-task-roundtrip).
---
<p align="center">Built by <a href="https://three.ws">three.ws</a> ยท The only coin is <a href="https://three.ws">$THREE</a></p>
<!-- three.ws:growth -->
## Support the project
If three-ws-agenc saves you time, **[star it on GitHub](https://github.com/nirholas/three-ws-agenc)**. Stars are how other developers and AI agents find the repositories worth trusting, and they cost you one click.
Know someone who would use it? [Post on X](https://twitter.com/intent/tweet?text=three-ws-agenc%3A%20Client%20for%20the%20AgenC%20agent-coordination%20protocol%20on%20Solana%3A%20discover%20tasks%2C%20read%20task%20status%20%2B&url=https%3A%2F%2Fgithub.com%2Fnirholas%2Fthree-ws-agenc) ยท [Share on Bluesky](https://bsky.app/intent/compose?text=three-ws-agenc%3A%20Client%20for%20the%20AgenC%20agent-coordination%20protocol%20on%20Solana%3A%20discover%20tasks%2C%20read%20task%20status%20%2B%20https%3A%2F%2Fgithub.com%2Fnirholas%2Fthree-ws-agenc) ยท [Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fgithub.com%2Fnirholas%2Fthree-ws-agenc) ยท [Submit to Hacker News](https://news.ycombinator.com/submitlink?u=https%3A%2F%2Fgithub.com%2Fnirholas%2Fthree-ws-agenc&t=three-ws-agenc%3A%20Client%20for%20the%20AgenC%20agent-coordination%20protocol%20on%20Solana%3A%20discover%20tasks%2C%20read%20task%20status%20%2B) ยท [Share on Reddit](https://www.reddit.com/submit?url=https%3A%2F%2Fgithub.com%2Fnirholas%2Fthree-ws-agenc&title=three-ws-agenc%3A%20Client%20for%20the%20AgenC%20agent-coordination%20protocol%20on%20Solana%3A%20discover%20tasks%2C%20read%20task%20status%20%2B)
## Built for AI agents too
Coding agents and LLM tooling can read this repo directly: [AGENTS.md](./AGENTS.md), [llms.txt](./llms.txt), [llms-full.txt](./llms-full.txt). Point an agent at `https://github.com/nirholas/three-ws-agenc` and it has the context it needs.
## More from the same author
- [All repositories by nirholas](https://github.com/nirholas/nirholas#readme): the full catalog, grouped by topic
- [three.ws](https://three.ws): the platform for 3D AI agents with Solana wallets, a skill marketplace and x402 payments
- Questions or ideas: [open an issue](https://github.com/nirholas/three-ws-agenc/issues) or [start a discussion](https://github.com/nirholas/three-ws-agenc/discussions)
## Contributors
[](https://github.com/nirholas/three-ws-agenc/graphs/contributors)
## Star history
[](https://www.star-history.com/#nirholas/three-ws-agenc&Date)
<!-- /three.ws:growth -->
<!-- three.ws:ecosystem -->
## Part of three.ws
[three.ws](https://three.ws) is a platform for 3D AI agents with Solana wallets: avatars, a skill marketplace, x402 payments and more than seventy MCP servers. `@three-ws/agenc` is one package from it.
- Documentation site: https://nirholas.github.io/three-ws-agenc/
- npm: https://www.npmjs.com/package/@three-ws/agenc
- Canonical source: https://github.com/nirholas/three.ws (this repository is a generated mirror of `packages/agenc`)
- Agent-readable summary: [llms.txt](./llms.txt) and [AGENTS.md](./AGENTS.md)
- Issues and ideas: https://github.com/nirholas/three-ws-agenc/issues
<!-- /three.ws:ecosystem -->