From 625e3a1ab22955fd513cfe343ee0c49b5e93d782 Mon Sep 17 00:00:00 2001 From: Lyon <88232613+pikasTech@users.noreply.github.com> Date: Mon, 22 Jun 2026 04:05:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=86=E5=88=86=20AgentRun=20unreachable=20?= =?UTF-8?q?=E5=88=86=E7=B1=BB=20(#626)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Codex --- scripts/src/agentrun.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/scripts/src/agentrun.ts b/scripts/src/agentrun.ts index dff7829d..a42d1420 100644 --- a/scripts/src/agentrun.ts +++ b/scripts/src/agentrun.ts @@ -6091,7 +6091,7 @@ async function agentRunRestRequest(command: string, method: AgentRunHttpMethod, response = await fetch(new URL(pathValue, clientConfig.manager.baseUrl), init); } catch (error) { const timedOut = isAbortLikeError(error); - throw new AgentRunRestError(timedOut ? "agentrun-timeout" : "agentrun-unreachable", timedOut ? `AgentRun server request timed out for ${method} ${pathValue} after ${clientConfig.manager.timeoutMs}ms` : `AgentRun server is unreachable for ${method} ${pathValue}: ${error instanceof Error ? error.message : String(error)}`, { bridge: { ...bridgeBase, elapsedMs: Date.now() - startedAt } }); + throw new AgentRunRestError(timedOut ? "agentrun-timeout" : "agentrun-connect-failed", timedOut ? `AgentRun server request timed out for ${method} ${pathValue} after ${clientConfig.manager.timeoutMs}ms` : `AgentRun server connection failed for ${method} ${pathValue}: ${error instanceof Error ? error.message : String(error)}`, { bridge: { ...bridgeBase, elapsedMs: Date.now() - startedAt } }); } finally { clearTimeout(timeout); } @@ -6148,12 +6148,12 @@ async function agentRunLaneRestRequest(command: string, method: AgentRunHttpMeth const captureSummary = compactCapture(captureResult, { full: false, stdoutTailChars: 1200, stderrTailChars: 2000 }); const bridge = { ...bridgeBase, elapsedMs: Date.now() - startedAt, capture: captureSummary }; if (captureResult.exitCode !== 0) { - throw new AgentRunRestError("agentrun-unreachable", `AgentRun lane ${target.spec.nodeId}/${target.spec.lane} manager proxy failed for ${method} ${pathValue}`, { bridge }); + throw new AgentRunRestError("agentrun-proxy-exec-failed", `AgentRun lane ${target.spec.nodeId}/${target.spec.lane} manager proxy execution failed for ${method} ${pathValue}`, { bridge }); } const proxy = captureJsonPayload(captureResult); if (proxy.ok !== true) { const proxyFailureKind = stringOrNull(proxy.failureKind); - const failureKind: AgentRunFailureKind = proxyFailureKind === "manager-pod-fetch-timeout" ? "agentrun-timeout" : "agentrun-unreachable"; + const failureKind = classifyAgentRunProxyFailureKind(proxyFailureKind); throw new AgentRunRestError(failureKind, stringOrNull(proxy.message) ?? `AgentRun lane ${target.spec.nodeId}/${target.spec.lane} manager proxy failed`, { bridge: { ...bridge, proxy }, details: pickCompact(proxy, ["ok", "failureKind", "message", "elapsedMs", "path", "baseUrl", "valuesPrinted"]) }); } const httpStatus = nonNegativeIntegerOrNull(proxy.httpStatus) ?? 0; @@ -6844,12 +6844,20 @@ function safeAgentRunEnvelope(envelope: Record): Record, key: string, pathValue: string): string { const value = obj[key]; if (typeof value !== "string" || value.trim().length === 0) throw new Error(`${pathValue}.${key} must be a non-empty string`); @@ -6934,7 +6942,7 @@ interface AgentRunResolvedAuth { } type AgentRunHttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE"; -type AgentRunFailureKind = "auth-missing" | "auth-failed" | "agentrun-unreachable" | "agentrun-timeout" | "schema-mismatch" | "unsupported-version" | "validation-failed" | "not-found"; +type AgentRunFailureKind = "auth-missing" | "auth-failed" | "agentrun-connect-failed" | "agentrun-proxy-exec-failed" | "agentrun-manager-fetch-failed" | "agentrun-timeout" | "schema-mismatch" | "unsupported-version" | "validation-failed" | "not-found"; type AgentRunRestCompatGroup = "queue" | "sessions" | "aipod-specs" | "aipods" | "runs" | "commands" | "runner"; type AgentRunResourceVerb = "get" | "describe" | "events" | "logs" | "result" | "ack" | "cancel" | "dispatch" | "create" | "apply" | "send" | "explain";