svamp-cli 0.2.139 → 0.2.140
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.
|
@@ -195,12 +195,9 @@ async function inboxSend(targetSessionId, opts) {
|
|
|
195
195
|
console.error("Message body is required.");
|
|
196
196
|
process.exit(1);
|
|
197
197
|
}
|
|
198
|
-
const {
|
|
198
|
+
const { connectAndResolveSession } = await import('./commands-BrFcWUFe.mjs');
|
|
199
|
+
const { server, machine, fullId } = await connectAndResolveSession(targetSessionId);
|
|
199
200
|
try {
|
|
200
|
-
const { resolveSessionId } = await import('./commands-BrFcWUFe.mjs');
|
|
201
|
-
const sessions = await machine.listSessions();
|
|
202
|
-
const match = resolveSessionId(sessions, targetSessionId);
|
|
203
|
-
const fullTargetId = match.sessionId;
|
|
204
201
|
const message = {
|
|
205
202
|
messageId: shortId(),
|
|
206
203
|
body,
|
|
@@ -208,12 +205,12 @@ async function inboxSend(targetSessionId, opts) {
|
|
|
208
205
|
read: false,
|
|
209
206
|
from: `agent:${sessionId}`,
|
|
210
207
|
fromSession: sessionId,
|
|
211
|
-
to:
|
|
208
|
+
to: fullId,
|
|
212
209
|
subject: opts?.subject,
|
|
213
210
|
urgency: opts?.urgency || "normal"
|
|
214
211
|
};
|
|
215
|
-
const result = await machine.sessionRPC(
|
|
216
|
-
console.log(`Inbox message sent to ${
|
|
212
|
+
const result = await machine.sessionRPC(fullId, "sendInboxMessage", { message });
|
|
213
|
+
console.log(`Inbox message sent to ${fullId.slice(0, 8)} (id: ${result.messageId.slice(0, 8)})`);
|
|
217
214
|
} finally {
|
|
218
215
|
await server.disconnect();
|
|
219
216
|
}
|
|
@@ -256,10 +253,11 @@ async function inboxReply(messageId, body) {
|
|
|
256
253
|
console.error("SVAMP_SESSION_ID not set. This command must be run inside a Svamp session.");
|
|
257
254
|
process.exit(1);
|
|
258
255
|
}
|
|
256
|
+
let original;
|
|
259
257
|
const { server, machine } = await connectToMachineService();
|
|
260
258
|
try {
|
|
261
259
|
const result = await machine.sessionRPC(sessionId, "getInbox", {});
|
|
262
|
-
|
|
260
|
+
original = result.messages.find((m) => m.messageId === messageId || m.messageId.startsWith(messageId));
|
|
263
261
|
if (!original) {
|
|
264
262
|
console.error(`Message ${messageId} not found in inbox.`);
|
|
265
263
|
process.exit(1);
|
|
@@ -279,6 +277,12 @@ async function inboxReply(messageId, body) {
|
|
|
279
277
|
console.error("Cannot reply: original message has no fromSession (and not a channel message).");
|
|
280
278
|
process.exit(1);
|
|
281
279
|
}
|
|
280
|
+
} finally {
|
|
281
|
+
await server.disconnect();
|
|
282
|
+
}
|
|
283
|
+
const { connectAndResolveSession } = await import('./commands-BrFcWUFe.mjs');
|
|
284
|
+
const { server: sendServer, machine: sendMachine, fullId } = await connectAndResolveSession(original.fromSession);
|
|
285
|
+
try {
|
|
282
286
|
const reply = {
|
|
283
287
|
messageId: shortId(),
|
|
284
288
|
body,
|
|
@@ -286,16 +290,16 @@ async function inboxReply(messageId, body) {
|
|
|
286
290
|
read: false,
|
|
287
291
|
from: `agent:${sessionId}`,
|
|
288
292
|
fromSession: sessionId,
|
|
289
|
-
to:
|
|
293
|
+
to: fullId,
|
|
290
294
|
subject: original.subject ? `Re: ${original.subject}` : void 0,
|
|
291
295
|
urgency: "normal",
|
|
292
296
|
replyTo: original.messageId,
|
|
293
297
|
threadId: original.threadId || original.messageId
|
|
294
298
|
};
|
|
295
|
-
const sendResult = await
|
|
296
|
-
console.log(`Reply sent to ${
|
|
299
|
+
const sendResult = await sendMachine.sessionRPC(fullId, "sendInboxMessage", { message: reply });
|
|
300
|
+
console.log(`Reply sent to ${fullId.slice(0, 8)} (id: ${sendResult.messageId.slice(0, 8)})`);
|
|
297
301
|
} finally {
|
|
298
|
-
await
|
|
302
|
+
await sendServer.disconnect();
|
|
299
303
|
}
|
|
300
304
|
}
|
|
301
305
|
async function machineNotify(message, level = "info") {
|
package/dist/cli.mjs
CHANGED
|
@@ -390,7 +390,7 @@ async function main() {
|
|
|
390
390
|
} else if (!subcommand || subcommand === "start") {
|
|
391
391
|
await handleInteractiveCommand();
|
|
392
392
|
} else if (subcommand === "--version" || subcommand === "-v") {
|
|
393
|
-
const pkg = await import('./package-
|
|
393
|
+
const pkg = await import('./package-C_TBqrbi.mjs').catch(() => ({ default: { version: "unknown" } }));
|
|
394
394
|
console.log(`svamp version: ${pkg.default.version}`);
|
|
395
395
|
} else {
|
|
396
396
|
console.error(`Unknown command: ${subcommand}`);
|
|
@@ -912,7 +912,7 @@ async function handleSessionCommand() {
|
|
|
912
912
|
console.error("Usage: svamp session set-title <title>");
|
|
913
913
|
process.exit(1);
|
|
914
914
|
}
|
|
915
|
-
const { sessionSetTitle } = await import('./agentCommands-
|
|
915
|
+
const { sessionSetTitle } = await import('./agentCommands-D8MtjJSX.mjs');
|
|
916
916
|
await sessionSetTitle(title);
|
|
917
917
|
} else if (sessionSubcommand === "set-project-description" || sessionSubcommand === "set-project") {
|
|
918
918
|
const desc = sessionArgs.slice(1).filter((a) => !a.startsWith("--")).join(" ");
|
|
@@ -920,7 +920,7 @@ async function handleSessionCommand() {
|
|
|
920
920
|
console.error("Usage: svamp session set-project-description <text>");
|
|
921
921
|
process.exit(1);
|
|
922
922
|
}
|
|
923
|
-
const { sessionSetProjectDescription } = await import('./agentCommands-
|
|
923
|
+
const { sessionSetProjectDescription } = await import('./agentCommands-D8MtjJSX.mjs');
|
|
924
924
|
await sessionSetProjectDescription(desc);
|
|
925
925
|
} else if (sessionSubcommand === "set-link") {
|
|
926
926
|
const url = sessionArgs[1];
|
|
@@ -929,7 +929,7 @@ async function handleSessionCommand() {
|
|
|
929
929
|
process.exit(1);
|
|
930
930
|
}
|
|
931
931
|
const label = sessionArgs[2] && !sessionArgs[2].startsWith("--") ? sessionArgs[2] : void 0;
|
|
932
|
-
const { sessionSetLink } = await import('./agentCommands-
|
|
932
|
+
const { sessionSetLink } = await import('./agentCommands-D8MtjJSX.mjs');
|
|
933
933
|
await sessionSetLink(url, label);
|
|
934
934
|
} else if (sessionSubcommand === "notify") {
|
|
935
935
|
const message = sessionArgs[1];
|
|
@@ -938,7 +938,7 @@ async function handleSessionCommand() {
|
|
|
938
938
|
process.exit(1);
|
|
939
939
|
}
|
|
940
940
|
const level = parseFlagStr("--level") || "info";
|
|
941
|
-
const { sessionNotify } = await import('./agentCommands-
|
|
941
|
+
const { sessionNotify } = await import('./agentCommands-D8MtjJSX.mjs');
|
|
942
942
|
await sessionNotify(message, level);
|
|
943
943
|
} else if (sessionSubcommand === "broadcast") {
|
|
944
944
|
const action = sessionArgs[1];
|
|
@@ -946,7 +946,7 @@ async function handleSessionCommand() {
|
|
|
946
946
|
console.error("Usage: svamp session broadcast <action> [args...]\nActions: open-canvas <url> [label], close-canvas, toast <message>");
|
|
947
947
|
process.exit(1);
|
|
948
948
|
}
|
|
949
|
-
const { sessionBroadcast } = await import('./agentCommands-
|
|
949
|
+
const { sessionBroadcast } = await import('./agentCommands-D8MtjJSX.mjs');
|
|
950
950
|
await sessionBroadcast(action, sessionArgs.slice(2).filter((a) => !a.startsWith("--")));
|
|
951
951
|
} else if (sessionSubcommand === "inbox") {
|
|
952
952
|
const inboxSubcmd = sessionArgs[1];
|
|
@@ -957,7 +957,7 @@ async function handleSessionCommand() {
|
|
|
957
957
|
process.exit(1);
|
|
958
958
|
}
|
|
959
959
|
if (agentSessionId) {
|
|
960
|
-
const { inboxSend } = await import('./agentCommands-
|
|
960
|
+
const { inboxSend } = await import('./agentCommands-D8MtjJSX.mjs');
|
|
961
961
|
await inboxSend(sessionArgs[2], {
|
|
962
962
|
body: sessionArgs[3],
|
|
963
963
|
subject: parseFlagStr("--subject"),
|
|
@@ -972,7 +972,7 @@ async function handleSessionCommand() {
|
|
|
972
972
|
}
|
|
973
973
|
} else if (inboxSubcmd === "list" || inboxSubcmd === "ls") {
|
|
974
974
|
if (agentSessionId && !sessionArgs[2]) {
|
|
975
|
-
const { inboxList } = await import('./agentCommands-
|
|
975
|
+
const { inboxList } = await import('./agentCommands-D8MtjJSX.mjs');
|
|
976
976
|
await inboxList({
|
|
977
977
|
unread: hasFlag("--unread"),
|
|
978
978
|
limit: parseFlagInt("--limit"),
|
|
@@ -994,7 +994,7 @@ async function handleSessionCommand() {
|
|
|
994
994
|
process.exit(1);
|
|
995
995
|
}
|
|
996
996
|
if (agentSessionId && !sessionArgs[3]) {
|
|
997
|
-
const { inboxList } = await import('./agentCommands-
|
|
997
|
+
const { inboxList } = await import('./agentCommands-D8MtjJSX.mjs');
|
|
998
998
|
await sessionInboxRead(agentSessionId, sessionArgs[2], targetMachineId);
|
|
999
999
|
} else if (sessionArgs[3]) {
|
|
1000
1000
|
await sessionInboxRead(sessionArgs[2], sessionArgs[3], targetMachineId);
|
|
@@ -1004,7 +1004,7 @@ async function handleSessionCommand() {
|
|
|
1004
1004
|
}
|
|
1005
1005
|
} else if (inboxSubcmd === "reply") {
|
|
1006
1006
|
if (agentSessionId && sessionArgs[2] && sessionArgs[3] && !sessionArgs[4]) {
|
|
1007
|
-
const { inboxReply } = await import('./agentCommands-
|
|
1007
|
+
const { inboxReply } = await import('./agentCommands-D8MtjJSX.mjs');
|
|
1008
1008
|
await inboxReply(sessionArgs[2], sessionArgs[3]);
|
|
1009
1009
|
} else if (sessionArgs[2] && sessionArgs[3] && sessionArgs[4]) {
|
|
1010
1010
|
await sessionInboxReply(sessionArgs[2], sessionArgs[3], sessionArgs[4], targetMachineId);
|
|
@@ -1118,7 +1118,7 @@ async function handleMachineCommand() {
|
|
|
1118
1118
|
level = machineArgs[++i];
|
|
1119
1119
|
}
|
|
1120
1120
|
}
|
|
1121
|
-
const { machineNotify } = await import('./agentCommands-
|
|
1121
|
+
const { machineNotify } = await import('./agentCommands-D8MtjJSX.mjs');
|
|
1122
1122
|
await machineNotify(message, level);
|
|
1123
1123
|
} else if (machineSubcommand === "ls") {
|
|
1124
1124
|
const { machineLs } = await import('./commands-BrFcWUFe.mjs');
|