@mastra/mcp-docs-server 0.0.5 → 0.0.6-alpha.2

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.
Files changed (110) hide show
  1. package/.docs/organized/changelogs/%40mastra%2Fastra.md +52 -52
  2. package/.docs/organized/changelogs/%40mastra%2Fchroma.md +50 -50
  3. package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +11 -0
  4. package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +55 -55
  5. package/.docs/organized/changelogs/%40mastra%2Fcore.md +52 -52
  6. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +61 -61
  7. package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +61 -61
  8. package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +61 -61
  9. package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +61 -61
  10. package/.docs/organized/changelogs/%40mastra%2Fevals.md +51 -51
  11. package/.docs/organized/changelogs/%40mastra%2Ffirecrawl.md +55 -55
  12. package/.docs/organized/changelogs/%40mastra%2Fgithub.md +50 -50
  13. package/.docs/organized/changelogs/%40mastra%2Floggers.md +50 -50
  14. package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +49 -0
  15. package/.docs/organized/changelogs/%40mastra%2Fmcp.md +50 -50
  16. package/.docs/organized/changelogs/%40mastra%2Fmem0.md +50 -0
  17. package/.docs/organized/changelogs/%40mastra%2Fmemory.md +61 -61
  18. package/.docs/organized/changelogs/%40mastra%2Fpg.md +54 -54
  19. package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +51 -51
  20. package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +64 -64
  21. package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +51 -51
  22. package/.docs/organized/changelogs/%40mastra%2Frag.md +52 -52
  23. package/.docs/organized/changelogs/%40mastra%2Fragie.md +50 -50
  24. package/.docs/organized/changelogs/%40mastra%2Fserver.md +302 -0
  25. package/.docs/organized/changelogs/%40mastra%2Fspeech-azure.md +50 -50
  26. package/.docs/organized/changelogs/%40mastra%2Fspeech-deepgram.md +50 -50
  27. package/.docs/organized/changelogs/%40mastra%2Fspeech-elevenlabs.md +50 -50
  28. package/.docs/organized/changelogs/%40mastra%2Fspeech-google.md +51 -51
  29. package/.docs/organized/changelogs/%40mastra%2Fspeech-ibm.md +50 -50
  30. package/.docs/organized/changelogs/%40mastra%2Fspeech-murf.md +50 -50
  31. package/.docs/organized/changelogs/%40mastra%2Fspeech-openai.md +50 -50
  32. package/.docs/organized/changelogs/%40mastra%2Fspeech-playai.md +50 -50
  33. package/.docs/organized/changelogs/%40mastra%2Fspeech-replicate.md +50 -50
  34. package/.docs/organized/changelogs/%40mastra%2Fspeech-speechify.md +50 -50
  35. package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +49 -0
  36. package/.docs/organized/changelogs/%40mastra%2Fupstash.md +50 -50
  37. package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +51 -51
  38. package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +50 -0
  39. package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +50 -0
  40. package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +51 -51
  41. package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +51 -51
  42. package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +51 -51
  43. package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +51 -51
  44. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +55 -0
  45. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +51 -51
  46. package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +51 -51
  47. package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +50 -0
  48. package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +51 -51
  49. package/.docs/organized/changelogs/create-mastra.md +18 -18
  50. package/.docs/organized/changelogs/mastra.md +70 -70
  51. package/.docs/organized/code-examples/agent-network.md +53 -0
  52. package/.docs/organized/code-examples/crypto-chatbot.md +3 -3
  53. package/.docs/raw/agents/{02-adding-tools.mdx → adding-tools.mdx} +1 -1
  54. package/.docs/raw/agents/{03-adding-voice.mdx → adding-voice.mdx} +3 -3
  55. package/.docs/raw/agents/{00-overview.mdx → overview.mdx} +4 -4
  56. package/.docs/raw/community/discord.mdx +12 -0
  57. package/.docs/raw/deployment/server.mdx +66 -11
  58. package/.docs/raw/evals/{02-custom-eval.mdx → custom-eval.mdx} +1 -1
  59. package/.docs/raw/evals/{00-overview.mdx → overview.mdx} +3 -3
  60. package/.docs/raw/evals/{01-textual-evals.mdx → textual-evals.mdx} +1 -1
  61. package/.docs/raw/frameworks/{02-ai-sdk.mdx → ai-sdk.mdx} +3 -3
  62. package/.docs/raw/getting-started/installation.mdx +1 -1
  63. package/.docs/raw/index.mdx +4 -4
  64. package/.docs/raw/integrations/index.mdx +1 -1
  65. package/.docs/raw/local-dev/mastra-dev.mdx +1 -1
  66. package/.docs/raw/observability/nextjs-tracing.mdx +43 -37
  67. package/.docs/raw/observability/tracing.mdx +7 -2
  68. package/.docs/raw/rag/chunking-and-embedding.mdx +32 -4
  69. package/.docs/raw/rag/vector-databases.mdx +2 -0
  70. package/.docs/raw/reference/client-js/workflows.mdx +4 -6
  71. package/.docs/raw/reference/memory/Memory.mdx +1 -1
  72. package/.docs/raw/reference/memory/memory-processors.mdx +229 -0
  73. package/.docs/raw/reference/rag/astra.mdx +1 -1
  74. package/.docs/raw/reference/rag/chroma.mdx +1 -1
  75. package/.docs/raw/reference/rag/chunk.mdx +2 -4
  76. package/.docs/raw/reference/rag/document.mdx +2 -4
  77. package/.docs/raw/reference/rag/extract-params.mdx +192 -40
  78. package/.docs/raw/reference/rag/libsql.mdx +1 -1
  79. package/.docs/raw/reference/rag/pg.mdx +1 -1
  80. package/.docs/raw/reference/rag/pinecone.mdx +36 -4
  81. package/.docs/raw/reference/rag/qdrant.mdx +1 -1
  82. package/.docs/raw/reference/rag/turbopuffer.mdx +1 -1
  83. package/.docs/raw/reference/rag/upstash.mdx +1 -1
  84. package/.docs/raw/reference/rag/vectorize.mdx +1 -1
  85. package/.docs/raw/reference/storage/postgresql.mdx +1 -1
  86. package/.docs/raw/reference/workflows/createRun.mdx +1 -1
  87. package/.docs/raw/reference/workflows/resumeWithEvent.mdx +23 -24
  88. package/.docs/raw/reference/workflows/snapshots.mdx +36 -33
  89. package/.docs/raw/reference/workflows/suspend.mdx +0 -10
  90. package/.docs/raw/reference/workflows/watch.mdx +22 -22
  91. package/.docs/raw/storage/overview.mdx +97 -59
  92. package/.docs/raw/voice/overview.mdx +1 -1
  93. package/.docs/raw/voice/speech-to-text.mdx +1 -1
  94. package/.docs/raw/voice/text-to-speech.mdx +1 -1
  95. package/.docs/raw/voice/voice-to-voice.mdx +1 -1
  96. package/.docs/raw/workflows/error-handling.mdx +3 -3
  97. package/.docs/raw/workflows/nested-workflows.mdx +352 -0
  98. package/.docs/raw/workflows/{00-overview.mdx → overview.mdx} +1 -1
  99. package/.docs/raw/workflows/suspend-and-resume.mdx +73 -70
  100. package/package.json +4 -4
  101. package/.docs/raw/agents/02b-discord-mcp-bot.mdx +0 -87
  102. /package/.docs/raw/agents/{01-agent-memory.mdx → agent-memory.mdx} +0 -0
  103. /package/.docs/raw/agents/{02a-mcp-guide.mdx → mcp-guide.mdx} +0 -0
  104. /package/.docs/raw/{faq/index.mdx → community/licensing.mdx} +0 -0
  105. /package/.docs/raw/evals/{03-running-in-ci.mdx → running-in-ci.mdx} +0 -0
  106. /package/.docs/raw/frameworks/{01-next-js.mdx → next-js.mdx} +0 -0
  107. /package/.docs/raw/guides/{03-recruiter.mdx → ai-recruiter.mdx} +0 -0
  108. /package/.docs/raw/guides/{01-chef-michel.mdx → chef-michel.mdx} +0 -0
  109. /package/.docs/raw/guides/{04-research-assistant.mdx → research-assistant.mdx} +0 -0
  110. /package/.docs/raw/guides/{02-stock-agent.mdx → stock-agent.mdx} +0 -0
