@elizaos/core 1.0.0-beta.6 → 1.0.0-beta.61
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/LICENSE +1 -1
- package/dist/actions.d.ts +2 -8
- package/dist/database.d.ts +27 -9
- package/dist/index.d.ts +5 -3
- package/dist/index.js +32959 -7083
- package/dist/instrumentation/index.d.ts +2 -0
- package/dist/instrumentation/service.d.ts +20 -0
- package/dist/instrumentation/types.d.ts +16 -0
- package/dist/prompts.d.ts +3 -200
- package/dist/roles.d.ts +5 -1
- package/dist/runtime.d.ts +95 -44
- package/dist/search.d.ts +316 -0
- package/dist/sentry/instrument.d.ts +2 -0
- package/dist/settings.d.ts +79 -1
- package/dist/types.d.ts +502 -78
- package/dist/utils.d.ts +231 -0
- package/package.json +18 -4
- package/dist/actions/choice.d.ts +0 -13
- package/dist/actions/followRoom.d.ts +0 -20
- package/dist/actions/ignore.d.ts +0 -13
- package/dist/actions/muteRoom.d.ts +0 -22
- package/dist/actions/none.d.ts +0 -9
- package/dist/actions/reply.d.ts +0 -15
- package/dist/actions/roles.d.ts +0 -13
- package/dist/actions/sendMessage.d.ts +0 -14
- package/dist/actions/settings.d.ts +0 -21
- package/dist/actions/unfollowRoom.d.ts +0 -12
- package/dist/actions/unmuteRoom.d.ts +0 -18
- package/dist/actions/updateEntity.d.ts +0 -42
- package/dist/bootstrap.d.ts +0 -14
- package/dist/evaluators/reflection.d.ts +0 -2
- package/dist/import.d.ts +0 -9
- package/dist/providers/actions.d.ts +0 -14
- package/dist/providers/anxiety.d.ts +0 -9
- package/dist/providers/attachments.d.ts +0 -8
- package/dist/providers/capabilities.d.ts +0 -13
- package/dist/providers/character.d.ts +0 -9
- package/dist/providers/choice.d.ts +0 -10
- package/dist/providers/entities.d.ts +0 -2
- package/dist/providers/evaluators.d.ts +0 -26
- package/dist/providers/facts.d.ts +0 -10
- package/dist/providers/knowledge.d.ts +0 -13
- package/dist/providers/providers.d.ts +0 -6
- package/dist/providers/recentMessages.d.ts +0 -13
- package/dist/providers/relationships.d.ts +0 -14
- package/dist/providers/roles.d.ts +0 -14
- package/dist/providers/settings.d.ts +0 -6
- package/dist/providers/shouldRespond.d.ts +0 -6
- package/dist/providers/time.d.ts +0 -11
- package/dist/services/index.d.ts +0 -1
- package/dist/services/scenario.d.ts +0 -106
- package/dist/services/task.d.ts +0 -72
- package/dist/services/websocket.d.ts +0 -73
- package/dist/uuid.d.ts +0 -18
package/dist/types.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Pool as PgPool } from 'pg';
|
|
2
|
+
import { PGlite } from '@electric-sql/pglite';
|
|
2
3
|
/**
|
|
3
4
|
* Type definition for a Universally Unique Identifier (UUID) using a specific format.
|
|
4
5
|
* @typedef {`${string}-${string}-${string}-${string}-${string}`} UUID
|
|
5
6
|
*/
|
|
7
|
+
/**
|
|
8
|
+
* Defines a custom type UUID representing a universally unique identifier
|
|
9
|
+
*/
|
|
6
10
|
export type UUID = `${string}-${string}-${string}-${string}-${string}`;
|
|
7
11
|
/**
|
|
8
12
|
* Helper function to safely cast a string to strongly typed UUID
|
|
@@ -47,7 +51,14 @@ export interface ActionExample {
|
|
|
47
51
|
}
|
|
48
52
|
export type ModelTypeName = (typeof ModelType)[keyof typeof ModelType] | string;
|
|
49
53
|
/**
|
|
50
|
-
*
|
|
54
|
+
* Defines the recognized types of models that the agent runtime can use.
|
|
55
|
+
* These include models for text generation (small, large, reasoning, completion),
|
|
56
|
+
* text embedding, tokenization (encode/decode), image generation and description,
|
|
57
|
+
* audio transcription, text-to-speech, and generic object generation.
|
|
58
|
+
* This constant is used throughout the system, particularly in `AgentRuntime.useModel`,
|
|
59
|
+
* `AgentRuntime.registerModel`, and in `ModelParamsMap` / `ModelResultMap` to ensure
|
|
60
|
+
* type safety and clarity when working with different AI models.
|
|
61
|
+
* String values are used for extensibility with custom model types.
|
|
51
62
|
*/
|
|
52
63
|
export declare const ModelType: {
|
|
53
64
|
readonly SMALL: "TEXT_SMALL";
|
|
@@ -71,6 +82,14 @@ export declare const ModelType: {
|
|
|
71
82
|
readonly OBJECT_LARGE: "OBJECT_LARGE";
|
|
72
83
|
};
|
|
73
84
|
export type ServiceTypeName = (typeof ServiceType)[keyof typeof ServiceType];
|
|
85
|
+
/**
|
|
86
|
+
* Enumerates the recognized types of services that can be registered and used by the agent runtime.
|
|
87
|
+
* Services provide specialized functionalities like audio transcription, video processing,
|
|
88
|
+
* web browsing, PDF handling, file storage (e.g., AWS S3), web search, email integration,
|
|
89
|
+
* secure execution via TEE (Trusted Execution Environment), task management, and instrumentation.
|
|
90
|
+
* This constant is used in `AgentRuntime` for service registration and retrieval (e.g., `getService`).
|
|
91
|
+
* Each service typically implements the `Service` abstract class or a more specific interface like `IVideoService`.
|
|
92
|
+
*/
|
|
74
93
|
export declare const ServiceType: {
|
|
75
94
|
readonly TRANSCRIPTION: "transcription";
|
|
76
95
|
readonly VIDEO: "video";
|
|
@@ -81,9 +100,17 @@ export declare const ServiceType: {
|
|
|
81
100
|
readonly EMAIL: "email";
|
|
82
101
|
readonly TEE: "tee";
|
|
83
102
|
readonly TASK: "task";
|
|
103
|
+
readonly INSTRUMENTATION: "instrumentation";
|
|
84
104
|
};
|
|
85
105
|
/**
|
|
86
|
-
* Represents the current state
|
|
106
|
+
* Represents the current state or context of a conversation or agent interaction.
|
|
107
|
+
* This interface is a flexible container for various pieces of information that define the agent's
|
|
108
|
+
* understanding at a point in time. It includes:
|
|
109
|
+
* - `values`: A key-value store for general state variables, often populated by providers.
|
|
110
|
+
* - `data`: Another key-value store, potentially for more structured or internal data.
|
|
111
|
+
* - `text`: A string representation of the current context, often a summary or concatenated history.
|
|
112
|
+
* The `[key: string]: any;` allows for dynamic properties, though `EnhancedState` offers better typing.
|
|
113
|
+
* This state object is passed to handlers for actions, evaluators, and providers.
|
|
87
114
|
*/
|
|
88
115
|
export interface State {
|
|
89
116
|
/** Additional dynamic properties */
|
|
@@ -100,6 +127,15 @@ export interface State {
|
|
|
100
127
|
* Memory type enumeration for built-in memory types
|
|
101
128
|
*/
|
|
102
129
|
export type MemoryTypeAlias = string;
|
|
130
|
+
/**
|
|
131
|
+
* Enumerates the built-in types of memories that can be stored and retrieved.
|
|
132
|
+
* - `DOCUMENT`: Represents a whole document or a large piece of text.
|
|
133
|
+
* - `FRAGMENT`: A chunk or segment of a `DOCUMENT`, often created for embedding and search.
|
|
134
|
+
* - `MESSAGE`: A conversational message, typically from a user or the agent.
|
|
135
|
+
* - `DESCRIPTION`: A descriptive piece of information, perhaps about an entity or concept.
|
|
136
|
+
* - `CUSTOM`: For any other type of memory not covered by the built-in types.
|
|
137
|
+
* This enum is used in `MemoryMetadata` to categorize memories and influences how they are processed or queried.
|
|
138
|
+
*/
|
|
103
139
|
export declare enum MemoryType {
|
|
104
140
|
DOCUMENT = "document",
|
|
105
141
|
FRAGMENT = "fragment",
|
|
@@ -107,9 +143,24 @@ export declare enum MemoryType {
|
|
|
107
143
|
DESCRIPTION = "description",
|
|
108
144
|
CUSTOM = "custom"
|
|
109
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* Defines the scope of a memory, indicating its visibility and accessibility.
|
|
148
|
+
* - `shared`: The memory is accessible to multiple entities or across different contexts (e.g., a public fact).
|
|
149
|
+
* - `private`: The memory is specific to a single entity or a private context (e.g., a user's personal preference).
|
|
150
|
+
* - `room`: The memory is scoped to a specific room or channel.
|
|
151
|
+
* This is used in `MemoryMetadata` to control how memories are stored and retrieved based on context.
|
|
152
|
+
*/
|
|
110
153
|
export type MemoryScope = 'shared' | 'private' | 'room';
|
|
111
154
|
/**
|
|
112
|
-
* Base interface for all memory metadata types
|
|
155
|
+
* Base interface for all memory metadata types.
|
|
156
|
+
* It includes common properties for all memories, such as:
|
|
157
|
+
* - `type`: The kind of memory (e.g., `MemoryType.MESSAGE`, `MemoryType.DOCUMENT`).
|
|
158
|
+
* - `source`: An optional string indicating the origin of the memory (e.g., 'discord', 'user_input').
|
|
159
|
+
* - `sourceId`: An optional UUID linking to a source entity or object.
|
|
160
|
+
* - `scope`: The visibility scope of the memory (`shared`, `private`, or `room`).
|
|
161
|
+
* - `timestamp`: An optional numerical timestamp (e.g., milliseconds since epoch) of when the memory was created or relevant.
|
|
162
|
+
* - `tags`: Optional array of strings for categorizing or filtering memories.
|
|
163
|
+
* Specific metadata types like `DocumentMetadata` or `MessageMetadata` extend this base.
|
|
113
164
|
*/
|
|
114
165
|
export interface BaseMetadata {
|
|
115
166
|
type: MemoryTypeAlias;
|
|
@@ -155,6 +206,8 @@ export interface Memory {
|
|
|
155
206
|
embedding?: number[];
|
|
156
207
|
/** Associated room ID */
|
|
157
208
|
roomId: UUID;
|
|
209
|
+
/** Associated world ID (optional) */
|
|
210
|
+
worldId?: UUID;
|
|
158
211
|
/** Whether memory is unique (used to prevent duplicates) */
|
|
159
212
|
unique?: boolean;
|
|
160
213
|
/** Embedding similarity score (set when retrieved via search) */
|
|
@@ -310,6 +363,7 @@ export interface Component {
|
|
|
310
363
|
worldId: UUID;
|
|
311
364
|
sourceEntityId: UUID;
|
|
312
365
|
type: string;
|
|
366
|
+
createdAt: number;
|
|
313
367
|
data: {
|
|
314
368
|
[key: string]: any;
|
|
315
369
|
};
|
|
@@ -346,6 +400,7 @@ export type World = {
|
|
|
346
400
|
[key: string]: unknown;
|
|
347
401
|
};
|
|
348
402
|
};
|
|
403
|
+
export type RoomMetadata = Record<string, unknown>;
|
|
349
404
|
export type Room = {
|
|
350
405
|
id: UUID;
|
|
351
406
|
name?: string;
|
|
@@ -355,7 +410,7 @@ export type Room = {
|
|
|
355
410
|
channelId?: string;
|
|
356
411
|
serverId?: string;
|
|
357
412
|
worldId?: UUID;
|
|
358
|
-
metadata?:
|
|
413
|
+
metadata?: RoomMetadata;
|
|
359
414
|
};
|
|
360
415
|
/**
|
|
361
416
|
* Room participant with account details
|
|
@@ -422,11 +477,20 @@ export type Route = {
|
|
|
422
477
|
type: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'STATIC';
|
|
423
478
|
path: string;
|
|
424
479
|
filePath?: string;
|
|
480
|
+
public?: boolean;
|
|
481
|
+
name: string extends {
|
|
482
|
+
public: true;
|
|
483
|
+
} ? string : string | undefined;
|
|
425
484
|
handler?: (req: any, res: any, runtime: IAgentRuntime) => Promise<void>;
|
|
426
485
|
};
|
|
427
486
|
/**
|
|
428
487
|
* Plugin for extending agent functionality
|
|
429
488
|
*/
|
|
489
|
+
export type PluginEvents = {
|
|
490
|
+
[K in keyof EventPayloadMap]?: EventHandler<K>[];
|
|
491
|
+
} & {
|
|
492
|
+
[key: string]: ((params: EventPayload) => Promise<any>)[];
|
|
493
|
+
};
|
|
430
494
|
export interface Plugin {
|
|
431
495
|
name: string;
|
|
432
496
|
description: string;
|
|
@@ -447,13 +511,10 @@ export interface Plugin {
|
|
|
447
511
|
models?: {
|
|
448
512
|
[key: string]: (...args: any[]) => Promise<any>;
|
|
449
513
|
};
|
|
450
|
-
events?:
|
|
451
|
-
[K in keyof EventPayloadMap]?: EventHandler<K>[];
|
|
452
|
-
} & {
|
|
453
|
-
[key: string]: ((params: EventPayload) => Promise<any>)[];
|
|
454
|
-
};
|
|
514
|
+
events?: PluginEvents;
|
|
455
515
|
routes?: Route[];
|
|
456
516
|
tests?: TestSuite[];
|
|
517
|
+
priority?: number;
|
|
457
518
|
}
|
|
458
519
|
export interface ProjectAgent {
|
|
459
520
|
character: Character;
|
|
@@ -470,7 +531,20 @@ export type TemplateType = string | ((options: {
|
|
|
470
531
|
};
|
|
471
532
|
}) => string);
|
|
472
533
|
/**
|
|
473
|
-
* Configuration for an agent character
|
|
534
|
+
* Configuration for an agent's character, defining its personality, knowledge, and capabilities.
|
|
535
|
+
* This is a central piece of an agent's definition, used by the `AgentRuntime` to initialize and operate the agent.
|
|
536
|
+
* It includes:
|
|
537
|
+
* - `id`: Optional unique identifier for the character.
|
|
538
|
+
* - `name`, `username`: Identifying names for the character.
|
|
539
|
+
* - `system`: A system prompt that guides the agent's overall behavior.
|
|
540
|
+
* - `templates`: A map of prompt templates for various situations (e.g., message generation, summarization).
|
|
541
|
+
* - `bio`: A textual biography or description of the character.
|
|
542
|
+
* - `messageExamples`, `postExamples`: Examples of how the character communicates.
|
|
543
|
+
* - `topics`, `adjectives`: Keywords describing the character's knowledge areas and traits.
|
|
544
|
+
* - `knowledge`: Paths to knowledge files or directories to be loaded into the agent's memory.
|
|
545
|
+
* - `plugins`: A list of plugin names to be loaded for this character.
|
|
546
|
+
* - `settings`, `secrets`: Configuration key-value pairs, with secrets being handled more securely.
|
|
547
|
+
* - `style`: Guidelines for the character's writing style in different contexts (chat, post).
|
|
474
548
|
*/
|
|
475
549
|
export interface Character {
|
|
476
550
|
/** Optional unique identifier */
|
|
@@ -499,6 +573,9 @@ export interface Character {
|
|
|
499
573
|
knowledge?: (string | {
|
|
500
574
|
path: string;
|
|
501
575
|
shared?: boolean;
|
|
576
|
+
} | {
|
|
577
|
+
directory: string;
|
|
578
|
+
shared?: boolean;
|
|
502
579
|
})[];
|
|
503
580
|
/** Available plugins */
|
|
504
581
|
plugins?: string[];
|
|
@@ -521,6 +598,15 @@ export declare enum AgentStatus {
|
|
|
521
598
|
ACTIVE = "active",
|
|
522
599
|
INACTIVE = "inactive"
|
|
523
600
|
}
|
|
601
|
+
/**
|
|
602
|
+
* Represents an operational agent, extending the `Character` definition with runtime status and timestamps.
|
|
603
|
+
* While `Character` defines the blueprint, `Agent` represents an instantiated and potentially running version.
|
|
604
|
+
* It includes:
|
|
605
|
+
* - `enabled`: A boolean indicating if the agent is currently active or disabled.
|
|
606
|
+
* - `status`: The current operational status, typically `AgentStatus.ACTIVE` or `AgentStatus.INACTIVE`.
|
|
607
|
+
* - `createdAt`, `updatedAt`: Timestamps for when the agent record was created and last updated in the database.
|
|
608
|
+
* This interface is primarily used by the `IDatabaseAdapter` for agent management.
|
|
609
|
+
*/
|
|
524
610
|
export interface Agent extends Character {
|
|
525
611
|
enabled?: boolean;
|
|
526
612
|
status?: AgentStatus;
|
|
@@ -537,13 +623,14 @@ export interface IDatabaseAdapter {
|
|
|
537
623
|
init(): Promise<void>;
|
|
538
624
|
/** Close database connection */
|
|
539
625
|
close(): Promise<void>;
|
|
626
|
+
getConnection(): Promise<PGlite | PgPool>;
|
|
540
627
|
getAgent(agentId: UUID): Promise<Agent | null>;
|
|
541
628
|
/** Get all agents */
|
|
542
|
-
getAgents(): Promise<Agent[]>;
|
|
629
|
+
getAgents(): Promise<Partial<Agent>[]>;
|
|
543
630
|
createAgent(agent: Partial<Agent>): Promise<boolean>;
|
|
544
631
|
updateAgent(agentId: UUID, agent: Partial<Agent>): Promise<boolean>;
|
|
545
632
|
deleteAgent(agentId: UUID): Promise<boolean>;
|
|
546
|
-
ensureAgentExists(agent: Partial<Agent>): Promise<
|
|
633
|
+
ensureAgentExists(agent: Partial<Agent>): Promise<Agent>;
|
|
547
634
|
ensureEmbeddingDimension(dimension: number): Promise<void>;
|
|
548
635
|
/** Get entity by ID */
|
|
549
636
|
getEntityById(entityId: UUID): Promise<Entity | null>;
|
|
@@ -567,12 +654,13 @@ export interface IDatabaseAdapter {
|
|
|
567
654
|
getMemories(params: {
|
|
568
655
|
entityId?: UUID;
|
|
569
656
|
agentId?: UUID;
|
|
570
|
-
roomId?: UUID;
|
|
571
657
|
count?: number;
|
|
572
658
|
unique?: boolean;
|
|
573
659
|
tableName: string;
|
|
574
660
|
start?: number;
|
|
575
661
|
end?: number;
|
|
662
|
+
roomId?: UUID;
|
|
663
|
+
worldId?: UUID;
|
|
576
664
|
}): Promise<Memory[]>;
|
|
577
665
|
getMemoryById(id: UUID): Promise<Memory | null>;
|
|
578
666
|
getMemoriesByIds(ids: UUID[], tableName?: string): Promise<Memory[]>;
|
|
@@ -612,9 +700,12 @@ export interface IDatabaseAdapter {
|
|
|
612
700
|
embedding: number[];
|
|
613
701
|
match_threshold?: number;
|
|
614
702
|
count?: number;
|
|
615
|
-
roomId?: UUID;
|
|
616
703
|
unique?: boolean;
|
|
617
704
|
tableName: string;
|
|
705
|
+
query?: string;
|
|
706
|
+
roomId?: UUID;
|
|
707
|
+
worldId?: UUID;
|
|
708
|
+
entityId?: UUID;
|
|
618
709
|
}): Promise<Memory[]>;
|
|
619
710
|
createMemory(memory: Memory, tableName: string, unique?: boolean): Promise<UUID>;
|
|
620
711
|
updateMemory(memory: Partial<Memory> & {
|
|
@@ -626,11 +717,13 @@ export interface IDatabaseAdapter {
|
|
|
626
717
|
countMemories(roomId: UUID, unique?: boolean, tableName?: string): Promise<number>;
|
|
627
718
|
createWorld(world: World): Promise<UUID>;
|
|
628
719
|
getWorld(id: UUID): Promise<World | null>;
|
|
720
|
+
removeWorld(id: UUID): Promise<void>;
|
|
629
721
|
getAllWorlds(): Promise<World[]>;
|
|
630
722
|
updateWorld(world: World): Promise<void>;
|
|
631
723
|
getRoom(roomId: UUID): Promise<Room | null>;
|
|
632
724
|
createRoom({ id, name, source, type, channelId, serverId, worldId }: Room): Promise<UUID>;
|
|
633
725
|
deleteRoom(roomId: UUID): Promise<void>;
|
|
726
|
+
deleteRoomsByServerId(serverId: UUID): Promise<void>;
|
|
634
727
|
updateRoom(room: Room): Promise<void>;
|
|
635
728
|
getRoomsForParticipant(entityId: UUID): Promise<UUID[]>;
|
|
636
729
|
getRoomsForParticipants(userIds: UUID[]): Promise<UUID[]>;
|
|
@@ -686,6 +779,7 @@ export interface IDatabaseAdapter {
|
|
|
686
779
|
getTasks(params: {
|
|
687
780
|
roomId?: UUID;
|
|
688
781
|
tags?: string[];
|
|
782
|
+
entityId?: UUID;
|
|
689
783
|
}): Promise<Task[]>;
|
|
690
784
|
getTask(id: UUID): Promise<Task | null>;
|
|
691
785
|
getTasksByName(name: string): Promise<Task[]>;
|
|
@@ -749,9 +843,26 @@ export interface UnifiedSearchOptions extends UnifiedMemoryOptions {
|
|
|
749
843
|
embedding: number[];
|
|
750
844
|
similarity?: number;
|
|
751
845
|
}
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
846
|
+
/**
|
|
847
|
+
* Information describing the target of a message.
|
|
848
|
+
*/
|
|
849
|
+
export interface TargetInfo {
|
|
850
|
+
source: string;
|
|
851
|
+
roomId?: UUID;
|
|
852
|
+
channelId?: string;
|
|
853
|
+
serverId?: string;
|
|
854
|
+
entityId?: UUID;
|
|
855
|
+
threadId?: string;
|
|
856
|
+
}
|
|
857
|
+
/**
|
|
858
|
+
* Function signature for handlers responsible for sending messages to specific platforms.
|
|
859
|
+
*/
|
|
860
|
+
export type SendHandlerFunction = (runtime: IAgentRuntime, target: TargetInfo, content: Content) => Promise<void>;
|
|
861
|
+
/**
|
|
862
|
+
* Represents the core runtime environment for an agent.
|
|
863
|
+
* Defines methods for database interaction, plugin management, event handling,
|
|
864
|
+
* state composition, model usage, and task management.
|
|
865
|
+
*/
|
|
755
866
|
export interface IAgentRuntime extends IDatabaseAdapter {
|
|
756
867
|
agentId: UUID;
|
|
757
868
|
character: Character;
|
|
@@ -765,17 +876,26 @@ export interface IAgentRuntime extends IDatabaseAdapter {
|
|
|
765
876
|
routes: Route[];
|
|
766
877
|
registerPlugin(plugin: Plugin): Promise<void>;
|
|
767
878
|
initialize(): Promise<void>;
|
|
768
|
-
|
|
879
|
+
getConnection(): Promise<PGlite | PgPool>;
|
|
880
|
+
getKnowledge(message: Memory, scope?: {
|
|
881
|
+
roomId?: UUID;
|
|
882
|
+
worldId?: UUID;
|
|
883
|
+
entityId?: UUID;
|
|
884
|
+
}): Promise<KnowledgeItem[]>;
|
|
769
885
|
addKnowledge(item: KnowledgeItem, options: {
|
|
770
886
|
targetTokens: number;
|
|
771
887
|
overlap: number;
|
|
772
888
|
modelContextSize: number;
|
|
889
|
+
}, scope?: {
|
|
890
|
+
roomId?: UUID;
|
|
891
|
+
worldId?: UUID;
|
|
892
|
+
entityId?: UUID;
|
|
773
893
|
}): Promise<void>;
|
|
774
894
|
getService<T extends Service>(service: ServiceTypeName | string): T | null;
|
|
775
895
|
getAllServices(): Map<ServiceTypeName, Service>;
|
|
776
|
-
registerService(service: typeof Service): void
|
|
896
|
+
registerService(service: typeof Service): Promise<void>;
|
|
777
897
|
registerDatabaseAdapter(adapter: IDatabaseAdapter): void;
|
|
778
|
-
setSetting(key: string, value: string | boolean | null | any, secret
|
|
898
|
+
setSetting(key: string, value: string | boolean | null | any, secret?: boolean): void;
|
|
779
899
|
getSetting(key: string): string | boolean | null | any;
|
|
780
900
|
getConversationLength(): number;
|
|
781
901
|
processActions(message: Memory, responses: Memory[], state?: State, callback?: HandlerCallback): Promise<void>;
|
|
@@ -783,21 +903,24 @@ export interface IAgentRuntime extends IDatabaseAdapter {
|
|
|
783
903
|
registerProvider(provider: Provider): void;
|
|
784
904
|
registerAction(action: Action): void;
|
|
785
905
|
registerEvaluator(evaluator: Evaluator): void;
|
|
786
|
-
ensureConnection({ entityId, roomId, userName, name, source, channelId, serverId, type, worldId, }: {
|
|
906
|
+
ensureConnection({ entityId, roomId, metadata, userName, worldName, name, source, channelId, serverId, type, worldId, userId, }: {
|
|
787
907
|
entityId: UUID;
|
|
788
908
|
roomId: UUID;
|
|
789
909
|
userName?: string;
|
|
790
910
|
name?: string;
|
|
911
|
+
worldName?: string;
|
|
791
912
|
source?: string;
|
|
792
913
|
channelId?: string;
|
|
793
914
|
serverId?: string;
|
|
794
915
|
type: ChannelType;
|
|
795
|
-
worldId
|
|
916
|
+
worldId: UUID;
|
|
917
|
+
userId?: UUID;
|
|
918
|
+
metadata?: Record<string, any>;
|
|
796
919
|
}): Promise<void>;
|
|
797
920
|
ensureParticipantInRoom(entityId: UUID, roomId: UUID): Promise<void>;
|
|
798
921
|
ensureWorldExists(world: World): Promise<void>;
|
|
799
922
|
ensureRoomExists(room: Room): Promise<void>;
|
|
800
|
-
composeState(message: Memory,
|
|
923
|
+
composeState(message: Memory, includeList?: string[], onlyInclude?: boolean, skipCache?: boolean): Promise<State>;
|
|
801
924
|
/**
|
|
802
925
|
* Use a model with strongly typed parameters and return values based on model type
|
|
803
926
|
* @template T - The model type to use
|
|
@@ -807,7 +930,7 @@ export interface IAgentRuntime extends IDatabaseAdapter {
|
|
|
807
930
|
* @returns {Promise<R>} - The model result, typed based on the provided generic type parameter
|
|
808
931
|
*/
|
|
809
932
|
useModel<T extends ModelTypeName, R = ModelResultMap[T]>(modelType: T, params: Omit<ModelParamsMap[T], 'runtime'> | any): Promise<R>;
|
|
810
|
-
registerModel(modelType: ModelTypeName | string, handler: (params: any) => Promise<any
|
|
933
|
+
registerModel(modelType: ModelTypeName | string, handler: (params: any) => Promise<any>, provider: string, priority?: number): void;
|
|
811
934
|
getModel(modelType: ModelTypeName | string): ((runtime: IAgentRuntime, params: any) => Promise<any>) | undefined;
|
|
812
935
|
registerEvent(event: string, handler: (params: any) => Promise<void>): void;
|
|
813
936
|
getEvent(event: string): ((params: any) => Promise<void>)[] | undefined;
|
|
@@ -816,142 +939,333 @@ export interface IAgentRuntime extends IDatabaseAdapter {
|
|
|
816
939
|
getTaskWorker(name: string): TaskWorker | undefined;
|
|
817
940
|
stop(): Promise<void>;
|
|
818
941
|
addEmbeddingToMemory(memory: Memory): Promise<Memory>;
|
|
942
|
+
/**
|
|
943
|
+
* Registers a handler function responsible for sending messages to a specific source/platform.
|
|
944
|
+
* @param source - The unique identifier string for the source (e.g., 'discord', 'telegram').
|
|
945
|
+
* @param handler - The SendHandlerFunction to be called for this source.
|
|
946
|
+
*/
|
|
947
|
+
registerSendHandler(source: string, handler: SendHandlerFunction): void;
|
|
948
|
+
/**
|
|
949
|
+
* Sends a message to a specified target using the appropriate registered handler.
|
|
950
|
+
* @param target - Information describing the target recipient and platform.
|
|
951
|
+
* @param content - The message content to send.
|
|
952
|
+
* @returns Promise resolving when the message sending process is initiated or completed.
|
|
953
|
+
*/
|
|
954
|
+
sendMessageToTarget(target: TargetInfo, content: Content): Promise<void>;
|
|
955
|
+
}
|
|
956
|
+
/**
|
|
957
|
+
* Interface for settings object with key-value pairs.
|
|
958
|
+
*/
|
|
959
|
+
/**
|
|
960
|
+
* Interface representing settings with string key-value pairs.
|
|
961
|
+
*/
|
|
962
|
+
export interface RuntimeSettings {
|
|
963
|
+
[key: string]: string | undefined;
|
|
819
964
|
}
|
|
965
|
+
/**
|
|
966
|
+
* Represents a single item of knowledge that can be processed and stored by the agent.
|
|
967
|
+
* Knowledge items consist of content (text and optional structured data) and metadata.
|
|
968
|
+
* These items are typically added to the agent's knowledge base via `AgentRuntime.addKnowledge`
|
|
969
|
+
* and retrieved using `AgentRuntime.getKnowledge`.
|
|
970
|
+
* The `id` is a unique identifier for the knowledge item, often derived from its source or content.
|
|
971
|
+
*/
|
|
820
972
|
export type KnowledgeItem = {
|
|
973
|
+
/** A Universally Unique Identifier for this specific knowledge item. */
|
|
821
974
|
id: UUID;
|
|
975
|
+
/** The actual content of the knowledge item, which must include text and can have other fields. */
|
|
822
976
|
content: Content;
|
|
977
|
+
/** Optional metadata associated with this knowledge item, conforming to `MemoryMetadata`. */
|
|
823
978
|
metadata?: MemoryMetadata;
|
|
824
979
|
};
|
|
980
|
+
/**
|
|
981
|
+
* Defines the scope or visibility of knowledge items within the agent's system.
|
|
982
|
+
* - `SHARED`: Indicates knowledge that is broadly accessible, potentially across different agents or users if the system architecture permits.
|
|
983
|
+
* - `PRIVATE`: Indicates knowledge that is restricted, typically to the specific agent or user context it belongs to.
|
|
984
|
+
* This enum is used to manage access and retrieval of knowledge items, often in conjunction with `AgentRuntime.addKnowledge` or `AgentRuntime.getKnowledge` scopes.
|
|
985
|
+
*/
|
|
825
986
|
export declare enum KnowledgeScope {
|
|
826
987
|
SHARED = "shared",
|
|
827
988
|
PRIVATE = "private"
|
|
828
989
|
}
|
|
990
|
+
/**
|
|
991
|
+
* Specifies prefixes for keys used in caching mechanisms, helping to namespace cached data.
|
|
992
|
+
* For example, `KNOWLEDGE` might be used to prefix keys for cached knowledge embeddings or processed documents.
|
|
993
|
+
* This helps in organizing the cache and avoiding key collisions.
|
|
994
|
+
* Used internally by caching strategies, potentially within `IDatabaseAdapter` cache methods or runtime caching layers.
|
|
995
|
+
*/
|
|
829
996
|
export declare enum CacheKeyPrefix {
|
|
830
997
|
KNOWLEDGE = "knowledge"
|
|
831
998
|
}
|
|
999
|
+
/**
|
|
1000
|
+
* Represents an item within a directory listing, specifically for knowledge loading.
|
|
1001
|
+
* When an agent's `Character.knowledge` configuration includes a directory, this type
|
|
1002
|
+
* is used to specify the path to that directory and whether its contents should be treated as shared.
|
|
1003
|
+
* - `directory`: The path to the directory containing knowledge files.
|
|
1004
|
+
* - `shared`: An optional boolean (defaults to false) indicating if the knowledge from this directory is considered shared or private.
|
|
1005
|
+
*/
|
|
832
1006
|
export interface DirectoryItem {
|
|
1007
|
+
/** The path to the directory containing knowledge files. */
|
|
833
1008
|
directory: string;
|
|
1009
|
+
/** If true, knowledge from this directory is considered shared; otherwise, it's private. Defaults to false. */
|
|
834
1010
|
shared?: boolean;
|
|
835
1011
|
}
|
|
1012
|
+
/**
|
|
1013
|
+
* Represents a row structure, typically from a database query related to text chunking or processing.
|
|
1014
|
+
* This interface is quite minimal and seems to be a placeholder or a base for more specific chunk-related types.
|
|
1015
|
+
* The `id` would be the unique identifier for the chunk.
|
|
1016
|
+
* It might be used when splitting large documents into smaller, manageable pieces for embedding or analysis.
|
|
1017
|
+
*/
|
|
836
1018
|
export interface ChunkRow {
|
|
1019
|
+
/** The unique identifier for this chunk of text. */
|
|
837
1020
|
id: string;
|
|
838
1021
|
}
|
|
1022
|
+
/**
|
|
1023
|
+
* Parameters for generating text using a language model.
|
|
1024
|
+
* This structure is typically passed to `AgentRuntime.useModel` when the `modelType` is one of
|
|
1025
|
+
* `ModelType.TEXT_SMALL`, `ModelType.TEXT_LARGE`, `ModelType.TEXT_REASONING_SMALL`,
|
|
1026
|
+
* `ModelType.TEXT_REASONING_LARGE`, or `ModelType.TEXT_COMPLETION`.
|
|
1027
|
+
* It includes essential information like the prompt, model type, and various generation controls.
|
|
1028
|
+
*/
|
|
839
1029
|
export type GenerateTextParams = {
|
|
1030
|
+
/** The `AgentRuntime` instance, providing access to models and other services. */
|
|
840
1031
|
runtime: IAgentRuntime;
|
|
1032
|
+
/** The input string or prompt that the language model will use to generate text. */
|
|
841
1033
|
prompt: string;
|
|
1034
|
+
/** Specifies the type of text generation model to use (e.g., TEXT_LARGE, REASONING_SMALL). */
|
|
842
1035
|
modelType: ModelTypeName;
|
|
1036
|
+
/** Optional. The maximum number of tokens to generate in the response. */
|
|
843
1037
|
maxTokens?: number;
|
|
1038
|
+
/** Optional. Controls randomness (0.0-1.0). Lower values are more deterministic, higher are more creative. */
|
|
844
1039
|
temperature?: number;
|
|
1040
|
+
/** Optional. Penalizes new tokens based on their existing frequency in the text so far. */
|
|
845
1041
|
frequencyPenalty?: number;
|
|
1042
|
+
/** Optional. Penalizes new tokens based on whether they appear in the text so far. */
|
|
846
1043
|
presencePenalty?: number;
|
|
1044
|
+
/** Optional. A list of sequences at which the model will stop generating further tokens. */
|
|
847
1045
|
stopSequences?: string[];
|
|
848
1046
|
};
|
|
1047
|
+
/**
|
|
1048
|
+
* Parameters for tokenizing text, i.e., converting a string into a sequence of numerical tokens.
|
|
1049
|
+
* This is a common preprocessing step for many language models.
|
|
1050
|
+
* This structure is used with `AgentRuntime.useModel` when the `modelType` is `ModelType.TEXT_TOKENIZER_ENCODE`.
|
|
1051
|
+
*/
|
|
849
1052
|
export interface TokenizeTextParams {
|
|
1053
|
+
/** The input string to be tokenized. */
|
|
850
1054
|
prompt: string;
|
|
1055
|
+
/** The model type to use for tokenization, which determines the tokenizer algorithm and vocabulary. */
|
|
851
1056
|
modelType: ModelTypeName;
|
|
852
1057
|
}
|
|
1058
|
+
/**
|
|
1059
|
+
* Parameters for detokenizing text, i.e., converting a sequence of numerical tokens back into a string.
|
|
1060
|
+
* This is the reverse operation of tokenization.
|
|
1061
|
+
* This structure is used with `AgentRuntime.useModel` when the `modelType` is `ModelType.TEXT_TOKENIZER_DECODE`.
|
|
1062
|
+
*/
|
|
853
1063
|
export interface DetokenizeTextParams {
|
|
1064
|
+
/** An array of numerical tokens to be converted back into text. */
|
|
854
1065
|
tokens: number[];
|
|
1066
|
+
/** The model type used for detokenization, ensuring consistency with the original tokenization. */
|
|
855
1067
|
modelType: ModelTypeName;
|
|
856
1068
|
}
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
export interface IBrowserService extends Service {
|
|
864
|
-
getPageContent(url: string, runtime: IAgentRuntime): Promise<{
|
|
865
|
-
title: string;
|
|
866
|
-
description: string;
|
|
867
|
-
bodyContent: string;
|
|
868
|
-
}>;
|
|
869
|
-
}
|
|
870
|
-
export interface IPdfService extends Service {
|
|
871
|
-
convertPdfToText(pdfBuffer: Buffer): Promise<string>;
|
|
872
|
-
}
|
|
873
|
-
export interface IFileService extends Service {
|
|
874
|
-
uploadFile(imagePath: string, subDirectory: string, useSignedUrl: boolean, expiresIn: number): Promise<{
|
|
875
|
-
success: boolean;
|
|
876
|
-
url?: string;
|
|
877
|
-
error?: string;
|
|
878
|
-
}>;
|
|
879
|
-
generateSignedUrl(fileName: string, expiresIn: number): Promise<string>;
|
|
880
|
-
}
|
|
1069
|
+
/**
|
|
1070
|
+
* Represents a test case for evaluating agent or plugin functionality.
|
|
1071
|
+
* Each test case has a name and a function that contains the test logic.
|
|
1072
|
+
* The test function receives the `IAgentRuntime` instance, allowing it to interact with the agent's capabilities.
|
|
1073
|
+
* Test cases are typically grouped into `TestSuite`s.
|
|
1074
|
+
*/
|
|
881
1075
|
export interface TestCase {
|
|
1076
|
+
/** A descriptive name for the test case, e.g., "should respond to greetings". */
|
|
882
1077
|
name: string;
|
|
1078
|
+
/**
|
|
1079
|
+
* The function that executes the test logic. It can be synchronous or asynchronous.
|
|
1080
|
+
* It receives the `IAgentRuntime` to interact with the agent and its services.
|
|
1081
|
+
* The function should typically contain assertions to verify expected outcomes.
|
|
1082
|
+
*/
|
|
883
1083
|
fn: (runtime: IAgentRuntime) => Promise<void> | void;
|
|
884
1084
|
}
|
|
1085
|
+
/**
|
|
1086
|
+
* Represents a suite of related test cases for an agent or plugin.
|
|
1087
|
+
* This helps in organizing tests and running them collectively.
|
|
1088
|
+
* A `ProjectAgent` can define one or more `TestSuite`s.
|
|
1089
|
+
*/
|
|
885
1090
|
export interface TestSuite {
|
|
1091
|
+
/** A descriptive name for the test suite, e.g., "Core Functionality Tests". */
|
|
886
1092
|
name: string;
|
|
1093
|
+
/** An array of `TestCase` objects that belong to this suite. */
|
|
887
1094
|
tests: TestCase[];
|
|
888
1095
|
}
|
|
1096
|
+
/**
|
|
1097
|
+
* Represents an agent's registration details within a Trusted Execution Environment (TEE) context.
|
|
1098
|
+
* This is typically stored in a database table (e.g., `TeeAgent`) to manage agents operating in a TEE.
|
|
1099
|
+
* It allows for multiple registrations of the same `agentId` to support scenarios where an agent might restart,
|
|
1100
|
+
* generating a new keypair and attestation each time.
|
|
1101
|
+
*/
|
|
889
1102
|
export interface TeeAgent {
|
|
1103
|
+
/** Primary key for the TEE agent registration record (e.g., a UUID or auto-incrementing ID). */
|
|
890
1104
|
id: string;
|
|
1105
|
+
/** The core identifier of the agent, which can be duplicated across multiple TEE registrations. */
|
|
891
1106
|
agentId: string;
|
|
1107
|
+
/** The human-readable name of the agent. */
|
|
892
1108
|
agentName: string;
|
|
1109
|
+
/** Timestamp (e.g., Unix epoch in milliseconds) when this TEE registration was created. */
|
|
893
1110
|
createdAt: number;
|
|
1111
|
+
/** The public key associated with this specific TEE agent instance/session. */
|
|
894
1112
|
publicKey: string;
|
|
1113
|
+
/** The attestation document proving the authenticity and integrity of the TEE instance. */
|
|
895
1114
|
attestation: string;
|
|
896
1115
|
}
|
|
1116
|
+
/**
|
|
1117
|
+
* Defines the operational modes for a Trusted Execution Environment (TEE).
|
|
1118
|
+
* This enum is used to configure how TEE functionalities are engaged, allowing for
|
|
1119
|
+
* different setups for local development, Docker-based development, and production.
|
|
1120
|
+
*/
|
|
897
1121
|
export declare enum TEEMode {
|
|
1122
|
+
/** TEE functionality is completely disabled. */
|
|
898
1123
|
OFF = "OFF",
|
|
1124
|
+
/** For local development, potentially using a TEE simulator. */
|
|
899
1125
|
LOCAL = "LOCAL",// For local development with simulator
|
|
1126
|
+
/** For Docker-based development environments, possibly with a TEE simulator. */
|
|
900
1127
|
DOCKER = "DOCKER",// For docker development with simulator
|
|
1128
|
+
/** For production deployments, using actual TEE hardware without a simulator. */
|
|
901
1129
|
PRODUCTION = "PRODUCTION"
|
|
902
1130
|
}
|
|
1131
|
+
/**
|
|
1132
|
+
* Represents a quote obtained during remote attestation for a Trusted Execution Environment (TEE).
|
|
1133
|
+
* This quote is a piece of evidence provided by the TEE, cryptographically signed, which can be
|
|
1134
|
+
* verified by a relying party to ensure the TEE's integrity and authenticity.
|
|
1135
|
+
*/
|
|
903
1136
|
export interface RemoteAttestationQuote {
|
|
1137
|
+
/** The attestation quote data, typically a base64 encoded string or similar format. */
|
|
904
1138
|
quote: string;
|
|
1139
|
+
/** Timestamp (e.g., Unix epoch in milliseconds) when the quote was generated or received. */
|
|
905
1140
|
timestamp: number;
|
|
906
1141
|
}
|
|
1142
|
+
/**
|
|
1143
|
+
* Data structure used in the attestation process for deriving a key within a Trusted Execution Environment (TEE).
|
|
1144
|
+
* This information helps establish a secure channel or verify the identity of the agent instance
|
|
1145
|
+
* requesting key derivation.
|
|
1146
|
+
*/
|
|
907
1147
|
export interface DeriveKeyAttestationData {
|
|
1148
|
+
/** The unique identifier of the agent for which the key derivation is being attested. */
|
|
908
1149
|
agentId: string;
|
|
1150
|
+
/** The public key of the agent instance involved in the key derivation process. */
|
|
909
1151
|
publicKey: string;
|
|
1152
|
+
/** Optional subject or context information related to the key derivation. */
|
|
910
1153
|
subject?: string;
|
|
911
1154
|
}
|
|
1155
|
+
/**
|
|
1156
|
+
* Represents a message that has been attested by a Trusted Execution Environment (TEE).
|
|
1157
|
+
* This structure binds a message to an agent's identity and a timestamp, all within the
|
|
1158
|
+
* context of a remote attestation process, ensuring the message originated from a trusted TEE instance.
|
|
1159
|
+
*/
|
|
912
1160
|
export interface RemoteAttestationMessage {
|
|
1161
|
+
/** The unique identifier of the agent sending the attested message. */
|
|
913
1162
|
agentId: string;
|
|
1163
|
+
/** Timestamp (e.g., Unix epoch in milliseconds) when the message was attested or sent. */
|
|
914
1164
|
timestamp: number;
|
|
1165
|
+
/** The actual message content, including details about the entity, room, and the content itself. */
|
|
915
1166
|
message: {
|
|
916
1167
|
entityId: string;
|
|
917
1168
|
roomId: string;
|
|
918
1169
|
content: string;
|
|
919
1170
|
};
|
|
920
1171
|
}
|
|
1172
|
+
/**
|
|
1173
|
+
* Enumerates different types or vendors of Trusted Execution Environments (TEEs).
|
|
1174
|
+
* This allows the system to adapt to specific TEE technologies, like Intel TDX on DSTACK.
|
|
1175
|
+
*/
|
|
921
1176
|
export declare enum TeeType {
|
|
1177
|
+
/** Represents Intel Trusted Domain Extensions (TDX) running on DSTACK infrastructure. */
|
|
922
1178
|
TDX_DSTACK = "tdx_dstack"
|
|
923
1179
|
}
|
|
1180
|
+
/**
|
|
1181
|
+
* Configuration options specific to a particular Trusted Execution Environment (TEE) vendor.
|
|
1182
|
+
* This allows for vendor-specific settings to be passed to the TEE plugin or service.
|
|
1183
|
+
* The structure is a generic key-value map, as configurations can vary widely between vendors.
|
|
1184
|
+
*/
|
|
924
1185
|
export interface TeeVendorConfig {
|
|
925
1186
|
[key: string]: unknown;
|
|
926
1187
|
}
|
|
1188
|
+
/**
|
|
1189
|
+
* Configuration for a TEE (Trusted Execution Environment) plugin.
|
|
1190
|
+
* This allows specifying the TEE vendor and any vendor-specific configurations.
|
|
1191
|
+
* It's used to initialize and configure TEE-related functionalities within the agent system.
|
|
1192
|
+
*/
|
|
927
1193
|
export interface TeePluginConfig {
|
|
1194
|
+
/** Optional. The name or identifier of the TEE vendor (e.g., 'tdx_dstack' from `TeeType`). */
|
|
928
1195
|
vendor?: string;
|
|
1196
|
+
/** Optional. Vendor-specific configuration options, conforming to `TeeVendorConfig`. */
|
|
929
1197
|
vendorConfig?: TeeVendorConfig;
|
|
930
1198
|
}
|
|
1199
|
+
/**
|
|
1200
|
+
* Defines the contract for a Task Worker, which is responsible for executing a specific type of task.
|
|
1201
|
+
* Task workers are registered with the `AgentRuntime` and are invoked when a `Task` of their designated `name` needs processing.
|
|
1202
|
+
* This pattern allows for modular and extensible background task processing.
|
|
1203
|
+
*/
|
|
931
1204
|
export interface TaskWorker {
|
|
1205
|
+
/** The unique name of the task type this worker handles. This name links `Task` instances to this worker. */
|
|
932
1206
|
name: string;
|
|
1207
|
+
/**
|
|
1208
|
+
* The core execution logic for the task. This function is called by the runtime when a task needs to be processed.
|
|
1209
|
+
* It receives the `AgentRuntime`, task-specific `options`, and the `Task` object itself.
|
|
1210
|
+
*/
|
|
933
1211
|
execute: (runtime: IAgentRuntime, options: {
|
|
934
1212
|
[key: string]: unknown;
|
|
935
1213
|
}, task: Task) => Promise<void>;
|
|
1214
|
+
/**
|
|
1215
|
+
* Optional validation function that can be used to determine if a task is valid or should be executed,
|
|
1216
|
+
* often based on the current message and state. This might be used by an action or evaluator
|
|
1217
|
+
* before creating or queueing a task.
|
|
1218
|
+
*/
|
|
936
1219
|
validate?: (runtime: IAgentRuntime, message: Memory, state: State) => Promise<boolean>;
|
|
937
1220
|
}
|
|
1221
|
+
/**
|
|
1222
|
+
* Defines metadata associated with a `Task`.
|
|
1223
|
+
* This can include scheduling information like `updateInterval` or UI-related details
|
|
1224
|
+
* for presenting task options to a user.
|
|
1225
|
+
* The `[key: string]: unknown;` allows for additional, unspecified metadata fields.
|
|
1226
|
+
*/
|
|
1227
|
+
export type TaskMetadata = {
|
|
1228
|
+
/** Optional. If the task is recurring, this specifies the interval in milliseconds between updates or executions. */
|
|
1229
|
+
updateInterval?: number;
|
|
1230
|
+
/** Optional. Describes options or parameters that can be configured for this task, often for UI presentation. */
|
|
1231
|
+
options?: {
|
|
1232
|
+
name: string;
|
|
1233
|
+
description: string;
|
|
1234
|
+
}[];
|
|
1235
|
+
/** Allows for other dynamic metadata properties related to the task. */
|
|
1236
|
+
[key: string]: unknown;
|
|
1237
|
+
};
|
|
1238
|
+
/**
|
|
1239
|
+
* Represents a task to be performed, often in the background or at a later time.
|
|
1240
|
+
* Tasks are managed by the `AgentRuntime` and processed by registered `TaskWorker`s.
|
|
1241
|
+
* They can be associated with a room, world, and tagged for categorization and retrieval.
|
|
1242
|
+
* The `IDatabaseAdapter` handles persistence of task data.
|
|
1243
|
+
*/
|
|
938
1244
|
export interface Task {
|
|
1245
|
+
/** Optional. A Universally Unique Identifier for the task. Generated if not provided. */
|
|
939
1246
|
id?: UUID;
|
|
1247
|
+
/** The name of the task, which should correspond to a registered `TaskWorker.name`. */
|
|
940
1248
|
name: string;
|
|
1249
|
+
/** Optional. Timestamp of the last update to this task. */
|
|
941
1250
|
updatedAt?: number;
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
name: string;
|
|
946
|
-
description: string;
|
|
947
|
-
}[];
|
|
948
|
-
[key: string]: unknown;
|
|
949
|
-
};
|
|
1251
|
+
/** Optional. Metadata associated with the task, conforming to `TaskMetadata`. */
|
|
1252
|
+
metadata?: TaskMetadata;
|
|
1253
|
+
/** A human-readable description of what the task does or its purpose. */
|
|
950
1254
|
description: string;
|
|
1255
|
+
/** Optional. The UUID of the room this task is associated with. */
|
|
951
1256
|
roomId?: UUID;
|
|
1257
|
+
/** Optional. The UUID of the world this task is associated with. */
|
|
952
1258
|
worldId?: UUID;
|
|
1259
|
+
entityId?: UUID;
|
|
953
1260
|
tags: string[];
|
|
954
1261
|
}
|
|
1262
|
+
/**
|
|
1263
|
+
* Defines roles within a system, typically for access control or permissions, often within a `World`.
|
|
1264
|
+
* - `OWNER`: Represents the highest level of control, typically the creator or primary administrator.
|
|
1265
|
+
* - `ADMIN`: Represents administrative privileges, usually a subset of owner capabilities.
|
|
1266
|
+
* - `NONE`: Indicates no specific role or default, minimal permissions.
|
|
1267
|
+
* These roles are often used in `World.metadata.roles` to assign roles to entities.
|
|
1268
|
+
*/
|
|
955
1269
|
export declare enum Role {
|
|
956
1270
|
OWNER = "OWNER",
|
|
957
1271
|
ADMIN = "ADMIN",
|
|
@@ -1157,7 +1471,7 @@ export interface ModelResultMap {
|
|
|
1157
1471
|
description: string;
|
|
1158
1472
|
};
|
|
1159
1473
|
[ModelType.TRANSCRIPTION]: string;
|
|
1160
|
-
[ModelType.TEXT_TO_SPEECH]:
|
|
1474
|
+
[ModelType.TEXT_TO_SPEECH]: any | Buffer;
|
|
1161
1475
|
[ModelType.AUDIO]: any;
|
|
1162
1476
|
[ModelType.VIDEO]: any;
|
|
1163
1477
|
[ModelType.OBJECT_SMALL]: any;
|
|
@@ -1189,7 +1503,8 @@ export declare enum EventType {
|
|
|
1189
1503
|
ACTION_STARTED = "ACTION_STARTED",
|
|
1190
1504
|
ACTION_COMPLETED = "ACTION_COMPLETED",
|
|
1191
1505
|
EVALUATOR_STARTED = "EVALUATOR_STARTED",
|
|
1192
|
-
EVALUATOR_COMPLETED = "EVALUATOR_COMPLETED"
|
|
1506
|
+
EVALUATOR_COMPLETED = "EVALUATOR_COMPLETED",
|
|
1507
|
+
MODEL_USED = "MODEL_USED"
|
|
1193
1508
|
}
|
|
1194
1509
|
/**
|
|
1195
1510
|
* Platform-specific event type prefix
|
|
@@ -1205,6 +1520,7 @@ export declare enum PlatformPrefix {
|
|
|
1205
1520
|
export interface EventPayload {
|
|
1206
1521
|
runtime: IAgentRuntime;
|
|
1207
1522
|
source: string;
|
|
1523
|
+
onComplete?: () => void;
|
|
1208
1524
|
}
|
|
1209
1525
|
/**
|
|
1210
1526
|
* Payload for world-related events
|
|
@@ -1234,6 +1550,7 @@ export interface EntityPayload extends EventPayload {
|
|
|
1234
1550
|
export interface MessagePayload extends EventPayload {
|
|
1235
1551
|
message: Memory;
|
|
1236
1552
|
callback?: HandlerCallback;
|
|
1553
|
+
onComplete?: () => void;
|
|
1237
1554
|
}
|
|
1238
1555
|
/**
|
|
1239
1556
|
* Payload for events that are invoked without a message
|
|
@@ -1243,6 +1560,7 @@ export interface InvokePayload extends EventPayload {
|
|
|
1243
1560
|
userId: string;
|
|
1244
1561
|
roomId: UUID;
|
|
1245
1562
|
callback?: HandlerCallback;
|
|
1563
|
+
source: string;
|
|
1246
1564
|
}
|
|
1247
1565
|
/**
|
|
1248
1566
|
* Run event payload type
|
|
@@ -1278,6 +1596,19 @@ export interface EvaluatorEventPayload extends EventPayload {
|
|
|
1278
1596
|
completed?: boolean;
|
|
1279
1597
|
error?: Error;
|
|
1280
1598
|
}
|
|
1599
|
+
/**
|
|
1600
|
+
* Model event payload type
|
|
1601
|
+
*/
|
|
1602
|
+
export interface ModelEventPayload extends EventPayload {
|
|
1603
|
+
provider: string;
|
|
1604
|
+
type: ModelTypeName;
|
|
1605
|
+
prompt: string;
|
|
1606
|
+
tokens?: {
|
|
1607
|
+
prompt: number;
|
|
1608
|
+
completion: number;
|
|
1609
|
+
total: number;
|
|
1610
|
+
};
|
|
1611
|
+
}
|
|
1281
1612
|
/**
|
|
1282
1613
|
* Represents the parameters for a message received handler.
|
|
1283
1614
|
* @typedef {Object} MessageReceivedHandlerParams
|
|
@@ -1289,6 +1620,7 @@ export type MessageReceivedHandlerParams = {
|
|
|
1289
1620
|
runtime: IAgentRuntime;
|
|
1290
1621
|
message: Memory;
|
|
1291
1622
|
callback: HandlerCallback;
|
|
1623
|
+
onComplete?: () => void;
|
|
1292
1624
|
};
|
|
1293
1625
|
/**
|
|
1294
1626
|
* Maps event types to their corresponding payload types
|
|
@@ -1312,6 +1644,7 @@ export interface EventPayloadMap {
|
|
|
1312
1644
|
[EventType.ACTION_COMPLETED]: ActionEventPayload;
|
|
1313
1645
|
[EventType.EVALUATOR_STARTED]: EvaluatorEventPayload;
|
|
1314
1646
|
[EventType.EVALUATOR_COMPLETED]: EvaluatorEventPayload;
|
|
1647
|
+
[EventType.MODEL_USED]: ModelEventPayload;
|
|
1315
1648
|
}
|
|
1316
1649
|
/**
|
|
1317
1650
|
* Event handler function type
|
|
@@ -1325,7 +1658,8 @@ export declare enum SOCKET_MESSAGE_TYPE {
|
|
|
1325
1658
|
SEND_MESSAGE = 2,
|
|
1326
1659
|
MESSAGE = 3,
|
|
1327
1660
|
ACK = 4,
|
|
1328
|
-
THINKING = 5
|
|
1661
|
+
THINKING = 5,
|
|
1662
|
+
CONTROL = 6
|
|
1329
1663
|
}
|
|
1330
1664
|
/**
|
|
1331
1665
|
* Specialized memory type for messages with enhanced type checking
|
|
@@ -1412,22 +1746,6 @@ export interface ServiceError {
|
|
|
1412
1746
|
details?: unknown;
|
|
1413
1747
|
cause?: Error;
|
|
1414
1748
|
}
|
|
1415
|
-
/**
|
|
1416
|
-
* Type-safe helper for accessing the video service
|
|
1417
|
-
*/
|
|
1418
|
-
export declare function getVideoService(runtime: IAgentRuntime): IVideoService | null;
|
|
1419
|
-
/**
|
|
1420
|
-
* Type-safe helper for accessing the browser service
|
|
1421
|
-
*/
|
|
1422
|
-
export declare function getBrowserService(runtime: IAgentRuntime): IBrowserService | null;
|
|
1423
|
-
/**
|
|
1424
|
-
* Type-safe helper for accessing the PDF service
|
|
1425
|
-
*/
|
|
1426
|
-
export declare function getPdfService(runtime: IAgentRuntime): IPdfService | null;
|
|
1427
|
-
/**
|
|
1428
|
-
* Type-safe helper for accessing the file service
|
|
1429
|
-
*/
|
|
1430
|
-
export declare function getFileService(runtime: IAgentRuntime): IFileService | null;
|
|
1431
1749
|
/**
|
|
1432
1750
|
* Memory type guard for document memories
|
|
1433
1751
|
*/
|
|
@@ -1454,24 +1772,130 @@ export declare function createServiceError(error: unknown, code?: string): Servi
|
|
|
1454
1772
|
/**
|
|
1455
1773
|
* Replace 'any' types with more specific types
|
|
1456
1774
|
*/
|
|
1775
|
+
/**
|
|
1776
|
+
* Defines the possible primitive types or structured types for a value within the agent's state.
|
|
1777
|
+
* This type is used to provide more specific typing for properties within `StateObject` and `StateArray`,
|
|
1778
|
+
* moving away from a generic 'any' type for better type safety and clarity in state management.
|
|
1779
|
+
*/
|
|
1457
1780
|
export type StateValue = string | number | boolean | null | StateObject | StateArray;
|
|
1781
|
+
/**
|
|
1782
|
+
* Represents a generic object structure within the agent's state, where keys are strings
|
|
1783
|
+
* and values can be any `StateValue`. This allows for nested objects within the state.
|
|
1784
|
+
* It's a fundamental part of the `EnhancedState` interface.
|
|
1785
|
+
*/
|
|
1458
1786
|
export interface StateObject {
|
|
1459
1787
|
[key: string]: StateValue;
|
|
1460
1788
|
}
|
|
1789
|
+
/**
|
|
1790
|
+
* Represents an array of `StateValue` types within the agent's state.
|
|
1791
|
+
* This allows for lists of mixed or uniform types to be stored in the state,
|
|
1792
|
+
* contributing to the structured definition of `EnhancedState`.
|
|
1793
|
+
*/
|
|
1461
1794
|
export type StateArray = StateValue[];
|
|
1462
1795
|
/**
|
|
1463
|
-
* Enhanced State interface with more specific types
|
|
1796
|
+
* Enhanced State interface with more specific types for its core properties.
|
|
1797
|
+
* This interface provides a more structured representation of an agent's conversational state,
|
|
1798
|
+
* building upon the base `State` by typing `values` and `data` as `StateObject`.
|
|
1799
|
+
* The `text` property typically holds a textual summary or context derived from the state.
|
|
1800
|
+
* Additional dynamic properties are still allowed via the index signature `[key: string]: StateValue;`.
|
|
1464
1801
|
*/
|
|
1465
1802
|
export interface EnhancedState {
|
|
1803
|
+
/** Holds directly accessible state values, often used for template rendering or quick lookups. */
|
|
1466
1804
|
values: StateObject;
|
|
1805
|
+
/** Stores more complex or structured data, potentially namespaced by providers or internal systems. */
|
|
1467
1806
|
data: StateObject;
|
|
1807
|
+
/** A textual representation or summary of the current state, often used as context for models. */
|
|
1468
1808
|
text: string;
|
|
1809
|
+
/** Allows for additional dynamic properties to be added to the state object. */
|
|
1469
1810
|
[key: string]: StateValue;
|
|
1470
1811
|
}
|
|
1812
|
+
/**
|
|
1813
|
+
* A generic type for the `data` field within a `Component`.
|
|
1814
|
+
* While `Record<string, unknown>` allows for flexibility, developers are encouraged
|
|
1815
|
+
* to define more specific types for component data where possible to improve type safety
|
|
1816
|
+
* and code maintainability. This type serves as a base for various component implementations.
|
|
1817
|
+
*/
|
|
1471
1818
|
export type ComponentData = Record<string, unknown>;
|
|
1819
|
+
/**
|
|
1820
|
+
* Represents a generic data object that can be passed as a payload in an event.
|
|
1821
|
+
* This type is often used in `TypedEventHandler` to provide a flexible yet somewhat
|
|
1822
|
+
* structured way to handle event data. Specific event handlers might cast this to a
|
|
1823
|
+
* more concrete type based on the event being processed.
|
|
1824
|
+
*/
|
|
1472
1825
|
export type EventDataObject = Record<string, unknown>;
|
|
1826
|
+
/**
|
|
1827
|
+
* Defines a more specific type for event handlers, expecting an `EventDataObject`.
|
|
1828
|
+
* This aims to improve upon generic 'any' type handlers, providing a clearer contract
|
|
1829
|
+
* for functions that respond to events emitted within the agent runtime (see `emitEvent` in `AgentRuntime`).
|
|
1830
|
+
* Handlers can be synchronous or asynchronous.
|
|
1831
|
+
*/
|
|
1473
1832
|
export type TypedEventHandler = (data: EventDataObject) => Promise<void> | void;
|
|
1833
|
+
/**
|
|
1834
|
+
* Represents a generic database connection object.
|
|
1835
|
+
* The actual type of this connection will depend on the specific database adapter implementation
|
|
1836
|
+
* (e.g., a connection pool object for PostgreSQL, a client instance for a NoSQL database).
|
|
1837
|
+
* This `unknown` type serves as a placeholder in the abstract `IDatabaseAdapter`.
|
|
1838
|
+
*/
|
|
1474
1839
|
export type DbConnection = unknown;
|
|
1840
|
+
/**
|
|
1841
|
+
* A generic type for metadata objects, often used in various parts of the system like
|
|
1842
|
+
* `Relationship` metadata or other extensible data structures.
|
|
1843
|
+
* It allows for arbitrary key-value pairs where values are of `unknown` type,
|
|
1844
|
+
* encouraging consumers to perform type checking or casting.
|
|
1845
|
+
*/
|
|
1475
1846
|
export type MetadataObject = Record<string, unknown>;
|
|
1476
|
-
|
|
1847
|
+
/**
|
|
1848
|
+
* Defines the structure for a model handler registration within the `AgentRuntime`.
|
|
1849
|
+
* Each model (e.g., for text generation, embedding) is associated with a handler function,
|
|
1850
|
+
* the name of the provider (plugin or system) that registered it, and an optional priority.
|
|
1851
|
+
* The `priority` (higher is more preferred) helps in selecting which handler to use if multiple
|
|
1852
|
+
* handlers are registered for the same model type. The `registrationOrder` (not in type, but used in runtime)
|
|
1853
|
+
* serves as a tie-breaker. See `AgentRuntime.registerModel` and `AgentRuntime.getModel`.
|
|
1854
|
+
*/
|
|
1855
|
+
export interface ModelHandler {
|
|
1856
|
+
/** The function that executes the model, taking runtime and parameters, and returning a Promise. */
|
|
1857
|
+
handler: (runtime: IAgentRuntime, params: Record<string, unknown>) => Promise<unknown>;
|
|
1858
|
+
/** The name of the provider (e.g., plugin name) that registered this model handler. */
|
|
1859
|
+
provider: string;
|
|
1860
|
+
/**
|
|
1861
|
+
* Optional priority for this model handler. Higher numbers indicate higher priority.
|
|
1862
|
+
* This is used by `AgentRuntime.getModel` to select the most appropriate handler
|
|
1863
|
+
* when multiple are available for a given model type. Defaults to 0 if not specified.
|
|
1864
|
+
*/
|
|
1865
|
+
priority?: number;
|
|
1866
|
+
registrationOrder?: number;
|
|
1867
|
+
}
|
|
1868
|
+
/**
|
|
1869
|
+
* A generic type for service configurations.
|
|
1870
|
+
* Services (like `IVideoService`, `IBrowserService`) can have their own specific configuration
|
|
1871
|
+
* structures. This type allows for a flexible way to pass configuration objects,
|
|
1872
|
+
* typically used during service initialization within a plugin or the `AgentRuntime`.
|
|
1873
|
+
*/
|
|
1477
1874
|
export type ServiceConfig = Record<string, unknown>;
|
|
1875
|
+
export declare const VECTOR_DIMS: {
|
|
1876
|
+
readonly SMALL: 384;
|
|
1877
|
+
readonly MEDIUM: 512;
|
|
1878
|
+
readonly LARGE: 768;
|
|
1879
|
+
readonly XL: 1024;
|
|
1880
|
+
readonly XXL: 1536;
|
|
1881
|
+
readonly XXXL: 3072;
|
|
1882
|
+
};
|
|
1883
|
+
/**
|
|
1884
|
+
* Interface for control messages sent from the backend to the frontend
|
|
1885
|
+
* to manage UI state and interaction capabilities
|
|
1886
|
+
*/
|
|
1887
|
+
export interface ControlMessage {
|
|
1888
|
+
/** Message type identifier */
|
|
1889
|
+
type: 'control';
|
|
1890
|
+
/** Control message payload */
|
|
1891
|
+
payload: {
|
|
1892
|
+
/** Action to perform */
|
|
1893
|
+
action: 'disable_input' | 'enable_input';
|
|
1894
|
+
/** Optional target element identifier */
|
|
1895
|
+
target?: string;
|
|
1896
|
+
/** Additional optional parameters */
|
|
1897
|
+
[key: string]: unknown;
|
|
1898
|
+
};
|
|
1899
|
+
/** Room ID to ensure signal is directed to the correct chat window */
|
|
1900
|
+
roomId: UUID;
|
|
1901
|
+
}
|