@mastra/client-js 1.60.0-alpha.2 → 1.60.0-alpha.4
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/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +6 -6
- package/dist/index.cjs +37 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +37 -26
- package/dist/index.js.map +1 -1
- package/dist/resources/agent.d.ts.map +1 -1
- package/dist/route-types.generated.d.ts +6 -0
- package/dist/route-types.generated.d.ts.map +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
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.60.0-alpha.
|
|
6
|
+
version: "1.60.0-alpha.4"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.60.0-alpha.
|
|
2
|
+
"version": "1.60.0-alpha.4",
|
|
3
3
|
"package": "@mastra/client-js",
|
|
4
4
|
"exports": {
|
|
5
5
|
"ClientTool": {
|
|
6
6
|
"types": "dist/tools.d.ts",
|
|
7
7
|
"implementation": "dist/index.js",
|
|
8
|
-
"line":
|
|
8
|
+
"line": 9603
|
|
9
9
|
},
|
|
10
10
|
"MastraClient": {
|
|
11
11
|
"types": "dist/client.d.ts",
|
|
12
12
|
"implementation": "dist/index.js",
|
|
13
|
-
"line":
|
|
13
|
+
"line": 7761
|
|
14
14
|
},
|
|
15
15
|
"MastraClientError": {
|
|
16
16
|
"types": "dist/types.d.ts",
|
|
@@ -20,17 +20,17 @@
|
|
|
20
20
|
"agentControllerMessageText": {
|
|
21
21
|
"types": "dist/resources/agent-controller.d.ts",
|
|
22
22
|
"implementation": "dist/index.js",
|
|
23
|
-
"line":
|
|
23
|
+
"line": 7738
|
|
24
24
|
},
|
|
25
25
|
"createTool": {
|
|
26
26
|
"types": "dist/tools.d.ts",
|
|
27
27
|
"implementation": "dist/index.js",
|
|
28
|
-
"line":
|
|
28
|
+
"line": 9617
|
|
29
29
|
},
|
|
30
30
|
"isKnownAgentControllerEvent": {
|
|
31
31
|
"types": "dist/resources/agent-controller.d.ts",
|
|
32
32
|
"implementation": "dist/index.js",
|
|
33
|
-
"line":
|
|
33
|
+
"line": 7101
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
"modules": {}
|
package/dist/index.cjs
CHANGED
|
@@ -1338,11 +1338,13 @@ async function executeClientToolWithObservability({ clientTool, args, toolName,
|
|
|
1338
1338
|
}
|
|
1339
1339
|
};
|
|
1340
1340
|
}
|
|
1341
|
-
async function executeToolCallAndRespond({ response, params, agentId, resourceId, threadId, requestContext, respondFn }) {
|
|
1341
|
+
async function executeToolCallAndRespond({ response, params, agentId, resourceId, threadId, requestContext, respondFn, abortSignal }) {
|
|
1342
1342
|
if (response.finishReason === "tool-calls") {
|
|
1343
1343
|
const toolCalls = response.toolCalls;
|
|
1344
1344
|
if (!toolCalls || !Array.isArray(toolCalls)) return response;
|
|
1345
|
+
const toolResults = [];
|
|
1345
1346
|
for (const toolCall of toolCalls) {
|
|
1347
|
+
if (abortSignal?.aborted) throw abortSignal.reason ?? new DOMException("This operation was aborted", "AbortError");
|
|
1346
1348
|
const clientTool = params.clientTools?.[toolCall.payload.toolName];
|
|
1347
1349
|
if (clientTool && clientTool.execute) {
|
|
1348
1350
|
const { result, observability } = await executeClientToolWithObservability({
|
|
@@ -1372,19 +1374,22 @@ async function executeToolCallAndRespond({ response, params, agentId, resourceId
|
|
|
1372
1374
|
...modelOutput != null ? { providerOptions: { mastra: { modelOutput } } } : {}
|
|
1373
1375
|
};
|
|
1374
1376
|
if (observability) toolResultContent.__mastraObservability = observability;
|
|
1375
|
-
|
|
1376
|
-
role: "tool",
|
|
1377
|
-
content: [toolResultContent]
|
|
1378
|
-
}];
|
|
1379
|
-
const updatedMessages = threadId ? newMessages : [...Array.isArray(params.messages) ? params.messages : [], ...newMessages];
|
|
1380
|
-
const respondOptions = {
|
|
1381
|
-
...params,
|
|
1382
|
-
clientTools: params.clientToolsResolver?.() ?? params.clientTools
|
|
1383
|
-
};
|
|
1384
|
-
delete respondOptions.messages;
|
|
1385
|
-
return respondFn(updatedMessages, respondOptions);
|
|
1377
|
+
toolResults.push(toolResultContent);
|
|
1386
1378
|
}
|
|
1387
1379
|
}
|
|
1380
|
+
if (toolResults.length > 0) {
|
|
1381
|
+
const newMessages = [...response.response.messages || [], {
|
|
1382
|
+
role: "tool",
|
|
1383
|
+
content: toolResults
|
|
1384
|
+
}];
|
|
1385
|
+
const updatedMessages = threadId ? newMessages : [...Array.isArray(params.messages) ? params.messages : [], ...newMessages];
|
|
1386
|
+
const respondOptions = {
|
|
1387
|
+
...params,
|
|
1388
|
+
clientTools: params.clientToolsResolver?.() ?? params.clientTools
|
|
1389
|
+
};
|
|
1390
|
+
delete respondOptions.messages;
|
|
1391
|
+
return respondFn(updatedMessages, respondOptions);
|
|
1392
|
+
}
|
|
1388
1393
|
}
|
|
1389
1394
|
return response;
|
|
1390
1395
|
}
|
|
@@ -2081,7 +2086,9 @@ var Agent = class extends BaseResource {
|
|
|
2081
2086
|
if (abortSignal?.aborted) throw abortSignal.reason ?? new DOMException("This operation was aborted", "AbortError");
|
|
2082
2087
|
const toolCalls = response.toolCalls;
|
|
2083
2088
|
if (!toolCalls || !Array.isArray(toolCalls)) return response;
|
|
2089
|
+
const toolResults = [];
|
|
2084
2090
|
for (const toolCall of toolCalls) {
|
|
2091
|
+
if (abortSignal?.aborted) throw abortSignal.reason ?? new DOMException("This operation was aborted", "AbortError");
|
|
2085
2092
|
const clientTool = processedParams.clientTools?.[toolCall.toolName];
|
|
2086
2093
|
if (clientTool && clientTool.execute) {
|
|
2087
2094
|
const { result, observability } = await executeClientToolWithObservability({
|
|
@@ -2102,22 +2109,25 @@ var Agent = class extends BaseResource {
|
|
|
2102
2109
|
}
|
|
2103
2110
|
}
|
|
2104
2111
|
});
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
result,
|
|
2112
|
-
...observability ? { __mastraObservability: observability } : {}
|
|
2113
|
-
}]
|
|
2114
|
-
}];
|
|
2115
|
-
return this.generateLegacy({
|
|
2116
|
-
...params,
|
|
2117
|
-
messages: updatedMessages
|
|
2112
|
+
toolResults.push({
|
|
2113
|
+
type: "tool-result",
|
|
2114
|
+
toolCallId: toolCall.toolCallId,
|
|
2115
|
+
toolName: toolCall.toolName,
|
|
2116
|
+
result,
|
|
2117
|
+
...observability ? { __mastraObservability: observability } : {}
|
|
2118
2118
|
});
|
|
2119
2119
|
}
|
|
2120
2120
|
}
|
|
2121
|
+
if (toolResults.length > 0) {
|
|
2122
|
+
const updatedMessages = [...response.response.messages, {
|
|
2123
|
+
role: "tool",
|
|
2124
|
+
content: toolResults
|
|
2125
|
+
}];
|
|
2126
|
+
return this.generateLegacy({
|
|
2127
|
+
...params,
|
|
2128
|
+
messages: updatedMessages
|
|
2129
|
+
});
|
|
2130
|
+
}
|
|
2121
2131
|
}
|
|
2122
2132
|
return response;
|
|
2123
2133
|
}
|
|
@@ -2159,7 +2169,8 @@ var Agent = class extends BaseResource {
|
|
|
2159
2169
|
resourceId,
|
|
2160
2170
|
threadId,
|
|
2161
2171
|
requestContext,
|
|
2162
|
-
respondFn: this.generate.bind(this)
|
|
2172
|
+
respondFn: this.generate.bind(this),
|
|
2173
|
+
abortSignal
|
|
2163
2174
|
});
|
|
2164
2175
|
}
|
|
2165
2176
|
return response;
|