469 Commits

Author SHA1 Message Date
malewis5 e0880e80c3 save 2026-03-11 14:51:18 -04:00
Matthew Lewis d565c61e9d add github username (#216) 2026-03-11 10:41:24 -04:00
Hayden Bleasel deeb9cec3a Improve tests 2026-03-10 23:35:14 -07:00
Ben Sabic 4c7a2b2bec Document scheduled message support across all docs (#207)
Add thread.schedule() and channel.schedule() documentation to the
API reference, usage guides, feature matrix, error handling guide,
adapter building guide, and SKILL.md.

Co-authored-by: Ben Sabic <bensabic@users.noreply.github.com>
2026-03-10 22:20:57 -07:00
Ben Sabic 7c4719b3f3 Adds two Workflow-focused guides (#211)
* Add workflow guides for durable chat sessions and scheduled posts

* Update workflow guides

* fix: use correct Workflow APIs and fix TypeScript issues

- Replace `defineHook`/`.create()`/`.resume()` with `createHook` + `resumeHook` from documented Workflow APIs
- Add TypeScript 5.2+ note for `using` keyword (explicit resource management)
- Fix `result.rowCount` null safety in cancelScheduledPost

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Ben Sabic <bensabic@users.noreply.github.com>
Co-authored-by: Hayden Bleasel <hello@haydenbleasel.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-10 21:13:00 -07:00
Matthew Lewis ee1c025ea7 fix(telegram): fix DM replies failing with "chat not found" (#214)
* fix(telegram): fix DM replies failing with "chat not found"

postChannelMessage was double-wrapping the channel ID with the
telegram: prefix via encodeThreadId, producing "telegram:telegram:<chatId>".
This caused sendMessage to be called with chat_id "telegram" instead of
the actual chat ID. Pass the channel ID directly to postMessage which
already handles prefix resolution via resolveThreadId.

Made-with: Cursor

* test(telegram): add postChannelMessage tests

Verify channel ID is not double-prefixed and works with both
telegram:-prefixed and raw channel IDs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Hayden Bleasel <hello@haydenbleasel.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-10 20:55:25 -07:00
Hayden Bleasel 135088b824 Update logo 2026-03-10 16:21:32 -07:00
Achraf Ghellach 60f5d8e19f feat: add WhatsApp Business Cloud API adapter (#102)
* feat: add WhatsApp Business Cloud API adapter

Add @chat-adapter/whatsapp with support for sending/receiving messages,
reactions, interactive reply buttons, typing indicators, and webhook
verification via the Meta Graph API. Includes full test suite,
documentation updates, and workspace/turbo configuration.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat: add media download, attachments, and location support to WhatsApp adapter

- Add downloadMedia() public method for fetching images, documents,
  audio, video, and stickers via the Graph API (two-step: URL then binary)
- Populate message attachments with lazy fetchData() for all media types
- Add location support with Google Maps URL and structured text
- Add audio, video, sticker, and location fields to WhatsAppInboundMessage
- Set isMention: true on all messages (WhatsApp DMs are always direct)
- Update parseMessage to include attachments and isMention
- Add 10 new tests covering all media types, locations, and isMention
- Update docs feature matrix to reflect media receive support

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: address PR review feedback for WhatsApp adapter

- Validate Graph API response before accessing messages[0].id in
  sendTextMessage and sendInteractiveMessage
- Escape backticks and backslashes in escapeWhatsApp()
- Apply escapeWhatsApp() to renderText() content in all style branches
- Use webhook phoneNumberId in buildMessage() instead of this.phoneNumberId
- Encode proper threadId in parseMessage() instead of empty string
- Strict decodeThreadId() validation (exactly 2 segments after prefix)
- Add tests for extra segments in decodeThreadId and threadId in parseMessage

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Migrate improvements from #179

Bring over several enhancements from chitru's WhatsApp adapter PR (#179):

- Voice message support (separate from audio)
- Legacy button response handling (template quick replies)
- Callback data encoding/decoding for interactive reply round-trips
- Message truncation at WhatsApp's 4096 char limit
- Example app integration (adapters, webhook route, package.json)
- GET webhook forwarding for WhatsApp verification challenges
- Package README and changeset
- Tests for all new functionality (68 total)

Co-Authored-By: Chitru Shrestha <chitra.shrestha@akuru.com.au>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(whatsapp): add error handling for inbound message processing

Wrap handleInboundMessage calls in try/catch to log errors if
synchronous processing fails (e.g., thread ID encoding). The async
processing already has its own error handling in Chat.processMessage.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(whatsapp): prevent markdown regex from matching across newlines

Use [^\n*] and [^\n~] in fromWhatsAppFormat regex to prevent bold/strike
spans from merging across line boundaries. Adds a regression test.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(whatsapp): use WhatsAppInteractiveMessage type instead of object

Replace the untyped `object` parameter in sendInteractiveMessage with
the proper WhatsAppInteractiveMessage type for full type safety.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(whatsapp): hoist emoji mapping to module-level constant

Move the emoji name-to-unicode mapping out of resolveEmoji() so it is
not re-allocated on every call.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(whatsapp): remove duplicate JSDoc comment in types

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(example): add startTyping to WhatsApp recording methods

The adapter supports typing indicators but the method was missing from
the recording proxy list.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(whatsapp): fix formatting and add package to readme test allowlist

Fix line-length formatting in markdown.ts regex and add
@chat-adapter/whatsapp to the valid packages list in readme tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(whatsapp): use defaultEmojiResolver instead of custom emoji map

Replace the hand-rolled EMOJI_MAP with the shared defaultEmojiResolver
from the chat SDK. WhatsApp uses unicode emoji like GChat, so toGChat()
provides the correct mapping with broader coverage.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(whatsapp): make Graph API version configurable

Add apiVersion option to WhatsAppAdapterConfig (defaults to v21.0)
so users can upgrade without waiting for a package release.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(whatsapp): validate lat/lng before constructing Google Maps URL

Coerce and validate latitude/longitude with Number.isFinite() to
prevent unexpected URL construction from malformed webhook payloads.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(whatsapp): throw on editMessage instead of silently sending new message

Callers expecting an edit would get duplicate messages with the silent
fallback. Throwing makes the unsupported operation explicit.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(whatsapp): document regex asymmetry between toWhatsApp and fromWhatsApp

Explain why toWhatsAppFormat doesn't need newline guards like
fromWhatsAppFormat does — the standard markdown parser output
never produces spans crossing line boundaries.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(whatsapp): document callback data passthrough behavior

Add comments explaining that non-prefixed and malformed callback data
is intentionally passed through for legacy/external button IDs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(whatsapp): add editMessage and deleteMessage to recording methods

Include all adapter methods in the recording list for complete
debugging traces, even for unsupported operations.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(whatsapp): preserve escaped formatting chars in toWhatsAppFormat

Escaped asterisks and tildes in standard markdown (e.g. \* and \~) are
now preserved through the conversion pipeline so WhatsApp renders them
as literal characters instead of misinterpreting them as formatting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(whatsapp): split long messages instead of truncating

Replace silent truncation at 4096 chars with message splitting that
breaks on paragraph (\n\n) then line (\n) boundaries, sending multiple
messages so no content is lost. Adds 8 tests for the splitting logic.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(whatsapp): align editMessage/deleteMessage behavior and docs

- Fix README: editMessage/deleteMessage both throw, not fallback/no-op
- Fix editMessage JSDoc to reflect it throws
- Make deleteMessage throw instead of silently warning (consistent with editMessage)
- Bump @types/node to ^25.3.2 to match monorepo
- Add sample-messages.md with webhook payload examples

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* docs(whatsapp): add adapter documentation page

Add whatsapp.mdx covering installation, usage, Meta app setup,
webhook config, interactive messages, media attachments, 24-hour
messaging window, configuration, features, and troubleshooting.
Also add WhatsApp to the adapters navigation in meta.json.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: add whatsapp adapter debug logging and try/catch

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(whatsapp): convert emoji placeholders in outgoing messages

WhatsApp adapter was sending raw {{emoji:wave}} placeholders instead of
Unicode emoji. Apply convertEmojiPlaceholders on all outgoing paths:
text messages, card fallback text, and interactive message fields.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Fix button rendering and streaming (needs to buffer)

* fix(example): handle editMessage failure on WhatsApp

WhatsApp Cloud API doesn't support message editing. Catch the error
in the demo "processing" animation and send a follow-up instead.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat(chat): add onDirectMessage handler, stop treating DMs as mentions

DMs now route to dedicated onDirectMessage handlers instead of being
forced through onNewMention. If no DM handlers registered, DMs fall
through to onNewMention for backward compat. Adapters no longer set
isMention=true for DMs — the Chat SDK handles routing via adapter.isDM().

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat(chat): always route DMs to onDirectMessage regardless of subscription

Previously, onDirectMessage only fired for unsubscribed DM threads.
Subscribed DMs were routed to onSubscribedMessage, which was confusing
on non-threaded platforms (WhatsApp, Telegram) where all DMs share one
threadId — after the first message, onDirectMessage never fired again.

Now, DMs always route to onDirectMessage first, and onSubscribedMessage
only handles non-DM subscribed threads. Backward compat is preserved:
if no onDirectMessage handlers are registered, DMs fall through as
mentions.

The example bot is simplified accordingly — onDirectMessage now fetches
conversation history via fetchMessages each time instead of relying on
subscribe() and stored state.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat(chat): pass channel as third argument to DirectMessageHandler

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(example): reply to channel instead of thread in DM handler

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(example): use thread instead of channel for DM operations

Channel ID is only two parts (whatsapp:{phoneNumberId}) which isn't a
valid conversation target on WhatsApp. The thread ID includes the user
phone and is required for startTyping/post/fetchMessages.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Revert "fix(example): use thread instead of channel for DM operations"

This reverts commit f4801d7015.

* fix(adapters): return valid thread IDs from channelIdFromThreadId

WhatsApp's channelIdFromThreadId was stripping the user WA ID, producing
an invalid ID that caused ValidationError on channel operations like
startTyping(). Since every WhatsApp conversation is a 1:1 DM, channel
and thread are identical.

Telegram's channelIdFromThreadId was returning a raw chatId without the
telegram: prefix, which is not a valid thread ID for adapter operations.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(chat): normalize fullStream in Channel.post() to extract text deltas

Channel.post() was coercing AI SDK fullStream objects to strings via +=,
producing "[object Object]" output. Now uses fromFullStream() to extract
text-delta events, matching how Thread.post() already handles streams.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(example): use thread.allMessages for DM history instead of adapter directly

The DM handler was calling channel.adapter.fetchMessages() which always
returns empty on WhatsApp (no native history API). Now uses
thread.allMessages which falls back to the persisted message history
cache, giving the AI conversation context.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat(chat): add message history support to Channel for DM platforms

Channel now falls back to the persisted message history cache when the
adapter lacks native message fetch (e.g. WhatsApp, Telegram). Incoming
messages are persisted under both thread and channel IDs. Outgoing
messages from channel.post() are also persisted.

The example DM handler now uses channel.messages instead of calling the
adapter directly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(whatsapp): improve markdown rendering and remove broken typing indicator

- Convert headings to bold text, thematic breaks to text separators,
  and tables to code blocks (WhatsApp doesn't support these)
- Convert standard italic (*text*) to WhatsApp italic (_text_) since
  WhatsApp uses *text* for bold
- Make startTyping a no-op (Cloud API doesn't support typing indicators)
- Update channelIdFromThreadId test for channel===thread change

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(example): reverse channel.messages to chronological order for AI

channel.messages yields newest first but AI expects chronological order.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(chat): auto-sort messages chronologically in toAiMessages

toAiMessages now sorts by dateSent (oldest first) so callers don't need
to worry about iteration order from channel.messages or thread.messages.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(chat): pass accumulated stream text as markdown in Channel.post()

Stream text was posted as a plain string, bypassing the adapter's format
converter. Now wraps it as { markdown: accumulated } so headings, bold,
italic etc. are properly converted for each platform.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(whatsapp): use stringifier options for emphasis and bullets

Use emphasis: '_' and bullet: '-' options in stringifyMarkdown so the
only * in output is **strong**, avoiding conflicts between list bullets
and italic markers. Simplifies toWhatsAppFormat to only convert
**bold** -> *bold* and ~~strike~~ -> ~strike~.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(whatsapp): flatten bold inside headings to avoid triple asterisks

When AI outputs headings with bold text like `## **Choose React if:**`,
the heading-to-bold conversion created nested strong nodes producing
`***text***`. Now flattens strong children in headings so they merge
into a single bold span.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* test(whatsapp): add full toBe assertion for complex markdown conversion

Also use ━━━ for thematic breaks instead of --- to avoid remark escaping.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* test: add WhatsApp replay tests from production recordings

Adds WhatsApp DM replay test infrastructure:
- Fixture from real webhook recordings (dm/whatsapp.json)
- WhatsApp test utilities with HMAC-signed request factory and
  Graph API fetch mock (whatsapp-utils.ts)
- 6 replay tests covering DM handling, thread/channel IDs, message
  sending, status update filtering, sequential messages, and
  message history persistence

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(whatsapp): fix type narrowing in replay test after merge

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Update WhatsApp logo

* Update adapters.json

* Update logos.tsx

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Hayden Bleasel <hello@haydenbleasel.com>
Co-authored-by: Chitru Shrestha <chitra.shrestha@akuru.com.au>
Co-authored-by: Malte Ubl <malte.ubl@gmail.com>
2026-03-10 15:16:10 -07:00
Hayden Bleasel 6e4004a88c Improve og:images 2026-03-10 11:19:33 -07:00
Hayden Bleasel 28302300a7 Update metadata 2026-03-10 11:00:49 -07:00
Hayden Bleasel 2fa840c84d Fix opengraph image 2026-03-10 10:58:57 -07:00
github-actions[bot] 7ba7465071 Version Packages (#200)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@chat-adapter/state-memory@4.19.0 chat@4.19.0 @chat-adapter/telegram@4.19.0 @chat-adapter/teams@4.19.0 @chat-adapter/state-redis@4.19.0 @chat-adapter/state-pg@4.19.0 @chat-adapter/state-ioredis@4.19.0 @chat-adapter/slack@4.19.0 @chat-adapter/shared@4.19.0 @chat-adapter/linear@4.19.0 @chat-adapter/github@4.19.0 @chat-adapter/gchat@4.19.0 @chat-adapter/discord@4.19.0
2026-03-09 23:10:49 -07:00
Hayden Bleasel 30698ed6d8 Adapters (#204)
* Initial marketplace draft

* Update language

* Add logos to cards

* Redesign cards

* Update adapter-card.tsx

* Update adapter-card.tsx

* Migrate marketplace to adapters

* Update meta.json

* Split adapters into new three groups

* Add iMessage

* Move adapter docs to READMEs

* Cleanup docs

* Add more logos, implement shadcn ui components

* Update adapters.json

* Add Streamdown

* Fetch vercel readmes from workspace

* Update readme-content.tsx

* Upgrade Streamdown

* Update global.css

* Update adapters.json

* Update adapters.json

* Add links to docs

* List upcoming official adapters

* Update adapters.json

* Fix adapters links

* Fix typo

* Misc fixes

* Update adapters.json

* Update adapters.json

* Migrate new info

* Update pnpm-lock.yaml

* Update adapter-card.tsx

* Add postgres to adapters page

* Update adapter-card.tsx

* Migrate postgres docs

* Add pg to valid README imports

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Move feature matrices from docs to package READMEs

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Remove packages tables from adapter/state docs

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Genericize adapter/state doc descriptions

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: improve adapters page accessibility and empty state handling

* Add custom adapter building section to SKILL.md

* Use currentColor for GitHub, Linear, and Memory icons

* Use GitHub API for README fetch, add heading to fallback state

Use the GitHub REST API instead of raw.githubusercontent.com to
automatically resolve the repo's default branch, so community
adapters using master or other branch names work correctly.

* Update adapters-grid.tsx

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Ben Sabic <bensabic@users.noreply.github.com>
2026-03-09 16:09:42 -07:00
Ben Sabic dac88f8ad1 docs: mention PostgreSQL state adapter across remaining docs (#201)
Several docs pages only referenced Redis as the production state
adapter. Add PostgreSQL mentions to usage page, guide "Next steps"
sections, adapters overview, SKILL.md, and package README.

Co-authored-by: Ben Sabic <bensabic@users.noreply.github.com>
2026-03-08 12:43:33 -07:00
Hayden Bleasel 736880ad90 Resolves #203 2026-03-08 12:41:01 -07:00
Ben Sabic 5b41f0869d feat: add scheduled message support via Slack's chat.scheduleMessage API (#202)
Add thread.schedule() and ScheduledMessage type for scheduling messages
to be sent at a future time. The Slack adapter implements scheduling
natively via chat.scheduleMessage with cancel() support via
chat.deleteScheduledMessage. Other adapters throw NotImplementedError.

Co-authored-by: Ben Sabic <bensabic@users.noreply.github.com>
2026-03-08 06:53:21 -07:00
Hayden Bleasel c4b0e69012 Misc improvements 2026-03-08 00:02:53 -08:00
Georgios Konstantopoulos eb49b2a9d1 feat: add forceReleaseLock + onLockConflict for interrupt/steerability (#193)
* feat: add forceReleaseLock and onLockConflict for steerability

Amp-Thread-ID: https://ampcode.com/threads/T-019cc675-20e8-73db-b852-5690bafe0008
Co-authored-by: Amp <amp@ampcode.com>

* fix: add forceReleaseLock to mock state adapter

Implements the new StateAdapter.forceReleaseLock method in the mock
adapter so tests using createMockState() don't break.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat: support async onLockConflict callbacks

Allow the onLockConflict callback to return a Promise, enabling
users to check external state (e.g. DB queries) before deciding
whether to force-release or drop.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* test: add tests for forceReleaseLock and onLockConflict

Covers: default drop behavior, force mode, sync/async callbacks
returning force/drop, and forceReleaseLock on memory adapter.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* chore: add changeset for forceReleaseLock and onLockConflict

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: alphabetize interface members, add forceReleaseLock to ioredis adapter

Biome enforces alphabetical ordering on interface members. Also adds
the missing forceReleaseLock implementation to the ioredis state adapter.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: add missing @chat-adapter/state-ioredis to changeset

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: add comment noting race window after force-release

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* test: add forceReleaseLock tests for ioredis adapter

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* test: assert lock re-acquisition after force-release

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* test: add forceReleaseLock tests for state-redis adapter

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* test: replace fragile acquireLock call count with last-call assertion

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* docs: document concurrent handler execution after force-release

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: use .at(-1) and single-line format for biome compliance

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat: add forceReleaseLock to state-pg adapter

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* docs: document onLockConflict and forceReleaseLock

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Hayden Bleasel <hello@haydenbleasel.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-07 23:43:40 -08:00
Fernando Rojo dd60e67f5f fix: discord docs (#199) 2026-03-07 16:54:24 -08:00
Malte Ubl 350717aa6b Switch back to sonnet. Otherwise streaming is too fast. Remove the immediate response on AI responses. 2026-03-07 12:42:26 -08:00
github-actions[bot] 28cbcb2994 Version Packages (#192)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
chat@4.18.0 @chat-adapter/telegram@4.18.0 @chat-adapter/teams@4.18.0 @chat-adapter/state-redis@4.18.0 @chat-adapter/state-pg@4.18.0 @chat-adapter/state-memory@4.18.0 @chat-adapter/state-ioredis@4.18.0 @chat-adapter/slack@4.18.0 @chat-adapter/shared@4.18.0 @chat-adapter/linear@4.18.0 @chat-adapter/github@4.18.0 @chat-adapter/gchat@4.18.0 @chat-adapter/discord@4.18.0
2026-03-07 12:39:16 -08:00
Malte Ubl a3cfc1aee3 Support native tables in slack (#194)
* Support native tables in slack

Brand new per https://docs.slack.dev/reference/block-kit/blocks/table-block/
Only one per message.

* Record streams

* Error handling

* Debugging

* fix-delta

* fix-delta2

* fix-delta3

* fix-delta4

* fix-delta5

* show-table

* show-table2

* replay-test

* changeset

* lint-types
2026-03-07 12:31:18 -08:00
Hayden Bleasel ebbe108b76 Fix code scanning issues 2026-03-06 17:15:03 -08:00
bai 8fe175f7fe Implement state adapter based on Postgres (#154)
* Initial work on postgres state store

* Run fix

* Replace pre-written CHANGELOG with proper changeset

The CHANGELOG was manually written with a version entry. This repo uses
Changesets to manage versioning, so add a proper changeset file instead.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Add missing @vitest/coverage-v8 dev dependency

The vitest config specifies coverage provider "v8" but the package
was missing from devDependencies.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Drop drizzle-orm, use raw postgres queries

The adapter only needs 3 simple tables with basic CRUD. drizzle-orm is
a full ORM that adds significant dependency weight for no real benefit
here. The ensureSchema() method was already using raw queries. This
halves the dependency surface to just the postgres driver.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Add comprehensive unit tests for postgres state adapter

Test factory function edge cases (missing URL, env var fallbacks,
custom keyPrefix) and ensureConnected guard for all state operations.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Document expired row cleanup limitation for postgres adapter

Unlike Redis, Postgres doesn't auto-delete expired rows. Document the
opportunistic cleanup behavior and provide SQL for periodic cleanup.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Remove stale drizzle keyword from package.json

drizzle-orm was removed in a prior commit but the keyword remained.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Fix expiresAt parsing in acquireLock

The postgres library returns timestamptz columns as JavaScript Date
objects, not strings. Wrapping in new Date() was unnecessary overhead.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Document lock atomicity difference vs Redis adapters

The Postgres ON CONFLICT approach relies on row-level locking rather
than a single atomic SET NX PX like Redis. Note this for users who
need high-contention distributed locking.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Use crypto.randomUUID() for lock token generation

Math.random() is not cryptographically secure and has a higher
collision risk in distributed environments. crypto.randomUUID() is
available in Node 16+ and provides better uniqueness guarantees.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Delete CHANGELOG.md

* Add comprehensive unit tests for postgres state adapter

Mock the postgres module and SQL client to achieve 100% coverage
across statements, branches, functions, and lines. Tests cover
factory function, connection lifecycle, subscriptions, locking,
cache operations, and the owned-client disconnect path.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Add setIfNotExists method and merge with main

Implement the setIfNotExists method added to the StateAdapter
interface since this branch diverged. Uses INSERT ... ON CONFLICT
DO NOTHING with RETURNING to atomically check-and-set.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Add postgres to state docs navigation and memory adapter callout

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Migrate postgres state adapter from postgres to pg (node-postgres)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Rename state-postgres to state-pg and align version to 4.17.0

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Hayden Bleasel <hello@haydenbleasel.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 17:05:32 -08:00
github-actions[bot] 3f881daf07 Version Packages (#186)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
chat@4.17.0 @chat-adapter/telegram@4.17.0 @chat-adapter/teams@4.17.0 @chat-adapter/state-redis@4.17.0 @chat-adapter/state-memory@4.17.0 @chat-adapter/state-ioredis@4.17.0 @chat-adapter/slack@4.17.0 @chat-adapter/shared@4.17.0 @chat-adapter/linear@4.17.0 @chat-adapter/github@4.17.0 @chat-adapter/gchat@4.17.0 @chat-adapter/discord@4.17.0
2026-03-06 00:01:23 -08:00
Hayden Bleasel c744bdc2ef Update teams.mdx 2026-03-05 17:08:16 -08:00
Hayden Bleasel b35bb34dd5 feat: make adapter constructors default to env vars (#182)
* Update adapter configs

* Update tests

* Add new adapter config tests

* Update index.mdx

* Update index.test.ts

* Fix polynomial regex issue

* Update index.ts

* Remove unused suppressions

* Misc fixes

* Update index.test.ts

* Update index.test.ts

* Update index.ts

* Update index.mdx

* Test and lint fixes
2026-03-05 16:29:44 -08:00
Hayden Bleasel cc65dc3111 fix: atomic message deduplication to prevent silent app_mention drops (#189)
* Add setIfNotExists

* Update chat.test.ts

* Improve tests

* Create bright-regions-dance.md
2026-03-05 16:16:03 -08:00
Hayden Bleasel d3db36ec35 fix(slack): check text value truthiness for file-only posts (#187)
* Update index.ts

* Update index.test.ts

* Create odd-news-jam.md
2026-03-05 16:15:51 -08:00
Hayden Bleasel 10b0e6b6ec fix(slack): allow file_share and other content subtypes through (#188)
* Update index.ts

* Update index.test.ts

* Create fluffy-onions-unite.md
2026-03-05 16:15:44 -08:00
Hayden Bleasel a3f8656243 Teams: support certificate and federated credentials (#190)
* Add federated auth support to Teams

* Update index.test.ts

* Create teams-certificate-federated-auth.md
2026-03-05 16:15:36 -08:00
Hayden Bleasel 5cfd9be5fa Fix JSX issues (#161)
* Fix JSX issues

* fix: add null guards for event.thread in onAction handlers

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-05 16:13:33 -08:00
Hayden Bleasel e09ce7ea4a Switch to using chatApi.media.download (#168) 2026-03-05 16:13:26 -08:00
Dardan Bujupaj 5f32506c2d fix discord thread starter root message parsing (#185)
* fix discord thread starter root message parsing

* use original thread start message as raw
2026-03-05 13:27:49 -08:00
github-actions[bot] e937e0d3dd Version Packages (#181)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
chat@4.16.1 @chat-adapter/telegram@4.16.1 @chat-adapter/teams@4.16.1 @chat-adapter/state-redis@4.16.1 @chat-adapter/state-memory@4.16.1 @chat-adapter/state-ioredis@4.16.1 @chat-adapter/slack@4.16.1 @chat-adapter/shared@4.16.1 @chat-adapter/linear@4.16.1 @chat-adapter/github@4.16.1 @chat-adapter/gchat@4.16.1 @chat-adapter/discord@4.16.1
2026-03-04 15:27:16 -08:00
Hayden Bleasel fcaee5c671 Update docs 2026-03-04 11:33:41 -08:00
zm2231 f27c89b424 feat(slack): streaming StreamChunk support + url_verification fix (#173)
* feat(slack): support streaming task_update, plan_update, markdown_text chunks

- Add StreamChunk type for structured streaming content
- Extend stream() to accept AsyncIterable<string | StreamChunk>
- Add taskDisplayMode option to StreamOptions
- Slack adapter passes structured chunks directly to Slack's streaming API
- Handle url_verification before signature check to prevent Slack from
  silently disabling event delivery when signing secret is misconfigured
- Add tests for StreamChunk handling in thread.post()

* review fixes: type safety, security, dedup

- Replace loose StreamChunk interface (index signature) with
  discriminated union (MarkdownTextChunk | TaskUpdateChunk | PlanUpdateChunk)
- Move url_verification back after signature check to prevent
  unauthenticated challenge responses
- Remove redundant AsyncIterable<string> from PostableMessage union
- Extract pushTextAndFlush helper to deduplicate markdown flush logic
- Remove unnecessary `as string` casts after type guards
- Export individual chunk types from package index

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* add changeset

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Hayden Bleasel <hello@haydenbleasel.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-04 11:31:30 -08:00
Hayden Bleasel 460eecc6db Update ci.yml 2026-03-04 11:15:51 -08:00
John Pham 130e780418 fix openModal crash when action has no thread context (#174)
* fix openModal crash when action has no thread context

Home tab actions (e.g. Change Team) have no thread → openModal closure
crashed accessing thread.channel on null. Guard thread access in the
openModal closure and pass undefined to storeModalContext.

Add test for empty threadId action → openModal works with null thread.

* add changeset

* make ActionEvent.thread nullable, remove unsafe cast

- Change `ActionEvent.thread` type from `Thread` to `Thread | null`
- Remove `null as unknown as Thread` unsafe cast in handleActionEvent
- Update test files to use null guards and optional chaining

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Hayden Bleasel <hello@haydenbleasel.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-04 11:15:33 -08:00
Utopia f0dfa4d64d fix: preserve nesting depth when rendering lists in all chat adapters (#177)
* fix: preserve nesting depth when rendering lists in all chat adapters

All format converters (Slack, Discord, Teams, Google Chat) were flattening
nested lists during Markdown→platform conversion. When a listItem had a
paragraph followed by a child list, the child list output was concatenated
directly onto the parent item's text with no indentation or separating
newline, producing garbled output like "• parent• child 1\n• child 2".

Add an optional `depth` parameter to each adapter's private `nodeToX()`
method. The `isListNode` handler now builds lines explicitly: paragraph
content is prefixed with the bullet/number at the correct indent level
(`"  ".repeat(depth)`), and nested list nodes are rendered recursively
at `depth + 1`. Sibling items at the same depth are unaffected.

Add regression tests covering:
- nested unordered lists (2 levels)
- nested ordered lists (2 levels)
- deeply nested lists (3 levels)
- flat sibling items (no regressions)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* refactor: extract renderList() helper to eliminate dead depth parameter

The previous fix added `depth = 0` to each adapter's general nodeToX()
method, but only the isListNode branch ever used it — a dead parameter
across ~10 other branches that made the signature misleading.

Extract a private renderList(node: List, depth: number) method in each
adapter. nodeToX() stays as a clean single-argument node converter;
all depth-aware list logic lives exclusively inside renderList(), which
recurses into itself for nested lists and calls nodeToX() for leaf nodes.

Import the List type from the chat package to give renderList() an
explicit, narrowed parameter type.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Deduplicate renderList into BaseFormatConverter, fix start offset, add mixed list tests

- Extract shared renderList() into BaseFormatConverter with configurable bullet char
- Respect List.start property for ordered lists starting at non-1 values
- Remove dead isListItemNode branches from all adapters
- Add mixed ordered/unordered nesting test to all adapters

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Hayden Bleasel <hello@haydenbleasel.com>
2026-03-04 11:06:32 -08:00
Malte Ubl ff954f938b Correctly handle AI SDK stream concatenation (#170)
* Correctly handle AI SDK stream concatenation

* changset

* docs

---------

Co-authored-by: Hayden Bleasel <hello@haydenbleasel.com>
2026-03-04 11:02:02 -08:00
Rich Haines 6b2a165e32 Make sitemap.md static via generateStaticParams (#176) 2026-03-04 10:56:38 -08:00
Hayden Bleasel 7bcf9d1578 Docs for f0c7050349 2026-03-04 10:52:06 -08:00
github-actions[bot] 0ab742c62d Version Packages (#133)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@chat-adapter/teams@4.16.0 chat@4.16.0 @chat-adapter/telegram@4.16.0 @chat-adapter/state-redis@4.16.0 @chat-adapter/state-memory@4.16.0 @chat-adapter/state-ioredis@4.16.0 @chat-adapter/slack@4.16.0 @chat-adapter/shared@4.16.0 @chat-adapter/linear@4.16.0 @chat-adapter/github@4.16.0 @chat-adapter/gchat@4.16.0 @chat-adapter/discord@4.16.0
2026-03-04 00:32:57 -08:00
Nicolás Montone f0c7050349 add member_joined_channel event support to Slack adapter (#167)
* Add member_joined_channel event support to Slack adapter

* changset

* Apply suggestion from @NicolasMontone

* fix
2026-03-03 16:24:40 -08:00
Hayden Bleasel bbe4de55bf Add docs for 73de82dbef 2026-03-03 12:57:17 -08:00
Hayden Bleasel deda3e59d4 Add docs for 02e7ef605c 2026-03-03 12:55:25 -08:00
Hayden Bleasel dc72b893ae Improve usage docs 2026-03-03 12:52:30 -08:00
Malte Ubl 02e7ef605c Implement markdown and AST rendering for tables across adapters (#160)
* Implement markdown and AST rendering for tables across adapters

* Render the default instead

* Fix bot app

* lint

* streaming-rendering

* fix-streaming

* fix-streaming-agent

* fix-streaming-again2

* fix-streaming-again3

* prefix tests

* no final edit

* changeset

* feedback

* lint

* Copilot feedback
2026-03-03 09:43:18 -08:00
Hayden Bleasel 73de82dbef Add remend for streaming markdown healing (#163)
* Add remend

* Create sixty-wasps-hope.md

* feat: wrap message content in markdown objects (#164)

Update 'fallbackStream' and 'handleStream' to send '{ markdown: string }'. Adjust tests for '{ markdown: string }'.

Slack-Thread: https://vercel.slack.com/archives/C08077A6JDB/p1772491650055389?thread_ts=1772491650.055389&cid=C08077A6JDB

Co-authored-by: v0 <v0[bot]@users.noreply.github.com>

---------

Co-authored-by: v0 <v0[bot]@users.noreply.github.com>
2026-03-03 07:59:58 -08:00