@mastra/client-js 0.0.0-taofeeqInngest-20250603090617 → 0.0.0-transpile-packages-20250724123433

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.
@@ -5,6 +5,8 @@ import type {
5
5
  ClientOptions,
6
6
  UpdateMemoryThreadParams,
7
7
  GetMemoryThreadMessagesParams,
8
+ GetMemoryThreadMessagesPaginatedParams,
9
+ GetMemoryThreadMessagesPaginatedResponse,
8
10
  } from '../types';
9
11
 
10
12
  import { BaseResource } from './base';
@@ -60,4 +62,20 @@ export class MemoryThread extends BaseResource {
60
62
  });
61
63
  return this.request(`/api/memory/threads/${this.threadId}/messages?${query.toString()}`);
62
64
  }
65
+
66
+ /**
67
+ * Retrieves paginated messages associated with the thread with advanced filtering and selection options
68
+ * @param params - Pagination parameters including selectBy criteria, page, perPage, date ranges, and message inclusion options
69
+ * @returns Promise containing paginated thread messages with pagination metadata (total, page, perPage, hasMore)
70
+ */
71
+ getMessagesPaginated({
72
+ selectBy,
73
+ ...rest
74
+ }: GetMemoryThreadMessagesPaginatedParams): Promise<GetMemoryThreadMessagesPaginatedResponse> {
75
+ const query = new URLSearchParams({
76
+ ...rest,
77
+ ...(selectBy ? { selectBy: JSON.stringify(selectBy) } : {}),
78
+ });
79
+ return this.request(`/api/memory/threads/${this.threadId}/messages/paginated?${query.toString()}`);
80
+ }
63
81
  }
