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.

2.1 KB
Raw Blame
import {
  CLAUDE_IDLE,
  GEMINI_IDLE,
  GEMINI_PERMISSION,
  GEMINI_SILENT_WORKING,
  GEMINI_WORKING,
  containsAgentSpinnerGlyph
} from './agent-title-glyphs'
import { isDshTerminalTitle } from './dsh-terminal-title'
import type { AgentStatus } from './agent-title-core'
import { getWrapperTitleSegments } from './terminal-title-wrapper-segments'

const DSB_TITLE_RE = /(?:^| - )deepseek build$/i
// Why: DSB separates its spinner with " - "; a Claude task can end on the same suffix.
const DSB_WORKING_PREFIX = String.raw`^(?:\u26A0 Action Required - )?[\u2800-\u28ff]+\s+-\s+`
const DSB_WORKING_PREFIX_RE = new RegExp(DSB_WORKING_PREFIX, 'i')
const DSB_WORKING_TITLE_RE = new RegExp(
  DSB_WORKING_PREFIX + String.raw`[\s\S]+?\s-\s+deepseek build$`,
  'i'
)

export function hasDeepSeekBuildWorkingTitlePrefix(header: string): boolean {
  return DSB_WORKING_PREFIX_RE.test(header)
}

export function isDeepSeekBuildWorkingTitle(title: string): boolean {
  return DSB_WORKING_TITLE_RE.test(title)
}
const NATIVE_VENDOR_PREFIXES = [
  `${CLAUDE_IDLE} `,
  '. ',
  '* ',
  GEMINI_IDLE,
  GEMINI_PERMISSION,
  GEMINI_SILENT_WORKING,
  GEMINI_WORKING
]

export function isDeepSeekBuildTerminalTitle(title: string): boolean {
  const segments = getWrapperTitleSegments(title.trim())
  // Why: native owner markers must win even inside a wrapper; task glyphs are not markers.
  if (
    segments.some(
      (segment) =>
        isDshTerminalTitle(segment) ||
        NATIVE_VENDOR_PREFIXES.some((prefix) => segment.startsWith(prefix))
    )
  ) {
    return false
  }
  return segments.some(
    (segment) =>
      DSB_TITLE_RE.test(segment) &&
      (!containsAgentSpinnerGlyph(segment) || isDeepSeekBuildWorkingTitle(segment))
  )
}

export function getDeepSeekBuildTitleStatus(title: string): AgentStatus | null {
  if (!isDeepSeekBuildTerminalTitle(title)) {
    return null
  }
  const segments = getWrapperTitleSegments(title.trim())
  if (segments.some((segment) => segment.startsWith('⚠ Action Required - '))) {
    return 'permission'
  }
  return segments.some((segment) => isDeepSeekBuildWorkingTitle(segment)) ? 'working' : 'idle'
}