oneie 5.3.2 → 5.3.3

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.3.2",
3
+ "version": "5.3.3",
4
4
  "description": "ONE agent CLI",
5
5
  "type": "module",
6
6
  "bin": {
package/dist/src/init.js CHANGED
@@ -217,7 +217,8 @@ export function initCmd() {
217
217
  writeEnvLocal(dir, { ONE_API_KEY: apiKey, ONE_API_URL: opts.api });
218
218
  }
219
219
  // 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.
220
+ // the file kept, so `one wallet register --kind agent --from <file>` (or
221
+ // `--dir <folder>` for the sealed vault) retries.
221
222
  const wallet = opts.wallet !== false
222
223
  ? await provisionLocalWallet({
223
224
  api: opts.api, key: regKey || apiKey, workspace,
@@ -238,7 +239,9 @@ export function initCmd() {
238
239
  ...(wallet?.ok ? { addresses: Object.entries(wallet.addresses ?? {}).filter(([, a]) => a).map(([c, a]) => `${c} ${a}`).join(', ') } : {}),
239
240
  ...(wallet && !wallet.ok ? { wallet_error: wallet.sealed === false
240
241
  ? `${wallet.error} — retry: one wallet register --kind agent --workspace ${workspace} --from ${wallet.file}`
241
- : `${wallet.error}` } : {}),
242
+ : wallet.sealed === true
243
+ ? `${wallet.error} — retry: one wallet register --kind agent --workspace ${workspace} --dir ${vaultDir}`
244
+ : `${wallet.error}` } : {}),
242
245
  ...(skills.length ? { skills: skills.join(', ') } : {}),
243
246
  });
244
247
  });
@@ -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,32 @@ 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
+ type Unlocked = {
100
+ blob: VaultBlob;
101
+ mnemonic: string;
102
+ addresses: Record<string, string>;
103
+ keys: GeneratedWallet['keys'];
104
+ };
105
+ /** Where a vault's passphrase can come from. Injectable so the refusal is testable. */
106
+ export interface UnlockIO {
107
+ interactive: boolean;
108
+ readPassphrase: (prompt: string) => Promise<string>;
109
+ readKeychain: (authPub: string) => {
110
+ ok: boolean;
111
+ value?: string;
112
+ error?: string;
113
+ };
114
+ }
115
+ /**
116
+ * Open the folder's vault, asking Keychain or the human depending on how it was
117
+ * SEALED. `wrap` is what makes this possible: without it a keychain vault is
118
+ * indistinguishable from a passphrase one and the only way to find out is to
119
+ * prompt for a passphrase that was never set.
120
+ *
121
+ * A passphrase vault with no terminal has no passphrase source — the passphrase
122
+ * is never read from argv, env or a pipe — so it is refused BY NAME, the same
123
+ * name `oneie init` refuses with, rather than surfacing promptSecret's throw.
124
+ */
125
+ export declare function unlock(dir: string, io?: UnlockIO): Promise<Unlocked | {
126
+ error: string;
127
+ }>;
@@ -191,9 +191,10 @@ export function walletCmd() {
191
191
  out(cmd, okWrap(result));
192
192
  });
