svamp-cli 0.2.14 → 0.2.16

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.
@@ -148,7 +148,7 @@ async function sessionBroadcast(action, args) {
148
148
  console.log(`Broadcast sent: ${action}`);
149
149
  }
150
150
  async function connectToMachineService() {
151
- const { connectAndGetMachine } = await import('./commands-B2C52dbI.mjs');
151
+ const { connectAndGetMachine } = await import('./commands-DC5ay_Ne.mjs');
152
152
  return connectAndGetMachine();
153
153
  }
154
154
  async function inboxSend(targetSessionId, opts) {
@@ -165,7 +165,7 @@ async function inboxSend(targetSessionId, opts) {
165
165
  }
166
166
  const { server, machine } = await connectToMachineService();
167
167
  try {
168
- const { resolveSessionId } = await import('./commands-B2C52dbI.mjs');
168
+ const { resolveSessionId } = await import('./commands-DC5ay_Ne.mjs');
169
169
  const sessions = await machine.listSessions();
170
170
  const match = resolveSessionId(sessions, targetSessionId);
171
171
  const fullTargetId = match.sessionId;
package/dist/cli.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { s as startDaemon, b as stopDaemon, d as daemonStatus } from './run-B3BZk1Vy.mjs';
1
+ import { s as startDaemon, b as stopDaemon, d as daemonStatus } from './run-B9RS4JWP.mjs';
2
2
  import 'os';
3
3
  import 'fs/promises';
4
4
  import 'fs';
@@ -36,7 +36,7 @@ async function main() {
36
36
  await logoutFromHypha();
37
37
  } else if (subcommand === "daemon") {
38
38
  if (daemonSubcommand === "restart") {
39
- const { restartDaemon } = await import('./run-B3BZk1Vy.mjs').then(function (n) { return n.k; });
39
+ const { restartDaemon } = await import('./run-B9RS4JWP.mjs').then(function (n) { return n.k; });
40
40
  await restartDaemon();
41
41
  process.exit(0);
42
42
  }
@@ -246,7 +246,7 @@ async function main() {
246
246
  console.error("svamp serve: Serve commands are not available in sandboxed sessions.");
247
247
  process.exit(1);
248
248
  }
249
- const { handleServeCommand } = await import('./serveCommands-CYrI41gO.mjs');
249
+ const { handleServeCommand } = await import('./serveCommands-PRXMNein.mjs');
250
250
  await handleServeCommand();
251
251
  process.exit(0);
252
252
  } else if (subcommand === "process" || subcommand === "proc") {
@@ -255,7 +255,7 @@ async function main() {
255
255
  console.error("svamp process: Process commands are not available in sandboxed sessions.");
256
256
  process.exit(1);
257
257
  }
258
- const { processCommand } = await import('./commands-4T8foR5R.mjs');
258
+ const { processCommand } = await import('./commands-CONYig_A.mjs');
259
259
  let machineId;
260
260
  const processArgs = args.slice(1);
261
261
  const mIdx = processArgs.findIndex((a) => a === "--machine" || a === "-m");
@@ -273,7 +273,7 @@ async function main() {
273
273
  } else if (!subcommand || subcommand === "start") {
274
274
  await handleInteractiveCommand();
275
275
  } else if (subcommand === "--version" || subcommand === "-v") {
276
- const pkg = await import('./package-D1BbmqDt.mjs').catch(() => ({ default: { version: "unknown" } }));
276
+ const pkg = await import('./package-BFSJrcnA.mjs').catch(() => ({ default: { version: "unknown" } }));
277
277
  console.log(`svamp version: ${pkg.default.version}`);
278
278
  } else {
279
279
  console.error(`Unknown command: ${subcommand}`);
@@ -282,7 +282,7 @@ async function main() {
282
282
  }
283
283
  }
284
284
  async function handleInteractiveCommand() {
285
- const { runInteractive } = await import('./run-w5Y4LmzE.mjs');
285
+ const { runInteractive } = await import('./run-COosyOXs.mjs');
286
286
  const interactiveArgs = subcommand === "start" ? args.slice(1) : args;
287
287
  let directory = process.cwd();
288
288
  let resumeSessionId;
@@ -327,7 +327,7 @@ async function handleAgentCommand() {
327
327
  return;
328
328
  }
329
329
  if (agentArgs[0] === "list") {
330
- const { KNOWN_ACP_AGENTS, KNOWN_MCP_AGENTS: KNOWN_MCP_AGENTS2 } = await import('./run-B3BZk1Vy.mjs').then(function (n) { return n.i; });
330
+ const { KNOWN_ACP_AGENTS, KNOWN_MCP_AGENTS: KNOWN_MCP_AGENTS2 } = await import('./run-B9RS4JWP.mjs').then(function (n) { return n.i; });
331
331
  console.log("Known agents:");
332
332
  for (const [name, config2] of Object.entries(KNOWN_ACP_AGENTS)) {
333
333
  console.log(` ${name.padEnd(12)} ${config2.command} ${config2.args.join(" ")} (ACP)`);
@@ -339,7 +339,7 @@ async function handleAgentCommand() {
339
339
  console.log('Use "svamp agent -- <command> [args]" for a custom ACP agent.');
340
340
  return;
341
341
  }
342
- const { resolveAcpAgentConfig, KNOWN_MCP_AGENTS } = await import('./run-B3BZk1Vy.mjs').then(function (n) { return n.i; });
342
+ const { resolveAcpAgentConfig, KNOWN_MCP_AGENTS } = await import('./run-B9RS4JWP.mjs').then(function (n) { return n.i; });
343
343
  let cwd = process.cwd();
344
344
  const filteredArgs = [];
345
345
  for (let i = 0; i < agentArgs.length; i++) {
@@ -363,12 +363,12 @@ async function handleAgentCommand() {
363
363
  console.log(`Starting ${config.agentName} agent in ${cwd}...`);
364
364
  let backend;
365
365
  if (KNOWN_MCP_AGENTS[config.agentName]) {
366
- const { CodexMcpBackend } = await import('./run-B3BZk1Vy.mjs').then(function (n) { return n.j; });
366
+ const { CodexMcpBackend } = await import('./run-B9RS4JWP.mjs').then(function (n) { return n.j; });
367
367
  backend = new CodexMcpBackend({ cwd, log: logFn });
368
368
  } else {
369
- const { AcpBackend } = await import('./run-B3BZk1Vy.mjs').then(function (n) { return n.h; });
370
- const { GeminiTransport } = await import('./run-B3BZk1Vy.mjs').then(function (n) { return n.G; });
371
- const { DefaultTransport } = await import('./run-B3BZk1Vy.mjs').then(function (n) { return n.D; });
369
+ const { AcpBackend } = await import('./run-B9RS4JWP.mjs').then(function (n) { return n.h; });
370
+ const { GeminiTransport } = await import('./run-B9RS4JWP.mjs').then(function (n) { return n.G; });
371
+ const { DefaultTransport } = await import('./run-B9RS4JWP.mjs').then(function (n) { return n.D; });
372
372
  const transportHandler = config.agentName === "gemini" ? new GeminiTransport() : new DefaultTransport(config.agentName);
373
373
  backend = new AcpBackend({
374
374
  agentName: config.agentName,
@@ -495,7 +495,7 @@ async function handleSessionCommand() {
495
495
  process.exit(1);
496
496
  }
497
497
  }
498
- const { sessionList, sessionSpawn, sessionStop, sessionInfo, sessionMessages, sessionAttach, sessionMachines, sessionSend, sessionWait, sessionShare, sessionRalphStart, sessionRalphCancel, sessionRalphStatus, sessionInboxSend, sessionInboxList, sessionInboxRead, sessionInboxReply, sessionInboxClear } = await import('./commands-B2C52dbI.mjs');
498
+ const { sessionList, sessionSpawn, sessionStop, sessionInfo, sessionMessages, sessionAttach, sessionMachines, sessionSend, sessionWait, sessionShare, sessionRalphStart, sessionRalphCancel, sessionRalphStatus, sessionInboxSend, sessionInboxList, sessionInboxRead, sessionInboxReply, sessionInboxClear } = await import('./commands-DC5ay_Ne.mjs');
499
499
  const parseFlagStr = (flag, shortFlag) => {
500
500
  for (let i = 1; i < sessionArgs.length; i++) {
501
501
  if ((sessionArgs[i] === flag || shortFlag) && i + 1 < sessionArgs.length) {
@@ -555,7 +555,7 @@ async function handleSessionCommand() {
555
555
  allowDomain.push(sessionArgs[++i]);
556
556
  }
557
557
  }
558
- const { parseShareArg } = await import('./commands-B2C52dbI.mjs');
558
+ const { parseShareArg } = await import('./commands-DC5ay_Ne.mjs');
559
559
  const shareEntries = share.map((s) => parseShareArg(s));
560
560
  await sessionSpawn(agent, dir, targetMachineId, {
561
561
  message,
@@ -641,7 +641,7 @@ async function handleSessionCommand() {
641
641
  console.error("Usage: svamp session approve <session-id> [request-id] [--json]");
642
642
  process.exit(1);
643
643
  }
644
- const { sessionApprove } = await import('./commands-B2C52dbI.mjs');
644
+ const { sessionApprove } = await import('./commands-DC5ay_Ne.mjs');
645
645
  const approveReqId = sessionArgs[2] && !sessionArgs[2].startsWith("--") ? sessionArgs[2] : void 0;
646
646
  await sessionApprove(sessionArgs[1], approveReqId, targetMachineId, {
647
647
  json: hasFlag("--json")
@@ -651,7 +651,7 @@ async function handleSessionCommand() {
651
651
  console.error("Usage: svamp session deny <session-id> [request-id] [--json]");
652
652
  process.exit(1);
653
653
  }
654
- const { sessionDeny } = await import('./commands-B2C52dbI.mjs');
654
+ const { sessionDeny } = await import('./commands-DC5ay_Ne.mjs');
655
655
  const denyReqId = sessionArgs[2] && !sessionArgs[2].startsWith("--") ? sessionArgs[2] : void 0;
656
656
  await sessionDeny(sessionArgs[1], denyReqId, targetMachineId, {
657
657
  json: hasFlag("--json")
@@ -687,7 +687,7 @@ async function handleSessionCommand() {
687
687
  console.error("Usage: svamp session set-title <title>");
688
688
  process.exit(1);
689
689
  }
690
- const { sessionSetTitle } = await import('./agentCommands-Dk0gk58l.mjs');
690
+ const { sessionSetTitle } = await import('./agentCommands-DQG-ppC8.mjs');
691
691
  await sessionSetTitle(title);
692
692
  } else if (sessionSubcommand === "set-link") {
693
693
  const url = sessionArgs[1];
@@ -696,7 +696,7 @@ async function handleSessionCommand() {
696
696
  process.exit(1);
697
697
  }
698
698
  const label = sessionArgs[2] && !sessionArgs[2].startsWith("--") ? sessionArgs[2] : void 0;
699
- const { sessionSetLink } = await import('./agentCommands-Dk0gk58l.mjs');
699
+ const { sessionSetLink } = await import('./agentCommands-DQG-ppC8.mjs');
700
700
  await sessionSetLink(url, label);
701
701
  } else if (sessionSubcommand === "notify") {
702
702
  const message = sessionArgs[1];
@@ -705,7 +705,7 @@ async function handleSessionCommand() {
705
705
  process.exit(1);
706
706
  }
707
707
  const level = parseFlagStr("--level") || "info";
708
- const { sessionNotify } = await import('./agentCommands-Dk0gk58l.mjs');
708
+ const { sessionNotify } = await import('./agentCommands-DQG-ppC8.mjs');
709
709
  await sessionNotify(message, level);
710
710
  } else if (sessionSubcommand === "broadcast") {
711
711
  const action = sessionArgs[1];
@@ -713,7 +713,7 @@ async function handleSessionCommand() {
713
713
  console.error("Usage: svamp session broadcast <action> [args...]\nActions: open-canvas <url> [label], close-canvas, toast <message>");
714
714
  process.exit(1);
715
715
  }
716
- const { sessionBroadcast } = await import('./agentCommands-Dk0gk58l.mjs');
716
+ const { sessionBroadcast } = await import('./agentCommands-DQG-ppC8.mjs');
717
717
  await sessionBroadcast(action, sessionArgs.slice(2).filter((a) => !a.startsWith("--")));
718
718
  } else if (sessionSubcommand === "inbox") {
719
719
  const inboxSubcmd = sessionArgs[1];
@@ -724,7 +724,7 @@ async function handleSessionCommand() {
724
724
  process.exit(1);
725
725
  }
726
726
  if (agentSessionId) {
727
- const { inboxSend } = await import('./agentCommands-Dk0gk58l.mjs');
727
+ const { inboxSend } = await import('./agentCommands-DQG-ppC8.mjs');
728
728
  await inboxSend(sessionArgs[2], {
729
729
  body: sessionArgs[3],
730
730
  subject: parseFlagStr("--subject"),
@@ -739,7 +739,7 @@ async function handleSessionCommand() {
739
739
  }
740
740
  } else if (inboxSubcmd === "list" || inboxSubcmd === "ls") {
741
741
  if (agentSessionId && !sessionArgs[2]) {
742
- const { inboxList } = await import('./agentCommands-Dk0gk58l.mjs');
742
+ const { inboxList } = await import('./agentCommands-DQG-ppC8.mjs');
743
743
  await inboxList({
744
744
  unread: hasFlag("--unread"),
745
745
  limit: parseFlagInt("--limit"),
@@ -761,7 +761,7 @@ async function handleSessionCommand() {
761
761
  process.exit(1);
762
762
  }
763
763
  if (agentSessionId && !sessionArgs[3]) {
764
- const { inboxList } = await import('./agentCommands-Dk0gk58l.mjs');
764
+ const { inboxList } = await import('./agentCommands-DQG-ppC8.mjs');
765
765
  await sessionInboxRead(agentSessionId, sessionArgs[2], targetMachineId);
766
766
  } else if (sessionArgs[3]) {
767
767
  await sessionInboxRead(sessionArgs[2], sessionArgs[3], targetMachineId);
@@ -771,7 +771,7 @@ async function handleSessionCommand() {
771
771
  }
772
772
  } else if (inboxSubcmd === "reply") {
773
773
  if (agentSessionId && sessionArgs[2] && sessionArgs[3] && !sessionArgs[4]) {
774
- const { inboxReply } = await import('./agentCommands-Dk0gk58l.mjs');
774
+ const { inboxReply } = await import('./agentCommands-DQG-ppC8.mjs');
775
775
  await inboxReply(sessionArgs[2], sessionArgs[3]);
776
776
  } else if (sessionArgs[2] && sessionArgs[3] && sessionArgs[4]) {
777
777
  await sessionInboxReply(sessionArgs[2], sessionArgs[3], sessionArgs[4], targetMachineId);
@@ -807,7 +807,7 @@ async function handleMachineCommand() {
807
807
  return;
808
808
  }
809
809
  if (machineSubcommand === "share") {
810
- const { machineShare } = await import('./commands-B2C52dbI.mjs');
810
+ const { machineShare } = await import('./commands-DC5ay_Ne.mjs');
811
811
  let machineId;
812
812
  const shareArgs = [];
813
813
  for (let i = 1; i < machineArgs.length; i++) {
@@ -837,7 +837,7 @@ async function handleMachineCommand() {
837
837
  }
838
838
  await machineShare(machineId, { add, remove, list, configPath, showConfig });
839
839
  } else if (machineSubcommand === "exec") {
840
- const { machineExec } = await import('./commands-B2C52dbI.mjs');
840
+ const { machineExec } = await import('./commands-DC5ay_Ne.mjs');
841
841
  let machineId;
842
842
  let cwd;
843
843
  const cmdParts = [];
@@ -857,7 +857,7 @@ async function handleMachineCommand() {
857
857
  }
858
858
  await machineExec(machineId, command, cwd);
859
859
  } else if (machineSubcommand === "info") {
860
- const { machineInfo } = await import('./commands-B2C52dbI.mjs');
860
+ const { machineInfo } = await import('./commands-DC5ay_Ne.mjs');
861
861
  let machineId;
862
862
  for (let i = 1; i < machineArgs.length; i++) {
863
863
  if ((machineArgs[i] === "--machine" || machineArgs[i] === "-m") && i + 1 < machineArgs.length) {
@@ -877,10 +877,10 @@ async function handleMachineCommand() {
877
877
  level = machineArgs[++i];
878
878
  }
879
879
  }
880
- const { machineNotify } = await import('./agentCommands-Dk0gk58l.mjs');
880
+ const { machineNotify } = await import('./agentCommands-DQG-ppC8.mjs');
881
881
  await machineNotify(message, level);
882
882
  } else if (machineSubcommand === "ls") {
883
- const { machineLs } = await import('./commands-B2C52dbI.mjs');
883
+ const { machineLs } = await import('./commands-DC5ay_Ne.mjs');
884
884
  let machineId;
885
885
  let showHidden = false;
886
886
  let path;
@@ -1,11 +1,11 @@
1
1
  import { writeFileSync, readFileSync } from 'fs';
2
2
  import { resolve } from 'path';
3
- import { connectAndGetMachine } from './commands-B2C52dbI.mjs';
3
+ import { connectAndGetMachine } from './commands-DC5ay_Ne.mjs';
4
4
  import 'node:fs';
5
5
  import 'node:child_process';
6
6
  import 'node:path';
7
7
  import 'node:os';
8
- import './run-B3BZk1Vy.mjs';
8
+ import './run-B9RS4JWP.mjs';
9
9
  import 'os';
10
10
  import 'fs/promises';
11
11
  import 'url';
@@ -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-B3BZk1Vy.mjs';
5
+ import { l as loadSecurityContextConfig, e as resolveSecurityContext, f as buildSecurityContextFromFlags, m as mergeSecurityContexts, c as connectToHypha } from './run-B9RS4JWP.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-B3BZk1Vy.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-B9RS4JWP.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.2.14";
2
+ var version = "0.2.16";
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";
@@ -3,7 +3,7 @@ import fs, { mkdir as mkdir$1, readdir as readdir$1, readFile, writeFile as writ
3
3
  import { readFileSync as readFileSync$1, mkdirSync, writeFileSync, renameSync, existsSync as existsSync$1, copyFileSync, unlinkSync, watch, rmdirSync } from 'fs';
4
4
  import path__default, { join, dirname, resolve, basename } from 'path';
5
5
  import { fileURLToPath } from 'url';
6
- import { spawn as spawn$1 } from 'child_process';
6
+ import { spawn as spawn$1, execSync as execSync$1 } from 'child_process';
7
7
  import { randomUUID as randomUUID$1 } from 'crypto';
8
8
  import { existsSync, readFileSync, writeFileSync as writeFileSync$1, mkdirSync as mkdirSync$1, appendFileSync } from 'node:fs';
9
9
  import { randomUUID, createHash } from 'node:crypto';
@@ -6133,8 +6133,12 @@ async function startDaemon(options) {
6133
6133
  // hypha-rpc: RPC call failed after reconnect (often wraps the cache store error)
6134
6134
  "Rate limit",
6135
6135
  // Hypha server 429 rate limiting — transient, will resolve on its own
6136
- "status 429"
6136
+ "status 429",
6137
6137
  // HTTP 429 status code
6138
+ "Service not found",
6139
+ // Machine service lost server-side — heartbeat will force reconnection
6140
+ "terminated"
6141
+ // HTTP fetch/stream terminated — transport will auto-reconnect
6138
6142
  ];
6139
6143
  let unhandledRejectionCount = 0;
6140
6144
  let unhandledRejectionResetTimer = null;
@@ -6437,26 +6441,40 @@ async function startDaemon(options) {
6437
6441
  let startupFailureRetryPending = false;
6438
6442
  let startupRetryMessage;
6439
6443
  let startupNonJsonLines = [];
6440
- const STUCK_PROCESS_TIMEOUT_MS = 10 * 60 * 1e3;
6441
- const STUCK_CHECK_INTERVAL_MS = 60 * 1e3;
6444
+ const STUCK_PROCESS_TIMEOUT_MS = 30 * 60 * 1e3;
6445
+ const STUCK_CHECK_INTERVAL_MS = 2 * 60 * 1e3;
6442
6446
  let lastOutputTime = Date.now();
6443
6447
  let stuckWatchdogTimer = null;
6448
+ const hasActiveChildren = (pid) => {
6449
+ try {
6450
+ const result = execSync$1(`pgrep -P ${pid}`, { encoding: "utf8", timeout: 5e3 });
6451
+ return result.trim().length > 0;
6452
+ } catch {
6453
+ return false;
6454
+ }
6455
+ };
6444
6456
  const startStuckWatchdog = () => {
6445
6457
  if (stuckWatchdogTimer) return;
6446
6458
  stuckWatchdogTimer = setInterval(() => {
6447
6459
  if (!claudeProcess || claudeProcess.exitCode !== null) return;
6460
+ if (!sessionWasProcessing) return;
6461
+ const ralphState = readRalphState(getRalphStateFilePath(directory, sessionId));
6462
+ if (!ralphState) return;
6463
+ if (claudeProcess.pid && hasActiveChildren(claudeProcess.pid)) {
6464
+ lastOutputTime = Date.now();
6465
+ return;
6466
+ }
6448
6467
  const elapsed = Date.now() - lastOutputTime;
6449
6468
  if (elapsed > STUCK_PROCESS_TIMEOUT_MS) {
6450
- logger.log(`[Session ${sessionId}] Stuck process detected: no output for ${Math.round(elapsed / 1e3)}s \u2014 killing`);
6469
+ logger.log(`[Session ${sessionId}] Ralph Loop stuck: mid-turn, no output for ${Math.round(elapsed / 1e3)}s, no child processes \u2014 killing to unblock next iteration`);
6451
6470
  sessionService.pushMessage(
6452
- { type: "message", message: `Agent process appears stuck (no output for ${Math.round(elapsed / 6e4)} minutes). Restarting...`, level: "warning" },
6471
+ { type: "message", message: `Ralph Loop iteration appears stuck (no output for ${Math.round(elapsed / 6e4)} minutes, no active tools). Restarting to continue loop...`, level: "warning" },
6453
6472
  "event"
6454
6473
  );
6455
6474
  claudeProcess.kill("SIGTERM");
6456
6475
  setTimeout(() => {
6457
- const ralphState = readRalphState(getRalphStateFilePath(directory, sessionId));
6458
- if (ralphState && !trackedSession.stopped) {
6459
- logger.log(`[Session ${sessionId}] Stuck watchdog: Ralph loop active, sending nudge to resume`);
6476
+ if (!trackedSession.stopped) {
6477
+ logger.log(`[Session ${sessionId}] Stuck watchdog: nudging Ralph loop to resume`);
6460
6478
  processMessageQueueRef?.();
6461
6479
  }
6462
6480
  }, 3e3);
@@ -7473,10 +7491,10 @@ The automated loop has finished. Review the progress above and let me know if yo
7473
7491
  if (trackedSession?.stopped) return;
7474
7492
  logger.log(`[Session ${sessionId}] Inbox message received (urgency: ${message.urgency || "normal"}, from: ${message.from || "unknown"})`);
7475
7493
  const formatted = formatInboxMessageXml(message);
7476
- sessionService.pushMessage(formatted, "user");
7477
7494
  sessionService.markInboxRead(message.messageId);
7478
7495
  if (message.urgency === "urgent") {
7479
7496
  logger.log(`[Session ${sessionId}] Delivering urgent inbox message to agent`);
7497
+ sessionService.pushMessage(formatted, "user");
7480
7498
  if (!claudeProcess || claudeProcess.exitCode !== null) {
7481
7499
  spawnClaude(formatted);
7482
7500
  } else {
@@ -7488,6 +7506,17 @@ The automated loop has finished. Review the progress above and let me know if yo
7488
7506
  }
7489
7507
  signalProcessing(true);
7490
7508
  sessionWasProcessing = true;
7509
+ } else {
7510
+ logger.log(`[Session ${sessionId}] Queuing non-urgent inbox message for idle processing`);
7511
+ const existingQueue = sessionMetadata.messageQueue || [];
7512
+ sessionMetadata = {
7513
+ ...sessionMetadata,
7514
+ messageQueue: [...existingQueue, { id: message.messageId, text: formatted, displayText: formatted, createdAt: Date.now() }]
7515
+ };
7516
+ sessionService.updateMetadata(sessionMetadata);
7517
+ if (!sessionWasProcessing) {
7518
+ setTimeout(() => processMessageQueueRef?.(), 200);
7519
+ }
7491
7520
  }
7492
7521
  },
7493
7522
  onMetadataUpdate: (newMeta) => {
@@ -7899,10 +7928,10 @@ The automated loop has finished. Review the progress above and let me know if yo
7899
7928
  if (acpStopped) return;
7900
7929
  logger.log(`[${agentName} Session ${sessionId}] Inbox message received (urgency: ${message.urgency || "normal"}, from: ${message.from || "unknown"})`);
7901
7930
  const formatted = formatInboxMessageXml(message);
7902
- sessionService.pushMessage(formatted, "user");
7903
7931
  sessionService.markInboxRead(message.messageId);
7904
7932
  if (message.urgency === "urgent" && acpBackendReady) {
7905
7933
  logger.log(`[${agentName} Session ${sessionId}] Delivering urgent inbox message to agent`);
7934
+ sessionService.pushMessage(formatted, "user");
7906
7935
  sessionMetadata = { ...sessionMetadata, lifecycleState: "running" };
7907
7936
  sessionService.updateMetadata(sessionMetadata);
7908
7937
  sessionService.sendKeepAlive(true);
@@ -7914,6 +7943,33 @@ The automated loop has finished. Review the progress above and let me know if yo
7914
7943
  sessionService.sendSessionEnd();
7915
7944
  }
7916
7945
  });
7946
+ } else if (!message.urgency || message.urgency !== "urgent") {
7947
+ logger.log(`[${agentName} Session ${sessionId}] Queuing non-urgent inbox message for idle processing`);
7948
+ const existingQueue = sessionMetadata.messageQueue || [];
7949
+ sessionMetadata = {
7950
+ ...sessionMetadata,
7951
+ messageQueue: [...existingQueue, { id: message.messageId, text: formatted, displayText: formatted, createdAt: Date.now() }]
7952
+ };
7953
+ sessionService.updateMetadata(sessionMetadata);
7954
+ if (sessionMetadata.lifecycleState === "idle" && acpBackendReady) {
7955
+ const queue = sessionMetadata.messageQueue;
7956
+ if (queue && queue.length > 0) {
7957
+ const next = queue[0];
7958
+ const remaining = queue.slice(1);
7959
+ sessionMetadata = { ...sessionMetadata, messageQueue: remaining.length > 0 ? remaining : void 0, lifecycleState: "running" };
7960
+ sessionService.updateMetadata(sessionMetadata);
7961
+ sessionService.pushMessage(next.text, "user");
7962
+ sessionService.sendKeepAlive(true);
7963
+ agentBackend.sendPrompt(sessionId, next.text).catch((err) => {
7964
+ logger.error(`[${agentName} Session ${sessionId}] Error processing queued inbox message: ${err.message}`);
7965
+ if (!acpStopped) {
7966
+ sessionMetadata = { ...sessionMetadata, lifecycleState: "idle" };
7967
+ sessionService.updateMetadata(sessionMetadata);
7968
+ sessionService.sendSessionEnd();
7969
+ }
7970
+ });
7971
+ }
7972
+ }
7917
7973
  }
7918
7974
  },
7919
7975
  onMetadataUpdate: (newMeta) => {
@@ -8654,13 +8710,14 @@ The automated loop has finished. Review the progress above and let me know if yo
8654
8710
  if (!inGrace) {
8655
8711
  try {
8656
8712
  const pingStart = Date.now();
8713
+ const machineServiceId = `${server.config.client_id}:default`;
8657
8714
  await Promise.race([
8658
- server.echo("ping"),
8659
- new Promise((_, reject) => setTimeout(() => reject(new Error("Ping timed out")), PING_TIMEOUT_MS))
8715
+ server.getService(machineServiceId),
8716
+ new Promise((_, reject) => setTimeout(() => reject(new Error("Service probe timed out")), PING_TIMEOUT_MS))
8660
8717
  ]);
8661
8718
  const pingMs = Date.now() - pingStart;
8662
8719
  if (pingMs > 5e3) {
8663
- logger.log(`Slow ping: ${pingMs}ms (server under load)`);
8720
+ logger.log(`Slow service probe: ${pingMs}ms (server under load)`);
8664
8721
  }
8665
8722
  if (consecutiveHeartbeatFailures > 0) {
8666
8723
  logger.log(`Heartbeat recovered after ${consecutiveHeartbeatFailures} failures`);
@@ -8668,8 +8725,9 @@ The automated loop has finished. Review the progress above and let me know if yo
8668
8725
  }
8669
8726
  } catch (err) {
8670
8727
  consecutiveHeartbeatFailures++;
8728
+ const isServiceMissing = err.message?.includes("Service not found") || err.message?.includes("KeyError");
8671
8729
  if (consecutiveHeartbeatFailures === 1) {
8672
- logger.log(`Ping failed: ${err.message}`);
8730
+ logger.log(`Service probe failed: ${err.message}${isServiceMissing ? " \u2014 machine service lost, forcing reconnection to re-register" : ""}`);
8673
8731
  } else if (consecutiveHeartbeatFailures % 6 === 0) {
8674
8732
  logger.log(`Connection down for ${consecutiveHeartbeatFailures * HEARTBEAT_INTERVAL_MS / 1e3}s (${consecutiveHeartbeatFailures} failures, retrying indefinitely)`);
8675
8733
  }
@@ -8847,8 +8905,8 @@ async function stopDaemon(options) {
8847
8905
  }
8848
8906
  if (pidsToSignal.length === 0) {
8849
8907
  try {
8850
- const { execSync } = await import('child_process');
8851
- const pgrepOutput = execSync(
8908
+ const { execSync: execSync2 } = await import('child_process');
8909
+ const pgrepOutput = execSync2(
8852
8910
  'pgrep -f "svamp daemon start-(supervised|sync)" 2>/dev/null || true',
8853
8911
  { encoding: "utf-8" }
8854
8912
  ).trim();
@@ -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-B3BZk1Vy.mjs';
5
+ import { c as connectToHypha, a as registerSessionService } from './run-B9RS4JWP.mjs';
6
6
  import { createServer } from 'node:http';
7
7
  import { spawn } from 'node:child_process';
8
8
  import { createInterface } from 'node:readline';
@@ -52,7 +52,7 @@ async function handleServeCommand() {
52
52
  }
53
53
  }
54
54
  async function serveAdd(args, machineId) {
55
- const { connectAndGetMachine } = await import('./commands-B2C52dbI.mjs');
55
+ const { connectAndGetMachine } = await import('./commands-DC5ay_Ne.mjs');
56
56
  const pos = positionalArgs(args);
57
57
  const name = pos[0];
58
58
  if (!name) {
@@ -84,7 +84,7 @@ async function serveAdd(args, machineId) {
84
84
  }
85
85
  }
86
86
  async function serveRemove(args, machineId) {
87
- const { connectAndGetMachine } = await import('./commands-B2C52dbI.mjs');
87
+ const { connectAndGetMachine } = await import('./commands-DC5ay_Ne.mjs');
88
88
  const pos = positionalArgs(args);
89
89
  const name = pos[0];
90
90
  if (!name) {
@@ -104,7 +104,7 @@ async function serveRemove(args, machineId) {
104
104
  }
105
105
  }
106
106
  async function serveList(args, machineId) {
107
- const { connectAndGetMachine } = await import('./commands-B2C52dbI.mjs');
107
+ const { connectAndGetMachine } = await import('./commands-DC5ay_Ne.mjs');
108
108
  const all = hasFlag(args, "--all", "-a");
109
109
  const json = hasFlag(args, "--json");
110
110
  const sessionId = getFlag(args, "--session");
@@ -137,7 +137,7 @@ async function serveList(args, machineId) {
137
137
  }
138
138
  }
139
139
  async function serveInfo(machineId) {
140
- const { connectAndGetMachine } = await import('./commands-B2C52dbI.mjs');
140
+ const { connectAndGetMachine } = await import('./commands-DC5ay_Ne.mjs');
141
141
  const { machine, server } = await connectAndGetMachine(machineId);
142
142
  try {
143
143
  const info = await machine.serveInfo({ _rkwargs: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svamp-cli",
3
- "version": "0.2.14",
3
+ "version": "0.2.16",
4
4
  "description": "Svamp CLI — AI workspace daemon on Hypha Cloud",
5
5
  "author": "Amun AI AB",
6
6
  "license": "SEE LICENSE IN LICENSE",