oneie 5.7.2 → 5.7.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/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oneie",
3
- "version": "5.7.2",
3
+ "version": "5.7.4",
4
4
  "description": "ONE agent CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "commander": "^12.0.0",
23
- "@oneie/sdk": "^0.17.0"
23
+ "@oneie/sdk": "^0.17.5"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@oneie/evals": "^0.2.0",
@@ -10,7 +10,8 @@ export function displayBanner() {
10
10
  ██║ ██║██║╚██╗██║██╔══╝
11
11
  ╚██████╔╝██║ ╚████║███████╗
12
12
  ╚═════╝ ╚═╝ ╚═══╝╚══════╝
13
- Turn ideas into reality — https://one.ie
13
+ Give your agents financial superpowers.
14
+ https://one.ie
14
15
 
15
16
  `);
16
17
  }
@@ -1,2 +1,12 @@
1
1
  import { Command } from 'commander';
2
+ interface CatalogItem {
3
+ receiver: string;
4
+ summary?: string;
5
+ effect?: string;
6
+ cost?: unknown;
7
+ reversible?: boolean;
8
+ settles?: string;
9
+ }
10
+ export declare function catalogItems(data: Record<string, unknown>): CatalogItem[];
2
11
  export declare function catalogCommands(program: Command): void;
12
+ export {};
@@ -1,18 +1,9 @@
1
1
  import { askPath } from './lib/api-path.js';
2
+ import { authHeaders } from './lib/client.js';
2
3
  const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://api.one.ie';
3
- function apiKey() {
4
- return process.env.ONEIE_API_KEY ?? process.env.ONE_API_KEY ?? '';
5
- }
6
4
  function base(opts) {
7
5
  return (opts.api ?? DEFAULT_API).replace(/\/$/, '');
8
6
  }
9
- function authHeaders() {
10
- const h = { 'Content-Type': 'application/json' };
11
- const k = apiKey();
12
- if (k)
13
- h['Authorization'] = `Bearer ${k}`;
14
- return h;
15
- }
16
7
  const RECIPE_BLURB = {
17
8
  spine: 'onboard — become an actor, mint a key, declare capability',
18
9
  build: 'build a world — workspace, group, actor, thing',
@@ -50,6 +41,13 @@ function formatCatalog(items, goal) {
50
41
  }
51
42
  return out.join('\n');
52
43
  }
44
+ // The door answers { outcome, result: CatalogItem[] }; older shapes put the list at
45
+ // items / receivers. Reading only those two printed an empty catalog.
46
+ export function catalogItems(data) {
47
+ const r = data.result;
48
+ const list = Array.isArray(r) ? r : r?.items ?? data.items ?? data.receivers ?? [];
49
+ return Array.isArray(list) ? list : [];
50
+ }
53
51
  export function catalogCommands(program) {
54
52
  program
55
53
  .command('catalog')
@@ -72,7 +70,7 @@ export function catalogCommands(program) {
72
70
  process.stdout.write(JSON.stringify(data, null, 2) + '\n');
73
71
  return;
74
72
  }
75
- const items = (data.items ?? data.receivers ?? []);
73
+ const items = catalogItems(data);
76
74
  process.stdout.write(formatCatalog(items, opts.goal) + '\n');
77
75
  });
78
76
  }
@@ -2,7 +2,7 @@ import { Command } from 'commander';
2
2
  import { existsSync, readFileSync } from 'node:fs';
3
3
  import { mergeEnv } from './env.js';
4
4
  import { resolveBase, resolveKey, authHeaders } from './lib/client.js';
5
- import { readKeyFolder, keyFolderStatus } from './lib/keyfile.js';
5
+ import { readKeyFolder, keyFolderStatus, workspaceFor, KEY_DIR_NAME, LEGACY_KEY_DIR_NAME } from './lib/keyfile.js';
6
6
  import { KEY_FILE } from './lib/paths.js';
7
7
  import { askPath } from './lib/api-path.js';
8
8
  /** api.one.ie (the gateway) answers `GET /health`; one.ie/web has no /health
@@ -57,7 +57,7 @@ export async function runDoctor(dir, opts = {}) {
57
57
  name: 'config',
58
58
  ok: hasConfig,
59
59
  detail: folder
60
- ? `${dir}/.oneie/agent.key (0600, project)`
60
+ ? `${dir}/${existsSync(`${dir}/${KEY_DIR_NAME}/agent.key`) ? KEY_DIR_NAME : LEGACY_KEY_DIR_NAME}/agent.key (0600, project)`
61
61
  : hasConfig
62
62
  ? `${keyFile} (0600)`
63
63
  : `${keyFile} missing — run \`one setup\` or \`one login\``,
@@ -124,7 +124,7 @@ export function whoamiCmd() {
124
124
  body: JSON.stringify({ data: {} }),
125
125
  });
126
126
  const live = res.ok;
127
- process.stdout.write(`workspace ${env.WORKSPACE_SLUG ?? env.AGENCY_SLUG ?? '(unset)'}\n`);
127
+ process.stdout.write(`workspace ${env.WORKSPACE_SLUG ?? workspaceFor(undefined, dir, env) ?? '(unset)'}\n`);
128
128
  process.stdout.write(`key ${key.slice(0, 4)}***… ${live ? '(live)' : `(unreachable — ${base})`}\n`);
129
129
  process.stdout.write(`base ${base}\n`);
130
130
  if (!live)
