Skip to content

armgit / orca

Public Imported from GitHub
0

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.

2.5 KB
Raw Blame
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']