JavaScript Runtime

Reference for the JavaScript runtime contract.

This is a reference for the JavaScript runtime contract. It is the surface a JavaScript orchestrator script runs against: the values the host binds at script start, and the helpers a script calls to record progress, dispatch child work, attach artifacts, and finish.

Example script

Every call below is a published symbol from the package contract, in the order an author would chain them.
phase("draft");
log("checkpoint", { step: 1 });
workflow.checkpoint({ label: "draft", state: { step: 1 } });
await agent.run({
  prompt: "Summarize findings",
  label: "summarize",
  preset: "operator",
});
workflow.artifact({ kind: "log", label: "step", content: { step: 1 } });
workflow.final({ ok: true, result: { count: 1 } });

Runtime Inventory

Scan the published JavaScript symbols and shared schemas below. Filter by symbol path, schema id, description, or lifecycle when those facets are present. Open a card for available metadata and shared-schema links, and copy its stable anchor when you need a deep link.

21 published JavaScript runtime items from the package contract.

Filter JavaScript runtime items

Symbols

Mutable invocation argument value bound from workflow request args JSON at script start. The binding is a non-null object snapshot; property reads and writes affect only the in-script view and do not change the original request payload.

Lifecycle: ActiveActive, since 1.0.0Visibility: Public
Kind: ValueMutability: Mutable objectNullability: Non-nullBinding lifecycle: Snapshot at bind
Symbol path
args
Symbol id
javascript.args

Examples

{ "subject": "release", "count": 2, "prefix": "echo" }

Mutable invocation metadata object bound from workflow request metadata at script start. The binding is a non-null object snapshot with string-valued entries; when name is absent the runtime supplies the default simple-final label.

Lifecycle: ActiveActive, since 1.0.0Visibility: Public
Kind: ValueMutability: Mutable objectNullability: Non-nullBinding lifecycle: Snapshot at bind
Symbol path
meta
Symbol id
javascript.meta

Examples

{ "name": "simple-final", "description": "Example workflow metadata" }

Synchronously emits one workflow-scoped log record. The first argument must be a non-empty string message; an optional second argument supplies JSON-compatible structured fields.

Lifecycle: ActiveActive, since 1.0.0Visibility: Public
Kind: Function
Symbol path
log
Symbol id
javascript.log

Shared schemas

Examples

log("checkpoint", { step: 1 })

Root agent namespace for the installed agent.run child-dispatch helper.

Lifecycle: ActiveActive, since 1.0.0Visibility: Public
Kind: NamespaceMutability: Fixed bindingNullability: Non-nullBinding lifecycle: Live namespace
Symbol path
agent
Symbol id
javascript.agent

Examples

agent.run({ prompt: "Summarize findings", label: "summarize" })

Dispatches one child agent run from a closed spec object with a required prompt and optional model or preset fields. Returns a promise that resolves to the child result object after policy checks and child_dispatch emission.

Lifecycle: ActiveActive, since 1.0.0Visibility: Public
Kind: Method
Symbol path
agent.run
Symbol id
javascript.agent.run

Shared schemas

Examples

await agent.run({ prompt: "Summarize findings", label: "summarize", preset: "operator" })

Runs an array of agent run specs or item functions concurrently and returns a promise that resolves to an array of child results. Each function item is invoked with undefined this.

Lifecycle: ActiveActive, since 1.0.0Visibility: Public
Kind: Function
Symbol path
parallel
Symbol id
javascript.parallel

Examples

await parallel([{ prompt: "first" }, { prompt: "second", label: "two" }])

Maps each items entry through a required worker function and optional next stage callback, running stages sequentially per item. Returns a promise that resolves to a pipeline result array.

Lifecycle: ActiveActive, since 1.0.0Visibility: Public
Kind: Function
Symbol path
pipeline
Symbol id
javascript.pipeline

Examples

await pipeline([1, 2], (item) => item * 2, (prior, item) => prior + item)

Synchronously records one named workflow phase transition for progress tracking. The name must be a non-empty string.

Lifecycle: ActiveActive, since 1.0.0Visibility: Public
Kind: Function
Symbol path
phase
Symbol id
javascript.phase

Examples

phase("draft")

Root workflow namespace for installed checkpoint, artifact, budget, final, log, and resumeState helpers.

Lifecycle: ActiveActive, since 1.0.0Visibility: Public
Kind: NamespaceMutability: Fixed bindingNullability: Non-nullBinding lifecycle: Live namespace
Symbol path
workflow
Symbol id
javascript.workflow

Examples

workflow.artifact({ kind: "log", label: "step" })

Registers one workflow artifact with kind and label metadata. Optional content must be JSON-compatible and is subject to maxArtifactBytes policy.

Lifecycle: ActiveActive, since 1.0.0Visibility: Public
Kind: Method
Symbol path
workflow.artifact
Symbol id
javascript.workflow.artifact

Shared schemas

Examples

workflow.artifact({ kind: "log", label: "step", content: { step: 1 } })

Returns the current workflow budget counters and emits one budget record. The helper does not accept arguments.

Lifecycle: ActiveActive, since 1.0.0Visibility: Public
Kind: Method
Symbol path
workflow.budget
Symbol id
javascript.workflow.budget

Shared schemas

Examples

workflow.budget()

Persists one labeled checkpoint with optional JSON-compatible state for later resume through workflow.resumeState().

Lifecycle: ActiveActive, since 1.0.0Visibility: Public
Kind: Method
Symbol path
workflow.checkpoint
Symbol id
javascript.workflow.checkpoint

Shared schemas

Examples

workflow.checkpoint({ label: "draft", state: { step: 1 } })

Terminates the workflow with an optional final value. When both workflow.final and a returned value are present, workflow.final wins for terminal result selection.

Lifecycle: ActiveActive, since 1.0.0Visibility: Public
Kind: Method
Symbol path
workflow.final
Symbol id
javascript.workflow.final

Examples

workflow.final({ ok: true, result: { count: 1 } })

Synchronously emits one workflow-scoped log record. The first argument must be a string message; an optional second argument supplies JSON-compatible structured fields.

Lifecycle: ActiveActive, since 1.0.0Visibility: Public
Kind: Method
Symbol path
workflow.log
Symbol id
javascript.workflow.log

Shared schemas

Examples

workflow.log("checkpoint", { step: 1 })

Reads checkpoint state restored for a resumed workflow session, or undefined when no resume state is bound.

Lifecycle: ActiveActive, since 1.0.0Visibility: Public
Kind: Method
Symbol path
workflow.resumeState
Symbol id
javascript.workflow.resume-state

Shared schemas

Examples

workflow.resumeState()

Shared schemas

Closed object shape for workflow.checkpoint spec arguments.

Visibility: Public

Schema

Required
label

Closed object shape for workflow.checkpoint spec arguments.

Properties
  • labelstringRequired
  • state#/sharedSchemas/javascript.schema.json_compatible/schemaOptional

Examples

{ "label": "draft", "state": {} }

Closed object shape for workflow.artifact spec arguments.

Visibility: Public

Schema

Required
kind, label

Closed object shape for workflow.artifact spec arguments.

Properties
  • kindstringRequired
  • labelstringRequired
  • content#/sharedSchemas/javascript.schema.json_compatible/schemaOptional
  • visibilitystringOptional

Examples

{ "kind": "log", "label": "step" }

Closed object shape returned by workflow.budget.

Visibility: Public

Schema

Required
maxAgents, concurrency

Closed object shape returned by workflow.budget.

Properties
  • maxAgentsnumberRequired
  • concurrencynumberRequired
  • sandboxModestringOptional
  • maxRunDurationMsnumberOptional
  • maxWorkerDurationMsnumberOptional
  • maxOutputBytesPerWorkernumberOptional
  • maxArtifactBytesnumberOptional
  • maxTokensnumberOptional

Examples

{ "maxAgents": 4, "concurrency": 2 }

Closed object shape for agent.run spec arguments.

Visibility: Public

Schema

Required
prompt

Closed object shape for agent.run spec arguments.

Properties
  • promptstringRequired
  • labelstringOptional
  • presetstringOptional
  • modelProviderstringOptional
  • modelstringOptional
  • reasoningEffortstringOptional

Examples

{ "prompt": "Summarize findings", "label": "summarize" }