package/dist/src/init.js CHANGED
@@ -150,7 +150,7 @@ export function initCmd() {
150
150
  .option('--no-content', 'Skip generating a starter agent.md')
151
151
  .option('--api <url>', 'API base URL', DEFAULT_API)
152
152
  .option('--write-env', 'Also write ONE_API_KEY to .env.local in the current directory')
153
- .option('--dir <path>', 'Write the key into THIS project folder (.oneie/agent.key, 0600, gitignored) instead of the machine-wide ~/.config/one/key')
153
+ .option('--dir <path>', 'Write the key into THIS project folder (.one/agent.key, 0600, gitignored) instead of the machine-wide ~/.config/one/key')
154
154
  .option('--ttl-days <n>', 'Key lifetime in days (default 90, max 365)')
155
155
  .option('--no-wallet', 'Skip minting a local wallet and registering its addresses')
156
156
  .option('--yes-i-accept-plaintext-file', 'Write the new wallet as a 0600 PLAINTEXT file instead of sealing it with a passphrase — needed for a non-interactive run')
package/dist/src/join.js CHANGED
@@ -21,7 +21,7 @@ export function bareDoors(agent) {
21
21
  ' oneie onboard # provision + walk the lifecycle stages\n'
22
22
  : ' npx oneie create <name> # scaffold a new group\n';
23
23
  return ('new group:\n' +
24
- ' npx oneie [--email <owner>] # key → products → test sale → handover link\n' +
24
+ ' npx oneie [--email <owner>] # your key, a product, a test sale, then one link to hand it over\n' +
25
25
  newGroup +
26
26
  'existing group:\n' +
27
27
  ' oneie login # become someone — no new group\n' +
@@ -1 +1,2 @@
1
1
  export declare function askPath(base: string, receiver: string): string;
2
+ export declare function substrateUrl(url: string): string;
@@ -7,3 +7,34 @@ export function askPath(base, receiver) {
7
7
  const isGateway = new URL(base).hostname === 'api.one.ie';
8
8
  return `${base}${isGateway ? '/ask' : '/api/ask'}/${encodeURIComponent(receiver)}`;
9
9
  }
10
+ // The other substrate doors. They were written as one.ie/web's long form (/api/mark/…),
11
+ // which api.one.ie — the default base — answers 404; only /ask knew the host. The map is the
12
+ // inverse of api/src/substrate-binding.ts PATH_MAP, so a path the gateway serves is spelled the
13
+ // way the gateway serves it and every other host keeps the long form.
14
+ const GATEWAY_SHORT = [
15
+ ['/api/export/groups', '/groups'],
16
+ ['/api/export/actors', '/actors'],
17
+ ['/api/export/paths', '/paths'],
18
+ ['/api/signal', '/signal'],
19
+ ['/api/mark', '/mark'],
20
+ ['/api/warn', '/warn'],
21
+ ['/api/fade', '/fade'],
22
+ ['/api/sub', '/sub'],
23
+ ['/api/follow', '/follow'],
24
+ ['/api/select', '/select'],
25
+ ['/api/things', '/things'],
26
+ ['/api/events', '/events'],
27
+ ['/api/learning', '/learning'],
28
+ ];
29
+ export function substrateUrl(url) {
30
+ const u = new URL(url);
31
+ if (u.hostname !== 'api.one.ie')
32
+ return url;
33
+ for (const [long, short] of GATEWAY_SHORT) {
34
+ if (u.pathname === long || u.pathname.startsWith(`${long}/`)) {
35
+ u.pathname = short + u.pathname.slice(long.length);
36
+ return u.toString();
37
+ }
38
+ }
39
+ return url;
40
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * What bare `npx oneie` SAYS to a person — the words only. The walk itself is
3
+ * `journey.ts`, and its JourneyReport is the `--json` contract an agent reads;
4
+ * nothing here changes it. This file turns that report into the home page's
5
+ * journey (one.ie, `lib/home/home-copy.ts`) told in plain English, step by step.
6
+ *
7
+ * Four steps, not nine: the CLI walks key (with keep + wallets folded in),
8
+ * make, practise and hand over. Sign in and send happen after, in the browser.
9
+ *
10
+ * COPY LAW (text/home-text.md § 0), held here too:
11
+ * - the 24 words are never printed; `wallet paper` in the person's own terminal
12
+ * - the test sale is a TEST CARD (Stripe test mode), never "Sui testnet"
13
+ * - the owner link is a bearer credential: once, 7 days, send it to one person
14
+ * - every printed command exists, spelled through `cliPrefix()` so it runs as printed
15
+ */
16
+ import type { JourneyReport } from './journey.js';
17
+ /** A box around a title — plain characters, so it reads the same in a terminal and in Claude Code. */
18
+ export declare function box(lines: string[]): string[];
19
+ /** Shown before a first run: what is about to happen, so nothing pops up unannounced. */
20
+ export declare function journeyIntro(cli: string): string;
21
+ /** Shown before a re-run. */
22
+ export declare function journeyResume(workspace: string): string;
23
+ /** The whole report, in words. */
24
+ export declare function journeyWords(r: JourneyReport, cli: string, opts?: {
25
+ agent?: string;
26
+ }): string;
27
+ /**
28
+ * What the person can do now, each move twice: the words to say to Claude, and the
29
+ * command it runs. Every command exists in this CLI and works from this folder (the
30
+ * key and the group are read from .one/). Sending is the one move the CLI does not
31
+ * sign, so it is told as the screen that does, never as a command.
32
+ */
33
+ export declare function superpowers(r: JourneyReport, cli: string): string[];
@@ -0,0 +1,221 @@
1
+ const STEPS = [
2
+ { step: 'key', title: 'Your key', line: 'Your agent makes its own key on this machine, and its wallets.',
3
+ why: 'Whoever holds the key holds the money. Here that is this machine, not ONE.' },
4
+ { step: 'products', title: 'Your product', line: 'It opens a shop and makes a product with its own checkout page.',
5
+ why: 'A checkout page is how anyone, a person or an agent, pays you.' },
6
+ { step: 'sale', title: 'A test sale', line: 'You buy it once with a test card. No real money moves.',
7
+ why: 'You rehearse the whole sale before real money is ever at stake.' },
8
+ { step: 'handover', title: 'Hand over', line: 'It gives you one link. Open it, and the shop is yours.',
9
+ why: 'The agent does the work. A person owns what it built.' },
10
+ ];
11
+ const MARK = { done: '✓', pending: '…', waiting: '·', failed: '✗' };
12
+ /** The chains in the home page's order, whatever key the server named them by. */
13
+ const CHAINS = [
14
+ { label: 'Sui', keys: ['sui'] },
15
+ { label: 'EVM', keys: ['evm', 'eth', 'ethereum'], note: 'Ethereum, Base and the other EVM networks' },
16
+ { label: 'Solana', keys: ['sol', 'solana'] },
17
+ { label: 'Bitcoin', keys: ['btc', 'bitcoin'] },
18
+ { label: 'ASI', keys: ['asi', 'fet', 'fetch'] },
19
+ ];
20
+ /** `npx oneie` in a sentence becomes whatever this process was started as. */
21
+ const spell = (text, cli) => text.replaceAll('npx oneie', cli);
22
+ const indent = (lines, by = ' ') => lines.map((l) => (l ? by + l : l));
23
+ /** A box around a title — plain characters, so it reads the same in a terminal and in Claude Code. */
24
+ export function box(lines) {
25
+ const w = Math.max(...lines.map((l) => [...l].length));
26
+ return ['╭' + '─'.repeat(w + 4) + '╮', ...lines.map((l) => `│ ${l}${' '.repeat(w - [...l].length)} │`), '╰' + '─'.repeat(w + 4) + '╯'];
27
+ }
28
+ const HEADER = box(['ONE · Give your agents financial superpowers', 'A key, wallets, a shop and a first sale, from this folder.']);
29
+ /** Shown before a first run: what is about to happen, so nothing pops up unannounced. */
30
+ export function journeyIntro(cli) {
31
+ const width = Math.max(...STEPS.map((s) => s.title.length));
32
+ return [
33
+ ...HEADER,
34
+ '',
35
+ 'Here is the path. Four steps, and each one is checked before the next starts.',
36
+ '',
37
+ ...STEPS.map((s, i) => ` ${i + 1}. ${s.title.padEnd(width)} ${s.line}`),
38
+ '',
39
+ 'You are in control. Nothing here moves real money, and nothing secret is printed.',
40
+ `Stop at any step. Run ${cli} again and it picks up where it left off.`,
41
+ '',
42
+ ].join('\n') + '\n';
43
+ }
44
+ /** Shown before a re-run. */
45
+ export function journeyResume(workspace) {
46
+ return [...HEADER, '', `Picking up where you left off, for ${workspace}.`, '', ''].join('\n');
47
+ }
48
+ function addressLines(addresses) {
49
+ const seen = new Set();
50
+ const rows = [];
51
+ for (const c of CHAINS) {
52
+ const k = c.keys.find((key) => typeof addresses[key] === 'string' && addresses[key]);
53
+ if (!k)
54
+ continue;
55
+ seen.add(k);
56
+ rows.push([c.label, addresses[k], c.note]);
57
+ }
58
+ for (const [k, v] of Object.entries(addresses))
59
+ if (!seen.has(k) && v)
60
+ rows.push([k, v]);
61
+ const w = Math.max(0, ...rows.map((r) => r[0].length));
62
+ return rows.map(([label, addr, note]) => ` ${label.padEnd(w)} ${addr}${note ? ` (${note})` : ''}`);
63
+ }
64
+ function failed(s, cli) {
65
+ const out = ['This step stopped.'];
66
+ if (s.detail.error)
67
+ out.push(`Why: ${spell(String(s.detail.error), cli)}`);
68
+ if (s.detail.fix)
69
+ out.push(`To fix it: ${spell(String(s.detail.fix), cli)}`);
70
+ if (s.detail.workspace)
71
+ out.push(`Your group: ${String(s.detail.workspace)}`);
72
+ return out;
73
+ }
74
+ function keyLines(s, cli) {
75
+ if (s.status === 'failed')
76
+ return failed(s, cli);
77
+ const d = s.detail;
78
+ const addresses = (d.addresses && typeof d.addresses === 'object' ? d.addresses : {});
79
+ const n = Object.keys(addresses).length;
80
+ const keychain = String(d.sealed ?? '').startsWith('Apple');
81
+ if (s.reused) {
82
+ // A re-run: the key was told in full the first time. Say it is still here, and how it opens.
83
+ const chains = CHAINS.filter((c) => c.keys.some((k) => addresses[k])).map((c) => c.label);
84
+ return [
85
+ `Your agent's key is still here, ${keychain ? 'in your Apple Keychain. Touch ID opens it' : 'locked with your passphrase'}.`,
86
+ ...(chains.length ? [`Wallets on ${chains.length > 1 ? `${chains.slice(0, -1).join(', ')} and ${chains.at(-1)}` : chains[0]}.`] : []),
87
+ `Not on paper yet? Run ${cli} wallet paper in your own terminal.`,
88
+ ];
89
+ }
90
+ return [
91
+ 'Your agent made its own key, here on this machine. ONE never saw it.',
92
+ keychain ? 'It is locked in your Apple Keychain. Touch ID opens it.' : 'It is locked with the passphrase you chose.',
93
+ '',
94
+ n > 0
95
+ ? `One key, ${n === 1 ? 'one wallet' : `${n} wallets`}. Anyone can pay these addresses. Only your key can spend from them.`
96
+ : 'Your wallet is made.',
97
+ ...addressLines(addresses),
98
+ '',
99
+ 'Now keep it. Write the 24 words on paper. Run this in your own terminal:',
100
+ ` ${cli} wallet paper`,
101
+ 'The words are never printed here. Lose every copy and ONE cannot bring them back.',
102
+ '',
103
+ `Your group: ${String(d.workspace ?? '')}`,
104
+ ];
105
+ }
106
+ function productLines(s, cli) {
107
+ if (s.status === 'failed')
108
+ return failed(s, cli);
109
+ const products = Array.isArray(s.detail.products) ? s.detail.products.map(String) : [];
110
+ return [
111
+ 'Your shop is open, in test mode. Each product has its own checkout page:',
112
+ ...products.map((p) => {
113
+ // "Name 1.00 USD https://…" — drawn as columns; anything else prints as it came.
114
+ const m = /^(.*) (\d+\.\d{2}) ([A-Z]{3}) (\S+)$/.exec(p);
115
+ return m ? ` ${m[1]} ${m[2]} ${m[3]} ${m[4]}` : ` ${p}`;
116
+ }),
117
+ ];
118
+ }
119
+ function saleLines(s, cli) {
120
+ if (s.status === 'failed')
121
+ return failed(s, cli);
122
+ if (s.status === 'done') {
123
+ const n = Number(s.detail.purchases ?? 1);
124
+ return [`${n === 1 ? 'One sale' : `${n} sales`} counted, read back from your shop. Test money: nothing real moved.`];
125
+ }
126
+ const [number, ...rest] = String(s.detail.card ?? '').split(' · ');
127
+ return [
128
+ 'Nothing sold yet. Make the first sale yourself, with test money:',
129
+ '',
130
+ ` 1. Open this page ${String(s.detail.pay ?? '')}`,
131
+ ` 2. Pay with test card ${number}`,
132
+ ...(rest.length ? [` ${rest.join(', ')}`] : []),
133
+ ` 3. Then come back, run ${cli}`,
134
+ '',
135
+ 'No real card is charged. The sale counts only once your shop reads it back.',
136
+ ];
137
+ }
138
+ function handoverLines(s, cli) {
139
+ if (s.status === 'failed')
140
+ return failed(s, cli);
141
+ if (s.status === 'waiting')
142
+ return ['This waits for the test sale. Once it is counted, your link appears here.'];
143
+ return [
144
+ 'Your agent built it. Now it is yours to take.',
145
+ 'Open this link, make your own key in the browser, and press Accept:',
146
+ ` ${String(s.detail.link ?? '')}`,
147
+ ...(s.detail.emailed ? [`We also sent it to ${String(s.detail.emailed)}.`] : []),
148
+ '',
149
+ 'Keep it private. Anyone with this link can claim the owner seat.',
150
+ 'It works once and lasts 7 days. Sales stay on test money until you take the shop live.',
151
+ ];
152
+ }
153
+ const LINES = {
154
+ key: keyLines, products: productLines, sale: saleLines, handover: handoverLines,
155
+ };
156
+ /** The whole report, in words. */
157
+ export function journeyWords(r, cli, opts = {}) {
158
+ const out = [];
159
+ r.steps.forEach((s) => {
160
+ const n = STEPS.findIndex((x) => x.step === s.step);
161
+ const title = STEPS[n]?.title ?? s.step;
162
+ const tag = s.reused && s.status === 'done' ? ' (done on an earlier run)' : '';
163
+ out.push(`${MARK[s.status] ?? '?'} ${n + 1} of ${STEPS.length} ${title}${tag}`);
164
+ if (STEPS[n] && !s.reused && s.status !== 'failed')
165
+ out.push(` Why it matters: ${STEPS[n].why}`, '');
166
+ out.push(...indent((LINES[s.step] ?? ((x) => failed(x, cli)))(s, cli)), '');
167
+ });
168
+ // Steps never reached (an early stop) still show, so the person sees the whole path.
169
+ for (let i = r.steps.length; i < STEPS.length; i++) {
170
+ out.push(`· ${i + 1} of ${STEPS.length} ${STEPS[i].title}`, ` Not started. ${STEPS[i].line}`, '');
171
+ }
172
+ const panel = superpowers(r, cli);
173
+ if (panel.length)
174
+ out.push(...panel, '');
175
+ // The one thing to do now goes last, under everything, where the eye lands.
176
+ const allDone = r.ok && r.steps.length === STEPS.length && r.steps.every((s) => s.status === 'done');
177
+ if (allDone) {
178
+ out.push('Done. Your agent has a key, a shop and a first test sale, and you hold the link that makes it yours.');
179
+ }
180
+ else if (r.next) {
181
+ const next = spell(r.next, cli).replaceAll('`', '');
182
+ out.push(`Next: ${next.charAt(0).toUpperCase()}${next.slice(1)}`);
183
+ }
184
+ if (opts.agent === 'claude-code') {
185
+ out.push('', '(Claude: offer the person these moves as choices and run the one they pick. The 24 words are theirs to write down in their own terminal. Never ask for them.)');
186
+ }
187
+ return out.join('\n') + '\n';
188
+ }
189
+ /**
190
+ * What the person can do now, each move twice: the words to say to Claude, and the
191
+ * command it runs. Every command exists in this CLI and works from this folder (the
192
+ * key and the group are read from .one/). Sending is the one move the CLI does not
193
+ * sign, so it is told as the screen that does, never as a command.
194
+ */
195
+ export function superpowers(r, cli) {
196
+ const key = r.steps.find((s) => s.step === 'key');
197
+ if (!key || key.status !== 'done')
198
+ return [];
199
+ const addresses = (key.detail.addresses ?? {});
200
+ const sui = addresses.sui ?? '<your Sui address>';
201
+ const moves = [
202
+ { what: 'See your balances', say: 'show my balances', run: `${cli} wallet get` },
203
+ { what: 'Get free test coins', say: 'fill my wallet with test coins', run: `${cli} wallet faucet ${sui} --chain sui --network testnet` },
204
+ { what: 'Sell something new', say: 'sell a mug for $12.50', run: `${cli} --product "Mug=12.50"` },
205
+ { what: 'See what came in', say: 'what payments came in?', run: `${cli} wallet transactions` },
206
+ { what: 'Ask ONE anything', say: 'how do I get paid in USDC?', run: `${cli} message "how do I get paid in USDC?"` },
207
+ ];
208
+ const w = Math.max(...moves.map((m) => m.what.length));
209
+ const pad = ' '.repeat(w + 4);
210
+ return [
211
+ ...box(['Your superpowers', 'Say it to Claude, or run it yourself. Every one is real.']),
212
+ '',
213
+ ...moves.flatMap((m) => [` ${m.what.padEnd(w)} "${m.say}"`, `${pad}${m.run}`, '']),
214
+ ` ${'Send money'.padEnd(w)} "how do I send USDC?"`,
215
+ `${pad}Once you own it: https://one.ie/wallets, press Send.`,
216
+ `${pad}Your key signs on your device. Stablecoins wallet to wallet on Sui:`,
217
+ `${pad}ONE takes no fee. Sui charges its own small network fee, paid in SUI.`,
218
+ '',
219
+ ` Every command: ${cli} --help`,
220
+ ];
221
+ }
@@ -225,12 +225,12 @@ export async function runJourney(deps, o) {
225
225
  const k = await keyStep(deps, o, deps.load());
226
226
  steps.push(k.report);
227
227
  if (!k.state || !k.key)
228
- return { ok: false, steps, next: 'fix the key step and run `npx oneie` again' };
228
+ return { ok: false, steps, next: 'fix what stopped the key step above, then run `npx oneie` again' };
229
229
  const state = k.state;
230
230
  const products = await productsStep(deps, o, state, k.key);
231
231
  steps.push(products);
232
232
  if (products.status !== 'done') {
233
- return { ok: false, workspace: state.workspace, steps, next: 'fix the products step and run `npx oneie` again' };
233
+ return { ok: false, workspace: state.workspace, steps, next: 'fix what stopped the product step above, then run `npx oneie` again' };
234
234
  }
235
235
  // A re-run: the shop already had its products before this run, so someone was sent to pay.
236
236
  const sale = await saleStep(deps, o, state, k.key, products.reused === true);
@@ -239,7 +239,7 @@ export async function runJourney(deps, o) {
239
239
  steps.push(handover);
240
240
  const failed = steps.some((s) => s.status === 'failed');
241
241
  const next = sale.status === 'pending'
242
- ? 'pay with the test card at the link above, then run `npx oneie` again — it waits for the sale to land (or `npx oneie --wait 30` to wait here now)'
242
+ ? 'pay with the test card at the link above, then run `npx oneie` again. It waits a few seconds for the sale to land. Or run `npx oneie --wait 30` to wait here while you pay'
243
243
  : undefined;
244
244
  return { ok: !failed, workspace: state.workspace, steps, ...(next ? { next } : {}) };
245
245
  }
@@ -128,3 +128,9 @@ export declare function readKeyFolder(dir: string): {
128
128
  * a silent null is right for `resolveKey` and useless for `doctor`.
129
129
  */
130
130
  export declare function keyFolderStatus(dir: string): 'none' | 'ok' | 'foreign' | 'unsafe' | 'unreadable';
131
+ /**
132
+ * Which workspace a command acts in: flag > AGENCY_SLUG > the workspace `npx oneie`
133
+ * saved beside this folder's key. The journey already knows the agent's workspace;
134
+ * asking for it again was a dead end (`wallet get`, `whoami`).
135
+ */
136
+ export declare function workspaceFor(explicit: string | undefined, dir: string, env: Record<string, string>): string | undefined;
@@ -382,3 +382,16 @@ export function keyFolderStatus(dir) {
382
382
  return 'unreadable';
383
383
  }
384
384
  }
385
+ /**
386
+ * Which workspace a command acts in: flag > AGENCY_SLUG > the workspace `npx oneie`
387
+ * saved beside this folder's key. The journey already knows the agent's workspace;
388
+ * asking for it again was a dead end (`wallet get`, `whoami`).
389
+ */
390
+ export function workspaceFor(explicit, dir, env) {
391
+ if (explicit)
392
+ return explicit;
393
+ if (env.AGENCY_SLUG)
394
+ return env.AGENCY_SLUG;
395
+ const saved = readKeyFolder(dir)?.meta.workspace;
396
+ return typeof saved === 'string' && saved ? saved : undefined;
397
+ }
@@ -95,8 +95,8 @@ export interface GiveSdk {
95
95
  * Swappable in tests (the message-seal.ts `loaders` shape): the cli resolves `@oneie/sdk` through
96
96
  * its own node_modules, which can be a published or main-tree SDK older than `./secrets-give`;
97
97
  * a test serves the source. `oneVault` is the reader of ONE's vault and the ONLY source of ONE's
98
- * lock — the IC#7 fixture until C14 reaches testnet, which answers no lock, so a give refuses
99
- * `no_one_lock`. Nothing in the environment or on disk can name another lock (C8 repair 3); a
98
+ * lock — C14 reached testnet 2026-11-08: the fixture is the SDK's mirror of ONE's testnet vault
99
+ * (ONE_VAULT_ID), pinned equal to the chain by one-vault-chain.test.ts. Nothing in the environment or on disk can name another lock (C8 repair 3); a
100
100
  * test injects a reader by assigning this field. `fetch` is the one network call.
101
101
  */
102
102
  export declare const giveLoaders: {
@@ -47,8 +47,8 @@ const GIVE_SPEC = '@oneie/sdk/secrets-give'; // a variable, so a bundler/vite do
47
47
  * Swappable in tests (the message-seal.ts `loaders` shape): the cli resolves `@oneie/sdk` through
48
48
  * its own node_modules, which can be a published or main-tree SDK older than `./secrets-give`;
49
49
  * a test serves the source. `oneVault` is the reader of ONE's vault and the ONLY source of ONE's
50
- * lock — the IC#7 fixture until C14 reaches testnet, which answers no lock, so a give refuses
51
- * `no_one_lock`. Nothing in the environment or on disk can name another lock (C8 repair 3); a
50
+ * lock — C14 reached testnet 2026-11-08: the fixture is the SDK's mirror of ONE's testnet vault
51
+ * (ONE_VAULT_ID), pinned equal to the chain by one-vault-chain.test.ts. Nothing in the environment or on disk can name another lock (C8 repair 3); a
52
52
  * test injects a reader by assigning this field. `fetch` is the one network call.
53
53
  */
54
54
  export const giveLoaders = {
@@ -0,0 +1,27 @@
1
+ /**
2
+ * secrets-list.ts — `one secrets list`: your secrets desk from the terminal (text/secrets.md
3
+ * § What an agent sees; the `secrets:list` receiver, C15).
4
+ *
5
+ * Read only. One POST to secrets:list through ask(); the web side reads WHO from the session or
6
+ * the API key and D1 — this command sends nothing about the caller. Names and meters only: the
7
+ * receiver never returns a value, and this prints only what it returned.
8
+ *
9
+ * Lending and Stop are not here. A person signs a grant or a Stop with a passkey on the seal
10
+ * page, in a window of its own (plan D11, § Signatures); an agent may sign with its own ed25519
11
+ * key, but no vault holds a grant-signer list until the D37 package is published (D46), so an
12
+ * agent-signed grant has nothing to verify against yet.
13
+ */
14
+ import { Command } from 'commander';
15
+ /** Swappable in tests. `fetch` is the one network call. */
16
+ export declare const listLoaders: {
17
+ fetch: (input: string, init: RequestInit) => Promise<Response>;
18
+ };
19
+ type Rec = Record<string, unknown>;
20
+ /** The desk in a few human lines — never a value, never a full id where a short one reads. */
21
+ export declare function deskLines(r: Rec): string[];
22
+ export declare function listAction(o: {
23
+ api?: string;
24
+ }, c: Command): Promise<void>;
25
+ /** The `list` subcommand, fresh per call (a Command has one parent). */
26
+ export declare function buildList(): Command;
27
+ export {};
@@ -0,0 +1,84 @@
1
+ /**
2
+ * secrets-list.ts — `one secrets list`: your secrets desk from the terminal (text/secrets.md
3
+ * § What an agent sees; the `secrets:list` receiver, C15).
4
+ *
5
+ * Read only. One POST to secrets:list through ask(); the web side reads WHO from the session or
6
+ * the API key and D1 — this command sends nothing about the caller. Names and meters only: the
7
+ * receiver never returns a value, and this prints only what it returned.
8
+ *
9
+ * Lending and Stop are not here. A person signs a grant or a Stop with a passkey on the seal
10
+ * page, in a window of its own (plan D11, § Signatures); an agent may sign with its own ed25519
11
+ * key, but no vault holds a grant-signer list until the D37 package is published (D46), so an
12
+ * agent-signed grant has nothing to verify against yet.
13
+ */
14
+ import { Command } from 'commander';
15
+ import { askPath } from './lib/api-path.js';
16
+ import { authHeaders, jsonMode, out, resolveBase } from './lib/client.js';
17
+ /** Swappable in tests. `fetch` is the one network call. */
18
+ export const listLoaders = {
19
+ fetch: (input, init) => fetch(input, init),
20
+ };
21
+ /** D51: an "unlimited" lend signs this ceiling (UNLIMITED_PER_DAY in @oneie/sdk/secrets; kept here so the CLI runs on a published SDK that predates it). */
22
+ const UNLIMITED_PER_DAY = 1_000_000;
23
+ const leftLine = (l) => {
24
+ const per = Number(l['perDay']);
25
+ if (per === UNLIMITED_PER_DAY)
26
+ return `${per - Number(l['left_today'] ?? per)} today · no daily limit (ceiling 1,000,000)`;
27
+ return `${String(l['left_today'] ?? '?')}/${String(l['perDay'] ?? '?')} left today`;
28
+ };
29
+ const arr = (v) => (Array.isArray(v) ? v : []);
30
+ /** The desk in a few human lines — never a value, never a full id where a short one reads. */
31
+ export function deskLines(r) {
32
+ const lines = [];
33
+ const keys = arr(r['keys']);
34
+ const lent = arr(r['lentToMe']);
35
+ lines.push(`ok keys=${keys.length} lent_to_me=${lent.length} vaults=${arr(r['vaults']).length}${r['capped'] === true ? ' capped=true' : ''}`);
36
+ for (const k of keys) {
37
+ const grants = arr(k['grants']);
38
+ const live = grants.filter((g) => g['stopped'] !== true).length;
39
+ lines.push(`key ${String(k['name'] ?? '?')} ${String(k['provider'] ?? '?')} …${String(k['last4'] ?? '')} grants=${live} live/${grants.length}${k['flagged'] ? ` flagged=${String(k['flagged'])}` : ''}`);
40
+ }
41
+ for (const l of lent) {
42
+ lines.push(`lent ${String(l['name'] ?? '?')} ${String(l['provider'] ?? '?')} from ${String(l['from'] ?? '?')} ${leftLine(l)} until ${String(l['until'] ?? '?')}${l['stopped'] === true ? ' STOPPED' : l['accepted'] === true ? '' : ' not accepted'}`);
43
+ }
44
+ for (const c of arr(r['composio'])) {
45
+ if (!c['requireGrants'])
46
+ lines.push(`composio ${String(c['group'] ?? '?')} running without a grant today=${String(c['noGrantToday'] ?? 0)}`);
47
+ }
48
+ return lines;
49
+ }
50
+ export async function listAction(o, c) {
51
+ const base = resolveBase({ api: o.api });
52
+ let res;
53
+ try {
54
+ res = await listLoaders.fetch(askPath(base, 'secrets:list'), { method: 'POST', headers: authHeaders(), body: JSON.stringify({ data: {} }) });
55
+ }
56
+ catch {
57
+ return out(c, { ok: false, error: `could not reach ${base}`, code: 'unreachable' });
58
+ }
59
+ let json = {};
60
+ try {
61
+ json = (await res.json());
62
+ }
63
+ catch {
64
+ /* the status speaks */
65
+ }
66
+ const r = json['result'] ?? json;
67
+ if (!res.ok || r['ok'] !== true) {
68
+ const code = String(r['refused'] ?? r['error'] ?? `http_${res.status}`);
69
+ const why = code === 'opener_unbound' ? ' — the opener is not live on this host yet; nothing was read' : '';
70
+ return out(c, { ok: false, error: `secrets:list refused: ${code}${why}`, code });
71
+ }
72
+ if (jsonMode(c)) {
73
+ process.stdout.write(JSON.stringify(r) + '\n');
74
+ return;
75
+ }
76
+ process.stdout.write(deskLines(r).join('\n') + '\n');
77
+ }
78
+ /** The `list` subcommand, fresh per call (a Command has one parent). */
79
+ export function buildList() {
80
+ return new Command('list')
81
+ .description('Your secrets desk — the keys you gave ONE, who uses them, keys lent to you. Names and meters, never values')
82
+ .option('--api <url>', 'API base (default: ONE_API_URL or https://one.ie)')
83
+ .action(listAction);
84
+ }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * secrets.ts — `one secrets seal | run | add-device | give`: the sealed .env.
2
+ * secrets.ts — `one secrets seal | run | add-device | give | list`: the sealed .env.
3
3
  * (text/secrets.md deliverables 1 and 5; text/secrets-todo.md § C1.)
4
4
  *
5
5
  * `seal` is the one verb built here. It turns a plaintext .env into `.env.sealed` v1 —
@@ -17,7 +17,8 @@
17
17
  * `run` and `hash` live in secrets-run.ts (C2). `add-device` (secrets-device.ts, C3) makes this
18
18
  * Mac a reader; a Secure Enclave lock among the readers seals through the `age` program
19
19
  * (lib/age-plugin.ts). `give` (secrets-give.ts, C8) hands a key to ONE, sealed to the lock ONE's
20
- * vault names and signed by an agent's own key.
20
+ * vault names and signed by an agent's own key. `list` (secrets-list.ts, C15) reads the desk —
21
+ * secrets:list, names and meters, never values.
21
22
  */
22
23
  import { Command } from 'commander';
23
24
  import { type Fail } from './lib/message-seal.js';
@@ -1,5 +1,5 @@
1
1
  /**
2
- * secrets.ts — `one secrets seal | run | add-device | give`: the sealed .env.
2
+ * secrets.ts — `one secrets seal | run | add-device | give | list`: the sealed .env.
3
3
  * (text/secrets.md deliverables 1 and 5; text/secrets-todo.md § C1.)
4
4
  *
5
5
  * `seal` is the one verb built here. It turns a plaintext .env into `.env.sealed` v1 —
@@ -17,7 +17,8 @@
17
17
  * `run` and `hash` live in secrets-run.ts (C2). `add-device` (secrets-device.ts, C3) makes this
18
18
  * Mac a reader; a Secure Enclave lock among the readers seals through the `age` program
19
19
  * (lib/age-plugin.ts). `give` (secrets-give.ts, C8) hands a key to ONE, sealed to the lock ONE's
20
- * vault names and signed by an agent's own key.
20
+ * vault names and signed by an agent's own key. `list` (secrets-list.ts, C15) reads the desk —
21
+ * secrets:list, names and meters, never values.
21
22
  */
22
23
  import { existsSync, readFileSync, renameSync, unlinkSync, writeFileSync } from 'node:fs';
23
24
  import { homedir } from 'node:os';
@@ -29,6 +30,7 @@ import { ageModule, loadSecretsKey, MAX_INPUT_BYTES } from './lib/message-seal.j
29
30
  import { AgePluginError, isPluginLock, PLUGIN_LOCK_RE, requireAge } from './lib/age-plugin.js';
30
31
  import { addDeviceAction } from './secrets-device.js';
31
32
  import { buildGive } from './secrets-give.js';
33
+ import { buildList } from './secrets-list.js';
32
34
  import { buildHash, buildRun } from './secrets-run.js';
33
35
  export function fail(cmd, f) {
34
36
  if (jsonMode(cmd))
@@ -193,5 +195,6 @@ export function secretsCmd() {
193
195
  .option('--name <label>', 'A name for this Mac (default: its hostname)')
194
196
  .option('--replace', 'Make a new key even though one exists (the old one stops being a reader)')
195
197
  .action(addDeviceAction))
196
- .addCommand(buildGive());
198
+ .addCommand(buildGive())
199
+ .addCommand(buildList());
197
200
  }
package/dist/src/start.js CHANGED
@@ -15,9 +15,11 @@ import { jsonMode } from './lib/client.js';
15
15
  import { KEY_DIR_NAME, KEY_FILE_NAME, LEGACY_KEY_DIR_NAME, META_FILE_NAME, readKeyFolder, writeKeyFolder } from './lib/keyfile.js';
16
16
  import { keychainAvailable, readVaultFolder, vaultPath } from './lib/vaultfile.js';
17
17
  import { cliPrefix } from './lib/invoked-as.js';
18
+ import { agentType } from './lib/agent-env.js';
18
19
  import { provisionLocalWallet } from './init.js';
19
20
  import { promptSecret, registerSealedWallet } from './wallet.js';
20
21
  import { parseProductSpec, runJourney, } from './lib/journey.js';
22
+ import { journeyIntro, journeyResume, journeyWords } from './lib/journey-words.js';
21
23
  const DEFAULT_API = process.env.ONEIE_BASE_URL ?? 'https://one.ie';
22
24
  /** The flags bare `npx oneie --email …` hands to `start` — the journey's own, nothing else. */
23
25
  export const START_FLAGS = new Set(['--name', '--email', '--product', '--currency', '--wait', '--api']);
@@ -66,14 +68,14 @@ async function walletStore(dir) {
66
68
  if (!process.stdin.isTTY) {
67
69
  return { error: 'no Apple Keychain here and no terminal to type a passphrase into — run `npx oneie wallet new` in your own terminal, then `npx oneie wallet register --kind agent`' };
68
70
  }
69
- const passphrase = await promptSecret('Passphrase to seal the agent wallet: ');
70
- if (passphrase !== (await promptSecret('Repeat it: ')))
71
- return { error: 'passphrases did not match — no wallet was made' };
71
+ const passphrase = await promptSecret('Choose a passphrase to lock your agent\'s wallet (8 characters or more): ');
72
+ if (passphrase !== (await promptSecret('Type it again: ')))
73
+ return { error: 'the two passphrases did not match, so no wallet was made. Run it again and type the same one twice' };
72
74
  if (passphrase.length < 8)
73
- return { error: 'passphrase too short — no wallet was made' };
75
+ return { error: 'that passphrase is shorter than 8 characters, so no wallet was made. Run it again with a longer one' };
74
76
  return { kind: 'vault', dir, passphrase };
75
77
  }
76
- function deps(dir, api) {
78
+ function deps(dir, api, say) {
77
79
  return {
78
80
  load: () => loadState(dir),
79
81
  save: (s) => saveState(dir, s),
@@ -99,6 +101,7 @@ function deps(dir, api) {
99
101
  return null;
100
102
  },
101
103
  provision: async (body) => {
104
+ say('Making your agent\'s key and its own group on one.ie…');
102
105
  const res = await fetch(`${api}/api/provision/agent`, {
103
106
  method: 'POST',
104
107
  headers: { 'Content-Type': 'application/json' },
@@ -113,6 +116,7 @@ function deps(dir, api) {
113
116
  // (Touch ID for a Keychain seal) and register THAT one — minting again would
114
117
  // be refused, and would leave the first wallet's addresses orphaned.
115
118
  if (existsSync(vaultPath(dir))) {
119
+ say('Opening the wallet made on an earlier run. Touch ID may ask you to confirm…');
116
120
  const r = await registerSealedWallet({ base: api, key, workspace, actor: workspace, dir });
117
121
  return r.ok
118
122
  ? { ok: true, file: vaultPath(dir), keychain: readVaultFolder(dir)?.wrap === 'keychain', addresses: (r.addresses ?? {}) }
@@ -121,6 +125,9 @@ function deps(dir, api) {
121
125
  const store = await walletStore(dir);
122
126
  if ('error' in store)
123
127
  return { ok: false, error: store.error };
128
+ say(store.kind === 'keychain'
129
+ ? 'Locking your agent\'s wallet in your Apple Keychain. Touch ID may ask you to confirm…'
130
+ : 'Locking your agent\'s wallet with your passphrase…');
124
131
  return provisionLocalWallet({ api, key, workspace, store });
125
132
  },
126
133
  ask: async (key, receiver, data) => {
@@ -139,32 +146,9 @@ function deps(dir, api) {
139
146
  now: () => Date.now(),
140
147
  };
141
148
  }
142
- const MARK = { done: '✓', pending: '…', waiting: '·', failed: '✗' };
143
- function render(r, cli) {
144
- const lines = ['ONE — key → products → test sale → handover', ''];
145
- for (const s of r.steps) {
146
- lines.push(`${MARK[s.status] ?? '?'} ${s.step.padEnd(9)} ${s.status}${s.reused ? ' (earlier run)' : ''}`);
147
- for (const [k, v] of Object.entries(s.detail)) {
148
- if (Array.isArray(v)) {
149
- lines.push(` ${k}:`);
150
- for (const item of v)
151
- lines.push(` ${String(item)}`);
152
- }
153
- else if (v && typeof v === 'object') {
154
- lines.push(` ${k}: ${Object.entries(v).map(([a, b]) => `${a} ${String(b)}`).join(', ')}`);
155
- }
156
- else if (v !== undefined) {
157
- lines.push(` ${k}: ${String(v)}`);
158
- }
159
- }
160
- }
161
- if (r.next)
162
- lines.push('', `next: ${r.next.replaceAll('npx oneie', cli)}`);
163
- return lines.join('\n') + '\n';
164
- }
165
149
  export function startCmd() {
166
150
  const cmd = new Command('start')
167
- .description('The whole journey in this folder — key → products → test sale → handover link. Bare `npx oneie` runs it; a re-run resumes')
151
+ .description('Walk the whole path in this folder: your key, a product, a test sale, then one link that hands it over. Bare `npx oneie` runs it; run it again to pick up where you left off')
168
152
  .option('--name <name>', 'Workspace / agent display name', 'My Shop')
169
153
  .option('--email <email>', "The new owner's email — the handover link is sent there as well as printed")
170
154
  .option('--product <name=price>', 'A product in major units, e.g. "Mug=12.50" (repeatable; default one Test product at 1.00)', (v, acc) => [...acc, v], [])
@@ -186,17 +170,24 @@ export function startCmd() {
186
170
  products.push(p.product);
187
171
  }
188
172
  const api = opts.api.replace(/\/$/, '');
189
- const report = await runJourney(deps(process.cwd(), api), {
173
+ const json = jsonMode(sub);
174
+ const cli = cliPrefix();
175
+ if (!json) {
176
+ const earlier = loadState(process.cwd());
177
+ process.stdout.write(earlier ? journeyResume(earlier.workspace) : journeyIntro(cli));
178
+ }
179
+ const say = json ? () => { } : (line) => process.stderr.write(` ${line}\n`);
180
+ const report = await runJourney(deps(process.cwd(), api, say), {
190
181
  api,
191
182
  name: opts.name,
192
183
  ...(opts.email ? { email: opts.email } : {}),
193
184
  products,
194
185
  ...(opts.wait !== undefined ? { waitSeconds: Math.max(0, Number(opts.wait) || 0) } : {}),
195
186
  });
196
- if (jsonMode(sub))
187
+ if (json)
197
188
  process.stdout.write(JSON.stringify(report) + '\n');
198
189
  else
199
- process.stdout.write(render(report, cliPrefix()));
190
+ process.stdout.write('\n' + journeyWords(report, cli, { agent: agentType() }));
200
191
  if (!report.ok)
201
192
  process.exitCode = 1;
202
193
  });
@@ -1,12 +1,12 @@
1
1
  import { authHeaders, resolveBase, resolveKey } from './lib/client.js';
2
- import { askPath } from './lib/api-path.js';
2
+ import { askPath, substrateUrl } from './lib/api-path.js';
3
3
  import { sendMessage } from './message.js';
4
4
  const DEFAULT_API = resolveBase({}, 'https://api.one.ie');
5
5
  function base(opts) {
6
6
  return resolveBase(opts, 'https://api.one.ie');
7
7
  }
8
8
  async function api(url, init) {
9
- const res = await fetch(url, { headers: authHeaders(), ...init });
9
+ const res = await fetch(substrateUrl(url), { headers: authHeaders(), ...init });
10
10
  if (!res.ok) {
11
11
  const body = await res.text().catch(() => '');
12
12
  process.stderr.write(`${init?.method ?? 'GET'} ${url} → ${res.status}\n${body}\n`);
package/dist/src/trade.js CHANGED
@@ -1,18 +1,9 @@
1
1
  import { askPath } from './lib/api-path.js';
2
+ import { authHeaders } from './lib/client.js';
2
3
  const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://api.one.ie';
3
- function apiKey() {
4
- return process.env.ONEIE_API_KEY ?? process.env.ONE_API_KEY ?? '';
5
- }
6
4
  function base(opts) {
7
5
  return (opts.api ?? DEFAULT_API).replace(/\/$/, '');
8
6
  }
9
- function authHeaders() {
10
- const h = { 'Content-Type': 'application/json' };
11
- const k = apiKey();
12
- if (k)
13
- h['Authorization'] = `Bearer ${k}`;
14
- return h;
15
- }
16
7
  async function ask(b, receiver, data) {
17
8
  const res = await fetch(askPath(b, receiver), {
18
9
  method: 'POST',
@@ -76,12 +67,17 @@ export function tradeCommands(program) {
76
67
  });
77
68
  program
78
69
  .command('earn')
79
- .description('Show credit earned summary (pay:weight)')
70
+ .description('What this workspace has earned — card money waiting, crypto owed, credit balance')
80
71
  .option('--api <url>', 'API base URL', DEFAULT_API)
81
72
  .option('--json', 'Output raw JSON')
82
73
  .action(async (opts) => {
83
- const data = await ask(base(opts), 'pay:weight', {});
84
- process.stdout.write(JSON.stringify(data, null, 2) + '\n');
74
+ // pay:weight PAYS for a task (needs to/task/amount); it was never a summary.
75
+ // These two are what an agent key can read, and they answer for its own workspace.
76
+ const [store, credits] = await Promise.all([
77
+ ask(base(opts), 'storefront:balance', {}),
78
+ ask(base(opts), 'credits:balance', {}),
79
+ ]);
80
+ process.stdout.write(JSON.stringify({ storefront: store, credits }, null, 2) + '\n');
85
81
  });
86
82
  program
87
83
  .command('usage')
@@ -2,6 +2,7 @@ import { Command } from 'commander';
2
2
  import { type Derivation, type GeneratedWallet } from '@oneie/sdk/wallet';
3
3
  import { type VaultBlob, type SealOpts } from '@oneie/sdk/vault-file';
4
4
  import { askPath } from './lib/api-path.js';
5
+ import { workspaceFor } from './lib/keyfile.js';
5
6
  export { askPath };
6
7
  type AskEnvelope = {
7
8
  outcome?: string;
@@ -48,6 +49,7 @@ export declare function sealWallet(mnemonic: string, passphrase: string, opts: {
48
49
  }): Promise<VaultBlob>;
49
50
  /** The addresses a sealed vault holds, read under ITS marker — absent is v1. */
50
51
  export declare function openedWallet(blob: VaultBlob, mnemonic: string): Promise<GeneratedWallet>;
52
+ export { workspaceFor };
51
53
  export declare function faucetOk(results: Array<{
52
54
  success: boolean;
53
55
  }>): boolean;
@@ -142,3 +144,24 @@ export interface UnlockIO {
142
144
  export declare function unlock(dir: string, io?: UnlockIO): Promise<Unlocked | {
143
145
  error: string;
144
146
  }>;
147
+ /** "5000" → 5000; anything that is not a whole number in 0..10M → null (the server checks again). */
148
+ export declare function parseCredits(raw: string): number | null;
149
+ export interface WalletLine {
150
+ actor: string;
151
+ tags: string[];
152
+ address: string | null;
153
+ limit: {
154
+ monthlyCredits: number;
155
+ spentCredits: number;
156
+ paused: boolean;
157
+ } | null;
158
+ sweep: {
159
+ chain: string;
160
+ thresholdUnits: string;
161
+ floatUnits: string;
162
+ to: string;
163
+ } | null;
164
+ }
165
+ /** One wallet:get row reduced to what a person reads: who, the tags, the first address, the limit, the sweep. */
166
+ export declare function walletLine(w: Record<string, unknown>): WalletLine;
167
+ export declare function formatWalletLine(r: WalletLine): string;
@@ -6,6 +6,8 @@ import { generateWallet, recoverWallet, readDerivation } from '@oneie/sdk/wallet
6
6
  import { sealVault, openVault, mintKeychainSecret } from '@oneie/sdk/vault-file';
7
7
  import { proveAddresses } from '@oneie/sdk/address-proof';
8
8
  import { askPath } from './lib/api-path.js';
9
+ import { workspaceFor } from './lib/keyfile.js';
10
+ import { resolveKey } from './lib/client.js';
9
11
  import { wordsStdoutRefusal } from './lib/agent-env.js';
10
12
  import { cliPrefix } from './lib/invoked-as.js';
11
13
  import { writeVaultFolder, readVaultFolder, vaultPath, paperSheet, keychainStore, keychainRead, keychainAvailable, } from './lib/vaultfile.js';
@@ -98,14 +100,14 @@ export async function openedWallet(blob, mnemonic) {
98
100
  }
99
101
  function resolveAuth(opts) {
100
102
  const env = mergeEnv(process.cwd());
101
- const key = opts.key ?? env.ONEIE_API_KEY ?? env.ONE_API_KEY ?? '';
103
+ const key = opts.key ?? env.ONEIE_API_KEY ?? env.ONE_API_KEY ?? resolveKey();
102
104
  return { base: opts.api.replace(/\/$/, ''), key };
103
105
  }
106
+ export { workspaceFor };
104
107
  function resolveWorkspace(explicit) {
105
- const env = mergeEnv(process.cwd());
106
- const workspace = explicit ?? env.AGENCY_SLUG;
108
+ const workspace = workspaceFor(explicit, process.cwd(), mergeEnv(process.cwd()));
107
109
  if (!workspace) {
108
- process.stderr.write('--workspace required (or set AGENCY_SLUG)\n');
110
+ process.stderr.write('--workspace required (or set AGENCY_SLUG, or run from the folder `npx oneie` made)\n');
109
111
  process.exit(1);
110
112
  }
111
113
  return workspace;
@@ -143,6 +145,53 @@ export function walletCmd() {
143
145
  const result = await ask(base, key, 'wallet:get', { workspace, actor: opts.actor });
144
146
  out(cmd, okWrap(result));
145
147
  });
148
+ // list — every wallet in the workspace with the words it wears (treasury · agent · person ·
149
+ // limit · paused · no-limit · sweep · vault · no-address). The tags are wallet:get's own,
150
+ // derived on the server from the rows, the caps and the signed sweep rules.
151
+ cmd.command('list')
152
+ .description('Every wallet in the workspace with its tags, limit and sweep rule')
153
+ .option('--workspace <slug>', 'Workspace (defaults to AGENCY_SLUG)')
154
+ .option('--api <url>', 'API base URL', DEFAULT_API)
155
+ .option('--key <key>', 'API key (overrides ONEIE_API_KEY env)')
156
+ .action(async (opts) => {
157
+ const { base, key } = resolveAuth(opts);
158
+ const workspace = resolveWorkspace(opts.workspace);
159
+ const result = await ask(base, key, 'wallet:get', { workspace });
160
+ const wallets = Array.isArray(result.wallets) ? result.wallets : [];
161
+ const rows = wallets.map(walletLine);
162
+ if (cmd.parent?.opts().json) {
163
+ process.stdout.write(JSON.stringify({ ok: !result.error, workspace, wallets: rows, ...(result.error ? { error: result.error } : {}) }) + '\n');
164
+ return;
165
+ }
166
+ if (result.error)
167
+ return out(cmd, okWrap(result));
168
+ if (!rows.length)
169
+ return console.log(`no wallets in ${workspace} yet`);
170
+ for (const r of rows)
171
+ console.log(formatWalletLine(r));
172
+ });
173
+ // limit — the owner's one number for an agent: credits a month, 0 pauses it. Lowering is
174
+ // open to anyone who controls the workspace; raising needs a person (this CLI's own human
175
+ // key counts, an agent key never does). The server decides — this only sends the number.
176
+ cmd.command('limit <agent> <credits>')
177
+ .description('Set an agent\'s spending limit in credits a month (1000 = $1). 0 pauses it')
178
+ .option('--workspace <slug>', 'Workspace (defaults to AGENCY_SLUG)')
179
+ .option('--api <url>', 'API base URL', DEFAULT_API)
180
+ .option('--key <key>', 'API key (overrides ONEIE_API_KEY env)')
181
+ .action(async (agent, raw, opts) => {
182
+ const credits = parseCredits(raw);
183
+ if (credits === null) {
184
+ out(cmd, { ok: false, error: 'credits must be a whole number from 0 to 10000000' });
185
+ process.exitCode = 1;
186
+ return;
187
+ }
188
+ const { base, key } = resolveAuth(opts);
189
+ const workspace = resolveWorkspace(opts.workspace);
190
+ const result = await ask(base, key, 'wallet:update', { workspace, actor: agent, limit: credits });
191
+ if (!result.ok)
192
+ process.exitCode = 1;
193
+ out(cmd, okWrap(result));
194
+ });
146
195
  cmd.command('create')
147
196
  .description('Provision a wallet row for an actor (idempotent)')
148
197
  .option('--workspace <slug>', 'Workspace (defaults to AGENCY_SLUG)')
@@ -630,3 +679,32 @@ export async function unlock(dir, io = terminalIO()) {
630
679
  const wallet = await openedWallet(blob, mnemonic);
631
680
  return { blob, mnemonic, addresses: Object.fromEntries(wallet.keys.map((k) => [k.chain, k.address])), keys: wallet.keys };
632
681
  }
682
+ /** "5000" → 5000; anything that is not a whole number in 0..10M → null (the server checks again). */
683
+ export function parseCredits(raw) {
684
+ if (!/^\d{1,8}$/.test(raw.trim()))
685
+ return null;
686
+ const n = Number(raw.trim());
687
+ return n <= 10_000_000 ? n : null;
688
+ }
689
+ /** One wallet:get row reduced to what a person reads: who, the tags, the first address, the limit, the sweep. */
690
+ export function walletLine(w) {
691
+ const address = ['sui_address', 'evm_address', 'solana_address', 'btc_address', 'asi_address']
692
+ .map((k) => w[k]).find((v) => typeof v === 'string' && v.length > 0) ?? null;
693
+ return {
694
+ actor: String(w.actor ?? ''),
695
+ tags: Array.isArray(w.tags) ? w.tags.map(String) : [],
696
+ address,
697
+ limit: w.limit ?? null,
698
+ sweep: w.sweep ?? null,
699
+ };
700
+ }
701
+ export function formatWalletLine(r) {
702
+ const parts = [r.actor.padEnd(24), `[${r.tags.join(' ')}]`];
703
+ if (r.limit)
704
+ parts.push(r.limit.paused ? 'paused' : `limit ${r.limit.spentCredits}/${r.limit.monthlyCredits} credits`);
705
+ if (r.sweep)
706
+ parts.push(`sweeps ${r.sweep.chain} above ${r.sweep.thresholdUnits} keeping ${r.sweep.floatUnits}`);
707
+ if (r.address)
708
+ parts.push(r.address);
709
+ return parts.join(' ');
710
+ }
package/dist/src/write.js CHANGED
@@ -64,9 +64,11 @@ export async function sealNote(note, locks) {
64
64
  }
65
65
  /** Post an ALREADY SEALED block. Its inputs carry no plaintext, by signature. */
66
66
  export async function postSealed(base, ws, sealed, from, fetchImpl = fetch) {
67
+ // The door reads `name` (writerLabel → "Sam (not verified)") and ignores `from`; sending
68
+ // `from` made every CLI note arrive as "Someone with your lock".
67
69
  const body = { ws, sealed };
68
70
  if (from)
69
- body.from = from;
71
+ body.name = from;
70
72
  const ctl = new AbortController();
71
73
  const timer = setTimeout(() => ctl.abort(), DEADLINE_MS);
72
74
  let res;
@@ -91,6 +93,8 @@ export async function postSealed(base, ws, sealed, from, fetchImpl = fetch) {
91
93
  catch {
92
94
  /* a non-JSON body is reported by status below */
93
95
  }
96
+ if (res.status === 429 && j.error === 'inbox_busy')
97
+ return { ok: false, error: 'this inbox is busy — it has taken its 60 notes for these ten minutes; wait a minute and try again', code: 'inbox_busy' };
94
98
  if (res.status === 429)
95
99
  return { ok: false, error: 'too many notes from this address — the door takes ten a minute; wait and try again', code: 'rate_limited' };
96
100
  if (res.ok && j.ok)
@@ -100,6 +104,8 @@ export async function postSealed(base, ws, sealed, from, fetchImpl = fetch) {
100
104
  return { ok: false, error: `"${ws}" is not a workspace name`, code: 'bad_workspace' };
101
105
  case 'unknown_workspace':
102
106
  return { ok: false, error: `there is no workspace called "${ws}" on ${base}`, code: 'unknown_workspace' };
107
+ case 'too_large':
108
+ return { ok: false, error: 'the door refused it — the sealed note is over its size cap', code: 'too_large' };
103
109
  case 'not_sealed':
104
110
  return { ok: false, error: 'the door refused it — it is not one armored age block', code: 'not_sealed' };
105
111
  default:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oneie",
3
- "version": "5.7.2",
3
+ "version": "5.7.4",
4
4
  "description": "ONE agent CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "commander": "^12.0.0",
23
- "@oneie/sdk": "^0.17.0"
23
+ "@oneie/sdk": "^0.17.5"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@oneie/evals": "^0.2.0",