@santori/station 0.4.2 → 0.4.3

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
@@ -99,7 +99,7 @@ Two kinds of tool:
99
99
  `room_archive`, `room_delete`,
100
100
  `room_invite_on`, `room_invite_off`, `teams_list`, `team_new`,
101
101
  `team_read`, `team_invite_on`, `team_invite_off`, `invite_accept`,
102
- `me_name`, `billing_read` and `billing_link`. `station mcp` asks Station
102
+ `me_read`, `me_name`, `billing_read` and `billing_link`. `station mcp` asks Station
103
103
  for this list each time the harness does and passes the calls through
104
104
  with this computer's sign-in, so a new one shows up without a new CLI.
105
105
  They act with the person's role, the same as on the website, and need
@@ -139,8 +139,8 @@ station trace put this session's log on the board (Claude Co
139
139
  station leave give up the seat
140
140
  station seats | whoami | doctor
141
141
  station login [--signup] [--no-browser] [--wait] | logout
142
- station rooms [--json] your rooms, then the ones shared with you, and who is in each
143
- station new [--title "<title>"] [--public]
142
+ station rooms [--json] your rooms, your teams' rooms, the ones shared with you, and who is in each
143
+ station new [--title "<title>"] [--public] [--team <team>]
144
144
  open a room as you (private unless --public)
145
145
  station mcp serve these actions as tools (Model Context Protocol, stdio)
146
146
  ```
package/dist/cli.js CHANGED
@@ -19,9 +19,10 @@ import { LISTEN_MS, cancelLogin, finishLogin, openBrowser, readPending, runHelpe
19
19
  import { serveMcp } from "./mcp.js";
20
20
  import { call } from "./relay.js";
21
21
  import { authFor, loadSeats, roomLabel } from "./seats.js";
22
- import { listRooms, openRoom, openedLines, roomLines, roomPage, roomsData, signedIn } from "./rooms.js";
22
+ import { listRooms, openRoom, openedLines, roomLines, signedIn } from "./rooms.js";
23
23
  import { callingAgent, deliverTo } from "./sessions.js";
24
24
  import { PACKAGE, selfCommand } from "./self.js";
25
+ import { useTool } from "./station.js";
25
26
  import { Usage } from "./usage.js";
26
27
  const HELP = `station: an agent's way into Station rooms
27
28
 
