@mastra/server 1.32.0-alpha.3 → 1.32.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 (95) hide show
  1. package/CHANGELOG.md +101 -0
  2. package/dist/{chunk-LCAQQOLF.js → chunk-356JZOB2.js} +29 -4
  3. package/dist/chunk-356JZOB2.js.map +1 -0
  4. package/dist/{chunk-RP7OLAVZ.js → chunk-4HRTLLE6.js} +38 -22
  5. package/dist/chunk-4HRTLLE6.js.map +1 -0
  6. package/dist/{chunk-TEVHVRZI.js → chunk-4WWS6GKP.js} +3 -3
  7. package/dist/{chunk-TEVHVRZI.js.map → chunk-4WWS6GKP.js.map} +1 -1
  8. package/dist/{chunk-6XN2MNYW.cjs → chunk-6AYGQBID.cjs} +39 -21
  9. package/dist/chunk-6AYGQBID.cjs.map +1 -0
  10. package/dist/{chunk-KZ3ERBUT.cjs → chunk-BNR5CIPX.cjs} +32 -3
  11. package/dist/chunk-BNR5CIPX.cjs.map +1 -0
  12. package/dist/{chunk-ZATCZFSW.cjs → chunk-BOFX5I7S.cjs} +5 -5
  13. package/dist/{chunk-ZATCZFSW.cjs.map → chunk-BOFX5I7S.cjs.map} +1 -1
  14. package/dist/{chunk-5UK4WOHD.cjs → chunk-CQUVNOZ6.cjs} +2 -2
  15. package/dist/chunk-CQUVNOZ6.cjs.map +1 -0
  16. package/dist/{chunk-ETWIAKQ7.cjs → chunk-EYSAQHCP.cjs} +4 -4
  17. package/dist/{chunk-ETWIAKQ7.cjs.map → chunk-EYSAQHCP.cjs.map} +1 -1
  18. package/dist/{chunk-OTRCNZO4.js → chunk-FQ7YYW4Q.js} +2 -2
  19. package/dist/chunk-FQ7YYW4Q.js.map +1 -0
  20. package/dist/{chunk-COAE7JJY.js → chunk-IIM2YSQ4.js} +3 -3
  21. package/dist/{chunk-COAE7JJY.js.map → chunk-IIM2YSQ4.js.map} +1 -1
  22. package/dist/{chunk-S65F3MGF.js → chunk-M5I6LD6N.js} +3 -3
  23. package/dist/{chunk-S65F3MGF.js.map → chunk-M5I6LD6N.js.map} +1 -1
  24. package/dist/{chunk-GOFGQSF7.js → chunk-MOWSRYNJ.js} +65 -6
  25. package/dist/chunk-MOWSRYNJ.js.map +1 -0
  26. package/dist/{chunk-I7EPR6KM.js → chunk-PPD3LELX.js} +24 -6
  27. package/dist/chunk-PPD3LELX.js.map +1 -0
  28. package/dist/{chunk-MIK6X2SR.cjs → chunk-Q5EQ3HQY.cjs} +6 -6
  29. package/dist/{chunk-MIK6X2SR.cjs.map → chunk-Q5EQ3HQY.cjs.map} +1 -1
  30. package/dist/{chunk-QNTYBN3J.js → chunk-QMEGOGRN.js} +3 -3
  31. package/dist/{chunk-QNTYBN3J.js.map → chunk-QMEGOGRN.js.map} +1 -1
  32. package/dist/{chunk-N4IQKTJO.cjs → chunk-RGGZPBPR.cjs} +5 -5
  33. package/dist/{chunk-N4IQKTJO.cjs.map → chunk-RGGZPBPR.cjs.map} +1 -1
  34. package/dist/{chunk-LVJUHHZY.js → chunk-RQVAWLYS.js} +3 -3
  35. package/dist/{chunk-LVJUHHZY.js.map → chunk-RQVAWLYS.js.map} +1 -1
  36. package/dist/{chunk-GVLAYCDU.cjs → chunk-SZT2CUS6.cjs} +4 -4
  37. package/dist/{chunk-GVLAYCDU.cjs.map → chunk-SZT2CUS6.cjs.map} +1 -1
  38. package/dist/{chunk-ZSEAPJ73.cjs → chunk-W4VETOUS.cjs} +4 -4
  39. package/dist/{chunk-ZSEAPJ73.cjs.map → chunk-W4VETOUS.cjs.map} +1 -1
  40. package/dist/{chunk-NP5C5PIL.js → chunk-XDGV7WG3.js} +3 -3
  41. package/dist/{chunk-NP5C5PIL.js.map → chunk-XDGV7WG3.js.map} +1 -1
  42. package/dist/{chunk-IMPWOZUQ.cjs → chunk-YTCMTRWU.cjs} +81 -20
  43. package/dist/chunk-YTCMTRWU.cjs.map +1 -0
  44. package/dist/{chunk-CPZEA2XG.cjs → chunk-ZW7DMFEG.cjs} +38 -22
  45. package/dist/chunk-ZW7DMFEG.cjs.map +1 -0
  46. package/dist/docs/SKILL.md +1 -1
  47. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  48. package/dist/{observational-memory-UMDC4VC2-3I52URYY.cjs → observational-memory-FBBKXNO5-3V6BP5K3.cjs} +26 -26
  49. package/dist/{observational-memory-UMDC4VC2-3I52URYY.cjs.map → observational-memory-FBBKXNO5-3V6BP5K3.cjs.map} +1 -1
  50. package/dist/{observational-memory-UMDC4VC2-X5QMTUND.js → observational-memory-FBBKXNO5-I7J47ELO.js} +3 -3
  51. package/dist/{observational-memory-UMDC4VC2-X5QMTUND.js.map → observational-memory-FBBKXNO5-I7J47ELO.js.map} +1 -1
  52. package/dist/server/handlers/a2a.cjs +10 -10
  53. package/dist/server/handlers/a2a.js +1 -1
  54. package/dist/server/handlers/agent-builder.cjs +16 -16
  55. package/dist/server/handlers/agent-builder.js +1 -1
  56. package/dist/server/handlers/agents.cjs +38 -38
  57. package/dist/server/handlers/agents.d.ts.map +1 -1
  58. package/dist/server/handlers/agents.js +1 -1
  59. package/dist/server/handlers/conversations.cjs +5 -5
  60. package/dist/server/handlers/conversations.js +1 -1
  61. package/dist/server/handlers/mcp.cjs +17 -9
  62. package/dist/server/handlers/mcp.d.ts +46 -0
  63. package/dist/server/handlers/mcp.d.ts.map +1 -1
  64. package/dist/server/handlers/mcp.js +1 -1
  65. package/dist/server/handlers/responses.cjs +4 -4
  66. package/dist/server/handlers/responses.js +1 -1
  67. package/dist/server/handlers/scores.cjs +7 -7
  68. package/dist/server/handlers/scores.js +1 -1
  69. package/dist/server/handlers/tools.cjs +6 -6
  70. package/dist/server/handlers/tools.js +1 -1
  71. package/dist/server/handlers/voice.cjs +8 -8
  72. package/dist/server/handlers/voice.js +1 -1
  73. package/dist/server/handlers.cjs +18 -18
  74. package/dist/server/handlers.js +9 -9
  75. package/dist/server/schemas/index.cjs +15 -15
  76. package/dist/server/schemas/index.js +1 -1
  77. package/dist/server/schemas/mcp.d.ts +36 -0
  78. package/dist/server/schemas/mcp.d.ts.map +1 -1
  79. package/dist/server/server-adapter/index.cjs +88 -83
  80. package/dist/server/server-adapter/index.cjs.map +1 -1
  81. package/dist/server/server-adapter/index.js +14 -9
  82. package/dist/server/server-adapter/index.js.map +1 -1
  83. package/dist/server/server-adapter/routes/mcp.d.ts +44 -0
  84. package/dist/server/server-adapter/routes/mcp.d.ts.map +1 -1
  85. package/package.json +8 -8
  86. package/dist/chunk-5UK4WOHD.cjs.map +0 -1
  87. package/dist/chunk-6XN2MNYW.cjs.map +0 -1
  88. package/dist/chunk-CPZEA2XG.cjs.map +0 -1
  89. package/dist/chunk-GOFGQSF7.js.map +0 -1
  90. package/dist/chunk-I7EPR6KM.js.map +0 -1
  91. package/dist/chunk-IMPWOZUQ.cjs.map +0 -1
  92. package/dist/chunk-KZ3ERBUT.cjs.map +0 -1
  93. package/dist/chunk-LCAQQOLF.js.map +0 -1
  94. package/dist/chunk-OTRCNZO4.js.map +0 -1
  95. package/dist/chunk-RP7OLAVZ.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,106 @@
