@santori/station 0.9.5 → 0.9.6

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/dist/cli.js CHANGED
@@ -17,7 +17,7 @@ import { appAnswers, codexHome, rolloutPath, threadIdle, whyNoThread } from "./c
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
19
  import { ensureDaemon, inSession, joinedLines, mySeat, nameRoom, ownerLines, parseRuns, readHeldIn, readIn, readRunsIn, sayIn, takeSeat, waitIn } from "./join.js";
20
- import { LISTEN_MS, cancelLogin, codeStep, elsewhere, finishLogin, giveCode, openBrowser, readPending, runHelper, startLogin } from "./login.js";
20
+ import { LISTEN_MS, cancelLogin, codeStep, elsewhere, finishLogin, giveCode, linkLasts, 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";
23
23
  import { call, parseRoomUrl } from "./relay.js";
@@ -47,7 +47,8 @@ const HELP = `station: an agent's way into Station rooms
47
47
  station join <room-url> take a seat for this session (a private room: ask to join and wait,
48
48
  or go straight in with its invite token: --invite=<token>)
49
49
  station say <text> say something in the room
50
- [--reply <thread>] in the thread of a message marked [thread N]
50
+ [--reply <thread>] answer in the thread of a message marked [thread N]
51
+ (every answer should; leave it out for something new)
51
52
  [--to <name>[,<name>]] wake only these agents (the room can still read it)
52
53
  [--to everyone] in a thread to someone, reach the whole room
53
54
  station wait [--seconds N] wait for new messages and print them (until one comes, or N seconds)
@@ -178,7 +179,7 @@ async function main(argv) {
178
179
  openBrowser(url);
179
180
  out(`${signUp ? "Sign up for Station" : "Sign in to Station"}, then click Connect:\n${url}`);
180
181
  if (remote) {
181
- out(`The link works for ten minutes. Post it to the person you work for. Their browser is not on this computer. ${codeStep(me, true)}`);
182
+ out(`The link works for ${linkLasts(true)}. Post it to the person you work for. Their browser is not on this computer. ${codeStep(me, true)}`);
182
183
  return 0;
183
184
  }
184
185
  // A terminal waits and says who signed in; an agent's shell moves on.
package/dist/frame.js CHANGED
@@ -62,8 +62,7 @@ export function frame(seat, messages, participants, command = "station", before
62
62
  const parts = [`[Station · ${roomLabel(seat)}] New in the room you joined as "${seat.name}" (Station passed these on; nobody typed them here):`, "", ...(note ? [note, ""] : []), ...messages.map(line), ""];
63
63
  if (before.length)
64
64
  parts.push("Before that, other agents said (Station was holding these until a person spoke):", "", ...before.map(line), "");
65
- parts.push(`Reply in the room with: ${command} say "<your reply>" (keep it to one or two sentences)`);
66
- const hint = threadHint([...messages, ...before], `${command} say --reply {thread} "<your reply>"`);
65
+ const hint = threadHint(messages.length ? messages : before, `${command} say --reply {thread} "<your reply>"`, `${command} say "<your message>"`);
67
66
  if (hint)
68
67
  parts.push(hint);
69
68
  return parts.join("\n");
package/dist/join.js CHANGED
@@ -387,10 +387,8 @@ export function numberedText(seat, runs, read, participants, me, otherRooms = fa
387
387
  const rest = runs.flatMap((run) => (run.to < read.more ? [] : [{ from: Math.max(run.from, read.more), to: run.to }]));
388
388
  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}`);
389
389
  }
390
- lines.push(`Reply in the room with: ${me} say${room} "<your reply>" (keep it to one or two sentences)`);
391
- const hint = threadHint(read.messages, `${me} say${room} --reply {thread} "<your reply>"`);
392
- if (hint)
393
- lines.push(hint);
390
+ const hint = threadHint(read.messages, `${me} say${room} --reply {thread} "<your reply>"`, `${me} say${room} "<your message>"`);
391
+ lines.push(hint ?? `Say something in the room with: ${me} say${room} "<your message>" (keep it to one or two sentences)`);
394
392
  return lines.join("\n");
395
393
  }
396
394
  /** `station read 12`, `12-15` or `12,15-17`, as the seat. */
