@cogitator-ai/channels 0.9.2 → 0.10.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.
Files changed (102) hide show
  1. package/README.md +101 -11
  2. package/dist/assistant-config.d.ts +16 -0
  3. package/dist/assistant-config.d.ts.map +1 -1
  4. package/dist/assistant-config.js +22 -0
  5. package/dist/assistant-config.js.map +1 -1
  6. package/dist/channels/bluesky/account.d.ts +18 -0
  7. package/dist/channels/bluesky/account.d.ts.map +1 -0
  8. package/dist/channels/bluesky/account.js +25 -0
  9. package/dist/channels/bluesky/account.js.map +1 -0
  10. package/dist/channels/bluesky/channel.d.ts +89 -0
  11. package/dist/channels/bluesky/channel.d.ts.map +1 -0
  12. package/dist/channels/bluesky/channel.js +427 -0
  13. package/dist/channels/bluesky/channel.js.map +1 -0
  14. package/dist/channels/bluesky/config.d.ts +16 -0
  15. package/dist/channels/bluesky/config.d.ts.map +1 -0
  16. package/dist/channels/bluesky/config.js +2 -0
  17. package/dist/channels/bluesky/config.js.map +1 -0
  18. package/dist/channels/bluesky/connection.d.ts +40 -0
  19. package/dist/channels/bluesky/connection.d.ts.map +1 -0
  20. package/dist/channels/bluesky/connection.js +159 -0
  21. package/dist/channels/bluesky/connection.js.map +1 -0
  22. package/dist/channels/bluesky/feed.d.ts +59 -0
  23. package/dist/channels/bluesky/feed.d.ts.map +1 -0
  24. package/dist/channels/bluesky/feed.js +324 -0
  25. package/dist/channels/bluesky/feed.js.map +1 -0
  26. package/dist/channels/bluesky/index.d.ts +5 -0
  27. package/dist/channels/bluesky/index.d.ts.map +1 -0
  28. package/dist/channels/bluesky/index.js +4 -0
  29. package/dist/channels/bluesky/index.js.map +1 -0
  30. package/dist/channels/threads/account.d.ts +42 -0
  31. package/dist/channels/threads/account.d.ts.map +1 -0
  32. package/dist/channels/threads/account.js +64 -0
  33. package/dist/channels/threads/account.js.map +1 -0
  34. package/dist/channels/threads/channel.d.ts +119 -0
  35. package/dist/channels/threads/channel.d.ts.map +1 -0
  36. package/dist/channels/threads/channel.js +405 -0
  37. package/dist/channels/threads/channel.js.map +1 -0
  38. package/dist/channels/threads/client.d.ts +42 -0
  39. package/dist/channels/threads/client.d.ts.map +1 -0
  40. package/dist/channels/threads/client.js +97 -0
  41. package/dist/channels/threads/client.js.map +1 -0
  42. package/dist/channels/threads/feed.d.ts +74 -0
  43. package/dist/channels/threads/feed.d.ts.map +1 -0
  44. package/dist/channels/threads/feed.js +372 -0
  45. package/dist/channels/threads/feed.js.map +1 -0
  46. package/dist/channels/threads/index.d.ts +6 -0
  47. package/dist/channels/threads/index.d.ts.map +1 -0
  48. package/dist/channels/threads/index.js +6 -0
  49. package/dist/channels/threads/index.js.map +1 -0
  50. package/dist/channels/threads/token.d.ts +51 -0
  51. package/dist/channels/threads/token.d.ts.map +1 -0
  52. package/dist/channels/threads/token.js +128 -0
  53. package/dist/channels/threads/token.js.map +1 -0
  54. package/dist/feeds/attachments.d.ts +15 -0
  55. package/dist/feeds/attachments.d.ts.map +1 -0
  56. package/dist/feeds/attachments.js +85 -0
  57. package/dist/feeds/attachments.js.map +1 -0
  58. package/dist/feeds/errors.d.ts +39 -0
  59. package/dist/feeds/errors.d.ts.map +1 -0
  60. package/dist/feeds/errors.js +62 -0
  61. package/dist/feeds/errors.js.map +1 -0
  62. package/dist/feeds/index.d.ts +8 -0
  63. package/dist/feeds/index.d.ts.map +1 -0
  64. package/dist/feeds/index.js +6 -0
  65. package/dist/feeds/index.js.map +1 -0
  66. package/dist/feeds/publish-store.d.ts +148 -0
  67. package/dist/feeds/publish-store.d.ts.map +1 -0
  68. package/dist/feeds/publish-store.js +345 -0
  69. package/dist/feeds/publish-store.js.map +1 -0
  70. package/dist/feeds/publisher.d.ts +118 -0
  71. package/dist/feeds/publisher.d.ts.map +1 -0
  72. package/dist/feeds/publisher.js +308 -0
  73. package/dist/feeds/publisher.js.map +1 -0
  74. package/dist/feeds/storage.d.ts +33 -0
  75. package/dist/feeds/storage.d.ts.map +1 -0
  76. package/dist/feeds/storage.js +61 -0
  77. package/dist/feeds/storage.js.map +1 -0
  78. package/dist/feeds/text.d.ts +26 -0
  79. package/dist/feeds/text.d.ts.map +1 -0
  80. package/dist/feeds/text.js +126 -0
  81. package/dist/feeds/text.js.map +1 -0
  82. package/dist/feeds/token-store.d.ts +45 -0
  83. package/dist/feeds/token-store.d.ts.map +1 -0
  84. package/dist/feeds/token-store.js +128 -0
  85. package/dist/feeds/token-store.js.map +1 -0
  86. package/dist/formatters/markdown.d.ts.map +1 -1
  87. package/dist/formatters/markdown.js +6 -0
  88. package/dist/formatters/markdown.js.map +1 -1
  89. package/dist/formatters/plain-text.d.ts +7 -0
  90. package/dist/formatters/plain-text.d.ts.map +1 -0
  91. package/dist/formatters/plain-text.js +38 -0
  92. package/dist/formatters/plain-text.js.map +1 -0
  93. package/dist/gateway.js +1 -1
  94. package/dist/gateway.js.map +1 -1
  95. package/dist/index.d.ts +5 -1
  96. package/dist/index.d.ts.map +1 -1
  97. package/dist/index.js +4 -0
  98. package/dist/index.js.map +1 -1
  99. package/dist/runtime-builder.d.ts.map +1 -1
  100. package/dist/runtime-builder.js +54 -0
  101. package/dist/runtime-builder.js.map +1 -1
  102. package/package.json +23 -15
