asyx 0.5.9 → 0.6.1

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 (88) hide show
  1. package/README.md +73 -9
  2. package/SECURITY.md +5 -3
  3. package/package.json +13 -23
  4. package/src/commands/name.js +23 -0
  5. package/src/commands/reject-messages.js +54 -0
  6. package/src/commands/setup.js +98 -102
  7. package/src/commands/tunnel.js +279 -2425
  8. package/src/lib/naming.js +81 -0
  9. package/src/main.js +9 -1
  10. package/vendor/tunnel-core/dist/control-plane/MqttControlPlaneClient.d.ts +260 -0
  11. package/vendor/tunnel-core/dist/control-plane/MqttControlPlaneClient.js +1088 -0
  12. package/vendor/tunnel-core/dist/control-plane/MqttControlPlaneTransport.d.ts +79 -0
  13. package/vendor/tunnel-core/dist/control-plane/MqttControlPlaneTransport.js +138 -0
  14. package/vendor/tunnel-core/dist/control-plane/session.d.ts +50 -0
  15. package/vendor/tunnel-core/dist/control-plane/session.js +115 -0
  16. package/vendor/tunnel-core/dist/errors.d.ts +49 -0
  17. package/vendor/tunnel-core/dist/errors.js +53 -0
  18. package/vendor/tunnel-core/dist/flows/http.d.ts +50 -0
  19. package/vendor/tunnel-core/dist/flows/http.js +585 -0
  20. package/vendor/tunnel-core/dist/flows/tcp.d.ts +60 -0
  21. package/vendor/tunnel-core/dist/flows/tcp.js +546 -0
  22. package/vendor/tunnel-core/dist/flows/udp.d.ts +41 -0
  23. package/vendor/tunnel-core/dist/flows/udp.js +376 -0
  24. package/vendor/tunnel-core/dist/lib/adapt-logger.d.ts +2 -0
  25. package/vendor/tunnel-core/dist/lib/adapt-logger.js +6 -0
  26. package/vendor/tunnel-core/dist/lib/fingerprint.d.ts +13 -0
  27. package/vendor/tunnel-core/dist/lib/fingerprint.js +95 -0
  28. package/vendor/tunnel-core/dist/lib/jwt-verifier.d.ts +27 -0
  29. package/vendor/tunnel-core/dist/lib/jwt-verifier.js +230 -0
  30. package/vendor/tunnel-core/dist/lib/logger.d.ts +9 -0
  31. package/vendor/tunnel-core/dist/lib/logger.js +58 -0
  32. package/vendor/tunnel-core/dist/lib/refresh-helpers.d.ts +16 -0
  33. package/vendor/tunnel-core/dist/lib/refresh-helpers.js +66 -0
  34. package/vendor/tunnel-core/dist/lifecycle.d.ts +24 -0
  35. package/vendor/tunnel-core/dist/lifecycle.js +29 -0
  36. package/vendor/tunnel-core/dist/mqtt/awaiter-map.d.ts +56 -0
  37. package/vendor/tunnel-core/dist/mqtt/awaiter-map.js +227 -0
  38. package/vendor/tunnel-core/dist/mqtt/events/handlers.d.ts +58 -0
  39. package/vendor/tunnel-core/dist/mqtt/events/handlers.js +250 -0
  40. package/vendor/tunnel-core/dist/mqtt/events/index.d.ts +1 -0
  41. package/vendor/tunnel-core/dist/mqtt/events/index.js +191 -0
  42. package/vendor/tunnel-core/dist/mqtt/events/schemas.d.ts +498 -0
  43. package/vendor/tunnel-core/dist/mqtt/events/schemas.js +51 -0
  44. package/vendor/tunnel-core/dist/mqtt/ingress.d.ts +63 -0
  45. package/vendor/tunnel-core/dist/mqtt/ingress.js +170 -0
  46. package/vendor/tunnel-core/dist/state/assignment.d.ts +122 -0
  47. package/vendor/tunnel-core/dist/state/assignment.js +322 -0
  48. package/vendor/tunnel-core/dist/state/instance-registry.d.ts +88 -0
  49. package/{src → vendor/tunnel-core/dist}/state/instance-registry.js +38 -53
  50. package/vendor/tunnel-core/dist/tcp-v1/framing.d.ts +43 -0
  51. package/vendor/tunnel-core/dist/tcp-v1/framing.js +157 -0
  52. package/vendor/tunnel-core/dist/tunnel/http-tunnel.d.ts +137 -0
  53. package/vendor/tunnel-core/dist/tunnel/http-tunnel.js +1591 -0
  54. package/vendor/tunnel-core/dist/tunnel/httpws-constants.d.ts +13 -0
  55. package/{src → vendor/tunnel-core/dist}/tunnel/httpws-constants.js +5 -7
  56. package/vendor/tunnel-core/dist/tunnel/reconnect.d.ts +76 -0
  57. package/vendor/tunnel-core/dist/tunnel/reconnect.js +183 -0
  58. package/vendor/tunnel-core/dist/tunnel/request-sink.d.ts +40 -0
  59. package/vendor/tunnel-core/dist/tunnel/request-sink.js +39 -0
  60. package/vendor/tunnel-core/dist/tunnel/tcp-tunnel.d.ts +89 -0
  61. package/vendor/tunnel-core/dist/tunnel/tcp-tunnel.js +838 -0
  62. package/vendor/tunnel-core/dist/tunnel/udp-tunnel.d.ts +90 -0
  63. package/vendor/tunnel-core/dist/tunnel/udp-tunnel.js +737 -0
  64. package/vendor/tunnel-core/dist/tunnel/ws-control.d.ts +22 -0
  65. package/vendor/tunnel-core/dist/tunnel/ws-control.js +124 -0
  66. package/vendor/tunnel-core/dist/types.d.ts +24 -0
  67. package/vendor/tunnel-core/dist/types.js +2 -0
  68. package/vendor/tunnel-core/dist/udp-v1/framing.d.ts +41 -0
  69. package/vendor/tunnel-core/dist/udp-v1/framing.js +158 -0
  70. package/vendor/tunnel-core/package.json +34 -0
  71. package/src/control-plane/MqttControlPlaneClient.js +0 -1196
  72. package/src/control-plane/MqttControlPlaneTransport.js +0 -150
  73. package/src/lib/fingerprint.js +0 -115
  74. package/src/lib/jwt-verifier.js +0 -260
  75. package/src/lib/logger.js +0 -62
  76. package/src/mqtt/awaiter-map.js +0 -247
  77. package/src/mqtt/events/handlers.js +0 -300
  78. package/src/mqtt/events/index.js +0 -222
  79. package/src/mqtt/events/schemas.js +0 -58
  80. package/src/mqtt/ingress.js +0 -182
  81. package/src/state/assignment.js +0 -333
  82. package/src/tcp-v1/framing.js +0 -203
  83. package/src/tunnel/http-tunnel.js +0 -1738
  84. package/src/tunnel/reconnect.js +0 -182
  85. package/src/tunnel/tcp-tunnel.js +0 -944
  86. package/src/tunnel/udp-tunnel.js +0 -813
  87. package/src/tunnel/ws-control.js +0 -135
  88. package/src/udp-v1/framing.js +0 -203
