@oneie/cli 5.3.2 → 5.3.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/cli",
3
- "version": "5.3.2",
3
+ "version": "5.3.4",
4
4
  "description": "ONE agent CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -51,4 +51,17 @@ export declare function provisionLocalWallet(opts: {
51
51
  addresses?: Record<string, string>;
52
52
  error?: string;
53
53
  }>;
54
+ /**
55
+ * The wallet lines of init's receipt. Every command in them must run as printed:
56
+ * `cli` is `npx oneie` unless this process came in through the `one` bin (under
57
+ * npx, `one` is not on PATH — hit live on oneie@5.3.3), and `--dir` is named
58
+ * whenever the vault is not in the folder `wallet open` / `wallet paper` default
59
+ * to (`init --dir X` seals it in X).
60
+ */
61
+ export declare function initWalletReceipt(wallet: Awaited<ReturnType<typeof provisionLocalWallet>>, o: {
62
+ workspace: string;
63
+ dir: string;
64
+ vaultDir: string;
65
+ cli: string;
66
+ }): Record<string, string>;
54
67
  export declare function initCmd(): Command;
package/dist/src/init.js CHANGED
@@ -15,6 +15,7 @@ import { writeKeyFolder } from './lib/keyfile.js';
15
15
  import { KEY_FILE, CONFIG_DIR, writeMachineKey } from './lib/paths.js';
16
16
  import { walletFor, writeKeysFile, registerAgentWallet, sealWallet, promptSecret } from './wallet.js';
17
17
  import { writeVaultFolder, vaultPath } from './lib/vaultfile.js';
18
+ import { cliPrefix } from './lib/invoked-as.js';
18
19
  const DEFAULT_API = process.env.ONEIE_BASE_URL ?? 'https://one.ie';
19
20
  function out(cmd, data) {
20
21
  const isJson = cmd.parent?.opts().json;
@@ -104,6 +105,27 @@ export async function provisionLocalWallet(opts) {
104
105
  return { ok: false, file: target, error: err.message };
105
106
  }
106
107
  }
108
+ /**
109
+ * The wallet lines of init's receipt. Every command in them must run as printed:
110
+ * `cli` is `npx oneie` unless this process came in through the `one` bin (under
111
+ * npx, `one` is not on PATH — hit live on oneie@5.3.3), and `--dir` is named
112
+ * whenever the vault is not in the folder `wallet open` / `wallet paper` default
113
+ * to (`init --dir X` seals it in X).
114
+ */
115
+ export function initWalletReceipt(wallet, o) {
116
+ const atVault = resolve(o.vaultDir) === resolve(o.dir) ? '' : ` --dir ${o.vaultDir}`;
117
+ return {
118
+ wallet: wallet.sealed
119
+ ? `${wallet.file} (sealed with your passphrase — \`${o.cli} wallet open${atVault}\` to read it, \`${o.cli} wallet paper${atVault}\` to back it up)`
120
+ : `${wallet.file} (0600 PLAINTEXT — the 24 words and keys; back it up, never commit it)`,
121
+ ...(wallet.ok ? { addresses: Object.entries(wallet.addresses ?? {}).filter(([, a]) => a).map(([c, a]) => `${c} ${a}`).join(', ') } : {}),
122
+ ...(!wallet.ok ? { wallet_error: wallet.sealed === false
123
+ ? `${wallet.error} — retry: ${o.cli} wallet register --kind agent --workspace ${o.workspace} --from ${wallet.file}`
124
+ : wallet.sealed === true
125
+ ? `${wallet.error} — retry: ${o.cli} wallet register --kind agent --workspace ${o.workspace} --dir ${o.vaultDir}`
126
+ : `${wallet.error}` } : {}),
127
+ };
128
+ }
107
129
  export function initCmd() {
108
130
  const cmd = new Command('init')
109
131
  .description('Provision a new workspace in one command — no account required')
@@ -217,7 +239,8 @@ export function initCmd() {
217
239
  writeEnvLocal(dir, { ONE_API_KEY: apiKey, ONE_API_URL: opts.api });
218
240
  }
219
241
  // Non-fatal: the workspace exists either way. A refusal is REPORTED, with
220
- // the file kept, so `one wallet register --kind agent --from <file>` retries.
242
+ // the file kept, so `one wallet register --kind agent --from <file>` (or
243
+ // `--dir <folder>` for the sealed vault) retries.
221
244
  const wallet = opts.wallet !== false
222
245
  ? await provisionLocalWallet({
223
246
  api: opts.api, key: regKey || apiKey, workspace,
@@ -232,13 +255,7 @@ export function initCmd() {
232
255
  ...(expiresAt ? { expires: new Date(expiresAt * 1000).toISOString() } : {}),
233
256
  ...(opts.writeEnv ? { env: `${dir}/.env.local`, mcp: 'export ONE_API_KEY before launching Claude Code — MCP reads the shell env, not .env.local directly' } : {}),
234
257
  ...(inviteUrl ? { invite: inviteUrl } : {}),
235
- ...(wallet ? { wallet: wallet.sealed
236
- ? `${wallet.file} (sealed with your passphrase — \`one wallet open\` to read it, \`one wallet paper\` to back it up)`
237
- : `${wallet.file} (0600 PLAINTEXT — the 24 words and keys; back it up, never commit it)` } : {}),
238
- ...(wallet?.ok ? { addresses: Object.entries(wallet.addresses ?? {}).filter(([, a]) => a).map(([c, a]) => `${c} ${a}`).join(', ') } : {}),
239
- ...(wallet && !wallet.ok ? { wallet_error: wallet.sealed === false
240
- ? `${wallet.error} — retry: one wallet register --kind agent --workspace ${workspace} --from ${wallet.file}`
241
- : `${wallet.error}` } : {}),
258
+ ...(wallet ? initWalletReceipt(wallet, { workspace, dir, vaultDir, cli: cliPrefix() }) : {}),
242
259
  ...(skills.length ? { skills: skills.join(', ') } : {}),
243
260
  });
244
261
  });
