Every public export of @warlock.js/ai, grouped by primitive. This page is the lookup table — for the “why” and “how to use it well” angle, follow the cross-links to the concept and basics pages.
All exports come from the same entry:
import { ai, /* types, errors */ } from " @warlock.js/ai " ;
Export What it is AgentContract<T>The shape returned by ai.agent. Has .execute(), .stream(), .on(), .off(), .name, .isAnonymous, .description. AgentConfigConfig object accepted by ai.agent. AgentExecuteOptionsPer-call options for execute / stream. AgentResult<T>Result envelope — { type, data?, text?, report, usage, error? }. AgentReportTrace tree — { status, startedAt, endedAt, duration, model, trips, toolCalls }. AgentEventHandlersTyped event handler map for on (factory / per-call). AgentEventMapMap of event name → payload, keyed by agent.* event. StreamingToolGuardConfigConfig for streamingToolGuard. MessageHistory message — { role, content, ... }. AttachmentImage attachment — string or tagged object.
Export What it is WorkflowInstance<TIn, TOut, TState, TContext>Returned by ai.workflow. .execute(), .resume(), .asTool(), .signature. WorkflowDefinition<TIn, TOut, TState, TContext>Config for ai.workflow. StepDefinition<TIn, TState, TContext>Returned by ai.step. WorkflowContext<TIn, TState, TContext>The ctx argument step bodies receive. WorkflowResult<TOut>Result envelope. WorkflowReportTrace tree — { runId, signature, status, timings, steps }. StepSnapshotOne step’s recorded outcome — { output, status, attempts, attemptHistory, timings, steps? }. WorkflowRunOptionsPer-call options for execute / resume. WorkflowSnapshotPersisted shape — see Persist AI data .
Export What it is SupervisorContract<TOutput>Returned by ai.supervisor. .execute(), .stream(), .resume(), .asTool(), .signature. SupervisorConfig<TOutput>Config for ai.supervisor. SupervisorContext<TOutput>ctx argument intent bodies and routers receive.SupervisorResult<TOutput>Result envelope. SupervisorReportTrace tree — iterations, intent dispatches. SupervisorSnapshotPersisted shape. ENDSentinel value to terminate routing.
Export What it is ToolContract<TIn, TOut>Returned by ai.tool. Has .name, .description, .invoke(). ToolConfig<TIn, TOut>Config for ai.tool. ToolContext<TArtifacts>Second argument to execute — { artifacts, signal, ... }. ToolCallOne recorded tool call — { name, input, output, error?, tripIndex, duration, startedAt, endedAt }. ToolMode`“feedback"
Export What it is SystemPromptImmutable builder returned by ai.systemPrompt. .persona(t), .instruction(t), .resolve(placeholders). SystemPromptContractInterface implemented by SystemPrompt. SystemPromptBlockContractDiscriminated union — `PersonaContract PersonaContract{ type: "persona", text, resolve }.InstructionContract{ type: "instruction", text, resolve }.
Export What it is EmbedderContractSibling of ModelContract on SDKAdapterContract. .embed(), .embedMany(), .dimensions. EmbeddingResult{ vector: number[], usage: Usage, dimensions: number }.EmbeddingBatchResult{ vectors: number[][], usage: Usage, dimensions: number }.
Export What it is SDKAdapterContractInterface every provider adapter implements — model(), embedder?(). ModelContractReturned by sdk.model({...}). Owns complete, stream, capabilities, pricing. ModelCallOptionsPer-call options forwarded to the model (temperature, maxTokens, etc.). ModelResponseShape returned by model.complete. ModelPricing{ input, output, cachedInput?, cachedOutput? } — USD per 1M tokens.Usage{ input, output, total, cost? }.CostBreakdown{ input, output, cachedInput?, cachedOutput? } — USD.
Export What it is AgentMiddlewareShape — { name, execute?, trip?, tool?, log? }. MiddlewareExecuteContextctx for execute hooks.MiddlewareTripContextctx for trip hooks.MiddlewareToolContextctx for tool hooks.
All extend AIError. Stable code strings listed in Handle errors .
Class Code Category AIError(base) varies AgentExecutionErrorAGENT_EXEC_FAILEDvaries SchemaValidationErrorSCHEMA_VALIDATION_FAILEDschemaToolExecutionErrorTOOL_EXEC_FAILEDtoolWorkflowError(base) varies StepFailedErrorSTEP_FAILEDproviderWorkflowDriftErrorWORKFLOW_DRIFTdriftWorkflowCancelledErrorWORKFLOW_CANCELLEDcancelledMaxStepsExceededErrorWORKFLOW_MAX_STEPSmax-stepsRoutingErrorWORKFLOW_INVALID_GOTOroutingProviderErrorPROVIDER_ERRORproviderProviderRateLimitErrorPROVIDER_RATE_LIMITrate-limitQuotaExceededErrorPROVIDER_QUOTA_EXCEEDEDquotaProviderTimeoutErrorPROVIDER_TIMEOUTtimeoutContextLengthExceededErrorCONTEXT_LENGTH_EXCEEDEDcontext-lengthContentFilterErrorCONTENT_FILTERcontent-filterInvalidRequestErrorPROVIDER_INVALID_REQUESTvalidationProviderAuthErrorPROVIDER_AUTHauthBudgetExceededErrorBUDGET_EXCEEDEDbudgetGuardrailViolationErrorGUARDRAIL_VIOLATIONguardrailSupervisorDriftErrorSUPERVISOR_DRIFTdriftMaxIterationsErrorSUPERVISOR_MAX_ITERATIONSmax-iterations
Export What it is AIConfig{ defaultStore? } — process-wide config.ai.config(partial)Merge into the process-wide config.
Export What it is BaseReportCommon report shape — runId, rootRunId, parentRunId?, reportSchemaVersion, version?, sessionId?. LLMTripOne round-trip — { index, finishReason, usage, startedAt, endedAt, duration, ... }. FinishReason`“stop"
Export What it is MockSDKTest double for any SDKAdapterContract. Use in tests instead of hitting real providers. MockModelBacking model with scripted responses. MockEmbedderBacking embedder with scripted vectors.