拆分 AgentRun unreachable 分类 (#626)
Co-authored-by: Codex <codex@noreply.local>
This commit is contained in:
+13
-5
@@ -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<string, unknown>): Record<string,
|
||||
}
|
||||
|
||||
function normalizeAgentRunFailureKind(raw: string | null, httpStatus: number): AgentRunFailureKind {
|
||||
if (raw === "auth-missing" || raw === "auth-failed" || raw === "agentrun-unreachable" || raw === "agentrun-timeout" || raw === "schema-mismatch" || raw === "unsupported-version" || raw === "validation-failed" || raw === "not-found") return raw;
|
||||
if (raw === "agentrun-unreachable") return "agentrun-connect-failed";
|
||||
if (raw === "auth-missing" || raw === "auth-failed" || raw === "agentrun-connect-failed" || raw === "agentrun-proxy-exec-failed" || raw === "agentrun-manager-fetch-failed" || raw === "agentrun-timeout" || raw === "schema-mismatch" || raw === "unsupported-version" || raw === "validation-failed" || raw === "not-found") return raw;
|
||||
if (httpStatus === 401 || httpStatus === 403) return "auth-failed";
|
||||
if (httpStatus === 404) return "not-found";
|
||||
return raw === "schema-invalid" ? "validation-failed" : "validation-failed";
|
||||
}
|
||||
|
||||
function classifyAgentRunProxyFailureKind(raw: string | null): AgentRunFailureKind {
|
||||
if (raw === "manager-pod-fetch-timeout" || raw === "agentrun-timeout") return "agentrun-timeout";
|
||||
if (raw === "manager-pod-fetch-failed") return "agentrun-manager-fetch-failed";
|
||||
const normalized = normalizeAgentRunFailureKind(raw, 0);
|
||||
return normalized === "validation-failed" ? "agentrun-proxy-exec-failed" : normalized;
|
||||
}
|
||||
|
||||
function stringFieldFromRecord(obj: Record<string, unknown>, 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";
|
||||
|
||||
Reference in New Issue
Block a user