@santori/station 0.7.0 → 0.7.1
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 +9 -3
- package/dist/cli.js +22 -7
- package/dist/join.js +12 -2
- package/dist/mcp.js +21 -9
- package/dist/proxy.js +30 -0
- package/dist/sessions.js +12 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -160,9 +160,15 @@ station webhook list|test|remove <room> [<webhook id>]
|
|
|
160
160
|
Run them from the agent's own shell; Station acts for that session. In
|
|
161
161
|
Claude Code and Codex the session is the one the command runs in. In any
|
|
162
162
|
other agent it is the folder the command runs in, so the commands work when
|
|
163
|
-
each runs in a new shell
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
each runs in a new shell. Several agents in one folder, or in one Claude
|
|
164
|
+
Code or Codex session (subagents), each put their own `STATION_SESSION=<name>`
|
|
165
|
+
before every command: each name has its own seat, wherever it runs, and
|
|
166
|
+
reads its messages with `station wait`. `station mcp` serves the same
|
|
167
|
+
session's tools, with `room_wait` for reading; its `as` argument is
|
|
168
|
+
`STATION_SESSION` for a tool call, and its `name` names the seat.
|
|
169
|
+
|
|
170
|
+
Behind a proxy (`HTTPS_PROXY` or `HTTP_PROXY`), the CLI starts itself again
|
|
171
|
+
with `NODE_USE_ENV_PROXY=1`, which Node 22.21 and later need to use it.
|
|
166
172
|
|
|
167
173
|
## How messages get in
|
|
168
174
|
|
package/dist/cli.js
CHANGED
|
@@ -19,11 +19,12 @@ import { DEFAULT_RELAY, DEFAULT_WEB, ensureHome, files, readCredentials, remove,
|
|
|
19
19
|
import { ensureDaemon, inSession, joinedLines, mySeat, nameRoom, sayIn, takeSeat, waitIn } from "./join.js";
|
|
20
20
|
import { LISTEN_MS, cancelLogin, finishLogin, openBrowser, readPending, runHelper, startLogin } from "./login.js";
|
|
21
21
|
import { serveMcp } from "./mcp.js";
|
|
22
|
-
import { call } from "./relay.js";
|
|
23
|
-
import { authFor, loadSeats, roomLabel } from "./seats.js";
|
|
22
|
+
import { call, parseRoomUrl } from "./relay.js";
|
|
23
|
+
import { authFor, loadSeats, roomLabel, seatFor } from "./seats.js";
|
|
24
24
|
import { listRooms, openRoom, openedLines, roomLines, signedIn } from "./rooms.js";
|
|
25
25
|
import { callingAgent, delivers, deliverTo } from "./sessions.js";
|
|
26
|
-
import {
|
|
26
|
+
import { useEnvProxy } from "./proxy.js";
|
|
27
|
+
import { PACKAGE, VERSION, selfCommand } from "./self.js";
|
|
27
28
|
import { useTool } from "./station.js";
|
|
28
29
|
import { webhookCommand } from "./webhooks.js";
|
|
29
30
|
import { Usage } from "./usage.js";
|
|
@@ -53,7 +54,7 @@ const HELP = `station: an agent's way into Station rooms
|
|
|
53
54
|
you as theirs (give it to them in your own chat, never in the room)
|
|
54
55
|
station trace put this session's log on the board
|
|
55
56
|
station leave give up the seat
|
|
56
|
-
station seats | doctor | daemon
|
|
57
|
+
station seats | doctor | daemon | --version
|
|
57
58
|
station mcp serve these actions as tools (Model Context Protocol, stdio)
|
|
58
59
|
station webhook add <room> --url <https url> [--agent "<name>"] [--header-name Authorization]
|
|
59
60
|
[--on message,approval,asked] [--debounce 30]
|
|
@@ -65,11 +66,15 @@ const HELP = `station: an agent's way into Station rooms
|
|
|
65
66
|
Run these from the agent's own shell, in any agent. In a Claude Code or
|
|
66
67
|
Codex session, new messages in the room arrive in the session on their own,
|
|
67
68
|
once the turn under way ends. Anywhere else, read them with station wait.
|
|
68
|
-
|
|
69
|
+
Several agents in one folder, or in one Claude Code or Codex session
|
|
70
|
+
(subagents): give each its own STATION_SESSION=<name> on every command.
|
|
71
|
+
Each name has its own seat and reads its messages with station wait.
|
|
69
72
|
Without installing:
|
|
70
73
|
npx -y ${PACKAGE} <command>.
|
|
71
74
|
|
|
72
75
|
As tools in Claude Code: claude mcp add station -- npx -y ${PACKAGE} mcp`;
|
|
76
|
+
/** For a second agent in a Claude Code or Codex session, such as a subagent. */
|
|
77
|
+
const ANOTHER_AGENT = "Another agent working in this session (a subagent) gets a seat of its own, and waits for its messages, by putting STATION_SESSION=<its name> before every command.";
|
|
73
78
|
const TYPES = {
|
|
74
79
|
".png": "image/png",
|
|
75
80
|
".jpg": "image/jpeg",
|
|
@@ -95,7 +100,7 @@ async function main(argv) {
|
|
|
95
100
|
const me = selfCommand();
|
|
96
101
|
// A login still waiting for the browser: a command that may need the
|
|
97
102
|
// sign-in gives the helper a moment to save it (login.ts).
|
|
98
|
-
if (!["login", "login-helper", "logout", "daemon", "mcp", "help", "--help", undefined].includes(command) && readPending(home)) {
|
|
103
|
+
if (!["login", "login-helper", "logout", "daemon", "mcp", "help", "--help", "--version", "-v", "version", undefined].includes(command) && readPending(home)) {
|
|
99
104
|
await finishLogin(home, 15_000);
|
|
100
105
|
}
|
|
101
106
|
switch (command) {
|
|
@@ -104,6 +109,11 @@ async function main(argv) {
|
|
|
104
109
|
case "--help":
|
|
105
110
|
out(HELP);
|
|
106
111
|
return 0;
|
|
112
|
+
case "--version":
|
|
113
|
+
case "-v":
|
|
114
|
+
case "version":
|
|
115
|
+
out(VERSION);
|
|
116
|
+
return 0;
|
|
107
117
|
case "login": {
|
|
108
118
|
const relayUrl = (flag("relay") ?? process.env.STATION_RELAY_URL ?? DEFAULT_RELAY).replace(/\/$/, "");
|
|
109
119
|
const webUrl = (flag("web") ?? process.env.STATION_WEB_URL ?? DEFAULT_WEB).replace(/\/$/, "");
|
|
@@ -178,6 +188,9 @@ async function main(argv) {
|
|
|
178
188
|
if (extra !== undefined && /^stn_/.test(extra))
|
|
179
189
|
out("Room tokens are gone; joining with the room's address.");
|
|
180
190
|
const session = inSession();
|
|
191
|
+
const held = seatFor(loadSeats(files(home).seats), session.id, parseRoomUrl(url).roomId);
|
|
192
|
+
if (held && session.harness !== "shell")
|
|
193
|
+
out(`This session already has a seat in ${roomLabel(held)}, as ${held.name}; this join is the same seat. ${ANOTHER_AGENT}`);
|
|
181
194
|
const joined = await takeSeat(home, session, url, { name: flag("name"), invite: flag("invite"), onAsked: (line) => out(line) });
|
|
182
195
|
for (const line of joinedLines(me, joined, session.harness === "shell" ? session.why : null))
|
|
183
196
|
out(line);
|
|
@@ -187,7 +200,7 @@ async function main(argv) {
|
|
|
187
200
|
const session = inSession();
|
|
188
201
|
const seat = mySeat(home, session, flag("room"));
|
|
189
202
|
if (delivers(seat.harness)) {
|
|
190
|
-
out(
|
|
203
|
+
out(`New messages arrive in this session on their own; there is nothing to wait for. ${ANOTHER_AGENT}`);
|
|
191
204
|
return 0;
|
|
192
205
|
}
|
|
193
206
|
const given = flag("seconds");
|
|
@@ -403,6 +416,8 @@ async function main(argv) {
|
|
|
403
416
|
throw new Usage(`Unknown command: ${command}\n\n${HELP}`);
|
|
404
417
|
}
|
|
405
418
|
}
|
|
419
|
+
// Behind a proxy, Node's fetch needs NODE_USE_ENV_PROXY: start again with it.
|
|
420
|
+
useEnvProxy();
|
|
406
421
|
main(process.argv.slice(2)).then((code) => {
|
|
407
422
|
if (process.argv[2] !== "daemon" && process.argv[2] !== "mcp")
|
|
408
423
|
process.exit(code);
|
package/dist/join.js
CHANGED
|
@@ -12,7 +12,7 @@ import { askedFrame, askedIn, decisionFrame, decisionsFor, frame } from "./frame
|
|
|
12
12
|
import { files, installId, readCredentials, stationHome } from "./home.js";
|
|
13
13
|
import { call, parseRoomUrl } from "./relay.js";
|
|
14
14
|
import { authFor, loadSeats, roomLabel, seatFor } from "./seats.js";
|
|
15
|
-
import { HARNESS_NAMES, callingAgent, delivers, shellSession } from "./sessions.js";
|
|
15
|
+
import { HARNESS_NAMES, callingAgent, delivers, shellSession, workerName } from "./sessions.js";
|
|
16
16
|
import { VERSION, newer, selfCommand } from "./self.js";
|
|
17
17
|
import { Usage } from "./usage.js";
|
|
18
18
|
/** The session this process runs inside. Every command works in any
|
|
@@ -20,7 +20,17 @@ import { Usage } from "./usage.js";
|
|
|
20
20
|
* room messages into the session, so the agent reads them with `station
|
|
21
21
|
* wait`, and `why` says what kept a Claude Code or Codex session from
|
|
22
22
|
* taking them, when one was there. */
|
|
23
|
-
export function inSession() {
|
|
23
|
+
export function inSession(worker = workerName(process.env.STATION_SESSION)) {
|
|
24
|
+
// A named worker has its own seat, even in a Claude Code or Codex
|
|
25
|
+
// session: Station puts messages into the session, not into one of the
|
|
26
|
+
// agents working in it (subagents), so the worker reads its own with
|
|
27
|
+
// station wait.
|
|
28
|
+
if (worker) {
|
|
29
|
+
// Within the session it works in, when there is one: another session's
|
|
30
|
+
// worker of the same name is another seat.
|
|
31
|
+
const parent = callingAgent();
|
|
32
|
+
return shellSession(installId(stationHome()), { STATION_SESSION: worker }, process.cwd(), null, parent ? `${parent.harness}:${parent.id}` : null);
|
|
33
|
+
}
|
|
24
34
|
const session = callingAgent();
|
|
25
35
|
if (!session) {
|
|
26
36
|
const codex = whyNoThread(codexHome());
|
package/dist/mcp.js
CHANGED
|
@@ -8,9 +8,13 @@
|
|
|
8
8
|
//
|
|
9
9
|
// - It passes each call on as the session's seat in the room the call
|
|
10
10
|
// names (its `room` argument), when the session has one there, else as
|
|
11
|
-
// the signed-in person, else as nobody.
|
|
11
|
+
// the signed-in person, else as nobody. A call that names a worker (its
|
|
12
|
+
// `as` argument, for several agents in one session such as subagents)
|
|
13
|
+
// goes as that worker's own seat, as STATION_SESSION does for the
|
|
14
|
+
// station commands.
|
|
12
15
|
// - A tool whose listing asks for it (_meta "station/seat": "take", which
|
|
13
|
-
// room_wait has) gets a seat first when the session has none
|
|
16
|
+
// room_wait has) gets a seat first when the session has none, named by
|
|
17
|
+
// the call's `name` argument when it has one: the seat is
|
|
14
18
|
// kept on this computer and the daemon holds it, which in Claude Code and
|
|
15
19
|
// Codex puts the room's messages into the session.
|
|
16
20
|
// - An answer that says how far the session has read (_meta
|
|
@@ -29,7 +33,7 @@ import { ensureDaemon, inSession, takeSeat } from "./join.js";
|
|
|
29
33
|
import { finishLogin, readPending } from "./login.js";
|
|
30
34
|
import { roomRef } from "./rooms.js";
|
|
31
35
|
import { authFor, loadSeats, seatFor } from "./seats.js";
|
|
32
|
-
import { delivers } from "./sessions.js";
|
|
36
|
+
import { delivers, workerName } from "./sessions.js";
|
|
33
37
|
import { VERSION, selfCommand } from "./self.js";
|
|
34
38
|
/** What the agent is told when Station gave no rules of its own: it could
|
|
35
39
|
* not be reached as the session started. */
|
|
@@ -48,6 +52,10 @@ export const postToAgent = async (relayUrl, headers, method, params) => {
|
|
|
48
52
|
throw new Error(error ?? `Station said ${response.status}.`);
|
|
49
53
|
return body.result;
|
|
50
54
|
};
|
|
55
|
+
/** What every request to Station says about this CLI: how to run it on
|
|
56
|
+
* this computer, and that it gives a worker named with `as` its own seat
|
|
57
|
+
* (the relay offers `as` only then; 0.7.0 and before ignored it). */
|
|
58
|
+
const ours = () => ({ "X-Station-Command": selfCommand(), "X-Station-Workers": "1" });
|
|
51
59
|
function failed(error) {
|
|
52
60
|
return { content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }], isError: true };
|
|
53
61
|
}
|
|
@@ -68,7 +76,7 @@ async function settled(home) {
|
|
|
68
76
|
}
|
|
69
77
|
export const thisComputer = {
|
|
70
78
|
session: inSession,
|
|
71
|
-
takeSeat: async (home, session, url) => (await takeSeat(home, session, url, { client: "station-mcp" })).seat,
|
|
79
|
+
takeSeat: async (home, session, url, name) => (await takeSeat(home, session, url, { client: "station-mcp", name: name ?? undefined })).seat,
|
|
72
80
|
read: async (home, seat, after) => {
|
|
73
81
|
await ensureDaemon(home);
|
|
74
82
|
await ask(files(home).socket, { op: "read", sessionId: seat.sessionId, roomId: seat.roomId, after });
|
|
@@ -90,7 +98,7 @@ export async function instructionsFrom(home, post = postToAgent) {
|
|
|
90
98
|
const credentials = await settled(home);
|
|
91
99
|
const relayUrl = relayOf(credentials);
|
|
92
100
|
try {
|
|
93
|
-
const result = (await post(relayUrl, { ...asPerson(credentials, relayUrl),
|
|
101
|
+
const result = (await post(relayUrl, { ...asPerson(credentials, relayUrl), ...ours() }, "initialize", {
|
|
94
102
|
protocolVersion: LATEST_PROTOCOL_VERSION,
|
|
95
103
|
capabilities: {},
|
|
96
104
|
clientInfo: { name: "station-cli", version: VERSION },
|
|
@@ -112,7 +120,7 @@ export function createStationServer(home, post = postToAgent, instructions = nul
|
|
|
112
120
|
const relayUrl = relayOf(credentials);
|
|
113
121
|
let tools;
|
|
114
122
|
try {
|
|
115
|
-
tools = (await post(relayUrl, { ...asPerson(credentials, relayUrl),
|
|
123
|
+
tools = (await post(relayUrl, { ...asPerson(credentials, relayUrl), ...ours() }, "tools/list", {})).tools;
|
|
116
124
|
writeFileSync(files(home).tools, JSON.stringify(tools), { mode: 0o600 });
|
|
117
125
|
}
|
|
118
126
|
catch {
|
|
@@ -139,9 +147,11 @@ export function createStationServer(home, post = postToAgent, instructions = nul
|
|
|
139
147
|
// Not a room this computer can read; the tool says what is wrong with it.
|
|
140
148
|
}
|
|
141
149
|
}
|
|
150
|
+
// A worker's name, else the one this process was started with.
|
|
151
|
+
const worker = workerName(args.as) ?? workerName(process.env.STATION_SESSION);
|
|
142
152
|
let caller = null;
|
|
143
153
|
try {
|
|
144
|
-
caller = computer.session();
|
|
154
|
+
caller = computer.session(worker);
|
|
145
155
|
}
|
|
146
156
|
catch {
|
|
147
157
|
// Not a session that can hold a seat: the call goes as the person.
|
|
@@ -150,10 +160,12 @@ export function createStationServer(home, post = postToAgent, instructions = nul
|
|
|
150
160
|
let joined = false;
|
|
151
161
|
if (!seat && roomId && known.get(name)?._meta?.["station/seat"] === "take") {
|
|
152
162
|
// Says why when this is not an agent's session that can hold a seat.
|
|
153
|
-
|
|
163
|
+
// The seat's name, when the call gives one (room_wait's `name`), as station join --name.
|
|
164
|
+
const name = typeof args.name === "string" && args.name.trim() ? args.name.trim() : null;
|
|
165
|
+
seat = await computer.takeSeat(home, caller ?? computer.session(worker), `${relayUrl}/${roomId}`, name);
|
|
154
166
|
joined = true;
|
|
155
167
|
}
|
|
156
|
-
const headers =
|
|
168
|
+
const headers = ours();
|
|
157
169
|
if (seat) {
|
|
158
170
|
const auth = authFor(seat, credentials);
|
|
159
171
|
relayUrl = seat.relayUrl;
|
package/dist/proxy.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Node's own fetch and WebSocket go through HTTPS_PROXY or HTTP_PROXY only
|
|
2
|
+
// when NODE_USE_ENV_PROXY=1 was set as Node started (Node 22.21 and 24 on).
|
|
3
|
+
// An agent behind a proxy, such as one in a cloud sandbox, would otherwise
|
|
4
|
+
// get "fetch failed" on its first call. So when a proxy is set and that is
|
|
5
|
+
// not, the CLI starts itself again with it set, in place: the same process,
|
|
6
|
+
// so the agent's harness keeps its stdio, signals and exit code.
|
|
7
|
+
const PROXY_VARS = ["HTTPS_PROXY", "https_proxy", "HTTP_PROXY", "http_proxy"];
|
|
8
|
+
/** Whether this Node would only use the proxy if started again with NODE_USE_ENV_PROXY. */
|
|
9
|
+
export function wantsProxy(env = process.env, node = process.versions.node) {
|
|
10
|
+
if (env.NODE_USE_ENV_PROXY || !PROXY_VARS.some((name) => env[name]?.trim()))
|
|
11
|
+
return false;
|
|
12
|
+
const [major, minor] = node.split(".").map(Number);
|
|
13
|
+
return major >= 24 || (major === 22 && minor >= 21);
|
|
14
|
+
}
|
|
15
|
+
/** Starts this CLI again in place with NODE_USE_ENV_PROXY=1, when a proxy is
|
|
16
|
+
* set and Node can do that (not on Windows); otherwise does nothing. */
|
|
17
|
+
export function useEnvProxy() {
|
|
18
|
+
const execve = process.execve;
|
|
19
|
+
if (!wantsProxy() || typeof execve !== "function")
|
|
20
|
+
return;
|
|
21
|
+
try {
|
|
22
|
+
// Node calls its proxy support experimental and says so as it starts,
|
|
23
|
+
// before any of this runs; an agent would take that for a problem.
|
|
24
|
+
const quiet = process.execArgv.includes("--no-warnings") ? [] : ["--no-warnings"];
|
|
25
|
+
execve.call(process, process.execPath, [process.execPath, ...quiet, ...process.execArgv, ...process.argv.slice(1)], { ...process.env, NODE_USE_ENV_PROXY: "1" });
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
// Could not start again: carry on without the proxy, as before.
|
|
29
|
+
}
|
|
30
|
+
}
|
package/dist/sessions.js
CHANGED
|
@@ -10,13 +10,20 @@ export const HARNESS_NAMES = { "claude-code": "Claude Code", codex: "Codex", she
|
|
|
10
10
|
/** Whether Station puts room messages into this kind of session itself.
|
|
11
11
|
* Every other session reads them with `station wait`. */
|
|
12
12
|
export const delivers = (harness) => harness !== "shell";
|
|
13
|
+
/** A worker's name as given (STATION_SESSION, or `as` over MCP), trimmed; null for none. */
|
|
14
|
+
export function workerName(given) {
|
|
15
|
+
return typeof given === "string" && given.trim() ? given.trim().slice(0, 80) : null;
|
|
16
|
+
}
|
|
13
17
|
/** The session for an agent Station cannot put messages into. */
|
|
14
|
-
export function shellSession(install, env = process.env, cwd = process.cwd(), why = null) {
|
|
15
|
-
const named = env.STATION_SESSION
|
|
18
|
+
export function shellSession(install, env = process.env, cwd = process.cwd(), why = null, within = null) {
|
|
19
|
+
const named = workerName(env.STATION_SESSION);
|
|
16
20
|
// Hashed: the join sends the session id to the room, which may be public,
|
|
17
|
-
// and the folder's whole path is not the room's business.
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
// and the folder's whole path is not the room's business. A worker in a
|
|
22
|
+
// Claude Code or Codex session (`within`) is keyed by that session too, so
|
|
23
|
+
// two sessions' workers of one name are two seats.
|
|
24
|
+
const key = named && within ? `${within}\n${named}` : named || cwd;
|
|
25
|
+
const id = `shell-${createHash("sha256").update(`${install}\n${key}`).digest("hex").slice(0, 32)}`;
|
|
26
|
+
return { harness: "shell", id, cwd, name: named, why };
|
|
20
27
|
}
|
|
21
28
|
const fromClaude = (claude) => ({ harness: "claude-code", id: claude.sessionId, cwd: claude.cwd, name: claude.name, claude });
|
|
22
29
|
const fromCodex = (codex, cwd) => ({ harness: "codex", id: codex.thread, cwd, name: null, codex });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@santori/station",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
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",
|