Skip to main content

utility

Interfaces​

AnalyzerConfig​

Type Parameters​

TOutputSchema​

TOutputSchema extends ZodTypeAny = typeof analyzerOutputSchema

Properties​

criteria?​
criteria?: string[];
itemVisibility?​
itemVisibility?: ItemVisibility;

Identity for emitted items. Unset by default — analysis output flows via graph edges only. Set to "primary" to surface findings to the user, or "trace" for observability-only runs.

model?​
model?: ResolvableModel<any, BlockContext<Record<string, unknown>, {
[key: string]: unknown;
}, Record<string, unknown>, Record<string, unknown>, {
[key: string]: ResourceRef<any>;
}, {
[key: string]: unknown;
}, unknown, undefined, {
}, {
[key: string]: unknown;
}, Record<string, unknown>, Readonly<Record<string, unknown>>>>;
name​
name: string;
outputSchema?​
outputSchema?: TOutputSchema;

CascadeLevel​

One level of the tree: the evaluator to ask, the id of the choice question to route on, and one branch per option to route.

Properties​

ask​
ask: AnyEvaluatorBlock;
branches​
branches: Readonly<Record<string, CascadeBranch>>;
on​
on: string;

CascadingRouterConfig​

Config for cascadingRouter. The router's input is what the root evaluator accepts; every evaluator, leaf and ambiguous must accept it.

Type Parameters​

TRoot​

TRoot extends CascadeLevel

TAmbiguous​

TAmbiguous extends BlockDefinition<any, any>

Properties​

ambiguous​
ambiguous: TAmbiguous & AcceptsInput<TAmbiguous, CascadeInputOf<TRoot>>;

Where every edge that doesn't open goes, at any level: no confidence reported, confidence below the edge's floor, or an option with no branch. Receives the router's own input; its output is one of the router's.

name​
name: string;

The router's name. Levels, gates and routes are named under it.

root​
root: TRoot & CheckedLevel<TRoot, CascadeInputOf<TRoot>>;

The first level of the tree.


CombinerConfig​

Type Parameters​

TOutputSchema​

TOutputSchema extends ZodTypeAny = typeof combinerOutputSchema

Properties​

name​
name: string;
outputSchema?​
outputSchema?: TOutputSchema;

ContextReducerConfig​

Type Parameters​

TOutputSchema​

TOutputSchema extends ZodTypeAny = typeof contextReducerDistillOutputSchema

Properties​

itemVisibility?​
itemVisibility?: ItemVisibility;

Identity for emitted items. Unset by default — reducer output flows via graph edges only. Set to "primary" to surface the reduction to the user, or "trace" for observability-only runs.

mode?​
mode?: "distill" | "denoise" | "compress";
model?​
model?: ResolvableModel<any, BlockContext<Record<string, unknown>, {
[key: string]: unknown;
}, Record<string, unknown>, Record<string, unknown>, {
[key: string]: ResourceRef<any>;
}, {
[key: string]: unknown;
}, unknown, undefined, {
}, {
[key: string]: unknown;
}, Record<string, unknown>, Readonly<Record<string, unknown>>>>;
name​
name: string;
outputSchema?​
outputSchema?: TOutputSchema;

DecomposerConfig​

Type Parameters​

TOutputSchema​

TOutputSchema extends ZodTypeAny = typeof decomposerOutputSchema

Properties​

context?​
context?: GeneratorSlot;

Additional context injected into the system prompt before decomposition.

history?​
history?: GeneratorHistoryConfig;

History slot — provides conversation history so the decomposer can resolve references.

itemVisibility?​
itemVisibility?: ItemVisibility;

Identity for emitted items. Unset by default — decomposed task lists flow via graph edges only. Set to "primary" to surface the plan to the user, or "trace" for observability-only runs.

model?​
model?: ResolvableModel<any, BlockContext<Record<string, unknown>, {
[key: string]: unknown;
}, Record<string, unknown>, Record<string, unknown>, {
[key: string]: ResourceRef<any>;
}, {
[key: string]: unknown;
}, unknown, undefined, {
}, {
[key: string]: unknown;
}, Record<string, unknown>, Readonly<Record<string, unknown>>>>;
name​
name: string;
outputSchema?​
outputSchema?: TOutputSchema;

HistorySummaryOptions​

Properties​

name?​
name?: string;

The resource's accessor name and storage key. Default historySummary.

summarize​
summarize: BlockDefinition<any, any>;

The block that writes the summary: handed the summary so far and the turns to fold, returning { summary }, optionally with keyPoints, which are kept under the summary. Core's summarizer(...) returns that shape.


IntentClassifierConfig​

Type Parameters​

TOutputSchema​

TOutputSchema extends ZodTypeAny = ZodTypeAny

Properties​

categories​
categories: IntentCategories;
itemVisibility?​
itemVisibility?: ItemVisibility;

Identity for emitted items. Unset by default — classification output flows via graph edges only, which is the usual routing case. Set to "primary" if you want the classification surfaced to the user, or "trace" for observability-only runs.

model?​
model?: ResolvableModel<any, BlockContext<Record<string, unknown>, {
[key: string]: unknown;
}, Record<string, unknown>, Record<string, unknown>, {
[key: string]: ResourceRef<any>;
}, {
[key: string]: unknown;
}, unknown, undefined, {
}, {
[key: string]: unknown;
}, Record<string, unknown>, Readonly<Record<string, unknown>>>>;
name​
name: string;
outputSchema?​
outputSchema?: TOutputSchema;

IntentClassifierOutput​

Properties​

category​
category: string;
confidence​
confidence: number;
reasoning​
reasoning: string;

IntentRouterConfig​

Type Parameters​

TCategories​

TCategories extends IntentRouterCategories

Properties​

categories​
categories: TCategories;
confidenceThreshold?​
confidenceThreshold?: number;
fallback?​
fallback?: BlockDefinition<ZodTypeAny, ZodTypeAny, any, any>;
model?​
model?: ResolvableModel<any, BlockContext<Record<string, unknown>, {
[key: string]: unknown;
}, Record<string, unknown>, Record<string, unknown>, {
[key: string]: ResourceRef<any>;
}, {
[key: string]: unknown;
}, unknown, undefined, {
}, {
[key: string]: unknown;
}, Record<string, unknown>, Readonly<Record<string, unknown>>>>;
name​
name: string;

