@mastra/client-js 0.0.0-fix-cloud-peer-deps-20250923194656 → 0.0.0-gl-test-20250917080133
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 +3 -111
- package/dist/client.d.ts +13 -29
- package/dist/client.d.ts.map +1 -1
- package/dist/index.cjs +71 -135
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +71 -135
- package/dist/index.js.map +1 -1
- package/dist/resources/agent.d.ts +6 -22
- package/dist/resources/agent.d.ts.map +1 -1
- package/dist/resources/index.d.ts +1 -0
- package/dist/resources/index.d.ts.map +1 -1
- package/dist/resources/network.d.ts +32 -0
- package/dist/resources/network.d.ts.map +1 -0
- package/dist/resources/observability.d.ts +0 -10
- package/dist/resources/observability.d.ts.map +1 -1
- package/dist/resources/workflow.d.ts +0 -28
- package/dist/resources/workflow.d.ts.map +1 -1
- package/dist/types.d.ts +21 -42
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -91,7 +91,7 @@ async function sharedProcessMastraStream({
|
|
|
91
91
|
if (line.startsWith("data: ")) {
|
|
92
92
|
const data = line.slice(6);
|
|
93
93
|
if (data === "[DONE]") {
|
|
94
|
-
console.
|
|
94
|
+
console.log("\u{1F3C1} Stream finished");
|
|
95
95
|
return;
|
|
96
96
|
}
|
|
97
97
|
try {
|
|
@@ -213,9 +213,7 @@ async function executeToolCallAndRespond({
|
|
|
213
213
|
resourceId,
|
|
214
214
|
threadId,
|
|
215
215
|
runtimeContext,
|
|
216
|
-
tracingContext: { currentSpan: void 0 }
|
|
217
|
-
suspend: async () => {
|
|
218
|
-
}
|
|
216
|
+
tracingContext: { currentSpan: void 0 }
|
|
219
217
|
},
|
|
220
218
|
{
|
|
221
219
|
messages: response.messages,
|
|
@@ -323,7 +321,7 @@ var Agent = class extends BaseResource {
|
|
|
323
321
|
}
|
|
324
322
|
async generate(params) {
|
|
325
323
|
console.warn(
|
|
326
|
-
"Deprecation NOTICE:Generate method will switch to use generateVNext implementation September
|
|
324
|
+
"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."
|
|
327
325
|
);
|
|
328
326
|
return this.generateLegacy(params);
|
|
329
327
|
}
|
|
@@ -358,9 +356,7 @@ var Agent = class extends BaseResource {
|
|
|
358
356
|
resourceId,
|
|
359
357
|
threadId,
|
|
360
358
|
runtimeContext,
|
|
361
|
-
tracingContext: { currentSpan: void 0 }
|
|
362
|
-
suspend: async () => {
|
|
363
|
-
}
|
|
359
|
+
tracingContext: { currentSpan: void 0 }
|
|
364
360
|
},
|
|
365
361
|
{
|
|
366
362
|
messages: response.messages,
|
|
@@ -704,7 +700,7 @@ var Agent = class extends BaseResource {
|
|
|
704
700
|
*/
|
|
705
701
|
async stream(params) {
|
|
706
702
|
console.warn(
|
|
707
|
-
"Deprecation NOTICE:\nStream method will switch to use streamVNext implementation September
|
|
703
|
+
"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."
|
|
708
704
|
);
|
|
709
705
|
return this.streamLegacy(params);
|
|
710
706
|
}
|
|
@@ -1053,9 +1049,7 @@ var Agent = class extends BaseResource {
|
|
|
1053
1049
|
threadId: processedParams.threadId,
|
|
1054
1050
|
runtimeContext: processedParams.runtimeContext,
|
|
1055
1051
|
// TODO: Pass proper tracing context when client-js supports tracing
|
|
1056
|
-
tracingContext: { currentSpan: void 0 }
|
|
1057
|
-
suspend: async () => {
|
|
1058
|
-
}
|
|
1052
|
+
tracingContext: { currentSpan: void 0 }
|
|
1059
1053
|
},
|
|
1060
1054
|
{
|
|
1061
1055
|
messages: response.messages,
|
|
@@ -1219,9 +1213,7 @@ var Agent = class extends BaseResource {
|
|
|
1219
1213
|
threadId: processedParams.threadId,
|
|
1220
1214
|
runtimeContext: processedParams.runtimeContext,
|
|
1221
1215
|
// TODO: Pass proper tracing context when client-js supports tracing
|
|
1222
|
-
tracingContext: { currentSpan: void 0 }
|
|
1223
|
-
suspend: async () => {
|
|
1224
|
-
}
|
|
1216
|
+
tracingContext: { currentSpan: void 0 }
|
|
1225
1217
|
},
|
|
1226
1218
|
{
|
|
1227
1219
|
messages: response.messages,
|
|
@@ -1339,27 +1331,62 @@ var Agent = class extends BaseResource {
|
|
|
1339
1331
|
body: params
|
|
1340
1332
|
});
|
|
1341
1333
|
}
|
|
1334
|
+
};
|
|
1335
|
+
var Network = class extends BaseResource {
|
|
1336
|
+
constructor(options, networkId) {
|
|
1337
|
+
super(options);
|
|
1338
|
+
this.networkId = networkId;
|
|
1339
|
+
}
|
|
1342
1340
|
/**
|
|
1343
|
-
*
|
|
1344
|
-
* @param
|
|
1345
|
-
* @returns Promise containing
|
|
1341
|
+
* Retrieves details about the network
|
|
1342
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
1343
|
+
* @returns Promise containing network details
|
|
1346
1344
|
*/
|
|
1347
|
-
|
|
1348
|
-
return this.request(`/api/
|
|
1345
|
+
details(runtimeContext) {
|
|
1346
|
+
return this.request(`/api/networks/${this.networkId}${runtimeContextQueryString(runtimeContext)}`);
|
|
1347
|
+
}
|
|
1348
|
+
/**
|
|
1349
|
+
* Generates a response from the agent
|
|
1350
|
+
* @param params - Generation parameters including prompt
|
|
1351
|
+
* @returns Promise containing the generated response
|
|
1352
|
+
*/
|
|
1353
|
+
generate(params) {
|
|
1354
|
+
const processedParams = {
|
|
1355
|
+
...params,
|
|
1356
|
+
output: zodToJsonSchema(params.output),
|
|
1357
|
+
experimental_output: zodToJsonSchema(params.experimental_output)
|
|
1358
|
+
};
|
|
1359
|
+
return this.request(`/api/networks/${this.networkId}/generate`, {
|
|
1349
1360
|
method: "POST",
|
|
1350
|
-
body:
|
|
1361
|
+
body: processedParams
|
|
1351
1362
|
});
|
|
1352
1363
|
}
|
|
1353
1364
|
/**
|
|
1354
|
-
*
|
|
1355
|
-
* @param params -
|
|
1356
|
-
* @returns Promise containing the
|
|
1365
|
+
* Streams a response from the agent
|
|
1366
|
+
* @param params - Stream parameters including prompt
|
|
1367
|
+
* @returns Promise containing the enhanced Response object with processDataStream method
|
|
1357
1368
|
*/
|
|
1358
|
-
|
|
1359
|
-
|
|
1369
|
+
async stream(params) {
|
|
1370
|
+
const processedParams = {
|
|
1371
|
+
...params,
|
|
1372
|
+
output: zodToJsonSchema(params.output),
|
|
1373
|
+
experimental_output: zodToJsonSchema(params.experimental_output)
|
|
1374
|
+
};
|
|
1375
|
+
const response = await this.request(`/api/networks/${this.networkId}/stream`, {
|
|
1360
1376
|
method: "POST",
|
|
1361
|
-
body:
|
|
1377
|
+
body: processedParams,
|
|
1378
|
+
stream: true
|
|
1362
1379
|
});
|
|
1380
|
+
if (!response.body) {
|
|
1381
|
+
throw new Error("No response body");
|
|
1382
|
+
}
|
|
1383
|
+
response.processDataStream = async (options = {}) => {
|
|
1384
|
+
await processDataStream({
|
|
1385
|
+
stream: response.body,
|
|
1386
|
+
...options
|
|
1387
|
+
});
|
|
1388
|
+
};
|
|
1389
|
+
return response;
|
|
1363
1390
|
}
|
|
1364
1391
|
};
|
|
1365
1392
|
|
|
@@ -1912,14 +1939,6 @@ var Workflow = class extends BaseResource {
|
|
|
1912
1939
|
},
|
|
1913
1940
|
resumeAsync: async (p) => {
|
|
1914
1941
|
return this.resumeAsync({ runId, step: p.step, resumeData: p.resumeData, runtimeContext: p.runtimeContext });
|
|
1915
|
-
},
|
|
1916
|
-
resumeStreamVNext: async (p) => {
|
|
1917
|
-
return this.resumeStreamVNext({
|
|
1918
|
-
runId,
|
|
1919
|
-
step: p.step,
|
|
1920
|
-
resumeData: p.resumeData,
|
|
1921
|
-
runtimeContext: p.runtimeContext
|
|
1922
|
-
});
|
|
1923
1942
|
}
|
|
1924
1943
|
};
|
|
1925
1944
|
}
|
|
@@ -1992,54 +2011,7 @@ var Workflow = class extends BaseResource {
|
|
|
1992
2011
|
}
|
|
1993
2012
|
);
|
|
1994
2013
|
if (!response.ok) {
|
|
1995
|
-
throw new Error(`Failed to stream workflow: ${response.statusText}`);
|
|
1996
|
-
}
|
|
1997
|
-
if (!response.body) {
|
|
1998
|
-
throw new Error("Response body is null");
|
|
1999
|
-
}
|
|
2000
|
-
let failedChunk = void 0;
|
|
2001
|
-
const transformStream = new TransformStream({
|
|
2002
|
-
start() {
|
|
2003
|
-
},
|
|
2004
|
-
async transform(chunk, controller) {
|
|
2005
|
-
try {
|
|
2006
|
-
const decoded = new TextDecoder().decode(chunk);
|
|
2007
|
-
const chunks = decoded.split(RECORD_SEPARATOR2);
|
|
2008
|
-
for (const chunk2 of chunks) {
|
|
2009
|
-
if (chunk2) {
|
|
2010
|
-
const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
|
|
2011
|
-
try {
|
|
2012
|
-
const parsedChunk = JSON.parse(newChunk);
|
|
2013
|
-
controller.enqueue(parsedChunk);
|
|
2014
|
-
failedChunk = void 0;
|
|
2015
|
-
} catch {
|
|
2016
|
-
failedChunk = newChunk;
|
|
2017
|
-
}
|
|
2018
|
-
}
|
|
2019
|
-
}
|
|
2020
|
-
} catch {
|
|
2021
|
-
}
|
|
2022
|
-
}
|
|
2023
|
-
});
|
|
2024
|
-
return response.body.pipeThrough(transformStream);
|
|
2025
|
-
}
|
|
2026
|
-
/**
|
|
2027
|
-
* Observes workflow stream for a workflow run
|
|
2028
|
-
* @param params - Object containing the runId
|
|
2029
|
-
* @returns Promise containing the workflow execution results
|
|
2030
|
-
*/
|
|
2031
|
-
async observeStream(params) {
|
|
2032
|
-
const searchParams = new URLSearchParams();
|
|
2033
|
-
searchParams.set("runId", params.runId);
|
|
2034
|
-
const response = await this.request(
|
|
2035
|
-
`/api/workflows/${this.workflowId}/observe-stream?${searchParams.toString()}`,
|
|
2036
|
-
{
|
|
2037
|
-
method: "POST",
|
|
2038
|
-
stream: true
|
|
2039
|
-
}
|
|
2040
|
-
);
|
|
2041
|
-
if (!response.ok) {
|
|
2042
|
-
throw new Error(`Failed to observe workflow stream: ${response.statusText}`);
|
|
2014
|
+
throw new Error(`Failed to stream vNext workflow: ${response.statusText}`);
|
|
2043
2015
|
}
|
|
2044
2016
|
if (!response.body) {
|
|
2045
2017
|
throw new Error("Response body is null");
|
|
@@ -2085,7 +2057,7 @@ var Workflow = class extends BaseResource {
|
|
|
2085
2057
|
`/api/workflows/${this.workflowId}/streamVNext?${searchParams.toString()}`,
|
|
2086
2058
|
{
|
|
2087
2059
|
method: "POST",
|
|
2088
|
-
body: { inputData: params.inputData, runtimeContext
|
|
2060
|
+
body: { inputData: params.inputData, runtimeContext },
|
|
2089
2061
|
stream: true
|
|
2090
2062
|
}
|
|
2091
2063
|
);
|
|
@@ -2137,22 +2109,6 @@ var Workflow = class extends BaseResource {
|
|
|
2137
2109
|
}
|
|
2138
2110
|
});
|
|
2139
2111
|
}
|
|
2140
|
-
/**
|
|
2141
|
-
* Resumes a suspended workflow step that uses streamVNext asynchronously and returns a promise that resolves when the workflow is complete
|
|
2142
|
-
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
2143
|
-
* @returns Promise containing the workflow resume results
|
|
2144
|
-
*/
|
|
2145
|
-
resumeStreamVNext(params) {
|
|
2146
|
-
const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
|
|
2147
|
-
return this.request(`/api/workflows/${this.workflowId}/resume-stream?runId=${params.runId}`, {
|
|
2148
|
-
method: "POST",
|
|
2149
|
-
body: {
|
|
2150
|
-
step: params.step,
|
|
2151
|
-
resumeData: params.resumeData,
|
|
2152
|
-
runtimeContext
|
|
2153
|
-
}
|
|
2154
|
-
});
|
|
2155
|
-
}
|
|
2156
2112
|
/**
|
|
2157
2113
|
* Watches workflow transitions in real-time
|
|
2158
2114
|
* @param runId - Optional run ID to filter the watch stream
|
|
@@ -2729,12 +2685,6 @@ var Observability = class extends BaseResource {
|
|
|
2729
2685
|
const queryString = searchParams.toString();
|
|
2730
2686
|
return this.request(`/api/observability/traces${queryString ? `?${queryString}` : ""}`);
|
|
2731
2687
|
}
|
|
2732
|
-
score(params) {
|
|
2733
|
-
return this.request(`/api/observability/traces/score`, {
|
|
2734
|
-
method: "POST",
|
|
2735
|
-
body: { ...params }
|
|
2736
|
-
});
|
|
2737
|
-
}
|
|
2738
2688
|
};
|
|
2739
2689
|
|
|
2740
2690
|
// src/resources/network-memory-thread.ts
|
|
@@ -2976,14 +2926,6 @@ var MastraClient = class extends BaseResource {
|
|
|
2976
2926
|
getMemoryThreads(params) {
|
|
2977
2927
|
return this.request(`/api/memory/threads?resourceid=${params.resourceId}&agentId=${params.agentId}`);
|
|
2978
2928
|
}
|
|
2979
|
-
/**
|
|
2980
|
-
* Retrieves memory config for a resource
|
|
2981
|
-
* @param params - Parameters containing the resource ID
|
|
2982
|
-
* @returns Promise containing array of memory threads
|
|
2983
|
-
*/
|
|
2984
|
-
getMemoryConfig(params) {
|
|
2985
|
-
return this.request(`/api/memory/config?agentId=${params.agentId}`);
|
|
2986
|
-
}
|
|
2987
2929
|
/**
|
|
2988
2930
|
* Creates a new memory thread
|
|
2989
2931
|
* @param params - Parameters for creating the memory thread
|
|
@@ -3000,24 +2942,6 @@ var MastraClient = class extends BaseResource {
|
|
|
3000
2942
|
getMemoryThread(threadId, agentId) {
|
|
3001
2943
|
return new MemoryThread(this.options, threadId, agentId);
|
|
3002
2944
|
}
|
|
3003
|
-
getThreadMessages(threadId, opts = {}) {
|
|
3004
|
-
let url = "";
|
|
3005
|
-
if (opts.agentId) {
|
|
3006
|
-
url = `/api/memory/threads/${threadId}/messages?agentId=${opts.agentId}`;
|
|
3007
|
-
} else if (opts.networkId) {
|
|
3008
|
-
url = `/api/memory/network/threads/${threadId}/messages?networkId=${opts.networkId}`;
|
|
3009
|
-
}
|
|
3010
|
-
return this.request(url);
|
|
3011
|
-
}
|
|
3012
|
-
deleteThread(threadId, opts = {}) {
|
|
3013
|
-
let url = "";
|
|
3014
|
-
if (opts.agentId) {
|
|
3015
|
-
url = `/api/memory/threads/${threadId}?agentId=${opts.agentId}`;
|
|
3016
|
-
} else if (opts.networkId) {
|
|
3017
|
-
url = `/api/memory/network/threads/${threadId}?networkId=${opts.networkId}`;
|
|
3018
|
-
}
|
|
3019
|
-
return this.request(url, { method: "DELETE" });
|
|
3020
|
-
}
|
|
3021
2945
|
/**
|
|
3022
2946
|
* Saves messages to memory
|
|
3023
2947
|
* @param params - Parameters containing messages to save
|
|
@@ -3295,6 +3219,13 @@ var MastraClient = class extends BaseResource {
|
|
|
3295
3219
|
return this.request(`/api/telemetry`);
|
|
3296
3220
|
}
|
|
3297
3221
|
}
|
|
3222
|
+
/**
|
|
3223
|
+
* Retrieves all available networks
|
|
3224
|
+
* @returns Promise containing map of network IDs to network details
|
|
3225
|
+
*/
|
|
3226
|
+
getNetworks() {
|
|
3227
|
+
return this.request("/api/networks");
|
|
3228
|
+
}
|
|
3298
3229
|
/**
|
|
3299
3230
|
* Retrieves all available vNext networks
|
|
3300
3231
|
* @returns Promise containing map of vNext network IDs to vNext network details
|
|
@@ -3302,6 +3233,14 @@ var MastraClient = class extends BaseResource {
|
|
|
3302
3233
|
getVNextNetworks() {
|
|
3303
3234
|
return this.request("/api/networks/v-next");
|
|
3304
3235
|
}
|
|
3236
|
+
/**
|
|
3237
|
+
* Gets a network instance by ID
|
|
3238
|
+
* @param networkId - ID of the network to retrieve
|
|
3239
|
+
* @returns Network instance
|
|
3240
|
+
*/
|
|
3241
|
+
getNetwork(networkId) {
|
|
3242
|
+
return new Network(this.options, networkId);
|
|
3243
|
+
}
|
|
3305
3244
|
/**
|
|
3306
3245
|
* Gets a vNext network instance by ID
|
|
3307
3246
|
* @param networkId - ID of the vNext network to retrieve
|
|
@@ -3492,9 +3431,6 @@ var MastraClient = class extends BaseResource {
|
|
|
3492
3431
|
getAITraces(params) {
|
|
3493
3432
|
return this.observability.getTraces(params);
|
|
3494
3433
|
}
|
|
3495
|
-
score(params) {
|
|
3496
|
-
return this.observability.score(params);
|
|
3497
|
-
}
|
|
3498
3434
|
};
|
|
3499
3435
|
|
|
3500
3436
|
// src/tools.ts
|