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.0 KB
Raw Blame
/** Holder identity token: the registry only compares references, never reads fields. */
export type HostClientAcquisition = Record<string, never>

export class HostClientAcquisitionRegistry {
  private readonly acquisitions = new Map<string, Set<HostClientAcquisition>>()

  acquire(hostId: string, acquisition: HostClientAcquisition): number {
    let active = this.acquisitions.get(hostId)
    if (!active) {
      active = new Set()
      this.acquisitions.set(hostId, active)
    }
    active.add(acquisition)
    return active.size
  }

  release(hostId: string, acquisition: HostClientAcquisition): number | null {
    const active = this.acquisitions.get(hostId)
    if (!active?.delete(acquisition)) {
      return null
    }
    if (active.size === 0) {
      this.acquisitions.delete(hostId)
    }
    return active.size
  }

  count(hostId: string): number {
    return this.acquisitions.get(hostId)?.size ?? 0
  }

  clear(hostId: string): void {
    this.acquisitions.delete(hostId)
  }

  clearAll(): void {
    this.acquisitions.clear()
  }
}