svamp-cli 0.1.4 → 0.1.6
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/cli.mjs +173 -8
- package/dist/index.mjs +3 -1
- package/dist/run-C2z4Zl9E.mjs +3617 -0
- package/dist/run-xiJdI9RG.mjs +2119 -0
- package/package.json +2 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { s as startDaemon, b as stopDaemon, d as daemonStatus } from './run-
|
|
1
|
+
import { s as startDaemon, b as stopDaemon, d as daemonStatus } from './run-C2z4Zl9E.mjs';
|
|
2
2
|
import 'os';
|
|
3
3
|
import 'fs/promises';
|
|
4
4
|
import 'fs';
|
|
@@ -13,6 +13,8 @@ import '@modelcontextprotocol/sdk/server/mcp.js';
|
|
|
13
13
|
import 'node:http';
|
|
14
14
|
import '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
15
15
|
import 'zod';
|
|
16
|
+
import 'node:child_process';
|
|
17
|
+
import '@agentclientprotocol/sdk';
|
|
16
18
|
|
|
17
19
|
const args = process.argv.slice(2);
|
|
18
20
|
const subcommand = args[0];
|
|
@@ -70,6 +72,8 @@ async function main() {
|
|
|
70
72
|
} else {
|
|
71
73
|
printDaemonHelp();
|
|
72
74
|
}
|
|
75
|
+
} else if (subcommand === "agent") {
|
|
76
|
+
await handleAgentCommand();
|
|
73
77
|
} else if (subcommand === "--help" || subcommand === "-h" || !subcommand) {
|
|
74
78
|
printHelp();
|
|
75
79
|
} else if (subcommand === "--version" || subcommand === "-v") {
|
|
@@ -80,6 +84,146 @@ async function main() {
|
|
|
80
84
|
process.exit(1);
|
|
81
85
|
}
|
|
82
86
|
}
|
|
87
|
+
async function handleAgentCommand() {
|
|
88
|
+
const agentArgs = args.slice(1);
|
|
89
|
+
if (agentArgs.length === 0 || agentArgs[0] === "--help" || agentArgs[0] === "-h") {
|
|
90
|
+
printAgentHelp();
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (agentArgs[0] === "list") {
|
|
94
|
+
const { KNOWN_ACP_AGENTS } = await import('./run-C2z4Zl9E.mjs').then(function (n) { return n.f; });
|
|
95
|
+
console.log("Known ACP agents:");
|
|
96
|
+
for (const [name, config2] of Object.entries(KNOWN_ACP_AGENTS)) {
|
|
97
|
+
console.log(` ${name.padEnd(12)} ${config2.command} ${config2.args.join(" ")}`);
|
|
98
|
+
}
|
|
99
|
+
console.log('\nUse "svamp agent <name>" to start an interactive session.');
|
|
100
|
+
console.log('Use "svamp agent -- <command> [args]" for a custom ACP agent.');
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const { resolveAcpAgentConfig } = await import('./run-C2z4Zl9E.mjs').then(function (n) { return n.f; });
|
|
104
|
+
const { AcpBackend } = await import('./run-C2z4Zl9E.mjs').then(function (n) { return n.e; });
|
|
105
|
+
const { GeminiTransport } = await import('./run-C2z4Zl9E.mjs').then(function (n) { return n.G; });
|
|
106
|
+
const { DefaultTransport } = await import('./run-C2z4Zl9E.mjs').then(function (n) { return n.D; });
|
|
107
|
+
let cwd = process.cwd();
|
|
108
|
+
const filteredArgs = [];
|
|
109
|
+
for (let i = 0; i < agentArgs.length; i++) {
|
|
110
|
+
if ((agentArgs[i] === "-d" || agentArgs[i] === "--directory") && i + 1 < agentArgs.length) {
|
|
111
|
+
cwd = agentArgs[i + 1];
|
|
112
|
+
i++;
|
|
113
|
+
} else {
|
|
114
|
+
filteredArgs.push(agentArgs[i]);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
let config;
|
|
118
|
+
try {
|
|
119
|
+
config = resolveAcpAgentConfig(filteredArgs);
|
|
120
|
+
} catch (err) {
|
|
121
|
+
console.error(err.message);
|
|
122
|
+
process.exit(1);
|
|
123
|
+
}
|
|
124
|
+
console.log(`Starting ${config.agentName} agent in ${cwd}...`);
|
|
125
|
+
const transportHandler = config.agentName === "gemini" ? new GeminiTransport() : new DefaultTransport(config.agentName);
|
|
126
|
+
const backend = new AcpBackend({
|
|
127
|
+
agentName: config.agentName,
|
|
128
|
+
cwd,
|
|
129
|
+
command: config.command,
|
|
130
|
+
args: config.args,
|
|
131
|
+
transportHandler,
|
|
132
|
+
log: (...logArgs) => {
|
|
133
|
+
if (process.env.DEBUG) {
|
|
134
|
+
console.error("[debug]", ...logArgs);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
let currentText = "";
|
|
139
|
+
backend.onMessage((msg) => {
|
|
140
|
+
switch (msg.type) {
|
|
141
|
+
case "model-output":
|
|
142
|
+
if (msg.textDelta) {
|
|
143
|
+
process.stdout.write(msg.textDelta);
|
|
144
|
+
currentText += msg.textDelta;
|
|
145
|
+
} else if (msg.fullText) {
|
|
146
|
+
process.stdout.write(msg.fullText);
|
|
147
|
+
}
|
|
148
|
+
break;
|
|
149
|
+
case "status":
|
|
150
|
+
if (msg.status === "idle") {
|
|
151
|
+
if (currentText && !currentText.endsWith("\n")) {
|
|
152
|
+
process.stdout.write("\n");
|
|
153
|
+
}
|
|
154
|
+
currentText = "";
|
|
155
|
+
process.stdout.write("\n> ");
|
|
156
|
+
} else if (msg.status === "error") {
|
|
157
|
+
console.error(`
|
|
158
|
+
Error: ${msg.detail}`);
|
|
159
|
+
} else if (msg.status === "stopped") {
|
|
160
|
+
console.log(`
|
|
161
|
+
Agent stopped: ${msg.detail || ""}`);
|
|
162
|
+
}
|
|
163
|
+
break;
|
|
164
|
+
case "tool-call":
|
|
165
|
+
console.log(`
|
|
166
|
+
[tool] ${msg.toolName}(${JSON.stringify(msg.args).substring(0, 100)})`);
|
|
167
|
+
break;
|
|
168
|
+
case "tool-result": {
|
|
169
|
+
const resultStr = typeof msg.result === "string" ? msg.result : JSON.stringify(msg.result);
|
|
170
|
+
if (resultStr.length > 200) {
|
|
171
|
+
console.log(`[tool result] ${resultStr.substring(0, 200)}...`);
|
|
172
|
+
}
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
case "event":
|
|
176
|
+
if (msg.name === "thinking") {
|
|
177
|
+
const payload = msg.payload;
|
|
178
|
+
if (payload?.text) {
|
|
179
|
+
process.stdout.write(`\x1B[90m${payload.text}\x1B[0m`);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
try {
|
|
186
|
+
const result = await backend.startSession();
|
|
187
|
+
console.log(`Session started: ${result.sessionId}`);
|
|
188
|
+
process.stdout.write("> ");
|
|
189
|
+
} catch (err) {
|
|
190
|
+
console.error(`Failed to start ${config.agentName}: ${err.message}`);
|
|
191
|
+
process.exit(1);
|
|
192
|
+
}
|
|
193
|
+
const readline = await import('readline');
|
|
194
|
+
const rl = readline.createInterface({
|
|
195
|
+
input: process.stdin,
|
|
196
|
+
output: process.stdout,
|
|
197
|
+
terminal: false
|
|
198
|
+
});
|
|
199
|
+
rl.on("line", async (line) => {
|
|
200
|
+
const trimmed = line.trim();
|
|
201
|
+
if (!trimmed) return;
|
|
202
|
+
if (trimmed === "/quit" || trimmed === "/exit") {
|
|
203
|
+
console.log("Shutting down...");
|
|
204
|
+
await backend.dispose();
|
|
205
|
+
process.exit(0);
|
|
206
|
+
}
|
|
207
|
+
if (trimmed === "/cancel") {
|
|
208
|
+
await backend.cancel("");
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
try {
|
|
212
|
+
await backend.sendPrompt("", trimmed);
|
|
213
|
+
} catch (err) {
|
|
214
|
+
console.error(`Error: ${err.message}`);
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
rl.on("close", async () => {
|
|
218
|
+
await backend.dispose();
|
|
219
|
+
process.exit(0);
|
|
220
|
+
});
|
|
221
|
+
process.on("SIGINT", async () => {
|
|
222
|
+
console.log("\nShutting down...");
|
|
223
|
+
await backend.dispose();
|
|
224
|
+
process.exit(0);
|
|
225
|
+
});
|
|
226
|
+
}
|
|
83
227
|
async function loginToHypha() {
|
|
84
228
|
const serverUrl = args[1] || process.env.HYPHA_SERVER_URL;
|
|
85
229
|
if (!serverUrl) {
|
|
@@ -169,19 +313,22 @@ function printHelp() {
|
|
|
169
313
|
svamp \u2014 Svamp CLI with Hypha transport
|
|
170
314
|
|
|
171
315
|
Usage:
|
|
172
|
-
svamp login [url]
|
|
173
|
-
svamp daemon start
|
|
174
|
-
svamp daemon stop
|
|
175
|
-
svamp daemon status
|
|
176
|
-
svamp
|
|
177
|
-
svamp
|
|
316
|
+
svamp login [url] Login to Hypha (opens browser, stores token)
|
|
317
|
+
svamp daemon start Start the daemon (detached)
|
|
318
|
+
svamp daemon stop Stop the daemon
|
|
319
|
+
svamp daemon status Show daemon status
|
|
320
|
+
svamp agent list List known ACP agents
|
|
321
|
+
svamp agent <name> Start interactive ACP agent session
|
|
322
|
+
svamp agent -- <cmd> Start custom ACP agent
|
|
323
|
+
svamp --version Show version
|
|
324
|
+
svamp --help Show this help
|
|
178
325
|
|
|
179
326
|
Environment variables:
|
|
180
327
|
HYPHA_SERVER_URL Hypha server URL (required for daemon)
|
|
181
328
|
HYPHA_TOKEN Hypha auth token (stored by login command)
|
|
182
329
|
HYPHA_WORKSPACE Hypha workspace / user ID (stored by login command)
|
|
183
330
|
SVAMP_MACHINE_ID Machine identifier (optional, auto-generated)
|
|
184
|
-
SVAMP_HOME
|
|
331
|
+
SVAMP_HOME Config directory (default: ~/.svamp)
|
|
185
332
|
`);
|
|
186
333
|
}
|
|
187
334
|
function printDaemonHelp() {
|
|
@@ -194,6 +341,24 @@ Usage:
|
|
|
194
341
|
svamp daemon status Show daemon status
|
|
195
342
|
`);
|
|
196
343
|
}
|
|
344
|
+
function printAgentHelp() {
|
|
345
|
+
console.log(`
|
|
346
|
+
svamp agent \u2014 Interactive ACP agent sessions
|
|
347
|
+
|
|
348
|
+
Usage:
|
|
349
|
+
svamp agent list List known ACP agents
|
|
350
|
+
svamp agent <name> [-d <path>] Start interactive agent session
|
|
351
|
+
svamp agent -- <cmd> [args] Start custom ACP agent
|
|
352
|
+
|
|
353
|
+
Examples:
|
|
354
|
+
svamp agent gemini Start Gemini agent in current directory
|
|
355
|
+
svamp agent gemini -d /tmp/proj Start Gemini agent in /tmp/proj
|
|
356
|
+
svamp agent opencode Start OpenCode agent
|
|
357
|
+
svamp agent -- mycli --acp Start custom ACP-compatible agent
|
|
358
|
+
|
|
359
|
+
Known agents: gemini, opencode
|
|
360
|
+
`);
|
|
361
|
+
}
|
|
197
362
|
main().catch((err) => {
|
|
198
363
|
console.error("Fatal error:", err);
|
|
199
364
|
process.exit(1);
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { c as connectToHypha, d as daemonStatus, g as getHyphaServerUrl, r as registerMachineService, a as registerSessionService, s as startDaemon, b as stopDaemon } from './run-
|
|
1
|
+
export { c as connectToHypha, d as daemonStatus, g as getHyphaServerUrl, r as registerMachineService, a as registerSessionService, s as startDaemon, b as stopDaemon } from './run-C2z4Zl9E.mjs';
|
|
2
2
|
import 'os';
|
|
3
3
|
import 'fs/promises';
|
|
4
4
|
import 'fs';
|
|
@@ -13,3 +13,5 @@ import '@modelcontextprotocol/sdk/server/mcp.js';
|
|
|
13
13
|
import 'node:http';
|
|
14
14
|
import '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
15
15
|
import 'zod';
|
|
16
|
+
import 'node:child_process';
|
|
17
|
+
import '@agentclientprotocol/sdk';
|