@craftlead/sdk
v0.4.31
Published
[](https://www.npmjs.com/package/@craftlead/sdk)
Readme
@craftlead/sdk
Agent runtime SDK for CraftLead — orchestrate autonomous AI agent swarms with 0G Storage persistence and Uniswap settlement.
Installation
npm install @craftlead/sdk
# or
pnpm add @craftlead/sdk
# or
yarn add @craftlead/sdkOverview
@craftlead/sdk provides the core runtime for CraftLead's 4-agent autonomous swarm:
- Planner — Decomposes missions into research tasks
- Researcher — Analyzes job data with iterative refinement
- Critic — Quality review with feedback loop
- Executor — Compiles final structured reports
All agent outputs are persisted to 0G Storage (File + KV layers) for verifiable memory.
Architecture
All exports are available through the barrel import @craftlead/sdk:
flowchart LR
subgraph SDK["@craftlead/sdk"]
subgraph Modules["Modules"]
Orch[orchestrator]
JS[job-sources]
OG[og]
Uniswap[uniswap]
Supabase[supabase]
AXL[axl]
Gensyn[gensyn]
Verify[verify]
end
end
MCP["@craftlead/mcp"] --> SDK
style MCP fill:#ec4899Module Structure
| Module | Purpose |
|--------|---------|
| orchestrator | Agent swarm coordination, mission runner |
| job-sources | HTTP fetchers for 4 job sources, 5-signal matching |
| og | 0G Storage client, memory store, iNFT minting |
| supabase | Database queries, user operations |
| uniswap | Uniswap Trading API integration, settlement |
| verify | Report verification from 0G Storage |
| axl | AXL P2P mesh (optional, for distributed execution) |
| gensyn | Gensyn Delphi client (optional, for markets) |
Quick Start
import {
runMission,
runPlanner,
runResearcher,
runCritic,
runExecutor,
} from '@craftlead/sdk'
// Run full mission (fire-and-forget)
runMission(missionId, title, description)
// Or run individual agents
const tasks = await runPlanner(title, description)
const observations = await runResearcher(tasks, jobData)
const review = await runCritic(observations)
const report = await runExecutor(review.verifiedObservations, title)API Reference
Agent Swarm
import {
runMission, // Full pipeline (Planner → Researcher ↔ Critic → Executor)
runPlanner, // Decompose mission into 3-5 tasks
runResearcher, // Analyze job data per task
runCritic, // Review observations for quality
runExecutor, // Compile final structured report
} from '@craftlead/sdk'Job Sources
import {
syncAllJobs, // Sync from all 4 sources
syncSource, // Sync from specific source
matchAllJobs, // Match jobs to active users
} from '@craftlead/sdk'NFT / 0G
import {
mintAgentNFTWithArt, // Mint single agent iNFT
mintSwarmNFTs, // Mint all 4 agent iNFTs
getAgentNFTInfo, // Get iNFT metadata
verifyReport, // Retrieve report from 0G Storage
runInference, // AI inference via 0G Compute
} from '@craftlead/sdk'Uniswap
import {
getQuote, // Get Uniswap quote
executeSwap, // Execute swap
settleAgentReward, // Settle agent rewards on-chain
calculateAgentFeeDistribution, // Calculate fee split
} from '@craftlead/sdk'Mission Status
import {
getMissionById, // Get mission details
getAgentLogs, // Get agent logs for a mission
getAgentEarnings, // Get earnings for an agent role
} from '@craftlead/sdk'MCP Server
The SDK is consumed by @craftlead/mcp, which exposes all SDK functions as MCP tools via stdio. This allows any MCP-compatible client (Claude Desktop, OpenClaw, etc.) to use the full agent swarm.
# Test MCP server locally
npx @modelcontextprotocol/inspector npx -y @craftlead/mcpAgent Rewards
Default reward distribution per mission:
| Agent | Share | |-------|-------| | Planner | 15% | | Researcher | 30% | | Critic | 20% | | Executor | 35% |
Peer Dependencies
{
"@0gfoundation/0g-ts-sdk": ">=0.1.0",
"@gensyn-ai/gensyn-delphi-sdk": ">=1.0.0",
"ethers": ">=6.0.0",
"openai": ">=4.0.0",
"zod": ">=3.22.0"
}All peer dependencies are optional — only install the ones your use case requires.
Development
pnpm install
pnpm build # Build to dist/
pnpm dev # Watch mode