@oneie/cli 0.8.0 → 0.10.0

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
@@ -73,10 +73,11 @@ Every actor — human or agent — gets real, self-custodied multi-chain wallets
73
73
  one wallet create --workspace <slug> --kind agent # provision a wallet row (idempotent)
74
74
  one wallet get --workspace <slug> # credits, ceiling, live balances, delegated wallets
75
75
  one wallet transactions --workspace <slug> --limit 50 # unified feed across every settlement rail
76
+ one wallet faucet <address> --chain sui # fund from testnet — sui/sol auto-fund, others return a manual URL
76
77
  one wallet send <to> --chain SUI --amount 5 --payment-tx <hash> --workspace <slug>
77
78
  ```
78
79
 
79
- `send` never signs — sign and broadcast the transfer yourself first (`agent-wallet-client.ts` for an agent, `/w` for a human), then pass the resulting transaction hash. The private key never crosses this command.
80
+ `send` never signs — sign and broadcast the transfer yourself first (`agent-wallet-client.ts` for an agent, `/w` for a human), then pass the resulting transaction hash. The private key never crosses this command. `faucet` talks to `pay.one.ie` directly (its own protocol, not the `/ask` gateway) and needs no credential — funding any address is public by design, funding ≠ ownership.
80
81
 
81
82
  ## Chat — fan in · fan out
82
83
 
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oneie/cli",
3
- "version": "0.8.0",
3
+ "version": "0.10.0",
4
4
  "description": "ONE agent CLI",
5
5
  "type": "module",
6
6
  "bin": {
package/dist/src/index.js CHANGED
@@ -27,6 +27,7 @@ import { createCmd } from './create.js';
27
27
  import { fnCmd } from './fn.js';
28
28
  import { trailCmd } from './trail.js';
29
29
  import { initCmd } from './init.js';
30
+ import { onboardCmd } from './onboard.js';
30
31
  import { pluginCmd } from './plugin.js';
31
32
  import { readFileSync } from 'node:fs';
32
33
  import { fileURLToPath } from 'node:url';
@@ -66,6 +67,7 @@ program.addCommand(createCmd());
66
67
  program.addCommand(fnCmd());
67
68
  program.addCommand(trailCmd());
68
69
  program.addCommand(initCmd());
70
+ program.addCommand(onboardCmd());
69
71
  program.addCommand(pluginCmd());
70
72
  program.parseAsync(process.argv).catch((err) => {
71
73
  const isJson = process.argv.includes('--json');
@@ -0,0 +1,16 @@
1
+ /**
2
+ * oneie onboard — deterministically walk a fresh agent through the platform's
3
+ * agent-onboarding lifecycle (text/agent-onboarding-lifecycle.md): registered
4
+ * → bootstrapped → active → settled → adopted.
5
+ *
6
+ * Reuses the same zero-to-live call `one init` uses (POST /api/provision/agent)
7
+ * for register+bootstrap — both stages are tracked server-side automatically
8
+ * (no extra calls from here). Adds the read-back + guide layer `init` doesn't:
9
+ * after provisioning, reads the real stage_transition log via lifecycle:mine
10
+ * and tells the agent exactly what unlocks each remaining stage.
11
+ *
12
+ * Idempotent: if this directory already has ONE_API_KEY, skips provisioning
13
+ * and just reports current lifecycle position.
14
+ */
15
+ import { Command } from 'commander';
16
+ export declare function onboardCmd(): Command;
@@ -0,0 +1,146 @@
1
+ /**
2
+ * oneie onboard — deterministically walk a fresh agent through the platform's
3
+ * agent-onboarding lifecycle (text/agent-onboarding-lifecycle.md): registered
4
+ * → bootstrapped → active → settled → adopted.
5
+ *
6
+ * Reuses the same zero-to-live call `one init` uses (POST /api/provision/agent)
7
+ * for register+bootstrap — both stages are tracked server-side automatically
8
+ * (no extra calls from here). Adds the read-back + guide layer `init` doesn't:
9
+ * after provisioning, reads the real stage_transition log via lifecycle:mine
10
+ * and tells the agent exactly what unlocks each remaining stage.
11
+ *
12
+ * Idempotent: if this directory already has ONE_API_KEY, skips provisioning
13
+ * and just reports current lifecycle position.
14
+ */
15
+ import { Command } from 'commander';
16
+ import { writeFileSync, mkdirSync, renameSync, chmodSync } from 'node:fs';
17
+ import { resolve, join } from 'node:path';
18
+ import { homedir } from 'node:os';
19
+ import { mergeEnv, writeEnvLocal } from './env.js';
20
+ const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://one.ie';
21
+ const CONFIG_DIR = resolve(homedir(), '.config', 'oneie');
22
+ const KEY_FILE = resolve(CONFIG_DIR, 'key');
23
+ function writeKey(value) {
24
+ mkdirSync(CONFIG_DIR, { recursive: true });
25
+ const tmp = join(CONFIG_DIR, '.key.tmp');
26
+ writeFileSync(tmp, value, { mode: 0o600 });
27
+ chmodSync(tmp, 0o600);
28
+ renameSync(tmp, KEY_FILE);
29
+ }
30
+ async function ask(base, key, receiver, data) {
31
+ const res = await fetch(`${base}/api/ask/${encodeURIComponent(receiver)}`, {
32
+ method: 'POST',
33
+ headers: { 'Content-Type': 'application/json', ...(key ? { Authorization: `Bearer ${key}` } : {}) },
34
+ body: JSON.stringify({ data }),
35
+ });
36
+ const json = (await res.json().catch(() => ({})));
37
+ if (!res.ok)
38
+ throw new Error(`${receiver} → ${res.status}: ${JSON.stringify(json)}`);
39
+ return json;
40
+ }
41
+ // The 5 stages, in order, and what unlocks each one — mirrors
42
+ // SEED_DEFS['agent-onboarding'] in one.ie/web/src/lib/lifecycle/seed.ts.
43
+ // Kept here as plain data (not fetched) so `onboard` works even before the
44
+ // agent has a key to call the substrate with.
45
+ const STAGE_GUIDE = {
46
+ registered: 'done — your identity exists (uid + apiKey minted).',
47
+ bootstrapped: 'done — your own workspace exists (gid + aid + scopedKey minted).',
48
+ active: 'publish a capability or place a market offer: `one agent publish` or `one trade market`.',
49
+ settled: 'complete a sale: `one trade hire` (as a buyer) or accept + settle an offer (as the seller).',
50
+ adopted: 'get adopted by another workspace — accept an invite, or have your capability hired long-term.',
51
+ };
52
+ const STAGE_ORDER = ['registered', 'bootstrapped', 'active', 'settled', 'adopted'];
53
+ function out(cmd, data) {
54
+ const isJson = cmd.parent?.opts().json;
55
+ if (isJson) {
56
+ process.stdout.write(JSON.stringify(data) + '\n');
57
+ return;
58
+ }
59
+ if (data.ok === false) {
60
+ process.stderr.write(`✗ ${data.error ?? 'failed'}\n`);
61
+ return;
62
+ }
63
+ const stages = data.stages ?? [];
64
+ process.stdout.write(`✓ onboarded as ${data.uid ?? '?'}\n`);
65
+ process.stdout.write(` workspace: ${data.workspace ?? '?'}\n`);
66
+ process.stdout.write(` url: ${data.url ?? '?'}\n\n`);
67
+ process.stdout.write(' lifecycle: register → bootstrap → active → settled → adopted\n');
68
+ for (const s of stages) {
69
+ process.stdout.write(` ${s.done ? '✓' : '·'} ${s.id.padEnd(12)} ${s.guide}\n`);
70
+ }
71
+ }
72
+ export function onboardCmd() {
73
+ const cmd = new Command('onboard')
74
+ .description('Zero-to-live onboarding + a deterministic guide through the agent lifecycle')
75
+ .option('--name <name>', 'Workspace / agent display name')
76
+ .option('--api <url>', 'API base URL', DEFAULT_API)
77
+ .option('--write-env', 'Also write ONE_API_KEY to .env.local in the current directory', true)
78
+ .action(async (opts) => {
79
+ const dir = process.cwd();
80
+ const base = opts.api.replace(/\/$/, '');
81
+ const env = mergeEnv(dir);
82
+ let apiKey = env.ONE_API_KEY ?? env.ONEIE_API_KEY ?? '';
83
+ // regKey is the uid-bound registration key — distinct from apiKey (the
84
+ // workspace-scoped key `apiKey` resolves to). lifecycle:mine and any
85
+ // other uid-scoped receiver need THIS key: ctx.ownerSlug from `apiKey`
86
+ // resolves to the workspace's aid, which has zero stage_transition rows.
87
+ let regKey = env.ONE_REG_KEY ?? '';
88
+ let uid = env.ONE_UID ?? '';
89
+ let workspace = env.AGENCY_WSID ?? env.AGENCY_SLUG ?? '';
90
+ if (!apiKey) {
91
+ // Register + bootstrap in one call — the same zero-to-live path `one
92
+ // init` uses, POST /api/provision/agent. Both stages are tracked
93
+ // server-side the moment this call lands; nothing extra to do here.
94
+ const res = await fetch(`${base}/api/provision/agent`, {
95
+ method: 'POST',
96
+ headers: { 'Content-Type': 'application/json' },
97
+ body: JSON.stringify({ name: opts.name ?? 'My Agent', live: true }),
98
+ });
99
+ const json = (await res.json().catch(() => ({})));
100
+ if (!res.ok || !json.apiKey) {
101
+ out(cmd, { ok: false, error: json.error ?? `provision failed (${res.status})` });
102
+ process.exitCode = 1;
103
+ return;
104
+ }
105
+ uid = String(json.uid);
106
+ workspace = String(json.workspace);
107
+ apiKey = json.apiKey;
108
+ regKey = json.regKey ?? '';
109
+ writeKey(apiKey);
110
+ if (opts.writeEnv) {
111
+ writeEnvLocal(dir, { ONE_API_KEY: apiKey, ONE_API_URL: base, ONE_REG_KEY: regKey, ONE_UID: uid, AGENCY_WSID: workspace });
112
+ }
113
+ }
114
+ // Read back the real stage_transition log — the deterministic proof,
115
+ // not an assertion this command makes up. lifecycle:mine is self-scoped
116
+ // (entity_id = the caller's own uid, attested by the bearer key) —
117
+ // MUST be called with regKey, not apiKey (see note above).
118
+ const reached = new Set();
119
+ if (regKey) {
120
+ try {
121
+ const mine = await ask(base, regKey, 'lifecycle:mine', {});
122
+ const rows = (mine.result?.rows) ?? [];
123
+ for (const r of rows)
124
+ reached.add(r.to_stage);
125
+ }
126
+ catch {
127
+ // lifecycle:mine itself failing (e.g. no DB in a local dev target)
128
+ // must never block reporting what we already know from provisioning.
129
+ }
130
+ }
131
+ if (uid) {
132
+ reached.add('registered');
133
+ reached.add('bootstrapped');
134
+ }
135
+ const stages = STAGE_ORDER.map((id) => ({ id, done: reached.has(id), guide: STAGE_GUIDE[id] }));
136
+ out(cmd, {
137
+ ok: true,
138
+ uid: uid || '(unknown — no ONE_UID in env; re-run in a fresh dir to see it)',
139
+ workspace,
140
+ url: workspace ? `${base}/u/${workspace}` : base,
141
+ key: `${KEY_FILE} (0600)`,
142
+ stages,
143
+ });
144
+ });
145
+ return cmd;
146
+ }
@@ -1,4 +1,7 @@
1
1
  import { Command } from 'commander';
