Skip to content
API contract reference

API contract reference

This page summarizes the current contracts shared by Rust, Python, and TypeScript/Node. It is a navigation and integration guide, not a stability promise. Exact serialized fields are defined by the source types and the linked contract documents.

Chat requests and events

OpenAI-compatible chat uses contract version 1. A request contains contract_version, model, messages, and optional options, tools, and provider-specific extensions. The consumer provides base_url and optional api_key, headers, timeout values, retry limit, and response/event size limits. The engine preserves path prefixes and does not load credentials from environment files.

Streaming event types are text_delta, reasoning_delta, tool_call_delta, model_switched, usage, and completed. Tool-call deltas are indexed fragments; consumers assemble them and validate the final arguments before dispatch. Closing the stream cancels the native request path.

Native chat uses NativeChatSettings with provider anthropic, google, or cohere; provider-specific fields remain explicit. Embedding and reranking requests are separately versioned and return vectors or ranked source indices. Empty input batches avoid a network request.

Run and tool coordination

RunIdentity is a versioned identity/scope/capability snapshot supplied by the host. Run lifecycle functions validate transitions but do not authenticate the identity. ToolContract defines a schema, capability, effect class, timeout, and idempotency declaration. Dispatch returns ordered decisions; it does not invoke adapters.

ModelToolLoopState coordinates model turns and correlated tool results. Its current state contract is version 2; tool results use version 1. Cancellation may return pending calls for the host to interrupt. Recovery and unknown external outcomes require host reconciliation; no adapter replay or exactly-once effect guarantee is implied.

PolicySnapshot and approval grants bind a decision to the run, turn, tool call, normalized arguments, scope, policy revision, and digest. The host authenticates approvers and validates the trust source. Verification reports distinguish passed, failed, infra_error, and not_run; required checks and evidence determine the gate verdict.

Durable stores

SQLite store operations accept a database path and host-authorized scope. Mutating durable operations use an operation_id for idempotent replay and reject stale/conflicting snapshots. Event/checkpoint writes are atomic only within the same SQLite transaction. Specialized stores exist for the model/tool loop, run lifecycle/verification, and tool policy/approval.

The host must redact sensitive values before persistence, control file permissions and retention, and reconcile external effects after uncertain outcomes. The stores do not authenticate the caller or make provider/tool effects part of a database transaction.

Language naming

CapabilityPythonTypeScript
Chatchat_complete, chat_streamchatComplete, chatStream
Native chatnative_chat_complete, native_chat_streamnativeChatComplete, nativeChatStream
Turn assemblyassemble_turnassembleTurn
Tool dispatchprepare_tool_dispatch, authorize_tool_dispatchprepareToolDispatch, authorizeToolDispatch
Model/tool loopstart_model_tool_loop, accept_model_turn, submit_tool_result, recover_model_tool_loop, cancel_model_tool_loop, reconcile_tool_resultstartModelToolLoop, acceptModelTurn, submitToolResult, recoverModelToolLoop, cancelModelToolLoop, reconcileToolResult
Verificationevaluate_verificationevaluateVerification
Durable SQLitesqlite_* functionssqlite* functions
Vectorsvector_store_upsert, vector_store_search, vector_store_deletevectorStoreUpsert, vectorStoreSearch, vectorStoreDelete
KVkv_store_put, kv_store_getkvStorePut, kvStoreGet
Queuequeue_enqueue, queue_receive, queue_ack, queue_releasequeueEnqueue, queueReceive, queueAck, queueRelease
Pub/subpubsub_publish, pubsub_subscribe, pubsub_receive, pubsub_unsubscribepubsubPublish, pubsubSubscribe, pubsubReceive, pubsubUnsubscribe
Resilient ledger projectionresilient_ledger_appendresilientLedgerAppend

Rust consumers use the canonical typed API in crate modules. These language surfaces are not guaranteed to expose every internal Rust type. PostgreSQL is currently exposed through the local-first resilient ledger operation; direct PostgreSQL ledger connection APIs remain Rust-only. For full input/output schemas, error codes, and version rules, consult the contract specifications in the source repository and the binding READMEs.