@mastra/server 1.6.0 → 1.7.0

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 (48) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/{chunk-P4O7OBGH.cjs → chunk-3BKGGOC6.cjs} +3 -3
  3. package/dist/{chunk-P4O7OBGH.cjs.map → chunk-3BKGGOC6.cjs.map} +1 -1
  4. package/dist/{chunk-CMYJ32N3.js → chunk-EFKPTKKF.js} +51 -15
  5. package/dist/chunk-EFKPTKKF.js.map +1 -0
  6. package/dist/{chunk-NC6UUX6D.js → chunk-KTGIAURI.js} +3 -2
  7. package/dist/chunk-KTGIAURI.js.map +1 -0
  8. package/dist/{chunk-NGFAF6WW.cjs → chunk-MJLQLQ6K.cjs} +51 -15
  9. package/dist/chunk-MJLQLQ6K.cjs.map +1 -0
  10. package/dist/{chunk-VHBLYGH7.js → chunk-PGB5HYV7.js} +3 -3
  11. package/dist/{chunk-VHBLYGH7.js.map → chunk-PGB5HYV7.js.map} +1 -1
  12. package/dist/{chunk-GPRCK7GP.cjs → chunk-ZE4IJKQD.cjs} +3 -2
  13. package/dist/chunk-ZE4IJKQD.cjs.map +1 -0
  14. package/dist/{observational-memory-ZNTAIUGT-565A3END.cjs → observational-memory-AJWSMZVP-HI6EWRCH.cjs} +29 -12
  15. package/dist/observational-memory-AJWSMZVP-HI6EWRCH.cjs.map +1 -0
  16. package/dist/{observational-memory-ZNTAIUGT-VIXA4SKE.js → observational-memory-AJWSMZVP-J3OYOGXO.js} +29 -12
  17. package/dist/observational-memory-AJWSMZVP-J3OYOGXO.js.map +1 -0
  18. package/dist/server/handlers/agent-builder.cjs +16 -16
  19. package/dist/server/handlers/agent-builder.js +1 -1
  20. package/dist/server/handlers/prompt-block-versions.cjs +8 -8
  21. package/dist/server/handlers/prompt-block-versions.d.ts +6 -0
  22. package/dist/server/handlers/prompt-block-versions.d.ts.map +1 -1
  23. package/dist/server/handlers/prompt-block-versions.js +1 -1
  24. package/dist/server/handlers/stored-prompt-blocks.cjs +6 -6
  25. package/dist/server/handlers/stored-prompt-blocks.d.ts +16 -4
  26. package/dist/server/handlers/stored-prompt-blocks.d.ts.map +1 -1
  27. package/dist/server/handlers/stored-prompt-blocks.js +1 -1
  28. package/dist/server/handlers.cjs +2 -2
  29. package/dist/server/handlers.js +1 -1
  30. package/dist/server/schemas/prompt-block-versions.d.ts +27 -0
  31. package/dist/server/schemas/prompt-block-versions.d.ts.map +1 -1
  32. package/dist/server/schemas/stored-prompt-blocks.d.ts +44 -4
  33. package/dist/server/schemas/stored-prompt-blocks.d.ts.map +1 -1
  34. package/dist/server/server-adapter/index.cjs +30 -30
  35. package/dist/server/server-adapter/index.js +3 -3
  36. package/package.json +6 -6
  37. package/dist/chunk-CMYJ32N3.js.map +0 -1
  38. package/dist/chunk-GPRCK7GP.cjs.map +0 -1
  39. package/dist/chunk-NC6UUX6D.js.map +0 -1
  40. package/dist/chunk-NGFAF6WW.cjs.map +0 -1
  41. package/dist/docs/SKILL.md +0 -28
  42. package/dist/docs/assets/SOURCE_MAP.json +0 -6
  43. package/dist/docs/references/docs-server-custom-adapters.md +0 -374
  44. package/dist/docs/references/reference-server-create-route.md +0 -260
  45. package/dist/docs/references/reference-server-mastra-server.md +0 -298
  46. package/dist/docs/references/reference-server-routes.md +0 -306
  47. package/dist/observational-memory-ZNTAIUGT-565A3END.cjs.map +0 -1
  48. package/dist/observational-memory-ZNTAIUGT-VIXA4SKE.js.map +0 -1
