@mastra/mcp-docs-server 1.0.0-beta.5 → 1.0.0-beta.7
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/organized/changelogs/%40mastra%2Fagent-builder.md +9 -9
- package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +67 -67
- package/.docs/organized/changelogs/%40mastra%2Fastra.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fchroma.md +12 -12
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +57 -57
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +110 -110
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +57 -57
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +57 -57
- package/.docs/organized/changelogs/%40mastra%2Fcodemod.md +6 -0
- package/.docs/organized/changelogs/%40mastra%2Fconvex.md +60 -0
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +358 -358
- package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +24 -24
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +12 -12
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +79 -79
- package/.docs/organized/changelogs/%40mastra%2Fduckdb.md +42 -0
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +57 -57
- package/.docs/organized/changelogs/%40mastra%2Felasticsearch.md +61 -0
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +12 -12
- package/.docs/organized/changelogs/%40mastra%2Flance.md +57 -57
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +55 -55
- package/.docs/organized/changelogs/%40mastra%2Floggers.md +12 -12
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +125 -125
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +36 -36
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +57 -57
- package/.docs/organized/changelogs/%40mastra%2Fmssql.md +57 -57
- package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +59 -59
- package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +77 -77
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Frag.md +43 -43
- package/.docs/organized/changelogs/%40mastra%2Freact.md +16 -0
- package/.docs/organized/changelogs/%40mastra%2Fs3vectors.md +9 -0
- package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +6 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +113 -113
- package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +57 -57
- package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +19 -19
- package/.docs/organized/changelogs/create-mastra.md +15 -15
- package/.docs/organized/changelogs/mastra.md +30 -30
- package/.docs/organized/code-examples/agui.md +1 -0
- package/.docs/organized/code-examples/ai-elements.md +1 -1
- package/.docs/organized/code-examples/ai-sdk-useChat.md +1 -1
- package/.docs/organized/code-examples/ai-sdk-v5.md +2 -1
- package/.docs/organized/code-examples/assistant-ui.md +1 -1
- package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +1 -1
- package/.docs/organized/code-examples/bird-checker-with-nextjs.md +1 -1
- package/.docs/organized/code-examples/crypto-chatbot.md +1 -1
- package/.docs/organized/code-examples/mcp-server-adapters.md +721 -0
- package/.docs/organized/code-examples/server-app-access.md +342 -0
- package/.docs/organized/code-examples/server-express-adapter.md +87 -0
- package/.docs/organized/code-examples/server-hono-adapter.md +85 -0
- package/.docs/raw/agents/agent-approval.mdx +189 -0
- package/.docs/raw/agents/guardrails.mdx +13 -9
- package/.docs/raw/agents/networks.mdx +1 -0
- package/.docs/raw/agents/overview.mdx +8 -152
- package/.docs/raw/agents/processors.mdx +279 -0
- package/.docs/raw/agents/structured-output.mdx +224 -0
- package/.docs/raw/deployment/cloud-providers/index.mdx +19 -26
- package/.docs/raw/deployment/cloud-providers/netlify-deployer.mdx +44 -13
- package/.docs/raw/evals/running-in-ci.mdx +0 -2
- package/.docs/raw/{guides/getting-started → getting-started}/manual-install.mdx +2 -2
- package/.docs/raw/getting-started/start.mdx +1 -1
- package/.docs/raw/guides/build-your-ui/ai-sdk-ui.mdx +8 -0
- package/.docs/raw/guides/getting-started/quickstart.mdx +1 -1
- package/.docs/raw/guides/guide/whatsapp-chat-bot.mdx +421 -0
- package/.docs/raw/guides/index.mdx +3 -35
- package/.docs/raw/guides/migrations/upgrade-to-v1/agent.mdx +11 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/workflows.mdx +37 -0
- package/.docs/raw/index.mdx +1 -1
- package/.docs/raw/memory/memory-processors.mdx +265 -79
- package/.docs/raw/memory/working-memory.mdx +11 -2
- package/.docs/raw/observability/overview.mdx +0 -1
- package/.docs/raw/observability/tracing/bridges/otel.mdx +200 -0
- package/.docs/raw/observability/tracing/exporters/arize.mdx +36 -0
- package/.docs/raw/observability/tracing/exporters/braintrust.mdx +19 -0
- package/.docs/raw/observability/tracing/exporters/langfuse.mdx +83 -0
- package/.docs/raw/observability/tracing/exporters/langsmith.mdx +12 -0
- package/.docs/raw/observability/tracing/exporters/otel.mdx +34 -22
- package/.docs/raw/observability/tracing/exporters/posthog.mdx +20 -0
- package/.docs/raw/observability/tracing/overview.mdx +76 -6
- package/.docs/raw/observability/tracing/processors/sensitive-data-filter.mdx +0 -1
- package/.docs/raw/rag/retrieval.mdx +23 -6
- package/.docs/raw/rag/vector-databases.mdx +93 -2
- package/.docs/raw/reference/agents/generate.mdx +55 -6
- package/.docs/raw/reference/agents/network.mdx +44 -0
- package/.docs/raw/reference/client-js/memory.mdx +43 -0
- package/.docs/raw/reference/client-js/workflows.mdx +92 -63
- package/.docs/raw/reference/deployer/netlify.mdx +1 -2
- package/.docs/raw/reference/evals/scorer-utils.mdx +362 -0
- package/.docs/raw/reference/index.mdx +1 -0
- package/.docs/raw/reference/observability/tracing/bridges/otel.mdx +177 -0
- package/.docs/raw/reference/observability/tracing/configuration.mdx +0 -4
- package/.docs/raw/reference/observability/tracing/exporters/arize.mdx +29 -0
- package/.docs/raw/reference/observability/tracing/exporters/langfuse.mdx +43 -0
- package/.docs/raw/reference/observability/tracing/exporters/langsmith.mdx +17 -1
- package/.docs/raw/reference/observability/tracing/exporters/otel.mdx +33 -43
- package/.docs/raw/reference/observability/tracing/instances.mdx +0 -4
- package/.docs/raw/reference/observability/tracing/interfaces.mdx +29 -4
- package/.docs/raw/reference/observability/tracing/spans.mdx +0 -4
- package/.docs/raw/reference/processors/language-detector.mdx +9 -2
- package/.docs/raw/reference/processors/message-history-processor.mdx +131 -0
- package/.docs/raw/reference/processors/moderation-processor.mdx +10 -3
- package/.docs/raw/reference/processors/pii-detector.mdx +10 -3
- package/.docs/raw/reference/processors/processor-interface.mdx +502 -0
- package/.docs/raw/reference/processors/prompt-injection-detector.mdx +9 -2
- package/.docs/raw/reference/processors/semantic-recall-processor.mdx +197 -0
- package/.docs/raw/reference/processors/system-prompt-scrubber.mdx +2 -2
- package/.docs/raw/reference/processors/tool-call-filter.mdx +125 -0
- package/.docs/raw/reference/processors/working-memory-processor.mdx +221 -0
- package/.docs/raw/reference/server/create-route.mdx +314 -0
- package/.docs/raw/reference/server/express-adapter.mdx +193 -0
- package/.docs/raw/reference/server/hono-adapter.mdx +174 -0
- package/.docs/raw/reference/server/mastra-server.mdx +316 -0
- package/.docs/raw/reference/server/routes.mdx +250 -0
- package/.docs/raw/reference/storage/cloudflare-d1.mdx +37 -0
- package/.docs/raw/reference/storage/convex.mdx +164 -0
- package/.docs/raw/reference/storage/lance.mdx +33 -0
- package/.docs/raw/reference/storage/libsql.mdx +37 -0
- package/.docs/raw/reference/storage/mongodb.mdx +39 -0
- package/.docs/raw/reference/storage/mssql.mdx +37 -0
- package/.docs/raw/reference/storage/postgresql.mdx +37 -0
- package/.docs/raw/reference/streaming/ChunkType.mdx +1 -1
- package/.docs/raw/reference/streaming/agents/stream.mdx +56 -1
- package/.docs/raw/reference/streaming/workflows/observeStream.mdx +7 -9
- package/.docs/raw/reference/streaming/workflows/{resumeStreamVNext.mdx → resumeStream.mdx} +51 -11
- package/.docs/raw/reference/streaming/workflows/stream.mdx +83 -24
- package/.docs/raw/reference/streaming/workflows/timeTravelStream.mdx +170 -0
- package/.docs/raw/reference/tools/mcp-client.mdx +128 -18
- package/.docs/raw/reference/vectors/convex.mdx +429 -0
- package/.docs/raw/reference/vectors/duckdb.mdx +462 -0
- package/.docs/raw/reference/vectors/elasticsearch.mdx +310 -0
- package/.docs/raw/reference/voice/google.mdx +159 -20
- package/.docs/raw/reference/workflows/run-methods/restart.mdx +142 -0
- package/.docs/raw/reference/workflows/run-methods/resume.mdx +44 -0
- package/.docs/raw/reference/workflows/run-methods/start.mdx +44 -0
- package/.docs/raw/reference/workflows/run-methods/timeTravel.mdx +310 -0
- package/.docs/raw/reference/workflows/run.mdx +27 -5
- package/.docs/raw/reference/workflows/step.mdx +13 -0
- package/.docs/raw/reference/workflows/workflow.mdx +19 -0
- package/.docs/raw/server-db/custom-adapters.mdx +380 -0
- package/.docs/raw/server-db/mastra-server.mdx +16 -8
- package/.docs/raw/server-db/request-context.mdx +0 -1
- package/.docs/raw/server-db/server-adapters.mdx +286 -0
- package/.docs/raw/server-db/storage.mdx +11 -0
- package/.docs/raw/streaming/overview.mdx +6 -6
- package/.docs/raw/streaming/tool-streaming.mdx +2 -2
- package/.docs/raw/streaming/workflow-streaming.mdx +5 -11
- package/.docs/raw/workflows/error-handling.mdx +1 -0
- package/.docs/raw/workflows/human-in-the-loop.mdx +4 -4
- package/.docs/raw/workflows/overview.mdx +56 -44
- package/.docs/raw/workflows/snapshots.mdx +1 -0
- package/.docs/raw/workflows/suspend-and-resume.mdx +85 -16
- package/.docs/raw/workflows/time-travel.mdx +313 -0
- package/.docs/raw/workflows/workflow-state.mdx +191 -0
- package/CHANGELOG.md +16 -0
- package/package.json +4 -4
- package/.docs/raw/agents/human-in-the-loop-with-tools.mdx +0 -91
- package/.docs/raw/reference/streaming/workflows/observeStreamVNext.mdx +0 -47
- package/.docs/raw/reference/streaming/workflows/streamVNext.mdx +0 -153
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mcp-docs-server",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.7",
|
|
4
4
|
"description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"@modelcontextprotocol/sdk": "^1.17.5",
|
|
29
29
|
"jsdom": "^26.1.0",
|
|
30
30
|
"zod": "^3.25.76",
|
|
31
|
-
"@mastra/core": "1.0.0-beta.
|
|
32
|
-
"@mastra/mcp": "^1.0.0-beta.
|
|
31
|
+
"@mastra/core": "1.0.0-beta.7",
|
|
32
|
+
"@mastra/mcp": "^1.0.0-beta.5"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@hono/node-server": "^1.19.6",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"typescript": "^5.8.3",
|
|
47
47
|
"vitest": "4.0.12",
|
|
48
48
|
"@internal/lint": "0.0.53",
|
|
49
|
-
"@mastra/core": "1.0.0-beta.
|
|
49
|
+
"@mastra/core": "1.0.0-beta.7"
|
|
50
50
|
},
|
|
51
51
|
"homepage": "https://mastra.ai",
|
|
52
52
|
"repository": {
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Human in the Loop with Tools | Agents"
|
|
3
|
-
description: Learn how to require approvals and suspend tool execution while keeping humans in control of agent workflows.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Human in the Loop with Tools
|
|
7
|
-
|
|
8
|
-
Sometimes agents need human oversight before they can run potentially sensitive tools or long-running workflows. Mastra lets you pause tool execution to wait for approval, decline a tool call entirely, or suspend a tool mid-flight until the required data is available.
|
|
9
|
-
|
|
10
|
-
## Tool approvals
|
|
11
|
-
|
|
12
|
-
### Enforcing approval on every tool
|
|
13
|
-
|
|
14
|
-
Pass `requireToolApproval: true` when calling `stream` (or `generate`) to automatically pause execution whenever the agent tries to invoke a tool. The stream closes until you explicitly approve or decline the tool call using the original run’s `runId`.
|
|
15
|
-
|
|
16
|
-
```typescript {2,6} title="Require approval before executing any tool" showLineNumbers copy
|
|
17
|
-
const stream = await myAgent.stream("Find the user with name - John Smith", {
|
|
18
|
-
requireToolApproval: true,
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
const approvedToolCallStream = await myAgent.approveToolCall({ runId: stream.runId });
|
|
22
|
-
const declinedToolCallStream = await myAgent.declineToolCall({ runId: stream.runId });
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
### Requiring approval per tool
|
|
26
|
-
|
|
27
|
-
You can also enforce approval on specific tools. Set `requireApproval: true` when creating a tool so the agent pauses only when it tries to invoke that tool.
|
|
28
|
-
|
|
29
|
-
```typescript {8} title="Mark a tool as approval-only" showLineNumbers copy
|
|
30
|
-
const findUserTool = createTool({
|
|
31
|
-
id: "Find user tool",
|
|
32
|
-
description: "Returns the name and email for a matching user",
|
|
33
|
-
inputSchema: z.object({
|
|
34
|
-
name: z.string(),
|
|
35
|
-
}),
|
|
36
|
-
execute: async (inputData) => {
|
|
37
|
-
return mockFindUser(inputData);
|
|
38
|
-
},
|
|
39
|
-
requireApproval: true,
|
|
40
|
-
});
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
When the agent reaches this tool, it emits a tool-call event you can approve or decline with the same `approveToolCall` or `declineToolCall` helpers.
|
|
44
|
-
|
|
45
|
-
## Tool suspension
|
|
46
|
-
|
|
47
|
-
Sometimes a tool can’t finish immediately—maybe it’s waiting for external confirmation or extra input. You can suspend and later resume execution using `workflow.suspend`, `resumeStream`, and optional schemas that define what data is required at each step.
|
|
48
|
-
|
|
49
|
-
```typescript {10,14} title="Suspend and resume a tool" showLineNumbers copy
|
|
50
|
-
const findUserTool = createTool({
|
|
51
|
-
id: "Find user tool",
|
|
52
|
-
description: "Returns the name and email for a matching user",
|
|
53
|
-
inputSchema: z.object({
|
|
54
|
-
name: z.string(),
|
|
55
|
-
}),
|
|
56
|
-
suspendSchema: z.object({
|
|
57
|
-
message: z.string(),
|
|
58
|
-
}),
|
|
59
|
-
resumeSchema: z.object({
|
|
60
|
-
name: z.string(),
|
|
61
|
-
}),
|
|
62
|
-
execute: async (inputData, { agent }) => {
|
|
63
|
-
if (!agent.resumeData) {
|
|
64
|
-
return agent.suspend({ message: "Please provide the name of the user" });
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return {
|
|
68
|
-
name: agent?.resumeData?.name,
|
|
69
|
-
email: "test@test.com",
|
|
70
|
-
};
|
|
71
|
-
},
|
|
72
|
-
});
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
To continue execution, call `resumeStream` with the run’s `runId` and the `resumeData` that satisfies the `resumeSchema`. The workflow resumes from the suspension point and the tool completes with the new data.
|
|
76
|
-
When using `suspend` directly in the tool, you don't need to add `requireToolApproval: true` to the agent `stream`/`generate` call, nor `requireApproval: true` to the tool creation.
|
|
77
|
-
|
|
78
|
-
```typescript {1} title="Resume a suspended tool call" showLineNumbers copy
|
|
79
|
-
const resumedStream = await myAgent.resumeStream(
|
|
80
|
-
{ name: "John Smith" },
|
|
81
|
-
{ runId: stream.runId }
|
|
82
|
-
);
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
## Related
|
|
86
|
-
|
|
87
|
-
- [Using Tools](./using-tools)
|
|
88
|
-
- [Agent Overview](./overview)
|
|
89
|
-
- [Tools Overview](../mcp/overview)
|
|
90
|
-
- [Agent Memory](./agent-memory)
|
|
91
|
-
- [Request Context](/docs/v1/server-db/request-context)
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Reference: Run.observeStreamVNext() (Experimental) | Streaming"
|
|
3
|
-
description: Documentation for the `Run.observeStreamVNext()` method in workflows, which enables reopening the stream of an already active workflow run.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Run.observeStreamVNext() (Experimental)
|
|
7
|
-
|
|
8
|
-
The `.observeStreamVNext()` method opens a new `ReadableStream` to a workflow run that is currently running, allowing you to observe the stream of events if the original stream is no longer available.
|
|
9
|
-
|
|
10
|
-
## Usage example
|
|
11
|
-
|
|
12
|
-
```typescript showLineNumbers copy
|
|
13
|
-
const run = await workflow.createRun();
|
|
14
|
-
|
|
15
|
-
run.streamVNext({
|
|
16
|
-
inputData: {
|
|
17
|
-
value: "initial data",
|
|
18
|
-
},
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
const stream = await run.observeStreamVNext();
|
|
22
|
-
|
|
23
|
-
for await (const chunk of stream) {
|
|
24
|
-
console.log(chunk);
|
|
25
|
-
}
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## Returns
|
|
29
|
-
|
|
30
|
-
`ReadableStream<ChunkType>`
|
|
31
|
-
|
|
32
|
-
## Stream Events
|
|
33
|
-
|
|
34
|
-
The stream emits various event types during workflow execution. Each event has a `type` field and a `payload` containing relevant data:
|
|
35
|
-
|
|
36
|
-
- **`workflow-start`**: Workflow execution begins
|
|
37
|
-
- **`workflow-step-start`**: A step begins execution
|
|
38
|
-
- **`workflow-step-output`**: Custom output from a step
|
|
39
|
-
- **`workflow-step-result`**: A step completes with results
|
|
40
|
-
- **`workflow-finish`**: Workflow execution completes with usage statistics
|
|
41
|
-
|
|
42
|
-
## Related
|
|
43
|
-
|
|
44
|
-
- [Workflows overview](/docs/v1/workflows/overview#running-workflows)
|
|
45
|
-
- [Workflow.createRun()](/reference/v1/workflows/workflow-methods/create-run)
|
|
46
|
-
- [Run.streamVNext()](./streamVNext)
|
|
47
|
-
- [Run.resumeStreamVNext()](./resumeStreamVNext)
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Reference: Run.streamVNext() (Experimental) | Streaming"
|
|
3
|
-
description: Documentation for the `Run.streamVNext()` method in workflows, which enables real-time streaming of responses.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Run.streamVNext() (Experimental)
|
|
7
|
-
|
|
8
|
-
:::caution Experimental Feature
|
|
9
|
-
This is an experimental API that may change in future versions. The `streamVNext()` method will eventually replace the current `stream()` method. Use with caution in production environments.
|
|
10
|
-
:::
|
|
11
|
-
|
|
12
|
-
The `.streamVNext()` method enables real-time streaming of responses from a workflow. This enhanced streaming capability will eventually replace the current `stream()` method.
|
|
13
|
-
|
|
14
|
-
## Usage example
|
|
15
|
-
|
|
16
|
-
```typescript showLineNumbers copy
|
|
17
|
-
const run = await workflow.createRun();
|
|
18
|
-
|
|
19
|
-
const stream = run.streamVNext({
|
|
20
|
-
inputData: {
|
|
21
|
-
value: "initial data",
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## Parameters
|
|
27
|
-
|
|
28
|
-
<PropertiesTable
|
|
29
|
-
content={[
|
|
30
|
-
{
|
|
31
|
-
name: "inputData",
|
|
32
|
-
type: "z.infer<TInput>",
|
|
33
|
-
description: "Input data that matches the workflow's input schema",
|
|
34
|
-
isOptional: true,
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
name: "requestContext",
|
|
38
|
-
type: "RequestContext",
|
|
39
|
-
description: "Request Context data to use during workflow execution",
|
|
40
|
-
isOptional: true,
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
name: "tracingContext",
|
|
44
|
-
type: "TracingContext",
|
|
45
|
-
isOptional: true,
|
|
46
|
-
description:
|
|
47
|
-
"Tracing context for creating child spans and adding metadata.",
|
|
48
|
-
properties: [
|
|
49
|
-
{
|
|
50
|
-
parameters: [
|
|
51
|
-
{
|
|
52
|
-
name: "currentSpan",
|
|
53
|
-
type: "Span",
|
|
54
|
-
isOptional: true,
|
|
55
|
-
description:
|
|
56
|
-
"Current span for creating child spans and adding metadata.",
|
|
57
|
-
},
|
|
58
|
-
],
|
|
59
|
-
},
|
|
60
|
-
],
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
name: "tracingOptions",
|
|
64
|
-
type: "TracingOptions",
|
|
65
|
-
isOptional: true,
|
|
66
|
-
description: "Options for Tracing configuration.",
|
|
67
|
-
properties: [
|
|
68
|
-
{
|
|
69
|
-
parameters: [
|
|
70
|
-
{
|
|
71
|
-
name: "metadata",
|
|
72
|
-
type: "Record<string, any>",
|
|
73
|
-
isOptional: true,
|
|
74
|
-
description: "Metadata to add to the root trace span.",
|
|
75
|
-
},
|
|
76
|
-
],
|
|
77
|
-
},
|
|
78
|
-
],
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
name: "closeOnSuspend",
|
|
82
|
-
type: "boolean",
|
|
83
|
-
description:
|
|
84
|
-
"Whether to close the stream when the workflow is suspended, or to keep the stream open until the workflow is finished (by success or error). Default value is true.",
|
|
85
|
-
isOptional: true,
|
|
86
|
-
},
|
|
87
|
-
]}
|
|
88
|
-
/>
|
|
89
|
-
|
|
90
|
-
## Returns
|
|
91
|
-
|
|
92
|
-
<PropertiesTable
|
|
93
|
-
content={[
|
|
94
|
-
{
|
|
95
|
-
name: "stream",
|
|
96
|
-
type: "MastraWorkflowStream<ChunkType>",
|
|
97
|
-
description:
|
|
98
|
-
"A custom stream that extends ReadableStream<ChunkType> with additional workflow-specific properties",
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
name: "stream.status",
|
|
102
|
-
type: "Promise<RunStatus>",
|
|
103
|
-
description: "A promise that resolves to the current workflow run status",
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
name: "stream.result",
|
|
107
|
-
type: "Promise<WorkflowResult<TState, TOutput, TSteps>>",
|
|
108
|
-
description: "A promise that resolves to the final workflow result",
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
name: "stream.usage",
|
|
112
|
-
type: "Promise<{ inputTokens: number; outputTokens: number; totalTokens: number, reasoningTokens?: number, cacheInputTokens?: number }>",
|
|
113
|
-
description: "A promise that resolves to token usage statistics",
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
name: "stream.traceId",
|
|
117
|
-
type: "string",
|
|
118
|
-
isOptional: true,
|
|
119
|
-
description:
|
|
120
|
-
"The trace ID associated with this execution when Tracing is enabled.",
|
|
121
|
-
},
|
|
122
|
-
]}
|
|
123
|
-
/>
|
|
124
|
-
|
|
125
|
-
## Extended usage example
|
|
126
|
-
|
|
127
|
-
```typescript showLineNumbers copy
|
|
128
|
-
const run = await workflow.createRun();
|
|
129
|
-
|
|
130
|
-
const stream = run.streamVNext({
|
|
131
|
-
inputData: {
|
|
132
|
-
value: "initial data",
|
|
133
|
-
},
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
const result = await stream.result;
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
## Stream Events
|
|
140
|
-
|
|
141
|
-
The stream emits various event types during workflow execution. Each event has a `type` field and a `payload` containing relevant data:
|
|
142
|
-
|
|
143
|
-
- **`workflow-start`**: Workflow execution begins
|
|
144
|
-
- **`workflow-step-start`**: A step begins execution
|
|
145
|
-
- **`workflow-step-output`**: Custom output from a step
|
|
146
|
-
- **`workflow-step-result`**: A step completes with results
|
|
147
|
-
- **`workflow-finish`**: Workflow execution completes with usage statistics
|
|
148
|
-
|
|
149
|
-
## Related
|
|
150
|
-
|
|
151
|
-
- [Workflows overview](/docs/v1/workflows/overview#running-workflows)
|
|
152
|
-
- [Workflow.createRun()](/reference/v1/workflows/workflow-methods/create-run)
|
|
153
|
-
- [Run.resumeStreamVNext()](./resumeStreamVNext)
|