svamp-cli 0.1.80 → 0.1.81

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.
@@ -145,7 +145,7 @@ async function sessionBroadcast(action, args) {
145
145
  console.log(`Broadcast sent: ${action}`);
146
146
  }
147
147
  async function connectToMachineService() {
148
- const { connectAndGetMachine } = await import('./commands-C06J5fW3.mjs');
148
+ const { connectAndGetMachine } = await import('./commands-6PO-ky9k.mjs');
149
149
  return connectAndGetMachine();
150
150
  }
151
151
  async function inboxSend(targetSessionId, opts) {
@@ -161,7 +161,7 @@ async function inboxSend(targetSessionId, opts) {
161
161
  }
162
162
  const { server, machine } = await connectToMachineService();
163
163
  try {
164
- const { resolveSessionId } = await import('./commands-C06J5fW3.mjs');
164
+ const { resolveSessionId } = await import('./commands-6PO-ky9k.mjs');
165
165
  const sessions = await machine.listSessions();
166
166
  const match = resolveSessionId(sessions, targetSessionId);
167
167
  const fullTargetId = match.sessionId;
package/dist/cli.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { b as stopDaemon, s as startDaemon, d as daemonStatus } from './run-Dm7UViwQ.mjs';
1
+ import { b as stopDaemon, s as startDaemon, d as daemonStatus } from './run-kLd-u7KD.mjs';
2
2
  import 'os';
3
3
  import 'fs/promises';
4
4
  import 'fs';
@@ -211,7 +211,7 @@ async function main() {
211
211
  const { handleServiceCommand } = await import('./commands-BYbuedOK.mjs');
212
212
  await handleServiceCommand();
213
213
  } else if (subcommand === "process" || subcommand === "proc") {
214
- const { processCommand } = await import('./commands-CphOj2pR.mjs');
214
+ const { processCommand } = await import('./commands-B41tMO2x.mjs');
215
215
  let machineId;
216
216
  const processArgs = args.slice(1);
217
217
  const mIdx = processArgs.findIndex((a) => a === "--machine" || a === "-m");
@@ -229,7 +229,7 @@ async function main() {
229
229
  } else if (!subcommand || subcommand === "start") {
230
230
  await handleInteractiveCommand();
231
231
  } else if (subcommand === "--version" || subcommand === "-v") {
232
- const pkg = await import('./package-CSxyijZF.mjs').catch(() => ({ default: { version: "unknown" } }));
232
+ const pkg = await import('./package-BoA_DXNG.mjs').catch(() => ({ default: { version: "unknown" } }));
233
233
  console.log(`svamp version: ${pkg.default.version}`);
234
234
  } else {
235
235
  console.error(`Unknown command: ${subcommand}`);
@@ -238,7 +238,7 @@ async function main() {
238
238
  }
239
239
  }
240
240
  async function handleInteractiveCommand() {
241
- const { runInteractive } = await import('./run-DsSVL5N4.mjs');
241
+ const { runInteractive } = await import('./run-BDAinUvU.mjs');
242
242
  const interactiveArgs = subcommand === "start" ? args.slice(1) : args;
243
243
  let directory = process.cwd();
244
244
  let resumeSessionId;
@@ -283,7 +283,7 @@ async function handleAgentCommand() {
283
283
  return;
284
284
  }
285
285
  if (agentArgs[0] === "list") {
286
- const { KNOWN_ACP_AGENTS, KNOWN_MCP_AGENTS: KNOWN_MCP_AGENTS2 } = await import('./run-Dm7UViwQ.mjs').then(function (n) { return n.i; });
286
+ const { KNOWN_ACP_AGENTS, KNOWN_MCP_AGENTS: KNOWN_MCP_AGENTS2 } = await import('./run-kLd-u7KD.mjs').then(function (n) { return n.i; });
287
287
  console.log("Known agents:");
288
288
  for (const [name, config2] of Object.entries(KNOWN_ACP_AGENTS)) {
289
289
  console.log(` ${name.padEnd(12)} ${config2.command} ${config2.args.join(" ")} (ACP)`);
@@ -295,7 +295,7 @@ async function handleAgentCommand() {
295
295
  console.log('Use "svamp agent -- <command> [args]" for a custom ACP agent.');
296
296
  return;
297
297
  }
298
- const { resolveAcpAgentConfig, KNOWN_MCP_AGENTS } = await import('./run-Dm7UViwQ.mjs').then(function (n) { return n.i; });
298
+ const { resolveAcpAgentConfig, KNOWN_MCP_AGENTS } = await import('./run-kLd-u7KD.mjs').then(function (n) { return n.i; });
299
299
  let cwd = process.cwd();
300
300
  const filteredArgs = [];
301
301
  for (let i = 0; i < agentArgs.length; i++) {
@@ -319,12 +319,12 @@ async function handleAgentCommand() {
319
319
  console.log(`Starting ${config.agentName} agent in ${cwd}...`);
320
320
  let backend;
321
321
  if (KNOWN_MCP_AGENTS[config.agentName]) {
322
- const { CodexMcpBackend } = await import('./run-Dm7UViwQ.mjs').then(function (n) { return n.j; });
322
+ const { CodexMcpBackend } = await import('./run-kLd-u7KD.mjs').then(function (n) { return n.j; });
323
323
  backend = new CodexMcpBackend({ cwd, log: logFn });
324
324
  } else {
325
- const { AcpBackend } = await import('./run-Dm7UViwQ.mjs').then(function (n) { return n.h; });
326
- const { GeminiTransport } = await import('./run-Dm7UViwQ.mjs').then(function (n) { return n.G; });
327
- const { DefaultTransport } = await import('./run-Dm7UViwQ.mjs').then(function (n) { return n.D; });
325
+ const { AcpBackend } = await import('./run-kLd-u7KD.mjs').then(function (n) { return n.h; });
326
+ const { GeminiTransport } = await import('./run-kLd-u7KD.mjs').then(function (n) { return n.G; });
327
+ const { DefaultTransport } = await import('./run-kLd-u7KD.mjs').then(function (n) { return n.D; });
328
328
  const transportHandler = config.agentName === "gemini" ? new GeminiTransport() : new DefaultTransport(config.agentName);
329
329
  backend = new AcpBackend({
330
330
  agentName: config.agentName,
@@ -442,7 +442,7 @@ async function handleSessionCommand() {
442
442
  printSessionHelp();
443
443
  return;
444
444
  }
445
- const { sessionList, sessionSpawn, sessionStop, sessionInfo, sessionMessages, sessionAttach, sessionMachines, sessionSend, sessionWait, sessionShare, sessionRalphStart, sessionRalphCancel, sessionRalphStatus, sessionInboxSend, sessionInboxList, sessionInboxRead, sessionInboxReply, sessionInboxClear } = await import('./commands-C06J5fW3.mjs');
445
+ const { sessionList, sessionSpawn, sessionStop, sessionInfo, sessionMessages, sessionAttach, sessionMachines, sessionSend, sessionWait, sessionShare, sessionRalphStart, sessionRalphCancel, sessionRalphStatus, sessionInboxSend, sessionInboxList, sessionInboxRead, sessionInboxReply, sessionInboxClear } = await import('./commands-6PO-ky9k.mjs');
446
446
  const parseFlagStr = (flag, shortFlag) => {
447
447
  for (let i = 1; i < sessionArgs.length; i++) {
448
448
  if ((sessionArgs[i] === flag || shortFlag) && i + 1 < sessionArgs.length) {
@@ -502,7 +502,7 @@ async function handleSessionCommand() {
502
502
  allowDomain.push(sessionArgs[++i]);
503
503
  }
504
504
  }
505
- const { parseShareArg } = await import('./commands-C06J5fW3.mjs');
505
+ const { parseShareArg } = await import('./commands-6PO-ky9k.mjs');
506
506
  const shareEntries = share.map((s) => parseShareArg(s));
507
507
  await sessionSpawn(agent, dir, targetMachineId, {
508
508
  message,
@@ -588,7 +588,7 @@ async function handleSessionCommand() {
588
588
  console.error("Usage: svamp session approve <session-id> [request-id] [--json]");
589
589
  process.exit(1);
590
590
  }
591
- const { sessionApprove } = await import('./commands-C06J5fW3.mjs');
591
+ const { sessionApprove } = await import('./commands-6PO-ky9k.mjs');
592
592
  const approveReqId = sessionArgs[2] && !sessionArgs[2].startsWith("--") ? sessionArgs[2] : void 0;
593
593
  await sessionApprove(sessionArgs[1], approveReqId, targetMachineId, {
594
594
  json: hasFlag("--json")
@@ -598,7 +598,7 @@ async function handleSessionCommand() {
598
598
  console.error("Usage: svamp session deny <session-id> [request-id] [--json]");
599
599
  process.exit(1);
600
600
  }
601
- const { sessionDeny } = await import('./commands-C06J5fW3.mjs');
601
+ const { sessionDeny } = await import('./commands-6PO-ky9k.mjs');
602
602
  const denyReqId = sessionArgs[2] && !sessionArgs[2].startsWith("--") ? sessionArgs[2] : void 0;
603
603
  await sessionDeny(sessionArgs[1], denyReqId, targetMachineId, {
604
604
  json: hasFlag("--json")
@@ -634,7 +634,7 @@ async function handleSessionCommand() {
634
634
  console.error("Usage: svamp session set-title <title>");
635
635
  process.exit(1);
636
636
  }
637
- const { sessionSetTitle } = await import('./agentCommands-WLRw5gAP.mjs');
637
+ const { sessionSetTitle } = await import('./agentCommands-BnAlpm77.mjs');
638
638
  await sessionSetTitle(title);
639
639
  } else if (sessionSubcommand === "set-link") {
640
640
  const url = sessionArgs[1];
@@ -643,7 +643,7 @@ async function handleSessionCommand() {
643
643
  process.exit(1);
644
644
  }
645
645
  const label = sessionArgs[2] && !sessionArgs[2].startsWith("--") ? sessionArgs[2] : void 0;
646
- const { sessionSetLink } = await import('./agentCommands-WLRw5gAP.mjs');
646
+ const { sessionSetLink } = await import('./agentCommands-BnAlpm77.mjs');
647
647
  await sessionSetLink(url, label);
648
648
  } else if (sessionSubcommand === "notify") {
649
649
  const message = sessionArgs[1];
@@ -652,7 +652,7 @@ async function handleSessionCommand() {
652
652
  process.exit(1);
653
653
  }
654
654
  const level = parseFlagStr("--level") || "info";
655
- const { sessionNotify } = await import('./agentCommands-WLRw5gAP.mjs');
655
+ const { sessionNotify } = await import('./agentCommands-BnAlpm77.mjs');
656
656
  await sessionNotify(message, level);
657
657
  } else if (sessionSubcommand === "broadcast") {
658
658
  const action = sessionArgs[1];
@@ -660,7 +660,7 @@ async function handleSessionCommand() {
660
660
  console.error("Usage: svamp session broadcast <action> [args...]\nActions: open-canvas <url> [label], close-canvas, toast <message>");
661
661
  process.exit(1);
662
662
  }
663
- const { sessionBroadcast } = await import('./agentCommands-WLRw5gAP.mjs');
663
+ const { sessionBroadcast } = await import('./agentCommands-BnAlpm77.mjs');
664
664
  await sessionBroadcast(action, sessionArgs.slice(2).filter((a) => !a.startsWith("--")));
665
665
  } else if (sessionSubcommand === "inbox") {
666
666
  const inboxSubcmd = sessionArgs[1];
@@ -671,7 +671,7 @@ async function handleSessionCommand() {
671
671
  process.exit(1);
672
672
  }
673
673
  if (agentSessionId) {
674
- const { inboxSend } = await import('./agentCommands-WLRw5gAP.mjs');
674
+ const { inboxSend } = await import('./agentCommands-BnAlpm77.mjs');
675
675
  await inboxSend(sessionArgs[2], {
676
676
  body: sessionArgs[3],
677
677
  subject: parseFlagStr("--subject"),
@@ -686,7 +686,7 @@ async function handleSessionCommand() {
686
686
  }
687
687
  } else if (inboxSubcmd === "list" || inboxSubcmd === "ls") {
688
688
  if (agentSessionId && !sessionArgs[2]) {
689
- const { inboxList } = await import('./agentCommands-WLRw5gAP.mjs');
689
+ const { inboxList } = await import('./agentCommands-BnAlpm77.mjs');
690
690
  await inboxList({
691
691
  unread: hasFlag("--unread"),
692
692
  limit: parseFlagInt("--limit"),
@@ -708,7 +708,7 @@ async function handleSessionCommand() {
708
708
  process.exit(1);
709
709
  }
710
710
  if (agentSessionId && !sessionArgs[3]) {
711
- const { inboxList } = await import('./agentCommands-WLRw5gAP.mjs');
711
+ const { inboxList } = await import('./agentCommands-BnAlpm77.mjs');
712
712
  await sessionInboxRead(agentSessionId, sessionArgs[2], targetMachineId);
713
713
  } else if (sessionArgs[3]) {
714
714
  await sessionInboxRead(sessionArgs[2], sessionArgs[3], targetMachineId);
@@ -718,7 +718,7 @@ async function handleSessionCommand() {
718
718
  }
719
719
  } else if (inboxSubcmd === "reply") {
720
720
  if (agentSessionId && sessionArgs[2] && sessionArgs[3] && !sessionArgs[4]) {
721
- const { inboxReply } = await import('./agentCommands-WLRw5gAP.mjs');
721
+ const { inboxReply } = await import('./agentCommands-BnAlpm77.mjs');
722
722
  await inboxReply(sessionArgs[2], sessionArgs[3]);
723
723
  } else if (sessionArgs[2] && sessionArgs[3] && sessionArgs[4]) {
724
724
  await sessionInboxReply(sessionArgs[2], sessionArgs[3], sessionArgs[4], targetMachineId);
@@ -754,7 +754,7 @@ async function handleMachineCommand() {
754
754
  return;
755
755
  }
756
756
  if (machineSubcommand === "share") {
757
- const { machineShare } = await import('./commands-C06J5fW3.mjs');
757
+ const { machineShare } = await import('./commands-6PO-ky9k.mjs');
758
758
  let machineId;
759
759
  const shareArgs = [];
760
760
  for (let i = 1; i < machineArgs.length; i++) {
@@ -784,7 +784,7 @@ async function handleMachineCommand() {
784
784
  }
785
785
  await machineShare(machineId, { add, remove, list, configPath, showConfig });
786
786
  } else if (machineSubcommand === "exec") {
787
- const { machineExec } = await import('./commands-C06J5fW3.mjs');
787
+ const { machineExec } = await import('./commands-6PO-ky9k.mjs');
788
788
  let machineId;
789
789
  let cwd;
790
790
  const cmdParts = [];
@@ -804,7 +804,7 @@ async function handleMachineCommand() {
804
804
  }
805
805
  await machineExec(machineId, command, cwd);
806
806
  } else if (machineSubcommand === "info") {
807
- const { machineInfo } = await import('./commands-C06J5fW3.mjs');
807
+ const { machineInfo } = await import('./commands-6PO-ky9k.mjs');
808
808
  let machineId;
809
809
  for (let i = 1; i < machineArgs.length; i++) {
810
810
  if ((machineArgs[i] === "--machine" || machineArgs[i] === "-m") && i + 1 < machineArgs.length) {
@@ -824,10 +824,10 @@ async function handleMachineCommand() {
824
824
  level = machineArgs[++i];
825
825
  }
826
826
  }
827
- const { machineNotify } = await import('./agentCommands-WLRw5gAP.mjs');
827
+ const { machineNotify } = await import('./agentCommands-BnAlpm77.mjs');
828
828
  await machineNotify(message, level);
829
829
  } else if (machineSubcommand === "ls") {
830
- const { machineLs } = await import('./commands-C06J5fW3.mjs');
830
+ const { machineLs } = await import('./commands-6PO-ky9k.mjs');
831
831
  let machineId;
832
832
  let showHidden = false;
833
833
  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-Dm7UViwQ.mjs';
5
+ import { l as loadSecurityContextConfig, e as resolveSecurityContext, f as buildSecurityContextFromFlags, m as mergeSecurityContexts, c as connectToHypha } from './run-kLd-u7KD.mjs';
6
6
  import 'os';
7
7
  import 'fs/promises';
8
8
  import 'fs';
@@ -70,6 +70,13 @@ function formatJson(data) {
70
70
  return JSON.stringify(data, null, 2);
71
71
  }
72
72
 
73
+ function getSessionProxy(machine, sessionId) {
74
+ return new Proxy({}, {
75
+ get(_target, method) {
76
+ return (...args) => machine.sessionRPC(sessionId, method, args);
77
+ }
78
+ });
79
+ }
73
80
  const SVAMP_HOME = process.env.SVAMP_HOME || join(os.homedir(), ".svamp");
74
81
  const DAEMON_STATE_FILE = join(SVAMP_HOME, "daemon.state.json");
75
82
  const ENV_FILE = join(SVAMP_HOME, ".env");
@@ -318,12 +325,11 @@ async function connectAndGetAllMachines() {
318
325
  const machines = [];
319
326
  try {
320
327
  const services = await server.listServices({ query: { type: "svamp-machine" }, include_unlisted: true, _rkwargs: true });
321
- for (const svc of services) {
322
- try {
323
- const svcId = svc.id || svc.name;
324
- machines.push(await server.getService(svcId));
325
- } catch {
326
- }
328
+ const results = await Promise.allSettled(
329
+ services.map((svc) => server.getService(svc.id || svc.name))
330
+ );
331
+ for (const r of results) {
332
+ if (r.status === "fulfilled") machines.push(r.value);
327
333
  }
328
334
  } catch (err) {
329
335
  restoreConsole();
@@ -402,34 +408,37 @@ async function sessionMachines() {
402
408
  console.log("No machines found.");
403
409
  return;
404
410
  }
405
- const machines = [];
406
- for (const svc of services) {
407
- const svcId = svc.id || svc.name;
408
- try {
409
- const machineSvc = await server.getService(svcId);
410
- const info = await machineSvc.getMachineInfo();
411
- const sessions = await machineSvc.listSessions();
412
- machines.push({
413
- serviceId: svcId,
414
- machineId: info.machineId || svcId,
415
- displayName: info.metadata?.displayName || info.metadata?.host || "-",
416
- platform: info.metadata?.platform || "-",
417
- host: info.metadata?.host || "-",
418
- sessions: sessions.length,
419
- status: info.daemonState?.status || "unknown"
420
- });
421
- } catch {
422
- machines.push({
423
- serviceId: svcId,
424
- machineId: svcId,
425
- displayName: "-",
426
- platform: "-",
427
- host: "-",
428
- sessions: -1,
429
- status: "unreachable"
430
- });
431
- }
432
- }
411
+ const machines = await Promise.all(
412
+ services.map(async (svc) => {
413
+ const svcId = svc.id || svc.name;
414
+ try {
415
+ const machineSvc = await server.getService(svcId);
416
+ const [info, sessions] = await Promise.all([
417
+ machineSvc.getMachineInfo(),
418
+ machineSvc.listSessions()
419
+ ]);
420
+ return {
421
+ serviceId: svcId,
422
+ machineId: info.machineId || svcId,
423
+ displayName: info.metadata?.displayName || info.metadata?.host || "-",
424
+ platform: info.metadata?.platform || "-",
425
+ host: info.metadata?.host || "-",
426
+ sessions: sessions.length,
427
+ status: info.daemonState?.status || "unknown"
428
+ };
429
+ } catch {
430
+ return {
431
+ serviceId: svcId,
432
+ machineId: svcId,
433
+ displayName: "-",
434
+ platform: "-",
435
+ host: "-",
436
+ sessions: -1,
437
+ status: "unreachable"
438
+ };
439
+ }
440
+ })
441
+ );
433
442
  const header = `${"MACHINE ID".padEnd(20)} ${"NAME".padEnd(20)} ${"PLATFORM".padEnd(12)} ${"HOST".padEnd(25)} ${"SESSIONS".padEnd(10)} ${"STATUS"}`;
434
443
  console.log(header);
435
444
  console.log("-".repeat(header.length));
@@ -672,18 +681,23 @@ async function sessionList(machineId, opts) {
672
681
  }
673
682
  }
674
683
  }
675
- async function listSessionsFromMachines(server, machines, opts) {
684
+ async function listSessionsFromMachines(_server, machines, opts) {
676
685
  const allSessions = [];
677
- for (const machine of machines) {
678
- try {
679
- const info = await machine.getMachineInfo();
680
- const sessions = await machine.listSessions();
686
+ const machineResults = await Promise.allSettled(
687
+ machines.map(async (machine) => {
688
+ const [info, sessions] = await Promise.all([
689
+ machine.getMachineInfo(),
690
+ machine.listSessions()
691
+ ]);
692
+ const host = info.metadata?.displayName || info.metadata?.host || info.machineId;
681
693
  for (const s of sessions) {
682
- s.machineHost = info.metadata?.displayName || info.metadata?.host || info.machineId;
694
+ s.machineHost = host;
683
695
  }
684
- allSessions.push(...sessions);
685
- } catch {
686
- }
696
+ return sessions;
697
+ })
698
+ );
699
+ for (const r of machineResults) {
700
+ if (r.status === "fulfilled") allSessions.push(...r.value);
687
701
  }
688
702
  const filtered = opts?.active ? allSessions.filter((s) => s.active) : allSessions;
689
703
  if (filtered.length === 0) {
@@ -694,29 +708,16 @@ async function listSessionsFromMachines(server, machines, opts) {
694
708
  }
695
709
  return;
696
710
  }
697
- const enriched = [];
698
- for (const s of filtered) {
699
- let flavor = "claude";
700
- let name = "";
701
- let path = s.directory || "";
702
- let host = s.machineHost || "";
703
- if (s.metadata) {
704
- flavor = s.metadata.flavor || "claude";
705
- name = s.metadata.name || "";
706
- }
707
- if (s.active) {
708
- try {
709
- const svc = await server.getService(`svamp-session-${s.sessionId}`);
710
- const { metadata } = await svc.getMetadata();
711
- flavor = metadata?.flavor || flavor;
712
- name = metadata?.name || name;
713
- path = metadata?.path || path;
714
- host = metadata?.host || host;
715
- } catch {
716
- }
717
- }
718
- enriched.push({ ...s, flavor, name, path, host });
719
- }
711
+ const enriched = filtered.map((s) => {
712
+ const m = s.metadata || {};
713
+ return {
714
+ ...s,
715
+ flavor: m.flavor || "claude",
716
+ name: m.name || "",
717
+ path: m.path || s.directory || "",
718
+ host: m.host || s.machineHost || ""
719
+ };
720
+ });
720
721
  if (opts?.json) {
721
722
  console.log(formatJson(enriched.map((s) => ({
722
723
  sessionId: s.sessionId,
@@ -874,12 +875,14 @@ async function sessionSpawn(agent, directory, machineId, opts) {
874
875
  let effectiveParentSessionId = opts?.parentSessionId || process.env.SVAMP_SESSION_ID || void 0;
875
876
  if (effectiveParentSessionId) {
876
877
  try {
878
+ const sessions = await machine.listSessions();
877
879
  if (opts?.parentSessionId) {
878
- const sessions = await machine.listSessions();
879
880
  const match = resolveSessionId(sessions, effectiveParentSessionId);
880
881
  effectiveParentSessionId = match.sessionId;
882
+ } else {
883
+ const found = sessions.find((s) => s.sessionId === effectiveParentSessionId);
884
+ if (!found) throw new Error("not found");
881
885
  }
882
- await server.getService(`svamp-session-${effectiveParentSessionId}`);
883
886
  } catch (err) {
884
887
  const source = opts?.parentSessionId ? "--parent" : "SVAMP_SESSION_ID";
885
888
  console.error(`Error: Parent session ${effectiveParentSessionId} not found (from ${source}).`);
@@ -921,7 +924,7 @@ async function sessionSpawn(agent, directory, machineId, opts) {
921
924
  console.log(`\x1B[33m Use -p bypassPermissions to run without approval prompts.\x1B[0m`);
922
925
  }
923
926
  if (opts?.message && result.sessionId) {
924
- const svc = await server.getService(`svamp-session-${result.sessionId}`);
927
+ const svc = getSessionProxy(machine, result.sessionId);
925
928
  const sendResult = await svc.sendMessage(
926
929
  JSON.stringify({
927
930
  role: "user",
@@ -972,7 +975,7 @@ async function sessionInfo(sessionId, machineId, opts) {
972
975
  let metadata = {};
973
976
  let activity = {};
974
977
  try {
975
- const svc = await server.getService(`svamp-session-${fullId}`);
978
+ const svc = getSessionProxy(machine, fullId);
976
979
  const metaResult = await svc.getMetadata();
977
980
  metadata = metaResult.metadata || {};
978
981
  activity = await svc.getActivityState();
@@ -1012,7 +1015,7 @@ async function sessionMessages(sessionId, machineId, opts) {
1012
1015
  const sessions = await machine.listSessions();
1013
1016
  const match = resolveSessionId(sessions, sessionId);
1014
1017
  const fullId = match.sessionId;
1015
- const svc = await server.getService(`svamp-session-${fullId}`);
1018
+ const svc = getSessionProxy(machine, fullId);
1016
1019
  const afterSeq = opts?.after ?? 0;
1017
1020
  const apiLimit = opts?.limit ?? 1e3;
1018
1021
  const { messages } = await svc.getMessages(afterSeq, apiLimit);
@@ -1052,7 +1055,7 @@ async function sessionApprove(sessionId, requestId, machineId, opts) {
1052
1055
  const sessions = await machine.listSessions();
1053
1056
  const match = resolveSessionId(sessions, sessionId);
1054
1057
  const fullId = match.sessionId;
1055
- const svc = await server.getService(`svamp-session-${fullId}`);
1058
+ const svc = getSessionProxy(machine, fullId);
1056
1059
  if (requestId) {
1057
1060
  const activity = await svc.getActivityState();
1058
1061
  const pending = activity.pendingPermissions || [];
@@ -1101,7 +1104,7 @@ async function sessionDeny(sessionId, requestId, machineId, opts) {
1101
1104
  const sessions = await machine.listSessions();
1102
1105
  const match = resolveSessionId(sessions, sessionId);
1103
1106
  const fullId = match.sessionId;
1104
- const svc = await server.getService(`svamp-session-${fullId}`);
1107
+ const svc = getSessionProxy(machine, fullId);
1105
1108
  if (requestId) {
1106
1109
  const activity = await svc.getActivityState();
1107
1110
  const pending = activity.pendingPermissions || [];
@@ -1151,7 +1154,7 @@ async function sessionAttach(sessionId, machineId) {
1151
1154
  const fullId = match.sessionId;
1152
1155
  let svc;
1153
1156
  try {
1154
- svc = await server.getService(`svamp-session-${fullId}`);
1157
+ svc = getSessionProxy(machine, fullId);
1155
1158
  } catch (err) {
1156
1159
  console.error(`Could not find session service: ${err.message}`);
1157
1160
  await server.disconnect();
@@ -1369,7 +1372,7 @@ async function sessionShare(sessionIdPartial, machineId, opts) {
1369
1372
  const sessions = await machine.listSessions();
1370
1373
  const match = resolveSessionId(sessions, sessionIdPartial);
1371
1374
  const fullId = match.sessionId;
1372
- const svc = await server.getService(`svamp-session-${fullId}`);
1375
+ const svc = getSessionProxy(machine, fullId);
1373
1376
  if (opts.list) {
1374
1377
  const metaResult = await svc.getMetadata();
1375
1378
  const sharing = metaResult.metadata?.sharing;
@@ -1638,7 +1641,7 @@ async function sessionRalphStart(sessionIdPartial, task, machineId, opts) {
1638
1641
  const sessions = await machine.listSessions();
1639
1642
  const match = resolveSessionId(sessions, sessionIdPartial);
1640
1643
  const fullId = match.sessionId;
1641
- const svc = await server.getService(`svamp-session-${fullId}`);
1644
+ const svc = getSessionProxy(machine, fullId);
1642
1645
  const { metadata } = await svc.getMetadata();
1643
1646
  if (metadata?.ralphLoop?.active) {
1644
1647
  console.error(`Ralph loop is already active (iteration ${metadata.ralphLoop.currentIteration}). Cancel it first with: svamp session ralph-cancel ${sessionIdPartial}`);
@@ -1672,7 +1675,7 @@ async function sessionRalphCancel(sessionIdPartial, machineId) {
1672
1675
  const sessions = await machine.listSessions();
1673
1676
  const match = resolveSessionId(sessions, sessionIdPartial);
1674
1677
  const fullId = match.sessionId;
1675
- const svc = await server.getService(`svamp-session-${fullId}`);
1678
+ const svc = getSessionProxy(machine, fullId);
1676
1679
  const { metadata } = await svc.getMetadata();
1677
1680
  if (!metadata?.ralphLoop?.active) {
1678
1681
  console.log("No active Ralph loop on this session.");
@@ -1691,7 +1694,7 @@ async function sessionRalphStatus(sessionIdPartial, machineId) {
1691
1694
  const sessions = await machine.listSessions();
1692
1695
  const match = resolveSessionId(sessions, sessionIdPartial);
1693
1696
  const fullId = match.sessionId;
1694
- const svc = await server.getService(`svamp-session-${fullId}`);
1697
+ const svc = getSessionProxy(machine, fullId);
1695
1698
  const { metadata } = await svc.getMetadata();
1696
1699
  const ralph = metadata?.ralphLoop;
1697
1700
  if (!ralph || !ralph.active) {
@@ -1,11 +1,11 @@
1
1
  import { writeFileSync, readFileSync } from 'fs';
2
2
  import { resolve } from 'path';
3
- import { connectAndGetMachine } from './commands-C06J5fW3.mjs';
3
+ import { connectAndGetMachine } from './commands-6PO-ky9k.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-Dm7UViwQ.mjs';
8
+ import './run-kLd-u7KD.mjs';
9
9
  import 'os';
10
10
  import 'fs/promises';
11
11
  import 'url';
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-Dm7UViwQ.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-kLd-u7KD.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.80";
2
+ var version = "0.1.81";
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";
@@ -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-Dm7UViwQ.mjs';
5
+ import { c as connectToHypha, a as registerSessionService } from './run-kLd-u7KD.mjs';
6
6
  import { createServer } from 'node:http';
7
7
  import { spawn } from 'node:child_process';
8
8
  import { createInterface } from 'node:readline';
@@ -836,6 +836,11 @@ async function registerMachineService(server, machineId, metadata, daemonState,
836
836
  const session = terminalSessions.get(params.sessionId);
837
837
  if (!session) throw new Error(`Terminal session ${params.sessionId} not found`);
838
838
  const scrollback = session.outputBuffer.join("");
839
+ if (params.cols && params.rows) {
840
+ session.pty.resize(params.cols, params.rows);
841
+ session.cols = params.cols;
842
+ session.rows = params.rows;
843
+ }
839
844
  return { sessionId: session.id, cols: session.cols, rows: session.rows, scrollback, exited: session.exited };
840
845
  },
841
846
  // Machine-level directory listing (read-only, view role)
@@ -1599,6 +1604,7 @@ function createSessionStore(server, sessionId, initialMetadata, initialAgentStat
1599
1604
  const store = {
1600
1605
  serviceInfo: { id: `svamp-session-${sessionId}` },
1601
1606
  pushMessage,
1607
+ getMetadata: () => ({ ...metadata }),
1602
1608
  get _agentState() {
1603
1609
  return agentState;
1604
1610
  },
@@ -5572,8 +5578,7 @@ async function startDaemon(options) {
5572
5578
  process.on("SIGUSR1", () => requestShutdown("os-signal-cleanup"));
5573
5579
  process.on("uncaughtException", (error) => {
5574
5580
  if (shutdownRequested) return;
5575
- logger.error("Uncaught exception:", error);
5576
- requestShutdown("exception", error.message);
5581
+ logger.error("Uncaught exception (non-fatal, daemon continues):", error);
5577
5582
  });
5578
5583
  const TRANSIENT_REJECTION_PATTERNS = [
5579
5584
  "_rintf",
@@ -5604,8 +5609,12 @@ async function startDaemon(options) {
5604
5609
  // Fetch API errors during reconnect
5605
5610
  "already exists in the cache store",
5606
5611
  // hypha-rpc: stale in-flight RPC calls after reconnect try to resolve with duplicate message keys
5607
- "Failed to send the request when calling method"
5612
+ "Failed to send the request when calling method",
5608
5613
  // hypha-rpc: RPC call failed after reconnect (often wraps the cache store error)
5614
+ "Rate limit",
5615
+ // Hypha server 429 rate limiting — transient, will resolve on its own
5616
+ "status 429"
5617
+ // HTTP 429 status code
5609
5618
  ];
5610
5619
  let unhandledRejectionCount = 0;
5611
5620
  let unhandledRejectionResetTimer = null;
@@ -5628,10 +5637,9 @@ async function startDaemon(options) {
5628
5637
  }, UNHANDLED_REJECTION_WINDOW_MS);
5629
5638
  }
5630
5639
  if (unhandledRejectionCount >= UNHANDLED_REJECTION_THRESHOLD) {
5631
- logger.log(`Too many unhandled rejections (${unhandledRejectionCount} in ${UNHANDLED_REJECTION_WINDOW_MS / 1e3}s), shutting down`);
5632
- requestShutdown("exception", msg);
5640
+ logger.log(`Too many unhandled rejections (${unhandledRejectionCount} in ${UNHANDLED_REJECTION_WINDOW_MS / 1e3}s) \u2014 logging only, daemon continues`);
5633
5641
  } else {
5634
- logger.log(`Unhandled rejection ${unhandledRejectionCount}/${UNHANDLED_REJECTION_THRESHOLD} (not crashing yet): ${msg.slice(0, 200)}`);
5642
+ logger.log(`Unhandled rejection ${unhandledRejectionCount}/${UNHANDLED_REJECTION_THRESHOLD}: ${msg.slice(0, 200)}`);
5635
5643
  }
5636
5644
  });
5637
5645
  if (isDaemonAlive()) {
@@ -5713,8 +5721,7 @@ async function startDaemon(options) {
5713
5721
  });
5714
5722
  logger.log(`Connected to Hypha (workspace: ${server.config.workspace})`);
5715
5723
  server.on("disconnected", (reason) => {
5716
- logger.log(`Hypha connection permanently lost: ${reason}`);
5717
- requestShutdown("hypha-disconnected", String(reason));
5724
+ logger.log(`Hypha connection permanently lost: ${reason}. Daemon continues running \u2014 restart manually to reconnect.`);
5718
5725
  });
5719
5726
  const pidToTrackedSession = /* @__PURE__ */ new Map();
5720
5727
  server.on("services_registered", () => {
@@ -5725,13 +5732,33 @@ async function startDaemon(options) {
5725
5732
  }
5726
5733
  });
5727
5734
  const getCurrentChildren = () => {
5728
- return Array.from(pidToTrackedSession.values()).map((s) => ({
5729
- sessionId: s.svampSessionId || `PID-${s.pid}`,
5730
- pid: s.pid,
5731
- startedBy: s.startedBy,
5732
- directory: s.directory,
5733
- active: !s.stopped && s.hyphaService != null
5734
- }));
5735
+ return Array.from(pidToTrackedSession.values()).map((s) => {
5736
+ const active = !s.stopped && s.hyphaService != null;
5737
+ let metadata;
5738
+ if (active && s.hyphaService) {
5739
+ try {
5740
+ const m = s.hyphaService.getMetadata();
5741
+ metadata = {
5742
+ flavor: m.flavor,
5743
+ name: m.name,
5744
+ path: m.path,
5745
+ host: m.host,
5746
+ lifecycleState: m.lifecycleState,
5747
+ parentSessionId: m.parentSessionId,
5748
+ tags: m.tags
5749
+ };
5750
+ } catch {
5751
+ }
5752
+ }
5753
+ return {
5754
+ sessionId: s.svampSessionId || `PID-${s.pid}`,
5755
+ pid: s.pid,
5756
+ startedBy: s.startedBy,
5757
+ directory: s.directory,
5758
+ active,
5759
+ metadata
5760
+ };
5761
+ });
5735
5762
  };
5736
5763
  let machineServiceRef = null;
5737
5764
  const spawnSession = async (options2) => {
@@ -7679,7 +7706,9 @@ The automated loop has finished. Review the progress above and let me know if yo
7679
7706
  spawnSession,
7680
7707
  stopSession,
7681
7708
  restartSession,
7682
- requestShutdown: () => requestShutdown("hypha-app"),
7709
+ requestShutdown: () => {
7710
+ logger.log("Shutdown requested via hypha-app (ignored \u2014 daemon never self-terminates)");
7711
+ },
7683
7712
  getTrackedSessions: getCurrentChildren,
7684
7713
  getSessionRPCHandlers: (sessionId) => {
7685
7714
  for (const [, session] of pidToTrackedSession) {
@@ -7785,20 +7814,16 @@ The automated loop has finished. Review the progress above and let me know if yo
7785
7814
  for (const sessionId of sessionsToAutoContinue) {
7786
7815
  setTimeout(async () => {
7787
7816
  try {
7788
- const svc = await Promise.race([
7789
- server.getService(`svamp-session-${sessionId}`),
7790
- new Promise((_, reject) => setTimeout(() => reject(new Error("getService timeout")), 1e4))
7791
- ]);
7792
- await Promise.race([
7793
- svc.sendMessage(
7794
- JSON.stringify({
7795
- role: "user",
7796
- content: { type: "text", text: 'The svamp daemon was restarted, which interrupted this session. Please continue where you left off. IMPORTANT: Do not run any command that would stop or restart the svamp daemon (e.g. "svamp daemon stop") \u2014 that would interrupt the session again.' },
7797
- meta: { sentFrom: "svamp-daemon-auto-continue" }
7798
- })
7799
- ),
7800
- new Promise((_, reject) => setTimeout(() => reject(new Error("sendMessage timeout")), 3e4))
7801
- ]);
7817
+ const tracked = Array.from(pidToTrackedSession.values()).find((s) => s.svampSessionId === sessionId);
7818
+ const rpc = tracked?.sessionRPCHandlers;
7819
+ if (!rpc) throw new Error(`Session ${sessionId} RPC handlers not found`);
7820
+ await rpc.sendMessage(
7821
+ JSON.stringify({
7822
+ role: "user",
7823
+ content: { type: "text", text: 'The svamp daemon was restarted, which interrupted this session. Please continue where you left off. IMPORTANT: Do not run any command that would stop or restart the svamp daemon (e.g. "svamp daemon stop") \u2014 that would interrupt the session again.' },
7824
+ meta: { sentFrom: "svamp-daemon-auto-continue" }
7825
+ })
7826
+ );
7802
7827
  logger.log(`Auto-continued session ${sessionId}`);
7803
7828
  } catch (err) {
7804
7829
  logger.log(`Failed to auto-continue session ${sessionId}: ${err.message}`);
@@ -7812,10 +7837,12 @@ The automated loop has finished. Review the progress above and let me know if yo
7812
7837
  logger.log(`Resuming Ralph loop for ${sessionsToRalphResume.length} session(s)...`);
7813
7838
  for (const { sessionId, directory: sessDir } of sessionsToRalphResume) {
7814
7839
  try {
7815
- const svc = await Promise.race([
7816
- server.getService(`svamp-session-${sessionId}`),
7817
- new Promise((_, reject) => setTimeout(() => reject(new Error("getService timeout")), 1e4))
7818
- ]);
7840
+ const tracked = Array.from(pidToTrackedSession.values()).find((s) => s.svampSessionId === sessionId);
7841
+ const rpc = tracked?.sessionRPCHandlers;
7842
+ if (!rpc) {
7843
+ logger.log(`Session ${sessionId} RPC handlers not found for Ralph resume`);
7844
+ continue;
7845
+ }
7819
7846
  const rlState = readRalphState(getRalphStateFilePath(sessDir, sessionId));
7820
7847
  if (!rlState) continue;
7821
7848
  const initDelayMs = 2e3;
@@ -7836,20 +7863,17 @@ The automated loop has finished. Review the progress above and let me know if yo
7836
7863
  const progressRelPath = `.svamp/${sessionId}/ralph-progress.md`;
7837
7864
  const prompt = buildRalphPrompt(currentState.task, currentState);
7838
7865
  const ralphSysPrompt = buildRalphSystemPrompt(currentState, progressRelPath);
7839
- await Promise.race([
7840
- svc.sendMessage(
7841
- JSON.stringify({
7842
- role: "user",
7843
- content: { type: "text", text: prompt },
7844
- meta: {
7845
- sentFrom: "svamp-daemon-ralph-resume",
7846
- appendSystemPrompt: ralphSysPrompt,
7847
- ...isFreshMode ? { ralphFreshContext: true } : {}
7848
- }
7849
- })
7850
- ),
7851
- new Promise((_, reject) => setTimeout(() => reject(new Error("sendMessage timeout")), 3e4))
7852
- ]);
7866
+ await rpc.sendMessage(
7867
+ JSON.stringify({
7868
+ role: "user",
7869
+ content: { type: "text", text: prompt },
7870
+ meta: {
7871
+ sentFrom: "svamp-daemon-ralph-resume",
7872
+ appendSystemPrompt: ralphSysPrompt,
7873
+ ...isFreshMode ? { ralphFreshContext: true } : {}
7874
+ }
7875
+ })
7876
+ );
7853
7877
  logger.log(`Resumed Ralph loop for session ${sessionId} at iteration ${currentState.iteration} (${isFreshMode ? "fresh" : "continue"})`);
7854
7878
  } catch (err) {
7855
7879
  logger.log(`Failed to resume Ralph loop for session ${sessionId}: ${err.message}`);
@@ -7913,20 +7937,6 @@ The automated loop has finished. Review the progress above and let me know if yo
7913
7937
  }
7914
7938
  } catch {
7915
7939
  }
7916
- try {
7917
- const installedVersion = readPackageVersion();
7918
- if (installedVersion !== "unknown" && installedVersion !== DAEMON_VERSION) {
7919
- const supervised2 = process.env.SVAMP_SUPERVISED === "1";
7920
- if (supervised2) {
7921
- logger.log(`svamp-cli version changed on disk: ${DAEMON_VERSION} \u2192 ${installedVersion}. Exiting for launchd restart...`);
7922
- requestShutdown("version-update", `Updated ${DAEMON_VERSION} \u2192 ${installedVersion}`);
7923
- return;
7924
- } else {
7925
- logger.log(`svamp-cli version changed on disk: ${DAEMON_VERSION} \u2192 ${installedVersion}. Run 'svamp daemon stop && svamp daemon start' to apply the update.`);
7926
- }
7927
- }
7928
- } catch {
7929
- }
7930
7940
  for (const [key, session] of pidToTrackedSession) {
7931
7941
  const child = session.childProcess;
7932
7942
  if (child && child.pid) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svamp-cli",
3
- "version": "0.1.80",
3
+ "version": "0.1.81",
4
4
  "description": "Svamp CLI — AI workspace daemon on Hypha Cloud",
5
5
  "author": "Amun AI AB",
6
6
  "license": "SEE LICENSE IN LICENSE",