@mastra/ai-sdk 0.0.1-alpha.0 → 0.0.1

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,5 +1,64 @@
1
1
  # @mastra/ai-sdk
2
2
 
3
+ ## 0.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - de3cbc6: Update the `package.json` file to include additional fields like `repository`, `homepage` or `files`.
8
+ - 9beaeff: Create new `@mastra/ai-sdk` package to better support `useChat()`
9
+ - Updated dependencies [ab48c97]
10
+ - Updated dependencies [85ef90b]
11
+ - Updated dependencies [aedbbfa]
12
+ - Updated dependencies [ff89505]
13
+ - Updated dependencies [637f323]
14
+ - Updated dependencies [de3cbc6]
15
+ - Updated dependencies [c19bcf7]
16
+ - Updated dependencies [4474d04]
17
+ - Updated dependencies [183dc95]
18
+ - Updated dependencies [a1111e2]
19
+ - Updated dependencies [b42a961]
20
+ - Updated dependencies [61debef]
21
+ - Updated dependencies [9beaeff]
22
+ - Updated dependencies [29de0e1]
23
+ - Updated dependencies [f643c65]
24
+ - Updated dependencies [00c74e7]
25
+ - Updated dependencies [fef7375]
26
+ - Updated dependencies [e3d8fea]
27
+ - Updated dependencies [45e4d39]
28
+ - Updated dependencies [9eee594]
29
+ - Updated dependencies [7149d8d]
30
+ - Updated dependencies [822c2e8]
31
+ - Updated dependencies [979912c]
32
+ - Updated dependencies [7dcf4c0]
33
+ - Updated dependencies [4106a58]
34
+ - Updated dependencies [ad78bfc]
35
+ - Updated dependencies [0302f50]
36
+ - Updated dependencies [6ac697e]
37
+ - Updated dependencies [74db265]
38
+ - Updated dependencies [0ce418a]
39
+ - Updated dependencies [af90672]
40
+ - Updated dependencies [8387952]
41
+ - Updated dependencies [7f3b8da]
42
+ - Updated dependencies [905352b]
43
+ - Updated dependencies [599d04c]
44
+ - Updated dependencies [56041d0]
45
+ - Updated dependencies [3412597]
46
+ - Updated dependencies [5eca5d2]
47
+ - Updated dependencies [f2cda47]
48
+ - Updated dependencies [5de1555]
49
+ - Updated dependencies [cfd377a]
50
+ - Updated dependencies [1ed5a3e]
51
+ - @mastra/core@0.15.3
52
+
53
+ ## 0.0.1-alpha.1
54
+
55
+ ### Patch Changes
56
+
57
+ - [#7343](https://github.com/mastra-ai/mastra/pull/7343) [`de3cbc6`](https://github.com/mastra-ai/mastra/commit/de3cbc61079211431bd30487982ea3653517278e) Thanks [@LekoArts](https://github.com/LekoArts)! - Update the `package.json` file to include additional fields like `repository`, `homepage` or `files`.
58
+
59
+ - Updated dependencies [[`85ef90b`](https://github.com/mastra-ai/mastra/commit/85ef90bb2cd4ae4df855c7ac175f7d392c55c1bf), [`de3cbc6`](https://github.com/mastra-ai/mastra/commit/de3cbc61079211431bd30487982ea3653517278e)]:
60
+ - @mastra/core@0.15.3-alpha.5
61
+
3
62
  ## 0.0.1-alpha.0
4
63
 
5
64
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/ai-sdk",
3
- "version": "0.0.1-alpha.0",
3
+ "version": "0.0.1",
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",
@@ -17,6 +17,10 @@
17
17
  },
18
18
  "./package.json": "./package.json"
19
19
  },
20
+ "files": [
21
+ "dist",
22
+ "CHANGELOG.md"
23
+ ],
20
24
  "peerDependencies": {
21
25
  "@mastra/core": ">=0.15.3-0 <0.16.0-0",
22
26
  "zod": "^3.25.0 || ^4.0.0"
@@ -28,13 +32,25 @@
28
32
  "typescript": "^5.8.3",
29
33
  "vitest": "^3.2.4",
30
34
  "zod": "^3.25.67",
31
- "@internal/lint": "0.0.34",
32
- "@internal/types-builder": "0.0.9",
33
- "@mastra/core": "0.15.3-alpha.4"
35
+ "@internal/types-builder": "0.0.10",
36
+ "@internal/lint": "0.0.35",
37
+ "@mastra/core": "0.15.3"
34
38
  },
35
- "keywords": [],
36
- "author": "",
39
+ "keywords": [
40
+ "mastra",
41
+ "ai-sdk",
42
+ "ai"
43
+ ],
37
44
  "license": "Apache-2.0",
45
+ "homepage": "https://mastra.ai",
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "git+https://github.com/mastra-ai/mastra.git",
49
+ "directory": "client-sdks/ai-sdk"
50
+ },
51
+ "bugs": {
52
+ "url": "https://github.com/mastra-ai/mastra/issues"
53
+ },
38
54
  "scripts": {
39
55
  "lint": "eslint .",
40
56
  "build": "tsup --config tsup.config.ts",
@@ -1,18 +0,0 @@
1
-
2
- > @mastra/ai-sdk@0.0.1-alpha.0 build /home/runner/work/mastra/mastra/client-sdks/ai-sdk
3
- > tsup --config tsup.config.ts
4
-
5
- CLI Building entry: src/index.ts
6
- CLI Using tsconfig: tsconfig.json
7
- CLI tsup v8.5.0
8
- CLI Using tsup config: /home/runner/work/mastra/mastra/client-sdks/ai-sdk/tsup.config.ts
9
- CLI Target: es2022
10
- CLI Cleaning output folder
11
- ESM Build start
12
- CJS Build start
13
- CJS dist/index.cjs 3.77 KB
14
- CJS dist/index.cjs.map 7.61 KB
15
- CJS ⚡️ Build success in 542ms
16
- ESM dist/index.js 3.75 KB
17
- ESM dist/index.js.map 7.59 KB
18
- ESM ⚡️ Build success in 543ms
package/eslint.config.js DELETED
@@ -1,6 +0,0 @@
1
- import { createConfig } from '@internal/lint/eslint';
2
-
3
- const config = await createConfig();
4
-
5
- /** @type {import("eslint").Linter.Config[]} */
6
- export default [...config.map(conf => ({ ...conf, ignores: [...(conf.ignores || []), '**/vitest.perf.config.ts'] }))];
package/src/index.ts DELETED
@@ -1,165 +0,0 @@
1
- import type { AgentExecutionOptions } from '@mastra/core/agent';
2
- import { registerApiRoute } from '@mastra/core/server';
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
-
8
- export type chatRouteOptions<
9
- OUTPUT extends OutputSchema | undefined = undefined,
10
- STRUCTURED_OUTPUT extends ZodSchema | ZodAny | JSONSchema7 | undefined = undefined,
11
- > = {
12
- defaultOptions?: AgentExecutionOptions<OUTPUT, STRUCTURED_OUTPUT, 'aisdk'>;
13
- } & (
14
- | {
15
- path: `${string}:agentId${string}`;
16
- agent?: never;
17
- }
18
- | {
19
- path: string;
20
- agent: string;
21
- }
22
- );
23
-
24
- export function chatRoute<
25
- OUTPUT extends OutputSchema | undefined = undefined,
26
- STRUCTURED_OUTPUT extends ZodSchema | ZodAny | JSONSchema7 | undefined = undefined,
27
- >({
28
- path = '/chat/:agentId',
29
- agent,
30
- defaultOptions,
31
- }: chatRouteOptions<OUTPUT, STRUCTURED_OUTPUT>): ReturnType<typeof registerApiRoute> {
32
- if (!agent && !path.includes('/:agentId')) {
33
- throw new Error('Path must include :agentId to route to the correct agent or pass the agent explicitly');
34
- }
35
-
36
- return registerApiRoute(path, {
37
- method: 'POST',
38
- openapi: {
39
- summary: 'Chat with an agent',
40
- description: 'Send messages to an agent and stream the response in the AI SDK format',
41
- tags: ['ai-sdk'],
42
- parameters: [
43
- {
44
- name: 'agentId',
45
- in: 'path',
46
- required: true,
47
- description: 'The ID of the agent to chat with',
48
- schema: {
49
- type: 'string',
50
- },
51
- },
52
- ],
53
- requestBody: {
54
- required: true,
55
- content: {
56
- 'application/json': {
57
- schema: {
58
- type: 'object',
59
- properties: {
60
- messages: {
61
- type: 'array',
62
- description: 'Array of messages in the conversation',
63
- items: {
64
- type: 'object',
65
- properties: {
66
- role: {
67
- type: 'string',
68
- enum: ['user', 'assistant', 'system'],
69
- description: 'The role of the message sender',
70
- },
71
- content: {
72
- type: 'string',
73
- description: 'The content of the message',
74
- },
75
- },
76
- required: ['role', 'content'],
77
- },
78
- },
79
- },
80
- required: ['messages'],
81
- },
82
- },
83
- },
84
- },
85
- responses: {
86
- '200': {
87
- description: 'Streaming response from the agent',
88
- content: {
89
- 'text/plain': {
90
- schema: {
91
- type: 'string',
92
- description: 'Server-sent events stream containing the agent response',
93
- },
94
- },
95
- },
96
- },
97
- '400': {
98
- description: 'Bad request - invalid input',
99
- content: {
100
- 'application/json': {
101
- schema: {
102
- type: 'object',
103
- properties: {
104
- error: {
105
- type: 'string',
106
- },
107
- },
108
- },
109
- },
110
- },
111
- },
112
- '404': {
113
- description: 'Agent not found',
114
- content: {
115
- 'application/json': {
116
- schema: {
117
- type: 'object',
118
- properties: {
119
- error: {
120
- type: 'string',
121
- },
122
- },
123
- },
124
- },
125
- },
126
- },
127
- },
128
- },
129
- handler: async c => {
130
- const { messages, ...rest } = await c.req.json();
131
- const mastra = c.get('mastra');
132
-
133
- let agentToUse: string | undefined = agent;
134
- if (!agent) {
135
- const agentId = c.req.param('agentId');
136
- agentToUse = agentId;
137
- }
138
-
139
- if (c.req.param('agentId') && agent) {
140
- mastra
141
- .getLogger()
142
- ?.warn(
143
- `Fixed agent ID was set together with an agentId path parameter. This can lead to unexpected behavior.`,
144
- );
145
- }
146
-
147
- if (!agentToUse) {
148
- throw new Error('Agent ID is required');
149
- }
150
-
151
- const agentObj = mastra.getAgent(agentToUse);
152
- if (!agentObj) {
153
- throw new Error(`Agent ${agentToUse} not found`);
154
- }
155
-
156
- const result = await agentObj.streamVNext<any, any, 'aisdk'>(messages, {
157
- ...defaultOptions,
158
- ...rest,
159
- format: 'aisdk',
160
- });
161
-
162
- return result.toUIMessageStreamResponse();
163
- },
164
- });
165
- }
@@ -1,9 +0,0 @@
1
- {
2
- "extends": ["./tsconfig.json", "../../tsconfig.build.json"],
3
- "compilerOptions": {
4
- "outDir": "./dist",
5
- "rootDir": "./src"
6
- },
7
- "include": ["src/**/*"],
8
- "exclude": ["node_modules", "**/*.test.ts", "src/**/*.mock.ts"]
9
- }
package/tsconfig.json DELETED
@@ -1,5 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.node.json",
3
- "include": ["src/**/*", "tsup.config.ts", "integration-tests/**/*"],
4
- "exclude": ["node_modules", "integration-tests/node_modules", "src/example.ts", "**/*.test.ts"]
5
- }
package/tsup.config.ts DELETED
@@ -1,17 +0,0 @@
1
- import { generateTypes } from '@internal/types-builder';
2
- import { defineConfig } from 'tsup';
3
-
4
- export default defineConfig({
5
- entry: ['src/index.ts'],
6
- format: ['esm', 'cjs'],
7
- clean: true,
8
- dts: false,
9
- splitting: true,
10
- treeshake: {
11
- preset: 'smallest',
12
- },
13
- sourcemap: true,
14
- onSuccess: async () => {
15
- await generateTypes(process.cwd());
16
- },
17
- });
package/vitest.config.js DELETED
@@ -1,8 +0,0 @@
1
- import { defineConfig } from 'vitest/config';
2
-
3
- export default defineConfig({
4
- test: {
5
- environment: 'node',
6
- include: ['src/**/*.test.ts'],
7
- },
8
- });