@tikoci/centrs 0.1.1 → 0.1.3

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.
Files changed (95) hide show
  1. package/CHANGELOG.md +107 -2
  2. package/GLOSSARY.txt +87 -0
  3. package/README.md +25 -9
  4. package/SECURITY.md +3 -3
  5. package/commands/AGENTS.md +3 -2
  6. package/commands/api/AGENTS.md +212 -0
  7. package/commands/api/README.md +177 -0
  8. package/commands/api/examples.md +428 -0
  9. package/commands/btest/README.md +56 -31
  10. package/commands/btest/examples.md +35 -10
  11. package/commands/check/README.md +371 -53
  12. package/commands/check/examples.md +390 -0
  13. package/commands/devices/README.md +177 -37
  14. package/commands/devices/examples.md +148 -0
  15. package/commands/execute/README.md +48 -7
  16. package/commands/execute/examples.md +90 -6
  17. package/commands/retrieve/README.md +37 -51
  18. package/commands/retrieve/examples.md +40 -9
  19. package/commands/settings/README.md +286 -22
  20. package/commands/settings/examples.md +408 -0
  21. package/commands/terminal/README.md +6 -0
  22. package/commands/transfer/README.md +32 -2
  23. package/commands/transfer/examples.md +66 -0
  24. package/docs/CONSTITUTION.md +40 -15
  25. package/docs/MATRIX.md +69 -142
  26. package/docs/errors/README.md +2 -1
  27. package/docs/errors/cdb/empty-selection.md +19 -0
  28. package/docs/errors/input/incomplete-gps.md +9 -0
  29. package/docs/errors/input/invalid-altitude.md +9 -0
  30. package/docs/errors/input/invalid-bbox.md +9 -0
  31. package/docs/errors/input/invalid-coordinate.md +9 -0
  32. package/docs/errors/input/invalid-radius.md +9 -0
  33. package/docs/errors/internal/settings-failed.md +9 -0
  34. package/docs/errors/routeros/btest-connection-count-single-stream.md +22 -0
  35. package/docs/errors/routeros/btest-udp-tx-size-ignored.md +15 -0
  36. package/docs/errors/settings/consequential-value.md +26 -0
  37. package/docs/errors/settings/invalid-boolean.md +21 -3
  38. package/docs/errors/settings/invalid-format.md +18 -3
  39. package/docs/errors/settings/invalid-integer.md +18 -3
  40. package/docs/errors/settings/invalid-timeout.md +20 -3
  41. package/docs/errors/settings/invalid-via.md +22 -3
  42. package/docs/errors/settings/reserved-key.md +29 -0
  43. package/docs/errors/settings/skip-env-file-active.md +25 -0
  44. package/docs/errors/settings/unknown-key.md +25 -0
  45. package/docs/errors/usage/fanout-not-supported.md +16 -0
  46. package/docs/errors/usage/invalid-method.md +23 -0
  47. package/package.json +9 -9
  48. package/src/api-fanout.ts +454 -0
  49. package/src/api.ts +1627 -0
  50. package/src/btest.ts +61 -1
  51. package/src/cli/api.ts +660 -0
  52. package/src/cli/btest.ts +20 -2
  53. package/src/cli/common.ts +75 -0
  54. package/src/cli/devices.ts +235 -6
  55. package/src/cli/discover.ts +3 -1
  56. package/src/cli/execute.ts +107 -6
  57. package/src/cli/mcp.ts +8 -1
  58. package/src/cli/retrieve.ts +135 -90
  59. package/src/cli/selection.ts +200 -0
  60. package/src/cli/settings.ts +286 -0
  61. package/src/cli/terminal.ts +22 -7
  62. package/src/cli/transfer.ts +171 -47
  63. package/src/cli.ts +29 -0
  64. package/src/core/error-catalog.ts +69 -0
  65. package/src/core/fanout.ts +301 -0
  66. package/src/core/inspect.ts +170 -0
  67. package/src/devices.ts +212 -20
  68. package/src/discover.ts +7 -2
  69. package/src/execute-fanout.ts +438 -0
  70. package/src/execute.ts +134 -70
  71. package/src/index.ts +166 -9
  72. package/src/mcp/config.ts +12 -2
  73. package/src/mcp/tools.ts +137 -2
  74. package/src/protocols/adapter.ts +357 -9
  75. package/src/protocols/btest-session.ts +279 -46
  76. package/src/protocols/btest.ts +6 -2
  77. package/src/protocols/index.ts +11 -5
  78. package/src/protocols/native-api.ts +223 -30
  79. package/src/resolver/cdb.ts +10 -2
  80. package/src/resolver/comment-kv.ts +58 -4
  81. package/src/resolver/config-file.ts +136 -0
  82. package/src/resolver/facts.ts +78 -0
  83. package/src/resolver/geo.ts +453 -0
  84. package/src/resolver/index.ts +46 -0
  85. package/src/resolver/mac.ts +12 -3
  86. package/src/resolver/selection.ts +304 -0
  87. package/src/resolver/settings.ts +54 -5
  88. package/src/resolver/target.ts +20 -2
  89. package/src/retrieve-fanout.ts +232 -268
  90. package/src/retrieve.ts +69 -94
  91. package/src/settings.ts +1078 -0
  92. package/src/terminal.ts +11 -1
  93. package/src/transfer-fanout.ts +527 -0
  94. package/src/transfer.ts +61 -11
  95. package/commands/stream/README.md +0 -70