2
2
  export declare function askPath(base: string, receiver: string): string;
3
+ export declare function faucetOk(results: Array<{
4
+ success: boolean;
5
+ }>): boolean;
3
6
  export declare function okWrap(result: Record<string, unknown>): Record<string, unknown>;
4
7
  export declare function walletCmd(): Command;
@@ -29,6 +29,23 @@ async function ask(base, key, receiver, data) {
29
29
  }
30
30
  return envelope.result ?? envelope;
31
31
  }
32
+ const DEFAULT_PAY = process.env.ONEIE_PAY_URL ?? 'https://pay.one.ie';
33
+ // pay.one.ie is a separate service from the gateway/one.ie ask surface above —
34
+ // its own protocol envelope, POST <payUrl>/ { protocol, data } → { success, data,
35
+ // error? }. faucet_request is public (no credential), matching the threat model:
36
+ // funding ≠ ownership, anyone can fund any address (wallet-plan.md).
37
+ async function payProtocol(payUrl, protocol, data) {
38
+ const res = await fetch(`${payUrl.replace(/\/$/, '')}/`, {
39
+ method: 'POST',
40
+ headers: { 'Content-Type': 'application/json' },
41
+ body: JSON.stringify({ protocol, data }),
42
+ });
43
+ const body = (await res.json().catch(() => ({})));
44
+ if (!res.ok || !body.success) {
45
+ throw new Error(`${protocol} → ${body.error?.message ?? body.error?.code ?? res.status}`);
46
+ }
47
+ return body.data ?? {};
48
+ }
32
49
  function resolveAuth(opts) {
33
50
  const env = mergeEnv(process.cwd());
34
51
  const key = opts.key ?? env.ONEIE_API_KEY ?? env.ONE_API_KEY ?? '';
@@ -43,6 +60,14 @@ function resolveWorkspace(explicit) {
43
60
  }
44
61
  return workspace;
45
62
  }
