Docs
SDK API

SDK API

The public execution API for Captor jobs and backfills.

Execution API

Import from captar (Node.js 22+). The captar/execution and focused execution subpaths remain supported.

ExportPurpose
run(name, contract, execute)Run a callback and return { value, receipt }
ExecutionRunIn-process accounting and execution state
ContractViolationErrorFailed contract, with receipt
backfill(options) / runBackfill(options)Sequential, guarded batch processing
runStored(name, contract, execute, store?)Persist the final receipt; defaults to JSONL
JsonlRunStore / SqliteRunStoreLocal receipt storage
boundedFetch(execution, options?)Meter HTTP attempts
createPrismaQueryGuard(execution, options?)Preflight supported Prisma writes
UnboundedPrismaWriteErrorBulk mutation blocked before execution

The upcoming RunPersistenceError export describes a receipt save failure, retaining receipt, the storage cause, and an optional executionError. It is part of the repository reliability update; consult the release changelog for package availability.

ExecutionRun methods

MethodMeaning
reserve(resource, amount)Return a reservation if capacity permits
commit(reservation, actualAmount?)Commit actual usage; defaults to the reserved amount
release(reservation)Release unused capacity on an active run
consume(resource, amount?) / count(resource, amount?)Immediately charge a resource; amount defaults to 1
remaining(resource)Remaining capacity, or undefined for an unlimited resource
metric(name, value)Set a finite numeric outcome metric
checkpoint(name, value)Record application progress
signalCooperative cancellation signal
receipt()Snapshot current execution state

See contracts, backfills, stores and adapters for behavior and boundaries.

Existing createCaptar, provider wrappers and tool APIs remain in the AI compatibility API.