svamp-cli 0.1.56 → 0.1.57

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.
@@ -0,0 +1,140 @@
1
+ function getSandboxEnv() {
2
+ return {
3
+ apiUrl: process.env.SANDBOX_API_URL || "https://agent-sandbox.aicell.io",
4
+ apiKey: process.env.SANDBOX_API_KEY || process.env.HYPHA_TOKEN || "",
5
+ namespace: process.env.SANDBOX_NAMESPACE || process.env.HYPHA_WORKSPACE || "",
6
+ sandboxId: process.env.SANDBOX_ID || ""
7
+ };
8
+ }
9
+ function requireSandboxEnv() {
10
+ const env = getSandboxEnv();
11
+ if (!env.apiKey) {
12
+ throw new Error(
13
+ 'No API credentials found.\nRun "svamp login" to authenticate with Hypha, or set SANDBOX_API_KEY directly.'
14
+ );
15
+ }
16
+ if (!env.namespace) {
17
+ throw new Error(
18
+ 'No namespace/workspace found.\nRun "svamp login" to set HYPHA_WORKSPACE, or set SANDBOX_NAMESPACE directly.'
19
+ );
20
+ }
21
+ return env;
22
+ }
23
+ function requireSandboxApiEnv() {
24
+ const env = getSandboxEnv();
25
+ if (!env.apiKey) {
26
+ throw new Error(
27
+ 'No API credentials found.\nRun "svamp login" to authenticate with Hypha, or set SANDBOX_API_KEY directly.'
28
+ );
29
+ }
30
+ return env;
31
+ }
32
+ async function sandboxFetch(env, path, init) {
33
+ const url = `${env.apiUrl.replace(/\/+$/, "")}${path}`;
34
+ const headers = {
35
+ "Authorization": `Bearer ${env.apiKey}`,
36
+ "Content-Type": "application/json",
37
+ ...init?.headers || {}
38
+ };
39
+ const res = await fetch(url, { ...init, headers });
40
+ if (!res.ok) {
41
+ const body = await res.text().catch(() => "");
42
+ let detail = body;
43
+ try {
44
+ detail = JSON.parse(body).detail || body;
45
+ } catch {
46
+ }
47
+ throw new Error(`${res.status} ${res.statusText}: ${detail}`);
48
+ }
49
+ return res;
50
+ }
51
+ async function createServiceGroup(name, ports, options) {
52
+ const env = requireSandboxEnv();
53
+ const body = {};
54
+ if (ports.length === 1 && options?.subdomain) {
55
+ body.port = ports[0];
56
+ body.subdomain = options.subdomain;
57
+ } else {
58
+ body.ports = ports.map((p) => ({ port: p }));
59
+ }
60
+ if (options?.healthPath) {
61
+ body.health_path = options.healthPath;
62
+ if (options.healthInterval) {
63
+ body.health_interval = options.healthInterval;
64
+ }
65
+ }
66
+ const res = await sandboxFetch(env, `/services/${env.namespace}/${name}`, {
67
+ method: "POST",
68
+ body: JSON.stringify(body)
69
+ });
70
+ return res.json();
71
+ }
72
+ async function listServiceGroups() {
73
+ const env = requireSandboxEnv();
74
+ const res = await sandboxFetch(env, `/services/${env.namespace}`);
75
+ return res.json();
76
+ }
77
+ async function getServiceGroup(name) {
78
+ const env = requireSandboxEnv();
79
+ const res = await sandboxFetch(env, `/services/${env.namespace}/${name}`);
80
+ return res.json();
81
+ }
82
+ async function deleteServiceGroup(name) {
83
+ const env = requireSandboxEnv();
84
+ const res = await sandboxFetch(env, `/services/${env.namespace}/${name}`, {
85
+ method: "DELETE"
86
+ });
87
+ return res.json();
88
+ }
89
+ async function addPort(name, port, subdomain) {
90
+ const env = requireSandboxEnv();
91
+ const res = await sandboxFetch(env, `/services/${env.namespace}/${name}/ports`, {
92
+ method: "POST",
93
+ body: JSON.stringify({ port, subdomain })
94
+ });
95
+ return res.json();
96
+ }
97
+ async function removePort(name, port) {
98
+ const env = requireSandboxEnv();
99
+ const res = await sandboxFetch(env, `/services/${env.namespace}/${name}/ports/${port}`, {
100
+ method: "DELETE"
101
+ });
102
+ return res.json();
103
+ }
104
+ async function renameSubdomain(name, port, subdomain) {
105
+ const env = requireSandboxEnv();
106
+ const res = await sandboxFetch(env, `/services/${env.namespace}/${name}/subdomain`, {
107
+ method: "PUT",
108
+ body: JSON.stringify({ port, subdomain })
109
+ });
110
+ return res.json();
111
+ }
112
+ async function addBackend(name, sandboxId) {
113
+ const env = requireSandboxEnv();
114
+ const sid = sandboxId || env.sandboxId;
115
+ if (!sid) {
116
+ throw new Error(
117
+ "No sandbox ID provided and SANDBOX_ID is not set.\nUse --sandbox-id <id> to specify which sandbox to add."
118
+ );
119
+ }
120
+ const res = await sandboxFetch(env, `/services/${env.namespace}/${name}/backends`, {
121
+ method: "POST",
122
+ body: JSON.stringify({ sandbox_id: sid })
123
+ });
124
+ return res.json();
125
+ }
126
+ async function removeBackend(name, sandboxId) {
127
+ const env = requireSandboxEnv();
128
+ const sid = sandboxId || env.sandboxId;
129
+ if (!sid) {
130
+ throw new Error(
131
+ "No sandbox ID provided and SANDBOX_ID is not set.\nUse --sandbox-id <id> to specify which sandbox to remove."
132
+ );
133
+ }
134
+ const res = await sandboxFetch(env, `/services/${env.namespace}/${name}/backends/${sid}`, {
135
+ method: "DELETE"
136
+ });
137
+ return res.json();
138
+ }
139
+
140
+ export { addBackend, addPort, createServiceGroup, deleteServiceGroup, getSandboxEnv, getServiceGroup, listServiceGroups, removeBackend, removePort, renameSubdomain, requireSandboxApiEnv, requireSandboxEnv };
package/dist/cli.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { b as stopDaemon, s as startDaemon, d as daemonStatus } from './run-sALUrMgm.mjs';
1
+ import { b as stopDaemon, s as startDaemon, d as daemonStatus } from './run-Dn2eJUkz.mjs';
2
2
  import 'os';