@@ -46,7 +46,7 @@ It provides real-time vector search, with features like hybrid search, metadata
46
46
  type: "'cosine' | 'euclidean' | 'dotproduct'",
47
47
  isOptional: true,
48
48
  defaultValue: "cosine",
49
- description: "Distance metric for similarity search",
49
+ description: "Distance metric for similarity search. Use 'dotproduct' if you plan to use hybrid search.",
50
50
  },
51
51
  ]}
52
52
  />
@@ -63,7 +63,13 @@ It provides real-time vector search, with features like hybrid search, metadata
63
63
  {
64
64
  name: "vectors",
65
65
  type: "number[][]",
66
- description: "Array of embedding vectors",
66
+ description: "Array of dense embedding vectors",
67
+ },
68
+ {
69
+ name: "sparseVectors",
70
+ type: "{ indices: number[], values: number[] }[]",
71
+ isOptional: true,
72
+ description: "Array of sparse vectors for hybrid search. Each vector must have matching indices and values arrays.",
67
73
  },
68
74
  {
69
75
  name: "metadata",
@@ -77,6 +83,12 @@ It provides real-time vector search, with features like hybrid search, metadata
77
83
  isOptional: true,
78
84
  description: "Optional vector IDs (auto-generated if not provided)",
79
85
  },
