mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-08 15:23:57 +00:00
28 lines
951 B
TypeScript
28 lines
951 B
TypeScript
/** Agent run phases used when attributing timeout/cancellation sources. */
|
|
const AGENT_RUN_TIMEOUT_PHASES = [
|
|
"queue",
|
|
"preflight",
|
|
"provider",
|
|
"post_turn",
|
|
"gateway_draining",
|
|
] as const;
|
|
|
|
/** Timeout attribution phase for agent run lifecycle spans. */
|
|
export type AgentRunTimeoutPhase = (typeof AGENT_RUN_TIMEOUT_PHASES)[number];
|
|
|
|
const AGENT_RUN_TIMEOUT_PHASE_SET = new Set<string>(AGENT_RUN_TIMEOUT_PHASES);
|
|
|
|
/** Normalizes raw timeout phase metadata into a known agent run phase. */
|
|
export function normalizeAgentRunTimeoutPhase(value: unknown): AgentRunTimeoutPhase | undefined {
|
|
if (typeof value !== "string") {
|
|
return undefined;
|
|
}
|
|
const normalized = value.trim();
|
|
return AGENT_RUN_TIMEOUT_PHASE_SET.has(normalized)
|
|
? (normalized as AgentRunTimeoutPhase)
|
|
: undefined;
|
|
}
|
|
|
|
/** Normalizes provider-started timeout attribution metadata. */
|
|
export { asBoolean as normalizeProviderStarted } from "../utils/boolean.js";
|