//#region src/errors/index.d.ts /** * Typed error surface for `@graphorin/agent`. * * Every error class extends the base {@link AgentRuntimeError} which is * a thin wrapper around `Error` with a stable `code` discriminator so * callers can `switch` on it without parsing messages. * * @packageDocumentation */ /** * Stable code discriminator surfaced on every {@link AgentRuntimeError}. * * @stable */ type AgentRuntimeErrorCode = 'invalid-config' | 'invalid-preferred-model' | 'invalid-fallback-policy' | 'invalid-evaluator-optimizer-config' | 'agent-resolution-failed' | 'tool-not-found' | 'handoff-target-not-found' | 'multiple-handoffs-in-step' | 'sub-run-resume-target-not-found' | 'run-aborted' | 'middleware-order-violation' | 'progress-write-failed' | 'merge-blocked' | 'protocol-injection-rejected' | 'run-state-version-unsupported' | 'run-state-malformed' | 'concurrent-run' | 'budget-exceeded' | 'budget-unpriced'; /** * Base class for every error thrown from `@graphorin/agent`. * * @stable */ declare class AgentRuntimeError extends Error { readonly code: AgentRuntimeErrorCode; constructor(code: AgentRuntimeErrorCode, message: string, name?: string, opts?: { readonly cause?: unknown; }); } /** * Thrown by `createAgent({...})` when the supplied options fail * structural validation (missing `provider`, empty `name`, an * `outputType` of kind `'text'` carrying a `schema`, ...). * * @stable */ declare class InvalidAgentConfigError extends AgentRuntimeError { constructor(reason: string); } /** * Thrown by `createAgent({...})` when `preferredModel` carries an * unknown literal (any value outside the `'fast' | 'balanced' | * 'smart'` cost-tier vocabulary AND not a valid `ModelSpec`). * * @stable */ declare class InvalidPreferredModelError extends AgentRuntimeError { readonly value: unknown; constructor(value: unknown); } /** * Thrown by `evaluatorOptimizer({...})` when `maxIterations < 1` at * construction time. The helper purposely surfaces the misuse early * rather than failing on the first run. * * @stable */ declare class EvaluatorOptimizerConfigError extends AgentRuntimeError { constructor(reason: string); } /** * Thrown by `runStateFromJSON(...)` when the agent name in the * serialized state cannot be resolved against the supplied agent * graph (renamed agent / removed handoff). * * @stable */ declare class AgentResolutionError extends AgentRuntimeError { readonly agentId: string; constructor(agentId: string); } /** * Thrown by the agent loop when the model emits a tool call referring * to an unregistered tool (the model hallucinated a name). * * @stable */ declare class ToolNotFoundError extends AgentRuntimeError { readonly toolName: string; constructor(toolName: string); } /** * Thrown when the model invokes more than one handoff (`transfer_to_*`) * tool in a single response. Per the agent-loop documentation this is * an error rather than a silent drop. * * @stable */ /** * Thrown when a second `run()` / `stream()` starts while another run is * in flight on the same `Agent` instance. The public surface * (`steer` / `followUp` / `abort` / `compact`) addresses "the run" * without a run handle, so overlapping runs would share the abort * controller, steer queue, and executor bridge - start the second run * on its own `createAgent(...)` instance instead. * * @stable */ declare class ConcurrentRunError extends AgentRuntimeError { constructor(); } declare class MultipleHandoffsInStepError extends AgentRuntimeError { readonly handoffNames: ReadonlyArray; constructor(handoffNames: ReadonlyArray); } /** * Thrown when a resume directive routes a decision into a parked * sub-agent run but the resuming agent instance cannot resolve * the target: the parked toolName matches neither a configured handoff * target nor a `toTool` sub-agent tool. Resume a parked sub-run on the * SAME parent instance (or an identically-configured one). * * @stable */ declare class SubAgentResumeTargetNotFoundError extends AgentRuntimeError { readonly toolName: string; constructor(toolName: string, detail: string); } /** * Thrown by `runStateFromJSON(...)` when the version field in the * serialized state is from a future major version of the framework. * * @stable */ declare class RunStateVersionUnsupportedError extends AgentRuntimeError { readonly version: string; readonly readerVersion: string; constructor(version: string, readerVersion: string); } /** * Thrown by `runStateFromJSON(...)` when the supplied JSON does not * shape-match the documented `SerializedRunState`. * * @stable */ declare class RunStateMalformedError extends AgentRuntimeError { constructor(reason: string); } /** * Thrown by `Agent.fanOut(...)` when the configured * `MergeAgentSidewaysInjectionGuard` fires with strictness * `'detect-and-block'`. * * @stable */ declare class MergeBlockedError extends AgentRuntimeError { readonly fanOutId: string; readonly reason: string; constructor(fanOutId: string, reason: string); } /** * Thrown by the protocol-injection guard when the operator selected * the strictest deployment posture (`escapePolicy: 'reject'`) and a * tool result body carries control characters at the corresponding * outbound boundary. * * @stable */ declare class ProtocolInjectionRejectError extends AgentRuntimeError { readonly boundary: string; readonly matchedPattern: string; constructor(boundary: string, matchedPattern: string); } /** * Thrown by `agent.progress.write(...)` when the atomic write fails * (disk full, permission denied, ...). The partial `.tmp` file is * unlinked before the error propagates. * * @stable */ declare class ProgressWriteError extends AgentRuntimeError { readonly path: string; constructor(path: string, cause: unknown); } /** * Thrown when a run crosses its `RunBudget` ceiling under * `onExceed: 'throw'`. The run's promise REJECTS with this error * after an `agent.error` event; graceful finalization is skipped. The * default `onExceed: 'stop'` never throws - it resolves the run as * `status: 'failed'` with `error.code: 'budget-exceeded'` instead. * * @stable */ declare class AgentBudgetExceededError extends AgentRuntimeError { /** Which ceiling tripped. */ readonly resource: 'cost' | 'tokens'; /** Observed cumulative value at the between-step check. */ readonly observed: number; /** The configured ceiling. */ readonly limit: number; constructor(args: { resource: 'cost' | 'tokens'; observed: number; limit: number; }); } /** * `RunBudget.maxCostUsd` is set but the * accumulated usage carries no USD cost data, so the ceiling cannot * observe spend. Under the fail-closed default * (`RunBudget.onUnpriced: 'fail'`) the run stops at the first * between-step check: `onExceed: 'throw'` rejects with this error, the * `'stop'` shape fails the run with `error.code: 'budget-unpriced'`. * Wire `withCostTracking` (@graphorin/provider) with a * `@graphorin/pricing` snapshot, use `RunBudget.maxTokens`, or opt back * into the old warn-once behaviour with `onUnpriced: 'warn'`. * * @stable */ declare class AgentBudgetUnpricedError extends AgentRuntimeError { constructor(); } /** * Thrown by `createAgent({...})` when the supplied * `composeProviderMiddleware` chain violates the canonical inside-out * ordering (DEC-145 / ADR-039). * * @stable */ declare class ProviderMiddlewareOrderError extends AgentRuntimeError { constructor(reason: string); } //#endregion export { AgentBudgetExceededError, AgentBudgetUnpricedError, AgentResolutionError, AgentRuntimeError, AgentRuntimeErrorCode, ConcurrentRunError, EvaluatorOptimizerConfigError, InvalidAgentConfigError, InvalidPreferredModelError, MergeBlockedError, MultipleHandoffsInStepError, ProgressWriteError, ProtocolInjectionRejectError, ProviderMiddlewareOrderError, RunStateMalformedError, RunStateVersionUnsupportedError, SubAgentResumeTargetNotFoundError, ToolNotFoundError }; //# sourceMappingURL=index.d.ts.map