Commit Graph
18 Commits
Author SHA1 Message Date
openbot 355446c80a feat(admin): sqlite-backed config CRUD + full management UI
- config doc moves to agenthub.db table 'config' (single JSON doc, id=1);
  config.json is first-run seed only; same db as bindings/records
- AdminStore: sqlite doc store (thread-locked, persists across restarts)
- full CRUD per entity: list/get/upsert/delete for channels + agents,
  bind/unbind for bindings; upsert merges blank secret fields (edit form
  can leave them empty); last-agent delete guard; unknown-field 400s
- secrets masked at list/get time (yb…[REDACTED]); plaintext never
  crosses the API
- Ops tab rebuilt: list tables w/ per-row edit+delete buttons, +新增
  forms, delete confirm() dialogs, live binding table w/ unbind
2026-10-13 17:04:30 +08:00
openbot f876f2723d feat(admin): write ops — channel/agent config editing + IM<->agent binding
- admin_ops.AdminWrites: atomic config.json writes (tmp+rename), field
  validation (required/optional/unknown), secrets stay server-side
- channels: upsert/delete for wecom|wecom-app|weixin; sets pending_restart
  hint (long-lived IM connections need supervisor restart)
- agents: upsert hot-registers AgentSpec into live SessionManager (lazy
  spawn); delete guards last-agent; cmd string->list normalization
- binding: reuse mgr.switch() (cross-agent history migration honored) +
  unbind; /api/* POST endpoints auth-gated (fail-closed)
- UI: Ops tab — 3 forms (channel w/ per-type fields, agent, bind) with
  toasts, secret inputs masked, pending-restart banner
2026-10-13 16:50:15 +08:00
openbot c396ce2d5e feat(admin): auth + four data panels (sessions/conversations/approvals/config)
- HTTP Basic auth from config http.admin (constant-time compare; absent
  config -> UI/api fail-closed 503, legacy JSON endpoints stay open)
- GET /api/sessions: bindings + pinned model + idle
- GET /api/conversations: hub-side text logs (tail 50/binding)
- GET /api/approvals: pending permission requests incl. options/presented
- GET /api/config: effective config with secret-looking values redacted
- UI: tabbed layout (Overview/Sessions/Conversations/Approvals/Config),
  approvals tab shows pending count badge
2026-10-13 16:05:42 +08:00
openbot e1afdce073 feat(admin): single-file dark dashboard UI on / and /ui
Static HTML served by StatusHTTP (stdlib only, no build step): service
health pills, channel connection states, agent processes, live bindings
table; fetches existing /status + /sessions JSON, 10s auto-refresh.
2026-10-13 15:00:55 +08:00
openbot 036b5641cf session: activate default_model — pin configured model after session/new
AgentSpec.default_model was declared but never consumed; the agent's
built-in default rotated (fledge-alpha-free -> exo-free) and several
free upstreams go dark ('Endpoint is unavailable'). After session/new,
set the configured model via session/set_config_option; failure is
non-fatal (warn + continue with agent default). Adds 4 tests (75 total).
2026-10-08 22:12:45 +08:00
openbot d8cce95adf feat: wecom finish-frame overflow splitting + /status channel state
- _stream_close: finish frame capped at 19KB; overflow chunks delivered
  as aibot_send_msg markdown (dsh-im verified approach, nothing dropped)
- channel_state events recorded on channel objects; wecom WS reconnect
  failures surface in /status as channels[].state, service "degraded"
  when any channel failed
- runtime _safe_event no longer misroutes chatless keys

Tests: 71 passed (2 new: split + total-integrity)
2026-10-08 11:35:28 +08:00
openbot 23c1adcca4 feat: keepalive hardening + approval safety (dsh-im parity)
Keepalive (fixes 19h silent WS death on 2026-10-07):
- recv() raises on dead reader / stale inbound (no pong) instead of
  returning None forever -> outer loop reconnects
- heartbeat closes socket after 2 missed pongs
- reconnect default unlimited (0), backoff cap 60s; auth still terminal
- connection_state surfaced (idle/connecting/connected/failed)

Approval hardening:
- unpresented approval can never be answered (race guard)
- timeout notifies the user ("已自动拒绝")
- stale pending permissions reaped; created_at tracked

Tests: 69 passed (9 new regressions in test_keepalive_approvals.py)
2026-10-08 11:26:57 +08:00
openbot 1a25790d4a fix: route IM replies during pending permission to permission_reply (was leaking to agent queue) 2026-10-06 20:40:51 +08:00
openbot 0e4bcc5a1f fix: server requests must not block reader thread; drop stale bindings on startup 2026-10-06 19:09:12 +08:00
openbot e36f596255 feat: IM commands (/new /model /agents /switch /status), inbound ack, structured permission interactions 2026-10-06 17:46:53 +08:00
openbot e22dc9c1ee fix(wecom-ws): EOF raises ConnectionError to trigger reconnect; close() hardened
- recv(): connection EOF now raises instead of returning None — the channel
  outer loop treats it as disconnect and runs backoff reconnect
- close(): best-effort with timeouts, no hang when loop already dead
- tests: fake aibot gateway (subscribe/reply/heartbeat), auth-failure path
  45 passed
2026-10-06 16:15:54 +08:00
openbot bbe36be192 feat(wecom): official aibot long-connection protocol + real WS transport
- wecom_ws.py: AibotWSAdapter (asyncio websockets bridged to channel threads):
  connect wss://openws.work.weixin.qq.com, aibot_subscribe auth, 30s ping
  heartbeat, reader->queue, graceful shutdown
- wecom.py switched to official frames:
  * inbound aibot_msg_callback / aibot_event_callback (enter_chat -> welcome)
  * reply: aibot_respond_msg stream {id, finish, content} reusing the
    callback's req_id; after finish, proactive aibot_send_msg markdown
  * image inbound: {url, aeskey} fetch + AES-256-CBC (IV=key[:16], PKCS7)
  * mixed (text+image) and voice (transcribed) message types
- tests updated to official frame shapes; 43 passed
2026-10-06 16:06:49 +08:00
openbot 86642e07c9 test(channels): IM three-channel e2e wiring tests + final-text accumulation
- test_channels_e2e.py: full loop per channel
  (inbound -> SessionManager.prompt -> mock ACP agent -> events -> outbound):
  * wecom aibot: text dispatch -> delta frames -> replyStream final;
    image base64 inbound
  * wecom-app: real local HTTP callback server + real WXBizMsgCrypt
    (GET echo verify + POST encrypted XML) -> stubbed qyapi send
  * weixin: QR login -> long-poll inbound -> sendmessage outbound
- session.py fix: accumulate delta text per turn; 'final' event now carries
  full text so no-edit-API channels (wecom-app/weixin) deliver whole message
- wecom.py: buffer outbound frames when not connected (testability)
- tests: 43 passed
2026-10-06 11:51:04 +08:00
openbot 3598358293 feat(session): M1 session manager — binding table, /switch, reaper, sqlite
- (channel, chat_id) -> {agent, acp_session_id} binding table
- prompt(): auto-create binding, per-chat turn serialization, image blocks
- switch(): /switch semantics; --continue migrates hub-side text ONLY
  (tool state does not migrate, documented)
- update relay: ACP session/update -> delta/thinking/tool_start/tool_end/
  plan/final events via per-binding event sink
- cwd whitelist per agent (fnmatch, ~ expanded, realpath)
- idle reaper: expire bindings after idle_ttl_s, close unbound processes;
  max_sessions cap with LRU eviction
- sqlite persistence (bindings + session_records) — DB is fact source,
  config.json only bootstrap
- process death: client+binding dropped, SessionError surfaced
- tests: 39 passed (mock ACP agent subprocess)
2026-10-06 11:45:19 +08:00
openbot d698ae8a60 feat(channels): add wecom / wecom-app / weixin IM channels (M1.5)
- base.py: IMChannel protocol + InboundMessage + shared helpers
  (split_message_text utf-8 byte-safe, clean_control_chars ZWSP hygiene)
- editable_stream.py: create-edit-flush streaming fallback pattern
- wecom.py: aibot WebSocket long-connection (replyStream streaming,
  allowlist, reconnect backoff, auth-failure terminal)
- wecom_app.py: self-built app HTTP callback (stdlib server, WXBizMsgCrypt
  AES-CBC round-trip, access_token cache, media download; works in both
  WeCom client and WeChat via WeChat-plugin, no streaming on this path)
- weixin.py: WeChat bot QR login + getupdates long-poll + sendmessage
- tests: 28 passed (mock transports, crypt roundtrip, stream coalesce)

Ported from dsh-im (xmanrui) protocol facts and resilience patterns.
2026-10-06 11:33:07 +08:00
openbot 33d8ac3046 test: fix ndjson partial-tail truncation point 2026-10-06 11:07:14 +08:00
openbot 82c3763e5c M0: framing (ndjson + lsp-frame), ACPClient, mock agent fixture, probe script; real claude-code-acp handshake verified 2026-10-06 11:05:40 +08:00
openbot 951fada34b init: project skeleton + design docs (ACP bridge) 2026-10-06 09:59:08 +08:00