Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

2.3 KB
Raw Blame
/** Recognized Desktop events. Deferred names remain accepted for compatibility. */
export const TRUSTED_EXTENSION_EVENTS = [
  "session_start",
  "session_shutdown",
  "session_info_changed",
  "project_trust",
  "resources_discover",
  "before_agent_start",
  "context",
  "before_provider_request",
  "before_provider_headers",
  "after_provider_response",
  "agent_start",
  "agent_end",
  "agent_settled",
  "turn_start",
  "turn_end",
  "message_start",
  "message_update",
  "message_end",
  "tool_call",
  "tool_execution_start",
  "tool_execution_update",
  "tool_execution_end",
  "tool_result",
  "model_select",
  "thinking_level_select",
  "session_before_compact",
  "session_compact",
  "session_compact_failed",
  "session_before_fork",
  "input",
] as const;

export type TrustedExtensionEventName = (typeof TRUSTED_EXTENSION_EVENTS)[number];


/** Result means the Desktop caller consumes the returned value; mutation edits the payload. */
export const TRUSTED_EXTENSION_EVENT_CAPABILITIES = {
  session_start: "notification",
  session_shutdown: "notification",
  session_info_changed: "notification",
  project_trust: "deferred",
  resources_discover: "deferred",
  before_agent_start: "result",
  context: "result",
  before_provider_request: "result",
  before_provider_headers: "mutation",
  after_provider_response: "notification",
  agent_start: "notification",
  agent_end: "notification",
  agent_settled: "notification",
  turn_start: "notification",
  turn_end: "notification",
  message_start: "notification",
  message_update: "notification",
  message_end: "notification",
  tool_call: "result",
  tool_execution_start: "notification",
  tool_execution_update: "notification",
  tool_execution_end: "notification",
  tool_result: "result",
  model_select: "deferred",
  thinking_level_select: "deferred",
  session_before_compact: "result",
  session_compact: "notification",
  session_compact_failed: "notification",
  session_before_fork: "deferred",
  input: "deferred",
  user_bash: "deferred",
  session_before_switch: "deferred",
  session_before_tree: "deferred",
  session_tree: "deferred",
  ui_prompt_start: "deferred",
  ui_prompt_end: "deferred",
} as const;

export function isKnownExtensionEvent(event: string): event is keyof typeof TRUSTED_EXTENSION_EVENT_CAPABILITIES {
  return Object.hasOwn(TRUSTED_EXTENSION_EVENT_CAPABILITIES, event);
}