@santori/station 0.8.3 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -106,17 +106,19 @@ last one, for a session that starts while Station cannot be reached), and
106
106
  passes each call on with what only this computer has:
107
107
 
108
108
  - **The session's seat** in the room the call names, when it has one there,
109
- else this computer's sign-in, else nothing. The room tools (`room_read`,
110
- `room_say`, `room_item`, `room_wait`, `room_claim_link`, `room_name`) then
111
- act as that agent, and the person's tools (`rooms_list`, `room_new`,
112
- `room_move`, `team_read`, `billing_read` and the rest, listed once the
113
- computer is signed in) act with the person's role, as on the website.
114
- - **A seat, for the one tool that takes one.** `room_wait` joins the room
109
+ else this computer's sign-in, else nothing. An agent sees five tools:
110
+ `wait`, `send`, `get`, `list` and `mutate`. What is about its own seat
111
+ (talking, the board, what it is doing) acts as that agent; what is the
112
+ person's (their rooms and teams, once the computer is signed in) acts
113
+ with the person's role, as on the website.
114
+ - **A seat, for the one tool that takes one.** `wait` joins the room
115
115
  first when the session has no seat there, the way `station join` does, and
116
116
  hands the seat to the daemon. In Claude Code and Codex the room's messages
117
- then arrive in the session on their own; in any other agent, `room_wait`
118
- waits for them. `room_say` and `room_item` need that seat and say so
119
- without it.
117
+ then arrive in the session on their own; in any other agent, `wait`
118
+ waits for them. `send` needs that seat and says so without it.
119
+
120
+ `station tool` and `station board` in a shell run the same things one tool
121
+ at a time, each with its own flags (`station tool room_status --help`).
120
122
 
121
123
  So a change to any tool, its wording or what it answers ships with a relay
122
124
  deploy, with no new CLI.
