Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

3.8 KB
Raw Blame
// `agenc_list_tasks` — paid MCP tool that lists every public AgenC task
// created by a given Solana wallet on the AgenC coordination protocol.
//
// Pricing: $0.001 USDC, settled `exact` in USDC on Solana mainnet.
//
// AgenC = agenc.tech (Tetsuo Corp). Coordination protocol on Solana. This tool
// surfaces the on-chain task marketplace so any MCP client (Claude Desktop,
// Cursor, three.ws agents) can discover open jobs without standing up Anchor.

import { z } from 'zod';
import { getTasksByCreator } from '@tetsuo-ai/sdk';

import { paid } from '../payments.js';
import { jsonSchemaFromZod } from './_shared.js';
import {
	getAgenCClient,
	parsePubkey,
	serializeBigInts,
	taskStateLabel,
} from './agenc-client.js';

const TOOL_NAME = 'agenc_list_tasks';
const TOOL_DESCRIPTION =
	'List every public AgenC task created by a given Solana wallet. AgenC (agenc.tech, by Tetsuo Corp) is a Solana coordination protocol where agents bid on, claim, and complete tasks with SOL/SPL escrow and optional zero-knowledge settlement. Returns task PDA, state, reward, deadline, worker counts, and reward mint for each task. Specify cluster="devnet" for the dev cluster (program 6UcJzbT...), otherwise mainnet. Use this first to enumerate a wallet\'s AgenC tasks, then pass a task PDA to agenc_get_task for its full lifecycle timeline. Paid: $0.001 USDC.';

// Single source of truth: Zod shape carries descriptions + bounds + cluster
// enum; JSON Schema derived.
const inputZodShape = {
	creator: z.string().min(32).max(44).describe('Base58 Solana pubkey of the task creator wallet.'),
	cluster: z.enum(['mainnet', 'devnet']).describe('Solana cluster to query. Defaults to mainnet.').optional(),
};

const inputJsonSchema = jsonSchemaFromZod(inputZodShape);

export async function buildAgenCListTasksTool() {
	const handler = await paid(
		{
			toolName: TOOL_NAME,
			description: TOOL_DESCRIPTION,
			scheme: 'exact',
			priceUsd: '$0.001',
			inputSchema: inputJsonSchema,
			example: {
				creator: 'THREEsynthetic111111111111111111111111111111',
				cluster: 'devnet',
			},
			outputExample: {
				ok: true,
				cluster: 'devnet',
				programId: '6UcJzbTEemBz3aY5wK5qKHGMD7bdRsmR4smND29gB2ab',
				creator: 'THREEsynthetic111111111111111111111111111111',
				count: 1,
				tasks: [
					{
						taskId: '11d3...',
						state: 'Open',
						rewardAmount: '50000000',
						rewardMint: null,
						deadline: 1716508800,
						currentWorkers: 0,
						maxWorkers: 1,
					},
				],
			},
		},
		async ({ creator, cluster }) => {
			const creatorPk = parsePubkey(creator, 'creator');
			const client = getAgenCClient(cluster);
			const tasks = await getTasksByCreator(client.program, creatorPk);
			const rows = tasks.map((t) => ({
				taskId: Buffer.from(t.taskId).toString('hex'),
				state: taskStateLabel(t.state),
				stateRaw: typeof t.state === 'number' ? t.state : null,
				rewardAmount: t.rewardAmount.toString(),
				rewardMint: t.rewardMint ? t.rewardMint.toBase58() : null,
				deadline: t.deadline,
				currentWorkers: t.currentWorkers,
				maxWorkers: t.maxWorkers,
				completedAt: t.completedAt,
				constraintHash: t.constraintHash
					? Buffer.from(t.constraintHash).toString('hex')
					: null,
			}));
			return serializeBigInts({
				ok: true,
				cluster: client.cluster,
				rpcUrl: client.rpcUrl,
				programId: client.programId.toBase58(),
				creator: creatorPk.toBase58(),
				count: rows.length,
				tasks: rows,
				fetchedAt: new Date().toISOString(),
			});
		},
	);
	return {
		name: TOOL_NAME,
		title: 'AgenC list tasks ($0.001)',
		description: TOOL_DESCRIPTION,
		inputSchema: inputZodShape,
		// Read-only on-chain program scan — the task set changes as agents
		// post/claim work, so not idempotent.
		annotations: {
			readOnlyHint: true,
			destructiveHint: false,
			idempotentHint: false,
			openWorldHint: true,
		},
		handler,
	};
}