@usex/mikrotik-mcp 5.10.0 → 5.11.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/cli.js +22 -10
- package/dist/index.js +1 -1
- package/dist/shared/{library-cv5qe3zh.js → library-drn9gmjm.js} +1 -1
- package/dist/shared/{library-kpx18cna.js → library-tm6yshkz.js} +22 -10
- package/dist/ui/observability.html +3 -3
- package/package.json +9 -9
- package/schemas/tool-catalog.json +1 -1
- /package/dist/shared/{cli-k3m3pxn8.js → cli-m947aqb2.js} +0 -0
package/dist/cli.js
CHANGED
|
@@ -16764,7 +16764,7 @@ function poolStatus() {
|
|
|
16764
16764
|
}
|
|
16765
16765
|
|
|
16766
16766
|
// src/ssh/safe-mode.ts
|
|
16767
|
-
var PROMPT_RE = /\[
|
|
16767
|
+
var PROMPT_RE = /\[[^\r\n\]]+@[^\r\n\]]+\][ \t]+(?:\/[^\r\n<>]*[ \t]*)?(?:<SAFE>(?:[ \t]*>)?|>)[ \t]*$/;
|
|
16768
16768
|
var ANSI_RE = /\x1B(?:\[[0-9;]*[mA-HJ-MSTfhilnprsu]|[()][0-9A-Za-z]|\[?\?\d+[hl])/g;
|
|
16769
16769
|
function stripAnsi(text) {
|
|
16770
16770
|
return text.replace(ANSI_RE, "");
|
|
@@ -16832,8 +16832,9 @@ class SafeModeManager {
|
|
|
16832
16832
|
this.cleanup();
|
|
16833
16833
|
return `Error: Timed out waiting for MikroTik shell prompt. Got: ${JSON.stringify(initial.slice(0, 300))}`;
|
|
16834
16834
|
}
|
|
16835
|
+
const activation = this.readUntilPrompt(1e4, (c) => isSafeModeActivated(c));
|
|
16835
16836
|
this.channel.write(CTRL_X);
|
|
16836
|
-
const response = (await
|
|
16837
|
+
const response = (await activation).text;
|
|
16837
16838
|
if (!isSafeModeActivated(response)) {
|
|
16838
16839
|
this.cleanup();
|
|
16839
16840
|
return `Error: Safe mode did not activate. Response: ${JSON.stringify(response.slice(0, 300))}`;
|
|
@@ -16850,11 +16851,12 @@ class SafeModeManager {
|
|
|
16850
16851
|
if (!this.active || !this.channel) {
|
|
16851
16852
|
throw new Error("Safe mode session is not active.");
|
|
16852
16853
|
}
|
|
16854
|
+
const response = this.readUntilPrompt();
|
|
16853
16855
|
this.channel.write(`${command}
|
|
16854
16856
|
`);
|
|
16855
|
-
const { text, timedOut } = await
|
|
16857
|
+
const { text, timedOut } = await response;
|
|
16856
16858
|
if (timedOut) {
|
|
16857
|
-
throw new Error(`Safe Mode
|
|
16859
|
+
throw new Error(`Safe Mode command did not return a recognized prompt before the timeout (command: ${command}). ` + "Execution may have occurred; do not retry the write blindly. Inspect the session " + "and roll back if its state cannot be verified.");
|
|
16858
16860
|
}
|
|
16859
16861
|
return this.extractOutput(text, command);
|
|
16860
16862
|
});
|
|
@@ -16961,12 +16963,17 @@ class SafeModeManager {
|
|
|
16961
16963
|
if (!this.channel)
|
|
16962
16964
|
return "unknown";
|
|
16963
16965
|
const token = "__MCP_SAFEMODE_PROBE__";
|
|
16966
|
+
const response = this.readUntilPrompt(8000, (cleaned) => {
|
|
16967
|
+
const lines = cleaned.replace(/\r/g, `
|
|
16968
|
+
`).split(`
|
|
16969
|
+
`);
|
|
16970
|
+
const i = lines.findIndex((line) => line.trim() === token);
|
|
16971
|
+
return i >= 0 && PROMPT_RE.test(lines.slice(i + 1).join(`
|
|
16972
|
+
`));
|
|
16973
|
+
});
|
|
16964
16974
|
this.channel.write(`:put "${token}"
|
|
16965
16975
|
`);
|
|
16966
|
-
const out = (await
|
|
16967
|
-
const i = cleaned.lastIndexOf(token);
|
|
16968
|
-
return i >= 0 && PROMPT_RE.test(cleaned.slice(i));
|
|
16969
|
-
})).text;
|
|
16976
|
+
const out = (await response).text;
|
|
16970
16977
|
return classifyPrompt(out);
|
|
16971
16978
|
}
|
|
16972
16979
|
extractOutput(raw, command) {
|
|
@@ -16984,6 +16991,11 @@ class SafeModeManager {
|
|
|
16984
16991
|
pastEcho = true;
|
|
16985
16992
|
continue;
|
|
16986
16993
|
}
|
|
16994
|
+
if (stripped.endsWith(command.trim())) {
|
|
16995
|
+
const prefix = stripped.slice(0, -command.trim().length).trimEnd();
|
|
16996
|
+
if (PROMPT_RE.test(prefix))
|
|
16997
|
+
continue;
|
|
16998
|
+
}
|
|
16987
16999
|
if (PROMPT_RE.test(stripped))
|
|
16988
17000
|
break;
|
|
16989
17001
|
result.push(line);
|
|
@@ -30211,7 +30223,7 @@ var cache2 = null;
|
|
|
30211
30223
|
async function gateway() {
|
|
30212
30224
|
if (cache2)
|
|
30213
30225
|
return cache2;
|
|
30214
|
-
const { moduleCatalog } = await import("./shared/cli-
|
|
30226
|
+
const { moduleCatalog } = await import("./shared/cli-m947aqb2.js");
|
|
30215
30227
|
const forIndex = [];
|
|
30216
30228
|
const byName = new Map;
|
|
30217
30229
|
for (const mod of moduleCatalog) {
|
|
@@ -52437,7 +52449,7 @@ var riskByTool = null;
|
|
|
52437
52449
|
async function riskIndex() {
|
|
52438
52450
|
if (riskByTool)
|
|
52439
52451
|
return riskByTool;
|
|
52440
|
-
const { moduleCatalog } = await import("./shared/cli-
|
|
52452
|
+
const { moduleCatalog } = await import("./shared/cli-m947aqb2.js");
|
|
52441
52453
|
const index = new Map;
|
|
52442
52454
|
for (const mod of moduleCatalog) {
|
|
52443
52455
|
for (const tool of mod.tools)
|
package/dist/index.js
CHANGED
|
@@ -62,7 +62,7 @@ import {
|
|
|
62
62
|
updateSummaryLine,
|
|
63
63
|
allToolModules2,
|
|
64
64
|
selectToolModules2
|
|
65
|
-
} from "./shared/library-
|
|
65
|
+
} from "./shared/library-tm6yshkz.js";
|
|
66
66
|
|
|
67
67
|
// node_modules/ajv/dist/compile/codegen/code.js
|
|
68
68
|
var require_code = __commonJS(function(exports) {
|
|
@@ -10181,7 +10181,7 @@ async function runPooled(command, deviceName, opts) {
|
|
|
10181
10181
|
}
|
|
10182
10182
|
|
|
10183
10183
|
// src/ssh/safe-mode.ts
|
|
10184
|
-
var PROMPT_RE = /\[
|
|
10184
|
+
var PROMPT_RE = /\[[^\r\n\]]+@[^\r\n\]]+\][ \t]+(?:\/[^\r\n<>]*[ \t]*)?(?:<SAFE>(?:[ \t]*>)?|>)[ \t]*$/;
|
|
10185
10185
|
var ANSI_RE = /\x1B(?:\[[0-9;]*[mA-HJ-MSTfhilnprsu]|[()][0-9A-Za-z]|\[?\?\d+[hl])/g;
|
|
10186
10186
|
function stripAnsi(text) {
|
|
10187
10187
|
return text.replace(ANSI_RE, "");
|
|
@@ -10249,8 +10249,9 @@ class SafeModeManager2 {
|
|
|
10249
10249
|
this.cleanup();
|
|
10250
10250
|
return `Error: Timed out waiting for MikroTik shell prompt. Got: ${JSON.stringify(initial.slice(0, 300))}`;
|
|
10251
10251
|
}
|
|
10252
|
+
const activation = this.readUntilPrompt(1e4, (c) => isSafeModeActivated(c));
|
|
10252
10253
|
this.channel.write(CTRL_X);
|
|
10253
|
-
const response = (await
|
|
10254
|
+
const response = (await activation).text;
|
|
10254
10255
|
if (!isSafeModeActivated(response)) {
|
|
10255
10256
|
this.cleanup();
|
|
10256
10257
|
return `Error: Safe mode did not activate. Response: ${JSON.stringify(response.slice(0, 300))}`;
|
|
@@ -10267,11 +10268,12 @@ class SafeModeManager2 {
|
|
|
10267
10268
|
if (!this.active || !this.channel) {
|
|
10268
10269
|
throw new Error("Safe mode session is not active.");
|
|
10269
10270
|
}
|
|
10271
|
+
const response = this.readUntilPrompt();
|
|
10270
10272
|
this.channel.write(`${command}
|
|
10271
10273
|
`);
|
|
10272
|
-
const { text, timedOut } = await
|
|
10274
|
+
const { text, timedOut } = await response;
|
|
10273
10275
|
if (timedOut) {
|
|
10274
|
-
throw new Error(`Safe Mode
|
|
10276
|
+
throw new Error(`Safe Mode command did not return a recognized prompt before the timeout (command: ${command}). ` + "Execution may have occurred; do not retry the write blindly. Inspect the session " + "and roll back if its state cannot be verified.");
|
|
10275
10277
|
}
|
|
10276
10278
|
return this.extractOutput(text, command);
|
|
10277
10279
|
});
|
|
@@ -10378,12 +10380,17 @@ class SafeModeManager2 {
|
|
|
10378
10380
|
if (!this.channel)
|
|
10379
10381
|
return "unknown";
|
|
10380
10382
|
const token = "__MCP_SAFEMODE_PROBE__";
|
|
10383
|
+
const response = this.readUntilPrompt(8000, (cleaned) => {
|
|
10384
|
+
const lines = cleaned.replace(/\r/g, `
|
|
10385
|
+
`).split(`
|
|
10386
|
+
`);
|
|
10387
|
+
const i = lines.findIndex((line) => line.trim() === token);
|
|
10388
|
+
return i >= 0 && PROMPT_RE.test(lines.slice(i + 1).join(`
|
|
10389
|
+
`));
|
|
10390
|
+
});
|
|
10381
10391
|
this.channel.write(`:put "${token}"
|
|
10382
10392
|
`);
|
|
10383
|
-
const out = (await
|
|
10384
|
-
const i = cleaned.lastIndexOf(token);
|
|
10385
|
-
return i >= 0 && PROMPT_RE.test(cleaned.slice(i));
|
|
10386
|
-
})).text;
|
|
10393
|
+
const out = (await response).text;
|
|
10387
10394
|
return classifyPrompt(out);
|
|
10388
10395
|
}
|
|
10389
10396
|
extractOutput(raw, command) {
|
|
@@ -10401,6 +10408,11 @@ class SafeModeManager2 {
|
|
|
10401
10408
|
pastEcho = true;
|
|
10402
10409
|
continue;
|
|
10403
10410
|
}
|
|
10411
|
+
if (stripped.endsWith(command.trim())) {
|
|
10412
|
+
const prefix = stripped.slice(0, -command.trim().length).trimEnd();
|
|
10413
|
+
if (PROMPT_RE.test(prefix))
|
|
10414
|
+
continue;
|
|
10415
|
+
}
|
|
10404
10416
|
if (PROMPT_RE.test(stripped))
|
|
10405
10417
|
break;
|
|
10406
10418
|
result.push(line);
|
|
@@ -23012,7 +23024,7 @@ var cache2 = null;
|
|
|
23012
23024
|
async function gateway() {
|
|
23013
23025
|
if (cache2)
|
|
23014
23026
|
return cache2;
|
|
23015
|
-
const { moduleCatalog } = await import("./library-
|
|
23027
|
+
const { moduleCatalog } = await import("./library-drn9gmjm.js");
|
|
23016
23028
|
const forIndex = [];
|
|
23017
23029
|
const byName = new Map;
|
|
23018
23030
|
for (const mod of moduleCatalog) {
|
|
@@ -44990,7 +45002,7 @@ var riskByTool = null;
|
|
|
44990
45002
|
async function riskIndex() {
|
|
44991
45003
|
if (riskByTool)
|
|
44992
45004
|
return riskByTool;
|
|
44993
|
-
const { moduleCatalog } = await import("./library-
|
|
45005
|
+
const { moduleCatalog } = await import("./library-drn9gmjm.js");
|
|
44994
45006
|
const index = new Map;
|
|
44995
45007
|
for (const mod of moduleCatalog) {
|
|
44996
45008
|
for (const tool of mod.tools)
|