Anchorage API reference
    Preparing search index...

    What a module's register() receives: the init()-derived builder factories (createWorkflow is the register-intercepting wrapper; createStep is raw Mastra) plus the shared, binding-gated infrastructure its connectors close over. deps is generic so the kit imposes no host-specific shape.

    interface WorkflowModuleContext<Deps = unknown> {
        audit: AuditLogger;
        createStep: {
            <
                TStepId extends string,
                TStateSchema extends PublicSchema | undefined,
                TInputSchema extends PublicSchema,
                TOutputSchema extends PublicSchema,
                TResumeSchema extends PublicSchema | undefined = undefined,
                TSuspendSchema extends PublicSchema | undefined = undefined,
                TRequestContextSchema extends PublicSchema | undefined = undefined,
            >(
                params: StepParams<
                    TStepId,
                    TStateSchema,
                    TInputSchema,
                    TOutputSchema,
                    TResumeSchema,
                    TSuspendSchema,
                    TRequestContextSchema,
                >,
            ): Step<
                TStepId,
                TStateSchema extends PublicSchema
                    ? InferPublicSchema<TStateSchema>
                    : unknown,
                InferPublicSchema<TInputSchema>,
                InferPublicSchema<TOutputSchema>,
                TResumeSchema extends PublicSchema
                    ? InferPublicSchema<TResumeSchema>
                    : unknown,
                TSuspendSchema extends PublicSchema
                    ? InferPublicSchema<TSuspendSchema>
                    : unknown,
                DefaultEngineType,
                TRequestContextSchema extends PublicSchema
                    ? InferPublicSchema<TRequestContextSchema>
                    : unknown,
            >;
            <TStepId extends string>(
                agent:
                    | SubAgent<TStepId, any>
                    | Agent<TStepId, any, undefined, unknown, AgentEditorConfig | undefined>,
                agentOptions?: Omit<AgentStepOptions<{}>, "structuredOutput"> & {},
            ): Step<TStepId, unknown, {}, {}, unknown, unknown, DefaultEngineType>;
            <TStepId extends string, TStepOutput>(
                agent:
                    | SubAgent<TStepId, any>
                    | Agent<TStepId, any, undefined, unknown, AgentEditorConfig | undefined>,
                agentOptions: Omit<AgentStepOptions<TStepOutput>, "structuredOutput"> & {},
            ): Step<
                TStepId,
                unknown,
                {},
                TStepOutput,
                unknown,
                unknown,
                DefaultEngineType,
            >;
            <
                TSchemaIn,
                TSchemaOut,
                TSuspend,
                TResume,
                TContext extends ToolExecutionContext<TSuspend, TResume, any>,
                TId extends string,
                TRequestContext extends unknown = unknown,
            >(
                tool: Tool<
                    TSchemaIn,
                    TSchemaOut,
                    TSuspend,
                    TResume,
                    TContext,
                    TId,
                    TRequestContext,
                >,
                toolOptions?: {},
            ): Step<
                TId,
                unknown,
                TSchemaIn,
                TSchemaOut,
                TSuspend,
                TResume,
                DefaultEngineType,
                TRequestContext,
            >;
            <TProcessorId extends string>(
                processor:
                    | Processor<TProcessorId, unknown> & {}
                    | Processor<TProcessorId, unknown> & {}
                    | Processor<TProcessorId, unknown> & {}
                    | Processor<TProcessorId, unknown> & {}
                    | Processor<TProcessorId, unknown> & {}
                    | Processor<TProcessorId, unknown> & {}
                    | Processor<TProcessorId, unknown> & {},
            ): Step<
                `processor:${TProcessorId}`,
                unknown,
                ProcessorStepInputType,
                ProcessorStepOutputType,
                unknown,
                unknown,
                DefaultEngineType,
            >;
            <
                TStepId extends string,
                TStateSchema extends PublicSchema | undefined,
                TInputSchema extends PublicSchema,
                TOutputSchema extends PublicSchema,
                TResumeSchema extends PublicSchema | undefined = undefined,
                TSuspendSchema extends PublicSchema | undefined = undefined,
                TRequestContextSchema extends PublicSchema | undefined = undefined,
            >(
                params: StepParams<
                    TStepId,
                    TStateSchema,
                    TInputSchema,
                    TOutputSchema,
                    TResumeSchema,
                    TSuspendSchema,
                    TRequestContextSchema,
                >,
            ): Step<
                TStepId,
                TStateSchema extends PublicSchema
                    ? InferPublicSchema<TStateSchema>
                    : unknown,
                InferPublicSchema<TInputSchema>,
                InferPublicSchema<TOutputSchema>,
                TResumeSchema extends PublicSchema
                    ? InferPublicSchema<TResumeSchema>
                    : unknown,
                TSuspendSchema extends PublicSchema
                    ? InferPublicSchema<TSuspendSchema>
                    : unknown,
                DefaultEngineType,
                TRequestContextSchema extends PublicSchema
                    ? InferPublicSchema<TRequestContextSchema>
                    : unknown,
            >;
        };
        createWorkflow: <
            TWorkflowId extends string = string,
            TInputSchema extends PublicSchema<any> = PublicSchema<any>,
            TOutputSchema extends PublicSchema<any> = PublicSchema<any>,
            TStateSchema extends PublicSchema<any> | undefined = undefined,
            TSteps extends
                Step<string, any, any, any, any, any, DefaultEngineType, unknown>[] = Step<
                string,
                unknown,
                unknown,
                unknown,
                unknown,
                unknown,
                any,
                unknown,
            >[],
            TRequestContextSchema extends PublicSchema<any>
            | undefined = undefined,
        >(
            params: CreateWorkflowParams<
                TWorkflowId,
                TStateSchema,
                TInputSchema,
                TOutputSchema,
                TSteps,
                TRequestContextSchema,
            >,
        ) => Workflow<
            DefaultEngineType,
            TSteps,
            TWorkflowId,
            InferSchemaOutput<TStateSchema>,
            InferPublicSchema<TInputSchema>,
            InferPublicSchema<TOutputSchema>,
            InferPublicSchema<TInputSchema>,
            InferSchemaOutput<TRequestContextSchema>,
        >;
        deps: Deps;
    }

    Type Parameters

    • Deps = unknown
    Index

    Properties

    Connector audit sink shared across every module on the runtime.

    createStep: {
        <
            TStepId extends string,
            TStateSchema extends PublicSchema | undefined,
            TInputSchema extends PublicSchema,
            TOutputSchema extends PublicSchema,
            TResumeSchema extends PublicSchema | undefined = undefined,
            TSuspendSchema extends PublicSchema | undefined = undefined,
            TRequestContextSchema extends PublicSchema | undefined = undefined,
        >(
            params: StepParams<
                TStepId,
                TStateSchema,
                TInputSchema,
                TOutputSchema,
                TResumeSchema,
                TSuspendSchema,
                TRequestContextSchema,
            >,
        ): Step<
            TStepId,
            TStateSchema extends PublicSchema
                ? InferPublicSchema<TStateSchema>
                : unknown,
            InferPublicSchema<TInputSchema>,
            InferPublicSchema<TOutputSchema>,
            TResumeSchema extends PublicSchema
                ? InferPublicSchema<TResumeSchema>
                : unknown,
            TSuspendSchema extends PublicSchema
                ? InferPublicSchema<TSuspendSchema>
                : unknown,
            DefaultEngineType,
            TRequestContextSchema extends PublicSchema
                ? InferPublicSchema<TRequestContextSchema>
                : unknown,
        >;
        <TStepId extends string>(
            agent:
                | SubAgent<TStepId, any>
                | Agent<TStepId, any, undefined, unknown, AgentEditorConfig | undefined>,
            agentOptions?: Omit<AgentStepOptions<{}>, "structuredOutput"> & {},
        ): Step<TStepId, unknown, {}, {}, unknown, unknown, DefaultEngineType>;
        <TStepId extends string, TStepOutput>(
            agent:
                | SubAgent<TStepId, any>
                | Agent<TStepId, any, undefined, unknown, AgentEditorConfig | undefined>,
            agentOptions: Omit<AgentStepOptions<TStepOutput>, "structuredOutput"> & {},
        ): Step<
            TStepId,
            unknown,
            {},
            TStepOutput,
            unknown,
            unknown,
            DefaultEngineType,
        >;
        <
            TSchemaIn,
            TSchemaOut,
            TSuspend,
            TResume,
            TContext extends ToolExecutionContext<TSuspend, TResume, any>,
            TId extends string,
            TRequestContext extends unknown = unknown,
        >(
            tool: Tool<
                TSchemaIn,
                TSchemaOut,
                TSuspend,
                TResume,
                TContext,
                TId,
                TRequestContext,
            >,
            toolOptions?: {},
        ): Step<
            TId,
            unknown,
            TSchemaIn,
            TSchemaOut,
            TSuspend,
            TResume,
            DefaultEngineType,
            TRequestContext,
        >;
        <TProcessorId extends string>(
            processor:
                | Processor<TProcessorId, unknown> & {}
                | Processor<TProcessorId, unknown> & {}
                | Processor<TProcessorId, unknown> & {}
                | Processor<TProcessorId, unknown> & {}
                | Processor<TProcessorId, unknown> & {}
                | Processor<TProcessorId, unknown> & {}
                | Processor<TProcessorId, unknown> & {},
        ): Step<
            `processor:${TProcessorId}`,
            unknown,
            ProcessorStepInputType,
            ProcessorStepOutputType,
            unknown,
            unknown,
            DefaultEngineType,
        >;
        <
            TStepId extends string,
            TStateSchema extends PublicSchema | undefined,
            TInputSchema extends PublicSchema,
            TOutputSchema extends PublicSchema,
            TResumeSchema extends PublicSchema | undefined = undefined,
            TSuspendSchema extends PublicSchema | undefined = undefined,
            TRequestContextSchema extends PublicSchema | undefined = undefined,
        >(
            params: StepParams<
                TStepId,
                TStateSchema,
                TInputSchema,
                TOutputSchema,
                TResumeSchema,
                TSuspendSchema,
                TRequestContextSchema,
            >,
        ): Step<
            TStepId,
            TStateSchema extends PublicSchema
                ? InferPublicSchema<TStateSchema>
                : unknown,
            InferPublicSchema<TInputSchema>,
            InferPublicSchema<TOutputSchema>,
            TResumeSchema extends PublicSchema
                ? InferPublicSchema<TResumeSchema>
                : unknown,
            TSuspendSchema extends PublicSchema
                ? InferPublicSchema<TSuspendSchema>
                : unknown,
            DefaultEngineType,
            TRequestContextSchema extends PublicSchema
                ? InferPublicSchema<TRequestContextSchema>
                : unknown,
        >;
    }

    Type Declaration

      • <
            TStepId extends string,
            TStateSchema extends PublicSchema | undefined,
            TInputSchema extends PublicSchema,
            TOutputSchema extends PublicSchema,
            TResumeSchema extends PublicSchema | undefined = undefined,
            TSuspendSchema extends PublicSchema | undefined = undefined,
            TRequestContextSchema extends PublicSchema | undefined = undefined,
        >(
            params: StepParams<
                TStepId,
                TStateSchema,
                TInputSchema,
                TOutputSchema,
                TResumeSchema,
                TSuspendSchema,
                TRequestContextSchema,
            >,
        ): Step<
            TStepId,
            TStateSchema extends PublicSchema
                ? InferPublicSchema<TStateSchema>
                : unknown,
            InferPublicSchema<TInputSchema>,
            InferPublicSchema<TOutputSchema>,
            TResumeSchema extends PublicSchema
                ? InferPublicSchema<TResumeSchema>
                : unknown,
            TSuspendSchema extends PublicSchema
                ? InferPublicSchema<TSuspendSchema>
                : unknown,
            DefaultEngineType,
            TRequestContextSchema extends PublicSchema
                ? InferPublicSchema<TRequestContextSchema>
                : unknown,
        >
      • Creates a step from explicit params (IMPORTANT: FIRST overload for best error messages when using .then in workflows)

        Type Parameters

        • TStepId extends string
        • TStateSchema extends PublicSchema | undefined
        • TInputSchema extends PublicSchema
        • TOutputSchema extends PublicSchema
        • TResumeSchema extends PublicSchema | undefined = undefined
        • TSuspendSchema extends PublicSchema | undefined = undefined
        • TRequestContextSchema extends PublicSchema | undefined = undefined

        Parameters

        • params: StepParams<
              TStepId,
              TStateSchema,
              TInputSchema,
              TOutputSchema,
              TResumeSchema,
              TSuspendSchema,
              TRequestContextSchema,
          >

          Configuration parameters for the step

          • id

            Unique identifier for the step

          • description

            Optional description of what the step does

          • inputSchema

            Zod schema defining the input structure

          • outputSchema

            Zod schema defining the output structure

          • execute

            Function that performs the step's operations

        Returns Step<
            TStepId,
            TStateSchema extends PublicSchema
                ? InferPublicSchema<TStateSchema>
                : unknown,
            InferPublicSchema<TInputSchema>,
            InferPublicSchema<TOutputSchema>,
            TResumeSchema extends PublicSchema
                ? InferPublicSchema<TResumeSchema>
                : unknown,
            TSuspendSchema extends PublicSchema
                ? InferPublicSchema<TSuspendSchema>
                : unknown,
            DefaultEngineType,
            TRequestContextSchema extends PublicSchema
                ? InferPublicSchema<TRequestContextSchema>
                : unknown,
        >

        A Step object that can be added to the workflow

      • <TStepId extends string>(
            agent:
                | SubAgent<TStepId, any>
                | Agent<TStepId, any, undefined, unknown, AgentEditorConfig | undefined>,
            agentOptions?: Omit<AgentStepOptions<{}>, "structuredOutput"> & {},
        ): Step<TStepId, unknown, {}, {}, unknown, unknown, DefaultEngineType>
      • Creates a step from an agent (defaults to { text: string } output)

        Type Parameters

        • TStepId extends string

        Parameters

        • agent:
              | SubAgent<TStepId, any>
              | Agent<TStepId, any, undefined, unknown, AgentEditorConfig | undefined>
        • OptionalagentOptions: Omit<AgentStepOptions<{}>, "structuredOutput"> & {}

        Returns Step<TStepId, unknown, {}, {}, unknown, unknown, DefaultEngineType>

      • <TStepId extends string, TStepOutput>(
            agent:
                | SubAgent<TStepId, any>
                | Agent<TStepId, any, undefined, unknown, AgentEditorConfig | undefined>,
            agentOptions: Omit<AgentStepOptions<TStepOutput>, "structuredOutput"> & {},
        ): Step<
            TStepId,
            unknown,
            {},
            TStepOutput,
            unknown,
            unknown,
            DefaultEngineType,
        >
      • Creates a step from an agent with structured output

        Type Parameters

        • TStepId extends string
        • TStepOutput

        Parameters

        • agent:
              | SubAgent<TStepId, any>
              | Agent<TStepId, any, undefined, unknown, AgentEditorConfig | undefined>
        • agentOptions: Omit<AgentStepOptions<TStepOutput>, "structuredOutput"> & {}

        Returns Step<TStepId, unknown, {}, TStepOutput, unknown, unknown, DefaultEngineType>

      • <
            TSchemaIn,
            TSchemaOut,
            TSuspend,
            TResume,
            TContext extends ToolExecutionContext<TSuspend, TResume, any>,
            TId extends string,
            TRequestContext extends unknown = unknown,
        >(
            tool: Tool<
                TSchemaIn,
                TSchemaOut,
                TSuspend,
                TResume,
                TContext,
                TId,
                TRequestContext,
            >,
            toolOptions?: {},
        ): Step<
            TId,
            unknown,
            TSchemaIn,
            TSchemaOut,
            TSuspend,
            TResume,
            DefaultEngineType,
            TRequestContext,
        >
      • Creates a step from a tool

        Type Parameters

        • TSchemaIn
        • TSchemaOut
        • TSuspend
        • TResume
        • TContext extends ToolExecutionContext<TSuspend, TResume, any>
        • TId extends string
        • TRequestContext extends unknown = unknown

        Parameters

        • tool: Tool<TSchemaIn, TSchemaOut, TSuspend, TResume, TContext, TId, TRequestContext>
        • OptionaltoolOptions: {}

        Returns Step<
            TId,
            unknown,
            TSchemaIn,
            TSchemaOut,
            TSuspend,
            TResume,
            DefaultEngineType,
            TRequestContext,
        >

      • <TProcessorId extends string>(
            processor:
                | Processor<TProcessorId, unknown> & {}
                | Processor<TProcessorId, unknown> & {}
                | Processor<TProcessorId, unknown> & {}
                | Processor<TProcessorId, unknown> & {}
                | Processor<TProcessorId, unknown> & {}
                | Processor<TProcessorId, unknown> & {}
                | Processor<TProcessorId, unknown> & {},
        ): Step<
            `processor:${TProcessorId}`,
            unknown,
            ProcessorStepInputType,
            ProcessorStepOutputType,
            unknown,
            unknown,
            DefaultEngineType,
        >
      • Creates a step from a Processor - wraps a Processor as a workflow step Note: We require at least one processor method to distinguish from StepParams

        Type Parameters

        • TProcessorId extends string

        Parameters

        • processor:
              | Processor<TProcessorId, unknown> & {}
              | Processor<TProcessorId, unknown> & {}
              | Processor<TProcessorId, unknown> & {}
              | Processor<TProcessorId, unknown> & {}
              | Processor<TProcessorId, unknown> & {}
              | Processor<TProcessorId, unknown> & {}
              | Processor<TProcessorId, unknown> & {}

        Returns Step<
            `processor:${TProcessorId}`,
            unknown,
            ProcessorStepInputType,
            ProcessorStepOutputType,
            unknown,
            unknown,
            DefaultEngineType,
        >

      • <
            TStepId extends string,
            TStateSchema extends PublicSchema | undefined,
            TInputSchema extends PublicSchema,
            TOutputSchema extends PublicSchema,
            TResumeSchema extends PublicSchema | undefined = undefined,
            TSuspendSchema extends PublicSchema | undefined = undefined,
            TRequestContextSchema extends PublicSchema | undefined = undefined,
        >(
            params: StepParams<
                TStepId,
                TStateSchema,
                TInputSchema,
                TOutputSchema,
                TResumeSchema,
                TSuspendSchema,
                TRequestContextSchema,
            >,
        ): Step<
            TStepId,
            TStateSchema extends PublicSchema
                ? InferPublicSchema<TStateSchema>
                : unknown,
            InferPublicSchema<TInputSchema>,
            InferPublicSchema<TOutputSchema>,
            TResumeSchema extends PublicSchema
                ? InferPublicSchema<TResumeSchema>
                : unknown,
            TSuspendSchema extends PublicSchema
                ? InferPublicSchema<TSuspendSchema>
                : unknown,
            DefaultEngineType,
            TRequestContextSchema extends PublicSchema
                ? InferPublicSchema<TRequestContextSchema>
                : unknown,
        >
      • IMPORTANT: Fallback overload - provides better error messages when StepParams doesn't match This should be LAST and will show clearer errors about what's wrong This is a copy of first one, KEEP THIS IN SYNC!

        Type Parameters

        • TStepId extends string
        • TStateSchema extends PublicSchema | undefined
        • TInputSchema extends PublicSchema
        • TOutputSchema extends PublicSchema
        • TResumeSchema extends PublicSchema | undefined = undefined
        • TSuspendSchema extends PublicSchema | undefined = undefined
        • TRequestContextSchema extends PublicSchema | undefined = undefined

        Parameters

        • params: StepParams<
              TStepId,
              TStateSchema,
              TInputSchema,
              TOutputSchema,
              TResumeSchema,
              TSuspendSchema,
              TRequestContextSchema,
          >

        Returns Step<
            TStepId,
            TStateSchema extends PublicSchema
                ? InferPublicSchema<TStateSchema>
                : unknown,
            InferPublicSchema<TInputSchema>,
            InferPublicSchema<TOutputSchema>,
            TResumeSchema extends PublicSchema
                ? InferPublicSchema<TResumeSchema>
                : unknown,
            TSuspendSchema extends PublicSchema
                ? InferPublicSchema<TSuspendSchema>
                : unknown,
            DefaultEngineType,
            TRequestContextSchema extends PublicSchema
                ? InferPublicSchema<TRequestContextSchema>
                : unknown,
        >

    createWorkflow: <
        TWorkflowId extends string = string,
        TInputSchema extends PublicSchema<any> = PublicSchema<any>,
        TOutputSchema extends PublicSchema<any> = PublicSchema<any>,
        TStateSchema extends PublicSchema<any> | undefined = undefined,
        TSteps extends
            Step<string, any, any, any, any, any, DefaultEngineType, unknown>[] = Step<
            string,
            unknown,
            unknown,
            unknown,
            unknown,
            unknown,
            any,
            unknown,
        >[],
        TRequestContextSchema extends PublicSchema<any>
        | undefined = undefined,
    >(
        params: CreateWorkflowParams<
            TWorkflowId,
            TStateSchema,
            TInputSchema,
            TOutputSchema,
            TSteps,
            TRequestContextSchema,
        >,
    ) => Workflow<
        DefaultEngineType,
        TSteps,
        TWorkflowId,
        InferSchemaOutput<TStateSchema>,
        InferPublicSchema<TInputSchema>,
        InferPublicSchema<TOutputSchema>,
        InferPublicSchema<TInputSchema>,
        InferSchemaOutput<TRequestContextSchema>,
    >

    Type Declaration

      • <
            TWorkflowId extends string = string,
            TInputSchema extends PublicSchema<any> = PublicSchema<any>,
            TOutputSchema extends PublicSchema<any> = PublicSchema<any>,
            TStateSchema extends PublicSchema<any> | undefined = undefined,
            TSteps extends
                Step<string, any, any, any, any, any, DefaultEngineType, unknown>[] = Step<
                string,
                unknown,
                unknown,
                unknown,
                unknown,
                unknown,
                any,
                unknown,
            >[],
            TRequestContextSchema extends PublicSchema<any>
            | undefined = undefined,
        >(
            params: CreateWorkflowParams<
                TWorkflowId,
                TStateSchema,
                TInputSchema,
                TOutputSchema,
                TSteps,
                TRequestContextSchema,
            >,
        ): Workflow<
            DefaultEngineType,
            TSteps,
            TWorkflowId,
            InferSchemaOutput<TStateSchema>,
            InferPublicSchema<TInputSchema>,
            InferPublicSchema<TOutputSchema>,
            InferPublicSchema<TInputSchema>,
            InferSchemaOutput<TRequestContextSchema>,
        >
      • Create a workflow, auto-promoting to the evented engine when a schedule is declared.

        Type Parameters

        • TWorkflowId extends string = string
        • TInputSchema extends PublicSchema<any> = PublicSchema<any>
        • TOutputSchema extends PublicSchema<any> = PublicSchema<any>
        • TStateSchema extends PublicSchema<any> | undefined = undefined
        • TSteps extends Step<string, any, any, any, any, any, DefaultEngineType, unknown>[] = Step<string, unknown, unknown, unknown, unknown, unknown, any, unknown>[]
        • TRequestContextSchema extends PublicSchema<any> | undefined = undefined

        Parameters

        • params: CreateWorkflowParams<
              TWorkflowId,
              TStateSchema,
              TInputSchema,
              TOutputSchema,
              TSteps,
              TRequestContextSchema,
          >

        Returns Workflow<
            DefaultEngineType,
            TSteps,
            TWorkflowId,
            InferSchemaOutput<TStateSchema>,
            InferPublicSchema<TInputSchema>,
            InferPublicSchema<TOutputSchema>,
            InferPublicSchema<TInputSchema>,
            InferSchemaOutput<TRequestContextSchema>,
        >

    deps: Deps