mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
* feat(cloud): sync Claude Code and Codex skills and slash commands to cloud workspaces Copies ~/.claude/skills, ~/.claude/commands, ~/.agents/skills, ~/.codex/skills, ~/.codex/prompts and untracked project .claude/.agents items into each Orca Cloud workspace on create and wake, next to MCP sync. Plan-then-put host RPCs (agentConfig.planSkillSync / agentConfig.putSkills) with a per-computer ledger: items made or edited in the sandbox are never touched; dropped items are removed. Likely secrets stay on this computer; 256 KB/file, 512 KB/skill, 8 MB/workspace. Optional cross-agent sharing. Settings > Orca Cloud > Skills & commands. * fix(cloud-skills): design review: Claude naming, grouped list, copies under originals, off state, relative recency * fix(cloud-skills): use the shared cloud relative time (synced 2m ago) * fix(cloud-skills): premerge findings (process-host, async prefs/syncer id, exhaustive switches, no casts, runtime catalog) * fix(cloud-skills): place Skills & commands after Cloud secrets (design-squad nav order) * chore: restore integration's copies of files the commit hook reformatted during merges
246 lines
12 KiB
TypeScript
246 lines
12 KiB
TypeScript
import { ipcRenderer } from 'electron'
|
|
import type {
|
|
RuntimePortForward,
|
|
RuntimePortForwardOpenRequest,
|
|
RuntimePortForwardOpenResult
|
|
} from '../../shared/runtime-port-forwards'
|
|
import { RUNTIME_PORT_FORWARDS_CHANGED_CHANNEL } from '../../shared/runtime-port-forward-channels'
|
|
import { CLOUD_MCP_SYNC_CHANGED_CHANNEL } from '../../shared/agent-mcp-sync/mcp-sync-preferences'
|
|
import {
|
|
RUNTIME_HOST_STATUS_CHANNEL,
|
|
type RuntimeHostStatusSnapshot
|
|
} from '../../shared/remote-runtime/host-status/runtime-host-status'
|
|
import type { VerifyAndAddRuntimeEnvironmentResult } from '../../shared/remote-runtime/pairing/remote-pairing-verification'
|
|
import type { RuntimeStatus } from '../../shared/runtime-session-contracts'
|
|
import type { RuntimeRpcResponse } from '../../shared/runtime-rpc-envelope'
|
|
import type {
|
|
PublicKnownRuntimeEnvironment,
|
|
RuntimeEnvironmentRemoval
|
|
} from '../../shared/remote-runtime/host-catalog/runtime-environments'
|
|
import type { RemoteRuntimeSharedConnectionDiagnostics } from '../../shared/remote-runtime/control/remote-runtime-shared-control-types'
|
|
import { RUNTIME_ENVIRONMENT_DIAGNOSTICS_CHANNEL } from '../../shared/remote-runtime/host-catalog/runtime-environment-diagnostics'
|
|
import { RUNTIME_ENVIRONMENT_CATALOG_CHANGED_CHANNEL } from '../../shared/remote-runtime/host-catalog/runtime-environment-catalog-channel'
|
|
import {
|
|
WSL_ORCAD_ACCOUNT_NOT_APPLIED_CHANNEL,
|
|
type WslOrcadAccountNotAppliedEvent
|
|
} from '../../shared/wsl-orcad-account-notice'
|
|
import {
|
|
subscribeRuntimeEnvironmentFromPreload,
|
|
subscribeCrewAttemptFromPreload,
|
|
cancelRuntimeEnvironmentSubscriptionFromPreload,
|
|
type RuntimeEnvironmentSubscriptionHandle
|
|
} from '../runtime-environment-subscriptions'
|
|
import type { PreloadApi } from '../api-types'
|
|
import type {
|
|
AuthCallbackForwardRequest,
|
|
AuthCallbackForwardResult,
|
|
LoopbackCallbackForwardRequest
|
|
} from '../../shared/auth-callback-forward'
|
|
import type { McpSyncStatus } from '../../shared/agent-mcp-sync/mcp-sync-contract'
|
|
import type { CloudMcpSyncPreferences } from '../../shared/agent-mcp-sync/mcp-sync-preferences'
|
|
import {
|
|
CLOUD_AGENT_CONFIG_SYNC_CHANGED_CHANNEL,
|
|
CLOUD_AGENT_CONFIG_SYNC_PREFERENCES_CHANNEL,
|
|
type AgentConfigSyncStatus,
|
|
type CloudAgentConfigSyncPreferences
|
|
} from '../../shared/agent-config-sync/agent-config-sync-contract'
|
|
import { managedOrcadApi } from './managed-orcad-api'
|
|
import { getWslHostsApi } from './wsl-hosts-api'
|
|
|
|
export const runtimeEnvironmentsApi = {
|
|
desktopCreatedChatIds: (): Promise<string[]> =>
|
|
ipcRenderer.invoke('runtimeEnvironments:desktopCreatedChatIds'),
|
|
openAuthCallbackForward: (
|
|
request: AuthCallbackForwardRequest
|
|
): Promise<AuthCallbackForwardResult> =>
|
|
ipcRenderer.invoke('runtimeEnvironments:openAuthCallbackForward', request),
|
|
closeAuthCallbackForward: (
|
|
request: Pick<AuthCallbackForwardRequest, 'environmentId' | 'flowId'>
|
|
): Promise<void> => ipcRenderer.invoke('runtimeEnvironments:closeAuthCallbackForward', request),
|
|
listPortForwards: (): Promise<RuntimePortForward[]> =>
|
|
ipcRenderer.invoke('runtimePortForwards:list'),
|
|
openPortForward: (
|
|
request: RuntimePortForwardOpenRequest
|
|
): Promise<RuntimePortForwardOpenResult> =>
|
|
ipcRenderer.invoke('runtimePortForwards:open', request),
|
|
closePortForward: (request: { id: string }): Promise<RuntimePortForward | null> =>
|
|
ipcRenderer.invoke('runtimePortForwards:close', request),
|
|
wakePortForwardHost: (request: { environmentId: string }): Promise<boolean> =>
|
|
ipcRenderer.invoke('runtimePortForwards:wake', request),
|
|
onPortForwardsChanged: (callback: (forwards: RuntimePortForward[]) => void): (() => void) => {
|
|
const listener = (_event: Electron.IpcRendererEvent, forwards: RuntimePortForward[]): void =>
|
|
callback(forwards)
|
|
ipcRenderer.on(RUNTIME_PORT_FORWARDS_CHANGED_CHANNEL, listener)
|
|
return () => ipcRenderer.removeListener(RUNTIME_PORT_FORWARDS_CHANGED_CHANNEL, listener)
|
|
},
|
|
openLoopbackCallbackForward: (
|
|
request: LoopbackCallbackForwardRequest
|
|
): Promise<AuthCallbackForwardResult> =>
|
|
ipcRenderer.invoke('runtimeEnvironments:openLoopbackCallbackForward', request),
|
|
getMcpSyncStatus: (environmentId: string): Promise<McpSyncStatus | null> =>
|
|
ipcRenderer.invoke('cloudMcpSync:getStatus', environmentId),
|
|
syncMcpServersNow: (environmentId: string): Promise<McpSyncStatus | null> =>
|
|
ipcRenderer.invoke('cloudMcpSync:syncNow', environmentId),
|
|
getMcpSyncPreferences: (): Promise<CloudMcpSyncPreferences | null> =>
|
|
ipcRenderer.invoke('cloudMcpSync:getPreferences'),
|
|
setMcpSyncPreferences: (
|
|
preferences: Partial<CloudMcpSyncPreferences>
|
|
): Promise<CloudMcpSyncPreferences | null> =>
|
|
ipcRenderer.invoke('cloudMcpSync:setPreferences', preferences),
|
|
setMcpServerIncluded: (key: string, included: boolean): Promise<CloudMcpSyncPreferences | null> =>
|
|
ipcRenderer.invoke('cloudMcpSync:setServerIncluded', key, included),
|
|
onMcpSyncChanged: (callback: (status: McpSyncStatus) => void): (() => void) => {
|
|
const listener = (_event: Electron.IpcRendererEvent, status: McpSyncStatus): void =>
|
|
callback(status)
|
|
ipcRenderer.on(CLOUD_MCP_SYNC_CHANGED_CHANNEL, listener)
|
|
return () => ipcRenderer.removeListener(CLOUD_MCP_SYNC_CHANGED_CHANNEL, listener)
|
|
},
|
|
getAgentConfigSyncStatus: (environmentId: string): Promise<AgentConfigSyncStatus | null> =>
|
|
ipcRenderer.invoke('cloudAgentConfigSync:getStatus', environmentId),
|
|
syncAgentConfigNow: (environmentId: string): Promise<AgentConfigSyncStatus | null> =>
|
|
ipcRenderer.invoke('cloudAgentConfigSync:syncNow', environmentId),
|
|
getAgentConfigSyncPreferences: (): Promise<CloudAgentConfigSyncPreferences | null> =>
|
|
ipcRenderer.invoke('cloudAgentConfigSync:getPreferences'),
|
|
setAgentConfigSyncPreferences: (
|
|
preferences: Partial<Omit<CloudAgentConfigSyncPreferences, 'excluded'>>
|
|
): Promise<CloudAgentConfigSyncPreferences | null> =>
|
|
ipcRenderer.invoke('cloudAgentConfigSync:setPreferences', preferences),
|
|
setAgentConfigItemIncluded: (
|
|
key: string,
|
|
included: boolean
|
|
): Promise<CloudAgentConfigSyncPreferences | null> =>
|
|
ipcRenderer.invoke('cloudAgentConfigSync:setItemIncluded', key, included),
|
|
onAgentConfigSyncChanged: (callback: (status: AgentConfigSyncStatus) => void): (() => void) => {
|
|
const listener = (_event: Electron.IpcRendererEvent, status: AgentConfigSyncStatus): void =>
|
|
callback(status)
|
|
ipcRenderer.on(CLOUD_AGENT_CONFIG_SYNC_CHANGED_CHANNEL, listener)
|
|
return () => ipcRenderer.removeListener(CLOUD_AGENT_CONFIG_SYNC_CHANGED_CHANNEL, listener)
|
|
},
|
|
onAgentConfigSyncPreferencesChanged: (
|
|
callback: (preferences: CloudAgentConfigSyncPreferences) => void
|
|
): (() => void) => {
|
|
const listener = (
|
|
_event: Electron.IpcRendererEvent,
|
|
preferences: CloudAgentConfigSyncPreferences
|
|
): void => callback(preferences)
|
|
ipcRenderer.on(CLOUD_AGENT_CONFIG_SYNC_PREFERENCES_CHANNEL, listener)
|
|
return () => ipcRenderer.removeListener(CLOUD_AGENT_CONFIG_SYNC_PREFERENCES_CHANNEL, listener)
|
|
},
|
|
getStatusSnapshots: (): Promise<RuntimeHostStatusSnapshot[]> =>
|
|
ipcRenderer.invoke('runtimeEnvironments:getStatusSnapshots'),
|
|
onStatusChanged: (callback: (snapshot: RuntimeHostStatusSnapshot) => void): (() => void) => {
|
|
const listener = (
|
|
_event: Electron.IpcRendererEvent,
|
|
snapshot: RuntimeHostStatusSnapshot
|
|
): void => callback(snapshot)
|
|
ipcRenderer.on(RUNTIME_HOST_STATUS_CHANNEL, listener)
|
|
return () => ipcRenderer.removeListener(RUNTIME_HOST_STATUS_CHANNEL, listener)
|
|
},
|
|
onCatalogChanged: (callback: () => void): (() => void) => {
|
|
const listener = (): void => callback()
|
|
ipcRenderer.on(RUNTIME_ENVIRONMENT_CATALOG_CHANGED_CHANNEL, listener)
|
|
return () => ipcRenderer.removeListener(RUNTIME_ENVIRONMENT_CATALOG_CHANGED_CHANNEL, listener)
|
|
},
|
|
list: (): Promise<PublicKnownRuntimeEnvironment[]> =>
|
|
ipcRenderer.invoke('runtimeEnvironments:list'),
|
|
addFromPairingCode: (args: {
|
|
name: string
|
|
pairingCode: string
|
|
}): Promise<{ environment: PublicKnownRuntimeEnvironment }> =>
|
|
ipcRenderer.invoke('runtimeEnvironments:addFromPairingCode', args),
|
|
verifyAndAddFromPairingCode: (args: {
|
|
name: string
|
|
pairingCode: string
|
|
allowLoopback?: boolean
|
|
}): Promise<VerifyAndAddRuntimeEnvironmentResult> =>
|
|
ipcRenderer.invoke('runtimeEnvironments:verifyAndAddFromPairingCode', args),
|
|
repairFromPairingCode: (args: {
|
|
selector: string
|
|
pairingCode: string
|
|
}): Promise<VerifyAndAddRuntimeEnvironmentResult> =>
|
|
ipcRenderer.invoke('runtimeEnvironments:repairFromPairingCode', args),
|
|
resolve: (args: { selector: string }): Promise<PublicKnownRuntimeEnvironment> =>
|
|
ipcRenderer.invoke('runtimeEnvironments:resolve', args),
|
|
remove: (args: { selector: string }): Promise<RuntimeEnvironmentRemoval> =>
|
|
ipcRenderer.invoke('runtimeEnvironments:remove', args),
|
|
disconnect: (args: {
|
|
selector: string
|
|
}): Promise<{ disconnected: PublicKnownRuntimeEnvironment }> =>
|
|
ipcRenderer.invoke('runtimeEnvironments:disconnect', args),
|
|
connect: (args: {
|
|
selector: string
|
|
timeoutMs?: number
|
|
}): Promise<RuntimeRpcResponse<RuntimeStatus>> =>
|
|
ipcRenderer.invoke('runtimeEnvironments:connect', args),
|
|
getStatus: (args: {
|
|
selector: string
|
|
timeoutMs?: number
|
|
observeOnly?: true
|
|
}): Promise<RuntimeRpcResponse<RuntimeStatus>> =>
|
|
ipcRenderer.invoke('runtimeEnvironments:getStatus', args),
|
|
onSharedControlDiagnostics: (
|
|
callback: (event: {
|
|
environmentId: string
|
|
transportGeneration: number
|
|
diagnostics: RemoteRuntimeSharedConnectionDiagnostics
|
|
}) => void
|
|
): (() => void) => {
|
|
const listener = (
|
|
_event: Electron.IpcRendererEvent,
|
|
data: {
|
|
environmentId: string
|
|
transportGeneration: number
|
|
diagnostics: RemoteRuntimeSharedConnectionDiagnostics
|
|
}
|
|
): void => callback(data)
|
|
ipcRenderer.on(RUNTIME_ENVIRONMENT_DIAGNOSTICS_CHANNEL, listener)
|
|
return () => ipcRenderer.removeListener(RUNTIME_ENVIRONMENT_DIAGNOSTICS_CHANNEL, listener)
|
|
},
|
|
onWslAccountNotApplied: (
|
|
callback: (event: WslOrcadAccountNotAppliedEvent) => void
|
|
): (() => void) => {
|
|
const listener = (
|
|
_event: Electron.IpcRendererEvent,
|
|
data: WslOrcadAccountNotAppliedEvent
|
|
): void => callback(data)
|
|
ipcRenderer.on(WSL_ORCAD_ACCOUNT_NOT_APPLIED_CHANNEL, listener)
|
|
return () => ipcRenderer.removeListener(WSL_ORCAD_ACCOUNT_NOT_APPLIED_CHANNEL, listener)
|
|
},
|
|
prepareBrowserClientHostPlacement: (args) =>
|
|
ipcRenderer.invoke('runtimeEnvironments:prepareBrowserClientHostPlacement', args),
|
|
retryConnectionsNow: (): Promise<void> =>
|
|
ipcRenderer.invoke('runtimeEnvironments:retryConnectionsNow'),
|
|
call: (args: {
|
|
selector: string
|
|
method: string
|
|
params?: unknown
|
|
timeoutMs?: number
|
|
expectedEnvironmentPairingRevision?: number
|
|
expectedEnvironmentRuntimeId?: string
|
|
}): Promise<RuntimeRpcResponse<unknown>> => ipcRenderer.invoke('runtimeEnvironments:call', args),
|
|
cancelSubscription: (args: { subscriptionId: string }): Promise<void> =>
|
|
cancelRuntimeEnvironmentSubscriptionFromPreload(ipcRenderer, args.subscriptionId),
|
|
subscribeCrewAttempt: (args, callbacks) =>
|
|
subscribeCrewAttemptFromPreload(ipcRenderer, args, callbacks),
|
|
subscribe: async (
|
|
args: {
|
|
subscriptionId?: string
|
|
selector: string
|
|
method: string
|
|
params?: unknown
|
|
timeoutMs?: number
|
|
expectedEnvironmentPairingRevision?: number
|
|
expectedEnvironmentRuntimeId?: string
|
|
},
|
|
callbacks: {
|
|
onResponse: (response: RuntimeRpcResponse<unknown>) => void
|
|
onBinary?: (bytes: Uint8Array<ArrayBufferLike>) => void
|
|
onError?: (error: { code: string; message: string }) => void
|
|
onClose?: () => void
|
|
}
|
|
): Promise<RuntimeEnvironmentSubscriptionHandle> =>
|
|
subscribeRuntimeEnvironmentFromPreload(ipcRenderer, args, callbacks),
|
|
managedOrcad: managedOrcadApi,
|
|
wslHosts: getWslHostsApi()
|
|
} satisfies PreloadApi['runtimeEnvironments']
|