@santori/station 0.9.4 → 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/README.md +6 -0
- package/dist/cli.js +24 -4
- package/dist/frame.js +1 -2
- package/dist/guest.js +45 -0
- package/dist/home.js +2 -0
- package/dist/join.js +2 -4
- package/dist/login.js +21 -6
- package/dist/mark.js +24 -15
- 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
|
@@ -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";
|
|
@@ -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
|
|
|
@@ -46,7 +47,8 @@ const HELP = `station: an agent's way into Station rooms
|
|
|
46
47
|
station join <room-url> take a seat for this session (a private room: ask to join and wait,
|
|
47
48
|
or go straight in with its invite token: --invite=<token>)
|
|
48
49
|
station say <text> say something in the room
|
|
49
|
-
[--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)
|
|
50
52
|
[--to <name>[,<name>]] wake only these agents (the room can still read it)
|
|
51
53
|
[--to everyone] in a thread to someone, reach the whole room
|
|
52
54
|
station wait [--seconds N] wait for new messages and print them (until one comes, or N seconds)
|
|
@@ -177,7 +179,7 @@ async function main(argv) {
|
|
|
177
179
|
openBrowser(url);
|
|
178
180
|
out(`${signUp ? "Sign up for Station" : "Sign in to Station"}, then click Connect:\n${url}`);
|
|
179
181
|
if (remote) {
|
|
180
|
-
out(`The link works for
|
|
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)}`);
|
|
181
183
|
return 0;
|
|
182
184
|
}
|
|
183
185
|
// A terminal waits and says who signed in; an agent's shell moves on.
|
|
@@ -241,8 +243,26 @@ async function main(argv) {
|
|
|
241
243
|
case "webhooks":
|
|
242
244
|
return webhookCommand(signedIn(home), args, flag, out, me);
|
|
243
245
|
case "new": {
|
|
244
|
-
const credentials = signedIn(home);
|
|
245
246
|
const title = flag("title") ?? args.join(" ").trim();
|
|
247
|
+
// No sign-in, and none the person was asked for: a public room, as this computer's own identity (guest.ts).
|
|
248
|
+
if (!readCredentials(home) && (!waiting || waiting.claims)) {
|
|
249
|
+
if (flag("team") !== undefined)
|
|
250
|
+
throw new Usage(`A room in a team needs this computer signed in. Run ${me} login and give your person the link.`);
|
|
251
|
+
// Asked for a private room: never open a public one in its place.
|
|
252
|
+
if (flag("public") === "false")
|
|
253
|
+
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.`);
|
|
254
|
+
const relayUrl = (process.env.STATION_RELAY_URL ?? DEFAULT_RELAY).replace(/\/$/, "");
|
|
255
|
+
const guest = await guestFor(home, relayUrl);
|
|
256
|
+
const opened = await call(relayUrl, "/", { token: guest.token }, { body: { ...(title ? { title } : {}), is_public: true } });
|
|
257
|
+
const webUrl = (process.env.STATION_WEB_URL ?? DEFAULT_WEB).replace(/\/$/, "");
|
|
258
|
+
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 }))
|
|
259
|
+
out(line);
|
|
260
|
+
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.`);
|
|
261
|
+
if (opened.note)
|
|
262
|
+
out(opened.note);
|
|
263
|
+
return 0;
|
|
264
|
+
}
|
|
265
|
+
const credentials = signedIn(home);
|
|
246
266
|
const opened = await openRoom(credentials, { title: title || null, isPublic: flag("public") === "true", team: flag("team") });
|
|
247
267
|
for (const line of openedLines(opened))
|
|
248
268
|
out(line);
|
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
|
-
|
|
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/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/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
|
-
|
|
391
|
-
|
|
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
|
@@ -31,9 +31,21 @@ 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;
|
|
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
|
+
}
|
|
37
49
|
export function newVerifier() {
|
|
38
50
|
return randomBytes(32).toString("base64url");
|
|
39
51
|
}
|
|
@@ -93,7 +105,7 @@ export const MAX_TRIES = 5;
|
|
|
93
105
|
* A refused code is answered with why, and the helper keeps listening for
|
|
94
106
|
* the right one, up to MAX_TRIES. `--code` asks for JSON; a browser gets a
|
|
95
107
|
* page. */
|
|
96
|
-
function listen(state, waitMs, trade) {
|
|
108
|
+
function listen(state, waitMs, lasts, trade) {
|
|
97
109
|
return new Promise((resolveStart, rejectStart) => {
|
|
98
110
|
let settle;
|
|
99
111
|
const done = new Promise((resolve, reject) => {
|
|
@@ -148,7 +160,7 @@ function listen(state, waitMs, trade) {
|
|
|
148
160
|
}
|
|
149
161
|
});
|
|
150
162
|
});
|
|
151
|
-
const timer = setTimeout(() => end(new Error(
|
|
163
|
+
const timer = setTimeout(() => end(new Error(`Nobody finished signing in within ${lasts}. Run station login again.`)), waitMs);
|
|
152
164
|
server.on("error", rejectStart);
|
|
153
165
|
server.listen(0, "127.0.0.1", () => {
|
|
154
166
|
const address = server.address();
|
|
@@ -161,10 +173,11 @@ function listen(state, waitMs, trade) {
|
|
|
161
173
|
/** The helper: listens, then trades each code it gets for a token and
|
|
162
174
|
* saves it. `station login-helper` runs it in its own process; tests call
|
|
163
175
|
* it here. */
|
|
164
|
-
export async function runHelper(home, waitMs
|
|
176
|
+
export async function runHelper(home, waitMs) {
|
|
165
177
|
const pending = readPending(home);
|
|
166
178
|
if (!pending)
|
|
167
179
|
return;
|
|
180
|
+
const remote = Boolean(pending.remote);
|
|
168
181
|
const mine = () => readPending(home)?.verifier === pending.verifier;
|
|
169
182
|
// Only while the file is still this sign-in's: a newer login replaces it.
|
|
170
183
|
const report = (more) => {
|
|
@@ -197,10 +210,12 @@ export async function runHelper(home, waitMs = LISTEN_MS) {
|
|
|
197
210
|
remove(files(home).login);
|
|
198
211
|
for (const claim of claims)
|
|
199
212
|
await claimSeat(pending.relayUrl, claim, answer.token);
|
|
213
|
+
// Rooms this computer opened with no sign-in become the person's.
|
|
214
|
+
await carryGuest(home, pending.relayUrl, answer.token);
|
|
200
215
|
};
|
|
201
216
|
try {
|
|
202
|
-
const { port, done } = await listen(pending.state, waitMs, trade);
|
|
203
|
-
report({ pid: process.pid, port, url: loginUrl(pending.webUrl,
|
|
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) });
|
|
204
219
|
await done;
|
|
205
220
|
}
|
|
206
221
|
catch (error) {
|
|
@@ -310,7 +325,7 @@ export function codeIn(given) {
|
|
|
310
325
|
export async function giveCode(home, given, command = "station") {
|
|
311
326
|
const pending = readPending(home);
|
|
312
327
|
if (!pending || pending.error || !pending.port || !alive(pending.pid))
|
|
313
|
-
throw new Error(`No sign-in is waiting for a code here
|
|
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.`);
|
|
314
329
|
const code = codeIn(given);
|
|
315
330
|
if (!code)
|
|
316
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,
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
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 ??
|
|
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
|
|
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
|
-
/**
|
|
77
|
-
*
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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 =
|
|
83
|
-
return
|
|
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/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.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",
|