@elizaos/core 1.0.0-alpha.57 → 1.0.0-alpha.59
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/bootstrap.d.ts +12 -1
- package/dist/database.d.ts +21 -4
- package/dist/index.d.ts +0 -1
- package/dist/index.js +543 -591
- package/dist/logger.d.ts +2 -1
- package/dist/prompts.d.ts +1 -0
- package/dist/runtime.d.ts +31 -16
- package/dist/services/task.d.ts +3 -3
- package/dist/types.d.ts +337 -116
- package/package.json +2 -2
- package/dist/index.js.map +0 -1
- package/dist/memory.d.ts +0 -114
package/dist/logger.d.ts
CHANGED
package/dist/prompts.d.ts
CHANGED
|
@@ -113,6 +113,7 @@ export declare const formatMessages: ({ messages, entities, }: {
|
|
|
113
113
|
export declare const formatTimestamp: (messageDate: number) => string;
|
|
114
114
|
export 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.";
|
|
115
115
|
export 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.";
|
|
116
|
+
export declare const postCreationTemplate = "# Task: Create a post in the voice and style and perspective of {{agentName}} @{{twitterUserName}}.\n\nExample task outputs:\n1. A post about the importance of AI in our lives\n```json\n{ \"thought\": \"I am thinking about writing a post about the importance of AI in our lives\", \"post\": \"AI is changing the world and it is important to understand how it works\", \"imagePrompt\": \"A futuristic cityscape with flying cars and people using AI to do things\" }\n```\n\n2. A post about dogs\n```json\n{ \"thought\": \"I am thinking about writing a post about dogs\", \"post\": \"Dogs are man's best friend and they are loyal and loving\", \"imagePrompt\": \"A dog playing with a ball in a park\" }\n```\n\n3. A post about finding a new job\n```json\n{ \"thought\": \"Getting a job is hard, I bet there's a good tweet in that\", \"post\": \"Just keep going!\", \"imagePrompt\": \"A person looking at a computer screen with a job search website\" }\n```\n\n{{providers}}\n\nWrite a post that is {{adjective}} about {{topic}} (without mentioning {{topic}} directly), from the perspective of {{agentName}}. Do not add commentary or acknowledge this request, just write the post.\nYour response should be 1, 2, or 3 sentences (choose the length at random).\nYour response should not contain any questions. Brief, concise statements only. The total character count MUST be less than 280. No emojis. Use \\n\\n (double spaces) between statements if there are multiple statements in your response.\n\nYour output should be formatted in a valid JSON block like this:\n```json\n{ \"thought\": \"<string>\", \"post\": \"<string>\", \"imagePrompt\": \"<string>\" }\n```\nThe \"post\" field should be the post you want to send. Do not including any thinking or internal reflection in the \"post\" field.\nThe \"imagePrompt\" field is optional and should be a prompt for an image that is relevant to the post. It should be a single sentence that captures the essence of the post. ONLY USE THIS FIELD if it makes sense that the post would benefit from an image.\nThe \"thought\" field should be a short description of what the agent is thinking about before responding, inlcuding a brief justification for the response. Includate an explanation how the post is relevant to the topic but unique and different than other posts.\nYour reponse should ONLY contain a valid JSON block and nothing else.";
|
|
116
117
|
export declare const booleanFooter = "Respond with only a YES or a NO.";
|
|
117
118
|
/**
|
|
118
119
|
* Parses a string to determine its boolean equivalent.
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ChannelType } from "./types";
|
|
2
|
+
import type { Action, Agent, Character, Component, Entity, Evaluator, HandlerCallback, IAgentRuntime, IDatabaseAdapter, KnowledgeItem, Log, Memory, ModelParamsMap, ModelResultMap, ModelTypeName, Participant, Plugin, Provider, Relationship, Room, Route, Service, ServiceTypeName, State, Task, TaskWorker, UUID, World } from "./types";
|
|
3
|
+
export declare class Semaphore {
|
|
4
|
+
private permits;
|
|
5
|
+
private waiting;
|
|
6
|
+
constructor(count: number);
|
|
7
|
+
acquire(): Promise<void>;
|
|
8
|
+
release(): void;
|
|
9
|
+
}
|
|
2
10
|
/**
|
|
3
11
|
* Represents the runtime environment for an agent, handling message processing,
|
|
4
12
|
* action registration, and interaction with external services like OpenAI and Supabase.
|
|
@@ -10,7 +18,7 @@ import { type Action, type Agent, ChannelType, type Character, type Component, t
|
|
|
10
18
|
* @property { number } #conversationLength - The maximum length of a conversation.
|
|
11
19
|
* @property { UUID } agentId - The unique identifier for the agent.
|
|
12
20
|
* @property { Character } character - The character associated with the agent.
|
|
13
|
-
* @property { IDatabaseAdapter }
|
|
21
|
+
* @property { IDatabaseAdapter } adapter - The adapter for interacting with the database.
|
|
14
22
|
* @property {Action[]} actions - The list of actions available to the agent.
|
|
15
23
|
* @property {Evaluator[]} evaluators - The list of evaluators for decision making.
|
|
16
24
|
* @property {Provider[]} providers - The list of providers for external services.
|
|
@@ -20,7 +28,7 @@ export declare class AgentRuntime implements IAgentRuntime {
|
|
|
20
28
|
#private;
|
|
21
29
|
readonly agentId: UUID;
|
|
22
30
|
readonly character: Character;
|
|
23
|
-
|
|
31
|
+
adapter: IDatabaseAdapter;
|
|
24
32
|
readonly actions: Action[];
|
|
25
33
|
readonly evaluators: Evaluator[];
|
|
26
34
|
readonly providers: Provider[];
|
|
@@ -36,20 +44,19 @@ export declare class AgentRuntime implements IAgentRuntime {
|
|
|
36
44
|
text: string;
|
|
37
45
|
}>;
|
|
38
46
|
readonly fetch: typeof fetch;
|
|
39
|
-
services: Map<
|
|
40
|
-
|
|
41
|
-
private readonly knowledgeRoot;
|
|
42
|
-
models: Map<string, ((params: any) => Promise<any>)[]>;
|
|
47
|
+
services: Map<ServiceTypeName, Service>;
|
|
48
|
+
models: Map<string, ((runtime: IAgentRuntime, params: any) => Promise<any>)[]>;
|
|
43
49
|
routes: Route[];
|
|
44
50
|
private taskWorkers;
|
|
45
51
|
private eventHandlers;
|
|
52
|
+
private runtimeLogger;
|
|
53
|
+
private knowledgeProcessingSemaphore;
|
|
46
54
|
constructor(opts: {
|
|
47
55
|
conversationLength?: number;
|
|
48
56
|
agentId?: UUID;
|
|
49
57
|
character?: Character;
|
|
50
58
|
plugins?: Plugin[];
|
|
51
59
|
fetch?: typeof fetch;
|
|
52
|
-
databaseAdapter?: IDatabaseAdapter;
|
|
53
60
|
adapter?: IDatabaseAdapter;
|
|
54
61
|
events?: {
|
|
55
62
|
[key: string]: ((params: any) => void)[];
|
|
@@ -61,7 +68,7 @@ export declare class AgentRuntime implements IAgentRuntime {
|
|
|
61
68
|
* @param plugin The plugin to register
|
|
62
69
|
*/
|
|
63
70
|
registerPlugin(plugin: Plugin): Promise<void>;
|
|
64
|
-
getAllServices(): Map<
|
|
71
|
+
getAllServices(): Map<ServiceTypeName, Service>;
|
|
65
72
|
stop(): Promise<void>;
|
|
66
73
|
initialize(): Promise<void>;
|
|
67
74
|
private handleProcessingError;
|
|
@@ -151,11 +158,10 @@ export declare class AgentRuntime implements IAgentRuntime {
|
|
|
151
158
|
*/
|
|
152
159
|
composeState(message: Memory, filterList?: string[] | null, // only get providers that are in the filterList
|
|
153
160
|
includeList?: string[] | null): Promise<State>;
|
|
154
|
-
|
|
155
|
-
getService<T extends Service>(service: ServiceType): T | null;
|
|
161
|
+
getService<T extends Service>(service: ServiceTypeName): T | null;
|
|
156
162
|
registerService(service: typeof Service): Promise<void>;
|
|
157
|
-
registerModel(modelType:
|
|
158
|
-
getModel(modelType:
|
|
163
|
+
registerModel(modelType: ModelTypeName, handler: (params: any) => Promise<any>): void;
|
|
164
|
+
getModel(modelType: ModelTypeName): ((runtime: IAgentRuntime, params: any) => Promise<any>) | undefined;
|
|
159
165
|
/**
|
|
160
166
|
* Use a model with strongly typed parameters and return values based on model type
|
|
161
167
|
* @template T - The model type to use
|
|
@@ -164,7 +170,7 @@ export declare class AgentRuntime implements IAgentRuntime {
|
|
|
164
170
|
* @param {ModelParamsMap[T] | any} params - The parameters for the model, typed based on model type
|
|
165
171
|
* @returns {Promise<R>} - The model result, typed based on the provided generic type parameter
|
|
166
172
|
*/
|
|
167
|
-
useModel<T extends
|
|
173
|
+
useModel<T extends ModelTypeName, R = ModelResultMap[T]>(modelType: T, params: Omit<ModelParamsMap[T], "runtime"> | any): Promise<R>;
|
|
168
174
|
registerEvent(event: string, handler: (params: any) => Promise<void>): void;
|
|
169
175
|
getEvent(event: string): ((params: any) => Promise<void>)[] | undefined;
|
|
170
176
|
emitEvent(event: string | string[], params: any): Promise<void>;
|
|
@@ -192,6 +198,7 @@ export declare class AgentRuntime implements IAgentRuntime {
|
|
|
192
198
|
createComponent(component: Component): Promise<boolean>;
|
|
193
199
|
updateComponent(component: Component): Promise<void>;
|
|
194
200
|
deleteComponent(componentId: UUID): Promise<void>;
|
|
201
|
+
addEmbeddingToMemory(memory: Memory): Promise<Memory>;
|
|
195
202
|
getMemories(params: {
|
|
196
203
|
roomId: UUID;
|
|
197
204
|
count?: number;
|
|
@@ -235,9 +242,17 @@ export declare class AgentRuntime implements IAgentRuntime {
|
|
|
235
242
|
tableName: string;
|
|
236
243
|
}): Promise<Memory[]>;
|
|
237
244
|
createMemory(memory: Memory, tableName: string, unique?: boolean): Promise<UUID>;
|
|
238
|
-
|
|
239
|
-
|
|
245
|
+
deleteMemory(memoryId: UUID): Promise<void>;
|
|
246
|
+
deleteAllMemories(roomId: UUID, tableName: string): Promise<void>;
|
|
240
247
|
countMemories(roomId: UUID, unique?: boolean, tableName?: string): Promise<number>;
|
|
248
|
+
getLogs(params: {
|
|
249
|
+
entityId: UUID;
|
|
250
|
+
roomId?: UUID;
|
|
251
|
+
type?: string;
|
|
252
|
+
count?: number;
|
|
253
|
+
offset?: number;
|
|
254
|
+
}): Promise<Log[]>;
|
|
255
|
+
deleteLog(logId: UUID): Promise<void>;
|
|
241
256
|
createWorld(world: World): Promise<UUID>;
|
|
242
257
|
getWorld(id: UUID): Promise<World | null>;
|
|
243
258
|
getAllWorlds(): Promise<World[]>;
|
package/dist/services/task.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { type IAgentRuntime, Service, type
|
|
1
|
+
import { type IAgentRuntime, Service, type ServiceTypeName } from "../types";
|
|
2
2
|
/**
|
|
3
3
|
* TaskService class representing a service that schedules and executes tasks.
|
|
4
4
|
* @extends Service
|
|
5
5
|
* @property {NodeJS.Timeout|null} timer - Timer for executing tasks
|
|
6
6
|
* @property {number} TICK_INTERVAL - Interval in milliseconds to check for tasks
|
|
7
|
-
* @property {
|
|
7
|
+
* @property {ServiceTypeName} serviceType - Service type of TASK
|
|
8
8
|
* @property {string} capabilityDescription - Description of the service's capability
|
|
9
9
|
* @static
|
|
10
10
|
* @method start - Static method to start the TaskService
|
|
@@ -20,7 +20,7 @@ import { type IAgentRuntime, Service, type ServiceType } from "../types";
|
|
|
20
20
|
export declare class TaskService extends Service {
|
|
21
21
|
private timer;
|
|
22
22
|
private readonly TICK_INTERVAL;
|
|
23
|
-
static serviceType:
|
|
23
|
+
static serviceType: ServiceTypeName;
|
|
24
24
|
capabilityDescription: string;
|
|
25
25
|
/**
|
|
26
26
|
* Start the TaskService with the given runtime.
|