@oneie/cli 0.4.0 → 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 (44) 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 +1 -2
  6. package/dist/src/catalog.js +65 -36
  7. package/dist/src/client.d.ts +0 -1
  8. package/dist/src/client.js +71 -169
  9. package/dist/src/compiler.d.ts +15 -19
  10. package/dist/src/compiler.js +170 -219
  11. package/dist/src/config.d.ts +24 -0
  12. package/dist/src/config.js +70 -0
  13. package/dist/src/coordinate.d.ts +2 -2
  14. package/dist/src/coordinate.js +47 -61
  15. package/dist/src/create.d.ts +2 -0
  16. package/dist/src/create.js +193 -0
  17. package/dist/src/deploy.d.ts +0 -1
  18. package/dist/src/deploy.js +8 -35
  19. package/dist/src/env.d.ts +3 -6
  20. package/dist/src/env.js +31 -24
  21. package/dist/src/fn.d.ts +2 -0
  22. package/dist/src/fn.js +73 -0
  23. package/dist/src/index.js +16 -8
  24. package/dist/src/links.d.ts +5 -0
  25. package/dist/src/links.js +50 -0
  26. package/dist/src/push.d.ts +0 -1
  27. package/dist/src/push.js +44 -99
  28. package/dist/src/render.d.ts +17 -0
  29. package/dist/src/render.js +25 -0
  30. package/dist/src/setup.d.ts +0 -1
  31. package/dist/src/setup.js +43 -134
  32. package/dist/src/ship.d.ts +0 -1
  33. package/dist/src/ship.js +13 -36
  34. package/dist/src/slug.d.ts +2 -5
  35. package/dist/src/slug.js +4 -7
  36. package/dist/src/status.d.ts +0 -1
  37. package/dist/src/status.js +29 -42
  38. package/dist/src/trade.d.ts +1 -2
  39. package/dist/src/trade.js +71 -74
  40. package/dist/src/trail.d.ts +2 -0
  41. package/dist/src/trail.js +47 -0
  42. package/dist/src/validate.d.ts +11 -10
  43. package/dist/src/validate.js +32 -34
  44. package/package.json +2 -2
