{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "input": {
      "type": "string",
      "minLength": 1,
      "description": "Current target DOCX containing every target paragraph or table cell.",
      "x-tiwater-file-role": "read",
      "x-tiwater-document-revision-role": "current"
    },
    "changes": {
      "minItems": 1,
      "type": "array",
      "description": "Replace one or more existing target paragraphs or cells with explicit native source selections in one atomic commit. This preserves selected native runs but does not change rows, spans, or merges.",
      "items": {
        "type": "object",
        "properties": {
          "target": {
            "type": "object",
            "description": "Existing main-document paragraph or table-cell address whose inline content is replaced while its container formatting and table structure remain unchanged.",
            "properties": {
              "part": {
                "type": "string",
                "minLength": 1,
                "pattern": "^\\/"
              },
              "path": {
                "type": "string",
                "pattern": "^\\/[A-Za-z_][A-Za-z0-9_.-]*:[A-Za-z_][A-Za-z0-9_.-]*\\[[1-9][0-9]*\\](?:\\/[A-Za-z_][A-Za-z0-9_.-]*:[A-Za-z_][A-Za-z0-9_.-]*\\[[1-9][0-9]*\\])*$"
              }
            },
            "required": [
              "part",
              "path"
            ],
            "additionalProperties": false
          },
          "sourceInput": {
            "type": "string",
            "minLength": 1,
            "description": "Current source DOCX containing this change's sourceSelections.",
            "x-tiwater-file-role": "read"
          },
          "sourceSelections": {
            "minItems": 1,
            "type": "array",
            "description": "Ordered native source cells, paragraphs, runs, or text nodes. The target becomes exactly these selections; omitted source content is omitted. When excluding parallel-language text, explicitly include every required language-neutral formula, number, unit, and symbol in source order. Consecutive selections from one source paragraph form one target paragraph; a range retains the native runs it crosses. A source paragraph boundary remains a target paragraph boundary. Selected content becomes the target content without Agent transcription.",
            "items": {
              "type": "object",
              "properties": {
                "address": {
                  "type": "object",
                  "description": "Native source object address returned by docx_read_object or docx_read_table. Selecting a paragraph copies that paragraph's inline content; selecting a cell copies its direct paragraphs; selecting a run or text copies native inline content and formatting.",
                  "properties": {
                    "part": {
                      "type": "string",
                      "minLength": 1,
                      "pattern": "^\\/"
                    },
                    "path": {
                      "type": "string",
                      "pattern": "^\\/[A-Za-z_][A-Za-z0-9_.-]*:[A-Za-z_][A-Za-z0-9_.-]*\\[[1-9][0-9]*\\](?:\\/[A-Za-z_][A-Za-z0-9_.-]*:[A-Za-z_][A-Za-z0-9_.-]*\\[[1-9][0-9]*\\])*$"
                    }
                  },
                  "required": [
                    "part",
                    "path"
                  ],
                  "additionalProperties": false
                },
                "range": {
                  "type": "object",
                  "description": "Optional Unicode-scalar substring of the selected object's observed text. For a cell, offsets use its docx_read_table text with one newline between direct paragraphs. Length zero selects empty content and clears the target. The selected native runs and paragraph boundaries are retained. Omit it to copy the complete selected object.",
                  "properties": {
                    "start": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    },
                    "length": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    }
                  },
                  "required": [
                    "start",
                    "length"
                  ],
                  "additionalProperties": false
                }
              },
              "required": [
                "address"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "target",
          "sourceInput",
          "sourceSelections"
        ],
        "additionalProperties": false
      }
    },
    "changesInput": {
      "type": "string",
      "minLength": 1,
      "description": "Absolute path to a JSON file containing the same non-empty changes array accepted by changes. Use this for large batches so the array stays out of the tool call.",
      "x-tiwater-file-role": "read"
    },
    "output": {
      "type": "string",
      "minLength": 1,
      "description": "Output DOCX path; may equal input for one atomic in-place update after every replacement has passed preflight.",
      "x-tiwater-file-role": "write"
    },
    "receiptOutput": {
      "type": "string",
      "minLength": 1,
      "description": "New JSON receipt path containing target readback for every completed replacement.",
      "x-tiwater-file-role": "write",
      "x-tiwater-file-effect": false
    }
  },
  "required": [
    "input",
    "output",
    "receiptOutput"
  ],
  "additionalProperties": false,
  "$id": "tiwater.office-mcp-input/docx_replace_content_from_source"
}
