agent-comm-hub 0.10.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -258,8 +258,8 @@ with `agent-comm-hub setup --remove` (or only refresh skills via
258
258
  | `bridge_chat(to, message, threadId?, priority?, ref?, expiresAt?)` | Send a chat message; `to: "all"` broadcasts. `expiresAt` is an absolute epoch-ms deadline: a message still undelivered after it is dropped and counted, not delivered late. `priority` (0\|1\|2, default 0) orders the recipient's mailbox |
259
259
  | `bridge_notice(to, message, level?)` | Send a system-flavoured notice (`info`/`warn`/`error`) — read as a status, not as chat; creates no task |
260
260
  | `bridge_task(to, prompt, context?, deliverable?, timeoutMs?, threadId?, ref?, expiresAt?)` | Delegate a structured task (`timeoutMs` is the assignee's SLA once it arrives; `expiresAt` is the delivery deadline) |
261
- | `bridge_ack(ref, status, note?, progress?)` | Acknowledge a task (`accepted`/`working`/`rejected`/`done`/`failed`), routed back to the original sender |
262
- | `bridge_wait(from?, ref?, threadId?, timeoutMs?, ack?, maxMessages?)` | Long-poll for the next message (default 30 s). `ack: "manual"` leases it instead of consuming it; `maxMessages > 1` returns `{type:"messages", messages:[…]}` in one call |
261
+ | `bridge_ack(ref, status, note?, progress?, artifacts?)` | Acknowledge a task (`accepted`/`working`/`input-required`/`rejected`/`done`/`failed`), routed back to the original sender and folded into the ledger. `artifacts` (`[{name, mimeType?, text?\|url?}]`) is where the result goes; only the task's assignee may move its ledger |
262
+ | `bridge_wait(from?, ref?, threadId?, timeoutMs?, ack?, maxMessages?, statuses?, terminalOnly?)` | Long-poll for the next message (default 30 s). `ref` matches that task's ack **or** the chat an assignee answers with; `statuses`/`terminalOnly` narrow it to a terminal ack. `ack: "manual"` leases it instead of consuming it; `maxMessages > 1` returns `{type:"messages", messages:[…]}` in one call |
263
263
  | `bridge_poll(from?, ack?)` | Non-blocking drain of queued messages (`ack: "manual"` leases them) |
264
264
  | `bridge_commit(ids)` | Acknowledge leased messages; uncommitted ones come back when the lease expires |
265
265
  | `bridge_nack(ids)` | Give leased (or dead-lettered) messages back immediately — use when handling failed |
@@ -274,7 +274,7 @@ with `agent-comm-hub setup --remove` (or only refresh skills via
274
274
  | `bridge_discover(skill?, tag?, acceptsTasks?, idleOnly?)` | Find a peer to hand work to, with its current load |
275
275
  | `bridge_group_create` · `bridge_group_send` · `bridge_group_list` · `bridge_group_delete` · `bridge_group_add_member` · `bridge_group_remove_member` | Named channels for a subset of peers |
276
276
 
277
- That is the full 26 message + group tools; the 11 control tools are below. (37 in total and symmetric on every side — see [ARCHITECTURE.md](ARCHITECTURE.md) §4.)
277
+ That is the full 28 message + observability + group tools; the 11 control tools are below. (39 in total and symmetric on every side — see [ARCHITECTURE.md](ARCHITECTURE.md) §4.)
278
278
 
279
279
  Two peer ids are reserved and cannot be registered or renamed into: `all` (broadcast) and `hub` (the hub's own drop notices — `bridge_wait { from: "hub" }` subscribes to them).
280
280
 
@@ -348,10 +348,11 @@ token table owns the `Authorization` header, so `--manager-token` is ignored the
348
348
  Rosters persist: `--state-file` (default `~/.agent-comm-hub/roster.json`,
349
349
  `off` to disable) keeps aliases and client info across hub restarts.
350
350
 
351
- Roster changes and queued mail are pushed over the SSE channel as
351
+ Roster changes, queued mail and task moves are pushed over the SSE channel as
352
352
  `notifications/message` events (`data.event: "peers_changed"` with the full
353
- roster, `data.event: "message"` hint scoped to the recipient), so GUIs and
354
- skills can react without polling.
353
+ roster, `data.event: "message"` hint scoped to the recipient,
354
+ `data.event: "task_changed"` with `{taskId, status, a2aState, updatedAt}` to a
355
+ task's sender and assignees only), so GUIs and skills can react without polling.
355
356
 
356
357
  Every result is lossless JSON (compatible with DSH's strict tool registry).
357
358
 
@@ -486,7 +487,7 @@ const hub = startHub({ port: 18764 }, console) // returns { hub, registry, serve
486
487
  ```bash
487
488
  pnpm install
488
489
  pnpm typecheck # tsc --noEmit (strict)
489
- pnpm test # test suite (314 checks: 169 smoke + 46 setup + 11 ops + 35 herdr + 33 discover + 20 e2e)
490
+ pnpm test # test suite (446 checks: 286 smoke + 46 setup + 11 ops + 35 herdr + 33 discover + 35 e2e)
490
491
  npm run build:admin # admin/ workspace (npm) → single-file assets/admin.html
491
492
  pnpm run build # esbuild → lib/{cli,index,setup}.js (zero deps)
492
493
  pnpm pack # build + npm pack (publishing artifact)
@@ -537,4 +538,4 @@ Tests cover registration, duplicate rejection, chat routing, sender-filtered wai
537
538
 
538
539
  ## License
539
540
 
540
- MIT — see [LICENSE](LICENSE). Contributions welcome: keep the 314-check suite green (`pnpm test`) and zero runtime dependencies. Architecture: [ARCHITECTURE.md](ARCHITECTURE.md).
541
+ MIT — see [LICENSE](LICENSE). Contributions welcome: keep the 446-check suite green (`pnpm test`) and zero runtime dependencies. Architecture: [ARCHITECTURE.md](ARCHITECTURE.md).
package/README.zh.md CHANGED
@@ -169,8 +169,8 @@ agent-comm-hub service uninstall
169
169
  | `bridge_unregister()` | 离开 hub(移除 peer、队列与绑定;之后保持离线直到显式注册) |
170
170
  | `bridge_chat(to, message)` | 发消息;`to: "all"` 广播 |
171
171
  | `bridge_task(to, prompt, context?, deliverable?)` | 派结构化任务 |
172
- | `bridge_ack(ref, status, note?)` | 回执(accepted/rejected/done/failed),自动回到原发送者 |
173
- | `bridge_wait(from?, timeoutMs?)` | 长轮询收下一条消息(默认 30s;循环=实时监听) |
172
+ | `bridge_ack(ref, status, note?, progress?, artifacts?)` | 回执(accepted/working/input-required/rejected/done/failed),自动回到原发送者并记入账本;`artifacts` 放产出物。只有该任务的 assignee 能改账本 |
173
+ | `bridge_wait(from?, ref?, threadId?, timeoutMs?, ack?, maxMessages?, statuses?, terminalOnly?)` | 长轮询收下一条消息(默认 30s;循环=实时监听)。`ref` 匹配该任务的 ack 或 assignee 用 chat 回传的结果;`statuses`/`terminalOnly` 收窄到终态 ack |
174
174
  | `bridge_poll(from?)` | 非阻塞取走所有排队消息 |
175
175
  | `bridge_status()` | 枢纽健康:各 peer 在线/队列/等待状态 |
176
176
  | `bridge_peers()` | 谁在线 |
@@ -210,7 +210,7 @@ agent-comm-hub service uninstall
210
210
 
211
211
  花名册可落盘:`--state-file`(默认 `~/.agent-comm-hub/roster.json`,`off` 关闭),别名与客户端信息在 hub 重启后保留。
212
212
 
213
- 花名册变化与排队消息会通过 SSE 通道以 `notifications/message` 事件推送(`data.event: "peers_changed"` 携带完整花名册,`data.event: "message"` 仅推送给收件人),GUI 与 skill 无需轮询即可感知。
213
+ 花名册变化、排队消息与任务跃迁会通过 SSE 通道以 `notifications/message` 事件推送(`data.event: "peers_changed"` 携带完整花名册,`data.event: "message"` 仅推送给收件人,`data.event: "task_changed"` 携带 `{taskId, status, a2aState, updatedAt}` 且只推给该任务的发送方与 assignee),GUI 与 skill 无需轮询即可感知。
214
214
 
215
215
  所有返回都是 lossless JSON(兼容 DSH 的严格工具注册表)。
216
216
 
@@ -276,7 +276,7 @@ const hub = startHub({ port: 18764 }, console) // 返回 { hub, registry, server
276
276
  ```bash
277
277
  pnpm install
278
278
  pnpm typecheck # tsc --noEmit(strict)
279
- pnpm test # 测试套件(314 项:169 冒烟 + 46 安装器 + 11 运维 + 35 herdr + 33 发现 + 20 e2e)
279
+ pnpm test # 测试套件(446 项:286 冒烟 + 46 安装器 + 11 运维 + 35 herdr + 33 发现 + 35 e2e)
280
280
  npm run build:admin # admin/ 工作区(用 npm)→ 单文件 assets/admin.html
281
281
  pnpm run build # esbuild → lib/{cli,index,setup}.js(零依赖)
282
282
  pnpm pack # 构建 + npm pack(发布产物)
package/agents/SKILL.md CHANGED
@@ -38,11 +38,16 @@ Optional: call `bridge_register(peerId)` to claim a readable id
38
38
  task `timeout` if no terminal ack arrives in time. `ref` names the task this
39
39
  one answers; a task answering a task is a re-delegation, and that chain is
40
40
  capped at 5 hops.
41
- - `bridge_ack(ref, status, note?, progress?)` — acknowledge a task.
42
- Statuses: `accepted` | `working` | `rejected` | `done` | `failed`.
43
- `working` + `progress` (0–100) report intermediate state. Terminal
44
- statuses lock the task (later acks are recorded on the timeline but do
45
- not reopen it). The ack is auto-routed to the original sender of `ref`.
41
+ - `bridge_ack(ref, status, note?, progress?, artifacts?)` — acknowledge a task.
42
+ Statuses: `accepted` | `working` | `input-required` | `rejected` | `done` |
43
+ `failed`. `working` + `progress` (0–100) report intermediate state.
44
+ `input-required` is an interrupt: it asks the delegator for information
45
+ without ending the task (it answers with `bridge_task_input`; the task resumes
46
+ `working`). Terminal statuses lock the task (later acks are recorded on the
47
+ timeline but do not reopen it). `artifacts` (`[{name, mimeType?, text?|url?}]`)
48
+ is how you hand back what you produced — it is kept on the ledger, so
49
+ `bridge_task_status` shows it later. The ack is auto-routed to the original
50
+ sender of `ref`.
46
51
  - `bridge_task_status(ref)` — one task's ledger state, per-assignee state,
47
52
  and full ack timeline (also carries the A2A aliases `taskId` / `contextId` /
48
53
  `a2aState`).
@@ -59,10 +64,12 @@ Optional: call `bridge_register(peerId)` to claim a readable id
59
64
  - `bridge_discover(skill?, tag?, acceptsTasks?, idleOnly?)` — find a peer to hand
60
65
  work to. Returns matches with their current load (`queued` / `waiting` /
61
66
  `running`); by default only peers that accept tasks.
62
- - `bridge_wait(from?, ref?, threadId?, timeoutMs?, ack?, maxMessages?)` — long-poll for the next
63
- message (default 30 s; `ref` waits for that task's ack; `threadId` narrows
64
- to one dialog). Loop it to hold a real-time conversation. `ack: "manual"`
65
- LEASES the message instead of consuming it.
67
+ - `bridge_wait(from?, ref?, threadId?, timeoutMs?, ack?, maxMessages?, statuses?, terminalOnly?)` —
68
+ long-poll for the next message (default 30 s). `ref` waits for that task's
69
+ reply — an ack OR the chat an assignee answers with; `statuses` and
70
+ `terminalOnly` narrow that to the ack you actually want (see the workflows
71
+ below). `threadId` narrows to one dialog. Loop it to hold a real-time
72
+ conversation. `ack: "manual"` LEASES the message instead of consuming it.
66
73
  - `bridge_poll(from?, ack?)` — non-blocking drain of every queued message.
67
74
  - `bridge_commit(ids)` — confirm you have finished with leased messages. Until you
68
75
  do, they are handed out again when the lease expires (with `attempts` growing),
@@ -93,7 +100,10 @@ Optional: call `bridge_register(peerId)` to claim a readable id
93
100
  4. On receiving a `task` (content is `{prompt, context?, deliverable?}`):
94
101
  - `bridge_ack(ref, "accepted")` when you take it on
95
102
  - `bridge_ack(ref, "working", note?, progress?)` for long-running work
96
- - `bridge_ack(ref, "done"[, note])` when finished
103
+ - `bridge_ack(ref, "input-required", note?)` when you need information from
104
+ the delegator before you can continue (it answers with `bridge_task_input`)
105
+ - `bridge_ack(ref, "done"[, note, artifacts?])` when finished — `artifacts`
106
+ is where the result belongs
97
107
  - `bridge_ack(ref, "rejected")` to decline (with a reason)
98
108
  - `bridge_ack(ref, "failed")` when it could not be completed (with a note)
99
109
  5. Unsure whether the peer is online: check `bridge_peers()` first.
@@ -107,14 +117,23 @@ Follow the scenario directly (tool names stay as-is):
107
117
  say "got it, starting".
108
118
  - For work that takes a while: `bridge_ack(ref, "working", note, progress)`
109
119
  so the delegator can see it is moving.
110
- - When done: send the result and a delivery note back to the delegator
111
- (`bridge_chat` / `bridge_task`), then `bridge_ack(ref, "done", note)` so it
112
- can review.
120
+ - Need something before you can finish: `bridge_ack(ref, "input-required",
121
+ note)` — the task waits, the delegator answers with `bridge_task_input`, and
122
+ your work resumes.
123
+ - When done: `bridge_ack(ref, "done", note, artifacts)` — put the result in
124
+ `artifacts` (`[{name, text}]`, or `url` for a file you left on disk) so it is
125
+ recorded on the ledger the delegator reads with `bridge_task_status`. Add a
126
+ `bridge_chat { ref }` when the delegator should also see the result as a
127
+ message in its mailbox.
113
128
  - If you can't do it: `bridge_ack(ref, "rejected")` with the reason.
114
129
 
115
130
  **2. You delegate to someone else (wait vs don't-wait)**
116
- - Wait for delivery: after `bridge_task`, loop `bridge_wait({ref})` until the
117
- terminal ack arrives, then take the result over.
131
+ - Wait for the outcome: after `bridge_task`, loop
132
+ `bridge_wait({ref, terminalOnly: true})` until the terminal ack arrives, then
133
+ take the result over. Without `terminalOnly` a `ref` wait resolves on the
134
+ FIRST reply — an `accepted` or `working` beat, or the chat the assignee answers
135
+ with — so you would take over before the work is done. `statuses` is the same
136
+ knob spelled out (`["done"]`, `["rejected", "failed"]`, …).
118
137
  - Don't wait: send it and move on; the peer sends the result back when done —
119
138
  collect it later with `bridge_poll()` / `bridge_wait()` /
120
139
  `bridge_history()` (messages queue while you are away).
@@ -137,8 +156,11 @@ Follow the scenario directly (tool names stay as-is):
137
156
  means nothing arrived — try again.
138
157
  - Cadence: use 10–30 s short polls when the peer is active; check
139
158
  `bridge_peers()` when unsure.
140
- - Task terminal states (`done`/`failed`/`rejected`/`timeout`) cannot be
141
- reopened; start a new task instead of re-acking.
159
+ - Task terminal states (`done`/`failed`/`rejected`/`timeout`/`canceled`) cannot be
160
+ reopened; start a new task instead of re-acking. `terminalOnly: true` on a
161
+ `bridge_wait {ref}` resolves on the terminal ack (or the cancel message) —
162
+ the outcome, not "it started". An SLA `timeout` produces no ack at all, so it
163
+ never resolves a wait: read the `ref` snapshot a timed-out wait returns.
142
164
  - **Reply chains are counted, not enforced — nothing is ever refused.**
143
165
  Every message carrying `ref` sits one hop deeper than the message it points at.
144
166
  A plain conversation (chat / ack replies) counts up to **50** hops; a **task
@@ -154,6 +176,11 @@ Follow the scenario directly (tool names stay as-is):
154
176
  your row. When you are waiting you may also receive a `notice` whose `from` is
155
177
  the reserved id `hub` — `bridge_wait { from: "hub" }` subscribes to exactly
156
178
  those. `all` and `hub` are reserved: you cannot register or rename into them.
179
+ A `from` filter never hides a hub notice either: `bridge_wait { from: <assignee> }`
180
+ still receives one. When a **task you sent** is dropped on the
181
+ way (rate, overflow, expiry, dead letter) you get exactly one of these notices
182
+ naming the task; the task stays open on purpose, because a dead letter can
183
+ still be revived with `bridge_nack`.
157
184
  - **Need at-least-once instead of best-effort?** Take messages with
158
185
  `bridge_wait { ack: "manual" }` (or `bridge_poll { ack: "manual" }`) and call
159
186
  `bridge_commit` once you have really handled them. Uncommitted messages come