MCPcopy Create free account
hub / github.com/CreminiAI/skillpack / withCapturedIpc

Function withCapturedIpc

tests/ipc-adapter.test.ts:9–33  ·  view source on GitHub ↗
(
  run: (sent: unknown[]) => Promise<void> | void,
)

Source from the content-addressed store, hash-verified

7import { IpcAdapter } from "../src/runtime/adapters/ipc.js";
8
9async function withCapturedIpc(
10 run: (sent: unknown[]) => Promise<void> | void,
11): Promise<void> {
12 const processWithSend = process as NodeJS.Process & {
13 send?: (message: unknown) => boolean;
14 };
15 const hadSend = Object.prototype.hasOwnProperty.call(processWithSend, "send");
16 const originalSend = processWithSend.send;
17 const sent: unknown[] = [];
18
19 processWithSend.send = (message: unknown) => {
20 sent.push(message);
21 return true;
22 };
23
24 try {
25 await run(sent);
26 } finally {
27 if (hadSend) {
28 processWithSend.send = originalSend;
29 } else {
30 delete processWithSend.send;
31 }
32 }
33}
34
35test("ipc send_message handles slash commands before prompting the agent", async () => {
36 await withCapturedIpc(async (sent) => {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected