@elizaos/cli 1.0.10 → 1.0.12
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 +4 -4
- package/dist/assets/{index-DDQnwxzL.js → index-CtxA4ev_.js} +32568 -31589
- package/dist/assets/{index-DDQnwxzL.js.map → index-CtxA4ev_.js.map} +1 -1
- package/dist/assets/{index-CmuPnu0u.js → index-xhCgCbS4.js} +2 -2
- package/dist/assets/index-xhCgCbS4.js.br +0 -0
- package/dist/assets/{index-CmuPnu0u.js.map → index-xhCgCbS4.js.map} +1 -1
- package/dist/assets/vendor-DSdxb8P-.js.map +1 -1
- package/dist/chunk-AQ6OMR2A.js +14 -0
- package/dist/chunk-KB3JDWUI.js +106 -0
- package/dist/{chunk-GWQB7PBK.js → chunk-PYMK3ECE.js} +44 -18
- package/dist/chunk-Y76S7TNK.js +5372 -0
- package/dist/{chunk-B4KJXECB.js → chunk-YDVNTQX3.js} +6 -6
- package/dist/commands/agent/actions/index.js +3 -3
- package/dist/commands/agent/index.js +3 -3
- package/dist/commands/create/actions/index.js +4 -4
- package/dist/commands/create/index.js +5 -5
- package/dist/commands/shared/index.js +1 -1
- package/dist/index.html +1 -1
- package/dist/index.js +344 -7703
- package/dist/migrator-UQ4XFYE5.js +744 -0
- package/dist/{plugin-creator-T4K2673C.js → plugin-creator-TLQLTQIB.js} +8 -11
- package/dist/{registry-CBMRMYCG.js → registry-7PBDJL64.js} +3 -3
- package/dist/templates/plugin-starter/bunfig.toml +5 -1
- package/dist/templates/plugin-starter/package.json +6 -8
- package/dist/templates/plugin-starter/scripts/install-test-deps.js +50 -0
- package/dist/templates/plugin-starter/src/index.ts +1 -1
- package/dist/templates/project-starter/bunfig.toml +13 -1
- package/dist/templates/project-starter/package.json +16 -20
- package/dist/templates/project-starter/scripts/install-test-deps.js +51 -0
- package/dist/templates/project-starter/src/__tests__/config.test.ts +9 -9
- package/dist/templates/project-starter/src/__tests__/error-handling.test.ts +11 -11
- package/dist/templates/project-starter/src/__tests__/events.test.ts +6 -6
- package/dist/templates/project-starter/src/__tests__/integration.test.ts +11 -11
- package/dist/templates/project-starter/src/__tests__/routes.test.ts +2 -2
- package/dist/templates/project-tee-starter/__tests__/env.test.ts +10 -6
- package/dist/templates/project-tee-starter/bunfig.toml +13 -1
- package/dist/templates/project-tee-starter/e2e/project.test.ts +1 -1
- package/dist/templates/project-tee-starter/e2e/starter-plugin.test.ts +1 -1
- package/dist/templates/project-tee-starter/package.json +3 -3
- package/dist/{utils-TIALZU53.js → utils-WRGBZBAJ.js} +9 -3
- package/package.json +28 -56
- package/templates/plugin-starter/bunfig.toml +5 -1
- package/templates/plugin-starter/package.json +6 -8
- package/templates/plugin-starter/scripts/install-test-deps.js +50 -0
- package/templates/plugin-starter/src/index.ts +1 -1
- package/templates/project-starter/bunfig.toml +13 -1
- package/templates/project-starter/package.json +16 -20
- package/templates/project-starter/scripts/install-test-deps.js +51 -0
- package/templates/project-starter/src/__tests__/config.test.ts +9 -9
- package/templates/project-starter/src/__tests__/error-handling.test.ts +11 -11
- package/templates/project-starter/src/__tests__/events.test.ts +6 -6
- package/templates/project-starter/src/__tests__/integration.test.ts +11 -11
- package/templates/project-starter/src/__tests__/routes.test.ts +2 -2
- package/templates/project-tee-starter/__tests__/env.test.ts +10 -6
- package/templates/project-tee-starter/bunfig.toml +13 -1
- package/templates/project-tee-starter/e2e/project.test.ts +1 -1
- package/templates/project-tee-starter/e2e/starter-plugin.test.ts +1 -1
- package/templates/project-tee-starter/package.json +3 -3
- package/dist/assets/index-CmuPnu0u.js.br +0 -0
- package/dist/chunk-2GXSCVA2.js +0 -2057
- package/dist/chunk-567UPUC7.js +0 -52
- package/dist/chunk-7HYEGM5V.js +0 -11098
- package/dist/chunk-LQ6XHF53.js +0 -19487
- package/dist/chunk-WS4DWCDZ.js +0 -892
- package/dist/fileFromPath-KB6XMTJ4.js +0 -133
- package/dist/migrator-JREQPDN3.js +0 -7523
- package/dist/pglite.data +0 -0
- package/dist/pglite.wasm +0 -0
|
@@ -2,24 +2,21 @@
|
|
|
2
2
|
import { createRequire } from 'module';
|
|
3
3
|
const require = createRequire(import.meta.url);
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
esm_default,
|
|
7
|
-
ora,
|
|
8
|
-
sdk_default
|
|
9
|
-
} from "./chunk-LQ6XHF53.js";
|
|
10
|
-
import "./chunk-2GXSCVA2.js";
|
|
11
5
|
import {
|
|
12
6
|
runBunCommand
|
|
13
7
|
} from "./chunk-RIAWNDYI.js";
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-KB3JDWUI.js";
|
|
9
|
+
import "./chunk-AQ6OMR2A.js";
|
|
16
10
|
|
|
17
11
|
// src/utils/plugin-creator.ts
|
|
12
|
+
import Anthropic from "@anthropic-ai/sdk";
|
|
18
13
|
import { logger } from "@elizaos/core";
|
|
19
14
|
import { execa } from "execa";
|
|
20
15
|
import * as fs from "fs-extra";
|
|
21
16
|
import inquirer from "inquirer";
|
|
17
|
+
import ora from "ora";
|
|
22
18
|
import * as path from "path";
|
|
19
|
+
import simpleGit from "simple-git";
|
|
23
20
|
import * as os from "os";
|
|
24
21
|
var MAX_BUILD_ITERATIONS = 5;
|
|
25
22
|
var MAX_TEST_ITERATIONS = 5;
|
|
@@ -33,7 +30,7 @@ var PluginCreator = class {
|
|
|
33
30
|
activeClaudeProcess = null;
|
|
34
31
|
options;
|
|
35
32
|
constructor(options = {}) {
|
|
36
|
-
this.git =
|
|
33
|
+
this.git = simpleGit();
|
|
37
34
|
this.options = options;
|
|
38
35
|
this.registerCleanupHandlers();
|
|
39
36
|
}
|
|
@@ -63,7 +60,7 @@ var PluginCreator = class {
|
|
|
63
60
|
logger.error("ANTHROPIC_API_KEY not found in environment.");
|
|
64
61
|
throw new Error("ANTHROPIC_API_KEY is required for plugin generation");
|
|
65
62
|
}
|
|
66
|
-
this.anthropic = new
|
|
63
|
+
this.anthropic = new Anthropic({ apiKey });
|
|
67
64
|
}
|
|
68
65
|
async create(pluginSpec) {
|
|
69
66
|
const spinner = ora("Initializing plugin creator...").start();
|
|
@@ -232,7 +229,7 @@ var PluginCreator = class {
|
|
|
232
229
|
logger.warn("Failed to use elizaos create, creating structure manually");
|
|
233
230
|
await this.createPluginStructureManually(pluginName);
|
|
234
231
|
}
|
|
235
|
-
this.git =
|
|
232
|
+
this.git = simpleGit(this.pluginPath);
|
|
236
233
|
await this.git.init();
|
|
237
234
|
await this.git.add(".");
|
|
238
235
|
await this.git.commit("Initial commit from plugin-starter template");
|
|
@@ -28,11 +28,11 @@ import {
|
|
|
28
28
|
setEnvVar,
|
|
29
29
|
setGitHubToken,
|
|
30
30
|
validateDataDir
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-Y76S7TNK.js";
|
|
32
32
|
import "./chunk-RIAWNDYI.js";
|
|
33
|
-
import "./chunk-
|
|
33
|
+
import "./chunk-KB3JDWUI.js";
|
|
34
34
|
import "./chunk-F24MS2YR.js";
|
|
35
|
-
import "./chunk-
|
|
35
|
+
import "./chunk-AQ6OMR2A.js";
|
|
36
36
|
export {
|
|
37
37
|
checkDataDir,
|
|
38
38
|
ensureElizaDir,
|
|
@@ -50,12 +50,9 @@
|
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@cypress/react": "^9.0.1",
|
|
54
53
|
"@elizaos/cli": "^1.0.0",
|
|
55
54
|
"@tailwindcss/vite": "^4.1.10",
|
|
56
|
-
"@testing-library/cypress": "^10.0.3",
|
|
57
55
|
"@vitejs/plugin-react-swc": "^3.10.2",
|
|
58
|
-
"cypress": "^14.4.1",
|
|
59
56
|
"dotenv": "16.4.5",
|
|
60
57
|
"prettier": "3.5.3",
|
|
61
58
|
"tailwindcss-animate": "^1.0.7",
|
|
@@ -67,11 +64,12 @@
|
|
|
67
64
|
"dev": "elizaos dev",
|
|
68
65
|
"build": "tsc --noEmit && vite build && tsup",
|
|
69
66
|
"lint": "prettier --write ./src",
|
|
70
|
-
"test:component": "bun test",
|
|
71
|
-
"test:e2e": "bun test",
|
|
72
|
-
"test:e2e:manual": "node scripts/test-e2e-manual.js",
|
|
73
|
-
"test:cypress": "cypress run --component",
|
|
74
|
-
"test": "bun run test:component && bun run test:e2e",
|
|
67
|
+
"test:component": "bun run test:install && bun test",
|
|
68
|
+
"test:e2e": "bun run test:install && bun test",
|
|
69
|
+
"test:e2e:manual": "bun run test:install && node scripts/test-e2e-manual.js",
|
|
70
|
+
"test:cypress": "bun run test:install && cypress run --component",
|
|
71
|
+
"test": "bun run test:install && bun run test:component && bun run test:e2e",
|
|
72
|
+
"test:install": "node scripts/install-test-deps.js",
|
|
75
73
|
"publish": "elizaos publish",
|
|
76
74
|
"format": "prettier --write ./src",
|
|
77
75
|
"format:check": "prettier --check ./src"
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { existsSync, readFileSync } from 'fs';
|
|
4
|
+
import { execSync } from 'child_process';
|
|
5
|
+
import { join } from 'path';
|
|
6
|
+
|
|
7
|
+
const testDependencies = {
|
|
8
|
+
'@cypress/react': '^9.0.1',
|
|
9
|
+
'@testing-library/cypress': '^10.0.3',
|
|
10
|
+
cypress: '^14.4.1',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
function isInstalled(packageName) {
|
|
14
|
+
try {
|
|
15
|
+
const packageJsonPath = join(process.cwd(), 'package.json');
|
|
16
|
+
if (existsSync(packageJsonPath)) {
|
|
17
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
|
|
18
|
+
const deps = { ...packageJson.dependencies, ...packageJson.devDependencies };
|
|
19
|
+
return packageName in deps;
|
|
20
|
+
}
|
|
21
|
+
} catch (error) {
|
|
22
|
+
// Silent fail, will install if error
|
|
23
|
+
}
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function installTestDependencies() {
|
|
28
|
+
const missingDeps = Object.entries(testDependencies)
|
|
29
|
+
.filter(([name]) => !isInstalled(name))
|
|
30
|
+
.map(([name, version]) => `${name}@${version}`);
|
|
31
|
+
|
|
32
|
+
if (missingDeps.length === 0) {
|
|
33
|
+
console.log('✓ Test dependencies already installed');
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
console.log('Installing test dependencies...');
|
|
38
|
+
try {
|
|
39
|
+
execSync(`bun add -d ${missingDeps.join(' ')}`, {
|
|
40
|
+
stdio: 'inherit',
|
|
41
|
+
cwd: process.cwd(),
|
|
42
|
+
});
|
|
43
|
+
console.log('✓ Test dependencies installed successfully');
|
|
44
|
+
} catch (error) {
|
|
45
|
+
console.error('Failed to install test dependencies:', error.message);
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
installTestDependencies();
|
|
@@ -268,7 +268,7 @@ export const starterPlugin: Plugin = {
|
|
|
268
268
|
actions: [helloWorldAction],
|
|
269
269
|
providers: [helloWorldProvider],
|
|
270
270
|
tests: [StarterPluginTestSuite],
|
|
271
|
-
// dependencies: ['@elizaos/plugin-knowledge'], <--- plugin
|
|
271
|
+
// dependencies: ['@elizaos/plugin-knowledge'], <--- plugin dependencies go here (if requires another plugin)
|
|
272
272
|
};
|
|
273
273
|
|
|
274
274
|
export default starterPlugin;
|
|
@@ -3,4 +3,16 @@ timeout = 60000
|
|
|
3
3
|
coverage = true
|
|
4
4
|
|
|
5
5
|
[test.env]
|
|
6
|
-
NODE_ENV = "test"
|
|
6
|
+
NODE_ENV = "test"
|
|
7
|
+
|
|
8
|
+
coverage-exclude = [
|
|
9
|
+
"**/dist/**",
|
|
10
|
+
"**/build/**",
|
|
11
|
+
"**/chunk-*.js",
|
|
12
|
+
"**/*.chunk.js",
|
|
13
|
+
"**/node_modules/**",
|
|
14
|
+
"**/*.min.js",
|
|
15
|
+
"**/*.bundle.js",
|
|
16
|
+
"**/coverage/**",
|
|
17
|
+
"**/.turbo/**",
|
|
18
|
+
]
|
|
@@ -28,11 +28,10 @@
|
|
|
28
28
|
"dist"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@elizaos/cli": "1.0.
|
|
32
|
-
"@elizaos/core": "1.0.
|
|
33
|
-
"@elizaos/plugin-bootstrap": "1.0.
|
|
34
|
-
"@elizaos/plugin-
|
|
35
|
-
"@elizaos/plugin-sql": "1.0.9",
|
|
31
|
+
"@elizaos/cli": "1.0.12",
|
|
32
|
+
"@elizaos/core": "1.0.12",
|
|
33
|
+
"@elizaos/plugin-bootstrap": "1.0.12",
|
|
34
|
+
"@elizaos/plugin-sql": "1.0.12",
|
|
36
35
|
"@tanstack/react-query": "^5.29.0",
|
|
37
36
|
"clsx": "^2.1.1",
|
|
38
37
|
"react": "^18.3.1",
|
|
@@ -42,13 +41,9 @@
|
|
|
42
41
|
"zod": "3.24.2"
|
|
43
42
|
},
|
|
44
43
|
"devDependencies": {
|
|
45
|
-
"@cypress/react": "^9.0.1",
|
|
46
|
-
"@cypress/vite-dev-server": "^6.0.3",
|
|
47
|
-
"@testing-library/cypress": "^10.0.3",
|
|
48
44
|
"@types/react": "^18.3.3",
|
|
49
45
|
"@types/react-dom": "^18.3.0",
|
|
50
46
|
"@vitejs/plugin-react": "^4.3.1",
|
|
51
|
-
"cypress": "^14.4.1",
|
|
52
47
|
"prettier": "3.5.3",
|
|
53
48
|
"tsup": "8.5.0",
|
|
54
49
|
"typescript": "^5.6.3",
|
|
@@ -61,20 +56,21 @@
|
|
|
61
56
|
"lint": "prettier --write ./src",
|
|
62
57
|
"type-check": "tsc --noEmit",
|
|
63
58
|
"type-check:watch": "tsc --noEmit --watch",
|
|
64
|
-
"test:component": "bun test",
|
|
65
|
-
"test:e2e": "bun test",
|
|
66
|
-
"test": "bun run test:component && bun run test:e2e",
|
|
67
|
-
"test:coverage": "bun test --coverage",
|
|
68
|
-
"test:watch": "bun test --watch",
|
|
59
|
+
"test:component": "bun run test:install && bun test",
|
|
60
|
+
"test:e2e": "bun run test:install && bun test",
|
|
61
|
+
"test": "bun run test:install && bun run test:component && bun run test:e2e",
|
|
62
|
+
"test:coverage": "bun run test:install && bun test --coverage",
|
|
63
|
+
"test:watch": "bun run test:install && bun test --watch",
|
|
64
|
+
"test:install": "node scripts/install-test-deps.js",
|
|
69
65
|
"format": "prettier --write ./src",
|
|
70
66
|
"format:check": "prettier --check ./src",
|
|
71
67
|
"check-all": "bun run type-check && bun run format:check && bun run test",
|
|
72
|
-
"cy:open": "cypress open",
|
|
73
|
-
"cy:run": "cypress run --component",
|
|
74
|
-
"cy:test": "cypress run --component --reporter spec",
|
|
75
|
-
"cypress:component": "cypress run --component",
|
|
76
|
-
"cypress:e2e": "cypress run --e2e",
|
|
77
|
-
"cypress:open": "cypress open"
|
|
68
|
+
"cy:open": "bun run test:install && cypress open",
|
|
69
|
+
"cy:run": "bun run test:install && cypress run --component",
|
|
70
|
+
"cy:test": "bun run test:install && cypress run --component --reporter spec",
|
|
71
|
+
"cypress:component": "bun run test:install && cypress run --component",
|
|
72
|
+
"cypress:e2e": "bun run test:install && cypress run --e2e",
|
|
73
|
+
"cypress:open": "bun run test:install && cypress open"
|
|
78
74
|
},
|
|
79
75
|
"publishConfig": {
|
|
80
76
|
"access": "public"
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { existsSync, readFileSync } from 'fs';
|
|
4
|
+
import { execSync } from 'child_process';
|
|
5
|
+
import { join } from 'path';
|
|
6
|
+
|
|
7
|
+
const testDependencies = {
|
|
8
|
+
'@cypress/react': '^9.0.1',
|
|
9
|
+
'@cypress/vite-dev-server': '^6.0.3',
|
|
10
|
+
'@testing-library/cypress': '^10.0.3',
|
|
11
|
+
cypress: '^14.4.1',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
function isInstalled(packageName) {
|
|
15
|
+
try {
|
|
16
|
+
const packageJsonPath = join(process.cwd(), 'package.json');
|
|
17
|
+
if (existsSync(packageJsonPath)) {
|
|
18
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
|
|
19
|
+
const deps = { ...packageJson.dependencies, ...packageJson.devDependencies };
|
|
20
|
+
return packageName in deps;
|
|
21
|
+
}
|
|
22
|
+
} catch (error) {
|
|
23
|
+
// Silent fail, will install if error
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function installTestDependencies() {
|
|
29
|
+
const missingDeps = Object.entries(testDependencies)
|
|
30
|
+
.filter(([name]) => !isInstalled(name))
|
|
31
|
+
.map(([name, version]) => `${name}@${version}`);
|
|
32
|
+
|
|
33
|
+
if (missingDeps.length === 0) {
|
|
34
|
+
console.log('✓ Test dependencies already installed');
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
console.log('Installing test dependencies...');
|
|
39
|
+
try {
|
|
40
|
+
execSync(`bun add -d ${missingDeps.join(' ')}`, {
|
|
41
|
+
stdio: 'inherit',
|
|
42
|
+
cwd: process.cwd(),
|
|
43
|
+
});
|
|
44
|
+
console.log('✓ Test dependencies installed successfully');
|
|
45
|
+
} catch (error) {
|
|
46
|
+
console.error('Failed to install test dependencies:', error.message);
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
installTestDependencies();
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { describe, expect, it,
|
|
1
|
+
import { describe, expect, it, beforeEach, afterEach, mock } from 'bun:test';
|
|
2
2
|
import plugin from '../plugin';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { createMockRuntime } from './utils/core-test-utils';
|
|
5
5
|
|
|
6
6
|
// Mock logger
|
|
7
|
-
|
|
8
|
-
const actual =
|
|
7
|
+
mock.module('@elizaos/core', () => {
|
|
8
|
+
const actual = require('@elizaos/core');
|
|
9
9
|
return {
|
|
10
10
|
...actual,
|
|
11
11
|
logger: {
|
|
12
|
-
info:
|
|
13
|
-
error:
|
|
14
|
-
warn:
|
|
12
|
+
info: mock(),
|
|
13
|
+
error: mock(),
|
|
14
|
+
warn: mock(),
|
|
15
15
|
},
|
|
16
16
|
};
|
|
17
17
|
});
|
|
@@ -24,7 +24,7 @@ describe('Plugin Configuration Schema', () => {
|
|
|
24
24
|
const originalEnv = { ...process.env };
|
|
25
25
|
|
|
26
26
|
beforeEach(() => {
|
|
27
|
-
|
|
27
|
+
mock.restore();
|
|
28
28
|
// Reset environment variables before each test
|
|
29
29
|
process.env = { ...originalEnv };
|
|
30
30
|
});
|
|
@@ -150,7 +150,7 @@ describe('Plugin Configuration Schema', () => {
|
|
|
150
150
|
|
|
151
151
|
// Mock the parseAsync function
|
|
152
152
|
const originalParseAsync = schema.parseAsync;
|
|
153
|
-
schema.parseAsync =
|
|
153
|
+
schema.parseAsync = mock().mockRejectedValue(mockZodError);
|
|
154
154
|
|
|
155
155
|
try {
|
|
156
156
|
// Use the mocked schema directly to avoid TypeScript errors
|
|
@@ -176,7 +176,7 @@ describe('Plugin Configuration Schema', () => {
|
|
|
176
176
|
|
|
177
177
|
// Mock the parseAsync function
|
|
178
178
|
const originalParseAsync = schema.parseAsync;
|
|
179
|
-
schema.parseAsync =
|
|
179
|
+
schema.parseAsync = mock().mockRejectedValue(genericError);
|
|
180
180
|
|
|
181
181
|
try {
|
|
182
182
|
// Use the mocked schema directly to avoid TypeScript errors
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { describe, expect, it,
|
|
1
|
+
import { describe, expect, it, beforeEach, afterEach, mock, spyOn } from 'bun:test';
|
|
2
2
|
import plugin from '../plugin';
|
|
3
3
|
import { StarterService } from '../plugin';
|
|
4
4
|
import { logger } from '@elizaos/core';
|
|
@@ -6,21 +6,21 @@ import type { IAgentRuntime, Memory, State } from '@elizaos/core';
|
|
|
6
6
|
import { v4 as uuidv4 } from 'uuid';
|
|
7
7
|
|
|
8
8
|
// Mock logger
|
|
9
|
-
|
|
10
|
-
const actual =
|
|
9
|
+
mock.module('@elizaos/core', () => {
|
|
10
|
+
const actual = require('@elizaos/core');
|
|
11
11
|
return {
|
|
12
12
|
...actual,
|
|
13
13
|
logger: {
|
|
14
|
-
info:
|
|
15
|
-
error:
|
|
16
|
-
warn:
|
|
14
|
+
info: mock(),
|
|
15
|
+
error: mock(),
|
|
16
|
+
warn: mock(),
|
|
17
17
|
},
|
|
18
18
|
};
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
describe('Error Handling', () => {
|
|
22
22
|
beforeEach(() => {
|
|
23
|
-
|
|
23
|
+
mock.restore();
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
afterEach(() => {
|
|
@@ -57,7 +57,7 @@ describe('Error Handling', () => {
|
|
|
57
57
|
text: '',
|
|
58
58
|
} as State;
|
|
59
59
|
|
|
60
|
-
const mockCallback =
|
|
60
|
+
const mockCallback = mock();
|
|
61
61
|
|
|
62
62
|
// Mock the logger.error to verify it's called
|
|
63
63
|
spyOn(logger, 'error');
|
|
@@ -80,7 +80,7 @@ describe('Error Handling', () => {
|
|
|
80
80
|
describe('Service Error Handling', () => {
|
|
81
81
|
it('should throw an error when stopping non-existent service', async () => {
|
|
82
82
|
const mockRuntime = {
|
|
83
|
-
getService:
|
|
83
|
+
getService: mock().mockReturnValue(null),
|
|
84
84
|
} as unknown as IAgentRuntime;
|
|
85
85
|
|
|
86
86
|
let caughtError = null;
|
|
@@ -97,13 +97,13 @@ describe('Error Handling', () => {
|
|
|
97
97
|
|
|
98
98
|
it('should handle service stop errors gracefully', async () => {
|
|
99
99
|
const mockServiceWithError = {
|
|
100
|
-
stop:
|
|
100
|
+
stop: mock().mockImplementation(() => {
|
|
101
101
|
throw new Error('Error stopping service');
|
|
102
102
|
}),
|
|
103
103
|
};
|
|
104
104
|
|
|
105
105
|
const mockRuntime = {
|
|
106
|
-
getService:
|
|
106
|
+
getService: mock().mockReturnValue(mockServiceWithError),
|
|
107
107
|
} as unknown as IAgentRuntime;
|
|
108
108
|
|
|
109
109
|
// The error should be propagated
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { describe, expect, it,
|
|
1
|
+
import { describe, expect, it, beforeEach, mock } from 'bun:test';
|
|
2
2
|
import plugin from '../plugin';
|
|
3
3
|
import { logger } from '@elizaos/core';
|
|
4
4
|
|
|
5
5
|
// Mock logger
|
|
6
|
-
|
|
7
|
-
const actual =
|
|
6
|
+
mock.module('@elizaos/core', () => {
|
|
7
|
+
const actual = require('@elizaos/core');
|
|
8
8
|
return {
|
|
9
9
|
...actual,
|
|
10
10
|
logger: {
|
|
11
|
-
info:
|
|
12
|
-
error:
|
|
11
|
+
info: mock(),
|
|
12
|
+
error: mock(),
|
|
13
13
|
},
|
|
14
14
|
};
|
|
15
15
|
});
|
|
16
16
|
|
|
17
17
|
describe('Plugin Events', () => {
|
|
18
18
|
beforeEach(() => {
|
|
19
|
-
|
|
19
|
+
mock.restore();
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
it('should have events defined', () => {
|
|
@@ -2,7 +2,7 @@ import { IAgentRuntime, logger, Plugin } from '@elizaos/core';
|
|
|
2
2
|
import * as fs from 'node:fs';
|
|
3
3
|
import * as os from 'node:os';
|
|
4
4
|
import * as path from 'node:path';
|
|
5
|
-
import { afterAll, beforeAll, describe, expect, it } from 'bun:test';
|
|
5
|
+
import { afterAll, beforeAll, describe, expect, it, mock, spyOn } from 'bun:test';
|
|
6
6
|
import { character } from '../index';
|
|
7
7
|
import plugin from '../plugin';
|
|
8
8
|
|
|
@@ -92,27 +92,27 @@ describe('Integration: Runtime Initialization', () => {
|
|
|
92
92
|
const customMockRuntime = {
|
|
93
93
|
character: { ...character },
|
|
94
94
|
plugins: [],
|
|
95
|
-
registerPlugin:
|
|
95
|
+
registerPlugin: mock().mockImplementation((plugin: Plugin) => {
|
|
96
96
|
// In a real runtime, registering the plugin would call its init method,
|
|
97
97
|
// but since we're testing init itself, we just need to record the call
|
|
98
98
|
return Promise.resolve();
|
|
99
99
|
}),
|
|
100
|
-
initialize:
|
|
101
|
-
getService:
|
|
102
|
-
getSetting:
|
|
103
|
-
useModel:
|
|
104
|
-
getProviderResults:
|
|
105
|
-
evaluateProviders:
|
|
106
|
-
evaluate:
|
|
100
|
+
initialize: mock(),
|
|
101
|
+
getService: mock(),
|
|
102
|
+
getSetting: mock().mockReturnValue(null),
|
|
103
|
+
useModel: mock().mockResolvedValue('Test model response'),
|
|
104
|
+
getProviderResults: mock().mockResolvedValue([]),
|
|
105
|
+
evaluateProviders: mock().mockResolvedValue([]),
|
|
106
|
+
evaluate: mock().mockResolvedValue([]),
|
|
107
107
|
} as unknown as IAgentRuntime;
|
|
108
108
|
|
|
109
109
|
// Ensure we're testing safely - to avoid parallel test race conditions
|
|
110
110
|
const originalInit = plugin.init;
|
|
111
111
|
let initCalled = false;
|
|
112
112
|
|
|
113
|
-
// Mock the plugin.init method using
|
|
113
|
+
// Mock the plugin.init method using mock instead of direct assignment
|
|
114
114
|
if (plugin.init) {
|
|
115
|
-
plugin.init =
|
|
115
|
+
plugin.init = mock(async (config, runtime) => {
|
|
116
116
|
// Set flag to indicate our wrapper was called
|
|
117
117
|
initCalled = true;
|
|
118
118
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { describe, expect, it } from 'bun:test';
|
|
1
|
+
import { describe, expect, it, mock } from 'bun:test';
|
|
2
2
|
import plugin from '../plugin';
|
|
3
3
|
|
|
4
4
|
describe('Plugin Routes', () => {
|
|
@@ -30,7 +30,7 @@ describe('Plugin Routes', () => {
|
|
|
30
30
|
// Create mock request and response objects
|
|
31
31
|
const mockReq = {};
|
|
32
32
|
const mockRes = {
|
|
33
|
-
json:
|
|
33
|
+
json: mock(),
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
// Mock runtime object as third parameter
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { describe, expect, it } from 'bun:test';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
|
|
6
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
const projectRoot = path.resolve(__dirname, '..');
|
|
4
8
|
|
|
5
9
|
describe('Environment Setup', () => {
|
|
6
10
|
it('should verify configuration files exist', () => {
|
|
@@ -13,13 +17,13 @@ describe('Environment Setup', () => {
|
|
|
13
17
|
];
|
|
14
18
|
|
|
15
19
|
for (const file of requiredFiles) {
|
|
16
|
-
const filePath = path.join(
|
|
20
|
+
const filePath = path.join(projectRoot, file);
|
|
17
21
|
expect(fs.existsSync(filePath)).toBe(true);
|
|
18
22
|
}
|
|
19
23
|
});
|
|
20
24
|
|
|
21
25
|
it('should have proper src directory structure', () => {
|
|
22
|
-
const srcDir = path.join(
|
|
26
|
+
const srcDir = path.join(projectRoot, 'src');
|
|
23
27
|
expect(fs.existsSync(srcDir)).toBe(true);
|
|
24
28
|
|
|
25
29
|
const requiredSrcFiles = ['index.ts', 'plugin.ts'];
|
|
@@ -31,7 +35,7 @@ describe('Environment Setup', () => {
|
|
|
31
35
|
});
|
|
32
36
|
|
|
33
37
|
it('should have a valid package.json with required fields', () => {
|
|
34
|
-
const packageJsonPath = path.join(
|
|
38
|
+
const packageJsonPath = path.join(projectRoot, 'package.json');
|
|
35
39
|
expect(fs.existsSync(packageJsonPath)).toBe(true);
|
|
36
40
|
|
|
37
41
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
@@ -54,7 +58,7 @@ describe('Environment Setup', () => {
|
|
|
54
58
|
});
|
|
55
59
|
|
|
56
60
|
it('should have a valid tsconfig.json with required configuration', () => {
|
|
57
|
-
const tsconfigPath = path.join(
|
|
61
|
+
const tsconfigPath = path.join(projectRoot, 'tsconfig.json');
|
|
58
62
|
expect(fs.existsSync(tsconfigPath)).toBe(true);
|
|
59
63
|
|
|
60
64
|
const tsconfig = JSON.parse(fs.readFileSync(tsconfigPath, 'utf8'));
|
|
@@ -68,7 +72,7 @@ describe('Environment Setup', () => {
|
|
|
68
72
|
});
|
|
69
73
|
|
|
70
74
|
it('should have a valid tsup.config.ts for building', () => {
|
|
71
|
-
const tsupConfigPath = path.join(
|
|
75
|
+
const tsupConfigPath = path.join(projectRoot, 'tsup.config.ts');
|
|
72
76
|
expect(fs.existsSync(tsupConfigPath)).toBe(true);
|
|
73
77
|
|
|
74
78
|
const tsupConfig = fs.readFileSync(tsupConfigPath, 'utf8');
|
|
@@ -78,7 +82,7 @@ describe('Environment Setup', () => {
|
|
|
78
82
|
});
|
|
79
83
|
|
|
80
84
|
it('should have a valid README.md file', () => {
|
|
81
|
-
const readmePath = path.join(
|
|
85
|
+
const readmePath = path.join(projectRoot, 'README.md');
|
|
82
86
|
expect(fs.existsSync(readmePath)).toBe(true);
|
|
83
87
|
|
|
84
88
|
const readme = fs.readFileSync(readmePath, 'utf8');
|
|
@@ -3,4 +3,16 @@ timeout = 60000
|
|
|
3
3
|
coverage = true
|
|
4
4
|
|
|
5
5
|
[test.env]
|
|
6
|
-
NODE_ENV = "test"
|
|
6
|
+
NODE_ENV = "test"
|
|
7
|
+
|
|
8
|
+
coverage-exclude = [
|
|
9
|
+
"**/dist/**",
|
|
10
|
+
"**/build/**",
|
|
11
|
+
"**/chunk-*.js",
|
|
12
|
+
"**/*.chunk.js",
|
|
13
|
+
"**/node_modules/**",
|
|
14
|
+
"**/*.min.js",
|
|
15
|
+
"**/*.bundle.js",
|
|
16
|
+
"**/coverage/**",
|
|
17
|
+
"**/.turbo/**",
|
|
18
|
+
]
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TestSuite, IAgentRuntime } from '@elizaos/core';
|
|
2
|
-
import { character as mrTeeCharacter } from '../
|
|
2
|
+
import { character as mrTeeCharacter } from '../src/index';
|
|
3
3
|
|
|
4
4
|
export class MrTeeProjectTestSuite implements TestSuite {
|
|
5
5
|
name = 'mr-tee-project';
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"GUIDE.md"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@elizaos/cli": "1.0.
|
|
37
|
-
"@elizaos/core": "1.0.
|
|
36
|
+
"@elizaos/cli": "1.0.12",
|
|
37
|
+
"@elizaos/core": "1.0.12",
|
|
38
38
|
"@elizaos/plugin-redpill": "1.0.3",
|
|
39
|
-
"@elizaos/plugin-sql": "1.0.
|
|
39
|
+
"@elizaos/plugin-sql": "1.0.12",
|
|
40
40
|
"@phala/dstack-sdk": "0.1.11",
|
|
41
41
|
"@solana/web3.js": "1.98.2",
|
|
42
42
|
"viem": "2.30.1",
|