1
1
  # @mastra/server
2
2
 
3
+ ## 1.32.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Extend the schedules storage schema to support owned schedules and richer trigger audit. This is a breaking schema change to `mastra_schedules` and `mastra_schedule_triggers`; scheduled workflows are still in alpha so no compat shim is provided. ([#16166](https://github.com/mastra-ai/mastra/pull/16166))
8
+ - `Schedule` gains optional `ownerType` / `ownerId` so a schedule row can be attributed to an owning subsystem (e.g. an agent that owns a heartbeat schedule). Workflow schedules leave both fields unset.
9
+ - `ScheduleTrigger.status` is renamed to `outcome` and the type is widened to `ScheduleTriggerOutcome` so future outcome values can be added without another rename.
10
+ - `ScheduleTrigger` gains a stable `id` primary key and new `triggerKind`, `parentTriggerId`, and `metadata` fields. `triggerKind` distinguishes `schedule-fire` rows from later `queue-drain` rows (used by upcoming heartbeat work); `parentTriggerId` links related rows; `metadata` carries outcome-specific context.
11
+ - The libsql, pg, and mongodb adapters all add the new columns/indexes. Their `@mastra/core` peer dependency is tightened to `>=1.32.0-0 <2.0.0-0` so installing a new storage adapter against an older core (or vice-versa) surfaces a peer-dependency warning at install time instead of silently writing/reading the wrong field.
12
+ - Scheduler producer, server schemas/handler, and client SDK types are updated to use the new fields. The `triggers` response on `GET /api/schedules/:id/triggers` now returns `outcome` instead of `status`.
13
+ - The bundled Studio (Mastra CLI) is updated to read `outcome` so the schedule detail page keeps polling and rendering publish-failure rows correctly.
14
+
15
+ - Added API endpoints for MCP server resources, enabling clients to list and read app resources for interactive UI rendering. ([#16004](https://github.com/mastra-ai/mastra/pull/16004))
16
+ - `GET /api/mcp/:serverId/resources` — lists available resources on an MCP server
17
+ - `POST /api/mcp/:serverId/resources/read` — reads a specific resource by URI (e.g. `ui://calculator/app`)
18
+
19
+ - Added HTTP routes for scheduled workflows. ([#15830](https://github.com/mastra-ai/mastra/pull/15830))
20
+ - `GET /api/schedules` — list schedules across the project, optionally filtered by `workflowId`.
21
+ - `GET /api/schedules/:scheduleId` — fetch a schedule with its most recent run summary.
22
+ - `GET /api/schedules/:scheduleId/triggers` — paginated trigger history joined to the corresponding workflow run.
23
+ - `POST /api/schedules/:scheduleId/pause` and `POST /api/schedules/:scheduleId/resume` — durable pause/resume. Both require `schedules:write` and are idempotent. Resume recomputes `nextFireAt` from now so a long-paused schedule does not fire a backlog.
24
+
25
+ - Added `listBranches` and `getBranch` endpoints. Use these to find specific runs of an agent, workflow, tool, or processor — even when they are nested inside another trace — and to fetch the subtree of spans rooted at any single span. ([#16177](https://github.com/mastra-ai/mastra/pull/16177))
26
+
27
+ ```
28
+ GET /observability/branches?spanType=agent_run&entityName=Observer
29
+ GET /observability/traces/:traceId/branches/:spanId?depth=1
30
+ ```
31
+
32
+ Each row in `listBranches` is a single anchor span (one of `AGENT_RUN`, `WORKFLOW_RUN`, `PROCESSOR_RUN`, `SCORER_RUN`, `RAG_INGESTION`, `TOOL_CALL`, `MCP_TOOL_CALL`), so entities that always run as a child (e.g., an `Observer` agent inside a workflow) — previously not listable through `listTraces` — are now queryable via the HTTP API. `getBranch` accepts an optional `depth` (`0` = anchor only; omitted = full subtree).
33
+
34
+ Follow-up to https://github.com/mastra-ai/mastra/pull/16154 which added the underlying `@mastra/core` storage APIs.
35
+
36
+ - Added Fine-Grained Authorization (FGA) enforcement across server handlers and memory APIs: ([#15410](https://github.com/mastra-ai/mastra/pull/15410))
37
+ - Route-level checks on detail endpoints, custom routes (including request-aware resource ID resolvers and path parameters), and resource-scoped search
38
+ - Thread-level checks on reads, writes, creation, cloning, message saving, and listing — with unviewable threads hidden from totals and pagination
39
+ - Message deletion now denies access when the message's thread cannot be verified
40
+ - Authenticated user context preserved through thread authorization, and the thread's owning `resourceId` forwarded into the FGA context so providers can derive composite tenant-scoped resource IDs
41
+ - Route permission derivation and memory clone checks now use the correct resource context
42
+ - Typed FGA permission constants accepted in route and thread authorization config
43
+
44
+ ### Patch Changes
45
+
46
+ - Fixed A2A task resubscribe to return the current task snapshot and continue streaming live artifact and status updates for in-progress tasks. ([#15987](https://github.com/mastra-ai/mastra/pull/15987))
47
+
48
+ - Added an observability score lookup endpoint at `GET /observability/scores/:scoreId` backed by observability storage. ([#16162](https://github.com/mastra-ai/mastra/pull/16162))
49
+
50
+ - Added MCP Apps extension support (SEP-1865). MCPServer now accepts an `appResources` config to register interactive `ui://` HTML resources. MCPClient preserves full tool `_meta` (including `ui.resourceUri`) when converting MCP tools to Mastra tools. Both advertise the `io.modelcontextprotocol/ui` extension capability. ([#16004](https://github.com/mastra-ai/mastra/pull/16004))
51
+
52
+ **Example — MCPServer with app resources:**
53
+
54
+ ```typescript
55
+ const server = new MCPServer({
56
+ name: 'my-server',
57
+ tools: { myTool },
58
+ appResources: {
59
+ dashboard: {
60
+ name: 'Dashboard',
61
+ description: 'Interactive dashboard UI',
62
+ html: '<html>...</html>',
63
+ },
64
+ },
65
+ });
66
+ ```
67
+
68
+ - Added server-generated route contract types for the JavaScript client SDK and updated the SDK to use those generated request and response types. ([#15519](https://github.com/mastra-ai/mastra/pull/15519))
69
+
70
+ - Updated dependencies [[`6dcd65f`](https://github.com/mastra-ai/mastra/commit/6dcd65f2a34069e6dc43ba35f1d11119b9b40bef), [`86c0298`](https://github.com/mastra-ai/mastra/commit/86c0298e647306423c842f9d5ac827bd616bd13d), [`c05c9a1`](https://github.com/mastra-ai/mastra/commit/c05c9a13230988cef6d438a62f37760f31927bc7), [`ca28c23`](https://github.com/mastra-ai/mastra/commit/ca28c232a2f18801a6cf20fe053479237b4d4fb0), [`e24aacb`](https://github.com/mastra-ai/mastra/commit/e24aacba07bd66f5d95b636dc24016fca26b52cf), [`7679a63`](https://github.com/mastra-ai/mastra/commit/7679a634eae8e8ca459fd87538fdf72b4389b07f), [`7fce309`](https://github.com/mastra-ai/mastra/commit/7fce30912b14170bfc41f0ac736cca0f39fe0cd4), [`1d64a76`](https://github.com/mastra-ai/mastra/commit/1d64a765861a0772ea187bab76e5ed37bf82d042), [`1c2dda8`](https://github.com/mastra-ai/mastra/commit/1c2dda805fbfccc0abf55d4cb20cc34402dc3f0c), [`c721164`](https://github.com/mastra-ai/mastra/commit/c7211643f7ac861f83b19a3757cc921487fc9d75), [`1b55954`](https://github.com/mastra-ai/mastra/commit/1b559541c1e08a10e49d01ffc51a634dfc37a286), [`7997c2e`](https://github.com/mastra-ai/mastra/commit/7997c2e55ddd121562a4098cd8d2b89c68433bf1), [`5adc55e`](https://github.com/mastra-ai/mastra/commit/5adc55e63407be8ee977914957d68bcc2a075ceb), [`7679a63`](https://github.com/mastra-ai/mastra/commit/7679a634eae8e8ca459fd87538fdf72b4389b07f), [`a0d9b6d`](https://github.com/mastra-ai/mastra/commit/a0d9b6d6b810aeaa9e177a0dcc99a4402e609634), [`e97ccb9`](https://github.com/mastra-ai/mastra/commit/e97ccb900f8b7a390ce82c9f8eb8d6eb2c5e3777), [`c5daf48`](https://github.com/mastra-ai/mastra/commit/c5daf48556e98c46ae06caf00f92c249912007e9), [`70017d7`](https://github.com/mastra-ai/mastra/commit/70017d72ab741b5d7040e2a15c251a317782e39e), [`cd96779`](https://github.com/mastra-ai/mastra/commit/cd9677937f113b2856dc8b9f3d4bdabcee58bb2e), [`b0c7022`](https://github.com/mastra-ai/mastra/commit/b0c70224f80dad7c0cdbfb22cbff22e0f75c064f), [`e4942bc`](https://github.com/mastra-ai/mastra/commit/e4942bc7fdc903572f7d84f26d5e15f9d39c763d)]:
71
+ - @mastra/core@1.32.0
72
+
73
+ ## 1.32.0-alpha.4
74
+
75
+ ### Minor Changes
76
+
77
+ - Added API endpoints for MCP server resources, enabling clients to list and read app resources for interactive UI rendering. ([#16004](https://github.com/mastra-ai/mastra/pull/16004))
78
+ - `GET /api/mcp/:serverId/resources` — lists available resources on an MCP server
79
+ - `POST /api/mcp/:serverId/resources/read` — reads a specific resource by URI (e.g. `ui://calculator/app`)
80
+
81
+ ### Patch Changes
82
+
83
+ - Added MCP Apps extension support (SEP-1865). MCPServer now accepts an `appResources` config to register interactive `ui://` HTML resources. MCPClient preserves full tool `_meta` (including `ui.resourceUri`) when converting MCP tools to Mastra tools. Both advertise the `io.modelcontextprotocol/ui` extension capability. ([#16004](https://github.com/mastra-ai/mastra/pull/16004))
84
+
85
+ **Example — MCPServer with app resources:**
86
+
87
+ ```typescript
88
+ const server = new MCPServer({
89
+ name: 'my-server',
90
+ tools: { myTool },
91
+ appResources: {
92
+ dashboard: {
93
+ name: 'Dashboard',
94
+ description: 'Interactive dashboard UI',
95
+ html: '<html>...</html>',
96
+ },
97
+ },
98
+ });
99
+ ```
100
+
101
+ - Updated dependencies [[`7679a63`](https://github.com/mastra-ai/mastra/commit/7679a634eae8e8ca459fd87538fdf72b4389b07f), [`1d64a76`](https://github.com/mastra-ai/mastra/commit/1d64a765861a0772ea187bab76e5ed37bf82d042), [`7679a63`](https://github.com/mastra-ai/mastra/commit/7679a634eae8e8ca459fd87538fdf72b4389b07f), [`a0d9b6d`](https://github.com/mastra-ai/mastra/commit/a0d9b6d6b810aeaa9e177a0dcc99a4402e609634)]:
102
+ - @mastra/core@1.32.0-alpha.4
103
+
3
104
  ## 1.32.0-alpha.3
4
105
 
5
106
  ### Minor Changes
@@ -47,7 +47,8 @@ var mcpToolInfoSchema = z.object({
47
47
  description: z.string().optional(),
48
48
  inputSchema: z.unknown(),
49
49
  outputSchema: z.unknown().optional(),
50
- toolType: z.string().optional()
50
+ toolType: z.string().optional(),
51
+ _meta: z.record(z.string(), z.unknown()).optional()
51
52
  });
52
53
  var listMcpServerToolsResponseSchema = z.object({
53
54
  tools: z.array(mcpToolInfoSchema)
@@ -55,6 +56,30 @@ var listMcpServerToolsResponseSchema = z.object({
55
56
  var executeToolResponseSchema = z.object({
56
57
  result: z.unknown()
57
58
  });
59
+ var mcpServerResourcePathParams = z.object({
60
+ serverId: z.string().describe("MCP server ID")
61
+ });
62
+ var readResourceBodySchema = z.object({
63
+ uri: z.string().describe("Resource URI to read")
64
+ });
65
+ var resourceContentSchema = z.object({
66
+ uri: z.string(),
67
+ text: z.string().optional(),
68
+ blob: z.string().optional()
69
+ });
70
+ var readResourceResponseSchema = z.object({
71
+ contents: z.array(resourceContentSchema)
72
+ });
73
+ var resourceInfoSchema = z.object({
74
+ uri: z.string(),
75
+ name: z.string(),
76
+ description: z.string().optional(),
77
+ mimeType: z.string().optional(),
78
+ _meta: z.record(z.string(), z.unknown()).optional()
79
+ });
80
+ var listResourcesResponseSchema = z.object({
81
+ resources: z.array(resourceInfoSchema)
82
+ });
58
83
  var jsonRpcErrorSchema = z.object({
59
84
  jsonrpc: z.literal("2.0"),
60
85
  error: z.object({
@@ -64,6 +89,6 @@ var jsonRpcErrorSchema = z.object({
64
89
  id: z.null()
65
90
  });
66
91
 
67
- export { executeToolBodySchema, executeToolResponseSchema, getMcpServerDetailQuerySchema, jsonRpcErrorSchema, listMcpServerToolsResponseSchema, listMcpServersQuerySchema, listMcpServersResponseSchema, mcpServerDetailPathParams, mcpServerIdPathParams, mcpServerToolPathParams, mcpToolInfoSchema, serverDetailSchema, serverInfoSchema, versionDetailSchema };
68
- //# sourceMappingURL=chunk-LCAQQOLF.js.map
69
- //# sourceMappingURL=chunk-LCAQQOLF.js.map
92
+ export { executeToolBodySchema, executeToolResponseSchema, getMcpServerDetailQuerySchema, jsonRpcErrorSchema, listMcpServerToolsResponseSchema, listMcpServersQuerySchema, listMcpServersResponseSchema, listResourcesResponseSchema, mcpServerDetailPathParams, mcpServerIdPathParams, mcpServerResourcePathParams, mcpServerToolPathParams, mcpToolInfoSchema, readResourceBodySchema, readResourceResponseSchema, serverDetailSchema, serverInfoSchema, versionDetailSchema };
93
+ //# sourceMappingURL=chunk-356JZOB2.js.map
94
+ //# sourceMappingURL=chunk-356JZOB2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/server/schemas/mcp.ts"],"names":[],"mappings":";;;AAIO,IAAM,qBAAA,GAAwB,EAAE,MAAA,CAAO;AAAA,EAC5C,QAAA,EAAU,CAAA,CAAE,MAAA,EAAO,CAAE,SAAS,eAAe;AAC/C,CAAC;AAEM,IAAM,yBAAA,GAA4B,EAAE,MAAA,CAAO;AAAA,EAChD,EAAA,EAAI,CAAA,CAAE,MAAA,EAAO,CAAE,SAAS,eAAe;AACzC,CAAC;AAEM,IAAM,uBAAA,GAA0B,EAAE,MAAA,CAAO;AAAA,EAC9C,QAAA,EAAU,CAAA,CAAE,MAAA,EAAO,CAAE,SAAS,eAAe,CAAA;AAAA,EAC7C,MAAA,EAAQ,CAAA,CAAE,MAAA,EAAO,CAAE,SAAS,SAAS;AACvC,CAAC;AAEM,IAAM,qBAAA,GAAwB,EAAE,MAAA,CAAO;AAAA,EAC5C,IAAA,EAAM,CAAA,CAAE,OAAA,EAAQ,CAAE,QAAA;AACpB,CAAC;AAIM,IAAM,4BAA4B,8BAAA;AAElC,IAAM,6BAAA,GAAgC,EAAE,MAAA,CAAO;AAAA,EACpD,OAAA,EAAS,CAAA,CAAE,M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AAA,CAAE,MAAA,EAAO,CAAE,QAAA,EAAS;AAAA,EACjC,QAAA,EAAU,CAAA,CAAE,MAAA,EAAO,CAAE,QAAA,EAAS;AAAA,EAC9B,KAAA,EAAO,CAAA,CAAE,MAAA,CAAO,CAAA,CAAE,MAAA,IAAU,CAAA,CAAE,OAAA,EAAS,CAAA,CAAE,QAAA;AAC3C,CAAC,CAAA;AAEM,IAAM,2BAAA,GAA8B,EAAE,MAAA,CAAO;AAAA,EAClD,SAAA,EAAW,CAAA,CAAE,KAAA,CAAM,kBAAkB;AACvC,CAAC;AAGM,IAAM,kBAAA,GAAqB,EAAE,MAAA,CAAO;AAAA,EACzC,OAAA,EAAS,CAAA,CAAE,OAAA,CAAQ,KAAK,CAAA;AAAA,EACxB,KAAA,EAAO,EAAE,MAAA,CAAO;AAAA,IACd,IAAA,EAAM,EAAE,MAAA,EAAO;AAAA,IACf,OAAA,EAAS,EAAE,MAAA;AAAO,GACnB,CAAA;AAAA,EACD,EAAA,EAAI,EAAE,IAAA;AACR,CAAC","file":"chunk-356JZOB2.js","sourcesContent":["import { z } from 'zod/v4';\nimport { createCombinedPaginationSchema } from './common';\n\n// Path parameters\nexport const mcpServerIdPathParams = z.object({\n serverId: z.string().describe('MCP server ID'),\n});\n\nexport const mcpServerDetailPathParams = z.object({\n id: z.string().describe('MCP server ID'),\n});\n\nexport const mcpServerToolPathParams = z.object({\n serverId: z.string().describe('MCP server ID'),\n toolId: z.string().describe('Tool ID'),\n});\n\nexport const executeToolBodySchema = z.object({\n data: z.unknown().optional(),\n});\n\n// Query parameters\n// Supports both page/perPage and limit/offset for backwards compatibility\nexport const listMcpServersQuerySchema = createCombinedPaginationSchema();\n\nexport const getMcpServerDetailQuerySchema = z.object({\n version: z.string().optional(),\n});\n\n// Response schemas\nexport const versionDetailSchema = z.object({\n version: z.string(),\n release_date: z.string(),\n is_latest: z.boolean(),\n});\n\nexport const serverInfoSchema = z.object({\n id: z.string(),\n name: z.string(),\n version_detail: versionDetailSchema,\n});\n\nexport const listMcpServersResponseSchema = z.object({\n servers: z.array(serverInfoSchema),\n total_count: z.number(),\n next: z.string().nullable(),\n});\n\nexport const serverDetailSchema = z.object({\n id: z.string(),\n name: z.string(),\n description: z.string().optional(),\n version_detail: versionDetailSchema,\n package_canonical: z.string().optional(),\n packages: z.array(z.unknown()).optional(),\n remotes: z.array(z.unknown()).optional(),\n});\n\n// Tool schemas\nexport const mcpToolInfoSchema = z.object({\n name: z.string(),\n description: z.string().optional(),\n inputSchema: z.unknown(),\n outputSchema: z.unknown().optional(),\n toolType: z.string().optional(),\n _meta: z.record(z.string(), z.unknown()).optional(),\n});\n\nexport const listMcpServerToolsResponseSchema = z.object({\n tools: z.array(mcpToolInfoSchema),\n});\n\nexport const executeToolResponseSchema = z.object({\n result: z.unknown(),\n});\n\n// Resource schemas\nexport const mcpServerResourcePathParams = z.object({\n serverId: z.string().describe('MCP server ID'),\n});\n\nexport const readResourceBodySchema = z.object({\n uri: z.string().describe('Resource URI to read'),\n});\n\nexport const resourceContentSchema = z.object({\n uri: z.string(),\n text: z.string().optional(),\n blob: z.string().optional(),\n});\n\nexport const readResourceResponseSchema = z.object({\n contents: z.array(resourceContentSchema),\n});\n\nexport const resourceInfoSchema = z.object({\n uri: z.string(),\n name: z.string(),\n description: z.string().optional(),\n mimeType: z.string().optional(),\n _meta: z.record(z.string(), z.unknown()).optional(),\n});\n\nexport const listResourcesResponseSchema = z.object({\n resources: z.array(resourceInfoSchema),\n});\n\n// JSON-RPC error response schema\nexport const jsonRpcErrorSchema = z.object({\n jsonrpc: z.literal('2.0'),\n error: z.object({\n code: z.number(),\n message: z.string(),\n }),\n id: z.null(),\n});\n"]}
@@ -1040,7 +1040,7 @@ function imageSize(input) {
1040
1040
  throw new TypeError(`unsupported file type: ${type}`);
1041
1041
  }
1042
1042
 
1043
- // ../memory/dist/chunk-Z5GWA7LB.js
1043
+ // ../memory/dist/chunk-BPJLUC2F.js
1044
1044
  var OM_DEBUG_LOG = process.env.OM_DEBUG ? join(process.cwd(), "om-debug.log") : null;
1045
1045
  function omDebug(msg) {
1046
1046
  if (!OM_DEBUG_LOG) return;
@@ -4749,6 +4749,7 @@ var ObserverRunner = class {
4749
4749
  observedMessageIds;
4750
4750
  resolveModel;
4751
4751
  tokenCounter;
4752
+ mastra;
4752
4753
  /** Captured prompt/response from the last observer call (for repro capture). */
4753
4754
  lastExchange;
4754
4755
  constructor(opts) {
@@ -4756,9 +4757,13 @@ var ObserverRunner = class {
4756
4757
  this.observedMessageIds = opts.observedMessageIds;
4757
4758
  this.resolveModel = opts.resolveModel;
4758
4759
  this.tokenCounter = opts.tokenCounter;
4760
+ this.mastra = opts.mastra;
4761
+ }
4762
+ __registerMastra(mastra) {
4763
+ this.mastra = mastra;
4759
4764
  }
4760
4765
  createAgent(model, isMultiThread = false) {
4761
- return new Agent({
4766
+ const agent = new Agent({
4762
4767
  id: isMultiThread ? "multi-thread-observer" : "observational-memory-observer",
4763
4768
  name: isMultiThread ? "multi-thread-observer" : "Observer",
4764
4769
  instructions: buildObserverSystemPrompt(
@@ -4768,6 +4773,10 @@ var ObserverRunner = class {
4768
4773
  ),
4769
4774
  model
4770
4775
  });
4776
+ if (this.mastra) {
4777
+ agent.__registerMastra(this.mastra);
4778
+ }
4779
+ return agent;
4771
4780
  }
4772
4781
  async withAbortCheck(fn, abortSignal) {
4773
4782
  if (abortSignal?.aborted) {
@@ -5283,6 +5292,7 @@ var ReflectorRunner = class {
5283
5292
  persistMarkerToStorage;
5284
5293
  persistMarkerToMessage;
5285
5294
  getCompressionStartLevel;
5295
+ mastra;
5286
5296
  constructor(opts) {
5287
5297
  this.reflectionConfig = opts.reflectionConfig;
5288
5298
  this.observationConfig = opts.observationConfig;
@@ -5295,14 +5305,22 @@ var ReflectorRunner = class {
5295
5305
  this.persistMarkerToStorage = opts.persistMarkerToStorage;
5296
5306
  this.persistMarkerToMessage = opts.persistMarkerToMessage;
5297
5307
  this.getCompressionStartLevel = opts.getCompressionStartLevel;
5308
+ this.mastra = opts.mastra;
5309
+ }
5310
+ __registerMastra(mastra) {
5311
+ this.mastra = mastra;
5298
5312
  }
5299
5313
  createAgent(model) {
5300
- return new Agent({
5314
+ const agent = new Agent({
5301
5315
  id: "observational-memory-reflector",
5302
5316
  name: "Reflector",
5303
5317
  instructions: buildReflectorSystemPrompt(this.reflectionConfig.instruction),
5304
5318
  model
5305
5319
  });
5320
+ if (this.mastra) {
5321
+ agent.__registerMastra(this.mastra);
5322
+ }
5323
+ return agent;
5306
5324
  }
5307
5325
  getObservationMarkerConfig(record) {
5308
5326
  return {
@@ -7586,6 +7604,7 @@ var ObservationalMemory = class _ObservationalMemory {
7586
7604
  buffering;
7587
7605
  shouldObscureThreadIds = false;
7588
7606
  hasher = e();
7607
+ mastra;
7589
7608
  /**
7590
7609
  * Track message IDs observed during this instance's lifetime.
7591
7610
  * Prevents re-observing messages when per-thread lastObservedAt cursors
@@ -7652,20 +7671,10 @@ var ObservationalMemory = class _ObservationalMemory {
7652
7671
  this.scope = config.scope ?? "thread";
7653
7672
  this.retrieval = Boolean(config.retrieval);
7654
7673
  this.onIndexObservations = config.onIndexObservations;
7655
- const resolveModel = (m) => m === "default" ? OBSERVATIONAL_MEMORY_DEFAULTS.observation.model : m;
7656
- const observationModel = resolveModel(config.model) ?? resolveModel(config.observation?.model) ?? resolveModel(config.reflection?.model);
7657
- const reflectionModel = resolveModel(config.model) ?? resolveModel(config.reflection?.model) ?? resolveModel(config.observation?.model);
7658
- if (!observationModel || !reflectionModel) {
7659
- throw new Error(
7660
- `Observational Memory requires a model to be set. Use \`observationalMemory: true\` for the default (google/gemini-2.5-flash), or set a model explicitly:
7661
-
7662
- observationalMemory: {
7663
- model: "$provider/$model",
7664
- }
7665
-
7666
- See https://mastra.ai/docs/memory/observational-memory#models for model recommendations and alternatives.`
7667
- );
7668
- }
7674
+ this.mastra = config.mastra;
7675
+ const resolveModel = (model, defaultModel) => model === "default" ? defaultModel : model;
7676
+ const observationModel = resolveModel(config.model, OBSERVATIONAL_MEMORY_DEFAULTS.observation.model) ?? resolveModel(config.observation?.model, OBSERVATIONAL_MEMORY_DEFAULTS.observation.model) ?? resolveModel(config.reflection?.model, OBSERVATIONAL_MEMORY_DEFAULTS.observation.model) ?? OBSERVATIONAL_MEMORY_DEFAULTS.observation.model;
7677
+ const reflectionModel = resolveModel(config.model, OBSERVATIONAL_MEMORY_DEFAULTS.reflection.model) ?? resolveModel(config.reflection?.model, OBSERVATIONAL_MEMORY_DEFAULTS.reflection.model) ?? resolveModel(config.observation?.model, OBSERVATIONAL_MEMORY_DEFAULTS.reflection.model) ?? OBSERVATIONAL_MEMORY_DEFAULTS.reflection.model;
7669
7678
  const messageTokens = config.observation?.messageTokens ?? OBSERVATIONAL_MEMORY_DEFAULTS.observation.messageTokens;
7670
7679
  const observationTokens = config.reflection?.observationTokens ?? OBSERVATIONAL_MEMORY_DEFAULTS.reflection.observationTokens;
7671
7680
  const isSharedBudget = config.shareTokenBudget ?? false;
@@ -7751,7 +7760,8 @@ Async buffering is enabled by default \u2014 this opt-out is only needed when us
7751
7760
  observationConfig: this.observationConfig,
7752
7761
  observedMessageIds: this.observedMessageIds,
7753
7762
  resolveModel: (inputTokens) => this.resolveObservationModel(inputTokens),
7754
- tokenCounter: this.tokenCounter
7763
+ tokenCounter: this.tokenCounter,
7764
+ mastra: config.mastra
7755
7765
  });
7756
7766
  this.buffering = new BufferingCoordinator({
7757
7767
  observationConfig: this.observationConfig,
@@ -7769,13 +7779,19 @@ Async buffering is enabled by default \u2014 this opt-out is only needed when us
7769
7779
  persistMarkerToStorage: (m, t2, r) => this.persistMarkerToStorage(m, t2, r),
7770
7780
  persistMarkerToMessage: (m, ml, t2, r) => this.persistMarkerToMessage(m, ml, t2, r),
7771
7781
  getCompressionStartLevel: (rc) => this.getCompressionStartLevel(rc),
7772
- resolveModel: (inputTokens) => this.resolveReflectionModel(inputTokens)
7782
+ resolveModel: (inputTokens) => this.resolveReflectionModel(inputTokens),
7783
+ mastra: config.mastra
7773
7784
  });
7774
7785
  this.validateBufferConfig();
7775
7786
  omDebug(
7776
7787
  `[OM:init] new ObservationalMemory instance created \u2014 scope=${this.scope}, messageTokens=${JSON.stringify(this.observationConfig.messageTokens)}, obsAsyncEnabled=${this.buffering.isAsyncObservationEnabled()}, bufferTokens=${this.observationConfig.bufferTokens}, bufferActivation=${this.observationConfig.bufferActivation}, blockAfter=${this.observationConfig.blockAfter}, reflectionTokens=${this.reflectionConfig.observationTokens}, refAsyncEnabled=${this.buffering.isAsyncReflectionEnabled()}, refAsyncActivation=${this.reflectionConfig.bufferActivation}, refBlockAfter=${this.reflectionConfig.blockAfter}`
7777
7788
  );
7778
7789
  }
7790
+ __registerMastra(mastra) {
7791
+ this.mastra = mastra;
7792
+ this.observer.__registerMastra(mastra);
7793
+ this.reflector.__registerMastra(mastra);
7794
+ }
7779
7795
  /**
7780
7796
  * Get the current configuration for this OM instance.
7781
7797
  * Used by the server to expose config to the UI when OM is added via processors.
@@ -7884,7 +7900,7 @@ Async buffering is enabled by default \u2014 this opt-out is only needed when us
7884
7900
  if (!modelToResolve) {
7885
7901
  return void 0;
7886
7902
  }
7887
- const resolved = await resolveModelConfig(modelToResolve, requestContext);
7903
+ const resolved = await resolveModelConfig(modelToResolve, requestContext, this.mastra);
7888
7904
  return {
7889
7905
  provider: resolved.provider,
7890
7906
  modelId: resolved.modelId
@@ -10335,5 +10351,5 @@ function getObservationsAsOf(activeObservations, asOf) {
10335
10351
  }
10336
10352
 
10337
10353
  export { ModelByInputTokens, OBSERVER_SYSTEM_PROMPT, ObservationalMemory, ObservationalMemoryProcessor, TokenCounter, buildObserverPrompt, buildObserverSystemPrompt, combineObservationGroupRanges, deriveObservationGroupProvenance, e, estimateTokenCount, extractCurrentTask, formatMessagesForObserver, formatToolResultForObserver, getObservationsAsOf, hasCurrentTaskSection, injectAnchorIds, optimizeObservationsForContext, parseAnchorId, parseObservationGroups, parseObserverOutput, reconcileObservationGroupsFromReflection, renderObservationGroupsForReflection, resolveToolResultValue, stripEphemeralAnchorIds, stripObservationGroups, truncateStringByTokens, wrapInObservationGroup };
10338
- //# sourceMappingURL=chunk-RP7OLAVZ.js.map
10339
- //# sourceMappingURL=chunk-RP7OLAVZ.js.map
10354
+ //# sourceMappingURL=chunk-4HRTLLE6.js.map
10355
+ //# sourceMappingURL=chunk-4HRTLLE6.js.map