@santori/station 0.9.9 → 0.9.10
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 +14 -7
- package/dist/agentToken.js +14 -5
- package/dist/agents.js +4 -4
- package/dist/args.js +109 -6
- package/dist/cli.js +137 -92
- package/dist/codex.js +26 -5
- package/dist/commands.js +22 -5
- package/dist/daemon.js +27 -14
- package/dist/frame.js +12 -24
- package/dist/guest.js +3 -2
- package/dist/handover.js +1 -0
- package/dist/home.js +3 -1
- package/dist/join.js +119 -92
- package/dist/login.js +146 -24
- package/dist/mark.js +40 -10
- package/dist/mcp.js +3 -3
- package/dist/rooms.js +2 -4
- package/dist/seats.js +14 -2
- package/dist/starts.js +15 -8
- package/dist/tool.js +5 -2
- package/dist/waking.js +11 -5
- package/dist/webhooks.js +30 -42
- package/package.json +2 -2
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.
|
|
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
|
|
@@ -183,7 +186,9 @@ station wait [--seconds N] wait for new messages and print them (until on
|
|
|
183
186
|
station read <n> | <n>-<m> print message n, or messages n to m (several: 12,15-17)
|
|
184
187
|
station read [--after N] print the room's messages after message N (0 for the oldest), 100 at a time
|
|
185
188
|
station name "<a few words>" name the room, once you know what the work is
|
|
186
|
-
station file <
|
|
189
|
+
station cp <file>... <to> put files from this computer on the room's board: to is a
|
|
190
|
+
board path for one file, or a folder ending with /.
|
|
191
|
+
A file already there is replaced. [--if-rev N]
|
|
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> ...]]
|
|
@@ -205,10 +210,11 @@ 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 <
|
|
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
|
|
211
|
-
|
|
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
|
|
278
|
-
|
|
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
|
package/dist/agentToken.js
CHANGED
|
@@ -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.
|
|
5
|
-
//
|
|
6
|
-
//
|
|
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
|
@@ -52,11 +52,11 @@ export function askable(mine, own) {
|
|
|
52
52
|
export function toFlag(name) {
|
|
53
53
|
return `--to ${name.includes(" ") ? `"${name}"` : name}`;
|
|
54
54
|
}
|
|
55
|
-
/** What a seat is told about the agents it can
|
|
55
|
+
/** What a seat is told about the agents it can address, or null with none. */
|
|
56
56
|
export function askLine(names, me) {
|
|
57
57
|
if (!names.length)
|
|
58
58
|
return null;
|
|
59
|
-
return `Your person's agents
|
|
59
|
+
return `Your person's agents, seated here or not: ${names.join(", ")}. Address one with: ${me} say ${toFlag(names[0])} "<what>"`;
|
|
60
60
|
}
|
|
61
61
|
/** The agents to offer a session that joins a room: on this computer,
|
|
62
62
|
* with no install of theirs here, not said no to, and not the joining one's own kind. */
|
|
@@ -105,7 +105,7 @@ export async function addDevin(credentials, options, env = process.env) {
|
|
|
105
105
|
const max = options.maxAcu === undefined ? 3 : Number(options.maxAcu);
|
|
106
106
|
const added = await call(credentials.relayUrl, "/me/agents", { token: credentials.token }, { body: { kind: "devin", devin: { org: options.org, key, max_acu_limit: max } } });
|
|
107
107
|
return [
|
|
108
|
-
`Devin is your person's agent in Station now. When
|
|
108
|
+
`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
109
|
"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
110
|
added.secret,
|
|
111
111
|
`To ask it in a room, run: ${options.me} say --to Devin "<what to do>"`,
|
|
@@ -132,6 +132,6 @@ export async function addAgent(home, credentials, wanted, options, env = process
|
|
|
132
132
|
await run(program, agent.addArgs(mcpCommand(), stationEnv(env)), env);
|
|
133
133
|
lines.push(`${agent.name}'s own windows now have Station's tools, through this computer's Station.`);
|
|
134
134
|
}
|
|
135
|
-
lines.push(`${agent.name} is your person's agent in Station now, in all their rooms, and runs on this computer.
|
|
135
|
+
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
136
|
return lines;
|
|
137
137
|
}
|
package/dist/args.js
CHANGED
|
@@ -1,18 +1,121 @@
|
|
|
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
|
-
|
|
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. */
|
|
7
|
+
export function flags(args, command, me = "station") {
|
|
8
|
+
const known = command === undefined ? undefined : COMMAND_FLAGS[command];
|
|
9
|
+
if (known) {
|
|
10
|
+
const wrong = unknownFlag(me, command, args);
|
|
11
|
+
if (wrong)
|
|
12
|
+
throw new Usage(wrong);
|
|
13
|
+
}
|
|
4
14
|
const rest = [];
|
|
5
15
|
const named = new Map();
|
|
16
|
+
const set = (name, value) => named.set(name, [...(named.get(name) ?? []), value]);
|
|
6
17
|
for (let i = 0; i < args.length; i++) {
|
|
7
18
|
const match = /^--([a-z-]+)(?:=(.*))?$/.exec(args[i]);
|
|
8
19
|
if (!match)
|
|
9
20
|
rest.push(args[i]);
|
|
10
21
|
else if (match[2] !== undefined)
|
|
11
|
-
|
|
22
|
+
set(match[1], match[2]);
|
|
12
23
|
else if (i + 1 < args.length && !args[i + 1].startsWith("--"))
|
|
13
|
-
|
|
24
|
+
set(match[1], args[++i]);
|
|
14
25
|
else
|
|
15
|
-
|
|
26
|
+
set(match[1], "true");
|
|
27
|
+
}
|
|
28
|
+
const values = (name) => {
|
|
29
|
+
if (known && name !== "help" && !known.includes(name))
|
|
30
|
+
throw new Error(`${me} ${command} reads --${name}, which COMMAND_FLAGS does not list for it.`);
|
|
31
|
+
return named.get(name) ?? [];
|
|
32
|
+
};
|
|
33
|
+
return { rest, flag: (name) => values(name).at(-1), all: values };
|
|
34
|
+
}
|
|
35
|
+
/** The flags of each of the CLI's own commands, --help aside: the one
|
|
36
|
+
* list. flags() refuses any other on the command line, and throws when the
|
|
37
|
+
* command's code reads one not listed here. A command not here checks its
|
|
38
|
+
* own: `tool` and the commands Station defines (tool.ts, commands.ts), and
|
|
39
|
+
* the ones Station starts itself (daemon, mcp, login-helper). */
|
|
40
|
+
export const COMMAND_FLAGS = {
|
|
41
|
+
login: ["relay", "web", "signup", "code", "remote", "agent", "no-browser", "wait"],
|
|
42
|
+
signup: ["relay", "web", "email"],
|
|
43
|
+
logout: [],
|
|
44
|
+
whoami: [],
|
|
45
|
+
rooms: ["json"],
|
|
46
|
+
webhook: ["agent", "url", "header-name", "sign", "on", "debounce", "wakes-per-day"],
|
|
47
|
+
webhooks: ["agent", "url", "header-name", "sign", "on", "debounce", "wakes-per-day"],
|
|
48
|
+
new: ["title", "public", "team", "relay"],
|
|
49
|
+
add: ["no", "org", "key-env", "max-acu"],
|
|
50
|
+
watch: ["agent", "seconds"],
|
|
51
|
+
join: ["name", "invite"],
|
|
52
|
+
wait: ["room", "seconds"],
|
|
53
|
+
read: ["room", "after"],
|
|
54
|
+
say: ["reply", "to", "room"],
|
|
55
|
+
name: ["room"],
|
|
56
|
+
cp: ["room", "name", "if-rev"],
|
|
57
|
+
file: ["room", "name", "if-rev"],
|
|
58
|
+
ask: ["room", "for", "command", "answered"],
|
|
59
|
+
admit: ["room", "no"],
|
|
60
|
+
claim: ["room"],
|
|
61
|
+
status: ["room", "doing"],
|
|
62
|
+
trace: ["room"],
|
|
63
|
+
leave: ["room"],
|
|
64
|
+
seats: [],
|
|
65
|
+
doctor: [],
|
|
66
|
+
poke: [],
|
|
67
|
+
};
|
|
68
|
+
function distance(a, b) {
|
|
69
|
+
let row = Array.from({ length: b.length + 1 }, (_, i) => i);
|
|
70
|
+
for (let i = 1; i <= a.length; i++) {
|
|
71
|
+
const next = [i];
|
|
72
|
+
for (let j = 1; j <= b.length; j++)
|
|
73
|
+
next[j] = Math.min(row[j] + 1, next[j - 1] + 1, row[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
|
|
74
|
+
row = next;
|
|
75
|
+
}
|
|
76
|
+
return row[b.length];
|
|
77
|
+
}
|
|
78
|
+
function lettersInOrder(short, long) {
|
|
79
|
+
let at = 0;
|
|
80
|
+
for (const letter of short) {
|
|
81
|
+
at = long.indexOf(letter, at) + 1;
|
|
82
|
+
if (at === 0)
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
/** The closest of `known` to a mistyped flag: one that starts the other
|
|
88
|
+
* (--reply for --reply-to), else one with its letters in order, else one
|
|
89
|
+
* a few letters away. */
|
|
90
|
+
export function closestFlag(name, known) {
|
|
91
|
+
const prefix = known.filter((one) => name.startsWith(one) || one.startsWith(name)).sort((a, b) => b.length - a.length)[0];
|
|
92
|
+
if (prefix)
|
|
93
|
+
return prefix;
|
|
94
|
+
// Its letters in order: --secs for --seconds.
|
|
95
|
+
const spelled = known.find((one) => lettersInOrder(name, one));
|
|
96
|
+
if (spelled)
|
|
97
|
+
return spelled;
|
|
98
|
+
const near = known.map((one) => ({ one, far: distance(name, one) })).sort((a, b) => a.far - b.far)[0];
|
|
99
|
+
return near && near.far <= Math.max(2, Math.floor(name.length / 3)) ? near.one : null;
|
|
100
|
+
}
|
|
101
|
+
/** The error for the first flag `command` does not have, or null. A word
|
|
102
|
+
* like --reply_to counts too, though flags() reads it as text: said is
|
|
103
|
+
* better than posted. */
|
|
104
|
+
export function unknownFlag(me, command, args) {
|
|
105
|
+
const known = COMMAND_FLAGS[command];
|
|
106
|
+
if (!known)
|
|
107
|
+
return null;
|
|
108
|
+
for (const word of args) {
|
|
109
|
+
const match = /^--([A-Za-z0-9][A-Za-z0-9_-]*)(?:=|$)/.exec(word);
|
|
110
|
+
if (!match || match[1] === "help" || known.includes(match[1]))
|
|
111
|
+
continue;
|
|
112
|
+
const flag = `--${match[1]}`;
|
|
113
|
+
if (!known.length)
|
|
114
|
+
return `${flag} is not a flag of ${me} ${command}, which takes none. Run it again without ${flag}.`;
|
|
115
|
+
const near = closestFlag(match[1].toLowerCase().replace(/_/g, "-"), known);
|
|
116
|
+
if (near)
|
|
117
|
+
return `${flag} is not a flag of ${me} ${command}. Did you mean --${near}? Nothing was done.`;
|
|
118
|
+
return `${flag} is not a flag of ${me} ${command}. Its flags: ${known.map((one) => `--${one}`).join(", ")}. Nothing was done.`;
|
|
16
119
|
}
|
|
17
|
-
return
|
|
120
|
+
return null;
|
|
18
121
|
}
|