docs: add Hooks System architecture to KNOWLEDGE.md
This commit is contained in:
@@ -154,11 +154,26 @@ If a collector's raw data exceeds its budget, the collector must truncate to the
|
||||
- Subagent results injected into assistant context only — NOT sent to Telegram
|
||||
- Subagents set_context("subagent", ...) to prevent Telegram spam
|
||||
|
||||
### Hooks System
|
||||
- HTTP endpoint on port 18790 (`POST /hooks`) for external services (Gitea, Home Assistant, scripts, other agents)
|
||||
- Messages go through the bus as proper `InboundMessage`s — same processing path as any channel message
|
||||
- Bus-level correlation: `register_correlation(id)` returns `asyncio.Future`, resolved by outbound dispatcher when matching `correlation_id` appears in outbound metadata
|
||||
- "hook" registered as a channel in ChannelManager — `send()` is a no-op (response returned via correlation, not channel delivery)
|
||||
- Named tokens: config maps names to secrets (`tokens: {gitea: "secret1", ha: "secret2"}`); token name used in message prefix and as default `chat_id`
|
||||
- Default behavior: `channel="hook"`, `chat_id={token_name}`, session=`hook:{token_name}` (isolated per token)
|
||||
- Channel injection: specify `channel="telegram"`, `chat_id="239824268"` to use real channel session — response delivered to that channel AND returned to HTTP caller
|
||||
- Message prefix: `[HOOK MESSAGE from "{token_name}"]` prepended in `_process_message` when `hook_source` present in metadata
|
||||
- `timeout=0` returns 202 (fire-and-forget, message still processed); `timeout>0` waits for agent response
|
||||
- Outbound dispatcher calls `bus.resolve_correlation(msg)` before channel dispatch — resolves Future regardless of target channel
|
||||
- Auth: `Authorization: Bearer <token>` or `X-Hook-Token` header
|
||||
- Health check: `GET /health` (no auth)
|
||||
|
||||
### Key Nanobot Features (Live)
|
||||
- Time-gap injection: >5 min since last message prepends [Current time: ...] notice
|
||||
- Quota-based model switching: /quota command shows usage, burn rate, selected model
|
||||
- Class reminder system: Telegram nudge 30-75 min before class, deduplicated per class
|
||||
- Extended thinking: enabled and active — prevents confident guessing without reasoning
|
||||
- Hooks endpoint: see Hooks System section above
|
||||
|
||||
### Git Notes
|
||||
- /root/.gitconfig is a Docker mount directory — use GIT_CONFIG_GLOBAL=/tmp/gitconfig for git ops
|
||||
|
||||
Reference in New Issue
Block a user