@mastra/client-js 0.1.10 → 0.1.11-alpha.0

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @mastra/client-js@0.1.10-alpha.0 build /home/runner/work/mastra/mastra/client-sdks/client-js
2
+ > @mastra/client-js@0.1.11-alpha.0 build /home/runner/work/mastra/mastra/client-sdks/client-js
3
3
  > tsup src/index.ts --format esm,cjs --dts --clean --treeshake=smallest --splitting
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -9,11 +9,11 @@
9
9
  CLI Cleaning output folder
10
10
  ESM Build start
11
11
  CJS Build start
12
- CJS dist/index.cjs 17.58 KB
13
- CJS ⚡️ Build success in 787ms
14
- ESM dist/index.js 17.49 KB
15
- ESM ⚡️ Build success in 789ms
12
+ CJS dist/index.cjs 19.59 KB
13
+ CJS ⚡️ Build success in 991ms
14
+ ESM dist/index.js 19.41 KB
15
+ ESM ⚡️ Build success in 997ms
16
16
  DTS Build start
17
- DTS ⚡️ Build success in 10226ms
18
- DTS dist/index.d.ts 16.15 KB
19
- DTS dist/index.d.cts 16.15 KB
17
+ DTS ⚡️ Build success in 9664ms
18
+ DTS dist/index.d.ts 17.68 KB
19
+ DTS dist/index.d.cts 17.68 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @mastra/client-js
2
2
 
3
+ ## 0.1.11-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 404640e: AgentNetwork changeset
8
+ - Updated dependencies [404640e]
9
+ - @mastra/core@0.6.3-alpha.0
10
+
3
11
  ## 0.1.10
4
12
 
5
13
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -132,6 +132,52 @@ var Agent = class extends BaseResource {
132
132
  return this.request(`/api/agents/${this.agentId}/evals/live`);
133
133
  }
134
134
  };
135
+ var Network = class extends BaseResource {
136
+ constructor(options, networkId) {
137
+ super(options);
138
+ this.networkId = networkId;
139
+ }
140
+ /**
141
+ * Retrieves details about the network
142
+ * @returns Promise containing network details
143
+ */
144
+ details() {
145
+ return this.request(`/api/networks/${this.networkId}`);
146
+ }
147
+ /**
148
+ * Generates a response from the agent
149
+ * @param params - Generation parameters including prompt
150
+ * @returns Promise containing the generated response
151
+ */
152
+ generate(params) {
153
+ const processedParams = {
154
+ ...params,
155
+ output: params.output instanceof zod.ZodSchema ? zodToJsonSchema.zodToJsonSchema(params.output) : params.output,
156
+ experimental_output: params.experimental_output instanceof zod.ZodSchema ? zodToJsonSchema.zodToJsonSchema(params.experimental_output) : params.experimental_output
157
+ };
158
+ return this.request(`/api/networks/${this.networkId}/generate`, {
159
+ method: "POST",
160
+ body: processedParams
161
+ });
162
+ }
163
+ /**
164
+ * Streams a response from the agent
165
+ * @param params - Stream parameters including prompt
166
+ * @returns Promise containing the streamed response
167
+ */
168
+ stream(params) {
169
+ const processedParams = {
170
+ ...params,
171
+ output: params.output instanceof zod.ZodSchema ? zodToJsonSchema.zodToJsonSchema(params.output) : params.output,
172
+ experimental_output: params.experimental_output instanceof zod.ZodSchema ? zodToJsonSchema.zodToJsonSchema(params.experimental_output) : params.experimental_output
173
+ };
174
+ return this.request(`/api/networks/${this.networkId}/stream`, {
175
+ method: "POST",
176
+ body: processedParams,
177
+ stream: true
178
+ });
179
+ }
180
+ };
135
181
 
136
182
  // src/resources/memory-thread.ts
137
183
  var MemoryThread = class extends BaseResource {
@@ -589,6 +635,21 @@ var MastraClient = class extends BaseResource {
589
635
  return this.request(`/api/telemetry`);
590
636
  }
591
637
  }
638
+ /**
639
+ * Retrieves all available networks
640
+ * @returns Promise containing map of network IDs to network details
641
+ */
642
+ getNetworks() {
643
+ return this.request("/api/networks");
644
+ }
645
+ /**
646
+ * Gets a network instance by ID
647
+ * @param networkId - ID of the network to retrieve
648
+ * @returns Network instance
649
+ */
650
+ getNetwork(networkId) {
651
+ return new Network(this.options, networkId);
652
+ }
592
653
  };
593
654
 
594
655
  exports.MastraClient = MastraClient;
package/dist/index.d.cts CHANGED
@@ -147,6 +147,20 @@ interface GetTelemetryParams {
147
147
  perPage?: number;
148
148
  attribute?: Record<string, string>;
149
149
  }
