@mastra/server 1.48.0-alpha.8 → 1.48.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 (97) hide show
  1. package/CHANGELOG.md +139 -0
  2. package/dist/{api-schema-manifest-OSFSFYKI.cjs → api-schema-manifest-4VQSWI7S.cjs} +4 -4
  3. package/dist/{api-schema-manifest-OSFSFYKI.cjs.map → api-schema-manifest-4VQSWI7S.cjs.map} +1 -1
  4. package/dist/{api-schema-manifest-YKMSPSZR.js → api-schema-manifest-RP35YQV7.js} +3 -3
  5. package/dist/{api-schema-manifest-YKMSPSZR.js.map → api-schema-manifest-RP35YQV7.js.map} +1 -1
  6. package/dist/chunk-2WUMO4RN.cjs +32677 -0
  7. package/dist/chunk-2WUMO4RN.cjs.map +1 -0
  8. package/dist/{chunk-LFZO2LHV.cjs → chunk-3QVZXWIE.cjs} +7 -3
  9. package/dist/chunk-3QVZXWIE.cjs.map +1 -0
  10. package/dist/{chunk-5SZOGYYO.cjs → chunk-FKM644Z6.cjs} +52 -52
  11. package/dist/{chunk-5SZOGYYO.cjs.map → chunk-FKM644Z6.cjs.map} +1 -1
  12. package/dist/{chunk-UXVICGWD.cjs → chunk-H7NWUAHC.cjs} +3 -3
  13. package/dist/{chunk-UXVICGWD.cjs.map → chunk-H7NWUAHC.cjs.map} +1 -1
  14. package/dist/{chunk-BVMR64B7.cjs → chunk-I4COPLOY.cjs} +3 -3
  15. package/dist/{chunk-BVMR64B7.cjs.map → chunk-I4COPLOY.cjs.map} +1 -1
  16. package/dist/{chunk-UTRP4B2Q.js → chunk-JEFGF2F5.js} +7 -3
  17. package/dist/chunk-JEFGF2F5.js.map +1 -0
  18. package/dist/{chunk-PXY4G3SN.cjs → chunk-KN22ZEKU.cjs} +11 -11
  19. package/dist/{chunk-PXY4G3SN.cjs.map → chunk-KN22ZEKU.cjs.map} +1 -1
  20. package/dist/{chunk-WOE6XG6B.js → chunk-LEKVIHSE.js} +3 -3
  21. package/dist/{chunk-WOE6XG6B.js.map → chunk-LEKVIHSE.js.map} +1 -1
  22. package/dist/{chunk-PJXH5A23.cjs → chunk-LVGS5ADS.cjs} +110 -110
  23. package/dist/{chunk-PJXH5A23.cjs.map → chunk-LVGS5ADS.cjs.map} +1 -1
  24. package/dist/{chunk-LZMQLV2S.js → chunk-MDXMBAYV.js} +4 -4
  25. package/dist/{chunk-LZMQLV2S.js.map → chunk-MDXMBAYV.js.map} +1 -1
  26. package/dist/{chunk-HTBC6CVX.cjs → chunk-NI2DJ2VW.cjs} +4 -4
  27. package/dist/{chunk-HTBC6CVX.cjs.map → chunk-NI2DJ2VW.cjs.map} +1 -1
  28. package/dist/{chunk-UZKVYNYR.js → chunk-Q6FMYSXG.js} +18 -2
  29. package/dist/chunk-Q6FMYSXG.js.map +1 -0
  30. package/dist/{chunk-NOXRQV2G.cjs → chunk-QQF22Q32.cjs} +18 -2
  31. package/dist/chunk-QQF22Q32.cjs.map +1 -0
  32. package/dist/{chunk-XDR5CTSX.js → chunk-USYLK73B.js} +3 -3
  33. package/dist/{chunk-XDR5CTSX.js.map → chunk-USYLK73B.js.map} +1 -1
  34. package/dist/{chunk-YAEG3FIX.js → chunk-V23YWHBT.js} +3 -3
  35. package/dist/{chunk-YAEG3FIX.js.map → chunk-V23YWHBT.js.map} +1 -1
  36. package/dist/{chunk-XJLHTR7T.js → chunk-V4X6NCFW.js} +6 -6
  37. package/dist/{chunk-XJLHTR7T.js.map → chunk-V4X6NCFW.js.map} +1 -1
  38. package/dist/chunk-WWPJKPP2.js +32631 -0
  39. package/dist/chunk-WWPJKPP2.js.map +1 -0
  40. package/dist/{chunk-NZBVBHKY.js → chunk-YPYXJKWJ.js} +3 -3
  41. package/dist/{chunk-NZBVBHKY.js.map → chunk-YPYXJKWJ.js.map} +1 -1
  42. package/dist/{constants-DVRTNEGY-A5OAGF3M.js → constants-RMCTOZE3-3LAM6TBM.js} +2 -2
  43. package/dist/{constants-DVRTNEGY-A5OAGF3M.js.map → constants-RMCTOZE3-3LAM6TBM.js.map} +1 -1
  44. package/dist/{constants-DVRTNEGY-ZGCNETZ3.cjs → constants-RMCTOZE3-JL6U6KRC.cjs} +2 -2
  45. package/dist/{constants-DVRTNEGY-ZGCNETZ3.cjs.map → constants-RMCTOZE3-JL6U6KRC.cjs.map} +1 -1
  46. package/dist/dist-6VCCDFCW.cjs +11402 -0
  47. package/dist/dist-6VCCDFCW.cjs.map +1 -0
  48. package/dist/dist-7DYUIL2E.js +11375 -0
  49. package/dist/dist-7DYUIL2E.js.map +1 -0
  50. package/dist/docs/SKILL.md +1 -1
  51. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  52. package/dist/observational-memory-PBLNZABH-2OUE5VEX.js +4 -0
  53. package/dist/{observational-memory-VZDCB747-I6PAZ4T6.js.map → observational-memory-PBLNZABH-2OUE5VEX.js.map} +1 -1
  54. package/dist/{observational-memory-VZDCB747-HGIBYINL.cjs → observational-memory-PBLNZABH-MQEKJOVA.cjs} +34 -26
  55. package/dist/{observational-memory-VZDCB747-HGIBYINL.cjs.map → observational-memory-PBLNZABH-MQEKJOVA.cjs.map} +1 -1
  56. package/dist/server/handlers/agent-builder.cjs +17 -17
  57. package/dist/server/handlers/agent-builder.js +1 -1
  58. package/dist/server/handlers/conversations.cjs +5 -5
  59. package/dist/server/handlers/conversations.js +1 -1
  60. package/dist/server/handlers/gateway-memory-client.cjs +8 -8
  61. package/dist/server/handlers/gateway-memory-client.d.ts +37 -2
  62. package/dist/server/handlers/gateway-memory-client.d.ts.map +1 -1
  63. package/dist/server/handlers/gateway-memory-client.js +1 -1
  64. package/dist/server/handlers/memory.cjs +27 -27
  65. package/dist/server/handlers/memory.d.ts +108 -0
  66. package/dist/server/handlers/memory.d.ts.map +1 -1
  67. package/dist/server/handlers/memory.js +1 -1
  68. package/dist/server/handlers/system.cjs +3 -3
  69. package/dist/server/handlers/system.js +1 -1
  70. package/dist/server/handlers.cjs +6 -6
  71. package/dist/server/handlers.js +3 -3
  72. package/dist/server/schemas/index.cjs +50 -50
  73. package/dist/server/schemas/index.js +2 -2
  74. package/dist/server/schemas/memory.d.ts +54 -0
  75. package/dist/server/schemas/memory.d.ts.map +1 -1
  76. package/dist/server/server-adapter/index.cjs +13 -13
  77. package/dist/server/server-adapter/index.js +2 -2
  78. package/dist/server/server-adapter/routes/memory.d.ts +108 -0
  79. package/dist/server/server-adapter/routes/memory.d.ts.map +1 -1
  80. package/dist/{working-memory-state-J7ASTNXX-WEIO7C67.cjs → working-memory-state-OMSMSYAW-4THWAGFK.cjs} +2 -2
  81. package/dist/{working-memory-state-J7ASTNXX-WEIO7C67.cjs.map → working-memory-state-OMSMSYAW-4THWAGFK.cjs.map} +1 -1
  82. package/dist/{working-memory-state-J7ASTNXX-JNDYMEET.js → working-memory-state-OMSMSYAW-NEULPFZX.js} +2 -2
  83. package/dist/{working-memory-state-J7ASTNXX-JNDYMEET.js.map → working-memory-state-OMSMSYAW-NEULPFZX.js.map} +1 -1
  84. package/package.json +9 -9
  85. package/dist/chunk-3SSXARFU.cjs +0 -11543
  86. package/dist/chunk-3SSXARFU.cjs.map +0 -1
  87. package/dist/chunk-LFZO2LHV.cjs.map +0 -1
  88. package/dist/chunk-NOXRQV2G.cjs.map +0 -1
  89. package/dist/chunk-S2RXZQ4K.js +0 -11514
  90. package/dist/chunk-S2RXZQ4K.js.map +0 -1
  91. package/dist/chunk-UTRP4B2Q.js.map +0 -1
  92. package/dist/chunk-UZKVYNYR.js.map +0 -1
  93. package/dist/dist-66SHYWFH.cjs +0 -60958
  94. package/dist/dist-66SHYWFH.cjs.map +0 -1
  95. package/dist/dist-Q3RF3I36.js +0 -60931
  96. package/dist/dist-Q3RF3I36.js.map +0 -1
  97. package/dist/observational-memory-VZDCB747-I6PAZ4T6.js +0 -4
package/CHANGELOG.md CHANGED
@@ -1,5 +1,144 @@
1
1
  # @mastra/server
2
2
 
3
+ ## 1.48.0
4
+
5
+ ### Minor Changes
6
+
7
+ - **Added** heartbeats: schedule an agent to run on a recurring cron, either inside an existing conversation thread or on its own. ([#18184](https://github.com/mastra-ai/mastra/pull/18184))
8
+
9
+ A heartbeat fires a prompt to an agent on a schedule. When it has a thread, the run is delivered into that thread as a normal agent signal, so anything watching the thread sees it like any other message; without a thread, the agent just runs in isolation. Each heartbeat has its own id and an optional `name`, so one agent or thread can have several heartbeats with different schedules and prompts. The id is generated for you, or you can pass your own `id` to `create` for a stable handle (it's normalized to `hb_<slug>`). Heartbeats are persisted, so they keep firing across process restarts with no extra setup.
10
+
11
+ ```ts
12
+ const hb = await mastra.heartbeats.create({
13
+ agentId: 'chef',
14
+ name: 'morning-checkin',
15
+ threadId,
16
+ resourceId,
17
+ cron: '*/5 * * * *',
18
+ prompt: 'Check in on the user',
19
+ ifActive: { behavior: 'discard' }, // skip if the user is mid-conversation
20
+ ifIdle: { behavior: 'wake' }, // wake the agent if the thread is idle
21
+ });
22
+
23
+ // Threadless: run the agent on a cron with no conversation.
24
+ await mastra.heartbeats.create({
25
+ agentId: 'chef',
26
+ cron: '0 * * * *',
27
+ prompt: 'Run the hourly summary',
28
+ });
29
+
30
+ await mastra.heartbeats.list({ agentId: 'chef' });
31
+ await mastra.heartbeats.get(hb.id);
32
+ await mastra.heartbeats.update(hb.id, { prompt: 'check in gently' });
33
+ await mastra.heartbeats.pause(hb.id);
34
+ await mastra.heartbeats.resume(hb.id);
35
+ await mastra.heartbeats.run(hb.id); // fire once now
36
+ await mastra.heartbeats.delete(hb.id);
37
+ ```
38
+
39
+ The same CRUD is available over HTTP through `@mastra/server` (under `/api/heartbeats`) and as top-level methods on the `@mastra/client-js` client (`client.createHeartbeat`, `client.getHeartbeat`, `client.listHeartbeats`, etc.).
40
+
41
+ **Lifecycle hooks**
42
+
43
+ React to heartbeat runs via `heartbeat` on the `Mastra` constructor. It's a single hook bundle that runs for every agent's heartbeats; each hook receives the firing `agentId` so you can branch on it. `prepare` resolves fire-time parameters (for example, creating a fresh thread per fire), and `onFinish` / `onError` / `onAbort` mirror `agent.stream`.
44
+
45
+ ```ts
46
+ new Mastra({
47
+ // ...
48
+ heartbeat: {
49
+ // Return overrides, `null` to skip this fire, or `undefined` to use defaults.
50
+ prepare: async ({ agentId, heartbeat }) => {
51
+ if (agentId === 'chef' && heartbeat.name === 'daily-digest') {
52
+ return { threadId: await createDailyThread(), resourceId: 'slack:U095PUH0FKL' };
53
+ }
54
+ },
55
+ onFinish: ({ agentId, outcome, result, heartbeat }) => {
56
+ metrics.record({ agentId, heartbeat: heartbeat.name, outcome });
57
+ },
58
+ onError: ({ agentId, error, phase, heartbeat }) => {
59
+ alerts.send(`heartbeat ${agentId}/${heartbeat.name} failed in ${phase}: ${error.message}`);
60
+ },
61
+ },
62
+ });
63
+ ```
64
+
65
+ **Signal shaping**
66
+
67
+ A heartbeat fire surfaces to the agent as a signal. By default it uses the `notification` type and renders as `<heartbeat>…</heartbeat>`; override `signalType` and `tagName` to change either. `ifActive` and `ifIdle` mirror the `agent.sendSignal` options shape (`{ behavior, attributes }`, plus `streamOptions` on `ifIdle`) and stay JSON-serializable so they persist with the schedule. `ifIdle.streamOptions` currently accepts `requestContext`, which is rehydrated onto the woken run. Top-level `attributes` are rendered on the signal tag, and top-level `providerOptions` are merged into the signal payload on every fire.
68
+
69
+ ```ts
70
+ await mastra.heartbeats.create({
71
+ agentId: 'chef',
72
+ threadId,
73
+ resourceId,
74
+ cron: '*/5 * * * *',
75
+ prompt: 'Check in on the user',
76
+ tagName: 'check-in', // renders as <check-in>…</check-in>
77
+ attributes: { source: 'cron' },
78
+ providerOptions: { openai: { store: false } },
79
+ ifIdle: {
80
+ behavior: 'wake',
81
+ streamOptions: { requestContext: { locale: 'en-US' } },
82
+ },
83
+ });
84
+ ```
85
+
86
+ - Added storage-backed discovery of suspended agent runs, so human-in-the-loop approval UIs can recover a pending run after a page refresh or server restart. ([#17898](https://github.com/mastra-ai/mastra/pull/17898))
87
+
88
+ `agent.listSuspendedRuns()` lists runs waiting on a tool-call approval or on a tool that called `suspend()`. Unlike the in-memory `getActiveThreadRunId()`, it reads from storage, so it works after a restart and across multiple server instances:
89
+
90
+ ```ts
91
+ const { runs, total } = await agent.listSuspendedRuns({ threadId, resourceId });
92
+ if (runs[0]) {
93
+ // runs[0].toolCalls -> [{ toolCallId, toolName, args, requiresApproval }]
94
+ await agent.approveToolCall({ runId: runs[0].runId, toolCallId: runs[0].toolCalls[0].toolCallId });
95
+ }
96
+ ```
97
+
98
+ Supports `threadId`/`resourceId`/date filters and pagination, mirroring `listWorkflowRuns()`. The same surface is exposed over HTTP as `GET /agents/:agentId/suspended-runs` and on the client SDK as `agent.listSuspendedRuns()`; server-enforced request-context values take precedence over client query parameters, so clients cannot list runs outside their scope.
99
+
100
+ `sendToolApproval()` now falls back to this storage-backed discovery when no active run is found in memory for the thread, so approvals keep working after a restart. If several suspended runs match, it throws an error asking for a `toolCallId` to disambiguate.
101
+
102
+ **Why:** approval UIs previously had no public way to recover a suspended run after a refresh or restart, forcing apps to parse internal workflow snapshots.
103
+
104
+ ### Patch Changes
105
+
106
+ - Allow `'fs'` as an agent/scorer definition source in the server handlers and response schemas. File-based agents are registered with `source: 'fs'`, and the scorer/agent list endpoints now surface and validate that value instead of failing schema validation. ([#18609](https://github.com/mastra-ai/mastra/pull/18609))
107
+
108
+ ```ts
109
+ // GET /api/agents now returns file-based agents alongside code/stored ones:
110
+ {
111
+ "weather": { "name": "weather", "source": "fs" /* was rejected before */ }
112
+ }
113
+ ```
114
+
115
+ - Fixed inline skills (created via createSkill()) not appearing in the Dev Portal. The server now uses agent.listSkills() and agent.getSkill() which return both inline and workspace skills, instead of only querying workspace skills. ([#18569](https://github.com/mastra-ai/mastra/pull/18569))
116
+
117
+ - add Studio support for observational memory extractors ([#18655](https://github.com/mastra-ai/mastra/pull/18655))
118
+
119
+ Adds `bufferedObservationChunks` and extraction metadata to the buffer-status API and client types so extracted values flow through during live streaming. Renders observational memory indicators from a normalized cycle model that preserves extraction data across streaming, refetch, reload, activation, and failure transitions.
120
+
121
+ - Updated dependencies [[`b9a2961`](https://github.com/mastra-ai/mastra/commit/b9a2961c1be81e3639c0879e58588c26dd0ae866), [`b33c77d`](https://github.com/mastra-ai/mastra/commit/b33c77d5293f14a794f3ec38dc947a6676de2764), [`1274eb3`](https://github.com/mastra-ai/mastra/commit/1274eb3a9508f579ceb3187fbce34408222d4b71), [`cdd5f93`](https://github.com/mastra-ai/mastra/commit/cdd5f939cefa67390629704dce92563ccbf492b2), [`1274eb3`](https://github.com/mastra-ai/mastra/commit/1274eb3a9508f579ceb3187fbce34408222d4b71), [`0ac14ce`](https://github.com/mastra-ai/mastra/commit/0ac14cea48e1b0a7857782153c78f7242fdf7e1a), [`9566d27`](https://github.com/mastra-ai/mastra/commit/9566d27ead3d95bdbe5a69e5a082a68222829cf2), [`8be63b0`](https://github.com/mastra-ai/mastra/commit/8be63b015fb8d72cea1220f05e7dc3bb997cc249), [`1009f77`](https://github.com/mastra-ai/mastra/commit/1009f772aa40016b49267c8566d0c29f6a16aa3c), [`1b8728a`](https://github.com/mastra-ai/mastra/commit/1b8728a57fd844205a452b0b4216d20ff60c784a), [`23c31de`](https://github.com/mastra-ai/mastra/commit/23c31de96ed8153402dcf092ac84b27a0c3638c1), [`0368766`](https://github.com/mastra-ai/mastra/commit/0368766744c7ea3df4d6059e2cc15f7bdf55f5a6), [`6f578ac`](https://github.com/mastra-ai/mastra/commit/6f578acba84930b406b2a0700b17cfdfaf5aae56), [`345eecc`](https://github.com/mastra-ai/mastra/commit/345eecce6ba519b5d987f0e10b5de4c8e5734580), [`1917c53`](https://github.com/mastra-ai/mastra/commit/1917c53b19dac43926f29c496893b0686462dca4), [`c01012f`](https://github.com/mastra-ai/mastra/commit/c01012f50368d29eb3fc3764df42d48291973d23), [`705ba98`](https://github.com/mastra-ai/mastra/commit/705ba98726d388a596e896225f237907ca6807a9), [`95857bc`](https://github.com/mastra-ai/mastra/commit/95857bcd6669da7193f503e803f0d72a2bd66be6), [`e62c108`](https://github.com/mastra-ai/mastra/commit/e62c108409dfd6a6cac0a48ec39c5cc81d24fd52), [`2866f04`](https://github.com/mastra-ai/mastra/commit/2866f04953edb78c1637fa45cc53abe24122edcb), [`ee14cae`](https://github.com/mastra-ai/mastra/commit/ee14cae244805783bde518a6142de28b744b169c), [`e84e791`](https://github.com/mastra-ai/mastra/commit/e84e79174031d7bc8793ca6c805eb38b06e7cfb1), [`c2f0b7f`](https://github.com/mastra-ai/mastra/commit/c2f0b7f1370f4428d165f51f0d1d9a48331cc257), [`213feb8`](https://github.com/mastra-ai/mastra/commit/213feb87bfdd1d8ec00ea660e218f9bcfcb34e7b), [`58e287b`](https://github.com/mastra-ai/mastra/commit/58e287b1edaf978b13745a1795989cad3826e82b), [`e420b3c`](https://github.com/mastra-ai/mastra/commit/e420b3c3ffc98bbc5b791897ea390bb47af99696), [`be875ed`](https://github.com/mastra-ai/mastra/commit/be875ed43f856742ce58529f531b5ea0ae6911f3), [`9eefdc0`](https://github.com/mastra-ai/mastra/commit/9eefdc0ac03f989718c6d835334940a977938895), [`bfbbb01`](https://github.com/mastra-ai/mastra/commit/bfbbb01bd845ba54cdc0c678c277d08a7cb847e4), [`7d112ca`](https://github.com/mastra-ai/mastra/commit/7d112ca17078479b2659b88ba1c85b936cfc111c)]:
122
+ - @mastra/core@1.48.0
123
+
124
+ ## 1.48.0-alpha.10
125
+
126
+ ### Patch Changes
127
+
128
+ - add Studio support for observational memory extractors ([#18655](https://github.com/mastra-ai/mastra/pull/18655))
129
+
130
+ Adds `bufferedObservationChunks` and extraction metadata to the buffer-status API and client types so extracted values flow through during live streaming. Renders observational memory indicators from a normalized cycle model that preserves extraction data across streaming, refetch, reload, activation, and failure transitions.
131
+
132
+ - Updated dependencies [[`6f578ac`](https://github.com/mastra-ai/mastra/commit/6f578acba84930b406b2a0700b17cfdfaf5aae56), [`c01012f`](https://github.com/mastra-ai/mastra/commit/c01012f50368d29eb3fc3764df42d48291973d23), [`be875ed`](https://github.com/mastra-ai/mastra/commit/be875ed43f856742ce58529f531b5ea0ae6911f3), [`9eefdc0`](https://github.com/mastra-ai/mastra/commit/9eefdc0ac03f989718c6d835334940a977938895), [`7d112ca`](https://github.com/mastra-ai/mastra/commit/7d112ca17078479b2659b88ba1c85b936cfc111c)]:
133
+ - @mastra/core@1.48.0-alpha.10
134
+
135
+ ## 1.48.0-alpha.9
136
+
137
+ ### Patch Changes
138
+
139
+ - Updated dependencies [[`e84e791`](https://github.com/mastra-ai/mastra/commit/e84e79174031d7bc8793ca6c805eb38b06e7cfb1)]:
140
+ - @mastra/core@1.48.0-alpha.9
141
+
3
142
  ## 1.48.0-alpha.8
4
143
 
5
144
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunk5SZOGYYO_cjs = require('./chunk-5SZOGYYO.cjs');
3
+ var chunkFKM644Z6_cjs = require('./chunk-FKM644Z6.cjs');
4
4
  var chunkDN2NUSL2_cjs = require('./chunk-DN2NUSL2.cjs');
5
5
 
6
6
  // src/server/server-adapter/api-schema-manifest.ts
@@ -34,7 +34,7 @@ function inferResponseShape(responseSchema) {
34
34
  function isManifestRoute(route) {
35
35
  return route.responseType === "json" && !route.deprecated;
36
36
  }
37
- function buildApiSchemaManifest(routes = chunk5SZOGYYO_cjs.SERVER_ROUTES) {
37
+ function buildApiSchemaManifest(routes = chunkFKM644Z6_cjs.SERVER_ROUTES) {
38
38
  return {
39
39
  version: 1,
40
40
  routes: routes.filter(isManifestRoute).map((route) => {
@@ -54,5 +54,5 @@ function buildApiSchemaManifest(routes = chunk5SZOGYYO_cjs.SERVER_ROUTES) {
54
54
  }
55
55
 
56
56
  exports.buildApiSchemaManifest = buildApiSchemaManifest;
57
- //# sourceMappingURL=api-schema-manifest-OSFSFYKI.cjs.map
58
- //# sourceMappingURL=api-schema-manifest-OSFSFYKI.cjs.map
57
+ //# sourceMappingURL=api-schema-manifest-4VQSWI7S.cjs.map
58
+ //# sourceMappingURL=api-schema-manifest-4VQSWI7S.cjs.map
@@ -1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":"api-schema-manifest-OSFSFYKI.cjs","sourcesContent":["import type { JSONSchema7 } from '@mastra/schema-compat';\nimport { schemaToJsonSchema } from './openapi-utils';\nimport { SERVER_ROUTES } from './routes/index';\nimport type { ServerRoute } from './routes/index';\n\nexport interface ApiSchemaResponseShape {\n kind: 'array' | 'record' | 'object-property' | 'single' | 'unknown';\n listProperty?: string;\n paginationProperty?: string;\n}\n\nexport interface ApiSchemaManifestRoute {\n method: string;\n path: string;\n responseType: string;\n pathParamSchema?: JSONSchema7;\n queryParamSchema?: JSONSchema7;\n bodySchema?: JSONSchema7;\n responseSchema?: JSONSchema7;\n responseShape: ApiSchemaResponseShape;\n}\n\nexport interface ApiSchemaManifest {\n version: 1;\n routes: ApiSchemaManifestRoute[];\n}\n\nfunction convertSchema(schema: ServerRoute['bodySchema']): JSONSchema7 | undefined {\n return schema ? schemaToJsonSchema(schema) : undefined;\n}\n\nfunction asJsonSchema(value: unknown): JSONSchema7 | undefined {\n return value && typeof value === 'object' && !Array.isArray(value) ? (value as JSONSchema7) : undefined;\n}\n\nfunction schemaType(schema: JSONSchema7 | undefined): JSONSchema7['type'] | undefined {\n const type = schema?.type;\n return Array.isArray(type) ? type.find(Boolean) : type;\n}\n\nfunction inferResponseShape(responseSchema: JSONSchema7 | undefined): ApiSchemaResponseShape {\n if (!responseSchema) return { kind: 'unknown' };\n\n const type = schemaType(responseSchema);\n if (type === 'array') return { kind: 'array' };\n if (type !== 'object') return { kind: 'single' };\n\n const properties =\n responseSchema.properties && !Array.isArray(responseSchema.properties) ? responseSchema.properties : {};\n const propertyNames = Object.keys(properties);\n const paginationProperty = 'page' in properties ? 'page' : 'pagination' in properties ? 'pagination' : undefined;\n const listProperty = Object.entries(properties).find(\n ([, property]) => schemaType(asJsonSchema(property)) === 'array',\n )?.[0];\n\n if (listProperty && (paginationProperty || propertyNames.length <= 2)) {\n return { kind: 'object-property', listProperty, paginationProperty };\n }\n if (responseSchema.additionalProperties && propertyNames.length === 0) return { kind: 'record' };\n return { kind: 'single' };\n}\n\nfunction isManifestRoute(route: ServerRoute): boolean {\n return route.responseType === 'json' && !route.deprecated;\n}\n\nexport function buildApiSchemaManifest(routes: readonly ServerRoute[] = SERVER_ROUTES): ApiSchemaManifest {\n return {\n version: 1,\n routes: routes.filter(isManifestRoute).map(route => {\n const responseSchema = convertSchema(route.responseSchema);\n return {\n method: route.method,\n path: route.path,\n responseType: route.responseType,\n pathParamSchema: convertSchema(route.pathParamSchema),\n queryParamSchema: convertSchema(route.queryParamSchema),\n bodySchema: convertSchema(route.bodySchema),\n responseSchema,\n responseShape: inferResponseShape(responseSchema),\n };\n }),\n };\n}\n"]}
1
+ {"version":3,"sources":["../src/server/server-adapter/api-schema-manifest.ts"],"names":["schemaToJsonSchema","SERVER_ROUTES"],"mappings":";;;;;;AA2BA,SAAS,cAAc,MAAA,EAA4D;AACjF,EAAA,OAAO,MAAA,GAASA,oCAAA,CAAmB,MAAM,CAAA,GAAI,MAAA;AAC/C;AAEA,SAAS,aAAa,KAAA,EAAyC;AAC7D,EAAA,OAAO,KAAA,IAAS,OAAO,KAAA,KAAU,QAAA,IAAY,CAAC,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,GAAK,KAAA,GAAwB,MAAA;AAChG;AAEA,SAAS,WAAW,MAAA,EAAkE;AACpF,EAAA,MAAM,OAAO,MAAA,EAAQ,IAAA;AACrB,EAAA,OAAO,MAAM,OAAA,CAAQ,IAAI,IAAI,IAAA,CAAK,IAAA,CAAK,OAAO,CAAA,GAAI,IAAA;AACpD;AAEA,SAAS,mBAAmB,cAAA,EAAiE;AAC3F,EAAA,IAAI,CAAC,cAAA,EAAgB,OAAO,EAAE,MAAM,SAAA,EAAU;AAE9C,EAAA,MAAM,IAAA,GAAO,WAAW,cAAc,CAAA;AACtC,EAAA,IAAI,IAAA,KAAS,OAAA,EAAS,OAAO,EAAE,MAAM,OAAA,EAAQ;AAC7C,EAAA,IAAI,IAAA,KAAS,QAAA,EAAU,OAAO,EAAE,M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;AAAA,QACL,QAAQ,KAAA,CAAM,MAAA;AAAA,QACd,MAAM,KAAA,CAAM,IAAA;AAAA,QACZ,cAAc,KAAA,CAAM,YAAA;AAAA,QACpB,eAAA,EAAiB,aAAA,CAAc,KAAA,CAAM,eAAe,CAAA;AAAA,QACpD,gBAAA,EAAkB,aAAA,CAAc,KAAA,CAAM,gBAAgB,CAAA;AAAA,QACtD,UAAA,EAAY,aAAA,CAAc,KAAA,CAAM,UAAU,CAAA;AAAA,QAC1C,cAAA;AAAA,QACA,aAAA,EAAe,mBAAmB,cAAc;AAAA,OAClD;AAAA,IACF,CAAC;AAAA,GACH;AACF","file":"api-schema-manifest-4VQSWI7S.cjs","sourcesContent":["import type { JSONSchema7 } from '@mastra/schema-compat';\nimport { schemaToJsonSchema } from './openapi-utils';\nimport { SERVER_ROUTES } from './routes/index';\nimport type { ServerRoute } from './routes/index';\n\nexport interface ApiSchemaResponseShape {\n kind: 'array' | 'record' | 'object-property' | 'single' | 'unknown';\n listProperty?: string;\n paginationProperty?: string;\n}\n\nexport interface ApiSchemaManifestRoute {\n method: string;\n path: string;\n responseType: string;\n pathParamSchema?: JSONSchema7;\n queryParamSchema?: JSONSchema7;\n bodySchema?: JSONSchema7;\n responseSchema?: JSONSchema7;\n responseShape: ApiSchemaResponseShape;\n}\n\nexport interface ApiSchemaManifest {\n version: 1;\n routes: ApiSchemaManifestRoute[];\n}\n\nfunction convertSchema(schema: ServerRoute['bodySchema']): JSONSchema7 | undefined {\n return schema ? schemaToJsonSchema(schema) : undefined;\n}\n\nfunction asJsonSchema(value: unknown): JSONSchema7 | undefined {\n return value && typeof value === 'object' && !Array.isArray(value) ? (value as JSONSchema7) : undefined;\n}\n\nfunction schemaType(schema: JSONSchema7 | undefined): JSONSchema7['type'] | undefined {\n const type = schema?.type;\n return Array.isArray(type) ? type.find(Boolean) : type;\n}\n\nfunction inferResponseShape(responseSchema: JSONSchema7 | undefined): ApiSchemaResponseShape {\n if (!responseSchema) return { kind: 'unknown' };\n\n const type = schemaType(responseSchema);\n if (type === 'array') return { kind: 'array' };\n if (type !== 'object') return { kind: 'single' };\n\n const properties =\n responseSchema.properties && !Array.isArray(responseSchema.properties) ? responseSchema.properties : {};\n const propertyNames = Object.keys(properties);\n const paginationProperty = 'page' in properties ? 'page' : 'pagination' in properties ? 'pagination' : undefined;\n const listProperty = Object.entries(properties).find(\n ([, property]) => schemaType(asJsonSchema(property)) === 'array',\n )?.[0];\n\n if (listProperty && (paginationProperty || propertyNames.length <= 2)) {\n return { kind: 'object-property', listProperty, paginationProperty };\n }\n if (responseSchema.additionalProperties && propertyNames.length === 0) return { kind: 'record' };\n return { kind: 'single' };\n}\n\nfunction isManifestRoute(route: ServerRoute): boolean {\n return route.responseType === 'json' && !route.deprecated;\n}\n\nexport function buildApiSchemaManifest(routes: readonly ServerRoute[] = SERVER_ROUTES): ApiSchemaManifest {\n return {\n version: 1,\n routes: routes.filter(isManifestRoute).map(route => {\n const responseSchema = convertSchema(route.responseSchema);\n return {\n method: route.method,\n path: route.path,\n responseType: route.responseType,\n pathParamSchema: convertSchema(route.pathParamSchema),\n queryParamSchema: convertSchema(route.queryParamSchema),\n bodySchema: convertSchema(route.bodySchema),\n responseSchema,\n responseShape: inferResponseShape(responseSchema),\n };\n }),\n };\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { SERVER_ROUTES } from './chunk-XJLHTR7T.js';
1
+ import { SERVER_ROUTES } from './chunk-V4X6NCFW.js';
2
2
  import { schemaToJsonSchema } from './chunk-Z5MTOVTR.js';
3
3
 
4
4
  // src/server/server-adapter/api-schema-manifest.ts
@@ -52,5 +52,5 @@ function buildApiSchemaManifest(routes = SERVER_ROUTES) {
52
52
  }
53
53
 
54
54
  export { buildApiSchemaManifest };
55
- //# sourceMappingURL=api-schema-manifest-YKMSPSZR.js.map
56
- //# sourceMappingURL=api-schema-manifest-YKMSPSZR.js.map
55
+ //# sourceMappingURL=api-schema-manifest-RP35YQV7.js.map
56
+ //# sourceMappingURL=api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"api-schema-manifest-YKMSPSZR.js","sourcesContent":["import type { JSONSchema7 } from '@mastra/schema-compat';\nimport { schemaToJsonSchema } from './openapi-utils';\nimport { SERVER_ROUTES } from './routes/index';\nimport type { ServerRoute } from './routes/index';\n\nexport interface ApiSchemaResponseShape {\n kind: 'array' | 'record' | 'object-property' | 'single' | 'unknown';\n listProperty?: string;\n paginationProperty?: string;\n}\n\nexport interface ApiSchemaManifestRoute {\n method: string;\n path: string;\n responseType: string;\n pathParamSchema?: JSONSchema7;\n queryParamSchema?: JSONSchema7;\n bodySchema?: JSONSchema7;\n responseSchema?: JSONSchema7;\n responseShape: ApiSchemaResponseShape;\n}\n\nexport interface ApiSchemaManifest {\n version: 1;\n routes: ApiSchemaManifestRoute[];\n}\n\nfunction convertSchema(schema: ServerRoute['bodySchema']): JSONSchema7 | undefined {\n return schema ? schemaToJsonSchema(schema) : undefined;\n}\n\nfunction asJsonSchema(value: unknown): JSONSchema7 | undefined {\n return value && typeof value === 'object' && !Array.isArray(value) ? (value as JSONSchema7) : undefined;\n}\n\nfunction schemaType(schema: JSONSchema7 | undefined): JSONSchema7['type'] | undefined {\n const type = schema?.type;\n return Array.isArray(type) ? type.find(Boolean) : type;\n}\n\nfunction inferResponseShape(responseSchema: JSONSchema7 | undefined): ApiSchemaResponseShape {\n if (!responseSchema) return { kind: 'unknown' };\n\n const type = schemaType(responseSchema);\n if (type === 'array') return { kind: 'array' };\n if (type !== 'object') return { kind: 'single' };\n\n const properties =\n responseSchema.properties && !Array.isArray(responseSchema.properties) ? responseSchema.properties : {};\n const propertyNames = Object.keys(properties);\n const paginationProperty = 'page' in properties ? 'page' : 'pagination' in properties ? 'pagination' : undefined;\n const listProperty = Object.entries(properties).find(\n ([, property]) => schemaType(asJsonSchema(property)) === 'array',\n )?.[0];\n\n if (listProperty && (paginationProperty || propertyNames.length <= 2)) {\n return { kind: 'object-property', listProperty, paginationProperty };\n }\n if (responseSchema.additionalProperties && propertyNames.length === 0) return { kind: 'record' };\n return { kind: 'single' };\n}\n\nfunction isManifestRoute(route: ServerRoute): boolean {\n return route.responseType === 'json' && !route.deprecated;\n}\n\nexport function buildApiSchemaManifest(routes: readonly ServerRoute[] = SERVER_ROUTES): ApiSchemaManifest {\n return {\n version: 1,\n routes: routes.filter(isManifestRoute).map(route => {\n const responseSchema = convertSchema(route.responseSchema);\n return {\n method: route.method,\n path: route.path,\n responseType: route.responseType,\n pathParamSchema: convertSchema(route.pathParamSchema),\n queryParamSchema: convertSchema(route.queryParamSchema),\n bodySchema: convertSchema(route.bodySchema),\n responseSchema,\n responseShape: inferResponseShape(responseSchema),\n };\n }),\n };\n}\n"]}
1
+ {"version":3,"sources":["../src/server/server-adapter/api-schema-manifest.ts"],"names":[],"mappings":";;;;AA2BA,SAAS,cAAc,MAAA,EAA4D;AACjF,EAAA,OAAO,MAAA,GAAS,kBAAA,CAAmB,MAAM,CAAA,GAAI,MAAA;AAC/C;AAEA,SAAS,aAAa,KAAA,EAAyC;AAC7D,EAAA,OAAO,KAAA,IAAS,OAAO,KAAA,KAAU,QAAA,IAAY,CAAC,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,GAAK,KAAA,GAAwB,MAAA;AAChG;AAEA,SAAS,WAAW,MAAA,EAAkE;AACpF,EAAA,MAAM,OAAO,MAAA,EAAQ,IAAA;AACrB,EAAA,OAAO,MAAM,OAAA,CAAQ,IAAI,IAAI,IAAA,CAAK,IAAA,CAAK,OAAO,CAAA,GAAI,IAAA;AACpD;AAEA,SAAS,mBAAmB,cAAA,EAAiE;AAC3F,EAAA,IAAI,CAAC,cAAA,EAAgB,OAAO,EAAE,MAAM,SAAA,EAAU;AAE9C,EAAA,MAAM,IAAA,GAAO,WAAW,cAAc,CAAA;AACtC,EAAA,IAAI,IAAA,KAAS,OAAA,EAAS,OAAO,EAAE,MAAM,OAAA,EAAQ;AAC7C,EAAA,IAAI,IAAA,KAAS,QAAA,EAAU,OAAO,EAAE,MAAM,QAAA,EAAS;AAE/C,EAAA,MA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A;AAAA,QACd,MAAM,KAAA,CAAM,IAAA;AAAA,QACZ,cAAc,KAAA,CAAM,YAAA;AAAA,QACpB,eAAA,EAAiB,aAAA,CAAc,KAAA,CAAM,eAAe,CAAA;AAAA,QACpD,gBAAA,EAAkB,aAAA,CAAc,KAAA,CAAM,gBAAgB,CAAA;AAAA,QACtD,UAAA,EAAY,aAAA,CAAc,KAAA,CAAM,UAAU,CAAA;AAAA,QAC1C,cAAA;AAAA,QACA,aAAA,EAAe,mBAAmB,cAAc;AAAA,OAClD;AAAA,IACF,CAAC;AAAA,GACH;AACF","file":"api-schema-manifest-RP35YQV7.js","sourcesContent":["import type { JSONSchema7 } from '@mastra/schema-compat';\nimport { schemaToJsonSchema } from './openapi-utils';\nimport { SERVER_ROUTES } from './routes/index';\nimport type { ServerRoute } from './routes/index';\n\nexport interface ApiSchemaResponseShape {\n kind: 'array' | 'record' | 'object-property' | 'single' | 'unknown';\n listProperty?: string;\n paginationProperty?: string;\n}\n\nexport interface ApiSchemaManifestRoute {\n method: string;\n path: string;\n responseType: string;\n pathParamSchema?: JSONSchema7;\n queryParamSchema?: JSONSchema7;\n bodySchema?: JSONSchema7;\n responseSchema?: JSONSchema7;\n responseShape: ApiSchemaResponseShape;\n}\n\nexport interface ApiSchemaManifest {\n version: 1;\n routes: ApiSchemaManifestRoute[];\n}\n\nfunction convertSchema(schema: ServerRoute['bodySchema']): JSONSchema7 | undefined {\n return schema ? schemaToJsonSchema(schema) : undefined;\n}\n\nfunction asJsonSchema(value: unknown): JSONSchema7 | undefined {\n return value && typeof value === 'object' && !Array.isArray(value) ? (value as JSONSchema7) : undefined;\n}\n\nfunction schemaType(schema: JSONSchema7 | undefined): JSONSchema7['type'] | undefined {\n const type = schema?.type;\n return Array.isArray(type) ? type.find(Boolean) : type;\n}\n\nfunction inferResponseShape(responseSchema: JSONSchema7 | undefined): ApiSchemaResponseShape {\n if (!responseSchema) return { kind: 'unknown' };\n\n const type = schemaType(responseSchema);\n if (type === 'array') return { kind: 'array' };\n if (type !== 'object') return { kind: 'single' };\n\n const properties =\n responseSchema.properties && !Array.isArray(responseSchema.properties) ? responseSchema.properties : {};\n const propertyNames = Object.keys(properties);\n const paginationProperty = 'page' in properties ? 'page' : 'pagination' in properties ? 'pagination' : undefined;\n const listProperty = Object.entries(properties).find(\n ([, property]) => schemaType(asJsonSchema(property)) === 'array',\n )?.[0];\n\n if (listProperty && (paginationProperty || propertyNames.length <= 2)) {\n return { kind: 'object-property', listProperty, paginationProperty };\n }\n if (responseSchema.additionalProperties && propertyNames.length === 0) return { kind: 'record' };\n return { kind: 'single' };\n}\n\nfunction isManifestRoute(route: ServerRoute): boolean {\n return route.responseType === 'json' && !route.deprecated;\n}\n\nexport function buildApiSchemaManifest(routes: readonly ServerRoute[] = SERVER_ROUTES): ApiSchemaManifest {\n return {\n version: 1,\n routes: routes.filter(isManifestRoute).map(route => {\n const responseSchema = convertSchema(route.responseSchema);\n return {\n method: route.method,\n path: route.path,\n responseType: route.responseType,\n pathParamSchema: convertSchema(route.pathParamSchema),\n queryParamSchema: convertSchema(route.queryParamSchema),\n bodySchema: convertSchema(route.bodySchema),\n responseSchema,\n responseShape: inferResponseShape(responseSchema),\n };\n }),\n };\n}\n"]}