@@ -1,306 +0,0 @@
1
- # Server Routes
2
-
3
- Server adapters register these routes when you call `server.init()`. All routes are prefixed with the `prefix` option if configured.
4
-
5
- ## Agents
6
-
7
- | Method | Path | Description |
8
- | ------ | -------------------------------------------- | ----------------------- |
9
- | `GET` | `/api/agents` | List all agents |
10
- | `GET` | `/api/agents/:agentId` | Get agent by ID |
11
- | `POST` | `/api/agents/:agentId/generate` | Generate agent response |
12
- | `POST` | `/api/agents/:agentId/stream` | Stream agent response |
13
- | `GET` | `/api/agents/:agentId/tools` | List agent tools |
14
- | `POST` | `/api/agents/:agentId/tools/:toolId/execute` | Execute agent tool |
15
-
16
- ### Generate request body
17
-
18
- ```typescript
19
- {
20
- messages: CoreMessage[] | string; // Required
21
- instructions?: string; // System instructions
22
- system?: string; // System prompt
23
- context?: CoreMessage[]; // Additional context
24
- memory?: { key: string } | boolean; // Memory config
25
- resourceId?: string; // Resource identifier
26
- threadId?: string; // Thread identifier
27
- runId?: string; // Run identifier
28
- maxSteps?: number; // Max tool steps
29
- activeTools?: string[]; // Tools to enable
30
- toolChoice?: ToolChoice; // Tool selection mode
31
- requestContext?: Record<string, unknown>; // Request context
32
- output?: ZodSchema; // Structured output schema
33
- }
34
- ```
35
-
36
- ### Generate response
37
-
38
- ```typescript
39
- {
40
- text: string;
41
- toolCalls?: ToolCall[];
42
- finishReason: string;
43
- usage?: {
44
- promptTokens: number;
45
- completionTokens: number;
46
- };
47
- }
48
- ```
49
-
50
- ## Workflows
51
-
52
- | Method | Path | Description |
53
- | ------ | ----------------------------------------- | ------------------------------- |
54
- | `GET` | `/api/workflows` | List all workflows |
55
- | `GET` | `/api/workflows/:workflowId` | Get workflow by ID |
56
- | `POST` | `/api/workflows/:workflowId/create-run` | Create a new workflow run |
57
- | `POST` | `/api/workflows/:workflowId/start-async` | Start workflow and await result |
58
- | `POST` | `/api/workflows/:workflowId/stream` | Stream workflow execution |
59
- | `POST` | `/api/workflows/:workflowId/resume` | Resume suspended workflow |
60
- | `POST` | `/api/workflows/:workflowId/resume-async` | Resume asynchronously |
61
- | `GET` | `/api/workflows/:workflowId/runs` | List workflow runs |
62
- | `GET` | `/api/workflows/:workflowId/runs/:runId` | Get specific run |
63
-
64
- ### Create run request body
65
-
66
- ```typescript
67
- {
68
- resourceId?: string; // Associate run with a resource (e.g., user ID)
69
- disableScorers?: boolean; // Disable scorers for this run
70
- }
71
- ```
72
-
73
- ### Start-async request body
74
-
75
- ```typescript
76
- {
77
- resourceId?: string; // Associate run with a resource (e.g., user ID)
78
- inputData?: unknown;
79
- initialState?: unknown;
80
- requestContext?: Record<string, unknown>;
81
- tracingOptions?: {
82
- spanName?: string;
83
- attributes?: Record<string, unknown>;
84
- };
85
- }
86
- ```
87
-
88
- ### Stream workflow request body
89
-
90
- ```typescript
91
- {
92
- resourceId?: string; // Associate run with a resource (e.g., user ID)
93
- inputData?: unknown;
94
- initialState?: unknown;
95
- requestContext?: Record<string, unknown>;
96
- closeOnSuspend?: boolean;
97
- }
98
- ```
99
-
100
- ### Resume request body
101
-
102
- ```typescript
103
- {
104
- step?: string | string[];
105
- resumeData?: unknown;
106
- requestContext?: Record<string, unknown>;
107
- }
108
- ```
109
-
110
- ## Tools
111
-
112
- | Method | Path | Description |
113
- | ------ | ---------------------------- | -------------- |
114
- | `GET` | `/api/tools` | List all tools |
115
- | `GET` | `/api/tools/:toolId` | Get tool by ID |
116
- | `POST` | `/api/tools/:toolId/execute` | Execute tool |
117
-
118
- ### Execute tool request body
119
-
120
- ```typescript
121
- {
122
- data: unknown; // Tool input data
123
- requestContext?: Record<string, unknown>;
124
- }
125
- ```
126
-
127
- ## Memory
128
-
129
- | Method | Path | Description |
130
- | -------- | ---------------------------------------- | ------------------- |
131
- | `GET` | `/api/memory/threads` | List threads |
132
- | `GET` | `/api/memory/threads/:threadId` | Get thread |
133
- | `POST` | `/api/memory/threads` | Create thread |
134
- | `DELETE` | `/api/memory/threads/:threadId` | Delete thread |
135
- | `POST` | `/api/memory/threads/:threadId/clone` | Clone thread |
136
- | `GET` | `/api/memory/threads/:threadId/messages` | Get thread messages |
137
- | `POST` | `/api/memory/threads/:threadId/messages` | Add message |
138
-
139
- ### Create thread request body
140
-
141
- ```typescript
142
- {
143
- resourceId: string;
144
- title?: string;
145
- metadata?: Record<string, unknown>;
146
- }
147
- ```
148
-
149
- ### Clone thread request body
150
-
151
- ```typescript
152
- {
153
- newThreadId?: string; // Custom ID for cloned thread
154
- resourceId?: string; // Override resource ID
155
- title?: string; // Custom title for clone
156
- metadata?: Record<string, unknown>; // Additional metadata
157
- options?: {
158
- messageLimit?: number; // Max messages to clone
159
- messageFilter?: {
160
- startDate?: Date; // Clone messages after this date
161
- endDate?: Date; // Clone messages before this date
162
- messageIds?: string[]; // Clone specific messages
163
- };
164
- };
165
- }
166
- ```
167
-
168
- ### Clone thread response
169
-
170
- ```typescript
171
- {
172
- thread: {
173
- id: string;
174
- resourceId: string;
175
- title: string;
176
- createdAt: Date;
177
- updatedAt: Date;
178
- metadata: {
179
- clone: {
180
- sourceThreadId: string;
181
- clonedAt: Date;
182
- lastMessageId?: string;
183
- };
184
- // ... other metadata
185
- };
186
- };
187
- clonedMessages: MastraDBMessage[];
188
- }
189
- ```
190
-
191
- ## Vectors
192
-
193
- | Method | Path | Description |
194
- | ------ | --------------------------------- | -------------- |
195
- | `POST` | `/api/vectors/:vectorName/upsert` | Upsert vectors |
196
- | `POST` | `/api/vectors/:vectorName/query` | Query vectors |
197
- | `POST` | `/api/vectors/:vectorName/delete` | Delete vectors |
198
-
199
- ### Upsert request body
200
-
201
- ```typescript
202
- {
203
- vectors: Array<{
204
- id: string;
205
- values: number[];
206
- metadata?: Record<string, unknown>;
207
- }>;
208
- }
209
- ```
210
-
211
- ### Query request body
212
-
213
- ```typescript
214
- {
215
- vector: number[];
216
- topK?: number;
217
- filter?: Record<string, unknown>;
218
- includeMetadata?: boolean;
219
- }
220
- ```
221
-
222
- ## MCP
223
-
224
- | Method | Path | Description |
225
- | ------ | ---------------------------------- | ------------------ |
226
- | `GET` | `/api/mcp/servers` | List MCP servers |
227
- | `GET` | `/api/mcp/servers/:serverId/tools` | List server tools |
228
- | `POST` | `/api/mcp/:serverId` | MCP HTTP transport |
229
- | `GET` | `/api/mcp/:serverId/sse` | MCP SSE transport |
230
-
231
- ## Logs
232
-
233
- | Method | Path | Description |
234
- | ------ | ------------------ | ------------------ |
235
- | `GET` | `/api/logs` | List logs |
236
- | `GET` | `/api/logs/:runId` | Get logs by run ID |
237
-
238
- ### Query parameters
239
-
240
- ```typescript
241
- {
242
- page?: number;
243
- perPage?: number;
244
- transportId?: string;
245
- }
246
- ```
247
-
248
- ## Telemetry
249
-
250
- | Method | Path | Description |
251
- | ------ | -------------------------------------- | --------------- |
252
- | `GET` | `/api/telemetry/traces` | List traces |
253
- | `GET` | `/api/telemetry/traces/:traceId` | Get trace |
254
- | `GET` | `/api/telemetry/traces/:traceId/spans` | Get trace spans |
255
-
256
- ## Common query parameters
257
-
258
- ### Pagination
259
-
260
- Most list endpoints support:
261
-
262
- ```typescript
263
- {
264
- page?: number; // Page number (0-indexed)
265
- perPage?: number; // Items per page (default: 10)
266
- }
267
- ```
268
-
269
- ### Filtering
270
-
271
- Workflow runs support:
272
-
273
- ```typescript
274
- {
275
- fromDate?: string; // ISO date string
276
- toDate?: string; // ISO date string
277
- status?: string; // Run status filter
278
- resourceId?: string; // Filter by resource
279
- }
280
- ```
281
-
282
- ## Error responses
283
-
284
- All routes return errors in this format:
285
-
286
- ```typescript
287
- {
288
- error: string; // Error message
289
- details?: unknown; // Additional details
290
- }
291
- ```
292
-
293
- Common status codes:
294
-
295
- | Code | Meaning |
296
- | ---- | ------------------------------------ |
297
- | 400 | Bad Request - Invalid parameters |
298
- | 401 | Unauthorized - Missing/invalid auth |
299
- | 403 | Forbidden - Insufficient permissions |
300
- | 404 | Not Found - Resource doesn't exist |
301
- | 500 | Internal Server Error |
302
-
303
- ## Related
304
-
305
- - [createRoute()](https://mastra.ai/reference/server/create-route) - Creating custom routes
306
- - [Server Adapters](https://mastra.ai/docs/server/server-adapters) - Using adapters