DAKB Session Bridge Client SDK — hooks, launcher, watcher daemon for Claude Code agent communication
Project description
Bridge Client SDK
Client-side SDK for the Session Bridge system. Provides hooks for Claude Code event injection, a background WebSocket bridge runner, and a watcher daemon that auto-responds to external chat messages when Claude Code is idle.
Install
pip install -e backend/dakb_service/bridge/Client_SDK
Architecture: Two Paths, One Inbox
Path A (User active — hook-driven):
User types → UserPromptSubmit hook → inbox_hook.py
→ consumes inbox → injects additionalContext → Claude responds inline
Path B (Agent standby — daemon-driven):
Message arrives → Redis notify key → Watcher Daemon (BLPOP)
→ checks no interactive session active
→ claude -p --resume SESSION_ID
→ captures response → POST /api/v1/bridge/send → external chat gets reply
Components
Hooks (bridge_client_sdk/hooks/)
| Hook | Event | Purpose |
|---|---|---|
inbox_hook.py |
UserPromptSubmit | Consume inbox, inject as additionalContext |
cleanup_hook.py |
SessionEnd | Kill bridge + watcher processes, clean Redis keys |
event_hook.py |
TaskCompleted, TeammateIdle | Forward event notifications to external chat |
test_hook.py |
Any | Verify additionalContext injection works |
Scripts
| Script | CLI Command | Purpose |
|---|---|---|
client_launcher.py |
bridge-launcher |
Launch bridge WebSocket client as background process |
client_runner.py |
— | Long-running WS→Redis bridge (spawned by launcher) |
test_fire.py |
bridge-test-fire |
Push test message into inbox + notify watcher |
watcher_daemon.py |
bridge-watcher |
Auto-respond daemon (BLPOP + claude -p) |
Usage
Start the watcher daemon
# Auto-discover session ID
bridge-watcher
# Or specify explicitly
bridge-watcher --session-id SESSION_ID
# With debug logging
bridge-watcher --session-id SESSION_ID --log-level DEBUG
Push a test message
bridge-test-fire "Hello from test"
Launch the WebSocket bridge
bridge-launcher SESSION_ID --chat-id telegram:-456
Dual-Response Prevention
| Redis Key | Set By | TTL | Purpose |
|---|---|---|---|
bridge:interactive:{session_id} |
inbox hook | 30s | User active → daemon defers |
bridge:watcher:lock:{session_id} |
daemon | 120s | Daemon responding → hook defers |
bridge:watcher:notify:{session_id} |
bridge/queue | — | BLPOP doorbell for daemon |
Configuration
Edit bridge_client_sdk/config/watcher_config.json:
{
"blpop_timeout": 30,
"batch_delay": 2.0,
"cooldown": 5.0,
"lock_ttl": 120,
"max_budget_usd": 0.50,
"allowed_tools": "Read,Bash,Grep,Glob,WebFetch,WebSearch",
"system_prompt": "..."
}
Hook Integration
The original hook scripts at .claude/scripts/bridge_*.py are thin shims that import from this SDK. The .claude/settings.local.json hook paths remain unchanged — they call the shims which delegate to the SDK.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dakb_bridge_sdk-0.1.0.tar.gz.
File metadata
- Download URL: dakb_bridge_sdk-0.1.0.tar.gz
- Upload date:
- Size: 21.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dfe580b34c39f9d601ea1bf544eda2369943752d710626557392d7b12277dc72
|
|
| MD5 |
d67e65cbf90acba4321cc52eaa9123de
|
|
| BLAKE2b-256 |
cd329333aba87e47ecd4d85ff80854adefcc2ce28436d7c28948d2e294398665
|
File details
Details for the file dakb_bridge_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: dakb_bridge_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 21.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db5de3c142b4e85d0f09f37444d172f394a539bfeeeffa3f61af8d1bde1bd8e1
|
|
| MD5 |
af726a30cd8fe9e6b9081da3dca13266
|
|
| BLAKE2b-256 |
fae926ae48e68cf79448b1272d8c270c948aa68b7714eafc1d2039b1fb19f7aa
|