stuntman 0.2.3 → 0.2.4

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
@@ -113,6 +113,18 @@ import { stuntmanPlugin } from 'stuntman/eliza'; // npm install stuntman
113
113
  // character: plugins: [stuntmanPlugin], settings: { secrets: { STUNTMAN_ENDPOINT: '...' } }
114
114
  ```
115
115
 
116
+ ### Coinbase AgentKit
117
+
118
+ ```ts
119
+ import { stuntmanWalletProvider, stuntmanActionProvider } from 'stuntman/agentkit'; // npm install stuntman @coinbase/agentkit
120
+ const agentkit = await AgentKit.from({
121
+ walletProvider: await stuntmanWalletProvider({ privateKey: process.env.AGENT_KEY, endpoint }),
122
+ actionProviders: [await stuntmanActionProvider({ endpoint }), walletActionProvider(), erc20ActionProvider()],
123
+ });
124
+ ```
125
+
126
+ The wallet provider is AgentKit's viem wallet on Robinhood Chain, pointed at a Stuntman endpoint: AgentKit transactions are practiced, never broadcast. `stuntman connect agentkit` prints the setup.
127
+
116
128
  ### Priors
117
129
 
118
130
  Point Priors' MCP server at a Stuntman endpoint and its on-chain transactions (borrows, stock trades) are practiced, never broadcast. Keep `PRIORS_MAX_SPEND_USD=0` while practicing: `pay_url` pays over HTTPS, outside any RPC. Repaying a practice loan isn't carried forward yet. `stuntman connect priors` prints the setup, and every Stuntman record also shows the agent's Priors credit record.
@@ -139,7 +151,7 @@ Agents that send their own transactions use the printed endpoint as their RPC ad
139
151
  stuntman init --address <wallet> | --new [--rpc <url>] [--eth <amount>]
140
152
  stuntman mcp MCP server over stdio
141
153
  stuntman rpc [--port 8545] Practice RPC
142
- stuntman connect [claude|codex|json|raxol|virtuals|eliza|openclaw|priors]
154
+ stuntman connect [claude|codex|json|raxol|virtuals|eliza|agentkit|openclaw|priors]
143
155
  stuntman takes [--limit 20] [--json]
144
156
  stuntman take <id> [--json]
145
157
  stuntman balances [token ...]
@@ -0,0 +1,115 @@
1
+ // Stuntman for Coinbase AgentKit.
2
+ //
3
+ // import { AgentKit } from '@coinbase/agentkit';
4
+ // import { stuntmanWalletProvider, stuntmanActionProvider } from 'stuntman/agentkit';
5
+ //
6
+ // const agentkit = await AgentKit.from({
7
+ // walletProvider: await stuntmanWalletProvider({ privateKey: process.env.AGENT_KEY, endpoint: process.env.STUNTMAN_ENDPOINT }),
8
+ // actionProviders: [await stuntmanActionProvider({ endpoint: process.env.STUNTMAN_ENDPOINT }), ...yourOtherProviders],
9
+ // });
10
+ //
11
+ // The wallet provider is AgentKit's own viem wallet on Robinhood Chain, pointed
12
+ // at a Stuntman endpoint: every action that sends a transaction is played out
13
+ // at the latest block with practice money and never broadcast. The action
14
+ // provider adds practice balances, takes, status and practice money. With a
15
+ // witness endpoint, every take is also kept on the agent's public record.
16
+ import { createRequire } from 'node:module';
17
+ import { createWalletClient, defineChain, http } from 'viem';
18
+ import { privateKeyToAccount } from 'viem/accounts';
19
+ import { DEFAULT_CHAIN_ID } from './config.js';
20
+ import { practiceActions } from './practice.js';
21
+ const requireHere = createRequire(import.meta.url);
22
+ async function loadAgentKit() {
23
+ let path;
24
+ try {
25
+ path = requireHere.resolve('@coinbase/agentkit');
26
+ }
27
+ catch {
28
+ throw new Error('stuntman/agentkit needs Coinbase AgentKit. Install it with: npm install @coinbase/agentkit');
29
+ }
30
+ const ak = requireHere(path);
31
+ // AgentKit turns action schemas into tool definitions with its own zod, so
32
+ // the schemas must come from that same copy.
33
+ const z = createRequire(path)('zod');
34
+ return { ak, z };
35
+ }
36
+ const DEFAULT_ENDPOINT = 'http://127.0.0.1:8545';
37
+ function robinhoodChain(endpoint) {
38
+ return defineChain({
39
+ id: DEFAULT_CHAIN_ID,
40
+ name: 'Robinhood Chain',
41
+ nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
42
+ rpcUrls: { default: { http: [endpoint] } },
43
+ blockExplorers: { default: { name: 'Blockscout', url: 'https://robinhoodchain.blockscout.com' } },
44
+ });
45
+ }
46
+ /** AgentKit's viem wallet on Robinhood Chain, practicing through Stuntman. */
47
+ export async function stuntmanWalletProvider(options) {
48
+ const endpoint = options.endpoint ?? process.env.STUNTMAN_ENDPOINT ?? DEFAULT_ENDPOINT;
49
+ const key = String(options.privateKey ?? '').trim();
50
+ if (!/^(0x)?[0-9a-fA-F]{64}$/.test(key))
51
+ throw new Error('stuntmanWalletProvider needs the agent wallet private key (64 hex characters).');
52
+ const { ak } = await loadAgentKit();
53
+ const walletClient = createWalletClient({
54
+ account: privateKeyToAccount((key.startsWith('0x') ? key : `0x${key}`)),
55
+ chain: robinhoodChain(endpoint),
56
+ transport: http(endpoint),
57
+ });
58
+ // rpcUrl points AgentKit's receipt and balance reads at Stuntman too, so it
59
+ // sees practice transactions and practice balances.
60
+ return new ak.ViemWalletProvider(walletClient, { rpcUrl: endpoint });
61
+ }
62
+ /** Practice actions for an AgentKit agent. */
63
+ export async function stuntmanActionProvider(options = {}) {
64
+ const endpoint = options.endpoint ?? process.env.STUNTMAN_ENDPOINT ?? DEFAULT_ENDPOINT;
65
+ const { ak, z } = await loadAgentKit();
66
+ const a = practiceActions(endpoint);
67
+ const text = (out) => (typeof out === 'string' ? out : out.ok ? out.text : `Failed: ${out.text}`);
68
+ const safe = (fn) => async (args) => {
69
+ try {
70
+ return text(await fn(args ?? {}));
71
+ }
72
+ catch (err) {
73
+ return `Failed: ${err.message}`;
74
+ }
75
+ };
76
+ return ak.customActionProvider([
77
+ {
78
+ name: 'stuntman_practice_status',
79
+ description: 'Show the practice account on Robinhood Chain, recent practice results, and whether takes are witnessed on a public record. Every transaction this agent sends is practice: simulated, never broadcast.',
80
+ schema: z.object({}),
81
+ invoke: safe(() => a.status()),
82
+ },
83
+ {
84
+ name: 'stuntman_practice_balances',
85
+ description: 'Practice balances of ETH and tokens on Robinhood Chain. These are practice money, not real funds.',
86
+ schema: z.object({}),
87
+ invoke: safe(() => a.balances()),
88
+ },
89
+ {
90
+ name: 'stuntman_practice_takes',
91
+ description: 'Recent practice takes, newest first, with results and the reason for any failure.',
92
+ schema: z.object({ limit: z.number().int().min(1).max(50).optional().describe('How many takes, up to 50. Default 10.') }),
93
+ invoke: safe((args) => a.takes(Number(args.limit ?? 10))),
94
+ },
95
+ {
96
+ name: 'stuntman_send_practice_transaction',
97
+ description: 'Send any transaction in practice: simulated at the latest block of Robinhood Chain with practice money, never broadcast. Returns whether it filled and what changed.',
98
+ schema: z.object({
99
+ to: z.string().optional().describe('Contract or wallet address. Leave out to deploy a contract.'),
100
+ data: z.string().optional().describe('Calldata as 0x hex. Leave out for a plain ETH send.'),
101
+ value: z.string().optional().describe('ETH to send, in wei as a whole number.'),
102
+ }),
103
+ invoke: safe((args) => a.send(args.to, args.data, args.value)),
104
+ },
105
+ {
106
+ name: 'stuntman_add_practice_money',
107
+ description: 'Add practice money on a witness endpoint. It shows on the public record.',
108
+ schema: z.object({
109
+ asset: z.string().describe('ETH or a token address'),
110
+ amount: z.string().describe('Amount in whole units, for example 1 or 250.5'),
111
+ }),
112
+ invoke: safe((args) => a.fund(args.asset, args.amount)),
113
+ },
114
+ ]);
115
+ }
package/dist/cli.js CHANGED
@@ -57,7 +57,7 @@ Start
57
57
  Connect your agent
58
58
  stuntman mcp Practice wallet as an MCP server (stdio)
59
59
  stuntman rpc [--port 8545] Practice RPC for agents that send their own transactions
60
- stuntman connect [claude|codex|json|raxol|virtuals|eliza|openclaw|priors] Print the setup line for your agent
60
+ stuntman connect [claude|codex|json|raxol|virtuals|eliza|agentkit|openclaw|priors] Print the setup line for your agent
61
61
 
62
62
  Watch the takes
63
63
  stuntman takes [--limit 20] Recent takes
@@ -139,6 +139,16 @@ function connectLines(target) {
139
139
  '',
140
140
  `# Get a witness endpoint with "${installed ? 'stuntman' : 'npx stuntman'} witness" (or witness --key-env for the agent's own wallet).`,
