@elizaos/cli 1.0.8 → 1.0.10
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/README.md +9 -16
- package/dist/assets/{index-CZAd5zm2.js → index-CmuPnu0u.js} +72 -89
- package/dist/assets/index-CmuPnu0u.js.br +0 -0
- package/dist/assets/index-CmuPnu0u.js.map +1 -0
- package/dist/assets/{index-CaEsCLCC.js → index-DDQnwxzL.js} +28798 -16391
- package/dist/assets/{index-CaEsCLCC.js.map → index-DDQnwxzL.js.map} +1 -1
- package/dist/assets/index-Df1AFSuJ.css +1 -0
- package/dist/assets/index-Df1AFSuJ.css.br +0 -0
- package/dist/assets/vendor-DSdxb8P-.js.map +1 -1
- package/dist/{chunk-REBZFQYE.js → chunk-7HYEGM5V.js} +967 -1597
- package/dist/{chunk-W3HS2NP6.js → chunk-B4KJXECB.js} +13 -18
- package/dist/{chunk-33BHGAF7.js → chunk-GWQB7PBK.js} +59 -32
- package/dist/{chunk-CVADLFW6.js → chunk-LQ6XHF53.js} +4543 -3043
- package/dist/{chunk-GYTAJJOD.js → chunk-RIAWNDYI.js} +16 -2
- package/dist/{chunk-IEKLJDUU.js → chunk-WS4DWCDZ.js} +54 -32
- package/dist/commands/agent/actions/index.d.ts +5 -1
- package/dist/commands/agent/actions/index.js +5 -4
- package/dist/commands/agent/index.js +3 -4
- package/dist/commands/create/actions/index.js +4 -5
- package/dist/commands/create/index.js +5 -6
- package/dist/{fileFromPath-DCRQMDLJ.js → fileFromPath-KB6XMTJ4.js} +1 -0
- package/dist/index.html +2 -2
- package/dist/index.js +9346 -102098
- package/dist/{migrator-KZLCVEIH.js → migrator-JREQPDN3.js} +42 -220
- package/dist/pglite.data +0 -0
- package/dist/pglite.wasm +0 -0
- package/dist/plugin-creator-T4K2673C.js +910 -0
- package/dist/{registry-XFOSZFU4.js → registry-CBMRMYCG.js} +3 -4
- package/dist/templates/plugin-starter/README.md +255 -0
- package/dist/templates/plugin-starter/bunfig.toml +6 -0
- package/dist/templates/plugin-starter/cypress.config.ts +18 -0
- package/dist/templates/plugin-starter/index.html +13 -0
- package/dist/templates/plugin-starter/package.json +95 -0
- package/dist/templates/plugin-starter/postcss.config.js +3 -0
- package/dist/templates/plugin-starter/scripts/test-e2e-manual.js +201 -0
- package/dist/templates/plugin-starter/src/__tests__/cypress/component/ExampleRoute.cy.tsx +404 -0
- package/dist/templates/plugin-starter/src/__tests__/cypress/component/PanelComponent.cy.tsx +287 -0
- package/dist/templates/plugin-starter/src/__tests__/cypress/support/commands.ts +38 -0
- package/dist/templates/plugin-starter/src/__tests__/cypress/support/component-index.html +11 -0
- package/dist/templates/plugin-starter/src/__tests__/cypress/support/component.ts +33 -0
- package/dist/templates/plugin-starter/src/__tests__/cypress/support/e2e.ts +11 -0
- package/dist/templates/plugin-starter/src/__tests__/cypress/tsconfig.json +10 -0
- package/dist/templates/plugin-starter/src/__tests__/e2e/README.md +47 -0
- package/dist/templates/plugin-starter/src/__tests__/e2e/starter-plugin.ts +320 -0
- package/{templates/plugin-starter → dist/templates/plugin-starter/src}/__tests__/integration.test.ts +22 -17
- package/{templates/plugin-starter → dist/templates/plugin-starter/src}/__tests__/plugin.test.ts +8 -8
- package/{templates/plugin-starter → dist/templates/plugin-starter/src}/__tests__/test-utils.ts +17 -17
- package/dist/templates/plugin-starter/src/frontend/index.css +77 -0
- package/dist/templates/plugin-starter/src/frontend/index.tsx +164 -0
- package/dist/templates/plugin-starter/src/frontend/utils.ts +6 -0
- package/dist/templates/plugin-starter/src/index.ts +274 -0
- package/dist/templates/plugin-starter/src/tests.ts +6 -0
- package/dist/templates/plugin-starter/tailwind.config.js +62 -0
- package/dist/templates/plugin-starter/tsconfig.build.json +11 -0
- package/dist/templates/plugin-starter/tsconfig.json +28 -0
- package/dist/templates/plugin-starter/tsup.config.ts +20 -0
- package/dist/templates/plugin-starter/vite.config.ts +20 -0
- package/dist/templates/project-starter/.env.example +153 -0
- package/dist/templates/project-starter/README.md +109 -0
- package/dist/templates/project-starter/bunfig.toml +6 -0
- package/dist/templates/project-starter/cypress.config.ts +31 -0
- package/dist/templates/project-starter/index.html +13 -0
- package/dist/templates/project-starter/package.json +83 -0
- package/dist/templates/project-starter/postcss.config.js +3 -0
- package/dist/templates/project-starter/scripts/test-all.sh +101 -0
- package/{templates/project-starter → dist/templates/project-starter/src}/__tests__/actions.test.ts +6 -6
- package/{templates/project-starter → dist/templates/project-starter/src}/__tests__/character.test.ts +3 -3
- package/{templates/project-starter → dist/templates/project-starter/src}/__tests__/config.test.ts +18 -18
- package/dist/templates/project-starter/src/__tests__/cypress/component/Accessibility.cy.tsx +271 -0
- package/dist/templates/project-starter/src/__tests__/cypress/component/ApiIntegration.cy.tsx +220 -0
- package/dist/templates/project-starter/src/__tests__/cypress/component/ExampleRoute.cy.tsx +146 -0
- package/dist/templates/project-starter/src/__tests__/cypress/component/PanelComponent.cy.tsx +51 -0
- package/dist/templates/project-starter/src/__tests__/cypress/e2e/agent-chat.cy.ts +235 -0
- package/dist/templates/project-starter/src/__tests__/cypress/e2e/dashboard.cy.ts +146 -0
- package/dist/templates/project-starter/src/__tests__/cypress/e2e/user-workflow.cy.ts +257 -0
- package/dist/templates/project-starter/src/__tests__/cypress/support/commands.ts +44 -0
- package/dist/templates/project-starter/src/__tests__/cypress/support/component-index.html +11 -0
- package/dist/templates/project-starter/src/__tests__/cypress/support/component.ts +33 -0
- package/dist/templates/project-starter/src/__tests__/cypress/support/e2e.ts +179 -0
- package/dist/templates/project-starter/src/__tests__/e2e/index.ts +14 -0
- package/dist/templates/project-starter/src/__tests__/e2e/natural-language.test.ts +246 -0
- package/dist/templates/project-starter/src/__tests__/e2e/project.test.ts +155 -0
- package/dist/templates/project-starter/src/__tests__/e2e/starter-plugin.test.ts +421 -0
- package/{templates/project-starter → dist/templates/project-starter/src}/__tests__/env.test.ts +2 -2
- package/{templates/project-starter → dist/templates/project-starter/src}/__tests__/error-handling.test.ts +17 -17
- package/{templates/project-starter → dist/templates/project-starter/src}/__tests__/events.test.ts +7 -7
- package/dist/templates/project-starter/src/__tests__/file-structure.test.ts +135 -0
- package/{templates/project-starter → dist/templates/project-starter/src}/__tests__/integration.test.ts +25 -25
- package/{templates/project-starter → dist/templates/project-starter/src}/__tests__/models.test.ts +6 -6
- package/{templates/project-starter → dist/templates/project-starter/src}/__tests__/plugin.test.ts +9 -9
- package/{templates/project-starter → dist/templates/project-starter/src}/__tests__/provider.test.ts +7 -7
- package/{templates/project-starter → dist/templates/project-starter/src}/__tests__/routes.test.ts +3 -3
- package/{templates/project-starter → dist/templates/project-starter/src}/__tests__/test-utils.ts +17 -17
- package/{templates/project-starter → dist/templates/project-starter/src}/__tests__/utils/core-test-utils.ts +3 -3
- package/dist/templates/project-starter/src/frontend/index.css +77 -0
- package/dist/templates/project-starter/src/frontend/index.html +19 -0
- package/dist/templates/project-starter/src/frontend/index.tsx +98 -0
- package/dist/templates/project-starter/src/frontend/utils.ts +6 -0
- package/dist/templates/project-starter/src/index.ts +153 -0
- package/dist/templates/project-starter/src/plugin.ts +255 -0
- package/dist/templates/project-starter/tailwind.config.js +62 -0
- package/dist/templates/project-starter/tsconfig.build.json +20 -0
- package/dist/templates/project-starter/tsconfig.json +39 -0
- package/dist/templates/project-starter/tsup.config.ts +19 -0
- package/dist/templates/project-starter/vite.config.ts +39 -0
- package/dist/templates/project-tee-starter/.dockerignore +20 -0
- package/dist/templates/project-tee-starter/.env.example +55 -0
- package/dist/templates/project-tee-starter/Dockerfile +66 -0
- package/dist/templates/project-tee-starter/GUIDE.md +235 -0
- package/dist/templates/project-tee-starter/README.md +173 -0
- package/dist/templates/project-tee-starter/__tests__/actions.test.ts +9 -0
- package/dist/templates/project-tee-starter/__tests__/character.test.ts +86 -0
- package/dist/templates/project-tee-starter/__tests__/config.test.ts +31 -0
- package/dist/templates/project-tee-starter/__tests__/env.test.ts +87 -0
- package/dist/templates/project-tee-starter/__tests__/error-handling.test.ts +30 -0
- package/dist/templates/project-tee-starter/__tests__/events.test.ts +21 -0
- package/{templates/project-starter → dist/templates/project-tee-starter}/__tests__/file-structure.test.ts +6 -6
- package/dist/templates/project-tee-starter/__tests__/integration.test.ts +205 -0
- package/dist/templates/project-tee-starter/__tests__/models.test.ts +22 -0
- package/dist/templates/project-tee-starter/__tests__/plugin.test.ts +38 -0
- package/dist/templates/project-tee-starter/__tests__/provider.test.ts +189 -0
- package/dist/templates/project-tee-starter/__tests__/routes.test.ts +21 -0
- package/dist/templates/project-tee-starter/__tests__/test-utils.ts +121 -0
- package/dist/templates/project-tee-starter/__tests__/utils/core-test-utils.ts +167 -0
- package/dist/templates/project-tee-starter/assets/mr-tee-portrait.jpg +0 -0
- package/dist/templates/project-tee-starter/bunfig.toml +6 -0
- package/dist/templates/project-tee-starter/docker-compose.yaml +57 -0
- package/dist/templates/project-tee-starter/e2e/project.test.ts +38 -0
- package/dist/templates/project-tee-starter/e2e/starter-plugin.test.ts +92 -0
- package/dist/templates/project-tee-starter/package.json +74 -0
- package/dist/templates/project-tee-starter/src/character.ts +257 -0
- package/dist/templates/project-tee-starter/src/index.ts +33 -0
- package/dist/templates/project-tee-starter/src/plugin.ts +169 -0
- package/dist/templates/project-tee-starter/tsconfig.build.json +13 -0
- package/dist/templates/project-tee-starter/tsconfig.json +30 -0
- package/dist/templates/project-tee-starter/tsup.config.ts +19 -0
- package/dist/{utils-DIZZ3HNZ.js → utils-TIALZU53.js} +9 -8
- package/package.json +29 -12
- package/templates/plugin-starter/README.md +38 -13
- package/templates/plugin-starter/bunfig.toml +6 -0
- package/templates/plugin-starter/cypress.config.ts +18 -0
- package/templates/plugin-starter/index.html +13 -0
- package/templates/plugin-starter/package.json +19 -7
- package/templates/plugin-starter/postcss.config.js +3 -0
- package/templates/plugin-starter/scripts/test-e2e-manual.js +201 -0
- package/templates/plugin-starter/src/__tests__/cypress/component/ExampleRoute.cy.tsx +404 -0
- package/templates/plugin-starter/src/__tests__/cypress/component/PanelComponent.cy.tsx +287 -0
- package/templates/plugin-starter/src/__tests__/cypress/support/commands.ts +38 -0
- package/templates/plugin-starter/src/__tests__/cypress/support/component-index.html +11 -0
- package/templates/plugin-starter/src/__tests__/cypress/support/component.ts +33 -0
- package/templates/plugin-starter/src/__tests__/cypress/support/e2e.ts +11 -0
- package/templates/plugin-starter/src/__tests__/cypress/tsconfig.json +10 -0
- package/templates/plugin-starter/src/__tests__/e2e/README.md +47 -0
- package/templates/plugin-starter/src/__tests__/e2e/starter-plugin.ts +320 -0
- package/templates/plugin-starter/src/__tests__/integration.test.ts +138 -0
- package/templates/plugin-starter/src/__tests__/plugin.test.ts +182 -0
- package/templates/plugin-starter/src/__tests__/test-utils.ts +162 -0
- package/templates/plugin-starter/src/frontend/index.css +77 -0
- package/templates/plugin-starter/src/frontend/index.tsx +164 -0
- package/templates/plugin-starter/src/frontend/utils.ts +6 -0
- package/templates/plugin-starter/src/index.ts +31 -8
- package/templates/plugin-starter/src/tests.ts +6 -0
- package/templates/plugin-starter/tailwind.config.js +62 -0
- package/templates/plugin-starter/tsconfig.json +8 -8
- package/templates/plugin-starter/vite.config.ts +20 -0
- package/templates/project-starter/bunfig.toml +6 -0
- package/templates/project-starter/cypress.config.ts +31 -0
- package/templates/project-starter/index.html +13 -0
- package/templates/project-starter/package.json +37 -14
- package/templates/project-starter/postcss.config.js +3 -0
- package/templates/project-starter/scripts/test-all.sh +101 -0
- package/templates/project-starter/src/__tests__/actions.test.ts +155 -0
- package/templates/project-starter/src/__tests__/character.test.ts +86 -0
- package/templates/project-starter/src/__tests__/config.test.ts +193 -0
- package/templates/project-starter/src/__tests__/cypress/component/Accessibility.cy.tsx +271 -0
- package/templates/project-starter/src/__tests__/cypress/component/ApiIntegration.cy.tsx +220 -0
- package/templates/project-starter/src/__tests__/cypress/component/ExampleRoute.cy.tsx +146 -0
- package/templates/project-starter/src/__tests__/cypress/component/PanelComponent.cy.tsx +51 -0
- package/templates/project-starter/src/__tests__/cypress/e2e/agent-chat.cy.ts +235 -0
- package/templates/project-starter/src/__tests__/cypress/e2e/dashboard.cy.ts +146 -0
- package/templates/project-starter/src/__tests__/cypress/e2e/user-workflow.cy.ts +257 -0
- package/templates/project-starter/src/__tests__/cypress/support/commands.ts +44 -0
- package/templates/project-starter/src/__tests__/cypress/support/component-index.html +11 -0
- package/templates/project-starter/src/__tests__/cypress/support/component.ts +33 -0
- package/templates/project-starter/src/__tests__/cypress/support/e2e.ts +179 -0
- package/templates/project-starter/src/__tests__/e2e/index.ts +14 -0
- package/templates/project-starter/src/__tests__/e2e/natural-language.test.ts +246 -0
- package/templates/project-starter/src/__tests__/e2e/project.test.ts +155 -0
- package/templates/project-starter/src/__tests__/e2e/starter-plugin.test.ts +421 -0
- package/templates/project-starter/src/__tests__/env.test.ts +87 -0
- package/templates/project-starter/src/__tests__/error-handling.test.ts +177 -0
- package/templates/project-starter/src/__tests__/events.test.ts +144 -0
- package/templates/project-starter/src/__tests__/file-structure.test.ts +135 -0
- package/templates/project-starter/src/__tests__/integration.test.ts +209 -0
- package/templates/project-starter/src/__tests__/models.test.ts +152 -0
- package/templates/project-starter/src/__tests__/plugin.test.ts +393 -0
- package/templates/project-starter/src/__tests__/provider.test.ts +325 -0
- package/templates/project-starter/src/__tests__/routes.test.ts +79 -0
- package/templates/project-starter/src/__tests__/test-utils.ts +121 -0
- package/templates/project-starter/src/__tests__/utils/core-test-utils.ts +180 -0
- package/templates/project-starter/src/frontend/index.css +77 -0
- package/templates/project-starter/src/frontend/index.html +19 -0
- package/templates/project-starter/src/frontend/index.tsx +98 -0
- package/templates/project-starter/src/frontend/utils.ts +6 -0
- package/templates/project-starter/src/index.ts +9 -1
- package/templates/project-starter/tailwind.config.js +62 -0
- package/templates/project-starter/tsconfig.build.json +9 -2
- package/templates/project-starter/tsconfig.json +15 -6
- package/templates/project-starter/tsup.config.ts +1 -1
- package/templates/project-starter/vite.config.ts +39 -0
- package/templates/project-tee-starter/__tests__/actions.test.ts +1 -1
- package/templates/project-tee-starter/__tests__/character.test.ts +1 -1
- package/templates/project-tee-starter/__tests__/config.test.ts +1 -1
- package/templates/project-tee-starter/__tests__/env.test.ts +2 -2
- package/templates/project-tee-starter/__tests__/error-handling.test.ts +1 -1
- package/templates/project-tee-starter/__tests__/events.test.ts +1 -1
- package/templates/project-tee-starter/__tests__/file-structure.test.ts +5 -5
- package/templates/project-tee-starter/__tests__/integration.test.ts +22 -26
- package/templates/project-tee-starter/__tests__/models.test.ts +1 -1
- package/templates/project-tee-starter/__tests__/plugin.test.ts +6 -12
- package/templates/project-tee-starter/__tests__/provider.test.ts +6 -6
- package/templates/project-tee-starter/__tests__/routes.test.ts +1 -1
- package/templates/project-tee-starter/__tests__/test-utils.ts +15 -15
- package/templates/project-tee-starter/__tests__/utils/core-test-utils.ts +3 -3
- package/templates/project-tee-starter/bunfig.toml +6 -0
- package/templates/project-tee-starter/package.json +10 -12
- package/dist/assets/index-CZAd5zm2.js.br +0 -0
- package/dist/assets/index-CZAd5zm2.js.map +0 -1
- package/dist/assets/index-DyA-lndn.css +0 -1
- package/dist/assets/index-DyA-lndn.css.br +0 -0
- package/dist/chunk-CEE6RKN5.js +0 -2746
- package/dist/chunk-MA2ZXPG6.js +0 -260
- package/dist/chunk-TUAYJIF2.js +0 -3649
- package/dist/lib-NAGYZHVV.js +0 -9
- package/dist/plugin-creator-IC42XOHG.js +0 -29165
- package/templates/plugin-starter/e2e/starter-plugin.test.ts +0 -171
- package/templates/plugin-starter/images/README.md +0 -24
- package/templates/plugin-starter/vitest.config.ts +0 -16
- package/templates/project-starter/e2e/project.test.ts +0 -34
- package/templates/project-starter/e2e/starter-plugin.test.ts +0 -217
- package/templates/project-starter/vitest.config.ts +0 -16
- package/templates/project-tee-starter/vitest.config.ts +0 -19
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { describe, expect, it, spyOn, beforeEach } from 'bun:test';
|
|
2
|
+
import plugin from '../plugin';
|
|
3
|
+
import { logger } from '@elizaos/core';
|
|
4
|
+
|
|
5
|
+
// Mock logger
|
|
6
|
+
spyOnmock('@elizaos/core', async () => {
|
|
7
|
+
const actual = await spyOnimportActual('@elizaos/core');
|
|
8
|
+
return {
|
|
9
|
+
...actual,
|
|
10
|
+
logger: {
|
|
11
|
+
info: spyOnfn(),
|
|
12
|
+
error: spyOnfn(),
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
describe('Plugin Events', () => {
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
spyOnclearAllMocks();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('should have events defined', () => {
|
|
23
|
+
expect(plugin.events).toBeDefined();
|
|
24
|
+
if (plugin.events) {
|
|
25
|
+
expect(Object.keys(plugin.events).length).toBeGreaterThan(0);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('should handle MESSAGE_RECEIVED event', async () => {
|
|
30
|
+
if (plugin.events && plugin.events.MESSAGE_RECEIVED) {
|
|
31
|
+
expect(Array.isArray(plugin.events.MESSAGE_RECEIVED)).toBe(true);
|
|
32
|
+
expect(plugin.events.MESSAGE_RECEIVED.length).toBeGreaterThan(0);
|
|
33
|
+
|
|
34
|
+
const messageHandler = plugin.events.MESSAGE_RECEIVED[0];
|
|
35
|
+
expect(typeof messageHandler).toBe('function');
|
|
36
|
+
|
|
37
|
+
// Use any type to bypass strict type checking for testing
|
|
38
|
+
const mockParams: any = {
|
|
39
|
+
message: {
|
|
40
|
+
id: 'test-id',
|
|
41
|
+
content: { text: 'Hello!' },
|
|
42
|
+
},
|
|
43
|
+
source: 'test',
|
|
44
|
+
runtime: {},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// Call the event handler
|
|
48
|
+
await messageHandler(mockParams);
|
|
49
|
+
|
|
50
|
+
// Verify log was called
|
|
51
|
+
expect(logger.info).toHaveBeenCalledWith('MESSAGE_RECEIVED event received');
|
|
52
|
+
expect(logger.info).toHaveBeenCalledWith(expect.any(Array));
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('should handle VOICE_MESSAGE_RECEIVED event', async () => {
|
|
57
|
+
if (plugin.events && plugin.events.VOICE_MESSAGE_RECEIVED) {
|
|
58
|
+
expect(Array.isArray(plugin.events.VOICE_MESSAGE_RECEIVED)).toBe(true);
|
|
59
|
+
expect(plugin.events.VOICE_MESSAGE_RECEIVED.length).toBeGreaterThan(0);
|
|
60
|
+
|
|
61
|
+
const voiceHandler = plugin.events.VOICE_MESSAGE_RECEIVED[0];
|
|
62
|
+
expect(typeof voiceHandler).toBe('function');
|
|
63
|
+
|
|
64
|
+
// Use any type to bypass strict type checking for testing
|
|
65
|
+
const mockParams: any = {
|
|
66
|
+
message: {
|
|
67
|
+
id: 'test-id',
|
|
68
|
+
content: { text: 'Voice message!' },
|
|
69
|
+
},
|
|
70
|
+
source: 'test',
|
|
71
|
+
runtime: {},
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// Call the event handler
|
|
75
|
+
await voiceHandler(mockParams);
|
|
76
|
+
|
|
77
|
+
// Verify log was called
|
|
78
|
+
expect(logger.info).toHaveBeenCalledWith('VOICE_MESSAGE_RECEIVED event received');
|
|
79
|
+
expect(logger.info).toHaveBeenCalledWith(expect.any(Array));
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('should handle WORLD_CONNECTED event', async () => {
|
|
84
|
+
if (plugin.events && plugin.events.WORLD_CONNECTED) {
|
|
85
|
+
expect(Array.isArray(plugin.events.WORLD_CONNECTED)).toBe(true);
|
|
86
|
+
expect(plugin.events.WORLD_CONNECTED.length).toBeGreaterThan(0);
|
|
87
|
+
|
|
88
|
+
const connectedHandler = plugin.events.WORLD_CONNECTED[0];
|
|
89
|
+
expect(typeof connectedHandler).toBe('function');
|
|
90
|
+
|
|
91
|
+
// Use any type to bypass strict type checking for testing
|
|
92
|
+
const mockParams: any = {
|
|
93
|
+
world: {
|
|
94
|
+
id: 'test-world-id',
|
|
95
|
+
name: 'Test World',
|
|
96
|
+
},
|
|
97
|
+
rooms: [],
|
|
98
|
+
entities: [],
|
|
99
|
+
source: 'test',
|
|
100
|
+
runtime: {},
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
// Call the event handler
|
|
104
|
+
await connectedHandler(mockParams);
|
|
105
|
+
|
|
106
|
+
// Verify log was called
|
|
107
|
+
expect(logger.info).toHaveBeenCalledWith('WORLD_CONNECTED event received');
|
|
108
|
+
expect(logger.info).toHaveBeenCalledWith(expect.any(Array));
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('should handle WORLD_JOINED event', async () => {
|
|
113
|
+
if (plugin.events && plugin.events.WORLD_JOINED) {
|
|
114
|
+
expect(Array.isArray(plugin.events.WORLD_JOINED)).toBe(true);
|
|
115
|
+
expect(plugin.events.WORLD_JOINED.length).toBeGreaterThan(0);
|
|
116
|
+
|
|
117
|
+
const joinedHandler = plugin.events.WORLD_JOINED[0];
|
|
118
|
+
expect(typeof joinedHandler).toBe('function');
|
|
119
|
+
|
|
120
|
+
// Use any type to bypass strict type checking for testing
|
|
121
|
+
const mockParams: any = {
|
|
122
|
+
world: {
|
|
123
|
+
id: 'test-world-id',
|
|
124
|
+
name: 'Test World',
|
|
125
|
+
},
|
|
126
|
+
entity: {
|
|
127
|
+
id: 'test-entity-id',
|
|
128
|
+
name: 'Test Entity',
|
|
129
|
+
},
|
|
130
|
+
rooms: [],
|
|
131
|
+
entities: [],
|
|
132
|
+
source: 'test',
|
|
133
|
+
runtime: {},
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
// Call the event handler
|
|
137
|
+
await joinedHandler(mockParams);
|
|
138
|
+
|
|
139
|
+
// Verify log was called
|
|
140
|
+
expect(logger.info).toHaveBeenCalledWith('WORLD_JOINED event received');
|
|
141
|
+
expect(logger.info).toHaveBeenCalledWith(expect.any(Array));
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
});
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { describe, expect, it } from 'bun:test';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { logger } from '@elizaos/core';
|
|
5
|
+
|
|
6
|
+
// Helper function to check if a file exists
|
|
7
|
+
function fileExists(filePath: string): boolean {
|
|
8
|
+
return fs.existsSync(filePath);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// Helper function to check if a directory exists
|
|
12
|
+
function directoryExists(dirPath: string): boolean {
|
|
13
|
+
return fs.existsSync(dirPath) && fs.statSync(dirPath).isDirectory();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
describe('Project Structure Validation', () => {
|
|
17
|
+
const rootDir = path.resolve(__dirname, '../..');
|
|
18
|
+
|
|
19
|
+
describe('Directory Structure', () => {
|
|
20
|
+
it('should have the expected directory structure', () => {
|
|
21
|
+
expect(directoryExists(path.join(rootDir, 'src'))).toBe(true);
|
|
22
|
+
expect(directoryExists(path.join(rootDir, 'src', '__tests__'))).toBe(true);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('should have a dist directory after building', () => {
|
|
26
|
+
// This test assumes the build has been run before testing
|
|
27
|
+
expect(directoryExists(path.join(rootDir, 'dist'))).toBe(true);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
describe('Source Files', () => {
|
|
32
|
+
it('should contain the required source files', () => {
|
|
33
|
+
expect(fileExists(path.join(rootDir, 'src', 'index.ts'))).toBe(true);
|
|
34
|
+
expect(fileExists(path.join(rootDir, 'src', 'plugin.ts'))).toBe(true);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('should have properly structured main files', () => {
|
|
38
|
+
// Check index.ts contains character definition
|
|
39
|
+
const indexContent = fs.readFileSync(path.join(rootDir, 'src', 'index.ts'), 'utf8');
|
|
40
|
+
expect(indexContent).toContain('character');
|
|
41
|
+
expect(indexContent).toContain('plugin');
|
|
42
|
+
|
|
43
|
+
// Check plugin.ts contains plugin definition
|
|
44
|
+
const pluginContent = fs.readFileSync(path.join(rootDir, 'src', 'plugin.ts'), 'utf8');
|
|
45
|
+
expect(pluginContent).toContain('export default');
|
|
46
|
+
expect(pluginContent).toContain('actions');
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
describe('Configuration Files', () => {
|
|
51
|
+
it('should have the required configuration files', () => {
|
|
52
|
+
expect(fileExists(path.join(rootDir, 'package.json'))).toBe(true);
|
|
53
|
+
expect(fileExists(path.join(rootDir, 'tsconfig.json'))).toBe(true);
|
|
54
|
+
expect(fileExists(path.join(rootDir, 'tsconfig.build.json'))).toBe(true);
|
|
55
|
+
expect(fileExists(path.join(rootDir, 'tsup.config.ts'))).toBe(true);
|
|
56
|
+
expect(fileExists(path.join(rootDir, 'bunfig.toml'))).toBe(true);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('should have the correct package.json configuration', () => {
|
|
60
|
+
const packageJson = JSON.parse(fs.readFileSync(path.join(rootDir, 'package.json'), 'utf8'));
|
|
61
|
+
|
|
62
|
+
// Check package name
|
|
63
|
+
expect(packageJson.name).toBe('@elizaos/project-starter');
|
|
64
|
+
|
|
65
|
+
// Check scripts
|
|
66
|
+
expect(packageJson.scripts).toHaveProperty('build');
|
|
67
|
+
expect(packageJson.scripts).toHaveProperty('test');
|
|
68
|
+
expect(packageJson.scripts).toHaveProperty('test:coverage');
|
|
69
|
+
|
|
70
|
+
// Check dependencies
|
|
71
|
+
expect(packageJson.dependencies).toHaveProperty('@elizaos/core');
|
|
72
|
+
|
|
73
|
+
// Check dev dependencies - adjusted for actual dev dependencies
|
|
74
|
+
expect(packageJson.devDependencies).toBeTruthy();
|
|
75
|
+
// bun test is built-in, no external test framework dependency needed
|
|
76
|
+
expect(packageJson.devDependencies).toHaveProperty('tsup');
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('should have proper TypeScript configuration', () => {
|
|
80
|
+
const tsConfig = JSON.parse(fs.readFileSync(path.join(rootDir, 'tsconfig.json'), 'utf8'));
|
|
81
|
+
|
|
82
|
+
// Check essential compiler options
|
|
83
|
+
expect(tsConfig).toHaveProperty('compilerOptions');
|
|
84
|
+
expect(tsConfig.compilerOptions).toHaveProperty('target');
|
|
85
|
+
expect(tsConfig.compilerOptions).toHaveProperty('module');
|
|
86
|
+
|
|
87
|
+
// Check paths inclusion
|
|
88
|
+
expect(tsConfig).toHaveProperty('include');
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
describe('Build Output', () => {
|
|
93
|
+
it('should check for expected build output structure', () => {
|
|
94
|
+
// Instead of checking specific files, check that the dist directory exists
|
|
95
|
+
// and contains at least some files
|
|
96
|
+
if (directoryExists(path.join(rootDir, 'dist'))) {
|
|
97
|
+
const files = fs.readdirSync(path.join(rootDir, 'dist'));
|
|
98
|
+
expect(files.length).toBeGreaterThan(0);
|
|
99
|
+
|
|
100
|
+
// Check for common output patterns rather than specific files
|
|
101
|
+
const hasJsFiles = files.some((file) => file.endsWith('.js'));
|
|
102
|
+
expect(hasJsFiles).toBe(true);
|
|
103
|
+
} else {
|
|
104
|
+
// Skip test if dist directory doesn't exist yet
|
|
105
|
+
logger.warn('Dist directory not found, skipping build output tests');
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('should verify the build process can be executed', () => {
|
|
110
|
+
// Check that the build script exists in package.json
|
|
111
|
+
const packageJson = JSON.parse(fs.readFileSync(path.join(rootDir, 'package.json'), 'utf8'));
|
|
112
|
+
expect(packageJson.scripts).toHaveProperty('build');
|
|
113
|
+
|
|
114
|
+
// Check that tsup.config.ts exists and contains proper configuration
|
|
115
|
+
const tsupConfig = fs.readFileSync(path.join(rootDir, 'tsup.config.ts'), 'utf8');
|
|
116
|
+
expect(tsupConfig).toContain('export default');
|
|
117
|
+
expect(tsupConfig).toContain('entry');
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
describe('Documentation', () => {
|
|
122
|
+
it('should have README files', () => {
|
|
123
|
+
expect(fileExists(path.join(rootDir, 'README.md'))).toBe(true);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it('should have appropriate documentation content', () => {
|
|
127
|
+
const readmeContent = fs.readFileSync(path.join(rootDir, 'README.md'), 'utf8');
|
|
128
|
+
expect(readmeContent).toContain('Project Starter');
|
|
129
|
+
|
|
130
|
+
// Testing key sections exist without requiring specific keywords
|
|
131
|
+
expect(readmeContent).toContain('Development');
|
|
132
|
+
expect(readmeContent).toContain('Testing');
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
});
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { IAgentRuntime, logger, Plugin } from '@elizaos/core';
|
|
2
|
+
import * as fs from 'node:fs';
|
|
3
|
+
import * as os from 'node:os';
|
|
4
|
+
import * as path from 'node:path';
|
|
5
|
+
import { afterAll, beforeAll, describe, expect, it } from 'bun:test';
|
|
6
|
+
import { character } from '../index';
|
|
7
|
+
import plugin from '../plugin';
|
|
8
|
+
|
|
9
|
+
// Set up spies on logger
|
|
10
|
+
beforeAll(() => {
|
|
11
|
+
spyOn(logger, 'info').mockImplementation(() => {});
|
|
12
|
+
spyOn(logger, 'error').mockImplementation(() => {});
|
|
13
|
+
spyOn(logger, 'warn').mockImplementation(() => {});
|
|
14
|
+
spyOn(logger, 'debug').mockImplementation(() => {});
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
afterAll(() => {
|
|
18
|
+
// No global restore needed in bun:test;
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// Skip in CI environments or when running automated tests without interaction
|
|
22
|
+
const isCI = Boolean(process.env.CI) || process.env.NODE_ENV === 'test';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Integration tests demonstrate how multiple components of the project work together.
|
|
26
|
+
* Unlike unit tests that test individual functions in isolation, integration tests
|
|
27
|
+
* examine how components interact with each other.
|
|
28
|
+
*/
|
|
29
|
+
describe('Integration: Project Structure and Components', () => {
|
|
30
|
+
it('should have a valid package structure', () => {
|
|
31
|
+
const srcDir = path.join(process.cwd(), 'src');
|
|
32
|
+
expect(fs.existsSync(srcDir)).toBe(true);
|
|
33
|
+
|
|
34
|
+
// Check for required source files - only checking core files
|
|
35
|
+
const srcFiles = [path.join(srcDir, 'index.ts'), path.join(srcDir, 'plugin.ts')];
|
|
36
|
+
|
|
37
|
+
srcFiles.forEach((file) => {
|
|
38
|
+
expect(fs.existsSync(file)).toBe(true);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('should have dist directory for build outputs', () => {
|
|
43
|
+
const distDir = path.join(process.cwd(), 'dist');
|
|
44
|
+
|
|
45
|
+
// Skip directory content validation if dist doesn't exist yet
|
|
46
|
+
if (!fs.existsSync(distDir)) {
|
|
47
|
+
logger.warn('Dist directory does not exist yet. Build the project first.');
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
expect(fs.existsSync(distDir)).toBe(true);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
describe('Integration: Character and Plugin', () => {
|
|
56
|
+
it('should have character with required properties', () => {
|
|
57
|
+
// Verify character has required properties
|
|
58
|
+
expect(character).toHaveProperty('name');
|
|
59
|
+
expect(character).toHaveProperty('plugins');
|
|
60
|
+
expect(character).toHaveProperty('bio');
|
|
61
|
+
expect(character).toHaveProperty('system');
|
|
62
|
+
expect(character).toHaveProperty('messageExamples');
|
|
63
|
+
|
|
64
|
+
// Verify plugins is an array
|
|
65
|
+
expect(Array.isArray(character.plugins)).toBe(true);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('should configure plugin correctly', () => {
|
|
69
|
+
// Verify plugin has necessary components that character will use
|
|
70
|
+
expect(plugin).toHaveProperty('name');
|
|
71
|
+
expect(plugin).toHaveProperty('description');
|
|
72
|
+
expect(plugin).toHaveProperty('init');
|
|
73
|
+
|
|
74
|
+
// Check if plugin has actions, models, providers, etc. that character might use
|
|
75
|
+
const components = ['models', 'actions', 'providers', 'services', 'routes', 'events'];
|
|
76
|
+
components.forEach((component) => {
|
|
77
|
+
if ((plugin as any)[component]) {
|
|
78
|
+
// Just verify if these exist, we don't need to test their functionality here
|
|
79
|
+
// Those tests belong in plugin.test.ts, actions.test.ts, etc.
|
|
80
|
+
expect(
|
|
81
|
+
Array.isArray((plugin as any)[component]) ||
|
|
82
|
+
typeof (plugin as any)[component] === 'object'
|
|
83
|
+
).toBeTruthy();
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
describe('Integration: Runtime Initialization', () => {
|
|
90
|
+
it('should create a mock runtime with character and plugin', async () => {
|
|
91
|
+
// Create a custom mock runtime for this test
|
|
92
|
+
const customMockRuntime = {
|
|
93
|
+
character: { ...character },
|
|
94
|
+
plugins: [],
|
|
95
|
+
registerPlugin: spyOnfn().mockImplementation((plugin: Plugin) => {
|
|
96
|
+
// In a real runtime, registering the plugin would call its init method,
|
|
97
|
+
// but since we're testing init itself, we just need to record the call
|
|
98
|
+
return Promise.resolve();
|
|
99
|
+
}),
|
|
100
|
+
initialize: spyOnfn(),
|
|
101
|
+
getService: spyOnfn(),
|
|
102
|
+
getSetting: spyOnfn().mockReturnValue(null),
|
|
103
|
+
useModel: spyOnfn().mockResolvedValue('Test model response'),
|
|
104
|
+
getProviderResults: spyOnfn().mockResolvedValue([]),
|
|
105
|
+
evaluateProviders: spyOnfn().mockResolvedValue([]),
|
|
106
|
+
evaluate: spyOnfn().mockResolvedValue([]),
|
|
107
|
+
} as unknown as IAgentRuntime;
|
|
108
|
+
|
|
109
|
+
// Ensure we're testing safely - to avoid parallel test race conditions
|
|
110
|
+
const originalInit = plugin.init;
|
|
111
|
+
let initCalled = false;
|
|
112
|
+
|
|
113
|
+
// Mock the plugin.init method using spyOnfn instead of direct assignment
|
|
114
|
+
if (plugin.init) {
|
|
115
|
+
plugin.init = spyOnfn(async (config, runtime) => {
|
|
116
|
+
// Set flag to indicate our wrapper was called
|
|
117
|
+
initCalled = true;
|
|
118
|
+
|
|
119
|
+
// Call original if it exists
|
|
120
|
+
if (originalInit) {
|
|
121
|
+
await originalInit(config, runtime);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Register plugin
|
|
125
|
+
await runtime.registerPlugin(plugin);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
try {
|
|
130
|
+
// Initialize plugin in runtime
|
|
131
|
+
if (plugin.init) {
|
|
132
|
+
await plugin.init({ EXAMPLE_PLUGIN_VARIABLE: 'test-value' }, customMockRuntime);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Verify our wrapper was called
|
|
136
|
+
expect(initCalled).toBe(true);
|
|
137
|
+
|
|
138
|
+
// Check if registerPlugin was called
|
|
139
|
+
expect(customMockRuntime.registerPlugin).toHaveBeenCalled();
|
|
140
|
+
} catch (error) {
|
|
141
|
+
console.error('Error initializing plugin:', error);
|
|
142
|
+
throw error;
|
|
143
|
+
} finally {
|
|
144
|
+
// Restore the original init method to avoid affecting other tests
|
|
145
|
+
plugin.init = originalInit;
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
// Skip scaffolding tests in CI environments as they modify the filesystem
|
|
151
|
+
const describeScaffolding = isCI ? describe.skip : describe;
|
|
152
|
+
describeScaffolding('Integration: Project Scaffolding', () => {
|
|
153
|
+
// Create a temp directory for testing the scaffolding
|
|
154
|
+
const TEST_DIR = fs.mkdtempSync(path.join(os.tmpdir(), 'eliza-test-'));
|
|
155
|
+
|
|
156
|
+
beforeAll(() => {
|
|
157
|
+
// Create test directory if it doesn't exist
|
|
158
|
+
if (!fs.existsSync(TEST_DIR)) {
|
|
159
|
+
fs.mkdirSync(TEST_DIR, { recursive: true });
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
afterAll(() => {
|
|
164
|
+
// Clean up test directory
|
|
165
|
+
if (fs.existsSync(TEST_DIR)) {
|
|
166
|
+
fs.rmSync(TEST_DIR, { recursive: true, force: true });
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it('should scaffold a new project correctly', () => {
|
|
171
|
+
try {
|
|
172
|
+
// This is a simple simulation of the scaffolding process
|
|
173
|
+
// In a real scenario, you'd use the CLI or API to scaffold
|
|
174
|
+
|
|
175
|
+
// Copy essential files to test directory
|
|
176
|
+
const srcFiles = ['index.ts', 'plugin.ts', 'character.ts'];
|
|
177
|
+
|
|
178
|
+
for (const file of srcFiles) {
|
|
179
|
+
const sourceFilePath = path.join(process.cwd(), 'src', file);
|
|
180
|
+
const targetFilePath = path.join(TEST_DIR, file);
|
|
181
|
+
|
|
182
|
+
if (fs.existsSync(sourceFilePath)) {
|
|
183
|
+
fs.copyFileSync(sourceFilePath, targetFilePath);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Create package.json in test directory
|
|
188
|
+
const packageJson = {
|
|
189
|
+
name: 'test-project',
|
|
190
|
+
version: '1.0.0',
|
|
191
|
+
type: 'module',
|
|
192
|
+
dependencies: {
|
|
193
|
+
'@elizaos/core': 'workspace:*',
|
|
194
|
+
},
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
fs.writeFileSync(path.join(TEST_DIR, 'package.json'), JSON.stringify(packageJson, null, 2));
|
|
198
|
+
|
|
199
|
+
// Verify files exist
|
|
200
|
+
expect(fs.existsSync(path.join(TEST_DIR, 'index.ts'))).toBe(true);
|
|
201
|
+
expect(fs.existsSync(path.join(TEST_DIR, 'plugin.ts'))).toBe(true);
|
|
202
|
+
expect(fs.existsSync(path.join(TEST_DIR, 'character.ts'))).toBe(true);
|
|
203
|
+
expect(fs.existsSync(path.join(TEST_DIR, 'package.json'))).toBe(true);
|
|
204
|
+
} catch (error) {
|
|
205
|
+
logger.error('Error in scaffolding test:', error);
|
|
206
|
+
throw error;
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
});
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { describe, expect, it, spyOn, beforeAll, afterAll } from 'bun:test';
|
|
2
|
+
import plugin from '../plugin';
|
|
3
|
+
import { ModelType, logger } from '@elizaos/core';
|
|
4
|
+
import type { IAgentRuntime } from '@elizaos/core';
|
|
5
|
+
import dotenv from 'dotenv';
|
|
6
|
+
import { documentTestResult, createMockRuntime } from './utils/core-test-utils';
|
|
7
|
+
|
|
8
|
+
// Define a simplified version of the GenerateTextParams for testing
|
|
9
|
+
interface TestGenerateParams {
|
|
10
|
+
prompt: string;
|
|
11
|
+
stopSequences?: string[];
|
|
12
|
+
maxTokens?: number;
|
|
13
|
+
temperature?: number;
|
|
14
|
+
frequencyPenalty?: number;
|
|
15
|
+
presencePenalty?: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Setup environment variables from .env file
|
|
19
|
+
dotenv.config();
|
|
20
|
+
|
|
21
|
+
// Spy on logger to capture logs for documentation
|
|
22
|
+
beforeAll(() => {
|
|
23
|
+
spyOn(logger, 'info');
|
|
24
|
+
spyOn(logger, 'error');
|
|
25
|
+
spyOn(logger, 'warn');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
afterAll(() => {
|
|
29
|
+
// No global restore needed in bun:test;
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Tests a model function with core testing patterns
|
|
34
|
+
* @param modelType The type of model to test
|
|
35
|
+
* @param modelFn The model function to test
|
|
36
|
+
*/
|
|
37
|
+
const runCoreModelTests = async (
|
|
38
|
+
modelType: keyof typeof ModelType,
|
|
39
|
+
modelFn: (runtime: IAgentRuntime, params: TestGenerateParams) => Promise<string>
|
|
40
|
+
) => {
|
|
41
|
+
// Create a mock runtime for model testing
|
|
42
|
+
const mockRuntime = createMockRuntime();
|
|
43
|
+
|
|
44
|
+
// Test with basic parameters
|
|
45
|
+
const basicParams: TestGenerateParams = {
|
|
46
|
+
prompt: `Test prompt for ${modelType}`,
|
|
47
|
+
stopSequences: ['STOP'],
|
|
48
|
+
maxTokens: 100,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
let basicResponse: string | null = null;
|
|
52
|
+
let basicError: Error | null = null;
|
|
53
|
+
|
|
54
|
+
try {
|
|
55
|
+
basicResponse = await modelFn(mockRuntime, basicParams);
|
|
56
|
+
expect(basicResponse).toBeTruthy();
|
|
57
|
+
expect(typeof basicResponse).toBe('string');
|
|
58
|
+
} catch (e) {
|
|
59
|
+
basicError = e as Error;
|
|
60
|
+
logger.error(`${modelType} model call failed:`, e);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Test with empty prompt
|
|
64
|
+
const emptyParams: TestGenerateParams = {
|
|
65
|
+
prompt: '',
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
let emptyResponse: string | null = null;
|
|
69
|
+
let emptyError: Error | null = null;
|
|
70
|
+
|
|
71
|
+
try {
|
|
72
|
+
emptyResponse = await modelFn(mockRuntime, emptyParams);
|
|
73
|
+
} catch (e) {
|
|
74
|
+
emptyError = e as Error;
|
|
75
|
+
logger.error(`${modelType} empty prompt test failed:`, e);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Test with all parameters
|
|
79
|
+
const fullParams: TestGenerateParams = {
|
|
80
|
+
prompt: `Comprehensive test prompt for ${modelType}`,
|
|
81
|
+
stopSequences: ['STOP1', 'STOP2'],
|
|
82
|
+
maxTokens: 200,
|
|
83
|
+
temperature: 0.8,
|
|
84
|
+
frequencyPenalty: 0.6,
|
|
85
|
+
presencePenalty: 0.4,
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
let fullResponse: string | null = null;
|
|
89
|
+
let fullError: Error | null = null;
|
|
90
|
+
|
|
91
|
+
try {
|
|
92
|
+
fullResponse = await modelFn(mockRuntime, fullParams);
|
|
93
|
+
} catch (e) {
|
|
94
|
+
fullError = e as Error;
|
|
95
|
+
logger.error(`${modelType} all parameters test failed:`, e);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
basic: { response: basicResponse, error: basicError },
|
|
100
|
+
empty: { response: emptyResponse, error: emptyError },
|
|
101
|
+
full: { response: fullResponse, error: fullError },
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
describe('Plugin Models', () => {
|
|
106
|
+
it('should have models defined', () => {
|
|
107
|
+
expect(plugin.models).toBeDefined();
|
|
108
|
+
if (plugin.models) {
|
|
109
|
+
expect(typeof plugin.models).toBe('object');
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
describe('TEXT_SMALL Model', () => {
|
|
114
|
+
it('should have a TEXT_SMALL model defined', () => {
|
|
115
|
+
if (plugin.models) {
|
|
116
|
+
expect(plugin.models).toHaveProperty(ModelType.TEXT_SMALL);
|
|
117
|
+
expect(typeof plugin.models[ModelType.TEXT_SMALL]).toBe('function');
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it('should run core tests for TEXT_SMALL model', async () => {
|
|
122
|
+
if (plugin.models && plugin.models[ModelType.TEXT_SMALL]) {
|
|
123
|
+
const results = await runCoreModelTests(
|
|
124
|
+
ModelType.TEXT_SMALL,
|
|
125
|
+
plugin.models[ModelType.TEXT_SMALL]
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
documentTestResult('TEXT_SMALL core model tests', results);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
describe('TEXT_LARGE Model', () => {
|
|
134
|
+
it('should have a TEXT_LARGE model defined', () => {
|
|
135
|
+
if (plugin.models) {
|
|
136
|
+
expect(plugin.models).toHaveProperty(ModelType.TEXT_LARGE);
|
|
137
|
+
expect(typeof plugin.models[ModelType.TEXT_LARGE]).toBe('function');
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('should run core tests for TEXT_LARGE model', async () => {
|
|
142
|
+
if (plugin.models && plugin.models[ModelType.TEXT_LARGE]) {
|
|
143
|
+
const results = await runCoreModelTests(
|
|
144
|
+
ModelType.TEXT_LARGE,
|
|
145
|
+
plugin.models[ModelType.TEXT_LARGE]
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
documentTestResult('TEXT_LARGE core model tests', results);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
});
|