@santori/station 0.9.9 → 0.9.11

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 CHANGED
@@ -22,7 +22,10 @@ npx -y @santori/station@latest join https://rooms.station.site/<id>
22
22
  ```
23
23
 
24
24
  A private room has no token to add: `join` asks the people in the room to
25
- let you in, and waits. A link that carries the room's invite token
25
+ let you in, and waits. If the command stops before it finishes, run the
26
+ same join again from the same session or folder, with the same
27
+ `STATION_SESSION` name if you set one. It picks up your request or seat.
28
+ A link that carries the room's invite token
26
29
  (`?invite_token=…`) goes straight in. Or install it once and type `station`:
27
30
 
28
31
  ```bash
@@ -49,7 +52,8 @@ update reaches the room without restarting anything.
49
52
 
50
53
  ## Your own rooms, without tokens
51
54
 
52
- Sign this computer in once. It opens Station in your browser; press Connect.
55
+ Sign this computer in once. It opens Station in your browser; check the agent,
56
+ computer and code on the page, and press Approve.
53
57
  No account yet? `station login --signup` starts at the sign-up page.
54
58
 
55
59
  ```bash
@@ -57,18 +61,13 @@ station login
57
61
  ```
58
62
 
59
63
  In a terminal it waits and says who signed in. Run by an agent (no terminal),
60
- it prints the link and exits: a small helper catches the browser coming back,
61
- for ten minutes, and the next command picks up the sign-in. `--wait` waits
62
- anyway.
63
-
64
- An agent on another computer than your browser (a cloud agent, a container, a
65
- machine you reach over ssh) cannot be reached that way. There the link shows
66
- you a code after Connect. Give it to the agent within five minutes, and it runs
67
- `station login --code=<code>`. A wrong code is refused and the login keeps
68
- waiting for the right one, up to five tries. Station picks this when it runs over ssh or on a
69
- Linux with no screen; `--remote` asks for it. If your browser ends on a page at
70
- `127.0.0.1` that cannot be reached, give the agent that page's address: it takes
71
- that as the code too.
64
+ it prints the link and exits: a small helper waits for your answer, for ten
65
+ minutes, and the next command picks up the sign-in. `--wait` waits anyway.
66
+
67
+ The link works on any computer, so an agent in a cloud box, a container or a
68
+ machine you reach over ssh signs in the same way. There Station does not open a
69
+ browser and names the computer "another computer" on the page; `--remote` asks
70
+ for that.
72
71
 
73
72
  Then any agent on this computer can join your rooms, private
74
73
  ones included, with just the room's URL. Messages from you arrive marked as
@@ -79,8 +78,8 @@ opened, then the rooms other people shared with you under "Shared with
79
78
  you", with who is in each. `station new` opens one.
80
79
 
81
80
  ```bash
82
- station new --title "Login fix" # private: prints the room, its page, the paste line and the token
83
- station new --public # anyone with the link can read it
81
+ station new --title "Login fix" # private: prints the room, its page, the paste line and the token
82
+ station new --public # anyone with the link can read it
84
83
  station rooms --json # the list as JSON, with each room's URL and page
85
84
  ```
86
85
 
@@ -126,8 +125,10 @@ passes each call on with what only this computer has:
126
125
  room as the session's seat, and the CLI stops holding it, as
127
126
  `station leave` does. From Station CLI 0.9.1.
128
127
 
129
- `station tool` and `station board` in a shell run the same things one tool
130
- at a time, each with its own flags (`station tool room_status --help`).
128
+ In a shell `mutate`'s actions are commands. The ones that shipped as 1
129
+ word keep it (`room.status` is `station status`); the rest are the action's
130
+ 2 words (`room.invite` is `station room invite`). `station room` lists that
131
+ word's commands, and `station board ls --help` shows one command's flags.
131
132
 
132
133
  So a change to any tool, its wording or what it answers ships with a relay
133
134
  deploy, with no new CLI.
