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:

type Step<I = unknown, O = unknown> =
  | StepRun<I, O>
  | StepLLM<I, O>
  | StepTool<I, O>
  | StepBranch<I, O>
  | StepFork<I, O>
  | StepSpawn<I, O>
  | StepLoop<I, O>;

StepRun

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

StepLLM

FieldTypeRequiredDescription
kind'llm'yesDiscriminant
idstringyesStep identifier
modelstringyesModel identifier
systemstringnoSystem prompt
toolsTool[]noAvailable tools
outputZodType<O>noStructured output schema
paramsModelParamsnoSampling parameters

StepTool

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

StepBranch

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

StepFork

Fork has three mode variants, each a separate interface.

StepForkRace

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

StepForkAll

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

StepForkSettle

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

StepSpawn

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

StepLoop

FieldTypeRequiredDescription
kind'loop'yesDiscriminant
idstringyesStep identifier
bodyStep<I, O>yesLoop body step
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) => InoTransform output to next input
onError(error: NoeticError, ctx: Context) => 'retry' | 'skip' | 'abort'noError handler

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
descriptionstringTool description for the LLM
inputZodTypeInput schema
outputZodTypeOutput schema
execute(args: I, ctx: Context) => Promise<O>Execution function
needsApprovalbooleanWhether the tool requires human approval (optional)

ExecuteStepFn

type ExecuteStepFn = <I, O>(step: Step<I, O>, input: I, ctx: Context) => Promise<O>;

On this page