Files
lobster/bin/openclaw.invoke.js
2026-06-22 13:53:21 +08:00

28 lines
924 B
JavaScript
Executable File

#!/usr/bin/env node
import { spawnSync } from "node:child_process";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
function shellQuote(arg) {
// Conservative POSIX-ish quoting for embedding argv into a single pipeline string.
// Lobster's pipeline parser preserves quoted substrings.
if (/^[A-Za-z0-9_\-./:=@]+$/.test(arg)) return arg;
// single-quote, escaping embedded single quotes: ' -> '\''
return `'${String(arg).replace(/'/g, `'\\''`)}'`;
}
const argv = process.argv.slice(2);
const pipeline = ["openclaw.invoke", ...argv.map(shellQuote)].join(" ");
const lobsterBin = join(dirname(fileURLToPath(import.meta.url)), "lobster.js");
const res = spawnSync(process.execPath, [lobsterBin, pipeline], {
stdio: "inherit",
env: process.env,
});
if (res.error) {
console.error(`openclaw.invoke failed to spawn lobster: ${res.error.message}`);
}
process.exit(res.status ?? 1);