@cogitator-ai/channels 0.2.5 → 0.3.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/README.md +141 -39
- package/dist/assistant-config.d.ts +1 -0
- package/dist/assistant-config.d.ts.map +1 -1
- package/dist/assistant-config.js +1 -0
- package/dist/assistant-config.js.map +1 -1
- package/dist/channels/discord.d.ts +4 -0
- package/dist/channels/discord.d.ts.map +1 -1
- package/dist/channels/discord.js +123 -59
- package/dist/channels/discord.js.map +1 -1
- package/dist/channels/slack.d.ts +9 -0
- package/dist/channels/slack.d.ts.map +1 -1
- package/dist/channels/slack.js +153 -34
- package/dist/channels/slack.js.map +1 -1
- package/dist/channels/telegram.d.ts +13 -0
- package/dist/channels/telegram.d.ts.map +1 -1
- package/dist/channels/telegram.js +206 -111
- package/dist/channels/telegram.js.map +1 -1
- package/dist/channels/terminal.d.ts +10 -0
- package/dist/channels/terminal.d.ts.map +1 -1
- package/dist/channels/terminal.js +46 -10
- package/dist/channels/terminal.js.map +1 -1
- package/dist/channels/webchat.d.ts +7 -2
- package/dist/channels/webchat.d.ts.map +1 -1
- package/dist/channels/webchat.js +112 -50
- package/dist/channels/webchat.js.map +1 -1
- package/dist/channels/whatsapp.d.ts +19 -3
- package/dist/channels/whatsapp.d.ts.map +1 -1
- package/dist/channels/whatsapp.js +204 -66
- package/dist/channels/whatsapp.js.map +1 -1
- package/dist/cron.d.ts +2 -0
- package/dist/cron.d.ts.map +1 -0
- package/dist/cron.js +9 -0
- package/dist/cron.js.map +1 -0
- package/dist/envelope.d.ts.map +1 -1
- package/dist/envelope.js +7 -6
- package/dist/envelope.js.map +1 -1
- package/dist/formatters/code-protect.d.ts +2 -0
- package/dist/formatters/code-protect.d.ts.map +1 -0
- package/dist/formatters/code-protect.js +12 -0
- package/dist/formatters/code-protect.js.map +1 -0
- package/dist/formatters/markdown.d.ts +1 -1
- package/dist/formatters/markdown.d.ts.map +1 -1
- package/dist/formatters/markdown.js +79 -21
- package/dist/formatters/markdown.js.map +1 -1
- package/dist/formatters/whatsapp-markdown.d.ts.map +1 -1
- package/dist/formatters/whatsapp-markdown.js +7 -21
- package/dist/formatters/whatsapp-markdown.js.map +1 -1
- package/dist/gateway.d.ts +32 -3
- package/dist/gateway.d.ts.map +1 -1
- package/dist/gateway.js +275 -174
- package/dist/gateway.js.map +1 -1
- package/dist/heartbeat.d.ts +9 -2
- package/dist/heartbeat.d.ts.map +1 -1
- package/dist/heartbeat.js +121 -84
- package/dist/heartbeat.js.map +1 -1
- package/dist/inbound-debounce.js +2 -2
- package/dist/inbound-debounce.js.map +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/media/audio-format.d.ts +3 -0
- package/dist/media/audio-format.d.ts.map +1 -0
- package/dist/media/audio-format.js +20 -0
- package/dist/media/audio-format.js.map +1 -0
- package/dist/media/deepgram-stt.d.ts +1 -1
- package/dist/media/deepgram-stt.d.ts.map +1 -1
- package/dist/media/deepgram-stt.js +4 -3
- package/dist/media/deepgram-stt.js.map +1 -1
- package/dist/media/media-processor.d.ts +12 -1
- package/dist/media/media-processor.d.ts.map +1 -1
- package/dist/media/media-processor.js +75 -18
- package/dist/media/media-processor.js.map +1 -1
- package/dist/media/whisper-api.d.ts.map +1 -1
- package/dist/media/whisper-api.js +20 -32
- package/dist/media/whisper-api.js.map +1 -1
- package/dist/media/whisper-local.d.ts +1 -0
- package/dist/media/whisper-local.d.ts.map +1 -1
- package/dist/media/whisper-local.js +100 -45
- package/dist/media/whisper-local.js.map +1 -1
- package/dist/message-queue.d.ts +1 -0
- package/dist/message-queue.d.ts.map +1 -1
- package/dist/message-queue.js +17 -10
- package/dist/message-queue.js.map +1 -1
- package/dist/middleware/auto-extract.d.ts +2 -0
- package/dist/middleware/auto-extract.d.ts.map +1 -1
- package/dist/middleware/auto-extract.js +94 -30
- package/dist/middleware/auto-extract.js.map +1 -1
- package/dist/middleware/dm-policy.d.ts +2 -1
- package/dist/middleware/dm-policy.d.ts.map +1 -1
- package/dist/middleware/dm-policy.js +26 -27
- package/dist/middleware/dm-policy.js.map +1 -1
- package/dist/middleware/owner-commands.d.ts +1 -1
- package/dist/middleware/owner-commands.d.ts.map +1 -1
- package/dist/middleware/owner-commands.js +8 -7
- package/dist/middleware/owner-commands.js.map +1 -1
- package/dist/middleware/pairing-codes.d.ts +12 -0
- package/dist/middleware/pairing-codes.d.ts.map +1 -0
- package/dist/middleware/pairing-codes.js +26 -0
- package/dist/middleware/pairing-codes.js.map +1 -0
- package/dist/middleware/pairing.d.ts +3 -3
- package/dist/middleware/pairing.d.ts.map +1 -1
- package/dist/middleware/pairing.js +18 -25
- package/dist/middleware/pairing.js.map +1 -1
- package/dist/middleware/rate-limit.d.ts +3 -1
- package/dist/middleware/rate-limit.d.ts.map +1 -1
- package/dist/middleware/rate-limit.js +21 -6
- package/dist/middleware/rate-limit.js.map +1 -1
- package/dist/runtime-builder.d.ts +11 -0
- package/dist/runtime-builder.d.ts.map +1 -1
- package/dist/runtime-builder.js +212 -62
- package/dist/runtime-builder.js.map +1 -1
- package/dist/simple-timer-store.d.ts +6 -0
- package/dist/simple-timer-store.d.ts.map +1 -1
- package/dist/simple-timer-store.js +8 -1
- package/dist/simple-timer-store.js.map +1 -1
- package/dist/stream-buffer.d.ts +14 -7
- package/dist/stream-buffer.d.ts.map +1 -1
- package/dist/stream-buffer.js +129 -84
- package/dist/stream-buffer.js.map +1 -1
- package/dist/tools/path-guard.d.ts +4 -0
- package/dist/tools/path-guard.d.ts.map +1 -0
- package/dist/tools/path-guard.js +53 -0
- package/dist/tools/path-guard.js.map +1 -0
- package/dist/tools/self-config.d.ts +12 -2
- package/dist/tools/self-config.d.ts.map +1 -1
- package/dist/tools/self-config.js +53 -16
- package/dist/tools/self-config.js.map +1 -1
- package/package.json +19 -12
package/README.md
CHANGED
|
@@ -11,8 +11,9 @@ pnpm add @cogitator-ai/channels
|
|
|
11
11
|
pnpm add grammy # Telegram
|
|
12
12
|
pnpm add discord.js # Discord
|
|
13
13
|
pnpm add @slack/bolt # Slack
|
|
14
|
-
pnpm add @whiskeysockets/baileys # WhatsApp
|
|
14
|
+
pnpm add @whiskeysockets/baileys # WhatsApp (+ qrcode-terminal to print the pairing QR)
|
|
15
15
|
pnpm add ws # WebChat
|
|
16
|
+
pnpm add pg # Postgres memory for RuntimeBuilder (optional)
|
|
16
17
|
```
|
|
17
18
|
|
|
18
19
|
## Quick Start
|
|
@@ -21,8 +22,14 @@ pnpm add ws # WebChat
|
|
|
21
22
|
import { Cogitator, Agent } from '@cogitator-ai/core';
|
|
22
23
|
import { Gateway, telegramChannel } from '@cogitator-ai/channels';
|
|
23
24
|
|
|
24
|
-
const cogitator = new Cogitator({
|
|
25
|
-
|
|
25
|
+
const cogitator = new Cogitator({
|
|
26
|
+
llm: { providers: { google: { apiKey: process.env.GOOGLE_API_KEY! } } },
|
|
27
|
+
});
|
|
28
|
+
const agent = new Agent({
|
|
29
|
+
name: 'bot',
|
|
30
|
+
model: 'google/gemini-2.5-flash',
|
|
31
|
+
instructions: 'You are a helpful assistant.',
|
|
32
|
+
});
|
|
26
33
|
|
|
27
34
|
const gateway = new Gateway({
|
|
28
35
|
cogitator,
|
|
@@ -45,14 +52,19 @@ import { telegramChannel } from '@cogitator-ai/channels';
|
|
|
45
52
|
|
|
46
53
|
telegramChannel({ token: process.env.TG_TOKEN! });
|
|
47
54
|
|
|
48
|
-
// Webhook mode (production):
|
|
55
|
+
// Webhook mode (production): starts an HTTP server on `port` and registers `url` with Telegram
|
|
49
56
|
telegramChannel({
|
|
50
57
|
token: process.env.TG_TOKEN!,
|
|
51
|
-
webhook: {
|
|
58
|
+
webhook: {
|
|
59
|
+
url: 'https://example.com/telegram',
|
|
60
|
+
port: 8443,
|
|
61
|
+
secretToken: process.env.TG_WEBHOOK_SECRET, // verified on every update
|
|
62
|
+
},
|
|
63
|
+
allowedUpdates: ['message'],
|
|
52
64
|
});
|
|
53
65
|
```
|
|
54
66
|
|
|
55
|
-
Supports: text, photos (→ vision), voice (→ STT), documents, streaming via editText, emoji reactions, 4096 char limit.
|
|
67
|
+
Supports: text, photos (→ vision), voice and audio (→ STT), video, documents, replies, streaming via drafts/editText, emoji reactions, sending files from buffers or URLs, 4096 char limit.
|
|
56
68
|
|
|
57
69
|
### Discord
|
|
58
70
|
|
|
@@ -67,7 +79,7 @@ discordChannel({
|
|
|
67
79
|
});
|
|
68
80
|
```
|
|
69
81
|
|
|
70
|
-
Supports: DMs, server messages, streaming, reactions, auto-chunking (2000
|
|
82
|
+
Supports: DMs, server messages, attachments (images → vision, audio → STT), replies, streaming, reactions, auto-chunking (2000 chars / 17 lines, code-block aware). Long streamed answers span several Discord messages that are edited in place.
|
|
71
83
|
|
|
72
84
|
### Slack
|
|
73
85
|
|
|
@@ -75,7 +87,7 @@ Supports: DMs, server messages, streaming, reactions, auto-chunking (2000 char l
|
|
|
75
87
|
|
|
76
88
|
1. [api.slack.com/apps](https://api.slack.com/apps) → Create New App → From scratch
|
|
77
89
|
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`
|
|
90
|
+
3. OAuth & Permissions → add scopes: `chat:write`, `app_mentions:read`, `im:history`, `im:read`, `im:write`, `users:read` (display names), `files:read` (attachments), `files:write` (sendFile), `reactions:write` (status reactions)
|
|
79
91
|
4. Event Subscriptions → enable → add: `message.im`, `app_mention`
|
|
80
92
|
5. Install App → copy Bot Token (`xoxb-...`) → save as `SLACK_BOT_TOKEN`
|
|
81
93
|
6. Basic Information → copy Signing Secret → save as `SLACK_SIGNING_SECRET`
|
|
@@ -90,7 +102,7 @@ slackChannel({
|
|
|
90
102
|
});
|
|
91
103
|
```
|
|
92
104
|
|
|
93
|
-
Supports: DMs, channel messages (via @mention), Socket Mode (no public URL), streaming via chat.update.
|
|
105
|
+
Supports: DMs, channel messages (via @mention), threads (replies go to the thread root), file shares, Socket Mode (no public URL), streaming via chat.update, reactions.
|
|
94
106
|
|
|
95
107
|
### WhatsApp
|
|
96
108
|
|
|
@@ -101,13 +113,13 @@ import { whatsappChannel } from '@cogitator-ai/channels';
|
|
|
101
113
|
|
|
102
114
|
whatsappChannel({
|
|
103
115
|
sessionPath: '.cogitator/whatsapp-session',
|
|
104
|
-
printQr: true,
|
|
116
|
+
printQr: true, // needs `qrcode-terminal`; or pass qrCallback: (qr) => render(qr)
|
|
105
117
|
});
|
|
106
118
|
```
|
|
107
119
|
|
|
108
|
-
**First run:** QR code
|
|
120
|
+
**First run:** the QR code is printed to the terminal (or handed to `qrCallback`) → scan from WhatsApp → Settings → Linked Devices. Session is saved for future restarts.
|
|
109
121
|
|
|
110
|
-
Supports: 1-on-1 and group chats, typing indicators, auto-reconnect, WhatsApp-native markdown.
|
|
122
|
+
Supports: 1-on-1 and group chats, images/voice/video/documents with captions, quoted replies, message edits (streaming), typing indicators, auto-reconnect with exponential backoff, WhatsApp-native markdown.
|
|
111
123
|
|
|
112
124
|
### WebChat
|
|
113
125
|
|
|
@@ -120,36 +132,75 @@ webchatChannel({
|
|
|
120
132
|
port: 3100,
|
|
121
133
|
path: '/ws',
|
|
122
134
|
auth: (token) => token === process.env.WEBCHAT_SECRET,
|
|
135
|
+
maxPayload: 1024 * 1024, // bytes per incoming frame (default 1 MiB)
|
|
123
136
|
});
|
|
124
137
|
```
|
|
125
138
|
|
|
126
|
-
Connect: `ws://localhost:3100/ws?token=YOUR_SECRET
|
|
139
|
+
Connect: `ws://localhost:3100/ws?token=YOUR_SECRET` (unauthorized sockets are closed with code 1008). Send `{"text": "Hello!", "id": "optional-client-id"}`.
|
|
140
|
+
|
|
141
|
+
Server frames: `connected` (`clientId`), `message` (`id`, `text`, `replyTo`), `edit` (`id`, `text`), `delete` (`id`), `typing`, `file` (`url` or base64 `data`).
|
|
142
|
+
|
|
143
|
+
Supports: streaming (via edit frames), typing indicators, token auth, no message limit.
|
|
144
|
+
|
|
145
|
+
### Terminal
|
|
127
146
|
|
|
128
|
-
|
|
147
|
+
Local REPL channel used by `cogitator up`. Active only when stdin is a TTY (or `COGITATOR_FORCE_TERMINAL` is set).
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
import { terminalChannel } from '@cogitator-ai/channels';
|
|
151
|
+
|
|
152
|
+
terminalChannel({ userName: 'Alice', prompt: '> ', onExit: () => shutdown() });
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Ctrl+C, Ctrl+D, `/quit`, `/exit` and `exit` call `onExit` (default: raise `SIGINT` so the host app shuts down gracefully); `stop()` closes readline without exiting the process.
|
|
129
156
|
|
|
130
157
|
## Platform Comparison
|
|
131
158
|
|
|
132
159
|
| Feature | Telegram | Discord | Slack | WhatsApp | WebChat |
|
|
133
160
|
| ------------------ | ------------ | ------- | --------- | -------- | --------- |
|
|
134
|
-
| Streaming (edit) | ✅ | ✅ | ✅ |
|
|
135
|
-
| Reactions | ✅ | ✅ |
|
|
136
|
-
| Typing indicator | ✅ | ✅ |
|
|
137
|
-
| Photos → vision | ✅ |
|
|
138
|
-
| Voice → STT | ✅ |
|
|
139
|
-
| Max message length | 4096 | 2000 |
|
|
161
|
+
| Streaming (edit) | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
162
|
+
| Reactions | ✅ | ✅ | ✅ | ❌ | ❌ |
|
|
163
|
+
| Typing indicator | ✅ | ✅ | ❌ | ✅ | ✅ |
|
|
164
|
+
| Photos → vision | ✅ | ✅ | ✅ | ✅ | ❌ |
|
|
165
|
+
| Voice → STT | ✅ | ✅ | ✅ | ✅ | ❌ |
|
|
166
|
+
| Max message length | 4096 | 2000 | 40000 | 65536 | unlimited |
|
|
140
167
|
| Public URL needed | webhook only | no | HTTP only | no | no |
|
|
141
168
|
|
|
169
|
+
Outbound calls (`sendText`, `editText`, `sendFile`, `deleteMessage`) throw when the channel is not started, the target chat/client is unavailable or the platform rejects the request — wrap direct calls in `try/catch`. `sendText` returns the platform message id (for Discord, the id of the first chunk; continuation chunks are edited and deleted with it).
|
|
170
|
+
|
|
142
171
|
## Gateway
|
|
143
172
|
|
|
144
173
|
Routes incoming messages to your agent. Handles:
|
|
145
174
|
|
|
146
|
-
- Session management (per-user, per-channel)
|
|
147
|
-
-
|
|
175
|
+
- Session management (per-user, per-channel) with an optional custom `sessionManager`
|
|
176
|
+
- History compaction with LLM-written summaries
|
|
177
|
+
- Streaming with `StreamBuffer` (message editing, splits at the platform limit without losing text)
|
|
148
178
|
- Typing keep-alive (re-sends typing indicator every 4s)
|
|
149
179
|
- Media processing (images → vision, voice → STT)
|
|
150
180
|
- Middleware pipeline
|
|
151
181
|
- Platform-specific markdown conversion
|
|
152
182
|
- Status reactions, debouncing, envelope formatting, queue modes
|
|
183
|
+
- Run timeouts (`runTimeout`, defaults to the agent's `timeout`)
|
|
184
|
+
|
|
185
|
+
```typescript
|
|
186
|
+
const gateway = new Gateway({
|
|
187
|
+
cogitator,
|
|
188
|
+
agent, // or (user) => Agent | Promise<Agent> for per-user agents
|
|
189
|
+
channels,
|
|
190
|
+
memory, // MemoryAdapter — enables sessions and history
|
|
191
|
+
session: {
|
|
192
|
+
threadKey: (msg) => `${msg.channelType}:${msg.userId}`,
|
|
193
|
+
// compact once a conversation holds 50 messages, keep the last 10 verbatim
|
|
194
|
+
compaction: { strategy: 'summary', threshold: 50, keepRecent: 10 },
|
|
195
|
+
},
|
|
196
|
+
runTimeout: 120_000,
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
gateway.stats; // { uptime, activeSessions, totalSessions, messagesToday, connectedChannels }
|
|
200
|
+
gateway.getSessions(); // [{ threadId, userName, messageCount, lastActiveAt, active }]
|
|
201
|
+
await gateway.compactThread('telegram:42'); // force compaction of one conversation
|
|
202
|
+
await gateway.injectMessage(msg); // feed a synthetic message (used by the scheduler)
|
|
203
|
+
```
|
|
153
204
|
|
|
154
205
|
## Status Reactions
|
|
155
206
|
|
|
@@ -187,7 +238,7 @@ const gateway = new Gateway({
|
|
|
187
238
|
|
|
188
239
|
Wrap messages with context so the LLM knows who's talking, on which platform, and when:
|
|
189
240
|
|
|
190
|
-
`[14:23
|
|
241
|
+
`[Oct 2, 14:23 | telegram | alice | DM | +2m30s] Hello world`
|
|
191
242
|
|
|
192
243
|
```typescript
|
|
193
244
|
const gateway = new Gateway({
|
|
@@ -217,17 +268,19 @@ const gateway = new Gateway({
|
|
|
217
268
|
|
|
218
269
|
- **parallel** — default, all messages processed immediately
|
|
219
270
|
- **sequential** — FIFO per thread, wait for current to finish
|
|
220
|
-
- **interrupt** — abort current, start new message
|
|
271
|
+
- **interrupt** — abort the current run (its signal is passed to `cogitator.run`), start the new message
|
|
221
272
|
- **collect** — buffer during processing, merge on idle
|
|
222
273
|
|
|
223
274
|
## Formatting Pipeline
|
|
224
275
|
|
|
225
|
-
Platform-specific markdown conversion applied automatically:
|
|
276
|
+
Platform-specific markdown conversion applied automatically (code spans and fences are never touched):
|
|
226
277
|
|
|
227
|
-
- **Telegram** — `# headers` → bold,
|
|
278
|
+
- **Telegram** — `**bold**` → `*bold*`, `# headers` → bold, `* item` → `• item`
|
|
228
279
|
- **Discord** — native Markdown, auto-chunks at 2000 chars with code block integrity
|
|
229
|
-
- **Slack** — `**bold**` → `*bold*`,
|
|
230
|
-
- **WhatsApp** — `**bold**` → `*bold*`, `~~strike~~` → `~strike
|
|
280
|
+
- **Slack** — mrkdwn: `**bold**` → `*bold*`, `[text](url)` → `<url|text>`, `~~x~~` → `~x~`, `&<>` escaped
|
|
281
|
+
- **WhatsApp** — `**bold**` → `*bold*`, `~~strike~~` → `~strike~`, headers → bold, links → `text (url)`
|
|
282
|
+
|
|
283
|
+
`chunkMessage(text, limit)` splits long answers at paragraph → line → word boundaries and closes/reopens code fences across chunks.
|
|
231
284
|
|
|
232
285
|
## Middleware
|
|
233
286
|
|
|
@@ -237,18 +290,22 @@ import { rateLimit, ownerCommands, DmPolicyMiddleware, autoExtract } from '@cogi
|
|
|
237
290
|
const gateway = new Gateway({
|
|
238
291
|
// ...
|
|
239
292
|
middleware: [
|
|
240
|
-
rateLimit({ maxPerMinute: 30 }),
|
|
241
|
-
ownerCommands({
|
|
242
|
-
ownerIds: { telegram: '123' },
|
|
243
|
-
commandLevels: { status: 'authorized', block: 'owner', help: 'public' },
|
|
244
|
-
}),
|
|
245
293
|
new DmPolicyMiddleware({
|
|
246
294
|
mode: 'pairing',
|
|
247
295
|
ownerIds: { telegram: '123' },
|
|
248
296
|
storePath: '~/.cogitator/dm-allowlist.json',
|
|
249
297
|
groupPolicy: 'open',
|
|
250
298
|
}),
|
|
251
|
-
|
|
299
|
+
ownerCommands({
|
|
300
|
+
ownerIds: { telegram: '123' },
|
|
301
|
+
authorizedUserIds: ['telegram:456'],
|
|
302
|
+
publicCommands: ['help'],
|
|
303
|
+
onStatus: () => JSON.stringify(gateway.stats),
|
|
304
|
+
onCompact: (target, threadId) =>
|
|
305
|
+
gateway.compactThread(target === 'current' ? threadId : target),
|
|
306
|
+
}),
|
|
307
|
+
rateLimit({ maxPerMinute: 30 }),
|
|
308
|
+
autoExtract({ extractor, graphAdapter, agentId: 'jarvis' }),
|
|
252
309
|
],
|
|
253
310
|
});
|
|
254
311
|
```
|
|
@@ -262,7 +319,11 @@ const gateway = new Gateway({
|
|
|
262
319
|
|
|
263
320
|
### Command Authorization Levels
|
|
264
321
|
|
|
265
|
-
Commands have 3 access levels: `owner`, `authorized`, `public`.
|
|
322
|
+
Commands have 3 access levels: `owner`, `authorized`, `public`. Built-in commands: `/status`, `/sessions`, `/help` (authorized) and `/users`, `/compact`, `/model <name> [@user]`, `/restart` (owner). Each command calls the matching `on*` handler you provide. `/cmd@botname` (Telegram groups) is recognized. Only owners can approve `/pair` codes.
|
|
323
|
+
|
|
324
|
+
### Rate Limit
|
|
325
|
+
|
|
326
|
+
`rateLimit({ maxPerMinute, message })` — sliding one-minute window per user; the limit notice is sent once per window.
|
|
266
327
|
|
|
267
328
|
## Lifecycle Hooks
|
|
268
329
|
|
|
@@ -292,26 +353,43 @@ Voice messages are transcribed automatically. STT provider is selected by availa
|
|
|
292
353
|
3. **OpenAI** — set `OPENAI_API_KEY`
|
|
293
354
|
4. **Local Whisper** — downloads ~75MB model on first use, runs offline (no API key needed)
|
|
294
355
|
|
|
295
|
-
Images are passed to the LLM as vision input if the model supports it.
|
|
356
|
+
Images are passed to the LLM as vision input if the model supports it. Attachments that arrive only as URLs (Discord) are downloaded (default cap 25 MiB). Text-like files (`.md`, `.json`, `text/*`, …) are inlined into the prompt; other files and videos are announced to the model.
|
|
357
|
+
|
|
358
|
+
```typescript
|
|
359
|
+
import { MediaProcessor, LocalWhisper, GroqSttProvider } from '@cogitator-ai/channels';
|
|
360
|
+
|
|
361
|
+
const media = new MediaProcessor(new LocalWhisper(), () => true, new GroqSttProvider({ apiKey }), {
|
|
362
|
+
maxInlineTextChars: 20_000,
|
|
363
|
+
maxDownloadBytes: 25 * 1024 * 1024,
|
|
364
|
+
});
|
|
365
|
+
const gateway = new Gateway({ /* ... */ mediaProcessor: media });
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
Local Whisper decodes OGG/Opus and WAV (8/16/24/32-bit, any channel count); use a cloud provider for other formats.
|
|
296
369
|
|
|
297
370
|
## Scheduler
|
|
298
371
|
|
|
299
372
|
```typescript
|
|
300
|
-
import { HeartbeatScheduler, SimpleTimerStore } from '@cogitator-ai/channels';
|
|
373
|
+
import { HeartbeatScheduler, SimpleTimerStore, getNextCronMs } from '@cogitator-ai/channels';
|
|
301
374
|
|
|
302
|
-
const store = new SimpleTimerStore({
|
|
375
|
+
const store = new SimpleTimerStore({
|
|
376
|
+
persistPath: '.cogitator/timers.json',
|
|
377
|
+
resolveCronFiresAt: (cron, tz) => getNextCronMs(cron, Date.now(), tz), // validates and schedules cron entries
|
|
378
|
+
});
|
|
303
379
|
const scheduler = new HeartbeatScheduler(store, {
|
|
304
380
|
onFire: (msg) => gateway.injectMessage(msg),
|
|
305
381
|
pollInterval: 30_000,
|
|
306
382
|
maxRetries: 5,
|
|
383
|
+
retentionMs: 7 * 24 * 60 * 60 * 1000, // prune fired entries after a week
|
|
307
384
|
onRunComplete: (entry, status, error, durationMs) => {
|
|
308
385
|
console.log(`Job ${entry.id}: ${status} (${durationMs}ms)`);
|
|
309
386
|
},
|
|
387
|
+
onError: (err, entry) => console.error('scheduler', entry?.id, err.message),
|
|
310
388
|
});
|
|
311
389
|
scheduler.start();
|
|
312
390
|
```
|
|
313
391
|
|
|
314
|
-
Schedule types: `cron` (recurring), `recurring` (interval), `fixed` (one-shot).
|
|
392
|
+
Schedule types: `cron` (recurring, next fire computed with `cron-parser`, honors `timezone`), `recurring` (interval), `fixed` (one-shot). Consecutive failures are carried across reschedules; after `maxRetries` the job is skipped until `enableJob()`.
|
|
315
393
|
|
|
316
394
|
```typescript
|
|
317
395
|
await scheduler.listJobs();
|
|
@@ -320,6 +398,27 @@ await scheduler.disableJob(id);
|
|
|
320
398
|
await scheduler.cancelJob(id);
|
|
321
399
|
```
|
|
322
400
|
|
|
401
|
+
## RuntimeBuilder (YAML assistants)
|
|
402
|
+
|
|
403
|
+
`RuntimeBuilder` turns a validated `cogitator.yml` (`AssistantConfigSchema`) into a running assistant — this is what `cogitator up` uses.
|
|
404
|
+
|
|
405
|
+
```typescript
|
|
406
|
+
import { AssistantConfigSchema, RuntimeBuilder } from '@cogitator-ai/channels';
|
|
407
|
+
|
|
408
|
+
const config = AssistantConfigSchema.parse(yamlObject);
|
|
409
|
+
const runtime = await new RuntimeBuilder(config, process.env, {
|
|
410
|
+
onRestart: () => process.exit(78), // default behaviour
|
|
411
|
+
}).build();
|
|
412
|
+
await runtime.gateway.start(); // the scheduler (if enabled) is already running
|
|
413
|
+
// ...
|
|
414
|
+
await runtime.cleanup();
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
- **Memory:** `memory.adapter: sqlite` (default, `memory.path`) or `postgres` (`memory.connectionString` or `DATABASE_URL`; requires `pg`). Knowledge graph + core facts + auto-extraction included.
|
|
418
|
+
- **Fresh context:** the gateway builds an agent per message — instructions (current date/time and known user facts) and the `/model` override are resolved each time. `runtime.agent` is the base agent.
|
|
419
|
+
- **Owner commands wired:** `/status`, `/sessions`, `/users`, `/compact`, `/model` (global or per user), `/restart`.
|
|
420
|
+
- **Security:** `fileSystem.paths` is enforced — file tools refuse paths outside the allowed roots (symlinks resolved). Self-config tools (`config_*`, `env_*`) only work for channel owners and the local terminal.
|
|
421
|
+
|
|
323
422
|
## Environment Variables
|
|
324
423
|
|
|
325
424
|
```bash
|
|
@@ -339,6 +438,9 @@ SLACK_APP_TOKEN=xapp-...
|
|
|
339
438
|
|
|
340
439
|
# WhatsApp — no token, uses QR pairing
|
|
341
440
|
|
|
441
|
+
# Postgres memory (memory.adapter: postgres)
|
|
442
|
+
DATABASE_URL=postgres://user:pass@localhost:5432/cogitator
|
|
443
|
+
|
|
342
444
|
# WebChat
|
|
343
445
|
WEBCHAT_SECRET=your-secret
|
|
344
446
|
|
|
@@ -53,6 +53,7 @@ export declare const AssistantConfigSchema: z.ZodObject<{
|
|
|
53
53
|
postgres: "postgres";
|
|
54
54
|
}>>;
|
|
55
55
|
path: z.ZodOptional<z.ZodString>;
|
|
56
|
+
connectionString: z.ZodOptional<z.ZodString>;
|
|
56
57
|
autoExtract: z.ZodDefault<z.ZodBoolean>;
|
|
57
58
|
knowledgeGraph: z.ZodDefault<z.ZodBoolean>;
|
|
58
59
|
compaction: z.ZodOptional<z.ZodObject<{
|
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"assistant-config.d.ts","sourceRoot":"","sources":["../src/assistant-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAoExB,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"}
|
package/dist/assistant-config.js
CHANGED
|
@@ -38,6 +38,7 @@ const AssistantCapabilitiesSchema = z.object({
|
|
|
38
38
|
const AssistantMemorySchema = z.object({
|
|
39
39
|
adapter: z.enum(['sqlite', 'postgres']).default('sqlite'),
|
|
40
40
|
path: z.string().optional(),
|
|
41
|
+
connectionString: z.string().optional(),
|
|
41
42
|
autoExtract: z.boolean().default(true),
|
|
42
43
|
knowledgeGraph: z.boolean().default(true),
|
|
43
44
|
compaction: z.object({ threshold: z.number() }).optional(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assistant-config.js","sourceRoot":"","sources":["../src/assistant-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACzB,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;CACjD,CAAC,CAAC;AAEH,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,KAAK,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CAAC;QACtC,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;KACrC,CAAC;SACD,QAAQ,EAAE;IACb,SAAS,EAAE,CAAC;SACT,MAAM,CAAC;QACN,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;KACrC,CAAC;SACD,QAAQ,EAAE;CACd,CAAC,CAAC"}
|
|
@@ -10,11 +10,15 @@ export declare class DiscordChannel implements Channel {
|
|
|
10
10
|
private handler;
|
|
11
11
|
private client;
|
|
12
12
|
private botUserId;
|
|
13
|
+
private readonly continuations;
|
|
13
14
|
constructor(config: DiscordConfig);
|
|
14
15
|
onMessage(handler: (msg: ChannelMessage) => Promise<void>): void;
|
|
15
16
|
start(): Promise<void>;
|
|
17
|
+
private mentionPattern;
|
|
16
18
|
private handleDiscordMessage;
|
|
17
19
|
stop(): Promise<void>;
|
|
20
|
+
private fetchTextChannel;
|
|
21
|
+
private rememberContinuations;
|
|
18
22
|
sendText(channelId: string, text: string, options?: SendOptions): Promise<string>;
|
|
19
23
|
editText(channelId: string, messageId: string, text: string): Promise<void>;
|
|
20
24
|
sendFile(channelId: string, file: Attachment): Promise<void>;
|
|
@@ -1 +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,
|
|
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,EAEV,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,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