@elizaos/core 1.0.0-beta.32 → 1.0.0-beta.33
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/dist/database.d.ts +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +92 -21
- package/dist/runtime.d.ts +14 -1
- package/dist/types.d.ts +25 -2
- package/dist/utils.d.ts +1 -0
- package/package.json +2 -3
package/dist/database.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Agent, Component, Entity, IDatabaseAdapter, Log, Memory, Participant, Relationship, Room, Task, UUID, World
|
|
1
|
+
import type { Agent, Component, Entity, IDatabaseAdapter, Log, Memory, MemoryMetadata, Participant, Relationship, Room, Task, UUID, World } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* An abstract class representing a database adapter for managing various entities
|
|
4
4
|
* like entities, memories, entities, goals, and rooms.
|
|
@@ -379,7 +379,7 @@ export declare abstract class DatabaseAdapter<DB = unknown> implements IDatabase
|
|
|
379
379
|
* @param agent The agent object to ensure exists.
|
|
380
380
|
* @returns A Promise that resolves when the agent has been ensured to exist.
|
|
381
381
|
*/
|
|
382
|
-
abstract ensureAgentExists(agent: Partial<Agent>): Promise<
|
|
382
|
+
abstract ensureAgentExists(agent: Partial<Agent>): Promise<Agent>;
|
|
383
383
|
/**
|
|
384
384
|
* Ensures an embedding dimension exists in the database.
|
|
385
385
|
* @param dimension The dimension to ensure exists.
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -157,6 +157,7 @@ var SOCKET_MESSAGE_TYPE = /* @__PURE__ */ ((SOCKET_MESSAGE_TYPE2) => {
|
|
|
157
157
|
SOCKET_MESSAGE_TYPE2[SOCKET_MESSAGE_TYPE2["MESSAGE"] = 3] = "MESSAGE";
|
|
158
158
|
SOCKET_MESSAGE_TYPE2[SOCKET_MESSAGE_TYPE2["ACK"] = 4] = "ACK";
|
|
159
159
|
SOCKET_MESSAGE_TYPE2[SOCKET_MESSAGE_TYPE2["THINKING"] = 5] = "THINKING";
|
|
160
|
+
SOCKET_MESSAGE_TYPE2[SOCKET_MESSAGE_TYPE2["CONTROL"] = 6] = "CONTROL";
|
|
160
161
|
return SOCKET_MESSAGE_TYPE2;
|
|
161
162
|
})(SOCKET_MESSAGE_TYPE || {});
|
|
162
163
|
function createMessageMemory(params) {
|
|
@@ -1329,7 +1330,7 @@ var AgentRuntime = class {
|
|
|
1329
1330
|
this.plugins.push(plugin);
|
|
1330
1331
|
this.runtimeLogger.debug(`Success: Plugin ${plugin.name} registered successfully`);
|
|
1331
1332
|
}
|
|
1332
|
-
if (plugin.init) {
|
|
1333
|
+
if (plugin && "init" in plugin && plugin.init !== null && typeof plugin.init === "function") {
|
|
1333
1334
|
try {
|
|
1334
1335
|
await plugin.init(plugin.config || {}, this);
|
|
1335
1336
|
this.runtimeLogger.debug(`Success: Plugin ${plugin.name} initialized successfully`);
|
|
@@ -1349,6 +1350,11 @@ var AgentRuntime = class {
|
|
|
1349
1350
|
if (plugin.adapter) {
|
|
1350
1351
|
this.runtimeLogger.debug(`Registering database adapter for plugin ${plugin.name}`);
|
|
1351
1352
|
this.registerDatabaseAdapter(plugin.adapter);
|
|
1353
|
+
this.runtimeLogger.debug(
|
|
1354
|
+
`Database adapter registered successfully for plugin ${plugin.name}`
|
|
1355
|
+
);
|
|
1356
|
+
} else {
|
|
1357
|
+
this.runtimeLogger.debug(`Plugin ${plugin.name} does not provide a database adapter`);
|
|
1352
1358
|
}
|
|
1353
1359
|
if (plugin.actions) {
|
|
1354
1360
|
for (const action of plugin.actions) {
|
|
@@ -1415,37 +1421,41 @@ var AgentRuntime = class {
|
|
|
1415
1421
|
pluginRegistrationPromises.push(await this.registerPlugin(plugin));
|
|
1416
1422
|
}
|
|
1417
1423
|
}
|
|
1418
|
-
|
|
1424
|
+
if (!this.adapter) {
|
|
1425
|
+
this.runtimeLogger.error(
|
|
1426
|
+
"Database adapter not initialized. Make sure @elizaos/plugin-sql is included in your plugins."
|
|
1427
|
+
);
|
|
1428
|
+
throw new Error(
|
|
1429
|
+
"Database adapter not initialized. The SQL plugin (@elizaos/plugin-sql) is required for agent initialization. Please ensure it is included in your character configuration."
|
|
1430
|
+
);
|
|
1431
|
+
}
|
|
1419
1432
|
try {
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1433
|
+
await this.adapter.init();
|
|
1434
|
+
} catch (error) {
|
|
1435
|
+
this.runtimeLogger.error(
|
|
1436
|
+
`Failed to initialize database adapter: ${error instanceof Error ? error.message : String(error)}`
|
|
1437
|
+
);
|
|
1438
|
+
throw error;
|
|
1439
|
+
}
|
|
1440
|
+
try {
|
|
1441
|
+
const existingAgent = await this.adapter.ensureAgentExists(this.character);
|
|
1442
|
+
let agentEntity = await this.adapter.getEntityById(this.agentId);
|
|
1428
1443
|
if (!agentEntity) {
|
|
1429
1444
|
const created = await this.createEntity({
|
|
1430
1445
|
id: this.agentId,
|
|
1431
|
-
agentId:
|
|
1446
|
+
agentId: existingAgent.id,
|
|
1432
1447
|
names: Array.from(new Set([this.character.name].filter(Boolean))),
|
|
1433
1448
|
metadata: {}
|
|
1434
1449
|
});
|
|
1435
1450
|
if (!created) {
|
|
1436
1451
|
throw new Error(`Failed to create entity for agent ${this.agentId}`);
|
|
1437
1452
|
}
|
|
1453
|
+
agentEntity = await this.adapter.getEntityById(this.agentId);
|
|
1438
1454
|
this.runtimeLogger.debug(
|
|
1439
1455
|
`Success: Agent entity created successfully for ${this.character.name}`
|
|
1440
1456
|
);
|
|
1441
1457
|
}
|
|
1442
|
-
|
|
1443
|
-
this.runtimeLogger.error(
|
|
1444
|
-
`Failed to create agent entity: ${error instanceof Error ? error.message : String(error)}`
|
|
1445
|
-
);
|
|
1446
|
-
throw error;
|
|
1447
|
-
}
|
|
1448
|
-
try {
|
|
1458
|
+
if (!agentEntity) throw new Error(`Agent entity not found for ${this.agentId}`);
|
|
1449
1459
|
await Promise.all([
|
|
1450
1460
|
this.ensureRoomExists({
|
|
1451
1461
|
id: this.agentId,
|
|
@@ -2152,7 +2162,10 @@ ${newProvidersText}`;
|
|
|
2152
2162
|
if (!model) {
|
|
2153
2163
|
throw new Error(`No handler found for delegate type: ${modelKey}`);
|
|
2154
2164
|
}
|
|
2155
|
-
this.runtimeLogger.debug(
|
|
2165
|
+
this.runtimeLogger.debug(
|
|
2166
|
+
`[useModel] ${modelKey} input:`,
|
|
2167
|
+
JSON.stringify(params, safeReplacer(), 2)
|
|
2168
|
+
);
|
|
2156
2169
|
let paramsWithRuntime;
|
|
2157
2170
|
if (params === null || params === void 0 || typeof params !== "object" || Array.isArray(params) || typeof Buffer !== "undefined" && Buffer.isBuffer(params)) {
|
|
2158
2171
|
paramsWithRuntime = params;
|
|
@@ -2179,7 +2192,21 @@ ${newProvidersText}`;
|
|
|
2179
2192
|
body: {
|
|
2180
2193
|
modelType,
|
|
2181
2194
|
modelKey,
|
|
2182
|
-
params:
|
|
2195
|
+
params: (() => {
|
|
2196
|
+
if (params === null || params === void 0) {
|
|
2197
|
+
return null;
|
|
2198
|
+
}
|
|
2199
|
+
if (typeof Buffer !== "undefined" && Buffer.isBuffer(params)) {
|
|
2200
|
+
return `[Audio Buffer (${params.length} bytes)]`;
|
|
2201
|
+
}
|
|
2202
|
+
if (ArrayBuffer.isView(params)) {
|
|
2203
|
+
return `[Audio ${params.constructor.name} (${params.length})]`;
|
|
2204
|
+
}
|
|
2205
|
+
if (typeof params === "object") {
|
|
2206
|
+
return Object.keys(params);
|
|
2207
|
+
}
|
|
2208
|
+
return typeof params;
|
|
2209
|
+
})(),
|
|
2183
2210
|
response: Array.isArray(response) && response.every((x) => typeof x === "number") ? "[array]" : response
|
|
2184
2211
|
},
|
|
2185
2212
|
type: `useModel:${modelKey}`
|
|
@@ -2282,7 +2309,7 @@ ${newProvidersText}`;
|
|
|
2282
2309
|
return await this.adapter.deleteAgent(agentId);
|
|
2283
2310
|
}
|
|
2284
2311
|
async ensureAgentExists(agent) {
|
|
2285
|
-
await this.adapter.ensureAgentExists(agent);
|
|
2312
|
+
return await this.adapter.ensureAgentExists(agent);
|
|
2286
2313
|
}
|
|
2287
2314
|
async getEntityById(entityId) {
|
|
2288
2315
|
return await this.adapter.getEntityById(entityId);
|
|
@@ -2485,6 +2512,35 @@ ${newProvidersText}`;
|
|
|
2485
2512
|
handler(data);
|
|
2486
2513
|
}
|
|
2487
2514
|
}
|
|
2515
|
+
/**
|
|
2516
|
+
* Sends a control message to the frontend to enable or disable input
|
|
2517
|
+
* @param {Object} params - Parameters for the control message
|
|
2518
|
+
* @param {UUID} params.roomId - The ID of the room to send the control message to
|
|
2519
|
+
* @param {'enable_input' | 'disable_input'} params.action - The action to perform
|
|
2520
|
+
* @param {string} [params.target] - Optional target element identifier
|
|
2521
|
+
* @returns {Promise<void>}
|
|
2522
|
+
*/
|
|
2523
|
+
async sendControlMessage(params) {
|
|
2524
|
+
try {
|
|
2525
|
+
const { roomId, action, target } = params;
|
|
2526
|
+
const controlMessage = {
|
|
2527
|
+
type: "control",
|
|
2528
|
+
payload: {
|
|
2529
|
+
action,
|
|
2530
|
+
target
|
|
2531
|
+
},
|
|
2532
|
+
roomId
|
|
2533
|
+
};
|
|
2534
|
+
await this.emitEvent("CONTROL_MESSAGE", {
|
|
2535
|
+
runtime: this,
|
|
2536
|
+
message: controlMessage,
|
|
2537
|
+
source: "agent"
|
|
2538
|
+
});
|
|
2539
|
+
this.runtimeLogger.debug(`Sent control message: ${action} to room ${roomId}`);
|
|
2540
|
+
} catch (error) {
|
|
2541
|
+
this.runtimeLogger.error(`Error sending control message: ${error}`);
|
|
2542
|
+
}
|
|
2543
|
+
}
|
|
2488
2544
|
};
|
|
2489
2545
|
|
|
2490
2546
|
// src/settings.ts
|
|
@@ -2750,6 +2806,20 @@ function prependWavHeader(readable, audioLength, sampleRate, channelCount = 1, b
|
|
|
2750
2806
|
});
|
|
2751
2807
|
return passThrough;
|
|
2752
2808
|
}
|
|
2809
|
+
|
|
2810
|
+
// src/utils.ts
|
|
2811
|
+
function safeReplacer() {
|
|
2812
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
2813
|
+
return function(key, value) {
|
|
2814
|
+
if (typeof value === "object" && value !== null) {
|
|
2815
|
+
if (seen.has(value)) {
|
|
2816
|
+
return "[Circular]";
|
|
2817
|
+
}
|
|
2818
|
+
seen.add(value);
|
|
2819
|
+
}
|
|
2820
|
+
return value;
|
|
2821
|
+
};
|
|
2822
|
+
}
|
|
2753
2823
|
export {
|
|
2754
2824
|
AgentRuntime,
|
|
2755
2825
|
AgentStatus,
|
|
@@ -2828,6 +2898,7 @@ export {
|
|
|
2828
2898
|
postCreationTemplate,
|
|
2829
2899
|
prependWavHeader,
|
|
2830
2900
|
providersTemplate,
|
|
2901
|
+
safeReplacer,
|
|
2831
2902
|
saltSettingValue,
|
|
2832
2903
|
saltWorldSettings,
|
|
2833
2904
|
shouldRespondTemplate,
|
package/dist/runtime.d.ts
CHANGED
|
@@ -199,7 +199,7 @@ export declare class AgentRuntime implements IAgentRuntime {
|
|
|
199
199
|
createAgent(agent: Partial<Agent>): Promise<boolean>;
|
|
200
200
|
updateAgent(agentId: UUID, agent: Partial<Agent>): Promise<boolean>;
|
|
201
201
|
deleteAgent(agentId: UUID): Promise<boolean>;
|
|
202
|
-
ensureAgentExists(agent: Partial<Agent>): Promise<
|
|
202
|
+
ensureAgentExists(agent: Partial<Agent>): Promise<Agent>;
|
|
203
203
|
getEntityById(entityId: UUID): Promise<Entity | null>;
|
|
204
204
|
getEntitiesForRoom(roomId: UUID, includeComponents?: boolean): Promise<Entity[]>;
|
|
205
205
|
createEntity(entity: Entity): Promise<boolean>;
|
|
@@ -315,4 +315,17 @@ export declare class AgentRuntime implements IAgentRuntime {
|
|
|
315
315
|
on(event: string, callback: (data: any) => void): void;
|
|
316
316
|
off(event: string, callback: (data: any) => void): void;
|
|
317
317
|
emit(event: string, data: any): void;
|
|
318
|
+
/**
|
|
319
|
+
* Sends a control message to the frontend to enable or disable input
|
|
320
|
+
* @param {Object} params - Parameters for the control message
|
|
321
|
+
* @param {UUID} params.roomId - The ID of the room to send the control message to
|
|
322
|
+
* @param {'enable_input' | 'disable_input'} params.action - The action to perform
|
|
323
|
+
* @param {string} [params.target] - Optional target element identifier
|
|
324
|
+
* @returns {Promise<void>}
|
|
325
|
+
*/
|
|
326
|
+
sendControlMessage(params: {
|
|
327
|
+
roomId: UUID;
|
|
328
|
+
action: 'enable_input' | 'disable_input';
|
|
329
|
+
target?: string;
|
|
330
|
+
}): Promise<void>;
|
|
318
331
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -501,6 +501,9 @@ export interface Character {
|
|
|
501
501
|
knowledge?: (string | {
|
|
502
502
|
path: string;
|
|
503
503
|
shared?: boolean;
|
|
504
|
+
} | {
|
|
505
|
+
directory: string;
|
|
506
|
+
shared?: boolean;
|
|
504
507
|
})[];
|
|
505
508
|
/** Available plugins */
|
|
506
509
|
plugins?: string[];
|
|
@@ -545,7 +548,7 @@ export interface IDatabaseAdapter {
|
|
|
545
548
|
createAgent(agent: Partial<Agent>): Promise<boolean>;
|
|
546
549
|
updateAgent(agentId: UUID, agent: Partial<Agent>): Promise<boolean>;
|
|
547
550
|
deleteAgent(agentId: UUID): Promise<boolean>;
|
|
548
|
-
ensureAgentExists(agent: Partial<Agent>): Promise<
|
|
551
|
+
ensureAgentExists(agent: Partial<Agent>): Promise<Agent>;
|
|
549
552
|
ensureEmbeddingDimension(dimension: number): Promise<void>;
|
|
550
553
|
/** Get entity by ID */
|
|
551
554
|
getEntityById(entityId: UUID): Promise<Entity | null>;
|
|
@@ -1338,7 +1341,8 @@ export declare enum SOCKET_MESSAGE_TYPE {
|
|
|
1338
1341
|
SEND_MESSAGE = 2,
|
|
1339
1342
|
MESSAGE = 3,
|
|
1340
1343
|
ACK = 4,
|
|
1341
|
-
THINKING = 5
|
|
1344
|
+
THINKING = 5,
|
|
1345
|
+
CONTROL = 6
|
|
1342
1346
|
}
|
|
1343
1347
|
/**
|
|
1344
1348
|
* Specialized memory type for messages with enhanced type checking
|
|
@@ -1496,3 +1500,22 @@ export declare const VECTOR_DIMS: {
|
|
|
1496
1500
|
readonly XXL: 1536;
|
|
1497
1501
|
readonly XXXL: 3072;
|
|
1498
1502
|
};
|
|
1503
|
+
/**
|
|
1504
|
+
* Interface for control messages sent from the backend to the frontend
|
|
1505
|
+
* to manage UI state and interaction capabilities
|
|
1506
|
+
*/
|
|
1507
|
+
export interface ControlMessage {
|
|
1508
|
+
/** Message type identifier */
|
|
1509
|
+
type: 'control';
|
|
1510
|
+
/** Control message payload */
|
|
1511
|
+
payload: {
|
|
1512
|
+
/** Action to perform */
|
|
1513
|
+
action: 'disable_input' | 'enable_input';
|
|
1514
|
+
/** Optional target element identifier */
|
|
1515
|
+
target?: string;
|
|
1516
|
+
/** Additional optional parameters */
|
|
1517
|
+
[key: string]: unknown;
|
|
1518
|
+
};
|
|
1519
|
+
/** Room ID to ensure signal is directed to the correct chat window */
|
|
1520
|
+
roomId: UUID;
|
|
1521
|
+
}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function safeReplacer(): (key: string, value: any) => any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elizaos/core",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.33",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -58,7 +58,6 @@
|
|
|
58
58
|
"typescript": "5.8.2"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@types/hapi__shot": "^6.0.0",
|
|
62
61
|
"buffer": "^6.0.3",
|
|
63
62
|
"crypto-browserify": "^3.12.1",
|
|
64
63
|
"dotenv": "16.4.5",
|
|
@@ -76,5 +75,5 @@
|
|
|
76
75
|
"publishConfig": {
|
|
77
76
|
"access": "public"
|
|
78
77
|
},
|
|
79
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "9da6c2edde9ccc19112c6aa5b028810fb8d2da54"
|
|
80
79
|
}
|