mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-16 20:11:08 +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
37 lines
1.5 KiB
JavaScript
37 lines
1.5 KiB
JavaScript
"use strict";
|
|
|
|
/** Managed MCP and Skills CLI share their chat's prompt mapping in the main process. */
|
|
function createManagedPrivacyBoundary(dispatch, privacyService) {
|
|
return async (method, params) => {
|
|
const chatSessionId = params?.chatSessionId;
|
|
if (!chatSessionId) {
|
|
if (privacyService.isEnabled()) {
|
|
throw new Error("AI privacy requires a managed chat session.");
|
|
}
|
|
return dispatch(method, params, { beforeExecute: () => {
|
|
if (privacyService.isEnabled()) throw new Error("AI privacy requires a managed chat session.");
|
|
} });
|
|
}
|
|
const enabled = privacyService.checkSession(chatSessionId);
|
|
const restored = enabled ? privacyService.restore(chatSessionId, params) : params;
|
|
let result;
|
|
try {
|
|
result = await dispatch(method, restored, {
|
|
beforeExecute: () => privacyService.checkSession(chatSessionId),
|
|
});
|
|
} catch (error) {
|
|
privacyService.checkSession(chatSessionId);
|
|
if (!enabled) throw error;
|
|
throw new Error(privacyService.redact(chatSessionId, String(error?.message || "Netcatty tool failed.")));
|
|
}
|
|
privacyService.checkSession(chatSessionId);
|
|
if (enabled && method === "netcatty/readAttachment" && typeof result?.text === "string") {
|
|
const { base64Data: _encoded, ...textPayload } = result;
|
|
result = textPayload;
|
|
}
|
|
return enabled ? privacyService.redact(chatSessionId, result) : result;
|
|
};
|
|
}
|
|
|
|
module.exports = { createManagedPrivacyBoundary };
|