@@ -0,0 +1,81 @@
1
+ // Story 2.1 r3: hostname choice for `asyx setup` and `asyx name check`.
2
+ // The server decides (GET /www/names/check, POST /www/sts/authorize); these checks only give an early,
3
+ // clear answer in the terminal. The terminal never prompts (4.7 c5).
4
+ import os from 'node:os';
5
+ import { createHash } from 'node:crypto';
6
+
7
+ export const ZONE = 'tunnel.asyx.ai';
8
+ export const LABEL_RE = /^[a-z0-9](?:[a-z0-9-]{1,28}[a-z0-9])$/; // same rule as the server (4.3 c3)
9
+ export const NAMES_URL = process.env.ASYX_NAMES_URL || 'https://www.asyx.ai/www/names/check';
10
+
11
+ // Exit codes (documented in webui/content/docs/ai-agent-checklist.mdx)
12
+ export const EXIT = { OK: 0, FAILED: 1, USAGE: 2, NAME_UNAVAILABLE: 3 };
13
+
14
+ /** "Orders-API.tunnel.asyx.ai" -> "orders-api"; returns the label or null when it is not valid. */
15
+ export function normalizeLabel(input) {
16
+ let l = String(input || '').trim().toLowerCase();
17
+ if (l.endsWith(`.${ZONE}`)) l = l.slice(0, -(ZONE.length + 1));
18
+ return LABEL_RE.test(l) ? l : null;
19
+ }
20
+
21
+ /** Parses `asyx setup` options. Returns { hostname, random, json } or { error }. */
22
+ export function parseSetupArgs(argv) {
23
+ const out = { hostname: null, random: false, json: false };
24
+ for (let i = 0; i < argv.length; i++) {
25
+ const a = argv[i];
26
+ if (a === 'setup') continue;
27
+ if (a === '--json') out.json = true;
28
+ else if (a === '--random') out.random = true;
29
+ else if (a === '--hostname' || a.startsWith('--hostname=')) {
30
+ const v = a.includes('=') ? a.slice(a.indexOf('=') + 1) : argv[++i];
31
+ if (!v) return { error: '--hostname needs a name, for example --hostname orders-api' };
32
+ const label = normalizeLabel(v);
33
+ if (!label) return { error: `"${v}" is not a valid name: use 3-30 characters a-z, 0-9 and hyphens, starting and ending with a letter or digit` };
34
+ out.hostname = label;
35
+ } else return { error: `unknown option ${a}` };
36
+ }
37
+ if (out.hostname && out.random) return { error: 'use either --hostname or --random, not both' };
38
+ return out;
39
+ }
40
+
41
+ /** The approval link. v=2 tells the page this CLI supports device naming (2.1 r3). */
42
+ export function approvalUrl(base, { clientId, ticket, hostname, random, machine = os.hostname() }) {
43
+ const q = new URLSearchParams({ clientId, ticket, v: '2' });
44
+ if (machine) q.set('machine', String(machine).slice(0, 64));
45
+ if (hostname) q.set('hostname', hostname);
46
+ if (random) q.set('random', '1');
47
+ return `${base}?${q.toString()}`;
48
+ }
49
+
50
+ /** Asks the server whether <label>.tunnel.asyx.ai can be claimed. Throws on network/service errors. */
51
+ export async function checkName(label, { fetchImpl = fetch, url = NAMES_URL } = {}) {
52
+ const res = await fetchImpl(`${url}?label=${encodeURIComponent(label)}`, { headers: { accept: 'application/json' } });
53
+ if (res.status === 429) { const e = new Error('too many name checks, try again in a minute'); e.code = 'rate_limited'; throw e; }
54
+ if (!res.ok) { const e = new Error(`name check failed (HTTP ${res.status})`); e.code = 'service_error'; throw e; }
55
+ return res.json();
56
+ }
57
+
58
+ const REASONS = {
59
+ hostname_taken: 'is taken',
60
+ hostname_reserved: 'is reserved',
61
+ hostname_cooling_down: 'was released recently and is not available yet',
62
+ hostname_invalid: 'is not a valid name',
63
+ };
64
+ export function describeAnswer(a) {
65
+ if (a.status === 'available') return `${a.hostname} is available`;
66
+ const name = a.hostname || a.label;
67
+ const s = a.suggestions?.length ? ` Try: ${a.suggestions.join(', ')}` : '';
68
+ return `${name} ${REASONS[a.status] || 'is not available'}.${s}`;
69
+ }
70
+
71
+ /** Defect 11.25 / Story 4.7 c6: the short code the terminal shows and the approval page asks for.
72
+ * Derived from the setup ticket, so the CLI and the server agree without storing anything; it is never
73
+ * put in the approval link. Alphabet without look-alikes (no I, L, O, U, 0, 1). */
74
+ export const SETUP_CODE_ALPHABET = "ABCDEFGHJKMNPQRSTVWXYZ23456789";
75
+ export function setupCode(ticket) {
76
+ const h = createHash("sha256").update(`asyx-setup-code|${ticket}`).digest();
77
+ let s = "";
78
+ for (let i = 0; i < 6; i++) s += SETUP_CODE_ALPHABET[h[i] % SETUP_CODE_ALPHABET.length];
79
+ return `${s.slice(0, 3)}-${s.slice(3)}`;
80
+ }
81
+ export const normalizeCode = (c) => String(c || "").toUpperCase().replace(/[^A-Z0-9]/g, "");
package/src/main.js CHANGED
@@ -7,6 +7,8 @@ const require = createRequire(import.meta.url);
7
7
  const pkg = require("../package.json");
