repositories / pi-ext
pi-ext
bugabingas pi extensions
owned by bugabinga
extensions/ui/command-adapter.ts
RawFile outline
import type { RpcClient, RpcResponse } from "./rpc";
export type RpcSender = Pick<RpcClient, "send">;
export function sendPrompt(rpc: RpcSender, text: string): Promise<RpcResponse> {
return rpc.send({ type: "prompt", message: text });
}
export function runSlashCommand(
rpc: RpcSender,
command: string,
args = "",
): Promise<RpcResponse> {
const suffix = args.trim() ? ` ${args.trim()}` : "";
return sendPrompt(rpc, `/${command}${suffix}`);
}
export function runBash(
rpc: RpcSender,
command: string,
excludeFromContext: boolean,
): Promise<RpcResponse> {
return rpc.send({ type: "bash", command, excludeFromContext });
}
export function cycleModel(rpc: RpcSender): Promise<RpcResponse> {
return rpc.send({ type: "cycle_model" });
}
export function cycleThinking(rpc: RpcSender): Promise<RpcResponse> {
return rpc.send({ type: "cycle_thinking_level" });
}
export function compactSession(rpc: RpcSender): Promise<RpcResponse> {
return rpc.send({ type: "compact" });
}
export function abortCurrent(rpc: RpcSender): Promise<RpcResponse> {
return rpc.send({ type: "abort" });
}