@oneie/cli 5.3.1 → 5.3.2
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 +30 -0
- package/dist/package.json +2 -2
- package/dist/src/init.d.ts +43 -0
- package/dist/src/init.js +104 -1
- package/dist/src/lib/keyfile.js +7 -4
- package/dist/src/wallet.d.ts +25 -0
- package/dist/src/wallet.js +40 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -37,6 +37,20 @@ one ship "<message>" # git add + commit + push in one step
|
|
|
37
37
|
deploys `ai/workflows/*.md` as runnable workflows — the step graph rides in a fenced
|
|
38
38
|
` ```graph ` block (`{ "steps": [...], "edges": [...] }`), prose above it is human docs.
|
|
39
39
|
|
|
40
|
+
## Say it — `oneie message`
|
|
41
|
+
|
|
42
|
+
One command, no receiver names. The router picks who answers, the answer prints here, and a receipt says what it cost:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npx oneie message "add a dark-mode toggle"
|
|
46
|
+
npx oneie "add a dark-mode toggle" # bare text works too: anything that is not a command or a flag
|
|
47
|
+
oneie message "…" --json # the whole reply as JSON (answer, model, shape, usage)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
The text goes to the router (`world:route`), which derives its tags on the server, picks a model, and returns the reply. The CLI waits up to 30 s. The receipt under the answer shows the model and shape (`warmed` from measured runs, `cold` if unmeasured), tokens in and out, and a cost **estimated** from those tokens at the registry price. The billed figure arrives later with the hourly gateway mirror, so it prints as `pending` with a link to the stream (the link shows `<your-group>` as a placeholder — use your own slug). Any figure the CLI could not read prints as `unmeasured`, never as `0`, and it never prints a "Nx cheaper" multiple.
|
|
51
|
+
|
|
52
|
+
Exit `0` with an answer; `1` when there is no key (it prints `not signed in — run: npx oneie login`), the call is refused, times out or comes back empty; `2` for empty text. Under `--json` it exits `0` only when the reply carries text.
|
|
53
|
+
|
|
40
54
|
## Reach the whole surface
|
|
41
55
|
|
|
42
56
|
The receiver namespace *is* the API — discover it, then call anything:
|
|
@@ -121,6 +135,20 @@ one approve <requestId> # owner answers (--reject to refuse
|
|
|
121
135
|
|
|
122
136
|
Bare `one` prints this door beside the new-group one and never prompts. `approve` needs `manage_members`, so an owner answers with a `one login` key — an agent-class key is refused. Every verb takes `--json` and `--api`; with no key it exits 1 pointing at `one login`.
|
|
123
137
|
|
|
138
|
+
## Your key — `one key`
|
|
139
|
+
|
|
140
|
+
A key is 24 words you write on paper. ONE never holds it and cannot recover it. Every verb here runs on your machine; only `verify` calls the network, and it cannot send the key.
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
one key new # mint 24 words, printed ONCE, for paper (v2: standard BIP-44 paths — what one.ie mints)
|
|
144
|
+
one key new --derivation v1 # the original ONE derivation (HKDF labels)
|
|
145
|
+
one key recover # rebuild from your words — prints BOTH address sets
|
|
146
|
+
one key public # the public identity + four chain addresses; both sets unless you name --derivation
|
|
147
|
+
one key verify # compare this key's public identity with the server: locked | verified | mismatch | unregistered
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
The words are never accepted on the command line (shell history, `ps`) — pipe them on stdin, set `ONE_WALLET_MNEMONIC`, or type them at the hidden prompt. `--phrase` and `--mnemonic` are refused, and a stray argument is never echoed back, because it may be your phrase. The words print only to a terminal: a shell that looks like an agent or CI is refused, and a non-terminal stdout needs `--yes-print-to-pipe` (a printer, on purpose). Under `--json` the words never reach stdout; `--out <file>` writes them at mode `0600` and needs `--yes-i-accept-plaintext-file`. That is detection, not proof — a pty with no agent marker is not caught. A key minted under v1 and one minted under v2 have different addresses from the same words, which is why `recover` and `public` print both.
|
|
151
|
+
|
|
124
152
|
## Wallets
|
|
125
153
|
|
|
126
154
|
Every actor — human or agent — gets real, self-custodied multi-chain wallets. The CLI reads and writes the same `wallet:*` receivers `/w` uses:
|
|
@@ -132,6 +160,8 @@ one wallet register --from keys.json --workspace <slug> # register the PU
|
|
|
132
160
|
one wallet transactions --workspace <slug> --limit 50 # unified feed across every settlement rail
|
|
133
161
|
one wallet faucet <address> --chain sui # fund from testnet — sui/sol auto-fund, others return a manual URL
|
|
134
162
|
one wallet send <to> --chain SUI --amount 5 --payment-tx <hash> --workspace <slug>
|
|
163
|
+
one wallet keygen # mint a self-hosted 4-chain wallet locally (a fresh one is v2), offline
|
|
164
|
+
one wallet paper # reprint the 24 words for paper — terminal only, same refusals as `one key new`
|
|
135
165
|
```
|
|
136
166
|
|
|
137
167
|
`register` reads a `wallet keygen` output but transmits only its four address fields — the map it sends is built key-by-key from a fixed chain whitelist, so a `mnemonic` or `privateKey` in that file has no route onto the wire. The write is first-write-wins per chain and cannot be corrected afterwards (`address_conflict`), so it prints the addresses and asks for confirmation; `--yes` skips the prompt for scripted provisioning (needed when the JSON arrives on stdin, which leaves no terminal to answer with).
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oneie/cli",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.2",
|
|
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.16.
|
|
23
|
+
"@oneie/sdk": "^0.16.6"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@oneie/evals": "^0.2.0",
|
package/dist/src/init.d.ts
CHANGED
|
@@ -8,4 +8,47 @@
|
|
|
8
8
|
* No prior account or API key required. The server mints everything.
|
|
9
9
|
*/
|
|
10
10
|
import { Command } from 'commander';
|
|
11
|
+
/** Where the new wallet goes. A vault by default; plaintext only on the flag. */
|
|
12
|
+
export type WalletStore = {
|
|
13
|
+
kind: 'vault';
|
|
14
|
+
dir: string;
|
|
15
|
+
passphrase: string;
|
|
16
|
+
} | {
|
|
17
|
+
kind: 'plaintext';
|
|
18
|
+
file: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Can init store a wallet at all, before anything is provisioned? The repo's
|
|
22
|
+
* key-material rule (keygen --out, key new --out): words reach disk in the clear
|
|
23
|
+
* only behind --yes-i-accept-plaintext-file. Otherwise they are SEALED, and
|
|
24
|
+
* sealing needs a passphrase typed at a terminal — so a non-interactive run with
|
|
25
|
+
* no flag is refused by name, never quietly downgraded to plaintext.
|
|
26
|
+
*/
|
|
27
|
+
export declare function initWalletRefusal(o: {
|
|
28
|
+
wallet: boolean;
|
|
29
|
+
plaintext: boolean;
|
|
30
|
+
interactive: boolean;
|
|
31
|
+
}): string | null;
|
|
32
|
+
/**
|
|
33
|
+
* Give the new agent a wallet it actually holds: mint a v2 key HERE, store it
|
|
34
|
+
* FIRST (sealed in the `wallet new` vault, or the 0600 plaintext file on the
|
|
35
|
+
* flag), then prove control of each address to the server and register it. The
|
|
36
|
+
* order matters — an address registered before its key is stored is an address
|
|
37
|
+
* nobody can ever spend from.
|
|
38
|
+
*
|
|
39
|
+
* The private key and the words never leave this machine: the server sees the
|
|
40
|
+
* four addresses and one signature per address over its own fresh challenge.
|
|
41
|
+
*/
|
|
42
|
+
export declare function provisionLocalWallet(opts: {
|
|
43
|
+
api: string;
|
|
44
|
+
key: string;
|
|
45
|
+
workspace: string;
|
|
46
|
+
store: WalletStore;
|
|
47
|
+
}): Promise<{
|
|
48
|
+
ok: boolean;
|
|
49
|
+
file?: string;
|
|
50
|
+
sealed?: boolean;
|
|
51
|
+
addresses?: Record<string, string>;
|
|
52
|
+
error?: string;
|
|
53
|
+
}>;
|
|
11
54
|
export declare function initCmd(): Command;
|
package/dist/src/init.js
CHANGED
|
@@ -8,9 +8,13 @@
|
|
|
8
8
|
* No prior account or API key required. The server mints everything.
|
|
9
9
|
*/
|
|
10
10
|
import { Command } from 'commander';
|
|
11
|
+
import { mkdirSync, existsSync } from 'node:fs';
|
|
12
|
+
import { resolve, dirname } from 'node:path';
|
|
11
13
|
import { mergeEnv, writeEnvLocal } from './env.js';
|
|
12
14
|
import { writeKeyFolder } from './lib/keyfile.js';
|
|
13
|
-
import { KEY_FILE, writeMachineKey } from './lib/paths.js';
|
|
15
|
+
import { KEY_FILE, CONFIG_DIR, writeMachineKey } from './lib/paths.js';
|
|
16
|
+
import { walletFor, writeKeysFile, registerAgentWallet, sealWallet, promptSecret } from './wallet.js';
|
|
17
|
+
import { writeVaultFolder, vaultPath } from './lib/vaultfile.js';
|
|
14
18
|
const DEFAULT_API = process.env.ONEIE_BASE_URL ?? 'https://one.ie';
|
|
15
19
|
function out(cmd, data) {
|
|
16
20
|
const isJson = cmd.parent?.opts().json;
|
|
@@ -45,6 +49,61 @@ You are ${name}. Answer questions clearly and helpfully.
|
|
|
45
49
|
When you complete a task, summarise what you did in one sentence.
|
|
46
50
|
`;
|
|
47
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Can init store a wallet at all, before anything is provisioned? The repo's
|
|
54
|
+
* key-material rule (keygen --out, key new --out): words reach disk in the clear
|
|
55
|
+
* only behind --yes-i-accept-plaintext-file. Otherwise they are SEALED, and
|
|
56
|
+
* sealing needs a passphrase typed at a terminal — so a non-interactive run with
|
|
57
|
+
* no flag is refused by name, never quietly downgraded to plaintext.
|
|
58
|
+
*/
|
|
59
|
+
export function initWalletRefusal(o) {
|
|
60
|
+
if (!o.wallet || o.plaintext || o.interactive)
|
|
61
|
+
return null;
|
|
62
|
+
return 'wallet_passphrase_unavailable: init seals the new wallet with a passphrase typed at a terminal, and stdin is not one. ' +
|
|
63
|
+
'Pass --yes-i-accept-plaintext-file to write a 0600 plaintext wallet file instead, or --no-wallet to skip the wallet';
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Give the new agent a wallet it actually holds: mint a v2 key HERE, store it
|
|
67
|
+
* FIRST (sealed in the `wallet new` vault, or the 0600 plaintext file on the
|
|
68
|
+
* flag), then prove control of each address to the server and register it. The
|
|
69
|
+
* order matters — an address registered before its key is stored is an address
|
|
70
|
+
* nobody can ever spend from.
|
|
71
|
+
*
|
|
72
|
+
* The private key and the words never leave this machine: the server sees the
|
|
73
|
+
* four addresses and one signature per address over its own fresh challenge.
|
|
74
|
+
*/
|
|
75
|
+
export async function provisionLocalWallet(opts) {
|
|
76
|
+
const target = opts.store.kind === 'vault' ? vaultPath(opts.store.dir) : opts.store.file;
|
|
77
|
+
// Never replace a wallet: it may hold the only copy of the words behind
|
|
78
|
+
// addresses already registered and funded (`wallet new` refuses the same way).
|
|
79
|
+
if (existsSync(target)) {
|
|
80
|
+
return { ok: false, file: target, error: 'wallet_file_exists (kept untouched)' };
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
83
|
+
const { wallet, derivation } = await walletFor({}, () => '');
|
|
84
|
+
if (opts.store.kind === 'vault') {
|
|
85
|
+
const authPub = wallet.keys.find((k) => k.chain === 'sui')?.publicKeyHex ?? '';
|
|
86
|
+
const blob = await sealWallet(wallet.mnemonic, opts.store.passphrase, { wrap: 'passphrase', authPub, derivation });
|
|
87
|
+
const written = writeVaultFolder(opts.store.dir, { ...blob });
|
|
88
|
+
if (!written.ok)
|
|
89
|
+
return { ok: false, file: target, error: written.error ?? 'vault not written' };
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
mkdirSync(dirname(opts.store.file), { recursive: true, mode: 0o700 });
|
|
93
|
+
writeKeysFile(opts.store.file, JSON.stringify({ mnemonic: wallet.mnemonic, derivation, keys: wallet.keys, workspace: opts.workspace }, null, 2) + '\n', true);
|
|
94
|
+
}
|
|
95
|
+
const sealed = opts.store.kind === 'vault';
|
|
96
|
+
const res = await registerAgentWallet({
|
|
97
|
+
base: opts.api.replace(/\/$/, ''), key: opts.key, workspace: opts.workspace, actor: opts.workspace, keys: wallet.keys,
|
|
98
|
+
});
|
|
99
|
+
if (!res.ok)
|
|
100
|
+
return { ok: false, file: target, sealed, error: String(res.error ?? 'wallet:create refused') };
|
|
101
|
+
return { ok: true, file: target, sealed, addresses: (res.addresses ?? {}) };
|
|
102
|
+
}
|
|
103
|
+
catch (err) {
|
|
104
|
+
return { ok: false, file: target, error: err.message };
|
|
105
|
+
}
|
|
106
|
+
}
|
|
48
107
|
export function initCmd() {
|
|
49
108
|
const cmd = new Command('init')
|
|
50
109
|
.description('Provision a new workspace in one command — no account required')
|
|
@@ -56,8 +115,32 @@ export function initCmd() {
|
|
|
56
115
|
.option('--write-env', 'Also write ONE_API_KEY to .env.local in the current directory')
|
|
57
116
|
.option('--dir <path>', 'Write the key into THIS project folder (.oneie/agent.key, 0600, gitignored) instead of the machine-wide ~/.config/one/key')
|
|
58
117
|
.option('--ttl-days <n>', 'Key lifetime in days (default 90, max 365)')
|
|
118
|
+
.option('--no-wallet', 'Skip minting a local wallet and registering its addresses')
|
|
119
|
+
.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')
|
|
59
120
|
.action(async (opts) => {
|
|
60
121
|
const dir = process.cwd();
|
|
122
|
+
// Decided BEFORE anything is provisioned: a refusal here creates nothing.
|
|
123
|
+
const plaintext = Boolean(opts.yesIAcceptPlaintextFile);
|
|
124
|
+
const refusal = initWalletRefusal({ wallet: opts.wallet !== false, plaintext, interactive: Boolean(process.stdin.isTTY) });
|
|
125
|
+
if (refusal) {
|
|
126
|
+
out(cmd, { ok: false, error: refusal });
|
|
127
|
+
process.exitCode = 1;
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
let passphrase = '';
|
|
131
|
+
if (opts.wallet !== false && !plaintext) {
|
|
132
|
+
passphrase = await promptSecret('Passphrase to seal the new wallet: ');
|
|
133
|
+
if (passphrase !== (await promptSecret('Repeat it: '))) {
|
|
134
|
+
out(cmd, { ok: false, error: 'passphrases did not match — nothing was created' });
|
|
135
|
+
process.exitCode = 1;
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (passphrase.length < 8) {
|
|
139
|
+
out(cmd, { ok: false, error: 'passphrase too short — nothing was created' });
|
|
140
|
+
process.exitCode = 1;
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
61
144
|
if (opts.writeEnv) {
|
|
62
145
|
const env = mergeEnv(dir);
|
|
63
146
|
if (env.ONE_API_KEY) {
|
|
@@ -100,6 +183,8 @@ export function initCmd() {
|
|
|
100
183
|
// folder is. The ceremony writes the ignore entry BEFORE the key and
|
|
101
184
|
// refuses to write a key at all if it cannot — see lib/keyfile.ts.
|
|
102
185
|
let keyLocation;
|
|
186
|
+
let walletFile = resolve(CONFIG_DIR, 'wallets', `${workspace}.json`);
|
|
187
|
+
let vaultDir = dir;
|
|
103
188
|
if (opts.dir) {
|
|
104
189
|
const res = writeKeyFolder({
|
|
105
190
|
dir: opts.dir,
|
|
@@ -115,6 +200,9 @@ export function initCmd() {
|
|
|
115
200
|
return;
|
|
116
201
|
}
|
|
117
202
|
keyLocation = `${res.keyPath} (0600, ignored via ${res.ignorePath})`;
|
|
203
|
+
if (res.keyPath)
|
|
204
|
+
walletFile = resolve(dirname(res.keyPath), 'wallet.json');
|
|
205
|
+
vaultDir = opts.dir;
|
|
118
206
|
}
|
|
119
207
|
else {
|
|
120
208
|
// The MACHINE key is regKey, not apiKey (text/agent-handover.md § 0). regKey's actor
|
|
@@ -128,6 +216,14 @@ export function initCmd() {
|
|
|
128
216
|
if (opts.writeEnv) {
|
|
129
217
|
writeEnvLocal(dir, { ONE_API_KEY: apiKey, ONE_API_URL: opts.api });
|
|
130
218
|
}
|
|
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.
|
|
221
|
+
const wallet = opts.wallet !== false
|
|
222
|
+
? await provisionLocalWallet({
|
|
223
|
+
api: opts.api, key: regKey || apiKey, workspace,
|
|
224
|
+
store: plaintext ? { kind: 'plaintext', file: walletFile } : { kind: 'vault', dir: vaultDir, passphrase },
|
|
225
|
+
})
|
|
226
|
+
: null;
|
|
131
227
|
out(cmd, {
|
|
132
228
|
ok: true,
|
|
133
229
|
workspace,
|
|
@@ -136,6 +232,13 @@ export function initCmd() {
|
|
|
136
232
|
...(expiresAt ? { expires: new Date(expiresAt * 1000).toISOString() } : {}),
|
|
137
233
|
...(opts.writeEnv ? { env: `${dir}/.env.local`, mcp: 'export ONE_API_KEY before launching Claude Code — MCP reads the shell env, not .env.local directly' } : {}),
|
|
138
234
|
...(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}` } : {}),
|
|
139
242
|
...(skills.length ? { skills: skills.join(', ') } : {}),
|
|
140
243
|
});
|
|
141
244
|
});
|
package/dist/src/lib/keyfile.js
CHANGED
|
@@ -28,10 +28,13 @@
|
|
|
28
28
|
* `agent-wallet-provision.ts` writes `addressed:false` always ("no server-side
|
|
29
29
|
* key material, ever"), and `isCreditOnlyWallet` keeps such an actor on credits.
|
|
30
30
|
* Minting a fundable identity from an unauthenticated door would turn a free
|
|
31
|
-
* empty-workspace faucet into a wallet faucet.
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
31
|
+
* empty-workspace faucet into a wallet faucet. The SERVER still never does:
|
|
32
|
+
* addresses arrive only from a key generated on the agent's machine, and for
|
|
33
|
+
* an agent row only with a signature over a fresh `wallet:challenge`
|
|
34
|
+
* (`@oneie/sdk/address-proof`). `oneie init` now runs that ceremony itself,
|
|
35
|
+
* after this one, sealing the wallet in the `wallet new` vault beside the key —
|
|
36
|
+
* never into it, and plaintext only behind --yes-i-accept-plaintext-file
|
|
37
|
+
* (`provisionLocalWallet` in init.ts; `--no-wallet` skips it).
|
|
35
38
|
*/
|
|
36
39
|
import { mkdirSync, writeFileSync, readFileSync, existsSync, chmodSync, renameSync, rmSync, realpathSync, lstatSync, openSync, writeSync, closeSync, constants as FS, } from 'node:fs';
|
|
37
40
|
import { randomBytes } from 'node:crypto';
|
package/dist/src/wallet.d.ts
CHANGED
|
@@ -42,6 +42,31 @@ export declare function faucetOk(results: Array<{
|
|
|
42
42
|
}>): boolean;
|
|
43
43
|
export declare function okWrap(result: Record<string, unknown>): Record<string, unknown>;
|
|
44
44
|
export declare function walletCmd(): Command;
|
|
45
|
+
/**
|
|
46
|
+
* Register an AGENT's locally generated addresses: fetch a fresh wallet:challenge,
|
|
47
|
+
* sign one statement per address with the local keys, send addresses + proofs.
|
|
48
|
+
* The server refuses an agent address without this (`address_proof_required`).
|
|
49
|
+
*
|
|
50
|
+
* The private keys are read here and go into `proveAddresses` only; the request
|
|
51
|
+
* body is built from its `{ addresses, proofs }` — public bytes — and nothing else.
|
|
52
|
+
*/
|
|
53
|
+
export declare function registerAgentWallet(opts: {
|
|
54
|
+
base: string;
|
|
55
|
+
key: string;
|
|
56
|
+
workspace: string;
|
|
57
|
+
actor: string;
|
|
58
|
+
keys: ReadonlyArray<{
|
|
59
|
+
chain: string;
|
|
60
|
+
address: string;
|
|
61
|
+
privateKeyHex: string;
|
|
62
|
+
}>;
|
|
63
|
+
}): Promise<Record<string, unknown>>;
|
|
64
|
+
/** The `keys` array of a keygen file, or [] — read for SIGNING only, never sent. */
|
|
65
|
+
export declare function signingKeys(source: unknown): Array<{
|
|
66
|
+
chain: string;
|
|
67
|
+
address: string;
|
|
68
|
+
privateKeyHex: string;
|
|
69
|
+
}>;
|
|
45
70
|
/**
|
|
46
71
|
* Reduce ANY keygen-shaped object to public receiving addresses. This is a
|
|
47
72
|
* whitelist build, never a spread or a delete-list: the returned object is
|
package/dist/src/wallet.js
CHANGED
|
@@ -4,6 +4,7 @@ import { writeFileSync, chmodSync, readFileSync, existsSync, rmSync } from 'node
|
|
|
4
4
|
import { createInterface } from 'node:readline';
|
|
5
5
|
import { generateWallet, recoverWallet, readDerivation } from '@oneie/sdk/wallet';
|
|
6
6
|
import { sealVault, openVault, mintKeychainSecret } from '@oneie/sdk/vault-file';
|
|
7
|
+
import { proveAddresses } from '@oneie/sdk/address-proof';
|
|
7
8
|
import { askPath } from './lib/api-path.js';
|
|
8
9
|
import { wordsStdoutRefusal } from './lib/agent-env.js';
|
|
9
10
|
import { writeVaultFolder, readVaultFolder, vaultPath, paperSheet, keychainStore, keychainRead, keychainAvailable, } from './lib/vaultfile.js';
|
|
@@ -190,7 +191,7 @@ export function walletCmd() {
|
|
|
190
191
|
out(cmd, okWrap(result));
|
|
191
192
|
});
|
|
192
193
|
cmd.command('register')
|
|
193
|
-
.description('Register a keygen output\'s PUBLIC receiving addresses with a workspace —
|
|
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
195
|
.option('--from <file>', 'A `wallet keygen --out` file (or any JSON with `addresses` / `keys`) — only the address fields are read')
|
|
195
196
|
.option('--addresses <json>', 'Inline JSON address map, e.g. \'{"sui":"0x…","evm":"0x…"}\'')
|
|
196
197
|
.option('--workspace <slug>', 'Workspace (defaults to AGENCY_SLUG)')
|
|
@@ -224,6 +225,18 @@ export function walletCmd() {
|
|
|
224
225
|
out(cmd, { ok: false, error: 'cancelled' });
|
|
225
226
|
return;
|
|
226
227
|
}
|
|
228
|
+
// An agent's addresses are taken only with proof of control, so an agent
|
|
229
|
+
// registration signs locally with the keygen file's keys — inline
|
|
230
|
+
// --addresses carries no keys and cannot prove anything.
|
|
231
|
+
if (opts.kind === 'agent') {
|
|
232
|
+
const keys = signingKeys(source);
|
|
233
|
+
if (keys.length === 0) {
|
|
234
|
+
out(cmd, { ok: false, error: 'an agent registration signs a server challenge — pass --from <a `wallet keygen --out` file> holding the keys' });
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
out(cmd, await registerAgentWallet({ base, key, workspace, actor, keys }));
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
227
240
|
// `actor`, not `opts.actor` — what the operator confirmed on screen is what gets
|
|
228
241
|
// written, rather than relying on the resolver's own default to agree.
|
|
229
242
|
const result = await ask(base, key, 'wallet:create', { workspace, actor, kind: opts.kind, addresses });
|
|
@@ -386,6 +399,32 @@ export function walletCmd() {
|
|
|
386
399
|
});
|
|
387
400
|
return cmd;
|
|
388
401
|
}
|
|
402
|
+
/**
|
|
403
|
+
* Register an AGENT's locally generated addresses: fetch a fresh wallet:challenge,
|
|
404
|
+
* sign one statement per address with the local keys, send addresses + proofs.
|
|
405
|
+
* The server refuses an agent address without this (`address_proof_required`).
|
|
406
|
+
*
|
|
407
|
+
* The private keys are read here and go into `proveAddresses` only; the request
|
|
408
|
+
* body is built from its `{ addresses, proofs }` — public bytes — and nothing else.
|
|
409
|
+
*/
|
|
410
|
+
export async function registerAgentWallet(opts) {
|
|
411
|
+
const issued = okWrap(await ask(opts.base, opts.key, 'wallet:challenge', { workspace: opts.workspace, actor: opts.actor }));
|
|
412
|
+
if (!issued.ok || typeof issued.challenge !== 'string')
|
|
413
|
+
return { ok: false, error: issued.error ?? 'no challenge issued' };
|
|
414
|
+
const { addresses, proofs } = proveAddresses(opts.keys, {
|
|
415
|
+
challenge: issued.challenge, workspace: opts.workspace, actor: opts.actor,
|
|
416
|
+
});
|
|
417
|
+
if (Object.keys(addresses).length === 0)
|
|
418
|
+
return { ok: false, error: 'no signable keys — expected a `keys` array of { chain, address, privateKeyHex }' };
|
|
419
|
+
return okWrap(await ask(opts.base, opts.key, 'wallet:create', {
|
|
420
|
+
workspace: opts.workspace, actor: opts.actor, kind: 'agent', addresses, challenge: issued.challenge, proofs,
|
|
421
|
+
}));
|
|
422
|
+
}
|
|
423
|
+
/** The `keys` array of a keygen file, or [] — read for SIGNING only, never sent. */
|
|
424
|
+
export function signingKeys(source) {
|
|
425
|
+
const keys = (source && typeof source === 'object' ? source['keys'] : undefined);
|
|
426
|
+
return (Array.isArray(keys) ? keys : []).filter((k) => !!k && typeof k.chain === 'string' && typeof k.address === 'string' && typeof k.privateKeyHex === 'string');
|
|
427
|
+
}
|
|
389
428
|
// Chain-name spellings a keygen output may use -> the four columns wallet:create
|
|
390
429
|
// declares. `eth`/`sol` are the SDK's WalletChain spellings; `evm`/`solana` are the
|
|
391
430
|
// server's.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oneie/cli",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.2",
|
|
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.16.
|
|
23
|
+
"@oneie/sdk": "^0.16.6"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@oneie/evals": "^0.2.0",
|