feat(rpc): add validated desktop Pi RPC command palette

This commit is contained in:
2026-08-24 20:16:51 +02:00
parent 475f95ba70
commit 99084cc5a5
25 changed files with 2170 additions and 344 deletions
+13
View File
@@ -1,4 +1,5 @@
import path from "node:path";
import { validatePiRpcCommand } from "../bridge/pi-rpc-command-spec.js";
export const PROTOCOL_VERSION = "v1";
export const MAX_FRAME_BYTES = 64 * 1024;
@@ -37,6 +38,7 @@ const requestOperations = new Map([
["compact", { agent: true, payload: "compact" }],
["set_model", { agent: true, payload: "model" }],
["set_thinking_level", { agent: true, payload: "thinking" }],
["pi_rpc_command", { agent: true, payload: "piRpcCommand" }],
]);
const eventTypes = new Set([
@@ -275,6 +277,17 @@ function validatePayload(kind, value) {
);
return { level };
}
case "piRpcCommand": {
assertAllowedKeys(payload, new Set(["command", "input"]), "payload");
const command = assertString(payload.command, "payload.command", {
maxLength: 64,
});
try {
return { command, input: validatePiRpcCommand(command, payload.input) };
} catch (error) {
throw new ProtocolError("invalid_message", error.message);
}
}
default:
throw new ProtocolError("invalid_message", "unsupported payload shape");
}