@renanlido/tia-openness-mcp 1.10.4 → 1.10.5
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.
- package/dist/index.js +5 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -23945,11 +23945,11 @@ var BRIEF = '# TIA Openness MCP \u2014 operating brief\n\nYou are driving Siemen
|
|
|
23945
23945
|
var GATES_GUARDS = '# Gates vs guards\n\n## GATES vs GUARDS\n\n- **GATES (human-only \u2014 never auto-bypass):** trust dialog (**G1**), download / CPU-STOP\n (**G3**), go-online (**G4**, which includes a **station upload** (`tia_upload`): it goes\n online to read the CPU), network scan / accessible-devices (**G7**), master-secret/UMAC\n (**G6**, which includes a CPU **read-access password** for an upload, a block **know-how\n password** (`tia_block_protect`), a certificate file\'s password (`tia_certificate_import`)\n and the **password-policy** values (`tia_password_policy_set`)), **safety / F-logic\n (G5) \u2014 never autonomous**.\n- **GUARDS (tool-enforced preconditions):** compile-clean before deploy, consistency,\n dry-run\u2192approve, idempotency by name (advisory: re-runs do not converge), `OrderNumber:<MLFB>/V<fw>`\n format, serial-only.\n- Back up a physical CPU with the **`tia-backup`** skill (dedicated empty project; the upload\n token is bound to the project shown in the handoff).\n- **Picking the G3 download path (no gate, no scan):** `tia_pg_interfaces` lists the connection\n modes/PG-PC interfaces TIA already sees for the CPU (plus the OS status of each adapter) \u2014\n use it to fill `connectionMode`/`pcInterfaceName`/`targetInterfaceName` for `tia_download`\n instead of reaching for `tia_accessible_devices` (a real network scan, GATE G7).\n- **GUI-ONLY settings (NOT exposed via Openness \u2014 surface as a human gate, do not script):**\n "Permit access with PUT/GET communication", OPC UA **runtime license** / server-interface\n creation. (OPC UA server **activation** is the exception \u2014 settable via Openness with\n `tia_obj_set_attributes {handle, attributes:{OpcUaServer:true}}` on the "OPC UA" device-item.)\n\n**Deploy-time approval gates** (download / online / network-scan / secret / safety = **G3/G4/G7/G6/G5**)\nare a *different* class \u2014 see the **`tia-handoff`** skill. Those are "a human **approves an action**",\nnot "a human **clicks a GUI setting**". Both are human interaction points; surface them as\n`requires_human_action` with concrete guidance, never as a tool failure.\n';
|
|
23946
23946
|
var GUI_GATES = '# GUI gates \u2014 expected human interaction points\n\n## Human interaction points (GUI gates) \u2014 EXPECTED, not an error\n\nSome TIA settings are **not reachable via Openness** on the S7-1200/1500. The harness will hit a\nsignal that *looks* like an error but is actually a point where a **human must act in the TIA GUI**.\nWhen you see one of these, **do not treat it as a failure and do not retry blindly** \u2014 recognize it,\ntell the human the **exact GUI steps**, and resume after they confirm. A GUI gate is a *handoff*, not a *bug*.\n\n| # | Signal you\'ll see | Why it\'s expected | Tell the human (exact GUI steps) |\n|---|---|---|---|\n| **G1 trust** | `tia_connect` \u2192 `requires_human_action` (`trust_dialog`), or the **1st** TIA-starting call per `serve` process goes **~180 s** (`TIA_CONNECT_TIMEOUT_MS`) without an answer \u2014 `tia_connect`, `tia_start`, `tia_show_ui` and `tia_project_create` all share that wait, and a client timeout with `/health` alive yields the same `trust_dialog` handoff. A `running` answer from any of them can still mean a trust dialog is waiting on the serve host | TIA shows a one-time security prompt the first time an Openness app attaches, **per process** | On the **serve host**, in TIA Portal, click **"Yes to all"** in the access dialog. *Caveat:* it can false-positive on a client timeout with **no** real dialog \u2014 check `tia_status` (**`hasProject:true`**, not `attached:true`) and\u2026 If the handoff state is `TRUST_DIALOG_DENIED_OR_EXPIRED`, the dialog was denied or left to expire: the serve lists what it closed (`closedPids`), what is still running (`stillRunningPids`) and what it could not confirm (`unknownPids`) \u2014 close any still-running TIA (no project inside) before re-calling, and for an unconfirmed pid first verify in Task Manager that it is a TIA Portal started by this serve with no open project, with a human ready to click **"Yes to all"**. |\n| **OPC UA license** | `tia_compile` **ERROR**: *"The selected OPC UA license is not sufficient\u2026"* | License selection is GUI-only (no Openness service); a fresh project **or a firmware change** leaves it unset | CPU \u2192 **Properties \u2192 General \u2192 Runtime licenses \u2192 OPC UA** \u2192 *Type of required license* \u2192 select **"SIMATIC OPC UA S7-1200 Basic"** (the 1214C option), and *Type of purchased license* \u2192 the license the CPU holds (the human declares it; left at "No license" the compile still reports *"Type of purchased license: The selected OPC UA license is not sufficient"*). Recompile. |\n| **OPC UA interface** | OPC UA client connects but the DB nodes aren\'t there (`ns=4` empty / no `ServerInterfaces`) | The **S7-1200 does NOT auto-expose DBs** (unlike the S7-1500) \u2014 a server interface must be created by hand | CPU \u2192 **OPC UA \u2192 Server interfaces \u2192 Add new server interface** \u2192 add/drag the DB (e.g. `ModbusData`) into it. Recompile; data appears under `ns=4`. |\n| **PUT/GET** | S7 client (`nodes7`/`snap7`) connects on port 102 but reads return access-denied (`ROSCTR=2` / "BAD") | *"Permit access with PUT/GET"* is a GUI-only protection setting | CPU \u2192 **Properties \u2192 Protection & Security \u2192 Connection mechanisms** \u2192 check **"Permit access with PUT/GET communication from remote partner"**. Compile + download (`hardware:true`). |\n| **FW-change reset** | After `tia_device_change_version`: OPC UA server off, the license error on compile, blocks `isConsistent:false` | `DeviceItem.ChangeType` **resets GUI-gated comm settings** (server activation + license); the interface & PUT/GET survive | `tia_project_archive` **before** the FW change. After: re-set `OpcUaServer:true` via `tia_obj_set_attributes` (scriptable), re-select the license (row above), recompile. |\n\n**Not a gate (now scriptable):** *activating* the OPC UA server \u2014 `tia_obj_set_attributes {handle, attributes:{OpcUaServer:true}}`\non the "OPC UA" device-item (it auto-generates the server certificate). Only the **license** and the\n**server interface** stay GUI-only.\n';
|
|
23947
23947
|
var GOTCHAS = '# Hard-won gotchas (runtime-validated)\n\n## Hard-won gotchas\n\n1. **Always compile before deploy.** `tia_compile` aggregates **hardware + software**; a\n **clean** compile (`errors:0`) is the precondition for download and for S7 connections.\n2. **The serve is a SINGLE serial worker** \u2014 one Openness op at a time. Do **not** fire\n concurrent `tia_*` calls; a hung Openness op can stall the serve (may need a restart).\n3. **Changing an FB\'s interface (e.g. regenerating it via `tia_source_put`) leaves its\n instance DB inconsistent.** Recompile FIRST: a software-scope `tia_compile` regenerates\n the instance DB in most cases \u2014 read the compile result\'s **`blockChanges`** (`tia_compile`\n and `tia_source_put {compile:true}` both return it): a `"change":"modified"` entry on the\n instance DB is your confirmation it was regenerated \u2014 **export and commit it**\n (`tia_export_block`/`tia_block_compare`) so what\'s versioned matches the project. Only if\n the DB still reports inconsistent after a compile, delete it (`tia_block_delete`),\n recreate it (`tia_instancedb_create`) and recompile.\n4. **Firmware rule: project FW \u2264 device FW.** Bump the project FW **in-place** with\n `tia_device_change_version` (`DeviceItem.ChangeType`), which preserves the **program** \u2014 never\n set the project higher than the physical CPU. **\u26A0\uFE0F It RESETS GUI-gated comm settings** (the\n **OPC UA server activation** + **runtime-license**; the server interface and PUT/GET survive):\n **archive first** (`tia_project_archive`) on a CPU with hand-configured OPC UA, recompile after\n (it marks blocks inconsistent), and re-verify. Same-version `ChangeType` is rejected.\n5. **Use a NON-optimized DB** for Modbus (`MB_HOLD_REG`) and S7 (absolute addressing); OPC UA\n works with optimized or not.\n6. **Order numbers use `/V<fw>`, not `:V<fw>`** (guard Gd5).\n7. **A station upload (`tia_upload`) ADDS a new station to the open project \u2014 back up into a\n dedicated EMPTY project.** Observed on hardware (S7-1200 1214C, 2026-09-26): the upload read\n the CPU into an empty project (0 \u2192 1 device, twice) in ~75 s (76.7 s and 74.2 s); the CPU\n stayed in RUN the whole time (owner watching its LEDs during the second upload). Protect the\n working project FIRST: `tia_project_create` closes the current project, and serve refuses it\n (`409 unsaved_changes`) while that project has unsaved changes \u2014 so `tia_project_save` +\n `tia_project_archive` before creating the backup project (never pass `discardUnsavedChanges` to\n get past the refusal) \u2014 and pass the archive `name` WITH the `.zap21` extension (`name` absent\n or extension-less fails; with `.zap21` it archived 1.6 MB).\n8. **One wrong know-how password can lock a block for the session.** Observed on the bench\n (2026-10-12): after one rejected unprotect (`tia_block_protect {protect:false}`), TIA refused\n the CORRECT password of that block for the rest of the session (cause not confirmed \u2014 possibly\n brute-force protection). Never retry with a guess \u2014 ask the human for the password (G6); if a\n password the human confirms is refused, stop and hand off instead of retrying.\n9. **`unsaved_changes` and `binding_conflict` are refusals, not faults: nothing was changed.**\n `tia_connect`, `tia_project_close`, `tia_disconnect` and `tia_project_create` answer\n `409 unsaved_changes` when the call would close a project with unsaved changes (the error lists\n each one). ASK the human; the recommended answer is to repeat the same call with\n `saveUnsavedChanges:true`. Pass `discardUnsavedChanges:true` (data loss) ONLY when the human\n explicitly decides to throw the work away, never to make the error go away (the client then asks\n the human to confirm in its own dialog; `declined_by_human` = nothing was sent, stop).\n `409 binding_conflict` means the project this session is bound to is no longer the one open in\n the bound TIA (closed, replaced or Save As done by hand; `tia_status` shows `boundProjectPath`\n and `bindingDrift`): ask the human which project is intended, then `tia_connect` with the bound\n path (back to it) or the open one (adopt it) \u2014 do not repeat the refused call first.\n10. **`503 audit_unavailable`: the serve could not write its audit log, so it refused the call BEFORE\n running (nothing reached the PLC).** Have the human fix the disk or permissions, then re-plan.\n An `auditWarning` in a response = the call ran but was not fully recorded: report it.\n\n## Prerequisites (environment)\n\n- The **`tia` serve must be running** (default `http://localhost:5000`, e.g.\n `TIAOpenness.exe serve 5000`). The MCP is a pure HTTP client; point it at the serve host via\n `TIA_API_BASE` if it runs elsewhere.\n- The Windows user must belong to the **"Siemens TIA Openness"** local group.\n- The **FIRST connection per serve process shows a trust dialog** that a **human must confirm**\n ("Yes to all") on the serve host \u2014 this **cannot be automated** (gate G1).\n';
|
|
23948
|
-
var PIPELINE = '# The build pipeline (spec \u2192 verified project)\n\nStages in order \u2014 the class tells you what each stage may do:\n\n| # | Stage | Tool(s) | Class | What it does |\n|---|---|---|---|---|\n| 0 | Validate the spec | `tia_spec_validate` | R (pure) |
|
|
23949
|
-
var RECIPES = '# Recipes (runtime-verified) & scaffold order\n\n## Pipeline order (dependency-correct)\n\n`tia_spec_apply` already encodes this; use it manually only when the spec maps imperfectly.\n\n1. **Subnets** (`tia_subnet_create`) \u2014 before connecting devices to them.\n2. **Devices** (`tia_device_create`, `OrderNumber:<MLFB>/V<fw>`) \u2014 CPUs first.\n3. **Modules** (`tia_device_plug`) \u2014 into existing devices, by slot.\n4. **Network** (`tia_network_connect`, IP, `createIoSystem`) \u2014 CPU + its IO-devices on the\n **same** subnet; exactly one `createIoSystem` per IO-system.\n5. **Protection recipe** (below) \u2014 so the CPU can compile clean.\n6. **Tag tables** (`tia_tagtable_create`) \u2192 **tags** (`tia_tag_create`) \u2192 **constants**.\n7. **UDTs first** (`tia_types_import`), **then** blocks that use them.\n8. **Blocks** \u2014 FB shells (`tia_fb_create`) + instance DBs (`tia_instancedb_create`);\n logic via `tia_source_put` (SCL) or `tia_import_xml` (LAD/FBD/GRAPH). Gd6 format routing.\n9. **Compile** (`tia_compile`) \u2014 the verifier; only `Error` blocks. It compiles the **software**\n scope (not just the CPU device item), so it makes freshly-generated blocks consistent and, in\n most cases, **regenerates** any instance DB left inconsistent by an FB interface change.\n **Recompile first**; only if the DB still reports inconsistent after a compile, delete it\n (`tia_block_delete`), recreate it (`tia_instancedb_create`) and recompile.\n\n**The PlcSoftware name.** TIA names the PlcSoftware of a CPU created through `tia_device_create` or `tia_spec_apply` after the CPU device item (default `PLC_1`), not the device, so `plc` in steps 6-9 is the name from `tia_plcs`. The spec plan carries `{plc}`; `tia_spec_apply` resolves it after the device step (`plc.resolve` in `applied`) and stops with kind `plc_unresolved` rather than guess. `devices[].plcName` names the CPU item.\n\n## Recipe \u2014 edit an existing block or type without overwriting a newer change (stale-write guard)\n\nRead it with `tia_export_block` (block) or `tia_export_type` / `tia_type_source` (type) and keep its `contentHash`: `contentHash`, `normalizedSha256` and `sha256` are different hash contracts over different normalizations, so never substitute one for another and pass only the `contentHash` of a fresh read as `expectedContentHash`. Edit, then write it back with `tia_import_xml`, `tia_source_put` or `tia_types_import` passing `expectedContentHash:<that contentHash>` (one object per write); on `state_changed` NOTHING was written \u2014 re-read, merge your edit onto the current content and retry with the new `contentHash`; a guarded write never compiles, so a block that is not consistent is refused with `409 inconsistent` (NOTHING written) \u2014 `tia_compile`, re-read with `tia_export_block` for the current `contentHash`, retry; an object whose current export is not well-formed XML has no hash (its read answers `contentHashError` instead of `contentHash`) and a guarded write over it is refused with `409 unverifiable` (NOTHING written) \u2014 repair or re-export it in TIA Portal, or retry WITHOUT `expectedContentHash` (an unguarded write); a verified write returns `contentGuard`.\n\n## Recipe \u2014 unlock a freshly-created CPU so it compiles clean (VERIFIED V21, firmware-dependent)\n\nA bare CPU added via Openness may fail `compile` with **protection** errors: the\n*confidential-PLC-configuration-data* password is unset, the *communication certificate*\ncan\'t be generated without it, and (on newer firmware) the *access control* defaults to a\nprotected level needing a password. **The recipe differs by CPU family/firmware \u2014 there is\nno single universal form.** Fix, in order:\n\n**Tell the human first.** The recipe lowers the CPU\'s protection in the project: it sets the\nconfidential-configuration password (typed by the human) and then either sets the access level\nto **Full access** (S7-1500) or turns access control **off** (S7-1200, FW V4.5+). The CPU runs\nwith that protection after the next download. Name these changes when you ask for the password\nand list them in the report; the human may pick a stricter level in the TIA GUI before deploying.\n\n**(1) Confidential-data password \u2192 also auto-generates the certificate** (common to both\nfamilies):\n\n```\n# find the CPU device-item handle:\ntia_obj_roots -> the device handle (role:"device")\ntia_obj_items { handle:<device>, composition:"DeviceItems" } -> the CPU item handle\n# acquire the service ON THE CPU MODULE (not the rack) and invoke Protect:\ntia_obj_service { handle:<cpu>, type:"Siemens.Engineering.HW.Features.PlcMasterSecretConfigurator" } -> <svc>\ntia_obj_invoke { handle:<svc>, name:"Protect", args:["<password>"] }\n```\n\n**(2) Clear the access-control error \u2014 pick the variant for the CPU\'s family/firmware:**\n\n- **S7-1500 V2.9** (verified 2026 on real hardware \u2014 a 1516-3 V2.9, 3 errors \u2192 0): set\n `PlcProtectionAccessLevel = "FullAccess"` **on the CPU device item**:\n\n ```\n tia_obj_set_attributes { handle:<cpu>, attributes:{ "PlcProtectionAccessLevel":"FullAccess" } }\n ```\n\n- **S7-1200 V4.7** (new security model, FW \u2273 V4.5; per `docs/HARNESS-KNOWLEDGE.md` \xA72,\n runtime-observed): set `PlcAccessControlConfiguration = "Disabled"` on the\n **`PlcAccessControlConfigurationProvider`** SERVICE \u2014 not a direct attribute on the CPU\n item:\n\n ```\n tia_obj_service { handle:<cpu>, type:"Siemens.Engineering.HW.Features.PlcAccessControlConfigurationProvider" } -> <svc2>\n tia_obj_set_attributes { handle:<svc2>, attributes:{ "PlcAccessControlConfiguration":"Disabled" } }\n ```\n\n \u26A0\uFE0F **The two variants are mutually exclusive \u2014 the wrong one returns HTTP 500 on the\n other family:** `PlcAccessControlConfiguration` isn\'t on a 1500\'s CPU item, and\n `PlcProtectionAccessLevel` isn\'t the right model on a 1200 V4.7 item. Detect the\n family/FW \u2014 or the compile-error signature \u2014 before picking a variant.\n\n- **S7-1200 V4.0** (old security model): nothing to do here \u2014 the same bare-CPU condition\n is only a **WARNING**, not an error; a plain `tia_compile` already returns `errors: 0`.\n\nThen `tia_compile` \u2192 `state: Warning, errors: 0` (any remaining warnings \u2014 e.g. CPU-display\npassword \u2014 are benign and do **not** block; Gd8).\n\n> **Requires the `tia_obj_service` tool** (acquire `GetService<T>` \u2192 handle) for step 1 and\n> for the S7-1200 V4.7 variant of step 2. Without it the MCP cannot run either.\n\n### Policy \u2014 who supplies the confidential password\n\n`Protect()` sets an **offline project** password (it is not the online master secret / G6), but\nit protects confidential configuration data, so **the human supplies it, every time** (the\nrecommended policy, pending the product owner\'s confirmation): the project-spec has no field\nfor it, and a skill never invents, defaults, stores or logs it. The online master secret (`tia_mastersecret_set`, G6) is **always**\nhuman-supplied too.\n\n## S7 connection precondition (G2)\n\n`tia_connection_create` needs **\u2265 2 CONSISTENT CPUs** (both compile clean). Two *bare* CPUs\nnever form a valid S7 connection \u2014 apply the protection recipe + `tia_compile` to make each\nconsistent first, then create the connection. Use `tia_connections_diagnose` on failure.\n\n## Recipe \u2014 bump the project firmware **in-place** (keeps the program) (VERIFIED, V21 / S7-1200 1214C)\n\nBumped a project **V4.0 \u2192 V4.4** on a real S7-1200 1214C **without losing blocks or tags**\n(verified 2026-06-07). Use this for **auto-FW-match**: align the project to the firmware\nactually read from the CPU. `DeviceItem.ChangeType(typeIdentifier)` changes the item type\nin place and **preserves the software** \u2014 it does **not** require delete/recreate.\n\n```\n# archive first (see the warning below), then change the CPU\'s type to the SAME MLFB with the target /V<fw>:\ntia_device_change_version { plc:"<plc>", typeIdentifier:"OrderNumber:6ES7 214-1HG40-0XB0/V4.4" }\n# then recompile \u2014 a regenerated FB may need a fresh compile before download:\ntia_compile { ... }\n```\n\n(`tia_device_change_version` runs `ChangeType` on the CPU item for you; the raw form, `tia_obj_invoke`\nwith `name:"ChangeType"` on the CPU item handle from `tia_obj_roots` / `tia_obj_items`, does the same.)\n\n- **Rule: `project FW \u2264 device FW`** \u2014 never set the project firmware **higher** than the physical\n device\'s (download would be rejected). Bumping the project *up to* the device FW is the safe move.\n- Keep the **same MLFB**, swap only the `/V<fw>` suffix. The program (blocks/tags) survives.\n- After `ChangeType` the CPU/blocks can be inconsistent; **always recompile** before any handoff.\n- **\u26A0\uFE0F `ChangeType` RESETS GUI-gated comm settings** (runtime-validated on the 1214C): it **disabled\n the OPC UA server** (`OpcUaServer`\u2192`false`) and **cleared the OPC UA runtime-license** selection\n (the custom server interface and PUT/GET *survived*). So **`tia_project_archive` first** on a CPU\n with hand-configured OPC UA/PUT-GET, and **re-verify after**. Recovery: `tia_obj_set_attributes\n {handle, attributes:{OpcUaServer:true}}` on the "OPC UA" device-item (it **is** writable; re-select the license in the\n GUI). `ChangeType` to the **same** version is rejected ("Cannot change the type of the device item").\n\n## Recipe \u2014 enable a **Modbus TCP server** (`MB_SERVER`) on the S7-1200 (VERIFIED, FW V4.0)\n\nLets an external client (e.g. a Node backend) read/write the CPU over **Modbus TCP, port 502**\n(verified 2026-06-07; full backend/app detail in `docs/COMM-SCENARIOS.md`).\n\n1. **Non-optimized DB with an `Array of Word`** for the holding-register block (`MB_HOLD_REG`).\n Modbus needs a byte-addressable (non-optimized) DB \u2014 optimized access won\'t map.\n2. **On FW V4.0 use `MB_SERVER` V1.x**, which takes **`CONNECT_ID` + `IP_PORT`** parameters\n (**not** `CONNECT`/`TCON`, which the newer instruction versions use). Pin the instruction\n version when generating the FB.\n3. Instantiate `MB_SERVER` as a **multi-instance inside an FB** (its instance lives in the FB\'s\n instance DB), call it cyclically.\n4. **Map a holding register \u2192 a command tag** (e.g. `MB_HOLD_REG[0]` \u2192 `LedCmd`), so writing the\n register drives the output.\n\n> **Instance-DB gotcha (the big one):** when you regenerate the FB via `tia_source_put`, the\n> existing **instance DB** can go inconsistent (its interface no longer matches the FB).\n> **Recompile first** \u2014 a software-scope `tia_compile` regenerates the instance DB in most cases.\n> Only if it still reports inconsistent after a compile (typical when the interface was edited via\n> source), delete + recreate it, then recompile:\n>\n> ```\n> tia_compile { ... } # try first\n> tia_block_delete { ... the stale instance DB ... } # only if still inconsistent\n> tia_instancedb_create { ... fresh instance DB for the FB ... }\n> tia_compile { ... }\n> ```\n>\n> (Matches the \xA7Pipeline note: recompile first, delete+recreate only as the fallback.)\n\n## Recipe \u2014 enable **S7 / PUT-GET** on the S7-1200 (port 102)\n\nLets an external S7 client (e.g. `nodes7`) read/write the CPU over **S7comm, port 102**.\n\n1. **GATE (human, GUI only):** enable PUT/GET \u2014 *Properties \u2192 Protection & Security \u2192\n Connection mechanisms \u2192 "Permit access with PUT/GET communication"*. **Not exposed by\n Openness** on this CPU/FW (we tried `PlcAccessLevelProvider` \u2014 no toggle). Mark it as a\n **human gate** and surface it in `tia-handoff`; do **not** attempt to script it.\n2. **Non-optimized DB** for the data the client touches (PUT/GET addresses absolute offsets, so\n the DB must be byte-addressable / non-optimized).\n3. Compile + download as usual; the client then reads/writes the DB by area+offset.\n\n## Recipe \u2014 enable **OPC UA** on the S7-1200 (port 4840)\n\nLets an external OPC UA client read/write the CPU over **OPC UA, port 4840**. This path is the\nmost gated \u2014 most of it is **human GUI steps**, not Openness.\n\n**Prerequisite \u2014 firmware \u2265 V4.4.** OPC UA server isn\'t available on V4.0. If the project is on\nan older FW, bump it in-place first (see *bump the project firmware in-place* above \u2014\n`ChangeType` to `.../V4.4`).\n\nThen the setup sequence. **Step 1 is scriptable; steps 2\u20133 are human/GUI** on this CPU/FW (for those two\nwe tried `CommunicationManagement` and `OpcUaUserManagement\u2192404`):\n\n1. **Activate the OPC UA server** \u2014 *Properties \u2192 OPC UA \u2192 Server* (enable). *(This step **is**\n scriptable via Openness: `tia_obj_set_attributes {handle, attributes:{OpcUaServer:true}}` on the "OPC UA"\n device-item \u2014 it auto-generates the server certificate. Steps 2\u20133 stay GUI-only.)*\n2. **Select the runtime license** \u2014 *"SIMATIC OPC UA S7-1200 Basic"* (Runtime licenses).\n3. **Create a server interface** that **exposes the DB** \u2014 the **S7-1200 does NOT auto-expose**\n tags/DBs to OPC UA (unlike the S7-1500), so you must add a server interface and place the DB\n nodes in it manually.\n\n**Finding the node IDs (client side):** browse `ns=3;s=ServerInterfaces` with any OPC UA client;\nthe actual data nodes show up under **`ns=4`**. Use those node IDs from the backend.\n\n> What Openness *can* still do here: create the DB/blocks, compile, download \u2014 **and activate the OPC UA\n> server** (step 1: `tia_obj_set_attributes {handle, attributes:{OpcUaServer:true}}`; do NOT gate it on a human). Only **three**\n> items are truly human/GUI: the **runtime license**, the **server interface** \u2014 and **PUT/GET** in the S7\n> recipe. See `docs/TIA-Openness-Casos-de-Uso.md` \xA78c for the full "GUI-only gates" table.\n\n## Recipe \u2014 WinCC Unified HMI: read, then guarded writes\n\nOnly for a WinCC **Unified** HMI (`tia_hmis` \u2192 `kind:"unified"`). A Classic HMI answers `409 hmi_not_unified`; use the screen export/import there. Everything below is offline (M-off): it edits the project, never the panel or the PLC.\n\n1. **Read first.** `tia_hmis` for the HMI name, then `tia_hmi_tag_tables`, `tia_hmi_tags` (`table`), `tia_hmi_alarm_classes`, `tia_hmi_alarms` (`kind`: `discrete`|`analog`) and `tia_hmi_connections`. Every read pages (`limit` 1..1000, `cursor`): follow `nextCursor` UNCHANGED, and on `cursor_stale` restart from the first page. Read `inventoryGaps` too: a non-empty list means a value reads `null` because Openness refused it, so do not write on the strength of that value.\n2. **Baseline.** `tia_hmi_validate` (scope `all`, or `tags`/`alarms`/`connections`/`screens`) aggregates the per-object `Validate()` results into `errors`, `warnings` and `findings`. Unified has NO compile: a clean validate is not a clean compile, and it can be slow (Long).\n3. **`dryRun:true` on EVERY write first** (`tia_hmi_tag_table_create|delete`, `tia_hmi_tag_create|update|delete`, `tia_hmi_alarm_create|update|delete`). The plan runs the same guards as the real call and changes nothing; repeat without `dryRun` only when it answers `plan_ok`. The real answer carries `postcheck` (`verified:true`, `requested` equal to `actual`). `409 postcheck_failed` is NOT a success: read the object again before going on (`rollback` says what was undone; a delete is never rolled back).\n4. **What the guards enforce \u2014 fix the cause, do not retry the same call.** Names: letters, digits and `_`, starting with a letter or `_` (tag tables may also hold spaces and `-` inside), at most 128 characters (`invalid_name`), unique ignoring case (`name_collision`). `dataType` is an allow-list: Bool, Byte, Char, DInt, DWord, Int, LInt, LReal, LWord, Real, SInt, String, UDInt, UInt, ULInt, USInt, Word, WChar, WString, DateTime, Time (`invalid_data_type`). A tag without `connection` is internal and needs `dataType`; with `connection` it is external and takes exactly one of `plcTag` or `address`. A PLC-bound tag needs a `plcTag` that EXISTS in the connected PLC (`plcName` when the connection\'s partner does not resolve to one PLC): `plc_unresolved` / `reference_not_found` mean fix the link, never invent a tag. A PLC tag whose own name contains a dot or a bracket is sent as ONE quoted token (`"A.B"`, `"Valve[1]"`): unquoted, `A.B` is member `B` of data block `A` and `Valve[1]` is an indexed name, so the call is refused. A discrete alarm needs an existing `alarmClass` and `triggerTag` and a `triggerBit` inside the width of the tag\'s type (Bool: 0, Word: 0..15; `trigger_bit_out_of_range`); an analog alarm has ONE `condition` and ONE `conditionValue` on a numeric tag (no limit ordering exists), and the value must fit the type (`condition_value_out_of_range`).\n5. **Alarm values, event text and what a read shows.** TIA stores the condition value of an alarm as a double: on an `LInt`, `ULInt` or `LWord` trigger tag a whole `conditionValue` above 2^53 in absolute value is refused `409 condition_value_out_of_range` (a `dryRun` too, nothing written); 2^53 itself is accepted, sent as a string, and `Real` and `LReal` values are always JSON numbers. `eventText` is PLAIN single-paragraph text per active project language: the serve wraps it as the rich text TIA stores (`<body><p>\u2026</p></body>`) and escapes `&`, `<` and `>`, so send no markup; a line break, an XML-invalid character (a tab is allowed), an unpaired surrogate, a blank text or more than 1024 characters is `400 bad_request`, and a text cannot be cleared by a write. A read answers the plain text (an event-text item without text is `""`, a language without an item `null`; any other markup comes back as raw rich text, which cannot be written back). TIA\'s placeholders read as `null`: an internal tag has `connection`, `plcName`, `plcTag`, `address`, `accessMode`, `acquisitionMode` and `acquisitionCycle` all `null` (TIA reads its connection back as a placeholder such as `<Internal tag>`), and an alarm class without a common class has `commonAlarmClass` `null` (`<No alarm class>`). The attribute list of an alarm itself is never read: `hmi_attribute_list_unavailable` and `hmi_attribute_not_writable` apply to tags and to the event text item of each culture (its list unreadable, `Text` not writable, or no item for that language), never to another alarm attribute.\n6. **Deleting.** A tag, or a tag table that holds one, is refused with `tag_in_use` while an alarm references it; a non-empty table needs `recursive:true` (`tag_table_not_empty`); the default table is refused. References from screens, scripts and logging are NOT scanned, so run `tia_hmi_validate` again after a delete.\n7. **Finish** with `tia_hmi_validate` and compare `errors` and `findings` with the baseline.\n\nLimits to remember: a **create\'s `dryRun` cannot check writability** (a `plan_ok` can still end in `hmi_attribute_not_writable`, after which the new object is removed again); an **update checks only what it changes** (a tag change against the stored bit or value, a connection change against its link), never a reference it leaves alone, and never switches a tag between `plcTag` and `address` \u2014 `tia_hmi_validate` finds a dangling carried reference; send a whole `conditionValue` as a **JSON integer or a string** (`5.0` and `1e3` are refused, and so is a whole value above 2^53 on an `LInt`, `ULInt` or `LWord` tag: step 5); a system tag may be an alarm trigger tag; `tia_hmi_validate` is Long, so it may answer `status:"running"` with a `jobId`: follow `tia_job_status` and never repeat the call.\n\nNo tool creates an HMI connection: when `tia_hmi_connections` is empty, PLC-bound tags cannot be created \u2014 ask the human to create the connection in TIA Portal.\n\n## Recipe \u2014 diff a project against a VCI workspace, or round-trip a block through a new one\n\nA VCI workspace is a folder on the serve host that mirrors project objects as files, so a diff tool or git can version\nthem. VCI takes **leaf objects only** (PLC blocks, PLC data types, tag tables): a device, a PLC, a group or the library is\nrefused with `409 vci_not_leaf` before VCI is called. Every write takes `dryRun:true` first (Gd11), a call holds at most 50\nobjects, and a batch is NOT a transaction: it stops at the first failure.\n\n**(1) A workspace that already has mapped objects is a baseline: its diff is READ-ONLY.**\n\n```\ntia_vci_workspaces -> `mappedObjects` above 0: a baseline exists\ntia_vci_status { workspace:"WS_1", limit:100 } -> follow nextCursor until it is null\n```\n\nClassify every row. `equal` is the only verified match. `projectChanged` (the project object changed), `workspaceChanged`\n(the file changed), `conflict` (both), `workspaceFileMissing` (the file is gone) and `unequal` (a difference of unknown\nside) are differences: report each by name, they are the result, not something to repair. `unknown`, `unsupported` and\n`statusFailed` prove nothing, neither equality nor a diff: report them by name, and the diff is NOT complete. **Never\nexport or import just to make a comparison equal.** `tia_vci_export` over a mapped object REPLACES its workspace file\nwith the project content (the plan says `action:"synchronize"`) and `tia_vci_import` replaces the project object with\nthe file, so either one destroys the difference you were asked to see. Refreshing the baseline is an explicit decision\nof the human: name the objects, ask, and only then export with `dryRun:true` first and read which files the plan\nreplaces.\n\n**(2) A NEW workspace, or new objects: export, then prove it.**\n\n```\n(a) tia_vci_workspaces -> reuse a workspace that is listed\n # none yet: ask the HUMAN for the root folder on the serve host. Never choose or invent a rootPath.\n tia_vci_workspace_create { name:"WS_1", rootPath:"<the folder the human gave>", dryRun:true }\n tia_vci_workspace_create { name:"WS_1", rootPath:"<the same folder>" } -> created | reused\n(b) tia_vci_export { workspace:"WS_1", objects:[{ kind:"block", name:"FB_Motor" }], dryRun:true }\n tia_vci_export { workspace:"WS_1", objects:[{ kind:"block", name:"FB_Motor" }] } -> the file(s) written\n(c) tia_vci_status { workspace:"WS_1", limit:100 } -> follow nextCursor until it is null\n(d) tia_export_block { plc:"PLC_1", block:"FB_Motor" } -> contentHash\n tia_block_set_attribute { plc:"PLC_1", block:"FB_Motor", name:"HeaderAuthor", value:"<a new text>" } -> an edit IN PLACE: the mapping survives\n tia_block_compile { plc:"PLC_1", block:"FB_Motor" }\n tia_export_block { plc:"PLC_1", block:"FB_Motor" } -> a DIFFERENT contentHash\n tia_vci_status { workspace:"WS_1", limit:100 } -> that row is now projectChanged\n(e) tia_vci_import { workspace:"WS_1", objects:[{ kind:"block", name:"FB_Motor" }], dryRun:true }\n tia_export_block { plc:"PLC_1", block:"FB_Motor" } -> a fresh contentHash\n tia_vci_import { workspace:"WS_1", objects:[{ kind:"block", name:"FB_Motor", expectedContentHash:"<fresh>" }] }\n tia_export_block { plc:"PLC_1", block:"FB_Motor" } -> the import REPLACED the project object: read it again by name\n tia_vci_status { workspace:"WS_1", limit:100 } -> that row is equal again\n```\n\n- **(b) Read the plan.** `action:"export"` creates a new file; `willCreateDirectory:true` on an object means the serve will\n create its target folder (the first export into a fresh workspace has none yet), and the dry run creates nothing. An\n object the plan lists as `synchronize` is already\n mapped and its file would be REPLACED: stop and go back to (1). `format` chooses the file format of an UNMAPPED object\n only (leave it out unless the serve answers `400 bad_request` with `details.supportedFormats`); a mapped object keeps its\n mapping\'s format and the selector is neither applied nor validated for it.\n- **(c) Verify an export.** Every row of every page must be `equal`. Read `coverage` on EVERY page: `summary` and\n `coverage` describe only the rows of that response (the serve compares only the rows of the page), so fold them over all\n pages before saying the workspace is in sync. `409 cursor_stale` (a mapping appeared or went) restarts the walk once.\n- **(d) Edit the project IN PLACE, never by regenerating.** A block attribute (`tia_block_set_attribute`, a header attribute such as `HeaderAuthor`) keeps the project object, so its mapping stays and the row becomes `projectChanged` (measured on V21). If `tia_export_block` shows the same `contentHash` afterwards, that attribute is not part of the exported XML: try another header attribute (`HeaderFamily`, `HeaderName`). `tia_source_put` (regenerating the block from SCL) REPLACES the project object, and V21 DROPS its VCI mapping (measured): the row vanishes from `tia_vci_status` and `tia_vci_import` answers `409 not_mapped`, which is the correct answer, not a fault; `tia_import_xml` over an existing block replaces it the same way (not measured separately). Export the new object again to map it: `tia_vci_export` is refused `409 vci_path_collision` (`reason:"file_exists"`) while the old workspace file is still in the folder, so ask the human to remove or move that file first; on a baseline you were asked to diff, report the dropped mapping instead of exporting over it.\n- **(d) What a row says.** Only `equal` is a match. After a human edits a workspace file its row should show\n `workspaceChanged`; a row that still says `equal` after a known edit means the status is not live (V21 has no refresh\n call): say so and treat the check as NOT verified.\n- **(e) Read the plan before importing, and read the hash per kind.** The dry run shows per object `statusBefore` and\n `overwritesProjectChanges` (`true` for `projectChanged` and `conflict`: the import discards an edit that exists only in\n the project, there is no undo, so ask the human). An object that is already `equal` is skipped. The hash reader depends\n on the kind: a block uses `tia_export_block`, a type uses `tia_export_type { plc:"PLC_1", type:"UDT_Motor" }`, and a tag\n table has NO hash (the serve and the MCP refuse `expectedContentHash` for it), so rely on the dry run and the postcheck.\n A wrong `expectedContentHash` is `409 state_changed` and nothing was written.\n- **An import REPLACES the project object.** After a real import the old object is disposed: a handle of it (`tia_obj_*`) and every value read before are stale, so re-read the block by name (`tia_export_block`, `tia_plc_blocks`) and then `tia_vci_status`. The serve does the same for its postcheck: an object it cannot find again by name, or whose mapping the replacement dropped, is `409 import_unverified` (the object WAS written). In a batch, an object that can no longer be found or mapped when its turn comes stops the batch there: `409 vci_batch_incomplete` naming it, or `409 conflict` when nothing was imported yet; nothing more is written.\n- **Verified only with a postcheck.** An import is done only when every imported object has `postcheck.verified:true`. Every\n other answer means it is NOT verified: `409 import_unverified` (the object WAS written, review it with `tia_export_block`\n or `tia_export_type`), `409 vci_batch_incomplete` (the objects in `done` WERE written), a status row `unsupported`,\n `statusFailed` or `unknown`, `coverage.complete:false`, an omission marker that survives smaller `limit` retries, or a\n page walk that did not finish.\n- **Unknown outcomes.** `504 worker_restarted`, a `timeout` or a lost session during an export or an import leaves the\n outcome UNKNOWN or partial: walk `tia_vci_status` and re-read the object before repeating anything.\n- **Refusals before any write** (nothing changed): `vci_path_collision` (two objects, another mapping or an existing file\n share a target; `reason:"alias_unverifiable"` means the short 8.3 name of an existing file in the target folder could not\n be read, so a collision with its alias cannot be excluded), `vci_path_too_long`, `vci_mapping_outside_workspace` for an\n EXISTING mapping rejected in the plan, `not_mapped` (export it first), `workspace_file_missing`, `workspace_exists`,\n `workspace_root_in_use`, `workspace_ambiguous` (ask the human which workspace is meant) and `vci_inventory_incomplete`\n (the workspace inventory could not be read completely: report it and stop, never guess a workspace).\n- **`vci_mapping_outside_workspace` has TWO outcomes.** An existing mapping rejected in the plan changed nothing. After a\n NEW export the same kind means the file WAS written outside the workspace root: read its message and `details`\n (`object`, `directory`, `root`, `done`), report it, hand the cleanup to the human and never retry blindly.\n\n## Reference \u2014 global library and CAx error contracts (by app version)\n\n**Project library** (`tia_block_from_mastercopy`). A device copy is refused (`409 mastercopy_not_blocks` after app 1.6.3; up to 1.6.3 a 500).\n\n**Global libraries** (`tia_global_library_save` / `_close`). After app 1.6.3 a name that picks no single open USER library is refused, nothing saved or closed: `404 not_found` (`details.userLibraries` lists the names that work), or `409 conflict` for a read-only system/corporate library or a name several user libraries match only ignoring case; up to 1.6.3 the serve reports success even for an unknown name. A library opened read-only (`readWrite:false`) cannot be saved: `409 conflict` (`details.readOnly`) after app 1.6.3, a 500 up to 1.6.3 \u2014 close it and open it again with `readWrite:true` to change and save it.\n\n**CAx (AutomationML)** (`tia_cax_export` / `tia_cax_import`). A failed transfer is an error (`500 cax_transfer_failed`) after app 1.6.3; up to 1.6.3 the serve returns an opaque `result` even on failure \u2014 check the devices with `tia_devices`.\n\n## Reference \u2014 download plan fingerprint limits\n\n**Fingerprint limits** (`tia_download`): user program blocks, UDTs and tag tables only \u2014 no hardware configuration, system block groups, S7-1500 software units or technology objects; per-object fallback to modification dates (`source:"dates"`, warned in the plan \u2014 dates can false-positive `plan_stale`).\n\n## Recipe \u2014 generate the FAT/SAT I/O list (tia_io_map)\n\n**Generate the FAT/SAT I/O list** (`tia-verify` step 6). `tia_io_map` (`jobId` \u2192 `tia_job_status`), one\nlist per PLC, `limit:100`, `cursor` = previous `nextCursor` unchanged until null. Read `coverage` on every\npage; `cursor_stale` or differing coverage restarts once; omission marker: same call and cursor, half the\n`limit`, max 3 times, never follow its cursor. Rows: one per tag on a `channel`, or on a `range` with\nstatus `matched`; per unmatched `tag` entry; and (empty tag) per unmatched `channel` or channelless\n`range`; none for a `range` with status `channels`; a tag spanning channels: ONE row (`table`+`name`)\nlisting them; statuses `matched`|`unmatched`|`conflict` only. Unresolved channels/ranges and unparsed\ntags: "Could not be mapped". Print `coverage` numbers, `coverage.limits`, DERIVED addresses (spot-check in\nTIA). Complete ONLY after a finished walk with no marker left on ANY page and `coverage.complete: true`,\nsame counts, on every page; else start "NOT complete", say why. An unmatched tag is never\n"unused"/"orphan"; never invent, round or fix an address. Read-only; the human signs.\n\nLengths: a `range`\'s `start` is a byte number and its `length` is in BYTES (Openness reports an address length in bits and the map converts it, rounding up to whole bytes); `from` and `to` are its first and last bit (2 bytes from `%I0.0` end at `%I1.7`). `tia_device_tree` shows the raw Openness value, in BITS: convert before comparing the two.\n\n## Recipe \u2014 prove the project matches the versioned XML (tia_block_compare)\n\n**The project matches what\'s versioned \u2014 prove it, don\'t assume it.** A raw hash of an\nexport is NOT proof (two exports of the same block differ in `<Created>`/UIds). Use\n`tia_export_block` to pull a block inline and `tia_block_compare` to diff it against the\ncommitted XML (normalized \u2014 ignores formatting/BOM/`<Created>`/UIds); `verdict:"equal"` is\nthe actual round-trip proof. After `tia_compile`/`tia_source_put`, read `blockChanges` and\nexport/commit any regenerated instance DBs before calling the project verified.\n\n## Reference \u2014 network, audit and CAx how-to\n\n**Network lifecycle.** `tia_subnet_delete` on a non-empty subnet is refused (`409 subnet_not_empty`); `disconnectNodes:true` disconnects its nodes and removes its IO systems. A subnet rename (`tia_subnet_update` `name`) takes at most 24 characters: a longer name is `400 invalid_subnet_name` (a `dryRun` too, nothing changed) although `tia_subnet_create` accepts longer names; a name equal to the current one is not a rename, and the serve counts UTF-16 code units, spaces included. PROFINET name (`tia_pn_name_set`): lower-case DNS labels (`a-z0-9-`) split by `.`, not an IP look-alike. A node in its default state (automatic name generation on, `PnDeviceName` read-only) takes a `name`: the serve switches auto-generation off first and writes the name second, and its `dryRun` cannot prove that the name becomes writable, so a `plan_ok` can still be followed by `409 pn_name_unsupported` from the real call; the serve then writes the previous auto-generation back and verifies it, the error ends with "Nothing was changed." only when that read-back confirmed it, and otherwise `409 conflict` names `autoGeneration` as NOT restored: re-read with `tia_device_network`. IO system first: `tia_io_system_create` on the controller, then `tia_io_system_connect` per device; `409 cross_subnet_assignment`: connect the device to that subnet (`tia_network_connect`) first.\n\n**Audit** (class R). Read blocks/types/tags via `tia_plc_*` and check the engineering baseline: optimized access, 100% symbolic, UDT-typed interfaces, FB + instance-DB, uniform naming. Scope `tia_crossrefs` with `target`/`kind` on a big project: a whole-PLC read can take minutes.\n\n**CAx (AutomationML).** `tia_cax_export` exports one device or the whole project; `tia_cax_import` takes `option`: `RetainTiaDevice` (default) / `OverwriteTiaDevice` / `MoveToParkingLot`.\n\n## Where to stop\n\nEverything above is **offline (M-off)**. `tia_download` / `tia_online` (G3/G4) are **not**\npart of scaffold \u2014 they belong to `tia-handoff` and require explicit human approval.\n';
|
|
23950
|
-
var SPEC_FORMAT = '# The project-spec (input model)\n\nA project-spec is ONE JSON document describing the whole project. Always run it\nthrough the pipeline front door: `tia_spec_validate` (rung 0, pure) \u2192 `tia_spec_plan`\n(dry) \u2192 `tia_spec_apply` (M-off, stops at gates).\n\
|
|
23948
|
+
var PIPELINE = '# The build pipeline (spec \u2192 verified project)\n\nStages in order \u2014 the class tells you what each stage may do:\n\n| # | Stage | Tool(s) | Class | What it does |\n|---|---|---|---|---|\n| 0 | Validate the spec | `tia_spec_validate` | R (pure) | Partial shape checks + the cross-field rules the tool implements: unique names, IP inside the subnet CIDR, Gd5 order-number format, no STL/GRAPH on S7-1200, the G5 safety rule, at most 8 SMs on an S7-1200. It does NOT run the JSON Schema or per-model module limits; the `spec-validate` skill covers both. Needs no serve. |\n| 1 | Plan | `tia_spec_plan` | R (pure) | Turns a VALID spec into the ordered list of M-off operations. Nothing mutates. |\n| 2 | Scaffold | `tia_spec_apply` (or the M-off tools manually) | M-off | Creates part of the project content in dependency order (scope below). Stops at every gate. |\n| 3 | Verify | `tia_compile` | M-off | THE offline verifier: aggregates hardware + software. Gd8: only ERRORs block. `errors:0` is the Gd9 precondition for any deploy. |\n| 4 | Handoff / deploy | `tia_download` | GATE G3 | `dryRun:true` asks serve for a VERIFIED plan (clean compile, resolved connection, software fingerprint) \u2192 plan + `planHash` \u2192 a HUMAN approves \u2192 re-call with `approved:true` + the SAME `planHash` (serve re-checks the fingerprint and refuses `plan_stale` if the software changed). The approval covers the connection/options and the covered software content \u2014 NOT the hardware configuration (a hardware change after approval passes the token check). Re-plan (new dryRun) + fresh human approval only when the hardware configuration changed AFTER the dryRun that produced the token \u2014 the fingerprint cannot detect that change, so the human must confirm nothing hardware-side moved; never reuse the old token for changed hardware. The fingerprint covers only user program blocks, UDTs and tag tables (what it leaves out, the `source:"dates"` fallback: `tia_guide {"topic":"recipes"}`, \'Reference \u2014 download plan fingerprint limits\'). Never self-approve. Pick the connection with `tia_pg_interfaces` (no scan). |\n\nScaffold order (UDTs BEFORE the blocks that use them): by hand, `tia_guide {"topic":"recipes"}`, \'Pipeline order\'. `tia_spec_apply` automates only subnets, devices, modules, network, tag tables, tags, FB shells, control-module instance DBs and the compile; protection, constants, UDTs and all logic stay manual. The FB shells it creates are empty: add their logic with `tia_source_put` (SCL) or `tia_import_xml` (LAD/FBD).\n\nPLC-scoped steps use the PlcSoftware (e.g. `PLC_1`) read after the device step, not the device name.\n\n## The approval envelope (what a gate handoff looks like)\n\nGated tools return `status:"requires_human_action"` with:\n\n- `gate` \u2014 which gate (e.g. `download_approval`, `station_upload`, `go_online`, `trust_dialog`);\n- `youMustDo` \u2014 what the human must confirm, in plain words;\n- `plan` + `planHash` \u2014 exactly what would be executed (the hash binds the approval to\n this exact plan; a changed plan needs a new approval); the download\'s plan also carries\n `fingerprint` (the software content the plan was verified against \u2014 show it too);\n- `nextSteps` \u2014 how to resume after the human\'s yes.\n\nRelay the envelope to the human, wait for an explicit yes, resume exactly as\ninstructed. The AI never approves, never invents a secret, never deploys F-logic.\n\n**Confirmation dialog.** When the client supports elicitation, the crossing calls (`tia_download` with\n`approved:true`; `tia_upload`, `tia_online`, `tia_accessible_devices` with `confirm:true`) first ask the\nhuman in a dialog; clients without it behave as before. The dialog only checks the human\'s answer: the\n`planHash` and serve\'s approval token stay the authority.\nPasswords (G6) are never asked there. `declined_by_human` / `cancelled_by_human` = the human refused:\nnothing was sent, no retry unless asked. `elicitation_failed` (`isError`) = the dialog could not be\nshown or answered, nothing was sent (fails closed).\n\n## After scaffolding\n\n- Re-run `tia_compile` after ANY authoring change.\n- `tia_project_save` regularly; `tia_project_archive` BEFORE risky operations\n (firmware change \u2014 see `tia_guide {"topic":"gotchas"}`).\n- Auditing an existing project is class R (`tia_plc_*` reads); baseline: `tia_guide {"topic":"recipes"}`, \'Reference \u2014 network, audit and CAx how-to\'.\n- `tia_crossrefs` (class R, a long read: it may answer `status:"running"` + `jobId`, then poll\n `tia_job_status`) reads the cross-references: in an audit, `filter:"UnusedObjects"` lists\n unused-object CANDIDATES, never proof (OBs, objects used only from outside the PLC such as an\n HMI, OPC UA or another CPU, and library TYPEs show as unreferenced); before changing an\n existing object, `target` + `kind` + `filter:"ObjectsWithReferences"` returns the objects related\n to it with each `referenceType` and `access` as TIA reports them (the direction of `Uses` /\n `UsedBy` is not interpreted: the human confirms it). Page a whole-PLC or container read with `limit`\n (for example 200) and `cursor` (the `nextCursor` of the previous page, until it is null; on\n `cursor_stale` restart from the first page, and on an omission marker repeat the same request\n with a smaller `limit`, never following a cursor from an omitted page); each page re-reads the\n whole PLC, so a later page can report less than an earlier one. Read `coverage` on every page,\n not only the first, and compare its counts across pages: differing counts restart the walk once\n from the first page (like `cursor_stale`). Only a finished walk whose pages all report\n `coverage.complete: true` supports "audited completely" or "nothing uses this"; an omission\n marker, an unfinished walk, differing counts or `coverage.complete: false` on any page (see\n `coverage.unavailableOwners`) means the result is NOT complete.\n- **FAT/SAT I/O list** (`tia-verify` step 6): `tia_io_map`; recipe: `tia_guide {"topic":"recipes"}`, \'Recipe \u2014 generate the FAT/SAT I/O list\'.\n- **Prove the project matches what\'s versioned** (a raw hash is NOT proof): `tia_guide {"topic":"recipes"}`, \'Recipe \u2014 prove the project matches the versioned XML\'.\n\n## Network lifecycle (subnets, PROFINET names, IO systems)\n\nRead first (`tia_subnet_get`, `tia_device_network`, `tia_io_systems`), then run each write\'s `dryRun` (answered by\nthe serve, needs an open project). Order, PROFINET names, `disconnectNodes`: `tia_guide {"topic":"recipes"}`, \'Reference \u2014 network, audit and CAx how-to\'.\n\n- **Refused, nothing changed:** `tia_subnet_delete` of a non-empty subnet (`409 subnet_not_empty`);\n `tia_io_system_connect` across subnets (`409 cross_subnet_assignment`: `tia_network_connect` the device to that subnet first).\n- **`409 postcheck_failed`:** the write did not take effect as asked: re-read, never repeat blindly.\n\n## Libraries, HMI, CAx and PLC security\n\nReads are class R; every change is class M-off (offline, with `dryRun`) and reaches the CPU\nonly through a later `tia_compile` + human-gated `tia_download` (G3). Every file path is a\npath ON THE SERVE HOST.\n\n- **Guarded PLC writes** (`tia_tag_update`, `tia_constant_update`, `tia_constant_delete`,\n `tia_tagtable_delete`, `tia_block_group_delete`, `tia_ob_create`, `tia_block_compile`): the serve\n answers their `dryRun` (it needs an open project) with the guard verdict (name collision, default\n tag table, non-empty group, singleton OB).\n- **Project library:** `tia_library_mastercopies` / `tia_library_types` read it;\n `tia_library_mastercopy_create` turns a DEVICE into a master copy (a block cannot be a source);\n `tia_block_from_mastercopy` needs one that holds PLC blocks.\n- **Global libraries** (in the TIA Portal session, not the project): `tia_global_libraries`,\n `tia_global_library_create` / `_open` / `_save` / `_close`; save/close take the name from\n `tia_global_libraries` (exact name first, then ignoring case). REFUSED, nothing saved or closed\n (`404 not_found` / `409 conflict`): a name that picks no single open USER library (unknown, read-only\n system/corporate, several matches ignoring case) and a save of a `readWrite:false` library. Up to app\n 1.6.3 an unknown name can report success without saving or closing anything: check `tia_global_libraries`.\n- **HMI:** `tia_hmis` and `tia_hmi_screens` read any HMI; screen files\n (`tia_hmi_screen_export`, `tia_hmi_screens_import`) work for WinCC **Classic** only, and the\n import OVERWRITES same-named screens.\n- **CAx (AutomationML):** `tia_cax_export` / `tia_cax_import` (scope, `option` values: recipes). Archive the\n project before an overwrite. A failed transfer is an error after app 1.6.3; on an older serve check the\n devices with `tia_devices`.\n- **Error contracts by app version:** `tia_guide {"topic":"recipes"}`, \'Reference \u2014 global library and CAx error contracts (by app version)\'.\n- **PLC security:** `tia_certificates` / `tia_certificate_template` / `tia_password_policy`\n read; `tia_certificate_import` / `_export` / `_delete`, `tia_password_policy_set` and\n `tia_block_protect` change the project. **G6:** a block or certificate password and the\n password-policy values come from a HUMAN \u2014 never invent, guess or reuse one; dryRun plans\n show a password as `[redacted]`. A CPU without the certificate manager or a policy service\n answers 409.\n- **Multiuser:** `tia_project_servers`, `tia_server_projects` read Project Servers; `tia_local_session_open` needs NO open project (`tia_project_close`, `tia_start`). Nothing is ever checked in.\n';
|
|
23949
|
+
var RECIPES = '# Recipes (runtime-verified) & scaffold order\n\n## Pipeline order (dependency-correct)\n\n`tia_spec_apply` automates only steps 1-4, the tag tables and tags of 6, the FB shells and control-module instance DBs of 8, and the compile of 9. Protection (5), constants (6), UDTs (7), OB/FC/DB blocks and all block logic stay manual: declaring `dataTypes` in the spec imports nothing. The FB shells of 8 are empty: their logic is step 8 by hand.\n\n1. **Subnets** (`tia_subnet_create`) \u2014 before connecting devices to them.\n2. **Devices** (`tia_device_create`, `OrderNumber:<MLFB>/V<fw>`) \u2014 CPUs first.\n3. **Modules** (`tia_device_plug`) \u2014 into existing devices, by slot.\n4. **Network** (`tia_network_connect`, IP, `createIoSystem`) \u2014 CPU + its IO-devices on the\n **same** subnet; exactly one `createIoSystem` per IO-system.\n5. **Protection recipe** (below) \u2014 so the CPU can compile clean.\n6. **Tag tables** (`tia_tagtable_create`) \u2192 **tags** (`tia_tag_create`) \u2192 **constants**.\n7. **UDTs first** (`tia_types_import`), **then** blocks that use them.\n8. **Blocks** \u2014 the FB comes with its logic: `tia_source_put` (SCL) or `tia_import_xml` (LAD/FBD/GRAPH), Gd6 format\n routing (`tia_fb_create` only makes an empty FB shell); then its instance DB (`tia_instancedb_create`).\n9. **Compile** (`tia_compile`) \u2014 the verifier; only `Error` blocks. It compiles the **software**\n scope (not just the CPU device item), so it makes freshly-generated blocks consistent and, in\n most cases, **regenerates** any instance DB left inconsistent by an FB interface change.\n **Recompile first**; only if the DB still reports inconsistent after a compile, delete it\n (`tia_block_delete`), recreate it (`tia_instancedb_create`) and recompile.\n\n**The PlcSoftware name.** TIA names the PlcSoftware of a CPU created through `tia_device_create` or `tia_spec_apply` after the CPU device item (default `PLC_1`), not the device, so `plc` in steps 6-9 is the name from `tia_plcs`. The spec plan carries `{plc}`; `tia_spec_apply` resolves it after the device step (`plc.resolve` in `applied`) and stops with kind `plc_unresolved` rather than guess. `devices[].plcName` names the CPU item.\n\n## Recipe \u2014 edit an existing block or type without overwriting a newer change (stale-write guard)\n\nRead it with `tia_export_block` (block) or `tia_export_type` / `tia_type_source` (type) and keep its `contentHash`: `contentHash`, `normalizedSha256` and `sha256` are different hash contracts over different normalizations, so never substitute one for another and pass only the `contentHash` of a fresh read as `expectedContentHash`. Edit, then write it back with `tia_import_xml`, `tia_source_put` or `tia_types_import` passing `expectedContentHash:<that contentHash>` (one object per write); on `state_changed` NOTHING was written \u2014 re-read, merge your edit onto the current content and retry with the new `contentHash`; a guarded write never compiles, so a block that is not consistent is refused with `409 inconsistent` (NOTHING written) \u2014 `tia_compile`, re-read with `tia_export_block` for the current `contentHash`, retry; an object whose current export is not well-formed XML has no hash (its read answers `contentHashError` instead of `contentHash`) and a guarded write over it is refused with `409 unverifiable` (NOTHING written) \u2014 repair or re-export it in TIA Portal, or retry WITHOUT `expectedContentHash` (an unguarded write); a verified write returns `contentGuard`.\n\n## Recipe \u2014 unlock a freshly-created CPU so it compiles clean (VERIFIED V21, firmware-dependent)\n\nA bare CPU added via Openness may fail `compile` with **protection** errors: the\n*confidential-PLC-configuration-data* password is unset, the *communication certificate*\ncan\'t be generated without it, and (on newer firmware) the *access control* defaults to a\nprotected level needing a password. **The recipe differs by CPU family/firmware \u2014 there is\nno single universal form.** Fix, in order:\n\n**Tell the human first.** The recipe lowers the CPU\'s protection in the project: it sets the\nconfidential-configuration password (typed by the human) and then either sets the access level\nto **Full access** (S7-1500) or turns access control **off** (S7-1200, FW V4.5+). The CPU runs\nwith that protection after the next download. Name these changes when you ask for the password\nand list them in the report; the human may pick a stricter level in the TIA GUI before deploying.\n\n**(1) Confidential-data password \u2192 also auto-generates the certificate** (common to both\nfamilies):\n\n```\n# find the CPU device-item handle:\ntia_obj_roots -> the device handle (role:"device")\ntia_obj_items { handle:<device>, composition:"DeviceItems" } -> the CPU item handle\n# acquire the service ON THE CPU MODULE (not the rack) and invoke Protect:\ntia_obj_service { handle:<cpu>, type:"Siemens.Engineering.HW.Features.PlcMasterSecretConfigurator" } -> <svc>\ntia_obj_invoke { handle:<svc>, name:"Protect", args:["<password>"] }\n```\n\n**(2) Clear the access-control error \u2014 pick the variant for the CPU\'s family/firmware:**\n\n- **S7-1500 V2.9** (verified 2026 on real hardware \u2014 a 1516-3 V2.9, 3 errors \u2192 0): set\n `PlcProtectionAccessLevel = "FullAccess"` **on the CPU device item**:\n\n ```\n tia_obj_set_attributes { handle:<cpu>, attributes:{ "PlcProtectionAccessLevel":"FullAccess" } }\n ```\n\n- **S7-1200 V4.7** (new security model, FW \u2273 V4.5; per `docs/HARNESS-KNOWLEDGE.md` \xA72,\n runtime-observed): set `PlcAccessControlConfiguration = "Disabled"` on the\n **`PlcAccessControlConfigurationProvider`** SERVICE \u2014 not a direct attribute on the CPU\n item:\n\n ```\n tia_obj_service { handle:<cpu>, type:"Siemens.Engineering.HW.Features.PlcAccessControlConfigurationProvider" } -> <svc2>\n tia_obj_set_attributes { handle:<svc2>, attributes:{ "PlcAccessControlConfiguration":"Disabled" } }\n ```\n\n \u26A0\uFE0F **The two variants are mutually exclusive \u2014 the wrong one returns HTTP 500 on the\n other family:** `PlcAccessControlConfiguration` isn\'t on a 1500\'s CPU item, and\n `PlcProtectionAccessLevel` isn\'t the right model on a 1200 V4.7 item. Detect the\n family/FW \u2014 or the compile-error signature \u2014 before picking a variant.\n\n- **S7-1200 V4.0** (old security model): nothing to do here \u2014 the same bare-CPU condition\n is only a **WARNING**, not an error; a plain `tia_compile` already returns `errors: 0`.\n\nThen `tia_compile` \u2192 `state: Warning, errors: 0` (any remaining warnings \u2014 e.g. CPU-display\npassword \u2014 are benign and do **not** block; Gd8).\n\n> **Requires the `tia_obj_service` tool** (acquire `GetService<T>` \u2192 handle) for step 1 and\n> for the S7-1200 V4.7 variant of step 2. Without it the MCP cannot run either.\n\n### Policy \u2014 who supplies the confidential password\n\n`Protect()` sets an **offline project** password (it is not the online master secret / G6), but\nit protects confidential configuration data, so **the human supplies it, every time** (the\nrecommended policy, pending the product owner\'s confirmation): the project-spec has no field\nfor it, and a skill never invents, defaults, stores or logs it. The online master secret (`tia_mastersecret_set`, G6) is **always**\nhuman-supplied too.\n\n## S7 connection precondition (G2)\n\n`tia_connection_create` needs **\u2265 2 CONSISTENT CPUs** (both compile clean). Two *bare* CPUs\nnever form a valid S7 connection \u2014 apply the protection recipe + `tia_compile` to make each\nconsistent first, then create the connection. Use `tia_connections_diagnose` on failure.\n\n## Recipe \u2014 bump the project firmware **in-place** (keeps the program) (VERIFIED, V21 / S7-1200 1214C)\n\nBumped a project **V4.0 \u2192 V4.4** on a real S7-1200 1214C **without losing blocks or tags**\n(verified 2026-06-07). Use this for **auto-FW-match**: align the project to the firmware\nactually read from the CPU. `DeviceItem.ChangeType(typeIdentifier)` changes the item type\nin place and **preserves the software** \u2014 it does **not** require delete/recreate.\n\n```\n# archive first (see the warning below), then change the CPU\'s type to the SAME MLFB with the target /V<fw>:\ntia_device_change_version { plc:"<plc>", typeIdentifier:"OrderNumber:6ES7 214-1HG40-0XB0/V4.4" }\n# then recompile \u2014 a regenerated FB may need a fresh compile before download:\ntia_compile { ... }\n```\n\n(`tia_device_change_version` runs `ChangeType` on the CPU item for you; the raw form, `tia_obj_invoke`\nwith `name:"ChangeType"` on the CPU item handle from `tia_obj_roots` / `tia_obj_items`, does the same.)\n\n- **Rule: `project FW \u2264 device FW`** \u2014 never set the project firmware **higher** than the physical\n device\'s (download would be rejected). Bumping the project *up to* the device FW is the safe move.\n- Keep the **same MLFB**, swap only the `/V<fw>` suffix. The program (blocks/tags) survives.\n- After `ChangeType` the CPU/blocks can be inconsistent; **always recompile** before any handoff.\n- **\u26A0\uFE0F `ChangeType` RESETS GUI-gated comm settings** (runtime-validated on the 1214C): it **disabled\n the OPC UA server** (`OpcUaServer`\u2192`false`) and **cleared the OPC UA runtime-license** selection\n (the custom server interface and PUT/GET *survived*). So **`tia_project_archive` first** on a CPU\n with hand-configured OPC UA/PUT-GET, and **re-verify after**. Recovery: `tia_obj_set_attributes\n {handle, attributes:{OpcUaServer:true}}` on the "OPC UA" device-item (it **is** writable; re-select the license in the\n GUI). `ChangeType` to the **same** version is rejected ("Cannot change the type of the device item").\n\n## Recipe \u2014 enable a **Modbus TCP server** (`MB_SERVER`) on the S7-1200 (VERIFIED, FW V4.0)\n\nLets an external client (e.g. a Node backend) read/write the CPU over **Modbus TCP, port 502**\n(verified 2026-06-07; full backend/app detail in `docs/COMM-SCENARIOS.md`).\n\n1. **Non-optimized DB with an `Array of Word`** for the holding-register block (`MB_HOLD_REG`).\n Modbus needs a byte-addressable (non-optimized) DB \u2014 optimized access won\'t map.\n2. **On FW V4.0 use `MB_SERVER` V1.x**, which takes **`CONNECT_ID` + `IP_PORT`** parameters\n (**not** `CONNECT`/`TCON`, which the newer instruction versions use). Pin the instruction\n version when generating the FB.\n3. Instantiate `MB_SERVER` as a **multi-instance inside an FB** (its instance lives in the FB\'s\n instance DB), call it cyclically.\n4. **Map a holding register \u2192 a command tag** (e.g. `MB_HOLD_REG[0]` \u2192 `LedCmd`), so writing the\n register drives the output.\n\n> **Instance-DB gotcha (the big one):** when you regenerate the FB via `tia_source_put`, the\n> existing **instance DB** can go inconsistent (its interface no longer matches the FB).\n> **Recompile first** \u2014 a software-scope `tia_compile` regenerates the instance DB in most cases.\n> Only if it still reports inconsistent after a compile (typical when the interface was edited via\n> source), delete + recreate it, then recompile:\n>\n> ```\n> tia_compile { ... } # try first\n> tia_block_delete { ... the stale instance DB ... } # only if still inconsistent\n> tia_instancedb_create { ... fresh instance DB for the FB ... }\n> tia_compile { ... }\n> ```\n>\n> (Matches the \xA7Pipeline note: recompile first, delete+recreate only as the fallback.)\n\n## Recipe \u2014 enable **S7 / PUT-GET** on the S7-1200 (port 102)\n\nLets an external S7 client (e.g. `nodes7`) read/write the CPU over **S7comm, port 102**.\n\n1. **GATE (human, GUI only):** enable PUT/GET \u2014 *Properties \u2192 Protection & Security \u2192\n Connection mechanisms \u2192 "Permit access with PUT/GET communication"*. **Not exposed by\n Openness** on this CPU/FW (we tried `PlcAccessLevelProvider` \u2014 no toggle). Mark it as a\n **human gate** and surface it in `tia-handoff`; do **not** attempt to script it.\n2. **Non-optimized DB** for the data the client touches (PUT/GET addresses absolute offsets, so\n the DB must be byte-addressable / non-optimized).\n3. Compile + download as usual; the client then reads/writes the DB by area+offset.\n\n## Recipe \u2014 enable **OPC UA** on the S7-1200 (port 4840)\n\nLets an external OPC UA client read/write the CPU over **OPC UA, port 4840**. This path is the\nmost gated \u2014 most of it is **human GUI steps**, not Openness.\n\n**Prerequisite \u2014 firmware \u2265 V4.4.** OPC UA server isn\'t available on V4.0. If the project is on\nan older FW, bump it in-place first (see *bump the project firmware in-place* above \u2014\n`ChangeType` to `.../V4.4`).\n\nThen the setup sequence. **Step 1 is scriptable; steps 2\u20133 are human/GUI** on this CPU/FW (for those two\nwe tried `CommunicationManagement` and `OpcUaUserManagement\u2192404`):\n\n1. **Activate the OPC UA server** \u2014 *Properties \u2192 OPC UA \u2192 Server* (enable). *(This step **is**\n scriptable via Openness: `tia_obj_set_attributes {handle, attributes:{OpcUaServer:true}}` on the "OPC UA"\n device-item \u2014 it auto-generates the server certificate. Steps 2\u20133 stay GUI-only.)*\n2. **Select the runtime license** \u2014 *"SIMATIC OPC UA S7-1200 Basic"* (Runtime licenses).\n3. **Create a server interface** that **exposes the DB** \u2014 the **S7-1200 does NOT auto-expose**\n tags/DBs to OPC UA (unlike the S7-1500), so you must add a server interface and place the DB\n nodes in it manually.\n\n**Finding the node IDs (client side):** browse `ns=3;s=ServerInterfaces` with any OPC UA client;\nthe actual data nodes show up under **`ns=4`**. Use those node IDs from the backend.\n\n> What Openness *can* still do here: create the DB/blocks, compile, download \u2014 **and activate the OPC UA\n> server** (step 1: `tia_obj_set_attributes {handle, attributes:{OpcUaServer:true}}`; do NOT gate it on a human). Only **three**\n> items are truly human/GUI: the **runtime license**, the **server interface** \u2014 and **PUT/GET** in the S7\n> recipe. See `docs/TIA-Openness-Casos-de-Uso.md` \xA78c for the full "GUI-only gates" table.\n\n## Recipe \u2014 WinCC Unified HMI: read, then guarded writes\n\nOnly for a WinCC **Unified** HMI (`tia_hmis` \u2192 `kind:"unified"`). A Classic HMI answers `409 hmi_not_unified`; use the screen export/import there. Everything below is offline (M-off): it edits the project, never the panel or the PLC.\n\n1. **Read first.** `tia_hmis` for the HMI name, then `tia_hmi_tag_tables`, `tia_hmi_tags` (`table`), `tia_hmi_alarm_classes`, `tia_hmi_alarms` (`kind`: `discrete`|`analog`) and `tia_hmi_connections`. Every read pages (`limit` 1..1000, `cursor`): follow `nextCursor` UNCHANGED, and on `cursor_stale` restart from the first page. Read `inventoryGaps` too: a non-empty list means a value reads `null` because Openness refused it, so do not write on the strength of that value.\n2. **Baseline.** `tia_hmi_validate` (scope `all`, or `tags`/`alarms`/`connections`/`screens`) aggregates the per-object `Validate()` results into `errors`, `warnings` and `findings`. Unified has NO compile: a clean validate is not a clean compile, and it can be slow (Long).\n3. **`dryRun:true` on EVERY write first** (`tia_hmi_tag_table_create|delete`, `tia_hmi_tag_create|update|delete`, `tia_hmi_alarm_create|update|delete`). The plan runs the same guards as the real call and changes nothing; repeat without `dryRun` only when it answers `plan_ok`. The real answer carries `postcheck` (`verified:true`, `requested` equal to `actual`). `409 postcheck_failed` is NOT a success: read the object again before going on (`rollback` says what was undone; a delete is never rolled back).\n4. **What the guards enforce \u2014 fix the cause, do not retry the same call.** Names: letters, digits and `_`, starting with a letter or `_` (tag tables may also hold spaces and `-` inside), at most 128 characters (`invalid_name`), unique ignoring case (`name_collision`). `dataType` is an allow-list: Bool, Byte, Char, DInt, DWord, Int, LInt, LReal, LWord, Real, SInt, String, UDInt, UInt, ULInt, USInt, Word, WChar, WString, DateTime, Time (`invalid_data_type`). A tag without `connection` is internal and needs `dataType`; with `connection` it is external and takes exactly one of `plcTag` or `address`. A PLC-bound tag needs a `plcTag` that EXISTS in the connected PLC (`plcName` when the connection\'s partner does not resolve to one PLC): `plc_unresolved` / `reference_not_found` mean fix the link, never invent a tag. A PLC tag whose own name contains a dot or a bracket is sent as ONE quoted token (`"A.B"`, `"Valve[1]"`): unquoted, `A.B` is member `B` of data block `A` and `Valve[1]` is an indexed name, so the call is refused. A discrete alarm needs an existing `alarmClass` and `triggerTag` and a `triggerBit` inside the width of the tag\'s type (Bool: 0, Word: 0..15; `trigger_bit_out_of_range`); an analog alarm has ONE `condition` and ONE `conditionValue` on a numeric tag (no limit ordering exists), and the value must fit the type (`condition_value_out_of_range`).\n5. **Alarm values, event text and what a read shows.** TIA stores the condition value of an alarm as a double: on an `LInt`, `ULInt` or `LWord` trigger tag a whole `conditionValue` above 2^53 in absolute value is refused `409 condition_value_out_of_range` (a `dryRun` too, nothing written); 2^53 itself is accepted, sent as a string, and `Real` and `LReal` values are always JSON numbers. `eventText` is PLAIN single-paragraph text per active project language: the serve wraps it as the rich text TIA stores (`<body><p>\u2026</p></body>`) and escapes `&`, `<` and `>`, so send no markup; a line break, an XML-invalid character (a tab is allowed), an unpaired surrogate, a blank text or more than 1024 characters is `400 bad_request`, and a text cannot be cleared by a write. A read answers the plain text (an event-text item without text is `""`, a language without an item `null`; any other markup comes back as raw rich text, which cannot be written back). TIA\'s placeholders read as `null`: an internal tag has `connection`, `plcName`, `plcTag`, `address`, `accessMode`, `acquisitionMode` and `acquisitionCycle` all `null` (TIA reads its connection back as a placeholder such as `<Internal tag>`), and an alarm class without a common class has `commonAlarmClass` `null` (`<No alarm class>`). The attribute list of an alarm itself is never read: `hmi_attribute_list_unavailable` and `hmi_attribute_not_writable` apply to tags and to the event text item of each culture (its list unreadable, `Text` not writable, or no item for that language), never to another alarm attribute.\n6. **Deleting.** A tag, or a tag table that holds one, is refused with `tag_in_use` while an alarm references it; a non-empty table needs `recursive:true` (`tag_table_not_empty`); the default table is refused. References from screens, scripts and logging are NOT scanned, so run `tia_hmi_validate` again after a delete.\n7. **Finish** with `tia_hmi_validate` and compare `errors` and `findings` with the baseline.\n\nLimits to remember: a **create\'s `dryRun` cannot check writability** (a `plan_ok` can still end in `hmi_attribute_not_writable`, after which the new object is removed again); an **update checks only what it changes** (a tag change against the stored bit or value, a connection change against its link), never a reference it leaves alone, and never switches a tag between `plcTag` and `address` \u2014 `tia_hmi_validate` finds a dangling carried reference; send a whole `conditionValue` as a **JSON integer or a string** (`5.0` and `1e3` are refused, and so is a whole value above 2^53 on an `LInt`, `ULInt` or `LWord` tag: step 5); a system tag may be an alarm trigger tag; `tia_hmi_validate` is Long, so it may answer `status:"running"` with a `jobId`: follow `tia_job_status` and never repeat the call.\n\nNo tool creates an HMI connection: when `tia_hmi_connections` is empty, PLC-bound tags cannot be created \u2014 ask the human to create the connection in TIA Portal.\n\n## Recipe \u2014 diff a project against a VCI workspace, or round-trip a block through a new one\n\nA VCI workspace is a folder on the serve host that mirrors project objects as files, so a diff tool or git can version\nthem. VCI takes **leaf objects only** (PLC blocks, PLC data types, tag tables): a device, a PLC, a group or the library is\nrefused with `409 vci_not_leaf` before VCI is called. Every write takes `dryRun:true` first (Gd11), a call holds at most 50\nobjects, and a batch is NOT a transaction: it stops at the first failure.\n\n**(1) A workspace that already has mapped objects is a baseline: its diff is READ-ONLY.**\n\n```\ntia_vci_workspaces -> `mappedObjects` above 0: a baseline exists\ntia_vci_status { workspace:"WS_1", limit:100 } -> follow nextCursor until it is null\n```\n\nClassify every row. `equal` is the only verified match. `projectChanged` (the project object changed), `workspaceChanged`\n(the file changed), `conflict` (both), `workspaceFileMissing` (the file is gone) and `unequal` (a difference of unknown\nside) are differences: report each by name, they are the result, not something to repair. `unknown`, `unsupported` and\n`statusFailed` prove nothing, neither equality nor a diff: report them by name, and the diff is NOT complete. **Never\nexport or import just to make a comparison equal.** `tia_vci_export` over a mapped object REPLACES its workspace file\nwith the project content (the plan says `action:"synchronize"`) and `tia_vci_import` replaces the project object with\nthe file, so either one destroys the difference you were asked to see. Refreshing the baseline is an explicit decision\nof the human: name the objects, ask, and only then export with `dryRun:true` first and read which files the plan\nreplaces.\n\n**(2) A NEW workspace, or new objects: export, then prove it.**\n\n```\n(a) tia_vci_workspaces -> reuse a workspace that is listed\n # none yet: ask the HUMAN for the root folder on the serve host. Never choose or invent a rootPath.\n tia_vci_workspace_create { name:"WS_1", rootPath:"<the folder the human gave>", dryRun:true }\n tia_vci_workspace_create { name:"WS_1", rootPath:"<the same folder>" } -> created | reused\n(b) tia_vci_export { workspace:"WS_1", objects:[{ kind:"block", name:"FB_Motor" }], dryRun:true }\n tia_vci_export { workspace:"WS_1", objects:[{ kind:"block", name:"FB_Motor" }] } -> the file(s) written\n(c) tia_vci_status { workspace:"WS_1", limit:100 } -> follow nextCursor until it is null\n(d) tia_export_block { plc:"PLC_1", block:"FB_Motor" } -> contentHash\n tia_block_set_attribute { plc:"PLC_1", block:"FB_Motor", name:"HeaderAuthor", value:"<a new text>" } -> an edit IN PLACE: the mapping survives\n tia_block_compile { plc:"PLC_1", block:"FB_Motor" }\n tia_export_block { plc:"PLC_1", block:"FB_Motor" } -> a DIFFERENT contentHash\n tia_vci_status { workspace:"WS_1", limit:100 } -> that row is now projectChanged\n(e) tia_vci_import { workspace:"WS_1", objects:[{ kind:"block", name:"FB_Motor" }], dryRun:true }\n tia_export_block { plc:"PLC_1", block:"FB_Motor" } -> a fresh contentHash\n tia_vci_import { workspace:"WS_1", objects:[{ kind:"block", name:"FB_Motor", expectedContentHash:"<fresh>" }] }\n tia_export_block { plc:"PLC_1", block:"FB_Motor" } -> the import REPLACED the project object: read it again by name\n tia_vci_status { workspace:"WS_1", limit:100 } -> that row is equal again\n```\n\n- **(b) Read the plan.** `action:"export"` creates a new file; `willCreateDirectory:true` on an object means the serve will\n create its target folder (the first export into a fresh workspace has none yet), and the dry run creates nothing. An\n object the plan lists as `synchronize` is already\n mapped and its file would be REPLACED: stop and go back to (1). `format` chooses the file format of an UNMAPPED object\n only (leave it out unless the serve answers `400 bad_request` with `details.supportedFormats`); a mapped object keeps its\n mapping\'s format and the selector is neither applied nor validated for it.\n- **(c) Verify an export.** Every row of every page must be `equal`. Read `coverage` on EVERY page: `summary` and\n `coverage` describe only the rows of that response (the serve compares only the rows of the page), so fold them over all\n pages before saying the workspace is in sync. `409 cursor_stale` (a mapping appeared or went) restarts the walk once.\n- **(d) Edit the project IN PLACE, never by regenerating.** A block attribute (`tia_block_set_attribute`, a header attribute such as `HeaderAuthor`) keeps the project object, so its mapping stays and the row becomes `projectChanged` (measured on V21). If `tia_export_block` shows the same `contentHash` afterwards, that attribute is not part of the exported XML: try another header attribute (`HeaderFamily`, `HeaderName`). `tia_source_put` (regenerating the block from SCL) REPLACES the project object, and V21 DROPS its VCI mapping (measured): the row vanishes from `tia_vci_status` and `tia_vci_import` answers `409 not_mapped`, which is the correct answer, not a fault; `tia_import_xml` over an existing block replaces it the same way (not measured separately). Export the new object again to map it: `tia_vci_export` is refused `409 vci_path_collision` (`reason:"file_exists"`) while the old workspace file is still in the folder, so ask the human to remove or move that file first; on a baseline you were asked to diff, report the dropped mapping instead of exporting over it.\n- **(d) What a row says.** Only `equal` is a match. After a human edits a workspace file its row should show\n `workspaceChanged`; a row that still says `equal` after a known edit means the status is not live (V21 has no refresh\n call): say so and treat the check as NOT verified.\n- **(e) Read the plan before importing, and read the hash per kind.** The dry run shows per object `statusBefore` and\n `overwritesProjectChanges` (`true` for `projectChanged` and `conflict`: the import discards an edit that exists only in\n the project, there is no undo, so ask the human). An object that is already `equal` is skipped. The hash reader depends\n on the kind: a block uses `tia_export_block`, a type uses `tia_export_type { plc:"PLC_1", type:"UDT_Motor" }`, and a tag\n table has NO hash (the serve and the MCP refuse `expectedContentHash` for it), so rely on the dry run and the postcheck.\n A wrong `expectedContentHash` is `409 state_changed` and nothing was written.\n- **An import REPLACES the project object.** After a real import the old object is disposed: a handle of it (`tia_obj_*`) and every value read before are stale, so re-read the block by name (`tia_export_block`, `tia_plc_blocks`) and then `tia_vci_status`. The serve does the same for its postcheck: an object it cannot find again by name, or whose mapping the replacement dropped, is `409 import_unverified` (the object WAS written). In a batch, an object that can no longer be found or mapped when its turn comes stops the batch there: `409 vci_batch_incomplete` naming it, or `409 conflict` when nothing was imported yet; nothing more is written.\n- **Verified only with a postcheck.** An import is done only when every imported object has `postcheck.verified:true`. Every\n other answer means it is NOT verified: `409 import_unverified` (the object WAS written, review it with `tia_export_block`\n or `tia_export_type`), `409 vci_batch_incomplete` (the objects in `done` WERE written), a status row `unsupported`,\n `statusFailed` or `unknown`, `coverage.complete:false`, an omission marker that survives smaller `limit` retries, or a\n page walk that did not finish.\n- **Unknown outcomes.** `504 worker_restarted`, a `timeout` or a lost session during an export or an import leaves the\n outcome UNKNOWN or partial: walk `tia_vci_status` and re-read the object before repeating anything.\n- **Refusals before any write** (nothing changed): `vci_path_collision` (two objects, another mapping or an existing file\n share a target; `reason:"alias_unverifiable"` means the short 8.3 name of an existing file in the target folder could not\n be read, so a collision with its alias cannot be excluded), `vci_path_too_long`, `vci_mapping_outside_workspace` for an\n EXISTING mapping rejected in the plan, `not_mapped` (export it first), `workspace_file_missing`, `workspace_exists`,\n `workspace_root_in_use`, `workspace_ambiguous` (ask the human which workspace is meant) and `vci_inventory_incomplete`\n (the workspace inventory could not be read completely: report it and stop, never guess a workspace).\n- **`vci_mapping_outside_workspace` has TWO outcomes.** An existing mapping rejected in the plan changed nothing. After a\n NEW export the same kind means the file WAS written outside the workspace root: read its message and `details`\n (`object`, `directory`, `root`, `done`), report it, hand the cleanup to the human and never retry blindly.\n\n## Reference \u2014 global library and CAx error contracts (by app version)\n\n**Project library** (`tia_block_from_mastercopy`). A device copy is refused (`409 mastercopy_not_blocks` after app 1.6.3; up to 1.6.3 a 500).\n\n**Global libraries** (`tia_global_library_save` / `_close`). After app 1.6.3 a name that picks no single open USER library is refused, nothing saved or closed: `404 not_found` (`details.userLibraries` lists the names that work), or `409 conflict` for a read-only system/corporate library or a name several user libraries match only ignoring case; up to 1.6.3 the serve reports success even for an unknown name. A library opened read-only (`readWrite:false`) cannot be saved: `409 conflict` (`details.readOnly`) after app 1.6.3, a 500 up to 1.6.3 \u2014 close it and open it again with `readWrite:true` to change and save it.\n\n**CAx (AutomationML)** (`tia_cax_export` / `tia_cax_import`). A failed transfer is an error (`500 cax_transfer_failed`) after app 1.6.3; up to 1.6.3 the serve returns an opaque `result` even on failure \u2014 check the devices with `tia_devices`.\n\n## Reference \u2014 download plan fingerprint limits\n\n**Fingerprint limits** (`tia_download`): user program blocks, UDTs and tag tables only \u2014 no hardware configuration, system block groups, S7-1500 software units or technology objects; per-object fallback to modification dates (`source:"dates"`, warned in the plan \u2014 dates can false-positive `plan_stale`).\n\n## Recipe \u2014 generate the FAT/SAT I/O list (tia_io_map)\n\n**Generate the FAT/SAT I/O list** (`tia-verify` step 6). `tia_io_map` (`jobId` \u2192 `tia_job_status`), one\nlist per PLC, `limit:100`, `cursor` = previous `nextCursor` unchanged until null. Read `coverage` on every\npage; `cursor_stale` or differing coverage restarts once; omission marker: same call and cursor, half the\n`limit`, max 3 times, never follow its cursor. Rows: one per tag on a `channel`, or on a `range` with\nstatus `matched`; per unmatched `tag` entry; and (empty tag) per unmatched `channel` or channelless\n`range`; none for a `range` with status `channels`; a tag spanning channels: ONE row (`table`+`name`)\nlisting them; statuses `matched`|`unmatched`|`conflict` only. Unresolved channels/ranges and unparsed\ntags: "Could not be mapped". Print `coverage` numbers, `coverage.limits`, DERIVED addresses (spot-check in\nTIA). Complete ONLY after a finished walk with no marker left on ANY page and `coverage.complete: true`,\nsame counts, on every page; else start "NOT complete", say why. An unmatched tag is never\n"unused"/"orphan"; never invent, round or fix an address. Read-only; the human signs.\n\nLengths: a `range`\'s `start` is a byte number and its `length` is in BYTES (Openness reports an address length in bits and the map converts it, rounding up to whole bytes); `from` and `to` are its first and last bit (2 bytes from `%I0.0` end at `%I1.7`). `tia_device_tree` shows the raw Openness value, in BITS: convert before comparing the two.\n\n## Recipe \u2014 prove the project matches the versioned XML (tia_block_compare)\n\n**The project matches what\'s versioned \u2014 prove it, don\'t assume it.** A raw hash of an\nexport is NOT proof (two exports of the same block differ in `<Created>`/UIds). Use\n`tia_export_block` to pull a block inline and `tia_block_compare` to diff it against the\ncommitted XML (normalized \u2014 ignores formatting/BOM/`<Created>`/UIds); `verdict:"equal"` is\nthe actual round-trip proof. After `tia_compile`/`tia_source_put`, read `blockChanges` and\nexport/commit any regenerated instance DBs before calling the project verified.\n\n## Reference \u2014 network, audit and CAx how-to\n\n**Network lifecycle.** `tia_subnet_delete` on a non-empty subnet is refused (`409 subnet_not_empty`); `disconnectNodes:true` disconnects its nodes and removes its IO systems. A subnet rename (`tia_subnet_update` `name`) takes at most 24 characters: a longer name is `400 invalid_subnet_name` (a `dryRun` too, nothing changed) although `tia_subnet_create` accepts longer names; a name equal to the current one is not a rename, and the serve counts UTF-16 code units, spaces included. PROFINET name (`tia_pn_name_set`): lower-case DNS labels (`a-z0-9-`) split by `.`, not an IP look-alike. A node in its default state (automatic name generation on, `PnDeviceName` read-only) takes a `name`: the serve switches auto-generation off first and writes the name second, and its `dryRun` cannot prove that the name becomes writable, so a `plan_ok` can still be followed by `409 pn_name_unsupported` from the real call; the serve then writes the previous auto-generation back and verifies it, the error ends with "Nothing was changed." only when that read-back confirmed it, and otherwise `409 conflict` names `autoGeneration` as NOT restored: re-read with `tia_device_network`. IO system first: `tia_io_system_create` on the controller, then `tia_io_system_connect` per device; `409 cross_subnet_assignment`: connect the device to that subnet (`tia_network_connect`) first.\n\n**Audit** (class R). Read blocks/types/tags via `tia_plc_*` and check the engineering baseline: optimized access, 100% symbolic, UDT-typed interfaces, FB + instance-DB, uniform naming. Scope `tia_crossrefs` with `target`/`kind` on a big project: a whole-PLC read can take minutes.\n\n**CAx (AutomationML).** `tia_cax_export` exports one device or the whole project; `tia_cax_import` takes `option`: `RetainTiaDevice` (default) / `OverwriteTiaDevice` / `MoveToParkingLot`.\n\n## Where to stop\n\nEverything above is **offline (M-off)**. `tia_download` / `tia_online` (G3/G4) are **not**\npart of scaffold \u2014 they belong to `tia-handoff` and require explicit human approval.\n';
|
|
23950
|
+
var SPEC_FORMAT = '# The project-spec (input model)\n\nA project-spec is ONE JSON document describing the whole project. Always run it\nthrough the pipeline front door: `tia_spec_validate` (rung 0, pure) \u2192 `tia_spec_plan`\n(dry) \u2192 `tia_spec_apply` (M-off, stops at gates).\n\n`tia_spec_validate` checks the shape only in part (it does not run the JSON Schema; the `spec-validate`\nskill adds it) and enforces: unique device/subnet/UDT/block/per-table tag names; every network node IP\ninside the subnet CIDR; `OrderNumber:<MLFB>/V<fw>` with `/V` \u2014 never `:V` (Gd5); no STL/GRAPH on an\nS7-1200; at most 8 SMs on an S7-1200 (its only module limit); and G5 \u2014 a spec with safety content\nmarked autonomous is REJECTED (F-logic is never autonomous).\n\nMinimal example:\n\n```json\n{\n "project": { "name": "Line2", "directory": "C:\\\\TIA\\\\Line2" },\n "conventions": {\n "namingScheme": "plcopen",\n "optimizedAccess": true,\n "symbolicOnly": true,\n "defaultLanguages": { "interlocks": "LAD", "algorithms": "SCL", "sequencers": "GRAPH" }\n },\n "devices": [\n {\n "name": "Line2_CPU",\n "typeIdentifier": "OrderNumber:6ES7 511-1AK02-0AB0/V2.9",\n "role": "cpu",\n "family": "S7-1500"\n }\n ],\n "network": {\n "subnet": { "type": "System:Subnet.Ethernet", "name": "PN_Line2", "cidr": "192.168.0.0/24" },\n "nodes": [{ "device": "Line2_CPU", "ip": "192.168.0.1", "createIoSystem": true }]\n },\n "dataTypes": [\n {\n "name": "UDT_Motor",\n "members": [\n { "name": "xStart", "dataType": "Bool", "comment": "Start command" },\n { "name": "rSpeed", "dataType": "Real", "comment": "Speed [%]" }\n ]\n }\n ],\n "tagTables": [{ "name": "IO", "purpose": "IO" }],\n "tags": [{ "table": "IO", "name": "Conv01_Run", "dataType": "Bool", "address": "%Q0.0" }]\n}\n```\n\nThe plan and `tia_spec_apply` neither import `dataTypes` nor author block logic: UDTs go in with\n`tia_types_import`, logic with `tia_source_put` / `tia_import_xml`.\n\nResolve every concrete MLFB + firmware via `tia_catalog` before building \u2014 never guess\nan order number. Project firmware must be \u2264 the physical device\'s firmware.\n';
|
|
23951
23951
|
var FULL_GUIDE = [BRIEF, GATES_GUARDS, GUI_GATES, GOTCHAS, PIPELINE, RECIPES, SPEC_FORMAT].join("\n---\n\n");
|
|
23952
|
-
var CODEX_GUIDE = '# TIA Openness MCP \u2014 operating brief\n\nYou are driving Siemens TIA Portal V21 through the `tia_*` tools (an MCP over the TIA\nOpenness HTTP `serve`). This brief is ALWAYS in effect. For depth, call the `tia_guide`\ntool (topics: `gates-guards`, `gui-gates`, `gotchas`, `pipeline`, `recipes`,\n`spec-format`) \u2014 read the relevant topic BEFORE authoring blocks, changing hardware,\nor preparing a deploy. You are an assistant up to the gate, never an autonomous\ncommissioner.\n\n## Vocabulary (used across all tool descriptions)\n\n- **Class R** \u2014 read-only; safe anytime.\n- **Class M-off** \u2014 offline mutation (edits the project; never touches the physical PLC).\n- **Class GATE** \u2014 touches the physical world or a human-only decision; needs a human.\n- **G1..G7** \u2014 the GATES: G1 trust dialog, G2 S7-connection precondition (tool-enforced:\n both CPUs must compile clean), G3 download / CPU-STOP, G4 go-online (incl. station upload),\n G5 safety / F-logic (NEVER autonomous), G6 credentials \u2014 master secret, UMAC, upload /\n block / certificate passwords, password policy (from a human \u2014 never invented), G7 network\n scan. All except G2 are human-only \u2014 never crossed autonomously.\n- **Gd\\*** \u2014 tool-enforced GUARDS (preconditions the tools check), e.g. Gd5\n `OrderNumber:<MLFB>/V<fw>` format (slash before V, never `:V`), Gd8 only ERRORs block\n a compile (warnings don\'t), Gd9 clean compile before deploy, Gd11 dryRun-then-approve.\n\n## Non-negotiable rules\n\n1. **Serial only.** The serve owns ONE TIA Portal on ONE serial worker. Never fire\n concurrent `tia_*` calls; one hung Openness call can stall the whole serve.\n2. **Never cross a GATE autonomously.** A `requires_human_action` response is a HANDOFF,\n not an error: relay its `youMustDo`/`nextSteps` to the human verbatim, wait for their\n explicit yes, then resume exactly as instructed. Never self-approve a download; never\n invent a secret (G6); never author, modify or deploy safety/F logic (G5).\n3. **Long operations are jobs.** A tool whose description says "Long operation" (connect,\n compile, download, upload, project create/save/archive, exports, CAx\u2026) may answer `status:"running"` with a\n `jobId` \u2014 the operation is STILL running on serve. Call `tia_job_status {jobId}`\n until it returns the final result; never repeat the original call. While a job runs,\n any OTHER ordinary serve-bound tool answers `kind:"busy"` (with `details.jobId`) \u2014 that is\n expected, not a failure: go back to `tia_job_status`. `tia_ping` probes `/health`: never busy,\n `activated:null` while a job runs, and no job ID in it \u2014 use it for reachability only. Offline\n tools (`tia_guide`, `tia_spec_validate`, `tia_spec_plan`, `tia_job_status` itself) never answer busy.\n4. **Compile before deploy.** `tia_compile` aggregates hardware + software and is the\n offline verifier: `errors:0` is the Gd9 precondition for download (G3) and for S7\n connections.\n5. **Follow the build pipeline order** (details: `tia_guide {"topic":"pipeline"}`):\n validate the spec (`tia_spec_validate`) \u2192 plan (`tia_spec_plan`) \u2192 scaffold\n (`tia_spec_apply` or the M-off tools) \u2192 verify (`tia_compile`) \u2192 human-gated deploy\n (`tia_download` with dryRun \u2192 human approval \u2192 `approved:true` + the same `planHash`).\n6. **Some CPU settings are GUI-only** (PUT/GET permission, OPC UA runtime license,\n OPC UA server interface). Hitting one is EXPECTED, not a bug: relay the exact GUI\n steps from `tia_guide {"topic":"gui-gates"}` and resume after the human confirms.\n7. **Prerequisites:** the serve must be running (default `http://localhost:5000` \u2014\n check with `tia_ping`); the FIRST connect per serve process hits the G1 trust dialog\n on the serve host.\n8. **Confirmation dialogs.** Where the client supports it, a gated call first asks the human in the client\'s dialog\n (elicitation); only the human answers it, and it never replaces dryRun \u2192 approval \u2192 `planHash`. `declined_by_human` /\n `cancelled_by_human` = refused, nothing sent: stop, no retry unless asked.\n9. **Size budget and paging.** A result holding `{"omitted":true,\u2026}` had that value cut out WHOLE by the MCP\'s size budget:\n repeating the same call returns the same marker, so follow its `hint` instead. Read large lists (`tia_plc_blocks`,\n `tia_plc_tags`, `tia_device_tree`) in pages: pass `limit`, then each `nextCursor` as `cursor` until it is `null`. A page\n with a marker has NO `nextCursor` (it would skip the omitted data): retry the same request with a smaller `limit`.\n `cursor_stale` means the project changed: restart from the first page (no `cursor`). Gate handoffs, plans and job\n envelopes are never cut. For XML too big for one result use `tia_export_xml` (it writes files on the serve host).\n\nSession start: `tia_ping` \u2192 `tia_status` \u2192 (if needed) `tia_start` / `tia_connect`.\nBefore the first build on a project: read `tia_guide {"topic":"pipeline"}` and\n`tia_guide {"topic":"gotchas"}`.\n\n**Tool names** are written bare (`tia_status`) here and in the skills. Claude Code shows them qualified:\n`mcp__plugin_tia-harness_tia__tia_status` (plugin; what a subagent `tools:` list needs) or\n`mcp__tia__tia_status` (standalone). Other clients may display them differently; the `tia_*` suffix\nis the tool.\n\n---\n\n# Gates vs guards\n\n## GATES vs GUARDS\n\n- **GATES (human-only \u2014 never auto-bypass):** trust dialog (**G1**), download / CPU-STOP\n (**G3**), go-online (**G4**, which includes a **station upload** (`tia_upload`): it goes\n online to read the CPU), network scan / accessible-devices (**G7**), master-secret/UMAC\n (**G6**, which includes a CPU **read-access password** for an upload, a block **know-how\n password** (`tia_block_protect`), a certificate file\'s password (`tia_certificate_import`)\n and the **password-policy** values (`tia_password_policy_set`)), **safety / F-logic\n (G5) \u2014 never autonomous**.\n- **GUARDS (tool-enforced preconditions):** compile-clean before deploy, consistency,\n dry-run\u2192approve, idempotency by name (advisory: re-runs do not converge), `OrderNumber:<MLFB>/V<fw>`\n format, serial-only.\n- Back up a physical CPU with the **`tia-backup`** skill (dedicated empty project; the upload\n token is bound to the project shown in the handoff).\n- **Picking the G3 download path (no gate, no scan):** `tia_pg_interfaces` lists the connection\n modes/PG-PC interfaces TIA already sees for the CPU (plus the OS status of each adapter) \u2014\n use it to fill `connectionMode`/`pcInterfaceName`/`targetInterfaceName` for `tia_download`\n instead of reaching for `tia_accessible_devices` (a real network scan, GATE G7).\n- **GUI-ONLY settings (NOT exposed via Openness \u2014 surface as a human gate, do not script):**\n "Permit access with PUT/GET communication", OPC UA **runtime license** / server-interface\n creation. (OPC UA server **activation** is the exception \u2014 settable via Openness with\n `tia_obj_set_attributes {handle, attributes:{OpcUaServer:true}}` on the "OPC UA" device-item.)\n\n**Deploy-time approval gates** (download / online / network-scan / secret / safety = **G3/G4/G7/G6/G5**)\nare a *different* class \u2014 see the **`tia-handoff`** skill. Those are "a human **approves an action**",\nnot "a human **clicks a GUI setting**". Both are human interaction points; surface them as\n`requires_human_action` with concrete guidance, never as a tool failure.\n\n---\n\n# GUI gates \u2014 expected human interaction points\n\n## Human interaction points (GUI gates) \u2014 EXPECTED, not an error\n\nSome TIA settings are **not reachable via Openness** on the S7-1200/1500. The harness will hit a\nsignal that *looks* like an error but is actually a point where a **human must act in the TIA GUI**.\nWhen you see one of these, **do not treat it as a failure and do not retry blindly** \u2014 recognize it,\ntell the human the **exact GUI steps**, and resume after they confirm. A GUI gate is a *handoff*, not a *bug*.\n\n| # | Signal you\'ll see | Why it\'s expected | Tell the human (exact GUI steps) |\n|---|---|---|---|\n| **G1 trust** | `tia_connect` \u2192 `requires_human_action` (`trust_dialog`), or the **1st** TIA-starting call per `serve` process goes **~180 s** (`TIA_CONNECT_TIMEOUT_MS`) without an answer \u2014 `tia_connect`, `tia_start`, `tia_show_ui` and `tia_project_create` all share that wait, and a client timeout with `/health` alive yields the same `trust_dialog` handoff. A `running` answer from any of them can still mean a trust dialog is waiting on the serve host | TIA shows a one-time security prompt the first time an Openness app attaches, **per process** | On the **serve host**, in TIA Portal, click **"Yes to all"** in the access dialog. *Caveat:* it can false-positive on a client timeout with **no** real dialog \u2014 check `tia_status` (**`hasProject:true`**, not `attached:true`) and\u2026 If the handoff state is `TRUST_DIALOG_DENIED_OR_EXPIRED`, the dialog was denied or left to expire: the serve lists what it closed (`closedPids`), what is still running (`stillRunningPids`) and what it could not confirm (`unknownPids`) \u2014 close any still-running TIA (no project inside) before re-calling, and for an unconfirmed pid first verify in Task Manager that it is a TIA Portal started by this serve with no open project, with a human ready to click **"Yes to all"**. |\n| **OPC UA license** | `tia_compile` **ERROR**: *"The selected OPC UA license is not sufficient\u2026"* | License selection is GUI-only (no Openness service); a fresh project **or a firmware change** leaves it unset | CPU \u2192 **Properties \u2192 General \u2192 Runtime licenses \u2192 OPC UA** \u2192 *Type of required license* \u2192 select **"SIMATIC OPC UA S7-1200 Basic"** (the 1214C option), and *Type of purchased license* \u2192 the license the CPU holds (the human declares it; left at "No license" the compile still reports *"Type of purchased license: The selected OPC UA license is not sufficient"*). Recompile. |\n| **OPC UA interface** | OPC UA client connects but the DB nodes aren\'t there (`ns=4` empty / no `ServerInterfaces`) | The **S7-1200 does NOT auto-expose DBs** (unlike the S7-1500) \u2014 a server interface must be created by hand | CPU \u2192 **OPC UA \u2192 Server interfaces \u2192 Add new server interface** \u2192 add/drag the DB (e.g. `ModbusData`) into it. Recompile; data appears under `ns=4`. |\n| **PUT/GET** | S7 client (`nodes7`/`snap7`) connects on port 102 but reads return access-denied (`ROSCTR=2` / "BAD") | *"Permit access with PUT/GET"* is a GUI-only protection setting | CPU \u2192 **Properties \u2192 Protection & Security \u2192 Connection mechanisms** \u2192 check **"Permit access with PUT/GET communication from remote partner"**. Compile + download (`hardware:true`). |\n| **FW-change reset** | After `tia_device_change_version`: OPC UA server off, the license error on compile, blocks `isConsistent:false` | `DeviceItem.ChangeType` **resets GUI-gated comm settings** (server activation + license); the interface & PUT/GET survive | `tia_project_archive` **before** the FW change. After: re-set `OpcUaServer:true` via `tia_obj_set_attributes` (scriptable), re-select the license (row above), recompile. |\n\n**Not a gate (now scriptable):** *activating* the OPC UA server \u2014 `tia_obj_set_attributes {handle, attributes:{OpcUaServer:true}}`\non the "OPC UA" device-item (it auto-generates the server certificate). Only the **license** and the\n**server interface** stay GUI-only.\n\n---\n\n# Hard-won gotchas (runtime-validated)\n\n## Hard-won gotchas\n\n1. **Always compile before deploy.** `tia_compile` aggregates **hardware + software**; a\n **clean** compile (`errors:0`) is the precondition for download and for S7 connections.\n2. **The serve is a SINGLE serial worker** \u2014 one Openness op at a time. Do **not** fire\n concurrent `tia_*` calls; a hung Openness op can stall the serve (may need a restart).\n3. **Changing an FB\'s interface (e.g. regenerating it via `tia_source_put`) leaves its\n instance DB inconsistent.** Recompile FIRST: a software-scope `tia_compile` regenerates\n the instance DB in most cases \u2014 read the compile result\'s **`blockChanges`** (`tia_compile`\n and `tia_source_put {compile:true}` both return it): a `"change":"modified"` entry on the\n instance DB is your confirmation it was regenerated \u2014 **export and commit it**\n (`tia_export_block`/`tia_block_compare`) so what\'s versioned matches the project. Only if\n the DB still reports inconsistent after a compile, delete it (`tia_block_delete`),\n recreate it (`tia_instancedb_create`) and recompile.\n4. **Firmware rule: project FW \u2264 device FW.** Bump the project FW **in-place** with\n `tia_device_change_version` (`DeviceItem.ChangeType`), which preserves the **program** \u2014 never\n set the project higher than the physical CPU. **\u26A0\uFE0F It RESETS GUI-gated comm settings** (the\n **OPC UA server activation** + **runtime-license**; the server interface and PUT/GET survive):\n **archive first** (`tia_project_archive`) on a CPU with hand-configured OPC UA, recompile after\n (it marks blocks inconsistent), and re-verify. Same-version `ChangeType` is rejected.\n5. **Use a NON-optimized DB** for Modbus (`MB_HOLD_REG`) and S7 (absolute addressing); OPC UA\n works with optimized or not.\n6. **Order numbers use `/V<fw>`, not `:V<fw>`** (guard Gd5).\n7. **A station upload (`tia_upload`) ADDS a new station to the open project \u2014 back up into a\n dedicated EMPTY project.** Observed on hardware (S7-1200 1214C, 2026-09-26): the upload read\n the CPU into an empty project (0 \u2192 1 device, twice) in ~75 s (76.7 s and 74.2 s); the CPU\n stayed in RUN the whole time (owner watching its LEDs during the second upload). Protect the\n working project FIRST: `tia_project_create` closes the current project, and serve refuses it\n (`409 unsaved_changes`) while that project has unsaved changes \u2014 so `tia_project_save` +\n `tia_project_archive` before creating the backup project (never pass `discardUnsavedChanges` to\n get past the refusal) \u2014 and pass the archive `name` WITH the `.zap21` extension (`name` absent\n or extension-less fails; with `.zap21` it archived 1.6 MB).\n8. **One wrong know-how password can lock a block for the session.** Observed on the bench\n (2026-10-12): after one rejected unprotect (`tia_block_protect {protect:false}`), TIA refused\n the CORRECT password of that block for the rest of the session (cause not confirmed \u2014 possibly\n brute-force protection). Never retry with a guess \u2014 ask the human for the password (G6); if a\n password the human confirms is refused, stop and hand off instead of retrying.\n9. **`unsaved_changes` and `binding_conflict` are refusals, not faults: nothing was changed.**\n `tia_connect`, `tia_project_close`, `tia_disconnect` and `tia_project_create` answer\n `409 unsaved_changes` when the call would close a project with unsaved changes (the error lists\n each one). ASK the human; the recommended answer is to repeat the same call with\n `saveUnsavedChanges:true`. Pass `discardUnsavedChanges:true` (data loss) ONLY when the human\n explicitly decides to throw the work away, never to make the error go away (the client then asks\n the human to confirm in its own dialog; `declined_by_human` = nothing was sent, stop).\n `409 binding_conflict` means the project this session is bound to is no longer the one open in\n the bound TIA (closed, replaced or Save As done by hand; `tia_status` shows `boundProjectPath`\n and `bindingDrift`): ask the human which project is intended, then `tia_connect` with the bound\n path (back to it) or the open one (adopt it) \u2014 do not repeat the refused call first.\n10. **`503 audit_unavailable`: the serve could not write its audit log, so it refused the call BEFORE\n running (nothing reached the PLC).** Have the human fix the disk or permissions, then re-plan.\n An `auditWarning` in a response = the call ran but was not fully recorded: report it.\n\n## Prerequisites (environment)\n\n- The **`tia` serve must be running** (default `http://localhost:5000`, e.g.\n `TIAOpenness.exe serve 5000`). The MCP is a pure HTTP client; point it at the serve host via\n `TIA_API_BASE` if it runs elsewhere.\n- The Windows user must belong to the **"Siemens TIA Openness"** local group.\n- The **FIRST connection per serve process shows a trust dialog** that a **human must confirm**\n ("Yes to all") on the serve host \u2014 this **cannot be automated** (gate G1).\n\n---\n\n# The build pipeline (spec \u2192 verified project)\n\nStages in order \u2014 the class tells you what each stage may do:\n\n| # | Stage | Tool(s) | Class | What it does |\n|---|---|---|---|---|\n| 0 | Validate the spec | `tia_spec_validate` | R (pure) | JSON-Schema + cross-field engineering rules (unique names, same-subnet IPs, Gd5 order-number format, per-CPU module limits, language-by-family, the G5 safety rule). Needs no serve. |\n| 1 | Plan | `tia_spec_plan` | R (pure) | Turns a VALID spec into the ordered list of M-off operations. Nothing mutates. |\n| 2 | Scaffold | `tia_spec_apply` (or the M-off tools manually) | M-off | Creates the project content in dependency order (see below). Stops at every gate. |\n| 3 | Verify | `tia_compile` | M-off | THE offline verifier: aggregates hardware + software. Gd8: only ERRORs block. `errors:0` is the Gd9 precondition for any deploy. |\n| 4 | Handoff / deploy | `tia_download` | GATE G3 | `dryRun:true` asks serve for a VERIFIED plan (clean compile, resolved connection, software fingerprint) \u2192 plan + `planHash` \u2192 a HUMAN approves \u2192 re-call with `approved:true` + the SAME `planHash` (serve re-checks the fingerprint and refuses `plan_stale` if the software changed). The approval covers the connection/options and the covered software content \u2014 NOT the hardware configuration (a hardware change after approval passes the token check). Re-plan (new dryRun) + fresh human approval only when the hardware configuration changed AFTER the dryRun that produced the token \u2014 the fingerprint cannot detect that change, so the human must confirm nothing hardware-side moved; never reuse the old token for changed hardware. The fingerprint covers only user program blocks, UDTs and tag tables (what it leaves out, the `source:"dates"` fallback: `tia_guide {"topic":"recipes"}`, \'Reference \u2014 download plan fingerprint limits\'). Never self-approve. Pick the connection with `tia_pg_interfaces` (no scan). |\n\nScaffold order (UDTs BEFORE the blocks that use them): `tia_spec_apply` follows it; by hand, `tia_guide {"topic":"recipes"}`, \'Pipeline order\'.\n\nPLC-scoped steps use the PlcSoftware (e.g. `PLC_1`) read after the device step, not the device name.\n\n## The approval envelope (what a gate handoff looks like)\n\nGated tools return `status:"requires_human_action"` with:\n\n- `gate` \u2014 which gate (e.g. `download_approval`, `station_upload`, `go_online`, `trust_dialog`);\n- `youMustDo` \u2014 what the human must confirm, in plain words;\n- `plan` + `planHash` \u2014 exactly what would be executed (the hash binds the approval to\n this exact plan; a changed plan needs a new approval); the download\'s plan also carries\n `fingerprint` (the software content the plan was verified against \u2014 show it too);\n- `nextSteps` \u2014 how to resume after the human\'s yes.\n\nRelay the envelope to the human, wait for an explicit yes, resume exactly as\ninstructed. The AI never approves, never invents a secret, never deploys F-logic.\n\n**Confirmation dialog.** When the client supports elicitation, the crossing calls (`tia_download` with\n`approved:true`; `tia_upload`, `tia_online`, `tia_accessible_devices` with `confirm:true`) first ask the\nhuman in a dialog; clients without it behave as before. The dialog only checks the human\'s answer: the\n`planHash` and serve\'s approval token stay the authority.\nPasswords (G6) are never asked there. `declined_by_human` / `cancelled_by_human` = the human refused:\nnothing was sent, no retry unless asked. `elicitation_failed` (`isError`) = the dialog could not be\nshown or answered, nothing was sent (fails closed).\n\n## After scaffolding\n\n- Re-run `tia_compile` after ANY authoring change.\n- `tia_project_save` regularly; `tia_project_archive` BEFORE risky operations\n (firmware change \u2014 see `tia_guide {"topic":"gotchas"}`).\n- Auditing an existing project is class R (`tia_plc_*` reads); baseline: `tia_guide {"topic":"recipes"}`, \'Reference \u2014 network, audit and CAx how-to\'.\n- `tia_crossrefs` (class R, a long read: it may answer `status:"running"` + `jobId`, then poll\n `tia_job_status`) reads the cross-references: in an audit, `filter:"UnusedObjects"` lists\n unused-object CANDIDATES, never proof (OBs, objects used only from outside the PLC such as an\n HMI, OPC UA or another CPU, and library TYPEs show as unreferenced); before changing an\n existing object, `target` + `kind` + `filter:"ObjectsWithReferences"` returns the objects related\n to it with each `referenceType` and `access` as TIA reports them (the direction of `Uses` /\n `UsedBy` is not interpreted: the human confirms it). Page a whole-PLC or container read with `limit`\n (for example 200) and `cursor` (the `nextCursor` of the previous page, until it is null; on\n `cursor_stale` restart from the first page, and on an omission marker repeat the same request\n with a smaller `limit`, never following a cursor from an omitted page); each page re-reads the\n whole PLC, so a later page can report less than an earlier one. Read `coverage` on every page,\n not only the first, and compare its counts across pages: differing counts restart the walk once\n from the first page (like `cursor_stale`). Only a finished walk whose pages all report\n `coverage.complete: true` supports "audited completely" or "nothing uses this"; an omission\n marker, an unfinished walk, differing counts or `coverage.complete: false` on any page (see\n `coverage.unavailableOwners`) means the result is NOT complete.\n- **FAT/SAT I/O list** (`tia-verify` step 6): `tia_io_map`; recipe: `tia_guide {"topic":"recipes"}`, \'Recipe \u2014 generate the FAT/SAT I/O list\'.\n- **Prove the project matches what\'s versioned** (a raw hash is NOT proof): `tia_guide {"topic":"recipes"}`, \'Recipe \u2014 prove the project matches the versioned XML\'.\n\n## Network lifecycle (subnets, PROFINET names, IO systems)\n\nRead first (`tia_subnet_get`, `tia_device_network`, `tia_io_systems`), then run each write\'s `dryRun` (answered by\nthe serve, needs an open project). Order, PROFINET names, `disconnectNodes`: `tia_guide {"topic":"recipes"}`, \'Reference \u2014 network, audit and CAx how-to\'.\n\n- **Refused, nothing changed:** `tia_subnet_delete` of a non-empty subnet (`409 subnet_not_empty`);\n `tia_io_system_connect` across subnets (`409 cross_subnet_assignment`: `tia_network_connect` the device to that subnet first).\n- **`409 postcheck_failed`:** the write did not take effect as asked: re-read, never repeat blindly.\n\n## Libraries, HMI, CAx and PLC security\n\nReads are class R; every change is class M-off (offline, with `dryRun`) and reaches the CPU\nonly through a later `tia_compile` + human-gated `tia_download` (G3). Every file path is a\npath ON THE SERVE HOST.\n\n- **Guarded PLC writes** (`tia_tag_update`, `tia_constant_update`, `tia_constant_delete`,\n `tia_tagtable_delete`, `tia_block_group_delete`, `tia_ob_create`, `tia_block_compile`): the serve\n answers their `dryRun` (it needs an open project) with the guard verdict (name collision, default\n tag table, non-empty group, singleton OB).\n- **Project library:** `tia_library_mastercopies` / `tia_library_types` read it;\n `tia_library_mastercopy_create` turns a DEVICE into a master copy (a block cannot be a source);\n `tia_block_from_mastercopy` needs one that holds PLC blocks.\n- **Global libraries** (in the TIA Portal session, not the project): `tia_global_libraries`,\n `tia_global_library_create` / `_open` / `_save` / `_close`; save/close take the name from\n `tia_global_libraries` (exact name first, then ignoring case). REFUSED, nothing saved or closed\n (`404 not_found` / `409 conflict`): a name that picks no single open USER library (unknown, read-only\n system/corporate, several matches ignoring case) and a save of a `readWrite:false` library. Up to app\n 1.6.3 an unknown name can report success without saving or closing anything: check `tia_global_libraries`.\n- **HMI:** `tia_hmis` and `tia_hmi_screens` read any HMI; screen files\n (`tia_hmi_screen_export`, `tia_hmi_screens_import`) work for WinCC **Classic** only, and the\n import OVERWRITES same-named screens.\n- **CAx (AutomationML):** `tia_cax_export` / `tia_cax_import` (scope, `option` values: recipes). Archive the\n project before an overwrite. A failed transfer is an error after app 1.6.3; on an older serve check the\n devices with `tia_devices`.\n- **Error contracts by app version:** `tia_guide {"topic":"recipes"}`, \'Reference \u2014 global library and CAx error contracts (by app version)\'.\n- **PLC security:** `tia_certificates` / `tia_certificate_template` / `tia_password_policy`\n read; `tia_certificate_import` / `_export` / `_delete`, `tia_password_policy_set` and\n `tia_block_protect` change the project. **G6:** a block or certificate password and the\n password-policy values come from a HUMAN \u2014 never invent, guess or reuse one; dryRun plans\n show a password as `[redacted]`. A CPU without the certificate manager or a policy service\n answers 409.\n- **Multiuser:** `tia_project_servers`, `tia_server_projects` read Project Servers; `tia_local_session_open` needs NO open project (`tia_project_close`, `tia_start`). Nothing is ever checked in.\n\n---\n\n# Recipes (runtime-verified)\n\nNot copied here: Codex reads at most 32 KiB of AGENTS.md and cuts the rest without a word. Call\n`tia_guide {"topic":"recipes"}` for the verified recipes (unlocking a freshly-created CPU, the in-place firmware\nbump, Modbus TCP, S7 PUT/GET and OPC UA on the S7-1200, the scaffold order) before you need one.\n\n---\n\n# The project-spec (input model)\n\nA project-spec is ONE JSON document describing the whole project. Always run it\nthrough the pipeline front door: `tia_spec_validate` (rung 0, pure) \u2192 `tia_spec_plan`\n(dry) \u2192 `tia_spec_apply` (M-off, stops at gates).\n\nRules the validator enforces (beyond the JSON Schema): unique device/tag/block names;\nevery network node IP inside the subnet CIDR (same-subnet rule); `OrderNumber:<MLFB>/V<fw>`\nformat with `/V` \u2014 never `:V` (Gd5); per-CPU module limits; language by family (e.g.\nS7-1200 has no GRAPH); and the G5 rule \u2014 a spec with safety content marked autonomous\nis REJECTED (F-logic is never autonomous).\n\nMinimal example:\n\n```json\n{\n "project": { "name": "Line2", "directory": "C:\\\\TIA\\\\Line2" },\n "conventions": {\n "namingScheme": "plcopen",\n "optimizedAccess": true,\n "symbolicOnly": true,\n "defaultLanguages": { "interlocks": "LAD", "algorithms": "SCL", "sequencers": "GRAPH" }\n },\n "devices": [\n {\n "name": "Line2_CPU",\n "typeIdentifier": "OrderNumber:6ES7 511-1AK02-0AB0/V2.9",\n "role": "cpu",\n "family": "S7-1500"\n }\n ],\n "network": {\n "subnet": { "type": "System:Subnet.Ethernet", "name": "PN_Line2", "cidr": "192.168.0.0/24" },\n "nodes": [{ "device": "Line2_CPU", "ip": "192.168.0.1", "createIoSystem": true }]\n },\n "dataTypes": [\n {\n "name": "UDT_Motor",\n "members": [\n { "name": "xStart", "dataType": "Bool", "comment": "Start command" },\n { "name": "rSpeed", "dataType": "Real", "comment": "Speed [%]" }\n ]\n }\n ],\n "tagTables": [{ "name": "IO", "purpose": "IO" }],\n "tags": [{ "table": "IO", "name": "Conv01_Run", "dataType": "Bool", "address": "%Q0.0" }]\n}\n```\n\nResolve every concrete MLFB + firmware via `tia_catalog` before building \u2014 never guess\nan order number. Project firmware must be \u2264 the physical device\'s firmware.\n';
|
|
23952
|
+
var CODEX_GUIDE = '# TIA Openness MCP \u2014 operating brief\n\nYou are driving Siemens TIA Portal V21 through the `tia_*` tools (an MCP over the TIA\nOpenness HTTP `serve`). This brief is ALWAYS in effect. For depth, call the `tia_guide`\ntool (topics: `gates-guards`, `gui-gates`, `gotchas`, `pipeline`, `recipes`,\n`spec-format`) \u2014 read the relevant topic BEFORE authoring blocks, changing hardware,\nor preparing a deploy. You are an assistant up to the gate, never an autonomous\ncommissioner.\n\n## Vocabulary (used across all tool descriptions)\n\n- **Class R** \u2014 read-only; safe anytime.\n- **Class M-off** \u2014 offline mutation (edits the project; never touches the physical PLC).\n- **Class GATE** \u2014 touches the physical world or a human-only decision; needs a human.\n- **G1..G7** \u2014 the GATES: G1 trust dialog, G2 S7-connection precondition (tool-enforced:\n both CPUs must compile clean), G3 download / CPU-STOP, G4 go-online (incl. station upload),\n G5 safety / F-logic (NEVER autonomous), G6 credentials \u2014 master secret, UMAC, upload /\n block / certificate passwords, password policy (from a human \u2014 never invented), G7 network\n scan. All except G2 are human-only \u2014 never crossed autonomously.\n- **Gd\\*** \u2014 tool-enforced GUARDS (preconditions the tools check), e.g. Gd5\n `OrderNumber:<MLFB>/V<fw>` format (slash before V, never `:V`), Gd8 only ERRORs block\n a compile (warnings don\'t), Gd9 clean compile before deploy, Gd11 dryRun-then-approve.\n\n## Non-negotiable rules\n\n1. **Serial only.** The serve owns ONE TIA Portal on ONE serial worker. Never fire\n concurrent `tia_*` calls; one hung Openness call can stall the whole serve.\n2. **Never cross a GATE autonomously.** A `requires_human_action` response is a HANDOFF,\n not an error: relay its `youMustDo`/`nextSteps` to the human verbatim, wait for their\n explicit yes, then resume exactly as instructed. Never self-approve a download; never\n invent a secret (G6); never author, modify or deploy safety/F logic (G5).\n3. **Long operations are jobs.** A tool whose description says "Long operation" (connect,\n compile, download, upload, project create/save/archive, exports, CAx\u2026) may answer `status:"running"` with a\n `jobId` \u2014 the operation is STILL running on serve. Call `tia_job_status {jobId}`\n until it returns the final result; never repeat the original call. While a job runs,\n any OTHER ordinary serve-bound tool answers `kind:"busy"` (with `details.jobId`) \u2014 that is\n expected, not a failure: go back to `tia_job_status`. `tia_ping` probes `/health`: never busy,\n `activated:null` while a job runs, and no job ID in it \u2014 use it for reachability only. Offline\n tools (`tia_guide`, `tia_spec_validate`, `tia_spec_plan`, `tia_job_status` itself) never answer busy.\n4. **Compile before deploy.** `tia_compile` aggregates hardware + software and is the\n offline verifier: `errors:0` is the Gd9 precondition for download (G3) and for S7\n connections.\n5. **Follow the build pipeline order** (details: `tia_guide {"topic":"pipeline"}`):\n validate the spec (`tia_spec_validate`) \u2192 plan (`tia_spec_plan`) \u2192 scaffold\n (`tia_spec_apply` or the M-off tools) \u2192 verify (`tia_compile`) \u2192 human-gated deploy\n (`tia_download` with dryRun \u2192 human approval \u2192 `approved:true` + the same `planHash`).\n6. **Some CPU settings are GUI-only** (PUT/GET permission, OPC UA runtime license,\n OPC UA server interface). Hitting one is EXPECTED, not a bug: relay the exact GUI\n steps from `tia_guide {"topic":"gui-gates"}` and resume after the human confirms.\n7. **Prerequisites:** the serve must be running (default `http://localhost:5000` \u2014\n check with `tia_ping`); the FIRST connect per serve process hits the G1 trust dialog\n on the serve host.\n8. **Confirmation dialogs.** Where the client supports it, a gated call first asks the human in the client\'s dialog\n (elicitation); only the human answers it, and it never replaces dryRun \u2192 approval \u2192 `planHash`. `declined_by_human` /\n `cancelled_by_human` = refused, nothing sent: stop, no retry unless asked.\n9. **Size budget and paging.** A result holding `{"omitted":true,\u2026}` had that value cut out WHOLE by the MCP\'s size budget:\n repeating the same call returns the same marker, so follow its `hint` instead. Read large lists (`tia_plc_blocks`,\n `tia_plc_tags`, `tia_device_tree`) in pages: pass `limit`, then each `nextCursor` as `cursor` until it is `null`. A page\n with a marker has NO `nextCursor` (it would skip the omitted data): retry the same request with a smaller `limit`.\n `cursor_stale` means the project changed: restart from the first page (no `cursor`). Gate handoffs, plans and job\n envelopes are never cut. For XML too big for one result use `tia_export_xml` (it writes files on the serve host).\n\nSession start: `tia_ping` \u2192 `tia_status` \u2192 (if needed) `tia_start` / `tia_connect`.\nBefore the first build on a project: read `tia_guide {"topic":"pipeline"}` and\n`tia_guide {"topic":"gotchas"}`.\n\n**Tool names** are written bare (`tia_status`) here and in the skills. Claude Code shows them qualified:\n`mcp__plugin_tia-harness_tia__tia_status` (plugin; what a subagent `tools:` list needs) or\n`mcp__tia__tia_status` (standalone). Other clients may display them differently; the `tia_*` suffix\nis the tool.\n\n---\n\n# Gates vs guards\n\n## GATES vs GUARDS\n\n- **GATES (human-only \u2014 never auto-bypass):** trust dialog (**G1**), download / CPU-STOP\n (**G3**), go-online (**G4**, which includes a **station upload** (`tia_upload`): it goes\n online to read the CPU), network scan / accessible-devices (**G7**), master-secret/UMAC\n (**G6**, which includes a CPU **read-access password** for an upload, a block **know-how\n password** (`tia_block_protect`), a certificate file\'s password (`tia_certificate_import`)\n and the **password-policy** values (`tia_password_policy_set`)), **safety / F-logic\n (G5) \u2014 never autonomous**.\n- **GUARDS (tool-enforced preconditions):** compile-clean before deploy, consistency,\n dry-run\u2192approve, idempotency by name (advisory: re-runs do not converge), `OrderNumber:<MLFB>/V<fw>`\n format, serial-only.\n- Back up a physical CPU with the **`tia-backup`** skill (dedicated empty project; the upload\n token is bound to the project shown in the handoff).\n- **Picking the G3 download path (no gate, no scan):** `tia_pg_interfaces` lists the connection\n modes/PG-PC interfaces TIA already sees for the CPU (plus the OS status of each adapter) \u2014\n use it to fill `connectionMode`/`pcInterfaceName`/`targetInterfaceName` for `tia_download`\n instead of reaching for `tia_accessible_devices` (a real network scan, GATE G7).\n- **GUI-ONLY settings (NOT exposed via Openness \u2014 surface as a human gate, do not script):**\n "Permit access with PUT/GET communication", OPC UA **runtime license** / server-interface\n creation. (OPC UA server **activation** is the exception \u2014 settable via Openness with\n `tia_obj_set_attributes {handle, attributes:{OpcUaServer:true}}` on the "OPC UA" device-item.)\n\n**Deploy-time approval gates** (download / online / network-scan / secret / safety = **G3/G4/G7/G6/G5**)\nare a *different* class \u2014 see the **`tia-handoff`** skill. Those are "a human **approves an action**",\nnot "a human **clicks a GUI setting**". Both are human interaction points; surface them as\n`requires_human_action` with concrete guidance, never as a tool failure.\n\n---\n\n# GUI gates \u2014 expected human interaction points\n\n## Human interaction points (GUI gates) \u2014 EXPECTED, not an error\n\nSome TIA settings are **not reachable via Openness** on the S7-1200/1500. The harness will hit a\nsignal that *looks* like an error but is actually a point where a **human must act in the TIA GUI**.\nWhen you see one of these, **do not treat it as a failure and do not retry blindly** \u2014 recognize it,\ntell the human the **exact GUI steps**, and resume after they confirm. A GUI gate is a *handoff*, not a *bug*.\n\n| # | Signal you\'ll see | Why it\'s expected | Tell the human (exact GUI steps) |\n|---|---|---|---|\n| **G1 trust** | `tia_connect` \u2192 `requires_human_action` (`trust_dialog`), or the **1st** TIA-starting call per `serve` process goes **~180 s** (`TIA_CONNECT_TIMEOUT_MS`) without an answer \u2014 `tia_connect`, `tia_start`, `tia_show_ui` and `tia_project_create` all share that wait, and a client timeout with `/health` alive yields the same `trust_dialog` handoff. A `running` answer from any of them can still mean a trust dialog is waiting on the serve host | TIA shows a one-time security prompt the first time an Openness app attaches, **per process** | On the **serve host**, in TIA Portal, click **"Yes to all"** in the access dialog. *Caveat:* it can false-positive on a client timeout with **no** real dialog \u2014 check `tia_status` (**`hasProject:true`**, not `attached:true`) and\u2026 If the handoff state is `TRUST_DIALOG_DENIED_OR_EXPIRED`, the dialog was denied or left to expire: the serve lists what it closed (`closedPids`), what is still running (`stillRunningPids`) and what it could not confirm (`unknownPids`) \u2014 close any still-running TIA (no project inside) before re-calling, and for an unconfirmed pid first verify in Task Manager that it is a TIA Portal started by this serve with no open project, with a human ready to click **"Yes to all"**. |\n| **OPC UA license** | `tia_compile` **ERROR**: *"The selected OPC UA license is not sufficient\u2026"* | License selection is GUI-only (no Openness service); a fresh project **or a firmware change** leaves it unset | CPU \u2192 **Properties \u2192 General \u2192 Runtime licenses \u2192 OPC UA** \u2192 *Type of required license* \u2192 select **"SIMATIC OPC UA S7-1200 Basic"** (the 1214C option), and *Type of purchased license* \u2192 the license the CPU holds (the human declares it; left at "No license" the compile still reports *"Type of purchased license: The selected OPC UA license is not sufficient"*). Recompile. |\n| **OPC UA interface** | OPC UA client connects but the DB nodes aren\'t there (`ns=4` empty / no `ServerInterfaces`) | The **S7-1200 does NOT auto-expose DBs** (unlike the S7-1500) \u2014 a server interface must be created by hand | CPU \u2192 **OPC UA \u2192 Server interfaces \u2192 Add new server interface** \u2192 add/drag the DB (e.g. `ModbusData`) into it. Recompile; data appears under `ns=4`. |\n| **PUT/GET** | S7 client (`nodes7`/`snap7`) connects on port 102 but reads return access-denied (`ROSCTR=2` / "BAD") | *"Permit access with PUT/GET"* is a GUI-only protection setting | CPU \u2192 **Properties \u2192 Protection & Security \u2192 Connection mechanisms** \u2192 check **"Permit access with PUT/GET communication from remote partner"**. Compile + download (`hardware:true`). |\n| **FW-change reset** | After `tia_device_change_version`: OPC UA server off, the license error on compile, blocks `isConsistent:false` | `DeviceItem.ChangeType` **resets GUI-gated comm settings** (server activation + license); the interface & PUT/GET survive | `tia_project_archive` **before** the FW change. After: re-set `OpcUaServer:true` via `tia_obj_set_attributes` (scriptable), re-select the license (row above), recompile. |\n\n**Not a gate (now scriptable):** *activating* the OPC UA server \u2014 `tia_obj_set_attributes {handle, attributes:{OpcUaServer:true}}`\non the "OPC UA" device-item (it auto-generates the server certificate). Only the **license** and the\n**server interface** stay GUI-only.\n\n---\n\n# Hard-won gotchas (runtime-validated)\n\n## Hard-won gotchas\n\n1. **Always compile before deploy.** `tia_compile` aggregates **hardware + software**; a\n **clean** compile (`errors:0`) is the precondition for download and for S7 connections.\n2. **The serve is a SINGLE serial worker** \u2014 one Openness op at a time. Do **not** fire\n concurrent `tia_*` calls; a hung Openness op can stall the serve (may need a restart).\n3. **Changing an FB\'s interface (e.g. regenerating it via `tia_source_put`) leaves its\n instance DB inconsistent.** Recompile FIRST: a software-scope `tia_compile` regenerates\n the instance DB in most cases \u2014 read the compile result\'s **`blockChanges`** (`tia_compile`\n and `tia_source_put {compile:true}` both return it): a `"change":"modified"` entry on the\n instance DB is your confirmation it was regenerated \u2014 **export and commit it**\n (`tia_export_block`/`tia_block_compare`) so what\'s versioned matches the project. Only if\n the DB still reports inconsistent after a compile, delete it (`tia_block_delete`),\n recreate it (`tia_instancedb_create`) and recompile.\n4. **Firmware rule: project FW \u2264 device FW.** Bump the project FW **in-place** with\n `tia_device_change_version` (`DeviceItem.ChangeType`), which preserves the **program** \u2014 never\n set the project higher than the physical CPU. **\u26A0\uFE0F It RESETS GUI-gated comm settings** (the\n **OPC UA server activation** + **runtime-license**; the server interface and PUT/GET survive):\n **archive first** (`tia_project_archive`) on a CPU with hand-configured OPC UA, recompile after\n (it marks blocks inconsistent), and re-verify. Same-version `ChangeType` is rejected.\n5. **Use a NON-optimized DB** for Modbus (`MB_HOLD_REG`) and S7 (absolute addressing); OPC UA\n works with optimized or not.\n6. **Order numbers use `/V<fw>`, not `:V<fw>`** (guard Gd5).\n7. **A station upload (`tia_upload`) ADDS a new station to the open project \u2014 back up into a\n dedicated EMPTY project.** Observed on hardware (S7-1200 1214C, 2026-09-26): the upload read\n the CPU into an empty project (0 \u2192 1 device, twice) in ~75 s (76.7 s and 74.2 s); the CPU\n stayed in RUN the whole time (owner watching its LEDs during the second upload). Protect the\n working project FIRST: `tia_project_create` closes the current project, and serve refuses it\n (`409 unsaved_changes`) while that project has unsaved changes \u2014 so `tia_project_save` +\n `tia_project_archive` before creating the backup project (never pass `discardUnsavedChanges` to\n get past the refusal) \u2014 and pass the archive `name` WITH the `.zap21` extension (`name` absent\n or extension-less fails; with `.zap21` it archived 1.6 MB).\n8. **One wrong know-how password can lock a block for the session.** Observed on the bench\n (2026-10-12): after one rejected unprotect (`tia_block_protect {protect:false}`), TIA refused\n the CORRECT password of that block for the rest of the session (cause not confirmed \u2014 possibly\n brute-force protection). Never retry with a guess \u2014 ask the human for the password (G6); if a\n password the human confirms is refused, stop and hand off instead of retrying.\n9. **`unsaved_changes` and `binding_conflict` are refusals, not faults: nothing was changed.**\n `tia_connect`, `tia_project_close`, `tia_disconnect` and `tia_project_create` answer\n `409 unsaved_changes` when the call would close a project with unsaved changes (the error lists\n each one). ASK the human; the recommended answer is to repeat the same call with\n `saveUnsavedChanges:true`. Pass `discardUnsavedChanges:true` (data loss) ONLY when the human\n explicitly decides to throw the work away, never to make the error go away (the client then asks\n the human to confirm in its own dialog; `declined_by_human` = nothing was sent, stop).\n `409 binding_conflict` means the project this session is bound to is no longer the one open in\n the bound TIA (closed, replaced or Save As done by hand; `tia_status` shows `boundProjectPath`\n and `bindingDrift`): ask the human which project is intended, then `tia_connect` with the bound\n path (back to it) or the open one (adopt it) \u2014 do not repeat the refused call first.\n10. **`503 audit_unavailable`: the serve could not write its audit log, so it refused the call BEFORE\n running (nothing reached the PLC).** Have the human fix the disk or permissions, then re-plan.\n An `auditWarning` in a response = the call ran but was not fully recorded: report it.\n\n## Prerequisites (environment)\n\n- The **`tia` serve must be running** (default `http://localhost:5000`, e.g.\n `TIAOpenness.exe serve 5000`). The MCP is a pure HTTP client; point it at the serve host via\n `TIA_API_BASE` if it runs elsewhere.\n- The Windows user must belong to the **"Siemens TIA Openness"** local group.\n- The **FIRST connection per serve process shows a trust dialog** that a **human must confirm**\n ("Yes to all") on the serve host \u2014 this **cannot be automated** (gate G1).\n\n---\n\n# The build pipeline (spec \u2192 verified project)\n\nStages in order \u2014 the class tells you what each stage may do:\n\n| # | Stage | Tool(s) | Class | What it does |\n|---|---|---|---|---|\n| 0 | Validate the spec | `tia_spec_validate` | R (pure) | Partial shape checks + the cross-field rules the tool implements: unique names, IP inside the subnet CIDR, Gd5 order-number format, no STL/GRAPH on S7-1200, the G5 safety rule, at most 8 SMs on an S7-1200. It does NOT run the JSON Schema or per-model module limits; the `spec-validate` skill covers both. Needs no serve. |\n| 1 | Plan | `tia_spec_plan` | R (pure) | Turns a VALID spec into the ordered list of M-off operations. Nothing mutates. |\n| 2 | Scaffold | `tia_spec_apply` (or the M-off tools manually) | M-off | Creates part of the project content in dependency order (scope below). Stops at every gate. |\n| 3 | Verify | `tia_compile` | M-off | THE offline verifier: aggregates hardware + software. Gd8: only ERRORs block. `errors:0` is the Gd9 precondition for any deploy. |\n| 4 | Handoff / deploy | `tia_download` | GATE G3 | `dryRun:true` asks serve for a VERIFIED plan (clean compile, resolved connection, software fingerprint) \u2192 plan + `planHash` \u2192 a HUMAN approves \u2192 re-call with `approved:true` + the SAME `planHash` (serve re-checks the fingerprint and refuses `plan_stale` if the software changed). The approval covers the connection/options and the covered software content \u2014 NOT the hardware configuration (a hardware change after approval passes the token check). Re-plan (new dryRun) + fresh human approval only when the hardware configuration changed AFTER the dryRun that produced the token \u2014 the fingerprint cannot detect that change, so the human must confirm nothing hardware-side moved; never reuse the old token for changed hardware. The fingerprint covers only user program blocks, UDTs and tag tables (what it leaves out, the `source:"dates"` fallback: `tia_guide {"topic":"recipes"}`, \'Reference \u2014 download plan fingerprint limits\'). Never self-approve. Pick the connection with `tia_pg_interfaces` (no scan). |\n\nScaffold order (UDTs BEFORE the blocks that use them): by hand, `tia_guide {"topic":"recipes"}`, \'Pipeline order\'. `tia_spec_apply` automates only subnets, devices, modules, network, tag tables, tags, FB shells, control-module instance DBs and the compile; protection, constants, UDTs and all logic stay manual. The FB shells it creates are empty: add their logic with `tia_source_put` (SCL) or `tia_import_xml` (LAD/FBD).\n\nPLC-scoped steps use the PlcSoftware (e.g. `PLC_1`) read after the device step, not the device name.\n\n## The approval envelope (what a gate handoff looks like)\n\nGated tools return `status:"requires_human_action"` with:\n\n- `gate` \u2014 which gate (e.g. `download_approval`, `station_upload`, `go_online`, `trust_dialog`);\n- `youMustDo` \u2014 what the human must confirm, in plain words;\n- `plan` + `planHash` \u2014 exactly what would be executed (the hash binds the approval to\n this exact plan; a changed plan needs a new approval); the download\'s plan also carries\n `fingerprint` (the software content the plan was verified against \u2014 show it too);\n- `nextSteps` \u2014 how to resume after the human\'s yes.\n\nRelay the envelope to the human, wait for an explicit yes, resume exactly as\ninstructed. The AI never approves, never invents a secret, never deploys F-logic.\n\n**Confirmation dialog.** When the client supports elicitation, the crossing calls (`tia_download` with\n`approved:true`; `tia_upload`, `tia_online`, `tia_accessible_devices` with `confirm:true`) first ask the\nhuman in a dialog; clients without it behave as before. The dialog only checks the human\'s answer: the\n`planHash` and serve\'s approval token stay the authority.\nPasswords (G6) are never asked there. `declined_by_human` / `cancelled_by_human` = the human refused:\nnothing was sent, no retry unless asked. `elicitation_failed` (`isError`) = the dialog could not be\nshown or answered, nothing was sent (fails closed).\n\n## After scaffolding\n\n- Re-run `tia_compile` after ANY authoring change.\n- `tia_project_save` regularly; `tia_project_archive` BEFORE risky operations\n (firmware change \u2014 see `tia_guide {"topic":"gotchas"}`).\n- Auditing an existing project is class R (`tia_plc_*` reads); baseline: `tia_guide {"topic":"recipes"}`, \'Reference \u2014 network, audit and CAx how-to\'.\n- `tia_crossrefs` (class R, a long read: it may answer `status:"running"` + `jobId`, then poll\n `tia_job_status`) reads the cross-references: in an audit, `filter:"UnusedObjects"` lists\n unused-object CANDIDATES, never proof (OBs, objects used only from outside the PLC such as an\n HMI, OPC UA or another CPU, and library TYPEs show as unreferenced); before changing an\n existing object, `target` + `kind` + `filter:"ObjectsWithReferences"` returns the objects related\n to it with each `referenceType` and `access` as TIA reports them (the direction of `Uses` /\n `UsedBy` is not interpreted: the human confirms it). Page a whole-PLC or container read with `limit`\n (for example 200) and `cursor` (the `nextCursor` of the previous page, until it is null; on\n `cursor_stale` restart from the first page, and on an omission marker repeat the same request\n with a smaller `limit`, never following a cursor from an omitted page); each page re-reads the\n whole PLC, so a later page can report less than an earlier one. Read `coverage` on every page,\n not only the first, and compare its counts across pages: differing counts restart the walk once\n from the first page (like `cursor_stale`). Only a finished walk whose pages all report\n `coverage.complete: true` supports "audited completely" or "nothing uses this"; an omission\n marker, an unfinished walk, differing counts or `coverage.complete: false` on any page (see\n `coverage.unavailableOwners`) means the result is NOT complete.\n- **FAT/SAT I/O list** (`tia-verify` step 6): `tia_io_map`; recipe: `tia_guide {"topic":"recipes"}`, \'Recipe \u2014 generate the FAT/SAT I/O list\'.\n- **Prove the project matches what\'s versioned** (a raw hash is NOT proof): `tia_guide {"topic":"recipes"}`, \'Recipe \u2014 prove the project matches the versioned XML\'.\n\n## Network lifecycle (subnets, PROFINET names, IO systems)\n\nRead first (`tia_subnet_get`, `tia_device_network`, `tia_io_systems`), then run each write\'s `dryRun` (answered by\nthe serve, needs an open project). Order, PROFINET names, `disconnectNodes`: `tia_guide {"topic":"recipes"}`, \'Reference \u2014 network, audit and CAx how-to\'.\n\n- **Refused, nothing changed:** `tia_subnet_delete` of a non-empty subnet (`409 subnet_not_empty`);\n `tia_io_system_connect` across subnets (`409 cross_subnet_assignment`: `tia_network_connect` the device to that subnet first).\n- **`409 postcheck_failed`:** the write did not take effect as asked: re-read, never repeat blindly.\n\n## Libraries, HMI, CAx and PLC security\n\nReads are class R; every change is class M-off (offline, with `dryRun`) and reaches the CPU\nonly through a later `tia_compile` + human-gated `tia_download` (G3). Every file path is a\npath ON THE SERVE HOST.\n\n- **Guarded PLC writes** (`tia_tag_update`, `tia_constant_update`, `tia_constant_delete`,\n `tia_tagtable_delete`, `tia_block_group_delete`, `tia_ob_create`, `tia_block_compile`): the serve\n answers their `dryRun` (it needs an open project) with the guard verdict (name collision, default\n tag table, non-empty group, singleton OB).\n- **Project library:** `tia_library_mastercopies` / `tia_library_types` read it;\n `tia_library_mastercopy_create` turns a DEVICE into a master copy (a block cannot be a source);\n `tia_block_from_mastercopy` needs one that holds PLC blocks.\n- **Global libraries** (in the TIA Portal session, not the project): `tia_global_libraries`,\n `tia_global_library_create` / `_open` / `_save` / `_close`; save/close take the name from\n `tia_global_libraries` (exact name first, then ignoring case). REFUSED, nothing saved or closed\n (`404 not_found` / `409 conflict`): a name that picks no single open USER library (unknown, read-only\n system/corporate, several matches ignoring case) and a save of a `readWrite:false` library. Up to app\n 1.6.3 an unknown name can report success without saving or closing anything: check `tia_global_libraries`.\n- **HMI:** `tia_hmis` and `tia_hmi_screens` read any HMI; screen files\n (`tia_hmi_screen_export`, `tia_hmi_screens_import`) work for WinCC **Classic** only, and the\n import OVERWRITES same-named screens.\n- **CAx (AutomationML):** `tia_cax_export` / `tia_cax_import` (scope, `option` values: recipes). Archive the\n project before an overwrite. A failed transfer is an error after app 1.6.3; on an older serve check the\n devices with `tia_devices`.\n- **Error contracts by app version:** `tia_guide {"topic":"recipes"}`, \'Reference \u2014 global library and CAx error contracts (by app version)\'.\n- **PLC security:** `tia_certificates` / `tia_certificate_template` / `tia_password_policy`\n read; `tia_certificate_import` / `_export` / `_delete`, `tia_password_policy_set` and\n `tia_block_protect` change the project. **G6:** a block or certificate password and the\n password-policy values come from a HUMAN \u2014 never invent, guess or reuse one; dryRun plans\n show a password as `[redacted]`. A CPU without the certificate manager or a policy service\n answers 409.\n- **Multiuser:** `tia_project_servers`, `tia_server_projects` read Project Servers; `tia_local_session_open` needs NO open project (`tia_project_close`, `tia_start`). Nothing is ever checked in.\n\n---\n\n# Recipes (runtime-verified)\n\nNot copied here: Codex reads at most 32 KiB of AGENTS.md and cuts the rest without a word. Call\n`tia_guide {"topic":"recipes"}` for the verified recipes (unlocking a freshly-created CPU, the in-place firmware\nbump, Modbus TCP, S7 PUT/GET and OPC UA on the S7-1200, the scaffold order) before you need one.\n\n---\n\n# The project-spec (input model)\n\nA project-spec is ONE JSON document describing the whole project. Always run it\nthrough the pipeline front door: `tia_spec_validate` (rung 0, pure) \u2192 `tia_spec_plan`\n(dry) \u2192 `tia_spec_apply` (M-off, stops at gates).\n\n`tia_spec_validate` checks the shape only in part (it does not run the JSON Schema; the `spec-validate`\nskill adds it) and enforces: unique device/subnet/UDT/block/per-table tag names; every network node IP\ninside the subnet CIDR; `OrderNumber:<MLFB>/V<fw>` with `/V` \u2014 never `:V` (Gd5); no STL/GRAPH on an\nS7-1200; at most 8 SMs on an S7-1200 (its only module limit); and G5 \u2014 a spec with safety content\nmarked autonomous is REJECTED (F-logic is never autonomous).\n\nMinimal example:\n\n```json\n{\n "project": { "name": "Line2", "directory": "C:\\\\TIA\\\\Line2" },\n "conventions": {\n "namingScheme": "plcopen",\n "optimizedAccess": true,\n "symbolicOnly": true,\n "defaultLanguages": { "interlocks": "LAD", "algorithms": "SCL", "sequencers": "GRAPH" }\n },\n "devices": [\n {\n "name": "Line2_CPU",\n "typeIdentifier": "OrderNumber:6ES7 511-1AK02-0AB0/V2.9",\n "role": "cpu",\n "family": "S7-1500"\n }\n ],\n "network": {\n "subnet": { "type": "System:Subnet.Ethernet", "name": "PN_Line2", "cidr": "192.168.0.0/24" },\n "nodes": [{ "device": "Line2_CPU", "ip": "192.168.0.1", "createIoSystem": true }]\n },\n "dataTypes": [\n {\n "name": "UDT_Motor",\n "members": [\n { "name": "xStart", "dataType": "Bool", "comment": "Start command" },\n { "name": "rSpeed", "dataType": "Real", "comment": "Speed [%]" }\n ]\n }\n ],\n "tagTables": [{ "name": "IO", "purpose": "IO" }],\n "tags": [{ "table": "IO", "name": "Conv01_Run", "dataType": "Bool", "address": "%Q0.0" }]\n}\n```\n\nThe plan and `tia_spec_apply` neither import `dataTypes` nor author block logic: UDTs go in with\n`tia_types_import`, logic with `tia_source_put` / `tia_import_xml`.\n\nResolve every concrete MLFB + firmware via `tia_catalog` before building \u2014 never guess\nan order number. Project firmware must be \u2264 the physical device\'s firmware.\n';
|
|
23953
23953
|
|
|
23954
23954
|
// src/mode.ts
|
|
23955
23955
|
var MCP_MODES = ["full", "read-only"];
|
|
@@ -39706,7 +39706,7 @@ function buildServer(mode, version2, budget = resolveBudget()) {
|
|
|
39706
39706
|
}
|
|
39707
39707
|
|
|
39708
39708
|
// src/index.ts
|
|
39709
|
-
var VERSION = "1.10.
|
|
39709
|
+
var VERSION = "1.10.5";
|
|
39710
39710
|
async function main() {
|
|
39711
39711
|
if (process.argv.slice(2).some((a) => a === "--version" || a === "-v")) {
|
|
39712
39712
|
console.log(VERSION);
|
package/package.json
CHANGED