@mastra/server 1.36.0-alpha.8 → 1.36.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 +209 -0
- package/dist/{api-schema-manifest-HYLH35UU.cjs → api-schema-manifest-4VHMCJM3.cjs} +4 -4
- package/dist/{api-schema-manifest-HYLH35UU.cjs.map → api-schema-manifest-4VHMCJM3.cjs.map} +1 -1
- package/dist/{api-schema-manifest-WY623UST.js → api-schema-manifest-DZFKQXHM.js} +3 -3
- package/dist/{api-schema-manifest-WY623UST.js.map → api-schema-manifest-DZFKQXHM.js.map} +1 -1
- package/dist/{chunk-3FLL7GNJ.js → chunk-32CLLOUG.js} +3 -3
- package/dist/{chunk-3FLL7GNJ.js.map → chunk-32CLLOUG.js.map} +1 -1
- package/dist/{chunk-YQYYIRDS.cjs → chunk-35SOHRUB.cjs} +90 -90
- package/dist/{chunk-YQYYIRDS.cjs.map → chunk-35SOHRUB.cjs.map} +1 -1
- package/dist/{chunk-E3UHRQZ7.js → chunk-3HMSFYGA.js} +12 -12
- package/dist/{chunk-E3UHRQZ7.js.map → chunk-3HMSFYGA.js.map} +1 -1
- package/dist/{chunk-JZ2K5LY4.cjs → chunk-5R2TJISH.cjs} +4 -4
- package/dist/{chunk-JZ2K5LY4.cjs.map → chunk-5R2TJISH.cjs.map} +1 -1
- package/dist/{chunk-D4HVKF56.js → chunk-ADCOCQN6.js} +3 -3
- package/dist/{chunk-D4HVKF56.js.map → chunk-ADCOCQN6.js.map} +1 -1
- package/dist/{chunk-KME4O3RJ.cjs → chunk-ADOALG4G.cjs} +3 -2
- package/dist/chunk-ADOALG4G.cjs.map +1 -0
- package/dist/{chunk-CY2WDWFQ.cjs → chunk-BXXP2OVD.cjs} +3 -3
- package/dist/{chunk-CY2WDWFQ.cjs.map → chunk-BXXP2OVD.cjs.map} +1 -1
- package/dist/{chunk-A4FTF4A7.cjs → chunk-CUCQCEE7.cjs} +63 -63
- package/dist/{chunk-A4FTF4A7.cjs.map → chunk-CUCQCEE7.cjs.map} +1 -1
- package/dist/{chunk-CODPCBGN.cjs → chunk-EQICIFWJ.cjs} +25 -25
- package/dist/{chunk-CODPCBGN.cjs.map → chunk-EQICIFWJ.cjs.map} +1 -1
- package/dist/{chunk-HFESVWJ6.js → chunk-GYC5P37S.js} +3 -3
- package/dist/{chunk-HFESVWJ6.js.map → chunk-GYC5P37S.js.map} +1 -1
- package/dist/{chunk-MERLF4UP.cjs → chunk-GZ4HIOSP.cjs} +7 -7
- package/dist/{chunk-MERLF4UP.cjs.map → chunk-GZ4HIOSP.cjs.map} +1 -1
- package/dist/{chunk-XM54QZ3G.js → chunk-JHFU2P6Z.js} +3 -3
- package/dist/{chunk-XM54QZ3G.js.map → chunk-JHFU2P6Z.js.map} +1 -1
- package/dist/{chunk-ZRU7KWNW.cjs → chunk-JIB75MHZ.cjs} +7 -3
- package/dist/chunk-JIB75MHZ.cjs.map +1 -0
- package/dist/{chunk-7X6KGLPA.js → chunk-K2KT5JNX.js} +4 -4
- package/dist/{chunk-7X6KGLPA.js.map → chunk-K2KT5JNX.js.map} +1 -1
- package/dist/{chunk-WM2RUEBO.js → chunk-K5ED24PC.js} +3 -3
- package/dist/{chunk-WM2RUEBO.js.map → chunk-K5ED24PC.js.map} +1 -1
- package/dist/{chunk-TNXHSUIL.cjs → chunk-KIR4MF3S.cjs} +117 -117
- package/dist/{chunk-TNXHSUIL.cjs.map → chunk-KIR4MF3S.cjs.map} +1 -1
- package/dist/{chunk-KWREVMMS.js → chunk-LO3JBCO6.js} +7 -3
- package/dist/chunk-LO3JBCO6.js.map +1 -0
- package/dist/{chunk-HKM5KOOK.cjs → chunk-LRIYO7KQ.cjs} +4 -4
- package/dist/{chunk-HKM5KOOK.cjs.map → chunk-LRIYO7KQ.cjs.map} +1 -1
- package/dist/{chunk-HWT5YD7H.cjs → chunk-M2CPNUSL.cjs} +4 -4
- package/dist/{chunk-HWT5YD7H.cjs.map → chunk-M2CPNUSL.cjs.map} +1 -1
- package/dist/{chunk-I3RWQGD7.js → chunk-MRG75BLC.js} +3 -3
- package/dist/{chunk-I3RWQGD7.js.map → chunk-MRG75BLC.js.map} +1 -1
- package/dist/{chunk-L6U4LZZX.cjs → chunk-NVWA33MV.cjs} +24 -24
- package/dist/{chunk-L6U4LZZX.cjs.map → chunk-NVWA33MV.cjs.map} +1 -1
- package/dist/{chunk-Y3KIKJW6.js → chunk-P673H7LK.js} +3 -3
- package/dist/{chunk-Y3KIKJW6.js.map → chunk-P673H7LK.js.map} +1 -1
- package/dist/{chunk-CBHBMWZ2.cjs → chunk-PQKBBJOP.cjs} +5 -5
- package/dist/{chunk-CBHBMWZ2.cjs.map → chunk-PQKBBJOP.cjs.map} +1 -1
- package/dist/{chunk-4Z24UGLY.cjs → chunk-RDR3XN2X.cjs} +17 -17
- package/dist/{chunk-4Z24UGLY.cjs.map → chunk-RDR3XN2X.cjs.map} +1 -1
- package/dist/{chunk-IRJQQYII.js → chunk-SAPM56NU.js} +3 -3
- package/dist/{chunk-IRJQQYII.js.map → chunk-SAPM56NU.js.map} +1 -1
- package/dist/{chunk-IFYVRBFS.js → chunk-VVLD43MX.js} +3 -2
- package/dist/chunk-VVLD43MX.js.map +1 -0
- package/dist/{chunk-664F5XOW.js → chunk-YZPXWF6M.js} +4 -4
- package/dist/{chunk-664F5XOW.js.map → chunk-YZPXWF6M.js.map} +1 -1
- package/dist/{chunk-GW6T4HLN.js → chunk-ZUWPQVWA.js} +4 -4
- package/dist/{chunk-GW6T4HLN.js.map → chunk-ZUWPQVWA.js.map} +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/server/handlers/a2a.cjs +14 -14
- package/dist/server/handlers/a2a.js +1 -1
- package/dist/server/handlers/agent-builder.cjs +16 -16
- package/dist/server/handlers/agent-builder.js +1 -1
- package/dist/server/handlers/agents.cjs +41 -41
- package/dist/server/handlers/agents.d.ts +8 -0
- package/dist/server/handlers/agents.d.ts.map +1 -1
- package/dist/server/handlers/agents.js +1 -1
- package/dist/server/handlers/conversations.cjs +5 -5
- package/dist/server/handlers/conversations.js +1 -1
- package/dist/server/handlers/datasets.cjs +26 -26
- package/dist/server/handlers/datasets.d.ts +2 -0
- package/dist/server/handlers/datasets.d.ts.map +1 -1
- package/dist/server/handlers/datasets.js +1 -1
- package/dist/server/handlers/responses.cjs +4 -4
- package/dist/server/handlers/responses.js +1 -1
- package/dist/server/handlers/scores.cjs +7 -7
- package/dist/server/handlers/scores.js +1 -1
- package/dist/server/handlers/system.cjs +3 -3
- package/dist/server/handlers/system.js +1 -1
- package/dist/server/handlers/tools.cjs +6 -6
- package/dist/server/handlers/tools.js +1 -1
- package/dist/server/handlers/voice.cjs +8 -8
- package/dist/server/handlers/voice.js +1 -1
- package/dist/server/handlers/workflows.cjs +26 -26
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers.cjs +18 -18
- package/dist/server/handlers.js +9 -9
- package/dist/server/schemas/agents.d.ts +8 -0
- package/dist/server/schemas/agents.d.ts.map +1 -1
- package/dist/server/schemas/datasets.d.ts +2 -0
- package/dist/server/schemas/datasets.d.ts.map +1 -1
- package/dist/server/schemas/index.cjs +90 -90
- package/dist/server/schemas/index.js +2 -2
- package/dist/server/server-adapter/index.cjs +14 -14
- package/dist/server/server-adapter/index.cjs.map +1 -1
- package/dist/server/server-adapter/index.js +3 -3
- package/dist/server/server-adapter/index.js.map +1 -1
- package/dist/server/server-adapter/routes/datasets.d.ts +2 -0
- package/dist/server/server-adapter/routes/datasets.d.ts.map +1 -1
- package/package.json +7 -7
- package/dist/chunk-IFYVRBFS.js.map +0 -1
- package/dist/chunk-KME4O3RJ.cjs.map +0 -1
- package/dist/chunk-KWREVMMS.js.map +0 -1
- package/dist/chunk-ZRU7KWNW.cjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,214 @@
|
|
|
1
1
|
# @mastra/server
|
|
2
2
|
|
|
3
|
+
## 1.36.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Added delta polling support for observability list endpoints. ([#16632](https://github.com/mastra-ai/mastra/pull/16632))
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
const page = await client.observability.listTraces({
|
|
11
|
+
mode: 'page',
|
|
12
|
+
filters: { entityName: 'agent-1' },
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const delta = await client.observability.listTraces({
|
|
16
|
+
mode: 'delta',
|
|
17
|
+
filters: { entityName: 'agent-1' },
|
|
18
|
+
after: page.deltaCursor,
|
|
19
|
+
});
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Use `mode: 'delta'` to fetch only new items after the last cursor.
|
|
23
|
+
|
|
24
|
+
Page-mode responses include `pagination` and `deltaCursor` when delta polling is supported. Delta-mode responses include `delta` and do not include `pagination`.
|
|
25
|
+
|
|
26
|
+
If you read these responses directly in typed code, note that `pagination` is only included in page mode.
|
|
27
|
+
|
|
28
|
+
- Added automatic FGA metadata for stored resource routes plus optional request scope isolation for stored resource APIs. Enable protected-route coverage with provider options: ([#16651](https://github.com/mastra-ai/mastra/pull/16651))
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
const fga = new MastraFGAWorkos({
|
|
32
|
+
resourceMapping,
|
|
33
|
+
permissionMapping,
|
|
34
|
+
requireForProtectedRoutes: true,
|
|
35
|
+
auditProtectedRoutes: 'warn',
|
|
36
|
+
});
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
- Added an HTTP surface for stored agents/skills/workspaces, plus introspection endpoints for the agent-builder and an external skill-registry proxy. Studio and the client SDK use these endpoints to back the new "stored entity" management UI. ([#16666](https://github.com/mastra-ai/mastra/pull/16666))
|
|
40
|
+
|
|
41
|
+
```http
|
|
42
|
+
# Browse + manage stored entities (responses include favoriteCount + isFavorited)
|
|
43
|
+
GET /stored/agents?visibility=public&page=1&perPage=20
|
|
44
|
+
GET /stored/agents/:id
|
|
45
|
+
POST /stored/agents
|
|
46
|
+
PATCH /stored/agents/:id
|
|
47
|
+
DELETE /stored/agents/:id
|
|
48
|
+
|
|
49
|
+
# Versioning
|
|
50
|
+
POST /stored/skills/:id/publish
|
|
51
|
+
POST /stored/skills/:id/activate
|
|
52
|
+
POST /stored/skills/:id/restore
|
|
53
|
+
|
|
54
|
+
# Favorites
|
|
55
|
+
PUT /stored/agents/:id/favorite
|
|
56
|
+
DELETE /stored/agents/:id/favorite
|
|
57
|
+
|
|
58
|
+
# Builder introspection
|
|
59
|
+
GET /editor/builder/settings
|
|
60
|
+
GET /editor/builder/infrastructure
|
|
61
|
+
|
|
62
|
+
# External skill registry proxy (skills.sh)
|
|
63
|
+
GET /editor/builder/registries
|
|
64
|
+
GET /editor/builder/registries/:registryId/search
|
|
65
|
+
GET /editor/builder/registries/:registryId/popular
|
|
66
|
+
GET /editor/builder/registries/:registryId/skills/:owner/:repo/preview
|
|
67
|
+
POST /editor/builder/registries/:registryId/skills/:owner/:repo/install
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Highlights:
|
|
71
|
+
- **Visibility + authorship gating.** Stored agents/skills now resolve a caller's author identity from the request context. Non-admin users only see their own + public entities. Admins see everything.
|
|
72
|
+
- **Favorites.** List/get responses include `favoriteCount` and the caller's `isFavorited` flag. `PUT`/`DELETE /stored/{agents|skills}/:id/favorite` toggle the favorite for the caller.
|
|
73
|
+
- **Avatar validation.** Stored-agent/skill metadata avatars are validated through a new `validateMetadataAvatarUrl` helper (rejects payloads over the size limit or with malformed base64).
|
|
74
|
+
- **Model-policy enforcement.** Stored-agent create/update routes invoke `assertModelAllowed` via the new `resolveBuilderModelPolicy` helper. Disallowed models map to HTTP 422 with a structured body — `{ code, attempted, offendingLabel, allowed }` — via `handleError`'s new `ModelNotAllowedError` mapping.
|
|
75
|
+
- **Builder introspection.** `GET /editor/builder/settings` returns feature flags, configuration, picker visibility, and model policy. `GET /editor/builder/infrastructure` reports browser-provider and sandbox status. Both default to `{ enabled: false }` when no `MastraEditor` is configured.
|
|
76
|
+
- **External skill registry.** `/editor/builder/registries/*` proxies the public skills.sh catalog so the builder UI can browse and install registered skills.
|
|
77
|
+
|
|
78
|
+
This also bumps the `@mastra/core` peer dependency floor to `>=1.34.0-0` (see the separate changeset) because the new handlers and error mapping import runtime values from `@mastra/core/agent-builder/ee`.
|
|
79
|
+
|
|
80
|
+
- Narrowed `AgentSignalContents` from `BaseMessageListInput` to `string | (TextPart | FilePart)[]`. ([#16622](https://github.com/mastra-ai/mastra/pull/16622))
|
|
81
|
+
|
|
82
|
+
Fixed two signal-content bugs:
|
|
83
|
+
- `user-message` signal attributes now reach the LLM
|
|
84
|
+
- multimodal non-`user-message` signals no longer lose file parts
|
|
85
|
+
|
|
86
|
+
Callers that previously passed wrapped message shapes to `agent.sendSignal` should now pass a bare string or a bare parts array.
|
|
87
|
+
|
|
88
|
+
Before:
|
|
89
|
+
`{ type: 'user-message', contents: [{ role: 'user', content: [{ type: 'text', text: 'hi' }] }] }`
|
|
90
|
+
|
|
91
|
+
After:
|
|
92
|
+
`{ type: 'user-message', contents: [{ type: 'text', text: 'hi' }] }`
|
|
93
|
+
|
|
94
|
+
Added an optional `providerOptions` field to `agent.sendSignal` that flows through to the resulting prompt turn (as `providerOptions` on the LLM message) and is persisted on the stored signal message (as `content.providerMetadata`).
|
|
95
|
+
|
|
96
|
+
- Routes can now require **any one of multiple permissions** by passing an array to `requiresPermission`. When an array is provided, the request is allowed if the caller holds any of the listed permissions. Existing single-string usage continues to work. ([#16605](https://github.com/mastra-ai/mastra/pull/16605))
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
// Before — single permission only
|
|
100
|
+
{
|
|
101
|
+
path: '/v1/things',
|
|
102
|
+
method: 'GET',
|
|
103
|
+
requiresPermission: 'things:read',
|
|
104
|
+
handler,
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// After — single permission or ANY-of array
|
|
108
|
+
{
|
|
109
|
+
path: '/v1/things/:id/stream',
|
|
110
|
+
method: 'GET',
|
|
111
|
+
requiresPermission: ['things:read', 'things:execute'],
|
|
112
|
+
handler,
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Denial messages now read `Missing required permission: a or b or c` when an array is used.
|
|
117
|
+
|
|
118
|
+
**New endpoint**
|
|
119
|
+
|
|
120
|
+
`GET /api/auth/roles/:roleId/permissions` returns the resolved permission list for a role. Useful for client-side gating and admin tooling.
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
const res = await fetch('/api/auth/roles/admin/permissions', { credentials: 'include' });
|
|
124
|
+
// { "roleId": "admin", "permissions": ["*"] }
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**Namespaced request-context keys (non-breaking)**
|
|
128
|
+
|
|
129
|
+
`coreAuthMiddleware` now writes user state under namespaced keys (`mastra__user`, `mastra__userPermissions`, `mastra__userRoles`) in addition to the existing bare keys (`user`, `userPermissions`, `userRoles`). The bare keys are still written for backward compatibility, so existing middleware, integrations, and built-in handlers that read `requestContext.get('user')` continue to work unchanged.
|
|
130
|
+
|
|
131
|
+
New code should prefer the namespaced constants to avoid collisions with caller-supplied request-context entries:
|
|
132
|
+
|
|
133
|
+
```ts
|
|
134
|
+
import { MASTRA_USER_KEY, MASTRA_USER_PERMISSIONS_KEY, MASTRA_USER_ROLES_KEY } from '@mastra/server/auth';
|
|
135
|
+
|
|
136
|
+
const user = requestContext.get(MASTRA_USER_KEY);
|
|
137
|
+
const permissions = requestContext.get(MASTRA_USER_PERMISSIONS_KEY) as string[] | undefined;
|
|
138
|
+
const roles = requestContext.get(MASTRA_USER_ROLES_KEY) as string[] | undefined;
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
The bare keys (`user`, `userPermissions`, `userRoles`) remain populated and are considered the documented public surface for this release; a future major release may deprecate them.
|
|
142
|
+
|
|
143
|
+
**Route permission derivation**
|
|
144
|
+
|
|
145
|
+
`getEffectivePermission()` now recognizes stored resource families (`stored-agents`, `stored-skills`, `stored-prompt-blocks`, `stored-mcp-clients`, `stored-scorers`, `stored-workspaces`) and `publish` / `activate` / `restore` action suffixes on stored-resource routes. Return type widened to `string | string[] | null` to support routes that map to multiple permissions.
|
|
146
|
+
|
|
147
|
+
### Patch Changes
|
|
148
|
+
|
|
149
|
+
- Fixed stored resource updates to preserve existing metadata keys. ([#16651](https://github.com/mastra-ai/mastra/pull/16651))
|
|
150
|
+
|
|
151
|
+
- Hardened the stored-agent and stored-skill favorite toggle endpoints (`PUT`/`DELETE /stored/{agents,skills}/:id/favorite`) so callers can no longer favorite or unfavorite entities outside their tenant scope. ([#16749](https://github.com/mastra-ai/mastra/pull/16749))
|
|
152
|
+
|
|
153
|
+
Deployments that configure `storedResources.scope` now get the same 404-on-mismatch protection on favorite toggles that already applied to read/update/delete. Single-tenant deployments are unaffected.
|
|
154
|
+
|
|
155
|
+
Also corrected JSDoc on stored-agent and stored-skill handlers to reference the canonical resource/action names (`stored-agents:read`, `stored-skills:write`).
|
|
156
|
+
|
|
157
|
+
- Fix DELETE custom routes forwarding JSON request bodies. ([#16857](https://github.com/mastra-ai/mastra/pull/16857))
|
|
158
|
+
|
|
159
|
+
- Fixed CompositeAuth incorrectly advertising SSO, session, and user provider capabilities when no inner provider supports them. Studio would show an SSO login button even when no provider had SSO configured, leading to 401 errors on login attempts. The duck-typing check now verifies that interface methods are actual functions rather than just present on the prototype chain. ([#16664](https://github.com/mastra-ai/mastra/pull/16664))
|
|
160
|
+
|
|
161
|
+
- Fixed provider and dataset item history response types to include fields returned by the API. ([#16213](https://github.com/mastra-ai/mastra/pull/16213))
|
|
162
|
+
|
|
163
|
+
- Widened `BrowserStreamConfig.getToolset` to support async lookup. Existing synchronous implementations continue to work — the type now accepts `MastraBrowser | undefined` or `Promise<MastraBrowser | undefined>`. ([#16778](https://github.com/mastra-ai/mastra/pull/16778))
|
|
164
|
+
|
|
165
|
+
This unblocks server-adapter implementations that need to resolve agents asynchronously (for example, hydrating stored agents from storage on first browser-stream connection).
|
|
166
|
+
|
|
167
|
+
```ts
|
|
168
|
+
import { setupBrowserStream } from '@mastra/server';
|
|
169
|
+
|
|
170
|
+
await setupBrowserStream(app, {
|
|
171
|
+
getToolset: async agentId => {
|
|
172
|
+
const agent = await resolveAgent(agentId);
|
|
173
|
+
return agent?.browser;
|
|
174
|
+
},
|
|
175
|
+
apiPrefix,
|
|
176
|
+
});
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
- Align stored-entity authorship checks with their RBAC resource names. Stored-agent and stored-skill handlers were calling `hasAdminBypass` / `assertReadAccess` / `assertWriteAccess` / `resolveAuthorFilter` with `resource: 'agents'` and `resource: 'skills'`, but the routes are gated by `stored-agents:*` / `stored-skills:*` permissions. An admin granted `stored-agents:*` (or `stored-skills:*`) without the global `*` wildcard would pass route authorization but be treated as a non-admin inside the handler, so they could not list, read, or update private records owned by other users. Handlers now use `stored-agents` and `stored-skills` as the authorship resource string, matching the permission strings emitted by the route layer. ([#16666](https://github.com/mastra-ai/mastra/pull/16666))
|
|
180
|
+
|
|
181
|
+
- Restore backwards compatibility for the legacy `GET /api/memory/threads?orderBy=<field>&sortDirection=<dir>` query shape emitted by `@mastra/client-js` < 1.18 (and any hand-rolled HTTP clients written against pre-1.0 docs). Server 1.31.0 turned that shape into a hard 400 (`Invalid input: expected object, received undefined`); the legacy bare-string + `sortDirection` pair is now transparently fused into the current `{ orderBy: { field, direction } }` object shape before validation, so pinned clients keep working. ([#16745](https://github.com/mastra-ai/mastra/pull/16745))
|
|
182
|
+
|
|
183
|
+
Current callers using bracket notation (`orderBy[field]=...&orderBy[direction]=...`) or a JSON-stringified `orderBy` are unaffected.
|
|
184
|
+
|
|
185
|
+
- Bumped the `@mastra/core` peer dependency floor from `>=1.32.0-0` to `>=1.34.0-0`. ([#16666](https://github.com/mastra-ai/mastra/pull/16666))
|
|
186
|
+
|
|
187
|
+
- Fixed the playground memory configuration display for agents using observationalMemory: true. ([#16213](https://github.com/mastra-ai/mastra/pull/16213))
|
|
188
|
+
|
|
189
|
+
- Updated dependencies [[`452036a`](https://github.com/mastra-ai/mastra/commit/452036a0d965b4f4c1efd93606e4f03b50b807a5), [`c272d50`](https://github.com/mastra-ai/mastra/commit/c272d50610a54496b6b6d92ccd4d37b333a2613a), [`27fd1b7`](https://github.com/mastra-ai/mastra/commit/27fd1b79ac62eb7694f92587eb7d1be05b59be01), [`5ba7253`](https://github.com/mastra-ai/mastra/commit/5ba7253745c85e8df8012a76d954c640ffa336f7), [`5556cc1`](https://github.com/mastra-ai/mastra/commit/5556cc1befec71518d84f826b3bfe3a079a9daf7), [`f73980d`](https://github.com/mastra-ai/mastra/commit/f73980d651eb5f7f1ab20582de4615a1b6f10fce), [`5499303`](https://github.com/mastra-ai/mastra/commit/54993032c1ebc09642625b78d2014e0cf84a3cae), [`a702009`](https://github.com/mastra-ai/mastra/commit/a702009d3cfaa745120f501e21c783ed4d6a3072), [`9aee493`](https://github.com/mastra-ai/mastra/commit/9aee493ed6089b5133472623dcce49934bf2d509), [`d8692af`](https://github.com/mastra-ai/mastra/commit/d8692afa253028e39cdce2aafa0ac414071a762e), [`1a9cc60`](https://github.com/mastra-ai/mastra/commit/1a9cc6069f9910fc3d59e4953ac8cd95d89ad6f5), [`8cdb86c`](https://github.com/mastra-ai/mastra/commit/8cdb86ceed1137bc2768e147dce85a0692b9fb26), [`8534d79`](https://github.com/mastra-ai/mastra/commit/8534d791fa1cb70fe1c19e2604c4b63cc10dd051), [`eda90c5`](https://github.com/mastra-ai/mastra/commit/eda90c5bfd7de11805ecc9f4552716c895fbaf78), [`a935b0a`](https://github.com/mastra-ai/mastra/commit/a935b0a0977ae3f196b33ec7621f528069c82db0), [`9c88701`](https://github.com/mastra-ai/mastra/commit/9c8870195b41a38dc40b6ba2aa55eda04df8fa69), [`c78f8cd`](https://github.com/mastra-ai/mastra/commit/c78f8cd6222a86e6c60ae5210b6929ad5221b6fb), [`e146aad`](https://github.com/mastra-ai/mastra/commit/e146aadbba66c410ba0e74bac4c50135495cb8dd), [`ac79462`](https://github.com/mastra-ai/mastra/commit/ac79462b98f1062394c45093aa515b0766f27ee2), [`1a0ec78`](https://github.com/mastra-ai/mastra/commit/1a0ec789a26cae443744e9abbd62ed6ee676af39), [`e47bca7`](https://github.com/mastra-ai/mastra/commit/e47bca7b72866d3abd173b9f530ac4318113a8ff), [`afc004f`](https://github.com/mastra-ai/mastra/commit/afc004f5cc7e30697809e7021820b9f5881e6719), [`0031d0f`](https://github.com/mastra-ai/mastra/commit/0031d0f13831d7843ac5d498734a7d92862e2ce3), [`841a222`](https://github.com/mastra-ai/mastra/commit/841a222560d8c19238f8213713f30535cdd82284), [`64c1e0b`](https://github.com/mastra-ai/mastra/commit/64c1e0b35165c96b659818bd0177aa18794ef11f), [`40d83a9`](https://github.com/mastra-ai/mastra/commit/40d83a90d9be31a1b83e04649edb703eb7753e33), [`4e88dc6`](https://github.com/mastra-ai/mastra/commit/4e88dc6b89f154c0eae37221c8126be0c23c569f), [`19018f0`](https://github.com/mastra-ai/mastra/commit/19018f05722af74a5978781a7731a654b26f7f2a), [`19281c7`](https://github.com/mastra-ai/mastra/commit/19281c70424f757219782de16c2699743c5e04d0), [`3498b49`](https://github.com/mastra-ai/mastra/commit/3498b4946be94f4313cd817733589680dcda5278), [`d52b6fe`](https://github.com/mastra-ai/mastra/commit/d52b6fe1c56853eb38864baae0bbfa75cc739ccb), [`408be73`](https://github.com/mastra-ai/mastra/commit/408be73449dfab92b51eab8c6623b6c443debc25), [`359439b`](https://github.com/mastra-ai/mastra/commit/359439bb8c635e048176306828195f8297f50021), [`71a820b`](https://github.com/mastra-ai/mastra/commit/71a820b2353fa1406772c50760a3732058a8b337), [`1698f5e`](https://github.com/mastra-ai/mastra/commit/1698f5ec141d34f22a873efdb145ce3cdf848a5e)]:
|
|
190
|
+
- @mastra/core@1.36.0
|
|
191
|
+
|
|
192
|
+
## 1.36.0-alpha.10
|
|
193
|
+
|
|
194
|
+
### Patch Changes
|
|
195
|
+
|
|
196
|
+
- Fix DELETE custom routes forwarding JSON request bodies. ([#16857](https://github.com/mastra-ai/mastra/pull/16857))
|
|
197
|
+
|
|
198
|
+
- Updated dependencies [[`27fd1b7`](https://github.com/mastra-ai/mastra/commit/27fd1b79ac62eb7694f92587eb7d1be05b59be01), [`a702009`](https://github.com/mastra-ai/mastra/commit/a702009d3cfaa745120f501e21c783ed4d6a3072), [`8534d79`](https://github.com/mastra-ai/mastra/commit/8534d791fa1cb70fe1c19e2604c4b63cc10dd051), [`c78f8cd`](https://github.com/mastra-ai/mastra/commit/c78f8cd6222a86e6c60ae5210b6929ad5221b6fb), [`e146aad`](https://github.com/mastra-ai/mastra/commit/e146aadbba66c410ba0e74bac4c50135495cb8dd), [`1a0ec78`](https://github.com/mastra-ai/mastra/commit/1a0ec789a26cae443744e9abbd62ed6ee676af39), [`d52b6fe`](https://github.com/mastra-ai/mastra/commit/d52b6fe1c56853eb38864baae0bbfa75cc739ccb)]:
|
|
199
|
+
- @mastra/core@1.36.0-alpha.10
|
|
200
|
+
|
|
201
|
+
## 1.36.0-alpha.9
|
|
202
|
+
|
|
203
|
+
### Patch Changes
|
|
204
|
+
|
|
205
|
+
- Fixed provider and dataset item history response types to include fields returned by the API. ([#16213](https://github.com/mastra-ai/mastra/pull/16213))
|
|
206
|
+
|
|
207
|
+
- Fixed the playground memory configuration display for agents using observationalMemory: true. ([#16213](https://github.com/mastra-ai/mastra/pull/16213))
|
|
208
|
+
|
|
209
|
+
- Updated dependencies [[`1698f5e`](https://github.com/mastra-ai/mastra/commit/1698f5ec141d34f22a873efdb145ce3cdf848a5e)]:
|
|
210
|
+
- @mastra/core@1.36.0-alpha.9
|
|
211
|
+
|
|
3
212
|
## 1.36.0-alpha.8
|
|
4
213
|
|
|
5
214
|
### Patch Changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkKIR4MF3S_cjs = require('./chunk-KIR4MF3S.cjs');
|
|
4
4
|
var chunkXTFWFQZ7_cjs = require('./chunk-XTFWFQZ7.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 =
|
|
37
|
+
function buildApiSchemaManifest(routes = chunkKIR4MF3S_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 = chunkTNXHSUIL_cjs.SERVER_ROUTES) {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
exports.buildApiSchemaManifest = buildApiSchemaManifest;
|
|
57
|
-
//# sourceMappingURL=api-schema-manifest-
|
|
58
|
-
//# sourceMappingURL=api-schema-manifest-
|
|
57
|
+
//# sourceMappingURL=api-schema-manifest-4VHMCJM3.cjs.map
|
|
58
|
+
//# sourceMappingURL=api-schema-manifest-4VHMCJM3.cjs.map
|
|
@@ -1 +1 @@
|
|
|
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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;AAC1B;AAEA,SAAS,gBAAgB,KAAA,EAA6B;AACpD,EAAA,OAAO,KAAA,CAAM,YAAA,KAAiB,MAAA,IAAU,CAAC,KAAA,CAAM,UAAA;AACjD;AAEO,SAAS,sBAAA,CAAuB,SAAiCC,+BAAA,EAAkC;AACxG,EAAA,OAAO;AAAA,IACL,OAAA,EAAS,CAAA;AAAA,IACT,QAAQ,MAAA,CAAO,MAAA,CAAO,eAAe,CAAA,CAAE,IAAI,CAAA,KAAA,KAAS;AAClD,MAAA,MAAM,cAAA,GAAiB,aAAA,CAAc,KAAA,CAAM,cAAc,CAAA;AACzD,MAAA,OAAO;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-
|
|
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,OAA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AM,QAAA,EAAS;AAC1B;AAEA,SAAS,gBAAgB,KAAA,EAA6B;AACpD,EAAA,OAAO,KAAA,CAAM,YAAA,KAAiB,MAAA,IAAU,CAAC,KAAA,CAAM,UAAA;AACjD;AAEO,SAAS,sBAAA,CAAuB,SAAiCC,+BAAA,EAAkC;AACxG,EAAA,OAAO;AAAA,IACL,OAAA,EAAS,CAAA;AAAA,IACT,QAAQ,MAAA,CAAO,MAAA,CAAO,eAAe,CAAA,CAAE,IAAI,CAAA,KAAA,KAAS;AAClD,MAAA,MAAM,cAAA,GAAiB,aAAA,CAAc,KAAA,CAAM,cAAc,CAAA;AACzD,MAAA,OAAO;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-4VHMCJM3.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-
|
|
1
|
+
import { SERVER_ROUTES } from './chunk-3HMSFYGA.js';
|
|
2
2
|
import { schemaToJsonSchema } from './chunk-F2FAL5CZ.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-
|
|
56
|
-
//# sourceMappingURL=api-schema-manifest-
|
|
55
|
+
//# sourceMappingURL=api-schema-manifest-DZFKQXHM.js.map
|
|
56
|
+
//# sourceMappingURL=api-schema-manifest-DZFKQXHM.js.map
|
|
@@ -1 +1 @@
|
|
|
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,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A,GAAiB,aAAA,CAAc,KAAA,CAAM,cAAc,CAAA;AACzD,MAAA,OAAO;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-DZFKQXHM.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,5 +1,5 @@
|
|
|
1
1
|
import { listScorersResponseSchema, scorerIdPathParams, scorerEntrySchema, scoresWithPaginationResponseSchema, listScoresByRunIdQuerySchema, listScoresByScorerIdQuerySchema, listScoresByEntityIdQuerySchema, entityPathParams, saveScoreResponseSchema, saveScoreBodySchema } from './chunk-OC4S3EDO.js';
|
|
2
|
-
import { getAgentFromSystem } from './chunk-
|
|
2
|
+
import { getAgentFromSystem } from './chunk-MRG75BLC.js';
|
|
3
3
|
import { runIdSchema } from './chunk-2YY3EMMS.js';
|
|
4
4
|
import { handleError } from './chunk-GA4BG5JK.js';
|
|
5
5
|
import { createRoute } from './chunk-F2FAL5CZ.js';
|
|
@@ -296,5 +296,5 @@ var SAVE_SCORE_ROUTE = createRoute({
|
|
|
296
296
|
});
|
|
297
297
|
|
|
298
298
|
export { GET_SCORER_ROUTE, LIST_SCORERS_ROUTE, LIST_SCORES_BY_ENTITY_ID_ROUTE, LIST_SCORES_BY_RUN_ID_ROUTE, LIST_SCORES_BY_SCORER_ID_ROUTE, SAVE_SCORE_ROUTE, scores_exports };
|
|
299
|
-
//# sourceMappingURL=chunk-
|
|
300
|
-
//# sourceMappingURL=chunk-
|
|
299
|
+
//# sourceMappingURL=chunk-32CLLOUG.js.map
|
|
300
|
+
//# sourceMappingURL=chunk-32CLLOUG.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/server/handlers/scores.ts"],"names":[],"mappings":";;;;;;;;;AAAA,IAAA,cAAA,GAAA;AAAA,QAAA,CAAA,cAAA,EAAA;AAAA,EAAA,gBAAA,EAAA,MAAA,gBAAA;AAAA,EAAA,kBAAA,EAAA,MAAA,kBAAA;AAAA,EAAA,8BAAA,EAAA,MAAA,8BAAA;AAAA,EAAA,2BAAA,EAAA,MAAA,2BAAA;AAAA,EAAA,8BAAA,EAAA,MAAA,8BAAA;AAAA,EAAA,gBAAA,EAAA,MAAA;AAAA,CAAA,CAAA;AAsBA,eAAe,qBAAA,CAAsB;AAAA,EACnC,MAAA;AAAA,EACA;AACF,CAAA,EAEG;AACD,EAAA,MAAM,MAAA,GAAS,OAAO,UAAA,EAAW;AACjC,EAAA,MAAM,SAAA,GAAY,OAAO,aAAA,EAAc;AAEvC,EAAA,MAAM,UAAA,uBAAiB,GAAA,EASrB;AAGF,EAAA,MAAM,mBAAA,GAAsB,OAAO,KAAA,KAI7B;AACJ,IAAA,MAAM,OAAA,GACH,MAAM,KAAA,CAAM,WAAA,CAAY;AAAA,MACvB;AAAA,KACD,KAAM,EAAC;AAEV,IAAA,IAAI,MAAA,CAA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AAG,QAAO,KAAM;AACxC,IAAA,IAAI;AACF,MAAA,MAAM,EAAE,OAAM,GAAI,MAAA;AAClB,MAAA,MAAM,cAAc,MAAM,MAAA,CAAO,UAAA,EAAW,EAAG,SAAS,QAAQ,CAAA;AAChE,MAAA,MAAM,MAAA,GAAS,MAAM,WAAA,EAAa,SAAA,GAAY,KAAK,CAAA;AACnD,MAAA,IAAI,CAAC,MAAA,EAAQ;AACX,QAAA,MAAM,IAAI,aAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,0BAA0B,CAAA;AAAA,MACpE;AACA,MAAA,OAAO,MAAA;AAAA,IACT,SAAS,KAAA,EAAO;AACd,MAAA,OAAO,WAAA,CAAY,OAAO,oBAAoB,CAAA;AAAA,IAChD;AAAA,EACF;AACF,CAAC","file":"chunk-3FLL7GNJ.js","sourcesContent":["import type { MastraScorerEntry, ScoreRowData } from '@mastra/core/evals';\nimport type { RequestContext } from '@mastra/core/request-context';\nimport type { StoragePagination } from '@mastra/core/storage';\nimport { HTTPException } from '../http-exception';\nimport { runIdSchema } from '../schemas/common';\nimport {\n listScorersResponseSchema,\n scorerEntrySchema,\n scorerIdPathParams,\n entityPathParams,\n listScoresByRunIdQuerySchema,\n listScoresByScorerIdQuerySchema,\n listScoresByEntityIdQuerySchema,\n saveScoreBodySchema,\n scoresWithPaginationResponseSchema,\n saveScoreResponseSchema,\n} from '../schemas/scores';\nimport { createRoute } from '../server-adapter/routes/route-builder';\nimport type { Context } from '../types';\nimport { getAgentFromSystem } from './agents';\nimport { handleError } from './error';\n\nasync function listScorersFromSystem({\n mastra,\n requestContext,\n}: Context & {\n requestContext: RequestContext;\n}) {\n const agents = mastra.listAgents();\n const workflows = mastra.listWorkflows();\n\n const scorersMap = new Map<\n string,\n MastraScorerEntry & {\n agentIds: string[];\n agentNames: string[];\n workflowIds: string[];\n isRegistered: boolean;\n source: 'code' | 'stored';\n }\n >();\n\n // Helper function to process an agent's scorers\n const processAgentScorers = async (agent: {\n id: string;\n name: string;\n listScorers: (typeof agents)[string]['listScorers'];\n }) => {\n const scorers =\n (await agent.listScorers({\n requestContext,\n })) || {};\n\n if (Object.keys(scorers).length > 0) {\n for (const [_scorerId, scorer] of Object.entries(scorers)) {\n const scorerId = scorer.scorer.id;\n if (scorersMap.has(scorerId)) {\n scorersMap.get(scorerId)?.agentIds.push(agent.id);\n scorersMap.get(scorerId)?.agentNames.push(agent.name);\n } else {\n scorersMap.set(scorerId, {\n workflowIds: [],\n ...scorer,\n agentNames: [agent.name],\n agentIds: [agent.id],\n isRegistered: false,\n source: scorer.scorer.source ?? 'code',\n });\n }\n }\n }\n };\n\n // Process code-defined agents\n for (const [_, agent] of Object.entries(agents)) {\n await processAgentScorers(agent);\n }\n\n // Process stored agents (database-backed agents)\n try {\n const editor = mastra.getEditor();\n const storedAgentsResult = await editor?.agent.list();\n if (storedAgentsResult?.agents) {\n for (const storedAgentConfig of storedAgentsResult.agents) {\n try {\n const agent = await editor?.agent.getById(storedAgentConfig.id);\n if (agent) {\n await processAgentScorers(agent);\n }\n } catch {\n // Skip individual agents that fail to hydrate\n }\n }\n }\n } catch {\n // Silently ignore if storage is not configured - not all setups have storage\n }\n\n // Process stored scorers (standalone CMS-created scorers)\n try {\n const editor = mastra.getEditor();\n const storedScorersResult = await editor?.scorer.list();\n if (storedScorersResult?.scorerDefinitions) {\n for (const storedScorerConfig of storedScorersResult.scorerDefinitions) {\n try {\n await editor?.scorer.getById(storedScorerConfig.id);\n } catch {\n // Skip individual scorers that fail to hydrate\n }\n }\n }\n } catch {\n // Silently ignore if storage is not configured\n }\n\n for (const [workflowId, workflow] of Object.entries(workflows)) {\n const scorers =\n (await workflow.listScorers({\n requestContext,\n })) || {};\n\n if (Object.keys(scorers).length > 0) {\n for (const [_scorerId, scorer] of Object.entries(scorers)) {\n const scorerName = scorer.scorer.name;\n if (scorersMap.has(scorerName)) {\n scorersMap.get(scorerName)?.workflowIds.push(workflowId);\n } else {\n scorersMap.set(scorerName, {\n agentIds: [],\n agentNames: [],\n ...scorer,\n workflowIds: [workflowId],\n isRegistered: false,\n source: scorer.scorer.source ?? 'code',\n });\n }\n }\n }\n }\n\n const registeredScorers = await mastra.listScorers();\n for (const [_scorerId, scorer] of Object.entries(registeredScorers || {})) {\n const scorerId = scorer.id;\n if (scorersMap.has(scorerId)) {\n scorersMap.get(scorerId)!.isRegistered = true;\n } else {\n scorersMap.set(scorerId, {\n scorer: scorer,\n agentIds: [],\n agentNames: [],\n workflowIds: [],\n isRegistered: true,\n source: scorer.source ?? 'code',\n });\n }\n }\n\n return Object.fromEntries(scorersMap.entries());\n}\n\n// Legacy function to get trace and span details\nfunction getTraceDetails(traceIdWithSpanId?: string) {\n if (!traceIdWithSpanId) {\n return {};\n }\n\n const [traceId, spanId] = traceIdWithSpanId.split('-');\n\n return {\n ...(traceId ? { traceId } : {}),\n ...(spanId ? { spanId } : {}),\n };\n}\n\n// ============================================================================\n// Route Definitions (new pattern - handlers defined inline with createRoute)\n// ============================================================================\n\nexport const LIST_SCORERS_ROUTE = createRoute({\n method: 'GET',\n path: '/scores/scorers',\n responseType: 'json',\n responseSchema: listScorersResponseSchema,\n summary: 'List all scorers',\n description: 'Returns a list of all registered scorers with their configuration and associated agents and workflows',\n tags: ['Scoring'],\n requiresAuth: true,\n handler: (async ({ mastra, requestContext }: any) => {\n const scorers = await listScorersFromSystem({\n mastra,\n requestContext,\n });\n return scorers;\n }) as any,\n});\n\nexport const GET_SCORER_ROUTE = createRoute({\n method: 'GET',\n path: '/scores/scorers/:scorerId',\n responseType: 'json',\n pathParamSchema: scorerIdPathParams,\n responseSchema: scorerEntrySchema.nullable(),\n summary: 'Get scorer by ID',\n description: 'Returns details for a specific scorer including its configuration and associations',\n tags: ['Scoring'],\n requiresAuth: true,\n handler: (async ({ mastra, scorerId, requestContext }: any) => {\n const scorers = await listScorersFromSystem({\n mastra,\n requestContext,\n });\n\n const scorer = scorers[scorerId];\n\n if (!scorer) {\n return null;\n }\n\n return scorer;\n }) as any,\n});\n\nexport const LIST_SCORES_BY_RUN_ID_ROUTE = createRoute({\n method: 'GET',\n path: '/scores/run/:runId',\n responseType: 'json',\n pathParamSchema: runIdSchema,\n queryParamSchema: listScoresByRunIdQuerySchema,\n responseSchema: scoresWithPaginationResponseSchema,\n summary: 'List scores by run ID',\n description: 'Returns all scores for a specific execution run',\n tags: ['Scoring'],\n requiresAuth: true,\n handler: async ({ mastra, runId, ...params }) => {\n try {\n const { page, perPage } = params;\n const pagination: StoragePagination = {\n page: page ?? 0,\n perPage: perPage ?? 10,\n };\n const scores = await mastra.getStorage()?.getStore('scores');\n const scoreResults = (await scores?.listScoresByRunId?.({\n runId,\n pagination,\n })) || { pagination: { total: 0, page: 0, perPage: 0, hasMore: false }, scores: [] };\n return {\n pagination: scoreResults.pagination,\n scores: scoreResults.scores.map((score: ScoreRowData) => ({ ...score, ...getTraceDetails(score.traceId) })),\n };\n } catch (error) {\n return handleError(error, 'Error getting scores by run id');\n }\n },\n});\n\nexport const LIST_SCORES_BY_SCORER_ID_ROUTE = createRoute({\n method: 'GET',\n path: '/scores/scorer/:scorerId',\n responseType: 'json',\n pathParamSchema: scorerIdPathParams,\n queryParamSchema: listScoresByScorerIdQuerySchema,\n responseSchema: scoresWithPaginationResponseSchema,\n summary: 'List scores by scorer ID',\n description: 'Returns all scores generated by a specific scorer',\n tags: ['Scoring'],\n requiresAuth: true,\n handler: async ({ mastra, scorerId, ...params }) => {\n try {\n const { page, perPage, entityId, entityType } = params;\n const filters = Object.fromEntries(Object.entries({ entityId, entityType }).filter(([_, v]) => v !== undefined));\n const scores = await mastra.getStorage()?.getStore('scores');\n const scoreResults = (await scores?.listScoresByScorerId?.({\n scorerId,\n pagination: { page: page ?? 0, perPage: perPage ?? 10 },\n ...filters,\n })) || { pagination: { total: 0, page: 0, perPage: 0, hasMore: false }, scores: [] };\n return {\n pagination: scoreResults.pagination,\n scores: scoreResults.scores.map((score: ScoreRowData) => ({ ...score, ...getTraceDetails(score.traceId) })),\n };\n } catch (error) {\n return handleError(error, 'Error getting scores by scorer id');\n }\n },\n});\n\nexport const LIST_SCORES_BY_ENTITY_ID_ROUTE = createRoute({\n method: 'GET',\n path: '/scores/entity/:entityType/:entityId',\n responseType: 'json',\n pathParamSchema: entityPathParams,\n queryParamSchema: listScoresByEntityIdQuerySchema,\n responseSchema: scoresWithPaginationResponseSchema,\n summary: 'List scores by entity ID',\n description: 'Returns all scores for a specific entity (agent or workflow)',\n tags: ['Scoring'],\n requiresAuth: true,\n handler: async ({ mastra, entityId, entityType, ...params }) => {\n try {\n const { page, perPage } = params;\n let entityIdToUse = entityId;\n\n if (entityType === 'AGENT') {\n const agent = await getAgentFromSystem({ mastra, agentId: entityId });\n entityIdToUse = agent.id;\n } else if (entityType === 'WORKFLOW') {\n const workflow = mastra.getWorkflowById(entityId);\n entityIdToUse = workflow.id;\n }\n\n const pagination: StoragePagination = {\n page: page ?? 0,\n perPage: perPage ?? 10,\n };\n\n const scoresStore = await mastra.getStorage()?.getStore('scores');\n const scoreResults = (await scoresStore?.listScoresByEntityId?.({\n entityId: entityIdToUse,\n entityType,\n pagination,\n })) || { pagination: { total: 0, page: 0, perPage: 0, hasMore: false }, scores: [] };\n\n return {\n pagination: scoreResults.pagination,\n scores: scoreResults.scores.map((score: ScoreRowData) => ({ ...score, ...getTraceDetails(score.traceId) })),\n };\n } catch (error) {\n return handleError(error, 'Error getting scores by entity id');\n }\n },\n});\n\nexport const SAVE_SCORE_ROUTE = createRoute({\n method: 'POST',\n path: '/scores',\n responseType: 'json',\n bodySchema: saveScoreBodySchema,\n responseSchema: saveScoreResponseSchema,\n summary: 'Save score',\n description: 'Saves a new score record to storage',\n tags: ['Scoring'],\n requiresAuth: true,\n handler: async ({ mastra, ...params }) => {\n try {\n const { score } = params as { score: ScoreRowData };\n const scoresStore = await mastra.getStorage()?.getStore('scores');\n const result = await scoresStore?.saveScore?.(score);\n if (!result) {\n throw new HTTPException(500, { message: 'Storage not configured' });\n }\n return result;\n } catch (error) {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oBAAoB,CAAA;AAAA,IAChD;AAAA,EACF;AACF,CAAC","file":"chunk-32CLLOUG.js","sourcesContent":["import type { MastraScorerEntry, ScoreRowData } from '@mastra/core/evals';\nimport type { RequestContext } from '@mastra/core/request-context';\nimport type { StoragePagination } from '@mastra/core/storage';\nimport { HTTPException } from '../http-exception';\nimport { runIdSchema } from '../schemas/common';\nimport {\n listScorersResponseSchema,\n scorerEntrySchema,\n scorerIdPathParams,\n entityPathParams,\n listScoresByRunIdQuerySchema,\n listScoresByScorerIdQuerySchema,\n listScoresByEntityIdQuerySchema,\n saveScoreBodySchema,\n scoresWithPaginationResponseSchema,\n saveScoreResponseSchema,\n} from '../schemas/scores';\nimport { createRoute } from '../server-adapter/routes/route-builder';\nimport type { Context } from '../types';\nimport { getAgentFromSystem } from './agents';\nimport { handleError } from './error';\n\nasync function listScorersFromSystem({\n mastra,\n requestContext,\n}: Context & {\n requestContext: RequestContext;\n}) {\n const agents = mastra.listAgents();\n const workflows = mastra.listWorkflows();\n\n const scorersMap = new Map<\n string,\n MastraScorerEntry & {\n agentIds: string[];\n agentNames: string[];\n workflowIds: string[];\n isRegistered: boolean;\n source: 'code' | 'stored';\n }\n >();\n\n // Helper function to process an agent's scorers\n const processAgentScorers = async (agent: {\n id: string;\n name: string;\n listScorers: (typeof agents)[string]['listScorers'];\n }) => {\n const scorers =\n (await agent.listScorers({\n requestContext,\n })) || {};\n\n if (Object.keys(scorers).length > 0) {\n for (const [_scorerId, scorer] of Object.entries(scorers)) {\n const scorerId = scorer.scorer.id;\n if (scorersMap.has(scorerId)) {\n scorersMap.get(scorerId)?.agentIds.push(agent.id);\n scorersMap.get(scorerId)?.agentNames.push(agent.name);\n } else {\n scorersMap.set(scorerId, {\n workflowIds: [],\n ...scorer,\n agentNames: [agent.name],\n agentIds: [agent.id],\n isRegistered: false,\n source: scorer.scorer.source ?? 'code',\n });\n }\n }\n }\n };\n\n // Process code-defined agents\n for (const [_, agent] of Object.entries(agents)) {\n await processAgentScorers(agent);\n }\n\n // Process stored agents (database-backed agents)\n try {\n const editor = mastra.getEditor();\n const storedAgentsResult = await editor?.agent.list();\n if (storedAgentsResult?.agents) {\n for (const storedAgentConfig of storedAgentsResult.agents) {\n try {\n const agent = await editor?.agent.getById(storedAgentConfig.id);\n if (agent) {\n await processAgentScorers(agent);\n }\n } catch {\n // Skip individual agents that fail to hydrate\n }\n }\n }\n } catch {\n // Silently ignore if storage is not configured - not all setups have storage\n }\n\n // Process stored scorers (standalone CMS-created scorers)\n try {\n const editor = mastra.getEditor();\n const storedScorersResult = await editor?.scorer.list();\n if (storedScorersResult?.scorerDefinitions) {\n for (const storedScorerConfig of storedScorersResult.scorerDefinitions) {\n try {\n await editor?.scorer.getById(storedScorerConfig.id);\n } catch {\n // Skip individual scorers that fail to hydrate\n }\n }\n }\n } catch {\n // Silently ignore if storage is not configured\n }\n\n for (const [workflowId, workflow] of Object.entries(workflows)) {\n const scorers =\n (await workflow.listScorers({\n requestContext,\n })) || {};\n\n if (Object.keys(scorers).length > 0) {\n for (const [_scorerId, scorer] of Object.entries(scorers)) {\n const scorerName = scorer.scorer.name;\n if (scorersMap.has(scorerName)) {\n scorersMap.get(scorerName)?.workflowIds.push(workflowId);\n } else {\n scorersMap.set(scorerName, {\n agentIds: [],\n agentNames: [],\n ...scorer,\n workflowIds: [workflowId],\n isRegistered: false,\n source: scorer.scorer.source ?? 'code',\n });\n }\n }\n }\n }\n\n const registeredScorers = await mastra.listScorers();\n for (const [_scorerId, scorer] of Object.entries(registeredScorers || {})) {\n const scorerId = scorer.id;\n if (scorersMap.has(scorerId)) {\n scorersMap.get(scorerId)!.isRegistered = true;\n } else {\n scorersMap.set(scorerId, {\n scorer: scorer,\n agentIds: [],\n agentNames: [],\n workflowIds: [],\n isRegistered: true,\n source: scorer.source ?? 'code',\n });\n }\n }\n\n return Object.fromEntries(scorersMap.entries());\n}\n\n// Legacy function to get trace and span details\nfunction getTraceDetails(traceIdWithSpanId?: string) {\n if (!traceIdWithSpanId) {\n return {};\n }\n\n const [traceId, spanId] = traceIdWithSpanId.split('-');\n\n return {\n ...(traceId ? { traceId } : {}),\n ...(spanId ? { spanId } : {}),\n };\n}\n\n// ============================================================================\n// Route Definitions (new pattern - handlers defined inline with createRoute)\n// ============================================================================\n\nexport const LIST_SCORERS_ROUTE = createRoute({\n method: 'GET',\n path: '/scores/scorers',\n responseType: 'json',\n responseSchema: listScorersResponseSchema,\n summary: 'List all scorers',\n description: 'Returns a list of all registered scorers with their configuration and associated agents and workflows',\n tags: ['Scoring'],\n requiresAuth: true,\n handler: (async ({ mastra, requestContext }: any) => {\n const scorers = await listScorersFromSystem({\n mastra,\n requestContext,\n });\n return scorers;\n }) as any,\n});\n\nexport const GET_SCORER_ROUTE = createRoute({\n method: 'GET',\n path: '/scores/scorers/:scorerId',\n responseType: 'json',\n pathParamSchema: scorerIdPathParams,\n responseSchema: scorerEntrySchema.nullable(),\n summary: 'Get scorer by ID',\n description: 'Returns details for a specific scorer including its configuration and associations',\n tags: ['Scoring'],\n requiresAuth: true,\n handler: (async ({ mastra, scorerId, requestContext }: any) => {\n const scorers = await listScorersFromSystem({\n mastra,\n requestContext,\n });\n\n const scorer = scorers[scorerId];\n\n if (!scorer) {\n return null;\n }\n\n return scorer;\n }) as any,\n});\n\nexport const LIST_SCORES_BY_RUN_ID_ROUTE = createRoute({\n method: 'GET',\n path: '/scores/run/:runId',\n responseType: 'json',\n pathParamSchema: runIdSchema,\n queryParamSchema: listScoresByRunIdQuerySchema,\n responseSchema: scoresWithPaginationResponseSchema,\n summary: 'List scores by run ID',\n description: 'Returns all scores for a specific execution run',\n tags: ['Scoring'],\n requiresAuth: true,\n handler: async ({ mastra, runId, ...params }) => {\n try {\n const { page, perPage } = params;\n const pagination: StoragePagination = {\n page: page ?? 0,\n perPage: perPage ?? 10,\n };\n const scores = await mastra.getStorage()?.getStore('scores');\n const scoreResults = (await scores?.listScoresByRunId?.({\n runId,\n pagination,\n })) || { pagination: { total: 0, page: 0, perPage: 0, hasMore: false }, scores: [] };\n return {\n pagination: scoreResults.pagination,\n scores: scoreResults.scores.map((score: ScoreRowData) => ({ ...score, ...getTraceDetails(score.traceId) })),\n };\n } catch (error) {\n return handleError(error, 'Error getting scores by run id');\n }\n },\n});\n\nexport const LIST_SCORES_BY_SCORER_ID_ROUTE = createRoute({\n method: 'GET',\n path: '/scores/scorer/:scorerId',\n responseType: 'json',\n pathParamSchema: scorerIdPathParams,\n queryParamSchema: listScoresByScorerIdQuerySchema,\n responseSchema: scoresWithPaginationResponseSchema,\n summary: 'List scores by scorer ID',\n description: 'Returns all scores generated by a specific scorer',\n tags: ['Scoring'],\n requiresAuth: true,\n handler: async ({ mastra, scorerId, ...params }) => {\n try {\n const { page, perPage, entityId, entityType } = params;\n const filters = Object.fromEntries(Object.entries({ entityId, entityType }).filter(([_, v]) => v !== undefined));\n const scores = await mastra.getStorage()?.getStore('scores');\n const scoreResults = (await scores?.listScoresByScorerId?.({\n scorerId,\n pagination: { page: page ?? 0, perPage: perPage ?? 10 },\n ...filters,\n })) || { pagination: { total: 0, page: 0, perPage: 0, hasMore: false }, scores: [] };\n return {\n pagination: scoreResults.pagination,\n scores: scoreResults.scores.map((score: ScoreRowData) => ({ ...score, ...getTraceDetails(score.traceId) })),\n };\n } catch (error) {\n return handleError(error, 'Error getting scores by scorer id');\n }\n },\n});\n\nexport const LIST_SCORES_BY_ENTITY_ID_ROUTE = createRoute({\n method: 'GET',\n path: '/scores/entity/:entityType/:entityId',\n responseType: 'json',\n pathParamSchema: entityPathParams,\n queryParamSchema: listScoresByEntityIdQuerySchema,\n responseSchema: scoresWithPaginationResponseSchema,\n summary: 'List scores by entity ID',\n description: 'Returns all scores for a specific entity (agent or workflow)',\n tags: ['Scoring'],\n requiresAuth: true,\n handler: async ({ mastra, entityId, entityType, ...params }) => {\n try {\n const { page, perPage } = params;\n let entityIdToUse = entityId;\n\n if (entityType === 'AGENT') {\n const agent = await getAgentFromSystem({ mastra, agentId: entityId });\n entityIdToUse = agent.id;\n } else if (entityType === 'WORKFLOW') {\n const workflow = mastra.getWorkflowById(entityId);\n entityIdToUse = workflow.id;\n }\n\n const pagination: StoragePagination = {\n page: page ?? 0,\n perPage: perPage ?? 10,\n };\n\n const scoresStore = await mastra.getStorage()?.getStore('scores');\n const scoreResults = (await scoresStore?.listScoresByEntityId?.({\n entityId: entityIdToUse,\n entityType,\n pagination,\n })) || { pagination: { total: 0, page: 0, perPage: 0, hasMore: false }, scores: [] };\n\n return {\n pagination: scoreResults.pagination,\n scores: scoreResults.scores.map((score: ScoreRowData) => ({ ...score, ...getTraceDetails(score.traceId) })),\n };\n } catch (error) {\n return handleError(error, 'Error getting scores by entity id');\n }\n },\n});\n\nexport const SAVE_SCORE_ROUTE = createRoute({\n method: 'POST',\n path: '/scores',\n responseType: 'json',\n bodySchema: saveScoreBodySchema,\n responseSchema: saveScoreResponseSchema,\n summary: 'Save score',\n description: 'Saves a new score record to storage',\n tags: ['Scoring'],\n requiresAuth: true,\n handler: async ({ mastra, ...params }) => {\n try {\n const { score } = params as { score: ScoreRowData };\n const scoresStore = await mastra.getStorage()?.getStore('scores');\n const result = await scoresStore?.saveScore?.(score);\n if (!result) {\n throw new HTTPException(500, { message: 'Storage not configured' });\n }\n return result;\n } catch (error) {\n return handleError(error, 'Error saving score');\n }\n },\n});\n"]}
|