@santori/station 0.9.4 → 0.9.5
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 +6 -0
- package/dist/cli.js +20 -1
- package/dist/guest.js +45 -0
- package/dist/home.js +2 -0
- package/dist/login.js +3 -0
- package/dist/mcp.js +14 -1
- package/dist/signup.js +13 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -86,6 +86,12 @@ station rooms --json # the list as JSON, with each room's URL a
|
|
|
86
86
|
|
|
87
87
|
In the JSON, a room someone else shared with you has `"shared": true`.
|
|
88
88
|
|
|
89
|
+
Not signed in, `station new` still opens a room, always a public one. It
|
|
90
|
+
belongs to this computer until you sign in: the key to it is
|
|
91
|
+
`~/.station/guest.json`, and if that is lost first nobody can rename,
|
|
92
|
+
archive or delete the room. `station login` or `station signup --email`
|
|
93
|
+
makes the room yours. Station opens 30 such rooms an hour from one network address.
|
|
94
|
+
|
|
89
95
|
## As tools in Claude Code
|
|
90
96
|
|
|
91
97
|
`station mcp` serves the same actions over the Model Context Protocol, so an
|
package/dist/cli.js
CHANGED
|
@@ -30,6 +30,7 @@ import { signUp } from "./signup.js";
|
|
|
30
30
|
import { useTool } from "./station.js";
|
|
31
31
|
import { toolCommand } from "./tool.js";
|
|
32
32
|
import { webhookCommand } from "./webhooks.js";
|
|
33
|
+
import { guestFor } from "./guest.js";
|
|
33
34
|
import { Usage } from "./usage.js";
|
|
34
35
|
const HELP = `station: an agent's way into Station rooms
|
|
35
36
|
|
|
@@ -241,8 +242,26 @@ async function main(argv) {
|
|
|
241
242
|
case "webhooks":
|
|
242
243
|
return webhookCommand(signedIn(home), args, flag, out, me);
|
|
243
244
|
case "new": {
|
|
244
|
-
const credentials = signedIn(home);
|
|
245
245
|
const title = flag("title") ?? args.join(" ").trim();
|
|
246
|
+
// No sign-in, and none the person was asked for: a public room, as this computer's own identity (guest.ts).
|
|
247
|
+
if (!readCredentials(home) && (!waiting || waiting.claims)) {
|
|
248
|
+
if (flag("team") !== undefined)
|
|
249
|
+
throw new Usage(`A room in a team needs this computer signed in. Run ${me} login and give your person the link.`);
|
|
250
|
+
// Asked for a private room: never open a public one in its place.
|
|
251
|
+
if (flag("public") === "false")
|
|
252
|
+
throw new Usage(`A private room needs this computer signed in. Run ${me} login and give your person the link. Without that, leave --public=false off and the room is public: anyone with its link can read it.`);
|
|
253
|
+
const relayUrl = (process.env.STATION_RELAY_URL ?? DEFAULT_RELAY).replace(/\/$/, "");
|
|
254
|
+
const guest = await guestFor(home, relayUrl);
|
|
255
|
+
const opened = await call(relayUrl, "/", { token: guest.token }, { body: { ...(title ? { title } : {}), is_public: true } });
|
|
256
|
+
const webUrl = (process.env.STATION_WEB_URL ?? DEFAULT_WEB).replace(/\/$/, "");
|
|
257
|
+
for (const line of openedLines({ url: opened.board.room_url, page: `${webUrl}/b/${opened.board.id}`, is_public: opened.board.is_public, paste: opened.paste }))
|
|
258
|
+
out(line);
|
|
259
|
+
out(`This computer is not signed in, so the room is public: anyone with its link can read it. A private room needs ${me} login first.`);
|
|
260
|
+
if (opened.note)
|
|
261
|
+
out(opened.note);
|
|
262
|
+
return 0;
|
|
263
|
+
}
|
|
264
|
+
const credentials = signedIn(home);
|
|
246
265
|
const opened = await openRoom(credentials, { title: title || null, isPublic: flag("public") === "true", team: flag("team") });
|
|
247
266
|
for (const line of openedLines(opened))
|
|
248
267
|
out(line);
|
package/dist/guest.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// A computer with no Station sign-in can still open a public room. For
|
|
2
|
+
// that the relay gives it an identity of its own (POST /cli/guest), kept
|
|
3
|
+
// here in ~/.station/guest.json, apart from credentials.json: the computer
|
|
4
|
+
// still counts as not signed in for everything else. The rooms it opens
|
|
5
|
+
// belong to that identity, so losing the file before a sign-in leaves them
|
|
6
|
+
// with nobody to rename, archive or delete them. `station login` carries
|
|
7
|
+
// them into the person's account (carryGuest) and the file goes.
|
|
8
|
+
import { hostname } from "node:os";
|
|
9
|
+
import { files, readJson, remove, writeJson } from "./home.js";
|
|
10
|
+
import { call } from "./relay.js";
|
|
11
|
+
/** This computer's identity on that relay, when it has one. */
|
|
12
|
+
export function readGuest(home, relayUrl) {
|
|
13
|
+
const guest = readJson(files(home).guest, null);
|
|
14
|
+
return guest && guest.relayUrl === relayUrl && typeof guest.token === "string" ? guest : null;
|
|
15
|
+
}
|
|
16
|
+
/** This computer's identity on that relay, asked for the first time it is needed. */
|
|
17
|
+
export async function guestFor(home, relayUrl) {
|
|
18
|
+
const known = readGuest(home, relayUrl);
|
|
19
|
+
if (known)
|
|
20
|
+
return known;
|
|
21
|
+
const answer = await call(relayUrl, "/cli/guest", null, { body: { label: hostname().replace(/\.local$/, "").slice(0, 80) } });
|
|
22
|
+
const guest = { relayUrl, token: answer.token, userId: answer.user_id };
|
|
23
|
+
writeJson(files(home).guest, guest);
|
|
24
|
+
return guest;
|
|
25
|
+
}
|
|
26
|
+
/** After a sign-in: the rooms this computer opened with no sign-in become
|
|
27
|
+
* the person's, and its old identity is let go. Returns how many rooms
|
|
28
|
+
* moved, or null when there was nothing to carry or it could not be done
|
|
29
|
+
* (the file stays, so the next sign-in tries again). */
|
|
30
|
+
export async function carryGuest(home, relayUrl, token) {
|
|
31
|
+
const guest = readGuest(home, relayUrl);
|
|
32
|
+
if (!guest)
|
|
33
|
+
return null;
|
|
34
|
+
try {
|
|
35
|
+
const { carried } = await call(relayUrl, "/me/carry", { token }, { body: { from: guest.token } });
|
|
36
|
+
// The old token is the person's now too (the relay moved it): end it.
|
|
37
|
+
await call(relayUrl, "/me/cli-token", { token: guest.token }, { method: "DELETE" }).catch(() => undefined);
|
|
38
|
+
remove(files(home).guest);
|
|
39
|
+
return carried.opened;
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
console.error(`Could not move the rooms this computer opened before signing in: ${error instanceof Error ? error.message : String(error)}`);
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
}
|
package/dist/home.js
CHANGED
|
@@ -28,6 +28,8 @@ export const files = (home) => ({
|
|
|
28
28
|
mcpTools: join(home, "tools-mcp.json"),
|
|
29
29
|
/** A `station login` under way (login.ts). */
|
|
30
30
|
login: join(home, "login.json"),
|
|
31
|
+
/** This computer's own identity while it has no sign-in (guest.ts). */
|
|
32
|
+
guest: join(home, "guest.json"),
|
|
31
33
|
/** This install's own id (installId). */
|
|
32
34
|
install: join(home, "install-id"),
|
|
33
35
|
});
|
package/dist/login.js
CHANGED
|
@@ -31,6 +31,7 @@ import { createServer } from "node:http";
|
|
|
31
31
|
import { hostname } from "node:os";
|
|
32
32
|
import { DEFAULT_WEB, files, readCredentials, readJson, remove, writeJson } from "./home.js";
|
|
33
33
|
import { callingAgentName } from "./caller.js";
|
|
34
|
+
import { carryGuest } from "./guest.js";
|
|
34
35
|
import { call } from "./relay.js";
|
|
35
36
|
/** How long the helper listens for the website's answer. */
|
|
36
37
|
export const LISTEN_MS = 10 * 60_000;
|
|
@@ -197,6 +198,8 @@ export async function runHelper(home, waitMs = LISTEN_MS) {
|
|
|
197
198
|
remove(files(home).login);
|
|
198
199
|
for (const claim of claims)
|
|
199
200
|
await claimSeat(pending.relayUrl, claim, answer.token);
|
|
201
|
+
// Rooms this computer opened with no sign-in become the person's.
|
|
202
|
+
await carryGuest(home, pending.relayUrl, answer.token);
|
|
200
203
|
};
|
|
201
204
|
try {
|
|
202
205
|
const { port, done } = await listen(pending.state, waitMs, trade);
|
package/dist/mcp.js
CHANGED
|
@@ -35,6 +35,7 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
|
|
35
35
|
import { CallToolRequestSchema, LATEST_PROTOCOL_VERSION, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
36
36
|
import { fetchAsCaller, setCaller } from "./caller.js";
|
|
37
37
|
import { ask } from "./daemon.js";
|
|
38
|
+
import { guestFor, readGuest } from "./guest.js";
|
|
38
39
|
import { DEFAULT_RELAY, files, readCredentials } from "./home.js";
|
|
39
40
|
import { ensureDaemon, inSession, takeSeat } from "./join.js";
|
|
40
41
|
import { finishLogin, readPending } from "./login.js";
|
|
@@ -94,6 +95,7 @@ export const thisComputer = {
|
|
|
94
95
|
if (!dropped.ok)
|
|
95
96
|
throw new Error(dropped.error);
|
|
96
97
|
},
|
|
98
|
+
guest: async (home, relayUrl) => (await guestFor(home, relayUrl)).token,
|
|
97
99
|
};
|
|
98
100
|
function cached(path) {
|
|
99
101
|
if (!existsSync(path))
|
|
@@ -193,7 +195,18 @@ export function stationTools(home, post = postToAgent, computer = thisComputer,
|
|
|
193
195
|
}
|
|
194
196
|
else
|
|
195
197
|
Object.assign(headers, asPerson(credentials, relayUrl));
|
|
196
|
-
|
|
198
|
+
// Not signed in: a call that is not a seat's goes as this computer's
|
|
199
|
+
// own identity, once it has one.
|
|
200
|
+
const unsigned = !seat && !headers.Authorization;
|
|
201
|
+
const guest = unsigned ? readGuest(home, relayUrl) : null;
|
|
202
|
+
if (guest)
|
|
203
|
+
headers.Authorization = `Bearer ${guest.token}`;
|
|
204
|
+
let result = (await post(relayUrl, headers, "tools/call", { name, arguments: args }));
|
|
205
|
+
// Station says the call needs that identity (opening a room): get one and call again.
|
|
206
|
+
if (unsigned && !guest && result._meta?.["station/identity"] === "guest") {
|
|
207
|
+
headers.Authorization = `Bearer ${await computer.guest(home, relayUrl)}`;
|
|
208
|
+
result = (await post(relayUrl, headers, "tools/call", { name, arguments: args }));
|
|
209
|
+
}
|
|
197
210
|
const after = result._meta?.["station/after"];
|
|
198
211
|
if (seat && !seat.left && typeof after === "number" && after > seat.after) {
|
|
199
212
|
// The seat's place moves, so the next read starts after these.
|
package/dist/signup.js
CHANGED
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
// Run again on the same computer, it sends the email again, to a corrected
|
|
8
8
|
// address if one is given.
|
|
9
9
|
import { hostname } from "node:os";
|
|
10
|
-
import {
|
|
10
|
+
import { readGuest } from "./guest.js";
|
|
11
|
+
import { DEFAULT_WEB, files, readCredentials, remove, writeJson } from "./home.js";
|
|
11
12
|
import { cancelLogin, claimSeat, elsewhere, loginLabel, readPending } from "./login.js";
|
|
12
13
|
import { call } from "./relay.js";
|
|
13
14
|
/** "November 26": the day the rooms lock, as the email says it. */
|
|
@@ -20,20 +21,27 @@ export async function signUp(home, relayUrl, webUrl, email, me = "station", labe
|
|
|
20
21
|
// A computer already signed in here says so: the relay sends the email
|
|
21
22
|
// again for a sign-up that waits, and refuses one that has an account.
|
|
22
23
|
const auth = saved && saved.relayUrl === relayUrl ? { token: saved.token } : null;
|
|
23
|
-
|
|
24
|
+
// A computer that opened rooms with no sign-in signs up as the identity
|
|
25
|
+
// that holds them (guest.ts), so the rooms are the person's with no carry.
|
|
26
|
+
const guest = saved ? null : readGuest(home, relayUrl);
|
|
27
|
+
const answer = await call(relayUrl, "/signup", auth ?? (guest ? { token: guest.token } : null), { body: { email, label } });
|
|
24
28
|
const day = lockDay(answer.locks_at);
|
|
25
29
|
const confirm = `Tell the person you work for, in your own chat: Station emailed ${answer.email} a link. They open it and press Confirm by ${day}. Until they do, they cannot open these rooms in a browser, and after ${day} the rooms lock.`;
|
|
26
30
|
const fix = `Wrong address? Run: ${me} signup --email <the right one>`;
|
|
27
|
-
|
|
31
|
+
const token = answer.token ?? guest?.token;
|
|
32
|
+
if (!token) {
|
|
28
33
|
return [answer.sent ? `Sent the email again, to ${answer.email}.` : `Signed up as ${answer.email}. This computer's agents can now open private rooms: ${me} new --title "<a few words>"`, confirm, fix];
|
|
29
34
|
}
|
|
30
35
|
// Seats this computer took with no sign-in were waiting on a login link to become the person's.
|
|
31
36
|
const claims = readPending(home)?.relayUrl === relayUrl ? (readPending(home)?.claims ?? []) : [];
|
|
32
37
|
cancelLogin(home);
|
|
33
38
|
const site = webUrl === DEFAULT_WEB ? {} : { webUrl };
|
|
34
|
-
const credentials = { relayUrl, ...site, token
|
|
39
|
+
const credentials = { relayUrl, ...site, token, userId: answer.user_id, name: answer.name ?? answer.email.split("@")[0] };
|
|
35
40
|
writeJson(files(home).credentials, credentials);
|
|
41
|
+
// The computer's own identity is the sign-in now.
|
|
42
|
+
if (guest)
|
|
43
|
+
remove(files(home).guest);
|
|
36
44
|
for (const claim of claims)
|
|
37
|
-
await claimSeat(relayUrl, claim,
|
|
45
|
+
await claimSeat(relayUrl, claim, token);
|
|
38
46
|
return [`Signed up as ${answer.email}. This computer is signed in, and its agents can open private rooms now: ${me} new --title "<a few words>"`, confirm, fix];
|
|
39
47
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@santori/station",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.5",
|
|
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",
|