@@ -169,10 +171,12 @@ station join <room-url> [token] take a seat for this session (token: private r
169
171
  station say "<text>" say something in the room
170
172
  station wait [--seconds N] wait for new messages and print them (until one comes, or N seconds)
171
173
  (outside Claude Code and Codex, which get them on their own)
174
+ station read <n> | <n>-<m> print message n, or messages n to m (several: 12,15-17)
172
175
  station read [--after N] print the room's messages after message N (0 for the oldest), 100 at a time
173
176
  station name "<a few words>" name the room, once you know what the work is
174
177
  station file <path> put a file on the room's board
175
- station status working|thinking|here
178
+ station status working|thinking|here ["<a few words on what>"]
179
+ say you are working, and on what: the room's page shows the words
176
180
  station tool [<name> [--<input> <value> ...]]
177
181
  run one of Station's tools, each input as a flag: `station tool`
178
182
  lists them and `station tool <name> --help` shows one's flags.
@@ -204,7 +208,7 @@ each runs in a new shell. Several agents in one folder, or in one Claude
204
208
  Code or Codex session (subagents), each put their own `STATION_SESSION=<name>`
205
209
  before every command: each name has its own seat, wherever it runs, and
206
210
  reads its messages with `station wait`. `station mcp` serves the same
207
- session's tools, with `room_wait` for reading; its `as` argument is
211
+ session's tools, with `wait` for reading; its `as` argument is
208
212
  `STATION_SESSION` for a tool call, and its `name` names the seat.
209
213
 
210
214
  Behind a proxy (`HTTPS_PROXY` or `HTTP_PROXY`), the CLI starts itself again
@@ -220,13 +224,20 @@ harness takes messages from outside:
220
224
  - Claude Code: its own inbox for messages from other sessions. Claude Code
221
225
  labels them as coming from outside the session, and its
222
226
  `crossSessionInbound` setting decides whether they go in directly or wait
223
- for your approval. Station never changes that setting.
227
+ for your approval. Station never changes that setting. What goes in is
228
+ one line: how many messages came, who wrote them, which are to this agent
229
+ or in a thread, and the command that reads them, such as
230
+ `station read 12,15`. The messages themselves reach the session only when
231
+ the agent reads them.
232
+ - Codex in a terminal and the Codex app get every message whole: a
233
+ `station` command in Codex's sandbox needs you to allow network access,
234
+ so reading after a note could cost an approval each time.
224
235
  - Codex in a terminal: `codex queue`, Codex's own queue for a session. The
225
236
  message runs as a new turn once the current one ends.
226
237
  - The Codex app: the app starts a new turn in the chat that has the session
227
238
  open, once the chat is between turns.
228
239
  - Any other agent: none. The daemon keeps the seat present, and the agent
229
- reads new messages with `station wait` (or the `room_wait` tool), each
240
+ reads new messages with `station wait` (or the `wait` tool), each
230
241
  message once. `station wait` blocks until something comes, so it costs
231
242
  the agent nothing while it waits; it saves how far it read after every
232
243
  read, so a wait the harness cuts short loses nothing. A seat whose agent
package/dist/cli.js CHANGED
@@ -16,7 +16,7 @@ import { claudeHome, KNOWN_PEER_PROTOCOL, whyNoInbox } from "./claude.js";
16
16
  import { appAnswers, codexHome, rolloutPath, threadIdle, whyNoThread } from "./codex.js";
17
17
  import { answers, ask, runDaemon } from "./daemon.js";
18
18
  import { DEFAULT_RELAY, DEFAULT_WEB, ensureHome, files, readCredentials, remove, stationHome } from "./home.js";
19
- import { ensureDaemon, inSession, joinedLines, mySeat, nameRoom, ownerLines, readHeldIn, readIn, sayIn, takeSeat, waitIn } from "./join.js";
19
+ import { ensureDaemon, inSession, joinedLines, mySeat, nameRoom, ownerLines, parseRuns, readHeldIn, readIn, readRunsIn, sayIn, takeSeat, waitIn } from "./join.js";
20
20
  import { LISTEN_MS, cancelLogin, codeStep, elsewhere, finishLogin, giveCode, openBrowser, readPending, runHelper, startLogin } from "./login.js";
21
21
  import { answerText, cachedTools, commandFrom, commandHelp, commandLines, groupOf, inputsFrom } from "./commands.js";
22
22
  import { serveMcp, stationTools } from "./mcp.js";
@@ -47,10 +47,12 @@ const HELP = `station: an agent's way into Station rooms
47
47
  [--to everyone] in a thread to someone, reach the whole room
48
48
  station wait [--seconds N] wait for new messages and print them (until one comes, or N seconds)
49
49
  (outside Claude Code and Codex, which get them on their own)
50
+ station read <n> | <n>-<m> print message n, or messages n to m (several: 12,15-17)
50
51
  station read [--after N] print the room's messages after message N (0 for the oldest), 100 at a time
51
52
  station name "<a few words>" name the room, once you know what the work is
52
53
  station file <path> put a file on the room's board
53
- station status working|thinking|here
54
+ station status working|thinking|here ["<a few words on what>"]
55
+ say you are working, and on what: the room's page shows the words
54
56
  station tool [<name> [--<input> <value> ...]]
55
57
  run one of Station's tools from the shell, each input as a flag:
56
58
  station tool lists them, station tool <name> --help shows its flags.
@@ -76,7 +78,9 @@ const HELP = `station: an agent's way into Station rooms
76
78
 
77
79
  Run these from the agent's own shell, in any agent. In a Claude Code or
78
80
  Codex session, new messages in the room arrive in the session on their own,
79
- once the turn under way ends. Anywhere else, read them with station wait.
81
+ once the turn under way ends: in Claude Code as a short note with the
82
+ station read command for them (your own person's messages come whole).
83
+ Anywhere else, read them with station wait.
80
84
  Several agents in one folder, or in one Claude Code or Codex session
81
85
  (subagents): give each its own STATION_SESSION=<name> on every command.
82
86
  Each name has its own seat and reads its messages with station wait.
@@ -278,10 +282,21 @@ async function main(argv) {
278
282
  return 0;
279
283
  }
280
284
  case "read": {
285
+ const usage = `${me} read <message number>, ${me} read <first>-<last>, or ${me} read --after <message number, 0 for the oldest>`;
286
+ const [spec, extra] = args;
287
+ if (extra !== undefined || (spec !== undefined && flag("after") !== undefined))
288
+ throw new Usage(usage);
289
+ if (spec !== undefined) {
290
+ const runs = parseRuns(spec);
291
+ if (!runs)
292
+ throw new Usage(usage);
293
+ out(await readRunsIn(home, mySeat(home, inSession(), flag("room")), runs, me));
294
+ return 0;
295
+ }
281
296
  const seat = mySeat(home, inSession(), flag("room"));
282
297
  const after = Number(flag("after") ?? 0);
283
298
  if (!Number.isInteger(after) || after < 0)
284
- throw new Usage(`${me} read --after <message number, 0 for the oldest>`);
299
+ throw new Usage(usage);
285
300
  out(await readIn(home, seat, after, me));
286
301
  return 0;
287
302
  }
@@ -394,12 +409,16 @@ async function main(argv) {
394
409
  case "tool":
395
410
  return toolCommand({ home, args: rawArgs, out, me });
396
411
  case "status": {
397
- const [status] = args;
412
+ const [status, ...words] = args;
398
413
  if (!["working", "thinking", "here"].includes(status ?? ""))
399
- throw new Usage("station status working|thinking|here");
414
+ throw new Usage('station status working|thinking|here ["<a few words on what>"]');
415
+ // What on, in a few words: after the status, or as --doing. Agents type
416
+ // `station status working "reading the cookie code"` unprompted, and
417
+ // the words used to be dropped without a word.
418
+ const doing = status === "here" ? "" : (flag("doing") ?? words.join(" ")).trim();
400
419
  const seat = mySeat(home, inSession(), flag("room"));
401
- await call(seat.relayUrl, `/${seat.roomId}/presence`, authFor(seat, readCredentials(home)), { body: { status } });
402
- out(`Status in ${roomLabel(seat)}: ${status}.`);
420
+ await call(seat.relayUrl, `/${seat.roomId}/presence`, authFor(seat, readCredentials(home)), { body: { status, ...(doing ? { doing } : {}) } });
421
+ out(`Status in ${roomLabel(seat)}: ${status}${doing ? `, ${doing}` : ""}.`);
403
422
  return 0;
404
423
  }
405
424
  case "trace": {
package/dist/daemon.js CHANGED
@@ -4,8 +4,9 @@
4
4
  // keeps the seat present while the agent works. When the room says its
5
5
  // messages changed (and every 30 s in case a notice was missed) it reads the
6
6
  // messages after the seat's position and puts the new chat into the agent's
7
- // session (Claude Code or Codex) as one message. The position moves only once the message was
8
- // handed to the session, or might have been: a delivery that may have
7
+ // session (Claude Code or Codex) as one message. Claude Code gets a
8
+ // one-line note and reads the messages with `station read` (frame.ts). The position moves only once the message
9
+ // was handed to the session, or might have been: a delivery that may have
9
10
  // landed is never sent again. Each outcome goes to the relay too
10
11
  // (`/delivery`), and the board shows it under the newest message.
11
12
  //
@@ -121,7 +122,8 @@ export async function runDaemon(home) {
121
122
  while (seat) {
122
123
  const answer = await call(seat.relayUrl, `/${seat.roomId}/messages?after=${seat.after}`, authFor(seat, readCredentials(home)));
123
124
  const before = seat.guard ?? freshGuard();
124
- const result = await handOver(() => find(key) ?? seat, before, answer, roomOf(key), Date.now(), selfCommand());
125
+ const otherRooms = seats.some((s) => s.sessionId === seat.sessionId && s.roomId !== seat.roomId);
126
+ const result = await handOver(() => find(key) ?? seat, before, answer, roomOf(key), Date.now(), selfCommand(), otherRooms);
125
127
  const { text, handed, guard } = result;
126
128
  seat = find(key) ?? seat; // it may have just learned its owner
127
129
  if (text) {
package/dist/frame.js CHANGED
@@ -68,3 +68,51 @@ export function frame(seat, messages, participants, command = "station", before
68
68
  parts.push(hint);
69
69
  return parts.join("\n");
70
70
  }
71
+ /** Message numbers as `station read` takes them: one, a run (12-14), or
72
+ * both, joined by commas. Only numbers next to each other make a run, so
73
+ * the command reads exactly these. */
74
+ export function idList(ids) {
75
+ const sorted = [...new Set(ids)].sort((a, b) => a - b);
76
+ const runs = [];
77
+ for (let i = 0; i < sorted.length; i++) {
78
+ let j = i;
79
+ while (j + 1 < sorted.length && sorted[j + 1] === sorted[j] + 1)
80
+ j++;
81
+ runs.push(j === i ? String(sorted[i]) : `${sorted[i]}-${sorted[j]}`);
82
+ i = j;
83
+ }
84
+ return runs.join(",");
85
+ }
86
+ const together = (items) => (items.length < 2 ? (items[0] ?? "") : `${items.slice(0, -1).join(", ")} and ${items[items.length - 1]}`);
87
+ /** What a Claude Code session gets for new room messages: one line
88
+ * saying what came and how to read it, in place of the messages. Nobody's
89
+ * words enter the session until the agent reads them, and a delivery in
90
+ * the middle of other work is one line. `room`: the session has seats in
91
+ * other rooms too, so the command names this one. */
92
+ export function noteFrame(seat, messages, participants, command = "station", before = [], room = false) {
93
+ const hearer = hearerFor(seat, participants, command);
94
+ const byId = new Map(participants.map((p) => [p.id, p]));
95
+ const authorOf = (message) => byId.get(message.participant_id ?? "");
96
+ const rest = [...messages, ...before].sort((a, b) => a.id - b.id);
97
+ // Who wrote them, in the order they first spoke, with what each is to the reader.
98
+ const groups = new Map();
99
+ for (const message of rest) {
100
+ const key = message.participant_id ?? "";
101
+ const group = groups.get(key) ?? { name: authorOf(message)?.name ?? "Someone", count: 0, toYou: false, threads: [] };
102
+ group.count++;
103
+ if (hearer.seat && message.to?.includes(hearer.seat))
104
+ group.toYou = true;
105
+ const thread = message.reply_to ?? (message.to?.length && !message.to.includes(hearer.seat ?? "") ? message.id : null);
106
+ if (thread !== null && !group.threads.includes(thread))
107
+ group.threads.push(thread);
108
+ groups.set(key, group);
109
+ }
110
+ const who = [...groups.values()].map(({ name, count, toYou, threads }) => {
111
+ const marks = [count > 1 ? String(count) : null, toYou ? "to you" : null, threads.length ? `${threads.length > 1 ? "threads" : "thread"} ${together(threads.map(String))}` : null].filter(Boolean);
112
+ return marks.length ? `${name} (${marks.join(", ")})` : name;
113
+ });
114
+ const read = `${command} read ${idList(rest.map((m) => m.id))}${room ? ` --room ${seat.roomId}` : ""}`;
115
+ const count = `${rest.length} new message${rest.length === 1 ? "" : "s"}`;
116
+ const summary = `${who.join(", ")}. Read ${rest.length === 1 ? "it" : "them"}: ${read}`;
117
+ return `[Station · ${roomLabel(seat)}] ${count}: ${summary}`;
118
+ }
package/dist/handover.js CHANGED
@@ -2,7 +2,7 @@
2
2
  // guard lets through, held messages it releases, answers on the seat's
3
3
  // cards, people asking to join, and the note about held messages. The
4
4
  // daemon does the delivery; this decides what goes in it.
5
- import { askedFrame, askedIn, decisionFrame, decisionsFor, frame } from "./frame.js";
5
+ import { askedFrame, askedIn, decisionFrame, decisionsFor, frame, noteFrame } from "./frame.js";
6
6
  import { AGENT_LIMIT, sift, throughOf, WINDOW_MS } from "./guard.js";
7
7
  import { roomLabel } from "./seats.js";
8
8
  /** Held messages by id, read again page by page. The pages are every row,
@@ -32,7 +32,9 @@ export function heldNote(seat, count, command) {
32
32
  `They also come through here on their own when a person in the room says something, or as the ${WINDOW_MS / 60_000} minutes pass.`,
33
33
  ].join("\n");
34
34
  }
35
- export async function handOver(seat, guard, batch, room, now, command) {
35
+ export async function handOver(seat, guard, batch, room, now, command,
36
+ /** The session has seats in other rooms too: the note's read command names this room. */
37
+ otherRooms = false) {
36
38
  const chat = batch.messages.filter((m) => m.kind === "chat" && m.participant_id !== seat().participantId);
37
39
  const decisions = decisionsFor(seat(), batch.messages);
38
40
  const asked = askedIn(batch.messages);
@@ -52,10 +54,14 @@ export async function handOver(seat, guard, batch, room, now, command) {
52
54
  const person = earlier.length ? chat.find((m) => kinds.get(m.participant_id ?? "") !== "agent") : undefined;
53
55
  const before = person ? admitted.filter((m) => m.id < person.id) : [];
54
56
  const said = admitted.slice(before.length);
57
+ // Claude Code gets a one-line note and reads the messages with station read. Codex still gets every message
58
+ // whole: a station command in Codex's sandbox needs its person to allow
59
+ // network access, so reading after a note could cost an approval each time.
60
+ const chatFrame = seat().harness === "claude-code" ? noteFrame(seat(), said, participants, command, before, otherRooms) : frame(seat(), said, participants, command, before);
55
61
  const parts = [
56
62
  // Answers on its cards come first: they are what the agent is waiting for.
57
63
  decisions.length ? decisionFrame(seat(), decisions, participants) : null,
58
- admitted.length ? frame(seat(), said, participants, command, before) : null,
64
+ admitted.length ? chatFrame : null,
59
65
  // Someone asking to join: the people who can answer may not be looking
60
66
  // at the room, so the agents seated there say so.
61
67
  asked.length ? askedFrame(seat(), asked, command) : null,
package/dist/home.js CHANGED
@@ -24,6 +24,8 @@ export const files = (home) => ({
24
24
  log: join(home, "daemon.log"),
25
25
  /** The tools Station listed last, for a session that starts while it cannot be reached (mcp.ts). */
26
26
  tools: join(home, "tools.json"),
27
+ /** The five folded tools Station listed last for `station mcp`, kept apart from the commands' list. */
28
+ mcpTools: join(home, "tools-mcp.json"),
27
29
  /** A `station login` under way (login.ts). */
28
30
  login: join(home, "login.json"),
29
31
  /** This install's own id (installId). */
package/dist/join.js CHANGED
@@ -9,7 +9,7 @@ import { KNOWN_PEER_PROTOCOL, claudeHome, whyNoInbox } from "./claude.js";
9
9
  import { codexHome, whyNoThread } from "./codex.js";
10
10
  import { answers, ask } from "./daemon.js";
11
11
  import { askedFrame, askedIn, decisionFrame, decisionsFor, frame, hearerFor } from "./frame.js";
12
- import { lineOf, noteFor, whereOf } from "./mark.js";
12
+ import { lineOf, noteFor, threadHint, whereOf } from "./mark.js";
13
13
  import { DEFAULT_WEB, files, installId, readCredentials, stationHome } from "./home.js";
14
14
  import { call, parseRoomUrl } from "./relay.js";
15
15
  import { authFor, loadSeats, roomLabel, seatFor } from "./seats.js";
@@ -308,6 +308,82 @@ export async function readIn(home, seat, after, me) {
308
308
  lines.push(answer.messages.length === 100 ? `There are more. Read on with: ${me} read --after ${answer.next_after}` : "That is everything up to now.");
309
309
  return lines.join("\n");
310
310
  }
311
+ /** What `station read` takes besides --after: a message number (12), a
312
+ * run (12-15), or several joined by commas (12,15-17). Null when it is
313
+ * none of those. */
314
+ export function parseRuns(spec) {
315
+ const runs = [];
316
+ for (const part of spec.split(",")) {
317
+ const found = /^\s*(\d+)\s*(?:-\s*(\d+)\s*)?$/.exec(part);
318
+ if (!found)
319
+ return null;
320
+ const from = Number(found[1]);
321
+ const to = found[2] === undefined ? from : Number(found[2]);
322
+ if (!Number.isSafeInteger(from) || !Number.isSafeInteger(to) || from < 1 || to < from)
323
+ return null;
324
+ runs.push({ from, to });
325
+ }
326
+ return runs.length ? runs : null;
327
+ }
328
+ /** The most `station read` prints at once. */
329
+ const READ_AT_ONCE = 100;
330
+ /** The chat messages in these runs, read page by page (every row, as
331
+ * --after reads them). `more`: the first number not read yet, when there
332
+ * were more than READ_AT_ONCE. */
333
+ export async function messagesIn(runs, page) {
334
+ const inside = (id) => runs.some((run) => id >= run.from && id <= run.to);
335
+ const last = Math.max(...runs.map((run) => run.to));
336
+ const found = [];
337
+ let after = Math.min(...runs.map((run) => run.from)) - 1;
338
+ for (;;) {
339
+ const answer = await page(after);
340
+ for (const message of answer.messages) {
341
+ if (message.id > last)
342
+ return { messages: found, more: null };
343
+ if (message.kind !== "chat" || !inside(message.id))
344
+ continue;
345
+ if (found.length === READ_AT_ONCE)
346
+ return { messages: found, more: message.id };
347
+ found.push(message);
348
+ }
349
+ if (answer.messages.length < 100 || answer.next_after <= after)
350
+ return { messages: found, more: null };
351
+ after = answer.next_after;
352
+ }
353
+ }
354
+ /** What `station read 12,15` prints: those messages, marked as every
355
+ * other read marks them, and how to answer. `otherRooms`: the session has
356
+ * seats in other rooms too, so each command it prints names this room;
357
+ * without it, a reply would go to the room the session joined last. */
358
+ export function numberedText(seat, runs, read, participants, me, otherRooms = false) {
359
+ const room = otherRooms ? ` --room ${seat.roomId}` : "";
360
+ const hearer = hearerFor(seat, participants, me);
361
+ const byId = new Map(participants.map((p) => [p.id, p]));
362
+ const authors = read.messages.map((m) => byId.get(m.participant_id ?? ""));
363
+ const note = noteFor(hearer, authors);
364
+ const asked = runs.map((run) => (run.from === run.to ? String(run.from) : `${run.from}-${run.to}`)).join(", ");
365
+ const lines = [`[Station · ${roomLabel(seat)}] ${runs.length === 1 && runs[0].from === runs[0].to ? "Message" : "Messages"} ${asked}:`, "", ...(note ? [note, ""] : [])];
366
+ lines.push(...(read.messages.length ? read.messages.map((m, i) => lineOf(hearer, authors[i], m.body, whereOf(hearer, m, participants))) : ["(no chat message with that number in this room)"]), "");
367
+ if (read.more !== null) {
368
+ const rest = runs.flatMap((run) => (run.to < read.more ? [] : [{ from: Math.max(run.from, read.more), to: run.to }]));
369
+ lines.push(`There are more. Read on with: ${me} read ${rest.map((run) => (run.from === run.to ? String(run.from) : `${run.from}-${run.to}`)).join(",")}${room}`);
370
+ }
371
+ lines.push(`Reply in the room with: ${me} say${room} "<your reply>" (keep it to one or two sentences)`);
372
+ const hint = threadHint(read.messages, `${me} say${room} --reply {thread} "<your reply>"`);
373
+ if (hint)
374
+ lines.push(hint);
375
+ return lines.join("\n");
376
+ }
377
+ /** `station read 12`, `12-15` or `12,15-17`, as the seat. */
378
+ export async function readRunsIn(home, seat, runs, me) {
379
+ const auth = authFor(seat, readCredentials(home));
380
+ const [read, room] = await Promise.all([
381
+ messagesIn(runs, (after) => call(seat.relayUrl, `/${seat.roomId}/messages?after=${after}&all=1`, auth)),
382
+ call(seat.relayUrl, `/${seat.roomId}`, auth),
383
+ ]);
384
+ const otherRooms = loadSeats(files(home).seats).some((other) => other.sessionId === seat.sessionId && other.roomId !== seat.roomId);
385
+ return numberedText(seat, runs, read, room.participants, me, otherRooms);
386
+ }
311
387
  const SEAT_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
312
388
  /** Seats by id or by name, as `station say --to` takes them. A name must
313
389
  * be one seat's, any case. */
package/dist/mcp.js CHANGED
@@ -22,6 +22,11 @@
22
22
  //
23
23
  // The last list Station gave is kept, so a session that starts while
24
24
  // Station cannot be reached still has its tools.
25
+ //
26
+ // Station has two lists. An agent's app gets five folded tools (wait, send,
27
+ // get, list, mutate), which this server asks for. The shell commands
28
+ // (`station tool`, `station board ls`) get the tools one by one, each with
29
+ // its own flags, by not asking.
25
30
  import { existsSync, readFileSync, writeFileSync } from "node:fs";
26
31
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
27
32
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
@@ -55,7 +60,7 @@ export const postToAgent = async (relayUrl, headers, method, params) => {
55
60
  /** What every request to Station says about this CLI: how to run it on
56
61
  * this computer, and that it gives a worker named with `as` its own seat
57
62
  * (the relay offers `as` only then; 0.7.0 and before ignored it). */
58
- const ours = () => ({ "X-Station-Command": selfCommand(), "X-Station-Workers": "1" });
63
+ const ours = (folded = false) => ({ "X-Station-Command": selfCommand(), "X-Station-Workers": "1", ...(folded ? { "X-Station-Tools": "2" } : {}) });
59
64
  function failed(error) {
60
65
  return { content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }], isError: true };
61
66
  }
@@ -82,8 +87,7 @@ export const thisComputer = {
82
87
  await ask(files(home).socket, { op: "read", sessionId: seat.sessionId, roomId: seat.roomId, after });
83
88
  },
84
89
  };
85
- function cached(home) {
86
- const path = files(home).tools;
90
+ function cached(path) {
87
91
  if (!existsSync(path))
88
92
  return [];
89
93
  try {
@@ -93,12 +97,13 @@ function cached(home) {
93
97
  return [];
94
98
  }
95
99
  }
96
- /** Station's rules for its tools, as it gives them; null when it cannot be reached. */
100
+ /** Station's rules for its five folded tools, as it gives them to
101
+ * `station mcp`; null when it cannot be reached. */
97
102
  export async function instructionsFrom(home, post = postToAgent) {
98
103
  const credentials = await settled(home);
99
104
  const relayUrl = relayOf(credentials);
100
105
  try {
101
- const result = (await post(relayUrl, { ...asPerson(credentials, relayUrl), ...ours() }, "initialize", {
106
+ const result = (await post(relayUrl, { ...asPerson(credentials, relayUrl), ...ours(true) }, "initialize", {
102
107
  protocolVersion: LATEST_PROTOCOL_VERSION,
103
108
  capabilities: {},
104
109
  clientInfo: { name: "station-cli", version: VERSION },
@@ -109,19 +114,20 @@ export async function instructionsFrom(home, post = postToAgent) {
109
114
  return null;
110
115
  }
111
116
  }
112
- export function stationTools(home, post = postToAgent, computer = thisComputer) {
117
+ export function stationTools(home, post = postToAgent, computer = thisComputer, folded = false) {
113
118
  let known = new Map();
119
+ const kept = folded ? files(home).mcpTools : files(home).tools;
114
120
  const list = async (from) => {
115
121
  const credentials = await settled(home);
116
122
  const relayUrl = from ?? relayOf(credentials);
117
123
  let tools;
118
124
  try {
119
- tools = (await post(relayUrl, { ...asPerson(credentials, relayUrl), ...ours() }, "tools/list", {})).tools;
120
- writeFileSync(files(home).tools, JSON.stringify(tools), { mode: 0o600 });
125
+ tools = (await post(relayUrl, { ...asPerson(credentials, relayUrl), ...ours(folded) }, "tools/list", {})).tools;
126
+ writeFileSync(kept, JSON.stringify(tools), { mode: 0o600 });
121
127
  }
122
128
  catch {
123
129
  // Station could not be reached: the tools it gave last time.
124
- tools = cached(home);
130
+ tools = cached(kept);
125
131
  }
126
132
  known = new Map(tools.map((tool) => [tool.name, tool]));
127
133
  return tools;
@@ -159,7 +165,7 @@ export function stationTools(home, post = postToAgent, computer = thisComputer)
159
165
  seat = await computer.takeSeat(home, caller ?? computer.session(worker), `${relayUrl}/${roomId}`, name);
160
166
  joined = true;
161
167
  }
162
- const headers = ours();
168
+ const headers = ours(folded);
163
169
  if (seat) {
164
170
  const auth = authFor(seat, credentials);
165
171
  relayUrl = seat.relayUrl;
@@ -193,7 +199,7 @@ export function createStationServer(home, post = postToAgent, instructions = nul
193
199
  // The agent's app names itself when it connects (Cursor, Claude Code);
194
200
  // every call to Station from here on says so in its User-Agent.
195
201
  server.oninitialized = () => setCaller({ host: server.getClientVersion()?.name ?? null });
196
- const tools = stationTools(home, post, computer);
202
+ const tools = stationTools(home, post, computer, true);
197
203
  server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: await tools.list() }));
198
204
  server.setRequestHandler(CallToolRequestSchema, async (request) => tools.call(request.params.name, request.params.arguments ?? {}));
199
205
  return server;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@santori/station",
3
- "version": "0.8.3",
3
+ "version": "0.9.0",
4
4
  "description": "Meeting rooms for your agents. They can share context with each other and work together. This CLI brings any agent into a Station room. In Claude Code and Codex, messages from the room arrive in the session on their own.",
5
5
  "keywords": [
6
6
  "station",