svamp-cli 0.1.53 → 0.1.54

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 CHANGED
@@ -1,4 +1,4 @@
1
- import { b as stopDaemon, s as startDaemon, d as daemonStatus } from './run-CBhm4Jop.mjs';
1
+ import { b as stopDaemon, s as startDaemon, d as daemonStatus } from './run-xuIB35Y4.mjs';
2
2
  import 'os';
3
3
  import 'fs/promises';
4
4
  import 'fs';
@@ -113,7 +113,7 @@ async function main() {
113
113
  } else if (!subcommand || subcommand === "start") {
114
114
  await handleInteractiveCommand();
115
115
  } else if (subcommand === "--version" || subcommand === "-v") {
116
- const pkg = await import('./package-DbeynOln.mjs').catch(() => ({ default: { version: "unknown" } }));
116
+ const pkg = await import('./package-HcoejbYj.mjs').catch(() => ({ default: { version: "unknown" } }));
117
117
  console.log(`svamp version: ${pkg.default.version}`);
118
118
  } else {
119
119
  console.error(`Unknown command: ${subcommand}`);
@@ -122,7 +122,7 @@ async function main() {
122
122
  }
123
123
  }
124
124
  async function handleInteractiveCommand() {
125
- const { runInteractive } = await import('./run-Y0b60UYS.mjs');
125
+ const { runInteractive } = await import('./run-Bus1nAOe.mjs');
126
126
  const interactiveArgs = subcommand === "start" ? args.slice(1) : args;
127
127
  let directory = process.cwd();
128
128
  let resumeSessionId;
@@ -167,7 +167,7 @@ async function handleAgentCommand() {
167
167
  return;
168
168
  }
169
169
  if (agentArgs[0] === "list") {
170
- const { KNOWN_ACP_AGENTS, KNOWN_MCP_AGENTS: KNOWN_MCP_AGENTS2 } = await import('./run-CBhm4Jop.mjs').then(function (n) { return n.i; });
170
+ const { KNOWN_ACP_AGENTS, KNOWN_MCP_AGENTS: KNOWN_MCP_AGENTS2 } = await import('./run-xuIB35Y4.mjs').then(function (n) { return n.i; });
171
171
  console.log("Known agents:");
172
172
  for (const [name, config2] of Object.entries(KNOWN_ACP_AGENTS)) {
173
173
  console.log(` ${name.padEnd(12)} ${config2.command} ${config2.args.join(" ")} (ACP)`);
@@ -179,7 +179,7 @@ async function handleAgentCommand() {
179
179
  console.log('Use "svamp agent -- <command> [args]" for a custom ACP agent.');
180
180
  return;
181
181
  }
182
- const { resolveAcpAgentConfig, KNOWN_MCP_AGENTS } = await import('./run-CBhm4Jop.mjs').then(function (n) { return n.i; });
182
+ const { resolveAcpAgentConfig, KNOWN_MCP_AGENTS } = await import('./run-xuIB35Y4.mjs').then(function (n) { return n.i; });
183
183
  let cwd = process.cwd();
184
184
  const filteredArgs = [];
185
185
  for (let i = 0; i < agentArgs.length; i++) {
@@ -203,12 +203,12 @@ async function handleAgentCommand() {
203
203
  console.log(`Starting ${config.agentName} agent in ${cwd}...`);
204
204
  let backend;
205
205
  if (KNOWN_MCP_AGENTS[config.agentName]) {
206
- const { CodexMcpBackend } = await import('./run-CBhm4Jop.mjs').then(function (n) { return n.j; });
206
+ const { CodexMcpBackend } = await import('./run-xuIB35Y4.mjs').then(function (n) { return n.j; });
207
207
  backend = new CodexMcpBackend({ cwd, log: logFn });
208
208
  } else {
209
- const { AcpBackend } = await import('./run-CBhm4Jop.mjs').then(function (n) { return n.h; });
210
- const { GeminiTransport } = await import('./run-CBhm4Jop.mjs').then(function (n) { return n.G; });
211
- const { DefaultTransport } = await import('./run-CBhm4Jop.mjs').then(function (n) { return n.D; });
209
+ const { AcpBackend } = await import('./run-xuIB35Y4.mjs').then(function (n) { return n.h; });
210
+ const { GeminiTransport } = await import('./run-xuIB35Y4.mjs').then(function (n) { return n.G; });
211
+ const { DefaultTransport } = await import('./run-xuIB35Y4.mjs').then(function (n) { return n.D; });
212
212
  const transportHandler = config.agentName === "gemini" ? new GeminiTransport() : new DefaultTransport(config.agentName);
213
213
  backend = new AcpBackend({
214
214
  agentName: config.agentName,
@@ -326,7 +326,7 @@ async function handleSessionCommand() {
326
326
  printSessionHelp();
327
327
  return;
328
328
  }
329
- const { sessionList, sessionSpawn, sessionStop, sessionInfo, sessionMessages, sessionAttach, sessionMachines, sessionSend, sessionWait, sessionShare, sessionRalphStart, sessionRalphCancel, sessionRalphStatus, sessionQueueAdd, sessionQueueList, sessionQueueClear } = await import('./commands-VGt5ofDo.mjs');
329
+ const { sessionList, sessionSpawn, sessionStop, sessionInfo, sessionMessages, sessionAttach, sessionMachines, sessionSend, sessionWait, sessionShare, sessionRalphStart, sessionRalphCancel, sessionRalphStatus, sessionQueueAdd, sessionQueueList, sessionQueueClear } = await import('./commands-DawcW7Ty.mjs');
330
330
  const parseFlagStr = (flag, shortFlag) => {
331
331
  for (let i = 1; i < sessionArgs.length; i++) {
332
332
  if ((sessionArgs[i] === flag || shortFlag) && i + 1 < sessionArgs.length) {
@@ -386,7 +386,7 @@ async function handleSessionCommand() {
386
386
  allowDomain.push(sessionArgs[++i]);
387
387
  }
388
388
  }
389
- const { parseShareArg } = await import('./commands-VGt5ofDo.mjs');
389
+ const { parseShareArg } = await import('./commands-DawcW7Ty.mjs');
390
390
  const shareEntries = share.map((s) => parseShareArg(s));
391
391
  await sessionSpawn(agent, dir, targetMachineId, {
392
392
  message,
@@ -470,7 +470,7 @@ async function handleSessionCommand() {
470
470
  console.error("Usage: svamp session approve <session-id> [request-id] [--json]");
471
471
  process.exit(1);
472
472
  }
473
- const { sessionApprove } = await import('./commands-VGt5ofDo.mjs');
473
+ const { sessionApprove } = await import('./commands-DawcW7Ty.mjs');
474
474
  const approveReqId = sessionArgs[2] && !sessionArgs[2].startsWith("--") ? sessionArgs[2] : void 0;
475
475
  await sessionApprove(sessionArgs[1], approveReqId, targetMachineId, {
476
476
  json: hasFlag("--json")
@@ -480,7 +480,7 @@ async function handleSessionCommand() {
480
480
  console.error("Usage: svamp session deny <session-id> [request-id] [--json]");
481
481
  process.exit(1);
482
482
  }
483
- const { sessionDeny } = await import('./commands-VGt5ofDo.mjs');
483
+ const { sessionDeny } = await import('./commands-DawcW7Ty.mjs');
484
484
  const denyReqId = sessionArgs[2] && !sessionArgs[2].startsWith("--") ? sessionArgs[2] : void 0;
485
485
  await sessionDeny(sessionArgs[1], denyReqId, targetMachineId, {
486
486
  json: hasFlag("--json")
@@ -549,7 +549,7 @@ async function handleMachineCommand() {
549
549
  return;
550
550
  }
551
551
  if (machineSubcommand === "share") {
552
- const { machineShare } = await import('./commands-VGt5ofDo.mjs');
552
+ const { machineShare } = await import('./commands-DawcW7Ty.mjs');
553
553
  let machineId;
554
554
  const shareArgs = [];
555
555
  for (let i = 1; i < machineArgs.length; i++) {
@@ -579,7 +579,7 @@ async function handleMachineCommand() {
579
579
  }
580
580
  await machineShare(machineId, { add, remove, list, configPath, showConfig });
581
581
  } else if (machineSubcommand === "exec") {
582
- const { machineExec } = await import('./commands-VGt5ofDo.mjs');
582
+ const { machineExec } = await import('./commands-DawcW7Ty.mjs');
583
583
  let machineId;
584
584
  let cwd;
585
585
  const cmdParts = [];
@@ -599,7 +599,7 @@ async function handleMachineCommand() {
599
599
  }
600
600
  await machineExec(machineId, command, cwd);
601
601
  } else if (machineSubcommand === "info") {
602
- const { machineInfo } = await import('./commands-VGt5ofDo.mjs');
602
+ const { machineInfo } = await import('./commands-DawcW7Ty.mjs');
603
603
  let machineId;
604
604
  for (let i = 1; i < machineArgs.length; i++) {
605
605
  if ((machineArgs[i] === "--machine" || machineArgs[i] === "-m") && i + 1 < machineArgs.length) {
@@ -608,7 +608,7 @@ async function handleMachineCommand() {
608
608
  }
609
609
  await machineInfo(machineId);
610
610
  } else if (machineSubcommand === "ls") {
611
- const { machineLs } = await import('./commands-VGt5ofDo.mjs');
611
+ const { machineLs } = await import('./commands-DawcW7Ty.mjs');
612
612
  let machineId;
613
613
  let showHidden = false;
614
614
  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-CBhm4Jop.mjs';
5
+ import { l as loadSecurityContextConfig, e as resolveSecurityContext, f as buildSecurityContextFromFlags, m as mergeSecurityContexts, c as connectToHypha } from './run-xuIB35Y4.mjs';
6
6
  import 'os';
7
7
  import 'fs/promises';
8
8
  import 'fs';
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-CBhm4Jop.mjs';
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-xuIB35Y4.mjs';
2
2
  import 'os';
3
3
  import 'fs/promises';
4
4
  import 'fs';
@@ -1,5 +1,5 @@
1
1
  var name = "svamp-cli";
2
- var version = "0.1.51";
2
+ var version = "0.1.54";
3
3
  var description = "Svamp CLI — AI workspace daemon on Hypha Cloud";
4
4
  var author = "Amun AI AB";
5
5
  var license = "SEE LICENSE IN LICENSE";
@@ -17,7 +17,7 @@ var exports$1 = {
17
17
  "./cli": "./dist/cli.mjs"
18
18
  };
19
19
  var scripts = {
20
- build: "tsc --noEmit && pkgroll",
20
+ build: "rm -rf dist && tsc --noEmit && pkgroll",
21
21
  typecheck: "tsc --noEmit",
22
22
  test: "npx tsx test/test-authorize.mjs && npx tsx test/test-session-helpers.mjs && npx tsx test/test-cli-routing.mjs && npx tsx test/test-security-context.mjs && npx tsx test/test-ralph-loop.mjs && npx tsx test/test-message-helpers.mjs && npx tsx test/test-agent-config.mjs && npx tsx test/test-wrap-command.mjs && npx tsx test/test-credential-staging.mjs && npx tsx test/test-output-formatters.mjs && npx tsx test/test-agent-types.mjs && npx tsx test/test-transport.mjs && npx tsx test/test-session-update-handlers.mjs && npx tsx test/test-session-scanner.mjs && npx tsx test/test-hypha-client.mjs && npx tsx test/test-hook-settings.mjs && npx tsx test/test-session-service-logic.mjs && npx tsx test/test-daemon-persistence.mjs && npx tsx test/test-detect-isolation.mjs && npx tsx test/test-machine-service-logic.mjs && npx tsx test/test-interactive-helpers.mjs && npx tsx test/test-codex-backend.mjs && npx tsx test/test-acp-backend.mjs && npx tsx test/test-acp-bridge.mjs && npx tsx test/test-hook-server.mjs && npx tsx test/test-session-commands.mjs && npx tsx test/test-interactive-console.mjs && npx tsx test/test-session-messages.mjs && npx tsx test/test-skills.mjs && npx tsx test/test-agent-grouping.mjs && npx tsx test/test-ralph-loop-integration.mjs && npx tsx test/test-ralph-loop-modes.mjs && npx tsx test/test-machine-list-directory.mjs && npx tsx test/test-service-commands.mjs",
23
23
  "test:hypha": "node --no-warnings test/test-hypha-service.mjs",
@@ -2,7 +2,7 @@ import{createRequire as _pkgrollCR}from"node:module";const require=_pkgrollCR(im
2
2
  import os from 'node:os';
3
3
  import { join, resolve } from 'node:path';
4
4
  import { mkdirSync, writeFileSync, existsSync, unlinkSync, readFileSync, watch } from 'node:fs';
5
- import { c as connectToHypha, a as registerSessionService } from './run-eYBOEaWw.mjs';
5
+ import { c as connectToHypha, a as registerSessionService } from './run-xuIB35Y4.mjs';
6
6
  import { createServer } from 'node:http';
7
7
  import { spawn } from 'node:child_process';
8
8
  import { createInterface } from 'node:readline';
@@ -32,14 +32,19 @@ async function getConnectToServer() {
32
32
  async function connectToHypha(config) {
33
33
  const connectToServer = await getConnectToServer();
34
34
  const workspace = config.token ? parseWorkspaceFromToken(config.token) : void 0;
35
- const server = await connectToServer({
36
- server_url: config.serverUrl,
37
- token: config.token,
38
- client_id: config.clientId,
39
- name: config.name || "svamp-cli",
40
- workspace,
41
- ...config.transport ? { transport: config.transport } : {}
42
- });
35
+ const server = await Promise.race([
36
+ connectToServer({
37
+ server_url: config.serverUrl,
38
+ token: config.token,
39
+ client_id: config.clientId,
40
+ name: config.name || "svamp-cli",
41
+ workspace,
42
+ ...config.transport ? { transport: config.transport } : {}
43
+ }),
44
+ new Promise((_, reject) => setTimeout(() => reject(new Error(
45
+ "Timeout connecting to Hypha server (30s). A previous daemon may still be connected. Retrying..."
46
+ )), 3e4))
47
+ ]);
43
48
  return server;
44
49
  }
45
50
  function parseWorkspaceFromToken(token) {
@@ -1599,6 +1604,11 @@ var DefaultTransport$1 = /*#__PURE__*/Object.freeze({
1599
1604
  DefaultTransport: DefaultTransport
1600
1605
  });
1601
1606
 
1607
+ function expandHome(p) {
1608
+ if (p === "~") return homedir();
1609
+ if (p.startsWith("~/")) return join$1(homedir(), p.slice(2));
1610
+ return p;
1611
+ }
1602
1612
  function wrapWithIsolation(originalCommand, originalArgs, config) {
1603
1613
  switch (config.method) {
1604
1614
  case "nono":
@@ -1630,22 +1640,22 @@ function wrapWithNono(command, args, config) {
1630
1640
  }
1631
1641
  if (config.nonoConfig?.allowDirs) {
1632
1642
  for (const dir of config.nonoConfig.allowDirs) {
1633
- nonoArgs.push("--allow", dir);
1643
+ nonoArgs.push("--allow", expandHome(dir));
1634
1644
  }
1635
1645
  }
1636
1646
  if (config.nonoConfig?.readDirs) {
1637
1647
  for (const dir of config.nonoConfig.readDirs) {
1638
- nonoArgs.push("--read", dir);
1648
+ nonoArgs.push("--read", expandHome(dir));
1639
1649
  }
1640
1650
  }
1641
1651
  if (config.nonoConfig?.allowFiles) {
1642
1652
  for (const file of config.nonoConfig.allowFiles) {
1643
- nonoArgs.push("--allow-file", file);
1653
+ nonoArgs.push("--allow-file", expandHome(file));
1644
1654
  }
1645
1655
  }
1646
1656
  if (config.nonoConfig?.readFiles) {
1647
1657
  for (const file of config.nonoConfig.readFiles) {
1648
- nonoArgs.push("--read-file", file);
1658
+ nonoArgs.push("--read-file", expandHome(file));
1649
1659
  }
1650
1660
  }
1651
1661
  if (config.nonoConfig?.netBlock) {
@@ -4261,9 +4271,13 @@ function readDaemonStateFile() {
4261
4271
  return null;
4262
4272
  }
4263
4273
  }
4264
- function cleanupDaemonStateFile() {
4274
+ function cleanupDaemonStateFile(onlyIfOwnedByMe = false) {
4265
4275
  try {
4266
4276
  if (existsSync$1(DAEMON_STATE_FILE)) {
4277
+ if (onlyIfOwnedByMe) {
4278
+ const state = readDaemonStateFile();
4279
+ if (state && state.pid !== process.pid) return;
4280
+ }
4267
4281
  fs.unlink(DAEMON_STATE_FILE).catch(() => {
4268
4282
  });
4269
4283
  }
@@ -6328,7 +6342,7 @@ The automated loop has finished. Review the progress above and let me know if yo
6328
6342
  await server.disconnect();
6329
6343
  } catch {
6330
6344
  }
6331
- cleanupDaemonStateFile();
6345
+ cleanupDaemonStateFile(true);
6332
6346
  logger.log("Cleanup complete");
6333
6347
  };
6334
6348
  const shutdownReq = await resolvesWhenShutdownRequested;
@@ -6339,7 +6353,7 @@ The automated loop has finished. Review the progress above and let me know if yo
6339
6353
  process.exit(0);
6340
6354
  } catch (error) {
6341
6355
  logger.error("Fatal error:", error);
6342
- cleanupDaemonStateFile();
6356
+ cleanupDaemonStateFile(true);
6343
6357
  if (server) {
6344
6358
  try {
6345
6359
  await server.disconnect();
@@ -6361,7 +6375,7 @@ async function stopDaemon(options) {
6361
6375
  process.kill(state.pid, 0);
6362
6376
  process.kill(state.pid, signal);
6363
6377
  console.log(`Sent ${signal} to daemon PID ${state.pid} \u2014 ${mode}`);
6364
- for (let i = 0; i < 30; i++) {
6378
+ for (let i = 0; i < 100; i++) {
6365
6379
  await new Promise((r) => setTimeout(r, 100));
6366
6380
  try {
6367
6381
  process.kill(state.pid, 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svamp-cli",
3
- "version": "0.1.53",
3
+ "version": "0.1.54",
4
4
  "description": "Svamp CLI — AI workspace daemon on Hypha Cloud",
5
5
  "author": "Amun AI AB",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -18,7 +18,7 @@
18
18
  "./cli": "./dist/cli.mjs"
19
19
  },
20
20
  "scripts": {
21
- "build": "tsc --noEmit && pkgroll",
21
+ "build": "rm -rf dist && tsc --noEmit && pkgroll",
22
22
  "typecheck": "tsc --noEmit",
23
23
  "test": "npx tsx test/test-authorize.mjs && npx tsx test/test-session-helpers.mjs && npx tsx test/test-cli-routing.mjs && npx tsx test/test-security-context.mjs && npx tsx test/test-ralph-loop.mjs && npx tsx test/test-message-helpers.mjs && npx tsx test/test-agent-config.mjs && npx tsx test/test-wrap-command.mjs && npx tsx test/test-credential-staging.mjs && npx tsx test/test-output-formatters.mjs && npx tsx test/test-agent-types.mjs && npx tsx test/test-transport.mjs && npx tsx test/test-session-update-handlers.mjs && npx tsx test/test-session-scanner.mjs && npx tsx test/test-hypha-client.mjs && npx tsx test/test-hook-settings.mjs && npx tsx test/test-session-service-logic.mjs && npx tsx test/test-daemon-persistence.mjs && npx tsx test/test-detect-isolation.mjs && npx tsx test/test-machine-service-logic.mjs && npx tsx test/test-interactive-helpers.mjs && npx tsx test/test-codex-backend.mjs && npx tsx test/test-acp-backend.mjs && npx tsx test/test-acp-bridge.mjs && npx tsx test/test-hook-server.mjs && npx tsx test/test-session-commands.mjs && npx tsx test/test-interactive-console.mjs && npx tsx test/test-session-messages.mjs && npx tsx test/test-skills.mjs && npx tsx test/test-agent-grouping.mjs && npx tsx test/test-ralph-loop-integration.mjs && npx tsx test/test-ralph-loop-modes.mjs && npx tsx test/test-machine-list-directory.mjs && npx tsx test/test-service-commands.mjs",
24
24
  "test:hypha": "node --no-warnings test/test-hypha-service.mjs",