@mrciphersmith/roomyx 0.10.2 → 0.10.3
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/CHANGELOG.md +29 -0
- package/package.json +1 -1
- package/src/log/store.ts +62 -3
- package/src/log/types.ts +21 -0
- package/src/server/index.ts +31 -0
- package/src/server/tools/get-agent-delta.ts +16 -0
package/CHANGELOG.md
CHANGED
|
@@ -13,6 +13,35 @@ patch and never a minor. The rule, the reason, and an audit of the four of seven
|
|
|
13
13
|
releases that followed it are in
|
|
14
14
|
[`docs/roomyx/versioning.md`](docs/roomyx/versioning.md) and decision D-13.
|
|
15
15
|
|
|
16
|
+
## [0.10.3] — 2026-09-10
|
|
17
|
+
|
|
18
|
+
A patch. A new read tool, and no existing response changes.
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
|
|
22
|
+
- **`room.get_delta_for(agent_id, since_seq?)`** — what a participant has not
|
|
23
|
+
seen, by the convention the dispatcher used to apply by hand on every turn:
|
|
24
|
+
everything after that participant's own last message, excluding its own. The
|
|
25
|
+
rule is not new — `get_agent_detail` has always reported `lastSeenSeq` as the
|
|
26
|
+
maximum of an agent's own `seq` — but the cursor map and the filter were being
|
|
27
|
+
re-derived in a language model's context once per iteration. The answer also
|
|
28
|
+
reports `since_seq` and `cursor_from` (`agent-last-message` or `caller`), so an
|
|
29
|
+
empty delta means "nothing new" rather than "I passed the wrong cursor".
|
|
30
|
+
|
|
31
|
+
### Notes
|
|
32
|
+
|
|
33
|
+
- **It is a candidate delta, not a delivery record.** The server cannot see a
|
|
34
|
+
`SendMessage`: it knows a convention about the log and nothing else. The tool's
|
|
35
|
+
description says so, and a test asserts that wording **as a client receives
|
|
36
|
+
it** over the wire, because a string assertion in the tool's own unit test
|
|
37
|
+
cannot see what the wire says. A dispatcher may have failed to send a delta or
|
|
38
|
+
sent one twice, and no field here can tell.
|
|
39
|
+
- Its own messages are excluded at any cursor, including an explicit `0` — an
|
|
40
|
+
agent does not need to be told what it said.
|
|
41
|
+
- Stateless: the default cursor is derived from the log on every call. A cursor
|
|
42
|
+
the server *stored* would belong to one server instance, and the factory behind
|
|
43
|
+
`serve` runs once per session (the lesson `0.10.0` paid for).
|
|
44
|
+
|
|
16
45
|
## [0.10.2] — 2026-09-10
|
|
17
46
|
|
|
18
47
|
### Added
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrciphersmith/roomyx",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.3",
|
|
4
4
|
"description": "MCP server + terminal UI for startup-room: live room status, chat, per-agent modal, an installable room registry, and skill-sync.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
package/src/log/store.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import { messageLineSchema, stateLineSchema } from "./schema";
|
|
3
|
-
import type { AgentDetail, MessageEnvelope, RoomState, RosterEntry } from "./types";
|
|
3
|
+
import type { AgentDelta, AgentDetail, MessageEnvelope, RoomState, RosterEntry } from "./types";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* `JSON.parse`, with the one thing it never says: where.
|
|
@@ -83,6 +83,22 @@ export function getTranscript(messages: MessageEnvelope[], sinceSeq: number): Me
|
|
|
83
83
|
return messages.filter((m) => m.seq > sinceSeq);
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The agent's own last `seq`, or 0 when it has never spoken.
|
|
89
|
+
*
|
|
90
|
+
* Extracted because two functions now need this rule and it is a *rule*, not an
|
|
91
|
+
* expression: "what counts as the agent's own last message" is the convention
|
|
92
|
+
* both `get_agent_detail` and `getAgentDelta` publish, and computing it twice
|
|
93
|
+
* means a change to it has to be made twice — which is how the two would come to
|
|
94
|
+
* disagree about what a participant has seen, silently, since both answers look
|
|
95
|
+
* plausible on their own.
|
|
96
|
+
*/
|
|
97
|
+
function lastOwnSeq(messages: MessageEnvelope[], agentId: string): number {
|
|
98
|
+
const own = messages.filter((m) => m.from === agentId);
|
|
99
|
+
return own.length > 0 ? Math.max(...own.map((m) => m.seq)) : 0;
|
|
100
|
+
}
|
|
101
|
+
|
|
86
102
|
/** A single participant's messages and last-seen seq, or an explicit not-found result. */
|
|
87
103
|
export function getAgentDetail(
|
|
88
104
|
messages: MessageEnvelope[],
|
|
@@ -95,6 +111,49 @@ export function getAgentDetail(
|
|
|
95
111
|
}
|
|
96
112
|
|
|
97
113
|
const own = messages.filter((m) => m.from === agentId);
|
|
98
|
-
|
|
99
|
-
|
|
114
|
+
return { found: true, agent, messages: own, lastSeenSeq: lastOwnSeq(messages, agentId) };
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* The messages a participant has not seen, and the cursor that says so.
|
|
119
|
+
*
|
|
120
|
+
* This is the arithmetic the dispatcher re-derived in its own context on every
|
|
121
|
+
* turn — the phrase in the bundled skill is "everything since your last turn" —
|
|
122
|
+
* moved into the server that already knows how to compute it: `getAgentDetail`
|
|
123
|
+
* has always reported `lastSeenSeq` as the maximum of an agent's own `seq`.
|
|
124
|
+
*
|
|
125
|
+
* Two rules, and the second is the one that survives an explicit cursor:
|
|
126
|
+
*
|
|
127
|
+
* 1. The default cursor is that maximum, and the delta is `seq > cursor`.
|
|
128
|
+
* 2. Its own messages are excluded **at any cursor** — an agent does not need to
|
|
129
|
+
* be told what it said. With `sinceSeq: 0` this is the only rule doing work.
|
|
130
|
+
*
|
|
131
|
+
* Stateless on purpose. A cursor the server stored would belong to one server
|
|
132
|
+
* instance, and `serveMcpOverHttp` builds one per session (the lesson flow 005
|
|
133
|
+
* paid for); deriving it from the log on every call is what makes the answer
|
|
134
|
+
* shareable without any state at all.
|
|
135
|
+
*
|
|
136
|
+
* **What this is not:** a record of what was delivered. The convention is a
|
|
137
|
+
* good guess at what a participant has not seen, and a dispatcher may have
|
|
138
|
+
* failed to send a delta or sent one twice. `cursor_from` names which cursor was
|
|
139
|
+
* used so the guess is visible rather than implied.
|
|
140
|
+
*/
|
|
141
|
+
export function getAgentDelta(
|
|
142
|
+
messages: MessageEnvelope[],
|
|
143
|
+
roster: RosterEntry[],
|
|
144
|
+
agentId: string,
|
|
145
|
+
sinceSeq?: number,
|
|
146
|
+
): AgentDelta {
|
|
147
|
+
const agent = roster.find((r) => r.id === agentId);
|
|
148
|
+
if (!agent) return { found: false };
|
|
149
|
+
|
|
150
|
+
const since = sinceSeq ?? lastOwnSeq(messages, agentId);
|
|
151
|
+
|
|
152
|
+
return {
|
|
153
|
+
found: true,
|
|
154
|
+
agent,
|
|
155
|
+
messages: messages.filter((m) => m.seq > since && m.from !== agentId),
|
|
156
|
+
since_seq: since,
|
|
157
|
+
cursor_from: sinceSeq === undefined ? "agent-last-message" : "caller",
|
|
158
|
+
};
|
|
100
159
|
}
|
package/src/log/types.ts
CHANGED
|
@@ -60,6 +60,27 @@ export interface RoomState {
|
|
|
60
60
|
dispatcherAttached?: boolean;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
/**
|
|
64
|
+
* What a participant has not seen, according to the convention the dispatcher
|
|
65
|
+
* used to apply by hand: everything after that participant's own last message,
|
|
66
|
+
* excluding its own.
|
|
67
|
+
*
|
|
68
|
+
* `cursor_from` is not decoration. The server knows the convention; it does
|
|
69
|
+
* **not** know what was delivered to anyone — a dispatcher may have failed to
|
|
70
|
+
* send, or sent twice — and a caller must not have to guess which of the two
|
|
71
|
+
* produced the cursor it is looking at.
|
|
72
|
+
*/
|
|
73
|
+
export type AgentDelta =
|
|
74
|
+
| {
|
|
75
|
+
found: true;
|
|
76
|
+
agent: RosterEntry;
|
|
77
|
+
messages: MessageEnvelope[];
|
|
78
|
+
/** The cursor this delta was computed from. */
|
|
79
|
+
since_seq: number;
|
|
80
|
+
cursor_from: "agent-last-message" | "caller";
|
|
81
|
+
}
|
|
82
|
+
| { found: false };
|
|
83
|
+
|
|
63
84
|
export type AgentDetail =
|
|
64
85
|
| { found: true; agent: RosterEntry; messages: MessageEnvelope[]; lastSeenSeq: number }
|
|
65
86
|
| { found: false };
|
package/src/server/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { getStateTool } from "./tools/get-state";
|
|
|
4
4
|
import { OWNER_COMMAND_KINDS, OwnerCommandQueue } from "./owner-queue";
|
|
5
5
|
import type { OwnerCommand, OwnerCommandEnvelope, OwnerCommandKind } from "./owner-queue";
|
|
6
6
|
import { getTranscriptTool } from "./tools/get-transcript";
|
|
7
|
+
import { getAgentDeltaTool } from "./tools/get-agent-delta";
|
|
7
8
|
import { getAgentDetailTool } from "./tools/get-agent-detail";
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -138,6 +139,36 @@ export function createRoomMcpServer(logPath: string, options: RoomMcpServerOptio
|
|
|
138
139
|
}),
|
|
139
140
|
);
|
|
140
141
|
|
|
142
|
+
server.registerTool(
|
|
143
|
+
"room.get_delta_for",
|
|
144
|
+
{
|
|
145
|
+
title: "What one participant has not seen",
|
|
146
|
+
description:
|
|
147
|
+
"Everything after that participant's own last message, excluding its own — the convention " +
|
|
148
|
+
"\"everything since your last turn\", computed here instead of by hand. `since_seq` overrides " +
|
|
149
|
+
"the convention's cursor; the answer reports the cursor used and whether it came from the " +
|
|
150
|
+
"participant's last message or from the caller. " +
|
|
151
|
+
"This is what the participant has probably not seen: the server cannot see what was actually " +
|
|
152
|
+
"sent to it, so treat the result as a candidate delta, not as a delivery record.",
|
|
153
|
+
inputSchema: {
|
|
154
|
+
agent_id: z.string().min(1),
|
|
155
|
+
since_seq: z.number().int().min(0).optional(),
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
async ({ agent_id, since_seq }) => ({
|
|
159
|
+
content: [
|
|
160
|
+
{
|
|
161
|
+
type: "text",
|
|
162
|
+
text: JSON.stringify(
|
|
163
|
+
since_seq === undefined
|
|
164
|
+
? getAgentDeltaTool(logPath, agent_id)
|
|
165
|
+
: getAgentDeltaTool(logPath, agent_id, since_seq),
|
|
166
|
+
),
|
|
167
|
+
},
|
|
168
|
+
],
|
|
169
|
+
}),
|
|
170
|
+
);
|
|
171
|
+
|
|
141
172
|
server.registerTool(
|
|
142
173
|
"room.post_owner_command",
|
|
143
174
|
{
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { getAgentDelta, loadRoomLog } from "../../log/store";
|
|
2
|
+
import type { AgentDelta } from "../../log/types";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* MCP tool `room.get_delta_for`: what a participant has not seen, by the
|
|
6
|
+
* convention of "everything after its own last message". Read-only.
|
|
7
|
+
*
|
|
8
|
+
* It returns the cursor it used and where that cursor came from, so an empty
|
|
9
|
+
* delta means "nothing new" and not "the caller passed the wrong cursor".
|
|
10
|
+
*/
|
|
11
|
+
export function getAgentDeltaTool(logPath: string, agentId: string, sinceSeq?: number): AgentDelta {
|
|
12
|
+
const { state, messages } = loadRoomLog(logPath);
|
|
13
|
+
return sinceSeq === undefined
|
|
14
|
+
? getAgentDelta(messages, state.roster, agentId)
|
|
15
|
+
: getAgentDelta(messages, state.roster, agentId, sinceSeq);
|
|
16
|
+
}
|