mirror of
https://github.com/stablyai/orca.git
synced 2026-09-29 16:02:50 +00:00
* Split speech session lifecycle * Split terminal output scheduler pipeline * Split mobile browser pane modules * Prune resolved max-lines suppressions * Split pane tree equalization logic * Extract mobile troubleshoot screen styles * Split external automation manager * Split main window service attachments * Split hosted review creation checks * Split automation dispatch event handling * Split settings navigation metadata * Split daemon initialization lifecycle * Split GitLab item dialog * Split relay dispatcher layers * Split mobile host screen * Retarget mobile view settings source test * Split runtime file client layers * Split ports panel layers * Split runtime environments pane layers * Split local PTY provider responsibilities * Split CDP bridge responsibilities * Split relay Git handler responsibilities * Track moved relay Git fetch audit * Split Linear item drawer responsibilities * Split telemetry event schema responsibilities * Split resource usage status responsibilities * Split remote terminal multiplexer responsibilities * Split Git worktree responsibilities * Split Codex hook service responsibilities * Keep mirrored hook trust type private * Fix F3-speech for #17123 * Fix F1-cycle for #17131 * Fix F4-navtest for #17157 * Fix F2-allowlist for #17161
91 lines
3.8 KiB
TypeScript
91 lines
3.8 KiB
TypeScript
import { buildPosixAgentHookPostCommand } from '../agent-hooks/hook-post-command'
|
|
import {
|
|
buildPosixHookPayloadCapture,
|
|
buildPosixHookSpoolLines,
|
|
buildWindowsHookEnvironmentGuardLines,
|
|
buildWindowsHookStdinDrainEpilogue
|
|
} 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',
|
|
// Why: the endpoint file holds this install's live port/token; sourcing it lets a surviving PTY reach the current server (see claude/hook-service.ts).
|
|
'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',
|
|
...buildWindowsHookStdinDrainEpilogue(),
|
|
''
|
|
].join('\r\n')
|
|
}
|
|
|
|
return [
|
|
'#!/bin/sh',
|
|
...buildPosixHookPayloadCapture(),
|
|
...buildPosixHookSpoolLines('codex'),
|
|
// Why: sourcing refreshes PORT/TOKEN/ENV/VERSION from the current Orca so a surviving PTY keeps reporting after a restart (see claude/hook-service.ts).
|
|
'load_hook_endpoint() {',
|
|
' endpoint_path="$1"',
|
|
' unset ORCA_AGENT_HOOK_TRANSPORT',
|
|
' case "$endpoint_path" in',
|
|
' *.cmd)',
|
|
// Why: Windows passes endpoint.cmd into WSL via WSLENV; parse only Orca's known assignments since cmd.exe `set` lines aren't shell 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}"',
|
|
// Why: keep full hook JSON off the command line and avoid URL-encoding paths/commands into IDS-friendly traversal signatures.
|
|
...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')
|
|
}
|