@mastra/server 1.1.0-alpha.2 → 1.1.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,190 @@
1
1
  # @mastra/server
2
2
 
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Restructured stored agents to use a thin metadata record with versioned configuration snapshots. ([#12488](https://github.com/mastra-ai/mastra/pull/12488))
8
+
9
+ The agent record now only stores metadata fields (id, status, activeVersionId, authorId, metadata, timestamps). All configuration fields (name, instructions, model, tools, etc.) live exclusively in version snapshot rows, enabling full version history and rollback.
10
+
11
+ **Key changes:**
12
+ - Stored Agent records are now thin metadata-only (StorageAgentType)
13
+ - All config lives in version snapshots (StorageAgentSnapshotType)
14
+ - New resolved type (StorageResolvedAgentType) merges agent record + active version config
15
+ - Renamed `ownerId` to `authorId` for multi-tenant filtering
16
+ - Changed `memory` field type from `string` to `Record<string, unknown>`
17
+ - Added `status` field ('draft' | 'published') to agent records
18
+ - Flattened CreateAgent/UpdateAgent input types (config fields at top level, no nested snapshot)
19
+ - Version config columns are top-level in the agent_versions table (no single snapshot jsonb column)
20
+ - List endpoints return resolved agents (thin record + active version config)
21
+ - Auto-versioning on update with retention limits and race condition handling
22
+
23
+ - Added explicit auth control to built-in API routes. All routes now have a requiresAuth property that determines whether authentication is required. This eliminates route matching overhead and makes auth requirements clear in route definitions. Routes default to requiresAuth: true (protected) for security. To make a route public, set requiresAuth: false in the route definition. ([#12153](https://github.com/mastra-ai/mastra/pull/12153))
24
+
25
+ - Added dynamic agent management with CRUD operations and version tracking ([#12038](https://github.com/mastra-ai/mastra/pull/12038))
26
+
27
+ **New Features:**
28
+ - Create, edit, and delete agents directly from the Mastra Studio UI
29
+ - Full version history for agents with compare and restore capabilities
30
+ - Visual diff viewer to compare agent configurations across versions
31
+ - Agent creation modal with comprehensive configuration options (model selection, instructions, tools, workflows, sub-agents, memory)
32
+ - AI-powered instruction enhancement
33
+
34
+ **Storage:**
35
+ - New storage interfaces for stored agents and agent versions
36
+ - PostgreSQL, LibSQL, and MongoDB implementations included
37
+ - In-memory storage for development and testing
38
+
39
+ **API:**
40
+ - RESTful endpoints for agent CRUD operations
41
+ - Version management endpoints (create, list, activate, restore, delete, compare)
42
+ - Automatic versioning on agent updates when enabled
43
+
44
+ **Client SDK:**
45
+ - JavaScript client with full support for stored agents and versions
46
+ - Type-safe methods for all CRUD and version operations
47
+
48
+ **Usage Example:**
49
+
50
+ ```typescript
51
+ // Server-side: Configure storage
52
+ import { Mastra } from '@mastra/core';
53
+ import { PgAgentsStorage } from '@mastra/pg';
54
+
55
+ const mastra = new Mastra({
56
+ agents: { agentOne },
57
+ storage: {
58
+ agents: new PgAgentsStorage({
59
+ connectionString: process.env.DATABASE_URL,
60
+ }),
61
+ },
62
+ });
63
+
64
+ // Client-side: Use the SDK
65
+ import { MastraClient } from '@mastra/client-js';
66
+
67
+ const client = new MastraClient({ baseUrl: 'http://localhost:3000' });
68
+
69
+ // Create a stored agent
70
+ const agent = await client.createStoredAgent({
71
+ name: 'Customer Support Agent',
72
+ description: 'Handles customer inquiries',
73
+ model: { provider: 'ANTHROPIC', name: 'claude-sonnet-4-5' },
74
+ instructions: 'You are a helpful customer support agent...',
75
+ tools: ['search', 'email'],
76
+ });
77
+
78
+ // Create a version snapshot
79
+ await client.storedAgent(agent.id).createVersion({
80
+ name: 'v1.0 - Initial release',
81
+ changeMessage: 'First production version',
82
+ });
83
+
84
+ // Compare versions
85
+ const diff = await client.storedAgent(agent.id).compareVersions('version-1', 'version-2');
86
+ ```
87
+
88
+ **Why:**
89
+ This feature enables teams to manage agents dynamically without code changes, making it easier to iterate on agent configurations and maintain a complete audit trail of changes.
90
+
91
+ - Added support for including custom API routes in the generated OpenAPI documentation. Custom routes registered via `registerApiRoute()` now appear in the OpenAPI spec alongside built-in Mastra routes. ([#11786](https://github.com/mastra-ai/mastra/pull/11786))
92
+
93
+ - Added workspace API endpoints for filesystem operations, skill management, and content search. ([#11986](https://github.com/mastra-ai/mastra/pull/11986))
94
+
95
+ **New endpoints:**
96
+ - `GET /workspaces` - List all workspaces (from Mastra instance and agents)
97
+ - `GET /workspaces/:workspaceId` - Get workspace info and capabilities
98
+ - `GET/POST/DELETE /workspaces/:workspaceId/fs/*` - Filesystem operations (read, write, list, delete, mkdir, stat)
99
+ - `GET /workspaces/:workspaceId/skills` - List available skills
100
+ - `GET /workspaces/:workspaceId/skills/:skillName` - Get skill details
101
+ - `GET /workspaces/:workspaceId/skills/:skillName/references` - List skill references
102
+ - `GET /workspaces/:workspaceId/search` - Search indexed content
103
+
104
+ **Usage:**
105
+
106
+ ```typescript
107
+ // List workspaces
108
+ const { workspaces } = await fetch('/api/workspaces').then(r => r.json());
109
+ const workspaceId = workspaces[0].id;
110
+
111
+ // Read a file
112
+ const response = await fetch(`/api/workspaces/${workspaceId}/fs/read?path=/docs/guide.md`);
113
+ const { content } = await response.json();
114
+
115
+ // List skills
116
+ const skills = await fetch(`/api/workspaces/${workspaceId}/skills`).then(r => r.json());
117
+
118
+ // Search content
119
+ const results = await fetch(`/api/workspaces/${workspaceId}/search?query=authentication&mode=hybrid`).then(r =>
120
+ r.json(),
121
+ );
122
+ ```
123
+
124
+ ### Patch Changes
125
+
126
+ - Fixed server handlers to find stored and sub-agents, not just registered agents. Agents created via the API or stored in the database are now correctly resolved in A2A, memory, scores, tools, and voice endpoints. ([#12481](https://github.com/mastra-ai/mastra/pull/12481))
127
+
128
+ - Fixed a bug introduced in PR #12251 where requestContext was not passed through to agent and workflow operations. This could cause tools and nested operations that rely on requestContext values to fail or behave incorrectly. ([#12428](https://github.com/mastra-ai/mastra/pull/12428))
129
+
130
+ - Fix broken import for deepEqual by inlining the function into server. ([#12446](https://github.com/mastra-ai/mastra/pull/12446))
131
+
132
+ - Added requestContextSchema type support. ([#12259](https://github.com/mastra-ai/mastra/pull/12259))
133
+
134
+ - Fixed authentication bypass for custom routes in dev mode. Routes registered with registerApiRoute and requiresAuth: true now correctly enforce authentication even when MASTRA_DEV=true. ([#12339](https://github.com/mastra-ai/mastra/pull/12339))
135
+
136
+ - Fixed malformed JSON body handling in Hono adapter. When a POST request contains invalid JSON (e.g., missing closing braces), the server now returns HTTP 400 Bad Request with a structured error message instead of silently accepting the request with HTTP 200. This prevents workflows from starting with undefined input data. ([#12310](https://github.com/mastra-ai/mastra/issues/12310)) ([#12332](https://github.com/mastra-ai/mastra/pull/12332))
137
+
138
+ - Fix path parameter routes not respecting requiresAuth setting ([#12143](https://github.com/mastra-ai/mastra/pull/12143))
139
+
140
+ Fixes issue where custom API routes with path parameters (e.g., `/users/:id`) were incorrectly requiring authentication even when `requiresAuth` was set to `false`. The authentication middleware now uses pattern matching to correctly match dynamic routes against registered patterns.
141
+
142
+ Changes:
143
+ - Inlined path pattern matching utility (based on regexparam) to avoid dependency complexity
144
+ - Updated `isCustomRoutePublic()` to iterate through routes and match path patterns
145
+ - Enhanced `pathMatchesPattern()` to support path parameters (`:id`), optional parameters (`:id?`), and wildcards (`*`)
146
+ - Added comprehensive test coverage for path parameter matching scenarios
147
+
148
+ Fixes #12106
149
+
150
+ - Improves CommonJS support by adding typefiles to the root directory ([#12068](https://github.com/mastra-ai/mastra/pull/12068))
151
+
152
+ - Added `mcpOptions` to server adapters for serverless MCP support. ([#12324](https://github.com/mastra-ai/mastra/pull/12324))
153
+
154
+ **Why:** MCP HTTP transport uses session management by default, which requires persistent state across requests. This doesn't work in serverless environments like Cloudflare Workers or Vercel Edge where each request runs in isolation. The new `mcpOptions` parameter lets you enable stateless mode without overriding the entire `sendResponse()` method.
155
+
156
+ **Before:**
157
+
158
+ ```typescript
159
+ const server = new MastraServer({
160
+ app,
161
+ mastra,
162
+ });
163
+ // No way to pass serverless option to MCP HTTP transport
164
+ ```
165
+
166
+ **After:**
167
+
168
+ ```typescript
169
+ const server = new MastraServer({
170
+ app,
171
+ mastra,
172
+ mcpOptions: {
173
+ serverless: true,
174
+ },
175
+ });
176
+ // MCP HTTP transport now runs in stateless mode
177
+ ```
178
+
179
+ - Fixed memory API endpoints to respect MASTRA_RESOURCE_ID_KEY and MASTRA_THREAD_ID_KEY from middleware. Previously, these endpoints ignored the reserved context keys and used client-provided values directly, allowing authenticated users to potentially access other users' threads and messages. Now when middleware sets these reserved keys, they take precedence over client-provided values for secure user isolation. ([#12251](https://github.com/mastra-ai/mastra/pull/12251))
180
+
181
+ - Route prefixes are now normalized for consistent handling (trailing slashes removed, leading slashes added, multiple slashes collapsed). ([#12295](https://github.com/mastra-ai/mastra/pull/12295))
182
+
183
+ - Fixed route prefix behavior to correctly replace the default /api prefix instead of prepending to it. Previously, setting prefix: '/api/v2' resulted in routes at /api/v2/api/agents. Now routes correctly appear at /api/v2/agents as documented. ([#12221](https://github.com/mastra-ai/mastra/pull/12221))
184
+
185
+ - Updated dependencies [[`90fc0e5`](https://github.com/mastra-ai/mastra/commit/90fc0e5717cb280c2d4acf4f0410b510bb4c0a72), [`1cf5d2e`](https://github.com/mastra-ai/mastra/commit/1cf5d2ea1b085be23e34fb506c80c80a4e6d9c2b), [`b99ceac`](https://github.com/mastra-ai/mastra/commit/b99ceace2c830dbdef47c8692d56a91954aefea2), [`deea43e`](https://github.com/mastra-ai/mastra/commit/deea43eb1366d03a864c5e597d16a48592b9893f), [`833ae96`](https://github.com/mastra-ai/mastra/commit/833ae96c3e34370e58a1e979571c41f39a720592), [`943772b`](https://github.com/mastra-ai/mastra/commit/943772b4378f625f0f4e19ea2b7c392bd8e71786), [`b5c711b`](https://github.com/mastra-ai/mastra/commit/b5c711b281dd1fb81a399a766bc9f86c55efc13e), [`3efbe5a`](https://github.com/mastra-ai/mastra/commit/3efbe5ae20864c4f3143457f4f3ee7dc2fa5ca76), [`1e49e7a`](https://github.com/mastra-ai/mastra/commit/1e49e7ab5f173582154cb26b29d424de67d09aef), [`751eaab`](https://github.com/mastra-ai/mastra/commit/751eaab4e0d3820a94e4c3d39a2ff2663ded3d91), [`69d8156`](https://github.com/mastra-ai/mastra/commit/69d81568bcf062557c24471ce26812446bec465d), [`60d9d89`](https://github.com/mastra-ai/mastra/commit/60d9d899e44b35bc43f1bcd967a74e0ce010b1af), [`5c544c8`](https://github.com/mastra-ai/mastra/commit/5c544c8d12b08ab40d64d8f37b3c4215bee95b87), [`771ad96`](https://github.com/mastra-ai/mastra/commit/771ad962441996b5c43549391a3e6a02c6ddedc2), [`2b0936b`](https://github.com/mastra-ai/mastra/commit/2b0936b0c9a43eeed9bef63e614d7e02ee803f7e), [`3b04f30`](https://github.com/mastra-ai/mastra/commit/3b04f3010604f3cdfc8a0674731700ad66471cee), [`97e26de`](https://github.com/mastra-ai/mastra/commit/97e26deaebd9836647a67b96423281d66421ca07), [`ac9ec66`](https://github.com/mastra-ai/mastra/commit/ac9ec6672779b2e6d4344e415481d1a6a7d4911a), [`10523f4`](https://github.com/mastra-ai/mastra/commit/10523f4882d9b874b40ce6e3715f66dbcd4947d2), [`cb72d20`](https://github.com/mastra-ai/mastra/commit/cb72d2069d7339bda8a0e76d4f35615debb07b84), [`42856b1`](https://github.com/mastra-ai/mastra/commit/42856b1c8aeea6371c9ee77ae2f5f5fe34400933), [`66f33ff`](https://github.com/mastra-ai/mastra/commit/66f33ff68620018513e499c394411d1d39b3aa5c), [`ab3c190`](https://github.com/mastra-ai/mastra/commit/ab3c1901980a99910ca9b96a7090c22e24060113), [`d4f06c8`](https://github.com/mastra-ai/mastra/commit/d4f06c85ffa5bb0da38fb82ebf3b040cc6b4ec4e), [`0350626`](https://github.com/mastra-ai/mastra/commit/03506267ec41b67add80d994c0c0fcce93bbc75f), [`bc9fa00`](https://github.com/mastra-ai/mastra/commit/bc9fa00859c5c4a796d53a0a5cae46ab4a3072e4), [`f46a478`](https://github.com/mastra-ai/mastra/commit/f46a4782f595949c696569e891f81c8d26338508), [`90fc0e5`](https://github.com/mastra-ai/mastra/commit/90fc0e5717cb280c2d4acf4f0410b510bb4c0a72), [`f05a3a5`](https://github.com/mastra-ai/mastra/commit/f05a3a5cf2b9a9c2d40c09cb8c762a4b6cd5d565), [`a291da9`](https://github.com/mastra-ai/mastra/commit/a291da9363efd92dafd8775dccb4f2d0511ece7a), [`c5d71da`](https://github.com/mastra-ai/mastra/commit/c5d71da1c680ce5640b1a7f8ca0e024a4ab1cfed), [`07042f9`](https://github.com/mastra-ai/mastra/commit/07042f9f89080f38b8f72713ba1c972d5b1905b8), [`0423442`](https://github.com/mastra-ai/mastra/commit/0423442b7be2dfacba95890bea8f4a810db4d603)]:
186
+ - @mastra/core@1.1.0
187
+
3
188
  ## 1.1.0-alpha.2
4
189
 
5
190
  ### Patch Changes
@@ -28,4 +28,4 @@ docs/
28
28
  ## Version
29
29
 
30
30
  Package: @mastra/server
31
- Version: 1.1.0-alpha.2
31
+ Version: 1.1.0
@@ -5,7 +5,7 @@ description: Documentation for @mastra/server. Includes links to type definition
5
5
 
6
6
  # @mastra/server Documentation
7
7
 
8
- > **Version**: 1.1.0-alpha.2
8
+ > **Version**: 1.1.0
9
9
  > **Package**: @mastra/server
10
10
 
11
11
  ## Quick Navigation
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.1.0-alpha.2",
2
+ "version": "1.1.0",
3
3
  "package": "@mastra/server",
4
4
  "exports": {},
5
5
  "modules": {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/server",
3
- "version": "1.1.0-alpha.2",
3
+ "version": "1.1.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "files": [
@@ -92,11 +92,11 @@
92
92
  "typescript": "^5.9.3",
93
93
  "vitest": "4.0.16",
94
94
  "zod": "^3.25.76",
95
- "@internal/lint": "0.0.55",
96
- "@internal/storage-test-utils": "0.0.51",
97
- "@internal/types-builder": "0.0.30",
98
- "@mastra/agent-builder": "1.0.1-alpha.1",
99
- "@mastra/core": "1.1.0-alpha.2"
95
+ "@internal/types-builder": "0.0.31",
96
+ "@mastra/agent-builder": "1.0.1",
97
+ "@mastra/core": "1.1.0",
98
+ "@internal/storage-test-utils": "0.0.52",
99
+ "@internal/lint": "0.0.56"
100
100
  },
101
101
  "homepage": "https://mastra.ai",
102
102
  "repository": {