@mastra/mcp-docs-server 1.2.14-alpha.3 → 1.2.14-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/docs/agents/processors.md +25 -1
- package/.docs/docs/workflows/agents-and-tools.md +29 -0
- package/.docs/docs/workflows/stored-workflows.md +146 -0
- package/.docs/models/environment-variables.md +1 -1
- package/.docs/models/gateways/neon.md +71 -0
- package/.docs/models/gateways/netlify.md +6 -6
- package/.docs/models/gateways/openrouter.md +6 -6
- package/.docs/models/gateways/vercel.md +6 -6
- package/.docs/models/gateways.md +1 -0
- package/.docs/models/index.md +95 -96
- package/.docs/models/providers/alibaba-cn.md +23 -25
- package/.docs/models/providers/alibaba-token-plan-cn.md +24 -24
- package/.docs/models/providers/alibaba-token-plan.md +23 -25
- package/.docs/models/providers/alibaba.md +23 -25
- package/.docs/models/providers/ambient.md +23 -25
- package/.docs/models/providers/baseten.md +23 -25
- package/.docs/models/providers/chutes.md +23 -25
- package/.docs/models/providers/cortecs.md +23 -25
- package/.docs/models/providers/crof.md +23 -25
- package/.docs/models/providers/crossmodel.md +23 -25
- package/.docs/models/providers/deepinfra.md +22 -24
- package/.docs/models/providers/digitalocean.md +23 -25
- package/.docs/models/providers/empiriolabs.md +23 -25
- package/.docs/models/providers/fireworks-ai.md +24 -24
- package/.docs/models/providers/greenpt.md +23 -25
- package/.docs/models/providers/groq.md +23 -25
- package/.docs/models/providers/huggingface.md +23 -25
- package/.docs/models/providers/hyper.md +23 -25
- package/.docs/models/providers/impossibl.md +23 -25
- package/.docs/models/providers/infomaniak.md +24 -24
- package/.docs/models/providers/kilo.md +23 -25
- package/.docs/models/providers/llmgateway.md +23 -25
- package/.docs/models/providers/mistral.md +23 -25
- package/.docs/models/providers/modal.md +23 -25
- package/.docs/models/providers/modelis.md +23 -25
- package/.docs/models/providers/nano-gpt.md +23 -25
- package/.docs/models/providers/neuralwatt.md +23 -25
- package/.docs/models/providers/ofox.md +23 -25
- package/.docs/models/providers/ollama-cloud.md +23 -25
- package/.docs/models/providers/opencode-go.md +23 -25
- package/.docs/models/providers/opencode.md +23 -25
- package/.docs/models/providers/pioneer.md +23 -25
- package/.docs/models/providers/requesty.md +23 -25
- package/.docs/models/providers/routing-run.md +23 -25
- package/.docs/models/providers/scx.md +23 -25
- package/.docs/models/providers/tensorx.md +23 -25
- package/.docs/models/providers/togetherai.md +22 -24
- package/.docs/models/providers/umans-ai-coding-plan.md +24 -24
- package/.docs/models/providers/umans-ai.md +23 -25
- package/.docs/models/providers/wandb.md +23 -25
- package/.docs/models/providers/xai.md +26 -28
- package/.docs/models/providers/zai-coding-plan.md +23 -25
- package/.docs/models/providers/zhipuai-coding-plan.md +23 -25
- package/.docs/models/providers.md +0 -1
- package/.docs/reference/client-js/workflows.md +92 -0
- package/.docs/reference/core/addStoredWorkflow.md +62 -0
- package/.docs/reference/core/addStoredWorkflows.md +40 -0
- package/.docs/reference/index.md +5 -0
- package/.docs/reference/processors/processor-interface.md +121 -10
- package/.docs/reference/server/routes.md +13 -0
- package/.docs/reference/storage/overview.md +9 -8
- package/.docs/reference/streaming/workflows/observeStream.md +1 -1
- package/.docs/reference/streaming/workflows/resumeStream.md +1 -1
- package/.docs/reference/streaming/workflows/stream.md +1 -1
- package/.docs/reference/workflows/stored-workflow-definition.md +292 -0
- package/.docs/reference/workflows/workflow-methods/agent.md +62 -0
- package/.docs/reference/workflows/workflow-methods/tool.md +43 -0
- package/CHANGELOG.md +7 -0
- package/package.json +5 -5
- package/.docs/models/providers/neon.md +0 -109
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# Mastra.addStoredWorkflow()
|
|
4
|
+
|
|
5
|
+
> **Beta:** Stored workflows are in beta. Breaking changes may occur without a major version bump until the API is stable.
|
|
6
|
+
|
|
7
|
+
The `.addStoredWorkflow()` method validates a stored workflow definition and registers it as a live workflow on the instance, persisting it through the `workflowDefinitions` storage domain. Once registered, the workflow runs like any other workflow via [`getWorkflow()`](https://mastra.ai/reference/core/getWorkflow).
|
|
8
|
+
|
|
9
|
+
See [Stored workflows](https://mastra.ai/docs/workflows/stored-workflows) for a complete setup example and the [stored workflow definition reference](https://mastra.ai/reference/workflows/stored-workflow-definition) for the accepted fields and graph entries.
|
|
10
|
+
|
|
11
|
+
## Usage example
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
await mastra.addStoredWorkflow({
|
|
15
|
+
id: 'greeting-workflow',
|
|
16
|
+
description: 'Returns a greeting for the supplied name',
|
|
17
|
+
inputSchema: {
|
|
18
|
+
type: 'object',
|
|
19
|
+
properties: { name: { type: 'string' } },
|
|
20
|
+
required: ['name'],
|
|
21
|
+
},
|
|
22
|
+
outputSchema: {
|
|
23
|
+
type: 'object',
|
|
24
|
+
properties: { message: { type: 'string' } },
|
|
25
|
+
required: ['message'],
|
|
26
|
+
},
|
|
27
|
+
graph: [
|
|
28
|
+
{
|
|
29
|
+
type: 'mapping',
|
|
30
|
+
id: 'create-greeting',
|
|
31
|
+
mapConfig: JSON.stringify({
|
|
32
|
+
message: { template: 'Hello, ${initData.name}!' },
|
|
33
|
+
}),
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
const run = await mastra.getWorkflow('greeting-workflow').createRun()
|
|
39
|
+
const result = await run.start({ inputData: { name: 'Ada' } })
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Parameters
|
|
43
|
+
|
|
44
|
+
**def** (`StoredWorkflowGraph`): The workflow definition: id, optional description and metadata, JSON Schema input/output schemas, optional state and request-context schemas, and the step graph.
|
|
45
|
+
|
|
46
|
+
## Returns
|
|
47
|
+
|
|
48
|
+
A promise that resolves once the definition is validated, registered, and persisted.
|
|
49
|
+
|
|
50
|
+
## Behavior
|
|
51
|
+
|
|
52
|
+
- The definition is fully validated (structure, references, schema flow) before anything is mutated. Agents, tools, and workflows referenced by the graph must already be registered on the instance.
|
|
53
|
+
- Adding a definition with an existing ID replaces both the stored definition and the live registration. In-flight runs keep the graph they started with.
|
|
54
|
+
- Without a storage adapter that supports the `workflowDefinitions` domain, the workflow is still validated and registered in memory, but the definition is lost on restart.
|
|
55
|
+
- To add a root workflow together with helper workflows it nests, use [`addStoredWorkflows()`](https://mastra.ai/reference/core/addStoredWorkflows).
|
|
56
|
+
|
|
57
|
+
## Related
|
|
58
|
+
|
|
59
|
+
- [Mastra.addStoredWorkflows()](https://mastra.ai/reference/core/addStoredWorkflows): Add a dependency-ordered bundle of definitions
|
|
60
|
+
- [Mastra.getWorkflow()](https://mastra.ai/reference/core/getWorkflow): Retrieve a registered workflow
|
|
61
|
+
- [Stored workflows](https://mastra.ai/docs/workflows/stored-workflows): Set up and use stored workflows
|
|
62
|
+
- [Stored workflow definition](https://mastra.ai/reference/workflows/stored-workflow-definition): Definition fields and graph entries
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# Mastra.addStoredWorkflows()
|
|
4
|
+
|
|
5
|
+
> **Beta:** Stored workflows are in beta. Breaking changes may occur without a major version bump until the API is stable.
|
|
6
|
+
|
|
7
|
+
The `.addStoredWorkflows()` method adds a bundle of stored workflow definitions that may reference each other. The typical case is a root workflow plus helper workflows it nests, where none of the definitions exist yet.
|
|
8
|
+
|
|
9
|
+
The whole bundle is validated up front. Members are then registered in dependency order, so a helper is always in place before the workflow that nests it.
|
|
10
|
+
|
|
11
|
+
[`addStoredWorkflow()`](https://mastra.ai/reference/core/addStoredWorkflow) is the single-member case.
|
|
12
|
+
|
|
13
|
+
## Usage example
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
await mastra.addStoredWorkflows([
|
|
17
|
+
helperDefinition, // nested by the root — order in the array doesn't matter
|
|
18
|
+
rootDefinition, // graph contains { type: 'workflow', workflowId: helperDefinition.id }
|
|
19
|
+
])
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Parameters
|
|
23
|
+
|
|
24
|
+
**defs** (`readonly StoredWorkflowGraph[]`): The workflow definitions to add. Nested-workflow references may resolve against the live registries or against other members of the same bundle.
|
|
25
|
+
|
|
26
|
+
## Returns
|
|
27
|
+
|
|
28
|
+
A promise that resolves once every member is validated, registered, and persisted.
|
|
29
|
+
|
|
30
|
+
## Behavior
|
|
31
|
+
|
|
32
|
+
- References resolve against the instance's registries union the bundle's own IDs, so a root may nest a helper introduced in the same call. Registration order is derived from the dependency graph, not the array order.
|
|
33
|
+
- A rejected bundle registers nothing. Duplicate IDs, invalid members, and dependency cycles are detected before anything is mutated, and if registration or persistence fails partway, the in-memory registry is restored to its prior state.
|
|
34
|
+
- Storage writes happen last. A storage-level failure mid-bundle can leave some rows written, but the registry is still rolled back and the orphaned rows are inert until the next boot.
|
|
35
|
+
|
|
36
|
+
## Related
|
|
37
|
+
|
|
38
|
+
- [Mastra.addStoredWorkflow()](https://mastra.ai/reference/core/addStoredWorkflow): Add a single definition
|
|
39
|
+
- [Stored workflows](https://mastra.ai/docs/workflows/stored-workflows): Set up and use stored workflows
|
|
40
|
+
- [Stored workflow definition](https://mastra.ai/reference/workflows/stored-workflow-definition): Definition fields and graph entries
|
package/.docs/reference/index.md
CHANGED
|
@@ -83,6 +83,8 @@ The Reference section provides documentation of Mastra's API, including paramete
|
|
|
83
83
|
- [Mastra Class](https://mastra.ai/reference/core/mastra-class)
|
|
84
84
|
- [MastraModelGateway](https://mastra.ai/reference/core/mastra-model-gateway)
|
|
85
85
|
- [.addGateway()](https://mastra.ai/reference/core/addGateway)
|
|
86
|
+
- [.addStoredWorkflow()](https://mastra.ai/reference/core/addStoredWorkflow)
|
|
87
|
+
- [.addStoredWorkflows()](https://mastra.ai/reference/core/addStoredWorkflows)
|
|
86
88
|
- [.getAgent()](https://mastra.ai/reference/core/getAgent)
|
|
87
89
|
- [.getAgentById()](https://mastra.ai/reference/core/getAgentById)
|
|
88
90
|
- [.getDeployer()](https://mastra.ai/reference/core/getDeployer)
|
|
@@ -364,8 +366,10 @@ The Reference section provides documentation of Mastra's API, including paramete
|
|
|
364
366
|
- [Overview](https://mastra.ai/reference/workers/overview)
|
|
365
367
|
- [Run Class](https://mastra.ai/reference/workflows/run)
|
|
366
368
|
- [Step Class](https://mastra.ai/reference/workflows/step)
|
|
369
|
+
- [Stored Workflow Definition](https://mastra.ai/reference/workflows/stored-workflow-definition)
|
|
367
370
|
- [Workflow Class](https://mastra.ai/reference/workflows/workflow)
|
|
368
371
|
- [Workflow State Reader](https://mastra.ai/reference/workflows/workflow-state-reader)
|
|
372
|
+
- [.agent()](https://mastra.ai/reference/workflows/workflow-methods/agent)
|
|
369
373
|
- [.branch()](https://mastra.ai/reference/workflows/workflow-methods/branch)
|
|
370
374
|
- [.commit()](https://mastra.ai/reference/workflows/workflow-methods/commit)
|
|
371
375
|
- [.createRun()](https://mastra.ai/reference/workflows/workflow-methods/create-run)
|
|
@@ -377,6 +381,7 @@ The Reference section provides documentation of Mastra's API, including paramete
|
|
|
377
381
|
- [.sleep()](https://mastra.ai/reference/workflows/workflow-methods/sleep)
|
|
378
382
|
- [.sleepUntil()](https://mastra.ai/reference/workflows/workflow-methods/sleepUntil)
|
|
379
383
|
- [.then()](https://mastra.ai/reference/workflows/workflow-methods/then)
|
|
384
|
+
- [.tool()](https://mastra.ai/reference/workflows/workflow-methods/tool)
|
|
380
385
|
- [.cancel()](https://mastra.ai/reference/workflows/run-methods/cancel)
|
|
381
386
|
- [.restart()](https://mastra.ai/reference/workflows/run-methods/restart)
|
|
382
387
|
- [.resume()](https://mastra.ai/reference/workflows/run-methods/resume)
|
|
@@ -58,6 +58,11 @@ Processor methods run at different points in the agent execution lifecycle:
|
|
|
58
58
|
│ │ ▼ │ │
|
|
59
59
|
│ │ Tool Execution (if needed) │ │
|
|
60
60
|
│ │ │ │ │
|
|
61
|
+
│ │ ▼ │ │
|
|
62
|
+
│ │ ┌────────────────────────┐ │ │
|
|
63
|
+
│ │ │ processToolResult │ ← Runs per tool, after each │ │
|
|
64
|
+
│ │ └───────────┬────────────┘ tool.execute() returns │ │
|
|
65
|
+
│ │ │ │ │
|
|
61
66
|
│ │ └──────── Loop back if tools called ────────────│ │
|
|
62
67
|
│ │ │ │
|
|
63
68
|
│ └──────────────────────────────────────────────────────────────┘ │
|
|
@@ -73,16 +78,17 @@ Processor methods run at different points in the agent execution lifecycle:
|
|
|
73
78
|
└────────────────────────────────────────────────────────────────────┘
|
|
74
79
|
```
|
|
75
80
|
|
|
76
|
-
| Method | When it runs
|
|
77
|
-
| --------------------- |
|
|
78
|
-
| `processInput` | Once at the start, before the agentic loop
|
|
79
|
-
| `processInputStep` | At each step of the agentic loop, before each LLM call
|
|
80
|
-
| `processLLMRequest` | After LLM request conversion, before the provider call
|
|
81
|
-
| `processAPIError` | When an LLM API call fails
|
|
82
|
-
| `processOutputStream` | On each streaming chunk during LLM response
|
|
83
|
-
| `processLLMResponse` | After the LLM step completes and stream chunks are collected
|
|
84
|
-
| `processOutputStep` | After each LLM response, before tool execution
|
|
85
|
-
| `
|
|
81
|
+
| Method | When it runs | Use case |
|
|
82
|
+
| --------------------- | ------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
|
|
83
|
+
| `processInput` | Once at the start, before the agentic loop | Validate/transform initial user input, add context |
|
|
84
|
+
| `processInputStep` | At each step of the agentic loop, before each LLM call | Transform messages between steps, handle tool results |
|
|
85
|
+
| `processLLMRequest` | After LLM request conversion, before the provider call | Rewrite the outbound `LanguageModelV2Prompt` for the current call without persisting changes |
|
|
86
|
+
| `processAPIError` | When an LLM API call fails | Inspect API rejections, optionally mutate state/messages, and request a retry |
|
|
87
|
+
| `processOutputStream` | On each streaming chunk during LLM response | Filter/modify streaming content, detect patterns in real-time |
|
|
88
|
+
| `processLLMResponse` | After the LLM step completes and stream chunks are collected | Capture or cache the full response, run post-call side effects paired with `processLLMRequest` |
|
|
89
|
+
| `processOutputStep` | After each LLM response, before tool execution | Validate output quality, implement guardrails with retry |
|
|
90
|
+
| `processToolResult` | Per tool, after `tool.execute()` returns and before the result is added to the message list | Scan tool output for prompt injection, redact sensitive fields, abort on policy violations |
|
|
91
|
+
| `processOutputResult` | Once after generation completes | Post-process final response, log results |
|
|
86
92
|
|
|
87
93
|
## Interface definition
|
|
88
94
|
|
|
@@ -131,6 +137,8 @@ interface Processor<TId extends string = string, TTripwireMetadata = unknown> {
|
|
|
131
137
|
|
|
132
138
|
processOutputStep?(args: ProcessOutputStepArgs<TTripwireMetadata>): ProcessorMessageResult
|
|
133
139
|
|
|
140
|
+
processToolResult?(args: ProcessToolResultArgs<TTripwireMetadata>): ProcessorMessageResult
|
|
141
|
+
|
|
134
142
|
processOutputResult?(args: ProcessOutputResultArgs<TTripwireMetadata>): ProcessorMessageResult
|
|
135
143
|
}
|
|
136
144
|
```
|
|
@@ -698,6 +706,109 @@ export class QualityGuardrail implements Processor {
|
|
|
698
706
|
}
|
|
699
707
|
```
|
|
700
708
|
|
|
709
|
+
### `processToolResult`
|
|
710
|
+
|
|
711
|
+
Processes a tool's result after `tool.execute()` returns and before the result is added to the message list or fed to the next LLM call. Symmetric with `processOutputStep`, which fires before tool execution. Use this method to scan tool output for prompt injection, redact sensitive fields, or abort the run with `abort('reason', { retry: true })`.
|
|
712
|
+
|
|
713
|
+
To replace the tool's result, mutate `messageList` in place via `messageList.updateToolInvocation`. The runtime re-reads the post-processor result from the message list and overwrites the downstream tool-result stream chunk before it is enqueued, so streaming clients see the processed value.
|
|
714
|
+
|
|
715
|
+
This method does not fire when `tool.execute()` throws; it is called only for successful tool executions where a result is available.
|
|
716
|
+
|
|
717
|
+
```typescript
|
|
718
|
+
processToolResult?(args: ProcessToolResultArgs): ProcessorMessageResult;
|
|
719
|
+
```
|
|
720
|
+
|
|
721
|
+
#### `ProcessToolResultArgs`
|
|
722
|
+
|
|
723
|
+
**messages** (`MastraDBMessage[]`): All messages including the current assistant message with the tool call.
|
|
724
|
+
|
|
725
|
+
**messageList** (`MessageList`): MessageList instance for managing messages. Call updateToolInvocation to replace the tool result with a redacted or transformed value.
|
|
726
|
+
|
|
727
|
+
**stepNumber** (`number`): Current step number (0-indexed).
|
|
728
|
+
|
|
729
|
+
**toolName** (`string`): Name of the tool that was executed.
|
|
730
|
+
|
|
731
|
+
**toolCallId** (`string`): Unique identifier for this specific tool call.
|
|
732
|
+
|
|
733
|
+
**args** (`unknown`): Arguments the LLM passed to the tool.
|
|
734
|
+
|
|
735
|
+
**result** (`unknown`): Value returned by the tool. For client-executed tools this is the output of tool.execute() after it has passed through ensureSerializable. For provider-executed tools (e.g. Anthropic web\_search) it is the raw result from the provider stream, which is not run through ensureSerializable.
|
|
736
|
+
|
|
737
|
+
**providerExecuted** (`boolean`): Whether this result came from a provider-executed tool such as Anthropic web\_search. Defaults to undefined for client-executed tools.
|
|
738
|
+
|
|
739
|
+
**systemMessages** (`CoreMessage[]`): All system messages for read access.
|
|
740
|
+
|
|
741
|
+
**steps** (`StepResult[]`): All completed steps so far.
|
|
742
|
+
|
|
743
|
+
**state** (`Record<string, unknown>`): Per-processor state that persists across all method calls within this request. Shared with other processor methods on the same processor.
|
|
744
|
+
|
|
745
|
+
**abort** (`(reason?: string, options?: { retry?: boolean; metadata?: unknown }) => never`): Function to abort the run. Pass retry: true to request the LLM retry the step with the abort reason as feedback.
|
|
746
|
+
|
|
747
|
+
**retryCount** (`number`): Number of times processors have triggered retry. Starts at 0.
|
|
748
|
+
|
|
749
|
+
**tracingContext** (`TracingContext`): Tracing context for observability.
|
|
750
|
+
|
|
751
|
+
**requestContext** (`RequestContext`): Request-scoped context with execution metadata.
|
|
752
|
+
|
|
753
|
+
#### Use cases
|
|
754
|
+
|
|
755
|
+
- Scanning tool output for prompt injection before the LLM sees it.
|
|
756
|
+
- Redacting sensitive fields from tool returns (PII, secrets, credentials).
|
|
757
|
+
- Aborting the run when a tool returns content that violates policy.
|
|
758
|
+
- Logging or instrumenting tool returns for compliance or audit.
|
|
759
|
+
|
|
760
|
+
#### Example: Redact sensitive fields
|
|
761
|
+
|
|
762
|
+
```typescript
|
|
763
|
+
import type { Processor } from '@mastra/core/processors'
|
|
764
|
+
|
|
765
|
+
export class RedactToolResult implements Processor {
|
|
766
|
+
id = 'redact-tool-result'
|
|
767
|
+
|
|
768
|
+
async processToolResult({ toolName, toolCallId, args, result, messageList }) {
|
|
769
|
+
if (toolName !== 'lookup-customer') return
|
|
770
|
+
|
|
771
|
+
const redacted = {
|
|
772
|
+
...(result as Record<string, unknown>),
|
|
773
|
+
ssn: '[REDACTED]',
|
|
774
|
+
email: '[REDACTED]',
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
messageList.updateToolInvocation({
|
|
778
|
+
type: 'tool-invocation',
|
|
779
|
+
toolInvocation: {
|
|
780
|
+
state: 'result',
|
|
781
|
+
toolCallId,
|
|
782
|
+
toolName,
|
|
783
|
+
args,
|
|
784
|
+
result: redacted,
|
|
785
|
+
},
|
|
786
|
+
})
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
```
|
|
790
|
+
|
|
791
|
+
#### Example: Block prompt injection in tool output
|
|
792
|
+
|
|
793
|
+
```typescript
|
|
794
|
+
import type { Processor } from '@mastra/core/processors'
|
|
795
|
+
|
|
796
|
+
export class ScanToolResult implements Processor {
|
|
797
|
+
id = 'scan-tool-result'
|
|
798
|
+
|
|
799
|
+
async processToolResult({ result, abort }) {
|
|
800
|
+
const text = typeof result === 'string' ? result : JSON.stringify(result)
|
|
801
|
+
if (containsPromptInjection(text)) {
|
|
802
|
+
abort('blocked by scan-tool-result: suspected prompt injection')
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
function containsPromptInjection(text: string): boolean {
|
|
808
|
+
return /ignore (all )?(previous|prior) instructions/i.test(text)
|
|
809
|
+
}
|
|
810
|
+
```
|
|
811
|
+
|
|
701
812
|
## Processor types
|
|
702
813
|
|
|
703
814
|
Mastra provides type aliases to ensure processors implement the required methods:
|
|
@@ -183,6 +183,19 @@ The route returns:
|
|
|
183
183
|
| `GET` | `/api/workflows/:workflowId/runs` | List workflow runs |
|
|
184
184
|
| `GET` | `/api/workflows/:workflowId/runs/:runId` | Get specific run |
|
|
185
185
|
|
|
186
|
+
### Stored workflows
|
|
187
|
+
|
|
188
|
+
Stored workflow definitions (beta) are workflows expressed as JSON, persisted through the `workflowDefinitions` storage domain, and live-registered on the running instance. See [Stored workflows](https://mastra.ai/docs/workflows/stored-workflows).
|
|
189
|
+
|
|
190
|
+
| Method | Path | Description |
|
|
191
|
+
| -------- | ----------------------------------------- | ------------------------------------------------------------------------------ |
|
|
192
|
+
| `GET` | `/api/stored/workflows` | List stored workflow definitions, filterable by `status` and `authorId` |
|
|
193
|
+
| `GET` | `/api/stored/workflows/:storedWorkflowId` | Get a stored workflow definition by ID |
|
|
194
|
+
| `POST` | `/api/stored/workflows` | Upsert a definition (plus optional helper `dependencies`) and live-register it |
|
|
195
|
+
| `DELETE` | `/api/stored/workflows/:storedWorkflowId` | Delete a stored definition and unregister the live workflow |
|
|
196
|
+
|
|
197
|
+
On authenticated servers, the read routes require the `stored-workflows:read` permission and the write routes require `stored-workflows:write`. Registered stored workflows are executed through the ordinary `/api/workflows/:workflowId` routes above.
|
|
198
|
+
|
|
186
199
|
### Create run request body
|
|
187
200
|
|
|
188
201
|
```typescript
|
|
@@ -10,14 +10,15 @@ Mastra storage is organized into domains. Each domain owns a set of tables or co
|
|
|
10
10
|
|
|
11
11
|
Not every storage adapter implements every domain. Composite storage lets you mix adapters per domain when the adapter packages export the corresponding domain classes.
|
|
12
12
|
|
|
13
|
-
| Domain
|
|
14
|
-
|
|
|
15
|
-
| `memory`
|
|
16
|
-
| `workflows`
|
|
17
|
-
| `
|
|
18
|
-
| `
|
|
19
|
-
| `
|
|
20
|
-
| `
|
|
13
|
+
| Domain | Description |
|
|
14
|
+
| --------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
|
|
15
|
+
| `memory` | Conversation persistence: messages, threads, and resources (including working memory). |
|
|
16
|
+
| `workflows` | Workflow run snapshots used for suspend and resume. |
|
|
17
|
+
| `workflowDefinitions` | Persisted [stored workflow](https://mastra.ai/docs/workflows/stored-workflows) definitions (beta). Loaded and live-registered on boot. |
|
|
18
|
+
| `scores` | Evaluation score records from eval runs. |
|
|
19
|
+
| `observability` | Traces and spans used by observability exporters and Studio. |
|
|
20
|
+
| `datasets` | Dataset records, versioned items, and dataset versions used by experiments. |
|
|
21
|
+
| `experiments` | Experiment runs and per-item experiment results. |
|
|
21
22
|
|
|
22
23
|
The schema definitions below cover the built-in database-backed tables documented for `memory`, `workflows`, `scores`, and `observability`. Other domains, and non-database adapters, use implementation-specific storage structures.
|
|
23
24
|
|
|
@@ -34,7 +34,7 @@ The stream emits event types during workflow execution. Each event has a `type`
|
|
|
34
34
|
- **`workflow-step-start`**: A step begins execution
|
|
35
35
|
- **`workflow-step-output`**: Custom output from a step
|
|
36
36
|
- **`workflow-step-result`**: A step completes with results
|
|
37
|
-
- **`workflow-finish`**: Workflow execution completes with usage statistics
|
|
37
|
+
- **`workflow-finish`**: Workflow execution completes with usage statistics. For successful runs, `payload.finalWorkflowResult` carries the workflow's final result
|
|
38
38
|
|
|
39
39
|
## Related
|
|
40
40
|
|
|
@@ -66,7 +66,7 @@ The stream emits event types during workflow execution. Each event has a `type`
|
|
|
66
66
|
- **`workflow-step-start`**: A step begins execution
|
|
67
67
|
- **`workflow-step-output`**: Custom output from a step
|
|
68
68
|
- **`workflow-step-result`**: A step completes with results
|
|
69
|
-
- **`workflow-finish`**: Workflow execution completes with usage statistics
|
|
69
|
+
- **`workflow-finish`**: Workflow execution completes with usage statistics. For successful runs, `payload.finalWorkflowResult` carries the workflow's final result
|
|
70
70
|
|
|
71
71
|
## Related
|
|
72
72
|
|
|
@@ -93,7 +93,7 @@ The stream emits event types during workflow execution. Each event has a `type`
|
|
|
93
93
|
- **`workflow-step-output`**: Custom output from a step
|
|
94
94
|
- **`workflow-step-progress`**: A foreach step reports per-iteration progress (includes `completedCount`, `totalCount`, `currentIndex`, `iterationStatus`, and optional `iterationOutput`)
|
|
95
95
|
- **`workflow-step-result`**: A step completes with results
|
|
96
|
-
- **`workflow-finish`**: Workflow execution completes with usage statistics
|
|
96
|
+
- **`workflow-finish`**: Workflow execution completes with usage statistics. For successful runs, `payload.finalWorkflowResult` carries the workflow's final result so stream consumers don't need a follow-up fetch
|
|
97
97
|
|
|
98
98
|
## Related
|
|
99
99
|
|