@elizaos/core 1.0.0-alpha.5 → 1.0.0-alpha.7
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/index.d.ts +106 -9
- package/dist/index.js +1152 -749
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,10 @@ import * as pino from 'pino';
|
|
|
4
4
|
/**
|
|
5
5
|
* Represents a UUID string in the format "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
|
6
6
|
*/
|
|
7
|
+
/**
|
|
8
|
+
* Type definition for a Universally Unique Identifier (UUID) using a specific format.
|
|
9
|
+
* @typedef {`${string}-${string}-${string}-${string}-${string}`} UUID
|
|
10
|
+
*/
|
|
7
11
|
type UUID = `${string}-${string}-${string}-${string}-${string}`;
|
|
8
12
|
/**
|
|
9
13
|
* Represents the content of a message or communication
|
|
@@ -429,9 +433,10 @@ declare abstract class Service {
|
|
|
429
433
|
static stop(_runtime: IAgentRuntime): Promise<unknown>;
|
|
430
434
|
}
|
|
431
435
|
type Route = {
|
|
432
|
-
type: "GET" | "POST" | "PUT" | "DELETE";
|
|
436
|
+
type: "GET" | "POST" | "PUT" | "DELETE" | "STATIC";
|
|
433
437
|
path: string;
|
|
434
|
-
|
|
438
|
+
filePath?: string;
|
|
439
|
+
handler?: (req: any, res: any, runtime: IAgentRuntime) => Promise<void>;
|
|
435
440
|
};
|
|
436
441
|
/**
|
|
437
442
|
* Plugin for extending agent functionality
|
|
@@ -453,7 +458,7 @@ interface Plugin {
|
|
|
453
458
|
actions?: Action[];
|
|
454
459
|
providers?: Provider[];
|
|
455
460
|
evaluators?: Evaluator[];
|
|
456
|
-
|
|
461
|
+
adapter?: IDatabaseAdapter;
|
|
457
462
|
models?: {
|
|
458
463
|
[key: string]: (...args: any[]) => Promise<any>;
|
|
459
464
|
};
|
|
@@ -761,7 +766,6 @@ interface IAgentRuntime {
|
|
|
761
766
|
getAllServices(): Map<ServiceType, Service>;
|
|
762
767
|
registerService(service: typeof Service): void;
|
|
763
768
|
registerDatabaseAdapter(adapter: IDatabaseAdapter): void;
|
|
764
|
-
getDatabaseAdapters(): IDatabaseAdapter[];
|
|
765
769
|
getDatabaseAdapter(): IDatabaseAdapter | null;
|
|
766
770
|
setSetting(key: string, value: string | boolean | null | any, secret: boolean): void;
|
|
767
771
|
getSetting(key: string): string | boolean | null | any;
|
|
@@ -957,7 +961,7 @@ interface TaskWorker {
|
|
|
957
961
|
name: string;
|
|
958
962
|
execute: (runtime: IAgentRuntime, options: {
|
|
959
963
|
[key: string]: unknown;
|
|
960
|
-
}) => Promise<void>;
|
|
964
|
+
}, task: Task) => Promise<void>;
|
|
961
965
|
validate?: (runtime: IAgentRuntime, message: Memory, state: State) => Promise<boolean>;
|
|
962
966
|
}
|
|
963
967
|
interface Task {
|
|
@@ -1013,6 +1017,13 @@ interface OnboardingConfig {
|
|
|
1013
1017
|
* @param count - The number of examples to generate.
|
|
1014
1018
|
* @returns A string containing formatted examples of conversations.
|
|
1015
1019
|
*/
|
|
1020
|
+
/**
|
|
1021
|
+
* Compose a specified number of random action examples from the given actionsData.
|
|
1022
|
+
*
|
|
1023
|
+
* @param {Action[]} actionsData - The list of actions to generate examples from.
|
|
1024
|
+
* @param {number} count - The number of examples to compose.
|
|
1025
|
+
* @returns {string} The formatted action examples.
|
|
1026
|
+
*/
|
|
1016
1027
|
declare const composeActionExamples: (actionsData: Action[], count: number) => string;
|
|
1017
1028
|
/**
|
|
1018
1029
|
* Formats the names of the provided actions into a comma-separated string.
|
|
@@ -1031,6 +1042,13 @@ declare function formatActions(actions: Action[]): string;
|
|
|
1031
1042
|
* An abstract class representing a database adapter for managing various entities
|
|
1032
1043
|
* like entities, memories, entities, goals, and rooms.
|
|
1033
1044
|
*/
|
|
1045
|
+
/**
|
|
1046
|
+
* Database adapter class to be extended by individual database adapters.
|
|
1047
|
+
*
|
|
1048
|
+
* @template DB - The type of the database instance.
|
|
1049
|
+
* @abstract
|
|
1050
|
+
* @implements {IDatabaseAdapter}
|
|
1051
|
+
*/
|
|
1034
1052
|
declare abstract class DatabaseAdapter<DB = unknown> implements IDatabaseAdapter {
|
|
1035
1053
|
/**
|
|
1036
1054
|
* The database instance.
|
|
@@ -1483,16 +1501,42 @@ declare abstract class DatabaseAdapter<DB = unknown> implements IDatabaseAdapter
|
|
|
1483
1501
|
abstract deleteTask(id: UUID): Promise<void>;
|
|
1484
1502
|
}
|
|
1485
1503
|
|
|
1504
|
+
/**
|
|
1505
|
+
* Finds an entity by name in the given runtime environment.
|
|
1506
|
+
*
|
|
1507
|
+
* @param {IAgentRuntime} runtime - The agent runtime environment.
|
|
1508
|
+
* @param {Memory} message - The memory message containing relevant information.
|
|
1509
|
+
* @param {State} state - The current state of the system.
|
|
1510
|
+
* @returns {Promise<Entity | null>} A promise that resolves to the found entity or null if not found.
|
|
1511
|
+
*/
|
|
1486
1512
|
declare function findEntityByName(runtime: IAgentRuntime, message: Memory, state: State): Promise<Entity | null>;
|
|
1513
|
+
/**
|
|
1514
|
+
* Function to create a unique UUID based on the runtime and base user ID.
|
|
1515
|
+
*
|
|
1516
|
+
* @param {RuntimeContext} runtime - The runtime context object.
|
|
1517
|
+
* @param {UUID|string} baseUserId - The base user ID to use in generating the UUID.
|
|
1518
|
+
* @returns {UUID} - The unique UUID generated based on the runtime and base user ID.
|
|
1519
|
+
*/
|
|
1487
1520
|
declare const createUniqueUuid: (runtime: any, baseUserId: UUID | string) => UUID;
|
|
1488
1521
|
/**
|
|
1489
1522
|
* Get details for a list of entities.
|
|
1490
1523
|
*/
|
|
1524
|
+
/**
|
|
1525
|
+
* Retrieves entity details for a specific room from the database.
|
|
1526
|
+
*
|
|
1527
|
+
* @param {Object} params - The input parameters
|
|
1528
|
+
* @param {IAgentRuntime} params.runtime - The Agent Runtime instance
|
|
1529
|
+
* @param {UUID} params.roomId - The ID of the room to retrieve entity details for
|
|
1530
|
+
* @returns {Promise<Array>} - A promise that resolves to an array of unique entity details
|
|
1531
|
+
*/
|
|
1491
1532
|
declare function getEntityDetails({ runtime, roomId, }: {
|
|
1492
1533
|
runtime: IAgentRuntime;
|
|
1493
1534
|
roomId: UUID;
|
|
1494
1535
|
}): Promise<any[]>;
|
|
1495
1536
|
|
|
1537
|
+
/**
|
|
1538
|
+
* Interface for settings object with key-value pairs.
|
|
1539
|
+
*/
|
|
1496
1540
|
interface Settings {
|
|
1497
1541
|
[key: string]: string | undefined;
|
|
1498
1542
|
}
|
|
@@ -1894,6 +1938,12 @@ declare function validateCharacterConfig(json: unknown): CharacterConfig;
|
|
|
1894
1938
|
|
|
1895
1939
|
declare const dynamicImport: (specifier: string) => Promise<any>;
|
|
1896
1940
|
declare const registerDynamicImport: (specifier: string, module: any) => void;
|
|
1941
|
+
/**
|
|
1942
|
+
* Handles importing of plugins asynchronously.
|
|
1943
|
+
*
|
|
1944
|
+
* @param {string[]} plugins - An array of strings representing the plugins to import.
|
|
1945
|
+
* @returns {Promise<Function[]>} - A Promise that resolves to an array of imported plugins functions.
|
|
1946
|
+
*/
|
|
1897
1947
|
declare function handlePluginImporting(plugins: string[]): Promise<any[]>;
|
|
1898
1948
|
|
|
1899
1949
|
declare const logger: pino.Logger<string, boolean>;
|
|
@@ -1902,6 +1952,9 @@ declare const elizaLogger: pino.Logger<string, boolean>;
|
|
|
1902
1952
|
/**
|
|
1903
1953
|
* Manage memories in the database.
|
|
1904
1954
|
*/
|
|
1955
|
+
/**
|
|
1956
|
+
* The AgentRuntime instance associated with this manager.
|
|
1957
|
+
*/
|
|
1905
1958
|
declare class MemoryManager implements IMemoryManager {
|
|
1906
1959
|
/**
|
|
1907
1960
|
* The AgentRuntime instance associated with this manager.
|
|
@@ -2038,6 +2091,14 @@ declare class MemoryManager implements IMemoryManager {
|
|
|
2038
2091
|
* };
|
|
2039
2092
|
* const contextSimple = composePrompt({ state, template });
|
|
2040
2093
|
*/
|
|
2094
|
+
/**
|
|
2095
|
+
* Function to compose a prompt using a provided template and state.
|
|
2096
|
+
*
|
|
2097
|
+
* @param {Object} options - Object containing state and template information.
|
|
2098
|
+
* @param {State} options.state - The state object containing values to fill the template.
|
|
2099
|
+
* @param {TemplateType} options.template - The template to be used for composing the prompt.
|
|
2100
|
+
* @returns {string} The composed prompt output.
|
|
2101
|
+
*/
|
|
2041
2102
|
declare const composePrompt: ({ state, template, }: {
|
|
2042
2103
|
state: State;
|
|
2043
2104
|
template: TemplateType;
|
|
@@ -2100,7 +2161,7 @@ declare const formatMessages: ({ messages, entities, }: {
|
|
|
2100
2161
|
entities: Entity[];
|
|
2101
2162
|
}) => string;
|
|
2102
2163
|
declare const formatTimestamp: (messageDate: number) => string;
|
|
2103
|
-
declare const shouldRespondTemplate = "# Task: Decide on behalf of {{agentName}} whether they should respond to the message, ignore it or stop the conversation.\n{{providers}}\n# Instructions: Decide if {{agentName}} should respond to or interact with the conversation.\nIf the message is directed at or relevant to {{agentName}}, respond with RESPOND action.\nIf a user asks {{agentName}} to be quiet, respond with STOP action.\nIf {{agentName}} should ignore the message, respond with IGNORE action.\nIf responding with the RESPOND action, include a list of optional providers that could be relevant to the response.\nResponse format should be formatted in a valid JSON block like this:\n```json\n{\n \"name\": \"{{agentName}}\",\n \"action\": \"RESPOND\" | \"IGNORE\" | \"STOP\",\n \"providers\": [\"<string>\", \"<string>\", ...]\n}\n```\nYour response should include the valid JSON block and nothing else.";
|
|
2164
|
+
declare const shouldRespondTemplate = "# Task: Decide on behalf of {{agentName}} whether they should respond to the message, ignore it or stop the conversation.\n{{providers}}\n# Instructions: Decide if {{agentName}} should respond to or interact with the conversation.\nIf the message is directed at or relevant to {{agentName}}, respond with RESPOND action.\nIf a user asks {{agentName}} to be quiet, respond with STOP action.\nIf {{agentName}} should ignore the message, respond with IGNORE action.\nIf responding with the RESPOND action, include a list of optional providers that could be relevant to the response.\nResponse format should be formatted in a valid JSON block like this:\n```json\n{\n \"name\": \"{{agentName}}\",\n\t\"reasoning\": \"<string>\",\n \"action\": \"RESPOND\" | \"IGNORE\" | \"STOP\",\n \"providers\": [\"<string>\", \"<string>\", ...]\n}\n```\nYour response should include the valid JSON block and nothing else.";
|
|
2104
2165
|
declare const messageHandlerTemplate = "# Task: Generate dialog and actions for the character {{agentName}}.\n{{providers}}\n# Instructions: Write a thought and plan for {{agentName}} and decide what actions to take. Also include the providers that {{agentName}} will use to have the right context for responding and acting, if any.\nFirst, think about what you want to do next and plan your actions. Then, write the next message and include the actions you plan to take.\n\"thought\" should be a short description of what the agent is thinking about and planning.\n\"actions\" should be an array of the actions {{agentName}} plans to take based on the thought (if none, use IGNORE, if simply responding with text, use REPLY)\n\"providers\" should be an optional array of the providers that {{agentName}} will use to have the right context for responding and acting\n\"evaluators\" should be an optional array of the evaluators that {{agentName}} will use to evaluate the conversation after responding\n\"plan\" should be explanation of the message you plan to send, the actions you plan to take, and the data providers you plan to use.\nThese are the available valid actions: {{actionNames}}\n\nResponse format should be formatted in a valid JSON block like this:\n```json\n{\n \"thought\": \"<string>\",\n \"plan\": \"<string>\",\n \"actions\": [\"<string>\", \"<string>\", ...],\n \"providers\": [\"<string>\", \"<string>\", ...]\n}\n```\n\nYour response should include the valid JSON block and nothing else.";
|
|
2105
2166
|
declare const booleanFooter = "Respond with only a YES or a NO.";
|
|
2106
2167
|
/**
|
|
@@ -2187,6 +2248,9 @@ declare function splitChunks(content: string, chunkSize?: number, bleed?: number
|
|
|
2187
2248
|
*/
|
|
2188
2249
|
declare function trimTokens(prompt: string, maxTokens: number, runtime: IAgentRuntime): Promise<any>;
|
|
2189
2250
|
|
|
2251
|
+
/**
|
|
2252
|
+
* Represents the state of server ownership, including a mapping of server IDs to their respective World objects.
|
|
2253
|
+
*/
|
|
2190
2254
|
interface ServerOwnershipState {
|
|
2191
2255
|
servers: {
|
|
2192
2256
|
[serverId: string]: World;
|
|
@@ -2195,6 +2259,14 @@ interface ServerOwnershipState {
|
|
|
2195
2259
|
/**
|
|
2196
2260
|
* Gets a user's role from world metadata
|
|
2197
2261
|
*/
|
|
2262
|
+
/**
|
|
2263
|
+
* Retrieve the server role of a specified user entity within a given server.
|
|
2264
|
+
*
|
|
2265
|
+
* @param {IAgentRuntime} runtime - The runtime object containing necessary configurations and services.
|
|
2266
|
+
* @param {string} entityId - The unique identifier of the user entity.
|
|
2267
|
+
* @param {string} serverId - The unique identifier of the server.
|
|
2268
|
+
* @returns {Promise<Role>} The role of the user entity within the server, resolved as a Promise.
|
|
2269
|
+
*/
|
|
2198
2270
|
declare function getUserServerRole(runtime: IAgentRuntime, entityId: string, serverId: string): Promise<Role>;
|
|
2199
2271
|
/**
|
|
2200
2272
|
* Finds a server where the given user is the owner
|
|
@@ -2205,6 +2277,19 @@ declare function findWorldForOwner(runtime: IAgentRuntime, entityId: string): Pr
|
|
|
2205
2277
|
* Represents the runtime environment for an agent, handling message processing,
|
|
2206
2278
|
* action registration, and interaction with external services like OpenAI and Supabase.
|
|
2207
2279
|
*/
|
|
2280
|
+
/**
|
|
2281
|
+
* Represents the runtime environment for an agent.
|
|
2282
|
+
* @class
|
|
2283
|
+
* @implements { IAgentRuntime }
|
|
2284
|
+
* @property { number } #conversationLength - The maximum length of a conversation.
|
|
2285
|
+
* @property { UUID } agentId - The unique identifier for the agent.
|
|
2286
|
+
* @property { Character } character - The character associated with the agent.
|
|
2287
|
+
* @property { IDatabaseAdapter } databaseAdapter - The adapter for interacting with the database.
|
|
2288
|
+
* @property {Action[]} actions - The list of actions available to the agent.
|
|
2289
|
+
* @property {Evaluator[]} evaluators - The list of evaluators for decision making.
|
|
2290
|
+
* @property {Provider[]} providers - The list of providers for external services.
|
|
2291
|
+
* @property {Plugin[]} plugins - The list of plugins to extend functionality.
|
|
2292
|
+
*/
|
|
2208
2293
|
declare class AgentRuntime implements IAgentRuntime {
|
|
2209
2294
|
#private;
|
|
2210
2295
|
readonly agentId: UUID;
|
|
@@ -2226,7 +2311,7 @@ declare class AgentRuntime implements IAgentRuntime {
|
|
|
2226
2311
|
}>;
|
|
2227
2312
|
readonly fetch: typeof fetch;
|
|
2228
2313
|
services: Map<ServiceType, Service>;
|
|
2229
|
-
|
|
2314
|
+
adapter: IDatabaseAdapter;
|
|
2230
2315
|
private readonly knowledgeRoot;
|
|
2231
2316
|
models: Map<string, ((params: any) => Promise<any>)[]>;
|
|
2232
2317
|
routes: Route[];
|
|
@@ -2238,7 +2323,7 @@ declare class AgentRuntime implements IAgentRuntime {
|
|
|
2238
2323
|
plugins?: Plugin[];
|
|
2239
2324
|
fetch?: typeof fetch;
|
|
2240
2325
|
databaseAdapter?: IDatabaseAdapter;
|
|
2241
|
-
|
|
2326
|
+
adapter?: IDatabaseAdapter;
|
|
2242
2327
|
events?: {
|
|
2243
2328
|
[key: string]: ((params: any) => void)[];
|
|
2244
2329
|
};
|
|
@@ -2269,7 +2354,6 @@ declare class AgentRuntime implements IAgentRuntime {
|
|
|
2269
2354
|
*/
|
|
2270
2355
|
getConversationLength(): number;
|
|
2271
2356
|
registerDatabaseAdapter(adapter: IDatabaseAdapter): void;
|
|
2272
|
-
getDatabaseAdapters(): IDatabaseAdapter[];
|
|
2273
2357
|
getDatabaseAdapter(): IDatabaseAdapter;
|
|
2274
2358
|
/**
|
|
2275
2359
|
* Register a provider for the agent to use.
|
|
@@ -2369,7 +2453,20 @@ declare function getWorldSettings(runtime: IAgentRuntime, serverId: string): Pro
|
|
|
2369
2453
|
declare function initializeOnboarding(runtime: IAgentRuntime, world: World, config: OnboardingConfig): Promise<WorldSettings | null>;
|
|
2370
2454
|
|
|
2371
2455
|
declare const uuidSchema: z.ZodType<UUID>;
|
|
2456
|
+
/**
|
|
2457
|
+
* Validates a UUID value.
|
|
2458
|
+
*
|
|
2459
|
+
* @param {unknown} value - The value to validate.
|
|
2460
|
+
* @returns {UUID | null} Returns the validated UUID value or null if validation fails.
|
|
2461
|
+
*/
|
|
2372
2462
|
declare function validateUuid(value: unknown): UUID | null;
|
|
2463
|
+
/**
|
|
2464
|
+
* Converts a string or number to a UUID.
|
|
2465
|
+
*
|
|
2466
|
+
* @param {string | number} target - The string or number to convert to a UUID.
|
|
2467
|
+
* @returns {UUID} The UUID generated from the input target.
|
|
2468
|
+
* @throws {TypeError} Throws an error if the input target is not a string.
|
|
2469
|
+
*/
|
|
2373
2470
|
declare function stringToUuid(target: string | number): UUID;
|
|
2374
2471
|
|
|
2375
2472
|
export { type Action, type ActionExample, type Agent, AgentRuntime, type BaseMetadata, CacheKeyPrefix, type CacheOptions, ChannelType, type Character, type CharacterConfig, CharacterSchema, type ChunkRow, type Component, type Content, type ConversationExample, type CustomMetadata, DatabaseAdapter, type DeriveKeyAttestationData, type DescriptionMetadata, type DetokenizeTextParams, type DirectoryItem, type DocumentMetadata, type Entity, type EvaluationExample, type Evaluator, type FragmentMetadata, type GenerateTextParams, type Goal, GoalStatus, type Handler, type HandlerCallback, type IAgentRuntime, type IBrowserService, type IDatabaseAdapter, type IFileService, type IMemoryManager, type IPdfService, type ITeeLogService, type IVideoService, type KnowledgeItem, KnowledgeScope, type Media, type Memory, MemoryManager, type MemoryMetadata, MemoryType, type MemoryTypeAlias, type MessageExample, MessageExampleSchema, type MessageMetadata, type ModelConfiguration, type ModelType, ModelTypes, type Objective, type OnboardingConfig, type Participant, type Plugin, PluginSchema, type Project, type ProjectAgent, type Provider, type ProviderResult, type Relationship, type RemoteAttestationMessage, type RemoteAttestationQuote, Role, type Room, type Route, type ServerOwnershipState, Service, type ServiceType, ServiceTypes, type Setting, type SgxAttestation, type State, TEEMode, type Task, type TaskWorker, type TeeAgent, type TeeLog, TeeLogDAO, type TeeLogQuery, type TeePageQuery, type TeePluginConfig, TeeType, type TeeVendorConfig, type TemplateType, type TestCase, type TestSuite, type TokenizeTextParams, type UUID, type Validator, type World, type WorldSettings, addHeader, booleanFooter, cleanJsonResponse, composeActionExamples, composePrompt, composeRandomUser, configureSettings, createUniqueUuid, dynamicImport, elizaLogger, extractAttributes, findEntityByName, findNearestEnvFile, findWorldForOwner, formatActionNames, formatActions, formatMessages, formatPosts, formatTimestamp, getEntityDetails, getEnvVariable, getUserServerRole, getWorldSettings, handlePluginImporting, hasEnvVariable, initializeOnboarding, loadEnvConfig, logger, messageHandlerTemplate, normalizeJsonString, parseActionResponseFromText, parseBooleanFromText, parseJSONObjectFromText, parseJsonArrayFromText, postActionResponseFooter, registerDynamicImport, settings, shouldRespondTemplate, splitChunks, stringArrayFooter, stringToUuid, trimTokens, truncateToCompleteSentence, updateWorldSettings, uuidSchema, validateCharacterConfig, validateUuid };
|