@amigo-ai/platform-sdk 0.78.1 → 0.80.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.
Files changed (36) hide show
  1. package/api.md +0 -2
  2. package/dist/core/reconnecting-websocket.js +142 -29
  3. package/dist/core/reconnecting-websocket.js.map +1 -1
  4. package/dist/index.cjs +65 -40
  5. package/dist/index.cjs.map +2 -2
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.mjs +65 -40
  8. package/dist/index.mjs.map +2 -2
  9. package/dist/resources/channels/index.js.map +1 -1
  10. package/dist/resources/channels/ses-setup.js +0 -17
  11. package/dist/resources/channels/ses-setup.js.map +1 -1
  12. package/dist/resources/observers.js.map +1 -1
  13. package/dist/types/core/reconnecting-websocket.d.ts +57 -7
  14. package/dist/types/core/reconnecting-websocket.d.ts.map +1 -1
  15. package/dist/types/generated/api.d.ts +126 -84
  16. package/dist/types/generated/api.d.ts.map +1 -1
  17. package/dist/types/index.d.cts +2 -2
  18. package/dist/types/index.d.cts.map +1 -1
  19. package/dist/types/index.d.ts +2 -2
  20. package/dist/types/index.d.ts.map +1 -1
  21. package/dist/types/resources/channels/index.d.ts +1 -1
  22. package/dist/types/resources/channels/index.d.ts.map +1 -1
  23. package/dist/types/resources/channels/ses-setup.d.ts +0 -12
  24. package/dist/types/resources/channels/ses-setup.d.ts.map +1 -1
  25. package/dist/types/resources/external-integrations.d.ts.map +1 -1
  26. package/dist/types/resources/intake.d.ts.map +1 -1
  27. package/dist/types/resources/integrations.d.ts.map +1 -1
  28. package/dist/types/resources/metrics.d.ts.map +1 -1
  29. package/dist/types/resources/observers.d.ts +7 -4
  30. package/dist/types/resources/observers.d.ts.map +1 -1
  31. package/dist/types/resources/operators.d.ts.map +1 -1
  32. package/dist/types/resources/services.d.ts.map +1 -1
  33. package/dist/types/resources/settings.d.ts.map +1 -1
  34. package/dist/types/resources/surfaces.d.ts.map +1 -1
  35. package/dist/types/resources/world.d.ts.map +1 -1
  36. package/package.json +1 -1
package/api.md CHANGED
@@ -266,8 +266,6 @@ All workspace-scoped resources also expose `withOptions(options)`.
266
266
  **`channels.sesSetup`**
267
267
 
268
268
  - `create`
269
- - `list`
270
- - `listAutoPaging`
271
269
  - `get`
272
270
  - `verify`
273
271
  - `delete`
@@ -6,11 +6,13 @@
6
6
  * lifecycle requirements:
7
7
  *
8
8
  * * Resume on transient drops with exponential backoff + full jitter
9
- * * Treat 4001 (client error) and 4403 (auth) close codes as terminal
10
- * * Treat 4029 (rate limit / cap) as terminal-but-retryable on a slow timer
9
+ * * Treat permanent-rejection close codes (1008 / 3003 / 4001 / 4003 /
10
+ * 4004 / 4100 / 4403) as terminal fail fast, do not loop
11
+ * * Treat 4029 / 1013 (rate limit / cap) as reconnectable on a slow floor,
12
+ * surfacing a ``rate_limited`` reconnect reason
11
13
  * * Watchdog the connection: if no message arrives within an idle window,
12
14
  * the upstream is dead even if the TCP socket has not closed; force a
13
- * reconnect
15
+ * reconnect (with a NON-terminal close code so the loop actually rebuilds)
14
16
  * * Surface every typed message through ``onMessage`` and every state
15
17
  * transition through ``onStateChange``
16
18
  *