@@ -0,0 +1,2 @@
1
+ export type CliPrefix = 'one' | 'npx oneie';
2
+ export declare function cliPrefix(argv?: readonly string[]): CliPrefix;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * invoked-as.ts — how to spell a follow-up command so it runs as printed.
3
+ *
4
+ * The package ships two bins, `oneie` and `one`, but only a global install puts
5
+ * `one` on PATH. Under `npx oneie init` a hint reading `one wallet open` answers
6
+ * `command not found: one` (hit live 2026-10-04, oneie@5.3.3). So a hint says
7
+ * `one` only when THIS process was started through the `one` bin, and
8
+ * `npx oneie` otherwise — which runs from any shell, installed or not.
9
+ *
10
+ * Node keeps the bin's own name in argv[1] (a symlink is not resolved), so the
11
+ * basename is the whole test. A Windows `.cmd` shim never matches and falls
12
+ * back to `npx oneie`, which still runs.
13
+ */
14
+ import { basename } from 'node:path';
15
+ export function cliPrefix(argv = process.argv) {
16
+ return basename(argv[1] ?? '') === 'one' ? 'one' : 'npx oneie';
17
+ }
@@ -69,5 +69,20 @@ export declare function keychainRead(authPub: string): KeychainResult;
69
69
  * Numbered because BIP-39 order is load-bearing and an unnumbered column of 24
70
70
  * words is trivially copied out of sequence — a wallet that restores to the
71
71
  * wrong addresses with no error. Pure, so it is testable without a wallet.
72
+ *
73
+ * The derivation is printed, and named in the restore command, because the words
74
+ * carry no marker of their own: `wallet new --recover` with no `--derivation`
75
+ * recovers v1 (it must — a v1 key recovers its v1 addresses forever), while
76
+ * `oneie init` mints v2. A sheet that omits it restores a v2 holder to a
77
+ * different, empty wallet with no error. The paper alone must carry what restore
78
+ * needs, so the derivation is required here, not defaulted.
79
+ *
80
+ * `cli` is how the restore command is spelled (`one` or `npx oneie`, see
81
+ * invoked-as.ts) so the line runs as printed. The restore line itself is a bare
82
+ * command — nothing trailing — so it can be copied, and parsed by the test that
83
+ * follows it back to the same addresses (tests/paper-restore.test.ts).
72
84
  */
