diff --git a/src/infra/gateway-process-argv.test.ts b/src/infra/gateway-process-argv.test.ts index f3570316860..81e6da2210a 100644 --- a/src/infra/gateway-process-argv.test.ts +++ b/src/infra/gateway-process-argv.test.ts @@ -10,6 +10,11 @@ describe("parseProcCmdline", () => { "18789", ]); }); + + it("keeps non-delimited single arguments and drops whitespace-only entries", () => { + expect(parseProcCmdline(" gateway ")).toEqual(["gateway"]); + expect(parseProcCmdline(" \0\t\0 ")).toEqual([]); + }); }); describe("isGatewayArgv", () => { @@ -20,6 +25,8 @@ describe("isGatewayArgv", () => { it("matches known entrypoints across slash and case variants", () => { expect(isGatewayArgv(["NODE", "C:\\OpenClaw\\DIST\\ENTRY.JS", "gateway"])).toBe(true); expect(isGatewayArgv(["bun", "/srv/openclaw/scripts/run-node.mjs", "gateway"])).toBe(true); + expect(isGatewayArgv(["node", "/srv/openclaw/openclaw.mjs", "gateway"])).toBe(true); + expect(isGatewayArgv(["tsx", "/srv/openclaw/src/index.ts", "gateway"])).toBe(true); }); it("matches the openclaw executable but gates the gateway binary behind the opt-in flag", () => { @@ -30,5 +37,15 @@ describe("isGatewayArgv", () => { allowGatewayBinary: true, }), ).toBe(true); + expect( + isGatewayArgv(["C:\\bin\\openclaw-gateway.EXE", "gateway"], { + allowGatewayBinary: true, + }), + ).toBe(true); + }); + + it("rejects unknown gateway argv even when the token is present", () => { + expect(isGatewayArgv(["node", "/srv/openclaw/custom.js", "gateway"])).toBe(false); + expect(isGatewayArgv(["python", "gateway", "script.py"])).toBe(false); }); });