@cogitator-ai/channels 0.2.1
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 +349 -0
- package/dist/assistant-config.d.ts +92 -0
- package/dist/assistant-config.d.ts.map +1 -0
- package/dist/assistant-config.js +89 -0
- package/dist/assistant-config.js.map +1 -0
- package/dist/capabilities.d.ts +14 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +28 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/channels/discord.d.ts +26 -0
- package/dist/channels/discord.d.ts.map +1 -0
- package/dist/channels/discord.js +153 -0
- package/dist/channels/discord.js.map +1 -0
- package/dist/channels/slack.d.ts +23 -0
- package/dist/channels/slack.d.ts.map +1 -0
- package/dist/channels/slack.js +89 -0
- package/dist/channels/slack.js.map +1 -0
- package/dist/channels/telegram.d.ts +30 -0
- package/dist/channels/telegram.d.ts.map +1 -0
- package/dist/channels/telegram.js +236 -0
- package/dist/channels/telegram.js.map +1 -0
- package/dist/channels/terminal.d.ts +30 -0
- package/dist/channels/terminal.d.ts.map +1 -0
- package/dist/channels/terminal.js +110 -0
- package/dist/channels/terminal.js.map +1 -0
- package/dist/channels/webchat.d.ts +24 -0
- package/dist/channels/webchat.d.ts.map +1 -0
- package/dist/channels/webchat.js +106 -0
- package/dist/channels/webchat.js.map +1 -0
- package/dist/channels/whatsapp.d.ts +28 -0
- package/dist/channels/whatsapp.d.ts.map +1 -0
- package/dist/channels/whatsapp.js +117 -0
- package/dist/channels/whatsapp.js.map +1 -0
- package/dist/envelope.d.ts +4 -0
- package/dist/envelope.d.ts.map +1 -0
- package/dist/envelope.js +64 -0
- package/dist/envelope.js.map +1 -0
- package/dist/formatters/discord-chunker.d.ts +6 -0
- package/dist/formatters/discord-chunker.d.ts.map +1 -0
- package/dist/formatters/discord-chunker.js +169 -0
- package/dist/formatters/discord-chunker.js.map +1 -0
- package/dist/formatters/markdown.d.ts +5 -0
- package/dist/formatters/markdown.d.ts.map +1 -0
- package/dist/formatters/markdown.js +59 -0
- package/dist/formatters/markdown.js.map +1 -0
- package/dist/formatters/whatsapp-markdown.d.ts +2 -0
- package/dist/formatters/whatsapp-markdown.d.ts.map +1 -0
- package/dist/formatters/whatsapp-markdown.js +26 -0
- package/dist/formatters/whatsapp-markdown.js.map +1 -0
- package/dist/gateway.d.ts +38 -0
- package/dist/gateway.d.ts.map +1 -0
- package/dist/gateway.js +347 -0
- package/dist/gateway.js.map +1 -0
- package/dist/heartbeat.d.ts +28 -0
- package/dist/heartbeat.d.ts.map +1 -0
- package/dist/heartbeat.js +143 -0
- package/dist/heartbeat.js.map +1 -0
- package/dist/hooks.d.ts +4 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +30 -0
- package/dist/hooks.js.map +1 -0
- package/dist/inbound-debounce.d.ts +13 -0
- package/dist/inbound-debounce.d.ts.map +1 -0
- package/dist/inbound-debounce.js +61 -0
- package/dist/inbound-debounce.js.map +1 -0
- package/dist/index.d.ts +54 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -0
- package/dist/media/deepgram-stt.d.ts +14 -0
- package/dist/media/deepgram-stt.d.ts.map +1 -0
- package/dist/media/deepgram-stt.js +30 -0
- package/dist/media/deepgram-stt.js.map +1 -0
- package/dist/media/index.d.ts +7 -0
- package/dist/media/index.d.ts.map +1 -0
- package/dist/media/index.js +5 -0
- package/dist/media/index.js.map +1 -0
- package/dist/media/media-processor.d.ts +20 -0
- package/dist/media/media-processor.d.ts.map +1 -0
- package/dist/media/media-processor.js +80 -0
- package/dist/media/media-processor.js.map +1 -0
- package/dist/media/whisper-api.d.ts +22 -0
- package/dist/media/whisper-api.d.ts.map +1 -0
- package/dist/media/whisper-api.js +53 -0
- package/dist/media/whisper-api.js.map +1 -0
- package/dist/media/whisper-local.d.ts +16 -0
- package/dist/media/whisper-local.d.ts.map +1 -0
- package/dist/media/whisper-local.js +155 -0
- package/dist/media/whisper-local.js.map +1 -0
- package/dist/media/whisper-tool.d.ts +4 -0
- package/dist/media/whisper-tool.d.ts.map +1 -0
- package/dist/media/whisper-tool.js +19 -0
- package/dist/media/whisper-tool.js.map +1 -0
- package/dist/message-queue.d.ts +17 -0
- package/dist/message-queue.d.ts.map +1 -0
- package/dist/message-queue.js +115 -0
- package/dist/message-queue.js.map +1 -0
- package/dist/middleware/auto-extract.d.ts +36 -0
- package/dist/middleware/auto-extract.d.ts.map +1 -0
- package/dist/middleware/auto-extract.js +73 -0
- package/dist/middleware/auto-extract.js.map +1 -0
- package/dist/middleware/dm-policy.d.ts +39 -0
- package/dist/middleware/dm-policy.d.ts.map +1 -0
- package/dist/middleware/dm-policy.js +177 -0
- package/dist/middleware/dm-policy.js.map +1 -0
- package/dist/middleware/owner-commands.d.ts +25 -0
- package/dist/middleware/owner-commands.d.ts.map +1 -0
- package/dist/middleware/owner-commands.js +131 -0
- package/dist/middleware/owner-commands.js.map +1 -0
- package/dist/middleware/pairing.d.ts +20 -0
- package/dist/middleware/pairing.d.ts.map +1 -0
- package/dist/middleware/pairing.js +70 -0
- package/dist/middleware/pairing.js.map +1 -0
- package/dist/middleware/rate-limit.d.ts +14 -0
- package/dist/middleware/rate-limit.d.ts.map +1 -0
- package/dist/middleware/rate-limit.js +31 -0
- package/dist/middleware/rate-limit.js.map +1 -0
- package/dist/runtime-builder.d.ts +42 -0
- package/dist/runtime-builder.d.ts.map +1 -0
- package/dist/runtime-builder.js +607 -0
- package/dist/runtime-builder.js.map +1 -0
- package/dist/simple-timer-store.d.ts +28 -0
- package/dist/simple-timer-store.d.ts.map +1 -0
- package/dist/simple-timer-store.js +129 -0
- package/dist/simple-timer-store.js.map +1 -0
- package/dist/status-reactions.d.ts +22 -0
- package/dist/status-reactions.d.ts.map +1 -0
- package/dist/status-reactions.js +86 -0
- package/dist/status-reactions.js.map +1 -0
- package/dist/stream-buffer.d.ts +31 -0
- package/dist/stream-buffer.d.ts.map +1 -0
- package/dist/stream-buffer.js +170 -0
- package/dist/stream-buffer.js.map +1 -0
- package/dist/tools/self-config.d.ts +9 -0
- package/dist/tools/self-config.d.ts.map +1 -0
- package/dist/tools/self-config.js +122 -0
- package/dist/tools/self-config.js.map +1 -0
- package/package.json +102 -0
package/README.md
ADDED
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
# @cogitator-ai/channels
|
|
2
|
+
|
|
3
|
+
Connect Cogitator agents to messaging platforms. Gateway routes messages across channels, handles sessions, streaming, media, and middleware.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @cogitator-ai/channels
|
|
9
|
+
|
|
10
|
+
# Then install the adapters you need:
|
|
11
|
+
pnpm add grammy # Telegram
|
|
12
|
+
pnpm add discord.js # Discord
|
|
13
|
+
pnpm add @slack/bolt # Slack
|
|
14
|
+
pnpm add @whiskeysockets/baileys # WhatsApp
|
|
15
|
+
pnpm add ws # WebChat
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Quick Start
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
import { Cogitator, Agent } from '@cogitator-ai/core';
|
|
22
|
+
import { Gateway, telegramChannel } from '@cogitator-ai/channels';
|
|
23
|
+
|
|
24
|
+
const cogitator = new Cogitator({ llm: { defaultModel: 'google/gemini-2.5-flash' } });
|
|
25
|
+
const agent = new Agent({ name: 'bot', instructions: 'You are a helpful assistant.' });
|
|
26
|
+
|
|
27
|
+
const gateway = new Gateway({
|
|
28
|
+
cogitator,
|
|
29
|
+
agent,
|
|
30
|
+
channels: [telegramChannel({ token: process.env.TG_TOKEN! })],
|
|
31
|
+
stream: { flushInterval: 500, minChunkSize: 20 },
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
await gateway.start();
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Channels
|
|
38
|
+
|
|
39
|
+
### Telegram
|
|
40
|
+
|
|
41
|
+
**Get your token:** Open Telegram → search `@BotFather` → send `/newbot` → follow prompts → copy the token.
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import { telegramChannel } from '@cogitator-ai/channels';
|
|
45
|
+
|
|
46
|
+
telegramChannel({ token: process.env.TG_TOKEN! });
|
|
47
|
+
|
|
48
|
+
// Webhook mode (production):
|
|
49
|
+
telegramChannel({
|
|
50
|
+
token: process.env.TG_TOKEN!,
|
|
51
|
+
webhook: { url: 'https://example.com/telegram', port: 8443 },
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Supports: text, photos (→ vision), voice (→ STT), documents, streaming via editText, emoji reactions, 4096 char limit.
|
|
56
|
+
|
|
57
|
+
### Discord
|
|
58
|
+
|
|
59
|
+
**Get your token:** [Discord Developer Portal](https://discord.com/developers/applications) → New Application → Bot → Reset Token → copy it. **Enable "Message Content Intent"** under Privileged Gateway Intents. Invite via OAuth2 URL Generator with `bot` scope + `Send Messages`, `Read Message History`, `Add Reactions` permissions.
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
import { discordChannel } from '@cogitator-ai/channels';
|
|
63
|
+
|
|
64
|
+
discordChannel({
|
|
65
|
+
token: process.env.DISCORD_TOKEN!,
|
|
66
|
+
mentionOnly: true, // only respond when @mentioned in servers
|
|
67
|
+
});
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Supports: DMs, server messages, streaming, reactions, auto-chunking (2000 char limit, code-block aware).
|
|
71
|
+
|
|
72
|
+
### Slack
|
|
73
|
+
|
|
74
|
+
**Get your tokens (3 total):**
|
|
75
|
+
|
|
76
|
+
1. [api.slack.com/apps](https://api.slack.com/apps) → Create New App → From scratch
|
|
77
|
+
2. Socket Mode → enable → generate App Token (`xapp-...`) → save as `SLACK_APP_TOKEN`
|
|
78
|
+
3. OAuth & Permissions → add scopes: `chat:write`, `app_mentions:read`, `im:history`, `im:read`, `im:write`
|
|
79
|
+
4. Event Subscriptions → enable → add: `message.im`, `app_mention`
|
|
80
|
+
5. Install App → copy Bot Token (`xoxb-...`) → save as `SLACK_BOT_TOKEN`
|
|
81
|
+
6. Basic Information → copy Signing Secret → save as `SLACK_SIGNING_SECRET`
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
import { slackChannel } from '@cogitator-ai/channels';
|
|
85
|
+
|
|
86
|
+
slackChannel({
|
|
87
|
+
token: process.env.SLACK_BOT_TOKEN!,
|
|
88
|
+
signingSecret: process.env.SLACK_SIGNING_SECRET!,
|
|
89
|
+
appToken: process.env.SLACK_APP_TOKEN!,
|
|
90
|
+
});
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Supports: DMs, channel messages (via @mention), Socket Mode (no public URL), streaming via chat.update.
|
|
94
|
+
|
|
95
|
+
### WhatsApp
|
|
96
|
+
|
|
97
|
+
No bot API — connects as a linked device to your WhatsApp account (like WhatsApp Web).
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
import { whatsappChannel } from '@cogitator-ai/channels';
|
|
101
|
+
|
|
102
|
+
whatsappChannel({
|
|
103
|
+
sessionPath: '.cogitator/whatsapp-session',
|
|
104
|
+
printQr: true,
|
|
105
|
+
});
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**First run:** QR code prints to terminal → scan from WhatsApp → Settings → Linked Devices. Session is saved for future restarts.
|
|
109
|
+
|
|
110
|
+
Supports: 1-on-1 and group chats, typing indicators, auto-reconnect, WhatsApp-native markdown. No streaming (WhatsApp doesn't support editing).
|
|
111
|
+
|
|
112
|
+
### WebChat
|
|
113
|
+
|
|
114
|
+
WebSocket server for custom UIs, CLI tools, or any client.
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
import { webchatChannel } from '@cogitator-ai/channels';
|
|
118
|
+
|
|
119
|
+
webchatChannel({
|
|
120
|
+
port: 3100,
|
|
121
|
+
path: '/ws',
|
|
122
|
+
auth: (token) => token === process.env.WEBCHAT_SECRET,
|
|
123
|
+
});
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Connect: `ws://localhost:3100/ws?token=YOUR_SECRET`. Send `{"text": "Hello!"}`, receive `{"type": "message", "id": "...", "text": "..."}`.
|
|
127
|
+
|
|
128
|
+
Supports: streaming (via edit messages), typing indicators, token auth, no message limit.
|
|
129
|
+
|
|
130
|
+
## Platform Comparison
|
|
131
|
+
|
|
132
|
+
| Feature | Telegram | Discord | Slack | WhatsApp | WebChat |
|
|
133
|
+
| ------------------ | ------------ | ------- | --------- | -------- | --------- |
|
|
134
|
+
| Streaming (edit) | ✅ | ✅ | ✅ | ❌ | ✅ |
|
|
135
|
+
| Reactions | ✅ | ✅ | ❌ | ❌ | ❌ |
|
|
136
|
+
| Typing indicator | ✅ | ✅ | ⚠️ | ✅ | ✅ |
|
|
137
|
+
| Photos → vision | ✅ | ❌ | ❌ | ❌ | ❌ |
|
|
138
|
+
| Voice → STT | ✅ | ❌ | ❌ | ❌ | ❌ |
|
|
139
|
+
| Max message length | 4096 | 2000 | ~4000 | ~65536 | unlimited |
|
|
140
|
+
| Public URL needed | webhook only | no | HTTP only | no | no |
|
|
141
|
+
|
|
142
|
+
## Gateway
|
|
143
|
+
|
|
144
|
+
Routes incoming messages to your agent. Handles:
|
|
145
|
+
|
|
146
|
+
- Session management (per-user, per-channel)
|
|
147
|
+
- Streaming with `StreamBuffer` (chunked message editing)
|
|
148
|
+
- Typing keep-alive (re-sends typing indicator every 4s)
|
|
149
|
+
- Media processing (images → vision, voice → STT)
|
|
150
|
+
- Middleware pipeline
|
|
151
|
+
- Platform-specific markdown conversion
|
|
152
|
+
- Status reactions, debouncing, envelope formatting, queue modes
|
|
153
|
+
|
|
154
|
+
## Status Reactions
|
|
155
|
+
|
|
156
|
+
Emoji progress indicators on the user's message:
|
|
157
|
+
|
|
158
|
+
```typescript
|
|
159
|
+
const gateway = new Gateway({
|
|
160
|
+
// ...
|
|
161
|
+
reactions: {
|
|
162
|
+
enabled: true,
|
|
163
|
+
emojis: { queued: '👀', thinking: '🤔', tool: '🔥', done: '👍', error: '😱' },
|
|
164
|
+
debounceMs: 700,
|
|
165
|
+
stallSoftMs: 10000,
|
|
166
|
+
stallHardMs: 30000,
|
|
167
|
+
},
|
|
168
|
+
});
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Inbound Debouncing
|
|
172
|
+
|
|
173
|
+
Merge rapid messages into a single LLM call:
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
const gateway = new Gateway({
|
|
177
|
+
// ...
|
|
178
|
+
debounce: {
|
|
179
|
+
enabled: true,
|
|
180
|
+
delayMs: 1500,
|
|
181
|
+
byChannel: { discord: 2000 },
|
|
182
|
+
},
|
|
183
|
+
});
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Envelope Formatting
|
|
187
|
+
|
|
188
|
+
Wrap messages with context so the LLM knows who's talking, on which platform, and when:
|
|
189
|
+
|
|
190
|
+
`[14:23 MSK | telegram | @alice | DM | +2m30s] Hello world`
|
|
191
|
+
|
|
192
|
+
```typescript
|
|
193
|
+
const gateway = new Gateway({
|
|
194
|
+
// ...
|
|
195
|
+
envelope: {
|
|
196
|
+
enabled: true,
|
|
197
|
+
includeTimestamp: true,
|
|
198
|
+
includeElapsed: true,
|
|
199
|
+
includeSender: true,
|
|
200
|
+
includeChannel: true,
|
|
201
|
+
includeChatType: true,
|
|
202
|
+
timezone: 'Europe/Moscow',
|
|
203
|
+
},
|
|
204
|
+
});
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Queue Modes
|
|
208
|
+
|
|
209
|
+
Control concurrent message handling per user:
|
|
210
|
+
|
|
211
|
+
```typescript
|
|
212
|
+
const gateway = new Gateway({
|
|
213
|
+
// ...
|
|
214
|
+
queueMode: 'sequential', // 'parallel' | 'sequential' | 'interrupt' | 'collect'
|
|
215
|
+
});
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
- **parallel** — default, all messages processed immediately
|
|
219
|
+
- **sequential** — FIFO per thread, wait for current to finish
|
|
220
|
+
- **interrupt** — abort current, start new message
|
|
221
|
+
- **collect** — buffer during processing, merge on idle
|
|
222
|
+
|
|
223
|
+
## Formatting Pipeline
|
|
224
|
+
|
|
225
|
+
Platform-specific markdown conversion applied automatically:
|
|
226
|
+
|
|
227
|
+
- **Telegram** — `# headers` → bold, preserves code blocks
|
|
228
|
+
- **Discord** — native Markdown, auto-chunks at 2000 chars with code block integrity
|
|
229
|
+
- **Slack** — `**bold**` → `*bold*`, headers → bold
|
|
230
|
+
- **WhatsApp** — `**bold**` → `*bold*`, `~~strike~~` → `~strike~`
|
|
231
|
+
|
|
232
|
+
## Middleware
|
|
233
|
+
|
|
234
|
+
```typescript
|
|
235
|
+
import { rateLimit, ownerCommands, DmPolicyMiddleware, autoExtract } from '@cogitator-ai/channels';
|
|
236
|
+
|
|
237
|
+
const gateway = new Gateway({
|
|
238
|
+
// ...
|
|
239
|
+
middleware: [
|
|
240
|
+
rateLimit({ maxPerMinute: 30 }),
|
|
241
|
+
ownerCommands({
|
|
242
|
+
ownerIds: { telegram: '123' },
|
|
243
|
+
commandLevels: { status: 'authorized', block: 'owner', help: 'public' },
|
|
244
|
+
}),
|
|
245
|
+
new DmPolicyMiddleware({
|
|
246
|
+
mode: 'pairing',
|
|
247
|
+
ownerIds: { telegram: '123' },
|
|
248
|
+
storePath: '~/.cogitator/dm-allowlist.json',
|
|
249
|
+
groupPolicy: 'open',
|
|
250
|
+
}),
|
|
251
|
+
autoExtract({ extractor }),
|
|
252
|
+
],
|
|
253
|
+
});
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### DM Policy Modes
|
|
257
|
+
|
|
258
|
+
- **open** — anyone can DM the bot
|
|
259
|
+
- **allowlist** — only pre-approved users
|
|
260
|
+
- **pairing** — unknown users get a code, owner approves via `/pair CODE`
|
|
261
|
+
- **disabled** — DMs blocked entirely
|
|
262
|
+
|
|
263
|
+
### Command Authorization Levels
|
|
264
|
+
|
|
265
|
+
Commands have 3 access levels: `owner`, `authorized`, `public`. Owner-only commands (like `/block`, `/model`) can't be run by regular users even if they're approved.
|
|
266
|
+
|
|
267
|
+
## Lifecycle Hooks
|
|
268
|
+
|
|
269
|
+
Subscribe to events across the message lifecycle:
|
|
270
|
+
|
|
271
|
+
```typescript
|
|
272
|
+
import { createHookRegistry } from '@cogitator-ai/channels';
|
|
273
|
+
|
|
274
|
+
const hooks = createHookRegistry();
|
|
275
|
+
hooks.on('message:received', (e) => console.log('New message:', e));
|
|
276
|
+
hooks.on('agent:after_run', (e) => console.log('Response:', e));
|
|
277
|
+
hooks.on('agent:error', (e) => console.error('Agent failed:', e));
|
|
278
|
+
|
|
279
|
+
const gateway = new Gateway({ /* ... */ hooks });
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
Available hooks: `message:received`, `message:sending`, `message:sent`, `agent:before_run`, `agent:after_run`, `agent:error`, `session:created`, `session:compacted`, `stream:started`, `stream:finished`.
|
|
283
|
+
|
|
284
|
+
Errors in one handler don't affect others.
|
|
285
|
+
|
|
286
|
+
## Media & STT
|
|
287
|
+
|
|
288
|
+
Voice messages are transcribed automatically. STT provider is selected by available env vars (highest priority first):
|
|
289
|
+
|
|
290
|
+
1. **Deepgram** — set `DEEPGRAM_API_KEY` (nova-3 model, fast and accurate)
|
|
291
|
+
2. **Groq** — set `GROQ_API_KEY` (free tier available)
|
|
292
|
+
3. **OpenAI** — set `OPENAI_API_KEY`
|
|
293
|
+
4. **Local Whisper** — downloads ~75MB model on first use, runs offline (no API key needed)
|
|
294
|
+
|
|
295
|
+
Images are passed to the LLM as vision input if the model supports it.
|
|
296
|
+
|
|
297
|
+
## Scheduler
|
|
298
|
+
|
|
299
|
+
```typescript
|
|
300
|
+
import { HeartbeatScheduler, SimpleTimerStore } from '@cogitator-ai/channels';
|
|
301
|
+
|
|
302
|
+
const store = new SimpleTimerStore({ persistPath: '.cogitator/timers.json' });
|
|
303
|
+
const scheduler = new HeartbeatScheduler(store, {
|
|
304
|
+
onFire: (msg) => gateway.injectMessage(msg),
|
|
305
|
+
pollInterval: 30_000,
|
|
306
|
+
maxRetries: 5,
|
|
307
|
+
onRunComplete: (entry, status, error, durationMs) => {
|
|
308
|
+
console.log(`Job ${entry.id}: ${status} (${durationMs}ms)`);
|
|
309
|
+
},
|
|
310
|
+
});
|
|
311
|
+
scheduler.start();
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
Schedule types: `cron` (recurring), `recurring` (interval), `fixed` (one-shot). Error tracking with auto-backoff.
|
|
315
|
+
|
|
316
|
+
```typescript
|
|
317
|
+
await scheduler.listJobs();
|
|
318
|
+
await scheduler.enableJob(id);
|
|
319
|
+
await scheduler.disableJob(id);
|
|
320
|
+
await scheduler.cancelJob(id);
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
## Environment Variables
|
|
324
|
+
|
|
325
|
+
```bash
|
|
326
|
+
# LLM Provider
|
|
327
|
+
GOOGLE_API_KEY=... # or ANTHROPIC_API_KEY, OPENAI_API_KEY
|
|
328
|
+
|
|
329
|
+
# Telegram
|
|
330
|
+
TG_TOKEN=7204891735:AAHr...
|
|
331
|
+
|
|
332
|
+
# Discord
|
|
333
|
+
DISCORD_TOKEN=MTI...
|
|
334
|
+
|
|
335
|
+
# Slack (3 tokens)
|
|
336
|
+
SLACK_BOT_TOKEN=xoxb-...
|
|
337
|
+
SLACK_SIGNING_SECRET=...
|
|
338
|
+
SLACK_APP_TOKEN=xapp-...
|
|
339
|
+
|
|
340
|
+
# WhatsApp — no token, uses QR pairing
|
|
341
|
+
|
|
342
|
+
# WebChat
|
|
343
|
+
WEBCHAT_SECRET=your-secret
|
|
344
|
+
|
|
345
|
+
# STT (optional, for voice messages — pick one)
|
|
346
|
+
DEEPGRAM_API_KEY=... # highest priority
|
|
347
|
+
GROQ_API_KEY=... # free tier
|
|
348
|
+
OPENAI_API_KEY=... # fallback
|
|
349
|
+
```
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const AssistantConfigSchema: z.ZodObject<{
|
|
3
|
+
name: z.ZodString;
|
|
4
|
+
personality: z.ZodString;
|
|
5
|
+
llm: z.ZodObject<{
|
|
6
|
+
provider: z.ZodEnum<{
|
|
7
|
+
google: "google";
|
|
8
|
+
openai: "openai";
|
|
9
|
+
anthropic: "anthropic";
|
|
10
|
+
ollama: "ollama";
|
|
11
|
+
}>;
|
|
12
|
+
model: z.ZodString;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
channels: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
15
|
+
telegram: z.ZodOptional<z.ZodObject<{
|
|
16
|
+
ownerIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
17
|
+
}, z.core.$strip>>;
|
|
18
|
+
discord: z.ZodOptional<z.ZodObject<{
|
|
19
|
+
ownerIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
20
|
+
}, z.core.$strip>>;
|
|
21
|
+
slack: z.ZodOptional<z.ZodObject<{
|
|
22
|
+
ownerIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
23
|
+
}, z.core.$strip>>;
|
|
24
|
+
}, z.core.$strip>>>;
|
|
25
|
+
capabilities: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
26
|
+
webSearch: z.ZodOptional<z.ZodBoolean>;
|
|
27
|
+
fileSystem: z.ZodOptional<z.ZodObject<{
|
|
28
|
+
paths: z.ZodArray<z.ZodString>;
|
|
29
|
+
}, z.core.$strip>>;
|
|
30
|
+
github: z.ZodOptional<z.ZodBoolean>;
|
|
31
|
+
deviceTools: z.ZodOptional<z.ZodBoolean>;
|
|
32
|
+
browser: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
|
|
33
|
+
headless: z.ZodDefault<z.ZodBoolean>;
|
|
34
|
+
stealth: z.ZodDefault<z.ZodBoolean>;
|
|
35
|
+
}, z.core.$strip>]>>;
|
|
36
|
+
scheduler: z.ZodOptional<z.ZodBoolean>;
|
|
37
|
+
rag: z.ZodOptional<z.ZodObject<{
|
|
38
|
+
paths: z.ZodArray<z.ZodString>;
|
|
39
|
+
}, z.core.$strip>>;
|
|
40
|
+
selfConfig: z.ZodOptional<z.ZodBoolean>;
|
|
41
|
+
selfTools: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
|
|
42
|
+
path: z.ZodOptional<z.ZodString>;
|
|
43
|
+
}, z.core.$strip>]>>;
|
|
44
|
+
}, z.core.$strip>>>;
|
|
45
|
+
mcpServers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
46
|
+
command: z.ZodString;
|
|
47
|
+
args: z.ZodArray<z.ZodString>;
|
|
48
|
+
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
49
|
+
}, z.core.$strip>>>;
|
|
50
|
+
memory: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
51
|
+
adapter: z.ZodDefault<z.ZodEnum<{
|
|
52
|
+
sqlite: "sqlite";
|
|
53
|
+
postgres: "postgres";
|
|
54
|
+
}>>;
|
|
55
|
+
path: z.ZodOptional<z.ZodString>;
|
|
56
|
+
autoExtract: z.ZodDefault<z.ZodBoolean>;
|
|
57
|
+
knowledgeGraph: z.ZodDefault<z.ZodBoolean>;
|
|
58
|
+
compaction: z.ZodOptional<z.ZodObject<{
|
|
59
|
+
threshold: z.ZodNumber;
|
|
60
|
+
}, z.core.$strip>>;
|
|
61
|
+
}, z.core.$strip>>>;
|
|
62
|
+
security: z.ZodOptional<z.ZodObject<{
|
|
63
|
+
dmPolicy: z.ZodDefault<z.ZodEnum<{
|
|
64
|
+
open: "open";
|
|
65
|
+
allowlist: "allowlist";
|
|
66
|
+
pairing: "pairing";
|
|
67
|
+
disabled: "disabled";
|
|
68
|
+
}>>;
|
|
69
|
+
allowlist: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
70
|
+
groupPolicy: z.ZodDefault<z.ZodEnum<{
|
|
71
|
+
open: "open";
|
|
72
|
+
allowlist: "allowlist";
|
|
73
|
+
disabled: "disabled";
|
|
74
|
+
}>>;
|
|
75
|
+
groupAllowlist: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
76
|
+
storePath: z.ZodOptional<z.ZodString>;
|
|
77
|
+
commandAccess: z.ZodOptional<z.ZodObject<{
|
|
78
|
+
authorized: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
79
|
+
publicCommands: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
80
|
+
}, z.core.$strip>>;
|
|
81
|
+
}, z.core.$strip>>;
|
|
82
|
+
stream: z.ZodOptional<z.ZodObject<{
|
|
83
|
+
flushInterval: z.ZodDefault<z.ZodNumber>;
|
|
84
|
+
minChunkSize: z.ZodDefault<z.ZodNumber>;
|
|
85
|
+
}, z.core.$strip>>;
|
|
86
|
+
rateLimit: z.ZodOptional<z.ZodObject<{
|
|
87
|
+
maxPerMinute: z.ZodDefault<z.ZodNumber>;
|
|
88
|
+
}, z.core.$strip>>;
|
|
89
|
+
}, z.core.$strip>;
|
|
90
|
+
export type AssistantConfigInput = z.input<typeof AssistantConfigSchema>;
|
|
91
|
+
export type AssistantConfigOutput = z.output<typeof AssistantConfigSchema>;
|
|
92
|
+
//# sourceMappingURL=assistant-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assistant-config.d.ts","sourceRoot":"","sources":["../src/assistant-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAmExB,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA2BhC,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACzE,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const McpServerSchema = z.object({
|
|
3
|
+
command: z.string(),
|
|
4
|
+
args: z.array(z.string()),
|
|
5
|
+
env: z.record(z.string(), z.string()).optional(),
|
|
6
|
+
});
|
|
7
|
+
const AssistantChannelsSchema = z.object({
|
|
8
|
+
telegram: z.object({ ownerIds: z.array(z.string()).optional() }).optional(),
|
|
9
|
+
discord: z.object({ ownerIds: z.array(z.string()).optional() }).optional(),
|
|
10
|
+
slack: z.object({ ownerIds: z.array(z.string()).optional() }).optional(),
|
|
11
|
+
});
|
|
12
|
+
const AssistantCapabilitiesSchema = z.object({
|
|
13
|
+
webSearch: z.boolean().optional(),
|
|
14
|
+
fileSystem: z.object({ paths: z.array(z.string()) }).optional(),
|
|
15
|
+
github: z.boolean().optional(),
|
|
16
|
+
deviceTools: z.boolean().optional(),
|
|
17
|
+
browser: z
|
|
18
|
+
.union([
|
|
19
|
+
z.boolean(),
|
|
20
|
+
z.object({
|
|
21
|
+
headless: z.boolean().default(true),
|
|
22
|
+
stealth: z.boolean().default(false),
|
|
23
|
+
}),
|
|
24
|
+
])
|
|
25
|
+
.optional(),
|
|
26
|
+
scheduler: z.boolean().optional(),
|
|
27
|
+
rag: z.object({ paths: z.array(z.string()) }).optional(),
|
|
28
|
+
selfConfig: z.boolean().optional(),
|
|
29
|
+
selfTools: z
|
|
30
|
+
.union([
|
|
31
|
+
z.boolean(),
|
|
32
|
+
z.object({
|
|
33
|
+
path: z.string().optional(),
|
|
34
|
+
}),
|
|
35
|
+
])
|
|
36
|
+
.optional(),
|
|
37
|
+
});
|
|
38
|
+
const AssistantMemorySchema = z.object({
|
|
39
|
+
adapter: z.enum(['sqlite', 'postgres']).default('sqlite'),
|
|
40
|
+
path: z.string().optional(),
|
|
41
|
+
autoExtract: z.boolean().default(true),
|
|
42
|
+
knowledgeGraph: z.boolean().default(true),
|
|
43
|
+
compaction: z.object({ threshold: z.number() }).optional(),
|
|
44
|
+
});
|
|
45
|
+
const CommandAccessSchema = z
|
|
46
|
+
.object({
|
|
47
|
+
authorized: z.array(z.string()).optional(),
|
|
48
|
+
publicCommands: z.array(z.string()).optional(),
|
|
49
|
+
})
|
|
50
|
+
.optional();
|
|
51
|
+
const SecuritySchema = z
|
|
52
|
+
.object({
|
|
53
|
+
dmPolicy: z.enum(['open', 'allowlist', 'pairing', 'disabled']).default('open'),
|
|
54
|
+
allowlist: z.array(z.string()).optional(),
|
|
55
|
+
groupPolicy: z.enum(['open', 'allowlist', 'disabled']).default('open'),
|
|
56
|
+
groupAllowlist: z.array(z.string()).optional(),
|
|
57
|
+
storePath: z.string().optional(),
|
|
58
|
+
commandAccess: CommandAccessSchema,
|
|
59
|
+
})
|
|
60
|
+
.optional();
|
|
61
|
+
export const AssistantConfigSchema = z.object({
|
|
62
|
+
name: z.string(),
|
|
63
|
+
personality: z.string(),
|
|
64
|
+
llm: z.object({
|
|
65
|
+
provider: z.enum(['google', 'openai', 'anthropic', 'ollama']),
|
|
66
|
+
model: z.string(),
|
|
67
|
+
}),
|
|
68
|
+
channels: AssistantChannelsSchema.optional().default({}),
|
|
69
|
+
capabilities: AssistantCapabilitiesSchema.optional().default({}),
|
|
70
|
+
mcpServers: z.record(z.string(), McpServerSchema).optional(),
|
|
71
|
+
memory: AssistantMemorySchema.optional().default({
|
|
72
|
+
adapter: 'sqlite',
|
|
73
|
+
autoExtract: true,
|
|
74
|
+
knowledgeGraph: true,
|
|
75
|
+
}),
|
|
76
|
+
security: SecuritySchema,
|
|
77
|
+
stream: z
|
|
78
|
+
.object({
|
|
79
|
+
flushInterval: z.number().default(600),
|
|
80
|
+
minChunkSize: z.number().default(30),
|
|
81
|
+
})
|
|
82
|
+
.optional(),
|
|
83
|
+
rateLimit: z
|
|
84
|
+
.object({
|
|
85
|
+
maxPerMinute: z.number().default(30),
|
|
86
|
+
})
|
|
87
|
+
.optional(),
|
|
88
|
+
});
|
|
89
|
+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+
entities: number;
|
|
9
|
+
relations: number;
|
|
10
|
+
};
|
|
11
|
+
scheduledTasks?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare function generateCapabilitiesDoc(input: CapabilitiesInput): string;
|
|
14
|
+
//# sourceMappingURL=capabilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../src/capabilities.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpD,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,WAAW,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IACtD,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,CA+BxE"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export function generateCapabilitiesDoc(input) {
|
|
2
|
+
const lines = ['# Assistant Capabilities', ''];
|
|
3
|
+
lines.push('## Available Tools', '');
|
|
4
|
+
for (const t of input.tools) {
|
|
5
|
+
lines.push(`- **${t.name}** — ${t.description}`);
|
|
6
|
+
}
|
|
7
|
+
lines.push('');
|
|
8
|
+
if (input.channels.length > 0) {
|
|
9
|
+
lines.push('## Connected Channels', '');
|
|
10
|
+
for (const ch of input.channels) {
|
|
11
|
+
lines.push(`- ${ch}`);
|
|
12
|
+
}
|
|
13
|
+
lines.push('');
|
|
14
|
+
}
|
|
15
|
+
if (input.memoryStats) {
|
|
16
|
+
lines.push('## Memory', '');
|
|
17
|
+
lines.push(`- ${input.memoryStats.entities} entities in knowledge graph`);
|
|
18
|
+
lines.push(`- ${input.memoryStats.relations} relations`);
|
|
19
|
+
lines.push('');
|
|
20
|
+
}
|
|
21
|
+
if (input.scheduledTasks !== undefined) {
|
|
22
|
+
lines.push('## Scheduled Tasks', '');
|
|
23
|
+
lines.push(`- ${input.scheduledTasks} active scheduled tasks`);
|
|
24
|
+
lines.push('');
|
|
25
|
+
}
|
|
26
|
+
return lines.join('\n');
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=capabilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilities.js","sourceRoot":"","sources":["../src/capabilities.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,uBAAuB,CAAC,KAAwB;IAC9D,MAAM,KAAK,GAAa,CAAC,0BAA0B,EAAE,EAAE,CAAC,CAAC;IAEzD,KAAK,CAAC,IAAI,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC;IACrC,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QAC5B,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;IACnD,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEf,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9B,KAAK,CAAC,IAAI,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC;QACxC,KAAK,MAAM,EAAE,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;YAChC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACxB,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IAED,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC;QACtB,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QAC5B,KAAK,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,WAAW,CAAC,QAAQ,8BAA8B,CAAC,CAAC;QAC1E,KAAK,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,WAAW,CAAC,SAAS,YAAY,CAAC,CAAC;QACzD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IAED,IAAI,KAAK,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;QACvC,KAAK,CAAC,IAAI,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC;QACrC,KAAK,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,cAAc,yBAAyB,CAAC,CAAC;QAC/D,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Channel, ChannelMessage, ChannelType, Attachment, SendOptions } from '@cogitator-ai/types';
|
|
2
|
+
export interface DiscordConfig {
|
|
3
|
+
token: string;
|
|
4
|
+
intents?: number[];
|
|
5
|
+
mentionOnly?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare class DiscordChannel implements Channel {
|
|
8
|
+
private readonly config;
|
|
9
|
+
readonly type: ChannelType;
|
|
10
|
+
private handler;
|
|
11
|
+
private client;
|
|
12
|
+
private botUserId;
|
|
13
|
+
constructor(config: DiscordConfig);
|
|
14
|
+
onMessage(handler: (msg: ChannelMessage) => Promise<void>): void;
|
|
15
|
+
start(): Promise<void>;
|
|
16
|
+
private handleDiscordMessage;
|
|
17
|
+
stop(): Promise<void>;
|
|
18
|
+
sendText(channelId: string, text: string, options?: SendOptions): Promise<string>;
|
|
19
|
+
editText(channelId: string, messageId: string, text: string): Promise<void>;
|
|
20
|
+
sendFile(channelId: string, file: Attachment): Promise<void>;
|
|
21
|
+
sendTyping(channelId: string): Promise<void>;
|
|
22
|
+
deleteMessage(channelId: string, messageId: string): Promise<void>;
|
|
23
|
+
setReaction(channelId: string, messageId: string, emoji: string): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
export declare function discordChannel(config: DiscordConfig): Channel;
|
|
26
|
+
//# sourceMappingURL=discord.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discord.d.ts","sourceRoot":"","sources":["../../src/channels/discord.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,cAAc,EACd,WAAW,EACX,UAAU,EACV,WAAW,EACZ,MAAM,qBAAqB,CAAC;AAG7B,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAuCD,qBAAa,cAAe,YAAW,OAAO;IAMhC,OAAO,CAAC,QAAQ,CAAC,MAAM;IALnC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAa;IACvC,OAAO,CAAC,OAAO,CAAyD;IACxE,OAAO,CAAC,MAAM,CAA8B;IAC5C,OAAO,CAAC,SAAS,CAAuB;gBAEX,MAAM,EAAE,aAAa;IAElD,SAAS,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAI1D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;YAoCd,oBAAoB;IA8B5B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAOrB,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;IAqBjF,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAkB3E,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAW5D,UAAU,CAAC,SAAS,EAA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