@oneie/cli 0.3.5 → 0.5.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.
Files changed (49) hide show
  1. package/LICENSE +86 -0
  2. package/dist/src/agent.js +2 -1
  3. package/dist/src/args.d.ts +9 -0
  4. package/dist/src/args.js +61 -0
  5. package/dist/src/catalog.d.ts +2 -0
  6. package/dist/src/catalog.js +77 -0
  7. package/dist/src/client.d.ts +2 -0
  8. package/dist/src/client.js +98 -0
  9. package/dist/src/compiler.d.ts +18 -0
  10. package/dist/src/compiler.js +201 -0
  11. package/dist/src/config.d.ts +24 -0
  12. package/dist/src/config.js +70 -0
  13. package/dist/src/coordinate.d.ts +3 -0
  14. package/dist/src/coordinate.js +57 -0
  15. package/dist/src/create.d.ts +2 -0
  16. package/dist/src/create.js +193 -0
  17. package/dist/src/deploy.d.ts +2 -0
  18. package/dist/src/deploy.js +19 -0
  19. package/dist/src/env.d.ts +3 -0
  20. package/dist/src/env.js +37 -0
  21. package/dist/src/eval.d.ts +2 -0
  22. package/dist/src/eval.js +32 -0
  23. package/dist/src/fn.d.ts +2 -0
  24. package/dist/src/fn.js +73 -0
  25. package/dist/src/index.js +29 -1
  26. package/dist/src/links.d.ts +5 -0
  27. package/dist/src/links.js +50 -0
  28. package/dist/src/push.d.ts +2 -0
  29. package/dist/src/push.js +57 -0
  30. package/dist/src/render.d.ts +17 -0
  31. package/dist/src/render.js +25 -0
  32. package/dist/src/setup.d.ts +2 -0
  33. package/dist/src/setup.js +56 -0
  34. package/dist/src/ship.d.ts +2 -0
  35. package/dist/src/ship.js +18 -0
  36. package/dist/src/skill.js +39 -0
  37. package/dist/src/slug.d.ts +2 -0
  38. package/dist/src/slug.js +6 -0
  39. package/dist/src/status.d.ts +2 -0
  40. package/dist/src/status.js +38 -0
  41. package/dist/src/templates/_node/site/one.config.d.ts +2 -0
  42. package/dist/src/templates/_node/site/one.config.js +22 -0
  43. package/dist/src/trade.d.ts +2 -0
  44. package/dist/src/trade.js +94 -0
  45. package/dist/src/trail.d.ts +2 -0
  46. package/dist/src/trail.js +47 -0
  47. package/dist/src/validate.d.ts +13 -0
  48. package/dist/src/validate.js +35 -0
  49. package/package.json +4 -3
@@ -0,0 +1,57 @@
1
+ const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://api.one.ie';
2
+ function apiKey() {
3
+ return process.env.ONEIE_API_KEY ?? process.env.ONE_API_KEY ?? '';
4
+ }
5
+ function base(opts) {
6
+ return (opts.api ?? DEFAULT_API).replace(/\/$/, '');
7
+ }
8
+ function authHeaders() {
9
+ const h = { 'Content-Type': 'application/json' };
10
+ const k = apiKey();
11
+ if (k)
12
+ h['Authorization'] = `Bearer ${k}`;
13
+ return h;
14
+ }
15
+ export const REPUTATION_PENDING = 'reputation: pending — meta:reputation is not yet shipped (agent-first follow-on).\n' +
16
+ ' Standing lives in TypeDB paths; until the receiver lands, one shows no score (no stub).';
17
+ function formatRecall(out) {
18
+ const hyps = (out?.hypotheses ?? []);
19
+ if (!hyps.length)
20
+ return ' (no memory yet — recall returns what this caller has learned)';
21
+ return hyps.map((h) => ` · [${h.status}] ${h.claim}${h.confidence != null ? ` (${h.confidence})` : ''}`).join('\n');
22
+ }
23
+ export function coordinateCommands(program) {
24
+ program
25
+ .command('recall')
26
+ .description('Read cross-session memory (meta:recall)')
27
+ .option('--about <term>', 'Filter by keyword')
28
+ .option('--limit <n>', 'Max results', '20')
29
+ .option('--api <url>', 'API base URL', DEFAULT_API)
30
+ .option('--json', 'Output raw JSON')
31
+ .action(async (opts) => {
32
+ const payload = { limit: Number(opts.limit) };
33
+ if (opts.about)
34
+ payload.match = opts.about;
35
+ const res = await fetch(`${base(opts)}/api/ask/${encodeURIComponent('meta:recall')}`, {
36
+ method: 'POST',
37
+ headers: authHeaders(),
38
+ body: JSON.stringify({ data: payload }),
39
+ });
40
+ if (!res.ok) {
41
+ process.stderr.write(`meta:recall → ${res.status}\n`);
42
+ process.exit(1);
43
+ }
44
+ const data = await res.json();
45
+ if (opts.json) {
46
+ process.stdout.write(JSON.stringify(data, null, 2) + '\n');
47
+ return;
48
+ }
49
+ process.stdout.write(formatRecall(data) + '\n');
50
+ });
51
+ program
52
+ .command('reputation')
53
+ .description('Agent reputation standing (pending)')
54
+ .action(() => {
55
+ process.stdout.write(REPUTATION_PENDING + '\n');
56
+ });
57
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function createCmd(): Command;
@@ -0,0 +1,193 @@
1
+ import { Command } from 'commander';
2
+ import { mkdirSync, mkdtempSync, readFileSync, writeFileSync, existsSync } from 'node:fs';
3
+ import { resolve, join } from 'node:path';
4
+ import { spawnSync } from 'node:child_process';
5
+ import { tmpdir } from 'node:os';
6
+ const SAFE_REF = /^[A-Za-z0-9._/-]+$/;
7
+ function downloadTarball(url, targetDir) {
8
+ mkdirSync(targetDir, { recursive: true });
9
+ // No shell — pipe curl stdout directly into tar stdin as a buffer
10
+ const curl = spawnSync('curl', ['-fsSL', '--location', url], {
11
+ maxBuffer: 512 * 1024 * 1024,
12
+ stdio: ['ignore', 'pipe', 'inherit'],
13
+ });
14
+ if (curl.status !== 0 || !curl.stdout)
15
+ throw new Error(`curl failed: ${url}`);
16
+ const tar = spawnSync('tar', ['-xz', '--strip-components=1', '-C', targetDir], {
17
+ input: curl.stdout,
18
+ stdio: ['pipe', 'inherit', 'inherit'],
19
+ });
20
+ if (tar.status !== 0)
21
+ throw new Error(`tar failed extracting to ${targetDir}`);
22
+ }
23
+ function downloadSubdir(url, subdir, targetDir) {
24
+ const tmp = mkdtempSync(join(tmpdir(), 'one-create-'));
25
+ try {
26
+ downloadTarball(url, tmp);
27
+ mkdirSync(targetDir, { recursive: true });
28
+ const r = spawnSync('cp', ['-r', join(tmp, subdir, '.'), targetDir], { stdio: 'inherit' });
29
+ if (r.status !== 0)
30
+ throw new Error('cp failed');
31
+ }
32
+ finally {
33
+ spawnSync('rm', ['-rf', tmp]);
34
+ }
35
+ }
36
+ export function createCmd() {
37
+ const cmd = new Command('create').description('Scaffold a new ONE node or site');
38
+ // ── one create agency [name] ──────────────────────────────────────────────
39
+ cmd
40
+ .command('agency [name]')
41
+ .description('Scaffold a new agency node from github.com/one-ie/oo')
42
+ .option('--ref <ref>', 'Git ref to download', 'main')
43
+ .option('--slug <slug>', 'Your agency slug (written into agency.toml)')
44
+ .option('--name <name>', 'Your agency display name (written into agency.toml)')
45
+ .action((dirName, opts) => {
46
+ if (!SAFE_REF.test(opts.ref)) {
47
+ process.stderr.write(`Invalid ref: ${opts.ref}\n`);
48
+ process.exit(1);
49
+ }
50
+ const label = dirName ?? opts.slug ?? 'my-agency';
51
+ const dir = resolve(process.cwd(), label);
52
+ if (existsSync(dir)) {
53
+ process.stderr.write(`Directory already exists: ${dir}\n`);
54
+ process.exit(1);
55
+ }
56
+ process.stdout.write(`Creating agency node at ${dir}...\n`);
57
+ downloadTarball(`https://api.github.com/repos/one-ie/oo/tarball/${opts.ref}`, dir);
58
+ // Patch agency.toml with the user's slug + name so they don't have to
59
+ const tomlPath = join(dir, 'agency.toml');
60
+ if (existsSync(tomlPath) && (opts.slug ?? opts.name)) {
61
+ let toml = readFileSync(tomlPath, 'utf8');
62
+ if (opts.slug)
63
+ toml = toml.replace(/^slug\s*=\s*"[^"]*"/m, `slug = "${opts.slug}"`);
64
+ if (opts.name)
65
+ toml = toml.replace(/^name\s*=\s*"[^"]*"/m, `name = "${opts.name}"`);
66
+ writeFileSync(tomlPath, toml);
67
+ }
68
+ process.stdout.write(`\nAgency node created.\n\n`);
69
+ process.stdout.write(`Next steps:\n`);
70
+ process.stdout.write(` cd ${label}\n`);
71
+ process.stdout.write(` cp .env.example .env.local\n`);
72
+ process.stdout.write(` # Edit .env.local — set ONE_API_KEY and AGENCY_OWNER_EMAIL\n`);
73
+ if (!opts.slug)
74
+ process.stdout.write(` # Edit agency.toml — set slug and name\n`);
75
+ process.stdout.write(` one setup\n`);
76
+ });
77
+ // ── one create client <slug> ──────────────────────────────────────────────
78
+ cmd
79
+ .command('client <slug>')
80
+ .description('Scaffold a client node in clients/<slug>/')
81
+ .option('--name <name>', 'Display name for the client')
82
+ .option('--plan <plan>', 'Plan tier', 'studio')
83
+ .action((slug, opts) => {
84
+ const base = resolve(process.cwd(), 'clients', slug);
85
+ if (existsSync(base)) {
86
+ process.stderr.write(`Client already exists: clients/${slug}\n`);
87
+ process.exit(1);
88
+ }
89
+ const displayName = opts.name ?? slug;
90
+ mkdirSync(join(base, 'ai'), { recursive: true });
91
+ mkdirSync(join(base, 'data', 'lifecycles'), { recursive: true });
92
+ mkdirSync(join(base, 'site'), { recursive: true });
93
+ writeFileSync(join(base, 'ai', 'context.md'), `# ${displayName}\n\nAdd company context here — agents read this on every turn.\n`);
94
+ writeFileSync(join(base, 'site', 'one.config.ts'), [
95
+ `import { defineOne } from '@oneie/frontend'`,
96
+ ``,
97
+ `export default defineOne({`,
98
+ ` backend: { baseUrl: 'https://one.ie' },`,
99
+ ` brand: {`,
100
+ ` tokens: {`,
101
+ ` primary: 'hsl(216 55% 25%)',`,
102
+ ` secondary: 'hsl(219 14% 28%)',`,
103
+ ` tertiary: 'hsl(105 22% 25%)',`,
104
+ ` background: 'hsl(0 0% 93%)',`,
105
+ ` foreground: 'hsl(0 0% 100%)',`,
106
+ ` font: 'hsl(0 0% 13%)',`,
107
+ ` },`,
108
+ ` },`,
109
+ ` plugins: [`,
110
+ ` // auth(),`,
111
+ ` // track({ ws: '${slug}' }),`,
112
+ ` // chat({ agent: 'your-agent' }),`,
113
+ ` ],`,
114
+ `})`,
115
+ ].join('\n') + '\n');
116
+ writeFileSync(join(base, 'client.toml'), [
117
+ `slug = "${slug}"`,
118
+ `name = "${displayName}"`,
119
+ `plan = "${opts.plan}"`,
120
+ ``,
121
+ `# markup_pct = 15 # override agency default`,
122
+ `# monthly_cap = 50000`,
123
+ ].join('\n') + '\n');
124
+ process.stdout.write(`Client node scaffolded: clients/${slug}/\n`);
125
+ process.stdout.write(` ai/context.md — add company context\n`);
126
+ process.stdout.write(` site/one.config.ts — brand tokens (6 tokens rebrand the site)\n`);
127
+ process.stdout.write(` client.toml — plan + economics\n\n`);
128
+ process.stdout.write(`Next: one client add ${slug} [--dry-run]\n`);
129
+ });
130
+ // ── one create partner [name] ────────────────────────────────────────────
131
+ cmd
132
+ .command('partner [name]')
133
+ .description('Scaffold a new partner node from github.com/one-ie/partner')
134
+ .option('--ref <ref>', 'Git ref to download', 'main')
135
+ .option('--slug <slug>', 'Your partner slug (written into partner.toml)')
136
+ .option('--name <name>', 'Your display name (written into partner.toml)')
137
+ .action((dirName, opts) => {
138
+ if (!SAFE_REF.test(opts.ref)) {
139
+ process.stderr.write(`Invalid ref: ${opts.ref}\n`);
140
+ process.exit(1);
141
+ }
142
+ const label = dirName ?? opts.slug ?? 'my-partner';
143
+ const dir = resolve(process.cwd(), label);
144
+ if (existsSync(dir)) {
145
+ process.stderr.write(`Directory already exists: ${dir}\n`);
146
+ process.exit(1);
147
+ }
148
+ process.stdout.write(`Creating partner node at ${dir}...\n`);
149
+ downloadTarball(`https://api.github.com/repos/one-ie/partner/tarball/${opts.ref}`, dir);
150
+ const tomlPath = join(dir, 'partner.toml');
151
+ if (existsSync(tomlPath) && (opts.slug ?? opts.name)) {
152
+ let toml = readFileSync(tomlPath, 'utf8');
153
+ if (opts.slug)
154
+ toml = toml.replace(/^slug\s*=\s*"[^"]*"/m, `slug = "${opts.slug}"`);
155
+ if (opts.name)
156
+ toml = toml.replace(/^name\s*=\s*"[^"]*"/m, `name = "${opts.name}"`);
157
+ writeFileSync(tomlPath, toml);
158
+ }
159
+ process.stdout.write(`\nPartner node created.\n\n`);
160
+ process.stdout.write(`Next steps:\n`);
161
+ process.stdout.write(` cd ${label}\n`);
162
+ process.stdout.write(` cp .env.example .env.local\n`);
163
+ process.stdout.write(` # Edit .env.local — set ONE_API_KEY\n`);
164
+ if (!opts.slug)
165
+ process.stdout.write(` # Edit partner.toml — set slug and name\n`);
166
+ process.stdout.write(` one setup\n`);
167
+ });
168
+ // ── one create site [name] ────────────────────────────────────────────────
169
+ cmd
170
+ .command('site [name]')
171
+ .description('Scaffold a standalone ONE Astro site from github.com/one-ie/one')
172
+ .option('--ref <ref>', 'Git ref to download', 'main')
173
+ .action((name, opts) => {
174
+ if (!SAFE_REF.test(opts.ref)) {
175
+ process.stderr.write(`Invalid ref: ${opts.ref}\n`);
176
+ process.exit(1);
177
+ }
178
+ const dir = resolve(process.cwd(), name ?? 'my-site');
179
+ if (existsSync(dir)) {
180
+ process.stderr.write(`Directory already exists: ${dir}\n`);
181
+ process.exit(1);
182
+ }
183
+ process.stdout.write(`Creating site at ${dir}...\n`);
184
+ downloadSubdir(`https://api.github.com/repos/one-ie/one/tarball/${opts.ref}`, 'apps/web', dir);
185
+ const label = name ?? 'my-site';
186
+ process.stdout.write(`\nSite created.\n\n`);
187
+ process.stdout.write(`Next steps:\n`);
188
+ process.stdout.write(` cd ${label}\n`);
189
+ process.stdout.write(` cp .env.example .env.local\n`);
190
+ process.stdout.write(` bun install && bun run dev\n`);
191
+ });
192
+ return cmd;
193
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function deployCmd(): Command;
@@ -0,0 +1,19 @@
1
+ import { Command } from 'commander';
2
+ import { spawnSync } from 'node:child_process';
3
+ import { existsSync } from 'node:fs';
4
+ export function deployCmd() {
5
+ return new Command('deploy')
6
+ .description('Deploy site/ to Cloudflare Pages via wrangler')
7
+ .argument('[path]', 'Path to deploy (default: site/dist)')
8
+ .option('--project <name>', 'Cloudflare Pages project name')
9
+ .action((path, opts) => {
10
+ const target = path ?? (existsSync('site/dist') ? 'site/dist' : 'dist');
11
+ const args = ['pages', 'deploy', target];
12
+ if (opts.project)
13
+ args.push('--project-name', opts.project);
14
+ process.stdout.write(`Deploying ${target}...\n`);
15
+ const result = spawnSync('wrangler', args, { stdio: 'inherit' });
16
+ if (result.status !== 0)
17
+ process.exit(result.status ?? 1);
18
+ });
19
+ }
@@ -0,0 +1,3 @@
1
+ export declare function readEnvFile(path: string): Record<string, string>;
2
+ export declare function mergeEnv(dir: string): Record<string, string>;
3
+ export declare function writeEnvLocal(dir: string, updates: Record<string, string>): void;
@@ -0,0 +1,37 @@
1
+ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
2
+ const LINE = /^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*?)\s*$/;
3
+ export function readEnvFile(path) {
4
+ if (!existsSync(path))
5
+ return {};
6
+ const out = {};
7
+ for (const raw of readFileSync(path, 'utf8').split('\n')) {
8
+ if (raw.trim().startsWith('#') || !raw.trim())
9
+ continue;
10
+ const m = raw.match(LINE);
11
+ if (m)
12
+ out[m[1]] = m[2].replace(/^["']|["']$/g, '');
13
+ }
14
+ return out;
15
+ }
16
+ function fromProcess() {
17
+ const out = {};
18
+ for (const k of ['ONE_API_URL', 'ONE_API_KEY', 'ONEIE_API_KEY', 'AGENCY_SLUG', 'AGENCY_NAME', 'AGENCY_WSID', 'CC_ACTOR_ID']) {
19
+ const v = process.env[k];
20
+ if (v)
21
+ out[k] = v;
22
+ }
23
+ return out;
24
+ }
25
+ export function mergeEnv(dir) {
26
+ return {
27
+ ...readEnvFile(`${dir}/.env`),
28
+ ...readEnvFile(`${dir}/.env.local`),
29
+ ...fromProcess(),
30
+ };
31
+ }
32
+ export function writeEnvLocal(dir, updates) {
33
+ const path = `${dir}/.env.local`;
34
+ const merged = { ...readEnvFile(path), ...updates };
35
+ const body = Object.entries(merged).map(([k, v]) => `${k}=${v}`).join('\n') + '\n';
36
+ writeFileSync(path, body, 'utf8');
37
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function evalCmd(): Command;
@@ -0,0 +1,32 @@
1
+ import { Command } from 'commander';
2
+ import { existsSync } from 'node:fs';
3
+ export function evalCmd() {
4
+ const cmd = new Command('eval')
5
+ .description('Run agent-behavior evals from *.eval.ts files (tool + signal receipts)')
6
+ .argument('[path]', 'File or directory of *.eval.ts', 'evals')
7
+ .option('--channels <url>', 'Channels base URL', process.env.ONEIE_CHANNELS_URL ?? 'https://channels.one.ie')
8
+ .option('--events <url>', 'Events base URL', process.env.ONEIE_BASE_URL ?? 'https://one.ie')
9
+ .action(async (path, opts) => {
10
+ const out = (data) => process.stdout.write(JSON.stringify(data) + '\n');
11
+ if (!existsSync(path)) {
12
+ out({ ok: false, error: `not found: ${path}` });
13
+ return;
14
+ }
15
+ try {
16
+ const { runEvals } = await import('@oneie/evals');
17
+ const results = await runEvals(path, {
18
+ channelsUrl: opts.channels.replace(/\/$/, ''),
19
+ eventsUrl: opts.events.replace(/\/$/, ''),
20
+ groqApiKey: process.env.GROQ_API_KEY,
21
+ });
22
+ const failed = results.filter((r) => r.failed > 0).length;
23
+ out({ ok: failed === 0, total: results.length, passed: results.length - failed, results });
24
+ if (failed > 0)
25
+ process.exitCode = 1;
26
+ }
27
+ catch (err) {
28
+ out({ ok: false, error: err.message });
29
+ }
30
+ });
31
+ return cmd;
32
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function fnCmd(): Command;
package/dist/src/fn.js ADDED
@@ -0,0 +1,73 @@
1
+ import { Command } from 'commander';
2
+ import { FN_MAP, FN_MAP_VERSION } from '@oneie/sdk/generated/fn-map';
3
+ const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://api.one.ie';
4
+ const ALLOWLIST = new Set([
5
+ 'actionable_hypotheses', 'active_frontiers', 'active_objectives',
6
+ 'actor_classification', 'actors_by_kind', 'actors_by_tag', 'actors_for',
7
+ 'attractive_tasks', 'blocked_tasks', 'cheapest_provider', 'exploratory_tasks',
8
+ 'highways', 'optimal_route', 'promising_frontiers', 'suggest_route', 'total_contribution',
9
+ ]);
10
+ function apiKey() {
11
+ return process.env.ONEIE_API_KEY ?? process.env.ONE_API_KEY ?? '';
12
+ }
13
+ function base(opts) {
14
+ return (opts.api ?? DEFAULT_API).replace(/\/$/, '');
15
+ }
16
+ async function api(url, body) {
17
+ const h = { 'Content-Type': 'application/json' };
18
+ const k = apiKey();
19
+ if (k)
20
+ h['Authorization'] = `Bearer ${k}`;
21
+ const res = await fetch(url, { method: 'POST', headers: h, body: JSON.stringify(body) });
22
+ if (!res.ok) {
23
+ const text = await res.text().catch(() => '');
24
+ process.stderr.write(`fn:run → ${res.status}\n${text}\n`);
25
+ process.exit(1);
26
+ }
27
+ return res.json();
28
+ }
29
+ export function fnCmd() {
30
+ const cmd = new Command('fn').description(`Execute an allowlisted TypeDB function (FN_MAP v${FN_MAP_VERSION})`);
31
+ cmd
32
+ .command('list')
33
+ .description('List all allowlisted functions')
34
+ .action(() => {
35
+ const rows = Array.from(ALLOWLIST).map((name) => {
36
+ const entry = FN_MAP[name];
37
+ const params = entry?.params.map((p) => p.name).join(', ') ?? '';
38
+ return ` ${name.padEnd(28)}${params ? `(${params})` : '()'} → ${entry?.returnKind ?? '?'}`;
39
+ });
40
+ process.stdout.write(`Allowlisted functions (FN_MAP v${FN_MAP_VERSION}):\n${rows.join('\n')}\n`);
41
+ });
42
+ cmd
43
+ .command('run <name>')
44
+ .description('Execute a function by name')
45
+ .option('--args <json>', 'Function arguments as JSON object (keys without $ prefix)')
46
+ .option('--workspace <slug>', 'Workspace slug')
47
+ .option('--api <url>', 'API base URL', DEFAULT_API)
48
+ .action(async (name, opts) => {
49
+ if (!ALLOWLIST.has(name)) {
50
+ process.stderr.write(`error: '${name}' is not in the allowlist. Run 'one fn list' to see available functions.\n`);
51
+ process.exit(1);
52
+ }
53
+ let args = {};
54
+ if (opts.args) {
55
+ try {
56
+ args = JSON.parse(opts.args);
57
+ }
58
+ catch {
59
+ process.stderr.write('error: --args must be valid JSON\n');
60
+ process.exit(1);
61
+ }
62
+ }
63
+ const prefixed = {};
64
+ for (const [k, v] of Object.entries(args)) {
65
+ prefixed[k.startsWith('$') ? k : `$${k}`] = v;
66
+ }
67
+ const result = await api(`${base(opts)}/api/ask/fn%3Arun`, {
68
+ data: { fn: name, args: prefixed, workspace: opts.workspace },
69
+ });
70
+ process.stdout.write(JSON.stringify(result, null, 2) + '\n');
71
+ });
72
+ return cmd;
73
+ }
package/dist/src/index.js CHANGED
@@ -8,13 +8,27 @@ import { groupCmd } from './group.js';
8
8
  import { socialCmd } from './social.js';
9
9
  import { connectCmd } from './connect.js';
10
10
  import { broadcastCmd, newsletterCmd } from './broadcast.js';
11
+ import { linksCmd } from './links.js';
11
12
  import { staffCmd } from './staff.js';
12
13
  import { substrateCommands } from './substrate.js';
14
+ import { evalCmd } from './eval.js';
15
+ import { setupCmd } from './setup.js';
16
+ import { clientCmd } from './client.js';
17
+ import { pushCmd } from './push.js';
18
+ import { deployCmd } from './deploy.js';
19
+ import { statusCmd } from './status.js';
20
+ import { shipCmd } from './ship.js';
21
+ import { catalogCommands } from './catalog.js';
22
+ import { tradeCommands } from './trade.js';
23
+ import { coordinateCommands } from './coordinate.js';
24
+ import { createCmd } from './create.js';
25
+ import { fnCmd } from './fn.js';
26
+ import { trailCmd } from './trail.js';
13
27
  import { readFileSync } from 'node:fs';
14
28
  import { fileURLToPath } from 'node:url';
15
29
  import { resolve, dirname } from 'node:path';
16
30
  const __dirname = dirname(fileURLToPath(import.meta.url));
17
- const pkg = JSON.parse(readFileSync(resolve(__dirname, '../../package.json'), 'utf8'));
31
+ const pkg = JSON.parse(readFileSync(resolve(__dirname, '../package.json'), 'utf8'));
18
32
  const program = new Command()
19
33
  .name('oneie')
20
34
  .description('ONE — agent CLI')
@@ -29,8 +43,22 @@ program.addCommand(socialCmd());
29
43
  program.addCommand(connectCmd());
30
44
  program.addCommand(broadcastCmd());
31
45
  program.addCommand(newsletterCmd());
46
+ program.addCommand(linksCmd());
32
47
  program.addCommand(staffCmd());
48
+ program.addCommand(evalCmd());
49
+ program.addCommand(setupCmd());
50
+ program.addCommand(clientCmd());
51
+ program.addCommand(pushCmd());
52
+ program.addCommand(deployCmd());
53
+ program.addCommand(statusCmd());
54
+ program.addCommand(shipCmd());
55
+ catalogCommands(program);
56
+ tradeCommands(program);
57
+ coordinateCommands(program);
33
58
  substrateCommands(program);
59
+ program.addCommand(createCmd());
60
+ program.addCommand(fnCmd());
61
+ program.addCommand(trailCmd());
34
62
  program.parseAsync(process.argv).catch((err) => {
35
63
  const isJson = process.argv.includes('--json');
36
64
  if (isJson)
@@ -0,0 +1,5 @@
1
+ import { Command } from 'commander';
2
+ /** `one links` — mint personalised, actor-bound tracked links from the terminal.
3
+ * Thin wrapper over the `links:create` receiver via ask() (no new route). The
4
+ * receiver walks authority server-side; the API key identifies the caller. */
5
+ export declare function linksCmd(): Command;
@@ -0,0 +1,50 @@
1
+ import { Command } from 'commander';
2
+ const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_BASE_URL ?? 'https://api.one.ie';
3
+ function headers() {
4
+ const h = { 'Content-Type': 'application/json' };
5
+ const k = process.env.ONEIE_API_KEY ?? process.env.ONE_API_KEY ?? '';
6
+ if (k)
7
+ h['Authorization'] = `Bearer ${k}`;
8
+ return h;
9
+ }
10
+ async function ask(api, receiver, data) {
11
+ const res = await fetch(`${api.replace(/\/$/, '')}/api/ask/${encodeURIComponent(receiver)}`, {
12
+ method: 'POST',
13
+ headers: headers(),
14
+ body: JSON.stringify({ data }),
15
+ });
16
+ if (!res.ok) {
17
+ process.stderr.write(`POST /api/ask/${receiver} → ${res.status}\n`);
18
+ process.exit(1);
19
+ }
20
+ return res.json();
21
+ }
22
+ function out(data) {
23
+ process.stdout.write(JSON.stringify(data, null, 2) + '\n');
24
+ }
25
+ /** `one links` — mint personalised, actor-bound tracked links from the terminal.
26
+ * Thin wrapper over the `links:create` receiver via ask() (no new route). The
27
+ * receiver walks authority server-side; the API key identifies the caller. */
28
+ export function linksCmd() {
29
+ const cmd = new Command('links').description('Create personalised, actor-bound tracked links');
30
+ cmd
31
+ .command('create <actorId>')
32
+ .description('Create a tracked link bound to a contact (rung-4 identity on click)')
33
+ .option('--to <path>', "Destination path, e.g. '/pricing'", '/')
34
+ .option('--context <text>', "Context injected into the agent's system prompt")
35
+ .option('--greeting <text>', "Override the chat agent's opening line")
36
+ .option('--campaign <id>', 'Group clicks under a campaign')
37
+ .option('--expires <days>', 'Link TTL in days (omit = never)')
38
+ .option('--api <url>', 'API base URL', DEFAULT_API)
39
+ .action(async (actorId, opts) => {
40
+ out(await ask(opts.api, 'links:create', {
41
+ actorId,
42
+ destination: opts.to,
43
+ context: opts.context,
44
+ greeting: opts.greeting,
45
+ campaignId: opts.campaign,
46
+ expiresInDays: opts.expires ? Number(opts.expires) : undefined,
47
+ }));
48
+ });
49
+ return cmd;
50
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function pushCmd(): Command;
@@ -0,0 +1,57 @@
1
+ import { Command } from 'commander';
2
+ import { compileNode } from './compiler.js';
3
+ import { mergeEnv } from './env.js';
4
+ const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://api.one.ie';
5
+ function apiKey(env) {
6
+ return env.ONEIE_API_KEY ?? env.ONE_API_KEY ?? process.env.ONEIE_API_KEY ?? process.env.ONE_API_KEY ?? '';
7
+ }
8
+ export function pushCmd() {
9
+ return new Command('push')
10
+ .description('Compile ai/ + data/ folders and push to substrate')
11
+ .argument('[path]', 'Node root directory (default: cwd)')
12
+ .option('--client <slug>', 'Apply client override from clients/<slug>/')
13
+ .option('--dry-run', 'Validate and print plan without making substrate calls')
14
+ .option('--api <url>', 'API base URL', DEFAULT_API)
15
+ .option('--key <key>', 'API key (overrides ONEIE_API_KEY env)')
16
+ .action(async (path, opts) => {
17
+ const dir = path ?? process.cwd();
18
+ const env = mergeEnv(dir);
19
+ const agencySlug = env.AGENCY_SLUG;
20
+ if (!agencySlug) {
21
+ process.stderr.write('AGENCY_SLUG missing — run `one setup` first\n');
22
+ process.exit(1);
23
+ }
24
+ const { compiled, errors } = await compileNode(dir, agencySlug, { clientSlug: opts.client, dryRun: opts.dryRun });
25
+ if (errors.length) {
26
+ for (const e of errors)
27
+ process.stderr.write(` error: ${e.path}: ${e.message}\n`);
28
+ process.exit(1);
29
+ }
30
+ if (opts.dryRun) {
31
+ process.stdout.write(`[dry-run] ${compiled.length} item(s) would push:\n`);
32
+ for (const item of compiled)
33
+ process.stdout.write(` ${item.receiver} ${item.path}\n`);
34
+ return;
35
+ }
36
+ const base = (opts.api ?? DEFAULT_API).replace(/\/$/, '');
37
+ const key = opts.key ?? apiKey(env);
38
+ const authHeaders = { 'Content-Type': 'application/json' };
39
+ if (key)
40
+ authHeaders['Authorization'] = `Bearer ${key}`;
41
+ let ok = 0;
42
+ for (const item of compiled) {
43
+ const res = await fetch(`${base}/api/ask/${encodeURIComponent(item.receiver)}`, {
44
+ method: 'POST',
45
+ headers: authHeaders,
46
+ body: JSON.stringify({ data: item.payload }),
47
+ });
48
+ if (!res.ok) {
49
+ process.stderr.write(` failed: ${item.receiver} ${res.status}\n`);
50
+ }
51
+ else {
52
+ ok++;
53
+ }
54
+ }
55
+ process.stdout.write(`Pushed ${ok}/${compiled.length} item(s).\n`);
56
+ });
57
+ }
@@ -0,0 +1,17 @@
1
+ export interface AgencyPL {
2
+ slug: string;
3
+ name: string | null;
4
+ markup_pct: number;
5
+ pool: number;
6
+ }
7
+ export interface ClientPL {
8
+ slug: string;
9
+ name: string | null;
10
+ plan: string;
11
+ funded: number;
12
+ burned: number;
13
+ margin: number;
14
+ balance: number;
15
+ cap: number | null;
16
+ }
17
+ export declare function renderStatus(agency: AgencyPL, clients: ClientPL[]): string;
@@ -0,0 +1,25 @@
1
+ const fmt = (n) => n.toLocaleString('en-US');
2
+ const capFmt = (n) => (n == null ? '—' : fmt(n));
3
+ function pad(cells, widths) {
4
+ return cells.map((c, i) => c.padEnd(widths[i])).join(' ').replace(/\s+$/, '');
5
+ }
6
+ export function renderStatus(agency, clients) {
7
+ const header = ['CLIENT', 'PLAN', 'FUNDED', 'BURNED', `MARGIN(${agency.markup_pct}%)`, 'BALANCE', 'CAP'];
8
+ const rows = clients.map((c) => [
9
+ c.slug, c.plan, fmt(c.funded), fmt(c.burned), fmt(c.margin), fmt(c.balance), capFmt(c.cap),
10
+ ]);
11
+ const widths = header.map((h, i) => Math.max(h.length, ...rows.map((r) => r[i].length), 0));
12
+ const totalBurned = clients.reduce((s, c) => s + c.burned, 0);
13
+ const totalMargin = clients.reduce((s, c) => s + c.margin, 0);
14
+ const out = [];
15
+ out.push(`Agency: ${agency.name ?? agency.slug} (${agency.slug}) plan=agency markup=${agency.markup_pct}% pool=${fmt(agency.pool)} cr`);
16
+ out.push('');
17
+ out.push(pad(header, widths));
18
+ for (const r of rows)
19
+ out.push(pad(r, widths));
20
+ if (clients.length === 0)
21
+ out.push(' (no clients yet — `one client add <slug>`)');
22
+ else
23
+ out.push(`\n total burned ${fmt(totalBurned)} · margin ${fmt(totalMargin)} ← your margin this period`);
24
+ return out.join('\n');
25
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function setupCmd(): Command;