Generated from SDK source comments by
scripts/generate-play-sdk-reference.ts. Do not edit this file manually.Runtime Model
The Deepline SDK is a runtime SDK. Your TypeScript defines durable play code and typed run contracts; Deepline executes that code in the cloud runtime, records provider/tool calls, persists dataset rows, and exposes run state through SDK handles and HTTP APIs. UsedefinePlay(...) for code that runs inside a Deepline play. Inside that function, ctx.* is the runtime boundary: ctx.tools.execute calls managed providers, ctx.dataset records row-level work, ctx.step checkpoints scalar work, ctx.fetch records external HTTP, and ctx.runPlay composes registered or prebuilt plays.
Use Deepline.connect() and DeeplineClient from regular Node/TypeScript services, scripts, schedulers, or tests. Those APIs discover tools and plays, start runs, stream/poll status, stop runs, and inspect durable output without requiring a local play file.
Reference Map
Detail Policy
Tested Examples
These examples are copied fromdocs-examples/sdk-v2 and validated by bun run docs:sdk-v2:check. Keep examples there first, then regenerate this reference.
Run A Prebuilt From TypeScript
Source:docs-examples/sdk-v2/run-prebuilt.ts
Define A Play With ctx.tools.execute
Source: docs-examples/sdk-v2/company-lookup.play.ts
Fall Through A Transient Provider Failure
Catch onlyProviderTransientError when another read provider can answer the same question. Validation, authentication, billing, Deepline, unknown, and final-provider failures stay loud.
Source: docs-examples/sdk-v2/provider-fallback.play.ts
Schedule A Dataset Refresh
Source:docs-examples/sdk-v2/nightly-account-refresh.play.ts
Verify A Webhook With HMAC
Source:docs-examples/sdk-v2/inbound-lead-webhook.play.ts
Play Authoring Contract
New artifacts pin authoring contract edition 3. Check, publish, and run use the same admitted snapshot.
Generated from source comments and type declarations by
scripts/generate-play-sdk-reference.ts. Do not edit this file manually.
Version And Coverage
Runtime Entrypoints
Deepline
Static entry point for the Deepline SDK.
Signature: class Deepline
Members
DeeplineContext
High-level SDK context with tool shortcuts and play handles.
Created by Deepline.connect. Wraps a DeeplineClient with
a friendlier API for common operations.
Signature: class DeeplineContext
Members
Play Authoring And In-Play Runtime
definePlay
Define a play — a composable TypeScript workflow for the Deepline platform.
The returned value is both:
- A callable function — invoked by the Temporal worker with a runtime context
- A named play handle — with
.run(),.versions(),.get(),.publish(), etc. for remote lifecycle management
export function definePlay<TInput, TOutput extends PlayReturnObject>( config: DefinePlayConfig<TInput, TOutput>, ): DefinedPlay<TInput, TOutput>; export function definePlay<TInput, TOutput extends PlayReturnObject>( name: string, fn: (ctx: DeeplinePlayRuntimeContext, input: TInput) => Promise<TOutput>, bindings?: PlayBindings, ): DefinedPlay<TInput, TOutput>;
Overload 1
Parameters
Returns
DefinedPlay<TInput, TOutput>
Overload 2
Parameters
Returns
DefinedPlay<TInput, TOutput>
DefinePlayConfig
Object-form play definition accepted by definePlay(config).
Use this form when the input contract should be explicit at definition time
through defineInput<T>(schema), or when configuration reads clearer as one
object. The shorthand definePlay(name, fn, bindings?) is equivalent for
simple file-backed plays.
Signature: export type DefinePlayConfig< TInput, TOutput extends PlayReturnObject, > = PlayAuthoringDefineConfig<TInput, TOutput, DeeplinePlayRuntimeContext>;
PlayBindings
Optional trigger bindings for a play.
A play can be triggered three ways, declared as the third argument to
definePlay:
webhook— an inbound HTTP call (with optional HMAC signature verification);cron— a schedule; orsqlListeners— a monitor: the play runs whenever a monitor writes a new row to its output stream. This is how you build a play “on top of” a monitor (e.g. run enrichment every time a watched company posts a new job). Each listener binds to a monitor tool id + one of its output stream keys (seedeepline monitors available <id>for a tool’s streams and row columns). The changed row is delivered to the handler as the listener event’safter.
export type PlayBindings = PlayAuthoringBindings;
ctx.csv(path, options)
Load a staged CSV file as a durable dataset handle.
Signature: csv<T = Record<string, unknown>>( path: string | CsvInput<T & object>, options?: CsvOptions, ): Promise<PlayDataset<T>>;
Parameters
Returns
Promise<PlayDataset<T>>
CsvOptions
Options for loading a staged CSV with ctx.csv(...).
Signature: export type CsvOptions = CsvOptions;
ctx.dataset(key, items)
Create a persisted row dataset and define durable output columns.
Signature: dataset<TSource extends PlayDatasetInput<object>>( key: string, items: TSource, ): DatasetBuilder< PlayDatasetRow<TSource> & object, PlayDatasetRow<TSource> & object, PlayAuthoringRuntimeContext >;
Parameters
Returns
DatasetBuilder< PlayDatasetRow<TSource> & object, PlayDatasetRow<TSource> & object, PlayAuthoringRuntimeContext >
.dataset(...).withColumn(name, resolver).run(options)
Define one output column for every row in this dataset.
Column Overload 1 Parameters
Column Overload 1 Returns
DatasetBuilder< InputRow, OutputRow & Record<Name, Value> >
Column Overload 2 Parameters
Column Overload 2 Returns
DatasetBuilder< InputRow, OutputRow & Record<Name, Value | null> >
Column Overload 3 Parameters
Column Overload 3 Returns
DatasetBuilder< InputRow, OutputRow & Record<Name, Value> >
Column Overload 4 Parameters
Column Overload 4 Returns
DatasetBuilder< InputRow, OutputRow & Record<Name, Value | null> >
Run Parameters
Run Returns
Promise<PlayDataset<OutputRow>>
Execute the row-column program and return a durable dataset handle.
upsert preserves row-by-row enrichment. net_new admits and returns only
unseen stable keys. isolate records failed rows while siblings continue;
fail opts into fail-fast behavior.
DatasetColumnRunInput
Input object passed to an object-column run resolver.
Fields
DatasetColumnDefinition
Object-column form for .withColumn(...).
Use this when a column needs runIf or typed previousCell.
Fields
StepOptions
Options for row-level .withColumn(...) and steps().step(...) entries.
Fields
PreviousCell
Previous durable cell value passed to object-column resolvers.
The runtime supplies this when a row+column is being recomputed after a
previous value existed. value has the same type that the column returns;
freshness metadata lives beside it.
Fields
ctx.step(id, fn)
Create one scalar durable checkpoint.
Signature: step<T>( id: string, run: () => T | Promise<T>, options?: RuntimeStepOptions, ): Promise<T>;
Parameters
Returns
Promise<T>
ctx.runPlay(key, playRef, input, options)
Compose another Play inline under a stable call key.
Signature: runPlay<TOutput = unknown>( key: string, playRef: string | PlayReferenceLike, input: Record<string, unknown>, options: PlayCallOptions, ): Promise<TOutput>;
Parameters
Returns
Promise<TOutput>
ctx.tools.execute(request)
Execute a provider tool through the durable receipt contract.
Signature: execute<TOutput = PlayLooseObject>( request: PlayToolExecutionRequest, ): Promise<ToolExecuteResult<TOutput>>;
Parameters
Returns
Promise<ToolExecuteResult<TOutput>>
ToolExecutionRequest
Keyword-style request object for ctx.tools.execute(...).
The tool value comes from live tool discovery. The id is the stable
logical call name used for logs, metadata, and receipt attachment. Provider
call reuse is keyed by play, tool, semantic input, auth scope, provider action
version, and cache policy.
Signature: export type ToolExecutionRequest = PlayToolExecutionRequest;
ctx.fetch(key, url, init)
Execute a durable, replay-safe HTTP request.
Signature: fetch( key: string, url: string | URL, init?: PlaySecretAwareRequestInit, options?: FetchOptions, ): Promise<PlayFetchResponse>;
Parameters
Returns
Promise<PlayFetchResponse>
ctx.runSteps(program, input, options)
Execute one reusable step program against a scalar input.
Signature: runSteps<TInput extends Record<string, unknown>, TOutput>( program: PlayAuthoringRunnableStepProgram< TOutput, PlayAuthoringRuntimeContext > & { readonly __inputType?: (input: TInput) => void }, input: TInput, options?: PlayAuthoringRunStepsOptions, ): Promise<TOutput>;
Parameters
Returns
Promise<TOutput>
PlayDataset
Durable handle for rows produced by ctx.csv(...) or ctx.dataset(...).run().
A PlayDataset is not a normal in-memory array. It points at runtime-managed
rows, usually backed by persisted sheet storage, and carries metadata such as
dataset kind, dataset id, table namespace, count, and preview rows.
Pass dataset handles directly into later ctx.dataset(...) stages by default so
Deepline keeps row progress, retries, memory use, and table output under
runtime control. Use count() and peek() for bounded inspection. Use
materialize(limit) or async iteration only when the dataset is intentionally
small and bounded. PlayDataset intentionally does not expose .rows,
.toArray(), .length, numeric indexing, spread, or synchronous iteration;
those hide the runtime cost of loading persisted rows into memory or make
behavior depend on whether rows happen to be resident.
Fields
ToolExecuteResult
Canonical result returned by Deepline tool execution.
The top-level object is Deepline-owned execution metadata and semantic
extraction state. Raw tool/provider data lives under toolResponse.raw;
response metadata lives under toolResponse.meta. Semantic single-value
getters live under extractedValues.<name>.get(), and list getters live
under extractedLists.<name>.get().
Use extractors first when a tool contract exposes them. Use list getters for
row-shaped data. Drop to toolResponse.raw only for provider-specific scalar
fields or bounded debugging context; persisted rows may clip declared lists to
previews.
Signature: export type ToolExecuteResult< TResult = unknown, TMeta = Record<string, unknown>, TExtracted extends Record<string, unknown> = Partial<DeeplineGetterValueMap>, TLists extends Record<string, Record<string, unknown>> = Record< string, Record<string, unknown> >, > = ToolExecuteResultBase<TResult, TMeta> & ToolExecuteResultAccessors<TExtracted, TLists>;
Errors And Provider Fallthrough
New Plays receive typed tool errors. Existing published artifacts keep the error contract stored with their revision. For a read waterfall, catch onlyProviderTransientError and keep the final provider call loud. For structured diagnostics, narrow to ToolExecutionError and branch on its stable fields. Never branch on error.message.
A newly authored Play can explicitly retain legacy errors with compatibility: { toolErrorSchemaVersion: 0 } in its definePlay options. Use that only while migrating old message-based handling.
DeeplineError
Base error class shared by the SDK and play runtime.
The global brand preserves instanceof DeeplineError when a bundled play
and the runtime load separate physical copies of this module.
Signature: class DeeplineError extends Error
Members
ToolExecutionErrorOrigin
The boundary responsible for a failed tool call.
Use provider to distinguish a provider answer from caller input and
Deepline infrastructure. unknown fails closed and must not trigger a
waterfall fallback.
Signature: export type ToolExecutionErrorOrigin = | 'caller' | 'provider' | 'deepline' | 'unknown';
ToolExecutionErrorCategory
The stable reason family for a failed tool call.
Branch on this field only after narrowing to ToolExecutionError. Catch
ProviderTransientError when the policy is simply “try the next read
provider”; it is the safer and shorter waterfall contract.
Signature: export type ToolExecutionErrorCategory = | 'validation' | 'authentication' | 'authorization' | 'rate_limit' | 'network' | 'upstream' | 'billing' | 'conflict' | 'internal' | 'unknown';
ToolExecutionNetworkKind
The transport failure observed when category is network.
This is null for failures that are not network failures.
Signature: export type ToolExecutionNetworkKind = | 'timeout' | 'dns' | 'connect' | 'reset' | 'unavailable' | 'unknown';
ToolExecutionNetworkScope
The request boundary on which a network failure occurred.
deepline_to_provider is provider-side. Client and runtime scopes are
Deepline transport failures and never qualify as provider fallthrough.
Signature: export type ToolExecutionNetworkScope = | 'client_to_deepline' | 'runtime_to_deepline' | 'deepline_to_provider';
ProviderTransientErrorCategory
Provider-owned failure categories that may fall through to another read
provider.
Signature: export type ProviderTransientErrorCategory = | 'rate_limit' | 'network' | 'upstream';
ToolExecutionFailureV1
Portable version-1 tool_error payload.
This allowlisted shape crosses the API, runtime, and SDK boundaries.
message remains on the Error object and is deliberately not a policy
field.
Fields
ToolExecutionErrorOptions
Constructor input for a structured tool failure.
Deepline creates these values while decoding the versioned wire payload.
Customer code normally reads ToolExecutionError fields instead of
constructing an error.
Signature: export type ToolExecutionErrorOptions = Omit< ToolExecutionFailureV1, 'schemaVersion' > & { details?: Record<string, unknown>; };
ToolExecutionError
A failed tools.execute call with stable, allowlisted provenance.
retryable means Deepline’s delivery/idempotency contract says it is safe
to repeat the same semantic call. It does not describe durable receipt
repairability and does not make arbitrary side-effecting fallbacks safe.
In a Play, catch ProviderTransientError to continue a read waterfall and
let every other ToolExecutionError remain loud. In an SDK client, catch
this base class when you need structured diagnostics for every tool failure.
Signature: class ToolExecutionError extends DeeplineError
Members
ProviderTransientError
A provider-owned transient failure that is safe to handle as an empty
waterfall leg. Validation, auth, billing, Deepline, and unknown failures
never satisfy this type.
retryable remains independent: it says whether the same semantic call may
be repeated safely. Falling through to a different read provider depends on
this class, not on retryable.
Signature: class ProviderTransientError extends ToolExecutionError
Members
AuthError
Thrown when the API rejects the request due to an invalid or missing API key.
This maps to HTTP 401 responses. HTTP 403 means the caller was authenticated
but lacks permission, so the SDK preserves the server’s API error instead.
The SDK never retries auth errors —
they fail immediately.
Fix: run deepline auth register to obtain a valid key, or pass one via
the apiKey option or DEEPLINE_API_KEY environment variable.
Signature: class AuthError extends DeeplineError
Members
RateLimitError
Thrown when the API returns HTTP 429 (Too Many Requests).
The SDK retries rate-limited requests automatically up to maxRetries times
with exponential backoff. This error is only thrown when all retries are exhausted.
Use RateLimitError.retryAfterMs to implement your own backoff if needed.
Signature: class RateLimitError extends DeeplineError
Members
ToolRateLimitError
Tool-specific 429 preserving both historical RateLimitError catches and the
structured ToolExecutionError ontology. JavaScript has one prototype chain,
so this class extends RateLimitError and carries ToolExecutionError’s stable
cross-bundle brand.
This class appears in external SDK calls after HTTP 429 retries are
exhausted. It also satisfies instanceof ToolExecutionError and, for a
provider-owned rate limit, instanceof ProviderTransientError. Authored
Plays should use ProviderTransientError; they do not need this
compatibility class.
Signature: class ToolRateLimitError extends RateLimitError
Members
ConfigError
Thrown when the SDK cannot resolve a valid configuration.
Most commonly: no API key found in any of the resolution sources
(explicit option, environment variable, CLI env files).
Signature: class ConfigError extends DeeplineError
Members
Tool And Provider Calls
DeeplineContext.tools
Tool/provider operations available from a connected DeeplineContext.
This namespace is for regular SDK callers outside a play runtime. Inside a
definePlay(...) body, use ctx.tools.execute({ id, tool, input, ... })
so provider calls become durable runtime checkpoints.
Signature: export type DeeplineToolsNamespace = { list(): Promise<ToolDefinition[]>; get(toolId: string): Promise<ToolMetadata>; execute( toolId: string, input: Record<string, unknown>, ): Promise<ToolExecuteResult>; };
Remote Plays And Runs
DeeplineContext.plays
Named-play discovery and handle operations from a connected DeeplineContext.
Signature: export type DeeplinePlaysNamespace = { list(): Promise<PlayListItem[]>; get<TInput = Record<string, unknown>, TOutput = unknown>( name: string, ): DeeplineNamedPlay<TInput, TOutput>; };
DeeplineNamedPlay
Handle to a named play for remote lifecycle operations.
Returned by DeeplineContext.play and attached to DefinedPlay.
Provides methods to run, inspect, list runs, and publish a play by name.
Fields
PlayJob
Handle to a running play execution.
Provides methods to check status, stream logs, wait for completion,
or cancel the execution.
This handle is the SDK-context equivalent of deepline plays run --watch and
POST /api/v2/plays/run: every surface returns a run id first, then exposes
the completed user output through PlayJob.get() or the status endpoint’s
result field. Runtime logs are available from status().progress.logs and
are intentionally separate from the returned output object.
Fields
Low-Level Client
DeeplineClient
Low-level client for the Deepline REST API.
Provides typed methods for every API endpoint: tools, plays, auth, and health.
Handles authentication, retries, and localhost failover automatically.
Signature: class DeeplineClient
Members
client.runs
Public runs namespace exposed as client.runs.
This namespace mirrors the canonical /api/v2/runs resource family and is
the preferred low-level surface for polling, streaming, stopping, reading
logs, and exporting durable dataset rows.
Fields
client.billing
Public billing namespace exposed as client.billing.
Carries plans, subscription state, cancellation, and invoice/receipt history
so CLI commands and programmatic callers share one surface.
Fields
client.monitors
Public monitors namespace exposed as client.monitors.
Mirrors the /api/v2/monitors resource family so the monitors CLI and
programmatic callers share one product surface — every deepline monitors
verb maps to a method here. Monitors are fully expressible as SDK code: author
a definition with defineMonitor, then check/deploy/list/get/update/
delete/reactivate through this namespace.