8
8
 
9
9
  export const CLI_VERSION = pkg.version;
10
+ // Story 2.1 c7: tunnel-core adds this to every cmd/open.
11
+ if (!process.env.ASYX_CLIENT_VERSION) process.env.ASYX_CLIENT_VERSION = `asyx-cli@${CLI_VERSION}`;
10
12
  export const CLI_DESCRIPTION = pkg.description;
11
13
 
12
14
  // Unified error handling
@@ -28,12 +30,15 @@ async function run() {
28
30
  Usage: asyx <command>
29
31
 
30
32
  Commands:
31
- setup Enroll this machine (opens your browser once)
33
+ setup Enroll this machine (prints an approval link; opens your browser)
34
+ name check <name> Is <name>.tunnel.asyx.ai available? (works before setup)
32
35
  tunnel Open an HTTP, TCP or UDP tunnel to a local port
33
36
  help Show this help
34
37
 
35
38
  Examples:
36
39
  asyx setup
40
+ asyx setup --hostname orders-api (or --random; add --json for agents)
41
+ asyx name check orders-api
37
42
  asyx tunnel --http --port 3000
38
43
  asyx tunnel --tcp --port 5432
39
44
  asyx tunnel --udp --port 27015
@@ -49,6 +54,9 @@ Usage: asyx <command>
49
54
  }
