svamp-cli 0.1.71 → 0.1.73

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/cli.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { b as stopDaemon, s as startDaemon, d as daemonStatus } from './run-DGKMT1Af.mjs';
1
+ import { b as stopDaemon, s as startDaemon, d as daemonStatus } from './run-DWTcdCOS.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-CheZ8rae.mjs');
112
+ const { processCommand } = await import('./commands-CPy4F-7w.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-CxTZatXO.mjs').catch(() => ({ default: { version: "unknown" } }));
130
+ const pkg = await import('./package-BAXhI1Iz.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-6vD6-456.mjs');
139
+ const { runInteractive } = await import('./run-C2UwUIgR.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-DGKMT1Af.mjs').then(function (n) { return n.i; });
184
+ const { KNOWN_ACP_AGENTS, KNOWN_MCP_AGENTS: KNOWN_MCP_AGENTS2 } = await import('./run-DWTcdCOS.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-DGKMT1Af.mjs').then(function (n) { return n.i; });
196
+ const { resolveAcpAgentConfig, KNOWN_MCP_AGENTS } = await import('./run-DWTcdCOS.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-DGKMT1Af.mjs').then(function (n) { return n.j; });
220
+ const { CodexMcpBackend } = await import('./run-DWTcdCOS.mjs').then(function (n) { return n.j; });
221
221
  backend = new CodexMcpBackend({ cwd, log: logFn });
