@mastra/client-js 0.0.0-fix-multi-modal-for-cloud-20251028082043 → 0.0.0-fix-persist-session-cache-option-mcp-server-20251030171242
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 +33 -3
- package/README.md +7 -7
- package/dist/client.d.ts +35 -56
- package/dist/client.d.ts.map +1 -1
- package/dist/index.cjs +364 -358
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +364 -358
- package/dist/index.js.map +1 -1
- package/dist/resources/agent-builder.d.ts +55 -7
- package/dist/resources/agent-builder.d.ts.map +1 -1
- package/dist/resources/agent.d.ts +20 -25
- package/dist/resources/agent.d.ts.map +1 -1
- package/dist/resources/mcp-tool.d.ts +5 -5
- package/dist/resources/memory-thread.d.ts +16 -8
- package/dist/resources/memory-thread.d.ts.map +1 -1
- package/dist/resources/tool.d.ts +4 -4
- package/dist/resources/vector.d.ts +5 -5
- package/dist/resources/workflow.d.ts +41 -41
- package/dist/resources/workflow.d.ts.map +1 -1
- package/dist/types.d.ts +35 -34
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/index.d.ts +10 -4
- package/dist/utils/index.d.ts.map +1 -1
- package/package.json +4 -4
- package/dist/resources/network-memory-thread.d.ts +0 -47
- package/dist/resources/network-memory-thread.d.ts.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var uiUtils = require('@ai-sdk/ui-utils');
|
|
4
4
|
var uuid = require('@lukeed/uuid');
|
|
5
5
|
var error = require('@mastra/core/error');
|
|
6
|
-
var
|
|
6
|
+
var requestContext = require('@mastra/core/request-context');
|
|
7
7
|
var isVercelTool = require('@mastra/core/tools/is-vercel-tool');
|
|
8
8
|
var zod = require('zod');
|
|
9
9
|
var originalZodToJsonSchema = require('zod-to-json-schema');
|
|
@@ -13,28 +13,28 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
13
13
|
var originalZodToJsonSchema__default = /*#__PURE__*/_interopDefault(originalZodToJsonSchema);
|
|
14
14
|
|
|
15
15
|
// src/resources/agent.ts
|
|
16
|
-
function
|
|
17
|
-
if (
|
|
18
|
-
if (
|
|
19
|
-
return Object.fromEntries(
|
|
16
|
+
function parseClientRequestContext(requestContext$1) {
|
|
17
|
+
if (requestContext$1) {
|
|
18
|
+
if (requestContext$1 instanceof requestContext.RequestContext) {
|
|
19
|
+
return Object.fromEntries(requestContext$1.entries());
|
|
20
20
|
}
|
|
21
|
-
return
|
|
21
|
+
return requestContext$1;
|
|
22
22
|
}
|
|
23
23
|
return void 0;
|
|
24
24
|
}
|
|
25
|
-
function
|
|
26
|
-
if (
|
|
27
|
-
return btoa(JSON.stringify(
|
|
25
|
+
function base64RequestContext(requestContext) {
|
|
26
|
+
if (requestContext) {
|
|
27
|
+
return btoa(JSON.stringify(requestContext));
|
|
28
28
|
}
|
|
29
29
|
return void 0;
|
|
30
30
|
}
|
|
31
|
-
function
|
|
32
|
-
const
|
|
33
|
-
if (!
|
|
31
|
+
function requestContextQueryString(requestContext, delimiter = "?") {
|
|
32
|
+
const requestContextParam = base64RequestContext(parseClientRequestContext(requestContext));
|
|
33
|
+
if (!requestContextParam) return "";
|
|
34
34
|
const searchParams = new URLSearchParams();
|
|
35
|
-
searchParams.set("
|
|
35
|
+
searchParams.set("requestContext", requestContextParam);
|
|
36
36
|
const queryString = searchParams.toString();
|
|
37
|
-
return queryString ?
|
|
37
|
+
return queryString ? `${delimiter}${queryString}` : "";
|
|
38
38
|
}
|
|
39
39
|
function isZodType(value) {
|
|
40
40
|
return typeof value === "object" && value !== null && "_def" in value && "parse" in value && typeof value.parse === "function" && "safeParse" in value && typeof value.safeParse === "function";
|
|
@@ -206,7 +206,7 @@ async function executeToolCallAndRespond({
|
|
|
206
206
|
runId,
|
|
207
207
|
resourceId,
|
|
208
208
|
threadId,
|
|
209
|
-
|
|
209
|
+
requestContext,
|
|
210
210
|
respondFn
|
|
211
211
|
}) {
|
|
212
212
|
if (response.finishReason === "tool-calls") {
|
|
@@ -223,7 +223,7 @@ async function executeToolCallAndRespond({
|
|
|
223
223
|
runId,
|
|
224
224
|
resourceId,
|
|
225
225
|
threadId,
|
|
226
|
-
|
|
226
|
+
requestContext,
|
|
227
227
|
tracingContext: { currentSpan: void 0 },
|
|
228
228
|
suspend: async () => {
|
|
229
229
|
}
|
|
@@ -296,21 +296,21 @@ var AgentVoice = class extends BaseResource {
|
|
|
296
296
|
}
|
|
297
297
|
/**
|
|
298
298
|
* Get available speakers for the agent's voice provider
|
|
299
|
-
* @param
|
|
300
|
-
* @param
|
|
299
|
+
* @param requestContext - Optional request context to pass as query parameter
|
|
300
|
+
* @param requestContext - Optional request context to pass as query parameter
|
|
301
301
|
* @returns Promise containing list of available speakers
|
|
302
302
|
*/
|
|
303
|
-
getSpeakers(
|
|
304
|
-
return this.request(`/api/agents/${this.agentId}/voice/speakers${
|
|
303
|
+
getSpeakers(requestContext) {
|
|
304
|
+
return this.request(`/api/agents/${this.agentId}/voice/speakers${requestContextQueryString(requestContext)}`);
|
|
305
305
|
}
|
|
306
306
|
/**
|
|
307
307
|
* Get the listener configuration for the agent's voice provider
|
|
308
|
-
* @param
|
|
309
|
-
* @param
|
|
308
|
+
* @param requestContext - Optional request context to pass as query parameter
|
|
309
|
+
* @param requestContext - Optional request context to pass as query parameter
|
|
310
310
|
* @returns Promise containing a check if the agent has listening capabilities
|
|
311
311
|
*/
|
|
312
|
-
getListener(
|
|
313
|
-
return this.request(`/api/agents/${this.agentId}/voice/listener${
|
|
312
|
+
getListener(requestContext) {
|
|
313
|
+
return this.request(`/api/agents/${this.agentId}/voice/listener${requestContextQueryString(requestContext)}`);
|
|
314
314
|
}
|
|
315
315
|
};
|
|
316
316
|
var Agent = class extends BaseResource {
|
|
@@ -322,11 +322,11 @@ var Agent = class extends BaseResource {
|
|
|
322
322
|
voice;
|
|
323
323
|
/**
|
|
324
324
|
* Retrieves details about the agent
|
|
325
|
-
* @param
|
|
325
|
+
* @param requestContext - Optional request context to pass as query parameter
|
|
326
326
|
* @returns Promise containing agent details including model and instructions
|
|
327
327
|
*/
|
|
328
|
-
details(
|
|
329
|
-
return this.request(`/api/agents/${this.agentId}${
|
|
328
|
+
details(requestContext) {
|
|
329
|
+
return this.request(`/api/agents/${this.agentId}${requestContextQueryString(requestContext)}`);
|
|
330
330
|
}
|
|
331
331
|
enhanceInstructions(instructions, comment) {
|
|
332
332
|
return this.request(`/api/agents/${this.agentId}/instructions/enhance`, {
|
|
@@ -339,10 +339,10 @@ var Agent = class extends BaseResource {
|
|
|
339
339
|
...params,
|
|
340
340
|
output: params.output ? zodToJsonSchema(params.output) : void 0,
|
|
341
341
|
experimental_output: params.experimental_output ? zodToJsonSchema(params.experimental_output) : void 0,
|
|
342
|
-
|
|
342
|
+
requestContext: parseClientRequestContext(params.requestContext),
|
|
343
343
|
clientTools: processClientTools(params.clientTools)
|
|
344
344
|
};
|
|
345
|
-
const { runId, resourceId, threadId,
|
|
345
|
+
const { runId, resourceId, threadId, requestContext } = processedParams;
|
|
346
346
|
const response = await this.request(
|
|
347
347
|
`/api/agents/${this.agentId}/generate-legacy`,
|
|
348
348
|
{
|
|
@@ -364,7 +364,7 @@ var Agent = class extends BaseResource {
|
|
|
364
364
|
runId,
|
|
365
365
|
resourceId,
|
|
366
366
|
threadId,
|
|
367
|
-
|
|
367
|
+
requestContext,
|
|
368
368
|
tracingContext: { currentSpan: void 0 },
|
|
369
369
|
suspend: async () => {
|
|
370
370
|
}
|
|
@@ -409,14 +409,14 @@ var Agent = class extends BaseResource {
|
|
|
409
409
|
}
|
|
410
410
|
const processedParams = {
|
|
411
411
|
...params,
|
|
412
|
-
|
|
412
|
+
requestContext: parseClientRequestContext(params.requestContext),
|
|
413
413
|
clientTools: processClientTools(params.clientTools),
|
|
414
414
|
structuredOutput: params.structuredOutput ? {
|
|
415
415
|
...params.structuredOutput,
|
|
416
416
|
schema: zodToJsonSchema(params.structuredOutput.schema)
|
|
417
417
|
} : void 0
|
|
418
418
|
};
|
|
419
|
-
const { runId, resourceId, threadId,
|
|
419
|
+
const { runId, resourceId, threadId, requestContext } = processedParams;
|
|
420
420
|
const response = await this.request(
|
|
421
421
|
`/api/agents/${this.agentId}/generate`,
|
|
422
422
|
{
|
|
@@ -431,7 +431,7 @@ var Agent = class extends BaseResource {
|
|
|
431
431
|
runId,
|
|
432
432
|
resourceId,
|
|
433
433
|
threadId,
|
|
434
|
-
|
|
434
|
+
requestContext,
|
|
435
435
|
respondFn: this.generate.bind(this)
|
|
436
436
|
});
|
|
437
437
|
}
|
|
@@ -709,7 +709,7 @@ var Agent = class extends BaseResource {
|
|
|
709
709
|
...params,
|
|
710
710
|
output: params.output ? zodToJsonSchema(params.output) : void 0,
|
|
711
711
|
experimental_output: params.experimental_output ? zodToJsonSchema(params.experimental_output) : void 0,
|
|
712
|
-
|
|
712
|
+
requestContext: parseClientRequestContext(params.requestContext),
|
|
713
713
|
clientTools: processClientTools(params.clientTools)
|
|
714
714
|
};
|
|
715
715
|
const { readable, writable } = new TransformStream();
|
|
@@ -1054,7 +1054,7 @@ var Agent = class extends BaseResource {
|
|
|
1054
1054
|
runId: processedParams.runId,
|
|
1055
1055
|
resourceId: processedParams.resourceId,
|
|
1056
1056
|
threadId: processedParams.threadId,
|
|
1057
|
-
|
|
1057
|
+
requestContext: processedParams.requestContext,
|
|
1058
1058
|
// TODO: Pass proper tracing context when client-js supports tracing
|
|
1059
1059
|
tracingContext: { currentSpan: void 0 },
|
|
1060
1060
|
suspend: async () => {
|
|
@@ -1152,7 +1152,7 @@ var Agent = class extends BaseResource {
|
|
|
1152
1152
|
}
|
|
1153
1153
|
const processedParams = {
|
|
1154
1154
|
...params,
|
|
1155
|
-
|
|
1155
|
+
requestContext: parseClientRequestContext(params.requestContext),
|
|
1156
1156
|
clientTools: processClientTools(params.clientTools),
|
|
1157
1157
|
structuredOutput: params.structuredOutput ? {
|
|
1158
1158
|
...params.structuredOutput,
|
|
@@ -1258,7 +1258,7 @@ var Agent = class extends BaseResource {
|
|
|
1258
1258
|
runId: processedParams.runId,
|
|
1259
1259
|
resourceId: processedParams.resourceId,
|
|
1260
1260
|
threadId: processedParams.threadId,
|
|
1261
|
-
|
|
1261
|
+
requestContext: processedParams.requestContext,
|
|
1262
1262
|
// TODO: Pass proper tracing context when client-js supports tracing
|
|
1263
1263
|
tracingContext: { currentSpan: void 0 },
|
|
1264
1264
|
suspend: async () => {
|
|
@@ -1329,11 +1329,11 @@ var Agent = class extends BaseResource {
|
|
|
1329
1329
|
/**
|
|
1330
1330
|
* Gets details about a specific tool available to the agent
|
|
1331
1331
|
* @param toolId - ID of the tool to retrieve
|
|
1332
|
-
* @param
|
|
1332
|
+
* @param requestContext - Optional request context to pass as query parameter
|
|
1333
1333
|
* @returns Promise containing tool details
|
|
1334
1334
|
*/
|
|
1335
|
-
getTool(toolId,
|
|
1336
|
-
return this.request(`/api/agents/${this.agentId}/tools/${toolId}${
|
|
1335
|
+
getTool(toolId, requestContext) {
|
|
1336
|
+
return this.request(`/api/agents/${this.agentId}/tools/${toolId}${requestContextQueryString(requestContext)}`);
|
|
1337
1337
|
}
|
|
1338
1338
|
/**
|
|
1339
1339
|
* Executes a tool for the agent
|
|
@@ -1344,29 +1344,13 @@ var Agent = class extends BaseResource {
|
|
|
1344
1344
|
executeTool(toolId, params) {
|
|
1345
1345
|
const body = {
|
|
1346
1346
|
data: params.data,
|
|
1347
|
-
|
|
1347
|
+
requestContext: parseClientRequestContext(params.requestContext)
|
|
1348
1348
|
};
|
|
1349
1349
|
return this.request(`/api/agents/${this.agentId}/tools/${toolId}/execute`, {
|
|
1350
1350
|
method: "POST",
|
|
1351
1351
|
body
|
|
1352
1352
|
});
|
|
1353
1353
|
}
|
|
1354
|
-
/**
|
|
1355
|
-
* Retrieves evaluation results for the agent
|
|
1356
|
-
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
1357
|
-
* @returns Promise containing agent evaluations
|
|
1358
|
-
*/
|
|
1359
|
-
evals(runtimeContext) {
|
|
1360
|
-
return this.request(`/api/agents/${this.agentId}/evals/ci${runtimeContextQueryString(runtimeContext)}`);
|
|
1361
|
-
}
|
|
1362
|
-
/**
|
|
1363
|
-
* Retrieves live evaluation results for the agent
|
|
1364
|
-
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
1365
|
-
* @returns Promise containing live agent evaluations
|
|
1366
|
-
*/
|
|
1367
|
-
liveEvals(runtimeContext) {
|
|
1368
|
-
return this.request(`/api/agents/${this.agentId}/evals/live${runtimeContextQueryString(runtimeContext)}`);
|
|
1369
|
-
}
|
|
1370
1354
|
/**
|
|
1371
1355
|
* Updates the model for the agent
|
|
1372
1356
|
* @param params - Parameters for updating the model
|
|
@@ -1378,6 +1362,15 @@ var Agent = class extends BaseResource {
|
|
|
1378
1362
|
body: params
|
|
1379
1363
|
});
|
|
1380
1364
|
}
|
|
1365
|
+
/**
|
|
1366
|
+
* Resets the agent's model to the original model that was set during construction
|
|
1367
|
+
* @returns Promise containing a success message
|
|
1368
|
+
*/
|
|
1369
|
+
resetModel() {
|
|
1370
|
+
return this.request(`/api/agents/${this.agentId}/model/reset`, {
|
|
1371
|
+
method: "POST"
|
|
1372
|
+
});
|
|
1373
|
+
}
|
|
1381
1374
|
/**
|
|
1382
1375
|
* Updates the model for the agent in the model list
|
|
1383
1376
|
* @param params - Parameters for updating the model
|
|
@@ -1417,34 +1410,44 @@ var MemoryThread = class extends BaseResource {
|
|
|
1417
1410
|
}
|
|
1418
1411
|
/**
|
|
1419
1412
|
* Retrieves the memory thread details
|
|
1413
|
+
* @param requestContext - Optional request context to pass as query parameter
|
|
1420
1414
|
* @returns Promise containing thread details including title and metadata
|
|
1421
1415
|
*/
|
|
1422
|
-
get() {
|
|
1423
|
-
return this.request(
|
|
1416
|
+
get(requestContext) {
|
|
1417
|
+
return this.request(
|
|
1418
|
+
`/api/memory/threads/${this.threadId}?agentId=${this.agentId}${requestContextQueryString(requestContext, "&")}`
|
|
1419
|
+
);
|
|
1424
1420
|
}
|
|
1425
1421
|
/**
|
|
1426
1422
|
* Updates the memory thread properties
|
|
1427
|
-
* @param params - Update parameters including title and
|
|
1423
|
+
* @param params - Update parameters including title, metadata, and optional request context
|
|
1428
1424
|
* @returns Promise containing updated thread details
|
|
1429
1425
|
*/
|
|
1430
1426
|
update(params) {
|
|
1431
|
-
return this.request(
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1427
|
+
return this.request(
|
|
1428
|
+
`/api/memory/threads/${this.threadId}?agentId=${this.agentId}${requestContextQueryString(params.requestContext, "&")}`,
|
|
1429
|
+
{
|
|
1430
|
+
method: "PATCH",
|
|
1431
|
+
body: params
|
|
1432
|
+
}
|
|
1433
|
+
);
|
|
1435
1434
|
}
|
|
1436
1435
|
/**
|
|
1437
1436
|
* Deletes the memory thread
|
|
1437
|
+
* @param requestContext - Optional request context to pass as query parameter
|
|
1438
1438
|
* @returns Promise containing deletion result
|
|
1439
1439
|
*/
|
|
1440
|
-
delete() {
|
|
1441
|
-
return this.request(
|
|
1442
|
-
|
|
1443
|
-
|
|
1440
|
+
delete(requestContext) {
|
|
1441
|
+
return this.request(
|
|
1442
|
+
`/api/memory/threads/${this.threadId}?agentId=${this.agentId}${requestContextQueryString(requestContext, "&")}`,
|
|
1443
|
+
{
|
|
1444
|
+
method: "DELETE"
|
|
1445
|
+
}
|
|
1446
|
+
);
|
|
1444
1447
|
}
|
|
1445
1448
|
/**
|
|
1446
1449
|
* Retrieves messages associated with the thread
|
|
1447
|
-
* @param params - Optional parameters including limit for number of messages to retrieve
|
|
1450
|
+
* @param params - Optional parameters including limit for number of messages to retrieve and request context
|
|
1448
1451
|
* @returns Promise containing thread messages and UI messages
|
|
1449
1452
|
*/
|
|
1450
1453
|
getMessages(params) {
|
|
@@ -1452,37 +1455,46 @@ var MemoryThread = class extends BaseResource {
|
|
|
1452
1455
|
agentId: this.agentId,
|
|
1453
1456
|
...params?.limit ? { limit: params.limit.toString() } : {}
|
|
1454
1457
|
});
|
|
1455
|
-
return this.request(
|
|
1458
|
+
return this.request(
|
|
1459
|
+
`/api/memory/threads/${this.threadId}/messages?${query.toString()}${requestContextQueryString(params?.requestContext, "&")}`
|
|
1460
|
+
);
|
|
1456
1461
|
}
|
|
1457
1462
|
/**
|
|
1458
1463
|
* Retrieves paginated messages associated with the thread with advanced filtering and selection options
|
|
1459
|
-
* @param params - Pagination parameters including selectBy criteria, page, perPage, date ranges,
|
|
1464
|
+
* @param params - Pagination parameters including selectBy criteria, page, perPage, date ranges, message inclusion options, and request context
|
|
1460
1465
|
* @returns Promise containing paginated thread messages with pagination metadata (total, page, perPage, hasMore)
|
|
1461
1466
|
*/
|
|
1462
1467
|
getMessagesPaginated({
|
|
1463
1468
|
selectBy,
|
|
1469
|
+
requestContext,
|
|
1464
1470
|
...rest
|
|
1465
1471
|
}) {
|
|
1466
1472
|
const query = new URLSearchParams({
|
|
1467
1473
|
...rest,
|
|
1468
1474
|
...selectBy ? { selectBy: JSON.stringify(selectBy) } : {}
|
|
1469
1475
|
});
|
|
1470
|
-
return this.request(
|
|
1476
|
+
return this.request(
|
|
1477
|
+
`/api/memory/threads/${this.threadId}/messages/paginated?${query.toString()}${requestContextQueryString(requestContext, "&")}`
|
|
1478
|
+
);
|
|
1471
1479
|
}
|
|
1472
1480
|
/**
|
|
1473
1481
|
* Deletes one or more messages from the thread
|
|
1474
1482
|
* @param messageIds - Can be a single message ID (string), array of message IDs,
|
|
1475
1483
|
* message object with id property, or array of message objects
|
|
1484
|
+
* @param requestContext - Optional request context to pass as query parameter
|
|
1476
1485
|
* @returns Promise containing deletion result
|
|
1477
1486
|
*/
|
|
1478
|
-
deleteMessages(messageIds) {
|
|
1487
|
+
deleteMessages(messageIds, requestContext) {
|
|
1479
1488
|
const query = new URLSearchParams({
|
|
1480
1489
|
agentId: this.agentId
|
|
1481
1490
|
});
|
|
1482
|
-
return this.request(
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1491
|
+
return this.request(
|
|
1492
|
+
`/api/memory/messages/delete?${query.toString()}${requestContextQueryString(requestContext, "&")}`,
|
|
1493
|
+
{
|
|
1494
|
+
method: "POST",
|
|
1495
|
+
body: { messageIds }
|
|
1496
|
+
}
|
|
1497
|
+
);
|
|
1486
1498
|
}
|
|
1487
1499
|
};
|
|
1488
1500
|
|
|
@@ -1495,12 +1507,12 @@ var Vector = class extends BaseResource {
|
|
|
1495
1507
|
/**
|
|
1496
1508
|
* Retrieves details about a specific vector index
|
|
1497
1509
|
* @param indexName - Name of the index to get details for
|
|
1498
|
-
* @param
|
|
1510
|
+
* @param requestContext - Optional request context to pass as query parameter
|
|
1499
1511
|
* @returns Promise containing vector index details
|
|
1500
1512
|
*/
|
|
1501
|
-
details(indexName,
|
|
1513
|
+
details(indexName, requestContext) {
|
|
1502
1514
|
return this.request(
|
|
1503
|
-
`/api/vector/${this.vectorName}/indexes/${indexName}${
|
|
1515
|
+
`/api/vector/${this.vectorName}/indexes/${indexName}${requestContextQueryString(requestContext)}`
|
|
1504
1516
|
);
|
|
1505
1517
|
}
|
|
1506
1518
|
/**
|
|
@@ -1515,11 +1527,11 @@ var Vector = class extends BaseResource {
|
|
|
1515
1527
|
}
|
|
1516
1528
|
/**
|
|
1517
1529
|
* Retrieves a list of all available indexes
|
|
1518
|
-
* @param
|
|
1530
|
+
* @param requestContext - Optional request context to pass as query parameter
|
|
1519
1531
|
* @returns Promise containing array of index names
|
|
1520
1532
|
*/
|
|
1521
|
-
getIndexes(
|
|
1522
|
-
return this.request(`/api/vector/${this.vectorName}/indexes${
|
|
1533
|
+
getIndexes(requestContext) {
|
|
1534
|
+
return this.request(`/api/vector/${this.vectorName}/indexes${requestContextQueryString(requestContext)}`);
|
|
1523
1535
|
}
|
|
1524
1536
|
/**
|
|
1525
1537
|
* Creates a new vector index
|
|
@@ -1564,11 +1576,11 @@ var Tool = class extends BaseResource {
|
|
|
1564
1576
|
}
|
|
1565
1577
|
/**
|
|
1566
1578
|
* Retrieves details about the tool
|
|
1567
|
-
* @param
|
|
1579
|
+
* @param requestContext - Optional request context to pass as query parameter
|
|
1568
1580
|
* @returns Promise containing tool details including description and schemas
|
|
1569
1581
|
*/
|
|
1570
|
-
details(
|
|
1571
|
-
return this.request(`/api/tools/${this.toolId}${
|
|
1582
|
+
details(requestContext) {
|
|
1583
|
+
return this.request(`/api/tools/${this.toolId}${requestContextQueryString(requestContext)}`);
|
|
1572
1584
|
}
|
|
1573
1585
|
/**
|
|
1574
1586
|
* Executes the tool with the provided parameters
|
|
@@ -1582,7 +1594,7 @@ var Tool = class extends BaseResource {
|
|
|
1582
1594
|
}
|
|
1583
1595
|
const body = {
|
|
1584
1596
|
data: params.data,
|
|
1585
|
-
|
|
1597
|
+
requestContext: parseClientRequestContext(params.requestContext)
|
|
1586
1598
|
};
|
|
1587
1599
|
return this.request(`/api/tools/${this.toolId}/execute?${url.toString()}`, {
|
|
1588
1600
|
method: "POST",
|
|
@@ -1645,20 +1657,20 @@ var Workflow = class extends BaseResource {
|
|
|
1645
1657
|
}
|
|
1646
1658
|
/**
|
|
1647
1659
|
* Retrieves details about the workflow
|
|
1648
|
-
* @param
|
|
1660
|
+
* @param requestContext - Optional request context to pass as query parameter
|
|
1649
1661
|
* @returns Promise containing workflow details including steps and graphs
|
|
1650
1662
|
*/
|
|
1651
|
-
details(
|
|
1652
|
-
return this.request(`/api/workflows/${this.workflowId}${
|
|
1663
|
+
details(requestContext) {
|
|
1664
|
+
return this.request(`/api/workflows/${this.workflowId}${requestContextQueryString(requestContext)}`);
|
|
1653
1665
|
}
|
|
1654
1666
|
/**
|
|
1655
1667
|
* Retrieves all runs for a workflow
|
|
1656
1668
|
* @param params - Parameters for filtering runs
|
|
1657
|
-
* @param
|
|
1669
|
+
* @param requestContext - Optional request context to pass as query parameter
|
|
1658
1670
|
* @returns Promise containing workflow runs array
|
|
1659
1671
|
*/
|
|
1660
|
-
runs(params,
|
|
1661
|
-
const
|
|
1672
|
+
runs(params, requestContext) {
|
|
1673
|
+
const requestContextParam = base64RequestContext(parseClientRequestContext(requestContext));
|
|
1662
1674
|
const searchParams = new URLSearchParams();
|
|
1663
1675
|
if (params?.fromDate) {
|
|
1664
1676
|
searchParams.set("fromDate", params.fromDate.toISOString());
|
|
@@ -1675,8 +1687,8 @@ var Workflow = class extends BaseResource {
|
|
|
1675
1687
|
if (params?.resourceId) {
|
|
1676
1688
|
searchParams.set("resourceId", params.resourceId);
|
|
1677
1689
|
}
|
|
1678
|
-
if (
|
|
1679
|
-
searchParams.set("
|
|
1690
|
+
if (requestContextParam) {
|
|
1691
|
+
searchParams.set("requestContext", requestContextParam);
|
|
1680
1692
|
}
|
|
1681
1693
|
if (searchParams.size) {
|
|
1682
1694
|
return this.request(`/api/workflows/${this.workflowId}/runs?${searchParams}`);
|
|
@@ -1687,21 +1699,21 @@ var Workflow = class extends BaseResource {
|
|
|
1687
1699
|
/**
|
|
1688
1700
|
* Retrieves a specific workflow run by its ID
|
|
1689
1701
|
* @param runId - The ID of the workflow run to retrieve
|
|
1690
|
-
* @param
|
|
1702
|
+
* @param requestContext - Optional request context to pass as query parameter
|
|
1691
1703
|
* @returns Promise containing the workflow run details
|
|
1692
1704
|
*/
|
|
1693
|
-
runById(runId,
|
|
1694
|
-
return this.request(`/api/workflows/${this.workflowId}/runs/${runId}${
|
|
1705
|
+
runById(runId, requestContext) {
|
|
1706
|
+
return this.request(`/api/workflows/${this.workflowId}/runs/${runId}${requestContextQueryString(requestContext)}`);
|
|
1695
1707
|
}
|
|
1696
1708
|
/**
|
|
1697
1709
|
* Retrieves the execution result for a specific workflow run by its ID
|
|
1698
1710
|
* @param runId - The ID of the workflow run to retrieve the execution result for
|
|
1699
|
-
* @param
|
|
1711
|
+
* @param requestContext - Optional request context to pass as query parameter
|
|
1700
1712
|
* @returns Promise containing the workflow run execution result
|
|
1701
1713
|
*/
|
|
1702
|
-
runExecutionResult(runId,
|
|
1714
|
+
runExecutionResult(runId, requestContext) {
|
|
1703
1715
|
return this.request(
|
|
1704
|
-
`/api/workflows/${this.workflowId}/runs/${runId}/execution-result${
|
|
1716
|
+
`/api/workflows/${this.workflowId}/runs/${runId}/execution-result${requestContextQueryString(requestContext)}`
|
|
1705
1717
|
);
|
|
1706
1718
|
}
|
|
1707
1719
|
/**
|
|
@@ -1757,7 +1769,7 @@ var Workflow = class extends BaseResource {
|
|
|
1757
1769
|
return this.start({
|
|
1758
1770
|
runId,
|
|
1759
1771
|
inputData: p.inputData,
|
|
1760
|
-
|
|
1772
|
+
requestContext: p.requestContext,
|
|
1761
1773
|
tracingOptions: p.tracingOptions
|
|
1762
1774
|
});
|
|
1763
1775
|
},
|
|
@@ -1765,7 +1777,7 @@ var Workflow = class extends BaseResource {
|
|
|
1765
1777
|
return this.startAsync({
|
|
1766
1778
|
runId,
|
|
1767
1779
|
inputData: p.inputData,
|
|
1768
|
-
|
|
1780
|
+
requestContext: p.requestContext,
|
|
1769
1781
|
tracingOptions: p.tracingOptions
|
|
1770
1782
|
});
|
|
1771
1783
|
},
|
|
@@ -1773,14 +1785,14 @@ var Workflow = class extends BaseResource {
|
|
|
1773
1785
|
return this.watch({ runId }, onRecord);
|
|
1774
1786
|
},
|
|
1775
1787
|
stream: async (p) => {
|
|
1776
|
-
return this.stream({ runId, inputData: p.inputData,
|
|
1788
|
+
return this.stream({ runId, inputData: p.inputData, requestContext: p.requestContext });
|
|
1777
1789
|
},
|
|
1778
1790
|
resume: async (p) => {
|
|
1779
1791
|
return this.resume({
|
|
1780
1792
|
runId,
|
|
1781
1793
|
step: p.step,
|
|
1782
1794
|
resumeData: p.resumeData,
|
|
1783
|
-
|
|
1795
|
+
requestContext: p.requestContext,
|
|
1784
1796
|
tracingOptions: p.tracingOptions
|
|
1785
1797
|
});
|
|
1786
1798
|
},
|
|
@@ -1789,7 +1801,7 @@ var Workflow = class extends BaseResource {
|
|
|
1789
1801
|
runId,
|
|
1790
1802
|
step: p.step,
|
|
1791
1803
|
resumeData: p.resumeData,
|
|
1792
|
-
|
|
1804
|
+
requestContext: p.requestContext,
|
|
1793
1805
|
tracingOptions: p.tracingOptions
|
|
1794
1806
|
});
|
|
1795
1807
|
},
|
|
@@ -1798,26 +1810,26 @@ var Workflow = class extends BaseResource {
|
|
|
1798
1810
|
runId,
|
|
1799
1811
|
step: p.step,
|
|
1800
1812
|
resumeData: p.resumeData,
|
|
1801
|
-
|
|
1813
|
+
requestContext: p.requestContext
|
|
1802
1814
|
});
|
|
1803
1815
|
}
|
|
1804
1816
|
};
|
|
1805
1817
|
}
|
|
1806
1818
|
/**
|
|
1807
1819
|
* Starts a workflow run synchronously without waiting for the workflow to complete
|
|
1808
|
-
* @param params - Object containing the runId, inputData and
|
|
1820
|
+
* @param params - Object containing the runId, inputData and requestContext
|
|
1809
1821
|
* @returns Promise containing success message
|
|
1810
1822
|
*/
|
|
1811
1823
|
start(params) {
|
|
1812
|
-
const
|
|
1824
|
+
const requestContext = parseClientRequestContext(params.requestContext);
|
|
1813
1825
|
return this.request(`/api/workflows/${this.workflowId}/start?runId=${params.runId}`, {
|
|
1814
1826
|
method: "POST",
|
|
1815
|
-
body: { inputData: params?.inputData,
|
|
1827
|
+
body: { inputData: params?.inputData, requestContext, tracingOptions: params.tracingOptions }
|
|
1816
1828
|
});
|
|
1817
1829
|
}
|
|
1818
1830
|
/**
|
|
1819
1831
|
* Resumes a suspended workflow step synchronously without waiting for the workflow to complete
|
|
1820
|
-
* @param params - Object containing the runId, step, resumeData and
|
|
1832
|
+
* @param params - Object containing the runId, step, resumeData and requestContext
|
|
1821
1833
|
* @returns Promise containing success message
|
|
1822
1834
|
*/
|
|
1823
1835
|
resume({
|
|
@@ -1827,20 +1839,20 @@ var Workflow = class extends BaseResource {
|
|
|
1827
1839
|
tracingOptions,
|
|
1828
1840
|
...rest
|
|
1829
1841
|
}) {
|
|
1830
|
-
const
|
|
1842
|
+
const requestContext = parseClientRequestContext(rest.requestContext);
|
|
1831
1843
|
return this.request(`/api/workflows/${this.workflowId}/resume?runId=${runId}`, {
|
|
1832
1844
|
method: "POST",
|
|
1833
1845
|
body: {
|
|
1834
1846
|
step,
|
|
1835
1847
|
resumeData,
|
|
1836
|
-
|
|
1848
|
+
requestContext,
|
|
1837
1849
|
tracingOptions
|
|
1838
1850
|
}
|
|
1839
1851
|
});
|
|
1840
1852
|
}
|
|
1841
1853
|
/**
|
|
1842
1854
|
* Starts a workflow run asynchronously and returns a promise that resolves when the workflow is complete
|
|
1843
|
-
* @param params - Object containing the optional runId, inputData and
|
|
1855
|
+
* @param params - Object containing the optional runId, inputData and requestContext
|
|
1844
1856
|
* @returns Promise containing the workflow execution results
|
|
1845
1857
|
*/
|
|
1846
1858
|
startAsync(params) {
|
|
@@ -1848,15 +1860,15 @@ var Workflow = class extends BaseResource {
|
|
|
1848
1860
|
if (!!params?.runId) {
|
|
1849
1861
|
searchParams.set("runId", params.runId);
|
|
1850
1862
|
}
|
|
1851
|
-
const
|
|
1863
|
+
const requestContext = parseClientRequestContext(params.requestContext);
|
|
1852
1864
|
return this.request(`/api/workflows/${this.workflowId}/start-async?${searchParams.toString()}`, {
|
|
1853
1865
|
method: "POST",
|
|
1854
|
-
body: { inputData: params.inputData,
|
|
1866
|
+
body: { inputData: params.inputData, requestContext, tracingOptions: params.tracingOptions }
|
|
1855
1867
|
});
|
|
1856
1868
|
}
|
|
1857
1869
|
/**
|
|
1858
1870
|
* Starts a workflow run and returns a stream
|
|
1859
|
-
* @param params - Object containing the optional runId, inputData and
|
|
1871
|
+
* @param params - Object containing the optional runId, inputData and requestContext
|
|
1860
1872
|
* @returns Promise containing the workflow execution results
|
|
1861
1873
|
*/
|
|
1862
1874
|
async stream(params) {
|
|
@@ -1864,12 +1876,12 @@ var Workflow = class extends BaseResource {
|
|
|
1864
1876
|
if (!!params?.runId) {
|
|
1865
1877
|
searchParams.set("runId", params.runId);
|
|
1866
1878
|
}
|
|
1867
|
-
const
|
|
1879
|
+
const requestContext = parseClientRequestContext(params.requestContext);
|
|
1868
1880
|
const response = await this.request(
|
|
1869
1881
|
`/api/workflows/${this.workflowId}/stream?${searchParams.toString()}`,
|
|
1870
1882
|
{
|
|
1871
1883
|
method: "POST",
|
|
1872
|
-
body: { inputData: params.inputData,
|
|
1884
|
+
body: { inputData: params.inputData, requestContext, tracingOptions: params.tracingOptions },
|
|
1873
1885
|
stream: true
|
|
1874
1886
|
}
|
|
1875
1887
|
);
|
|
@@ -1954,7 +1966,7 @@ var Workflow = class extends BaseResource {
|
|
|
1954
1966
|
}
|
|
1955
1967
|
/**
|
|
1956
1968
|
* Starts a workflow run and returns a stream
|
|
1957
|
-
* @param params - Object containing the optional runId, inputData and
|
|
1969
|
+
* @param params - Object containing the optional runId, inputData and requestContext
|
|
1958
1970
|
* @returns Promise containing the workflow execution results
|
|
1959
1971
|
*/
|
|
1960
1972
|
async streamVNext(params) {
|
|
@@ -1962,14 +1974,14 @@ var Workflow = class extends BaseResource {
|
|
|
1962
1974
|
if (!!params?.runId) {
|
|
1963
1975
|
searchParams.set("runId", params.runId);
|
|
1964
1976
|
}
|
|
1965
|
-
const
|
|
1977
|
+
const requestContext = parseClientRequestContext(params.requestContext);
|
|
1966
1978
|
const response = await this.request(
|
|
1967
1979
|
`/api/workflows/${this.workflowId}/streamVNext?${searchParams.toString()}`,
|
|
1968
1980
|
{
|
|
1969
1981
|
method: "POST",
|
|
1970
1982
|
body: {
|
|
1971
1983
|
inputData: params.inputData,
|
|
1972
|
-
|
|
1984
|
+
requestContext,
|
|
1973
1985
|
closeOnSuspend: params.closeOnSuspend,
|
|
1974
1986
|
tracingOptions: params.tracingOptions
|
|
1975
1987
|
},
|
|
@@ -2057,30 +2069,30 @@ var Workflow = class extends BaseResource {
|
|
|
2057
2069
|
}
|
|
2058
2070
|
/**
|
|
2059
2071
|
* Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
|
|
2060
|
-
* @param params - Object containing the runId, step, resumeData and
|
|
2072
|
+
* @param params - Object containing the runId, step, resumeData and requestContext
|
|
2061
2073
|
* @returns Promise containing the workflow resume results
|
|
2062
2074
|
*/
|
|
2063
2075
|
resumeAsync(params) {
|
|
2064
|
-
const
|
|
2076
|
+
const requestContext = parseClientRequestContext(params.requestContext);
|
|
2065
2077
|
return this.request(`/api/workflows/${this.workflowId}/resume-async?runId=${params.runId}`, {
|
|
2066
2078
|
method: "POST",
|
|
2067
2079
|
body: {
|
|
2068
2080
|
step: params.step,
|
|
2069
2081
|
resumeData: params.resumeData,
|
|
2070
|
-
|
|
2082
|
+
requestContext,
|
|
2071
2083
|
tracingOptions: params.tracingOptions
|
|
2072
2084
|
}
|
|
2073
2085
|
});
|
|
2074
2086
|
}
|
|
2075
2087
|
/**
|
|
2076
2088
|
* Resumes a suspended workflow step that uses streamVNext asynchronously and returns a promise that resolves when the workflow is complete
|
|
2077
|
-
* @param params - Object containing the runId, step, resumeData and
|
|
2089
|
+
* @param params - Object containing the runId, step, resumeData and requestContext
|
|
2078
2090
|
* @returns Promise containing the workflow resume results
|
|
2079
2091
|
*/
|
|
2080
2092
|
async resumeStreamVNext(params) {
|
|
2081
2093
|
const searchParams = new URLSearchParams();
|
|
2082
2094
|
searchParams.set("runId", params.runId);
|
|
2083
|
-
const
|
|
2095
|
+
const requestContext = parseClientRequestContext(params.requestContext);
|
|
2084
2096
|
const response = await this.request(
|
|
2085
2097
|
`/api/workflows/${this.workflowId}/resume-stream?${searchParams.toString()}`,
|
|
2086
2098
|
{
|
|
@@ -2088,7 +2100,7 @@ var Workflow = class extends BaseResource {
|
|
|
2088
2100
|
body: {
|
|
2089
2101
|
step: params.step,
|
|
2090
2102
|
resumeData: params.resumeData,
|
|
2091
|
-
|
|
2103
|
+
requestContext,
|
|
2092
2104
|
tracingOptions: params.tracingOptions
|
|
2093
2105
|
},
|
|
2094
2106
|
stream: true
|
|
@@ -2260,22 +2272,22 @@ var MCPTool = class extends BaseResource {
|
|
|
2260
2272
|
}
|
|
2261
2273
|
/**
|
|
2262
2274
|
* Retrieves details about this specific tool from the MCP server.
|
|
2263
|
-
* @param
|
|
2275
|
+
* @param requestContext - Optional request context to pass as query parameter
|
|
2264
2276
|
* @returns Promise containing the tool's information (name, description, schema).
|
|
2265
2277
|
*/
|
|
2266
|
-
details(
|
|
2267
|
-
return this.request(`/api/mcp/${this.serverId}/tools/${this.toolId}${
|
|
2278
|
+
details(requestContext) {
|
|
2279
|
+
return this.request(`/api/mcp/${this.serverId}/tools/${this.toolId}${requestContextQueryString(requestContext)}`);
|
|
2268
2280
|
}
|
|
2269
2281
|
/**
|
|
2270
2282
|
* Executes this specific tool on the MCP server.
|
|
2271
|
-
* @param params - Parameters for tool execution, including data/args and optional
|
|
2283
|
+
* @param params - Parameters for tool execution, including data/args and optional requestContext.
|
|
2272
2284
|
* @returns Promise containing the result of the tool execution.
|
|
2273
2285
|
*/
|
|
2274
2286
|
execute(params) {
|
|
2275
2287
|
const body = {};
|
|
2276
2288
|
if (params.data !== void 0) body.data = params.data;
|
|
2277
|
-
if (params.
|
|
2278
|
-
body.
|
|
2289
|
+
if (params.requestContext !== void 0) {
|
|
2290
|
+
body.requestContext = params.requestContext;
|
|
2279
2291
|
}
|
|
2280
2292
|
return this.request(`/api/mcp/${this.serverId}/tools/${this.toolId}/execute`, {
|
|
2281
2293
|
method: "POST",
|
|
@@ -2320,6 +2332,35 @@ var AgentBuilder = class extends BaseResource {
|
|
|
2320
2332
|
};
|
|
2321
2333
|
}
|
|
2322
2334
|
}
|
|
2335
|
+
/**
|
|
2336
|
+
* Creates a transform stream that parses binary chunks into JSON records.
|
|
2337
|
+
*/
|
|
2338
|
+
createRecordParserTransform() {
|
|
2339
|
+
let failedChunk = void 0;
|
|
2340
|
+
return new TransformStream({
|
|
2341
|
+
start() {
|
|
2342
|
+
},
|
|
2343
|
+
async transform(chunk, controller) {
|
|
2344
|
+
try {
|
|
2345
|
+
const decoded = new TextDecoder().decode(chunk);
|
|
2346
|
+
const chunks = decoded.split(RECORD_SEPARATOR2);
|
|
2347
|
+
for (const chunk2 of chunks) {
|
|
2348
|
+
if (chunk2) {
|
|
2349
|
+
const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
|
|
2350
|
+
try {
|
|
2351
|
+
const parsedChunk = JSON.parse(newChunk);
|
|
2352
|
+
controller.enqueue(parsedChunk);
|
|
2353
|
+
failedChunk = void 0;
|
|
2354
|
+
} catch {
|
|
2355
|
+
failedChunk = newChunk;
|
|
2356
|
+
}
|
|
2357
|
+
}
|
|
2358
|
+
}
|
|
2359
|
+
} catch {
|
|
2360
|
+
}
|
|
2361
|
+
}
|
|
2362
|
+
});
|
|
2363
|
+
}
|
|
2323
2364
|
/**
|
|
2324
2365
|
* @deprecated Use createRunAsync() instead.
|
|
2325
2366
|
* @throws {Error} Always throws an error directing users to use createRunAsync()
|
|
@@ -2352,12 +2393,12 @@ var AgentBuilder = class extends BaseResource {
|
|
|
2352
2393
|
if (runId) {
|
|
2353
2394
|
searchParams.set("runId", runId);
|
|
2354
2395
|
}
|
|
2355
|
-
const
|
|
2356
|
-
const {
|
|
2396
|
+
const requestContext = parseClientRequestContext(params.requestContext);
|
|
2397
|
+
const { requestContext: _, ...actionParams } = params;
|
|
2357
2398
|
const url = `/api/agent-builder/${this.actionId}/start-async${searchParams.toString() ? `?${searchParams.toString()}` : ""}`;
|
|
2358
2399
|
const result = await this.request(url, {
|
|
2359
2400
|
method: "POST",
|
|
2360
|
-
body: { ...actionParams,
|
|
2401
|
+
body: { ...actionParams, requestContext }
|
|
2361
2402
|
});
|
|
2362
2403
|
return this.transformWorkflowResult(result);
|
|
2363
2404
|
}
|
|
@@ -2368,12 +2409,12 @@ var AgentBuilder = class extends BaseResource {
|
|
|
2368
2409
|
async startActionRun(params, runId) {
|
|
2369
2410
|
const searchParams = new URLSearchParams();
|
|
2370
2411
|
searchParams.set("runId", runId);
|
|
2371
|
-
const
|
|
2372
|
-
const {
|
|
2412
|
+
const requestContext = parseClientRequestContext(params.requestContext);
|
|
2413
|
+
const { requestContext: _, ...actionParams } = params;
|
|
2373
2414
|
const url = `/api/agent-builder/${this.actionId}/start?${searchParams.toString()}`;
|
|
2374
2415
|
return this.request(url, {
|
|
2375
2416
|
method: "POST",
|
|
2376
|
-
body: { ...actionParams,
|
|
2417
|
+
body: { ...actionParams, requestContext }
|
|
2377
2418
|
});
|
|
2378
2419
|
}
|
|
2379
2420
|
/**
|
|
@@ -2383,12 +2424,12 @@ var AgentBuilder = class extends BaseResource {
|
|
|
2383
2424
|
async resume(params, runId) {
|
|
2384
2425
|
const searchParams = new URLSearchParams();
|
|
2385
2426
|
searchParams.set("runId", runId);
|
|
2386
|
-
const
|
|
2387
|
-
const {
|
|
2427
|
+
const requestContext = parseClientRequestContext(params.requestContext);
|
|
2428
|
+
const { requestContext: _, ...resumeParams } = params;
|
|
2388
2429
|
const url = `/api/agent-builder/${this.actionId}/resume?${searchParams.toString()}`;
|
|
2389
2430
|
return this.request(url, {
|
|
2390
2431
|
method: "POST",
|
|
2391
|
-
body: { ...resumeParams,
|
|
2432
|
+
body: { ...resumeParams, requestContext }
|
|
2392
2433
|
});
|
|
2393
2434
|
}
|
|
2394
2435
|
/**
|
|
@@ -2398,12 +2439,12 @@ var AgentBuilder = class extends BaseResource {
|
|
|
2398
2439
|
async resumeAsync(params, runId) {
|
|
2399
2440
|
const searchParams = new URLSearchParams();
|
|
2400
2441
|
searchParams.set("runId", runId);
|
|
2401
|
-
const
|
|
2402
|
-
const {
|
|
2442
|
+
const requestContext = parseClientRequestContext(params.requestContext);
|
|
2443
|
+
const { requestContext: _, ...resumeParams } = params;
|
|
2403
2444
|
const url = `/api/agent-builder/${this.actionId}/resume-async?${searchParams.toString()}`;
|
|
2404
2445
|
const result = await this.request(url, {
|
|
2405
2446
|
method: "POST",
|
|
2406
|
-
body: { ...resumeParams,
|
|
2447
|
+
body: { ...resumeParams, requestContext }
|
|
2407
2448
|
});
|
|
2408
2449
|
return this.transformWorkflowResult(result);
|
|
2409
2450
|
}
|
|
@@ -2461,12 +2502,12 @@ var AgentBuilder = class extends BaseResource {
|
|
|
2461
2502
|
if (runId) {
|
|
2462
2503
|
searchParams.set("runId", runId);
|
|
2463
2504
|
}
|
|
2464
|
-
const
|
|
2465
|
-
const {
|
|
2505
|
+
const requestContext = parseClientRequestContext(params.requestContext);
|
|
2506
|
+
const { requestContext: _, ...actionParams } = params;
|
|
2466
2507
|
const url = `/api/agent-builder/${this.actionId}/stream${searchParams.toString() ? `?${searchParams.toString()}` : ""}`;
|
|
2467
2508
|
const response = await this.request(url, {
|
|
2468
2509
|
method: "POST",
|
|
2469
|
-
body: { ...actionParams,
|
|
2510
|
+
body: { ...actionParams, requestContext },
|
|
2470
2511
|
stream: true
|
|
2471
2512
|
});
|
|
2472
2513
|
if (!response.ok) {
|
|
@@ -2475,31 +2516,7 @@ var AgentBuilder = class extends BaseResource {
|
|
|
2475
2516
|
if (!response.body) {
|
|
2476
2517
|
throw new Error("Response body is null");
|
|
2477
2518
|
}
|
|
2478
|
-
|
|
2479
|
-
const transformStream = new TransformStream({
|
|
2480
|
-
start() {
|
|
2481
|
-
},
|
|
2482
|
-
async transform(chunk, controller) {
|
|
2483
|
-
try {
|
|
2484
|
-
const decoded = new TextDecoder().decode(chunk);
|
|
2485
|
-
const chunks = decoded.split(RECORD_SEPARATOR2);
|
|
2486
|
-
for (const chunk2 of chunks) {
|
|
2487
|
-
if (chunk2) {
|
|
2488
|
-
const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
|
|
2489
|
-
try {
|
|
2490
|
-
const parsedChunk = JSON.parse(newChunk);
|
|
2491
|
-
controller.enqueue(parsedChunk);
|
|
2492
|
-
failedChunk = void 0;
|
|
2493
|
-
} catch {
|
|
2494
|
-
failedChunk = newChunk;
|
|
2495
|
-
}
|
|
2496
|
-
}
|
|
2497
|
-
}
|
|
2498
|
-
} catch {
|
|
2499
|
-
}
|
|
2500
|
-
}
|
|
2501
|
-
});
|
|
2502
|
-
return response.body.pipeThrough(transformStream);
|
|
2519
|
+
return response.body.pipeThrough(this.createRecordParserTransform());
|
|
2503
2520
|
}
|
|
2504
2521
|
/**
|
|
2505
2522
|
* Streams agent builder action progress in real-time using VNext streaming.
|
|
@@ -2510,12 +2527,12 @@ var AgentBuilder = class extends BaseResource {
|
|
|
2510
2527
|
if (runId) {
|
|
2511
2528
|
searchParams.set("runId", runId);
|
|
2512
2529
|
}
|
|
2513
|
-
const
|
|
2514
|
-
const {
|
|
2530
|
+
const requestContext = parseClientRequestContext(params.requestContext);
|
|
2531
|
+
const { requestContext: _, ...actionParams } = params;
|
|
2515
2532
|
const url = `/api/agent-builder/${this.actionId}/streamVNext${searchParams.toString() ? `?${searchParams.toString()}` : ""}`;
|
|
2516
2533
|
const response = await this.request(url, {
|
|
2517
2534
|
method: "POST",
|
|
2518
|
-
body: { ...actionParams,
|
|
2535
|
+
body: { ...actionParams, requestContext },
|
|
2519
2536
|
stream: true
|
|
2520
2537
|
});
|
|
2521
2538
|
if (!response.ok) {
|
|
@@ -2524,31 +2541,7 @@ var AgentBuilder = class extends BaseResource {
|
|
|
2524
2541
|
if (!response.body) {
|
|
2525
2542
|
throw new Error("Response body is null");
|
|
2526
2543
|
}
|
|
2527
|
-
|
|
2528
|
-
const transformStream = new TransformStream({
|
|
2529
|
-
start() {
|
|
2530
|
-
},
|
|
2531
|
-
async transform(chunk, controller) {
|
|
2532
|
-
try {
|
|
2533
|
-
const decoded = new TextDecoder().decode(chunk);
|
|
2534
|
-
const chunks = decoded.split(RECORD_SEPARATOR2);
|
|
2535
|
-
for (const chunk2 of chunks) {
|
|
2536
|
-
if (chunk2) {
|
|
2537
|
-
const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
|
|
2538
|
-
try {
|
|
2539
|
-
const parsedChunk = JSON.parse(newChunk);
|
|
2540
|
-
controller.enqueue(parsedChunk);
|
|
2541
|
-
failedChunk = void 0;
|
|
2542
|
-
} catch {
|
|
2543
|
-
failedChunk = newChunk;
|
|
2544
|
-
}
|
|
2545
|
-
}
|
|
2546
|
-
}
|
|
2547
|
-
} catch {
|
|
2548
|
-
}
|
|
2549
|
-
}
|
|
2550
|
-
});
|
|
2551
|
-
return response.body.pipeThrough(transformStream);
|
|
2544
|
+
return response.body.pipeThrough(this.createRecordParserTransform());
|
|
2552
2545
|
}
|
|
2553
2546
|
/**
|
|
2554
2547
|
* Watches an existing agent builder action run by runId.
|
|
@@ -2576,6 +2569,93 @@ var AgentBuilder = class extends BaseResource {
|
|
|
2576
2569
|
}
|
|
2577
2570
|
}
|
|
2578
2571
|
}
|
|
2572
|
+
/**
|
|
2573
|
+
* Observes an existing agent builder action run stream.
|
|
2574
|
+
* Replays cached execution from the beginning, then continues with live stream.
|
|
2575
|
+
* This is the recommended method for recovery after page refresh/hot reload.
|
|
2576
|
+
* This calls `/api/agent-builder/:actionId/observe` (which delegates to observeStreamVNext).
|
|
2577
|
+
*/
|
|
2578
|
+
async observeStream(params) {
|
|
2579
|
+
const searchParams = new URLSearchParams();
|
|
2580
|
+
searchParams.set("runId", params.runId);
|
|
2581
|
+
const url = `/api/agent-builder/${this.actionId}/observe?${searchParams.toString()}`;
|
|
2582
|
+
const response = await this.request(url, {
|
|
2583
|
+
method: "POST",
|
|
2584
|
+
stream: true
|
|
2585
|
+
});
|
|
2586
|
+
if (!response.ok) {
|
|
2587
|
+
throw new Error(`Failed to observe agent builder action stream: ${response.statusText}`);
|
|
2588
|
+
}
|
|
2589
|
+
if (!response.body) {
|
|
2590
|
+
throw new Error("Response body is null");
|
|
2591
|
+
}
|
|
2592
|
+
return response.body.pipeThrough(this.createRecordParserTransform());
|
|
2593
|
+
}
|
|
2594
|
+
/**
|
|
2595
|
+
* Observes an existing agent builder action run stream using VNext streaming API.
|
|
2596
|
+
* Replays cached execution from the beginning, then continues with live stream.
|
|
2597
|
+
* This calls `/api/agent-builder/:actionId/observe-streamVNext`.
|
|
2598
|
+
*/
|
|
2599
|
+
async observeStreamVNext(params) {
|
|
2600
|
+
const searchParams = new URLSearchParams();
|
|
2601
|
+
searchParams.set("runId", params.runId);
|
|
2602
|
+
const url = `/api/agent-builder/${this.actionId}/observe-streamVNext?${searchParams.toString()}`;
|
|
2603
|
+
const response = await this.request(url, {
|
|
2604
|
+
method: "POST",
|
|
2605
|
+
stream: true
|
|
2606
|
+
});
|
|
2607
|
+
if (!response.ok) {
|
|
2608
|
+
throw new Error(`Failed to observe agent builder action stream VNext: ${response.statusText}`);
|
|
2609
|
+
}
|
|
2610
|
+
if (!response.body) {
|
|
2611
|
+
throw new Error("Response body is null");
|
|
2612
|
+
}
|
|
2613
|
+
return response.body.pipeThrough(this.createRecordParserTransform());
|
|
2614
|
+
}
|
|
2615
|
+
/**
|
|
2616
|
+
* Observes an existing agent builder action run stream using legacy streaming API.
|
|
2617
|
+
* Replays cached execution from the beginning, then continues with live stream.
|
|
2618
|
+
* This calls `/api/agent-builder/:actionId/observe-stream-legacy`.
|
|
2619
|
+
*/
|
|
2620
|
+
async observeStreamLegacy(params) {
|
|
2621
|
+
const searchParams = new URLSearchParams();
|
|
2622
|
+
searchParams.set("runId", params.runId);
|
|
2623
|
+
const url = `/api/agent-builder/${this.actionId}/observe-stream-legacy?${searchParams.toString()}`;
|
|
2624
|
+
const response = await this.request(url, {
|
|
2625
|
+
method: "POST",
|
|
2626
|
+
stream: true
|
|
2627
|
+
});
|
|
2628
|
+
if (!response.ok) {
|
|
2629
|
+
throw new Error(`Failed to observe agent builder action stream legacy: ${response.statusText}`);
|
|
2630
|
+
}
|
|
2631
|
+
if (!response.body) {
|
|
2632
|
+
throw new Error("Response body is null");
|
|
2633
|
+
}
|
|
2634
|
+
return response.body.pipeThrough(this.createRecordParserTransform());
|
|
2635
|
+
}
|
|
2636
|
+
/**
|
|
2637
|
+
* Resumes a suspended agent builder action and streams the results.
|
|
2638
|
+
* This calls `/api/agent-builder/:actionId/resume-stream`.
|
|
2639
|
+
*/
|
|
2640
|
+
async resumeStream(params) {
|
|
2641
|
+
const searchParams = new URLSearchParams();
|
|
2642
|
+
searchParams.set("runId", params.runId);
|
|
2643
|
+
const requestContext = parseClientRequestContext(params.requestContext);
|
|
2644
|
+
const { runId: _, requestContext: __, ...resumeParams } = params;
|
|
2645
|
+
const url = `/api/agent-builder/${this.actionId}/resume-stream?${searchParams.toString()}`;
|
|
2646
|
+
const response = await this.request(url, {
|
|
2647
|
+
method: "POST",
|
|
2648
|
+
body: { ...resumeParams, requestContext },
|
|
2649
|
+
stream: true
|
|
2650
|
+
});
|
|
2651
|
+
if (!response.ok) {
|
|
2652
|
+
throw new Error(`Failed to resume agent builder action stream: ${response.statusText}`);
|
|
2653
|
+
}
|
|
2654
|
+
if (!response.body) {
|
|
2655
|
+
throw new Error("Response body is null");
|
|
2656
|
+
}
|
|
2657
|
+
return response.body.pipeThrough(this.createRecordParserTransform());
|
|
2658
|
+
}
|
|
2579
2659
|
/**
|
|
2580
2660
|
* Gets a specific action run by its ID.
|
|
2581
2661
|
* This calls `/api/agent-builder/:actionId/runs/:runId`.
|
|
@@ -2729,69 +2809,6 @@ var Observability = class extends BaseResource {
|
|
|
2729
2809
|
}
|
|
2730
2810
|
};
|
|
2731
2811
|
|
|
2732
|
-
// src/resources/network-memory-thread.ts
|
|
2733
|
-
var NetworkMemoryThread = class extends BaseResource {
|
|
2734
|
-
constructor(options, threadId, networkId) {
|
|
2735
|
-
super(options);
|
|
2736
|
-
this.threadId = threadId;
|
|
2737
|
-
this.networkId = networkId;
|
|
2738
|
-
}
|
|
2739
|
-
/**
|
|
2740
|
-
* Retrieves the memory thread details
|
|
2741
|
-
* @returns Promise containing thread details including title and metadata
|
|
2742
|
-
*/
|
|
2743
|
-
get() {
|
|
2744
|
-
return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`);
|
|
2745
|
-
}
|
|
2746
|
-
/**
|
|
2747
|
-
* Updates the memory thread properties
|
|
2748
|
-
* @param params - Update parameters including title and metadata
|
|
2749
|
-
* @returns Promise containing updated thread details
|
|
2750
|
-
*/
|
|
2751
|
-
update(params) {
|
|
2752
|
-
return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`, {
|
|
2753
|
-
method: "PATCH",
|
|
2754
|
-
body: params
|
|
2755
|
-
});
|
|
2756
|
-
}
|
|
2757
|
-
/**
|
|
2758
|
-
* Deletes the memory thread
|
|
2759
|
-
* @returns Promise containing deletion result
|
|
2760
|
-
*/
|
|
2761
|
-
delete() {
|
|
2762
|
-
return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`, {
|
|
2763
|
-
method: "DELETE"
|
|
2764
|
-
});
|
|
2765
|
-
}
|
|
2766
|
-
/**
|
|
2767
|
-
* Retrieves messages associated with the thread
|
|
2768
|
-
* @param params - Optional parameters including limit for number of messages to retrieve
|
|
2769
|
-
* @returns Promise containing thread messages and UI messages
|
|
2770
|
-
*/
|
|
2771
|
-
getMessages(params) {
|
|
2772
|
-
const query = new URLSearchParams({
|
|
2773
|
-
networkId: this.networkId,
|
|
2774
|
-
...params?.limit ? { limit: params.limit.toString() } : {}
|
|
2775
|
-
});
|
|
2776
|
-
return this.request(`/api/memory/network/threads/${this.threadId}/messages?${query.toString()}`);
|
|
2777
|
-
}
|
|
2778
|
-
/**
|
|
2779
|
-
* Deletes one or more messages from the thread
|
|
2780
|
-
* @param messageIds - Can be a single message ID (string), array of message IDs,
|
|
2781
|
-
* message object with id property, or array of message objects
|
|
2782
|
-
* @returns Promise containing deletion result
|
|
2783
|
-
*/
|
|
2784
|
-
deleteMessages(messageIds) {
|
|
2785
|
-
const query = new URLSearchParams({
|
|
2786
|
-
networkId: this.networkId
|
|
2787
|
-
});
|
|
2788
|
-
return this.request(`/api/memory/network/messages/delete?${query.toString()}`, {
|
|
2789
|
-
method: "POST",
|
|
2790
|
-
body: { messageIds }
|
|
2791
|
-
});
|
|
2792
|
-
}
|
|
2793
|
-
};
|
|
2794
|
-
|
|
2795
2812
|
// src/client.ts
|
|
2796
2813
|
var MastraClient = class extends BaseResource {
|
|
2797
2814
|
observability;
|
|
@@ -2801,18 +2818,21 @@ var MastraClient = class extends BaseResource {
|
|
|
2801
2818
|
}
|
|
2802
2819
|
/**
|
|
2803
2820
|
* Retrieves all available agents
|
|
2804
|
-
* @param
|
|
2821
|
+
* @param requestContext - Optional request context to pass as query parameter
|
|
2805
2822
|
* @returns Promise containing map of agent IDs to agent details
|
|
2806
2823
|
*/
|
|
2807
|
-
|
|
2808
|
-
const
|
|
2824
|
+
listAgents(requestContext) {
|
|
2825
|
+
const requestContextParam = base64RequestContext(parseClientRequestContext(requestContext));
|
|
2809
2826
|
const searchParams = new URLSearchParams();
|
|
2810
|
-
if (
|
|
2811
|
-
searchParams.set("
|
|
2827
|
+
if (requestContextParam) {
|
|
2828
|
+
searchParams.set("requestContext", requestContextParam);
|
|
2812
2829
|
}
|
|
2813
2830
|
const queryString = searchParams.toString();
|
|
2814
2831
|
return this.request(`/api/agents${queryString ? `?${queryString}` : ""}`);
|
|
2815
2832
|
}
|
|
2833
|
+
listAgentsModelProviders() {
|
|
2834
|
+
return this.request(`/api/agents/providers`);
|
|
2835
|
+
}
|
|
2816
2836
|
/**
|
|
2817
2837
|
* Gets an agent instance by ID
|
|
2818
2838
|
* @param agentId - ID of the agent to retrieve
|
|
@@ -2822,125 +2842,103 @@ var MastraClient = class extends BaseResource {
|
|
|
2822
2842
|
return new Agent(this.options, agentId);
|
|
2823
2843
|
}
|
|
2824
2844
|
/**
|
|
2825
|
-
*
|
|
2826
|
-
* @param params - Parameters containing
|
|
2827
|
-
* @returns Promise containing array of memory threads
|
|
2845
|
+
* Lists memory threads for a resource with pagination support
|
|
2846
|
+
* @param params - Parameters containing resource ID, pagination options, and optional request context
|
|
2847
|
+
* @returns Promise containing paginated array of memory threads with metadata
|
|
2828
2848
|
*/
|
|
2829
|
-
|
|
2830
|
-
|
|
2849
|
+
listMemoryThreads(params) {
|
|
2850
|
+
const queryParams = new URLSearchParams({
|
|
2851
|
+
resourceId: params.resourceId,
|
|
2852
|
+
agentId: params.agentId,
|
|
2853
|
+
...params.offset !== void 0 && { offset: params.offset.toString() },
|
|
2854
|
+
...params.limit !== void 0 && { limit: params.limit.toString() },
|
|
2855
|
+
...params.orderBy && { orderBy: params.orderBy },
|
|
2856
|
+
...params.sortDirection && { sortDirection: params.sortDirection }
|
|
2857
|
+
});
|
|
2858
|
+
return this.request(
|
|
2859
|
+
`/api/memory/threads?${queryParams.toString()}${requestContextQueryString(params.requestContext, "&")}`
|
|
2860
|
+
);
|
|
2831
2861
|
}
|
|
2832
2862
|
/**
|
|
2833
2863
|
* Retrieves memory config for a resource
|
|
2834
|
-
* @param params - Parameters containing the resource ID
|
|
2835
|
-
* @returns Promise containing
|
|
2864
|
+
* @param params - Parameters containing the resource ID and optional request context
|
|
2865
|
+
* @returns Promise containing memory configuration
|
|
2836
2866
|
*/
|
|
2837
2867
|
getMemoryConfig(params) {
|
|
2838
|
-
return this.request(
|
|
2868
|
+
return this.request(
|
|
2869
|
+
`/api/memory/config?agentId=${params.agentId}${requestContextQueryString(params.requestContext, "&")}`
|
|
2870
|
+
);
|
|
2839
2871
|
}
|
|
2840
2872
|
/**
|
|
2841
2873
|
* Creates a new memory thread
|
|
2842
|
-
* @param params - Parameters for creating the memory thread
|
|
2874
|
+
* @param params - Parameters for creating the memory thread including optional request context
|
|
2843
2875
|
* @returns Promise containing the created memory thread
|
|
2844
2876
|
*/
|
|
2845
2877
|
createMemoryThread(params) {
|
|
2846
|
-
return this.request(
|
|
2878
|
+
return this.request(
|
|
2879
|
+
`/api/memory/threads?agentId=${params.agentId}${requestContextQueryString(params.requestContext, "&")}`,
|
|
2880
|
+
{ method: "POST", body: params }
|
|
2881
|
+
);
|
|
2847
2882
|
}
|
|
2848
2883
|
/**
|
|
2849
2884
|
* Gets a memory thread instance by ID
|
|
2850
2885
|
* @param threadId - ID of the memory thread to retrieve
|
|
2851
2886
|
* @returns MemoryThread instance
|
|
2852
2887
|
*/
|
|
2853
|
-
getMemoryThread(threadId, agentId) {
|
|
2888
|
+
getMemoryThread({ threadId, agentId }) {
|
|
2854
2889
|
return new MemoryThread(this.options, threadId, agentId);
|
|
2855
2890
|
}
|
|
2856
2891
|
getThreadMessages(threadId, opts = {}) {
|
|
2857
2892
|
let url = "";
|
|
2858
2893
|
if (opts.agentId) {
|
|
2859
|
-
url = `/api/memory/threads/${threadId}/messages?agentId=${opts.agentId}`;
|
|
2894
|
+
url = `/api/memory/threads/${threadId}/messages?agentId=${opts.agentId}${requestContextQueryString(opts.requestContext, "&")}`;
|
|
2860
2895
|
} else if (opts.networkId) {
|
|
2861
|
-
url = `/api/memory/network/threads/${threadId}/messages?networkId=${opts.networkId}`;
|
|
2896
|
+
url = `/api/memory/network/threads/${threadId}/messages?networkId=${opts.networkId}${requestContextQueryString(opts.requestContext, "&")}`;
|
|
2862
2897
|
}
|
|
2863
2898
|
return this.request(url);
|
|
2864
2899
|
}
|
|
2865
2900
|
deleteThread(threadId, opts = {}) {
|
|
2866
2901
|
let url = "";
|
|
2867
2902
|
if (opts.agentId) {
|
|
2868
|
-
url = `/api/memory/threads/${threadId}?agentId=${opts.agentId}`;
|
|
2903
|
+
url = `/api/memory/threads/${threadId}?agentId=${opts.agentId}${requestContextQueryString(opts.requestContext, "&")}`;
|
|
2869
2904
|
} else if (opts.networkId) {
|
|
2870
|
-
url = `/api/memory/network/threads/${threadId}?networkId=${opts.networkId}`;
|
|
2905
|
+
url = `/api/memory/network/threads/${threadId}?networkId=${opts.networkId}${requestContextQueryString(opts.requestContext, "&")}`;
|
|
2871
2906
|
}
|
|
2872
2907
|
return this.request(url, { method: "DELETE" });
|
|
2873
2908
|
}
|
|
2874
2909
|
/**
|
|
2875
2910
|
* Saves messages to memory
|
|
2876
|
-
* @param params - Parameters containing messages to save
|
|
2911
|
+
* @param params - Parameters containing messages to save and optional request context
|
|
2877
2912
|
* @returns Promise containing the saved messages
|
|
2878
2913
|
*/
|
|
2879
2914
|
saveMessageToMemory(params) {
|
|
2880
|
-
return this.request(
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
* @returns Promise containing memory system status
|
|
2888
|
-
*/
|
|
2889
|
-
getMemoryStatus(agentId) {
|
|
2890
|
-
return this.request(`/api/memory/status?agentId=${agentId}`);
|
|
2891
|
-
}
|
|
2892
|
-
/**
|
|
2893
|
-
* Retrieves memory threads for a resource
|
|
2894
|
-
* @param params - Parameters containing the resource ID
|
|
2895
|
-
* @returns Promise containing array of memory threads
|
|
2896
|
-
*/
|
|
2897
|
-
getNetworkMemoryThreads(params) {
|
|
2898
|
-
return this.request(`/api/memory/network/threads?resourceid=${params.resourceId}&networkId=${params.networkId}`);
|
|
2899
|
-
}
|
|
2900
|
-
/**
|
|
2901
|
-
* Creates a new memory thread
|
|
2902
|
-
* @param params - Parameters for creating the memory thread
|
|
2903
|
-
* @returns Promise containing the created memory thread
|
|
2904
|
-
*/
|
|
2905
|
-
createNetworkMemoryThread(params) {
|
|
2906
|
-
return this.request(`/api/memory/network/threads?networkId=${params.networkId}`, { method: "POST", body: params });
|
|
2907
|
-
}
|
|
2908
|
-
/**
|
|
2909
|
-
* Gets a memory thread instance by ID
|
|
2910
|
-
* @param threadId - ID of the memory thread to retrieve
|
|
2911
|
-
* @returns MemoryThread instance
|
|
2912
|
-
*/
|
|
2913
|
-
getNetworkMemoryThread(threadId, networkId) {
|
|
2914
|
-
return new NetworkMemoryThread(this.options, threadId, networkId);
|
|
2915
|
-
}
|
|
2916
|
-
/**
|
|
2917
|
-
* Saves messages to memory
|
|
2918
|
-
* @param params - Parameters containing messages to save
|
|
2919
|
-
* @returns Promise containing the saved messages
|
|
2920
|
-
*/
|
|
2921
|
-
saveNetworkMessageToMemory(params) {
|
|
2922
|
-
return this.request(`/api/memory/network/save-messages?networkId=${params.networkId}`, {
|
|
2923
|
-
method: "POST",
|
|
2924
|
-
body: params
|
|
2925
|
-
});
|
|
2915
|
+
return this.request(
|
|
2916
|
+
`/api/memory/save-messages?agentId=${params.agentId}${requestContextQueryString(params.requestContext, "&")}`,
|
|
2917
|
+
{
|
|
2918
|
+
method: "POST",
|
|
2919
|
+
body: params
|
|
2920
|
+
}
|
|
2921
|
+
);
|
|
2926
2922
|
}
|
|
2927
2923
|
/**
|
|
2928
2924
|
* Gets the status of the memory system
|
|
2925
|
+
* @param agentId - The agent ID
|
|
2926
|
+
* @param requestContext - Optional request context to pass as query parameter
|
|
2929
2927
|
* @returns Promise containing memory system status
|
|
2930
2928
|
*/
|
|
2931
|
-
|
|
2932
|
-
return this.request(`/api/memory/
|
|
2929
|
+
getMemoryStatus(agentId, requestContext) {
|
|
2930
|
+
return this.request(`/api/memory/status?agentId=${agentId}${requestContextQueryString(requestContext, "&")}`);
|
|
2933
2931
|
}
|
|
2934
2932
|
/**
|
|
2935
2933
|
* Retrieves all available tools
|
|
2936
|
-
* @param
|
|
2934
|
+
* @param requestContext - Optional request context to pass as query parameter
|
|
2937
2935
|
* @returns Promise containing map of tool IDs to tool details
|
|
2938
2936
|
*/
|
|
2939
|
-
|
|
2940
|
-
const
|
|
2937
|
+
listTools(requestContext) {
|
|
2938
|
+
const requestContextParam = base64RequestContext(parseClientRequestContext(requestContext));
|
|
2941
2939
|
const searchParams = new URLSearchParams();
|
|
2942
|
-
if (
|
|
2943
|
-
searchParams.set("
|
|
2940
|
+
if (requestContextParam) {
|
|
2941
|
+
searchParams.set("requestContext", requestContextParam);
|
|
2944
2942
|
}
|
|
2945
2943
|
const queryString = searchParams.toString();
|
|
2946
2944
|
return this.request(`/api/tools${queryString ? `?${queryString}` : ""}`);
|
|
@@ -2955,14 +2953,14 @@ var MastraClient = class extends BaseResource {
|
|
|
2955
2953
|
}
|
|
2956
2954
|
/**
|
|
2957
2955
|
* Retrieves all available workflows
|
|
2958
|
-
* @param
|
|
2956
|
+
* @param requestContext - Optional request context to pass as query parameter
|
|
2959
2957
|
* @returns Promise containing map of workflow IDs to workflow details
|
|
2960
2958
|
*/
|
|
2961
|
-
|
|
2962
|
-
const
|
|
2959
|
+
listWorkflows(requestContext) {
|
|
2960
|
+
const requestContextParam = base64RequestContext(parseClientRequestContext(requestContext));
|
|
2963
2961
|
const searchParams = new URLSearchParams();
|
|
2964
|
-
if (
|
|
2965
|
-
searchParams.set("
|
|
2962
|
+
if (requestContextParam) {
|
|
2963
|
+
searchParams.set("requestContext", requestContextParam);
|
|
2966
2964
|
}
|
|
2967
2965
|
const queryString = searchParams.toString();
|
|
2968
2966
|
return this.request(`/api/workflows${queryString ? `?${queryString}` : ""}`);
|
|
@@ -3002,7 +3000,7 @@ var MastraClient = class extends BaseResource {
|
|
|
3002
3000
|
* @param params - Parameters for filtering logs
|
|
3003
3001
|
* @returns Promise containing array of log messages
|
|
3004
3002
|
*/
|
|
3005
|
-
|
|
3003
|
+
listLogs(params) {
|
|
3006
3004
|
const { transportId, fromDate, toDate, logLevel, filters, page, perPage } = params;
|
|
3007
3005
|
const _filters = filters ? Object.entries(filters).map(([key, value]) => `${key}:${value}`) : [];
|
|
3008
3006
|
const searchParams = new URLSearchParams();
|
|
@@ -3088,7 +3086,7 @@ var MastraClient = class extends BaseResource {
|
|
|
3088
3086
|
* List of all log transports
|
|
3089
3087
|
* @returns Promise containing list of log transports
|
|
3090
3088
|
*/
|
|
3091
|
-
|
|
3089
|
+
listLogTransports() {
|
|
3092
3090
|
return this.request("/api/logs/transports");
|
|
3093
3091
|
}
|
|
3094
3092
|
/**
|
|
@@ -3157,16 +3155,20 @@ var MastraClient = class extends BaseResource {
|
|
|
3157
3155
|
getWorkingMemory({
|
|
3158
3156
|
agentId,
|
|
3159
3157
|
threadId,
|
|
3160
|
-
resourceId
|
|
3158
|
+
resourceId,
|
|
3159
|
+
requestContext
|
|
3161
3160
|
}) {
|
|
3162
|
-
return this.request(
|
|
3161
|
+
return this.request(
|
|
3162
|
+
`/api/memory/threads/${threadId}/working-memory?agentId=${agentId}&resourceId=${resourceId}${requestContextQueryString(requestContext, "&")}`
|
|
3163
|
+
);
|
|
3163
3164
|
}
|
|
3164
3165
|
searchMemory({
|
|
3165
3166
|
agentId,
|
|
3166
3167
|
resourceId,
|
|
3167
3168
|
threadId,
|
|
3168
3169
|
searchQuery,
|
|
3169
|
-
memoryConfig
|
|
3170
|
+
memoryConfig,
|
|
3171
|
+
requestContext
|
|
3170
3172
|
}) {
|
|
3171
3173
|
const params = new URLSearchParams({
|
|
3172
3174
|
searchQuery,
|
|
@@ -3179,7 +3181,7 @@ var MastraClient = class extends BaseResource {
|
|
|
3179
3181
|
if (memoryConfig) {
|
|
3180
3182
|
params.append("memoryConfig", JSON.stringify(memoryConfig));
|
|
3181
3183
|
}
|
|
3182
|
-
return this.request(`/api/memory/search?${params}`);
|
|
3184
|
+
return this.request(`/api/memory/search?${params}${requestContextQueryString(requestContext, "&")}`);
|
|
3183
3185
|
}
|
|
3184
3186
|
/**
|
|
3185
3187
|
* Updates the working memory for a specific thread (optionally resource-scoped).
|
|
@@ -3192,21 +3194,25 @@ var MastraClient = class extends BaseResource {
|
|
|
3192
3194
|
agentId,
|
|
3193
3195
|
threadId,
|
|
3194
3196
|
workingMemory,
|
|
3195
|
-
resourceId
|
|
3197
|
+
resourceId,
|
|
3198
|
+
requestContext
|
|
3196
3199
|
}) {
|
|
3197
|
-
return this.request(
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3200
|
+
return this.request(
|
|
3201
|
+
`/api/memory/threads/${threadId}/working-memory?agentId=${agentId}${requestContextQueryString(requestContext, "&")}`,
|
|
3202
|
+
{
|
|
3203
|
+
method: "POST",
|
|
3204
|
+
body: {
|
|
3205
|
+
workingMemory,
|
|
3206
|
+
resourceId
|
|
3207
|
+
}
|
|
3202
3208
|
}
|
|
3203
|
-
|
|
3209
|
+
);
|
|
3204
3210
|
}
|
|
3205
3211
|
/**
|
|
3206
3212
|
* Retrieves all available scorers
|
|
3207
3213
|
* @returns Promise containing list of available scorers
|
|
3208
3214
|
*/
|
|
3209
|
-
|
|
3215
|
+
listScorers() {
|
|
3210
3216
|
return this.request("/api/scores/scorers");
|
|
3211
3217
|
}
|
|
3212
3218
|
/**
|