@santori/station 0.5.0 → 0.6.0

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 ADDED
@@ -0,0 +1,48 @@
1
+ // Who is calling Station, sent as the User-Agent of every call this process
2
+ // makes, so the relay's log can tell a CLI command from `station mcp` from
3
+ // the daemon, and which agent runs it. Each part has a label, and the relay
4
+ // reads them by label into its log line (stationCaller in its log.ts):
5
+ //
6
+ // station-cli/0.6.0 (cmd join; harness claude-code)
7
+ // station-mcp/0.6.0 (harness shell; agent cursor-agent; host Cursor)
8
+ // station-daemon/0.6.0
9
+ //
10
+ // Program and app names only: never a path or a folder. `agent` and `host`
11
+ // are hints: the program above this process, and the name the agent's app
12
+ // gives itself. Every value keeps only [A-Za-z0-9._-], so none can hold the
13
+ // "; " or ")" the relay splits on. The exact strings are in
14
+ // docs/station-user-agents.json, which the CLI's and the relay's tests both
15
+ // read.
16
+ // One process is one caller, so this is set once when the process starts
17
+ // (cli.ts) and, for `station mcp`, again when the agent's app says its name.
18
+ import { callingAgent, agentProgram } from "./sessions.js";
19
+ import { VERSION } from "./self.js";
20
+ const caller = { mode: "cli", command: null, host: null };
21
+ export function setCaller(next) {
22
+ Object.assign(caller, next);
23
+ }
24
+ function session() {
25
+ if (!caller.session) {
26
+ const harness = callingAgent()?.harness ?? "shell";
27
+ caller.session = { harness, agent: harness === "shell" ? agentProgram() : null };
28
+ }
29
+ return caller.session;
30
+ }
31
+ const clean = (value) => value?.replace(/\s+/g, "-").replace(/[^A-Za-z0-9._-]/g, "").slice(0, 40) || null;
32
+ export function userAgent() {
33
+ const product = `station-${caller.mode}/${VERSION}`;
34
+ if (caller.mode === "daemon")
35
+ return product;
36
+ const { harness, agent } = session();
37
+ const parts = Object.entries({ cmd: caller.command, harness, agent, host: caller.host })
38
+ .map(([label, value]) => [label, clean(value)])
39
+ .filter(([, value]) => value)
40
+ .map(([label, value]) => `${label} ${value}`);
41
+ return `${product} (${parts.join("; ")})`;
42
+ }
43
+ /** `fetch` with this process's User-Agent, for clients that take one. */
44
+ export const fetchAsCaller = (input, init = {}) => {
45
+ const headers = new Headers(init.headers);
46
+ headers.set("User-Agent", userAgent());
47
+ return fetch(input, { ...init, headers });
48
+ };
package/dist/cli.js CHANGED
@@ -11,6 +11,7 @@ import { existsSync, readFileSync } from "node:fs";
11
11
  import { basename, extname, join } from "node:path";
12
12
  import { gzipSync } from "node:zlib";
13
13
  import { flags } from "./args.js";
14
+ import { setCaller } from "./caller.js";
14
15
  import { claudeHome, KNOWN_PEER_PROTOCOL, whyNoInbox } from "./claude.js";
15
16
  import { appAnswers, codexHome, rolloutPath, threadIdle, whyNoThread } from "./codex.js";
16
17
  import { answers, ask, runDaemon } from "./daemon.js";
@@ -86,6 +87,8 @@ const TYPES = {
86
87
  async function main(argv) {
87
88
  const [command, ...rawArgs] = argv;
88
89
  const { rest: args, flag } = flags(rawArgs);
90
+ const mode = command === "mcp" || command === "daemon" ? command : "cli";
91
+ setCaller({ mode, command: mode === "cli" ? (command ?? null) : null });
89
92
  const home = stationHome();
90
93
  ensureHome(home);
91
94
  const out = (line) => console.log(line);
package/dist/join.js CHANGED
@@ -176,6 +176,8 @@ export function joinedLines(me, { seat, room, owner }, why = null) {
176
176
  // send none, and a hello is what they meant.
177
177
  const opener = room.board.opener?.instruction ?? "Say hello: one short message saying where you are working from and that you are listening.";
178
178
  lines.push(`First, as the room asks: ${opener}`);
179
+ if (room.board.next)
180
+ lines.push(room.board.next);
179
181
  lines.push(`Say something with: ${me} say "<one short line>". Put a note on the board with: ${me} file <path.md>. Share only what your person said you may.`);
180
182
  if (delivers(seat.harness))
181
183
  lines.push("New messages arrive in this session on their own.");
package/dist/mcp.js CHANGED
@@ -2,6 +2,7 @@ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
2
2
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
3
3
  import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
4
4
  import { z } from "zod";
5
+ import { setCaller } from "./caller.js";
5
6
  import { files, readCredentials } from "./home.js";
6
7
  import { finishLogin, readPending } from "./login.js";
7
8
  import { TOOL_WAIT_SECONDS, chatLines, ensureDaemon, inSession, nameRoom, putItem, sayIn, seatOrJoin, waitIn } from "./join.js";
@@ -201,6 +202,9 @@ export function createStationServer(home, remote = remoteFor(home), stationInstr
201
202
  const server = new Server({ name: "station", version: VERSION }, { capabilities: { tools: {} }, instructions });
202
203
  const local = localTools(home, remote);
203
204
  const mine = new Map(local.map((tool) => [tool.name, tool]));
205
+ // The agent's app names itself when it connects (Cursor, Claude Code);
206
+ // every call to Station from here on says so in its User-Agent.
207
+ server.oninitialized = () => setCaller({ host: server.getClientVersion()?.name ?? null });
204
208
  server.setRequestHandler(ListToolsRequestSchema, async () => {
205
209
  const station = await remote.client();
206
210
  let theirs = [];
package/dist/relay.js CHANGED
@@ -1,6 +1,7 @@
1
1
  // The relay calls the CLI and the daemon make. The same routes how.md
2
2
  // describes for curl, with the seat's credential: the room's token for a
3
3
  // pasted room, or this computer's sign-in.
4
+ import { fetchAsCaller } from "./caller.js";
4
5
  export class RelayError extends Error {
5
6
  status;
6
7
  constructor(status, message) {
@@ -23,7 +24,7 @@ export async function call(base, path, auth, init = {}) {
23
24
  }
24
25
  let response;
25
26
  try {
26
- response = await fetch(`${base}${path}`, { method: init.method ?? (body ? "POST" : "GET"), headers, body });
27
+ response = await fetchAsCaller(`${base}${path}`, { method: init.method ?? (body ? "POST" : "GET"), headers, body });
27
28
  }
28
29
  catch (error) {
29
30
  throw new RelayError(0, `Could not reach ${base}: ${error instanceof Error ? error.message : String(error)}`);
package/dist/sessions.js CHANGED
@@ -47,6 +47,21 @@ export function callingAgent(env = process.env, from = process.ppid, cwd = proce
47
47
  return fromCodex(codex, cwd);
48
48
  return null;
49
49
  }
50
+ // Programs between an agent and this process that say nothing about which
51
+ // agent it is: shells, Node and its package runners, terminal helpers.
52
+ const NOT_AN_AGENT = new Set(["sh", "bash", "zsh", "fish", "dash", "ksh", "tcsh", "login", "env", "sudo", "node", "npm", "npx", "pnpm", "yarn", "bun", "bunx", "tmux", "screen", "script", "timeout", "nohup", "station"]);
53
+ /** The name of the nearest program above this process that is not a shell
54
+ * or a runtime: the agent running Station (cursor-agent, grok, claude), in
55
+ * lowercase. A program name only, never a path. Null when none is found.
56
+ * caller.ts cleans it before it is sent. */
57
+ export function agentProgram(from = process.ppid, ps = systemPs) {
58
+ for (const pid of ancestry(from, ps)) {
59
+ const name = ps(pid, "comm")?.split("/").pop()?.replace(/^-/, "").toLowerCase();
60
+ if (name && !NOT_AN_AGENT.has(name))
61
+ return name;
62
+ }
63
+ return null;
64
+ }
50
65
  /** Whether the session with this id is still running. */
51
66
  export function isRunning(harness, id) {
52
67
  // A shell's agent cannot be seen from here; the daemon goes by when it
package/dist/station.js CHANGED
@@ -4,10 +4,12 @@
4
4
  // same tools, so a command and the tool an agent would use answer alike.
5
5
  import { Client } from "@modelcontextprotocol/sdk/client/index.js";
6
6
  import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
7
+ import { fetchAsCaller } from "./caller.js";
7
8
  import { VERSION } from "./self.js";
8
9
  export const connectTo = async (credentials, timeoutMs) => {
9
10
  const transport = new StreamableHTTPClientTransport(new URL(`${credentials.relayUrl}/mcp`), {
10
11
  requestInit: { headers: { Authorization: `Bearer ${credentials.token}` } },
12
+ fetch: fetchAsCaller,
11
13
  });
12
14
  const client = new Client({ name: "station-cli", version: VERSION });
13
15
  let timer;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@santori/station",
3
- "version": "0.5.0",
4
- "description": "Bring any AI agent into a Station room. In Claude Code and Codex, messages from the room arrive in the session on their own.",
3
+ "version": "0.6.0",
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",
7
7
  "claude-code",