fix(runner): read ACPX output error codes

This commit is contained in:
Dotta 2026-09-02 23:00:28 -05:00
parent 534ce69adb
commit 156c913779
2 changed files with 14 additions and 2 deletions

View File

@ -131,11 +131,14 @@ describe("ACPX sidecar input sequencing", () => {
detailCode: "AGENT_STARTUP_FAILED",
});
const genericStartup = Object.assign(new Error("provider exited"), {
code: "RUNTIME",
outputCode: "RUNTIME",
detailCode: "AGENT_STARTUP_FAILED",
stderrSummary: "Error [ERR_MODULE_NOT_FOUND]: package was not found",
exitCode: 1,
});
const genericRuntime = Object.assign(new Error("provider rejected"), {
outputCode: "RUNTIME",
});
const nestedHandshake = new AggregateError(
[
Object.assign(new Error("admission deadline"), {
@ -162,6 +165,7 @@ describe("ACPX sidecar input sequencing", () => {
expect(acpxSidecarErrorCode(genericStartup)).toBe(
"AGENT_STARTUP_FAILED.MODULE_NOT_FOUND",
);
expect(acpxSidecarErrorCode(genericRuntime)).toBe("RUNTIME");
expect(acpxSidecarErrorCode(codedWrapper)).toBe(
"AGENT_STARTUP_FAILED.MODULE_NOT_FOUND",
);

View File

@ -57,7 +57,15 @@ export function acpxSidecarErrorCode(error: Error): string {
function directAcpxSidecarErrorCode(error: Error): string | null {
const details = error as Error & Record<string, unknown>;
const outputCode = typeof details.code === "string" ? details.code : null;
// AcpxOperationalError publishes its presentation category as outputCode;
// Node/system errors conventionally use code. Accept the ACPX field first
// while retaining the latter for closed launch failures.
const outputCode =
typeof details.outputCode === "string"
? details.outputCode
: typeof details.code === "string"
? details.code
: null;
const detailCode =
typeof details.detailCode === "string" ? details.detailCode : null;
// ACPX output errors may carry both a broad presentation code (for example,