@elizaos/core 1.5.4 → 1.5.5
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/README.md +0 -15
- package/dist/index.d.ts +4886 -3
- package/dist/index.js +5287 -4
- package/package.json +21 -39
- package/dist/browser/index.browser.js +0 -1109
- package/dist/browser/index.browser.js.map +0 -707
- package/dist/browser/index.d.ts +0 -3
- package/dist/node/index.d.ts +0 -3
- package/dist/node/index.node.js +0 -74530
- package/dist/node/index.node.js.map +0 -1027
- package/src/__tests__/action-chaining-simple.test.ts +0 -203
- package/src/__tests__/actions.test.ts +0 -218
- package/src/__tests__/buffer.test.ts +0 -337
- package/src/__tests__/character-validation.test.ts +0 -309
- package/src/__tests__/database.test.ts +0 -750
- package/src/__tests__/entities.test.ts +0 -727
- package/src/__tests__/env.test.ts +0 -23
- package/src/__tests__/environment.test.ts +0 -285
- package/src/__tests__/logger-browser-node.test.ts +0 -716
- package/src/__tests__/logger.test.ts +0 -403
- package/src/__tests__/messages.test.ts +0 -196
- package/src/__tests__/mockCharacter.ts +0 -544
- package/src/__tests__/parsing.test.ts +0 -58
- package/src/__tests__/prompts.test.ts +0 -159
- package/src/__tests__/roles.test.ts +0 -331
- package/src/__tests__/runtime-embedding.test.ts +0 -343
- package/src/__tests__/runtime.test.ts +0 -978
- package/src/__tests__/search.test.ts +0 -15
- package/src/__tests__/services-by-type.test.ts +0 -204
- package/src/__tests__/services.test.ts +0 -136
- package/src/__tests__/settings.test.ts +0 -810
- package/src/__tests__/utils.test.ts +0 -1105
- package/src/__tests__/uuid.test.ts +0 -94
- package/src/actions.ts +0 -122
- package/src/database.ts +0 -579
- package/src/entities.ts +0 -406
- package/src/index.browser.ts +0 -48
- package/src/index.node.ts +0 -39
- package/src/index.ts +0 -50
- package/src/logger.ts +0 -527
- package/src/prompts.ts +0 -243
- package/src/roles.ts +0 -85
- package/src/runtime.ts +0 -2514
- package/src/schemas/character.ts +0 -149
- package/src/search.ts +0 -1543
- package/src/sentry/instrument.browser.ts +0 -65
- package/src/sentry/instrument.node.ts +0 -57
- package/src/sentry/instrument.ts +0 -82
- package/src/services.ts +0 -105
- package/src/settings.ts +0 -409
- package/src/test_resources/constants.ts +0 -12
- package/src/test_resources/testSetup.ts +0 -21
- package/src/test_resources/types.ts +0 -22
- package/src/types/agent.ts +0 -112
- package/src/types/browser.ts +0 -145
- package/src/types/components.ts +0 -184
- package/src/types/database.ts +0 -348
- package/src/types/email.ts +0 -162
- package/src/types/environment.ts +0 -129
- package/src/types/events.ts +0 -249
- package/src/types/index.ts +0 -29
- package/src/types/knowledge.ts +0 -65
- package/src/types/lp.ts +0 -124
- package/src/types/memory.ts +0 -228
- package/src/types/message.ts +0 -233
- package/src/types/messaging.ts +0 -57
- package/src/types/model.ts +0 -359
- package/src/types/pdf.ts +0 -77
- package/src/types/plugin.ts +0 -78
- package/src/types/post.ts +0 -271
- package/src/types/primitives.ts +0 -97
- package/src/types/runtime.ts +0 -190
- package/src/types/service.ts +0 -198
- package/src/types/settings.ts +0 -30
- package/src/types/state.ts +0 -60
- package/src/types/task.ts +0 -72
- package/src/types/tee.ts +0 -107
- package/src/types/testing.ts +0 -30
- package/src/types/token.ts +0 -96
- package/src/types/transcription.ts +0 -133
- package/src/types/video.ts +0 -108
- package/src/types/wallet.ts +0 -56
- package/src/types/web-search.ts +0 -146
- package/src/utils/__tests__/buffer.test.ts +0 -80
- package/src/utils/__tests__/environment.test.ts +0 -58
- package/src/utils/__tests__/stringToUuid.test.ts +0 -88
- package/src/utils/buffer.ts +0 -312
- package/src/utils/environment.ts +0 -316
- package/src/utils/server-health.ts +0 -117
- package/src/utils.ts +0 -1076
package/src/types/service.ts
DELETED
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
import type { Metadata } from './primitives';
|
|
2
|
-
import type { IAgentRuntime } from './runtime';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Core service type registry that can be extended by plugins via module augmentation.
|
|
6
|
-
* Plugins can extend this interface to add their own service types:
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* declare module '@elizaos/core' {
|
|
11
|
-
* interface ServiceTypeRegistry {
|
|
12
|
-
* MY_CUSTOM_SERVICE: 'my_custom_service';
|
|
13
|
-
* }
|
|
14
|
-
* }
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
export interface ServiceTypeRegistry {
|
|
18
|
-
TRANSCRIPTION: 'transcription';
|
|
19
|
-
VIDEO: 'video';
|
|
20
|
-
BROWSER: 'browser';
|
|
21
|
-
PDF: 'pdf';
|
|
22
|
-
REMOTE_FILES: 'aws_s3';
|
|
23
|
-
WEB_SEARCH: 'web_search';
|
|
24
|
-
EMAIL: 'email';
|
|
25
|
-
TEE: 'tee';
|
|
26
|
-
TASK: 'task';
|
|
27
|
-
WALLET: 'wallet';
|
|
28
|
-
LP_POOL: 'lp_pool';
|
|
29
|
-
TOKEN_DATA: 'token_data';
|
|
30
|
-
MESSAGE: 'message';
|
|
31
|
-
POST: 'post';
|
|
32
|
-
UNKNOWN: 'unknown';
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Type for service names that includes both core services and any plugin-registered services
|
|
37
|
-
*/
|
|
38
|
-
export type ServiceTypeName = ServiceTypeRegistry[keyof ServiceTypeRegistry];
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Helper type to extract service type values from the registry
|
|
42
|
-
*/
|
|
43
|
-
export type ServiceTypeValue<K extends keyof ServiceTypeRegistry> = ServiceTypeRegistry[K];
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Helper type to check if a service type exists in the registry
|
|
47
|
-
*/
|
|
48
|
-
export type IsValidServiceType<T extends string> = T extends ServiceTypeName ? true : false;
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Type-safe service class definition
|
|
52
|
-
*/
|
|
53
|
-
export type TypedServiceClass<T extends ServiceTypeName> = {
|
|
54
|
-
new (runtime?: IAgentRuntime): Service;
|
|
55
|
-
serviceType: T;
|
|
56
|
-
start(runtime: IAgentRuntime): Promise<Service>;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Map of service type names to their implementation classes
|
|
61
|
-
*/
|
|
62
|
-
export interface ServiceClassMap {
|
|
63
|
-
// Core services will be added here, plugins extend via module augmentation
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Helper to infer service instance type from service type name
|
|
68
|
-
*/
|
|
69
|
-
export type ServiceInstance<T extends ServiceTypeName> = T extends keyof ServiceClassMap
|
|
70
|
-
? InstanceType<ServiceClassMap[T]>
|
|
71
|
-
: Service;
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Runtime service registry type
|
|
75
|
-
*/
|
|
76
|
-
export type ServiceRegistry<T extends ServiceTypeName = ServiceTypeName> = Map<T, Service>;
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Enumerates the recognized types of services that can be registered and used by the agent runtime.
|
|
80
|
-
* Services provide specialized functionalities like audio transcription, video processing,
|
|
81
|
-
* web browsing, PDF handling, file storage (e.g., AWS S3), web search, email integration,
|
|
82
|
-
* secure execution via TEE (Trusted Execution Environment), and task management.
|
|
83
|
-
* This constant is used in `AgentRuntime` for service registration and retrieval (e.g., `getService`).
|
|
84
|
-
* Each service typically implements the `Service` abstract class or a more specific interface like `IVideoService`.
|
|
85
|
-
*/
|
|
86
|
-
export const ServiceType = {
|
|
87
|
-
TRANSCRIPTION: 'transcription',
|
|
88
|
-
VIDEO: 'video',
|
|
89
|
-
BROWSER: 'browser',
|
|
90
|
-
PDF: 'pdf',
|
|
91
|
-
REMOTE_FILES: 'aws_s3',
|
|
92
|
-
WEB_SEARCH: 'web_search',
|
|
93
|
-
EMAIL: 'email',
|
|
94
|
-
TEE: 'tee',
|
|
95
|
-
TASK: 'task',
|
|
96
|
-
WALLET: 'wallet',
|
|
97
|
-
LP_POOL: 'lp_pool',
|
|
98
|
-
TOKEN_DATA: 'token_data',
|
|
99
|
-
MESSAGE: 'message',
|
|
100
|
-
POST: 'post',
|
|
101
|
-
UNKNOWN: 'unknown',
|
|
102
|
-
} as const satisfies ServiceTypeRegistry;
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Client instance
|
|
106
|
-
*/
|
|
107
|
-
export abstract class Service {
|
|
108
|
-
/** Runtime instance */
|
|
109
|
-
protected runtime!: IAgentRuntime;
|
|
110
|
-
|
|
111
|
-
constructor(runtime?: IAgentRuntime) {
|
|
112
|
-
if (runtime) {
|
|
113
|
-
this.runtime = runtime;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
abstract stop(): Promise<void>;
|
|
118
|
-
|
|
119
|
-
/** Service type */
|
|
120
|
-
static serviceType: string;
|
|
121
|
-
|
|
122
|
-
/** Service name */
|
|
123
|
-
abstract capabilityDescription: string;
|
|
124
|
-
|
|
125
|
-
/** Service configuration */
|
|
126
|
-
config?: Metadata;
|
|
127
|
-
|
|
128
|
-
/** Start service connection */
|
|
129
|
-
static async start(_runtime: IAgentRuntime): Promise<Service> {
|
|
130
|
-
throw new Error('Not implemented');
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/** Stop service connection */
|
|
134
|
-
static async stop(_runtime: IAgentRuntime): Promise<unknown> {
|
|
135
|
-
throw new Error('Not implemented');
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Generic service interface that provides better type checking for services
|
|
141
|
-
* @template ConfigType The configuration type for this service
|
|
142
|
-
* @template ResultType The result type returned by the service operations
|
|
143
|
-
*/
|
|
144
|
-
export interface TypedService<ConfigType extends Metadata = Metadata, ResultType = unknown>
|
|
145
|
-
extends Service {
|
|
146
|
-
/**
|
|
147
|
-
* The configuration for this service instance
|
|
148
|
-
*/
|
|
149
|
-
config?: ConfigType;
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Process an input with this service
|
|
153
|
-
* @param input The input to process
|
|
154
|
-
* @returns A promise resolving to the result
|
|
155
|
-
*/
|
|
156
|
-
process(input: unknown): Promise<ResultType>;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Generic factory function to create a typed service instance
|
|
161
|
-
* @param runtime The agent runtime
|
|
162
|
-
* @param serviceType The type of service to get
|
|
163
|
-
* @returns The service instance or null if not available
|
|
164
|
-
*/
|
|
165
|
-
export function getTypedService<T extends TypedService<any, any>>(
|
|
166
|
-
runtime: IAgentRuntime,
|
|
167
|
-
serviceType: ServiceTypeName
|
|
168
|
-
): T | null {
|
|
169
|
-
return runtime.getService<T>(serviceType);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Standardized service error type for consistent error handling
|
|
174
|
-
*/
|
|
175
|
-
export interface ServiceError {
|
|
176
|
-
code: string;
|
|
177
|
-
message: string;
|
|
178
|
-
details?: unknown;
|
|
179
|
-
cause?: Error;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Safely create a ServiceError from any caught error
|
|
184
|
-
*/
|
|
185
|
-
export function createServiceError(error: unknown, code = 'UNKNOWN_ERROR'): ServiceError {
|
|
186
|
-
if (error instanceof Error) {
|
|
187
|
-
return {
|
|
188
|
-
code,
|
|
189
|
-
message: error.message,
|
|
190
|
-
cause: error,
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
return {
|
|
195
|
-
code,
|
|
196
|
-
message: String(error),
|
|
197
|
-
};
|
|
198
|
-
}
|
package/src/types/settings.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Interface representing settings with string key-value pairs.
|
|
3
|
-
*/
|
|
4
|
-
export interface RuntimeSettings {
|
|
5
|
-
[key: string]: string | undefined;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface Setting {
|
|
9
|
-
name: string;
|
|
10
|
-
description: string; // Used in chat context when discussing the setting
|
|
11
|
-
usageDescription: string; // Used during settings to guide users
|
|
12
|
-
value: string | boolean | null;
|
|
13
|
-
required: boolean;
|
|
14
|
-
public?: boolean; // If true, shown in public channels
|
|
15
|
-
secret?: boolean; // If true, value is masked and only shown during settings
|
|
16
|
-
validation?: (value: any) => boolean;
|
|
17
|
-
dependsOn?: string[];
|
|
18
|
-
onSetAction?: (value: any) => string;
|
|
19
|
-
visibleIf?: (settings: { [key: string]: Setting }) => boolean;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface WorldSettings {
|
|
23
|
-
[key: string]: Setting;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface OnboardingConfig {
|
|
27
|
-
settings: {
|
|
28
|
-
[key: string]: Omit<Setting, 'value'>;
|
|
29
|
-
};
|
|
30
|
-
}
|
package/src/types/state.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Represents the current state or context of a conversation or agent interaction.
|
|
3
|
-
* This interface is a flexible container for various pieces of information that define the agent's
|
|
4
|
-
* understanding at a point in time. It includes:
|
|
5
|
-
* - `values`: A key-value store for general state variables, often populated by providers.
|
|
6
|
-
* - `data`: Another key-value store, potentially for more structured or internal data.
|
|
7
|
-
* - `text`: A string representation of the current context, often a summary or concatenated history.
|
|
8
|
-
* The `[key: string]: any;` allows for dynamic properties, though `EnhancedState` offers better typing.
|
|
9
|
-
* This state object is passed to handlers for actions, evaluators, and providers.
|
|
10
|
-
*/
|
|
11
|
-
export interface State {
|
|
12
|
-
/** Additional dynamic properties */
|
|
13
|
-
[key: string]: any;
|
|
14
|
-
values: {
|
|
15
|
-
[key: string]: any;
|
|
16
|
-
};
|
|
17
|
-
data: {
|
|
18
|
-
[key: string]: any;
|
|
19
|
-
};
|
|
20
|
-
text: string;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Defines the possible primitive types or structured types for a value within the agent's state.
|
|
25
|
-
* This type is used to provide more specific typing for properties within `StateObject` and `StateArray`,
|
|
26
|
-
* moving away from a generic 'any' type for better type safety and clarity in state management.
|
|
27
|
-
*/
|
|
28
|
-
export type StateValue = string | number | boolean | null | StateObject | StateArray;
|
|
29
|
-
/**
|
|
30
|
-
* Represents a generic object structure within the agent's state, where keys are strings
|
|
31
|
-
* and values can be any `StateValue`. This allows for nested objects within the state.
|
|
32
|
-
* It's a fundamental part of the `EnhancedState` interface.
|
|
33
|
-
*/
|
|
34
|
-
export interface StateObject {
|
|
35
|
-
[key: string]: StateValue;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Represents an array of `StateValue` types within the agent's state.
|
|
39
|
-
* This allows for lists of mixed or uniform types to be stored in the state,
|
|
40
|
-
* contributing to the structured definition of `EnhancedState`.
|
|
41
|
-
*/
|
|
42
|
-
export type StateArray = StateValue[];
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Enhanced State interface with more specific types for its core properties.
|
|
46
|
-
* This interface provides a more structured representation of an agent's conversational state,
|
|
47
|
-
* building upon the base `State` by typing `values` and `data` as `StateObject`.
|
|
48
|
-
* The `text` property typically holds a textual summary or context derived from the state.
|
|
49
|
-
* Additional dynamic properties are still allowed via the index signature `[key: string]: StateValue;`.
|
|
50
|
-
*/
|
|
51
|
-
export interface EnhancedState {
|
|
52
|
-
/** Holds directly accessible state values, often used for template rendering or quick lookups. */
|
|
53
|
-
values: StateObject;
|
|
54
|
-
/** Stores more complex or structured data, potentially namespaced by providers or internal systems. */
|
|
55
|
-
data: StateObject;
|
|
56
|
-
/** A textual representation or summary of the current state, often used as context for models. */
|
|
57
|
-
text: string;
|
|
58
|
-
/** Allows for additional dynamic properties to be added to the state object. */
|
|
59
|
-
[key: string]: StateValue;
|
|
60
|
-
}
|
package/src/types/task.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import type { Memory } from './memory';
|
|
2
|
-
import type { UUID } from './primitives';
|
|
3
|
-
import type { IAgentRuntime } from './runtime';
|
|
4
|
-
import type { State } from './state';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Defines the contract for a Task Worker, which is responsible for executing a specific type of task.
|
|
8
|
-
* Task workers are registered with the `AgentRuntime` and are invoked when a `Task` of their designated `name` needs processing.
|
|
9
|
-
* This pattern allows for modular and extensible background task processing.
|
|
10
|
-
*/
|
|
11
|
-
export interface TaskWorker {
|
|
12
|
-
/** The unique name of the task type this worker handles. This name links `Task` instances to this worker. */
|
|
13
|
-
name: string;
|
|
14
|
-
/**
|
|
15
|
-
* The core execution logic for the task. This function is called by the runtime when a task needs to be processed.
|
|
16
|
-
* It receives the `AgentRuntime`, task-specific `options`, and the `Task` object itself.
|
|
17
|
-
*/
|
|
18
|
-
execute: (
|
|
19
|
-
runtime: IAgentRuntime,
|
|
20
|
-
options: { [key: string]: unknown },
|
|
21
|
-
task: Task
|
|
22
|
-
) => Promise<void>;
|
|
23
|
-
/**
|
|
24
|
-
* Optional validation function that can be used to determine if a task is valid or should be executed,
|
|
25
|
-
* often based on the current message and state. This might be used by an action or evaluator
|
|
26
|
-
* before creating or queueing a task.
|
|
27
|
-
*/
|
|
28
|
-
validate?: (runtime: IAgentRuntime, message: Memory, state: State) => Promise<boolean>;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Defines metadata associated with a `Task`.
|
|
33
|
-
* This can include scheduling information like `updateInterval` or UI-related details
|
|
34
|
-
* for presenting task options to a user.
|
|
35
|
-
* The `[key: string]: unknown;` allows for additional, unspecified metadata fields.
|
|
36
|
-
*/
|
|
37
|
-
export type TaskMetadata = {
|
|
38
|
-
/** Optional. If the task is recurring, this specifies the interval in milliseconds between updates or executions. */
|
|
39
|
-
updateInterval?: number;
|
|
40
|
-
/** Optional. Describes options or parameters that can be configured for this task, often for UI presentation. */
|
|
41
|
-
options?: {
|
|
42
|
-
name: string;
|
|
43
|
-
description: string;
|
|
44
|
-
}[];
|
|
45
|
-
/** Allows for other dynamic metadata properties related to the task. */
|
|
46
|
-
[key: string]: unknown;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Represents a task to be performed, often in the background or at a later time.
|
|
51
|
-
* Tasks are managed by the `AgentRuntime` and processed by registered `TaskWorker`s.
|
|
52
|
-
* They can be associated with a room, world, and tagged for categorization and retrieval.
|
|
53
|
-
* The `IDatabaseAdapter` handles persistence of task data.
|
|
54
|
-
*/
|
|
55
|
-
export interface Task {
|
|
56
|
-
/** Optional. A Universally Unique Identifier for the task. Generated if not provided. */
|
|
57
|
-
id?: UUID;
|
|
58
|
-
/** The name of the task, which should correspond to a registered `TaskWorker.name`. */
|
|
59
|
-
name: string;
|
|
60
|
-
/** Optional. Timestamp of the last update to this task. */
|
|
61
|
-
updatedAt?: number;
|
|
62
|
-
/** Optional. Metadata associated with the task, conforming to `TaskMetadata`. */
|
|
63
|
-
metadata?: TaskMetadata;
|
|
64
|
-
/** A human-readable description of what the task does or its purpose. */
|
|
65
|
-
description: string;
|
|
66
|
-
/** Optional. The UUID of the room this task is associated with. */
|
|
67
|
-
roomId?: UUID;
|
|
68
|
-
/** Optional. The UUID of the world this task is associated with. */
|
|
69
|
-
worldId?: UUID;
|
|
70
|
-
entityId?: UUID;
|
|
71
|
-
tags: string[];
|
|
72
|
-
}
|
package/src/types/tee.ts
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import type { Metadata } from './primitives';
|
|
2
|
-
|
|
3
|
-
// Represents an agent in the TeeAgent table, containing details about the agent.
|
|
4
|
-
/**
|
|
5
|
-
* Represents an agent's registration details within a Trusted Execution Environment (TEE) context.
|
|
6
|
-
* This is typically stored in a database table (e.g., `TeeAgent`) to manage agents operating in a TEE.
|
|
7
|
-
* It allows for multiple registrations of the same `agentId` to support scenarios where an agent might restart,
|
|
8
|
-
* generating a new keypair and attestation each time.
|
|
9
|
-
*/
|
|
10
|
-
export interface TeeAgent {
|
|
11
|
-
/** Primary key for the TEE agent registration record (e.g., a UUID or auto-incrementing ID). */
|
|
12
|
-
id: string; // Primary key
|
|
13
|
-
// Allow duplicate agentId.
|
|
14
|
-
// This is to support the case where the same agentId is registered multiple times.
|
|
15
|
-
// Each time the agent restarts, we will generate a new keypair and attestation.
|
|
16
|
-
/** The core identifier of the agent, which can be duplicated across multiple TEE registrations. */
|
|
17
|
-
agentId: string;
|
|
18
|
-
/** The human-readable name of the agent. */
|
|
19
|
-
agentName: string;
|
|
20
|
-
/** Timestamp (e.g., Unix epoch in milliseconds) when this TEE registration was created. */
|
|
21
|
-
createdAt: number;
|
|
22
|
-
/** The public key associated with this specific TEE agent instance/session. */
|
|
23
|
-
publicKey: string;
|
|
24
|
-
/** The attestation document proving the authenticity and integrity of the TEE instance. */
|
|
25
|
-
attestation: string;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Defines the operational modes for a Trusted Execution Environment (TEE).
|
|
30
|
-
* This enum is used to configure how TEE functionalities are engaged, allowing for
|
|
31
|
-
* different setups for local development, Docker-based development, and production.
|
|
32
|
-
*/
|
|
33
|
-
export enum TEEMode {
|
|
34
|
-
/** TEE functionality is completely disabled. */
|
|
35
|
-
OFF = 'OFF',
|
|
36
|
-
/** For local development, potentially using a TEE simulator. */
|
|
37
|
-
LOCAL = 'LOCAL', // For local development with simulator
|
|
38
|
-
/** For Docker-based development environments, possibly with a TEE simulator. */
|
|
39
|
-
DOCKER = 'DOCKER', // For docker development with simulator
|
|
40
|
-
/** For production deployments, using actual TEE hardware without a simulator. */
|
|
41
|
-
PRODUCTION = 'PRODUCTION', // For production without simulator
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Represents a quote obtained during remote attestation for a Trusted Execution Environment (TEE).
|
|
46
|
-
* This quote is a piece of evidence provided by the TEE, cryptographically signed, which can be
|
|
47
|
-
* verified by a relying party to ensure the TEE's integrity and authenticity.
|
|
48
|
-
*/
|
|
49
|
-
export interface RemoteAttestationQuote {
|
|
50
|
-
/** The attestation quote data, typically a base64 encoded string or similar format. */
|
|
51
|
-
quote: string;
|
|
52
|
-
/** Timestamp (e.g., Unix epoch in milliseconds) when the quote was generated or received. */
|
|
53
|
-
timestamp: number;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Data structure used in the attestation process for deriving a key within a Trusted Execution Environment (TEE).
|
|
58
|
-
* This information helps establish a secure channel or verify the identity of the agent instance
|
|
59
|
-
* requesting key derivation.
|
|
60
|
-
*/
|
|
61
|
-
export interface DeriveKeyAttestationData {
|
|
62
|
-
/** The unique identifier of the agent for which the key derivation is being attested. */
|
|
63
|
-
agentId: string;
|
|
64
|
-
/** The public key of the agent instance involved in the key derivation process. */
|
|
65
|
-
publicKey: string;
|
|
66
|
-
/** Optional subject or context information related to the key derivation. */
|
|
67
|
-
subject?: string;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Represents a message that has been attested by a Trusted Execution Environment (TEE).
|
|
72
|
-
* This structure binds a message to an agent's identity and a timestamp, all within the
|
|
73
|
-
* context of a remote attestation process, ensuring the message originated from a trusted TEE instance.
|
|
74
|
-
*/
|
|
75
|
-
export interface RemoteAttestationMessage {
|
|
76
|
-
/** The unique identifier of the agent sending the attested message. */
|
|
77
|
-
agentId: string;
|
|
78
|
-
/** Timestamp (e.g., Unix epoch in milliseconds) when the message was attested or sent. */
|
|
79
|
-
timestamp: number;
|
|
80
|
-
/** The actual message content, including details about the entity, room, and the content itself. */
|
|
81
|
-
message: {
|
|
82
|
-
entityId: string;
|
|
83
|
-
roomId: string;
|
|
84
|
-
content: string;
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Enumerates different types or vendors of Trusted Execution Environments (TEEs).
|
|
90
|
-
* This allows the system to adapt to specific TEE technologies, like Intel TDX on DSTACK.
|
|
91
|
-
*/
|
|
92
|
-
export enum TeeType {
|
|
93
|
-
/** Represents Intel Trusted Domain Extensions (TDX) running on DSTACK infrastructure. */
|
|
94
|
-
TDX_DSTACK = 'tdx_dstack',
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Configuration for a TEE (Trusted Execution Environment) plugin.
|
|
99
|
-
* This allows specifying the TEE vendor and any vendor-specific configurations.
|
|
100
|
-
* It's used to initialize and configure TEE-related functionalities within the agent system.
|
|
101
|
-
*/
|
|
102
|
-
export interface TeePluginConfig {
|
|
103
|
-
/** Optional. The name or identifier of the TEE vendor (e.g., 'tdx_dstack' from `TeeType`). */
|
|
104
|
-
vendor?: string;
|
|
105
|
-
/** Optional. Vendor-specific configuration options, conforming to `TeeVendorConfig`. */
|
|
106
|
-
vendorConfig?: Metadata;
|
|
107
|
-
}
|
package/src/types/testing.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { IAgentRuntime } from './runtime';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Represents a test case for evaluating agent or plugin functionality.
|
|
5
|
-
* Each test case has a name and a function that contains the test logic.
|
|
6
|
-
* The test function receives the `IAgentRuntime` instance, allowing it to interact with the agent's capabilities.
|
|
7
|
-
* Test cases are typically grouped into `TestSuite`s.
|
|
8
|
-
*/
|
|
9
|
-
export interface TestCase {
|
|
10
|
-
/** A descriptive name for the test case, e.g., "should respond to greetings". */
|
|
11
|
-
name: string;
|
|
12
|
-
/**
|
|
13
|
-
* The function that executes the test logic. It can be synchronous or asynchronous.
|
|
14
|
-
* It receives the `IAgentRuntime` to interact with the agent and its services.
|
|
15
|
-
* The function should typically contain assertions to verify expected outcomes.
|
|
16
|
-
*/
|
|
17
|
-
fn: (runtime: IAgentRuntime) => Promise<void> | void;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Represents a suite of related test cases for an agent or plugin.
|
|
22
|
-
* This helps in organizing tests and running them collectively.
|
|
23
|
-
* A `ProjectAgent` can define one or more `TestSuite`s.
|
|
24
|
-
*/
|
|
25
|
-
export interface TestSuite {
|
|
26
|
-
/** A descriptive name for the test suite, e.g., "Core Functionality Tests". */
|
|
27
|
-
name: string;
|
|
28
|
-
/** An array of `TestCase` objects that belong to this suite. */
|
|
29
|
-
tests: TestCase[];
|
|
30
|
-
}
|
package/src/types/token.ts
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { Service, ServiceType } from './service';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* A standardized representation of a token holding.
|
|
5
|
-
*/
|
|
6
|
-
export interface TokenBalance {
|
|
7
|
-
address: string; // Token mint address, or a native identifier like 'SOL' or 'ETH'
|
|
8
|
-
balance: string; // Raw balance as a string to handle large numbers with precision
|
|
9
|
-
decimals: number;
|
|
10
|
-
uiAmount?: number; // User-friendly balance, adjusted for decimals
|
|
11
|
-
name?: string;
|
|
12
|
-
symbol?: string;
|
|
13
|
-
logoURI?: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Generic representation of token data that can be provided by various services.
|
|
18
|
-
*/
|
|
19
|
-
export interface TokenData {
|
|
20
|
-
id: string; // Unique identifier (e.g., contract address or a composite ID)
|
|
21
|
-
symbol: string;
|
|
22
|
-
name: string;
|
|
23
|
-
address: string; // Contract address
|
|
24
|
-
chain: string; // e.g., 'solana', 'ethereum', 'base'
|
|
25
|
-
sourceProvider: string; // e.g., 'birdeye', 'coinmarketcap'
|
|
26
|
-
|
|
27
|
-
price?: number;
|
|
28
|
-
priceChange24hPercent?: number;
|
|
29
|
-
priceChange24hUSD?: number; // Absolute change
|
|
30
|
-
|
|
31
|
-
volume24hUSD?: number;
|
|
32
|
-
marketCapUSD?: number;
|
|
33
|
-
|
|
34
|
-
liquidity?: number;
|
|
35
|
-
holders?: number;
|
|
36
|
-
|
|
37
|
-
logoURI?: string;
|
|
38
|
-
decimals?: number;
|
|
39
|
-
|
|
40
|
-
// Timestamps
|
|
41
|
-
lastUpdatedAt?: Date; // When this specific data point was last updated from the source
|
|
42
|
-
|
|
43
|
-
// Optional raw data from the provider
|
|
44
|
-
raw?: any;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Interface for a generic service that provides token data.
|
|
49
|
-
*/
|
|
50
|
-
export abstract class ITokenDataService extends Service {
|
|
51
|
-
static override readonly serviceType = ServiceType.TOKEN_DATA;
|
|
52
|
-
public readonly capabilityDescription =
|
|
53
|
-
'Provides standardized access to token market data.' as string;
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Fetches detailed information for a single token.
|
|
57
|
-
* @param address The token's contract address.
|
|
58
|
-
* @param chain The blockchain the token resides on.
|
|
59
|
-
* @returns A Promise resolving to TokenData or null if not found.
|
|
60
|
-
*/
|
|
61
|
-
abstract getTokenDetails(address: string, chain: string): Promise<TokenData | null>;
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Fetches a list of trending tokens.
|
|
65
|
-
* @param chain Optional: Filter by a specific blockchain.
|
|
66
|
-
* @param limit Optional: Number of tokens to return. Defaults to a service-specific value.
|
|
67
|
-
* @param timePeriod Optional: Time period for trending data (e.g., '24h', '7d'). Defaults to service-specific.
|
|
68
|
-
* @returns A Promise resolving to an array of TokenData.
|
|
69
|
-
*/
|
|
70
|
-
abstract getTrendingTokens(
|
|
71
|
-
chain?: string,
|
|
72
|
-
limit?: number,
|
|
73
|
-
timePeriod?: string
|
|
74
|
-
): Promise<TokenData[]>;
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Searches for tokens based on a query string.
|
|
78
|
-
* @param query The search query (e.g., symbol, name, address).
|
|
79
|
-
* @param chain Optional: Filter by a specific blockchain.
|
|
80
|
-
* @param limit Optional: Number of results to return.
|
|
81
|
-
* @returns A Promise resolving to an array of TokenData.
|
|
82
|
-
*/
|
|
83
|
-
abstract searchTokens(query: string, chain?: string, limit?: number): Promise<TokenData[]>;
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Fetches data for multiple tokens by their addresses on a specific chain.
|
|
87
|
-
* @param addresses Array of token contract addresses.
|
|
88
|
-
* @param chain The blockchain the tokens reside on.
|
|
89
|
-
* @returns A Promise resolving to an array of TokenData. May not include all requested if some are not found.
|
|
90
|
-
*/
|
|
91
|
-
abstract getTokensByAddresses(addresses: string[], chain: string): Promise<TokenData[]>;
|
|
92
|
-
|
|
93
|
-
// Future potential methods:
|
|
94
|
-
// getHistoricalPriceData(address: string, chain: string, timeFrame: string): Promise<any[]>;
|
|
95
|
-
// getTokenMarketChart(address: string, chain: string, days: number): Promise<any[]>;
|
|
96
|
-
}
|