package/src/btest.ts CHANGED
@@ -138,6 +138,8 @@ export interface BtestClientData {
138
138
  stopReason: BtestStopReason;
139
139
  serverUdpPort?: number;
140
140
  clientUdpPort?: number;
141
+ /** TCP data connections actually driven (1 + joined secondaries). */
142
+ activeConnections: number;
141
143
  }
142
144
 
143
145
  export interface BtestClientOperationMeta {
@@ -215,9 +217,37 @@ export async function btestClient(
215
217
  controlPort,
216
218
  };
217
219
 
220
+ const warnings: {
221
+ code: string;
222
+ message: string;
223
+ context?: Record<string, unknown>;
224
+ }[] = [];
225
+
218
226
  try {
219
227
  validateClientOptions(request);
220
228
 
229
+ // The btest wire command carries a single tx-size field; --remote-udp-tx-size
230
+ // and --local-udp-tx-size map to it separately only for receive (remote wins)
231
+ // and transmit (local wins). For both, localUdpTxSize wins and
232
+ // remoteUdpTxSize is silently discarded — warn when they differ so the user
233
+ // knows which size the server will actually use.
234
+ if (
235
+ protocol === "udp" &&
236
+ direction === "both" &&
237
+ request.remoteUdpTxSize !== undefined &&
238
+ request.localUdpTxSize !== undefined &&
239
+ request.remoteUdpTxSize !== request.localUdpTxSize
240
+ ) {
241
+ warnings.push({
242
+ code: "routeros/btest-udp-tx-size-ignored",
243
+ message: `--remote-udp-tx-size (${request.remoteUdpTxSize}) is ignored for --direction both; the btest wire protocol carries a single tx-size and --local-udp-tx-size (${request.localUdpTxSize}) is used for both directions.`,
244
+ context: {
245
+ ignored: request.remoteUdpTxSize,
246
+ used: request.localUdpTxSize,
247
+ },
248
+ });
249
+ }
250
+
221
251
  const cdbResolution = await resolveCdb(
222
252
  {
223
253
  targetInput: request.targetInput,
@@ -273,6 +303,9 @@ export async function btestClient(
273
303
  ? { statusIntervalMs: request.intervalMs }
274
304
  : {}),
275
305
  ...(txSize !== undefined ? { txSize } : {}),
306
+ ...(request.connectionCount !== undefined
307
+ ? { tcpConnectionCount: request.connectionCount }
308
+ : {}),
276
309
  ...(request.localTxSpeed !== undefined
277
310
  ? { localTxSpeed: request.localTxSpeed }
278
311
  : {}),
@@ -301,6 +334,7 @@ export async function btestClient(
301
334
  txTotalAvgBps: secs > 0 ? (summary.totalTxBytes * 8) / secs : 0,
302
335
  rxTotalAvgBps: secs > 0 ? (summary.totalRxBytes * 8) / secs : 0,
303
336
  stopReason: summary.stopReason,
337
+ activeConnections: summary.activeConnections,
304
338
  };
305
339
  if (summary.username !== undefined) data.user = summary.username;
306
340
  if (summary.serverUdpPort !== undefined)
@@ -308,10 +342,36 @@ export async function btestClient(
308
342
  if (summary.clientUdpPort !== undefined)
309
343
  data.clientUdpPort = summary.clientUdpPort;
310
344
 
345
+ // TCP multi-connection: centrs now opens the negotiated extra data
346
+ // connections (fan-out). It still degrades to a single stream when the server
347
+ // negotiates no session token — notably authenticated (EC-SRP5) sessions,
348
+ // whose post-auth token centrs does not yet capture. Warn only when the
349
+ // realized fan-out fell short of the request, with the actual count.
350
+ if (
351
+ protocol === "tcp" &&
352
+ request.connectionCount !== undefined &&
353
+ request.connectionCount > 1 &&
354
+ summary.activeConnections < request.connectionCount
355
+ ) {
356
+ const single = summary.activeConnections === 1;
357
+ warnings.push({
358
+ code: "routeros/btest-connection-count-single-stream",
359
+ message: `--connection-count (${request.connectionCount}) requested, but ${summary.activeConnections} TCP data connection(s) are active${
360
+ single && summary.authKind !== "none"
361
+ ? " — authenticated multi-connection is not yet supported"
362
+ : ""
363
+ }; throughput will not scale to the full count.`,
364
+ context: {
365
+ requested: request.connectionCount,
366
+ active: summary.activeConnections,
367
+ },
368
+ });
369
+ }
370
+
311
371
  return {
312
372
  ok: true,
313
373
  data,
314
- warnings: [],
374
+ warnings: warnings.map((w) => ({ ...w })),
315
375
  tips: [],
316
376
  meta: clientMeta(target.host, controlPort, operation, auth.username),
317
377
  };