150
+ interface GetNetworkResponse {
151
+ name: string;
152
+ instructions: string;
153
+ agents: Array<{
154
+ name: string;
155
+ provider: string;
156
+ modelId: string;
157
+ }>;
158
+ routingModel: {
159
+ provider: string;
160
+ modelId: string;
161
+ };
162
+ state?: Record<string, any>;
163
+ }
150
164
 
151
165
  declare class BaseResource {
152
166
  readonly options: ClientOptions;
@@ -198,6 +212,28 @@ declare class Agent extends BaseResource {
198
212
  liveEvals(): Promise<GetEvalsByAgentIdResponse>;
199
213
  }
200
214
 
215
+ declare class Network extends BaseResource {
216
+ private networkId;
217
+ constructor(options: ClientOptions, networkId: string);
218
+ /**
219
+ * Retrieves details about the network
220
+ * @returns Promise containing network details
221
+ */
222
+ details(): Promise<GetNetworkResponse>;
223
+ /**
224
+ * Generates a response from the agent
225
+ * @param params - Generation parameters including prompt
226
+ * @returns Promise containing the generated response
227
+ */
228
+ generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T>): Promise<GenerateReturn<T>>;
229
+ /**
230
+ * Streams a response from the agent
231
+ * @param params - Stream parameters including prompt
232
+ * @returns Promise containing the streamed response
233
+ */
234
+ stream<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: StreamParams<T>): Promise<Response>;
235
+ }
236
+
201
237
  declare class MemoryThread extends BaseResource {
202
238
  private threadId;
203
239
  private agentId;
@@ -473,6 +509,17 @@ declare class MastraClient extends BaseResource {
473
509
  * @returns Promise containing telemetry data
474
510
  */
475
511
  getTelemetry(params?: GetTelemetryParams): Promise<GetTelemetryResponse>;
512
+ /**
513
+ * Retrieves all available networks
514
+ * @returns Promise containing map of network IDs to network details
515
+ */
516
+ getNetworks(): Promise<Record<string, GetNetworkResponse>>;
517
+ /**
518
+ * Gets a network instance by ID
519
+ * @param networkId - ID of the network to retrieve
520
+ * @returns Network instance
521
+ */
522
+ getNetwork(networkId: string): Network;
476
523
  }
477
524
 
478
- export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type GenerateParams, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVectorIndexResponse, type GetWorkflowResponse, MastraClient, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type WorkflowRunResult };
525
+ export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type GenerateParams, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVectorIndexResponse, type GetWorkflowResponse, MastraClient, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type WorkflowRunResult };
package/dist/index.d.ts CHANGED
@@ -147,6 +147,20 @@ interface GetTelemetryParams {
147
147
  perPage?: number;
148
148
  attribute?: Record<string, string>;
149
149
  }
150
+ interface GetNetworkResponse {
151
+ name: string;
152
+ instructions: string;
153
+ agents: Array<{
154
+ name: string;
155
+ provider: string;
156
+ modelId: string;
157
+ }>;
158
+ routingModel: {
159
+ provider: string;
160
+ modelId: string;
161
+ };
162
+ state?: Record<string, any>;
163
+ }
150
164
 
151
165
  declare class BaseResource {
152
166
  readonly options: ClientOptions;
@@ -198,6 +212,28 @@ declare class Agent extends BaseResource {
198
212
  liveEvals(): Promise<GetEvalsByAgentIdResponse>;
199
213
  }
200
214
 
215
+ declare class Network extends BaseResource {
216
+ private networkId;
217
+ constructor(options: ClientOptions, networkId: string);
218
+ /**
219
+ * Retrieves details about the network
220
+ * @returns Promise containing network details
221
+ */
222
+ details(): Promise<GetNetworkResponse>;
223
+ /**
224
+ * Generates a response from the agent
225
+ * @param params - Generation parameters including prompt
226
+ * @returns Promise containing the generated response
227
+ */
228
+ generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T>): Promise<GenerateReturn<T>>;
229
+ /**
230
+ * Streams a response from the agent
231
+ * @param params - Stream parameters including prompt
232
+ * @returns Promise containing the streamed response
233
+ */
234
+ stream<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: StreamParams<T>): Promise<Response>;
235
+ }
236
+
201
237
  declare class MemoryThread extends BaseResource {
202
238
  private threadId;
203
239
  private agentId;
@@ -473,6 +509,17 @@ declare class MastraClient extends BaseResource {
473
509
  * @returns Promise containing telemetry data
474
510
  */
475
511
  getTelemetry(params?: GetTelemetryParams): Promise<GetTelemetryResponse>;
512
+ /**
513
+ * Retrieves all available networks
514
+ * @returns Promise containing map of network IDs to network details
515
+ */
516
+ getNetworks(): Promise<Record<string, GetNetworkResponse>>;
517
+ /**
518
+ * Gets a network instance by ID
519
+ * @param networkId - ID of the network to retrieve
520
+ * @returns Network instance
521
+ */
522
+ getNetwork(networkId: string): Network;
476
523
  }
477
524
 
478
- export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type GenerateParams, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVectorIndexResponse, type GetWorkflowResponse, MastraClient, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type WorkflowRunResult };
525
+ export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type GenerateParams, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVectorIndexResponse, type GetWorkflowResponse, MastraClient, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type WorkflowRunResult };
package/dist/index.js CHANGED
@@ -130,6 +130,52 @@ var Agent = class extends BaseResource {
130
130
  return this.request(`/api/agents/${this.agentId}/evals/live`);
131
131
  }
