Skip to content

OpenReel Video - Professional browser-based video editor. Open source CapCut alternative. 100% browser-based, no installation, no cloud uploads, no watermarks.

TypeScript
2.0 KB
Raw Blame
export type JSONSchema = Record<string, unknown>;

export type ToolDomain =
  | "read"
  | "project"
  | "media"
  | "track"
  | "clip"
  | "transform"
  | "effect"
  | "color"
  | "speed"
  | "audio"
  | "text"
  | "subtitle"
  | "graphics"
  | "motion"
  | "transition"
  | "keyframe"
  | "marker"
  | "ai"
  | "export"
  | "multicam"
  | "raw";

export interface ToolDef {
  readonly name: string;
  readonly domain: ToolDomain;
  readonly title: string;
  readonly description: string;
  readonly inputSchema: JSONSchema;
  readonly readOnly: boolean;
  readonly destructive: boolean;
  readonly expensive: boolean;
}

export interface ToolCall {
  readonly id: string;
  readonly name: string;
  readonly args: Record<string, unknown>;
}

export interface ToolError {
  readonly code: string;
  readonly message: string;
  /** What to do next, e.g. "call create_project first". Set by the path / app-state / export tools. */
  readonly hint?: string;
  /** A rejected preflight that did not mutate the draft and may be corrected. */
  readonly recoverable?: boolean;
  /** The failed tool call to reference explicitly in a corrected retry. */
  readonly retryOf?: string;
}

export interface ToolResultImage {
  readonly dataUrl: string;
  readonly mimeType?: string;
}

export interface ToolResult {
  readonly ok: boolean;
  /** Short, model- and human-readable summary of the outcome. */
  readonly summary: string;
  readonly data?: unknown;
  readonly error?: ToolError;
  /** Rendered image the model can SEE (e.g. render_motion_frame). */
  readonly image?: ToolResultImage;
}

export type AgentEvent =
  | { type: "text_delta"; text: string }
  | { type: "tool_call"; call: ToolCall }
  | { type: "tool_result"; call: ToolCall; result: ToolResult }
  | { type: "tool_recovered"; callIds: string[]; repairedBy: string }
  | { type: "awaiting_confirmation"; call: ToolCall }
  | { type: "error"; error: ToolError }
  | { type: "turn_complete"; text: string };

export type ConfirmDecision = "approve" | "reject" | "approve_for_turn";