Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.
TypeScript adeagent-ideai-agentsautomationbotclaude-codecodexghosttygrok-bothermes-agentmobile-appmuseopenclawopencodeorchestrationpiruntimeterminalworktreesyc-backed
import type {
RuntimeEditorTabReveal,
RuntimeFileOpenPosition
} from '../../shared/runtime-file-contracts'
import { ipcRenderer } from 'electron'
import type { TerminalPaneSplitSource } from '../../shared/feature-education-telemetry'
import type { TerminalTabCreateReply } from '../../shared/terminal-reveal-identity'
import type {
AgentLaunchTabPublishReply,
AgentLaunchTabViewerRule,
AgentLaunchTabPublishRequest
} from '../../shared/agent-launch-tab-publication'
import type { AgentLaunchPaneVerdictEvent } from '../../shared/agent-launch-pane-verdict'
import type { PaneLaunchRecipe } from '../../shared/terminal-attachment-launch-result'
import type {
TerminalPaneRevealReply,
TerminalPaneRevealRequest
} from '../../shared/terminal-pane-reveal'
import type {
AgentProviderSessionMetadata,
SleepingAgentLaunchConfig
} from '../../shared/agent-session-resume'
import type { TuiAgent } from '../../shared/tui-agent'
import type { RuntimeNavigationTarget } from '../../shared/runtime-navigation'
import type {
RuntimeMobileSessionTabMove,
RuntimeTerminalCreateRequestPayload,
RuntimeTerminalPresentation
} from '../../shared/runtime-types'
import type { PreloadApi } from '../api-types'
export const uiTerminalAndSessionTabsApi = {
onCreateTerminal: (
callback: (data: {
requestId?: string
worktreeId: string
command?: string
cwd?: string
env?: Record<string, string>
launchConfig?: SleepingAgentLaunchConfig
resumeProviderSession?: AgentProviderSessionMetadata
launchToken?: string
launchAgent?: TuiAgent
viewMode?: 'terminal' | 'chat'
targetGroupId?: string
afterTabId?: string
shellOverride?: string
title?: string
ptyId?: string
activate?: boolean
focus?: boolean
presentation?: RuntimeTerminalPresentation
surfaceOwner?: false
agentLaunchViewer?: AgentLaunchTabViewerRule
tabId?: string
leafId?: string
splitFromLeafId?: string
splitDirection?: 'horizontal' | 'vertical'
splitTelemetrySource?: TerminalPaneSplitSource
}) => void
): (() => void) => {
const listener = (
_event: Electron.IpcRendererEvent,
data: {
requestId?: string
worktreeId: string
command?: string
cwd?: string
env?: Record<string, string>
launchConfig?: SleepingAgentLaunchConfig
resumeProviderSession?: AgentProviderSessionMetadata
launchToken?: string
launchAgent?: TuiAgent
viewMode?: 'terminal' | 'chat'
targetGroupId?: string
afterTabId?: string
shellOverride?: string
title?: string
ptyId?: string
activate?: boolean
focus?: boolean
presentation?: RuntimeTerminalPresentation
surfaceOwner?: false
agentLaunchViewer?: AgentLaunchTabViewerRule
tabId?: string
leafId?: string
splitFromLeafId?: string
splitDirection?: 'horizontal' | 'vertical'
splitTelemetrySource?: TerminalPaneSplitSource
}
) => callback(data)
ipcRenderer.on('ui:createTerminal', listener)
return () => ipcRenderer.removeListener('ui:createTerminal', listener)
},
onRequestTerminalCreate: (
callback: (data: RuntimeTerminalCreateRequestPayload) => void
): (() => void) => {
const listener = (
_event: Electron.IpcRendererEvent,
data: RuntimeTerminalCreateRequestPayload
) => callback(data)
ipcRenderer.on('terminal:requestTabCreate', listener)
return () => ipcRenderer.removeListener('terminal:requestTabCreate', listener)
},
onRequestTerminalTabMount: (
callback: (data: { worktreeId: string; tabId?: string; ptyId?: string }) => void
): (() => void) => {
const listener = (
_event: Electron.IpcRendererEvent,
data: { worktreeId: string; tabId?: string; ptyId?: string }
) => callback(data)
ipcRenderer.on('terminal:requestTabMount', listener)
return () => ipcRenderer.removeListener('terminal:requestTabMount', listener)
},
replyTerminalCreate: (reply: TerminalTabCreateReply): void => {
ipcRenderer.send('terminal:tabCreateReply', reply)
},
onPublishAgentLaunchTab: (
callback: (data: AgentLaunchTabPublishRequest) => void
): (() => void) => {
const listener = (_event: Electron.IpcRendererEvent, data: AgentLaunchTabPublishRequest) =>
callback(data)
ipcRenderer.on('ui:publishAgentLaunchTab', listener)
return () => ipcRenderer.removeListener('ui:publishAgentLaunchTab', listener)
},
replyAgentLaunchTabPublish: (reply: AgentLaunchTabPublishReply): void => {
ipcRenderer.send('agentLaunch:tabPublishReply', reply)
},
onRevealTerminalPane: (callback: (data: TerminalPaneRevealRequest) => void): (() => void) => {
const listener = (_event: Electron.IpcRendererEvent, data: TerminalPaneRevealRequest) =>
callback(data)
ipcRenderer.on('ui:revealTerminalPane', listener)
return () => ipcRenderer.removeListener('ui:revealTerminalPane', listener)
},
replyTerminalPaneReveal: (reply: TerminalPaneRevealReply): void => {
ipcRenderer.send('ui:terminalPaneRevealReply', reply)
},
onAgentLaunchPaneVerdict: (
callback: (data: AgentLaunchPaneVerdictEvent) => void
): (() => void) => {
const listener = (_event: Electron.IpcRendererEvent, data: AgentLaunchPaneVerdictEvent) =>
callback(data)
ipcRenderer.on('ui:agentLaunchPaneVerdict', listener)
return () => ipcRenderer.removeListener('ui:agentLaunchPaneVerdict', listener)
},
onLaunchRecipe: (callback: (data: PaneLaunchRecipe) => void): (() => void) => {
const listener = (_event: Electron.IpcRendererEvent, data: PaneLaunchRecipe) => callback(data)
ipcRenderer.on('ui:launchRecipe', listener)
return () => ipcRenderer.removeListener('ui:launchRecipe', listener)
},
onSplitTerminal: (
callback: (data: {
tabId: string
paneRuntimeId: number
direction: 'horizontal' | 'vertical'
command?: string
worktreeId?: string
sourceLeafId?: string
telemetrySource?: TerminalPaneSplitSource
newLeafId?: string
}) => void
): (() => void) => {
const listener = (
_event: Electron.IpcRendererEvent,
data: {
tabId: string
paneRuntimeId: number
direction: 'horizontal' | 'vertical'
command?: string
worktreeId?: string
sourceLeafId?: string
telemetrySource?: TerminalPaneSplitSource
newLeafId?: string
}
) => callback(data)
ipcRenderer.on('ui:splitTerminal', listener)
return () => ipcRenderer.removeListener('ui:splitTerminal', listener)
},
onRenameTerminal: (
callback: (data: { tabId: string; title: string | null; recordInteraction?: false }) => void
): (() => void) => {
const listener = (
_event: Electron.IpcRendererEvent,
data: { tabId: string; title: string | null; recordInteraction?: false }
) => callback(data)
ipcRenderer.on('ui:renameTerminal', listener)
return () => ipcRenderer.removeListener('ui:renameTerminal', listener)
},
onSetPaneTitle: (
callback: (data: { tabId: string; leafId: string; title: string | null }) => void
): (() => void) => {
const listener = (
_event: Electron.IpcRendererEvent,
data: { tabId: string; leafId: string; title: string | null }
) => callback(data)
ipcRenderer.on('ui:setPaneTitle', listener)
return () => ipcRenderer.removeListener('ui:setPaneTitle', listener)
},
onFocusTerminal: (
callback: (data: {
tabId: string
worktreeId: string
leafId?: string | null
ackPaneKeyOnSuccess?: string
flashFocusedPane?: boolean
scrollToBottomIfOutputSinceLastView?: boolean
}) => void
): (() => void) => {
const listener = (
_event: Electron.IpcRendererEvent,
data: {
tabId: string
worktreeId: string
leafId?: string | null
ackPaneKeyOnSuccess?: string
flashFocusedPane?: boolean
scrollToBottomIfOutputSinceLastView?: boolean
}
) => callback(data)
ipcRenderer.on('ui:focusTerminal', listener)
return () => ipcRenderer.removeListener('ui:focusTerminal', listener)
},
onFocusEditorTab: (
callback: (data: { tabId: string; worktreeId: string; userInitiated?: boolean }) => void
): (() => void) => {
const listener = (
_event: Electron.IpcRendererEvent,
data: { tabId: string; worktreeId: string; userInitiated?: boolean }
) => callback(data)
ipcRenderer.on('ui:focusEditorTab', listener)
return () => ipcRenderer.removeListener('ui:focusEditorTab', listener)
},
onCloseSessionTab: (
callback: (data: { tabId: string; worktreeId: string }) => void
): (() => void) => {
const listener = (
_event: Electron.IpcRendererEvent,
data: { tabId: string; worktreeId: string }
) => callback(data)
ipcRenderer.on('ui:closeSessionTab', listener)
return () => ipcRenderer.removeListener('ui:closeSessionTab', listener)
},
onSessionTabCloseRequest: (callback) => {
const listener = (_event: Electron.IpcRendererEvent, request: Parameters<typeof callback>[0]) =>
callback(request)
ipcRenderer.on('ui:sessionTabCloseRequest', listener)
return () => ipcRenderer.removeListener('ui:sessionTabCloseRequest', listener)
},
respondSessionTabClose: (response) => {
ipcRenderer.send('ui:sessionTabCloseResponse', response)
},
onMoveSessionTab: (
callback: (data: { worktreeId: string } & RuntimeMobileSessionTabMove) => void
): (() => void) => {
const listener = (
_event: Electron.IpcRendererEvent,
data: { worktreeId: string } & RuntimeMobileSessionTabMove
) => callback(data)
ipcRenderer.on('ui:moveSessionTab', listener)
return () => ipcRenderer.removeListener('ui:moveSessionTab', listener)
},
onOpenFileFromMobile: (
callback: (data: {
worktreeId: string
filePath: string
relativePath: string
runtimeEnvironmentId?: string | null
navigation?: RuntimeNavigationTarget
position?: RuntimeFileOpenPosition
}) => void
): (() => void) => {
const listener = (
_event: Electron.IpcRendererEvent,
data: {
worktreeId: string
filePath: string
relativePath: string
runtimeEnvironmentId?: string | null
navigation?: RuntimeNavigationTarget
position?: RuntimeFileOpenPosition
}
) => callback(data)
ipcRenderer.on('ui:openFileFromMobile', listener)
return () => ipcRenderer.removeListener('ui:openFileFromMobile', listener)
},
onRevealEditorTabFromRuntime: (
callback: (data: RuntimeEditorTabReveal) => void
): (() => void) => {
const listener = (_event: Electron.IpcRendererEvent, data: RuntimeEditorTabReveal) =>
callback(data)
ipcRenderer.on('ui:revealEditorTabFromRuntime', listener)
return () => ipcRenderer.removeListener('ui:revealEditorTabFromRuntime', listener)
}
} satisfies Partial<PreloadApi['ui']>