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.

644 B
Raw Blame
export type RetiredPtyIncarnation = {
  incarnationId: string
  code: number
  expiresAt: number
}

const MAX_RETIRED_PTY_INCARNATIONS = 1000

/** Drop expired exit evidence and cap retained records during long-lived hosts. */
export function pruneRetiredPtyIncarnations(
  records: Map<string, RetiredPtyIncarnation>,
  now = Date.now()
): void {
  for (const [id, record] of records) {
    if (record.expiresAt <= now) {
      records.delete(id)
    }
  }
  while (records.size > MAX_RETIRED_PTY_INCARNATIONS) {
    const oldest = records.keys().next().value
    if (oldest === undefined) {
      break
    }
    records.delete(oldest)
  }
}