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.

723 B
Raw Blame
import {
  stripAnsiEscapeSequences,
  TERMINAL_CONTROL_CHARACTER_PATTERN
} from './ansi-escape-sequences'
import { ownRetainedString } from './own-retained-string'
import { clampUtf8TextTail, isUtf8ByteLengthWithinLimit } from './utf8-byte-limits'

export const PR_CHECK_LOG_TAIL_BYTES = 16 * 1024

export function sanitizeCheckJobLogExcerpt(value: string): string {
  const bounded = isUtf8ByteLengthWithinLimit(value, PR_CHECK_LOG_TAIL_BYTES)
    ? value
    : clampUtf8TextTail(value, PR_CHECK_LOG_TAIL_BYTES).text
  return ownRetainedString(
    stripAnsiEscapeSequences(bounded)
      .replace(/\r\n?/g, '\n')
      .replace(TERMINAL_CONTROL_CHARACTER_PATTERN, '')
      .replace(/[^\P{Cf}\u200c\u200d]/gu, '')
  )
}