/** * Workflow-specific error types. */ export declare enum WorkflowErrorCode { /** Agent exceeded timeout. */ AGENT_TIMEOUT = "AGENT_TIMEOUT", /** Workflow was aborted by user. */ WORKFLOW_ABORTED = "WORKFLOW_ABORTED", /** Workflow exceeded its wall-clock runtime timeout. */ WORKFLOW_TIMEOUT = "WORKFLOW_TIMEOUT", /** Agent limit exceeded. */ AGENT_LIMIT_EXCEEDED = "AGENT_LIMIT_EXCEEDED", /** A selected harness runtime/config is not wired to this runtime (e.g. opencode/hermes). */ HARNESS_NOT_WIRED = "HARNESS_NOT_WIRED", /** Token budget exhausted. */ TOKEN_BUDGET_EXHAUSTED = "TOKEN_BUDGET_EXHAUSTED", /** Subagent exceeded its configured/effective context-window guardrail. */ CONTEXT_WINDOW_EXCEEDED = "CONTEXT_WINDOW_EXCEEDED", /** * The provider's subscription/usage/quota/rate limit was hit. Distinct from the * user's self-imposed TOKEN_BUDGET_EXHAUSTED: a provider limit refills on its own, * so the run is checkpointed (paused) and replayed by resume() rather than failed. */ PROVIDER_USAGE_LIMIT = "PROVIDER_USAGE_LIMIT", /** Script validation failed. */ SCRIPT_VALIDATION_ERROR = "SCRIPT_VALIDATION_ERROR", /** A schema agent never produced valid structured_output (after repair + extraction). */ SCHEMA_NONCOMPLIANCE = "SCHEMA_NONCOMPLIANCE", /** A non-schema agent completed without any assistant text output. */ AGENT_EMPTY_OUTPUT = "AGENT_EMPTY_OUTPUT", /** Agent execution failed. */ AGENT_EXECUTION_ERROR = "AGENT_EXECUTION_ERROR", /** Run state persistence failed. */ PERSISTENCE_ERROR = "PERSISTENCE_ERROR", /** Unknown error. */ UNKNOWN = "UNKNOWN" } export declare class WorkflowError extends Error { readonly code: WorkflowErrorCode; readonly recoverable: boolean; readonly agentLabel?: string; readonly details?: unknown; /** For PROVIDER_USAGE_LIMIT: the provider's human reset hint, e.g. "Resets in ~3h" (verbatim). */ readonly resetHint?: string; constructor(message: string, code: WorkflowErrorCode, options?: { recoverable?: boolean; agentLabel?: string; details?: unknown; resetHint?: string; }); } export declare function isWorkflowError(error: unknown): error is WorkflowError; export declare function isProviderUsageLimit(error: unknown): error is WorkflowError; /** * Detect a provider subscription/usage/quota/rate-limit exhaustion from free-form * error text, and extract the provider's human reset hint when present. * * The pi SDK does NOT throw these — it records them as an assistant message with * stopReason "error" and an errorMessage like "Codex usage limit reached (plus * plan). Resets in ~3h.". Callers reading message metadata MUST gate on * stopReason === "error" before trusting this, so a task whose own output merely * mentions "rate limit" is never misclassified. Patterns mirror the SDK's own * non-retryable-limit table. Deliberately excludes transient overloaded/5xx * errors, which stay recoverable and keep retrying. */ export declare function classifyProviderLimit(text: string | undefined): { matched: boolean; resetHint?: string; }; export declare function isAbortError(error: unknown): boolean; export declare function isTimeoutError(error: unknown): boolean; /** * Wrap an unknown error into a WorkflowError with appropriate classification. */ export declare function wrapError(error: unknown, context?: { agentLabel?: string; }): WorkflowError;