mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-25 16:14:26 +01:00
design(ui): show Antigravity swarm events in a task (inventory and stories) (#22803)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - A task can run Google's Antigravity CLI as a swarm: one coordinator and several helpers work in the task folder. > - Today the task shows the swarm only as a flat list of step titles, such as "Started helper writer-a". > - Antigravity's own Swarm UI shows a goal, threads, helpers with their state and current step, and a numbered message board. > - We did not know which of these facts Paperclip actually receives. We also did not know how the facts could look in a task. > - This pull request records what Paperclip receives, from real recorded runs. It also adds design-proposal stories that show three directions, built only from those facts. > - The benefit is a grounded design decision. The next step is clear: read the swarm's own files and fix one driver bug. ## Linked Issues or Issue Description Refs #22731 (the swarm driver). Refs #22733 (the `/swarm` command). **Subsystem affected** Task chat and run activity for the Antigravity CLI swarm turn (`packages/paperclip-runner/src/drivers/acpx/antigravity-swarm-*`). Storybook design proposals. **Problem or motivation** During a swarm, the user sees only short step titles. The user cannot see which helper does what, which helper is blocked, or how far the work is. Antigravity's own UI shows all of this. We did not know if Paperclip can get the same data. **Proposed solution** Record the evidence in `doc/plans/2026-11-24-antigravity-swarm-events.md`. The short answer is "partly": - Over ACP, Paperclip gets everything the coordinator does. This includes the swarm title, each helper's name and brief, a goal/task/thread plan, the coordinator's own messages, finish and stop, and one usage total. - Paperclip gets nothing that the helpers do over ACP. The results of `swarm status` and `read_board` are not forwarded. - The CLI writes the board, the roster and each helper's steps as structured JSON in its private `--gemini-dir`. Paperclip already owns that folder. Then show three directions in Storybook, built only from this data. Each element has a tag that tells where its data comes from. **Alternatives considered** - Show only the facts that come over ACP. With this choice, the task cannot show helper state, the current step or helper messages. - Ask the coordinator to post summaries. This costs tokens, and the summaries are still prose. - Wait for Google to expose more. The work graph, a Google review state and the narrator overview are not available today. The stories show them only in a variant with the label "Needs Google". **Additional context** The inventory found a driver bug. The coordinator writes its plan to `<state-dir>/antigravity-cli/brain/<session>/.system_generated/swarm/plan.json`, because its built-in `swarm_pane` skill tells it to. `antigravityOutsideChange` thinks that this is a write outside the task folder, so the driver stops the swarm. This happened in 3 of 7 recorded swarm turns. This PR does not fix it. The fix is to exempt that one folder, with a red/green test. ## What Changed - `doc/plans/2026-11-24-antigravity-swarm-events.md`: the inventory. It lists each element of the reference UI, where the data comes from (ACP update, tool input or file), samples, timing and risk. - `ui/storybook/fixtures/antigravity-swarm.sample.json`: redacted events from one real 4-helper swarm run (CLI 1.5.15, auto mode, isolated state folder). It holds the ACP updates and the swarm files. - `ui/storybook/support/design-proposals/swarm-activity/`: turns the fixture into a view model (helpers, state, current step, messages, progress, threads) and adds the state variants. It also holds presentational parts that reuse shipped primitives: the runner header, the activity group, the subagent tree, `StatusGlyph`, `Tabs`, `Badge` and `Button`. - `ui/storybook/stories/design-proposals/swarm-activity.stories.tsx` (`design-antigravity-swarm-activity`) adds 16 stories: - Compare directions. - Today: the step titles from the current driver. - Direction 1 · Inline helpers (running, helper blocked, finished). - Direction 2 · Swarm panel (overview, helpers, messages). - Direction 3 · Summary card (collapsed, expanded). - The states starting, running, helper blocked, stopping, stopped, failed, not available and finished. - A long swarm with 11 helpers and 25 messages. - Narrow width. - "Would need Google to expose". - No product code changes. Nothing is connected to live pages. ## Verification - `node scripts/storybook-catalog.mjs --check`: pass (371 files, 3480 stories). - `node --test scripts/storybook-catalog.test.mjs`: 13/13 pass. - `node scripts/check-token-gates.mjs`: all gates clean. - `cd ui && npx tsc -p tsconfig.json --noEmit`: 0 errors. - `pnpm build-storybook`: pass. A headless Playwright run opened each of the 16 stories in light and dark at 1440 px (390 px for the narrow story) and saved screenshots. No story scrolls horizontally. - Evidence for the inventory: 7 recorded swarm turns and 1 new real run, about 3 minutes and 180k coordinator tokens. ## Risks - Low risk. The change adds Storybook files and a doc only. - The design depends on files that the CLI does not document. A future reader must pin to the CLI version and use fixture tests. The doc tells this. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, in Claude Code with tool use (shell, file edit, headless browser). ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [ ] I have added or updated tests where applicable (stories only; no behavior to test) - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
94510d7b26
commit
9502a12252
7 files changed
+1988
No files matched your search
@@ -0,0 +1,58 @@
|
||||
# Antigravity swarm events: what Paperclip can show
|
||||
|
||||
Date: 2026-11-24. Evidence:
|
||||
|
||||
- Seven recorded swarm turns against `agy acp` 1.5.15, in auto, accept-edits and default modes, including a stop mid-run and a reload. One of them, a 4-helper run with a verifier and the CLI stall monitor, used an isolated `--gemini-dir` exactly like the driver. Its redacted events are the Storybook fixture `ui/storybook/fixtures/antigravity-swarm.sample.json`.
|
||||
- That run finished in 3 min. The coordinator turn totalled 179,931 tokens; the six helpers used about 123k input and 16k output tokens more. Google shows no price.
|
||||
- The CLI's built-in skills `native_swarm`, `swarm_pane`, `swarm_narrator` and `swarm_monitor` are unpacked under `<state-dir>/antigravity-cli/builtin/skills/`. They describe what Google's own Swarm UI is built from.
|
||||
- Stories: Storybook "Design proposals/Patterns/Antigravity swarm activity".
|
||||
|
||||
## Short answer
|
||||
|
||||
**Partly.** Over ACP Paperclip gets everything the **coordinator** does: the swarm title, each helper's name and brief, its own board posts, a goal/task/thread plan, its text and one usage total. Paperclip gets **nothing the helpers do**. The outputs of `swarm status` and `read_board` are never forwarded: `tool_call_update` arrives with `status: completed` and no `rawOutput` or `content`. All updates carry the one coordinator `sessionId`, and no `session/request_permission` ever arrives for a helper.
|
||||
|
||||
The data behind Google's reference UI does exist as **structured files** in the CLI's private `--gemini-dir`. Paperclip already creates and owns that directory per run.
|
||||
|
||||
| File | What it holds |
|
||||
| --- | --- |
|
||||
| `swarm/board.jsonl` | Every board post: seq, author, time, text, `kind: brief` |
|
||||
| `swarm/members.json` | The roster: role, `wake_mode` working/waiting, model, killed, read cursor |
|
||||
| `swarm/plan.json` | Goal, per-helper task, threads |
|
||||
| `<helper conversation>/logs/transcript.jsonl` | Each helper's tool calls with a `toolSummary`, plus per-step model and token counts |
|
||||
|
||||
So nearly the whole reference UI is **derivable** by reading these files. They are undocumented internal files, so a reader must be pinned to the CLI version and tested against fixtures.
|
||||
|
||||
**Bug found along the way (real, not fixed here).** The coordinator writes `<state-dir>/antigravity-cli/brain/<session>/.system_generated/swarm/plan.json` with `write_file`, because the `swarm_pane` skill tells it to. The shipped driver's `antigravityOutsideChange` treats that as an outside write and **halts the swarm**. This was confirmed by running `antigravityOutsideChange` from `antigravity-swarm-paths.ts` over the recorded run; it returns the `plan.json` path. This happened in 3 of 7 recorded swarm turns; the other coordinators did not load `swarm_pane`. No current driver code allows this path. Fix: exempt `<state-dir>/antigravity-cli/brain/<this session>/.system_generated/swarm/` and add a red/green test with this transcript.
|
||||
|
||||
## Inventory
|
||||
|
||||
Legend: **ACP** = AVAILABLE NOW over ACP (structured). **FILES** = DERIVABLE by reading the CLI's private state dir (structured JSON; risk: undocumented, can change with any CLI release). **TEXT** = DERIVABLE by parsing coordinator prose (fragile). **NO** = NOT AVAILABLE.
|
||||
|
||||
| Reference UI element | Class | Where exactly | Sample (redacted) | When |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| Goal | ACP | User request (Paperclip has it). `swarm{action:"title"}` → `tool_call_update.rawInput.title`. `plan.json` → `write_file` `rawInput.Content` (also a `diff` content block) with `goal.title` and `goal.line`. `session_info_update.title`. | `{"action":"title","title":"Static unit-converter page"}`; `"goal":{"title":"Build tiny static unit-converter web page","line":"Write HTML, CSS, JS, and README, then verify everything."}` | Title in the first ~70 s. Plan right after the adds. The plan is only written when the coordinator loads `swarm_pane` (3 of 7 runs). |
|
||||
| Member roster + brief | ACP | `tool_call`/`tool_call_update` `name:"swarm"`, `rawInput.action:"add"`, `name`, `brief`, `workspace`, optional `model`. | `{"action":"add","name":"logic-writer","brief":"You own convert.js in the current workspace folder ONLY…","workspace":"inherit"}` | Live, when each helper is added. |
|
||||
| Member role | ACP (verifier/monitor by name) / FILES | Name convention (`verifier`, `monitor`, `narrator`). `members.json` `role` is only `coordinator`/`worker`. `subagents/<id>.json` `role:"Swarm Worker (css-writer)"`. | `"role":"worker"` | Live. |
|
||||
| Per-helper task line | ACP when plan is written; else TEXT (first sentence of brief) | `plan.json` `tasks{name: text}` | `"logic-writer":"Write convert.js functions and wiring"` | After the adds. |
|
||||
| Threads / workstreams | ACP when plan is written | `plan.json` `threads[{id,title,goal,tasks[]}]`. No status or "Now" line: the skill says status comes from the board. | `{"id":"t-verify","title":"Verification and swarm health","tasks":["verifier","monitor"]}` | After the adds. Rewritten if work moves. |
|
||||
| Member state (working / waiting / killed) | FILES | `members.json` `wake_mode` (`working` while in a turn, `mentions` while asleep on the board), `killed`, `phase`. The coordinator's `swarm status` result has the same data but is **not forwarded** over ACP. | `"logic-writer":{"wake_mode":"working","killed":false}` | Whenever the file is rewritten (seen mid-run). Poll it. |
|
||||
| Member's current action | FILES (NO over ACP) | `<state-dir>/antigravity-cli/brain/<helper conversation>/.system_generated/logs/transcript.jsonl`: last `PLANNER_RESPONSE.tool_calls[]` (`name`, `args.toolSummary`, path args). | `run_command` · "Verify convert.js syntax, math, and DOM wiring"; `write_file` `<task-folder>/index.html` | Per step, live. Higher risk: the helper transcript format is internal. |
|
||||
| Board messages (#seq, author, text) | Coordinator's own: ACP. Helpers': FILES (NO over ACP). | ACP: `post_message` `rawInput.text`. The briefs are posted as `@name <brief>`, `kind:"brief"`. FILES: `board.jsonl` `{seq,agent,text,time,kind}`. `read_board{since:N}` / `swarm_wait{since:N}` inputs expose the board's head seq over ACP, but not the messages. | `{"seq":10,"agent":"logic-writer","text":"@verifier [done] convert.js created — defines … kmToMiles … celsiusToFahrenheit"}` | Live in the file. Over ACP only the seq cursor, when the coordinator polls. |
|
||||
| Task done / In review | FILES (board convention) | A `[done]` post addressed to `@verifier` means "in review". A verifier's `@coordinator [done]` means verified. `[stall]` comes from the monitor. The narrator's `view.json` (`state: review`) would be structured, but the narrator is not added under ACP: the coordinator reported `swarm_narrator` "is not available". | seq 7–10 `@verifier [done] …`, seq 11 `@coordinator [done] Verified all deliverables from #7-#10` | Live in the file. Helpers can misreport (one recorded run: `[done]` after a failed write), so Paperclip's own folder snapshot stays the source of truth for files. |
|
||||
| Progress ("x of y done · n in review · threads open") | FILES | Computed from `plan.json` tasks/threads + `board.jsonl` `[done]` posts. | 4 of 4 writers in review at seq 10, verified at seq 11 | Live. |
|
||||
| Helper blocked by the workspace boundary | TEXT (+ FILES) | Not forwarded as a permission request: a helper's prompt times out after 60 s inside the CLI. It reaches Paperclip only as coordinator prose ("permission prompts timed out after 60s waiting for user approval"; this does **not** match the driver's `BLOCKED_TEXT` regex) or in the helper transcript and board. | Helper error: `permission check failed for write_file "<outside>/c.txt" … timed out waiting for user response after 60s` | After a 60 s delay. |
|
||||
| Verifier result | FILES / TEXT | The verifier's `[done]` post in `board.jsonl`, or the coordinator's final prose. | seq 11 above | Live. |
|
||||
| Finished | ACP | `session/prompt` result `stopReason:"end_turn"`. The coordinator's `post_message "[done] …"`. In the recorded run, the coordinator was woken inside the **same** prompt; the turn closed 9 s after the verifier's post. | `"[done] Static unit-converter page built and verified (…)"` | End of turn. Helpers stay alive (`SUBAGENT_STATE_ALIVE`, waiting). |
|
||||
| Stopped (Stop) | ACP | `session/cancel` → prompt result `stopReason:"cancelled"` with usage (the recorded stop). | `{"stopReason":"cancelled","usage":{"totalTokens":29718,…}}` | Immediately (7 ms). |
|
||||
| Per-member model | FILES | `members.json` `applied_model`/`desired_model`; helper transcript `model`. Not over ACP unless `add` passed `model`. | `"applied_model":"gemini-4-neon-high"` | Live. |
|
||||
| Usage | ACP (one total) / FILES (per helper) | ACP: `usage_update {used,size}` (coordinator context only) and prompt result `usage` (coordinator total). FILES: helper transcripts carry `input_tokens`/`output_tokens`/`cache_read_tokens` per step, so per-helper usage is derivable. The driver's note "Google does not report it per helper" is true only of ACP. | prompt `usage.totalTokens:179931`; verifier steps sum to 34,265 input / 4,017 output | End of turn (ACP); per step (files). |
|
||||
| Graph / dependencies | NO (partial FILES) | No dependency graph exists. Only thread grouping (plan) and who-mentions-whom edges from `@name` in `board.jsonl` exist. | — | — |
|
||||
| Screenshot timeline / reel | NO in practice | `swarm_pane` asks helpers to post `Screenshot: <path> \| caption` for visual work. Not seen in any run. | — | — |
|
||||
| Narrator Overview (`view.json`: headline, attention, workstreams with state, `now` per member) | NO under ACP | The narrator is only added when `swarm_narrator` is in the coordinator's skill list, and it was not in any ACP run. If Google enabled it, `<state-dir>/brain/<narrator>/swarm_view/view.json` would be the closest match to the reference UI. | — | — |
|
||||
| `available_commands` | ACP | `available_commands_update` lists `swarm` ("(Preview & Quota Heavy) Run a swarm…") with goal, compact, schedule and others. Useful to detect "swarm not available here". | — | Session start. |
|
||||
|
||||
## Practical routes, best first
|
||||
|
||||
1. **Read the state-dir files (FILES).** Add a driver-owned watcher on `<state-dir>/antigravity-cli/brain/<session>/.system_generated/swarm/{plan.json,members.json,board.jsonl}`, plus the helpers' `logs/transcript.jsonl` for "current action". Emit normalized Paperclip run events: helper added/state/action, board post, plan. Pin the parser to CLI 1.5.15 fixtures, and fall back to today's ACP-only steps when a file is missing or unparseable. Never read anything else in the dir; it also holds credentials.
|
||||
2. **ACP-only (today plus plan).** Roster, briefs, plan/threads, coordinator posts, board seq cursor, finish/stop and usage total. No helper state or actions.
|
||||
3. **Ask the coordinator.** Prompting it to `read_board` does not help, because the result is not forwarded. It could be told to `post_message` summaries, but that costs tokens and is still prose.
|
||||
@@ -0,0 +1,752 @@
|
||||
{
|
||||
"about": "Representative real events from one Antigravity CLI 1.5.15 swarm turn (agy acp, session mode auto, isolated --gemini-dir), 2026-11-24. Paths are redacted to <task-folder>/<state-dir>; account tier redacted. acp: what Paperclip receives over ACP (coordinator session only). files: what the CLI writes under its private --gemini-dir for the same swarm (Paperclip owns that directory).",
|
||||
"request": "Build a tiny static unit-converter page in the current folder (four named helpers + a verifier).",
|
||||
"run": {
|
||||
"model": "Gemini 4 Neon",
|
||||
"filesChanged": [
|
||||
"README.md",
|
||||
"convert.js",
|
||||
"index.html",
|
||||
"style.css"
|
||||
]
|
||||
},
|
||||
"acp": [
|
||||
{
|
||||
"at": "2026-11-24T18:12:30.299Z",
|
||||
"kind": "current_mode_update",
|
||||
"currentModeId": "auto"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:12:30.329Z",
|
||||
"kind": "available_commands_update",
|
||||
"swarmCommand": {
|
||||
"name": "swarm",
|
||||
"description": "(Preview & Quota Heavy) Run a swarm: several agents working in parallel on one task, each in its own conversation, collaborating through a shared message board. Use when the work splits into pieces that can be done at the same time, or when a second pair of eyes should check the first pair's work."
|
||||
}
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:12:30.330Z",
|
||||
"kind": "usage_update",
|
||||
"used": 0,
|
||||
"size": 1048576
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:12:35.325Z",
|
||||
"kind": "session_info_update",
|
||||
"title": "Static Unit-Converter Page Swarm"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:12:41.870Z",
|
||||
"kind": "usage_update",
|
||||
"used": 10992,
|
||||
"size": 1048576
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:12:42.031Z",
|
||||
"kind": "tool_call_update",
|
||||
"name": "read_file",
|
||||
"status": "completed",
|
||||
"toolKind": "read",
|
||||
"title": "File ../gdir/antigravity-cli/builtin/skills/native_swarm/SKILL.md",
|
||||
"rawInput": {
|
||||
"Path": "<state-dir>/antigravity-cli/builtin/skills/native_swarm/SKILL.md"
|
||||
},
|
||||
"hasRawOutput": false,
|
||||
"hasContent": false
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:12:42.129Z",
|
||||
"kind": "tool_call_update",
|
||||
"name": "read_file",
|
||||
"status": "completed",
|
||||
"toolKind": "read",
|
||||
"title": "File ../gdir/antigravity-cli/builtin/skills/swarm_pane/SKILL.md",
|
||||
"rawInput": {
|
||||
"Path": "<state-dir>/antigravity-cli/builtin/skills/swarm_pane/SKILL.md"
|
||||
},
|
||||
"hasRawOutput": false,
|
||||
"hasContent": false
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:12:42.880Z",
|
||||
"kind": "tool_call_update",
|
||||
"name": "run_command",
|
||||
"status": "completed",
|
||||
"toolKind": "execute",
|
||||
"title": "ls -la",
|
||||
"rawInput": {
|
||||
"CommandLine": "ls -la",
|
||||
"WaitMsBeforeAsync": 5000,
|
||||
"toolSummary": "List current workspace files"
|
||||
},
|
||||
"hasRawOutput": true,
|
||||
"hasContent": true
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:13:38.175Z",
|
||||
"kind": "usage_update",
|
||||
"used": 24253,
|
||||
"size": 1048576
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:13:39.302Z",
|
||||
"kind": "tool_call_update",
|
||||
"name": "swarm",
|
||||
"status": "completed",
|
||||
"toolKind": "other",
|
||||
"title": "Run swarm",
|
||||
"rawInput": {
|
||||
"action": "title",
|
||||
"title": "Static unit-converter page"
|
||||
},
|
||||
"hasRawOutput": false,
|
||||
"hasContent": false
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:13:40.773Z",
|
||||
"kind": "tool_call_update",
|
||||
"name": "swarm",
|
||||
"status": "completed",
|
||||
"toolKind": "other",
|
||||
"title": "Run swarm",
|
||||
"rawInput": {
|
||||
"action": "add",
|
||||
"brief": "You own index.html in the current workspace folder ONLY. Do not create or modify any other file or anything outside the current folder.\n\nWrite index.html for a tiny static unit-converter page with:\n- Standard HTML5 document, <title>Unit Converter</title>\n- <link rel=\"stylesheet\" href=\"style.css\"> in <head>\n- <script src=\"convert.js\" defer></script>\n- <main …",
|
||||
"name": "html-writer",
|
||||
"workspace": "inherit"
|
||||
},
|
||||
"hasRawOutput": false,
|
||||
"hasContent": false
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:13:41.985Z",
|
||||
"kind": "tool_call_update",
|
||||
"name": "swarm",
|
||||
"status": "completed",
|
||||
"toolKind": "other",
|
||||
"title": "Run swarm",
|
||||
"rawInput": {
|
||||
"action": "add",
|
||||
"brief": "You own style.css in the current workspace folder ONLY. Do not create or modify any other file or anything outside the current folder.\n\nWrite style.css providing a simple, clean, readable layout for the static unit-converter page. Style standard elements and these shared hooks from index.html:\n- body (system font stack, soft neutral background, centered lay…",
|
||||
"name": "css-writer",
|
||||
"workspace": "inherit"
|
||||
},
|
||||
"hasRawOutput": false,
|
||||
"hasContent": false
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:13:43.482Z",
|
||||
"kind": "tool_call_update",
|
||||
"name": "swarm",
|
||||
"status": "completed",
|
||||
"toolKind": "other",
|
||||
"title": "Run swarm",
|
||||
"rawInput": {
|
||||
"action": "add",
|
||||
"brief": "You own convert.js in the current workspace folder ONLY. Do not create or modify any other file or anything outside the current folder.\n\nWrite convert.js for the static unit-converter page:\n1. Define two top-level named functions:\n - function kmToMiles(km) — returns km * 0.621371\n - function celsiusToFahrenheit(celsius) — returns (celsius * 9) / 5 + 32\n…",
|
||||
"name": "logic-writer",
|
||||
"workspace": "inherit"
|
||||
},
|
||||
"hasRawOutput": false,
|
||||
"hasContent": false
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:13:44.958Z",
|
||||
"kind": "tool_call_update",
|
||||
"name": "swarm",
|
||||
"status": "completed",
|
||||
"toolKind": "other",
|
||||
"title": "Run swarm",
|
||||
"rawInput": {
|
||||
"action": "add",
|
||||
"brief": "You own README.md in the current workspace folder ONLY. Do not create or modify any other file or anything outside the current folder.\n\nWrite a concise README.md for the static unit-converter page in the current folder:\n- Briefly describe what the page does (converts kilometers to miles and Celsius to Fahrenheit)\n- List the files (index.html, style.css, con…",
|
||||
"name": "docs-writer",
|
||||
"workspace": "inherit"
|
||||
},
|
||||
"hasRawOutput": false,
|
||||
"hasContent": false
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:13:47.086Z",
|
||||
"kind": "tool_call_update",
|
||||
"name": "swarm",
|
||||
"status": "completed",
|
||||
"toolKind": "other",
|
||||
"title": "Run swarm",
|
||||
"rawInput": {
|
||||
"action": "add",
|
||||
"brief": "You are the verifier for the static unit-converter page in the current workspace folder. Do NOT edit or create any files yourself; if something is wrong, ask the owning helper (@html-writer for index.html, @css-writer for style.css, @logic-writer for convert.js, @docs-writer for README.md) to fix it.\n\nYour job:\n1. Wait until all four helpers (html-writer, c…",
|
||||
"name": "verifier",
|
||||
"workspace": "inherit"
|
||||
},
|
||||
"hasRawOutput": false,
|
||||
"hasContent": false
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:13:48.942Z",
|
||||
"kind": "tool_call_update",
|
||||
"name": "swarm",
|
||||
"status": "completed",
|
||||
"toolKind": "other",
|
||||
"title": "Run swarm",
|
||||
"rawInput": {
|
||||
"action": "add",
|
||||
"brief": "You are this swarm's stall monitor. Load the swarm_monitor skill and follow it. Post only to break a stall.",
|
||||
"name": "monitor",
|
||||
"workspace": "inherit"
|
||||
},
|
||||
"hasRawOutput": false,
|
||||
"hasContent": false
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:13:59.772Z",
|
||||
"kind": "usage_update",
|
||||
"used": 26988,
|
||||
"size": 1048576
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:14:01.270Z",
|
||||
"kind": "tool_call_update",
|
||||
"name": "write_file",
|
||||
"status": "completed",
|
||||
"toolKind": "edit",
|
||||
"title": "File ../gdir/antigravity-cli/brain/9c3e4522-32a6-436f-94dd-427b32a6d896/.system_generated/swarm/plan.json",
|
||||
"rawInput": {
|
||||
"Content": "{\n \"goal\": {\n \"title\": \"Build tiny static unit-converter web page\",\n \"line\": \"Write HTML, CSS, JS, and README, then verify everything.\"\n },\n \"tasks\": {\n \"html-writer\": \"Write index.html with converter form\",\n \"css-writer\": \"Write style.css with readable layout\",\n \"logic-writer\": \"Write convert.js functions and wiring\",\n \"docs-writer\": \"Write README.md usage guide\",\n \"verifier\": \"Verify files, links, and JS logic\",\n \"monitor\": \"Watch swarm for stalls\"\n },\n \"threads\": [\n {\n \"id\": \"t-page\",\n \"title\": \"Unit-converter page files\",\n \"goal\": \"Create index.html, style.css, convert.js, and README.md in the workspace.\",\n \"tasks\": [\"html-writer\", \"css-writer\", \"logic-writer\", \"docs-writer\"]\n },\n {\n \"id\": \"t-verify\",\n \"title\": \"Verification and swarm health\",\n \"goal\": \"Confirm all files, references, and conversion functions work cleanly.\",\n \"tasks\": [\"verifier\", \"monitor\"]\n }\n ]\n}\n",
|
||||
"Overwrite": true,
|
||||
"Path": "<state-dir>/antigravity-cli/brain/9c3e4522-32a6-436f-94dd-427b32a6d896/.system_generated/swarm/plan.json"
|
||||
},
|
||||
"hasRawOutput": false,
|
||||
"hasContent": true
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:14:07.853Z",
|
||||
"kind": "agent_message",
|
||||
"text": "Swarm started for the static unit-converter page with all helpers running in `inherit` workspace mode:\n\n- **html-writer**: writing `index.html` (form with two inputs, `km-to-miles` / `celsius-to-fahrenheit` select, linking `style.css` and `convert.js`)\n- **css-writer**: writing `style.css` (simple readable layout)\n- **logic-writer**: writing `convert.js` (`kmToMiles`, `celsiusToFahrenheit`, and form wiring)\n- **docs-writer**: writing `README.md` (instructions on how to open the page)\n- **verifier**: waiting for all four helpers, checking every file/reference/function, requesting fixes from owners if needed, and reporting back once all checks pass\n- **monitor**: watching for stalls\n\nI'll report back as soon as `verifier` finishes.\n\nRun /swarm board (default shortcut alt+s) to open the live board."
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:14:07.853Z",
|
||||
"kind": "usage_update",
|
||||
"used": 27367,
|
||||
"size": 1048576
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:15:12.297Z",
|
||||
"kind": "usage_update",
|
||||
"used": 28277,
|
||||
"size": 1048576
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:15:12.324Z",
|
||||
"kind": "tool_call_update",
|
||||
"name": "read_board",
|
||||
"status": "completed",
|
||||
"toolKind": "other",
|
||||
"title": "Run read_board",
|
||||
"rawInput": {
|
||||
"since": 6
|
||||
},
|
||||
"hasRawOutput": false,
|
||||
"hasContent": false
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:15:13.151Z",
|
||||
"kind": "tool_call_update",
|
||||
"name": "swarm",
|
||||
"status": "completed",
|
||||
"toolKind": "other",
|
||||
"title": "Run swarm",
|
||||
"rawInput": {
|
||||
"action": "status"
|
||||
},
|
||||
"hasRawOutput": false,
|
||||
"hasContent": false
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:15:20.193Z",
|
||||
"kind": "usage_update",
|
||||
"used": 30535,
|
||||
"size": 1048576
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:15:21.202Z",
|
||||
"kind": "tool_call_update",
|
||||
"name": "post_message",
|
||||
"status": "completed",
|
||||
"toolKind": "other",
|
||||
"title": "Run post_message",
|
||||
"rawInput": {
|
||||
"text": "[done] Static unit-converter page built and verified (index.html, style.css, convert.js, README.md)."
|
||||
},
|
||||
"hasRawOutput": false,
|
||||
"hasContent": false
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:15:30.708Z",
|
||||
"kind": "agent_message",
|
||||
"text": "\n\nThe static unit-converter page is built and verified by the swarm.\n\n### Files Created\n- [index.html](file://<task-folder>/index.html) (`html-writer`) — HTML5 page linking `style.css` and `convert.js`, containing `#converter-form` with two inputs (`#input-value`, readonly `#output-value`) and a `#conversion-type` select (`km-to-miles`, `celsius-to-fahrenheit`).\n- [style.css](file://<task-folder>/style.css) (`css-writer`) — Simple, readable centered card layout styling `body`, `.converter-card`, `#converter-form`, inputs, select, labels, and submit button.\n- [convert.js](file://<task-folder>/convert.js) (`logic-writer`) — Defines `kmToMiles(km)` and `celsiusToFahrenheit(celsius)` and wires `#converter-form` for live updates, conversion-type switching (including label updates), submit handling, and empty/invalid input clearing.\n- [README.md](file://<task-folder>/README.md) (`docs-writer`…"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:15:30.708Z",
|
||||
"kind": "usage_update",
|
||||
"used": 31519,
|
||||
"size": 1048576
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:15:30.728Z",
|
||||
"kind": "prompt_result",
|
||||
"result": {
|
||||
"stopReason": "end_turn",
|
||||
"usage": {
|
||||
"inputTokens": 62507,
|
||||
"outputTokens": 8357,
|
||||
"cachedReadTokens": 109067,
|
||||
"cachedWriteTokens": 0,
|
||||
"thoughtTokens": 5021,
|
||||
"totalTokens": 179931
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"files": {
|
||||
"swarm": {
|
||||
"version": 1,
|
||||
"backend": "local",
|
||||
"swarm_id": "9c3e4522-32a6-436f-94dd-427b32a6d896",
|
||||
"created_at": "2026-11-24T18:13:39Z"
|
||||
},
|
||||
"plan": {
|
||||
"goal": {
|
||||
"title": "Build tiny static unit-converter web page",
|
||||
"line": "Write HTML, CSS, JS, and README, then verify everything."
|
||||
},
|
||||
"tasks": {
|
||||
"html-writer": "Write index.html with converter form",
|
||||
"css-writer": "Write style.css with readable layout",
|
||||
"logic-writer": "Write convert.js functions and wiring",
|
||||
"docs-writer": "Write README.md usage guide",
|
||||
"verifier": "Verify files, links, and JS logic",
|
||||
"monitor": "Watch swarm for stalls"
|
||||
},
|
||||
"threads": [
|
||||
{
|
||||
"id": "t-page",
|
||||
"title": "Unit-converter page files",
|
||||
"goal": "Create index.html, style.css, convert.js, and README.md in the workspace.",
|
||||
"tasks": [
|
||||
"html-writer",
|
||||
"css-writer",
|
||||
"logic-writer",
|
||||
"docs-writer"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "t-verify",
|
||||
"title": "Verification and swarm health",
|
||||
"goal": "Confirm all files, references, and conversion functions work cleanly.",
|
||||
"tasks": [
|
||||
"verifier",
|
||||
"monitor"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"members": {
|
||||
"title": "Static unit-converter page",
|
||||
"members": {
|
||||
"coordinator": {
|
||||
"role": "coordinator",
|
||||
"phase": "RUNNING",
|
||||
"wake_mode": "mentions",
|
||||
"model": "gemini-4-neon-high",
|
||||
"workspace_mode": "inherit",
|
||||
"killed": false,
|
||||
"last_read_seq": 12
|
||||
},
|
||||
"css-writer": {
|
||||
"role": "worker",
|
||||
"phase": "RUNNING",
|
||||
"wake_mode": "mentions",
|
||||
"model": "gemini-4-neon-high",
|
||||
"workspace_mode": "inherit",
|
||||
"killed": false,
|
||||
"last_read_seq": 6
|
||||
},
|
||||
"docs-writer": {
|
||||
"role": "worker",
|
||||
"phase": "RUNNING",
|
||||
"wake_mode": "mentions",
|
||||
"model": "gemini-4-neon-high",
|
||||
"workspace_mode": "inherit",
|
||||
"killed": false,
|
||||
"last_read_seq": 7
|
||||
},
|
||||
"html-writer": {
|
||||
"role": "worker",
|
||||
"phase": "RUNNING",
|
||||
"wake_mode": "mentions",
|
||||
"model": "gemini-4-neon-high",
|
||||
"workspace_mode": "inherit",
|
||||
"killed": false,
|
||||
"last_read_seq": 6
|
||||
},
|
||||
"logic-writer": {
|
||||
"role": "worker",
|
||||
"phase": "RUNNING",
|
||||
"wake_mode": "mentions",
|
||||
"model": "gemini-4-neon-high",
|
||||
"workspace_mode": "inherit",
|
||||
"killed": false,
|
||||
"last_read_seq": 6
|
||||
},
|
||||
"monitor": {
|
||||
"role": "worker",
|
||||
"phase": "RUNNING",
|
||||
"wake_mode": "mentions",
|
||||
"model": "gemini-4-neon-high",
|
||||
"workspace_mode": "inherit",
|
||||
"killed": false,
|
||||
"last_read_seq": 6
|
||||
},
|
||||
"verifier": {
|
||||
"role": "worker",
|
||||
"phase": "RUNNING",
|
||||
"wake_mode": "mentions",
|
||||
"model": "gemini-4-neon-high",
|
||||
"workspace_mode": "inherit",
|
||||
"killed": false,
|
||||
"last_read_seq": 11
|
||||
}
|
||||
}
|
||||
},
|
||||
"board": [
|
||||
{
|
||||
"seq": 1,
|
||||
"agent": "coordinator",
|
||||
"text": "@html-writer You own index.html in the current workspace folder ONLY. Do not create or modify any other file or anything outside the current folder.\n\nWrite index.html for a tiny static unit-converter page with:\n- Standard HTML5 document, <title>Unit Converter</title>\n- <link rel=\"stylesheet\" href=\"style.css\"> in <head>\n- <script src=\"convert.js\" defer></script>\n- <main class=\"converter-card\"> with <h1>Unit Converter…",
|
||||
"time": "2026-11-24T18:13:40.000Z",
|
||||
"kind": "brief"
|
||||
},
|
||||
{
|
||||
"seq": 2,
|
||||
"agent": "coordinator",
|
||||
"text": "@css-writer You own style.css in the current workspace folder ONLY. Do not create or modify any other file or anything outside the current folder.\n\nWrite style.css providing a simple, clean, readable layout for the static unit-converter page. Style standard elements and these shared hooks from index.html:\n- body (system font stack, soft neutral background, centered layout, comfortable padding)\n- .converter-card (max…",
|
||||
"time": "2026-11-24T18:13:41.000Z",
|
||||
"kind": "brief"
|
||||
},
|
||||
{
|
||||
"seq": 3,
|
||||
"agent": "coordinator",
|
||||
"text": "@logic-writer You own convert.js in the current workspace folder ONLY. Do not create or modify any other file or anything outside the current folder.\n\nWrite convert.js for the static unit-converter page:\n1. Define two top-level named functions:\n - function kmToMiles(km) — returns km * 0.621371\n - function celsiusToFahrenheit(celsius) — returns (celsius * 9) / 5 + 32\n2. Wire the form in index.html using these IDs…",
|
||||
"time": "2026-11-24T18:13:43.000Z",
|
||||
"kind": "brief"
|
||||
},
|
||||
{
|
||||
"seq": 4,
|
||||
"agent": "coordinator",
|
||||
"text": "@docs-writer You own README.md in the current workspace folder ONLY. Do not create or modify any other file or anything outside the current folder.\n\nWrite a concise README.md for the static unit-converter page in the current folder:\n- Briefly describe what the page does (converts kilometers to miles and Celsius to Fahrenheit)\n- List the files (index.html, style.css, convert.js)\n- Clearly explain how to open the page…",
|
||||
"time": "2026-11-24T18:13:44.000Z",
|
||||
"kind": "brief"
|
||||
},
|
||||
{
|
||||
"seq": 5,
|
||||
"agent": "coordinator",
|
||||
"text": "@verifier You are the verifier for the static unit-converter page in the current workspace folder. Do NOT edit or create any files yourself; if something is wrong, ask the owning helper (@html-writer for index.html, @css-writer for style.css, @logic-writer for convert.js, @docs-writer for README.md) to fix it.\n\nYour job:\n1. Wait until all four helpers (html-writer, css-writer, logic-writer, docs-writer) have posted …",
|
||||
"time": "2026-11-24T18:13:46.000Z",
|
||||
"kind": "brief"
|
||||
},
|
||||
{
|
||||
"seq": 6,
|
||||
"agent": "coordinator",
|
||||
"text": "@monitor You are this swarm's stall monitor. Load the swarm_monitor skill and follow it. Post only to break a stall.",
|
||||
"time": "2026-11-24T18:13:48.000Z",
|
||||
"kind": "brief"
|
||||
},
|
||||
{
|
||||
"seq": 7,
|
||||
"agent": "docs-writer",
|
||||
"text": "@verifier [done] README.md created: describes the km-to-miles and Celsius-to-Fahrenheit converter, lists index.html, style.css, and convert.js, and explains how to open index.html directly or serve it via a local static HTTP server.",
|
||||
"time": "2026-11-24T18:14:07.000Z"
|
||||
},
|
||||
{
|
||||
"seq": 8,
|
||||
"agent": "html-writer",
|
||||
"text": "@verifier [done] index.html created with HTML5 structure, style.css and convert.js links, main.converter-card, h1, and #converter-form (#conversion-type select for km-to-miles and celsius-to-fahrenheit, #input-label/#input-value, #output-label/#output-value readonly, and submit button).",
|
||||
"time": "2026-11-24T18:14:12.000Z"
|
||||
},
|
||||
{
|
||||
"seq": 9,
|
||||
"agent": "css-writer",
|
||||
"text": "@verifier [done] style.css created with a centered system-font layout on body, a max-width .converter-card with subtle border/shadow, a vertical #converter-form stack, full-width inputs/select/labels with focus rings, a muted readonly output field, and a primary submit button.",
|
||||
"time": "2026-11-24T18:14:22.000Z"
|
||||
},
|
||||
{
|
||||
"seq": 10,
|
||||
"agent": "logic-writer",
|
||||
"text": "@verifier [done] convert.js created — defines top-level `kmToMiles(km)` and `celsiusToFahrenheit(celsius)`, wires `#converter-form` (submit with `preventDefault`), `#conversion-type` (`km-to-miles` / `celsius-to-fahrenheit`), `#input-value` (live `input` updates), `#output-value` (clears on empty/NaN), and `#input-label`/`#output-label` updates, with `typeof document !== 'undefined'` guard. Verified syntax, math, an…",
|
||||
"time": "2026-11-24T18:14:27.000Z"
|
||||
},
|
||||
{
|
||||
"seq": 11,
|
||||
"agent": "verifier",
|
||||
"text": "@coordinator [done] Verified all deliverables from #7-#10:\n- Files: workspace contains only `index.html`, `style.css`, `convert.js`, and `README.md` (no stray files).\n- `index.html`: valid HTML5 with `<link rel=\"stylesheet\" href=\"style.css\">`, `<script src=\"convert.js\" defer>`, `.converter-card`, `#converter-form`, `#conversion-type` (`km-to-miles`, `celsius-to-fahrenheit`), `#input-value`, readonly `#output-value`,…",
|
||||
"time": "2026-11-24T18:15:08.000Z"
|
||||
},
|
||||
{
|
||||
"seq": 12,
|
||||
"agent": "coordinator",
|
||||
"text": "[done] Static unit-converter page built and verified (index.html, style.css, convert.js, README.md).",
|
||||
"time": "2026-11-24T18:15:21.000Z"
|
||||
}
|
||||
],
|
||||
"workers": {
|
||||
"css-writer": {
|
||||
"model": "gemini-4-neon-high",
|
||||
"steps": 10,
|
||||
"tokens": {
|
||||
"input": 17269,
|
||||
"output": 3505,
|
||||
"cachedRead": 26293
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"at": "2026-11-24T18:13:42Z",
|
||||
"tool": "read_board"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:13:42Z",
|
||||
"tool": "read_file",
|
||||
"target": "<task-folder>/index.html"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:13:50Z",
|
||||
"tool": "write_file",
|
||||
"target": "<task-folder>/style.css"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:14:15Z",
|
||||
"tool": "post_message"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:14:15Z",
|
||||
"tool": "swarm_wait"
|
||||
}
|
||||
]
|
||||
},
|
||||
"docs-writer": {
|
||||
"model": "gemini-4-neon-high",
|
||||
"steps": 10,
|
||||
"tokens": {
|
||||
"input": 17058,
|
||||
"output": 955,
|
||||
"cachedRead": 23984
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"at": "2026-11-24T18:13:45Z",
|
||||
"tool": "read_board"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:13:45Z",
|
||||
"tool": "run_command",
|
||||
"summary": "List workspace files",
|
||||
"target": "ls -la"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:13:50Z",
|
||||
"tool": "write_file",
|
||||
"target": "<task-folder>/README.md"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:13:59Z",
|
||||
"tool": "post_message"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:13:59Z",
|
||||
"tool": "swarm_wait"
|
||||
}
|
||||
]
|
||||
},
|
||||
"html-writer": {
|
||||
"model": "gemini-4-neon-high",
|
||||
"steps": 10,
|
||||
"tokens": {
|
||||
"input": 18319,
|
||||
"output": 2550,
|
||||
"cachedRead": 24590
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"at": "2026-11-24T18:13:41Z",
|
||||
"tool": "read_board"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:13:48Z",
|
||||
"tool": "write_file",
|
||||
"target": "<task-folder>/index.html"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:14:03Z",
|
||||
"tool": "post_message"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:14:03Z",
|
||||
"tool": "swarm_wait"
|
||||
}
|
||||
]
|
||||
},
|
||||
"logic-writer": {
|
||||
"model": "gemini-4-neon-high",
|
||||
"steps": 13,
|
||||
"tokens": {
|
||||
"input": 19132,
|
||||
"output": 3925,
|
||||
"cachedRead": 42959
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"at": "2026-11-24T18:13:43Z",
|
||||
"tool": "read_board"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:13:43Z",
|
||||
"tool": "run_command",
|
||||
"summary": "List workspace files",
|
||||
"target": "ls -la"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:13:50Z",
|
||||
"tool": "write_file",
|
||||
"target": "<task-folder>/convert.js"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:14:10Z",
|
||||
"tool": "run_command",
|
||||
"summary": "Verify convert.js syntax, math, and DOM wiring",
|
||||
"target": "node --check convert.js && node -e \\\"\\nconst assert = require('assert');\\nconst…"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:14:21Z",
|
||||
"tool": "post_message"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:14:21Z",
|
||||
"tool": "swarm_wait"
|
||||
}
|
||||
]
|
||||
},
|
||||
"monitor": {
|
||||
"model": "gemini-4-neon-high",
|
||||
"steps": 9,
|
||||
"tokens": {
|
||||
"input": 16770,
|
||||
"output": 832,
|
||||
"cachedRead": 25772
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"at": "2026-11-24T18:13:49Z",
|
||||
"tool": "read_file",
|
||||
"target": "<state-dir>/antigravity-cli/builtin/skills/swarm_monitor/SKILL.md"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:13:54Z",
|
||||
"tool": "read_board"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:13:54Z",
|
||||
"tool": "schedule"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:14:00Z",
|
||||
"tool": "swarm_wait"
|
||||
}
|
||||
]
|
||||
},
|
||||
"verifier": {
|
||||
"model": "gemini-4-neon-high",
|
||||
"steps": 35,
|
||||
"tokens": {
|
||||
"input": 34265,
|
||||
"output": 4017,
|
||||
"cachedRead": 115496
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"at": "2026-11-24T18:13:47Z",
|
||||
"tool": "read_board"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:13:51Z",
|
||||
"tool": "swarm_wait"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:14:07Z",
|
||||
"tool": "read_board"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:14:15Z",
|
||||
"tool": "swarm_wait"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:14:23Z",
|
||||
"tool": "read_board"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:14:25Z",
|
||||
"tool": "swarm_wait"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:14:30Z",
|
||||
"tool": "read_board"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:14:30Z",
|
||||
"tool": "read_file",
|
||||
"target": "<task-folder>/index.html"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:14:30Z",
|
||||
"tool": "read_file",
|
||||
"target": "<task-folder>/style.css"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:14:30Z",
|
||||
"tool": "read_file",
|
||||
"target": "<task-folder>/convert.js"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:14:30Z",
|
||||
"tool": "read_file",
|
||||
"target": "<task-folder>/README.md"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:14:30Z",
|
||||
"tool": "run_command",
|
||||
"summary": "Workspace listing and JS verification",
|
||||
"target": "ls -la && node --check convert.js && node -e '\\nconst fs = require(\\\"fs\\\");\\nco…"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:14:42Z",
|
||||
"tool": "run_command",
|
||||
"summary": "Mock DOM and module verification",
|
||||
"target": "node -e '\\nconst fs = require(\\\"fs\\\");\\nconst vm = require(\\\"vm\\\");\\nconst asse…"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:14:58Z",
|
||||
"tool": "post_message"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-24T18:14:58Z",
|
||||
"tool": "swarm_wait"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"recordedBlock": {
|
||||
"source": "Wording of a helper permission failure recorded in an earlier run of the same CLI version (a write outside the task folder). The helper name and path are adapted to this run; this run itself had no block.",
|
||||
"helper": "logic-writer",
|
||||
"text": "@coordinator [blocked] permission check failed for write_file \"../shared/units.json\": Permission prompt for action write_file timed out waiting for user response after 60s; the user did not respond, which is not an explicit denial."
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
import type { ReactNode } from "react";
|
||||
import type { Meta, StoryObj } from "@storybook/react-vite";
|
||||
import { TaskChatRunnerActivityGroup } from "@/components/task-chat/TaskChatRunnerActivityGroup";
|
||||
import type { TaskChatActivityPhaseItem } from "@/components/task-chat/task-chat-model";
|
||||
import {
|
||||
GoogleOnlyExtras,
|
||||
InlineDirection,
|
||||
SidePanel,
|
||||
SourceLegend,
|
||||
SummaryCard,
|
||||
SwarmTurn,
|
||||
} from "../../support/design-proposals/swarm-activity/SwarmViews";
|
||||
import type { SwarmView } from "../../support/design-proposals/swarm-activity/swarm-model";
|
||||
import {
|
||||
TODAY_STEPS,
|
||||
completed,
|
||||
failed,
|
||||
longSwarm,
|
||||
refused,
|
||||
running,
|
||||
runningWithBlocked,
|
||||
starting,
|
||||
stopped,
|
||||
stopping,
|
||||
} from "../../support/design-proposals/swarm-activity/swarm-variants";
|
||||
|
||||
function Thread({ request, children, narrow, wide }: { request: string; children: ReactNode; narrow?: boolean; wide?: boolean }) {
|
||||
const width = narrow ? "max-w-sm px-4" : wide ? "max-w-6xl px-6" : "max-w-3xl px-6";
|
||||
return (
|
||||
<div className="min-h-screen bg-background text-foreground">
|
||||
<main className={`mx-auto flex w-full flex-col gap-6 py-8 ${width}`}>
|
||||
<div className="self-end rounded-xl bg-muted px-4 py-3 text-sm">/swarm {request}</div>
|
||||
{children}
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function Legend() {
|
||||
return <div className="rounded-md border border-border p-3"><SourceLegend /></div>;
|
||||
}
|
||||
|
||||
function TodayView() {
|
||||
const phase: TaskChatActivityPhaseItem = {
|
||||
id: "today",
|
||||
kind: "activity_phase",
|
||||
summary: "",
|
||||
active: false,
|
||||
items: TODAY_STEPS.map((step, index) => ({ id: `today-${index}`, kind: "tool", name: "Swarm", rawName: "swarm", toolKind: "other", status: "completed", description: step, target: step })),
|
||||
};
|
||||
const view = completed();
|
||||
return (
|
||||
<Thread request={view.request}>
|
||||
<SwarmTurn view={view}><TaskChatRunnerActivityGroup item={phase} defaultExpanded /></SwarmTurn>
|
||||
</Thread>
|
||||
);
|
||||
}
|
||||
|
||||
function Inline({ view, narrow }: { view: SwarmView; narrow?: boolean }) {
|
||||
return <Thread request={view.request} narrow={narrow}><Legend /><InlineDirection view={view} /></Thread>;
|
||||
}
|
||||
|
||||
function Panel({ view, tab, google }: { view: SwarmView; tab?: string; google?: boolean }) {
|
||||
return (
|
||||
<Thread request={view.request} wide>
|
||||
<Legend />
|
||||
<div className="grid min-w-0 grid-cols-1 gap-6 md:grid-cols-5">
|
||||
<div className="min-w-0 md:col-span-3">
|
||||
<SwarmTurn view={view}>
|
||||
<p className="text-sm text-foreground">I split this into {view.helpers.length} helpers. Follow them in the swarm panel.</p>
|
||||
</SwarmTurn>
|
||||
</div>
|
||||
<div className="min-w-0 md:col-span-2"><SidePanel view={view} defaultTab={tab} googleExtras={google ? <GoogleOnlyExtras /> : undefined} /></div>
|
||||
</div>
|
||||
</Thread>
|
||||
);
|
||||
}
|
||||
|
||||
function Summary({ view, open, narrow }: { view: SwarmView; open?: boolean; narrow?: boolean }) {
|
||||
return (
|
||||
<Thread request={view.request} narrow={narrow}>
|
||||
<Legend />
|
||||
<SwarmTurn view={view}><SummaryCard view={view} defaultOpen={open} /></SwarmTurn>
|
||||
</Thread>
|
||||
);
|
||||
}
|
||||
|
||||
function NarrowBoth() {
|
||||
const blocked = runningWithBlocked();
|
||||
const view = running();
|
||||
return (
|
||||
<Thread request={view.request} narrow>
|
||||
<SwarmTurn view={blocked}><SummaryCard view={blocked} annotate={false} /></SwarmTurn>
|
||||
<InlineDirection view={view} annotate={false} />
|
||||
</Thread>
|
||||
);
|
||||
}
|
||||
|
||||
const STATES: Array<[string, () => SwarmView]> = [
|
||||
["Starting", starting],
|
||||
["Running", running],
|
||||
["Helper blocked", runningWithBlocked],
|
||||
["Stopping after Stop", stopping],
|
||||
["Stopped", stopped],
|
||||
["Failed", failed],
|
||||
["Not available here", refused],
|
||||
["Finished", completed],
|
||||
];
|
||||
|
||||
function StateMatrix() {
|
||||
return (
|
||||
<Thread request={running().request}>
|
||||
<Legend />
|
||||
{STATES.map(([label, make]) => (
|
||||
<section key={label} className="flex flex-col gap-2">
|
||||
<h3 className="text-xs font-medium text-muted-foreground">{label}</h3>
|
||||
<SummaryCard view={make()} annotate={false} />
|
||||
</section>
|
||||
))}
|
||||
</Thread>
|
||||
);
|
||||
}
|
||||
|
||||
function Compare() {
|
||||
const view = running();
|
||||
return (
|
||||
<Thread request={view.request} wide>
|
||||
<Legend />
|
||||
<div className="grid min-w-0 grid-cols-1 gap-6 lg:grid-cols-3">
|
||||
<section className="flex min-w-0 flex-col gap-2"><h3 className="text-xs font-medium text-muted-foreground">1 · Inline helpers</h3><InlineDirection view={view} annotate={false} /></section>
|
||||
<section className="flex min-w-0 flex-col gap-2"><h3 className="text-xs font-medium text-muted-foreground">2 · Swarm panel</h3><SidePanel view={view} annotate={false} /></section>
|
||||
<section className="flex min-w-0 flex-col gap-2"><h3 className="text-xs font-medium text-muted-foreground">3 · Summary card</h3><SummaryCard view={view} annotate={false} /></section>
|
||||
</div>
|
||||
</Thread>
|
||||
);
|
||||
}
|
||||
|
||||
const meta = {
|
||||
id: "design-antigravity-swarm-activity",
|
||||
title: "Design proposals/Patterns/Antigravity swarm activity",
|
||||
component: Compare,
|
||||
parameters: {
|
||||
layout: "fullscreen",
|
||||
docs: {
|
||||
description: {
|
||||
component: [
|
||||
"How a Google Antigravity swarm could appear inside a Paperclip task. Every story is built from one real swarm run (CLI 1.5.15, auto mode): `ui/storybook/fixtures/antigravity-swarm.sample.json`. The fixture is a normalised extract of that run: the ACP updates as received, plus the swarm's `plan.json`, `members.json` and `board.jsonl` and a summary of each helper transcript, stored under short keys with paths redacted. Two parts are not from this run. The blocked post is adapted from an earlier recorded run of the same CLI (a helper's write outside the task folder timed out): the wording is the recorded wording, but the helper name and path are changed. The long swarm is synthetic and uses the same shapes.",
|
||||
"Each element is tagged with where it comes from. **Live**: sent over ACP while the coordinator works (the request, swarm title, each helper's name and brief, the goal, tasks and threads from the coordinator's plan, the coordinator's own messages, finish and stop, and one usage total). **Swarm files**: read from the board, roster and helper transcripts that the CLI writes in Paperclip's private state folder (helper state, current step, helper messages with numbers, in review and done, progress, models and per-helper tokens). Google never forwards these over ACP. **Needs Google**: not available today; shown only in the labelled variant.",
|
||||
"Today renders the driver's current step titles for this run. The shipped driver would actually stop this run at the coordinator's plan write, because the plan file is outside the task folder. The plan is the source of the Goal and Threads shown here.",
|
||||
"Directions: 1 · Inline helpers reuses the shipped subagent tree. That tree has no blocked status (only running, done, failed and stopped), so this direction shows blocked helpers in a separate Needs attention row above it; doing it properly needs a blocked status in the shared card. 2 · Swarm panel follows Antigravity's Overview, Members and Board tabs. 3 · Summary card is one compact card that expands.",
|
||||
].join("\n\n"),
|
||||
},
|
||||
},
|
||||
paperclip: {
|
||||
capabilities: ["tasks/discussion", "runs-adapters/runs"],
|
||||
status: "proposed",
|
||||
home: "design-proposals",
|
||||
exception: "Design exploration for showing an Antigravity swarm in a task; not wired to the backend.",
|
||||
implementation: "prototype",
|
||||
boundary: "fixtures",
|
||||
notes: "Fixture-driven exploration built from shipped task-chat parts: runner header, activity group, subagent tree, status glyphs, tabs and badges. Uses one real recorded swarm run, plus one synthetic long swarm. Helper state, current step and helper messages need a reader for the CLI's private swarm files, which does not exist yet.",
|
||||
},
|
||||
},
|
||||
render: () => <Compare />,
|
||||
} satisfies Meta<typeof Compare>;
|
||||
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof meta>;
|
||||
|
||||
export const CompareDirections: Story = { name: "00 · Compare directions · running", render: () => <Compare /> };
|
||||
export const Today: Story = { name: "01 · Today · driver step titles", render: () => <TodayView /> };
|
||||
export const InlineRunning: Story = { name: "02 · Inline helpers · running", render: () => <Inline view={running()} /> };
|
||||
export const InlineBlocked: Story = { name: "03 · Inline helpers · helper blocked", render: () => <Inline view={runningWithBlocked()} /> };
|
||||
export const InlineFinished: Story = { name: "04 · Inline helpers · finished", render: () => <Inline view={completed()} /> };
|
||||
export const PanelOverview: Story = { name: "05 · Swarm panel · overview", render: () => <Panel view={running()} /> };
|
||||
export const PanelHelpers: Story = { name: "06 · Swarm panel · helpers", render: () => <Panel view={completed()} tab="helpers" /> };
|
||||
export const PanelMessages: Story = { name: "07 · Swarm panel · messages", render: () => <Panel view={completed()} tab="messages" /> };
|
||||
export const SummaryCollapsed: Story = { name: "08 · Summary card · collapsed", render: () => <Summary view={running()} /> };
|
||||
export const SummaryExpanded: Story = { name: "09 · Summary card · expanded", render: () => <Summary view={running()} open /> };
|
||||
export const States: Story = { name: "10 · States · starting to finished", render: () => <StateMatrix /> };
|
||||
export const LongSwarmInline: Story = { name: "11 · Long swarm · inline", render: () => <Inline view={longSwarm()} /> };
|
||||
export const LongSwarmPanel: Story = { name: "12 · Long swarm · panel messages", render: () => <Panel view={longSwarm()} tab="messages" /> };
|
||||
export const LongSwarmSummary: Story = { name: "13 · Long swarm · summary expanded", render: () => <Summary view={longSwarm()} open /> };
|
||||
export const Narrow: Story = { name: "14 · Narrow · summary and inline", render: () => <NarrowBoth /> };
|
||||
export const NeedsGoogle: Story = { name: "15 · Would need Google to expose", render: () => <Panel view={longSwarm()} tab="helpers" google /> };
|
||||
@@ -0,0 +1,455 @@
|
||||
import { useMemo, useState, type ReactNode } from "react";
|
||||
import { ChevronRight, Hourglass, Info, MessageSquare, ShieldCheck, Square, TriangleAlert, Users } from "lucide-react";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
import { StatusGlyph } from "@/components/StatusGlyph";
|
||||
import { TaskChatRunnerHeader } from "@/components/task-chat/TaskChatRunnerTurn";
|
||||
import { TaskChatSubagentTree, type TaskChatSubagent, type TaskChatSubagentStatus } from "@/components/task-chat/TaskChatSubagentCard";
|
||||
import { TaskChatExpansionState } from "@/components/task-chat/expansion-state";
|
||||
import { cn } from "@/lib/utils";
|
||||
import {
|
||||
SOURCE_DETAIL,
|
||||
SOURCE_LABEL,
|
||||
plainPost,
|
||||
progressLine,
|
||||
swarmProgress,
|
||||
threadCount,
|
||||
threadNow,
|
||||
threadState,
|
||||
type HelperState,
|
||||
type SwarmHelper,
|
||||
type SwarmPost,
|
||||
type SwarmSource,
|
||||
type SwarmStatus,
|
||||
type SwarmView,
|
||||
} from "./swarm-model";
|
||||
|
||||
const STATE_LABEL: Record<HelperState, string> = {
|
||||
starting: "Starting",
|
||||
working: "Working",
|
||||
waiting: "Standing by",
|
||||
in_review: "In review",
|
||||
done: "Done",
|
||||
blocked: "Blocked",
|
||||
stopped: "Stopped",
|
||||
};
|
||||
|
||||
const STATE_GLYPH: Record<HelperState, string> = {
|
||||
starting: "backlog",
|
||||
working: "in_progress",
|
||||
waiting: "todo",
|
||||
in_review: "in_review",
|
||||
done: "done",
|
||||
blocked: "blocked",
|
||||
stopped: "cancelled",
|
||||
};
|
||||
|
||||
const STATUS_LABEL: Record<SwarmStatus, string> = {
|
||||
starting: "Starting the swarm",
|
||||
running: "Swarm working",
|
||||
stopping: "Stopping the swarm",
|
||||
stopped: "Swarm stopped",
|
||||
failed: "Swarm failed",
|
||||
refused: "Swarm not available",
|
||||
completed: "Swarm finished",
|
||||
};
|
||||
|
||||
const STATUS_GLYPH: Record<SwarmStatus, string> = {
|
||||
starting: "backlog",
|
||||
running: "in_progress",
|
||||
stopping: "in_progress",
|
||||
stopped: "cancelled",
|
||||
failed: "blocked",
|
||||
refused: "blocked",
|
||||
completed: "done",
|
||||
};
|
||||
|
||||
export function SourceTag({ source, show = true }: { source: SwarmSource; show?: boolean }) {
|
||||
if (!show) return null;
|
||||
return (
|
||||
<Badge variant="outline" className={cn("font-normal text-muted-foreground", source === "google" && "border-dashed")} title={SOURCE_DETAIL[source]} data-swarm-source={source}>
|
||||
{SOURCE_LABEL[source]}
|
||||
</Badge>
|
||||
);
|
||||
}
|
||||
|
||||
export function SourceLegend() {
|
||||
return (
|
||||
<div className="flex flex-wrap items-center gap-2 text-xs text-muted-foreground" aria-label="Where each part comes from">
|
||||
{(Object.keys(SOURCE_LABEL) as SwarmSource[]).map((source) => (
|
||||
<span key={source} className="flex items-center gap-1.5">
|
||||
<SourceTag source={source} />
|
||||
<span>{SOURCE_DETAIL[source]}</span>
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function SectionTitle({ children, source, annotate }: { children: ReactNode; source?: SwarmSource; annotate?: boolean }) {
|
||||
return (
|
||||
<div className="flex min-w-0 items-center gap-2">
|
||||
<span className="text-xs font-medium text-muted-foreground">{children}</span>
|
||||
{source ? <SourceTag source={source} show={annotate} /> : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function HelperStateLabel({ state }: { state: HelperState }) {
|
||||
return (
|
||||
<span className="flex shrink-0 items-center gap-1 text-xs text-muted-foreground">
|
||||
<StatusGlyph status={STATE_GLYPH[state]} size="sm" />
|
||||
<span className={cn(state === "blocked" && "text-(--status-task-icon-blocked)")}>{STATE_LABEL[state]}</span>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
function HelperName({ name }: { name: string }) {
|
||||
return <span className="shrink-0 rounded-sm bg-muted px-1.5 font-mono text-xs text-muted-foreground">{name}</span>;
|
||||
}
|
||||
|
||||
export function HelperRow({ helper, showModel }: { helper: SwarmHelper; showModel?: boolean }) {
|
||||
return (
|
||||
<li className="flex min-w-0 items-start gap-2 py-1.5" data-swarm-helper={helper.name}>
|
||||
<span className="flex min-w-0 flex-1 flex-col gap-0.5">
|
||||
<span className="flex min-w-0 items-center gap-2">
|
||||
<HelperName name={helper.name} />
|
||||
<span className="min-w-0 truncate text-sm text-foreground">{helper.task}</span>
|
||||
</span>
|
||||
{helper.action ? (
|
||||
<span className={cn("min-w-0 truncate text-xs text-muted-foreground", helper.state === "working" && "shimmer-text", helper.state === "blocked" && "text-(--status-task-icon-blocked)")}>{helper.action}</span>
|
||||
) : null}
|
||||
{showModel && (helper.model || helper.tokens) ? (
|
||||
<span className="font-mono text-xs tabular-nums text-muted-foreground">
|
||||
{[helper.model, helper.tokens ? `${helper.tokens.input.toLocaleString()} in · ${helper.tokens.output.toLocaleString()} out` : null].filter(Boolean).join(" · ")}
|
||||
</span>
|
||||
) : null}
|
||||
</span>
|
||||
<HelperStateLabel state={helper.state} />
|
||||
</li>
|
||||
);
|
||||
}
|
||||
|
||||
const POST_TONE: Record<SwarmPost["kind"], string> = {
|
||||
brief: "text-muted-foreground",
|
||||
done: "text-foreground",
|
||||
update: "text-foreground",
|
||||
blocked: "text-(--status-task-icon-blocked)",
|
||||
stall: "text-(--status-task-icon-todo)",
|
||||
finish: "text-foreground",
|
||||
};
|
||||
|
||||
const POST_LABEL: Partial<Record<SwarmPost["kind"], string>> = {
|
||||
brief: "Brief",
|
||||
done: "Done",
|
||||
blocked: "Blocked",
|
||||
stall: "Stalled",
|
||||
finish: "Finished",
|
||||
};
|
||||
|
||||
export function MessageFeed({ posts, limit, hideBriefs }: { posts: SwarmPost[]; limit?: number; hideBriefs?: boolean }) {
|
||||
const visible = (hideBriefs ? posts.filter((post) => post.kind !== "brief") : posts);
|
||||
const shown = limit ? visible.slice(-limit) : visible;
|
||||
return (
|
||||
<ol className="flex min-w-0 flex-col gap-1" aria-label="Swarm messages">
|
||||
{shown.map((post) => (
|
||||
<li key={post.seq} className="flex min-w-0 items-baseline gap-2 text-sm" data-swarm-post={post.seq}>
|
||||
<span className="w-7 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground">#{post.seq}</span>
|
||||
<span className="min-w-0 flex-1">
|
||||
<span className="font-mono text-xs text-muted-foreground">{post.author}</span>
|
||||
{POST_LABEL[post.kind] ? <span className={cn("ml-1.5 text-xs", POST_TONE[post.kind])}>{POST_LABEL[post.kind]}</span> : null}
|
||||
<span className={cn("block truncate", POST_TONE[post.kind])} title={plainPost(post.text)}>{plainPost(post.text)}</span>
|
||||
</span>
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
);
|
||||
}
|
||||
|
||||
export function ProgressSegments({ view }: { view: SwarmView }) {
|
||||
const workers = view.helpers.filter((helper) => helper.role !== "monitor");
|
||||
if (!workers.length) return null;
|
||||
return (
|
||||
<div className="flex h-1.5 w-full gap-0.5 overflow-hidden rounded-full" aria-hidden>
|
||||
{workers.map((helper) => (
|
||||
<span
|
||||
key={helper.name}
|
||||
className={cn(
|
||||
"h-full flex-1",
|
||||
helper.state === "done" && "bg-(--status-task-icon-done)",
|
||||
helper.state === "in_review" && "bg-(--status-task-icon-in_review)",
|
||||
helper.state === "working" && "bg-(--status-agent-running)",
|
||||
helper.state === "blocked" && "bg-(--status-task-icon-blocked)",
|
||||
(helper.state === "waiting" || helper.state === "starting" || helper.state === "stopped") && "bg-border",
|
||||
)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function ThreadList({ view, annotate }: { view: SwarmView; annotate?: boolean }) {
|
||||
if (!view.threads.length) return null;
|
||||
return (
|
||||
<div className="flex min-w-0 flex-col gap-1.5">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<SectionTitle source="live" annotate={annotate}>Threads</SectionTitle>
|
||||
{annotate ? <span className="text-xs text-muted-foreground">state, count and Now line:</span> : null}
|
||||
<SourceTag source="files" show={annotate} />
|
||||
</div>
|
||||
<ul className="flex min-w-0 flex-col gap-1">
|
||||
{view.threads.map((thread) => {
|
||||
const state = threadState(view, thread);
|
||||
return (
|
||||
<li key={thread.id} className="flex min-w-0 items-start gap-2 rounded-md border border-border px-2.5 py-1.5">
|
||||
<StatusGlyph status={STATE_GLYPH[state]} size="sm" className="mt-0.5" />
|
||||
<span className="flex min-w-0 flex-1 flex-col">
|
||||
<span className="flex min-w-0 items-center gap-2 text-sm">
|
||||
<span className="min-w-0 truncate text-foreground">{thread.title}</span>
|
||||
<span className="ml-auto shrink-0 font-mono text-xs tabular-nums text-muted-foreground">{threadCount(view, thread)}</span>
|
||||
</span>
|
||||
<span className="min-w-0 truncate text-xs text-muted-foreground">Now: {threadNow(view, thread)}</span>
|
||||
</span>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function Notice({ icon: Icon, children, tone = "muted" }: { icon: typeof Info; children: ReactNode; tone?: "muted" | "danger" | "warning" }) {
|
||||
return (
|
||||
<p className={cn("flex items-start gap-1.5 text-xs", tone === "muted" && "text-muted-foreground", tone === "danger" && "text-(--status-task-icon-blocked)", tone === "warning" && "text-(--status-task-icon-todo)")}>
|
||||
<Icon className="mt-0.5 size-3.5 shrink-0" aria-hidden />
|
||||
<span>{children}</span>
|
||||
</p>
|
||||
);
|
||||
}
|
||||
|
||||
export function SwarmNotes({ view }: { view: SwarmView }) {
|
||||
return (
|
||||
<div className="flex flex-col gap-1">
|
||||
{view.status !== "refused" ? <Notice icon={ShieldCheck}>Helper changes inside the task folder were approved automatically; anything else is blocked.</Notice> : null}
|
||||
{view.reason ? <Notice icon={view.status === "stopped" ? Square : TriangleAlert} tone={view.status === "stopped" ? "muted" : "danger"}>{view.reason}</Notice> : null}
|
||||
{view.status === "stopping" ? <Notice icon={Hourglass}>Stopping the coordinator and its helpers. Files already written stay in the task folder.</Notice> : null}
|
||||
{view.files ? <Notice icon={Info}>Files changed in the task folder: {view.files.join(", ")}</Notice> : null}
|
||||
{view.usage ? <Notice icon={Info}>The coordinator used {view.usage.total.toLocaleString()} tokens.{view.usage.helpers ? ` The helpers used ${view.usage.helpers.input.toLocaleString()} in and ${view.usage.helpers.output.toLocaleString()} out more, read from the swarm's files.` : ""}</Notice> : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function subagentStatus(helper: SwarmHelper, view: SwarmView): TaskChatSubagentStatus {
|
||||
if (helper.state === "done") return "completed";
|
||||
if (helper.state === "blocked") return "failed";
|
||||
if (helper.state === "stopped" || view.status === "stopped" || view.status === "failed") return "cancelled";
|
||||
return "running";
|
||||
}
|
||||
|
||||
function toSubagent(helper: SwarmHelper, view: SwarmView): TaskChatSubagent {
|
||||
const lastPost = [...view.posts].reverse().find((post) => post.author === helper.name && post.kind !== "brief");
|
||||
return {
|
||||
id: `swarm-${helper.name}`,
|
||||
agentType: helper.name,
|
||||
prompt: helper.brief,
|
||||
model: helper.model,
|
||||
status: subagentStatus(helper, view),
|
||||
description: helper.task,
|
||||
progressSummary: helper.state === "in_review" ? "Waiting for the verifier" : helper.state === "waiting" ? `Standing by${helper.action ? ` · ${helper.action}` : ""}` : helper.action,
|
||||
activity: [],
|
||||
result: lastPost ? plainPost(lastPost.text) : undefined,
|
||||
};
|
||||
}
|
||||
|
||||
export function SwarmTurn({ view, children }: { view: SwarmView; children: ReactNode }) {
|
||||
return (
|
||||
<div className="flex min-w-0 flex-col" data-testid="swarm-turn">
|
||||
<TaskChatRunnerHeader
|
||||
runId="swarm-story"
|
||||
agentName="Antigravity"
|
||||
agentIcon="code"
|
||||
status={view.status === "running" ? "running" : "succeeded"}
|
||||
startedAtMs={null}
|
||||
statusContent={
|
||||
<span className="flex items-center gap-1.5 text-xs text-muted-foreground">
|
||||
<StatusGlyph status={STATUS_GLYPH[view.status]} size="sm" />
|
||||
{STATUS_LABEL[view.status]}
|
||||
</span>
|
||||
}
|
||||
/>
|
||||
<div className="flex min-w-0 flex-col gap-2 py-1">{children}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function GoalBlock({ view, annotate }: { view: SwarmView; annotate?: boolean }) {
|
||||
return (
|
||||
<div className="flex min-w-0 flex-col gap-1">
|
||||
<div className="flex min-w-0 flex-wrap items-center gap-2">
|
||||
<span className="min-w-0 text-sm font-medium text-foreground">{view.goal.title}</span>
|
||||
<SourceTag source="live" show={annotate} />
|
||||
</div>
|
||||
<span className="text-xs text-muted-foreground">{view.goal.line}</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function ProgressBlock({ view, annotate }: { view: SwarmView; annotate?: boolean }) {
|
||||
if (!view.helpers.length) return null;
|
||||
return (
|
||||
<div className="flex min-w-0 flex-col gap-1.5">
|
||||
<div className="flex min-w-0 flex-wrap items-center gap-2 text-xs text-muted-foreground">
|
||||
<span className="tabular-nums">{progressLine(view)}</span>
|
||||
<SourceTag source="files" show={annotate} />
|
||||
</div>
|
||||
<ProgressSegments view={view} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function InlineDirection({ view, annotate = true }: { view: SwarmView; annotate?: boolean }) {
|
||||
const memory = useMemo(() => new Map<string, boolean>(), []);
|
||||
const blocked = view.helpers.filter((helper) => helper.state === "blocked");
|
||||
const subagents = view.helpers.filter((helper) => helper.role !== "monitor" && helper.state !== "blocked").map((helper) => toSubagent(helper, view));
|
||||
const messages = view.posts.filter((post) => post.kind !== "brief");
|
||||
return (
|
||||
<TaskChatExpansionState.Provider value={memory}>
|
||||
<SwarmTurn view={view}>
|
||||
<GoalBlock view={view} annotate={annotate} />
|
||||
<ProgressBlock view={view} annotate={annotate} />
|
||||
{blocked.length ? (
|
||||
<div className="flex min-w-0 flex-col gap-1 rounded-lg border border-destructive/35 bg-destructive/5 px-3 py-1" data-testid="swarm-blocked-helpers">
|
||||
<SectionTitle source="files" annotate={annotate}>Needs attention</SectionTitle>
|
||||
<ul className="flex min-w-0 flex-col divide-y divide-border">{blocked.map((helper) => <HelperRow key={helper.name} helper={helper} />)}</ul>
|
||||
</div>
|
||||
) : null}
|
||||
{subagents.length ? (
|
||||
<div className="flex min-w-0 flex-col gap-1">
|
||||
<SectionTitle source="files" annotate={annotate}>Helpers, their current step and state</SectionTitle>
|
||||
<TaskChatSubagentTree subagents={subagents} />
|
||||
</div>
|
||||
) : null}
|
||||
{messages.length ? (
|
||||
<details className="group min-w-0 rounded-lg border border-border bg-card px-3 py-2">
|
||||
<summary className="flex cursor-pointer list-none items-center gap-2 text-xs text-muted-foreground hover:text-foreground">
|
||||
<ChevronRight className="size-3.5 shrink-0 group-open:rotate-90" aria-hidden />
|
||||
<MessageSquare className="size-3.5" aria-hidden />
|
||||
{messages.length} {messages.length === 1 ? "message" : "messages"} between helpers
|
||||
<SourceTag source="files" show={annotate} />
|
||||
</summary>
|
||||
<div className="pt-2"><MessageFeed posts={view.posts} hideBriefs /></div>
|
||||
</details>
|
||||
) : null}
|
||||
<SwarmNotes view={view} />
|
||||
</SwarmTurn>
|
||||
</TaskChatExpansionState.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
export function SidePanel({ view, annotate = true, defaultTab = "overview", googleExtras }: { view: SwarmView; annotate?: boolean; defaultTab?: string; googleExtras?: ReactNode }) {
|
||||
const active = view.helpers.filter((helper) => helper.state === "working" || helper.state === "blocked");
|
||||
return (
|
||||
<aside className="flex min-w-0 flex-col gap-3 rounded-lg border border-border bg-card p-3" aria-label="Swarm">
|
||||
<div className="flex min-w-0 items-center gap-2">
|
||||
<Users className="size-4 text-muted-foreground" aria-hidden />
|
||||
<span className="min-w-0 truncate text-sm font-medium text-foreground">{view.title}</span>
|
||||
<span className="ml-auto flex shrink-0 items-center gap-1 text-xs text-muted-foreground">
|
||||
<StatusGlyph status={STATUS_GLYPH[view.status]} size="sm" />
|
||||
{STATUS_LABEL[view.status]}
|
||||
</span>
|
||||
</div>
|
||||
<Tabs defaultValue={defaultTab}>
|
||||
<TabsList>
|
||||
<TabsTrigger value="overview">Overview</TabsTrigger>
|
||||
<TabsTrigger value="helpers">Helpers {view.helpers.length}</TabsTrigger>
|
||||
<TabsTrigger value="messages">Messages {view.posts.length}</TabsTrigger>
|
||||
</TabsList>
|
||||
<TabsContent value="overview" className="flex min-w-0 flex-col gap-3 pt-1">
|
||||
<GoalBlock view={view} annotate={annotate} />
|
||||
<ProgressBlock view={view} annotate={annotate} />
|
||||
{active.length ? (
|
||||
<div className="flex min-w-0 flex-col">
|
||||
<SectionTitle source="files" annotate={annotate}>Running {active.length}</SectionTitle>
|
||||
<ul className="flex min-w-0 flex-col divide-y divide-border">{active.map((helper) => <HelperRow key={helper.name} helper={helper} />)}</ul>
|
||||
</div>
|
||||
) : null}
|
||||
<ThreadList view={view} annotate={annotate} />
|
||||
<SwarmNotes view={view} />
|
||||
</TabsContent>
|
||||
<TabsContent value="helpers" className="flex min-w-0 flex-col gap-1 pt-1">
|
||||
<SectionTitle source="files" annotate={annotate}>Coordinator and {view.helpers.length} helpers</SectionTitle>
|
||||
<ul className="flex min-w-0 flex-col divide-y divide-border">
|
||||
<li className="flex min-w-0 items-center gap-2 py-1.5"><HelperName name="coordinator" /><span className="text-sm text-foreground">Splits the work and checks results</span></li>
|
||||
{view.helpers.map((helper) => <HelperRow key={helper.name} helper={helper} showModel />)}
|
||||
</ul>
|
||||
{googleExtras}
|
||||
</TabsContent>
|
||||
<TabsContent value="messages" className="flex min-w-0 flex-col gap-1 pt-1">
|
||||
<SectionTitle source="files" annotate={annotate}>Message board</SectionTitle>
|
||||
<MessageFeed posts={view.posts} />
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
</aside>
|
||||
);
|
||||
}
|
||||
|
||||
export function SummaryCard({ view, annotate = true, defaultOpen = false }: { view: SwarmView; annotate?: boolean; defaultOpen?: boolean }) {
|
||||
const [open, setOpen] = useState(defaultOpen);
|
||||
const progress = swarmProgress(view);
|
||||
const focus = view.helpers.filter((helper) => helper.state === "blocked" || helper.state === "working").slice(0, 3);
|
||||
const latest = [...view.posts].reverse().find((post) => post.kind !== "brief");
|
||||
return (
|
||||
<section className="flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-card px-3 py-2.5" aria-label="Swarm summary" data-swarm-status={view.status}>
|
||||
<div className="flex min-w-0 items-center gap-2">
|
||||
<StatusGlyph status={STATUS_GLYPH[view.status]} size="md" />
|
||||
<span className="flex min-w-0 flex-1 flex-col">
|
||||
<span className="min-w-0 truncate text-sm font-medium text-foreground">{view.goal.title}</span>
|
||||
<span className="min-w-0 truncate text-xs text-muted-foreground">{STATUS_LABEL[view.status]}{view.helpers.length ? ` · ${view.helpers.length} helpers · ${progressLine(view)}` : ""}</span>
|
||||
</span>
|
||||
{view.helpers.length ? (
|
||||
<Button variant="ghost" size="sm" onClick={() => setOpen(!open)} aria-expanded={open}>
|
||||
{open ? "Hide" : "Details"}
|
||||
<ChevronRight className={cn("size-3.5", open && "rotate-90")} aria-hidden />
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
{view.helpers.length ? <ProgressSegments view={view} /> : null}
|
||||
{!open && focus.length ? (
|
||||
<ul className="flex min-w-0 flex-col divide-y divide-border">{focus.map((helper) => <HelperRow key={helper.name} helper={helper} />)}</ul>
|
||||
) : null}
|
||||
{!open && latest && !focus.length && progress.total ? (
|
||||
<p className="min-w-0 truncate text-xs text-muted-foreground"><span className="font-mono">{latest.author}</span>: {plainPost(latest.text)}</p>
|
||||
) : null}
|
||||
{open ? (
|
||||
<div className="flex min-w-0 flex-col gap-3 border-t border-border pt-2">
|
||||
<div className="flex flex-wrap gap-2"><SourceTag source="live" show={annotate} /><SourceTag source="files" show={annotate} /></div>
|
||||
<ThreadList view={view} annotate={annotate} />
|
||||
<div className="flex min-w-0 flex-col">
|
||||
<SectionTitle source="files" annotate={annotate}>Helpers</SectionTitle>
|
||||
<ul className="flex min-w-0 flex-col divide-y divide-border">{view.helpers.map((helper) => <HelperRow key={helper.name} helper={helper} />)}</ul>
|
||||
</div>
|
||||
<div className="flex min-w-0 flex-col gap-1">
|
||||
<SectionTitle source="files" annotate={annotate}>Latest messages</SectionTitle>
|
||||
<MessageFeed posts={view.posts} hideBriefs limit={6} />
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
<SwarmNotes view={view} />
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
export function GoogleOnlyExtras() {
|
||||
return (
|
||||
<div className="mt-2 flex flex-col gap-1.5 rounded-md border border-dashed border-border p-2.5" data-swarm-source="google">
|
||||
<div className="flex items-center gap-2"><SourceTag source="google" /><span className="text-xs text-muted-foreground">Shown only if Google exposes it</span></div>
|
||||
<ul className="flex list-disc flex-col gap-0.5 pl-5 text-xs text-muted-foreground">
|
||||
<li>Which task depends on which (a work graph)</li>
|
||||
<li>A review state set by Google rather than read from "done" messages</li>
|
||||
<li>The swarm's own overview headline and asks (the narrator), which is not started for Paperclip</li>
|
||||
<li>A screenshot timeline of visible changes</li>
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import sample from "../../../fixtures/antigravity-swarm.sample.json";
|
||||
import { FIXTURE, deriveSwarm, parseSwarmFixture, postKind, progressLine, threadCount, threadState } from "./swarm-model";
|
||||
import { runningWithBlocked, stopped } from "./swarm-variants";
|
||||
|
||||
const states = (atSeq: number) => Object.fromEntries(deriveSwarm(FIXTURE, atSeq).helpers.map((helper) => [helper.name, helper.state]));
|
||||
|
||||
describe("swarm fixture derivation", () => {
|
||||
it("rejects a fixture with a missing field instead of rendering a blank story", () => {
|
||||
const broken = { ...sample, files: { ...sample.files, board: undefined } };
|
||||
expect(() => parseSwarmFixture(broken)).toThrow("files.board should be an array");
|
||||
});
|
||||
|
||||
it("derives helper states mid-run from board posts and helper steps", () => {
|
||||
expect(states(8)).toEqual({
|
||||
"html-writer": "in_review",
|
||||
"css-writer": "working",
|
||||
"logic-writer": "working",
|
||||
"docs-writer": "in_review",
|
||||
verifier: "working",
|
||||
monitor: "waiting",
|
||||
});
|
||||
const view = deriveSwarm(FIXTURE, 8);
|
||||
expect(view.helpers.find((helper) => helper.name === "css-writer")?.action).toBe("Writing style.css");
|
||||
expect(progressLine(view)).toBe("0 of 5 done · 2 in review · 2 threads open");
|
||||
});
|
||||
|
||||
it("keeps actions from the same second as the cutoff post", () => {
|
||||
const cutoff = FIXTURE.board.find((post) => post.seq === 7)!.time;
|
||||
const sameSecond = cutoff.replace(/\.\d+Z$/, "Z");
|
||||
const css = FIXTURE.workers["css-writer"]!;
|
||||
const fixture = { ...FIXTURE, workers: { ...FIXTURE.workers, "css-writer": { ...css, actions: [...css.actions.filter((action) => Date.parse(action.at) < Date.parse(cutoff)), { at: sameSecond, tool: "write_file", target: "<task-folder>/same-second.css" }] } } };
|
||||
expect(deriveSwarm(fixture, 7).helpers.find((helper) => helper.name === "css-writer")?.action).toBe("Writing same-second.css");
|
||||
});
|
||||
|
||||
it("marks everything done once the verifier reports", () => {
|
||||
const view = deriveSwarm(FIXTURE, 12, "completed");
|
||||
expect(Object.values(states(12)).filter((state) => state === "done")).toHaveLength(5);
|
||||
expect(view.threads.map((thread) => [threadState(view, thread), threadCount(view, thread)])).toEqual([["done", "4/4"], ["done", "1/1"]]);
|
||||
expect(progressLine(view)).toBe("5 of 5 done · 0 threads open");
|
||||
});
|
||||
|
||||
it("attaches usage and changed files only when the snapshot reaches the end of the turn", () => {
|
||||
const done = deriveSwarm(FIXTURE, 12, "completed");
|
||||
expect(done.usage?.total).toBe(179_931);
|
||||
expect(done.usage?.helpers?.input).toBeGreaterThan(0);
|
||||
expect(done.files).toEqual(FIXTURE.filesChanged);
|
||||
expect(stopped().usage).toBeUndefined();
|
||||
expect(deriveSwarm(FIXTURE, 8, "completed").usage).toBeUndefined();
|
||||
});
|
||||
|
||||
it("derives the blocked state from the recorded permission failure text", () => {
|
||||
const helper = runningWithBlocked().helpers.find((entry) => entry.name === FIXTURE.recordedBlock.helper);
|
||||
expect(helper?.state).toBe("blocked");
|
||||
expect(helper?.action).toBe("Blocked: tried to change ../shared/units.json, outside the task folder");
|
||||
});
|
||||
|
||||
it("clears the blocked state when the helper later reports done", () => {
|
||||
const at = FIXTURE.board.find((post) => post.seq === 8)!.time;
|
||||
const block = { seq: 7.5, agent: "logic-writer", text: FIXTURE.recordedBlock.text, time: at };
|
||||
const board = [...FIXTURE.board.filter((post) => post.seq <= 7), block, ...FIXTURE.board.filter((post) => post.seq > 7)];
|
||||
const view = deriveSwarm({ ...FIXTURE, board }, 12, "completed");
|
||||
expect(view.helpers.find((helper) => helper.name === "logic-writer")?.state).toBe("done");
|
||||
expect(progressLine(view)).toBe("5 of 5 done · 0 threads open");
|
||||
});
|
||||
|
||||
it("classifies board posts", () => {
|
||||
expect(postKind("monitor", "@coordinator [stall] nobody is working")).toBe("stall");
|
||||
expect(postKind("css-writer", "@verifier [done] style.css created")).toBe("done");
|
||||
expect(postKind("coordinator", "[done] built and verified")).toBe("finish");
|
||||
expect(postKind("coordinator", "@html-writer You own index.html", "brief")).toBe("brief");
|
||||
expect(postKind("logic-writer", FIXTURE.recordedBlock.text)).toBe("blocked");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,336 @@
|
||||
import sample from "../../../fixtures/antigravity-swarm.sample.json";
|
||||
|
||||
export type SwarmSource = "live" | "files" | "text" | "google";
|
||||
|
||||
export const SOURCE_LABEL: Record<SwarmSource, string> = {
|
||||
live: "Live",
|
||||
files: "Swarm files",
|
||||
text: "Parsed text",
|
||||
google: "Needs Google",
|
||||
};
|
||||
|
||||
export const SOURCE_DETAIL: Record<SwarmSource, string> = {
|
||||
live: "Sent live by the coordinator while it works",
|
||||
files: "Read from the files the swarm keeps in Paperclip's private folder",
|
||||
text: "Parsed from what the coordinator writes",
|
||||
google: "Not sent by Google today",
|
||||
};
|
||||
|
||||
export type SwarmStatus = "starting" | "running" | "stopping" | "stopped" | "failed" | "refused" | "completed";
|
||||
export type HelperState = "starting" | "working" | "waiting" | "in_review" | "done" | "blocked" | "stopped";
|
||||
export type HelperRole = "helper" | "verifier" | "monitor";
|
||||
export type PostKind = "brief" | "done" | "update" | "blocked" | "stall" | "finish";
|
||||
|
||||
export interface SwarmHelper {
|
||||
name: string;
|
||||
role: HelperRole;
|
||||
task: string;
|
||||
brief: string;
|
||||
state: HelperState;
|
||||
action?: string;
|
||||
model?: string;
|
||||
tokens?: { input: number; output: number };
|
||||
}
|
||||
|
||||
export interface SwarmPost {
|
||||
seq: number;
|
||||
author: string;
|
||||
text: string;
|
||||
at: string;
|
||||
kind: PostKind;
|
||||
}
|
||||
|
||||
export interface SwarmThread {
|
||||
id: string;
|
||||
title: string;
|
||||
goal: string;
|
||||
helpers: string[];
|
||||
}
|
||||
|
||||
export interface SwarmView {
|
||||
request: string;
|
||||
title: string;
|
||||
goal: { title: string; line: string };
|
||||
status: SwarmStatus;
|
||||
startedAt: string;
|
||||
helpers: SwarmHelper[];
|
||||
posts: SwarmPost[];
|
||||
threads: SwarmThread[];
|
||||
usage?: { total: number; input: number; output: number; helpers?: { input: number; output: number } };
|
||||
model: string;
|
||||
reason?: string;
|
||||
files?: string[];
|
||||
synthetic?: boolean;
|
||||
}
|
||||
|
||||
export interface SwarmAction { at: string; tool: string; summary?: string; target?: string }
|
||||
export interface SwarmWorker { model?: string; tokens: { input: number; output: number }; actions: SwarmAction[] }
|
||||
export interface SwarmBoardPost { seq: number; agent: string; text: string; time: string; kind?: string }
|
||||
export interface SwarmAdd { name: string; brief: string }
|
||||
export interface SwarmPlan { goal: { title: string; line: string }; tasks: Record<string, string>; threads: { id: string; title: string; goal: string; tasks: string[] }[] }
|
||||
|
||||
export interface SwarmFixture {
|
||||
request: string;
|
||||
model: string;
|
||||
filesChanged: string[];
|
||||
title: string;
|
||||
adds: SwarmAdd[];
|
||||
coordinatorUsage: { total: number; input: number; output: number } | null;
|
||||
plan: SwarmPlan;
|
||||
board: SwarmBoardPost[];
|
||||
workers: Record<string, SwarmWorker>;
|
||||
recordedBlock: { helper: string; text: string };
|
||||
}
|
||||
|
||||
type Json = Record<string, unknown>;
|
||||
|
||||
function fail(path: string, expected: string): never {
|
||||
throw new Error(`Swarm fixture: ${path} should be ${expected}`);
|
||||
}
|
||||
|
||||
function object(value: unknown, path: string): Json {
|
||||
return value !== null && typeof value === "object" && !Array.isArray(value) ? value as Json : fail(path, "an object");
|
||||
}
|
||||
|
||||
function array(value: unknown, path: string): unknown[] {
|
||||
return Array.isArray(value) ? value : fail(path, "an array");
|
||||
}
|
||||
|
||||
function text(value: unknown, path: string): string {
|
||||
return typeof value === "string" ? value : fail(path, "a string");
|
||||
}
|
||||
|
||||
function count(value: unknown, path: string): number {
|
||||
return typeof value === "number" && Number.isFinite(value) ? value : fail(path, "a number");
|
||||
}
|
||||
|
||||
function optionalText(value: unknown, path: string): string | undefined {
|
||||
return value === undefined ? undefined : text(value, path);
|
||||
}
|
||||
|
||||
export function parseSwarmFixture(raw: unknown): SwarmFixture {
|
||||
const root = object(raw, "fixture");
|
||||
const run = object(root.run, "run");
|
||||
const files = object(root.files, "files");
|
||||
const events = array(root.acp, "acp").map((event, index) => object(event, `acp[${index}]`));
|
||||
const swarmInputs = events
|
||||
.filter((event) => event.name === "swarm")
|
||||
.map((event, index) => object(event.rawInput, `swarm call ${index}.rawInput`));
|
||||
const titleInput = swarmInputs.find((input) => input.action === "title");
|
||||
const usageEvent = events.find((event) => event.kind === "prompt_result");
|
||||
const usage = usageEvent ? object(object(usageEvent.result, "prompt_result.result").usage, "prompt_result.result.usage") : null;
|
||||
const planRaw = object(files.plan, "files.plan");
|
||||
const goal = object(planRaw.goal, "files.plan.goal");
|
||||
const tasks = object(planRaw.tasks, "files.plan.tasks");
|
||||
const board = array(files.board, "files.board").map((value, index) => {
|
||||
const post = object(value, `files.board[${index}]`);
|
||||
return { seq: count(post.seq, `files.board[${index}].seq`), agent: text(post.agent, `files.board[${index}].agent`), text: text(post.text, `files.board[${index}].text`), time: text(post.time, `files.board[${index}].time`), kind: optionalText(post.kind, `files.board[${index}].kind`) };
|
||||
});
|
||||
if (!board.length) fail("files.board", "non-empty");
|
||||
const workers = Object.fromEntries(Object.entries(object(files.workers, "files.workers")).map(([name, value]) => {
|
||||
const worker = object(value, `files.workers.${name}`);
|
||||
const tokens = object(worker.tokens, `files.workers.${name}.tokens`);
|
||||
const actions = array(worker.actions, `files.workers.${name}.actions`).map((entry, index) => {
|
||||
const action = object(entry, `files.workers.${name}.actions[${index}]`);
|
||||
const at = text(action.at, `files.workers.${name}.actions[${index}].at`);
|
||||
return { at, tool: text(action.tool, `files.workers.${name}.actions[${index}].tool`), summary: optionalText(action.summary, "summary"), target: optionalText(action.target, "target") };
|
||||
});
|
||||
return [name, { model: optionalText(worker.model, `files.workers.${name}.model`), tokens: { input: count(tokens.input, "tokens.input"), output: count(tokens.output, "tokens.output") }, actions }];
|
||||
}));
|
||||
const block = object(root.recordedBlock, "recordedBlock");
|
||||
return {
|
||||
request: text(root.request, "request"),
|
||||
model: text(run.model, "run.model"),
|
||||
filesChanged: array(run.filesChanged, "run.filesChanged").map((value, index) => text(value, `run.filesChanged[${index}]`)),
|
||||
title: titleInput ? text(titleInput.title, "swarm title") : text(goal.title, "files.plan.goal.title"),
|
||||
adds: swarmInputs.filter((input) => input.action === "add").map((input, index) => ({ name: text(input.name, `swarm add ${index}.name`), brief: text(input.brief, `swarm add ${index}.brief`) })),
|
||||
coordinatorUsage: usage ? { total: count(usage.totalTokens, "usage.totalTokens"), input: count(usage.inputTokens, "usage.inputTokens"), output: count(usage.outputTokens, "usage.outputTokens") } : null,
|
||||
plan: {
|
||||
goal: { title: text(goal.title, "files.plan.goal.title"), line: text(goal.line, "files.plan.goal.line") },
|
||||
tasks: Object.fromEntries(Object.entries(tasks).map(([name, value]) => [name, text(value, `files.plan.tasks.${name}`)])),
|
||||
threads: array(planRaw.threads, "files.plan.threads").map((value, index) => {
|
||||
const thread = object(value, `files.plan.threads[${index}]`);
|
||||
return { id: text(thread.id, "thread.id"), title: text(thread.title, "thread.title"), goal: text(thread.goal, "thread.goal"), tasks: array(thread.tasks, "thread.tasks").map((name) => text(name, "thread.tasks[]")) };
|
||||
}),
|
||||
},
|
||||
board,
|
||||
workers,
|
||||
recordedBlock: { helper: text(block.helper, "recordedBlock.helper"), text: text(block.text, "recordedBlock.text") },
|
||||
};
|
||||
}
|
||||
|
||||
export const FIXTURE = parseSwarmFixture(sample);
|
||||
|
||||
function fileName(path?: string): string | undefined {
|
||||
if (!path) return undefined;
|
||||
return path.replace(/^<task-folder>\/?/, "").split("/").pop() || undefined;
|
||||
}
|
||||
|
||||
export function actionLabel(action: SwarmAction): string {
|
||||
if (action.summary) return action.summary;
|
||||
switch (action.tool) {
|
||||
case "read_board": return "Reading the messages";
|
||||
case "swarm_wait": return "Waiting for a message";
|
||||
case "post_message": return "Posting an update";
|
||||
case "write_file": return `Writing ${fileName(action.target) ?? "a file"}`;
|
||||
case "read_file": return `Reading ${fileName(action.target) ?? "a file"}`;
|
||||
case "schedule": return "Setting a stall timer";
|
||||
case "run_command": return "Running a command";
|
||||
default: return "Working";
|
||||
}
|
||||
}
|
||||
|
||||
export function plainBrief(brief: string): string {
|
||||
const first = /^(.+?[.!?])(\s|$)/.exec(brief.replace(/\s+/g, " ").trim())?.[1] ?? brief;
|
||||
return first.replace(/\s*ONLY\b/g, "").replace(/[.!?]$/, "");
|
||||
}
|
||||
|
||||
function roleOf(name: string): HelperRole {
|
||||
if (/^verifier/.test(name)) return "verifier";
|
||||
if (/^monitor/.test(name)) return "monitor";
|
||||
return "helper";
|
||||
}
|
||||
|
||||
export function postKind(author: string, text: string, kind?: string): PostKind {
|
||||
if (kind === "brief") return "brief";
|
||||
if (/\[stall\]/i.test(text)) return "stall";
|
||||
if (/\[blocked\]|permission check failed|timed out waiting/i.test(text)) return "blocked";
|
||||
if (/\[done\]/i.test(text)) return author === "coordinator" ? "finish" : "done";
|
||||
return "update";
|
||||
}
|
||||
|
||||
export function plainPost(text: string): string {
|
||||
return text.replace(/^(@[a-z0-9#_-]+\s*)+/i, "").replace(/\[(done|blocked|stall|update)\]\s*/gi, "").replace(/\s+/g, " ").trim();
|
||||
}
|
||||
|
||||
export function blockedReason(text: string): string {
|
||||
const target = /permission check failed for \w+ "([^"]+)"/i.exec(text)?.[1];
|
||||
return target ? `Blocked: tried to change ${target}, outside the task folder` : "Blocked by the task folder boundary";
|
||||
}
|
||||
|
||||
export const REAL_RUN = {
|
||||
request: FIXTURE.request,
|
||||
title: FIXTURE.title,
|
||||
startedAt: FIXTURE.board[0]!.time,
|
||||
lastSeq: FIXTURE.board[FIXTURE.board.length - 1]!.seq,
|
||||
addedHelpers: FIXTURE.adds,
|
||||
};
|
||||
|
||||
export function boardPost(fixture: SwarmFixture, post: SwarmBoardPost): SwarmPost {
|
||||
return { seq: post.seq, author: post.agent, text: post.text, at: post.time, kind: postKind(post.agent, post.text, post.kind) };
|
||||
}
|
||||
|
||||
export function deriveSwarm(fixture: SwarmFixture, atSeq: number, status: SwarmStatus = "running", extraPosts: SwarmBoardPost[] = []): SwarmView {
|
||||
const lastSeq = fixture.board[fixture.board.length - 1]!.seq;
|
||||
const cutoff = fixture.board.find((post) => post.seq === atSeq) ?? fixture.board[fixture.board.length - 1]!;
|
||||
const until = Date.parse(cutoff.time);
|
||||
const posts = [...fixture.board.filter((post) => post.seq <= atSeq), ...extraPosts].map((post) => boardPost(fixture, post));
|
||||
const verified = posts.some((post) => post.author.startsWith("verifier") && post.kind === "done");
|
||||
const helpers: SwarmHelper[] = fixture.adds.map(({ name, brief }) => {
|
||||
const role = roleOf(name);
|
||||
const worker = fixture.workers[name];
|
||||
const seen = (worker?.actions ?? []).filter((action) => Date.parse(action.at) <= until);
|
||||
const last = seen[seen.length - 1];
|
||||
const own = posts.filter((post) => post.author === name);
|
||||
const latest = own.filter((post) => post.kind === "blocked" || post.kind === "done").pop();
|
||||
const blocked = latest?.kind === "blocked" ? latest : undefined;
|
||||
const posted = own.some((post) => post.kind === "done");
|
||||
let state: HelperState = seen.length ? "working" : "starting";
|
||||
if (role === "monitor") state = "waiting";
|
||||
else if (blocked) state = "blocked";
|
||||
else if (posted && role === "verifier") state = "done";
|
||||
else if (posted) state = verified ? "done" : "in_review";
|
||||
else if (last?.tool === "swarm_wait") state = "waiting";
|
||||
if (status === "stopped" && state !== "done") state = "stopped";
|
||||
const settled = state === "done" || state === "in_review" || state === "stopped";
|
||||
return {
|
||||
name,
|
||||
role,
|
||||
task: fixture.plan.tasks[name] ?? plainBrief(brief),
|
||||
brief: plainBrief(brief),
|
||||
state,
|
||||
action: state === "blocked" ? blockedReason(blocked!.text) : settled ? undefined : role === "monitor" ? "Watching for stalls" : last ? actionLabel(last) : undefined,
|
||||
model: worker?.model,
|
||||
tokens: worker ? { ...worker.tokens } : undefined,
|
||||
};
|
||||
});
|
||||
const turnEnded = status === "completed" && atSeq >= lastSeq;
|
||||
const helperTokens = Object.values(fixture.workers).reduce((sum, worker) => ({ input: sum.input + worker.tokens.input, output: sum.output + worker.tokens.output }), { input: 0, output: 0 });
|
||||
return {
|
||||
request: fixture.request,
|
||||
title: fixture.title,
|
||||
goal: fixture.plan.goal,
|
||||
status,
|
||||
startedAt: fixture.board[0]!.time,
|
||||
helpers,
|
||||
posts,
|
||||
threads: fixture.plan.threads.map((thread) => ({ id: thread.id, title: thread.title, goal: thread.goal, helpers: thread.tasks })),
|
||||
usage: turnEnded && fixture.coordinatorUsage ? { ...fixture.coordinatorUsage, helpers: helperTokens } : undefined,
|
||||
model: fixture.model,
|
||||
files: turnEnded ? fixture.filesChanged : undefined,
|
||||
};
|
||||
}
|
||||
|
||||
export function deriveRealSwarm(atSeq: number, status: SwarmStatus = "running", extraPosts: SwarmBoardPost[] = []): SwarmView {
|
||||
return deriveSwarm(FIXTURE, atSeq, status, extraPosts);
|
||||
}
|
||||
|
||||
export interface SwarmProgress {
|
||||
done: number;
|
||||
inReview: number;
|
||||
blocked: number;
|
||||
total: number;
|
||||
threadsOpen: number;
|
||||
}
|
||||
|
||||
function members(view: SwarmView, thread: SwarmThread): SwarmHelper[] {
|
||||
return thread.helpers
|
||||
.map((name) => view.helpers.find((helper) => helper.name === name))
|
||||
.filter((helper): helper is SwarmHelper => Boolean(helper && helper.role !== "monitor"));
|
||||
}
|
||||
|
||||
export function swarmProgress(view: SwarmView): SwarmProgress {
|
||||
const workers = view.helpers.filter((helper) => helper.role !== "monitor");
|
||||
return {
|
||||
done: workers.filter((helper) => helper.state === "done").length,
|
||||
inReview: workers.filter((helper) => helper.state === "in_review").length,
|
||||
blocked: workers.filter((helper) => helper.state === "blocked").length,
|
||||
total: workers.length,
|
||||
threadsOpen: view.threads.filter((thread) => members(view, thread).some((helper) => helper.state !== "done")).length,
|
||||
};
|
||||
}
|
||||
|
||||
export function progressLine(view: SwarmView): string {
|
||||
const progress = swarmProgress(view);
|
||||
const parts = [`${progress.done} of ${progress.total} done`];
|
||||
if (progress.inReview) parts.push(`${progress.inReview} in review`);
|
||||
if (progress.blocked) parts.push(`${progress.blocked} blocked`);
|
||||
if (view.threads.length) parts.push(`${progress.threadsOpen} ${progress.threadsOpen === 1 ? "thread" : "threads"} open`);
|
||||
return parts.join(" · ");
|
||||
}
|
||||
|
||||
export function threadState(view: SwarmView, thread: SwarmThread): HelperState {
|
||||
const list = members(view, thread);
|
||||
if (list.some((helper) => helper.state === "blocked")) return "blocked";
|
||||
if (list.length && list.every((helper) => helper.state === "done")) return "done";
|
||||
if (list.some((helper) => helper.state === "stopped")) return "stopped";
|
||||
if (list.some((helper) => helper.state === "working" || helper.state === "starting")) return "working";
|
||||
if (list.some((helper) => helper.state === "in_review")) return "in_review";
|
||||
return "waiting";
|
||||
}
|
||||
|
||||
export function threadNow(view: SwarmView, thread: SwarmThread): string {
|
||||
const list = members(view, thread);
|
||||
const blocked = list.find((helper) => helper.state === "blocked");
|
||||
if (blocked) return `${blocked.name} is blocked`;
|
||||
const active = list.find((helper) => helper.state === "working" && helper.action);
|
||||
if (active) return `${active.name}: ${active.action}`;
|
||||
if (list.length && list.every((helper) => helper.state === "done")) return "Delivered";
|
||||
if (list.some((helper) => helper.state === "in_review")) return "Waiting for the verifier";
|
||||
return "Waiting";
|
||||
}
|
||||
|
||||
export function threadCount(view: SwarmView, thread: SwarmThread): string {
|
||||
const list = members(view, thread);
|
||||
return `${list.filter((helper) => helper.state === "done").length}/${list.length}`;
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
import { FIXTURE, REAL_RUN, deriveRealSwarm, plainBrief, type SwarmHelper, type SwarmPost, type SwarmView } from "./swarm-model";
|
||||
|
||||
export const REQUEST = "Build a tiny static unit-converter page in this folder: page, styles, conversion logic and a README, then have it checked.";
|
||||
|
||||
export function starting(): SwarmView {
|
||||
const view = deriveRealSwarm(6, "starting");
|
||||
return { ...view, request: REQUEST, helpers: view.helpers.map((helper) => ({ ...helper, state: helper.role === "monitor" ? "waiting" : "starting", action: undefined })) };
|
||||
}
|
||||
|
||||
export function running(): SwarmView {
|
||||
return { ...deriveRealSwarm(8, "running"), request: REQUEST };
|
||||
}
|
||||
|
||||
export function runningWithBlocked(): SwarmView {
|
||||
const at = FIXTURE.board.find((post) => post.seq === 8)!.time;
|
||||
const recorded = { seq: 9, agent: FIXTURE.recordedBlock.helper, text: FIXTURE.recordedBlock.text, time: at };
|
||||
return { ...deriveRealSwarm(8, "running", [recorded]), request: REQUEST };
|
||||
}
|
||||
|
||||
export function stopping(): SwarmView {
|
||||
return { ...running(), status: "stopping" };
|
||||
}
|
||||
|
||||
export function stopped(): SwarmView {
|
||||
return { ...deriveRealSwarm(8, "stopped"), request: REQUEST, reason: "You stopped the swarm. Files the helpers already wrote stay in the task folder." };
|
||||
}
|
||||
|
||||
export function failed(): SwarmView {
|
||||
return {
|
||||
...deriveRealSwarm(8, "stopped"),
|
||||
request: REQUEST,
|
||||
status: "failed",
|
||||
reason: "The helpers did not finish in time, so Paperclip stopped the swarm. Files they already wrote stay in the task folder.",
|
||||
};
|
||||
}
|
||||
|
||||
export function refused(): SwarmView {
|
||||
return {
|
||||
...deriveRealSwarm(0, "refused"),
|
||||
request: REQUEST,
|
||||
helpers: [],
|
||||
posts: [],
|
||||
threads: [],
|
||||
reason: "Swarm is not available with this Google connection: helpers can only change files in Antigravity's auto mode, which this sign-in does not offer.",
|
||||
};
|
||||
}
|
||||
|
||||
export function completed(): SwarmView {
|
||||
return { ...deriveRealSwarm(REAL_RUN.lastSeq, "completed"), request: REQUEST };
|
||||
}
|
||||
|
||||
const LONG_HELPERS: Array<[string, string, string, SwarmHelper["state"], string | undefined]> = [
|
||||
["api-profiler", "Profile the task list endpoint", "t-api", "done", undefined],
|
||||
["query-tuner", "Cut the task list query to one round trip", "t-api", "in_review", undefined],
|
||||
["cache-writer", "Cache project and label lookups", "t-api", "working", "Running server tests for the label cache"],
|
||||
["ui-virtualizer", "Render only visible task rows", "t-ui", "working", "Writing TaskListRows.tsx"],
|
||||
["bundle-trimmer", "Split the task list bundle", "t-ui", "blocked", "Blocked: tried to change a file outside the task folder"],
|
||||
["skeleton-writer", "Show a stable loading skeleton", "t-ui", "done", undefined],
|
||||
["bench-writer", "Add a cold-load benchmark", "t-proof", "working", "Running the cold-load benchmark 5 times"],
|
||||
["docs-writer", "Note the new limits in the docs", "t-proof", "waiting", undefined],
|
||||
["verifier-api", "Check server changes and tests", "t-proof", "working", "Reading query-tuner's diff in #23"],
|
||||
["verifier-ui", "Check UI changes in both themes", "t-proof", "waiting", undefined],
|
||||
["monitor", "Watch for stalls", "t-proof", "waiting", "Watching for stalls"],
|
||||
];
|
||||
|
||||
const LONG_POSTS: Array<[string, string]> = [
|
||||
["api-profiler", "@coordinator [done] p95 is 2.4s: 61% in the label join, 22% serialising 900 rows, rest is auth"],
|
||||
["coordinator", "@query-tuner @cache-writer see #12 for the profile"],
|
||||
["skeleton-writer", "@verifier-ui [done] skeleton keeps the row height; no layout shift in the trace"],
|
||||
["query-tuner", "@verifier-api [done] task list now loads labels with one joined query; 2.4s to 0.9s locally"],
|
||||
["bundle-trimmer", "@coordinator [blocked] permission check failed for write_file \"../vendor/router.patch\": the prompt timed out waiting for user response after 60s"],
|
||||
["coordinator", "@bundle-trimmer keep the split inside the task folder; do not patch vendor files"],
|
||||
["cache-writer", "@verifier-api cache keys are scoped per company; running the server tests now"],
|
||||
["ui-virtualizer", "@skeleton-writer I reuse your row height token for the virtual list"],
|
||||
["verifier-ui", "@skeleton-writer looks right in light and dark; one gap at 360px, see screenshot"],
|
||||
["skeleton-writer", "@verifier-ui [done] fixed the 360px gap"],
|
||||
["bench-writer", "@coordinator first cold loads: 3.1s, 2.9s; waiting on query-tuner and cache-writer"],
|
||||
["monitor", "@coordinator [stall] docs-writer and verifier-ui have waited 6 minutes with nothing assigned"],
|
||||
["coordinator", "@docs-writer start the limits note from #23"],
|
||||
["verifier-api", "@query-tuner reading your diff now; one question about the label index"],
|
||||
];
|
||||
|
||||
export function longSwarm(): SwarmView {
|
||||
const at = REAL_RUN.startedAt;
|
||||
const briefs: SwarmPost[] = LONG_HELPERS.map(([name, task], index) => ({ seq: index + 1, author: "coordinator", text: `@${name} ${task}.`, at, kind: "brief" }));
|
||||
const posts: SwarmPost[] = LONG_POSTS.map(([author, text], index) => ({
|
||||
seq: briefs.length + index + 1,
|
||||
author,
|
||||
text,
|
||||
at,
|
||||
kind: /\[stall\]/.test(text) ? "stall" : /\[blocked\]/.test(text) ? "blocked" : /\[done\]/.test(text) ? "done" : "update",
|
||||
}));
|
||||
return {
|
||||
request: "The task list takes over two seconds on a cold load. Get it under one second without changing what it shows.",
|
||||
title: "Task list under one second",
|
||||
goal: { title: "Get the task list under one second", line: "Query and skeleton landed; virtual list and bundle split in progress." },
|
||||
status: "running",
|
||||
startedAt: at,
|
||||
helpers: LONG_HELPERS.map(([name, task, , state, action]) => ({
|
||||
name,
|
||||
role: name.startsWith("verifier") ? "verifier" : name === "monitor" ? "monitor" : "helper",
|
||||
task,
|
||||
brief: plainBrief(task),
|
||||
state,
|
||||
action,
|
||||
model: "gemini-4-neon-high",
|
||||
})),
|
||||
posts: [...briefs, ...posts],
|
||||
threads: [
|
||||
{ id: "t-api", title: "Faster task query", goal: "One round trip, cached lookups", helpers: ["api-profiler", "query-tuner", "cache-writer"] },
|
||||
{ id: "t-ui", title: "Lighter task page", goal: "Render less, load less", helpers: ["ui-virtualizer", "bundle-trimmer", "skeleton-writer"] },
|
||||
{ id: "t-proof", title: "Proof and docs", goal: "Benchmarked, checked and written down", helpers: ["bench-writer", "docs-writer", "verifier-api", "verifier-ui", "monitor"] },
|
||||
],
|
||||
model: "Gemini 4 Neon",
|
||||
synthetic: true,
|
||||
};
|
||||
}
|
||||
|
||||
export const TODAY_STEPS: string[] = [
|
||||
"Swarm started in the task folder with Gemini 4 Neon. Helper changes inside the task folder are approved automatically; anything else is blocked.",
|
||||
`Swarm: ${REAL_RUN.title}`,
|
||||
...REAL_RUN.addedHelpers.map(({ name, brief }) => (/^monitor$/i.test(name) ? "Started a helper that watches for stalls" : `Started helper ${name}: ${plainBrief(brief)}`)),
|
||||
"Checked on the helpers",
|
||||
"Checked on the helpers",
|
||||
"Coordinator: Static unit-converter page built and verified (index.html, style.css, convert.js, README.md)",
|
||||
"Files changed in the task folder: README.md, convert.js, index.html, style.css",
|
||||
"Token usage is the coordinator's total and includes the helpers; Google does not report it per helper",
|
||||
];
|
||||
Reference in new issue
Block a user