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.
Metadata
Release files for dakb-bridge-sdk 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dakb_bridge_sdk-0.1.0.tar.gz | 21.2 kB | Without provenance | Details for dakb_bridge_sdk-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dakb_bridge_sdk-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for dakb_bridge_sdk-0.1.0-py3-none-any.whl |
Total release size: 42.8 kB
Release files / dakb_bridge_sdk-0.1.0.tar.gz
| Download URL | dakb_bridge_sdk-0.1.0.tar.gz |
|---|---|
| Size | 21.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dfe580b34c39f9d601ea1bf544eda2369943752d710626557392d7b12277dc72
|
|
BLAKE2b-256 checksum How to use checksums |
cd329333aba87e47ecd4d85ff80854adefcc2ce28436d7c28948d2e294398665
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.12
|
Release files / dakb_bridge_sdk-0.1.0-py3-none-any.whl
| Download URL | dakb_bridge_sdk-0.1.0-py3-none-any.whl |
|---|---|
| Size | 21.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
db5de3c142b4e85d0f09f37444d172f394a539bfeeeffa3f61af8d1bde1bd8e1
|
|
BLAKE2b-256 checksum How to use checksums |
fae926ae48e68cf79448b1272d8c270c948aa68b7714eafc1d2039b1fb19f7aa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.12
|
Security for dakb-bridge-sdk 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.