73
- export declare function paperSheet(mnemonic: string, addresses: Record<string, string>): string;
85
+ export declare function paperSheet(mnemonic: string, addresses: Record<string, string>, restore: {
86
+ derivation: 'v1' | 'v2';
87
+ cli: string;
88
+ }): string;
@@ -157,8 +157,20 @@ export function keychainRead(authPub) {
157
157
  * Numbered because BIP-39 order is load-bearing and an unnumbered column of 24
158
158
  * words is trivially copied out of sequence — a wallet that restores to the
159
159
  * wrong addresses with no error. Pure, so it is testable without a wallet.
160
+ *
161
+ * The derivation is printed, and named in the restore command, because the words
162
+ * carry no marker of their own: `wallet new --recover` with no `--derivation`
163
+ * recovers v1 (it must — a v1 key recovers its v1 addresses forever), while
164
+ * `oneie init` mints v2. A sheet that omits it restores a v2 holder to a
165
+ * different, empty wallet with no error. The paper alone must carry what restore
166
+ * needs, so the derivation is required here, not defaulted.
167
+ *
168
+ * `cli` is how the restore command is spelled (`one` or `npx oneie`, see
169
+ * invoked-as.ts) so the line runs as printed. The restore line itself is a bare
170
+ * command — nothing trailing — so it can be copied, and parsed by the test that
171
+ * follows it back to the same addresses (tests/paper-restore.test.ts).
160
172
  */
161
- export function paperSheet(mnemonic, addresses) {
173
+ export function paperSheet(mnemonic, addresses, restore) {
162
174
  const words = mnemonic.trim().split(/\s+/);
163
175
  const rows = [];
164
176
  const half = Math.ceil(words.length / 2);
@@ -179,6 +191,12 @@ export function paperSheet(mnemonic, addresses) {
179
191
  'Receiving addresses (public — safe to share, this is how you get paid):',
180
192
  ...Object.entries(addresses).map(([chain, addr]) => ` ${chain.padEnd(5)} ${addr}`),
181
193
  '',
182
- 'Restore with: one wallet open --recover',
194
+ `Derivation: ${restore.derivation} (restore MUST name it — without it the same words open a different, empty wallet)`,
195
+ '',
196
+ `Restore with: ${restore.cli} wallet new --recover --derivation ${restore.derivation}`,
197
+ ' The words go in ONE_WALLET_MNEMONIC, set without echo first:',
198
+ ' read -rs ONE_WALLET_MNEMONIC && export ONE_WALLET_MNEMONIC',
199
+ ' Never on the command line — argv lands in shell history and in `ps`.',
200
+ `Offline, no ONE server: npx @oneie/recover --derivation ${restore.derivation}`,
183
201
  ].join('\n');
184
202
  }
@@ -61,6 +61,23 @@ export declare function registerAgentWallet(opts: {
61
61
  privateKeyHex: string;
62
62
  }>;
63
63
  }): Promise<Record<string, unknown>>;
64
+ /**
65
+ * Register the SEALED wallet in `dir` — the vault `oneie init` and `wallet new`
66
+ * write — by the same challenge → sign → register flow. Opens it the way
67
+ * `wallet open` does (Keychain or the typed passphrase), so a sealed agent wallet
68
+ * whose first registration failed can be retried without ever being written out
69
+ * in the clear. The words and keys stay in this process.
70
+ */
71
+ export declare function registerSealedWallet(opts: {
72
+ base: string;
73
+ key: string;
74
+ workspace: string;
75
+ actor: string;
76
+ dir: string;
77
+ io?: UnlockIO;
78
+ /** Shown the addresses before anything is sent; false cancels. */
79
+ confirmAddresses?: (addresses: Record<string, string>) => Promise<boolean>;
80
+ }): Promise<Record<string, unknown>>;
64
81
  /** The `keys` array of a keygen file, or [] — read for SIGNING only, never sent. */
65
82
  export declare function signingKeys(source: unknown): Array<{
66
83
  chain: string;
@@ -79,3 +96,38 @@ export declare function addressesOnly(source: unknown): Record<string, string>;
79
96
  export declare function writeKeysFile(filePath: string, contents: string, accepted: boolean): void;
80
97
  /** Read a secret from the TTY with echo off. Never argv (world-readable in ps), never env. */
81
98
  export declare function promptSecret(prompt: string): Promise<string>;
99
+ /** The sheet `wallet paper` prints — unlock, then lay out what restore needs. */
100
+ export declare function paperFor(dir: string, io?: UnlockIO, cli?: string): Promise<{
101
+ sheet: string;
102
+ } | {
103
+ error: string;
104
+ }>;
105
+ type Unlocked = {
106
+ blob: VaultBlob;
107
+ mnemonic: string;
108
+ addresses: Record<string, string>;
109
+ keys: GeneratedWallet['keys'];
110
+ };
111
+ /** Where a vault's passphrase can come from. Injectable so the refusal is testable. */
112
+ export interface UnlockIO {
113
+ interactive: boolean;
114
+ readPassphrase: (prompt: string) => Promise<string>;
115
+ readKeychain: (authPub: string) => {
116
+ ok: boolean;
117
+ value?: string;
118
+ error?: string;
119
+ };
120
+ }
121
+ /**
122
+ * Open the folder's vault, asking Keychain or the human depending on how it was
123
+ * SEALED. `wrap` is what makes this possible: without it a keychain vault is
124
+ * indistinguishable from a passphrase one and the only way to find out is to
125
+ * prompt for a passphrase that was never set.
126
+ *
127
+ * A passphrase vault with no terminal has no passphrase source — the passphrase
128
+ * is never read from argv, env or a pipe — so it is refused BY NAME, the same
129
+ * name `oneie init` refuses with, rather than surfacing promptSecret's throw.
130
+ */
131
+ export declare function unlock(dir: string, io?: UnlockIO): Promise<Unlocked | {
132
+ error: string;
133
+ }>;
@@ -7,6 +7,7 @@ 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
9
  import { wordsStdoutRefusal } from './lib/agent-env.js';
10
+ import { cliPrefix } from './lib/invoked-as.js';
10
11
  import { writeVaultFolder, readVaultFolder, vaultPath, paperSheet, keychainStore, keychainRead, keychainAvailable, } from './lib/vaultfile.js';
11
12
  const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://api.one.ie';
12
13
  // Re-exported for existing callers/tests — canonical implementation now lives
@@ -191,9 +192,10 @@ export function walletCmd() {
191
192
  out(cmd, okWrap(result));
192
193
  });
193
194
  cmd.command('register')
194
- .description('Register a keygen output\'s PUBLIC receiving addresses with a workspace — sends addresses only, never a key or a mnemonic. With --kind agent the keys in --from sign a server challenge locally, and only the signatures are sent. First write wins per chain and is permanent')
195
+ .description('Register a keygen output\'s PUBLIC receiving addresses with a workspace — sends addresses only, never a key or a mnemonic. With --kind agent the keys in --from (or the sealed wallet in --dir) sign a server challenge locally, and only the signatures are sent. First write wins per chain and is permanent')
195
196
  .option('--from <file>', 'A `wallet keygen --out` file (or any JSON with `addresses` / `keys`) — only the address fields are read')
196
197
  .option('--addresses <json>', 'Inline JSON address map, e.g. \'{"sui":"0x…","evm":"0x…"}\'')
198
+ .option('--dir <path>', 'With --kind agent: open the SEALED wallet in this project folder (what `oneie init` / `wallet new` write) — passphrase at the terminal, or Touch ID for a keychain wallet — and register it by proof')
197
199
  .option('--workspace <slug>', 'Workspace (defaults to AGENCY_SLUG)')
198
200
  .option('--actor <id>', 'Actor to register for (defaults to workspace)')
199
201
  .option('--kind <kind>', 'human | agent', 'human')
@@ -203,6 +205,28 @@ export function walletCmd() {
203
205
  .action(async (opts) => {
204
206
  const { base, key } = resolveAuth(opts);
205
207
  const workspace = resolveWorkspace(opts.workspace);
208
+ if (opts.dir !== undefined) {
209
+ if (opts.from || opts.addresses) {
210
+ out(cmd, { ok: false, error: '--dir opens a sealed wallet — pass it alone, not with --from or --addresses' });
211
+ return;
212
+ }
213
+ if (opts.kind !== 'agent') {
214
+ out(cmd, { ok: false, error: '--dir registers by proof, which is the agent path — pass --kind agent' });
215
+ return;
216
+ }
217
+ const actor = opts.actor ?? workspace;
218
+ out(cmd, await registerSealedWallet({
219
+ base, key, workspace, actor, dir: opts.dir,
220
+ confirmAddresses: async (addresses) => {
221
+ process.stderr.write(`Registering PUBLIC receiving addresses for actor '${actor}' in workspace '${workspace}':\n`);
222
+ for (const [chain, addr] of Object.entries(addresses))
223
+ process.stderr.write(` ${chain.padEnd(7)} ${addr}\n`);
224
+ process.stderr.write('This is permanent — the first address written to a chain cannot be changed.\n');
225
+ return Boolean(opts.yes) || confirm('Register these addresses? [y/N] ');
226
+ },
227
+ }));
228
+ return;
229
+ }
206
230
  const source = opts.from
207
231
  ? JSON.parse(readFileSync(opts.from, 'utf8'))
208
232
  : opts.addresses
@@ -331,7 +355,7 @@ export function walletCmd() {
331
355
  wrap,
332
356
  derivation,
333
357
  addresses,
334
- next: 'one wallet paper # write the 24 words down — this is the ONLY backup',
358
+ next: `${cliPrefix()} wallet paper${opts.dir === '.' ? '' : ` --dir ${opts.dir}`} # write the 24 words down — this is the ONLY backup`,
335
359
  });
336
360
  });
337
361
  cmd.command('open')
@@ -357,7 +381,7 @@ export function walletCmd() {
357
381
  process.exitCode = 1;
358
382
  return;
359
383
  }
360
- const r = await unlock(opts.dir);
384
+ const r = await paperFor(opts.dir);
361
385
  if ('error' in r) {
362
386
  out(cmd, { ok: false, error: r.error });
363
387
  return;
@@ -365,7 +389,7 @@ export function walletCmd() {
365
389
  // Straight to stdout, never through out(): a --json receipt carrying 24
366
390
  // words would put the whole wallet into any pipeline or CI log that
367
391
  // captured it.
368
- process.stdout.write(paperSheet(r.mnemonic, r.addresses) + '\n');
392
+ process.stdout.write(r.sheet + '\n');
369
393
  });
370
394
  cmd.command('keychain')
371
395
  .description('Move this wallet behind Touch ID — stores its passphrase in Apple Keychain so biometrics open it')
@@ -420,6 +444,21 @@ export async function registerAgentWallet(opts) {
420
444
  workspace: opts.workspace, actor: opts.actor, kind: 'agent', addresses, challenge: issued.challenge, proofs,
421
445
  }));
