@santori/station 0.9.3 → 0.9.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/dist/caller.js +7 -0
- package/dist/cli.js +27 -5
- package/dist/daemon.js +20 -8
- package/dist/join.js +24 -5
- package/dist/login.js +10 -5
- package/dist/mcp.js +9 -4
- package/dist/seats.js +1 -1
- package/dist/signup.js +39 -0
- package/dist/usage.js +1 -1
- package/package.json +1 -1
package/dist/caller.js
CHANGED
|
@@ -29,6 +29,13 @@ function session() {
|
|
|
29
29
|
return caller.session;
|
|
30
30
|
}
|
|
31
31
|
const clean = (value) => value?.replace(/\s+/g, "-").replace(/[^A-Za-z0-9._-]/g, "").slice(0, 40) || null;
|
|
32
|
+
/** The agent running this process, as the login page names it: the
|
|
33
|
+
* harness (claude-code, codex), else the program above this one
|
|
34
|
+
* (cursor-agent, devin). A hint for the page's picture, never a check. */
|
|
35
|
+
export function callingAgentName() {
|
|
36
|
+
const { harness, agent } = session();
|
|
37
|
+
return clean(harness === "shell" ? agent : harness);
|
|
38
|
+
}
|
|
32
39
|
export function userAgent() {
|
|
33
40
|
const product = `station-${caller.mode}/${VERSION}`;
|
|
34
41
|
if (caller.mode === "daemon")
|
package/dist/cli.js
CHANGED
|
@@ -26,6 +26,7 @@ import { listRooms, openRoom, openedLines, roomLines, signedIn } from "./rooms.j
|
|
|
26
26
|
import { callingAgent, delivers, deliverTo } from "./sessions.js";
|
|
27
27
|
import { useEnvProxy } from "./proxy.js";
|
|
28
28
|
import { PACKAGE, VERSION, selfCommand } from "./self.js";
|
|
29
|
+
import { signUp } from "./signup.js";
|
|
29
30
|
import { useTool } from "./station.js";
|
|
30
31
|
import { toolCommand } from "./tool.js";
|
|
31
32
|
import { webhookCommand } from "./webhooks.js";
|
|
@@ -35,6 +36,9 @@ const HELP = `station: an agent's way into Station rooms
|
|
|
35
36
|
station login [--signup] [--no-browser] [--wait] [--remote] | login --code=<code>
|
|
36
37
|
sign this computer in through the website: prints the link and
|
|
37
38
|
exits (in a terminal it waits); --signup makes a free account first
|
|
39
|
+
station signup --email <address>
|
|
40
|
+
sign your person up with their email: this computer is signed in at
|
|
41
|
+
once and can open private rooms; they confirm from an email within 7 days
|
|
38
42
|
station logout | whoami
|
|
39
43
|
station rooms [--json] your rooms, your teams' rooms, the ones shared with you, and who is in each
|
|
40
44
|
station new [--title "<title>"] [--public] [--team <team>]
|
|
@@ -106,7 +110,7 @@ const TYPES = {
|
|
|
106
110
|
};
|
|
107
111
|
/** The commands this CLI has of its own. Any other word is looked up in
|
|
108
112
|
* the commands Station defines (commands.ts). */
|
|
109
|
-
const OWN = ["login", "login-helper", "logout", "whoami", "rooms", "webhook", "webhooks", "new", "join", "wait", "read", "say", "name", "file", "ask", "admit", "claim", "status", "trace", "leave", "seats", "tool", "daemon", "mcp", "doctor", "poke", "help", "--help", "--version", "-v", "version"];
|
|
113
|
+
const OWN = ["login", "login-helper", "signup", "logout", "whoami", "rooms", "webhook", "webhooks", "new", "join", "wait", "read", "say", "name", "file", "ask", "admit", "claim", "status", "trace", "leave", "seats", "tool", "daemon", "mcp", "doctor", "poke", "help", "--help", "--version", "-v", "version"];
|
|
110
114
|
/** The help, with the commands Station defines as it last listed them
|
|
111
115
|
* (asked for now when this computer has never had the list). */
|
|
112
116
|
async function help(home, me) {
|
|
@@ -137,7 +141,7 @@ async function main(argv) {
|
|
|
137
141
|
// sign-in gives the helper a moment to save it (login.ts). Not one a join
|
|
138
142
|
// started for its seat's person: the seat works without it.
|
|
139
143
|
const waiting = readPending(home);
|
|
140
|
-
if (!["login", "login-helper", "logout", "daemon", "mcp", "help", "--help", "--version", "-v", "version", undefined].includes(command) && waiting && !waiting.claims) {
|
|
144
|
+
if (!["login", "login-helper", "signup", "logout", "daemon", "mcp", "help", "--help", "--version", "-v", "version", undefined].includes(command) && waiting && !waiting.claims) {
|
|
141
145
|
await finishLogin(home, 15_000);
|
|
142
146
|
}
|
|
143
147
|
switch (command) {
|
|
@@ -190,6 +194,17 @@ async function main(argv) {
|
|
|
190
194
|
out(`Signed in as ${credentials.name}. Agents on this computer can now join your rooms with ${me} join <room-url>.`);
|
|
191
195
|
return 0;
|
|
192
196
|
}
|
|
197
|
+
case "signup": {
|
|
198
|
+
const relayUrl = (flag("relay") ?? process.env.STATION_RELAY_URL ?? DEFAULT_RELAY).replace(/\/$/, "");
|
|
199
|
+
const webUrl = (flag("web") ?? process.env.STATION_WEB_URL ?? DEFAULT_WEB).replace(/\/$/, "");
|
|
200
|
+
const email = (flag("email") ?? args[0] ?? "").trim();
|
|
201
|
+
// The agent asks; it never guesses an address or takes one from a file.
|
|
202
|
+
if (!email || email === "true")
|
|
203
|
+
throw new Usage(`${me} signup --email <address>. Ask the person you work for which email to sign up with, then run it with that one.`);
|
|
204
|
+
for (const line of await signUp(home, relayUrl, webUrl, email, me))
|
|
205
|
+
out(line);
|
|
206
|
+
return 0;
|
|
207
|
+
}
|
|
193
208
|
case "login-helper": {
|
|
194
209
|
// Not in the help: `station login` starts it, detached.
|
|
195
210
|
await runHelper(home);
|
|
@@ -253,7 +268,12 @@ async function main(argv) {
|
|
|
253
268
|
}
|
|
254
269
|
case "wait": {
|
|
255
270
|
const session = inSession();
|
|
256
|
-
const
|
|
271
|
+
const room = flag("room");
|
|
272
|
+
const seats = loadSeats(files(home).seats);
|
|
273
|
+
const left = seats.filter((s) => s.left && s.sessionId === session.id && (!room || room.includes(s.roomId) || s.roomId.startsWith(room))).sort((a, b) => b.joinedAt.localeCompare(a.joinedAt))[0];
|
|
274
|
+
const seat = !seatFor(seats, session.id, room) && left
|
|
275
|
+
? (await takeSeat(home, session, `${left.relayUrl}/${left.roomId}`)).seat
|
|
276
|
+
: mySeat(home, session, room);
|
|
257
277
|
// Written out in full before the position moves: an exit right after
|
|
258
278
|
// console.log can cut a long batch short on a pipe.
|
|
259
279
|
const write = (text) => new Promise((resolve, reject) => process.stdout.write(`${text}\n`, (error) => (error ? reject(error) : resolve())));
|
|
@@ -448,9 +468,11 @@ async function main(argv) {
|
|
|
448
468
|
case "leave": {
|
|
449
469
|
const session = inSession();
|
|
450
470
|
const seat = mySeat(home, session, flag("room"));
|
|
471
|
+
await ensureDaemon(home);
|
|
451
472
|
await call(seat.relayUrl, `/${seat.roomId}/presence`, authFor(seat, readCredentials(home)), { body: { leaving: true } });
|
|
452
|
-
|
|
453
|
-
|
|
473
|
+
const dropped = await ask(files(home).socket, { op: "drop", sessionId: seat.sessionId, roomId: seat.roomId });
|
|
474
|
+
if (!dropped.ok)
|
|
475
|
+
throw new Error(dropped.error);
|
|
454
476
|
out(`Left ${roomLabel(seat)}.`);
|
|
455
477
|
return 0;
|
|
456
478
|
}
|
package/dist/daemon.js
CHANGED
|
@@ -77,9 +77,9 @@ export async function runDaemon(home) {
|
|
|
77
77
|
waitingSent.set(key, receipt.waiting);
|
|
78
78
|
void call(seat.relayUrl, `/${seat.roomId}/delivery`, authFor(seat, readCredentials(home)), { body: receipt }).catch((error) => log(`${key} receipt not sent: ${error instanceof Error ? error.message : String(error)}`));
|
|
79
79
|
};
|
|
80
|
-
let emptySince = seats.
|
|
80
|
+
let emptySince = seats.some((s) => !s.left) ? null : Date.now();
|
|
81
81
|
const save = () => writeJson(paths.seats, seats);
|
|
82
|
-
const find = (key) => seats.find((seat) => keyOf(seat) === key) ?? null;
|
|
82
|
+
const find = (key) => seats.find((seat) => keyOf(seat) === key && !seat.left) ?? null;
|
|
83
83
|
const participantsFor = async (seat, authors) => {
|
|
84
84
|
const key = keyOf(seat);
|
|
85
85
|
const known = people.get(key) ?? [];
|
|
@@ -90,7 +90,7 @@ export async function runDaemon(home) {
|
|
|
90
90
|
// Someone new spoke: maybe the person this seat works for, come in late.
|
|
91
91
|
const learned = withOwner(seat, room.owner);
|
|
92
92
|
if (learned !== seat) {
|
|
93
|
-
seats = seats.map((s) => (keyOf(s) === key ?
|
|
93
|
+
seats = seats.map((s) => (keyOf(s) === key ? withOwner(s, room.owner) : s));
|
|
94
94
|
save();
|
|
95
95
|
log(`${key} now knows who it works for`);
|
|
96
96
|
}
|
|
@@ -121,11 +121,15 @@ export async function runDaemon(home) {
|
|
|
121
121
|
let seat = find(key);
|
|
122
122
|
while (seat) {
|
|
123
123
|
const answer = await call(seat.relayUrl, `/${seat.roomId}/messages?after=${seat.after}`, authFor(seat, readCredentials(home)));
|
|
124
|
+
if (!find(key))
|
|
125
|
+
break;
|
|
124
126
|
const before = seat.guard ?? freshGuard();
|
|
125
127
|
const otherRooms = seats.some((s) => s.sessionId === seat.sessionId && s.roomId !== seat.roomId);
|
|
126
128
|
const result = await handOver(() => find(key) ?? seat, before, answer, roomOf(key), Date.now(), selfCommand(), otherRooms);
|
|
127
129
|
const { text, handed, guard } = result;
|
|
128
|
-
seat = find(key)
|
|
130
|
+
seat = find(key);
|
|
131
|
+
if (!seat)
|
|
132
|
+
break;
|
|
129
133
|
if (text) {
|
|
130
134
|
if (!isRunning(seat.harness, seat.sessionId)) {
|
|
131
135
|
// The tick decides whether it ended.
|
|
@@ -155,6 +159,8 @@ export async function runDaemon(home) {
|
|
|
155
159
|
report(seat, { waiting: result.waiting });
|
|
156
160
|
if (answer.next_after === seat.after && JSON.stringify(guard) === JSON.stringify(before))
|
|
157
161
|
break;
|
|
162
|
+
if (!find(key))
|
|
163
|
+
break;
|
|
158
164
|
const moved = { ...seat, after: answer.next_after, guard };
|
|
159
165
|
seats = seats.map((s) => (keyOf(s) === key ? moved : s));
|
|
160
166
|
save();
|
|
@@ -229,9 +235,9 @@ export async function runDaemon(home) {
|
|
|
229
235
|
waitingSent.delete(key);
|
|
230
236
|
lent.delete(key);
|
|
231
237
|
people.delete(key);
|
|
232
|
-
seats = seats.
|
|
238
|
+
seats = seats.map((s) => keyOf(s) === key ? { ...s, left: true } : s);
|
|
233
239
|
save();
|
|
234
|
-
if (!seats.
|
|
240
|
+
if (!seats.some((s) => !s.left))
|
|
235
241
|
emptySince = Date.now();
|
|
236
242
|
if (seat && leave) {
|
|
237
243
|
void call(seat.relayUrl, `/${seat.roomId}/presence`, authFor(seat, readCredentials(home)), { body: { leaving: true } }).catch(() => { });
|
|
@@ -292,6 +298,12 @@ export async function runDaemon(home) {
|
|
|
292
298
|
drop(keyOf(request), false);
|
|
293
299
|
return { ok: true };
|
|
294
300
|
}
|
|
301
|
+
if (request.op === "forget") {
|
|
302
|
+
drop(keyOf(request), false);
|
|
303
|
+
seats = seats.filter((s) => keyOf(s) !== keyOf(request));
|
|
304
|
+
save();
|
|
305
|
+
return { ok: true };
|
|
306
|
+
}
|
|
295
307
|
if (request.op !== "read" && request.op !== "held" && request.op !== "heldRead")
|
|
296
308
|
return { ok: false, error: "unknown request" };
|
|
297
309
|
const key = keyOf(request);
|
|
@@ -330,10 +342,10 @@ export async function runDaemon(home) {
|
|
|
330
342
|
// their sessions.
|
|
331
343
|
chmodSync(paths.socket, 0o600);
|
|
332
344
|
log(`daemon ${process.pid} (Station ${VERSION}) listening; ${seats.length} seat(s)`);
|
|
333
|
-
for (const seat of seats)
|
|
345
|
+
for (const seat of seats.filter((s) => !s.left))
|
|
334
346
|
connectLive(seat);
|
|
335
347
|
const tick = setInterval(() => {
|
|
336
|
-
for (const seat of
|
|
348
|
+
for (const seat of seats.filter((s) => !s.left)) {
|
|
337
349
|
const key = keyOf(seat);
|
|
338
350
|
if (!delivers(seat.harness)) {
|
|
339
351
|
if (Date.now() - Date.parse(seat.seenAt ?? seat.joinedAt) > SHELL_GONE_MS)
|
package/dist/join.js
CHANGED
|
@@ -11,7 +11,7 @@ import { answers, ask } from "./daemon.js";
|
|
|
11
11
|
import { askedFrame, askedIn, decisionFrame, decisionsFor, frame, hearerFor } from "./frame.js";
|
|
12
12
|
import { lineOf, noteFor, threadHint, whereOf } from "./mark.js";
|
|
13
13
|
import { DEFAULT_WEB, files, installId, readCredentials, stationHome } from "./home.js";
|
|
14
|
-
import { call, parseRoomUrl } from "./relay.js";
|
|
14
|
+
import { call, parseRoomUrl, RelayError } from "./relay.js";
|
|
15
15
|
import { authFor, loadSeats, roomLabel, seatFor } from "./seats.js";
|
|
16
16
|
import { addClaim, codeStep, elsewhere, readPending, startLogin } from "./login.js";
|
|
17
17
|
import { HARNESS_NAMES, callingAgent, delivers, shellSession, workerName } from "./sessions.js";
|
|
@@ -83,8 +83,12 @@ export async function ensureDaemon(home) {
|
|
|
83
83
|
/** The calling session's seat, in `room` when given. */
|
|
84
84
|
export function mySeat(home, session, room) {
|
|
85
85
|
const seat = seatFor(loadSeats(files(home).seats), session.id, room);
|
|
86
|
-
if (!seat)
|
|
86
|
+
if (!seat) {
|
|
87
|
+
const left = loadSeats(files(home).seats).find((s) => s.left && s.sessionId === session.id && (!room || room.includes(s.roomId) || s.roomId.startsWith(room)));
|
|
88
|
+
if (left)
|
|
89
|
+
throw new Usage(`This session left the room. Come back with: ${selfCommand()} join ${left.relayUrl}/${left.roomId}`);
|
|
87
90
|
throw new Usage(`This session has no seat in a room. Run ${selfCommand()} join <room-url> first.`);
|
|
91
|
+
}
|
|
88
92
|
return seat;
|
|
89
93
|
}
|
|
90
94
|
/** The join body for the session. client tells the relay a daemon holds
|
|
@@ -135,11 +139,26 @@ export async function takeSeat(home, session, url, options = {}) {
|
|
|
135
139
|
via = "room";
|
|
136
140
|
token = null;
|
|
137
141
|
}
|
|
138
|
-
const
|
|
142
|
+
const kept = loadSeats(files(home).seats).find((s) => s.sessionId === session.id && s.roomId === roomId && s.relayUrl === relayUrl);
|
|
143
|
+
const name = (options.name ?? kept?.name ?? `${HARNESS_NAMES[session.harness]} · ${session.name || basename(session.cwd)}`).slice(0, 80);
|
|
139
144
|
const body = joinBody(name, session, options.client);
|
|
140
145
|
if (invite && !token)
|
|
141
146
|
body.invite_token = invite;
|
|
142
|
-
|
|
147
|
+
let joined;
|
|
148
|
+
try {
|
|
149
|
+
joined = await joinOrAsk(relayUrl, roomId, kept?.roomToken ?? token, body, options);
|
|
150
|
+
if (kept?.roomToken)
|
|
151
|
+
via = kept.via;
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
if (!kept?.roomToken || !(error instanceof RelayError) || ![401, 403, 404].includes(error.status))
|
|
155
|
+
throw error;
|
|
156
|
+
await ensureDaemon(home);
|
|
157
|
+
const forgotten = await ask(files(home).socket, { op: "forget", sessionId: session.id, roomId });
|
|
158
|
+
if (!forgotten.ok)
|
|
159
|
+
throw new Error(forgotten.error);
|
|
160
|
+
joined = await joinOrAsk(relayUrl, roomId, token, body, options);
|
|
161
|
+
}
|
|
143
162
|
const participantId = joined.participant.id;
|
|
144
163
|
// From now on the seat calls with its own key, when the room gave one.
|
|
145
164
|
const seatToken = joined.key ?? token;
|
|
@@ -158,7 +177,7 @@ export async function takeSeat(home, session, url, options = {}) {
|
|
|
158
177
|
// The join answers as the seat: the seat of the person it works for,
|
|
159
178
|
// when they have one here.
|
|
160
179
|
ownerSeat: joined.owner ?? null,
|
|
161
|
-
after: Math.max(0, ...joined.messages.map((m) => m.id)),
|
|
180
|
+
after: kept?.participantId === participantId ? kept.after : Math.max(0, ...joined.messages.map((m) => m.id)),
|
|
162
181
|
joinedAt: new Date().toISOString(),
|
|
163
182
|
seenAt: new Date().toISOString(),
|
|
164
183
|
};
|
package/dist/login.js
CHANGED
|
@@ -30,6 +30,7 @@ import { openSync } from "node:fs";
|
|
|
30
30
|
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
|
+
import { callingAgentName } from "./caller.js";
|
|
33
34
|
import { call } from "./relay.js";
|
|
34
35
|
/** How long the helper listens for the website's answer. */
|
|
35
36
|
export const LISTEN_MS = 10 * 60_000;
|
|
@@ -48,14 +49,17 @@ export function elsewhere(env = process.env, platform = process.platform) {
|
|
|
48
49
|
return platform === "linux" && !env.DISPLAY && !env.WAYLAND_DISPLAY;
|
|
49
50
|
}
|
|
50
51
|
/** The link the person opens. With no port, the website shows them the
|
|
51
|
-
* code to give the agent instead of sending the browser to 127.0.0.1.
|
|
52
|
-
|
|
52
|
+
* code to give the agent instead of sending the browser to 127.0.0.1.
|
|
53
|
+
* `agent` names the agent that asked, so the page can show its mark. */
|
|
54
|
+
export function loginUrl(webUrl, port, state, challenge, label, signUp = false, agent = null) {
|
|
53
55
|
const params = new URLSearchParams(port === null ? { challenge, host: label } : { port: String(port), state, challenge, host: label });
|
|
56
|
+
if (agent)
|
|
57
|
+
params.set("agent", agent);
|
|
54
58
|
const connect = `/cli/login?${params}`;
|
|
55
59
|
// Someone with no account yet: the sign-up page, which comes back here.
|
|
56
60
|
return signUp ? `${webUrl}/signup?next=${encodeURIComponent(connect)}` : `${webUrl}${connect}`;
|
|
57
61
|
}
|
|
58
|
-
/** The computer's name on the page ("
|
|
62
|
+
/** The computer's name on the page ("Codex on <label> wants to connect").
|
|
59
63
|
* Elsewhere it is often a container's random id, which the person cannot
|
|
60
64
|
* place, so the page says it is another computer than theirs. */
|
|
61
65
|
export function loginLabel(host, remote) {
|
|
@@ -196,7 +200,7 @@ export async function runHelper(home, waitMs = LISTEN_MS) {
|
|
|
196
200
|
};
|
|
197
201
|
try {
|
|
198
202
|
const { port, done } = await listen(pending.state, waitMs, trade);
|
|
199
|
-
report({ pid: process.pid, port, url: loginUrl(pending.webUrl, pending.remote ? null : port, pending.state, challengeOf(pending.verifier), pending.label, pending.signUp) });
|
|
203
|
+
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) });
|
|
200
204
|
await done;
|
|
201
205
|
}
|
|
202
206
|
catch (error) {
|
|
@@ -220,7 +224,7 @@ export async function claimSeat(relayUrl, claim, token) {
|
|
|
220
224
|
}
|
|
221
225
|
}
|
|
222
226
|
/** Starts a sign-in: the helper listens, and this returns its link. */
|
|
223
|
-
export async function startLogin(home, relayUrl, webUrl, signUp, launch = spawnHelper, remote = false, claims = []) {
|
|
227
|
+
export async function startLogin(home, relayUrl, webUrl, signUp, launch = spawnHelper, remote = false, claims = [], agent = callingAgentName()) {
|
|
224
228
|
// A newer login replaces one still listening.
|
|
225
229
|
const before = readPending(home);
|
|
226
230
|
if (before?.pid && before.pid !== process.pid && alive(before.pid))
|
|
@@ -237,6 +241,7 @@ export async function startLogin(home, relayUrl, webUrl, signUp, launch = spawnH
|
|
|
237
241
|
signUp,
|
|
238
242
|
startedAt: Date.now(),
|
|
239
243
|
...(remote ? { remote } : {}),
|
|
244
|
+
...(agent ? { agent } : {}),
|
|
240
245
|
...(claims.length ? { claims } : {}),
|
|
241
246
|
};
|
|
242
247
|
writeJson(files(home).login, pending);
|
package/dist/mcp.js
CHANGED
|
@@ -89,8 +89,10 @@ export const thisComputer = {
|
|
|
89
89
|
await ask(files(home).socket, { op: "read", sessionId: seat.sessionId, roomId: seat.roomId, after });
|
|
90
90
|
},
|
|
91
91
|
drop: async (home, seat) => {
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
await ensureDaemon(home);
|
|
93
|
+
const dropped = await ask(files(home).socket, { op: "drop", sessionId: seat.sessionId, roomId: seat.roomId });
|
|
94
|
+
if (!dropped.ok)
|
|
95
|
+
throw new Error(dropped.error);
|
|
94
96
|
},
|
|
95
97
|
};
|
|
96
98
|
function cached(path) {
|
|
@@ -173,6 +175,9 @@ export function stationTools(home, post = postToAgent, computer = thisComputer,
|
|
|
173
175
|
seat = await computer.takeSeat(home, caller ?? computer.session(worker), `${relayUrl}/${roomId}${invite}`, name);
|
|
174
176
|
joined = true;
|
|
175
177
|
}
|
|
178
|
+
if (!seat && roomId && caller) {
|
|
179
|
+
seat = loadSeats(files(home).seats).find((s) => s.left && s.sessionId === caller.id && s.roomId === roomId && s.relayUrl === relayUrl) ?? null;
|
|
180
|
+
}
|
|
176
181
|
const headers = ours(folded);
|
|
177
182
|
if (seat) {
|
|
178
183
|
const auth = authFor(seat, credentials);
|
|
@@ -181,7 +186,7 @@ export function stationTools(home, post = postToAgent, computer = thisComputer,
|
|
|
181
186
|
if (auth.participant)
|
|
182
187
|
headers["X-Participant"] = auth.participant;
|
|
183
188
|
headers["X-Station-After"] = String(seat.after);
|
|
184
|
-
if (delivers(seat.harness))
|
|
189
|
+
if (!seat.left && delivers(seat.harness))
|
|
185
190
|
headers["X-Station-Delivered"] = "1";
|
|
186
191
|
if (joined)
|
|
187
192
|
headers["X-Station-Joined"] = "1";
|
|
@@ -190,7 +195,7 @@ export function stationTools(home, post = postToAgent, computer = thisComputer,
|
|
|
190
195
|
Object.assign(headers, asPerson(credentials, relayUrl));
|
|
191
196
|
const result = (await post(relayUrl, headers, "tools/call", { name, arguments: args }));
|
|
192
197
|
const after = result._meta?.["station/after"];
|
|
193
|
-
if (seat && typeof after === "number" && after > seat.after) {
|
|
198
|
+
if (seat && !seat.left && typeof after === "number" && after > seat.after) {
|
|
194
199
|
// The seat's place moves, so the next read starts after these.
|
|
195
200
|
await computer.read(home, seat, after).catch(() => undefined);
|
|
196
201
|
}
|
package/dist/seats.js
CHANGED
|
@@ -14,7 +14,7 @@ export function authFor(seat, credentials) {
|
|
|
14
14
|
/** The calling session's seat: the one in `room` when given (a room URL,
|
|
15
15
|
* an id, or the start of one), else the one it joined last. */
|
|
16
16
|
export function seatFor(seats, sessionId, room) {
|
|
17
|
-
const mine = seats.filter((seat) => seat.sessionId === sessionId);
|
|
17
|
+
const mine = seats.filter((seat) => seat.sessionId === sessionId && !seat.left);
|
|
18
18
|
if (room)
|
|
19
19
|
return mine.find((seat) => room.includes(seat.roomId) || seat.roomId.startsWith(room)) ?? null;
|
|
20
20
|
return mine.sort((a, b) => b.joinedAt.localeCompare(a.joinedAt))[0] ?? null;
|
package/dist/signup.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// `station signup --email <address>`: an agent signs its person up with
|
|
2
|
+
// their email (relay: signups.ts). The relay answers a sign-in for this
|
|
3
|
+
// computer at once, so the agent can open private rooms, and emails the
|
|
4
|
+
// address a link. The person confirms from that email within the week; no
|
|
5
|
+
// browser has to open first, and no code comes back to the agent.
|
|
6
|
+
//
|
|
7
|
+
// Run again on the same computer, it sends the email again, to a corrected
|
|
8
|
+
// address if one is given.
|
|
9
|
+
import { hostname } from "node:os";
|
|
10
|
+
import { DEFAULT_WEB, files, readCredentials, writeJson } from "./home.js";
|
|
11
|
+
import { cancelLogin, claimSeat, elsewhere, loginLabel, readPending } from "./login.js";
|
|
12
|
+
import { call } from "./relay.js";
|
|
13
|
+
/** "November 26": the day the rooms lock, as the email says it. */
|
|
14
|
+
export function lockDay(locksAt) {
|
|
15
|
+
return new Date(locksAt).toLocaleDateString("en-US", { month: "long", day: "numeric", timeZone: "UTC" });
|
|
16
|
+
}
|
|
17
|
+
/** Signs the person up, saves this computer's sign-in, and returns what to print. */
|
|
18
|
+
export async function signUp(home, relayUrl, webUrl, email, me = "station", label = loginLabel(hostname(), elsewhere())) {
|
|
19
|
+
const saved = readCredentials(home);
|
|
20
|
+
// A computer already signed in here says so: the relay sends the email
|
|
21
|
+
// again for a sign-up that waits, and refuses one that has an account.
|
|
22
|
+
const auth = saved && saved.relayUrl === relayUrl ? { token: saved.token } : null;
|
|
23
|
+
const answer = await call(relayUrl, "/signup", auth, { body: { email, label } });
|
|
24
|
+
const day = lockDay(answer.locks_at);
|
|
25
|
+
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
|
+
const fix = `Wrong address? Run: ${me} signup --email <the right one>`;
|
|
27
|
+
if (!answer.token) {
|
|
28
|
+
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
|
+
}
|
|
30
|
+
// Seats this computer took with no sign-in were waiting on a login link to become the person's.
|
|
31
|
+
const claims = readPending(home)?.relayUrl === relayUrl ? (readPending(home)?.claims ?? []) : [];
|
|
32
|
+
cancelLogin(home);
|
|
33
|
+
const site = webUrl === DEFAULT_WEB ? {} : { webUrl };
|
|
34
|
+
const credentials = { relayUrl, ...site, token: answer.token, userId: answer.user_id, name: answer.name ?? answer.email.split("@")[0] };
|
|
35
|
+
writeJson(files(home).credentials, credentials);
|
|
36
|
+
for (const claim of claims)
|
|
37
|
+
await claimSeat(relayUrl, claim, answer.token);
|
|
38
|
+
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
|
+
}
|
package/dist/usage.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
* the CLI prints it and exits 2, and an MCP tool returns it as its error. */
|
|
3
3
|
export class Usage extends Error {
|
|
4
4
|
}
|
|
5
|
-
export const NOT_SIGNED_IN = "Not signed in.
|
|
5
|
+
export const NOT_SIGNED_IN = "Not signed in. Ask the person you work for which email to sign up with, then run station signup --email <their email>: this computer is signed in at once, and they confirm from an email Station sends them. If they already have a Station account, run station login instead and post the link it prints to them.";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@santori/station",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.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",
|