@mastra/client-js 0.0.0-ai-v5-20250813235735 → 0.0.0-ai-telementry-ui-20250908094819
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 +400 -4
- package/README.md +5 -3
- package/dist/client.d.ts +16 -6
- package/dist/client.d.ts.map +1 -1
- package/dist/index.cjs +1170 -407
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1169 -406
- package/dist/index.js.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 +44 -12
- package/dist/resources/agent.d.ts.map +1 -1
- package/dist/resources/index.d.ts +2 -0
- package/dist/resources/index.d.ts.map +1 -1
- package/dist/resources/memory-thread.d.ts +1 -1
- package/dist/resources/memory-thread.d.ts.map +1 -1
- package/dist/resources/network-memory-thread.d.ts +1 -1
- package/dist/resources/network-memory-thread.d.ts.map +1 -1
- package/dist/resources/network.d.ts +2 -2
- 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.map +1 -1
- package/dist/resources/vNextNetwork.d.ts +1 -1
- package/dist/resources/vNextNetwork.d.ts.map +1 -1
- package/dist/types.d.ts +44 -10
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/process-client-tools.d.ts.map +1 -1
- package/dist/utils/process-mastra-stream.d.ts +7 -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 +24 -16
- package/.turbo/turbo-build.log +0 -18
- package/dist/adapters/agui.d.ts +0 -22
- 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 -17
- package/integration-tests/src/mastra/index.ts +0 -38
- package/integration-tests/vitest.config.ts +0 -9
- package/src/adapters/agui.test.ts +0 -322
- package/src/adapters/agui.ts +0 -263
- package/src/client.ts +0 -631
- package/src/example.ts +0 -95
- package/src/index.test.ts +0 -1226
- package/src/index.ts +0 -2
- package/src/resources/a2a.ts +0 -98
- package/src/resources/agent.ts +0 -793
- package/src/resources/base.ts +0 -77
- 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 -100
- 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 -506
- 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 -17
- package/vitest.config.js +0 -8
|
@@ -1,105 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function zodToJsonSchema<T extends
|
|
3
|
-
anyOf: import("zod-to-json-schema").JsonSchema7DateType[];
|
|
4
|
-
} & {
|
|
5
|
-
title?: string;
|
|
6
|
-
default?: any;
|
|
7
|
-
description?: string;
|
|
8
|
-
markdownDescription?: string;
|
|
9
|
-
} & {
|
|
10
|
-
$schema?: string | undefined;
|
|
11
|
-
definitions?: {
|
|
12
|
-
[key: string]: import("zod-to-json-schema").JsonSchema7Type;
|
|
13
|
-
} | undefined;
|
|
14
|
-
}) | ({
|
|
15
|
-
type: "object" | "array";
|
|
16
|
-
} & {
|
|
17
|
-
title?: string;
|
|
18
|
-
default?: any;
|
|
19
|
-
description?: string;
|
|
20
|
-
markdownDescription?: string;
|
|
21
|
-
} & {
|
|
22
|
-
$schema?: string | undefined;
|
|
23
|
-
definitions?: {
|
|
24
|
-
[key: string]: import("zod-to-json-schema").JsonSchema7Type;
|
|
25
|
-
} | undefined;
|
|
26
|
-
}) | ({
|
|
27
|
-
type: ("string" | "number" | "boolean" | "integer" | "null") | ("string" | "number" | "boolean" | "integer" | "null")[];
|
|
28
|
-
} & {
|
|
29
|
-
title?: string;
|
|
30
|
-
default?: any;
|
|
31
|
-
description?: string;
|
|
32
|
-
markdownDescription?: string;
|
|
33
|
-
} & {
|
|
34
|
-
$schema?: string | undefined;
|
|
35
|
-
definitions?: {
|
|
36
|
-
[key: string]: import("zod-to-json-schema").JsonSchema7Type;
|
|
37
|
-
} | undefined;
|
|
38
|
-
}) | ({
|
|
39
|
-
anyOf: import("zod-to-json-schema").JsonSchema7Type[];
|
|
40
|
-
} & {
|
|
41
|
-
title?: string;
|
|
42
|
-
default?: any;
|
|
43
|
-
description?: string;
|
|
44
|
-
markdownDescription?: string;
|
|
45
|
-
} & {
|
|
46
|
-
$schema?: string | undefined;
|
|
47
|
-
definitions?: {
|
|
48
|
-
[key: string]: import("zod-to-json-schema").JsonSchema7Type;
|
|
49
|
-
} | undefined;
|
|
50
|
-
}) | (import("zod-to-json-schema").JsonSchema7UndefinedType & {
|
|
51
|
-
title?: string;
|
|
52
|
-
default?: any;
|
|
53
|
-
description?: string;
|
|
54
|
-
markdownDescription?: string;
|
|
55
|
-
} & {
|
|
56
|
-
$schema?: string | undefined;
|
|
57
|
-
definitions?: {
|
|
58
|
-
[key: string]: import("zod-to-json-schema").JsonSchema7Type;
|
|
59
|
-
} | undefined;
|
|
60
|
-
}) | (import("zod-to-json-schema").JsonSchema7AnyType & {
|
|
61
|
-
title?: string;
|
|
62
|
-
default?: any;
|
|
63
|
-
description?: string;
|
|
64
|
-
markdownDescription?: string;
|
|
65
|
-
} & {
|
|
66
|
-
$schema?: string | undefined;
|
|
67
|
-
definitions?: {
|
|
68
|
-
[key: string]: import("zod-to-json-schema").JsonSchema7Type;
|
|
69
|
-
} | undefined;
|
|
70
|
-
}) | ({
|
|
71
|
-
anyOf: [import("zod-to-json-schema").JsonSchema7Type, import("zod-to-json-schema").JsonSchema7NullType];
|
|
72
|
-
} & {
|
|
73
|
-
title?: string;
|
|
74
|
-
default?: any;
|
|
75
|
-
description?: string;
|
|
76
|
-
markdownDescription?: string;
|
|
77
|
-
} & {
|
|
78
|
-
$schema?: string | undefined;
|
|
79
|
-
definitions?: {
|
|
80
|
-
[key: string]: import("zod-to-json-schema").JsonSchema7Type;
|
|
81
|
-
} | undefined;
|
|
82
|
-
}) | ({
|
|
83
|
-
type: [string, "null"];
|
|
84
|
-
} & {
|
|
85
|
-
title?: string;
|
|
86
|
-
default?: any;
|
|
87
|
-
description?: string;
|
|
88
|
-
markdownDescription?: string;
|
|
89
|
-
} & {
|
|
90
|
-
$schema?: string | undefined;
|
|
91
|
-
definitions?: {
|
|
92
|
-
[key: string]: import("zod-to-json-schema").JsonSchema7Type;
|
|
93
|
-
} | undefined;
|
|
94
|
-
}) | (import("zod-to-json-schema").JsonSchema7AllOfType & {
|
|
95
|
-
title?: string;
|
|
96
|
-
default?: any;
|
|
97
|
-
description?: string;
|
|
98
|
-
markdownDescription?: string;
|
|
99
|
-
} & {
|
|
100
|
-
$schema?: string | undefined;
|
|
101
|
-
definitions?: {
|
|
102
|
-
[key: string]: import("zod-to-json-schema").JsonSchema7Type;
|
|
103
|
-
} | undefined;
|
|
104
|
-
});
|
|
1
|
+
import type { ZodType } from 'zod';
|
|
2
|
+
export declare function zodToJsonSchema<T extends ZodType | any>(zodSchema: T): any;
|
|
105
3
|
//# sourceMappingURL=zod-to-json-schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod-to-json-schema.d.ts","sourceRoot":"","sources":["../../src/utils/zod-to-json-schema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"zod-to-json-schema.d.ts","sourceRoot":"","sources":["../../src/utils/zod-to-json-schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAgBnC,wBAAgB,eAAe,CAAC,CAAC,SAAS,OAAO,GAAG,GAAG,EAAE,SAAS,EAAE,CAAC,OAYpE"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/client-js",
|
|
3
|
-
"version": "0.0.0-ai-
|
|
3
|
+
"version": "0.0.0-ai-telementry-ui-20250908094819",
|
|
4
4
|
"description": "The official TypeScript library for the Mastra Client API",
|
|
5
5
|
"author": "",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"main": "dist/index.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"CHANGELOG.md"
|
|
12
|
+
],
|
|
9
13
|
"exports": {
|
|
10
14
|
".": {
|
|
11
15
|
"import": {
|
|
@@ -21,42 +25,46 @@
|
|
|
21
25
|
},
|
|
22
26
|
"repository": {
|
|
23
27
|
"type": "git",
|
|
24
|
-
"url": "https://github.com/mastra-ai/mastra.git",
|
|
28
|
+
"url": "git+https://github.com/mastra-ai/mastra.git",
|
|
25
29
|
"directory": "client-sdks/client-js"
|
|
26
30
|
},
|
|
27
|
-
"
|
|
31
|
+
"bugs": {
|
|
32
|
+
"url": "https://github.com/mastra-ai/mastra/issues"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://mastra.ai",
|
|
28
35
|
"license": "Apache-2.0",
|
|
29
36
|
"dependencies": {
|
|
30
|
-
"@
|
|
37
|
+
"@ai-sdk/ui-utils": "^1.2.11",
|
|
31
38
|
"@lukeed/uuid": "^2.0.1",
|
|
32
|
-
"ai": "^4.3.19",
|
|
33
39
|
"json-schema": "^0.4.0",
|
|
34
40
|
"rxjs": "7.8.1",
|
|
35
|
-
"zod": "^3.
|
|
36
|
-
"
|
|
37
|
-
"@mastra/core": "0.0.0-ai-v5-20250813235735"
|
|
41
|
+
"zod-to-json-schema": "^3.24.6",
|
|
42
|
+
"@mastra/core": "0.0.0-ai-telementry-ui-20250908094819"
|
|
38
43
|
},
|
|
39
44
|
"peerDependencies": {
|
|
40
|
-
"zod": "^3.0.0"
|
|
45
|
+
"zod": "^3.25.0 || ^4.0.0"
|
|
41
46
|
},
|
|
42
47
|
"devDependencies": {
|
|
43
|
-
"@babel/preset-env": "^7.28.
|
|
48
|
+
"@babel/preset-env": "^7.28.3",
|
|
44
49
|
"@babel/preset-typescript": "^7.27.1",
|
|
45
|
-
"@tsconfig/recommended": "^1.0.
|
|
50
|
+
"@tsconfig/recommended": "^1.0.10",
|
|
46
51
|
"@types/json-schema": "^7.0.15",
|
|
47
52
|
"@types/node": "^20.19.0",
|
|
53
|
+
"zod": "^3.25.76",
|
|
54
|
+
"ai": "^4.3.19",
|
|
55
|
+
"eslint": "^9.34.0",
|
|
48
56
|
"globby": "^14.1.0",
|
|
49
57
|
"tsup": "^8.5.0",
|
|
50
58
|
"typescript": "^5.8.3",
|
|
51
59
|
"vitest": "^3.2.4",
|
|
52
|
-
"@internal/
|
|
53
|
-
"@internal/
|
|
60
|
+
"@internal/types-builder": "0.0.0-ai-telementry-ui-20250908094819",
|
|
61
|
+
"@internal/lint": "0.0.0-ai-telementry-ui-20250908094819"
|
|
54
62
|
},
|
|
55
63
|
"scripts": {
|
|
64
|
+
"lint": "eslint .",
|
|
56
65
|
"build": "tsup --config tsup.config.ts",
|
|
57
66
|
"dev": "pnpm build --watch",
|
|
58
|
-
"test": "vitest
|
|
59
|
-
"test:unit": "vitest run"
|
|
60
|
-
"test:integration": "cd integration-tests && pnpm test"
|
|
67
|
+
"test": "vitest",
|
|
68
|
+
"test:unit": "vitest run"
|
|
61
69
|
}
|
|
62
70
|
}
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
> @mastra/client-js@0.10.22-alpha.0 build /home/runner/work/mastra/mastra/client-sdks/client-js
|
|
3
|
-
> tsup --config tsup.config.ts
|
|
4
|
-
|
|
5
|
-
[34mCLI[39m Building entry: src/index.ts
|
|
6
|
-
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
|
-
[34mCLI[39m tsup v8.5.0
|
|
8
|
-
[34mCLI[39m Using tsup config: /home/runner/work/mastra/mastra/client-sdks/client-js/tsup.config.ts
|
|
9
|
-
[34mCLI[39m Target: es2022
|
|
10
|
-
[34mCLI[39m Cleaning output folder
|
|
11
|
-
[34mESM[39m Build start
|
|
12
|
-
[34mCJS[39m Build start
|
|
13
|
-
[32mESM[39m [1mdist/index.js [22m[32m76.67 KB[39m
|
|
14
|
-
[32mESM[39m [1mdist/index.js.map [22m[32m164.37 KB[39m
|
|
15
|
-
[32mESM[39m ⚡️ Build success in 2116ms
|
|
16
|
-
[32mCJS[39m [1mdist/index.cjs [22m[32m76.97 KB[39m
|
|
17
|
-
[32mCJS[39m [1mdist/index.cjs.map [22m[32m164.54 KB[39m
|
|
18
|
-
[32mCJS[39m ⚡️ Build success in 2117ms
|
package/dist/adapters/agui.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { AgentConfig, BaseEvent, Message, RunAgentInput } from '@ag-ui/client';
|
|
2
|
-
import { AbstractAgent } from '@ag-ui/client';
|
|
3
|
-
import { Observable } from 'rxjs';
|
|
4
|
-
import type { Agent } from '../resources/agent.js';
|
|
5
|
-
interface MastraAgentConfig extends AgentConfig {
|
|
6
|
-
agent: Agent;
|
|
7
|
-
agentId: string;
|
|
8
|
-
resourceId?: string;
|
|
9
|
-
}
|
|
10
|
-
export declare class AGUIAdapter extends AbstractAgent {
|
|
11
|
-
agent: Agent;
|
|
12
|
-
resourceId?: string;
|
|
13
|
-
constructor({ agent, agentId, resourceId, ...rest }: MastraAgentConfig);
|
|
14
|
-
protected run(input: RunAgentInput): Observable<BaseEvent>;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Generates a UUID v4 that works in both browser and Node.js environments
|
|
18
|
-
*/
|
|
19
|
-
export declare function generateUUID(): string;
|
|
20
|
-
export declare function convertMessagesToMastraMessages(messages: Message[]): any[];
|
|
21
|
-
export {};
|
|
22
|
-
//# sourceMappingURL=agui.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agui.d.ts","sourceRoot":"","sources":["../../src/adapters/agui.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EACX,SAAS,EACT,OAAO,EACP,aAAa,EASd,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,aAAa,EAAa,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEhD,UAAU,iBAAkB,SAAQ,WAAW;IAC7C,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,WAAY,SAAQ,aAAa;IAC5C,KAAK,EAAE,KAAK,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;gBACR,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,EAAE,iBAAiB;IAStE,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,aAAa,GAAG,UAAU,CAAC,SAAS,CAAC;CA+G3D;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAgCrC;AAED,wBAAgB,+BAA+B,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,GAAG,EAAE,CA2E1E"}
|
package/eslint.config.js
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { spawn } from 'node:child_process';
|
|
2
|
-
import { createServer } from 'node:net';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import type { BaseEvent } from '@ag-ui/client';
|
|
5
|
-
import { describe, it, expect, beforeAll, afterAll } from 'vitest';
|
|
6
|
-
import { AGUIAdapter } from '../src/adapters/agui';
|
|
7
|
-
|
|
8
|
-
// Helper to find an available port
|
|
9
|
-
async function getAvailablePort(): Promise<number> {
|
|
10
|
-
return new Promise((resolve, reject) => {
|
|
11
|
-
const server = createServer();
|
|
12
|
-
server.listen(0, () => {
|
|
13
|
-
const { port } = server.address() as { port: number };
|
|
14
|
-
server.close(() => resolve(port));
|
|
15
|
-
});
|
|
16
|
-
server.on('error', reject);
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
describe.skip('AGUIAdapter Integration Tests', () => {
|
|
21
|
-
let mastraServer: ReturnType<typeof spawn>;
|
|
22
|
-
let port: number;
|
|
23
|
-
|
|
24
|
-
beforeAll(async () => {
|
|
25
|
-
port = await getAvailablePort();
|
|
26
|
-
|
|
27
|
-
// Run mastra dev from the integration tests directory using the built CLI
|
|
28
|
-
const cliPath = path.resolve(import.meta.dirname, '..', '..', '..', 'packages', 'cli', 'dist', 'index.js');
|
|
29
|
-
mastraServer = spawn('node', [cliPath, 'dev', '--port', port.toString()], {
|
|
30
|
-
cwd: path.resolve(import.meta.dirname),
|
|
31
|
-
stdio: 'pipe',
|
|
32
|
-
detached: true, // Run in a new process group so we can kill it and children
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
// Wait for server to be ready
|
|
36
|
-
await new Promise<void>((resolve, reject) => {
|
|
37
|
-
let output = '';
|
|
38
|
-
mastraServer.stdout?.on('data', data => {
|
|
39
|
-
output += data.toString();
|
|
40
|
-
console.log(output);
|
|
41
|
-
if (output.includes('http://localhost:')) {
|
|
42
|
-
resolve();
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
mastraServer.stderr?.on('data', data => {
|
|
46
|
-
console.error('Mastra server error:', data.toString());
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
setTimeout(() => reject(new Error('Mastra server failed to start')), 10000);
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
afterAll(() => {
|
|
54
|
-
// Kill the server and its process group
|
|
55
|
-
if (mastraServer?.pid) {
|
|
56
|
-
try {
|
|
57
|
-
process.kill(-mastraServer.pid, 'SIGTERM');
|
|
58
|
-
} catch (e) {
|
|
59
|
-
console.error('Failed to kill Mastra server:', e);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('should correctly pass parameters to agent stream method with real server', async () => {
|
|
65
|
-
// Create a client agent that communicates with the real server
|
|
66
|
-
const { Agent: ClientAgent } = await import('../src/resources/agent');
|
|
67
|
-
const clientAgent = new ClientAgent(
|
|
68
|
-
{
|
|
69
|
-
baseUrl: `http://localhost:${port}`,
|
|
70
|
-
apiKey: 'test-key',
|
|
71
|
-
},
|
|
72
|
-
'test',
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
const adapter = new AGUIAdapter({
|
|
76
|
-
agent: clientAgent,
|
|
77
|
-
agentId: 'test',
|
|
78
|
-
resourceId: 'testAgent',
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
const input = {
|
|
82
|
-
threadId: 'test-thread-id',
|
|
83
|
-
runId: 'test-run-id',
|
|
84
|
-
messages: [
|
|
85
|
-
{
|
|
86
|
-
id: '1',
|
|
87
|
-
role: 'user' as const,
|
|
88
|
-
content: 'Hello',
|
|
89
|
-
},
|
|
90
|
-
],
|
|
91
|
-
tools: [],
|
|
92
|
-
context: [],
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
const observable = adapter['run'](input);
|
|
96
|
-
const events: BaseEvent[] = [];
|
|
97
|
-
|
|
98
|
-
await new Promise<void>((resolve, reject) => {
|
|
99
|
-
observable.subscribe({
|
|
100
|
-
next: (event: BaseEvent) => events.push(event),
|
|
101
|
-
complete: () => resolve(),
|
|
102
|
-
error: (error: any) => reject(error),
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
// Verify we received the expected events
|
|
107
|
-
expect(events).toHaveLength(7); // RUN_STARTED, TEXT_MESSAGE_START, TEXT_MESSAGE_CONTENT (x3), TEXT_MESSAGE_END, RUN_FINISHED
|
|
108
|
-
expect(events[0].type).toBe('RUN_STARTED');
|
|
109
|
-
expect(events[1].type).toBe('TEXT_MESSAGE_START');
|
|
110
|
-
expect(events[2].type).toBe('TEXT_MESSAGE_CONTENT');
|
|
111
|
-
expect(events[3].type).toBe('TEXT_MESSAGE_CONTENT');
|
|
112
|
-
expect(events[4].type).toBe('TEXT_MESSAGE_CONTENT');
|
|
113
|
-
expect(events[5].type).toBe('TEXT_MESSAGE_END');
|
|
114
|
-
expect(events[6].type).toBe('RUN_FINISHED');
|
|
115
|
-
|
|
116
|
-
// Verify the content was streamed correctly
|
|
117
|
-
const contentEvents = events.filter(e => e.type === 'TEXT_MESSAGE_CONTENT') as any[];
|
|
118
|
-
expect(contentEvents[0].delta).toBe('Hello');
|
|
119
|
-
expect(contentEvents[1].delta).toBe(' from');
|
|
120
|
-
expect(contentEvents[2].delta).toBe(' agent');
|
|
121
|
-
});
|
|
122
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@mastra/client-js-integration-tests",
|
|
3
|
-
"private": true,
|
|
4
|
-
"version": "0.1.0",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"test": "vitest run",
|
|
7
|
-
"test:watch": "vitest"
|
|
8
|
-
},
|
|
9
|
-
"dependencies": {
|
|
10
|
-
"@ag-ui/client": "^0.0.27",
|
|
11
|
-
"@mastra/client-js": "workspace:*",
|
|
12
|
-
"@mastra/core": "workspace:*"
|
|
13
|
-
},
|
|
14
|
-
"devDependencies": {
|
|
15
|
-
"vitest": "^3.2.4"
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Mastra } from '@mastra/core';
|
|
2
|
-
import { Agent } from '@mastra/core/agent';
|
|
3
|
-
import { MockLanguageModelV2, simulateReadableStream } from '@mastra/core/test-utils';
|
|
4
|
-
|
|
5
|
-
const mockModel = new MockLanguageModelV2({
|
|
6
|
-
doStream: async () => ({
|
|
7
|
-
stream: simulateReadableStream({
|
|
8
|
-
chunks: [
|
|
9
|
-
{ type: 'text-delta', textDelta: 'Hello' },
|
|
10
|
-
{ type: 'text-delta', textDelta: ' from' },
|
|
11
|
-
{ type: 'text-delta', textDelta: ' agent' },
|
|
12
|
-
{
|
|
13
|
-
type: 'finish',
|
|
14
|
-
finishReason: 'stop',
|
|
15
|
-
logprobs: undefined,
|
|
16
|
-
usage: { completionTokens: 3, promptTokens: 10 },
|
|
17
|
-
},
|
|
18
|
-
],
|
|
19
|
-
}),
|
|
20
|
-
rawCall: { rawPrompt: null, rawSettings: {} },
|
|
21
|
-
}),
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
const testAgent = new Agent({
|
|
25
|
-
name: 'test',
|
|
26
|
-
instructions: 'You are a test agent',
|
|
27
|
-
model: mockModel,
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
export const mastra = new Mastra({
|
|
31
|
-
agents: {
|
|
32
|
-
test: testAgent,
|
|
33
|
-
},
|
|
34
|
-
systemHostname: 'localhost',
|
|
35
|
-
aiSdkOptions: {
|
|
36
|
-
v4Compat: true,
|
|
37
|
-
},
|
|
38
|
-
});
|