422
446
  }
447
+ /**
448
+ * Register the SEALED wallet in `dir` — the vault `oneie init` and `wallet new`
449
+ * write — by the same challenge → sign → register flow. Opens it the way
450
+ * `wallet open` does (Keychain or the typed passphrase), so a sealed agent wallet
451
+ * whose first registration failed can be retried without ever being written out
452
+ * in the clear. The words and keys stay in this process.
453
+ */
454
+ export async function registerSealedWallet(opts) {
455
+ const opened = await unlock(opts.dir, opts.io);
456
+ if ('error' in opened)
457
+ return { ok: false, error: opened.error };
458
+ if (opts.confirmAddresses && !(await opts.confirmAddresses(opened.addresses)))
459
+ return { ok: false, error: 'cancelled' };
460
+ return registerAgentWallet({ base: opts.base, key: opts.key, workspace: opts.workspace, actor: opts.actor, keys: opened.keys });
461
+ }
423
462
  /** The `keys` array of a keygen file, or [] — read for SIGNING only, never sent. */
424
463
  export function signingKeys(source) {
425
464
  const keys = (source && typeof source === 'object' ? source['keys'] : undefined);
@@ -531,26 +570,45 @@ export async function promptSecret(prompt) {
531
570
  orig('\n');
532
571
  }
533
572
  }
