mirror of
https://github.com/stablyai/orca.git
synced 2026-09-26 00:02:34 +00:00
* wip(omp): prove fresh settings overlay without redirecting storage * fix(omp): guard fresh launches with execution-host settings * fix(omp): preserve unmodelled shell launch commands * test(omp): consolidate shell fixture path import * preserve fresh OMP launch status * test: cover preserved OMP launch status * fix: recognize wrapped fresh OMP launches * chore(ci): refresh validation against fixed main baseline * fix(omp): recognize generated fresh launch guards across shells * fix(omp): preserve draft status and clear prefill across Unix shells * fix(omp): run cmd draft cleanup after either guard branch * fix(omp): launch drafts safely with nounset enabled * fix(omp): select draft shell without parser diagnostics * test(omp): await relay environment augmentation
23 lines
1.2 KiB
TypeScript
23 lines
1.2 KiB
TypeScript
import {
|
|
clearEnvCommand,
|
|
commandSeparator,
|
|
quoteStartupArg,
|
|
type AgentStartupShell
|
|
} from './tui-agent-startup-shell'
|
|
|
|
const FUNCTION_NAME = '__orca_omp_draft'
|
|
export const OMP_DRAFT_LAUNCH_PREFIX = `eval 'builtin --query set' 2>/dev/null && eval 'function ${FUNCTION_NAME}; `
|
|
|
|
/** Clear the calling shell's prefill without replacing the agent's exit status. */
|
|
export function withOmpDraftCleanup(command: string, shell: AgentStartupShell): string {
|
|
if (shell !== 'posix') {
|
|
// cmd otherwise binds the cleanup to the guard's else branch.
|
|
const launch = shell === 'cmd' ? `( ${command} )` : command
|
|
return `${launch}${commandSeparator(shell)}${clearEnvCommand('ORCA_OMP_PREFILL', shell)}`
|
|
}
|
|
const fish = `function ${FUNCTION_NAME}; ${command}; set -l __orca_status $status; set -e -g ORCA_OMP_PREFILL; return $__orca_status; end`
|
|
const posix = `${FUNCTION_NAME}() { ${command}; set -- "$?"; unset ORCA_OMP_PREFILL; return "$1"; }`
|
|
// Fish supports builtin --query; other shells reject it without parsing the wrong definition.
|
|
return `eval 'builtin --query set' 2>/dev/null && eval ${quoteStartupArg(fish, 'posix')} || eval ${quoteStartupArg(posix, 'posix')}; ${FUNCTION_NAME}`
|
|
}
|