@mastra/client-js 0.13.0-alpha.5 → 0.13.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/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.log("\u{1F3C1} Stream finished");
94
+ console.info("\u{1F3C1} Stream finished");
95
95
  return;
96
96
  }
97
97
  try {
@@ -1332,63 +1332,6 @@ var Agent = class extends BaseResource {
1332
1332
  });
1333
1333
  }
1334
1334
  };
1335
- var Network = class extends BaseResource {
1336
- constructor(options, networkId) {
1337
- super(options);
1338
- this.networkId = networkId;
1339
- }
1340
- /**
1341
- * Retrieves details about the network
1342
- * @param runtimeContext - Optional runtime context to pass as query parameter
1343
- * @returns Promise containing network details
1344
- */
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`, {
1360
- method: "POST",
1361
- body: processedParams
1362
- });
1363
- }
1364
- /**
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
1368
- */
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`, {
1376
- method: "POST",
1377
- body: processedParams,
1378
- stream: true
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;
1390
- }
1391
- };
1392
1335
 
1393
1336
  // src/resources/memory-thread.ts
1394
1337
  var MemoryThread = class extends BaseResource {
@@ -2011,7 +1954,54 @@ var Workflow = class extends BaseResource {
2011
1954
  }
2012
1955
  );
2013
1956
  if (!response.ok) {
2014
- throw new Error(`Failed to stream vNext workflow: ${response.statusText}`);
1957
+ throw new Error(`Failed to stream workflow: ${response.statusText}`);
1958
+ }
1959
+ if (!response.body) {
1960
+ throw new Error("Response body is null");
1961
+ }
1962
+ let failedChunk = void 0;
1963
+ const transformStream = new TransformStream({
1964
+ start() {
1965
+ },
1966
+ async transform(chunk, controller) {
1967
+ try {
1968
+ const decoded = new TextDecoder().decode(chunk);
1969
+ const chunks = decoded.split(RECORD_SEPARATOR2);
1970
+ for (const chunk2 of chunks) {
1971
+ if (chunk2) {
1972
+ const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
1973
+ try {
1974
+ const parsedChunk = JSON.parse(newChunk);
1975
+ controller.enqueue(parsedChunk);
1976
+ failedChunk = void 0;
1977
+ } catch {
1978
+ failedChunk = newChunk;
1979
+ }
1980
+ }
1981
+ }
1982
+ } catch {
1983
+ }
1984
+ }
1985
+ });
1986
+ return response.body.pipeThrough(transformStream);
1987
+ }
1988
+ /**
1989
+ * Observes workflow stream for a workflow run
1990
+ * @param params - Object containing the runId
1991
+ * @returns Promise containing the workflow execution results
1992
+ */
1993
+ async observeStream(params) {
1994
+ const searchParams = new URLSearchParams();
1995
+ searchParams.set("runId", params.runId);
1996
+ const response = await this.request(
1997
+ `/api/workflows/${this.workflowId}/observe-stream?${searchParams.toString()}`,
1998
+ {
1999
+ method: "POST",
2000
+ stream: true
2001
+ }
2002
+ );
2003
+ if (!response.ok) {
2004
+ throw new Error(`Failed to observe workflow stream: ${response.statusText}`);
2015
2005
  }
2016
2006
  if (!response.body) {
2017
2007
  throw new Error("Response body is null");
@@ -3219,13 +3209,6 @@ var MastraClient = class extends BaseResource {
3219
3209
  return this.request(`/api/telemetry`);
3220
3210
  }
3221
3211
  }
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
- }
3229
3212
  /**
3230
3213
  * Retrieves all available vNext networks
3231
3214
  * @returns Promise containing map of vNext network IDs to vNext network details
@@ -3233,14 +3216,6 @@ var MastraClient = class extends BaseResource {
3233
3216
  getVNextNetworks() {
3234
3217
  return this.request("/api/networks/v-next");
3235
3218
  }
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
- }
3244
3219
  /**
3245
3220
  * Gets a vNext network instance by ID
3246
3221
  * @param networkId - ID of the vNext network to retrieve