/** * @license * Copyright 2025 Steven Roussey * SPDX-License-Identifier: Apache-2.0 */ import { IJobExecuteContext, Job } from "@workglow/job-queue"; import { TaskInput, TaskOutput } from "@workglow/task-graph"; import type { JsonSchema } from "@workglow/util/schema"; import type { AiEmit } from "../capability/AiEmit"; import type { Capability } from "../capability/Capabilities"; import type { ModelConfig } from "../model/ModelSchema"; /** * Input data for the AiJob. * * `taskType` is retained as observability / queue-key metadata only — dispatch * resolves the run function via `requires` against the provider's capability-set * registrations. Both fields travel together so logs and queue keys remain stable * even though the registry is now keyed by capability sets. */ export interface AiJobInput { taskType: string; /** * Capability set the job requires from the provider. The dispatcher passes * this to {@link AiProviderRegistry.getRunFnFor} to resolve a streaming run * function. An empty array matches the smallest registration available. */ requires: readonly Capability[]; aiProvider: string; taskInput: Input & { model: ModelConfig; }; /** JSON Schema for structured output, when the task declares x-structured-output. */ outputSchema?: JsonSchema; /** Timeout in milliseconds for the provider API call. Defaults to 120s. */ timeoutMs?: number; /** Opaque session token for multi-turn conversation caching (KV cache for local models, prompt caching for API providers). */ sessionId?: string; } /** * Classifies a provider error as retryable or permanent based on known patterns. * Returns a RetryableJobError for transient issues (rate limits, network errors, * server errors) and a PermanentJobError for non-recoverable issues (auth, not found). */ export declare function classifyProviderError(err: unknown, taskType: string, provider: string): Error; export declare class AiJob = AiJobInput, Output extends TaskOutput = TaskOutput> extends Job { /** * Executes the job by dispatching to the registered run function and * forwarding every emitted event to the caller-supplied `emit`. The Promise * carries no data — output rides on the `finish` event (or accumulated * deltas + trailing empty `finish` for streaming capabilities). * * AiJob no longer fits Job's `execute(input, ctx): Promise` * contract because the new dispatch shape is `execute(input, ctx, emit): Promise`. * The storage-queue path that depended on the Job contract was removed in * QueuedExecutionStrategy. AiJob still uses Job's progress-event / status * machinery, so we keep the inheritance but accept the intentional override * signature mismatch. * * @override Deliberate signature deviation: adds `emit` param, returns `Promise`. */ execute(input: Input, context: IJobExecuteContext, emit: AiEmit): Promise; } //# sourceMappingURL=AiJob.d.ts.map