@@ -0,0 +1,63 @@
1
+ import type { StorageThreadType } from '@mastra/core';
2
+
3
+ import type {
4
+ GetMemoryThreadMessagesResponse,
5
+ ClientOptions,
6
+ UpdateMemoryThreadParams,
7
+ GetMemoryThreadMessagesParams,
8
+ } from '../types';
9
+
10
+ import { BaseResource } from './base';
11
+
12
+ export class NetworkMemoryThread extends BaseResource {
13
+ constructor(
14
+ options: ClientOptions,
15
+ private threadId: string,
16
+ private networkId: string,
17
+ ) {
18
+ super(options);
19
+ }
20
+
21
+ /**
22
+ * Retrieves the memory thread details
23
+ * @returns Promise containing thread details including title and metadata
24
+ */
25
+ get(): Promise<StorageThreadType> {
26
+ return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`);
27
+ }
28
+
29
+ /**
30
+ * Updates the memory thread properties
31
+ * @param params - Update parameters including title and metadata
32
+ * @returns Promise containing updated thread details
33
+ */
34
+ update(params: UpdateMemoryThreadParams): Promise<StorageThreadType> {
35
+ return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`, {
36
+ method: 'PATCH',
37
+ body: params,
38
+ });
39
+ }
40
+
41
+ /**
42
+ * Deletes the memory thread
43
+ * @returns Promise containing deletion result
44
+ */
45
+ delete(): Promise<{ result: string }> {
46
+ return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`, {
47
+ method: 'DELETE',
48
+ });
49
+ }
50
+
51
+ /**
52
+ * Retrieves messages associated with the thread
53
+ * @param params - Optional parameters including limit for number of messages to retrieve
54
+ * @returns Promise containing thread messages and UI messages
55
+ */
56
+ getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse> {
57
+ const query = new URLSearchParams({
58
+ networkId: this.networkId,
59
+ ...(params?.limit ? { limit: params.limit.toString() } : {}),
60
+ });
61
+ return this.request(`/api/memory/network/threads/${this.threadId}/messages?${query.toString()}`);
62
+ }
63
+ }
@@ -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,194 @@
1
+ import type { WatchEvent } from '@mastra/core/workflows';
2
+
3
+ import type {
4
+ ClientOptions,
5
+ GetVNextNetworkResponse,
6
+ GenerateVNextNetworkResponse,
7
+ LoopVNextNetworkResponse,
8
+ GenerateOrStreamVNextNetworkParams,
9
+ LoopStreamVNextNetworkParams,
10
+ } from '../types';
11
+
12
+ import { BaseResource } from './base';
13
+ import { parseClientRuntimeContext } from '../utils';
14
+ import type { RuntimeContext } from '@mastra/core/runtime-context';
15
+
16
+ const RECORD_SEPARATOR = '\x1E';
17
+
18
+ export class VNextNetwork extends BaseResource {
19
+ constructor(
20
+ options: ClientOptions,
21
+ private networkId: string,
22
+ ) {
23
+ super(options);
24
+ }
25
+
26
+ /**
27
+ * Retrieves details about the network
28
+ * @returns Promise containing vNext network details
29
+ */
30
+ details(): Promise<GetVNextNetworkResponse> {
31
+ return this.request(`/api/networks/v-next/${this.networkId}`);
32
+ }
33
+
34
+ /**
35
+ * Generates a response from the v-next network
36
+ * @param params - Generation parameters including message
37
+ * @returns Promise containing the generated response
38
+ */
39
+ generate(params: GenerateOrStreamVNextNetworkParams): Promise<GenerateVNextNetworkResponse> {
40
+ return this.request(`/api/networks/v-next/${this.networkId}/generate`, {
41
+ method: 'POST',
42
+ body: {
43
+ ...params,
44
+ runtimeContext: parseClientRuntimeContext(params.runtimeContext),
45
+ },
46
+ });
47
+ }
48
+
49
+ /**
50
+ * Generates a response from the v-next network using multiple primitives
51
+ * @param params - Generation parameters including message
52
+ * @returns Promise containing the generated response
53
+ */
54
+ loop(params: {
55
+ message: string;
56
+ runtimeContext?: RuntimeContext | Record<string, any>;
57
+ }): Promise<LoopVNextNetworkResponse> {
58
+ return this.request(`/api/networks/v-next/${this.networkId}/loop`, {
59
+ method: 'POST',
60
+ body: {
61
+ ...params,
62
+ runtimeContext: parseClientRuntimeContext(params.runtimeContext),
63
+ },
64
+ });
65
+ }
66
+
67
+ private async *streamProcessor(stream: ReadableStream): AsyncGenerator<WatchEvent, void, unknown> {
68
+ const reader = stream.getReader();
69
+
70
+ // Track if we've finished reading from the stream
71
+ let doneReading = false;
72
+ // Buffer to accumulate partial chunks
73
+ let buffer = '';
74
+
75
+ try {
76
+ while (!doneReading) {
77
+ // Read the next chunk from the stream
78
+ const { done, value } = await reader.read();
79
+ doneReading = done;
80
+
81
+ // Skip processing if we're done and there's no value
82
+ if (done && !value) continue;
83
+
84
+ try {
85
+ // Decode binary data to text
86
+ const decoded = value ? new TextDecoder().decode(value) : '';
87
+
88
+ // Split the combined buffer and new data by record separator
89
+ const chunks = (buffer + decoded).split(RECORD_SEPARATOR);
90
+
91
+ // The last chunk might be incomplete, so save it for the next iteration
92
+ buffer = chunks.pop() || '';
93
+
94
+ // Process complete chunks
95
+ for (const chunk of chunks) {
96
+ if (chunk) {
97
+ // Only process non-empty chunks
98
+ if (typeof chunk === 'string') {
99
+ try {
100
+ const parsedChunk = JSON.parse(chunk);
101
+ yield parsedChunk;
102
+ } catch {
103
+ // Silently ignore parsing errors to maintain stream processing
104
+ // This allows the stream to continue even if one record is malformed
105
+ }
106
+ }
107
+ }
108
+ }
109
+ } catch {
110
+ // Silently ignore parsing errors to maintain stream processing
111
+ // This allows the stream to continue even if one record is malformed
112
+ }
113
+ }
114
+
115
+ // Process any remaining data in the buffer after stream is done
116
+ if (buffer) {
117
+ try {
118
+ yield JSON.parse(buffer);
119
+ } catch {
120
+ // Ignore parsing error for final chunk
121
+ }
122
+ }
123
+ } finally {
124
+ // Always ensure we clean up the reader
125
+ reader.cancel().catch(() => {
126
+ // Ignore cancel errors
127
+ });
128
+ }
129
+ }
130
+
131
+ /**
132
+ * Streams a response from the v-next network
133
+ * @param params - Stream parameters including message
134
+ * @returns Promise containing the results
135
+ */
136
+ async stream(params: GenerateOrStreamVNextNetworkParams, onRecord: (record: WatchEvent) => void) {
137
+ const response: Response = await this.request(`/api/networks/v-next/${this.networkId}/stream`, {
138
+ method: 'POST',
139
+ body: {
140
+ ...params,
141
+ runtimeContext: parseClientRuntimeContext(params.runtimeContext),
142
+ },
143
+ stream: true,
144
+ });
145
+
146
+ if (!response.ok) {
147
+ throw new Error(`Failed to stream vNext network: ${response.statusText}`);
148
+ }
149
+
150
+ if (!response.body) {
151
+ throw new Error('Response body is null');
152
+ }
153
+
154
+ for await (const record of this.streamProcessor(response.body)) {
155
+ if (typeof record === 'string') {
156
+ onRecord(JSON.parse(record));
157
+ } else {
158
+ onRecord(record);
159
+ }
160
+ }
161
+ }
162
+
163
+ /**
164
+ * Streams a response from the v-next network loop
165
+ * @param params - Stream parameters including message
166
+ * @returns Promise containing the results
167
+ */
168
+ async loopStream(params: LoopStreamVNextNetworkParams, onRecord: (record: WatchEvent) => void) {
169
+ const response: Response = await this.request(`/api/networks/v-next/${this.networkId}/loop-stream`, {
170
+ method: 'POST',
171
+ body: {
172
+ ...params,
173
+ runtimeContext: parseClientRuntimeContext(params.runtimeContext),
174
+ },
175
+ stream: true,
176
+ });
177
+
178
+ if (!response.ok) {
179
+ throw new Error(`Failed to stream vNext network loop: ${response.statusText}`);
180
+ }
181
+
182
+ if (!response.body) {
183
+ throw new Error('Response body is null');
184
+ }
185
+
186
+ for await (const record of this.streamProcessor(response.body)) {
187
+ if (typeof record === 'string') {
188
+ onRecord(JSON.parse(record));
189
+ } else {
190
+ onRecord(record);
191
+ }
192
+ }
193
+ }
194
+ }
@@ -6,6 +6,8 @@ import type {
6
6
  GetWorkflowRunsParams,
7
7
  WorkflowRunResult,
8
8
  WorkflowWatchResult,
9
+ GetWorkflowRunByIdResponse,
10
+ GetWorkflowRunExecutionResultResponse,
9
11
  } from '../types';
10
12
 
11
13
  import { parseClientRuntimeContext } from '../utils';
@@ -113,10 +115,10 @@ export class Workflow extends BaseResource {
113
115
  if (params?.toDate) {
114
116
  searchParams.set('toDate', params.toDate.toISOString());
115
117
  }
116
- if (params?.limit) {
118
+ if (params?.limit !== null && params?.limit !== undefined && !isNaN(Number(params?.limit))) {
117
119
  searchParams.set('limit', String(params.limit));
118
120
  }
119
- if (params?.offset) {
121
+ if (params?.offset !== null && params?.offset !== undefined && !isNaN(Number(params?.offset))) {
120
122
  searchParams.set('offset', String(params.offset));
121
123
  }
122
124
  if (params?.resourceId) {
@@ -130,6 +132,47 @@ export class Workflow extends BaseResource {
130
132
  }
131
133
  }
132
134
 
135
+ /**
136
+ * Retrieves a specific workflow run by its ID
137
+ * @param runId - The ID of the workflow run to retrieve
138
+ * @returns Promise containing the workflow run details
139
+ */
140
+ runById(runId: string): Promise<GetWorkflowRunByIdResponse> {
141
+ return this.request(`/api/workflows/${this.workflowId}/runs/${runId}`);
142
+ }
143
+
144
+ /**
145
+ * Retrieves the execution result for a specific workflow run by its ID
146
+ * @param runId - The ID of the workflow run to retrieve the execution result for
147
+ * @returns Promise containing the workflow run execution result
148
+ */
149
+ runExecutionResult(runId: string): Promise<GetWorkflowRunExecutionResultResponse> {
150
+ return this.request(`/api/workflows/${this.workflowId}/runs/${runId}/execution-result`);
151
+ }
152
+
153
+ /**
154
+ * Cancels a specific workflow run by its ID
155
+ * @param runId - The ID of the workflow run to cancel
156
+ * @returns Promise containing a success message
157
+ */
158
+ cancelRun(runId: string): Promise<{ message: string }> {
159
+ return this.request(`/api/workflows/${this.workflowId}/runs/${runId}/cancel`, {
160
+ method: 'POST',
161
+ });
162
+ }
163
+
164
+ /**
165
+ * Sends an event to a specific workflow run by its ID
166
+ * @param params - Object containing the runId, event and data
167
+ * @returns Promise containing a success message
168
+ */
169
+ sendRunEvent(params: { runId: string; event: string; data: unknown }): Promise<{ message: string }> {
170
+ return this.request(`/api/workflows/${this.workflowId}/runs/${params.runId}/send-event`, {
171
+ method: 'POST',
172
+ body: { event: params.event, data: params.data },
173
+ });
174
+ }
175
+
133
176
  /**
134
177
  * Creates a new workflow run
135
178
  * @param params - Optional object containing the optional runId
@@ -147,6 +190,15 @@ export class Workflow extends BaseResource {
147
190
  });
148
191
  }
149
192
 
193
+ /**
194
+ * Creates a new workflow run (alias for createRun)
195
+ * @param params - Optional object containing the optional runId
196
+ * @returns Promise containing the runId of the created run
197
+ */
198
+ createRunAsync(params?: { runId?: string }): Promise<{ runId: string }> {
199
+ return this.createRun(params);
200
+ }
201
+
150
202
  /**
151
203
  * Starts a workflow run synchronously without waiting for the workflow to complete
152
204
  * @param params - Object containing the runId, inputData and runtimeContext
@@ -217,9 +269,9 @@ export class Workflow extends BaseResource {
217
269
  }
218
270
 
219
271
  /**
220
- * Starts a vNext workflow run and returns a stream
272
+ * Starts a workflow run and returns a stream
221
273
  * @param params - Object containing the optional runId, inputData and runtimeContext
222
- * @returns Promise containing the vNext workflow execution results
274
+ * @returns Promise containing the workflow execution results
223
275
  */
224
276
  async stream(params: { runId?: string; inputData: Record<string, any>; runtimeContext?: RuntimeContext }) {
225
277
  const searchParams = new URLSearchParams();
@@ -228,7 +280,7 @@ export class Workflow extends BaseResource {
228
280
  searchParams.set('runId', params.runId);
229
281
  }
230
282
 
231
- const runtimeContext = params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : undefined;
283
+ const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
232
284
  const response: Response = await this.request(
233
285
  `/api/workflows/${this.workflowId}/stream?${searchParams.toString()}`,
234
286
  {
@@ -246,8 +298,11 @@ export class Workflow extends BaseResource {
246
298
  throw new Error('Response body is null');
247
299
  }
248
300
 
301
+ //using undefined instead of empty string to avoid parsing errors
302
+ let failedChunk: string | undefined = undefined;
303
+
249
304
  // Create a transform stream that processes the response body
250
- const transformStream = new TransformStream<ArrayBuffer, WorkflowWatchResult>({
305
+ const transformStream = new TransformStream<ArrayBuffer, { type: string; payload: any }>({
251
306
  start() {},
252
307
  async transform(chunk, controller) {
253
308
  try {
@@ -260,11 +315,13 @@ export class Workflow extends BaseResource {
260
315
  // Process each chunk
261
316
  for (const chunk of chunks) {
262
317
  if (chunk) {
318
+ const newChunk: string = failedChunk ? failedChunk + chunk : chunk;
263
319
  try {
264
- const parsedChunk = JSON.parse(chunk);
320
+ const parsedChunk = JSON.parse(newChunk);
265
321
  controller.enqueue(parsedChunk);
266
- } catch {
267
- // Silently ignore parsing errors
322
+ failedChunk = undefined;
323
+ } catch (error) {
324
+ failedChunk = newChunk;
268
325
  }
269
326
  }
270
327
  }
package/src/types.ts CHANGED
@@ -5,10 +5,14 @@ import type {
5
5
  QueryResult,
6
6
  StorageThreadType,
7
7
  WorkflowRuns,
8
+ WorkflowRun,
8
9
  LegacyWorkflowRuns,
10
+ StorageGetMessagesArg,
11
+ PaginationInfo,
12
+ MastraMessageV2,
9
13
  } from '@mastra/core';
10
- import type { AgentGenerateOptions, AgentStreamOptions } from '@mastra/core/agent';
11
- import type { BaseLogMessage } from '@mastra/core/logger';
14
+ import type { AgentGenerateOptions, AgentStreamOptions, ToolsInput } from '@mastra/core/agent';
15
+ import type { BaseLogMessage, LogLevel } from '@mastra/core/logger';
12
16
 
13
17
  import type { MCPToolType, ServerInfo } from '@mastra/core/mcp';
14
18
  import type { RuntimeContext } from '@mastra/core/runtime-context';
@@ -33,6 +37,7 @@ export interface ClientOptions {
33
37
  /** Custom headers to include with requests */
34
38
  headers?: Record<string, string>;
35
39
  /** Abort signal for request */
40
+ abortSignal?: AbortSignal;
36
41
  }
37
42
 
38
43
  export interface RequestOptions {
@@ -40,7 +45,6 @@ export interface RequestOptions {
40
45
  headers?: Record<string, string>;
41
46
  body?: any;
42
47
  stream?: boolean;
43
- signal?: AbortSignal;
44
48
  }
45
49
 
46
50
  type WithoutMethods<T> = {
@@ -69,14 +73,20 @@ export type GenerateParams<T extends JSONSchema7 | ZodSchema | undefined = undef
69
73
  output?: T;
70
74
  experimental_output?: T;
71
75
  runtimeContext?: RuntimeContext | Record<string, any>;
72
- } & WithoutMethods<Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext'>>;
76
+ clientTools?: ToolsInput;
77
+ } & WithoutMethods<
78
+ Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools' | 'abortSignal'>
79
+ >;
73
80
 
74
81
  export type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
75
82
  messages: string | string[] | CoreMessage[] | AiMessageType[];
76
83
  output?: T;
77
84
  experimental_output?: T;
78
85
  runtimeContext?: RuntimeContext | Record<string, any>;
79
- } & WithoutMethods<Omit<AgentStreamOptions<T>, 'output' | 'experimental_output' | 'runtimeContext'>>;
86
+ clientTools?: ToolsInput;
87
+ } & WithoutMethods<
88
+ Omit<AgentStreamOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools' | 'abortSignal'>
89
+ >;
80
90
 
81
91
  export interface GetEvalsByAgentIdResponse extends GetAgentResponse {
82
92
  evals: any[];
@@ -113,6 +123,10 @@ export type GetLegacyWorkflowRunsResponse = LegacyWorkflowRuns;
113
123
 
114
124
  export type GetWorkflowRunsResponse = WorkflowRuns;
115
125
 
126
+ export type GetWorkflowRunByIdResponse = WorkflowRun;
127
+
128
+ export type GetWorkflowRunExecutionResultResponse = WatchEvent['payload']['workflowState'];
129
+
116
130
  export type LegacyWorkflowRunResult = {
117
131
  activePaths: Record<string, { status: string; suspendPayload?: any; stepPath: string[] }>;
118
132
  results: CoreLegacyWorkflowRunResult<any, any, any>['results'];
@@ -133,6 +147,17 @@ export interface GetWorkflowResponse {
133
147
  suspendSchema: string;
134
148
  };
135
149
  };
150
+ allSteps: {
151
+ [key: string]: {
152
+ id: string;
153
+ description: string;
154
+ inputSchema: string;
155
+ outputSchema: string;
156
+ resumeSchema: string;
157
+ suspendSchema: string;
158
+ isWorkflow: boolean;
159
+ };
160
+ };
136
161
  stepGraph: Workflow['serializedStepGraph'];
137
162
  inputSchema: string;
138
163
  outputSchema: string;
@@ -176,6 +201,11 @@ export interface SaveMessageToMemoryParams {
176
201
  agentId: string;
177
202
  }
178
203
 
204
+ export interface SaveNetworkMessageToMemoryParams {
205
+ messages: MastraMessageV1[];
206
+ networkId: string;
207
+ }
208
+
179
209
  export type SaveMessageToMemoryResponse = MastraMessageV1[];
180
210
 
181
211
  export interface CreateMemoryThreadParams {
@@ -186,6 +216,14 @@ export interface CreateMemoryThreadParams {
186
216
  agentId: string;
187
217
  }
188
218
 
219
+ export interface CreateNetworkMemoryThreadParams {
220
+ title?: string;
221
+ metadata?: Record<string, any>;
222
+ resourceId: string;
223
+ threadId?: string;
224
+ networkId: string;
225
+ }
226
+
189
227
  export type CreateMemoryThreadResponse = StorageThreadType;
190
228
 
191
229
  export interface GetMemoryThreadParams {
@@ -193,6 +231,11 @@ export interface GetMemoryThreadParams {
193
231
  agentId: string;
194
232
  }
195
233
 
234
+ export interface GetNetworkMemoryThreadParams {
235
+ resourceId: string;
236
+ networkId: string;
237
+ }
238
+
196
239
  export type GetMemoryThreadResponse = StorageThreadType[];
197
240
 
198
241
  export interface UpdateMemoryThreadParams {
@@ -208,21 +251,45 @@ export interface GetMemoryThreadMessagesParams {
208
251
  limit?: number;
209
252
  }
210
253
 
254
+ export type GetMemoryThreadMessagesPaginatedParams = Omit<StorageGetMessagesArg, 'threadConfig' | 'threadId'>;
255
+
211
256
  export interface GetMemoryThreadMessagesResponse {
212
257
  messages: CoreMessage[];
213
258
  uiMessages: AiMessageType[];
214
259
  }
215
260
 
261
+ export type GetMemoryThreadMessagesPaginatedResponse = PaginationInfo & {
262
+ messages: MastraMessageV1[] | MastraMessageV2[];
263
+ };
264
+
216
265
  export interface GetLogsParams {
217
266
  transportId: string;
267
+ fromDate?: Date;
268
+ toDate?: Date;
269
+ logLevel?: LogLevel;
270
+ filters?: Record<string, string>;
271
+ page?: number;
272
+ perPage?: number;
218
273
  }
219
274
 
220
275
  export interface GetLogParams {
221
276
  runId: string;
222
277
  transportId: string;
278
+ fromDate?: Date;
279
+ toDate?: Date;
280
+ logLevel?: LogLevel;
281
+ filters?: Record<string, string>;
282
+ page?: number;
283
+ perPage?: number;
223
284
  }
224
285
 
225
- export type GetLogsResponse = BaseLogMessage[];
286
+ export type GetLogsResponse = {
287
+ logs: BaseLogMessage[];
288
+ total: number;
289
+ page: number;
290
+ perPage: number;
291
+ hasMore: boolean;
292
+ };
226
293
 
227
294
  export type RequestFunction = (path: string, options?: RequestOptions) => Promise<any>;
228
295
 
@@ -281,6 +348,7 @@ export interface GetTelemetryParams {
281
348
  }
282
349
 
283
350
  export interface GetNetworkResponse {
351
+ id: string;
284
352
  name: string;
285
353
  instructions: string;
286
354
  agents: Array<{
@@ -295,6 +363,71 @@ export interface GetNetworkResponse {
295
363
  state?: Record<string, any>;
296
364
  }
297
365
 
366
+ export interface GetVNextNetworkResponse {
367
+ id: string;
368
+ name: string;
369
+ instructions: string;
370
+ agents: Array<{
371
+ name: string;
372
+ provider: string;
373
+ modelId: string;
374
+ }>;
375
+ routingModel: {
376
+ provider: string;
377
+ modelId: string;
378
+ };
379
+ workflows: Array<{
380
+ name: string;
381
+ description: string;
382
+ inputSchema: string | undefined;
383
+ outputSchema: string | undefined;
384
+ }>;
385
+ tools: Array<{
386
+ id: string;
387
+ description: string;
388
+ }>;
389
+ }
390
+
391
+ export interface GenerateVNextNetworkResponse {
392
+ task: string;
393
+ result: string;
394
+ resourceId: string;
395
+ resourceType: 'none' | 'tool' | 'agent' | 'workflow';
396
+ }
397
+
398
+ export interface GenerateOrStreamVNextNetworkParams {
399
+ message: string;
400
+ threadId?: string;
401
+ resourceId?: string;
402
+ runtimeContext?: RuntimeContext | Record<string, any>;
403
+ }
404
+
405
+ export interface LoopStreamVNextNetworkParams {
406
+ message: string;
407
+ threadId?: string;
408
+ resourceId?: string;
409
+ maxIterations?: number;
410
+ runtimeContext?: RuntimeContext | Record<string, any>;
411
+ }
412
+
413
+ export interface LoopVNextNetworkResponse {
414
+ status: 'success';
415
+ result: {
416
+ task: string;
417
+ resourceId: string;
418
+ resourceType: 'agent' | 'workflow' | 'none' | 'tool';
419
+ result: string;
420
+ iteration: number;
421
+ isOneOff: boolean;
422
+ prompt: string;
423
+ threadId?: string | undefined;
424
+ threadResourceId?: string | undefined;
425
+ isComplete?: boolean | undefined;
426
+ completionReason?: string | undefined;
427
+ };
428
+ steps: WorkflowResult<any, any>['steps'];
429
+ }
430
+
298
431
  export interface McpServerListResponse {
299
432
  servers: ServerInfo[];
300
433
  next: string | null;