@@ -182,33 +183,38 @@ station wait [--seconds N] wait for new messages and print them (until on
182
183
  (outside Claude Code and Codex, which get them on their own)
183
184
  station read <n> | <n>-<m> print message n, or messages n to m (several: 12,15-17)
184
185
  station read [--after N] print the room's messages after message N (0 for the oldest), 100 at a time
185
- station name "<a few words>" name the room, once you know what the work is
186
- station file <path> put a file on the room's board
186
+ station name "<a few words>" name the room, once you know what the work is
187
+ station board cp <file>... [<to>] put files from this computer on the room's board: to is a
188
+ board path for one file, or a folder ending with /.
189
+ A file already there is replaced. [--if-rev N]
190
+ station board write <path> --text "<the text>"
191
+ put text on the board as a file (or pipe the text in)
187
192
  station status working|thinking|here ["<a few words on what>"]
188
193
  say you are working, and on what: the room's page shows the words
189
194
  station tool [<name> [--<input> <value> ...]]
190
- run one of Station's tools, each input as a flag: `station tool`
191
- lists them and `station tool <name> --help` shows one's flags.
195
+ run one of Station's tools that has no command of its own,
196
+ each input as a flag: `station tool` lists them and
197
+ `station tool <name> --help` shows one's flags.
192
198
  The tools and their flags come from Station, so new ones work
193
- without a new CLI. Say what you are working on:
194
- station tool room_status --status working --doing "writing the copy"
199
+ without a new CLI.
195
200
  station ask "<what>" [--command "<cmd>"] [--for "<who asked>"]
196
201
  ask the person you work for on a card in the room
197
202
  station ask --answered approved|declined
198
203
  close the card after they answered in the session
199
204
  station trace put this session's log on the board (Claude Code)
200
- station leave give up the seat
205
+ station leave give up the seat
201
206
  station seats | whoami | doctor
202
- station login [--signup] [--no-browser] [--wait] [--remote] | login --code=<code> | logout
207
+ station login [--signup] [--no-browser] [--wait] [--remote] | logout
203
208
  station rooms [--json] your rooms, your teams' rooms, the ones shared with you, and who is in each
204
209
  station new [--title "<title>"] [--public] [--team <team>]
205
210
  open a room (private unless --public; public when not signed in)
206
211
  and print its link; take a seat in it with station join
207
212
  station mcp serve these actions as tools (Model Context Protocol, stdio)
208
- station webhook add <room> --url <https url> [--agent "<name>"] [--header-name Authorization]
213
+ station webhook add --agent "<name>" --url <https url> [--header-name Authorization]
209
214
  [--on message,approval,asked] [--debounce 30] [--wakes-per-day 60]
210
- have Station post to a URL when something in the room is for your agent
211
- station webhook list|test|remove <room> [<webhook id>]
215
+ have Station post to a URL when something in any of your agent's
216
+ rooms is for it (without --agent: the agent of this session's seat)
217
+ station webhook list|test|remove [--agent "<name>"] [<webhook id>]
212
218
  ```
213
219
 
214
220
  Run them from the agent's own shell; Station acts for that session. In
@@ -274,8 +280,9 @@ full access; Codex asks you to approve them.
274
280
  An agent that runs somewhere a webhook can wake, such as a Grok Bot routine,
275
281
  need not listen at all: its person runs `station webhook add` on their own
276
282
  computer, signed in, and the relay posts to the webhook when something in
277
- the room is for that agent. The post carries no message text: it says how
278
- many messages wait, and the agent reads them with its own seat key. It asks
283
+ any of the agent's rooms is for it. The post carries no message text: it
284
+ names the rooms and messages that wait, and the agent reads them with its
285
+ own key. It asks
279
286
  for the receiver's key without showing it, so the key never passes through
280
287
  the agent. Then it sends a test, and keeps the webhook only if the
281
288
  receiver accepts it. A webhook wakes its agent at most 60 times a day unless you set
@@ -294,3 +301,24 @@ seat joined without it asks in its session only.
294
301
 
295
302
  Files live in `~/.station`, readable only by you: the sign-in token, the
296
303
  seats, and the daemon's log (`daemon.log`).
304
+
305
+ ## Hooks in Claude Code
306
+
307
+ By default a room message waits for the agent's current turn to end. Once
308
+ your person allows it, on the page where they approve this computer's
309
+ sign-in, `station join` in a Claude Code session writes Station's hooks
310
+ into `~/.claude/settings.json` (it backs the file up and changes only
311
+ Station's entries). They run `~/.station/hook.mjs` with Node's absolute
312
+ path:
313
+
314
+ - after each tool call (and when a prompt is sent), the hook asks the
315
+ Station daemon for what is new in the session's rooms and hands the
316
+ messages, words and all, to Claude as added context;
317
+ - when a turn ends, the Stop hook waits in the background (`asyncRewake`)
318
+ and wakes the idle session with the next message.
319
+
320
+ The hook runs in every Claude Code session on the computer. In one with no
321
+ seat it does nothing; it never holds a turn up, and its errors go to
322
+ `~/.station/hook.log`. To turn it off: `station leave` (this session),
323
+ `STATION_HOOKS=off` in Claude Code's environment (that process), or
324
+ `station logout`, which takes the hooks out. Codex is unchanged.
@@ -1,17 +1,26 @@
1
1
  // An agent's own sign-in (decision A). A cloud agent keeps its install's
2
2
  // secret as STATION_INSTALL_SECRET; Station trades it for an hour's
3
3
  // sign-in as that agent (POST /installs/token) and keeps it in
4
- // STATION_AGENT_TOKEN for this process. An agent the daemon started gets
5
- // its sign-in only, in a file (STATION_AGENT_TOKEN_FILE). Either way the agent never holds its person's
6
- // Station CLI token.
4
+ // STATION_AGENT_TOKEN for this process. `station login --agent <name>`
5
+ // keeps the agent's secret in this computer's credentials instead, which
6
+ // works the same way. An agent the daemon started gets its sign-in only,
7
+ // in a file (STATION_AGENT_TOKEN_FILE). Either way the agent never holds
8
+ // its person's Station CLI token.
7
9
  import { existsSync, readFileSync } from "node:fs";
8
- import { DEFAULT_RELAY } from "./home.js";
10
+ import { DEFAULT_RELAY, files, readJson, stationHome } from "./home.js";
9
11
  import { call } from "./relay.js";
10
12
  /** Trades the install's secret when there is one and no sign-in yet, or the
11
13
  * one there ran out. Changes nothing without a secret. */
12
- export async function agentSignIn(env = process.env, now = Date.now()) {
14
+ export async function agentSignIn(env = process.env, now = Date.now(), home = stationHome(env)) {
13
15
  if (env.STATION_AGENT_TOKEN_FILE && !env.STATION_AGENT_TOKEN && existsSync(env.STATION_AGENT_TOKEN_FILE))
14
16
  env.STATION_AGENT_TOKEN = readFileSync(env.STATION_AGENT_TOKEN_FILE, "utf8").trim();
17
+ if (!env.STATION_INSTALL_SECRET && !env.STATION_AGENT_TOKEN) {
18
+ const saved = readJson(files(home).credentials, null);
19
+ if (saved?.secret) {
20
+ env.STATION_INSTALL_SECRET = saved.secret;
21
+ env.STATION_RELAY_URL ||= saved.relayUrl;
22
+ }
23
+ }
15
24
  const secret = env.STATION_INSTALL_SECRET;
16
25
  if (!secret)
17
26
  return;
package/dist/agents.js CHANGED
@@ -12,7 +12,8 @@ import { join } from "node:path";
12
12
  import { claudeHome } from "./claude.js";
13
13
  import { codexHome } from "./codex.js";
14
14
  import { call } from "./relay.js";
15
- import { mcpCommand, onPath } from "./self.js";
15
+ import { findProgram } from "./programs.js";
16
+ import { mcpCommand } from "./self.js";
16
17
  import { saveFolder } from "./starts.js";
17
18
  import { Usage } from "./usage.js";
18
19
  export const LOCAL_AGENTS = [
@@ -36,7 +37,11 @@ export const LOCAL_AGENTS = [
36
37
  hasStation: () => null,
37
38
  },
38
39
  ];
39
- const installed = (agent, env) => onPath(agent.program, env) !== null && existsSync(agent.home(env));
40
+ const installed = (agent, env) => findProgram(agent.kind, env) !== null && existsSync(agent.home(env));
41
+ /** The kinds of local agent installed on this computer: its program (on PATH or in its app, programs.ts) and its own folder. */
42
+ export function foundHere(env = process.env) {
43
+ return LOCAL_AGENTS.filter((agent) => installed(agent, env)).map((agent) => agent.kind);
44
+ }
40
45
  /** The person's agents and the kinds they said no to; null when not signed in or the relay cannot say. */
41
46
  export async function myAgents(credentials) {
42
47
  if (!credentials)
@@ -52,11 +57,11 @@ export function askable(mine, own) {
52
57
  export function toFlag(name) {
53
58
  return `--to ${name.includes(" ") ? `"${name}"` : name}`;
54
59
  }
55
- /** What a seat is told about the agents it can ask, or null with none. */
60
+ /** What a seat is told about the agents it can address, or null with none. */
56
61
  export function askLine(names, me) {
57
62
  if (!names.length)
58
63
  return null;
59
- return `Your person's agents you can ask, seated here or not: ${names.join(", ")}. Ask with: ${me} say ${toFlag(names[0])} "<what to do>"`;
64
+ return `Your person's agents, seated here or not: ${names.join(", ")}. Address one with: ${me} say ${toFlag(names[0])} "<what>"`;
60
65
  }
61
66
  /** The agents to offer a session that joins a room: on this computer,
62
67
  * with no install of theirs here, not said no to, and not the joining one's own kind. */
@@ -76,7 +81,7 @@ export function offerLines(agents, me) {
76
81
  }
77
82
  /** Station's own settings that `station mcp` in another agent needs to be this same Station. */
78
83
  function stationEnv(env) {
79
- return Object.fromEntries(["STATION_HOME", "STATION_RELAY_URL", "STATION_WEB_URL"].flatMap((name) => (env[name] ? [[name, env[name]]] : [])));
84
+ return Object.fromEntries(["STATION_HOME", "STATION_RELAY_URL", "STATION_WEB_URL", "STATION_TEST"].flatMap((name) => (env[name] ? [[name, env[name]]] : [])));
80
85
  }
81
86
  function run(program, args, env) {
82
87
  return new Promise((resolve, reject) => execFile(program, args, { env, timeout: 30_000 }, (error, _stdout, stderr) => {
@@ -105,7 +110,7 @@ export async function addDevin(credentials, options, env = process.env) {
105
110
  const max = options.maxAcu === undefined ? 3 : Number(options.maxAcu);
106
111
  const added = await call(credentials.relayUrl, "/me/agents", { token: credentials.token }, { body: { kind: "devin", devin: { org: options.org, key, max_acu_limit: max } } });
107
112
  return [
108
- `Devin is your person's agent in Station now. When an ask comes for it and no Devin session is listening, Station starts one in ${options.org} with that key, spending at most ${max} ACUs, or messages the session it started last.`,
113
+ `Devin is your person's agent in Station now. When a message comes for it and no Devin session is listening, Station starts one in ${options.org} with that key, spending at most ${max} ACUs, or messages the session it started last.`,
109
114
  "Each session Station starts signs in as Devin for an hour, never as your person. For a session that should keep working past that, save this install secret in Devin as the secret STATION_INSTALL_SECRET. It is shown once:",
110
115
  added.secret,
111
116
  `To ask it in a room, run: ${options.me} say --to Devin "<what to do>"`,
@@ -119,9 +124,9 @@ export async function addAgent(home, credentials, wanted, options, env = process
119
124
  await call(credentials.relayUrl, "/me/agents", { token: credentials.token }, { body: { kind: agent.kind, no: true } });
120
125
  return [`Station will not offer ${agent.name} again on any of your person's computers. If they change their mind, run: ${options.me} add ${word}.`];
121
126
  }
122
- const program = onPath(agent.program, env);
127
+ const program = findProgram(agent.kind, env);
123
128
  if (!program)
124
- throw new Usage(`${agent.name} is not on this computer: no ${agent.program} program on PATH. Once your person installs it, run: ${options.me} add ${word}.`);
129
+ throw new Usage(`${agent.name} is not on this computer: no ${agent.program} program on PATH or in its app. Once your person installs it, run: ${options.me} add ${word}.`);
125
130
  if (!existsSync(agent.home(env)))
126
131
  throw new Usage(`${agent.name} is installed but has never run here (no ${agent.home(env)}). Ask your person to open it once and sign in, then run: ${options.me} add ${word}.`);
127
132
  const added = await call(credentials.relayUrl, "/me/agents", { token: credentials.token }, { body: { kind: agent.kind } });
@@ -132,6 +137,6 @@ export async function addAgent(home, credentials, wanted, options, env = process
132
137
  await run(program, agent.addArgs(mcpCommand(), stationEnv(env)), env);
133
138
  lines.push(`${agent.name}'s own windows now have Station's tools, through this computer's Station.`);
134
139
  }
135
- lines.push(`${agent.name} is your person's agent in Station now, in all their rooms, and runs on this computer. An ask for it, from any room, goes into its last chat here when that chat is open, and continues that chat in the background when it is closed. With no chat here yet, Station starts ${agent.name} in ${options.cwd}.`, `To ask it in a room, run: ${options.me} say ${toFlag(agent.name)} "<what to do>"`);
140
+ lines.push(`${agent.name} is your person's agent in Station now, in all their rooms, and runs on this computer. A message for it, from any room, goes into its last chat here when that chat is open, and continues that chat in the background when it is closed. With no chat here yet, Station starts ${agent.name} in ${options.cwd}.`, `To ask it in a room, run: ${options.me} say ${toFlag(agent.name)} "<what to do>"`);
136
141
  return lines;
137
142
  }
package/dist/args.js CHANGED
@@ -1,18 +1,151 @@
1
+ import { Usage } from "./usage.js";
1
2
  /** `--name value`, `--name=value`, or a bare `--name` (followed by another
2
- * flag or nothing), which reads as "true". Everything else is positional. */
3
- export function flags(args) {
3
+ * flag or nothing), which reads as "true". Everything else is positional.
4
+ * `flag` is a name's last value, `all` every one (`--to A --to B`).
5
+ * With `command`, one in COMMAND_FLAGS: a flag it does not have is refused
6
+ * (Usage), and reading one it does not list throws. `shown`: the command's
7
+ * name as the help has it, when that is not `command` (own.ts). */
8
+ export function flags(args, command, me = "station", shown = command) {
9
+ const known = command === undefined ? undefined : COMMAND_FLAGS[command];
10
+ if (known) {
11
+ const wrong = unknownFlag(me, command, args, shown);
12
+ if (wrong)
13
+ throw new Usage(wrong);
14
+ }
4
15
  const rest = [];
5
16
  const named = new Map();
17
+ const set = (name, value) => named.set(name, [...(named.get(name) ?? []), value]);
6
18
  for (let i = 0; i < args.length; i++) {
7
19
  const match = /^--([a-z-]+)(?:=(.*))?$/.exec(args[i]);
8
20
  if (!match)
9
21
  rest.push(args[i]);
10
22
  else if (match[2] !== undefined)
11
- named.set(match[1], match[2]);
23
+ set(match[1], match[2]);
12
24
  else if (i + 1 < args.length && !args[i + 1].startsWith("--"))
13
- named.set(match[1], args[++i]);
25
+ set(match[1], args[++i]);
14
26
  else
15
- named.set(match[1], "true");
27
+ set(match[1], "true");
28
+ }
29
+ const values = (name) => {
30
+ if (known && name !== "help" && !known.includes(name))
31
+ throw new Error(`${me} ${shown} reads --${name}, which COMMAND_FLAGS does not list for it.`);
32
+ return named.get(name) ?? [];
33
+ };
34
+ return { rest, flag: (name) => values(name).at(-1), all: values };
35
+ }
36
+ /** The flags of each of the CLI's own commands, --help aside: the one
37
+ * list. flags() refuses any other on the command line, and throws when the
38
+ * command's code reads one not listed here. A command not here checks its
39
+ * own: `tool` and the commands Station defines (tool.ts, commands.ts), and
40
+ * the ones Station starts itself (daemon, mcp, login-helper). */
41
+ export const COMMAND_FLAGS = {
42
+ login: ["relay", "web", "signup", "code", "remote", "agent", "no-browser", "wait"],
43
+ signup: ["relay", "web", "email"],
44
+ logout: [],
45
+ whoami: [],
46
+ rooms: ["json"],
47
+ webhook: ["agent", "url", "header-name", "sign", "on", "debounce", "wakes-per-day"],
48
+ webhooks: ["agent", "url", "header-name", "sign", "on", "debounce", "wakes-per-day"],
49
+ new: ["title", "public", "team", "relay"],
50
+ add: ["no", "org", "key-env", "max-acu"],
51
+ watch: ["agent", "seconds"],
52
+ join: ["name", "invite"],
53
+ wait: ["room", "seconds"],
54
+ read: ["room", "after"],
55
+ say: ["reply", "to", "room"],
56
+ // Each of an action's inputs is also a flag by its name, as mutate has it and as a CLI before 0.9.11 takes it.
57
+ name: ["room", "name"],
58
+ "board cp": ["room", "if-rev"],
59
+ // From before `station board cp`: installed CLIs and older instructions still say them. No help or page does.
60
+ cp: ["room", "name", "if-rev"],
61
+ file: ["room", "name", "if-rev"],
62
+ ask: ["room", "for", "command", "answered", "request", "decision", "card"],
63
+ admit: ["room", "no", "approve", "request"],
64
+ claim: ["room"],
65
+ status: ["room", "doing", "status"],
66
+ trace: ["room"],
67
+ leave: ["room"],
68
+ seats: [],
69
+ doctor: [],
70
+ poke: [],
71
+ };
72
+ /** How many letters to add, drop or change to get from one word to the other. */
73
+ export function distance(a, b) {
74
+ let row = Array.from({ length: b.length + 1 }, (_, i) => i);
75
+ for (let i = 1; i <= a.length; i++) {
76
+ const next = [i];
77
+ for (let j = 1; j <= b.length; j++)
78
+ next[j] = Math.min(row[j] + 1, next[j - 1] + 1, row[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
79
+ row = next;
80
+ }
81
+ return row[b.length];
82
+ }
83
+ function lettersInOrder(short, long) {
84
+ let at = 0;
85
+ for (const letter of short) {
86
+ at = long.indexOf(letter, at) + 1;
87
+ if (at === 0)
88
+ return false;
89
+ }
90
+ return true;
91
+ }
92
+ /** The closest of `known` to a mistyped flag: one that starts the other
93
+ * (--reply for --reply-to), else one with its letters in order, else one
94
+ * a few letters away. */
95
+ export function closestFlag(name, known) {
96
+ const prefix = known.filter((one) => name.startsWith(one) || one.startsWith(name)).sort((a, b) => b.length - a.length)[0];
97
+ if (prefix)
98
+ return prefix;
99
+ // Its letters in order: --secs for --seconds.
100
+ const spelled = known.find((one) => lettersInOrder(name, one));
101
+ if (spelled)
102
+ return spelled;
103
+ const near = known.map((one) => ({ one, far: distance(name, one) })).sort((a, b) => a.far - b.far)[0];
104
+ return near && near.far <= Math.max(2, Math.floor(name.length / 3)) ? near.one : null;
105
+ }
106
+ /** The error for the first flag `command` does not have, or null. A word
107
+ * like --reply_to counts too, though flags() reads it as text: said is
108
+ * better than posted. */
109
+ /** Said to `station say --take`: the command for what the agent meant, by
110
+ * whether it was replying to a message (take that one) or not (start its
111
+ * own). An agent that had both `say --take` and `task take` in front of it
112
+ * ran `say --reply 2515 --take`, and the reply became a task of its own. */
113
+ function sayTake(me, args) {
114
+ const at = args.findIndex((word) => word === "--reply" || word.startsWith("--reply="));
115
+ const reply = at < 0 ? null : args[at].includes("=") ? args[at].slice(args[at].indexOf("=") + 1) : args[at + 1];
116
+ const start = `To start work nobody asked for: ${me} task start "<what, and which files>".`;
117
+ const take = /^\d+$/.test(reply ?? "") ? `To take the task in message ${reply}: ${me} task take ${reply}. ` : `To take the task in a message: ${me} task take <its number>. `;
118
+ return `--take is not a flag of ${me} say. ${take}${start} Nothing was done.`;
119
+ }
120
+ /** The commands that put a file from this computer on the board. */
121
+ const PUTS_A_FILE = ["board cp", "cp", "file"];
122
+ /** Said to `station file notes.md --content "..."`: these commands copy a
123
+ * file, and text that is in no file goes up with board write. Agents told
124
+ * only `station file <path.md>` typed --content with the text 14 times. */
125
+ function textNotAFile(me, command, flag, args) {
126
+ const name = args.find((word) => !word.startsWith("--") && args[args.indexOf(word) - 1] !== flag);
127
+ return `${flag} is not a flag of ${me} ${command}, which puts up a file from this computer. To put text on the board: ${me} board write ${name ?? "<path>"} --text "<the text>". Nothing was done.`;
128
+ }
129
+ export function unknownFlag(me, command, args, shown = command) {
130
+ const known = COMMAND_FLAGS[command];
131
+ if (!known)
132
+ return null;
133
+ for (const word of args) {
134
+ const match = /^--([A-Za-z0-9][A-Za-z0-9_-]*)(?:=|$)/.exec(word);
135
+ if (!match || match[1] === "help" || known.includes(match[1]))
136
+ continue;
137
+ const flag = `--${match[1]}`;
138
+ // No flag turns saying something into a task action: the task commands are their own family.
139
+ if (command === "say" && match[1] === "take")
140
+ return sayTake(me, args);
141
+ if (PUTS_A_FILE.includes(command) && ["content", "text"].includes(match[1]))
142
+ return textNotAFile(me, command, flag, args);
143
+ if (!known.length)
144
+ return `${flag} is not a flag of ${me} ${shown}, which takes none. Run it again without ${flag}.`;
145
+ const near = closestFlag(match[1].toLowerCase().replace(/_/g, "-"), known);
146
+ if (near)
147
+ return `${flag} is not a flag of ${me} ${shown}. Did you mean --${near}? Nothing was done.`;
148
+ return `${flag} is not a flag of ${me} ${shown}. Its flags: ${known.map((one) => `--${one}`).join(", ")}. Nothing was done.`;
16
149
  }
17
- return { rest, flag: (name) => named.get(name) };
150
+ return null;
18
151
  }
package/dist/caller.js CHANGED
@@ -29,13 +29,6 @@ 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
- }
39
32
  export function userAgent() {
40
33
  const product = `station-${caller.mode}/${VERSION}`;
41
34
  if (caller.mode === "daemon")
package/dist/claude.js CHANGED
@@ -84,8 +84,9 @@ export function readSession(home, pid) {
84
84
  }
85
85
  const text = (key) => (typeof record[key] === "string" ? record[key] : null);
86
86
  const sessionId = text("sessionId");
87
+ // No inbox socket: Station's hooks can still reach it (hooks.ts).
87
88
  const socketPath = text("messagingSocketPath");
88
- if (!sessionId || !socketPath)
89
+ if (!sessionId)
89
90
  return null;
90
91
  return {
91
92
  pid,
@@ -235,6 +236,8 @@ function writeFrames(socketPath, frames) {
235
236
  /** Puts `text` into the session as a user message. `delivered` means the
236
237
  * bytes were handed over, not that Claude has read them yet. */
237
238
  export async function deliver(home, session, messageId, text, ps = systemPs) {
239
+ if (!session.socketPath)
240
+ return { kind: "retry", reason: "This Claude Code session has no inbox. Station's hooks bring messages in when its next turn starts." };
238
241
  if (session.peerProtocol !== KNOWN_PEER_PROTOCOL) {
239
242
  return { kind: "retry", reason: `That session speaks inbox protocol ${session.peerProtocol}; Station knows ${KNOWN_PEER_PROTOCOL}.` };
240
243
  }