mirror of
https://github.com/stablyai/orca.git
synced 2026-10-31 17:17:38 +00:00
Extract subprocess execution and process contracts into @orca/process-host with explicit public entry points, independent checks, and one Node 18 compatible CommonJS runtime. Migrate application consumers and integrate package builds, dependency selection, import enforcement, and runtime resource staging. Preserve daemon startup ownership and profile isolation, and qualify development rebuild recovery and concurrent output publication. Remove unnecessary aliases, test forwarding exports, and a duplicate output scan. Validation: full typechecks, changed-code quality, package and artifact checks, native Windows builds/types plus 306 runtime tests, and independent native reviews. Matched full E2E controls on original main and unchanged reviewed head both pass all 17 applicable tests (nine skips). Earlier intermittent E2E failures are documented in the PR; no assertions were weakened. The final combined-tree audit preserves both branches with no import-boundary violations.
73 lines
2.6 KiB
TypeScript
73 lines
2.6 KiB
TypeScript
import { existsSync } from 'node:fs'
|
|
import { mkdtemp, writeFile, readFile, rm } from 'node:fs/promises'
|
|
import { tmpdir } from 'node:os'
|
|
import { delimiter, join } from 'node:path'
|
|
import { expect, it } from 'vitest'
|
|
import { runProcess } from '@orca/process-host'
|
|
import { buildAgentDraftLaunchPlan } from './tui-agent-startup'
|
|
|
|
const shells = ['sh', 'bash', 'zsh', 'dash', 'ksh', 'fish'].filter(
|
|
(shell) =>
|
|
process.platform !== 'win32' &&
|
|
(process.env.PATH ?? '')
|
|
.split(delimiter)
|
|
.some((directory) => existsSync(join(directory, shell)))
|
|
)
|
|
|
|
it.each(
|
|
shells.flatMap((shell) =>
|
|
shell === 'fish'
|
|
? [{ shell, nounset: false }]
|
|
: [false, true].map((nounset) => ({ shell, nounset }))
|
|
)
|
|
)(
|
|
'clears the draft and preserves status in $shell (nounset=$nounset)',
|
|
async ({ shell, nounset }) => {
|
|
const root = await mkdtemp(join(tmpdir(), 'orca-omp-draft-'))
|
|
try {
|
|
const config = join(root, 'fresh settings.yml')
|
|
const calls = join(root, 'calls')
|
|
await writeFile(config, 'autoResume: false\n')
|
|
const plan = buildAgentDraftLaunchPlan({
|
|
agent: 'omp',
|
|
draft: 'task with spaces',
|
|
cmdOverrides: {},
|
|
platform: 'linux'
|
|
})
|
|
if (!plan) {
|
|
throw new Error('Expected draft plan')
|
|
}
|
|
const define =
|
|
shell === 'fish'
|
|
? 'function omp; printf "%s\\n" "$ORCA_OMP_PREFILL" >> "$CAPTURE"; printf agent-stderr >&2; return 17; end; '
|
|
: 'omp() { printf "%s\\n" "$ORCA_OMP_PREFILL" >> "$CAPTURE"; printf agent-stderr >&2; return 17; }; '
|
|
const observe =
|
|
shell === 'fish'
|
|
? '; set -l result $status; set -q ORCA_OMP_PREFILL; and exit 91; exit $result'
|
|
: '; result=$?; test -z "${ORCA_OMP_PREFILL+x}" || exit 91; exit "$result"'
|
|
for (const present of [true, false]) {
|
|
if (!present) {
|
|
await rm(config)
|
|
}
|
|
const result = await runProcess({
|
|
program: shell,
|
|
args: ['-c', (nounset ? 'set -u; ' : '') + define + plan.launchCommand + observe],
|
|
cwd: root,
|
|
env: { ...process.env, ...plan.env, ORCA_OMP_FRESH_CONFIG: config, CAPTURE: calls }
|
|
})
|
|
expect(result.code, result.stderr).toBe(present ? 17 : 1)
|
|
expect(result.stderr).toContain(
|
|
present ? 'agent-stderr' : 'fresh OMP settings are unavailable'
|
|
)
|
|
if (present) {
|
|
expect(result.stderr).toBe('agent-stderr')
|
|
}
|
|
expect(result.stderr).not.toContain('command substitutions not allowed')
|
|
expect(await readFile(calls, 'utf8')).toBe('task with spaces\n')
|
|
}
|
|
} finally {
|
|
await rm(root, { recursive: true, force: true })
|
|
}
|
|
}
|
|
)
|