Fix(ogagent): preserve PowerShell exit code when redirecting output
ogagent/pipeline/head This commit looks good
Details
ogagent/pipeline/head This commit looks good
Details
parent
43c57ea320
commit
5b286e005c
|
|
@ -5,8 +5,14 @@ All notable changes to this project will be documented in this file.
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
## [8.5.6] - 2026-07-21
|
## [8.5.9] - 2026-07-23
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Preserve original exit code in Windows PowerShell script wrapper when redirecting streams, ensuring ogcore receives failure status (e.g., CommandNotFoundException).
|
||||||
|
- Prevent raw PowerShell CLIXML output from leaking into stderr on Windows when a command fails non-interactively.
|
||||||
|
- Send `START_SCRIPT` webhook when a script is picked up by the agent, ensuring the UI correctly displays the "In Progress" trace state. Applies to both admin (`client=false`) and user-session (`client=true`) execution paths.
|
||||||
|
|
||||||
|
## [8.5.6] - 2026-07-21
|
||||||
### Added
|
### Added
|
||||||
- Notify `ogcore` via webhook when natively executed scripts finish, bringing `ogagent` in line with `ogLive` functionality (resolves stuck traces in "Enviada" state).
|
- Notify `ogcore` via webhook when natively executed scripts finish, bringing `ogagent` in line with `ogLive` functionality (resolves stuck traces in "Enviada" state).
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -152,7 +152,7 @@ def get_etc_path():
|
||||||
def build_popen_args(script):
|
def build_popen_args(script):
|
||||||
## turn the script into utf16le, then to b64 again, and feed the blob to powershell
|
## turn the script into utf16le, then to b64 again, and feed the blob to powershell
|
||||||
## wrap the script to redirect stderr and output as a simple string to avoid CLIXML wrappers in non-interactive errors
|
## wrap the script to redirect stderr and output as a simple string to avoid CLIXML wrappers in non-interactive errors
|
||||||
script = f"& {{ {script} }} 2>&1 | Out-String"
|
script = f"$ProgressPreference = 'SilentlyContinue'; try {{ $errBefore = $Error.Count; $output = & {{ {script} }} 2>&1; $errAfter = $Error.Count; $exitcode = $LASTEXITCODE; $output | Out-String; if ($exitcode) {{ exit $exitcode }} elseif ($errAfter -gt $errBefore) {{ exit 1 }} }} catch {{ $_ | Out-String; exit 1 }}"
|
||||||
u16 = script.encode ('utf-16le') ## utf16
|
u16 = script.encode ('utf-16le') ## utf16
|
||||||
b64 = base64.b64encode (u16).decode ('utf-8') ## b64 (which returns bytes, so we need an additional decode(utf8))
|
b64 = base64.b64encode (u16).decode ('utf-8') ## b64 (which returns bytes, so we need an additional decode(utf8))
|
||||||
return ['powershell', '-WindowStyle', 'Hidden', '-EncodedCommand', b64]
|
return ['powershell', '-WindowStyle', 'Hidden', '-EncodedCommand', b64]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue