@mastra/client-js 1.31.2-alpha.4 → 1.31.2-alpha.6

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,38 @@
1
1
  # @mastra/client-js
2
2
 
3
+ ## 1.31.2-alpha.6
4
+
5
+ ### Patch Changes
6
+
7
+ - Added HTTP and client bindings for recovering an interrupted durable agent run. ([#19191](https://github.com/mastra-ai/mastra/pull/19191))
8
+
9
+ **What changed**
10
+ - `@mastra/server`: new `POST /agents/:agentId/recover` route. Given the id of a durable agent run that was interrupted by a deploy or crash, the server picks the run back up from where it left off and streams the rest of the response to the caller. Non-durable agents are rejected, and callers can only recover runs that belong to them (same permission and ownership rules as resuming a suspended run).
11
+ - `@mastra/client-js`: new `agent.recover({ runId })` method that reads that stream from the browser or Node. It behaves the same as `agent.resumeStream()` — you get back a readable stream of the agent's remaining response.
12
+
13
+ **Why**
14
+
15
+ The underlying core API for recovering an interrupted durable agent run could previously only be called from server-side code. This adds the standard HTTP + client surface so operators can reattach to an interrupted run from a dashboard, an admin tool, or any other client, using the same auth and ownership rules as the rest of the agents API.
16
+
17
+ **Usage**
18
+
19
+ ```ts
20
+ const stream = await mastraClient.getAgent('support').recover({ runId: 'run-abc123' });
21
+ for await (const chunk of stream) {
22
+ // render or forward the remaining agent output
23
+ }
24
+ ```
25
+
26
+ - Updated dependencies [[`e2d5f37`](https://github.com/mastra-ai/mastra/commit/e2d5f373bd289be534d5f8694d34465010533df6)]:
27
+ - @mastra/core@1.51.0-alpha.6
28
+
29
+ ## 1.31.2-alpha.5
30
+
31
+ ### Patch Changes
32
+
33
+ - Updated dependencies [[`fb8aea3`](https://github.com/mastra-ai/mastra/commit/fb8aea384291e77311be3a64ee1717320d5c3c73), [`4ce0163`](https://github.com/mastra-ai/mastra/commit/4ce0163dc86e675a86809685c8ce6c49f1aeb87e)]:
34
+ - @mastra/core@1.51.0-alpha.5
35
+
3
36
  ## 1.31.2-alpha.4
4
37
 
5
38
  ### 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.31.2-alpha.4"
6
+ version: "1.31.2-alpha.6"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.31.2-alpha.4",
2
+ "version": "1.31.2-alpha.6",
3
3
  "package": "@mastra/client-js",
4
4
  "exports": {
5
5
  "RequestContext": {
package/dist/index.cjs CHANGED
@@ -2508,6 +2508,38 @@ var Agent = class extends BaseResource {
2508
2508
  };
2509
2509
  return streamResponse;
2510
2510
  }
2511
+ /**
2512
+ * Re-drives an orphaned RUNNING durable-agent run after a process restart.
2513
+ *
2514
+ * Only supported when the target agent is a durable agent (createDurableAgent).
2515
+ * The server rebuilds the runtime state from the persisted snapshot, replays
2516
+ * past chunks, and continues the loop to completion.
2517
+ */
2518
+ async recover(params) {
2519
+ const body = {
2520
+ runId: params.runId,
2521
+ requestContext: parseClientRequestContext(params.requestContext),
2522
+ versions: params.versions
2523
+ };
2524
+ const response = await this.request(`/agents/${this.agentId}/recover`, {
2525
+ method: "POST",
2526
+ body,
2527
+ stream: true
2528
+ });
2529
+ if (!response.body) {
2530
+ throw new Error("No response body");
2531
+ }
2532
+ const streamResponse = response;
2533
+ streamResponse.processDataStream = async ({
2534
+ onChunk
2535
+ }) => {
2536
+ await processMastraStream({
2537
+ stream: streamResponse.body,
2538
+ onChunk
2539
+ });
2540
+ };
2541
+ return streamResponse;
2542
+ }
2511
2543
  /**
2512
2544
  * @deprecated Use `resumeStream(resumeData, { untilIdle: true, ... })` instead.
2513
2545
  *