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.
TypeScript adeagent-ideai-agentsautomationbotclaude-codecodexghosttygrok-bothermes-agentmobile-appmuseopenclawopencodeorchestrationpiruntimeterminalworktreesyc-backed
import { mkdtempSync, readFileSync, rmSync, writeFileSync, existsSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { afterEach, describe, expect, it } from 'vitest'
import { ORCAD_WINDOWS_BREAKAWAY_CONTRACT } from './windows-breakaway-launch'
import {
keepPreviousStderrLog,
parseWindowsBreakawayLaunchRequest
} from './windows-breakaway-launcher'
let dir: string | undefined
function makeDir(): string {
dir = mkdtempSync(join(tmpdir(), 'orca-breakaway-log-'))
return dir
}
afterEach(() => {
if (dir) {
rmSync(dir, { recursive: true, force: true })
dir = undefined
}
})
describe('keeping the previous orcad.log on Windows', () => {
it('parses the opt-in flag without taking the next flag as its value', () => {
const request = parseWindowsBreakawayLaunchRequest(ORCAD_WINDOWS_BREAKAWAY_CONTRACT, [
'node.exe',
'orcad.js',
'--windows-breakaway-launch',
'--stdout-file',
'C:/slot/.orcad-readiness',
'--stderr-file',
'C:/slot/orcad.log',
'--stderr-keep-previous',
'--process-file',
'C:/slot/.orcad-process.json',
'--orcad-args',
'--json'
])
expect(request).toMatchObject({
stderrPath: 'C:/slot/orcad.log',
processFilePath: 'C:/slot/.orcad-process.json',
keepPreviousStderr: true
})
})
it('moves the last run log to .1, replacing an older one', () => {
const log = join(makeDir(), 'orcad.log')
writeFileSync(`${log}.1`, 'two runs ago')
writeFileSync(log, 'crash: listen EADDRINUSE')
keepPreviousStderrLog(log)
expect(readFileSync(`${log}.1`, 'utf8')).toBe('crash: listen EADDRINUSE')
expect(existsSync(log)).toBe(false)
})
it('keeps only the tail of an oversized log', () => {
const log = join(makeDir(), 'orcad.log')
writeFileSync(log, `${'x'.repeat(100)}last error`)
keepPreviousStderrLog(log, 10)
expect(readFileSync(`${log}.1`, 'utf8')).toBe('last error')
})
it('does nothing when there is no previous log', () => {
const log = join(makeDir(), 'orcad.log')
expect(() => keepPreviousStderrLog(log)).not.toThrow()
expect(existsSync(`${log}.1`)).toBe(false)
})
})