package/README.md CHANGED
@@ -15,10 +15,11 @@ pnpm add discord.js # Discord
15
15
  pnpm add @slack/bolt # Slack
16
16
  pnpm add @whiskeysockets/baileys # WhatsApp, 6.x or 7.x (+ qrcode-terminal to print the pairing QR)
17
17
  pnpm add ws # WebChat
18
+ pnpm add @atproto/api # Bluesky (Threads needs no SDK)
18
19
 
19
20
  # RuntimeBuilder (`cogitator up`)
20
21
  pnpm add better-sqlite3 # SQLite memory, knowledge graph and core facts (always needed)
21
- pnpm add pg # memory.adapter: postgres
22
+ pnpm add pg # memory.adapter: postgres, PostgresPublishStore, PostgresTokenStore
22
23
  ```
23
24
 
24
25
  All adapters are optional peer dependencies, loaded only when the channel starts; a missing one fails `start()` with an install hint. RuntimeBuilder capabilities load `@cogitator-ai/browser`, `@cogitator-ai/rag`, `@cogitator-ai/mcp` and `@cogitator-ai/models` (vision detection) on demand. `LocalWhisper` needs `@huggingface/transformers` and `ogg-opus-decoder`, and installs them with `npm install --no-save` when missing.
@@ -187,20 +188,100 @@ terminalChannel({ userName: 'Alice', prompt: '> ', onExit: () => shutdown() });
187
188
 
188
189
  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. Docs: [Terminal](https://cogitator.app/docs/channels/terminal).
189
190
 
191
+ ### Bluesky
192
+
193
+ ```bash
194
+ pnpm add @atproto/api
195
+ ```
196
+
197
+ ```typescript
198
+ import { blueskyChannel, FileTokenStore } from '@cogitator-ai/channels';
199
+
200
+ const bluesky = blueskyChannel({
201
+ identifier: process.env.BLUESKY_HANDLE!, // yourbot.bsky.social
202
+ appPassword: process.env.BLUESKY_APP_PASSWORD!, // Settings → Privacy and security → App passwords
203
+ store: new FileTokenStore(), // keeps the session across restarts
204
+ });
205
+ ```
206
+
207
+ The agent answers mentions, replies and quotes in their thread, and direct messages (the app password needs "Allow access to your direct messages"). The channel polls and keeps what it has seen on Bluesky itself, so it answers what arrived while it was stopped (`catchUp: false` starts from now). Bluesky cannot edit posts (`editable: false`), so answers go out finished, as a thread of 300-grapheme posts when long. A message's `channelId` is `post:<at-uri>`, `dm:<convoId>`, or `feed` for a new post. Docs: [Bluesky](https://cogitator.app/docs/channels/bluesky).
208
+
209
+ ### Threads
210
+
211
+ ```typescript
212
+ import { threadsChannel, FileTokenStore } from '@cogitator-ai/channels';
213
+
214
+ const threads = threadsChannel({
215
+ accessToken: process.env.THREADS_ACCESS_TOKEN!, // a long-lived token, renewed before it expires
216
+ store: new FileTokenStore(),
217
+ webhook: {
218
+ appSecret: process.env.THREADS_APP_SECRET!,
219
+ verifyToken: process.env.THREADS_VERIFY_TOKEN!,
220
+ port: 3200, // or mount threads.handleWebhook in your own server
221
+ },
222
+ });
223
+ ```
224
+
225
+ The agent answers replies to the bot's posts and mentions of it, from Meta's webhooks (verification and `X-Hub-Signature-256` checked) or, without `webhook`, by polling, which skips replies people make to each other. Answers go out finished, as a chain of 500-character replies when long. The Threads API has no direct messages. Docs: [Threads](https://cogitator.app/docs/channels/threads).
226
+
190
227
  ## Platform Comparison
191
228
 
192
- | Feature | Telegram | Discord | Slack | WhatsApp | WebChat |
193
- | ------------------ | ------------ | ------- | --------- | -------- | --------- |
194
- | Streaming (edit) | ✅ | ✅ | ✅ | ✅ | ✅ |
195
- | Reactions | ✅ | ✅ | ✅ | ❌ | ❌ |
196
- | Typing indicator | ✅ | ✅ | ❌ | ✅ | ✅ |
197
- | Photos → vision | ✅ | ✅ | ✅ | ✅ | ❌ |
198
- | Voice → STT | ✅ | ✅ | ✅ | ✅ | ❌ |
199
- | Max message length | 4096 | 2000 | 40000 | 65536 | unlimited |
200
- | Public URL needed | webhook only | no | HTTP only | no | no |
229
+ | Feature | Telegram | Discord | Slack | WhatsApp | WebChat | Bluesky | Threads |
230
+ | ------------------ | ------------ | ------- | --------- | -------- | --------- | ------------------ | ------------------ |
231
+ | Streaming (edit) | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ (sent finished) | ❌ (sent finished) |
232
+ | Reactions | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ |
233
+ | Typing indicator | ✅ | ✅ | ❌ | ✅ | ✅ | ❌ | ❌ |
234
+ | Photos → vision | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ |
235
+ | Voice → STT | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ |
236
+ | Max message length | 4096 | 2000 | 40000 | 65536 | unlimited | 300 per post | 500 per post |
237
+ | Public URL needed | webhook only | no | HTTP only | no | no | no | webhooks only |
201
238
 
202
239
  Outbound calls (`sendText`, `editText`, `sendFile`, `deleteMessage`) throw when the channel is not started, the target chat is unavailable or the platform rejects the request — wrap direct calls in `try/catch`. WebChat is the exception: only `sendText` throws for a disconnected client, the other calls are dropped. `sendText` returns the platform message id (for Discord, the id of the first chunk; continuation chunks are edited and deleted with it).
203
240
 
241
+ ## Social Feeds
242
+
243
+ Feeds publish posts instead of answering people. `BlueskyFeed` and `ThreadsFeed` publish text with a link card, images with alt text, tags and replies. `FeedPublisher` sends one post to several feeds, now or at `publishAt`:
244
+
245
+ ```typescript
246
+ import {
247
+ BlueskyFeed,
248
+ FeedPublisher,
249
+ FilePublishStore,
250
+ FileTokenStore,
251
+ ThreadsFeed,
252
+ } from '@cogitator-ai/channels';
253
+
254
+ const tokens = new FileTokenStore();
255
+ const publisher = new FeedPublisher({
256
+ feeds: [
257
+ new BlueskyFeed({
258
+ identifier: process.env.BLUESKY_HANDLE!,
259
+ appPassword: process.env.BLUESKY_APP_PASSWORD!,
260
+ store: tokens,
261
+ }),
262
+ new ThreadsFeed({ accessToken: process.env.THREADS_ACCESS_TOKEN!, store: tokens }),
263
+ ],
264
+ store: new FilePublishStore(), // scheduled posts and retries survive a restart
265
+ });
266
+
267
+ const { job } = await publisher.publish(
268
+ {
269
+ text: 'A new open model runs on a laptop:',
270
+ link: { url: 'https://example.com/story' },
271
+ tags: ['AI'],
272
+ },
273
+ { key: 'story-42' } // publishing twice with one key publishes once
274
+ );
275
+ publisher.start(); // publishes scheduled posts and retries when they are due
276
+ ```
277
+
278
+ - Each feed is tried on its own and each outcome saved as soon as it is known. A delivery keeps the feed's idempotency key from before its first attempt, so an attempt after a crash or a lost answer finds the post instead of publishing it twice (Bluesky publishes under that record key, Threads looks the post up). Retries wait as long as the feed asked or back off from one minute to an hour, and a full Threads quota is waited out without spending attempts.
279
+ - Text is measured as each feed counts it (`graphemeLength` on Bluesky, with its 3000-byte limit too, `threadsLength` on Threads with emoji as their UTF-8 bytes) and fitted to each feed with an ellipsis (`overflow: 'fail'` fails instead). Each feed checks its rules before sending (images, links, tags) and fails with a `FeedError` that says whether retrying helps.
280
+ - Jobs live in `MemoryPublishStore`, `FilePublishStore` or `PostgresPublishStore` (several workers, claims with `FOR UPDATE SKIP LOCKED`). A worker takes one due job at a time, extends its claim while it works and saves only while the claim is its own. Sessions and tokens live in `MemoryTokenStore`, `FileTokenStore` (owner-only file, shared safely by the stores of one process) or `PostgresTokenStore`.
281
+ - The Threads token renews itself a week before its 60 days end. `BlueskyAccount` and `ThreadsAccount` share one session between a feed and a channel.
282
+
283
+ Docs: [Social Feeds](https://cogitator.app/docs/channels/feeds).
284
+
204
285
  ## Gateway
205
286
 
206
287
  Routes incoming messages to your agent. Handles:
@@ -535,7 +616,7 @@ await runtime.cleanup();
535
616
 
536
617
  For a parsed YAML file, validate it first with `new RuntimeBuilder(AssistantConfigSchema.parse(yamlObject), process.env)` (the schema is exported, along with the `AssistantConfigInput` / `AssistantConfigOutput` types).
537
618
 
538
- - **Channels:** the terminal REPL plus `channels.telegram` (`TG_TOKEN` or `TELEGRAM_TOKEN`), `channels.discord` (`DISCORD_TOKEN`) and `channels.slack` (`SLACK_BOT_TOKEN`, `SLACK_SIGNING_SECRET`, optional `SLACK_APP_TOKEN` / `SLACK_PORT`). A configured channel without its token is skipped with a warning. `channels.whatsapp` (`{ ownerIds?, sessionPath? }`; owner ids are phone numbers without `@s.whatsapp.net`, the session defaults to `~/.cogitator/whatsapp-session`) needs `@whiskeysockets/baileys`. `channels.webchat` (`{ port?, path? }`, default `8080` and `/ws`, no `ownerIds`) needs `ws` and starts only with `WEBCHAT_TOKEN` set; clients connect with `?token=<WEBCHAT_TOKEN>`.
619
+ - **Channels:** the terminal REPL plus `channels.telegram` (`TG_TOKEN` or `TELEGRAM_TOKEN`), `channels.discord` (`DISCORD_TOKEN`) and `channels.slack` (`SLACK_BOT_TOKEN`, `SLACK_SIGNING_SECRET`, optional `SLACK_APP_TOKEN` / `SLACK_PORT`). A configured channel without its token is skipped with a warning. `channels.whatsapp` (`{ ownerIds?, sessionPath? }`, owner ids are phone numbers without `@s.whatsapp.net`, the session defaults to `~/.cogitator/whatsapp-session`) needs `@whiskeysockets/baileys`. `channels.webchat` (`{ port?, path? }`, default `8080` and `/ws`, no `ownerIds`) needs `ws` and starts only with `WEBCHAT_TOKEN` set, and clients connect with `?token=<WEBCHAT_TOKEN>`. `channels.bluesky` (`{ ownerIds?, posts?, directMessages?, pollInterval?, tokenPath? }`, owner ids are DIDs) needs `@atproto/api` and starts with `BLUESKY_HANDLE` and `BLUESKY_APP_PASSWORD`. `channels.threads` (`{ ownerIds?, webhook?: { port, path? }, pollInterval?, tokenPath? }`, owner ids are usernames) starts with `THREADS_ACCESS_TOKEN`, and with `THREADS_APP_SECRET` and `THREADS_VERIFY_TOKEN` for webhooks. Both keep their session or token in `tokenPath` (default `~/.cogitator/tokens.json`).
539
620
 
540
621
  - **Memory:** `memory.adapter: sqlite` (default, `memory.path`, default `~/.cogitator/memory.db`) or `postgres` (`memory.connectionString`, `DATABASE_URL` or `POSTGRES_URL`; requires `pg`). Core facts always live in the SQLite file. The knowledge graph (`memory.knowledgeGraph`) and auto-extraction (`memory.autoExtract`) are on by default; `memory.compaction.threshold` enables history compaction.
541
622
  - **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.
@@ -570,6 +651,15 @@ DATABASE_URL=postgres://user:pass@localhost:5432/cogitator # or POSTGRES_URL
570
651
  # WebChat
571
652
  WEBCHAT_TOKEN=your-secret # required by channels.webchat in cogitator.yml
572
653
 
654
+ # Bluesky (session kept in ~/.cogitator/tokens.json)
655
+ BLUESKY_HANDLE=yourbot.bsky.social
656
+ BLUESKY_APP_PASSWORD=... # an app password, with DM access to answer messages
657
+
658
+ # Threads (token renewed in ~/.cogitator/tokens.json)
659
+ THREADS_ACCESS_TOKEN=... # a long-lived token
660
+ THREADS_APP_SECRET=... # webhooks only
661
+ THREADS_VERIFY_TOKEN=... # webhooks only
662
+
573
663
  # STT (optional, for voice messages — pick one)
574
664
  DEEPGRAM_API_KEY=... # highest priority
575
665
  GROQ_API_KEY=... # free tier
@@ -29,6 +29,22 @@ export declare const AssistantConfigSchema: z.ZodObject<{
29
29
  port: z.ZodDefault<z.ZodNumber>;
30
30
  path: z.ZodOptional<z.ZodString>;
31
31
  }, z.core.$strip>>;
32
+ bluesky: z.ZodOptional<z.ZodObject<{
33
+ ownerIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
34
+ posts: z.ZodOptional<z.ZodBoolean>;
35
+ directMessages: z.ZodOptional<z.ZodBoolean>;
36
+ pollInterval: z.ZodOptional<z.ZodNumber>;
37
+ tokenPath: z.ZodOptional<z.ZodString>;
38
+ }, z.core.$strip>>;
39
+ threads: z.ZodOptional<z.ZodObject<{
40
+ ownerIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
41
+ webhook: z.ZodOptional<z.ZodObject<{
42
+ port: z.ZodNumber;
43
+ path: z.ZodOptional<z.ZodString>;
44
+ }, z.core.$strip>>;
45
+ pollInterval: z.ZodOptional<z.ZodNumber>;
46
+ tokenPath: z.ZodOptional<z.ZodString>;
47
+ }, z.core.$strip>>;
32
48
  }, z.core.$strip>>>;
33
49
  capabilities: z.ZodDefault<z.ZodOptional<z.ZodObject<{
34
50
  webSearch: z.ZodOptional<z.ZodBoolean>;
@@ -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;AA2FxB,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA4BhC,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"}
1
+ {"version":3,"file":"assistant-config.d.ts","sourceRoot":"","sources":["../src/assistant-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAiHxB,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA4BhC,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"}
@@ -21,6 +21,28 @@ const AssistantChannelsSchema = z.object({
21
21
  path: z.string().optional(),
22
22
  })
23
23
  .optional(),
24
+ bluesky: z
25
+ .object({
26
+ ownerIds: OwnerIdsSchema,
27
+ posts: z.boolean().optional(),
28
+ directMessages: z.boolean().optional(),
29
+ pollInterval: z.number().int().positive().optional(),
30
+ tokenPath: z.string().optional(),
31
+ })
32
+ .optional(),
33
+ threads: z
34
+ .object({
35
+ ownerIds: OwnerIdsSchema,
36
+ webhook: z
37
+ .object({
38
+ port: z.number().int().positive(),
39
+ path: z.string().optional(),
40
+ })
41
+ .optional(),
42
+ pollInterval: z.number().int().positive().optional(),
43
+ tokenPath: z.string().optional(),
44
+ })
45
+ .optional(),
24
46
  });
25
47
  const ApprovalsSchema = z
26
48
  .object({
@@ -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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,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,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"}
@@ -0,0 +1,18 @@
1
+ import type { BlueskyConnectionConfig } from './config.js';
2
+ /**
3
+ * One Bluesky account and its session, to share between `BlueskyFeed` and
4
+ * `BlueskyChannel` so they sign in once and refresh one session.
5
+ */
6
+ export declare class BlueskyAccount {
7
+ readonly identifier: string;
8
+ constructor(config: BlueskyConnectionConfig);
9
+ /** Signs in, or resumes the stored session. */
10
+ connect(): Promise<void>;
11
+ /** The DID of the account, signing in if needed. */
12
+ did(): Promise<string>;
13
+ }
14
+ /** The account a feed or channel config names, or a new one for its credentials. */
15
+ export declare function accountOf(config: {
16
+ account: BlueskyAccount;
17
+ } | BlueskyConnectionConfig): BlueskyAccount;
18
+ //# sourceMappingURL=account.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../../src/channels/bluesky/account.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAGxD;;;GAGG;AACH,qBAAa,cAAc;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;gBAEhB,MAAM,EAAE,uBAAuB;IAK3C,+CAA+C;IACzC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9B,oDAAoD;IACpD,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;CAGvB;AAED,oFAAoF;AACpF,wBAAgB,SAAS,CACvB,MAAM,EAAE;IAAE,OAAO,EAAE,cAAc,CAAA;CAAE,GAAG,uBAAuB,GAC5D,cAAc,CAEhB"}
@@ -0,0 +1,25 @@
1
+ import { BlueskyConnection, connectionOf, register } from './connection.js';
2
+ /**
3
+ * One Bluesky account and its session, to share between `BlueskyFeed` and
4
+ * `BlueskyChannel` so they sign in once and refresh one session.
5
+ */
6
+ export class BlueskyAccount {
7
+ identifier;
8
+ constructor(config) {
9
+ this.identifier = config.identifier;
10
+ register(this, new BlueskyConnection(config));
11
+ }
12
+ /** Signs in, or resumes the stored session. */
13
+ async connect() {
14
+ await connectionOf(this).agent();
15
+ }
16
+ /** The DID of the account, signing in if needed. */
17
+ did() {
18
+ return connectionOf(this).did();
19
+ }
20
+ }
21
+ /** The account a feed or channel config names, or a new one for its credentials. */
22
+ export function accountOf(config) {
23
+ return 'account' in config ? config.account : new BlueskyAccount(config);
24
+ }
25
+ //# sourceMappingURL=account.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account.js","sourceRoot":"","sources":["../../../src/channels/bluesky/account.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEzE;;;GAGG;AACH,MAAM,OAAO,cAAc;IAChB,UAAU,CAAS;IAE5B,YAAY,MAA+B;QACzC,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QACpC,QAAQ,CAAC,IAAI,EAAE,IAAI,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC;IAChD,CAAC;IAED,+CAA+C;IAC/C,KAAK,CAAC,OAAO;QACX,MAAM,YAAY,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC;IACnC,CAAC;IAED,oDAAoD;IACpD,GAAG;QACD,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,CAAC;IAClC,CAAC;CACF;AAED,oFAAoF;AACpF,MAAM,UAAU,SAAS,CACvB,MAA6D;IAE7D,OAAO,SAAS,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;AAC3E,CAAC"}
@@ -0,0 +1,89 @@
1
+ import type { Attachment, Channel, ChannelMessage, SendOptions } from '@cogitator-ai/types';
2
+ import { type BlueskyAccount } from './account.js';
3
+ import type { BlueskyConnectionConfig } from './config.js';
4
+ export type BlueskyChannelConfig = ({
5
+ account: BlueskyAccount;
6
+ } | BlueskyConnectionConfig) & {
7
+ /** How often to look for mentions, replies and messages, in ms (default 15 000). */
8
+ pollInterval?: number;
9
+ /** Answers mentions, replies and quotes of the account's posts (default true). */
10
+ posts?: boolean;
11
+ /**
12
+ * Answers direct messages (default true). Needs an app password created
13
+ * with "Allow access to your direct messages".
14
+ */
15
+ directMessages?: boolean;
16
+ /** Answers what arrived while the channel was stopped (default true), false starts from now. */
17
+ catchUp?: boolean;
18
+ };
19
+ /**
20
+ * A conversational Bluesky channel: an agent answers mentions, replies and
21
+ * quotes of its posts in their threads, and direct messages in their
22
+ * conversation. It polls, and keeps what it has seen on Bluesky itself (the
23
+ * notifications' seen time, each conversation's read state), so it needs no
24
+ * state of its own across restarts. Bluesky cannot edit posts, so answers
25
+ * are sent once finished, as a thread of posts or several messages when
26
+ * long. A message's `channelId` is `post:<uri>` to answer under that post,
27
+ * `dm:<convoId>` for a conversation, or `feed` for a new post.
28
+ */
29
+ export declare class BlueskyChannel implements Channel {
30
+ readonly type = "bluesky";
31
+ readonly editable = false;
32
+ readonly nativeMarkdown = false;
33
+ readonly maxMessageChars: number;
34
+ readonly account: BlueskyAccount;
35
+ private readonly feed;
36
+ private readonly interval;
37
+ private readonly posts;
38
+ private readonly directMessages;
39
+ private readonly catchUp;
40
+ private handler;
41
+ private timer?;
42
+ private polling?;
43
+ private readonly seen;
44
+ private readonly requests;
45
+ private chatOf?;
46
+ private backlog?;
47
+ private readonly conversations;
48
+ private ownDid?;
49
+ private running;
50
+ constructor(config: BlueskyChannelConfig);
51
+ onMessage(handler: (msg: ChannelMessage) => Promise<void>): void;
52
+ start(): Promise<void>;
53
+ stop(): Promise<void>;
54
+ /** Looks for new mentions, replies and messages once. `start()` does this on a timer. */
55
+ poll(): Promise<void>;
56
+ sendText(channelId: string, text: string, options?: SendOptions): Promise<string>;
57
+ editText(): Promise<void>;
58
+ sendFile(channelId: string, file: Attachment, options?: SendOptions): Promise<string>;
59
+ sendTyping(): Promise<void>;
60
+ deleteMessage(channelId: string, messageId: string): Promise<void>;
61
+ /** The chat service agent of the current session, made again after a new sign-in. */
62
+ private chat;
63
+ private remember;
64
+ private skipBacklog;
65
+ /**
66
+ * Answers the unread mentions, replies and quotes, oldest first of each
67
+ * batch, paging back to the first one already seen, then marks them seen.
68
+ * A backlog longer than one poll reads is carried on from where the last
69
+ * poll stopped, and nothing is marked seen until it is read to the end,
70
+ * since marking a time seen also marks everything older.
71
+ */
72
+ private pollPosts;
73
+ private postMessage;
74
+ private pollMessages;
75
+ /**
76
+ * Answers a conversation's unread messages, then marks it read. History
77
+ * runs newest first and holds the bot's own, deleted and system messages
78
+ * too, so it is read back until as many messages from others as are
79
+ * unread were found. A conversation with more than one poll reads is
80
+ * carried on by the next poll from where this one stopped, and marked
81
+ * read only at the end, since marking a message read marks all before it.
82
+ */
83
+ private readConversation;
84
+ private sendMessages;
85
+ private deliver;
86
+ }
87
+ /** A conversational Bluesky channel. */
88
+ export declare function blueskyChannel(config: BlueskyChannelConfig): BlueskyChannel;
89
+ //# sourceMappingURL=channel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../../src/channels/bluesky/channel.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAE5F,OAAO,EAAa,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAWxD,MAAM,M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