@elizaos/rust 2.0.0-alpha.10 → 2.0.0-alpha.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elizaos/rust",
3
- "version": "2.0.0-alpha.10",
3
+ "version": "2.0.0-alpha.13",
4
4
  "description": "elizaOS Core - Rust runtime and types",
5
5
  "type": "module",
6
6
  "main": "pkg/node/elizaos.js",
@@ -25,7 +25,7 @@
25
25
  "build": "./build.sh",
26
26
  "build:native": "cargo build --release",
27
27
  "build:wasm": "wasm-pack build --target web --out-dir pkg/web --no-default-features --features wasm && wasm-pack build --target nodejs --out-dir pkg/node --no-default-features --features wasm",
28
- "test": "cargo test && (bun run test:wasm || echo '[WARN] WASM tests skipped - requires wasm-pack build')",
28
+ "test": "cargo test",
29
29
  "lint": "cargo clippy --lib --features native --fix --allow-dirty --allow-staged -- -D warnings && cargo fmt",
30
30
  "lint:fix": "cargo clippy --all-targets --all-features --fix --allow-dirty",
31
31
  "typecheck": "cargo check --lib --features native",
@@ -42,5 +42,5 @@
42
42
  "publishConfig": {
43
43
  "access": "public"
44
44
  },
45
- "gitHead": "658f659feda0e65899d9b0e8aa17ff9445dd715a"
45
+ "gitHead": "9448dcfc32d38873e1e2596d4ff4eca444fadca0"
46
46
  }
