@mastra/client-js 0.0.0-mcp-changeset-20250707162621 → 0.0.0-message-list-update-20250715150321
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/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +109 -2
- package/LICENSE.md +11 -42
- package/dist/index.cjs +349 -271
- package/dist/index.d.cts +69 -39
- package/dist/index.d.ts +69 -39
- package/dist/index.js +350 -272
- package/package.json +5 -4
- package/src/client.ts +48 -2
- package/src/example.ts +45 -17
- package/src/resources/agent.ts +291 -254
- package/src/resources/base.ts +1 -0
- package/src/resources/vNextNetwork.ts +22 -5
- package/src/types.ts +9 -3
|
@@ -10,6 +10,8 @@ import type {
|
|
|
10
10
|
} from '../types';
|
|
11
11
|
|
|
12
12
|
import { BaseResource } from './base';
|
|
13
|
+
import { parseClientRuntimeContext } from '../utils';
|
|
14
|
+
import type { RuntimeContext } from '@mastra/core/runtime-context';
|
|
13
15
|
|
|
14
16
|
const RECORD_SEPARATOR = '\x1E';
|
|
15
17
|
|
|
@@ -37,7 +39,10 @@ export class VNextNetwork extends BaseResource {
|
|
|
37
39
|
generate(params: GenerateOrStreamVNextNetworkParams): Promise<GenerateVNextNetworkResponse> {
|
|
38
40
|
return this.request(`/api/networks/v-next/${this.networkId}/generate`, {
|
|
39
41
|
method: 'POST',
|
|
40
|
-
body:
|
|
42
|
+
body: {
|
|
43
|
+
...params,
|
|
44
|
+
runtimeContext: parseClientRuntimeContext(params.runtimeContext),
|
|
45
|
+
},
|
|
41
46
|
});
|
|
42
47
|
}
|
|
43
48
|
|
|
@@ -46,10 +51,16 @@ export class VNextNetwork extends BaseResource {
|
|
|
46
51
|
* @param params - Generation parameters including message
|
|
47
52
|
* @returns Promise containing the generated response
|
|
48
53
|
*/
|
|
49
|
-
loop(params: {
|
|
54
|
+
loop(params: {
|
|
55
|
+
message: string;
|
|
56
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
57
|
+
}): Promise<LoopVNextNetworkResponse> {
|
|
50
58
|
return this.request(`/api/networks/v-next/${this.networkId}/loop`, {
|
|
51
59
|
method: 'POST',
|
|
52
|
-
body:
|
|
60
|
+
body: {
|
|
61
|
+
...params,
|
|
62
|
+
runtimeContext: parseClientRuntimeContext(params.runtimeContext),
|
|
63
|
+
},
|
|
53
64
|
});
|
|
54
65
|
}
|
|
55
66
|
|
|
@@ -125,7 +136,10 @@ export class VNextNetwork extends BaseResource {
|
|
|
125
136
|
async stream(params: GenerateOrStreamVNextNetworkParams, onRecord: (record: WatchEvent) => void) {
|
|
126
137
|
const response: Response = await this.request(`/api/networks/v-next/${this.networkId}/stream`, {
|
|
127
138
|
method: 'POST',
|
|
128
|
-
body:
|
|
139
|
+
body: {
|
|
140
|
+
...params,
|
|
141
|
+
runtimeContext: parseClientRuntimeContext(params.runtimeContext),
|
|
142
|
+
},
|
|
129
143
|
stream: true,
|
|
130
144
|
});
|
|
131
145
|
|
|
@@ -154,7 +168,10 @@ export class VNextNetwork extends BaseResource {
|
|
|
154
168
|
async loopStream(params: LoopStreamVNextNetworkParams, onRecord: (record: WatchEvent) => void) {
|
|
155
169
|
const response: Response = await this.request(`/api/networks/v-next/${this.networkId}/loop-stream`, {
|
|
156
170
|
method: 'POST',
|
|
157
|
-
body:
|
|
171
|
+
body: {
|
|
172
|
+
...params,
|
|
173
|
+
runtimeContext: parseClientRuntimeContext(params.runtimeContext),
|
|
174
|
+
},
|
|
158
175
|
stream: true,
|
|
159
176
|
});
|
|
160
177
|
|
package/src/types.ts
CHANGED
|
@@ -34,6 +34,7 @@ export interface ClientOptions {
|
|
|
34
34
|
/** Custom headers to include with requests */
|
|
35
35
|
headers?: Record<string, string>;
|
|
36
36
|
/** Abort signal for request */
|
|
37
|
+
abortSignal?: AbortSignal;
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
export interface RequestOptions {
|
|
@@ -41,7 +42,6 @@ export interface RequestOptions {
|
|
|
41
42
|
headers?: Record<string, string>;
|
|
42
43
|
body?: any;
|
|
43
44
|
stream?: boolean;
|
|
44
|
-
signal?: AbortSignal;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
type WithoutMethods<T> = {
|
|
@@ -71,7 +71,9 @@ export type GenerateParams<T extends JSONSchema7 | ZodSchema | undefined = undef
|
|
|
71
71
|
experimental_output?: T;
|
|
72
72
|
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
73
73
|
clientTools?: ToolsInput;
|
|
74
|
-
} & WithoutMethods<
|
|
74
|
+
} & WithoutMethods<
|
|
75
|
+
Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools' | 'abortSignal'>
|
|
76
|
+
>;
|
|
75
77
|
|
|
76
78
|
export type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
|
|
77
79
|
messages: string | string[] | CoreMessage[] | AiMessageType[];
|
|
@@ -79,7 +81,9 @@ export type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefin
|
|
|
79
81
|
experimental_output?: T;
|
|
80
82
|
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
81
83
|
clientTools?: ToolsInput;
|
|
82
|
-
} & WithoutMethods<
|
|
84
|
+
} & WithoutMethods<
|
|
85
|
+
Omit<AgentStreamOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools' | 'abortSignal'>
|
|
86
|
+
>;
|
|
83
87
|
|
|
84
88
|
export interface GetEvalsByAgentIdResponse extends GetAgentResponse {
|
|
85
89
|
evals: any[];
|
|
@@ -386,6 +390,7 @@ export interface GenerateOrStreamVNextNetworkParams {
|
|
|
386
390
|
message: string;
|
|
387
391
|
threadId?: string;
|
|
388
392
|
resourceId?: string;
|
|
393
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
389
394
|
}
|
|
390
395
|
|
|
391
396
|
export interface LoopStreamVNextNetworkParams {
|
|
@@ -393,6 +398,7 @@ export interface LoopStreamVNextNetworkParams {
|
|
|
393
398
|
threadId?: string;
|
|
394
399
|
resourceId?: string;
|
|
395
400
|
maxIterations?: number;
|
|
401
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
396
402
|
}
|
|
397
403
|
|
|
398
404
|
export interface LoopVNextNetworkResponse {
|