svamp-cli 0.2.5 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{agentCommands-H9L9d8cw.mjs → agentCommands-vROerKBL.mjs} +2 -2
- package/dist/cli.mjs +27 -27
- package/dist/{commands-DkIugVbL.mjs → commands-B5yjf3Me.mjs} +2 -2
- package/dist/{commands-md-Rbc_2.mjs → commands-Bh7MIzIQ.mjs} +51 -109
- package/dist/index.mjs +1 -1
- package/dist/{package-_sA63eK5.mjs → package-rfyKrDIy.mjs} +1 -1
- package/dist/{run-XoQsDcg4.mjs → run-1sh7lcBI.mjs} +33 -1
- package/dist/{run-RsupAuzC.mjs → run-CKmnXg7d.mjs} +1 -1
- package/package.json +1 -1
|
@@ -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-
|
|
151
|
+
const { connectAndGetMachine } = await import('./commands-Bh7MIzIQ.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-
|
|
168
|
+
const { resolveSessionId } = await import('./commands-Bh7MIzIQ.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-
|
|
1
|
+
import { b as stopDaemon, s as startDaemon, d as daemonStatus } from './run-1sh7lcBI.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-
|
|
234
|
+
const { processCommand } = await import('./commands-B5yjf3Me.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-
|
|
252
|
+
const pkg = await import('./package-rfyKrDIy.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-
|
|
261
|
+
const { runInteractive } = await import('./run-CKmnXg7d.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-
|
|
306
|
+
const { KNOWN_ACP_AGENTS, KNOWN_MCP_AGENTS: KNOWN_MCP_AGENTS2 } = await import('./run-1sh7lcBI.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-
|
|
318
|
+
const { resolveAcpAgentConfig, KNOWN_MCP_AGENTS } = await import('./run-1sh7lcBI.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-
|
|
342
|
+
const { CodexMcpBackend } = await import('./run-1sh7lcBI.mjs').then(function (n) { return n.j; });
|
|
343
343
|
backend = new CodexMcpBackend({ cwd, log: logFn });
|
|
344
344
|
} else {
|
|
345
|
-
const { AcpBackend } = await import('./run-
|
|
346
|
-
const { GeminiTransport } = await import('./run-
|
|
347
|
-
const { DefaultTransport } = await import('./run-
|
|
345
|
+
const { AcpBackend } = await import('./run-1sh7lcBI.mjs').then(function (n) { return n.h; });
|
|
346
|
+
const { GeminiTransport } = await import('./run-1sh7lcBI.mjs').then(function (n) { return n.G; });
|
|
347
|
+
const { DefaultTransport } = await import('./run-1sh7lcBI.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-
|
|
474
|
+
const { sessionList, sessionSpawn, sessionStop, sessionInfo, sessionMessages, sessionAttach, sessionMachines, sessionSend, sessionWait, sessionShare, sessionRalphStart, sessionRalphCancel, sessionRalphStatus, sessionInboxSend, sessionInboxList, sessionInboxRead, sessionInboxReply, sessionInboxClear } = await import('./commands-Bh7MIzIQ.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-
|
|
534
|
+
const { parseShareArg } = await import('./commands-Bh7MIzIQ.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-
|
|
620
|
+
const { sessionApprove } = await import('./commands-Bh7MIzIQ.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-
|
|
630
|
+
const { sessionDeny } = await import('./commands-Bh7MIzIQ.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-
|
|
666
|
+
const { sessionSetTitle } = await import('./agentCommands-vROerKBL.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-
|
|
675
|
+
const { sessionSetLink } = await import('./agentCommands-vROerKBL.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-
|
|
684
|
+
const { sessionNotify } = await import('./agentCommands-vROerKBL.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-
|
|
692
|
+
const { sessionBroadcast } = await import('./agentCommands-vROerKBL.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-
|
|
703
|
+
const { inboxSend } = await import('./agentCommands-vROerKBL.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-
|
|
718
|
+
const { inboxList } = await import('./agentCommands-vROerKBL.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-
|
|
740
|
+
const { inboxList } = await import('./agentCommands-vROerKBL.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-
|
|
750
|
+
const { inboxReply } = await import('./agentCommands-vROerKBL.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-
|
|
786
|
+
const { machineShare } = await import('./commands-Bh7MIzIQ.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-
|
|
816
|
+
const { machineExec } = await import('./commands-Bh7MIzIQ.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-
|
|
836
|
+
const { machineInfo } = await import('./commands-Bh7MIzIQ.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-
|
|
856
|
+
const { machineNotify } = await import('./agentCommands-vROerKBL.mjs');
|
|
857
857
|
await machineNotify(message, level);
|
|
858
858
|
} else if (machineSubcommand === "ls") {
|
|
859
|
-
const { machineLs } = await import('./commands-
|
|
859
|
+
const { machineLs } = await import('./commands-Bh7MIzIQ.mjs');
|
|
860
860
|
let machineId;
|
|
861
861
|
let showHidden = false;
|
|
862
862
|
let path;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { writeFileSync, readFileSync } from 'fs';
|
|
2
2
|
import { resolve } from 'path';
|
|
3
|
-
import { connectAndGetMachine } from './commands-
|
|
3
|
+
import { connectAndGetMachine } from './commands-Bh7MIzIQ.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-
|
|
8
|
+
import './run-1sh7lcBI.mjs';
|
|
9
9
|
import 'os';
|
|
10
10
|
import 'fs/promises';
|
|
11
11
|
import 'url';
|
|
@@ -2,7 +2,7 @@ import { existsSync, readFileSync } from 'node:fs';
|
|
|
2
2
|
import { execSync } from 'node:child_process';
|
|
3
3
|
import { resolve, join } from 'node:path';
|
|
4
4
|
import os from 'node:os';
|
|
5
|
-
import { l as loadSecurityContextConfig, e as resolveSecurityContext, f as buildSecurityContextFromFlags, m as mergeSecurityContexts, c as connectToHypha } from './run-
|
|
5
|
+
import { l as loadSecurityContextConfig, e as resolveSecurityContext, f as buildSecurityContextFromFlags, m as mergeSecurityContexts, c as connectToHypha } from './run-1sh7lcBI.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
|
|
1034
|
+
const { server, machine, fullId } = await connectAndResolveSession(sessionId, machineId);
|
|
1007
1035
|
try {
|
|
1008
|
-
const
|
|
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 ${
|
|
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
|
|
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 ||
|
|
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 ||
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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 };
|
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-
|
|
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-1sh7lcBI.mjs';
|
|
2
2
|
import 'os';
|
|
3
3
|
import 'fs/promises';
|
|
4
4
|
import 'fs';
|
|
@@ -315,6 +315,14 @@ async function getPtyModule() {
|
|
|
315
315
|
function generateTerminalId() {
|
|
316
316
|
return `term-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
|
|
317
317
|
}
|
|
318
|
+
function filterTerminalResponses(data) {
|
|
319
|
+
if (!data || data.length === 0) return data;
|
|
320
|
+
if (data.indexOf("\x1B") === -1) return data;
|
|
321
|
+
let filtered = data.replace(/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/g, "");
|
|
322
|
+
filtered = filtered.replace(/\x1b\[\d+;\d+R/g, "");
|
|
323
|
+
filtered = filtered.replace(/\x1b\[\?\d+(?:;\d+)*c/g, "");
|
|
324
|
+
return filtered;
|
|
325
|
+
}
|
|
318
326
|
function getMachineMetadataPath(svampHomeDir) {
|
|
319
327
|
return join(svampHomeDir, "machine-metadata.json");
|
|
320
328
|
}
|
|
@@ -858,7 +866,8 @@ async function registerMachineService(server, machineId, metadata, daemonState,
|
|
|
858
866
|
authorizeRequest(context, currentMetadata.sharing, "admin");
|
|
859
867
|
const session = terminalSessions.get(params.sessionId);
|
|
860
868
|
if (!session) throw new Error(`Terminal session ${params.sessionId} not found`);
|
|
861
|
-
|
|
869
|
+
const filtered = filterTerminalResponses(params.data);
|
|
870
|
+
if (filtered) session.pty.write(filtered);
|
|
862
871
|
return { success: true };
|
|
863
872
|
},
|
|
864
873
|
/** Resize a terminal session. */
|
|
@@ -1213,6 +1222,25 @@ function loadMessages(messagesDir, sessionId) {
|
|
|
1213
1222
|
return [];
|
|
1214
1223
|
}
|
|
1215
1224
|
}
|
|
1225
|
+
function loadMessagesFromDisk(messagesDir, afterSeq, limit) {
|
|
1226
|
+
const filePath = join$1(messagesDir, "messages.jsonl");
|
|
1227
|
+
if (!existsSync(filePath)) return { messages: [], hasMore: false };
|
|
1228
|
+
try {
|
|
1229
|
+
const lines = readFileSync(filePath, "utf-8").split("\n").filter((l) => l.trim());
|
|
1230
|
+
const filtered = [];
|
|
1231
|
+
for (const line of lines) {
|
|
1232
|
+
try {
|
|
1233
|
+
const msg = JSON.parse(line);
|
|
1234
|
+
if (msg.seq > afterSeq) filtered.push(msg);
|
|
1235
|
+
} catch {
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
const page = filtered.slice(0, limit);
|
|
1239
|
+
return { messages: page, hasMore: filtered.length > limit };
|
|
1240
|
+
} catch {
|
|
1241
|
+
return { messages: [], hasMore: false };
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1216
1244
|
function appendMessage(messagesDir, sessionId, msg) {
|
|
1217
1245
|
try {
|
|
1218
1246
|
const filePath = join$1(messagesDir, "messages.jsonl");
|
|
@@ -1336,6 +1364,10 @@ function createSessionStore(server, sessionId, initialMetadata, initialAgentStat
|
|
|
1336
1364
|
authorizeRequest(context, metadata.sharing, "view");
|
|
1337
1365
|
const after = afterSeq ?? 0;
|
|
1338
1366
|
const lim = Math.min(limit ?? 100, 500);
|
|
1367
|
+
const minInMemorySeq = messages.length > 0 ? messages[0].seq : Infinity;
|
|
1368
|
+
if (after < minInMemorySeq && options?.messagesDir) {
|
|
1369
|
+
return loadMessagesFromDisk(options.messagesDir, after, lim);
|
|
1370
|
+
}
|
|
1339
1371
|
const filtered = messages.filter((m) => m.seq > after);
|
|
1340
1372
|
const page = filtered.slice(0, lim);
|
|
1341
1373
|
return {
|
|
@@ -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-
|
|
5
|
+
import { c as connectToHypha, a as registerSessionService } from './run-1sh7lcBI.mjs';
|
|
6
6
|
import { createServer } from 'node:http';
|
|
7
7
|
import { spawn } from 'node:child_process';
|
|
8
8
|
import { createInterface } from 'node:readline';
|