Set document SVG
set_document_svgReplace the entire SVG document with a provided SVG string. Use for adopting a full SVG composed in memory without file round-trip.
Instructions
REPLACE the whole working copy with an agent-composed SVG string (root must be <svg>).
When to use: adopting a full SVG composed in memory, replacing the working copy wholesale (no
file round-trip). To ADD to (not replace) a document use insert_svg_fragment; for a blank
start use create_document.
Key params: svg root must be <svg>; it is byte-size-checked, safe-parsed, and
allowlist-scrubbed — <script>, any on* handler, javascript: hrefs, and external refs
(http(s):// / // / file: / data:) are REJECTED; only a same-document #id reference is
allowed. A real run REQUIRES a non-empty approval_token. The original/source file is never
touched.
Return shape: ComposeResult — an EditResult (operation + pre-mutation snapshot links,
reversible via restore_snapshot) extended with the post-adopt validate_document findings
(validation).
Example: set_document_svg(doc_id, "<svg ...>...</svg>", approval_token="ok")
Render and look before you trust this edit: render with render_preview (or live_render_view)
and inspect the result before relying on it; restore_snapshot reverts it if it is wrong.
Risk class: HIGH — requires a non-empty approval_token; without it the op is refused and
nothing is written.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| svg | Yes | ||
| doc_id | Yes | ||
| approval_token | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| doc_id | Yes | ||
| changed | Yes | ||
| summary | No | ||
| validation | Yes | Structured, machine-readable validation result for one document. `ok` is True iff there are no `error`-severity findings. `error_count` / `warning_count` are convenience tallies over `findings`. | |
| snapshot_id | Yes | ||
| operation_id | Yes | ||
| preview_after | No | ||
| preview_before | No |