@oneie/cli 0.7.0 → 0.8.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
@@ -63,7 +63,20 @@ one login --key <key> # stored at ~/.config/oneie/key (0600)
63
63
  # or set ONEIE_API_KEY in the environment
64
64
  ```
65
65
 
66
- Workspace operations use a Bearer token `<slug>:<key>`. Override the API base per command with `--api` (default `https://one.ie`).
66
+ Workspace operations use a Bearer token `<slug>:<key>`. Override the API base per command with `--api` (default `https://api.one.ie`, the gateway).
67
+
68
+ ## Wallets
69
+
70
+ Every actor — human or agent — gets real, self-custodied multi-chain wallets. The CLI reads and writes the same `wallet:*` receivers `/w` uses:
71
+
72
+ ```bash
73
+ one wallet create --workspace <slug> --kind agent # provision a wallet row (idempotent)
74
+ one wallet get --workspace <slug> # credits, ceiling, live balances, delegated wallets
75
+ one wallet transactions --workspace <slug> --limit 50 # unified feed across every settlement rail
76
+ one wallet send <to> --chain SUI --amount 5 --payment-tx <hash> --workspace <slug>
77
+ ```
78
+
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.
67
80
 
68
81
  ## Chat — fan in · fan out
69
82
 
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oneie/cli",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "ONE agent CLI",
5
5
  "type": "module",
