feat(openclaw): improve dispatcher and integration

🤖 Generated with assistance of OhMyOpenCode
This commit is contained in:
YeonGyu-Kim
2026-03-31 17:33:45 -07:00
parent 94a2b8ec2c
commit 366ebb33c4
3 changed files with 66 additions and 3 deletions
+41
View File
@@ -3,6 +3,7 @@ import {
interpolateInstruction,
resolveCommandTimeoutMs,
shellEscapeArg,
terminateCommandProcess,
wakeGateway,
wakeCommandGateway,
} from "../dispatcher"
@@ -41,6 +42,10 @@ describe("OpenClaw Dispatcher", () => {
expect(result.success).toBe(true)
expect(fetchSpy).toHaveBeenCalled()
const call = fetchSpy.mock.calls.find(c => c[0] === "https://example.com")
expect(call).toBeDefined()
if (!call) {
throw new Error("Expected fetch call for https://example.com")
}
expect(call[0]).toBe("https://example.com")
expect(call[1]?.method).toBe("POST")
expect(call[1]?.body).toBe('{"foo":"bar"}')
@@ -67,4 +72,40 @@ describe("OpenClaw Dispatcher", () => {
else process.env.OMO_OPENCLAW_COMMAND_TIMEOUT_MS = original
}
})
test("terminateCommandProcess kills process group on unix when pid exists", () => {
const killSpy = spyOn(process, "kill").mockImplementation(() => true)
const proc = {
pid: 4321,
kill: mock(() => {}),
}
try {
terminateCommandProcess(proc, "SIGKILL")
expect(killSpy).toHaveBeenCalledWith(-4321, "SIGKILL")
expect(proc.kill).not.toHaveBeenCalled()
} finally {
killSpy.mockRestore()
}
})
test("terminateCommandProcess falls back to direct kill when process group kill fails", () => {
const killSpy = spyOn(process, "kill").mockImplementation(() => {
throw new Error("group kill failed")
})
const proc = {
pid: 9876,
kill: mock(() => {}),
}
try {
terminateCommandProcess(proc, "SIGKILL")
expect(killSpy).toHaveBeenCalledWith(-9876, "SIGKILL")
expect(proc.kill).toHaveBeenCalledWith("SIGKILL")
} finally {
killSpy.mockRestore()
}
})
})