// Frontend-visible types. Kept minimal — we avoid importing the SDK in the // browser bundle and instead rely on `unknown`-shaped messages that the UI // renders defensively. import type { SessionInfoBase } from '../shared/session-info' import type { SupportedImageMediaType } from '../shared/image-media' import type { ImageAttachmentRef } from '../shared/image-attachment' import type { SessionHooksConfig } from '../shared/hooks' import { PERMISSION_PRESETS, type SdkAgentPermissionMode, } from '../shared/permission-modes' /** Permission modes this host accepts. Derived from the shared list (which * is locked to the SDK at compile time) so the client union cannot drift. */ export type PermissionMode = SdkAgentPermissionMode // User-selectable permission modes (dropdowns/chip menus) — the three presets. export const PERMISSION_MODES: readonly PermissionMode[] = PERMISSION_PRESETS.map((p) => p.mode) // Keyboard cycle follows the same risk order as the picker: Ask → Auto → Bypass. export const PERMISSION_MODE_CYCLE: PermissionMode[] = [ 'default', 'auto', 'bypassPermissions', ] /** Reasoning effort level — controls how many tokens the model spends. * The SDK default is 'high' (equivalent to omitting the parameter). * Defined in shared/model-info.ts so both server and client use the same * type; re-exported here for backward-compatible client imports. */ export type { EffortLevel } from '../shared/model-info' export type { ThinkingDisplay, ThinkingSetting } from '../shared/session-info' import type { EffortLevel } from '../shared/model-info' /** User-selectable effort levels, ordered low→max. Shown in the effort * chip dropdown. All five are always offered: unsupported levels for the * current model are silently downgraded by the SDK, so there's no harm in * listing them (and no per-model gating needed). */ export const EFFORT_LEVELS: EffortLevel[] = ['low', 'medium', 'high', 'xhigh', 'max'] /** SDK default effort when none is explicitly set. */ export const DEFAULT_EFFORT_LEVEL: EffortLevel = 'high' /** Field shape is defined once in shared/session-info.ts and instantiated * here with the client's PermissionMode union. Server uses the SDK's * PermissionMode; both project to the same JSON. */ export type SessionInfo = SessionInfoBase // Re-export the per-session skill override union from shared so the UI // can construct override values without importing into the same module // where SessionInfo lives. The shape is identical on both ends. export type { SessionSkillOverride, SkillLoadMode } from '../shared/skills' /** A session discoverable on disk via the /resume picker. Mirrors the * server's ResumableSession (server/session-types.ts) — manual mirror, * no automated drift check (same convention as ws-types). Spans both * sessions this app tracks (`known`) and CLI-created ones it doesn't. */ export interface ResumableSession { provider?: string sessionId: string title?: string firstPrompt?: string /** Last user prompt — server tail-reads it from the transcript, condensed * to 120 chars. Display-only preview in the /resume picker. */ lastPrompt?: string cwd?: string createdAt?: number lastModified: number gitBranch?: string known: boolean running: boolean terminated: boolean /** True when terminated but only with a transient reason (crash / query * error) — the server still allows a manual resume. Mirrors * SessionInfo.canRetryResume so the /resume picker can offer retry. */ canRetryResume?: boolean } /** A name collection of sessions for quick group switching. Each session * belongs to at most one group (exclusive membership). Sessions not in any * group are "ungrouped" and appear in a separate sidebar section. Each * group holds at most `maxOpen` sessions. Order of sessionIds determines * activation priority (first MAX_OPEN are opened). */ export interface SessionGroup { id: string name: string sessionIds: string[] /** Remembered column ratios when the group was last active. */ panelRatios?: Record } /** Discriminated union for sidebar section rendering. */ export type SidebarSection = | { kind: 'group'; group: SessionGroup; sessions: SessionInfo[] } | { kind: 'ungrouped'; sessions: SessionInfo[] } /** Shape of Options we expose in the "new session" form. */ export interface NewSessionForm { /** Carried by New-like-this / Restart to preserve the source session's * provider. The create dialog omits it — native is the only provider, so * the server's effective default governs. */ provider?: string cwd?: string model?: string /** Name of a custom agent definition to start this session as. Omitted * when no agent is selected ("None"). Injected as `Options.agent`. */ agent?: string systemPrompt?: string permissionMode?: PermissionMode maxTurns?: number allowedTools?: string[] disallowedTools?: string[] title?: string /** Anthropic beta flags forwarded verbatim to the SDK. Use this to opt * into extended windows such as the 1M context beta for Sonnet 4/4.5. */ betas?: string[] // Advanced options additionalDirectories?: string[] fallbackModel?: string maxBudgetUsd?: number thinking?: 'adaptive' | 'enabled' | 'disabled' | { type: 'enabled'; budgetTokens: number } /** API-side task budget in tokens (SDK Options.taskBudget). Spawn-time * only — the model is made aware of its remaining budget so it can pace * tool use and wrap up before the limit. */ taskBudget?: { total: number } effort?: 'low' | 'medium' | 'high' | 'xhigh' | 'max' tools?: string[] /** Names of global MCP servers to enable for this session. */ enabledMcpServers?: string[] /** Per-first-party-server overrides chosen at create time. Only servers * diverging from the global default are included (absent = inherit). */ firstPartyTools?: Record /** Compound keys of globally-enabled plugins to carry into this session. * Omitted when all enabled plugins are selected (default); `[]` when none. */ enabledPlugins?: string[] /** Opt-in: run this session in its own git worktree (server provisions * /worktrees/ off the repo HEAD). */ isolateWorktree?: boolean /** Auto-compact policy window (absolute tokens) applied at spawn via * `Options.settings.autoCompactWindow`. Omitted = auto (the model-tuned * window). Native clamps it under the model window and derives its * compaction trigger from that effective window (ratio policy). */ settings?: { autoCompactWindow?: number } // Advanced (JSON blobs — rendered as