eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
71 lines (70 loc) • 3.7 kB
TypeScript
/**
* Error classification and display formatting shared by the TUI runner and
* terminal renderer. One module owns the interrupt sentinel and the
* failure-event projections so the two sides cannot drift apart.
*/
import type { SessionFailedStreamEvent, StepFailedStreamEvent, TurnFailedStreamEvent } from "#client/index.js";
/**
* One of the failure events a session stream can carry. All three share the
* same `{ code, message, details? }` payload shape — the harness emits them
* as a cascade (`step.failed` → `turn.failed` → `session.failed` /
* `session.waiting`) describing a single underlying failure.
*/
export type FailureStreamEvent = StepFailedStreamEvent | TurnFailedStreamEvent | SessionFailedStreamEvent;
/**
* Thrown when the user interrupts the TUI (Ctrl+C, or Ctrl+D on an empty
* prompt). The runner treats it as a clean exit, never as a failure.
*/
export declare class InterruptedError extends Error {
constructor();
}
export declare function interruptedError(): InterruptedError;
export declare function isInterruptedError(error: unknown): boolean;
/**
* Recognizes errors raised by aborting an in-flight fetch/stream (e.g. the
* subagent child-session pump being cancelled). These are expected shutdown
* noise, not failures to surface.
*/
export declare function isAbortLikeError(error: unknown): boolean;
/**
* Stable identity for one failure cascade entry. The harness emits the same
* `{ code, message }` payload on `step.failed`, `turn.failed`, and (for
* terminal failures) `session.failed`; keying on both lets the stream
* translator render the underlying failure exactly once.
*/
export declare function failureKey(event: FailureStreamEvent): string;
/**
* One-line headline for a failure event: `code: message`, except when the
* message already carries its own class-name prefix (e.g. a
* `HookConflictError` whose message starts with `HookConflictError:`), in
* which case the message stands alone instead of reading `Code: Code: …`.
*/
export declare function formatFailureMessage(event: FailureStreamEvent): string;
/**
* Extracts the diagnostic dump attached to a failure event, if any.
*
* `details.detail` is the `util.inspect` rendering (stack trace and cause
* chain included) that `formatError` attaches to *unrecognized* failures —
* i.e. code bugs escaping user code. Recognized provider/config failures
* deliberately ship a curated summary without the dump, so this returns
* `undefined` for them and the headline stands alone.
*/
export declare function formatFailureDetail(event: FailureStreamEvent): string | undefined;
/**
* Minimal TUI rendering for a gateway-auth failure when `/model` is available
* locally. Replaces the harness's full summary — whose remediation names CLI
* commands and dashboard URLs — with one actionable line; the caller drops
* the diagnostic detail along with it. The variant is picked off the summary
* message the harness wrote, so a stale key, an expired OIDC token, and
* missing credentials each get the fix that actually applies.
*/
export declare function formatGatewayAuthFailureNotice(event: FailureStreamEvent): string;
/**
* Recognizes a model-call failure caused by AI Gateway authentication. The
* primary signal is the machine-readable `gatewayName` the harness merges
* into every model-call failure's details (`extractModelCallErrorDetails`);
* the summary name is the fallback for payloads whose gateway error was not
* preserved on the cause chain. Both identifiers are imported from the
* harness module that writes them, so the two sides cannot drift.
*/
export declare function isGatewayAuthFailure(event: FailureStreamEvent): boolean;