573
+ /** The sheet `wallet paper` prints — unlock, then lay out what restore needs. */
574
+ export async function paperFor(dir, io = terminalIO(), cli = cliPrefix()) {
575
+ const r = await unlock(dir, io);
576
+ if ('error' in r)
577
+ return { error: r.error };
578
+ // The vault's OWN marker, read the way unlock derived the addresses above — an
579
+ // absent marker is v1 — so the sheet names the derivation those addresses are.
580
+ return { sheet: paperSheet(r.mnemonic, r.addresses, { derivation: readDerivation(r.blob.derivation), cli }) };
581
+ }
582
+ const terminalIO = () => ({
583
+ interactive: Boolean(process.stdin.isTTY), readPassphrase: promptSecret, readKeychain: keychainRead,
584
+ });
534
585
  /**
535
586
  * Open the folder's vault, asking Keychain or the human depending on how it was
536
587
  * SEALED. `wrap` is what makes this possible: without it a keychain vault is
537
588
  * indistinguishable from a passphrase one and the only way to find out is to
538
589
  * prompt for a passphrase that was never set.
590
+ *
591
+ * A passphrase vault with no terminal has no passphrase source — the passphrase
592
+ * is never read from argv, env or a pipe — so it is refused BY NAME, the same
593
+ * name `oneie init` refuses with, rather than surfacing promptSecret's throw.
539
594
  */
