site_operate: Change the project's own site, from the thread: generate its pages from the corpus (optionally under a directive), refine one page from a prompt, apply a batch of node edits to one page, take the project's media in as site assets, publish the draft as the next served version, restore a published version into the draft, set the theme's variables, propose a contrast-corrected theme without writing it, or optimize the stored theme at WCAG AA contrast. Each is the same call the Design tab's own controls make; what the site currently holds is read with site_read. Publish and restore are admin-only; publish changes what visitors see, so perform it only on an explicit ask.runs on a thread, stream it
| Field | Type | Required | Description |
|---|
| operation | string | required | one of generate | refine | apply_ops | import_assets | publish | restore | set_theme | propose_theme | optimize_theme |
| route | string | optional | apply_ops only: the route whose frame the ops edit. Required for apply_ops. |
| baseVersion | number | optional | apply_ops only: the doc version the ops were built on, as site_read's page subject answers it. Required for apply_ops. |
| ops | object[] | optional | apply_ops only: the CanvasOp list, each naming a node id from site_read's page tree (op, nodeId, key, value, parentId, index, node); a SET_TEXT value is the element's new inner HTML. Required for apply_ops. |
| directive | string | optional | generate only: the owner's brief for the site, e.g. the pages wanted or the tone. Omit to generate from the corpus alone. |
| prompt | string | optional | refine only: the one change to make; the lens picks the page it targets. Required for refine. |
| tokens | object | optional | set_theme only: a map of theme variable name (without the -- prefix, e.g. color-brand) to its new value. Names not in the map keep their value. Required for set_theme. |
| version | number | optional | restore only: the published version number to re-seed the draft from (read them with site_read). Required for restore. |
Contract generate drafts every page fresh from the corpus and REPLACES the current draft pages; on a site that already has pages, confirm the owner means regenerate rather than refine.
Contract On the tool surface generate and refine are queued, not awaited: each answers {action: "queued", taskId, lands} and the pages are in the draft once that task completes; every other operation answers its result.
Contract refine takes ONE change; the page it lands on is chosen from the change, so name the page in the prompt when the owner did.
Contract set_theme restyles every page with no page rewritten and reports how many render with it — the restyle path that costs no generation; a value that could escape its declaration is refused by the server.
Contract propose_theme writes nothing: it answers the contrast pass over the tokens supplied, or over the stored theme when none are, so the owner reads the correction before it lands. optimize_theme is the same pass committed.
Contract apply_ops lands the batch whole or not at all: a batch built on a version the page has left, or naming a node off that route, is refused rather than merged. In a thread a page's content changes through the update node instead.
Contract publish is irreversible for visitors until the next publish: never publish to show a change — the draft preview already shows it.
Contract restore rewrites the DRAFT from a published version and publishes nothing; the owner reviews it in Edit Page and ships it as the next version — the live site never points backwards.