package/LICENSE ADDED
@@ -0,0 +1,86 @@
1
+ # ONE License (Version 1.0)
2
+
3
+ Copyright (c) 2024-2026 one.ie
4
+
5
+ ## Maximum Freedom, One Obligation
6
+
7
+ This license empowers you with complete commercial freedom to use, reuse, modify, sell and resell the software, AI and data, at any price you wish.
8
+
9
+ No usage limits. No royalty fees. Just pure, unrestricted ability to innovate and profit from the software.
10
+
11
+ You are free to run ONE locally, on your own servers, in the cloud and at the edge.
12
+
13
+ ## You Receive
14
+
15
+ ### Unlimited Rights
16
+
17
+ You have unrestricted rights to use, modify, license, sublicense, distribute, sell, resell and monetize the Software without restrictions, subject only to the Brand Requirement below.
18
+
19
+ ### Permitted Actions
20
+
21
+ Including, but not limited to:
22
+
23
+ - Commercial use and integration into any systems
24
+ - Creation and sale of derivative works
25
+ - Providing software as a service
26
+ - AI training and content generation
27
+ - Patenting innovations based on the Software
28
+ - Open source applications and integrations
29
+
30
+ ### License Compatibility
31
+
32
+ This license is compatible with all major open-source licenses, including:
33
+
34
+ - MIT License
35
+ - Apache License
36
+ - GNU General Public License (GPL)
37
+ - BSD Licenses
38
+ - Mozilla Public License
39
+
40
+ ### Perpetual Rights
41
+
42
+ These rights are granted in perpetuity and are irrevocable, provided the Brand Requirement is maintained.
43
+
44
+ ## Intellectual Property
45
+
46
+ - We retain ownership of the original Software and data.
47
+ - You own any modifications you make.
48
+ - You never have to share your code or data.
49
+
50
+ ## Brand Requirement
51
+
52
+ The only obligation is:
53
+
54
+ - Don't remove the ONE brand, logo, and link to https://one.ie/ from the deployed product.
55
+
56
+ To remove the Brand Requirement — white-label, no visible ONE branding — obtain the
57
+ **ONE Enterprise License** (see `LICENSE-ENTERPRISE.md` or contact agent@one.ie).
58
+
59
+ ## Liability and Warranty
60
+
61
+ The Software and data is provided "AS IS". We bear no liability for its use.
62
+
63
+ ## Termination
64
+
65
+ This license terminates if you remove or hide the ONE brand, logo, or link without
66
+ holding a current ONE Enterprise License.
67
+
68
+ ## Governing Law and Disputes
69
+
70
+ This license is governed by the laws of Ireland. The parties will attempt to resolve disputes through good-faith negotiation. If necessary, disputes will proceed to mediation under the Mediators' Institute of Ireland rules, and then to binding arbitration under the Arbitration Act 2010, seated in Dublin, conducted in English.
71
+
72
+ ---
73
+
74
+ This license is designed to maximize freedom to innovate and profit. There is no copyleft requirement to share any code, making it suitable for enterprise use.
75
+
76
+ ## Enterprise Solutions
77
+
78
+ Building something big? We're here to help:
79
+
80
+ - **Free** — use every feature with the ONE brand link in the footer
81
+ - **White-label** — remove the brand requirement (ONE Enterprise License)
82
+ - **Custom** — white-label solutions tailored to your needs
83
+ - **Enterprise** — full support and deployment assistance
84
+ - **Training** — help getting your team started
85
+
86
+ Contact agent@one.ie to share your needs · Learn at https://one.ie/learn · Agents: https://one.ie/llms.txt
package/dist/src/agent.js CHANGED
@@ -758,7 +758,8 @@ function compileTarget(content, target) {
758
758
  const fm = m ? m[1] : '';
759
759
  const body = m ? m[2].trim() : content.trim();
760
760
  return [
761
- '// auto-generated by `oneie agent compile --target web` — do not edit by hand',
761
+ '// Generated by ONE — https://one.ie',
762
+ '// `oneie agent compile --target web` — do not edit by hand',
762
763
  '',
763
764
  'export const frontmatterRaw = ' + JSON.stringify(fm),
764
765
  'export const prompt = ' + JSON.stringify(body),
@@ -0,0 +1,9 @@
1
+ export interface ParsedArgs {
2
+ receiver?: string;
3
+ positional: string[];
4
+ body: Record<string, unknown>;
5
+ dryRun: boolean;
6
+ simulate: boolean;
7
+ flags: Record<string, string | boolean>;
8
+ }
9
+ export declare function parseArgs(rest: string[]): ParsedArgs;
@@ -0,0 +1,61 @@
1
+ function coerce(v) {
2
+ if (v === 'true')
3
+ return true;
4
+ if (v === 'false')
5
+ return false;
6
+ if (v !== '' && !Number.isNaN(Number(v)))
7
+ return Number(v);
8
+ return v;
9
+ }
10
+ export function parseArgs(rest) {
11
+ const positional = [];
12
+ const flags = {};
13
+ const fromFlags = {};
14
+ let body = {};
15
+ let dryRun = false;
16
+ let simulate = false;
17
+ for (let i = 0; i < rest.length; i++) {
18
+ const tok = rest[i];
19
+ if (tok.startsWith('--')) {
20
+ const eq = tok.indexOf('=');
21
+ const key = (eq === -1 ? tok.slice(2) : tok.slice(2, eq));
22
+ if (key === 'dry-run') {
23
+ dryRun = true;
24
+ flags[key] = true;
25
+ continue;
26
+ }
27
+ if (key === 'simulate') {
28
+ simulate = true;
29
+ flags[key] = true;
30
+ continue;
31
+ }
32
+ let val;
33
+ if (eq !== -1)
34
+ val = tok.slice(eq + 1);
35
+ else if (i + 1 < rest.length && !rest[i + 1].startsWith('--'))
36
+ val = rest[++i];
37
+ else
38
+ val = true;
39
+ flags[key] = val;
40
+ fromFlags[key] = typeof val === 'string' ? coerce(val) : val;
41
+ }
42
+ else if (tok.trimStart().startsWith('{')) {
43
+ try {
44
+ const parsed = JSON.parse(tok);
45
+ if (parsed && typeof parsed === 'object')
46
+ body = { ...body, ...parsed };
47
+ }
48
+ catch {
49
+ throw new Error(`invalid JSON payload: ${tok}`);
50
+ }
51
+ }
52
+ else {
53
+ positional.push(tok);
54
+ }
55
+ }
56
+ body = { ...body, ...fromFlags };
57
+ simulate = simulate || dryRun;
58
+ if (simulate)
59
+ body.simulate = true;
60
+ return { receiver: positional[0], positional, body, dryRun, simulate, flags };
61
+ }
@@ -1,3 +1,2 @@
1
- /** `one catalog` — browse the ONE receiver surface. */
2
1
  import { Command } from 'commander';
3
- export declare function catalogCmd(): Command;
2
+ export declare function catalogCommands(program: Command): void;
@@ -1,48 +1,77 @@
1
- /** `one catalog` — browse the ONE receiver surface. */
2
- import { Command } from 'commander';
3
- const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_BASE_URL ?? 'https://api.one.ie';
1
+ const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://api.one.ie';
4
2
  function apiKey() {
5
3
  return process.env.ONEIE_API_KEY ?? process.env.ONE_API_KEY ?? '';
6
4
  }
7
- async function ask(base, receiver, data) {
8
- const res = await fetch(`${base}/api/ask/${encodeURIComponent(receiver)}`, {
9
- method: 'POST',
10
- headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${apiKey()}` },
11
- body: JSON.stringify({ data }),
12
- });
13
- return res.json();
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
+ const RECIPE_BLURB = {
16
+ spine: 'onboard — become an actor, mint a key, declare capability',
17
+ build: 'build a world — workspace, group, actor, thing',
18
+ trade: 'discover peers, hire, get paid',
19
+ transact: 'post a bounty, settle onchain',
20
+ };
21
+ function formatItem(it) {
22
+ const meta = [];
23
+ if (it.cost != null)
24
+ meta.push(`cost: ${typeof it.cost === 'object' ? JSON.stringify(it.cost) : it.cost}`);
25
+ if (it.settles && it.settles !== 'none')
26
+ meta.push(`settles: ${it.settles}`);
27
+ if (it.reversible === false)
28
+ meta.push('reversible: false');
29
+ const tail = meta.length ? ` · ${meta.join(' · ')}` : '';
30
+ return ` ${it.receiver.padEnd(28)}${it.summary ?? ''}${tail}`;
14
31
  }
15
- function out(cmd, data) {
16
- const isJson = cmd.parent?.opts()?.json;
17
- if (isJson) {
18
- process.stdout.write(JSON.stringify(data, null, 2) + '\n');
19
- return;
32
+ function formatCatalog(items, goal) {
33
+ if (goal) {
34
+ const match = items.filter((it) => it.receiver.toLowerCase().includes(goal.toLowerCase()));
35
+ if (!match.length)
36
+ return ` (no receivers matching "${goal}")`;
37
+ return `GOAL: ${goal}\n\n` + match.map(formatItem).join('\n');
20
38
  }
21
- // Pretty-print catalog rows
22
- const d = data;
23
- const rows = d?.result?.catalog ?? [];
24
- if (!Array.isArray(rows) || rows.length === 0) {
25
- process.stdout.write(JSON.stringify(data, null, 2) + '\n');
26
- return;
39
+ const grouped = {};
40
+ for (const it of items) {
41
+ const group = it.receiver.split(':')[0] ?? 'other';
42
+ (grouped[group] ??= []).push(it);
27
43
  }
28
- for (const row of rows) {
29
- const cost = row['cost'] ? ` [${row['cost']} cr]` : '';
30
- const rev = row['reversible'] === false ? ' (irreversible)' : '';
31
- const summary = String(row['summary'] ?? '');
32
- const receiver = String(row['receiver'] ?? '');
33
- process.stdout.write(` ${receiver.padEnd(32)} ${summary}${cost}${rev}\n`);
44
+ const out = [];
45
+ for (const [group, groupItems] of Object.entries(grouped)) {
46
+ out.push(`${group.toUpperCase()} — ${RECIPE_BLURB[group] ?? ''}`);
47
+ groupItems.forEach((it) => out.push(formatItem(it)));
48
+ out.push('');
34
49
  }
35
- process.stdout.write(`\n Total: ${rows.length} receivers\n`);
50
+ return out.join('\n');
36
51
  }
37
- export function catalogCmd() {
38
- const cmd = new Command('catalog')
39
- .description('Browse the ONE receiver surface')
40
- .option('--goal <goal>', 'Filter to a named recipe (spine, build, trade, transact, sop)')
52
+ export function catalogCommands(program) {
53
+ program
54
+ .command('catalog')
55
+ .description('Browse receiver surface by recipe')
56
+ .option('--goal <text>', 'Filter by receiver group or keyword')
41
57
  .option('--api <url>', 'API base URL', DEFAULT_API)
58
+ .option('--json', 'Output raw JSON')
42
59
  .action(async (opts) => {
43
- const base = opts.api.replace(/\/$/, '');
44
- const result = await ask(base, 'meta:catalog', { goal: opts.goal });
45
- out(cmd, result);
60
+ const res = await fetch(`${base(opts)}/api/ask/${encodeURIComponent('meta:catalog')}`, {
61
+ method: 'POST',
62
+ headers: authHeaders(),
63
+ body: JSON.stringify({ data: opts.goal ? { goal: opts.goal } : {} }),
64
+ });
65
+ if (!res.ok) {
66
+ process.stderr.write(`meta:catalog → ${res.status}\n`);
67
+ process.exit(1);
68
+ }
69
+ const data = await res.json();
70
+ if (opts.json) {
71
+ process.stdout.write(JSON.stringify(data, null, 2) + '\n');
72
+ return;
73
+ }
74
+ const items = (data.items ?? data.receivers ?? []);
75
+ process.stdout.write(formatCatalog(items, opts.goal) + '\n');
46
76
  });
47
- return cmd;
48
77
  }
@@ -1,3 +1,2 @@
1
- /** `one client` — provision and manage client nodes. */
2
1
  import { Command } from 'commander';
3
2
  export declare function clientCmd(): Command;
@@ -1,196 +1,98 @@
1
- /** `one client` — provision and manage client nodes. */
2
1
  import { Command } from 'commander';
3
- import { readFileSync, existsSync, mkdirSync, cpSync } from 'node:fs';
4
- import { resolve } from 'node:path';
5
- const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_BASE_URL ?? 'https://api.one.ie';
6
- function apiKey() {
7
- return process.env.ONEIE_API_KEY ?? process.env.ONE_API_KEY ?? '';
8
- }
9
- function headers() {
10
- return { 'Content-Type': 'application/json', Authorization: `Bearer ${apiKey()}` };
11
- }
12
- async function ask(base, receiver, data) {
2
+ import { mergeEnv } from './env.js';
3
+ import { readClient } from './config.js';
4
+ import { validateClient } from './validate.js';
5
+ import { safeSlug } from './slug.js';
6
+ const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://api.one.ie';
7
+ async function ask(base, key, receiver, data) {
13
8
  const res = await fetch(`${base}/api/ask/${encodeURIComponent(receiver)}`, {
14
- method: 'POST', headers: headers(), body: JSON.stringify({ data }),
9
+ method: 'POST',
10
+ headers: { 'Content-Type': 'application/json', ...(key ? { Authorization: `Bearer ${key}` } : {}) },
11
+ body: JSON.stringify({ data }),
15
12
  });
16
- return res.json();
17
- }
18
- function parseToml(text) {
19
- const result = {};
20
- let currentSection = null;
21
- for (const rawLine of text.split('\n')) {
22
- const line = rawLine.split('#')[0].trim();
23
- if (!line)
24
- continue;
25
- if (line.startsWith('[[') && line.endsWith(']]')) {
26
- currentSection = line.slice(2, -2).trim();
27
- if (!Array.isArray(result[currentSection]))
28
- result[currentSection] = [];
29
- result[currentSection].push({});
30
- continue;
31
- }
32
- if (line.startsWith('[') && line.endsWith(']')) {
33
- currentSection = null;
34
- continue;
35
- }
36
- const eq = line.indexOf('=');
37
- if (eq < 1)
38
- continue;
39
- const key = line.slice(0, eq).trim();
40
- const raw = line.slice(eq + 1).trim();
41
- let val;
42
- if (raw === 'true')
43
- val = true;
44
- else if (raw === 'false')
45
- val = false;
46
- else if (!isNaN(Number(raw)) && raw !== '')
47
- val = Number(raw);
48
- else if (raw.startsWith('"') || raw.startsWith("'"))
49
- val = raw.slice(1, -1);
50
- else if (raw.startsWith('[') && raw.endsWith(']')) {
51
- val = raw.slice(1, -1).split(',').map(v => v.trim().replace(/^["']|["']$/g, '')).filter(Boolean);
52
- }
53
- else
54
- val = raw;
55
- if (currentSection) {
56
- const arr = result[currentSection];
57
- if (arr.length > 0)
58
- arr[arr.length - 1][key] = val;
59
- }
60
- else
61
- result[key] = val;
62
- }
63
- return result;
64
- }
65
- function readAgencyConfig(cwd) {
66
- for (const name of ['agency.toml', '_node.toml']) {
67
- const p = resolve(cwd, name);
68
- if (existsSync(p))
69
- return parseToml(readFileSync(p, 'utf8'));
70
- }
71
- return {};
72
- }
73
- function out(cmd, data) {
74
- const isJson = cmd.parent?.opts()?.json;
75
- if (isJson)
76
- process.stdout.write(JSON.stringify(data, null, 2) + '\n');
77
- else {
78
- const d = data;
79
- for (const [k, v] of Object.entries(d)) {
80
- if (typeof v !== 'object')
81
- process.stdout.write(` ${k}=${v}\n`);
82
- }
13
+ if (!res.ok) {
14
+ const body = await res.text().catch(() => '');
15
+ throw new Error(`${receiver} → ${res.status}\n${body}`);
83
16
  }
17
+ return res.json();
84
18
  }
85
19
  export function clientCmd() {
86
20
  const cmd = new Command('client').description('Manage client nodes');
87
21
  cmd.command('add <slug>')
88
- .description('Provision a new client workspace and scaffold clients/<slug>/')
89
- .option('--name <name>', 'Display name (defaults to slug)')
90
- .option('--plan <plan>', 'Plan tier', 'pro')
91
- .option('--credits <n>', 'Initial credit grant from agency pool', '5000')
92
- .option('--markup <pct>', 'Reseller markup %', '20')
93
- .option('--cap <n>', 'Monthly spend ceiling in credits', '10000')
94
- .option('--site <url>', 'Crawl a URL to draft ai/ + data/ folders')
95
- .option('--dry-run', 'Simulate without making API calls')
22
+ .description('Atomically provision a managed client node')
23
+ .option('--dry-run', 'Print plan without making substrate calls')
96
24
  .option('--api <url>', 'API base URL', DEFAULT_API)
25
+ .option('--key <key>', 'API key (overrides ONEIE_API_KEY env)')
97
26
  .action(async (slug, opts) => {
98
- const cwd = process.cwd();
99
- const agencyCfg = readAgencyConfig(cwd);
100
- const agencySlug = String(agencyCfg['slug'] ?? '');
101
- const clientName = opts.name ?? slug;
102
- const base = opts.api.replace(/\/$/, '');
103
- const key = apiKey();
104
- if (!key) {
105
- process.stderr.write('error: ONEIE_API_KEY not set — run `one auth login` first\n');
27
+ const dir = process.cwd();
28
+ const env = mergeEnv(dir);
29
+ const key = opts.key ?? env.ONEIE_API_KEY ?? env.ONE_API_KEY ?? '';
30
+ const agencySlug = env.AGENCY_SLUG;
31
+ if (!agencySlug) {
32
+ process.stderr.write('AGENCY_SLUG missing — run `one setup` first\n');
106
33
  process.exit(1);
107
34
  }
108
- // Scaffold clients/<slug>/ from the _node template
109
- const clientDir = resolve(cwd, 'clients', slug);
110
- if (!existsSync(clientDir)) {
111
- if (opts.dryRun) {
112
- process.stdout.write(`[dry-run] would scaffold clients/${slug}/\n`);
113
- }
114
- else {
115
- mkdirSync(clientDir, { recursive: true });
116
- // Copy the _node template if present
117
- const tplDir = resolve(cwd, 'node_modules', '@oneie', 'cli', 'dist', 'templates', '_node');
118
- if (existsSync(tplDir)) {
119
- cpSync(tplDir, clientDir, { recursive: true });
120
- }
121
- else {
122
- // Fallback: create minimal structure
123
- mkdirSync(resolve(clientDir, 'ai', 'agents'), { recursive: true });
124
- mkdirSync(resolve(clientDir, 'data', 'lifecycles'), { recursive: true });
125
- mkdirSync(resolve(clientDir, 'site'), { recursive: true });
126
- }
127
- process.stdout.write(` ✓ scaffolded clients/${slug}/\n`);
128
- }
129
- }
130
- // Crawl the site if --site provided
131
- if (opts.site && !opts.dryRun) {
132
- process.stdout.write(` ~ crawling ${opts.site} to draft ai/ and data/…\n`);
133
- await ask(base, 'web:crawl', { url: opts.site, slug });
35
+ const config = readClient(`${dir}/clients/${safeSlug(slug)}.toml`);
36
+ const errs = validateClient(config);
37
+ if (errs.length) {
38
+ process.stderr.write(errs.join('\n') + '\n');
39
+ process.exit(1);
134
40
  }
41
+ const request = {
42
+ name: config.name,
43
+ slug: safeSlug(config.slug),
44
+ parent: agencySlug,
45
+ plan: config.plan,
46
+ credit: config.credits,
47
+ markup: config.markup_pct,
48
+ cap: config.monthly_cap ?? null,
49
+ brand: config.brand_lock ?? false,
50
+ agents: config.agents,
51
+ };
135
52
  if (opts.dryRun) {
136
- process.stdout.write(`[dry-run] would provision: ${slug} (parent=${agencySlug})\n`);
137
- out(cmd, { ok: true, slug, parent: agencySlug, dry: true });
53
+ process.stdout.write(`[dry-run] add ${request.slug} → managed under ${agencySlug} (plan=${config.plan}, credits=${config.credits ?? 0})\n`);
138
54
  return;
139
55
  }
140
- // Provision the workspace
141
- const result = (await ask(base, 'world:create-workspace', {
142
- name: clientName,
143
- slug,
144
- parent: agencySlug || undefined,
145
- plan: opts.plan,
146
- credit: Number(opts.credits),
147
- markup_pct: Number(opts.markup),
148
- monthly_cap: Number(opts.cap),
149
- }));
150
- if (result?.kind === 'failure') {
151
- process.stderr.write(` ✗ provision failed: ${result?.error ?? 'unknown'}\n`);
152
- process.exit(1);
153
- }
154
- process.stdout.write(` ✓ workspace: ${slug} (parent=${agencySlug || 'none'})\n`);
155
- out(cmd, { ok: true, slug, parent: agencySlug, plan: opts.plan });
156
- process.stdout.write(`\n✓ Client "${clientName}" provisioned. Next: one push clients/${slug}\n`);
56
+ const result = await ask(opts.api.replace(/\/$/, ''), key, 'world:create-workspace', request);
57
+ process.stdout.write(`Added ${request.slug} (managed) → ${String(result.wsid ?? request.slug)}\n`);
157
58
  });
158
- cmd.command('invite <slug>')
159
- .description('Invite a client owner by email')
160
- .requiredOption('--email <email>', 'Client owner email address')
161
- .option('--role <role>', 'Role to assign', 'owner')
59
+ cmd.command('invite <email>')
60
+ .description('Invite a self-serve client (they own the workspace)')
61
+ .option('--slug <slug>', 'Client slug (required)')
62
+ .option('--dry-run', 'Print plan without making substrate calls')
162
63
  .option('--api <url>', 'API base URL', DEFAULT_API)
163
- .action(async (slug, opts) => {
164
- const base = opts.api.replace(/\/$/, '');
165
- const key = apiKey();
166
- if (!key) {
167
- process.stderr.write('error: ONEIE_API_KEY not set\n');
64
+ .option('--key <key>', 'API key (overrides ONEIE_API_KEY env)')
65
+ .action(async (email, opts) => {
66
+ const dir = process.cwd();
67
+ const env = mergeEnv(dir);
68
+ const key = opts.key ?? env.ONEIE_API_KEY ?? env.ONE_API_KEY ?? '';
69
+ const agencySlug = env.AGENCY_SLUG;
70
+ if (!agencySlug) {
71
+ process.stderr.write('AGENCY_SLUG missing — run `one setup` first\n');
168
72
  process.exit(1);
169
73
  }
170
- const result = (await ask(base, 'world:invite-member', {
171
- slug, email: opts.email, role: opts.role,
172
- }));
173
- if (result?.kind === 'failure') {
174
- process.stderr.write(` ✗ invite failed: ${result?.error ?? 'unknown'}\n`);
74
+ if (!opts.slug) {
75
+ process.stderr.write('--slug required\n');
175
76
  process.exit(1);
176
77
  }
177
- out(cmd, { ok: true, slug, email: opts.email, role: opts.role });
178
- });
179
- cmd.command('list')
180
- .description('List client workspaces in clients/')
181
- .option('--api <url>', 'API base URL', DEFAULT_API)
182
- .action(async (_opts) => {
183
- const cwd = process.cwd();
184
- const clientsDir = resolve(cwd, 'clients');
185
- if (!existsSync(clientsDir)) {
186
- out(cmd, { ok: true, clients: [] });
78
+ const config = readClient(`${dir}/clients/${safeSlug(opts.slug)}.toml`);
79
+ const request = {
80
+ slug: safeSlug(config.slug),
81
+ name: config.name,
82
+ email,
83
+ plan: config.plan,
84
+ credits: config.credits,
85
+ markup: config.markup_pct,
86
+ cap: config.monthly_cap ?? null,
87
+ brand: config.brand_lock ?? false,
88
+ agents: config.agents,
89
+ };
90
+ if (opts.dryRun) {
91
+ process.stdout.write(`[dry-run] invite ${request.slug} → self-serve (client owns; ${email})\n`);
187
92
  return;
188
93
  }
189
- const { readdirSync } = await import('node:fs');
190
- const slugs = readdirSync(clientsDir, { withFileTypes: true })
191
- .filter(e => e.isDirectory())
192
- .map(e => e.name);
193
- out(cmd, { ok: true, clients: slugs, count: slugs.length });
94
+ const result = await ask(opts.api.replace(/\/$/, ''), key, 'world:invite-client', request);
95
+ process.stdout.write(`Invite for ${request.slug}: ${String(result.token ?? '(token)')}\n`);
194
96
  });
195
97
  return cmd;
196
98
  }
@@ -1,22 +1,18 @@
1
+ export interface CompileItem {
2
+ path: string;
3
+ receiver: string;
4
+ payload: Record<string, unknown>;
5
+ }
1
6
  export interface CompileResult {
2
- pushed: string[];
3
- skipped: string[];
4
- errors: string[];
7
+ compiled: CompileItem[];
8
+ errors: {
9
+ path: string;
10
+ message: string;
11
+ }[];
5
12
  }
6
- /** Minimal TOML parser — supports top-level scalars + array tables ([[section]]). */
7
- export declare function parseToml(text: string): Record<string, unknown>;
8
- /** Read _node.toml / agency.toml / client.toml from a dir. */
9
- export declare function readNodeConfig(dir: string): Record<string, unknown>;
10
- /**
11
- * Compile a node directory (root or clients/<slug>).
12
- * `clientDir` is the client override folder; if set, it is merged OVER `rootDir`.
13
- */
14
- export declare function compileNode(opts: {
15
- rootDir: string;
16
- clientDir?: string;
17
- apiBase: string;
18
- apiKey: string;
19
- agencySlug: string;
20
- targetSlug: string;
21
- dry: boolean;
13
+ /** Minimal TOML parser: key="v", key=123, key=true, [section], key=["a","b"] */
14
+ export declare function parseToml(src: string): Record<string, unknown>;
15
+ export declare function compileNode(dir: string, agencySlug: string, opts?: {
16
+ clientSlug?: string;
17
+ dryRun?: boolean;
22
18
  }): Promise<CompileResult>;