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.

feat(cli): three-ws create makes an agent with its own wallet, and three-ws launch hands a prefilled coin to /launch for the owner to sign

nirholasd518756ec8f4
diff --git a/docs/cli.md b/docs/cli.md
index 32de4313e..41b9b4068 100644
--- a/docs/cli.md
+++ b/docs/cli.md
@@ -82,6 +82,17 @@ Every client stores a server under the same name, which is also what `--servers`
`npx three-ws mcp list --available` prints the live list, which is the source of truth if this table and the directory ever disagree.
+## Create an agent and launch its coin
+
+```bash
+npx three-ws create "Nova" --description "A deep-space guide who explains orbital mechanics."
+npx three-ws launch --agent <agent-id> --name "Nova" --symbol NOVA
+```
+
+`create` makes the agent on your account and prints its public page and the Solana wallet three.ws minted for it. Pass `--avatar <id>` to use an avatar you already own as its 3D body; otherwise give it a body on its page. A name that imitates an existing public agent is refused with the reason, so pick a distinct one.
+
+`launch` never spends anything from the terminal. It collects the coin's name, ticker, description, optional image (`--image`, the agent's portrait by default) and optional first buy (`--initial-buy <sol>`), then opens [/launch](/launch) with all of it filled in. You review the cost there and sign the launch in your browser. The launching agent needs a 3D body, because that page picks agents by their body. Run either command with no flags to be prompted for each field, or with `--json` to get the agent record or the review URL as JSON.
+
## Choosing which tools a client may call
Every tool is labelled read, write or financial ([the catalog](/mcp-tools) shows which is which). By default read and write tools are on and financial tools are off.
@@ -106,6 +117,8 @@ The selection is enforced whichever way you signed in. With a browser sign-in, s
| `setup` | Sign in, write servers into clients, verify with `tools/list` |
| `login` / `logout` | Sign in or switch accounts; `logout` also revokes the OAuth refresh token |
| `status` / `whoami` | Account, plan, wallet balance, token expiry and every configured client |
+| `create [name]` | Create an agent with its own Solana wallet and public page |
+| `launch` | Fill in a coin for one of your agents and open three.ws/launch to review and sign it |
| `mcp list` | Servers configured in each client (`--available` lists every server) |
| `mcp add <server>` / `mcp remove <server>` | Add or remove one server without prompts |
| `tools` | Choose which tool tiers or tools each server exposes |
diff --git a/packages/three-ws-cli/README.md b/packages/three-ws-cli/README.md
index 8807f5c86..8d83e8423 100644
--- a/packages/three-ws-cli/README.md
+++ b/packages/three-ws-cli/README.md
@@ -23,6 +23,8 @@ npx three-ws login --device # sign in over SSH
npx three-ws mcp list --available # every server and its name
npx three-ws tools --server three-ws-main --enable financial
npx three-ws status
+npx three-ws create "Nova" --description "A deep-space guide." # an agent with its own Solana wallet
+npx three-ws launch --agent <id> --name Nova --symbol NOVA # prefilled, you sign on three.ws/launch
```
Sign-in is a browser OAuth flow by default. `--device` approves a code from any browser, and `--key sk_live_...` (or `THREE_WS_API_KEY`) uses an API key from [Dashboard → API](https://three.ws/dashboard/api). Tools that move funds are off unless you sign in with `--financial` and enable them.
diff --git a/packages/three-ws-cli/src/cli.js b/packages/three-ws-cli/src/cli.js
index 5fdfd2a78..5cff69e0d 100755
--- a/packages/three-ws-cli/src/cli.js
+++ b/packages/three-ws-cli/src/cli.js
@@ -22,6 +22,8 @@ ${c.bold('Commands')}
logout Remove stored credentials and revoke the OAuth refresh token
status Account, plan, wallet balance, token expiry, and every configured client
whoami Print the signed-in account
+ create [name] Create an agent with its own Solana wallet and a public page
+ launch Fill in a coin for one of your agents, then review and sign it on three.ws/launch
tools Choose which tool groups each server exposes (financial tools are off by default)
mcp list Show three.ws servers configured in each client (--available lists all servers)
mcp add <server> Add one server to your clients without prompts
@@ -55,6 +57,15 @@ ${c.bold('Tools options')}
--disable a,b Tiers or tool names to turn off
--reset Back to the default (read and write on, financial off)
+${c.bold('Agent options')} (create, launch)
+ --name <text> Agent name (create) or coin name (launch)
+ --description <text> What the agent or coin is
+ --avatar <id> An avatar you own to use as the agent's 3D body (create)
+ --agent <id> The agent that launches the coin (launch)
+ --symbol <ticker> Coin ticker, letters and digits (launch)
+ --image <https-url> Coin image; the agent's portrait when omitted (launch)
+ --initial-buy <sol> SOL for the first buy, prefilled for review (launch)
+
${c.bold('Inference options')} (fund, provider, usage)
--amount <usdc> USDC to move from the agent wallet into credits (fund)
--agent <id> The agent whose wallet pays (fund) or whose budget to show (usage)
@@ -94,6 +105,11 @@ const OPTIONS = {
amount: { type: 'string' },
agent: { type: 'string' },
name: { type: 'string' },
+ description: { type: 'string' },
+ avatar: { type: 'string' },
+ symbol: { type: 'string' },
+ image: { type: 'string' },
+ 'initial-buy': { type: 'string' },
};
// `--key` alone (no value) means "prompt for it"; parseArgs needs a value for a
@@ -116,6 +132,8 @@ const COMMANDS = {
status: async (ctx) => (await import('./commands/account.js')).status(ctx),
whoami: async (ctx) => (await import('./commands/account.js')).whoami(ctx),
tools: async (ctx) => (await import('./commands/tools.js')).tools(ctx),
+ create: async (ctx) => (await import('./commands/agent.js')).create(ctx),
+ launch: async (ctx) => (await import('./commands/agent.js')).launch(ctx),
mcp: async (ctx) => (await import('./commands/mcp.js')).mcp(ctx),
proxy: async (ctx) => {
const [url] = ctx.positionals;
diff --git a/packages/three-ws-cli/src/commands/agent.js b/packages/three-ws-cli/src/commands/agent.js
new file mode 100644
index 000000000..77ee3f09c
--- /dev/null
+++ b/packages/three-ws-cli/src/commands/agent.js
@@ -0,0 +1,201 @@
+// `three-ws create` and `three-ws launch`: an agent and its coin from the terminal.
+//
+// create POSTs /api/agents with the stored credential. The server mints the
+// agent's own Solana wallet in that request; nothing here touches keys.
+// launch never spends from the terminal. Launching signs with the agent's
+// custodial wallet, which three.ws only allows from a same-site browser
+// session, so this collects the coin details and opens /launch with them
+// filled in: the owner reviews the cost there and signs it themselves.
+
+import * as p from '@clack/prompts';
+import { answer, canPrompt, signIn } from './common.js';
+import { c, line, rows, sym, printJson, shortAddress } from '../ui.js';
+import { bearerFor } from '../oauth.js';
+import { requestJson, ApiError } from '../http.js';
+import { openBrowser } from '../browser.js';
+
+const NAME_MAX = 100;
+const DESCRIPTION_MAX = 500;
+const COIN_NAME_MAX = 32;
+const SYMBOL_MAX = 10;
+const COIN_DESCRIPTION_MAX = 500;
+
+/** A bearer for the signed-in account, signing in first when a prompt is allowed. */
+async function requireBearer(ctx) {
+ let bearer = await bearerFor(ctx.env, { origin: ctx.origin });
+ if (bearer) return bearer;
+ if (!canPrompt(ctx)) throw new ApiError('sign in first: `npx three-ws login` (or pass --key / set THREE_WS_API_KEY)');
+ await signIn(ctx, {});
+ bearer = await bearerFor(ctx.env, { origin: ctx.origin });
+ if (!bearer) throw new ApiError('sign-in did not complete; run `npx three-ws login`');
+ return bearer;
+}
+
+async function ask(ctx, { flag, message, placeholder, max, required = true, validate }) {
+ const given = typeof flag === 'string' ? flag.trim() : '';
+ if (given) {
+ const err = validate?.(given);
+ if (err) throw new Error(err);
+ return given.slice(0, max);
+ }
+ if (!canPrompt(ctx)) {
+ if (required) throw new Error(`${message.toLowerCase()} is required (pass it as a flag)`);
+ return '';
+ }
+ const value = answer(await p.text({
+ message,
+ placeholder,
+ validate: (v) => {
+ const s = String(v || '').trim();
+ if (required && !s) return 'Required.';
+ if (s.length > max) return `At most ${max} characters.`;
+ return validate?.(s);
+ },
+ }));
+ return String(value || '').trim();
+}
+
+async function listAgents(ctx, bearer) {
+ const data = await requestJson(`${ctx.origin}/api/agents`, { headers: { authorization: `Bearer ${bearer}` } });
+ return Array.isArray(data?.agents) ? data.agents : [];
+}
+
+export async function create(ctx) {
+ const { flags, positionals } = ctx;
+ const bearer = await requireBearer(ctx);
+ if (canPrompt(ctx)) p.intro(`${c.bold('three.ws')} create an agent`);
+
+ const name = await ask(ctx, {
+ flag: flags.name || positionals[0],
+ message: 'Agent name',
+ placeholder: 'Nova',
+ max: NAME_MAX,
+ });
+ const description = await ask(ctx, {
+ flag: flags.description,
+ message: 'What does it do? (shown on its page and in search)',
+ placeholder: 'A deep-space guide who explains orbital mechanics in plain language.',
+ max: DESCRIPTION_MAX,
+ required: false,
+ });
+
+ const body = { name, ...(description ? { description } : {}), ...(flags.avatar ? { avatar_id: flags.avatar } : {}) };
+ let agent;
+ try {
+ const res = await requestJson(`${ctx.origin}/api/agents`, {
+ method: 'POST',
+ headers: { authorization: `Bearer ${bearer}` },
+ json: body,
+ timeoutMs: 60_000,
+ });
+ agent = res.agent;
+ } catch (err) {
+ // A name that impersonates an existing public agent is refused on purpose.
+ if (err instanceof ApiError && err.status === 409) {
+ const reason = err.body?.integrity?.reasons?.[0] || err.message;
+ throw new ApiError(`three.ws refused that name: ${reason}. Pick a distinct name and run create again.`, { status: 409, code: 'identity_conflict' });
+ }
+ throw err;
+ }
+
+ const page = `${ctx.origin}/agents/${agent.id}`;
+ if (flags.json) {
+ printJson({ agent: { id: agent.id, name: agent.name, solana_address: agent.solana_address, wallet_ready: agent.walletReady ?? null }, page });
+ return 0;
+ }
+ if (canPrompt(ctx)) p.outro(`${c.green(sym.ok)} ${c.bold(agent.name)} is live`);
+ else line(`${c.green(sym.ok)} ${c.bold(agent.name)} is live`);
+ rows([
+ ['Page', c.cyan(page)],
+ ['Agent id', agent.id],
+ ['Solana wallet', agent.solana_address ? `${agent.solana_address} ${c.dim(`(${shortAddress(agent.solana_address)})`)}` : c.dim('preparing; it appears on the agent page')],
+ ], ' ');
+ line('');
+ if (!agent.avatar_id) line(c.dim(` Give it a 3D body on its page. A body is also what a coin launch shows.`));
+ line(c.dim(` Launch its coin: npx three-ws launch --agent ${agent.id}`));
+ return 0;
+}
+
+export async function launch(ctx) {
+ const { flags } = ctx;
+ const bearer = await requireBearer(ctx);
+ const interactive = canPrompt(ctx);
+ if (interactive) p.intro(`${c.bold('three.ws')} launch a coin`);
+
+ // /launch picks the launching agent by its 3D body, so only agents with one
+ // can be preselected there.
+ const agents = await listAgents(ctx, bearer);
+ let agent = null;
+ if (flags.agent) {
+ agent = agents.find((a) => a.id === flags.agent || a.avatar_id === flags.agent);
+ if (!agent) throw new Error(`no agent ${flags.agent} on this account. \`npx three-ws create\` makes one.`);
+ } else if (!agents.length) {
+ throw new Error('this account has no agents yet. Run `npx three-ws create` first.');
+ } else if (agents.length === 1 || !interactive) {
+ [agent] = agents.filter((a) => a.avatar_id).concat(agents);
+ } else {
+ agent = answer(await p.select({
+ message: 'Which agent launches it?',
+ options: agents.map((a) => ({
+ value: a,
+ label: a.name,
+ hint: a.avatar_id ? (a.token?.mint ? 'already has a coin' : undefined) : 'no 3D body yet',
+ })),
+ }));
+ }
+ if (!agent.avatar_id) {
+ throw new Error(`${agent.name} has no 3D body yet, and /launch picks the launching agent by its body. Give it one at ${ctx.origin}/agents/${agent.id}, then run launch again.`);
+ }
+ if (agent.token?.mint && !flags.json) {
+ line(c.yellow(` ${agent.name} already launched ${agent.token.symbol ? `$${agent.token.symbol}` : 'a coin'} (${agent.token.mint}).`));
+ }
+
+ const coinName = await ask(ctx, { flag: flags.name, message: 'Coin name', placeholder: agent.name, max: COIN_NAME_MAX });
+ const symbol = (await ask(ctx, {
+ flag: flags.symbol,
+ message: 'Ticker',
+ placeholder: coinName.replace(/[^A-Za-z0-9]/g, '').slice(0, 5).toUpperCase(),
+ max: SYMBOL_MAX,
+ validate: (s) => (/^[A-Za-z0-9]+$/.test(s) ? undefined : 'Letters and digits only.'),
+ })).toUpperCase();
+ const description = await ask(ctx, {
+ flag: flags.description,
+ message: 'Coin description (optional)',
+ max: COIN_DESCRIPTION_MAX,
+ required: false,
+ });
+ const image = await ask(ctx, {
+ flag: flags.image,
+ message: 'Image URL (optional; the agent\'s portrait is used when blank)',
+ max: 2000,
+ required: false,
+ validate: (s) => (/^https:\/\//.test(s) ? undefined : 'Use an https:// URL.'),
+ });
+ const initialBuy = flags['initial-buy'] ? Number(flags['initial-buy']) : 0;
+ if (!Number.isFinite(initialBuy) || initialBuy < 0) throw new Error('--initial-buy must be a SOL amount of 0 or more');
+
+ const url = new URL('/launch', ctx.origin);
+ url.searchParams.set('avatar', agent.avatar_id);
+ url.searchParams.set('name', coinName);
+ url.searchParams.set('symbol', symbol);
+ if (description) url.searchParams.set('description', description);
+ if (image) url.searchParams.set('image', image);
+ if (initialBuy > 0) url.searchParams.set('initialBuy', String(initialBuy));
+
+ if (flags.json) {
+ printJson({ agent: { id: agent.id, name: agent.name }, coin: { name: coinName, symbol, description: description || null, image: image || null, initial_buy_sol: initialBuy }, review_url: url.toString() });
+ return 0;
+ }
+
+ rows([
+ ['Agent', agent.name],
+ ['Coin', `${coinName} ($${symbol})`],
+ ['Initial buy', initialBuy > 0 ? `${initialBuy} SOL` : 'none'],
+ ], ' ');
+ line('');
+ const opened = await openBrowser(url.toString(), { env: ctx.env.vars });
+ line(` ${opened ? 'Opened' : 'Open'} ${c.cyan(url.toString())}`);
+ line(c.dim(' Nothing is paid from the terminal. Review the cost on that page and sign the launch there.'));
+ if (interactive) p.outro('Finish the launch in your browser.');
+ return 0;
+}
diff --git a/packages/three-ws-cli/tests/agent.test.js b/packages/three-ws-cli/tests/agent.test.js
new file mode 100644
index 000000000..476c4fd0a
--- /dev/null
+++ b/packages/three-ws-cli/tests/agent.test.js
@@ -0,0 +1,125 @@
+import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
+import fs from 'node:fs';
+import os from 'node:os';
+import path from 'node:path';
+import { writeStore } from '../src/store.js';
+import { main } from '../src/cli.js';
+
+const ORIGIN = 'https://three.ws';
+const KEY = 'sk_live_cli_agent_test_key_00000000';
+
+function tempEnv() {
+ const home = fs.mkdtempSync(path.join(os.tmpdir(), 'three-ws-agent-'));
+ return { home, platform: process.platform, cwd: home, vars: { THREE_WS_NO_BROWSER: '1' } };
+}
+
+function reply(status, body) {
+ return new Response(JSON.stringify(body), { status, headers: { 'content-type': 'application/json' } });
+}
+
+/** Run the CLI and capture stdout, parsing it when --json was passed. */
+async function run(argv, env) {
+ let out = '';
+ const write = vi.spyOn(process.stdout, 'write').mockImplementation((chunk) => {
+ out += String(chunk);
+ return true;
+ });
+ const err = vi.spyOn(process.stderr, 'write').mockImplementation(() => true);
+ try {
+ const code = await main(argv, env);
+ return { code, out, json: argv.includes('--json') && out ? JSON.parse(out) : null };
+ } finally {
+ write.mockRestore();
+ err.mockRestore();
+ }
+}
+
+describe('three-ws create', () => {
+ let env;
+ let fetchMock;
+ beforeEach(() => {
+ env = tempEnv();
+ writeStore({ origin: ORIGIN, auth: { type: 'apikey', key: KEY, prefix: KEY.slice(0, 12) } }, env);
+ fetchMock = vi.fn();
+ vi.stubGlobal('fetch', fetchMock);
+ });
+ afterEach(() => vi.unstubAllGlobals());
+
+ it('creates the agent with the stored key and reports its page and wallet', async () => {
+ fetchMock.mockResolvedValueOnce(reply(201, { agent: { id: 'a1', name: 'Nova', solana_address: 'So1anaAddre55', walletReady: true, avatar_id: null } }));
+ const { code, json } = await run(['create', 'Nova', '--description', 'A deep-space guide.', '--json', '--origin', ORIGIN], env);
+ expect(code).toBe(0);
+ const [url, init] = fetchMock.mock.calls[0];
+ expect(url).toBe(`${ORIGIN}/api/agents`);
+ expect(init.method).toBe('POST');
+ expect(init.headers.authorization).toBe(`Bearer ${KEY}`);
+ expect(JSON.parse(init.body)).toEqual({ name: 'Nova', description: 'A deep-space guide.' });
+ expect(json).toEqual({ agent: { id: 'a1', name: 'Nova', solana_address: 'So1anaAddre55', wallet_ready: true }, page: `${ORIGIN}/agents/a1` });
+ });
+
+ it('explains an impersonation refusal instead of printing a bare 409', async () => {
+ fetchMock.mockResolvedValueOnce(reply(409, { error: 'identity_conflict', integrity: { reasons: ['too close to the public agent "Nova Prime"'] } }));
+ const { code, json } = await run(['create', 'Nova Prime', '--json', '--origin', ORIGIN], env);
+ expect(code).toBe(1);
+ expect(json.error).toBe('identity_conflict');
+ expect(json.message).toContain('too close to the public agent "Nova Prime"');
+ expect(json.message).toContain('Pick a distinct name');
+ });
+
+ it('refuses to run without a credential when it cannot prompt', async () => {
+ const bare = tempEnv();
+ const { code, json } = await run(['create', 'Nova', '--json', '--origin', ORIGIN], bare);
+ expect(code).toBe(1);
+ expect(json.message).toContain('npx three-ws login');
+ expect(fetchMock).not.toHaveBeenCalled();
+ });
+});
+
+describe('three-ws launch', () => {
+ let env;
+ let fetchMock;
+ beforeEach(() => {
+ env = tempEnv();
+ writeStore({ origin: ORIGIN, auth: { type: 'apikey', key: KEY, prefix: KEY.slice(0, 12) } }, env);
+ fetchMock = vi.fn();
+ vi.stubGlobal('fetch', fetchMock);
+ });
+ afterEach(() => vi.unstubAllGlobals());
+
+ it('never spends: it only reads the agent list and hands back a prefilled /launch URL', async () => {
+ fetchMock.mockResolvedValueOnce(reply(200, { agents: [{ id: 'a1', name: 'Nova', avatar_id: 'av1' }] }));
+ const { code, json } = await run(
+ ['launch', '--agent', 'a1', '--name', 'Nova Coin', '--symbol', 'nova', '--description', 'The Nova agent coin.', '--image', 'https://example.com/nova.png', '--initial-buy', '0.1', '--json', '--origin', ORIGIN],
+ env,
+ );
+ expect(code).toBe(0);
+ expect(fetchMock).toHaveBeenCalledTimes(1);
+ expect(fetchMock.mock.calls[0][0]).toBe(`${ORIGIN}/api/agents`);
+ expect(fetchMock.mock.calls[0][1].method || 'GET').toBe('GET');
+ const url = new URL(json.review_url);
+ expect(url.origin + url.pathname).toBe(`${ORIGIN}/launch`);
+ expect(Object.fromEntries(url.searchParams)).toEqual({
+ avatar: 'av1',
+ name: 'Nova Coin',
+ symbol: 'NOVA',
+ description: 'The Nova agent coin.',
+ image: 'https://example.com/nova.png',
+ initialBuy: '0.1',
+ });
+ });
+
+ it('stops when the agent has no 3D body, since /launch selects agents by their body', async () => {
+ fetchMock.mockResolvedValueOnce(reply(200, { agents: [{ id: 'a1', name: 'Nova', avatar_id: null }] }));
+ const { code, json } = await run(['launch', '--agent', 'a1', '--name', 'Nova Coin', '--symbol', 'NOVA', '--json', '--origin', ORIGIN], env);
+ expect(code).toBe(1);
+ expect(json.message).toContain('has no 3D body yet');
+ expect(json.message).toContain(`${ORIGIN}/agents/a1`);
+ });
+
+ it('rejects a ticker with symbols in it', async () => {
+ fetchMock.mockResolvedValueOnce(reply(200, { agents: [{ id: 'a1', name: 'Nova', avatar_id: 'av1' }] }));
+ const { code, json } = await run(['launch', '--agent', 'a1', '--name', 'Nova Coin', '--symbol', 'NO$VA', '--json', '--origin', ORIGIN], env);
+ expect(code).toBe(1);
+ expect(json.message).toContain('Letters and digits only');
+ });
+});