540
- async function unlock(dir) {
595
+ export async function unlock(dir, io = terminalIO()) {
541
596
  const raw = readVaultFolder(dir);
542
597
  if (!raw)
543
- return { error: `no wallet at ${vaultPath(dir)} — run \`one wallet new\`` };
598
+ return { error: `no wallet at ${vaultPath(dir)} — run \`${cliPrefix()} wallet new\`` };
544
599
  const blob = raw;
545
600
  let passphrase;
546
601
  if (blob.wrap === 'keychain') {
547
- const k = keychainRead(String(blob.authPub ?? ''));
602
+ const k = io.readKeychain(String(blob.authPub ?? ''));
548
603
  if (!k.ok || !k.value)
549
- return { error: k.ok ? 'Keychain returned nothing' : k.error };
604
+ return { error: k.ok ? 'Keychain returned nothing' : String(k.error) };
550
605
  passphrase = k.value;
551
606
  }
552
607
  else {
553
- passphrase = await promptSecret('Passphrase: ');
608
+ if (!io.interactive) {
609
+ return { error: `wallet_passphrase_unavailable: the wallet at ${vaultPath(dir)} is sealed with a passphrase typed at a terminal, and stdin is not one. Run this at a terminal, or move the wallet behind Touch ID with \`${cliPrefix()} wallet keychain\`` };
610
+ }
611
+ passphrase = await io.readPassphrase('Passphrase: ');
554
612
  }
555
613
  let mnemonic;
556
614
  try {
@@ -560,5 +618,5 @@ async function unlock(dir) {
560
618
  return { error: e.message };
561
619
  }
562
620
  const wallet = await openedWallet(blob, mnemonic);
563
- return { blob, mnemonic, addresses: Object.fromEntries(wallet.keys.map((k) => [k.chain, k.address])) };
621
+ return { blob, mnemonic, addresses: Object.fromEntries(wallet.keys.map((k) => [k.chain, k.address])), keys: wallet.keys };
564
622
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oneie/cli",
3
- "version": "5.3.2",
3
+ "version": "5.3.4",
4
4
  "description": "ONE agent CLI",
5
5
  "type": "module",
6
6
  "bin": {