@flow-state-dev/patterns
Interfaces
ParallelTasksConfig
Type Parameters
TOutputSchema
TOutputSchema extends ZodTypeAny = ZodTypeAny
Properties
maxConcurrency?
maxConcurrency?: number;
Maximum number of sub-tasks to run concurrently. Defaults to 3.
maxEnqueuedTasks?
maxEnqueuedTasks?: number | null;
maxTotalRetries?
maxTotalRetries?: number | null;
Cumulative failure retries the internal board may authorize, across every
task. Default 50 — a number, or null for explicitly unbounded.
The two bounds above count only new tasks, so a task that keeps failing
keeps spending while both sit still. This is the one number that bounds
that. At the bound the failing task settles terminal errored instead of
re-pending, and the board reports terminationReason: "retry-budget-exhausted". 0 means "run every task once, never retry".
Reachable here even though this pattern has no maxAttemptsPerTask
option: the planning entry stamps maxAttempts straight from planner
output, so a planned task can carry one and retry.
maxTotalTasks?
maxTotalTasks?: number | null;
Creation bounds for the internal board. Defaults 500/100 —
unchanged behavior when unset. A planner that legitimately produces more
than the enqueue bound would otherwise fail its whole seed with no way to
raise the ceiling, so both are reachable here: a number, or null for
explicitly unbounded on that axis.
name
name: string;
Name for this parallelTasks instance.
onSubTaskError?
onSubTaskError?: SubTaskErrorStrategy;
How to handle individual sub-task failures.
skip(default): exclude failed sub-tasks; pass completed results to synthesizerfail: abort entire coordination on any failure
outputSchema?
outputSchema?: TOutputSchema;
Schema for the synthesized output. Passed to the default combiner when no custom synthesizer is provided.
planner?
planner?: BlockDefinition<any, any, any, any>;
Override the planning step. Defaults to utility.decomposer().
synthesizer?
synthesizer?: BlockDefinition<any, any, any, any>;
Final synthesis block. Receives unknown[] of completed task outputs.
When omitted, utility.combiner() is used.
worker
worker: BlockDefinition<any, any>;
The worker block that processes each sub-task. Receives TaskWorkerInput.
Type Aliases
DebateInput
type DebateInput = z.infer<typeof debateInputSchema>;
PlanAndExecuteInput
type PlanAndExecuteInput = z.infer<typeof planAndExecuteInputSchema>;
RoundRobinInput
type RoundRobinInput = z.infer<typeof roundRobinInputSchema>;
SubTaskErrorStrategy
type SubTaskErrorStrategy = "skip" | "fail";
Variables
debateInputSchema
const debateInputSchema: z.ZodObject<{
question: z.ZodString;
}, "strip", z.ZodTypeAny, {
question: string;
}, {
question: string;
}>;
Input shape accepted by a debate block.
parallelTasksInputSchema
const parallelTasksInputSchema: z.ZodObject<{
goal: z.ZodString;
}, "strip", z.ZodTypeAny, {
goal: string;
}, {
goal: string;
}>;
planAndExecuteInputSchema
const planAndExecuteInputSchema: z.ZodObject<{
goal: z.ZodString;
}, "strip", z.ZodTypeAny, {
goal: string;
}, {
goal: string;
}>;
reviewerInputSchema
const reviewerInputSchema: z.ZodObject<{
attempts: z.ZodDefault<z.ZodNumber>;
criteria: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
goal: z.ZodString;
taskId: z.ZodString;
workerOutput: z.ZodUnknown;
}, "strip", z.ZodTypeAny, {
attempts: number;
criteria?: string[];
goal: string;
taskId: string;
workerOutput?: unknown;
}, {
attempts?: number;
criteria?: string[];
goal: string;
taskId: string;
workerOutput?: unknown;
}>;
Input shape passed to a reviewer block — worker output plus task metadata.
reviewerVerdictSchema
const reviewerVerdictSchema: z.ZodObject<{
criteria: z.ZodOptional<z.ZodArray<z.ZodObject<{
name: z.ZodString;
score: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
name: string;
score: number;
}, {
name: string;
score: number;
}>, "many">>;
decision: z.ZodEnum<["approve", "reject", "needs-revision"]>;
feedback: z.ZodOptional<z.ZodString>;
reasoning: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
criteria?: object[];
decision: "approve" | "needs-revision" | "reject";
feedback?: string;
reasoning?: string;
}, {
criteria?: object[];
decision: "approve" | "needs-revision" | "reject";
feedback?: string;
reasoning?: string;
}>;
Per-task reviewer verdict. applyVerdict flows the worker output
through on approve; on reject / needs-revision it throws so
the substrate's recordError + maxAttempts machinery handles the
retry.
roundRobinInputSchema
const roundRobinInputSchema: z.ZodObject<{
goal: z.ZodString;
}, "strip", z.ZodTypeAny, {
goal: string;
}, {
goal: string;
}>;
Input shape accepted by a roundRobin block.
Functions
createWorkspace()
function createWorkspace<TStateSchema>(stateSchema): object & ResourceConfig<JsonObject> & object;
Creates a workspace resource — the shared writable surface specialists
read from and contribute to. Renamed from createBlackboard; same
semantics. The user supplies the full schema; the pattern imposes no
structure on the workspace contents.
Type Parameters
TStateSchema
TStateSchema extends ZodTypeAny
Parameters
stateSchema
TStateSchema
Returns
object & ResourceConfig<JsonObject> & object
parallelTasks()
function parallelTasks<TOutputSchema>(config): SequencerDefinition<any, any>;
Creates a parallelTasks block — a sequencer that decomposes a goal into sub-tasks, dispatches a worker for each concurrently via taskBoard, and synthesizes results.
Type Parameters
TOutputSchema
TOutputSchema extends ZodTypeAny = ZodTypeAny
Parameters
config
ParallelTasksConfig<TOutputSchema>
Returns
SequencerDefinition<any, any>
References
actor
Re-exports actor
Actor
Re-exports Actor
ActorConfig
Re-exports ActorConfig
createEventActorsWorkspace
Re-exports createEventActorsWorkspace
debate
Re-exports debate
DebateConfig
Re-exports DebateConfig
DebaterConfig
Re-exports DebaterConfig
eventActors
Re-exports eventActors
EventActorsConfig
Re-exports EventActorsConfig
EventActorsHandle
Re-exports EventActorsHandle
EventActorsWorkspaceConfig
Re-exports EventActorsWorkspaceConfig
planAndExecute
Re-exports planAndExecute
PlanAndExecuteConfig
Re-exports PlanAndExecuteConfig
RosterEntry
Re-exports RosterEntry
roundRobin
Re-exports roundRobin
RoundRobinConfig
Re-exports RoundRobinConfig
routedSpecialists
Re-exports routedSpecialists
RoutedSpecialistsConfig
Re-exports RoutedSpecialistsConfig
supervisor
Re-exports supervisor
SupervisorConfig
Re-exports SupervisorConfig