svamp-cli 0.1.74 → 0.1.75

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.
@@ -1,7 +1,6 @@
1
1
  import { existsSync, readFileSync, mkdirSync, writeFileSync, renameSync } from 'node:fs';
2
2
  import { join, dirname } from 'node:path';
3
3
  import os from 'node:os';
4
- import 'node:crypto';
5
4
 
6
5
  const SVAMP_HOME = process.env.SVAMP_HOME || join(os.homedir(), ".svamp");
7
6
  function getConfigPath(sessionId) {
package/dist/cli.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { b as stopDaemon, s as startDaemon, d as daemonStatus } from './run-6QgabuQN.mjs';
1
+ import { b as stopDaemon, s as startDaemon, d as daemonStatus } from './run-lhAjX4NB.mjs';
2
2
  import 'os';
3
3
  import 'fs/promises';
4
4
  import 'fs';
@@ -109,7 +109,7 @@ async function main() {
109
109
  const { handleServiceCommand } = await import('./commands-BLjcT1Vl.mjs');
110
110
  await handleServiceCommand();
111
111
  } else if (subcommand === "process" || subcommand === "proc") {
112
- const { processCommand } = await import('./commands-dKkUOvUb.mjs');
112
+ const { processCommand } = await import('./commands-Dq8WSqvt.mjs');
113
113
  let machineId;
114
114
  const processArgs = args.slice(1);
115
115
  const mIdx = processArgs.findIndex((a) => a === "--machine" || a === "-m");
@@ -127,7 +127,7 @@ async function main() {
127
127
  } else if (!subcommand || subcommand === "start") {
128
128
  await handleInteractiveCommand();
129
129
  } else if (subcommand === "--version" || subcommand === "-v") {
130
- const pkg = await import('./package-CCjeil_X.mjs').catch(() => ({ default: { version: "unknown" } }));
130
+ const pkg = await import('./package-BFnad6d1.mjs').catch(() => ({ default: { version: "unknown" } }));
131
131
  console.log(`svamp version: ${pkg.default.version}`);
132
132
  } else {
133
133
  console.error(`Unknown command: ${subcommand}`);
@@ -136,7 +136,7 @@ async function main() {
136
136
  }
137
137
  }
138
138
  async function handleInteractiveCommand() {
139
- const { runInteractive } = await import('./run-BgwhZgkT.mjs');
139
+ const { runInteractive } = await import('./run-Dy5lxT3M.mjs');
140
140
  const interactiveArgs = subcommand === "start" ? args.slice(1) : args;
141
141
  let directory = process.cwd();
142
142
  let resumeSessionId;
@@ -181,7 +181,7 @@ async function handleAgentCommand() {
181
181
  return;
182
182
  }
183
183
  if (agentArgs[0] === "list") {
184
- const { KNOWN_ACP_AGENTS, KNOWN_MCP_AGENTS: KNOWN_MCP_AGENTS2 } = await import('./run-6QgabuQN.mjs').then(function (n) { return n.i; });
184
+ const { KNOWN_ACP_AGENTS, KNOWN_MCP_AGENTS: KNOWN_MCP_AGENTS2 } = await import('./run-lhAjX4NB.mjs').then(function (n) { return n.i; });
185
185
  console.log("Known agents:");
186
186
  for (const [name, config2] of Object.entries(KNOWN_ACP_AGENTS)) {
187
187
  console.log(` ${name.padEnd(12)} ${config2.command} ${config2.args.join(" ")} (ACP)`);
@@ -193,7 +193,7 @@ async function handleAgentCommand() {
193
193
  console.log('Use "svamp agent -- <command> [args]" for a custom ACP agent.');
194
194
  return;
195
195
  }
196
- const { resolveAcpAgentConfig, KNOWN_MCP_AGENTS } = await import('./run-6QgabuQN.mjs').then(function (n) { return n.i; });
196
+ const { resolveAcpAgentConfig, KNOWN_MCP_AGENTS } = await import('./run-lhAjX4NB.mjs').then(function (n) { return n.i; });
197
197
  let cwd = process.cwd();
198
198
  const filteredArgs = [];
199
199
  for (let i = 0; i < agentArgs.length; i++) {
@@ -217,12 +217,12 @@ async function handleAgentCommand() {
217
217
  console.log(`Starting ${config.agentName} agent in ${cwd}...`);
218
218
  let backend;
219
219
  if (KNOWN_MCP_AGENTS[config.agentName]) {
220
- const { CodexMcpBackend } = await import('./run-6QgabuQN.mjs').then(function (n) { return n.j; });
220
+ const { CodexMcpBackend } = await import('./run-lhAjX4NB.mjs').then(function (n) { return n.j; });
221
221
  backend = new CodexMcpBackend({ cwd, log: logFn });
222
222
  } else {
223
- const { AcpBackend } = await import('./run-6QgabuQN.mjs').then(function (n) { return n.h; });
224
- const { GeminiTransport } = await import('./run-6QgabuQN.mjs').then(function (n) { return n.G; });
225
- const { DefaultTransport } = await import('./run-6QgabuQN.mjs').then(function (n) { return n.D; });
223
+ const { AcpBackend } = await import('./run-lhAjX4NB.mjs').then(function (n) { return n.h; });
224
+ const { GeminiTransport } = await import('./run-lhAjX4NB.mjs').then(function (n) { return n.G; });
225
+ const { DefaultTransport } = await import('./run-lhAjX4NB.mjs').then(function (n) { return n.D; });
226
226
  const transportHandler = config.agentName === "gemini" ? new GeminiTransport() : new DefaultTransport(config.agentName);
227
227
  backend = new AcpBackend({
228
228
  agentName: config.agentName,
@@ -340,7 +340,7 @@ async function handleSessionCommand() {
340
340
  printSessionHelp();
341
341
  return;
342
342
  }
343
- const { sessionList, sessionSpawn, sessionStop, sessionInfo, sessionMessages, sessionAttach, sessionMachines, sessionSend, sessionWait, sessionShare, sessionRalphStart, sessionRalphCancel, sessionRalphStatus, sessionQueueAdd, sessionQueueList, sessionQueueClear, sessionInboxSend, sessionInboxList, sessionInboxRead, sessionInboxReply, sessionInboxClear } = await import('./commands-ClMc3nSg.mjs');
343
+ const { sessionList, sessionSpawn, sessionStop, sessionInfo, sessionMessages, sessionAttach, sessionMachines, sessionSend, sessionWait, sessionShare, sessionRalphStart, sessionRalphCancel, sessionRalphStatus, sessionQueueAdd, sessionQueueList, sessionQueueClear } = await import('./commands-a7p1jW-t.mjs');
344
344
  const parseFlagStr = (flag, shortFlag) => {
345
345
  for (let i = 1; i < sessionArgs.length; i++) {
346
346
  if ((sessionArgs[i] === flag || shortFlag) && i + 1 < sessionArgs.length) {
@@ -400,7 +400,7 @@ async function handleSessionCommand() {
400
400
  allowDomain.push(sessionArgs[++i]);
401
401
  }
402
402
  }
403
- const { parseShareArg } = await import('./commands-ClMc3nSg.mjs');
403
+ const { parseShareArg } = await import('./commands-a7p1jW-t.mjs');
404
404
  const shareEntries = share.map((s) => parseShareArg(s));
405
405
  await sessionSpawn(agent, dir, targetMachineId, {
406
406
  message,
@@ -484,7 +484,7 @@ async function handleSessionCommand() {
484
484
  console.error("Usage: svamp session approve <session-id> [request-id] [--json]");
485
485
  process.exit(1);
486
486
  }
487
- const { sessionApprove } = await import('./commands-ClMc3nSg.mjs');
487
+ const { sessionApprove } = await import('./commands-a7p1jW-t.mjs');
488
488
  const approveReqId = sessionArgs[2] && !sessionArgs[2].startsWith("--") ? sessionArgs[2] : void 0;
489
489
  await sessionApprove(sessionArgs[1], approveReqId, targetMachineId, {
490
490
  json: hasFlag("--json")
@@ -494,7 +494,7 @@ async function handleSessionCommand() {
494
494
  console.error("Usage: svamp session deny <session-id> [request-id] [--json]");
495
495
  process.exit(1);
496
496
  }
497
- const { sessionDeny } = await import('./commands-ClMc3nSg.mjs');
497
+ const { sessionDeny } = await import('./commands-a7p1jW-t.mjs');
498
498
  const denyReqId = sessionArgs[2] && !sessionArgs[2].startsWith("--") ? sessionArgs[2] : void 0;
499
499
  await sessionDeny(sessionArgs[1], denyReqId, targetMachineId, {
500
500
  json: hasFlag("--json")
@@ -530,7 +530,7 @@ async function handleSessionCommand() {
530
530
  console.error("Usage: svamp session set-title <title>");
531
531
  process.exit(1);
532
532
  }
533
- const { sessionSetTitle } = await import('./agentCommands-7GGmL2zY.mjs');
533
+ const { sessionSetTitle } = await import('./agentCommands-C6iGblcL.mjs');
534
534
  await sessionSetTitle(title);
535
535
  } else if (sessionSubcommand === "set-link") {
536
536
  const url = sessionArgs[1];
@@ -539,7 +539,7 @@ async function handleSessionCommand() {
539
539
  process.exit(1);
540
540
  }
541
541
  const label = sessionArgs[2] && !sessionArgs[2].startsWith("--") ? sessionArgs[2] : void 0;
542
- const { sessionSetLink } = await import('./agentCommands-7GGmL2zY.mjs');
542
+ const { sessionSetLink } = await import('./agentCommands-C6iGblcL.mjs');
543
543
  await sessionSetLink(url, label);
544
544
  } else if (sessionSubcommand === "notify") {
545
545
  const message = sessionArgs[1];
@@ -548,7 +548,7 @@ async function handleSessionCommand() {
548
548
  process.exit(1);
549
549
  }
550
550
  const level = parseFlagStr("--level") || "info";
551
- const { sessionNotify } = await import('./agentCommands-7GGmL2zY.mjs');
551
+ const { sessionNotify } = await import('./agentCommands-C6iGblcL.mjs');
552
552
  await sessionNotify(message, level);
553
553
  } else if (sessionSubcommand === "broadcast") {
554
554
  const action = sessionArgs[1];
@@ -556,7 +556,7 @@ async function handleSessionCommand() {
556
556
  console.error("Usage: svamp session broadcast <action> [args...]\nActions: open-canvas <url> [label], close-canvas, toast <message>");
557
557
  process.exit(1);
558
558
  }
559
- const { sessionBroadcast } = await import('./agentCommands-7GGmL2zY.mjs');
559
+ const { sessionBroadcast } = await import('./agentCommands-C6iGblcL.mjs');
560
560
  await sessionBroadcast(action, sessionArgs.slice(2).filter((a) => !a.startsWith("--")));
561
561
  } else if (sessionSubcommand === "queue") {
562
562
  const queueSubcmd = sessionArgs[1];
@@ -582,82 +582,6 @@ async function handleSessionCommand() {
582
582
  console.error("Usage: svamp session queue <add|list|clear> <session-id> [args]");
583
583
  process.exit(1);
584
584
  }
585
- } else if (sessionSubcommand === "inbox") {
586
- const inboxSubcmd = sessionArgs[1];
587
- if (inboxSubcmd === "send") {
588
- const targetId = sessionArgs[2];
589
- if (!targetId) {
590
- console.error('Usage: svamp session inbox send <target-session-id> --subject "..." --body "..."');
591
- process.exit(1);
592
- }
593
- const ccStr = parseFlagStr("--cc");
594
- await sessionInboxSend(targetId, targetMachineId, {
595
- subject: parseFlagStr("--subject") || "",
596
- body: parseFlagStr("--body") || "",
597
- urgency: parseFlagStr("--urgency") || "normal",
598
- replyTo: parseFlagStr("--reply-to"),
599
- cc: ccStr ? ccStr.split(",").map((s) => s.trim()).filter(Boolean) : void 0,
600
- wait: hasFlag("--wait"),
601
- timeout: parseFlagInt("--timeout"),
602
- json: hasFlag("--json")
603
- });
604
- } else if (inboxSubcmd === "list" || inboxSubcmd === "ls") {
605
- const targetId = sessionArgs[2] && !sessionArgs[2].startsWith("--") ? sessionArgs[2] : process.env.SVAMP_SESSION_ID;
606
- if (!targetId) {
607
- console.error("Usage: svamp session inbox list [session-id] [--unread] [--limit N] [--json]");
608
- process.exit(1);
609
- }
610
- await sessionInboxList(targetId, targetMachineId, {
611
- unread: hasFlag("--unread"),
612
- limit: parseFlagInt("--limit"),
613
- json: hasFlag("--json")
614
- });
615
- } else if (inboxSubcmd === "read") {
616
- const targetId = sessionArgs[2];
617
- const msgId = sessionArgs[3];
618
- if (!targetId || !msgId) {
619
- console.error("Usage: svamp session inbox read <session-id> <message-id>");
620
- process.exit(1);
621
- }
622
- await sessionInboxRead(targetId, msgId, targetMachineId, {
623
- json: hasFlag("--json")
624
- });
625
- } else if (inboxSubcmd === "reply") {
626
- let targetId;
627
- let msgId;
628
- if (sessionArgs[3] && !sessionArgs[3].startsWith("--")) {
629
- targetId = sessionArgs[2];
630
- msgId = sessionArgs[3];
631
- } else if (sessionArgs[2] && !sessionArgs[2].startsWith("--")) {
632
- targetId = process.env.SVAMP_SESSION_ID;
633
- msgId = sessionArgs[2];
634
- }
635
- if (!targetId || !msgId) {
636
- console.error('Usage: svamp session inbox reply [session-id] <message-id> --body "..."');
637
- process.exit(1);
638
- }
639
- await sessionInboxReply(targetId, msgId, targetMachineId, {
640
- body: parseFlagStr("--body") || "",
641
- urgency: parseFlagStr("--urgency") || "normal",
642
- wait: hasFlag("--wait"),
643
- json: hasFlag("--json")
644
- });
645
- } else if (inboxSubcmd === "clear") {
646
- const targetId = sessionArgs[2];
647
- if (!targetId) {
648
- console.error("Usage: svamp session inbox clear <session-id> [--all]");
649
- process.exit(1);
650
- }
651
- const msgId = sessionArgs[3] && !sessionArgs[3].startsWith("--") ? sessionArgs[3] : void 0;
652
- await sessionInboxClear(targetId, targetMachineId, {
653
- messageId: msgId,
654
- all: hasFlag("--all"),
655
- json: hasFlag("--json")
656
- });
657
- } else {
658
- console.error("Usage: svamp session inbox <send|list|read|reply|clear> [args]");
659
- process.exit(1);
660
- }
661
585
  } else {
662
586
  console.error(`Unknown session command: ${sessionSubcommand}`);
663
587
  printSessionHelp();
@@ -673,7 +597,7 @@ async function handleMachineCommand() {
673
597
  return;
674
598
  }
675
599
  if (machineSubcommand === "share") {
676
- const { machineShare } = await import('./commands-ClMc3nSg.mjs');
600
+ const { machineShare } = await import('./commands-a7p1jW-t.mjs');
677
601
  let machineId;
678
602
  const shareArgs = [];
679
603
  for (let i = 1; i < machineArgs.length; i++) {
@@ -703,7 +627,7 @@ async function handleMachineCommand() {
703
627
  }
704
628
  await machineShare(machineId, { add, remove, list, configPath, showConfig });
705
629
  } else if (machineSubcommand === "exec") {
706
- const { machineExec } = await import('./commands-ClMc3nSg.mjs');
630
+ const { machineExec } = await import('./commands-a7p1jW-t.mjs');
707
631
  let machineId;
708
632
  let cwd;
709
633
  const cmdParts = [];
@@ -723,7 +647,7 @@ async function handleMachineCommand() {
723
647
  }
724
648
  await machineExec(machineId, command, cwd);
725
649
  } else if (machineSubcommand === "info") {
726
- const { machineInfo } = await import('./commands-ClMc3nSg.mjs');
650
+ const { machineInfo } = await import('./commands-a7p1jW-t.mjs');
727
651
  let machineId;
728
652
  for (let i = 1; i < machineArgs.length; i++) {
729
653
  if ((machineArgs[i] === "--machine" || machineArgs[i] === "-m") && i + 1 < machineArgs.length) {
@@ -743,10 +667,10 @@ async function handleMachineCommand() {
743
667
  level = machineArgs[++i];
744
668
  }
745
669
  }
746
- const { machineNotify } = await import('./agentCommands-7GGmL2zY.mjs');
670
+ const { machineNotify } = await import('./agentCommands-C6iGblcL.mjs');
747
671
  await machineNotify(message, level);
748
672
  } else if (machineSubcommand === "ls") {
749
- const { machineLs } = await import('./commands-ClMc3nSg.mjs');
673
+ const { machineLs } = await import('./commands-a7p1jW-t.mjs');
750
674
  let machineId;
751
675
  let showHidden = false;
752
676
  let path;
@@ -1236,17 +1160,10 @@ COMMANDS:
1236
1160
  ralph-cancel <id> Cancel loop
1237
1161
  ralph-status <id> Show loop status
1238
1162
 
1239
- Inbox:
1240
- inbox send <target> --subject "..." --body "..." Send inbox message
1241
- inbox list [session-id] [--unread] [--json] List inbox messages
1242
- inbox read <session-id> <message-id> Read a message
1243
- inbox reply [session-id] <message-id> --body "..." Reply to a message
1244
- inbox clear <session-id> [--all] Clear inbox
1245
-
1246
- Queue (deprecated, use inbox):
1247
- queue add <id> "<message>" Queue a message (alias for inbox send)
1248
- queue list <id> List messages (alias for inbox list)
1249
- queue clear <id> Clear messages (alias for inbox clear)
1163
+ Message Queue:
1164
+ queue add <id> "<message>" Queue a message for later
1165
+ queue list <id> List queued messages
1166
+ queue clear <id> Clear queue
1250
1167
 
1251
1168
  SPAWN OPTIONS:
1252
1169
  -d, --directory <path> Working directory (REQUIRED for meaningful work)
@@ -1,17 +1,17 @@
1
1
  import { writeFileSync, readFileSync } from 'fs';
2
2
  import { resolve } from 'path';
3
- import { connectAndGetMachine } from './commands-ClMc3nSg.mjs';
3
+ import { connectAndGetMachine } from './commands-a7p1jW-t.mjs';
4
4
  import 'node:fs';
5
5
  import 'node:child_process';
6
- import 'node:crypto';
7
6
  import 'node:path';
8
7
  import 'node:os';
9
- import './run-6QgabuQN.mjs';
8
+ import './run-lhAjX4NB.mjs';
10
9
  import 'os';
11
10
  import 'fs/promises';
12
11
  import 'url';
13
12
  import 'child_process';
14
13
  import 'crypto';
14
+ import 'node:crypto';
15
15
  import '@agentclientprotocol/sdk';
16
16
  import '@modelcontextprotocol/sdk/client/index.js';
17
17
  import '@modelcontextprotocol/sdk/client/stdio.js';
@@ -1,9 +1,8 @@
1
1
  import { existsSync, readFileSync } from 'node:fs';
2
2
  import { execSync } from 'node:child_process';
3
- import { randomUUID } from 'node:crypto';
4
3
  import { resolve, join } from 'node:path';
5
4
  import os from 'node:os';
6
- import { l as loadSecurityContextConfig, e as resolveSecurityContext, f as buildSecurityContextFromFlags, m as mergeSecurityContexts, c as connectToHypha } from './run-6QgabuQN.mjs';
5
+ import { l as loadSecurityContextConfig, e as resolveSecurityContext, f as buildSecurityContextFromFlags, m as mergeSecurityContexts, c as connectToHypha } from './run-lhAjX4NB.mjs';
7
6
  import 'os';
8
7
  import 'fs/promises';
9
8
  import 'fs';
@@ -11,6 +10,7 @@ import 'path';
11
10
  import 'url';
12
11
  import 'child_process';
13
12
  import 'crypto';
13
+ import 'node:crypto';
14
14
  import '@agentclientprotocol/sdk';
15
15
  import '@modelcontextprotocol/sdk/client/index.js';
16
16
  import '@modelcontextprotocol/sdk/client/stdio.js';
@@ -1713,207 +1713,71 @@ async function sessionQueueAdd(sessionIdPartial, message, machineId) {
1713
1713
  const match = resolveSessionId(sessions, sessionIdPartial);
1714
1714
  const fullId = match.sessionId;
1715
1715
  const svc = await server.getService(`svamp-session-${fullId}`);
1716
+ const { metadata, version } = await svc.getMetadata();
1717
+ const existingQueue = metadata?.messageQueue || [];
1716
1718
  const newMsg = {
1717
- messageId: `msg-${randomUUID()}`,
1718
- body: message,
1719
- timestamp: Date.now(),
1720
- read: false
1719
+ id: `cli-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
1720
+ text: message,
1721
+ createdAt: Date.now()
1721
1722
  };
1722
- await svc.sendInboxMessage(newMsg);
1723
- console.log(`Message queued on session ${fullId.slice(0, 8)}`);
1724
- } finally {
1725
- await server.disconnect();
1726
- }
1727
- }
1728
- async function sessionQueueList(sessionIdPartial, machineId) {
1729
- return sessionInboxList(sessionIdPartial, machineId);
1730
- }
1731
- async function sessionQueueClear(sessionIdPartial, machineId) {
1732
- return sessionInboxClear(sessionIdPartial, machineId);
1733
- }
1734
- async function sessionInboxSend(targetSessionId, machineId, opts) {
1735
- if (!opts?.subject || !opts?.body) {
1736
- console.error('Usage: svamp session inbox send <target-session-id> --subject "..." --body "..."');
1737
- process.exit(1);
1738
- }
1739
- const { server, machine } = await connectAndGetMachine(machineId);
1740
- try {
1741
- const sessions = await machine.listSessions();
1742
- const match = resolveSessionId(sessions, targetSessionId);
1743
- const fullTargetId = match.sessionId;
1744
- const senderSessionId = process.env.SVAMP_SESSION_ID || "cli";
1745
- const senderEmail = process.env.USER_EMAIL || process.env.USER || os.userInfo().username;
1746
- const from = senderSessionId === "cli" ? `user:${senderEmail}` : `agent:${senderSessionId}`;
1747
- const message = {
1748
- messageId: `msg-${randomUUID()}`,
1749
- from,
1750
- fromSession: senderSessionId,
1751
- to: fullTargetId,
1752
- subject: opts.subject,
1753
- body: opts.body,
1754
- urgency: opts.urgency || "normal",
1755
- replyTo: opts.replyTo,
1756
- cc: opts.cc,
1757
- timestamp: Date.now(),
1758
- read: false,
1759
- threadId: opts.replyTo ? void 0 : void 0
1760
- // will be set by reply logic
1761
- };
1762
- const svc = await server.getService(`svamp-session-${fullTargetId}`);
1763
- const result = await svc.sendInboxMessage(message);
1764
- if (opts.wait) {
1765
- const timeoutMs = (opts.timeout || 300) * 1e3;
1766
- await waitForBusyThenIdle(server, fullTargetId, timeoutMs);
1767
- }
1768
- if (opts.json) {
1769
- console.log(formatJson({
1770
- messageId: message.messageId,
1771
- targetSessionId: fullTargetId,
1772
- subject: opts.subject,
1773
- urgency: message.urgency,
1774
- delivered: result.delivered
1775
- }));
1776
- } else {
1777
- console.log(`Inbox message sent to session ${fullTargetId.slice(0, 8)} [${message.urgency}]: "${opts.subject}"`);
1778
- }
1779
- } finally {
1780
- await server.disconnect();
1781
- }
1782
- }
1783
- async function sessionInboxList(sessionIdPartial, machineId, opts) {
1784
- const { server, machine } = await connectAndGetMachine(machineId);
1785
- try {
1786
- const sessions = await machine.listSessions();
1787
- const match = resolveSessionId(sessions, sessionIdPartial);
1788
- const fullId = match.sessionId;
1789
- const svc = await server.getService(`svamp-session-${fullId}`);
1790
- const result = await svc.getInbox({
1791
- unreadOnly: opts?.unread || false,
1792
- limit: opts?.limit || 50
1793
- });
1794
- if (opts?.json) ; else {
1795
- const msgs = result.messages || [];
1796
- if (msgs.length === 0) {
1797
- console.log("Inbox is empty.");
1798
- return;
1799
- }
1800
- console.log(`Inbox for session ${fullId.slice(0, 8)} (${msgs.length} message(s), ${result.total} total):
1801
- `);
1802
- for (const msg of msgs) {
1803
- const readMark = msg.read ? " " : "*";
1804
- const date = new Date(msg.timestamp).toLocaleString();
1805
- console.log(`${readMark} [${msg.messageId.slice(0, 12)}] ${date}`);
1806
- console.log(` From: ${msg.from} | Subject: ${msg.subject} | Urgency: ${msg.urgency}`);
1807
- if (msg.replyTo) console.log(` Reply-To: ${msg.replyTo.slice(0, 12)}`);
1808
- console.log(` ${msg.body.slice(0, 120)}${msg.body.length > 120 ? "..." : ""}`);
1809
- console.log();
1810
- }
1811
- }
1812
- } finally {
1813
- await server.disconnect();
1814
- }
1815
- }
1816
- async function sessionInboxRead(sessionIdPartial, messageId, machineId, opts) {
1817
- const { server, machine } = await connectAndGetMachine(machineId);
1818
- try {
1819
- const sessions = await machine.listSessions();
1820
- const match = resolveSessionId(sessions, sessionIdPartial);
1821
- const fullId = match.sessionId;
1822
- const svc = await server.getService(`svamp-session-${fullId}`);
1823
- const result = await svc.getInbox({});
1824
- const msg = (result.messages || []).find(
1825
- (m) => m.messageId === messageId || m.messageId.startsWith(messageId)
1826
- );
1827
- if (!msg) {
1828
- console.error(`Message ${messageId} not found in inbox.`);
1723
+ const updatedQueue = [...existingQueue, newMsg];
1724
+ const updatedMetadata = { ...metadata, messageQueue: updatedQueue };
1725
+ const result = await svc.updateMetadata(updatedMetadata, version);
1726
+ if (result.result !== "success") {
1727
+ console.error(`Failed to add to queue: ${result.result}`);
1829
1728
  process.exit(1);
1830
1729
  }
1831
- await svc.markInboxRead([msg.messageId]);
1832
- if (opts?.json) {
1833
- console.log(formatJson(msg));
1834
- } else {
1835
- console.log(`Message-ID: ${msg.messageId}`);
1836
- console.log(`From: ${msg.from}`);
1837
- console.log(`From-Session: ${msg.fromSession}`);
1838
- console.log(`Subject: ${msg.subject}`);
1839
- console.log(`Urgency: ${msg.urgency}`);
1840
- console.log(`Date: ${new Date(msg.timestamp).toLocaleString()}`);
1841
- if (msg.replyTo) console.log(`Reply-To: ${msg.replyTo}`);
1842
- if (msg.cc?.length) console.log(`CC: ${msg.cc.join(", ")}`);
1843
- console.log(`---`);
1844
- console.log(msg.body);
1845
- }
1730
+ console.log(`Message queued on session ${fullId.slice(0, 8)} (${updatedQueue.length} total)`);
1846
1731
  } finally {
1847
1732
  await server.disconnect();
1848
1733
  }
1849
1734
  }
1850
- async function sessionInboxReply(sessionIdPartial, messageId, machineId, opts) {
1851
- if (!opts?.body) {
1852
- console.error('Usage: svamp session inbox reply <session-id> <message-id> --body "..."');
1853
- process.exit(1);
1854
- }
1735
+ async function sessionQueueList(sessionIdPartial, machineId) {
1855
1736
  const { server, machine } = await connectAndGetMachine(machineId);
1856
1737
  try {
1857
1738
  const sessions = await machine.listSessions();
1858
1739
  const match = resolveSessionId(sessions, sessionIdPartial);
1859
1740
  const fullId = match.sessionId;
1860
1741
  const svc = await server.getService(`svamp-session-${fullId}`);
1861
- const inboxResult = await svc.getInbox({});
1862
- const originalMsg = (inboxResult.messages || []).find(
1863
- (m) => m.messageId === messageId || m.messageId.startsWith(messageId)
1864
- );
1865
- if (!originalMsg) {
1866
- console.error(`Message ${messageId} not found in inbox. Cannot reply.`);
1867
- process.exit(1);
1742
+ const { metadata } = await svc.getMetadata();
1743
+ const queue = metadata?.messageQueue || [];
1744
+ if (queue.length === 0) {
1745
+ console.log("Queue is empty.");
1746
+ return;
1868
1747
  }
1869
- const senderSessionId = process.env.SVAMP_SESSION_ID || fullId;
1870
- const senderEmail = process.env.USER_EMAIL || process.env.USER || os.userInfo().username;
1871
- const from = senderSessionId === "cli" ? `user:${senderEmail}` : `agent:${senderSessionId}`;
1872
- const reply = {
1873
- messageId: `msg-${randomUUID()}`,
1874
- from,
1875
- fromSession: senderSessionId,
1876
- to: originalMsg.fromSession,
1877
- subject: `Re: ${originalMsg.subject}`,
1878
- body: opts.body,
1879
- urgency: opts.urgency || "normal",
1880
- replyTo: originalMsg.messageId,
1881
- threadId: originalMsg.threadId || originalMsg.messageId,
1882
- timestamp: Date.now(),
1883
- read: false
1884
- };
1885
- const targetSvc = await server.getService(`svamp-session-${originalMsg.fromSession}`);
1886
- const result = await targetSvc.sendInboxMessage(reply);
1887
- if (opts.json) {
1888
- console.log(formatJson({
1889
- messageId: reply.messageId,
1890
- targetSessionId: originalMsg.fromSession,
1891
- subject: reply.subject,
1892
- urgency: reply.urgency,
1893
- delivered: result.delivered
1894
- }));
1895
- } else {
1896
- console.log(`Reply sent to session ${originalMsg.fromSession.slice(0, 8)}: "${reply.subject}"`);
1748
+ console.log(`Queue for session ${fullId.slice(0, 8)} (${queue.length} messages):`);
1749
+ for (let i = 0; i < queue.length; i++) {
1750
+ const msg = queue[i];
1751
+ const time = new Date(msg.createdAt).toLocaleTimeString();
1752
+ console.log(` ${i + 1}. [${time}] ${msg.text.slice(0, 80)}${msg.text.length > 80 ? "..." : ""}`);
1897
1753
  }
1898
1754
  } finally {
1899
1755
  await server.disconnect();
1900
1756
  }
1901
1757
  }
1902
- async function sessionInboxClear(sessionIdPartial, machineId, opts) {
1758
+ async function sessionQueueClear(sessionIdPartial, machineId) {
1903
1759
  const { server, machine } = await connectAndGetMachine(machineId);
1904
1760
  try {
1905
1761
  const sessions = await machine.listSessions();
1906
1762
  const match = resolveSessionId(sessions, sessionIdPartial);
1907
1763
  const fullId = match.sessionId;
1908
1764
  const svc = await server.getService(`svamp-session-${fullId}`);
1909
- const messageIds = opts?.messageId ? [opts.messageId] : void 0;
1910
- const result = await svc.clearInbox(messageIds);
1911
- if (opts?.json) ; else {
1912
- console.log(`Cleared ${result.removed} message(s) from inbox on session ${fullId.slice(0, 8)}`);
1765
+ const { metadata, version } = await svc.getMetadata();
1766
+ const count = (metadata?.messageQueue || []).length;
1767
+ if (count === 0) {
1768
+ console.log("Queue is already empty.");
1769
+ return;
1770
+ }
1771
+ const updatedMetadata = { ...metadata, messageQueue: void 0 };
1772
+ const result = await svc.updateMetadata(updatedMetadata, version);
1773
+ if (result.result !== "success") {
1774
+ console.error(`Failed to clear queue: ${result.result}`);
1775
+ process.exit(1);
1913
1776
  }
1777
+ console.log(`Cleared ${count} message(s) from queue on session ${fullId.slice(0, 8)}`);
1914
1778
  } finally {
1915
1779
  await server.disconnect();
1916
1780
  }
1917
1781
  }
1918
1782
 
1919
- export { connectAndGetMachine, createWorktree, generateWorktreeName, machineExec, machineInfo, machineLs, machineShare, parseShareArg, renderMessage, resolveSessionId, sessionApprove, sessionAttach, sessionDeny, sessionInboxClear, sessionInboxList, sessionInboxRead, sessionInboxReply, sessionInboxSend, sessionInfo, sessionList, sessionMachines, sessionMessages, sessionQueueAdd, sessionQueueClear, sessionQueueList, sessionRalphCancel, sessionRalphStart, sessionRalphStatus, sessionSend, sessionShare, sessionSpawn, sessionStop, sessionWait };
1783
+ export { connectAndGetMachine, createWorktree, generateWorktreeName, machineExec, machineInfo, machineLs, machineShare, parseShareArg, renderMessage, resolveSessionId, sessionApprove, sessionAttach, sessionDeny, sessionInfo, sessionList, sessionMachines, sessionMessages, sessionQueueAdd, sessionQueueClear, sessionQueueList, sessionRalphCancel, sessionRalphStart, sessionRalphStatus, sessionSend, sessionShare, sessionSpawn, sessionStop, sessionWait };
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-6QgabuQN.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-lhAjX4NB.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.74";
2
+ var version = "0.1.75";
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";
@@ -29,6 +29,7 @@ var dependencies = {
29
29
  "@agentclientprotocol/sdk": "^0.14.1",
30
30
  "@modelcontextprotocol/sdk": "^1.25.3",
31
31
  "hypha-rpc": "0.21.29",
32
+ "node-pty": "^1.1.0",
32
33
  ws: "^8.18.0",
33
34
  yaml: "^2.8.2",
34
35
  zod: "^3.24.4"
@@ -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-6QgabuQN.mjs';
5
+ import { c as connectToHypha, a as registerSessionService } from './run-lhAjX4NB.mjs';
6
6
  import { createServer } from 'node:http';
7
7
  import { spawn } from 'node:child_process';
8
8
  import { createInterface } from 'node:readline';