@flow-state-dev/core/blocks/handler
Namespaces
Interfaces
HandlerConfig
Extends
Omit<BlockConfig<TInputSchema,TOutputSchema,TInput,TOutput>,"execute"|"stateSchema"|"flowConfigSchema">
Type Parameters
TInputSchema
TInputSchema extends ZodTypeAny = ZodTypeAny
TOutputSchema
TOutputSchema extends ZodTypeAny = ZodTypeAny
TInput
TInput = z.infer<TInputSchema>
TOutput
TOutput = z.infer<TOutputSchema>
TRequestStateSchema
TRequestStateSchema extends ZodTypeAny | undefined = undefined
TSessionStateSchema
TSessionStateSchema extends ZodTypeAny | undefined = undefined
TUserStateSchema
TUserStateSchema extends ZodTypeAny | undefined = undefined
TOrgStateSchema
TOrgStateSchema extends ZodTypeAny | undefined = undefined
TSequencerStateSchema
TSequencerStateSchema extends ZodTypeAny | undefined = undefined
TParentInputSchema
TParentInputSchema extends ZodTypeAny | undefined = undefined
TResourceDefs
TResourceDefs extends
| Record<string, DeclaredResourceEntry>
| undefined = undefined
TTargetSchemas
TTargetSchemas extends Record<string, ZodTypeAny> | undefined = undefined
TUses
TUses extends readonly UsesEntry[] = readonly []
TRequestState
TRequestState extends object = InferStateFromSchema<TRequestStateSchema>
TSessionState
TSessionState extends object = Prettify<InferStateFromSchema<TSessionStateSchema> & InferCapabilitySessionState<TUses>>
TUserState
TUserState extends object = InferStateFromSchema<TUserStateSchema>
TOrgState
TOrgState extends object = InferStateFromSchema<TOrgStateSchema>
TSequencerState
TSequencerState extends object = Prettify<InferStateFromSchema<TSequencerStateSchema> & InferCapabilitySequencerState<TUses>>
TParentInput
TParentInput = TParentInputSchema extends ZodTypeAny ? z.infer<TParentInputSchema> : unknown
TResources
TResources extends Record<string, AnyResourceRef> = Prettify<InferBlockResources<undefined, TResourceDefs> & InferCapabilityResources<TUses>>
TMergedTargetSchemas
TMergedTargetSchemas extends Record<string, ZodTypeAny> | undefined = MergeTargetSchemas<TTargetSchemas, TUses>
TCapabilities
TCapabilities extends Record<string, Record<string, (...args) => any>> = InferCapabilities<TUses>
TStateSchema
TStateSchema extends ZodTypeAny | undefined = undefined
TParentStateSchema
TParentStateSchema extends ZodTypeAny | undefined = undefined
TSelfState
TSelfState extends object = Prettify<InferStateFromSchema<TStateSchema> & InferCapabilityOwnState<TUses>>
TParentState
TParentState extends object = InferStateFromSchema<TParentStateSchema>
TFlowConfigSchema
TFlowConfigSchema extends ZodTypeAny | undefined = undefined
TFlowConfig
TFlowConfig extends object = InferFlowConfigFromSchema<TFlowConfigSchema>
Properties
activeStatusMessage?
activeStatusMessage?: string | ((input, ctx) => string);
Active status message for this block — declarative sugar for
ctx.emit.status() at block start. A static string is emitted once when
the block enters execution; a function receives (input, ctx) and its
return value is emitted. Use direct ctx.emit.status() only when a block
needs to update status mid-execution (e.g. per-file progress).
Inherited from
Omit.activeStatusMessage
cacheable?
cacheable?: true | BlockCacheableConfig;
Opt-in tool-result memoization. When set, and when this
block is installed as a tool on a generator, the framework caches the
tool's output keyed on (toolName, canonicalize(args), scope) and
serves repeat calls from the cache. Errors are never cached. Identical
concurrent calls within a request are coalesced (single-flight).
Pass true for cache-everything defaults, or an object to tune TTL,
scope, key derivation, and a cacheIf predicate.
No effect when the block is used outside a generator's tool slot.
Inherited from
Omit.cacheable
connectInput?
connectInput?: ConnectorFn<unknown, TInput>;
Overrides
Omit.connectInput
container?
container?: object;
component?
component?: string;
label?
label?: string | ((input) => string);
metadata?
metadata?:
| Record<string, unknown>
| ((input) => Record<string, unknown>);
Inherited from
Omit.container
description?
description?: string;
Inherited from
Omit.description
execute
execute: (input, ctx) => TOutput | Promise<TOutput>;
Parameters
input
TInput
ctx
BlockContext<TRequestState, TSessionState, TUserState, TOrgState, TResources, TSequencerState, TParentInput, TMergedTargetSchemas, TCapabilities, TSelfState, TParentState, TFlowConfig>
Returns
TOutput | Promise<TOutput>
flowConfigSchema?
flowConfigSchema?: TFlowConfigSchema;
What this block requires of whatever flow installs it. Types
ctx.flow.config off this schema, and makes the flow refuse when it
cannot supply a bag that satisfies it. Names no flow, so the block stays
portable. See BlockConfig.flowConfigSchema.
inputSchema?
inputSchema?: TInputSchema;
Inherited from
Omit.inputSchema
name
name: string;
Inherited from
Omit.name
onCompleted?
onCompleted?: (output, ctx) => void | Promise<void>;
Parameters
output
TOutput
ctx
Returns
void | Promise<void>
Inherited from
Omit.onCompleted
onErrored?
onErrored?: (error, ctx) => void | Promise<void>;
Parameters
error
Error
ctx
Returns
void | Promise<void>
Inherited from
Omit.onErrored
orgStateSchema?
orgStateSchema?: TOrgStateSchema;
outputSchema?
outputSchema?: TOutputSchema;
Inherited from
Omit.outputSchema
parentInputSchema?
parentInputSchema?: TParentInputSchema;
parentStateSchema?
parentStateSchema?: TParentStateSchema;
Expected shape of the immediate parent's own state. Exposed
via ctx.parent's state ops when the parent declares stateSchema.
requestStateSchema?
requestStateSchema?: TRequestStateSchema;
rescue?
rescue?: RescueHandlerSpec[];
Per-block rescue handlers. When this block's execution throws a
non-SuspensionError, the first handler whose when matches runs with the
block's own scoped context — so it can read sequencer state — and its
output replaces the throw, letting the enclosing chain / fan-out continue.
Set via block.rescue([...]). Sequencers handle their own chain-level
rescue in the operation loop and do not use this field.
Inherited from
Omit.rescue
resources?
resources?: TResourceDefs;
Flat resource declaration: accessor key → resource definition. Resources
are routed to the right storage layer via their intrinsic scope
(set on defineResource). Replaces the legacy
sessionResources / userResources / orgResources.
retry?
retry?: RetryPolicy;
Inherited from
Omit.retry
sequencerStateSchema?
sequencerStateSchema?: TSequencerStateSchema;
sessionStateSchema?
sessionStateSchema?: TSessionStateSchema;
stateSchema?
stateSchema?: TStateSchema;
This block's own request-scoped state. Exposed via ctx.self.
targetStateSchemas?
targetStateSchemas?: TTargetSchemas;
transient?
transient?: boolean;
Inherited from
Omit.transient
userStateSchema?
userStateSchema?: TUserStateSchema;
uses?
uses?: TUses;
Capabilities to install. Merges resources, state schemas, targets, and any active preset surfaces into this block's config.
validateChunk?
validateChunk?: (input, ctx) =>
| ChunkValidation
| Promise<ChunkValidation>;
Parameters
input
TInput
ctx
Returns
| ChunkValidation
| Promise<ChunkValidation>
Inherited from
Omit.validateChunk
Type Aliases
HandlerDefaults
type HandlerDefaults<TSessionStateSchema, TUserStateSchema, TOrgStateSchema, TRequestStateSchema, TSequencerStateSchema, TResourceDefs, TOutputSchema, TUses> = object;
The subset of HandlerConfig fields that make sense to default — shared
scaffolding like state schemas, declared resources, the output schema, and
the capability list. name, inputSchema, execute, and description
are deliberately excluded: those vary per block.
Type Parameters
TSessionStateSchema
TSessionStateSchema extends ZodTypeAny | undefined = undefined
TUserStateSchema
TUserStateSchema extends ZodTypeAny | undefined = undefined
TOrgStateSchema
TOrgStateSchema extends ZodTypeAny | undefined = undefined
TRequestStateSchema
TRequestStateSchema extends ZodTypeAny | undefined = undefined
TSequencerStateSchema
TSequencerStateSchema extends ZodTypeAny | undefined = undefined
TResourceDefs
TResourceDefs extends
| Record<string, DeclaredResourceEntry>
| undefined = undefined
TOutputSchema
TOutputSchema extends ZodTypeAny | undefined = undefined
TUses
TUses extends readonly UsesEntry[] = readonly []
Properties
orgStateSchema?
orgStateSchema?: TOrgStateSchema;
outputSchema?
outputSchema?: TOutputSchema;
requestStateSchema?
requestStateSchema?: TRequestStateSchema;
resources?
resources?: TResourceDefs;
sequencerStateSchema?
sequencerStateSchema?: TSequencerStateSchema;
sessionStateSchema?
sessionStateSchema?: TSessionStateSchema;
userStateSchema?
userStateSchema?: TUserStateSchema;
uses?
uses?: TUses;
Functions
handler()
function handler<TInputSchema, TOutputSchema, TInput, TOutput, TRequestStateSchema, TSessionStateSchema, TUserStateSchema, TOrgStateSchema, TSequencerStateSchema, TParentInputSchema, TResourceDefs, TTargetSchemas, TUses, TRequestState, TSessionState, TUserState, TOrgState, TSequencerState, TParentInput, TResources, TMergedTargetSchemas, TCapabilities, TStateSchema, TParentStateSchema, TSelfState, TParentState, TFlowConfigSchema, TFlowConfig>(config): BlockDefinition<TInputSchema, TOutputSchema, TInput, TOutput>;
Type Parameters
TInputSchema
TInputSchema extends ZodTypeAny = ZodTypeAny
TOutputSchema
TOutputSchema extends ZodTypeAny = ZodTypeAny
TInput
TInput = TypeOf<TInputSchema>
TOutput
TOutput = TypeOf<TOutputSchema>
TRequestStateSchema
TRequestStateSchema extends ZodTypeAny | undefined = undefined
TSessionStateSchema
TSessionStateSchema extends ZodTypeAny | undefined = undefined
TUserStateSchema
TUserStateSchema extends ZodTypeAny | undefined = undefined
TOrgStateSchema
TOrgStateSchema extends ZodTypeAny | undefined = undefined
TSequencerStateSchema
TSequencerStateSchema extends ZodTypeAny | undefined = undefined
TParentInputSchema
TParentInputSchema extends ZodTypeAny | undefined = undefined
TResourceDefs
TResourceDefs extends
| Record<string, DeclaredResourceEntry>
| undefined = undefined
TTargetSchemas
TTargetSchemas extends Record<string, ZodTypeAny> | undefined = undefined
TUses
TUses extends readonly UsesEntry[] = readonly []
TRequestState
TRequestState extends object = InferStateFromSchema<TRequestStateSchema>
TSessionState
TSessionState extends object = { [K in string | number | symbol]: (InferStateFromSchema<TSessionStateSchema> & InferCapabilitySessionState<TUses>)[K] }
TUserState
TUserState extends object = InferStateFromSchema<TUserStateSchema>
TOrgState
TOrgState extends object = InferStateFromSchema<TOrgStateSchema>
TSequencerState
TSequencerState extends object = { [K in string | number | symbol]: (InferStateFromSchema<TSequencerStateSchema> & InferCapabilitySequencerState<TUses>)[K] }
TParentInput
TParentInput = TParentInputSchema extends ZodTypeAny ? TypeOf<TParentInputSchema> : unknown
TResources
TResources extends Record<string, AnyResourceRef> = { [K in string | number | symbol]: (InferBlockResources<undefined, TResourceDefs> & InferCapabilityResources<TUses>)[K] }
TMergedTargetSchemas
TMergedTargetSchemas extends Record<string, ZodTypeAny> | undefined = MergeTargetSchemas<TTargetSchemas, TUses>
TCapabilities
TCapabilities extends Record<string, Record<string, (...args) => any>> = InferCapabilities<TUses>
TStateSchema
TStateSchema extends ZodTypeAny | undefined = undefined
TParentStateSchema
TParentStateSchema extends ZodTypeAny | undefined = undefined
TSelfState
TSelfState extends object = { [K in string | number | symbol]: (InferStateFromSchema<TStateSchema> & InferCapabilityOwnState<TUses>)[K] }
TParentState
TParentState extends object = InferStateFromSchema<TParentStateSchema>
TFlowConfigSchema
TFlowConfigSchema extends ZodTypeAny | undefined = undefined
TFlowConfig
TFlowConfig extends object = InferFlowConfigFromSchema<TFlowConfigSchema>
Parameters
config
HandlerConfig<TInputSchema, TOutputSchema, TInput, TOutput, TRequestStateSchema, TSessionStateSchema, TUserStateSchema, TOrgStateSchema, TSequencerStateSchema, TParentInputSchema, TResourceDefs, TTargetSchemas, TUses, TRequestState, TSessionState, TUserState, TOrgState, TSequencerState, TParentInput, TResources, TMergedTargetSchemas, TCapabilities, TStateSchema, TParentStateSchema, TSelfState, TParentState, TFlowConfigSchema, TFlowConfig>
Returns
BlockDefinition<TInputSchema, TOutputSchema, TInput, TOutput>