@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/lp.ts
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import type { Metadata } from './primitives';
|
|
2
|
-
import { Service } from './service';
|
|
3
|
-
import type { TokenBalance } from './token';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* A standardized representation of a liquidity pool from any DEX.
|
|
7
|
-
*/
|
|
8
|
-
export type PoolInfo = {
|
|
9
|
-
id: string; // Unique identifier for the pool (e.g., LP token mint or a DEX-specific ID).
|
|
10
|
-
displayName?: string; // User-friendly name for the pool.
|
|
11
|
-
dex: string; // Identifier for the DEX (e.g., "orca", "raydium").
|
|
12
|
-
tokenA: {
|
|
13
|
-
mint: string;
|
|
14
|
-
symbol?: string;
|
|
15
|
-
reserve?: string;
|
|
16
|
-
decimals?: number;
|
|
17
|
-
};
|
|
18
|
-
tokenB: {
|
|
19
|
-
mint: string;
|
|
20
|
-
symbol?: string;
|
|
21
|
-
reserve?: string;
|
|
22
|
-
decimals?: number;
|
|
23
|
-
};
|
|
24
|
-
lpTokenMint?: string;
|
|
25
|
-
apr?: number; // Annual Percentage Rate.
|
|
26
|
-
apy?: number; // Annual Percentage Yield.
|
|
27
|
-
tvl?: number; // Total Value Locked in USD.
|
|
28
|
-
fee?: number; // Trading fee percentage.
|
|
29
|
-
metadata?: Metadata; // For DEX-specific extra data.
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* A standardized representation of a user's position in a liquidity pool.
|
|
34
|
-
*/
|
|
35
|
-
export type LpPositionDetails = {
|
|
36
|
-
poolId: string;
|
|
37
|
-
dex: string;
|
|
38
|
-
lpTokenBalance: TokenBalance;
|
|
39
|
-
underlyingTokens: TokenBalance[]; // Array of two token balances.
|
|
40
|
-
valueUsd?: number;
|
|
41
|
-
accruedFees?: TokenBalance[];
|
|
42
|
-
rewards?: TokenBalance[];
|
|
43
|
-
metadata?: Metadata; // For additional DEX-specific position data.
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* A standardized result for blockchain transactions.
|
|
48
|
-
*/
|
|
49
|
-
export type TransactionResult = {
|
|
50
|
-
success: boolean;
|
|
51
|
-
transactionId?: string;
|
|
52
|
-
error?: string;
|
|
53
|
-
data?: any;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Abstract interface for a Liquidity Pool Service.
|
|
58
|
-
* DEX-specific plugins (e.g., for Orca, Raydium) must implement this service
|
|
59
|
-
* to allow the LP Manager to interact with them in a standardized way.
|
|
60
|
-
*/
|
|
61
|
-
export abstract class ILpService extends Service {
|
|
62
|
-
static override readonly serviceType = 'lp';
|
|
63
|
-
|
|
64
|
-
public readonly capabilityDescription = 'Provides standardized access to DEX liquidity pools.';
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Returns the name of the DEX this service interacts with.
|
|
68
|
-
* @returns The name of the DEX (e.g., "Orca", "Raydium").
|
|
69
|
-
*/
|
|
70
|
-
abstract getDexName(): string;
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Fetches a list of available liquidity pools from the DEX.
|
|
74
|
-
* @param tokenAMint - Optional: Filter pools by the mint address of the first token.
|
|
75
|
-
* @param tokenBMint - Optional: Filter pools by the mint address of the second token.
|
|
76
|
-
* @returns A promise that resolves to an array of standardized PoolInfo objects.
|
|
77
|
-
*/
|
|
78
|
-
abstract getPools(tokenAMint?: string, tokenBMint?: string): Promise<PoolInfo[]>;
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Adds liquidity to a specified pool.
|
|
82
|
-
* @param params - The parameters for adding liquidity.
|
|
83
|
-
* @returns A promise resolving to a transaction result, including the LP tokens received.
|
|
84
|
-
*/
|
|
85
|
-
abstract addLiquidity(params: {
|
|
86
|
-
userVault: any;
|
|
87
|
-
poolId: string;
|
|
88
|
-
tokenAAmountLamports: string;
|
|
89
|
-
tokenBAmountLamports?: string;
|
|
90
|
-
slippageBps: number;
|
|
91
|
-
tickLowerIndex?: number; // For concentrated liquidity
|
|
92
|
-
tickUpperIndex?: number; // For concentrated liquidity
|
|
93
|
-
}): Promise<TransactionResult & { lpTokensReceived?: TokenBalance }>;
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Removes liquidity from a specified pool.
|
|
97
|
-
* @param params - The parameters for removing liquidity.
|
|
98
|
-
* @returns A promise resolving to a transaction result, including the tokens received.
|
|
99
|
-
*/
|
|
100
|
-
abstract removeLiquidity(params: {
|
|
101
|
-
userVault: any;
|
|
102
|
-
poolId: string;
|
|
103
|
-
lpTokenAmountLamports: string;
|
|
104
|
-
slippageBps: number;
|
|
105
|
-
}): Promise<TransactionResult & { tokensReceived?: TokenBalance[] }>;
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Fetches the details of a specific LP position for a user.
|
|
109
|
-
* @param userAccountPublicKey - The user's wallet public key.
|
|
110
|
-
* @param poolOrPositionIdentifier - The identifier for the pool or a specific position (e.g., position NFT mint).
|
|
111
|
-
* @returns A promise resolving to the position details or null if not found.
|
|
112
|
-
*/
|
|
113
|
-
abstract getLpPositionDetails(
|
|
114
|
-
userAccountPublicKey: string,
|
|
115
|
-
poolOrPositionIdentifier: string
|
|
116
|
-
): Promise<LpPositionDetails | null>;
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Fetches the latest market data (e.g., APY, TVL) for a list of pools.
|
|
120
|
-
* @param poolIds - An array of pool IDs to fetch data for.
|
|
121
|
-
* @returns A promise resolving to a map of pool IDs to their partial market data.
|
|
122
|
-
*/
|
|
123
|
-
abstract getMarketDataForPools(poolIds: string[]): Promise<Record<string, Partial<PoolInfo>>>;
|
|
124
|
-
}
|
package/src/types/memory.ts
DELETED
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
import type { Content, UUID } from './primitives';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Memory type enumeration for built-in memory types
|
|
5
|
-
*/
|
|
6
|
-
export type MemoryTypeAlias = string;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Enumerates the built-in types of memories that can be stored and retrieved.
|
|
10
|
-
* - `DOCUMENT`: Represents a whole document or a large piece of text.
|
|
11
|
-
* - `FRAGMENT`: A chunk or segment of a `DOCUMENT`, often created for embedding and search.
|
|
12
|
-
* - `MESSAGE`: A conversational message, typically from a user or the agent.
|
|
13
|
-
* - `DESCRIPTION`: A descriptive piece of information, perhaps about an entity or concept.
|
|
14
|
-
* - `CUSTOM`: For any other type of memory not covered by the built-in types.
|
|
15
|
-
* This enum is used in `MemoryMetadata` to categorize memories and influences how they are processed or queried.
|
|
16
|
-
*/
|
|
17
|
-
export enum MemoryType {
|
|
18
|
-
DOCUMENT = 'document',
|
|
19
|
-
FRAGMENT = 'fragment',
|
|
20
|
-
MESSAGE = 'message',
|
|
21
|
-
DESCRIPTION = 'description',
|
|
22
|
-
CUSTOM = 'custom',
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Defines the scope of a memory, indicating its visibility and accessibility.
|
|
26
|
-
* - `shared`: The memory is accessible to multiple entities or across different contexts (e.g., a public fact).
|
|
27
|
-
* - `private`: The memory is specific to a single entity or a private context (e.g., a user's personal preference).
|
|
28
|
-
* - `room`: The memory is scoped to a specific room or channel.
|
|
29
|
-
* This is used in `MemoryMetadata` to control how memories are stored and retrieved based on context.
|
|
30
|
-
*/
|
|
31
|
-
export type MemoryScope = 'shared' | 'private' | 'room';
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Base interface for all memory metadata types.
|
|
35
|
-
* It includes common properties for all memories, such as:
|
|
36
|
-
* - `type`: The kind of memory (e.g., `MemoryType.MESSAGE`, `MemoryType.DOCUMENT`).
|
|
37
|
-
* - `source`: An optional string indicating the origin of the memory (e.g., 'discord', 'user_input').
|
|
38
|
-
* - `sourceId`: An optional UUID linking to a source entity or object.
|
|
39
|
-
* - `scope`: The visibility scope of the memory (`shared`, `private`, or `room`).
|
|
40
|
-
* - `timestamp`: An optional numerical timestamp (e.g., milliseconds since epoch) of when the memory was created or relevant.
|
|
41
|
-
* - `tags`: Optional array of strings for categorizing or filtering memories.
|
|
42
|
-
* Specific metadata types like `DocumentMetadata` or `MessageMetadata` extend this base.
|
|
43
|
-
*/
|
|
44
|
-
export interface BaseMetadata {
|
|
45
|
-
type: MemoryTypeAlias;
|
|
46
|
-
source?: string;
|
|
47
|
-
sourceId?: UUID;
|
|
48
|
-
scope?: MemoryScope;
|
|
49
|
-
timestamp?: number;
|
|
50
|
-
tags?: string[];
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export interface DocumentMetadata extends BaseMetadata {
|
|
54
|
-
type: MemoryType.DOCUMENT;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export interface FragmentMetadata extends BaseMetadata {
|
|
58
|
-
type: MemoryType.FRAGMENT;
|
|
59
|
-
documentId: UUID;
|
|
60
|
-
position: number;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export interface MessageMetadata extends BaseMetadata {
|
|
64
|
-
type: MemoryType.MESSAGE;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export interface DescriptionMetadata extends BaseMetadata {
|
|
68
|
-
type: MemoryType.DESCRIPTION;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export interface CustomMetadata extends BaseMetadata {
|
|
72
|
-
[key: string]: unknown;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export type MemoryMetadata =
|
|
76
|
-
| DocumentMetadata
|
|
77
|
-
| FragmentMetadata
|
|
78
|
-
| MessageMetadata
|
|
79
|
-
| DescriptionMetadata
|
|
80
|
-
| CustomMetadata;
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Represents a stored memory/message
|
|
84
|
-
*/
|
|
85
|
-
export interface Memory {
|
|
86
|
-
/** Optional unique identifier */
|
|
87
|
-
id?: UUID;
|
|
88
|
-
|
|
89
|
-
/** Associated user ID */
|
|
90
|
-
entityId: UUID;
|
|
91
|
-
|
|
92
|
-
/** Associated agent ID */
|
|
93
|
-
agentId?: UUID;
|
|
94
|
-
|
|
95
|
-
/** Optional creation timestamp in milliseconds since epoch */
|
|
96
|
-
createdAt?: number;
|
|
97
|
-
|
|
98
|
-
/** Memory content */
|
|
99
|
-
content: Content;
|
|
100
|
-
|
|
101
|
-
/** Optional embedding vector for semantic search */
|
|
102
|
-
embedding?: number[];
|
|
103
|
-
|
|
104
|
-
/** Associated room ID */
|
|
105
|
-
roomId: UUID;
|
|
106
|
-
|
|
107
|
-
/** Associated world ID (optional) */
|
|
108
|
-
worldId?: UUID;
|
|
109
|
-
|
|
110
|
-
/** Whether memory is unique (used to prevent duplicates) */
|
|
111
|
-
unique?: boolean;
|
|
112
|
-
|
|
113
|
-
/** Embedding similarity score (set when retrieved via search) */
|
|
114
|
-
similarity?: number;
|
|
115
|
-
|
|
116
|
-
/** Metadata for the memory */
|
|
117
|
-
metadata?: MemoryMetadata;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Specialized memory type for messages with enhanced type checking
|
|
122
|
-
*/
|
|
123
|
-
export interface MessageMemory extends Memory {
|
|
124
|
-
metadata: MessageMetadata;
|
|
125
|
-
content: Content & {
|
|
126
|
-
text: string; // Message memories must have text content
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Factory function to create a new message memory with proper defaults
|
|
132
|
-
*/
|
|
133
|
-
export function createMessageMemory(params: {
|
|
134
|
-
id?: UUID;
|
|
135
|
-
entityId: UUID;
|
|
136
|
-
agentId?: UUID;
|
|
137
|
-
roomId: UUID;
|
|
138
|
-
content: Content & { text: string };
|
|
139
|
-
embedding?: number[];
|
|
140
|
-
}): MessageMemory {
|
|
141
|
-
return {
|
|
142
|
-
...params,
|
|
143
|
-
createdAt: Date.now(),
|
|
144
|
-
metadata: {
|
|
145
|
-
type: MemoryType.MESSAGE,
|
|
146
|
-
timestamp: Date.now(),
|
|
147
|
-
scope: params.agentId ? 'private' : 'shared',
|
|
148
|
-
},
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Type guard to check if a memory metadata is a DocumentMetadata
|
|
154
|
-
* @param metadata The metadata to check
|
|
155
|
-
* @returns True if the metadata is a DocumentMetadata
|
|
156
|
-
*/
|
|
157
|
-
export function isDocumentMetadata(metadata: MemoryMetadata): metadata is DocumentMetadata {
|
|
158
|
-
return metadata.type === MemoryType.DOCUMENT;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Type guard to check if a memory metadata is a FragmentMetadata
|
|
163
|
-
* @param metadata The metadata to check
|
|
164
|
-
* @returns True if the metadata is a FragmentMetadata
|
|
165
|
-
*/
|
|
166
|
-
export function isFragmentMetadata(metadata: MemoryMetadata): metadata is FragmentMetadata {
|
|
167
|
-
return metadata.type === MemoryType.FRAGMENT;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Type guard to check if a memory metadata is a MessageMetadata
|
|
172
|
-
* @param metadata The metadata to check
|
|
173
|
-
* @returns True if the metadata is a MessageMetadata
|
|
174
|
-
*/
|
|
175
|
-
export function isMessageMetadata(metadata: MemoryMetadata): metadata is MessageMetadata {
|
|
176
|
-
return metadata.type === MemoryType.MESSAGE;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Type guard to check if a memory metadata is a DescriptionMetadata
|
|
181
|
-
* @param metadata The metadata to check
|
|
182
|
-
* @returns True if the metadata is a DescriptionMetadata
|
|
183
|
-
*/
|
|
184
|
-
export function isDescriptionMetadata(metadata: MemoryMetadata): metadata is DescriptionMetadata {
|
|
185
|
-
return metadata.type === MemoryType.DESCRIPTION;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Type guard to check if a memory metadata is a CustomMetadata
|
|
190
|
-
* @param metadata The metadata to check
|
|
191
|
-
* @returns True if the metadata is a CustomMetadata
|
|
192
|
-
*/
|
|
193
|
-
export function isCustomMetadata(metadata: MemoryMetadata): metadata is CustomMetadata {
|
|
194
|
-
return (
|
|
195
|
-
metadata.type !== MemoryType.DOCUMENT &&
|
|
196
|
-
metadata.type !== MemoryType.FRAGMENT &&
|
|
197
|
-
metadata.type !== MemoryType.MESSAGE &&
|
|
198
|
-
metadata.type !== MemoryType.DESCRIPTION
|
|
199
|
-
);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* Memory type guard for document memories
|
|
204
|
-
*/
|
|
205
|
-
export function isDocumentMemory(
|
|
206
|
-
memory: Memory
|
|
207
|
-
): memory is Memory & { metadata: DocumentMetadata } {
|
|
208
|
-
return memory.metadata?.type === MemoryType.DOCUMENT;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Memory type guard for fragment memories
|
|
213
|
-
*/
|
|
214
|
-
export function isFragmentMemory(
|
|
215
|
-
memory: Memory
|
|
216
|
-
): memory is Memory & { metadata: FragmentMetadata } {
|
|
217
|
-
return memory.metadata?.type === MemoryType.FRAGMENT;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Safely access the text content of a memory
|
|
222
|
-
* @param memory The memory to extract text from
|
|
223
|
-
* @param defaultValue Optional default value if no text is found
|
|
224
|
-
* @returns The text content or default value
|
|
225
|
-
*/
|
|
226
|
-
export function getMemoryText(memory: Memory, defaultValue = ''): string {
|
|
227
|
-
return memory.content.text ?? defaultValue;
|
|
228
|
-
}
|
package/src/types/message.ts
DELETED
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
import { Service, ServiceType } from './service';
|
|
2
|
-
import type { UUID } from './primitives';
|
|
3
|
-
|
|
4
|
-
export interface MessageParticipant {
|
|
5
|
-
id: UUID;
|
|
6
|
-
name: string;
|
|
7
|
-
username?: string;
|
|
8
|
-
avatar?: string;
|
|
9
|
-
status?: 'online' | 'offline' | 'away' | 'busy';
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface MessageAttachment {
|
|
13
|
-
id: UUID;
|
|
14
|
-
filename: string;
|
|
15
|
-
url: string;
|
|
16
|
-
mimeType: string;
|
|
17
|
-
size: number;
|
|
18
|
-
width?: number;
|
|
19
|
-
height?: number;
|
|
20
|
-
duration?: number;
|
|
21
|
-
thumbnail?: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface MessageReaction {
|
|
25
|
-
emoji: string;
|
|
26
|
-
count: number;
|
|
27
|
-
users: UUID[];
|
|
28
|
-
hasReacted: boolean;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface MessageReference {
|
|
32
|
-
messageId: UUID;
|
|
33
|
-
channelId: UUID;
|
|
34
|
-
type: 'reply' | 'forward' | 'quote';
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface MessageContent {
|
|
38
|
-
text?: string;
|
|
39
|
-
html?: string;
|
|
40
|
-
markdown?: string;
|
|
41
|
-
attachments?: MessageAttachment[];
|
|
42
|
-
reactions?: MessageReaction[];
|
|
43
|
-
reference?: MessageReference;
|
|
44
|
-
mentions?: UUID[];
|
|
45
|
-
embeds?: Array<{
|
|
46
|
-
title?: string;
|
|
47
|
-
description?: string;
|
|
48
|
-
url?: string;
|
|
49
|
-
image?: string;
|
|
50
|
-
fields?: Array<{
|
|
51
|
-
name: string;
|
|
52
|
-
value: string;
|
|
53
|
-
inline?: boolean;
|
|
54
|
-
}>;
|
|
55
|
-
}>;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export interface MessageInfo {
|
|
59
|
-
id: UUID;
|
|
60
|
-
channelId: UUID;
|
|
61
|
-
senderId: UUID;
|
|
62
|
-
content: MessageContent;
|
|
63
|
-
timestamp: Date;
|
|
64
|
-
edited?: Date;
|
|
65
|
-
deleted?: Date;
|
|
66
|
-
pinned?: boolean;
|
|
67
|
-
thread?: {
|
|
68
|
-
id: UUID;
|
|
69
|
-
messageCount: number;
|
|
70
|
-
participants: UUID[];
|
|
71
|
-
lastMessageAt: Date;
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export interface MessageSendOptions {
|
|
76
|
-
replyTo?: UUID;
|
|
77
|
-
ephemeral?: boolean;
|
|
78
|
-
silent?: boolean;
|
|
79
|
-
scheduled?: Date;
|
|
80
|
-
thread?: UUID;
|
|
81
|
-
nonce?: string;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export interface MessageSearchOptions {
|
|
85
|
-
query?: string;
|
|
86
|
-
channelId?: UUID;
|
|
87
|
-
senderId?: UUID;
|
|
88
|
-
before?: Date;
|
|
89
|
-
after?: Date;
|
|
90
|
-
limit?: number;
|
|
91
|
-
offset?: number;
|
|
92
|
-
hasAttachments?: boolean;
|
|
93
|
-
pinned?: boolean;
|
|
94
|
-
mentions?: UUID;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export interface MessageChannel {
|
|
98
|
-
id: UUID;
|
|
99
|
-
name: string;
|
|
100
|
-
type: 'text' | 'voice' | 'dm' | 'group' | 'announcement' | 'thread';
|
|
101
|
-
description?: string;
|
|
102
|
-
participants?: MessageParticipant[];
|
|
103
|
-
permissions?: {
|
|
104
|
-
canSend: boolean;
|
|
105
|
-
canRead: boolean;
|
|
106
|
-
canDelete: boolean;
|
|
107
|
-
canPin: boolean;
|
|
108
|
-
canManage: boolean;
|
|
109
|
-
};
|
|
110
|
-
lastMessageAt?: Date;
|
|
111
|
-
messageCount?: number;
|
|
112
|
-
unreadCount?: number;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Interface for messaging services
|
|
117
|
-
*/
|
|
118
|
-
export abstract class IMessageService extends Service {
|
|
119
|
-
static override readonly serviceType = ServiceType.MESSAGE;
|
|
120
|
-
|
|
121
|
-
public readonly capabilityDescription = 'Message sending, receiving, and management capabilities';
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Send a message to a channel
|
|
125
|
-
* @param channelId - Channel ID
|
|
126
|
-
* @param content - Message content
|
|
127
|
-
* @param options - Send options
|
|
128
|
-
* @returns Promise resolving to message ID
|
|
129
|
-
*/
|
|
130
|
-
abstract sendMessage(
|
|
131
|
-
channelId: UUID,
|
|
132
|
-
content: MessageContent,
|
|
133
|
-
options?: MessageSendOptions
|
|
134
|
-
): Promise<UUID>;
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Get messages from a channel
|
|
138
|
-
* @param channelId - Channel ID
|
|
139
|
-
* @param options - Search options
|
|
140
|
-
* @returns Promise resolving to array of messages
|
|
141
|
-
*/
|
|
142
|
-
abstract getMessages(channelId: UUID, options?: MessageSearchOptions): Promise<MessageInfo[]>;
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Get a specific message by ID
|
|
146
|
-
* @param messageId - Message ID
|
|
147
|
-
* @returns Promise resolving to message
|
|
148
|
-
*/
|
|
149
|
-
abstract getMessage(messageId: UUID): Promise<MessageInfo>;
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Edit a message
|
|
153
|
-
* @param messageId - Message ID
|
|
154
|
-
* @param content - New message content
|
|
155
|
-
* @returns Promise resolving when edit completes
|
|
156
|
-
*/
|
|
157
|
-
abstract editMessage(messageId: UUID, content: MessageContent): Promise<void>;
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Delete a message
|
|
161
|
-
* @param messageId - Message ID
|
|
162
|
-
* @returns Promise resolving when deletion completes
|
|
163
|
-
*/
|
|
164
|
-
abstract deleteMessage(messageId: UUID): Promise<void>;
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Add a reaction to a message
|
|
168
|
-
* @param messageId - Message ID
|
|
169
|
-
* @param emoji - Reaction emoji
|
|
170
|
-
* @returns Promise resolving when reaction is added
|
|
171
|
-
*/
|
|
172
|
-
abstract addReaction(messageId: UUID, emoji: string): Promise<void>;
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Remove a reaction from a message
|
|
176
|
-
* @param messageId - Message ID
|
|
177
|
-
* @param emoji - Reaction emoji
|
|
178
|
-
* @returns Promise resolving when reaction is removed
|
|
179
|
-
*/
|
|
180
|
-
abstract removeReaction(messageId: UUID, emoji: string): Promise<void>;
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Pin a message
|
|
184
|
-
* @param messageId - Message ID
|
|
185
|
-
* @returns Promise resolving when message is pinned
|
|
186
|
-
*/
|
|
187
|
-
abstract pinMessage(messageId: UUID): Promise<void>;
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Unpin a message
|
|
191
|
-
* @param messageId - Message ID
|
|
192
|
-
* @returns Promise resolving when message is unpinned
|
|
193
|
-
*/
|
|
194
|
-
abstract unpinMessage(messageId: UUID): Promise<void>;
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* Get available channels
|
|
198
|
-
* @returns Promise resolving to array of channels
|
|
199
|
-
*/
|
|
200
|
-
abstract getChannels(): Promise<MessageChannel[]>;
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* Get channel information
|
|
204
|
-
* @param channelId - Channel ID
|
|
205
|
-
* @returns Promise resolving to channel info
|
|
206
|
-
*/
|
|
207
|
-
abstract getChannel(channelId: UUID): Promise<MessageChannel>;
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Create a new channel
|
|
211
|
-
* @param name - Channel name
|
|
212
|
-
* @param type - Channel type
|
|
213
|
-
* @param options - Channel options
|
|
214
|
-
* @returns Promise resolving to new channel ID
|
|
215
|
-
*/
|
|
216
|
-
abstract createChannel(
|
|
217
|
-
name: string,
|
|
218
|
-
type: MessageChannel['type'],
|
|
219
|
-
options?: {
|
|
220
|
-
description?: string;
|
|
221
|
-
participants?: UUID[];
|
|
222
|
-
private?: boolean;
|
|
223
|
-
}
|
|
224
|
-
): Promise<UUID>;
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Search messages across channels
|
|
228
|
-
* @param query - Search query
|
|
229
|
-
* @param options - Search options
|
|
230
|
-
* @returns Promise resolving to search results
|
|
231
|
-
*/
|
|
232
|
-
abstract searchMessages(query: string, options?: MessageSearchOptions): Promise<MessageInfo[]>;
|
|
233
|
-
}
|
package/src/types/messaging.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import type { Content, UUID } from './primitives';
|
|
2
|
-
import type { IAgentRuntime } from './runtime';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Information describing the target of a message.
|
|
6
|
-
*/
|
|
7
|
-
export interface TargetInfo {
|
|
8
|
-
source: string; // Platform identifier (e.g., 'discord', 'telegram', 'websocket-api')
|
|
9
|
-
roomId?: UUID; // Target room ID (platform-specific or runtime-specific)
|
|
10
|
-
channelId?: string; // Platform-specific channel/chat ID
|
|
11
|
-
serverId?: string; // Platform-specific server/guild ID
|
|
12
|
-
entityId?: UUID; // Target user ID (for DMs)
|
|
13
|
-
threadId?: string; // Platform-specific thread ID (e.g., Telegram topics)
|
|
14
|
-
// Add other relevant platform-specific identifiers as needed
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Function signature for handlers responsible for sending messages to specific platforms.
|
|
19
|
-
*/
|
|
20
|
-
export type SendHandlerFunction = (
|
|
21
|
-
runtime: IAgentRuntime,
|
|
22
|
-
target: TargetInfo,
|
|
23
|
-
content: Content
|
|
24
|
-
) => Promise<void>;
|
|
25
|
-
|
|
26
|
-
export enum SOCKET_MESSAGE_TYPE {
|
|
27
|
-
ROOM_JOINING = 1,
|
|
28
|
-
SEND_MESSAGE = 2,
|
|
29
|
-
MESSAGE = 3,
|
|
30
|
-
ACK = 4,
|
|
31
|
-
THINKING = 5,
|
|
32
|
-
CONTROL = 6,
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Interface for control messages sent from the backend to the frontend
|
|
37
|
-
* to manage UI state and interaction capabilities
|
|
38
|
-
*/
|
|
39
|
-
export interface ControlMessage {
|
|
40
|
-
/** Message type identifier */
|
|
41
|
-
type: 'control';
|
|
42
|
-
|
|
43
|
-
/** Control message payload */
|
|
44
|
-
payload: {
|
|
45
|
-
/** Action to perform */
|
|
46
|
-
action: 'disable_input' | 'enable_input';
|
|
47
|
-
|
|
48
|
-
/** Optional target element identifier */
|
|
49
|
-
target?: string;
|
|
50
|
-
|
|
51
|
-
/** Additional optional parameters */
|
|
52
|
-
[key: string]: unknown;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
/** Room ID to ensure signal is directed to the correct chat window */
|
|
56
|
-
roomId: UUID;
|
|
57
|
-
}
|