141
141
  ].join('\n');
142
+ case 'agentkit':
143
+ return [
144
+ '# Coinbase AgentKit: use the Stuntman wallet provider, so AgentKit transactions are practiced.',
145
+ 'npm install stuntman @coinbase/agentkit',
146
+ "import { stuntmanWalletProvider, stuntmanActionProvider } from 'stuntman/agentkit';",
147
+ 'walletProvider: await stuntmanWalletProvider({ privateKey: process.env.AGENT_KEY, endpoint: process.env.STUNTMAN_ENDPOINT }),',
148
+ 'actionProviders: [await stuntmanActionProvider({ endpoint: process.env.STUNTMAN_ENDPOINT }), ...yourProviders],',
149
+ '',
150
+ `# Get a witness endpoint for the agent's own wallet with "${installed ? 'stuntman' : 'npx stuntman'} witness --key-env AGENT_KEY".`,
151
+ ].join('\n');
142
152
  case 'openclaw':
143
153
  return [
144
154
  '# OpenClaw: add the Stuntman skill, then ask your agent to practice a trade first.',
@@ -172,7 +182,7 @@ function connectLines(target) {
172
182
  '',
173
183
  `Agents that send their own transactions: run "${rpc}" and use http://127.0.0.1:${DEFAULT_PORT} as the RPC address.`,
174
184
  `Raxol agents: run "${rpc}", then "${installed ? 'stuntman' : 'npx stuntman'} connect raxol" for the two settings.`,
175
- `Virtuals GAME agents: "${installed ? 'stuntman' : 'npx stuntman'} connect virtuals". ElizaOS: "connect eliza". OpenClaw: "connect openclaw". Priors: "connect priors".`,
185
+ `Virtuals GAME agents: "${installed ? 'stuntman' : 'npx stuntman'} connect virtuals". ElizaOS: "connect eliza". AgentKit: "connect agentkit". OpenClaw: "connect openclaw". Priors: "connect priors".`,
176
186
  ].join('\n');
177
187
  }