6
6
  "bin": {
package/dist/src/index.js CHANGED
@@ -15,6 +15,7 @@ import { substrateCommands } from './substrate.js';
15
15
  import { evalCmd } from './eval.js';
16
16
  import { setupCmd } from './setup.js';
17
17
  import { clientCmd } from './client.js';
18
+ import { walletCmd } from './wallet.js';
18
19
  import { pushCmd } from './push.js';
19
20
  import { deployCmd } from './deploy.js';
20
21
  import { statusCmd } from './status.js';
@@ -52,6 +53,7 @@ program.addCommand(staffCmd());
52
53
  program.addCommand(evalCmd());
53
54
  program.addCommand(setupCmd());
54
55
  program.addCommand(clientCmd());
56
+ program.addCommand(walletCmd());
55
57
  program.addCommand(pushCmd());
56
58
  program.addCommand(deployCmd());
57
59
  program.addCommand(statusCmd());
@@ -1,4 +1,6 @@
1
1
  import { Command } from 'commander';
2
+ import { mkdirSync } from 'node:fs';
3
+ import { spawnSync } from 'node:child_process';
2
4
  function out(cmd, data) {
3
5
  if (process.env.ONEIE_JSON) {
4
6
  process.stdout.write(JSON.stringify({ cmd, ...data }) + '\n');
@@ -19,6 +21,17 @@ function bearerHeaders(workspace) {
19
21
  const key = process.env.ONEIE_API_KEY;
20
22
  return key && workspace ? { Authorization: `Bearer ${workspace}:${key}` } : {};
21
23
  }
24
+ // npm pack wraps a package's contents under a "package/" root — strip-components=1 lands
25
+ // the real package.json + src/ directly at ./plugin-<name>/, same as a real npm install would.
26
+ function extractTarball(bytes, targetDir) {
27
+ mkdirSync(targetDir, { recursive: true });
28
+ const tar = spawnSync('tar', ['-xz', '--strip-components=1', '-C', targetDir], {
29
+ input: bytes,
30
+ stdio: ['pipe', 'inherit', 'inherit'],
31
+ });
32
+ if (tar.status !== 0)
33
+ throw new Error(`tar failed extracting to ${targetDir}`);
34
+ }
22
35
  export function pluginCmd() {
23
36
  const cmd = new Command('plugin').description('Manage ONE plugins');
24
37
  cmd
@@ -65,6 +78,21 @@ export function pluginCmd() {
65
78
  console.error(`Error: ${e instanceof Error ? e.message : e}`);
66
79
  process.exit(1);
67
80
  }
81
+ // Paid plugins (PAID_FEATURES) stream a real gzip tarball on 200; free plugins keep
82
+ // the JSON pointer to their public npm package. Discriminate before parsing the body.
83
+ if (res.ok && res.headers.get('content-type')?.startsWith('application/gzip')) {
84
+ const bytes = new Uint8Array(await res.arrayBuffer());
85
+ const targetDir = `./plugin-${name}`;
86
+ try {
87
+ extractTarball(bytes, targetDir);
88
+ }
89
+ catch (e) {
90
+ out('plugin:add', { ok: false, error: 'extract_failed', plugin: name, detail: e instanceof Error ? e.message : String(e) });
91
+ process.exit(1);
92
+ }
93
+ out('plugin:add', { ok: true, plugin: name, extracted: true, path: targetDir });
94
+ return;
95
+ }
68
96
  const body = (await res.json());
69
97
  if (res.status === 402) {
70
98
  out('plugin:add', {
@@ -0,0 +1,4 @@
1
+ import { Command } from 'commander';
2
+ export declare function askPath(base: string, receiver: string): string;
3
+ export declare function okWrap(result: Record<string, unknown>): Record<string, unknown>;
4
+ export declare function walletCmd(): Command;
@@ -0,0 +1,135 @@
1
+ import { Command } from 'commander';
2
+ import { mergeEnv } from './env.js';
3
+ const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://api.one.ie';
4
+ // The api.one.ie GATEWAY serves substrate ops at the short form (/ask/<receiver>,
5
+ // mapped internally to one-prod's /api/ask/<receiver> — api/src/substrate-binding.ts
6
+ // PATH_MAP). Calling /api/ask/ directly against the gateway 404s (verified live
7
+ // 2026-07-03). one.ie/web itself only answers the long form. Pick the path that
8
+ // matches whichever host --api actually points at, rather than hardcoding one.
9
+ export function askPath(base, receiver) {
10
+ const isGateway = new URL(base).hostname === 'api.one.ie';
11
+ return `${base}${isGateway ? '/ask' : '/api/ask'}/${encodeURIComponent(receiver)}`;
12
+ }
13
+ // The ask envelope nests the resolver's return under `result`, not at the top
14
+ // level: { outcome:'result'|'timeout'|'dissolved'|'failure', result, signalId,
15
+ // receiver }. Unwrap it here so callers work with the plain wallet:* shape.
16
+ async function ask(base, key, receiver, data) {
17
+ const res = await fetch(askPath(base, receiver), {
18
+ method: 'POST',
19
+ headers: { 'Content-Type': 'application/json', ...(key ? { Authorization: `Bearer ${key}` } : {}) },
20
+ body: JSON.stringify({ data }),
21
+ });
22
+ if (!res.ok) {
23
+ const body = await res.text().catch(() => '');
24
+ throw new Error(`${receiver} → ${res.status}\n${body}`);
25
+ }
26
+ const envelope = (await res.json());
27
+ if (envelope.outcome && envelope.outcome !== 'result') {
28
+ throw new Error(`${receiver} → ${envelope.outcome}`);
29
+ }
30
+ return envelope.result ?? envelope;
31
+ }
32
+ function resolveAuth(opts) {
33
+ const env = mergeEnv(process.cwd());
34
+ const key = opts.key ?? env.ONEIE_API_KEY ?? env.ONE_API_KEY ?? '';
35
+ return { base: opts.api.replace(/\/$/, ''), key };
36
+ }
37
+ function resolveWorkspace(explicit) {
38
+ const env = mergeEnv(process.cwd());
39
+ const workspace = explicit ?? env.AGENCY_SLUG;
40
+ if (!workspace) {
41
+ process.stderr.write('--workspace required (or set AGENCY_SLUG)\n');
42
+ process.exit(1);
43
+ }
44
+ return workspace;
45
+ }
46
+ // wallet:get/create/transactions return bare data or { error } — no `ok` field
47
+ // of their own. wallet:send already returns { ok, ... }. Normalize both to the
48
+ // { ok, ... } shape out() expects without ever overwriting a real error/false
49
+ // with a hardcoded ok:true.
50
+ export function okWrap(result) {
51
+ if ('ok' in result)
52
+ return result;
53
+ if ('error' in result)
54
+ return { ok: false, ...result };
55
+ return { ok: true, ...result };
56
+ }
57
+ export function walletCmd() {
58
+ const cmd = new Command('wallet').description('Read balances, provision a wallet row, send crypto — wallet:* receivers');
59
+ cmd.command('get')
60
+ .description('Credits, spend ceiling, wallet rows, live chain balances, delegated wallets')
61
+ .option('--workspace <slug>', 'Workspace (defaults to AGENCY_SLUG)')
62
+ .option('--actor <id>', 'Actor within the workspace (defaults to workspace)')
63
+ .option('--api <url>', 'API base URL', DEFAULT_API)
64
+ .option('--key <key>', 'API key (overrides ONEIE_API_KEY env)')
65
+ .action(async (opts) => {
66
+ const { base, key } = resolveAuth(opts);
67
+ const workspace = resolveWorkspace(opts.workspace);
68
+ const result = await ask(base, key, 'wallet:get', { workspace, actor: opts.actor });
69
+ out(cmd, okWrap(result));
70
+ });
71
+ cmd.command('create')
72
+ .description('Provision a wallet row for an actor (idempotent)')
73
+ .option('--workspace <slug>', 'Workspace (defaults to AGENCY_SLUG)')
74
+ .option('--actor <id>', 'Actor to provision (defaults to workspace)')
75
+ .option('--kind <kind>', 'human | agent', 'human')
76
+ .option('--api <url>', 'API base URL', DEFAULT_API)
77
+ .option('--key <key>', 'API key (overrides ONEIE_API_KEY env)')
78
+ .action(async (opts) => {
79
+ const { base, key } = resolveAuth(opts);
80
+ const workspace = resolveWorkspace(opts.workspace);
81
+ const result = await ask(base, key, 'wallet:create', { workspace, actor: opts.actor, kind: opts.kind });
82
+ out(cmd, okWrap(result));
83
+ });
84
+ cmd.command('transactions')
85
+ .description('Unified transaction feed across every settlement rail')
86
+ .option('--workspace <slug>', 'Workspace (defaults to AGENCY_SLUG)')
87
+ .option('--limit <n>', 'Max rows (default 100, max 500)', '100')
88
+ .option('--api <url>', 'API base URL', DEFAULT_API)
89
+ .option('--key <key>', 'API key (overrides ONEIE_API_KEY env)')
90
+ .action(async (opts) => {
91
+ const { base, key } = resolveAuth(opts);
92
+ const workspace = resolveWorkspace(opts.workspace);
93
+ const result = await ask(base, key, 'wallet:transactions', { workspace, limit: Number(opts.limit) });
94
+ out(cmd, okWrap(result));
95
+ });
96
+ cmd.command('send <to>')
97
+ .description('Send crypto via pay.one.ie payment links, incl. Bitcoin — sign the transfer yourself first, pass the tx hash')
98
+ .requiredOption('--chain <chain>', 'SUI | EVM | SOL | BTC | BASE | ARB | OPT')
99
+ .requiredOption('--amount <n>', 'Amount to send')
100
+ .requiredOption('--payment-tx <hash>', 'The transaction hash from signing & broadcasting client-side — this command never signs')
101
+ .option('--workspace <slug>', 'Source workspace (defaults to AGENCY_SLUG)')
102
+ .option('--unit <unit>', 'usd | token', 'usd')
103
+ .option('--currency <currency>', 'NATIVE | USDC', 'NATIVE')
104
+ .option('--user-address <address>', 'Sender address (defaults to --to)')
105
+ .option('--memo <text>', 'Payment memo')
106
+ .option('--api <url>', 'API base URL', DEFAULT_API)
107
+ .option('--key <key>', 'API key (overrides ONEIE_API_KEY env)')
108
+ .action(async (to, opts) => {
109
+ const { base, key } = resolveAuth(opts);
110
+ const workspace = resolveWorkspace(opts.workspace);
111
+ const result = await ask(base, key, 'wallet:send', {
112
+ workspace, to, chain: opts.chain, amount: Number(opts.amount), paymentTx: opts.paymentTx,
113
+ unit: opts.unit, currency: opts.currency, userAddress: opts.userAddress, memo: opts.memo,
114
+ });
115
+ out(cmd, okWrap(result));
116
+ });
117
+ return cmd;
118
+ }
119
+ function out(cmd, data) {
120
+ const isJson = cmd.parent?.opts().json;
121
+ if (isJson) {
122
+ process.stdout.write(JSON.stringify(data) + '\n');
123
+ }
124
+ else if (data.ok) {
125
+ const pairs = Object.entries(data)
126
+ .filter(([k]) => k !== 'ok')
127
+ .map(([k, v]) => `${k}=${JSON.stringify(v)}`)
128
+ .join(' ');
129
+ console.log('✓', pairs);
130
+ }
131
+ else {
132
+ const detail = data.error ?? data.errors ?? data.issues ?? data;
133
+ console.error('✗', typeof detail === 'string' ? detail : JSON.stringify(detail));
134
+ }
135
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oneie/cli",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "ONE agent CLI",
5
5
  "type": "module",
6
6
  "bin": {