@oneie/cli 5.8.0 → 5.9.0
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 +114 -6
- package/dist/package.json +37 -11
- package/dist/src/age-1k8hs4ec.js +1 -0
- package/dist/src/client-n6fpnd9f.js +1 -0
- package/dist/src/evm-tx-cqhm9rtt.js +1 -0
- package/dist/src/hl-run-0pv1e0p2.js +1 -0
- package/dist/src/index-f5vhzspa.js +12 -0
- package/dist/src/index-h3nrt8bx.js +4 -0
- package/dist/src/index-st6k9vhc.js +2062 -0
- package/dist/src/index.js +1122 -134
- package/dist/src/message-key-yczrxszr.js +1 -0
- package/dist/src/message-lock-thr851d5.js +5 -0
- package/dist/src/sweep-order-jrq2hkye.js +1 -0
- package/dist/src/sweep-runner-jftw9em7.js +1 -0
- package/package.json +37 -11
- package/dist/src/agent.d.ts +0 -75
- package/dist/src/agent.js +0 -1334
- package/dist/src/agentverse.d.ts +0 -26
- package/dist/src/agentverse.js +0 -171
- package/dist/src/args.d.ts +0 -9
- package/dist/src/args.js +0 -61
- package/dist/src/auth.d.ts +0 -6
- package/dist/src/auth.js +0 -121
- package/dist/src/balances.d.ts +0 -89
- package/dist/src/balances.js +0 -202
- package/dist/src/banner.d.ts +0 -1
- package/dist/src/banner.js +0 -17
- package/dist/src/broadcast.d.ts +0 -8
- package/dist/src/broadcast.js +0 -175
- package/dist/src/catalog.d.ts +0 -12
- package/dist/src/catalog.js +0 -76
- package/dist/src/ceiling.d.ts +0 -36
- package/dist/src/ceiling.js +0 -189
- package/dist/src/chat.d.ts +0 -2
- package/dist/src/chat.js +0 -92
- package/dist/src/check.d.ts +0 -11
- package/dist/src/check.js +0 -53
- package/dist/src/client.d.ts +0 -5
- package/dist/src/client.js +0 -157
- package/dist/src/compiler.d.ts +0 -36
- package/dist/src/compiler.js +0 -366
- package/dist/src/config.d.ts +0 -24
- package/dist/src/config.js +0 -70
- package/dist/src/connect.d.ts +0 -2
- package/dist/src/connect.js +0 -64
- package/dist/src/coordinate.d.ts +0 -3
- package/dist/src/coordinate.js +0 -58
- package/dist/src/create.d.ts +0 -2
- package/dist/src/create.js +0 -113
- package/dist/src/credits.d.ts +0 -29
- package/dist/src/credits.js +0 -88
- package/dist/src/deploy.d.ts +0 -2
- package/dist/src/deploy.js +0 -19
- package/dist/src/dev.d.ts +0 -2
- package/dist/src/dev.js +0 -75
- package/dist/src/device-flow.d.ts +0 -57
- package/dist/src/device-flow.js +0 -173
- package/dist/src/doctor.d.ts +0 -26
- package/dist/src/doctor.js +0 -146
- package/dist/src/draw.d.ts +0 -18
- package/dist/src/draw.js +0 -156
- package/dist/src/endpoint.d.ts +0 -2
- package/dist/src/endpoint.js +0 -250
- package/dist/src/env.d.ts +0 -3
- package/dist/src/env.js +0 -37
- package/dist/src/eval.d.ts +0 -2
- package/dist/src/eval.js +0 -43
- package/dist/src/fn.d.ts +0 -2
- package/dist/src/fn.js +0 -70
- package/dist/src/group.d.ts +0 -2
- package/dist/src/group.js +0 -117
- package/dist/src/hl-run.d.ts +0 -119
- package/dist/src/hl-run.js +0 -480
- package/dist/src/hl.d.ts +0 -17
- package/dist/src/hl.js +0 -148
- package/dist/src/index.d.ts +0 -2
- package/dist/src/init.d.ts +0 -76
- package/dist/src/init.js +0 -278
- package/dist/src/join.d.ts +0 -11
- package/dist/src/join.js +0 -297
- package/dist/src/key-publish.d.ts +0 -40
- package/dist/src/key-publish.js +0 -232
- package/dist/src/key-seal.d.ts +0 -21
- package/dist/src/key-seal.js +0 -142
- package/dist/src/key-sweep.d.ts +0 -93
- package/dist/src/key-sweep.js +0 -270
- package/dist/src/key.d.ts +0 -26
- package/dist/src/key.js +0 -338
- package/dist/src/lib/age-plugin.d.ts +0 -51
- package/dist/src/lib/age-plugin.js +0 -130
- package/dist/src/lib/agent-env.d.ts +0 -12
- package/dist/src/lib/agent-env.js +0 -48
- package/dist/src/lib/api-path.d.ts +0 -2
- package/dist/src/lib/api-path.js +0 -40
- package/dist/src/lib/asker.d.ts +0 -34
- package/dist/src/lib/asker.js +0 -126
- package/dist/src/lib/check-words.d.ts +0 -57
- package/dist/src/lib/check-words.js +0 -144
- package/dist/src/lib/client.d.ts +0 -20
- package/dist/src/lib/client.js +0 -71
- package/dist/src/lib/env-sealed.d.ts +0 -53
- package/dist/src/lib/env-sealed.js +0 -184
- package/dist/src/lib/flow-tag.d.ts +0 -86
- package/dist/src/lib/flow-tag.js +0 -230
- package/dist/src/lib/hl-core/actions.d.ts +0 -99
- package/dist/src/lib/hl-core/actions.js +0 -69
- package/dist/src/lib/hl-core/eip712.d.ts +0 -33
- package/dist/src/lib/hl-core/eip712.js +0 -107
- package/dist/src/lib/hl-core/errors.d.ts +0 -10
- package/dist/src/lib/hl-core/errors.js +0 -15
- package/dist/src/lib/hl-core/exchange.d.ts +0 -24
- package/dist/src/lib/hl-core/exchange.js +0 -47
- package/dist/src/lib/hl-core/index.d.ts +0 -13
- package/dist/src/lib/hl-core/index.js +0 -14
- package/dist/src/lib/hl-core/meta.d.ts +0 -57
- package/dist/src/lib/hl-core/meta.js +0 -110
- package/dist/src/lib/hl-core/msgpack.d.ts +0 -18
- package/dist/src/lib/hl-core/msgpack.js +0 -136
- package/dist/src/lib/hl-core/net.d.ts +0 -2
- package/dist/src/lib/hl-core/net.js +0 -7
- package/dist/src/lib/hl-core/signing.d.ts +0 -103
- package/dist/src/lib/hl-core/signing.js +0 -295
- package/dist/src/lib/hl-core/wire.d.ts +0 -34
- package/dist/src/lib/hl-core/wire.js +0 -81
- package/dist/src/lib/invoked-as.d.ts +0 -2
- package/dist/src/lib/invoked-as.js +0 -24
- package/dist/src/lib/journey-words.d.ts +0 -84
- package/dist/src/lib/journey-words.js +0 -363
- package/dist/src/lib/journey.d.ts +0 -150
- package/dist/src/lib/journey.js +0 -264
- package/dist/src/lib/key-receipt.d.ts +0 -48
- package/dist/src/lib/key-receipt.js +0 -116
- package/dist/src/lib/key-source.d.ts +0 -9
- package/dist/src/lib/key-source.js +0 -33
- package/dist/src/lib/keyfile.d.ts +0 -136
- package/dist/src/lib/keyfile.js +0 -397
- package/dist/src/lib/launch-claude.d.ts +0 -5
- package/dist/src/lib/launch-claude.js +0 -45
- package/dist/src/lib/lock-lookup.d.ts +0 -40
- package/dist/src/lib/lock-lookup.js +0 -92
- package/dist/src/lib/message-seal.d.ts +0 -63
- package/dist/src/lib/message-seal.js +0 -150
- package/dist/src/lib/net-choice.d.ts +0 -28
- package/dist/src/lib/net-choice.js +0 -72
- package/dist/src/lib/network.d.ts +0 -22
- package/dist/src/lib/network.js +0 -50
- package/dist/src/lib/next-words.d.ts +0 -105
- package/dist/src/lib/next-words.js +0 -298
- package/dist/src/lib/paths.d.ts +0 -41
- package/dist/src/lib/paths.js +0 -91
- package/dist/src/lib/plan-draw.d.ts +0 -56
- package/dist/src/lib/plan-draw.js +0 -219
- package/dist/src/lib/plan-live.d.ts +0 -20
- package/dist/src/lib/plan-live.js +0 -192
- package/dist/src/lib/qr.d.ts +0 -21
- package/dist/src/lib/qr.js +0 -402
- package/dist/src/lib/roster.d.ts +0 -20
- package/dist/src/lib/roster.js +0 -79
- package/dist/src/lib/sale-card.d.ts +0 -117
- package/dist/src/lib/sale-card.js +0 -261
- package/dist/src/lib/shop-init.d.ts +0 -62
- package/dist/src/lib/shop-init.js +0 -63
- package/dist/src/lib/sui-grpc-send.d.ts +0 -90
- package/dist/src/lib/sui-grpc-send.js +0 -128
- package/dist/src/lib/swap-core.d.ts +0 -163
- package/dist/src/lib/swap-core.js +0 -405
- package/dist/src/lib/tasks-digest.d.ts +0 -66
- package/dist/src/lib/tasks-digest.js +0 -200
- package/dist/src/lib/tasks-graph.d.ts +0 -79
- package/dist/src/lib/tasks-graph.js +0 -463
- package/dist/src/lib/tasks-lens.d.ts +0 -31
- package/dist/src/lib/tasks-lens.js +0 -47
- package/dist/src/lib/tasks-next.d.ts +0 -25
- package/dist/src/lib/tasks-next.js +0 -103
- package/dist/src/lib/tasks-prove.d.ts +0 -15
- package/dist/src/lib/tasks-prove.js +0 -68
- package/dist/src/lib/tasks-route.d.ts +0 -29
- package/dist/src/lib/tasks-route.js +0 -151
- package/dist/src/lib/tasks-score.d.ts +0 -36
- package/dist/src/lib/tasks-score.js +0 -152
- package/dist/src/lib/tasks-workspace.d.ts +0 -18
- package/dist/src/lib/tasks-workspace.js +0 -73
- package/dist/src/lib/timed-fetch.d.ts +0 -33
- package/dist/src/lib/timed-fetch.js +0 -59
- package/dist/src/lib/vault-read.d.ts +0 -24
- package/dist/src/lib/vault-read.js +0 -77
- package/dist/src/lib/vaultfile.d.ts +0 -103
- package/dist/src/lib/vaultfile.js +0 -249
- package/dist/src/lib/wallet-money.d.ts +0 -222
- package/dist/src/lib/wallet-money.js +0 -578
- package/dist/src/lib/wallet-request.d.ts +0 -50
- package/dist/src/lib/wallet-request.js +0 -86
- package/dist/src/links.d.ts +0 -5
- package/dist/src/links.js +0 -45
- package/dist/src/media.d.ts +0 -29
- package/dist/src/media.js +0 -487
- package/dist/src/message-receipt.d.ts +0 -25
- package/dist/src/message-receipt.js +0 -71
- package/dist/src/message.d.ts +0 -13
- package/dist/src/message.js +0 -92
- package/dist/src/move.d.ts +0 -36
- package/dist/src/move.js +0 -152
- package/dist/src/network-cmd.d.ts +0 -17
- package/dist/src/network-cmd.js +0 -74
- package/dist/src/next.d.ts +0 -12
- package/dist/src/next.js +0 -67
- package/dist/src/onboard.d.ts +0 -16
- package/dist/src/onboard.js +0 -149
- package/dist/src/plugin.d.ts +0 -2
- package/dist/src/plugin.js +0 -193
- package/dist/src/push.d.ts +0 -2
- package/dist/src/push.js +0 -115
- package/dist/src/render.d.ts +0 -21
- package/dist/src/render.js +0 -32
- package/dist/src/secrets-device.d.ts +0 -32
- package/dist/src/secrets-device.js +0 -127
- package/dist/src/secrets-give.d.ts +0 -125
- package/dist/src/secrets-give.js +0 -236
- package/dist/src/secrets-list.d.ts +0 -27
- package/dist/src/secrets-list.js +0 -84
- package/dist/src/secrets-run.d.ts +0 -31
- package/dist/src/secrets-run.js +0 -182
- package/dist/src/secrets.d.ts +0 -33
- package/dist/src/secrets.js +0 -200
- package/dist/src/setup.d.ts +0 -6
- package/dist/src/setup.js +0 -127
- package/dist/src/ship.d.ts +0 -2
- package/dist/src/ship.js +0 -18
- package/dist/src/shop-buy.d.ts +0 -16
- package/dist/src/shop-buy.js +0 -101
- package/dist/src/shop.d.ts +0 -10
- package/dist/src/shop.js +0 -112
- package/dist/src/skill-parser.d.ts +0 -14
- package/dist/src/skill-parser.js +0 -113
- package/dist/src/skill.d.ts +0 -2
- package/dist/src/skill.js +0 -493
- package/dist/src/slug.d.ts +0 -2
- package/dist/src/slug.js +0 -6
- package/dist/src/social.d.ts +0 -2
- package/dist/src/social.js +0 -106
- package/dist/src/staff.d.ts +0 -2
- package/dist/src/staff.js +0 -104
- package/dist/src/start.d.ts +0 -27
- package/dist/src/start.js +0 -225
- package/dist/src/status.d.ts +0 -2
- package/dist/src/status.js +0 -52
- package/dist/src/substrate.d.ts +0 -2
- package/dist/src/substrate.js +0 -258
- package/dist/src/swap.d.ts +0 -93
- package/dist/src/swap.js +0 -622
- package/dist/src/tasks.d.ts +0 -2
- package/dist/src/tasks.js +0 -743
- package/dist/src/templates.d.ts +0 -1
- package/dist/src/templates.js +0 -213
- package/dist/src/thread.d.ts +0 -2
- package/dist/src/thread.js +0 -52
- package/dist/src/trade.d.ts +0 -2
- package/dist/src/trade.js +0 -91
- package/dist/src/trail.d.ts +0 -2
- package/dist/src/trail.js +0 -41
- package/dist/src/validate.d.ts +0 -13
- package/dist/src/validate.js +0 -35
- package/dist/src/wallet-money.d.ts +0 -158
- package/dist/src/wallet-money.js +0 -664
- package/dist/src/wallet.d.ts +0 -169
- package/dist/src/wallet.js +0 -973
- package/dist/src/workflow.d.ts +0 -2
- package/dist/src/workflow.js +0 -169
- package/dist/src/write.d.ts +0 -43
- package/dist/src/write.js +0 -180
package/dist/src/secrets-run.js
DELETED
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* secrets-run.ts — `one run -- <cmd…>` and `one secrets run -- <cmd…>`; `one secrets hash`.
|
|
3
|
-
* (text/secrets.md deliverable 2; text/secrets-todo.md § C2.)
|
|
4
|
-
*
|
|
5
|
-
* Opens `.env.sealed` once, hands the values to ONE child process through its environment,
|
|
6
|
-
* and writes nothing anywhere. The order is the point:
|
|
7
|
-
*
|
|
8
|
-
* 1. read the file's exact bytes, parse the header (no key yet)
|
|
9
|
-
* 2. sha256 of those bytes must equal the `sealed_hash` of the vault named by `# vault`
|
|
10
|
-
* — a file the vault does not know opens NOTHING (the key is not even loaded)
|
|
11
|
-
* 3. open every value with the owner's paper identity, in memory
|
|
12
|
-
* 4. spawn the child with `{ ...process.env, ...values }`, stdio inherited
|
|
13
|
-
* 5. zero the decrypted buffers; exit with the child's exit code
|
|
14
|
-
*
|
|
15
|
-
* There is no flag that skips step 2. `process.env` of this process is never changed, no
|
|
16
|
-
* value is printed, and an error names a variable or a line number, never a value or the key.
|
|
17
|
-
*/
|
|
18
|
-
import { spawn } from 'node:child_process';
|
|
19
|
-
import { createHash } from 'node:crypto';
|
|
20
|
-
import { readFileSync } from 'node:fs';
|
|
21
|
-
import { constants as osConstants } from 'node:os';
|
|
22
|
-
import { resolve } from 'node:path';
|
|
23
|
-
import { Command } from 'commander';
|
|
24
|
-
import { jsonMode } from './lib/client.js';
|
|
25
|
-
import { parseSealed } from './lib/env-sealed.js';
|
|
26
|
-
import { ageModule, loadSecretsKey, MAX_INPUT_BYTES } from './lib/message-seal.js';
|
|
27
|
-
import { readVault } from './lib/vault-read.js';
|
|
28
|
-
function fail(cmd, f, exit = 1) {
|
|
29
|
-
if (jsonMode(cmd))
|
|
30
|
-
process.stdout.write(JSON.stringify(f) + '\n');
|
|
31
|
-
else
|
|
32
|
-
process.stderr.write(`error ${f.error}\n`);
|
|
33
|
-
process.exitCode = exit;
|
|
34
|
-
}
|
|
35
|
-
const sha256 = (b) => createHash('sha256').update(b).digest('hex');
|
|
36
|
-
function readSealedBytes(file) {
|
|
37
|
-
try {
|
|
38
|
-
const b = readFileSync(resolve(file));
|
|
39
|
-
if (b.length > MAX_INPUT_BYTES)
|
|
40
|
-
return { ok: false, error: `${file} is more than ${MAX_INPUT_BYTES / (1024 * 1024)} MiB`, code: 'too_big' };
|
|
41
|
-
return b;
|
|
42
|
-
}
|
|
43
|
-
catch {
|
|
44
|
-
return { ok: false, error: `cannot read ${file}`, code: 'no_input' };
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Was `--` the word that ended this command's own flags? Commander strips the `--`, so look
|
|
49
|
-
* at the raw argv: between the command's name and the first `--` there may be only flags
|
|
50
|
-
* (and the values of --file / --key). Any other word there means `one run bun dev`, where
|
|
51
|
-
* `bun` would be taken for the command without the person ever saying where it starts.
|
|
52
|
-
*/
|
|
53
|
-
function dashDashStartsCommand(c) {
|
|
54
|
-
let root = c;
|
|
55
|
-
while (root.parent)
|
|
56
|
-
root = root.parent;
|
|
57
|
-
// commander sets rawArgs on the root; its typings do not declare it
|
|
58
|
-
const raw = (root.rawArgs ?? []).slice(2);
|
|
59
|
-
const at = raw.indexOf(c.name());
|
|
60
|
-
if (at < 0)
|
|
61
|
-
return false;
|
|
62
|
-
const rest = raw.slice(at + 1);
|
|
63
|
-
const end = rest.indexOf('--');
|
|
64
|
-
if (end < 0)
|
|
65
|
-
return false;
|
|
66
|
-
for (let i = 0; i < end; i++) {
|
|
67
|
-
const t = rest[i];
|
|
68
|
-
if (t === '--file' || t === '--key')
|
|
69
|
-
i++;
|
|
70
|
-
else if (!t.startsWith('-'))
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
|
-
return true;
|
|
74
|
-
}
|
|
75
|
-
export async function runAction(cmdArgs, o, c) {
|
|
76
|
-
if (cmdArgs.length === 0 || !dashDashStartsCommand(c)) {
|
|
77
|
-
return fail(c, { ok: false, error: 'usage: one run [--file .env.sealed] [--key <file>] -- <command> [args…] (the -- is required)', code: 'usage' }, 2);
|
|
78
|
-
}
|
|
79
|
-
const bytes = readSealedBytes(o.file);
|
|
80
|
-
if (!Buffer.isBuffer(bytes))
|
|
81
|
-
return fail(c, bytes);
|
|
82
|
-
const sealed = parseSealed(bytes.toString('utf8'));
|
|
83
|
-
if ('ok' in sealed)
|
|
84
|
-
return fail(c, sealed);
|
|
85
|
-
// The check comes first and has no way around it.
|
|
86
|
-
if (!sealed.vault) {
|
|
87
|
-
return fail(c, { ok: false, error: `${o.file} names no vault (# vault <id>) — there is nothing to check it against, so it is not run`, code: 'unknown_file' });
|
|
88
|
-
}
|
|
89
|
-
const vault = await readVault(sealed.vault);
|
|
90
|
-
if ('ok' in vault)
|
|
91
|
-
return fail(c, { ok: false, error: vault.error, code: 'cannot_verify' });
|
|
92
|
-
if (!vault.sealedHash) {
|
|
93
|
-
return fail(c, { ok: false, error: 'the vault has no sealed hash for this file — set one with: one secrets hash, then set_sealed_hash', code: 'unknown_file' });
|
|
94
|
-
}
|
|
95
|
-
if (vault.sealedHash.toLowerCase() !== sha256(bytes)) {
|
|
96
|
-
return fail(c, { ok: false, error: `${o.file} is not the file your vault knows — its hash differs, so nothing was opened`, code: 'unknown_file' });
|
|
97
|
-
}
|
|
98
|
-
const k = await loadSecretsKey(o.key);
|
|
99
|
-
if ('ok' in k)
|
|
100
|
-
return fail(c, k);
|
|
101
|
-
const opened = [];
|
|
102
|
-
try {
|
|
103
|
-
const age = await ageModule();
|
|
104
|
-
const dec = new TextDecoder();
|
|
105
|
-
const values = {};
|
|
106
|
-
for (const e of sealed.entries) {
|
|
107
|
-
let plain;
|
|
108
|
-
try {
|
|
109
|
-
plain = age.decrypt(e.file, [k.secret]);
|
|
110
|
-
}
|
|
111
|
-
catch {
|
|
112
|
-
return fail(c, { ok: false, error: `${e.name} does not open with this key`, code: 'no_identity' });
|
|
113
|
-
}
|
|
114
|
-
opened.push(plain);
|
|
115
|
-
values[e.name] = dec.decode(plain);
|
|
116
|
-
}
|
|
117
|
-
const [bin, ...args] = cmdArgs;
|
|
118
|
-
const code = await new Promise((done) => {
|
|
119
|
-
const child = spawn(bin, args, { stdio: 'inherit', env: { ...process.env, ...values } });
|
|
120
|
-
// spawn has copied the environment; nothing in this process needs a value any more.
|
|
121
|
-
for (const p of opened)
|
|
122
|
-
p.fill(0);
|
|
123
|
-
for (const n of Object.keys(values))
|
|
124
|
-
delete values[n];
|
|
125
|
-
const forward = (sig) => () => {
|
|
126
|
-
child.kill(sig);
|
|
127
|
-
};
|
|
128
|
-
const onInt = forward('SIGINT');
|
|
129
|
-
const onTerm = forward('SIGTERM');
|
|
130
|
-
process.on('SIGINT', onInt);
|
|
131
|
-
process.on('SIGTERM', onTerm);
|
|
132
|
-
const finish = (n) => {
|
|
133
|
-
process.off('SIGINT', onInt);
|
|
134
|
-
process.off('SIGTERM', onTerm);
|
|
135
|
-
done(n);
|
|
136
|
-
};
|
|
137
|
-
child.on('error', (err) => {
|
|
138
|
-
process.stderr.write(`error cannot start ${bin}: ${err.code ?? 'failed'}\n`);
|
|
139
|
-
finish(127);
|
|
140
|
-
});
|
|
141
|
-
child.on('exit', (status, signal) => finish(status ?? 128 + (signal ? (osConstants.signals[signal] ?? 0) : 0)));
|
|
142
|
-
});
|
|
143
|
-
process.exitCode = code;
|
|
144
|
-
}
|
|
145
|
-
finally {
|
|
146
|
-
for (const p of opened)
|
|
147
|
-
p.fill(0);
|
|
148
|
-
k.secret.fill(0);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
/** The `run` subcommand, fresh per call (a Command has one parent). */
|
|
152
|
-
export function buildRun() {
|
|
153
|
-
return new Command('run')
|
|
154
|
-
.description('Run a command with the sealed values in its environment only — nothing is written to disk')
|
|
155
|
-
.argument('[command...]', 'The command and its arguments, after --')
|
|
156
|
-
.option('--file <file>', 'The sealed file', '.env.sealed')
|
|
157
|
-
.option('--key <file>', 'Key file made by `one key new --out` (else ONE_WALLET_MNEMONIC). Never read from stdin')
|
|
158
|
-
.allowUnknownOption() // a stray flag must reach the usage check (exit 2), not commander's own error
|
|
159
|
-
.action((cmdArgs, o, c) => runAction(cmdArgs, o, c));
|
|
160
|
-
}
|
|
161
|
-
/** The top-level `one run`. */
|
|
162
|
-
export const runCmd = () => buildRun();
|
|
163
|
-
/** `one secrets hash [file]` — the sha256 an owner sets on their vault. Names no value, needs no key. */
|
|
164
|
-
export async function hashAction(file, _o, c) {
|
|
165
|
-
const bytes = readSealedBytes(file);
|
|
166
|
-
if (!Buffer.isBuffer(bytes))
|
|
167
|
-
return fail(c, bytes);
|
|
168
|
-
const sealed = parseSealed(bytes.toString('utf8'));
|
|
169
|
-
if ('ok' in sealed)
|
|
170
|
-
return fail(c, sealed);
|
|
171
|
-
const hash = sha256(bytes);
|
|
172
|
-
if (jsonMode(c))
|
|
173
|
-
process.stdout.write(JSON.stringify({ ok: true, file: resolve(file), sealedHash: hash }) + '\n');
|
|
174
|
-
else
|
|
175
|
-
process.stdout.write(hash + '\n');
|
|
176
|
-
}
|
|
177
|
-
export function buildHash() {
|
|
178
|
-
return new Command('hash')
|
|
179
|
-
.description("Print the sha256 of a sealed file — the value to set on your vault with set_sealed_hash")
|
|
180
|
-
.argument('[file]', 'The sealed file', '.env.sealed')
|
|
181
|
-
.action(hashAction);
|
|
182
|
-
}
|
package/dist/src/secrets.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* secrets.ts — `one secrets seal | run | add-device | give | list`: the sealed .env.
|
|
3
|
-
* (text/secrets.md deliverables 1 and 5; text/secrets-todo.md § C1.)
|
|
4
|
-
*
|
|
5
|
-
* `seal` is the one verb built here. It turns a plaintext .env into `.env.sealed` v1 —
|
|
6
|
-
* names readable, one age file per value — and the readers of every value are ONLY the
|
|
7
|
-
* owner's: the paper lock (the 24 words, HKDF `secrets-x25519-v1`) and the device locks
|
|
8
|
-
* the owner listed in ~/.one/secrets-readers.json (`add-device`, C3, writes it). A lock
|
|
9
|
-
* that is in neither is refused `not_your_reader`: no other person and no agent ever
|
|
10
|
-
* holds a key.
|
|
11
|
-
*
|
|
12
|
-
* Like key-seal.ts it is offline, never prompts, answers `--json`, and exits 0 done /
|
|
13
|
-
* 1 refused. It never prints a value, a line of the .env, or the key words; an error
|
|
14
|
-
* names a variable or a line number. The key is a key file (`--key`) or
|
|
15
|
-
* ONE_WALLET_MNEMONIC — never stdin.
|
|
16
|
-
*
|
|
17
|
-
* `run` and `hash` live in secrets-run.ts (C2). `add-device` (secrets-device.ts, C3) makes this
|
|
18
|
-
* Mac a reader; a Secure Enclave lock among the readers seals through the `age` program
|
|
19
|
-
* (lib/age-plugin.ts). `give` (secrets-give.ts, C8) hands a key to ONE, sealed to the lock ONE's
|
|
20
|
-
* vault names and signed by an agent's own key. `list` (secrets-list.ts, C15) reads the desk —
|
|
21
|
-
* secrets:list, names and meters, never values.
|
|
22
|
-
*/
|
|
23
|
-
import { Command } from 'commander';
|
|
24
|
-
import { type Fail } from './lib/message-seal.js';
|
|
25
|
-
export declare function fail(cmd: Command, f: Fail): void;
|
|
26
|
-
/** The owner's device-lock list. ONE_SECRETS_READERS moves it (tests); `add-device` (C3) writes it. */
|
|
27
|
-
export declare function readersFile(): string;
|
|
28
|
-
/**
|
|
29
|
-
* The owner's device locks: a JSON array of locks, or `{ "readers": [...] }`, each entry a
|
|
30
|
-
* lock string or `{ "lock": "…" }`. No file is no devices — the paper lock is then the only reader.
|
|
31
|
-
*/
|
|
32
|
-
export declare function deviceLocks(path?: string): string[] | Fail;
|
|
33
|
-
export declare function secretsCmd(): Command;
|
package/dist/src/secrets.js
DELETED
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* secrets.ts — `one secrets seal | run | add-device | give | list`: the sealed .env.
|
|
3
|
-
* (text/secrets.md deliverables 1 and 5; text/secrets-todo.md § C1.)
|
|
4
|
-
*
|
|
5
|
-
* `seal` is the one verb built here. It turns a plaintext .env into `.env.sealed` v1 —
|
|
6
|
-
* names readable, one age file per value — and the readers of every value are ONLY the
|
|
7
|
-
* owner's: the paper lock (the 24 words, HKDF `secrets-x25519-v1`) and the device locks
|
|
8
|
-
* the owner listed in ~/.one/secrets-readers.json (`add-device`, C3, writes it). A lock
|
|
9
|
-
* that is in neither is refused `not_your_reader`: no other person and no agent ever
|
|
10
|
-
* holds a key.
|
|
11
|
-
*
|
|
12
|
-
* Like key-seal.ts it is offline, never prompts, answers `--json`, and exits 0 done /
|
|
13
|
-
* 1 refused. It never prints a value, a line of the .env, or the key words; an error
|
|
14
|
-
* names a variable or a line number. The key is a key file (`--key`) or
|
|
15
|
-
* ONE_WALLET_MNEMONIC — never stdin.
|
|
16
|
-
*
|
|
17
|
-
* `run` and `hash` live in secrets-run.ts (C2). `add-device` (secrets-device.ts, C3) makes this
|
|
18
|
-
* Mac a reader; a Secure Enclave lock among the readers seals through the `age` program
|
|
19
|
-
* (lib/age-plugin.ts). `give` (secrets-give.ts, C8) hands a key to ONE, sealed to the lock ONE's
|
|
20
|
-
* vault names and signed by an agent's own key. `list` (secrets-list.ts, C15) reads the desk —
|
|
21
|
-
* secrets:list, names and meters, never values.
|
|
22
|
-
*/
|
|
23
|
-
import { existsSync, readFileSync, renameSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
24
|
-
import { homedir } from 'node:os';
|
|
25
|
-
import { join, resolve } from 'node:path';
|
|
26
|
-
import { Command } from 'commander';
|
|
27
|
-
import { jsonMode } from './lib/client.js';
|
|
28
|
-
import { isVaultId, parseEnv, parseSealed, renderSealed, sealEntries, verifySealed } from './lib/env-sealed.js';
|
|
29
|
-
import { ageModule, loadSecretsKey, MAX_INPUT_BYTES } from './lib/message-seal.js';
|
|
30
|
-
import { AgePluginError, isPluginLock, PLUGIN_LOCK_RE, requireAge } from './lib/age-plugin.js';
|
|
31
|
-
import { addDeviceAction } from './secrets-device.js';
|
|
32
|
-
import { buildGive } from './secrets-give.js';
|
|
33
|
-
import { buildList } from './secrets-list.js';
|
|
34
|
-
import { buildHash, buildRun } from './secrets-run.js';
|
|
35
|
-
export function fail(cmd, f) {
|
|
36
|
-
if (jsonMode(cmd))
|
|
37
|
-
process.stdout.write(JSON.stringify(f) + '\n');
|
|
38
|
-
else
|
|
39
|
-
process.stderr.write(`error ${f.error}\n`);
|
|
40
|
-
process.exitCode = 1;
|
|
41
|
-
}
|
|
42
|
-
const collect = (v, prev = []) => [...prev, v];
|
|
43
|
-
/** The owner's device-lock list. ONE_SECRETS_READERS moves it (tests); `add-device` (C3) writes it. */
|
|
44
|
-
export function readersFile() {
|
|
45
|
-
return process.env.ONE_SECRETS_READERS?.trim() || join(homedir(), '.one', 'secrets-readers.json');
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* The owner's device locks: a JSON array of locks, or `{ "readers": [...] }`, each entry a
|
|
49
|
-
* lock string or `{ "lock": "…" }`. No file is no devices — the paper lock is then the only reader.
|
|
50
|
-
*/
|
|
51
|
-
export function deviceLocks(path = readersFile()) {
|
|
52
|
-
if (!existsSync(path))
|
|
53
|
-
return [];
|
|
54
|
-
const badFile = () => ({ ok: false, error: `${path} is not a list of age1… locks`, code: 'bad_readers_file' });
|
|
55
|
-
let parsed;
|
|
56
|
-
try {
|
|
57
|
-
parsed = JSON.parse(readFileSync(path, 'utf8'));
|
|
58
|
-
}
|
|
59
|
-
catch {
|
|
60
|
-
return badFile();
|
|
61
|
-
}
|
|
62
|
-
const list = Array.isArray(parsed) ? parsed : parsed?.readers;
|
|
63
|
-
if (!Array.isArray(list))
|
|
64
|
-
return badFile();
|
|
65
|
-
const locks = [];
|
|
66
|
-
for (const e of list) {
|
|
67
|
-
const l = typeof e === 'string' ? e : e?.lock;
|
|
68
|
-
if (typeof l !== 'string' || !l.trim())
|
|
69
|
-
return badFile();
|
|
70
|
-
locks.push(l.trim());
|
|
71
|
-
}
|
|
72
|
-
return locks;
|
|
73
|
-
}
|
|
74
|
-
async function sealAction(file, o, c) {
|
|
75
|
-
const envPath = resolve(file);
|
|
76
|
-
const outPath = resolve(o.out ?? `${file}.sealed`);
|
|
77
|
-
if (outPath === envPath)
|
|
78
|
-
return fail(c, { ok: false, error: 'the sealed file cannot be the .env itself — pass a different --out', code: 'bad_out' });
|
|
79
|
-
if (o.vault !== undefined && !isVaultId(o.vault))
|
|
80
|
-
return fail(c, { ok: false, error: 'that is not a vault id', code: 'bad_vault' });
|
|
81
|
-
let raw;
|
|
82
|
-
try {
|
|
83
|
-
const b = readFileSync(envPath);
|
|
84
|
-
if (b.length > MAX_INPUT_BYTES)
|
|
85
|
-
return fail(c, { ok: false, error: `${file} is more than ${MAX_INPUT_BYTES / (1024 * 1024)} MiB — too big to seal here`, code: 'too_big' });
|
|
86
|
-
raw = b.toString('utf8');
|
|
87
|
-
}
|
|
88
|
-
catch {
|
|
89
|
-
return fail(c, { ok: false, error: `cannot read ${file}`, code: 'no_input' });
|
|
90
|
-
}
|
|
91
|
-
const k = await loadSecretsKey(o.key);
|
|
92
|
-
if ('ok' in k)
|
|
93
|
-
return fail(c, k);
|
|
94
|
-
try {
|
|
95
|
-
// The readers: the paper lock, the owner's device locks, nobody else.
|
|
96
|
-
const devices = deviceLocks();
|
|
97
|
-
if (!Array.isArray(devices))
|
|
98
|
-
return fail(c, devices);
|
|
99
|
-
const owners = new Set([k.recipient, ...devices]);
|
|
100
|
-
for (const l of o.reader ?? []) {
|
|
101
|
-
if (!owners.has(l.trim())) {
|
|
102
|
-
return fail(c, { ok: false, error: `${l.trim()} is not your lock — a secret is readable only by your paper and your own devices (add one with: one secrets add-device)`, code: 'not_your_reader' });
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
const readers = [...owners];
|
|
106
|
-
const age = await ageModule();
|
|
107
|
-
for (const l of readers) {
|
|
108
|
-
if (isPluginLock(l)) {
|
|
109
|
-
// A Secure Enclave lock is sealed through the `age` program. A missing program is a refusal, never a dropped device.
|
|
110
|
-
if (!PLUGIN_LOCK_RE.test(l))
|
|
111
|
-
return fail(c, { ok: false, error: `${l} is not an age lock — it starts age1…`, code: 'bad_key' });
|
|
112
|
-
const bins = requireAge();
|
|
113
|
-
if (typeof bins === 'string') {
|
|
114
|
-
return fail(c, { ok: false, error: bins === 'no_plugin' ? 'a Secure Enclave reader needs `age-plugin-se` — brew install age-plugin-se' : 'a Secure Enclave reader needs `age` — brew install age', code: bins });
|
|
115
|
-
}
|
|
116
|
-
continue;
|
|
117
|
-
}
|
|
118
|
-
try {
|
|
119
|
-
age.decodeRecipient(l);
|
|
120
|
-
}
|
|
121
|
-
catch {
|
|
122
|
-
return fail(c, { ok: false, error: `${l} is not an age lock — it starts age1…`, code: 'bad_key' });
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
const entries = parseEnv(raw);
|
|
126
|
-
if (!Array.isArray(entries))
|
|
127
|
-
return fail(c, entries);
|
|
128
|
-
if (entries.length === 0)
|
|
129
|
-
return fail(c, { ok: false, error: `${file} has no NAME=value lines to seal`, code: 'empty_env' });
|
|
130
|
-
const text = renderSealed({ readers, vault: o.vault, entries: await sealEntries(entries, readers) });
|
|
131
|
-
// Write beside the target, open every value back from the bytes on disk, and only then
|
|
132
|
-
// put it in place. The temp file holds sealed bytes only.
|
|
133
|
-
const tmp = `${outPath}.tmp-${process.pid}`;
|
|
134
|
-
writeFileSync(tmp, text, { mode: 0o644 });
|
|
135
|
-
try {
|
|
136
|
-
const back = parseSealed(readFileSync(tmp, 'utf8'));
|
|
137
|
-
if ('ok' in back)
|
|
138
|
-
return fail(c, { ...back, code: 'readback_failed' });
|
|
139
|
-
const bad = await verifySealed(back, entries, k.secret);
|
|
140
|
-
if (bad)
|
|
141
|
-
return fail(c, bad);
|
|
142
|
-
renameSync(tmp, outPath);
|
|
143
|
-
}
|
|
144
|
-
finally {
|
|
145
|
-
if (existsSync(tmp))
|
|
146
|
-
unlinkSync(tmp);
|
|
147
|
-
}
|
|
148
|
-
if (o.remove)
|
|
149
|
-
unlinkSync(envPath);
|
|
150
|
-
const names = entries.map((e) => e.name);
|
|
151
|
-
if (jsonMode(c))
|
|
152
|
-
process.stdout.write(JSON.stringify({ ok: true, file: outPath, names, readers: readers.length, removed: Boolean(o.remove) }) + '\n');
|
|
153
|
-
else {
|
|
154
|
-
process.stdout.write(`sealed ${names.length} value${names.length === 1 ? '' : 's'} → ${outPath} (${readers.length} reader${readers.length === 1 ? '' : 's'})\n`);
|
|
155
|
-
if (o.remove)
|
|
156
|
-
process.stdout.write(`removed ${file}\n`);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
catch (e) {
|
|
160
|
-
// Never `e.message` of a failure that may sit next to a value; the cause is one of a few I/O errors
|
|
161
|
-
// or an age-plugin failure, which carries a code and a fixed message.
|
|
162
|
-
if (e instanceof AgePluginError)
|
|
163
|
-
return fail(c, { ok: false, error: e.message, code: e.code });
|
|
164
|
-
fail(c, { ok: false, error: `could not seal ${file}: ${e.code ?? 'failed'}`, code: 'failed' });
|
|
165
|
-
}
|
|
166
|
-
finally {
|
|
167
|
-
k.secret.fill(0);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
const stub = (name, cycle, description) => new Command(name)
|
|
171
|
-
.description(`${description} (not built yet — ${cycle})`)
|
|
172
|
-
.allowUnknownOption()
|
|
173
|
-
.allowExcessArguments()
|
|
174
|
-
.action(() => {
|
|
175
|
-
process.stderr.write(`one secrets ${name}: not built yet (${cycle})\n`);
|
|
176
|
-
process.exitCode = 2;
|
|
177
|
-
});
|
|
178
|
-
export function secretsCmd() {
|
|
179
|
-
const seal = new Command('seal')
|
|
180
|
-
.description('Seal a .env to .env.sealed — names stay readable, every value is sealed to your paper and your own devices')
|
|
181
|
-
.argument('[file]', 'The .env to seal', '.env')
|
|
182
|
-
.option('--out <file>', 'Where to write the sealed file (default: <file>.sealed)')
|
|
183
|
-
.option('--reader <lock>', "Name a reader to include; it must be your paper lock or one in ~/.one/secrets-readers.json (repeat for several)", collect)
|
|
184
|
-
.option('--vault <id>', "Record the owner's vault id in the file header")
|
|
185
|
-
.option('--remove', 'Delete the .env once every value has been opened back from the sealed file and compared byte for byte')
|
|
186
|
-
.option('--key <file>', 'Key file made by `one key new --out` (else ONE_WALLET_MNEMONIC). Never read from stdin')
|
|
187
|
-
.action(sealAction);
|
|
188
|
-
return new Command('secrets')
|
|
189
|
-
.description('Seal a .env so it is safe to commit; only your paper and your own devices can open it')
|
|
190
|
-
.addCommand(seal)
|
|
191
|
-
.addCommand(buildHash())
|
|
192
|
-
.addCommand(buildRun())
|
|
193
|
-
.addCommand(new Command('add-device')
|
|
194
|
-
.description('Make this Mac a reader of your sealed files — a Secure Enclave key opened by Touch ID')
|
|
195
|
-
.option('--name <label>', 'A name for this Mac (default: its hostname)')
|
|
196
|
-
.option('--replace', 'Make a new key even though one exists (the old one stops being a reader)')
|
|
197
|
-
.action(addDeviceAction))
|
|
198
|
-
.addCommand(buildGive())
|
|
199
|
-
.addCommand(buildList());
|
|
200
|
-
}
|
package/dist/src/setup.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
/** No key in env — provision one via the same open call `init` uses, then
|
|
3
|
-
* reconcile the returned slug down into .env.local + workspace.toml. The
|
|
4
|
-
* route mints its own slug; it does not accept a desired one (contract #4). */
|
|
5
|
-
export declare function keylessSetup(dir: string, cfgPath: string | undefined, web: string): Promise<void>;
|
|
6
|
-
export declare function setupCmd(): Command;
|
package/dist/src/setup.js
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
3
|
-
import { mergeEnv, writeEnvLocal } from './env.js';
|
|
4
|
-
import { readAgency } from './config.js';
|
|
5
|
-
import { askPath } from './lib/api-path.js';
|
|
6
|
-
const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://api.one.ie';
|
|
7
|
-
const DEFAULT_WEB = process.env.ONEIE_BASE_URL ?? 'https://one.ie';
|
|
8
|
-
async function ask(base, key, receiver, data) {
|
|
9
|
-
const res = await fetch(askPath(base, receiver), {
|
|
10
|
-
method: 'POST',
|
|
11
|
-
headers: { 'Content-Type': 'application/json', ...(key ? { Authorization: `Bearer ${key}` } : {}) },
|
|
12
|
-
body: JSON.stringify({ data }),
|
|
13
|
-
});
|
|
14
|
-
if (!res.ok) {
|
|
15
|
-
const body = await res.text().catch(() => '');
|
|
16
|
-
throw new Error(`${receiver} → ${res.status}\n${body}`);
|
|
17
|
-
}
|
|
18
|
-
const json = await res.json();
|
|
19
|
-
if (json.outcome === 'failure') {
|
|
20
|
-
const result = (json.result ?? {});
|
|
21
|
-
const details = Object.entries(result)
|
|
22
|
-
.map(([k, v]) => `${k}=${typeof v === 'string' ? v : JSON.stringify(v)}`)
|
|
23
|
-
.join(' ');
|
|
24
|
-
throw new Error(`${receiver} → forbidden: ${details}`);
|
|
25
|
-
}
|
|
26
|
-
return json;
|
|
27
|
-
}
|
|
28
|
-
function findConfigPath(dir) {
|
|
29
|
-
for (const name of ['_node.toml', 'agency.toml', 'partner.toml', 'workspace.toml']) {
|
|
30
|
-
if (existsSync(`${dir}/${name}`))
|
|
31
|
-
return `${dir}/${name}`;
|
|
32
|
-
}
|
|
33
|
-
return undefined;
|
|
34
|
-
}
|
|
35
|
-
/** No key in env — provision one via the same open call `init` uses, then
|
|
36
|
-
* reconcile the returned slug down into .env.local + workspace.toml. The
|
|
37
|
-
* route mints its own slug; it does not accept a desired one (contract #4). */
|
|
38
|
-
export async function keylessSetup(dir, cfgPath, web) {
|
|
39
|
-
let name = 'my-workspace';
|
|
40
|
-
if (cfgPath) {
|
|
41
|
-
try {
|
|
42
|
-
name = readAgency(cfgPath).name;
|
|
43
|
-
}
|
|
44
|
-
catch {
|
|
45
|
-
// toml without slug/name (e.g. a bare workspace.toml) — fall through with the default
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
const ownerEmail = mergeEnv(dir).WORKSPACE_OWNER_EMAIL;
|
|
49
|
-
const body = { name };
|
|
50
|
-
if (ownerEmail)
|
|
51
|
-
body.invite = { email: ownerEmail, role: 'owner' };
|
|
52
|
-
const res = await fetch(`${web}/api/provision/agent`, {
|
|
53
|
-
method: 'POST',
|
|
54
|
-
headers: { 'Content-Type': 'application/json' },
|
|
55
|
-
body: JSON.stringify(body),
|
|
56
|
-
});
|
|
57
|
-
const json = (await res.json());
|
|
58
|
-
if (!res.ok) {
|
|
59
|
-
process.stderr.write(`provision/agent → ${res.status}\n${JSON.stringify(json)}\n`);
|
|
60
|
-
process.exit(1);
|
|
61
|
-
}
|
|
62
|
-
const { uid, workspace, apiKey } = json;
|
|
63
|
-
writeEnvLocal(dir, {
|
|
64
|
-
ONE_API_KEY: apiKey,
|
|
65
|
-
WORKSPACE_ID: workspace,
|
|
66
|
-
WORKSPACE_SLUG: workspace,
|
|
67
|
-
AGENCY_WSID: workspace,
|
|
68
|
-
AGENCY_SLUG: workspace,
|
|
69
|
-
CC_ACTOR_ID: uid,
|
|
70
|
-
});
|
|
71
|
-
let reconciled = '';
|
|
72
|
-
const targetToml = cfgPath ?? `${dir}/workspace.toml`;
|
|
73
|
-
if (existsSync(targetToml)) {
|
|
74
|
-
let toml = readFileSync(targetToml, 'utf8');
|
|
75
|
-
if (/^slug\s*=/m.test(toml)) {
|
|
76
|
-
toml = toml.replace(/^slug\s*=\s*"[^"]*"/m, `slug = "${workspace}"`);
|
|
77
|
-
writeFileSync(targetToml, toml);
|
|
78
|
-
reconciled = ` reconciled: ${targetToml} slug → ${workspace}\n`;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
process.stdout.write(`Workspace provisioned: ${workspace}\n`);
|
|
82
|
-
process.stdout.write(` key: ${apiKey.slice(0, 8)}… (written to .env.local)\n`);
|
|
83
|
-
process.stdout.write(reconciled);
|
|
84
|
-
}
|
|
85
|
-
export function setupCmd() {
|
|
86
|
-
return new Command('setup')
|
|
87
|
-
.description('Bootstrap a workspace (idempotent) — keyless: provisions with no prior account')
|
|
88
|
-
.option('--api <url>', 'API base URL', DEFAULT_API)
|
|
89
|
-
.option('--key <key>', 'API key (overrides ONEIE_API_KEY env)')
|
|
90
|
-
.action(async (opts) => {
|
|
91
|
-
const dir = process.cwd();
|
|
92
|
-
const env = mergeEnv(dir);
|
|
93
|
-
const key = opts.key ?? env.ONEIE_API_KEY ?? env.ONE_API_KEY ?? '';
|
|
94
|
-
if ((env.AGENCY_WSID && env.CC_ACTOR_ID) || env.ONE_API_KEY) {
|
|
95
|
-
process.stdout.write(`Workspace already set up (${env.AGENCY_WSID ?? env.WORKSPACE_SLUG}). No-op.\n`);
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
const cfgPath = findConfigPath(dir);
|
|
99
|
-
if (!key) {
|
|
100
|
-
await keylessSetup(dir, cfgPath, DEFAULT_WEB);
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
if (!cfgPath) {
|
|
104
|
-
process.stderr.write(`No _node.toml/agency.toml/partner.toml/workspace.toml found in ${dir}\n`);
|
|
105
|
-
process.exit(1);
|
|
106
|
-
}
|
|
107
|
-
const agency = readAgency(cfgPath);
|
|
108
|
-
const base = opts.api.replace(/\/$/, '');
|
|
109
|
-
const ws = await ask(base, key, 'world:create-workspace', {
|
|
110
|
-
name: agency.name,
|
|
111
|
-
slug: agency.slug,
|
|
112
|
-
plan: agency.plan,
|
|
113
|
-
markup: agency.markup_pct,
|
|
114
|
-
brand: agency.brand ?? false,
|
|
115
|
-
credit: agency.pool ?? 0,
|
|
116
|
-
});
|
|
117
|
-
const wsid = String(ws.wsid ?? agency.slug);
|
|
118
|
-
const actor = await ask(base, key, 'world:create-actor', {
|
|
119
|
-
name: 'claude-code',
|
|
120
|
-
type: 'claude-code',
|
|
121
|
-
group: wsid,
|
|
122
|
-
});
|
|
123
|
-
const aid = String(actor.aid ?? '');
|
|
124
|
-
writeEnvLocal(dir, { AGENCY_WSID: wsid, CC_ACTOR_ID: aid, AGENCY_SLUG: agency.slug });
|
|
125
|
-
process.stdout.write(`Agency: ${wsid} plan=${agency.plan} markup=${agency.markup_pct}% pool=${agency.pool ?? 0} cr\nClaude Code actor: ${aid}\n`);
|
|
126
|
-
});
|
|
127
|
-
}
|
package/dist/src/ship.d.ts
DELETED
package/dist/src/ship.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { spawnSync } from 'node:child_process';
|
|
3
|
-
export function shipCmd() {
|
|
4
|
-
return new Command('ship')
|
|
5
|
-
.description('git add -A, commit, and push (close the loop)')
|
|
6
|
-
.argument('[message]', 'Commit message', 'ship: update agency workspace')
|
|
7
|
-
.action((message) => {
|
|
8
|
-
const add = spawnSync('git', ['add', '-A'], { stdio: 'inherit' });
|
|
9
|
-
if (add.status !== 0)
|
|
10
|
-
process.exit(add.status ?? 1);
|
|
11
|
-
const commit = spawnSync('git', ['commit', '-m', message], { stdio: 'inherit' });
|
|
12
|
-
if (commit.status !== 0 && commit.status !== 1)
|
|
13
|
-
process.exit(commit.status ?? 1);
|
|
14
|
-
const push = spawnSync('git', ['push'], { stdio: 'inherit' });
|
|
15
|
-
if (push.status !== 0)
|
|
16
|
-
process.exit(push.status ?? 1);
|
|
17
|
-
});
|
|
18
|
-
}
|
package/dist/src/shop-buy.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* shop-buy.ts — `one shop buy <workspace> <ppid>`: an agent buys a store's product with USDC on Sui from its own
|
|
3
|
-
* vault, through the same route the checkout page uses (/api/storefront/crypto):
|
|
4
|
-
*
|
|
5
|
-
* 1. quote action:'quote' — the store's price, its Sui option, usdcEligible
|
|
6
|
-
* 2. escrow action:'escrow' — a deposit address for THIS sale and the exact USDC amount pay recorded
|
|
7
|
-
* 3. pay the vault in --dir sends exactly that USDC to the deposit address (suiSendGrpc, the one Sui signer)
|
|
8
|
-
* 4. status action:'status' — polled until pay sees the money (completed); forwardTxHash once the sweep moves it on
|
|
9
|
-
*
|
|
10
|
-
* No address or amount is ever typed: both come back from the route, which reads them server-side. Dry by default:
|
|
11
|
-
* without --live it quotes and stops — the escrow address is minted only by a live run, because minting one is a write.
|
|
12
|
-
*/
|
|
13
|
-
import { Command } from 'commander';
|
|
14
|
-
/** "1.000000" USDC → 1000000 base units (6 decimals); anything else → null. */
|
|
15
|
-
export declare function usdcUnits(v: unknown): bigint | null;
|
|
16
|
-
export declare function shopBuyCmd(): Command;
|