@openagentmarket/create-agent 1.5.0 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -31,8 +31,7 @@ Interactive prompts for:
31
31
  - Agent name and description
32
32
  - Skills (comma-separated)
33
33
  - Optional **on-chain registration** (ERC-8004)
34
- - Optional **x402 payments** — charge for your services (USDC on Base)
35
- - Optional **send payments** — send USDC or ETH on Base (`send_usdc`, `send_eth` skills)
34
+ - Optional **x402 payments** (USDC on Base)
36
35
 
37
36
  ## Getting Started
38
37
 
@@ -45,53 +44,3 @@ npm start
45
44
  ```
46
45
 
47
46
  Configure `.env` with your `MNEMONIC` (auto-generated for hirers).
48
-
49
- ## Adding Send Payments to Existing Projects
50
-
51
- If you scaffolded your agent before the send payment feature was available, you can add it manually. No new npm packages required — `ethers` (already in your `package.json`) has everything needed.
52
-
53
- **1. Add to `.env`:**
54
-
55
- ```
56
- BASE_RPC_URL="https://mainnet.base.org"
57
- ```
58
-
59
- **2. Add imports to `index.ts`:**
60
-
61
- ```typescript
62
- import { Contract, parseUnits, parseEther, JsonRpcProvider } from 'ethers';
63
- ```
64
-
65
- **3. Add task handlers after your existing `agent.onTask(...)` blocks:**
66
-
67
- ```typescript
68
- // ── Send USDC on Base ──
69
- const USDC_ADDRESS = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
70
- const USDC_ABI = [
71
- "function transfer(address to, uint256 amount) returns (bool)",
72
- "function balanceOf(address owner) view returns (uint256)"
73
- ];
74
-
75
- agent.onTask("send_usdc", async (input) => {
76
- const provider = new JsonRpcProvider(process.env.BASE_RPC_URL || "https://mainnet.base.org");
77
- const wallet = agent.getWallet().connect(provider);
78
- const usdc = new Contract(USDC_ADDRESS, USDC_ABI, wallet);
79
- const amount = parseUnits(input.amount, 6);
80
- const tx = await usdc.transfer(input.to, amount);
81
- const receipt = await tx.wait();
82
- return { success: true, txHash: receipt.hash, chain: "base", currency: "USDC", amount: input.amount, to: input.to };
83
- });
84
-
85
- // ── Send ETH on Base ──
86
- agent.onTask("send_eth", async (input) => {
87
- const provider = new JsonRpcProvider(process.env.BASE_RPC_URL || "https://mainnet.base.org");
88
- const wallet = agent.getWallet().connect(provider);
89
- const tx = await wallet.sendTransaction({ to: input.to, value: parseEther(input.amount) });
90
- const receipt = await tx.wait();
91
- return { success: true, txHash: receipt.hash, chain: "base", currency: "ETH", amount: input.amount, to: input.to };
92
- });
93
- ```
94
-
95
- **4. Add `"send_usdc"` and `"send_eth"` to your agent's `skills` array in the `card` config.**
96
-
97
- **5. Fund your agent's wallet** with USDC or ETH on Base before sending.
package/dist/index.js CHANGED
@@ -201,15 +201,29 @@ async function scaffoldHirer() {
201
201
  ` const reg = item.registrationFile || {};`,
202
202
  ` const name = reg.name || "Unknown";`,
203
203
  ` const desc = reg.description || "";`,
204
- ` // Find xmtpAddress from metadata array`,
205
- ` const meta = item.metadata || [];`,
206
- ` let addr = item.owner || "?";`,
207
- ` const walletMeta = meta.find((m: any) => m.key === "agentWallet");`,
208
- ` if (walletMeta) addr = walletMeta.value;`,
209
204
  ` const agentId = item.agentId || "";`,
205
+ ``,
206
+ ` // Extract XMTP chat address from Agent Endpoints`,
207
+ ` let chatAddr = "";`,
208
+ ` try {`,
209
+ ` const services = JSON.parse(reg.endpointsRawJson || "[]");`,
210
+ ` for (const svc of services) {`,
211
+ ` if (svc.endpoint && svc.endpoint.includes("openagent.market/chat")) {`,
212
+ ` const url = new URL(svc.endpoint);`,
213
+ ` chatAddr = url.searchParams.get("agent") || "";`,
214
+ ` break;`,
215
+ ` }`,
216
+ ` }`,
217
+ ` } catch {}`,
218
+ ``,
219
+ ` // Fallback to owner if no endpoint found`,
220
+ ` if (!chatAddr) chatAddr = item.owner || "?";`,
221
+ ``,
210
222
  ` console.log(" 🤖 " + name + (agentId ? " (#" + agentId + ")" : ""));`,
