feat(rpc): add validated desktop Pi RPC command palette
This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user