@elizaos/cli 1.3.1 → 1.4.2
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 +47 -1
- package/dist/{bun-exec-6CQHTS4F.js → bun-exec-ULMPAIQC.js} +1 -1
- package/dist/{chunk-2ALAPQLV.js → chunk-D3QSET5H.js} +342 -360
- package/dist/{chunk-FDEDLANP.js → chunk-FQYWRHLX.js} +1 -1
- package/dist/{chunk-RM6LUTKD.js → chunk-FSSUAWXQ.js} +3 -3
- package/dist/chunk-GXWWPFBO.js +39 -0
- package/dist/{chunk-D3Q2UZLZ.js → chunk-I4L4T7QX.js} +1 -1
- package/dist/{chunk-KDNV7EA5.js → chunk-SMZBJQJR.js} +1 -1
- package/dist/commands/agent/actions/index.d.ts +5 -0
- package/dist/commands/agent/actions/index.js +4 -4
- package/dist/commands/agent/index.d.ts +2 -2
- package/dist/commands/agent/index.js +4 -4
- package/dist/commands/create/actions/index.js +5 -5
- package/dist/commands/create/index.js +6 -6
- package/dist/commands/shared/index.d.ts +11 -28
- package/dist/commands/shared/index.js +7 -3
- package/dist/index.js +599 -483
- package/dist/{plugin-creator-H26ZLR6H.js → plugin-creator-TCUFII32.js} +2 -2
- package/dist/{registry-N626N4VG.js → registry-RF6PW3EN.js} +4 -4
- package/dist/templates/plugin-quick-starter/README.md +52 -10
- package/dist/templates/plugin-quick-starter/package.json +10 -3
- package/dist/templates/plugin-quick-starter/src/__tests__/e2e/README.md +140 -0
- package/dist/templates/plugin-quick-starter/src/__tests__/e2e/plugin-quick-starter.e2e.ts +339 -0
- package/dist/templates/plugin-quick-starter/src/__tests__/plugin.test.ts +537 -146
- package/dist/templates/plugin-quick-starter/src/__tests__/test-utils.ts +316 -115
- package/dist/templates/plugin-quick-starter/src/plugin.ts +20 -26
- package/dist/templates/plugin-starter/README.md +124 -49
- package/dist/templates/plugin-starter/package.json +10 -3
- package/dist/templates/plugin-starter/src/__tests__/e2e/README.md +44 -9
- package/{templates/plugin-starter/src/__tests__/e2e/starter-plugin.ts → dist/templates/plugin-starter/src/__tests__/e2e/plugin-starter.e2e.ts} +13 -20
- package/dist/templates/plugin-starter/src/__tests__/integration.test.ts +13 -13
- package/dist/templates/plugin-starter/src/__tests__/plugin.test.ts +556 -129
- package/dist/templates/plugin-starter/src/__tests__/test-utils.ts +347 -115
- package/dist/templates/plugin-starter/src/plugin.ts +21 -27
- package/dist/templates/project-starter/README.md +25 -12
- package/dist/templates/project-starter/package.json +4 -4
- package/dist/templates/project-starter/src/__tests__/actions.test.ts +2 -2
- package/dist/templates/project-starter/src/__tests__/e2e/README.md +103 -0
- package/dist/templates/project-starter/src/__tests__/e2e/project-starter.e2e.ts +575 -0
- package/dist/templates/project-starter/src/__tests__/env.test.ts +3 -1
- package/dist/templates/project-starter/src/__tests__/file-structure.test.ts +3 -2
- package/dist/templates/project-starter/src/__tests__/integration.test.ts +2 -2
- package/dist/templates/project-starter/src/__tests__/models.test.ts +3 -3
- package/dist/templates/project-starter/src/__tests__/plugin.test.ts +3 -3
- package/dist/templates/project-starter/src/__tests__/provider.test.ts +2 -2
- package/dist/templates/project-starter/src/index.ts +4 -3
- package/dist/templates/project-starter/src/plugin.ts +5 -5
- package/dist/templates/project-starter/tsup.config.ts +2 -1
- package/dist/templates/project-tee-starter/.dockerignore +64 -14
- package/dist/templates/project-tee-starter/Dockerfile +9 -5
- package/dist/templates/project-tee-starter/GUIDE.md +103 -42
- package/dist/templates/project-tee-starter/README.md +83 -24
- package/dist/templates/project-tee-starter/docker-compose.yaml +5 -2
- package/dist/templates/{plugin-starter/dist → project-tee-starter}/index.html +3 -3
- package/dist/templates/project-tee-starter/package.json +34 -14
- package/dist/templates/project-tee-starter/postcss.config.js +3 -0
- package/dist/templates/project-tee-starter/scripts/install-test-deps.js +52 -0
- package/dist/templates/project-tee-starter/scripts/test-all.sh +82 -0
- package/dist/templates/project-tee-starter/src/__tests__/build-order.test.ts +62 -0
- package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/character.test.ts +20 -18
- package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/config.test.ts +11 -4
- package/dist/templates/project-tee-starter/src/__tests__/e2e/README.md +128 -0
- package/dist/templates/project-tee-starter/src/__tests__/e2e/project-tee-starter.e2e.ts +280 -0
- package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/env.test.ts +3 -2
- package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/error-handling.test.ts +2 -2
- package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/events.test.ts +1 -1
- package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/file-structure.test.ts +16 -5
- package/dist/templates/project-tee-starter/src/__tests__/frontend.test.ts +459 -0
- package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/integration.test.ts +2 -2
- package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/models.test.ts +1 -1
- package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/plugin.test.ts +5 -3
- package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/provider.test.ts +2 -2
- package/dist/templates/project-tee-starter/src/__tests__/routes.test.ts +30 -0
- package/dist/templates/project-tee-starter/src/__tests__/tee-validation.test.ts +295 -0
- package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/test-utils.ts +2 -2
- package/dist/templates/project-tee-starter/src/__tests__/vite-config-utils.ts +51 -0
- package/dist/templates/project-tee-starter/src/frontend/index.css +106 -0
- package/dist/templates/project-tee-starter/src/frontend/index.html +20 -0
- package/dist/templates/project-tee-starter/src/frontend/index.tsx +370 -0
- package/dist/templates/project-tee-starter/src/frontend/panels.tsx +17 -0
- package/dist/templates/project-tee-starter/src/frontend/utils.ts +6 -0
- package/dist/templates/project-tee-starter/src/index.ts +8 -6
- package/dist/templates/project-tee-starter/src/plugin.ts +223 -61
- package/dist/templates/project-tee-starter/tailwind.config.js +62 -0
- package/dist/templates/project-tee-starter/tsconfig.build.json +2 -2
- package/dist/templates/project-tee-starter/tsconfig.json +8 -5
- package/dist/templates/project-tee-starter/tsup.config.ts +3 -2
- package/dist/templates/project-tee-starter/vite.config.ts +39 -0
- package/dist/url-utils-CKc_Ebt_.d.ts +35 -0
- package/dist/{utils-H66532NB.js → utils-5HPZSIF6.js} +4 -4
- package/package.json +7 -6
- package/templates/plugin-quick-starter/README.md +52 -10
- package/templates/plugin-quick-starter/package.json +10 -3
- package/templates/plugin-quick-starter/src/__tests__/e2e/README.md +140 -0
- package/templates/plugin-quick-starter/src/__tests__/e2e/plugin-quick-starter.e2e.ts +339 -0
- package/templates/plugin-quick-starter/src/__tests__/plugin.test.ts +537 -146
- package/templates/plugin-quick-starter/src/__tests__/test-utils.ts +316 -115
- package/templates/plugin-quick-starter/src/plugin.ts +20 -26
- package/templates/plugin-starter/README.md +124 -49
- package/templates/plugin-starter/package.json +10 -3
- package/templates/plugin-starter/src/__tests__/e2e/README.md +44 -9
- package/{dist/templates/plugin-starter/src/__tests__/e2e/starter-plugin.ts → templates/plugin-starter/src/__tests__/e2e/plugin-starter.e2e.ts} +13 -20
- package/templates/plugin-starter/src/__tests__/integration.test.ts +13 -13
- package/templates/plugin-starter/src/__tests__/plugin.test.ts +556 -129
- package/templates/plugin-starter/src/__tests__/test-utils.ts +347 -115
- package/templates/plugin-starter/src/plugin.ts +21 -27
- package/templates/project-starter/README.md +25 -12
- package/templates/project-starter/package.json +4 -4
- package/templates/project-starter/src/__tests__/actions.test.ts +2 -2
- package/templates/project-starter/src/__tests__/e2e/README.md +103 -0
- package/templates/project-starter/src/__tests__/e2e/project-starter.e2e.ts +575 -0
- package/templates/project-starter/src/__tests__/env.test.ts +3 -1
- package/templates/project-starter/src/__tests__/file-structure.test.ts +3 -2
- package/templates/project-starter/src/__tests__/integration.test.ts +2 -2
- package/templates/project-starter/src/__tests__/models.test.ts +3 -3
- package/templates/project-starter/src/__tests__/plugin.test.ts +3 -3
- package/templates/project-starter/src/__tests__/provider.test.ts +2 -2
- package/templates/project-starter/src/index.ts +4 -3
- package/templates/project-starter/src/plugin.ts +5 -5
- package/templates/project-starter/tsup.config.ts +2 -1
- package/templates/project-tee-starter/.dockerignore +64 -14
- package/templates/project-tee-starter/Dockerfile +9 -5
- package/templates/project-tee-starter/GUIDE.md +103 -42
- package/templates/project-tee-starter/README.md +83 -24
- package/templates/project-tee-starter/docker-compose.yaml +5 -2
- package/templates/{plugin-starter/dist → project-tee-starter}/index.html +3 -3
- package/templates/project-tee-starter/package.json +34 -14
- package/templates/project-tee-starter/postcss.config.js +3 -0
- package/templates/project-tee-starter/scripts/install-test-deps.js +52 -0
- package/templates/project-tee-starter/scripts/test-all.sh +82 -0
- package/templates/project-tee-starter/src/__tests__/build-order.test.ts +62 -0
- package/templates/project-tee-starter/{__tests__ → src/__tests__}/character.test.ts +20 -18
- package/templates/project-tee-starter/{__tests__ → src/__tests__}/config.test.ts +11 -4
- package/templates/project-tee-starter/src/__tests__/e2e/README.md +128 -0
- package/templates/project-tee-starter/src/__tests__/e2e/project-tee-starter.e2e.ts +280 -0
- package/templates/project-tee-starter/{__tests__ → src/__tests__}/env.test.ts +3 -2
- package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/error-handling.test.ts +2 -2
- package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/events.test.ts +1 -1
- package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/file-structure.test.ts +16 -5
- package/templates/project-tee-starter/src/__tests__/frontend.test.ts +459 -0
- package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/integration.test.ts +2 -2
- package/templates/project-tee-starter/{__tests__ → src/__tests__}/models.test.ts +1 -1
- package/templates/project-tee-starter/{__tests__ → src/__tests__}/plugin.test.ts +5 -3
- package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/provider.test.ts +2 -2
- package/templates/project-tee-starter/src/__tests__/routes.test.ts +30 -0
- package/templates/project-tee-starter/src/__tests__/tee-validation.test.ts +295 -0
- package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/test-utils.ts +2 -2
- package/templates/project-tee-starter/src/__tests__/vite-config-utils.ts +51 -0
- package/templates/project-tee-starter/src/frontend/index.css +106 -0
- package/templates/project-tee-starter/src/frontend/index.html +20 -0
- package/templates/project-tee-starter/src/frontend/index.tsx +370 -0
- package/templates/project-tee-starter/src/frontend/panels.tsx +17 -0
- package/templates/project-tee-starter/src/frontend/utils.ts +6 -0
- package/templates/project-tee-starter/src/index.ts +8 -6
- package/templates/project-tee-starter/src/plugin.ts +223 -61
- package/templates/project-tee-starter/tailwind.config.js +62 -0
- package/templates/project-tee-starter/tsconfig.build.json +2 -2
- package/templates/project-tee-starter/tsconfig.json +8 -5
- package/templates/project-tee-starter/tsup.config.ts +3 -2
- package/templates/project-tee-starter/vite.config.ts +39 -0
- package/dist/chunk-4O6EZU37.js +0 -14
- package/dist/migration-guides/advanced-migration-guide.md +0 -459
- package/dist/migration-guides/completion-requirements.md +0 -379
- package/dist/migration-guides/integrated-migration-loop.md +0 -392
- package/dist/migration-guides/migration-guide.md +0 -712
- package/dist/migration-guides/prompt-and-generation-guide.md +0 -702
- package/dist/migration-guides/state-and-providers-guide.md +0 -544
- package/dist/migration-guides/testing-guide.md +0 -1021
- package/dist/templates/plugin-starter/dist/assets/index-CgkejLs_.css +0 -1
- package/dist/templates/plugin-starter/dist/assets/index-D1cHX53P.js +0 -49
- package/dist/templates/plugin-starter/dist/index.js +0 -387
- package/dist/templates/plugin-starter/dist/index.js.map +0 -1
- package/dist/templates/plugin-starter/src/tests.ts +0 -6
- package/dist/templates/project-starter/src/__tests__/e2e/index.ts +0 -14
- package/dist/templates/project-starter/src/__tests__/e2e/natural-language.test.ts +0 -246
- package/dist/templates/project-starter/src/__tests__/e2e/project.test.ts +0 -155
- package/dist/templates/project-starter/src/__tests__/e2e/starter-plugin.test.ts +0 -421
- package/dist/templates/project-tee-starter/__tests__/routes.test.ts +0 -21
- package/dist/templates/project-tee-starter/e2e/project.test.ts +0 -38
- package/dist/templates/project-tee-starter/e2e/starter-plugin.test.ts +0 -92
- package/templates/plugin-starter/dist/.vite/manifest.json +0 -11
- package/templates/plugin-starter/dist/assets/index-CgkejLs_.css +0 -1
- package/templates/plugin-starter/dist/assets/index-D1cHX53P.js +0 -49
- package/templates/plugin-starter/dist/index.d.ts +0 -14
- package/templates/plugin-starter/dist/index.js +0 -387
- package/templates/plugin-starter/dist/index.js.map +0 -1
- package/templates/plugin-starter/src/tests.ts +0 -6
- package/templates/project-starter/src/__tests__/e2e/index.ts +0 -14
- package/templates/project-starter/src/__tests__/e2e/natural-language.test.ts +0 -246
- package/templates/project-starter/src/__tests__/e2e/project.test.ts +0 -155
- package/templates/project-starter/src/__tests__/e2e/starter-plugin.test.ts +0 -421
- package/templates/project-tee-starter/__tests__/routes.test.ts +0 -21
- package/templates/project-tee-starter/e2e/project.test.ts +0 -38
- package/templates/project-tee-starter/e2e/starter-plugin.test.ts +0 -92
- /package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/actions.test.ts +0 -0
- /package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/utils/core-test-utils.ts +0 -0
- /package/templates/project-tee-starter/{__tests__ → src/__tests__}/actions.test.ts +0 -0
- /package/templates/project-tee-starter/{__tests__ → src/__tests__}/utils/core-test-utils.ts +0 -0
|
@@ -1,162 +1,363 @@
|
|
|
1
1
|
import { mock, spyOn } from 'bun:test';
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
type IAgentRuntime,
|
|
4
|
+
type Memory,
|
|
5
|
+
type State,
|
|
6
|
+
type Content,
|
|
7
|
+
type UUID,
|
|
8
|
+
type Character,
|
|
9
|
+
type Service,
|
|
10
|
+
type ServiceTypeName,
|
|
6
11
|
ModelType,
|
|
7
|
-
|
|
8
|
-
State,
|
|
9
|
-
UUID,
|
|
12
|
+
asUUID,
|
|
10
13
|
logger,
|
|
11
14
|
} from '@elizaos/core';
|
|
12
15
|
|
|
13
16
|
/**
|
|
14
|
-
* Creates a
|
|
15
|
-
*
|
|
16
|
-
* @param overrides - Optional overrides for the default mock methods and properties
|
|
17
|
-
* @returns A mock runtime for testing
|
|
17
|
+
* Creates a UUID for testing
|
|
18
18
|
*/
|
|
19
|
-
export function
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
export function createUUID(): UUID {
|
|
20
|
+
return asUUID(crypto.randomUUID());
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Creates a test character
|
|
25
|
+
*/
|
|
26
|
+
export function createTestCharacter(overrides: Partial<Character> = {}): Character {
|
|
27
|
+
return {
|
|
28
|
+
id: createUUID(),
|
|
29
|
+
name: 'Test Character',
|
|
30
|
+
username: 'test-character',
|
|
31
|
+
bio: 'A test character for unit testing',
|
|
32
|
+
system: 'You are a helpful assistant for testing.',
|
|
33
|
+
plugins: [],
|
|
34
|
+
settings: {},
|
|
35
|
+
messageExamples: [],
|
|
36
|
+
topics: [],
|
|
37
|
+
adjectives: [],
|
|
38
|
+
style: { all: [], chat: [], post: [] },
|
|
39
|
+
secrets: {},
|
|
40
|
+
...overrides,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Creates a test memory
|
|
46
|
+
*/
|
|
47
|
+
export function createTestMemory(overrides: Partial<Memory> = {}): Memory {
|
|
48
|
+
const now = Date.now();
|
|
49
|
+
return {
|
|
50
|
+
id: createUUID(),
|
|
51
|
+
agentId: createUUID(),
|
|
52
|
+
entityId: createUUID(),
|
|
53
|
+
roomId: createUUID(),
|
|
54
|
+
content: {
|
|
55
|
+
text: 'Test message',
|
|
56
|
+
source: 'test',
|
|
27
57
|
},
|
|
28
|
-
|
|
58
|
+
createdAt: now,
|
|
59
|
+
...overrides,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
29
62
|
|
|
30
|
-
|
|
63
|
+
/**
|
|
64
|
+
* Creates a test state
|
|
65
|
+
*/
|
|
66
|
+
export function createTestState(overrides: Partial<State> = {}): State {
|
|
67
|
+
return {
|
|
68
|
+
agentId: createUUID(),
|
|
69
|
+
roomId: createUUID(),
|
|
70
|
+
userId: createUUID(),
|
|
71
|
+
bio: 'Test bio',
|
|
72
|
+
lore: 'Test lore',
|
|
73
|
+
userName: 'Test User',
|
|
74
|
+
userBio: 'Test user bio',
|
|
75
|
+
actors: '',
|
|
76
|
+
recentMessages: '',
|
|
77
|
+
recentInteractions: '',
|
|
78
|
+
goals: 'Test goals',
|
|
79
|
+
image: '',
|
|
80
|
+
messageDirections: '',
|
|
81
|
+
values: {},
|
|
82
|
+
data: {},
|
|
83
|
+
text: '',
|
|
84
|
+
...overrides,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Creates a properly typed mock runtime
|
|
90
|
+
*/
|
|
91
|
+
export function createMockRuntime(overrides: Partial<IAgentRuntime> = {}): IAgentRuntime {
|
|
92
|
+
const agentId = overrides.agentId || createUUID();
|
|
93
|
+
const character = overrides.character || createTestCharacter();
|
|
94
|
+
|
|
95
|
+
// Create base runtime object with all required properties
|
|
96
|
+
const mockRuntime: IAgentRuntime = {
|
|
97
|
+
// Properties
|
|
98
|
+
agentId,
|
|
99
|
+
character,
|
|
100
|
+
providers: [],
|
|
101
|
+
actions: [],
|
|
102
|
+
evaluators: [],
|
|
103
|
+
plugins: [],
|
|
104
|
+
services: new Map<ServiceTypeName, Service[]>(),
|
|
105
|
+
events: new Map(),
|
|
106
|
+
fetch: null,
|
|
107
|
+
routes: [],
|
|
108
|
+
logger: {
|
|
109
|
+
info: mock(() => {}),
|
|
110
|
+
warn: mock(() => {}),
|
|
111
|
+
error: mock(() => {}),
|
|
112
|
+
debug: mock(() => {}),
|
|
113
|
+
},
|
|
114
|
+
db: {},
|
|
115
|
+
|
|
116
|
+
// Database methods
|
|
117
|
+
initialize: mock().mockResolvedValue(undefined),
|
|
118
|
+
init: mock().mockResolvedValue(undefined),
|
|
119
|
+
runMigrations: mock().mockResolvedValue(undefined),
|
|
120
|
+
isReady: mock().mockResolvedValue(true),
|
|
121
|
+
close: mock().mockResolvedValue(undefined),
|
|
122
|
+
getConnection: mock().mockResolvedValue({}),
|
|
123
|
+
|
|
124
|
+
// Agent methods
|
|
125
|
+
getAgent: mock().mockResolvedValue(null),
|
|
126
|
+
getAgents: mock().mockResolvedValue([]),
|
|
127
|
+
createAgent: mock().mockResolvedValue(true),
|
|
128
|
+
updateAgent: mock().mockResolvedValue(true),
|
|
129
|
+
deleteAgent: mock().mockResolvedValue(true),
|
|
130
|
+
|
|
131
|
+
// Memory methods
|
|
132
|
+
createMemory: mock().mockImplementation(async (memory: Memory) => ({
|
|
133
|
+
...memory,
|
|
134
|
+
id: memory.id || createUUID(),
|
|
135
|
+
})),
|
|
136
|
+
getMemories: mock().mockResolvedValue([]),
|
|
137
|
+
getMemoryById: mock().mockResolvedValue(null),
|
|
138
|
+
getMemoriesByIds: mock().mockResolvedValue([]),
|
|
139
|
+
getMemoriesByRoomIds: mock().mockResolvedValue([]),
|
|
140
|
+
searchMemories: mock().mockResolvedValue([]),
|
|
141
|
+
addEmbeddingToMemory: mock().mockImplementation(async (memory: Memory) => memory),
|
|
142
|
+
getAllMemories: mock().mockResolvedValue([]),
|
|
143
|
+
clearAllAgentMemories: mock().mockResolvedValue(undefined),
|
|
144
|
+
updateMemory: mock().mockResolvedValue(true),
|
|
145
|
+
deleteMemory: mock().mockResolvedValue(undefined),
|
|
146
|
+
deleteManyMemories: mock().mockResolvedValue(undefined),
|
|
147
|
+
deleteAllMemories: mock().mockResolvedValue(undefined),
|
|
148
|
+
countMemories: mock().mockResolvedValue(0),
|
|
149
|
+
|
|
150
|
+
// Entity methods
|
|
151
|
+
getEntitiesByIds: mock().mockResolvedValue([]),
|
|
152
|
+
getEntitiesForRoom: mock().mockResolvedValue([]),
|
|
153
|
+
createEntities: mock().mockResolvedValue(true),
|
|
154
|
+
updateEntity: mock().mockResolvedValue(undefined),
|
|
155
|
+
createEntity: mock().mockResolvedValue(true),
|
|
156
|
+
getEntityById: mock().mockResolvedValue(null),
|
|
157
|
+
|
|
158
|
+
// Room methods
|
|
159
|
+
createRoom: mock().mockImplementation(async () => createUUID()),
|
|
160
|
+
createRooms: mock().mockImplementation(async () => [createUUID()]),
|
|
161
|
+
getRoom: mock().mockResolvedValue(null),
|
|
162
|
+
getRooms: mock().mockResolvedValue([]),
|
|
163
|
+
getRoomsByIds: mock().mockResolvedValue([]),
|
|
164
|
+
getRoomsByWorld: mock().mockResolvedValue([]),
|
|
165
|
+
updateRoom: mock().mockResolvedValue(undefined),
|
|
166
|
+
deleteRoom: mock().mockResolvedValue(undefined),
|
|
167
|
+
deleteRoomsByWorldId: mock().mockResolvedValue(undefined),
|
|
168
|
+
addParticipant: mock().mockResolvedValue(true),
|
|
169
|
+
addParticipantsRoom: mock().mockResolvedValue(true),
|
|
170
|
+
removeParticipant: mock().mockResolvedValue(true),
|
|
171
|
+
getRoomsForParticipant: mock().mockResolvedValue([]),
|
|
172
|
+
getRoomsForParticipants: mock().mockResolvedValue([]),
|
|
173
|
+
getParticipantsForEntity: mock().mockResolvedValue([]),
|
|
174
|
+
getParticipantsForRoom: mock().mockResolvedValue([]),
|
|
175
|
+
getParticipantUserState: mock().mockResolvedValue(null),
|
|
176
|
+
setParticipantUserState: mock().mockResolvedValue(undefined),
|
|
177
|
+
|
|
178
|
+
// Service methods
|
|
31
179
|
getService: mock().mockReturnValue(null),
|
|
32
|
-
|
|
33
|
-
|
|
180
|
+
getServicesByType: mock().mockReturnValue([]),
|
|
181
|
+
getAllServices: mock().mockReturnValue(new Map()),
|
|
182
|
+
registerService: mock().mockResolvedValue(undefined),
|
|
183
|
+
getRegisteredServiceTypes: mock().mockReturnValue([]),
|
|
184
|
+
hasService: mock().mockReturnValue(false),
|
|
185
|
+
|
|
186
|
+
// Plugin/Action/Provider methods
|
|
187
|
+
registerPlugin: mock().mockResolvedValue(undefined),
|
|
188
|
+
registerProvider: mock().mockReturnValue(undefined),
|
|
189
|
+
registerAction: mock().mockReturnValue(undefined),
|
|
190
|
+
registerEvaluator: mock().mockReturnValue(undefined),
|
|
34
191
|
|
|
35
192
|
// Model methods
|
|
36
|
-
|
|
193
|
+
registerModel: mock().mockReturnValue(undefined),
|
|
194
|
+
getModel: mock().mockReturnValue(undefined),
|
|
195
|
+
useModel: mock().mockImplementation(async (modelType: string) => {
|
|
37
196
|
if (modelType === ModelType.TEXT_SMALL) {
|
|
38
|
-
return
|
|
197
|
+
return 'Never gonna give you up, never gonna let you down';
|
|
39
198
|
} else if (modelType === ModelType.TEXT_LARGE) {
|
|
40
|
-
return
|
|
41
|
-
} else if (modelType === ModelType.OBJECT_LARGE) {
|
|
42
|
-
return Promise.resolve({
|
|
43
|
-
thought: 'I should respond in a friendly way',
|
|
44
|
-
message: 'Hello there! How can I help you today?',
|
|
45
|
-
});
|
|
199
|
+
return 'Never gonna make you cry, never gonna say goodbye';
|
|
46
200
|
}
|
|
47
|
-
return
|
|
201
|
+
return 'Default model response';
|
|
48
202
|
}),
|
|
49
203
|
|
|
50
|
-
//
|
|
51
|
-
|
|
204
|
+
// Event methods
|
|
205
|
+
registerEvent: mock().mockReturnValue(undefined),
|
|
206
|
+
getEvent: mock().mockReturnValue(undefined),
|
|
207
|
+
emitEvent: mock().mockResolvedValue(undefined),
|
|
208
|
+
|
|
209
|
+
// Settings methods
|
|
210
|
+
setSetting: mock().mockReturnValue(undefined),
|
|
211
|
+
getSetting: mock().mockImplementation((key: string) => {
|
|
212
|
+
if (key === 'EXAMPLE_PLUGIN_VARIABLE') return 'test-value';
|
|
213
|
+
return null;
|
|
214
|
+
}),
|
|
215
|
+
|
|
216
|
+
// Other methods
|
|
217
|
+
processActions: mock().mockResolvedValue(undefined),
|
|
218
|
+
evaluate: mock().mockResolvedValue(null),
|
|
219
|
+
ensureConnections: mock().mockResolvedValue(undefined),
|
|
220
|
+
ensureConnection: mock().mockResolvedValue(undefined),
|
|
221
|
+
getConversationLength: mock().mockReturnValue(10),
|
|
222
|
+
composeState: mock().mockImplementation(async () => createTestState()),
|
|
223
|
+
// Task methods
|
|
224
|
+
getTasks: mock().mockResolvedValue([]),
|
|
225
|
+
getTask: mock().mockResolvedValue(null),
|
|
226
|
+
getTasksByName: mock().mockResolvedValue([]),
|
|
227
|
+
createTask: mock().mockImplementation(async () => createUUID()),
|
|
228
|
+
updateTask: mock().mockResolvedValue(undefined),
|
|
229
|
+
deleteTask: mock().mockResolvedValue(undefined),
|
|
230
|
+
registerTaskWorker: mock().mockReturnValue(undefined),
|
|
231
|
+
getTaskWorker: mock().mockReturnValue(undefined),
|
|
232
|
+
stop: mock().mockResolvedValue(undefined),
|
|
233
|
+
createRunId: mock().mockImplementation(() => createUUID()),
|
|
234
|
+
startRun: mock().mockImplementation(() => createUUID()),
|
|
235
|
+
endRun: mock().mockReturnValue(undefined),
|
|
236
|
+
getCurrentRunId: mock().mockImplementation(() => createUUID()),
|
|
237
|
+
registerSendHandler: mock().mockReturnValue(undefined),
|
|
238
|
+
sendMessageToTarget: mock().mockResolvedValue(undefined),
|
|
239
|
+
registerDatabaseAdapter: mock().mockReturnValue(undefined),
|
|
240
|
+
log: mock().mockResolvedValue(undefined),
|
|
241
|
+
getLogs: mock().mockResolvedValue([]),
|
|
242
|
+
deleteLog: mock().mockResolvedValue(undefined),
|
|
243
|
+
|
|
244
|
+
// Component methods (from IDatabaseAdapter)
|
|
245
|
+
getComponent: mock().mockResolvedValue(null),
|
|
246
|
+
getComponents: mock().mockResolvedValue([]),
|
|
247
|
+
createComponent: mock().mockResolvedValue(true),
|
|
248
|
+
updateComponent: mock().mockResolvedValue(undefined),
|
|
249
|
+
deleteComponent: mock().mockResolvedValue(undefined),
|
|
250
|
+
|
|
251
|
+
// Relationship methods
|
|
252
|
+
createRelationship: mock().mockResolvedValue(true),
|
|
253
|
+
getRelationships: mock().mockResolvedValue([]),
|
|
254
|
+
getRelationship: mock().mockResolvedValue(null),
|
|
255
|
+
updateRelationship: mock().mockResolvedValue(undefined),
|
|
256
|
+
|
|
257
|
+
// Embedding methods
|
|
258
|
+
ensureEmbeddingDimension: mock().mockResolvedValue(undefined),
|
|
259
|
+
getCachedEmbeddings: mock().mockResolvedValue([]),
|
|
260
|
+
|
|
261
|
+
// World methods
|
|
262
|
+
getWorld: mock().mockResolvedValue(null),
|
|
263
|
+
createWorld: mock().mockImplementation(async () => createUUID()),
|
|
264
|
+
updateWorld: mock().mockResolvedValue(undefined),
|
|
265
|
+
removeWorld: mock().mockResolvedValue(undefined),
|
|
266
|
+
getAllWorlds: mock().mockResolvedValue([]),
|
|
267
|
+
|
|
268
|
+
// Required method that was missing
|
|
269
|
+
ensureParticipantInRoom: mock().mockResolvedValue(undefined),
|
|
270
|
+
ensureWorldExists: mock().mockResolvedValue(undefined),
|
|
271
|
+
ensureRoomExists: mock().mockResolvedValue(undefined),
|
|
272
|
+
|
|
273
|
+
// Cache methods
|
|
274
|
+
getCache: mock().mockResolvedValue(undefined),
|
|
275
|
+
setCache: mock().mockResolvedValue(true),
|
|
276
|
+
deleteCache: mock().mockResolvedValue(true),
|
|
277
|
+
|
|
278
|
+
// Other missing database methods
|
|
279
|
+
getMemoriesByWorldId: mock().mockResolvedValue([]),
|
|
280
|
+
|
|
281
|
+
// Apply any overrides
|
|
52
282
|
...overrides,
|
|
53
283
|
};
|
|
54
284
|
|
|
55
|
-
//
|
|
285
|
+
// Setup logger spies if not already overridden
|
|
286
|
+
if (!overrides.logger) {
|
|
287
|
+
spyOn(logger, 'info').mockImplementation(() => {});
|
|
288
|
+
spyOn(logger, 'warn').mockImplementation(() => {});
|
|
289
|
+
spyOn(logger, 'error').mockImplementation(() => {});
|
|
290
|
+
spyOn(logger, 'debug').mockImplementation(() => {});
|
|
291
|
+
}
|
|
292
|
+
|
|
56
293
|
return mockRuntime;
|
|
57
294
|
}
|
|
58
295
|
|
|
59
296
|
/**
|
|
60
|
-
* Creates
|
|
61
|
-
*
|
|
62
|
-
* @param overrides - Optional overrides for the default memory properties
|
|
63
|
-
* @returns A mock memory object
|
|
297
|
+
* Creates test fixtures for event payloads
|
|
64
298
|
*/
|
|
65
|
-
export
|
|
66
|
-
|
|
67
|
-
id: 'test-message-id' as UUID,
|
|
68
|
-
roomId: 'test-room-id' as UUID,
|
|
69
|
-
entityId: 'test-entity-id' as UUID,
|
|
70
|
-
agentId: 'test-agent-id' as UUID,
|
|
299
|
+
export const testFixtures = {
|
|
300
|
+
messagePayload: (overrides: any = {}) => ({
|
|
71
301
|
content: {
|
|
72
302
|
text: 'Test message',
|
|
73
303
|
source: 'test',
|
|
74
|
-
}
|
|
75
|
-
|
|
304
|
+
},
|
|
305
|
+
userId: createUUID(),
|
|
306
|
+
roomId: createUUID(),
|
|
307
|
+
runtime: createMockRuntime(),
|
|
308
|
+
source: 'test',
|
|
76
309
|
...overrides,
|
|
77
|
-
}
|
|
78
|
-
|
|
310
|
+
}),
|
|
311
|
+
|
|
312
|
+
worldPayload: (overrides: any = {}) => ({
|
|
313
|
+
content: {
|
|
314
|
+
text: 'World event',
|
|
315
|
+
world: 'test-world',
|
|
316
|
+
},
|
|
317
|
+
userId: createUUID(),
|
|
318
|
+
roomId: createUUID(),
|
|
319
|
+
runtime: createMockRuntime(),
|
|
320
|
+
source: 'test',
|
|
321
|
+
...overrides,
|
|
322
|
+
}),
|
|
323
|
+
};
|
|
79
324
|
|
|
80
325
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
* @param overrides - Optional overrides for the default state properties
|
|
84
|
-
* @returns A mock state object
|
|
326
|
+
* Type guard to check if a value is a mock function
|
|
85
327
|
*/
|
|
86
|
-
export function
|
|
87
|
-
return
|
|
88
|
-
...overrides,
|
|
89
|
-
values: {
|
|
90
|
-
recentMessages: 'User: Test message',
|
|
91
|
-
...overrides.values,
|
|
92
|
-
},
|
|
93
|
-
data: {
|
|
94
|
-
...overrides.data,
|
|
95
|
-
},
|
|
96
|
-
};
|
|
328
|
+
export function isMockFunction(value: any): value is ReturnType<typeof mock> {
|
|
329
|
+
return value && typeof value.mock === 'object';
|
|
97
330
|
}
|
|
98
331
|
|
|
99
332
|
/**
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
* @param overrides - Optional overrides for default mock implementations
|
|
103
|
-
* @returns An object containing mockRuntime, mockMessage, mockState, and callbackFn
|
|
333
|
+
* Helper to assert spy was called with specific arguments
|
|
104
334
|
*/
|
|
105
|
-
export function
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
stateOverrides?: Partial<State>;
|
|
110
|
-
} = {}
|
|
111
|
-
) {
|
|
112
|
-
// Create mock callback function
|
|
113
|
-
const callbackFn = mock();
|
|
114
|
-
|
|
115
|
-
// Create a message
|
|
116
|
-
const mockMessage = createMockMemory(overrides.messageOverrides);
|
|
117
|
-
|
|
118
|
-
// Create a state object
|
|
119
|
-
const mockState = createMockState(overrides.stateOverrides);
|
|
120
|
-
|
|
121
|
-
// Create a mock runtime
|
|
122
|
-
const mockRuntime = createMockRuntime({
|
|
123
|
-
...overrides.runtimeOverrides,
|
|
124
|
-
});
|
|
335
|
+
export function assertSpyCalledWith(spy: any, ...args: any[]) {
|
|
336
|
+
if (!isMockFunction(spy)) {
|
|
337
|
+
throw new Error('Not a mock function');
|
|
338
|
+
}
|
|
125
339
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
340
|
+
const calls = spy.mock.calls;
|
|
341
|
+
const found = calls.some((call: any[]) =>
|
|
342
|
+
args.every((arg, index) => {
|
|
343
|
+
if (typeof arg === 'object' && arg !== null) {
|
|
344
|
+
return JSON.stringify(arg) === JSON.stringify(call[index]);
|
|
345
|
+
}
|
|
346
|
+
return arg === call[index];
|
|
347
|
+
})
|
|
348
|
+
);
|
|
349
|
+
|
|
350
|
+
if (!found) {
|
|
351
|
+
throw new Error(`Spy was not called with expected arguments: ${JSON.stringify(args)}`);
|
|
352
|
+
}
|
|
132
353
|
}
|
|
133
354
|
|
|
134
355
|
/**
|
|
135
|
-
*
|
|
356
|
+
* Setup logger spies for testing
|
|
136
357
|
*/
|
|
137
|
-
export interface MockRuntime {
|
|
138
|
-
agentId: UUID;
|
|
139
|
-
character: {
|
|
140
|
-
name: string;
|
|
141
|
-
bio: string;
|
|
142
|
-
[key: string]: any;
|
|
143
|
-
};
|
|
144
|
-
services: Map<string, Service>;
|
|
145
|
-
getService: ReturnType<typeof mock>;
|
|
146
|
-
registerService: ReturnType<typeof mock>;
|
|
147
|
-
getSetting: ReturnType<typeof mock>;
|
|
148
|
-
useModel: ReturnType<typeof mock>;
|
|
149
|
-
init: ReturnType<typeof mock>;
|
|
150
|
-
[key: string]: any;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// Add spy on logger for common usage in tests
|
|
154
358
|
export function setupLoggerSpies() {
|
|
155
359
|
spyOn(logger, 'info').mockImplementation(() => {});
|
|
156
|
-
spyOn(logger, 'error').mockImplementation(() => {});
|
|
157
360
|
spyOn(logger, 'warn').mockImplementation(() => {});
|
|
361
|
+
spyOn(logger, 'error').mockImplementation(() => {});
|
|
158
362
|
spyOn(logger, 'debug').mockImplementation(() => {});
|
|
159
|
-
|
|
160
|
-
// allow tests to restore originals
|
|
161
|
-
return () => mock.restore();
|
|
162
363
|
}
|
|
@@ -51,9 +51,9 @@ const configSchema = z.object({
|
|
|
51
51
|
* @property {Function} handler - Asynchronous function to handle the action and generate a response.
|
|
52
52
|
* @property {Object[]} examples - An array of example inputs and expected outputs for the action.
|
|
53
53
|
*/
|
|
54
|
-
const
|
|
55
|
-
name: '
|
|
56
|
-
similes: ['GREET', 'SAY_HELLO'],
|
|
54
|
+
const quickAction: Action = {
|
|
55
|
+
name: 'QUICK_ACTION',
|
|
56
|
+
similes: ['GREET', 'SAY_HELLO', 'HELLO_WORLD'],
|
|
57
57
|
description: 'Responds with a simple hello world message',
|
|
58
58
|
|
|
59
59
|
validate: async (
|
|
@@ -74,31 +74,25 @@ const helloWorldAction: Action = {
|
|
|
74
74
|
_responses?: Memory[]
|
|
75
75
|
): Promise<ActionResult> => {
|
|
76
76
|
try {
|
|
77
|
-
|
|
77
|
+
const response = 'Hello world!';
|
|
78
78
|
|
|
79
|
-
// Simple response content for callback
|
|
80
|
-
const responseContent: Content = {
|
|
81
|
-
text: 'hello world!',
|
|
82
|
-
actions: ['HELLO_WORLD'],
|
|
83
|
-
source: message.content.source,
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
// Call back with the hello world message if callback is provided
|
|
87
79
|
if (callback) {
|
|
88
|
-
await callback(
|
|
80
|
+
await callback({
|
|
81
|
+
text: response,
|
|
82
|
+
actions: ['QUICK_ACTION'],
|
|
83
|
+
source: message.content.source,
|
|
84
|
+
});
|
|
89
85
|
}
|
|
90
86
|
|
|
91
|
-
// Return ActionResult
|
|
92
87
|
return {
|
|
93
|
-
text:
|
|
88
|
+
text: response,
|
|
94
89
|
success: true,
|
|
95
90
|
data: {
|
|
96
|
-
actions: ['
|
|
91
|
+
actions: ['QUICK_ACTION'],
|
|
97
92
|
source: message.content.source,
|
|
98
93
|
},
|
|
99
94
|
};
|
|
100
95
|
} catch (error) {
|
|
101
|
-
logger.error('Error in HELLO_WORLD action:', error);
|
|
102
96
|
return {
|
|
103
97
|
success: false,
|
|
104
98
|
error: error instanceof Error ? error : new Error(String(error)),
|
|
@@ -118,7 +112,7 @@ const helloWorldAction: Action = {
|
|
|
118
112
|
name: '{{name2}}',
|
|
119
113
|
content: {
|
|
120
114
|
text: 'hello world!',
|
|
121
|
-
actions: ['
|
|
115
|
+
actions: ['QUICK_ACTION'],
|
|
122
116
|
},
|
|
123
117
|
},
|
|
124
118
|
],
|
|
@@ -129,8 +123,8 @@ const helloWorldAction: Action = {
|
|
|
129
123
|
* Example Hello World Provider
|
|
130
124
|
* This demonstrates the simplest possible provider implementation
|
|
131
125
|
*/
|
|
132
|
-
const
|
|
133
|
-
name: '
|
|
126
|
+
const quickProvider: Provider = {
|
|
127
|
+
name: 'QUICK_PROVIDER',
|
|
134
128
|
description: 'A simple example provider',
|
|
135
129
|
|
|
136
130
|
get: async (
|
|
@@ -241,31 +235,31 @@ export const starterPlugin: Plugin = {
|
|
|
241
235
|
[EventType.MESSAGE_RECEIVED]: [
|
|
242
236
|
async (params: MessagePayload) => {
|
|
243
237
|
logger.debug('MESSAGE_RECEIVED event received');
|
|
244
|
-
logger.debug(
|
|
238
|
+
logger.debug({ message: params.message }, 'Message:');
|
|
245
239
|
},
|
|
246
240
|
],
|
|
247
241
|
[EventType.VOICE_MESSAGE_RECEIVED]: [
|
|
248
242
|
async (params: MessagePayload) => {
|
|
249
243
|
logger.debug('VOICE_MESSAGE_RECEIVED event received');
|
|
250
|
-
logger.debug(
|
|
244
|
+
logger.debug({ message: params.message }, 'Message:');
|
|
251
245
|
},
|
|
252
246
|
],
|
|
253
247
|
[EventType.WORLD_CONNECTED]: [
|
|
254
248
|
async (params: WorldPayload) => {
|
|
255
249
|
logger.debug('WORLD_CONNECTED event received');
|
|
256
|
-
logger.debug(
|
|
250
|
+
logger.debug({ world: params.world }, 'World:');
|
|
257
251
|
},
|
|
258
252
|
],
|
|
259
253
|
[EventType.WORLD_JOINED]: [
|
|
260
254
|
async (params: WorldPayload) => {
|
|
261
255
|
logger.debug('WORLD_JOINED event received');
|
|
262
|
-
logger.debug(
|
|
256
|
+
logger.debug({ world: params.world }, 'World:');
|
|
263
257
|
},
|
|
264
258
|
],
|
|
265
259
|
},
|
|
266
260
|
services: [StarterService],
|
|
267
|
-
actions: [
|
|
268
|
-
providers: [
|
|
261
|
+
actions: [quickAction],
|
|
262
|
+
providers: [quickProvider],
|
|
269
263
|
// dependencies: ['@elizaos/plugin-knowledge'], <--- plugin dependencies go here (if requires another plugin)
|
|
270
264
|
};
|
|
271
265
|
|