193
193
  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')
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 (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
195
  .option('--from <file>', 'A `wallet keygen --out` file (or any JSON with `addresses` / `keys`) — only the address fields are read')
196
196
  .option('--addresses <json>', 'Inline JSON address map, e.g. \'{"sui":"0x…","evm":"0x…"}\'')
197
+ .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
198
  .option('--workspace <slug>', 'Workspace (defaults to AGENCY_SLUG)')
198
199
  .option('--actor <id>', 'Actor to register for (defaults to workspace)')
199
200
  .option('--kind <kind>', 'human | agent', 'human')
@@ -203,6 +204,28 @@ export function walletCmd() {
203
204
  .action(async (opts) => {
204
205
  const { base, key } = resolveAuth(opts);
205
206
  const workspace = resolveWorkspace(opts.workspace);
207
+ if (opts.dir !== undefined) {
208
+ if (opts.from || opts.addresses) {
209
+ out(cmd, { ok: false, error: '--dir opens a sealed wallet — pass it alone, not with --from or --addresses' });
210
+ return;
211
+ }
212
+ if (opts.kind !== 'agent') {
213
+ out(cmd, { ok: false, error: '--dir registers by proof, which is the agent path — pass --kind agent' });
214
+ return;
215
+ }
216
+ const actor = opts.actor ?? workspace;
217
+ out(cmd, await registerSealedWallet({
218
+ base, key, workspace, actor, dir: opts.dir,
219
+ confirmAddresses: async (addresses) => {
220
+ process.stderr.write(`Registering PUBLIC receiving addresses for actor '${actor}' in workspace '${workspace}':\n`);
221
+ for (const [chain, addr] of Object.entries(addresses))
222
+ process.stderr.write(` ${chain.padEnd(7)} ${addr}\n`);
223
+ process.stderr.write('This is permanent — the first address written to a chain cannot be changed.\n');
224
+ return Boolean(opts.yes) || confirm('Register these addresses? [y/N] ');
225
+ },
226
+ }));
227
+ return;
228
+ }
206
229
  const source = opts.from
207
230
  ? JSON.parse(readFileSync(opts.from, 'utf8'))
208
231
  : opts.addresses
@@ -420,6 +443,21 @@ export async function registerAgentWallet(opts) {
420
443
  workspace: opts.workspace, actor: opts.actor, kind: 'agent', addresses, challenge: issued.challenge, proofs,
421
444
  }));
422
445
  }
446
+ /**
447
+ * Register the SEALED wallet in `dir` — the vault `oneie init` and `wallet new`
448
+ * write — by the same challenge → sign → register flow. Opens it the way
449
+ * `wallet open` does (Keychain or the typed passphrase), so a sealed agent wallet
450
+ * whose first registration failed can be retried without ever being written out
451
+ * in the clear. The words and keys stay in this process.
452
+ */
453
+ export async function registerSealedWallet(opts) {
454
+ const opened = await unlock(opts.dir, opts.io);
455
+ if ('error' in opened)
456
+ return { ok: false, error: opened.error };
457
+ if (opts.confirmAddresses && !(await opts.confirmAddresses(opened.addresses)))
458
+ return { ok: false, error: 'cancelled' };
459
+ return registerAgentWallet({ base: opts.base, key: opts.key, workspace: opts.workspace, actor: opts.actor, keys: opened.keys });
460
+ }
423
461
  /** The `keys` array of a keygen file, or [] — read for SIGNING only, never sent. */
424
462
  export function signingKeys(source) {
425
463
  const keys = (source && typeof source === 'object' ? source['keys'] : undefined);
@@ -531,26 +569,36 @@ export async function promptSecret(prompt) {
531
569
  orig('\n');
532
570
  }
533
571
  }
572
+ const terminalIO = () => ({
573
+ interactive: Boolean(process.stdin.isTTY), readPassphrase: promptSecret, readKeychain: keychainRead,
574
+ });
534
575
  /**
535
576
  * Open the folder's vault, asking Keychain or the human depending on how it was
536
577
  * SEALED. `wrap` is what makes this possible: without it a keychain vault is
537
578
  * indistinguishable from a passphrase one and the only way to find out is to
538
579
  * prompt for a passphrase that was never set.
580
+ *
581
+ * A passphrase vault with no terminal has no passphrase source — the passphrase
582
+ * is never read from argv, env or a pipe — so it is refused BY NAME, the same
583
+ * name `oneie init` refuses with, rather than surfacing promptSecret's throw.
539
584
  */
540
- async function unlock(dir) {
585
+ export async function unlock(dir, io = terminalIO()) {
541
586
  const raw = readVaultFolder(dir);
542
587
  if (!raw)
543
588
  return { error: `no wallet at ${vaultPath(dir)} — run \`one wallet new\`` };
544
589
  const blob = raw;
545
590
  let passphrase;
546
591
  if (blob.wrap === 'keychain') {
547
- const k = keychainRead(String(blob.authPub ?? ''));
592
+ const k = io.readKeychain(String(blob.authPub ?? ''));
548
593
  if (!k.ok || !k.value)
549
- return { error: k.ok ? 'Keychain returned nothing' : k.error };
594
+ return { error: k.ok ? 'Keychain returned nothing' : String(k.error) };
550
595
  passphrase = k.value;
551
596
  }
552
597
  else {
553
- passphrase = await promptSecret('Passphrase: ');
598
+ if (!io.interactive) {
599
+ 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 \`one wallet keychain\`` };
600
+ }
601
+ passphrase = await io.readPassphrase('Passphrase: ');
554
602
  }
555
603
  let mnemonic;
556
604
  try {
@@ -560,5 +608,5 @@ async function unlock(dir) {
560
608
  return { error: e.message };
561
609
  }
562
610
  const wallet = await openedWallet(blob, mnemonic);
563
- return { blob, mnemonic, addresses: Object.fromEntries(wallet.keys.map((k) => [k.chain, k.address])) };
611
+ return { blob, mnemonic, addresses: Object.fromEntries(wallet.keys.map((k) => [k.chain, k.address])), keys: wallet.keys };
564
612
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oneie",
3
- "version": "5.3.2",
3
+ "version": "5.3.3",
4
4
  "description": "ONE agent CLI",
5
5
  "type": "module",
6
6
  "bin": {