package/pkg/node/LICENSE DELETED
@@ -1,26 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Shaw Walters and elizaOS Contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
22
-
23
-
24
-
25
-
26
-
@@ -1,151 +0,0 @@
1
- # elizaOS Core - Rust Implementation
2
-
3
- This is the Rust implementation of the elizaOS core runtime. It provides a fully compatible implementation that can be compiled to both native binaries and WebAssembly.
4
-
5
- ## Features
6
-
7
- - **Full Type Compatibility**: All types serialize to JSON in a format identical to the TypeScript implementation
8
- - **Native Performance**: Compile to native code for maximum performance
9
- - **WASM Support**: Compile to WebAssembly for browser and Node.js environments
10
- - **Character Loading**: Parse and validate character files matching TypeScript behavior
11
- - **Plugin System**: Load, validate, and resolve plugin dependencies
12
- - **Agent Runtime**: Core runtime for elizaOS agents
13
-
14
- ## Runtime Settings (cross-language parity)
15
-
16
- These settings are read by the runtime/message loop to keep behavior aligned with the TypeScript and Python implementations:
17
-
18
- - `ALLOW_NO_DATABASE`: when truthy, allow running without a persistent database adapter (benchmarks/tests).
19
- - `USE_MULTI_STEP`: when truthy, enable the iterative multi-step workflow.
20
- - `MAX_MULTISTEP_ITERATIONS`: maximum iterations for multi-step mode (default: `6`).
21
-
22
- ### Benchmark & Trajectory Tracing
23
-
24
- Benchmarks and harnesses can attach metadata to inbound messages (stored under `Memory.metadata` as custom JSON):
25
-
26
- - `trajectoryStepId`: enables trajectory tracing for provider access + model calls.
27
- - `benchmarkContext`: enables the `CONTEXT_BENCH` provider and sets `state.values["benchmark_has_context"]=true`, which forces action-based execution to exercise the full loop.
28
-
29
- ## Model output contract (XML preferred, plain text tolerated)
30
-
31
- The canonical message loop expects model outputs in the `<response>...</response>` XML format (with `<actions>`, `<providers>`, and `<text>` fields).
32
-
33
- Some deterministic/offline backends may return **plain text** instead. In that case, the runtime will treat the raw output as a simple **`REPLY`** so the system remains usable even when strict XML formatting is unavailable.
34
-
35
- ## Building
36
-
37
- ### Prerequisites
38
-
39
- - Rust 1.70 or later
40
- - wasm-pack (for WASM builds)
41
-
42
- ### Native Build
43
-
44
- ```bash
45
- cargo build --release
46
- ```
47
-
48
- ### WASM Build
49
-
50
- ```bash
51
- # For web browsers
52
- wasm-pack build --target web --out-dir pkg/web --features wasm
53
-
54
- # For Node.js
55
- wasm-pack build --target nodejs --out-dir pkg/node --features wasm
56
- ```
57
-
58
- ### Build Script
59
-
60
- ```bash
61
- ./build.sh
62
- ```
63
-
64
- ## Testing
65
-
66
- ```bash
67
- cargo test
68
- ```
69
-
70
- ## Usage
71
-
72
- ### Rust (Native)
73
-
74
- ```rust
75
- use elizaos::{AgentRuntime, Character, parse_character};
76
-
77
- #[tokio::main]
78
- async fn main() -> anyhow::Result<()> {
79
- let json = r#"{"name": "TestAgent", "bio": "A test agent"}"#;
80
- let character = parse_character(json)?;
81
-
82
- let runtime = AgentRuntime::new(RuntimeOptions {
83
- character: Some(character),
84
- ..Default::default()
85
- }).await?;
86
-
87
- runtime.initialize().await?;
88
-
89
- Ok(())
90
- }
91
- ```
92
-
93
- ### JavaScript (WASM)
94
-
95
- ```javascript
96
- import init, {
97
- WasmAgentRuntime,
98
- parse_character,
99
- validate_character,
100
- } from "@elizaos/core/rust";
101
-
102
- // Initialize WASM module
103
- await init();
104
-
105
- // Create a runtime
106
- const runtime = await new WasmAgentRuntime(
107
- '{"name": "TestAgent", "bio": "A test agent"}',
108
- );
109
- await runtime.initialize();
110
-
111
- console.log(`Agent ID: ${runtime.agent_id}`);
112
- console.log(`Character: ${runtime.character_name}`);
113
- ```
114
-
115
- ## Architecture
116
-
117
- ```
118
- src/
119
- ├── lib.rs # Library entry point
120
- ├── types/ # Core type definitions
121
- │ ├── mod.rs # Type module exports
122
- │ ├── primitives.rs # UUID, Content, etc.
123
- │ ├── memory.rs # Memory types
124
- │ ├── agent.rs # Character, Agent types
125
- │ ├── plugin.rs # Plugin types
126
- │ ├── components.rs # Action, Provider, Evaluator
127
- │ ├── environment.rs # Entity, Room, World
128
- │ ├── events.rs # Event system types
129
- │ ├── database.rs # Database types
130
- │ ├── model.rs # Model types
131
- │ ├── service.rs # Service types
132
- │ ├── state.rs # State types
133
- │ └── ...
134
- ├── character.rs # Character parsing/validation
135
- ├── plugin.rs # Plugin loading/resolution
136
- ├── runtime.rs # AgentRuntime implementation
137
- └── wasm.rs # WASM bindings
138
- ```
139
-
140
- ## Compatibility
141
-
142
- This implementation is designed to be 100% compatible with the TypeScript version:
143
-
144
- - **JSON Serialization**: All types use `#[serde(rename_all = "camelCase")]` to match TypeScript
145
- - **UUID Format**: UUIDs are validated and stored in lowercase format
146
- - **Character Files**: Existing character files work without modification
147
- - **Plugin Loading**: Plugins are resolved using the same dependency algorithm
148
-
149
- ## License
150
-
151
- MIT
@@ -1,304 +0,0 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
-
4
- export class JsModelHandler {
5
- free(): void;
6
- [Symbol.dispose](): void;
7
- /**
8
- * Creates a new JsModelHandler from a JavaScript object.
9
- */
10
- constructor(js_object: object);
11
- /**
12
- * Calls the handler with the given parameters.
13
- */
14
- handle(params_json: string): Promise<any>;
15
- /**
16
- * Returns the underlying JavaScript object.
17
- */
18
- readonly jsObject: object;
19
- }
20
-
21
- export class WasmAgent {
22
- private constructor();
23
- free(): void;
24
- [Symbol.dispose](): void;
25
- /**
26
- * Convert to JSON
27
- */
28
- toJson(): string;
29
- /**
30
- * Create a new agent from JSON
31
- */
32
- static fromJson(json: string): WasmAgent;
33
- /**
34
- * Get the agent ID
35
- */
36
- readonly id: string | undefined;
37
- /**
38
- * Get the agent name
39
- */
40
- readonly name: string;
41
- }
42
-
43
- export class WasmAgentRuntime {
44
- private constructor();
45
- free(): void;
46
- [Symbol.dispose](): void;
47
- /**
48
- * Initialize the runtime.
49
- */
50
- initialize(): void;
51
- /**
52
- * Handle an incoming message
53
- */
54
- handleMessage(message_json: string): Promise<any>;
55
- /**
56
- * Register a model handler using the shim.
57
- */
58
- registerModelHandler(model_type: string, handler: JsModelHandler): void;
59
- /**
60
- * Register a model handler from a raw JavaScript function.
61
- */
62
- registerModelHandlerFn(model_type: string, handler: Function): void;
63
- /**
64
- * Stop the runtime
65
- */
66
- stop(): void;
67
- /**
68
- * Create a new WasmAgentRuntime from a character JSON string
69
- *
70
- * This creates the runtime wrapper but does not initialize it.
71
- */
72
- static create(character_json: string): WasmAgentRuntime;
73
- /**
74
- * Get the character name
75
- */
76
- readonly characterName: string;
77
- /**
78
- * Check if the runtime has been initialized.
79
- */
80
- readonly isInitialized: boolean;
81
- /**
82
- * Get the agent ID
83
- */
84
- readonly agentId: string;
85
- /**
86
- * Get the character as JSON
87
- */
88
- readonly character: string;
89
- }
90
-
91
- export class WasmCharacter {
92
- private constructor();
93
- free(): void;
94
- [Symbol.dispose](): void;
95
- /**
96
- * Convert to JSON
97
- */
98
- toJson(): string;
99
- /**
100
- * Create a new character from JSON
101
- */
102
- static fromJson(json: string): WasmCharacter;
103
- /**
104
- * Get the bio
105
- */
106
- readonly bio: string;
107
- /**
108
- * Get the character name
109
- */
110
- readonly name: string;
111
- /**
112
- * Get the system prompt
113
- */
114
- readonly system: string | undefined;
115
- /**
116
- * Get topics as JSON array
117
- */
118
- readonly topics: string;
119
- }
120
-
121
- export class WasmEntity {
122
- private constructor();
123
- free(): void;
124
- [Symbol.dispose](): void;
125
- /**
126
- * Convert to JSON
127
- */
128
- toJson(): string;
129
- /**
130
- * Create a new entity from JSON
131
- */
132
- static fromJson(json: string): WasmEntity;
133
- /**
134
- * Get the entity ID
135
- */
136
- readonly id: string | undefined;
137
- }
138
-
139
- export class WasmError {
140
- private constructor();
141
- free(): void;
142
- [Symbol.dispose](): void;
143
- /**
144
- * Returns a formatted string representation of the error.
145
- */
146
- toString(): string;
147
- /**
148
- * Returns the error code for programmatic error handling.
149
- */
150
- readonly code: string;
151
- /**
152
- * Returns the source of the error (parameter name, field, etc.), if available.
153
- */
154
- readonly source: string | undefined;
155
- /**
156
- * Returns the human-readable error message.
157
- */
158
- readonly message: string;
159
- }
160
-
161
- export class WasmMemory {
162
- private constructor();
163
- free(): void;
164
- [Symbol.dispose](): void;
165
- /**
166
- * Convert to JSON
167
- */
168
- toJson(): string;
169
- /**
170
- * Create a new memory from JSON
171
- */
172
- static fromJson(json: string): WasmMemory;
173
- /**
174
- * Get created_at timestamp
175
- */
176
- readonly createdAt: number | undefined;
177
- /**
178
- * Get the memory ID
179
- */
180
- readonly id: string | undefined;
181
- /**
182
- * Check if memory is unique
183
- */
184
- readonly unique: boolean;
185
- /**
186
- * Get the content as JSON
187
- */
188
- readonly content: string;
189
- /**
190
- * Get the room ID
191
- */
192
- readonly roomId: string;
193
- /**
194
- * Get the entity ID
195
- */
196
- readonly entityId: string;
197
- }
198
-
199
- export class WasmPlugin {
200
- private constructor();
201
- free(): void;
202
- [Symbol.dispose](): void;
203
- /**
204
- * Convert to JSON (only definition is serialized)
205
- */
206
- toJson(): string;
207
- /**
208
- * Create a new plugin from JSON (only definition is serialized)
209
- */
210
- static fromJson(json: string): WasmPlugin;
211
- /**
212
- * Get the plugin description
213
- */
214
- readonly description: string | undefined;
215
- /**
216
- * Get the plugin name
217
- */
218
- readonly name: string;
219
- }
220
-
221
- export class WasmRoom {
222
- private constructor();
223
- free(): void;
224
- [Symbol.dispose](): void;
225
- /**
226
- * Convert to JSON
227
- */
228
- toJson(): string;
229
- /**
230
- * Create a new room from JSON
231
- */
232
- static fromJson(json: string): WasmRoom;
233
- /**
234
- * Get the room ID
235
- */
236
- readonly id: string;
237
- }
238
-
239
- export class WasmUUID {
240
- free(): void;
241
- [Symbol.dispose](): void;
242
- /**
243
- * Create a UUID from a string
244
- */
245
- static fromString(s: string): WasmUUID;
246
- /**
247
- * Convert to string
248
- */
249
- toString(): string;
250
- /**
251
- * Create a new random UUID
252
- */
253
- constructor();
254
- }
255
-
256
- /**
257
- * Generate a new UUID
258
- */
259
- export function generateUUID(): string;
260
-
261
- /**
262
- * Get the version of the elizaOS core
263
- */
264
- export function getVersion(): string;
265
-
266
- /**
267
- * Initialize the WASM module with panic hook for better error messages
268
- */
269
- export function init_wasm(): void;
270
-
271
- /**
272
- * Parse a character JSON string and validate it
273
- */
274
- export function parseCharacter(json: string): WasmCharacter;
275
-
276
- /**
277
- * Parse a memory JSON string
278
- */
279
- export function parseMemory(json: string): WasmMemory;
280
-
281
- /**
282
- * Convert a string to a deterministic UUID (similar to stringToUuid in TS)
283
- */
284
- export function stringToUuid(input: string): string;
285
-
286
- /**
287
- * Test serialization round-trip for Agent
288
- */
289
- export function testAgentRoundTrip(json: string): boolean;
290
-
291
- /**
292
- * Test serialization round-trip for Character
293
- */
294
- export function testCharacterRoundTrip(json: string): boolean;
295
-
296
- /**
297
- * Test serialization round-trip for Memory
298
- */
299
- export function testMemoryRoundTrip(json: string): boolean;
300
-
301
- /**
302
- * Validate a UUID string
303
- */
304
- export function validateUUID(uuid_str: string): boolean;