@santori/station 0.8.0 → 0.8.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 +6 -0
- package/dist/cli.js +12 -3
- package/dist/mcp.js +15 -11
- package/dist/tool.js +131 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -150,6 +150,12 @@ station read [--after N] print the room's messages after message N (0 f
|
|
|
150
150
|
station name "<a few words>" name the room, once you know what the work is
|
|
151
151
|
station file <path> put a file on the room's board
|
|
152
152
|
station status working|thinking|here
|
|
153
|
+
station tool [<name> [--<input> <value> ...]]
|
|
154
|
+
run one of Station's tools, each input as a flag: `station tool`
|
|
155
|
+
lists them and `station tool <name> --help` shows one's flags.
|
|
156
|
+
The tools and their flags come from Station, so new ones work
|
|
157
|
+
without a new CLI. Say what you are working on:
|
|
158
|
+
station tool room_status --status working --doing "writing the copy"
|
|
153
159
|
station ask "<what>" [--command "<cmd>"] [--for "<who asked>"]
|
|
154
160
|
ask the person you work for on a card in the room
|
|
155
161
|
station ask --answered approved|declined
|
package/dist/cli.js
CHANGED
|
@@ -26,6 +26,7 @@ import { callingAgent, delivers, deliverTo } from "./sessions.js";
|
|
|
26
26
|
import { useEnvProxy } from "./proxy.js";
|
|
27
27
|
import { PACKAGE, VERSION, selfCommand } from "./self.js";
|
|
28
28
|
import { useTool } from "./station.js";
|
|
29
|
+
import { toolCommand } from "./tool.js";
|
|
29
30
|
import { webhookCommand } from "./webhooks.js";
|
|
30
31
|
import { Usage } from "./usage.js";
|
|
31
32
|
const HELP = `station: an agent's way into Station rooms
|
|
@@ -46,6 +47,11 @@ const HELP = `station: an agent's way into Station rooms
|
|
|
46
47
|
station name "<a few words>" name the room, once you know what the work is
|
|
47
48
|
station file <path> put a file on the room's board
|
|
48
49
|
station status working|thinking|here
|
|
50
|
+
station tool [<name> [--<input> <value> ...]]
|
|
51
|
+
run one of Station's tools from the shell, each input as a flag:
|
|
52
|
+
station tool lists them, station tool <name> --help shows its flags.
|
|
53
|
+
Say what you are working on:
|
|
54
|
+
station tool room_status --status working --doing "writing the copy"
|
|
49
55
|
station ask "<what>" [--command "<cmd>"] [--for "<who asked>"]
|
|
50
56
|
ask the person you work for on a card in the room
|
|
51
57
|
station ask --answered approved|declined
|
|
@@ -71,9 +77,9 @@ Several agents in one folder, or in one Claude Code or Codex session
|
|
|
71
77
|
(subagents): give each its own STATION_SESSION=<name> on every command.
|
|
72
78
|
Each name has its own seat and reads its messages with station wait.
|
|
73
79
|
Without installing:
|
|
74
|
-
npx -y ${PACKAGE} <command>.
|
|
80
|
+
npx -y ${PACKAGE}@latest <command>.
|
|
75
81
|
|
|
76
|
-
As tools in Claude Code: claude mcp add station -- npx -y ${PACKAGE} mcp`;
|
|
82
|
+
As tools in Claude Code: claude mcp add station -- npx -y ${PACKAGE}@latest mcp`;
|
|
77
83
|
/** For a second agent in a Claude Code or Codex session, such as a subagent. */
|
|
78
84
|
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.";
|
|
79
85
|
const TYPES = {
|
|
@@ -95,7 +101,8 @@ async function main(argv) {
|
|
|
95
101
|
const { rest: args, flag } = flags(rawArgs);
|
|
96
102
|
// --help after a command prints the help and does nothing else: it used
|
|
97
103
|
// to be dropped, so `station login --help` started a login.
|
|
98
|
-
|
|
104
|
+
// `station tool <name> --help` is that tool's own help (tool.ts).
|
|
105
|
+
if (command !== "login-helper" && command !== "tool" && flag("help") !== undefined) {
|
|
99
106
|
console.log(HELP);
|
|
100
107
|
return 0;
|
|
101
108
|
}
|
|
@@ -347,6 +354,8 @@ async function main(argv) {
|
|
|
347
354
|
out(message);
|
|
348
355
|
return 0;
|
|
349
356
|
}
|
|
357
|
+
case "tool":
|
|
358
|
+
return toolCommand({ home, args: rawArgs, out, me });
|
|
350
359
|
case "status": {
|
|
351
360
|
const [status] = args;
|
|
352
361
|
if (!["working", "thinking", "here"].includes(status ?? ""))
|
package/dist/mcp.js
CHANGED
|
@@ -109,15 +109,11 @@ export async function instructionsFrom(home, post = postToAgent) {
|
|
|
109
109
|
return null;
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
export function
|
|
113
|
-
const server = new Server({ name: "station", version: VERSION }, { capabilities: { tools: {} }, instructions: instructions ?? OFFLINE_INSTRUCTIONS });
|
|
114
|
-
// The agent's app names itself when it connects (Cursor, Claude Code);
|
|
115
|
-
// every call to Station from here on says so in its User-Agent.
|
|
116
|
-
server.oninitialized = () => setCaller({ host: server.getClientVersion()?.name ?? null });
|
|
112
|
+
export function stationTools(home, post = postToAgent, computer = thisComputer) {
|
|
117
113
|
let known = new Map();
|
|
118
|
-
const list = async () => {
|
|
114
|
+
const list = async (from) => {
|
|
119
115
|
const credentials = await settled(home);
|
|
120
|
-
const relayUrl = relayOf(credentials);
|
|
116
|
+
const relayUrl = from ?? relayOf(credentials);
|
|
121
117
|
let tools;
|
|
122
118
|
try {
|
|
123
119
|
tools = (await post(relayUrl, { ...asPerson(credentials, relayUrl), ...ours() }, "tools/list", {})).tools;
|
|
@@ -130,9 +126,7 @@ export function createStationServer(home, post = postToAgent, instructions = nul
|
|
|
130
126
|
known = new Map(tools.map((tool) => [tool.name, tool]));
|
|
131
127
|
return tools;
|
|
132
128
|
};
|
|
133
|
-
|
|
134
|
-
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
135
|
-
const { name, arguments: args = {} } = request.params;
|
|
129
|
+
const call = async (name, args) => {
|
|
136
130
|
try {
|
|
137
131
|
if (!known.has(name))
|
|
138
132
|
await list();
|
|
@@ -191,7 +185,17 @@ export function createStationServer(home, post = postToAgent, instructions = nul
|
|
|
191
185
|
catch (error) {
|
|
192
186
|
return failed(error);
|
|
193
187
|
}
|
|
194
|
-
}
|
|
188
|
+
};
|
|
189
|
+
return { list, call };
|
|
190
|
+
}
|
|
191
|
+
export function createStationServer(home, post = postToAgent, instructions = null, computer = thisComputer) {
|
|
192
|
+
const server = new Server({ name: "station", version: VERSION }, { capabilities: { tools: {} }, instructions: instructions ?? OFFLINE_INSTRUCTIONS });
|
|
193
|
+
// The agent's app names itself when it connects (Cursor, Claude Code);
|
|
194
|
+
// every call to Station from here on says so in its User-Agent.
|
|
195
|
+
server.oninitialized = () => setCaller({ host: server.getClientVersion()?.name ?? null });
|
|
196
|
+
const tools = stationTools(home, post, computer);
|
|
197
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: await tools.list() }));
|
|
198
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => tools.call(request.params.name, request.params.arguments ?? {}));
|
|
195
199
|
return server;
|
|
196
200
|
}
|
|
197
201
|
export async function serveMcp(home) {
|
package/dist/tool.js
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { files } from "./home.js";
|
|
2
|
+
import { inSession } from "./join.js";
|
|
3
|
+
import { stationTools } from "./mcp.js";
|
|
4
|
+
import { loadSeats, seatFor } from "./seats.js";
|
|
5
|
+
import { Usage } from "./usage.js";
|
|
6
|
+
const inputsOf = (tool) => (tool.inputSchema.properties ?? {});
|
|
7
|
+
const requiredOf = (tool) => (tool.inputSchema.required ?? []);
|
|
8
|
+
/** An input as a flag: `is_public` is `--is-public`. */
|
|
9
|
+
const flagOf = (input) => `--${input.replace(/_/g, "-")}`;
|
|
10
|
+
const typeOf = (input) => (Array.isArray(input.type) ? (input.type.find((one) => one !== "null") ?? "string") : (input.type ?? "string"));
|
|
11
|
+
/** `--name value`, `--name=value`, or a bare `--name` (true). Unlike the
|
|
12
|
+
* commands' own flags, a name may hold digits and underscores, and a value
|
|
13
|
+
* may start with a dash when it is given with `=`. */
|
|
14
|
+
export function toolFlags(args) {
|
|
15
|
+
const given = new Map();
|
|
16
|
+
const rest = [];
|
|
17
|
+
for (let i = 0; i < args.length; i++) {
|
|
18
|
+
const match = /^--([A-Za-z0-9_-]+)(?:=([\s\S]*))?$/.exec(args[i]);
|
|
19
|
+
if (!match)
|
|
20
|
+
rest.push(args[i]);
|
|
21
|
+
else if (match[2] !== undefined)
|
|
22
|
+
given.set(match[1], match[2]);
|
|
23
|
+
else if (i + 1 < args.length && !args[i + 1].startsWith("--"))
|
|
24
|
+
given.set(match[1], args[++i]);
|
|
25
|
+
else
|
|
26
|
+
given.set(match[1], true);
|
|
27
|
+
}
|
|
28
|
+
return { given, rest };
|
|
29
|
+
}
|
|
30
|
+
/** A flag's text as the tool's input wants it. */
|
|
31
|
+
function valueFor(flag, input, raw) {
|
|
32
|
+
const type = typeOf(input);
|
|
33
|
+
if (type === "boolean") {
|
|
34
|
+
if (raw === true || raw === "true")
|
|
35
|
+
return true;
|
|
36
|
+
if (raw === "false")
|
|
37
|
+
return false;
|
|
38
|
+
throw new Usage(`${flag} is true or false.`);
|
|
39
|
+
}
|
|
40
|
+
if (raw === true)
|
|
41
|
+
throw new Usage(`${flag} needs a value.`);
|
|
42
|
+
if (type === "number" || type === "integer") {
|
|
43
|
+
const number = Number(raw);
|
|
44
|
+
if (raw.trim() === "" || Number.isNaN(number))
|
|
45
|
+
throw new Usage(`${flag} is a number.`);
|
|
46
|
+
return number;
|
|
47
|
+
}
|
|
48
|
+
if (type === "array" || type === "object") {
|
|
49
|
+
try {
|
|
50
|
+
return JSON.parse(raw);
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
throw new Usage(`${flag} is JSON, such as ${type === "array" ? '\'["a","b"]\'' : "'{\"key\":\"value\"}'"}.`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return raw;
|
|
57
|
+
}
|
|
58
|
+
function oneLine(text, max = 200) {
|
|
59
|
+
const line = (text ?? "").replace(/\s+/g, " ").trim();
|
|
60
|
+
return line.length > max ? `${line.slice(0, max - 1)}…` : line;
|
|
61
|
+
}
|
|
62
|
+
/** One tool's flags, as its help. */
|
|
63
|
+
export function toolHelp(me, tool) {
|
|
64
|
+
const required = requiredOf(tool);
|
|
65
|
+
const lines = [`${me} tool ${tool.name}${Object.keys(inputsOf(tool)).length ? " [flags]" : ""}`, "", (tool.description ?? "").trim(), ""];
|
|
66
|
+
for (const [name, input] of Object.entries(inputsOf(tool))) {
|
|
67
|
+
const choices = input.enum?.length ? ` One of: ${input.enum.join(", ")}.` : "";
|
|
68
|
+
const need = name === "room" ? " (this session's room when left out)" : required.includes(name) ? " (required)" : "";
|
|
69
|
+
lines.push(` ${flagOf(name)} <${typeOf(input)}>${need}`, ` ${oneLine(input.description)}${choices}`);
|
|
70
|
+
}
|
|
71
|
+
return lines;
|
|
72
|
+
}
|
|
73
|
+
function sessionSeat(home) {
|
|
74
|
+
try {
|
|
75
|
+
return seatFor(loadSeats(files(home).seats), inSession().id) ?? null;
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
// Not an agent's session: the call goes as the person.
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function textOf(result) {
|
|
83
|
+
return (result.content ?? []).map((part) => (part.type === "text" ? part.text : "")).join("\n");
|
|
84
|
+
}
|
|
85
|
+
/** Runs `station tool ...`: 0 when the tool answered, 1 when it refused. */
|
|
86
|
+
export async function toolCommand({ home, args, out, me, tools = stationTools(home), seat = () => sessionSeat(home) }) {
|
|
87
|
+
const { given, rest } = toolFlags(args);
|
|
88
|
+
const [name, ...extra] = rest;
|
|
89
|
+
const mine = seat();
|
|
90
|
+
const listed = await tools.list(mine?.relayUrl);
|
|
91
|
+
if (!listed.length)
|
|
92
|
+
throw new Error("Station did not answer, and this computer has no list of its tools yet. Try again in a moment.");
|
|
93
|
+
if (!name) {
|
|
94
|
+
out(`Station's tools. For one tool's flags: ${me} tool <name> --help`);
|
|
95
|
+
out("");
|
|
96
|
+
for (const tool of listed)
|
|
97
|
+
out(` ${tool.name.padEnd(18)} ${oneLine(tool.title ?? tool.description, 90)}`);
|
|
98
|
+
return 0;
|
|
99
|
+
}
|
|
100
|
+
const tool = listed.find((one) => one.name === name);
|
|
101
|
+
if (!tool)
|
|
102
|
+
throw new Usage(`Station has no tool called ${name}. It has: ${listed.map((one) => one.name).join(", ")}.`);
|
|
103
|
+
if (given.has("help")) {
|
|
104
|
+
for (const line of toolHelp(me, tool))
|
|
105
|
+
out(line);
|
|
106
|
+
return 0;
|
|
107
|
+
}
|
|
108
|
+
if (extra.length)
|
|
109
|
+
throw new Usage(`${me} tool takes each input as a flag, such as --text "hello". Not understood: ${extra.join(" ")}\n\n${toolHelp(me, tool).join("\n")}`);
|
|
110
|
+
const inputs = inputsOf(tool);
|
|
111
|
+
const byFlag = new Map(Object.keys(inputs).flatMap((input) => [[input, input], [input.replace(/_/g, "-"), input]]));
|
|
112
|
+
const call = {};
|
|
113
|
+
for (const [flag, raw] of given) {
|
|
114
|
+
const input = byFlag.get(flag);
|
|
115
|
+
if (!input)
|
|
116
|
+
throw new Usage(`${tool.name} has no --${flag}.\n\n${toolHelp(me, tool).join("\n")}`);
|
|
117
|
+
call[input] = valueFor(`--${flag}`, inputs[input], raw);
|
|
118
|
+
}
|
|
119
|
+
// The room this session sits in, when the tool takes one and none was given.
|
|
120
|
+
if ("room" in inputs && call.room === undefined && mine)
|
|
121
|
+
call.room = `${mine.relayUrl}/${mine.roomId}`;
|
|
122
|
+
const missing = requiredOf(tool).filter((input) => call[input] === undefined);
|
|
123
|
+
if (missing.length)
|
|
124
|
+
throw new Usage(`${tool.name} needs ${missing.map(flagOf).join(", ")}.\n\n${toolHelp(me, tool).join("\n")}`);
|
|
125
|
+
const result = await tools.call(tool.name, call);
|
|
126
|
+
const text = textOf(result);
|
|
127
|
+
if (result.isError)
|
|
128
|
+
throw new Error(text || `Station refused ${tool.name}.`);
|
|
129
|
+
out(text);
|
|
130
|
+
return 0;
|
|
131
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@santori/station",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.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",
|