@@ -43,16 +45,31 @@ export class ReconnectingWebSocketError extends Error {
43
45
  * Close codes that should NEVER be retried. The server is telling us the
44
46
  * connection cannot succeed regardless of how many times we try.
45
47
  *
46
- * 1008 (policy violation), 4001 (client error / bad params), 4003
47
- * (forbidden), 4100 (auth / not authenticated, used by some platform
48
+ * 1008 (policy violation), 3003 (workspace mismatch the call/session does
49
+ * not belong to the authenticated workspace; retrying replays the same
50
+ * mismatch), 4001 (client error / bad params), 4003 (forbidden), 4004 (call
51
+ * / session not found — the target no longer exists, every retry 404s the
52
+ * same way), 4100 (auth / not authenticated, used by some platform
48
53
  * endpoints), 4403 (forbidden — used by platform-api session-connect for
49
54
  * auth and origin rejection).
50
55
  */
51
- const TERMINAL_CLOSE_CODES = new Set([1008, 4001, 4003, 4100, 4403]);
56
+ const TERMINAL_CLOSE_CODES = new Set([1008, 3003, 4001, 4003, 4004, 4100, 4403]);
52
57
  /**
53
- * Close codes that are terminal-but-rate-limited. The reconnect loop honors
54
- * a longer floor (``RATE_LIMITED_FLOOR_MS``) before retrying so the client
55
- * does not amplify the problem it just hit.
58
+ * Dedicated NON-terminal close code the idle watchdog uses to force-close a
59
+ * stalled socket. It is deliberately OUTSIDE {@link TERMINAL_CLOSE_CODES}
60
+ * the watchdog's entire purpose is to FORCE a reconnect, so closing with a
61
+ * terminal code (the original bug) made the loop give up instead. Picked in
62
+ * the application-private 4000–4999 range, clear of the platform's assigned
63
+ * 40xx codes.
64
+ */
65
+ const WATCHDOG_CLOSE_CODE = 4099;
66
+ /**
67
+ * Close codes that are reconnectable-but-rate-limited. The reconnect loop
68
+ * still retries these (they are NOT terminal) but honors a longer floor
69
+ * (``RATE_LIMITED_FLOOR_MS``) before doing so, and surfaces a ``rate_limited``
70
+ * reason on ``onReconnect`` so consumers can message "too many connections —
71
+ * retrying…" instead of a generic banner. If the retries exhaust the budget,
72
+ * the terminal ``onError`` carries the originating 4029 / 1013 close code.
56
73
  *
57
74
  * 4029 (custom platform code for "too many connections / burst exceeded").
58
75
  * 1013 (try again later, RFC 6455 standard hint).
@@ -74,9 +91,16 @@ const DEFAULT_IDLE_TIMEOUT_MS = 45_000;
74
91
  * ```ts
75
92
  * const handle = createReconnectingWebSocket({
76
93
  * url: client.conversations.sessionConnectUrl({ serviceId, entityId }),
77
- * protocols: sessionConnectAuthProtocols(apiKey),
94
+ * // Re-mint the auth subprotocols on EACH (re)connect so a token that
95
+ * // expires mid-stream is refreshed before the retry — falls back to the
96
+ * // static `protocols` option when omitted.
97
+ * getProtocols: async () => sessionConnectAuthProtocols(await freshToken()),
78
98
  * onMessage: (e) => console.log('frame', e.data),
79
99
  * onStateChange: (s) => console.log('state', s),
100
+ * onReconnect: ({ reason, delayMs }) => {
101
+ * if (reason === 'rate_limited') showBanner('Too many connections — retrying…');
102
+ * else if (reason === 'idle_watchdog') showBanner('Connection went quiet — reconnecting…');
103
+ * },
80
104
  * onError: (err) => console.error('terminal:', err.reason, err.closeCode),
81
105
  * });
82
106
  *
@@ -165,16 +189,39 @@ export function createReconnectingWebSocket(options) {
165
189
  });
166
190
  return handle;
167
191
  }
192
+ /**
193
+ * Internal sentinel marking a pre-connect failure that the reconnect loop
194
+ * should RETRY (not treat as terminal). Currently only a {@link
195
+ * ReconnectingWebSocketOptions.getProtocols} rejection — a transient
196
+ * token-refresh hiccup — qualifies. Synchronous factory throws (bad URL, no
197
+ * global WebSocket) are NOT wrapped and remain terminal ``open_failed``.
198
+ */
199
+ class RetryableOpenError extends Error {
200
+ constructor(message, cause) {
201
+ super(message, { cause });
202
+ this.name = 'RetryableOpenError';
203
+ }
204
+ }
168
205
  async function runLoop(args) {
169
206
  const { options, signal, setState, reportError, setSocket } = args;
170
207
  let attempt = 0;
171
208
  let delayMs = args.initialDelayMs;
209
+ // Carried from the close that ENDED the previous connection so the
210
+ // ``onReconnect`` callback can report the originating close code and a
211
+ // coarse reason ("idle_watchdog" / "rate_limited" / "transient"). Seeded
212
+ // for the very first connection (attempt 0), where neither applies.
213
+ let pendingReconnect = { closeCode: undefined, reason: 'transient' };
172
214
  while (!signal.aborted) {
173
215
  if (attempt > 0) {
174
216
  setState('reconnecting');
175
217
  const sleepMs = jitter(delayMs);
176
218
  try {
177
- options.onReconnect?.({ attempt, delayMs: sleepMs, closeCode: undefined });
219
+ options.onReconnect?.({
220
+ attempt,
221
+ delayMs: sleepMs,
222
+ closeCode: pendingReconnect.closeCode,
223
+ reason: pendingReconnect.reason,
224
+ });
178
225
  }
179
226
  catch {
180
227
  // ignore
@@ -184,27 +231,51 @@ async function runLoop(args) {
184
231
  break;
185
232
  delayMs = Math.min(delayMs * 2, args.maxDelayMs);
186
233
  }
187
- setState(attempt === 0 ? 'connecting' : 'connecting');
234
+ setState('connecting');
188
235
  let outcome;
189
236
  try {
190
237
  outcome = await runOneConnection(args);
191
238
  }
192
239
  catch (err) {
193
- // Synchronous open failure (e.g., factory threw, invalid URL).
240
+ // A getProtocols() rejection is a TRANSIENT pre-connect failure (e.g. a
241
+ // token-refresh hiccup): retry it up to the reconnect budget rather
242
+ // than killing a long-lived stream over one bad refresh. A synchronous
243
+ // factory throw (invalid URL, no global WebSocket) is genuinely
244
+ // terminal — there is nothing to retry — so it fails fast as before.
245
+ if (err instanceof RetryableOpenError && attempt < args.maxReconnects) {
246
+ pendingReconnect = { closeCode: undefined, reason: 'transient' };
247
+ attempt += 1;
248
+ continue;
249
+ }
194
250
  reportError(new ReconnectingWebSocketError(err instanceof Error ? err.message : 'Failed to open WebSocket', 'open_failed', undefined, undefined, attempt));
195
251
  return;
196
252
  }
197
253
  finally {
198
254
  setSocket(null);
199
255
  }
200
- // Terminal close codes are reported BEFORE the abort check because the
201
- // close arrived from the wire the consumer's subsequent ``close()``
202
- // call (which flips signal.aborted true) must not suppress the diagnostic.
203
- if (outcome.closeCode !== undefined && TERMINAL_CLOSE_CODES.has(outcome.closeCode)) {
204
- reportError(new ReconnectingWebSocketError(`Server closed with terminal code ${outcome.closeCode}: ${outcome.closeReason ?? ''}`, outcome.closeCode === 4403 ? 'auth' : 'client_error', outcome.closeCode, outcome.closeReason, attempt));
205
- return;
256
+ // The idle watchdog forces a close purely to PROVOKE a reconnect — its
257
+ // synthetic close code must never be mistaken for a server-sent terminal
258
+ // rejection. Check ``watchdogTriggered`` first so that even if the
259
+ // watchdog code ever overlapped the terminal set, the loop still
260
+ // reconnects (defense-in-depth; the dedicated WATCHDOG_CLOSE_CODE 4099 is
261
+ // already outside TERMINAL_CLOSE_CODES).
262
+ if (!outcome.watchdogTriggered) {
263
+ // Terminal close codes are reported BEFORE the abort check because the
264
+ // close arrived from the wire — the consumer's subsequent ``close()``
265
+ // call (which flips signal.aborted true) must not suppress the
266
+ // diagnostic.
267
+ if (outcome.closeCode !== undefined && TERMINAL_CLOSE_CODES.has(outcome.closeCode)) {
268
+ reportError(new ReconnectingWebSocketError(`Server closed with terminal code ${outcome.closeCode}: ${outcome.closeReason ?? ''}`, terminalReasonForCode(outcome.closeCode), outcome.closeCode, outcome.closeReason, attempt));
269
+ return;
270
+ }
271
+ if (outcome.aborted || signal.aborted) {
272
+ setState('closed');
273
+ return;
274
+ }
206
275
  }
207
- if (outcome.aborted || signal.aborted) {
276
+ else if (signal.aborted) {
277
+ // Watchdog fired but the consumer also aborted in the same tick — honor
278
+ // the abort and stop, do not reconnect into a torn-down stream.
208
279
  setState('closed');
209
280
  return;
210
281
  }
@@ -212,21 +283,57 @@ async function runLoop(args) {
212
283
  reportError(new ReconnectingWebSocketError(`Reconnect budget exhausted (${args.maxReconnects} attempts)`, 'reconnect_budget_exhausted', outcome.closeCode, outcome.closeReason, attempt));
213
284
  return;
214
285
  }
215
- if (outcome.closeCode !== undefined && RATE_LIMITED_CLOSE_CODES.has(outcome.closeCode)) {
286
+ const isRateLimited = outcome.closeCode !== undefined && RATE_LIMITED_CLOSE_CODES.has(outcome.closeCode);
287
+ if (isRateLimited) {
216
288
  // Pin the floor up so we do not hammer the server we just got
217
289
  // throttled by. Honor whichever is larger between the current
218
290
  // exponential delay and the rate-limited floor.
219
291
  delayMs = Math.max(delayMs, RATE_LIMITED_FLOOR_MS);
220
292
  }
293
+ pendingReconnect = {
294
+ closeCode: outcome.closeCode,
295
+ reason: outcome.watchdogTriggered
296
+ ? 'idle_watchdog'
297
+ : isRateLimited
298
+ ? 'rate_limited'
299
+ : 'transient',
300
+ };
221
301
  attempt += 1;
222
302
  }
223
303
  setState('closed');
224
304
  }
305
+ /**
306
+ * Map a terminal close code to the {@link ReconnectingWebSocketErrorReason}
307
+ * surfaced on ``onError``. 4403 / 4100 are auth rejections; everything else
308
+ * in the terminal set is a client-side / target-not-found error.
309
+ */
310
+ function terminalReasonForCode(code) {
311
+ if (code === 4403 || code === 4100)
312
+ return 'auth';
313
+ return 'client_error';
314
+ }
225
315
  async function runOneConnection(args) {
226
316
  const { options, factory, signal, setState, setSocket, idleTimeoutMs } = args;
317
+ // Resolve subprotocols freshly per (re)connect when a provider is given so
318
+ // an expired bearer token is replaced before each attempt; otherwise reuse
319
+ // the static value frozen at subscribe time (backward compatible). A
320
+ // provider rejection is wrapped as a RetryableOpenError so the loop treats
321
+ // a transient token-refresh hiccup as reconnectable rather than terminal.
322
+ let protocols;
323
+ if (options.getProtocols) {
324
+ try {
325
+ protocols = await options.getProtocols();
326
+ }
327
+ catch (err) {
328
+ throw new RetryableOpenError(err instanceof Error ? err.message : 'getProtocols failed', err);
329
+ }
330
+ }
331
+ else {
332
+ protocols = options.protocols;
333
+ }
227
334
  let socket;
228
335
  try {
229
- socket = factory(options.url, options.protocols);
336
+ socket = factory(options.url, protocols);
230
337
  }
231
338
  catch (err) {
232
339
  throw err instanceof Error ? err : new Error(String(err));
@@ -248,18 +355,24 @@ async function runOneConnection(args) {
248
355
  watchdogTimer = setTimeout(() => {
249
356
  if (resolved)
250
357
  return;
251
- try {
252
- socket.close(4001, 'idle timeout');
253
- }
254
- catch {
255
- // already closed
256
- }
358
+ // Finalize FIRST (flips ``resolved`` and detaches the ``close``
359
+ // listener) so that a runtime which dispatches the ``close`` event
360
+ // synchronously from ``socket.close()`` cannot re-enter ``onClose``
361
+ // and overwrite the outcome with ``watchdogTriggered: false``. The
362
+ // outcome must record the watchdog as the cause so the loop reconnects
363
+ // with the ``idle_watchdog`` reason rather than misclassifying it.
257
364
  finalize({
258
- closeCode: 4001,
365
+ closeCode: WATCHDOG_CLOSE_CODE,
259
366
  closeReason: 'idle timeout',
260
367
  watchdogTriggered: true,
261
368
  aborted: false,
262
369
  });
370
+ try {
371
+ socket.close(WATCHDOG_CLOSE_CODE, 'idle timeout');
372
+ }
373
+ catch {
374
+ // already closed
375
+ }
263
376
  }, idleTimeoutMs);
264
377
  }
265
378
  function finalize(outcome) {
@@ -1 +1 @@
1
- {"version":3,"file":"reconnecting-websocket.js","sourceRoot":"","sources":["../../src/core/reconnecting-websocket.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;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AM,CAAC,OAAO;QAAE,OAAO,KAAK,CAAA;IAChC,OAAO,IAAI,OAAO,CAAU,CAAC,OAAO,EAAE,EAAE;QACtC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;YAC5B,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;YAC5C,OAAO,CAAC,IAAI,CAAC,CAAA;QACf,CAAC,EAAE,EAAE,CAAC,CAAA;QACN,MAAM,OAAO,GAAG,GAAS,EAAE;YACzB,YAAY,CAAC,KAAK,CAAC,CAAA;YACnB,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;YAC5C,OAAO,CAAC,KAAK,CAAC,CAAA;QAChB,CAAC,CAAA;QACD,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;IAC3D,CAAC,CAAC,CAAA;AACJ,CAAC"}
package/dist/index.cjs CHANGED
@@ -2705,23 +2705,6 @@ var SesSetupResource = class extends WorkspaceScopedResource {
2705
2705
  })
2706
2706
  );
2707
2707
  }
2708
- /**
2709
- * List SES setups owned by this workspace.
2710
- *
2711
- * Each item carries the cached ``dns_verified`` aggregate; call ``get``
2712
- * for per-record DNS detail.
2713
- */
2714
- async list(params) {
2715
- return extractData(
2716
- await this.client.GET("/v1/{workspace_id}/channels/ses-setup", {
2717
- params: { path: { workspace_id: this.workspaceId }, query: params }
2718
- })
2719
- );
2720
- }
2721
- /** Auto-paginating async iterable over every SES setup in the workspace. */
2722
- listAutoPaging(params) {
2723
- return this.iteratePaginatedList((pageParams) => this.list(pageParams), params);
2724
- }
2725
2708
  /**
2726
2709
  * Get an SES setup with a live DNS verification refresh.
2727
2710
  *
@@ -4260,7 +4243,8 @@ var ReconnectingWebSocketError = class extends Error {
4260
4243
  this.attempts = attempts;
4261
4244
  }
4262
4245
  };
4263
- var TERMINAL_CLOSE_CODES = /* @__PURE__ */ new Set([1008, 4001, 4003, 4100, 4403]);
4246
+ var TERMINAL_CLOSE_CODES = /* @__PURE__ */ new Set([1008, 3003, 4001, 4003, 4004, 4100, 4403]);
4247
+ var WATCHDOG_CLOSE_CODE = 4099;
4264
4248
  var RATE_LIMITED_CLOSE_CODES = /* @__PURE__ */ new Set([1013, 4029]);
4265
4249
  var RATE_LIMITED_FLOOR_MS = 5e3;
4266
4250
  var DEFAULT_INITIAL_DELAY_MS2 = 1e3;
@@ -4339,27 +4323,44 @@ function createReconnectingWebSocket(options) {
4339
4323
  });
4340
4324
  return handle;
4341
4325
  }
4326
+ var RetryableOpenError = class extends Error {
4327
+ constructor(message, cause) {
4328
+ super(message, { cause });
4329
+ this.name = "RetryableOpenError";
4330
+ }
4331
+ };
4342
4332
  async function runLoop(args) {
4343
4333
  const { options, signal, setState, reportError, setSocket } = args;
4344
4334
  let attempt = 0;
4345
4335
  let delayMs = args.initialDelayMs;
4336
+ let pendingReconnect = { closeCode: void 0, reason: "transient" };
4346
4337
  while (!signal.aborted) {
4347
4338
  if (attempt > 0) {
4348
4339
  setState("reconnecting");
4349
4340
  const sleepMs = jitter2(delayMs);
4350
4341
  try {
4351
- options.onReconnect?.({ attempt, delayMs: sleepMs, closeCode: void 0 });
4342
+ options.onReconnect?.({
4343
+ attempt,
4344
+ delayMs: sleepMs,
4345
+ closeCode: pendingReconnect.closeCode,
4346
+ reason: pendingReconnect.reason
4347
+ });
4352
4348
  } catch {
4353
4349
  }
4354
4350
  const slept = await abortableSleep2(sleepMs, signal);
4355
4351
  if (!slept) break;
4356
4352
  delayMs = Math.min(delayMs * 2, args.maxDelayMs);
4357
4353
  }
4358
- setState(attempt === 0 ? "connecting" : "connecting");
4354
+ setState("connecting");
4359
4355
  let outcome;
4360
4356
  try {
4361
4357
  outcome = await runOneConnection2(args);
4362
4358
  } catch (err) {
4359
+ if (err instanceof RetryableOpenError && attempt < args.maxReconnects) {
4360
+ pendingReconnect = { closeCode: void 0, reason: "transient" };
4361
+ attempt += 1;
4362
+ continue;
4363
+ }
4363
4364
  reportError(
4364
4365
  new ReconnectingWebSocketError(
4365
4366
  err instanceof Error ? err.message : "Failed to open WebSocket",
@@ -4373,19 +4374,24 @@ async function runLoop(args) {
4373
4374
  } finally {
4374
4375
  setSocket(null);
4375
4376
  }
4376
- if (outcome.closeCode !== void 0 && TERMINAL_CLOSE_CODES.has(outcome.closeCode)) {
4377
- reportError(
4378
- new ReconnectingWebSocketError(
4379
- `Server closed with terminal code ${outcome.closeCode}: ${outcome.closeReason ?? ""}`,
4380
- outcome.closeCode === 4403 ? "auth" : "client_error",
4381
- outcome.closeCode,
4382
- outcome.closeReason,
4383
- attempt
4384
- )
4385
- );
4386
- return;
4387
- }
4388
- if (outcome.aborted || signal.aborted) {
4377
+ if (!outcome.watchdogTriggered) {
4378
+ if (outcome.closeCode !== void 0 && TERMINAL_CLOSE_CODES.has(outcome.closeCode)) {
4379
+ reportError(
4380
+ new ReconnectingWebSocketError(
4381
+ `Server closed with terminal code ${outcome.closeCode}: ${outcome.closeReason ?? ""}`,
4382
+ terminalReasonForCode(outcome.closeCode),
4383
+ outcome.closeCode,
4384
+ outcome.closeReason,
4385
+ attempt
4386
+ )
4387
+ );
4388
+ return;
4389
+ }
4390
+ if (outcome.aborted || signal.aborted) {
4391
+ setState("closed");
4392
+ return;
4393
+ }
4394
+ } else if (signal.aborted) {
4389
4395
  setState("closed");
4390
4396
  return;
4391
4397
  }
@@ -4401,18 +4407,37 @@ async function runLoop(args) {
4401
4407
  );
4402
4408
  return;
4403
4409
  }
4404
- if (outcome.closeCode !== void 0 && RATE_LIMITED_CLOSE_CODES.has(outcome.closeCode)) {
4410
+ const isRateLimited = outcome.closeCode !== void 0 && RATE_LIMITED_CLOSE_CODES.has(outcome.closeCode);
4411
+ if (isRateLimited) {
4405
4412
  delayMs = Math.max(delayMs, RATE_LIMITED_FLOOR_MS);
4406
4413
  }
4414
+ pendingReconnect = {
4415
+ closeCode: outcome.closeCode,
4416
+ reason: outcome.watchdogTriggered ? "idle_watchdog" : isRateLimited ? "rate_limited" : "transient"
4417
+ };
4407
4418
  attempt += 1;
4408
4419
  }
4409
4420
  setState("closed");
4410
4421
  }
4422
+ function terminalReasonForCode(code) {
4423
+ if (code === 4403 || code === 4100) return "auth";
4424
+ return "client_error";
4425
+ }
4411
4426
  async function runOneConnection2(args) {
4412
4427
  const { options, factory, signal, setState, setSocket, idleTimeoutMs } = args;
4428
+ let protocols;
4429
+ if (options.getProtocols) {
4430
+ try {
4431
+ protocols = await options.getProtocols();
4432
+ } catch (err) {
4433
+ throw new RetryableOpenError(err instanceof Error ? err.message : "getProtocols failed", err);
4434
+ }
4435
+ } else {
4436
+ protocols = options.protocols;
4437
+ }
4413
4438
  let socket;
4414
4439
  try {
4415
- socket = factory(options.url, options.protocols);
4440
+ socket = factory(options.url, protocols);
4416
4441
  } catch (err) {
4417
4442
  throw err instanceof Error ? err : new Error(String(err));
4418
4443
  }
@@ -4431,16 +4456,16 @@ async function runOneConnection2(args) {
4431
4456
  clearWatchdog();
4432
4457
  watchdogTimer = setTimeout(() => {
4433
4458
  if (resolved) return;
4434
- try {
4435
- socket.close(4001, "idle timeout");
4436
- } catch {
4437
- }
4438
4459
  finalize({
4439
- closeCode: 4001,
4460
+ closeCode: WATCHDOG_CLOSE_CODE,
4440
4461
  closeReason: "idle timeout",
4441
4462
  watchdogTriggered: true,
4442
4463
  aborted: false
4443
4464
  });
4465
+ try {
4466
+ socket.close(WATCHDOG_CLOSE_CODE, "idle timeout");
4467
+ } catch {
4468
+ }
4444
4469
  }, idleTimeoutMs);
4445
4470
  }
4446
4471
  function finalize(outcome) {