Commit Graph

35 Commits

Author SHA1 Message Date
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