@renanlido/tia-openness-mcp 1.6.0 → 1.7.0
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 +34 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -32086,7 +32086,7 @@ function registerJobTools(server2) {
|
|
|
32086
32086
|
"tia_job_status",
|
|
32087
32087
|
{
|
|
32088
32088
|
title: "TIA \u2014 long-operation status",
|
|
32089
|
-
description: 'Waits (up to waitSeconds, default 20, max 25) for a background job started by a long tool that answered status:"running" (tia_connect, tia_start, tia_show_ui, tia_project_create/save/close/archive, tia_compile, tia_download, tia_upload, tia_export_xml, tia_export_block, tia_block_compare, tia_spec_apply) and returns its FINAL result with job:{id,tool,state,durationMs} \u2014 including a gate handoff if the operation ended in one. While a job runs, every other serve-bound tool answers kind:"busy" (with details.jobId): call this instead of polling tia_status, and never repeat the original call. If a tia_connect/tia_start/tia_show_ui job stays running for minutes, a trust dialog (GATE G1) may be waiting on the serve host \u2014 ask a human to look. Does not call serve. Class R.',
|
|
32089
|
+
description: 'Waits (up to waitSeconds, default 20, max 25) for a background job started by a long tool that answered status:"running" (tia_connect, tia_start, tia_show_ui, tia_project_create/save/saveas/close/archive, tia_compile, tia_source_put, tia_download, tia_upload, tia_export_xml, tia_export_block, tia_block_compare, tia_spec_apply) and returns its FINAL result with job:{id,tool,state,durationMs} \u2014 including a gate handoff if the operation ended in one. While a job runs, every other serve-bound tool answers kind:"busy" (with details.jobId): call this instead of polling tia_status, and never repeat the original call. If a tia_connect/tia_start/tia_show_ui job stays running for minutes, a trust dialog (GATE G1) may be waiting on the serve host \u2014 ask a human to look. Does not call serve. Class R.',
|
|
32090
32090
|
inputSchema: {
|
|
32091
32091
|
jobId: external_exports.string().describe("jobId returned by the long tool (or by a busy error's details.jobId)"),
|
|
32092
32092
|
waitSeconds: external_exports.number().int().min(0).max(25).optional().describe("how long this call may wait (default 20, max 25)")
|
|
@@ -32300,12 +32300,12 @@ function registerLifecycleTools(server2) {
|
|
|
32300
32300
|
"tia_project_saveas",
|
|
32301
32301
|
{
|
|
32302
32302
|
title: "TIA \u2014 save project as",
|
|
32303
|
-
description:
|
|
32303
|
+
description: `Saves the open project to another directory. Maps to POST /project/saveas. ${LONG_OPERATION_NOTE}`,
|
|
32304
32304
|
inputSchema: {
|
|
32305
32305
|
directory: external_exports.string().optional().describe("target directory for 'save as'")
|
|
32306
32306
|
}
|
|
32307
32307
|
},
|
|
32308
|
-
async ({ directory }) => postResult2("/project/saveas", jsonBody({ directory }))
|
|
32308
|
+
async ({ directory }) => jobs.run("tia_project_saveas", { directory }, () => postResult2("/project/saveas", jsonBody({ directory })))
|
|
32309
32309
|
);
|
|
32310
32310
|
server2.registerTool(
|
|
32311
32311
|
"tia_project_close",
|
|
@@ -32902,7 +32902,7 @@ function registerAuthoringTools(server2) {
|
|
|
32902
32902
|
"tia_source_put",
|
|
32903
32903
|
{
|
|
32904
32904
|
title: "TIA \u2014 write/compile SCL source",
|
|
32905
|
-
description:
|
|
32905
|
+
description: `Writes a block from textual SCL source and (optionally) compiles it. Gd6: use THIS for TEXTUAL language (SCL/STL); for graphical (LAD/FBD/GRAPH) use tia_import_xml. With compile:true, the raw compile DTO is nested under 'compile' (same as tia_compile's response), and 'located[]' plus a nextHint are merged at the TOP LEVEL of the result \u2014 same place tia_compile puts them \u2014 when the compile regenerated blocks, e.g. an instance DB after an FB interface change. \`generatedOrUpdated\` lists every block the source created or regenerated (app \u2265 v1.6.0; older serves list only new ones) \u2014 TIA regenerates a block even when the text is identical, so it then needs a compile \u2014 and \`sourceChanges\` gives the per-block change and parts. Maps to POST /plcs/{plc}/source. M-off. ${LONG_OPERATION_NOTE}`,
|
|
32906
32906
|
inputSchema: {
|
|
32907
32907
|
plc: external_exports.string().describe("PLC name"),
|
|
32908
32908
|
name: external_exports.string().describe("block/source name"),
|
|
@@ -32911,7 +32911,8 @@ function registerAuthoringTools(server2) {
|
|
|
32911
32911
|
...dryRunField
|
|
32912
32912
|
}
|
|
32913
32913
|
},
|
|
32914
|
-
|
|
32914
|
+
// dryRun is pure (never calls serve) and stays outside the runner, like tia_spec_apply.
|
|
32915
|
+
async ({ plc, name, code, compile, dryRun }) => dryRun ? sourcePutFlow({ plc, name, code, compile, dryRun }) : jobs.run("tia_source_put", { plc, name, code, compile }, () => sourcePutFlow({ plc, name, code, compile }))
|
|
32915
32916
|
);
|
|
32916
32917
|
server2.registerTool(
|
|
32917
32918
|
"tia_import_xml",
|
|
@@ -33128,7 +33129,7 @@ var PlanStore = class {
|
|
|
33128
33129
|
prefix;
|
|
33129
33130
|
issued = /* @__PURE__ */ new Map();
|
|
33130
33131
|
consumed = /* @__PURE__ */ new Set();
|
|
33131
|
-
issue(plan, fingerprint) {
|
|
33132
|
+
issue(plan, fingerprint, serveToken) {
|
|
33132
33133
|
if (!fingerprint) throw new Error("planStore.issue: fingerprint is required");
|
|
33133
33134
|
canonicalPlan(plan);
|
|
33134
33135
|
const t = this.now();
|
|
@@ -33137,7 +33138,8 @@ var PlanStore = class {
|
|
|
33137
33138
|
plan: { ...plan },
|
|
33138
33139
|
fingerprint,
|
|
33139
33140
|
issuedAt: t,
|
|
33140
|
-
expiresAt: t + this.ttlMs
|
|
33141
|
+
expiresAt: t + this.ttlMs,
|
|
33142
|
+
...serveToken ? { serveToken } : {}
|
|
33141
33143
|
};
|
|
33142
33144
|
this.issued.set(entry.token, entry);
|
|
33143
33145
|
return entry;
|
|
@@ -33319,6 +33321,8 @@ function bodyFromApprovedPlan(issued) {
|
|
|
33319
33321
|
software: plan.software
|
|
33320
33322
|
}),
|
|
33321
33323
|
expectedFingerprint: issued.fingerprint,
|
|
33324
|
+
// G3 on the serve: the token the serve issued with the plan (single use, bound to this exact request).
|
|
33325
|
+
...issued.serveToken ? { approvalToken: issued.serveToken } : {},
|
|
33322
33326
|
allowUpgradeTargetDevice: plan.allowUpgradeTargetDevice === true
|
|
33323
33327
|
};
|
|
33324
33328
|
}
|
|
@@ -33327,7 +33331,17 @@ async function planDownload(args, plan, store) {
|
|
|
33327
33331
|
try {
|
|
33328
33332
|
raw = await tiaFetch(
|
|
33329
33333
|
`/plcs/${seg(args.plc)}/download/plan`,
|
|
33330
|
-
|
|
33334
|
+
// The serve binds its approval token to the WHOLE request, so the plan carries the same flags as the approved plan.
|
|
33335
|
+
{
|
|
33336
|
+
method: "POST",
|
|
33337
|
+
headers: JSON_HEADERS,
|
|
33338
|
+
body: JSON.stringify({
|
|
33339
|
+
...connectionBody(args),
|
|
33340
|
+
hardware: plan.hardware,
|
|
33341
|
+
software: plan.software,
|
|
33342
|
+
allowUpgradeTargetDevice: plan.allowUpgradeTargetDevice
|
|
33343
|
+
})
|
|
33344
|
+
},
|
|
33331
33345
|
{ timeoutMs: SLOW_TIMEOUT_MS }
|
|
33332
33346
|
);
|
|
33333
33347
|
} catch (e) {
|
|
@@ -33360,12 +33374,14 @@ async function planDownload(args, plan, store) {
|
|
|
33360
33374
|
blockers,
|
|
33361
33375
|
compile,
|
|
33362
33376
|
connection: data.connection ?? null,
|
|
33377
|
+
target: data.target ?? null,
|
|
33363
33378
|
note: fingerprintMissing ? "NO approval token was issued: serve reported ready but returned no software fingerprint, and this MCP never approves a download it cannot verify. Update the TIAOpenness app (serve) to v1.6.0 or later and run dryRun again." : "NO approval token was issued. Fix the blockers (compile errors \u2192 tia_compile; interface \u2192 tia_pg_interfaces) and run dryRun again."
|
|
33364
33379
|
},
|
|
33365
33380
|
false
|
|
33366
33381
|
);
|
|
33367
33382
|
}
|
|
33368
|
-
const
|
|
33383
|
+
const serveToken = typeof data.approvalToken === "string" && data.approvalToken.trim() ? data.approvalToken.trim() : void 0;
|
|
33384
|
+
const issued = store.issue(plan, fingerprint, serveToken);
|
|
33369
33385
|
return textResult(
|
|
33370
33386
|
{
|
|
33371
33387
|
dryRun: true,
|
|
@@ -33380,6 +33396,7 @@ async function planDownload(args, plan, store) {
|
|
|
33380
33396
|
warnings: data.warnings ?? [],
|
|
33381
33397
|
compile,
|
|
33382
33398
|
connection: data.connection ?? null,
|
|
33399
|
+
target: data.target ?? null,
|
|
33383
33400
|
loadPreview: {
|
|
33384
33401
|
// Amendment #4: mirrors EVERY real auto-confirmation of PlcDeployService.cs (PreDownload/PostDownload),
|
|
33385
33402
|
// not just the 3 most obvious — including ones that don't stop/restart the CPU but still change its content.
|
|
@@ -33395,7 +33412,7 @@ async function planDownload(args, plan, store) {
|
|
|
33395
33412
|
],
|
|
33396
33413
|
note: "Openness has no preview-without-downloading; these are the selections serve's delegates will make. The real download returns 'configurations' with what was actually confirmed."
|
|
33397
33414
|
},
|
|
33398
|
-
note: "Plan verified by serve. NOTHING was downloaded. After a human approves THIS plan and
|
|
33415
|
+
note: "Plan verified by serve. NOTHING was downloaded. After a human approves THIS plan, fingerprint and target (project + CPU address), call tia_download with approved:true and this planHash (single-use, expires at expiresAt)."
|
|
33399
33416
|
},
|
|
33400
33417
|
false
|
|
33401
33418
|
);
|
|
@@ -33421,6 +33438,11 @@ async function downloadFlow(args, store = planStore) {
|
|
|
33421
33438
|
err,
|
|
33422
33439
|
"Serve is installing a TIAOpenness app update: nothing was downloaded (the call was refused BEFORE running, so no CPU check is needed). The single-use approval token is already spent \u2014 after the update finishes, run a fresh dryRun plan and get a new human approval. There is no background job for this call."
|
|
33423
33440
|
);
|
|
33441
|
+
if (err.status === 403 && (err.kind === "approval_required" || err.kind === "approval_invalid"))
|
|
33442
|
+
return errorResult(
|
|
33443
|
+
err,
|
|
33444
|
+
"Serve refused the download BEFORE running (its approval token was missing, expired, already used or for another request): nothing was downloaded and the CPU was not touched. Run a fresh dryRun plan and get a new human approval."
|
|
33445
|
+
);
|
|
33424
33446
|
const knownRefusal = err.status === 409 && (err.kind === "plan_stale" || err.kind === "upgrade_target_device_required");
|
|
33425
33447
|
if (knownRefusal) return errorResult(err);
|
|
33426
33448
|
const isTransport = err.kind === "timeout" || err.kind === "connection_refused";
|
|
@@ -33478,7 +33500,7 @@ function registerDownloadTools(server2) {
|
|
|
33478
33500
|
"tia_download",
|
|
33479
33501
|
{
|
|
33480
33502
|
title: "TIA \u2014 download to the PLC (GATE G3)",
|
|
33481
|
-
description: "Downloads hardware/software to the PHYSICAL CPU (STOPS and RESTARTS the CPU). GATE G3: does NOT download without human approval. dryRun:true asks serve for a VERIFIED plan (clean compile, PG/PC interface found, software fingerprint) and returns a single-use planHash that expires (TIA_PLAN_TTL_MS, default 15 min). After a human approves that plan, call with approved:true and the SAME planHash; serve re-checks the fingerprint inside the download and refuses (plan_stale) if the project changed. Pick connectionMode/pcInterfaceName/targetInterfaceName with tia_pg_interfaces (no scan). Requires app \u2265 v1.6.0. Maps to POST /plcs/{plc}/download/plan and POST /plcs/{plc}/download. " + LONG_OPERATION_NOTE,
|
|
33503
|
+
description: "Downloads hardware/software to the PHYSICAL CPU (STOPS and RESTARTS the CPU). GATE G3: does NOT download without human approval. dryRun:true asks serve for a VERIFIED plan (clean compile, PG/PC interface found, software fingerprint) and returns a single-use planHash that expires (TIA_PLAN_TTL_MS, default 15 min). After a human approves that plan, call with approved:true and the SAME planHash; serve re-checks the fingerprint inside the download and refuses (plan_stale) if the project changed. Pick connectionMode/pcInterfaceName/targetInterfaceName with tia_pg_interfaces (no scan). The serve also issues its own single-use approval token with the plan; this MCP keeps it and sends it with the download (a newer serve refuses any download without it \u2014 keep this MCP up to date). Requires app \u2265 v1.6.0. Maps to POST /plcs/{plc}/download/plan and POST /plcs/{plc}/download. " + LONG_OPERATION_NOTE,
|
|
33482
33504
|
inputSchema: {
|
|
33483
33505
|
plc: external_exports.string().describe("PLC name"),
|
|
33484
33506
|
connectionMode: external_exports.string().optional().describe(`connection mode (e.g., "PN/IE") \u2014 TIA's LOCALIZED name`),
|
|
@@ -34184,7 +34206,7 @@ function registerGuideTool(server2) {
|
|
|
34184
34206
|
|
|
34185
34207
|
// src/index.ts
|
|
34186
34208
|
var server = new McpServer(
|
|
34187
|
-
{ name: "tia-openness", version: "1.
|
|
34209
|
+
{ name: "tia-openness", version: "1.7.0" },
|
|
34188
34210
|
// Camada 1 (ambiente): o brief operacional viaja no handshake MCP — qualquer cliente
|
|
34189
34211
|
// que honre `instructions` recebe gates/serial-only/pipeline sem instalar nada.
|
|
34190
34212
|
{ instructions: BRIEF }
|
package/package.json
CHANGED