Files
archived-orca/src/preload/api/automations-bridge.ts
T
Neil 236eba1ecf fix(persistence): folder, group and session-state store writes name their host or why they needn't (R4-2c) (#30797)
* fix(persistence): session, automation-label writes take the workspace's host; exempt minted-unique folder and group ids (R4-2c)

* fix(persistence): keep the session removal's spill rule; the twin guard was unreachable (review)
2026-10-19 10:50:25 -07:00

52 lines
2.5 KiB
TypeScript

import type { ExecutionHostId } from '../../shared/execution-host'
import { ipcRenderer } from 'electron'
import type { ExternalAutomationManagerResult, PreloadApi } from '../api-types'
import type {
AutomationDispatchRequest,
AutomationDispatchResult,
AutomationRun,
AutomationPrecheckResult
} from '../../shared/automations-types'
import type { AutomationOwnerRef } from '../../shared/automation-owner-ref'
import type {
ScopedExternalManagerActionRequest,
ScopedExternalManagerListRequest
} from '../../shared/external-automation-scope'
import type { AutomationsChangedPayload } from '../../shared/runtime-client-events'
export const automationsApi = {
listExternalManagerForOwner: (
request: ScopedExternalManagerListRequest
): Promise<ExternalAutomationManagerResult> =>
ipcRenderer.invoke('automations:listExternalManagerForOwner', request),
runExternalActionForOwner: (request: ScopedExternalManagerActionRequest): Promise<void> =>
ipcRenderer.invoke('automations:runExternalActionForOwner', request),
retainExternalScopes: (request: { owners: readonly AutomationOwnerRef[] }): Promise<void> =>
ipcRenderer.invoke('automations:retainExternalScopes', request),
runPrecheck: (args: {
automationId: string
runId: string
}): Promise<AutomationPrecheckResult | null> =>
ipcRenderer.invoke('automations:runPrecheck', args),
markDispatchResult: (result: AutomationDispatchResult): Promise<AutomationRun> =>
ipcRenderer.invoke('automations:markDispatchResult', result),
snapshotWorkspaceName: (args: {
workspaceId: string
hostId: ExecutionHostId
displayName: string
}): Promise<number> => ipcRenderer.invoke('automations:snapshotWorkspaceName', args),
rendererReady: (): Promise<void> => ipcRenderer.invoke('automations:rendererReady'),
onDispatchRequested: (callback: (request: AutomationDispatchRequest) => void): (() => void) => {
const listener = (_event: Electron.IpcRendererEvent, request: AutomationDispatchRequest) =>
callback(request)
ipcRenderer.on('automations:dispatchRequested', listener)
return () => ipcRenderer.removeListener('automations:dispatchRequested', listener)
},
onChanged: (callback: (payload: AutomationsChangedPayload) => void): (() => void) => {
const listener = (_event: Electron.IpcRendererEvent, payload: AutomationsChangedPayload) =>
callback(payload)
ipcRenderer.on('automations:changed', listener)
return () => ipcRenderer.removeListener('automations:changed', listener)
}
} satisfies PreloadApi['automations']