mirror of
https://github.com/stablyai/orca.git
synced 2026-11-04 02:57:36 +00:00
* chore: audit preload root comments and track repository coverage * docs: track repository comment audit coverage * chore: keep comment audit tracker local * chore: shorten preload API contract comments --------- Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
95 lines
4.2 KiB
TypeScript
95 lines
4.2 KiB
TypeScript
import { ipcRenderer } from 'electron'
|
|
import type {
|
|
AgentStatusCacheIdentity,
|
|
AgentStatusClearIpcPayload,
|
|
AgentStatusIpcPayload,
|
|
MigrationUnsupportedPtyEntry
|
|
} from '../../shared/agent-status-types'
|
|
import type { AgentInterruptInferenceRequest } from '../../shared/agent-interrupt-intent'
|
|
import type { AgentQuestionAnsweredInferenceRequest } from '../../shared/agent-question-answered-intent'
|
|
import type { PreloadApi } from '../api-types'
|
|
|
|
export const agentStatusApi = {
|
|
onSet: (callback: (data: AgentStatusIpcPayload) => void): (() => void) => {
|
|
const listener = (_event: Electron.IpcRendererEvent, data: AgentStatusIpcPayload) =>
|
|
callback(data)
|
|
ipcRenderer.on('agentStatus:set', listener)
|
|
return () => ipcRenderer.removeListener('agentStatus:set', listener)
|
|
},
|
|
onClear: (callback: (data: AgentStatusClearIpcPayload) => void): (() => void) => {
|
|
const listener = (_event: Electron.IpcRendererEvent, data: AgentStatusClearIpcPayload) =>
|
|
callback(data)
|
|
ipcRenderer.on('agentStatus:clear', listener)
|
|
return () => ipcRenderer.removeListener('agentStatus:clear', listener)
|
|
},
|
|
getSnapshot: (): Promise<AgentStatusIpcPayload[]> =>
|
|
ipcRenderer.invoke('agentStatus:getSnapshot'),
|
|
inferInterrupt: (request: AgentInterruptInferenceRequest): Promise<boolean> =>
|
|
ipcRenderer.invoke('agentStatus:inferInterrupt', request),
|
|
hasVerifiableAgentProcess: (paneKey: string): Promise<boolean> =>
|
|
ipcRenderer.invoke('agentStatus:hasVerifiableAgentProcess', paneKey),
|
|
inferQuestionAnswered: (request: AgentQuestionAnsweredInferenceRequest): Promise<boolean> =>
|
|
ipcRenderer.invoke('agentStatus:inferQuestionAnswered', request),
|
|
onMigrationUnsupported: (
|
|
callback: (entry: MigrationUnsupportedPtyEntry) => void
|
|
): (() => void) => {
|
|
const listener = (_event: Electron.IpcRendererEvent, entry: MigrationUnsupportedPtyEntry) =>
|
|
callback(entry)
|
|
ipcRenderer.on('agentStatus:migrationUnsupported', listener)
|
|
return () => ipcRenderer.removeListener('agentStatus:migrationUnsupported', listener)
|
|
},
|
|
onMigrationUnsupportedClear: (callback: (data: { ptyId: string }) => void): (() => void) => {
|
|
const listener = (_event: Electron.IpcRendererEvent, data: { ptyId: string }) => callback(data)
|
|
ipcRenderer.on('agentStatus:migrationUnsupportedClear', listener)
|
|
return () => ipcRenderer.removeListener('agentStatus:migrationUnsupportedClear', listener)
|
|
},
|
|
onLegacyWorkerTerminalRecovery: (
|
|
callback: (data: {
|
|
paneKey: string
|
|
resolution: 'adopted' | 'exited' | 'rolled_back'
|
|
ptyId?: string
|
|
}) => void
|
|
): (() => void) => {
|
|
const listener = (
|
|
_event: Electron.IpcRendererEvent,
|
|
data: {
|
|
paneKey: string
|
|
resolution: 'adopted' | 'exited' | 'rolled_back'
|
|
ptyId?: string
|
|
}
|
|
) => callback(data)
|
|
ipcRenderer.on('agentStatus:legacyWorkerTerminalRecovery', listener)
|
|
return () => ipcRenderer.removeListener('agentStatus:legacyWorkerTerminalRecovery', listener)
|
|
},
|
|
getMigrationUnsupportedSnapshot: (): Promise<MigrationUnsupportedPtyEntry[]> =>
|
|
ipcRenderer.invoke('agentStatus:getMigrationUnsupportedSnapshot'),
|
|
drop: (paneKey: string): void => {
|
|
ipcRenderer.send('agentStatus:drop', paneKey)
|
|
},
|
|
dropPersisted: (identity: AgentStatusCacheIdentity): void => {
|
|
ipcRenderer.send('agentStatus:dropPersisted', identity)
|
|
},
|
|
dropPersistedBatch: (identities: readonly AgentStatusCacheIdentity[]): void => {
|
|
ipcRenderer.send('agentStatus:dropPersistedBatch', identities)
|
|
},
|
|
reconcileEndedProcess: (paneKey: string): void => {
|
|
ipcRenderer.send('agentStatus:reconcileEndedProcess', paneKey)
|
|
},
|
|
dropByTabPrefix: (tabId: string): void => {
|
|
ipcRenderer.send('agentStatus:dropByTabPrefix', tabId)
|
|
},
|
|
retirePaneAuthority: (paneKey: string, retirementId?: string): void => {
|
|
ipcRenderer.send('agentStatus:retirePaneAuthority', paneKey, retirementId)
|
|
},
|
|
restorePaneAuthority: (paneKey: string): void => {
|
|
ipcRenderer.send('agentStatus:restorePaneAuthority', paneKey)
|
|
},
|
|
transferPaneAuthority: (args: {
|
|
fromPaneKey: string
|
|
toPaneKey: string
|
|
ptyId?: string
|
|
}): void => {
|
|
ipcRenderer.send('agentStatus:transferPaneAuthority', args)
|
|
}
|
|
} satisfies PreloadApi['agentStatus']
|