mirror of
https://github.com/stablyai/orca.git
synced 2026-10-31 00:57:45 +00:00
Post-merge cleanup after the agent-integration fixes: remove the unreachable Windows hook-script stdin drain epilogue; Windows statusline exits instead of draining outside an Orca pane; Codex CLI fork uses the \\?\-aware rollout path; WSL browser-network relay falls back to orcad's pinned Node (shared launcher revision stamp); stranded sleep records only drop for their own worktree; renames (hidden probe cwd, local Windows ConPTY helper).
89 lines
3.4 KiB
TypeScript
89 lines
3.4 KiB
TypeScript
import { buildPosixAgentHookPostCommand } from '../agent-hooks/hook-post-command'
|
|
import {
|
|
buildPosixHookPayloadCapture,
|
|
buildPosixHookSpoolLines,
|
|
buildWindowsHookEnvironmentGuardLines
|
|
} from '../agent-hooks/hook-stdin-contract'
|
|
import { buildWindowsAgentHookCurlPostCommand } from '../agent-hooks/installer-utils'
|
|
|
|
export function getManagedScript(target: 'local' | 'posix' = 'local'): string {
|
|
if (target === 'local' && process.platform === 'win32') {
|
|
return [
|
|
'@echo off',
|
|
'setlocal',
|
|
// Reload the endpoint so surviving PTYs reach the current server after restart.
|
|
'if defined ORCA_AGENT_HOOK_ENDPOINT if exist "%ORCA_AGENT_HOOK_ENDPOINT%" call "%ORCA_AGENT_HOOK_ENDPOINT%" 2>nul',
|
|
...buildWindowsHookEnvironmentGuardLines(),
|
|
buildWindowsAgentHookCurlPostCommand('codex'),
|
|
'exit /b 0',
|
|
''
|
|
].join('\r\n')
|
|
}
|
|
|
|
return [
|
|
'#!/bin/sh',
|
|
...buildPosixHookPayloadCapture(),
|
|
...buildPosixHookSpoolLines('codex'),
|
|
// Reload endpoint state so surviving PTYs keep reporting after restart.
|
|
'load_hook_endpoint() {',
|
|
' endpoint_path="$1"',
|
|
' unset ORCA_AGENT_HOOK_TRANSPORT',
|
|
' case "$endpoint_path" in',
|
|
' *.cmd)',
|
|
// WSLENV passes endpoint.cmd; parse known assignments because cmd set lines are not POSIX syntax.
|
|
' endpoint_cr=$(printf "\\r")',
|
|
' while IFS= read -r endpoint_line || [ -n "$endpoint_line" ]; do',
|
|
' endpoint_line=${endpoint_line%"$endpoint_cr"}',
|
|
' case "$endpoint_line" in',
|
|
' "set ORCA_AGENT_HOOK_PORT="*) ORCA_AGENT_HOOK_PORT=${endpoint_line#*=} ;;',
|
|
' "set ORCA_AGENT_HOOK_TOKEN="*) ORCA_AGENT_HOOK_TOKEN=${endpoint_line#*=} ;;',
|
|
' "set ORCA_AGENT_HOOK_ENV="*) ORCA_AGENT_HOOK_ENV=${endpoint_line#*=} ;;',
|
|
' "set ORCA_AGENT_HOOK_VERSION="*) ORCA_AGENT_HOOK_VERSION=${endpoint_line#*=} ;;',
|
|
' "set ORCA_AGENT_HOOK_TRANSPORT="*) ORCA_AGENT_HOOK_TRANSPORT=${endpoint_line#*=} ;;',
|
|
' esac',
|
|
' done < "$endpoint_path"',
|
|
' ;;',
|
|
' *)',
|
|
' . "$endpoint_path" 2>/dev/null || :',
|
|
' ;;',
|
|
' esac',
|
|
'}',
|
|
'if [ -n "$ORCA_AGENT_HOOK_ENDPOINT" ] && [ -r "$ORCA_AGENT_HOOK_ENDPOINT" ]; then',
|
|
' load_hook_endpoint "$ORCA_AGENT_HOOK_ENDPOINT"',
|
|
'fi',
|
|
'if [ -z "$ORCA_AGENT_HOOK_PORT" ] || [ -z "$ORCA_AGENT_HOOK_TOKEN" ] || [ -z "$ORCA_PANE_KEY" ]; then',
|
|
' spool_hook_event',
|
|
' exit 0',
|
|
'fi',
|
|
'post_codex_hook() {',
|
|
' curl_bin="$1"',
|
|
' connect_timeout="${2:-0.5}"',
|
|
' max_time="${3:-1.5}"',
|
|
// Send JSON through stdin to keep it off argv and avoid path-encoding IDS alerts.
|
|
...buildPosixAgentHookPostCommand('codex', {
|
|
curlCommand: '"$curl_bin"',
|
|
indent: ' '
|
|
}).map((line) => ` ${line}`),
|
|
'}',
|
|
'is_wsl_runtime() {',
|
|
' [ -n "$WSL_DISTRO_NAME" ] && return 0',
|
|
' grep -qiE "microsoft|wsl" /proc/sys/kernel/osrelease /proc/version 2>/dev/null',
|
|
'}',
|
|
'if post_codex_hook curl >/dev/null 2>&1; then',
|
|
' exit 0',
|
|
'fi',
|
|
'if is_wsl_runtime; then',
|
|
' windows_curl=$(command -v curl.exe 2>/dev/null || true)',
|
|
' if [ -n "$windows_curl" ] && [ -x "$windows_curl" ]; then',
|
|
' if post_codex_hook "$windows_curl" 3 5 >/dev/null 2>&1; then',
|
|
' exit 0',
|
|
' fi',
|
|
' # post_codex_hook "$windows_curl" 3 5 >/dev/null 2>&1 || true',
|
|
' fi',
|
|
'fi',
|
|
'spool_hook_event',
|
|
'exit 0',
|
|
''
|
|
].join('\n')
|
|
}
|