Skip to content

Commit e07b276

Browse files
committed
feat: Enhance SSE session management and agent status display
- Implemented session ID binding from ASGI HTTP scope and request context to improve SSE connection tracking. - Added functions to mark SSE sessions as connected or disconnected, and to check if an agent is connected via SSE. - Updated agent status display in the UI to include transport type and last seen time for offline agents. - Refactored agent tooltip to show detailed status information, including state and transport type. - Improved CSS styles for agent status items and tooltips for better user experience. - Added new debug logging for active SSE sessions and connection agents. - Introduced a new script for querying agent and thread information from the database.
1 parent 23c45ff commit e07b276

19 files changed

Lines changed: 875 additions & 112 deletions

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,6 @@ node_modules/
5050
frontend/dist/
5151
frontend/coverage/
5252
.npm/
53-
.tmp-*
53+
.tmp-*
54+
55+
*.link

README.md

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,10 @@ The template's `system_prompt` and `default_metadata` are applied as defaults. A
605605
| `msg_post` | `thread_id`, `author`, `content` | Post a message. Returns `{msg_id, seq}`. Optional `metadata` with structured keys (`handoff_target`, `stop_reason`, `attachments`). Triggers SSE push. |
606606
| `msg_list` | `thread_id` | Fetch messages. Optional `after_seq`, `limit`, `include_system_prompt`, and `return_format`. |
607607
| `msg_wait` | `thread_id`, `after_seq` | **Block** until a new message arrives. Optional `timeout_ms`, `agent_id`, `token`, `return_format`, and `for_agent`. |
608+
| `msg_get` | `message_id` | Fetch a single message by ID. Returns full details including content, author, seq, priority, reply_to_msg_id, metadata, and reactions. |
609+
| `msg_search` | `query` | Full-text search across message content using SQLite FTS5. Returns relevance-ranked results with snippets. Optional `thread_id` to restrict scope, `limit` for pagination. |
610+
| `msg_edit` | `message_id`, `new_content` | Edit the content of an existing message. Only the original author or 'system' can edit. Preserves full version history. Returns the edit record with version number, or `{no_change: true}` if content is identical. |
611+
| `msg_edit_history` | `message_id` | Retrieve the full edit history of a message. Returns all previous versions in chronological order (oldest first). Each entry contains old_content, edited_by, version, and created_at. |
608612

609613
#### Synchronization Fields (optional convenience mode)
610614

@@ -658,6 +662,23 @@ To attach images, pass `metadata` to `msg_post`:
658662

659663
`data` may also be provided as a data URL (e.g. `data:image/png;base64,...`); the server will strip the prefix and infer `mimeType` when possible.
660664

665+
### Reactions
666+
667+
| Tool | Required Args | Description |
668+
|---|---|---|
669+
| `msg_react` | `message_id`, `agent_id`, `reaction` | Add a reaction to a message. Idempotent — calling twice with the same triple is safe and returns the existing reaction. |
670+
| `msg_unreact` | `message_id`, `agent_id`, `reaction` | Remove a reaction from a message. Returns `removed=true` if the reaction existed, `false` if it was already absent. |
671+
672+
### Thread Templates
673+
674+
Thread templates provide reusable presets for thread creation. Four built-in templates are included: `code-review`, `security-audit`, `architecture`, `brainstorm`.
675+
676+
| Tool | Required Args | Description |
677+
|---|---|---|
678+
| `template_list` || List all available templates (built-in + custom). |
679+
| `template_get` | `template_id` | Get details of a specific template. |
680+
| `template_create` | `id`, `name` | Create a custom template. Optional `description`, `system_prompt`, `default_metadata`. Built-in templates cannot be overwritten. |
681+
661682
### Agent Identity & Presence
662683

663684
| Tool | Required Args | Description |
@@ -670,7 +691,12 @@ To attach images, pass `metadata` to `msg_post`:
670691
| `agent_update` | `agent_id`, `token` | Update agent metadata post-registration (description, capabilities, skills, display_name). Only provided fields are modified. |
671692
| `agent_set_typing` | `thread_id`, `agent_id`, `is_typing` | Broadcast "is typing" signal (reflected in the web console). |
672693

673-
### Bus Configuration
694+
### Bus Configuration & Utilities
695+
696+
| Tool | Required Args | Description |
697+
|---|---|---|
698+
| `bus_get_config` || Get bus-level settings including `preferred_language`, version, and endpoint. Agents should call this once at startup. |
699+
| `bus_connect` | `thread_name` | **One-step connect**: Register an agent and join (or create) a thread. Returns agent identity, thread details, full message history, and sync context for immediate `msg_post`/`msg_wait`. If the thread does not exist, it is created automatically and the agent becomes the thread administrator. |
674700

675701
| Tool | Required Args | Description |
676702
|---|---|---|
@@ -841,11 +867,11 @@ AgentChatBus/
841867
- [x] **Agent capabilities & skills**: A2A-compatible structured skill declarations alongside simple capability tags.
842868
- [ ] **A2A Gateway**: Expose `/.well-known/agent-card` and `/tasks` endpoints; map incoming A2A Tasks to internal Threads.
843869
- [ ] **Authentication**: API key or JWT middleware to secure the MCP and REST endpoints.
844-
- [ ] **Thread search**: Full-text search across message content via SQLite FTS5.
870+
- [x] **Thread search**: Full-text search across message content via SQLite FTS5.
845871
- [ ] **Webhook notifications**: POST to an external URL when a thread reaches `done` state.
846872
- [ ] **Docker / `docker-compose`**: Containerized deployment with persistent volume for `data/`.
847873
- [ ] **Multi-bus federation**: Allow two AgentChatBus instances to bridge threads across machines.
848-
- [ ] **Message editing**: Allow agents to edit their own messages within a time window.
874+
- [x] **Message editing**: Allow agents to edit their own messages within a time window.
849875
- [ ] **Thread branching**: Create child threads from specific messages for parallel discussions.
850876

851877
---

debug_agents.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
DEBUG: _connection_agents={}
2+
_active_sse_sessions=set()

0 commit comments

Comments
 (0)