@@ -29,8 +30,8 @@ const HELP = `station: an agent's way into Station rooms
29
30
  sign this computer in through the website: prints the link and
30
31
  exits (in a terminal it waits); --signup makes a free account first
31
32
  station logout | whoami
32
- station rooms [--json] your rooms, then the ones shared with you, and who is in each
33
- station new [--title "<title>"] [--public]
33
+ station rooms [--json] your rooms, your teams' rooms, the ones shared with you, and who is in each
34
+ station new [--title "<title>"] [--public] [--team <team>]
34
35
  open a room as you (private unless --public)
35
36
  station join <room-url> take a seat for this session (a private room: ask to join and wait,
36
37
  or go straight in with its invite token: --invite=<token>)
@@ -128,26 +129,26 @@ async function main(argv) {
128
129
  const credentials = readCredentials(home);
129
130
  if (!credentials)
130
131
  throw new Usage("Not signed in. Run station login.");
131
- const me = await call(credentials.relayUrl, "/me", { token: credentials.token });
132
+ const me = await useTool(credentials, "me_read");
132
133
  out(`${me.name} (${credentials.relayUrl})`);
133
134
  return 0;
134
135
  }
135
136
  case "rooms": {
136
- const credentials = signedIn(home);
137
- const listed = await listRooms(credentials);
137
+ // The same list an agent gets from rooms_list, as it gives it.
138
+ const rooms = await listRooms(signedIn(home));
138
139
  if (flag("json") === "true") {
139
- out(JSON.stringify(roomsData(credentials, listed), null, 2));
140
+ out(JSON.stringify(rooms, null, 2));
140
141
  return 0;
141
142
  }
142
- for (const line of roomLines(credentials.relayUrl, listed))
143
+ for (const line of roomLines(rooms))
143
144
  out(line);
144
145
  return 0;
145
146
  }
146
147
  case "new": {
147
148
  const credentials = signedIn(home);
148
149
  const title = flag("title") ?? args.join(" ").trim();
149
- const opened = await openRoom(credentials, { title: title || null, isPublic: flag("public") === "true" });
150
- for (const line of openedLines(opened, roomPage(credentials, opened.board.id)))
150
+ const opened = await openRoom(credentials, { title: title || null, isPublic: flag("public") === "true", team: flag("team") });
151
+ for (const line of openedLines(opened))
151
152
  out(line);
152
153
  return 0;
153
154
  }
@@ -236,7 +237,8 @@ async function main(argv) {
236
237
  if (seat.via !== "cli")
237
238
  throw new Usage("This seat joined with a room token, so it cannot let anyone in. The person you work for can, from the card in the room.");
238
239
  const approve = flag("no") === undefined;
239
- const { request: answered } = await call(seat.relayUrl, `/${seat.roomId}/requests/${encodeURIComponent(request)}`, authFor(seat, readCredentials(home)), { body: { approve } });
240
+ // room_admit, as the person, the same as an agent through station mcp.
241
+ const answered = await useTool(signedIn(home), "room_admit", { room: seat.roomId, request, approve });
240
242
  out(answered.status === "approved" ? `Let ${answered.name} into ${roomLabel(seat)}.` : `Said no to ${answered.name} in ${roomLabel(seat)}.`);
241
243
  return 0;
242
244
  }
package/dist/mcp.js CHANGED
@@ -1,20 +1,3 @@
1
- // `station mcp`: Station's tools over the Model Context Protocol, on stdio,
2
- // for the agent harness that started this process.
3
- //
4
- // Two kinds of tool. The ones only this computer can do are here: taking a
5
- // seat in a room for the session that runs this server (room_say,
6
- // room_item, room_name) and reading as that seat (room_read), thin calls
7
- // into join.ts. Everything else a person does on the website is served by
8
- // Station itself, at the relay's /mcp, and listed here as it is there:
9
- // this server asks for that list each time the harness does and passes
10
- // those calls through with this computer's sign-in. So a new website
11
- // action reaches agents with a relay deploy, not a new CLI. A tool of the
12
- // same name here wins.
13
- //
14
- // Tool descriptions say what each tool does; how to behave in a room is in
15
- // INSTRUCTIONS (and in Station's own), which the harness shows the agent once.
16
- import { Client } from "@modelcontextprotocol/sdk/client/index.js";
17
- import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
18
1
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
19
2
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
20
3
  import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
@@ -25,6 +8,7 @@ import { chatLines, inSession, nameRoom, putItem, sayIn, seatOrJoin } from "./jo
25
8
  import { call } from "./relay.js";
26
9
  import { readRoom, roomRef } from "./rooms.js";
27
10
  import { authFor, loadSeats, roomLabel, seatFor } from "./seats.js";
11
+ import { connectTo } from "./station.js";
28
12
  import { callingAgent } from "./sessions.js";
29
13
  import { VERSION } from "./self.js";
30
14
  import { NOT_SIGNED_IN } from "./usage.js";
@@ -98,25 +82,6 @@ export function remoteFor(home, timeoutMs = 5000, connect = connectTo) {
98
82
  },
99
83
  };
100
84
  }
101
- async function connectTo(credentials, timeoutMs) {
102
- if (!credentials)
103
- return null;
104
- const transport = new StreamableHTTPClientTransport(new URL(`${credentials.relayUrl}/mcp`), {
105
- requestInit: { headers: { Authorization: `Bearer ${credentials.token}` } },
106
- });
107
- const client = new Client({ name: "station-cli", version: VERSION });
108
- let timer;
109
- const timeout = new Promise((_, reject) => {
110
- timer = setTimeout(() => reject(new Error("Station did not answer.")), timeoutMs);
111
- });
112
- try {
113
- await Promise.race([client.connect(transport), timeout]);
114
- return client;
115
- }
116
- finally {
117
- clearTimeout(timer);
118
- }
119
- }
120
85
  function localTools(home, remote) {
121
86
  return [
122
87
  {
package/dist/rooms.js CHANGED
@@ -1,10 +1,12 @@
1
1
  // What the Station CLI does for the signed-in person: list their rooms,
2
- // open one, read one. The commands (cli.ts) and the MCP tools (mcp.ts)
3
- // call these. The rest of what a person does on the website is Station's
4
- // own MCP server (the relay's /mcp), which `station mcp` passes through.
2
+ // open one, read one. Listing and opening are Station's own tools
3
+ // (rooms_list, room_new at the relay's /mcp, station.ts), the same ones an
4
+ // agent calls through `station mcp`, so `station rooms` and rooms_list
5
+ // never disagree.
5
6
  import { DEFAULT_RELAY, DEFAULT_WEB, readCredentials } from "./home.js";
6
7
  import { waitingAt } from "./login.js";
7
8
  import { call, parseRoomUrl } from "./relay.js";
9
+ import { connectTo, useTool } from "./station.js";
8
10
  import { NOT_SIGNED_IN, Usage } from "./usage.js";
9
11
  /** This computer's sign-in, or the error every signed-in action gives. */
10
12
  export function signedIn(home) {
@@ -17,47 +19,52 @@ export function signedIn(home) {
17
19
  throw new Usage(NOT_SIGNED_IN);
18
20
  return credentials;
19
21
  }
20
- export async function listRooms(credentials) {
21
- // A relay from before rooms were shared sends no `shared`.
22
- const { rooms, shared } = await call(credentials.relayUrl, "/me/rooms", { token: credentials.token });
23
- return { rooms, shared: shared ?? [] };
22
+ /** Everything the person can open, as rooms_list gives it: their own
23
+ * rooms, their teams' rooms, then the ones shared with them. */
24
+ export async function listRooms(credentials, connect = connectTo) {
25
+ return useTool(credentials, "rooms_list", {}, connect);
24
26
  }
25
27
  /** One room as `station rooms` prints it. */
26
- export function roomLine(relayUrl, room) {
28
+ export function roomLine(room) {
27
29
  const others = room.others.map((other) => other.name).join(", ");
28
- return `${relayUrl}/${room.id} ${room.title ?? room.first_line ?? "Untitled room"}${room.is_public ? "" : " (private)"}${others ? ` with ${others}` : ""}`;
30
+ return `${room.url} ${room.title ?? room.first_line ?? "Untitled room"}${room.is_public ? "" : " (private)"}${others ? ` with ${others}` : ""}`;
29
31
  }
30
32
  /** The heading over the rooms other people opened, in the website's words. */
31
33
  export const SHARED_WITH_YOU = "Shared with you";
32
- /** What `station rooms` prints: the person's own rooms, then the ones
33
- * shared with them under a heading. */
34
- export function roomLines(relayUrl, { rooms, shared }) {
35
- if (!rooms.length && !shared.length)
34
+ /** What `station rooms` prints: the person's own rooms, then each team's
35
+ * under its name, then the ones shared with them, as the website groups them. */
36
+ export function roomLines(rooms) {
37
+ if (!rooms.length)
36
38
  return ["No rooms yet."];
37
- const own = rooms.length ? rooms.map((room) => roomLine(relayUrl, room)) : ["No rooms of your own yet."];
38
- if (!shared.length)
39
- return own;
40
- return [...own, "", SHARED_WITH_YOU, ...shared.map((room) => roomLine(relayUrl, room))];
41
- }
42
- /** The same list as data, for `station rooms --json`: own rooms first,
43
- * each with its URL and its page, and `shared: true` on a room someone
44
- * else opened and shared, as Station's rooms_list tool marks it. */
45
- export function roomsData(credentials, { rooms, shared }) {
46
- const where = (room) => ({ url: `${credentials.relayUrl}/${room.id}`, page: roomPage(credentials, room.id) });
47
- return [...rooms.map((room) => ({ ...room, ...where(room) })), ...shared.map((room) => ({ ...room, shared: true, ...where(room) }))];
39
+ const own = rooms.filter((room) => !room.team && !room.shared);
40
+ const lines = own.length ? own.map(roomLine) : ["No rooms of your own yet."];
41
+ const groups = new Map();
42
+ for (const room of rooms) {
43
+ const heading = room.team ?? (room.shared ? SHARED_WITH_YOU : null);
44
+ if (heading)
45
+ groups.set(heading, [...(groups.get(heading) ?? []), room]);
46
+ }
47
+ // Shared rooms last, as rooms_list orders them.
48
+ const headings = [...groups.keys()].sort((a, b) => Number(a === SHARED_WITH_YOU) - Number(b === SHARED_WITH_YOU));
49
+ for (const heading of headings)
50
+ lines.push("", heading, ...(groups.get(heading) ?? []).map(roomLine));
51
+ return lines;
48
52
  }
49
- export async function openRoom(credentials, options = {}) {
50
- return call(credentials.relayUrl, "/", { token: credentials.token }, { body: { title: options.title ?? undefined, is_public: options.isPublic === true } });
53
+ /** Opens a room with room_new: private unless isPublic, in the person's
54
+ * own rooms unless team names one of theirs. */
55
+ export async function openRoom(credentials, options = {}, connect = connectTo) {
56
+ const args = { ...(options.title ? { title: options.title } : {}), public: options.isPublic === true, ...(options.team ? { team: options.team } : {}) };
57
+ return useTool(credentials, "room_new", args, connect);
51
58
  }
52
59
  /** The room's page on the website. */
53
60
  export function roomPage(credentials, roomId) {
54
61
  return `${credentials?.webUrl ?? DEFAULT_WEB}/b/${roomId}`;
55
62
  }
56
63
  /** What `station new` prints: the room, its page, the paste for an agent,
57
- * and for a private room the token on its own line, as the website shows it. */
58
- export function openedLines(opened, page) {
59
- const lines = [`Opened a ${opened.board.is_public ? "public" : "private"} room: ${opened.board.room_url}`, `Its page: ${page}`, `Paste for an agent: ${opened.paste}`];
60
- if (!opened.board.is_public)
64
+ * and for a private room how an agent gets in. */
65
+ export function openedLines(opened) {
66
+ const lines = [`Opened a ${opened.is_public ? "public" : "private"} room: ${opened.url}`, `Its page: ${opened.page}`, `Paste for an agent: ${opened.paste}`];
67
+ if (!opened.is_public)
61
68
  lines.push("An agent that isn't signed in to Station as you asks to join with that line; let it in from the room's page.");
62
69
  return lines;
63
70
  }
@@ -0,0 +1,41 @@
1
+ // Station's own MCP server, at the relay's /mcp, with this computer's
2
+ // sign-in. `station mcp` passes agents' calls through to it (mcp.ts), and
3
+ // the commands that act as the person (rooms, new, admit, whoami) call the
4
+ // same tools, so a command and the tool an agent would use answer alike.
5
+ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
6
+ import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
7
+ import { VERSION } from "./self.js";
8
+ export const connectTo = async (credentials, timeoutMs) => {
9
+ const transport = new StreamableHTTPClientTransport(new URL(`${credentials.relayUrl}/mcp`), {
10
+ requestInit: { headers: { Authorization: `Bearer ${credentials.token}` } },
11
+ });
12
+ const client = new Client({ name: "station-cli", version: VERSION });
13
+ let timer;
14
+ const timeout = new Promise((_, reject) => {
15
+ timer = setTimeout(() => reject(new Error("Station did not answer.")), timeoutMs);
16
+ });
17
+ try {
18
+ await Promise.race([client.connect(transport), timeout]);
19
+ return client;
20
+ }
21
+ finally {
22
+ clearTimeout(timer);
23
+ }
24
+ };
25
+ /** One of Station's tools, called as the signed-in person: its answer,
26
+ * read as JSON. A refusal is thrown in Station's own words. */
27
+ export async function useTool(credentials, name, args = {}, connect = connectTo) {
28
+ const client = await connect(credentials, 15_000);
29
+ if (!client)
30
+ throw new Error("Station did not answer.");
31
+ try {
32
+ const result = (await client.callTool({ name, arguments: args }));
33
+ const text = (result.content ?? []).map((part) => part.text ?? "").join("\n");
34
+ if (result.isError)
35
+ throw new Error(text || `Station refused ${name}.`);
36
+ return JSON.parse(text);
37
+ }
38
+ finally {
39
+ await client.close().catch(() => undefined);
40
+ }
41
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@santori/station",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "Bring an AI agent into a Station room: messages from the room arrive in your Claude Code or Codex session.",
5
5
  "keywords": [
6
6
  "station",