@renanlido/tia-openness-mcp 1.13.0 → 1.13.2
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 +41 -84
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -28629,7 +28629,7 @@ function isControlResult(value) {
|
|
|
28629
28629
|
// src/jobRunner.ts
|
|
28630
28630
|
var SOFT_DEADLINE_CAP_MS = 25e3;
|
|
28631
28631
|
function parsePositiveInt(raw, fallback) {
|
|
28632
|
-
if (
|
|
28632
|
+
if (!/^\d+$/.test(String(raw))) return fallback;
|
|
28633
28633
|
const n = Number(raw);
|
|
28634
28634
|
if (!Number.isSafeInteger(n) || n <= 0 || n > 2147483647) return fallback;
|
|
28635
28635
|
return n;
|
|
@@ -28646,8 +28646,7 @@ function toolResult(payload, isError) {
|
|
|
28646
28646
|
}
|
|
28647
28647
|
function describeError(e) {
|
|
28648
28648
|
try {
|
|
28649
|
-
|
|
28650
|
-
return String(e);
|
|
28649
|
+
return String(e instanceof Error ? e.message : e);
|
|
28651
28650
|
} catch {
|
|
28652
28651
|
return "non-Error rejection";
|
|
28653
28652
|
}
|
|
@@ -28681,7 +28680,9 @@ function stableStringifyPlain(value) {
|
|
|
28681
28680
|
}
|
|
28682
28681
|
const obj = value;
|
|
28683
28682
|
const keys = Object.keys(obj).filter((k) => obj[k] !== void 0).sort();
|
|
28684
|
-
|
|
28683
|
+
const members2 = keys.map((k) => `${JSON.stringify(k)}:${stableStringify(obj[k])}`);
|
|
28684
|
+
const canonical = members2.join(",");
|
|
28685
|
+
return `{${canonical}}`;
|
|
28685
28686
|
}
|
|
28686
28687
|
function dedupeKey(tool, args) {
|
|
28687
28688
|
const canonical = `${tool}:${stableStringify(args ?? {})}`;
|
|
@@ -28745,6 +28746,7 @@ var JobRunner = class {
|
|
|
28745
28746
|
result: null,
|
|
28746
28747
|
runningHint: options.runningHint ?? null,
|
|
28747
28748
|
retain: false,
|
|
28749
|
+
// Stryker disable next-line BooleanLiteral: a placeholder, replaced synchronously below
|
|
28748
28750
|
done: Promise.resolve(toolResult({}, false))
|
|
28749
28751
|
// placeholder; substituído já a seguir, síncrono
|
|
28750
28752
|
};
|
|
@@ -28760,13 +28762,12 @@ var JobRunner = class {
|
|
|
28760
28762
|
return settled;
|
|
28761
28763
|
}
|
|
28762
28764
|
).finally(() => {
|
|
28763
|
-
this.finish(job, settled
|
|
28765
|
+
this.finish(job, settled);
|
|
28764
28766
|
});
|
|
28765
28767
|
const deadline = wait(this.softDeadlineMs);
|
|
28766
|
-
|
|
28768
|
+
await Promise.race([job.done, deadline.promise]);
|
|
28767
28769
|
deadline.cancel();
|
|
28768
|
-
if (
|
|
28769
|
-
if (job.finishedAt !== null && job.result) return job.result;
|
|
28770
|
+
if (job.finishedAt !== null) return job.result;
|
|
28770
28771
|
return this.running(job, false);
|
|
28771
28772
|
}
|
|
28772
28773
|
async status(jobId, waitMs) {
|
|
@@ -28783,11 +28784,9 @@ var JobRunner = class {
|
|
|
28783
28784
|
true
|
|
28784
28785
|
);
|
|
28785
28786
|
}
|
|
28786
|
-
|
|
28787
|
-
|
|
28788
|
-
|
|
28789
|
-
w.cancel();
|
|
28790
|
-
}
|
|
28787
|
+
const w = wait(Math.min(Math.max(waitMs, 0), MAX_STATUS_WAIT_MS));
|
|
28788
|
+
await Promise.race([job.done, w.promise]);
|
|
28789
|
+
w.cancel();
|
|
28791
28790
|
return job.finishedAt !== null ? this.withJob(job) : this.running(job, false);
|
|
28792
28791
|
}
|
|
28793
28792
|
/** Só para testes: esquece jobs (não cancela trabalho em andamento). */
|
|
@@ -28802,9 +28801,7 @@ var JobRunner = class {
|
|
|
28802
28801
|
if (!job.retain) return;
|
|
28803
28802
|
this.finished.set(job.id, job);
|
|
28804
28803
|
while (this.finished.size > KEEP_FINISHED) {
|
|
28805
|
-
|
|
28806
|
-
if (oldest === void 0) break;
|
|
28807
|
-
this.finished.delete(oldest);
|
|
28804
|
+
this.finished.delete(this.finished.keys().next().value);
|
|
28808
28805
|
}
|
|
28809
28806
|
}
|
|
28810
28807
|
running(job, deduplicated) {
|
|
@@ -28958,10 +28955,11 @@ async function tiaFetch(path, init = {}, opts = {}) {
|
|
|
28958
28955
|
if (baseProblem) throw new TiaApiError(baseProblem, { kind: "invalid_api_base" });
|
|
28959
28956
|
const url2 = `${BASE}${path}`;
|
|
28960
28957
|
const timeout = opts.timeoutMs ?? TIMEOUT_MS;
|
|
28961
|
-
const headers =
|
|
28962
|
-
|
|
28963
|
-
|
|
28964
|
-
|
|
28958
|
+
const headers = new Headers(init.headers);
|
|
28959
|
+
if (!headers.has("Accept")) headers.set("Accept", "application/json");
|
|
28960
|
+
if (init.body !== void 0 && init.body !== null && !headers.has("Content-Type")) {
|
|
28961
|
+
headers.set("Content-Type", "application/json; charset=utf-8");
|
|
28962
|
+
}
|
|
28965
28963
|
const dispatcher = timeout > FETCH_HEADERS_TIMEOUT_MS ? unboundedDispatcher() : void 0;
|
|
28966
28964
|
const controller = new AbortController();
|
|
28967
28965
|
const timer = setTimeout(() => controller.abort(), timeout);
|
|
@@ -28995,7 +28993,7 @@ async function tiaFetch(path, init = {}, opts = {}) {
|
|
|
28995
28993
|
}
|
|
28996
28994
|
}
|
|
28997
28995
|
if (!res.ok) {
|
|
28998
|
-
const env = body
|
|
28996
|
+
const env = body instanceof Object ? body : {};
|
|
28999
28997
|
const license = env.license;
|
|
29000
28998
|
const message = typeof env.error === "string" ? env.error : `HTTP ${res.status} ${res.statusText}`;
|
|
29001
28999
|
throw new TiaApiError(message, {
|
|
@@ -29012,7 +29010,7 @@ async function tiaFetch(path, init = {}, opts = {}) {
|
|
|
29012
29010
|
}
|
|
29013
29011
|
var INSTALLING_HINT = "The serve host is installing a TIAOpenness app update: this call was refused BEFORE any operation ran (nothing changed). Wait until the update finishes, then retry the same call (GET /status stays available while draining \u2014 retry once it reports draining:false).";
|
|
29014
29012
|
var AUDIT_UNAVAILABLE_HINT = "The serve could not write its local audit log, so it refused this call BEFORE running anything: nothing was sent to the PLC and nothing changed (there is no background job for this call). A human must fix the audit log on the serve host (disk full or no write permission on %LOCALAPPDATA%\\TIAOpenness\\audit, or on the folder TIAOPENNESS_AUDIT_DIR points to); only after that, retry.";
|
|
29015
|
-
var UNSAVED_OPERATIONS = ["connect", "project_close", "disconnect", "project_create"];
|
|
29013
|
+
var UNSAVED_OPERATIONS = /* @__PURE__ */ new Set(["connect", "project_close", "disconnect", "project_create"]);
|
|
29016
29014
|
var BINDING_REASONS = {
|
|
29017
29015
|
project_closed: "the project was closed in TIA, so nothing is open in it now",
|
|
29018
29016
|
other_project: "another project is open in it now (a different project was opened, or the project was saved under another name or place with Save As)",
|
|
@@ -29042,7 +29040,7 @@ function unsavedChangesHint(details) {
|
|
|
29042
29040
|
const projects = (Array.isArray(d.projects) ? d.projects : []).map(describeProject).filter((p) => p !== null);
|
|
29043
29041
|
const stateUnknown = d.reason === "state_unknown";
|
|
29044
29042
|
if (d.operation === "show_ui") return showUiRefusalHint(projects, stateUnknown);
|
|
29045
|
-
const tool =
|
|
29043
|
+
const tool = UNSAVED_OPERATIONS.has(d.operation) ? `tia_${d.operation}` : null;
|
|
29046
29044
|
const named = stateUnknown ? projects.length > 0 ? `Whether they have unsaved changes could not be read. Projects whose unsaved state could not be verified: ${projects.join("; ")}. ` : "Whether a project has unsaved changes could not be read (the TIA Portal did not answer). " : projects.length > 0 ? `Projects with unsaved changes that this call would close: ${projects.join("; ")}. ` : "A project with unsaved changes would be closed by this call. ";
|
|
29047
29045
|
const untouched = stateUnknown ? "nothing was closed, disconnected or opened (a save you asked for may already have run for some projects: saved projects stay saved). " : "nothing was saved, closed, disconnected or opened. ";
|
|
29048
29046
|
return `serve REFUSED ${tool ?? "this call"} before changing anything: ${untouched}` + named + "ASK the human whether to keep that work or throw it away; do not decide for them. To keep it, repeat the SAME call with saveUnsavedChanges:true (recommended: serve saves each modified project, then goes on). Pass discardUnsavedChanges:true ONLY if the human explicitly decides the unsaved work may be lost for good (data loss, cannot be undone), never just to get past this error. The two flags cannot both be true.";
|
|
@@ -37434,10 +37432,7 @@ function resolveBudget(getEnv = (name) => process.env[name]) {
|
|
|
37434
37432
|
var PAGING_HINT = "Call the same tool again with limit (1..1000) and pass nextCursor from each page as cursor to read the rest.";
|
|
37435
37433
|
var PAGED_HINT = "The budget omitted data from this page, so any nextCursor was removed from it: following a cursor now would skip what was omitted. Retry the same request (the same cursor, or none for the first page) with a smaller limit, for example half of the one you used. Only follow a nextCursor from a page that arrives without an omission marker.";
|
|
37436
37434
|
var EXPORT_XML_HINT = "The XML is too large for the response budget. sha256, normalizedSha256, contentHash (when the serve computed one) and bytes stay in this result. Use tia_export_xml to write the block/type XML files to a directory on the serve host (it returns file paths), or tia_block_compare (block) to check the block against a SimaticML file you already hold without returning XML, or raise TIA_MCP_MAX_VALUE_CHARS/TIA_MCP_MAX_RESPONSE_CHARS on the MCP. tia_export_xml and tia_block_compare are not registered when TIA_MCP_MODE=read-only: in that mode raise the two limits.";
|
|
37437
|
-
var EXPORT_SD_HINT = (
|
|
37438
|
-
// Stryker disable next-line StringLiteral: static module constant, evaluated once at import; budget.test.ts pins every sentence of the delivered hint
|
|
37439
|
-
"The SD text is too large for the response budget. contentHash (when the serve computed one), s7dclBytes and s7resBytes stay in this result. Raise TIA_MCP_MAX_VALUE_CHARS/TIA_MCP_MAX_RESPONSE_CHARS on the MCP, or export the object to a VCI workspace file on the serve host (tia_vci_export, which is not registered when TIA_MCP_MODE=read-only: in that mode raise the two limits). An omitted s7dcl is not the object: do not import or compare it."
|
|
37440
|
-
);
|
|
37435
|
+
var EXPORT_SD_HINT = "The SD text is too large for the response budget. contentHash (when the serve computed one), s7dclBytes and s7resBytes stay in this result. Raise TIA_MCP_MAX_VALUE_CHARS/TIA_MCP_MAX_RESPONSE_CHARS on the MCP, or export the object to a VCI workspace file on the serve host (tia_vci_export, which is not registered when TIA_MCP_MODE=read-only: in that mode raise the two limits). An omitted s7dcl is not the object: do not import or compare it.";
|
|
37441
37436
|
var CROSSREFS_HINT = "Call tia_crossrefs again with limit (1..1000) and pass the nextCursor of each page as cursor to read the sources page by page, or narrow the read with target, kind or filter. summary and coverage stay in this result. An omitted section is NOT complete: do not report the sources, an UnusedObjects list or any claim that nothing uses an object as complete from it.";
|
|
37442
37437
|
var VCI_STATUS_HINT = "Call tia_vci_status again with limit (recommended 100, up to 1000) and pass the nextCursor of each page as cursor to read the objects page by page. summary and coverage stay in this result and describe the rows of the response, so fold them across every page of a paged read. An omitted section is NOT verified: do not report the workspace as clean, or any object as equal, from it.";
|
|
37443
37438
|
var IOMAP_HINT = "Call tia_io_map again with limit (1..1000), starting at 100 to 200, and pass the nextCursor of each page as cursor to read the entries page by page. summary and coverage stay in this result. An omitted section is NOT complete: do not report the channels, the matched tags, the unmatched tags or a FAT/SAT I/O list as complete from it.";
|
|
@@ -38571,10 +38566,7 @@ function registerReadOnlyTools(server) {
|
|
|
38571
38566
|
"tia_instances",
|
|
38572
38567
|
{
|
|
38573
38568
|
title: "TIA \u2014 running instances",
|
|
38574
|
-
description: (
|
|
38575
|
-
// Stryker disable next-line StringLiteral: handoff prose, facts are tested
|
|
38576
|
-
"Lists TIA Portal sessions exposed by Openness and native Siemens.Automation.Portal.exe processes on the serve host. Native-only rows include the PID with mode and project path set to null. Maps to GET /instances. Read-only (class R)."
|
|
38577
|
-
),
|
|
38569
|
+
description: "Lists TIA Portal sessions exposed by Openness and native Siemens.Automation.Portal.exe processes on the serve host. Native-only rows include the PID with mode and project path set to null. Maps to GET /instances. Read-only (class R).",
|
|
38578
38570
|
inputSchema: {}
|
|
38579
38571
|
},
|
|
38580
38572
|
async () => getResult("/instances")
|
|
@@ -39198,9 +39190,8 @@ function startingUnconfirmedResult(err, operation) {
|
|
|
39198
39190
|
kind: err.kind,
|
|
39199
39191
|
status: err.status,
|
|
39200
39192
|
type: err.type,
|
|
39201
|
-
//
|
|
39193
|
+
// A "timeout" kind is produced by the client, not the serve, so inner and details are null.
|
|
39202
39194
|
inner: err.inner ?? null,
|
|
39203
|
-
// Stryker disable next-line LogicalOperator: Client-created timeouts omit `details` and TiaApiError defaults it to null; the serve emits no timeout kind.
|
|
39204
39195
|
details: err.details ?? null,
|
|
39205
39196
|
hint: "The client timeout does not cancel the serve-side operation, so its serial worker may still be occupied. A timeout or reachable /health endpoint proves neither success nor G1.",
|
|
39206
39197
|
nextSteps: [
|
|
@@ -39399,7 +39390,7 @@ function registerLifecycleTools(server) {
|
|
|
39399
39390
|
description: "Opens/attaches a TIA project (.ap*) on the serve host. Class M-off. Idempotent for the ALREADY-OPEN project (response `alreadyOpen:true`, no-op) and reuses a running TIA instance for a DIFFERENT project (`reusedPortal:true`). In an instance serve started, the open project and any foreign project are closed to make room (or the instance is restarted): if one has unsaved changes the call is REFUSED with 409 `unsaved_changes` and nothing is changed, unless it carries `saveUnsavedChanges:true` (saves each modified project first; recommended) or `discardUnsavedChanges:true` (closes WITHOUT saving: DATA LOSS, only on an explicit human decision, never to get past the refusal; the client asks the human to confirm first). `closedForeign` lists the foreign projects that were closed, `savedProjects`/`discardedProjects` the ones saved or discarded; an instance you had open yourself is never closed (serve only detaches). The response carries `boundProjectPath` (the project this session is bound to) and `modified` (unsaved changes); a later operation answers 409 `binding_conflict` if the project open in the bound TIA changed meanwhile (call tia_connect again to rebind). `withUserInterface` only applies when a NEW instance is started (ignored when reusing one \u2014 see tia_show_ui to change an existing instance's visibility). WARNING: the 1st connection per `serve` process can BLOCK on the trust GATE (G1) \u2014 if the dialog hasn't been confirmed, this tool does NOT retry-storm: it returns a `requires_human_action` envelope (gate trust_dialog, with resumeToken) asking a human to confirm the dialog on the host. Proactive flow: tia_start \u2192 tia_show_ui \u2192 (human confirms) \u2192 tia_connect. UMAC (umacUser/umacPassword) is GATE G6: provide it ONLY if a human gave the credentials \u2014 NEVER make them up. Maps to POST /connect. " + LONG_OPERATION_NOTE,
|
|
39400
39391
|
inputSchema: {
|
|
39401
39392
|
projectPath: external_exports.string().describe("path to the project file (.ap*) on the serve host (required)"),
|
|
39402
|
-
tiaVersion: external_exports.string().optional().describe("Optional TIA host
|
|
39393
|
+
tiaVersion: external_exports.string().optional().describe("Optional TIA host: the line '21' or 'V21', or an exact release '21.0' or '21.1'. Without it the project target applies (.ap21 is V21, .ap21_1 is V21.1), otherwise the lowest installed V21 release (V21 before V21.1). A project opens only in its own release: TIA V21.1 would save a .ap21 project as .ap21_1, so that is refused with 409 tia_version_conflict. This application ships only the V21 layer, which serves V21 and V21.1; legacy selections are refused before startup with 409 feature_unsupported_in_version. Restart serve to change its selected host/API tuple."),
|
|
39403
39394
|
withUserInterface: external_exports.boolean().optional().describe("open with the TIA UI visible (default true)"),
|
|
39404
39395
|
umacUser: external_exports.string().optional().describe("UMAC user (GATE G6; only if a human provided it \u2014 never make it up)"),
|
|
39405
39396
|
umacPassword: external_exports.string().optional().describe("UMAC password (GATE G6; only if a human provided it \u2014 never make it up)"),
|
|
@@ -40571,7 +40562,6 @@ var IGNORED_ALWAYS = [
|
|
|
40571
40562
|
"indentation and blank lines (also inside multi-line <Text> comments, via a per-line trim)",
|
|
40572
40563
|
"<Created> (export timestamp)",
|
|
40573
40564
|
"<InstalledProducts> (TIA hotfix level and installed option packages)",
|
|
40574
|
-
// Stryker disable next-line StringLiteral: ignored-field explanation; compare-wiring.test.ts covers the actual normalization
|
|
40575
40565
|
"UId numbering (canonical first appearance across definitions and references; connectivity is preserved)"
|
|
40576
40566
|
];
|
|
40577
40567
|
var IGNORED_FORMATTING = "<NewLine/> and <Blank/> structured-text formatting tokens";
|
|
@@ -42871,10 +42861,7 @@ function renderPseudoScl(xml) {
|
|
|
42871
42861
|
}
|
|
42872
42862
|
|
|
42873
42863
|
// src/tools/asCode.ts
|
|
42874
|
-
var COMPARISON_HASH_NOTE =
|
|
42875
|
-
// Stryker disable next-line StringLiteral: comparison migration prose; compare-wiring.test.ts covers the hash behavior
|
|
42876
|
-
"`normalizedSha256` now uses wiring-safe UId canonicalization: stored values may change; recompute comparison baselines."
|
|
42877
|
-
);
|
|
42864
|
+
var COMPARISON_HASH_NOTE = "`normalizedSha256` now uses wiring-safe UId canonicalization: stored values may change; recompute comparison baselines.";
|
|
42878
42865
|
var HASH_CONTRACT_NOTE = "`contentHash`, `normalizedSha256` and `sha256` are different hash contracts over different normalizations: never substitute one for another, and pass only the `contentHash` of a fresh read as `expectedContentHash`. " + COMPARISON_HASH_NOTE;
|
|
42879
42866
|
async function fetchXml(path, options) {
|
|
42880
42867
|
const q = options ? `?options=${encodeURIComponent(options)}` : "";
|
|
@@ -42993,8 +42980,7 @@ function registerAsCodeTools(server) {
|
|
|
42993
42980
|
"tia_block_compare",
|
|
42994
42981
|
{
|
|
42995
42982
|
title: "TIA \u2014 compare a block with given SimaticML",
|
|
42996
|
-
description: "Exports the block from the project and compares it with the SimaticML you pass (e.g. the file committed in git). Like tia_export_block, this may compile an inconsistent block first (export requires consistency), which can regenerate its instance DB; read-mostly, treated as read for agent tool policy. Normalized: ignores BOM, line endings, indentation, blank lines, <Created>, <InstalledProducts> and \u2014 unless ignoreFormatting:false \u2014 <NewLine/>/<Blank/> formatting tokens (see the result's `ignored` field for the exact list). UIds are renumbered by first appearance across definitions and references: rewiring differs, pure renumbering matches; UId-like text in comments and values is preserved. Returns verdict equal|different and the first differing line. " + COMPARISON_HASH_NOTE +
|
|
42997
|
-
" This is the proof that the project contains what was versioned. Maps to GET /plcs/{plc}/blocks/{block}/xml. Engineering version and schema namespaces remain significant; equality is not cross-version import acceptance. " + LONG_OPERATION_NOTE,
|
|
42983
|
+
description: "Exports the block from the project and compares it with the SimaticML you pass (e.g. the file committed in git). Like tia_export_block, this may compile an inconsistent block first (export requires consistency), which can regenerate its instance DB; read-mostly, treated as read for agent tool policy. Normalized: ignores BOM, line endings, indentation, blank lines, <Created>, <InstalledProducts> and \u2014 unless ignoreFormatting:false \u2014 <NewLine/>/<Blank/> formatting tokens (see the result's `ignored` field for the exact list). UIds are renumbered by first appearance across definitions and references: rewiring differs, pure renumbering matches; UId-like text in comments and values is preserved. Returns verdict equal|different and the first differing line. " + COMPARISON_HASH_NOTE + " This is the proof that the project contains what was versioned. Maps to GET /plcs/{plc}/blocks/{block}/xml. Engineering version and schema namespaces remain significant; equality is not cross-version import acceptance. " + LONG_OPERATION_NOTE,
|
|
42998
42984
|
inputSchema: {
|
|
42999
42985
|
plc: external_exports.string().describe("PLC software name from tia_plcs.name, not the device station name"),
|
|
43000
42986
|
block: external_exports.string().describe("block name"),
|
|
@@ -43009,12 +42995,8 @@ function registerAsCodeTools(server) {
|
|
|
43009
42995
|
"tia_block_render",
|
|
43010
42996
|
{
|
|
43011
42997
|
title: "TIA \u2014 render a block as readable pseudo-SCL (LAD/FBD)",
|
|
43012
|
-
description: (
|
|
43013
|
-
// Stryker disable next-line StringLiteral: inline-input guidance prose; blockRender.test.ts covers path refusals and BOM XML
|
|
43014
|
-
"Class R, pure/offline: never calls serve. Pass XML text, not a file path: use the inline xml field of tia_export_block {plc, block}. Renders ONE SimaticML block as readable pseudo-SCL: LAD/FBD contacts, coils, logic boxes, comparators, MOVE/arithmetic, timers, counters, edges and block calls become SCL-like statements; SCL networks are rebuilt from their tokens; STL/GRAPH networks are marked not rendered. A value read by several statements or assigned to several targets is evaluated once: held in an RLO_<UId> temporary (UId of the part producing it) or read back from the first coil that wrote it. A MOVE/arithmetic output read by another part is inlined only when the box is always enabled; otherwise IF <EN> THEN TMP_<UId> := <value>; END_IF; and the reader uses TMP_<UId>, which keeps its previous (stale) value when EN is false. The output or return value of ONE call is TMP_<UId>_<pin> when it has several targets or, for an FC (no instance), when another part reads it or it is negated: bound in the call (pin => TMP_<UId>_<pin>, or TMP_<UId>_<pin> := call(args); for the return value), and targets and readers copy from it; two calls never share one. A call with an instance and one target is direct or read as #inst.pin. An edge (P_TRIG/N_TRIG) runs every scan: used inside an IF <EN> body it is evaluated before the IF (RLO_<UId> := P_TRIG(...);), not conditional on that EN. A negated output pin shows as NOT (a negated instance or call output: a following line target := NOT #t.Q; under the same EN). TYPE#(x) is x read as TYPE: an absolute address of a non-natural type for its size shows its own type (INT#(%MW0)); a comparator, arithmetic box or Inc/Dec casts with the instruction type every operand but a constant, a boolean or one of that type, values forwarded by MOVE, a box or a call too (INT#(RLO_40), INT#(TMP_41)); constants and written places are never cast. What it cannot translate stays visible as (* unsupported: ... *) and is listed in unsupported, as are a duplicate UId, edge memory shared by several edge parts, a negated operand on an S/R/P/N coil and an invalid name or UId: that part is ambiguous, read it in the XML or report it as not reviewed. A network too large to render is marked not rendered and in unsupported (render budget). Hidden and bidirectional characters show as <U+XXXX>. For review only: not importable, layout not preserved, ENO shown as EN (errors not modeled). Returns {text, blocks, unsupported, note}."
|
|
43015
|
-
),
|
|
42998
|
+
description: "Class R, pure/offline: never calls serve. Pass XML text, not a file path: use the inline xml field of tia_export_block {plc, block}. Renders ONE SimaticML block as readable pseudo-SCL: LAD/FBD contacts, coils, logic boxes, comparators, MOVE/arithmetic, timers, counters, edges and block calls become SCL-like statements; SCL networks are rebuilt from their tokens; STL/GRAPH networks are marked not rendered. A value read by several statements or assigned to several targets is evaluated once: held in an RLO_<UId> temporary (UId of the part producing it) or read back from the first coil that wrote it. A MOVE/arithmetic output read by another part is inlined only when the box is always enabled; otherwise IF <EN> THEN TMP_<UId> := <value>; END_IF; and the reader uses TMP_<UId>, which keeps its previous (stale) value when EN is false. The output or return value of ONE call is TMP_<UId>_<pin> when it has several targets or, for an FC (no instance), when another part reads it or it is negated: bound in the call (pin => TMP_<UId>_<pin>, or TMP_<UId>_<pin> := call(args); for the return value), and targets and readers copy from it; two calls never share one. A call with an instance and one target is direct or read as #inst.pin. An edge (P_TRIG/N_TRIG) runs every scan: used inside an IF <EN> body it is evaluated before the IF (RLO_<UId> := P_TRIG(...);), not conditional on that EN. A negated output pin shows as NOT (a negated instance or call output: a following line target := NOT #t.Q; under the same EN). TYPE#(x) is x read as TYPE: an absolute address of a non-natural type for its size shows its own type (INT#(%MW0)); a comparator, arithmetic box or Inc/Dec casts with the instruction type every operand but a constant, a boolean or one of that type, values forwarded by MOVE, a box or a call too (INT#(RLO_40), INT#(TMP_41)); constants and written places are never cast. What it cannot translate stays visible as (* unsupported: ... *) and is listed in unsupported, as are a duplicate UId, edge memory shared by several edge parts, a negated operand on an S/R/P/N coil and an invalid name or UId: that part is ambiguous, read it in the XML or report it as not reviewed. A network too large to render is marked not rendered and in unsupported (render budget). Hidden and bidirectional characters show as <U+XXXX>. For review only: not importable, layout not preserved, ENO shown as EN (errors not modeled). Returns {text, blocks, unsupported, note}.",
|
|
43016
42999
|
inputSchema: {
|
|
43017
|
-
// Stryker disable next-line StringLiteral: input description prose; path validation and parsing stay in mutation scope
|
|
43018
43000
|
xml: external_exports.string().describe("XML text of ONE SimaticML block export, NOT a file path. Get it from the inline xml field of tia_export_block {plc, block}")
|
|
43019
43001
|
}
|
|
43020
43002
|
},
|
|
@@ -43334,10 +43316,7 @@ var expectedContentHashField = {
|
|
|
43334
43316
|
)
|
|
43335
43317
|
};
|
|
43336
43318
|
var UNGUARDED_WRITE_HINT = "expectedContentHash was sent but the serve did not return `contentGuard`: it does not implement the stale-write guard (an older serve \u2014 update the TIAOpenness app on the host), so this write was NOT guarded against changes made in the project after you read the object. Re-read it (tia_export_block / tia_export_type) and compare before relying on the result.";
|
|
43337
|
-
var SOURCE_IMPACT_NOTE = (
|
|
43338
|
-
// Stryker disable next-line StringLiteral: description-only receipt catalog and guide pointer; runtime decisions remain in scope
|
|
43339
|
-
" Returns changeImpact/compileImpact (flags/members), memberCapture and readGaps (unknown); trackChanges:false skips observation. See tia_guide gotchas. "
|
|
43340
|
-
);
|
|
43319
|
+
var SOURCE_IMPACT_NOTE = " Returns changeImpact/compileImpact (flags/members), memberCapture and readGaps (unknown); trackChanges:false skips observation. See tia_guide gotchas. ";
|
|
43341
43320
|
function guardedSummary(summary, expectedContentHash) {
|
|
43342
43321
|
return expectedContentHash === void 0 ? summary : `${summary}, guarded by expectedContentHash (verified by the serve only when the write really runs; dryRun never calls it)`;
|
|
43343
43322
|
}
|
|
@@ -43459,11 +43438,8 @@ function registerAuthoringTools(server) {
|
|
|
43459
43438
|
description: `Creates a device (CPU/HMI/IO) by typeIdentifier. Optional group is an existing device user-group path (Area/Line, case-insensitive); omitted means project level. For group, GET /status must advertise supportsDeviceGroupCreation:true (app 1.8.1+); older serves are refused before creation. Uses typed CreateWithItem, never the unsafe generic CreateDevices call. The successful receipt identifies the canonical group; missing or different placement is an error naming the created station when available: inspect before retrying, never retry automatically. A dryRun preview does not check serve support. The answer uses the station type identifier, falling back to the first readable DeviceItem.TypeIdentifier, including HMI panels. typeIdentifierSource is device, deviceItem or unavailable; unavailable metadata has typeIdentifier:null and an explicit typeIdentifierUnavailableReason. For a single-item device such as a Classic panel, set its name as deviceItemName and omit deviceName; deviceName is the station name and may be read-only. On 400 device_name_read_only, re-read GET /devices before retrying with only deviceItemName. Guard Gd5: '/V<fw>' (slash), never ':V' \u2014 resolve via tia_catalog. Maps to POST /devices. Class M-off. ${LONG_OPERATION_NOTE}`,
|
|
43460
43439
|
inputSchema: {
|
|
43461
43440
|
typeIdentifier: external_exports.string().describe("OrderNumber:<MLFB>/V<fw> (Gd5; resolve via tia_catalog)"),
|
|
43462
|
-
// Stryker disable next-line StringLiteral: handoff prose, facts are tested
|
|
43463
43441
|
deviceItemName: external_exports.string().optional().describe("device-item name; for an HMI, names the panel item (for a single-item device, use this as its name)"),
|
|
43464
|
-
// Stryker disable next-line StringLiteral: handoff prose, facts are tested
|
|
43465
43442
|
deviceName: external_exports.string().optional().describe("station name; may be read-only on some device types"),
|
|
43466
|
-
// Stryker disable next-line StringLiteral: tool parameter documentation
|
|
43467
43443
|
group: external_exports.string().optional().describe("existing device user-group path from the project root, e.g. Area/Line; omitted: project level (app 1.8.1+)"),
|
|
43468
43444
|
...dryRunField
|
|
43469
43445
|
}
|
|
@@ -43715,10 +43691,7 @@ function registerAuthoringTools(server) {
|
|
|
43715
43691
|
"tia_tag_create",
|
|
43716
43692
|
{
|
|
43717
43693
|
title: "TIA \u2014 create tag",
|
|
43718
|
-
description: (
|
|
43719
|
-
// Stryker disable next-line StringLiteral: refusal guidance prose; validation behavior is covered by PlcValidationTests
|
|
43720
|
-
"App 1.8+ serve returns 400 bad_request (details.field, rule) for quote-bearing names or malformed/type-mismatched/out-of-range absolute addresses. Creates a tag in a table. Refused with 409 name_collision (details.collidesWith = the colliding tag, constant or block) when the name matches, ignoring case, any tag, constant or block of the PLC. The result carries `overlaps`: the OTHER tags whose logical address overlaps this one (informational, never a refusal). Maps to POST /plcs/{plc}/tags. M-off."
|
|
43721
|
-
),
|
|
43694
|
+
description: "App 1.8+ serve returns 400 bad_request (details.field, rule) for quote-bearing names or malformed/type-mismatched/out-of-range absolute addresses. Creates a tag in a table. Refused with 409 name_collision (details.collidesWith = the colliding tag, constant or block) when the name matches, ignoring case, any tag, constant or block of the PLC. The result carries `overlaps`: the OTHER tags whose logical address overlaps this one (informational, never a refusal). Maps to POST /plcs/{plc}/tags. M-off.",
|
|
43722
43695
|
inputSchema: {
|
|
43723
43696
|
plc: external_exports.string().describe("PLC software name from tia_plcs.name, not the device station name"),
|
|
43724
43697
|
table: external_exports.string().optional().describe("tag table (default: the standard one)"),
|
|
@@ -43748,10 +43721,7 @@ function registerAuthoringTools(server) {
|
|
|
43748
43721
|
"tia_tag_update",
|
|
43749
43722
|
{
|
|
43750
43723
|
title: "TIA \u2014 update tag",
|
|
43751
|
-
description: (
|
|
43752
|
-
// Stryker disable next-line StringLiteral: refusal guidance prose; validation behavior is covered by PlcValidationTests
|
|
43753
|
-
"App 1.8+ serve returns 400 bad_request (details.field, rule) for quote-bearing names or malformed/type-mismatched/out-of-range absolute addresses, including previews. Updates ONE tag: rename, data type, logical address and the external accessible/visible/writable flags. Only the fields you pass change, and only those that differ from the current value are written (none passed: 400 missing_param; all unchanged: 200 with changes:[]). A rename is refused with 409 name_collision (details.collidesWith = the colliding tag, constant or block) when the new name matches, ignoring case, another tag, constant or block of the PLC; an unknown table or tag is 404 not_found. The result carries `changes` [{field,from,to}] and `overlaps`: the OTHER tags whose address overlaps the final one (informational, never a refusal). dryRun (Gd11) is answered by the serve (needs an open project): it runs the same guards and returns that plan WITHOUT changing anything. Maps to POST /plcs/{plc}/tagtables/{table}/tags/{tag}. M-off."
|
|
43754
|
-
),
|
|
43724
|
+
description: "App 1.8+ serve returns 400 bad_request (details.field, rule) for quote-bearing names or malformed/type-mismatched/out-of-range absolute addresses, including previews. Updates ONE tag: rename, data type, logical address and the external accessible/visible/writable flags. Only the fields you pass change, and only those that differ from the current value are written (none passed: 400 missing_param; all unchanged: 200 with changes:[]). A rename is refused with 409 name_collision (details.collidesWith = the colliding tag, constant or block) when the new name matches, ignoring case, another tag, constant or block of the PLC; an unknown table or tag is 404 not_found. The result carries `changes` [{field,from,to}] and `overlaps`: the OTHER tags whose address overlaps the final one (informational, never a refusal). dryRun (Gd11) is answered by the serve (needs an open project): it runs the same guards and returns that plan WITHOUT changing anything. Maps to POST /plcs/{plc}/tagtables/{table}/tags/{tag}. M-off.",
|
|
43755
43725
|
inputSchema: {
|
|
43756
43726
|
plc: external_exports.string().describe("PLC software name from tia_plcs.name, not the device station name"),
|
|
43757
43727
|
table: external_exports.string().describe("tag table that holds the tag"),
|
|
@@ -43776,10 +43746,7 @@ function registerAuthoringTools(server) {
|
|
|
43776
43746
|
"tia_constant_create",
|
|
43777
43747
|
{
|
|
43778
43748
|
title: "TIA \u2014 create constant",
|
|
43779
|
-
description: (
|
|
43780
|
-
// Stryker disable next-line StringLiteral: refusal guidance prose; validation behavior is covered by PlcValidationTests
|
|
43781
|
-
"App 1.8+ serve returns 400 bad_request (details.field, rule) for quote-bearing names or invalid decimal integer literals; typed/radix literals pass through. Creates a user constant in a tag table. Refused with 409 name_collision (details.collidesWith = the colliding tag, constant or block) when the name matches, ignoring case, any tag, constant or block of the PLC. Maps to POST /plcs/{plc}/constants. M-off."
|
|
43782
|
-
),
|
|
43749
|
+
description: "App 1.8+ serve returns 400 bad_request (details.field, rule) for quote-bearing names or invalid decimal integer literals; typed/radix literals pass through. Creates a user constant in a tag table. Refused with 409 name_collision (details.collidesWith = the colliding tag, constant or block) when the name matches, ignoring case, any tag, constant or block of the PLC. Maps to POST /plcs/{plc}/constants. M-off.",
|
|
43783
43750
|
inputSchema: {
|
|
43784
43751
|
plc: external_exports.string().describe("PLC software name from tia_plcs.name, not the device station name"),
|
|
43785
43752
|
table: external_exports.string().optional().describe("tag table (default: the standard one)"),
|
|
@@ -43795,10 +43762,7 @@ function registerAuthoringTools(server) {
|
|
|
43795
43762
|
"tia_constant_update",
|
|
43796
43763
|
{
|
|
43797
43764
|
title: "TIA \u2014 update constant",
|
|
43798
|
-
description: (
|
|
43799
|
-
// Stryker disable next-line StringLiteral: refusal guidance prose; validation behavior is covered by PlcValidationTests
|
|
43800
|
-
"App 1.8+ serve returns 400 bad_request (details.field, rule) for quote-bearing names or invalid decimal integer literals, including previews; typed/radix literals pass through. Updates ONE user constant: rename, data type and value. Only the fields you pass change, and only those that differ from the current value are written (none passed: 400 missing_param; all unchanged: 200 with changes:[]). A rename is refused with 409 name_collision (details.collidesWith = the colliding tag, constant or block) when the new name matches, ignoring case, another tag, constant or block of the PLC; an unknown table or constant is 404 not_found. dryRun (Gd11) is answered by the serve (needs an open project): it runs the same guards and returns the plan {changes:[{field,from,to}]} WITHOUT changing anything. Maps to POST /plcs/{plc}/tagtables/{table}/constants/{constant}. M-off."
|
|
43801
|
-
),
|
|
43765
|
+
description: "App 1.8+ serve returns 400 bad_request (details.field, rule) for quote-bearing names or invalid decimal integer literals, including previews; typed/radix literals pass through. Updates ONE user constant: rename, data type and value. Only the fields you pass change, and only those that differ from the current value are written (none passed: 400 missing_param; all unchanged: 200 with changes:[]). A rename is refused with 409 name_collision (details.collidesWith = the colliding tag, constant or block) when the new name matches, ignoring case, another tag, constant or block of the PLC; an unknown table or constant is 404 not_found. dryRun (Gd11) is answered by the serve (needs an open project): it runs the same guards and returns the plan {changes:[{field,from,to}]} WITHOUT changing anything. Maps to POST /plcs/{plc}/tagtables/{table}/constants/{constant}. M-off.",
|
|
43802
43766
|
inputSchema: {
|
|
43803
43767
|
plc: external_exports.string().describe("PLC software name from tia_plcs.name, not the device station name"),
|
|
43804
43768
|
table: external_exports.string().describe("tag table that holds the constant"),
|
|
@@ -43989,10 +43953,7 @@ function registerAuthoringTools(server) {
|
|
|
43989
43953
|
"tia_types_import",
|
|
43990
43954
|
{
|
|
43991
43955
|
title: "TIA \u2014 import type/UDT (SimaticML XML)",
|
|
43992
|
-
description: (
|
|
43993
|
-
// Stryker disable next-line StringLiteral: target-local UDT authoring guidance, not import validation
|
|
43994
|
-
"Imports a UDT in SimaticML XML. Use a real export for the selected target; cross-version import compatibility is unverified, and V21 import behavior is unchanged (no new version preflight refusal). See tia_guide recipes, 'TIA version evidence and SimaticML'. Import UDTs BEFORE the blocks that use them (Gd6). Stale-write guard: pass the type's `contentHash` from tia_export_type (or tia_type_source) as `expectedContentHash` and the serve checks it against the type's current export BEFORE importing \u2014 a mismatch is 409 state_changed and NOTHING is imported; a match adds `contentGuard` to the result. " + HASH_CONTRACT_NOTE + " It guards exactly ONE type: the XML (or the file at `path`) must contain exactly one type (else 400 bad_request), and a hash for a type that does not exist (any more) is refused as state_changed \u2014 omit it to create; an existing type whose current export is not well-formed XML cannot be hashed and is refused with 409 unverifiable (NOTHING is imported; repair it, or omit expectedContentHash to write without the guard). " + SOURCE_IMPACT_NOTE + `Needs an app with the guard: an older serve ignores the field and the result says the import was NOT guarded. dryRun never verifies it. Maps to POST /plcs/{plc}/types/import. M-off. ${LONG_OPERATION_NOTE}`
|
|
43995
|
-
),
|
|
43956
|
+
description: "Imports a UDT in SimaticML XML. Use a real export for the selected target; cross-version import compatibility is unverified, and V21 import behavior is unchanged (no new version preflight refusal). See tia_guide recipes, 'TIA version evidence and SimaticML'. Import UDTs BEFORE the blocks that use them (Gd6). Stale-write guard: pass the type's `contentHash` from tia_export_type (or tia_type_source) as `expectedContentHash` and the serve checks it against the type's current export BEFORE importing \u2014 a mismatch is 409 state_changed and NOTHING is imported; a match adds `contentGuard` to the result. " + HASH_CONTRACT_NOTE + " It guards exactly ONE type: the XML (or the file at `path`) must contain exactly one type (else 400 bad_request), and a hash for a type that does not exist (any more) is refused as state_changed \u2014 omit it to create; an existing type whose current export is not well-formed XML cannot be hashed and is refused with 409 unverifiable (NOTHING is imported; repair it, or omit expectedContentHash to write without the guard). " + SOURCE_IMPACT_NOTE + `Needs an app with the guard: an older serve ignores the field and the result says the import was NOT guarded. dryRun never verifies it. Maps to POST /plcs/{plc}/types/import. M-off. ${LONG_OPERATION_NOTE}`,
|
|
43996
43957
|
inputSchema: {
|
|
43997
43958
|
plc: external_exports.string().describe("PLC software name from tia_plcs.name, not the device station name"),
|
|
43998
43959
|
xml: external_exports.string().optional().describe("SimaticML XML content of the UDT (alternative to path)"),
|
|
@@ -44141,12 +44102,8 @@ function registerAssetTools(server) {
|
|
|
44141
44102
|
"tia_device_from_mastercopy",
|
|
44142
44103
|
{
|
|
44143
44104
|
title: "TIA \u2014 station from a prepared master copy",
|
|
44144
|
-
description: (
|
|
44145
|
-
// Stryker disable next-line StringLiteral: handoff prose, not an executable contract
|
|
44146
|
-
`Requires app \u2265 v1.8.0. Creates a new station from a device master copy in the open project's library (name from tia_library_mastercopies), returning {device: actualName}; TIA may rename the copy and its PLC. Known block-only content is refused with 409 mastercopy_not_device; unknown content goes to Openness. Clones an owner-prepared configuration, including PUT/GET, purchased-license selection and OPC UA interface mappings on the validated 1214C V4.4; it is not a setter for an existing CPU and does not grant license entitlement. Certificates are not copied: inspect the new OPC UA item, regenerate its server certificate if needed and compile before any human-gated download. Maps to POST /devices/frommastercopy {masterCopy}. Class M-off. ${LONG_OPERATION_NOTE}`
|
|
44147
|
-
),
|
|
44105
|
+
description: `Requires app \u2265 v1.8.0. Creates a new station from a device master copy in the open project's library (name from tia_library_mastercopies), returning {device: actualName}; TIA may rename the copy and its PLC. Known block-only content is refused with 409 mastercopy_not_device; unknown content goes to Openness. Clones an owner-prepared configuration, including PUT/GET, purchased-license selection and OPC UA interface mappings on the validated 1214C V4.4; it is not a setter for an existing CPU and does not grant license entitlement. Certificates are not copied: inspect the new OPC UA item, regenerate its server certificate if needed and compile before any human-gated download. Maps to POST /devices/frommastercopy {masterCopy}. Class M-off. ${LONG_OPERATION_NOTE}`,
|
|
44148
44106
|
inputSchema: {
|
|
44149
|
-
// Stryker disable next-line StringLiteral: schema description prose; validation stays in mutation scope
|
|
44150
44107
|
masterCopy: external_exports.string().min(1).describe("owner-prepared device master copy in the project library"),
|
|
44151
44108
|
...dryRunField
|
|
44152
44109
|
}
|
|
@@ -45291,7 +45248,6 @@ var PlanStore = class {
|
|
|
45291
45248
|
return entry;
|
|
45292
45249
|
}
|
|
45293
45250
|
check(token, plan) {
|
|
45294
|
-
if (!token) return { ok: false, reason: "unknown" };
|
|
45295
45251
|
if (this.consumed.has(token)) return { ok: false, reason: "consumed" };
|
|
45296
45252
|
const entry = this.issued.get(token);
|
|
45297
45253
|
if (!entry) return { ok: false, reason: "unknown" };
|
|
@@ -45405,8 +45361,8 @@ async function planDownload(args, plan, store) {
|
|
|
45405
45361
|
)
|
|
45406
45362
|
);
|
|
45407
45363
|
}
|
|
45408
|
-
const
|
|
45409
|
-
const issued = store.issue(plan, fingerprint,
|
|
45364
|
+
const issuedToken = typeof data.approvalToken === "string" ? data.approvalToken.trim() : "";
|
|
45365
|
+
const issued = store.issue(plan, fingerprint, issuedToken);
|
|
45410
45366
|
return markControl(
|
|
45411
45367
|
textResult(
|
|
45412
45368
|
{
|
|
@@ -45600,7 +45556,7 @@ function uploadBodyFromApprovedPlan(issued, password) {
|
|
|
45600
45556
|
ip: plan.ip
|
|
45601
45557
|
}),
|
|
45602
45558
|
expectedProjectPath: issued.fingerprint,
|
|
45603
|
-
|
|
45559
|
+
password
|
|
45604
45560
|
};
|
|
45605
45561
|
}
|
|
45606
45562
|
function modesToProbe(args, data, blockers) {
|
|
@@ -45749,7 +45705,7 @@ async function planUpload(args, plan, store) {
|
|
|
45749
45705
|
devices,
|
|
45750
45706
|
connection: data.connection ?? null,
|
|
45751
45707
|
...auditWarningOf(raw),
|
|
45752
|
-
|
|
45708
|
+
warning
|
|
45753
45709
|
}
|
|
45754
45710
|
});
|
|
45755
45711
|
}
|
|
@@ -45870,6 +45826,7 @@ async function uploadFlow(args, store = uploadPlanStore) {
|
|
|
45870
45826
|
uploadedStation: typeof data.uploadedStation === "string" ? data.uploadedStation : null,
|
|
45871
45827
|
createdDevices,
|
|
45872
45828
|
configurations: data.configurations ?? null,
|
|
45829
|
+
// Stryker disable next-line StringLiteral: the separator between warning texts is wording, each text is tested
|
|
45873
45830
|
...warnings.length > 0 ? { warning: warnings.join(" ") } : {},
|
|
45874
45831
|
...auditWarningOf(raw),
|
|
45875
45832
|
nextSteps: [
|
|
@@ -46507,7 +46464,7 @@ function buildServer(mode, version2, budget = resolveBudget()) {
|
|
|
46507
46464
|
}
|
|
46508
46465
|
|
|
46509
46466
|
// src/index.ts
|
|
46510
|
-
var VERSION = "1.13.
|
|
46467
|
+
var VERSION = "1.13.2";
|
|
46511
46468
|
async function main() {
|
|
46512
46469
|
if (process.argv.slice(2).some((a) => a === "--version" || a === "-v")) {
|
|
46513
46470
|
console.log(VERSION);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@renanlido/tia-openness-mcp",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.2",
|
|
4
4
|
"description": "MCP server (stdio) — thin HTTP client over the TIA Openness `serve` API. Zero Openness/net48 references.",
|
|
5
5
|
"mcpName": "io.github.renanlido/tia-openness",
|
|
6
6
|
"keywords": [
|