/** A turn setting a session owns, shown in place of the chat's own selection. */ export interface BoundSetting { value: string | null | undefined; onChange: (value: string) => void; /** The session cannot take a change right now, such as while it is unreachable. */ disabled?: boolean | undefined; } export interface ChatUser { id: string; username: string; name?: string; avatarUrl?: string; /** An agent, such as the session that wrote a subagent's prompt, shows its name without an * avatar, whose initials would read as a person's. Defaults to a person. */ kind?: 'person' | 'agent' | undefined; } export interface AttachmentRef { id: string; filename: string; contentType: string; size: number; uploadedAt: string; /** A small picture an image's thumbnail shows instead of loading the file, such as a * `data:image/...` URL. Only ever an image's source, never a link. */ previewUrl?: string; /** The preview's size in pixels. With both, an image's thumbnail holds its place at the size * it will draw, before a preview that loads from a URL has arrived. */ previewWidth?: number; previewHeight?: number; conversationId?: string; messageId?: string; } export type AttachmentMeta = Record>; export interface FunctionCall { name: string; arguments: string; } export interface ToolCall { function: FunctionCall; id?: string; index?: number; type?: string; } export interface ToolCallDelta { index?: number; id?: string; type?: string; function?: { name?: string; arguments?: string; }; } export interface TokenUsage { prompt_tokens?: number; completion_tokens?: number; total_tokens?: number; } export type ToolCallStatus = 'running' | 'waiting' | 'ok' | 'error'; export interface TextPart { kind: 'text'; text: string; } export interface ReasoningPart { kind: 'reasoning'; text: string; durationMs?: number; } export type ToolDecisionStatus = 'approved' | 'denied' | 'expired' | 'timed_out' | 'failed'; /** How a call that needed an answer was settled. */ export interface ToolDecision { status: ToolDecisionStatus; by: 'user' | 'auto-reviewer'; /** The person who answered, when `by` is a user. */ name?: string; /** ISO time of the answer. */ at?: string; note?: string; /** Why it was settled this way, such as the auto-reviewer's rationale. */ reason?: string; /** The reader changed the call's arguments before allowing it. */ edited?: boolean; /** What was decided on, such as the command, in the decider's words. */ action?: string; } /** How a host names one of its own tool calls in a transcript, in place of * the raw call: words a person reads, with the arguments behind the row. */ export interface ToolPresentation { /** The row's label, such as "Checked costs for misc-dev". */ label: string; /** One line under a finished row, such as "3 resources, $67.50". */ summary?: string; /** A run of this tool's calls folded into one row, such as "Checked costs for 12 allocations". */ group?: (count: number) => string; /** This tool's clause in a row that folds different tools, such as "checked costs for 12 allocations". */ rollup?: (count: number) => string; /** Keeps the host's drawing open under the row, as for a card that asks or shows live progress. Otherwise it opens with the row. */ open?: boolean; } export interface ToolCallPart { kind: 'tool_call'; id: string; name: string; args: string; status: ToolCallStatus; result?: string; startLine?: number; decision?: ToolDecision; /** An edit whose diff repeats what the transcript shows elsewhere, such as a plan; it stays behind the row. */ foldDiff?: boolean; /** A hook changed the arguments the model sent before the call ran. */ argsRewritten?: boolean; /** ISO time a running call last started, which its run's line counts from. A host leaves it out while a person's answer holds the call. */ startedAt?: string; } export type SubagentStatus = 'running' | 'done' | 'failed'; export interface SubagentPart { kind: 'subagent'; id: string; status: SubagentStatus; agentType?: string; color?: string; background?: boolean; description?: string; actions?: string[]; summary?: string; report?: string; /** A stop cut it off rather than it failing on its own. */ interrupted?: boolean; /** Moved to the background after it started, so it outlives the turn that started it. */ detached?: boolean; /** How many of its calls a reviewer is deciding on. */ reviewing?: number; } export interface ApprovalOption { label: string; description?: string; /** Shown as written unless it fences its own code; a multi-select question ignores it. */ preview?: string; } /** One question of an ask; one without options takes typed text alone. */ export interface ApprovalQuestion { question: string; /** A short name for the question, on its tab. */ header?: string; multiSelect?: boolean; options?: ApprovalOption[]; } /** `picked` is in option order; `notes` come only on a single-select question. */ export interface ApprovalQuestionAnswer { picked?: string[]; text?: string; notes?: string; } export type ApprovalAnswerValue = { kind: 'confirm'; allowed: boolean; allowDir?: boolean; denyMessage?: string; /** A sibling tool to run in place of the one asked for, with the same * arguments, such as destroying a cluster the model asked to stop. */ instead?: string; /** The call's arguments as the reader changed them, as JSON text, to * run in place of the model's suggestion. */ args?: string; } | { kind: 'ask'; /** One per question, in order; an empty one leaves its question blank. */ answers: ApprovalQuestionAnswer[]; /** The reader would rather talk the questions through than answer them. */ chat?: boolean; }; export type ApprovalSubject = 'command' | 'code' | 'path' | 'call'; export interface ApprovalPart { kind: 'approval'; id: string; approvalKind: 'confirm' | 'ask' | 'plan'; toolName?: string; subject?: ApprovalSubject; command?: string; reason?: string; agent?: string; mode?: string; header?: string; questions?: ApprovalQuestion[]; toolCallId?: string; plan?: string; canAllowDirectory?: boolean; allowDirectoryLabel?: string; expiresAt?: string; waitingOn?: string; resolved?: boolean; answer?: string; answers?: ApprovalQuestionAnswer[]; chat?: boolean; } export interface NoticePart { kind: 'notice' | 'warning' | 'error'; text: string; detail?: string; /** Shows the detail under the line rather than behind it, as for a command's output. */ open?: boolean; } /** Pictures a tool call returned, such as a screenshot it read. */ export interface ImagePart { kind: 'image'; images: AttachmentRef[]; } export type TodoStatus = 'pending' | 'in_progress' | 'completed'; export interface TodoItem { content: string; status: TodoStatus; activeForm?: string; } export interface TodoSnapshotPart { kind: 'todo_snapshot'; todos: TodoItem[]; } export type MessagePart = TextPart | ReasoningPart | ToolCallPart | SubagentPart | ApprovalPart | NoticePart | TodoSnapshotPart | ImagePart; export type MessagePartKind = MessagePart['kind']; export type PseudoUserKind = 'command-input' | 'shell-input' | 'compaction'; /** A saved paste a user message names by its placeholder. The model got an * inline paste as text; a larger one as its saved file. */ export interface MessagePaste { placeholder: string; id: number; lines: number; bytes: number; inline?: boolean | undefined; text?: string | undefined; } export interface ChatMessage { id: string; role: string; content?: string | null | undefined; parentId?: string | null | undefined; model?: string | null | undefined; providerId?: string | null | undefined; reasoning?: string | undefined; reasoningDuration?: number | undefined; responsesOutput?: unknown[] | null | undefined; stopped?: boolean | undefined; timestamp?: string | undefined; tokensUsed?: TokenUsage | undefined; toolCallId?: string | undefined; toolCalls?: ToolCall[] | null | undefined; attachments?: AttachmentRef[] | null | undefined; author?: ChatUser | undefined; conversationId?: string | undefined; error?: string | null | undefined; retryAt?: string | null | undefined; parts?: MessagePart[] | null | undefined; pseudo?: PseudoUserKind | null | undefined; pastes?: MessagePaste[] | null | undefined; /** What a command the person ran answered, drawn under their message rather than as a reply. */ commandAnswer?: CommandAnswer | undefined; } /** A command's answer: a line, more behind it, and a document it showed. */ export interface CommandAnswer { text: string; /** More behind the line, such as a compaction's summary, opened on request. */ detail?: string; /** A document the command showed, such as a plan, drawn in a box under the line. */ document?: string; } export interface Conversation { id: string; messages: ChatMessage[]; title?: string | null; activeBranchId?: string | null; branches?: string[] | null; canCollaborate?: boolean; createdAt?: string; isOwner?: boolean; updatedAt?: string | null; generating?: GeneratingReply | null; } export interface GeneratingReply { messageId: string; content: string; reasoning: string; } export interface ConversationSummary { id: string; canCollaborate: boolean; createdAt: string; isOwner: boolean; messageCount: number; activeBranchId?: string; preview?: string; title?: string; updatedAt?: string; } export interface ChatModel { id: string; object: string; created: number; owned_by: string; tool_calling_mode: 'native' | 'emulated' | 'none'; name?: string; provider?: string; provider_name?: string; provider_owner?: string; provider_type?: string; context_window?: number; input_rate?: number; output_rate?: number; reasoning_efforts?: string[] | null; supports_responses?: boolean; supports_usage?: boolean; usage_not_supported?: boolean; } export interface UnreachableSession { name: string; owner: string; } export interface ProviderIssue { provider: string; provider_name: string; provider_owner?: string; status: 'unauthorized' | 'unreachable'; message?: string; } export type CspKind = 'openai' | 'anthropic' | 'google' | 'azure' | 'aws' | 'other'; export interface ProviderInfo { id: string; name: string; displayName?: string; user: string; cspKind: CspKind; platformLabel?: string; status: string; group?: string; groupBlocked?: boolean; } export interface Allocation { name: string; total: number; used?: number; description?: string | undefined; disabled?: boolean | undefined; } export interface ChatNavigation { toConversation(id: string): void; toNewChat(): void; } export type SharePermissionLevel = 'view' | 'collaborate'; export interface SharePermission { id?: string; team?: string | null; teamName?: string | null; permission: SharePermissionLevel; entireOrganization: boolean; } export interface ShareGroup { id: string; name: string; } export type ChatLinkTarget = { kind: 'conversation'; id: string; } /** Where `ChatNavigation.toNewChat` goes, for the sidebar's new chat link. */ | { kind: 'newChat'; } | { kind: 'attachments'; } | { kind: 'external'; href: string; };