repositories / pi-ext
pi-ext
bugabingas pi extensions
owned by bugabinga
extensions/ui/protocol.ts
RawFile outline
export type UiConnectionStatus =
| "starting"
| "waiting"
| "connected"
| "rpc-starting"
| "rpc-connected"
| "rpc-dead"
| "error"
| "stopped";
export type UiEventBase = {
id: number;
at: number;
};
export type UiStateEvent = UiEventBase & {
type: "state";
state: UiConnectionStatus;
message?: string;
};
export type UiLogEvent = UiEventBase & {
type: "log";
level: "info" | "warning" | "error";
message: string;
};
export type UiMessageEvent = UiEventBase & {
type: "message";
role: "user" | "assistant" | "tool" | "system";
text: string;
};
export type UiToolEvent = UiEventBase & {
type: "tool";
phase: "start" | "update" | "end";
toolCallId: string;
name: string;
text?: string;
isError?: boolean;
};
export type UiErrorEvent = UiEventBase & {
type: "error";
message: string;
action: string;
retryable: boolean;
};
export type UiEvent =
| UiStateEvent
| UiLogEvent
| UiMessageEvent
| UiToolEvent
| UiErrorEvent;
export type UiEventInput = Omit<UiEvent, keyof UiEventBase>;
export type UiCommandInfo = {
name: string;
description?: string;
};
export type UiSnapshot = {
version: 1;
lastEventId: number;
status: UiConnectionStatus;
sessionPath?: string;
commands: UiCommandInfo[];
events: UiEvent[];
};