svamp-cli 0.1.39 → 0.1.40
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
|
@@ -91,7 +91,7 @@ async function main() {
|
|
|
91
91
|
} else if (!subcommand || subcommand === "start") {
|
|
92
92
|
await handleInteractiveCommand();
|
|
93
93
|
} else if (subcommand === "--version" || subcommand === "-v") {
|
|
94
|
-
const pkg = await import('./package-
|
|
94
|
+
const pkg = await import('./package-D6mNQtUs.mjs').catch(() => ({ default: { version: "unknown" } }));
|
|
95
95
|
console.log(`svamp version: ${pkg.default.version}`);
|
|
96
96
|
} else {
|
|
97
97
|
console.error(`Unknown command: ${subcommand}`);
|
|
@@ -100,7 +100,7 @@ async function main() {
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
async function handleInteractiveCommand() {
|
|
103
|
-
const { runInteractive } = await import('./run-
|
|
103
|
+
const { runInteractive } = await import('./run-Ckh6JE9F.mjs');
|
|
104
104
|
const interactiveArgs = subcommand === "start" ? args.slice(1) : args;
|
|
105
105
|
let directory = process.cwd();
|
|
106
106
|
let resumeSessionId;
|
|
@@ -711,23 +711,37 @@ async function runInteractive(options) {
|
|
|
711
711
|
process.exit(0);
|
|
712
712
|
},
|
|
713
713
|
// File system operations — run locally since we have direct access
|
|
714
|
+
// All callbacks use try/catch to prevent errors from leaking
|
|
715
|
+
// through hypha-rpc's error handler to the terminal
|
|
714
716
|
onBash: async (command, execCwd) => {
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
717
|
+
try {
|
|
718
|
+
const { execSync } = await import('child_process');
|
|
719
|
+
const result = execSync(command, {
|
|
720
|
+
cwd: execCwd || cwd,
|
|
721
|
+
encoding: "utf-8",
|
|
722
|
+
timeout: 3e4,
|
|
723
|
+
maxBuffer: 1024 * 1024
|
|
724
|
+
});
|
|
725
|
+
return { output: result };
|
|
726
|
+
} catch (err) {
|
|
727
|
+
return { output: err.stdout || "", error: err.message, exitCode: err.status || 1 };
|
|
728
|
+
}
|
|
723
729
|
},
|
|
724
730
|
onReadFile: async (path) => {
|
|
725
|
-
|
|
726
|
-
|
|
731
|
+
try {
|
|
732
|
+
const { readFileSync: readFileSync2 } = await import('fs');
|
|
733
|
+
return readFileSync2(path, "utf-8");
|
|
734
|
+
} catch (err) {
|
|
735
|
+
throw new Error(`Cannot read file: ${err.message}`);
|
|
736
|
+
}
|
|
727
737
|
},
|
|
728
738
|
onWriteFile: async (path, content) => {
|
|
729
|
-
|
|
730
|
-
|
|
739
|
+
try {
|
|
740
|
+
const { writeFileSync } = await import('fs');
|
|
741
|
+
writeFileSync(path, content, "utf-8");
|
|
742
|
+
} catch (err) {
|
|
743
|
+
throw new Error(`Cannot write file: ${err.message}`);
|
|
744
|
+
}
|
|
731
745
|
},
|
|
732
746
|
onListDirectory: async (path) => {
|
|
733
747
|
const { readdirSync, statSync } = await import('fs');
|
|
@@ -742,13 +756,17 @@ async function runInteractive(options) {
|
|
|
742
756
|
});
|
|
743
757
|
},
|
|
744
758
|
onRipgrep: async (rgArgs, execCwd) => {
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
759
|
+
try {
|
|
760
|
+
const { execSync } = await import('child_process');
|
|
761
|
+
return execSync(`rg ${rgArgs}`, {
|
|
762
|
+
cwd: execCwd || cwd,
|
|
763
|
+
encoding: "utf-8",
|
|
764
|
+
timeout: 15e3,
|
|
765
|
+
maxBuffer: 1024 * 1024
|
|
766
|
+
});
|
|
767
|
+
} catch (err) {
|
|
768
|
+
return err.stdout || "";
|
|
769
|
+
}
|
|
752
770
|
}
|
|
753
771
|
};
|
|
754
772
|
try {
|
|
@@ -924,7 +942,10 @@ function readMachineId() {
|
|
|
924
942
|
let _origLog = null;
|
|
925
943
|
let _origWarn = null;
|
|
926
944
|
let _origInfo = null;
|
|
945
|
+
let _origDebug = null;
|
|
946
|
+
let _origError = null;
|
|
927
947
|
let _origStdoutWrite = null;
|
|
948
|
+
let _origStderrWrite = null;
|
|
928
949
|
const HYPHA_LOG_PATTERNS = [
|
|
929
950
|
"WebSocket connection",
|
|
930
951
|
"Connection established",
|
|
@@ -942,7 +963,18 @@ const HYPHA_LOG_PATTERNS = [
|
|
|
942
963
|
"disconnected, cleaning up",
|
|
943
964
|
"HYPHA SESSION",
|
|
944
965
|
"Listener registered",
|
|
945
|
-
"local RPC disconnection"
|
|
966
|
+
"local RPC disconnection",
|
|
967
|
+
"not found for method",
|
|
968
|
+
"likely cleaned up",
|
|
969
|
+
"Promise method",
|
|
970
|
+
"not available (detected by session type)",
|
|
971
|
+
"Session ",
|
|
972
|
+
// catch-all for "Session X not found" etc.
|
|
973
|
+
"Failed to find method",
|
|
974
|
+
"Method not found",
|
|
975
|
+
"Error during calling method",
|
|
976
|
+
"Timeout subscribing",
|
|
977
|
+
"Manager does not support subscribe"
|
|
946
978
|
];
|
|
947
979
|
function isHyphaLogLine(text) {
|
|
948
980
|
return HYPHA_LOG_PATTERNS.some((p) => text.includes(p));
|
|
@@ -952,7 +984,10 @@ function suppressHyphaLogs() {
|
|
|
952
984
|
_origLog = console.log;
|
|
953
985
|
_origWarn = console.warn;
|
|
954
986
|
_origInfo = console.info;
|
|
987
|
+
_origDebug = console.debug;
|
|
988
|
+
_origError = console.error;
|
|
955
989
|
_origStdoutWrite = process.stdout.write.bind(process.stdout);
|
|
990
|
+
_origStderrWrite = process.stderr.write.bind(process.stderr);
|
|
956
991
|
console.log = (...args) => {
|
|
957
992
|
if (DEBUG) _origLog.call(console, "[hypha-log]", ...args);
|
|
958
993
|
};
|
|
@@ -962,6 +997,17 @@ function suppressHyphaLogs() {
|
|
|
962
997
|
console.info = (...args) => {
|
|
963
998
|
if (DEBUG) _origInfo.call(console, "[hypha-info]", ...args);
|
|
964
999
|
};
|
|
1000
|
+
console.debug = (...args) => {
|
|
1001
|
+
if (DEBUG) _origDebug.call(console, "[hypha-debug]", ...args);
|
|
1002
|
+
};
|
|
1003
|
+
console.error = (...args) => {
|
|
1004
|
+
const text = args.map((a) => typeof a === "string" ? a : String(a)).join(" ");
|
|
1005
|
+
if (isHyphaLogLine(text)) {
|
|
1006
|
+
if (DEBUG) _origError.call(console, "[hypha-err]", ...args);
|
|
1007
|
+
return;
|
|
1008
|
+
}
|
|
1009
|
+
_origError.call(console, ...args);
|
|
1010
|
+
};
|
|
965
1011
|
process.stdout.write = function(chunk, ...rest) {
|
|
966
1012
|
const text = typeof chunk === "string" ? chunk : chunk?.toString?.() || "";
|
|
967
1013
|
if (isHyphaLogLine(text)) {
|
|
@@ -970,19 +1016,35 @@ function suppressHyphaLogs() {
|
|
|
970
1016
|
}
|
|
971
1017
|
return _origStdoutWrite.call(process.stdout, chunk, ...rest);
|
|
972
1018
|
};
|
|
1019
|
+
process.stderr.write = function(chunk, ...rest) {
|
|
1020
|
+
const text = typeof chunk === "string" ? chunk : chunk?.toString?.() || "";
|
|
1021
|
+
if (isHyphaLogLine(text)) {
|
|
1022
|
+
if (DEBUG) _origStderrWrite(`[hypha-stderr] ${text}`);
|
|
1023
|
+
return true;
|
|
1024
|
+
}
|
|
1025
|
+
return _origStderrWrite.call(process.stderr, chunk, ...rest);
|
|
1026
|
+
};
|
|
973
1027
|
}
|
|
974
1028
|
function restoreConsoleLogs() {
|
|
975
1029
|
if (!_origLog) return;
|
|
976
1030
|
console.log = _origLog;
|
|
977
1031
|
console.warn = _origWarn;
|
|
978
1032
|
console.info = _origInfo;
|
|
1033
|
+
console.debug = _origDebug;
|
|
1034
|
+
console.error = _origError;
|
|
979
1035
|
if (_origStdoutWrite) {
|
|
980
1036
|
process.stdout.write = _origStdoutWrite;
|
|
981
1037
|
}
|
|
1038
|
+
if (_origStderrWrite) {
|
|
1039
|
+
process.stderr.write = _origStderrWrite;
|
|
1040
|
+
}
|
|
982
1041
|
_origLog = null;
|
|
983
1042
|
_origWarn = null;
|
|
984
1043
|
_origInfo = null;
|
|
1044
|
+
_origDebug = null;
|
|
1045
|
+
_origError = null;
|
|
985
1046
|
_origStdoutWrite = null;
|
|
1047
|
+
_origStderrWrite = null;
|
|
986
1048
|
}
|
|
987
1049
|
|
|
988
1050
|
export { runInteractive };
|