@mastra/upstash 1.1.0-alpha.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +113 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,118 @@
|
|
|
1
1
|
# @mastra/upstash
|
|
2
2
|
|
|
3
|
+
## 1.1.0
|
|
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
|
+
- Add durable agents with resumable streams ([#12557](https://github.com/mastra-ai/mastra/pull/12557))
|
|
12
|
+
|
|
13
|
+
Durable agents make agent execution resilient to disconnections, crashes, and long-running operations.
|
|
14
|
+
|
|
15
|
+
### The Problem
|
|
16
|
+
|
|
17
|
+
Standard agent streaming has two fragility points:
|
|
18
|
+
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.
|
|
19
|
+
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.
|
|
20
|
+
|
|
21
|
+
### The Solution
|
|
22
|
+
|
|
23
|
+
**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.
|
|
24
|
+
|
|
25
|
+
**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.
|
|
26
|
+
|
|
27
|
+
### Usage
|
|
28
|
+
|
|
29
|
+
Wrap any existing `Agent` with durability using factory functions:
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
import { Agent } from '@mastra/core/agent';
|
|
33
|
+
import { createDurableAgent } from '@mastra/core/agent/durable';
|
|
34
|
+
|
|
35
|
+
const agent = new Agent({
|
|
36
|
+
id: 'my-agent',
|
|
37
|
+
model: openai('gpt-4'),
|
|
38
|
+
instructions: 'You are helpful',
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const durableAgent = createDurableAgent({ agent });
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**Factory functions for different execution strategies:**
|
|
45
|
+
|
|
46
|
+
| Factory | Execution | Use Case |
|
|
47
|
+
| ---------------------------------------- | ----------------------------------- | ------------------------------- |
|
|
48
|
+
| `createDurableAgent({ agent })` | Local, synchronous | Development, simple deployments |
|
|
49
|
+
| `createEventedAgent({ agent })` | Fire-and-forget via workflow engine | Long-running operations |
|
|
50
|
+
| `createInngestAgent({ agent, inngest })` | Inngest-powered | Production, distributed systems |
|
|
51
|
+
|
|
52
|
+
### Resumable Streams
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
// Start streaming
|
|
56
|
+
const { runId, output } = await durableAgent.stream('Analyze this data...');
|
|
57
|
+
|
|
58
|
+
// Client disconnects at event 5...
|
|
59
|
+
|
|
60
|
+
// Reconnect and resume from where we left off
|
|
61
|
+
const { output: resumed } = await durableAgent.observe(runId, { offset: 6 });
|
|
62
|
+
// Receives events 6, 7, 8... from cache, then continues with live events
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### PubSub and Cache
|
|
66
|
+
|
|
67
|
+
Durable agents use two infrastructure components:
|
|
68
|
+
|
|
69
|
+
| Component | Purpose | Default |
|
|
70
|
+
| ---------- | ----------------------------------------- | --------------------- |
|
|
71
|
+
| **PubSub** | Real-time event delivery during streaming | `EventEmitterPubSub` |
|
|
72
|
+
| **Cache** | Stores events for replay on reconnection | `InMemoryServerCache` |
|
|
73
|
+
|
|
74
|
+
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.
|
|
75
|
+
|
|
76
|
+
**Configure via Mastra instance (recommended):**
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
const mastra = new Mastra({
|
|
80
|
+
cache: new RedisServerCache({ url: 'redis://...' }),
|
|
81
|
+
pubsub: new RedisPubSub({ url: 'redis://...' }),
|
|
82
|
+
agents: {
|
|
83
|
+
// Inherits cache and pubsub from Mastra
|
|
84
|
+
myAgent: createDurableAgent({ agent }),
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**Configure per-agent (overrides Mastra):**
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
const durableAgent = createDurableAgent({
|
|
93
|
+
agent,
|
|
94
|
+
cache: new RedisServerCache({ url: 'redis://...' }),
|
|
95
|
+
pubsub: new RedisPubSub({ url: 'redis://...' }),
|
|
96
|
+
});
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**Disable caching (streams won't be resumable):**
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
const durableAgent = createDurableAgent({ agent, cache: false });
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
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.
|
|
106
|
+
|
|
107
|
+
### Class Hierarchy
|
|
108
|
+
- `DurableAgent` extends `Agent` - base class with resumable streams
|
|
109
|
+
- `EventedAgent` extends `DurableAgent` - fire-and-forget execution
|
|
110
|
+
- `InngestAgent` extends `DurableAgent` - Inngest-powered execution
|
|
111
|
+
|
|
112
|
+
- Updated dependencies [[`920c757`](https://github.com/mastra-ai/mastra/commit/920c75799c6bd71787d86deaf654a35af4c839ca), [`d587199`](https://github.com/mastra-ai/mastra/commit/d5871993c0371bde2b0717d6b47194755baa1443), [`1fe2533`](https://github.com/mastra-ai/mastra/commit/1fe2533c4382ca6858aac7c4b63e888c2eac6541), [`f8694b6`](https://github.com/mastra-ai/mastra/commit/f8694b6fa0b7a5cde71d794c3bbef4957c55bcb8), [`f8694b6`](https://github.com/mastra-ai/mastra/commit/f8694b6fa0b7a5cde71d794c3bbef4957c55bcb8)]:
|
|
113
|
+
- @mastra/core@1.30.0
|
|
114
|
+
- @mastra/redis@1.1.0
|
|
115
|
+
|
|
3
116
|
## 1.1.0-alpha.0
|
|
4
117
|
|
|
5
118
|
### Minor Changes
|
package/dist/docs/SKILL.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/upstash",
|
|
3
|
-
"version": "1.1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Upstash provider for Mastra - includes both vector and db storage capabilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@upstash/redis": "^1.37.0",
|
|
24
24
|
"@upstash/vector": "^1.2.3",
|
|
25
|
-
"@mastra/redis": "1.1.0
|
|
25
|
+
"@mastra/redis": "1.1.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/node": "22.19.15",
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"tsup": "^8.5.1",
|
|
34
34
|
"typescript": "^6.0.3",
|
|
35
35
|
"vitest": "4.1.5",
|
|
36
|
-
"@internal/lint": "0.0.
|
|
37
|
-
"@internal/storage-test-utils": "0.0.
|
|
38
|
-
"@internal/types-builder": "0.0.
|
|
39
|
-
"@mastra/core": "1.30.0
|
|
36
|
+
"@internal/lint": "0.0.89",
|
|
37
|
+
"@internal/storage-test-utils": "0.0.85",
|
|
38
|
+
"@internal/types-builder": "0.0.64",
|
|
39
|
+
"@mastra/core": "1.30.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@mastra/core": ">=1.0.5-0 <2.0.0-0"
|