@mastra/client-js 0.0.0-vnextAgentNetwork-20250527105810 → 0.0.0-vnextAgentNetwork-20250602084555

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @mastra/client-js
2
2
 
3
- ## 0.0.0-vnextAgentNetwork-20250527105810
3
+ ## 0.0.0-vnextAgentNetwork-20250602084555
4
4
 
5
5
  ### Patch Changes
6
6
 
@@ -14,7 +14,7 @@
14
14
  - Updated dependencies [38aee50]
15
15
  - Updated dependencies [5c41100]
16
16
  - Updated dependencies [d6a759b]
17
- - @mastra/core@0.0.0-vnextAgentNetwork-20250527105810
17
+ - @mastra/core@0.0.0-vnextAgentNetwork-20250602084555
18
18
 
19
19
  ## 0.10.1-alpha.0
20
20
 
package/dist/index.cjs CHANGED
@@ -955,9 +955,9 @@ var Workflow = class extends BaseResource {
955
955
  });
956
956
  }
957
957
  /**
958
- * Starts a vNext workflow run and returns a stream
958
+ * Starts a workflow run and returns a stream
959
959
  * @param params - Object containing the optional runId, inputData and runtimeContext
960
- * @returns Promise containing the vNext workflow execution results
960
+ * @returns Promise containing the workflow execution results
961
961
  */
962
962
  async stream(params) {
963
963
  const searchParams = new URLSearchParams();
@@ -1169,6 +1169,72 @@ var MCPTool = class extends BaseResource {
1169
1169
  }
1170
1170
  };
1171
1171
 
1172
+ // src/resources/vNextNetwork.ts
1173
+ var RECORD_SEPARATOR3 = "";
1174
+ var VNextNetwork = class extends BaseResource {
1175
+ constructor(options, networkId) {
1176
+ super(options);
1177
+ this.networkId = networkId;
1178
+ }
1179
+ /**
1180
+ * Retrieves details about the network
1181
+ * @returns Promise containing vNext network details
1182
+ */
1183
+ details() {
1184
+ return this.request(`/api/networks/v-next/${this.networkId}`);
1185
+ }
1186
+ /**
1187
+ * Generates a response from the v-next network
1188
+ * @param params - Generation parameters including message
1189
+ * @returns Promise containing the generated response
1190
+ */
1191
+ generate(params) {
1192
+ return this.request(`/api/networks/${this.networkId}/generate`, {
1193
+ method: "POST",
1194
+ body: params
1195
+ });
1196
+ }
1197
+ /**
1198
+ * Streams a response from the v-next network
1199
+ * @param params - Stream parameters including message
1200
+ * @returns Promise containing the results
1201
+ */
1202
+ async stream(params) {
1203
+ const response = await this.request(`/api/networks/v-next/${this.networkId}/stream`, {
1204
+ method: "POST",
1205
+ body: { message: params.message },
1206
+ stream: true
1207
+ });
1208
+ if (!response.ok) {
1209
+ throw new Error(`Failed to stream vNext network: ${response.statusText}`);
1210
+ }
1211
+ if (!response.body) {
1212
+ throw new Error("Response body is null");
1213
+ }
1214
+ const transformStream = new TransformStream({
1215
+ start() {
1216
+ },
1217
+ async transform(chunk, controller) {
1218
+ try {
1219
+ const decoded = new TextDecoder().decode(chunk);
1220
+ const chunks = decoded.split(RECORD_SEPARATOR3);
1221
+ for (const chunk2 of chunks) {
1222
+ if (chunk2) {
1223
+ try {
1224
+ const parsedChunk = JSON.parse(chunk2);
1225
+ controller.enqueue(parsedChunk);
1226
+ } catch {
1227
+ }
1228
+ }
1229
+ }
1230
+ } catch {
1231
+ }
1232
+ }
1233
+ });
1234
+ return response.body.pipeThrough(transformStream);
1235
+ }
1236
+ };
1237
+
1172
1238
  // src/client.ts
