Skip to content

API overview

@mastra-effect/core

Tools

ExportDescription
MastraTool.makeDefine a tool with Effect Schema
Toolkit.make / Toolkit.mergeBuild typed toolkits
toolkit.toLayerLayer<ToolHandlers, E, R> from Effect-ful handler callback
toolkit.toMastraToolsMastra ToolsInput for agent loop
ToolHandlersServer handler registry service
executeEffectToolLow-level server execute
HandlerRequirementsFrom<H>Union of handler R (usually inferred)

Agent

ExportDescription
MastraAgent / MastraAgent.layerAgent context service + layer
Agent.generate / Agent.streamEffect wrappers around Mastra agent
Agent.withToolsAttach tools to stream/generate options

Memory

ExportDescription
MastraMemoryEffect service for @mastra/memory instances
Memory.layerConstruct @mastra/memory
Memory.recall, getThreadById, listThreads, saveThread, saveMessages, createThread, deleteThread, settledEffect wrappers

Stream

ExportDescription
fromMastraOutputMastraModelOutput.fullStreamStream
fromReadableStream / fromAsyncIterableAdapters
runCollectCollect stream elements

AiBlock

ExportDescription
AiBlock.makeDefine typed block schema (optional Effect Schema for state/answer)
AiBlock.withAnswer / AiBlock.resumeAttach resume answer
AiBlock.toSuspendPayloadBuild suspend envelope for client rendering
AiBlock.fromSuspendArgsParse suspend args back into a typed block
AiBlock.fromToolCallSuspendParse tool-call-suspend stream chunk into a block
AiBlock.parse / AiBlock.parseByTagParse tagged payloads
AiBlock.answersEqual / AiBlock.equalsByAnswer equality helpers

Suspend

ExportDescription
Suspend.withBlockSuspend a requiredClient tool with an AiBlock.Def payload
Suspend.forClientToolSuspend with arbitrary args
Suspend.isToolCallPartGuard for tool-call-suspend stream chunks

Errors

ExportDescription
MastraErrorBridge failures (agent, memory, stream, handlers)
ClientToolRequiredErrorServer hit a requiredClient tool without client fulfillment
ClientToolSuspendedTyped suspend error carrying tool id + args

@mastra-effect/assistant-ui

ExportDescription
UiToolkit.makeBind toolkit + client components (all client tools required)
ui.toComponents()Assistant UI Toolkit
toAssistantUiToolkitLower-level toolkit mapping
clientToolIds / serverToolIdsList tool ids by kind
BlockRegistry.makeTyped dynamic block registry