132
132
  };
133
+ var Network = class extends BaseResource {
134
+ constructor(options, networkId) {
135
+ super(options);
136
+ this.networkId = networkId;
137
+ }
138
+ /**
139
+ * Retrieves details about the network
140
+ * @returns Promise containing network details
141
+ */
142
+ details() {
143
+ return this.request(`/api/networks/${this.networkId}`);
144
+ }
145
+ /**
146
+ * Generates a response from the agent
147
+ * @param params - Generation parameters including prompt
148
+ * @returns Promise containing the generated response
149
+ */
150
+ generate(params) {
151
+ const processedParams = {
152
+ ...params,
153
+ output: params.output instanceof ZodSchema ? zodToJsonSchema(params.output) : params.output,
154
+ experimental_output: params.experimental_output instanceof ZodSchema ? zodToJsonSchema(params.experimental_output) : params.experimental_output
155
+ };
156
+ return this.request(`/api/networks/${this.networkId}/generate`, {
157
+ method: "POST",
158
+ body: processedParams
159
+ });
160
+ }
161
+ /**
162
+ * Streams a response from the agent
163
+ * @param params - Stream parameters including prompt
164
+ * @returns Promise containing the streamed response
165
+ */
166
+ stream(params) {
167
+ const processedParams = {
168
+ ...params,
169
+ output: params.output instanceof ZodSchema ? zodToJsonSchema(params.output) : params.output,
170
+ experimental_output: params.experimental_output instanceof ZodSchema ? zodToJsonSchema(params.experimental_output) : params.experimental_output
171
+ };
172
+ return this.request(`/api/networks/${this.networkId}/stream`, {
173
+ method: "POST",
174
+ body: processedParams,
175
+ stream: true
176
+ });
177
+ }
178
+ };
133
179
 
134
180
  // src/resources/memory-thread.ts
135
181
  var MemoryThread = class extends BaseResource {
@@ -587,6 +633,21 @@ var MastraClient = class extends BaseResource {
587
633
  return this.request(`/api/telemetry`);
588
634
  }
589
635
  }
636
+ /**
637
+ * Retrieves all available networks
638
+ * @returns Promise containing map of network IDs to network details
639
+ */
640
+ getNetworks() {
641
+ return this.request("/api/networks");
642
+ }
643
+ /**
644
+ * Gets a network instance by ID
645
+ * @param networkId - ID of the network to retrieve
646
+ * @returns Network instance
647
+ */
648
+ getNetwork(networkId) {
649
+ return new Network(this.options, networkId);
650
+ }
590
651
  };
591
652
 
592
653
  export { MastraClient };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/client-js",
3
- "version": "0.1.10",
3
+ "version": "0.1.11-alpha.0",
4
4
  "description": "The official TypeScript library for the Mastra Client API",
5
5
  "author": "",
6
6
  "type": "module",
@@ -25,7 +25,7 @@
25
25
  "json-schema": "^0.4.0",
26
26
  "zod": "^3.24.2",
27
27
  "zod-to-json-schema": "^3.24.3",
28
- "@mastra/core": "^0.6.2"
28
+ "@mastra/core": "^0.6.3-alpha.0"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@babel/preset-env": "^7.26.9",
package/src/client.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Agent, MemoryThread, Tool, Workflow, Vector, BaseResource } from './resources';
1
+ import { Agent, MemoryThread, Tool, Workflow, Vector, BaseResource, Network } from './resources';
2
2
  import type {
3
3
  ClientOptions,
4
4
  CreateMemoryThreadParams,
@@ -9,6 +9,7 @@ import type {
9
9
  GetLogsResponse,
10
10
  GetMemoryThreadParams,
11
11
  GetMemoryThreadResponse,
12
+ GetNetworkResponse,
12
13
  GetTelemetryParams,
13
14
  GetTelemetryResponse,
14
15
  GetToolResponse,
@@ -202,4 +203,21 @@ export class MastraClient extends BaseResource {
202
203
  return this.request(`/api/telemetry`);
203
204
  }
204
205
  }
206
+
207
+ /**
208
+ * Retrieves all available networks
209
+ * @returns Promise containing map of network IDs to network details
210
+ */
211
+ public getNetworks(): Promise<Record<string, GetNetworkResponse>> {
212
+ return this.request('/api/networks');
213
+ }
214
+
215
+ /**
216
+ * Gets a network instance by ID
217
+ * @param networkId - ID of the network to retrieve
218
+ * @returns Network instance
219
+ */
220
+ public getNetwork(networkId: string) {
221
+ return new Network(this.options, networkId);
222
+ }
205
223
  }
