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.

976 B
Raw Blame
import type { ExecutionHostId } from '../execution-host'

/** Stable fields needed to identify one checkout occupant. */
export type WorktreeIdentityRef = {
  /** Existing repo/path locator; mutable when the folder moves. */
  worktreeId: string
  /** Host that owns execution for this checkout. */
  executionHostId: ExecutionHostId
  /** Durable identity for this checkout occupant. */
  instanceId: string
}
export type WorktreeIdentity = Omit<WorktreeIdentityRef, 'worktreeId'> & {
  key: string
}

/** Exclude the mutable locator so folder renames preserve occupant identity. */
export function canonicalWorktreeIdentity(ref: WorktreeIdentityRef): string {
  return `wt2:${encodeURIComponent(ref.executionHostId)}:${encodeURIComponent(ref.instanceId)}`
}
export function createWorktreeIdentity(ref: WorktreeIdentityRef): WorktreeIdentity {
  return {
    key: canonicalWorktreeIdentity(ref),
    executionHostId: ref.executionHostId,
    instanceId: ref.instanceId
  }
}