63
+ // A chain with no auto-fund path (ETH/USDC/BTC) legitimately returns success:false
64
+ // with a manualUrls fallback — that's documented, expected behavior (wallet-plan.md:
65
+ // "SUI/SOL auto-fund; ETH/USDC/BTC return a manual URL"), never a call failure.
66
+ // `ok` here means "the request was answered" (payProtocol already throws on a real
67
+ // failure) — per-chain funded/manual status lives in `results`, read that, not `ok`.
68
+ export function faucetOk(results) {
69
+ return results.length > 0;
70
+ }
46
71
  // wallet:get/create/transactions return bare data or { error } — no `ok` field
47
72
  // of their own. wallet:send already returns { ok, ... }. Normalize both to the
48
73
  // { ok, ... } shape out() expects without ever overwriting a real error/false
@@ -55,7 +80,7 @@ export function okWrap(result) {
55
80
  return { ok: true, ...result };
56
81
  }
57
82
  export function walletCmd() {
58
- const cmd = new Command('wallet').description('Read balances, provision a wallet row, send crypto — wallet:* receivers');
83
+ const cmd = new Command('wallet').description('Read balances, provision a wallet row, fund from testnet, send crypto — wallet:* receivers + pay.one.ie');
59
84
  cmd.command('get')
60
85
  .description('Credits, spend ceiling, wallet rows, live chain balances, delegated wallets')
61
86
  .option('--workspace <slug>', 'Workspace (defaults to AGENCY_SLUG)')
@@ -93,6 +118,16 @@ export function walletCmd() {
93
118
  const result = await ask(base, key, 'wallet:transactions', { workspace, limit: Number(opts.limit) });
94
119
  out(cmd, okWrap(result));
95
120
  });
