oneie 4.0.3 → 4.2.1
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 +80 -0
- package/dist/package.json +4 -4
- package/dist/src/agent.d.ts +73 -0
- package/dist/src/agent.js +486 -53
- package/dist/src/auth.js +3 -4
- package/dist/src/compiler.js +38 -5
- package/dist/src/doctor.js +61 -6
- package/dist/src/endpoint.d.ts +2 -0
- package/dist/src/endpoint.js +250 -0
- package/dist/src/eval.js +1 -0
- package/dist/src/fn.js +5 -8
- package/dist/src/index.js +8 -0
- package/dist/src/init.js +33 -3
- package/dist/src/lib/agent-env.js +7 -0
- package/dist/src/lib/client.js +16 -7
- package/dist/src/lib/keyfile.d.ts +130 -0
- package/dist/src/lib/keyfile.js +381 -0
- package/dist/src/lib/paths.d.ts +33 -0
- package/dist/src/lib/paths.js +77 -0
- package/dist/src/lib/shop-init.d.ts +62 -0
- package/dist/src/lib/shop-init.js +63 -0
- package/dist/src/lib/tasks-digest.d.ts +66 -0
- package/dist/src/lib/tasks-digest.js +200 -0
- package/dist/src/lib/tasks-graph.d.ts +78 -0
- package/dist/src/lib/tasks-graph.js +425 -0
- package/dist/src/lib/vaultfile.d.ts +73 -0
- package/dist/src/lib/vaultfile.js +184 -0
- package/dist/src/media.d.ts +2 -0
- package/dist/src/media.js +256 -0
- package/dist/src/plugin.js +10 -1
- package/dist/src/shop.d.ts +10 -0
- package/dist/src/shop.js +73 -0
- package/dist/src/skill.js +128 -12
- package/dist/src/tasks.d.ts +2 -0
- package/dist/src/tasks.js +424 -0
- package/dist/src/templates.js +8 -0
- package/dist/src/wallet.d.ts +9 -0
- package/dist/src/wallet.js +259 -1
- package/dist/src/workflow.js +54 -3
- package/package.json +4 -4
- package/dist/src/templates/_node/site/one.config.d.ts +0 -2
- package/dist/src/templates/_node/site/one.config.js +0 -22
package/dist/src/wallet.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { mergeEnv } from './env.js';
|
|
3
|
-
import { writeFileSync, chmodSync, readFileSync } from 'node:fs';
|
|
3
|
+
import { writeFileSync, chmodSync, readFileSync, existsSync, rmSync } from 'node:fs';
|
|
4
|
+
import { createInterface } from 'node:readline';
|
|
4
5
|
import { generateWallet, recoverWallet } from '@oneie/sdk/wallet';
|
|
6
|
+
import { sealVault, openVault, mintKeychainSecret } from '@oneie/sdk/vault-file';
|
|
5
7
|
import { askPath } from './lib/api-path.js';
|
|
8
|
+
import { writeVaultFolder, readVaultFolder, vaultPath, paperSheet, keychainStore, keychainRead, keychainAvailable, } from './lib/vaultfile.js';
|
|
6
9
|
const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://api.one.ie';
|
|
7
10
|
// Re-exported for existing callers/tests — canonical implementation now lives
|
|
8
11
|
// in ./lib/api-path.ts so trade.ts/client.ts/coordinate.ts/catalog.ts can share
|
|
@@ -147,6 +150,46 @@ export function walletCmd() {
|
|
|
147
150
|
});
|
|
148
151
|
out(cmd, okWrap(result));
|
|
149
152
|
});
|
|
153
|
+
cmd.command('register')
|
|
154
|
+
.description('Register a keygen output\'s PUBLIC receiving addresses with a workspace — reads addresses only, never a key or a mnemonic. First write wins per chain and is permanent')
|
|
155
|
+
.option('--from <file>', 'A `wallet keygen --out` file (or any JSON with `addresses` / `keys`) — only the address fields are read')
|
|
156
|
+
.option('--addresses <json>', 'Inline JSON address map, e.g. \'{"sui":"0x…","evm":"0x…"}\'')
|
|
157
|
+
.option('--workspace <slug>', 'Workspace (defaults to AGENCY_SLUG)')
|
|
158
|
+
.option('--actor <id>', 'Actor to register for (defaults to workspace)')
|
|
159
|
+
.option('--kind <kind>', 'human | agent', 'human')
|
|
160
|
+
.option('--yes', 'Skip the confirmation prompt (for scripted provisioning)')
|
|
161
|
+
.option('--api <url>', 'API base URL', DEFAULT_API)
|
|
162
|
+
.option('--key <key>', 'API key (overrides ONEIE_API_KEY env)')
|
|
163
|
+
.action(async (opts) => {
|
|
164
|
+
const { base, key } = resolveAuth(opts);
|
|
165
|
+
const workspace = resolveWorkspace(opts.workspace);
|
|
166
|
+
const source = opts.from
|
|
167
|
+
? JSON.parse(readFileSync(opts.from, 'utf8'))
|
|
168
|
+
: opts.addresses
|
|
169
|
+
? JSON.parse(opts.addresses)
|
|
170
|
+
: (() => { throw new Error('register needs --from <file> or --addresses <json>'); })();
|
|
171
|
+
const addresses = addressesOnly(source);
|
|
172
|
+
if (Object.keys(addresses).length === 0) {
|
|
173
|
+
throw new Error('no addresses found — expected an `addresses` map or a `keys` array of { chain, address }');
|
|
174
|
+
}
|
|
175
|
+
// mergeAddresses is FIRST-WRITE-WINS: a wrong address here is where every future
|
|
176
|
+
// payment lands, and the row refuses to change it afterwards (address_conflict).
|
|
177
|
+
// So the operator reads the exact strings back before anything is sent.
|
|
178
|
+
const actor = opts.actor ?? workspace;
|
|
179
|
+
process.stderr.write(`Registering PUBLIC receiving addresses for actor '${actor}' in workspace '${workspace}':\n`);
|
|
180
|
+
for (const [chain, addr] of Object.entries(addresses)) {
|
|
181
|
+
process.stderr.write(` ${chain.padEnd(7)} ${addr}\n`);
|
|
182
|
+
}
|
|
183
|
+
process.stderr.write('This is permanent — the first address written to a chain cannot be changed.\n');
|
|
184
|
+
if (!opts.yes && !(await confirm('Register these addresses? [y/N] '))) {
|
|
185
|
+
out(cmd, { ok: false, error: 'cancelled' });
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
// `actor`, not `opts.actor` — what the operator confirmed on screen is what gets
|
|
189
|
+
// written, rather than relying on the resolver's own default to agree.
|
|
190
|
+
const result = await ask(base, key, 'wallet:create', { workspace, actor, kind: opts.kind, addresses });
|
|
191
|
+
out(cmd, okWrap(result));
|
|
192
|
+
});
|
|
150
193
|
cmd.command('keygen')
|
|
151
194
|
.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')
|
|
152
195
|
.option('--recover', 'Recover from a 24-word BIP-39 mnemonic (ONE_WALLET_MNEMONIC env or stdin) instead of generating a fresh one')
|
|
@@ -164,8 +207,173 @@ export function walletCmd() {
|
|
|
164
207
|
out(cmd, { ok: true, mnemonic: wallet.mnemonic, addresses, keys: wallet.keys });
|
|
165
208
|
}
|
|
166
209
|
});
|
|
210
|
+
// ── the encrypted wallet folder ────────────────────────────────────────────
|
|
211
|
+
cmd.command('new')
|
|
212
|
+
.description('Create an encrypted wallet in this folder — 24 words sealed with a passphrase, four chains, fully offline')
|
|
213
|
+
.option('--dir <path>', 'Project directory', '.')
|
|
214
|
+
.option('--recover', 'Seal an EXISTING 24-word phrase instead of generating a new one (ONE_WALLET_MNEMONIC or stdin)')
|
|
215
|
+
.option('--keychain', 'Seal with a random secret stored in Apple Keychain, so Touch ID opens it instead of a passphrase')
|
|
216
|
+
.action(async (opts) => {
|
|
217
|
+
// Refuse BEFORE generating. Minting a wallet and then failing to store it
|
|
218
|
+
// is the one outcome that loses money: the words would exist only in a
|
|
219
|
+
// process about to exit.
|
|
220
|
+
if (existsSync(vaultPath(opts.dir))) {
|
|
221
|
+
out(cmd, { ok: false, error: `a wallet already exists at ${vaultPath(opts.dir)} — move it aside first` });
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
if (opts.keychain && !keychainAvailable()) {
|
|
225
|
+
out(cmd, { ok: false, error: 'Keychain is macOS-only — omit --keychain to seal with a passphrase' });
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
let passphrase;
|
|
229
|
+
let wrap;
|
|
230
|
+
if (opts.keychain) {
|
|
231
|
+
passphrase = mintKeychainSecret();
|
|
232
|
+
wrap = 'keychain';
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
passphrase = await promptSecret('Passphrase for this wallet: ');
|
|
236
|
+
const again = await promptSecret('Repeat it: ');
|
|
237
|
+
if (passphrase !== again) {
|
|
238
|
+
out(cmd, { ok: false, error: 'passphrases did not match — nothing was written' });
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
if (passphrase.length < 8) {
|
|
242
|
+
out(cmd, { ok: false, error: 'passphrase too short — this is the only thing between a stolen laptop and the wallet' });
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
wrap = 'passphrase';
|
|
246
|
+
}
|
|
247
|
+
const wallet = opts.recover ? await recoverWallet(readMnemonic()) : await generateWallet();
|
|
248
|
+
const addresses = Object.fromEntries(wallet.keys.map((k) => [k.chain, k.address]));
|
|
249
|
+
const authPub = wallet.keys.find((k) => k.chain === 'sui')?.publicKeyHex ?? '';
|
|
250
|
+
const blob = await sealVault(wallet.mnemonic, passphrase, { wrap, authPub });
|
|
251
|
+
const res = writeVaultFolder(opts.dir, { ...blob });
|
|
252
|
+
if (!res.ok) {
|
|
253
|
+
out(cmd, { ok: false, error: res.error });
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
if (opts.keychain) {
|
|
257
|
+
const k = keychainStore(authPub, passphrase);
|
|
258
|
+
if (!k.ok) {
|
|
259
|
+
// The vault is sealed with a secret nobody can now produce. Remove it
|
|
260
|
+
// rather than leaving an unopenable file that looks like a wallet.
|
|
261
|
+
rmSync(res.path, { force: true });
|
|
262
|
+
out(cmd, { ok: false, error: `Keychain write failed (${k.error}) — the wallet was removed rather than left unopenable` });
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
out(cmd, {
|
|
267
|
+
ok: true,
|
|
268
|
+
wallet: res.path,
|
|
269
|
+
wrap,
|
|
270
|
+
addresses,
|
|
271
|
+
next: 'one wallet paper # write the 24 words down — this is the ONLY backup',
|
|
272
|
+
});
|
|
273
|
+
});
|
|
274
|
+
cmd.command('open')
|
|
275
|
+
.description('Unlock the wallet in this folder and show its addresses — the phrase never leaves this machine')
|
|
276
|
+
.option('--dir <path>', 'Project directory', '.')
|
|
277
|
+
.action(async (opts) => {
|
|
278
|
+
const r = await unlock(opts.dir);
|
|
279
|
+
if ('error' in r) {
|
|
280
|
+
out(cmd, { ok: false, error: r.error });
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
out(cmd, { ok: true, wrap: r.blob.wrap, addresses: r.addresses });
|
|
284
|
+
});
|
|
285
|
+
cmd.command('paper')
|
|
286
|
+
.description('Print the recovery sheet — 24 numbered words plus the public addresses. Print it, then close the terminal')
|
|
287
|
+
.option('--dir <path>', 'Project directory', '.')
|
|
288
|
+
.action(async (opts) => {
|
|
289
|
+
const r = await unlock(opts.dir);
|
|
290
|
+
if ('error' in r) {
|
|
291
|
+
out(cmd, { ok: false, error: r.error });
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
// Straight to stdout, never through out(): a --json receipt carrying 24
|
|
295
|
+
// words would put the whole wallet into any pipeline or CI log that
|
|
296
|
+
// captured it.
|
|
297
|
+
process.stdout.write(paperSheet(r.mnemonic, r.addresses) + '\n');
|
|
298
|
+
});
|
|
299
|
+
cmd.command('keychain')
|
|
300
|
+
.description('Move this wallet behind Touch ID — stores its passphrase in Apple Keychain so biometrics open it')
|
|
301
|
+
.option('--dir <path>', 'Project directory', '.')
|
|
302
|
+
.action(async (opts) => {
|
|
303
|
+
if (!keychainAvailable()) {
|
|
304
|
+
out(cmd, { ok: false, error: 'Keychain is macOS-only' });
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
const blob = readVaultFolder(opts.dir);
|
|
308
|
+
if (!blob) {
|
|
309
|
+
out(cmd, { ok: false, error: `no wallet at ${vaultPath(opts.dir)}` });
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
if (blob.wrap === 'keychain') {
|
|
313
|
+
out(cmd, { ok: true, note: 'already opened by Keychain' });
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
const pass = await promptSecret('Current passphrase: ');
|
|
317
|
+
// Prove the passphrase before storing it — storing an unverified string
|
|
318
|
+
// would put a secret in Keychain that opens nothing.
|
|
319
|
+
try {
|
|
320
|
+
await openVault(blob, pass);
|
|
321
|
+
}
|
|
322
|
+
catch {
|
|
323
|
+
out(cmd, { ok: false, error: 'wrong passphrase — nothing was stored' });
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
const k = keychainStore(String(blob.authPub ?? ''), pass);
|
|
327
|
+
out(cmd, k.ok ? { ok: true, note: 'Touch ID now opens this wallet' } : { ok: false, error: k.error });
|
|
328
|
+
});
|
|
167
329
|
return cmd;
|
|
168
330
|
}
|
|
331
|
+
// Chain-name spellings a keygen output may use -> the four columns wallet:create
|
|
332
|
+
// declares. `eth`/`sol` are the SDK's WalletChain spellings; `evm`/`solana` are the
|
|
333
|
+
// server's.
|
|
334
|
+
const REGISTER_CHAINS = {
|
|
335
|
+
sui: 'sui', evm: 'evm', eth: 'evm', ethereum: 'evm',
|
|
336
|
+
sol: 'solana', solana: 'solana', btc: 'btc', bitcoin: 'btc',
|
|
337
|
+
};
|
|
338
|
+
/**
|
|
339
|
+
* Reduce ANY keygen-shaped object to public receiving addresses. This is a
|
|
340
|
+
* whitelist build, never a spread or a delete-list: the returned object is
|
|
341
|
+
* constructed field-by-field from four known chain keys whose values must be
|
|
342
|
+
* strings, so a `privateKey`, `secretKey`, `mnemonic` or any other field on the
|
|
343
|
+
* input has no route into the value this command transmits. The custody
|
|
344
|
+
* invariant here is structural, not a policy the caller has to remember.
|
|
345
|
+
*/
|
|
346
|
+
export function addressesOnly(source) {
|
|
347
|
+
const addresses = {};
|
|
348
|
+
const put = (rawChain, rawAddress) => {
|
|
349
|
+
const chain = REGISTER_CHAINS[String(rawChain).toLowerCase()];
|
|
350
|
+
if (!chain || typeof rawAddress !== 'string' || !rawAddress)
|
|
351
|
+
return;
|
|
352
|
+
addresses[chain] = rawAddress;
|
|
353
|
+
};
|
|
354
|
+
const src = (source && typeof source === 'object' ? source : {});
|
|
355
|
+
const nested = (src['addresses'] && typeof src['addresses'] === 'object' ? src['addresses'] : {});
|
|
356
|
+
for (const [chain, value] of Object.entries(src))
|
|
357
|
+
put(chain, value);
|
|
358
|
+
for (const [chain, value] of Object.entries(nested))
|
|
359
|
+
put(chain, value);
|
|
360
|
+
for (const k of (Array.isArray(src['keys']) ? src['keys'] : [])) {
|
|
361
|
+
put(k?.['chain'], k?.['address']);
|
|
362
|
+
}
|
|
363
|
+
return addresses;
|
|
364
|
+
}
|
|
365
|
+
// Ask the operator on the terminal. Used only for the permanent, first-write-wins
|
|
366
|
+
// address registration — every other verb is non-destructive.
|
|
367
|
+
async function confirm(prompt) {
|
|
368
|
+
const rl = createInterface({ input: process.stdin, output: process.stderr });
|
|
369
|
+
try {
|
|
370
|
+
const answer = await new Promise((resolve) => rl.question(prompt, resolve));
|
|
371
|
+
return /^y(es)?$/i.test(answer.trim());
|
|
372
|
+
}
|
|
373
|
+
finally {
|
|
374
|
+
rl.close();
|
|
375
|
+
}
|
|
376
|
+
}
|
|
169
377
|
// Read the recovery mnemonic for `keygen --recover`: ONE_WALLET_MNEMONIC env first
|
|
170
378
|
// (scriptable), else stdin (fd 0). Never a CLI arg — keeps the phrase out of the
|
|
171
379
|
// process table / shell history.
|
|
@@ -207,3 +415,53 @@ function out(cmd, data) {
|
|
|
207
415
|
console.error('✗', typeof detail === 'string' ? detail : JSON.stringify(detail));
|
|
208
416
|
}
|
|
209
417
|
}
|
|
418
|
+
/** Read a secret from the TTY with echo off. Never argv (world-readable in ps), never env. */
|
|
419
|
+
async function promptSecret(prompt) {
|
|
420
|
+
if (!process.stdin.isTTY)
|
|
421
|
+
throw new Error('a passphrase must be typed at a terminal — refusing to read one from a pipe');
|
|
422
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout, terminal: true });
|
|
423
|
+
const stdout = process.stdout;
|
|
424
|
+
const orig = stdout.write.bind(stdout);
|
|
425
|
+
process.stdout.write(prompt);
|
|
426
|
+
stdout.write = () => true;
|
|
427
|
+
try {
|
|
428
|
+
return await new Promise((resolve) => rl.question('', (a) => { resolve(a); }));
|
|
429
|
+
}
|
|
430
|
+
finally {
|
|
431
|
+
;
|
|
432
|
+
stdout.write = orig;
|
|
433
|
+
rl.close();
|
|
434
|
+
orig('\n');
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Open the folder's vault, asking Keychain or the human depending on how it was
|
|
439
|
+
* SEALED. `wrap` is what makes this possible: without it a keychain vault is
|
|
440
|
+
* indistinguishable from a passphrase one and the only way to find out is to
|
|
441
|
+
* prompt for a passphrase that was never set.
|
|
442
|
+
*/
|
|
443
|
+
async function unlock(dir) {
|
|
444
|
+
const raw = readVaultFolder(dir);
|
|
445
|
+
if (!raw)
|
|
446
|
+
return { error: `no wallet at ${vaultPath(dir)} — run \`one wallet new\`` };
|
|
447
|
+
const blob = raw;
|
|
448
|
+
let passphrase;
|
|
449
|
+
if (blob.wrap === 'keychain') {
|
|
450
|
+
const k = keychainRead(String(blob.authPub ?? ''));
|
|
451
|
+
if (!k.ok || !k.value)
|
|
452
|
+
return { error: k.ok ? 'Keychain returned nothing' : k.error };
|
|
453
|
+
passphrase = k.value;
|
|
454
|
+
}
|
|
455
|
+
else {
|
|
456
|
+
passphrase = await promptSecret('Passphrase: ');
|
|
457
|
+
}
|
|
458
|
+
let mnemonic;
|
|
459
|
+
try {
|
|
460
|
+
mnemonic = await openVault(blob, passphrase);
|
|
461
|
+
}
|
|
462
|
+
catch (e) {
|
|
463
|
+
return { error: e.message };
|
|
464
|
+
}
|
|
465
|
+
const wallet = await recoverWallet(mnemonic);
|
|
466
|
+
return { blob, mnemonic, addresses: Object.fromEntries(wallet.keys.map((k) => [k.chain, k.address])) };
|
|
467
|
+
}
|
package/dist/src/workflow.js
CHANGED
|
@@ -6,6 +6,9 @@ import { askPath } from './lib/api-path.js';
|
|
|
6
6
|
const DEFAULT_API = 'https://api.one.ie';
|
|
7
7
|
const KEY_FILE = resolve(homedir(), '.config', 'oneie', 'key');
|
|
8
8
|
function readApiKey() {
|
|
9
|
+
// ONE_API_KEY is canonical, ONEIE_API_KEY legacy — same order lib/client.ts uses.
|
|
10
|
+
if (process.env.ONE_API_KEY)
|
|
11
|
+
return process.env.ONE_API_KEY;
|
|
9
12
|
if (process.env.ONEIE_API_KEY)
|
|
10
13
|
return process.env.ONEIE_API_KEY;
|
|
11
14
|
if (existsSync(KEY_FILE))
|
|
@@ -22,14 +25,30 @@ export function workflowCmd() {
|
|
|
22
25
|
const key = readApiKey();
|
|
23
26
|
if (!key)
|
|
24
27
|
return { ok: false, error: 'no API key — run `oneie auth login --key <key>` or set ONEIE_API_KEY' };
|
|
25
|
-
const url =
|
|
28
|
+
const url = askPath(api.replace(/\/$/, ''), receiver);
|
|
26
29
|
const res = await fetch(url, {
|
|
27
30
|
method: 'POST',
|
|
28
|
-
|
|
31
|
+
// Bearer <key> — NOT `<slug>:<key>`. The world key carries its own ownerSlug;
|
|
32
|
+
// prefixing the slug made the gateway read the whole string as an unknown key
|
|
33
|
+
// and every workflow subcommand 403'd with "authentication required".
|
|
34
|
+
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${key}` },
|
|
29
35
|
body: JSON.stringify({ data }),
|
|
30
36
|
});
|
|
31
37
|
const text = await res.text();
|
|
32
|
-
|
|
38
|
+
if (!text)
|
|
39
|
+
return {};
|
|
40
|
+
const body = JSON.parse(text);
|
|
41
|
+
// The ask door answers with an ENVELOPE — { outcome, result, signalId }. Every
|
|
42
|
+
// subcommand below reads the receiver's own fields (r.id, r.ok, r.runId), so
|
|
43
|
+
// unwrap here. Reading them off the envelope made `pull` report not_found for
|
|
44
|
+
// a workflow that exists, and `push` report ok=false on a successful apply.
|
|
45
|
+
if (body && typeof body === 'object' && 'outcome' in body) {
|
|
46
|
+
const inner = (body.result ?? {});
|
|
47
|
+
if (body.outcome === 'failure')
|
|
48
|
+
return { error: inner.error ?? 'failure', ...inner };
|
|
49
|
+
return { ...inner, ...(body.simulated ? { simulated: true } : {}) };
|
|
50
|
+
}
|
|
51
|
+
return body;
|
|
33
52
|
};
|
|
34
53
|
cmd.command('list')
|
|
35
54
|
.description('List workflows in a workspace')
|
|
@@ -78,6 +97,38 @@ export function workflowCmd() {
|
|
|
78
97
|
const r = await call(opts.api, opts.slug, 'workflow:run', { workflowId: id });
|
|
79
98
|
out(cmd, { ok: !!r.runId, ...r });
|
|
80
99
|
});
|
|
100
|
+
cmd.command('validate <id> <file>')
|
|
101
|
+
.description('Validate a diff-JSON file against a workflow (§9 gate, never persists)')
|
|
102
|
+
.requiredOption('--slug <slug>', 'Workspace slug')
|
|
103
|
+
.option('--api <url>', 'API base URL', DEFAULT_API)
|
|
104
|
+
.action(async (id, file, opts) => {
|
|
105
|
+
if (!existsSync(file)) {
|
|
106
|
+
out(cmd, { ok: false, error: `not found: ${file}` });
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const diff = JSON.parse(readFileSync(file, 'utf8'));
|
|
110
|
+
const r = await call(opts.api, opts.slug, 'workflow:validate', { workflowId: id, diff });
|
|
111
|
+
out(cmd, { ok: !!r.ok, ...r });
|
|
112
|
+
});
|
|
113
|
+
cmd.command('resolve <runId> <stepId>')
|
|
114
|
+
.description('Resolve a suspended human step in a run (--decision approved|rejected)')
|
|
115
|
+
.requiredOption('--slug <slug>', 'Workspace slug')
|
|
116
|
+
.option('--decision <d>', 'approved | rejected')
|
|
117
|
+
.option('--api <url>', 'API base URL', DEFAULT_API)
|
|
118
|
+
.action(async (runId, stepId, opts) => {
|
|
119
|
+
const r = await call(opts.api, opts.slug, 'human:resolve', { runId, stepId, ...(opts.decision ? { decision: opts.decision } : {}) });
|
|
120
|
+
out(cmd, { ok: !!r.ok, ...r });
|
|
121
|
+
});
|
|
122
|
+
cmd.command('logs <id>')
|
|
123
|
+
.description("List recent runs of a workflow; --run <runId> for one run's step-event timeline")
|
|
124
|
+
.requiredOption('--slug <slug>', 'Workspace slug')
|
|
125
|
+
.option('--run <runId>', "Return this run's event timeline")
|
|
126
|
+
.option('--limit <n>', 'Max runs to list', (v) => parseInt(v, 10))
|
|
127
|
+
.option('--api <url>', 'API base URL', DEFAULT_API)
|
|
128
|
+
.action(async (id, opts) => {
|
|
129
|
+
const r = await call(opts.api, opts.slug, 'workflow:runs', { workflowId: id, ...(opts.run ? { runId: opts.run } : {}), ...(opts.limit ? { limit: opts.limit } : {}) });
|
|
130
|
+
out(cmd, { ok: !r.error, ...r });
|
|
131
|
+
});
|
|
81
132
|
return cmd;
|
|
82
133
|
}
|
|
83
134
|
// out() mirrors agent.ts — human `✓ k=v` or --json. W3: reuse the shared helper if
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oneie",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.1",
|
|
4
4
|
"description": "ONE agent CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -15,15 +15,15 @@
|
|
|
15
15
|
"build": "tsc && cp package.json dist/ && chmod +x dist/src/index.js",
|
|
16
16
|
"dev": "tsx src/index.ts",
|
|
17
17
|
"typecheck": "tsc --noEmit",
|
|
18
|
-
"test": "vitest run",
|
|
18
|
+
"test": "bash ../../.claude/scripts/gate-run.sh test-cli -- vitest run",
|
|
19
19
|
"prepublishOnly": "bun run build"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"commander": "^12.0.0",
|
|
23
|
-
"@oneie/sdk": "^0.
|
|
23
|
+
"@oneie/sdk": "^0.16.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@oneie/evals": "
|
|
26
|
+
"@oneie/evals": "^0.2.0",
|
|
27
27
|
"@types/node": "^25.6.0",
|
|
28
28
|
"tsx": "^4.0.0",
|
|
29
29
|
"typescript": "^5.4.0",
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// @ts-nocheck — template file; typechecked in the target Astro project, not the CLI
|
|
2
|
-
// Install: bun add @oneie/frontend
|
|
3
|
-
// After setup: copy ONE_API_KEY from .env.local into backend.apiKey
|
|
4
|
-
import { defineOne } from '@oneie/frontend';
|
|
5
|
-
// The only per-node configuration:
|
|
6
|
-
// - backend.apiKey: your workspace's scoped API key (from one setup)
|
|
7
|
-
// - brand.tokens: 6 color tokens to match your brand
|
|
8
|
-
export default defineOne({
|
|
9
|
-
backend: {
|
|
10
|
-
apiKey: process.env.ONE_API_KEY ?? '',
|
|
11
|
-
},
|
|
12
|
-
brand: {
|
|
13
|
-
tokens: {
|
|
14
|
-
primary: 'hsl(216 55% 25%)', // your brand primary
|
|
15
|
-
secondary: 'hsl(160 40% 45%)', // secondary / accent
|
|
16
|
-
tertiary: 'hsl(38 90% 55%)', // highlight / CTA
|
|
17
|
-
background: 'hsl(0 0% 100%)', // page background
|
|
18
|
-
foreground: 'hsl(220 20% 15%)', // body text
|
|
19
|
-
font: 'Inter, system-ui, sans-serif',
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
});
|