86
+ {
87
+ name: "namespace",
88
+ type: "string",
89
+ isOptional: true,
90
+ description: "Optional namespace to store vectors in. Vectors in different namespaces are isolated from each other.",
91
+ },
80
92
  ]}
81
93
  />
82
94
 
@@ -92,7 +104,13 @@ It provides real-time vector search, with features like hybrid search, metadata
92
104
  {
93
105
  name: "vector",
94
106
  type: "number[]",
95
- description: "Query vector to find similar vectors",
107
+ description: "Dense query vector to find similar vectors",
108
+ },
109
+ {
110
+ name: "sparseVector",
111
+ type: "{ indices: number[], values: number[] }",
112
+ isOptional: true,
113
+ description: "Optional sparse vector for hybrid search. Must have matching indices and values arrays.",
96
114
  },
97
115
  {
98
116
  name: "topK",
@@ -114,6 +132,12 @@ It provides real-time vector search, with features like hybrid search, metadata
114
132
  defaultValue: "false",
115
133
  description: "Whether to include the vector in the result",
116
134
  },
135
+ {
136
+ name: "namespace",
137
+ type: "string",
138
+ isOptional: true,
139
+ description: "Optional namespace to query vectors from. Only returns results from the specified namespace.",
140
+ },
117
141
  ]}
118
142
  />
119
143
 
@@ -244,6 +268,14 @@ Required environment variables:
244
268
  - `PINECONE_API_KEY`: Your Pinecone API key
245
269
  - `PINECONE_ENVIRONMENT`: Pinecone environment (e.g., 'us-west1-gcp')
246
270
 
247
- ### Related
271
+ ## Hybrid Search
272
+
273
+ Pinecone supports hybrid search by combining dense and sparse vectors. To use hybrid search:
274
+
275
+ 1. Create an index with `metric: 'dotproduct'`
276
+ 2. During upsert, provide sparse vectors using the `sparseVectors` parameter
277
+ 3. During query, provide a sparse vector using the `sparseVector` parameter
278
+
279
+ ## Related
248
280
 
249
281
  - [Metadata Filters](./metadata-filters)
@@ -231,6 +231,6 @@ try {
231
231
  }
232
232
  ```
233
233
 
234
- ### Related
234
+ ## Related
235
235
 
236
236
  - [Metadata Filters](./metadata-filters)
@@ -244,6 +244,6 @@ try {
244
244
  }
245
245
  ```
246
246
 
247
- ### Related
247
+ ## Related
248
248
 
249
249
  - [Metadata Filters](./metadata-filters)
@@ -242,6 +242,6 @@ Required environment variables:
242
242
  - `UPSTASH_VECTOR_URL`: Your Upstash Vector database URL
243
243
  - `UPSTASH_VECTOR_TOKEN`: Your Upstash Vector API token
244
244
 
245
- ### Related
245
+ ## Related
246
246
 
247
247
  - [Metadata Filters](./metadata-filters)
@@ -293,6 +293,6 @@ Required environment variables:
293
293
  - `CLOUDFLARE_ACCOUNT_ID`: Your Cloudflare account ID
294
294
  - `CLOUDFLARE_API_TOKEN`: Your Cloudflare API token with Vectorize permissions
295
295
 
296
- ### Related
296
+ ## Related
297
297
 
298
298
  - [Metadata Filters](./metadata-filters)
@@ -18,7 +18,7 @@ npm install @mastra/pg
18
18
  ```typescript copy showLineNumbers
19
19
  import { PostgresStore } from "@mastra/pg";
20
20
 
21
- const storage = new PostgresStorage({
21
+ const storage = new PostgresStore({
22
22
  connectionString: process.env.DATABASE_URL,
23
23
  });
24
24
  ```
@@ -33,7 +33,7 @@ const result = await start();
33
33
  },
34
34
  {
35
35
  name: "watch",
36
- type: "(callback: (record: WorkflowRunState) => void) => () => void",
36
+ type: "(callback: (record: WorkflowResult) => void) => () => void",
37
37
  description: "Function that accepts a callback function that will be called with each transition of the workflow run",
38
38
  },
39
39
  {
@@ -18,10 +18,10 @@ await run.resumeWithEvent(eventName: string, data: any): Promise<WorkflowRunResu
18
18
 
19
19
  ## Parameters
20
20
 
21
- | Parameter | Type | Description |
22
- |-----------|------|-------------|
21
+ | Parameter | Type | Description |
22
+ | --------- | ------ | ------------------------------------------------------------------------------------------------------- |
23
23
  | eventName | string | The name of the event to trigger. Must match an event defined in the workflow's `events` configuration. |
24
- | data | any | The event data to provide. Must conform to the schema defined for that event. |
24
+ | data | any | The event data to provide. Must conform to the schema defined for that event. |
25
25
 
26
26
  ## Return Value
27
27
 
@@ -58,17 +58,17 @@ This method is part of Mastra's event-driven workflow capabilities, allowing you
58
58
 
59
59
  ```typescript
60
60
  // Define and start a workflow
61
- const workflow = mastra.getWorkflow('approval-workflow');
61
+ const workflow = mastra.getWorkflow("approval-workflow");
62
62
  const run = workflow.createRun();
63
63
 
64
64
  // Start the workflow
65
- await run.start({ triggerData: { requestId: 'req-123' } });
65
+ await run.start({ triggerData: { requestId: "req-123" } });
66
66
 
67
67
  // Later, when the approval event occurs:
68
- const result = await run.resumeWithEvent('approval', {
68
+ const result = await run.resumeWithEvent("approval", {
69
69
  approved: true,
70
- approverName: 'John Doe',
71
- comment: 'Looks good to me!'
70
+ approverName: "John Doe",
71
+ comment: "Looks good to me!",
72
72
  });
73
73
 
74
74
  console.log(result.results);
@@ -78,15 +78,15 @@ console.log(result.results);
78
78
 
79
79
  ```typescript
80
80
  try {
81
- const result = await run.resumeWithEvent('paymentReceived', {
82
- amount: 100.50,
83
- transactionId: 'tx-456',
84
- paymentMethod: 'credit-card',
81
+ const result = await run.resumeWithEvent("paymentReceived", {
82
+ amount: 100.5,
83
+ transactionId: "tx-456",
84
+ paymentMethod: "credit-card",
85
85
  });
86
86
 
87
- console.log('Workflow resumed successfully:', result.results);
87
+ console.log("Workflow resumed successfully:", result.results);
88
88
  } catch (error) {
89
- console.error('Failed to resume workflow with event:', error);
89
+ console.error("Failed to resume workflow with event:", error);
90
90
  // Handle error - could be invalid event data, workflow not suspended, etc.
91
91
  }
92
92
  ```
@@ -98,31 +98,30 @@ try {
98
98
  const { start, watch, resumeWithEvent } = workflow.createRun();
99
99
 
100
100
  // Watch for suspended event steps
101
- watch(async ({ context, activePaths }) => {
101
+ watch(async ({ activePaths }) => {
102
+ const isApprovalEventSuspended =
103
+ activePaths.get("__approval_event")?.status === "suspended";
102
104
  // Check if suspended at the approval event step
103
- if (activePaths.some(path =>
104
- path.stepId === '__approval_event' &&
105
- path.status === 'suspended'
106
- )) {
107
- console.log('Workflow waiting for approval');
105
+ if (isApprovalEventSuspended) {
106
+ console.log("Workflow waiting for approval");
108
107
 
109
108
  // In a real scenario, you would wait for the actual event
110
109
  // Here we're simulating with a timeout
111
110
  setTimeout(async () => {
112
111
  try {
113
- await resumeWithEvent('approval', {
112
+ await resumeWithEvent("approval", {
114
113
  approved: true,
115
- approverName: 'Auto Approver',
114
+ approverName: "Auto Approver",
116
115
  });
117
116
  } catch (error) {
118
- console.error('Failed to auto-resume workflow:', error);
117
+ console.error("Failed to auto-resume workflow:", error);
119
118
  }
120
119
  }, 5000); // Wait 5 seconds before auto-approving
121
120
  }
122
121
  });
123
122
 
124
123
  // Start the workflow
125
- await start({ triggerData: { requestId: 'auto-123' } });
124
+ await start({ triggerData: { requestId: "auto-123" } });
126
125
  ```
127
126
 
128
127
  ## Related
@@ -36,31 +36,37 @@ A Mastra workflow snapshot consists of several key components:
36
36
  ```typescript
37
37
  export interface WorkflowRunState {
38
38
  // Core state info
39
- value: Record<string, string>; // Current state machine value
40
- context: { // Workflow context
41
- steps: Record<string, { // Step execution results
42
- status: 'success' | 'failed' | 'suspended' | 'waiting' | 'skipped';
43
- payload?: any; // Step-specific data
44
- error?: string; // Error info if failed
45
- }>;
39
+ value: Record<string, string>; // Current state machine value
40
+ context: {
41
+ // Workflow context
42
+ steps: Record<
43
+ string,
44
+ {
45
+ // Step execution results
46
+ status: "success" | "failed" | "suspended" | "waiting" | "skipped";
47
+ payload?: any; // Step-specific data
48
+ error?: string; // Error info if failed
49
+ }
50
+ >;
46
51
  triggerData: Record<string, any>; // Initial trigger data
47
52
  attempts: Record<string, number>; // Remaining retry attempts
48
- inputData: Record<string, any>; // Initial input data
53
+ inputData: Record<string, any>; // Initial input data
49
54
  };
50
55
 
51
- activePaths: Array<{ // Currently active execution paths
56
+ activePaths: Array<{
57
+ // Currently active execution paths
52
58
  stepPath: string[];
53
59
  stepId: string;
54
60
  status: string;
55
61
  }>;
56
62
 
57
63
  // Metadata
58
- runId: string; // Unique run identifier
59
- timestamp: number; // Time snapshot was created
64
+ runId: string; // Unique run identifier
65
+ timestamp: number; // Time snapshot was created
60
66
 
61
67
  // For nested workflows and suspended steps
62
- childStates?: Record<string, WorkflowRunState>; // Child workflow states
63
- suspendedSteps?: Record<string, string>; // Mapping of suspended steps
68
+ childStates?: Record<string, WorkflowRunState>; // Child workflow states
69
+ suspendedSteps?: Record<string, string>; // Mapping of suspended steps
64
70
  }
65
71
  ```
66
72
 
@@ -82,7 +88,6 @@ When a workflow is suspended, Mastra automatically persists the workflow snapsho
82
88
  4. The snapshot is serialized and stored in the configured database in the `workflow_snapshots` table
83
89
  5. The storage record includes the workflow name, run ID, and the serialized snapshot
84
90
 
85
-
86
91
  ### Retrieving Snapshots
87
92
 
88
93
  When a workflow is resumed, Mastra retrieves the persisted snapshot with these steps:
@@ -105,8 +110,8 @@ This means that storage is shared across all workflows registered with the same
105
110
  The default storage option is LibSQL, a SQLite-compatible database:
106
111
 
107
112
  ```typescript
108
- import { Mastra } from '@mastra/core/mastra';
109
- import { DefaultStorage } from '@mastra/core/storage/libsql';
113
+ import { Mastra } from "@mastra/core/mastra";
114
+ import { DefaultStorage } from "@mastra/core/storage/libsql";
110
115
 
111
116
  const mastra = new Mastra({
112
117
  storage: new DefaultStorage({
@@ -115,12 +120,12 @@ const mastra = new Mastra({
115
120
  // For production:
116
121
  // url: process.env.DATABASE_URL,
117
122
  // authToken: process.env.DATABASE_AUTH_TOKEN,
118
- }
123
+ },
119
124
  }),
120
125
  workflows: {
121
126
  weatherWorkflow,
122
127
  travelWorkflow,
123
- }
128
+ },
124
129
  });
125
130
  ```
126
131
 
@@ -129,7 +134,7 @@ const mastra = new Mastra({
129
134
  For serverless environments:
130
135
 
131
136
  ```typescript
132
- import { Mastra } from '@mastra/core/mastra';
137
+ import { Mastra } from "@mastra/core/mastra";
133
138
  import { UpstashStore } from "@mastra/upstash";
134
139
 
135
140
  const mastra = new Mastra({
@@ -140,7 +145,7 @@ const mastra = new Mastra({
140
145
  workflows: {
141
146
  weatherWorkflow,
142
147
  travelWorkflow,
143
- }
148
+ },
144
149
  });
145
150
  ```
146
151
 
@@ -168,7 +173,7 @@ await suspend({
168
173
  requiredApprovers: ["manager", "finance"],
169
174
  requestedBy: currentUser,
170
175
  urgency: "high",
171
- expires: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000)
176
+ expires: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000),
172
177
  });
173
178
  ```
174
179
 
@@ -179,18 +184,16 @@ This metadata is stored with the snapshot and available when resuming.
179
184
  You can implement conditional logic based on the suspend payload when resuming:
180
185
 
181
186
  ```typescript
182
- run.watch(async ({ context, activePaths }) => {
183
- for (const path of activePaths) {
184
- const approvalStep = context.steps?.approval;
185
- if (approvalStep?.status === 'suspended') {
186
- const payload = approvalStep.suspendPayload;
187
-
188
- if (payload.urgency === "high" && currentUser.role === "manager") {
189
- await resume({
190
- stepId: 'approval',
191
- context: { approved: true, approver: currentUser.id },
192
- });
193
- }
187
+ run.watch(async ({ activePaths }) => {
188
+ const isApprovalStepSuspended =
189
+ activePaths.get("approval")?.status === "suspended";
190
+ if (isApprovalStepSuspended) {
191
+ const payload = activePaths.get("approval")?.suspendPayload;
192
+ if (payload.urgency === "high" && currentUser.role === "manager") {
193
+ await resume({
194
+ stepId: "approval",
195
+ context: { approved: true, approver: currentUser.id },
196
+ });
194
197
  }
195
198
  }
196
199
  });
@@ -63,16 +63,6 @@ const reviewStep = new Step({
63
63
  });
64
64
  ```
65
65
 
66
- Monitor suspended state:
67
-
68
- ```typescript
69
- run.watch((state) => {
70
- if (state.status === "SUSPENDED") {
71
- notifyReviewers(state.metadata);
72
- }
73
- });
74
- ```
75
-
76
66
  ### Related
77
67
 
78
68
  - [Suspend & Resume Workflows](../../workflows/suspend-and-resume.mdx)
@@ -19,9 +19,9 @@ const workflow = new Workflow({
19
19
  const run = workflow.createRun();
20
20
 
21
21
  // Subscribe to state changes
22
- const unsubscribe = run.watch((state) => {
23
- console.log('Current step:', state.currentStep);
24
- console.log('Step outputs:', state.stepOutputs);
22
+ const unsubscribe = run.watch(({results, activePaths}) => {
23
+ console.log('Results:', results);
24
+ console.log('Active paths:', activePaths);
25
25
  });
26
26
 
27
27
  // Run the workflow
@@ -51,28 +51,28 @@ unsubscribe();
51
51
  <PropertiesTable
52
52
  content={[
53
53
  {
54
- name: "currentStep",
55
- type: "string",
56
- description: "ID of the currently executing step",
54
+ name: "results",
55
+ type: "Record<string, any>",
56
+ description: "Outputs from completed workflow steps",
57
57
  isOptional: false
58
58
  },
59
59
  {
60
- name: "stepOutputs",
61
- type: "Record<string, any>",
62
- description: "Outputs from completed workflow steps",
60
+ name: "activePaths",
61
+ type: "Map<string, { status: string; suspendPayload?: any; stepPath: string[] }>",
62
+ description: "Current status of each step",
63
63
  isOptional: false
64
64
  },
65
65
  {
66
- name: "status",
67
- type: "'running' | 'completed' | 'failed'",
68
- description: "Current status of the workflow",
66
+ name: "runId",
67
+ type: "string",
68
+ description: "ID of the workflow run",
69
69
  isOptional: false
70
70
  },
71
71
  {
72
- name: "error",
73
- type: "Error | null",
74
- description: "Error object if workflow failed",
75
- isOptional: true
72
+ name: "timestamp",
73
+ type: "number",
74
+ description: "Timestamp of the workflow run",
75
+ isOptional: false
76
76
  }
77
77
  ]}
78
78
  />
@@ -94,9 +94,9 @@ unsubscribe();
94
94
  Monitor specific step completion:
95
95
 
96
96
  ```typescript
97
- run.watch((state) => {
98
- if (state.currentStep === 'processDocument') {
99
- console.log('Document processing output:', state.stepOutputs.processDocument);
97
+ run.watch(({results, activePaths}) => {
98
+ if (activePaths.get('processDocument')?.status === 'completed') {
99
+ console.log('Document processing output:', results['processDocument'].output);
100
100
  }
101
101
  });
102
102
  ```
@@ -104,9 +104,9 @@ run.watch((state) => {
104
104
  Error handling:
105
105
 
106
106
  ```typescript
107
- run.watch((state) => {
108
- if (state.status === 'failed') {
109
- console.error('Workflow failed:', state.error);
107
+ run.watch(({results, activePaths}) => {
108
+ if (activePaths.get('processDocument')?.status === 'failed') {
109
+ console.error('Document processing failed:', results['processDocument'].error);
110
110
  // Implement error recovery logic
111
111
  }
112
112
  });