@mastra/client-js 1.15.2-alpha.1 → 1.15.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,115 @@
1
1
  # @mastra/client-js
2
2
 
3
+ ## 1.15.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Remove incorrect deprecation markers from `getTask()` and `cancelTask()` in the Mastra A2A client. ([#15941](https://github.com/mastra-ai/mastra/pull/15941))
8
+
9
+ - Add durable agents with resumable streams ([#12557](https://github.com/mastra-ai/mastra/pull/12557))
10
+
11
+ Durable agents make agent execution resilient to disconnections, crashes, and long-running operations.
12
+
13
+ ### The Problem
14
+
15
+ Standard agent streaming has two fragility points:
16
+ 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.
17
+ 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.
18
+
19
+ ### The Solution
20
+
21
+ **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.
22
+
23
+ **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.
24
+
25
+ ### Usage
26
+
27
+ Wrap any existing `Agent` with durability using factory functions:
28
+
29
+ ```typescript
30
+ import { Agent } from '@mastra/core/agent';
31
+ import { createDurableAgent } from '@mastra/core/agent/durable';
32
+
33
+ const agent = new Agent({
34
+ id: 'my-agent',
35
+ model: openai('gpt-4'),
36
+ instructions: 'You are helpful',
37
+ });
38
+
39
+ const durableAgent = createDurableAgent({ agent });
40
+ ```
41
+
42
+ **Factory functions for different execution strategies:**
43
+
44
+ | Factory | Execution | Use Case |
45
+ | ---------------------------------------- | ----------------------------------- | ------------------------------- |
46
+ | `createDurableAgent({ agent })` | Local, synchronous | Development, simple deployments |
47
+ | `createEventedAgent({ agent })` | Fire-and-forget via workflow engine | Long-running operations |
48
+ | `createInngestAgent({ agent, inngest })` | Inngest-powered | Production, distributed systems |
49
+
50
+ ### Resumable Streams
51
+
52
+ ```typescript
53
+ // Start streaming
54
+ const { runId, output } = await durableAgent.stream('Analyze this data...');
55
+
56
+ // Client disconnects at event 5...
57
+
58
+ // Reconnect and resume from where we left off
59
+ const { output: resumed } = await durableAgent.observe(runId, { offset: 6 });
60
+ // Receives events 6, 7, 8... from cache, then continues with live events
61
+ ```
62
+
63
+ ### PubSub and Cache
64
+
65
+ Durable agents use two infrastructure components:
66
+
67
+ | Component | Purpose | Default |
68
+ | ---------- | ----------------------------------------- | --------------------- |
69
+ | **PubSub** | Real-time event delivery during streaming | `EventEmitterPubSub` |
70
+ | **Cache** | Stores events for replay on reconnection | `InMemoryServerCache` |
71
+
72
+ 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.
73
+
74
+ **Configure via Mastra instance (recommended):**
75
+
76
+ ```typescript
77
+ const mastra = new Mastra({
78
+ cache: new RedisServerCache({ url: 'redis://...' }),
79
+ pubsub: new RedisPubSub({ url: 'redis://...' }),
80
+ agents: {
81
+ // Inherits cache and pubsub from Mastra
82
+ myAgent: createDurableAgent({ agent }),
83
+ },
84
+ });
85
+ ```
86
+
87
+ **Configure per-agent (overrides Mastra):**
88
+
89
+ ```typescript
90
+ const durableAgent = createDurableAgent({
91
+ agent,
92
+ cache: new RedisServerCache({ url: 'redis://...' }),
93
+ pubsub: new RedisPubSub({ url: 'redis://...' }),
94
+ });
95
+ ```
96
+
97
+ **Disable caching (streams won't be resumable):**
98
+
99
+ ```typescript
100
+ const durableAgent = createDurableAgent({ agent, cache: false });
101
+ ```
102
+
103
+ 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.
104
+
105
+ ### Class Hierarchy
106
+ - `DurableAgent` extends `Agent` - base class with resumable streams
107
+ - `EventedAgent` extends `DurableAgent` - fire-and-forget execution
108
+ - `InngestAgent` extends `DurableAgent` - Inngest-powered execution
109
+
110
+ - 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)]:
111
+ - @mastra/core@1.30.0
112
+
3
113
  ## 1.15.2-alpha.1
4
114
 
5
115
  ### Patch Changes
@@ -3,7 +3,7 @@ name: mastra-client-js
3
3
  description: Documentation for @mastra/client-js. Use when working with @mastra/client-js APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/client-js"
6
- version: "1.15.2-alpha.1"
6
+ version: "1.15.2"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.15.2-alpha.1",
2
+ "version": "1.15.2",
3
3
  "package": "@mastra/client-js",
4
4
  "exports": {
5
5
  "RequestContext": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/client-js",
3
- "version": "1.15.2-alpha.1",
3
+ "version": "1.15.2",
4
4
  "description": "The official TypeScript library for the Mastra Client API",
5
5
  "author": "",
6
6
  "type": "module",
@@ -37,7 +37,7 @@
37
37
  "@ai-sdk/ui-utils": "^1.2.11",
38
38
  "@lukeed/uuid": "^2.0.1",
39
39
  "json-schema": "^0.4.0",
40
- "@mastra/core": "1.30.0-alpha.1",
40
+ "@mastra/core": "1.30.0",
41
41
  "@mastra/schema-compat": "1.2.9"
42
42
  },
43
43
  "peerDependencies": {
@@ -53,10 +53,10 @@
53
53
  "typescript": "^6.0.3",
54
54
  "vitest": "4.1.5",
55
55
  "zod": "^4.3.6",
56
- "@internal/ai-sdk-v4": "0.0.35",
57
- "@internal/lint": "0.0.88",
58
- "@internal/types-builder": "0.0.63",
59
- "@internal/ai-sdk-v5": "0.0.35"
56
+ "@internal/ai-sdk-v4": "0.0.36",
57
+ "@internal/ai-sdk-v5": "0.0.36",
58
+ "@internal/lint": "0.0.89",
59
+ "@internal/types-builder": "0.0.64"
60
60
  },
61
61
  "engines": {
62
62
  "node": ">=22.13.0"