@mastra/server 0.0.0-fix-persist-session-cache-option-mcp-server-20251031182703 → 0.0.0-fix-9244-clickhouse-metadata-20251104213434
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 +176 -3
- package/dist/{chunk-BATEJLED.js → chunk-46Z2KDQL.js} +12 -12
- package/dist/chunk-46Z2KDQL.js.map +1 -0
- package/dist/{chunk-7NADHFD2.cjs → chunk-64ITUOXI.cjs} +2 -2
- package/dist/chunk-64ITUOXI.cjs.map +1 -0
- package/dist/{chunk-MMROOK5J.js → chunk-6QWQZI4Q.js} +2 -2
- package/dist/{chunk-7NADHFD2.cjs.map → chunk-6QWQZI4Q.js.map} +1 -1
- package/dist/{chunk-7KNKINQE.js → chunk-73PAWDM5.js} +4 -4
- package/dist/{chunk-7KNKINQE.js.map → chunk-73PAWDM5.js.map} +1 -1
- package/dist/{chunk-PUYDRTPG.cjs → chunk-AEVI2HIU.cjs} +105 -174
- package/dist/chunk-AEVI2HIU.cjs.map +1 -0
- package/dist/{chunk-OEW3R7V4.js → chunk-ALOLTNSO.js} +3 -3
- package/dist/{chunk-OEW3R7V4.js.map → chunk-ALOLTNSO.js.map} +1 -1
- package/dist/{chunk-7YHMDEQ6.cjs → chunk-B6NK4KI5.cjs} +25 -25
- package/dist/{chunk-7YHMDEQ6.cjs.map → chunk-B6NK4KI5.cjs.map} +1 -1
- package/dist/{chunk-6IGZKIRM.cjs → chunk-BANGX6SC.cjs} +28 -28
- package/dist/chunk-BANGX6SC.cjs.map +1 -0
- package/dist/{chunk-BMOVKZO7.cjs → chunk-BHQH5QXD.cjs} +42 -37
- package/dist/chunk-BHQH5QXD.cjs.map +1 -0
- package/dist/{chunk-G4PUALCE.cjs → chunk-BTWIR2B7.cjs} +4 -4
- package/dist/{chunk-G4PUALCE.cjs.map → chunk-BTWIR2B7.cjs.map} +1 -1
- package/dist/{chunk-6562SOHJ.js → chunk-DNUO33HF.js} +3 -4
- package/dist/chunk-DNUO33HF.js.map +1 -0
- package/dist/{chunk-CXVOX4WB.js → chunk-FKZVCLOY.js} +49 -30
- package/dist/chunk-FKZVCLOY.js.map +1 -0
- package/dist/{chunk-2S4IMB6E.cjs → chunk-GTZOYEAU.cjs} +31 -31
- package/dist/chunk-GTZOYEAU.cjs.map +1 -0
- package/dist/{chunk-LZKJT7QP.cjs → chunk-GU4EWMZB.cjs} +34 -64
- package/dist/chunk-GU4EWMZB.cjs.map +1 -0
- package/dist/{chunk-36CWLQQT.js → chunk-IGOWG5V5.js} +22 -22
- package/dist/chunk-IGOWG5V5.js.map +1 -0
- package/dist/{chunk-4BKR6543.cjs → chunk-JIIVA4BA.cjs} +4571 -988
- package/dist/chunk-JIIVA4BA.cjs.map +1 -0
- package/dist/{chunk-2XD2KQEK.js → chunk-JO2AZFJN.js} +21 -16
- package/dist/chunk-JO2AZFJN.js.map +1 -0
- package/dist/{chunk-HLIRV42R.cjs → chunk-JZ65BJ6H.cjs} +82 -89
- package/dist/chunk-JZ65BJ6H.cjs.map +1 -0
- package/dist/{chunk-4YFT3JFJ.js → chunk-KCP6I5F3.js} +4547 -963
- package/dist/chunk-KCP6I5F3.js.map +1 -0
- package/dist/{chunk-MYR4PVGN.js → chunk-KWH5QBXP.js} +4 -4
- package/dist/{chunk-MYR4PVGN.js.map → chunk-KWH5QBXP.js.map} +1 -1
- package/dist/{chunk-GQRJOUV7.js → chunk-LF2ZLOFP.js} +34 -64
- package/dist/chunk-LF2ZLOFP.js.map +1 -0
- package/dist/{chunk-74ZF4DII.js → chunk-LPCK5MAF.js} +5 -5
- package/dist/{chunk-74ZF4DII.js.map → chunk-LPCK5MAF.js.map} +1 -1
- package/dist/{chunk-YNGDJJOH.cjs → chunk-LWLSQ2W4.cjs} +13 -14
- package/dist/chunk-LWLSQ2W4.cjs.map +1 -0
- package/dist/{chunk-WH5RPLO4.cjs → chunk-PPMIB3FQ.cjs} +9 -9
- package/dist/{chunk-WH5RPLO4.cjs.map → chunk-PPMIB3FQ.cjs.map} +1 -1
- package/dist/{chunk-LROVQBIB.cjs → chunk-QFGNUBOA.cjs} +101 -82
- package/dist/chunk-QFGNUBOA.cjs.map +1 -0
- package/dist/{chunk-S4IOWSI3.js → chunk-R6OQFR47.js} +29 -97
- package/dist/chunk-R6OQFR47.js.map +1 -0
- package/dist/{chunk-EP3JQDPD.cjs → chunk-S54HNARD.cjs} +18 -18
- package/dist/{chunk-EP3JQDPD.cjs.map → chunk-S54HNARD.cjs.map} +1 -1
- package/dist/{chunk-4QCXUEAT.js → chunk-SZIFSF4T.js} +3 -3
- package/dist/{chunk-4QCXUEAT.js.map → chunk-SZIFSF4T.js.map} +1 -1
- package/dist/{chunk-CY4TP3FK.js → chunk-UXGQZUYZ.js} +3 -3
- package/dist/{chunk-CY4TP3FK.js.map → chunk-UXGQZUYZ.js.map} +1 -1
- package/dist/{chunk-RE4RPXT2.cjs → chunk-V5WWQN7P.cjs} +4 -4
- package/dist/{chunk-RE4RPXT2.cjs.map → chunk-V5WWQN7P.cjs.map} +1 -1
- package/dist/{chunk-7MCHFMDF.js → chunk-VYR3SAFM.js} +40 -47
- package/dist/chunk-VYR3SAFM.js.map +1 -0
- package/dist/{chunk-SED4H2GJ.cjs → chunk-XXGID4PQ.cjs} +4 -4
- package/dist/{chunk-SED4H2GJ.cjs.map → chunk-XXGID4PQ.cjs.map} +1 -1
- package/dist/server/handlers/a2a.cjs +7 -7
- package/dist/server/handlers/a2a.js +1 -1
- package/dist/server/handlers/agent-builder.cjs +20 -24
- package/dist/server/handlers/agent-builder.d.ts +23 -42
- package/dist/server/handlers/agent-builder.d.ts.map +1 -1
- package/dist/server/handlers/agent-builder.js +1 -1
- package/dist/server/handlers/agents.cjs +19 -19
- package/dist/server/handlers/agents.d.ts +8 -9
- package/dist/server/handlers/agents.d.ts.map +1 -1
- package/dist/server/handlers/agents.js +1 -1
- package/dist/server/handlers/error.cjs +2 -2
- package/dist/server/handlers/error.js +1 -1
- package/dist/server/handlers/logs.cjs +4 -4
- package/dist/server/handlers/logs.js +1 -1
- package/dist/server/handlers/memory.cjs +18 -18
- package/dist/server/handlers/memory.d.ts +17 -16
- package/dist/server/handlers/memory.d.ts.map +1 -1
- package/dist/server/handlers/memory.js +1 -1
- package/dist/server/handlers/observability.cjs +6 -6
- package/dist/server/handlers/observability.d.ts +7 -7
- package/dist/server/handlers/observability.d.ts.map +1 -1
- package/dist/server/handlers/observability.js +1 -1
- package/dist/server/handlers/scores.cjs +11 -11
- package/dist/server/handlers/scores.d.ts +16 -16
- package/dist/server/handlers/scores.d.ts.map +1 -1
- package/dist/server/handlers/scores.js +1 -1
- package/dist/server/handlers/tools.cjs +6 -6
- package/dist/server/handlers/tools.d.ts.map +1 -1
- package/dist/server/handlers/tools.js +1 -1
- package/dist/server/handlers/utils.cjs +3 -3
- package/dist/server/handlers/utils.js +1 -1
- package/dist/server/handlers/vector.cjs +7 -7
- package/dist/server/handlers/vector.js +1 -1
- package/dist/server/handlers/voice.cjs +5 -5
- package/dist/server/handlers/voice.js +1 -1
- package/dist/server/handlers/workflows.cjs +20 -24
- package/dist/server/handlers/workflows.d.ts +9 -12
- package/dist/server/handlers/workflows.d.ts.map +1 -1
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers.cjs +22 -22
- package/dist/server/handlers.js +11 -11
- package/dist/server/http-exception.d.ts +0 -5
- package/dist/server/http-exception.d.ts.map +1 -1
- package/dist/server/utils.d.ts +1 -1
- package/dist/server/utils.d.ts.map +1 -1
- package/package.json +6 -6
- package/dist/chunk-2S4IMB6E.cjs.map +0 -1
- package/dist/chunk-2XD2KQEK.js.map +0 -1
- package/dist/chunk-36CWLQQT.js.map +0 -1
- package/dist/chunk-4BKR6543.cjs.map +0 -1
- package/dist/chunk-4YFT3JFJ.js.map +0 -1
- package/dist/chunk-6562SOHJ.js.map +0 -1
- package/dist/chunk-6IGZKIRM.cjs.map +0 -1
- package/dist/chunk-7MCHFMDF.js.map +0 -1
- package/dist/chunk-BATEJLED.js.map +0 -1
- package/dist/chunk-BMOVKZO7.cjs.map +0 -1
- package/dist/chunk-CXVOX4WB.js.map +0 -1
- package/dist/chunk-GQRJOUV7.js.map +0 -1
- package/dist/chunk-HLIRV42R.cjs.map +0 -1
- package/dist/chunk-LROVQBIB.cjs.map +0 -1
- package/dist/chunk-LZKJT7QP.cjs.map +0 -1
- package/dist/chunk-MMROOK5J.js.map +0 -1
- package/dist/chunk-PUYDRTPG.cjs.map +0 -1
- package/dist/chunk-S4IOWSI3.js.map +0 -1
- package/dist/chunk-YNGDJJOH.cjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,19 +1,142 @@
|
|
|
1
1
|
# @mastra/server
|
|
2
2
|
|
|
3
|
-
## 0.0.0-fix-
|
|
3
|
+
## 0.0.0-fix-9244-clickhouse-metadata-20251104213434
|
|
4
4
|
|
|
5
5
|
### Major Changes
|
|
6
6
|
|
|
7
|
+
- Moving scorers under the eval domain, api method consistency, prebuilt evals, scorers require ids. ([#9589](https://github.com/mastra-ai/mastra/pull/9589))
|
|
8
|
+
|
|
7
9
|
- Update handlers to use `listWorkflowRuns` instead of `getWorkflowRuns`. Fix type names from `StoragelistThreadsByResourceIdInput/Output` to `StorageListThreadsByResourceIdInput/Output`. ([#9507](https://github.com/mastra-ai/mastra/pull/9507))
|
|
8
10
|
|
|
11
|
+
- **BREAKING:** Remove `getMessagesPaginated()` and add `perPage: false` support ([#9670](https://github.com/mastra-ai/mastra/pull/9670))
|
|
12
|
+
|
|
13
|
+
Removes deprecated `getMessagesPaginated()` method. The `listMessages()` API and score handlers now support `perPage: false` to fetch all records without pagination limits.
|
|
14
|
+
|
|
15
|
+
**Storage changes:**
|
|
16
|
+
- `StoragePagination.perPage` type changed from `number` to `number | false`
|
|
17
|
+
- All storage implementations support `perPage: false`:
|
|
18
|
+
- Memory: `listMessages()`
|
|
19
|
+
- Scores: `listScoresBySpan()`, `listScoresByRunId()`, `listScoresByExecutionId()`
|
|
20
|
+
- HTTP query parser accepts `"false"` string (e.g., `?perPage=false`)
|
|
21
|
+
|
|
22
|
+
**Memory changes:**
|
|
23
|
+
- `memory.query()` parameter type changed from `StorageGetMessagesArg` to `StorageListMessagesInput`
|
|
24
|
+
- Uses flat parameters (`page`, `perPage`, `include`, `filter`, `vectorSearchString`) instead of `selectBy` object
|
|
25
|
+
|
|
26
|
+
**Stricter validation:**
|
|
27
|
+
- `listMessages()` requires non-empty, non-whitespace `threadId` (throws error instead of returning empty results)
|
|
28
|
+
|
|
29
|
+
**Migration:**
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
// Storage/Memory: Replace getMessagesPaginated with listMessages
|
|
33
|
+
- storage.getMessagesPaginated({ threadId, selectBy: { pagination: { page: 0, perPage: 20 } } })
|
|
34
|
+
+ storage.listMessages({ threadId, page: 0, perPage: 20 })
|
|
35
|
+
+ storage.listMessages({ threadId, page: 0, perPage: false }) // Fetch all
|
|
36
|
+
|
|
37
|
+
// Memory: Replace selectBy with flat parameters
|
|
38
|
+
- memory.query({ threadId, selectBy: { last: 20, include: [...] } })
|
|
39
|
+
+ memory.query({ threadId, perPage: 20, include: [...] })
|
|
40
|
+
|
|
41
|
+
// Client SDK
|
|
42
|
+
- thread.getMessagesPaginated({ selectBy: { pagination: { page: 0 } } })
|
|
43
|
+
+ thread.listMessages({ page: 0, perPage: 20 })
|
|
44
|
+
```
|
|
45
|
+
|
|
9
46
|
- Replace `getThreadsByResourceIdPaginated` with `listThreadsByResourceId` across memory handlers. Update client SDK to use `listThreads()` with `offset`/`limit` parameters instead of deprecated `getMemoryThreads()`. Consolidate `/api/memory/threads` routes to single paginated endpoint. ([#9508](https://github.com/mastra-ai/mastra/pull/9508))
|
|
10
47
|
|
|
11
48
|
- Rename RuntimeContext to RequestContext ([#9511](https://github.com/mastra-ai/mastra/pull/9511))
|
|
12
49
|
|
|
50
|
+
- Rename `defaultVNextStreamOptions` to `defaultOptions`. Add "Legacy" suffix to v1 option properties and methods (`defaultGenerateOptions` → `defaultGenerateOptionsLegacy`, `defaultStreamOptions` → `defaultStreamOptionsLegacy`). ([#9535](https://github.com/mastra-ai/mastra/pull/9535))
|
|
51
|
+
|
|
52
|
+
- Remove `getThreadsByResourceId` and `getThreadsByResourceIdPaginated` methods from storage interfaces in favor of `listThreadsByResourceId`. The new method uses `offset`/`limit` pagination and a nested `orderBy` object structure (`{ field, direction }`). ([#9536](https://github.com/mastra-ai/mastra/pull/9536))
|
|
53
|
+
|
|
54
|
+
- **Breaking Change**: Remove legacy v1 watch events and consolidate on v2 implementation. ([#9252](https://github.com/mastra-ai/mastra/pull/9252))
|
|
55
|
+
|
|
56
|
+
This change simplifies the workflow watching API by removing the legacy v1 event system and promoting v2 as the standard (renamed to just `watch`).
|
|
57
|
+
|
|
58
|
+
### What's Changed
|
|
59
|
+
- Removed legacy v1 watch event handlers and types
|
|
60
|
+
- Renamed `watch-v2` to `watch` throughout the codebase
|
|
61
|
+
- Removed `.watch()` method from client-js SDK (`Workflow` and `AgentBuilder` classes)
|
|
62
|
+
- Removed `/watch` HTTP endpoints from server and deployer
|
|
63
|
+
- Removed `WorkflowWatchResult` and v1 `WatchEvent` types
|
|
64
|
+
|
|
65
|
+
- **BREAKING CHANGE**: Pagination APIs now use `page`/`perPage` instead of `offset`/`limit` ([#9592](https://github.com/mastra-ai/mastra/pull/9592))
|
|
66
|
+
|
|
67
|
+
All storage and memory pagination APIs have been updated to use `page` (0-indexed) and `perPage` instead of `offset` and `limit`, aligning with standard REST API patterns.
|
|
68
|
+
|
|
69
|
+
**Affected APIs:**
|
|
70
|
+
- `Memory.listThreadsByResourceId()`
|
|
71
|
+
- `Memory.listMessages()`
|
|
72
|
+
- `Storage.listWorkflowRuns()`
|
|
73
|
+
|
|
74
|
+
**Migration:**
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
// Before
|
|
78
|
+
await memory.listThreadsByResourceId({
|
|
79
|
+
resourceId: 'user-123',
|
|
80
|
+
offset: 20,
|
|
81
|
+
limit: 10,
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
// After
|
|
85
|
+
await memory.listThreadsByResourceId({
|
|
86
|
+
resourceId: 'user-123',
|
|
87
|
+
page: 2, // page = Math.floor(offset / limit)
|
|
88
|
+
perPage: 10,
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
// Before
|
|
92
|
+
await memory.listMessages({
|
|
93
|
+
threadId: 'thread-456',
|
|
94
|
+
offset: 20,
|
|
95
|
+
limit: 10,
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// After
|
|
99
|
+
await memory.listMessages({
|
|
100
|
+
threadId: 'thread-456',
|
|
101
|
+
page: 2,
|
|
102
|
+
perPage: 10,
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// Before
|
|
106
|
+
await storage.listWorkflowRuns({
|
|
107
|
+
workflowName: 'my-workflow',
|
|
108
|
+
offset: 20,
|
|
109
|
+
limit: 10,
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
// After
|
|
113
|
+
await storage.listWorkflowRuns({
|
|
114
|
+
workflowName: 'my-workflow',
|
|
115
|
+
page: 2,
|
|
116
|
+
perPage: 10,
|
|
117
|
+
});
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**Additional improvements:**
|
|
121
|
+
- Added validation for negative `page` values in all storage implementations
|
|
122
|
+
- Improved `perPage` validation to handle edge cases (negative values, `0`, `false`)
|
|
123
|
+
- Added reusable query parser utilities for consistent validation in handlers
|
|
124
|
+
|
|
13
125
|
- Changing getAgents -> listAgents, getTools -> listTools, getWorkflows -> listWorkflows ([#9495](https://github.com/mastra-ai/mastra/pull/9495))
|
|
14
126
|
|
|
15
127
|
- Removed old tracing code based on OpenTelemetry ([#9237](https://github.com/mastra-ai/mastra/pull/9237))
|
|
16
128
|
|
|
129
|
+
- Remove deprecated vector prompts and cohere provider from code ([#9596](https://github.com/mastra-ai/mastra/pull/9596))
|
|
130
|
+
|
|
131
|
+
- Mark as stable ([`83d5942`](https://github.com/mastra-ai/mastra/commit/83d5942669ce7bba4a6ca4fd4da697a10eb5ebdc))
|
|
132
|
+
|
|
133
|
+
- Enforcing id required on Processor primitive ([#9591](https://github.com/mastra-ai/mastra/pull/9591))
|
|
134
|
+
|
|
135
|
+
- Renamed `MastraMessageV2` to `MastraDBMessage` ([#9255](https://github.com/mastra-ai/mastra/pull/9255))
|
|
136
|
+
Made the return format of all methods that return db messages consistent. It's always `{ messages: MastraDBMessage[] }` now, and messages can be converted after that using `@mastra/ai-sdk/ui`'s `toAISdkV4/5Messages()` function
|
|
137
|
+
|
|
138
|
+
- moved ai-tracing code into @mastra/observability ([#9661](https://github.com/mastra-ai/mastra/pull/9661))
|
|
139
|
+
|
|
17
140
|
- Remove legacy evals from Mastra ([#9491](https://github.com/mastra-ai/mastra/pull/9491))
|
|
18
141
|
|
|
19
142
|
### Minor Changes
|
|
@@ -63,6 +186,54 @@
|
|
|
63
186
|
|
|
64
187
|
- Make step optional in all resume APIs ([#9454](https://github.com/mastra-ai/mastra/pull/9454))
|
|
65
188
|
|
|
189
|
+
- Update tool execution signature ([#9587](https://github.com/mastra-ai/mastra/pull/9587))
|
|
190
|
+
|
|
191
|
+
Consolidated the 3 different execution contexts to one
|
|
192
|
+
|
|
193
|
+
```typescript
|
|
194
|
+
// before depending on the context the tool was executed in
|
|
195
|
+
tool.execute({ context: data });
|
|
196
|
+
tool.execute({ context: { inputData: data } });
|
|
197
|
+
tool.execute(data);
|
|
198
|
+
|
|
199
|
+
// now, for all contexts
|
|
200
|
+
tool.execute(data, context);
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
**Before:**
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
inputSchema: z.object({ something: z.string() }),
|
|
207
|
+
execute: async ({ context, tracingContext, runId, ... }) => {
|
|
208
|
+
return doSomething(context.string);
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
**After:**
|
|
213
|
+
|
|
214
|
+
```typescript
|
|
215
|
+
inputSchema: z.object({ something: z.string() }),
|
|
216
|
+
execute: async (inputData, context) => {
|
|
217
|
+
const { agent, mcp, workflow, ...sharedContext } = context
|
|
218
|
+
|
|
219
|
+
// context that only an agent would get like toolCallId, messages, suspend, resume, etc
|
|
220
|
+
if (agent) {
|
|
221
|
+
doSomething(inputData.something, agent)
|
|
222
|
+
// context that only a workflow would get like runId, state, suspend, resume, etc
|
|
223
|
+
} else if (workflow) {
|
|
224
|
+
doSomething(inputData.something, workflow)
|
|
225
|
+
// context that only a workflow would get like "extra", "elicitation"
|
|
226
|
+
} else if (mcp) {
|
|
227
|
+
doSomething(inputData.something, mcp)
|
|
228
|
+
} else {
|
|
229
|
+
// Running a tool in no execution context
|
|
230
|
+
return doSomething(inputData.something);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
- Add the description field to listAgents ([#9672](https://github.com/mastra-ai/mastra/pull/9672))
|
|
236
|
+
|
|
66
237
|
- Add tool call approval ([#8649](https://github.com/mastra-ai/mastra/pull/8649))
|
|
67
238
|
|
|
68
239
|
- Fixes issue where clicking the reset button in the model picker would fail to restore the original LanguageModelV2 (or any other types) object that was passed during agent construction. ([#9481](https://github.com/mastra-ai/mastra/pull/9481))
|
|
@@ -75,8 +246,10 @@
|
|
|
75
246
|
|
|
76
247
|
- Use memory mock in server tests ([#9486](https://github.com/mastra-ai/mastra/pull/9486))
|
|
77
248
|
|
|
78
|
-
-
|
|
79
|
-
|
|
249
|
+
- Remove format from stream/generate ([#9577](https://github.com/mastra-ai/mastra/pull/9577))
|
|
250
|
+
|
|
251
|
+
- Updated dependencies [[`f743dbb`](https://github.com/mastra-ai/mastra/commit/f743dbb8b40d1627b5c10c0e6fc154f4ebb6e394), [`fec5129`](https://github.com/mastra-ai/mastra/commit/fec5129de7fc64423ea03661a56cef31dc747a0d), [`0e8ed46`](https://github.com/mastra-ai/mastra/commit/0e8ed467c54d6901a6a365f270ec15d6faadb36c), [`6c049d9`](https://github.com/mastra-ai/mastra/commit/6c049d94063fdcbd5b81c4912a2bf82a92c9cc0b), [`3443770`](https://github.com/mastra-ai/mastra/commit/3443770662df8eb24c9df3589b2792d78cfcb811), [`f0a07e0`](https://github.com/mastra-ai/mastra/commit/f0a07e0111b3307c5fabfa4094c5c2cfb734fbe6), [`1521d71`](https://github.com/mastra-ai/mastra/commit/1521d716e5daedc74690c983fbd961123c56756b), [`9e1911d`](https://github.com/mastra-ai/mastra/commit/9e1911db2b4db85e0e768c3f15e0d61e319869f6), [`ebac155`](https://github.com/mastra-ai/mastra/commit/ebac15564a590117db7078233f927a7e28a85106), [`5948e6a`](https://github.com/mastra-ai/mastra/commit/5948e6a5146c83666ba3f294b2be576c82a513fb), [`8940859`](https://github.com/mastra-ai/mastra/commit/89408593658199b4ad67f7b65e888f344e64a442), [`e629310`](https://github.com/mastra-ai/mastra/commit/e629310f1a73fa236d49ec7a1d1cceb6229dc7cc), [`4c6b492`](https://github.com/mastra-ai/mastra/commit/4c6b492c4dd591c6a592520c1f6855d6e936d71f), [`dff01d8`](https://github.com/mastra-ai/mastra/commit/dff01d81ce1f4e4087cfac20fa868e6db138dd14), [`9d819d5`](https://github.com/mastra-ai/mastra/commit/9d819d54b61481639f4008e4694791bddf187edd), [`71c8d6c`](https://github.com/mastra-ai/mastra/commit/71c8d6c161253207b2b9588bdadb7eed604f7253), [`6179a9b`](https://github.com/mastra-ai/mastra/commit/6179a9ba36ffac326de3cc3c43cdc8028d37c251), [`00f4921`](https://github.com/mastra-ai/mastra/commit/00f4921dd2c91a1e5446799599ef7116a8214a1a), [`7051bf3`](https://github.com/mastra-ai/mastra/commit/7051bf38b3b122a069008f861f7bfc004a6d9f6e), [`a8f1494`](https://github.com/mastra-ai/mastra/commit/a8f1494f4bbdc2770bcf327d4c7d869e332183f1), [`0793497`](https://github.com/mastra-ai/mastra/commit/079349753620c40246ffd673e3f9d7d9820beff3), [`5df9cce`](https://github.com/mastra-ai/mastra/commit/5df9cce1a753438413f64c11eeef8f845745c2a8), [`a854ede`](https://github.com/mastra-ai/mastra/commit/a854ede62bf5ac0945a624ac48913dd69c73aabf), [`c576fc0`](https://github.com/mastra-ai/mastra/commit/c576fc0b100b2085afded91a37c97a0ea0ec09c7), [`3defc80`](https://github.com/mastra-ai/mastra/commit/3defc80cf2b88a1b7fc1cc4ddcb91e982a614609), [`16153fe`](https://github.com/mastra-ai/mastra/commit/16153fe7eb13c99401f48e6ca32707c965ee28b9), [`9f4a683`](https://github.com/mastra-ai/mastra/commit/9f4a6833e88b52574665c028fd5508ad5c2f6004), [`bc94344`](https://github.com/mastra-ai/mastra/commit/bc943444a1342d8a662151b7bce1df7dae32f59c), [`57d157f`](https://github.com/mastra-ai/mastra/commit/57d157f0b163a95c3e6c9eae31bdb11d1bfc64f9), [`2a90c55`](https://github.com/mastra-ai/mastra/commit/2a90c55a86a9210697d5adaab5ee94584b079adc), [`96d35f6`](https://github.com/mastra-ai/mastra/commit/96d35f61376bc2b1bf148648a2c1985bd51bef55), [`5cbe88a`](https://github.com/mastra-ai/mastra/commit/5cbe88aefbd9f933bca669fd371ea36bf939ac6d), [`a1bd7b8`](https://github.com/mastra-ai/mastra/commit/a1bd7b8571db16b94eb01588f451a74758c96d65), [`d78b38d`](https://github.com/mastra-ai/mastra/commit/d78b38d898fce285260d3bbb4befade54331617f), [`0633100`](https://github.com/mastra-ai/mastra/commit/0633100a911ad22f5256471bdf753da21c104742), [`c710c16`](https://github.com/mastra-ai/mastra/commit/c710c1652dccfdc4111c8412bca7a6bb1d48b441), [`cfae733`](https://github.com/mastra-ai/mastra/commit/cfae73394f4920635e6c919c8e95ff9a0788e2e5), [`e3dfda7`](https://github.com/mastra-ai/mastra/commit/e3dfda7b11bf3b8c4bb55637028befb5f387fc74), [`844ea5d`](https://github.com/mastra-ai/mastra/commit/844ea5dc0c248961e7bf73629ae7dcff503e853c), [`f0f8f12`](https://github.com/mastra-ai/mastra/commit/f0f8f125c308f2d0fd36942ef652fd852df7522f), [`0d7618b`](https://github.com/mastra-ai/mastra/commit/0d7618bc650bf2800934b243eca5648f4aeed9c2), [`7b763e5`](https://github.com/mastra-ai/mastra/commit/7b763e52fc3eaf699c2a99f2adf418dd46e4e9a5), [`d36cfbb`](https://github.com/mastra-ai/mastra/commit/d36cfbbb6565ba5f827883cc9bb648eb14befdc1), [`3697853`](https://github.com/mastra-ai/mastra/commit/3697853deeb72017d90e0f38a93c1e29221aeca0), [`a534e95`](https://github.com/mastra-ai/mastra/commit/a534e9591f83b3cc1ebff99c67edf4cda7bf81d3), [`9d0e7fe`](https://github.com/mastra-ai/mastra/commit/9d0e7feca8ed98de959f53476ee1456073673348), [`53d927c`](https://github.com/mastra-ai/mastra/commit/53d927cc6f03bff33655b7e2b788da445a08731d), [`22f64bc`](https://github.com/mastra-ai/mastra/commit/22f64bc1d37149480b58bf2fefe35b79a1e3e7d5), [`83d5942`](https://github.com/mastra-ai/mastra/commit/83d5942669ce7bba4a6ca4fd4da697a10eb5ebdc), [`bda6370`](https://github.com/mastra-ai/mastra/commit/bda637009360649aaf579919e7873e33553c273e), [`d7acd8e`](https://github.com/mastra-ai/mastra/commit/d7acd8e987b5d7eff4fd98b0906c17c06a2e83d5), [`c7f1f7d`](https://github.com/mastra-ai/mastra/commit/c7f1f7d24f61f247f018cc2d1f33bf63212959a7), [`0bddc6d`](https://github.com/mastra-ai/mastra/commit/0bddc6d8dbd6f6008c0cba2e4960a2da75a55af1), [`735d8c1`](https://github.com/mastra-ai/mastra/commit/735d8c1c0d19fbc09e6f8b66cf41bc7655993838), [`acf322e`](https://github.com/mastra-ai/mastra/commit/acf322e0f1fd0189684cf529d91c694bea918a45), [`c942802`](https://github.com/mastra-ai/mastra/commit/c942802a477a925b01859a7b8688d4355715caaa), [`a0c8c1b`](https://github.com/mastra-ai/mastra/commit/a0c8c1b87d4fee252aebda73e8637fbe01d761c9), [`cc34739`](https://github.com/mastra-ai/mastra/commit/cc34739c34b6266a91bea561119240a7acf47887), [`c218bd3`](https://github.com/mastra-ai/mastra/commit/c218bd3759e32423735b04843a09404572631014), [`2c4438b`](https://github.com/mastra-ai/mastra/commit/2c4438b87817ab7eed818c7990fef010475af1a3), [`2b8893c`](https://github.com/mastra-ai/mastra/commit/2b8893cb108ef9acb72ee7835cd625610d2c1a4a), [`8e5c75b`](https://github.com/mastra-ai/mastra/commit/8e5c75bdb1d08a42d45309a4c72def4b6890230f), [`fa8409b`](https://github.com/mastra-ai/mastra/commit/fa8409bc39cfd8ba6643b9db5269b90b22e2a2f7), [`173c535`](https://github.com/mastra-ai/mastra/commit/173c535c0645b0da404fe09f003778f0b0d4e019)]:
|
|
252
|
+
- @mastra/core@0.0.0-fix-9244-clickhouse-metadata-20251104213434
|
|
80
253
|
|
|
81
254
|
## 0.22.2
|
|
82
255
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { handleError } from './chunk-
|
|
2
|
-
import { HTTPException } from './chunk-
|
|
1
|
+
import { handleError } from './chunk-UXGQZUYZ.js';
|
|
2
|
+
import { HTTPException } from './chunk-6QWQZI4Q.js';
|
|
3
3
|
import { __export } from './chunk-PR4QN5HX.js';
|
|
4
|
-
import { scoreTraces } from '@mastra/core/
|
|
4
|
+
import { scoreTraces } from '@mastra/core/evals/scoreTraces';
|
|
5
5
|
|
|
6
6
|
// src/server/handlers/observability.ts
|
|
7
7
|
var observability_exports = {};
|
|
8
8
|
__export(observability_exports, {
|
|
9
9
|
getAITraceHandler: () => getAITraceHandler,
|
|
10
10
|
getAITracesPaginatedHandler: () => getAITracesPaginatedHandler,
|
|
11
|
-
|
|
11
|
+
listScoresBySpan: () => listScoresBySpan,
|
|
12
12
|
scoreTracesHandler: () => scoreTracesHandler
|
|
13
13
|
});
|
|
14
14
|
async function getAITraceHandler({ mastra, traceId }) {
|
|
@@ -69,7 +69,7 @@ async function scoreTracesHandler({ mastra, body }) {
|
|
|
69
69
|
}
|
|
70
70
|
const { scorerName, targets } = body;
|
|
71
71
|
if (!scorerName) {
|
|
72
|
-
throw new HTTPException(400, { message: "Scorer
|
|
72
|
+
throw new HTTPException(400, { message: "Scorer ID is required" });
|
|
73
73
|
}
|
|
74
74
|
if (!targets || targets.length === 0) {
|
|
75
75
|
throw new HTTPException(400, { message: "At least one target is required" });
|
|
@@ -78,13 +78,13 @@ async function scoreTracesHandler({ mastra, body }) {
|
|
|
78
78
|
if (!storage) {
|
|
79
79
|
throw new HTTPException(500, { message: "Storage is not available" });
|
|
80
80
|
}
|
|
81
|
-
const scorer = mastra.
|
|
81
|
+
const scorer = mastra.getScorerById(scorerName);
|
|
82
82
|
if (!scorer) {
|
|
83
83
|
throw new HTTPException(404, { message: `Scorer '${scorerName}' not found` });
|
|
84
84
|
}
|
|
85
85
|
const logger = mastra.getLogger();
|
|
86
86
|
scoreTraces({
|
|
87
|
-
|
|
87
|
+
scorerId: scorer.config.id || scorer.config.name,
|
|
88
88
|
targets,
|
|
89
89
|
mastra
|
|
90
90
|
}).catch((error) => {
|
|
@@ -99,7 +99,7 @@ async function scoreTracesHandler({ mastra, body }) {
|
|
|
99
99
|
handleError(error, "Error processing trace scoring");
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
|
-
async function
|
|
102
|
+
async function listScoresBySpan({
|
|
103
103
|
mastra,
|
|
104
104
|
traceId,
|
|
105
105
|
spanId,
|
|
@@ -113,12 +113,12 @@ async function getScoresBySpan({
|
|
|
113
113
|
if (!traceId || !spanId) {
|
|
114
114
|
throw new HTTPException(400, { message: "Trace ID and span ID are required" });
|
|
115
115
|
}
|
|
116
|
-
return await storage.
|
|
116
|
+
return await storage.listScoresBySpan({ traceId, spanId, pagination });
|
|
117
117
|
} catch (error) {
|
|
118
118
|
return handleError(error, "Error getting scores by span");
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
export { getAITraceHandler, getAITracesPaginatedHandler,
|
|
123
|
-
//# sourceMappingURL=chunk-
|
|
124
|
-
//# sourceMappingURL=chunk-
|
|
122
|
+
export { getAITraceHandler, getAITracesPaginatedHandler, listScoresBySpan, observability_exports, scoreTracesHandler };
|
|
123
|
+
//# sourceMappingURL=chunk-46Z2KDQL.js.map
|
|
124
|
+
//# sourceMappingURL=chunk-46Z2KDQL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/server/handlers/observability.ts"],"names":[],"mappings":";;;;;;AAAA,IAAA,qBAAA,GAAA;AAAA,QAAA,CAAA,qBAAA,EAAA;AAAA,EAAA,iBAAA,EAAA,MAAA,iBAAA;AAAA,EAAA,2BAAA,EAAA,MAAA,2BAAA;AAAA,EAAA,gBAAA,EAAA,MAAA,gBAAA;AAAA,EAAA,kBAAA,EAAA,MAAA;AAAA,CAAA,CAAA;AA0BA,eAAsB,iBAAA,CAAkB,EAAE,MAAA,EAAQ,OAAA,EAAQ,EAA+C;AACvG,EAAA,IAAI;AACF,IAAA,IAAI,CAAC,OAAA,EAAS;AACZ,MAAA,MAAM,IAAI,aAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,wBAAwB,CAAA;AAAA,IAClE;AAEA,IAAA,MAAM,OAAA,GAAU,OAAO,UAAA,EAAW;AAClC,IAAA,IAAI,CAAC,OAAA,EAAS;AACZ,MAAA,MAAM,IAAI,aAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,4BAA4B,CAAA;AAAA,IACtE;AAEA,IAAA,MAAM,KAAA,GAAQ,MAAM,OAAA,CAAQ,UAAA,CAAW,OAAO,CAAA;AAE9C,IAAA,IAAI,CAAC,KAAA,EAAO;AACV,MAAA,MAAM,IAAI,cAAc,GAAA,EAAK,EAAE,SAAS,CAAA,eAAA,EAAkB,OAAO,eAAe,CAAA;AAAA,IAClF;AAEA,IAAA,OAAO,KAAA;AAAA,EACT,SAAS,KAAA,EAAO;AACd,IAAA,WAAA,CAAY,OAAO,wBAAwB,CAAA;AAAA,EAC7C;AACF;AAMA,eAAsB,2BAAA,CAA4B,EAAE,MAAA,EAAQ,IAA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esPaginatedArg, StoragePagination } from '@mastra/core/storage';\nimport { HTTPException } from '../http-exception';\nimport type { Context } from '../types';\nimport { handleError } from './error';\n\ninterface ObservabilityContext extends Context {\n traceId?: string;\n body?: AITracesPaginatedArg;\n}\n\ninterface ScoreTracesContext extends Context {\n body?: {\n // scorer.id\n scorerName: string;\n targets: Array<{\n traceId: string;\n spanId?: string;\n }>;\n };\n}\n\n/**\n * Get a complete AI trace by trace ID\n * Returns all spans in the trace with their parent-child relationships\n */\nexport async function getAITraceHandler({ mastra, traceId }: ObservabilityContext & { traceId: string }) {\n try {\n if (!traceId) {\n throw new HTTPException(400, { message: 'Trace ID is required' });\n }\n\n const storage = mastra.getStorage();\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not available' });\n }\n\n const trace = await storage.getAITrace(traceId);\n\n if (!trace) {\n throw new HTTPException(404, { message: `Trace with ID '${traceId}' not found` });\n }\n\n return trace;\n } catch (error) {\n handleError(error, 'Error getting AI trace');\n }\n}\n\n/**\n * Get paginated AI traces with filtering and pagination\n * Returns only root spans (parent spans) for pagination, not child spans\n */\nexport async function getAITracesPaginatedHandler({ mastra, body }: ObservabilityContext) {\n try {\n const storage = mastra.getStorage();\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not available' });\n }\n\n if (!body) {\n throw new HTTPException(400, { message: 'Request body is required' });\n }\n\n const { filters, pagination } = body;\n\n if (pagination?.page && pagination.page < 0) {\n throw new HTTPException(400, { message: 'Page must be a non-negative integer' });\n }\n\n if (pagination?.perPage && pagination.perPage < 0) {\n throw new HTTPException(400, { message: 'Per page must be a non-negative integer' });\n }\n\n if (pagination?.dateRange) {\n const { start, end } = pagination.dateRange;\n\n if (start && !(start instanceof Date)) {\n throw new HTTPException(400, { message: 'Invalid date format in date range' });\n }\n\n if (end && !(end instanceof Date)) {\n throw new HTTPException(400, { message: 'Invalid date format in date range' });\n }\n }\n\n return storage.getAITracesPaginated({\n pagination,\n filters,\n });\n } catch (error) {\n handleError(error, 'Error getting AI traces paginated');\n }\n}\n\n/**\n * Score traces using a specified scorer\n * Fire-and-forget approach - returns immediately while scoring runs in background\n */\nexport async function scoreTracesHandler({ mastra, body }: ScoreTracesContext) {\n try {\n if (!body) {\n throw new HTTPException(400, { message: 'Request body is required' });\n }\n\n const { scorerName, targets } = body;\n\n if (!scorerName) {\n throw new HTTPException(400, { message: 'Scorer ID is required' });\n }\n\n if (!targets || targets.length === 0) {\n throw new HTTPException(400, { message: 'At least one target is required' });\n }\n\n const storage = mastra.getStorage();\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not available' });\n }\n\n const scorer = mastra.getScorerById(scorerName);\n if (!scorer) {\n throw new HTTPException(404, { message: `Scorer '${scorerName}' not found` });\n }\n\n const logger = mastra.getLogger();\n\n scoreTraces({\n scorerId: scorer.config.id || scorer.config.name,\n targets,\n mastra,\n }).catch(error => {\n logger?.error(`Background trace scoring failed: ${error.message}`, error);\n });\n\n // Return immediate response\n return {\n status: 'success',\n message: `Scoring started for ${targets.length} ${targets.length === 1 ? 'trace' : 'traces'}`,\n traceCount: targets.length,\n };\n } catch (error) {\n handleError(error, 'Error processing trace scoring');\n }\n}\n\nexport async function listScoresBySpan({\n mastra,\n traceId,\n spanId,\n pagination,\n}: Context & { traceId: string; spanId: string; pagination: StoragePagination }) {\n try {\n const storage = mastra.getStorage();\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not available' });\n }\n\n if (!traceId || !spanId) {\n throw new HTTPException(400, { message: 'Trace ID and span ID are required' });\n }\n\n return await storage.listScoresBySpan({ traceId, spanId, pagination });\n } catch (error) {\n return handleError(error, 'Error getting scores by span');\n }\n}\n"]}
|
|
@@ -35,5 +35,5 @@ var HTTPException = class extends Error {
|
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
exports.HTTPException = HTTPException;
|
|
38
|
-
//# sourceMappingURL=chunk-
|
|
39
|
-
//# sourceMappingURL=chunk-
|
|
38
|
+
//# sourceMappingURL=chunk-64ITUOXI.cjs.map
|
|
39
|
+
//# sourceMappingURL=chunk-64ITUOXI.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/server/http-exception.ts"],"names":[],"mappings":";;;AA0GO,IAAM,aAAA,GAAN,cAA4B,KAAA,CAAM;AAAA,EAC9B,GAAA;AAAA,EACA,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOT,WAAA,CAAY,MAAA,GAAqB,GAAA,EAAK,OAAA,EAAgC;AACpE,IAAA,KAAA,CAAM,SAAS,OAAA,EAAS,EAAE,KAAA,EAAO,OAAA,EAAS,OAAO,CAAA;AACjD,IAAA,IAAA,CAAK,MAAM,OAAA,EAAS,GAAA;AACpB,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AACd,IAAA,IAAA,CAAK,KAAA,GAAQ,OAAA,EAAS,KAAA,IAAS,IAAA,CAAK,KAAA;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,WAAA,GAAwB;AACtB,IAAA,IAAI,KAAK,GAAA,EAAK;AACZ,MAAA,MAAM,WAAA,GAAc,IAAI,QAAA,CAAS,IAAA,CAAK,IAAI,IAAA,EAAM;AAAA,QAC9C,QAAQ,IAAA,CAAK,MAAA;AAAA,QACb,OAAA,EAAS,KAAK,GAAA,CAAI;AAAA,OACnB,CAAA;AACD,MAAA,OAAO,WAAA;AAAA,IACT;AACA,IAAA,OAAO,IAAI,QAAA,CAAS,IAAA,CAAK,OAAA,EAAS;AAAA,MAChC,QAAQ,IAAA,CAAK;AAAA,KACd,CAAA;AAAA,EACH;AACF","file":"chunk-64ITUOXI.cjs","sourcesContent":["// Copied from https://github.com/honojs/hono/blob/main/packages/hono/src/http-exception.ts\n\n/**\n * @module\n * This module provides the `HTTPException` class.\n */\n\ntype InfoStatusCode = 100 | 101 | 102 | 103;\ntype SuccessStatusCode = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226;\ntype DeprecatedStatusCode = 305 | 306;\ntype RedirectStatusCode = 300 | 301 | 302 | 303 | 304 | DeprecatedStatusCode | 307 | 308;\ntype ClientErrorStatusCode =\n | 400\n | 401\n | 402\n | 403\n | 404\n | 405\n | 406\n | 407\n | 408\n | 409\n | 410\n | 411\n | 412\n | 413\n | 414\n | 415\n | 416\n | 417\n | 418\n | 421\n | 422\n | 423\n | 424\n | 425\n | 426\n | 428\n | 429\n | 431\n | 451;\ntype ServerErrorStatusCode = 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511;\n\n/**\n * `UnofficialStatusCode` can be used to specify an unofficial status code.\n * @example\n *\n * ```ts\n * app.get('/unknown', (c) => {\n * return c.text(\"Unknown Error\", 520 as UnofficialStatusCode)\n * })\n * ```\n */\nexport type UnofficialStatusCode = -1;\n\n/**\n * If you want to use an unofficial status, use `UnofficialStatusCode`.\n */\nexport type StatusCode =\n | InfoStatusCode\n | SuccessStatusCode\n | RedirectStatusCode\n | ClientErrorStatusCode\n | ServerErrorStatusCode\n | UnofficialStatusCode;\n\n/**\n * Options for creating an `HTTPException`.\n * @property res - Optional response object to use.\n * @property message - Optional custom error message.\n * @property cause - Optional cause of the error.\n * @property stack - Optional stack trace for the error.\n */\ntype HTTPExceptionOptions = {\n res?: Response;\n message?: string;\n cause?: unknown;\n stack?: string;\n};\n\n/**\n * `HTTPException` must be used when a fatal error such as authentication failure occurs.\n *\n * @see {@link https://hono.dev/docs/api/exception}\n *\n * @param {StatusCode} status - status code of HTTPException\n * @param {HTTPExceptionOptions} options - options of HTTPException\n * @param {HTTPExceptionOptions[\"res\"]} options.res - response of options of HTTPException\n * @param {HTTPExceptionOptions[\"message\"]} options.message - message of options of HTTPException\n * @param {HTTPExceptionOptions[\"cause\"]} options.cause - cause of options of HTTPException\n *\n * @example\n * ```ts\n * import { HTTPException } from 'hono/http-exception'\n *\n * // ...\n *\n * app.post('/auth', async (c, next) => {\n * // authentication\n * if (authorized === false) {\n * throw new HTTPException(401, { message: 'Custom error message' })\n * }\n * await next()\n * })\n * ```\n */\nexport class HTTPException extends Error {\n readonly res?: Response;\n readonly status: StatusCode;\n\n /**\n * Creates an instance of `HTTPException`.\n * @param status - HTTP status code for the exception. Defaults to 500.\n * @param options - Additional options for the exception.\n */\n constructor(status: StatusCode = 500, options?: HTTPExceptionOptions) {\n super(options?.message, { cause: options?.cause });\n this.res = options?.res;\n this.status = status;\n this.stack = options?.stack || this.stack;\n }\n\n /**\n * Returns the response object associated with the exception.\n * If a response object is not provided, a new response is created with the error message and status code.\n * @returns The response object.\n */\n getResponse(): Response {\n if (this.res) {\n const newResponse = new Response(this.res.body, {\n status: this.status,\n headers: this.res.headers,\n });\n return newResponse;\n }\n return new Response(this.message, {\n status: this.status,\n });\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/server/http-exception.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/server/http-exception.ts"],"names":[],"mappings":";AA0GO,IAAM,aAAA,GAAN,cAA4B,KAAA,CAAM;AAAA,EAC9B,GAAA;AAAA,EACA,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOT,WAAA,CAAY,MAAA,GAAqB,GAAA,EAAK,OAAA,EAAgC;AACpE,IAAA,KAAA,CAAM,SAAS,OAAA,EAAS,EAAE,KAAA,EAAO,OAAA,EAAS,OAAO,CAAA;AACjD,IAAA,IAAA,CAAK,MAAM,OAAA,EAAS,GAAA;AACpB,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AACd,IAAA,IAAA,CAAK,KAAA,GAAQ,OAAA,EAAS,KAAA,IAAS,IAAA,CAAK,KAAA;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,WAAA,GAAwB;AACtB,IAAA,IAAI,KAAK,GAAA,EAAK;AACZ,MAAA,MAAM,WAAA,GAAc,IAAI,QAAA,CAAS,IAAA,CAAK,IAAI,IAAA,EAAM;AAAA,QAC9C,QAAQ,IAAA,CAAK,MAAA;AAAA,QACb,OAAA,EAAS,KAAK,GAAA,CAAI;AAAA,OACnB,CAAA;AACD,MAAA,OAAO,WAAA;AAAA,IACT;AACA,IAAA,OAAO,IAAI,QAAA,CAAS,IAAA,CAAK,OAAA,EAAS;AAAA,MAChC,QAAQ,IAAA,CAAK;AAAA,KACd,CAAA;AAAA,EACH;AACF","file":"chunk-6QWQZI4Q.js","sourcesContent":["// Copied from https://github.com/honojs/hono/blob/main/packages/hono/src/http-exception.ts\n\n/**\n * @module\n * This module provides the `HTTPException` class.\n */\n\ntype InfoStatusCode = 100 | 101 | 102 | 103;\ntype SuccessStatusCode = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226;\ntype DeprecatedStatusCode = 305 | 306;\ntype RedirectStatusCode = 300 | 301 | 302 | 303 | 304 | DeprecatedStatusCode | 307 | 308;\ntype ClientErrorStatusCode =\n | 400\n | 401\n | 402\n | 403\n | 404\n | 405\n | 406\n | 407\n | 408\n | 409\n | 410\n | 411\n | 412\n | 413\n | 414\n | 415\n | 416\n | 417\n | 418\n | 421\n | 422\n | 423\n | 424\n | 425\n | 426\n | 428\n | 429\n | 431\n | 451;\ntype ServerErrorStatusCode = 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511;\n\n/**\n * `UnofficialStatusCode` can be used to specify an unofficial status code.\n * @example\n *\n * ```ts\n * app.get('/unknown', (c) => {\n * return c.text(\"Unknown Error\", 520 as UnofficialStatusCode)\n * })\n * ```\n */\nexport type UnofficialStatusCode = -1;\n\n/**\n * If you want to use an unofficial status, use `UnofficialStatusCode`.\n */\nexport type StatusCode =\n | InfoStatusCode\n | SuccessStatusCode\n | RedirectStatusCode\n | ClientErrorStatusCode\n | ServerErrorStatusCode\n | UnofficialStatusCode;\n\n/**\n * Options for creating an `HTTPException`.\n * @property res - Optional response object to use.\n * @property message - Optional custom error message.\n * @property cause - Optional cause of the error.\n * @property stack - Optional stack trace for the error.\n */\ntype HTTPExceptionOptions = {\n res?: Response;\n message?: string;\n cause?: unknown;\n stack?: string;\n};\n\n/**\n * `HTTPException` must be used when a fatal error such as authentication failure occurs.\n *\n * @see {@link https://hono.dev/docs/api/exception}\n *\n * @param {StatusCode} status - status code of HTTPException\n * @param {HTTPExceptionOptions} options - options of HTTPException\n * @param {HTTPExceptionOptions[\"res\"]} options.res - response of options of HTTPException\n * @param {HTTPExceptionOptions[\"message\"]} options.message - message of options of HTTPException\n * @param {HTTPExceptionOptions[\"cause\"]} options.cause - cause of options of HTTPException\n *\n * @example\n * ```ts\n * import { HTTPException } from 'hono/http-exception'\n *\n * // ...\n *\n * app.post('/auth', async (c, next) => {\n * // authentication\n * if (authorized === false) {\n * throw new HTTPException(401, { message: 'Custom error message' })\n * }\n * await next()\n * })\n * ```\n */\nexport class HTTPException extends Error {\n readonly res?: Response;\n readonly status: StatusCode;\n\n /**\n * Creates an instance of `HTTPException`.\n * @param status - HTTP status code for the exception. Defaults to 500.\n * @param options - Additional options for the exception.\n */\n constructor(status: StatusCode = 500, options?: HTTPExceptionOptions) {\n super(options?.message, { cause: options?.cause });\n this.res = options?.res;\n this.status = status;\n this.stack = options?.stack || this.stack;\n }\n\n /**\n * Returns the response object associated with the exception.\n * If a response object is not provided, a new response is created with the error message and status code.\n * @returns The response object.\n */\n getResponse(): Response {\n if (this.res) {\n const newResponse = new Response(this.res.body, {\n status: this.status,\n headers: this.res.headers,\n });\n return newResponse;\n }\n return new Response(this.message, {\n status: this.status,\n });\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { validateBody } from './chunk-
|
|
2
|
-
import { handleError } from './chunk-
|
|
1
|
+
import { validateBody } from './chunk-SZIFSF4T.js';
|
|
2
|
+
import { handleError } from './chunk-UXGQZUYZ.js';
|
|
3
3
|
import { __export } from './chunk-PR4QN5HX.js';
|
|
4
4
|
|
|
5
5
|
// src/server/handlers/logs.ts
|
|
@@ -79,5 +79,5 @@ async function listLogTransports({ mastra }) {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
export { listLogTransports, listLogsByRunIdHandler, listLogsHandler, logs_exports };
|
|
82
|
-
//# sourceMappingURL=chunk-
|
|
83
|
-
//# sourceMappingURL=chunk-
|
|
82
|
+
//# sourceMappingURL=chunk-73PAWDM5.js.map
|
|
83
|
+
//# sourceMappingURL=chunk-73PAWDM5.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/server/handlers/logs.ts"],"names":[],"mappings":";;;;;AAAA,IAAA,YAAA,GAAA;AAAA,QAAA,CAAA,YAAA,EAAA;AAAA,EAAA,iBAAA,EAAA,MAAA,iBAAA;AAAA,EAAA,sBAAA,EAAA,MAAA,sBAAA;AAAA,EAAA,eAAA,EAAA,MAAA;AAAA,CAAA,CAAA;AAmBA,eAAsB,eAAA,CAAgB;AAAA,EACpC,MAAA;AAAA,EACA,WAAA;AAAA,EACA;AACF,CAAA,EAMG;AACD,EAAA,IAAI;AACF,IAAA,YAAA,CAAa,EAAE,aAAa,CAAA;AAE5B,IAAA,MAAM,EAAE,QAAA,EAAU,MAAA,EAAQ,QAAA,EAAU,OAAA,EAAS,UAAU,IAAA,EAAM,OAAA,EAAQ,GAAI,MAAA,IAAU,EAAC;AAGpF,IAAA,MAAM,OAAA,GAAU,WACZ,MAAA,CAAO,WAAA;AAAA,MAAA,CACJ,KAAA,CAAM,QAAQ,QAAQ,CAAA,GAAI,WAAW,CAAC,QAAQ,CAAA,EAAG,GAAA,CAAI,CAAA,IAAA,KAAQ;AAC5D,QAAA,MAAM,CAAC,GAAA,EAAK,KAAK,CAAA,GAAI,IAAA,CAAK,MAAM,GAAG,CAAA;AACnC,QAAA,OAAO,CAAC,KAAK,KAAK,CAAA;AAAA,MACpB,CAAC;AAAA,KACH,GACA,MAAA;AAEJ,IAAA,MAAM,IAAA,GAAO,MAAM,MAAA,CAAO,QAAA,CAAS,WAAA,EAAc;AAAA,MAC/C,QAAA;AAAA,MACA,MAAA;AA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H,GACA,MAAA;AAEJ,IAAA,MAAM,IAAA,GAAO,MAAM,MAAA,CAAO,eAAA,CAAgB;AAAA,MACxC,KAAA;AAAA,MACA,WAAA;AAAA,MACA,QAAA;AAAA,MACA,MAAA;AAAA,MACA,QAAA;AAAA,MACA,OAAA;AAAA,MACA,IAAA,EAAM,IAAA,GAAO,MAAA,CAAO,IAAI,CAAA,GAAI,MAAA;AAAA,MAC5B,OAAA,EAAS,OAAA,GAAU,MAAA,CAAO,OAAO,CAAA,GAAI;AAAA,KACtC,CAAA;AACD,IAAA,OAAO,IAAA;AAAA,EACT,SAAS,KAAA,EAAO;AACd,IAAA,OAAO,WAAA,CAAY,OAAO,8BAA8B,CAAA;AAAA,EAC1D;AACF;AAEA,eAAsB,iBAAA,CAAkB,EAAE,MAAA,EAAO,EAAgC;AAC/E,EAAA,IAAI;AACF,IAAA,MAAM,MAAA,GAAS,OAAO,SAAA,EAAU;AAChC,IAAA,MAAM,UAAA,GAAa,OAAO,aAAA,EAAc;AAExC,IAAA,OAAO;AAAA,MACL,UAAA,EAAY,aAAa,CAAC,GAAG,WAAW,IAAA,EAAM,IAAI;AAAC,KACrD;AAAA,EACF,SAAS,KAAA,EAAO;AACd,IAAA,OAAO,WAAA,CAAY,OAAO,8BAA8B,CAAA;AAAA,EAC1D;AACF","file":"chunk-73PAWDM5.js","sourcesContent":["import type { BaseLogMessage, LogLevel } from '@mastra/core/logger';\nimport type { Mastra } from '@mastra/core/mastra';\nimport { handleError } from './error';\nimport { validateBody } from './utils';\n\ntype LogsContext = {\n mastra: Mastra;\n transportId?: string;\n runId?: string;\n params?: {\n fromDate?: Date;\n toDate?: Date;\n logLevel?: LogLevel;\n filters?: string | string[];\n page?: number;\n perPage?: number;\n };\n};\n\nexport async function listLogsHandler({\n mastra,\n transportId,\n params,\n}: Pick<LogsContext, 'mastra' | 'transportId' | 'params'>): Promise<{\n logs: BaseLogMessage[];\n total: number;\n page: number;\n perPage: number;\n hasMore: boolean;\n}> {\n try {\n validateBody({ transportId });\n\n const { fromDate, toDate, logLevel, filters: _filters, page, perPage } = params || {};\n\n // Parse filter query parameter if present\n const filters = _filters\n ? Object.fromEntries(\n (Array.isArray(_filters) ? _filters : [_filters]).map(attr => {\n const [key, value] = attr.split(':');\n return [key, value];\n }),\n )\n : undefined;\n\n const logs = await mastra.listLogs(transportId!, {\n fromDate,\n toDate,\n logLevel,\n filters,\n page: page ? Number(page) : undefined,\n perPage: perPage ? Number(perPage) : undefined,\n });\n return logs;\n } catch (error) {\n return handleError(error, 'Error getting logs');\n }\n}\n\nexport async function listLogsByRunIdHandler({\n mastra,\n runId,\n transportId,\n params,\n}: Pick<LogsContext, 'mastra' | 'runId' | 'transportId' | 'params'>) {\n try {\n validateBody({ runId, transportId });\n\n const { fromDate, toDate, logLevel, filters: _filters, page, perPage } = params || {};\n\n // Parse filter query parameter if present\n const filters = _filters\n ? Object.fromEntries(\n (Array.isArray(_filters) ? _filters : [_filters]).map(attr => {\n const [key, value] = attr.split(':');\n return [key, value];\n }),\n )\n : undefined;\n\n const logs = await mastra.listLogsByRunId({\n runId: runId!,\n transportId: transportId!,\n fromDate,\n toDate,\n logLevel,\n filters,\n page: page ? Number(page) : undefined,\n perPage: perPage ? Number(perPage) : undefined,\n });\n return logs;\n } catch (error) {\n return handleError(error, 'Error getting logs by run ID');\n }\n}\n\nexport async function listLogTransports({ mastra }: Pick<LogsContext, 'mastra'>) {\n try {\n const logger = mastra.getLogger();\n const transports = logger.getTransports();\n\n return {\n transports: transports ? [...transports.keys()] : [],\n };\n } catch (error) {\n return handleError(error, 'Error getting log Transports');\n }\n}\n"]}
|