@renanlido/tia-openness-mcp 1.10.5 → 1.10.6
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 +77 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -38895,6 +38895,78 @@ function uploadBodyFromApprovedPlan(issued, password) {
|
|
|
38895
38895
|
...password !== void 0 ? { password } : {}
|
|
38896
38896
|
};
|
|
38897
38897
|
}
|
|
38898
|
+
function modesToProbe(args, data, blockers) {
|
|
38899
|
+
if (args.connectionMode !== void 0 && args.connectionMode.trim().length > 0) return [];
|
|
38900
|
+
if (blockers.length === 0 || !blockers.every((b) => b === "connection_unresolved")) return [];
|
|
38901
|
+
if (!isObject2(data.connection)) return [];
|
|
38902
|
+
const mode = data.connection.mode;
|
|
38903
|
+
const pcInterface = data.connection.pcInterface;
|
|
38904
|
+
if (!isObject2(mode) || !isObject2(pcInterface)) return [];
|
|
38905
|
+
if (typeof mode.requested === "string" && mode.requested.trim().length > 0) return [];
|
|
38906
|
+
if (!Array.isArray(pcInterface.available) || pcInterface.available.length > 0) return [];
|
|
38907
|
+
if (!Array.isArray(mode.available)) return [];
|
|
38908
|
+
const modes = [];
|
|
38909
|
+
for (const m of mode.available) {
|
|
38910
|
+
if (modes.length === 8) break;
|
|
38911
|
+
if (typeof m === "string" && m.trim().length > 0 && !modes.includes(m)) modes.push(m);
|
|
38912
|
+
}
|
|
38913
|
+
return modes;
|
|
38914
|
+
}
|
|
38915
|
+
function parsePcInterfaces(connectionMode, available) {
|
|
38916
|
+
if (!Array.isArray(available)) return [];
|
|
38917
|
+
const out = [];
|
|
38918
|
+
for (const entry of available) {
|
|
38919
|
+
if (typeof entry !== "string") continue;
|
|
38920
|
+
const match = /([\s\S]+) \((\d+)\)$/.exec(entry);
|
|
38921
|
+
if (match === null || match[1].trim().length === 0) continue;
|
|
38922
|
+
const pcInterfaceNumber = Number(match[2]);
|
|
38923
|
+
if (!Number.isSafeInteger(pcInterfaceNumber)) continue;
|
|
38924
|
+
out.push({ connectionMode, pcInterfaceName: match[1], pcInterfaceNumber });
|
|
38925
|
+
}
|
|
38926
|
+
return out;
|
|
38927
|
+
}
|
|
38928
|
+
function stopsProbing(e) {
|
|
38929
|
+
const kind = asTiaError(e).kind;
|
|
38930
|
+
return ["timeout", "connection_refused", "busy", "installing", "audit_unavailable"].some((k) => k === kind);
|
|
38931
|
+
}
|
|
38932
|
+
function probeInterfaces(raw) {
|
|
38933
|
+
if (!isObject2(raw) || !isObject2(raw.connection) || !isObject2(raw.connection.pcInterface)) return null;
|
|
38934
|
+
return raw.connection.pcInterface.available;
|
|
38935
|
+
}
|
|
38936
|
+
async function probeConnectionCandidates(ip, modes) {
|
|
38937
|
+
const candidates = [];
|
|
38938
|
+
for (const connectionMode of modes) {
|
|
38939
|
+
let raw = null;
|
|
38940
|
+
try {
|
|
38941
|
+
raw = await tiaFetch(
|
|
38942
|
+
"/stations/upload/plan",
|
|
38943
|
+
{ method: "POST", headers: JSON_HEADERS, body: JSON.stringify({ connectionMode, ip }) },
|
|
38944
|
+
{ timeoutMs: SLOW_TIMEOUT_MS }
|
|
38945
|
+
);
|
|
38946
|
+
} catch (e) {
|
|
38947
|
+
if (stopsProbing(e)) break;
|
|
38948
|
+
}
|
|
38949
|
+
for (const c of parsePcInterfaces(connectionMode, probeInterfaces(raw))) {
|
|
38950
|
+
if (candidates.length === 32) return candidates;
|
|
38951
|
+
const known = candidates.some(
|
|
38952
|
+
(k) => k.connectionMode === c.connectionMode && k.pcInterfaceName === c.pcInterfaceName && k.pcInterfaceNumber === c.pcInterfaceNumber
|
|
38953
|
+
);
|
|
38954
|
+
if (!known) candidates.push(c);
|
|
38955
|
+
}
|
|
38956
|
+
}
|
|
38957
|
+
return candidates;
|
|
38958
|
+
}
|
|
38959
|
+
function candidateFields(candidates) {
|
|
38960
|
+
if (candidates.length === 0) return {};
|
|
38961
|
+
return {
|
|
38962
|
+
connectionCandidates: candidates,
|
|
38963
|
+
nextSteps: [
|
|
38964
|
+
"1. No connectionMode was given, so this plan resolved no PG/PC interface; serve lists these candidates for each available mode (connectionCandidates). This is not a sign that the host has no adapter.",
|
|
38965
|
+
"2. Pick ONE candidate (ask the human when several could reach the CPU) and call tia_upload again WITHOUT confirm, with that candidate's exact connectionMode, pcInterfaceName and pcInterfaceNumber.",
|
|
38966
|
+
"3. Relay the GATE G4 handoff that plan returns to the human and wait for an explicit yes before confirm:true. No candidate was chosen, approved or uploaded here."
|
|
38967
|
+
]
|
|
38968
|
+
};
|
|
38969
|
+
}
|
|
38898
38970
|
async function planUpload(args, plan, store) {
|
|
38899
38971
|
let raw;
|
|
38900
38972
|
try {
|
|
@@ -38936,6 +39008,7 @@ async function planUpload(args, plan, store) {
|
|
|
38936
39008
|
const blockers = Array.isArray(data.blockers) ? [...data.blockers] : [];
|
|
38937
39009
|
if (!isObject2(raw)) blockers.push("invalid_plan_response");
|
|
38938
39010
|
if (data.ready === true) blockers.push("project_path_missing");
|
|
39011
|
+
const candidates = await probeConnectionCandidates(args.ip, modesToProbe(args, data, blockers));
|
|
38939
39012
|
return markControl(
|
|
38940
39013
|
textResult(
|
|
38941
39014
|
{
|
|
@@ -38947,7 +39020,8 @@ async function planUpload(args, plan, store) {
|
|
|
38947
39020
|
project: data.project ?? null,
|
|
38948
39021
|
devices,
|
|
38949
39022
|
note: typeof data.note === "string" ? data.note : null,
|
|
38950
|
-
...auditWarningOf(raw)
|
|
39023
|
+
...auditWarningOf(raw),
|
|
39024
|
+
...candidateFields(candidates)
|
|
38951
39025
|
},
|
|
38952
39026
|
false
|
|
38953
39027
|
)
|
|
@@ -39110,7 +39184,7 @@ function registerUploadTools(server) {
|
|
|
39110
39184
|
"tia_upload",
|
|
39111
39185
|
{
|
|
39112
39186
|
title: "TIA \u2014 station upload (GATE G4)",
|
|
39113
|
-
description: "Station upload (GATE G4): goes ONLINE to the PHYSICAL CPU at `ip` and reads its hardware configuration and program into the OPEN project as a new station \u2014 it reads the CPU and does not write or stop it (observed on hardware: the CPU stayed in RUN). Back up into a dedicated EMPTY project, never the working project (skill tia-backup). Without confirm it asks serve for an upload plan (PG/PC interface resolved, the open project's path and devices \u2014 no network access) and returns a single-use planHash bound to that project; after a human confirms, call again with confirm:true and that planHash. A read-protected CPU needs its read-access password from a HUMAN (G6 \u2014 never invented). Needs the deploy license scope (Basic \u2192 403 scope_required) and app \u2265 v1.6.0. Maps to POST /stations/upload/plan and POST /stations/upload. " + LONG_OPERATION_NOTE,
|
|
39187
|
+
description: "Station upload (GATE G4): goes ONLINE to the PHYSICAL CPU at `ip` and reads its hardware configuration and program into the OPEN project as a new station \u2014 it reads the CPU and does not write or stop it (observed on hardware: the CPU stayed in RUN). Back up into a dedicated EMPTY project, never the working project (skill tia-backup). Without confirm it asks serve for an upload plan (PG/PC interface resolved, the open project's path and devices \u2014 no network access) and returns a single-use planHash bound to that project; after a human confirms, call again with confirm:true and that planHash. A plan blocked by connection_unresolved because no connectionMode was given asks serve for one more plan per available mode (one at a time, never confirmed; up to 8 modes) and lists the PG/PC interfaces it reports in connectionCandidates (up to 32): repeat without confirm with one candidate's exact connectionMode, pcInterfaceName and pcInterfaceNumber. A read-protected CPU needs its read-access password from a HUMAN (G6 \u2014 never invented). Needs the deploy license scope (Basic \u2192 403 scope_required) and app \u2265 v1.6.0. Maps to POST /stations/upload/plan and POST /stations/upload. " + LONG_OPERATION_NOTE,
|
|
39114
39188
|
inputSchema: {
|
|
39115
39189
|
ip: external_exports.string().describe("IPv4 of the PHYSICAL CPU"),
|
|
39116
39190
|
connectionMode: external_exports.string().optional().describe(`connection mode (e.g., "PN/IE") \u2014 TIA's LOCALIZED name`),
|
|
@@ -39706,7 +39780,7 @@ function buildServer(mode, version2, budget = resolveBudget()) {
|
|
|
39706
39780
|
}
|
|
39707
39781
|
|
|
39708
39782
|
// src/index.ts
|
|
39709
|
-
var VERSION = "1.10.
|
|
39783
|
+
var VERSION = "1.10.6";
|
|
39710
39784
|
async function main() {
|
|
39711
39785
|
if (process.argv.slice(2).some((a) => a === "--version" || a === "-v")) {
|
|
39712
39786
|
console.log(VERSION);
|
package/package.json
CHANGED