@usex/mikrotik-mcp 6.13.0 → 6.15.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.
@@ -8499,6 +8499,7 @@ var McpServerSettingsSchema2 = object({
8499
8499
  allowedHosts: string().default(""),
8500
8500
  allowedOrigins: string().default(""),
8501
8501
  corsOrigins: string().default(""),
8502
+ sessionIdleTimeout: exports_coerce.number().int().positive().default(86400000),
8502
8503
  toolPageSize: exports_coerce.number().int().min(0).default(0),
8503
8504
  toolSurface: _enum(["full", "core"]).default("full"),
8504
8505
  coreTools: string().default(""),
@@ -8637,7 +8638,8 @@ var DashboardConfigSchema2 = object({
8637
8638
  redactInput: boolean().default(false),
8638
8639
  maxBodyBytes: exports_coerce.number().int().nonnegative().default(16384),
8639
8640
  token: string().optional(),
8640
- feedLimit: exports_coerce.number().int().positive().max(1e4).default(200)
8641
+ feedLimit: exports_coerce.number().int().positive().max(1e4).default(200),
8642
+ terminal: boolean().default(true)
8641
8643
  });
8642
8644
  var MemoryConfigSchema2 = object({
8643
8645
  enabled: boolean().default(true),
@@ -8863,6 +8865,7 @@ function loadConfig2(argv = process.argv.slice(2)) {
8863
8865
  allowedHosts: pick("mcp-allowed-hosts", "MIKROTIK_MCP__ALLOWED_HOSTS"),
8864
8866
  allowedOrigins: pick("mcp-allowed-origins", "MIKROTIK_MCP__ALLOWED_ORIGINS"),
8865
8867
  corsOrigins: pick("mcp-cors-origins", "MIKROTIK_MCP__CORS_ORIGINS"),
8868
+ sessionIdleTimeout: pick("mcp-session-idle-timeout", "MIKROTIK_MCP__SESSION_IDLE_TIMEOUT"),
8866
8869
  toolPageSize: pick("tool-page-size", "MIKROTIK_MCP__TOOL_PAGE_SIZE"),
8867
8870
  toolSurface: pick("tool-surface", "MIKROTIK_MCP__TOOL_SURFACE"),
8868
8871
  coreTools: pick("core-tools", "MIKROTIK_MCP__CORE_TOOLS"),
@@ -8892,7 +8895,8 @@ function loadConfig2(argv = process.argv.slice(2)) {
8892
8895
  redactInput: boolOpt(pick("dashboard-redact-input", "MIKROTIK_DASHBOARD__REDACT_INPUT")),
8893
8896
  maxBodyBytes: pick("dashboard-max-body-bytes", "MIKROTIK_DASHBOARD__MAX_BODY_BYTES"),
8894
8897
  token: pick("dashboard-token", "MIKROTIK_DASHBOARD__TOKEN"),
8895
- feedLimit: pick("dashboard-feed-limit", "MIKROTIK_DASHBOARD__FEED_LIMIT")
8898
+ feedLimit: pick("dashboard-feed-limit", "MIKROTIK_DASHBOARD__FEED_LIMIT"),
8899
+ terminal: boolOpt(pick("dashboard-terminal", "MIKROTIK_DASHBOARD__TERMINAL"))
8896
8900
  });
8897
8901
  const ssh = overlay(fileSsh, {
8898
8902
  keepAlive: boolOpt(pick("ssh-keep-alive", "MIKROTIK_SSH__KEEP_ALIVE")),
@@ -9106,6 +9110,37 @@ function decodeOutput(data) {
9106
9110
  }
9107
9111
  return new TextDecoder("utf-8").decode(data);
9108
9112
  }
9113
+ var watches = new WeakMap;
9114
+ function watchConnection(connection, waiter) {
9115
+ let watch = watches.get(connection);
9116
+ if (!watch) {
9117
+ const waiters = new Set;
9118
+ const notify = (lost) => {
9119
+ for (const each of Array.from(waiters))
9120
+ each(lost);
9121
+ };
9122
+ watch = {
9123
+ waiters,
9124
+ onError: (error) => notify(`SSH connection lost: ${error.message}.`),
9125
+ onClose: () => notify("SSH connection closed before command completion.")
9126
+ };
9127
+ watches.set(connection, watch);
9128
+ connection.on("error", watch.onError);
9129
+ connection.on("end", watch.onClose);
9130
+ connection.on("close", watch.onClose);
9131
+ }
9132
+ const current = watch;
9133
+ current.waiters.add(waiter);
9134
+ return () => {
9135
+ current.waiters.delete(waiter);
9136
+ if (current.waiters.size > 0 || watches.get(connection) !== current)
9137
+ return;
9138
+ watches.delete(connection);
9139
+ connection.off("error", current.onError);
9140
+ connection.off("end", current.onClose);
9141
+ connection.off("close", current.onClose);
9142
+ };
9143
+ }
9109
9144
 
9110
9145
  class MikroTikSSHClient2 {
9111
9146
  client = null;
@@ -9264,7 +9299,10 @@ class MikroTikSSHClient2 {
9264
9299
  let timer;
9265
9300
  let idleTimer;
9266
9301
  let hardTimer;
9302
+ let unwatch = () => {};
9303
+ const live = opts.onData ? new TextDecoder("utf-8") : undefined;
9267
9304
  const clearTimers = () => {
9305
+ opts.signal?.removeEventListener("abort", onAbort);
9268
9306
  if (openTimer)
9269
9307
  clearTimeout(openTimer);
9270
9308
  if (timer)
@@ -9273,9 +9311,7 @@ class MikroTikSSHClient2 {
9273
9311
  clearTimeout(idleTimer);
9274
9312
  if (hardTimer)
9275
9313
  clearTimeout(hardTimer);
9276
- connection.off("error", onConnectionError);
9277
- connection.off("end", onConnectionClose);
9278
- connection.off("close", onConnectionClose);
9314
+ unwatch();
9279
9315
  };
9280
9316
  const finish = () => {
9281
9317
  if (settled)
@@ -9300,15 +9336,7 @@ class MikroTikSSHClient2 {
9300
9336
  reject(e);
9301
9337
  };
9302
9338
  const uncertain = "Command outcome is unknown; do not retry a write blindly. Reconnect and read back the target state first.";
9303
- function onConnectionError(error) {
9304
- fail(new Error(`SSH connection lost: ${error.message}. ${uncertain}`));
9305
- }
9306
- function onConnectionClose() {
9307
- fail(new Error(`SSH connection closed before command completion. ${uncertain}`));
9308
- }
9309
- connection.on("error", onConnectionError);
9310
- connection.on("end", onConnectionClose);
9311
- connection.on("close", onConnectionClose);
9339
+ unwatch = watchConnection(connection, (lost) => fail(new Error(`${lost} ${uncertain}`)));
9312
9340
  openTimer = setTimeout(() => {
9313
9341
  fail(new Error(`SSH channel request timed out after ${this.opts.timeoutMs}ms. ${uncertain}`));
9314
9342
  if (this.client === connection)
@@ -9363,6 +9391,8 @@ class MikroTikSSHClient2 {
9363
9391
  if (settled)
9364
9392
  return;
9365
9393
  stdout.push(d);
9394
+ if (live)
9395
+ opts.onData?.(live.decode(d, { stream: true }));
9366
9396
  armIdle();
9367
9397
  }).stderr.on("data", (d) => {
9368
9398
  if (settled)
@@ -9371,6 +9401,19 @@ class MikroTikSSHClient2 {
9371
9401
  armIdle();
9372
9402
  });
9373
9403
  };
9404
+ function onAbort() {
9405
+ const channel = stream;
9406
+ finish();
9407
+ try {
9408
+ channel?.signal("INT");
9409
+ } catch {}
9410
+ try {
9411
+ channel?.close();
9412
+ } catch {}
9413
+ }
9414
+ if (opts.signal?.aborted)
9415
+ return onAbort();
9416
+ opts.signal?.addEventListener("abort", onAbort, { once: true });
9374
9417
  try {
9375
9418
  openChannel(command, onChannel);
9376
9419
  } catch (error) {
@@ -21054,13 +21097,13 @@ async function undoMigration(id, confirm, selected) {
21054
21097
  throw new Error("Undo lost Safe Mode or exceeded its time budget.");
21055
21098
  await checkedRead(item.undo, createContext(undefined, device));
21056
21099
  }
21057
- const beforeTarget = (await import("./library-jpmbkkz7.js")).openSnapshotStore;
21058
- const db = await beforeTarget((await import("./library-1swafsvq.js")).DEFAULT_SNAPSHOT_DB);
21100
+ const beforeTarget = (await import("./library-twpgma2r.js")).openSnapshotStore;
21101
+ const db = await beforeTarget((await import("./library-28w0j1ny.js")).DEFAULT_SNAPSHOT_DB);
21059
21102
  try {
21060
21103
  const original = db.get(p.snapshots.target);
21061
21104
  if (!original)
21062
21105
  throw new Error("Original target snapshot unavailable.");
21063
- const { normalizeExport } = await import("./library-1nhmbsv0.js");
21106
+ const { normalizeExport } = await import("./library-1sy0ph9r.js");
21064
21107
  if (normalizeExport((await migrationInventory(device)).export) !== normalizeExport(original.body))
21065
21108
  throw new Error("Target differs from its backup. Undo verification failed.");
21066
21109
  } finally {
@@ -33732,7 +33775,7 @@ var cache3 = null;
33732
33775
  async function gateway() {
33733
33776
  if (cache3)
33734
33777
  return cache3;
33735
- const { moduleCatalog } = await import("./library-0qn06vwr.js");
33778
+ const { moduleCatalog } = await import("./library-nt9fygza.js");
33736
33779
  const forIndex = [];
33737
33780
  const byName = new Map;
33738
33781
  for (const mod of moduleCatalog) {
@@ -59034,7 +59077,7 @@ var riskByTool = null;
59034
59077
  async function riskIndex() {
59035
59078
  if (riskByTool)
59036
59079
  return riskByTool;
59037
- const { moduleCatalog } = await import("./library-0qn06vwr.js");
59080
+ const { moduleCatalog } = await import("./library-nt9fygza.js");
59038
59081
  const index = new Map;
59039
59082
  for (const mod of moduleCatalog) {
59040
59083
  for (const tool of mod.tools)
@@ -3,7 +3,7 @@ import {
3
3
  moduleCatalog2,
4
4
  allToolModules2,
5
5
  selectToolModules2
6
- } from "./library-2wd7mt3g.js";
6
+ } from "./library-7qr2sc9x.js";
7
7
  export {
8
8
  allToolModules2 as allToolModules,
9
9
  moduleCatalog2 as moduleCatalog,
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  openSnapshotStore2
4
- } from "./library-2wd7mt3g.js";
4
+ } from "./library-7qr2sc9x.js";
5
5
  export {
6
6
  openSnapshotStore2 as openSnapshotStore
7
7
  };