50
55
  if (cmd === "setup") {
51
56
  cmdSetup(process.argv.slice(2)).catch(handleFailure('Setup'));
57
+ } else if (cmd === "name") {
58
+ const { default: cmdName } = await import("./commands/name.js");
59
+ cmdName(process.argv.slice(3)).then((code) => process.exit(code), handleFailure('Name check'));
52
60
  } else if (cmd === "sts") {
53
61
  cmdSts(process.argv.slice(2)).catch(handleFailure('STS'));
54
62
  } else if (cmd === "mqtt") {
@@ -0,0 +1,260 @@
1
+ /**
2
+ * @typedef {'soft' | 'hard' | 'transient'} MqttFaultKind
3
+ */
4
+ /**
5
+ * @typedef {Object} MqttControlPlaneClientOptions
6
+ * @property {string} url - MQTT broker URL (e.g., 'wss://...')
7
+ * @property {string} baseClientId - Base client ID (e.g., 'cli_F285616B53CE')
8
+ * @property {Object} [mqttOptions] - Additional mqtt.js options (cert, key, ca, etc.)
9
+ * @property {(client: any) => void | Promise<void>} [onConnected] - Called after successful connect
10
+ * @property {(reason: string) => void} [onOffline] - Called when connection goes offline
11
+ * @property {(reason: string, err?: unknown) => void} [onFatalError] - Called when we give up due to JWT expiry or unrecoverable error
12
+ * @property {() => Promise<number>} onRefreshLease - Async refresh function. Must publish the refresh request over MQTT and resolve with new exp (ms since epoch). Throw on hard failure.
13
+ * @property {number} [refreshEarlySeconds] - Seconds before exp when we should start refresh (e.g. 0.75 * ttl, default: 675s for 15min TTL)
14
+ * @property {number} [maxReconnectDelayMs] - Max reconnect delay in ms (default 5000)
15
+ * @property {'unique' | 'legacy'} [mode] - Mode: 'unique' (default) or 'legacy'
16
+ * @property {Object} [logger] - Logger for structured logging
17
+ * @property {any} [mqttLib] - Optional mqtt library for dependency injection (defaults to real mqtt)
18
+ * @property {any} [ulidLib] - Optional ulid library for dependency injection (defaults to real ulid)
19
+ */
20
+ export class MqttControlPlaneClient {
21
+ /**
22
+ * @param {MqttControlPlaneClientOptions} opts
23
+ */
24
+ constructor(opts: MqttControlPlaneClientOptions);
25
+ url: string;
26
+ baseClientId: string;
27
+ mqttOptions: any;
28
+ onConnected: (client: any) => void | Promise<void>;
29
+ onOffline: (reason: string) => void;
30
+ onFatalError: (reason: string, err?: unknown) => void;
31
+ onRefreshLease: () => Promise<number>;
32
+ refreshEarlySeconds: number;
33
+ maxReconnectDelayMs: number;
34
+ mode: "unique" | "legacy";
35
+ logger: any;
36
+ mqtt: any;
37
+ ulidLib: any;
38
+ currentClientId: string;
39
+ client: any;
40
+ forceClosing: any;
41
+ shuttingDown: boolean;
42
+ mqttOnline: boolean;
43
+ hardErrorCount: number;
44
+ transientErrorCount: number;
45
+ reconnectTimer: any;
46
+ connectStartTime: number;
47
+ reconnectAttempts: number;
48
+ maxReconnectAttempts: number;
49
+ refreshTimer: any;
50
+ refreshPending: boolean;
51
+ refreshDeadlineMs: number;
52
+ currentLeaseId: string;
53
+ rearmTimeout: any;
54
+ flushPendingRefreshTimer: any;
55
+ watchdogTimer: NodeJS.Timeout;
56
+ WATCHDOG_TIMEOUT_MS: number;
57
+ _pendingMessageHandler: (topic: any, payload: any, packet: any) => void;
58
+ /**
59
+ * Connect to MQTT broker (initial connection).
60
+ * Returns a promise that resolves when connected or rejects on fatal error.
61
+ * @returns {Promise<void>}
62
+ */
63
+ connect(): Promise<void>;
64
+ /**
65
+ * Disconnect and clean up all timers.
66
+ * @param {Object} [opts] - Options
67
+ * @param {boolean} [opts.preserveState] - If true, don't set shuttingDown (for forceReconnect)
68
+ * @returns {Promise<void>}
69
+ */
70
+ disconnect(opts?: {
71
+ preserveState?: boolean;
72
+ }): Promise<void>;
73
+ /**
74
+ * Force a manual reconnect (tear down and reconnect).
75
+ * Used when we need a fresh MQTT session (e.g., after ack timeout).
76
+ * @param {string} reason - Reason for reconnect
77
+ * @returns {Promise<void>}
78
+ */
79
+ forceReconnect(reason?: string): Promise<void>;
80
+ /**
81
+ * Publish a message.
82
+ * @param {string} topic
83
+ * @param {string | Buffer} payload
84
+ * @param {Object} [opts]
85
+ * @returns {Promise<void>}
86
+ */
87
+ publish(topic: string, payload: string | Buffer, opts?: any): Promise<void>;
88
+ /**
89
+ * Subscribe to a topic.
90
+ * @param {string} topic
91
+ * @param {number} qos
92
+ * @returns {Promise<void>}
93
+ */
94
+ subscribe(topic: string, qos?: number): Promise<void>;
95
+ /**
96
+ * Schedule a JWT refresh based on an expiration timestamp (ms since epoch).
97
+ * @param {number} expMs - Expiration timestamp in milliseconds since epoch
98
+ * @param {string} [leaseId] - Optional lease ID for correlation
99
+ */
100
+ scheduleRefresh(expMs: number, leaseId?: string): void;
101
+ /**
102
+ * Check if MQTT is online.
103
+ * @returns {boolean}
104
+ */
105
+ isOnline(): boolean;
106
+ /**
107
+ * Get current client ID.
108
+ * @returns {string}
109
+ */
110
+ getClientId(): string;
111
+ /**
112
+ * Set message handler (for Transport interface).
113
+ * Converts mqtt.js format (topic, payload, packet) to MqttCore format {topic, payload: Uint8Array}
114
+ * @param {(message: {topic: string, payload: Uint8Array}) => void} handler
115
+ */
116
+ setMessageHandler(handler: (message: {
117
+ topic: string;
118
+ payload: Uint8Array;
119
+ }) => void): void;
120
+ /**
121
+ * Generate client ID based on mode.
122
+ * @returns {string}
123
+ */
124
+ makeClientId(): string;
125
+ /**
126
+ * Connect with a new client (initial or after fault).
127
+ * @param {boolean} initial - true for first connect, false for reconnect
128
+ * @returns {Promise<void>}
129
+ */
130
+ connectWithNewClient(initial?: boolean): Promise<void>;
131
+ /**
132
+ * Classify MQTT fault as hard or soft.
133
+ * @param {string} event - Event type: 'error', 'close', 'end'
134
+ * @param {any} [err] - Error object
135
+ * @param {number} [closeCode] - MQTT close code
136
+ * @param {boolean} [beforeConnect] - true if fault occurred before connect event
137
+ * @returns {MqttFaultKind}
138
+ */
139
+ classifyMqttFault(event: string, err?: any, closeCode?: number, beforeConnect?: boolean): MqttFaultKind;
140
+ /**
141
+ * Handle a fault (soft or hard).
142
+ * Hard faults trigger clientId rotation and immediate reconnect.
143
+ * @param {MqttFaultKind} kind
144
+ * @param {any} [err]
145
+ */
146
+ handleFault(kind: MqttFaultKind, err?: any): void;
147
+ /**
148
+ * Force close the current client.
149
+ */
150
+ forceCloseClient(): void;
151
+ /**
152
+ * Schedule reconnect with jittered backoff.
153
+ * @param {boolean} immediate - true for hard faults (ECONNRESET, etc.), false for soft
154
+ * @param {{ transient?: boolean }} [options] - transient resolver failures use a growing delay
155
+ */
156
+ scheduleReconnect(immediate: boolean, options?: {
157
+ transient?: boolean;
158
+ }): void;
159
+ /**
160
+ * Start watchdog timer to detect stuck connections.
161
+ */
162
+ startWatchdog(): void;
163
+ /**
164
+ * Clear watchdog timer.
165
+ */
166
+ clearWatchdog(): void;
167
+ /**
168
+ * Clear reconnect timer.
169
+ */
170
+ clearReconnectTimer(): void;
171
+ /**
172
+ * Clear refresh timer.
173
+ */
174
+ clearRefreshTimer(): void;
175
+ /**
176
+ * Clear rearm timeout (QPA-CLI-08).
177
+ */
178
+ clearRearmTimeout(): void;
179
+ /**
180
+ * Clear flush pending refresh timer.
181
+ */
182
+ clearFlushPendingRefreshTimer(): void;
183
+ /**
184
+ * Attempt to refresh the lease token.
185
+ * @param {string} reason - Reason for refresh (e.g., 'scheduled', 'pending_after_reconnect')
186
+ */
187
+ refreshLeaseToken(reason: string): Promise<void>;
188
+ /**
189
+ * Check if error is an offline/connection error (should buffer refresh).
190
+ * @param {any} err
191
+ * @returns {boolean}
192
+ */
193
+ isOfflineError(err: any): boolean;
194
+ /**
195
+ * QPA-CLI-08: Ensure a refresh is scheduled after reconnect.
196
+ * Checks if refresh is pending or if we need to re-arm a refresh.
197
+ */
198
+ ensureRefreshScheduled(): void;
199
+ /**
200
+ * Handle fatal error (JWT expired, max retries, etc.).
201
+ * @param {string} reason
202
+ * @param {any} [err]
203
+ */
204
+ handleFatal(reason: string, err?: any): void;
205
+ }
206
+ export type MqttFaultKind = "soft" | "hard" | "transient";
207
+ export type MqttControlPlaneClientOptions = {
208
+ /**
209
+ * - MQTT broker URL (e.g., 'wss://...')
210
+ */
211
+ url: string;
212
+ /**
213
+ * - Base client ID (e.g., 'cli_F285616B53CE')
214
+ */
215
+ baseClientId: string;
216
+ /**
217
+ * - Additional mqtt.js options (cert, key, ca, etc.)
218
+ */
219
+ mqttOptions?: any;
220
+ /**
221
+ * - Called after successful connect
222
+ */
223
+ onConnected?: (client: any) => void | Promise<void>;
224
+ /**
225
+ * - Called when connection goes offline
226
+ */
227
+ onOffline?: (reason: string) => void;
228
+ /**
229
+ * - Called when we give up due to JWT expiry or unrecoverable error
230
+ */
231
+ onFatalError?: (reason: string, err?: unknown) => void;
232
+ /**
233
+ * - Async refresh function. Must publish the refresh request over MQTT and resolve with new exp (ms since epoch). Throw on hard failure.
234
+ */
235
+ onRefreshLease: () => Promise<number>;
236
+ /**
237
+ * - Seconds before exp when we should start refresh (e.g. 0.75 * ttl, default: 675s for 15min TTL)
238
+ */
239
+ refreshEarlySeconds?: number;
240
+ /**
241
+ * - Max reconnect delay in ms (default 5000)
242
+ */
243
+ maxReconnectDelayMs?: number;
244
+ /**
245
+ * - Mode: 'unique' (default) or 'legacy'
246
+ */
247
+ mode?: "unique" | "legacy";
248
+ /**
249
+ * - Logger for structured logging
250
+ */
251
+ logger?: any;
252
+ /**
253
+ * - Optional mqtt library for dependency injection (defaults to real mqtt)
254
+ */
255
+ mqttLib?: any;
256
+ /**
257
+ * - Optional ulid library for dependency injection (defaults to real ulid)
258
+ */
259
+ ulidLib?: any;
260
+ };