providerplaneai
    Preparing search index...

    Class GenericJob<TInput, TOutput>

    Manages execution state for a single queued or running AI job.

    Type Parameters

    • TInput

      Input type accepted by the job executor.

    • TOutput

      Output type returned by the job executor.

    Implements

    Index

    Constructors

    • Constructs a new GenericJob instance.

      Type Parameters

      • TInput

        Input type accepted by the job executor.

      • TOutput

        Output type returned by the job executor.

      Parameters

      • input: TInput

        The job input payload.

      • OptionalstreamingEnabled: boolean = false

        Whether the executor emits streaming chunks.

      • executor: (
            input: TInput,
            ctx: MultiModalExecutionContext,
            signal?: AbortSignal,
            onChunk?: (
                chunk: JobChunk<TOutput>,
                internalChunk?: AIResponseChunk<TOutput>,
            ) => void,
        ) => Promise<AIResponse<TOutput>>

        The function that performs the capability execution.

      • Optionalhooks: JobLifecycleHooks<TOutput>

        Optional lifecycle hooks invoked during execution.

      • OptionalmaxStoredResponseChunks: number

        Maximum number of streamed chunks retained in memory.

      • OptionalexecutionMetadata: {
            capability?: CapabilityKeyType;
            maxRawBytesPerJob?: number;
            providerChain?: ProviderRef[];
            storeRawResponses?: boolean;
            stripBinaryPayloadsInSnapshotsAndTimeline?: boolean;
        }

        Optional execution metadata persisted with snapshots.

      Returns GenericJob<TInput, TOutput>

      Thrown when maxStoredResponseChunks or maxRawBytesPerJob is invalid.

    Properties

    input: TInput

    The job input payload.

    onChunk?: (chunk: JobChunk<TOutput>) => void

    Optional streaming callback

    onStatusChange?: (status: JobStatus) => void

    Called whenever status changes

    Accessors

    • get id(): `${string}-${string}-${string}-${string}-${string}`

      Returns `${string}-${string}-${string}-${string}-${string}`

    Methods

    • Returns a promise that settles when the job reaches a terminal state.

      Returns Promise<TOutput>

      A promise that resolves with the final job output or rejects with the terminal error.

    • Marks the job as aborted without invoking the executor.

      Parameters

      • Optionalreason: Error

        Optional abort reason to retain as the terminal error.

      Returns void

      Nothing.

    • Resets transient state so the job can be executed again from its original input.

      Returns void

      Nothing.

    • Hydrate this job from a persisted snapshot. Internal response envelopes/chunks are intentionally not restored because rerun semantics are deterministic replay from input + executor, not raw resume.

      Parameters

      Returns void

      Nothing.

    • Run the job. NOTE: Consumers should typically call JobManager.runJob() instead of invoking this directly, to ensure proper concurrency management, hooks, and persistence.

      Parameters

      • ctx: MultiModalExecutionContext

        The execution context supplied by the caller or job manager.

      • Optionalsignal: AbortSignal

        Optional abort signal for cancellation.

      • OptionalonChunk: (chunk: JobChunk<TOutput>) => void

        Optional chunk callback that overrides the job-level handler.

      Returns Promise<void>

      Resolves when the run attempt finishes and terminal state has been recorded.