node-opcua-modeler-mcp-server 1.3.0 → 1.4.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/README.md +53 -3
- package/catalog/catalog.json +6706 -1432
- package/dist/catalog.d.ts +6 -0
- package/dist/catalog.js +6 -0
- package/dist/catalog.js.map +1 -1
- package/dist/cloud.d.ts +21 -6
- package/dist/cloud.js +173 -49
- package/dist/cloud.js.map +1 -1
- package/dist/local.d.ts +74 -0
- package/dist/local.js +149 -0
- package/dist/local.js.map +1 -0
- package/dist/server.d.ts +13 -17
- package/dist/server.js +185 -166
- package/dist/server.js.map +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
package/dist/catalog.d.ts
CHANGED
|
@@ -62,6 +62,12 @@ export declare function listNamespaces(): CompanionSpecEntry[];
|
|
|
62
62
|
/**
|
|
63
63
|
* Resolve the full dependency chain for a set of spec aliases.
|
|
64
64
|
* Returns a topologically sorted list (dependencies before dependents).
|
|
65
|
+
*
|
|
66
|
+
* NOTE: this is an intentional standalone copy of the toposort. The published
|
|
67
|
+
* MCP server ships a frozen `catalog.json` and imports NO `@sterfive/*` package
|
|
68
|
+
* at runtime (IP-safe, zero-dep), so it cannot reuse ex's `topologicalOrder`.
|
|
69
|
+
* The catalog `deps` are generated from — and kept in sync with — the ex/KB
|
|
70
|
+
* registries by `scripts/extract-catalog.ts` + `check-registry-consistency.ts`.
|
|
65
71
|
*/
|
|
66
72
|
export declare function resolveDependencies(aliases: string[]): string[];
|
|
67
73
|
/** List all types in a companion spec namespace */
|
package/dist/catalog.js
CHANGED
|
@@ -32,6 +32,12 @@ export function listNamespaces() {
|
|
|
32
32
|
/**
|
|
33
33
|
* Resolve the full dependency chain for a set of spec aliases.
|
|
34
34
|
* Returns a topologically sorted list (dependencies before dependents).
|
|
35
|
+
*
|
|
36
|
+
* NOTE: this is an intentional standalone copy of the toposort. The published
|
|
37
|
+
* MCP server ships a frozen `catalog.json` and imports NO `@sterfive/*` package
|
|
38
|
+
* at runtime (IP-safe, zero-dep), so it cannot reuse ex's `topologicalOrder`.
|
|
39
|
+
* The catalog `deps` are generated from — and kept in sync with — the ex/KB
|
|
40
|
+
* registries by `scripts/extract-catalog.ts` + `check-registry-consistency.ts`.
|
|
35
41
|
*/
|
|
36
42
|
export function resolveDependencies(aliases) {
|
|
37
43
|
const registry = getCatalog().registry;
|
package/dist/catalog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC/D,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC;AAyD9E,4EAA4E;AAE5E,IAAI,QAAQ,GAAmB,IAAI,CAAC;AAEpC,SAAS,UAAU;IACjB,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACnD,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAY,CAAC;IACxC,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,4EAA4E;AAE5E,yCAAyC;AACzC,MAAM,UAAU,cAAc;IAC5B,OAAO,UAAU,EAAE,CAAC,QAAQ,CAAC;AAC/B,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAW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AAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QACzC,MAAM,aAAa,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;QACxC,IAAI,aAAa,EAAE,CAAC;YAClB,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;QACzE,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/cloud.d.ts
CHANGED
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ==========================================================================
|
|
3
|
-
* OPC UA Modeler —
|
|
3
|
+
* OPC UA Modeler — API Client
|
|
4
4
|
*
|
|
5
|
-
* Thin HTTP wrapper for proxying MCP tool calls to
|
|
6
|
-
*
|
|
5
|
+
* Thin HTTP wrapper for proxying MCP tool calls to a backend that speaks the
|
|
6
|
+
* /api/v1 contract: either the Sterfive SaaS, or a licensed
|
|
7
|
+
* `opcua-modeler serve` running on this machine.
|
|
8
|
+
*
|
|
9
|
+
* ZERO proprietary dependencies — native fetch for the cloud, node:http for
|
|
10
|
+
* the local pipe.
|
|
7
11
|
*
|
|
8
12
|
* Configuration via environment variables:
|
|
13
|
+
* OPCUA_MODELER_BACKEND — "cloud" (default) or "local"
|
|
9
14
|
* OPCUA_MODELER_API_URL — Base URL (default: https://api.opcua-modeler.sterfive.io)
|
|
10
15
|
* OPCUA_MODELER_API_KEY — API key (stfv_...) for authenticated endpoints
|
|
11
16
|
*
|
|
17
|
+
* The two backends are NEVER mixed and there is no fallback between them:
|
|
18
|
+
* on-premise is chosen precisely so that models do not leave the network, and
|
|
19
|
+
* quietly retrying against the hosted API when a local daemon is down would
|
|
20
|
+
* be a data-egress bug rather than a convenience.
|
|
21
|
+
*
|
|
22
|
+
* Both transports resolve to a `Response`, so every status-handling branch
|
|
23
|
+
* below is shared. Only the messages differ, because "set your API key" is
|
|
24
|
+
* nonsense advice for a licensed local server.
|
|
25
|
+
*
|
|
12
26
|
* IMPORTANT: Never use console.log() — stdout is reserved for JSON-RPC.
|
|
13
27
|
* ==========================================================================
|
|
14
28
|
*/
|
|
@@ -30,11 +44,12 @@ export type CloudResult<T = unknown> = {
|
|
|
30
44
|
* Make an authenticated request to the Sterfive SaaS API.
|
|
31
45
|
*
|
|
32
46
|
* @param path - API path (e.g. "/v1/validate")
|
|
33
|
-
* @param body - Request body (string)
|
|
34
|
-
* @param contentType - Content-Type header (e.g. "text/yaml", "application/xml")
|
|
47
|
+
* @param body - Request body (string); ignored for GET
|
|
48
|
+
* @param contentType - Content-Type header (e.g. "text/yaml", "application/xml"); ignored for GET
|
|
49
|
+
* @param method - HTTP method (default "POST")
|
|
35
50
|
* @returns Parsed JSON response or structured error
|
|
36
51
|
*/
|
|
37
|
-
export declare function cloudFetch<T = unknown>(path: string, body: string, contentType: string): Promise<CloudResult<T>>;
|
|
52
|
+
export declare function cloudFetch<T = unknown>(path: string, body: string, contentType: string, method?: "GET" | "POST"): Promise<CloudResult<T>>;
|
|
38
53
|
/**
|
|
39
54
|
* Format a CloudError into a user-friendly MCP tool error response.
|
|
40
55
|
*/
|
package/dist/cloud.js
CHANGED
|
@@ -1,54 +1,126 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ==========================================================================
|
|
3
|
-
* OPC UA Modeler —
|
|
3
|
+
* OPC UA Modeler — API Client
|
|
4
4
|
*
|
|
5
|
-
* Thin HTTP wrapper for proxying MCP tool calls to
|
|
6
|
-
*
|
|
5
|
+
* Thin HTTP wrapper for proxying MCP tool calls to a backend that speaks the
|
|
6
|
+
* /api/v1 contract: either the Sterfive SaaS, or a licensed
|
|
7
|
+
* `opcua-modeler serve` running on this machine.
|
|
8
|
+
*
|
|
9
|
+
* ZERO proprietary dependencies — native fetch for the cloud, node:http for
|
|
10
|
+
* the local pipe.
|
|
7
11
|
*
|
|
8
12
|
* Configuration via environment variables:
|
|
13
|
+
* OPCUA_MODELER_BACKEND — "cloud" (default) or "local"
|
|
9
14
|
* OPCUA_MODELER_API_URL — Base URL (default: https://api.opcua-modeler.sterfive.io)
|
|
10
15
|
* OPCUA_MODELER_API_KEY — API key (stfv_...) for authenticated endpoints
|
|
11
16
|
*
|
|
17
|
+
* The two backends are NEVER mixed and there is no fallback between them:
|
|
18
|
+
* on-premise is chosen precisely so that models do not leave the network, and
|
|
19
|
+
* quietly retrying against the hosted API when a local daemon is down would
|
|
20
|
+
* be a data-egress bug rather than a convenience.
|
|
21
|
+
*
|
|
22
|
+
* Both transports resolve to a `Response`, so every status-handling branch
|
|
23
|
+
* below is shared. Only the messages differ, because "set your API key" is
|
|
24
|
+
* nonsense advice for a licensed local server.
|
|
25
|
+
*
|
|
12
26
|
* IMPORTANT: Never use console.log() — stdout is reserved for JSON-RPC.
|
|
13
27
|
* ==========================================================================
|
|
14
28
|
*/
|
|
29
|
+
import { isLocalBackend, localFetch, readLocalEndpoint } from "./local.js";
|
|
15
30
|
const DEFAULT_API_URL = "https://api.opcua-modeler.sterfive.io";
|
|
16
31
|
const TIMEOUT_MS = 30_000;
|
|
32
|
+
/**
|
|
33
|
+
* The local engine runs in-process on the user's machine, where a large model
|
|
34
|
+
* with documentation can legitimately take minutes — there is no gateway
|
|
35
|
+
* timeout to race, and no other tenant to be fair to.
|
|
36
|
+
*/
|
|
37
|
+
const LOCAL_TIMEOUT_MS = 300_000;
|
|
17
38
|
function getApiUrl() {
|
|
18
39
|
return process.env.OPCUA_MODELER_API_URL || DEFAULT_API_URL;
|
|
19
40
|
}
|
|
20
41
|
function getApiKey() {
|
|
21
42
|
return process.env.OPCUA_MODELER_API_KEY;
|
|
22
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Extract a human-readable detail (and optional hint) from an error response.
|
|
46
|
+
*
|
|
47
|
+
* The SaaS serializes errors as `{ error: string, hint?: string }` (see
|
|
48
|
+
* api-helpers.ts apiError); `detail`/`message` are tolerated for proxies and
|
|
49
|
+
* older servers. The body is read ONCE as text — a failed response.json()
|
|
50
|
+
* consumes the stream and would make a fallback .text() throw.
|
|
51
|
+
*/
|
|
52
|
+
async function readErrorBody(response) {
|
|
53
|
+
let text = "";
|
|
54
|
+
try {
|
|
55
|
+
text = await response.text();
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
return { detail: "" };
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
const body = JSON.parse(text);
|
|
62
|
+
const detail = [body.error, body.detail, body.message].find((v) => typeof v === "string" && v.length > 0);
|
|
63
|
+
return {
|
|
64
|
+
detail: detail ?? text.trim(),
|
|
65
|
+
hint: typeof body.hint === "string" && body.hint ? body.hint : undefined,
|
|
66
|
+
code: typeof body.code === "string" && body.code ? body.code : undefined
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return { detail: text.trim() };
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/** Direct renewal link for expired keys — surfaced verbatim to agents/CLI. */
|
|
74
|
+
const KEY_SETTINGS_URL = "https://opcua-modeler.sterfive.io/app/settings/api";
|
|
23
75
|
/**
|
|
24
76
|
* Make an authenticated request to the Sterfive SaaS API.
|
|
25
77
|
*
|
|
26
78
|
* @param path - API path (e.g. "/v1/validate")
|
|
27
|
-
* @param body - Request body (string)
|
|
28
|
-
* @param contentType - Content-Type header (e.g. "text/yaml", "application/xml")
|
|
79
|
+
* @param body - Request body (string); ignored for GET
|
|
80
|
+
* @param contentType - Content-Type header (e.g. "text/yaml", "application/xml"); ignored for GET
|
|
81
|
+
* @param method - HTTP method (default "POST")
|
|
29
82
|
* @returns Parsed JSON response or structured error
|
|
30
83
|
*/
|
|
31
|
-
export async function cloudFetch(path, body, contentType) {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
84
|
+
export async function cloudFetch(path, body, contentType, method = "POST") {
|
|
85
|
+
const local = isLocalBackend();
|
|
86
|
+
// Resolve the local endpoint BEFORE the try: "no server running" is a
|
|
87
|
+
// configuration answer, not a transport failure, and deserves its own
|
|
88
|
+
// message rather than being folded into the network-error branch.
|
|
89
|
+
let endpoint;
|
|
90
|
+
if (local) {
|
|
91
|
+
endpoint = readLocalEndpoint();
|
|
92
|
+
if (!endpoint.ok) {
|
|
93
|
+
return { ok: false, error: endpoint.error };
|
|
94
|
+
}
|
|
41
95
|
}
|
|
42
96
|
try {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
97
|
+
let response;
|
|
98
|
+
if (local && endpoint?.ok) {
|
|
99
|
+
response = await localFetch(endpoint.endpoint, path, body, contentType, method, LOCAL_TIMEOUT_MS);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
const headers = { Accept: "application/json" };
|
|
103
|
+
if (method !== "GET") {
|
|
104
|
+
headers["Content-Type"] = contentType;
|
|
105
|
+
}
|
|
106
|
+
const apiKey = getApiKey();
|
|
107
|
+
if (apiKey) {
|
|
108
|
+
headers["Authorization"] = `Bearer ${apiKey}`;
|
|
109
|
+
}
|
|
110
|
+
const controller = new AbortController();
|
|
111
|
+
const timeout = setTimeout(() => controller.abort(), TIMEOUT_MS);
|
|
112
|
+
try {
|
|
113
|
+
response = await fetch(`${getApiUrl()}${path}`, {
|
|
114
|
+
method,
|
|
115
|
+
headers,
|
|
116
|
+
...(method !== "GET" ? { body } : {}),
|
|
117
|
+
signal: controller.signal
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
finally {
|
|
121
|
+
clearTimeout(timeout);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
52
124
|
if (response.ok) {
|
|
53
125
|
const data = (await response.json());
|
|
54
126
|
return { ok: true, data };
|
|
@@ -56,58 +128,98 @@ export async function cloudFetch(path, body, contentType) {
|
|
|
56
128
|
// Handle specific HTTP error codes with actionable messages
|
|
57
129
|
switch (response.status) {
|
|
58
130
|
case 401:
|
|
59
|
-
case 403:
|
|
131
|
+
case 403: {
|
|
132
|
+
// The server says WHY (invalid key, expired trial, …) — surface it.
|
|
133
|
+
const { detail, hint, code } = await readErrorBody(response);
|
|
134
|
+
// A local server authenticates with a token from its own discovery
|
|
135
|
+
// file, so every word of the SaaS signup advice below is wrong here.
|
|
136
|
+
// The realistic cause is a stale file from a server that has since
|
|
137
|
+
// restarted with a fresh token.
|
|
138
|
+
if (local) {
|
|
139
|
+
return {
|
|
140
|
+
ok: false,
|
|
141
|
+
error: {
|
|
142
|
+
error: detail || "The on-premise server rejected this token.",
|
|
143
|
+
status: response.status,
|
|
144
|
+
hint: "The token is read from the server's discovery file. If the server was restarted, " +
|
|
145
|
+
"the file now holds a new token — retry. If that fails, restart `opcua-modeler serve`."
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
// Expired beta key: the fix is a rotation, not a signup — surface
|
|
150
|
+
// the renewal link verbatim so agents can relay it to the user.
|
|
151
|
+
if (code === "key_expired") {
|
|
152
|
+
const renewalNote = `Rotate your key at ${KEY_SETTINGS_URL} ("Rotate & extend" grants a fresh 30-day window), ` +
|
|
153
|
+
"then update OPCUA_MODELER_API_KEY in this MCP server's config.";
|
|
154
|
+
return {
|
|
155
|
+
ok: false,
|
|
156
|
+
error: {
|
|
157
|
+
error: detail || "Your OPC UA Modeler API key has expired.",
|
|
158
|
+
status: response.status,
|
|
159
|
+
hint: hint?.includes(KEY_SETTINGS_URL)
|
|
160
|
+
? `${hint} — then update OPCUA_MODELER_API_KEY in this MCP server's config.`
|
|
161
|
+
: renewalNote
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
const mcpNote = "This MCP server reads the key from OPCUA_MODELER_API_KEY in its config. " +
|
|
166
|
+
"Register at https://opcua-modeler.sterfive.io/signup then create an API key " +
|
|
167
|
+
"under Settings > API (free tier: 25 calls/day, 90-day trial).";
|
|
60
168
|
return {
|
|
61
169
|
ok: false,
|
|
62
170
|
error: {
|
|
63
|
-
error: "Authentication required. Set OPCUA_MODELER_API_KEY in your MCP server config.",
|
|
171
|
+
error: detail || "Authentication required. Set OPCUA_MODELER_API_KEY in your MCP server config.",
|
|
64
172
|
status: response.status,
|
|
65
|
-
hint:
|
|
66
|
-
"under Settings > API (free tier: 25 calls/day, 90-day trial)."
|
|
173
|
+
hint: hint ? `${hint} — ${mcpNote}` : mcpNote
|
|
67
174
|
}
|
|
68
175
|
};
|
|
176
|
+
}
|
|
69
177
|
case 429: {
|
|
178
|
+
// The server distinguishes burst / daily / discovery limits — surface it.
|
|
179
|
+
const { detail, hint } = await readErrorBody(response);
|
|
70
180
|
const retryAfter = response.headers.get("Retry-After");
|
|
71
181
|
const upgradeUrl = response.headers.get("X-Upgrade-URL");
|
|
72
182
|
return {
|
|
73
183
|
ok: false,
|
|
74
184
|
error: {
|
|
75
|
-
error:
|
|
185
|
+
error: `${detail || "Rate limit exceeded."}${retryAfter ? ` Try again in ${retryAfter}s.` : ""}`,
|
|
76
186
|
status: 429,
|
|
77
|
-
hint: upgradeUrl ? `Upgrade your plan at ${upgradeUrl}` : "Reduce request frequency or upgrade your plan."
|
|
187
|
+
hint: hint || (upgradeUrl ? `Upgrade your plan at ${upgradeUrl}` : "Reduce request frequency or upgrade your plan.")
|
|
78
188
|
}
|
|
79
189
|
};
|
|
80
190
|
}
|
|
81
191
|
case 422: {
|
|
82
192
|
// Validation error from the API (e.g. malformed YAML)
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
193
|
+
const { detail, hint } = await readErrorBody(response);
|
|
194
|
+
return {
|
|
195
|
+
ok: false,
|
|
196
|
+
error: {
|
|
197
|
+
error: `Validation error: ${detail || response.statusText || "(the server returned no details)"}`,
|
|
198
|
+
status: 422,
|
|
199
|
+
...(hint ? { hint } : {})
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
case 501: {
|
|
204
|
+
// This backend does not implement the endpoint — on-premise omits AI
|
|
205
|
+
// generation. Distinct from a 404: the URL was right, the capability
|
|
206
|
+
// is absent, and the agent should switch backends rather than retry.
|
|
207
|
+
const { detail, hint } = await readErrorBody(response);
|
|
91
208
|
return {
|
|
92
209
|
ok: false,
|
|
93
210
|
error: {
|
|
94
|
-
error:
|
|
95
|
-
status:
|
|
211
|
+
error: detail || "This backend does not provide that capability.",
|
|
212
|
+
status: 501,
|
|
213
|
+
hint: hint || "Set OPCUA_MODELER_BACKEND=cloud to use the hosted API for this tool."
|
|
96
214
|
}
|
|
97
215
|
};
|
|
98
216
|
}
|
|
99
217
|
default: {
|
|
100
|
-
|
|
101
|
-
try {
|
|
102
|
-
text = await response.text();
|
|
103
|
-
}
|
|
104
|
-
catch {
|
|
105
|
-
/* ignore */
|
|
106
|
-
}
|
|
218
|
+
const { detail } = await readErrorBody(response);
|
|
107
219
|
return {
|
|
108
220
|
ok: false,
|
|
109
221
|
error: {
|
|
110
|
-
error: `API error (HTTP ${response.status}): ${
|
|
222
|
+
error: `API error (HTTP ${response.status}): ${detail || response.statusText || "(the server returned no details)"}`,
|
|
111
223
|
status: response.status
|
|
112
224
|
}
|
|
113
225
|
};
|
|
@@ -124,8 +236,20 @@ export async function cloudFetch(path, body, contentType) {
|
|
|
124
236
|
}
|
|
125
237
|
};
|
|
126
238
|
}
|
|
127
|
-
// Network errors (DNS, connection refused, etc.)
|
|
128
239
|
const message = e instanceof Error ? e.message : String(e);
|
|
240
|
+
// A dead pipe means the server exited since it published its file — a
|
|
241
|
+
// different situation from a network problem, and a different fix.
|
|
242
|
+
if (local) {
|
|
243
|
+
return {
|
|
244
|
+
ok: false,
|
|
245
|
+
error: {
|
|
246
|
+
error: `Cannot reach the on-premise OPC UA Modeler server: ${message}`,
|
|
247
|
+
hint: "The server may have stopped since it published its discovery file. " +
|
|
248
|
+
"Restart it with `opcua-modeler serve`, or set OPCUA_MODELER_BACKEND=cloud."
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
// Network errors (DNS, connection refused, etc.)
|
|
129
253
|
return {
|
|
130
254
|
ok: false,
|
|
131
255
|
error: {
|
package/dist/cloud.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloud.js","sourceRoot":"","sources":["../src/cloud.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"cloud.js","sourceRoot":"","sources":["../src/cloud.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE3E,MAAM,eAAe,GAAG,uCAAuC,CAAC;AAChE,MAAM,UAAU,GAAG,MAAM,CAAC;AAE1B;;;;GAIG;AACH,MAAM,gBAAgB,GAAG,OAAO,CAAC;AAYjC,SAAS,SAAS;IAChB,OAAO,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,eAAe,CAAC;AAC9D,CAAC;AAED,SAAS,SAAS;IAChB,OAAO,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC;AAC3C,CAAC;AAED;;;;;;;GAOG;AACH,KAAK,UAAU,aAAa,CAAC,QAAkB;IAC7C,IAAI,IAAI,GAAG,EAAE,CAAC;IACd,IAAI,CAAC;QACH,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;IACxB,CAAC;IACD,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAA6F,CAAC;QAC1H,MAAM,MAAM,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAA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E;gBACL,KAAK,EAAE,wCAAwC,OAAO,EAAE;gBACxD,IAAI,EAAE,sDAAsD;aAC7D;SACF,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,GAAe;IAC9C,MAAM,KAAK,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC1B,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC;QACb,KAAK,CAAC,IAAI,CAAC,SAAS,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
package/dist/local.d.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ==========================================================================
|
|
3
|
+
* OPC UA Modeler — On-premise backend transport
|
|
4
|
+
*
|
|
5
|
+
* Talks to `opcua-modeler serve` running as the same OS user, over a named
|
|
6
|
+
* pipe (Windows) or Unix socket. Selected with OPCUA_MODELER_BACKEND=local.
|
|
7
|
+
*
|
|
8
|
+
* Why a pipe rather than a localhost port:
|
|
9
|
+
*
|
|
10
|
+
* - Both processes are on one machine by definition, so a network socket
|
|
11
|
+
* buys nothing and adds a surface. There is no address to bind wrongly
|
|
12
|
+
* and no port to expose beyond the host.
|
|
13
|
+
* - Access control is the operating system's, not ours: pipe and socket
|
|
14
|
+
* permissions already scope the endpoint to the user who started it,
|
|
15
|
+
* with no port-level authorisation layer to design or get wrong.
|
|
16
|
+
* - No port to allocate, publish, or collide with another service — the
|
|
17
|
+
* endpoint is named per process and advertised in a discovery file.
|
|
18
|
+
*
|
|
19
|
+
* Why node:http rather than fetch: native fetch cannot address a pipe without
|
|
20
|
+
* a custom dispatcher, and pulling undici into a package whose only runtime
|
|
21
|
+
* deps are the MCP SDK and zod is a poor trade for one option. `socketPath`
|
|
22
|
+
* has been in node:http forever and costs nothing.
|
|
23
|
+
*
|
|
24
|
+
* IMPORTANT: Never use console.log() — stdout is reserved for JSON-RPC.
|
|
25
|
+
* ==========================================================================
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* Where `opcua-modeler serve` advertises itself.
|
|
29
|
+
*
|
|
30
|
+
* This is a wire contract between two independently-distributed packages, so
|
|
31
|
+
* the path is restated here rather than imported — this package stays
|
|
32
|
+
* installable on its own, with no build-time coupling to the CLI. Both sides
|
|
33
|
+
* carry a test asserting the same path; change one, change the other.
|
|
34
|
+
*
|
|
35
|
+
* The location follows each platform's convention for per-user runtime state
|
|
36
|
+
* (XDG_RUNTIME_DIR, LOCALAPPDATA), so the endpoint is scoped to the account
|
|
37
|
+
* that started the server.
|
|
38
|
+
*/
|
|
39
|
+
export declare function discoveryFilePath(env?: NodeJS.ProcessEnv): string;
|
|
40
|
+
export interface LocalEndpoint {
|
|
41
|
+
pipe: string;
|
|
42
|
+
token: string;
|
|
43
|
+
pid: number;
|
|
44
|
+
version: string;
|
|
45
|
+
capabilities: string[];
|
|
46
|
+
}
|
|
47
|
+
/** True when the operator asked for the on-premise backend. */
|
|
48
|
+
export declare function isLocalBackend(env?: NodeJS.ProcessEnv): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Locate a running server.
|
|
51
|
+
*
|
|
52
|
+
* Deliberately does NOT fall back to the cloud when the file is missing.
|
|
53
|
+
* On-premise is chosen so that models never leave the network; silently
|
|
54
|
+
* shipping a model to the hosted API because a local daemon was down is a
|
|
55
|
+
* data-egress bug, not a convenience.
|
|
56
|
+
*/
|
|
57
|
+
export declare function readLocalEndpoint(env?: NodeJS.ProcessEnv): {
|
|
58
|
+
ok: true;
|
|
59
|
+
endpoint: LocalEndpoint;
|
|
60
|
+
} | {
|
|
61
|
+
ok: false;
|
|
62
|
+
error: {
|
|
63
|
+
error: string;
|
|
64
|
+
hint: string;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* One request over the pipe, adapted to a `Response`.
|
|
69
|
+
*
|
|
70
|
+
* Returning a real Response means the caller's status handling — 401, 429,
|
|
71
|
+
* 422, the JSON/text error parsing — is the SAME code for both backends. Two
|
|
72
|
+
* copies of that logic is exactly the drift this whole design avoids.
|
|
73
|
+
*/
|
|
74
|
+
export declare function localFetch(endpoint: LocalEndpoint, apiPath: string, body: string, contentType: string, method: "GET" | "POST", timeoutMs: number): Promise<Response>;
|