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.

1.1 KB
Raw Blame
import {
  serializeAgentStatusProviderAliasKey,
  type AgentStatusRunAliasIndex
} from './agent-status-run-alias-index'
import type { AgentStatusParentRecord } from './agent-status-store-parent'

export function deriveAgentStatusStoreRunAliasIndex(
  parents: Iterable<AgentStatusParentRecord>
): AgentStatusRunAliasIndex {
  const index: AgentStatusRunAliasIndex = new Map()
  for (const parent of parents) {
    if (parent.subject.kind !== 'pty-run' || !parent.run) {
      continue
    }
    for (const session of parent.run.providerSessions) {
      const key = serializeAgentStatusProviderAliasKey({
        executionHostId: parent.subject.executionHostId,
        wslDistro: parent.subject.wslDistro,
        workspaceId: parent.subject.workspaceId,
        workspaceKind: parent.subject.workspaceKind,
        provider: session.provider,
        sessionKeyKind: session.sessionKeyKind,
        providerId: session.providerId
      })
      const runIds = index.get(key) ?? new Set<string>()
      runIds.add(parent.run.runId)
      index.set(key, runIds)
    }
  }
  return index
}