Files
reverse-engineering-anything/src/apktool/ApktoolCommandOutput.ts
T
morlutoandPeter cc038da218 fix(apktool): attribute decode refusals to the selected APK
Carry caller-selected target identity separately from launcher selection. Only fully collected ordinary nonzero decode exits represent target refusals; startup, preparation, capture and signal failures retain provider attribution. Reuse one command/preparation output projection for probe and decode errors.

Adapt the target-path correction from PR #3462 (08d3d0d3a0) and extend its producer-boundary classification and regression coverage.

Validation: 131 focused tests in 12 files, final 50 source checks, build, typecheck/lint and docs. Ten regression controls fail on baseline 4844ae812. Twenty-four tiny actual CLI/stdio MCP refusal tasks preserve every projected field except the corrected message/path. Authored launchers only; no real Apktool/JVM or native Windows claim. Heavy stress/profiling remained stopped.

Closes #3340

Co-authored-by: Peter <304086198+peter-research@users.noreply.github.com>
2026-10-17 22:44:00 +08:00

32 lines
1.3 KiB
TypeScript

import { OwnedCommandFailure } from "../process/OwnedCommand.js";
import { DarwinProcessOwnershipInspectionError } from "../process/DarwinProcessRunTokenReader.js";
import type { AnalysisCapturedOutput } from "../domain/analysisErrorBase.js";
import type { ProviderProcessSnapshot } from "../process/ProviderProcess.js";
/** Project the command owner's bounded output without losing examined byte counts. */
const capturedApktoolCommandOutput = (
output: ProviderProcessSnapshot,
): AnalysisCapturedOutput => ({
stdout: output.stdout.text,
stderr: output.stderr.text,
truncated:
output.diagnosticTruncated === true || output.outputIncomplete === true,
stdout_bytes: output.stdout.observedBytes,
stderr_bytes: output.stderr.observedBytes,
exit_code: output.exitCode ?? null,
signal: output.signal ?? null,
});
/** The command owner selects command output or preparation output, once. */
export const capturedApktoolFailureOutput = (
cause: unknown,
): AnalysisCapturedOutput | undefined => {
if (cause instanceof OwnedCommandFailure)
return cause.snapshot === null
? cause.preparationFailure?.capturedOutput
: capturedApktoolCommandOutput(cause.snapshot);
return cause instanceof DarwinProcessOwnershipInspectionError
? cause.capturedOutput
: undefined;
};