Skip to content

IndeRun

The advanced task API. IndeRun implements IndeRunApi; constructing one by hand takes a ProviderRegistry and HostServices from @independo/inderun-web/provider.

new IndeRun(registry, hostServices, options?): IndeRun

Initializes the IndeRun instance.

ProviderRegistry

Registry filled with active providers.

HostServices

Services wrapping OS interfaces and indicators.

IndeRunOptions

Optional telemetry listener and model profiles.

IndeRun

If a model profile is malformed (see validateModelProfiles).

checkCapabilities(): Promise<ProviderCapabilitySnapshot[]>

Returns a live snapshot of every registered provider’s static descriptor and current dynamic availability, without executing a task or producing any side effects. Call this before run() when you need to show which providers/models are currently available — for example a settings screen or provider picker. Availability can change between calls (a local model can unload, cloud credentials can expire), so don’t cache the result across a run() call.

Promise<ProviderCapabilitySnapshot[]>

IndeRunApi.checkCapabilities


close(): Promise<void>

Closes the engine. In order: refuses new work, cancels in-flight streams and prepares, waits for them and for in-flight run() calls (Mode 1 has no cancel path, so those are awaited, not cancelled), disposes the engine’s artifacts, and closes the resources the engine’s creator handed over. Idempotent: later and concurrent calls await the first.

Promise<void>

IndeRunApi.close


disposeArtifact(artifact): Promise<void>

Releases the bytes of an engine-owned media artifact. Idempotent: disposing an artifact twice, or one the engine does not hold, does nothing. After disposal readArtifact reports ‘artifact_not_found’. An artifact outlives the run that produced it, so an application that keeps none should dispose each one it receives.

MediaArtifact

Promise<void>

IndeRunApi.disposeArtifact


prepare(request?): Promise<StreamRun>

Makes registered providers ready ahead of a run (ADR 019). Optional: without it, the first run of a task does the part that does not need the application’s say. Repeating it is cheap, because what is ready is skipped. Providers go one at a time, and one failing does not stop the rest: the terminal outcome lists each item.

PrepareRequest

Optional scope. An empty one covers every provider and task.

Promise<StreamRun>

If validation fails.

IndeRunApi.prepare


readArtifact(request): Promise<ArtifactChunk>

Reports each registered provider’s static descriptor and current dynamic capability check, without executing a task. Useful for UI that shows live provider availability before a run.

ArtifactReadRequest

Promise<ArtifactChunk>

IndeRunApi.readArtifact


run(request): Promise<TaskResult>

Orchestrates the execution of a TaskRequest. Performs JSON Schema validation, selects a provider via routing rules, measures total execution time, and attaches telemetry metadata to the outcome.

TaskRequest

The canonical task request containing prompts, tasks, and constraints.

Promise<TaskResult>

Canonical task output containing output details and telemetry metadata.

Standardized error indicating validation, connection, or provider failures.

IndeRunApi.run


stream(request): Promise<StreamRun>

Orchestrates a Mode 2 streaming execution of a TaskRequest.

Routes through the same planner as run(), asking it for a stream route: the planner rejects providers that do not declare supports.streaming or whose dynamic capability snapshot says they cannot stream here, and reports why. The whole returned chain is therefore mode-compatible and subject to the same privacy, locality, availability, and policy constraints as a Mode 1 route.

Fallback to the next provider is allowed only before the first content event has been admitted for the run; once one has been delivered, the run is committed to that provider and any later provider failure becomes a terminal error outcome rather than a silent provider swap — partial output spliced from two providers is undetectable to the caller. Cancellation always forecloses fallback, regardless of commit state, and is idempotent.

TaskRequest

The canonical task request containing prompts, tasks, and constraints.

Promise<StreamRun>

If validation fails or no eligible streaming provider exists.

IndeRunApi.stream