KeyedRouterConfig​

Type Parameters​

TInputSchema​

TInputSchema extends ZodTypeAny = ZodTypeAny

TOutputSchema​

TOutputSchema extends ZodTypeAny = ZodTypeAny

TInput​

TInput = z.infer<TInputSchema>

Properties​

blocks​
blocks: Record<string, BlockDefinition<any, any>>;

String-keyed routing table. Keys are the values select returns. Only own properties count as registered routes.

fallback?​
fallback?: BlockDefinition<any, any, any, any>;

Optional block to run when select returns a key absent from blocks. Without a fallback, an unknown key throws with the list of registered keys for fast debugging.

inputSchema?​
inputSchema?: TInputSchema;
name​
name: string;
outputSchema?​
outputSchema?: TOutputSchema;
select​
select: (input, ctx) => string;
Parameters​
input​

TInput

ctx​

BlockContext

Returns​

string


MemoryExtractorConfig​

Type Parameters​

TOutputSchema​

TOutputSchema extends ZodTypeAny = typeof memoryExtractorOutputSchema

Properties​

itemVisibility?​
itemVisibility?: ItemVisibility;

Identity for emitted items. Unset by default — extractor output is a background step that flows via graph edges to a memory-write handler. Set to "trace" for observability-only runs, or "primary" if the extraction itself should be visible to the user.

model?​
model?: ResolvableModel<any, BlockContext<Record<string, unknown>, {
[key: string]: unknown;
}, Record<string, unknown>, Record<string, unknown>, {
[key: string]: ResourceRef<any>;
}, {
[key: string]: unknown;
}, unknown, undefined, {
}, {
[key: string]: unknown;
}, Record<string, unknown>, Readonly<Record<string, unknown>>>>;
name​
name: string;
outputSchema?​
outputSchema?: TOutputSchema;

SessionTitleGeneratorConfig​

Properties​

messageLimit?​
messageLimit?: number;

Maximum number of recent conversational turns to include for title generation. One turn = one user → assistant request (tool-call/result messages within a turn ride along).

Default​
4
model?​
model?: string;
name​
name: string;

SummarizerConfig​

Type Parameters​

TOutputSchema​

TOutputSchema extends ZodTypeAny = typeof summarizerOutputSchema

Properties​

granularity?​
granularity?: "brief" | "detailed" | "executive";
itemVisibility?​
itemVisibility?: ItemVisibility;

Identity for emitted items. Unset by default — summaries flow via graph edges only. Set to "primary" to surface the summary to the user, or "trace" for observability-only runs.

model?​
model?: ResolvableModel<any, BlockContext<Record<string, unknown>, {
[key: string]: unknown;
}, Record<string, unknown>, Record<string, unknown>, {
[key: string]: ResourceRef<any>;
}, {
[key: string]: unknown;
}, unknown, undefined, {
}, {
[key: string]: unknown;
}, Record<string, unknown>, Readonly<Record<string, unknown>>>>;
name​
name: string;
objectives?​
objectives?: string | string[];
outputSchema?​
outputSchema?: TOutputSchema;

UpsertResourceConfig​

Type Parameters​

TInputSchema​

TInputSchema extends ZodTypeAny

Properties​

collectionKey​
collectionKey: string;

Accessor key into ctx.resources pointing at the target collection. The collection's intrinsic scope and ref decide where its instances persist.

content?​
content?: (input) => string | undefined;

Optional: content to write after upsert.

Parameters​
input​

TypeOf<TInputSchema>

Returns​

string | undefined

description?​
description?: string;
inputSchema​
inputSchema: TInputSchema;
key​
key: (input) => string;

Derive the resource key from input.

Parameters​
input​

TypeOf<TInputSchema>

Returns​

string

name​
name: string;

Block name.

resources?​
resources?: Record<string, DeclaredResourceEntry>;

Flat resource declarations the block needs registered.

sequencerStateSchema?​
sequencerStateSchema?: ZodTypeAny;

State schema of the outer sequencer, if the block needs to read/write sequencer state.

state​
state: (input, ctx) => Record<string, unknown>;

Derive state to create/patch from input.

Parameters​
input​

TypeOf<TInputSchema>

ctx​

BlockContext

Returns​

Record<string, unknown>

Type Aliases​

CascadeAmbiguousReason​

type CascadeAmbiguousReason = "no-confidence" | "below-floor" | "no-branch";

Why a gate did not open an edge.


CascadeBranch​

type CascadeBranch =
| {
block: BlockDefinition<any, any>;
minConfidence?: number;
next?: never;
}
| {
block?: never;
minConfidence?: number;
next: CascadeLevel;
};

One branch of a level: run a block, or ask the next level. An optional minConfidence in [0, 1] is the edge's floor, compared inclusively.


CascadeVerdict​

type CascadeVerdict =
| {
confidence: number;
edge: string;
level: string;
on: string;
}
| {
ambiguous: CascadeAmbiguousReason;
choice?: string;
level: string;
on: string;
};

What the gate step decided at one level, as it appears in the trace.


ConsultSessionHistoryOptions​

type ConsultSessionHistoryOptions = object;

Options for consultSessionHistoryTool.

Properties​

budgetTokens?​
budgetTokens?: number;

The hard cap on history tokens the generator receives. Default 24,000.

description?​
description?: string;

The tool's description, for a wrapper that says it in its own words.

model?​
model?: GeneratorConfig["model"];

The model the answer runs on. Default intent/utility: the app says what is cheaper.

name?​
name?: string;

The tool's name, as the model calls it. Default consultSessionHistory.

target?​
target?: object;

