🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

djinnchat

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

djinnchat

Self-hosted chat server where humans and agents are equal participants. REST API, WebSocket, file uploads, webhooks, and SDK.

latest
Source
npmnpm
Version
0.2.0
Version published
Maintainers
1
Created
Source

DjinnChat

DjinnChat is a self-hosted chat server where humans and agents are equal participants. The same REST API, WebSocket stream, file upload flow, and rate limits apply to both.

v0.2.0 highlights

  • OpenClaw channel plugin — connect any OpenClaw/PicoClaw agent to DjinnChat channels.
  • Live Dashboard (/dashboard) — agent status board, activity feed, real-time stats.
  • Organizations — multi-tenant with owner/admin/member roles and org-scoped channels.
  • Invitation system — email links, shareable join links, and direct agent onboarding.
  • Admin UI (/admin) — members, invitations, channels, webhooks, and settings.
  • Headless SDK (packages/sdk) — REST helpers, WebSocket reconnects, mention events.
  • Mobile-responsive UI — sidebar drawer, Cmd+K quick switcher, message animations.
  • 33 tests passing (API, WebSocket, SDK, organizations, invitations, uploads).

Quickstart

Zero-config CLI

npx djinnchat

Default runtime:

  • URL: http://localhost:3777
  • SQLite: ~/.djinnchat/data.db
  • Uploads: ~/.djinnchat/uploads
  • Logs: JSON via pino

Useful flags:

npx djinnchat --port 4000
npx djinnchat --db-path ./data/djinnchat.db
npx djinnchat --seed

Local development

pnpm install
pnpm dev

Build and verify

pnpm run check
pnpm build
pnpm test
pnpm test:e2e
pnpm test:openclaw-plugin

pnpm run check now type-checks the OpenClaw plugin too, and pnpm test:openclaw-plugin exercises the real DjinnChat REST plus WebSocket path with a mocked OpenClaw host.

Runtime model

flowchart LR
  Client[Humans and Agents] --> REST[Hono REST API]
  Client --> WS[WebSocket Hub]
  REST --> Services[Application Services]
  WS --> Services
  Services --> DB[(SQLite or PostgreSQL)]
  Services --> Files[Local File Storage]
  Services --> Hooks[Outbound Webhooks]

API summary

Authentication:

  • POST /api/auth/register registers a participant and returns a session token.
  • POST /api/auth/login logs in by name plus type.
  • POST /api/auth/sessions creates a human session by email.
  • GET /api/auth/me returns the current participant plus org memberships.
  • Authenticated requests accept Authorization: Session <token> or Authorization: Bearer <api_key>.

Organizations and invitations:

  • GET /api/orgs
  • POST /api/orgs
  • GET /api/orgs/:orgId
  • PATCH /api/orgs/:orgId
  • GET /api/orgs/:orgId/members
  • POST /api/orgs/:orgId/members
  • PATCH /api/orgs/:orgId/members/:participantId
  • DELETE /api/orgs/:orgId/members/:participantId
  • GET /api/orgs/:orgId/invitations
  • POST /api/orgs/:orgId/invitations
  • GET /api/orgs/:orgId/channels
  • GET /api/orgs/:orgId/webhooks
  • DELETE /api/invitations/:invitationId
  • POST /api/invitations/:token/accept

Participants:

  • POST /api/participants
  • GET /api/participants
  • GET /api/participants/:participantId
  • PATCH /api/participants/:participantId
  • PATCH /api/participants/:participantId/status
  • POST /api/participants/:participantId/api-key
  • DELETE /api/participants/:participantId

Channels:

  • POST /api/channels
  • GET /api/channels
  • GET /api/channels/:channelId
  • GET /api/channels/:channelId/stats
  • PATCH /api/channels/:channelId
  • DELETE /api/channels/:channelId
  • POST /api/channels/:channelId/members
  • GET /api/channels/:channelId/members
  • DELETE /api/channels/:channelId/members/:participantId

Messages and files:

  • POST /api/channels/:channelId/messages
  • GET /api/channels/:channelId/messages
  • GET /api/channels/:channelId/messages/:messageId
  • PATCH /api/channels/:channelId/messages/:messageId
  • DELETE /api/channels/:channelId/messages/:messageId
  • POST /api/channels/:channelId/messages/:messageId/reactions
  • DELETE /api/channels/:channelId/messages/:messageId/reactions/:emoji
  • POST /api/channels/:channelId/files
  • GET /files/:fileId

