@mastra/server 1.29.2-alpha.0 → 1.30.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +120 -0
- package/dist/{chunk-LWK57QIA.cjs → chunk-2CFH32YO.cjs} +5 -5
- package/dist/{chunk-LWK57QIA.cjs.map → chunk-2CFH32YO.cjs.map} +1 -1
- package/dist/{chunk-BR6MQNNL.js → chunk-2HVAN7FF.js} +12 -3
- package/dist/chunk-2HVAN7FF.js.map +1 -0
- package/dist/{chunk-QDNKVREO.js → chunk-2PF5ZR2Q.js} +9 -9
- package/dist/{chunk-QDNKVREO.js.map → chunk-2PF5ZR2Q.js.map} +1 -1
- package/dist/{chunk-HYI4ZAV7.js → chunk-43CWQ4M3.js} +8 -3
- package/dist/chunk-43CWQ4M3.js.map +1 -0
- package/dist/{chunk-JJT4GBDZ.js → chunk-4BSJHDYP.js} +3 -3
- package/dist/{chunk-JJT4GBDZ.js.map → chunk-4BSJHDYP.js.map} +1 -1
- package/dist/{chunk-X2XQFFXR.js → chunk-4GOK3PCO.js} +5 -5
- package/dist/{chunk-X2XQFFXR.js.map → chunk-4GOK3PCO.js.map} +1 -1
- package/dist/{chunk-4Y5P2GYV.js → chunk-4J4K36CU.js} +3 -3
- package/dist/{chunk-4Y5P2GYV.js.map → chunk-4J4K36CU.js.map} +1 -1
- package/dist/{chunk-RQXUPTUI.js → chunk-5OOYXBPG.js} +7 -3
- package/dist/chunk-5OOYXBPG.js.map +1 -0
- package/dist/{chunk-IO7PPBD4.js → chunk-DBPJYWAH.js} +47 -86
- package/dist/chunk-DBPJYWAH.js.map +1 -0
- package/dist/{chunk-W6TZ2TNY.cjs → chunk-DZZBC6UV.cjs} +7 -7
- package/dist/{chunk-W6TZ2TNY.cjs.map → chunk-DZZBC6UV.cjs.map} +1 -1
- package/dist/{chunk-I3BHHWHT.cjs → chunk-EFW6MWXU.cjs} +4 -2
- package/dist/chunk-EFW6MWXU.cjs.map +1 -0
- package/dist/{chunk-2Z5KJJDZ.js → chunk-EPM6ILRW.js} +14 -3
- package/dist/chunk-EPM6ILRW.js.map +1 -0
- package/dist/{chunk-HWK6K3DW.cjs → chunk-EQR4MMSL.cjs} +7 -7
- package/dist/{chunk-HWK6K3DW.cjs.map → chunk-EQR4MMSL.cjs.map} +1 -1
- package/dist/{chunk-VFHNACRY.js → chunk-FN4GIXQQ.js} +5 -5
- package/dist/{chunk-VFHNACRY.js.map → chunk-FN4GIXQQ.js.map} +1 -1
- package/dist/{chunk-YO7N5VOP.js → chunk-GEXJ4LPZ.js} +3 -3
- package/dist/{chunk-YO7N5VOP.js.map → chunk-GEXJ4LPZ.js.map} +1 -1
- package/dist/{chunk-XT6GKIYW.cjs → chunk-GUWIV3ZN.cjs} +9 -2
- package/dist/chunk-GUWIV3ZN.cjs.map +1 -0
- package/dist/{chunk-PSQNWPPT.cjs → chunk-H6NJWTER.cjs} +4 -4
- package/dist/{chunk-PSQNWPPT.cjs.map → chunk-H6NJWTER.cjs.map} +1 -1
- package/dist/{chunk-B5RUOKFI.cjs → chunk-HR4M27JP.cjs} +77 -77
- package/dist/{chunk-B5RUOKFI.cjs.map → chunk-HR4M27JP.cjs.map} +1 -1
- package/dist/{chunk-VLNRGJEM.js → chunk-JZNOIGOQ.js} +3 -3
- package/dist/{chunk-VLNRGJEM.js.map → chunk-JZNOIGOQ.js.map} +1 -1
- package/dist/{chunk-VR623NIZ.cjs → chunk-KI7TGMMV.cjs} +276 -160
- package/dist/chunk-KI7TGMMV.cjs.map +1 -0
- package/dist/{chunk-P7QF3UG4.js → chunk-KJLIMNMI.js} +3 -3
- package/dist/{chunk-P7QF3UG4.js.map → chunk-KJLIMNMI.js.map} +1 -1
- package/dist/{chunk-WC4RIS4D.js → chunk-KW2MZGRE.js} +3 -3
- package/dist/{chunk-WC4RIS4D.js.map → chunk-KW2MZGRE.js.map} +1 -1
- package/dist/{chunk-IA7PNRIA.cjs → chunk-LI3EL57Z.cjs} +11 -11
- package/dist/{chunk-IA7PNRIA.cjs.map → chunk-LI3EL57Z.cjs.map} +1 -1
- package/dist/{chunk-33WVA4ZN.cjs → chunk-LKS22ETT.cjs} +19 -19
- package/dist/{chunk-33WVA4ZN.cjs.map → chunk-LKS22ETT.cjs.map} +1 -1
- package/dist/{chunk-NO3V76EI.cjs → chunk-LY6Q36YN.cjs} +17 -17
- package/dist/{chunk-NO3V76EI.cjs.map → chunk-LY6Q36YN.cjs.map} +1 -1
- package/dist/{chunk-UOWUXTUO.cjs → chunk-NGYGE7QW.cjs} +27 -27
- package/dist/{chunk-UOWUXTUO.cjs.map → chunk-NGYGE7QW.cjs.map} +1 -1
- package/dist/{chunk-JVQ5EXNJ.js → chunk-OJRAH5VV.js} +4 -3
- package/dist/chunk-OJRAH5VV.js.map +1 -0
- package/dist/{chunk-JOC7WKJ2.cjs → chunk-ONPPBXWB.cjs} +48 -48
- package/dist/{chunk-JOC7WKJ2.cjs.map → chunk-ONPPBXWB.cjs.map} +1 -1
- package/dist/{chunk-QP5DRBMC.js → chunk-QL62CV5V.js} +5 -5
- package/dist/{chunk-QP5DRBMC.js.map → chunk-QL62CV5V.js.map} +1 -1
- package/dist/{chunk-6SUTXWOK.cjs → chunk-RPMBPQNO.cjs} +12 -3
- package/dist/chunk-RPMBPQNO.cjs.map +1 -0
- package/dist/{chunk-PRK4GVU6.js → chunk-RTD3NZ4G.js} +4 -4
- package/dist/{chunk-PRK4GVU6.js.map → chunk-RTD3NZ4G.js.map} +1 -1
- package/dist/{chunk-RPOKTN4O.cjs → chunk-SEAOI56Z.cjs} +7 -7
- package/dist/{chunk-RPOKTN4O.cjs.map → chunk-SEAOI56Z.cjs.map} +1 -1
- package/dist/{chunk-K33KUMJY.js → chunk-SSMLJV2K.js} +5 -5
- package/dist/{chunk-K33KUMJY.js.map → chunk-SSMLJV2K.js.map} +1 -1
- package/dist/{chunk-DIX6JWN4.cjs → chunk-TF7NSMHW.cjs} +7 -2
- package/dist/chunk-TF7NSMHW.cjs.map +1 -0
- package/dist/{chunk-B7SBAXEP.cjs → chunk-TKHLXCSZ.cjs} +7 -7
- package/dist/{chunk-B7SBAXEP.cjs.map → chunk-TKHLXCSZ.cjs.map} +1 -1
- package/dist/{chunk-JGHGC64S.cjs → chunk-UQLJDNXU.cjs} +4 -4
- package/dist/{chunk-JGHGC64S.cjs.map → chunk-UQLJDNXU.cjs.map} +1 -1
- package/dist/{chunk-YGQNINW7.js → chunk-UZRD3SEA.js} +146 -31
- package/dist/chunk-UZRD3SEA.js.map +1 -0
- package/dist/{chunk-O76KG2FC.js → chunk-VZNOKYP5.js} +3 -3
- package/dist/{chunk-O76KG2FC.js.map → chunk-VZNOKYP5.js.map} +1 -1
- package/dist/{chunk-5BXP7S4P.cjs → chunk-XG2VRXG5.cjs} +15 -4
- package/dist/chunk-XG2VRXG5.cjs.map +1 -0
- package/dist/{chunk-R4DZSQYI.cjs → chunk-Y2SA2JZT.cjs} +138 -177
- package/dist/chunk-Y2SA2JZT.cjs.map +1 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/{observational-memory-JX7VDONY-AOV7JL6X.js → observational-memory-ZS2HJPUO-2ZBP2HCP.js} +3 -3
- package/dist/{observational-memory-JX7VDONY-AOV7JL6X.js.map → observational-memory-ZS2HJPUO-2ZBP2HCP.js.map} +1 -1
- package/dist/{observational-memory-JX7VDONY-6J77R6HH.cjs → observational-memory-ZS2HJPUO-472SI4TK.cjs} +26 -26
- package/dist/{observational-memory-JX7VDONY-6J77R6HH.cjs.map → observational-memory-ZS2HJPUO-472SI4TK.cjs.map} +1 -1
- package/dist/server/auth/helpers.d.ts.map +1 -1
- package/dist/server/auth/index.cjs +14 -14
- package/dist/server/auth/index.js +1 -1
- package/dist/server/constants.d.ts +1 -0
- package/dist/server/constants.d.ts.map +1 -1
- package/dist/server/handlers/a2a.cjs +10 -10
- 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 -37
- package/dist/server/handlers/agents.d.ts +14 -2
- package/dist/server/handlers/agents.d.ts.map +1 -1
- package/dist/server/handlers/agents.js +1 -1
- package/dist/server/handlers/auth.cjs +11 -11
- package/dist/server/handlers/auth.js +1 -1
- package/dist/server/handlers/conversations.cjs +5 -5
- package/dist/server/handlers/conversations.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 +27 -27
- package/dist/server/handlers/memory.js +1 -1
- package/dist/server/handlers/responses.cjs +4 -4
- package/dist/server/handlers/responses.js +1 -1
- package/dist/server/handlers/responses.storage.cjs +8 -8
- package/dist/server/handlers/responses.storage.js +1 -1
- package/dist/server/handlers/scores.cjs +7 -7
- package/dist/server/handlers/scores.js +1 -1
- package/dist/server/handlers/tools.cjs +6 -6
- package/dist/server/handlers/tools.js +1 -1
- package/dist/server/handlers/utils.cjs +9 -9
- package/dist/server/handlers/utils.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 +24 -24
- package/dist/server/handlers/workflows.d.ts +2 -0
- 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/schemas/agents.d.ts +12 -0
- package/dist/server/schemas/agents.d.ts.map +1 -1
- package/dist/server/schemas/index.cjs +69 -61
- package/dist/server/schemas/index.js +3 -3
- package/dist/server/schemas/workflows.d.ts +8 -0
- package/dist/server/schemas/workflows.d.ts.map +1 -1
- package/dist/server/server-adapter/index.cjs +136 -131
- package/dist/server/server-adapter/index.cjs.map +1 -1
- package/dist/server/server-adapter/index.d.ts.map +1 -1
- package/dist/server/server-adapter/index.js +19 -14
- package/dist/server/server-adapter/index.js.map +1 -1
- package/dist/server/server-adapter/routes/agents.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/workflows.d.ts +2 -0
- package/dist/server/server-adapter/routes/workflows.d.ts.map +1 -1
- package/package.json +5 -5
- package/dist/chunk-2Z5KJJDZ.js.map +0 -1
- package/dist/chunk-5BXP7S4P.cjs.map +0 -1
- package/dist/chunk-6SUTXWOK.cjs.map +0 -1
- package/dist/chunk-BR6MQNNL.js.map +0 -1
- package/dist/chunk-DIX6JWN4.cjs.map +0 -1
- package/dist/chunk-HYI4ZAV7.js.map +0 -1
- package/dist/chunk-I3BHHWHT.cjs.map +0 -1
- package/dist/chunk-IO7PPBD4.js.map +0 -1
- package/dist/chunk-JVQ5EXNJ.js.map +0 -1
- package/dist/chunk-R4DZSQYI.cjs.map +0 -1
- package/dist/chunk-RQXUPTUI.js.map +0 -1
- package/dist/chunk-VR623NIZ.cjs.map +0 -1
- package/dist/chunk-XT6GKIYW.cjs.map +0 -1
- package/dist/chunk-YGQNINW7.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,125 @@
|
|
|
1
1
|
# @mastra/server
|
|
2
2
|
|
|
3
|
+
## 1.30.0-alpha.1
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Update peer dependencies to match core package version bump (1.0.5) ([#12557](https://github.com/mastra-ai/mastra/pull/12557))
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Fixed a regression in 1.29.0 where configuring an agent with channel adapters (e.g. `channels.adapters.slack`) caused server startup to crash with a "Custom API route ... must not start with /api" error. The custom-route prefix validation now skips framework-generated webhook routes. ([#15952](https://github.com/mastra-ai/mastra/pull/15952))
|
|
12
|
+
|
|
13
|
+
- Fix MCP client support in the agent editor: ([#15945](https://github.com/mastra-ai/mastra/pull/15945))
|
|
14
|
+
- MCP client form dirty state: Save button now enables after adding/removing MCP clients
|
|
15
|
+
- MCP tool name matching: Both bare and namespaced tool names are matched correctly
|
|
16
|
+
- Auth token forwarding: Token from cookie or header is forwarded to auth-protected MCP servers
|
|
17
|
+
- String interpolation: Request context variables in system prompts now resolve correctly
|
|
18
|
+
|
|
19
|
+
- Add durable agents with resumable streams ([#12557](https://github.com/mastra-ai/mastra/pull/12557))
|
|
20
|
+
|
|
21
|
+
Durable agents make agent execution resilient to disconnections, crashes, and long-running operations.
|
|
22
|
+
|
|
23
|
+
### The Problem
|
|
24
|
+
|
|
25
|
+
Standard agent streaming has two fragility points:
|
|
26
|
+
1. **Connection drops** - If a client disconnects mid-stream (network blip, browser refresh, mobile app backgrounded), all subsequent events are lost. The client has no way to "catch up" on what they missed.
|
|
27
|
+
2. **Long-running operations** - Agent loops with tool calls can take minutes. Holding an HTTP connection open that long is unreliable. If the server restarts or the connection times out, the work is lost.
|
|
28
|
+
|
|
29
|
+
### The Solution
|
|
30
|
+
|
|
31
|
+
**Resumable streams** solve connection drops. Every event is cached with a sequential index. If a client disconnects at event 5, they can reconnect and request events starting from index 6. They receive cached events immediately, then continue with live events as they arrive.
|
|
32
|
+
|
|
33
|
+
**Durable execution** solves long-running operations. Instead of executing the agent loop directly in the HTTP request, execution happens in a workflow engine (built-in evented engine or Inngest). The HTTP request just subscribes to events. If the connection drops, execution continues. The client can reconnect anytime to observe progress.
|
|
34
|
+
|
|
35
|
+
### Usage
|
|
36
|
+
|
|
37
|
+
Wrap any existing `Agent` with durability using factory functions:
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { Agent } from '@mastra/core/agent';
|
|
41
|
+
import { createDurableAgent } from '@mastra/core/agent/durable';
|
|
42
|
+
|
|
43
|
+
const agent = new Agent({
|
|
44
|
+
id: 'my-agent',
|
|
45
|
+
model: openai('gpt-4'),
|
|
46
|
+
instructions: 'You are helpful',
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const durableAgent = createDurableAgent({ agent });
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**Factory functions for different execution strategies:**
|
|
53
|
+
|
|
54
|
+
| Factory | Execution | Use Case |
|
|
55
|
+
| ---------------------------------------- | ----------------------------------- | ------------------------------- |
|
|
56
|
+
| `createDurableAgent({ agent })` | Local, synchronous | Development, simple deployments |
|
|
57
|
+
| `createEventedAgent({ agent })` | Fire-and-forget via workflow engine | Long-running operations |
|
|
58
|
+
| `createInngestAgent({ agent, inngest })` | Inngest-powered | Production, distributed systems |
|
|
59
|
+
|
|
60
|
+
### Resumable Streams
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
// Start streaming
|
|
64
|
+
const { runId, output } = await durableAgent.stream('Analyze this data...');
|
|
65
|
+
|
|
66
|
+
// Client disconnects at event 5...
|
|
67
|
+
|
|
68
|
+
// Reconnect and resume from where we left off
|
|
69
|
+
const { output: resumed } = await durableAgent.observe(runId, { offset: 6 });
|
|
70
|
+
// Receives events 6, 7, 8... from cache, then continues with live events
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### PubSub and Cache
|
|
74
|
+
|
|
75
|
+
Durable agents use two infrastructure components:
|
|
76
|
+
|
|
77
|
+
| Component | Purpose | Default |
|
|
78
|
+
| ---------- | ----------------------------------------- | --------------------- |
|
|
79
|
+
| **PubSub** | Real-time event delivery during streaming | `EventEmitterPubSub` |
|
|
80
|
+
| **Cache** | Stores events for replay on reconnection | `InMemoryServerCache` |
|
|
81
|
+
|
|
82
|
+
When `stream()` is called, events flow through pubsub in real-time. The cache stores each event with a sequential index. When `observe()` is called, missed events replay from cache before continuing with live events.
|
|
83
|
+
|
|
84
|
+
**Configure via Mastra instance (recommended):**
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
const mastra = new Mastra({
|
|
88
|
+
cache: new RedisServerCache({ url: 'redis://...' }),
|
|
89
|
+
pubsub: new RedisPubSub({ url: 'redis://...' }),
|
|
90
|
+
agents: {
|
|
91
|
+
// Inherits cache and pubsub from Mastra
|
|
92
|
+
myAgent: createDurableAgent({ agent }),
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**Configure per-agent (overrides Mastra):**
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
const durableAgent = createDurableAgent({
|
|
101
|
+
agent,
|
|
102
|
+
cache: new RedisServerCache({ url: 'redis://...' }),
|
|
103
|
+
pubsub: new RedisPubSub({ url: 'redis://...' }),
|
|
104
|
+
});
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
**Disable caching (streams won't be resumable):**
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
const durableAgent = createDurableAgent({ agent, cache: false });
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
For single-instance deployments, the defaults work fine. For multi-instance deployments (load balancer, horizontal scaling), use Redis-backed implementations so any instance can serve reconnection requests.
|
|
114
|
+
|
|
115
|
+
### Class Hierarchy
|
|
116
|
+
- `DurableAgent` extends `Agent` - base class with resumable streams
|
|
117
|
+
- `EventedAgent` extends `DurableAgent` - fire-and-forget execution
|
|
118
|
+
- `InngestAgent` extends `DurableAgent` - Inngest-powered execution
|
|
119
|
+
|
|
120
|
+
- Updated dependencies [[`920c757`](https://github.com/mastra-ai/mastra/commit/920c75799c6bd71787d86deaf654a35af4c839ca), [`1fe2533`](https://github.com/mastra-ai/mastra/commit/1fe2533c4382ca6858aac7c4b63e888c2eac6541), [`f8694b6`](https://github.com/mastra-ai/mastra/commit/f8694b6fa0b7a5cde71d794c3bbef4957c55bcb8)]:
|
|
121
|
+
- @mastra/core@1.30.0-alpha.1
|
|
122
|
+
|
|
3
123
|
## 1.29.2-alpha.0
|
|
4
124
|
|
|
5
125
|
### Patch Changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkEFW6MWXU_cjs = require('./chunk-EFW6MWXU.cjs');
|
|
4
4
|
var chunk64ITUOXI_cjs = require('./chunk-64ITUOXI.cjs');
|
|
5
5
|
|
|
6
6
|
// src/server/handlers/utils.ts
|
|
@@ -42,11 +42,11 @@ function parseFilters(filters) {
|
|
|
42
42
|
);
|
|
43
43
|
}
|
|
44
44
|
function getEffectiveResourceId(requestContext, clientResourceId) {
|
|
45
|
-
const contextResourceId = requestContext?.get(
|
|
45
|
+
const contextResourceId = requestContext?.get(chunkEFW6MWXU_cjs.MASTRA_RESOURCE_ID_KEY);
|
|
46
46
|
return contextResourceId || clientResourceId;
|
|
47
47
|
}
|
|
48
48
|
function getEffectiveThreadId(requestContext, clientThreadId) {
|
|
49
|
-
const contextThreadId = requestContext?.get(
|
|
49
|
+
const contextThreadId = requestContext?.get(chunkEFW6MWXU_cjs.MASTRA_THREAD_ID_KEY);
|
|
50
50
|
return contextThreadId || clientThreadId;
|
|
51
51
|
}
|
|
52
52
|
async function validateThreadOwnership(thread, effectiveResourceId) {
|
|
@@ -68,5 +68,5 @@ exports.sanitizeBody = sanitizeBody;
|
|
|
68
68
|
exports.validateBody = validateBody;
|
|
69
69
|
exports.validateRunOwnership = validateRunOwnership;
|
|
70
70
|
exports.validateThreadOwnership = validateThreadOwnership;
|
|
71
|
-
//# sourceMappingURL=chunk-
|
|
72
|
-
//# sourceMappingURL=chunk-
|
|
71
|
+
//# sourceMappingURL=chunk-2CFH32YO.cjs.map
|
|
72
|
+
//# sourceMappingURL=chunk-2CFH32YO.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/server/handlers/utils.ts"],"names":["HTTPException","MASTRA_RESOURCE_ID_KEY","MASTRA_THREAD_ID_KEY"],"mappings":";;;;;;AAKO,SAAS,aAAa,IAAA,EAA+B;AAC1D,EAAA,MAAM,aAAA,GAAgB,MAAA,CAAO,OAAA,CAAQ,IAAI,CAAA,CAAE,MAAA,CAA+B,CAAC,GAAA,EAAK,CAAC,GAAA,EAAK,KAAK,CAAA,KAAM;AAC/F,IAAA,IAAI,CAAC,KAAA,EAAO;AACV,MAAA,GAAA,CAAI,GAAG,CAAA,GA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AAAA,EACzG;AACF","file":"chunk-2CFH32YO.cjs","sourcesContent":["import type { RequestContext } from '@mastra/core/di';\nimport { MASTRA_RESOURCE_ID_KEY, MASTRA_THREAD_ID_KEY } from '../constants';\nimport { HTTPException } from '../http-exception';\n\n// Validation helper\nexport function validateBody(body: Record<string, unknown>) {\n const errorResponse = Object.entries(body).reduce<Record<string, string>>((acc, [key, value]) => {\n if (!value) {\n acc[key] = `Argument \"${key}\" is required`;\n }\n return acc;\n }, {});\n\n if (Object.keys(errorResponse).length > 0) {\n throw new HTTPException(400, { message: Object.values(errorResponse)[0] });\n }\n}\n\n/**\n * sanitizes the body by removing disallowed keys.\n * @param body body to sanitize\n * @param disallowedKeys keys to remove from the body\n */\nexport function sanitizeBody(body: Record<string, unknown>, disallowedKeys: string[]) {\n for (const key of disallowedKeys) {\n if (key in body) {\n delete body[key];\n }\n }\n}\n\nexport function parsePerPage(\n value: string | undefined,\n defaultValue: number = 100,\n max: number = 1000,\n): number | false {\n const normalized = (value || '').trim().toLowerCase();\n // Handle explicit false to bypass pagination\n if (normalized === 'false') {\n return false;\n }\n const parsed = parseInt(value || String(defaultValue), 10);\n if (isNaN(parsed)) return defaultValue;\n return Math.min(max, Math.max(1, parsed));\n}\n\n/**\n * Parses filter query parameters into a key-value object.\n */\nexport function parseFilters(filters: string | string[] | undefined): Record<string, string> | undefined {\n if (!filters) return undefined;\n\n return Object.fromEntries(\n (Array.isArray(filters) ? filters : [filters]).map((attr: string) => {\n const [key, ...valueParts] = attr.split(':');\n const value = valueParts.join(':'); // ✅ Handles colons in values\n return [key, value];\n }),\n );\n}\n\n// ============================================================================\n// Authorization Utilities\n// ============================================================================\n\n/**\n * Gets the effective resourceId, preferring the reserved key from requestContext\n * over client-provided values for security.\n */\nexport function getEffectiveResourceId(\n requestContext: RequestContext | undefined,\n clientResourceId: string | undefined,\n): string | undefined {\n const contextResourceId = requestContext?.get(MASTRA_RESOURCE_ID_KEY) as string | undefined;\n return contextResourceId || clientResourceId;\n}\n\n/**\n * Gets the effective threadId, preferring the reserved key from requestContext\n * over client-provided values for security.\n */\nexport function getEffectiveThreadId(\n requestContext: RequestContext | undefined,\n clientThreadId: string | undefined,\n): string | undefined {\n const contextThreadId = requestContext?.get(MASTRA_THREAD_ID_KEY) as string | undefined;\n return contextThreadId || clientThreadId;\n}\n\n/**\n * Validates that a thread belongs to the specified resourceId.\n * Throws 403 if the thread exists but belongs to a different resource.\n * Threads with no resourceId are accessible to all (shared threads).\n */\nexport async function validateThreadOwnership(\n thread: { resourceId?: string | null } | null | undefined,\n effectiveResourceId: string | undefined,\n): Promise<void> {\n if (thread && effectiveResourceId && thread.resourceId && thread.resourceId !== effectiveResourceId) {\n throw new HTTPException(403, { message: 'Access denied: thread belongs to a different resource' });\n }\n}\n\n/**\n * Validates that a workflow run belongs to the specified resourceId.\n * Throws 403 if the run exists but belongs to a different resource.\n */\nexport async function validateRunOwnership(\n run: { resourceId?: string | null } | null | undefined,\n effectiveResourceId: string | undefined,\n): Promise<void> {\n if (run && effectiveResourceId && run.resourceId && run.resourceId !== effectiveResourceId) {\n throw new HTTPException(403, { message: 'Access denied: workflow run belongs to a different resource' });\n }\n}\n"]}
|
|
@@ -1040,7 +1040,7 @@ function imageSize(input) {
|
|
|
1040
1040
|
throw new TypeError(`unsupported file type: ${type}`);
|
|
1041
1041
|
}
|
|
1042
1042
|
|
|
1043
|
-
// ../memory/dist/chunk-
|
|
1043
|
+
// ../memory/dist/chunk-4C4ERX6N.js
|
|
1044
1044
|
var OM_DEBUG_LOG = process.env.OM_DEBUG ? join(process.cwd(), "om-debug.log") : null;
|
|
1045
1045
|
function omDebug(msg) {
|
|
1046
1046
|
if (!OM_DEBUG_LOG) return;
|
|
@@ -10157,6 +10157,15 @@ var ObservationalMemoryProcessor = class {
|
|
|
10157
10157
|
if (readOnly) {
|
|
10158
10158
|
return messageList;
|
|
10159
10159
|
}
|
|
10160
|
+
const activeTurn = state.__omTurn ?? this.turn;
|
|
10161
|
+
if (activeTurn && activeTurn.messageList !== messageList) {
|
|
10162
|
+
await activeTurn.end().catch(() => {
|
|
10163
|
+
});
|
|
10164
|
+
if (this.turn === activeTurn) {
|
|
10165
|
+
this.turn = void 0;
|
|
10166
|
+
}
|
|
10167
|
+
state.__omTurn = void 0;
|
|
10168
|
+
}
|
|
10160
10169
|
if (!this.turn || !state.__omTurn) {
|
|
10161
10170
|
if (this.turn && !state.__omTurn) {
|
|
10162
10171
|
await this.turn.end().catch(() => {
|
|
@@ -10319,5 +10328,5 @@ function getObservationsAsOf(activeObservations, asOf) {
|
|
|
10319
10328
|
}
|
|
10320
10329
|
|
|
10321
10330
|
export { ModelByInputTokens, OBSERVER_SYSTEM_PROMPT, ObservationalMemory, ObservationalMemoryProcessor, TokenCounter, buildObserverPrompt, buildObserverSystemPrompt, combineObservationGroupRanges, deriveObservationGroupProvenance, e, estimateTokenCount, extractCurrentTask, formatMessagesForObserver, formatToolResultForObserver, getObservationsAsOf, hasCurrentTaskSection, injectAnchorIds, optimizeObservationsForContext, parseAnchorId, parseObservationGroups, parseObserverOutput, reconcileObservationGroupsFromReflection, renderObservationGroupsForReflection, resolveToolResultValue, stripEphemeralAnchorIds, stripObservationGroups, truncateStringByTokens, wrapInObservationGroup };
|
|
10322
|
-
//# sourceMappingURL=chunk-
|
|
10323
|
-
//# sourceMappingURL=chunk-
|
|
10331
|
+
//# sourceMappingURL=chunk-2HVAN7FF.js.map
|
|
10332
|
+
//# sourceMappingURL=chunk-2HVAN7FF.js.map
|