Chat tools: argument validation, replace, file snapshots, server-fetched images, show_run, show_diff head/paths, schedule_followup

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-02 19:44:47 +00:00
parent c441400f36
commit d204ce3187
27 changed files with 1988 additions and 79 deletions
+45
View File
@@ -100,6 +100,51 @@ The generic tool rows for `mcp__pipelines__*` (Claude), `pipelines_*`
visible. OpenCode V2 runs MCP tools from its code-mode `execute` script, and
that row stays visible because it can contain other code.
## Snapshots, replace, run cards and follow-ups (2026-12-02)
- **Argument validation.** `chattools.ValidateArguments` checks every call
against the tool's declared schema (the schemas say
`additionalProperties: false`): unknown or misnamed fields, missing required
ones and wrong types are refused with the expected field list, before any
effect. Each tool then decodes its own argument struct.
- **Item ids and `replace`.** Every `show_*` result ends with the item id.
`replace: <id>` (an item of this chat, same kind; file and image are one
family) stores the new item over the old one with the same `id` and
`created_at` plus `updated_at`; the client merges by id, so the card is
updated where it is.
- **File snapshots.** `show_file` / `show_image` copy a file up to 5 MiB into
`<data dir>/chat-shown/<session>/<id>-<nonce>/<name>` (inside home, so
`/files` serves it): `snapshot: true`, `source` = the path named. A larger
file stays live with `mod_time` and `sha256` (hash up to 64 MiB); the
subscribe reply sets `state: changed | missing`. Snapshot directories no
retained item references are swept (after a 1 minute grace).
- **Web images.** `show_image` with an https URL is downloaded by the server:
every dialed address (redirects included, checked after DNS resolution) must
be public unicast, no proxy, https-only redirects (at most 5), 20 s timeout,
PNG/JPEG/GIF/WebP/AVIF/BMP only (SVG refused) with content that sniffs as an
image, at most 10 MiB. The bytes become the item's snapshot; `url` keeps the
address. A failure is an error to the model and records nothing.
- **`show_run`.** A `run` item with `{id, pipeline, title, status, outcome,
current_stage, workspace, started_at, finished_at}`. The run event hub's
observer (`runEventHub.observe`) tells the tool service a followed run
changed; after 400 ms it rereads the run summary, stores a changed body over
the item and pushes it. The subscribe reply rereads followed runs too; a
finished run is no longer followed.
- **`show_diff`** takes `head` (compare that revision instead of the work tree,
against `base`'s merge base or HEAD) and `paths` (at most 50 relative
paths/globs; no `..`, absolute paths, leading `-` or `:`; passed as
`:(literal)` / `:(glob)` pathspecs).
- **`schedule_followup`** queues a durable prompt with `send_at` (1 minute to 7
days), operation id `followup-…`, sender label "Agent follow-up", at most 3
pending per chat. It is removable like any queued prompt. Unlike an
operator's scheduled prompt, a follow-up that is not due yet does not hold
the FIFO queue: `chatQueueHead` skips it, so the operator's prompts go
through.
- **HTML theme.** The client passes the app's brightness into the sandbox
(`color-scheme` on the frame plus a `color-scheme` meta in the document), so
`prefers-color-scheme` follows the operator's theme; the tool description
tells the model to style for both.
## Per-harness registration
`server.ConfigureChatTools(store, addr)` runs at startup, before any harness