211
223
  ` if (desc) console.log(" " + desc.slice(0, 120) + (desc.length > 120 ? "..." : ""));`,
212
- ` console.log(" Address: " + addr);`,
224
+ ` console.log(" Chat: /chat " + chatAddr + " <message>");`,
225
+ ` const numericId = (agentId || "").split(":").pop() || "";`,
226
+ ` if (numericId) console.log(" Profile: https://8004agents.ai/base/agent/" + numericId);`,
213
227
  ` console.log("");`,
214
228
  ` }`,
215
229
  ` console.log("Total: " + data.items.length + " agent(s)");`,
@@ -306,17 +320,11 @@ async function scaffoldWorker() {
306
320
  {
307
321
  type: 'confirm',
308
322
  name: 'includePayments',
309
- message: 'Include x402 payments (charge for your services)?',
310
- initial: false
311
- },
312
- {
313
- type: 'confirm',
314
- name: 'includeSendPayments',
315
- message: 'Include send payments (USDC/ETH on Base)?',
323
+ message: 'Include x402 payments?',
316
324
  initial: false
317
325
  }
318
326
  ]);
319
- const { agentName, description, skills, includeRegistration, includePayments, includeSendPayments } = response;
327
+ const { agentName, description, skills, includeRegistration, includePayments } = response;
320
328
  if (!agentName) {
321
329
  console.log(kleur.red('Cancelled.'));
322
330
  process.exit(1);
@@ -360,30 +368,14 @@ async function scaffoldWorker() {
360
368
  envContent += 'REGISTRATION_PRIVATE_KEY=""\n';
361
369
  envContent += 'PINATA_JWT=""\n';
362
370
  }
363
- if (includeSendPayments) {
364
- envContent += 'BASE_RPC_URL="https://mainnet.base.org"\n';
365
- }
366
371
  fs.writeFileSync(path.join(targetDir, '.env'), envContent);
367
372
  // 4. .gitignore
368
373
  fs.writeFileSync(path.join(targetDir, '.gitignore'), 'node_modules\n.env\ndist\n');
369
374
  // 5. index.ts
370
- // Add send payment skills if enabled
371
- if (includeSendPayments) {
372
- if (!skillList.includes('send_usdc'))
373
- skillList.push('send_usdc');
374
- if (!skillList.includes('send_eth'))
375
- skillList.push('send_eth');
376
- }
377
- const taskHandlers = skillList.map((skill) => {
378
- if (skill === 'send_usdc')
379
- return SEND_USDC_HANDLER;
380
- if (skill === 'send_eth')
381
- return SEND_ETH_HANDLER;
382
- return `
375
+ const taskHandlers = skillList.map((skill) => `
383
376
  agent.onTask("${skill}", async (input) => {
384
377
  return { message: \`Handled ${skill} with \${JSON.stringify(input)}\` };
385
- });`;
386
- }).join('\n');
378
+ });`).join('\n');
387
379
  const paymentConfig = includePayments ? `
388
380
  payment: {
389
381
  amount: 5,
@@ -416,11 +408,8 @@ async function registerAgent(agent: any) {
416
408
  const registrationCall = includeRegistration
417
409
  ? '\n // Uncomment to register on-chain:\n // await registerAgent(agent);\n'
418
410
  : '';
419
- const sendPaymentImports = includeSendPayments
420
- ? `import { Contract, parseUnits, parseEther, JsonRpcProvider } from 'ethers';\n`
421
- : '';
422
411
  const indexTs = `import { OpenAgent } from '@openagentmarket/nodejs';
423
- ${sendPaymentImports}import 'dotenv/config';
412
+ import 'dotenv/config';
424
413
 
425
414
  async function main() {
426
415
  const mnemonic = process.env.MNEMONIC;
@@ -480,7 +469,6 @@ main().catch(console.error);
480
469
  `| **Name** | ${agentName} |`,
481
470
  `| **Skills** | ${skillList.join(', ')} |`,
482
471
  `| **Payments** | ${includePayments ? 'Enabled (x402)' : 'Disabled'} |`,
483
- `| **Send Payments** | ${includeSendPayments ? 'Enabled (USDC/ETH on Base)' : 'Disabled'} |`,
484
472
  `| **Registration** | ${includeRegistration ? 'Included' : 'Not included'} |`,
485
473
  ``,
486
474
  `## Environment Variables`,
@@ -488,7 +476,6 @@ main().catch(console.error);
488
476
  `| Variable | Required | Description |`,
489
477
  `|----------|----------|-------------|`,
490
478
  '| `MNEMONIC` | Yes | Agent wallet seed phrase |',
491
- includeSendPayments ? '| `BASE_RPC_URL` | For send payments | Base RPC endpoint (default: https://mainnet.base.org) |' : '',
492
479
  includeRegistration ? '| `REGISTRATION_PRIVATE_KEY` | For registration | Wallet paying gas |\n| `PINATA_JWT` | For registration | IPFS metadata upload |' : '',
493
480
  ``,
494
481
  `## Resources`,
@@ -506,55 +493,6 @@ main().catch(console.error);
506
493
  console.log(' # Set your MNEMONIC in .env');
507
494
  console.log(' npm start\n');
508
495
  }
509
- // ── Send Payment Templates ───────────────────────────────────────────────────
510
- const SEND_USDC_HANDLER = `
511
- // ── Send USDC on Base ──
512
- const USDC_ADDRESS = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
513
- const USDC_ABI = [
514
- "function transfer(address to, uint256 amount) returns (bool)",
515
- "function balanceOf(address owner) view returns (uint256)"
516
- ];
517
-
518
- agent.onTask("send_usdc", async (input) => {
519
- const provider = new JsonRpcProvider(process.env.BASE_RPC_URL || "https://mainnet.base.org");
520
- const wallet = agent.getWallet().connect(provider);
521
- const usdc = new Contract(USDC_ADDRESS, USDC_ABI, wallet);
522
-
523
- // USDC has 6 decimals
524
- const amount = parseUnits(input.amount, 6);
525
- const tx = await usdc.transfer(input.to, amount);
526
- const receipt = await tx.wait();
527
-
528
- return {
529
- success: true,
530
- txHash: receipt.hash,
531
- chain: "base",
532
- currency: "USDC",
533
- amount: input.amount,
534
- to: input.to
535
- };
536
- });`;
537
- const SEND_ETH_HANDLER = `
538
- // ── Send ETH on Base ──
539
- agent.onTask("send_eth", async (input) => {
540
- const provider = new JsonRpcProvider(process.env.BASE_RPC_URL || "https://mainnet.base.org");
541
- const wallet = agent.getWallet().connect(provider);
542
-
543
- const tx = await wallet.sendTransaction({
544
- to: input.to,
545
- value: parseEther(input.amount)
546
- });
547
- const receipt = await tx.wait();
548
-
549
- return {
550
- success: true,
551
- txHash: receipt.hash,
552
- chain: "base",
553
- currency: "ETH",
554
- amount: input.amount,
555
- to: input.to
556
- };
557
- });`;
558
496
  // ── Shared helpers ───────────────────────────────────────────────────────────
559
497
  function writeSharedTsConfig(targetDir) {
560
498
  const tsConfig = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openagentmarket/create-agent",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "CLI to scaffold a new OpenAgent project (hirer or worker)",
5
5
  "type": "module",
6
6
  "bin": {
@@ -12,15 +12,15 @@
12
12
  "start": "node dist/index.js"
13
13
  },
14
14
  "dependencies": {
15
- "prompts": "^2.4.2",
16
- "kleur": "^4.1.5",
15
+ "ethers": "^6.16.0",
17
16
  "fs-extra": "^11.2.0",
18
- "ethers": "^6.10.0"
17
+ "kleur": "^4.1.5",
18
+ "prompts": "^2.4.2"
19
19
  },
20
20
  "devDependencies": {
21
- "@types/prompts": "^2.4.9",
22
21
  "@types/fs-extra": "^11.0.4",
23
- "typescript": "^5.3.3",
24
- "@types/node": "^20.11.20"
22
+ "@types/node": "^20.11.20",
23
+ "@types/prompts": "^2.4.9",
24
+ "typescript": "^5.3.3"
25
25
  }
26
26
  }
package/src/index.ts CHANGED
@@ -216,15 +216,29 @@ async function scaffoldHirer() {
216
216
  ` const reg = item.registrationFile || {};`,
217
217
  ` const name = reg.name || "Unknown";`,
218
218
  ` const desc = reg.description || "";`,
219
- ` // Find xmtpAddress from metadata array`,
220
- ` const meta = item.metadata || [];`,
221
- ` let addr = item.owner || "?";`,
222
- ` const walletMeta = meta.find((m: any) => m.key === "agentWallet");`,
223
- ` if (walletMeta) addr = walletMeta.value;`,
224
219
  ` const agentId = item.agentId || "";`,
220
+ ``,
221
+ ` // Extract XMTP chat address from Agent Endpoints`,
222
+ ` let chatAddr = "";`,
223
+ ` try {`,
224
+ ` const services = JSON.parse(reg.endpointsRawJson || "[]");`,
225
+ ` for (const svc of services) {`,
226
+ ` if (svc.endpoint && svc.endpoint.includes("openagent.market/chat")) {`,
227
+ ` const url = new URL(svc.endpoint);`,
228
+ ` chatAddr = url.searchParams.get("agent") || "";`,
229
+ ` break;`,
230
+ ` }`,
231
+ ` }`,
232
+ ` } catch {}`,
233
+ ``,
234
+ ` // Fallback to owner if no endpoint found`,
235
+ ` if (!chatAddr) chatAddr = item.owner || "?";`,
236
+ ``,
225
237
  ` console.log(" 🤖 " + name + (agentId ? " (#" + agentId + ")" : ""));`,
226
238
  ` if (desc) console.log(" " + desc.slice(0, 120) + (desc.length > 120 ? "..." : ""));`,
227
- ` console.log(" Address: " + addr);`,
239
+ ` console.log(" Chat: /chat " + chatAddr + " <message>");`,
240
+ ` const numericId = (agentId || "").split(":").pop() || "";`,
241
+ ` if (numericId) console.log(" Profile: https://8004agents.ai/base/agent/" + numericId);`,
228
242
  ` console.log("");`,
229
243
  ` }`,
230
244
  ` console.log("Total: " + data.items.length + " agent(s)");`,
@@ -325,18 +339,12 @@ async function scaffoldWorker() {
325
339
  {
326
340
  type: 'confirm',
327
341
  name: 'includePayments',
328
- message: 'Include x402 payments (charge for your services)?',
329
- initial: false
330
- },
331
- {
332
- type: 'confirm',
333
- name: 'includeSendPayments',
334
- message: 'Include send payments (USDC/ETH on Base)?',
342
+ message: 'Include x402 payments?',
335
343
  initial: false
336
344
  }
337
345
  ]);
338
346
 
339
- const { agentName, description, skills, includeRegistration, includePayments, includeSendPayments } = response;
347
+ const { agentName, description, skills, includeRegistration, includePayments } = response;
340
348
  if (!agentName) {
341
349
  console.log(kleur.red('Cancelled.'));
342
350
  process.exit(1);
@@ -386,29 +394,16 @@ async function scaffoldWorker() {
386
394
  envContent += 'REGISTRATION_PRIVATE_KEY=""\n';
387
395
  envContent += 'PINATA_JWT=""\n';
388
396
  }
389
- if (includeSendPayments) {
390
- envContent += 'BASE_RPC_URL="https://mainnet.base.org"\n';
391
- }
392
397
  fs.writeFileSync(path.join(targetDir, '.env'), envContent);
393
398
 
394
399
  // 4. .gitignore
395
400
  fs.writeFileSync(path.join(targetDir, '.gitignore'), 'node_modules\n.env\ndist\n');
396
401
 
397
402
  // 5. index.ts
398
- // Add send payment skills if enabled
399
- if (includeSendPayments) {
400
- if (!skillList.includes('send_usdc')) skillList.push('send_usdc');
401
- if (!skillList.includes('send_eth')) skillList.push('send_eth');
402
- }
403
-
404
- const taskHandlers = skillList.map((skill: string) => {
405
- if (skill === 'send_usdc') return SEND_USDC_HANDLER;
406
- if (skill === 'send_eth') return SEND_ETH_HANDLER;
407
- return `
403
+ const taskHandlers = skillList.map((skill: string) => `
408
404
  agent.onTask("${skill}", async (input) => {
409
405
  return { message: \`Handled ${skill} with \${JSON.stringify(input)}\` };
410
- });`;
411
- }).join('\n');
406
+ });`).join('\n');
412
407
 
413
408
  const paymentConfig = includePayments ? `
414
409
  payment: {
@@ -445,12 +440,8 @@ async function registerAgent(agent: any) {
445
440
  ? '\n // Uncomment to register on-chain:\n // await registerAgent(agent);\n'
446
441
  : '';
447
442
 
448
- const sendPaymentImports = includeSendPayments
449
- ? `import { Contract, parseUnits, parseEther, JsonRpcProvider } from 'ethers';\n`
450
- : '';
451
-
452
443
  const indexTs = `import { OpenAgent } from '@openagentmarket/nodejs';
453
- ${sendPaymentImports}import 'dotenv/config';
444
+ import 'dotenv/config';
454
445
 
455
446
  async function main() {
456
447
  const mnemonic = process.env.MNEMONIC;
@@ -511,7 +502,6 @@ main().catch(console.error);
511
502
  `| **Name** | ${agentName} |`,
512
503
  `| **Skills** | ${skillList.join(', ')} |`,
513
504
  `| **Payments** | ${includePayments ? 'Enabled (x402)' : 'Disabled'} |`,
514
- `| **Send Payments** | ${includeSendPayments ? 'Enabled (USDC/ETH on Base)' : 'Disabled'} |`,
515
505
  `| **Registration** | ${includeRegistration ? 'Included' : 'Not included'} |`,
516
506
  ``,
517
507
  `## Environment Variables`,
@@ -519,7 +509,6 @@ main().catch(console.error);
519
509
  `| Variable | Required | Description |`,
520
510
  `|----------|----------|-------------|`,
521
511
  '| `MNEMONIC` | Yes | Agent wallet seed phrase |',
522
- includeSendPayments ? '| `BASE_RPC_URL` | For send payments | Base RPC endpoint (default: https://mainnet.base.org) |' : '',
523
512
  includeRegistration ? '| `REGISTRATION_PRIVATE_KEY` | For registration | Wallet paying gas |\n| `PINATA_JWT` | For registration | IPFS metadata upload |' : '',
524
513
  ``,
525
514
  `## Resources`,
@@ -539,58 +528,6 @@ main().catch(console.error);
539
528
  console.log(' npm start\n');
540
529
  }
541
530
 
542
- // ── Send Payment Templates ───────────────────────────────────────────────────
543
-
544
- const SEND_USDC_HANDLER = `
545
- // ── Send USDC on Base ──
546
- const USDC_ADDRESS = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
547
- const USDC_ABI = [
548
- "function transfer(address to, uint256 amount) returns (bool)",
549
- "function balanceOf(address owner) view returns (uint256)"
550
- ];
551
-
552
- agent.onTask("send_usdc", async (input) => {
553
- const provider = new JsonRpcProvider(process.env.BASE_RPC_URL || "https://mainnet.base.org");
554
- const wallet = agent.getWallet().connect(provider);
555
- const usdc = new Contract(USDC_ADDRESS, USDC_ABI, wallet);
556
-
557
- // USDC has 6 decimals
558
- const amount = parseUnits(input.amount, 6);
559
- const tx = await usdc.transfer(input.to, amount);
560
- const receipt = await tx.wait();
561
-
562
- return {
563
- success: true,
564
- txHash: receipt.hash,
565
- chain: "base",
566
- currency: "USDC",
567
- amount: input.amount,
568
- to: input.to
569
- };
570
- });`;
571
-
572
- const SEND_ETH_HANDLER = `
573
- // ── Send ETH on Base ──
574
- agent.onTask("send_eth", async (input) => {
575
- const provider = new JsonRpcProvider(process.env.BASE_RPC_URL || "https://mainnet.base.org");
576
- const wallet = agent.getWallet().connect(provider);
577
-
578
- const tx = await wallet.sendTransaction({
579
- to: input.to,
580
- value: parseEther(input.amount)
581
- });
582
- const receipt = await tx.wait();
583
-
584
- return {
585
- success: true,
586
- txHash: receipt.hash,
587
- chain: "base",
588
- currency: "ETH",
589
- amount: input.amount,
590
- to: input.to
591
- };
592
- });`;
593
-
594
531
  // ── Shared helpers ───────────────────────────────────────────────────────────
595
532
 
596
533
  function writeSharedTsConfig(targetDir: string) {