1173
1239
  var MastraClient = class extends BaseResource {
1174
1240
  constructor(options) {
@@ -1371,6 +1437,13 @@ var MastraClient = class extends BaseResource {
1371
1437
  getNetworks() {
1372
1438
  return this.request("/api/networks");
1373
1439
  }
1440
+ /**
1441
+ * Retrieves all available vNext networks
1442
+ * @returns Promise containing map of vNext network IDs to vNext network details
1443
+ */
1444
+ getVNextNetworks() {
1445
+ return this.request("/api/networks/v-next");
1446
+ }
1374
1447
  /**
1375
1448
  * Gets a network instance by ID
1376
1449
  * @param networkId - ID of the network to retrieve
@@ -1379,6 +1452,14 @@ var MastraClient = class extends BaseResource {
1379
1452
  getNetwork(networkId) {
1380
1453
  return new Network(this.options, networkId);
1381
1454
  }
1455
+ /**
1456
+ * Gets a vNext network instance by ID
1457
+ * @param networkId - ID of the vNext network to retrieve
1458
+ * @returns vNext Network instance
1459
+ */
1460
+ getVNextNetwork(networkId) {
1461
+ return new VNextNetwork(this.options, networkId);
1462
+ }
1382
1463
  /**
1383
1464
  * Retrieves a list of available MCP servers.
1384
1465
  * @param params - Optional parameters for pagination (limit, offset).
package/dist/index.d.cts CHANGED
@@ -4,8 +4,8 @@ import { processDataStream } from '@ai-sdk/ui-utils';
4
4
  import { CoreMessage, AiMessageType, StorageThreadType, MessageType, LegacyWorkflowRuns, WorkflowRuns, QueryResult, GenerateReturn } from '@mastra/core';
5
5
  import { JSONSchema7 } from 'json-schema';
6
6
  import { ZodSchema } from 'zod';
7
- import { BaseLogMessage } from '@mastra/core/logger';
8
7
  import { AgentGenerateOptions, AgentStreamOptions } from '@mastra/core/agent';
8
+ import { BaseLogMessage } from '@mastra/core/logger';
9
9
  import { RuntimeContext } from '@mastra/core/runtime-context';
10
10
  import { Workflow as Workflow$1, WorkflowResult, WatchEvent } from '@mastra/core/workflows';
11
11
  import { StepAction, StepGraph, LegacyWorkflowRunResult as LegacyWorkflowRunResult$1 } from '@mastra/core/workflows/legacy';
@@ -247,6 +247,32 @@ interface GetNetworkResponse {
247
247
  };
248
248
  state?: Record<string, any>;
249
249
  }
250
+ interface GetVNextNetworkResponse {
251
+ id: string;
252
+ name: string;
253
+ instructions: string;
254
+ agents: Array<{
255
+ name: string;
256
+ provider: string;
257
+ modelId: string;
258
+ }>;
259
+ routingModel: {
260
+ provider: string;
261
+ modelId: string;
262
+ };
263
+ workflows: Array<{
264
+ name: string;
265
+ description: string;
266
+ inputSchema: string | undefined;
267
+ outputSchema: string | undefined;
268
+ }>;
269
+ }
270
+ interface GenerateVNextNetworkResponse {
271
+ task: string;
272
+ result: string;
273
+ resourceId: string;
274
+ resourceType: 'none' | 'tool' | 'agent' | 'workflow';
275
+ }
250
276
  interface McpServerListResponse {
251
277
  servers: ServerInfo[];
252
278
  next: string | null;
@@ -629,9 +655,9 @@ declare class Workflow extends BaseResource {
629
655
  runtimeContext?: RuntimeContext | Record<string, any>;
630
656
  }): Promise<WorkflowRunResult>;
631
657
  /**
632
- * Starts a vNext workflow run and returns a stream
658
+ * Starts a workflow run and returns a stream
633
659
  * @param params - Object containing the optional runId, inputData and runtimeContext
634
- * @returns Promise containing the vNext workflow execution results
660
+ * @returns Promise containing the workflow execution results
635
661
  */
636
662
  stream(params: {
637
663
  runId?: string;
@@ -732,6 +758,32 @@ declare class MCPTool extends BaseResource {
732
758
  }): Promise<any>;
733
759
  }
734
760
 
761
+ declare class VNextNetwork extends BaseResource {
762
+ private networkId;
763
+ constructor(options: ClientOptions, networkId: string);
764
+ /**
765
+ * Retrieves details about the network
766
+ * @returns Promise containing vNext network details
767
+ */
768
+ details(): Promise<GetVNextNetworkResponse>;
769
+ /**
770
+ * Generates a response from the v-next network
771
+ * @param params - Generation parameters including message
772
+ * @returns Promise containing the generated response
773
+ */
774
+ generate(params: {
775
+ message: string;
776
+ }): Promise<GenerateVNextNetworkResponse>;
777
+ /**
778
+ * Streams a response from the v-next network
779
+ * @param params - Stream parameters including message
780
+ * @returns Promise containing the results
781
+ */
782
+ stream(params: {
783
+ message: string;
784
+ }): Promise<stream_web.ReadableStream<any>>;
785
+ }
786
+
735
787
  declare class MastraClient extends BaseResource {
736
788
  constructor(options: ClientOptions);
737
789
  /**
@@ -848,12 +900,23 @@ declare class MastraClient extends BaseResource {
848
900
  * @returns Promise containing map of network IDs to network details
849
901
  */
850
902
  getNetworks(): Promise<Record<string, GetNetworkResponse>>;
903
+ /**
904
+ * Retrieves all available vNext networks
905
+ * @returns Promise containing map of vNext network IDs to vNext network details
906
+ */
907
+ getVNextNetworks(): Promise<Record<string, GetVNextNetworkResponse>>;
851
908
  /**
852
909
  * Gets a network instance by ID
853
910
  * @param networkId - ID of the network to retrieve
854
911
  * @returns Network instance
855
912
  */
856
913
  getNetwork(networkId: string): Network;
914
+ /**
915
+ * Gets a vNext network instance by ID
916
+ * @param networkId - ID of the vNext network to retrieve
917
+ * @returns vNext Network instance
918
+ */
919
+ getVNextNetwork(networkId: string): VNextNetwork;
857
920
  /**
858
921
  * Retrieves a list of available MCP servers.
859
922
  * @param params - Optional parameters for pagination (limit, offset).
@@ -894,4 +957,4 @@ declare class MastraClient extends BaseResource {
894
957
  getA2A(agentId: string): A2A;
895
958
  }
896
959
 
897
- export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type GenerateParams, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLegacyWorkflowResponse, type GetLegacyWorkflowRunsResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesParams, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVectorIndexResponse, type GetWorkflowResponse, type GetWorkflowRunsParams, type GetWorkflowRunsResponse, type LegacyWorkflowRunResult, MastraClient, type McpServerListResponse, type McpServerToolListResponse, type McpToolInfo, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type WorkflowRunResult, type WorkflowWatchResult };
960
+ export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type GenerateParams, type GenerateVNextNetworkResponse, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLegacyWorkflowResponse, type GetLegacyWorkflowRunsResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesParams, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVNextNetworkResponse, type GetVectorIndexResponse, type GetWorkflowResponse, type GetWorkflowRunsParams, type GetWorkflowRunsResponse, type LegacyWorkflowRunResult, MastraClient, type McpServerListResponse, type McpServerToolListResponse, type McpToolInfo, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type WorkflowRunResult, type WorkflowWatchResult };
package/dist/index.d.ts CHANGED
@@ -4,8 +4,8 @@ import { processDataStream } from '@ai-sdk/ui-utils';
4
4
  import { CoreMessage, AiMessageType, StorageThreadType, MessageType, LegacyWorkflowRuns, WorkflowRuns, QueryResult, GenerateReturn } from '@mastra/core';
5
5
  import { JSONSchema7 } from 'json-schema';
6
6
  import { ZodSchema } from 'zod';
7
- import { BaseLogMessage } from '@mastra/core/logger';
8
7
  import { AgentGenerateOptions, AgentStreamOptions } from '@mastra/core/agent';
8
+ import { BaseLogMessage } from '@mastra/core/logger';
9
9
  import { RuntimeContext } from '@mastra/core/runtime-context';
10
10
  import { Workflow as Workflow$1, WorkflowResult, WatchEvent } from '@mastra/core/workflows';
11
11
  import { StepAction, StepGraph, LegacyWorkflowRunResult as LegacyWorkflowRunResult$1 } from '@mastra/core/workflows/legacy';
@@ -247,6 +247,32 @@ interface GetNetworkResponse {
247
247
  };
248
248
  state?: Record<string, any>;
249
249
  }
250
+ interface GetVNextNetworkResponse {
251
+ id: string;
252
+ name: string;
253
+ instructions: string;
254
+ agents: Array<{
255
+ name: string;
256
+ provider: string;
257
+ modelId: string;
258
+ }>;
259
+ routingModel: {
260
+ provider: string;
261
+ modelId: string;
262
+ };
263
+ workflows: Array<{
264
+ name: string;
265
+ description: string;
266
+ inputSchema: string | undefined;
267
+ outputSchema: string | undefined;
268
+ }>;
269
+ }
270
+ interface GenerateVNextNetworkResponse {
271
+ task: string;
272
+ result: string;
273
+ resourceId: string;
274
+ resourceType: 'none' | 'tool' | 'agent' | 'workflow';
275
+ }
250
276
  interface McpServerListResponse {
251
277
  servers: ServerInfo[];
252
278
  next: string | null;
@@ -629,9 +655,9 @@ declare class Workflow extends BaseResource {
629
655
  runtimeContext?: RuntimeContext | Record<string, any>;
630
656
  }): Promise<WorkflowRunResult>;
631
657
  /**
632
- * Starts a vNext workflow run and returns a stream
658
+ * Starts a workflow run and returns a stream
633
659
  * @param params - Object containing the optional runId, inputData and runtimeContext
634
- * @returns Promise containing the vNext workflow execution results
660
+ * @returns Promise containing the workflow execution results
635
661
  */
636
662
  stream(params: {
637
663
  runId?: string;
@@ -732,6 +758,32 @@ declare class MCPTool extends BaseResource {
732
758
  }): Promise<any>;
733
759
  }
734
760
 
761
+ declare class VNextNetwork extends BaseResource {
762
+ private networkId;
763
+ constructor(options: ClientOptions, networkId: string);
764
+ /**
765
+ * Retrieves details about the network
766
+ * @returns Promise containing vNext network details
767
+ */
768
+ details(): Promise<GetVNextNetworkResponse>;
769
+ /**
770
+ * Generates a response from the v-next network
771
+ * @param params - Generation parameters including message
772
+ * @returns Promise containing the generated response
773
+ */
774
+ generate(params: {
775
+ message: string;
776
+ }): Promise<GenerateVNextNetworkResponse>;
777
+ /**
778
+ * Streams a response from the v-next network
779
+ * @param params - Stream parameters including message
780
+ * @returns Promise containing the results
781
+ */
782
+ stream(params: {
783
+ message: string;
784
+ }): Promise<stream_web.ReadableStream<any>>;
785
+ }
786
+
735
787
  declare class MastraClient extends BaseResource {
736
788
  constructor(options: ClientOptions);
737
789
  /**
@@ -848,12 +900,23 @@ declare class MastraClient extends BaseResource {
848
900
  * @returns Promise containing map of network IDs to network details
849
901
  */
850
902
  getNetworks(): Promise<Record<string, GetNetworkResponse>>;
903
+ /**
904
+ * Retrieves all available vNext networks
905
+ * @returns Promise containing map of vNext network IDs to vNext network details
906
+ */
907
+ getVNextNetworks(): Promise<Record<string, GetVNextNetworkResponse>>;
851
908
  /**
852
909
  * Gets a network instance by ID
853
910
  * @param networkId - ID of the network to retrieve
854
911
  * @returns Network instance
855
912
  */
856
913
  getNetwork(networkId: string): Network;
914
+ /**
915
+ * Gets a vNext network instance by ID
916
+ * @param networkId - ID of the vNext network to retrieve
917
+ * @returns vNext Network instance
918
+ */
919
+ getVNextNetwork(networkId: string): VNextNetwork;
857
920
  /**
858
921
  * Retrieves a list of available MCP servers.
859
922
  * @param params - Optional parameters for pagination (limit, offset).
@@ -894,4 +957,4 @@ declare class MastraClient extends BaseResource {
894
957
  getA2A(agentId: string): A2A;
895
958
  }
896
959
 
897
- export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type GenerateParams, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLegacyWorkflowResponse, type GetLegacyWorkflowRunsResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesParams, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVectorIndexResponse, type GetWorkflowResponse, type GetWorkflowRunsParams, type GetWorkflowRunsResponse, type LegacyWorkflowRunResult, MastraClient, type McpServerListResponse, type McpServerToolListResponse, type McpToolInfo, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type WorkflowRunResult, type WorkflowWatchResult };
960
+ export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type GenerateParams, type GenerateVNextNetworkResponse, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLegacyWorkflowResponse, type GetLegacyWorkflowRunsResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesParams, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVNextNetworkResponse, type GetVectorIndexResponse, type GetWorkflowResponse, type GetWorkflowRunsParams, type GetWorkflowRunsResponse, type LegacyWorkflowRunResult, MastraClient, type McpServerListResponse, type McpServerToolListResponse, type McpToolInfo, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type WorkflowRunResult, type WorkflowWatchResult };
package/dist/index.js CHANGED
@@ -949,9 +949,9 @@ var Workflow = class extends BaseResource {
949
949
  });
950
950
  }
951
951
  /**
952
- * Starts a vNext workflow run and returns a stream
952
+ * Starts a workflow run and returns a stream
953
953
  * @param params - Object containing the optional runId, inputData and runtimeContext
954
- * @returns Promise containing the vNext workflow execution results
954
+ * @returns Promise containing the workflow execution results
955
955
  */
956
956
  async stream(params) {
957
957
  const searchParams = new URLSearchParams();
@@ -1163,6 +1163,72 @@ var MCPTool = class extends BaseResource {
1163
1163
  }
1164
1164
  };
1165
1165
 
1166
+ // src/resources/vNextNetwork.ts
1167
+ var RECORD_SEPARATOR3 = "";
1168
+ var VNextNetwork = class extends BaseResource {
1169
+ constructor(options, networkId) {
1170
+ super(options);
1171
+ this.networkId = networkId;
1172
+ }
1173
+ /**
1174
+ * Retrieves details about the network
1175
+ * @returns Promise containing vNext network details
1176
+ */
1177
+ details() {
1178
+ return this.request(`/api/networks/v-next/${this.networkId}`);
1179
+ }
1180
+ /**
1181
+ * Generates a response from the v-next network
1182
+ * @param params - Generation parameters including message
1183
+ * @returns Promise containing the generated response
1184
+ */
1185
+ generate(params) {
1186
+ return this.request(`/api/networks/${this.networkId}/generate`, {
1187
+ method: "POST",
1188
+ body: params
1189
+ });
1190
+ }
1191
+ /**
1192
+ * Streams a response from the v-next network
1193
+ * @param params - Stream parameters including message
1194
+ * @returns Promise containing the results
1195
+ */
1196
+ async stream(params) {
1197
+ const response = await this.request(`/api/networks/v-next/${this.networkId}/stream`, {
1198
+ method: "POST",
1199
+ body: { message: params.message },
1200
+ stream: true
1201
+ });
1202
+ if (!response.ok) {
1203
+ throw new Error(`Failed to stream vNext network: ${response.statusText}`);
1204
+ }
1205
+ if (!response.body) {
1206
+ throw new Error("Response body is null");
1207
+ }
1208
+ const transformStream = new TransformStream({
1209
+ start() {
1210
+ },
1211
+ async transform(chunk, controller) {
1212
+ try {
1213
+ const decoded = new TextDecoder().decode(chunk);
1214
+ const chunks = decoded.split(RECORD_SEPARATOR3);
1215
+ for (const chunk2 of chunks) {
1216
+ if (chunk2) {
1217
+ try {
1218
+ const parsedChunk = JSON.parse(chunk2);
1219
+ controller.enqueue(parsedChunk);
1220
+ } catch {
1221
+ }
1222
+ }
1223
+ }
1224
+ } catch {
1225
+ }
1226
+ }
1227
+ });
1228
+ return response.body.pipeThrough(transformStream);
1229
+ }
1230
+ };
1231
+
1166
1232
  // src/client.ts
1167
1233
  var MastraClient = class extends BaseResource {
1168
1234
  constructor(options) {
@@ -1365,6 +1431,13 @@ var MastraClient = class extends BaseResource {
1365
1431
  getNetworks() {
1366
1432
  return this.request("/api/networks");
1367
1433
  }
1434
+ /**
1435
+ * Retrieves all available vNext networks
1436
+ * @returns Promise containing map of vNext network IDs to vNext network details
1437
+ */
1438
+ getVNextNetworks() {
1439
+ return this.request("/api/networks/v-next");
1440
+ }
1368
1441
  /**
1369
1442
  * Gets a network instance by ID
1370
1443
  * @param networkId - ID of the network to retrieve
@@ -1373,6 +1446,14 @@ var MastraClient = class extends BaseResource {
1373
1446
  getNetwork(networkId) {
1374
1447
  return new Network(this.options, networkId);
1375
1448
  }
1449
+ /**
1450
+ * Gets a vNext network instance by ID
1451
+ * @param networkId - ID of the vNext network to retrieve
1452
+ * @returns vNext Network instance
1453
+ */
1454
+ getVNextNetwork(networkId) {
1455
+ return new VNextNetwork(this.options, networkId);
1456
+ }
1376
1457
  /**
1377
1458
  * Retrieves a list of available MCP servers.
1378
1459
  * @param params - Optional parameters for pagination (limit, offset).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/client-js",
3
- "version": "0.0.0-vnextAgentNetwork-20250527105810",
3
+ "version": "0.0.0-vnextAgentNetwork-20250602084555",
4
4
  "description": "The official TypeScript library for the Mastra Client API",
5
5
  "author": "",
6
6
  "type": "module",
@@ -42,8 +42,8 @@
42
42
  "tsup": "^8.4.0",
43
43
  "typescript": "^5.8.2",
44
44
  "vitest": "^3.1.2",
45
- "@internal/lint": "0.0.0-vnextAgentNetwork-20250527105810",
46
- "@mastra/core": "0.0.0-vnextAgentNetwork-20250527105810"
45
+ "@mastra/core": "0.0.0-vnextAgentNetwork-20250602084555",
46
+ "@internal/lint": "0.0.0-vnextAgentNetwork-20250602084555"
47
47
  },
48
48
  "scripts": {
49
49
  "build": "tsup src/index.ts --format esm,cjs --dts --clean --treeshake=smallest --splitting",
package/src/client.ts CHANGED
@@ -33,7 +33,9 @@ import type {
33
33
  McpServerListResponse,
34
34
  McpServerToolListResponse,
35
35
  GetLegacyWorkflowResponse,
36
+ GetVNextNetworkResponse,
36
37
  } from './types';
38
+ import { VNextNetwork } from './resources/vNextNetwork';
37
39
 
38
40
  export class MastraClient extends BaseResource {
39
41
  constructor(options: ClientOptions) {
@@ -262,6 +264,14 @@ export class MastraClient extends BaseResource {
262
264
  return this.request('/api/networks');
263
265
  }
264
266
 
267
+ /**
268
+ * Retrieves all available vNext networks
269
+ * @returns Promise containing map of vNext network IDs to vNext network details
270
+ */
271
+ public getVNextNetworks(): Promise<Record<string, GetVNextNetworkResponse>> {
272
+ return this.request('/api/networks/v-next');
273
+ }
274
+
265
275
  /**
266
276
  * Gets a network instance by ID
267
277
  * @param networkId - ID of the network to retrieve
@@ -271,6 +281,15 @@ export class MastraClient extends BaseResource {
271
281
  return new Network(this.options, networkId);
272
282
  }
273
283
 
284
+ /**
285
+ * Gets a vNext network instance by ID
286
+ * @param networkId - ID of the vNext network to retrieve
287
+ * @returns vNext Network instance
288
+ */
289
+ public getVNextNetwork(networkId: string) {
290
+ return new VNextNetwork(this.options, networkId);
291
+ }
292
+
274
293
  /**
275
294
  * Retrieves a list of available MCP servers.
276
295
  * @param params - Optional parameters for pagination (limit, offset).
@@ -1,10 +1,9 @@
1
1
  import { processDataStream } from '@ai-sdk/ui-utils';
2
2
  import type { GenerateReturn } from '@mastra/core';
3
3
  import type { JSONSchema7 } from 'json-schema';
4
- import { ZodSchema } from 'zod';
5
- import { zodToJsonSchema } from '../utils/zod-to-json-schema';
6
-
4
+ import type { ZodSchema } from 'zod';
7
5
  import type { GenerateParams, ClientOptions, StreamParams, GetNetworkResponse } from '../types';
6
+ import { zodToJsonSchema } from '../utils/zod-to-json-schema';
8
7
 
9
8
  import { BaseResource } from './base';
10
9
 
@@ -0,0 +1,86 @@
1
+ import type { ClientOptions, GetVNextNetworkResponse, GenerateVNextNetworkResponse } from '../types';
2
+
3
+ import { BaseResource } from './base';
4
+
5
+ const RECORD_SEPARATOR = '\x1E';
6
+
7
+ export class VNextNetwork extends BaseResource {
8
+ constructor(
9
+ options: ClientOptions,
10
+ private networkId: string,
11
+ ) {
12
+ super(options);
13
+ }
14
+
15
+ /**
16
+ * Retrieves details about the network
17
+ * @returns Promise containing vNext network details
18
+ */
19
+ details(): Promise<GetVNextNetworkResponse> {
20
+ return this.request(`/api/networks/v-next/${this.networkId}`);
21
+ }
22
+
23
+ /**
24
+ * Generates a response from the v-next network
25
+ * @param params - Generation parameters including message
26
+ * @returns Promise containing the generated response
27
+ */
28
+ generate(params: { message: string }): Promise<GenerateVNextNetworkResponse> {
29
+ return this.request(`/api/networks/${this.networkId}/generate`, {
30
+ method: 'POST',
31
+ body: params,
32
+ });
33
+ }
34
+
35
+ /**
36
+ * Streams a response from the v-next network
37
+ * @param params - Stream parameters including message
38
+ * @returns Promise containing the results
39
+ */
40
+ async stream(params: { message: string }) {
41
+ const response: Response = await this.request(`/api/networks/v-next/${this.networkId}/stream`, {
42
+ method: 'POST',
43
+ body: { message: params.message },
44
+ stream: true,
45
+ });
46
+
47
+ if (!response.ok) {
48
+ throw new Error(`Failed to stream vNext network: ${response.statusText}`);
49
+ }
50
+
51
+ if (!response.body) {
52
+ throw new Error('Response body is null');
53
+ }
54
+
55
+ // Create a transform stream that processes the response body
56
+ const transformStream = new TransformStream({
57
+ start() {},
58
+ async transform(chunk, controller) {
59
+ try {
60
+ // Decode binary data to text
61
+ const decoded = new TextDecoder().decode(chunk);
62
+
63
+ // Split by record separator
64
+ const chunks = decoded.split(RECORD_SEPARATOR);
65
+
66
+ // Process each chunk
67
+ for (const chunk of chunks) {
68
+ if (chunk) {
69
+ try {
70
+ const parsedChunk = JSON.parse(chunk);
71
+ controller.enqueue(parsedChunk);
72
+ } catch {
73
+ // Silently ignore parsing errors
74
+ }
75
+ }
76
+ }
77
+ } catch {
78
+ // Silently ignore processing errors
79
+ }
80
+ },
81
+ });
82
+
83
+ // Pipe the response body through the transform stream
84
+ return response.body.pipeThrough(transformStream);
85
+ }
86
+ }
@@ -217,9 +217,9 @@ export class Workflow extends BaseResource {
217
217
  }
218
218
 
219
219
  /**
220
- * Starts a vNext workflow run and returns a stream
220
+ * Starts a workflow run and returns a stream
221
221
  * @param params - Object containing the optional runId, inputData and runtimeContext
222
- * @returns Promise containing the vNext workflow execution results
222
+ * @returns Promise containing the workflow execution results
223
223
  */
224
224
  async stream(params: { runId?: string; inputData: Record<string, any>; runtimeContext?: RuntimeContext }) {
225
225
  const searchParams = new URLSearchParams();
package/src/types.ts CHANGED
@@ -7,9 +7,9 @@ import type {
7
7
  WorkflowRuns,
8
8
  LegacyWorkflowRuns,
9
9
  } from '@mastra/core';
10
+ import type { AgentGenerateOptions, AgentStreamOptions } from '@mastra/core/agent';
10
11
  import type { BaseLogMessage } from '@mastra/core/logger';
11
12
 
12
- import type { AgentGenerateOptions, AgentStreamOptions } from '@mastra/core/agent';
13
13
  import type { ServerInfo } from '@mastra/core/mcp';
14
14
  import type { RuntimeContext } from '@mastra/core/runtime-context';
15
15
  import type { Workflow, WatchEvent, WorkflowResult } from '@mastra/core/workflows';
@@ -293,6 +293,34 @@ export interface GetNetworkResponse {
293
293
  state?: Record<string, any>;
294
294
  }
295
295
 
296
+ export interface GetVNextNetworkResponse {
297
+ id: string;
298
+ name: string;
299
+ instructions: string;
300
+ agents: Array<{
301
+ name: string;
302
+ provider: string;
303
+ modelId: string;
304
+ }>;
305
+ routingModel: {
306
+ provider: string;
307
+ modelId: string;
308
+ };
309
+ workflows: Array<{
310
+ name: string;
311
+ description: string;
312
+ inputSchema: string | undefined;
313
+ outputSchema: string | undefined;
314
+ }>;
315
+ }
316
+
317
+ export interface GenerateVNextNetworkResponse {
318
+ task: string;
319
+ result: string;
320
+ resourceId: string;
321
+ resourceType: 'none' | 'tool' | 'agent' | 'workflow';
322
+ }
323
+
296
324
  export interface McpServerListResponse {
297
325
  servers: ServerInfo[];
298
326
  next: string | null;