Files
loki/bridge
dependabot[bot] 6e7d534ced chore(deps): bump the minor-and-patch group across 1 directory with 19 updates (#1084)
Bumps the minor-and-patch group with 19 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [@bitbaum/ai-kit](https://github.com/bitbaum/ai-kit) | `1.18.0` | `1.20.1` |
| [drizzle-orm](https://github.com/drizzle-team/drizzle-orm) | `0.45.2` | `0.45.3` |
| [lucide-react](https://github.com/lucide-icons/lucide/tree/HEAD/packages/lucide-react) | `1.41.0` | `1.52.0` |
| [react](https://github.com/react/react/tree/HEAD/packages/react) | `19.2.8` | `19.3.0` |
| [@types/react](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react) | `19.2.18` | `19.3.0` |
| [react-dom](https://github.com/react/react/tree/HEAD/packages/react-dom) | `19.2.8` | `19.3.0` |
| [@types/react-dom](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react-dom) | `19.2.7` | `19.3.0` |
| [shadcn](https://github.com/shadcn-ui/ui/tree/HEAD/packages/shadcn) | `4.21.0` | `4.21.2` |
| [shiki](https://github.com/shikijs/shiki/tree/HEAD/packages/shiki) | `4.4.3` | `4.5.0` |
| [tailwind-merge](https://github.com/dcastil/tailwind-merge/tree/HEAD/packages/tailwind-merge) | `3.6.0` | `3.7.0` |
| [ws](https://github.com/websockets/ws) | `8.21.3` | `8.22.0` |
| [@types/ws](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/ws) | `8.18.1` | `8.18.2` |
| [zod](https://github.com/colinhacks/zod) | `4.5.4` | `4.6.5` |
| [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) | `26.4.1` | `26.6.4` |
| [@types/react](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react) | `19.2.18` | `19.3.0` |
| [@types/react-dom](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react-dom) | `19.2.7` | `19.3.0` |
| [drizzle-kit](https://github.com/drizzle-team/drizzle-orm) | `0.31.10` | `0.31.11` |
| [eslint](https://github.com/eslint/eslint) | `10.10.0` | `10.12.0` |
| [prettier](https://github.com/prettier/prettier) | `3.9.6` | `3.9.9` |
| [tsx](https://github.com/privatenumber/tsx) | `4.23.13` | `4.23.15` |
| [pg](https://github.com/brianc/node-postgres/tree/HEAD/packages/pg) | `8.23.0` | `8.23.1` |



Updates `@bitbaum/ai-kit` from 1.18.0 to 1.20.1
- [Commits](https://github.com/bitbaum/ai-kit/compare/v1.18.0...v1.20.1)

Updates `drizzle-orm` from 0.45.2 to 0.45.3
- [Release notes](https://github.com/drizzle-team/drizzle-orm/releases)
- [Commits](https://github.com/drizzle-team/drizzle-orm/compare/0.45.2...0.45.3)

Updates `lucide-react` from 1.41.0 to 1.52.0
- [Release notes](https://github.com/lucide-icons/lucide/releases)
- [Commits](https://github.com/lucide-icons/lucide/commits/1.52.0/packages/lucide-react)

Updates `react` from 19.2.8 to 19.3.0
- [Release notes](https://github.com/react/react/releases)
- [Changelog](https://github.com/react/react/blob/main/CHANGELOG.md)
- [Commits](https://github.com/react/react/commits/v19.3.0/packages/react)

Updates `@types/react` from 19.2.18 to 19.3.0
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/react)

Updates `react-dom` from 19.2.8 to 19.3.0
- [Release notes](https://github.com/react/react/releases)
- [Changelog](https://github.com/react/react/blob/main/CHANGELOG.md)
- [Commits](https://github.com/react/react/commits/v19.3.0/packages/react-dom)

Updates `@types/react-dom` from 19.2.7 to 19.3.0
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/react-dom)

Updates `shadcn` from 4.21.0 to 4.21.2
- [Release notes](https://github.com/shadcn-ui/ui/releases)
- [Changelog](https://github.com/shadcn-ui/ui/blob/main/packages/shadcn/CHANGELOG.md)
- [Commits](https://github.com/shadcn-ui/ui/commits/shadcn@4.21.2/packages/shadcn)

Updates `shiki` from 4.4.3 to 4.5.0
- [Release notes](https://github.com/shikijs/shiki/releases)
- [Commits](https://github.com/shikijs/shiki/commits/v4.5.0/packages/shiki)

Updates `tailwind-merge` from 3.6.0 to 3.7.0
- [Release notes](https://github.com/dcastil/tailwind-merge/releases)
- [Commits](https://github.com/dcastil/tailwind-merge/commits/tailwind-merge@3.7.0/packages/tailwind-merge)

Updates `ws` from 8.21.3 to 8.22.0
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](https://github.com/websockets/ws/compare/8.21.3...8.22.0)

Updates `@types/ws` from 8.18.1 to 8.18.2
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/ws)

Updates `zod` from 4.5.4 to 4.6.5
- [Release notes](https://github.com/colinhacks/zod/releases)
- [Commits](https://github.com/colinhacks/zod/compare/v4.5.4...v4.6.5)

Updates `@types/node` from 26.4.1 to 26.6.4
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Updates `@types/react` from 19.2.18 to 19.3.0
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/react)

Updates `@types/react-dom` from 19.2.7 to 19.3.0
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/react-dom)

Updates `drizzle-kit` from 0.31.10 to 0.31.11
- [Release notes](https://github.com/drizzle-team/drizzle-orm/releases)
- [Commits](https://github.com/drizzle-team/drizzle-orm/compare/drizzle-kit@0.31.10...drizzle-kit@0.31.11)

Updates `eslint` from 10.10.0 to 10.12.0
- [Release notes](https://github.com/eslint/eslint/releases)
- [Commits](https://github.com/eslint/eslint/compare/v10.10.0...v10.12.0)

Updates `prettier` from 3.9.6 to 3.9.9
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/3.9.6...3.9.9)

Updates `tsx` from 4.23.13 to 4.23.15
- [Release notes](https://github.com/privatenumber/tsx/releases)
- [Changelog](https://github.com/privatenumber/tsx/blob/master/release.config.cjs)
- [Commits](https://github.com/privatenumber/tsx/compare/v4.23.13...v4.23.15)

Updates `pg` from 8.23.0 to 8.23.1
- [Changelog](https://github.com/brianc/node-postgres/blob/master/CHANGELOG.md)
- [Commits](https://github.com/brianc/node-postgres/commits/pg@8.23.1/packages/pg)

---
updated-dependencies:
- dependency-name: "@bitbaum/ai-kit"
  dependency-version: 1.20.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: "@types/node"
  dependency-version: 26.6.4
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: "@types/react"
  dependency-version: 19.3.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: "@types/react"
  dependency-version: 19.3.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: "@types/react-dom"
  dependency-version: 19.3.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: "@types/react-dom"
  dependency-version: 19.3.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: "@types/ws"
  dependency-version: 8.18.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: drizzle-kit
  dependency-version: 0.31.11
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: drizzle-orm
  dependency-version: 0.45.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: eslint
  dependency-version: 10.12.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: lucide-react
  dependency-version: 1.52.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: pg
  dependency-version: 8.23.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: prettier
  dependency-version: 3.9.9
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: react
  dependency-version: 19.3.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: react-dom
  dependency-version: 19.3.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: shadcn
  dependency-version: 4.21.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: shiki
  dependency-version: 4.5.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: tailwind-merge
  dependency-version: 3.7.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: tsx
  dependency-version: 4.23.15
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: minor-and-patch
- dependency-name: ws
  dependency-version: 8.22.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: zod
  dependency-version: 4.6.5
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-10-08 09:03:25 -07:00
..

Loki event bridge

A ~300-line Node service that takes Postgres NOTIFY events on the fc:state channel and fans them out to subscribed browsers, desktop apps, and phones over Server-Sent Events. The piece that lets v0.6 replace polling with push.

What runs where

                                         ┌───────────────────┐
                                         │  this service     │
   Browser ─────── /sse?token=ck_* ──────┤  (bridge/)        │
                                         │                   │
   Fleet Runner ── /sse?token=ck_* ──────┤   one HTTP+SSE    │
                                         │   server, one     │
                                         │   pg LISTEN       │
                                         │                   │
                                         └────────┬──────────┘
                                                  │ LISTEN "fc:state"
                                                  ↓
                                         ┌───────────────────┐
                                         │   Postgres        │
                                         │   triggers in     │
                                         │   drizzle/0022    │
                                         └───────────────────┘
                                                  ↑
                                                  │ INSERT/UPDATE/DELETE
                                         ┌────────┴──────────┐
                                         │   Hosted API      │
                                         │   /api/control,   │
                                         │   /api/control/   │
                                         │   runtime-state,  │
                                         │   etc.            │
                                         └───────────────────┘

Read the architectural narrative in /thoughts/from-polling-to-listening-loki-v0-6 for the why.

Run locally

cd bridge
cp .env.example .env
# edit .env — point DATABASE_URL at the same db that has the v0.6 triggers
npm install
npm run dev      # tsx — fast iteration
# or
npm run build && npm start

Health: curl http://localhost:4001/healthz → {ok:true, users, connections, eventLogSize}

SSE: curl -N "http://localhost:4001/sse?token=ck_..." (replace with a real ck_* token from your agent_tokens table). Watch as event: change frames arrive whenever a row owned by that user changes.

Auth model

Tokens are looked up in the same agent_tokens table the cloud API uses. Plaintext lookup (matches the existing scheme; see src/db/queries/agent-tokens.ts). The token is passed as ?token=ck_... in the SSE URL because EventSource does not let JavaScript set custom request headers. Mitigated by HTTPS-only deploy + scrubbing query strings from access logs.

Last-Event-ID replay

Clients that disconnect briefly (sleep, wifi drop, deploy) reconnect with Last-Event-ID: <last_id> in their headers. The bridge replays any buffered events with a higher id, filtered to the user's scope. Buffer size is 1000 events — anything older requires a full re-fetch from the cloud snapshot endpoint.

Deploy (Oracle / Hetzner)

The bridge lives on the same box as Postgres. Both processes plus a small backup cron fit comfortably on Oracle Always Free or a Hetzner CX22. See scripts/db/SETUP_ORACLE_FREE.md and scripts/db/BOTH_PRODUCTS_ONE_HOST.md for the host setup. Once Postgres is up:

# On the box
git clone git@github.com:bitbaum/loki.git /opt/loki
cd /opt/loki/bridge
npm ci
npm run build

# /etc/systemd/system/loki-bridge.service
sudo tee /etc/systemd/system/loki-bridge.service <<'UNIT'
[Unit]
Description=Loki event bridge (Postgres LISTEN → SSE)
After=postgresql.service network-online.target
Wants=network-online.target

[Service]
Type=simple
User=loki
WorkingDirectory=/opt/loki/bridge
EnvironmentFile=/opt/loki/bridge/.env
ExecStart=/usr/bin/node /opt/loki/bridge/dist/server.js
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target
UNIT

sudo systemctl daemon-reload
sudo systemctl enable --now loki-bridge
sudo journalctl -u loki-bridge -f

Then reverse-proxy 443 → 4001 via Caddy with a TLS cert (this is how the bitbaum box runs it today, as loki-bridge.service behind bridge.orangecat.ch). Point the web app's LOKI_BRIDGE_URL env at https://your-host/sse and the web client will subscribe instead of polling.

Connection limits

Default Linux file descriptor limit (1024) caps connections per process. Bump in the systemd unit before going to scale:

[Service]
LimitNOFILE=65536

One process easily handles ~50,000 concurrent SSE connections on the Oracle Free shape (4 OCPU / 24 GB). Past that, run multiple bridge processes behind a load balancer; they share state via the Postgres LISTEN channel automatically (NOTIFY fans out to every LISTEN'er).