Skip to content

fix(agent-hooks): hide Windows .cmd hook consoles without dropping stdout - #15506

Closed
ynjmxn wants to merge 3 commits into
stablyai:mainfrom
ynjmxn:fix/windows-hook-cmd-no-window
Closed

ynjmxn wants to merge 3 commits into
stablyai:mainfrom
ynjmxn:fix/windows-hook-cmd-no-window

Conversation

@ynjmxn

@ynjmxn ynjmxn commented Aug 19, 2026

Copy link
Copy Markdown

ELI5

On Windows, every Grok tool call runs Orca's managed hook as a .cmd file. The hook is already wrapped in hidden PowerShell, but .cmd cannot inherit that hidden console, so Windows opens a brief titled cmd/conhost window and steals focus. This change starts System32\cmd.exe with CreateNoWindow and still copies the hook's stdout, stderr, and exit code back to the caller.

What Changed

  • wrapWindowsHookCommand still uses the existing encoded PowerShell launcher (-WindowStyle Hidden, $ProgressPreference='SilentlyContinue', absolute powershell.exe).
  • For .cmd, it no longer uses & $scriptPath. It starts absolute System32\cmd.exe through ProcessStartInfo with UseShellExecute = $false, CreateNoWindow = $true, redirected stdin/stdout/stderr, writes [Console]::In.ReadToEnd() into the child then closes stdin, writes child stdout/stderr back, and exit $p.ExitCode.
  • Path spaces, %, and ^ travel in an env var and are expanded with delayed expansion (/v:on + !ORCA_WINDOWS_HOOK_CMD!), so they stay out of the encoded command line ([Bug]: Codex hooks fail on Windows when user path contains spaces #6078) and cmd does not resplit them.
  • For .ps1, the launcher still calls & in-process.
  • Missing script still drains stdin and exits 0.
  • wrapWindowsCmdHookCommand (Codex/Antigravity argv[0] fast path), hook script bodies, terminal daemon OpenConsole.exe, and the Git Bash runtime-home-hook-command path are unchanged.

Why

#14825 hid the PowerShell wrapper. That is not enough for Grok: Grok's managed entry is & grok-hook.cmd, and a .cmd with no console to inherit gets a new one. #14845 tried a native GUI launcher for this issue and was closed unmerged against the same files. This is the small follow-up on main: one launcher change, stdout preserved so Claude/Cursor do not regress #14818.

Evidence for the .cmd spawn path: #14828 (comment)

Linked Issue

Fixes #14828

Visual Proof

N/A — no Orca UI, layout, or in-app control change. The bug is an OS console flash / focus steal (MainWindowTitle often C:\WINDOWS\System32\conhost.exe), so proof is command shape, process tree, and a live Windows test that samples titled cmd/conhost windows while a Grok-style powershell -NoProfile -NonInteractive launch runs a sleeping .cmd. Screenshots would not show the flash reliably.

Before: decoded payload is & '...\grok-hook.cmd'; each tool event opens a titled console.

After: decoded payload contains CreateNoWindow = $true and is not a naked & '...*.cmd'; live sampling on this Windows 11 machine found no new titled cmd/conhost window; stdout {"ok":true} and exit 0 still came back.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Platforms actually exercised: Windows 11 (this checkout). macOS/Linux covered by command-shape unit tests (no Windows spawn).

Ran locally:

  • pnpm exec vitest run --config config/vitest.config.ts src/main/agent-hooks/installer-utils.test.ts src/main/agent-hooks/windows-hook-cmd-no-window.test.ts src/main/claude/hook-service.test.ts src/main/grok/hook-service.test.ts — 84 passed, 7 skipped
  • Live Windows cases: caret path still exits 7; Grok-style outer (powershell -NoProfile -NonInteractive, no Hidden on that outer layer) relays stdout/stderr/exit 7; missing script drains and exits 0; titled-window sampler over a 3s .cmd saw no new cmd/conhost MainWindowTitle (skipped in CI via skipIf)
  • Claude registered-hook JSON-through-cmd/Git Bash test still passed
  • pnpm typecheck passed
  • pnpm lint: oxlint, code-quality native/type-aware, reliability gates, max-lines ratchet, and bundled skill guides passed. verify:skill-bundle-manifest failed on this worktree with stale resources/skills/*.json; those files are not in this diff (pre-existing generator drift). CI should cover the rest of lint plus pnpm test / pnpm build

Did not run full pnpm test / pnpm build (too heavy for this launcher-only change).

Pre-existing flake not caused by this PR: managed-hook-stdin-lifecycle.test.ts antigravity-hook.cmd stdin EOF vs EPIPE/ECONNRESET. That case spawns the .cmd as argv[0] via cmd.exe /d /c scriptPath, not wrapWindowsHookCommand (same race noted on #14825).

AI Disclosure

Implemented and verified with Grok 4.6.

Review

  • Cross-platform: Windows-only encoded launcher. macOS/Linux keep wrapPosixHookCommand. Command-shape tests run on every CI OS; live window sampling is skipIf Windows-desktop / not CI.
  • SSH / remote / folder workspaces: remote Grok/Claude install still writes POSIX .sh via SFTP. Local folder workspaces and git worktrees share ~/.orca/agent-hooks/*.cmd.
  • Agent compatibility: Grok, Cursor, Gemini, Droid, Command Code, Copilot .cmd entries use this wrapper. Copilot .ps1 stays in-process &. Claude Windows lifecycle hooks use getWindowsManagedLifecycleHook (unchanged). Codex/Antigravity still use wrapWindowsCmdHookCommand bare argv[0] when the path is cmd-safe ([Bug] Windows: Antigravity agent hooks spawn a visible console (cmd.exe + powershell.exe) on every invocation and tool call #15117).
  • Stdout contract: child stdout is written back to the current stdout (not $null = ReadToEnd()), so Claude-hooks-compat JSON from [Bug]: Windows shell command failures #14818 is not dropped.
  • Hot path: Grok fires this twice per tool (PreToolUse + PostToolUse) plus other events. Extra cost is one cmd.exe with CreateNoWindow instead of a visible console; no native GUI launcher and no process-tree kill.
  • Security: FileName is absolute System32\cmd.exe from getWindowsSystem32Path, not PATH. Script path is PowerShell-literal and passed through delayed expansion, not interpolated onto an unquoted cmd line.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

Author

  • X / Twitter:

…dout

Hidden PowerShell cannot give a .cmd an inheritable console, so invoking the script with the call operator opens a titled conhost on every Grok tool event. Launch System32\cmd.exe through ProcessStartInfo with CreateNoWindow, relay stdout/stderr, and keep .ps1 on the in-process call operator.

Fixes #14828
Copilot AI lite review requested due to automatic review settings August 19, 2026 16:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e15a6dc5-3d6c-427c-b165-81e0407a15e4

📥 Commits

Reviewing files that changed from the base of the PR and between 0992d1f and e6b1e49.

📒 Files selected for processing (2)
  • src/main/agent-hooks/installer-utils.test.ts
  • src/main/agent-hooks/windows-powershell-hook-launcher.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

Windows .cmd hooks now use a no-window cmd.exe launcher through PowerShell. The launcher forwards standard streams, passes the script path through an environment variable, preserves literal exclamation marks, and propagates the exit code. Non-.cmd hooks continue to use direct PowerShell invocation. Tests cover command generation, stream handling, exit codes, path and environment escaping, stdin draining, and titled-window absence.

Merge Risk: ⚪ Minimal · up to e6b1e

The Windows hook launcher change is localized and preserves hook output and exit-code behavior; no actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes hiding Windows .cmd hook consoles while preserving stdout.
Description check ✅ Passed The description covers all required sections, links issue #14828, and provides detailed changes, rationale, testing, and compatibility notes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
src/main/agent-hooks/windows-powershell-hook-launcher.ts (1)

50-58: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Set the redirected stream encodings, and do not block on the stdin write.

Two points on the relay:

  • No StandardOutputEncoding or StandardErrorEncoding is set. The child cmd.exe writes in the console OEM codepage. Non-ASCII hook JSON can be corrupted before [Console]::Out.Write. Set the encodings on $psi to match [Console]::OutputEncoding.
  • $p.StandardInput.Write($stdin) blocks once the payload exceeds the pipe buffer and the hook does not read stdin. The child still exits and the broken pipe raises the caught IOException, so this delays rather than hangs, but an async write removes the stall.
♻️ Proposed encoding and non-blocking write
     '$psi.RedirectStandardError = $true',
+    '$psi.StandardOutputEncoding = [Console]::OutputEncoding',
+    '$psi.StandardErrorEncoding = [Console]::OutputEncoding',
     `$psi.EnvironmentVariables['ORCA_WINDOWS_HOOK_CMD'] = ${quotedScriptPath}`,
     '$stdin = [Console]::In.ReadToEnd()',
     '$p = [System.Diagnostics.Process]::Start($psi)',
     '$outTask = $p.StandardOutput.ReadToEndAsync()',
     '$errTask = $p.StandardError.ReadToEndAsync()',
-    'try { $p.StandardInput.Write($stdin); $p.StandardInput.Close() } catch [System.IO.IOException] {}',
+    'try { $null = $p.StandardInput.WriteAsync($stdin).ContinueWith({ param($t) $p.StandardInput.Close() }) } catch [System.IO.IOException] {}',

StandardOutputEncoding requires RedirectStandardOutput = $true, which is already set. Confirm the property is available on Windows PowerShell 5.1, which is the launcher target.

src/main/agent-hooks/installer-utils.test.ts (1)

622-640: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Pin the launcher argument string with a literal assertion.

Line 635 compares the decoded command with a string that buildWindowsNoWindowCmdHookInvocation produced, so that assertion passes for any launcher body. The toContain checks at 636-639 cover only the window flag, the executable path, and the variable name. A regression in $psi.Arguments or in the exit-code relay still passes.

Add literal assertions for the parts that carry the fix.

♻️ Proposed additional assertions
     expect(decoded).toContain("EnvironmentVariables['ORCA_WINDOWS_HOOK_CMD']")
+    expect(decoded).toContain('$psi.UseShellExecute = $false')
+    expect(decoded).toContain('exit $p.ExitCode')
     expect(decoded).not.toMatch(/& 'C:\\Users\\alice\\.orca\\agent-hooks\\codex-hook\.cmd'/)
src/main/agent-hooks/windows-hook-cmd-no-window.test.ts (1)

134-166: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Bound the sampler by the hook lifetime, and observe the hook stderr promise.

Two reliability points in this test:

  • The sampler stops after a fixed 5000 ms. PowerShell startup plus ping -n 4 consumes most of that budget, so the sampling window can close before a launcher window would appear. The test then passes without proving the fix. Keep sampling until the hook process closes, or raise titledWindowSampleMs well above the hook duration.
  • hookOutput.stderr is never awaited. A stream error rejects an unobserved promise and surfaces as an unhandled rejection instead of a test failure. Include it in the Promise.all.
♻️ Proposed test adjustments
-const titledWindowSampleMs = 5_000
+const titledWindowSampleMs = 12_000
-    const [hookCode, hookStdout, samplerStdout] = await Promise.all([
+    const [hookCode, hookStdout, , samplerStdout] = await Promise.all([
       hookOutput.close,
       hookOutput.stdout,
+      hookOutput.stderr,
       samplerOutput.stdout,
       samplerOutput.close
     ])

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a3a7825c-012a-4754-afeb-3d4aea96c57d

📥 Commits

Reviewing files that changed from the base of the PR and between 73f7767 and 389a00f.

📒 Files selected for processing (4)
  • src/main/agent-hooks/installer-utils.test.ts
  • src/main/agent-hooks/installer-utils.ts
  • src/main/agent-hooks/windows-hook-cmd-no-window.test.ts
  • src/main/agent-hooks/windows-powershell-hook-launcher.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Keep /v:on only to expand the quoted script path, then nest cmd /v:off so literal ! in hook bodies, env values, and paths is not eaten. Pin UseShellExecute/exit-code shape, sample titled windows until the hook exits, and cover bang characters in live Windows tests.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/main/agent-hooks/windows-powershell-hook-launcher.ts (1)

38-40: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use a Node path utility for the cmd.exe path.

Line 39 converts assumed / separators to \. Use path.win32.normalize() or construct this path with path.win32.join() instead.

Proposed change
+import { win32 } from 'node:path'
+
 const quotedCmd = quotePowerShellSingleQuoted(
-  getWindowsSystem32Path('cmd.exe').replaceAll('/', '\\')
+  win32.normalize(getWindowsSystem32Path('cmd.exe'))
 )

As per coding guidelines: “Use path.join or Electron/Node path utilities for file paths; never assume / or \.”

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 18da8ab1-46d8-4ce0-a0ea-9ff8c2b5f01f

📥 Commits

Reviewing files that changed from the base of the PR and between 389a00f and 0992d1f.

📒 Files selected for processing (3)
  • src/main/agent-hooks/installer-utils.test.ts
  • src/main/agent-hooks/windows-hook-cmd-no-window.test.ts
  • src/main/agent-hooks/windows-powershell-hook-launcher.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.

CreateProcess still needs a backslash System32 cmd.exe path. Use path.win32.normalize on the existing forward-slash System32 helper instead of replacing separators by hand.
@ynjmxn

ynjmxn commented Aug 20, 2026 •

Copy link
Copy Markdown
Author

Closing in favor of #15595, which registers the cmd-safe .cmd path directly and drops the extra interpreters.

@ynjmxn ynjmxn closed this Aug 20, 2026
brennanb2025 added a commit that referenced this pull request Aug 27, 2026
…ed flag pair (STA-5237)

`-WindowStyle Hidden` + `-EncodedCommand` is denied at CreateProcess by
Kaspersky on Windows 11, whatever the payload decodes to. Bash reports it as
`Permission denied` and every managed hook event fails, so agent status never
arrives; the parent shell also briefly cannot spawn anything afterwards, so a
denied hook can take the user's next command down with it.

Measured on the reporting host (#16003), with a harmless `exit 0` payload:

  -NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden -EncodedCommand  126
  -NoProfile -WindowStyle Hidden -EncodedCommand                          126
  -WindowStyle Hidden -EncodedCommand                                     126
  -NoProfile -EncodedCommand                                              0 (5/5)

#16576 removed `-ExecutionPolicy Bypass`, which is the one flag of the three
NOT in the signature, so hooks kept failing after that fix. The pair that has
to stop being spelled is `-WindowStyle Hidden` + `-EncodedCommand`.

Because the change is to the shared switch constant, it covers every site that
spells the denied pair in one edit: Claude via `wrapWindowsPowerShellEncodedCommand`,
gemini/cursor/droid/command-code/copilot via `wrapWindowsHookCommand`, the
`runtime-home-hook-command` unsafe-HOME fallback, and the spaced-path fallback
for codex/grok/devin/antigravity. Only a flag is removed, so parser and payload
compatibility is unchanged for every executor: the string is still a PowerShell
command line, still one self-contained token, still base64-shielded.

The tradeoff, recorded rather than hidden: `-WindowStyle Hidden` was the shipped
fix for #14815 (+#14828, #15117, #15447, #15767), and this removes it. Its
suppression was never measured — #14825 confirmed it visually, #16576's author
stated it "remains unverified on a real box", and #15506's author argued it
cannot help a `.cmd` child with no console to inherit. The console is allocated
by the parent chain, not by this command line. A live window measurement is
still outstanding and is called out in the PR.

Also adds `windows-hook-payload-delivery.test.ts` to the PR CI Windows leg,
which had never run it.
brennanb2025 added a commit that referenced this pull request Aug 27, 2026
…ed flag pair (STA-5237)

`-WindowStyle Hidden` + `-EncodedCommand` is denied at CreateProcess by
Kaspersky on Windows 11, whatever the payload decodes to. Bash reports it as
`Permission denied` and every managed hook event fails, so agent status never
arrives; the parent shell also briefly cannot spawn anything afterwards, so a
denied hook can take the user's next command down with it.

Measured on the reporting host (#16003), with a harmless `exit 0` payload:

  -NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden -EncodedCommand  126
  -NoProfile -WindowStyle Hidden -EncodedCommand                          126
  -WindowStyle Hidden -EncodedCommand                                     126
  -NoProfile -EncodedCommand                                              0 (5/5)

#16576 removed `-ExecutionPolicy Bypass`, which is the one flag of the three
NOT in the signature, so hooks kept failing after that fix. The pair that has
to stop being spelled is `-WindowStyle Hidden` + `-EncodedCommand`.

Because the change is to the shared switch constant, it covers every site that
spells the denied pair in one edit: Claude via `wrapWindowsPowerShellEncodedCommand`,
gemini/cursor/droid/command-code/copilot via `wrapWindowsHookCommand`, the
`runtime-home-hook-command` unsafe-HOME fallback, and the spaced-path fallback
for codex/grok/devin/antigravity. Only a flag is removed, so parser and payload
compatibility is unchanged for every executor: the string is still a PowerShell
command line, still one self-contained token, still base64-shielded.

The tradeoff, recorded rather than hidden: `-WindowStyle Hidden` was the shipped
fix for #14815 (+#14828, #15117, #15447, #15767), and this removes it. Its
suppression was never measured — #14825 confirmed it visually, #16576's author
stated it "remains unverified on a real box", and #15506's author argued it
cannot help a `.cmd` child with no console to inherit. The console is allocated
by the parent chain, not by this command line. A live window measurement is
still outstanding and is called out in the PR.

Also adds `windows-hook-payload-delivery.test.ts` to the PR CI Windows leg,
which had never run it.
brennanb2025 added a commit that referenced this pull request Aug 27, 2026
…ed flag pair (STA-5237) (#16739)

* fix(agent-hooks): stop the Windows hook launcher spelling the AV-denied flag pair (STA-5237)

`-WindowStyle Hidden` + `-EncodedCommand` is denied at CreateProcess by
Kaspersky on Windows 11, whatever the payload decodes to. Bash reports it as
`Permission denied` and every managed hook event fails, so agent status never
arrives; the parent shell also briefly cannot spawn anything afterwards, so a
denied hook can take the user's next command down with it.

Measured on the reporting host (#16003), with a harmless `exit 0` payload:

  -NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden -EncodedCommand  126
  -NoProfile -WindowStyle Hidden -EncodedCommand                          126
  -WindowStyle Hidden -EncodedCommand                                     126
  -NoProfile -EncodedCommand                                              0 (5/5)

#16576 removed `-ExecutionPolicy Bypass`, which is the one flag of the three
NOT in the signature, so hooks kept failing after that fix. The pair that has
to stop being spelled is `-WindowStyle Hidden` + `-EncodedCommand`.

Because the change is to the shared switch constant, it covers every site that
spells the denied pair in one edit: Claude via `wrapWindowsPowerShellEncodedCommand`,
gemini/cursor/droid/command-code/copilot via `wrapWindowsHookCommand`, the
`runtime-home-hook-command` unsafe-HOME fallback, and the spaced-path fallback
for codex/grok/devin/antigravity. Only a flag is removed, so parser and payload
compatibility is unchanged for every executor: the string is still a PowerShell
command line, still one self-contained token, still base64-shielded.

The tradeoff, recorded rather than hidden: `-WindowStyle Hidden` was the shipped
fix for #14815 (+#14828, #15117, #15447, #15767), and this removes it. Its
suppression was never measured — #14825 confirmed it visually, #16576's author
stated it "remains unverified on a real box", and #15506's author argued it
cannot help a `.cmd` child with no console to inherit. The console is allocated
by the parent chain, not by this command line. A live window measurement is
still outstanding and is called out in the PR.

Also adds `windows-hook-payload-delivery.test.ts` to the PR CI Windows leg,
which had never run it.

* test(agent-hooks): keep launcher token out of source grep
paidaxingyo666 pushed a commit to paidaxingyo666/Manta that referenced this pull request Aug 30, 2026
…ed flag pair (STA-5237) (stablyai#16739)

* fix(agent-hooks): stop the Windows hook launcher spelling the AV-denied flag pair (STA-5237)

`-WindowStyle Hidden` + `-EncodedCommand` is denied at CreateProcess by
Kaspersky on Windows 11, whatever the payload decodes to. Bash reports it as
`Permission denied` and every managed hook event fails, so agent status never
arrives; the parent shell also briefly cannot spawn anything afterwards, so a
denied hook can take the user's next command down with it.

Measured on the reporting host (stablyai#16003), with a harmless `exit 0` payload:

  -NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden -EncodedCommand  126
  -NoProfile -WindowStyle Hidden -EncodedCommand                          126
  -WindowStyle Hidden -EncodedCommand                                     126
  -NoProfile -EncodedCommand                                              0 (5/5)

NOT in the signature, so hooks kept failing after that fix. The pair that has
to stop being spelled is `-WindowStyle Hidden` + `-EncodedCommand`.

Because the change is to the shared switch constant, it covers every site that
spells the denied pair in one edit: Claude via `wrapWindowsPowerShellEncodedCommand`,
gemini/cursor/droid/command-code/copilot via `wrapWindowsHookCommand`, the
`runtime-home-hook-command` unsafe-HOME fallback, and the spaced-path fallback
for codex/grok/devin/antigravity. Only a flag is removed, so parser and payload
compatibility is unchanged for every executor: the string is still a PowerShell
command line, still one self-contained token, still base64-shielded.

The tradeoff, recorded rather than hidden: `-WindowStyle Hidden` was the shipped
fix for stablyai#14815 (+stablyai#14828, stablyai#15117, stablyai#15447, stablyai#15767), and this removes it. Its
suppression was never measured — stablyai#14825 confirmed it visually, stablyai#16576's author
stated it "remains unverified on a real box", and stablyai#15506's author argued it
cannot help a `.cmd` child with no console to inherit. The console is allocated
by the parent chain, not by this command line. A live window measurement is
still outstanding and is called out in the PR.

Also adds `windows-hook-payload-delivery.test.ts` to the PR CI Windows leg,
which had never run it.

* test(agent-hooks): keep launcher token out of source grep

(cherry picked from commit 928d306)
@ynjmxn
ynjmxn deleted the fix/windows-hook-cmd-no-window branch September 26, 2026 11:41
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…ed flag pair (STA-5237) (stablyai#16739)

* fix(agent-hooks): stop the Windows hook launcher spelling the AV-denied flag pair (STA-5237)

`-WindowStyle Hidden` + `-EncodedCommand` is denied at CreateProcess by
Kaspersky on Windows 11, whatever the payload decodes to. Bash reports it as
`Permission denied` and every managed hook event fails, so agent status never
arrives; the parent shell also briefly cannot spawn anything afterwards, so a
denied hook can take the user's next command down with it.

Measured on the reporting host (stablyai#16003), with a harmless `exit 0` payload:

  -NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden -EncodedCommand  126
  -NoProfile -WindowStyle Hidden -EncodedCommand                          126
  -WindowStyle Hidden -EncodedCommand                                     126
  -NoProfile -EncodedCommand                                              0 (5/5)

stablyai#16576 removed `-ExecutionPolicy Bypass`, which is the one flag of the three
NOT in the signature, so hooks kept failing after that fix. The pair that has
to stop being spelled is `-WindowStyle Hidden` + `-EncodedCommand`.

Because the change is to the shared switch constant, it covers every site that
spells the denied pair in one edit: Claude via `wrapWindowsPowerShellEncodedCommand`,
gemini/cursor/droid/command-code/copilot via `wrapWindowsHookCommand`, the
`runtime-home-hook-command` unsafe-HOME fallback, and the spaced-path fallback
for codex/grok/devin/antigravity. Only a flag is removed, so parser and payload
compatibility is unchanged for every executor: the string is still a PowerShell
command line, still one self-contained token, still base64-shielded.

The tradeoff, recorded rather than hidden: `-WindowStyle Hidden` was the shipped
fix for stablyai#14815 (+stablyai#14828, stablyai#15117, stablyai#15447, stablyai#15767), and this removes it. Its
suppression was never measured — stablyai#14825 confirmed it visually, stablyai#16576's author
stated it "remains unverified on a real box", and stablyai#15506's author argued it
cannot help a `.cmd` child with no console to inherit. The console is allocated
by the parent chain, not by this command line. A live window measurement is
still outstanding and is called out in the PR.

Also adds `windows-hook-payload-delivery.test.ts` to the PR CI Windows leg,
which had never run it.

* test(agent-hooks): keep launcher token out of source grep
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Windows: Grok agent hooks flash a visible console and steal keyboard focus on every tool call

2 participants