Files
orca/src/shared/runtime-mobile-session-tab-contracts.ts
T

148 lines
4.6 KiB
TypeScript

import type { AgentStatusEntry } from './agent-status-types'
import type { BrowserCertificateFailure, BrowserLoadError } from './browser-workspace-types'
import type { RuntimeBrowserPlacement } from './runtime-browser-placement'
import type { TerminalColorOverrides } from './terminal-color-overrides'
import type { TerminalLayoutSnapshot, TerminalTab } from './terminal-tab-types'
import type { TuiAgent } from './tui-agent'
import type { StructuredAgentId } from './agent-session-provider-handle'
export type RuntimeMobileSessionTerminalTab = {
type: 'terminal'
id: string
title: string
/** The tab's manual name on the host, null when it has none. Absent from older hosts, so a
* client keeps its own record then rather than reading absence as a cleared name. */
customTitle?: string | null
quickCommandLabel?: string | null
/** Window-to-main only: the names the desktop ranks above the live title. `generatedTitle` is
* sent only while the desktop shows generated names. */
aiVaultTitle?: TerminalTab['aiVaultTitle']
generatedTitle?: string | null
parentTabId: string
leafId: string
ptyId?: string | null
/** Host-owned PTY incarnation used to fence remote identity observations. */
incarnationId?: string | null
terminalTheme?: RuntimeMobileTerminalTheme
agentStatus?: AgentStatusEntry | null
/** Event-only lead-turn end time for paired clients; never persisted in AgentStatusEntry. */
turnCompletedAt?: number
launchAgent?: TuiAgent
startupCwd?: string
parentLayout?: TerminalLayoutSnapshot
color?: string | null
isPinned?: boolean
viewMode?: 'terminal' | 'chat'
launchDraft?: string
launchDraftCreatedAt?: number
isActive: boolean
}
export type RuntimeMobileTerminalTheme = {
mode: 'dark' | 'light'
theme: TerminalColorOverrides
/** Optional desktop terminalMinimumContrastRatio override (#10754). Absent means the client picks
* its own background-luminance floor, which is what pre-#10754 clients always do. */
minimumContrastRatio?: number
}
export type RuntimeMobileSessionMarkdownTab = {
type: 'markdown'
id: string
title: string
filePath: string
relativePath: string
language: 'markdown'
mode: 'edit' | 'markdown-preview'
isDirty: boolean
isActive: boolean
sourceFileId: string
sourceFilePath: string
sourceRelativePath: string
/** Set by a desktop for a "New Markdown" document not yet named; hosts and phones before it omit it. */
isUntitled?: true
documentVersion: string
color?: string | null
isPinned?: boolean
}
export type RuntimeMobileSessionFileTab = {
type: 'file'
id: string
title: string
filePath: string
relativePath: string
language: string
mode?: 'edit' | 'diff'
diffSource?: 'staged' | 'unstaged'
isDirty: boolean
color?: string | null
isPinned?: boolean
isActive: boolean
}
export type RuntimeMobileSessionBrowserTab = {
type: 'browser'
id: string
title: string
browserWorkspaceId: string
browserPageId: string | null
browserProfileId?: string
executionHostKey?: string
placement?: RuntimeBrowserPlacement
url: string
loading: boolean
canGoBack: boolean
canGoForward: boolean
loadError?: BrowserLoadError | null
certificateFailure?: BrowserCertificateFailure | null
color?: string | null
isPinned?: boolean
isActive: boolean
}
export type RuntimeMobileSessionAgentTab = {
type: 'agent-session'
id: string
title: string
sessionId: string
replacesSessionId?: string
/** An agent the host registered. Beyond Claude and Codex, published only to clients advertising
* the registered-agents capability. */
agent: StructuredAgentId
/** The host's structured status row for this chat. Optional: old hosts never send it. */
chatStatus?: RuntimeMobileSessionAgentTabStatus
color?: string | null
isPinned?: boolean
isActive: boolean
}
export type RuntimeMobileSessionAgentTabStatus = Pick<
AgentStatusEntry,
| 'state'
| 'workingMode'
| 'interrupted'
| 'mainAgent'
| 'updatedAt'
| 'evidenceObservedAt'
| 'structuredHostOwned'
>
export type RuntimeMobileSessionSnapshotTab =
| RuntimeMobileSessionTerminalTab
| RuntimeMobileSessionMarkdownTab
| RuntimeMobileSessionFileTab
| RuntimeMobileSessionBrowserTab
| RuntimeMobileSessionAgentTab
export type RuntimeMobileSessionTerminalClientTab =
| (RuntimeMobileSessionTerminalTab & { status: 'pending-handle'; terminal: null })
| (RuntimeMobileSessionTerminalTab & { status: 'ready'; terminal: string })
export type RuntimeMobileSessionClientTab =
| RuntimeMobileSessionTerminalClientTab
| RuntimeMobileSessionMarkdownTab
| RuntimeMobileSessionFileTab
| RuntimeMobileSessionBrowserTab
| RuntimeMobileSessionAgentTab