@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/dist/index.js
CHANGED
|
@@ -1209,9 +1209,14 @@ var Agent = class extends BaseResource {
|
|
|
1209
1209
|
const { resource, thread } = memory ?? {};
|
|
1210
1210
|
const threadId = processedParams.threadId ?? (typeof thread === "string" ? thread : thread?.id);
|
|
1211
1211
|
const resourceId = processedParams.resourceId ?? resource;
|
|
1212
|
+
let requestBody = processedParams;
|
|
1213
|
+
if (route === "resume-stream") {
|
|
1214
|
+
const { messages: _messages, ...resumeStreamBody } = processedParams;
|
|
1215
|
+
requestBody = resumeStreamBody;
|
|
1216
|
+
}
|
|
1212
1217
|
const response = await this.request(`/agents/${this.agentId}/${route}`, {
|
|
1213
1218
|
method: "POST",
|
|
1214
|
-
body:
|
|
1219
|
+
body: requestBody,
|
|
1215
1220
|
stream: true
|
|
1216
1221
|
});
|
|
1217
1222
|
if (!response.body) {
|
|
@@ -1510,6 +1515,43 @@ var Agent = class extends BaseResource {
|
|
|
1510
1515
|
};
|
|
1511
1516
|
return streamResponse;
|
|
1512
1517
|
}
|
|
1518
|
+
/**
|
|
1519
|
+
* Resumes a suspended agent stream with custom resume data.
|
|
1520
|
+
* Used to continue execution after a suspension point (e.g., workflow suspend within an agent).
|
|
1521
|
+
*/
|
|
1522
|
+
async resumeStream(resumeData, options) {
|
|
1523
|
+
const processedParams = {
|
|
1524
|
+
...options,
|
|
1525
|
+
resumeData,
|
|
1526
|
+
requestContext: parseClientRequestContext(options.requestContext),
|
|
1527
|
+
clientTools: processClientTools(options.clientTools),
|
|
1528
|
+
structuredOutput: options.structuredOutput ? {
|
|
1529
|
+
...options.structuredOutput,
|
|
1530
|
+
schema: standardSchemaToJSONSchema(toStandardSchema(options.structuredOutput.schema))
|
|
1531
|
+
} : void 0
|
|
1532
|
+
};
|
|
1533
|
+
let readableController;
|
|
1534
|
+
const readable = new ReadableStream({
|
|
1535
|
+
start(controller) {
|
|
1536
|
+
readableController = controller;
|
|
1537
|
+
}
|
|
1538
|
+
});
|
|
1539
|
+
const response = await this.processStreamResponse(processedParams, readableController, "resume-stream");
|
|
1540
|
+
const streamResponse = new Response(readable, {
|
|
1541
|
+
status: response.status,
|
|
1542
|
+
statusText: response.statusText,
|
|
1543
|
+
headers: response.headers
|
|
1544
|
+
});
|
|
1545
|
+
streamResponse.processDataStream = async ({
|
|
1546
|
+
onChunk
|
|
1547
|
+
}) => {
|
|
1548
|
+
await processMastraStream({
|
|
1549
|
+
stream: streamResponse.body,
|
|
1550
|
+
onChunk
|
|
1551
|
+
});
|
|
1552
|
+
};
|
|
1553
|
+
return streamResponse;
|
|
1554
|
+
}
|
|
1513
1555
|
/**
|
|
1514
1556
|
* Approves a pending tool call and returns the complete response (non-streaming).
|
|
1515
1557
|
* Used when `requireToolApproval` is enabled with generate() to allow the agent to proceed.
|