For a wrapper that names the session its own way (Workforce's of): its input schema, which must carry question, and how an input resolves to a session. The default takes { sessionId, question }.

inputSchema​
inputSchema: ZodTypeAny;
resolve​
resolve: (input, ctx) => Promise<ConsultTarget>;
Parameters​
input​

any

ctx​

BlockContext

Returns​

Promise<ConsultTarget>


ConsultTarget​

type ConsultTarget =
| {
of: unknown;
ok: true;
sessionId: string;
}
| {
error: string;
ok: false;
};

Where a consult reads: the session, and how the result names it.


ContextReducerMode​

type ContextReducerMode = keyof typeof CONTEXT_REDUCER_INSTRUCTIONS;

HistorySummaryInput​

type HistorySummaryInput = object;

What summarize is handed on each fold.

Properties​

summary​
summary: string | null;

The running summary so far; null on the first fold.

turns​
turns: LLMMessage[];

The turns being folded, oldest first, as the model would have read them.


HistorySummaryState​

type HistorySummaryState = z.infer<typeof historySummaryStateSchema>;

IntentCategories​

type IntentCategories = Record<string, string>;

IntentRouterCategories​

type IntentRouterCategories = Record<string, IntentRouterCategory>;

IntentRouterCategory​

type IntentRouterCategory = object;

Properties​

description​
description: string;
handler​
handler: BlockDefinition;

SummarizerGranularity​

type SummarizerGranularity = keyof typeof GRANULARITY_INSTRUCTIONS;

Variables​

analyzerFindingSchema​

const analyzerFindingSchema: z.ZodObject<{
assessment: z.ZodString;
criterion: z.ZodString;
evidence: z.ZodOptional<z.ZodString>;
severity: z.ZodOptional<z.ZodEnum<["critical", "warning", "info"]>>;
}, "strip", ZodTypeAny, {
assessment: string;
criterion: string;
evidence?: string;
severity?: "critical" | "info" | "warning";
}, {
assessment: string;
criterion: string;
evidence?: string;
severity?: "critical" | "info" | "warning";
}>;

analyzerOutputSchema​

const analyzerOutputSchema: z.ZodObject<{
findings: z.ZodArray<z.ZodObject<{
assessment: z.ZodString;
criterion: z.ZodString;
evidence: z.ZodOptional<z.ZodString>;
severity: z.ZodOptional<z.ZodEnum<["critical", "warning", "info"]>>;
}, "strip", ZodTypeAny, {
assessment: string;
criterion: string;
evidence?: string;
severity?: "critical" | "info" | "warning";
}, {
assessment: string;
criterion: string;
evidence?: string;
severity?: "critical" | "info" | "warning";
}>, "many">;
recommendation: z.ZodOptional<z.ZodString>;
score: z.ZodOptional<z.ZodNumber>;
}, "strip", ZodTypeAny, {
findings: object[];
recommendation?: string;
score?: number;
}, {
findings: object[];
recommendation?: string;
score?: number;
}>;

combinerOutputSchema​

const combinerOutputSchema: z.ZodObject<{
combined: z.ZodUnknown;
mergeNotes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
}, "strip", ZodTypeAny, {
combined?: unknown;
mergeNotes?: string[];
}, {
combined?: unknown;
mergeNotes?: string[];
}>;

CONSULT_DEFAULT_BUDGET_TOKENS​

const CONSULT_DEFAULT_BUDGET_TOKENS: 24000 = 24000;

The default hard cap on the history tokens the consult's generator receives.


consultSessionHistoryInputSchema​

const consultSessionHistoryInputSchema: z.ZodObject<{
question: z.ZodString;
sessionId: z.ZodString;
}, "strict", ZodTypeAny, {
question: string;
sessionId: string;
}, {
question: string;
sessionId: string;
}>;

The default input: a session of the principal's, by id, and the question.


contextReducerCompressOutputSchema​

const contextReducerCompressOutputSchema: z.ZodObject<{
compressed: z.ZodString;
compressionRatio: z.ZodOptional<z.ZodNumber>;
dropped: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
}, "strip", ZodTypeAny, {
compressed: string;
compressionRatio?: number;
dropped?: string[];
}, {
compressed: string;
compressionRatio?: number;
dropped?: string[];
}>;

contextReducerDenoiseOutputSchema​

const contextReducerDenoiseOutputSchema: z.ZodObject<{
cleaned: z.ZodString;
removedCategories: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
}, "strip", ZodTypeAny, {
cleaned: string;
removedCategories?: string[];
}, {
cleaned: string;
removedCategories?: string[];
}>;

contextReducerDistillOutputSchema​

const contextReducerDistillOutputSchema: z.ZodObject<{
distilled: z.ZodString;
keyPoints: z.ZodArray<z.ZodString, "many">;
}, "strip", ZodTypeAny, {
distilled: string;
keyPoints: string[];
}, {
distilled: string;
keyPoints: string[];
}>;

decomposerOutputSchema​

const decomposerOutputSchema: z.ZodObject<{
tasks: z.ZodArray<z.ZodObject<{
context: z.ZodNullable<z.ZodString>;
deps: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
goal: z.ZodString;
id: z.ZodString;
priority: z.ZodOptional<z.ZodEnum<["high", "medium", "low"]>>;
title: z.ZodNullable<z.ZodString>;
}, "strip", ZodTypeAny, {
context: string | null;
deps?: string[];
goal: string;
id: string;
priority?: "high" | "low" | "medium";
title: string | null;
}, {
context: string | null;
deps?: string[];
goal: string;
id: string;
priority?: "high" | "low" | "medium";
title: string | null;
}>, "many">;
}, "strip", ZodTypeAny, {
tasks: object[];
}, {
tasks: object[];
}>;

decomposerTaskSchema​

const decomposerTaskSchema: z.ZodObject<{
context: z.ZodNullable<z.ZodString>;
deps: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
goal: z.ZodString;
id: z.ZodString;
priority: z.ZodOptional<z.ZodEnum<["high", "medium", "low"]>>;
title: z.ZodNullable<z.ZodString>;
}, "strip", ZodTypeAny, {
context: string | null;
deps?: string[];
goal: string;
id: string;
priority?: "high" | "low" | "medium";
title: string | null;
}, {
context: string | null;
deps?: string[];
goal: string;
id: string;
priority?: "high" | "low" | "medium";
title: string | null;
}>;

historySummaryStateSchema​

const historySummaryStateSchema: z.ZodObject<{
attempts: z.ZodDefault<z.ZodNumber>;
complete: z.ZodDefault<z.ZodBoolean>;
folds: z.ZodDefault<z.ZodNumber>;
gap: z.ZodDefault<z.ZodBoolean>;
nextRequestId: z.ZodDefault<z.ZodNullable<z.ZodString>>;
nextSettledRequestId: z.ZodDefault<z.ZodNullable<z.ZodString>>;
pending: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
summary: z.ZodDefault<z.ZodNullable<z.ZodString>>;
throughRequestId: z.ZodDefault<z.ZodNullable<z.ZodString>>;
throughStartedAtMs: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
}, "strip", z.ZodTypeAny, {
attempts: number;
complete: boolean;
folds: number;
gap: boolean;
nextRequestId: string | null;
nextSettledRequestId: string | null;
pending: string[];
summary: string | null;
throughRequestId: string | null;
throughStartedAtMs: number | null;
}, {
attempts?: number;
complete?: boolean;
folds?: number;
gap?: boolean;
nextRequestId?: string | null;
nextSettledRequestId?: string | null;
pending?: string[];
summary?: string | null;
throughRequestId?: string | null;
throughStartedAtMs?: number | null;
}>;

The session resource a history summary keeps.


memoryCandidateSchema​

const memoryCandidateSchema: z.ZodObject<{
confidence: z.ZodOptional<z.ZodNumber>;
content: z.ZodString;
source: z.ZodOptional<z.ZodString>;
type: z.ZodEnum<["fact", "preference", "constraint", "decision"]>;
}, "strip", ZodTypeAny, {
confidence?: number;
content: string;
source?: string;
type: "constraint" | "decision" | "fact" | "preference";
}, {
confidence?: number;
content: string;
source?: string;
type: "constraint" | "decision" | "fact" | "preference";
}>;

memoryExtractorOutputSchema​

const memoryExtractorOutputSchema: z.ZodObject<{
memories: z.ZodArray<z.ZodObject<{
confidence: z.ZodOptional<z.ZodNumber>;
content: z.ZodString;
source: z.ZodOptional<z.ZodString>;
type: z.ZodEnum<["fact", "preference", "constraint", "decision"]>;
}, "strip", ZodTypeAny, {
confidence?: number;
content: string;
source?: string;
type: "constraint" | "decision" | "fact" | "preference";
}, {
confidence?: number;
content: string;
source?: string;
type: "constraint" | "decision" | "fact" | "preference";
}>, "many">;
}, "strip", ZodTypeAny, {
memories: object[];
}, {
memories: object[];
}>;

memoryExtractorTypeSchema​

const memoryExtractorTypeSchema: z.ZodEnum<["fact", "preference", "constraint", "decision"]>;

summarizerOutputSchema​

const summarizerOutputSchema: z.ZodObject<{
keyPoints: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
summary: z.ZodString;
}, "strip", ZodTypeAny, {
keyPoints?: string[];
summary: string;
}, {
keyPoints?: string[];
summary: string;
}>;

Functions​

analyzer()​

function analyzer<TOutputSchema>(config): BlockDefinition<ZodTypeAny,
| TOutputSchema
| ZodObject<{
findings: ZodArray<ZodObject<{
assessment: ZodString;
criterion: ZodString;
evidence: ZodOptional<ZodString>;
severity: ZodOptional<ZodEnum<["critical", "warning", "info"]>>;
}, "strip", ZodTypeAny, {
assessment: string;
criterion: string;
evidence?: string;
severity?: "warning" | "critical" | "info";
}, {
assessment: string;
criterion: string;
evidence?: string;
severity?: "warning" | "critical" | "info";
}>, "many">;
recommendation: ZodOptional<ZodString>;
score: ZodOptional<ZodNumber>;
}, "strip", ZodTypeAny, {
findings: object[];
recommendation?: string;
score?: number;
}, {
findings: object[];
recommendation?: string;
score?: number;
}>, any, TypeOf<
| TOutputSchema
| ZodObject<{
findings: ZodArray<ZodObject<{
assessment: ZodString;
criterion: ZodString;
evidence: ZodOptional<ZodString>;
severity: ZodOptional<ZodEnum<[..., ..., ...]>>;
}, "strip", ZodTypeAny, {
assessment: string;
criterion: string;
evidence?: string;
severity?: "warning" | "critical" | "info";
}, {
assessment: string;
criterion: string;
evidence?: string;
severity?: "warning" | "critical" | "info";
}>, "many">;
recommendation: ZodOptional<ZodString>;
score: ZodOptional<ZodNumber>;
}, "strip", ZodTypeAny, {
findings: object[];
recommendation?: string;
score?: number;
}, {
findings: object[];
recommendation?: string;
score?: number;
}>>>;

Factory that returns a generator block for artifact analysis and critique.

Type Parameters​

TOutputSchema​

TOutputSchema extends ZodTypeAny = ZodObject<{ findings: ZodArray<ZodObject<{ assessment: ZodString; criterion: ZodString; evidence: ZodOptional<ZodString>; severity: ZodOptional<ZodEnum<["critical", "warning", "info"]>>; }, "strip", ZodTypeAny, { assessment: string; criterion: string; evidence?: string; severity?: "warning" | "critical" | "info"; }, { assessment: string; criterion: string; evidence?: string; severity?: "warning" | "critical" | "info"; }>, "many">; recommendation: ZodOptional<ZodString>; score: ZodOptional<ZodNumber>; }, "strip", ZodTypeAny, { findings: object[]; recommendation?: string; score?: number; }, { findings: object[]; recommendation?: string; score?: number; }>

Parameters​

config​

AnalyzerConfig<TOutputSchema>

Returns​

BlockDefinition<ZodTypeAny, | TOutputSchema | ZodObject<{ findings: ZodArray<ZodObject<{ assessment: ZodString; criterion: ZodString; evidence: ZodOptional<ZodString>; severity: ZodOptional<ZodEnum<["critical", "warning", "info"]>>; }, "strip", ZodTypeAny, { assessment: string; criterion: string; evidence?: string; severity?: "warning" | "critical" | "info"; }, { assessment: string; criterion: string; evidence?: string; severity?: "warning" | "critical" | "info"; }>, "many">; recommendation: ZodOptional<ZodString>; score: ZodOptional<ZodNumber>; }, "strip", ZodTypeAny, { findings: object[]; recommendation?: string; score?: number; }, { findings: object[]; recommendation?: string; score?: number; }>, any, TypeOf< | TOutputSchema | ZodObject<{ findings: ZodArray<ZodObject<{ assessment: ZodString; criterion: ZodString; evidence: ZodOptional<ZodString>; severity: ZodOptional<ZodEnum<[..., ..., ...]>>; }, "strip", ZodTypeAny, { assessment: string; criterion: string; evidence?: string; severity?: "warning" | "critical" | "info"; }, { assessment: string; criterion: string; evidence?: string; severity?: "warning" | "critical" | "info"; }>, "many">; recommendation: ZodOptional<ZodString>; score: ZodOptional<ZodNumber>; }, "strip", ZodTypeAny, { findings: object[]; recommendation?: string; score?: number; }, { findings: object[]; recommendation?: string; score?: number; }>>>


cascadingRouter()​

function cascadingRouter<TRoot, TAmbiguous>(config): CascadingRouterBlock<TRoot, TAmbiguous>;

Build a sequencer that walks a tree of evaluator choice questions. An edge opens only when the model chose its option and reported confidence at or above the edge's optional minConfidence; every other outcome, at any level, runs ambiguous. On evaluation models that report no confidence, every edge goes to ambiguous. A failed evaluation fails the router.

Every leaf and ambiguous receive the router's own input, and the router returns whatever the chosen block returns.

Type Parameters​

TRoot​

TRoot extends CascadeLevel

TAmbiguous​

TAmbiguous extends BlockDefinition<any, any, any, any>

Parameters​

config​

CascadingRouterConfig<TRoot, TAmbiguous>

Returns​

CascadingRouterBlock<TRoot, TAmbiguous>

Example​

const triage = utility.cascadingRouter({
name: "triage",
ambiguous: review,
root: {
ask: department,
on: "team",
branches: {
billing: { minConfidence: 0.6, next: { ask: urgency, on: "urgency", branches: {
high: { minConfidence: 0.7, block: escalate },
low: { block: billingQueue },
} } },
technical: { minConfidence: 0.6, block: techQueue },
},
},
});

combiner()​

function combiner<TOutputSchema>(config): BlockDefinition<ZodUnion<[ZodArray<ZodUnknown, "many">, ZodObject<{
artifacts: ZodArray<ZodUnknown, "many">;
}, "strip", ZodTypeAny, {
artifacts: unknown[];
}, {
artifacts: unknown[];
}>]>,
| TOutputSchema
| ZodObject<{
combined: ZodUnknown;
mergeNotes: ZodOptional<ZodArray<ZodString, "many">>;
}, "strip", ZodTypeAny, {
combined?: unknown;
mergeNotes?: string[];
}, {
combined?: unknown;
mergeNotes?: string[];
}>,
| unknown[]
| {
artifacts: unknown[];
}, {
combined: unknown;
mergeNotes?: string[];
}>;

Factory that returns a handler block for deterministic artifact combination.

Type Parameters​

TOutputSchema​

TOutputSchema extends ZodTypeAny = ZodObject<{ combined: ZodUnknown; mergeNotes: ZodOptional<ZodArray<ZodString, "many">>; }, "strip", ZodTypeAny, { combined?: unknown; mergeNotes?: string[]; }, { combined?: unknown; mergeNotes?: string[]; }>

Parameters​

config​

CombinerConfig<TOutputSchema>

Returns​

BlockDefinition<ZodUnion<[ZodArray<ZodUnknown, "many">, ZodObject<{ artifacts: ZodArray<ZodUnknown, "many">; }, "strip", ZodTypeAny, { artifacts: unknown[]; }, { artifacts: unknown[]; }>]>, | TOutputSchema | ZodObject<{ combined: ZodUnknown; mergeNotes: ZodOptional<ZodArray<ZodString, "many">>; }, "strip", ZodTypeAny, { combined?: unknown; mergeNotes?: string[]; }, { combined?: unknown; mergeNotes?: string[]; }>, | unknown[] | { artifacts: unknown[]; }, { combined: unknown; mergeNotes?: string[]; }>


consultSessionHistoryTool()​

function consultSessionHistoryTool(options?): SequencerDefinition<any,
| {
asOf: | {
at: string;
requestId: string;
}
| null;
cut: boolean;
earlierTurnsLeftOut: boolean;
error?: undefined;
of?: unknown;
ok?: undefined;
reading: string;
running: boolean;
turnsRead: number;
}
| {
error: string;
ok: false;
}, undefined, undefined>;

A tool that answers a question from another of the principal's sessions' history, without waking it. See the file header.

Parameters​

options?​

ConsultSessionHistoryOptions

Returns​

SequencerDefinition<any, | { asOf: | { at: string; requestId: string; } | null; cut: boolean; earlierTurnsLeftOut: boolean; error?: undefined; of?: unknown; ok?: undefined; reading: string; running: boolean; turnsRead: number; } | { error: string; ok: false; }, undefined, undefined>


contextReducer()​

function contextReducer<TOutputSchema>(config): BlockDefinition<ZodTypeAny, ZodTypeAny, any, any>;

Factory that returns a generator block for context reduction across distill, denoise, and compress strategies.

Type Parameters​

TOutputSchema​

TOutputSchema extends ZodTypeAny = ZodObject<{ distilled: ZodString; keyPoints: ZodArray<ZodString, "many">; }, "strip", ZodTypeAny, { distilled: string; keyPoints: string[]; }, { distilled: string; keyPoints: string[]; }>

Parameters​

config​

ContextReducerConfig<TOutputSchema>

Returns​

BlockDefinition<ZodTypeAny, ZodTypeAny, any, any>


decomposer()​

function decomposer<TOutputSchema>(config): BlockDefinition<ZodTypeAny,
| TOutputSchema
| ZodObject<{
tasks: ZodArray<ZodObject<{
context: ZodNullable<ZodString>;
deps: ZodOptional<ZodArray<ZodString, "many">>;
goal: ZodString;
id: ZodString;
priority: ZodOptional<ZodEnum<["high", "medium", "low"]>>;
title: ZodNullable<ZodString>;
}, "strip", ZodTypeAny, {
context: string | null;
deps?: string[];
goal: string;
id: string;
priority?: "low" | "medium" | "high";
title: string | null;
}, {
context: string | null;
deps?: string[];
goal: string;
id: string;
priority?: "low" | "medium" | "high";
title: string | null;
}>, "many">;
}, "strip", ZodTypeAny, {
tasks: object[];
}, {
tasks: object[];
}>, any, TypeOf<
| TOutputSchema
| ZodObject<{
tasks: ZodArray<ZodObject<{
context: ZodNullable<ZodString>;
deps: ZodOptional<ZodArray<ZodString, "many">>;
goal: ZodString;
id: ZodString;
priority: ZodOptional<ZodEnum<[..., ..., ...]>>;
title: ZodNullable<ZodString>;
}, "strip", ZodTypeAny, {
context: string | null;
deps?: string[];
goal: string;
id: string;
priority?: "low" | "medium" | "high";
title: string | null;
}, {
context: string | null;
deps?: string[];
goal: string;
id: string;
priority?: "low" | "medium" | "high";
title: string | null;
}>, "many">;
}, "strip", ZodTypeAny, {
tasks: object[];
}, {
tasks: object[];
}>>>;

Factory that returns a generator block for decomposing broad requests into executable tasks.

Type Parameters​

TOutputSchema​

TOutputSchema extends ZodTypeAny = ZodObject<{ tasks: ZodArray<ZodObject<{ context: ZodNullable<ZodString>; deps: ZodOptional<ZodArray<ZodString, "many">>; goal: ZodString; id: ZodString; priority: ZodOptional<ZodEnum<["high", "medium", "low"]>>; title: ZodNullable<ZodString>; }, "strip", ZodTypeAny, { context: string | null; deps?: string[]; goal: string; id: string; priority?: "low" | "medium" | "high"; title: string | null; }, { context: string | null; deps?: string[]; goal: string; id: string; priority?: "low" | "medium" | "high"; title: string | null; }>, "many">; }, "strip", ZodTypeAny, { tasks: object[]; }, { tasks: object[]; }>

Parameters​

config​

DecomposerConfig<TOutputSchema>

Returns​

BlockDefinition<ZodTypeAny, | TOutputSchema | ZodObject<{ tasks: ZodArray<ZodObject<{ context: ZodNullable<ZodString>; deps: ZodOptional<ZodArray<ZodString, "many">>; goal: ZodString; id: ZodString; priority: ZodOptional<ZodEnum<["high", "medium", "low"]>>; title: ZodNullable<ZodString>; }, "strip", ZodTypeAny, { context: string | null; deps?: string[]; goal: string; id: string; priority?: "low" | "medium" | "high"; title: string | null; }, { context: string | null; deps?: string[]; goal: string; id: string; priority?: "low" | "medium" | "high"; title: string | null; }>, "many">; }, "strip", ZodTypeAny, { tasks: object[]; }, { tasks: object[]; }>, any, TypeOf< | TOutputSchema | ZodObject<{ tasks: ZodArray<ZodObject<{ context: ZodNullable<ZodString>; deps: ZodOptional<ZodArray<ZodString, "many">>; goal: ZodString; id: ZodString; priority: ZodOptional<ZodEnum<[..., ..., ...]>>; title: ZodNullable<ZodString>; }, "strip", ZodTypeAny, { context: string | null; deps?: string[]; goal: string; id: string; priority?: "low" | "medium" | "high"; title: string | null; }, { context: string | null; deps?: string[]; goal: string; id: string; priority?: "low" | "medium" | "high"; title: string | null; }>, "many">; }, "strip", ZodTypeAny, { tasks: object[]; }, { tasks: object[]; }>>>


historySummary()​

function historySummary(options): object;

Build a history summary: a capability for the generator that answers and a fold step the flow runs before it.

const earlier = historySummary({
summarize: summarizer({ name: "earlier-turns", granularity: "detailed" }),
});

sequencer({ name: "chat", inputSchema })
.tap(earlier.fold)
.step(generator({ name: "answer", history: true, uses: [earlier.capability], ... }));

Parameters​

options​

HistorySummaryOptions

Returns​

object

capability​
capability: DefinedCapability<string, Record<string, never>, "default" | "context" | "history", Record<string, PresetDef<any>>, undefined, Record<string, DefinedResource<{
attempts: number;
complete: boolean;
folds: number;
gap: boolean;
nextRequestId: string | null;
nextSettledRequestId: string | null;
pending: string[];
summary: string | null;
throughRequestId: string | null;
throughStartedAtMs: number | null;
}>>, undefined, undefined, undefined> & object;
Type Declaration​
__configInType?​
readonly __configInType?: undefined;
resourcesType?​
readonly resourcesType?: unknown;
sequencerStateType?​
readonly sequencerStateType?: unknown;
sessionStateType?​
readonly sessionStateType?: unknown;
stateSchemaType?​
readonly stateSchemaType?: unknown;
targetStatesType?​
readonly targetStatesType?: unknown;
fold​
fold: SequencerDefinition<unknown, any, undefined, undefined>;
resource​
resource: object & ResourceConfig<JsonObject> & object;
Type Declaration​
client​
readonly client: object;
client.expose​
readonly expose: readonly ["throughRequestId", "complete", "folds"];
default​
readonly default: object;
default.attempts​
attempts: number;
default.complete​
complete: boolean;
default.folds​
folds: number;
default.gap​
gap: boolean;
default.nextRequestId​
nextRequestId: string | null;
default.nextSettledRequestId​
nextSettledRequestId: string | null;
default.pending​
pending: string[];
default.summary​
summary: string | null;
default.throughRequestId​
throughRequestId: string | null;
default.throughStartedAtMs​
throughStartedAtMs: number | null;
ref​
readonly ref: string;
scope​
readonly scope: "session";
stateSchema​
readonly stateSchema: ZodObject<{
attempts: ZodDefault<ZodNumber>;
complete: ZodDefault<ZodBoolean>;
folds: ZodDefault<ZodNumber>;
gap: ZodDefault<ZodBoolean>;
nextRequestId: ZodDefault<ZodNullable<ZodString>>;
nextSettledRequestId: ZodDefault<ZodNullable<ZodString>>;
pending: ZodDefault<ZodArray<ZodString, "many">>;
summary: ZodDefault<ZodNullable<ZodString>>;
throughRequestId: ZodDefault<ZodNullable<ZodString>>;
throughStartedAtMs: ZodDefault<ZodNullable<ZodNumber>>;
}, "strip", ZodTypeAny, {
attempts: number;
complete: boolean;
folds: number;
gap: boolean;
nextRequestId: string | null;
nextSettledRequestId: string | null;
pending: string[];
summary: string | null;
throughRequestId: string | null;
throughStartedAtMs: number | null;
}, {
attempts?: number;
complete?: boolean;
folds?: number;
gap?: boolean;
nextRequestId?: string | null;
nextSettledRequestId?: string | null;
pending?: string[];
summary?: string | null;
throughRequestId?: string | null;
throughStartedAtMs?: number | null;
}>;
writable​
readonly writable: true;
ClientType​
ClientType: Pick<{
attempts: number;
complete: boolean;
folds: number;
gap: boolean;
nextRequestId: string | null;
nextSettledRequestId: string | null;
pending: string[];
summary: string | null;
throughRequestId: string | null;
throughStartedAtMs: number | null;
}, "complete" | "folds" | "throughRequestId">;
ContextType​
ContextType: ResourceContext<{
attempts: number;
complete: boolean;
folds: number;
gap: boolean;
nextRequestId: string | null;
nextSettledRequestId: string | null;
pending: string[];
summary: string | null;
throughRequestId: string | null;
throughStartedAtMs: number | null;
}>;
StateType​
StateType: object;
StateType.attempts​
attempts: number;
StateType.complete​
complete: boolean;
StateType.folds​
folds: number;
StateType.gap​
gap: boolean;
StateType.nextRequestId​
nextRequestId: string | null;
StateType.nextSettledRequestId​
nextSettledRequestId: string | null;
StateType.pending​
pending: string[];
StateType.summary​
summary: string | null;
StateType.throughRequestId​
throughRequestId: string | null;
StateType.throughStartedAtMs​
throughStartedAtMs: number | null;

intentClassifier()​

function intentClassifier<TOutputSchema>(config): BlockDefinition<ZodTypeAny,
| ZodEffects<TOutputSchema, any, any>
| ZodEffects<ZodObject<{
category: ZodString;
confidence: ZodNumber;
reasoning: ZodDefault<ZodString>;
}, "strip", ZodTypeAny, {
category: string;
confidence: number;
reasoning: string;
}, {
category: string;
confidence: number;
reasoning?: string;
}>, {
category: string;
confidence: number;
reasoning: string;
}, {
category: string;
confidence: number;
reasoning?: string;
}>, any, any>;

Factory that returns a generator block for classifying input into a bounded category set.

Type Parameters​

TOutputSchema​

TOutputSchema extends ZodTypeAny = ZodEffects<ZodObject<{ category: ZodString; confidence: ZodNumber; reasoning: ZodDefault<ZodString>; }, "strip", ZodTypeAny, { category: string; confidence: number; reasoning: string; }, { category: string; confidence: number; reasoning?: string; }>, { category: string; confidence: number; reasoning: string; }, { category: string; confidence: number; reasoning?: string; }>

Parameters​

config​

IntentClassifierConfig<TOutputSchema>

Returns​

BlockDefinition<ZodTypeAny, | ZodEffects<TOutputSchema, any, any> | ZodEffects<ZodObject<{ category: ZodString; confidence: ZodNumber; reasoning: ZodDefault<ZodString>; }, "strip", ZodTypeAny, { category: string; confidence: number; reasoning: string; }, { category: string; confidence: number; reasoning?: string; }>, { category: string; confidence: number; reasoning: string; }, { category: string; confidence: number; reasoning?: string; }>, any, any>


intentRouter()​

function intentRouter<TCategories>(config): SequencerDefinition<any, any, undefined, undefined>;

Factory that returns a sequencer pre-wired to classify input intent and route to category handlers.

Type Parameters​

TCategories​

TCategories extends IntentRouterCategories

Parameters​

config​

IntentRouterConfig<TCategories>

Returns​

SequencerDefinition<any, any, undefined, undefined>


keyedRouter()​

function keyedRouter<TInputSchema, TOutputSchema, TInput>(config): BlockDefinition<TInputSchema, TOutputSchema>;

Build a router that selects one of blocks[select(input, ctx)]. Throws with the registered key list when no entry matches and no fallback is given.

Type Parameters​

TInputSchema​

TInputSchema extends ZodTypeAny = ZodTypeAny

TOutputSchema​

TOutputSchema extends ZodTypeAny = ZodTypeAny

TInput​

TInput = TypeOf<TInputSchema>

Parameters​

config​

KeyedRouterConfig<TInputSchema, TOutputSchema, TInput>

Returns​

BlockDefinition<TInputSchema, TOutputSchema>


memoryExtractor()​

function memoryExtractor<TOutputSchema>(config): BlockDefinition<ZodTypeAny,
| TOutputSchema
| ZodObject<{
memories: ZodArray<ZodObject<{
confidence: ZodOptional<ZodNumber>;
content: ZodString;
source: ZodOptional<ZodString>;
type: ZodEnum<["fact", "preference", "constraint", "decision"]>;
}, "strip", ZodTypeAny, {
confidence?: number;
content: string;
source?: string;
type: "fact" | "preference" | "constraint" | "decision";
}, {
confidence?: number;
content: string;
source?: string;
type: "fact" | "preference" | "constraint" | "decision";
}>, "many">;
}, "strip", ZodTypeAny, {
memories: object[];
}, {
memories: object[];
}>, any, TypeOf<
| TOutputSchema
| ZodObject<{
memories: ZodArray<ZodObject<{
confidence: ZodOptional<ZodNumber>;
content: ZodString;
source: ZodOptional<ZodString>;
type: ZodEnum<["fact", "preference", "constraint", "decision"]>;
}, "strip", ZodTypeAny, {
confidence?: number;
content: string;
source?: string;
type: "fact" | "preference" | "constraint" | "decision";
}, {
confidence?: number;
content: string;
source?: string;
type: "fact" | "preference" | "constraint" | "decision";
}>, "many">;
}, "strip", ZodTypeAny, {
memories: object[];
}, {
memories: object[];
}>>>;

Factory that returns a generator block for extracting durable memory candidates.

Type Parameters​

TOutputSchema​

TOutputSchema extends ZodTypeAny = ZodObject<{ memories: ZodArray<ZodObject<{ confidence: ZodOptional<ZodNumber>; content: ZodString; source: ZodOptional<ZodString>; type: ZodEnum<["fact", "preference", "constraint", "decision"]>; }, "strip", ZodTypeAny, { confidence?: number; content: string; source?: string; type: "fact" | "preference" | "constraint" | "decision"; }, { confidence?: number; content: string; source?: string; type: "fact" | "preference" | "constraint" | "decision"; }>, "many">; }, "strip", ZodTypeAny, { memories: object[]; }, { memories: object[]; }>

Parameters​

config​

MemoryExtractorConfig<TOutputSchema>

Returns​

BlockDefinition<ZodTypeAny, | TOutputSchema | ZodObject<{ memories: ZodArray<ZodObject<{ confidence: ZodOptional<ZodNumber>; content: ZodString; source: ZodOptional<ZodString>; type: ZodEnum<["fact", "preference", "constraint", "decision"]>; }, "strip", ZodTypeAny, { confidence?: number; content: string; source?: string; type: "fact" | "preference" | "constraint" | "decision"; }, { confidence?: number; content: string; source?: string; type: "fact" | "preference" | "constraint" | "decision"; }>, "many">; }, "strip", ZodTypeAny, { memories: object[]; }, { memories: object[]; }>, any, TypeOf< | TOutputSchema | ZodObject<{ memories: ZodArray<ZodObject<{ confidence: ZodOptional<ZodNumber>; content: ZodString; source: ZodOptional<ZodString>; type: ZodEnum<["fact", "preference", "constraint", "decision"]>; }, "strip", ZodTypeAny, { confidence?: number; content: string; source?: string; type: "fact" | "preference" | "constraint" | "decision"; }, { confidence?: number; content: string; source?: string; type: "fact" | "preference" | "constraint" | "decision"; }>, "many">; }, "strip", ZodTypeAny, { memories: object[]; }, { memories: object[]; }>>>


sessionTitleGenerator()​

function sessionTitleGenerator(config): SequencerDefinition<unknown, {
title: string;
}, undefined, undefined>;

Factory that returns a sequencer block for auto-generating a session title from recent conversation messages.

Designed for use as a .sideChain() background block in a sequencer. It runs a generator to produce a title from recent session messages, then a handler that persists the title via ctx.session.setMetadata({ title }) if it changed. The metadata update emits a session.metadata.changed SSE event so connected clients see the title in real-time.

The persist handler is a .tap(), so the sequencer output is { title } from the generator step — discarded when composed as a .sideChain(), and passed downstream in place of the action input when composed as a .step().

const titleBlock = sessionTitleGenerator({
name: "auto-title",
model: "openai/gpt-6-luna"
});

const pipeline = sequencer({ name: "chat", inputSchema })
.step(mainGenerator)
.sideChain(titleBlock)

Parameters​

config​

SessionTitleGeneratorConfig

Returns​

SequencerDefinition<unknown, { title: string; }, undefined, undefined>


summarizer()​

function summarizer<TOutputSchema>(config): BlockDefinition<ZodTypeAny,
| TOutputSchema
| ZodObject<{
keyPoints: ZodOptional<ZodArray<ZodString, "many">>;
summary: ZodString;
}, "strip", ZodTypeAny, {
keyPoints?: string[];
summary: string;
}, {
keyPoints?: string[];
summary: string;
}>, any, TypeOf<
| TOutputSchema
| ZodObject<{
keyPoints: ZodOptional<ZodArray<ZodString, "many">>;
summary: ZodString;
}, "strip", ZodTypeAny, {
keyPoints?: string[];
summary: string;
}, {
keyPoints?: string[];
summary: string;
}>>>;

Factory that returns a generator block for concise input summarization.

Type Parameters​

TOutputSchema​

TOutputSchema extends ZodTypeAny = ZodObject<{ keyPoints: ZodOptional<ZodArray<ZodString, "many">>; summary: ZodString; }, "strip", ZodTypeAny, { keyPoints?: string[]; summary: string; }, { keyPoints?: string[]; summary: string; }>

Parameters​

config​

SummarizerConfig<TOutputSchema>

Returns​

BlockDefinition<ZodTypeAny, | TOutputSchema | ZodObject<{ keyPoints: ZodOptional<ZodArray<ZodString, "many">>; summary: ZodString; }, "strip", ZodTypeAny, { keyPoints?: string[]; summary: string; }, { keyPoints?: string[]; summary: string; }>, any, TypeOf< | TOutputSchema | ZodObject<{ keyPoints: ZodOptional<ZodArray<ZodString, "many">>; summary: ZodString; }, "strip", ZodTypeAny, { keyPoints?: string[]; summary: string; }, { keyPoints?: string[]; summary: string; }>>>


upsertResource()​

function upsertResource<TInputSchema>(config): BlockDefinition<TInputSchema, ZodTypeAny, TypeOf<TInputSchema>, void>;

Factory that returns a handler block performing a resource upsert: get-or-create the resource instance, patch its state with the latest values, and optionally write binary/text content. Returns no value so the sequencer chain can pass through the original input unchanged.

Type Parameters​

TInputSchema​

TInputSchema extends ZodTypeAny

Parameters​

config​

UpsertResourceConfig<TInputSchema>

Returns​

BlockDefinition<TInputSchema, ZodTypeAny, TypeOf<TInputSchema>, void>