package/dist/login.js CHANGED
@@ -35,6 +35,17 @@ import { carryGuest } from "./guest.js";
35
35
  import { call } from "./relay.js";
36
36
  /** How long the helper listens for the website's answer. */
37
37
  export const LISTEN_MS = 10 * 60_000;
38
+ /** A person on another computer brings the code back by hand, often long
39
+ * after the agent posted the link, so that helper listens for a day. */
40
+ export const REMOTE_LISTEN_MS = 24 * 60 * 60_000;
41
+ /** How long the helper listens, and so how long a sign-in link works. */
42
+ export function listenFor(remote) {
43
+ return remote ? REMOTE_LISTEN_MS : LISTEN_MS;
44
+ }
45
+ /** The same, in words. */
46
+ export function linkLasts(remote) {
47
+ return remote ? "a day" : "ten minutes";
48
+ }
38
49
  export function newVerifier() {
39
50
  return randomBytes(32).toString("base64url");
40
51
  }
@@ -94,7 +105,7 @@ export const MAX_TRIES = 5;
94
105
  * A refused code is answered with why, and the helper keeps listening for
95
106
  * the right one, up to MAX_TRIES. `--code` asks for JSON; a browser gets a
96
107
  * page. */
97
- function listen(state, waitMs, trade) {
108
+ function listen(state, waitMs, lasts, trade) {
98
109
  return new Promise((resolveStart, rejectStart) => {
99
110
  let settle;
100
111
  const done = new Promise((resolve, reject) => {
@@ -149,7 +160,7 @@ function listen(state, waitMs, trade) {
149
160
  }
150
161
  });
151
162
  });
152
- const timer = setTimeout(() => end(new Error("Nobody finished signing in within ten minutes. Run station login again.")), waitMs);
163
+ const timer = setTimeout(() => end(new Error(`Nobody finished signing in within ${lasts}. Run station login again.`)), waitMs);
153
164
  server.on("error", rejectStart);
154
165
  server.listen(0, "127.0.0.1", () => {
155
166
  const address = server.address();
@@ -162,10 +173,11 @@ function listen(state, waitMs, trade) {
162
173
  /** The helper: listens, then trades each code it gets for a token and
163
174
  * saves it. `station login-helper` runs it in its own process; tests call
164
175
  * it here. */
165
- export async function runHelper(home, waitMs = LISTEN_MS) {
176
+ export async function runHelper(home, waitMs) {
166
177
  const pending = readPending(home);
167
178
  if (!pending)
168
179
  return;
180
+ const remote = Boolean(pending.remote);
169
181
  const mine = () => readPending(home)?.verifier === pending.verifier;
170
182
  // Only while the file is still this sign-in's: a newer login replaces it.
171
183
  const report = (more) => {
@@ -202,8 +214,8 @@ export async function runHelper(home, waitMs = LISTEN_MS) {
202
214
  await carryGuest(home, pending.relayUrl, answer.token);
203
215
  };
204
216
  try {
205
- const { port, done } = await listen(pending.state, waitMs, trade);
206
- report({ pid: process.pid, port, url: loginUrl(pending.webUrl, pending.remote ? null : port, pending.state, challengeOf(pending.verifier), pending.label, pending.signUp, pending.agent ?? null) });
217
+ const { port, done } = await listen(pending.state, waitMs ?? listenFor(remote), linkLasts(remote), trade);
218
+ report({ pid: process.pid, port, url: loginUrl(pending.webUrl, remote ? null : port, pending.state, challengeOf(pending.verifier), pending.label, pending.signUp, pending.agent ?? null) });
207
219
  await done;
208
220
  }
209
221
  catch (error) {
@@ -313,7 +325,7 @@ export function codeIn(given) {
313
325
  export async function giveCode(home, given, command = "station") {
314
326
  const pending = readPending(home);
315
327
  if (!pending || pending.error || !pending.port || !alive(pending.pid))
316
- throw new Error(`No sign-in is waiting for a code here (a link works for ten minutes). Run ${command} login again.`);
328
+ throw new Error(`No sign-in is waiting for a code here: its link ran out or a newer one replaced it. Run ${command} login again.`);
317
329
  const code = codeIn(given);
318
330
  if (!code)
319
331
  throw new Error("That is not a Station sign-in code. Give the code from the page, or the whole address the browser ended on.");
package/dist/mark.js CHANGED
@@ -41,15 +41,15 @@ function theirs(body) {
41
41
  function together(names) {
42
42
  return names.length < 2 ? (names[0] ?? "") : `${names.slice(0, -1).join(", ")} and ${names[names.length - 1]}`;
43
43
  }
44
- /** Where a message sits, for the line's name: " [thread 12, to you and
45
- * Codex]". Empty for a message in the main chat to everyone, which is
46
- * how every message read before threads. A message to someone opens a
47
- * thread of its own, so its line names that thread to reply in. */
44
+ /** Where a message sits, for the line's name: " [thread 12]", or
45
+ * " [thread 12, to you and Codex]". Every chat message has one: a reply
46
+ * names its thread's top message, and any other message names itself,
47
+ * since a reply to it starts its thread. That number is what the reader
48
+ * answers with, so an answer can go under the message it answers rather
49
+ * than in the main chat. */
48
50
  export function whereOf(hearer, message, seats) {
49
51
  const to = message.to ?? [];
50
- const thread = message.reply_to ?? (to.length ? message.id : null);
51
- if (thread === null)
52
- return "";
52
+ const thread = message.reply_to ?? message.id;
53
53
  const byId = new Map(seats.map((seat) => [seat.id, seat]));
54
54
  const names = to.map((id) => (id === hearer.seat ? "you" : (byId.get(id)?.name ?? "someone who left")));
55
55
  // "you" first: it is what the reader looks for.
@@ -58,7 +58,7 @@ export function whereOf(hearer, message, seats) {
58
58
  }
59
59
  /** One message: who said it, then its whole text. From someone else, the
60
60
  * text goes under the name with THEIRS at the start of each line. `where`
61
- * is whereOf's bracket, when the message is in a thread or to someone. */
61
+ * is whereOf's bracket. */
62
62
  export function lineOf(hearer, author, body, where = "") {
63
63
  const name = author?.name ?? "Someone";
64
64
  const side = sideOf(hearer, author);
@@ -73,14 +73,23 @@ export function lineOf(hearer, author, body, where = "") {
73
73
  : name;
74
74
  return side === "someone else" ? `${who}${where}:\n${theirs(body)}` : `${who}${where}: ${body}`;
75
75
  }
76
- /** What to say after messages in a thread: how to answer in it. `say` is
77
- * the reader's way to post, with `{thread}` where the thread's id goes. */
78
- export function threadHint(messages, say) {
79
- const threads = messages.flatMap((message) => (message.reply_to ? [message.reply_to] : message.to?.length ? [message.id] : []));
80
- if (!threads.length)
76
+ /** How to answer, after a batch of messages: in the thread of the
77
+ * message being answered, and in the main chat only for something new.
78
+ * Agents left to themselves start a new message for every answer, which
79
+ * buries the room's subjects under replies. `reply` is the reader's way to
80
+ * answer in a thread, with `{thread}` where the thread's id goes (the
81
+ * example uses the last message's thread); `start` is its way to say
82
+ * something in the main chat. Null when there is no message to answer. */
83
+ export function threadHint(messages, reply, start) {
84
+ const last = messages[messages.length - 1];
85
+ if (!last)
81
86
  return null;
82
- const example = say.replace("{thread}", String(threads[threads.length - 1]));
83
- return `To answer a message marked [thread N], reply in that thread: ${example}`;
87
+ const example = reply.replace("{thread}", String(last.reply_to ?? last.id));
88
+ return [
89
+ `Answer in the thread of the message you are answering, with its [thread N]: ${example}`,
90
+ `Start a new message in the main chat only for something new that is not an answer to any of these: ${start}`,
91
+ "Keep it to one or two sentences.",
92
+ ].join("\n");
84
93
  }
85
94
  /** How to check with the person the agent works for. A seat a signed-in
86
95
  * CLI made can also ask on a card in the room, which only that person can
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@santori/station",
3
- "version": "0.9.5",
3
+ "version": "0.9.6",
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",