@terreno/mcp 57.11.0 → 57.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/docs/upgrades/57.12.0.md +89 -0
  2. package/dist/docs/upgrades/57.13.0.md +75 -0
  3. package/dist/docs/versioned/next/explanation/README.md +1 -1
  4. package/dist/docs/versioned/next/explanation/agent-ui-blocks.md +69 -9
  5. package/dist/docs/versioned/next/explanation/ai-workflows.md +4 -3
  6. package/dist/docs/versioned/next/explanation/example-coverage.md +3 -3
  7. package/dist/docs/versioned/next/explanation/roadmap-process.md +4 -2
  8. package/dist/docs/versioned/next/explanation/roadmap-seed-issues.md +12 -0
  9. package/dist/docs/versioned/next/how-to/README.md +2 -0
  10. package/dist/docs/versioned/next/how-to/agent-ui-blocks.md +187 -3
  11. package/dist/docs/versioned/next/how-to/circleci.md +8 -2
  12. package/dist/docs/versioned/next/how-to/github-actions-ci.md +5 -6
  13. package/dist/docs/versioned/next/how-to/preview-demo.md +5 -5
  14. package/dist/docs/versioned/next/how-to/rate-limiting.md +17 -0
  15. package/dist/docs/versioned/next/how-to/test-ui-accessibility.md +35 -0
  16. package/dist/docs/versioned/next/implementationPlans/agent-ui-rich-replies.md +359 -0
  17. package/dist/docs/versioned/next/reference/README.md +1 -1
  18. package/dist/docs/versioned/next/reference/admin-backend.md +26 -0
  19. package/dist/docs/versioned/next/reference/admin-frontend.md +15 -0
  20. package/dist/docs/versioned/next/reference/ai-harness.md +33 -5
  21. package/dist/docs/versioned/next/reference/ai.md +88 -7
  22. package/dist/docs/versioned/next/reference/api.md +4 -0
  23. package/dist/docs/versioned/next/reference/blocks.md +243 -11
  24. package/dist/docs/versioned/next/reference/environment-variables.md +3 -0
  25. package/dist/docs/versioned/next/reference/ui.md +222 -12
  26. package/dist/docs/versioned/next/tasks/agent-ui-rich-replies.md +188 -0
  27. package/package.json +3 -3
  28. package/src/docs/upgrades/57.12.0.md +89 -0
  29. package/src/docs/upgrades/57.13.0.md +75 -0
  30. package/src/docs/versioned/next/explanation/README.md +1 -1
  31. package/src/docs/versioned/next/explanation/agent-ui-blocks.md +69 -9
  32. package/src/docs/versioned/next/explanation/ai-workflows.md +4 -3
  33. package/src/docs/versioned/next/explanation/example-coverage.md +3 -3
  34. package/src/docs/versioned/next/explanation/roadmap-process.md +4 -2
  35. package/src/docs/versioned/next/explanation/roadmap-seed-issues.md +12 -0
  36. package/src/docs/versioned/next/how-to/README.md +2 -0
  37. package/src/docs/versioned/next/how-to/agent-ui-blocks.md +187 -3
  38. package/src/docs/versioned/next/how-to/circleci.md +8 -2
  39. package/src/docs/versioned/next/how-to/github-actions-ci.md +5 -6
  40. package/src/docs/versioned/next/how-to/preview-demo.md +5 -5
  41. package/src/docs/versioned/next/how-to/rate-limiting.md +17 -0
  42. package/src/docs/versioned/next/how-to/test-ui-accessibility.md +35 -0
  43. package/src/docs/versioned/next/implementationPlans/agent-ui-rich-replies.md +359 -0
  44. package/src/docs/versioned/next/reference/README.md +1 -1
  45. package/src/docs/versioned/next/reference/admin-backend.md +26 -0
  46. package/src/docs/versioned/next/reference/admin-frontend.md +15 -0
  47. package/src/docs/versioned/next/reference/ai-harness.md +33 -5
  48. package/src/docs/versioned/next/reference/ai.md +88 -7
  49. package/src/docs/versioned/next/reference/api.md +4 -0
  50. package/src/docs/versioned/next/reference/blocks.md +243 -11
  51. package/src/docs/versioned/next/reference/environment-variables.md +3 -0
  52. package/src/docs/versioned/next/reference/ui.md +222 -12
  53. package/src/docs/versioned/next/tasks/agent-ui-rich-replies.md +188 -0
