oneie 5.3.0 → 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/key.d.ts +3 -0
- package/dist/src/key.js +47 -3
- package/dist/src/lib/agent-env.d.ts +7 -0
- package/dist/src/lib/agent-env.js +16 -0
- package/dist/src/lib/keyfile.js +7 -4
- package/dist/src/lib/tasks-prove.d.ts +15 -0
- package/dist/src/lib/tasks-prove.js +68 -0
- package/dist/src/tasks.js +4 -0
- package/dist/src/wallet.d.ts +61 -0
- package/dist/src/wallet.js +106 -9
- 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",
|
|
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/key.d.ts
CHANGED
|
@@ -18,6 +18,9 @@
|
|
|
18
18
|
* • Under --json the words never reach stdout (an agent's stdout is a model
|
|
19
19
|
* context and a session log). They reach disk only behind keygen's own
|
|
20
20
|
* --yes-i-accept-plaintext-file, at 0600.
|
|
21
|
+
* • Printed, the words go only to a terminal: a shell whose env names an agent
|
|
22
|
+
* or CI is refused, and a non-TTY stdout needs --yes-print-to-pipe. That is
|
|
23
|
+
* detection, not proof — a pty with no marker is not caught (text/key.md).
|
|
21
24
|
*/
|
|
22
25
|
import { Command } from 'commander';
|
|
23
26
|
export declare function keyCmd(): Command;
|
package/dist/src/key.js
CHANGED
|
@@ -18,6 +18,9 @@
|
|
|
18
18
|
* • Under --json the words never reach stdout (an agent's stdout is a model
|
|
19
19
|
* context and a session log). They reach disk only behind keygen's own
|
|
20
20
|
* --yes-i-accept-plaintext-file, at 0600.
|
|
21
|
+
* • Printed, the words go only to a terminal: a shell whose env names an agent
|
|
22
|
+
* or CI is refused, and a non-TTY stdout needs --yes-print-to-pipe. That is
|
|
23
|
+
* detection, not proof — a pty with no marker is not caught (text/key.md).
|
|
21
24
|
*/
|
|
22
25
|
import { Command } from 'commander';
|
|
23
26
|
import { existsSync, readFileSync } from 'node:fs';
|
|
@@ -25,6 +28,7 @@ import { generateWallet, recoverWallet } from '@oneie/sdk/wallet';
|
|
|
25
28
|
import { userIdPubFromPhrase } from '@oneie/sdk/key-identity';
|
|
26
29
|
import { jsonMode, resolveBase, resolveKey } from './lib/client.js';
|
|
27
30
|
import { promptSecret, writeKeysFile } from './wallet.js';
|
|
31
|
+
import { wordsStdoutRefusal } from './lib/agent-env.js';
|
|
28
32
|
const REFUSE_ARGV_SECRET = 'A secret on the command line is refused on purpose: it is written to your shell history and is ' +
|
|
29
33
|
'visible in `ps` to every user on this machine. Set ONE_WALLET_MNEMONIC or pipe the words on stdin.';
|
|
30
34
|
const REFUSE_ARGV = 'Unrecognised argument. It is not repeated here on purpose — it may BE your recovery phrase. ' +
|
|
@@ -146,10 +150,17 @@ export function keyCmd() {
|
|
|
146
150
|
const cmd = new Command('key').description('One key — new · recover · public · verify. Offline except verify, which sends only your API key');
|
|
147
151
|
cmd.command('new')
|
|
148
152
|
.description('Mint a key on this machine: 24 words, printed ONCE, for paper. No network')
|
|
149
|
-
.
|
|
153
|
+
.argument('[refused...]')
|
|
154
|
+
.allowUnknownOption()
|
|
155
|
+
.option('--phrase [words]', 'REFUSED — never put the words on the command line')
|
|
156
|
+
.option('--mnemonic [words]', 'REFUSED — never put the words on the command line')
|
|
157
|
+
.option('--derivation <v>', 'v2 (default — standard BIP-44 paths, what one.ie mints) or v1 (original ONE HKDF labels)', 'v2')
|
|
150
158
|
.option('--out <file>', 'Write the words + keys to a file at mode 0600 instead of printing them')
|
|
151
159
|
.option('--yes-i-accept-plaintext-file', 'Required with --out — acknowledge that unencrypted key material will be written to disk')
|
|
152
|
-
.
|
|
160
|
+
.option('--yes-print-to-pipe', 'Print the words even though stdout is not a terminal — a printer, on purpose. An agent shell is refused regardless')
|
|
161
|
+
.action(async (rest, opts, sub) => {
|
|
162
|
+
if (refuseArgv(sub, opts, rest))
|
|
163
|
+
return;
|
|
153
164
|
const derivation = readDerivationOpt(opts.derivation);
|
|
154
165
|
if (!derivation)
|
|
155
166
|
return fail(sub, '--derivation must be v1 or v2');
|
|
@@ -162,6 +173,11 @@ export function keyCmd() {
|
|
|
162
173
|
if (!opts.out && jsonMode(sub)) {
|
|
163
174
|
return fail(sub, 'refusing to print the words under --json — stdout may be a log or a model context. Use --out <file> --yes-i-accept-plaintext-file');
|
|
164
175
|
}
|
|
176
|
+
if (!opts.out) {
|
|
177
|
+
const why = wordsStdoutRefusal(process.env, Boolean(process.stdout.isTTY), Boolean(opts.yesPrintToPipe));
|
|
178
|
+
if (why)
|
|
179
|
+
return fail(sub, why);
|
|
180
|
+
}
|
|
165
181
|
const wallet = await generateWallet(derivation);
|
|
166
182
|
const addresses = addressesOf(wallet);
|
|
167
183
|
const userIdPub = await userIdPubFromPhrase(wallet.mnemonic);
|
|
@@ -216,7 +232,7 @@ export function keyCmd() {
|
|
|
216
232
|
});
|
|
217
233
|
}));
|
|
218
234
|
cmd.addCommand(wordsCommand('public', 'The public identity + the four chain addresses for your words — nothing secret, no network')
|
|
219
|
-
.option('--derivation <v>', 'v1
|
|
235
|
+
.option('--derivation <v>', 'v1 or v2 — omit it and both sets print, because the words carry no marker')
|
|
220
236
|
.action(async (rest, opts, sub) => {
|
|
221
237
|
if (refuseArgv(sub, opts, rest))
|
|
222
238
|
return;
|
|
@@ -224,6 +240,27 @@ export function keyCmd() {
|
|
|
224
240
|
if (!derivation)
|
|
225
241
|
return fail(sub, '--derivation must be v1 or v2');
|
|
226
242
|
const words = await readWords();
|
|
243
|
+
// No --derivation: the words say nothing about which set they were minted
|
|
244
|
+
// under, and `key new` mints v2 while every older key is v1. Picking one
|
|
245
|
+
// here is the silent divergence task:01a0c33a93bbebfc8e2ebba0 closed — so
|
|
246
|
+
// both sets print, the way `key recover` already does.
|
|
247
|
+
if (opts.derivation === undefined) {
|
|
248
|
+
let v1, v2, userIdPub;
|
|
249
|
+
try {
|
|
250
|
+
v1 = await recoverWallet(words, 'v1');
|
|
251
|
+
v2 = await recoverWallet(words, 'v2');
|
|
252
|
+
userIdPub = await userIdPubFromPhrase(words);
|
|
253
|
+
}
|
|
254
|
+
catch {
|
|
255
|
+
return fail(sub, INVALID_PHRASE);
|
|
256
|
+
}
|
|
257
|
+
return done(sub, {
|
|
258
|
+
ok: true,
|
|
259
|
+
userIdPub,
|
|
260
|
+
v1: { label: labelFor('v1'), addresses: addressesOf(v1) },
|
|
261
|
+
v2: { label: labelFor('v2'), addresses: addressesOf(v2) },
|
|
262
|
+
});
|
|
263
|
+
}
|
|
227
264
|
let wallet, userIdPub;
|
|
228
265
|
try {
|
|
229
266
|
wallet = await recoverWallet(words, derivation);
|
|
@@ -266,5 +303,12 @@ export function keyCmd() {
|
|
|
266
303
|
if (verdict === 'mismatch')
|
|
267
304
|
process.exitCode = 1;
|
|
268
305
|
}));
|
|
306
|
+
// `one key <token>`: commander would print "unknown command '<token>'" — and the
|
|
307
|
+
// token may BE the first word of a phrase. Refuse it here without repeating it.
|
|
308
|
+
cmd.argument('[refused...]').allowUnknownOption().action((rest, _opts, c) => {
|
|
309
|
+
if (rest.length === 0)
|
|
310
|
+
return c.help({ error: true });
|
|
311
|
+
fail(c, REFUSE_ARGV);
|
|
312
|
+
});
|
|
269
313
|
return cmd;
|
|
270
314
|
}
|
|
@@ -3,3 +3,10 @@ export declare function agentType(env?: NodeJS.ProcessEnv): string | undefined;
|
|
|
3
3
|
/** True when stdout isn't a human's terminal (agent shell, CI, piped) or a
|
|
4
4
|
* known agent env var is set — never used to gate a prompt, only the greeting. */
|
|
5
5
|
export declare function isAgentEnvironment(env?: NodeJS.ProcessEnv, isTTY?: boolean): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Why the 24 recovery words must NOT be written to this stdout, or null when it is
|
|
8
|
+
* a person's terminal. A shell whose env names an agent or CI is refused even with
|
|
9
|
+
* the pipe override: its stdout is a model context and a session log. This is
|
|
10
|
+
* detection, not proof — a pty with no marker set is not caught.
|
|
11
|
+
*/
|
|
12
|
+
export declare function wordsStdoutRefusal(env: NodeJS.ProcessEnv, isTTY: boolean, allowPipe: boolean): string | null;
|
|
@@ -30,3 +30,19 @@ export function agentType(env = process.env) {
|
|
|
30
30
|
export function isAgentEnvironment(env = process.env, isTTY = process.stdout.isTTY) {
|
|
31
31
|
return Boolean(agentType(env)) || !isTTY;
|
|
32
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Why the 24 recovery words must NOT be written to this stdout, or null when it is
|
|
35
|
+
* a person's terminal. A shell whose env names an agent or CI is refused even with
|
|
36
|
+
* the pipe override: its stdout is a model context and a session log. This is
|
|
37
|
+
* detection, not proof — a pty with no marker set is not caught.
|
|
38
|
+
*/
|
|
39
|
+
export function wordsStdoutRefusal(env, isTTY, allowPipe) {
|
|
40
|
+
const agent = agentType(env);
|
|
41
|
+
if (agent) {
|
|
42
|
+
return `refusing to print the words: this shell is driven by ${agent}, and its stdout is a model context and a session log. Run it yourself in a terminal no agent drives`;
|
|
43
|
+
}
|
|
44
|
+
if (!isTTY && !allowPipe) {
|
|
45
|
+
return 'refusing to print the words: stdout is not a terminal (a pipe, a file or a log). Pass --yes-print-to-pipe if you are sending them to a printer on purpose';
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
}
|
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';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Row } from './tasks-digest.js';
|
|
2
|
+
export declare function acceptOf(notes: string): string | null;
|
|
3
|
+
export declare function isHermetic(accept: string): boolean;
|
|
4
|
+
export declare function proveRows(rows: {
|
|
5
|
+
tid: string;
|
|
6
|
+
notes?: string;
|
|
7
|
+
}[], run: (accept: string) => number): {
|
|
8
|
+
tid: string;
|
|
9
|
+
verdict: 'proof-green — close?' | 'red' | 'unproven';
|
|
10
|
+
}[];
|
|
11
|
+
export declare function renderProve(results: {
|
|
12
|
+
tid: string;
|
|
13
|
+
verdict: string;
|
|
14
|
+
}[]): string;
|
|
15
|
+
export declare function proveBoard(rows: Row[]): Promise<void>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
export function acceptOf(notes) {
|
|
5
|
+
const acceptLine = notes.split('\n').find(line => line.startsWith('Accept:'));
|
|
6
|
+
if (!acceptLine)
|
|
7
|
+
return null;
|
|
8
|
+
return acceptLine.slice('Accept:'.length).trim();
|
|
9
|
+
}
|
|
10
|
+
export function isHermetic(accept) {
|
|
11
|
+
const falsePatterns = ['curl', 'proof.sh route', '--window', '--since-ship'];
|
|
12
|
+
for (const pat of falsePatterns) {
|
|
13
|
+
if (accept.includes(pat))
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
return accept.startsWith('bash .claude/scripts/proof.sh test ') || accept.includes('--self-test');
|
|
17
|
+
}
|
|
18
|
+
export function proveRows(rows, run) {
|
|
19
|
+
return rows.map(row => {
|
|
20
|
+
const accept = row.notes ? acceptOf(row.notes) : null;
|
|
21
|
+
if (accept && isHermetic(accept)) {
|
|
22
|
+
const exitCode = run(accept);
|
|
23
|
+
const verdict = exitCode === 0 ? 'proof-green — close?' : 'red';
|
|
24
|
+
return { tid: row.tid, verdict };
|
|
25
|
+
}
|
|
26
|
+
return { tid: row.tid, verdict: 'unproven' };
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
export function renderProve(results) {
|
|
30
|
+
return results.map(r => `${r.tid} ${r.verdict}`).join('\n');
|
|
31
|
+
}
|
|
32
|
+
export async function proveBoard(rows) {
|
|
33
|
+
const TOP = spawnSync('git', ['rev-parse', '--show-toplevel'], { encoding: 'utf8' }).stdout.trim();
|
|
34
|
+
const pid = process.pid;
|
|
35
|
+
const worktreeName = `prove-${pid}`;
|
|
36
|
+
const worktreePath = join(TOP, '.claude', 'worktrees', worktreeName);
|
|
37
|
+
const upResult = spawnSync('bash', [
|
|
38
|
+
'-c',
|
|
39
|
+
`bash .claude/scripts/worktree-up.sh ${worktreeName} --no-dev --base origin/dev`
|
|
40
|
+
], {
|
|
41
|
+
cwd: TOP,
|
|
42
|
+
encoding: 'utf8',
|
|
43
|
+
});
|
|
44
|
+
if (upResult.status !== 0) {
|
|
45
|
+
if (upResult.stderr) {
|
|
46
|
+
process.stderr.write(upResult.stderr);
|
|
47
|
+
}
|
|
48
|
+
if (existsSync(worktreePath)) {
|
|
49
|
+
spawnSync('git', ['worktree', 'remove', '--force', worktreePath]);
|
|
50
|
+
}
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
const run = (accept) => {
|
|
55
|
+
const result = spawnSync('bash', ['-c', accept], {
|
|
56
|
+
cwd: worktreePath,
|
|
57
|
+
encoding: 'utf8',
|
|
58
|
+
});
|
|
59
|
+
return result.status ?? 1;
|
|
60
|
+
};
|
|
61
|
+
const results = proveRows(rows, run);
|
|
62
|
+
const output = renderProve(results);
|
|
63
|
+
process.stdout.write(output + '\n');
|
|
64
|
+
}
|
|
65
|
+
finally {
|
|
66
|
+
spawnSync('git', ['worktree', 'remove', '--force', worktreePath]);
|
|
67
|
+
}
|
|
68
|
+
}
|
package/dist/src/tasks.js
CHANGED
|
@@ -10,6 +10,7 @@ import { runLivePlan } from './lib/plan-live.js';
|
|
|
10
10
|
import { runFlow, FLOWS as FLOW_IDS } from './lib/flow-tag.js';
|
|
11
11
|
import { buildLens, lensRows } from './lib/tasks-lens.js';
|
|
12
12
|
import { loadRoster } from './lib/roster.js';
|
|
13
|
+
import { proveBoard } from './lib/tasks-prove.js';
|
|
13
14
|
import { proposeOwners, routeEdits } from './lib/tasks-route.js';
|
|
14
15
|
import { claimNext, nextCandidates } from './lib/tasks-next.js';
|
|
15
16
|
import { resolveBulkWorkspaces, spreadWarning, workspaceSpread } from './lib/tasks-workspace.js';
|
|
@@ -263,6 +264,7 @@ export function tasksCmd() {
|
|
|
263
264
|
.option('--include <list>', 'Comma list: notes,graph,dates,thread')
|
|
264
265
|
.option('--summary', 'Counts and sets only, no rows')
|
|
265
266
|
.option('--all', 'Follow nextCursor until every page is read (ceiling 20 pages)')
|
|
267
|
+
.option('--prove', "Run each open row's Accept in a clean worktree at origin/dev and mark the ones already green")
|
|
266
268
|
.option('--limit <n>', 'Rows per page (max 2000)')
|
|
267
269
|
.option('--fresh', 'Rebuild the snapshot instead of reading the memo')
|
|
268
270
|
.option('--kind <k>', "work (default) | approval | all — approvals are parked workflow runs; filtered from ROWS here, the server summary still counts them", 'work')
|
|
@@ -310,6 +312,8 @@ export function tasksCmd() {
|
|
|
310
312
|
process.stdout.write(`\n--kind ${kind}: ${excluded} ${kind === 'work' ? 'approval' : 'work'} rows left out of the rows above (the summary is server-side and still counts them). --kind all to include.\n`);
|
|
311
313
|
}
|
|
312
314
|
}
|
|
315
|
+
if (res.ok !== false && sub.opts().prove)
|
|
316
|
+
await proveBoard((res.tasks ?? []));
|
|
313
317
|
if (res.ok === false)
|
|
314
318
|
fail(res.error ?? 'tasks:board failed');
|
|
315
319
|
});
|
package/dist/src/wallet.d.ts
CHANGED
|
@@ -1,11 +1,72 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
+
import { type Derivation, type GeneratedWallet } from '@oneie/sdk/wallet';
|
|
3
|
+
import { type VaultBlob, type SealOpts } from '@oneie/sdk/vault-file';
|
|
2
4
|
import { askPath } from './lib/api-path.js';
|
|
3
5
|
export { askPath };
|
|
6
|
+
/**
|
|
7
|
+
* A FRESH mint is born v2 — the same as one.ie (`NEW_MASTER_DERIVATION` in
|
|
8
|
+
* one.ie/web/src/lib/derive-multichain.ts). Before this the CLI minted v1 and the
|
|
9
|
+
* browser v2, so the same 24 words opened a different, empty wallet on each
|
|
10
|
+
* surface and nothing errored (task:01a0c33a93bbebfc8e2ebba0).
|
|
11
|
+
*
|
|
12
|
+
* A RECOVER has no marker to read, so it takes `--derivation` and an absent one is
|
|
13
|
+
* v1: the words may belong to a v1 key, and a v1 key recovers its v1 addresses
|
|
14
|
+
* forever. Guessing v2 here would recreate the same silent divergence in reverse.
|
|
15
|
+
*/
|
|
16
|
+
export declare const MINT_DERIVATION: Derivation;
|
|
17
|
+
export declare function walletDerivation(opts: {
|
|
18
|
+
recover?: boolean;
|
|
19
|
+
derivation?: string;
|
|
20
|
+
}): Derivation;
|
|
21
|
+
/** Mint or recover, under the derivation named above — the one door both commands use. */
|
|
22
|
+
export declare function walletFor(opts: {
|
|
23
|
+
recover?: boolean;
|
|
24
|
+
derivation?: string;
|
|
25
|
+
}, words: () => string): Promise<{
|
|
26
|
+
wallet: GeneratedWallet;
|
|
27
|
+
derivation: Derivation;
|
|
28
|
+
}>;
|
|
29
|
+
/** Seal the words WITH their derivation. v1 is the field's absence (it rides the
|
|
30
|
+
* AAD only when present), so a v1 vault stays byte-compatible with every one
|
|
31
|
+
* written before the marker existed. */
|
|
32
|
+
export declare function sealWallet(mnemonic: string, passphrase: string, opts: {
|
|
33
|
+
wrap: VaultBlob['wrap'];
|
|
34
|
+
authPub: string;
|
|
35
|
+
derivation: Derivation;
|
|
36
|
+
kdf?: SealOpts['kdf'];
|
|
37
|
+
}): Promise<VaultBlob>;
|
|
38
|
+
/** The addresses a sealed vault holds, read under ITS marker — absent is v1. */
|
|
39
|
+
export declare function openedWallet(blob: VaultBlob, mnemonic: string): Promise<GeneratedWallet>;
|
|
4
40
|
export declare function faucetOk(results: Array<{
|
|
5
41
|
success: boolean;
|
|
6
42
|
}>): boolean;
|
|
7
43
|
export declare function okWrap(result: Record<string, unknown>): Record<string, unknown>;
|
|
8
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
|
+
}>;
|
|
9
70
|
/**
|
|
10
71
|
* Reduce ANY keygen-shaped object to public receiving addresses. This is a
|
|
11
72
|
* whitelist build, never a spread or a delete-list: the returned object is
|
package/dist/src/wallet.js
CHANGED
|
@@ -2,9 +2,11 @@ import { Command } from 'commander';
|
|
|
2
2
|
import { mergeEnv } from './env.js';
|
|
3
3
|
import { writeFileSync, chmodSync, readFileSync, existsSync, rmSync } from 'node:fs';
|
|
4
4
|
import { createInterface } from 'node:readline';
|
|
5
|
-
import { generateWallet, recoverWallet } from '@oneie/sdk/wallet';
|
|
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';
|
|
9
|
+
import { wordsStdoutRefusal } from './lib/agent-env.js';
|
|
8
10
|
import { writeVaultFolder, readVaultFolder, vaultPath, paperSheet, keychainStore, keychainRead, keychainAvailable, } from './lib/vaultfile.js';
|
|
9
11
|
const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://api.one.ie';
|
|
10
12
|
// Re-exported for existing callers/tests — canonical implementation now lives
|
|
@@ -47,6 +49,44 @@ async function payProtocol(payUrl, protocol, data) {
|
|
|
47
49
|
}
|
|
48
50
|
return body.data ?? {};
|
|
49
51
|
}
|
|
52
|
+
// ── which derivation a wallet is born under ─────────────────────────────────
|
|
53
|
+
/**
|
|
54
|
+
* A FRESH mint is born v2 — the same as one.ie (`NEW_MASTER_DERIVATION` in
|
|
55
|
+
* one.ie/web/src/lib/derive-multichain.ts). Before this the CLI minted v1 and the
|
|
56
|
+
* browser v2, so the same 24 words opened a different, empty wallet on each
|
|
57
|
+
* surface and nothing errored (task:01a0c33a93bbebfc8e2ebba0).
|
|
58
|
+
*
|
|
59
|
+
* A RECOVER has no marker to read, so it takes `--derivation` and an absent one is
|
|
60
|
+
* v1: the words may belong to a v1 key, and a v1 key recovers its v1 addresses
|
|
61
|
+
* forever. Guessing v2 here would recreate the same silent divergence in reverse.
|
|
62
|
+
*/
|
|
63
|
+
export const MINT_DERIVATION = 'v2';
|
|
64
|
+
export function walletDerivation(opts) {
|
|
65
|
+
if (opts.derivation === undefined)
|
|
66
|
+
return opts.recover ? 'v1' : MINT_DERIVATION;
|
|
67
|
+
return readDerivation(opts.derivation);
|
|
68
|
+
}
|
|
69
|
+
/** Mint or recover, under the derivation named above — the one door both commands use. */
|
|
70
|
+
export async function walletFor(opts, words) {
|
|
71
|
+
const derivation = walletDerivation(opts);
|
|
72
|
+
const wallet = opts.recover ? await recoverWallet(words(), derivation) : await generateWallet(derivation);
|
|
73
|
+
return { wallet, derivation };
|
|
74
|
+
}
|
|
75
|
+
/** Seal the words WITH their derivation. v1 is the field's absence (it rides the
|
|
76
|
+
* AAD only when present), so a v1 vault stays byte-compatible with every one
|
|
77
|
+
* written before the marker existed. */
|
|
78
|
+
export async function sealWallet(mnemonic, passphrase, opts) {
|
|
79
|
+
return sealVault(mnemonic, passphrase, {
|
|
80
|
+
wrap: opts.wrap,
|
|
81
|
+
authPub: opts.authPub,
|
|
82
|
+
kdf: opts.kdf,
|
|
83
|
+
...(opts.derivation === 'v2' ? { derivation: 'v2' } : {}),
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
/** The addresses a sealed vault holds, read under ITS marker — absent is v1. */
|
|
87
|
+
export async function openedWallet(blob, mnemonic) {
|
|
88
|
+
return recoverWallet(mnemonic, readDerivation(blob.derivation));
|
|
89
|
+
}
|
|
50
90
|
function resolveAuth(opts) {
|
|
51
91
|
const env = mergeEnv(process.cwd());
|
|
52
92
|
const key = opts.key ?? env.ONEIE_API_KEY ?? env.ONE_API_KEY ?? '';
|
|
@@ -151,7 +191,7 @@ export function walletCmd() {
|
|
|
151
191
|
out(cmd, okWrap(result));
|
|
152
192
|
});
|
|
153
193
|
cmd.command('register')
|
|
154
|
-
.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')
|
|
155
195
|
.option('--from <file>', 'A `wallet keygen --out` file (or any JSON with `addresses` / `keys`) — only the address fields are read')
|
|
156
196
|
.option('--addresses <json>', 'Inline JSON address map, e.g. \'{"sui":"0x…","evm":"0x…"}\'')
|
|
157
197
|
.option('--workspace <slug>', 'Workspace (defaults to AGENCY_SLUG)')
|
|
@@ -185,6 +225,18 @@ export function walletCmd() {
|
|
|
185
225
|
out(cmd, { ok: false, error: 'cancelled' });
|
|
186
226
|
return;
|
|
187
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
|
+
}
|
|
188
240
|
// `actor`, not `opts.actor` — what the operator confirmed on screen is what gets
|
|
189
241
|
// written, rather than relying on the resolver's own default to agree.
|
|
190
242
|
const result = await ask(base, key, 'wallet:create', { workspace, actor, kind: opts.kind, addresses });
|
|
@@ -193,18 +245,19 @@ export function walletCmd() {
|
|
|
193
245
|
cmd.command('keygen')
|
|
194
246
|
.description('Generate or recover a self-hosted wallet locally — 4 chains (Sui/EVM/Sol/BTC), fully offline, never touches the network or a server. Prints once by default; use --out for scripted bulk provisioning')
|
|
195
247
|
.option('--recover', 'Recover from a 24-word BIP-39 mnemonic (ONE_WALLET_MNEMONIC env or stdin) instead of generating a fresh one')
|
|
248
|
+
.option('--derivation <v>', 'v2 (default for a fresh key — what one.ie mints) or v1. With --recover the default is v1: the words carry no marker, and a v1 key recovers its v1 addresses forever')
|
|
196
249
|
.option('--out <file>', 'Write the mnemonic + keys to a file at mode 0600 instead of printing once')
|
|
197
250
|
.option('--yes-i-accept-plaintext-file', 'Required with --out — acknowledge that unencrypted key material will be written to disk')
|
|
198
251
|
.action(async (opts) => {
|
|
199
|
-
const wallet
|
|
252
|
+
const { wallet, derivation } = await walletFor(opts, readMnemonic);
|
|
200
253
|
const addresses = Object.fromEntries(wallet.keys.map((k) => [k.chain, k.address]));
|
|
201
254
|
if (opts.out) {
|
|
202
|
-
const contents = JSON.stringify({ mnemonic: wallet.mnemonic, keys: wallet.keys }, null, 2) + '\n';
|
|
255
|
+
const contents = JSON.stringify({ mnemonic: wallet.mnemonic, derivation, keys: wallet.keys }, null, 2) + '\n';
|
|
203
256
|
writeKeysFile(opts.out, contents, Boolean(opts.yesIAcceptPlaintextFile));
|
|
204
|
-
out(cmd, { ok: true, out: opts.out, chains: wallet.keys.map((k) => k.chain), addresses });
|
|
257
|
+
out(cmd, { ok: true, out: opts.out, derivation, chains: wallet.keys.map((k) => k.chain), addresses });
|
|
205
258
|
}
|
|
206
259
|
else {
|
|
207
|
-
out(cmd, { ok: true, mnemonic: wallet.mnemonic, addresses, keys: wallet.keys });
|
|
260
|
+
out(cmd, { ok: true, mnemonic: wallet.mnemonic, derivation, addresses, keys: wallet.keys });
|
|
208
261
|
}
|
|
209
262
|
});
|
|
210
263
|
// ── the encrypted wallet folder ────────────────────────────────────────────
|
|
@@ -212,6 +265,7 @@ export function walletCmd() {
|
|
|
212
265
|
.description('Create an encrypted wallet in this folder — 24 words sealed with a passphrase, four chains, fully offline')
|
|
213
266
|
.option('--dir <path>', 'Project directory', '.')
|
|
214
267
|
.option('--recover', 'Seal an EXISTING 24-word phrase instead of generating a new one (ONE_WALLET_MNEMONIC or stdin)')
|
|
268
|
+
.option('--derivation <v>', 'v2 (default for a fresh wallet — what one.ie mints) or v1. With --recover the default is v1: the words carry no marker, and a v1 key recovers its v1 addresses forever')
|
|
215
269
|
.option('--keychain', 'Seal with a random secret stored in Apple Keychain, so Touch ID opens it instead of a passphrase')
|
|
216
270
|
.action(async (opts) => {
|
|
217
271
|
// Refuse BEFORE generating. Minting a wallet and then failing to store it
|
|
@@ -225,6 +279,14 @@ export function walletCmd() {
|
|
|
225
279
|
out(cmd, { ok: false, error: 'Keychain is macOS-only — omit --keychain to seal with a passphrase' });
|
|
226
280
|
return;
|
|
227
281
|
}
|
|
282
|
+
// A bad --derivation is refused before the passphrase is asked for, not after.
|
|
283
|
+
try {
|
|
284
|
+
walletDerivation(opts);
|
|
285
|
+
}
|
|
286
|
+
catch {
|
|
287
|
+
out(cmd, { ok: false, error: '--derivation must be v1 or v2' });
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
228
290
|
let passphrase;
|
|
229
291
|
let wrap;
|
|
230
292
|
if (opts.keychain) {
|
|
@@ -244,10 +306,10 @@ export function walletCmd() {
|
|
|
244
306
|
}
|
|
245
307
|
wrap = 'passphrase';
|
|
246
308
|
}
|
|
247
|
-
const wallet
|
|
309
|
+
const { wallet, derivation } = await walletFor(opts, readMnemonic);
|
|
248
310
|
const addresses = Object.fromEntries(wallet.keys.map((k) => [k.chain, k.address]));
|
|
249
311
|
const authPub = wallet.keys.find((k) => k.chain === 'sui')?.publicKeyHex ?? '';
|
|
250
|
-
const blob = await
|
|
312
|
+
const blob = await sealWallet(wallet.mnemonic, passphrase, { wrap, authPub, derivation });
|
|
251
313
|
const res = writeVaultFolder(opts.dir, { ...blob });
|
|
252
314
|
if (!res.ok) {
|
|
253
315
|
out(cmd, { ok: false, error: res.error });
|
|
@@ -267,6 +329,7 @@ export function walletCmd() {
|
|
|
267
329
|
ok: true,
|
|
268
330
|
wallet: res.path,
|
|
269
331
|
wrap,
|
|
332
|
+
derivation,
|
|
270
333
|
addresses,
|
|
271
334
|
next: 'one wallet paper # write the 24 words down — this is the ONLY backup',
|
|
272
335
|
});
|
|
@@ -285,7 +348,15 @@ export function walletCmd() {
|
|
|
285
348
|
cmd.command('paper')
|
|
286
349
|
.description('Print the recovery sheet — 24 numbered words plus the public addresses. Print it, then close the terminal')
|
|
287
350
|
.option('--dir <path>', 'Project directory', '.')
|
|
351
|
+
.option('--yes-print-to-pipe', 'Print the words even though stdout is not a terminal — a printer, on purpose. An agent shell is refused regardless')
|
|
288
352
|
.action(async (opts) => {
|
|
353
|
+
// Refuse BEFORE unlock: no passphrase prompt, no Touch ID, when the words could not be shown.
|
|
354
|
+
const why = wordsStdoutRefusal(process.env, Boolean(process.stdout.isTTY), Boolean(opts.yesPrintToPipe));
|
|
355
|
+
if (why) {
|
|
356
|
+
out(cmd, { ok: false, error: why });
|
|
357
|
+
process.exitCode = 1;
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
289
360
|
const r = await unlock(opts.dir);
|
|
290
361
|
if ('error' in r) {
|
|
291
362
|
out(cmd, { ok: false, error: r.error });
|
|
@@ -328,6 +399,32 @@ export function walletCmd() {
|
|
|
328
399
|
});
|
|
329
400
|
return cmd;
|
|
330
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
|
+
}
|
|
331
428
|
// Chain-name spellings a keygen output may use -> the four columns wallet:create
|
|
332
429
|
// declares. `eth`/`sol` are the SDK's WalletChain spellings; `evm`/`solana` are the
|
|
333
430
|
// server's.
|
|
@@ -462,6 +559,6 @@ async function unlock(dir) {
|
|
|
462
559
|
catch (e) {
|
|
463
560
|
return { error: e.message };
|
|
464
561
|
}
|
|
465
|
-
const wallet = await
|
|
562
|
+
const wallet = await openedWallet(blob, mnemonic);
|
|
466
563
|
return { blob, mnemonic, addresses: Object.fromEntries(wallet.keys.map((k) => [k.chain, k.address])) };
|
|
467
564
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oneie",
|
|
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",
|