178
188
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stuntman",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Practice mode for AI agents. Real apps, real prices, practice money. Every send is played out against the live chain and nothing is broadcast.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -48,6 +48,7 @@
48
48
  "zod": "^4.6.7"
49
49
  },
50
50
  "devDependencies": {
51
+ "@coinbase/agentkit": "^0.10.4",
51
52
  "@foundry-rs/anvil": "^1.7.1",
52
53
  "@types/node": "^26.6.11",
53
54
  "@virtuals-protocol/game": "^0.1.14",
@@ -57,14 +58,19 @@
57
58
  "exports": {
58
59
  "./game": "./dist/game.js",
59
60
  "./eliza": "./dist/eliza.js",
61
+ "./agentkit": "./dist/agentkit.js",
60
62
  "./package.json": "./package.json"
61
63
  },
62
64
  "peerDependencies": {
63
- "@virtuals-protocol/game": ">=0.1.14"
65
+ "@virtuals-protocol/game": ">=0.1.14",
66
+ "@coinbase/agentkit": ">=0.10.0"
64
67
  },
65
68
  "peerDependenciesMeta": {
66
69
  "@virtuals-protocol/game": {
67
70
  "optional": true
71
+ },
72
+ "@coinbase/agentkit": {
73
+ "optional": true
68
74
  }
69
75
  }
70
76
  }