svamp-cli 0.2.4 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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-DxBS60bF.mjs');
151
+ const { connectAndGetMachine } = await import('./commands-Bb11XUfY.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-DxBS60bF.mjs');
168
+ const { resolveSessionId } = await import('./commands-Bb11XUfY.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 { b as stopDaemon, s as startDaemon, d as daemonStatus } from './run-DA-51t9q.mjs';
1
+ import { b as stopDaemon, s as startDaemon, d as daemonStatus } from './run-XoQsDcg4.mjs';
2
2
  import 'os';
3
3
  import 'fs/promises';
4
4
  import 'fs';
@@ -231,7 +231,7 @@ async function main() {
231
231
  console.error("svamp process: Process commands are not available in sandboxed sessions.");
232
232
  process.exit(1);
233
233
  }
234
- const { processCommand } = await import('./commands-C-numdSB.mjs');
234
+ const { processCommand } = await import('./commands-Bhf3G7y0.mjs');
235
235
  let machineId;
236
236
  const processArgs = args.slice(1);
237
237
  const mIdx = processArgs.findIndex((a) => a === "--machine" || a === "-m");
@@ -249,7 +249,7 @@ async function main() {
249
249
  } else if (!subcommand || subcommand === "start") {
250
250
  await handleInteractiveCommand();
251
251
  } else if (subcommand === "--version" || subcommand === "-v") {
252
- const pkg = await import('./package-j4rcEm88.mjs').catch(() => ({ default: { version: "unknown" } }));
252
+ const pkg = await import('./package-BdGJqGmA.mjs').catch(() => ({ default: { version: "unknown" } }));
253
253
  console.log(`svamp version: ${pkg.default.version}`);
254
254
  } else {
255
255
  console.error(`Unknown command: ${subcommand}`);
@@ -258,7 +258,7 @@ async function main() {
258
258
  }
259
259
  }
260
260
  async function handleInteractiveCommand() {
261
- const { runInteractive } = await import('./run-8oWEecqT.mjs');
261
+ const { runInteractive } = await import('./run-RsupAuzC.mjs');
262
262
  const interactiveArgs = subcommand === "start" ? args.slice(1) : args;
263
263
  let directory = process.cwd();
264
264
  let resumeSessionId;
@@ -303,7 +303,7 @@ async function handleAgentCommand() {
303
303
  return;
304
304
  }
305
305
  if (agentArgs[0] === "list") {
306
- const { KNOWN_ACP_AGENTS, KNOWN_MCP_AGENTS: KNOWN_MCP_AGENTS2 } = await import('./run-DA-51t9q.mjs').then(function (n) { return n.i; });
306
+ const { KNOWN_ACP_AGENTS, KNOWN_MCP_AGENTS: KNOWN_MCP_AGENTS2 } = await import('./run-XoQsDcg4.mjs').then(function (n) { return n.i; });
307
307
  console.log("Known agents:");
308
308
  for (const [name, config2] of Object.entries(KNOWN_ACP_AGENTS)) {
309
309
  console.log(` ${name.padEnd(12)} ${config2.command} ${config2.args.join(" ")} (ACP)`);
@@ -315,7 +315,7 @@ async function handleAgentCommand() {
315
315
  console.log('Use "svamp agent -- <command> [args]" for a custom ACP agent.');
316
316
  return;
317
317
  }
318
- const { resolveAcpAgentConfig, KNOWN_MCP_AGENTS } = await import('./run-DA-51t9q.mjs').then(function (n) { return n.i; });
318
+ const { resolveAcpAgentConfig, KNOWN_MCP_AGENTS } = await import('./run-XoQsDcg4.mjs').then(function (n) { return n.i; });
319
319
  let cwd = process.cwd();
320
320
  const filteredArgs = [];
321
321
  for (let i = 0; i < agentArgs.length; i++) {
@@ -339,12 +339,12 @@ async function handleAgentCommand() {
339
339
  console.log(`Starting ${config.agentName} agent in ${cwd}...`);
340
340
  let backend;
341
341
  if (KNOWN_MCP_AGENTS[config.agentName]) {
342
- const { CodexMcpBackend } = await import('./run-DA-51t9q.mjs').then(function (n) { return n.j; });
342
+ const { CodexMcpBackend } = await import('./run-XoQsDcg4.mjs').then(function (n) { return n.j; });
343
343
  backend = new CodexMcpBackend({ cwd, log: logFn });
344
344
  } else {
345
- const { AcpBackend } = await import('./run-DA-51t9q.mjs').then(function (n) { return n.h; });
346
- const { GeminiTransport } = await import('./run-DA-51t9q.mjs').then(function (n) { return n.G; });
347
- const { DefaultTransport } = await import('./run-DA-51t9q.mjs').then(function (n) { return n.D; });
345
+ const { AcpBackend } = await import('./run-XoQsDcg4.mjs').then(function (n) { return n.h; });
346
+ const { GeminiTransport } = await import('./run-XoQsDcg4.mjs').then(function (n) { return n.G; });
347
+ const { DefaultTransport } = await import('./run-XoQsDcg4.mjs').then(function (n) { return n.D; });
348
348
  const transportHandler = config.agentName === "gemini" ? new GeminiTransport() : new DefaultTransport(config.agentName);
349
349
  backend = new AcpBackend({
350
350
  agentName: config.agentName,
@@ -471,7 +471,7 @@ async function handleSessionCommand() {
471
471
  process.exit(1);
472
472
  }
473
473
  }
474
- const { sessionList, sessionSpawn, sessionStop, sessionInfo, sessionMessages, sessionAttach, sessionMachines, sessionSend, sessionWait, sessionShare, sessionRalphStart, sessionRalphCancel, sessionRalphStatus, sessionInboxSend, sessionInboxList, sessionInboxRead, sessionInboxReply, sessionInboxClear } = await import('./commands-DxBS60bF.mjs');
474
+ const { sessionList, sessionSpawn, sessionStop, sessionInfo, sessionMessages, sessionAttach, sessionMachines, sessionSend, sessionWait, sessionShare, sessionRalphStart, sessionRalphCancel, sessionRalphStatus, sessionInboxSend, sessionInboxList, sessionInboxRead, sessionInboxReply, sessionInboxClear } = await import('./commands-Bb11XUfY.mjs');
475
475
  const parseFlagStr = (flag, shortFlag) => {
476
476
  for (let i = 1; i < sessionArgs.length; i++) {
477
477
  if ((sessionArgs[i] === flag || shortFlag) && i + 1 < sessionArgs.length) {
@@ -531,7 +531,7 @@ async function handleSessionCommand() {
531
531
  allowDomain.push(sessionArgs[++i]);
532
532
  }
533
533
  }
534
- const { parseShareArg } = await import('./commands-DxBS60bF.mjs');
534
+ const { parseShareArg } = await import('./commands-Bb11XUfY.mjs');
535
535
  const shareEntries = share.map((s) => parseShareArg(s));
536
536
  await sessionSpawn(agent, dir, targetMachineId, {
537
537
  message,
@@ -617,7 +617,7 @@ async function handleSessionCommand() {
617
617
  console.error("Usage: svamp session approve <session-id> [request-id] [--json]");
618
618
  process.exit(1);
619
619
  }
620
- const { sessionApprove } = await import('./commands-DxBS60bF.mjs');
620
+ const { sessionApprove } = await import('./commands-Bb11XUfY.mjs');
621
621
  const approveReqId = sessionArgs[2] && !sessionArgs[2].startsWith("--") ? sessionArgs[2] : void 0;
622
622
  await sessionApprove(sessionArgs[1], approveReqId, targetMachineId, {
623
623
  json: hasFlag("--json")
@@ -627,7 +627,7 @@ async function handleSessionCommand() {
627
627
  console.error("Usage: svamp session deny <session-id> [request-id] [--json]");
628
628
  process.exit(1);
629
629
  }
630
- const { sessionDeny } = await import('./commands-DxBS60bF.mjs');
630
+ const { sessionDeny } = await import('./commands-Bb11XUfY.mjs');
631
631
  const denyReqId = sessionArgs[2] && !sessionArgs[2].startsWith("--") ? sessionArgs[2] : void 0;
632
632
  await sessionDeny(sessionArgs[1], denyReqId, targetMachineId, {
633
633
  json: hasFlag("--json")
@@ -663,7 +663,7 @@ async function handleSessionCommand() {
663
663
  console.error("Usage: svamp session set-title <title>");
664
664
  process.exit(1);
665
665
  }
666
- const { sessionSetTitle } = await import('./agentCommands-D4sWJpjZ.mjs');
666
+ const { sessionSetTitle } = await import('./agentCommands-C69uiQZ0.mjs');
667
667
  await sessionSetTitle(title);
668
668
  } else if (sessionSubcommand === "set-link") {
669
669
  const url = sessionArgs[1];
@@ -672,7 +672,7 @@ async function handleSessionCommand() {
672
672
  process.exit(1);
673
673
  }
674
674
  const label = sessionArgs[2] && !sessionArgs[2].startsWith("--") ? sessionArgs[2] : void 0;
675
- const { sessionSetLink } = await import('./agentCommands-D4sWJpjZ.mjs');
675
+ const { sessionSetLink } = await import('./agentCommands-C69uiQZ0.mjs');
676
676
  await sessionSetLink(url, label);
677
677
  } else if (sessionSubcommand === "notify") {
678
678
  const message = sessionArgs[1];
@@ -681,7 +681,7 @@ async function handleSessionCommand() {
681
681
  process.exit(1);
682
682
  }
683
683
  const level = parseFlagStr("--level") || "info";
684
- const { sessionNotify } = await import('./agentCommands-D4sWJpjZ.mjs');
684
+ const { sessionNotify } = await import('./agentCommands-C69uiQZ0.mjs');
685
685
  await sessionNotify(message, level);
686
686
  } else if (sessionSubcommand === "broadcast") {
687
687
  const action = sessionArgs[1];
@@ -689,7 +689,7 @@ async function handleSessionCommand() {
689
689
  console.error("Usage: svamp session broadcast <action> [args...]\nActions: open-canvas <url> [label], close-canvas, toast <message>");
690
690
  process.exit(1);
691
691
  }
692
- const { sessionBroadcast } = await import('./agentCommands-D4sWJpjZ.mjs');
692
+ const { sessionBroadcast } = await import('./agentCommands-C69uiQZ0.mjs');
693
693
  await sessionBroadcast(action, sessionArgs.slice(2).filter((a) => !a.startsWith("--")));
694
694
  } else if (sessionSubcommand === "inbox") {
695
695
  const inboxSubcmd = sessionArgs[1];
@@ -700,7 +700,7 @@ async function handleSessionCommand() {
700
700
  process.exit(1);
701
701
  }
702
702
  if (agentSessionId) {
703
- const { inboxSend } = await import('./agentCommands-D4sWJpjZ.mjs');
703
+ const { inboxSend } = await import('./agentCommands-C69uiQZ0.mjs');
704
704
  await inboxSend(sessionArgs[2], {
705
705
  body: sessionArgs[3],
706
706
  subject: parseFlagStr("--subject"),
@@ -715,7 +715,7 @@ async function handleSessionCommand() {
715
715
  }
716
716
  } else if (inboxSubcmd === "list" || inboxSubcmd === "ls") {
717
717
  if (agentSessionId && !sessionArgs[2]) {
718
- const { inboxList } = await import('./agentCommands-D4sWJpjZ.mjs');
718
+ const { inboxList } = await import('./agentCommands-C69uiQZ0.mjs');
719
719
  await inboxList({
720
720
  unread: hasFlag("--unread"),
721
721
  limit: parseFlagInt("--limit"),
@@ -737,7 +737,7 @@ async function handleSessionCommand() {
737
737
  process.exit(1);
738
738
  }
739
739
  if (agentSessionId && !sessionArgs[3]) {
740
- const { inboxList } = await import('./agentCommands-D4sWJpjZ.mjs');
740
+ const { inboxList } = await import('./agentCommands-C69uiQZ0.mjs');
741
741
  await sessionInboxRead(agentSessionId, sessionArgs[2], targetMachineId);
742
742
  } else if (sessionArgs[3]) {
743
743
  await sessionInboxRead(sessionArgs[2], sessionArgs[3], targetMachineId);
@@ -747,7 +747,7 @@ async function handleSessionCommand() {
747
747
  }
748
748
  } else if (inboxSubcmd === "reply") {
749
749
  if (agentSessionId && sessionArgs[2] && sessionArgs[3] && !sessionArgs[4]) {
750
- const { inboxReply } = await import('./agentCommands-D4sWJpjZ.mjs');
750
+ const { inboxReply } = await import('./agentCommands-C69uiQZ0.mjs');
751
751
  await inboxReply(sessionArgs[2], sessionArgs[3]);
752
752
  } else if (sessionArgs[2] && sessionArgs[3] && sessionArgs[4]) {
753
753
  await sessionInboxReply(sessionArgs[2], sessionArgs[3], sessionArgs[4], targetMachineId);
@@ -783,7 +783,7 @@ async function handleMachineCommand() {
783
783
  return;
784
784
  }
785
785
  if (machineSubcommand === "share") {
786
- const { machineShare } = await import('./commands-DxBS60bF.mjs');
786
+ const { machineShare } = await import('./commands-Bb11XUfY.mjs');
787
787
  let machineId;
788
788
  const shareArgs = [];
789
789
  for (let i = 1; i < machineArgs.length; i++) {
@@ -813,7 +813,7 @@ async function handleMachineCommand() {
813
813
  }
814
814
  await machineShare(machineId, { add, remove, list, configPath, showConfig });
815
815
  } else if (machineSubcommand === "exec") {
816
- const { machineExec } = await import('./commands-DxBS60bF.mjs');
816
+ const { machineExec } = await import('./commands-Bb11XUfY.mjs');
817
817
  let machineId;
818
818
  let cwd;
819
819
  const cmdParts = [];
@@ -833,7 +833,7 @@ async function handleMachineCommand() {
833
833
  }
834
834
  await machineExec(machineId, command, cwd);
835
835
  } else if (machineSubcommand === "info") {
836
- const { machineInfo } = await import('./commands-DxBS60bF.mjs');
836
+ const { machineInfo } = await import('./commands-Bb11XUfY.mjs');
837
837
  let machineId;
838
838
  for (let i = 1; i < machineArgs.length; i++) {
839
839
  if ((machineArgs[i] === "--machine" || machineArgs[i] === "-m") && i + 1 < machineArgs.length) {
@@ -853,10 +853,10 @@ async function handleMachineCommand() {
853
853
  level = machineArgs[++i];
854
854
  }
855
855
  }
856
- const { machineNotify } = await import('./agentCommands-D4sWJpjZ.mjs');
856
+ const { machineNotify } = await import('./agentCommands-C69uiQZ0.mjs');
857
857
  await machineNotify(message, level);
858
858
  } else if (machineSubcommand === "ls") {
859
- const { machineLs } = await import('./commands-DxBS60bF.mjs');
859
+ const { machineLs } = await import('./commands-Bb11XUfY.mjs');
860
860
  let machineId;
861
861
  let showHidden = false;
862
862
  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-DA-51t9q.mjs';
5
+ import { l as loadSecurityContextConfig, e as resolveSecurityContext, f as buildSecurityContextFromFlags, m as mergeSecurityContexts, c as connectToHypha } from './run-XoQsDcg4.mjs';
6
6
  import 'os';
7
7
  import 'fs/promises';
8
8
  import 'fs';
@@ -526,6 +526,34 @@ function resolveSessionId(sessions, partial) {
526
526
  }
527
527
  process.exit(1);
528
528
  }
529
+ async function connectAndResolveSession(sessionId, machineId) {
530
+ let { server, machine } = await connectAndGetMachine(machineId);
531
+ const sessions = await machine.listSessions();
532
+ const localMatch = findSessionMatch(sessions, sessionId);
533
+ if (localMatch) {
534
+ return { server, machine, fullId: localMatch.sessionId };
535
+ }
536
+ if (!machineId) {
537
+ try {
538
+ const { server: allServer, machines } = await connectAndGetAllMachines();
539
+ for (const m of machines) {
540
+ try {
541
+ const mSessions = await m.listSessions();
542
+ const mMatch = findSessionMatch(mSessions, sessionId);
543
+ if (mMatch) {
544
+ await server.disconnect();
545
+ return { server: allServer, machine: m, fullId: mMatch.sessionId };
546
+ }
547
+ } catch {
548
+ }
549
+ }
550
+ await allServer.disconnect();
551
+ } catch {
552
+ }
553
+ }
554
+ resolveSessionId(sessions, sessionId);
555
+ process.exit(1);
556
+ }
529
557
  function truncate(str, max) {
530
558
  if (str.length <= max) return str;
531
559
  return "..." + str.slice(str.length - max + 3);
@@ -1003,13 +1031,11 @@ async function sessionSpawn(agent, directory, machineId, opts) {
1003
1031
  }
1004
1032
  }
1005
1033
  async function sessionStop(sessionId, machineId) {
1006
- const { server, machine } = await connectAndGetMachine(machineId);
1034
+ const { server, machine, fullId } = await connectAndResolveSession(sessionId, machineId);
1007
1035
  try {
1008
- const sessions = await machine.listSessions();
1009
- const match = resolveSessionId(sessions, sessionId);
1010
- const success = await machine.stopSession(match.sessionId);
1036
+ const success = await machine.stopSession(fullId);
1011
1037
  if (success) {
1012
- console.log(`Session ${match.sessionId.slice(0, 8)} stopped.`);
1038
+ console.log(`Session ${fullId.slice(0, 8)} stopped.`);
1013
1039
  } else {
1014
1040
  console.error("Failed to stop session (not found on daemon).");
1015
1041
  process.exit(1);
@@ -1019,11 +1045,8 @@ async function sessionStop(sessionId, machineId) {
1019
1045
  }
1020
1046
  }
1021
1047
  async function sessionInfo(sessionId, machineId, opts) {
1022
- const { server, machine } = await connectAndGetMachine(machineId);
1048
+ const { server, machine, fullId } = await connectAndResolveSession(sessionId, machineId);
1023
1049
  try {
1024
- const sessions = await machine.listSessions();
1025
- const match = resolveSessionId(sessions, sessionId);
1026
- const fullId = match.sessionId;
1027
1050
  let metadata = {};
1028
1051
  let activity = {};
1029
1052
  try {
@@ -1038,12 +1061,12 @@ async function sessionInfo(sessionId, machineId, opts) {
1038
1061
  sessionId: fullId,
1039
1062
  flavor: metadata.flavor || "claude",
1040
1063
  name: metadata.name || "",
1041
- path: metadata.path || match.directory || "",
1064
+ path: metadata.path || "",
1042
1065
  host: metadata.host || "",
1043
1066
  lifecycleState: metadata.lifecycleState || "unknown",
1044
1067
  active: activity.active ?? false,
1045
1068
  thinking: activity.thinking ?? false,
1046
- startedBy: metadata.startedBy || match.startedBy || "",
1069
+ startedBy: metadata.startedBy || "",
1047
1070
  summary: metadata.summary?.text || void 0,
1048
1071
  claudeSessionId: metadata.claudeSessionId || void 0,
1049
1072
  sessionLink: metadata.sessionLink?.url || void 0,
@@ -1062,11 +1085,8 @@ async function sessionInfo(sessionId, machineId, opts) {
1062
1085
  }
1063
1086
  }
1064
1087
  async function sessionMessages(sessionId, machineId, opts) {
1065
- const { server, machine } = await connectAndGetMachine(machineId);
1088
+ const { server, machine, fullId } = await connectAndResolveSession(sessionId, machineId);
1066
1089
  try {
1067
- const sessions = await machine.listSessions();
1068
- const match = resolveSessionId(sessions, sessionId);
1069
- const fullId = match.sessionId;
1070
1090
  const svc = getSessionProxy(machine, fullId);
1071
1091
  const afterSeq = opts?.after ?? 0;
1072
1092
  const apiLimit = opts?.limit ?? 1e3;
@@ -1102,11 +1122,8 @@ async function sessionMessages(sessionId, machineId, opts) {
1102
1122
  }
1103
1123
  }
1104
1124
  async function sessionApprove(sessionId, requestId, machineId, opts) {
1105
- const { server, machine } = await connectAndGetMachine(machineId);
1125
+ const { server, machine, fullId } = await connectAndResolveSession(sessionId, machineId);
1106
1126
  try {
1107
- const sessions = await machine.listSessions();
1108
- const match = resolveSessionId(sessions, sessionId);
1109
- const fullId = match.sessionId;
1110
1127
  const svc = getSessionProxy(machine, fullId);
1111
1128
  if (requestId) {
1112
1129
  const activity = await svc.getActivityState();
@@ -1151,11 +1168,8 @@ async function sessionApprove(sessionId, requestId, machineId, opts) {
1151
1168
  }
1152
1169
  }
1153
1170
  async function sessionDeny(sessionId, requestId, machineId, opts) {
1154
- const { server, machine } = await connectAndGetMachine(machineId);
1171
+ const { server, machine, fullId } = await connectAndResolveSession(sessionId, machineId);
1155
1172
  try {
1156
- const sessions = await machine.listSessions();
1157
- const match = resolveSessionId(sessions, sessionId);
1158
- const fullId = match.sessionId;
1159
1173
  const svc = getSessionProxy(machine, fullId);
1160
1174
  if (requestId) {
1161
1175
  const activity = await svc.getActivityState();
@@ -1200,10 +1214,7 @@ async function sessionDeny(sessionId, requestId, machineId, opts) {
1200
1214
  }
1201
1215
  }
1202
1216
  async function sessionAttach(sessionId, machineId) {
1203
- const { server, machine } = await connectAndGetMachine(machineId);
1204
- const sessions = await machine.listSessions();
1205
- const match = resolveSessionId(sessions, sessionId);
1206
- const fullId = match.sessionId;
1217
+ const { server, machine, fullId } = await connectAndResolveSession(sessionId, machineId);
1207
1218
  let svc;
1208
1219
  try {
1209
1220
  svc = getSessionProxy(machine, fullId);
@@ -1316,46 +1327,7 @@ async function sessionAttach(sessionId, machineId) {
1316
1327
  });
1317
1328
  }
1318
1329
  async function sessionSend(sessionId, message, machineId, opts) {
1319
- let server;
1320
- let machine;
1321
- let fullId = "";
1322
- const localConn = await connectAndGetMachine(machineId);
1323
- server = localConn.server;
1324
- machine = localConn.machine;
1325
- const sessions = await machine.listSessions();
1326
- const localMatch = findSessionMatch(sessions, sessionId);
1327
- if (localMatch) {
1328
- fullId = localMatch.sessionId;
1329
- } else if (!machineId) {
1330
- let found = false;
1331
- try {
1332
- const { server: allServer, machines } = await connectAndGetAllMachines();
1333
- for (const m of machines) {
1334
- try {
1335
- const mSessions = await m.listSessions();
1336
- const mMatch = findSessionMatch(mSessions, sessionId);
1337
- if (mMatch) {
1338
- await server.disconnect();
1339
- server = allServer;
1340
- machine = m;
1341
- fullId = mMatch.sessionId;
1342
- found = true;
1343
- break;
1344
- }
1345
- } catch {
1346
- }
1347
- }
1348
- if (!found) await allServer.disconnect();
1349
- } catch {
1350
- }
1351
- if (!found) {
1352
- resolveSessionId(sessions, sessionId);
1353
- return;
1354
- }
1355
- } else {
1356
- resolveSessionId(sessions, sessionId);
1357
- return;
1358
- }
1330
+ const { server, machine, fullId } = await connectAndResolveSession(sessionId, machineId);
1359
1331
  try {
1360
1332
  const { randomUUID } = await import('node:crypto');
1361
1333
  const inboxMessage = {
@@ -1415,11 +1387,8 @@ Use: svamp session approve ${fullId.slice(0, 8)}`);
1415
1387
  }
1416
1388
  }
1417
1389
  async function sessionWait(sessionId, machineId, opts) {
1418
- const { server, machine } = await connectAndGetMachine(machineId);
1390
+ const { server, machine, fullId } = await connectAndResolveSession(sessionId, machineId);
1419
1391
  try {
1420
- const sessions = await machine.listSessions();
1421
- const match = resolveSessionId(sessions, sessionId);
1422
- const fullId = match.sessionId;
1423
1392
  const timeoutMs = (opts?.timeout || 300) * 1e3;
1424
1393
  const result = await waitForIdle(machine, fullId, timeoutMs);
1425
1394
  if (result.pendingPermissions?.length) {
@@ -1455,11 +1424,8 @@ Use: svamp session approve ${fullId.slice(0, 8)}`);
1455
1424
  }
1456
1425
  }
1457
1426
  async function sessionShare(sessionIdPartial, machineId, opts) {
1458
- const { server, machine } = await connectAndGetMachine(machineId);
1427
+ const { server, machine, fullId } = await connectAndResolveSession(sessionIdPartial, machineId);
1459
1428
  try {
1460
- const sessions = await machine.listSessions();
1461
- const match = resolveSessionId(sessions, sessionIdPartial);
1462
- const fullId = match.sessionId;
1463
1429
  const svc = getSessionProxy(machine, fullId);
1464
1430
  if (opts.list) {
1465
1431
  const metaResult = await svc.getMetadata();
@@ -1724,11 +1690,8 @@ async function machineLs(machineId, path, showHidden) {
1724
1690
  }
1725
1691
  }
1726
1692
  async function sessionRalphStart(sessionIdPartial, task, machineId, opts) {
1727
- const { server, machine } = await connectAndGetMachine(machineId);
1693
+ const { server, machine, fullId } = await connectAndResolveSession(sessionIdPartial, machineId);
1728
1694
  try {
1729
- const sessions = await machine.listSessions();
1730
- const match = resolveSessionId(sessions, sessionIdPartial);
1731
- const fullId = match.sessionId;
1732
1695
  const svc = getSessionProxy(machine, fullId);
1733
1696
  const { metadata } = await svc.getMetadata();
1734
1697
  if (metadata?.ralphLoop?.active) {
@@ -1758,11 +1721,8 @@ async function sessionRalphStart(sessionIdPartial, task, machineId, opts) {
1758
1721
  }
1759
1722
  }
1760
1723
  async function sessionRalphCancel(sessionIdPartial, machineId) {
1761
- const { server, machine } = await connectAndGetMachine(machineId);
1724
+ const { server, machine, fullId } = await connectAndResolveSession(sessionIdPartial, machineId);
1762
1725
  try {
1763
- const sessions = await machine.listSessions();
1764
- const match = resolveSessionId(sessions, sessionIdPartial);
1765
- const fullId = match.sessionId;
1766
1726
  const svc = getSessionProxy(machine, fullId);
1767
1727
  const { metadata } = await svc.getMetadata();
1768
1728
  if (!metadata?.ralphLoop?.active) {
@@ -1777,11 +1737,8 @@ async function sessionRalphCancel(sessionIdPartial, machineId) {
1777
1737
  }
1778
1738
  }
1779
1739
  async function sessionRalphStatus(sessionIdPartial, machineId) {
1780
- const { server, machine } = await connectAndGetMachine(machineId);
1740
+ const { server, machine, fullId } = await connectAndResolveSession(sessionIdPartial, machineId);
1781
1741
  try {
1782
- const sessions = await machine.listSessions();
1783
- const match = resolveSessionId(sessions, sessionIdPartial);
1784
- const fullId = match.sessionId;
1785
1742
  const svc = getSessionProxy(machine, fullId);
1786
1743
  const { metadata } = await svc.getMetadata();
1787
1744
  const ralph = metadata?.ralphLoop;
@@ -1800,11 +1757,8 @@ async function sessionRalphStatus(sessionIdPartial, machineId) {
1800
1757
  }
1801
1758
  }
1802
1759
  async function sessionInboxSend(sessionIdPartial, body, machineId, opts) {
1803
- const { server, machine } = await connectAndGetMachine(machineId);
1760
+ const { server, machine, fullId } = await connectAndResolveSession(sessionIdPartial, machineId);
1804
1761
  try {
1805
- const sessions = await machine.listSessions();
1806
- const match = resolveSessionId(sessions, sessionIdPartial);
1807
- const fullId = match.sessionId;
1808
1762
  const { randomUUID } = await import('node:crypto');
1809
1763
  const message = {
1810
1764
  messageId: randomUUID(),
@@ -1829,11 +1783,8 @@ async function sessionInboxSend(sessionIdPartial, body, machineId, opts) {
1829
1783
  }
1830
1784
  }
1831
1785
  async function sessionInboxList(sessionIdPartial, machineId, opts) {
1832
- const { server, machine } = await connectAndGetMachine(machineId);
1786
+ const { server, machine, fullId } = await connectAndResolveSession(sessionIdPartial, machineId);
1833
1787
  try {
1834
- const sessions = await machine.listSessions();
1835
- const match = resolveSessionId(sessions, sessionIdPartial);
1836
- const fullId = match.sessionId;
1837
1788
  const result = await machine.sessionRPC(fullId, "getInbox", { opts: { unread: opts?.unread, limit: opts?.limit } });
1838
1789
  const messages = result.messages;
1839
1790
  if (opts?.json) {
@@ -1864,11 +1815,8 @@ async function sessionInboxList(sessionIdPartial, machineId, opts) {
1864
1815
  }
1865
1816
  }
1866
1817
  async function sessionInboxRead(sessionIdPartial, messageId, machineId) {
1867
- const { server, machine } = await connectAndGetMachine(machineId);
1818
+ const { server, machine, fullId } = await connectAndResolveSession(sessionIdPartial, machineId);
1868
1819
  try {
1869
- const sessions = await machine.listSessions();
1870
- const match = resolveSessionId(sessions, sessionIdPartial);
1871
- const fullId = match.sessionId;
1872
1820
  const result = await machine.sessionRPC(fullId, "getInbox", {});
1873
1821
  const msg = result.messages.find((m) => m.messageId === messageId || m.messageId.startsWith(messageId));
1874
1822
  if (!msg) {
@@ -1891,11 +1839,8 @@ ${msg.body}`);
1891
1839
  }
1892
1840
  }
1893
1841
  async function sessionInboxReply(sessionIdPartial, messageId, body, machineId) {
1894
- const { server, machine } = await connectAndGetMachine(machineId);
1842
+ const { server, machine, fullId } = await connectAndResolveSession(sessionIdPartial, machineId);
1895
1843
  try {
1896
- const sessions = await machine.listSessions();
1897
- const match = resolveSessionId(sessions, sessionIdPartial);
1898
- const fullId = match.sessionId;
1899
1844
  const result = await machine.sessionRPC(fullId, "getInbox", {});
1900
1845
  const original = result.messages.find((m) => m.messageId === messageId || m.messageId.startsWith(messageId));
1901
1846
  if (!original) {
@@ -1927,11 +1872,8 @@ async function sessionInboxReply(sessionIdPartial, messageId, body, machineId) {
1927
1872
  }
1928
1873
  }
1929
1874
  async function sessionInboxClear(sessionIdPartial, machineId, opts) {
1930
- const { server, machine } = await connectAndGetMachine(machineId);
1875
+ const { server, machine, fullId } = await connectAndResolveSession(sessionIdPartial, machineId);
1931
1876
  try {
1932
- const sessions = await machine.listSessions();
1933
- const match = resolveSessionId(sessions, sessionIdPartial);
1934
- const fullId = match.sessionId;
1935
1877
  const result = await machine.sessionRPC(fullId, "clearInbox", { opts: { all: opts?.all } });
1936
1878
  console.log(`Cleared inbox on session ${fullId.slice(0, 8)} (${result.remaining} remaining)`);
1937
1879
  } finally {
@@ -1939,4 +1881,4 @@ async function sessionInboxClear(sessionIdPartial, machineId, opts) {
1939
1881
  }
1940
1882
  }
1941
1883
 
1942
- export { connectAndGetMachine, createWorktree, generateWorktreeName, machineExec, machineInfo, machineLs, machineShare, parseShareArg, renderMessage, resolveSessionId, sessionApprove, sessionAttach, sessionDeny, sessionInboxClear, sessionInboxList, sessionInboxRead, sessionInboxReply, sessionInboxSend, sessionInfo, sessionList, sessionMachines, sessionMessages, sessionRalphCancel, sessionRalphStart, sessionRalphStatus, sessionSend, sessionShare, sessionSpawn, sessionStop, sessionWait };
1884
+ export { connectAndGetMachine, connectAndResolveSession, createWorktree, generateWorktreeName, machineExec, machineInfo, machineLs, machineShare, parseShareArg, renderMessage, resolveSessionId, sessionApprove, sessionAttach, sessionDeny, sessionInboxClear, sessionInboxList, sessionInboxRead, sessionInboxReply, sessionInboxSend, sessionInfo, sessionList, sessionMachines, sessionMessages, sessionRalphCancel, sessionRalphStart, sessionRalphStatus, sessionSend, sessionShare, sessionSpawn, sessionStop, sessionWait };
@@ -1,11 +1,11 @@
1
1
  import { writeFileSync, readFileSync } from 'fs';
2
2
  import { resolve } from 'path';
3
- import { connectAndGetMachine } from './commands-DxBS60bF.mjs';
3
+ import { connectAndGetMachine } from './commands-Bb11XUfY.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-DA-51t9q.mjs';
8
+ import './run-XoQsDcg4.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-DA-51t9q.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-XoQsDcg4.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.4";
2
+ var version = "0.2.6";
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-DA-51t9q.mjs';
5
+ import { c as connectToHypha, a as registerSessionService } from './run-XoQsDcg4.mjs';
6
6
  import { createServer } from 'node:http';
7
7
  import { spawn } from 'node:child_process';
8
8
  import { createInterface } from 'node:readline';
@@ -6883,6 +6883,72 @@ The automated loop has finished. Review the progress above and let me know if yo
6883
6883
  logger.log(`[Session ${sessionId}] Ralph fresh context: clearing resumeId for fresh spawn`);
6884
6884
  claudeResumeId = void 0;
6885
6885
  }
6886
+ if (msgMeta?.btw && claudeResumeId) {
6887
+ logger.log(`[Session ${sessionId}] /btw side-channel: "${text.substring(0, 80)}..."`);
6888
+ sessionService.pushMessage(
6889
+ { type: "message", message: `/btw ${text}`, level: "btw-question" },
6890
+ "event"
6891
+ );
6892
+ signalProcessing(true);
6893
+ const btwArgs = [
6894
+ "--print",
6895
+ text,
6896
+ "--resume",
6897
+ claudeResumeId,
6898
+ "--fork-session",
6899
+ "--no-session-persistence",
6900
+ "--output-format",
6901
+ "stream-json",
6902
+ "--verbose"
6903
+ ];
6904
+ const btwProcess = spawn$1("claude", btwArgs, {
6905
+ cwd: directory,
6906
+ env: { ...process.env },
6907
+ stdio: ["pipe", "pipe", "pipe"]
6908
+ });
6909
+ let btwResult = "";
6910
+ let btwBuffer = "";
6911
+ btwProcess.stdout.on("data", (chunk) => {
6912
+ btwBuffer += chunk.toString();
6913
+ let newlineIdx;
6914
+ while ((newlineIdx = btwBuffer.indexOf("\n")) !== -1) {
6915
+ const line = btwBuffer.substring(0, newlineIdx);
6916
+ btwBuffer = btwBuffer.substring(newlineIdx + 1);
6917
+ if (!line.trim()) continue;
6918
+ try {
6919
+ const msg = JSON.parse(line);
6920
+ if (msg.type === "assistant" && msg.message?.content) {
6921
+ for (const block of msg.message.content) {
6922
+ if (block.type === "text" && block.text) {
6923
+ btwResult += block.text;
6924
+ }
6925
+ }
6926
+ } else if (msg.type === "result") {
6927
+ const finalText = btwResult || msg.result || "(no response)";
6928
+ sessionService.pushMessage(
6929
+ { type: "message", message: finalText, level: "btw-answer" },
6930
+ "event"
6931
+ );
6932
+ signalProcessing(false);
6933
+ sessionService.sendSessionEnd();
6934
+ logger.log(`[Session ${sessionId}] /btw complete (${finalText.length} chars)`);
6935
+ }
6936
+ } catch {
6937
+ }
6938
+ }
6939
+ });
6940
+ btwProcess.on("exit", (code) => {
6941
+ if (code !== 0) {
6942
+ sessionService.pushMessage(
6943
+ { type: "message", message: `/btw failed (exit code ${code})`, level: "error" },
6944
+ "event"
6945
+ );
6946
+ signalProcessing(false);
6947
+ sessionService.sendSessionEnd();
6948
+ }
6949
+ });
6950
+ return;
6951
+ }
6886
6952
  if (!claudeProcess || claudeProcess.exitCode !== null) {
6887
6953
  spawnClaude(text, msgMeta);
6888
6954
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svamp-cli",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "Svamp CLI — AI workspace daemon on Hypha Cloud",
5
5
  "author": "Amun AI AB",
6
6
  "license": "SEE LICENSE IN LICENSE",