@mastra/client-js 0.0.0-scorers-api-v2-20250801171841 → 0.0.0-scorers-ui-refactored-20250916094952
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 +671 -3
- package/README.md +5 -3
- package/dist/client.d.ts +30 -11
- package/dist/client.d.ts.map +1 -1
- package/dist/index.cjs +1459 -413
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1459 -415
- package/dist/index.js.map +1 -1
- package/dist/resources/a2a.d.ts +15 -18
- package/dist/resources/a2a.d.ts.map +1 -1
- package/dist/resources/agent-builder.d.ts +161 -0
- package/dist/resources/agent-builder.d.ts.map +1 -0
- package/dist/resources/agent.d.ts +78 -15
- package/dist/resources/agent.d.ts.map +1 -1
- package/dist/resources/base.d.ts +1 -1
- package/dist/resources/base.d.ts.map +1 -1
- package/dist/resources/index.d.ts +12 -10
- package/dist/resources/index.d.ts.map +1 -1
- package/dist/resources/legacy-workflow.d.ts +7 -4
- package/dist/resources/legacy-workflow.d.ts.map +1 -1
- package/dist/resources/mcp-tool.d.ts +4 -3
- package/dist/resources/mcp-tool.d.ts.map +1 -1
- package/dist/resources/memory-thread.d.ts +3 -3
- package/dist/resources/memory-thread.d.ts.map +1 -1
- package/dist/resources/network-memory-thread.d.ts +3 -3
- package/dist/resources/network-memory-thread.d.ts.map +1 -1
- package/dist/resources/network.d.ts +6 -4
- package/dist/resources/network.d.ts.map +1 -1
- package/dist/resources/observability.d.ts +19 -0
- package/dist/resources/observability.d.ts.map +1 -0
- package/dist/resources/tool.d.ts +4 -3
- package/dist/resources/tool.d.ts.map +1 -1
- package/dist/resources/vNextNetwork.d.ts +5 -4
- package/dist/resources/vNextNetwork.d.ts.map +1 -1
- package/dist/resources/vector.d.ts +7 -4
- package/dist/resources/vector.d.ts.map +1 -1
- package/dist/resources/workflow.d.ts +80 -6
- package/dist/resources/workflow.d.ts.map +1 -1
- package/dist/tools.d.ts +22 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/types.d.ts +49 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/process-client-tools.d.ts.map +1 -1
- package/dist/utils/process-mastra-stream.d.ts +11 -0
- package/dist/utils/process-mastra-stream.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema.d.ts +2 -104
- package/dist/utils/zod-to-json-schema.d.ts.map +1 -1
- package/package.json +25 -16
- package/dist/adapters/agui.d.ts +0 -23
- package/dist/adapters/agui.d.ts.map +0 -1
- package/eslint.config.js +0 -6
- package/integration-tests/agui-adapter.test.ts +0 -122
- package/integration-tests/package.json +0 -18
- package/integration-tests/src/mastra/index.ts +0 -35
- package/integration-tests/vitest.config.ts +0 -9
- package/src/adapters/agui.test.ts +0 -322
- package/src/adapters/agui.ts +0 -239
- package/src/client.ts +0 -623
- package/src/example.ts +0 -95
- package/src/index.test.ts +0 -1226
- package/src/index.ts +0 -3
- package/src/resources/a2a.ts +0 -88
- package/src/resources/agent.ts +0 -785
- package/src/resources/base.ts +0 -76
- package/src/resources/index.ts +0 -10
- package/src/resources/legacy-workflow.ts +0 -242
- package/src/resources/mcp-tool.ts +0 -48
- package/src/resources/memory-thread.test.ts +0 -285
- package/src/resources/memory-thread.ts +0 -99
- package/src/resources/network-memory-thread.test.ts +0 -269
- package/src/resources/network-memory-thread.ts +0 -81
- package/src/resources/network.ts +0 -86
- package/src/resources/tool.ts +0 -45
- package/src/resources/vNextNetwork.ts +0 -194
- package/src/resources/vector.ts +0 -83
- package/src/resources/workflow.ts +0 -410
- package/src/types.ts +0 -502
- package/src/utils/index.ts +0 -11
- package/src/utils/process-client-tools.ts +0 -32
- package/src/utils/zod-to-json-schema.ts +0 -10
- package/src/v2-messages.test.ts +0 -180
- package/tsconfig.build.json +0 -9
- package/tsconfig.json +0 -5
- package/tsup.config.ts +0 -22
- package/vitest.config.js +0 -8
package/src/v2-messages.test.ts
DELETED
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
-
import type { MastraMessageV1, MastraMessageV2 } from '@mastra/core';
|
|
3
|
-
import { MastraClient } from './client';
|
|
4
|
-
|
|
5
|
-
describe('V2 Message Format Support', () => {
|
|
6
|
-
let client: MastraClient;
|
|
7
|
-
const agentId = 'test-agent';
|
|
8
|
-
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
global.fetch = vi.fn();
|
|
11
|
-
client = new MastraClient({
|
|
12
|
-
baseUrl: 'http://localhost:3000',
|
|
13
|
-
});
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it('should send v1 messages successfully', async () => {
|
|
17
|
-
const v1Messages: MastraMessageV1[] = [
|
|
18
|
-
{
|
|
19
|
-
id: 'msg-v1-1',
|
|
20
|
-
role: 'user',
|
|
21
|
-
content: 'Hello from v1!',
|
|
22
|
-
type: 'text',
|
|
23
|
-
createdAt: new Date(),
|
|
24
|
-
threadId: 'thread-123',
|
|
25
|
-
resourceId: 'resource-123',
|
|
26
|
-
},
|
|
27
|
-
];
|
|
28
|
-
|
|
29
|
-
(global.fetch as any).mockResolvedValueOnce({
|
|
30
|
-
ok: true,
|
|
31
|
-
json: async () => v1Messages,
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
const result = await client.saveMessageToMemory({
|
|
35
|
-
agentId,
|
|
36
|
-
messages: v1Messages,
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
expect(result).toEqual(v1Messages);
|
|
40
|
-
expect(global.fetch).toHaveBeenCalledWith(
|
|
41
|
-
expect.stringContaining('/api/memory/save-messages'),
|
|
42
|
-
expect.objectContaining({
|
|
43
|
-
method: 'POST',
|
|
44
|
-
body: JSON.stringify({ agentId, messages: v1Messages }),
|
|
45
|
-
}),
|
|
46
|
-
);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('should send v2 messages successfully', async () => {
|
|
50
|
-
const v2Messages: MastraMessageV2[] = [
|
|
51
|
-
{
|
|
52
|
-
id: 'msg-v2-1',
|
|
53
|
-
role: 'assistant',
|
|
54
|
-
createdAt: new Date(),
|
|
55
|
-
threadId: 'thread-123',
|
|
56
|
-
resourceId: 'resource-123',
|
|
57
|
-
content: {
|
|
58
|
-
format: 2,
|
|
59
|
-
parts: [{ type: 'text', text: 'Hello from v2!' }],
|
|
60
|
-
content: 'Hello from v2!',
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
];
|
|
64
|
-
|
|
65
|
-
(global.fetch as any).mockResolvedValueOnce({
|
|
66
|
-
ok: true,
|
|
67
|
-
json: async () => v2Messages,
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
const result = await client.saveMessageToMemory({
|
|
71
|
-
agentId,
|
|
72
|
-
messages: v2Messages,
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
expect(result).toEqual(v2Messages);
|
|
76
|
-
expect(global.fetch).toHaveBeenCalledWith(
|
|
77
|
-
expect.stringContaining('/api/memory/save-messages'),
|
|
78
|
-
expect.objectContaining({
|
|
79
|
-
method: 'POST',
|
|
80
|
-
body: JSON.stringify({ agentId, messages: v2Messages }),
|
|
81
|
-
}),
|
|
82
|
-
);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it('should send mixed v1 and v2 messages successfully', async () => {
|
|
86
|
-
const mixedMessages: (MastraMessageV1 | MastraMessageV2)[] = [
|
|
87
|
-
{
|
|
88
|
-
id: 'msg-v1-1',
|
|
89
|
-
role: 'user',
|
|
90
|
-
content: 'Question in v1 format',
|
|
91
|
-
type: 'text',
|
|
92
|
-
createdAt: new Date(),
|
|
93
|
-
threadId: 'thread-123',
|
|
94
|
-
resourceId: 'resource-123',
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
id: 'msg-v2-1',
|
|
98
|
-
role: 'assistant',
|
|
99
|
-
createdAt: new Date(),
|
|
100
|
-
threadId: 'thread-123',
|
|
101
|
-
resourceId: 'resource-123',
|
|
102
|
-
content: {
|
|
103
|
-
format: 2,
|
|
104
|
-
parts: [
|
|
105
|
-
{ type: 'text', text: 'Answer in v2 format' },
|
|
106
|
-
{
|
|
107
|
-
type: 'tool-invocation',
|
|
108
|
-
toolInvocation: {
|
|
109
|
-
state: 'result' as const,
|
|
110
|
-
toolCallId: 'call-123',
|
|
111
|
-
toolName: 'calculator',
|
|
112
|
-
args: { a: 1, b: 2 },
|
|
113
|
-
result: '3',
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
],
|
|
117
|
-
toolInvocations: [
|
|
118
|
-
{
|
|
119
|
-
state: 'result' as const,
|
|
120
|
-
toolCallId: 'call-123',
|
|
121
|
-
toolName: 'calculator',
|
|
122
|
-
args: { a: 1, b: 2 },
|
|
123
|
-
result: '3',
|
|
124
|
-
},
|
|
125
|
-
],
|
|
126
|
-
},
|
|
127
|
-
},
|
|
128
|
-
];
|
|
129
|
-
|
|
130
|
-
(global.fetch as any).mockResolvedValueOnce({
|
|
131
|
-
ok: true,
|
|
132
|
-
json: async () => mixedMessages,
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
const result = await client.saveMessageToMemory({
|
|
136
|
-
agentId,
|
|
137
|
-
messages: mixedMessages,
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
expect(result).toEqual(mixedMessages);
|
|
141
|
-
expect(global.fetch).toHaveBeenCalledWith(
|
|
142
|
-
expect.stringContaining('/api/memory/save-messages'),
|
|
143
|
-
expect.objectContaining({
|
|
144
|
-
method: 'POST',
|
|
145
|
-
body: JSON.stringify({ agentId, messages: mixedMessages }),
|
|
146
|
-
}),
|
|
147
|
-
);
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
it('should handle v2 messages with attachments', async () => {
|
|
151
|
-
const v2MessageWithAttachments: MastraMessageV2 = {
|
|
152
|
-
id: 'msg-v2-att',
|
|
153
|
-
role: 'user',
|
|
154
|
-
createdAt: new Date(),
|
|
155
|
-
threadId: 'thread-123',
|
|
156
|
-
resourceId: 'resource-123',
|
|
157
|
-
content: {
|
|
158
|
-
format: 2,
|
|
159
|
-
parts: [
|
|
160
|
-
{ type: 'text', text: 'Check out this image:' },
|
|
161
|
-
{ type: 'file', data: 'data:image/png;base64,iVBORw0...', mimeType: 'image/png' },
|
|
162
|
-
],
|
|
163
|
-
experimental_attachments: [{ url: 'data:image/png;base64,iVBORw0...', contentType: 'image/png' }],
|
|
164
|
-
},
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
(global.fetch as any).mockResolvedValueOnce({
|
|
168
|
-
ok: true,
|
|
169
|
-
json: async () => [v2MessageWithAttachments],
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
const result = await client.saveMessageToMemory({
|
|
173
|
-
agentId,
|
|
174
|
-
messages: [v2MessageWithAttachments],
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
expect(result).toHaveLength(1);
|
|
178
|
-
expect(result[0]).toEqual(v2MessageWithAttachments);
|
|
179
|
-
});
|
|
180
|
-
});
|
package/tsconfig.build.json
DELETED
package/tsconfig.json
DELETED
package/tsup.config.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { spawn } from 'child_process';
|
|
2
|
-
import { promisify } from 'util';
|
|
3
|
-
import { defineConfig } from 'tsup';
|
|
4
|
-
|
|
5
|
-
const exec = promisify(spawn);
|
|
6
|
-
|
|
7
|
-
export default defineConfig({
|
|
8
|
-
entry: ['src/index.ts'],
|
|
9
|
-
format: ['esm', 'cjs'],
|
|
10
|
-
clean: true,
|
|
11
|
-
dts: false,
|
|
12
|
-
splitting: true,
|
|
13
|
-
treeshake: {
|
|
14
|
-
preset: 'smallest',
|
|
15
|
-
},
|
|
16
|
-
sourcemap: true,
|
|
17
|
-
onSuccess: async () => {
|
|
18
|
-
await exec('pnpm', ['tsc', '-p', 'tsconfig.build.json'], {
|
|
19
|
-
stdio: 'inherit',
|
|
20
|
-
});
|
|
21
|
-
},
|
|
22
|
-
});
|