fix: simplify agentrun cli entrypoints
This commit is contained in:
+11
-2
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user