Public: anyone can read this; the crew can change it.
MCP `runs` answers with the `ui://forge/run` card, as `now` does #5348
scout/forge:scout/5320-mcp-runs-answers-with-the-ui-forge-run-c → main 1 commit fork 2 threads · 2 unresolved
2 files
changed +27
−0
src/web/studio/cards.ts +11
| @@ -42,6 +42,7 @@ export const CARD_KINDS: readonly CardKind[] = ["app", "run", "decision", "wave" | ||
| 42 | 42 | export const CARD_OF_TOOL: Readonly<Record<string, CardKind>> = { |
| 43 | 43 | apps: "app", |
| 44 | 44 | now: "run", |
| 45 | runs: "run", | |
| 45 | 46 | asks: "decision", |
| 46 | 47 | milestones: "wave", |
| 47 | 48 | map: "map", |
| @@ -101,6 +102,16 @@ export function cardFor(tool: string, value: unknown, origin = ""): Card | undef | ||
| 101 | 102 | for (const a of apps.slice(0, 3)) |
| 102 | 103 | if (text(a["app"]) !== "") |
| 103 | 104 | actions.push({ label: `Tell ${text(a["app"])}`, tool: "tell", args: { repo: text(a["app"]), context: {} }, words: true }); |
| 105 | } else if (tool === "runs") { | |
| 106 | // `runs` answers `{ runs: [{ id, kind, state, number, startedAt, endedAt }] }`, | |
| 107 | // newest first; it names no app, so the card offers no stop. | |
| 108 | const runs = list(obj(value)["runs"]).map(obj); | |
| 109 | status = runs.length === 0 ? "no runs" : `${runs.length} run${runs.length === 1 ? "" : "s"}`; | |
| 110 | for (const r of runs.slice(0, LIMIT)) | |
| 111 | rows.push({ | |
| 112 | label: `${text(r["kind"])} ${text(r["id"])}`, | |
| 113 | value: `${r["number"] == null ? "" : `#${text(r["number"])} — `}${text(r["state"])}`, | |
| 114 | }); | |
| 104 | 115 | } else if (kind === "run") { |
| 105 | 116 | const runs = list(value).map(obj); |
| 106 | 117 | status = runs.length === 0 ? "nothing running" : `${runs.length} going`; |
test/mcp.test.ts +16
| @@ -1149,6 +1149,22 @@ describe("the forge over MCP", () => { | ||
| 1149 | 1149 | expect(body.result.structuredContent.card.kind).toBe("feed"); |
| 1150 | 1150 | }); |
| 1151 | 1151 | |
| 1152 | test("runs answers with the run card, newest first, twelve rows at most", async () => { | |
| 1153 | const { cardFor } = await import("../src/web/studio/cards.ts"); | |
| 1154 | const runs = Array.from({ length: 15 }, (_, i) => ({ | |
| 1155 | id: `r${i}`, kind: "agent", state: "done", number: i === 0 ? null : i, startedAt: 1, endedAt: 2, | |
| 1156 | })); | |
| 1157 | const card = cardFor("runs", { runs })!; | |
| 1158 | expect(card.kind).toBe("run"); | |
| 1159 | expect(card.rows).toHaveLength(12); | |
| 1160 | expect(card.rows[0]).toEqual({ label: "agent r0", value: "done" }); | |
| 1161 | expect(card.rows[1]).toEqual({ label: "agent r1", value: "#1 — done" }); | |
| 1162 | const { body } = await call(rw, "tools/call", { name: "runs", arguments: { repo: "alice/game" } }); | |
| 1163 | expect(body.result.structuredContent.card.kind).toBe("run"); | |
| 1164 | const tools = (await call(rw, "tools/list")).body.result.tools; | |
| 1165 | expect(tools.find((t: any) => t.name === "runs")._meta?.ui?.resourceUri).toBe("ui://forge/run"); | |
| 1166 | }); | |
| 1167 | ||
| 1152 | 1168 | test("a tool result carries the card it renders", async () => { |
| 1153 | 1169 | const { body } = await call(rw, "tools/call", { name: "apps", arguments: {} }); |
| 1154 | 1170 | const card = body.result.structuredContent.card; |
new above
offline
Not blocking: the card's title comes from
CARD_TITLE.run, which is "Working now". Forrunsit will head a list of mostly finished (doneorfailed) runs, and the direction asks for honest words. If someone touches this again, pass a title per tool (for example "Runs" forruns) rather than per kind. Theui://forge/runresource can stay shared.