hypha-cli 0.1.12 → 0.1.13
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/channel-wm4EXm8s.mjs +101 -0
- package/dist/cli.mjs +8 -0
- package/package.json +2 -2
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { e as hasFlag, c as connectToHypha, i as getFlag, f as formatJson } from './helpers-BC4AKy6a.mjs';
|
|
2
|
+
import 'fs';
|
|
3
|
+
import 'path';
|
|
4
|
+
import 'os';
|
|
5
|
+
|
|
6
|
+
const HELP = `Usage: hypha channel <list|describe|send>
|
|
7
|
+
|
|
8
|
+
Message a Svamp session's Channels over Hypha RPC (verified identity, no key).
|
|
9
|
+
|
|
10
|
+
list [--workspace <ws>] [--json]
|
|
11
|
+
Discover svamp-channels services and the channels each exposes.
|
|
12
|
+
|
|
13
|
+
describe <service-id> <channel> [--json]
|
|
14
|
+
Show a channel's descriptor + skill (how to call it).
|
|
15
|
+
|
|
16
|
+
send <service-id> <channel> <message> [--from <name>] [--key <key>] [--json]
|
|
17
|
+
Send a message to a channel. <service-id> e.g. ws-user-x/abc123:channels
|
|
18
|
+
(from 'hypha channel list'). Your identity is your verified Hypha user.`;
|
|
19
|
+
async function channelCommand(args) {
|
|
20
|
+
const sub = args[0];
|
|
21
|
+
if (!sub || hasFlag(args, "--help", "-h")) {
|
|
22
|
+
console.log(HELP);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const json = hasFlag(args, "--json");
|
|
26
|
+
const rest = args.slice(1).filter((a) => !a.startsWith("-"));
|
|
27
|
+
const server = await connectToHypha();
|
|
28
|
+
try {
|
|
29
|
+
if (sub === "list") {
|
|
30
|
+
const ws = getFlag(args, "--workspace");
|
|
31
|
+
const query = { type: "svamp-channels" };
|
|
32
|
+
if (ws) query.workspace = ws;
|
|
33
|
+
const services = await server.listServices(query);
|
|
34
|
+
const rows = [];
|
|
35
|
+
for (const s of services || []) {
|
|
36
|
+
try {
|
|
37
|
+
const svc = await server.getService(s.id);
|
|
38
|
+
const channels = await svc.list();
|
|
39
|
+
for (const c of channels || []) rows.push({ service: s.id, channel: c.name, description: c.description || "", identity: c.identity?.mode });
|
|
40
|
+
} catch {
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (json) {
|
|
44
|
+
console.log(formatJson(rows));
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (!rows.length) {
|
|
48
|
+
console.log("No channels found.");
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
for (const r of rows) console.log(`${r.channel} [${r.identity || "?"}] ${r.description}
|
|
52
|
+
service: ${r.service}`);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (sub === "describe") {
|
|
56
|
+
const [serviceId, channel] = rest;
|
|
57
|
+
if (!serviceId || !channel) {
|
|
58
|
+
console.error("usage: hypha channel describe <service-id> <channel>");
|
|
59
|
+
process.exitCode = 1;
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const svc = await server.getService(serviceId);
|
|
63
|
+
const info = await svc.describe({ channel });
|
|
64
|
+
console.log(json ? formatJson(info) : info?.skill?.body || formatJson(info));
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (sub === "send") {
|
|
68
|
+
const [serviceId, channel, ...msgParts] = rest;
|
|
69
|
+
const message = msgParts.join(" ");
|
|
70
|
+
if (!serviceId || !channel || !message) {
|
|
71
|
+
console.error("usage: hypha channel send <service-id> <channel> <message> [--from name]");
|
|
72
|
+
process.exitCode = 1;
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const from = getFlag(args, "--from");
|
|
76
|
+
const key = getFlag(args, "--key");
|
|
77
|
+
const svc = await server.getService(serviceId);
|
|
78
|
+
const result = await svc.send({ channel, message, from, key });
|
|
79
|
+
if (result?.error) {
|
|
80
|
+
console.error(`\u2717 ${result.error}`);
|
|
81
|
+
process.exitCode = 1;
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (json) {
|
|
85
|
+
console.log(formatJson(result));
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (typeof result?.reply === "string" && result.reply) {
|
|
89
|
+
console.log(result.reply);
|
|
90
|
+
} else {
|
|
91
|
+
console.log(`\u2713 sent to ${channel} (call ${result?.call_id ?? "?"}, ${result?.status ?? "ok"})`);
|
|
92
|
+
}
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
console.log(HELP);
|
|
96
|
+
} finally {
|
|
97
|
+
await server.disconnect();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export { channelCommand };
|
package/dist/cli.mjs
CHANGED
|
@@ -56,6 +56,11 @@ Artifacts (manage data, models, and files):
|
|
|
56
56
|
artifacts edit <artifact> Edit artifact metadata
|
|
57
57
|
artifacts discard <artifact> Discard staged changes
|
|
58
58
|
|
|
59
|
+
Channels (message Svamp sessions / agents \u2014 agent-to-agent):
|
|
60
|
+
channel list [--workspace ws] Discover channels (svamp-channels services)
|
|
61
|
+
channel describe <svc> <ch> Show a channel's descriptor + skill
|
|
62
|
+
channel send <svc> <ch> <msg> Send a message to a channel (--from name)
|
|
63
|
+
|
|
59
64
|
Global options:
|
|
60
65
|
--server <url> Hypha server URL (overrides env/config)
|
|
61
66
|
--workspace <ws> Workspace ID (overrides env/config)
|
|
@@ -109,6 +114,9 @@ async function main() {
|
|
|
109
114
|
} else if (subcommand === "artifacts" || subcommand === "art") {
|
|
110
115
|
const { handleArtifactsCommand } = await import('./artifacts-DHPJIrSS.mjs');
|
|
111
116
|
await handleArtifactsCommand(commandArgs);
|
|
117
|
+
} else if (subcommand === "channel" || subcommand === "channels") {
|
|
118
|
+
const { channelCommand } = await import('./channel-wm4EXm8s.mjs');
|
|
119
|
+
await channelCommand(commandArgs);
|
|
112
120
|
} else {
|
|
113
121
|
console.error(`Unknown command: ${subcommand}`);
|
|
114
122
|
console.error("Run `hypha --help` for usage.");
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hypha-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
4
4
|
"description": "Hypha Cloud CLI — manage workspaces, apps, and artifacts",
|
|
5
5
|
"author": "Amun AI AB",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"bin": {
|
|
9
|
-
"hypha": "
|
|
9
|
+
"hypha": "bin/hypha.mjs"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
12
|
"dist",
|