@mrciphersmith/roomyx 0.2.1 → 0.4.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 +75 -15
- package/package.json +1 -1
- package/src/bundled-skills/startup-room/SKILL.md +193 -9
- package/src/cli.ts +123 -16
- package/src/client/components/status-bar.ts +12 -0
- package/src/client/index.ts +50 -9
- package/src/client/mcp-client.ts +9 -0
- package/src/client/owner-prompt.ts +92 -0
- package/src/installer/skill-sync.ts +7 -1
- package/src/installer/skill-targets.ts +53 -0
- package/src/mcp-management/server.ts +93 -31
- package/src/server/index.ts +57 -5
- package/src/server/serve.ts +3 -2
package/README.md
CHANGED
|
@@ -7,9 +7,11 @@ run at once and be found by id, and a skill-sync path that installs the bundled
|
|
|
7
7
|
`startup-room` skill into a project without ever silently overwriting local
|
|
8
8
|
edits.
|
|
9
9
|
|
|
10
|
-
roomyx
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
roomyx never writes to a room log. Owner commands do exist —
|
|
11
|
+
`room.post_owner_command` takes a veto, constraint, added participant or goal
|
|
12
|
+
edit — but the tool only forwards them to the dispatcher that runs the room.
|
|
13
|
+
The log keeps exactly one writer, which is what the room's consistency rests
|
|
14
|
+
on.
|
|
13
15
|
|
|
14
16
|
## Requirements
|
|
15
17
|
|
|
@@ -49,14 +51,18 @@ roomyx-client --room r-a1b2c3
|
|
|
49
51
|
```
|
|
50
52
|
|
|
51
53
|
In the TUI: `↑`/`↓` move through the roster, `Enter` opens the selected agent's
|
|
52
|
-
modal, `Esc` closes it, `q` or `Ctrl-C` quits.
|
|
54
|
+
modal, `Esc` closes it, `q` or `Ctrl-C` quits. `o` opens an owner command —
|
|
55
|
+
pick `v`eto, `c`onstraint, `a`dd participant or `g`oal edit, type the body,
|
|
56
|
+
`Enter` sends. While the prompt is open it owns the keyboard, so a `q` in a
|
|
57
|
+
veto is text rather than a quit.
|
|
53
58
|
|
|
54
59
|
## Commands
|
|
55
60
|
|
|
56
|
-
The
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
61
|
+
The TUI ships as its own binary, `roomyx-client`, because it is a separate
|
|
62
|
+
process with a lifetime independent of `serve` and `mcp` — closing it does
|
|
63
|
+
nothing to the room. `roomyx client`, with a space, starts that same TUI from
|
|
64
|
+
the single `roomyx` binary; it is an alias for convenience, not a second
|
|
65
|
+
implementation, and it does not tie the TUI's lifetime to anything.
|
|
60
66
|
|
|
61
67
|
### `roomyx init`
|
|
62
68
|
|
|
@@ -88,9 +94,43 @@ Lists rooms that are **confirmed live**, not merely present in the registry —
|
|
|
88
94
|
each entry is verified with a real MCP round-trip, and entries that don't answer
|
|
89
95
|
are pruned from the registry file as a side effect.
|
|
90
96
|
|
|
97
|
+
### `roomyx mcp [flags]`
|
|
98
|
+
|
|
99
|
+
Starts the management MCP server (room listing + skill-sync). Default port
|
|
100
|
+
`4320`. See **Management server** below for tools and flags.
|
|
101
|
+
|
|
102
|
+
### `roomyx skills sync --target <claude|codex|keryx|all|path> [flags]`
|
|
103
|
+
|
|
104
|
+
Installs the bundled `startup-room` skill into a runtime's skill location.
|
|
105
|
+
|
|
106
|
+
| Target | Path |
|
|
107
|
+
| --- | --- |
|
|
108
|
+
| `claude` | `~/.claude/skills/startup-room/SKILL.md` |
|
|
109
|
+
| `codex` | `~/.codex/skills/startup-room/SKILL.md` |
|
|
110
|
+
| `keryx` | `<cwd>/.metaproject/project-skills/startup-room/SKILL.md` |
|
|
111
|
+
| `all` | all three of the above |
|
|
112
|
+
| anything else | taken as a literal path |
|
|
113
|
+
|
|
114
|
+
| Flag | Default | Meaning |
|
|
115
|
+
| --- | --- | --- |
|
|
116
|
+
| `--yes` | off | Actually write. **Without it nothing is written** — the run reports what it would do and stops. |
|
|
117
|
+
| `--dry-run` | — | Says the same thing explicitly. Redundant unless paired with `--yes`, which it overrides. |
|
|
118
|
+
| `--config <path>` | `.roomyx/config.json` | Where the last-synced hashes are recorded. |
|
|
119
|
+
|
|
120
|
+
Requires `roomyx init` to have run, since that is what creates the config the
|
|
121
|
+
sync records into.
|
|
122
|
+
|
|
123
|
+
**This copies over the target; it does not merge into it.** If you already
|
|
124
|
+
maintain a fuller `startup-room` skill, fold the bundled text into it by hand
|
|
125
|
+
rather than pointing `--yes` at it. See **Skill sync safety** below for what
|
|
126
|
+
roomyx refuses outright.
|
|
127
|
+
|
|
91
128
|
### `roomyx-client [flags]`
|
|
92
129
|
|
|
93
|
-
The terminal UI.
|
|
130
|
+
The terminal UI. `roomyx client` (space, not hyphen) is the same entry — an
|
|
131
|
+
alias so a single `roomyx` binary can attach without a second command on PATH.
|
|
132
|
+
`roomyx-client` remains the dedicated binary: a separate process, independent
|
|
133
|
+
lifetime from `serve`/`mcp`.
|
|
94
134
|
|
|
95
135
|
| Flag | Meaning |
|
|
96
136
|
| --- | --- |
|
|
@@ -110,6 +150,12 @@ list of candidate ids when more than one is.
|
|
|
110
150
|
| `room.get_state` | — | Roster and current goal contract. |
|
|
111
151
|
| `room.get_transcript` | `since_seq: number` | Messages with `seq` greater than `since_seq`, in order. |
|
|
112
152
|
| `room.get_agent_detail` | `agent_id: string` | One participant's own messages and last-seen status. |
|
|
153
|
+
| `room.post_owner_command` | `kind: veto \| constraint \| add_participant \| goal_edit`, `body: string` | `{ accepted, reason? }` from the dispatcher. |
|
|
154
|
+
|
|
155
|
+
`room.post_owner_command` forwards; it never writes. A dispatcher supplies a
|
|
156
|
+
handler when it embeds the server (`onOwnerCommand` in `serve()`). A room served
|
|
157
|
+
by bare `roomyx serve` has no dispatcher, so the tool answers `accepted: false`
|
|
158
|
+
and says so — better than accepting a command nothing will act on.
|
|
113
159
|
|
|
114
160
|
### Management server
|
|
115
161
|
|
|
@@ -119,16 +165,26 @@ and skill-sync — to any MCP client.
|
|
|
119
165
|
| Tool | Input | Returns |
|
|
120
166
|
| --- | --- | --- |
|
|
121
167
|
| `roomyx.rooms.list` | — | Live, liveness-checked rooms. |
|
|
122
|
-
| `roomyx.skills.sync` | `targetPath
|
|
168
|
+
| `roomyx.skills.sync` | `target?: claude \| codex \| keryx \| all` or `targetPath?: string`, `dryRun?: boolean`, `yes?: boolean` | One result per target: whether it would write, whether it did, and where the backup went. |
|
|
169
|
+
|
|
170
|
+
Start it with `roomyx mcp` (default port `4320`, so it does not collide with
|
|
171
|
+
`roomyx serve`'s `4319`). Same loopback / `--acknowledge-non-loopback` rules as
|
|
172
|
+
`serve`. It is also a library entry point (`serveManagement` in
|
|
173
|
+
`src/mcp-management/server.ts`) for embedding hosts to bind.
|
|
123
174
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
175
|
+
| Flag | Default | Meaning |
|
|
176
|
+
| --- | --- | --- |
|
|
177
|
+
| `--port <n>` | `4320` | Listen port. `0` picks an ephemeral one. |
|
|
178
|
+
| `--host <addr>` | `127.0.0.1` | Bind address. |
|
|
179
|
+
| `--acknowledge-non-loopback` | off | Required to bind anything other than loopback. |
|
|
180
|
+
| `--registry <path>` | `.roomyx/rooms/registry.json` | Registry file to list rooms from. |
|
|
181
|
+
| `--config <path>` | `.roomyx/config.json` | Config file skill-sync records hashes in. |
|
|
127
182
|
|
|
128
183
|
## Skill sync safety
|
|
129
184
|
|
|
130
|
-
`roomyx.skills.sync` will
|
|
131
|
-
and
|
|
185
|
+
Neither `roomyx skills sync` nor `roomyx.skills.sync` will silently discard
|
|
186
|
+
local work. Both refuse to write, and report a warning instead, in two cases —
|
|
187
|
+
unless `--yes` / `yes: true` is passed:
|
|
132
188
|
|
|
133
189
|
- the target has changed since roomyx last synced it (hand-edited), or
|
|
134
190
|
- the target already exists but roomyx has **no record of ever having written
|
|
@@ -196,6 +252,10 @@ provenance via trusted publishing.
|
|
|
196
252
|
|
|
197
253
|
## Further reading
|
|
198
254
|
|
|
255
|
+
- [`docs/roomyx/testing-story.md`](https://github.com/MrCipherSmith/roomyx/blob/main/docs/roomyx/testing-story.md)
|
|
256
|
+
— a verified end-to-end walkthrough, from `npm install` to driving a live
|
|
257
|
+
room, including what keryx shell can and cannot do with roomyx.
|
|
258
|
+
|
|
199
259
|
Full architecture and the reasoning behind each decision:
|
|
200
260
|
|
|
201
261
|
- [`docs/roomyx/specification.md`](https://github.com/MrCipherSmith/roomyx/blob/main/docs/roomyx/specification.md)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrciphersmith/roomyx",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
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"
|
|
@@ -1,12 +1,196 @@
|
|
|
1
|
-
|
|
1
|
+
---
|
|
2
|
+
name: startup-room
|
|
3
|
+
description: Runs a persistent multi-persona discussion/brainstorm room cheaply — each persona is spawned once as a named subagent and kept alive across turns via SendMessage (so it remembers its own history instead of re-reading the whole transcript every time), every message is broadcast to every participant (not just @-addressed ones), participants self-moderate against tunneling too deep into one narrow thread, and the full dialogue is logged verbatim to a shared markdown file the participants never write to directly. The room is goal-driven, not round-driven: it runs until an explicit, measurable goal is met (by default, for startup-idea rooms: find an idea, score it against a 50-criteria rubric, and reach participant convergence) or the owner stops it — not until some fixed number of turns has elapsed. Use whenever the user wants several persona/character subagents (founders, experts, interview personas, judges) to discuss, debate, brainstorm, or interview each other over multiple rounds toward a concrete goal, especially when they've asked for this to be done without burning tokens by re-pasting the whole conversation into a fresh agent each round.
|
|
4
|
+
---
|
|
2
5
|
|
|
3
|
-
|
|
6
|
+
# Startup Room
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
eventually replace `~/.claude/skills/startup-room/SKILL.md` — is explicitly
|
|
7
|
-
out of scope for `roomyx-installer` flow 003 (see
|
|
8
|
-
`docs/requirements/roomyx-installer/description.md` and `decisions.md` D-02).
|
|
9
|
-
This file exists only so `roomyx init` and `roomyx skills sync` have a real
|
|
10
|
-
file to stage/copy/diff while the mechanism itself is built and tested.
|
|
8
|
+
A reusable pattern for running a multi-agent "room" — several distinct persona subagents holding a real, evolving group conversation toward an explicit goal — without the token cost of re-sending the full transcript to a brand-new agent every turn.
|
|
11
9
|
|
|
12
|
-
|
|
10
|
+
## Why this exists
|
|
11
|
+
|
|
12
|
+
The naive approach (spawn a fresh `Agent` call each turn, pasting the entire cumulative transcript into the prompt so the agent has context) burns tokens quadratically: transcript size × number of remaining turns. This skill fixes that by keeping each persona as one long-lived agent that remembers its own history natively, and only ever receiving the *delta* (what's new since it last spoke).
|
|
13
|
+
|
|
14
|
+
## The goal contract (mandatory)
|
|
15
|
+
|
|
16
|
+
A room without an explicit, checkable goal degenerates into an open-ended chat that never actually concludes anything — this was an observed failure mode, not a hypothetical. Every room must be created with:
|
|
17
|
+
|
|
18
|
+
1. **A goal statement** — what the room is *for*, in one sentence (e.g. "find a startup idea and defend it" / "pick the best of these 3 architectures" / "interview this candidate and reach a hire/no-hire call").
|
|
19
|
+
2. **Explicit, measurable success criteria** — a checklist or scoring rubric the candidate output must pass, decided *before* spawning participants, not invented after something looks good. See **Goal type: find & defend a startup idea** below for the default criteria set this skill ships with for that specific goal; other goal types need their own criteria stated up front the same way.
|
|
20
|
+
3. **A convergence requirement** — passing the criteria on paper is not enough; the room's own participants must explicitly agree the candidate is the pick. A high score with participants still arguing is not a completed goal.
|
|
21
|
+
|
|
22
|
+
The room is **goal-driven, not round-driven**: there is no fixed number of rounds. It keeps looping — search, propose, defend, score, converge — until either (a) a candidate passes the criteria *and* the room converges on it, or (b) the owner explicitly stops the room (out of patience, budget, or a decision that no candidate is good enough). Running out of obvious new ideas without reaching (a) is a legitimate status to report honestly — it is not a signal to quietly lower the bar or declare victory on a candidate that didn't actually pass.
|
|
23
|
+
|
|
24
|
+
## Roles in this pattern
|
|
25
|
+
|
|
26
|
+
- **The dispatcher** — you (the orchestrating Claude instance). Your job is transport, not judgment: relay deltas, append to the log, spawn new participants when told to. You never let participants write to the shared log file themselves; you are the only writer. This is a deliberate safety choice: it guarantees nothing gets deleted or corrupted by a subagent, and it lets you enforce formatting and catch a participant going off the rails before it's committed to the record. See **Dispatcher discipline** below — this role is narrower than it sounds, and it is easy to accidentally overstep it.
|
|
27
|
+
- **The participants** — one persistent named subagent per persona. They decide everything substantive: what to research, whether an idea is good, when to pivot, who should speak next, when to converge. This is the actual point of the room — if you (the dispatcher) are making these calls instead of them, the room has stopped being a room.
|
|
28
|
+
- **The session owner** — the human running the session. They can inject an instruction at any point (a veto, a new constraint, a topic to explore, a request to add participants, a reminder like "we're a small startup"). See **The owner-injection channel** below for how this differs from a participant's suggestion.
|
|
29
|
+
- **The log file** — a single markdown file (e.g. `<project>/brainstorm/<topic>-room.md`) that is the append-only source of truth for the whole session.
|
|
30
|
+
|
|
31
|
+
## Dispatcher discipline (the easiest way to break this pattern)
|
|
32
|
+
|
|
33
|
+
The dispatcher's job looks like a moderator's job but is actually much narrower. In practice, the strongest pull is to start *directing* — assigning specific research questions to specific participants, synthesizing conclusions before the room has, deciding which candidate to pursue next. Every one of these is a real failure mode observed in practice, not a hypothetical:
|
|
34
|
+
|
|
35
|
+
- **Don't assign research tasks.** Relay the delta ("here's what happened since your last turn") and stop there — let the participant decide whether to research, argue, ask someone else a question, or pass. Composing a specific question for them to answer ("please check X, Y, Z") is you doing their job.
|
|
36
|
+
- **Don't synthesize verdicts for them.** If Grace and Elena need to independently converge on whether an idea survives, let their own words do that — don't write "the room concludes X" until participants have actually said so.
|
|
37
|
+
- **Don't pick the next direction.** If the room hits a fork (which candidate to pursue, whether to pivot), relay the fork to participants and let them argue it out — including disagreeing with each other. Your log entries should record who decided what, not you deciding on their behalf.
|
|
38
|
+
- **Do relay a stalled thread's obvious next question** (e.g. "Grace asked Sam a direct question, he hasn't answered yet — send it to Sam") — this is transport, not judgment, because the question already exists in the transcript.
|
|
39
|
+
- **Self-check each turn:** if your message to a participant contains a specific instruction they didn't ask for and no one in the room raised, you've drifted from dispatcher into director. Rewrite it as a neutral delta + open prompt.
|
|
40
|
+
|
|
41
|
+
This discipline was learned the hard way mid-session: the dispatcher spent several rounds assigning bespoke research questions to each participant, effectively running the investigation *for* the room. The session owner corrected this explicitly ("не ты их направляешь, они сами друг друга... в этом смысл"). The fix held for the rest of the session and produced better, more surprising results — participants caught things a directed investigation would have missed (e.g. one participant refusing to trust their own confident technical claim until a colleague pressure-tested it).
|
|
42
|
+
|
|
43
|
+
## The owner-injection channel
|
|
44
|
+
|
|
45
|
+
The session owner is not a participant, and their messages are not "just another opinion" to be relayed on equal footing — they carry standing authority the room cannot vote down. When the owner sends an instruction mid-session, handle it distinctly from ordinary dispatch:
|
|
46
|
+
|
|
47
|
+
- **Vetoes are final, not negotiable.** If the owner says a direction is closed (e.g. "this is too heavy for a small startup, drop it"), relay it as a closed decision to the participant(s) working that thread — not as a question for them to weigh in on. They can react (and often will, gracefully — e.g. proposing what to do instead), but the veto itself isn't up for debate.
|
|
48
|
+
- **Constraints apply retroactively and going forward.** A reminder like "we're a small startup" should be relayed to whoever is currently evaluating open candidates, framed as: re-assess what you already found under this lens, not just apply it to future ideas.
|
|
49
|
+
- **New topics/scope changes come from the owner, not from you.** If the owner says "look at IT trends broadly, not just AI," that reframing is theirs — relay it as their explicit ask, don't quietly narrow or widen scope yourself.
|
|
50
|
+
- **Requests to add participants** are handled via the mid-session spawn pattern below.
|
|
51
|
+
- **The owner can edit the goal contract itself** (tighten/loosen the threshold, add a "must also" criterion, change the goal entirely) — this is a goal-injection, distinct from a veto on content. Relay it to the room as an authoritative update to what "done" means, and re-run the scoring/convergence check under the new terms if a candidate was already mid-evaluation.
|
|
52
|
+
- **Status requests ("what's happening in the room?") get a real status, not a decision.** Report what's been found, who's arguing what, what's still open — do not use the opportunity to steer. If the owner explicitly asks "which should we pursue," that's their call to make (possibly by asking the room, via you), not yours to answer.
|
|
53
|
+
- **Owner instructions may also arrive over roomyx.** If you started a room server and attached a dispatcher handler to it, a veto / constraint / add-participant / goal-edit posted through `room.post_owner_command` is an owner injection exactly like one typed in chat — same standing authority, same handling as above. It reaches you as a command to act on; roomyx itself never writes to the log.
|
|
54
|
+
- **Do not ask the owner "what should we do next" as your default move.** Once the room's goal is set, keep it running and report status; only surface a genuine fork to the owner if it's a decision only they can make (scope, budget, willingness to accept a risk) — not a decision participants should be making themselves.
|
|
55
|
+
|
|
56
|
+
## Mid-session participant addition
|
|
57
|
+
|
|
58
|
+
The room doesn't have to be fully cast before it starts. To add a participant partway through:
|
|
59
|
+
|
|
60
|
+
1. Write their persona profile file first if it doesn't exist yet (same neutral-biography convention as the rest of the roster — see the project's persona-writing convention if one exists).
|
|
61
|
+
2. Spawn them with a **condensed** recap of what's happened so far (not the full transcript — summarize the arc: what's been explored, what's been killed and why, what's currently live) plus the full current roster (names + one-line role of everyone, including the other new joiners arriving alongside them).
|
|
62
|
+
3. Give them the same broadcast/self-moderation rules as original participants, and ask for an opening reaction — they should react to the *substance* of what's happened, not just announce themselves. A good new joiner brings a genuinely different angle (a different market, a different domain, a skeptical read on an existing thread) rather than restating what's already been said.
|
|
63
|
+
4. Log their contribution like anyone else's, and update the roster reference in the log file header.
|
|
64
|
+
|
|
65
|
+
This works well for deliberately broadening a room's perspective (e.g. a US-centric room that needs non-US market voices) — inject 2-3 new participants at once with an explicit ask to bring the missing angle, not just "join the discussion."
|
|
66
|
+
|
|
67
|
+
## Goal type: find & defend a startup idea (default criteria)
|
|
68
|
+
|
|
69
|
+
This is the default, ready-to-use goal type for this skill. When the owner asks to "find a startup idea," "find and defend an idea," or similar, use this criteria set unless they specify otherwise or the project has its own rubric file (check for one, e.g. `<project>/ideas/scoring-rubric.md`, and prefer it if present and more current — the list below is the portable default this skill carries so it works standalone in any project).
|
|
70
|
+
|
|
71
|
+
**Goal statement:** find a startup idea, and defend it until it (a) scores ≥60-70% on the 50-criteria rubric below, and (b) every active participant explicitly backs it as the room's pick.
|
|
72
|
+
|
|
73
|
+
**The 50-criteria rubric** — score each 0-10, sum out of 500, report as a percentage. Threshold: **60-70% (300-350/500)** to be "seriously considered." Below that is a real fail, however good the idea sounds in conversation.
|
|
74
|
+
|
|
75
|
+
**A. Боль и спрос (pain & demand) — 1-8**
|
|
76
|
+
1. Боль подтверждена цифрами, не догадкой · 2. Частота возникновения боли · 3. Острота боли (цена НЕ-решения) · 4. Размер затронутой аудитории · 5. Боль растёт со временем (тренд) · 6. Осознаваемость боли самим страдающим · 7. Стоимость текущего обходного пути · 8. Источник данных о боли независим от продавца идеи
|
|
77
|
+
|
|
78
|
+
**B. Рынок и конкуренция — 9-16**
|
|
79
|
+
9. Конкуренция реально пуста после жёсткого поиска · 10. Качество существующих решений · 11. Защитимость (не скопируют за спринт) · 12. Риск, что крупный игрок зайдёт намеренно · 13. Фрагментация рынка · 14. Траектория конкурентов (растут/буксуют) · 15. Издержки переключения клиента · 16. Временное окно возможности имеет чёткую дату, не расплывчатое "скоро"
|
|
80
|
+
|
|
81
|
+
**C. Экономика — 17-24**
|
|
82
|
+
17. Готовность платить подтверждена, не гипотетична · 18. Реалистичный ценовой потолок на клиента · 19. Размер адресного рынка именно для этой ниши · 20. Юнит-экономика (CAC/LTV хотя бы оценочно) · 21. Повторяемость дохода (подписка vs разовая) · 22. Ясность модели ценообразования · 23. Устойчивость маржи к росту стоимости входов · 24. Скорость цикла продажа→первый доход
|
|
83
|
+
|
|
84
|
+
**D. Реализуемость — 25-32**
|
|
85
|
+
25. Соло-подъёмность MVP (недели vs годы) · 26. Технический риск/предсказуемость · 27. Зависимость от партнёрств/данных третьих лиц · 28. Скорость получения рыночной обратной связи · 29. Требуемая доменная экспертиза · 30. Зависимость продаж от личных связей/доверия · 31. Доступность данных для AI-компонента (если применимо) · 32. Реалистичная оценка времени до первой сделки
|
|
86
|
+
|
|
87
|
+
**E. Риски — 33-40**
|
|
88
|
+
33. Регуляторный/юридический риск минимален · 34. Независимость от чужой платформы/API · 35. Риск изменения политики платформы/вендора · 36. Ответственность/репутационный риск при ошибке · 37. Чувствительность к макроэкономике/сезонности · 38. Личный юридический риск для фаундеров · 39. Геополитическая/юрисдикционная хрупкость · 40. Риск единой точки отказа
|
|
89
|
+
|
|
90
|
+
**F. Дистрибуция и рост — 41-46**
|
|
91
|
+
41. Можешь ли ты реально продать именно в этот сегмент · 42. Тёплый путь к первому платящему клиенту · 43. Виральный/реферальный потенциал · 44. Founder-market fit · 45. Повторяемость GTM на новые сегменты/страны · 46. Готовое сообщество/экосистема, на которую можно опереться
|
|
92
|
+
|
|
93
|
+
**G. Долгосрочная устойчивость — 47-50**
|
|
94
|
+
47. Защитимость за пределами первого узкого клина · 48. Опциональность расширения в смежные звенья цепочки · 49. Ценовая власть со временем · 50. Реалистичный путь к экзиту, или устойчивость как bootstrap-бизнеса
|
|
95
|
+
|
|
96
|
+
**How to run the scoring gate:** see **Scoring & convergence protocol** below — do not treat "the room seems to like this idea" as equivalent to a passed gate.
|
|
97
|
+
|
|
98
|
+
## Archiving a finding mid-session
|
|
99
|
+
|
|
100
|
+
When the owner says "save this idea" (or a candidate clearly survives enough rounds to be worth keeping regardless of whether the room keeps exploring), write it to a dedicated file *outside* the raw transcript — e.g. `<project>/ideas/<idea-name>.md` — with: the core pitch, the "why now" trigger, the strongest supporting evidence with sources, the competitive landscape found, open questions still unresolved, and which participants found what. Do this instead of letting the idea's evidence live only buried in a long transcript. Then explicitly tell the room to keep going — archiving isn't the same as concluding, and a room that just landed a good finding is prone to a "victory lap" where everyone relaxes instead of continuing to search (one participant in practice named this risk explicitly and it's worth watching for).
|
|
101
|
+
|
|
102
|
+
## Setup
|
|
103
|
+
|
|
104
|
+
1. Identify the persona profile files to use (e.g. `arena/roles/**/*.md` or a subset). Each profile should already be a neutral biography/expertise sheet — no pre-baked opinions or conclusions (see the project's persona-writing convention if one exists).
|
|
105
|
+
2. Write the **goal contract** (see above): goal statement, success criteria (default to the 50-criteria rubric for a startup-idea room), and the convergence requirement.
|
|
106
|
+
3. Create the log file with a header: the goal contract in full (not just a one-line goal — include the criteria/threshold so anyone reading the log later can check whether it was actually met), list of participants (name + one-line role), and the ground rule that only the moderator writes to it.
|
|
107
|
+
4. Decide the opening framing. If the task is "find something from scratch," say so explicitly and do NOT hand participants a pre-built brief that narrows their options — that biases the room before it starts. The criteria are the bar the eventual candidate must clear, not a hint about what kind of idea to look for.
|
|
108
|
+
5. If roomyx is available for this project — a `.roomyx/` directory exists, or `roomyx` resolves on `PATH` — start a server for the log so the owner can watch the room live. See **Watching the room live (roomyx)** below. If it isn't available, skip this step and run the session exactly as you would otherwise; nothing here depends on it.
|
|
109
|
+
|
|
110
|
+
## Watching the room live (roomyx)
|
|
111
|
+
|
|
112
|
+
A room's transcript is a file the owner can only read after the fact. roomyx
|
|
113
|
+
turns it into something they can watch while it runs, without changing how the
|
|
114
|
+
room works: it reads the log and serves it, and it never writes to it. The
|
|
115
|
+
dispatcher stays the log's single writer.
|
|
116
|
+
|
|
117
|
+
Start the server as part of setup, before the kickoff spawns:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
roomyx serve <logPath> --port 0
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
`--port 0` takes an ephemeral port, so several rooms can run at once without
|
|
124
|
+
colliding. It prints the bound URL and a short room ID:
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
roomyx serving /abs/path/room.md at http://127.0.0.1:41235/mcp
|
|
128
|
+
room ID: r-a1b2c3 — attach with `roomyx-client --room r-a1b2c3`
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
**Relay that room ID to the owner in the kickoff confirmation, with the attach
|
|
132
|
+
command.** That is the whole point of starting it — the owner opens the room in
|
|
133
|
+
a second terminal and watches the discussion as it happens instead of waiting
|
|
134
|
+
for your status reports. `roomyx rooms list` shows what is actually running;
|
|
135
|
+
each entry is confirmed with a real call, not just read out of the registry.
|
|
136
|
+
|
|
137
|
+
Attaching, detaching, or closing that terminal does nothing to the room. If the
|
|
138
|
+
owner never attaches, the session is unaffected.
|
|
139
|
+
|
|
140
|
+
Stop the server with `SIGINT`/`SIGTERM` when the room ends — it removes its own
|
|
141
|
+
registry entry on the way out. A server killed outright leaves a stale entry,
|
|
142
|
+
which is harmless: the next `rooms list` prunes it after a liveness check.
|
|
143
|
+
|
|
144
|
+
## Kickoff (spawn once per persona)
|
|
145
|
+
|
|
146
|
+
Spawn each participant as a separate `Agent` call (`subagent_type: general-purpose`, tools available as needed — allow `WebSearch`/`WebFetch` if the room is expected to ground claims in reality, not just riff). The kickoff prompt for each must include:
|
|
147
|
+
|
|
148
|
+
- Instruction to read their own profile file and fully embody that character.
|
|
149
|
+
- The room's goal, stated neutrally, **and the concrete success criteria/threshold** — participants should know from turn one what "the room succeeded" actually means (e.g. "we're looking for an idea that would score ~300+/500 on the 50-criteria rubric and that all of us would personally back — not just something that sounds exciting").
|
|
150
|
+
- The full initial roster (names + one-line role of every other participant), so they know who they're in the room with.
|
|
151
|
+
- **The broadcast rule, stated explicitly:** "You will receive updates containing everything said by every participant since your last turn — not just messages addressed to you. Read all of it. You may address someone specifically with @Name, but @-addressing is just a convention for clarity in the transcript, not an access filter — you already see everything regardless."
|
|
152
|
+
- **The self-moderation instruction, stated explicitly:** "You and the other participants are jointly responsible for not letting the discussion tunnel too deep into one narrow technical thread too early. If you notice this happening — including in your own last message — say so and propose broadening back out. Anyone can call this out, not just a designated moderator persona."
|
|
153
|
+
- Whether real web research is expected/required this round (say so plainly; don't leave it ambiguous).
|
|
154
|
+
- Ask for their opening contribution (a pitch, a reaction, a question — whatever fits the room's stated purpose).
|
|
155
|
+
|
|
156
|
+
Capture the `agentId` (or assigned name) returned by each spawn — this is what you'll use with `SendMessage` for every subsequent turn. Log each opening contribution to the file, in dialogue form (`**Name:** their actual words`), as it comes in.
|
|
157
|
+
|
|
158
|
+
## Turn loop
|
|
159
|
+
|
|
160
|
+
For each subsequent turn:
|
|
161
|
+
|
|
162
|
+
1. Decide whose turn it is. Options: round-robin, or reactive (whoever was just @-mentioned or most directly challenged goes next), or "whoever has something to add" if you asked participants to signal that. Mix these — a real room isn't strictly round-robin.
|
|
163
|
+
2. Compose the delta: only the messages posted since that participant's last turn (typically: everything since you last messaged them). Do not re-paste anything they already said or already received — they remember it.
|
|
164
|
+
3. Send it via `SendMessage` to their `agentId`/name, with a short prompt: "Here's what's happened since your last turn: [delta]. Your turn — react, build, refute, research, or pass."
|
|
165
|
+
4. Append their reply verbatim to the log file, prefixed with their name.
|
|
166
|
+
5. Report to the session owner after essentially every substantive exchange, not just every few turns — in practice, "frequent" means after each participant's reply that adds something new, not on a fixed cadence. Use real quotes from the transcript, not paraphrases, so the owner can judge the room's reasoning quality directly. If the owner has explicitly asked for frequent updates, treat that as the floor, not a suggestion to pace yourself against.
|
|
167
|
+
|
|
168
|
+
**Mechanical note:** `SendMessage` to a previously-spawned agent runs it in the background and returns immediately; the agent's reply arrives later as a separate task-notification event, not as this tool call's return value. Don't block waiting for it — end your turn, and act on the reply when the notification arrives. Multiple participants can be messaged in parallel this way; their replies will arrive as separate notifications, in whatever order they finish.
|
|
169
|
+
|
|
170
|
+
## Scoring & convergence protocol
|
|
171
|
+
|
|
172
|
+
Once a candidate has survived enough open debate that participants seem to be converging on it, do not declare the goal met on vibes. Run an explicit gate:
|
|
173
|
+
|
|
174
|
+
1. **Formal scoring pass.** Either assign the full criteria list to one rigorous participant to walk through point-by-point with justification and sources (as has worked well in practice — one skeptical persona producing a full numbered scorecard), or split the criteria groups across 2-3 participants for independent scoring. Log the score, the percentage, and whether it clears the threshold — verbatim, including the reasoning per group, not just the final number.
|
|
175
|
+
2. **If it fails the threshold:** this is real, useful information, not a setback to paper over. Report the score and the weakest groups honestly, then relay back to the room: does this get refined (same idea, address the specific weak criteria) or abandoned (back to search)? That's the room's call, not the dispatcher's.
|
|
176
|
+
3. **If it clears the threshold:** run an explicit convergence turn — ask each active participant a direct, individual question: "This idea scored X% against the criteria. Do you personally back it as the room's pick — yes, no, or yes-with-reservations?" Collect actual individual answers, not a paraphrased summary.
|
|
177
|
+
4. **The goal is only met when both conditions hold**: score ≥ threshold *and* the room has converged (unanimous, or an owner-defined quorum if the owner has said unanimity isn't required). A high score with an unresolved direct challenge between two participants (e.g. one hasn't answered another's pointed question yet) is not convergence — relay the open question and wait for it to resolve.
|
|
178
|
+
5. Once met, write the final archive entry (see **Archiving a finding mid-session**) explicitly noting the score and that convergence was reached, and report completion to the owner as the goal being achieved — not just "an idea was found."
|
|
179
|
+
|
|
180
|
+
## Loop until the goal is met
|
|
181
|
+
|
|
182
|
+
There is no fixed "end of session" — the room's natural rhythm is: search → propose candidate(s) → open debate → (repeat until something looks worth formally testing) → scoring & convergence gate above → either goal met (stop) or gate failed (loop back to search/refine, goal contract unchanged unless the owner edits it).
|
|
183
|
+
|
|
184
|
+
Within that loop, still close individual rounds cleanly so status is checkable at any point:
|
|
185
|
+
- An explicit "where do things stand" turn (ask each active participant for a one-line current position) if a natural pause point is hit before a formal scoring gate is warranted, or
|
|
186
|
+
- A moderator-written synthesis that honestly reports non-convergence/non-consensus if that's what happened — do not manufacture a fake consensus, and do not let a partial or informal sense of agreement substitute for the actual gate above.
|
|
187
|
+
|
|
188
|
+
Formalize any intermediate outcome (a short brief, not the raw transcript) if it's meant to feed into a next round — raw transcripts are expensive to re-read; briefs are cheap. This is separate from, and does not substitute for, the formal scoring/convergence gate required to declare the goal met.
|
|
189
|
+
|
|
190
|
+
## Things to avoid
|
|
191
|
+
|
|
192
|
+
- Do not let a "kill the same idea seven ways" cycle run past the point of diminishing returns — if independent participants converge on the same verdict from different angles, stop and move on rather than collecting a ninth confirmation.
|
|
193
|
+
- Do not silently switch a room's stated task (e.g. "adversarially test idea X" quietly becoming "keep re-litigating idea X forever" instead of pivoting to searching for a new idea once X is dead) — check back against the room's actual stated goal each round.
|
|
194
|
+
- Do not give participants write access to the shared log file, even read-only tool access that could be misused — the moderator relays and appends, always.
|
|
195
|
+
- Do not declare the goal achieved without running the explicit scoring & convergence gate above — "the room seems excited about this" or "several participants like it" is not the same as a passed threshold plus an actual individual yes from everyone.
|
|
196
|
+
- Do not quietly lower the threshold or narrow the criteria because nothing is passing — if the room is genuinely stuck, report that honestly to the owner as a status (goal not yet met, here's why) rather than softening the bar to manufacture a win.
|
package/src/cli.ts
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
import {
|
|
2
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
+
import { join, resolve } from "node:path";
|
|
3
4
|
import { serve } from "./server/serve";
|
|
4
5
|
import { init } from "./installer/init";
|
|
5
6
|
import { registerRoom, deregisterRoom, listLiveRooms } from "./installer/registry";
|
|
7
|
+
import { syncSkill } from "./installer/skill-sync";
|
|
8
|
+
import { NAMED_TARGETS, resolveTargets } from "./installer/skill-targets";
|
|
9
|
+
import { serveManagement } from "./mcp-management/server";
|
|
6
10
|
|
|
7
11
|
/**
|
|
8
|
-
* `roomyx init` / `roomyx serve
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* rules out.
|
|
12
|
+
* `roomyx init` / `roomyx serve` / `roomyx rooms list` / `roomyx mcp` /
|
|
13
|
+
* `roomyx skills sync`.
|
|
14
|
+
* The TUI is primarily `roomyx-client` (its own binary over src/client/index.ts)
|
|
15
|
+
* so the orchestrator and the TUI stay independent processes (decisions.md
|
|
16
|
+
* D-06). `roomyx client` is a thin alias that starts that same TUI in this
|
|
17
|
+
* process — a separate invocation from `serve`/`mcp`, not a shared lifetime.
|
|
15
18
|
*/
|
|
16
19
|
|
|
17
20
|
function parseFlags(args: string[]): Record<string, string | boolean> {
|
|
@@ -36,9 +39,19 @@ function defaultRegistryPath(): string {
|
|
|
36
39
|
return join(process.cwd(), ".roomyx", "rooms", "registry.json");
|
|
37
40
|
}
|
|
38
41
|
|
|
42
|
+
function defaultConfigPath(): string {
|
|
43
|
+
return join(process.cwd(), ".roomyx", "config.json");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function bundledSkillPath(): string {
|
|
47
|
+
return join(import.meta.dir, "bundled-skills", "startup-room", "SKILL.md");
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const USAGE =
|
|
51
|
+
"Usage: roomyx <init|serve <logPath>|client|mcp|rooms list|skills sync --target <claude|codex|keryx|all|path>>";
|
|
52
|
+
|
|
39
53
|
async function runInit(): Promise<void> {
|
|
40
|
-
const
|
|
41
|
-
const result = init({ cwd: process.cwd(), bundledSkillPath });
|
|
54
|
+
const result = init({ cwd: process.cwd(), bundledSkillPath: bundledSkillPath() });
|
|
42
55
|
console.log(result.created ? `Created ${result.roomyxDir}` : `${result.roomyxDir} already initialized`);
|
|
43
56
|
}
|
|
44
57
|
|
|
@@ -48,16 +61,25 @@ async function runServe(logPath: string | undefined, rest: string[]): Promise<vo
|
|
|
48
61
|
process.exit(1);
|
|
49
62
|
}
|
|
50
63
|
const flags = parseFlags(rest);
|
|
51
|
-
|
|
64
|
+
// Absolute, because the registry outlives this process's working directory:
|
|
65
|
+
// `roomyx-client` resolves rooms from wherever the person happened to run it,
|
|
66
|
+
// and a relative logPath means nothing there. The specification's registry
|
|
67
|
+
// example has always shown an absolute path; only the code disagreed.
|
|
68
|
+
const absoluteLogPath = resolve(logPath);
|
|
69
|
+
const handle = await serve(absoluteLogPath, {
|
|
52
70
|
port: flags.port !== undefined ? Number(flags.port) : undefined,
|
|
53
71
|
host: typeof flags.host === "string" ? flags.host : undefined,
|
|
54
72
|
acknowledgeNonLoopback: flags["acknowledge-non-loopback"] === true,
|
|
55
73
|
});
|
|
56
74
|
|
|
57
75
|
const registryPath = typeof flags.registry === "string" ? flags.registry : defaultRegistryPath();
|
|
58
|
-
const entry = registerRoom(registryPath, {
|
|
76
|
+
const entry = registerRoom(registryPath, {
|
|
77
|
+
port: handle.port,
|
|
78
|
+
logPath: absoluteLogPath,
|
|
79
|
+
pid: process.pid,
|
|
80
|
+
});
|
|
59
81
|
|
|
60
|
-
console.log(`roomyx serving ${
|
|
82
|
+
console.log(`roomyx serving ${absoluteLogPath} at ${handle.url}`);
|
|
61
83
|
console.log(`room ID: ${entry.id} — attach with \`roomyx-client --room ${entry.id}\``);
|
|
62
84
|
|
|
63
85
|
const shutdown = () => {
|
|
@@ -79,18 +101,103 @@ async function runRoomsList(): Promise<void> {
|
|
|
79
101
|
}
|
|
80
102
|
}
|
|
81
103
|
|
|
104
|
+
/**
|
|
105
|
+
* `roomyx skills sync --target <claude|codex|keryx|all|path> [--dry-run] [--yes]`.
|
|
106
|
+
*
|
|
107
|
+
* Without `--yes` this reports what it would do and writes nothing — the
|
|
108
|
+
* specification's wording, and D-02's requirement that landing on a real skill
|
|
109
|
+
* file be a separate, deliberate act rather than a side effect of the
|
|
110
|
+
* mechanism existing. `--dry-run` is then the same thing said explicitly.
|
|
111
|
+
*/
|
|
112
|
+
async function runSkillsSync(rest: string[]): Promise<void> {
|
|
113
|
+
const flags = parseFlags(rest);
|
|
114
|
+
const target = typeof flags.target === "string" ? flags.target : undefined;
|
|
115
|
+
if (!target) {
|
|
116
|
+
console.error(`Missing --target. Expected one of ${NAMED_TARGETS.join(", ")}, all, or a path.`);
|
|
117
|
+
process.exit(1);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const yes = flags.yes === true;
|
|
121
|
+
const dryRun = flags["dry-run"] === true || !yes;
|
|
122
|
+
const configPath = typeof flags.config === "string" ? flags.config : defaultConfigPath();
|
|
123
|
+
|
|
124
|
+
if (!existsSync(configPath)) {
|
|
125
|
+
console.error(`No ${configPath}. Run \`roomyx init\` first.`);
|
|
126
|
+
process.exit(1);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
for (const { name, path } of resolveTargets(target)) {
|
|
130
|
+
const result = syncSkill({
|
|
131
|
+
bundledSkillPath: bundledSkillPath(),
|
|
132
|
+
targetPath: path,
|
|
133
|
+
configPath,
|
|
134
|
+
dryRun,
|
|
135
|
+
yes,
|
|
136
|
+
});
|
|
137
|
+
console.log(name === path ? path : `${name}: ${path}`);
|
|
138
|
+
for (const warning of result.warnings) console.log(` warning: ${warning}`);
|
|
139
|
+
if (result.written) {
|
|
140
|
+
console.log(result.backedUpTo ? ` written (backup: ${result.backedUpTo})` : " written");
|
|
141
|
+
} else {
|
|
142
|
+
console.log(dryRun ? " would write (pass --yes to apply)" : " not written");
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
async function runMcp(rest: string[]): Promise<void> {
|
|
148
|
+
const flags = parseFlags(rest);
|
|
149
|
+
const handle = await serveManagement(
|
|
150
|
+
{
|
|
151
|
+
registryPath: typeof flags.registry === "string" ? flags.registry : defaultRegistryPath(),
|
|
152
|
+
bundledSkillPath: bundledSkillPath(),
|
|
153
|
+
configPath: typeof flags.config === "string" ? flags.config : defaultConfigPath(),
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
port: flags.port !== undefined ? Number(flags.port) : undefined,
|
|
157
|
+
host: typeof flags.host === "string" ? flags.host : undefined,
|
|
158
|
+
acknowledgeNonLoopback: flags["acknowledge-non-loopback"] === true,
|
|
159
|
+
},
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
console.log(`roomyx mcp listening at ${handle.url}`);
|
|
163
|
+
console.log("tools: roomyx.rooms.list, roomyx.skills.sync");
|
|
164
|
+
|
|
165
|
+
const shutdown = () => {
|
|
166
|
+
void handle.close().then(() => process.exit(0));
|
|
167
|
+
};
|
|
168
|
+
process.on("SIGINT", shutdown);
|
|
169
|
+
process.on("SIGTERM", shutdown);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** package.json ships in the tarball (see `files`), so this resolves for an installed copy too. */
|
|
173
|
+
function version(): string {
|
|
174
|
+
const manifest = JSON.parse(readFileSync(join(import.meta.dir, "..", "package.json"), "utf8")) as {
|
|
175
|
+
version: string;
|
|
176
|
+
};
|
|
177
|
+
return manifest.version;
|
|
178
|
+
}
|
|
179
|
+
|
|
82
180
|
async function main(): Promise<void> {
|
|
83
181
|
const [command, ...rest] = process.argv.slice(2);
|
|
84
182
|
|
|
85
|
-
if (command === "
|
|
183
|
+
if (command === "--version" || command === "-v") {
|
|
184
|
+
console.log(version());
|
|
185
|
+
} else if (command === "init") {
|
|
86
186
|
await runInit();
|
|
87
187
|
} else if (command === "serve") {
|
|
88
188
|
await runServe(rest[0], rest.slice(1));
|
|
189
|
+
} else if (command === "client") {
|
|
190
|
+
const { runClient } = await import("./client/index");
|
|
191
|
+
await runClient(rest);
|
|
192
|
+
} else if (command === "mcp") {
|
|
193
|
+
await runMcp(rest);
|
|
89
194
|
} else if (command === "rooms" && rest[0] === "list") {
|
|
90
195
|
await runRoomsList();
|
|
196
|
+
} else if (command === "skills" && rest[0] === "sync") {
|
|
197
|
+
await runSkillsSync(rest.slice(1));
|
|
91
198
|
} else {
|
|
92
|
-
console.error(
|
|
93
|
-
console.error("The terminal UI is a separate binary: roomyx-client [--room <id>]");
|
|
199
|
+
console.error(USAGE);
|
|
200
|
+
console.error("The terminal UI is also a separate binary: roomyx-client [--room <id>]");
|
|
94
201
|
process.exit(1);
|
|
95
202
|
}
|
|
96
203
|
}
|
|
@@ -8,6 +8,8 @@ export class StatusBar {
|
|
|
8
8
|
readonly node: TextRenderable;
|
|
9
9
|
private goalStatement = "";
|
|
10
10
|
private status: ConnectionStatus = "connecting";
|
|
11
|
+
/** Takes over the line while an owner command is being composed or answered. */
|
|
12
|
+
private notice: string | null = null;
|
|
11
13
|
|
|
12
14
|
constructor(ctx: RenderContext) {
|
|
13
15
|
this.node = new TextRenderable(ctx, { content: "", height: 1 });
|
|
@@ -24,7 +26,17 @@ export class StatusBar {
|
|
|
24
26
|
this.render();
|
|
25
27
|
}
|
|
26
28
|
|
|
29
|
+
/** Pass null to hand the line back to the goal statement. */
|
|
30
|
+
setNotice(notice: string | null): void {
|
|
31
|
+
this.notice = notice;
|
|
32
|
+
this.render();
|
|
33
|
+
}
|
|
34
|
+
|
|
27
35
|
private render(): void {
|
|
36
|
+
if (this.notice !== null) {
|
|
37
|
+
this.node.content = this.notice;
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
28
40
|
const statusLabel = { connecting: "connecting…", connected: "connected", disconnected: "disconnected — retrying" }[
|
|
29
41
|
this.status
|
|
30
42
|
];
|
package/src/client/index.ts
CHANGED
|
@@ -6,6 +6,8 @@ import { ChatView } from "./screens/chat-view";
|
|
|
6
6
|
import { AgentModal } from "./screens/agent-modal";
|
|
7
7
|
import type { RosterEntry } from "../log/types";
|
|
8
8
|
import { resolveConnectionUrl } from "../installer/resolve-connection";
|
|
9
|
+
import { IDLE, ownerPromptLine, stepOwnerPrompt } from "./owner-prompt";
|
|
10
|
+
import type { OwnerPromptState } from "./owner-prompt";
|
|
9
11
|
|
|
10
12
|
function parseFlags(args: string[]): Record<string, string> {
|
|
11
13
|
const flags: Record<string, string> = {};
|
|
@@ -19,8 +21,8 @@ function parseFlags(args: string[]): Record<string, string> {
|
|
|
19
21
|
return flags;
|
|
20
22
|
}
|
|
21
23
|
|
|
22
|
-
async function
|
|
23
|
-
const flags = parseFlags(
|
|
24
|
+
export async function runClient(argv: string[] = process.argv.slice(2)): Promise<void> {
|
|
25
|
+
const flags = parseFlags(argv);
|
|
24
26
|
const registryPath = flags["registry"] ?? join(process.cwd(), ".roomyx", "rooms", "registry.json");
|
|
25
27
|
|
|
26
28
|
const resolved = await resolveConnectionUrl({
|
|
@@ -73,11 +75,48 @@ async function main(): Promise<void> {
|
|
|
73
75
|
);
|
|
74
76
|
roomClient.start();
|
|
75
77
|
|
|
78
|
+
let prompt: OwnerPromptState = IDLE;
|
|
79
|
+
|
|
80
|
+
function showPrompt(): void {
|
|
81
|
+
chatView.statusBar.setNotice(ownerPromptLine(prompt));
|
|
82
|
+
}
|
|
83
|
+
|
|
76
84
|
renderer.keyInput.on("keypress", (event) => {
|
|
77
85
|
if (modal.isVisible()) {
|
|
78
86
|
if (event.name === "escape") modal.hide();
|
|
79
87
|
return;
|
|
80
88
|
}
|
|
89
|
+
|
|
90
|
+
// The prompt owns the keyboard while it is open — otherwise typing "q"
|
|
91
|
+
// into a veto would quit the client.
|
|
92
|
+
if (prompt.stage !== "idle" || (event.name === "o" && !event.ctrl)) {
|
|
93
|
+
const stepped = stepOwnerPrompt(prompt, event);
|
|
94
|
+
prompt = stepped.state;
|
|
95
|
+
showPrompt();
|
|
96
|
+
if (stepped.action.type === "send") {
|
|
97
|
+
const { kind, body } = stepped.action;
|
|
98
|
+
chatView.statusBar.setNotice(`${kind}: sending…`);
|
|
99
|
+
void roomClient
|
|
100
|
+
.postOwnerCommand(kind, body)
|
|
101
|
+
.then((result) => {
|
|
102
|
+
chatView.statusBar.setNotice(
|
|
103
|
+
result.accepted
|
|
104
|
+
? `${kind} accepted${result.reason ? ` — ${result.reason}` : ""}`
|
|
105
|
+
: `${kind} not accepted — ${result.reason ?? "no reason given"}`,
|
|
106
|
+
);
|
|
107
|
+
})
|
|
108
|
+
.catch((error: unknown) => {
|
|
109
|
+
chatView.statusBar.setNotice(
|
|
110
|
+
`${kind} failed — ${error instanceof Error ? error.message : String(error)}`,
|
|
111
|
+
);
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Any other key clears a leftover result line and falls through.
|
|
118
|
+
chatView.statusBar.setNotice(null);
|
|
119
|
+
|
|
81
120
|
if (event.name === "up") chatView.roster.moveSelection(-1);
|
|
82
121
|
else if (event.name === "down") chatView.roster.moveSelection(1);
|
|
83
122
|
else if (event.name === "return") chatView.roster.confirmSelection();
|
|
@@ -90,10 +129,12 @@ async function main(): Promise<void> {
|
|
|
90
129
|
});
|
|
91
130
|
}
|
|
92
131
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
132
|
+
if (import.meta.main) {
|
|
133
|
+
runClient().catch((error) => {
|
|
134
|
+
// The message, not the object: a stack trace dumped at someone who simply
|
|
135
|
+
// hasn't started a room yet reads as a crash, and matches how cli.ts already
|
|
136
|
+
// reports its own failures.
|
|
137
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
138
|
+
process.exit(1);
|
|
139
|
+
});
|
|
140
|
+
}
|
package/src/client/mcp-client.ts
CHANGED
|
@@ -101,6 +101,15 @@ export class RoomClient {
|
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
/**
|
|
105
|
+
* Sends an owner command to the room's dispatcher. Not a write to the log —
|
|
106
|
+
* the server forwards it and answers with whatever the dispatcher said,
|
|
107
|
+
* including `accepted: false` when no dispatcher is attached at all.
|
|
108
|
+
*/
|
|
109
|
+
async postOwnerCommand(kind: string, body: string): Promise<{ accepted: boolean; reason?: string }> {
|
|
110
|
+
return this.callTool<{ accepted: boolean; reason?: string }>("room.post_owner_command", { kind, body });
|
|
111
|
+
}
|
|
112
|
+
|
|
104
113
|
private async callTool<T>(name: string, args: Record<string, unknown>): Promise<T> {
|
|
105
114
|
if (!this.client) throw new Error("not connected");
|
|
106
115
|
const result = await this.client.callTool({ name, arguments: args });
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { OWNER_COMMAND_KINDS } from "../server/index";
|
|
2
|
+
import type { OwnerCommandKind } from "../server/index";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The owner-command prompt, as a pure state machine.
|
|
6
|
+
*
|
|
7
|
+
* Kept separate from `index.ts` because that file cannot run without a real
|
|
8
|
+
* terminal: it builds a renderer on import. The composing logic — which keys
|
|
9
|
+
* open the prompt, what a half-typed command looks like, when Enter actually
|
|
10
|
+
* sends — is the part worth testing, so it lives where a test can reach it.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export type OwnerPromptState =
|
|
14
|
+
| { stage: "idle" }
|
|
15
|
+
| { stage: "kind" }
|
|
16
|
+
| { stage: "body"; kind: OwnerCommandKind; buffer: string };
|
|
17
|
+
|
|
18
|
+
export type OwnerPromptAction =
|
|
19
|
+
| { type: "none" }
|
|
20
|
+
| { type: "cancel" }
|
|
21
|
+
| { type: "send"; kind: OwnerCommandKind; body: string };
|
|
22
|
+
|
|
23
|
+
export interface PromptKey {
|
|
24
|
+
name: string;
|
|
25
|
+
sequence?: string;
|
|
26
|
+
ctrl?: boolean;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** First letter of each kind, which is what the prompt asks for. */
|
|
30
|
+
const KIND_BY_LETTER: Record<string, OwnerCommandKind> = {
|
|
31
|
+
v: "veto",
|
|
32
|
+
c: "constraint",
|
|
33
|
+
a: "add_participant",
|
|
34
|
+
g: "goal_edit",
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const IDLE: OwnerPromptState = { stage: "idle" };
|
|
38
|
+
|
|
39
|
+
/** The status line to show for a state, or null to leave the bar alone. */
|
|
40
|
+
export function ownerPromptLine(state: OwnerPromptState): string | null {
|
|
41
|
+
if (state.stage === "idle") return null;
|
|
42
|
+
if (state.stage === "kind") {
|
|
43
|
+
return "owner command — (v)eto (c)onstraint (a)dd participant (g)oal edit, Esc to cancel";
|
|
44
|
+
}
|
|
45
|
+
return `${state.kind}: ${state.buffer}▌ (Enter to send, Esc to cancel)`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function isPrintable(key: PromptKey): boolean {
|
|
49
|
+
return !key.ctrl && typeof key.sequence === "string" && key.sequence.length === 1 && key.sequence >= " ";
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function stepOwnerPrompt(
|
|
53
|
+
state: OwnerPromptState,
|
|
54
|
+
key: PromptKey,
|
|
55
|
+
): { state: OwnerPromptState; action: OwnerPromptAction } {
|
|
56
|
+
const none = (next: OwnerPromptState) => ({ state: next, action: { type: "none" } as OwnerPromptAction });
|
|
57
|
+
|
|
58
|
+
if (state.stage === "idle") {
|
|
59
|
+
// `o` opens the prompt. Everything else belongs to the view's own keys.
|
|
60
|
+
return key.name === "o" && !key.ctrl ? none({ stage: "kind" }) : none(state);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (key.name === "escape") {
|
|
64
|
+
return { state: IDLE, action: { type: "cancel" } };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (state.stage === "kind") {
|
|
68
|
+
const kind = KIND_BY_LETTER[key.sequence ?? ""];
|
|
69
|
+
// An unrecognised letter is ignored rather than cancelling: a typo should
|
|
70
|
+
// not throw away a prompt the person deliberately opened.
|
|
71
|
+
return kind ? none({ stage: "body", kind, buffer: "" }) : none(state);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (key.name === "return") {
|
|
75
|
+
// An empty body is not a command. Stay put rather than sending nothing.
|
|
76
|
+
if (state.buffer.trim().length === 0) return none(state);
|
|
77
|
+
return { state: IDLE, action: { type: "send", kind: state.kind, body: state.buffer.trim() } };
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (key.name === "backspace") {
|
|
81
|
+
return none({ ...state, buffer: state.buffer.slice(0, -1) });
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (isPrintable(key)) {
|
|
85
|
+
return none({ ...state, buffer: state.buffer + key.sequence });
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return none(state);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export { OWNER_COMMAND_KINDS };
|
|
92
|
+
export type { OwnerCommandKind };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
import { copyFileSync, existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { copyFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { dirname } from "node:path";
|
|
3
4
|
|
|
4
5
|
export interface SyncOptions {
|
|
5
6
|
bundledSkillPath: string;
|
|
@@ -84,6 +85,11 @@ export function syncSkill(options: SyncOptions): SyncResult {
|
|
|
84
85
|
copyFileSync(options.targetPath, backedUpTo);
|
|
85
86
|
}
|
|
86
87
|
|
|
88
|
+
// A named target's runtime may be installed without ever having had a
|
|
89
|
+
// startup-room skill, so its directory need not exist. Same failure mode the
|
|
90
|
+
// registry had: the write is ready for a missing file but not a missing
|
|
91
|
+
// directory.
|
|
92
|
+
mkdirSync(dirname(options.targetPath), { recursive: true });
|
|
87
93
|
writeFileSync(options.targetPath, bundledContent);
|
|
88
94
|
writeConfig(options.configPath, {
|
|
89
95
|
...config,
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { homedir } from "node:os";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The runtimes `roomyx skills sync --target` knows by name. Anything else the
|
|
6
|
+
* flag is given is treated as a literal path, which is what the tests use —
|
|
7
|
+
* D-02 requires the mechanism to be exercised against fixtures, never against
|
|
8
|
+
* a real `~/.claude/skills/...` file.
|
|
9
|
+
*/
|
|
10
|
+
export const NAMED_TARGETS = ["claude", "codex", "keryx"] as const;
|
|
11
|
+
|
|
12
|
+
export type NamedSkillTarget = (typeof NAMED_TARGETS)[number];
|
|
13
|
+
|
|
14
|
+
export function isNamedTarget(value: string): value is NamedSkillTarget {
|
|
15
|
+
return (NAMED_TARGETS as readonly string[]).includes(value);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Where each runtime keeps the `startup-room` skill.
|
|
20
|
+
*
|
|
21
|
+
* Claude and Codex both scope skills to the user, under a home directory.
|
|
22
|
+
* keryx scopes them to the project instead: `.metaproject/project-skills/` is
|
|
23
|
+
* where a project's own skills live, as distinct from `.metaproject/skills/`,
|
|
24
|
+
* which is keryx's own bundled set and not ours to write into.
|
|
25
|
+
*/
|
|
26
|
+
export function pathForNamedTarget(target: NamedSkillTarget, cwd: string = process.cwd()): string {
|
|
27
|
+
switch (target) {
|
|
28
|
+
case "claude":
|
|
29
|
+
return join(homedir(), ".claude", "skills", "startup-room", "SKILL.md");
|
|
30
|
+
case "codex":
|
|
31
|
+
return join(homedir(), ".codex", "skills", "startup-room", "SKILL.md");
|
|
32
|
+
case "keryx":
|
|
33
|
+
return join(cwd, ".metaproject", "project-skills", "startup-room", "SKILL.md");
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Turns whatever `--target` was given into concrete paths. `all` fans out to
|
|
39
|
+
* every named runtime; a name resolves to that runtime's path; anything else
|
|
40
|
+
* is passed through as a literal path.
|
|
41
|
+
*/
|
|
42
|
+
export function resolveTargets(
|
|
43
|
+
target: string,
|
|
44
|
+
cwd: string = process.cwd(),
|
|
45
|
+
): { name: string; path: string }[] {
|
|
46
|
+
if (target === "all") {
|
|
47
|
+
return NAMED_TARGETS.map((name) => ({ name, path: pathForNamedTarget(name, cwd) }));
|
|
48
|
+
}
|
|
49
|
+
if (isNamedTarget(target)) {
|
|
50
|
+
return [{ name: target, path: pathForNamedTarget(target, cwd) }];
|
|
51
|
+
}
|
|
52
|
+
return [{ name: target, path: target }];
|
|
53
|
+
}
|
|
@@ -4,6 +4,7 @@ import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/
|
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { listLiveRooms } from "../installer/registry";
|
|
6
6
|
import { syncSkill } from "../installer/skill-sync";
|
|
7
|
+
import { NAMED_TARGETS, resolveTargets } from "../installer/skill-targets";
|
|
7
8
|
|
|
8
9
|
export interface ManagementOptions {
|
|
9
10
|
registryPath: string;
|
|
@@ -12,8 +13,10 @@ export interface ManagementOptions {
|
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
export interface ManagementServeOptions {
|
|
15
|
-
port
|
|
16
|
+
/** Defaults to 4320 so it does not collide with `roomyx serve` (4319). 0 selects an ephemeral port. */
|
|
17
|
+
port?: number;
|
|
16
18
|
host?: string;
|
|
19
|
+
acknowledgeNonLoopback?: boolean;
|
|
17
20
|
}
|
|
18
21
|
|
|
19
22
|
/**
|
|
@@ -41,29 +44,47 @@ export function createManagementMcpServer(options: ManagementOptions): McpServer
|
|
|
41
44
|
"roomyx.skills.sync",
|
|
42
45
|
{
|
|
43
46
|
title: "Sync the bundled startup-room skill",
|
|
44
|
-
description:
|
|
47
|
+
description:
|
|
48
|
+
"Diffs/backs-up/writes the bundled skill into a target (see decisions.md D-02 for safety rules).",
|
|
45
49
|
inputSchema: {
|
|
46
|
-
|
|
50
|
+
target: z
|
|
51
|
+
.enum([...NAMED_TARGETS, "all"])
|
|
52
|
+
.optional()
|
|
53
|
+
.describe("A runtime by name, or `all`. Use targetPath instead for a literal path."),
|
|
54
|
+
targetPath: z.string().min(1).optional().describe("A literal path. Takes precedence over target."),
|
|
47
55
|
dryRun: z.boolean().optional(),
|
|
48
56
|
yes: z.boolean().optional(),
|
|
49
57
|
},
|
|
50
58
|
},
|
|
51
|
-
async ({ targetPath, dryRun, yes }) =>
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
59
|
+
async ({ target, targetPath, dryRun, yes }) => {
|
|
60
|
+
// One of the two is required, and neither can be marked required in the
|
|
61
|
+
// schema without excluding the other.
|
|
62
|
+
if (!target && !targetPath) {
|
|
63
|
+
return {
|
|
64
|
+
content: [
|
|
65
|
+
{
|
|
66
|
+
type: "text",
|
|
67
|
+
text: JSON.stringify({
|
|
68
|
+
error: `Pass either target (${[...NAMED_TARGETS, "all"].join(", ")}) or targetPath.`,
|
|
69
|
+
}),
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
const targets = targetPath ? [{ name: targetPath, path: targetPath }] : resolveTargets(target as string);
|
|
75
|
+
const results = targets.map(({ name, path }) => ({
|
|
76
|
+
target: name,
|
|
77
|
+
path,
|
|
78
|
+
...syncSkill({
|
|
79
|
+
bundledSkillPath: options.bundledSkillPath,
|
|
80
|
+
targetPath: path,
|
|
81
|
+
configPath: options.configPath,
|
|
82
|
+
dryRun,
|
|
83
|
+
yes,
|
|
84
|
+
}),
|
|
85
|
+
}));
|
|
86
|
+
return { content: [{ type: "text", text: JSON.stringify(results) }] };
|
|
87
|
+
},
|
|
67
88
|
);
|
|
68
89
|
|
|
69
90
|
return server;
|
|
@@ -75,39 +96,80 @@ export interface ManagementHandle {
|
|
|
75
96
|
close(): Promise<void>;
|
|
76
97
|
}
|
|
77
98
|
|
|
78
|
-
|
|
99
|
+
const LOOPBACK_HOSTS = new Set(["127.0.0.1", "localhost", "::1"]);
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Binds createManagementMcpServer() to a loopback HTTP transport, same
|
|
103
|
+
* multi-session pattern as ../server/serve.ts: one StreamableHTTP transport
|
|
104
|
+
* only ever completes a single initialize handshake, so each new session
|
|
105
|
+
* gets its own transport + McpServer pair.
|
|
106
|
+
*/
|
|
79
107
|
export async function serveManagement(
|
|
80
108
|
options: ManagementOptions,
|
|
81
109
|
serveOptions: ManagementServeOptions,
|
|
82
110
|
): Promise<ManagementHandle> {
|
|
83
111
|
const host = serveOptions.host ?? "127.0.0.1";
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
112
|
+
if (!LOOPBACK_HOSTS.has(host) && !serveOptions.acknowledgeNonLoopback) {
|
|
113
|
+
throw new Error(
|
|
114
|
+
`Refusing to bind roomyx mcp to non-loopback host "${host}" without --acknowledge-non-loopback.`,
|
|
115
|
+
);
|
|
116
|
+
}
|
|
87
117
|
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
118
|
+
const sessions = new Map<string, StreamableHTTPServerTransport>();
|
|
119
|
+
|
|
120
|
+
async function createSession(): Promise<StreamableHTTPServerTransport> {
|
|
121
|
+
const transport = new StreamableHTTPServerTransport({
|
|
122
|
+
sessionIdGenerator: () => crypto.randomUUID(),
|
|
123
|
+
onsessioninitialized: (sessionId) => {
|
|
124
|
+
sessions.set(sessionId, transport);
|
|
125
|
+
},
|
|
126
|
+
onsessionclosed: (sessionId) => {
|
|
127
|
+
sessions.delete(sessionId);
|
|
128
|
+
},
|
|
92
129
|
});
|
|
130
|
+
const mcpServer = createManagementMcpServer(options);
|
|
131
|
+
await mcpServer.connect(transport);
|
|
132
|
+
return transport;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const httpServer = createServer((req, res) => {
|
|
136
|
+
const sessionIdHeader = req.headers["mcp-session-id"];
|
|
137
|
+
const sessionId = typeof sessionIdHeader === "string" ? sessionIdHeader : undefined;
|
|
138
|
+
const existing = sessionId ? sessions.get(sessionId) : undefined;
|
|
139
|
+
|
|
140
|
+
const transportPromise = existing ? Promise.resolve(existing) : createSession();
|
|
141
|
+
transportPromise
|
|
142
|
+
.then((transport) => transport.handleRequest(req, res))
|
|
143
|
+
.catch((error) => {
|
|
144
|
+
if (!res.headersSent) res.writeHead(500, { "content-type": "application/json" });
|
|
145
|
+
res.end(JSON.stringify({ error: error instanceof Error ? error.message : String(error) }));
|
|
146
|
+
});
|
|
93
147
|
});
|
|
94
148
|
|
|
149
|
+
const port = serveOptions.port ?? 4320;
|
|
95
150
|
try {
|
|
96
151
|
await new Promise<void>((resolve, reject) => {
|
|
97
152
|
httpServer.once("error", reject);
|
|
98
|
-
httpServer.listen(
|
|
153
|
+
httpServer.listen(port, host, () => resolve());
|
|
99
154
|
});
|
|
100
155
|
} catch (error) {
|
|
101
|
-
await
|
|
156
|
+
await Promise.all([...sessions.values()].map((t) => t.close().catch(() => undefined)));
|
|
102
157
|
throw error;
|
|
103
158
|
}
|
|
104
159
|
|
|
105
160
|
const address = httpServer.address();
|
|
106
|
-
const actualPort = typeof address === "object" && address !== null ? address.port :
|
|
161
|
+
const actualPort = typeof address === "object" && address !== null ? address.port : port;
|
|
107
162
|
|
|
108
163
|
return {
|
|
109
164
|
url: `http://${host}:${actualPort}/mcp`,
|
|
110
165
|
port: actualPort,
|
|
111
|
-
close: () =>
|
|
166
|
+
close: () =>
|
|
167
|
+
new Promise<void>((resolve, reject) => {
|
|
168
|
+
httpServer.close(async (error) => {
|
|
169
|
+
await Promise.all([...sessions.values()].map((t) => t.close().catch(() => undefined)));
|
|
170
|
+
if (error) reject(error);
|
|
171
|
+
else resolve();
|
|
172
|
+
});
|
|
173
|
+
}),
|
|
112
174
|
};
|
|
113
175
|
}
|
package/src/server/index.ts
CHANGED
|
@@ -4,13 +4,42 @@ import { getStateTool } from "./tools/get-state";
|
|
|
4
4
|
import { getTranscriptTool } from "./tools/get-transcript";
|
|
5
5
|
import { getAgentDetailTool } from "./tools/get-agent-detail";
|
|
6
6
|
|
|
7
|
+
export const OWNER_COMMAND_KINDS = ["veto", "constraint", "add_participant", "goal_edit"] as const;
|
|
8
|
+
|
|
9
|
+
export type OwnerCommandKind = (typeof OWNER_COMMAND_KINDS)[number];
|
|
10
|
+
|
|
11
|
+
export interface OwnerCommand {
|
|
12
|
+
kind: OwnerCommandKind;
|
|
13
|
+
body: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface OwnerCommandResult {
|
|
17
|
+
accepted: boolean;
|
|
18
|
+
/** Why it was not accepted, or how the dispatcher took it. */
|
|
19
|
+
reason?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface RoomMcpServerOptions {
|
|
23
|
+
/**
|
|
24
|
+
* Supplied by the dispatcher that embeds this server. `room.post_owner_command`
|
|
25
|
+
* hands the command to it and returns whatever it says.
|
|
26
|
+
*
|
|
27
|
+
* There is deliberately no default that writes anywhere. D-01 makes the
|
|
28
|
+
* dispatcher the log's single writer, and D-02 explicitly rejected the
|
|
29
|
+
* obvious shortcut — a second, home-grown command file for the dispatcher to
|
|
30
|
+
* poll. So with no handler attached the tool exists and refuses, which is
|
|
31
|
+
* the honest answer for a bare `roomyx serve`: nothing is dispatching, and
|
|
32
|
+
* pretending a command was accepted would be worse than saying so.
|
|
33
|
+
*/
|
|
34
|
+
onOwnerCommand?: (command: OwnerCommand) => OwnerCommandResult | Promise<OwnerCommandResult>;
|
|
35
|
+
}
|
|
36
|
+
|
|
7
37
|
/**
|
|
8
|
-
* Builds the roomyx MCP server for a given room log file.
|
|
9
|
-
*
|
|
10
|
-
* `room.post_owner_command`,
|
|
11
|
-
* package; see docs/requirements/roomyx/).
|
|
38
|
+
* Builds the roomyx MCP server for a given room log file. Nothing here writes
|
|
39
|
+
* to `logPath` — not the three read tools (R2-R4, AC4), and not
|
|
40
|
+
* `room.post_owner_command`, which only forwards to the dispatcher (R5, D-01).
|
|
12
41
|
*/
|
|
13
|
-
export function createRoomMcpServer(logPath: string): McpServer {
|
|
42
|
+
export function createRoomMcpServer(logPath: string, options: RoomMcpServerOptions = {}): McpServer {
|
|
14
43
|
const server = new McpServer({ name: "roomyx", version: "0.1.0" });
|
|
15
44
|
|
|
16
45
|
server.registerTool(
|
|
@@ -48,5 +77,28 @@ export function createRoomMcpServer(logPath: string): McpServer {
|
|
|
48
77
|
}),
|
|
49
78
|
);
|
|
50
79
|
|
|
80
|
+
server.registerTool(
|
|
81
|
+
"room.post_owner_command",
|
|
82
|
+
{
|
|
83
|
+
title: "Post an owner command",
|
|
84
|
+
description:
|
|
85
|
+
"Hands a veto / constraint / add_participant / goal_edit to the dispatcher. Never writes to the room log itself.",
|
|
86
|
+
inputSchema: {
|
|
87
|
+
kind: z.enum(OWNER_COMMAND_KINDS),
|
|
88
|
+
body: z.string().min(1),
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
async ({ kind, body }) => {
|
|
92
|
+
const result: OwnerCommandResult = options.onOwnerCommand
|
|
93
|
+
? await options.onOwnerCommand({ kind, body })
|
|
94
|
+
: {
|
|
95
|
+
accepted: false,
|
|
96
|
+
reason:
|
|
97
|
+
"No dispatcher is attached to this server, so there is nothing to act on the command. A room served by `roomyx serve` alone is read-only; owner commands need the orchestrator that runs the room to embed this server and handle them.",
|
|
98
|
+
};
|
|
99
|
+
return { content: [{ type: "text", text: JSON.stringify(result) }] };
|
|
100
|
+
},
|
|
101
|
+
);
|
|
102
|
+
|
|
51
103
|
return server;
|
|
52
104
|
}
|
package/src/server/serve.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { createServer } from "node:http";
|
|
2
2
|
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
3
3
|
import { createRoomMcpServer } from "./index";
|
|
4
|
+
import type { RoomMcpServerOptions } from "./index";
|
|
4
5
|
|
|
5
6
|
const LOOPBACK_HOSTS = new Set(["127.0.0.1", "localhost", "::1"]);
|
|
6
7
|
|
|
7
|
-
export interface ServeOptions {
|
|
8
|
+
export interface ServeOptions extends RoomMcpServerOptions {
|
|
8
9
|
/** Defaults to 4319 (specification.md's default). 0 selects an ephemeral port. */
|
|
9
10
|
port?: number;
|
|
10
11
|
host?: string;
|
|
@@ -51,7 +52,7 @@ export async function serve(logPath: string, options: ServeOptions): Promise<Ser
|
|
|
51
52
|
sessions.delete(sessionId);
|
|
52
53
|
},
|
|
53
54
|
});
|
|
54
|
-
const mcpServer = createRoomMcpServer(logPath);
|
|
55
|
+
const mcpServer = createRoomMcpServer(logPath, { onOwnerCommand: options.onOwnerCommand });
|
|
55
56
|
await mcpServer.connect(transport);
|
|
56
57
|
return transport;
|
|
57
58
|
}
|