@mrciphersmith/roomyx 0.9.0 → 0.10.1
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 +81 -0
- package/README.md +26 -0
- package/package.json +1 -1
- package/src/bundled-personas/01-ngozi-tailor-nigeria.md +14 -0
- package/src/bundled-personas/02-klaus-electrician-germany.md +14 -0
- package/src/bundled-personas/03-priya-designer-india.md +14 -0
- package/src/bundled-personas/04-dave-landlord-usa.md +14 -0
- package/src/bundled-personas/05-budi-ecommerce-indonesia.md +14 -0
- package/src/bundled-personas/06-alejandra-eventplanner-mexico.md +14 -0
- package/src/bundled-personas/07-tanaka-izakaya-japan.md +14 -0
- package/src/bundled-personas/08-thandiwe-ngo-southafrica.md +14 -0
- package/src/bundled-personas/09-marco-va-philippines.md +14 -0
- package/src/bundled-personas/10-amelie-bookstore-france.md +14 -0
- package/src/bundled-personas/11-otieno-bodaboda-kenya.md +14 -0
- package/src/bundled-personas/12-mehmet-textile-turkey.md +14 -0
- package/src/bundled-personas/13-kasia-freelancedev-poland.md +14 -0
- package/src/bundled-personas/14-hassan-tourguide-egypt.md +14 -0
- package/src/bundled-personas/15-linh-electronics-vietnam.md +14 -0
- package/src/bundled-personas/16-chloe-creator-uk.md +14 -0
- package/src/bundled-personas/17-bruce-farmer-australia.md +14 -0
- package/src/bundled-personas/18-sara-interiordesign-uae.md +14 -0
- package/src/bundled-personas/19-fernanda-daycare-brazil.md +14 -0
- package/src/bundled-personas/20-ryan-engmanager-usa.md +14 -0
- package/src/bundled-personas/21-victoria-banker-nyc.md +14 -0
- package/src/bundled-personas/22-omar-cryptotrader-dubai.md +14 -0
- package/src/bundled-personas/23-diane-surgeon-la.md +14 -0
- package/src/bundled-personas/24-james-consultant-london.md +14 -0
- package/src/bundled-personas/25-lena-biotechfounder-boston.md +14 -0
- package/src/bundled-personas/26-carlos-realestate-miami.md +14 -0
- package/src/bundled-personas/27-michelle-lawyer-singapore.md +14 -0
- package/src/bundled-personas/28-kevin-hedgefund-hongkong.md +14 -0
- package/src/bundled-personas/29-felix-cto-berlin.md +14 -0
- package/src/bundled-personas/30-grace-orthodontist-toronto.md +14 -0
- package/src/bundled-personas/31-brad-pharmavp-chicago.md +14 -0
- package/src/bundled-personas/32-nadia-peops-zurich.md +14 -0
- package/src/bundled-personas/33-junho-pilot-seoul.md +14 -0
- package/src/bundled-personas/34-emma-newparent-sydney.md +14 -0
- package/src/bundled-personas/35-minji-caregiver-seoul.md +14 -0
- package/src/bundled-personas/36-daniel-divorced-toronto.md +14 -0
- package/src/bundled-personas/37-anke-chronicillness-berlin.md +14 -0
- package/src/bundled-personas/38-harold-retiree-florida.md +14 -0
- package/src/bundled-personas/39-priyanka-immigrantfamily-toronto.md +14 -0
- package/src/bundled-personas/40-tyler-student-austin.md +14 -0
- package/src/bundled-personas/41-lotte-stayathome-amsterdam.md +14 -0
- package/src/bundled-personas/42-jessica-milspouse-sandiego.md +14 -0
- package/src/bundled-personas/43-marcus-pastor-alabama.md +14 -0
- package/src/bundled-personas/44-carmen-adoptiveparent-spain.md +14 -0
- package/src/bundled-personas/45-robert-chronicconditions-usa.md +14 -0
- package/src/bundled-personas/46-gary-trucker-usa.md +14 -0
- package/src/bundled-personas/47-giulia-weddingphotographer-italy.md +14 -0
- package/src/bundled-personas/48-mark-indiedev-canada.md +14 -0
- package/src/bundled-personas/49-fiona-pharmacist-uk.md +14 -0
- package/src/bundled-personas/50-willem-urbanbeekeeper-netherlands.md +14 -0
- package/src/bundled-personas/founders/01-marcus-serial-founder-sf.md +20 -0
- package/src/bundled-personas/founders/02-aisha-firsttime-technical-london.md +20 -0
- package/src/bundled-personas/founders/03-jonas-indiehacker-stockholm.md +20 -0
- package/src/bundled-personas/founders/04-vanessa-blitzscaler-sf.md +20 -0
- package/src/bundled-personas/founders/05-kenji-domainexpert-tokyo.md +20 -0
- package/src/bundled-personas/founders/06-ben-scarred-founder-berlin.md +20 -0
- package/src/bundled-personas/founders/07-sofia-idealist-milan.md +20 -0
- package/src/bundled-personas/founders/08-priya-corporate-intrapreneur-bangalore.md +20 -0
- package/src/bundled-personas/founders/09-dmitry-cis-trade-founder.md +17 -0
- package/src/bundled-personas/founders/10-aigerim-centralasia-founder.md +17 -0
- package/src/bundled-personas/founders/11-sheikh-rashid-uae-investor.md +19 -0
- package/src/bundled-personas/founders/12-viktor-russia-market-expert.md +17 -0
- package/src/bundled-personas/founders/13-pavel-russia-developer.md +17 -0
- package/src/bundled-personas/founders/14-marina-russia-executive.md +17 -0
- package/src/bundled-personas/founders/15-rohan-india-saas-founder.md +17 -0
- package/src/bundled-personas/founders/16-wei-china-tech-veteran.md +17 -0
- package/src/bundled-personas/founders/17-lena-verticalai-saas.md +17 -0
- package/src/bundled-personas/founders/18-marcus-ai-infra-llmops.md +17 -0
- package/src/bundled-personas/founders/19-sofia-consumer-ai-product.md +17 -0
- package/src/bundled-personas/groups.md +69 -0
- package/src/bundled-personas/panel/01-rick-operator-exec.md +17 -0
- package/src/bundled-personas/panel/02-elena-regtech-exec.md +17 -0
- package/src/bundled-personas/panel/03-david-vc-financier.md +17 -0
- package/src/bundled-personas/panel/04-grace-cfo-financier.md +17 -0
- package/src/bundled-personas/panel/05-sam-enterprise-developer.md +17 -0
- package/src/bundled-personas/panel/06-mira-ml-developer.md +17 -0
- package/src/bundled-personas/questionnaire-50.md +81 -0
- package/src/bundled-personas/tech/01-yuki-ai-ml-engineer.md +17 -0
- package/src/bundled-personas/tech/02-omar-database-backend-architect.md +17 -0
- package/src/bundled-personas/tech/03-zara-ui-ux-designer.md +17 -0
- package/src/bundled-personas/tech/04-finn-web-platform-browser-engineer.md +17 -0
- package/src/bundled-personas/tech/05-naledi-mobile-engineer.md +17 -0
- package/src/bundled-personas/tech/06-theo-plt-devtools-engineer.md +17 -0
- package/src/bundled-personas/tech/07-priya-security-researcher.md +17 -0
- package/src/bundled-personas/tech/08-marcus-dx-oss-adoption.md +17 -0
- package/src/bundled-personas/tech/09-elena-engineering-manager-buyer.md +17 -0
- package/src/bundled-personas/tech/10-david-competitive-analyst.md +17 -0
- package/src/bundled-skills/startup-room/SKILL.md +1 -1
- package/src/cli.ts +32 -1
- package/src/client/index.ts +10 -5
- package/src/client/mcp-client.ts +10 -5
- package/src/installer/init-apply.ts +10 -0
- package/src/installer/init-plan.ts +22 -1
- package/src/installer/personas.ts +78 -0
- package/src/server/index.ts +112 -18
- package/src/server/owner-queue.ts +127 -0
- package/src/server/serve.ts +9 -1
package/src/server/index.ts
CHANGED
|
@@ -1,25 +1,48 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { getStateTool } from "./tools/get-state";
|
|
4
|
+
import { OWNER_COMMAND_KINDS, OwnerCommandQueue } from "./owner-queue";
|
|
5
|
+
import type { OwnerCommand, OwnerCommandEnvelope, OwnerCommandKind } from "./owner-queue";
|
|
4
6
|
import { getTranscriptTool } from "./tools/get-transcript";
|
|
5
7
|
import { getAgentDetailTool } from "./tools/get-agent-detail";
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Re-exported so the vocabulary has one home — `owner-queue.ts`, where a command
|
|
11
|
+
* first exists — while everything that already reads it from the server's own
|
|
12
|
+
* surface keeps working.
|
|
13
|
+
*/
|
|
14
|
+
export { OWNER_COMMAND_KINDS };
|
|
15
|
+
export type { OwnerCommand, OwnerCommandEnvelope, OwnerCommandKind };
|
|
10
16
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
/**
|
|
18
|
+
* What became of a posted command.
|
|
19
|
+
*
|
|
20
|
+
* `queued` is the third answer and the reason this is not a boolean: a command
|
|
21
|
+
* held for a dispatcher that has not read it yet is **not** the same as a command
|
|
22
|
+
* nothing will ever act on, and `accepted: false` used to mean both. It is also
|
|
23
|
+
* the normal answer for a bare `roomyx serve`.
|
|
24
|
+
*/
|
|
25
|
+
export type OwnerCommandStatus = "queued" | "accepted" | "refused";
|
|
15
26
|
|
|
16
27
|
export interface OwnerCommandResult {
|
|
17
|
-
|
|
18
|
-
|
|
28
|
+
/** The queue entry this command is, so a dispatcher can acknowledge exactly it. */
|
|
29
|
+
id: string;
|
|
30
|
+
status: OwnerCommandStatus;
|
|
31
|
+
/** The dispatcher's own words, when one handled it. */
|
|
19
32
|
reason?: string;
|
|
20
33
|
}
|
|
21
34
|
|
|
22
35
|
export interface RoomMcpServerOptions {
|
|
36
|
+
/**
|
|
37
|
+
* The room's owner-command queue, shared by every session.
|
|
38
|
+
*
|
|
39
|
+
* Optional so a unit test or an embedder can build a server on its own — but
|
|
40
|
+
* a caller that wants a command posted in one session to be readable in
|
|
41
|
+
* another MUST pass the same queue to both, which is what `serve()` does.
|
|
42
|
+
* Omitting it gives this server a private queue, and a private queue is
|
|
43
|
+
* invisible to every other client.
|
|
44
|
+
*/
|
|
45
|
+
ownerQueue?: OwnerCommandQueue;
|
|
23
46
|
/**
|
|
24
47
|
* Supplied by the dispatcher that embeds this server. `room.post_owner_command`
|
|
25
48
|
* hands the command to it and returns whatever it says.
|
|
@@ -31,7 +54,17 @@ export interface RoomMcpServerOptions {
|
|
|
31
54
|
* the honest answer for a bare `roomyx serve`: nothing is dispatching, and
|
|
32
55
|
* pretending a command was accepted would be worse than saying so.
|
|
33
56
|
*/
|
|
34
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Supplied by a dispatcher that embeds this server. It is a **second road**
|
|
59
|
+
* into the same queue, not a parallel one: the command is held either way, and
|
|
60
|
+
* a handler that answers settles the entry so that whoever reads the queue
|
|
61
|
+
* does not act on it twice.
|
|
62
|
+
*/
|
|
63
|
+
onOwnerCommand?: (
|
|
64
|
+
command: OwnerCommandEnvelope,
|
|
65
|
+
) =>
|
|
66
|
+
| { status: Exclude<OwnerCommandStatus, "queued">; reason?: string }
|
|
67
|
+
| Promise<{ status: Exclude<OwnerCommandStatus, "queued">; reason?: string }>;
|
|
35
68
|
}
|
|
36
69
|
|
|
37
70
|
/**
|
|
@@ -41,6 +74,9 @@ export interface RoomMcpServerOptions {
|
|
|
41
74
|
*/
|
|
42
75
|
export function createRoomMcpServer(logPath: string, options: RoomMcpServerOptions = {}): McpServer {
|
|
43
76
|
const server = new McpServer({ name: "roomyx", version: "0.1.0" });
|
|
77
|
+
// A private queue when nobody injected one. Correct for a unit test, wrong for
|
|
78
|
+
// a room with more than one client — see the option's own comment.
|
|
79
|
+
const queue = options.ownerQueue ?? new OwnerCommandQueue();
|
|
44
80
|
|
|
45
81
|
server.registerTool(
|
|
46
82
|
"room.get_state",
|
|
@@ -107,23 +143,81 @@ export function createRoomMcpServer(logPath: string, options: RoomMcpServerOptio
|
|
|
107
143
|
{
|
|
108
144
|
title: "Post an owner command",
|
|
109
145
|
description:
|
|
110
|
-
"Hands a veto / constraint / add_participant / goal_edit to the
|
|
146
|
+
"Hands a veto / constraint / add_participant / goal_edit to the room: it is held in the room's queue " +
|
|
147
|
+
"for a dispatcher to read, and settlement is reported as `queued`, `accepted` or `refused`. " +
|
|
148
|
+
"Never writes to the room log itself.",
|
|
111
149
|
inputSchema: {
|
|
112
150
|
kind: z.enum(OWNER_COMMAND_KINDS),
|
|
113
151
|
body: z.string().min(1),
|
|
114
152
|
},
|
|
115
153
|
},
|
|
116
154
|
async ({ kind, body }) => {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
155
|
+
// `OwnerQueueFullError` is thrown and the SDK turns it into an error
|
|
156
|
+
// result: a full queue is a refusal with a diagnosis, not a success with a
|
|
157
|
+
// caveat. `accepted: true` for a command that was dropped is the shape
|
|
158
|
+
// this whole item exists to remove.
|
|
159
|
+
const queued = queue.post(kind, body);
|
|
160
|
+
|
|
161
|
+
if (options.onOwnerCommand) {
|
|
162
|
+
// The handler is a dispatcher that embedded this server, so its verdict
|
|
163
|
+
// is the answer — and it SETTLES the entry, because delivering the same
|
|
164
|
+
// veto twice (once to the handler, once to whoever reads the queue) is
|
|
165
|
+
// worse than one delivery to a stub the embedder wrote itself.
|
|
166
|
+
const verdict = await options.onOwnerCommand({ kind, body, id: queued.id });
|
|
167
|
+
queue.ack(queued.id);
|
|
168
|
+
const settled: OwnerCommandResult = { id: queued.id, status: verdict.status };
|
|
169
|
+
if (verdict.reason !== undefined) settled.reason = verdict.reason;
|
|
170
|
+
return { content: [{ type: "text", text: JSON.stringify(settled) }] };
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const result: OwnerCommandResult = { id: queued.id, status: "queued" };
|
|
124
174
|
return { content: [{ type: "text", text: JSON.stringify(result) }] };
|
|
125
175
|
},
|
|
126
176
|
);
|
|
127
177
|
|
|
178
|
+
server.registerTool(
|
|
179
|
+
"room.get_pending_owner_commands",
|
|
180
|
+
{
|
|
181
|
+
title: "Owner commands nobody has acted on",
|
|
182
|
+
description:
|
|
183
|
+
"Commands posted by the owner that have not been acknowledged yet, oldest first. " +
|
|
184
|
+
"Read-only: the room log is still written only by the dispatcher.",
|
|
185
|
+
},
|
|
186
|
+
async () => ({ content: [{ type: "text", text: JSON.stringify(queue.list()) }] }),
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
server.registerTool(
|
|
190
|
+
"room.ack_owner_command",
|
|
191
|
+
{
|
|
192
|
+
title: "Acknowledge an owner command",
|
|
193
|
+
description:
|
|
194
|
+
"Says that a command has been dealt with, so `pending` keeps meaning something. " +
|
|
195
|
+
"An unknown or already-acknowledged id is refused rather than reported as success.",
|
|
196
|
+
inputSchema: { id: z.string().min(1) },
|
|
197
|
+
},
|
|
198
|
+
async ({ id }) => {
|
|
199
|
+
if (!queue.ack(id)) {
|
|
200
|
+
// Thrown, not returned: the SDK turns this into an error result, and a
|
|
201
|
+
// dispatcher told "acknowledged" about a command it never held would
|
|
202
|
+
// stop looking for it.
|
|
203
|
+
throw new Error(`No pending owner command with id "${id}".`);
|
|
204
|
+
}
|
|
205
|
+
return { content: [{ type: "text", text: JSON.stringify({ acked: true, id }) }] };
|
|
206
|
+
},
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
server.registerResource(
|
|
210
|
+
"owner-queue",
|
|
211
|
+
"room://owner-queue",
|
|
212
|
+
{
|
|
213
|
+
title: "Owner command queue",
|
|
214
|
+
description: "The same pending commands as room.get_pending_owner_commands, as a resource.",
|
|
215
|
+
mimeType: "application/json",
|
|
216
|
+
},
|
|
217
|
+
async (uri) => ({
|
|
218
|
+
contents: [{ uri: uri.href, text: JSON.stringify(queue.list()) }],
|
|
219
|
+
}),
|
|
220
|
+
);
|
|
221
|
+
|
|
128
222
|
return server;
|
|
129
223
|
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The owner-command vocabulary, which lives here rather than in `index.ts`
|
|
5
|
+
* because this is where a command first exists.
|
|
6
|
+
*
|
|
7
|
+
* It is here for a structural reason, not a tidy one: `index.ts` imports the
|
|
8
|
+
* queue, so a queue that imported the vocabulary back from `index.ts` made the
|
|
9
|
+
* two modules cyclic. The cycle happened to work under this loader — the
|
|
10
|
+
* bindings are only read inside functions — but "happens to work" is the kind of
|
|
11
|
+
* thing that stops being true when a bundler or a load order changes, and the
|
|
12
|
+
* fix costs nothing: one direction of dependency instead of two.
|
|
13
|
+
*/
|
|
14
|
+
export const OWNER_COMMAND_KINDS = ["veto", "constraint", "add_participant", "goal_edit"] as const;
|
|
15
|
+
|
|
16
|
+
export type OwnerCommandKind = (typeof OWNER_COMMAND_KINDS)[number];
|
|
17
|
+
|
|
18
|
+
export interface OwnerCommand {
|
|
19
|
+
kind: OwnerCommandKind;
|
|
20
|
+
body: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* A command as it reaches a dispatcher: the same two fields, plus the queue
|
|
25
|
+
* entry's id.
|
|
26
|
+
*
|
|
27
|
+
* The id is what lets an embedded handler and a queue reader talk about the same
|
|
28
|
+
* command — the handler can settle it, or name it in the log line it writes, and
|
|
29
|
+
* the two roads meet at one identity instead of at a coincidence of body text.
|
|
30
|
+
*/
|
|
31
|
+
export interface OwnerCommandEnvelope extends OwnerCommand {
|
|
32
|
+
id: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The owner-command queue, and the reason it is a separate object.
|
|
37
|
+
*
|
|
38
|
+
* `room.post_owner_command` used to hand the command straight to
|
|
39
|
+
* `onOwnerCommand` — a JS function supplied by whoever embeds the server. A
|
|
40
|
+
* model-driven orchestrator spawns `roomyx serve` as a child process and cannot
|
|
41
|
+
* inject a function into it, so for the consumer this feature exists for, the
|
|
42
|
+
* tool answered "no dispatcher is attached" and the command was **discarded**.
|
|
43
|
+
* `prd.md` R5's criterion ("at least one interactive command really reaches the
|
|
44
|
+
* room") had no measurable form because nothing was ever held anywhere.
|
|
45
|
+
*
|
|
46
|
+
* The queue is why it lives here and not inside `createRoomMcpServer`:
|
|
47
|
+
* `serveMcpOverHttp` calls that factory **once per session**, so state created
|
|
48
|
+
* inside it belongs to one client. A queue built there would accept the TUI's
|
|
49
|
+
* veto into a structure the dispatcher's own session cannot read — a feature
|
|
50
|
+
* that passes every single-client test and does nothing in the shape it exists
|
|
51
|
+
* for. `serve()` creates the queue and injects it into every session instead.
|
|
52
|
+
*
|
|
53
|
+
* **The server still does not write the room log** (D-01). This is a queue, not
|
|
54
|
+
* a pen: the dispatcher reads it and writes what it decides.
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* How many unacknowledged commands are held before posting is refused.
|
|
59
|
+
*
|
|
60
|
+
* A bound rather than unbounded, because the server lives exactly as long as the
|
|
61
|
+
* room and a room runs for hours: with nothing draining it, the queue grows for
|
|
62
|
+
* as long as somebody keeps posting. This project has already shipped one
|
|
63
|
+
* unbounded-retention defect — every MCP session retained for the life of the
|
|
64
|
+
* process — and the fix was a stated ceiling rather than hope. A refusal an
|
|
65
|
+
* operator can read beats a leak nobody measures.
|
|
66
|
+
*
|
|
67
|
+
* 32 is far more than a room needs (an owner sends a veto, not a stream) and
|
|
68
|
+
* small enough that a full queue means something is genuinely wrong.
|
|
69
|
+
*/
|
|
70
|
+
export const OWNER_QUEUE_LIMIT = 32;
|
|
71
|
+
|
|
72
|
+
export interface QueuedOwnerCommand {
|
|
73
|
+
id: string;
|
|
74
|
+
kind: OwnerCommandKind;
|
|
75
|
+
body: string;
|
|
76
|
+
/** ISO timestamp, so a dispatcher can tell a fresh veto from a stale one. */
|
|
77
|
+
postedAt: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Thrown when the queue is full. Carries the count, because the number is the diagnosis. */
|
|
81
|
+
export class OwnerQueueFullError extends Error {
|
|
82
|
+
constructor(readonly waiting: number) {
|
|
83
|
+
super(
|
|
84
|
+
`The owner-command queue is full: ${waiting} command(s) have been posted and none has been acknowledged. ` +
|
|
85
|
+
`Nothing is reading the queue — a dispatcher reads it with \`room.get_pending_owner_commands\` and settles each one with \`room.ack_owner_command\`.`,
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export class OwnerCommandQueue {
|
|
91
|
+
private readonly pending = new Map<string, QueuedOwnerCommand>();
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Holds a command, or refuses when nothing has drained the queue.
|
|
95
|
+
*
|
|
96
|
+
* The refusal is the honest failure: silently dropping the oldest would lose
|
|
97
|
+
* a veto, and silently growing would leak. Refusing says which of the two
|
|
98
|
+
* problems the operator actually has.
|
|
99
|
+
*/
|
|
100
|
+
post(kind: OwnerCommandKind, body: string): QueuedOwnerCommand {
|
|
101
|
+
if (this.pending.size >= OWNER_QUEUE_LIMIT) throw new OwnerQueueFullError(this.pending.size);
|
|
102
|
+
const command: QueuedOwnerCommand = {
|
|
103
|
+
id: `cmd-${randomUUID().slice(0, 8)}`,
|
|
104
|
+
kind,
|
|
105
|
+
body,
|
|
106
|
+
postedAt: new Date().toISOString(),
|
|
107
|
+
};
|
|
108
|
+
this.pending.set(command.id, command);
|
|
109
|
+
return command;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** Oldest first: an owner command is a queue, not a set. */
|
|
113
|
+
list(): QueuedOwnerCommand[] {
|
|
114
|
+
return [...this.pending.values()];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Settles one command. False when the id is not held.
|
|
119
|
+
*
|
|
120
|
+
* Returning false rather than throwing, because the caller decides how loud it
|
|
121
|
+
* should be: the tool turns it into an error, while the handler path calls it
|
|
122
|
+
* right after posting a command it knows is there.
|
|
123
|
+
*/
|
|
124
|
+
ack(id: string): boolean {
|
|
125
|
+
return this.pending.delete(id);
|
|
126
|
+
}
|
|
127
|
+
}
|
package/src/server/serve.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createRoomMcpServer } from "./index";
|
|
2
|
+
import { OwnerCommandQueue } from "./owner-queue";
|
|
2
3
|
import type { RoomMcpServerOptions } from "./index";
|
|
3
4
|
import { serveMcpOverHttp } from "./http-transport";
|
|
4
5
|
import type { McpHttpTransportHandle } from "./http-transport";
|
|
@@ -45,8 +46,15 @@ export async function serve(logPath: string, options: ServeOptions): Promise<Ser
|
|
|
45
46
|
// that names the file and the line.
|
|
46
47
|
loadRoomLog(logPath);
|
|
47
48
|
|
|
49
|
+
// ONE queue for the room, created here because this factory runs once per
|
|
50
|
+
// SESSION: state built inside it would belong to a single client, so a command
|
|
51
|
+
// posted by the TUI would be invisible to the dispatcher's own session. This is
|
|
52
|
+
// the difference between a feature and a feature that passes its tests.
|
|
53
|
+
const ownerQueue = new OwnerCommandQueue();
|
|
54
|
+
|
|
48
55
|
const handle = await serveMcpOverHttp({
|
|
49
|
-
createMcpServer: () =>
|
|
56
|
+
createMcpServer: () =>
|
|
57
|
+
createRoomMcpServer(logPath, { onOwnerCommand: options.onOwnerCommand, ownerQueue }),
|
|
50
58
|
commandLabel: "roomyx serve",
|
|
51
59
|
defaultPort: 4319,
|
|
52
60
|
port: options.port,
|