121
+ cmd.command('faucet <address>')
122
+ .description('Fund an address from a testnet tap — Sui and Solana auto-fund; ETH/USDC/BTC return a manual faucet URL')
123
+ .requiredOption('--chain <chain>', 'sui | sol | eth | usdc | btc | all')
124
+ .option('--network <network>', 'testnet | devnet (Sui only)')
125
+ .option('--pay-url <url>', 'pay.one.ie base URL', DEFAULT_PAY)
126
+ .action(async (address, opts) => {
127
+ const data = await payProtocol(opts.payUrl, 'faucet_request', { chain: opts.chain, address, network: opts.network });
128
+ const results = (data.results ?? []);
129
+ out(cmd, { ok: faucetOk(results), results, manualFaucets: data.manualFaucets });
130
+ });
96
131
  cmd.command('send <to>')
97
132
  .description('Send crypto via pay.one.ie payment links, incl. Bitcoin — sign the transfer yourself first, pass the tx hash')
98
133
  .requiredOption('--chain <chain>', 'SUI | EVM | SOL | BTC | BASE | ARB | OPT')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oneie/cli",
3
- "version": "0.8.0",
3
+ "version": "0.10.0",
4
4
  "description": "ONE agent CLI",
5
5
  "type": "module",
6
6
  "bin": {