222
222
  } else {
223
- const { AcpBackend } = await import('./run-DGKMT1Af.mjs').then(function (n) { return n.h; });
224
- const { GeminiTransport } = await import('./run-DGKMT1Af.mjs').then(function (n) { return n.G; });
225
- const { DefaultTransport } = await import('./run-DGKMT1Af.mjs').then(function (n) { return n.D; });
223
+ const { AcpBackend } = await import('./run-DWTcdCOS.mjs').then(function (n) { return n.h; });
224
+ const { GeminiTransport } = await import('./run-DWTcdCOS.mjs').then(function (n) { return n.G; });
225
+ const { DefaultTransport } = await import('./run-DWTcdCOS.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 } = await import('./commands-DDqf8dQ_.mjs');
343
+ const { sessionList, sessionSpawn, sessionStop, sessionInfo, sessionMessages, sessionAttach, sessionMachines, sessionSend, sessionWait, sessionShare, sessionRalphStart, sessionRalphCancel, sessionRalphStatus, sessionQueueAdd, sessionQueueList, sessionQueueClear } = await import('./commands-gghG16ZB.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-DDqf8dQ_.mjs');
403
+ const { parseShareArg } = await import('./commands-gghG16ZB.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-DDqf8dQ_.mjs');
487
+ const { sessionApprove } = await import('./commands-gghG16ZB.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-DDqf8dQ_.mjs');
497
+ const { sessionDeny } = await import('./commands-gghG16ZB.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")
@@ -597,7 +597,7 @@ async function handleMachineCommand() {
597
597
  return;
598
598
  }
599
599
  if (machineSubcommand === "share") {
600
- const { machineShare } = await import('./commands-DDqf8dQ_.mjs');
600
+ const { machineShare } = await import('./commands-gghG16ZB.mjs');
601
601
  let machineId;
602
602
  const shareArgs = [];
603
603
  for (let i = 1; i < machineArgs.length; i++) {
@@ -627,7 +627,7 @@ async function handleMachineCommand() {
627
627
  }
628
628
  await machineShare(machineId, { add, remove, list, configPath, showConfig });
629
629
  } else if (machineSubcommand === "exec") {
630
- const { machineExec } = await import('./commands-DDqf8dQ_.mjs');
630
+ const { machineExec } = await import('./commands-gghG16ZB.mjs');
631
631
  let machineId;
632
632
  let cwd;
633
633
  const cmdParts = [];
@@ -647,7 +647,7 @@ async function handleMachineCommand() {
647
647
  }
648
648
  await machineExec(machineId, command, cwd);
649
649
  } else if (machineSubcommand === "info") {
650
- const { machineInfo } = await import('./commands-DDqf8dQ_.mjs');
650
+ const { machineInfo } = await import('./commands-gghG16ZB.mjs');
651
651
  let machineId;
652
652
  for (let i = 1; i < machineArgs.length; i++) {
653
653
  if ((machineArgs[i] === "--machine" || machineArgs[i] === "-m") && i + 1 < machineArgs.length) {
@@ -670,7 +670,7 @@ async function handleMachineCommand() {
670
670
  const { machineNotify } = await import('./agentCommands-C6iGblcL.mjs');
671
671
  await machineNotify(message, level);
672
672
  } else if (machineSubcommand === "ls") {
673
- const { machineLs } = await import('./commands-DDqf8dQ_.mjs');
673
+ const { machineLs } = await import('./commands-gghG16ZB.mjs');
674
674
  let machineId;
675
675
  let showHidden = false;
676
676
  let path;
@@ -1,11 +1,11 @@
1
1
  import { writeFileSync, readFileSync } from 'fs';
2
2
  import { resolve } from 'path';
3
- import { connectAndGetMachine } from './commands-DDqf8dQ_.mjs';
3
+ import { connectAndGetMachine } from './commands-gghG16ZB.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-DGKMT1Af.mjs';
8
+ import './run-DWTcdCOS.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-DGKMT1Af.mjs';
5
+ import { l as loadSecurityContextConfig, e as resolveSecurityContext, f as buildSecurityContextFromFlags, m as mergeSecurityContexts, c as connectToHypha } from './run-DWTcdCOS.mjs';
6
6
  import 'os';
7
7
  import 'fs/promises';
8
8
  import 'fs';
@@ -181,28 +181,56 @@ async function connectAndGetMachine(machineId) {
181
181
  });
182
182
  if (prefixMatches.length === 1) {
183
183
  selectedService = prefixMatches[0];
184
- } else if (prefixMatches.length === 0) {
185
- const substringMatches = services.filter((s) => {
186
- const id = s.id || s.name || "";
187
- return id.includes(machineId);
188
- });
189
- if (substringMatches.length === 1) {
190
- selectedService = substringMatches[0];
191
- } else {
192
- restoreConsole();
193
- console.error(`No machine found matching: ${machineId}`);
194
- console.error("Available machines:");
195
- for (const s of services) {
196
- console.error(` ${s.id || s.name}`);
197
- }
198
- await server.disconnect();
199
- process.exit(1);
184
+ }
185
+ }
186
+ if (!selectedService) {
187
+ const query = machineId.toLowerCase();
188
+ const resolved = [];
189
+ await Promise.all(services.map(async (svc) => {
190
+ const svcId2 = svc.id || svc.name;
191
+ try {
192
+ const machineSvc = await server.getService(svcId2);
193
+ const info = await machineSvc.getMachineInfo();
194
+ resolved.push({
195
+ svc,
196
+ machineId: (info.machineId || svcId2).toLowerCase(),
197
+ host: (info.metadata?.host || "").toLowerCase(),
198
+ displayName: (info.metadata?.displayName || "").toLowerCase()
199
+ });
200
+ } catch {
201
+ }
202
+ }));
203
+ let matches = resolved.filter(
204
+ (r) => r.machineId === query || r.host === query || r.displayName === query
205
+ );
206
+ if (matches.length === 0) {
207
+ matches = resolved.filter(
208
+ (r) => r.machineId.startsWith(query) || r.host.startsWith(query) || r.displayName.startsWith(query)
209
+ );
210
+ }
211
+ if (matches.length === 0) {
212
+ matches = resolved.filter(
213
+ (r) => r.machineId.includes(query) || r.host.includes(query) || r.displayName.includes(query)
214
+ );
215
+ }
216
+ if (matches.length === 1) {
217
+ selectedService = matches[0].svc;
218
+ } else if (matches.length > 1) {
219
+ restoreConsole();
220
+ console.error(`Ambiguous machine "${machineId}". Matches:`);
221
+ for (const m of matches) {
222
+ console.error(` ${m.machineId} (${m.host})`);
200
223
  }
224
+ await server.disconnect();
225
+ process.exit(1);
201
226
  } else {
202
227
  restoreConsole();
203
- console.error(`Ambiguous machine ID "${machineId}". Matches:`);
204
- for (const s of prefixMatches) {
205
- console.error(` ${s.id || s.name}`);
228
+ console.error(`No machine found matching: ${machineId}`);
229
+ if (resolved.length > 0) {
230
+ console.error("Available machines:");
231
+ for (const r of resolved) {
232
+ console.error(` ${r.machineId} (${r.host})`);
233
+ }
206
234
  }
207
235
  await server.disconnect();
208
236
  process.exit(1);
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-DGKMT1Af.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-DWTcdCOS.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.71";
2
+ var version = "0.1.73";
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-DGKMT1Af.mjs';
5
+ import { c as connectToHypha, a as registerSessionService } from './run-DWTcdCOS.mjs';
6
6
  import { createServer } from 'node:http';
7
7
  import { spawn } from 'node:child_process';
8
8
  import { createInterface } from 'node:readline';
@@ -907,7 +907,7 @@ function createSessionStore(server, sessionId, initialMetadata, initialAgentStat
907
907
  let agentState = initialAgentState ? { ...initialAgentState } : null;
908
908
  let agentStateVersion = 1;
909
909
  let lastActivity = {
910
- active: false,
910
+ active: true,
911
911
  thinking: false,
912
912
  mode: "remote",
913
913
  time: Date.now()
@@ -5585,6 +5585,8 @@ async function startDaemon(options) {
5585
5585
  let lastSpawnMeta = persisted?.spawnMeta || {};
5586
5586
  let sessionWasProcessing = !!options2.wasProcessing;
5587
5587
  let lastAssistantText = "";
5588
+ let consecutiveRalphErrors = 0;
5589
+ const MAX_RALPH_ERRORS = 3;
5588
5590
  let spawnHasReceivedInit = false;
5589
5591
  let startupFailureRetryPending = false;
5590
5592
  let startupRetryMessage;
@@ -5905,6 +5907,33 @@ async function startDaemon(options) {
5905
5907
  sessionService.pushMessage({ type: "session_event", message: taskInfo }, "session");
5906
5908
  }
5907
5909
  const queueLen = sessionMetadata.messageQueue?.length ?? 0;
5910
+ if (msg.is_error) {
5911
+ const rlStateForError = readRalphState(getRalphStateFilePath(directory, sessionId));
5912
+ if (rlStateForError) {
5913
+ consecutiveRalphErrors++;
5914
+ logger.log(`[Session ${sessionId}] Ralph loop: error result (consecutive=${consecutiveRalphErrors}/${MAX_RALPH_ERRORS})`);
5915
+ if (consecutiveRalphErrors >= MAX_RALPH_ERRORS) {
5916
+ logger.log(`[Session ${sessionId}] Ralph loop: ${MAX_RALPH_ERRORS} consecutive errors \u2014 stopping loop`);
5917
+ removeRalphState(getRalphStateFilePath(directory, sessionId));
5918
+ if (lastSpawnMeta.appendSystemPrompt) {
5919
+ const { appendSystemPrompt: _, ...rest } = lastSpawnMeta;
5920
+ lastSpawnMeta = rest;
5921
+ }
5922
+ sessionMetadata = { ...sessionMetadata, ralphLoop: { active: false }, lifecycleState: "idle" };
5923
+ sessionService.updateMetadata(sessionMetadata);
5924
+ sessionService.pushMessage(
5925
+ { type: "message", message: `Ralph loop stopped \u2014 ${consecutiveRalphErrors} consecutive errors. Last error: ${msg.result || "unknown"}`, level: "error" },
5926
+ "event"
5927
+ );
5928
+ consecutiveRalphErrors = 0;
5929
+ signalProcessing(false);
5930
+ sessionService.sendSessionEnd();
5931
+ break;
5932
+ }
5933
+ }
5934
+ } else {
5935
+ consecutiveRalphErrors = 0;
5936
+ }
5908
5937
  if (queueLen > 0 && claudeResumeId && !trackedSession.stopped) {
5909
5938
  setTimeout(() => processMessageQueueRef?.(), 200);
5910
5939
  } else if (claudeResumeId) {
@@ -7381,6 +7410,12 @@ The automated loop has finished. Review the progress above and let me know if yo
7381
7410
  });
7382
7411
  if (result.type === "success") {
7383
7412
  logger.log(`Restored session ${persisted.sessionId} (resume=${persisted.claudeResumeId}, wasProcessing=${persisted.wasProcessing})`);
7413
+ for (const [, tracked] of pidToTrackedSession) {
7414
+ if (tracked.svampSessionId === persisted.sessionId && tracked.hyphaService) {
7415
+ tracked.hyphaService.sendKeepAlive(false);
7416
+ break;
7417
+ }
7418
+ }
7384
7419
  if (isOrphaned) {
7385
7420
  for (const [, tracked] of pidToTrackedSession) {
7386
7421
  if (tracked.svampSessionId === persisted.sessionId && tracked.hyphaService) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svamp-cli",
3
- "version": "0.1.71",
3
+ "version": "0.1.73",
4
4
  "description": "Svamp CLI — AI workspace daemon on Hypha Cloud",
5
5
  "author": "Amun AI AB",
6
6
  "license": "SEE LICENSE IN LICENSE",