@mastra/client-js 1.14.2 → 1.15.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 +34 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/reference-client-js-agents.md +20 -0
- package/dist/index.cjs +43 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +43 -1
- package/dist/index.js.map +1 -1
- package/dist/resources/agent.d.ts +17 -0
- package/dist/resources/agent.d.ts.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# @mastra/client-js
|
|
2
2
|
|
|
3
|
+
## 1.15.0-alpha.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`7a7b313`](https://github.com/mastra-ai/mastra/commit/7a7b3138fb3bcf0b0c740eaea07971e43d330ef3), [`a6dac0a`](https://github.com/mastra-ai/mastra/commit/a6dac0a40c7181161b1add4e8534f962bcbc9aa7), [`9cef83b`](https://github.com/mastra-ai/mastra/commit/9cef83b8a642b8098747772921e3523b492bafbc), [`d30e215`](https://github.com/mastra-ai/mastra/commit/d30e2156c746bc9fd791745cec1cc24377b66789), [`73b45fa`](https://github.com/mastra-ai/mastra/commit/73b45facdef4fbcb8af710c50f0646f18619dbaa), [`7a7b313`](https://github.com/mastra-ai/mastra/commit/7a7b3138fb3bcf0b0c740eaea07971e43d330ef3)]:
|
|
8
|
+
- @mastra/core@1.29.0-alpha.1
|
|
9
|
+
|
|
10
|
+
## 1.15.0-alpha.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- Added support for resuming suspended agent streams over HTTP with custom data. This adds the `POST /agents/:agentId/resume-stream` server endpoint and the client SDK `agent.resumeStream()` method, so apps can continue a suspended agent run through the Mastra client. ([#14579](https://github.com/mastra-ai/mastra/pull/14579))
|
|
15
|
+
|
|
16
|
+
**Usage example (client SDK):**
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
const agent = mastraClient.getAgent('my-agent');
|
|
20
|
+
|
|
21
|
+
// Resume a suspended agent stream with custom data
|
|
22
|
+
const response = await agent.resumeStream(
|
|
23
|
+
{ approved: true, selectedOption: 'plan-b' },
|
|
24
|
+
{ runId: 'previous-run-id', toolCallId: 'tool-123' },
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
await response.processDataStream({
|
|
28
|
+
onChunk: chunk => console.log(chunk),
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- Updated dependencies [[`b510d36`](https://github.com/mastra-ai/mastra/commit/b510d368f73dab6be2e2c2bc99035aaef1fb7d7a)]:
|
|
35
|
+
- @mastra/core@1.29.0-alpha.0
|
|
36
|
+
|
|
3
37
|
## 1.14.2
|
|
4
38
|
|
|
5
39
|
### Patch Changes
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -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.
|
|
6
|
+
version: "1.15.0-alpha.1"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -217,6 +217,26 @@ response.processDataStream({
|
|
|
217
217
|
})
|
|
218
218
|
```
|
|
219
219
|
|
|
220
|
+
### `resumeStream()`
|
|
221
|
+
|
|
222
|
+
Resume a suspended agent stream with custom data. Use this to continue execution after a suspension point, such as a workflow suspend within an agent:
|
|
223
|
+
|
|
224
|
+
```typescript
|
|
225
|
+
const response = await agent.resumeStream(
|
|
226
|
+
{ approved: true, selectedOption: 'plan-b' },
|
|
227
|
+
{
|
|
228
|
+
runId: 'run-123',
|
|
229
|
+
toolCallId: 'tool-call-456', // optional
|
|
230
|
+
},
|
|
231
|
+
)
|
|
232
|
+
|
|
233
|
+
await response.processDataStream({
|
|
234
|
+
onChunk: chunk => {
|
|
235
|
+
console.log(chunk)
|
|
236
|
+
},
|
|
237
|
+
})
|
|
238
|
+
```
|
|
239
|
+
|
|
220
240
|
### `approveToolCallGenerate()`
|
|
221
241
|
|
|
222
242
|
Approve a pending tool call when using `generate()` (non-streaming). Returns the complete response:
|
package/dist/index.cjs
CHANGED
|
@@ -1210,9 +1210,14 @@ var Agent = class extends BaseResource {
|
|
|
1210
1210
|
const { resource, thread } = memory ?? {};
|
|
1211
1211
|
const threadId = processedParams.threadId ?? (typeof thread === "string" ? thread : thread?.id);
|
|
1212
1212
|
const resourceId = processedParams.resourceId ?? resource;
|
|
1213
|
+
let requestBody = processedParams;
|
|
1214
|
+
if (route === "resume-stream") {
|
|
1215
|
+
const { messages: _messages, ...resumeStreamBody } = processedParams;
|
|
1216
|
+
requestBody = resumeStreamBody;
|
|
1217
|
+
}
|
|
1213
1218
|
const response = await this.request(`/agents/${this.agentId}/${route}`, {
|
|
1214
1219
|
method: "POST",
|
|
1215
|
-
body:
|
|
1220
|
+
body: requestBody,
|
|
1216
1221
|
stream: true
|
|
1217
1222
|
});
|
|
1218
1223
|
if (!response.body) {
|
|
@@ -1511,6 +1516,43 @@ var Agent = class extends BaseResource {
|
|
|
1511
1516
|
};
|
|
1512
1517
|
return streamResponse;
|
|
1513
1518
|
}
|
|
1519
|
+
/**
|
|
1520
|
+
* Resumes a suspended agent stream with custom resume data.
|
|
1521
|
+
* Used to continue execution after a suspension point (e.g., workflow suspend within an agent).
|
|
1522
|
+
*/
|
|
1523
|
+
async resumeStream(resumeData, options) {
|
|
1524
|
+
const processedParams = {
|
|
1525
|
+
...options,
|
|
1526
|
+
resumeData,
|
|
1527
|
+
requestContext: parseClientRequestContext(options.requestContext),
|
|
1528
|
+
clientTools: processClientTools(options.clientTools),
|
|
1529
|
+
structuredOutput: options.structuredOutput ? {
|
|
1530
|
+
...options.structuredOutput,
|
|
1531
|
+
schema: schema.standardSchemaToJSONSchema(schema.toStandardSchema(options.structuredOutput.schema))
|
|
1532
|
+
} : void 0
|
|
1533
|
+
};
|
|
1534
|
+
let readableController;
|
|
1535
|
+
const readable = new ReadableStream({
|
|
1536
|
+
start(controller) {
|
|
1537
|
+
readableController = controller;
|
|
1538
|
+
}
|
|
1539
|
+
});
|
|
1540
|
+
const response = await this.processStreamResponse(processedParams, readableController, "resume-stream");
|
|
1541
|
+
const streamResponse = new Response(readable, {
|
|
1542
|
+
status: response.status,
|
|
1543
|
+
statusText: response.statusText,
|
|
1544
|
+
headers: response.headers
|
|
1545
|
+
});
|
|
1546
|
+
streamResponse.processDataStream = async ({
|
|
1547
|
+
onChunk
|
|
1548
|
+
}) => {
|
|
1549
|
+
await processMastraStream({
|
|
1550
|
+
stream: streamResponse.body,
|
|
1551
|
+
onChunk
|
|
1552
|
+
});
|
|
1553
|
+
};
|
|
1554
|
+
return streamResponse;
|
|
1555
|
+
}
|
|
1514
1556
|
/**
|
|
1515
1557
|
* Approves a pending tool call and returns the complete response (non-streaming).
|
|
1516
1558
|
* Used when `requireToolApproval` is enabled with generate() to allow the agent to proceed.
|