mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-24 00:50:44 +00:00
Share opt-in, reversible privacy masking through main-owned policy and conversation maps across Catty, integrated agents, and External MCP. Restore managed arguments before validation, approval, and execution; fail closed on retired policy state. Add shared settings, documentation, boundary and lifecycle regressions. Validated with deterministic regressions, production desktop smoke, clean Codex review and passing cross-platform CI. Closes #3620
47 lines
1.5 KiB
JavaScript
47 lines
1.5 KiB
JavaScript
"use strict";
|
|
|
|
const { runCursorTurnInProcess } = require("./cursorDriver.cjs");
|
|
|
|
const controller = new AbortController();
|
|
const emitter = {};
|
|
for (const method of [
|
|
"text", "reasoning", "reasoningEnd", "toolCall", "toolResult",
|
|
"sessionId", "emitDone", "emitError",
|
|
]) {
|
|
emitter[method] = (...args) => process.parentPort.postMessage({ type: "event", method, args });
|
|
}
|
|
|
|
let started = false;
|
|
let pendingPrompt = null;
|
|
function getPrompt() {
|
|
return new Promise((resolve, reject) => {
|
|
if (controller.signal.aborted) {
|
|
reject(new Error("Cursor turn was interrupted"));
|
|
return;
|
|
}
|
|
pendingPrompt = { resolve, reject };
|
|
process.parentPort.postMessage({ type: "prompt-request" });
|
|
});
|
|
}
|
|
process.parentPort.on("message", ({ data }) => {
|
|
if (data?.type === "abort") {
|
|
controller.abort();
|
|
pendingPrompt?.reject(new Error("Cursor turn was interrupted"));
|
|
pendingPrompt = null;
|
|
}
|
|
if (data?.type === "prompt") {
|
|
pendingPrompt?.resolve({ prompt: data.prompt, attachments: data.attachments });
|
|
pendingPrompt = null;
|
|
}
|
|
if (data?.type === "start" && !started) {
|
|
started = true;
|
|
void runCursorTurnInProcess({
|
|
...data.params, emitter, signal: controller.signal,
|
|
getPrompt: data.params.deferPrompt ? getPrompt : undefined,
|
|
}).then(
|
|
(result) => process.parentPort.postMessage({ type: "result", result }),
|
|
(error) => process.parentPort.postMessage({ type: "error", message: error?.message || String(error) }),
|
|
);
|
|
}
|
|
});
|