mirror of
https://github.com/stablyai/orca.git
synced 2026-10-31 00:57:45 +00:00
* fix(agent-hooks): register forward-slash Windows hook paths for Grok, Devin, ZCode and Antigravity These four agents registered their native-Windows status hook as a bare backslash path. A Git Bash hook host strips the backslashes, the command exits 127, and no status event reaches Orca. Use the same direct forward-slash form Claude, Codex and Muse already register, keeping the cmd-safe gate and the encoded PowerShell fallback. Existing backslash entries still match the managed-command matcher, so the next install replaces them and keeps user hooks. * perf(hooks): register direct .cmd hooks for Gemini, DSH, Kiro, Droid and Command Code on Windows On a cmd-safe profile path these agents now register the managed .cmd path itself instead of a `powershell.exe -EncodedCommand` launcher, so each hook event no longer pays a second PowerShell start-up on top of the runner's own shell. Profiles the bare path cannot carry (spaces, non-ASCII, UNC) keep the encoded launcher. Same pattern as Claude (#18875) and Muse (#26755). Refs #20913 * test(agent-hooks): expect forward-slash Antigravity hooks after the Unicode upgrade ASCII profiles now register the direct forward-slash wrapper path, so the upgrade-delivery test expects that form and also runs it through Git Bash. Unicode profiles keep the encoded launcher. * test(agent-hooks): assert the registered hook lives under the mocked home Pins that the os mock reaches the agents' node:os imports, so the host test never installs into the real profile. * refactor(hooks): one Windows batch-hook helper and one payload-delivery table - Add wrapWindowsBatchHookCommand (bare .cmd path, encoded launcher otherwise) and use it for Muse, Gemini, DSH, Kiro, Droid and Command Code. - Fold the five agents into windows-hook-payload-delivery.test.ts as rows run under each vendor's shell, from a plain and a spaced profile, with a stale encoded registration seeded per row; drop the separate runner suite and its CI list entries. - Replace the Windows-only per-agent registration tests with ones that stub process.platform, so they run on every CI OS. - Fix stale launcher, helper and DSH comments. Refs #20913 * refactor(agent-hooks): register Grok, Devin, ZCode and Antigravity through wrapWindowsBatchHookCommand Use the shared batch-hook helper from #27717 instead of an inline direct-or-cmd fallback. A UNC home is cmd-safe but has no drive letter; the old fallback registered it as a bare backslash path that Git Bash cannot start, while the helper sends it to the encoded launcher. wrapWindowsCmdHookCommand has no production callers left, so it is removed and its tests point at the helper. Grok, Devin and ZCode join the Windows payload delivery table with a legacy backslash entry to sweep, replacing the separate host test, and the Antigravity migration test now runs on every platform. --------- Co-authored-by: Orca Worker <orca-worker@localhost>
47 lines
2.0 KiB
TypeScript
47 lines
2.0 KiB
TypeScript
import { quotePowerShellLiteral } from '../../shared/powershell-native-argument'
|
|
import { WINDOWS_POWERSHELL_HOOK_ENVIRONMENT_GUARD } from './hook-stdin-contract'
|
|
import {
|
|
wrapWindowsPowerShellEncodedCommand,
|
|
type WindowsPowerShellHookOptions
|
|
} from './windows-powershell-hook-launcher'
|
|
|
|
export function wrapWindowsHookCommand(
|
|
scriptPath: string,
|
|
env: Record<string, string> = {},
|
|
options: WindowsPowerShellHookOptions & { fallbackStdout?: string } = {}
|
|
): string {
|
|
return wrapWindowsPowerShellEncodedCommand(
|
|
buildWindowsHookPowerShellCommand(scriptPath, env, options),
|
|
options
|
|
)
|
|
}
|
|
|
|
export function buildWindowsHookPowerShellCommand(
|
|
scriptPath: string,
|
|
env: Record<string, string> = {},
|
|
// Why: POSIX wrap already answers missing-script with stdout; Windows must match so gate events cannot drift (#15462).
|
|
options: { fallbackStdout?: string } = {}
|
|
): string {
|
|
// Why: the encoded launcher protects paths across Windows shells and drains stdin when the config points at a missing script.
|
|
const quoted = quotePowerShellLiteral(scriptPath)
|
|
const envPrefix = Object.entries(env)
|
|
.map(([key, value]) => `$env:${key} = ${quotePowerShellLiteral(value)}; `)
|
|
.join('')
|
|
const fallback =
|
|
options.fallbackStdout === undefined
|
|
? ''
|
|
: `Write-Output ${quotePowerShellLiteral(options.fallbackStdout)}; `
|
|
// Why the order: answer first (a gate event reads silence as deny), then the shared
|
|
// env guard, and only then own stdin — outside an Orca pane the caller may abandon the
|
|
// pipe, and ReadToEnd would strand the launcher there forever (#11549).
|
|
return `${envPrefix}if (Test-Path -LiteralPath ${quoted} -PathType Leaf) { & ${quoted}; exit $LASTEXITCODE }; ${fallback}${WINDOWS_POWERSHELL_HOOK_ENVIRONMENT_GUARD}; [Console]::In.ReadToEnd() | Out-Null; exit 0`
|
|
}
|
|
|
|
export const WINDOWS_CMD_SAFE_PATH = /^[A-Za-z0-9_.:\\~-]+$/
|
|
|
|
export function isSafeUnicodeWindowsBatchHookPath(scriptPath: string): boolean {
|
|
return (
|
|
!WINDOWS_CMD_SAFE_PATH.test(scriptPath) && /^[\p{L}\p{N}\p{M}_.:\\~-]+\.cmd$/iu.test(scriptPath)
|
|
)
|
|
}
|