Skip to content

Rulvar API reference


Rulvar API reference / @rulvar/planner

@rulvar/planner

The flagship Rulvar hybrid mode: a planner model writes a workflow script against the sanctioned ctx dialect; the package lints and repairs it from structured diagnostics, compiles it with an import allowlist, and executes it deterministically in the worker sandbox with seeded, journaled globals. Exports plan, runPlanned, compileScript, WorkerSandboxRunner, and apiCard.

The one-line mnemonic against its sibling: @rulvar/planner plans before the run (it writes the script); @rulvar/plan replans during the run (it revises the task plan).

Part of Rulvar, an embeddable TypeScript engine for durable, budget-bounded multi-agent LLM workflows, where a completed LLM call is never paid for twice. Full documentation: docs.rulvar.com.

Install

bash
pnpm add @rulvar/core @rulvar/planner

Documentation

License

Apache-2.0

Classes

ClassDescription
WorkerSandboxRunnerAccepts CompiledWorkflow ONLY: feeding a closure is a type error.

Interfaces

InterfaceDescription
CompileScriptOptions@rulvar/planner: Rulvar flagship hybrid mode: plan agent, compileScript, WorkerSandboxRunner, self-repair loop (https://docs.rulvar.com/guide/planner). The surface lands across M6.
M6CassetteFixtureThe cassette file shape shared with the M3 sets.
PlanDiagnosticOne repair-loop diagnostic: lint and compile findings share the shape.
PlanOptions-
PlanResult-
RunPlannedOptions-
ScriptDiagnosticOne machine-readable compileScript diagnostic (carried by ScriptRejected).
WorkerSandboxRunnerOptions-

Variables

VariableDescription
DEFAULT_SANDBOX_MEMORY_MB-
DEFAULT_SANDBOX_TIMEOUT_MS-
SANDBOX_DETERMINISM_RUN_ID-
SANDBOX_DETERMINISM_SOURCEA script exercising agents, parallel, step, and every seeded shim.
SANDBOX_GLOBALSThe exact curated sandbox global set, in canonical order. The worker binds the ctx methods as bare globals under these names and the API card teaches exactly this list.
SELF_REPAIR_BAD_DRAFTThe failing first draft: bare Date.now trips rulvar/no-bare-date.
SELF_REPAIR_GOAL-
SELF_REPAIR_GOOD_DRAFTThe repaired draft the fake planner returns once diagnostics arrive.
SELF_REPAIR_RUN_ID-

Functions

FunctionDescription
apiCardRenders the sandbox-dialect API card; pure and byte-stable.
compileScript@rulvar/planner: Rulvar flagship hybrid mode: plan agent, compileScript, WorkerSandboxRunner, self-repair loop (https://docs.rulvar.com/guide/planner). The surface lands across M6.
extractScriptThe model may fence the script; the extractor takes the first fenced block when one exists, else the whole reply, and is deterministic.
lintScriptLints a script BODY with the workflows preset plus compileScript. The body is wrapped in an async function for parsing (top-level return/await are legal in the dialect); reported lines shift back so they index into the body source.
normalizeCassetteEntriesThe M3-convention cassette normalization: wall clock and spans only.
plan-
planRunIdOfThe deterministic planner runId: one goal, one journal.
runPlannedplan-then-run in one call (amended during M6-T05: the composition is async because planning itself is a run). options.plan bounds the planning conversation, options.run bounds the generated workflow's execution; the two ceilings are independent, and the bare form without options runs BOTH legs unbounded, as before.
runPlannerSelfRepairOne planner-self-repair run: the first draft fails lint, the JSON diagnostics ride the repair prompt, the second draft compiles. Returns the normalized planning journal plus the plan result.
runSandboxDeterminismOne fresh sandbox-determinism run on a fresh store; two invocations with the same worker produce byte-identical normalized journals (the cassette assertion). The adapter factory keeps @rulvar/testing out of the planner's dependency graph.
scriptDiagnosticsOf@rulvar/planner: Rulvar flagship hybrid mode: plan agent, compileScript, WorkerSandboxRunner, self-repair loop (https://docs.rulvar.com/guide/planner). The surface lands across M6.