@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,712 +0,0 @@
|
|
|
1
|
-
# ElizaOS Plugin Migration Guide - v1.x
|
|
2
|
-
|
|
3
|
-
> **Important**: This guide provides a general framework for migrating ElizaOS plugins to v1.x. Specific configurations will vary based on your plugin's functionality.
|
|
4
|
-
|
|
5
|
-
## Step 1: Create Version Branch
|
|
6
|
-
|
|
7
|
-
Create a new branch for the 1.x version while preserving the main branch for backwards compatibility:
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
git checkout -b 1.x
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
> **Note**: This branch will serve as your new 1.x version branch, keeping `main` intact for legacy support.
|
|
14
|
-
|
|
15
|
-
---
|
|
16
|
-
|
|
17
|
-
## Step 2: Remove Deprecated Files
|
|
18
|
-
|
|
19
|
-
Clean up deprecated tooling and configuration files:
|
|
20
|
-
|
|
21
|
-
### Files to Remove:
|
|
22
|
-
|
|
23
|
-
- **`biome.json`** - Deprecated linter configuration
|
|
24
|
-
- **`vitest.config.ts`** - Replaced by Bun test runner
|
|
25
|
-
- **Lock files** - Any `lock.json` or `yml.lock` files
|
|
26
|
-
|
|
27
|
-
### Quick Cleanup Commands:
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
rm -rf vitest.config.ts
|
|
31
|
-
rm -rf biome.json
|
|
32
|
-
rm -f *.lock.json *.yml.lock
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
> **Why?** The ElizaOS ecosystem has standardized on:
|
|
36
|
-
>
|
|
37
|
-
> - **Bun's built-in test runner** (replacing Vitest) - All plugins must now use `bun test`
|
|
38
|
-
> - **Prettier** for code formatting (replacing Biome)
|
|
39
|
-
>
|
|
40
|
-
> This ensures consistency across all ElizaOS plugins and simplifies the development toolchain.
|
|
41
|
-
|
|
42
|
-
---
|
|
43
|
-
|
|
44
|
-
## Step 3: Update package.json
|
|
45
|
-
|
|
46
|
-
### 3.1 Version Update
|
|
47
|
-
|
|
48
|
-
```json
|
|
49
|
-
"version": "1.0.0"
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
### 3.1.5 Package Name Update
|
|
53
|
-
|
|
54
|
-
Check if your package name contains the old namespace and update it:
|
|
55
|
-
|
|
56
|
-
```json
|
|
57
|
-
// OLD (incorrect):
|
|
58
|
-
"name": "@elizaos-plugins/plugin-bnb"
|
|
59
|
-
|
|
60
|
-
// NEW (correct):
|
|
61
|
-
"name": "@elizaos/plugin-bnb"
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
> **Important**: If your package name starts with `@elizaos-plugins/`, remove the "s" from "plugins" to change it to `@elizaos/`. This is the correct namespace for all ElizaOS plugins in v1.x.
|
|
65
|
-
|
|
66
|
-
### 3.2 Dependencies
|
|
67
|
-
|
|
68
|
-
- **Remove**: `biome`, `vitest` (if present)
|
|
69
|
-
- **Add**: Core and plugin-specific dependencies
|
|
70
|
-
|
|
71
|
-
### 3.3 Dev Dependencies
|
|
72
|
-
|
|
73
|
-
Add the following development dependencies:
|
|
74
|
-
|
|
75
|
-
```json
|
|
76
|
-
"devDependencies": {
|
|
77
|
-
"tsup": "8.3.5",
|
|
78
|
-
"prettier": "^3.0.0",
|
|
79
|
-
"bun": "^1.2.15", // REQUIRED: All plugins now use Bun test runner
|
|
80
|
-
"@types/bun": "latest", // REQUIRED: TypeScript types for Bun
|
|
81
|
-
"typescript": "^5.0.0"
|
|
82
|
-
}
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
> **Important**: `bun` and `@types/bun` are **REQUIRED** dependencies for all plugins in v1.x. The ElizaOS ecosystem has standardized on Bun's built-in test runner, replacing Vitest. Without these dependencies, your tests will not run properly.
|
|
86
|
-
|
|
87
|
-
### 3.4 Scripts Section
|
|
88
|
-
|
|
89
|
-
Replace your existing scripts with:
|
|
90
|
-
|
|
91
|
-
```json
|
|
92
|
-
"scripts": {
|
|
93
|
-
"build": "tsup",
|
|
94
|
-
"dev": "tsup --watch",
|
|
95
|
-
"lint": "prettier --write ./src",
|
|
96
|
-
"clean": "rm -rf dist .turbo node_modules .turbo-tsconfig.json tsconfig.tsbuildinfo",
|
|
97
|
-
"format": "prettier --write ./src",
|
|
98
|
-
"format:check": "prettier --check ./src",
|
|
99
|
-
"test": "bun test", // Uses Bun's built-in test runner
|
|
100
|
-
"test:watch": "bun test --watch", // Watch mode for development
|
|
101
|
-
"test:coverage": "bun test --coverage" // Coverage reports with Bun
|
|
102
|
-
}
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
> **Note**: All test scripts now use Bun's built-in test runner. Make sure you have `bun` and `@types/bun` installed as dev dependencies (see section 3.3).
|
|
106
|
-
|
|
107
|
-
### 3.5 Publish Configuration
|
|
108
|
-
|
|
109
|
-
Add the following to enable public npm publishing:
|
|
110
|
-
|
|
111
|
-
```json
|
|
112
|
-
"publishConfig": {
|
|
113
|
-
"access": "public"
|
|
114
|
-
}
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
### 3.6 Agent Configuration
|
|
118
|
-
|
|
119
|
-
Replace your `agentConfig` with the new structure:
|
|
120
|
-
|
|
121
|
-
```json
|
|
122
|
-
"agentConfig": {
|
|
123
|
-
"pluginType": "elizaos:plugin:1.0.0",
|
|
124
|
-
"pluginParameters": {
|
|
125
|
-
"YOUR_PARAMETER_NAME": {
|
|
126
|
-
"type": "string",
|
|
127
|
-
"description": "Description of what this parameter does",
|
|
128
|
-
"required": true,
|
|
129
|
-
"sensitive": true
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
> **Note**: Replace `YOUR_PARAMETER_NAME` with your plugin's specific configuration parameters. Common types include API keys, endpoints, credentials, etc.
|
|
136
|
-
|
|
137
|
-
### 3.7 Dependencies
|
|
138
|
-
|
|
139
|
-
Add your plugin-specific dependencies:
|
|
140
|
-
|
|
141
|
-
```json
|
|
142
|
-
"dependencies": {
|
|
143
|
-
"@elizaos/core": "latest",
|
|
144
|
-
// Add your plugin-specific dependencies here
|
|
145
|
-
}
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
---
|
|
149
|
-
|
|
150
|
-
## Step 4: TypeScript Configuration
|
|
151
|
-
|
|
152
|
-
### 4.1 Update `tsup.config.ts`
|
|
153
|
-
|
|
154
|
-
```typescript
|
|
155
|
-
import { defineConfig } from 'tsup';
|
|
156
|
-
|
|
157
|
-
export default defineConfig({
|
|
158
|
-
entry: ['src/index.ts'],
|
|
159
|
-
outDir: 'dist',
|
|
160
|
-
tsconfig: './tsconfig.build.json', // Use build-specific tsconfig
|
|
161
|
-
sourcemap: true,
|
|
162
|
-
clean: true,
|
|
163
|
-
format: ['esm'], // ESM output format
|
|
164
|
-
dts: true,
|
|
165
|
-
external: ['dotenv', 'fs', 'path', 'https', 'http', '@elizaos/core', 'zod'],
|
|
166
|
-
});
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
### 4.2 Update `tsconfig.json`
|
|
170
|
-
|
|
171
|
-
```json
|
|
172
|
-
{
|
|
173
|
-
"compilerOptions": {
|
|
174
|
-
"outDir": "dist",
|
|
175
|
-
"rootDir": "src",
|
|
176
|
-
"baseUrl": "./",
|
|
177
|
-
"lib": ["ESNext"],
|
|
178
|
-
"target": "ESNext",
|
|
179
|
-
"module": "Preserve",
|
|
180
|
-
"moduleResolution": "Bundler",
|
|
181
|
-
"strict": true,
|
|
182
|
-
"esModuleInterop": true,
|
|
183
|
-
"allowImportingTsExtensions": true,
|
|
184
|
-
"declaration": true,
|
|
185
|
-
"emitDeclarationOnly": true,
|
|
186
|
-
"resolveJsonModule": true,
|
|
187
|
-
"moduleDetection": "force",
|
|
188
|
-
"allowArbitraryExtensions": true,
|
|
189
|
-
"types": ["bun"]
|
|
190
|
-
},
|
|
191
|
-
"include": ["src/**/*.ts"]
|
|
192
|
-
}
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
### 4.3 Create `tsconfig.build.json`
|
|
196
|
-
|
|
197
|
-
Create a new file with build-specific TypeScript configuration:
|
|
198
|
-
|
|
199
|
-
```json
|
|
200
|
-
{
|
|
201
|
-
"extends": "./tsconfig.json",
|
|
202
|
-
"compilerOptions": {
|
|
203
|
-
"rootDir": "./src",
|
|
204
|
-
"outDir": "./dist",
|
|
205
|
-
"sourceMap": true,
|
|
206
|
-
"inlineSources": true,
|
|
207
|
-
"declaration": true,
|
|
208
|
-
"emitDeclarationOnly": true
|
|
209
|
-
},
|
|
210
|
-
"include": ["src/**/*.ts"],
|
|
211
|
-
"exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.spec.ts"]
|
|
212
|
-
}
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
---
|
|
216
|
-
|
|
217
|
-
## Step 5: Verify Build Process
|
|
218
|
-
|
|
219
|
-
Clean everything and test the new setup:
|
|
220
|
-
|
|
221
|
-
```bash
|
|
222
|
-
# Clean all build artifacts and dependencies
|
|
223
|
-
rm -rf dist node_modules .turbo
|
|
224
|
-
|
|
225
|
-
# Install dependencies with Bun
|
|
226
|
-
bun install
|
|
227
|
-
|
|
228
|
-
# Build the project
|
|
229
|
-
bun run build
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
### Expected Results:
|
|
233
|
-
|
|
234
|
-
- Dependencies install without errors
|
|
235
|
-
- Build completes successfully
|
|
236
|
-
- `dist` folder contains compiled output
|
|
237
|
-
- TypeScript declarations are generated
|
|
238
|
-
|
|
239
|
-
> **Next Steps**: After verifying the build, proceed to Step 6 to migrate your actions and providers to handle the breaking API changes.
|
|
240
|
-
|
|
241
|
-
## Step 6: Migrate Actions & Providers
|
|
242
|
-
|
|
243
|
-
### 6.1 Import Changes
|
|
244
|
-
|
|
245
|
-
Update your imports in action files:
|
|
246
|
-
|
|
247
|
-
```typescript
|
|
248
|
-
// Remove these imports:
|
|
249
|
-
import { generateObject, composeContext } from '@elizaos/core';
|
|
250
|
-
|
|
251
|
-
// Add/update these imports:
|
|
252
|
-
import {
|
|
253
|
-
composePromptFromState,
|
|
254
|
-
parseKeyValueXml,
|
|
255
|
-
ModelType, // Note: ModelType replaces ModelClass
|
|
256
|
-
} from '@elizaos/core';
|
|
257
|
-
```
|
|
258
|
-
|
|
259
|
-
### 6.2 State Handling Migration
|
|
260
|
-
|
|
261
|
-
Replace the state initialization and update pattern:
|
|
262
|
-
|
|
263
|
-
```typescript
|
|
264
|
-
// OLD Pattern:
|
|
265
|
-
let currentState = state;
|
|
266
|
-
if (!currentState) {
|
|
267
|
-
currentState = (await runtime.composeState(message)) as State;
|
|
268
|
-
} else {
|
|
269
|
-
currentState = await runtime.updateRecentMessageState(currentState);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
// NEW Pattern:
|
|
273
|
-
let currentState = state;
|
|
274
|
-
if (!currentState) {
|
|
275
|
-
currentState = await runtime.composeState(message);
|
|
276
|
-
} else {
|
|
277
|
-
currentState = await runtime.composeState(message, ['RECENT_MESSAGES']);
|
|
278
|
-
}
|
|
279
|
-
```
|
|
280
|
-
|
|
281
|
-
### 6.3 Context/Prompt Generation
|
|
282
|
-
|
|
283
|
-
Replace `composeContext` with `composePromptFromState`:
|
|
284
|
-
|
|
285
|
-
```typescript
|
|
286
|
-
// OLD:
|
|
287
|
-
const context = composeContext({
|
|
288
|
-
state: currentState,
|
|
289
|
-
template: yourTemplate,
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
// NEW:
|
|
293
|
-
const prompt = composePromptFromState({
|
|
294
|
-
state: currentState,
|
|
295
|
-
template: yourTemplate,
|
|
296
|
-
});
|
|
297
|
-
```
|
|
298
|
-
|
|
299
|
-
### 6.4 Template Migration - JSON to XML Format
|
|
300
|
-
|
|
301
|
-
#### Update Template Content:
|
|
302
|
-
|
|
303
|
-
Templates should be updated from requesting JSON responses to XML format for use with `parseKeyValueXml`.
|
|
304
|
-
|
|
305
|
-
```typescript
|
|
306
|
-
// OLD Template Pattern (JSON):
|
|
307
|
-
const template = `Respond with a JSON markdown block containing only the extracted values.
|
|
308
|
-
|
|
309
|
-
Example response for a new token:
|
|
310
|
-
\`\`\`json
|
|
311
|
-
{
|
|
312
|
-
"name": "Test Token",
|
|
313
|
-
"symbol": "TEST"
|
|
314
|
-
}
|
|
315
|
-
\`\`\`
|
|
316
|
-
|
|
317
|
-
Given the recent messages, extract the following information:
|
|
318
|
-
- Name
|
|
319
|
-
- Symbol`;
|
|
320
|
-
|
|
321
|
-
// NEW Template Pattern (XML):
|
|
322
|
-
const template = `Respond with an XML block containing only the extracted values. Use key-value pairs.
|
|
323
|
-
|
|
324
|
-
Example response for a new token:
|
|
325
|
-
<response>
|
|
326
|
-
<name>Test Token</name>
|
|
327
|
-
<symbol>TEST</symbol>
|
|
328
|
-
</response>
|
|
329
|
-
|
|
330
|
-
## Recent Messages
|
|
331
|
-
|
|
332
|
-
{{recentMessages}}
|
|
333
|
-
|
|
334
|
-
Given the recent messages, extract the following information about the requested token creation:
|
|
335
|
-
- Name
|
|
336
|
-
- Symbol
|
|
337
|
-
|
|
338
|
-
Respond with an XML block containing only the extracted values.`;
|
|
339
|
-
```
|
|
340
|
-
|
|
341
|
-
### 6.5 Content Generation Migration
|
|
342
|
-
|
|
343
|
-
Replace `generateObject` with `runtime.useModel`:
|
|
344
|
-
|
|
345
|
-
```typescript
|
|
346
|
-
// OLD Pattern:
|
|
347
|
-
const content = await generateObject({
|
|
348
|
-
runtime,
|
|
349
|
-
context: context,
|
|
350
|
-
modelClass: ModelClass.SMALL,
|
|
351
|
-
});
|
|
352
|
-
|
|
353
|
-
// NEW Pattern:
|
|
354
|
-
const result = await runtime.useModel(ModelType.TEXT_SMALL, {
|
|
355
|
-
prompt,
|
|
356
|
-
});
|
|
357
|
-
|
|
358
|
-
const content = parseKeyValueXml(result);
|
|
359
|
-
```
|
|
360
|
-
|
|
361
|
-
**Important Changes:**
|
|
362
|
-
|
|
363
|
-
- `ModelClass.SMALL` → `ModelType.TEXT_SMALL`
|
|
364
|
-
- First parameter is the model type enum value
|
|
365
|
-
- Second parameter is an object with `prompt` and optional `stopSequences`
|
|
366
|
-
- Parse the result with `parseKeyValueXml` which extracts key-value pairs from XML responses
|
|
367
|
-
|
|
368
|
-
### 6.6 Content Interface and Validation
|
|
369
|
-
|
|
370
|
-
#### Define Content Interface:
|
|
371
|
-
|
|
372
|
-
```typescript
|
|
373
|
-
export interface YourActionContent extends Content {
|
|
374
|
-
// Define your required fields
|
|
375
|
-
name: string;
|
|
376
|
-
symbol: string;
|
|
377
|
-
}
|
|
378
|
-
```
|
|
379
|
-
|
|
380
|
-
#### Create Validation Function:
|
|
381
|
-
|
|
382
|
-
```typescript
|
|
383
|
-
function isYourActionContent(_runtime: IAgentRuntime, content: any): content is YourActionContent {
|
|
384
|
-
elizaLogger.debug('Content for validation', content);
|
|
385
|
-
return typeof content.name === 'string' && typeof content.symbol === 'string';
|
|
386
|
-
}
|
|
387
|
-
```
|
|
388
|
-
|
|
389
|
-
### 6.7 Handler Pattern Updates
|
|
390
|
-
|
|
391
|
-
Complete handler migration example:
|
|
392
|
-
|
|
393
|
-
```typescript
|
|
394
|
-
handler: async (
|
|
395
|
-
runtime: IAgentRuntime,
|
|
396
|
-
message: Memory,
|
|
397
|
-
state: State,
|
|
398
|
-
_options: { [key: string]: unknown },
|
|
399
|
-
callback?: HandlerCallback
|
|
400
|
-
) => {
|
|
401
|
-
elizaLogger.log("Starting YOUR_ACTION handler...");
|
|
402
|
-
|
|
403
|
-
// 1. Initialize or update state
|
|
404
|
-
let currentState = state;
|
|
405
|
-
if (!currentState) {
|
|
406
|
-
currentState = await runtime.composeState(message);
|
|
407
|
-
} else {
|
|
408
|
-
currentState = await runtime.composeState(message, [
|
|
409
|
-
"RECENT_MESSAGES",
|
|
410
|
-
]);
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
// 2. Compose prompt from state
|
|
414
|
-
const prompt = composePromptFromState({
|
|
415
|
-
state: currentState,
|
|
416
|
-
template: yourTemplate,
|
|
417
|
-
});
|
|
418
|
-
|
|
419
|
-
// 3. Generate content using the model
|
|
420
|
-
const result = await runtime.useModel(ModelType.TEXT_SMALL, {
|
|
421
|
-
prompt,
|
|
422
|
-
stopSequences: [],
|
|
423
|
-
});
|
|
424
|
-
|
|
425
|
-
// 4. Parse the result
|
|
426
|
-
const content = parseKeyValueXml(result);
|
|
427
|
-
|
|
428
|
-
elizaLogger.debug("Parsed content:", content);
|
|
429
|
-
|
|
430
|
-
// 5. Validate content
|
|
431
|
-
if (!isYourActionContent(runtime, content)) {
|
|
432
|
-
elizaLogger.error("Invalid content for YOUR_ACTION action.");
|
|
433
|
-
callback?.({
|
|
434
|
-
text: "Unable to process request. Invalid content provided.",
|
|
435
|
-
content: { error: "Invalid content" },
|
|
436
|
-
});
|
|
437
|
-
return false;
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
// 6. Execute your action logic
|
|
441
|
-
try {
|
|
442
|
-
// Your action implementation here
|
|
443
|
-
const result = await yourActionLogic(runtime, content);
|
|
444
|
-
|
|
445
|
-
callback?.({
|
|
446
|
-
text: `Success message with ${content.name}`,
|
|
447
|
-
content: result,
|
|
448
|
-
});
|
|
449
|
-
return true;
|
|
450
|
-
} catch (error) {
|
|
451
|
-
elizaLogger.error("Action failed:", error);
|
|
452
|
-
callback?.({
|
|
453
|
-
text: "Action failed. Please try again.",
|
|
454
|
-
content: { error: error.message },
|
|
455
|
-
});
|
|
456
|
-
return false;
|
|
457
|
-
}
|
|
458
|
-
},
|
|
459
|
-
```
|
|
460
|
-
|
|
461
|
-
### 6.8 Action Examples Structure
|
|
462
|
-
|
|
463
|
-
The action examples structure remains largely the same, but ensure they follow this pattern:
|
|
464
|
-
|
|
465
|
-
```typescript
|
|
466
|
-
examples: [
|
|
467
|
-
[
|
|
468
|
-
{
|
|
469
|
-
user: "{{name1}}", // Note: "user" instead of "name" for user messages
|
|
470
|
-
content: {
|
|
471
|
-
text: "User input text here",
|
|
472
|
-
},
|
|
473
|
-
},
|
|
474
|
-
{
|
|
475
|
-
name: "{{name2}}", // Agent response uses "name"
|
|
476
|
-
content: {
|
|
477
|
-
action: "YOUR_ACTION_NAME",
|
|
478
|
-
// Include the expected parsed fields
|
|
479
|
-
name: "Expected Name",
|
|
480
|
-
symbol: "Expected Symbol",
|
|
481
|
-
},
|
|
482
|
-
},
|
|
483
|
-
],
|
|
484
|
-
] as ActionExample[][],
|
|
485
|
-
```
|
|
486
|
-
|
|
487
|
-
### Important Migration Notes:
|
|
488
|
-
|
|
489
|
-
- Update templates to request XML format instead of JSON
|
|
490
|
-
- The `parseKeyValueXml` function parses XML responses into key-value objects
|
|
491
|
-
- Always include error handling and validation
|
|
492
|
-
- Use `elizaLogger` for debugging
|
|
493
|
-
- The callback pattern remains the same for success/error responses
|
|
494
|
-
- Model types have changed from `ModelClass` to `ModelType` enum
|
|
495
|
-
|
|
496
|
-
## Step 7: Migrate Providers
|
|
497
|
-
|
|
498
|
-
### 7.1 Provider Interface Changes
|
|
499
|
-
|
|
500
|
-
The Provider interface has been significantly enhanced with new required and optional properties:
|
|
501
|
-
|
|
502
|
-
```typescript
|
|
503
|
-
// OLD Provider Interface:
|
|
504
|
-
export interface Provider {
|
|
505
|
-
get: (runtime: IAgentRuntime, message: Memory, state?: State) => Promise<any>;
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
// NEW Provider Interface:
|
|
509
|
-
interface Provider {
|
|
510
|
-
name: string; // REQUIRED: Unique identifier for the provider
|
|
511
|
-
description?: string; // Optional: Description of what the provider does
|
|
512
|
-
dynamic?: boolean; // Optional: Whether the provider is dynamic
|
|
513
|
-
position?: number; // Optional: Position in provider list (+ or -)
|
|
514
|
-
private?: boolean; // Optional: Whether provider is private (not shown in list)
|
|
515
|
-
get: (
|
|
516
|
-
runtime: IAgentRuntime,
|
|
517
|
-
message: Memory,
|
|
518
|
-
state: State // Note: state is no longer optional
|
|
519
|
-
) => Promise<ProviderResult>; // Returns ProviderResult instead of any
|
|
520
|
-
}
|
|
521
|
-
```
|
|
522
|
-
|
|
523
|
-
### 7.2 ProviderResult Interface
|
|
524
|
-
|
|
525
|
-
The `get` method must now return a `ProviderResult` object instead of `any`:
|
|
526
|
-
|
|
527
|
-
```typescript
|
|
528
|
-
interface ProviderResult {
|
|
529
|
-
values?: {
|
|
530
|
-
[key: string]: any;
|
|
531
|
-
};
|
|
532
|
-
data?: {
|
|
533
|
-
[key: string]: any;
|
|
534
|
-
};
|
|
535
|
-
text?: string;
|
|
536
|
-
}
|
|
537
|
-
```
|
|
538
|
-
|
|
539
|
-
### 7.3 Migration Steps
|
|
540
|
-
|
|
541
|
-
#### Step 1: Add Required `name` Property
|
|
542
|
-
|
|
543
|
-
Every provider must have a unique `name` property:
|
|
544
|
-
|
|
545
|
-
```typescript
|
|
546
|
-
// OLD:
|
|
547
|
-
const myProvider: Provider = {
|
|
548
|
-
get: async (runtime, message, state) => {
|
|
549
|
-
// ...
|
|
550
|
-
},
|
|
551
|
-
};
|
|
552
|
-
|
|
553
|
-
// NEW:
|
|
554
|
-
const myProvider: Provider = {
|
|
555
|
-
name: 'myProvider', // REQUIRED
|
|
556
|
-
get: async (runtime, message, state) => {
|
|
557
|
-
// ...
|
|
558
|
-
},
|
|
559
|
-
};
|
|
560
|
-
```
|
|
561
|
-
|
|
562
|
-
#### Step 2: Update Return Type
|
|
563
|
-
|
|
564
|
-
Change your return statements to return a `ProviderResult` object:
|
|
565
|
-
|
|
566
|
-
```typescript
|
|
567
|
-
// OLD:
|
|
568
|
-
return 'Some text response';
|
|
569
|
-
// or
|
|
570
|
-
return { someData: 'value' };
|
|
571
|
-
|
|
572
|
-
// NEW:
|
|
573
|
-
return {
|
|
574
|
-
text: 'Some text response',
|
|
575
|
-
};
|
|
576
|
-
// or
|
|
577
|
-
return {
|
|
578
|
-
data: { someData: 'value' },
|
|
579
|
-
};
|
|
580
|
-
// or
|
|
581
|
-
return {
|
|
582
|
-
text: 'Some text',
|
|
583
|
-
values: { key1: 'value1' },
|
|
584
|
-
data: { complex: { nested: 'data' } },
|
|
585
|
-
};
|
|
586
|
-
```
|
|
587
|
-
|
|
588
|
-
#### Step 3: Handle Non-Optional State
|
|
589
|
-
|
|
590
|
-
The `state` parameter is no longer optional. Update your function signature:
|
|
591
|
-
|
|
592
|
-
```typescript
|
|
593
|
-
// OLD:
|
|
594
|
-
get: async (runtime, message, state?) => {
|
|
595
|
-
if (!state) {
|
|
596
|
-
// handle missing state
|
|
597
|
-
}
|
|
598
|
-
};
|
|
599
|
-
|
|
600
|
-
// NEW:
|
|
601
|
-
get: async (runtime, message, state) => {
|
|
602
|
-
// state is always provided
|
|
603
|
-
};
|
|
604
|
-
```
|
|
605
|
-
|
|
606
|
-
### 7.4 Complete Migration Examples
|
|
607
|
-
|
|
608
|
-
#### Example 1: Simple Text Provider
|
|
609
|
-
|
|
610
|
-
```typescript
|
|
611
|
-
// OLD Implementation:
|
|
612
|
-
const simpleProvider: Provider = {
|
|
613
|
-
get: async (runtime, message, state?) => {
|
|
614
|
-
return 'Hello from provider';
|
|
615
|
-
},
|
|
616
|
-
};
|
|
617
|
-
|
|
618
|
-
// NEW Implementation:
|
|
619
|
-
const simpleProvider: Provider = {
|
|
620
|
-
name: 'simpleProvider',
|
|
621
|
-
description: 'A simple text provider',
|
|
622
|
-
get: async (runtime, message, state) => {
|
|
623
|
-
return {
|
|
624
|
-
text: 'Hello from provider',
|
|
625
|
-
};
|
|
626
|
-
},
|
|
627
|
-
};
|
|
628
|
-
```
|
|
629
|
-
|
|
630
|
-
#### Example 2: Data Provider
|
|
631
|
-
|
|
632
|
-
```typescript
|
|
633
|
-
// OLD Implementation:
|
|
634
|
-
const dataProvider: Provider = {
|
|
635
|
-
get: async (runtime, message, state?) => {
|
|
636
|
-
const data = await fetchSomeData();
|
|
637
|
-
return data;
|
|
638
|
-
},
|
|
639
|
-
};
|
|
640
|
-
|
|
641
|
-
// NEW Implementation:
|
|
642
|
-
const dataProvider: Provider = {
|
|
643
|
-
name: 'dataProvider',
|
|
644
|
-
description: 'Fetches external data',
|
|
645
|
-
dynamic: true,
|
|
646
|
-
get: async (runtime, message, state) => {
|
|
647
|
-
const data = await fetchSomeData();
|
|
648
|
-
return {
|
|
649
|
-
data: data,
|
|
650
|
-
text: `Fetched ${Object.keys(data).length} items`,
|
|
651
|
-
};
|
|
652
|
-
},
|
|
653
|
-
};
|
|
654
|
-
```
|
|
655
|
-
|
|
656
|
-
#### Example 3: Complex Provider with All Options
|
|
657
|
-
|
|
658
|
-
```typescript
|
|
659
|
-
// NEW Implementation with all options:
|
|
660
|
-
const complexProvider: Provider = {
|
|
661
|
-
name: 'complexProvider',
|
|
662
|
-
description: 'A complex provider with all options',
|
|
663
|
-
dynamic: true,
|
|
664
|
-
position: 10, // Higher priority in provider list
|
|
665
|
-
private: false, // Shown in provider list
|
|
666
|
-
get: async (runtime, message, state) => {
|
|
667
|
-
elizaLogger.debug('complexProvider::get');
|
|
668
|
-
|
|
669
|
-
const values = {
|
|
670
|
-
timestamp: Date.now(),
|
|
671
|
-
userId: message.userId,
|
|
672
|
-
};
|
|
673
|
-
|
|
674
|
-
const data = await fetchComplexData();
|
|
675
|
-
|
|
676
|
-
const text = formatDataAsText(data);
|
|
677
|
-
|
|
678
|
-
return {
|
|
679
|
-
text,
|
|
680
|
-
values,
|
|
681
|
-
data,
|
|
682
|
-
};
|
|
683
|
-
},
|
|
684
|
-
};
|
|
685
|
-
```
|
|
686
|
-
|
|
687
|
-
### 7.5 Provider Options Explained
|
|
688
|
-
|
|
689
|
-
- **`name`** (required): Unique identifier used to reference the provider
|
|
690
|
-
- **`description`**: Human-readable description of what the provider does
|
|
691
|
-
- **`dynamic`**: Set to `true` if the provider returns different data based on context
|
|
692
|
-
- **`position`**: Controls ordering in provider lists (positive = higher priority)
|
|
693
|
-
- **`private`**: Set to `true` to hide from public provider lists (must be called explicitly)
|
|
694
|
-
|
|
695
|
-
### 7.6 Best Practices
|
|
696
|
-
|
|
697
|
-
1. **Always include descriptive names**: Use clear, descriptive names that indicate what the provider does
|
|
698
|
-
2. **Return appropriate result types**:
|
|
699
|
-
- Use `text` for human-readable responses
|
|
700
|
-
- Use `data` for structured data that other components might process
|
|
701
|
-
- Use `values` for simple key-value pairs that might be used in templates
|
|
702
|
-
3. **Add descriptions**: Help other developers understand your provider's purpose
|
|
703
|
-
4. **Use logging**: Include debug logs to help troubleshoot issues
|
|
704
|
-
5. **Handle errors gracefully**: Return meaningful error messages in the `text` field
|
|
705
|
-
|
|
706
|
-
### Important Provider Migration Notes:
|
|
707
|
-
|
|
708
|
-
- The `name` property is now required for all providers
|
|
709
|
-
- Return type must be `ProviderResult` object, not raw values
|
|
710
|
-
- The `state` parameter is no longer optional
|
|
711
|
-
- Consider adding optional properties (`description`, `dynamic`, etc.) for better documentation and behavior
|
|
712
|
-
- Test thoroughly as the runtime may handle providers differently based on these new properties
|