@@ -1,4 +1,5 @@
1
1
  export * from './agent';
2
+ export * from './network';
2
3
  export * from './memory-thread';
3
4
  export * from './vector';
4
5
  export * from './workflow';
@@ -0,0 +1,70 @@
1
+ import type { GenerateReturn } from '@mastra/core';
2
+ import type { JSONSchema7 } from 'json-schema';
3
+ import { ZodSchema } from 'zod';
4
+ import { zodToJsonSchema } from 'zod-to-json-schema';
5
+
6
+ import type { GenerateParams, ClientOptions, StreamParams, GetNetworkResponse } from '../types';
7
+
8
+ import { BaseResource } from './base';
9
+
10
+ export class Network extends BaseResource {
11
+ constructor(
12
+ options: ClientOptions,
13
+ private networkId: string,
14
+ ) {
15
+ super(options);
16
+ }
17
+
18
+ /**
19
+ * Retrieves details about the network
20
+ * @returns Promise containing network details
21
+ */
22
+ details(): Promise<GetNetworkResponse> {
23
+ return this.request(`/api/networks/${this.networkId}`);
24
+ }
25
+
26
+ /**
27
+ * Generates a response from the agent
28
+ * @param params - Generation parameters including prompt
29
+ * @returns Promise containing the generated response
30
+ */
31
+ generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(
32
+ params: GenerateParams<T>,
33
+ ): Promise<GenerateReturn<T>> {
34
+ const processedParams = {
35
+ ...params,
36
+ output: params.output instanceof ZodSchema ? zodToJsonSchema(params.output) : params.output,
37
+ experimental_output:
38
+ params.experimental_output instanceof ZodSchema
39
+ ? zodToJsonSchema(params.experimental_output)
40
+ : params.experimental_output,
41
+ };
42
+
43
+ return this.request(`/api/networks/${this.networkId}/generate`, {
44
+ method: 'POST',
45
+ body: processedParams,
46
+ });
47
+ }
48
+
49
+ /**
50
+ * Streams a response from the agent
51
+ * @param params - Stream parameters including prompt
52
+ * @returns Promise containing the streamed response
53
+ */
54
+ stream<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: StreamParams<T>): Promise<Response> {
55
+ const processedParams = {
56
+ ...params,
57
+ output: params.output instanceof ZodSchema ? zodToJsonSchema(params.output) : params.output,
58
+ experimental_output:
59
+ params.experimental_output instanceof ZodSchema
60
+ ? zodToJsonSchema(params.experimental_output)
61
+ : params.experimental_output,
62
+ };
63
+
64
+ return this.request(`/api/networks/${this.networkId}/stream`, {
65
+ method: 'POST',
66
+ body: processedParams,
67
+ stream: true,
68
+ });
69
+ }
70
+ }
package/src/types.ts CHANGED
@@ -7,12 +7,11 @@ import type {
7
7
  StepGraph,
8
8
  StorageThreadType,
9
9
  BaseLogMessage,
10
- OutputType,
11
10
  } from '@mastra/core';
12
11
 
13
12
  import type { AgentGenerateOptions, AgentStreamOptions } from '@mastra/core/agent';
14
13
  import type { JSONSchema7 } from 'json-schema';
15
- import { ZodSchema } from 'zod';
14
+ import type { ZodSchema } from 'zod';
16
15
 
17
16
  export interface ClientOptions {
18
17
  /** Base URL for API requests */
@@ -190,3 +189,18 @@ export interface GetTelemetryParams {
190
189
  perPage?: number;
191
190
  attribute?: Record<string, string>;
192
191
  }
192
+
193
+ export interface GetNetworkResponse {
194
+ name: string;
195
+ instructions: string;
196
+ agents: Array<{
197
+ name: string;
198
+ provider: string;
199
+ modelId: string;
200
+ }>;
201
+ routingModel: {
202
+ provider: string;
203
+ modelId: string;
204
+ };
205
+ state?: Record<string, any>;
206
+ }