@@ -0,0 +1,35 @@
1
+ # Test UI accessibility
2
+
3
+ Run the WCAG scanner against every changed rendered state:
4
+
5
+ ```bash
6
+ bun run accessibility:scan \
7
+ "http://localhost:8085/dev/Theme?story=ThemeComponent&theme=light" \
8
+ "http://localhost:8085/dev/Theme?story=ThemeComponent&theme=dark"
9
+ ```
10
+
11
+ The scanner applies axe rules tagged WCAG 2.0 A/AA, WCAG 2.1 A/AA, and WCAG
12
+ 2.2 AA. It writes a JSON report and full-page screenshots under
13
+ `/opt/cursor/artifacts/accessibility/` and exits nonzero when any violation is
14
+ found.
15
+
16
+ ## Verify what automation cannot
17
+
18
+ 1. Use only the keyboard to reach and operate each changed control.
19
+ 2. Confirm focus order and the visible focus indicator match the visual order.
20
+ 3. Inspect each control's accessible name, role, state, and error relationship.
21
+ 4. Check light and dark modes, plus loading, empty, disabled, and error states
22
+ affected by the change.
23
+ 5. At 200% browser zoom, confirm content remains usable without clipping or
24
+ losing actions.
25
+
26
+ Automated scans do not prove keyboard behavior, announcement quality, reading
27
+ order, or whether alternative text conveys the intended meaning. Record those
28
+ manual checks with the automated report in the pull request Verification table.
29
+
30
+ ## Fixing findings
31
+
32
+ Fix violations in the changed feature before submission. If a finding is
33
+ pre-existing and outside the changed path, capture a baseline on an unaffected
34
+ route and name both routes in the pull request. Do not suppress an axe rule
35
+ without a linked issue and a documented reason.
@@ -0,0 +1,359 @@
1
+ # Agent UI Rich Replies: steppers, checklists, galleries, and copy
2
+
3
+ **Status:** approved 2026-10-07
4
+ **Task list:** [`docs/tasks/agent-ui-rich-replies.md`](../tasks/agent-ui-rich-replies.md)
5
+ **Supporting skills:** `terreno-ui`, `terreno-backend-api`, `ai-prompt-governance`, `update-docs`, `verify-ui-changes`, `backend-test-env`
6
+ **Source:** OpenAI, "GPT-6 and Intelligent UI for everyone", the "Planning a Sunday roast" GPT-5.6 vs GPT-6 Instant comparison (fetched 2026-10-07).
7
+
8
+ Terreno agents can already reply with whole-reply YAML block documents: headings, markdown,
9
+ metrics, cards, charts, dataset tables, images, callouts, and buttons that reply, open,
10
+ select, or call a host callback. OpenAI's GPT-6 launch shows a meal-plan reply that goes
11
+ further: a summary card at the top, a three-photo collage, a photo menu list, a guest-count
12
+ stepper that recalculates the shopping list, a "Copy shopping list" button, and a timed
13
+ cooking checklist with a "1 of 8" counter. The GPT-5.6 version beside it uses a markdown
14
+ "How much lamb?" table. This plan adds the missing pieces, so a Terreno agent can
15
+ return both replies. The new blocks are on by default (D6); a host whose shipped clients cannot render them yet sets `uiBlocks.richBlocks: false`.
16
+
17
+ ## The idea
18
+
19
+ Six additions to the closed block catalog in `@terreno/blocks`, each rendered by
20
+ `BlocksView` with `@terreno/ui` components:
21
+
22
+ | Demo element | Terreno block | Interaction |
23
+ | --- | --- | --- |
24
+ | "Your dinner plan" summary with a small label above the title | `card.eyebrow` (new optional field) | none |
25
+ | Three grouped hero photos | `gallery` (2–6 images, optional captions) | none |
26
+ | Menu items: photo, bold title, description | `list` (items with optional image) | none |
27
+ | Guest count − / + with recalculated quantities | `stepper` | **host callback round trip** |
28
+ | "Copy shopping list" | `copy` action kind on a button | on the device (clipboard) |
29
+ | Cooking checklist with times and "n of m" | `checklist` | **host callback per tick** (local when the host has no checklist action) |
30
+ | "How much lamb?" guests table | `table` renders typed columns; markdown tables in `text` get theme styling | none |
31
+
32
+ The stepper follows the decision made in chat: **− and + are callback buttons like the
33
+ existing ones.** A tap sends `POST /gpt/actions` with the stepper's callback name and
34
+ `{...callback.payload, value: <next>}`. The host action returns
35
+ `{replace: "block", blocks: {v: 1, blocks: [<new stepper>]}}`, and `GPTChat` swaps the block by
36
+ id through `overrides`, as it does today. `@terreno/ai` ships an opt-in host action,
37
+ `scaleStepperHostAction`. It reads the stepper the agent wrote from the stored history, not
38
+ from the tap request, and scales every item linearly from it. Scaling from the agent's
39
+ original keeps rounding from drifting tap after tap. The owner of a history can still edit
40
+ its stored prompts through `PATCH /gpt/histories/:id`, so an app whose numbers matter
41
+ (prices, stock) must compute them from its own data, not from the stored block.
42
+
43
+ ```yaml
44
+ - type: card
45
+ eyebrow: How much should you buy?
46
+ children:
47
+ - type: stepper
48
+ id: guests
49
+ label: Number of people
50
+ unit: People
51
+ value: 5
52
+ min: 1
53
+ max: 20
54
+ callback: {name: scaleStepper}
55
+ items:
56
+ - {label: Bone-in leg of lamb, amount: 2, unit: kg, decimals: 1}
57
+ - {label: Carrots, amount: 8, round: up}
58
+ note: Generous portions, with a little extra.
59
+ - type: actions
60
+ id: copy_list
61
+ elements:
62
+ - {type: button, id: copy, text: Copy shopping list, action: {kind: copy, target: guests}}
63
+ ```
64
+
65
+ The checklist works the same way (D2). Each tick sends a callback with the full set of ticks,
66
+ and `toggleChecklistHostAction` returns the checklist with those ticks. Photos (D3) come from
67
+ a library of images generated once with the Vertex image model and stored through
68
+ `FileStorageService`. The agent picks from it with a `findPhotos` tool and writes `file:` ids.
69
+
70
+ Rejected: a shared document `state` with `{{formula}}` bindings computed on the device.
71
+ It needs an expression language, and the human chose a server round trip.
72
+
73
+ ## The plan
74
+
75
+ | # | Task | Depends on | Lands in | Proves it |
76
+ | --- | --- | --- | --- | --- |
77
+ | T1 | Stepper block round trips through a host callback (tracer) | none | blocks, ui, ai | fixture, renderer, handler, and route tests |
78
+ | T2 | Prompt offers the new blocks only when the host opts in | T1 | blocks, ai | prompt + chat-turn tests |
79
+ | T3 | Table block renders typed columns | T1 | ui | `DataTable` + `BlocksView` tests |
80
+ | T4 | Markdown tables in `text` get theme styling | T3 | ui | `MarkdownView` test |
81
+ | T5 | `checklist` contract | T2 | blocks | fixtures |
82
+ | T6 | `gallery` contract | T5 | blocks | fixtures + image-host lint |
83
+ | T7 | `list` contract | T6 | blocks | fixtures + image-host lint |
84
+ | T8 | `card.eyebrow` contract | T7 | blocks | fixtures |
85
+ | T9 | `copy` action contract + `blockPlainText` | T8 | blocks | fixtures + serializer tests |
86
+ | T10 | Checklist renders and toggles | T3, T4, T5 | ui | `BlocksView` test |
87
+ | T11 | Gallery renders | T6, T10 | ui | `BlocksView` test |
88
+ | T12 | List renders | T7, T11 | ui | `BlocksView` test |
89
+ | T13 | Card eyebrow renders | T8, T12 | ui | `BlocksView` test |
90
+ | T14 | Copy action writes the clipboard | T9, T13 | ui | `BlocksView` test |
91
+ | T15 | Sunday roast golden document + playground story | T14 | blocks, demo | fixture + story screenshot |
92
+ | T16 | Example app: the roast reply against the real callback routes | T15, T20, T21 | example-backend, example-frontend | Playwright + recording |
93
+ | T17 | Model smoke: a real model writes the roast reply | T15, T20 | example-backend | smoke script output |
94
+ | T18 | Docs sweep, changelog, rules | T15, T20, T21 | docs, rules | `website:build`, `rules:check` |
95
+ | T19 | Generated photo library: generate images once and store them | none | example-backend | model + script tests |
96
+ | T20 | `findPhotos` tool and photo URLs in the example app | T19 | example-backend, example-frontend | tool + action tests |
97
+ | T21 | Checklist ticks round trip through a host callback | T10 | ai | handler + route tests |
98
+
99
+ Tracer: T1, from the agent's YAML through `validateBlocks`, `BlocksView`, the callback
100
+ event, `POST /gpt/actions`, and `scaleStepperHostAction`, back to a replaced block.
101
+ Out of scope: formulas or shared state, scripted html, persisting overrides, maps, tabs,
102
+ interactive diagrams, generated tools (see Expansions).
103
+ Open risks:
104
+ - Each tap is one round trip. `pendingElementIds` disables both buttons until the reply
105
+ lands, so fast taps are dropped, not queued (Q4).
106
+ - `scaleStepperHostAction` finds the agent's block by `messageId`, which is `msg-<index>`
107
+ when the host sets no message id. When that misses, it uses the only assistant prompt that
108
+ holds a stepper with that `blockId`. If more than one does, it returns 409 rather than
109
+ guess.
110
+ - Stored history prompts are writable by their owner, so the stored stepper is not a trust
111
+ boundary (see the idea above; the how-to says so).
112
+
113
+ ## Contracts
114
+
115
+ Field names are the contract. Limits go in `BLOCK_LIMITS` and are printed in the prompt
116
+ from there. Lint paths use the existing `blocks[0].images[2].src` form.
117
+
118
+ ### `stepper` (T1)
119
+
120
+ | Field | Required | Rule |
121
+ | --- | --- | --- |
122
+ | `id` | yes | block id pattern, at most 54 characters (room for the `_increase` suffix) |
123
+ | `label` | yes | 1–80 |
124
+ | `value`, `min`, `max` | yes | numbers; `min` < `max`; `min` ≤ `value` ≤ `max` (`OUT_OF_RANGE`) |
125
+ | `step` | no | > 0, default 1 |
126
+ | `unit` | no | 1–40, shown under the value ("People") |
127
+ | `callback` | yes | `{name, payload?}`; `name` is checked by `UNKNOWN_HOST_ACTION` when `hostActions` is passed |
128
+ | `itemsTitle` | no | 1–80, a small heading above the items ("Your shopping quantities") |
129
+ | `items` | no | 0–12 of `{label (1–80), amount (number), unit? (1–20), decimals? (0–3, default 0), round?: nearest \| up (default nearest)}` |
130
+ | `note` | no | 1–280, muted under the items |
131
+
132
+ The renderer reserves the element ids `<id>_decrease` and `<id>_increase`. Lint reports
133
+ `DUPLICATE_ID` when any other block or element uses them.
134
+
135
+ Rendering: the label as an eyebrow, `IconButton` − and +, then the value with its unit,
136
+ `itemsTitle`, the items as a two-column label / amount grid formatted with `decimals` ("2.0 kg"), then the
137
+ note. − is disabled when one more step would go below `min`, + when it would go above `max`.
138
+ Both are disabled while either element is pending,
139
+ and when `callback.name` is not in `hostActions`. Accessible labels: "Decrease <label>",
140
+ "Increase <label>".
141
+
142
+ Callback event: `blockId: <id>`, `elementId: <id>_increase` or `<id>_decrease`, action
143
+ `{kind: "callback", name, payload: {...payload, value: value ± step}}`.
144
+
145
+ `scaleStepperHostAction` (in `@terreno/ai`) is `{handler, payload, handles: "stepper", logResponse: false}`. Its `payload` schema is `z.object({value: z.number()}).passthrough()`, and the handler reads only `value`.
146
+
147
+ 1. Loads the stepper the agent wrote with `findAgentBlock({history, messageId, blockId, type})`,
148
+ a shared helper (`ai/src/service/agentBlocks.ts`). It reads `history.prompts[n]` when
149
+ `messageId` is `msg-<n>` (stored prompts have no ids), parses it with `parseBlocks`, and
150
+ finds the block of that type whose id is `blockId`. When that misses, it uses the only
151
+ assistant prompt holding such a block. With more than one, it returns 409. With none, 404.
152
+ 2. Checks that `value` is a number within `[min, max]` on the `step` grid. Anything else
153
+ returns 400.
154
+ 3. Returns `{replace: "block", blocks: {v: 1, blocks: [stepper]}}`. The returned stepper has
155
+ the new `value`, and each item's `amount` is `original amount × value / original value`,
156
+ rounded by that item's `decimals` and `round`.
157
+
158
+ `logResponse: false` is a new optional host-action field. With it, the `AIRequest` row for
159
+ `POST /gpt/actions` keeps today's ids-only prompt, adds the numeric `value`, and leaves out
160
+ the returned block. Every other host action keeps logging the full response, as today.
161
+
162
+ ### Default on, with an opt-out (T2)
163
+
164
+ | Option | Effect |
165
+ | --- | --- |
166
+ | `uiBlocks.richBlocks` (default `true`) | The prompt offers `checklist`, `gallery`, `list`, `card.eyebrow`, and `copy`. `false` removes them. |
167
+ | `richBlocks` on **and** a host action with `handles: "stepper"` | The prompt offers `stepper` and names those actions as its callbacks. Without a stepper action, the prompt never mentions `stepper`, because its buttons would be dead. |
168
+ | `richBlocks` on **and** a host action with `handles: "checklist"` | The checklist prompt line tells the model to set `callback` to that action. Without one, it says to leave `callback` out (ticks stay local). |
169
+
170
+ `blocksPromptSection` gains `richBlocks` (default `true`, matching the server), `stepperActions`, and `checklistActions`.
171
+ `validateBlocks` gains the same two lists: a stepper or checklist whose `callback.name` is not
172
+ in its list fails `UNKNOWN_HOST_ACTION`. `chatTurn` derives both lists from the host actions'
173
+ `handles` field. The server always accepts the new blocks when it validates. The
174
+ opt-out only stops the model from writing them for clients that cannot render them yet.
175
+
176
+ Upgrading changes behaviour: every host with `uiBlocks` on gets the new blocks in its prompt
177
+ after the bump. The changelog entry says so under a "Behaviour change" heading and names
178
+ `richBlocks: false` as the opt-out.
179
+
180
+ ### `checklist` (T5)
181
+
182
+ `{type: checklist, id (at most 31 characters), title? (1–120), callback?: {name, payload?}, items: 1–30 of {id (at most 32 characters), text (1–120), detail? (1–280), meta? (1–40), checked?: boolean}}`.
183
+ Item ids are unique. The element id of a tick is `<id>_<item id>`, reserved like the stepper's
184
+ (`DUPLICATE_ID`). Rendering: the title on the left and "n of m" on the right, then one
185
+ `CheckBox` row per item: the bold `text` first, then `meta` (the time, small and muted), then a muted
186
+ `detail` (D7).
187
+
188
+ With a `callback`, an `onAction` handler, and either no `hostActions` list or one that names the
189
+ callback (matching the stepper), a tick sends
190
+ `{kind: "callback", name, payload: {...payload, itemId, checked, state: {<item id>: boolean, ...}}}`
191
+ with `blockId: <id>` and `elementId: <id>_<item id>`. `state` is the full set of ticks after
192
+ this one, because overrides live only in the client (D4). The whole checklist is disabled until
193
+ the reply lands, so a second tick cannot send a `state` that misses the first, and the checklist
194
+ then shows the returned block. Ticks are not applied ahead of
195
+ the reply. Without a `callback`, without `onAction`, or when a `hostActions` list leaves the name
196
+ out, ticks are local.
197
+
198
+ `toggleChecklistHostAction` (in `@terreno/ai`, T21) is `{handler, payload, handles: "checklist", logResponse: false}`
199
+ with payload `z.object({itemId: z.string(), checked: z.boolean(), state: z.record(z.string(), z.boolean())}).passthrough()`.
200
+ It loads the agent's checklist with `findAgentBlock`, rejects item ids the checklist does not
201
+ have (400), and returns `{replace: "block", blocks: {v: 1, blocks: [checklist]}}` with
202
+ `checked` set from `state`. Apps that record progress register their own `handles: "checklist"`
203
+ action.
204
+
205
+ ### `gallery` (T6)
206
+
207
+ `{type: gallery, id?, images: 2–6 of {src, alt (1–200), caption? (1–120)}}`. Each `src` follows
208
+ the `image` rules, including `IMAGE_HOST_NOT_ALLOWED`. Rendering: up to 3 images sit in one
209
+ row of equal 4:3 tiles; more than 3 wrap into a 3-column grid. Narrow screens scroll the row
210
+ sideways (Q5).
211
+
212
+ ### `list` (T7)
213
+
214
+ `{type: list, id?, items: 1–12 of {title (1–120), text? (1–500, plain text), meta? (1–40), image?: {src, alt}}}`.
215
+ Image sources follow the `image` rules. Rendering: a 3:4 portrait thumbnail on the left,
216
+ then the bold title and muted text.
217
+
218
+ ### `card.eyebrow` (T8)
219
+
220
+ Optional `eyebrow` (1–60) on `card`, rendered small and muted above `title`.
221
+
222
+ ### Generated photo library (T19, T20)
223
+
224
+ The agent cannot make photos on the fly, and `https` images need an allowlist. So the example
225
+ app generates a library once and stores it.
226
+
227
+ | Piece | Contract |
228
+ | --- | --- |
229
+ | `PhotoLibraryEntry` model (example-backend) | `{fileAttachmentId, gcsKey, alt (1–200), tags: string[] (1–12), prompt}`, every field with a `description`; `createdUpdatedPlugin`, `isDeletedPlugin`; `prompt` is unique. A soft-deleted entry still holds its prompt, and `--force` leaves the old stored object and its `FileAttachment` behind |
230
+ | `bun run photos:generate` (example-backend script) | Reads `src/scripts/photoPrompts.ts` (about 12 entries: roast lamb, crispy potatoes, honey carrots and parsnips, lemony greens, apple crumble, a laid table, and so on). It runs each through AI SDK `generateImage` with the Vertex image model (`imagen-4.0-fast-generate-001` unless `PHOTO_IMAGE_MODEL` is set), uploads it with `FileStorageService.upload` as a system user, and upserts a `PhotoLibraryEntry` by `prompt`. Re-runs skip prompts that already exist unless `--force` is passed. Requires `GOOGLE_VERTEX_PROJECT`, Application Default Credentials for Vertex, and `GCS_BUCKET`, validated up front; `GOOGLE_VERTEX_LOCATION` (default `us-central1`) picks a regional endpoint for Imagen. Uploads are owned by a find-or-create system user `photo-library@system.invalid`. A failed prompt is logged, the run continues, and the exit code is 1 if any failed |
231
+ | `findPhotos({query, count})` tool | Matches `query` words against `tags` and `alt`, and returns up to `count` (1–6) `{src: "file:<entry id>", alt}` |
232
+ | `photoLibrary` `modelRouter` with an instance action `url` | `GET /photoLibrary/:id/url` returns `{url}` (a `FileStorageService.getSignedUrl`) to any authenticated user. The library is shared, so the per-user `GET /files/*` route does not fit. List and read are `IsAuthenticated`; create, update, and delete are disabled |
233
+ | example-frontend `resolveImage` | Resolves `file:<id>` through the generated SDK hook for `url` |
234
+
235
+ The library holds only generated food photos, no user data.
236
+
237
+ ### `copy` action (T9)
238
+
239
+ A new `action.kind`: `{kind: copy, text?, target?}`. Lint requires exactly one of the two,
240
+ reporting `MISSING_REQUIRED` as it does for `open`. `target` must name a `stepper`,
241
+ `checklist`, `list`, `table`, or `text` block (`COPY_TARGET_INVALID`). `text` holds at most
242
+ 4,000 characters (`copyTextMaxLength`); `target` is a block id.
243
+ `blockPlainText(block, {datasets?, checked?})` in `@terreno/blocks` turns a block into the
244
+ copied text:
245
+
246
+ | Block | Text |
247
+ | --- | --- |
248
+ | `stepper` | `<label>: <value> <unit>`, then one `<item label>: <amount> <unit>` line per item |
249
+ | `checklist` | one `[x] text` or `[ ] text` line per item, using the current toggles |
250
+ | `list` | one `- title: text` line per item |
251
+ | `table` | a header row, then the rows, tab-separated |
252
+ | `text` | the markdown as written |
253
+
254
+ `BlocksView` copies the text from the **current** block, with the override and toggles applied,
255
+ using `expo-clipboard`. It then shows "Copied" in a polite live region next to the button for
256
+ 2 s. It does not call `onAction` or the server.
257
+
258
+ ### Tables (T3, T4)
259
+
260
+ T3: `DataTable` gets real `number` and `date` cells. `number` is right-aligned. `date` is
261
+ formatted with Luxon (`DateTime.fromISO(...).toLocaleString(DateTime.DATE_MED)`). The
262
+ `table` block renderer stops forcing every column to `text` and `width: 120`. It maps the
263
+ dataset's column types to these cells. It measures the container with `onLayout` and splits
264
+ the width evenly, at least 96 per column, scrolling sideways past that. Number headers
265
+ right-align to match their cells. Headers show column names with underscores as spaces, and the
266
+ copied header row does the same. The table sits in a frame sized to its header plus rows (54
267
+ each, up to 10 rows), so it never spills over the next block; longer tables scroll inside it.
268
+
269
+ T4: `react-native-markdown-display` already lays GFM tables out as views. T4 adds theme
270
+ styling: `border.default` cell borders, a bold header row on `surface.secondaryLight`, and
271
+ horizontal scroll when the table is wider than its container. Its test fails on `master`
272
+ first.
273
+
274
+ ## Acceptance criteria
275
+
276
+ | ID | Criterion | Verification |
277
+ | --- | --- | --- |
278
+ | AC1 | Each new block and the `copy` action has at least one valid and one invalid fixture, and `jsonSchema.test.ts` agrees with Zod on all of them | `bun test blocks/` |
279
+ | AC2 | Every new error code (`OUT_OF_RANGE`, `COPY_TARGET_INVALID`) appears in `docs/reference/blocks.md` | `blocksDocParity.test.ts` |
280
+ | AC3 | With `richBlocks: false`, `blocksPromptSection` output is byte-identical to `master`, even when a stepper action is registered. With `richBlocks` unset, `addGptRoutes` and `blocksPromptSection` both behave as `true`. On, the prompt has one line per new block (added as each contract lands; the full snapshot is taken in T9), limits come from `BLOCK_LIMITS`, and the stepper line names the stepper actions | prompt snapshot tests |
281
+ | AC4 | Tapping + on a 5-person stepper emits a callback with `payload.value: 6`. An item `{amount: 2, unit: kg, decimals: 1}` renders "2.0 kg". Rendering an override with `value: 6` shows 6 and the new amounts | `ui/src/blocks/BlocksView.test.tsx` |
282
+ | AC5 | Through `POST /gpt/actions`, with a stored stepper (5 people; lamb `2` kg / 1 dp; parsnips `7` / up; broccoli `625` g / nearest) and `value: 6`: the result is `{replace: "block", blocks: {v: 1, blocks: [stepper]}}` with lamb 2.4, parsnips 9 (nearest would give 8), and broccoli 750. An extra agent `callback.payload` key is accepted. `value: 21` (max 20) returns 400. An unknown `blockId` returns 404. Two stored prompts with the same stepper id and a missed `msg-<n>` return 409. The `AIRequest` row has the ids and `value`, and no `response` | `ai/src/service/scaleStepper.test.ts`, `ai/src/routes/gptActions.test.ts` |
283
+ | AC6 | Without a callback, toggling an item changes "1 of 8" to "2 of 8" on the device. With a callback in `hostActions`, the tick emits `payload: {itemId, checked: true, state}` with all 8 items, disables the whole checklist while the tick is pending, and the counter shows "2 of 8" only after the override arrives | `BlocksView.test.tsx` |
284
+ | AC6b | Through `POST /gpt/actions`, `toggleChecklistHostAction` returns the stored checklist with `checked` from `state`. An unknown item id returns 400. The `AIRequest` row has no `response` | `ai/src/service/toggleChecklist.test.ts`, `ai/src/routes/gptActions.test.ts` |
285
+ | AC7 | Gallery, list, and eyebrow render with `@terreno/ui` components only, with `alt` as the accessible label | `BlocksView.test.tsx` |
286
+ | AC8 | Pressing a copy button whose target is a stepper at value 6 writes the scaled list to the clipboard (mocked `expo-clipboard`) and shows "Copied" | `BlocksView.test.tsx` |
287
+ | AC9 | A `number` column renders right-aligned and a `date` column renders Luxon `DATE_MED`. A GFM table in `text` has themed borders, a bold header, and scrolls sideways when wide. Both tests fail on `master` | `DataTable.test.tsx`, `BlocksView.test.tsx`, `MarkdownView.test.tsx` |
288
+ | AC10 | `blocks/src/fixtures/golden/sunday-roast.yaml` reproduces the GPT-6 demo reply (title, gallery, summary card, menu list, stepper + copy card with `itemsTitle`, checklist, note, tips, follow-up buttons) plus the GPT-5.6 "How much lamb?" table. It validates with `hostActions: ["scaleStepper", "toggleChecklist"]`, `stepperActions: ["scaleStepper"]`, `checklistActions: ["toggleChecklist"]`, and `imageHosts: ["images.example.com"]` in its own test, outside the option-less `valid/` loop | `bun test blocks/` |
289
+ | AC11 | In example-frontend, the roast reply is stored in a real `GptHistory` and streamed by the mocked model. Pressing + changes 5 to 6 through the real `POST /gpt/actions` on example-backend. Copy writes the list. A checklist tick goes through `POST /gpt/actions` and updates the counter. Gallery and list images load through `GET /photoLibrary/:id/url`, with only the storage download stubbed (`page.route` on the signed-URL host serves a fixture image) | `bun run frontend:e2e` (`e2e/ai-chat.spec.ts`), with screenshots and a recording attached to the PR (`/opt/cursor/artifacts/` is read-only in this sandbox) |
290
+ | AC12 | With a model key set, a generated photo library in the database, and the `findPhotos` tool registered, `bun run blocks:smoke` sends "Give me a plan for a sunday lamb roast, I'm having friends over still figuring out numbers tbh" through `AIService` with the opted-in prompt. It asserts that the reply validates and contains `gallery`, `list`, `stepper`, `checklist`, and a `copy` action, and that every image `src` is a `file:` id that `findPhotos` returned. Without a key it exits 0 and says it skipped | script exit code; output saved to `--out`. **Partly met:** the checks are unit-tested with a mock model, but no real model has run it (no key in the build sandbox) |
291
+ | AC14 | `photos:generate` with a fake image model and a fake storage service creates one entry per prompt, and a second run creates none. `findPhotos({query: "roast lamb", count: 3})` returns 3 `file:` ids. `GET /photoLibrary/:id/url` returns a URL to a non-admin user, and create returns 405 | `example-backend` tests |
292
+ | AC13 | Docs: reference rows, a how-to "Add a stepper callback", the explanation catalog fixed (it lacks `callout`, `image`, `details`, and `html` today), and a changelog entry | `bun run website:build`, `bun run rules:check` |
293
+
294
+ ## Assumptions
295
+
296
+ - "Serving layout" means the stepper card: the label, − value +, the unit, the quantities grid,
297
+ and the note (Q6).
298
+ - "Summary in an outline at the top" means the summary card: an eyebrow, a title, and a
299
+ bold-label bullet list written in markdown inside `text`. No new outline block.
300
+ - Generating the library is an operator step run once per environment (`bun run photos:generate`). Tests use a fake image model and fake storage, so CI never calls Vertex.
301
+ - "The tables" means the GPT-5.6 "How much lamb?" guests table, plus tables in general (Q7).
302
+ - Copy feedback is inline "Copied" text in a live region, as in the demo, not a toast.
303
+ - iOS and Android render through the same `BlocksView`. Builds already shipped do not know
304
+ the new blocks and would show an error banner, with the raw YAML collapsed, for the whole reply
305
+ that uses them. With the default on
306
+ (D6), a host with such builds must set `richBlocks: false` until they update. X10 (a
307
+ client-declared catalog version) would remove that manual step.
308
+ - The `copy` action never reaches the server, so `hostActions` lint does not apply to it.
309
+ Local checklist ticks (no callback) don't either.
310
+ - Image tiles reuse `useResolvedImages` for `file:` ids.
311
+ - Storage: no new collection. Each stepper tap adds one `AIRequest` row. Like every host
312
+ action today, its prompt holds only ids; this adds the numeric `value`. Unlike other host
313
+ actions, the returned block is left out (`logResponse: false`), because an agent can put
314
+ anything in a stepper label.
315
+ - Fixtures under `fixtures/valid/` use `data:image` or `file:` sources, because that loop
316
+ validates without `imageHosts`. Invalid cases that need options go in `lint.test.ts`.
317
+
318
+ ## Open questions (recommendation assumed)
319
+
320
+ | ID | Question | Recommendation | Why | If answered differently | Tasks affected |
321
+ | --- | --- | --- | --- | --- | --- |
322
+ | Q3 | Should `@terreno/ai` ship `scaleStepperHostAction`, or should each app write its own handler? | Ship it, opt-in, exported from `@terreno/ai` | Any app gets the roast reply in one line; apps with real logic (prices, stock) register their own `handles: "stepper"` action | Drop the export; example-backend owns the handler | T1, T16 |
323
+ | Q4 | Should + / − send one callback per tap, or batch taps (300 ms debounce, then one call)? | One per tap, with the buttons disabled while pending | Matches the existing callback buttons; simplest to prove | Add a debounce and send the final value | T1 |
324
+ | Q5 | Should `gallery` take a `layout` (`collage`, `grid`, `carousel`)? | No: one adaptive layout | Fewer choices for the model; the demo uses one row | Add the enum and two more renderer branches | T6, T11 |
325
+ | Q6 | Does "serving layout" mean the stepper card (− 5 +, People, quantities grid)? | Yes | It sits between the stepper and the copy button in the demo | Name what it is; likely one more block or field | T1 |
326
+ | Q7 | Does "the tables" mean the GPT-5.6 "How much lamb?" table (guests → lamb, potatoes)? | Yes: as a `table` block with typed columns, plus themed markdown tables | It is the only table in the post; the GPT-6 reply shows quantities as a grid | Name the table and what it should do (sort, scale with the stepper) | T3, T4, T15 |
327
+
328
+ ## Expansions (follow up later)
329
+
330
+ | ID | Idea | Why it came up | Rough size | Depends on |
331
+ | --- | --- | --- | --- | --- |
332
+ | X1 | Generated tools in chat (savings calculator, bill splitter, game) | The post's "Create interactive experiences" section | L | a state + formulas design, or more host callbacks |
333
+ | X2 | Interactive diagrams ("change an input to see what happens") | The post's central limit theorem example | L | X1 |
334
+ | X3 | `map` block with stops and notes | The post's road-trip example | M | none |
335
+ | X4 | Full eval that the model picks these blocks for planning questions (beyond the T17 smoke) | The post trains the model's design judgment | M | T17 |
336
+ | X5 | Copy button on markdown code fences | A common chat copy target; not in the demo | S | T14 |
337
+ | X6 | Sortable table columns | `DataTable` supports `sortable` already | S | T3 |
338
+ | X7 | Write `blocks.json` to `blocks/schemas/` for native clients | `blocksJsonSchema` exists but is not published there | S | T9 |
339
+ | X8 | Streaming inside a block (partial lists) | The post's progressive compiler | M | none |
340
+ | X9 | Persist overrides (if Q2 stays no) | A reload resets the stepper | M | Q2 |
341
+ | X11 | Generate images per reply (a `generatePhoto` tool) | D3 picked a stored library instead | M | T19 |
342
+ | X10 | A client-declared catalog version, so the server picks blocks per client | Shipped native builds lag behind the server; more pressing now that D6 turns the blocks on by default | M | T2 |
343
+
344
+ ## Decisions
345
+
346
+ | ID | Question asked | Answer | What it changes |
347
+ | --- | --- | --- | --- |
348
+ | D1 | How should the agent express the +/− servings interaction: fixed block types computed on the device, shared state with formulas, or scripted html? | "When they press the button it should round trip to the server for it to process the function callback. That's a callback button like the others we have." | `stepper` − / + are host callbacks through `POST /gpt/actions`; the server returns the replaced block. No formulas, no scripted html. |
349
+ | D2 | Q1: Should checklist ticks also round-trip to the server, like the stepper? | "Callback per tick" | `checklist.callback`, `toggleChecklistHostAction`, and T21. Ticks wait for the server; without a registered checklist action they stay local. |
350
+ | D3 | Q8: Where should a real agent get photos for the gallery and menu list? | First "Generated images", then: "change q8 to generate some images and store them" | A library generated once with the Vertex image model and stored through `FileStorageService` (T19). The agent picks with `findPhotos` and writes `file:` ids, resolved by `GET /photoLibrary/:id/url` (T20). No per-reply generation and no `imageHosts`. |
351
+ | D4 | Q2: Should stepper and checklist changes survive a page reload? | "No (Recommended)" | Overrides stay in client memory. X9 stays parked. |
352
+ | D5 | Approve the plan? | "Approve (Recommended)", given with D2–D4 | Status set to approved with these answers applied. |
353
+ | D6 | (unprompted) | "enable rich blocks by default" | `uiBlocks.richBlocks` and `blocksPromptSection` default to `true`; `false` opts out. AC3 now pins the `false` case to `master` and checks the default. The changelog flags the behaviour change. The stepper still needs a `handles: "stepper"` action. |
354
+ | D7 | (review of the built PR) | "in blocks playground, ensure every kind of block is available. also the serving callback doesn't work. if it cant work, wire up toasts or something. flip the checkboxes to be bold title, then time, then description. none of the images render." | The playground offers a preset per block type and an "All blocks" preset. The stepper and checklist callbacks run locally there through pure `scaleStepperBlock` / `applyChecklistState` helpers moved into `@terreno/blocks` (the host actions call the same helpers); other actions show a toast. Checklist rows read bold title, time, description. Demo stories and presets use bundled public-domain food photos through `file:` ids instead of colour swatches. Tasks T22–T25. |
355
+
356
+ ## Sign-off
357
+
358
+ Status: approved 2026-10-07 (chat; answers in D2–D6). Built 2026-10-08; AC12 partly met (see AC table).
359
+ Cut: 2 rounds, 23 findings: 21 fixed, 2 moved to questions or expansions (round 1 F4 → Q7, round 2 F2 → Q8, since answered as D3), 0 rebutted. Sign-off answers changed T5, T10, T16–T21; no cut re-run, since less than half the tasks changed and the tracer did not move
@@ -10,7 +10,7 @@ Technical reference for Terreno packages and APIs. Information-oriented, precise
10
10
  - [@terreno/ai](ai.md) — AI service, GPT routes, Langfuse integration