3
3
  import 'fs/promises';
4
4
  import 'fs';
@@ -106,14 +106,28 @@ async function main() {
106
106
  } else if (subcommand === "skills") {
107
107
  await handleSkillsCommand();
108
108
  } else if (subcommand === "service" || subcommand === "svc") {
109
- const { handleServiceCommand } = await import('./commands-ZuFXrcot.mjs').then(function (n) { return n.c; });
109
+ const { handleServiceCommand } = await import('./commands-Dvftls28.mjs');
110
110
  await handleServiceCommand();
111
+ } else if (subcommand === "process" || subcommand === "proc") {
112
+ const { processCommand } = await import('./commands-Dpl6J2YR.mjs');
113
+ let machineId;
114
+ const processArgs = args.slice(1);
115
+ const mIdx = processArgs.findIndex((a) => a === "--machine" || a === "-m");
116
+ if (mIdx !== -1 && mIdx + 1 < processArgs.length) {
117
+ machineId = processArgs[mIdx + 1];
118
+ }
119
+ await processCommand(processArgs.filter((_a, i) => {
120
+ if (processArgs[i] === "--machine" || processArgs[i] === "-m") return false;
121
+ if (i > 0 && (processArgs[i - 1] === "--machine" || processArgs[i - 1] === "-m")) return false;
122
+ return true;
123
+ }), machineId);
124
+ process.exit(0);
111
125
  } else if (subcommand === "--help" || subcommand === "-h") {
112
126
  printHelp();
113
127
  } else if (!subcommand || subcommand === "start") {
114
128
  await handleInteractiveCommand();
115
129
  } else if (subcommand === "--version" || subcommand === "-v") {
116
- const pkg = await import('./package-4AMqauyI.mjs').catch(() => ({ default: { version: "unknown" } }));
130
+ const pkg = await import('./package-Db816RJ1.mjs').catch(() => ({ default: { version: "unknown" } }));
117
131
  console.log(`svamp version: ${pkg.default.version}`);
118
132
  } else {
119
133
  console.error(`Unknown command: ${subcommand}`);
@@ -122,7 +136,7 @@ async function main() {
122
136
  }
123
137
  }
