@oneie/cli 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/src/agent.js CHANGED
@@ -3,6 +3,7 @@ import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'node:fs';
3
3
  import { basename, dirname, resolve } from 'node:path';
4
4
  import { homedir } from 'node:os';
5
5
  import { TEMPLATES } from './templates.js';
6
+ import { compileAgent } from '@oneie/sdk/compile';
6
7
  import { watch } from 'fs';
7
8
  const DEFAULT_API = 'https://one.ie';
8
9
  const KEY_FILE = resolve(homedir(), '.config', 'oneie', 'key');
@@ -49,6 +50,7 @@ export function agentCmd() {
49
50
  cmd.command('compile <path>')
50
51
  .description('Compile agent.md to target format')
51
52
  .option('--target <t>', 'Output format: mcp | uagents | skillmd | web | a2a | erc8004', 'mcp')
53
+ .option('--out <file>', 'Write output to file instead of stdout')
52
54
  .action((path, opts) => {
53
55
  if (!existsSync(path)) {
54
56
  out(cmd, { ok: false, error: `not found: ${path}` });
@@ -56,7 +58,14 @@ export function agentCmd() {
56
58
  }
57
59
  const content = readFileSync(path, 'utf8');
58
60
  const result = compileTarget(content, opts.target);
59
- out(cmd, { ok: true, target: opts.target, bytes: result.length });
61
+ if (opts.out) {
62
+ mkdirSync(dirname(opts.out), { recursive: true });
63
+ writeFileSync(opts.out, result);
64
+ out(cmd, { ok: true, target: opts.target, written: opts.out, bytes: result.length });
65
+ }
66
+ else {
67
+ process.stdout.write(result + '\n');
68
+ }
60
69
  });
61
70
  cmd.command('serve <path>')
62
71
  .description('Run agent as local A2A + MCP server on port 8000')
@@ -69,10 +78,12 @@ export function agentCmd() {
69
78
  out(cmd, { ok: true, path, port: Number(opts.port), status: 'listening' });
70
79
  });
71
80
  cmd.command('publish <path>')
72
- .description('Upload agent.md to your workspace at one.ie (or --api <url>)')
73
- .option('--slug <slug>', 'Workspace slug to publish into (required)')
81
+ .description('Upload agent.md to your workspace at one.ie, or deploy to Agentverse with --target agentverse')
82
+ .option('--slug <slug>', 'Workspace slug to publish into (one.ie target)')
74
83
  .option('--api <url>', 'API base URL', DEFAULT_API)
75
- .option('--name <name>', 'Override agent name (defaults to file stem)')
84
+ .option('--name <name>', 'Override agent name (defaults to frontmatter name:)')
85
+ .option('--target <t>', 'Publish target: oneie (default) | agentverse', 'oneie')
86
+ .option('--agentverse-key <key>', 'Agentverse API key (or set AGENTVERSE_API_KEY)')
76
87
  .action(async (path, opts) => {
77
88
  if (!existsSync(path)) {
78
89
  out(cmd, { ok: false, error: `not found: ${path}` });
@@ -83,6 +94,81 @@ export function agentCmd() {
83
94
  out(cmd, { ok: false, errors });
84
95
  return;
85
96
  }
97
+ const content = readFileSync(path, 'utf8');
98
+ const frontmatterName = /^name:\s*(\S+)/m.exec(content)?.[1];
99
+ const agentName = opts.name ?? frontmatterName ?? basename(path, '.md');
100
+ // ── Agentverse deploy path ────────────────────────────────────────────
101
+ if (opts.target === 'agentverse') {
102
+ const avKey = opts.agentverseKey ?? process.env.AGENTVERSE_API_KEY;
103
+ if (!avKey) {
104
+ out(cmd, { ok: false, error: 'Agentverse API key required — pass --agentverse-key or set AGENTVERSE_API_KEY' });
105
+ return;
106
+ }
107
+ // Compile agent.md → Python uAgents
108
+ let python;
109
+ try {
110
+ python = compileAgent(content, { target: 'uagents' });
111
+ }
112
+ catch (err) {
113
+ out(cmd, { ok: false, error: `compile failed: ${err.message}` });
114
+ return;
115
+ }
116
+ const AV = 'https://agentverse.ai/v1';
117
+ const avFetch = async (method, avPath, body) => {
118
+ const res = await fetch(`${AV}${avPath}`, {
119
+ method,
120
+ headers: { Authorization: `Bearer ${avKey}`, 'Content-Type': 'application/json' },
121
+ body: body !== undefined ? JSON.stringify(body) : undefined,
122
+ });
123
+ const text = await res.text();
124
+ if (!res.ok)
125
+ throw new Error(`${method} ${avPath} → ${res.status}: ${text}`);
126
+ return text ? JSON.parse(text) : {};
127
+ };
128
+ try {
129
+ // 1. Create agent
130
+ const created = await avFetch('POST', '/hosting/agents', { name: agentName });
131
+ const address = created.address;
132
+ if (!address)
133
+ throw new Error('Agentverse did not return an agent address');
134
+ // 2. Upload code (double-encoded JSON — Agentverse requirement)
135
+ const codeArray = [{ language: 'python', name: 'agent.py', value: python }];
136
+ await avFetch('PUT', `/hosting/agents/${address}/code`, { code: JSON.stringify(codeArray) });
137
+ // 3. Set API key as secret so agent can call back to ONE
138
+ const oneKey = readApiKey();
139
+ if (oneKey) {
140
+ await avFetch('POST', '/hosting/secrets', { address, name: 'ONEIE_API_KEY', secret: oneKey }).catch(() => { });
141
+ }
142
+ // 4. Start
143
+ await avFetch('POST', `/hosting/agents/${address}/start`, {});
144
+ // 5. Poll for compiled (up to 60s)
145
+ let compiled = false;
146
+ let walletAddress;
147
+ for (let i = 0; i < 12; i++) {
148
+ await new Promise(r => setTimeout(r, 5000));
149
+ const status = await avFetch('GET', `/hosting/agents/${address}`);
150
+ if (status.compiled || status.running) {
151
+ compiled = true;
152
+ walletAddress = status.wallet_address;
153
+ break;
154
+ }
155
+ }
156
+ out(cmd, {
157
+ ok: true,
158
+ target: 'agentverse',
159
+ agentAddress: address,
160
+ walletAddress,
161
+ compiled,
162
+ agentName,
163
+ agentverseUrl: `https://agentverse.ai/agents/details/${address}`,
164
+ });
165
+ }
166
+ catch (err) {
167
+ out(cmd, { ok: false, error: err.message });
168
+ }
169
+ return;
170
+ }
171
+ // ── ONE workspace publish path (default) ─────────────────────────────
86
172
  if (!opts.slug) {
87
173
  out(cmd, { ok: false, error: 'missing --slug <workspace>' });
88
174
  return;
@@ -92,19 +178,12 @@ export function agentCmd() {
92
178
  out(cmd, { ok: false, error: 'no API key — run `oneie auth login --key <key>` or set ONEIE_API_KEY' });
93
179
  return;
94
180
  }
95
- const content = readFileSync(path, 'utf8');
96
- // Derive publish name from frontmatter `name:` first (canonical), then
97
- // --name override, then basename. Convention is `<name>/agent.md` so
98
- // basename alone is rarely right.
99
- const frontmatterName = /^name:\s*(\S+)/m.exec(content)?.[1];
100
- const name = opts.name ?? frontmatterName ?? basename(path, '.md');
101
- // Owner-scoped Bearer convention from /api/agents/* — slug:token
102
181
  const token = `${opts.slug}:${key}`;
103
182
  try {
104
183
  const res = await fetch(`${opts.api.replace(/\/$/, '')}/api/agents/publish`, {
105
184
  method: 'POST',
106
185
  headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` },
107
- body: JSON.stringify({ slug: opts.slug, name, content }),
186
+ body: JSON.stringify({ slug: opts.slug, name: agentName, content }),
108
187
  });
109
188
  const text = await res.text();
110
189
  const data = text ? JSON.parse(text) : {};
@@ -670,7 +749,7 @@ function compileTarget(content, target) {
670
749
  if (target === 'mcp')
671
750
  return JSON.stringify({ tools: [] }, null, 2);
672
751
  if (target === 'uagents')
673
- return '# Python uAgents output — run oneie-py for full compile\n' + content;
752
+ return compileAgent(content, { target: 'uagents' });
674
753
  if (target === 'web') {
675
754
  // Emit a typed TS module — the web app can import this at build time
676
755
  // instead of parsing .md at request time. Matches the SDK's compileWeb()
@@ -0,0 +1,4 @@
1
+ import { Command } from 'commander';
2
+ /** `one broadcast` — operate newsletters from the terminal.
3
+ * Two verbs: list + send. Both hit broadcast:* receivers via ask(); no new route. */
4
+ export declare function broadcastCmd(): Command;
@@ -0,0 +1,45 @@
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 broadcast` — operate newsletters from the terminal.
26
+ * Two verbs: list + send. Both hit broadcast:* receivers via ask(); no new route. */
27
+ export function broadcastCmd() {
28
+ const cmd = new Command('broadcast').description('Operate email broadcasts (newsletters)');
29
+ cmd
30
+ .command('list')
31
+ .description('List broadcasts for the workspace')
32
+ .option('--limit <n>', 'Max results', '20')
33
+ .option('--api <url>', 'API base URL', DEFAULT_API)
34
+ .action(async (opts) => {
35
+ out(await ask(opts.api, 'broadcast:list', { limit: Number(opts.limit) }));
36
+ });
37
+ cmd
38
+ .command('send <id>')
39
+ .description('Send a broadcast now (inline drain, suppression-checked)')
40
+ .option('--api <url>', 'API base URL', DEFAULT_API)
41
+ .action(async (id, opts) => {
42
+ out(await ask(opts.api, 'broadcast:send', { broadcastId: id }));
43
+ });
44
+ return cmd;
45
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function connectCmd(): Command;
@@ -0,0 +1,86 @@
1
+ import { Command } from 'commander';
2
+ import { existsSync, readFileSync } from 'node:fs';
3
+ import { homedir } from 'node:os';
4
+ import { resolve } from 'node:path';
5
+ const DEFAULT_API = 'https://one.ie';
6
+ const KEY_FILE = resolve(homedir(), '.config', 'oneie', 'key');
7
+ function readApiKey() {
8
+ if (process.env.ONEIE_API_KEY)
9
+ return process.env.ONEIE_API_KEY;
10
+ if (existsSync(KEY_FILE))
11
+ return readFileSync(KEY_FILE, 'utf8').trim() || null;
12
+ return null;
13
+ }
14
+ function out(cmd, data) {
15
+ const isJson = cmd.parent?.parent?.opts().json;
16
+ if (isJson) {
17
+ process.stdout.write(JSON.stringify(data) + '\n');
18
+ }
19
+ else if (data.ok) {
20
+ const pairs = Object.entries(data)
21
+ .filter(([k]) => k !== 'ok')
22
+ .map(([k, v]) => `${k}=${JSON.stringify(v)}`);
23
+ process.stdout.write(`ok ${pairs.join(' ')}\n`);
24
+ }
25
+ else {
26
+ process.stderr.write(`error ${data.error ?? 'unknown'}\n`);
27
+ process.exit(1);
28
+ }
29
+ }
30
+ // `one connect <channel> --token <t>` — token-paste connect. The CLI never
31
+ // implements getMe/setWebhook; it POSTs to the web /api/connect/<channel> route
32
+ // which verifies + hands the secret to channels' sealed sink. The token is sent
33
+ // once in the request body and is NEVER echoed back to stdout (out() prints
34
+ // only the route's response, which carries status + public handle, no secret).
35
+ // With no channel argument it lists connection status (GET /api/connect/status).
36
+ export function connectCmd() {
37
+ const cmd = new Command('connect').description('Connect a channel to your workspace, or list connected channels with no argument');
38
+ cmd
39
+ .argument('[channel]', 'Channel to connect (telegram); omit to list status')
40
+ .option('--token <token>', 'Channel credential (e.g. @BotFather bot token)')
41
+ .option('--slug <slug>', 'Workspace slug (defaults to the authenticated owner)')
42
+ .option('--api <url>', 'API base URL', DEFAULT_API)
43
+ .action(async (channel, opts) => {
44
+ const key = readApiKey();
45
+ if (!key) {
46
+ out(cmd, { ok: false, error: 'no API key — run: oneie auth login' });
47
+ return;
48
+ }
49
+ const base = opts.api.replace(/\/$/, '');
50
+ if (!channel) {
51
+ // status listing — read-only, never carries credentials either way
52
+ const res = await fetch(`${base}/api/connect/status`, {
53
+ headers: { Authorization: `Bearer ${key}` },
54
+ });
55
+ if (!res.ok) {
56
+ const data = (await res.json().catch(() => ({})));
57
+ out(cmd, { ok: false, error: `${res.status}: ${data.error ?? 'status failed'}` });
58
+ return;
59
+ }
60
+ const data = (await res.json());
61
+ const connections = data.connections ?? [];
62
+ out(cmd, { ok: true, connected: connections.length, connections });
63
+ return;
64
+ }
65
+ if (!opts.token) {
66
+ out(cmd, { ok: false, error: 'token required — e.g. one connect telegram --token <t>' });
67
+ return;
68
+ }
69
+ const body = { token: opts.token };
70
+ if (opts.slug)
71
+ body.slug = opts.slug;
72
+ const res = await fetch(`${base}/api/connect/${encodeURIComponent(channel)}`, {
73
+ method: 'POST',
74
+ headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${key}` },
75
+ body: JSON.stringify(body),
76
+ });
77
+ if (!res.ok) {
78
+ const data = (await res.json().catch(() => ({})));
79
+ out(cmd, { ok: false, error: `${res.status}: ${data.error ?? 'connect failed'}` });
80
+ return;
81
+ }
82
+ const data = (await res.json());
83
+ out(cmd, { ok: true, channel, status: data.status ?? 'active', account: data.username ?? data.inbound });
84
+ });
85
+ return cmd;
86
+ }
@@ -158,8 +158,10 @@ export async function pollForToken(base, clientId, deviceCode, intervalSec, expi
158
158
  if (result.status === 'pending') {
159
159
  continue;
160
160
  }
161
- // Terminal error
162
- throw new Error(`auth failed [${result.code}]: ${result.message}`);
161
+ // Terminal error — narrow off the discriminant so code/message are present
162
+ if (result.status === 'error') {
163
+ throw new Error(`auth failed [${result.code}]: ${result.message}`);
164
+ }
163
165
  }
164
166
  throw new Error('Device code expired. Run `oneie auth login` to try again.');
165
167
  }
package/dist/src/index.js CHANGED
@@ -6,6 +6,8 @@ import { authCmd } from './auth.js';
6
6
  import { devCmd } from './dev.js';
7
7
  import { groupCmd } from './group.js';
8
8
  import { socialCmd } from './social.js';
9
+ import { connectCmd } from './connect.js';
10
+ import { broadcastCmd } from './broadcast.js';
9
11
  import { substrateCommands } from './substrate.js';
10
12
  import { readFileSync } from 'node:fs';
11
13
  import { fileURLToPath } from 'node:url';
@@ -23,6 +25,8 @@ program.addCommand(authCmd());
23
25
  program.addCommand(devCmd());
24
26
  program.addCommand(groupCmd());
25
27
  program.addCommand(socialCmd());
28
+ program.addCommand(connectCmd());
29
+ program.addCommand(broadcastCmd());
26
30
  substrateCommands(program);
27
31
  program.parseAsync(process.argv).catch((err) => {
28
32
  const isJson = process.argv.includes('--json');
package/dist/src/skill.js CHANGED
@@ -271,6 +271,7 @@ export function skillCmd() {
271
271
  });
272
272
  return cmd;
273
273
  }
274
+ // Mirrors one.ie/web/src/lib/eval/evals-source.ts and packages/mcp/src/tools/lifecycle.ts
274
275
  function extractEvals(content) {
275
276
  const fm = content.match(/^---\n([\s\S]*?)\n---/)?.[1];
276
277
  if (!fm)
@@ -279,6 +280,7 @@ function extractEvals(content) {
279
280
  const startIdx = lines.findIndex(l => /^evals:\s*$/.test(l));
280
281
  if (startIdx < 0)
281
282
  return [];
283
+ const unquote = (s) => s.replace(/^["']|["']$/g, '');
282
284
  const cases = [];
283
285
  let cur = null;
284
286
  let inAssertions = false;
@@ -290,23 +292,33 @@ function extractEvals(content) {
290
292
  if (promptMatch) {
291
293
  if (cur)
292
294
  cases.push(cur);
293
- cur = { prompt: promptMatch[1].replace(/^["']|["']$/g, ''), assertions: [] };
295
+ cur = { id: `case-${cases.length + 1}`, prompt: unquote(promptMatch[1]), expected: '', assertions: [] };
294
296
  inAssertions = false;
295
297
  continue;
296
298
  }
297
299
  if (!cur)
298
300
  continue;
301
+ const idMatch = line.match(/^\s+id:\s*(.+?)\s*$/);
302
+ if (idMatch) {
303
+ cur.id = unquote(idMatch[1]);
304
+ continue;
305
+ }
306
+ const expectedMatch = line.match(/^\s+expected:\s*(.+?)\s*$/);
307
+ if (expectedMatch) {
308
+ cur.expected = unquote(expectedMatch[1]);
309
+ continue;
310
+ }
299
311
  if (/^\s+assertions:\s*$/.test(line)) {
300
312
  inAssertions = true;
301
313
  continue;
302
314
  }
303
315
  const itemMatch = line.match(/^\s+-\s+(.+?)\s*$/);
304
316
  if (itemMatch && inAssertions)
305
- cur.assertions.push(itemMatch[1].replace(/^["']|["']$/g, ''));
317
+ cur.assertions.push(unquote(itemMatch[1]));
306
318
  }
307
319
  if (cur)
308
320
  cases.push(cur);
309
- return cases;
321
+ return cases.filter(c => c.prompt && c.assertions.length > 0);
310
322
  }
311
323
  function out(cmd, data) {
312
324
  const isJson = cmd.parent?.opts().json;
@@ -1,4 +1,4 @@
1
- const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_BASE_URL ?? 'https://one.ie';
1
+ const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_BASE_URL ?? 'https://api.one.ie';
2
2
  function apiKey() {
3
3
  return process.env.ONEIE_API_KEY ?? process.env.ONE_API_KEY ?? '';
4
4
  }
@@ -129,7 +129,7 @@ export function substrateCommands(program) {
129
129
  });
130
130
  program
131
131
  .command('select <type>')
132
- .description('Probabilistic path selection (pheromone-weighted)')
132
+ .description('Probabilistic path selection (strength-weighted)')
133
133
  .option('--exploration <n>', 'Exploration factor 0–1')
134
134
  .option('--api <url>', 'API base URL', DEFAULT_API)
135
135
  .action(async (type, opts) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oneie/cli",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "ONE agent CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -18,7 +18,8 @@
18
18
  "prepublishOnly": "bun run build"
19
19
  },
20
20
  "dependencies": {
21
- "commander": "^12.0.0"
21
+ "commander": "^12.0.0",
22
+ "@oneie/sdk": "workspace:*"
22
23
  },
23
24
  "devDependencies": {
24
25
  "@types/node": "^25.6.0",