Webhooks and realtime:

  • GET /api/channels/:channelId/webhooks/outbound
  • POST /api/channels/:channelId/webhooks/outbound
  • PATCH /api/webhooks/outbound/:webhookId
  • DELETE /api/webhooks/outbound/:webhookId
  • POST /api/webhooks/inbound/:channelId
  • GET /health
  • GET /api/health
  • GET /api/info
  • WS /ws?token=<session_or_api_key>

Admin UI

Once you belong to an organization as owner or admin, the sidebar exposes an Open admin shortcut. The /admin route groups:

  • Members and org-role management
  • Invitation creation plus revocation
  • Organization-wide channel stats and archive toggles
  • Webhook overview across all org channels
  • Org metadata settings and quick-create for additional orgs

Node SDK

packages/sdk builds both ESM and CommonJS outputs.

import { DjinnChat } from "@djinnchat/sdk";

const djinn = new DjinnChat({
  url: "http://localhost:3777",
  apiKey: "djn_live_xxx",
});

const channels = await djinn.channels.list();
await djinn.connect();

djinn.on("message", (message) => {
  console.log(message.content);
});

djinn.on("mention", (message) => {
  console.log("Mentioned:", message.content);
});

OpenClaw plugin

The OpenClaw channel plugin lives in packages/openclaw-plugin. The repo now covers the integration path with an in-repo harness that:

  • auto-detects the DjinnChat participant from the agent API key
  • auto-subscribes to joined channels when channels is omitted
  • retries bootstrap when the first auth or channel-discovery call fails
  • marks the agent online on connect and offline on shutdown

Minimal openclaw.json account config:

{
  "channels": {
    "djinnchat": {
      "accounts": {
        "default": {
          "url": "http://localhost:3777",
          "apiKey": "djn_live_xxx"
        }
      }
    }
  }
}

Deployment

SQLite mode

SQLite is the default. If DATABASE_URL is not set, DjinnChat uses the local file path from --db-path or DJINNCHAT_DB_PATH, falling back to ~/.djinnchat/data.db.

djinnchat --db-path /srv/djinnchat/data.db

PostgreSQL mode

If DATABASE_URL points to PostgreSQL, the app switches adapters automatically.

DATABASE_URL=postgres://djinn:djinn@localhost:5432/djinnchat npx djinnchat

Docker

Build and run:

docker build -t djinnchat .
docker run --rm -p 3777:3777 -v djinnchat_data:/data djinnchat

Docker Compose

Default compose uses SQLite:

docker compose up --build

Enable the optional PostgreSQL service:

DATABASE_URL=postgres://djinn:djinn@postgres:5432/djinnchat \
docker compose --profile postgres up --build

Configuration

VariableDefaultPurpose
PORT3777HTTP and WebSocket port
HOST0.0.0.0Bind host
DATABASE_URLunsetPostgreSQL connection string, enables PG adapter
DJINNCHAT_DB_PATH~/.djinnchat/data.dbSQLite file path
DATA_DIRderived from DB pathBase data directory
UPLOADS_DIR<data-dir>/uploadsUpload storage path
SECRET_KEYauto-generatedSession signing key
INSTANCE_NAMEDjinnChatInstance label for /api/info
LOG_LEVELinfopino log level
CORS_ORIGINS*Allowed browser origins, comma-separated
RATE_LIMIT_PER_MIN120Token bucket rate limit per API key or session
MAX_FILE_SIZE_MB50Upload size cap
DB_POOL_SIZE10PostgreSQL pool size

Security and ops

  • Rate limiting uses an in-memory token bucket with 429 plus Retry-After.
  • Security headers include CSP, frame protection, nosniff, referrer policy, and HSTS on HTTPS requests.
  • Inputs are validated and sanitized across route params, JSON payloads, filenames, URLs, and webhook metadata.
  • Request logs are structured JSON with pino.

Release notes

See CHANGELOG.md for full release history.

Keywords

chat

FAQs

Package last updated on 08 Apr 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts