Public: anyone can read this; the crew can change it.

Talk's tool list: 17,113 to 15,999 bytes (1,501 bytes of room under the 17,500 ceiling) #16373

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

talk/tools-trim → main 0 commits 3 threads · 3 unresolved

  • Merged. talk/tools-trim was merged into main as 8013afb.

Review

Sign in to review this change.
21 files changed +55 −20
src/http/mcp.ts +23 −1
@@ -81,6 +81,26 @@ export function toolEntries(tools: readonly (typeof TOOLS)[number][]) {
8181 ];
8282 }
8383
84 /** A schema without the `minimum: 1` of a count (a number or limit is positive by what it is). */
85 const noMinimum = (schema: unknown): unknown => {
86 if (Array.isArray(schema)) return schema.map(noMinimum);
87 if (schema === null || typeof schema !== "object") return schema;
88 return Object.fromEntries(
89 Object.entries(schema).filter(([k, v]) => !(k === "minimum" && v === 1)).map(([k, v]) => [k, noMinimum(v)]),
90 );
91 };
92
93 /**
94 * Talk's list is read every turn, so it is leaner than the public one: a card is named once (no
95 * `openai/outputTemplate` alias of `ui.resourceUri`, for ChatGPT) and a count has no `minimum: 1`.
96 * Every other caller's list keeps both, as the public contract.
97 */
98 function forTalk<T extends { inputSchema?: unknown }>(entry: T): T {
99 const meta = (entry as { _meta?: { ui?: unknown } })._meta;
100 const lean = { ...entry, inputSchema: noMinimum(entry.inputSchema) };
101 return meta === undefined ? lean : { ...lean, _meta: { ui: meta.ui } };
102 }
103
84104 /** The entries this caller may call, `report` and `start` included: what find_tool searches. */
85105 export const entriesFor = (ctx: Ctx, user: User) => toolEntries(TOOLS.filter((t) => listable(t, ctx, user)));
86106
@@ -218,7 +238,9 @@ function rpcOne(
218238 ? listed
219239 : role === "guest"
220240 ? listed.filter((t) => GUEST_TOOLS.includes(t.name))
221 : listed.filter((t) => (ctx.auth.through === undefined ? DEFAULT_TOOLS.includes(t.name) : talkLists(t.name, user.isAdmin)));
241 : ctx.auth.through === undefined
242 ? listed.filter((t) => DEFAULT_TOOLS.includes(t.name))
243 : listed.filter((t) => talkLists(t.name, user.isAdmin)).map(forTalk);
222244 // The cursor is the name of the last tool of the page before, so a tool
223245 // added between two requests moves nothing.
224246 const cursor = params["cursor"];
src/http/mcp/tools/apps.ts +1 −1
@@ -18,7 +18,7 @@ export const tool: Tool = {
1818 name: "apps",
1919 doc: "`{ action: \"restore\", repo? }` brings an archived app back (admin token); `{ archived? }`: your apps (`ui://forge/app` card): live or not, what is working, running `previews`, `crew` with a run now, and in migration mode `mode` and `migration {origin, done, total, state}` (`origin` is null to someone who may not see a private source). `{ repo, pulls: true, limit? }`: an adapter's pull runs, as `GET …/app/pulls` (`limit`); a reader's",
2020 description:
21 "Apps you can see: live, where served, how each runs, what works.",
21 "Apps you can see: live, where served, how run, what works.",
2222 inputSchema: {
2323 type: "object",
2424 properties: {
src/http/mcp/tools/assign.ts +1 −1
@@ -8,7 +8,7 @@ import { good, bad, type Tool, REPO_ARG, repoArg, issueArg, isAnswer } from "../
88 export const tool: Tool = {
99 name: "assign",
1010 doc: "`{ repo, number, kind, assignee }`: assign an issue or pull (`kind` is `issue` or `pull`) to a user, or clear it with `null`, as `PUT …/assignee` and with its refusals",
11 description: "Assign an issue or pull to a user, or clear (null); PUT refusals apply.",
11 description: "Assign an issue or pull to a user, or clear (null).",
1212 inputSchema: {
1313 type: "object",
1414 properties: {
src/http/mcp/tools/branches.ts +1 −1
@@ -11,7 +11,7 @@ export const tool: Tool = {
1111 name: "branches",
1212 doc: "`{ repo, name?, action?, from?, kind? }`: without `name`, lists the branches; `kind: \"tags\"` lists the tags instead (as GET `/api/v1/repos/:owner/:name/tags` does, newest first; no `name` or `action`); with `name` and `action` (`create` from `from`, or `delete`) it does what the branches page does: the default branch is never deleted, only a writer may act",
1313 description:
14 "A repo's branches; `name`, `action` create (from `from`) or delete one, not the default.",
14 "A repo's branches; `action` create (from `from`) or delete `name`, never the default.",
1515 inputSchema: {
1616 type: "object",
1717 properties: {
src/http/mcp/tools/health.ts +1 −1
@@ -6,7 +6,7 @@ export const tool: Tool = {
66 name: "health",
77 doc: "how this forge is: the version and commit it runs, draining or not, the rollout and its incidents; `voice` true answers in two spoken sentences",
88 description:
9 "How this forge is: version, rollout, incidents. ok means serving, broken act now, todo would like done.",
9 "The forge's health: version, rollout, incidents. ok serving, broken act now, todo wanted.",
1010 inputSchema: {
1111 type: "object",
1212 properties: { voice: { type: "boolean", description: "two plain sentences, no markup" } },
src/http/mcp/tools/keep_plan.ts +1 −1
@@ -5,7 +5,7 @@ export const tool: Tool = {
55 name: "keep_plan",
66 doc: "`{ repo, number, items, ask? }`: replace the plan checklist on an issue whole (`items`: up to 12 of `{ text, done? }`; an empty list clears it); `ask` is what you need a person to answer, and shows the run as needing input; the same as `PUT …/issues/:number/plan`; answers the plan",
77 description:
8 "Keep a short plan checklist on your issue, replaced whole each time.",
8 "Keep a short plan checklist on your issue, replaced whole.",
99 inputSchema: {
1010 type: "object",
1111 properties: {
src/http/mcp/tools/new_app.ts +1 −1
@@ -22,7 +22,7 @@ export const tool: Tool = {
2222 name: "new_app",
2323 doc: "`{ name?, sentence?, description?, owner?, visibility?, agent?, pick?, template? }`: make an app from a sentence: with `sentence` and no `name` the name is derived from it (`-2`, `-3` when taken), as the web and terminal do; `name` and `sentence` together keep the name; the first issue is `description`, else `sentence`; answers `{ repo, url, issue, agent, run }` (`run` is the first run's state, or `none`) and draws the `ui://forge/app` card: name, production URL, first issue, agent; refused as `POST /api/v1/apps` is (unverified, app_limit, no_such_agent, name_taken)",
2424 description:
25 "Make an app from a sentence: a repo, production, and with `description` a first issue.",
25 "Make an app from a sentence: repo, production, and with `description` a first issue.",
2626 inputSchema: {
2727 type: "object",
2828 properties: {
src/http/mcp/tools/next_up.ts +1 −1
@@ -27,7 +27,7 @@ const brief = (r: NextRow, week?: WeekView, at = 0) => ({
2727 export const tool: Tool = {
2828 name: "next_up",
2929 doc: "an app's one ranked list (without `app`: the top three of each repository you administer, newest activity first), the crew builds strictly from the top (`app`; with `issue` and `to` — `top`, `not-now` or `after:<number>` — a writer moves that issue and it saves at once; `top` lifts a gated issue past the Later gate; `undo` takes back your `not-now` of the last minute; `all` lists beyond the top ten; each row carries its cost `estimate` range and `thisWeek`, and `projection` is one sentence on what the week can ship)",
30 description: "The ranked list the crew builds from; `issue` + `to` (top, not-now, after:N) moves one.",
30 description: "The crew's ranked build list; `issue` + `to` (top, not-now, after:N) moves one.",
3131 inputSchema: {
3232 type: "object",
3333 properties: {
src/http/mcp/tools/pane.ts +1 −1
@@ -4,7 +4,7 @@ import { bad, good, str, type Tool } from "../shared.ts";
44 export const tool: Tool = {
55 name: "pane",
66 doc: "`{ repo, path?, version?: \"preview\" | \"live\", try? }`: in Talk, open the pane beside the chat on that app at `path` (on its own address), with \"Try: <try>\" above it; answers the address it frames",
7 description: "Open Talk's preview pane on an app at a path, with what to try there.",
7 description: "Open Talk's preview pane on an app at a path, with what to try.",
88 inputSchema: {
99 type: "object",
1010 properties: {
src/http/mcp/tools/pull.ts +1 −1
@@ -27,7 +27,7 @@ export const tool: Tool = {
2727 name: "pull",
2828 doc: "`{ repo, number }`: a pull's title, state, head and base, `summary` (two or three sentences: what changed, what was verified), and for an open pull whether it merges into the base's current head (`mergeable`) and the paths that stop it (`conflicts`), and `next: { who, why }` (open only; who acts next: builder, reviewer, queue or person), `step: { step, why, done }` (check, review, land or live; null once closed unlanded), and `comments` (the newest 10: author, body, at, `untrusted` on an outsider's), `commentsTotal` and `commentsNext` (older: `GET …/issues/:number/comments?cursor=`), and `looks` (newest first: `{ id, width, says, by, commit, url, at }`, the same as `GET …/pulls/:number/looks`), and `eta: { minutes, says }` (approved open pull only, else null), `waitsFor: { cause, says, action, line }` (green, unlanded 6 h+; else null), and `check: { state, baseOid }`: the latest check's state and the base tip it was merged with (empty when it merged nothing), `checkStale` (the base has moved since that check) and `checkedAgainst` (that base tip, or null; the same as `GET …/pulls/:number`); `mergeable` and `conflicts` are the same fields as `GET …/pulls/:number`, `check` is `state` and `run.baseOid` from `GET …/pulls/:number/checks`; `reviewSteps` (the review steps), draws the `ui://forge/pull` card: `#N title`, state with check and conflicts while open, `head → base` linked to the pull, and the preview link when the pull has an environment",
2929 description:
30 "A pull: title, state, head, base; open: `mergeable`, `conflicts`, `checkStale`, `checkedAgainst`, `check`.",
30 "A pull: title, state, head, base; open adds `mergeable`, `conflicts`, `check`.",
3131 inputSchema: {
3232 type: "object",
3333 properties: {
src/http/mcp/tools/read_file.ts +1 −1
@@ -19,7 +19,7 @@ export const tool: Tool = {
1919 name: "read_file",
2020 doc: "`{ repo, path, ref? }`: a file (utf-8 or base64) or a directory listing at a ref, as GET …/contents; MP4/MOV/M4A files also carry about: {kind, seconds, width?, height?, says}, a .pcd {kind: pcd, points, width, height, data, fields, bounds?, says}; .mid {bpm, tracks}; .ifc {says}",
2121 description:
22 "No shell? Read a file or list a directory at a ref (default branch); over 5 MB answers tooLarge.",
22 "No shell? Read a file or list a directory at a ref (default branch); over 5 MB: tooLarge.",
2323 inputSchema: {
2424 type: "object",
2525 properties: {
src/http/mcp/tools/repo.ts +1 −1
@@ -17,7 +17,7 @@ export const tool: Tool = {
1717 name: "repo",
1818 doc: "`{ repo }`: one repository's description, visibility, autonomy (to a writer), `audience { level, who, sentence, appLine }` and `provenance` (where a migrated one came from, `null` when hidden), `follows` (a fork's one line on how it follows upstream, the page's words; `null` for no fork), `credit` (a mirror's upstream, licence, authors; `null` otherwise), the same as `GET /api/v1/repos/:owner/:name`; `action` (`open|add|remove|move|close` with `chapter`, `number` for add/remove/move, `direction: up|down` for move; a person who administers it, `rw` token) says what it would do, and with `confirm: true` does it, as the page; `view: \"chapters\"` lists its chapters with state, and with `chapter` names one's items (`done|building|left`) and `progress` (the page's sentence)",
1919 description:
20 "One repository you can read, as GET /api/v1/repos/:owner/:name.",
20 "One repository you can read.",
2121 inputSchema: {
2222 type: "object",
2323 properties: { repo: REPO_ARG, view: { type: "string", enum: ["chapters"] }, chapter: { type: "string" }, action: { type: "string", enum: ["open", "add", "remove", "move", "close"] }, direction: { type: "string", enum: ["up", "down"] }, number: { type: "integer" }, confirm: { type: "boolean" } },
src/http/mcp/tools/run_log.ts +1 −1
@@ -5,7 +5,7 @@ export const tool: Tool = {
55 name: "run_log",
66 doc: "`{ repo, run, tail? }`: a run's log, or its last `tail` lines (1–2000), with the REST route's access: a hidden log or unreadable repository is not found",
77 description:
8 "A run's log, or its last `tail` lines, as GET /api/v1/repos/:owner/:name/runs/:id/log.",
8 "A run's log, or its last `tail` lines.",
outdated

Stray comma and no object: "…last tail lines,." Make it a full sentence.

99 inputSchema: {
1010 type: "object",
1111 properties: {
src/http/mcp/tools/search.ts +1 −1
@@ -6,7 +6,7 @@ export const tool: Tool = {
66 name: "search",
77 doc: "`{ q, kind?, limit?, repo?, all? }`: guides (`docs`, kind all), issues, pulls, repositories and code you can read, the same results as /search, drawn as the `ui://forge/search` card; `repo` keeps to one; `moreCode` says the code grep stopped at its budget, `all` greps the rest",
88 description:
9 "Find issues, pulls, repositories and code you can read; `kind` and `repo` narrow.",
9 "Find issues, pulls, repositories and code you can read; `kind`, `repo` narrow.",
1010 inputSchema: {
1111 type: "object",
1212 properties: {
src/http/mcp/tools/show.ts +1 −1
@@ -4,7 +4,7 @@ import { readWidget, searchWidgets } from "../../../widgets/registry.ts";
44 export const tool: Tool = {
55 name: "show",
66 doc: "`{ widget?, args?, query? }`: draw a widget (a graph of the forge's data) read as you, and in Talk get its handle for `::show cN`; with no `widget`, the widgets matching `query` with their arguments",
7 description: "Draw a graph of the forge's own data: compute usage, shipping throughput, checks. No widget: list them.",
7 description: "Graph the forge's own data: compute usage, throughput, checks. No widget: list them.",
88 inputSchema: {
99 type: "object",
1010 properties: { widget: { type: "string" }, args: { type: "object" }, query: { type: "string" } },
src/http/mcp/tools/stop.ts +1 −1
@@ -6,7 +6,7 @@ export const tool: Tool = {
66 name: "stop",
77 doc: "`{ repo?, run? }`: stop one run by its id from `now`; with no `repo` it stops the forge's own agent mid-answer",
88 description:
9 "Stop a crew run by its id from `now`; with no repo, the forge's own agent mid-answer.",
9 "Stop a crew run by its id from `now`; no repo: the forge's own agent mid-answer.",
1010 inputSchema: {
1111 type: "object",
1212 properties: { repo: REPO_ARG, run: { type: "string" } },
src/http/mcp/tools/telemetry_history.ts +1 −1
@@ -7,7 +7,7 @@ import { good, bad, type Tool } from "../shared.ts";
77 export const tool: Tool = {
88 name: "telemetry_history",
99 doc: "`{ hours? }` (1–72, default 6): the node's and the forge's CPU cores, memory and load over the window, `{ hours, points: [{ target, at, cpuCores, cpuCoresMax (the bucket's peak), memoryBytes, load }] }`, at most 300 points a series (15-s samples to 24 h, 5-min beyond, averaged down); a forge admin or `telemetry:read`, as `system`; the machine records no disk history. `brief: true`: one value an hour to chart from, `{ hours, at: [YYYY-MM-DDTHH], node, forge }`, each `{ cpuCores, memoryGiB, load }` as arrays, a few hundred bytes a day",
10 description: "Machine CPU, memory, load over `hours` (1–72, default 6); brief: hourly series to chart.",
10 description: "Machine CPU, memory, load over `hours` (1–72, default 6); brief: hourly series.",
1111 inputSchema: {
1212 type: "object",
1313 properties: { hours: { type: "integer", minimum: 1, maximum: 72 }, brief: { type: "boolean" } },
src/http/mcp/tools/threads.ts +1 −1
@@ -7,7 +7,7 @@ export const tool: Tool = {
77 name: "threads",
88 doc: "`{ repo, number, anchor?, resolved? }`: a pull's review threads with their comments; with `anchor` (from the list) resolve it (`resolved` true, the default) or reopen it (false), by the API's rules: a writer or someone who commented in the thread",
99 description:
10 "A pull's review threads; with `anchor`, resolve one or reopen it (`resolved` false).",
10 "A pull's review threads; with `anchor`, resolve one or reopen (`resolved` false).",
1111 inputSchema: {
1212 type: "object",
1313 properties: {
src/http/mcp/tools/usage.ts +1 −1
@@ -6,7 +6,7 @@ export const tool: Tool = {
66 name: "usage",
77 doc: "`{ repo?, days?, kind? }`: `kind: wallet` with a repo is its balance and ten latest spends, as the wallet page says them; no repo, the forge's spend today and last24h and each account's headroom %; else what the crew's runs spent — tokens, cost, wall time — by subscription, agent, issue, and each account's 5-hour and weekly standing; a writer's",
88 description:
9 "Crew spend by `repo` and `days`, or its wallet with `kind: wallet`. Writers.",
9 "Crew spend by `repo`, `days`; its wallet with `kind: wallet`. Writers.",
1010 inputSchema: {
1111 type: "object",
1212 properties: {
src/http/mcp/tools/whoami_can.ts +1 −1
@@ -9,7 +9,7 @@ export const tool: Tool = {
99 name: "whoami_can",
1010 doc: "`{ kind?, remove?, repo? }`: who you are (`username`, and `via` when your own Talk agent asks) and your role, with that role's row of the roles table, each ability yes or no; `repo` (owner/name) adds what you may do there (`read`, `write`, `admin`); `kind: \"passkeys\"` lists your own passkeys (`{ items }`: id, name, created, lastUsed), people only; `remove: id` with `kind: \"passkeys\"` removes one of them, as Settings → Passkeys does (an admin-scope token, never an agent)",
1111 description:
12 "What you can do: your role and its roles-table row, yes or no each.",
12 "What you can do: your role and each action, yes or no.",
1313 inputSchema: {
1414 type: "object",
1515 properties: {
test/mcp-talk-tools.test.ts +13
@@ -122,6 +122,19 @@ describe("the Talk list", () => {
122122 for (const name of DEFAULT_TOOLS) expect(TALK_TOOLS).toContain(name);
123123 });
124124
125 test("the Talk list names a card once and carries no minimum of 1; another caller's list keeps both", async () => {
126 const talk = (await post(via(alice, "what is open?").token, "tools/list")).result!["tools"] as { name: string; _meta?: Record<string, unknown> }[];
127 const cards = talk.filter((t) => t._meta !== undefined);
128 expect(cards.length).toBeGreaterThan(0);
129 for (const t of cards) {
130 expect(Object.keys(t._meta!), t.name).toEqual(["ui"]);
131 }
132 expect(JSON.stringify(talk)).not.toContain('"minimum":1');
133 const plainList = (await post(plain(alice), "tools/list", { all: true })).result!["tools"] as { _meta?: Record<string, unknown> }[];
134 expect(plainList.some((t) => t._meta?.["openai/outputTemplate"] !== undefined)).toBe(true);
135 expect(JSON.stringify(plainList)).toContain('"minimum":1');
136 });
137
125138 test("a conversation's agent is listed the reads and writes of the work, in one page within the ceiling", async () => {
126139 for (const u of [alice, bob]) {
127140 const { names, bytes, cursor } = await list(

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs