@mastra/client-js 0.0.0-ai-v5-20250729181825 → 0.0.0-ai-v5-20250813235735
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 +18 -0
- package/CHANGELOG.md +215 -20
- package/dist/adapters/agui.d.ts +22 -0
- package/dist/adapters/agui.d.ts.map +1 -0
- package/dist/client.d.ts +270 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/example.d.ts +2 -0
- package/dist/example.d.ts.map +1 -0
- package/dist/index.cjs +85 -41
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +3 -1331
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +82 -38
- package/dist/index.js.map +1 -0
- package/dist/resources/a2a.d.ts +41 -0
- package/dist/resources/a2a.d.ts.map +1 -0
- package/dist/resources/agent.d.ts +123 -0
- package/dist/resources/agent.d.ts.map +1 -0
- package/dist/resources/base.d.ts +13 -0
- package/dist/resources/base.d.ts.map +1 -0
- package/dist/resources/index.d.ts +11 -0
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/resources/legacy-workflow.d.ts +87 -0
- package/dist/resources/legacy-workflow.d.ts.map +1 -0
- package/dist/resources/mcp-tool.d.ts +27 -0
- package/dist/resources/mcp-tool.d.ts.map +1 -0
- package/dist/resources/memory-thread.d.ts +53 -0
- package/dist/resources/memory-thread.d.ts.map +1 -0
- package/dist/resources/network-memory-thread.d.ts +47 -0
- package/dist/resources/network-memory-thread.d.ts.map +1 -0
- package/dist/resources/network.d.ts +30 -0
- package/dist/resources/network.d.ts.map +1 -0
- package/dist/resources/tool.d.ts +23 -0
- package/dist/resources/tool.d.ts.map +1 -0
- package/dist/resources/vNextNetwork.d.ts +42 -0
- package/dist/resources/vNextNetwork.d.ts.map +1 -0
- package/dist/resources/vector.d.ts +48 -0
- package/dist/resources/vector.d.ts.map +1 -0
- package/dist/resources/workflow.d.ts +154 -0
- package/dist/resources/workflow.d.ts.map +1 -0
- package/dist/types.d.ts +427 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/process-client-tools.d.ts +3 -0
- package/dist/utils/process-client-tools.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema.d.ts +105 -0
- package/dist/utils/zod-to-json-schema.d.ts.map +1 -0
- package/integration-tests/agui-adapter.test.ts +122 -0
- package/integration-tests/package.json +17 -0
- package/integration-tests/src/mastra/index.ts +38 -0
- package/integration-tests/vitest.config.ts +9 -0
- package/package.json +12 -8
- package/src/adapters/agui.test.ts +145 -3
- package/src/adapters/agui.ts +41 -17
- package/src/client.ts +8 -0
- package/src/resources/a2a.ts +35 -25
- package/src/resources/agent.ts +26 -18
- package/src/resources/base.ts +1 -0
- package/src/resources/network.ts +1 -1
- package/src/types.ts +1 -1
- package/src/utils/process-client-tools.ts +1 -1
- package/tsconfig.build.json +9 -0
- package/tsconfig.json +1 -1
- package/tsup.config.ts +17 -0
- package/dist/index.d.cts +0 -1331
package/src/resources/agent.ts
CHANGED
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
processDataStream,
|
|
4
|
-
type JSONValue,
|
|
5
|
-
type ReasoningUIPart,
|
|
6
|
-
type TextUIPart,
|
|
7
|
-
type ToolInvocation,
|
|
8
|
-
type ToolInvocationUIPart,
|
|
9
|
-
type UIMessage,
|
|
10
|
-
type UseChatOptions,
|
|
11
|
-
} from '@ai-sdk/ui-utils';
|
|
12
|
-
import { Tool, type CoreMessage } from '@mastra/core';
|
|
1
|
+
import { processDataStream, type JSONValue, type ToolInvocation, type UIMessage } from 'ai';
|
|
2
|
+
import { Tool, type CoreMessage, type MastraLanguageModel } from '@mastra/core';
|
|
13
3
|
import { type GenerateReturn } from '@mastra/core/llm';
|
|
14
4
|
import type { JSONSchema7 } from 'json-schema';
|
|
15
5
|
import { ZodSchema } from 'zod';
|
|
@@ -213,7 +203,7 @@ export class Agent extends BaseResource {
|
|
|
213
203
|
}: {
|
|
214
204
|
stream: ReadableStream<Uint8Array>;
|
|
215
205
|
update: (options: { message: UIMessage; data: JSONValue[] | undefined; replaceLastMessage: boolean }) => void;
|
|
216
|
-
onToolCall?:
|
|
206
|
+
onToolCall?: any;
|
|
217
207
|
onFinish?: (options: { message: UIMessage | undefined; finishReason: string; usage: string }) => void;
|
|
218
208
|
generateId?: () => string;
|
|
219
209
|
getCurrentDate?: () => Date;
|
|
@@ -238,14 +228,14 @@ export class Agent extends BaseResource {
|
|
|
238
228
|
parts: [],
|
|
239
229
|
};
|
|
240
230
|
|
|
241
|
-
let currentTextPart:
|
|
242
|
-
let currentReasoningPart:
|
|
231
|
+
let currentTextPart: any | undefined = undefined;
|
|
232
|
+
let currentReasoningPart: any | undefined = undefined;
|
|
243
233
|
let currentReasoningTextDetail: { type: 'text'; text: string; signature?: string } | undefined = undefined;
|
|
244
234
|
|
|
245
235
|
function updateToolInvocationPart(toolCallId: string, invocation: ToolInvocation) {
|
|
246
236
|
const part = message.parts.find(
|
|
247
237
|
part => part.type === 'tool-invocation' && part.toolInvocation.toolCallId === toolCallId,
|
|
248
|
-
) as
|
|
238
|
+
) as any | undefined;
|
|
249
239
|
|
|
250
240
|
if (part != null) {
|
|
251
241
|
part.toolInvocation = invocation;
|
|
@@ -415,7 +405,13 @@ export class Agent extends BaseResource {
|
|
|
415
405
|
|
|
416
406
|
partialToolCall!.text += value.argsTextDelta;
|
|
417
407
|
|
|
418
|
-
|
|
408
|
+
// In v4, we don't have parsePartialJson, so we'll try to parse it directly
|
|
409
|
+
let partialArgs;
|
|
410
|
+
try {
|
|
411
|
+
partialArgs = JSON.parse(partialToolCall!.text);
|
|
412
|
+
} catch {
|
|
413
|
+
partialArgs = undefined;
|
|
414
|
+
}
|
|
419
415
|
|
|
420
416
|
const invocation = {
|
|
421
417
|
state: 'partial-call',
|
|
@@ -671,7 +667,7 @@ export class Agent extends BaseResource {
|
|
|
671
667
|
|
|
672
668
|
const toolInvocationPart = lastMessage?.parts?.find(
|
|
673
669
|
part => part.type === 'tool-invocation' && part.toolInvocation?.toolCallId === toolCall.toolCallId,
|
|
674
|
-
) as
|
|
670
|
+
) as any | undefined;
|
|
675
671
|
|
|
676
672
|
if (toolInvocationPart) {
|
|
677
673
|
toolInvocationPart.toolInvocation = {
|
|
@@ -782,4 +778,16 @@ export class Agent extends BaseResource {
|
|
|
782
778
|
liveEvals(): Promise<GetEvalsByAgentIdResponse> {
|
|
783
779
|
return this.request(`/api/agents/${this.agentId}/evals/live`);
|
|
784
780
|
}
|
|
781
|
+
|
|
782
|
+
/**
|
|
783
|
+
* Updates the model for the agent
|
|
784
|
+
* @param params - Parameters for updating the model
|
|
785
|
+
* @returns Promise containing the updated model
|
|
786
|
+
*/
|
|
787
|
+
updateModel(params: { model: MastraLanguageModel }): Promise<{ message: string }> {
|
|
788
|
+
return this.request(`/api/agents/${this.agentId}/model`, {
|
|
789
|
+
method: 'POST',
|
|
790
|
+
body: params,
|
|
791
|
+
});
|
|
792
|
+
}
|
|
785
793
|
}
|
package/src/resources/base.ts
CHANGED
|
@@ -33,6 +33,7 @@ export class BaseResource {
|
|
|
33
33
|
...options.headers,
|
|
34
34
|
// TODO: Bring this back once we figure out what we/users need to do to make this work with cross-origin requests
|
|
35
35
|
// 'x-mastra-client-type': 'js',
|
|
36
|
+
'x-ai-sdk-compat': 'v4',
|
|
36
37
|
},
|
|
37
38
|
signal: this.options.abortSignal,
|
|
38
39
|
body:
|
package/src/resources/network.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -14,7 +14,7 @@ export function processClientTools(clientTools: ToolsInput | undefined): ToolsIn
|
|
|
14
14
|
key,
|
|
15
15
|
{
|
|
16
16
|
...value,
|
|
17
|
-
|
|
17
|
+
inputSchema: value.inputSchema ? zodToJsonSchema(value.inputSchema) : undefined,
|
|
18
18
|
},
|
|
19
19
|
];
|
|
20
20
|
} else {
|
package/tsconfig.json
CHANGED
package/tsup.config.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineConfig } from 'tsup';
|
|
2
|
+
import { generateTypes } from '@internal/types-builder';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
entry: ['src/index.ts'],
|
|
6
|
+
format: ['esm', 'cjs'],
|
|
7
|
+
clean: true,
|
|
8
|
+
dts: false,
|
|
9
|
+
splitting: true,
|
|
10
|
+
treeshake: {
|
|
11
|
+
preset: 'smallest',
|
|
12
|
+
},
|
|
13
|
+
sourcemap: true,
|
|
14
|
+
onSuccess: async () => {
|
|
15
|
+
await generateTypes(process.cwd());
|
|
16
|
+
},
|
|
17
|
+
});
|