Skip to content

Commit ab05bf0

Browse files
authored
feat: add README to aixyz (#67)
1 parent 417b0cf commit ab05bf0

File tree

1 file changed

+167
-0
lines changed

1 file changed

+167
-0
lines changed

packages/aixyz/README.md

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
# aixyz
2+
3+
[![npm](https://img.shields.io/npm/v/aixyz)](https://www.npmjs.com/package/aixyz)
4+
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](../../LICENSE)
5+
6+
Bundle AI agents from any framework into deployable services. A2A, MCP, x402 payments, and ERC-8004 identity get wired
7+
up for you.
8+
9+
## Quickstart
10+
11+
```bash
12+
pnpm create aixyz-app my-agent
13+
cd my-agent
14+
pnpm install
15+
```
16+
17+
Add an `aixyz.config.ts`:
18+
19+
```ts
20+
import type { AixyzConfig } from "aixyz";
21+
22+
const config: AixyzConfig = {
23+
name: "My Agent",
24+
description: "What your agent does in one sentence.",
25+
version: "1.0.0",
26+
network: "eip155:1",
27+
x402: {
28+
payTo: process.env.X402_PAY_TO!,
29+
network: "eip155:8453",
30+
},
31+
skills: [
32+
{
33+
id: "my-skill",
34+
name: "My Skill",
35+
description: "Describe what this skill does",
36+
tags: ["example"],
37+
},
38+
],
39+
};
40+
41+
export default config;
42+
```
43+
44+
Write your agent with whichever framework you prefer, then wire it up through an adapter:
45+
46+
```ts
47+
// src/agent.ts
48+
import { openai } from "@ai-sdk/openai";
49+
import { stepCountIs, ToolLoopAgent } from "ai";
50+
import myTool from "./tools/my-tool";
51+
52+
export const agent = new ToolLoopAgent({
53+
model: openai("gpt-4o-mini"),
54+
instructions: "You are a helpful agent that...",
55+
tools: { myTool },
56+
stopWhen: stepCountIs(10),
57+
});
58+
```
59+
60+
```ts
61+
// src/index.ts
62+
import { AixyzRequestHandler, initExpressApp, loadAixyzConfig } from "aixyz";
63+
import { ToolLoopAgentExecutor } from "aixyz/server/adapters/ai";
64+
import { InMemoryTaskStore } from "@a2a-js/sdk/server";
65+
import { agent } from "./agent";
66+
67+
const config = loadAixyzConfig();
68+
const handler = new AixyzRequestHandler(new InMemoryTaskStore(), new ToolLoopAgentExecutor(agent));
69+
70+
const x402Routes = {
71+
"POST /agent": {
72+
accepts: { scheme: "exact", price: "$0.01", network: config.x402.network, payTo: config.x402.payTo },
73+
mimeType: "application/json",
74+
description: "Payment for agent API access",
75+
},
76+
};
77+
78+
export default await initExpressApp(handler, x402Routes);
79+
```
80+
81+
```bash
82+
bun run dev
83+
```
84+
85+
This gives you:
86+
87+
| Endpoint | Protocol | Description |
88+
| ------------------------------ | -------- | ------------------------------ |
89+
| `/.well-known/agent-card.json` | A2A | Agent discovery metadata |
90+
| `/agent` | A2A | JSON-RPC endpoint (x402-gated) |
91+
| `/mcp` | MCP | Tool sharing |
92+
93+
## CLI
94+
95+
```bash
96+
aixyz init # Scaffold a new agent project
97+
aixyz build # Bundle for deployment
98+
aixyz deploy # Deploy
99+
aixyz register # Register on-chain (ERC-8004)
100+
```
101+
102+
`aixyz build` loads your `aixyz.config.ts`, detects the entrypoint (`src/index.ts` or `src/app.ts`), bundles with
103+
`Bun.build()` targeting Node.js, and outputs Vercel Build Output API v3 structure.
104+
105+
`aixyz register` creates an ERC-8004 on-chain identity for your agent so other agents and contracts can reference it.
106+
107+
## Adapters
108+
109+
Each adapter wraps a framework's agent into the `AgentExecutor` interface that aixyz needs to handle protocol requests.
110+
111+
| Adapter | Framework | Import |
112+
| ------------------------ | ------------- | --------------------------------- |
113+
| `ToolLoopAgentExecutor` | Vercel AI SDK | `aixyz/server/adapters/ai` |
114+
| `LangChainAgentExecutor` | LangChain | `aixyz/server/adapters/langchain` |
115+
| `MastraAgentExecutor` | Mastra | `aixyz/server/adapters/mastra` |
116+
117+
If your framework isn't listed, implement `AgentExecutor` directly. It's one method.
118+
119+
## Project Structure
120+
121+
```
122+
my-agent/
123+
aixyz.config.ts # Agent config
124+
src/
125+
index.ts # Entrypoint (adapter + express app)
126+
agent.ts # Agent definition
127+
tools/
128+
my-tool.ts # Tools
129+
public/ # Static assets (optional)
130+
package.json
131+
tsconfig.json
132+
```
133+
134+
## Configuration
135+
136+
| Field | Type | Required | Description |
137+
| -------------- | ------------------ | -------- | -------------------------------------------------------------------- |
138+
| `name` | `string` | Yes | Display name |
139+
| `description` | `string` | Yes | What your agent does |
140+
| `version` | `string` | Yes | Semver version |
141+
| `network` | `eip155:${number}` | Yes | Chain ID for identity (e.g. `eip155:1`) |
142+
| `url` | `string` | No | Base URL. Auto-detected on Vercel, defaults to `localhost:3000` |
143+
| `x402.payTo` | `string` | Yes | Payment recipient address. Falls back to `process.env.X402_PAY_TO` |
144+
| `x402.network` | `string` | No | Payment network (e.g. `eip155:8453` for Base). Defaults to `network` |
145+
| `skills` | `AgentSkill[]` | Yes | Skills your agent exposes |
146+
147+
## Protocols
148+
149+
**A2A** generates your agent card and JSON-RPC endpoint so other agents can discover and talk to yours.
150+
151+
**MCP** exposes your tools to any MCP-compatible client.
152+
153+
**x402** gates requests behind HTTP 402 micropayments. No custodial wallets, no subscriptions.
154+
155+
**ERC-8004** gives your agent a verifiable on-chain identity on supported chains (i.e. Ethereum, Base, etc.)
156+
157+
## Contributing
158+
159+
```bash
160+
bun install
161+
bun run dev
162+
bun run format # before committing
163+
```
164+
165+
## License
166+
167+
MIT

0 commit comments

Comments
 (0)