Commit Graph

44 Commits

Author SHA1 Message Date
Ben Sabic 99c598505f docs: refresh agent docs, README badges, and Chat SDK skill (#646)
- Replace npm version/download badges with Agent Stack and MIT badges on
the root README and all published package READMEs
- Streamline root `AGENTS.md`: fix title, add an accurate monorepo map,
trim duplicated CONTRIBUTING/Ultracite/env-var content, and link to
package-level `AGENTS.md` files
- Slim the Chat SDK agent skill (`skills/chat/SKILL.md` and published
copies) to defer to bundled docs, chat-sdk.dev, Vercel KB, and
`llms.txt` instead of inlining CLI flags, quick-start code, and API
tables
- Polish root README copy (install examples, adapter/build links, Vercel
Plugin URL, Vercel KB link, “Made by Vercel” badge)
- Minor `CONTRIBUTING.md` fixes: simplify DCO wording, correct
preview-branch proxy file references (`proxy.ts` vs middleware)

---------

Signed-off-by: Ben Sabic <bensabic@users.noreply.github.com>
Co-authored-by: Ben Sabic <bensabic@users.noreply.github.com>
2026-06-27 14:06:13 +10:00
Ben Sabic 8f3af76565 feat: add create-chat-sdk CLI (#603)
Adds `create-chat-sdk`, a CLI that scaffolds a Next.js Chat SDK bot
project:

```bash
npm create chat-sdk@latest my-bot

# non-interactive
npm create chat-sdk@latest -- my-bot --adapter slack redis -y
```

The user picks platform and state adapters interactively or via
`--adapter`, and the CLI generates a webhook-only project with
`src/lib/bot.ts`, `.env.example`, `next.config.ts`, `package.json`, and
a README, then optionally runs `git init` and installs dependencies.
There are no pages or client UI in the template.

Adapter choices come straight from the `chat/adapters` catalog, so the
CLI has no adapter registry of its own. When a coding agent such as
Cursor or Claude Code runs the CLI, it uses non-interactive defaults and
requires an explicit platform adapter. `--interactive` forces prompts.

## also in this pr

- `google-chat` is renamed to `gchat` everywhere, including docs pages,
the OG image, and adapter catalog. Old URLs redirect permanently,
including language-prefixed and `/og` paths
- a new docs page is available at `chat-sdk.dev/docs/create-chat-sdk`,
and the CLI is promoted on the homepage, package READMEs, and agent
skill
- `create-chat-sdk` releases independently with a minor changeset for
its initial `0.1.0` release

---------

Co-authored-by: Ben Sabic <bensabic@users.noreply.github.com>
Co-authored-by: dancer <josh@afterima.ge>
2026-06-16 08:48:38 +01:00
Ben Sabic 9921dcd1c4 docs(seo): improve npm metadata, README discoverability, and structured data (#587)
Improves Chat SDK discoverability across npm, READMEs, and the docs site
for search engines and AI coding agents.

- **npm metadata**: point every published package `homepage` at
chat-sdk.dev deep links; expand `chat` keywords/description; fix
`repository.directory` (`packages/chat-sdk` → `packages/chat`); align
state adapter keywords
- **READMEs**: add npm callouts, Documentation/Guides links, and AI
Coding Agents sections (skill install, optional Vercel Plugin,
`llms.txt` / `llms-full.txt`) across all published packages and the repo
root
- **docs JSON-LD**: `HowTo` / `TechArticle` on getting-started,
streaming, and cards; `CollectionPage` + official-only `ItemList` on
`/adapters` (with split human vs JSON-LD descriptions)
- **UTMs**: add `chat-sdk_site` / `chat-sdk_repo` tracking params to
Resources links in selected MDX pages and adapter READMEs (discord,
github, slack, liveblocks, getting-started, ai index)
- **contract tests**: integration-tests guardrails for npm metadata and
README discoverability so future package additions don't drift

---------

Co-authored-by: Ben Sabic <bensabic@users.noreply.github.com>
2026-06-05 14:00:18 +10:00
luren 5461ea982b feat(telegram): add native DM draft streaming with segmented stream results (#340)
## Summary

Add native Telegram DM streaming via `sendMessageDraft` while preserving
Chat SDK's existing post+edit fallback for non-DM threads.

This PR:
- adds native private-chat draft streaming to the Telegram adapter
- splits long streamed markdown into Telegram-safe persisted segments
- retries without `parse_mode` when Telegram rejects markdown entity
parsing
- exposes segmented native stream results in the chat core
- updates docs and feature matrices to reflect Telegram DM draft
streaming

---------

Co-authored-by: dancer <josh@afterima.ge>
2026-05-28 15:17:10 -07:00
josh b75eedbb5f feat(chat): add queue-debounce concurrency strategy (#495)
## summary

adds an opt-in `burst` concurrency strategy for #414

when a thread is idle, the first message waits for `debounceMs`,
messages that arrive during that window are queued, and the handler runs
once with the latest message plus earlier burst messages in
`context.skipped`

after the handler finishes, messages that arrived while it was running
are drained like `queue`, so the latest queued message is processed with
earlier queued messages in `context.skipped`

keeps existing `drop`, `queue`, `debounce`, and `concurrent` behavior
unchanged

updates docs to cover `burst`, explain when to choose it over
`debounce`, and document the related `MessageContext` behavior
2026-05-14 19:18:40 -07:00
Ben Sabic 90cd8f181a chore: refresh release workflow, community health files, and agent docs (#431)
* ci(release): pin changesets/action and enable npm provenance

Pin changesets/action to the v1.7.0 commit SHA, switch to GitHub-API
commit mode (signed commits via the API), set the version PR commit
and title to a conventional "chore(release): version packages", and
enable npm provenance attestations on publish via NPM_CONFIG_PROVENANCE.

* chore: add CODEOWNERS

Default ownership goes to @vercel/chat-sdk; release-plumbing paths
(release workflow, changeset config, CODEOWNERS itself) stay locked
to @cramforce since the publish workflow is bound to npm Trusted
Publisher by filename.

* docs: add SUPPORT.md and tidy issue contact links

Add a SUPPORT.md pointing users to docs, the issue chooser, and the
security advisory flow. Also update .github/config.yml: point the
Documentation contact link at chat-sdk.dev/docs (was a github.com
README anchor) and remove the GitHub Discussions entry, which 404s
because Discussions isn't enabled on the repo.

* chore: add docs issue and adapter request templates

Two new issue templates so reports come in pre-shaped:
- Documentation Issue — page/section, type (typo, outdated, missing,
  broken link, etc.), description, suggested fix.
- Adapter Request — platform name, adapter type (platform/state), API
  docs link, use case, existing community work, willingness to help
  maintain.

* docs(contributing): point contributors at issue templates and SUPPORT.md

Add a "Reporting issues" section at the top of CONTRIBUTING.md that
links to the issue chooser (now covering bugs, features, docs issues,
and adapter requests) and to SUPPORT.md for general questions, with
the SECURITY.md private-disclosure path called out separately.

* chore: add pre-merge checklist to PR template

Adds four self-attestation boxes contributors can tick before
requesting review, surfacing requirements that already live in
CONTRIBUTING.md so they're not forgotten:

- Signed and verified commits (CONTRIBUTING explicitly bounces PRs
  with unsigned commits).
- `pnpm validate` passes (lint, typecheck, tests, build in one go).
- Changeset added when a package's behavior changes.
- Docs updated for user-facing changes.

The "or N/A" wording on the last two avoids forcing a yes for
internal-only or docs-only PRs.

* chore: add Telegram and WhatsApp to bug report platform dropdown

The bug report platform dropdown was missing Telegram and WhatsApp,
which both have official adapters (@chat-adapter/telegram and
@chat-adapter/whatsapp). Reporters had to fall back to "Other" for
bugs in those adapters, losing the platform signal.

* docs(readme): fix CONTRIBUTING link path and add Support section

The Contributing section linked to ./CONTRIBUTING.md, but the file
actually lives at .github/CONTRIBUTING.md, so the link 404'd on
github.com. Repoint it.

Also add a Support section linking SUPPORT.md (general help) and
SECURITY.md (private vulnerability reporting) so those community
health files are reachable from the repo entry point instead of
only via GitHub's auto-surfacing.

* docs(contributing): add adapter authoring, commit conventions, and docs sections

Three additions to CONTRIBUTING.md to round out the file alongside
the recently added issue templates and PR checklist:

- "Building your own adapter" — points contributors who hit the
  Adapter Request template at the existing community-adapter guide
  on chat-sdk.dev rather than leaving them to discover it.
- "Commit messages" — codifies the Conventional Commits style the
  repo already uses; the release workflow now relies on the
  "chore(release): version packages" convention for its auto-PR,
  so consistency in new commits keeps changelogs predictable.
- "Updating documentation" — names the apps/docs/content/docs/
  source path, links the live site, and shows the local preview
  command so the PR-template "Documentation updated" checkbox is
  actionable.

* docs: trim agent docs, rename CLAUDE.md to AGENTS.md, add CLAUDE.md pointer

Move the agent guidance to AGENTS.md (the cross-tool convention) and
leave CLAUDE.md as a one-line "@AGENTS.md" pointer so Claude Code
keeps auto-loading the same content.

While renaming, trim and update the file:

- "packages/chat-sdk" was wrong — directory is "packages/chat", npm
  name is "chat".
- Updated the package list to include adapter-{discord,telegram,
  github,linear,zoom,shared}, state-{ioredis,pg}, integration-tests,
  and the apps/docs and examples/nextjs-chat trees.
- Replaced the verbose recording-and-replay jq walkthrough with a
  one-line pointer to the integration-tests README.
- Dropped the duplicated Changesets walkthrough — full guidance now
  lives in CONTRIBUTING.md.
- Condensed ~120 lines of generic Ultracite/Biome rules to a short
  list of non-obvious gotchas (Biome enforces the rest automatically).
- Added Conventional Commits (load-bearing for the release workflow's
  auto-PR), the apps/docs/content/docs/ docs path with the "pnpm
  --filter docs dev" preview command, a pointer to the community
  health files, and POSTGRES_URL/DATABASE_URL for the new state-pg
  adapter.

Net: 344 → ~125 lines.

* docs(nav): rename "Source" link to "GitHub"

---------

Co-authored-by: Ben Sabic <bensabic@users.noreply.github.com>
2026-04-27 05:22:35 -07:00
Ben Sabic e8c4b1a6c4 docs: update adapter docs (#412)
* docs: update adapter docs

* docs: update adapter docs

* docs: update adapter docs

---------

Co-authored-by: Ben Sabic <bensabic@users.noreply.github.com>
2026-04-22 13:28:20 +10: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 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
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
Tobias Lins 0c688a0111 Add support for telegram bot (#90)
* Add support for telegram bot

* Add support for action buttons in telegram

* Use markdown parse mode

* Add more tests

* Fix linting issues

* Fixes

* Fixes

* Don't reverse order messages for AI and always answer for telegram

* Add telegram integration test

* Update telegram.json
2026-02-26 14:10:41 -08:00
Malte Ubl 9affdf3a55 Make the logger optional and infer most adapter config (#88)
* Make the logger optional and infer most adapter config

* Fix init
2026-02-23 17:48:41 -08:00
Hayden Bleasel a79ff81bcc Callout skill 2026-02-20 20:16:03 -08:00
Hayden Bleasel 1348532068 Open Source Beta Prep (#73)
* Update docs - Slack Assistants API, App Home tab, Stream stop blocks

* Update README.md

* Update package readmes, fix readme integration test

* Add npm badges to all package READMEs

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

* Add test coverage to all packages

* Create CODE_OF_CONDUCT.md

* Create pull_request_template.md

* Create issue templates

* Create config.yml

* Add unit tests for errors, singleton, logger, message, modals, gchat utils, and teams markdown

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

* Add a vitest:workspace command

* Misc URL fixes

* Update CONTRIBUTING.md

* Misc fixes, upgrade workflow/serde

* Replace PII in integration test data

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 13:25:09 -08:00
Vishal Yathish 8c50252d00 [chat] add support for slash commands (#50)
* [chat] add support for slash commands

* add comprehensive tests

* add documentation

* adding changeset
2026-02-18 08:32:44 -08:00
Vishal Yathish 417374b844 [chat] add inline select components (#45)
* [chat] add inline select components

* changeset

* adding radio buttons

* adding unit tests

* add documentation for the new components

* add replay tests
2026-02-15 17:18:53 -08:00
Vishal Yathish 660a84ee09 cleanup 2026-01-22 15:30:44 -08:00
Vishal Yathish e84cbf4187 [chat] add relatedThread and relatedMessage props to modal events 2026-01-22 13:19:09 -08:00
Fernando Rojo 68e3f74bfa changeset 2026-01-21 14:56:56 -05:00
Fernando Rojo b03cbd7130 add <LinkButton> 2026-01-21 14:54:48 -05:00
Fernando Rojo 62014514fe fix: tests in readme 2026-01-21 12:44:40 -05:00
Fernando Rojo dbc65dfd39 Merge branch 'main' into ephemeral 2026-01-21 11:34:28 -05:00
Fernando Rojo 4f2ff75070 ephemeral readme 2026-01-21 11:14:39 -05:00
Vishal Yathish 85609315d7 [chat] add private metadata/threadId to onModalClose events 2026-01-20 16:57:02 -08:00
Fernando Rojo 8d4878ec7b ephemeral messages 2026-01-20 19:50:20 -05:00
Fernando Rojo b76fdc45ab docs 2026-01-20 14:48:10 -05:00
Fernando Rojo 15107844a7 docs 2026-01-20 14:47:55 -05:00
Fernando Rojo 6934ed9999 docs 2026-01-20 14:47:44 -05:00
Malte Ubl 7403d64618 readme 2026-01-05 12:50:44 -08:00
Malte Ubl 9d71d4ce89 readme 2026-01-05 12:45:48 -08:00
Malte Ubl 2286214024 README updates and replay test for role mention 2026-01-04 18:40:28 -08:00
Malte Ubl 7e8826f9c2 Required-logger 2026-01-04 09:12:45 -08:00
Malte Ubl 0d8bfd5d15 Maybe fix Google Cards 2026-01-02 15:15:38 -08:00
Malte Ubl d2ffcc2cbe The great rename
We've acquired `chat` on npm. This plan covers renaming all packages and setting up automated publishing.

| Current Name | New Name | Version |
|--------------|----------|---------|
| `chat-sdk` | `chat` | 4.0.0 |
| `@chat-sdk/slack` | `@chat-adapter/slack` | 4.0.0 |
| `@chat-sdk/gchat` | `@chat-adapter/gchat` | 4.0.0 |
| `@chat-sdk/teams` | `@chat-adapter/teams` | 4.0.0 |
| `@chat-sdk/state-memory` | `@chat-adapter/state-memory` | 4.0.0 |
| `@chat-sdk/state-redis` | `@chat-adapter/state-redis` | 4.0.0 |
| `@chat-sdk/state-ioredis` | `@chat-adapter/state-ioredis` | 4.0.0 |

1. **Main package** (`packages/chat-sdk/package.json`):
   - Change `"name": "chat-sdk"` → `"name": "chat"`
   - Change `"version": "0.1.0"` → `"version": "4.0.0"`

2. **Adapter packages**:
   - `packages/adapter-slack/package.json`: `@chat-sdk/slack` → `@chat-adapter/slack`
   - `packages/adapter-gchat/package.json`: `@chat-sdk/gchat` → `@chat-adapter/gchat`
   - `packages/adapter-teams/package.json`: `@chat-sdk/teams` → `@chat-adapter/teams`
   - Update all versions to `4.0.0`
   - Update dependency on `chat-sdk` → `chat`

3. **State packages**:
   - `packages/state-memory/package.json`: `@chat-sdk/state-memory` → `@chat-adapter/state-memory`
   - `packages/state-redis/package.json`: `@chat-sdk/state-redis` → `@chat-adapter/state-redis`
   - `packages/state-ioredis/package.json`: `@chat-sdk/state-ioredis` → `@chat-adapter/state-ioredis`
   - Update all versions to `4.0.0`
   - Update dependency on `chat-sdk` → `chat`

Update `peerDependencies` and `dependencies` in each package:

```json
// Before
"peerDependencies": {
  "chat-sdk": "workspace:*"
}

// After
"peerDependencies": {
  "chat": "workspace:*"
}
```

Search and replace across the codebase:

| Find | Replace |
|------|---------|
| `from "chat-sdk"` | `from "chat"` |
| `from 'chat-sdk'` | `from 'chat'` |
| `import("chat-sdk")` | `import("chat")` |
| `from "@chat-sdk/slack"` | `from "@chat-adapter/slack"` |
| `from "@chat-sdk/gchat"` | `from "@chat-adapter/gchat"` |
| `from "@chat-sdk/teams"` | `from "@chat-adapter/teams"` |
| `from "@chat-sdk/state-memory"` | `from "@chat-adapter/state-memory"` |
| `from "@chat-sdk/state-redis"` | `from "@chat-adapter/state-redis"` |
| `from "@chat-sdk/state-ioredis"` | `from "@chat-adapter/state-ioredis"` |

Update any references to old package names in:
- `pnpm-workspace.yaml`
- `turbo.json` (task filters)
- Root `package.json` scripts

1. **README.md files** in each package
2. **Examples** (`examples/nextjs-chat/`)
3. **AGENTS.md** and other docs
4. **JSDoc comments** referencing package names

1. **Install changesets**:
   ```bash
   pnpm add -D @changesets/cli
   pnpm changeset init
   ```

2. **Configure `.changeset/config.json`**:
   ```json
   {
     "$schema": "https://unpkg.com/@changesets/config@3.0.0/schema.json",
     "changelog": "@changesets/cli/changelog",
     "commit": false,
     "fixed": [],
     "linked": [
       ["chat", "@chat-adapter/*"]
     ],
     "access": "public",
     "baseBranch": "main",
     "updateInternalDependencies": "patch",
     "ignore": ["example-nextjs-chat"]
   }
   ```

3. **Add GitHub Action** (`.github/workflows/release.yml`):
   ```yaml
   name: Release

   on:
     push:
       branches:
         - main

   concurrency: ${{ github.workflow }}-${{ github.ref }}

   jobs:
     release:
       name: Release
       runs-on: ubuntu-latest
       steps:
         - uses: actions/checkout@v4
         - uses: pnpm/action-setup@v2
           with:
             version: 9
         - uses: actions/setup-node@v4
           with:
             node-version: 20
             cache: 'pnpm'

         - run: pnpm install
         - run: pnpm build
         - run: pnpm test

         - name: Create Release Pull Request or Publish
           uses: changesets/action@v1
           with:
             publish: pnpm changeset publish
           env:
             GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
             NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
   ```

4. **Add publish config to each package.json**:
   ```json
   "publishConfig": {
     "access": "public"
   }
   ```

1. Run full build: `pnpm build`
2. Run typecheck: `pnpm typecheck`
3. Run lint: `pnpm lint`
4. Run tests: `pnpm test`
5. Test local linking in example app

| File | Changes |
|------|---------|
| `packages/chat-sdk/package.json` | Rename to `chat`, version 4.0.0 |
| `packages/adapter-slack/package.json` | Rename to `@chat-adapter/slack`, update deps |
| `packages/adapter-gchat/package.json` | Rename to `@chat-adapter/gchat`, update deps |
| `packages/adapter-teams/package.json` | Rename to `@chat-adapter/teams`, update deps |
| `packages/state-memory/package.json` | Rename to `@chat-adapter/state-memory`, update deps |
| `packages/state-redis/package.json` | Rename to `@chat-adapter/state-redis`, update deps |
| `packages/state-ioredis/package.json` | Rename to `@chat-adapter/state-ioredis`, update deps |
| `examples/nextjs-chat/package.json` | Update all dependencies |
| `packages/integration-tests/package.json` | Update all dependencies |
| `turbo.json` | Update package references |
| All `*.ts` files | Update import statements |
| All `README.md` files | Update package names in docs |
| `.changeset/config.json` | Create new |
| `.github/workflows/release.yml` | Create new |

1. Update all `package.json` files (names, versions, dependencies)
2. Run `pnpm install` to update lockfile
3. Update all import statements in source files
4. Update all import statements in test files
5. Update documentation
6. Set up changesets
7. Run full validation
8. Create initial changeset for 4.0.0 release
9. Commit and push

If issues arise:
1. Git revert the rename commit
2. Run `pnpm install` to restore lockfile
3. Previous npm versions remain available
2026-01-02 13:56:55 -08:00
Malte Ubl 39270b8b5d DM 2026-01-01 20:28:14 -08:00
Malte Ubl c75b9bc17d features 2026-01-01 17:25:27 -08:00
Malte Ubl 961013c171 README 2026-01-01 13:14:37 -08:00
Malte Ubl ce4baf2183 Type-safe emoji 2026-01-01 11:46:44 -08:00
Malte Ubl 93a82ffc08 IORedis and better validate 2026-01-01 09:11:52 -08:00
Malte Ubl 7236e88374 Ensure README is always in good shape 2026-01-01 08:33:57 -08:00
Malte Ubl e3c376f208 SETUP 2025-12-31 15:21:42 -08:00
Malte Ubl 42c705b245 rename 2025-12-22 18:21:52 -08:00
Malte Ubl bf18adc163 OIDC 2025-12-22 12:13:14 -08:00
Malte Ubl 1f401aacd0 initial cook 2025-12-21 20:48:14 -08:00