API Reference

Step Types

Type definitions for all step variants in Noetic's discriminated union.

Step Union

The Step type is a discriminated union over the kind field:

import type {
  Step,
  StepBranch,
  StepFork,
  StepLLM,
  StepLoop,
  StepProvide,
  StepRun,
  StepSpawn,
  StepTool,
} from '@noetic/core';

type _AssertShape<TMemory, I, O> =
  | StepRun<TMemory, I, O>
  | StepLLM<TMemory, I, O>
  | StepTool<TMemory, I, O>
  | StepBranch<TMemory, I, O>
  | StepFork<TMemory, I, O>
  | StepSpawn<TMemory, I, O>
  | StepProvide<TMemory, I, O>
  | StepLoop<TMemory, I, O>;

type _AssertSubset<TMemory, I, O> = _AssertShape<TMemory, I, O> extends Step<TMemory, I, O>
  ? true
  : false;

The exported Step union additionally includes StepEvery for fixed-interval scheduling.

StepRun

StepRun<TMemory, I, O>

FieldTypeRequiredDescription
kind'run'yesDiscriminant
idstringyesStep identifier
execute(input: I, ctx: Context<TMemory>) => Promise<O>yesAsync function to execute
retryRetryPolicynoRetry configuration

StepLLM

StepLLM<TMemory, I, O>

FieldTypeRequiredDescription
kind'llm'yesDiscriminant
idstringyesStep identifier
modelstringyesModel identifier
instructionsstringnoSystem prompt / instructions for the model
toolsTool[]noAllowed tool subset (undefined = all, [] = none)
outputZodType<O>noStructured output schema
paramsModelParamsnoSampling parameters
emitboolean | ((eventType, data) => boolean)noControls framework event emission for this step. Defaults to true. Pass false to suppress all framework events, or a filter function to allow specific events through.

StepTool

StepTool<TMemory, I, O>

FieldTypeRequiredDescription
kind'tool'yesDiscriminant
idstringyesStep identifier
toolTool<ZodType<I>, ZodType<O>>yesTool definition
argsPartial<I>noPreset arguments

StepBranch

StepBranch<TMemory, I, O>

FieldTypeRequiredDescription
kind'branch'yesDiscriminant
idstringyesStep identifier
route(input: I, ctx: Context<TMemory>) => Step<TMemory, I, O> | nullyesRouting function (null skips)

StepFork

Fork has three mode variants, each a separate interface.

StepForkRace

StepForkRace<TMemory, I, O>

FieldTypeRequiredDescription
kind'fork'yesDiscriminant
idstringyesStep identifier
mode'race'yesFirst completion wins
paths(input: I, ctx: Context<TMemory>) => Step<TMemory, I, O>[]yesPath factory
concurrencynumbernoMax parallel paths

StepForkAll

StepForkAll<TMemory, I, O>

FieldTypeRequiredDescription
kind'fork'yesDiscriminant
idstringyesStep identifier
mode'all'yesWait for all paths
paths(input: I, ctx: Context<TMemory>) => Step<TMemory, I, O>[]yesPath factory
merge(results: O[], ctx: Context<TMemory>) => OyesMerge function
concurrencynumbernoMax parallel paths

StepForkSettle

StepForkSettle<TMemory, I, O>

FieldTypeRequiredDescription
kind'fork'yesDiscriminant
idstringyesStep identifier
mode'settle'yesWait for all, include errors
paths(input: I, ctx: Context<TMemory>) => Step<TMemory, I, O>[]yesPath factory
merge(results: SettleResult<O>[], ctx: Context<TMemory>) => OyesMerge function
concurrencynumbernoMax parallel paths

StepProvide

StepProvide<TMemory, I, O>

FieldTypeRequiredDescription
kind'provide'yesDiscriminant
idstringyesStep identifier
childStep<TMemory, I, O>yesChild step to execute with the provided layers
memoryMemoryConfig | MemoryLayer[]yesMemory layers available to all descendant steps

StepSpawn

StepSpawn<TMemory, I, O>

FieldTypeRequiredDescription
kind'spawn'yesDiscriminant
idstringyesStep identifier
childStep<TMemory, I, O>yesChild step to execute
memoryMemoryConfig | MemoryLayer[]noSpawn-local memory layers
timeoutnumbernoTimeout in milliseconds

StepLoop

StepLoop<TMemory, I, O>

FieldTypeRequiredDescription
kind'loop'yesDiscriminant
idstringyesStep identifier
stepsReadonlyArray<Step<TMemory, I, O>>yesLoop body steps
untilUntilyesTermination predicate
maxIterationsnumbernoSafety limit on iterations
maxHistorySizenumbernoMax history items to retain
inboxChannel<string>noChannel for external messages that prevent loop from stopping
parkTimeoutnumbernoMilliseconds to wait on inbox before stopping (0 = non-blocking)
prepareNext(output: O, verdict: Verdict, ctx: Context<TMemory>) => InoTransform output to next input
onError(error: NoeticError, ctx: Context<TMemory>) => 'retry' | 'skip' | 'abort'noError handler

StepEvery

StepEvery<TMemory, I, O>

A step that runs a body step on a fixed-interval schedule, optionally woken sooner by a wake channel. Runs forever until the executing context is cancelled. The operator output is voidevery does not accumulate iteration outputs.

FieldTypeRequiredDescription
kind'every'yesDiscriminant
idstringyesStep identifier
stepStep<TMemory, I, O>yesBody step executed on each iteration
msnumberyesPark duration between iterations in milliseconds. Must be >= 0.
wakeOnChannel<unknown>noChannel that wakes the parking interval when any value arrives
onError'continue' | 'fail'noBehavior when step throws. Defaults to 'continue' (record the error and keep parking).
jitternumbernoRandom jitter applied to the park duration in milliseconds. Must be >= 0. Defaults to 0.

Supporting Types

SettleResult

FieldTypeDescription
stepIdstringStep that produced this result
status'fulfilled' | 'rejected'Outcome
valueOPresent if fulfilled
errorNoeticErrorPresent if rejected

RetryPolicy

FieldTypeDescription
maxAttemptsnumberMaximum retry attempts
backoff'fixed' | 'linear' | 'exponential'Backoff strategy
initialDelaynumberInitial delay in milliseconds
maxDelaynumberMaximum delay cap (optional)

ModelParams

FieldTypeDescription
temperaturenumberSampling temperature (optional)
topPnumberNucleus sampling (optional)
maxTokensnumberMax response tokens (optional)
stopSequencesstring[]Stop sequences (optional)

Tool

FieldTypeDescription
namestringTool name (used by the LLM for selection).
descriptionstringTool description shown to the LLM.
inputZodType<I>Zod schema validating tool input arguments.
outputZodType<O>Zod schema validating tool return value.
eventZodTypeOptional Zod schema validating streaming events yielded during execution.
itemSchemasItemSchemaExtensionsOptional item schemas for tool-call/result extensions contributed by this tool.
decorateResultItem(params) => ItemDecorate the harness-created tool-result item before it is appended/emitted.
execute(args: z.infer<I>, toolCtx: ToolExecutionContext) => Promise<z.infer<O>> | AsyncGenerator<unknown, z.infer<O>>Async function (or generator) that performs the tool's work.
needsApprovalbooleanOptional. When true, execution pauses for human approval before running.
memoryToolMemoryDeclarationOptional. Declares tool-owned memory the runtime materializes into a MemoryLayer.

ExecuteStepFn

declare const executeStepShape: <TMemory, I, O>(
  step: Step<TMemory, I, O>,
  input: I,
  ctx: Context<TMemory>,
) => Promise<O>;

On this page