11
11
  - [@terreno/ai/harness](ai-harness.md) — Durable multi-phase tasks with transactional checkpoints and audit spans
12
12
  - [Agent UI Asks](agent-ui-asks.md) — `@terreno/blocks` ask schemas, simple cards, the compact surface, limits, error codes, SSE events, the headless `pendingAsks` and `turn` endpoints, and JSON Schemas for native clients
13
- - [UI blocks](blocks.md) — whole-reply YAML for leaf and layout blocks: grammar, limits, and error codes
13
+ - [UI blocks](blocks.md) — whole-reply YAML for leaf, layout, and interactive blocks (stepper, checklist, gallery, list, copy): grammar, limits, and error codes
14
14
  - [@terreno/admin-backend](admin-backend.md) — Auto-generated admin CRUD endpoints
15
15
  - [@terreno/admin-frontend](admin-frontend.md) — Admin panel UI components
16
16
  - [@terreno/admin-spa](admin-spa.md) — Standalone admin SPA + Express serve plugin
@@ -259,6 +259,32 @@ status. `AuditEvent` itself is never audited.
259
259
 
260
260
  **Important:** Only expose models that should be editable via admin panel. Avoid sensitive internal models.
261
261
 
262
+ ## Document storage
263
+
264
+ `DocumentStorageApp` mounts a GCS file browser at `basePath` (default `/documents`): list, upload, download, create folder, and delete.
265
+
266
+ | Option | Default | Notes |
267
+ | --- | --- | --- |
268
+ | `bucketName` | `GCS_BUCKET` | 503 `Storage not configured` when neither is set |
269
+ | `folderPrefix` | `""` | Root inside the bucket. A non-empty value without a trailing `/` gets one, so `pr-5` and `pr-5/` both scope to `pr-5/` |
270
+ | `access` | `"admin"` | `"authenticated"` also admits signed-in non-admins, confined to `{folderPrefix}users/<userId>/`. Admins always see the whole `folderPrefix` |
271
+ | `uploadRateLimit` | off | `{max, windowMs, store?, keyBy?}` on `POST basePath/` only. Keys by IP by default. See [Rate limiting](../how-to/rate-limiting.md#limit-one-route) |
272
+ | `allowedMimeTypes`, `maxFileSize` | images, PDF, text, Office; 10 MB | Upload filter |
273
+ | `fileUploadsEnabled` | `true` | `false` or `(req) => boolean` rejects uploads; list, download, delete stay on |
274
+
275
+ ```typescript
276
+ new DocumentStorageApp({
277
+ access: "authenticated",
278
+ basePath: "/documents",
279
+ bucketName: process.env.GCS_BUCKET ?? "",
280
+ uploadRateLimit: {max: 1, store: "mongo", windowMs: 60_000},
281
+ });
282
+ ```
283
+
284
+ Pair it with `DocumentStorageBrowser` from `@terreno/admin-frontend`. Pass `backButton={false}` when the browser is embedded outside admin. Upload failures (including 429) show inline.
285
+
286
+ Example-backend deploys set `GCS_BUCKET` to the example documents bucket. PR previews also set `GCS_FOLDER_PREFIX` to `pr-<number>/`. Unset `GCS_BUCKET` is the only path that returns 503 `Storage not configured`. A bucket GCS reports as missing lists as an empty folder.
287
+
262
288
  ## Best Practices
263
289
 
264
290
  - Add `description` to all model fields — flows through to admin UI
@@ -240,6 +240,21 @@ const syncConflicts = useConflicts();
240
240
 
241
241
  ### AdminRolesList
242
242
 
243
+ Role cards and the **Available permissions** list split permissions into two groups:
244
+
245
+ 1. **Custom permissions**: actions an app or plugin declared, such as `admin:runScripts` or
246
+ `user:impersonate`.
247
+ 2. **Model permissions**: the actions `modelRouter` and admin model access check: `create`,
248
+ `list`, `read`, `update`, `delete`, `write`, and `writeOwned`.
249
+
250
+ A resource with both kinds of action appears in both groups. Each group shows one row per
251
+ resource, with that resource's actions as badges. Badge color shows the kind of access:
252
+
253
+ - Green: read-only actions (`read`, `list`, `access`, `view*`)
254
+ - Red: destructive actions (`delete`, `destroy`, `remove`)
255
+ - Amber: every other action. Custom actions (such as screen gates like `adminScreen:syncLab`)
256
+ fall here because the screen cannot tell from the name whether they only read data
257
+
243
258
  Role editing starts with a dedicated **Admin page** toggle for `admin:access`. That is the only
244
259
  permission that opens the admin panel. Grant it first; model and tool permissions do nothing until
245
260
  the role can enter.
@@ -142,7 +142,7 @@ The `task` view passed to `run`: `{id, name, version, input, state, phase, attem
142
142
  | `Harness.open({registry, runner?, models?, env?, priceMap?, streaming?, testHooks?})` | Checks requirements, rejects a duplicate `name@version` or agent name, ensures collections and indexes exist. `runner` defaults to `new InProcessRunner()`. See [open options](#open-options). |
143
143
  | `start()` | Throws, claiming nothing, when any non-terminal task uses a `name@version` missing from the registry (see [Versioning](#versioning)). Then starts the runner. Throws when already started. The runner recovers expired tasks once it owns execution. |
144
144
  | `stop()` | Stops claiming work, waits (without a time limit) for every phase in flight while still renewing the owner lease, then releases it. No-op when not started. |
145
- | `createTask(definition, input, {requestId?, userId?})` | Inserts a `pending` task, its `ObsTrace`, and its root span in one transaction. Wakes the runner. The definition must be in the registry. |
145
+ | `createTask(definition, input, {requestId?, userId?, trace?, prompts?})` | Inserts a `pending` task, its `ObsTrace`, and its root span in one transaction. Wakes the runner. The definition must be in the registry. See [Trace scope and prompt versions](#trace-scope-and-prompt-versions). |
146
146
  | `resolveInterrupted(id, {action, reason, result?, userId?})` | Resolve an `interrupted` task. See [resolveInterrupted](#resolveinterrupted). |
147
147
  | `abort(id, {reason, userId?})` | Abort a task and every non-terminal task it owns, bottom-up. See [abort](#abort). |
148
148
  | `decideApproval(approvalId, {approved, reason?, userId?})` | Approve or reject a pending approval without checking approvers. See [Approvals](#approvals). |
@@ -158,6 +158,30 @@ create with the same id returns the first task and leaves no extra trace. Reusin
158
158
  `requestId` for a different task name, or with a different `userId` (including none versus
159
159
  some), throws. A soft-deleted task still owns its `requestId`.
160
160
 
161
+ ### Trace scope and prompt versions
162
+
163
+ A task's `ObsTrace` is its run record. `createTask` can label it:
164
+
165
+ ```typescript
166
+ const prompt = await promptRegistry.get({label: "production", name: "intake-summary"});
167
+ await harness.createTask(intakeSummary, {patientId}, {
168
+ prompts: prompt ? [prompt] : [],
169
+ trace: {scope: String(workspaceId), tags: ["nightly"]},
170
+ userId,
171
+ });
172
+ ```
173
+
174
+ | Option | Type | Description |
175
+ | --- | --- | --- |
176
+ | `trace.scope` | `string` | App-defined scope, such as a tenant or workspace id. Stored as `ObsTrace.scope`, indexed with `created` for per-scope metering (sum `LLM` span `usage.costUsd` by scope and month). Blank throws `harness-invalid-request`. |
177
+ | `trace.tags` | `string[]` | App-defined labels, stored once each as `ObsTrace.tags`. A blank tag throws `harness-invalid-request`. |
178
+ | `prompts` | `{name, version, label?}[]` | Prompt versions the task uses, stored once each on `ObsTrace.prompts`. A `PromptVersionRef` from `promptRegistry.get` fits as-is; its `body` is not stored. A ref without a name, with a non-string `label`, or without a positive integer `version` throws `harness-invalid-request`. |
179
+
180
+ Child tasks and subagents write into the root task's trace, so they share its scope and
181
+ tags. `rt.runAgent` adds its own prompt versions to the same trace (see
182
+ [Subagents](#subagents-rtrunagent)). The admin trace list filters by `scope` and by
183
+ prompt.
184
+
161
185
  ### open options
162
186
 
163
187
  | Option | Type | Description |
@@ -306,7 +330,7 @@ where `lease` is `{owner, duration, heartbeat}` (Luxon `Duration`s). With `maxPh
306
330
  | `rt.signal` | `AbortSignal`. Aborts when the task is aborted (at once in this process, within one heartbeat elsewhere), or when this run loses its lease. Pass it to cancellable calls. |
307
331
  | `rt.createTask(definition, input, {background?, key?})` | Create a child task. Returns its id. See [Child tasks and waitForTasks](#child-tasks-and-waitfortasks). |
308
332
  | `rt.waitForTasks(ids, {policy?})` | Return child outcomes once they settle; until then the task waits. See [Child tasks and waitForTasks](#child-tasks-and-waitfortasks). |
309
- | `rt.runAgent(agent, {input, output?, instructions?})` | Run a registered agent as a subagent and return its answer; until it finishes the task waits. See [Subagents (rt.runAgent)](#subagents-rtrunagent). |
333
+ | `rt.runAgent(agent, {input, output?, instructions?, prompts?})` | Run a registered agent as a subagent and return its answer; until it finishes the task waits. See [Subagents (rt.runAgent)](#subagents-rtrunagent). |
310
334
  | `rt.memo(key)` / `rt.memo(key, value)` | Read, or first-write, a durable value scoped to this task. See [Memos](#memos). |
311
335
  | `rt.waitFor(event, {timeout?})` | Return the payload of the next `event` sent to this task, or `undefined` once `timeout` passes; until then the task waits. See [Events, waits, and sleep](#events-waits-and-sleep). |
312
336
  | `rt.sleep(duration)` | Return once `duration` has passed; until then the task waits. See [Events, waits, and sleep](#events-waits-and-sleep). |
@@ -817,7 +841,9 @@ is not offered to sections, `beforeModelRequest`, or `afterTool` (the tool alrea
817
841
  `basePath` defaults to `/harness`; it must start with `/` and not end with `/`.
818
842
  `heartbeatInterval` (default `{seconds: 15}`, must be positive) paces SSE heartbeats.
819
843
  Conversation, task, and approval routes are `modelRouter`s with instance actions, so they
820
- appear in `/openapi.json` (tag `harness`). The two SSE routes are plain Express routes
844
+ appear in `/openapi.json`. Each route and its mutations use that collection's tag
845
+ (`harnessconversations`, `harnesstasks`, `harnessapprovals`), so a generated client
846
+ invalidates the list it just changed. The two SSE routes are plain Express routes
821
847
  (the listed exception to modelRouter actions) and are not in the OpenAPI spec.
822
848
 
823
849
  ### Conversation routes
@@ -840,7 +866,7 @@ appear in `/openapi.json` (tag `harness`). The two SSE routes are plain Express
840
866
 
841
867
  | Method | Path | Permissions | Behavior |
842
868
  | --- | --- | --- | --- |
843
- | GET | `/harness/tasks/:id` | Owner (`userId`) or admin | One task. Others: 403. |
869
+ | GET | `/harness/tasks/:id` | Owner (`userId`) or admin | One task, without `lease` (the fencing token stays on the server). Others: 403. |
844
870
  | POST | `/harness/tasks/:id/abort` | Owner or admin | Body `{reason}` (required, non-blank). Runs `harness.abort` with the caller as `userId`; returns the aborted task. |
845
871
  | POST | `/harness/tasks/:id/resolveInterrupted` | Admin | Body `{action: "retry" \| "abort" \| "complete", reason, result?}`. Runs `harness.resolveInterrupted` with the caller as `userId`; returns the task. |
846
872
  | GET | `/harness/tasks/:id/events` | Owner or admin | SSE for the task and its descendants. See [Event stream (SSE)](#event-stream-sse). |
@@ -1320,7 +1346,8 @@ summarize: {
1320
1346
  | --- | --- | --- | --- |
1321
1347
  | `input` | `unknown` | Yes | The subagent's user message. A string is sent as-is (blank is rejected); anything else as `JSON.stringify(input)`. |
1322
1348
  | `output` | zod schema | No | Structured output. Defaults to the agent's own `output`. |
1323
- | `instructions` | `string` | No | Replaces the agent's instructions for this subagent conversation only. |
1349
+ | `instructions` | `string` or `PromptVersionRef` | No | Replaces the agent's instructions for this subagent conversation only. A registry prompt (`promptRegistry.get`) runs with its `body`, and its `{name, version, label}` is added to the trace's `prompts`. |
1350
+ | `prompts` | `{name, version, label?}[]` | No | More prompt versions this subagent used, added to the trace's `prompts`. Each version is recorded once per trace. An invalid ref, or an `instructions` prompt without a string `body`, fails the phase with a definition error. |
1324
1351
 
1325
1352
  Returns the final assistant text, or, with a schema, the object the schema parsed. The
1326
1353
  generic `rt.runAgent<T>(...)` types the result when the schema comes from the agent.
@@ -1331,6 +1358,7 @@ What one call does:
1331
1358
  (`ownership: {kind: "task", id: <caller>}`, `status: "busy"`, agent snapshot with
1332
1359
  `instructions` and `outputSchema`), its user message (`seq` 1), and the turn task
1333
1360
  (`ownership: {kind: "task", id: <caller>}`) with an `AGENT` span named after the agent.
1361
+ Prompt versions from `instructions` and `prompts` are added to the trace's `prompts`.
1334
1362
  2. Waits with `rt.waitForTasks([turn])`: the caller commits `waiting` and the phase stops.
1335
1363
  3. When the turn settles the caller wakes and the phase re-runs from its checkpoint. The
1336
1364
  same call finds the same turn and conversation (step 1 writes nothing) and returns.