@mastra/ai-sdk 0.0.0-message-file-url-handling-fix-20250904234524 → 0.0.0-rag-chunk-extract-llm-option-20250926183645

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,9 +1,67 @@
1
1
  # @mastra/ai-sdk
2
2
 
3
- ## 0.0.0-message-file-url-handling-fix-20250904234524
3
+ ## 0.0.0-rag-chunk-extract-llm-option-20250926183645
4
4
 
5
5
  ### Patch Changes
6
6
 
7
+ - Update peer deps ([#8154](https://github.com/mastra-ai/mastra/pull/8154))
8
+
9
+ - Updated dependencies [[`dc099b4`](https://github.com/mastra-ai/mastra/commit/dc099b40fb31147ba3f362f98d991892033c4c67), [`504438b`](https://github.com/mastra-ai/mastra/commit/504438b961bde211071186bba63a842c4e3db879), [`b342a68`](https://github.com/mastra-ai/mastra/commit/b342a68e1399cf1ece9ba11bda112db89d21118c), [`303a9c0`](https://github.com/mastra-ai/mastra/commit/303a9c0d7dd58795915979f06a0512359e4532fb), [`370f8a6`](https://github.com/mastra-ai/mastra/commit/370f8a6480faec70fef18d72e5f7538f27004301), [`809eea0`](https://github.com/mastra-ai/mastra/commit/809eea092fa80c3f69b9eaf078d843b57fd2a88e), [`623ffaf`](https://github.com/mastra-ai/mastra/commit/623ffaf2d969e11e99a0224633cf7b5a0815c857), [`9fc1613`](https://github.com/mastra-ai/mastra/commit/9fc16136400186648880fd990119ac15f7c02ee4), [`61f62aa`](https://github.com/mastra-ai/mastra/commit/61f62aa31bc88fe4ddf8da6240dbcfbeb07358bd), [`db1891a`](https://github.com/mastra-ai/mastra/commit/db1891a4707443720b7cd8a260dc7e1d49b3609c), [`3e292ba`](https://github.com/mastra-ai/mastra/commit/3e292ba00837886d5d68a34cbc0d9b703c991883), [`418c136`](https://github.com/mastra-ai/mastra/commit/418c1366843d88e491bca3f87763899ce855ca29), [`c84b7d0`](https://github.com/mastra-ai/mastra/commit/c84b7d093c4657772140cbfd2b15ef72f3315ed5)]:
10
+ - @mastra/core@0.0.0-rag-chunk-extract-llm-option-20250926183645
11
+
12
+ ## 0.0.4
13
+
14
+ ### Patch Changes
15
+
16
+ - fix: result object type inference when using structuredOutput and unify output/structuredOutput types with single OUTPUT generic ([#7969](https://github.com/mastra-ai/mastra/pull/7969))
17
+
18
+ - Update Peerdeps for packages based on core minor bump ([#8025](https://github.com/mastra-ai/mastra/pull/8025))
19
+
20
+ - Updated dependencies [[`cf34503`](https://github.com/mastra-ai/mastra/commit/cf345031de4e157f29087946449e60b965e9c8a9), [`6b4b1e4`](https://github.com/mastra-ai/mastra/commit/6b4b1e4235428d39e51cbda9832704c0ba70ab32), [`3469fca`](https://github.com/mastra-ai/mastra/commit/3469fca7bb7e5e19369ff9f7044716a5e4b02585), [`a61f23f`](https://github.com/mastra-ai/mastra/commit/a61f23fbbca4b88b763d94f1d784c47895ed72d7), [`4b339b8`](https://github.com/mastra-ai/mastra/commit/4b339b8141c20d6a6d80583c7e8c5c05d8c19492), [`d1dc606`](https://github.com/mastra-ai/mastra/commit/d1dc6067b0557a71190b68d56ee15b48c26d2411), [`c45298a`](https://github.com/mastra-ai/mastra/commit/c45298a0a0791db35cf79f1199d77004da0704cb), [`c4a8204`](https://github.com/mastra-ai/mastra/commit/c4a82046bfd241d6044e234bc5917d5a01fe6b55), [`d3bd4d4`](https://github.com/mastra-ai/mastra/commit/d3bd4d482a685bbb67bfa89be91c90dca3fa71ad), [`c591dfc`](https://github.com/mastra-ai/mastra/commit/c591dfc1e600fae1dedffe239357d250e146378f), [`1920c5c`](https://github.com/mastra-ai/mastra/commit/1920c5c6d666f687785c73021196aa551e579e0d), [`b6a3b65`](https://github.com/mastra-ai/mastra/commit/b6a3b65d830fa0ca7754ad6481661d1f2c878f21), [`af3abb6`](https://github.com/mastra-ai/mastra/commit/af3abb6f7c7585d856e22d27f4e7d2ece2186b9a)]:
21
+ - @mastra/core@0.18.0
22
+
23
+ ## 0.0.4-alpha.1
24
+
25
+ ### Patch Changes
26
+
27
+ - Update Peerdeps for packages based on core minor bump ([#8025](https://github.com/mastra-ai/mastra/pull/8025))
28
+
29
+ - Updated dependencies [[`cf34503`](https://github.com/mastra-ai/mastra/commit/cf345031de4e157f29087946449e60b965e9c8a9), [`6b4b1e4`](https://github.com/mastra-ai/mastra/commit/6b4b1e4235428d39e51cbda9832704c0ba70ab32), [`3469fca`](https://github.com/mastra-ai/mastra/commit/3469fca7bb7e5e19369ff9f7044716a5e4b02585), [`c4a8204`](https://github.com/mastra-ai/mastra/commit/c4a82046bfd241d6044e234bc5917d5a01fe6b55)]:
30
+ - @mastra/core@0.18.0-alpha.2
31
+
32
+ ## 0.0.4-alpha.0
33
+
34
+ ### Patch Changes
35
+
36
+ - fix: result object type inference when using structuredOutput and unify output/structuredOutput types with single OUTPUT generic ([#7969](https://github.com/mastra-ai/mastra/pull/7969))
37
+
38
+ - Updated dependencies [[`a61f23f`](https://github.com/mastra-ai/mastra/commit/a61f23fbbca4b88b763d94f1d784c47895ed72d7), [`d1dc606`](https://github.com/mastra-ai/mastra/commit/d1dc6067b0557a71190b68d56ee15b48c26d2411), [`d3bd4d4`](https://github.com/mastra-ai/mastra/commit/d3bd4d482a685bbb67bfa89be91c90dca3fa71ad)]:
39
+ - @mastra/core@0.17.2-alpha.0
40
+
41
+ ## 0.0.3
42
+
43
+ ### Patch Changes
44
+
45
+ - Update peerdep of @mastra/core ([#7619](https://github.com/mastra-ai/mastra/pull/7619))
46
+
47
+ - Updated dependencies [[`197cbb2`](https://github.com/mastra-ai/mastra/commit/197cbb248fc8cb4bbf61bf70b770f1388b445df2), [`a1bb887`](https://github.com/mastra-ai/mastra/commit/a1bb887e8bfae44230f487648da72e96ef824561), [`6590763`](https://github.com/mastra-ai/mastra/commit/65907630ef4bf4127067cecd1cb21b56f55d5f1b), [`fb84c21`](https://github.com/mastra-ai/mastra/commit/fb84c21859d09bdc8f158bd5412bdc4b5835a61c), [`5802bf5`](https://github.com/mastra-ai/mastra/commit/5802bf57f6182e4b67c28d7d91abed349a8d14f3), [`5bda53a`](https://github.com/mastra-ai/mastra/commit/5bda53a9747bfa7d876d754fc92c83a06e503f62), [`c2eade3`](https://github.com/mastra-ai/mastra/commit/c2eade3508ef309662f065e5f340d7840295dd53), [`f26a8fd`](https://github.com/mastra-ai/mastra/commit/f26a8fd99fcb0497a5d86c28324430d7f6a5fb83), [`222965a`](https://github.com/mastra-ai/mastra/commit/222965a98ce8197b86673ec594244650b5960257), [`6047778`](https://github.com/mastra-ai/mastra/commit/6047778e501df460648f31decddf8e443f36e373), [`a0f5f1c`](https://github.com/mastra-ai/mastra/commit/a0f5f1ca39c3c5c6d26202e9fcab986b4fe14568), [`9d4fc09`](https://github.com/mastra-ai/mastra/commit/9d4fc09b2ad55caa7738c7ceb3a905e454f74cdd), [`05c7abf`](https://github.com/mastra-ai/mastra/commit/05c7abfe105a015b7760c9bf33ff4419727502a0), [`0324ceb`](https://github.com/mastra-ai/mastra/commit/0324ceb8af9d16c12a531f90e575f6aab797ac81), [`d75ccf0`](https://github.com/mastra-ai/mastra/commit/d75ccf06dfd2582b916aa12624e3cd61b279edf1), [`0f9d227`](https://github.com/mastra-ai/mastra/commit/0f9d227890a98db33865abbea39daf407cd55ef7), [`b356f5f`](https://github.com/mastra-ai/mastra/commit/b356f5f7566cb3edb755d91f00b72fc1420b2a37), [`de056a0`](https://github.com/mastra-ai/mastra/commit/de056a02cbb43f6aa0380ab2150ea404af9ec0dd), [`f5ce05f`](https://github.com/mastra-ai/mastra/commit/f5ce05f831d42c69559bf4c0fdb46ccb920fc3a3), [`60c9cec`](https://github.com/mastra-ai/mastra/commit/60c9cec7048a79a87440f7840c383875bd710d93), [`c93532a`](https://github.com/mastra-ai/mastra/commit/c93532a340b80e4dd946d4c138d9381de5f70399), [`6cb1fcb`](https://github.com/mastra-ai/mastra/commit/6cb1fcbc8d0378ffed0d17784c96e68f30cb0272), [`aee4f00`](https://github.com/mastra-ai/mastra/commit/aee4f00e61e1a42e81a6d74ff149dbe69e32695a), [`9f6f30f`](https://github.com/mastra-ai/mastra/commit/9f6f30f04ec6648bbca798ea8aad59317c40d8db), [`547c621`](https://github.com/mastra-ai/mastra/commit/547c62104af3f7a551b3754e9cbdf0a3fbba15e4), [`897995e`](https://github.com/mastra-ai/mastra/commit/897995e630d572fe2891e7ede817938cabb43251), [`0fed8f2`](https://github.com/mastra-ai/mastra/commit/0fed8f2aa84b167b3415ea6f8f70755775132c8d), [`4f9ea8c`](https://github.com/mastra-ai/mastra/commit/4f9ea8c95ea74ba9abbf3b2ab6106c7d7bc45689), [`1a1fbe6`](https://github.com/mastra-ai/mastra/commit/1a1fbe66efb7d94abc373ed0dd9676adb8122454), [`d706fad`](https://github.com/mastra-ai/mastra/commit/d706fad6e6e4b72357b18d229ba38e6c913c0e70), [`87fd07f`](https://github.com/mastra-ai/mastra/commit/87fd07ff35387a38728967163460231b5d33ae3b), [`5c3768f`](https://github.com/mastra-ai/mastra/commit/5c3768fa959454232ad76715c381f4aac00c6881), [`2685a78`](https://github.com/mastra-ai/mastra/commit/2685a78f224b8b04e20d4fab5ac1adb638190071), [`36f39c0`](https://github.com/mastra-ai/mastra/commit/36f39c00dc794952dc3c11aab91c2fa8bca74b11), [`239b5a4`](https://github.com/mastra-ai/mastra/commit/239b5a497aeae2e8b4d764f46217cfff2284788e), [`8a3f5e4`](https://github.com/mastra-ai/mastra/commit/8a3f5e4212ec36b302957deb4bd47005ab598382)]:
48
+ - @mastra/core@0.17.0
49
+
50
+ ## 0.0.3-alpha.0
51
+
52
+ ### Patch Changes
53
+
54
+ - Update peerdep of @mastra/core ([#7619](https://github.com/mastra-ai/mastra/pull/7619))
55
+
56
+ - Updated dependencies [[`a1bb887`](https://github.com/mastra-ai/mastra/commit/a1bb887e8bfae44230f487648da72e96ef824561), [`a0f5f1c`](https://github.com/mastra-ai/mastra/commit/a0f5f1ca39c3c5c6d26202e9fcab986b4fe14568), [`b356f5f`](https://github.com/mastra-ai/mastra/commit/b356f5f7566cb3edb755d91f00b72fc1420b2a37), [`f5ce05f`](https://github.com/mastra-ai/mastra/commit/f5ce05f831d42c69559bf4c0fdb46ccb920fc3a3), [`9f6f30f`](https://github.com/mastra-ai/mastra/commit/9f6f30f04ec6648bbca798ea8aad59317c40d8db), [`d706fad`](https://github.com/mastra-ai/mastra/commit/d706fad6e6e4b72357b18d229ba38e6c913c0e70), [`5c3768f`](https://github.com/mastra-ai/mastra/commit/5c3768fa959454232ad76715c381f4aac00c6881), [`8a3f5e4`](https://github.com/mastra-ai/mastra/commit/8a3f5e4212ec36b302957deb4bd47005ab598382)]:
57
+ - @mastra/core@0.17.0-alpha.3
58
+
59
+ ## 0.0.2
60
+
61
+ ### Patch Changes
62
+
63
+ - 376913a: Update peerdeps
64
+ - Updated dependencies [8fbf79e]
7
65
  - Updated dependencies [fd83526]
8
66
  - Updated dependencies [d0b90ab]
9
67
  - Updated dependencies [6f5eb7a]
@@ -11,9 +69,16 @@
11
69
  - Updated dependencies [a9e50ee]
12
70
  - Updated dependencies [5397eb4]
13
71
  - Updated dependencies [c9f4e4a]
14
- - Updated dependencies [b586a0b]
15
72
  - Updated dependencies [0acbc80]
16
- - @mastra/core@0.0.0-message-file-url-handling-fix-20250904234524
73
+ - @mastra/core@0.16.0
74
+
75
+ ## 0.0.2-alpha.0
76
+
77
+ ### Patch Changes
78
+
79
+ - 376913a: Update peerdeps
80
+ - Updated dependencies [8fbf79e]
81
+ - @mastra/core@0.16.0-alpha.1
17
82
 
18
83
  ## 0.0.1
19
84
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":["registerApiRoute"],"mappings":";;;;;AAuBO,SAAS,SAAA,CAGd;AAAA,EACA,IAAA,GAAO,gBAAA;AAAA,EACP,KAAA;AAAA,EACA;AACF,CAAA,EAAqF;AACnF,EAAA,IAAI,CAAC,KAAA,IAAS,CAAC,IAAA,CAAK,QAAA,CAAS,WAAW,CAAA,EAAG;AACzC,IAAA,MAAM,IAAI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qGAAA;AAAA,SACF;AAAA,MACJ;AAEA,MAAA,IAAI,CAAC,UAAA,EAAY;AACf,QAAA,MAAM,IAAI,MAAM,sBAAsB,CAAA;AAAA,MACxC;AAEA,MAAA,MAAM,QAAA,GAAW,MAAA,CAAO,QAAA,CAAS,UAAU,CAAA;AAC3C,MAAA,IAAI,CAAC,QAAA,EAAU;AACb,QAAA,MAAM,IAAI,KAAA,CAAM,CAAA,MAAA,EAAS,UAAU,CAAA,UAAA,CAAY,CAAA;AAAA,MACjD;AAEA,MAAA,MAAM,MAAA,GAAS,MAAM,QAAA,CAAS,WAAA,CAA+B,QAAA,EAAU;AAAA,QACrE,GAAG,cAAA;AAAA,QACH,GAAG,IAAA;AAAA,QACH,MAAA,EAAQ;AAAA,OACT,CAAA;AAED,MAAA,OAAO,OAAO,yBAAA,EAA0B;AAAA,IAC1C;AAAA,GACD,CAAA;AACH","file":"index.cjs","sourcesContent":["import type { AgentExecutionOptions } from '@mastra/core/agent';\nimport { registerApiRoute } from '@mastra/core/server';\nimport type { OutputSchema } from '@mastra/core/stream';\nimport type { JSONSchema7 } from 'json-schema';\nimport type { ZodSchema } from 'zod/v3';\nimport type { ZodAny } from 'zod/v4';\n\nexport type chatRouteOptions<\n OUTPUT extends OutputSchema | undefined = undefined,\n STRUCTURED_OUTPUT extends ZodSchema | ZodAny | JSONSchema7 | undefined = undefined,\n> = {\n defaultOptions?: AgentExecutionOptions<OUTPUT, STRUCTURED_OUTPUT, 'aisdk'>;\n} & (\n | {\n path: `${string}:agentId${string}`;\n agent?: never;\n }\n | {\n path: string;\n agent: string;\n }\n);\n\nexport function chatRoute<\n OUTPUT extends OutputSchema | undefined = undefined,\n STRUCTURED_OUTPUT extends ZodSchema | ZodAny | JSONSchema7 | undefined = undefined,\n>({\n path = '/chat/:agentId',\n agent,\n defaultOptions,\n}: chatRouteOptions<OUTPUT, STRUCTURED_OUTPUT>): ReturnType<typeof registerApiRoute> {\n if (!agent && !path.includes('/:agentId')) {\n throw new Error('Path must include :agentId to route to the correct agent or pass the agent explicitly');\n }\n\n return registerApiRoute(path, {\n method: 'POST',\n openapi: {\n summary: 'Chat with an agent',\n description: 'Send messages to an agent and stream the response in the AI SDK format',\n tags: ['ai-sdk'],\n parameters: [\n {\n name: 'agentId',\n in: 'path',\n required: true,\n description: 'The ID of the agent to chat with',\n schema: {\n type: 'string',\n },\n },\n ],\n requestBody: {\n required: true,\n content: {\n 'application/json': {\n schema: {\n type: 'object',\n properties: {\n messages: {\n type: 'array',\n description: 'Array of messages in the conversation',\n items: {\n type: 'object',\n properties: {\n role: {\n type: 'string',\n enum: ['user', 'assistant', 'system'],\n description: 'The role of the message sender',\n },\n content: {\n type: 'string',\n description: 'The content of the message',\n },\n },\n required: ['role', 'content'],\n },\n },\n },\n required: ['messages'],\n },\n },\n },\n },\n responses: {\n '200': {\n description: 'Streaming response from the agent',\n content: {\n 'text/plain': {\n schema: {\n type: 'string',\n description: 'Server-sent events stream containing the agent response',\n },\n },\n },\n },\n '400': {\n description: 'Bad request - invalid input',\n content: {\n 'application/json': {\n schema: {\n type: 'object',\n properties: {\n error: {\n type: 'string',\n },\n },\n },\n },\n },\n },\n '404': {\n description: 'Agent not found',\n content: {\n 'application/json': {\n schema: {\n type: 'object',\n properties: {\n error: {\n type: 'string',\n },\n },\n },\n },\n },\n },\n },\n },\n handler: async c => {\n const { messages, ...rest } = await c.req.json();\n const mastra = c.get('mastra');\n\n let agentToUse: string | undefined = agent;\n if (!agent) {\n const agentId = c.req.param('agentId');\n agentToUse = agentId;\n }\n\n if (c.req.param('agentId') && agent) {\n mastra\n .getLogger()\n ?.warn(\n `Fixed agent ID was set together with an agentId path parameter. This can lead to unexpected behavior.`,\n );\n }\n\n if (!agentToUse) {\n throw new Error('Agent ID is required');\n }\n\n const agentObj = mastra.getAgent(agentToUse);\n if (!agentObj) {\n throw new Error(`Agent ${agentToUse} not found`);\n }\n\n const result = await agentObj.streamVNext<any, any, 'aisdk'>(messages, {\n ...defaultOptions,\n ...rest,\n format: 'aisdk',\n });\n\n return result.toUIMessageStreamResponse();\n },\n });\n}\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":["registerApiRoute"],"mappings":";;;;;AAiBO,SAAS,SAAA,CAAmD;AAAA,EACjE,IAAA,GAAO,gBAAA;AAAA,EACP,KAAA;AAAA,EACA;AACF,CAAA,EAAkE;AAChE,EAAA,IAAI,CAAC,KAAA,IAAS,CAAC,IAAA,CAAK,QAAA,CAAS,WAAW,CAAA,EAAG;AACzC,IAAA,MAAM,IAAI,MAAM,uFAAuF,CAAA;AAAA,EACzG;AAEA,EAAA,OAAOA,wBAAiB,IAAA,EAAM;AAAA,IAC5B,MAAA,EAAQ,MAAA;AAAA,IACR,OAAA,EAAS;AAAA,MACP,OAAA,EAAS,oBAAA;AAAA,MACT,WAAA,EAAa,wEAAA;AAAA,MACb,IAAA,EAAM,CAAC,QAAQ,CAAA;AAAA,MACf,UAAA,EAAY;AAAA,QACV;AAAA,UACE,IAAA,EAAM,SAAA;AAAA,UACN,EAAA,EAAI,MAAA;AAAA,UACJ,QAAA,EAAU,IAAA;AAAA,UACV,WAAA,EAAa,kCAAA;AAAA,UACb,MAAA,EAAQ;AAAA,YACN,IAAA,EAAM;AAAA;AACR;AACF,OACF;AAAA,MACA,WAAA,EAAa;AAAA,QACX,QAAA,EAAU,IAAA;AAAA,QACV,OAAA,EAAS;AAAA,UACP,kBAAA,EAAoB;AAAA,YAClB,MAAA,EAAQ;AAAA,cACN,IAAA,EAAM,QAAA;AAAA,cACN,UAAA,EAAY;AAAA,gBACV,QAAA,EAAU;AAAA,kBACR,IAAA,EAAM,OAAA;AAAA,kBACN,WAAA,EAAa,uCAAA;AAAA,kBACb,KAAA,EAAO;AAAA,oBACL,IAAA,EAAM,QAAA;AAAA,oBACN,UAAA,EAAY;AAAA,sBACV,IAAA,EAAM;AAAA,wBACJ,IAAA,EAAM,QAAA;AAAA,wBACN,IAAA,EAAM,CAAC,MAAA,EAAQ,WAAA,EAAa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AAA;AAE7B,MAAA,IAAI,UAAA,GAAiC,KAAA;AACrC,MAAA,IAAI,CAAC,KAAA,EAAO;AACV,QAAA,MAAM,OAAA,GAAU,CAAA,CAAE,GAAA,CAAI,KAAA,CAAM,SAAS,CAAA;AACrC,QAAA,UAAA,GAAa,OAAA;AAAA,MACf;AAEA,MAAA,IAAI,CAAA,CAAE,GAAA,CAAI,KAAA,CAAM,SAAS,KAAK,KAAA,EAAO;AACnC,QAAA,MAAA,CACG,WAAU,EACT,IAAA;AAAA,UACA,CAAA,qGAAA;AAAA,SACF;AAAA,MACJ;AAEA,MAAA,IAAI,CAAC,UAAA,EAAY;AACf,QAAA,MAAM,IAAI,MAAM,sBAAsB,CAAA;AAAA,MACxC;AAEA,MAAA,MAAM,QAAA,GAAW,MAAA,CAAO,QAAA,CAAS,UAAU,CAAA;AAC3C,MAAA,IAAI,CAAC,QAAA,EAAU;AACb,QAAA,MAAM,IAAI,KAAA,CAAM,CAAA,MAAA,EAAS,UAAU,CAAA,UAAA,CAAY,CAAA;AAAA,MACjD;AAEA,MAAA,MAAM,MAAA,GAAS,MAAM,QAAA,CAAS,WAAA,CAA6B,QAAA,EAAU;AAAA,QACnE,GAAG,cAAA;AAAA,QACH,GAAG,IAAA;AAAA,QACH,MAAA,EAAQ;AAAA,OACT,CAAA;AAED,MAAA,OAAO,OAAO,yBAAA,EAA0B;AAAA,IAC1C;AAAA,GACD,CAAA;AACH","file":"index.cjs","sourcesContent":["import type { AgentExecutionOptions } from '@mastra/core/agent';\nimport { registerApiRoute } from '@mastra/core/server';\nimport type { OutputSchema } from '@mastra/core/stream';\n\nexport type chatRouteOptions<OUTPUT extends OutputSchema = undefined> = {\n defaultOptions?: AgentExecutionOptions<OUTPUT, 'aisdk'>;\n} & (\n | {\n path: `${string}:agentId${string}`;\n agent?: never;\n }\n | {\n path: string;\n agent: string;\n }\n);\n\nexport function chatRoute<OUTPUT extends OutputSchema = undefined>({\n path = '/chat/:agentId',\n agent,\n defaultOptions,\n}: chatRouteOptions<OUTPUT>): ReturnType<typeof registerApiRoute> {\n if (!agent && !path.includes('/:agentId')) {\n throw new Error('Path must include :agentId to route to the correct agent or pass the agent explicitly');\n }\n\n return registerApiRoute(path, {\n method: 'POST',\n openapi: {\n summary: 'Chat with an agent',\n description: 'Send messages to an agent and stream the response in the AI SDK format',\n tags: ['ai-sdk'],\n parameters: [\n {\n name: 'agentId',\n in: 'path',\n required: true,\n description: 'The ID of the agent to chat with',\n schema: {\n type: 'string',\n },\n },\n ],\n requestBody: {\n required: true,\n content: {\n 'application/json': {\n schema: {\n type: 'object',\n properties: {\n messages: {\n type: 'array',\n description: 'Array of messages in the conversation',\n items: {\n type: 'object',\n properties: {\n role: {\n type: 'string',\n enum: ['user', 'assistant', 'system'],\n description: 'The role of the message sender',\n },\n content: {\n type: 'string',\n description: 'The content of the message',\n },\n },\n required: ['role', 'content'],\n },\n },\n },\n required: ['messages'],\n },\n },\n },\n },\n responses: {\n '200': {\n description: 'Streaming response from the agent',\n content: {\n 'text/plain': {\n schema: {\n type: 'string',\n description: 'Server-sent events stream containing the agent response',\n },\n },\n },\n },\n '400': {\n description: 'Bad request - invalid input',\n content: {\n 'application/json': {\n schema: {\n type: 'object',\n properties: {\n error: {\n type: 'string',\n },\n },\n },\n },\n },\n },\n '404': {\n description: 'Agent not found',\n content: {\n 'application/json': {\n schema: {\n type: 'object',\n properties: {\n error: {\n type: 'string',\n },\n },\n },\n },\n },\n },\n },\n },\n handler: async c => {\n const { messages, ...rest } = await c.req.json();\n const mastra = c.get('mastra');\n\n let agentToUse: string | undefined = agent;\n if (!agent) {\n const agentId = c.req.param('agentId');\n agentToUse = agentId;\n }\n\n if (c.req.param('agentId') && agent) {\n mastra\n .getLogger()\n ?.warn(\n `Fixed agent ID was set together with an agentId path parameter. This can lead to unexpected behavior.`,\n );\n }\n\n if (!agentToUse) {\n throw new Error('Agent ID is required');\n }\n\n const agentObj = mastra.getAgent(agentToUse);\n if (!agentObj) {\n throw new Error(`Agent ${agentToUse} not found`);\n }\n\n const result = await agentObj.streamVNext<OUTPUT, 'aisdk'>(messages, {\n ...defaultOptions,\n ...rest,\n format: 'aisdk',\n });\n\n return result.toUIMessageStreamResponse();\n },\n });\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -1,11 +1,8 @@
1
1
  import type { AgentExecutionOptions } from '@mastra/core/agent';
2
2
  import { registerApiRoute } from '@mastra/core/server';
3
3
  import type { OutputSchema } from '@mastra/core/stream';
4
- import type { JSONSchema7 } from 'json-schema';
5
- import type { ZodSchema } from 'zod/v3';
6
- import type { ZodAny } from 'zod/v4';
7
- export type chatRouteOptions<OUTPUT extends OutputSchema | undefined = undefined, STRUCTURED_OUTPUT extends ZodSchema | ZodAny | JSONSchema7 | undefined = undefined> = {
8
- defaultOptions?: AgentExecutionOptions<OUTPUT, STRUCTURED_OUTPUT, 'aisdk'>;
4
+ export type chatRouteOptions<OUTPUT extends OutputSchema = undefined> = {
5
+ defaultOptions?: AgentExecutionOptions<OUTPUT, 'aisdk'>;
9
6
  } & ({
10
7
  path: `${string}:agentId${string}`;
11
8
  agent?: never;
@@ -13,5 +10,5 @@ export type chatRouteOptions<OUTPUT extends OutputSchema | undefined = undefined
13
10
  path: string;
14
11
  agent: string;
15
12
  });
16
- export declare function chatRoute<OUTPUT extends OutputSchema | undefined = undefined, STRUCTURED_OUTPUT extends ZodSchema | ZodAny | JSONSchema7 | undefined = undefined>({ path, agent, defaultOptions, }: chatRouteOptions<OUTPUT, STRUCTURED_OUTPUT>): ReturnType<typeof registerApiRoute>;
13
+ export declare function chatRoute<OUTPUT extends OutputSchema = undefined>({ path, agent, defaultOptions, }: chatRouteOptions<OUTPUT>): ReturnType<typeof registerApiRoute>;
17
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;A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QACH,MAAA,EAAQ;AAAA,OACT,CAAA;AAED,MAAA,OAAO,OAAO,yBAAA,EAA0B;AAAA,IAC1C;AAAA,GACD,CAAA;AACH","file":"index.js","sourcesContent":["import type { AgentExecutionOptions } from '@mastra/core/agent';\nimport { registerApiRoute } from '@mastra/core/server';\nimport type { OutputSchema } from '@mastra/core/stream';\nimport type { JSONSchema7 } from 'json-schema';\nimport type { ZodSchema } from 'zod/v3';\nimport type { ZodAny } from 'zod/v4';\n\nexport type chatRouteOptions<\n OUTPUT extends OutputSchema | undefined = undefined,\n STRUCTURED_OUTPUT extends ZodSchema | ZodAny | JSONSchema7 | undefined = undefined,\n> = {\n defaultOptions?: AgentExecutionOptions<OUTPUT, STRUCTURED_OUTPUT, 'aisdk'>;\n} & (\n | {\n path: `${string}:agentId${string}`;\n agent?: never;\n }\n | {\n path: string;\n agent: string;\n }\n);\n\nexport function chatRoute<\n OUTPUT extends OutputSchema | undefined = undefined,\n STRUCTURED_OUTPUT extends ZodSchema | ZodAny | JSONSchema7 | undefined = undefined,\n>({\n path = '/chat/:agentId',\n agent,\n defaultOptions,\n}: chatRouteOptions<OUTPUT, STRUCTURED_OUTPUT>): ReturnType<typeof registerApiRoute> {\n if (!agent && !path.includes('/:agentId')) {\n throw new Error('Path must include :agentId to route to the correct agent or pass the agent explicitly');\n }\n\n return registerApiRoute(path, {\n method: 'POST',\n openapi: {\n summary: 'Chat with an agent',\n description: 'Send messages to an agent and stream the response in the AI SDK format',\n tags: ['ai-sdk'],\n parameters: [\n {\n name: 'agentId',\n in: 'path',\n required: true,\n description: 'The ID of the agent to chat with',\n schema: {\n type: 'string',\n },\n },\n ],\n requestBody: {\n required: true,\n content: {\n 'application/json': {\n schema: {\n type: 'object',\n properties: {\n messages: {\n type: 'array',\n description: 'Array of messages in the conversation',\n items: {\n type: 'object',\n properties: {\n role: {\n type: 'string',\n enum: ['user', 'assistant', 'system'],\n description: 'The role of the message sender',\n },\n content: {\n type: 'string',\n description: 'The content of the message',\n },\n },\n required: ['role', 'content'],\n },\n },\n },\n required: ['messages'],\n },\n },\n },\n },\n responses: {\n '200': {\n description: 'Streaming response from the agent',\n content: {\n 'text/plain': {\n schema: {\n type: 'string',\n description: 'Server-sent events stream containing the agent response',\n },\n },\n },\n },\n '400': {\n description: 'Bad request - invalid input',\n content: {\n 'application/json': {\n schema: {\n type: 'object',\n properties: {\n error: {\n type: 'string',\n },\n },\n },\n },\n },\n },\n '404': {\n description: 'Agent not found',\n content: {\n 'application/json': {\n schema: {\n type: 'object',\n properties: {\n error: {\n type: 'string',\n },\n },\n },\n },\n },\n },\n },\n },\n handler: async c => {\n const { messages, ...rest } = await c.req.json();\n const mastra = c.get('mastra');\n\n let agentToUse: string | undefined = agent;\n if (!agent) {\n const agentId = c.req.param('agentId');\n agentToUse = agentId;\n }\n\n if (c.req.param('agentId') && agent) {\n mastra\n .getLogger()\n ?.warn(\n `Fixed agent ID was set together with an agentId path parameter. This can lead to unexpected behavior.`,\n );\n }\n\n if (!agentToUse) {\n throw new Error('Agent ID is required');\n }\n\n const agentObj = mastra.getAgent(agentToUse);\n if (!agentObj) {\n throw new Error(`Agent ${agentToUse} not found`);\n }\n\n const result = await agentObj.streamVNext<any, any, 'aisdk'>(messages, {\n ...defaultOptions,\n ...rest,\n format: 'aisdk',\n });\n\n return result.toUIMessageStreamResponse();\n },\n });\n}\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;AAiBO,SAAS,SAAA,CAAmD;AAAA,EACjE,IAAA,GAAO,gBAAA;AAAA,EACP,KAAA;AAAA,EACA;AACF,CAAA,EAAkE;AAChE,EAAA,IAAI,CAAC,KAAA,IAAS,CAAC,IAAA,CAAK,QAAA,CAAS,WAAW,CAAA,EAAG;AACzC,IAAA,MAAM,IAAI,MAAM,uFAAuF,CAAA;AAAA,EACzG;AAEA,EAAA,OAAO,iBAAiB,IAAA,EAAM;AAAA,IAC5B,MAAA,EAAQ,MAAA;AAAA,IACR,OAAA,EAAS;A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AA,MAAM,QAAA,GAAW,MAAA,CAAO,QAAA,CAAS,UAAU,CAAA;AAC3C,MAAA,IAAI,CAAC,QAAA,EAAU;AACb,QAAA,MAAM,IAAI,KAAA,CAAM,CAAA,MAAA,EAAS,UAAU,CAAA,UAAA,CAAY,CAAA;AAAA,MACjD;AAEA,MAAA,MAAM,MAAA,GAAS,MAAM,QAAA,CAAS,WAAA,CAA6B,QAAA,EAAU;AAAA,QACnE,GAAG,cAAA;AAAA,QACH,GAAG,IAAA;AAAA,QACH,MAAA,EAAQ;AAAA,OACT,CAAA;AAED,MAAA,OAAO,OAAO,yBAAA,EAA0B;AAAA,IAC1C;AAAA,GACD,CAAA;AACH","file":"index.js","sourcesContent":["import type { AgentExecutionOptions } from '@mastra/core/agent';\nimport { registerApiRoute } from '@mastra/core/server';\nimport type { OutputSchema } from '@mastra/core/stream';\n\nexport type chatRouteOptions<OUTPUT extends OutputSchema = undefined> = {\n defaultOptions?: AgentExecutionOptions<OUTPUT, 'aisdk'>;\n} & (\n | {\n path: `${string}:agentId${string}`;\n agent?: never;\n }\n | {\n path: string;\n agent: string;\n }\n);\n\nexport function chatRoute<OUTPUT extends OutputSchema = undefined>({\n path = '/chat/:agentId',\n agent,\n defaultOptions,\n}: chatRouteOptions<OUTPUT>): ReturnType<typeof registerApiRoute> {\n if (!agent && !path.includes('/:agentId')) {\n throw new Error('Path must include :agentId to route to the correct agent or pass the agent explicitly');\n }\n\n return registerApiRoute(path, {\n method: 'POST',\n openapi: {\n summary: 'Chat with an agent',\n description: 'Send messages to an agent and stream the response in the AI SDK format',\n tags: ['ai-sdk'],\n parameters: [\n {\n name: 'agentId',\n in: 'path',\n required: true,\n description: 'The ID of the agent to chat with',\n schema: {\n type: 'string',\n },\n },\n ],\n requestBody: {\n required: true,\n content: {\n 'application/json': {\n schema: {\n type: 'object',\n properties: {\n messages: {\n type: 'array',\n description: 'Array of messages in the conversation',\n items: {\n type: 'object',\n properties: {\n role: {\n type: 'string',\n enum: ['user', 'assistant', 'system'],\n description: 'The role of the message sender',\n },\n content: {\n type: 'string',\n description: 'The content of the message',\n },\n },\n required: ['role', 'content'],\n },\n },\n },\n required: ['messages'],\n },\n },\n },\n },\n responses: {\n '200': {\n description: 'Streaming response from the agent',\n content: {\n 'text/plain': {\n schema: {\n type: 'string',\n description: 'Server-sent events stream containing the agent response',\n },\n },\n },\n },\n '400': {\n description: 'Bad request - invalid input',\n content: {\n 'application/json': {\n schema: {\n type: 'object',\n properties: {\n error: {\n type: 'string',\n },\n },\n },\n },\n },\n },\n '404': {\n description: 'Agent not found',\n content: {\n 'application/json': {\n schema: {\n type: 'object',\n properties: {\n error: {\n type: 'string',\n },\n },\n },\n },\n },\n },\n },\n },\n handler: async c => {\n const { messages, ...rest } = await c.req.json();\n const mastra = c.get('mastra');\n\n let agentToUse: string | undefined = agent;\n if (!agent) {\n const agentId = c.req.param('agentId');\n agentToUse = agentId;\n }\n\n if (c.req.param('agentId') && agent) {\n mastra\n .getLogger()\n ?.warn(\n `Fixed agent ID was set together with an agentId path parameter. This can lead to unexpected behavior.`,\n );\n }\n\n if (!agentToUse) {\n throw new Error('Agent ID is required');\n }\n\n const agentObj = mastra.getAgent(agentToUse);\n if (!agentObj) {\n throw new Error(`Agent ${agentToUse} not found`);\n }\n\n const result = await agentObj.streamVNext<OUTPUT, 'aisdk'>(messages, {\n ...defaultOptions,\n ...rest,\n format: 'aisdk',\n });\n\n return result.toUIMessageStreamResponse();\n },\n });\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/ai-sdk",
3
- "version": "0.0.0-message-file-url-handling-fix-20250904234524",
3
+ "version": "0.0.0-rag-chunk-extract-llm-option-20250926183645",
4
4
  "description": "Adds custom API routes to be compatible with the AI SDK UI parts",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -23,18 +23,18 @@
23
23
  ],
24
24
  "peerDependencies": {
25
25
  "zod": "^3.25.0 || ^4.0.0",
26
- "@mastra/core": "0.0.0-message-file-url-handling-fix-20250904234524"
26
+ "@mastra/core": "0.0.0-rag-chunk-extract-llm-option-20250926183645"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/json-schema": "^7.0.15",
30
- "eslint": "^9.34.0",
30
+ "eslint": "^9.35.0",
31
31
  "tsup": "^8.5.0",
32
32
  "typescript": "^5.8.3",
33
33
  "vitest": "^3.2.4",
34
- "zod": "^3.25.67",
35
- "@internal/lint": "0.0.0-message-file-url-handling-fix-20250904234524",
36
- "@internal/types-builder": "0.0.0-message-file-url-handling-fix-20250904234524",
37
- "@mastra/core": "0.0.0-message-file-url-handling-fix-20250904234524"
34
+ "zod": "^3.25.76",
35
+ "@internal/lint": "0.0.0-rag-chunk-extract-llm-option-20250926183645",
36
+ "@mastra/core": "0.0.0-rag-chunk-extract-llm-option-20250926183645",
37
+ "@internal/types-builder": "0.0.0-rag-chunk-extract-llm-option-20250926183645"
38
38
  },
39
39
  "keywords": [
40
40
  "mastra",