@animalabs/agent-framework 0.1.0
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 +21 -0
- package/README.md +233 -0
- package/dist/src/agent.d.ts +130 -0
- package/dist/src/agent.d.ts.map +1 -0
- package/dist/src/agent.js +406 -0
- package/dist/src/agent.js.map +1 -0
- package/dist/src/api/mcp-server.d.ts +37 -0
- package/dist/src/api/mcp-server.d.ts.map +1 -0
- package/dist/src/api/mcp-server.js +598 -0
- package/dist/src/api/mcp-server.js.map +1 -0
- package/dist/src/api/server.d.ts +83 -0
- package/dist/src/api/server.d.ts.map +1 -0
- package/dist/src/api/server.js +785 -0
- package/dist/src/api/server.js.map +1 -0
- package/dist/src/api/types.d.ts +395 -0
- package/dist/src/api/types.d.ts.map +1 -0
- package/dist/src/api/types.js +5 -0
- package/dist/src/api/types.js.map +1 -0
- package/dist/src/framework.d.ts +309 -0
- package/dist/src/framework.d.ts.map +1 -0
- package/dist/src/framework.js +2309 -0
- package/dist/src/framework.js.map +1 -0
- package/dist/src/gate/event-gate.d.ts +75 -0
- package/dist/src/gate/event-gate.d.ts.map +1 -0
- package/dist/src/gate/event-gate.js +503 -0
- package/dist/src/gate/event-gate.js.map +1 -0
- package/dist/src/gate/index.d.ts +3 -0
- package/dist/src/gate/index.d.ts.map +1 -0
- package/dist/src/gate/index.js +2 -0
- package/dist/src/gate/index.js.map +1 -0
- package/dist/src/gate/types.d.ts +82 -0
- package/dist/src/gate/types.d.ts.map +1 -0
- package/dist/src/gate/types.js +9 -0
- package/dist/src/gate/types.js.map +1 -0
- package/dist/src/index.d.ts +17 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +18 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/mcpl/channel-registry.d.ts +141 -0
- package/dist/src/mcpl/channel-registry.d.ts.map +1 -0
- package/dist/src/mcpl/channel-registry.js +647 -0
- package/dist/src/mcpl/channel-registry.js.map +1 -0
- package/dist/src/mcpl/checkpoint-manager.d.ts +79 -0
- package/dist/src/mcpl/checkpoint-manager.d.ts.map +1 -0
- package/dist/src/mcpl/checkpoint-manager.js +430 -0
- package/dist/src/mcpl/checkpoint-manager.js.map +1 -0
- package/dist/src/mcpl/errors.d.ts +52 -0
- package/dist/src/mcpl/errors.d.ts.map +1 -0
- package/dist/src/mcpl/errors.js +93 -0
- package/dist/src/mcpl/errors.js.map +1 -0
- package/dist/src/mcpl/feature-set-manager.d.ts +91 -0
- package/dist/src/mcpl/feature-set-manager.d.ts.map +1 -0
- package/dist/src/mcpl/feature-set-manager.js +250 -0
- package/dist/src/mcpl/feature-set-manager.js.map +1 -0
- package/dist/src/mcpl/hook-orchestrator.d.ts +51 -0
- package/dist/src/mcpl/hook-orchestrator.d.ts.map +1 -0
- package/dist/src/mcpl/hook-orchestrator.js +217 -0
- package/dist/src/mcpl/hook-orchestrator.js.map +1 -0
- package/dist/src/mcpl/index.d.ts +14 -0
- package/dist/src/mcpl/index.d.ts.map +1 -0
- package/dist/src/mcpl/index.js +21 -0
- package/dist/src/mcpl/index.js.map +1 -0
- package/dist/src/mcpl/inference-router.d.ts +67 -0
- package/dist/src/mcpl/inference-router.d.ts.map +1 -0
- package/dist/src/mcpl/inference-router.js +249 -0
- package/dist/src/mcpl/inference-router.js.map +1 -0
- package/dist/src/mcpl/push-handler.d.ts +60 -0
- package/dist/src/mcpl/push-handler.d.ts.map +1 -0
- package/dist/src/mcpl/push-handler.js +162 -0
- package/dist/src/mcpl/push-handler.js.map +1 -0
- package/dist/src/mcpl/scope-manager.d.ts +76 -0
- package/dist/src/mcpl/scope-manager.d.ts.map +1 -0
- package/dist/src/mcpl/scope-manager.js +213 -0
- package/dist/src/mcpl/scope-manager.js.map +1 -0
- package/dist/src/mcpl/server-connection.d.ts +174 -0
- package/dist/src/mcpl/server-connection.d.ts.map +1 -0
- package/dist/src/mcpl/server-connection.js +559 -0
- package/dist/src/mcpl/server-connection.js.map +1 -0
- package/dist/src/mcpl/server-registry.d.ts +63 -0
- package/dist/src/mcpl/server-registry.d.ts.map +1 -0
- package/dist/src/mcpl/server-registry.js +119 -0
- package/dist/src/mcpl/server-registry.js.map +1 -0
- package/dist/src/mcpl/types.d.ts +755 -0
- package/dist/src/mcpl/types.d.ts.map +1 -0
- package/dist/src/mcpl/types.js +48 -0
- package/dist/src/mcpl/types.js.map +1 -0
- package/dist/src/module-registry.d.ts +93 -0
- package/dist/src/module-registry.d.ts.map +1 -0
- package/dist/src/module-registry.js +386 -0
- package/dist/src/module-registry.js.map +1 -0
- package/dist/src/modules/api/index.d.ts +22 -0
- package/dist/src/modules/api/index.d.ts.map +1 -0
- package/dist/src/modules/api/index.js +63 -0
- package/dist/src/modules/api/index.js.map +1 -0
- package/dist/src/modules/discord/discord-js-client.d.ts +58 -0
- package/dist/src/modules/discord/discord-js-client.d.ts.map +1 -0
- package/dist/src/modules/discord/discord-js-client.js +273 -0
- package/dist/src/modules/discord/discord-js-client.js.map +1 -0
- package/dist/src/modules/discord/index.d.ts +82 -0
- package/dist/src/modules/discord/index.d.ts.map +1 -0
- package/dist/src/modules/discord/index.js +959 -0
- package/dist/src/modules/discord/index.js.map +1 -0
- package/dist/src/modules/discord/types.d.ts +327 -0
- package/dist/src/modules/discord/types.d.ts.map +1 -0
- package/dist/src/modules/discord/types.js +5 -0
- package/dist/src/modules/discord/types.js.map +1 -0
- package/dist/src/modules/index.d.ts +11 -0
- package/dist/src/modules/index.d.ts.map +1 -0
- package/dist/src/modules/index.js +7 -0
- package/dist/src/modules/index.js.map +1 -0
- package/dist/src/modules/workspace/index.d.ts +59 -0
- package/dist/src/modules/workspace/index.d.ts.map +1 -0
- package/dist/src/modules/workspace/index.js +831 -0
- package/dist/src/modules/workspace/index.js.map +1 -0
- package/dist/src/modules/workspace/sync.d.ts +48 -0
- package/dist/src/modules/workspace/sync.d.ts.map +1 -0
- package/dist/src/modules/workspace/sync.js +253 -0
- package/dist/src/modules/workspace/sync.js.map +1 -0
- package/dist/src/modules/workspace/types.d.ts +166 -0
- package/dist/src/modules/workspace/types.d.ts.map +1 -0
- package/dist/src/modules/workspace/types.js +5 -0
- package/dist/src/modules/workspace/types.js.map +1 -0
- package/dist/src/modules/workspace/watcher.d.ts +43 -0
- package/dist/src/modules/workspace/watcher.d.ts.map +1 -0
- package/dist/src/modules/workspace/watcher.js +120 -0
- package/dist/src/modules/workspace/watcher.js.map +1 -0
- package/dist/src/queue.d.ts +50 -0
- package/dist/src/queue.d.ts.map +1 -0
- package/dist/src/queue.js +95 -0
- package/dist/src/queue.js.map +1 -0
- package/dist/src/safe-slice.d.ts +8 -0
- package/dist/src/safe-slice.d.ts.map +1 -0
- package/dist/src/safe-slice.js +18 -0
- package/dist/src/safe-slice.js.map +1 -0
- package/dist/src/types/agent.d.ts +118 -0
- package/dist/src/types/agent.d.ts.map +1 -0
- package/dist/src/types/agent.js +2 -0
- package/dist/src/types/agent.js.map +1 -0
- package/dist/src/types/events.d.ts +220 -0
- package/dist/src/types/events.d.ts.map +1 -0
- package/dist/src/types/events.js +2 -0
- package/dist/src/types/events.js.map +1 -0
- package/dist/src/types/framework.d.ts +184 -0
- package/dist/src/types/framework.d.ts.map +1 -0
- package/dist/src/types/framework.js +2 -0
- package/dist/src/types/framework.js.map +1 -0
- package/dist/src/types/index.d.ts +7 -0
- package/dist/src/types/index.d.ts.map +1 -0
- package/dist/src/types/index.js +7 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/types/inference-log.d.ts +64 -0
- package/dist/src/types/inference-log.d.ts.map +1 -0
- package/dist/src/types/inference-log.js +5 -0
- package/dist/src/types/inference-log.js.map +1 -0
- package/dist/src/types/module.d.ts +302 -0
- package/dist/src/types/module.d.ts.map +1 -0
- package/dist/src/types/module.js +2 -0
- package/dist/src/types/module.js.map +1 -0
- package/dist/src/types/trace.d.ts +173 -0
- package/dist/src/types/trace.d.ts.map +1 -0
- package/dist/src/types/trace.js +2 -0
- package/dist/src/types/trace.js.map +1 -0
- package/dist/test/event-gate.test.d.ts +2 -0
- package/dist/test/event-gate.test.d.ts.map +1 -0
- package/dist/test/event-gate.test.js +535 -0
- package/dist/test/event-gate.test.js.map +1 -0
- package/dist/test/framework.test.d.ts +5 -0
- package/dist/test/framework.test.d.ts.map +1 -0
- package/dist/test/framework.test.js +738 -0
- package/dist/test/framework.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +58 -0
- package/src/agent.ts +512 -0
- package/src/api/mcp-server.ts +687 -0
- package/src/api/server.ts +1023 -0
- package/src/api/types.ts +542 -0
- package/src/framework.ts +2784 -0
- package/src/gate/event-gate.ts +623 -0
- package/src/gate/index.ts +12 -0
- package/src/gate/types.ts +112 -0
- package/src/index.ts +63 -0
- package/src/mcpl/channel-registry.ts +824 -0
- package/src/mcpl/checkpoint-manager.ts +545 -0
- package/src/mcpl/errors.ts +114 -0
- package/src/mcpl/feature-set-manager.ts +333 -0
- package/src/mcpl/hook-orchestrator.ts +281 -0
- package/src/mcpl/index.ts +134 -0
- package/src/mcpl/inference-router.ts +335 -0
- package/src/mcpl/push-handler.ts +232 -0
- package/src/mcpl/scope-manager.ts +262 -0
- package/src/mcpl/server-connection.ts +694 -0
- package/src/mcpl/server-registry.ts +144 -0
- package/src/mcpl/types.ts +991 -0
- package/src/module-registry.ts +547 -0
- package/src/modules/api/index.ts +94 -0
- package/src/modules/discord/discord-js-client.ts +353 -0
- package/src/modules/discord/index.ts +1146 -0
- package/src/modules/discord/types.ts +465 -0
- package/src/modules/index.ts +43 -0
- package/src/modules/workspace/index.ts +969 -0
- package/src/modules/workspace/sync.ts +314 -0
- package/src/modules/workspace/types.ts +202 -0
- package/src/modules/workspace/watcher.ts +142 -0
- package/src/queue.ts +106 -0
- package/src/safe-slice.ts +18 -0
- package/src/types/agent.ts +119 -0
- package/src/types/events.ts +252 -0
- package/src/types/framework.ts +211 -0
- package/src/types/index.ts +6 -0
- package/src/types/inference-log.ts +64 -0
- package/src/types/module.ts +367 -0
- package/src/types/trace.ts +196 -0
|
@@ -0,0 +1,465 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for the Discord module
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { ContentBlock } from '@animalabs/membrane';
|
|
6
|
+
|
|
7
|
+
// ============================================================================
|
|
8
|
+
// Module Configuration
|
|
9
|
+
// ============================================================================
|
|
10
|
+
|
|
11
|
+
export interface DiscordModuleConfig {
|
|
12
|
+
/** Discord bot token */
|
|
13
|
+
token: string;
|
|
14
|
+
|
|
15
|
+
/** Guild IDs to listen to (optional, defaults to all guilds the bot is in) */
|
|
16
|
+
guildIds?: string[];
|
|
17
|
+
|
|
18
|
+
/** Channel IDs to listen to (optional, defaults to all channels) */
|
|
19
|
+
channelIds?: string[];
|
|
20
|
+
|
|
21
|
+
/** Whether to handle DMs (default: true) */
|
|
22
|
+
handleDMs?: boolean;
|
|
23
|
+
|
|
24
|
+
/** Prefix for commands (optional, e.g., '!' or '/') */
|
|
25
|
+
commandPrefix?: string;
|
|
26
|
+
|
|
27
|
+
/** Whether to ignore bot messages (default: true) */
|
|
28
|
+
ignoreBots?: boolean;
|
|
29
|
+
|
|
30
|
+
/** Rate limit: max messages per minute per channel (default: 30) */
|
|
31
|
+
rateLimitPerMinute?: number;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* When to trigger agent inference (default: 'mention')
|
|
35
|
+
* - 'all': Every message triggers inference (use with caution!)
|
|
36
|
+
* - 'mention': Only when bot is @mentioned
|
|
37
|
+
* - 'mention_or_reply': When mentioned OR when replying to bot's message
|
|
38
|
+
* - 'dm_or_mention': DMs always trigger, channels require mention
|
|
39
|
+
*/
|
|
40
|
+
triggerOn?: 'all' | 'mention' | 'mention_or_reply' | 'dm_or_mention';
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Auto-send typing indicator when agent is activated (default: true)
|
|
44
|
+
*/
|
|
45
|
+
autoTyping?: boolean;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Number of messages to fetch on history sync (default: 50)
|
|
49
|
+
*/
|
|
50
|
+
historyScrollback?: number;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// ============================================================================
|
|
54
|
+
// Module State
|
|
55
|
+
// ============================================================================
|
|
56
|
+
|
|
57
|
+
export interface DiscordModuleState {
|
|
58
|
+
/** Currently connected guild IDs */
|
|
59
|
+
connectedGuilds: string[];
|
|
60
|
+
|
|
61
|
+
/** Active conversation contexts */
|
|
62
|
+
conversations: Record<string, ConversationContext>;
|
|
63
|
+
|
|
64
|
+
/** Rate limit tracking */
|
|
65
|
+
rateLimits: Record<string, RateLimitInfo>;
|
|
66
|
+
|
|
67
|
+
/** Bot user ID (set after connect) */
|
|
68
|
+
botUserId?: string;
|
|
69
|
+
|
|
70
|
+
/** Last read message ID per channel (for history sync) */
|
|
71
|
+
lastReadMessageId: Record<string, string>;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface ConversationContext {
|
|
75
|
+
/** Channel ID for replies */
|
|
76
|
+
channelId: string;
|
|
77
|
+
|
|
78
|
+
/** Thread ID if in a thread */
|
|
79
|
+
threadId?: string;
|
|
80
|
+
|
|
81
|
+
/** Message ID to reply to */
|
|
82
|
+
replyToMessageId?: string;
|
|
83
|
+
|
|
84
|
+
/** User who started the conversation */
|
|
85
|
+
userId: string;
|
|
86
|
+
|
|
87
|
+
/** Guild ID (null for DMs) */
|
|
88
|
+
guildId: string | null;
|
|
89
|
+
|
|
90
|
+
/** Last activity timestamp */
|
|
91
|
+
lastActivity: number;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface RateLimitInfo {
|
|
95
|
+
/** Messages sent in current window */
|
|
96
|
+
count: number;
|
|
97
|
+
|
|
98
|
+
/** Window start timestamp */
|
|
99
|
+
windowStart: number;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// ============================================================================
|
|
103
|
+
// Tool Inputs
|
|
104
|
+
// ============================================================================
|
|
105
|
+
|
|
106
|
+
export interface SendInput {
|
|
107
|
+
/** Channel ID to send to */
|
|
108
|
+
channelId: string;
|
|
109
|
+
|
|
110
|
+
/** Content to send */
|
|
111
|
+
content: string;
|
|
112
|
+
|
|
113
|
+
/** Whether to create a thread (optional) */
|
|
114
|
+
createThread?: {
|
|
115
|
+
name: string;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
/** Message ID to reply to (optional) */
|
|
119
|
+
replyTo?: string;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface SendDMInput {
|
|
123
|
+
/** User ID to DM */
|
|
124
|
+
userId: string;
|
|
125
|
+
|
|
126
|
+
/** Content to send */
|
|
127
|
+
content: string;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export interface ReplyInput {
|
|
131
|
+
/** Content to send */
|
|
132
|
+
content: string;
|
|
133
|
+
|
|
134
|
+
/** Whether to mention the user (default: false) */
|
|
135
|
+
mention?: boolean;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export interface ReactInput {
|
|
139
|
+
/** Channel ID containing the message */
|
|
140
|
+
channelId: string;
|
|
141
|
+
|
|
142
|
+
/** Message ID to react to */
|
|
143
|
+
messageId: string;
|
|
144
|
+
|
|
145
|
+
/** Emoji to react with (unicode or custom emoji ID) */
|
|
146
|
+
emoji: string;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export interface EditMessageInput {
|
|
150
|
+
/** Channel ID containing the message */
|
|
151
|
+
channelId: string;
|
|
152
|
+
|
|
153
|
+
/** Message ID to edit */
|
|
154
|
+
messageId: string;
|
|
155
|
+
|
|
156
|
+
/** New content */
|
|
157
|
+
content: string;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export interface DeleteMessageInput {
|
|
161
|
+
/** Channel ID containing the message */
|
|
162
|
+
channelId: string;
|
|
163
|
+
|
|
164
|
+
/** Message ID to delete */
|
|
165
|
+
messageId: string;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export interface CreateThreadInput {
|
|
169
|
+
/** Channel ID to create thread in */
|
|
170
|
+
channelId: string;
|
|
171
|
+
|
|
172
|
+
/** Message ID to start thread from */
|
|
173
|
+
messageId: string;
|
|
174
|
+
|
|
175
|
+
/** Thread name */
|
|
176
|
+
name: string;
|
|
177
|
+
|
|
178
|
+
/** Auto-archive duration in minutes (60, 1440, 4320, 10080) */
|
|
179
|
+
autoArchiveDuration?: 60 | 1440 | 4320 | 10080;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export interface SetReplyContextInput {
|
|
183
|
+
/** Channel ID for future replies */
|
|
184
|
+
channelId: string;
|
|
185
|
+
|
|
186
|
+
/** Thread ID (optional) */
|
|
187
|
+
threadId?: string;
|
|
188
|
+
|
|
189
|
+
/** Message ID to reply to (optional) */
|
|
190
|
+
replyToMessageId?: string;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export interface ListGuildsInput {
|
|
194
|
+
// No parameters needed
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export interface ListChannelsInput {
|
|
198
|
+
/** Guild ID to list channels for */
|
|
199
|
+
guildId: string;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export interface FetchHistoryInput {
|
|
203
|
+
/** Channel ID to fetch history from */
|
|
204
|
+
channelId: string;
|
|
205
|
+
|
|
206
|
+
/** Number of messages to fetch (default: 50) */
|
|
207
|
+
limit?: number;
|
|
208
|
+
|
|
209
|
+
/** Fetch messages before this message ID */
|
|
210
|
+
before?: string;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// ============================================================================
|
|
214
|
+
// Discord Data Types (returned by tools)
|
|
215
|
+
// ============================================================================
|
|
216
|
+
|
|
217
|
+
export interface DiscordGuild {
|
|
218
|
+
/** Guild ID */
|
|
219
|
+
id: string;
|
|
220
|
+
|
|
221
|
+
/** Guild name */
|
|
222
|
+
name: string;
|
|
223
|
+
|
|
224
|
+
/** Guild icon URL (optional) */
|
|
225
|
+
iconUrl?: string;
|
|
226
|
+
|
|
227
|
+
/** Number of members */
|
|
228
|
+
memberCount?: number;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export interface DiscordChannel {
|
|
232
|
+
/** Channel ID */
|
|
233
|
+
id: string;
|
|
234
|
+
|
|
235
|
+
/** Channel name */
|
|
236
|
+
name: string;
|
|
237
|
+
|
|
238
|
+
/** Channel type */
|
|
239
|
+
type: 'text' | 'voice' | 'category' | 'thread' | 'forum' | 'unknown';
|
|
240
|
+
|
|
241
|
+
/** Parent category ID (if applicable) */
|
|
242
|
+
parentId?: string;
|
|
243
|
+
|
|
244
|
+
/** Position in channel list */
|
|
245
|
+
position?: number;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export interface HistoryMessage {
|
|
249
|
+
/** Message ID */
|
|
250
|
+
id: string;
|
|
251
|
+
|
|
252
|
+
/** Author user ID */
|
|
253
|
+
authorId: string;
|
|
254
|
+
|
|
255
|
+
/** Author username */
|
|
256
|
+
authorName: string;
|
|
257
|
+
|
|
258
|
+
/** Whether author is a bot */
|
|
259
|
+
isBot: boolean;
|
|
260
|
+
|
|
261
|
+
/** Message content */
|
|
262
|
+
content: string;
|
|
263
|
+
|
|
264
|
+
/** Timestamp */
|
|
265
|
+
timestamp: Date;
|
|
266
|
+
|
|
267
|
+
/** Reply info (if this is a reply) */
|
|
268
|
+
replyTo?: {
|
|
269
|
+
messageId: string;
|
|
270
|
+
authorId: string;
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// ============================================================================
|
|
275
|
+
// Discord Events (internal)
|
|
276
|
+
// ============================================================================
|
|
277
|
+
|
|
278
|
+
export interface DiscordMessageData {
|
|
279
|
+
/** Discord message ID */
|
|
280
|
+
id: string;
|
|
281
|
+
|
|
282
|
+
/** Channel ID */
|
|
283
|
+
channelId: string;
|
|
284
|
+
|
|
285
|
+
/** Guild ID (null for DMs) */
|
|
286
|
+
guildId: string | null;
|
|
287
|
+
|
|
288
|
+
/** Author user ID */
|
|
289
|
+
authorId: string;
|
|
290
|
+
|
|
291
|
+
/** Author username */
|
|
292
|
+
authorName: string;
|
|
293
|
+
|
|
294
|
+
/** Whether the author is a bot */
|
|
295
|
+
isBot: boolean;
|
|
296
|
+
|
|
297
|
+
/** Message content */
|
|
298
|
+
content: string;
|
|
299
|
+
|
|
300
|
+
/** Whether this is a reply */
|
|
301
|
+
isReply: boolean;
|
|
302
|
+
|
|
303
|
+
/** ID of message being replied to */
|
|
304
|
+
replyToId?: string;
|
|
305
|
+
|
|
306
|
+
/** Author ID of the message being replied to */
|
|
307
|
+
replyToAuthorId?: string;
|
|
308
|
+
|
|
309
|
+
/** User IDs mentioned in this message */
|
|
310
|
+
mentionedUserIds: string[];
|
|
311
|
+
|
|
312
|
+
/** Attachments */
|
|
313
|
+
attachments: DiscordAttachment[];
|
|
314
|
+
|
|
315
|
+
/** Timestamp */
|
|
316
|
+
timestamp: Date;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
export interface DiscordAttachment {
|
|
320
|
+
/** Attachment ID */
|
|
321
|
+
id: string;
|
|
322
|
+
|
|
323
|
+
/** Filename */
|
|
324
|
+
filename: string;
|
|
325
|
+
|
|
326
|
+
/** URL */
|
|
327
|
+
url: string;
|
|
328
|
+
|
|
329
|
+
/** Content type */
|
|
330
|
+
contentType?: string;
|
|
331
|
+
|
|
332
|
+
/** Size in bytes */
|
|
333
|
+
size: number;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// ============================================================================
|
|
337
|
+
// Discord Custom Events (for event queue)
|
|
338
|
+
// ============================================================================
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Custom event for new Discord messages.
|
|
342
|
+
* Pushed to queue by callbacks, processed in onProcess().
|
|
343
|
+
*/
|
|
344
|
+
export interface DiscordMessageEvent {
|
|
345
|
+
type: 'discord:message';
|
|
346
|
+
discordMessageId: string;
|
|
347
|
+
channelId: string;
|
|
348
|
+
guildId: string | null;
|
|
349
|
+
authorId: string;
|
|
350
|
+
authorName: string;
|
|
351
|
+
content: string;
|
|
352
|
+
/** Pre-converted content blocks (includes attachments) */
|
|
353
|
+
contentBlocks?: ContentBlock[];
|
|
354
|
+
timestamp: number;
|
|
355
|
+
attachments: DiscordAttachment[];
|
|
356
|
+
/** Whether this message should trigger agent inference */
|
|
357
|
+
shouldTriggerInference?: boolean;
|
|
358
|
+
[key: string]: unknown; // Required for CustomEvent compatibility
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Custom event for Discord message edits.
|
|
363
|
+
*/
|
|
364
|
+
export interface DiscordEditEvent {
|
|
365
|
+
type: 'discord:edit';
|
|
366
|
+
discordMessageId: string;
|
|
367
|
+
newContent: string;
|
|
368
|
+
[key: string]: unknown;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Custom event for Discord message deletions.
|
|
373
|
+
*/
|
|
374
|
+
export interface DiscordDeleteEvent {
|
|
375
|
+
type: 'discord:delete';
|
|
376
|
+
discordMessageId: string;
|
|
377
|
+
[key: string]: unknown;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Union of all Discord custom events.
|
|
382
|
+
*/
|
|
383
|
+
export type DiscordEvent = DiscordMessageEvent | DiscordEditEvent | DiscordDeleteEvent;
|
|
384
|
+
|
|
385
|
+
// ============================================================================
|
|
386
|
+
// Discord Client Interface (for abstraction)
|
|
387
|
+
// ============================================================================
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Abstract interface for Discord client operations.
|
|
391
|
+
* Allows for real discord.js client or mock for testing.
|
|
392
|
+
*/
|
|
393
|
+
export interface DiscordClientInterface {
|
|
394
|
+
/** Connect to Discord */
|
|
395
|
+
connect(): Promise<void>;
|
|
396
|
+
|
|
397
|
+
/** Disconnect from Discord */
|
|
398
|
+
disconnect(): Promise<void>;
|
|
399
|
+
|
|
400
|
+
/** Get the bot's user ID (available after connect) */
|
|
401
|
+
getBotUserId(): string | null;
|
|
402
|
+
|
|
403
|
+
/** Send a message to a channel */
|
|
404
|
+
sendMessage(
|
|
405
|
+
channelId: string,
|
|
406
|
+
content: string,
|
|
407
|
+
options?: {
|
|
408
|
+
replyTo?: string;
|
|
409
|
+
createThread?: { name: string };
|
|
410
|
+
}
|
|
411
|
+
): Promise<{ messageId: string }>;
|
|
412
|
+
|
|
413
|
+
/** Send a DM to a user */
|
|
414
|
+
sendDM(userId: string, content: string): Promise<{ messageId: string }>;
|
|
415
|
+
|
|
416
|
+
/** Fetch a message's text content */
|
|
417
|
+
fetchMessage(channelId: string, messageId: string): Promise<string>;
|
|
418
|
+
|
|
419
|
+
/** Edit a message */
|
|
420
|
+
editMessage(channelId: string, messageId: string, content: string): Promise<void>;
|
|
421
|
+
|
|
422
|
+
/** Delete a message */
|
|
423
|
+
deleteMessage(channelId: string, messageId: string): Promise<void>;
|
|
424
|
+
|
|
425
|
+
/** Add a reaction */
|
|
426
|
+
addReaction(channelId: string, messageId: string, emoji: string): Promise<void>;
|
|
427
|
+
|
|
428
|
+
/** Create a thread */
|
|
429
|
+
createThread(
|
|
430
|
+
channelId: string,
|
|
431
|
+
messageId: string,
|
|
432
|
+
name: string,
|
|
433
|
+
autoArchiveDuration?: number
|
|
434
|
+
): Promise<{ threadId: string }>;
|
|
435
|
+
|
|
436
|
+
/** Send typing indicator to a channel */
|
|
437
|
+
sendTyping(channelId: string): Promise<void>;
|
|
438
|
+
|
|
439
|
+
/** List guilds the bot is in */
|
|
440
|
+
listGuilds(): Promise<DiscordGuild[]>;
|
|
441
|
+
|
|
442
|
+
/** List channels in a guild */
|
|
443
|
+
listChannels(guildId: string): Promise<DiscordChannel[]>;
|
|
444
|
+
|
|
445
|
+
/** Fetch message history from a channel */
|
|
446
|
+
fetchHistory(
|
|
447
|
+
channelId: string,
|
|
448
|
+
options?: { limit?: number; before?: string }
|
|
449
|
+
): Promise<HistoryMessage[]>;
|
|
450
|
+
|
|
451
|
+
/** Register message handler */
|
|
452
|
+
onMessage(handler: (message: DiscordMessageData) => void): void;
|
|
453
|
+
|
|
454
|
+
/** Register message edit handler */
|
|
455
|
+
onMessageEdit(handler: (messageId: string, newContent: string) => void): void;
|
|
456
|
+
|
|
457
|
+
/** Register message delete handler */
|
|
458
|
+
onMessageDelete(handler: (messageId: string) => void): void;
|
|
459
|
+
|
|
460
|
+
/** Register ready handler (called when connected and ready) */
|
|
461
|
+
onReady?(handler: () => void): void;
|
|
462
|
+
|
|
463
|
+
/** Check if connected */
|
|
464
|
+
isConnected(): boolean;
|
|
465
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in modules for the agent framework
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export { ApiModule } from './api/index.js';
|
|
6
|
+
export type { ApiEvent } from './api/index.js';
|
|
7
|
+
|
|
8
|
+
export { WorkspaceModule } from './workspace/index.js';
|
|
9
|
+
export type {
|
|
10
|
+
WorkspaceConfig,
|
|
11
|
+
MountConfig,
|
|
12
|
+
MountState,
|
|
13
|
+
WorkspaceModuleState,
|
|
14
|
+
ReadInput,
|
|
15
|
+
WriteInput,
|
|
16
|
+
EditInput,
|
|
17
|
+
DeleteInput,
|
|
18
|
+
LsInput,
|
|
19
|
+
GlobInput,
|
|
20
|
+
GrepInput,
|
|
21
|
+
StatusInput,
|
|
22
|
+
MaterializeInput,
|
|
23
|
+
SyncInput,
|
|
24
|
+
} from './workspace/index.js';
|
|
25
|
+
|
|
26
|
+
export { DiscordModule, DiscordJsClient } from './discord/index.js';
|
|
27
|
+
export type { DiscordJsClientConfig } from './discord/index.js';
|
|
28
|
+
export type {
|
|
29
|
+
DiscordModuleConfig,
|
|
30
|
+
DiscordModuleState,
|
|
31
|
+
ConversationContext,
|
|
32
|
+
DiscordClientInterface,
|
|
33
|
+
DiscordMessageData,
|
|
34
|
+
DiscordAttachment,
|
|
35
|
+
SendInput as DiscordSendInput,
|
|
36
|
+
SendDMInput,
|
|
37
|
+
ReplyInput,
|
|
38
|
+
ReactInput,
|
|
39
|
+
EditMessageInput,
|
|
40
|
+
DeleteMessageInput,
|
|
41
|
+
CreateThreadInput,
|
|
42
|
+
SetReplyContextInput,
|
|
43
|
+
} from './discord/index.js';
|