@oneie/cli 0.3.4 → 0.4.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/catalog.d.ts +3 -0
- package/dist/src/catalog.js +48 -0
- package/dist/src/client.d.ts +3 -0
- package/dist/src/client.js +196 -0
- package/dist/src/compiler.d.ts +22 -0
- package/dist/src/compiler.js +250 -0
- package/dist/src/coordinate.d.ts +3 -0
- package/dist/src/coordinate.js +71 -0
- package/dist/src/deploy.d.ts +3 -0
- package/dist/src/deploy.js +46 -0
- package/dist/src/env.d.ts +6 -0
- package/dist/src/env.js +30 -0
- package/dist/src/eval.d.ts +2 -0
- package/dist/src/eval.js +32 -0
- package/dist/src/index.js +20 -0
- package/dist/src/push.d.ts +3 -0
- package/dist/src/push.js +112 -0
- package/dist/src/setup.d.ts +3 -0
- package/dist/src/setup.js +147 -0
- package/dist/src/ship.d.ts +3 -0
- package/dist/src/ship.js +41 -0
- package/dist/src/skill.js +39 -0
- package/dist/src/slug.d.ts +5 -0
- package/dist/src/slug.js +9 -0
- package/dist/src/staff.js +46 -5
- package/dist/src/status.d.ts +3 -0
- package/dist/src/status.js +51 -0
- package/dist/src/templates/_node/site/one.config.d.ts +2 -0
- package/dist/src/templates/_node/site/one.config.js +22 -0
- package/dist/src/trade.d.ts +3 -0
- package/dist/src/trade.js +97 -0
- package/dist/src/validate.d.ts +12 -0
- package/dist/src/validate.js +37 -0
- package/package.json +3 -2
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/** `one market|hire|bounty|earn|usage` — trade layer commands. */
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_BASE_URL ?? 'https://api.one.ie';
|
|
4
|
+
function apiKey() {
|
|
5
|
+
return process.env.ONEIE_API_KEY ?? process.env.ONE_API_KEY ?? '';
|
|
6
|
+
}
|
|
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();
|
|
14
|
+
}
|
|
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;
|
|
20
|
+
}
|
|
21
|
+
const d = data;
|
|
22
|
+
if (d?.kind === 'failure') {
|
|
23
|
+
process.stderr.write(` x ${d?.error ?? 'failed'}\n`);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (d?.kind === 'result') {
|
|
27
|
+
const r = d.result;
|
|
28
|
+
if (typeof r === 'object' && r !== null) {
|
|
29
|
+
for (const [k, v] of Object.entries(r)) {
|
|
30
|
+
if (typeof v !== 'object')
|
|
31
|
+
process.stdout.write(` ${k}: ${v}\n`);
|
|
32
|
+
}
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
process.stdout.write(JSON.stringify(data, null, 2) + '\n');
|
|
37
|
+
}
|
|
38
|
+
export function tradeCmd() {
|
|
39
|
+
const cmd = new Command('trade').description('Trade layer — market, hire, bounty, earn, usage');
|
|
40
|
+
cmd.command('market')
|
|
41
|
+
.description('List the capability market')
|
|
42
|
+
.argument('[query]', 'Optional search term')
|
|
43
|
+
.option('--limit <n>', 'Max results', '20')
|
|
44
|
+
.option('--api <url>', 'API base URL', DEFAULT_API)
|
|
45
|
+
.action(async (query, opts) => {
|
|
46
|
+
const base = opts.api.replace(/\/$/, '');
|
|
47
|
+
const result = await ask(base, 'market:list', { query, limit: Number(opts.limit) });
|
|
48
|
+
out(cmd, result);
|
|
49
|
+
});
|
|
50
|
+
cmd.command('hire <skillId>')
|
|
51
|
+
.description('Hire a peer agent for a skill')
|
|
52
|
+
.option('--budget <credits>', 'Credit budget', '1000')
|
|
53
|
+
.option('--dry-run', 'Simulate (passes simulate:true)')
|
|
54
|
+
.option('--api <url>', 'API base URL', DEFAULT_API)
|
|
55
|
+
.action(async (skillId, opts) => {
|
|
56
|
+
const base = opts.api.replace(/\/$/, '');
|
|
57
|
+
const result = await ask(base, 'market:hire', {
|
|
58
|
+
skillId, budget: Number(opts.budget), simulate: opts.dryRun ?? false,
|
|
59
|
+
});
|
|
60
|
+
out(cmd, result);
|
|
61
|
+
});
|
|
62
|
+
cmd.command('bounty <skillId>')
|
|
63
|
+
.description('Post a bounty for a skill')
|
|
64
|
+
.requiredOption('--price <credits>', 'Bounty price in credits')
|
|
65
|
+
.option('--dry-run', 'Simulate (passes simulate:true)')
|
|
66
|
+
.option('--api <url>', 'API base URL', DEFAULT_API)
|
|
67
|
+
.action(async (skillId, opts) => {
|
|
68
|
+
const base = opts.api.replace(/\/$/, '');
|
|
69
|
+
const result = await ask(base, 'market:bounty', {
|
|
70
|
+
skillId, price: Number(opts.price), simulate: opts.dryRun ?? false,
|
|
71
|
+
});
|
|
72
|
+
out(cmd, result);
|
|
73
|
+
});
|
|
74
|
+
cmd.command('earn')
|
|
75
|
+
.description('Accept a payment (pay:weight)')
|
|
76
|
+
.option('--bounty-id <id>', 'Bounty to settle')
|
|
77
|
+
.option('--dry-run', 'Simulate (passes simulate:true)')
|
|
78
|
+
.option('--api <url>', 'API base URL', DEFAULT_API)
|
|
79
|
+
.action(async (opts) => {
|
|
80
|
+
const base = opts.api.replace(/\/$/, '');
|
|
81
|
+
const result = await ask(base, 'pay:weight', {
|
|
82
|
+
bountyId: opts.bountyId, simulate: opts.dryRun ?? false,
|
|
83
|
+
});
|
|
84
|
+
out(cmd, result);
|
|
85
|
+
});
|
|
86
|
+
cmd.command('usage')
|
|
87
|
+
.description('Plan metering — credit balance, burns, quota')
|
|
88
|
+
.option('--slug <slug>', 'Workspace slug')
|
|
89
|
+
.option('--api <url>', 'API base URL', DEFAULT_API)
|
|
90
|
+
.action(async (opts) => {
|
|
91
|
+
const base = opts.api.replace(/\/$/, '');
|
|
92
|
+
const slug = opts.slug ?? process.env.ONEIE_SLUG ?? process.env.ONE_SLUG ?? '';
|
|
93
|
+
const result = await ask(base, 'dashboard:usage', { slug });
|
|
94
|
+
out(cmd, result);
|
|
95
|
+
});
|
|
96
|
+
return cmd;
|
|
97
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface ValidationResult {
|
|
2
|
+
ok: boolean;
|
|
3
|
+
errors: string[];
|
|
4
|
+
warnings: string[];
|
|
5
|
+
}
|
|
6
|
+
/** Validate that `dir` looks like a valid node root. */
|
|
7
|
+
export declare function validateNodeDir(dir: string): ValidationResult;
|
|
8
|
+
/** Parse YAML-style frontmatter from a Markdown file. */
|
|
9
|
+
export declare function parseFrontmatter(content: string): {
|
|
10
|
+
fm: Record<string, string>;
|
|
11
|
+
body: string;
|
|
12
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** Structural validation for nodes before `one push`. */
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { resolve } from 'node:path';
|
|
4
|
+
/** Validate that `dir` looks like a valid node root. */
|
|
5
|
+
export function validateNodeDir(dir) {
|
|
6
|
+
const errors = [];
|
|
7
|
+
const warnings = [];
|
|
8
|
+
const hasToml = existsSync(resolve(dir, '_node.toml')) ||
|
|
9
|
+
existsSync(resolve(dir, 'agency.toml')) ||
|
|
10
|
+
existsSync(resolve(dir, 'client.toml'));
|
|
11
|
+
if (!hasToml) {
|
|
12
|
+
errors.push(`No _node.toml / agency.toml / client.toml found in ${dir}`);
|
|
13
|
+
}
|
|
14
|
+
if (!existsSync(resolve(dir, 'ai'))) {
|
|
15
|
+
warnings.push('ai/ directory missing — nothing to push for agents/skills');
|
|
16
|
+
}
|
|
17
|
+
if (!existsSync(resolve(dir, 'data'))) {
|
|
18
|
+
warnings.push('data/ directory missing — nothing to push for types/lifecycles');
|
|
19
|
+
}
|
|
20
|
+
return { ok: errors.length === 0, errors, warnings };
|
|
21
|
+
}
|
|
22
|
+
/** Parse YAML-style frontmatter from a Markdown file. */
|
|
23
|
+
export function parseFrontmatter(content) {
|
|
24
|
+
const fm = {};
|
|
25
|
+
if (!content.startsWith('---'))
|
|
26
|
+
return { fm, body: content };
|
|
27
|
+
const end = content.indexOf('\n---', 3);
|
|
28
|
+
if (end < 0)
|
|
29
|
+
return { fm, body: content };
|
|
30
|
+
for (const line of content.slice(3, end).split('\n')) {
|
|
31
|
+
const col = line.indexOf(':');
|
|
32
|
+
if (col < 0)
|
|
33
|
+
continue;
|
|
34
|
+
fm[line.slice(0, col).trim()] = line.slice(col + 1).trim();
|
|
35
|
+
}
|
|
36
|
+
return { fm, body: content.slice(end + 4).trim() };
|
|
37
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oneie/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "ONE agent CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"commander": "^12.0.0",
|
|
22
|
-
"@oneie/sdk": "
|
|
22
|
+
"@oneie/sdk": "^0.14.0",
|
|
23
|
+
"@oneie/evals": "^0.1.0"
|
|
23
24
|
},
|
|
24
25
|
"devDependencies": {
|
|
25
26
|
"@types/node": "^25.6.0",
|