fix: simplify agentrun cli entrypoints

This commit is contained in:
Codex
2026-06-11 00:41:20 +00:00
parent 4068d64555
commit 23e2a6e3e2
22 changed files with 342 additions and 199 deletions
+11 -2
View File
@@ -97,14 +97,23 @@ function renderEnvelope<T>(command: string, envelope: JsonEnvelope<T>): string {
}
function shouldDumpLargeOutput(command: string, text: string, envelope: JsonEnvelope<unknown>): boolean {
if (!(command === "gh" || command.startsWith("gh "))) return false;
if (process.env.UNIDESK_CLI_GH_OUTPUT_DUMP_DISABLED === "1") return false;
if (!isLargeOutputDumpCommand(command)) return false;
if (process.env.UNIDESK_CLI_GH_OUTPUT_DUMP_DISABLED === "1" || process.env.UNIDESK_CLI_OUTPUT_DUMP_DISABLED === "1") return false;
if (typeof envelope.data === "object" && envelope.data !== null && (envelope.data as { noDump?: unknown }).noDump === true) return false;
const threshold = configuredDumpThresholdBytes();
return Buffer.byteLength(text, "utf8") > threshold;
}
function isLargeOutputDumpCommand(command: string): boolean {
return command === "gh" || command.startsWith("gh ") || command === "agentrun" || command.startsWith("agentrun ");
}
function configuredDumpThresholdBytes(): number {
const genericRaw = process.env.UNIDESK_CLI_OUTPUT_DUMP_THRESHOLD_BYTES;
if (genericRaw !== undefined && genericRaw.trim().length > 0) {
const genericValue = Number(genericRaw);
if (Number.isInteger(genericValue) && genericValue > 0) return genericValue;
}
const raw = process.env.UNIDESK_CLI_GH_OUTPUT_DUMP_THRESHOLD_BYTES;
if (raw === undefined || raw.trim().length === 0) return GH_OUTPUT_DUMP_THRESHOLD_BYTES;
const value = Number(raw);