124
138
  async function handleInteractiveCommand() {
125
- const { runInteractive } = await import('./run-FHqgSPLk.mjs');
139
+ const { runInteractive } = await import('./run-Vy8jjMbh.mjs');
126
140
  const interactiveArgs = subcommand === "start" ? args.slice(1) : args;
127
141
  let directory = process.cwd();
128
142
  let resumeSessionId;
@@ -167,7 +181,7 @@ async function handleAgentCommand() {
167
181
  return;
168
182
  }
169
183
  if (agentArgs[0] === "list") {
170
- const { KNOWN_ACP_AGENTS, KNOWN_MCP_AGENTS: KNOWN_MCP_AGENTS2 } = await import('./run-sALUrMgm.mjs').then(function (n) { return n.i; });
184
+ const { KNOWN_ACP_AGENTS, KNOWN_MCP_AGENTS: KNOWN_MCP_AGENTS2 } = await import('./run-Dn2eJUkz.mjs').then(function (n) { return n.i; });
171
185
  console.log("Known agents:");
172
186
  for (const [name, config2] of Object.entries(KNOWN_ACP_AGENTS)) {
173
187
  console.log(` ${name.padEnd(12)} ${config2.command} ${config2.args.join(" ")} (ACP)`);
@@ -179,7 +193,7 @@ async function handleAgentCommand() {
179
193
  console.log('Use "svamp agent -- <command> [args]" for a custom ACP agent.');
180
194
  return;
181
195
  }
182
- const { resolveAcpAgentConfig, KNOWN_MCP_AGENTS } = await import('./run-sALUrMgm.mjs').then(function (n) { return n.i; });
196
+ const { resolveAcpAgentConfig, KNOWN_MCP_AGENTS } = await import('./run-Dn2eJUkz.mjs').then(function (n) { return n.i; });
183
197
  let cwd = process.cwd();
184
198
  const filteredArgs = [];
185
199
  for (let i = 0; i < agentArgs.length; i++) {
@@ -203,12 +217,12 @@ async function handleAgentCommand() {
203
217
  console.log(`Starting ${config.agentName} agent in ${cwd}...`);
204
218
  let backend;
205
219
  if (KNOWN_MCP_AGENTS[config.agentName]) {
206
- const { CodexMcpBackend } = await import('./run-sALUrMgm.mjs').then(function (n) { return n.j; });
220
+ const { CodexMcpBackend } = await import('./run-Dn2eJUkz.mjs').then(function (n) { return n.j; });
207
221
  backend = new CodexMcpBackend({ cwd, log: logFn });
208
222
  } else {
209
- const { AcpBackend } = await import('./run-sALUrMgm.mjs').then(function (n) { return n.h; });
210
- const { GeminiTransport } = await import('./run-sALUrMgm.mjs').then(function (n) { return n.G; });
211
- const { DefaultTransport } = await import('./run-sALUrMgm.mjs').then(function (n) { return n.D; });
223
+ const { AcpBackend } = await import('./run-Dn2eJUkz.mjs').then(function (n) { return n.h; });
224
+ const { GeminiTransport } = await import('./run-Dn2eJUkz.mjs').then(function (n) { return n.G; });
225
+ const { DefaultTransport } = await import('./run-Dn2eJUkz.mjs').then(function (n) { return n.D; });
212
226
  const transportHandler = config.agentName === "gemini" ? new GeminiTransport() : new DefaultTransport(config.agentName);
213
227
  backend = new AcpBackend({
214
228
  agentName: config.agentName,
@@ -326,7 +340,7 @@ async function handleSessionCommand() {
326
340
  printSessionHelp();
327
341
  return;
328
342
  }
329
- const { sessionList, sessionSpawn, sessionStop, sessionInfo, sessionMessages, sessionAttach, sessionMachines, sessionSend, sessionWait, sessionShare, sessionRalphStart, sessionRalphCancel, sessionRalphStatus, sessionQueueAdd, sessionQueueList, sessionQueueClear } = await import('./commands-CraYxTcv.mjs');
343
+ const { sessionList, sessionSpawn, sessionStop, sessionInfo, sessionMessages, sessionAttach, sessionMachines, sessionSend, sessionWait, sessionShare, sessionRalphStart, sessionRalphCancel, sessionRalphStatus, sessionQueueAdd, sessionQueueList, sessionQueueClear } = await import('./commands-CrNk2TV0.mjs');
330
344
  const parseFlagStr = (flag, shortFlag) => {
331
345
  for (let i = 1; i < sessionArgs.length; i++) {
332
346
  if ((sessionArgs[i] === flag || shortFlag) && i + 1 < sessionArgs.length) {
@@ -386,7 +400,7 @@ async function handleSessionCommand() {
386
400
  allowDomain.push(sessionArgs[++i]);
387
401
  }
388
402
  }
389
- const { parseShareArg } = await import('./commands-CraYxTcv.mjs');
403
+ const { parseShareArg } = await import('./commands-CrNk2TV0.mjs');
390
404
  const shareEntries = share.map((s) => parseShareArg(s));
391
405
  await sessionSpawn(agent, dir, targetMachineId, {
392
406
  message,
@@ -470,7 +484,7 @@ async function handleSessionCommand() {
470
484
  console.error("Usage: svamp session approve <session-id> [request-id] [--json]");
471
485
  process.exit(1);
472
486
  }
473
- const { sessionApprove } = await import('./commands-CraYxTcv.mjs');
487
+ const { sessionApprove } = await import('./commands-CrNk2TV0.mjs');
474
488
  const approveReqId = sessionArgs[2] && !sessionArgs[2].startsWith("--") ? sessionArgs[2] : void 0;
475
489
  await sessionApprove(sessionArgs[1], approveReqId, targetMachineId, {
476
490
  json: hasFlag("--json")
@@ -480,7 +494,7 @@ async function handleSessionCommand() {
480
494
  console.error("Usage: svamp session deny <session-id> [request-id] [--json]");
481
495
  process.exit(1);
482
496
  }
483
- const { sessionDeny } = await import('./commands-CraYxTcv.mjs');
497
+ const { sessionDeny } = await import('./commands-CrNk2TV0.mjs');
484
498
  const denyReqId = sessionArgs[2] && !sessionArgs[2].startsWith("--") ? sessionArgs[2] : void 0;
485
499
  await sessionDeny(sessionArgs[1], denyReqId, targetMachineId, {
486
500
  json: hasFlag("--json")
@@ -549,7 +563,7 @@ async function handleMachineCommand() {
549
563
  return;
550
564
  }
551
565
  if (machineSubcommand === "share") {
552
- const { machineShare } = await import('./commands-CraYxTcv.mjs');
566
+ const { machineShare } = await import('./commands-CrNk2TV0.mjs');
553
567
  let machineId;
554
568
  const shareArgs = [];
555
569
  for (let i = 1; i < machineArgs.length; i++) {
@@ -579,7 +593,7 @@ async function handleMachineCommand() {
579
593
  }
580
594
  await machineShare(machineId, { add, remove, list, configPath, showConfig });
581
595
  } else if (machineSubcommand === "exec") {
582
- const { machineExec } = await import('./commands-CraYxTcv.mjs');
596
+ const { machineExec } = await import('./commands-CrNk2TV0.mjs');
583
597
  let machineId;
584
598
  let cwd;
585
599
  const cmdParts = [];
@@ -599,7 +613,7 @@ async function handleMachineCommand() {
599
613
  }
600
614
  await machineExec(machineId, command, cwd);
601
615
  } else if (machineSubcommand === "info") {
602
- const { machineInfo } = await import('./commands-CraYxTcv.mjs');
616
+ const { machineInfo } = await import('./commands-CrNk2TV0.mjs');
603
617
  let machineId;
604
618
  for (let i = 1; i < machineArgs.length; i++) {
605
619
  if ((machineArgs[i] === "--machine" || machineArgs[i] === "-m") && i + 1 < machineArgs.length) {
@@ -608,7 +622,7 @@ async function handleMachineCommand() {
608
622
  }
609
623
  await machineInfo(machineId);
610
624
  } else if (machineSubcommand === "ls") {
611
- const { machineLs } = await import('./commands-CraYxTcv.mjs');
625
+ const { machineLs } = await import('./commands-CrNk2TV0.mjs');
612
626
  let machineId;
613
627
  let showHidden = false;
614
628
  let path;
@@ -2,7 +2,7 @@ import { existsSync, readFileSync } from 'node:fs';
2
2
  import { execSync } from 'node:child_process';
3
3
  import { resolve, join } from 'node:path';
4
4
  import os from 'node:os';
5
- import { l as loadSecurityContextConfig, e as resolveSecurityContext, f as buildSecurityContextFromFlags, m as mergeSecurityContexts, c as connectToHypha } from './run-sALUrMgm.mjs';
5
+ import { l as loadSecurityContextConfig, e as resolveSecurityContext, f as buildSecurityContextFromFlags, m as mergeSecurityContexts, c as connectToHypha } from './run-Dn2eJUkz.mjs';
6
6
  import 'os';
7
7
  import 'fs/promises';
8
8
  import 'fs';