@oneie/cli 0.10.0 → 0.10.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/dist/package.json +2 -2
- package/dist/src/catalog.js +2 -1
- package/dist/src/client.js +2 -1
- package/dist/src/coordinate.js +2 -1
- package/dist/src/lib/api-path.d.ts +1 -0
- package/dist/src/lib/api-path.js +9 -0
- package/dist/src/render.d.ts +1 -0
- package/dist/src/render.js +1 -1
- package/dist/src/setup.js +10 -2
- package/dist/src/status.js +13 -5
- package/dist/src/trade.js +2 -1
- package/dist/src/wallet.d.ts +3 -1
- package/dist/src/wallet.js +48 -9
- package/package.json +3 -3
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oneie/cli",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.1",
|
|
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": "
|
|
23
|
+
"@oneie/sdk": "workspace:*"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@oneie/evals": "workspace:*",
|
package/dist/src/catalog.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { askPath } from './lib/api-path.js';
|
|
1
2
|
const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://api.one.ie';
|
|
2
3
|
function apiKey() {
|
|
3
4
|
return process.env.ONEIE_API_KEY ?? process.env.ONE_API_KEY ?? '';
|
|
@@ -57,7 +58,7 @@ export function catalogCommands(program) {
|
|
|
57
58
|
.option('--api <url>', 'API base URL', DEFAULT_API)
|
|
58
59
|
.option('--json', 'Output raw JSON')
|
|
59
60
|
.action(async (opts) => {
|
|
60
|
-
const res = await fetch(
|
|
61
|
+
const res = await fetch(askPath(base(opts), 'meta:catalog'), {
|
|
61
62
|
method: 'POST',
|
|
62
63
|
headers: authHeaders(),
|
|
63
64
|
body: JSON.stringify({ data: opts.goal ? { goal: opts.goal } : {} }),
|
package/dist/src/client.js
CHANGED
|
@@ -3,9 +3,10 @@ import { mergeEnv } from './env.js';
|
|
|
3
3
|
import { readClient } from './config.js';
|
|
4
4
|
import { validateClient } from './validate.js';
|
|
5
5
|
import { safeSlug } from './slug.js';
|
|
6
|
+
import { askPath } from './lib/api-path.js';
|
|
6
7
|
const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://api.one.ie';
|
|
7
8
|
async function ask(base, key, receiver, data) {
|
|
8
|
-
const res = await fetch(
|
|
9
|
+
const res = await fetch(askPath(base, receiver), {
|
|
9
10
|
method: 'POST',
|
|
10
11
|
headers: { 'Content-Type': 'application/json', ...(key ? { Authorization: `Bearer ${key}` } : {}) },
|
|
11
12
|
body: JSON.stringify({ data }),
|
package/dist/src/coordinate.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { askPath } from './lib/api-path.js';
|
|
1
2
|
const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://api.one.ie';
|
|
2
3
|
function apiKey() {
|
|
3
4
|
return process.env.ONEIE_API_KEY ?? process.env.ONE_API_KEY ?? '';
|
|
@@ -32,7 +33,7 @@ export function coordinateCommands(program) {
|
|
|
32
33
|
const payload = { limit: Number(opts.limit) };
|
|
33
34
|
if (opts.about)
|
|
34
35
|
payload.match = opts.about;
|
|
35
|
-
const res = await fetch(
|
|
36
|
+
const res = await fetch(askPath(base(opts), 'meta:recall'), {
|
|
36
37
|
method: 'POST',
|
|
37
38
|
headers: authHeaders(),
|
|
38
39
|
body: JSON.stringify({ data: payload }),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function askPath(base: string, receiver: string): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// The api.one.ie GATEWAY serves substrate ops at the short form (/ask/<receiver>,
|
|
2
|
+
// mapped internally to one-prod's /api/ask/<receiver> — api/src/substrate-binding.ts
|
|
3
|
+
// PATH_MAP). Calling /api/ask/ directly against the gateway 404s (verified live
|
|
4
|
+
// 2026-07-03). one.ie/web itself only answers the long form. Pick the path that
|
|
5
|
+
// matches whichever host --api actually points at, rather than hardcoding one.
|
|
6
|
+
export function askPath(base, receiver) {
|
|
7
|
+
const isGateway = new URL(base).hostname === 'api.one.ie';
|
|
8
|
+
return `${base}${isGateway ? '/ask' : '/api/ask'}/${encodeURIComponent(receiver)}`;
|
|
9
|
+
}
|
package/dist/src/render.d.ts
CHANGED
package/dist/src/render.js
CHANGED
|
@@ -12,7 +12,7 @@ export function renderStatus(agency, clients) {
|
|
|
12
12
|
const totalBurned = clients.reduce((s, c) => s + c.burned, 0);
|
|
13
13
|
const totalMargin = clients.reduce((s, c) => s + c.margin, 0);
|
|
14
14
|
const out = [];
|
|
15
|
-
out.push(`Agency: ${agency.name ?? agency.slug} (${agency.slug}) plan
|
|
15
|
+
out.push(`Agency: ${agency.name ?? agency.slug} (${agency.slug}) plan=${agency.plan} markup=${agency.markup_pct}% pool=${fmt(agency.pool)} cr`);
|
|
16
16
|
out.push('');
|
|
17
17
|
out.push(pad(header, widths));
|
|
18
18
|
for (const r of rows)
|
package/dist/src/setup.js
CHANGED
|
@@ -2,7 +2,7 @@ import { Command } from 'commander';
|
|
|
2
2
|
import { existsSync } from 'node:fs';
|
|
3
3
|
import { mergeEnv, writeEnvLocal } from './env.js';
|
|
4
4
|
import { readAgency } from './config.js';
|
|
5
|
-
const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://
|
|
5
|
+
const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://one.ie';
|
|
6
6
|
async function ask(base, key, receiver, data) {
|
|
7
7
|
const res = await fetch(`${base}/api/ask/${encodeURIComponent(receiver)}`, {
|
|
8
8
|
method: 'POST',
|
|
@@ -13,7 +13,15 @@ async function ask(base, key, receiver, data) {
|
|
|
13
13
|
const body = await res.text().catch(() => '');
|
|
14
14
|
throw new Error(`${receiver} → ${res.status}\n${body}`);
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
const json = await res.json();
|
|
17
|
+
if (json.outcome === 'failure') {
|
|
18
|
+
const result = (json.result ?? {});
|
|
19
|
+
const details = Object.entries(result)
|
|
20
|
+
.map(([k, v]) => `${k}=${typeof v === 'string' ? v : JSON.stringify(v)}`)
|
|
21
|
+
.join(' ');
|
|
22
|
+
throw new Error(`${receiver} → forbidden: ${details}`);
|
|
23
|
+
}
|
|
24
|
+
return json;
|
|
17
25
|
}
|
|
18
26
|
export function setupCmd() {
|
|
19
27
|
return new Command('setup')
|
package/dist/src/status.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { mergeEnv } from './env.js';
|
|
3
3
|
import { renderStatus } from './render.js';
|
|
4
|
-
const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://
|
|
4
|
+
const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://one.ie';
|
|
5
5
|
export function statusCmd() {
|
|
6
6
|
return new Command('status')
|
|
7
7
|
.description('Agency P&L dashboard (pool, margin, per-client burns)')
|
|
@@ -26,13 +26,21 @@ export function statusCmd() {
|
|
|
26
26
|
process.stderr.write(`billing:clients → ${res.status}\n`);
|
|
27
27
|
process.exit(1);
|
|
28
28
|
}
|
|
29
|
-
const
|
|
29
|
+
const json = await res.json();
|
|
30
|
+
if (json.outcome === 'failure') {
|
|
31
|
+
const result = (json.result ?? {});
|
|
32
|
+
const details = Object.entries(result)
|
|
33
|
+
.map(([k, v]) => `${k}=${typeof v === 'string' ? v : JSON.stringify(v)}`)
|
|
34
|
+
.join(' ');
|
|
35
|
+
process.stderr.write(`billing:clients → forbidden: ${details}\n`);
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
30
38
|
if (opts.json) {
|
|
31
|
-
process.stdout.write(JSON.stringify(
|
|
39
|
+
process.stdout.write(JSON.stringify(json, null, 2) + '\n');
|
|
32
40
|
return;
|
|
33
41
|
}
|
|
34
|
-
const agency = (
|
|
35
|
-
const clients = (
|
|
42
|
+
const agency = (json.agency ?? { slug: env.AGENCY_SLUG, name: env.AGENCY_NAME ?? null, markup_pct: 0, pool: 0, plan: 'free' });
|
|
43
|
+
const clients = (json.clients ?? []);
|
|
36
44
|
process.stdout.write(renderStatus(agency, clients) + '\n');
|
|
37
45
|
});
|
|
38
46
|
}
|
package/dist/src/trade.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { askPath } from './lib/api-path.js';
|
|
1
2
|
const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://api.one.ie';
|
|
2
3
|
function apiKey() {
|
|
3
4
|
return process.env.ONEIE_API_KEY ?? process.env.ONE_API_KEY ?? '';
|
|
@@ -13,7 +14,7 @@ function authHeaders() {
|
|
|
13
14
|
return h;
|
|
14
15
|
}
|
|
15
16
|
async function ask(b, receiver, data) {
|
|
16
|
-
const res = await fetch(
|
|
17
|
+
const res = await fetch(askPath(b, receiver), {
|
|
17
18
|
method: 'POST',
|
|
18
19
|
headers: authHeaders(),
|
|
19
20
|
body: JSON.stringify({ data }),
|
package/dist/src/wallet.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
|
|
2
|
+
import { askPath } from './lib/api-path.js';
|
|
3
|
+
export { askPath };
|
|
3
4
|
export declare function faucetOk(results: Array<{
|
|
4
5
|
success: boolean;
|
|
5
6
|
}>): boolean;
|
|
6
7
|
export declare function okWrap(result: Record<string, unknown>): Record<string, unknown>;
|
|
7
8
|
export declare function walletCmd(): Command;
|
|
9
|
+
export declare function writeKeysFile(filePath: string, contents: string, accepted: boolean): void;
|
package/dist/src/wallet.js
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { mergeEnv } from './env.js';
|
|
3
|
+
import { writeFileSync, chmodSync, readFileSync } from 'node:fs';
|
|
4
|
+
import { generateWallet, recoverWallet } from '@oneie/sdk/wallet';
|
|
5
|
+
import { askPath } from './lib/api-path.js';
|
|
3
6
|
const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://api.one.ie';
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
// matches whichever host --api actually points at, rather than hardcoding one.
|
|
9
|
-
export function askPath(base, receiver) {
|
|
10
|
-
const isGateway = new URL(base).hostname === 'api.one.ie';
|
|
11
|
-
return `${base}${isGateway ? '/ask' : '/api/ask'}/${encodeURIComponent(receiver)}`;
|
|
12
|
-
}
|
|
7
|
+
// Re-exported for existing callers/tests — canonical implementation now lives
|
|
8
|
+
// in ./lib/api-path.ts so trade.ts/client.ts/coordinate.ts/catalog.ts can share
|
|
9
|
+
// it instead of each hardcoding /api/ask/<receiver> against DEFAULT_API.
|
|
10
|
+
export { askPath };
|
|
13
11
|
// The ask envelope nests the resolver's return under `result`, not at the top
|
|
14
12
|
// level: { outcome:'result'|'timeout'|'dissolved'|'failure', result, signalId,
|
|
15
13
|
// receiver }. Unwrap it here so callers work with the plain wallet:* shape.
|
|
@@ -149,8 +147,49 @@ export function walletCmd() {
|
|
|
149
147
|
});
|
|
150
148
|
out(cmd, okWrap(result));
|
|
151
149
|
});
|
|
150
|
+
cmd.command('keygen')
|
|
151
|
+
.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
|
+
.option('--recover', 'Recover from a 24-word BIP-39 mnemonic (ONE_WALLET_MNEMONIC env or stdin) instead of generating a fresh one')
|
|
153
|
+
.option('--out <file>', 'Write the mnemonic + keys to a file at mode 0600 instead of printing once')
|
|
154
|
+
.option('--yes-i-accept-plaintext-file', 'Required with --out — acknowledge that unencrypted key material will be written to disk')
|
|
155
|
+
.action(async (opts) => {
|
|
156
|
+
const wallet = opts.recover ? await recoverWallet(readMnemonic()) : await generateWallet();
|
|
157
|
+
const addresses = Object.fromEntries(wallet.keys.map((k) => [k.chain, k.address]));
|
|
158
|
+
if (opts.out) {
|
|
159
|
+
const contents = JSON.stringify({ mnemonic: wallet.mnemonic, keys: wallet.keys }, null, 2) + '\n';
|
|
160
|
+
writeKeysFile(opts.out, contents, Boolean(opts.yesIAcceptPlaintextFile));
|
|
161
|
+
out(cmd, { ok: true, out: opts.out, chains: wallet.keys.map((k) => k.chain), addresses });
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
out(cmd, { ok: true, mnemonic: wallet.mnemonic, addresses, keys: wallet.keys });
|
|
165
|
+
}
|
|
166
|
+
});
|
|
152
167
|
return cmd;
|
|
153
168
|
}
|
|
169
|
+
// Read the recovery mnemonic for `keygen --recover`: ONE_WALLET_MNEMONIC env first
|
|
170
|
+
// (scriptable), else stdin (fd 0). Never a CLI arg — keeps the phrase out of the
|
|
171
|
+
// process table / shell history.
|
|
172
|
+
function readMnemonic() {
|
|
173
|
+
const fromEnv = process.env.ONE_WALLET_MNEMONIC?.trim();
|
|
174
|
+
if (fromEnv)
|
|
175
|
+
return fromEnv;
|
|
176
|
+
try {
|
|
177
|
+
return readFileSync(0, 'utf8').trim();
|
|
178
|
+
}
|
|
179
|
+
catch {
|
|
180
|
+
throw new Error('--recover needs a mnemonic — set ONE_WALLET_MNEMONIC or pipe the phrase on stdin');
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
// Write key material to a plaintext file at mode 0600, and ONLY when the operator
|
|
184
|
+
// explicitly accepted the risk. chmod after write in case umask stripped bits at
|
|
185
|
+
// create time. Exported for the demo gate.
|
|
186
|
+
export function writeKeysFile(filePath, contents, accepted) {
|
|
187
|
+
if (!accepted) {
|
|
188
|
+
throw new Error('refusing to write plaintext key material to disk — pass --yes-i-accept-plaintext-file to override');
|
|
189
|
+
}
|
|
190
|
+
writeFileSync(filePath, contents, { mode: 0o600 });
|
|
191
|
+
chmodSync(filePath, 0o600);
|
|
192
|
+
}
|
|
154
193
|
function out(cmd, data) {
|
|
155
194
|
const isJson = cmd.parent?.opts().json;
|
|
156
195
|
if (isJson) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oneie/cli",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "ONE agent CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"commander": "^12.0.0",
|
|
23
|
-
"@oneie/sdk": "
|
|
23
|
+
"@oneie/sdk": "0.14.5"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@oneie/evals": "
|
|
26
|
+
"@oneie/evals": "0.1.0",
|
|
27
27
|
"@types/node": "^25.6.0",
|
|
28
28
|
"tsx": "^4.0.0",
|
|
29
29
|
"typescript": "^5.4.0",
|