37 lines · 1.0 KB · JavaScript
RawDownload
#!/usr/bin/env node // Reads the start message with raw fd reads instead of a stdin stream: only// an unwatched fd can be closed here, since libuv aborts the process when// fd 0 is closed while a stream watcher is attached, and a stream destroy()// never closes the underlying stdio fd, so the host's writes would keep// succeeding instead of failing with EPIPE. import { closeSync, readSync } from "node:fs"; let buffered = "";const chunk = Buffer.alloc(4096);while (!buffered.includes("\n")) {  try {    const bytesRead = readSync(0, chunk, 0, chunk.length);    if (bytesRead <= 0) break;    buffered += chunk.toString("utf8", 0, bytesRead);  } catch (error) {    if (error.code === "EAGAIN") continue;    throw error;  }} const { nonce } = JSON.parse(buffered.slice(0, buffered.indexOf("\n"))); closeSync(0);process.stdout.write(  `@@executor-ipc@@${JSON.stringify({    type: "tool_call",    nonce,    requestId: "request-1",    toolPath: "test.call",    args: {},  })}\n`,); setTimeout(() => process.exit(0), 5_000);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t