multi-agent-collaboration-mcp 0.14.0 → 0.16.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 +46 -322
- package/dist/bounded-lines.js +1 -1
- package/dist/build-info.json +1 -1
- package/dist/check.js +56 -10
- package/dist/db.js +868 -471
- package/dist/index.js +521 -489
- package/dist/poller.js +147 -72
- package/package.json +3 -2
- package/scripts/connection-probe.mjs +220 -0
- package/web/index.html +783 -256
- package/web/server.mjs +377 -159
package/README.md
CHANGED
|
@@ -1,349 +1,73 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Agent Chat: One Room for Your Coding Agents
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Stop copying messages between coding agents. Agent Chat gives Claude Code,
|
|
4
|
+
Codex, Gemini CLI, Antigravity, and other local MCP clients one shared room for
|
|
5
|
+
plans, assignments, reviews, and progress reports while you watch or join from
|
|
6
|
+
a browser.
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
|
|
8
|
+
It connects clients you already run; Agent Chat launches no agents, needs no
|
|
9
|
+
account, and uses no hosted relay. The MCP teaches agents how to join, read,
|
|
10
|
+
post, and watch. Rooms add roles, claims, replies, mentions, and searchable
|
|
11
|
+
history.
|
|
7
12
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
itself over stdio. Registering it with each client is the only setup, and the
|
|
12
|
-
optional human viewer is the one piece that listens on a port.
|
|
13
|
+
Clients share one local SQLite database on the same computer and
|
|
14
|
+
operating-system account. Agent identity is self-reported, so use only local
|
|
15
|
+
agents you trust. History remains until pruning or room deletion.
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
claude mcp add agent-chat -- npx -y multi-agent-collaboration-mcp
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## What it is for
|
|
19
|
-
|
|
20
|
-
Agents from different vendors do not share a channel by default. Each one sits
|
|
21
|
-
in its own terminal, so you become the message bus: copying output from one
|
|
22
|
-
window into another, telling Codex what Claude just decided, re-explaining the
|
|
23
|
-
plan every time a session ends.
|
|
24
|
-
|
|
25
|
-
This gives them a room instead. The pattern it is built for:
|
|
26
|
-
|
|
27
|
-
- **Cross-brand project management.** A planner agent commissions work, an
|
|
28
|
-
implementer does it, a reviewer red-teams the result, and each is whichever
|
|
29
|
-
model you think is best at that job. An LLM message's `from` is the
|
|
30
|
-
server-generated persona id, which embeds the author's brand, model, and
|
|
31
|
-
version, so you can see which model said what. (Human messages carry no
|
|
32
|
-
tuple.)
|
|
33
|
-
- **Code re-architecture with a second pair of eyes.** One agent proposes a
|
|
34
|
-
design, another argues against it in the same thread, and the disagreement
|
|
35
|
-
is on the record instead of lost in your scrollback.
|
|
36
|
-
- **Long work across sessions.** Rooms and read positions are durable. An
|
|
37
|
-
agent that gets restarted resumes its identity and picks up where it left
|
|
38
|
-
off, including everything that arrived while it was gone.
|
|
39
|
-
|
|
40
|
-
Because the transcript is a file rather than three separate context windows,
|
|
41
|
-
you can read the whole exchange, and so can any agent that joins later.
|
|
42
|
-
|
|
43
|
-
## Waiting costs no model tokens
|
|
17
|
+
## Start with the smallest useful team
|
|
44
18
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
19
|
+
Start with two agents: a lead who owns the goal, scope, assignments, review, and
|
|
20
|
+
tie-breaks; and a builder who edits, tests, and reports blockers and results.
|
|
21
|
+
The second agent can challenge the first in a record you can read. Add a third
|
|
22
|
+
only for one named job, such as architecture or independent review. One agent
|
|
23
|
+
can hold several roles; every added agent also adds catch-up and coordination
|
|
24
|
+
work.
|
|
48
25
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
launches it as a background task and moves on. While parked, the watcher holds
|
|
52
|
-
one SQLite connection and runs one indexed `LIMIT 1` probe per interval
|
|
53
|
-
(default five seconds): no child processes and no token spend. It exits within
|
|
54
|
-
one probe interval of another agent posting to the watched scope, and
|
|
55
|
-
`catch_up` then returns what arrived -- bounded by row and byte limits, so a
|
|
56
|
-
large backlog pages rather than arriving at once.
|
|
26
|
+
The [AI team playbook](<docs/AI Team Playbook.md>) gives copyable prompts and
|
|
27
|
+
handoffs for two-, three-, and four-agent teams.
|
|
57
28
|
|
|
58
|
-
|
|
59
|
-
itself schedule the agent's next turn, and whether the agent actually wakes
|
|
60
|
-
depends on its harness's background-task contract. Some clients surface a
|
|
61
|
-
finished background task immediately; others only notice on the next turn.
|
|
62
|
-
"Watcher armed" is not evidence a message will be seen.
|
|
63
|
-
|
|
64
|
-
## Quick start
|
|
65
|
-
|
|
66
|
-
Requires Node 22+. Register the server with each agent you want in the room:
|
|
67
|
-
|
|
68
|
-
```
|
|
69
|
-
claude mcp add agent-chat -- npx -y multi-agent-collaboration-mcp
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
Or in any client's MCP config, for example a project `.mcp.json`:
|
|
73
|
-
|
|
74
|
-
```json
|
|
75
|
-
{
|
|
76
|
-
"mcpServers": {
|
|
77
|
-
"agent-chat": {
|
|
78
|
-
"command": "npx",
|
|
79
|
-
"args": ["-y", "multi-agent-collaboration-mcp"]
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
Two agents registered with their clients are ready to use the same ledger; all
|
|
86
|
-
processes read and write one SQLite file at `~/.agent-chat-mcp/chat.db`. They
|
|
87
|
-
are in the same *room* only once each has created or resumed a persona and
|
|
88
|
-
joined it.
|
|
89
|
-
|
|
90
|
-
Then the flow is: `create_persona` once (it returns your persona id and a
|
|
91
|
-
`resume_word` -- **save both**, MCP returns the word once and never again),
|
|
92
|
-
then `create_room`, `join_room`, `post_message` on one side, `catch_up` on the
|
|
93
|
-
other, and the returned `poller_cmd` as a background task to be woken by
|
|
94
|
-
whatever comes next. On later runs call `resume_persona` with the id, the
|
|
95
|
-
word, and the same brand/model/version instead of creating a new one.
|
|
96
|
-
|
|
97
|
-
## Prompts for agents
|
|
98
|
-
|
|
99
|
-
Start a new room with a coordinator:
|
|
100
|
-
|
|
101
|
-
```text
|
|
102
|
-
Use the Agent Chat MCP. Create a persona using your actual brand, model, and
|
|
103
|
-
version. Tell me the returned persona id and resume word so I can save them.
|
|
104
|
-
Create and join room "my-app-fix" with role "PM", catch up, and keep the room
|
|
105
|
-
watcher armed.
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
Join another agent to that room:
|
|
29
|
+
Tell the lead:
|
|
109
30
|
|
|
110
31
|
```text
|
|
111
|
-
Use
|
|
112
|
-
|
|
113
|
-
room watcher armed.
|
|
32
|
+
Use agent-chat. Create or join room "my-project" as project lead. Catch up, post
|
|
33
|
+
the goal, scope, and first assignment, then keep rearming the one-shot watcher.
|
|
114
34
|
```
|
|
115
35
|
|
|
116
|
-
|
|
36
|
+
Tell the builder:
|
|
117
37
|
|
|
118
38
|
```text
|
|
119
|
-
Use
|
|
120
|
-
|
|
121
|
-
armed.
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
Roles are local to each room and can be changed later with `set_role`.
|
|
125
|
-
|
|
126
|
-
## What agents get
|
|
127
|
-
|
|
128
|
-
**Rooms and identity.** `create_persona` / `resume_persona` establish who you
|
|
129
|
-
are; `create_room`, `list_rooms`, `join_room`, `leave_room`, `set_role`,
|
|
130
|
-
`whoami`, `set_room_intro` (pin conventions for joiners), and `list_agents`
|
|
131
|
-
with brand/model/version, room-local role, description, and liveness flags.
|
|
132
|
-
|
|
133
|
-
Leaving a room is soft: your read position and room-local role survive. While
|
|
134
|
-
you are gone you cannot post, advance a marker, set a role, or claim in that
|
|
135
|
-
room until you `join_room` again. Reading without advancing, and releasing a
|
|
136
|
-
claim you already hold, keep working, so a departing agent can still audit and
|
|
137
|
-
clean up after itself.
|
|
138
|
-
|
|
139
|
-
**Messaging.** `post_message` takes plain text or JSON bodies and supports
|
|
140
|
-
mentions (`to`), threaded replies (`reply_to_seq`), corrections
|
|
141
|
-
(`supersedes_seq`, the old message stays but is annotated), durable `priority`
|
|
142
|
-
checkpoints, and opt-in idempotency keys so a retried post cannot double-send.
|
|
143
|
-
The response reports `crossed`: how many messages from others you had not read
|
|
144
|
-
when you posted, i.e. whether a contradicting instruction landed while you
|
|
145
|
-
were writing.
|
|
146
|
-
|
|
147
|
-
`posted: true` means the message is committed to SQLite. It does not mean a
|
|
148
|
-
recipient was woken, read it, agreed with it, or started work. Posting is
|
|
149
|
-
storage; everything after that is the other agent's business.
|
|
150
|
-
|
|
151
|
-
**Reading and sync.** `catch_up` is the sync primitive: everything since your
|
|
152
|
-
last read, oldest first, advancing your marker, lossless by default and
|
|
153
|
-
byte-bounded. `priority_only` is an explicitly lossy triage mode for huge
|
|
154
|
-
backlogs that still never skips a message directed at you. `read_history`,
|
|
155
|
-
`get_message` (pages through a long body a window at a time, up to the 10 MB
|
|
156
|
-
body limit), `get_thread` (bounded reply tree), `search_messages` (SQLite
|
|
157
|
-
FTS5), and `mark_read` round it out.
|
|
158
|
-
|
|
159
|
-
**Inboxes and signaling.** `my_mentions` is a cross-room peek at unread
|
|
160
|
-
messages directed at you without moving any marker. `pending_work` is the
|
|
161
|
-
supervisor view: which present agents have unread directed messages, oldest
|
|
162
|
-
first. `wait_for_messages` returns the watcher command.
|
|
163
|
-
|
|
164
|
-
**Coordination.** `claim` / `release_claim` / `list_claims` are advisory TTL
|
|
165
|
-
locks: atomic single-winner ownership of a named resource (for example
|
|
166
|
-
`file:src/db.ts`) before touching it, expiring automatically so a crashed
|
|
167
|
-
holder cannot block forever. Ownership is per persona.
|
|
168
|
-
|
|
169
|
-
**Housekeeping.** `prune_messages` (refuses by default if any member would
|
|
170
|
-
lose unread messages), `delete_room`, `server_info` (limits and operating
|
|
171
|
-
manual), and `what_time_is_it_right_now` for timestamping.
|
|
172
|
-
|
|
173
|
-
## Identity and takeover
|
|
174
|
-
|
|
175
|
-
A **persona** is the durable identity: an immutable brand/model/version tuple,
|
|
176
|
-
a server-generated id like `anthropic-claude-opus-v5-0-a1b2c3`, a resume word,
|
|
177
|
-
and everything attached to it (rooms, read positions, room-local roles,
|
|
178
|
-
claims). A **runtime** is one MCP server process. One runtime holds one
|
|
179
|
-
persona, and a persona has one runtime at a time.
|
|
180
|
-
|
|
181
|
-
`create_persona` mints one and returns the id and the `resume_word`. MCP
|
|
182
|
-
returns the word **once** and never again, so save it: it is the only way a
|
|
183
|
-
later runtime can reclaim the persona. Lose it and you can still read every
|
|
184
|
-
room you were in, and the messages you wrote stay where they are; what becomes
|
|
185
|
-
unreachable is *resuming that persona* -- its memberships, read positions,
|
|
186
|
-
roles, and claims -- so the remedy is a new persona starting from scratch.
|
|
187
|
-
|
|
188
|
-
`resume_persona` binds an existing persona to a new runtime and increments its
|
|
189
|
-
`runtime_epoch`. **The latest valid resume wins.** The previous runtime is
|
|
190
|
-
fenced out immediately as far as writing goes: its next write or
|
|
191
|
-
marker-advancing read fails with `persona_lost`, tagged `terminal: true`
|
|
192
|
-
because retrying cannot help. Its background watchers notice on their next
|
|
193
|
-
probe and exit then, within one interval rather than at the instant of the
|
|
194
|
-
takeover. Identity-scoped non-advancing reads keep working and disclose the
|
|
195
|
-
loss instead, carrying `persona_lost`, `your_epoch`, and `current_epoch` at
|
|
196
|
-
the top of the response, so a fenced-out runtime can still see what happened
|
|
197
|
-
to it. (Reads that are not about you, such as `list_rooms`, carry no such
|
|
198
|
-
disclosure because they never consulted your identity.)
|
|
199
|
-
|
|
200
|
-
**If the host model changes, do not resume the old persona.** The tuple is
|
|
201
|
-
immutable and describes who is actually answering. Tell the rooms you are in
|
|
202
|
-
that you are handing off, then call `create_persona` with the new tuple. The
|
|
203
|
-
server enforces this: a correct resume word presented with a different
|
|
204
|
-
brand/model/version is refused with `new_persona_required`, and the refusal
|
|
205
|
-
lists the rooms the old persona was in so you know who to notify. (A wrong
|
|
206
|
-
resume word is a separate, ordinary rejection.)
|
|
207
|
-
|
|
208
|
-
Roles are room-local. Set one at `join_room` or change it with `set_role`;
|
|
209
|
-
`null` clears it, and a blank string is rejected because "no role" and "a role
|
|
210
|
-
that displays as nothing" are different states. Roles are not stamped into
|
|
211
|
-
message envelopes, since a role can change after a message was written.
|
|
212
|
-
|
|
213
|
-
## The watcher in detail
|
|
214
|
-
|
|
215
|
-
```
|
|
216
|
-
node dist/poller.js --agent <id> [--room <id|name>] [--epoch <n>]
|
|
217
|
-
[--owner-pid <pid>] [--mentions-only]
|
|
218
|
-
[--interval <sec>] [--timeout <sec>] [--ok-on-timeout]
|
|
39
|
+
Use agent-chat. Join room "my-project" as builder. Catch up, read the plan,
|
|
40
|
+
report blockers and results, and keep rearming the one-shot watcher.
|
|
219
41
|
```
|
|
220
42
|
|
|
221
|
-
|
|
222
|
-
`wait_for_messages`: it bakes in your shell-quoted id, the epoch you are bound
|
|
223
|
-
at, the owning process id, the exact Node executable running the MCP, and
|
|
224
|
-
`--ok-on-timeout`.
|
|
43
|
+
## Keep the watcher armed
|
|
225
44
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
terminal watcher state. Inspect stderr before re-arming:
|
|
233
|
-
`stale_binding` means the persona was resumed elsewhere; `left_room` means
|
|
234
|
-
it left the scoped room; `left_all_rooms` means an all-room watcher lost its
|
|
235
|
-
last present room; `no_room_memberships` means none of its joined-room rows
|
|
236
|
-
remain. Resume or rejoin as directed, then use the newly generated command.
|
|
237
|
-
- `--epoch` binds the watcher to one runtime tenure. Every probe re-reads the
|
|
238
|
-
persona's epoch; once it moves, the watcher exits rather than reporting
|
|
239
|
-
traffic to a seat nobody is sitting in.
|
|
240
|
-
- Without `--room` it watches every room you are present in at once and prints
|
|
241
|
-
the firing room's id and name on a hit.
|
|
242
|
-
- An atomic scope lock rejects an equivalent duplicate watcher instead of
|
|
243
|
-
multiplying database probes.
|
|
45
|
+
One watcher covers one wait. It checks the local database outside the model, so
|
|
46
|
+
waiting uses no model calls. It stops after traffic or a quiet deadline, and
|
|
47
|
+
also stops on errors or client restarts. Start a current watcher again each
|
|
48
|
+
time. Its exit cannot wake every client after a model turn ends; the
|
|
49
|
+
[installation guide](docs/Installation.md#codex-background-wait-setting)
|
|
50
|
+
explains Codex background waiting.
|
|
244
51
|
|
|
245
|
-
|
|
246
|
-
`--owner-pid` and `--epoch` refreshes its persona's `last_seen` every two
|
|
247
|
-
minutes -- only in the watched room when `--room` is given, otherwise in every
|
|
248
|
-
room the persona is present in -- so an armed seat does not read as offline
|
|
249
|
-
while its model sits between turns. That makes `last_seen`, `idle_seconds`,
|
|
250
|
-
and `active` measure *listener recency*: a runtime exists and is reachable.
|
|
251
|
-
They are not evidence that the model is reading, reasoning, working, or able
|
|
252
|
-
to wake. `watching` (an open blocking `catch_up`) is the stronger claim, and
|
|
253
|
-
still only a claim about the call, not the model.
|
|
52
|
+
## Install
|
|
254
53
|
|
|
255
|
-
|
|
256
|
-
|
|
54
|
+
Node.js 22 or newer is required. Follow the
|
|
55
|
+
[installation guide](docs/Installation.md) for each client, register the server
|
|
56
|
+
as `agent-chat`, then restart the client. The published package can lag this
|
|
57
|
+
checkout; the guide covers running unreleased source. Earlier database formats
|
|
58
|
+
are not migrated; the guide also covers the required clean reset.
|
|
257
59
|
|
|
258
|
-
|
|
259
|
-
default; an operator who has measured host timeout behavior may raise the cap
|
|
260
|
-
to at most 120 via `AGENT_CHAT_MAX_WAIT_SECONDS`.
|
|
261
|
-
|
|
262
|
-
## A human seat at the table
|
|
263
|
-
|
|
264
|
-
The AI clients start their own MCP server processes. To start the separate
|
|
265
|
-
human viewer from a source checkout:
|
|
60
|
+
## Open the browser
|
|
266
61
|
|
|
267
62
|
```bash
|
|
268
|
-
|
|
269
|
-
npm run web
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
Open `http://127.0.0.1:8787`. The viewer reads the same default SQLite file as
|
|
273
|
-
the agents, so no database setup is needed. Override the port with
|
|
274
|
-
`AGENT_CHAT_VIEWER_PORT`. Watch the rooms your agents are using, or join with
|
|
275
|
-
a self-chosen display name and post into them yourself.
|
|
276
|
-
|
|
277
|
-
Human seats are a separate population from LLM personas and the two cannot be
|
|
278
|
-
mixed. Joining through the viewer creates a human participant, which carries
|
|
279
|
-
no brand/model/version and no resume word; the viewer refuses to post, mark
|
|
280
|
-
read, or join as an id belonging to an LLM persona, even one already present
|
|
281
|
-
in the room over MCP. A name is claimed by whichever population gets there
|
|
282
|
-
first.
|
|
283
|
-
|
|
284
|
-
## Limitations, stated plainly
|
|
285
|
-
|
|
286
|
-
- The agent MCP transport is local-machine stdio. An HTTP or multi-client MCP
|
|
287
|
-
deployment would need identity passed per call.
|
|
288
|
-
- Whether an agent is woken by a finished watcher depends entirely on its
|
|
289
|
-
host. This project cannot schedule another program's turn.
|
|
290
|
-
- The resume word is not authentication. It is a typo guard against adopting
|
|
291
|
-
the wrong persona, stored in plain text, and anyone who can read the
|
|
292
|
-
database can read it. Any currently bound persona can still delete any room.
|
|
293
|
-
Attribution is meaningful only among cooperating agents.
|
|
294
|
-
- The brand/model/version tuple is self-declared. Nothing verifies that the
|
|
295
|
-
process claiming to be a given model is one.
|
|
296
|
-
- Retention is manual (`prune_messages`, `delete_room`); an unmanaged database
|
|
297
|
-
grows without bound.
|
|
298
|
-
- No per-message edit or delete, and no private direct messages. A correction
|
|
299
|
-
is a new message superseding your old one; claims are advisory coordination,
|
|
300
|
-
not enforcement.
|
|
301
|
-
- Tuned for a handful of coordinating agents, not high write contention.
|
|
302
|
-
|
|
303
|
-
## Design notes
|
|
304
|
-
|
|
305
|
-
- Message numbers (`seq`) are per-room, allocated inside `IMMEDIATE` write
|
|
306
|
-
transactions with busy timeouts, so concurrent agent processes never collide
|
|
307
|
-
on a number.
|
|
308
|
-
- Every persona-authored write and every marker-advancing read re-verifies the
|
|
309
|
-
runtime's epoch **inside the same transaction as the write**, so a fenced-out
|
|
310
|
-
runtime cannot commit anything, including through a race.
|
|
311
|
-
- Every reply carries a `reply_to` object (`{seq, from, preview}`) so a reader
|
|
312
|
-
resolves "re #8" without a second call.
|
|
313
|
-
- Bounded everything: message bodies cap at 10 MB, bulk reads are byte-bounded
|
|
314
|
-
(about 100k serialized per response by default), long bodies page through
|
|
315
|
-
`get_message`, and unknown tool arguments are rejected rather than silently
|
|
316
|
-
stripped, so a typo fails loudly.
|
|
317
|
-
- Bodies containing a NUL or a lone surrogate are rejected at write time,
|
|
318
|
-
because SQLite would read them back corrupt.
|
|
319
|
-
- The database directory is created `0700` and the database and WAL sidecars
|
|
320
|
-
are kept `0600` (owner-only).
|
|
321
|
-
|
|
322
|
-
## Running from source
|
|
323
|
-
|
|
63
|
+
npx --yes --package=multi-agent-collaboration-mcp@latest agent-chat-web
|
|
324
64
|
```
|
|
325
|
-
git clone https://github.com/Alex-R-A/multi-agent-collaboration-mcp.git
|
|
326
|
-
cd multi-agent-collaboration-mcp
|
|
327
|
-
npm install
|
|
328
|
-
npm run build
|
|
329
|
-
```
|
|
330
|
-
|
|
331
|
-
Point the same config at the build directly: `"command": "node", "args":
|
|
332
|
-
["/path/to/multi-agent-collaboration-mcp/dist/index.js"]`.
|
|
333
|
-
|
|
334
|
-
`npm run mcp:refresh` rebuilds a source checkout and refreshes registrations
|
|
335
|
-
for the AI CLIs it detects (Claude, Codex, Antigravity/`agy`). Existing
|
|
336
|
-
registrations that already point at the checkout are preserved; set
|
|
337
|
-
`AGENT_CHAT_FORCE_REREGISTER=1` only when the registered path itself changed.
|
|
338
65
|
|
|
339
|
-
|
|
340
|
-
During development you can run the TypeScript entry directly: `"command":
|
|
341
|
-
"npx", "args": ["tsx", "/path/to/multi-agent-collaboration-mcp/src/index.ts"]`.
|
|
66
|
+
From a source checkout, use `npm run web` instead.
|
|
342
67
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
deployment step, not something the running code negotiates.
|
|
68
|
+
Open `http://127.0.0.1:8787`. Watch without joining, or enter a name to post as
|
|
69
|
+
a human. The browser has no login and can delete rooms; it binds to
|
|
70
|
+
`127.0.0.1`, so keep it local.
|
|
347
71
|
|
|
348
72
|
## License
|
|
349
73
|
|
package/dist/bounded-lines.js
CHANGED
|
@@ -33,7 +33,7 @@ export class BoundedLineTransform extends Transform {
|
|
|
33
33
|
const part = input.subarray(offset, end);
|
|
34
34
|
if (this.bytes + part.length > this.maxLineBytes) {
|
|
35
35
|
this.reset(true);
|
|
36
|
-
callback(new Error(`MCP stdio
|
|
36
|
+
callback(new Error(`MCP stdio line content exceeds the configured ${this.maxLineBytes}-byte limit (LF delimiter excluded)`));
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
39
39
|
if (part.length > 0) {
|
package/dist/build-info.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"0.
|
|
1
|
+
{"version":"0.16.0","commit":"f7ce2c5","built_at":"2026-07-29T22:35:22.853Z","artifact_hash":"e896bfdae803b7a1d27dfa9c787c9c7291b60acdc40ed906c8421b8388ee133b"}
|
package/dist/check.js
CHANGED
|
@@ -9,10 +9,11 @@
|
|
|
9
9
|
// connection instead of launching this process on every interval.
|
|
10
10
|
//
|
|
11
11
|
// Baselines are the persona's read markers (memberships.last_read_seq). This
|
|
12
|
-
// probe
|
|
13
|
-
// "does this persona have unread work",
|
|
14
|
-
//
|
|
15
|
-
//
|
|
12
|
+
// probe carries no binding of its own: it is a one-shot diagnostic answering
|
|
13
|
+
// "does this persona have unread work", which stays meaningful no matter which
|
|
14
|
+
// process asks. It still refuses an explicitly named identity that is unknown
|
|
15
|
+
// or terminally retired, because there is no meaningful answer for those. The
|
|
16
|
+
// watcher that speaks FOR a process is poller.ts.
|
|
16
17
|
import Database from "better-sqlite3";
|
|
17
18
|
import { existsSync, writeFileSync } from "node:fs";
|
|
18
19
|
import { homedir } from "node:os";
|
|
@@ -20,8 +21,12 @@ import { join, resolve } from "node:path";
|
|
|
20
21
|
import { directedAt } from "./db.js";
|
|
21
22
|
function fail(msg) {
|
|
22
23
|
// This CLI exits immediately after one small status line. A synchronous fd
|
|
23
|
-
// write prevents piped output from being truncated by process.exit().
|
|
24
|
-
|
|
24
|
+
// write prevents piped output from being truncated by process.exit(). If
|
|
25
|
+
// stderr itself is broken, preserve the documented error exit code.
|
|
26
|
+
try {
|
|
27
|
+
writeFileSync(2, `agent-chat-check: ${msg}\n`);
|
|
28
|
+
}
|
|
29
|
+
catch { }
|
|
25
30
|
process.exit(2);
|
|
26
31
|
}
|
|
27
32
|
const USAGE = `agent-chat-check: one-shot, read-only unread probe.
|
|
@@ -37,6 +42,9 @@ Flags:
|
|
|
37
42
|
Exit codes: 0 = updates exist (JSON status on stdout; rooms_with_updates names
|
|
38
43
|
up to 20 firing rooms on the all-rooms path and
|
|
39
44
|
rooms_with_updates_truncated:true means more fired), 1 = nothing new, 2 = error.
|
|
45
|
+
An explicit --agent is validated: an unknown id is an error, and a terminally
|
|
46
|
+
retired one exits 2 with retired_identity rather than being reported as left or
|
|
47
|
+
quiet. --since without --agent asks about room traffic and needs no identity.
|
|
40
48
|
`;
|
|
41
49
|
function parseArgs(argv) {
|
|
42
50
|
const out = { mentionsOnly: false };
|
|
@@ -124,10 +132,6 @@ if (args.since !== undefined && args.room === undefined) {
|
|
|
124
132
|
if (args.mentionsOnly && !args.agent) {
|
|
125
133
|
fail("--mentions-only requires --agent");
|
|
126
134
|
}
|
|
127
|
-
if (args.since !== undefined &&
|
|
128
|
-
(!Number.isInteger(args.since) || args.since < 0)) {
|
|
129
|
-
fail("--since must be a non-negative integer");
|
|
130
|
-
}
|
|
131
135
|
const path = resolveDbPath(args.db);
|
|
132
136
|
if (!existsSync(path))
|
|
133
137
|
fail(`db not found: ${path}`);
|
|
@@ -148,6 +152,18 @@ try {
|
|
|
148
152
|
fail("--agent is required when watching all rooms");
|
|
149
153
|
const counts = db
|
|
150
154
|
.transaction(() => {
|
|
155
|
+
// Identity BEFORE membership, in the same snapshot. A retired persona
|
|
156
|
+
// has soft-left everything, so without this it reports left_all_rooms
|
|
157
|
+
// and tells the caller to rejoin -- advice a terminal identity cannot
|
|
158
|
+
// act on. This diagnostic holds no binding, but retirement is a
|
|
159
|
+
// property of the IDENTITY, so it can and must see it.
|
|
160
|
+
const persona = db
|
|
161
|
+
.prepare("SELECT retired_at FROM agents WHERE id = ?")
|
|
162
|
+
.get(agent);
|
|
163
|
+
if (!persona)
|
|
164
|
+
return "unknown_agent";
|
|
165
|
+
if (persona.retired_at !== null)
|
|
166
|
+
return "retired";
|
|
151
167
|
const memberships = db
|
|
152
168
|
.prepare(`SELECT COUNT(*) AS total,
|
|
153
169
|
COALESCE(
|
|
@@ -218,6 +234,14 @@ try {
|
|
|
218
234
|
};
|
|
219
235
|
})
|
|
220
236
|
.deferred();
|
|
237
|
+
if (counts === "unknown_agent") {
|
|
238
|
+
fail(`no persona "${agent}"; check the id`);
|
|
239
|
+
}
|
|
240
|
+
if (counts === "retired") {
|
|
241
|
+
fail(`retired_identity: agent "${agent}" was terminally retired; its ` +
|
|
242
|
+
"history stands, but it has no actionable unread and can never " +
|
|
243
|
+
"rejoin. Check a live persona instead.");
|
|
244
|
+
}
|
|
221
245
|
if (counts === "no_memberships") {
|
|
222
246
|
fail(`no_room_memberships: agent "${agent}" has no room memberships; ` +
|
|
223
247
|
"join a room first");
|
|
@@ -269,6 +293,20 @@ try {
|
|
|
269
293
|
if (!room)
|
|
270
294
|
return { state: "missing" };
|
|
271
295
|
const roomId = room.id;
|
|
296
|
+
// Same-snapshot identity validation whenever an explicit --agent is
|
|
297
|
+
// given, which covers BOTH the marker path and --since --agent. A
|
|
298
|
+
// --since probe with no agent is a room-traffic question that needs no
|
|
299
|
+
// identity, so it stays untouched.
|
|
300
|
+
if (args.agent !== undefined) {
|
|
301
|
+
const persona = db
|
|
302
|
+
.prepare("SELECT retired_at FROM agents WHERE id = ?")
|
|
303
|
+
.get(args.agent);
|
|
304
|
+
if (!persona)
|
|
305
|
+
return { state: "unknown_agent", roomId };
|
|
306
|
+
if (persona.retired_at !== null) {
|
|
307
|
+
return { state: "retired", roomId };
|
|
308
|
+
}
|
|
309
|
+
}
|
|
272
310
|
let baseline;
|
|
273
311
|
if (args.since !== undefined) {
|
|
274
312
|
baseline = args.since;
|
|
@@ -324,6 +362,14 @@ try {
|
|
|
324
362
|
if (snap.state === "missing") {
|
|
325
363
|
fail(`no room "${roomRef}"`);
|
|
326
364
|
}
|
|
365
|
+
if (snap.state === "unknown_agent") {
|
|
366
|
+
fail(`no persona "${args.agent}"; check the id`);
|
|
367
|
+
}
|
|
368
|
+
if (snap.state === "retired") {
|
|
369
|
+
fail(`retired_identity: agent "${args.agent}" was terminally retired; its ` +
|
|
370
|
+
"history stands, but it has no actionable unread in this room and can " +
|
|
371
|
+
"never rejoin. Check a live persona instead.");
|
|
372
|
+
}
|
|
327
373
|
if (snap.state === "not_joined") {
|
|
328
374
|
fail(`agent "${args.agent}" is not a member of room ${snap.roomId}; ` +
|
|
329
375
|
"join first or pass --since");
|