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
import type { ProviderDiagnostic } from './agent-session-failure'
import type {
  AgentSessionFailureCopyId,
  AgentSessionFailureCopyValues,
  AgentSessionFailureSay
} from './agent-session-failure-copy'

/** Person-facing provider text is quoted, but bounded so the sentence stays one. */
const MAX_QUOTED_DETAIL_CHARS = 512

/** Provider text as a failure sentence quotes it. */
export function quotedProviderDetail(text: string): string {
  return text
    .slice(0, MAX_QUOTED_DETAIL_CHARS)
    .trim()
    .replace(/[.\s]+$/, '')
}

/** The quoted lead when the provider wrote the detail for a person; the plain lead otherwise. */
export function quotingPersonDetail(
  say: AgentSessionFailureSay,
  lead: AgentSessionFailureCopyId,
  quotedLead: AgentSessionFailureCopyId,
  detail: ProviderDiagnostic | undefined,
  values: AgentSessionFailureCopyValues = {}
): string {
  const quoted = detail?.audience === 'person' ? quotedProviderDetail(detail.text) : ''
  return quoted ? say(quotedLead, { ...values, detail: quoted }) : say(lead, values)
}