@elizaos/cli 1.3.0 → 1.3.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 +1 -1
- package/dist/{chunk-2CUIHNPL.js → chunk-5GUS4CFO.js} +7 -2
- package/dist/{chunk-2ALAPQLV.js → chunk-E6XYTE3A.js} +296 -311
- package/dist/chunk-GXWWPFBO.js +39 -0
- package/dist/{chunk-I77ZRNYO.js → chunk-T2QDIXGU.js} +2 -2
- package/dist/commands/agent/actions/index.d.ts +5 -0
- package/dist/commands/agent/actions/index.js +2 -2
- package/dist/commands/agent/index.d.ts +2 -2
- package/dist/commands/agent/index.js +2 -2
- package/dist/commands/create/actions/index.js +3 -3
- package/dist/commands/create/index.js +4 -4
- package/dist/commands/shared/index.d.ts +11 -28
- package/dist/commands/shared/index.js +7 -3
- package/dist/index.js +541 -450
- package/dist/{registry-N626N4VG.js → registry-433S5F3Y.js} +2 -2
- package/dist/templates/plugin-quick-starter/.gitignore +66 -0
- package/dist/templates/plugin-quick-starter/.npmignore +5 -0
- package/dist/templates/plugin-quick-starter/package.json +11 -3
- package/dist/templates/plugin-quick-starter/src/__tests__/plugin.test.ts +499 -146
- package/dist/templates/plugin-quick-starter/src/__tests__/test-utils.ts +316 -115
- package/dist/templates/plugin-quick-starter/src/plugin.ts +7 -13
- package/dist/templates/plugin-starter/.gitignore +66 -0
- package/dist/templates/plugin-starter/.npmignore +5 -0
- package/dist/templates/plugin-starter/README.md +1 -1
- package/dist/templates/plugin-starter/package.json +11 -3
- 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 +18 -22
- package/dist/templates/project-starter/.gitignore +57 -0
- package/dist/templates/project-starter/.npmignore +11 -0
- package/dist/templates/project-starter/README.md +1 -1
- package/dist/templates/project-starter/package.json +4 -4
- 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 +1 -1
- 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/.gitignore +57 -0
- package/dist/templates/project-tee-starter/.npmignore +6 -0
- 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 +39 -19
- package/dist/templates/project-tee-starter/__tests__/build-order.test.ts +62 -0
- package/dist/templates/project-tee-starter/__tests__/character.test.ts +19 -17
- package/dist/templates/project-tee-starter/__tests__/config.test.ts +10 -3
- package/dist/templates/project-tee-starter/__tests__/env.test.ts +2 -1
- package/dist/templates/project-tee-starter/__tests__/file-structure.test.ts +14 -3
- package/dist/templates/project-tee-starter/__tests__/frontend.test.ts +459 -0
- package/dist/templates/project-tee-starter/__tests__/plugin.test.ts +4 -2
- package/dist/templates/project-tee-starter/__tests__/routes.test.ts +15 -6
- package/dist/templates/project-tee-starter/__tests__/tee-validation.test.ts +295 -0
- package/dist/templates/project-tee-starter/__tests__/vite-config-utils.ts +39 -0
- 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/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 +6 -6
- package/dist/templates/project-tee-starter/src/plugin.ts +209 -59
- 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-DBLSDYBF.js} +2 -2
- package/package.json +12 -7
- package/templates/plugin-quick-starter/.gitignore +66 -0
- package/templates/plugin-quick-starter/.npmignore +5 -0
- package/templates/plugin-quick-starter/package.json +11 -3
- package/templates/plugin-quick-starter/src/__tests__/plugin.test.ts +499 -146
- package/templates/plugin-quick-starter/src/__tests__/test-utils.ts +316 -115
- package/templates/plugin-quick-starter/src/plugin.ts +7 -13
- package/templates/plugin-starter/.gitignore +66 -0
- package/templates/plugin-starter/.npmignore +5 -0
- package/templates/plugin-starter/README.md +1 -1
- package/templates/plugin-starter/package.json +11 -3
- 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 +18 -22
- package/templates/project-starter/.gitignore +57 -0
- package/templates/project-starter/.npmignore +11 -0
- package/templates/project-starter/README.md +1 -1
- package/templates/project-starter/package.json +4 -4
- 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 +1 -1
- package/templates/project-starter/tsup.config.ts +2 -1
- package/templates/project-tee-starter/.dockerignore +64 -14
- package/templates/project-tee-starter/.gitignore +57 -0
- package/templates/project-tee-starter/.npmignore +6 -0
- package/templates/project-tee-starter/Dockerfile +9 -5
- package/templates/project-tee-starter/GUIDE.md +103 -42
- package/templates/project-tee-starter/README.md +39 -19
- package/templates/project-tee-starter/__tests__/build-order.test.ts +62 -0
- package/templates/project-tee-starter/__tests__/character.test.ts +19 -17
- package/templates/project-tee-starter/__tests__/config.test.ts +10 -3
- package/templates/project-tee-starter/__tests__/env.test.ts +2 -1
- package/templates/project-tee-starter/__tests__/file-structure.test.ts +14 -3
- package/templates/project-tee-starter/__tests__/frontend.test.ts +459 -0
- package/templates/project-tee-starter/__tests__/plugin.test.ts +4 -2
- package/templates/project-tee-starter/__tests__/routes.test.ts +15 -6
- package/templates/project-tee-starter/__tests__/tee-validation.test.ts +295 -0
- package/templates/project-tee-starter/__tests__/vite-config-utils.ts +39 -0
- 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/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 +6 -6
- package/templates/project-tee-starter/src/plugin.ts +209 -59
- 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/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
|
@@ -1,459 +0,0 @@
|
|
|
1
|
-
# ElizaOS Advanced Migration Guide - v1.x
|
|
2
|
-
|
|
3
|
-
> **Important**: This guide covers advanced breaking changes for evaluators, services, and runtime methods. Read the main [migration-guide.md](./migration-guide.md) first for actions, providers, and basic migrations.
|
|
4
|
-
|
|
5
|
-
## Table of Contents
|
|
6
|
-
|
|
7
|
-
- [Evaluators Migration](#evaluators-migration)
|
|
8
|
-
- [Services & Clients Migration](#services--clients-migration)
|
|
9
|
-
- [Runtime Method Changes](#runtime-method-changes)
|
|
10
|
-
- [Entity System Migration](#entity-system-migration)
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
## Evaluators Migration
|
|
15
|
-
|
|
16
|
-
### Evaluator Interface Changes
|
|
17
|
-
|
|
18
|
-
Evaluators remain largely unchanged in their core structure, but their integration with the runtime has evolved:
|
|
19
|
-
|
|
20
|
-
```typescript
|
|
21
|
-
// v0 Evaluator usage remains the same
|
|
22
|
-
export interface Evaluator {
|
|
23
|
-
alwaysRun?: boolean;
|
|
24
|
-
description: string;
|
|
25
|
-
similes: string[];
|
|
26
|
-
examples: EvaluationExample[];
|
|
27
|
-
handler: Handler;
|
|
28
|
-
name: string;
|
|
29
|
-
validate: Validator;
|
|
30
|
-
}
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
### Key Changes:
|
|
34
|
-
|
|
35
|
-
1. **Evaluation Results**: The `evaluate()` method now returns `Evaluator[]` instead of `string[]`:
|
|
36
|
-
|
|
37
|
-
```typescript
|
|
38
|
-
// v0: Returns string array of evaluator names
|
|
39
|
-
const evaluators: string[] = await runtime.evaluate(message, state);
|
|
40
|
-
|
|
41
|
-
// v1: Returns Evaluator objects
|
|
42
|
-
const evaluators: Evaluator[] | null = await runtime.evaluate(message, state);
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
2. **Additional Parameters**: The evaluate method accepts new optional parameters:
|
|
46
|
-
|
|
47
|
-
```typescript
|
|
48
|
-
// v1: Extended evaluate signature
|
|
49
|
-
await runtime.evaluate(
|
|
50
|
-
message: Memory,
|
|
51
|
-
state?: State,
|
|
52
|
-
didRespond?: boolean,
|
|
53
|
-
callback?: HandlerCallback,
|
|
54
|
-
responses?: Memory[] // NEW: Can pass responses for evaluation
|
|
55
|
-
);
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
---
|
|
59
|
-
|
|
60
|
-
## Services & Clients Migration
|
|
61
|
-
|
|
62
|
-
### Service Registration Changes
|
|
63
|
-
|
|
64
|
-
Services have undergone significant architectural changes:
|
|
65
|
-
|
|
66
|
-
```typescript
|
|
67
|
-
// v0: Service extends abstract Service class
|
|
68
|
-
export abstract class Service {
|
|
69
|
-
static get serviceType(): ServiceType {
|
|
70
|
-
throw new Error('Service must implement static serviceType getter');
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
public static getInstance<T extends Service>(): T {
|
|
74
|
-
// Singleton pattern
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
abstract initialize(runtime: IAgentRuntime): Promise<void>;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// v1: Service is now a class with static properties
|
|
81
|
-
export class Service {
|
|
82
|
-
static serviceType: ServiceTypeName;
|
|
83
|
-
|
|
84
|
-
async initialize(runtime: IAgentRuntime): Promise<void> {
|
|
85
|
-
// Implementation
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### Migration Steps:
|
|
91
|
-
|
|
92
|
-
1. **Remove Singleton Pattern**:
|
|
93
|
-
|
|
94
|
-
```typescript
|
|
95
|
-
// v0: Singleton getInstance
|
|
96
|
-
class MyService extends Service {
|
|
97
|
-
private static instance: MyService | null = null;
|
|
98
|
-
|
|
99
|
-
public static getInstance(): MyService {
|
|
100
|
-
if (!this.instance) {
|
|
101
|
-
this.instance = new MyService();
|
|
102
|
-
}
|
|
103
|
-
return this.instance;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// v1: Direct instantiation
|
|
108
|
-
class MyService extends Service {
|
|
109
|
-
static serviceType = ServiceTypeName.MY_SERVICE;
|
|
110
|
-
// No getInstance needed
|
|
111
|
-
}
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
2. **Update Service Registration**:
|
|
115
|
-
|
|
116
|
-
```typescript
|
|
117
|
-
// v0: Register instance
|
|
118
|
-
await runtime.registerService(MyService.getInstance());
|
|
119
|
-
|
|
120
|
-
// v1: Register class
|
|
121
|
-
await runtime.registerService(MyService);
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
3. **Service Type Enum Changes**:
|
|
125
|
-
|
|
126
|
-
```typescript
|
|
127
|
-
// v0: ServiceType enum
|
|
128
|
-
export enum ServiceType {
|
|
129
|
-
IMAGE_DESCRIPTION = 'image_description',
|
|
130
|
-
TRANSCRIPTION = 'transcription',
|
|
131
|
-
// ...
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// v1: ServiceTypeName (similar but may have new values)
|
|
135
|
-
export enum ServiceTypeName {
|
|
136
|
-
IMAGE_DESCRIPTION = 'image_description',
|
|
137
|
-
TRANSCRIPTION = 'transcription',
|
|
138
|
-
// Check for any renamed or new service types
|
|
139
|
-
}
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
---
|
|
143
|
-
|
|
144
|
-
## Runtime Method Changes
|
|
145
|
-
|
|
146
|
-
### 1. State Management
|
|
147
|
-
|
|
148
|
-
The `updateRecentMessageState` method has been removed:
|
|
149
|
-
|
|
150
|
-
```typescript
|
|
151
|
-
// v0: Separate method for updating state
|
|
152
|
-
currentState = await runtime.updateRecentMessageState(currentState);
|
|
153
|
-
|
|
154
|
-
// v1: Use composeState with specific keys
|
|
155
|
-
currentState = await runtime.composeState(message, ['RECENT_MESSAGES']);
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
### 2. Memory Manager Access
|
|
159
|
-
|
|
160
|
-
Memory managers are no longer directly accessible:
|
|
161
|
-
|
|
162
|
-
```typescript
|
|
163
|
-
// v0: Direct access to memory managers
|
|
164
|
-
runtime.messageManager.getMemories({...});
|
|
165
|
-
runtime.registerMemoryManager(manager);
|
|
166
|
-
const manager = runtime.getMemoryManager("messages");
|
|
167
|
-
|
|
168
|
-
// v1: Use database adapter methods
|
|
169
|
-
await runtime.getMemories({
|
|
170
|
-
roomId,
|
|
171
|
-
count,
|
|
172
|
-
unique: false,
|
|
173
|
-
tableName: "messages",
|
|
174
|
-
agentId: runtime.agentId
|
|
175
|
-
});
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
### 3. Model Usage
|
|
179
|
-
|
|
180
|
-
Complete overhaul of model interaction:
|
|
181
|
-
|
|
182
|
-
```typescript
|
|
183
|
-
// v0: generateText with ModelClass
|
|
184
|
-
import { generateText, ModelClass } from '@elizaos/core';
|
|
185
|
-
|
|
186
|
-
const result = await generateText({
|
|
187
|
-
runtime,
|
|
188
|
-
context: prompt,
|
|
189
|
-
modelClass: ModelClass.SMALL,
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
// v1: useModel with ModelTypeName
|
|
193
|
-
const result = await runtime.useModel(ModelTypeName.TEXT_SMALL, {
|
|
194
|
-
prompt,
|
|
195
|
-
stopSequences: [],
|
|
196
|
-
});
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
### 4. Settings Management
|
|
200
|
-
|
|
201
|
-
#### Global Settings Object Removed
|
|
202
|
-
|
|
203
|
-
The global `settings` object is no longer exported from `@elizaos/core`:
|
|
204
|
-
|
|
205
|
-
```typescript
|
|
206
|
-
// v0: Import and use global settings
|
|
207
|
-
import { settings } from '@elizaos/core';
|
|
208
|
-
|
|
209
|
-
const charityAddress = settings[networkKey];
|
|
210
|
-
const apiKey = settings.OPENAI_API_KEY;
|
|
211
|
-
|
|
212
|
-
// v1: Use runtime.getSetting()
|
|
213
|
-
// Remove the settings import
|
|
214
|
-
import { elizaLogger, type IAgentRuntime } from '@elizaos/core';
|
|
215
|
-
|
|
216
|
-
const charityAddress = runtime.getSetting(networkKey);
|
|
217
|
-
const apiKey = runtime.getSetting('OPENAI_API_KEY');
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
#### New Settings Methods
|
|
221
|
-
|
|
222
|
-
```typescript
|
|
223
|
-
// v0: Only getSetting through runtime
|
|
224
|
-
const value = runtime.getSetting(key);
|
|
225
|
-
|
|
226
|
-
// v1: Both get and set
|
|
227
|
-
const value = runtime.getSetting(key);
|
|
228
|
-
runtime.setSetting(key, value, isSecret);
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
#### Migration Example
|
|
232
|
-
|
|
233
|
-
```typescript
|
|
234
|
-
// v0: utils.ts using global settings
|
|
235
|
-
import { settings } from '@elizaos/core';
|
|
236
|
-
|
|
237
|
-
export function getCharityAddress(network: string): string | null {
|
|
238
|
-
const networkKey = `CHARITY_ADDRESS_${network.toUpperCase()}`;
|
|
239
|
-
const charityAddress = settings[networkKey];
|
|
240
|
-
return charityAddress;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
// v1: Pass runtime to access settings
|
|
244
|
-
export function getCharityAddress(runtime: IAgentRuntime, network: string): string | null {
|
|
245
|
-
const networkKey = `CHARITY_ADDRESS_${network.toUpperCase()}`;
|
|
246
|
-
const charityAddress = runtime.getSetting(networkKey);
|
|
247
|
-
return charityAddress;
|
|
248
|
-
}
|
|
249
|
-
```
|
|
250
|
-
|
|
251
|
-
#### Common Settings Migration Patterns
|
|
252
|
-
|
|
253
|
-
1. **Environment Variables**: Both v0 and v1 read from environment variables, but access patterns differ
|
|
254
|
-
2. **Dynamic Settings**: v1 allows runtime setting updates with `setSetting()`
|
|
255
|
-
3. **Secret Management**: v1 adds explicit secret handling with the `isSecret` parameter
|
|
256
|
-
|
|
257
|
-
#### Real-World Fix: Coinbase Plugin
|
|
258
|
-
|
|
259
|
-
The Coinbase plugin's `getCharityAddress` function needs updating:
|
|
260
|
-
|
|
261
|
-
```typescript
|
|
262
|
-
// v0: Current broken code
|
|
263
|
-
import { settings } from '@elizaos/core'; // ERROR: 'settings' not exported
|
|
264
|
-
|
|
265
|
-
export function getCharityAddress(network: string, isCharitable = false): string | null {
|
|
266
|
-
const networkKey = `CHARITY_ADDRESS_${network.toUpperCase()}`;
|
|
267
|
-
const charityAddress = settings[networkKey]; // ERROR: Cannot use settings
|
|
268
|
-
// ...
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
// v1: Fixed code - runtime parameter added
|
|
272
|
-
export function getCharityAddress(
|
|
273
|
-
runtime: IAgentRuntime, // Add runtime parameter
|
|
274
|
-
network: string,
|
|
275
|
-
isCharitable = false
|
|
276
|
-
): string | null {
|
|
277
|
-
const networkKey = `CHARITY_ADDRESS_${network.toUpperCase()}`;
|
|
278
|
-
const charityAddress = runtime.getSetting(networkKey); // Use runtime.getSetting
|
|
279
|
-
// ...
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
// Update all callers to pass runtime
|
|
283
|
-
const charityAddress = getCharityAddress(runtime, network);
|
|
284
|
-
```
|
|
285
|
-
|
|
286
|
-
### 5. Event System
|
|
287
|
-
|
|
288
|
-
New event-driven architecture:
|
|
289
|
-
|
|
290
|
-
```typescript
|
|
291
|
-
// v1: Register and emit events
|
|
292
|
-
runtime.registerEvent('custom-event', async (params) => {
|
|
293
|
-
// Handle event
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
await runtime.emitEvent('custom-event', { data: 'value' });
|
|
297
|
-
```
|
|
298
|
-
|
|
299
|
-
---
|
|
300
|
-
|
|
301
|
-
## Entity System Migration
|
|
302
|
-
|
|
303
|
-
The most significant change is the shift from User/Participant to Entity/Room/World:
|
|
304
|
-
|
|
305
|
-
### User → Entity
|
|
306
|
-
|
|
307
|
-
```typescript
|
|
308
|
-
// v0: User-based methods
|
|
309
|
-
await runtime.ensureUserExists(userId, userName, name, email, source);
|
|
310
|
-
const account = await runtime.getAccountById(userId);
|
|
311
|
-
|
|
312
|
-
// v1: Entity-based methods
|
|
313
|
-
await runtime.ensureConnection({
|
|
314
|
-
entityId: userId,
|
|
315
|
-
roomId,
|
|
316
|
-
userName,
|
|
317
|
-
name,
|
|
318
|
-
worldId,
|
|
319
|
-
source,
|
|
320
|
-
});
|
|
321
|
-
const entity = await runtime.getEntityById(entityId);
|
|
322
|
-
```
|
|
323
|
-
|
|
324
|
-
### Participant → Room Membership
|
|
325
|
-
|
|
326
|
-
```typescript
|
|
327
|
-
// v0: Participant methods
|
|
328
|
-
await runtime.ensureParticipantExists(userId, roomId);
|
|
329
|
-
await runtime.ensureParticipantInRoom(userId, roomId);
|
|
330
|
-
|
|
331
|
-
// v1: Simplified room membership
|
|
332
|
-
await runtime.ensureParticipantInRoom(entityId, roomId);
|
|
333
|
-
```
|
|
334
|
-
|
|
335
|
-
### New World Concept
|
|
336
|
-
|
|
337
|
-
v1 introduces the concept of "worlds" (servers/environments):
|
|
338
|
-
|
|
339
|
-
```typescript
|
|
340
|
-
// v1: World management
|
|
341
|
-
await runtime.ensureWorldExists({
|
|
342
|
-
id: worldId,
|
|
343
|
-
name: serverName,
|
|
344
|
-
type: 'discord', // or other platform
|
|
345
|
-
});
|
|
346
|
-
|
|
347
|
-
// Get all rooms in a world
|
|
348
|
-
const rooms = await runtime.getRooms(worldId);
|
|
349
|
-
```
|
|
350
|
-
|
|
351
|
-
### Connection Management
|
|
352
|
-
|
|
353
|
-
```typescript
|
|
354
|
-
// v0: Multiple ensure methods
|
|
355
|
-
await runtime.ensureUserExists(...);
|
|
356
|
-
await runtime.ensureRoomExists(roomId);
|
|
357
|
-
await runtime.ensureParticipantInRoom(...);
|
|
358
|
-
|
|
359
|
-
// v1: Single connection method
|
|
360
|
-
await runtime.ensureConnection({
|
|
361
|
-
entityId,
|
|
362
|
-
roomId,
|
|
363
|
-
worldId,
|
|
364
|
-
userName,
|
|
365
|
-
name,
|
|
366
|
-
source,
|
|
367
|
-
channelId,
|
|
368
|
-
serverId,
|
|
369
|
-
type: 'user',
|
|
370
|
-
metadata: {}
|
|
371
|
-
});
|
|
372
|
-
```
|
|
373
|
-
|
|
374
|
-
---
|
|
375
|
-
|
|
376
|
-
## Client Migration
|
|
377
|
-
|
|
378
|
-
Clients now have a simpler interface:
|
|
379
|
-
|
|
380
|
-
```typescript
|
|
381
|
-
// v0: Client with config
|
|
382
|
-
export type Client = {
|
|
383
|
-
name: string;
|
|
384
|
-
config?: { [key: string]: any };
|
|
385
|
-
start: (runtime: IAgentRuntime) => Promise<ClientInstance>;
|
|
386
|
-
};
|
|
387
|
-
|
|
388
|
-
// v1: Client integrated with services
|
|
389
|
-
// Clients are now typically implemented as services
|
|
390
|
-
class MyClient extends Service {
|
|
391
|
-
static serviceType = ServiceTypeName.MY_CLIENT;
|
|
392
|
-
|
|
393
|
-
async initialize(runtime: IAgentRuntime): Promise<void> {
|
|
394
|
-
// Start client operations
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
async stop(): Promise<void> {
|
|
398
|
-
// Stop client operations
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
```
|
|
402
|
-
|
|
403
|
-
---
|
|
404
|
-
|
|
405
|
-
## Quick Reference
|
|
406
|
-
|
|
407
|
-
### Removed Methods
|
|
408
|
-
|
|
409
|
-
- `updateRecentMessageState()` → Use `composeState(message, ['RECENT_MESSAGES'])`
|
|
410
|
-
- `registerMemoryManager()` → Not needed, use database adapter
|
|
411
|
-
- `getMemoryManager()` → Use database adapter methods
|
|
412
|
-
- `registerContextProvider()` → Use `registerProvider()`
|
|
413
|
-
|
|
414
|
-
### Removed Exports
|
|
415
|
-
|
|
416
|
-
- `settings` object → Use `runtime.getSetting(key)` instead
|
|
417
|
-
|
|
418
|
-
### Changed Methods
|
|
419
|
-
|
|
420
|
-
- `evaluate()` → Now returns `Evaluator[]` instead of `string[]`
|
|
421
|
-
- `getAccountById()` → `getEntityById()`
|
|
422
|
-
- `ensureUserExists()` → `ensureConnection()`
|
|
423
|
-
- `generateText()` → `runtime.useModel()`
|
|
424
|
-
|
|
425
|
-
### New Methods
|
|
426
|
-
|
|
427
|
-
- `setSetting()`
|
|
428
|
-
- `registerEvent()`
|
|
429
|
-
- `emitEvent()`
|
|
430
|
-
- `useModel()`
|
|
431
|
-
- `registerModel()`
|
|
432
|
-
- `ensureWorldExists()`
|
|
433
|
-
- `getRooms()`
|
|
434
|
-
|
|
435
|
-
---
|
|
436
|
-
|
|
437
|
-
## Migration Checklist
|
|
438
|
-
|
|
439
|
-
- [ ] Update all evaluator result handling to expect `Evaluator[]` objects
|
|
440
|
-
- [ ] Remove singleton patterns from services
|
|
441
|
-
- [ ] Update service registration to pass classes instead of instances
|
|
442
|
-
- [ ] Replace `updateRecentMessageState` with `composeState`
|
|
443
|
-
- [ ] Migrate from `generateText` to `runtime.useModel`
|
|
444
|
-
- [ ] Update user/participant methods to entity/room methods
|
|
445
|
-
- [ ] Add world management for multi-server environments
|
|
446
|
-
- [ ] Convert clients to service-based architecture
|
|
447
|
-
- [ ] Update any direct memory manager access to use database adapter
|
|
448
|
-
- [ ] Replace `import { settings }` with `runtime.getSetting()` calls
|
|
449
|
-
- [ ] Update functions to accept `runtime` parameter where settings are needed
|
|
450
|
-
|
|
451
|
-
---
|
|
452
|
-
|
|
453
|
-
## Need Help?
|
|
454
|
-
|
|
455
|
-
If you encounter issues not covered in this guide:
|
|
456
|
-
|
|
457
|
-
1. Check the main [migration-guide.md](./migration-guide.md) for basic migrations
|
|
458
|
-
2. Review the [v1.x examples](../packages/core/examples) for reference implementations
|
|
459
|
-
3. Join our Discord community for support
|