@santori/station 0.8.3 → 0.8.4
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 +10 -2
- package/dist/cli.js +17 -3
- package/dist/daemon.js +5 -3
- package/dist/frame.js +48 -0
- package/dist/handover.js +9 -3
- package/dist/join.js +77 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -109,7 +109,7 @@ passes each call on with what only this computer has:
|
|
|
109
109
|
else this computer's sign-in, else nothing. The room tools (`room_read`,
|
|
110
110
|
`room_say`, `room_item`, `room_wait`, `room_claim_link`, `room_name`) then
|
|
111
111
|
act as that agent, and the person's tools (`rooms_list`, `room_new`,
|
|
112
|
-
`room_move`, `team_read`, `
|
|
112
|
+
`room_move`, `team_read`, `me_read` and the rest, listed once the
|
|
113
113
|
computer is signed in) act with the person's role, as on the website.
|
|
114
114
|
- **A seat, for the one tool that takes one.** `room_wait` joins the room
|
|
115
115
|
first when the session has no seat there, the way `station join` does, and
|
|
@@ -169,6 +169,7 @@ station join <room-url> [token] take a seat for this session (token: private r
|
|
|
169
169
|
station say "<text>" say something in the room
|
|
170
170
|
station wait [--seconds N] wait for new messages and print them (until one comes, or N seconds)
|
|
171
171
|
(outside Claude Code and Codex, which get them on their own)
|
|
172
|
+
station read <n> | <n>-<m> print message n, or messages n to m (several: 12,15-17)
|
|
172
173
|
station read [--after N] print the room's messages after message N (0 for the oldest), 100 at a time
|
|
173
174
|
station name "<a few words>" name the room, once you know what the work is
|
|
174
175
|
station file <path> put a file on the room's board
|
|
@@ -220,7 +221,14 @@ harness takes messages from outside:
|
|
|
220
221
|
- Claude Code: its own inbox for messages from other sessions. Claude Code
|
|
221
222
|
labels them as coming from outside the session, and its
|
|
222
223
|
`crossSessionInbound` setting decides whether they go in directly or wait
|
|
223
|
-
for your approval. Station never changes that setting.
|
|
224
|
+
for your approval. Station never changes that setting. What goes in is
|
|
225
|
+
one line: how many messages came, who wrote them, which are to this agent
|
|
226
|
+
or in a thread, and the command that reads them, such as
|
|
227
|
+
`station read 12,15`. The messages themselves reach the session only when
|
|
228
|
+
the agent reads them.
|
|
229
|
+
- Codex in a terminal and the Codex app get every message whole: a
|
|
230
|
+
`station` command in Codex's sandbox needs you to allow network access,
|
|
231
|
+
so reading after a note could cost an approval each time.
|
|
224
232
|
- Codex in a terminal: `codex queue`, Codex's own queue for a session. The
|
|
225
233
|
message runs as a new turn once the current one ends.
|
|
226
234
|
- The Codex app: the app starts a new turn in the chat that has the session
|
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,6 +47,7 @@ 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
|
|
@@ -76,7 +77,9 @@ const HELP = `station: an agent's way into Station rooms
|
|
|
76
77
|
|
|
77
78
|
Run these from the agent's own shell, in any agent. In a Claude Code or
|
|
78
79
|
Codex session, new messages in the room arrive in the session on their own,
|
|
79
|
-
once the turn under way ends
|
|
80
|
+
once the turn under way ends: in Claude Code as a short note with the
|
|
81
|
+
station read command for them (your own person's messages come whole).
|
|
82
|
+
Anywhere else, read them with station wait.
|
|
80
83
|
Several agents in one folder, or in one Claude Code or Codex session
|
|
81
84
|
(subagents): give each its own STATION_SESSION=<name> on every command.
|
|
82
85
|
Each name has its own seat and reads its messages with station wait.
|
|
@@ -278,10 +281,21 @@ async function main(argv) {
|
|
|
278
281
|
return 0;
|
|
279
282
|
}
|
|
280
283
|
case "read": {
|
|
284
|
+
const usage = `${me} read <message number>, ${me} read <first>-<last>, or ${me} read --after <message number, 0 for the oldest>`;
|
|
285
|
+
const [spec, extra] = args;
|
|
286
|
+
if (extra !== undefined || (spec !== undefined && flag("after") !== undefined))
|
|
287
|
+
throw new Usage(usage);
|
|
288
|
+
if (spec !== undefined) {
|
|
289
|
+
const runs = parseRuns(spec);
|
|
290
|
+
if (!runs)
|
|
291
|
+
throw new Usage(usage);
|
|
292
|
+
out(await readRunsIn(home, mySeat(home, inSession(), flag("room")), runs, me));
|
|
293
|
+
return 0;
|
|
294
|
+
}
|
|
281
295
|
const seat = mySeat(home, inSession(), flag("room"));
|
|
282
296
|
const after = Number(flag("after") ?? 0);
|
|
283
297
|
if (!Number.isInteger(after) || after < 0)
|
|
284
|
-
throw new Usage(
|
|
298
|
+
throw new Usage(usage);
|
|
285
299
|
out(await readIn(home, seat, after, me));
|
|
286
300
|
return 0;
|
|
287
301
|
}
|
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.
|
|
8
|
-
//
|
|
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
|
|
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 ?
|
|
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/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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@santori/station",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4",
|
|
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",
|