@oneie/cli 0.5.4 → 0.5.5
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/README.md +13 -0
- package/dist/package.json +3 -3
- package/dist/src/chat.d.ts +2 -0
- package/dist/src/chat.js +98 -0
- package/dist/src/index.js +2 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -65,6 +65,19 @@ one login --key <key> # stored at ~/.config/oneie/key (0600)
|
|
|
65
65
|
|
|
66
66
|
Workspace operations use a Bearer token `<slug>:<key>`. Override the API base per command with `--api` (default `https://one.ie`).
|
|
67
67
|
|
|
68
|
+
## Chat — fan in · fan out
|
|
69
|
+
|
|
70
|
+
Send to a space, broadcast to all, or stream incoming messages:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
one chat "deploy shipped" # broadcast to vespio · elitemoversca · world
|
|
74
|
+
one chat send --to vespio "hey donal, PR is ready" # targeted
|
|
75
|
+
one chat broadcast "all green" --spaces vespio,elitemoversca # explicit fan-out
|
|
76
|
+
one chat listen vespio # stream incoming SSE (Ctrl+C to stop)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Every `chat send` routes through `space:post` — authenticated, mirrored to `one.ie/u/<space>/in`, delivered to every connected SSE listener.
|
|
80
|
+
|
|
68
81
|
## Links
|
|
69
82
|
|
|
70
83
|
- Platform: **https://one.ie**
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oneie/cli",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.5",
|
|
4
4
|
"description": "ONE agent CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"commander": "^12.0.0",
|
|
23
|
-
"@oneie/sdk": "
|
|
24
|
-
"@oneie/evals": "
|
|
23
|
+
"@oneie/sdk": "workspace:*",
|
|
24
|
+
"@oneie/evals": "workspace:*"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/node": "^25.6.0",
|
package/dist/src/chat.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_BASE_URL ?? 'https://one.ie';
|
|
3
|
+
const DEFAULT_CHANNELS = process.env.CHANNELS_URL ?? 'https://channels.one.ie';
|
|
4
|
+
const DEFAULT_SPACES = ['vespio', 'elitemoversca', 'world'];
|
|
5
|
+
function headers() {
|
|
6
|
+
const h = { 'Content-Type': 'application/json' };
|
|
7
|
+
const k = process.env.ONEIE_API_KEY ?? process.env.ONE_API_KEY ?? '';
|
|
8
|
+
if (k)
|
|
9
|
+
h['Authorization'] = `Bearer ${k}`;
|
|
10
|
+
return h;
|
|
11
|
+
}
|
|
12
|
+
async function spacePost(api, space, content) {
|
|
13
|
+
const res = await fetch(`${api.replace(/\/$/, '')}/api/ask/space:post`, {
|
|
14
|
+
method: 'POST',
|
|
15
|
+
headers: headers(),
|
|
16
|
+
body: JSON.stringify({ data: { space, content } }),
|
|
17
|
+
});
|
|
18
|
+
if (!res.ok)
|
|
19
|
+
return { ok: false, error: `HTTP ${res.status}` };
|
|
20
|
+
const j = await res.json();
|
|
21
|
+
return j.result ?? { ok: j.outcome === 'result', error: j.error };
|
|
22
|
+
}
|
|
23
|
+
export function chatCmd() {
|
|
24
|
+
const cmd = new Command('chat')
|
|
25
|
+
.description('Send messages to Spaces (fan-out) or listen for incoming messages (fan-in)');
|
|
26
|
+
// one chat "text" [--to space] [--broadcast]
|
|
27
|
+
cmd
|
|
28
|
+
.command('send <text>', { isDefault: true })
|
|
29
|
+
.description('Send a message to a Space (default: broadcast to all)')
|
|
30
|
+
.option('--to <space>', 'Target space slug (default: broadcast to vespio + elitemoversca + world)')
|
|
31
|
+
.option('--api <url>', 'API base URL', DEFAULT_API)
|
|
32
|
+
.action(async (text, opts) => {
|
|
33
|
+
if (opts.to) {
|
|
34
|
+
const r = await spacePost(opts.api, opts.to, text);
|
|
35
|
+
process.stdout.write(JSON.stringify(r, null, 2) + '\n');
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
const results = await Promise.all(DEFAULT_SPACES.map(s => spacePost(opts.api, s, text)));
|
|
39
|
+
results.forEach((r, i) => process.stdout.write(`→ space:${DEFAULT_SPACES[i]} ${r.ok ? r.id : r.error}\n`));
|
|
40
|
+
process.stdout.write(`ok broadcast to ${DEFAULT_SPACES.length} spaces\n`);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
// one chat broadcast "text"
|
|
44
|
+
cmd
|
|
45
|
+
.command('broadcast <text>')
|
|
46
|
+
.description('Fan-out to all default spaces (vespio + elitemoversca + world)')
|
|
47
|
+
.option('--spaces <list>', 'Comma-separated space slugs', DEFAULT_SPACES.join(','))
|
|
48
|
+
.option('--api <url>', 'API base URL', DEFAULT_API)
|
|
49
|
+
.action(async (text, opts) => {
|
|
50
|
+
const spaces = opts.spaces.split(',').map(s => s.trim()).filter(Boolean);
|
|
51
|
+
const results = await Promise.all(spaces.map(s => spacePost(opts.api, s, text)));
|
|
52
|
+
results.forEach((r, i) => process.stdout.write(`→ space:${spaces[i]} ${r.ok ? r.id : r.error}\n`));
|
|
53
|
+
process.stdout.write(`ok broadcast to ${spaces.length} spaces\n`);
|
|
54
|
+
});
|
|
55
|
+
// one chat listen <space>
|
|
56
|
+
cmd
|
|
57
|
+
.command('listen <space>')
|
|
58
|
+
.description('Stream incoming messages from a Space via SSE (Ctrl+C to stop)')
|
|
59
|
+
.option('--channels <url>', 'Channels base URL', DEFAULT_CHANNELS)
|
|
60
|
+
.action(async (space, opts) => {
|
|
61
|
+
const group = space.startsWith('space:') ? space : `space:${space}`;
|
|
62
|
+
const url = `${opts.channels.replace(/\/$/, '')}/stream/${encodeURIComponent(group)}`;
|
|
63
|
+
process.stderr.write(`Listening on ${group} — Ctrl+C to stop\n`);
|
|
64
|
+
const key = process.env.ONEIE_API_KEY ?? process.env.ONE_API_KEY ?? '';
|
|
65
|
+
const h = { Accept: 'text/event-stream' };
|
|
66
|
+
if (key)
|
|
67
|
+
h['Authorization'] = `Bearer ${key}`;
|
|
68
|
+
const res = await fetch(url, { headers: h });
|
|
69
|
+
if (!res.ok || !res.body) {
|
|
70
|
+
process.stderr.write(`stream error: ${res.status}\n`);
|
|
71
|
+
process.exit(1);
|
|
72
|
+
}
|
|
73
|
+
const reader = res.body.getReader();
|
|
74
|
+
const dec = new TextDecoder();
|
|
75
|
+
while (true) {
|
|
76
|
+
const { done, value } = await reader.read();
|
|
77
|
+
if (done)
|
|
78
|
+
break;
|
|
79
|
+
const chunk = dec.decode(value);
|
|
80
|
+
for (const line of chunk.split('\n')) {
|
|
81
|
+
if (!line.startsWith('data:'))
|
|
82
|
+
continue;
|
|
83
|
+
const raw = line.slice(5).trim();
|
|
84
|
+
if (!raw || raw === '[DONE]')
|
|
85
|
+
continue;
|
|
86
|
+
try {
|
|
87
|
+
const msg = JSON.parse(raw);
|
|
88
|
+
const t = msg.ts ? new Date(msg.ts).toISOString().slice(11, 19) : '';
|
|
89
|
+
process.stdout.write(`[${t}] ${msg.sender ?? '?'}: ${msg.content ?? raw}\n`);
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
process.stdout.write(raw + '\n');
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
return cmd;
|
|
98
|
+
}
|
package/dist/src/index.js
CHANGED
|
@@ -8,6 +8,7 @@ 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 { chatCmd } from './chat.js';
|
|
11
12
|
import { linksCmd } from './links.js';
|
|
12
13
|
import { staffCmd } from './staff.js';
|
|
13
14
|
import { substrateCommands } from './substrate.js';
|
|
@@ -44,6 +45,7 @@ program.addCommand(groupCmd());
|
|
|
44
45
|
program.addCommand(socialCmd());
|
|
45
46
|
program.addCommand(connectCmd());
|
|
46
47
|
program.addCommand(broadcastCmd());
|
|
48
|
+
program.addCommand(chatCmd());
|
|
47
49
|
program.addCommand(newsletterCmd());
|
|
48
50
|
program.addCommand(linksCmd());
|
|
49
51
|
program.addCommand(staffCmd());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oneie/cli",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.5",
|
|
4
4
|
"description": "ONE agent CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"commander": "^12.0.0",
|
|
23
|
-
"@oneie/sdk": "
|
|
24
|
-
"@oneie/evals": "
|
|
23
|
+
"@oneie/sdk": "workspace:*",
|
|
24
|
+
"@oneie/evals": "workspace:*"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/node": "^25.6.0",
|