Commit Graph
54 Commits
Author SHA1 Message Date
openbot e5dad05c41 0.2.0: rename package agenthub-gateway; extract ACP client into acpclient (shims keep old imports) 2026-10-25 13:58:41 +08:00
openbot 80bb05510f docs: gateway/worker split design (deepagents orchestrator + HTTP/WS dispatch) 2026-10-24 15:47:27 +08:00
openbot 353db7ba10 fix(wecom): proactive fallback must not spam one message per delta
The 59c44e9 fallback replied every coalesced delta (~0.8s) as a separate
proactive message once the callback req_id went stale - a wall of
repeating snapshots. Now: intermediate deltas are dropped after a single
'long reply, result will follow' notice; only the final text goes out.
2026-10-24 10:12:19 +08:00
openbot 59c44e94ca fix(wecom): degrade stream replies to proactive msg when callback req_id stale
Turns that outlive the WeCom callback req_id window (e.g. approval
round-trips >5min) had their delta/finish frames silently rejected by
the gateway, so the user saw 'clicked approve, nothing happened' while
the agent kept working. Track req_id recv time; past a 240s TTL, stream
updates fall back to proactive aibot_send_msg. Also log non-zero
errcode ack frames so future gateway rejections are visible.
2026-10-24 09:18:19 +08:00
openbot 0f7adb7966 fix(wecom): half-open WS detection tests + heartbeat interval config; log card-click event frames 2026-10-22 18:47:09 +08:00
openbot c7497f0c4a feat(media): image/video/audio/file send+receive across channels
- inbound: wecom file/video frames download+decrypt into InboundMessage.files
- session: store non-image attachments under media_in/, reference path in prompt
- outbound: workspace sentinel diffs agent cwd after each turn; new files emit
  media events; wecom uploads via 3-step aibot upload protocol (init/chunk/finish)
- >20MB or unsupported channels fall back to text with the server path
2026-10-18 01:19:55 +08:00
openbot 2b3ed03804 fix(sessions): dedup update-relay handlers per ACP session
_attach_update_relay ran on every prompt but notification handlers
APPEND on the shared ACPClient, so the Nth turn registered N handlers
and every agent_message_chunk was appended N times into _deltas —
the final text came out interleaved and N-times repeated. Guard
registration by _relay_session tag; regression test included.
2026-10-16 17:09:49 +08:00
openbot 55b19c7d18 feat(nats): TLS support (tls_ca/tls_insecure config) 2026-10-16 11:12:00 +08:00
openbot f688e3be9f feat(channels): add NATS channel (request/reply front-end)
- NatsChannel: subscribe in_subject (agenthub.in.>), publish replies to
  out_subject.<chat_id>; JSON bodies {chat_id, user_id?, text}
- deltas dropped (no edit semantics), final/status/interaction/command
  rendered via shared base helpers; allowed_users gate; 900KB split
- vendored SyncNATS wrapper (nats-py is asyncio-only; thread behind)
- runtime.build_channels wiring; optional dependency extra "nats"
- 9 mock-transport tests; full suite 116 passed
2026-10-16 11:04:02 +08:00
openbot ee1cca839f chore(sessions): log approval request creation for observability 2026-10-14 21:29:22 +08:00
openbot c02cd9a379 fix(wecom): clearer expired-approval card title 2026-10-14 20:18:58 +08:00
openbot ef2259ad5e feat(wecom): interactive approval template cards
- interaction events on wecom render as button_interaction template cards
  (aibot_send_msg template_card): title=tool, buttons keyed <req_id>|<option_id>,
  task_id=request_id, allow=primary style, reject=danger
- aibot_event_callback template_card_event -> card_answer_cb ->
  SessionManager.answer_card(req_id, option_id) answers the pending permission
  directly (presented anti-race rule kept); card updated in place via
  aibot_respond_update_msg (已批准/已拒绝)
- text fallback on card send failure; numbered text replies still work
- tests: tests/test_approval_card.py (4 cases)
2026-10-14 17:55:58 +08:00
openbot 10420f9d72 feat(approval): route ACP permission approvals to the wecom approval chat
- single dispatch-all event sink (per-channel sinks previously overwrote each other)
- channels.wecom.approval_chat config: interaction events are additionally
  delivered to that wecom chat with routed_from stamp; SessionManager.set_route
  stamps the pending permission route_key so the approval chat can answer with
  numbered/name/re r replies (pending_interaction + permission_reply accept
  either the originating key or the route key)
- origin == approval chat is not duplicated; no config = previous behavior
- tests: tests/test_approval_route.py (7 cases)
2026-10-14 17:34:15 +08:00
openbot 5f2f724827 refactor(admin): multi-page UI per web interface guidelines
- hash routing (#/overview #/sessions #/convs #/approvals #/admin): deep-link, refresh-safe, back/forward
- a11y: semantic nav/main, skip link, focus-visible outlines, aria-current, aria-live toast/status, labelled inputs, aria-labels on icon buttons
- forms: inline validation errors, submit loading state, beforeunload guard for unsaved edits
- UX: Intl number/time formats, tabular-nums, ellipsis chars, destructive confirm, admin nav badge for pending approvals
- theming: color-scheme dark, theme-color meta, prefers-reduced-motion, touch-action
- fix stale admin_ui_credentials.txt vs config drift (creds file outdated; sqlite admin config is source of truth)
2026-10-13 19:05:55 +08:00
openbot 42b9b0ae8a feat(inbound): tell user when chat has no binding — routing never silent
First message on an unbound chat now shows which default agent will
handle it (+ /agents, /switch hints) before the turn runs.
2026-10-13 17:50:24 +08:00
openbot 69ea08ad44 chore(wecom): INFO log on every inbound callback frame (recv diagnostics) 2026-10-13 17:34:53 +08:00
openbot 26dd44bd19 fix(admin): bind button had zero feedback — looked dead
- bind is a synchronous ACP session create (seconds); button showed
  nothing meanwhile and the 10s auto-refresh could rebuild the pane
  mid-request, erasing the button the user was waiting on
- now: immediate toast (正在建立 ACP 会话…), button switches to
  绑定中…/disabled, opsBusy guard stops auto-refresh re-render during
  any write op, success toast carries session id, chat_id cleared
2026-10-13 17:30:24 +08:00
openbot 738c977e7d fix(session): switch() persists binding; wecom dispatch errors logged
- switch() (admin UI bind + /switch) never called _persist_binding —
  UI-created bindings were lost on restart and invisible in the db
- wecom ws recv loop swallowed dispatch exceptions silently; now logs
  msg preview on dispatch failure (inbound blind spot)
2026-10-13 17:25:01 +08:00
openbot 817a5cba5d fix(admin): UX round — form-preserving refresh, merged views, restyle
- bug1: auto-refresh no longer wipes filled forms on the manage tab
  (input events set opsDirty; refresh pulls data silently, re-renders
  only when idle)
- bug2: binding table now merges live bindings with persisted
  session_records (hub restarts clear bindings by design — ACP session
  ids die with the process — but chats keep their history); rows show
  活跃 vs 历史·N turns
- merge Config into 管理 tab (tabs now: 概览/会话/对话/审批/管理)
- restyle: header status lamp (运行中/降级/不可达), underline tabs w/
  accent color, card shadows, unified 12px radius, refresh as button
2026-10-13 17:14:15 +08:00
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 56259346d8 style(admin): UI/UX upgrade — larger type, roomier layout
- base font 14->16px, body max-width 1280->1440, line-height 1.5
- tables/rows/messages/badges upscaled to match; big-number KV 22->26px
- refresh button now a bordered chip (tap target)
- responsive: single-column grid under 760px
2026-10-13 16:22: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 2bf6b76e15 feat: tool progress markers in stream bubble, transient model error auto-retry, friendly error text 2026-10-06 22:17:15 +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 c16b643ed8 chore(scripts): add nginx /agents patch script (idempotent) 2026-10-06 16:17:21 +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 2bcdf946f7 feat(http): status http surface for nginx /agents reverse proxy
- http_admin.py: ThreadingHTTPServer on 127.0.0.1:30990
  GET /agents/ /status /healthz /sessions; POST /agents/prompt (ops)
- runtime starts it from config.http
- verified locally: healthz + status return JSON
2026-10-06 16:12:52 +08:00
openbot 436efc3b09 feat(runtime): use real aibot WS transport by default (mock_transport=true opts out) 2026-10-06 16:07:05 +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 62773ab2e5 feat(runtime): wire channels + session manager into a runnable service
- runtime.py: config load (JSONC tolerated) -> SessionManager + channels,
  inbound prompts run in worker threads (receive loop never stalls),
  prompt errors surfaced to the chat via final event, SIGTERM/SIGINT stop
- __main__/entry point forward to runtime.main
- tests: 43 passed
2026-10-06 16:00:54 +08:00
openbot 39368ecf65 chore(scripts): publish.sh — test/pypi upload flow via uv (token file, tests-then-build) 2026-10-06 15:48:29 +08:00
openbot 0e585c1d5a chore: uv packaging + README refresh, prep for TestPyPI
- pyproject: metadata (license/classifiers/urls), cryptography runtime dep,
  optional [nats] extra, PEP 735 dependency-groups dev (pytest/pyright),
  hatch wheel target src/agenthub
- regenerate uv.lock; uv sync/build verified (sdist+wheel, no node_modules)
- README: real repo structure, channel matrix, uv workflows, TestPyPI flow
- dist/ ignored
2026-10-06 15:47:20 +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 bf8748b21b design v0.5: IM channels - WeCom aibot long-connection + WeChat customer service 2026-10-06 11:10:46 +08:00
openbot 8a84f96250 design: record M0 findings (ndjson transport, M0 done) 2026-10-06 11:07:21 +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 d96d4f73bb design v0.4: IM/NATS as peer channels (NATS only handles message transport), all examples JSON 2026-10-06 10:41:52 +08:00
openbot 27d4da67fb design v0.3.1: DESIGN.md apply review feedback (NATS client role, JSON config) 2026-10-06 10:33:54 +08:00
openbot dad43aa1fd design v0.3.1: apply review feedback (NATS client role, JSON config) 2026-10-06 10:33:08 +08:00
openbot 4aee2446cb design v0.3: web admin UI, /switch command, monitoring dashboard 2026-10-06 10:31:09 +08:00
openbot 54cbd773ee chore: last naming refs 2026-10-06 10:16:44 +08:00
openbot 65ca560640 fix: package/config naming to agenthub 2026-10-06 10:16:32 +08:00
openbot de4a3337ec rename acp-bridge -> agenthub; design v0.2: front-end agnostic entry + supervisor orchestration + depth guard 2026-10-06 10:16:15 +08:00
openbot 951fada34b init: project skeleton + design docs (ACP bridge) 2026-10-06 09:59:08 +08:00