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.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.
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.
- 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.
- 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.
- Symbol path
- log
- Symbol id
- javascript.log
Shared schemas
- javascript.schema.json_compatible#/sharedSchemas/javascript.schema.json_compatible/schema
Examples
log("checkpoint", { step: 1 })Root agent namespace for the installed agent.run child-dispatch helper.
- 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.
- Symbol path
- agent.run
- Symbol id
- javascript.agent.run
Shared schemas
- javascript.schema.agent_run_spec#/sharedSchemas/javascript.schema.agent_run_spec/schema
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.
- 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.
- 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.
- Symbol path
- phase
- Symbol id
- javascript.phase
Examples
phase("draft")Root workflow namespace for installed checkpoint, artifact, budget, final, log, and resumeState helpers.
- 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.
- Symbol path
- workflow.artifact
- Symbol id
- javascript.workflow.artifact
Shared schemas
- javascript.schema.artifact_spec#/sharedSchemas/javascript.schema.artifact_spec/schema
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.
- Symbol path
- workflow.budget
- Symbol id
- javascript.workflow.budget
Shared schemas
- javascript.schema.budget_snapshot#/sharedSchemas/javascript.schema.budget_snapshot/schema
Examples
workflow.budget()
Persists one labeled checkpoint with optional JSON-compatible state for later resume through workflow.resumeState().
- Symbol path
- workflow.checkpoint
- Symbol id
- javascript.workflow.checkpoint
Shared schemas
- javascript.schema.checkpoint_spec#/sharedSchemas/javascript.schema.checkpoint_spec/schema
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.
- 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.
- Symbol path
- workflow.log
- Symbol id
- javascript.workflow.log
Shared schemas
- javascript.schema.json_compatible#/sharedSchemas/javascript.schema.json_compatible/schema
Examples
workflow.log("checkpoint", { step: 1 })Reads checkpoint state restored for a resumed workflow session, or undefined when no resume state is bound.
- Symbol path
- workflow.resumeState
- Symbol id
- javascript.workflow.resume-state
Shared schemas
- javascript.schema.checkpoint_spec#/sharedSchemas/javascript.schema.checkpoint_spec/schema
Examples
workflow.resumeState()