@mastra/client-js 0.12.2 → 0.12.3-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 +22 -0
- package/dist/client.d.ts +3 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/index.cjs +116 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +116 -19
- package/dist/index.js.map +1 -1
- package/dist/resources/agent.d.ts +20 -9
- package/dist/resources/agent.d.ts.map +1 -1
- package/dist/types.d.ts +8 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/process-mastra-stream.d.ts +5 -1
- package/dist/utils/process-mastra-stream.d.ts.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @mastra/client-js
|
|
2
2
|
|
|
3
|
+
## 0.12.3-alpha.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Delayed deprecation notice for streamVNext() replacing stream() until Sept 23rd ([#7739](https://github.com/mastra-ai/mastra/pull/7739))
|
|
8
|
+
|
|
9
|
+
- Client SDK Agents, Mastra server - support runtimeContext with GET requests ([#7734](https://github.com/mastra-ai/mastra/pull/7734))
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`2a6585f`](https://github.com/mastra-ai/mastra/commit/2a6585f7cb71f023f805d521d1c3c95fb9a3aa59), [`3d26e83`](https://github.com/mastra-ai/mastra/commit/3d26e8353a945719028f087cc6ac4b06f0ce27d2), [`56e55d1`](https://github.com/mastra-ai/mastra/commit/56e55d1e9eb63e7d9e41aa46e012aae471256812)]:
|
|
12
|
+
- @mastra/core@0.16.3-alpha.1
|
|
13
|
+
|
|
14
|
+
## 0.12.3-alpha.0
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- AN packages ([#7711](https://github.com/mastra-ai/mastra/pull/7711))
|
|
19
|
+
|
|
20
|
+
- Change SchemaCompat zodToJsonSchema ref strategy from none to relative, leading to less schema warnings and smaller converted schema sizes ([#7697](https://github.com/mastra-ai/mastra/pull/7697))
|
|
21
|
+
|
|
22
|
+
- Updated dependencies [[`b4379f7`](https://github.com/mastra-ai/mastra/commit/b4379f703fd74474f253420e8c3a684f2c4b2f8e), [`dd9119b`](https://github.com/mastra-ai/mastra/commit/dd9119b175a8f389082f75c12750e51f96d65dca), [`d34aaa1`](https://github.com/mastra-ai/mastra/commit/d34aaa1da5d3c5f991740f59e2fe6d28d3e2dd91), [`ce1e580`](https://github.com/mastra-ai/mastra/commit/ce1e580f6391e94a0c6816a9c5db0a21566a262f), [`b2babfa`](https://github.com/mastra-ai/mastra/commit/b2babfa9e75b22f2759179e71d8473f6dc5421ed), [`d8c3ba5`](https://github.com/mastra-ai/mastra/commit/d8c3ba516f4173282d293f7e64769cfc8738d360), [`a566c4e`](https://github.com/mastra-ai/mastra/commit/a566c4e92d86c1671707c54359b1d33934f7cc13), [`af333aa`](https://github.com/mastra-ai/mastra/commit/af333aa30fe6d1b127024b03a64736c46eddeca2), [`3863c52`](https://github.com/mastra-ai/mastra/commit/3863c52d44b4e5779968b802d977e87adf939d8e), [`6424c7e`](https://github.com/mastra-ai/mastra/commit/6424c7ec38b6921d66212431db1e0958f441b2a7), [`db94750`](https://github.com/mastra-ai/mastra/commit/db94750a41fd29b43eb1f7ce8e97ba8b9978c91b), [`a66a371`](https://github.com/mastra-ai/mastra/commit/a66a3716b00553d7f01842be9deb34f720b10fab), [`69fc3cd`](https://github.com/mastra-ai/mastra/commit/69fc3cd0fd814901785bdcf49bf536ab1e7fd975)]:
|
|
23
|
+
- @mastra/core@0.16.3-alpha.0
|
|
24
|
+
|
|
3
25
|
## 0.12.2
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/dist/client.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AITraceRecord, AITracesPaginatedArg, WorkflowInfo } from '@mastra/core';
|
|
2
2
|
import type { ServerDetailInfo } from '@mastra/core/mcp';
|
|
3
|
+
import type { RuntimeContext } from '@mastra/core/runtime-context';
|
|
3
4
|
import { Agent, MemoryThread, Tool, Workflow, Vector, BaseResource, Network, A2A, MCPTool, LegacyWorkflow, AgentBuilder } from './resources/index.js';
|
|
4
5
|
import { NetworkMemoryThread } from './resources/network-memory-thread.js';
|
|
5
6
|
import { VNextNetwork } from './resources/vNextNetwork.js';
|
|
@@ -9,9 +10,10 @@ export declare class MastraClient extends BaseResource {
|
|
|
9
10
|
constructor(options: ClientOptions);
|
|
10
11
|
/**
|
|
11
12
|
* Retrieves all available agents
|
|
13
|
+
* @param runtimeContext - Runtime context to use for the agents
|
|
12
14
|
* @returns Promise containing map of agent IDs to agent details
|
|
13
15
|
*/
|
|
14
|
-
getAgents(): Promise<Record<string, GetAgentResponse>>;
|
|
16
|
+
getAgents(runtimeContext?: RuntimeContext | Record<string, any>): Promise<Record<string, GetAgentResponse>>;
|
|
15
17
|
/**
|
|
16
18
|
* Gets an agent instance by ID
|
|
17
19
|
* @param agentId - ID of the agent to retrieve
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACtF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EACL,KAAK,EACL,YAAY,EACZ,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,OAAO,EACP,GAAG,EACH,OAAO,EACP,cAAc,EACd,YAAY,EAEb,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,KAAK,EACV,aAAa,EACb,wBAAwB,EACxB,0BAA0B,EAC1B,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,eAAe,EACf,qBAAqB,EACrB,uBAAuB,EACvB,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,mBAAmB,EACnB,yBAAyB,EACzB,2BAA2B,EAC3B,qBAAqB,EACrB,yBAAyB,EACzB,yBAAyB,EACzB,uBAAuB,EACvB,4BAA4B,EAC5B,+BAA+B,EAC/B,gCAAgC,EAChC,iBAAiB,EACjB,yBAAyB,EACzB,iBAAiB,EACjB,sBAAsB,EACtB,yBAAyB,EACzB,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACtF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EACL,KAAK,EACL,YAAY,EACZ,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,OAAO,EACP,GAAG,EACH,OAAO,EACP,cAAc,EACd,YAAY,EAEb,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,KAAK,EACV,aAAa,EACb,wBAAwB,EACxB,0BAA0B,EAC1B,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,eAAe,EACf,qBAAqB,EACrB,uBAAuB,EACvB,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,mBAAmB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IACI,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAI/D;;;;OAIG;IACI,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAIvD,mBAAmB,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAqBzF;;;;OAIG;IACI,gBAAgB,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAenF;;;;OAIG;IACI,mBAAmB,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAezF;;;;OAIG;IACI,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAOrE;;;OAGG;IACH,iBAAiB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAItC,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAInD,WAAW,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAGxE"}
|
package/dist/index.cjs
CHANGED
|
@@ -21,6 +21,12 @@ function parseClientRuntimeContext(runtimeContext$1) {
|
|
|
21
21
|
}
|
|
22
22
|
return void 0;
|
|
23
23
|
}
|
|
24
|
+
function base64RuntimeContext(runtimeContext) {
|
|
25
|
+
if (runtimeContext) {
|
|
26
|
+
return btoa(JSON.stringify(runtimeContext));
|
|
27
|
+
}
|
|
28
|
+
return void 0;
|
|
29
|
+
}
|
|
24
30
|
function isZodType(value) {
|
|
25
31
|
return typeof value === "object" && value !== null && "_def" in value && "parse" in value && typeof value.parse === "function" && "safeParse" in value && typeof value.safeParse === "function";
|
|
26
32
|
}
|
|
@@ -32,7 +38,7 @@ function zodToJsonSchema(zodSchema) {
|
|
|
32
38
|
const fn = "toJSONSchema";
|
|
33
39
|
return zod.z[fn].call(zod.z, zodSchema);
|
|
34
40
|
}
|
|
35
|
-
return originalZodToJsonSchema__default.default(zodSchema, { $refStrategy: "
|
|
41
|
+
return originalZodToJsonSchema__default.default(zodSchema, { $refStrategy: "relative" });
|
|
36
42
|
}
|
|
37
43
|
|
|
38
44
|
// src/utils/process-client-tools.ts
|
|
@@ -65,7 +71,7 @@ function processClientTools(clientTools) {
|
|
|
65
71
|
}
|
|
66
72
|
|
|
67
73
|
// src/utils/process-mastra-stream.ts
|
|
68
|
-
async function
|
|
74
|
+
async function sharedProcessMastraStream({
|
|
69
75
|
stream,
|
|
70
76
|
onChunk
|
|
71
77
|
}) {
|
|
@@ -99,6 +105,24 @@ async function processMastraStream({
|
|
|
99
105
|
reader.releaseLock();
|
|
100
106
|
}
|
|
101
107
|
}
|
|
108
|
+
async function processMastraNetworkStream({
|
|
109
|
+
stream,
|
|
110
|
+
onChunk
|
|
111
|
+
}) {
|
|
112
|
+
return sharedProcessMastraStream({
|
|
113
|
+
stream,
|
|
114
|
+
onChunk
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
async function processMastraStream({
|
|
118
|
+
stream,
|
|
119
|
+
onChunk
|
|
120
|
+
}) {
|
|
121
|
+
return sharedProcessMastraStream({
|
|
122
|
+
stream,
|
|
123
|
+
onChunk
|
|
124
|
+
});
|
|
125
|
+
}
|
|
102
126
|
|
|
103
127
|
// src/resources/base.ts
|
|
104
128
|
var BaseResource = class {
|
|
@@ -261,17 +285,31 @@ var AgentVoice = class extends BaseResource {
|
|
|
261
285
|
}
|
|
262
286
|
/**
|
|
263
287
|
* Get available speakers for the agent's voice provider
|
|
288
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
264
289
|
* @returns Promise containing list of available speakers
|
|
265
290
|
*/
|
|
266
|
-
getSpeakers() {
|
|
267
|
-
|
|
291
|
+
getSpeakers(runtimeContext) {
|
|
292
|
+
const runtimeContextParam = base64RuntimeContext(parseClientRuntimeContext(runtimeContext));
|
|
293
|
+
const searchParams = new URLSearchParams();
|
|
294
|
+
if (runtimeContextParam) {
|
|
295
|
+
searchParams.set("runtimeContext", runtimeContextParam);
|
|
296
|
+
}
|
|
297
|
+
const queryString = searchParams.toString();
|
|
298
|
+
return this.request(`/api/agents/${this.agentId}/voice/speakers${queryString ? `?${queryString}` : ""}`);
|
|
268
299
|
}
|
|
269
300
|
/**
|
|
270
301
|
* Get the listener configuration for the agent's voice provider
|
|
302
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
271
303
|
* @returns Promise containing a check if the agent has listening capabilities
|
|
272
304
|
*/
|
|
273
|
-
getListener() {
|
|
274
|
-
|
|
305
|
+
getListener(runtimeContext) {
|
|
306
|
+
const runtimeContextParam = base64RuntimeContext(parseClientRuntimeContext(runtimeContext));
|
|
307
|
+
const searchParams = new URLSearchParams();
|
|
308
|
+
if (runtimeContextParam) {
|
|
309
|
+
searchParams.set("runtimeContext", runtimeContextParam);
|
|
310
|
+
}
|
|
311
|
+
const queryString = searchParams.toString();
|
|
312
|
+
return this.request(`/api/agents/${this.agentId}/voice/listener${queryString ? `?${queryString}` : ""}`);
|
|
275
313
|
}
|
|
276
314
|
};
|
|
277
315
|
var Agent = class extends BaseResource {
|
|
@@ -283,14 +321,21 @@ var Agent = class extends BaseResource {
|
|
|
283
321
|
voice;
|
|
284
322
|
/**
|
|
285
323
|
* Retrieves details about the agent
|
|
324
|
+
* @param runtimeContext - Runtime context to use for the agent
|
|
286
325
|
* @returns Promise containing agent details including model and instructions
|
|
287
326
|
*/
|
|
288
|
-
details() {
|
|
289
|
-
|
|
327
|
+
details(runtimeContext) {
|
|
328
|
+
const runtimeContextParam = base64RuntimeContext(parseClientRuntimeContext(runtimeContext));
|
|
329
|
+
const searchParams = new URLSearchParams();
|
|
330
|
+
if (runtimeContextParam) {
|
|
331
|
+
searchParams.set("runtimeContext", runtimeContextParam);
|
|
332
|
+
}
|
|
333
|
+
const queryString = searchParams.toString();
|
|
334
|
+
return this.request(`/api/agents/${this.agentId}${queryString ? `?${queryString}` : ""}`);
|
|
290
335
|
}
|
|
291
336
|
async generate(params) {
|
|
292
337
|
console.warn(
|
|
293
|
-
"Deprecation NOTICE:Generate method will switch to use generateVNext implementation September
|
|
338
|
+
"Deprecation NOTICE:Generate method will switch to use generateVNext implementation September 23rd, 2025. Please use generateLegacy if you don't want to upgrade just yet."
|
|
294
339
|
);
|
|
295
340
|
return this.generateLegacy(params);
|
|
296
341
|
}
|
|
@@ -660,7 +705,7 @@ var Agent = class extends BaseResource {
|
|
|
660
705
|
*/
|
|
661
706
|
async stream(params) {
|
|
662
707
|
console.warn(
|
|
663
|
-
"Deprecation NOTICE:\nStream method will switch to use streamVNext implementation September
|
|
708
|
+
"Deprecation NOTICE:\nStream method will switch to use streamVNext implementation September 23rd, 2025. Please use streamLegacy if you don't want to upgrade just yet."
|
|
664
709
|
);
|
|
665
710
|
return this.streamLegacy(params);
|
|
666
711
|
}
|
|
@@ -1064,6 +1109,30 @@ var Agent = class extends BaseResource {
|
|
|
1064
1109
|
}
|
|
1065
1110
|
return response;
|
|
1066
1111
|
}
|
|
1112
|
+
async network(params) {
|
|
1113
|
+
const response = await this.request(`/api/agents/${this.agentId}/network`, {
|
|
1114
|
+
method: "POST",
|
|
1115
|
+
body: params,
|
|
1116
|
+
stream: true
|
|
1117
|
+
});
|
|
1118
|
+
if (!response.body) {
|
|
1119
|
+
throw new Error("No response body");
|
|
1120
|
+
}
|
|
1121
|
+
const streamResponse = new Response(response.body, {
|
|
1122
|
+
status: response.status,
|
|
1123
|
+
statusText: response.statusText,
|
|
1124
|
+
headers: response.headers
|
|
1125
|
+
});
|
|
1126
|
+
streamResponse.processDataStream = async ({
|
|
1127
|
+
onChunk
|
|
1128
|
+
}) => {
|
|
1129
|
+
await processMastraNetworkStream({
|
|
1130
|
+
stream: streamResponse.body,
|
|
1131
|
+
onChunk
|
|
1132
|
+
});
|
|
1133
|
+
};
|
|
1134
|
+
return streamResponse;
|
|
1135
|
+
}
|
|
1067
1136
|
async streamVNext(params) {
|
|
1068
1137
|
const processedParams = {
|
|
1069
1138
|
...params,
|
|
@@ -1209,10 +1278,17 @@ var Agent = class extends BaseResource {
|
|
|
1209
1278
|
/**
|
|
1210
1279
|
* Gets details about a specific tool available to the agent
|
|
1211
1280
|
* @param toolId - ID of the tool to retrieve
|
|
1281
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
1212
1282
|
* @returns Promise containing tool details
|
|
1213
1283
|
*/
|
|
1214
|
-
getTool(toolId) {
|
|
1215
|
-
|
|
1284
|
+
getTool(toolId, runtimeContext) {
|
|
1285
|
+
const runtimeContextParam = base64RuntimeContext(parseClientRuntimeContext(runtimeContext));
|
|
1286
|
+
const searchParams = new URLSearchParams();
|
|
1287
|
+
if (runtimeContextParam) {
|
|
1288
|
+
searchParams.set("runtimeContext", runtimeContextParam);
|
|
1289
|
+
}
|
|
1290
|
+
const queryString = searchParams.toString();
|
|
1291
|
+
return this.request(`/api/agents/${this.agentId}/tools/${toolId}${queryString ? `?${queryString}` : ""}`);
|
|
1216
1292
|
}
|
|
1217
1293
|
/**
|
|
1218
1294
|
* Executes a tool for the agent
|
|
@@ -1223,7 +1299,7 @@ var Agent = class extends BaseResource {
|
|
|
1223
1299
|
executeTool(toolId, params) {
|
|
1224
1300
|
const body = {
|
|
1225
1301
|
data: params.data,
|
|
1226
|
-
runtimeContext:
|
|
1302
|
+
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
1227
1303
|
};
|
|
1228
1304
|
return this.request(`/api/agents/${this.agentId}/tools/${toolId}/execute`, {
|
|
1229
1305
|
method: "POST",
|
|
@@ -1232,17 +1308,31 @@ var Agent = class extends BaseResource {
|
|
|
1232
1308
|
}
|
|
1233
1309
|
/**
|
|
1234
1310
|
* Retrieves evaluation results for the agent
|
|
1311
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
1235
1312
|
* @returns Promise containing agent evaluations
|
|
1236
1313
|
*/
|
|
1237
|
-
evals() {
|
|
1238
|
-
|
|
1314
|
+
evals(runtimeContext) {
|
|
1315
|
+
const runtimeContextParam = base64RuntimeContext(parseClientRuntimeContext(runtimeContext));
|
|
1316
|
+
const searchParams = new URLSearchParams();
|
|
1317
|
+
if (runtimeContextParam) {
|
|
1318
|
+
searchParams.set("runtimeContext", runtimeContextParam);
|
|
1319
|
+
}
|
|
1320
|
+
const queryString = searchParams.toString();
|
|
1321
|
+
return this.request(`/api/agents/${this.agentId}/evals/ci${queryString ? `?${queryString}` : ""}`);
|
|
1239
1322
|
}
|
|
1240
1323
|
/**
|
|
1241
1324
|
* Retrieves live evaluation results for the agent
|
|
1325
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
1242
1326
|
* @returns Promise containing live agent evaluations
|
|
1243
1327
|
*/
|
|
1244
|
-
liveEvals() {
|
|
1245
|
-
|
|
1328
|
+
liveEvals(runtimeContext) {
|
|
1329
|
+
const runtimeContextParam = base64RuntimeContext(parseClientRuntimeContext(runtimeContext));
|
|
1330
|
+
const searchParams = new URLSearchParams();
|
|
1331
|
+
if (runtimeContextParam) {
|
|
1332
|
+
searchParams.set("runtimeContext", runtimeContextParam);
|
|
1333
|
+
}
|
|
1334
|
+
const queryString = searchParams.toString();
|
|
1335
|
+
return this.request(`/api/agents/${this.agentId}/evals/live${queryString ? `?${queryString}` : ""}`);
|
|
1246
1336
|
}
|
|
1247
1337
|
/**
|
|
1248
1338
|
* Updates the model for the agent
|
|
@@ -2772,10 +2862,17 @@ var MastraClient = class extends BaseResource {
|
|
|
2772
2862
|
}
|
|
2773
2863
|
/**
|
|
2774
2864
|
* Retrieves all available agents
|
|
2865
|
+
* @param runtimeContext - Runtime context to use for the agents
|
|
2775
2866
|
* @returns Promise containing map of agent IDs to agent details
|
|
2776
2867
|
*/
|
|
2777
|
-
getAgents() {
|
|
2778
|
-
|
|
2868
|
+
getAgents(runtimeContext) {
|
|
2869
|
+
const runtimeContextParam = base64RuntimeContext(parseClientRuntimeContext(runtimeContext));
|
|
2870
|
+
const searchParams = new URLSearchParams();
|
|
2871
|
+
if (runtimeContextParam) {
|
|
2872
|
+
searchParams.set("runtimeContext", runtimeContextParam);
|
|
2873
|
+
}
|
|
2874
|
+
const queryString = searchParams.toString();
|
|
2875
|
+
return this.request(`/api/agents${queryString ? `?${queryString}` : ""}`);
|
|
2779
2876
|
}
|
|
2780
2877
|
/**
|
|
2781
2878
|
* Gets an agent instance by ID
|