@adaptic/utils 0.0.1025 → 0.0.1027

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/index.cjs CHANGED
@@ -3657,6 +3657,23 @@ const DEFAULT_ADJUSTMENT = "all";
3657
3657
  // `feed` argument on getOptions*/getLatestBars/etc.) still win.
3658
3658
  const DEFAULT_FEED$1 = (process.env.ALPACA_MARKET_DATA_FEED || "iex");
3659
3659
  const DEFAULT_CURRENCY$1 = "USD";
3660
+ /** Close code that the close handler treats as "do not reconnect". */
3661
+ const INTENTIONAL_CLOSE_CODE = 1000;
3662
+ /** Reason text carried on an intentional close, for server-side logs. */
3663
+ const INTENTIONAL_CLOSE_REASON = "intentional disconnect";
3664
+ /**
3665
+ * Close a stream, optionally in the way the close handler treats as final.
3666
+ *
3667
+ * @param ws - The socket to close.
3668
+ * @param options - Whether this close is intentional.
3669
+ */
3670
+ function closeStream(ws, options) {
3671
+ if (options.intentional === true) {
3672
+ ws.close(INTENTIONAL_CLOSE_CODE, INTENTIONAL_CLOSE_REASON);
3673
+ return;
3674
+ }
3675
+ ws.close();
3676
+ }
3660
3677
  /**
3661
3678
  * Singleton class for interacting with Alpaca Market Data API
3662
3679
  * Provides methods for fetching historical bars, latest bars, last trades, latest trades, latest quotes, and latest quote for a single symbol
@@ -4042,19 +4059,19 @@ class AlpacaMarketDataAPI extends require$$0$1.EventEmitter {
4042
4059
  this.connect("crypto");
4043
4060
  }
4044
4061
  }
4045
- disconnectStockStream() {
4062
+ disconnectStockStream(options = {}) {
4046
4063
  if (this.stockWs) {
4047
- this.stockWs.close();
4064
+ closeStream(this.stockWs, options);
4048
4065
  }
4049
4066
  }
4050
- disconnectOptionStream() {
4067
+ disconnectOptionStream(options = {}) {
4051
4068
  if (this.optionWs) {
4052
- this.optionWs.close();
4069
+ closeStream(this.optionWs, options);
4053
4070
  }
4054
4071
  }
4055
- disconnectCryptoStream() {
4072
+ disconnectCryptoStream(options = {}) {
4056
4073
  if (this.cryptoWs) {
4057
- this.cryptoWs.close();
4074
+ closeStream(this.cryptoWs, options);
4058
4075
  }
4059
4076
  }
4060
4077
  /**
@@ -63260,58 +63277,59 @@ function routeSupports(route, needs) {
63260
63277
  var defaults$1 = {
63261
63278
  _readme: "Applied to any provider whose published ceiling is unknown. Chosen to be comfortably below the slowest plausible published limit: being slower than necessary costs latency, while being faster than permitted costs 429s that the fallback chain will read as provider ill-health and use to open a circuit breaker. The asymmetry is what makes the conservative side the correct default.",
63262
63279
  basis: "conservative-default",
63263
- requests_per_minute: 60,
63264
- max_concurrent: 4,
63265
- acquire_timeout_ms: 15000
63280
+ requests_per_minute: 120,
63281
+ max_concurrent: 12,
63282
+ acquire_timeout_ms: 15000,
63283
+ note: "Raised 2026-09-15 after the 4-concurrent ceiling was measured starving the live equity decision path: the alias chain reported 'exhausted its fallback chain' with every leg skipped by this guard (deepinfra primary+secondary and the anthropic incumbent), 173 of 473 signal-coordination calls failed (36.6%), and decisions were lost outright. Corroborating evidence at the time: ZERO 429s observed on any provider, the engine's own global fan-out gate permits 100 concurrent with 17 active, and 877 signal-analysis calls had been admitted to that gate. Concurrency and RPM are raised TOGETHER because they bind in series - lifting max_concurrent alone would only move the bottleneck to the token bucket. STILL conservative-default, NOT published: no provider console was read for these numbers, so they remain a deliberate under-estimate of an unknown ceiling. Transcribe the real tier limits (W3-07) and set basis to published."
63266
63284
  };
63267
63285
  var providers$1 = {
63268
63286
  anthropic: {
63269
63287
  basis: "conservative-default",
63270
- requests_per_minute: 50,
63271
- max_concurrent: 4,
63288
+ requests_per_minute: 120,
63289
+ max_concurrent: 12,
63272
63290
  acquire_timeout_ms: 15000,
63273
63291
  source: null,
63274
- note: "Anthropic publishes tier-dependent limits; the account's tier is not recorded here. Transcribe the real ceiling from the console at W3-07 and set basis to published."
63292
+ note: "Raised 2026-09-15 after the 4-concurrent ceiling was measured starving the live equity decision path: the alias chain reported 'exhausted its fallback chain' with every leg skipped by this guard (deepinfra primary+secondary and the anthropic incumbent), 173 of 473 signal-coordination calls failed (36.6%), and decisions were lost outright. Corroborating evidence at the time: ZERO 429s observed on any provider, the engine's own global fan-out gate permits 100 concurrent with 17 active, and 877 signal-analysis calls had been admitted to that gate. Concurrency and RPM are raised TOGETHER because they bind in series - lifting max_concurrent alone would only move the bottleneck to the token bucket. STILL conservative-default, NOT published: no provider console was read for these numbers, so they remain a deliberate under-estimate of an unknown ceiling. Transcribe the real tier limits (W3-07) and set basis to published."
63275
63293
  },
63276
63294
  openai: {
63277
63295
  basis: "conservative-default",
63278
- requests_per_minute: 60,
63279
- max_concurrent: 4,
63296
+ requests_per_minute: 120,
63297
+ max_concurrent: 12,
63280
63298
  acquire_timeout_ms: 15000,
63281
63299
  source: null,
63282
- note: "Tier-dependent. No alias routes here today; the entry exists so a revert to an OpenAI incumbent inherits a bounded client rather than an unbounded one."
63300
+ note: "Raised 2026-09-15 after the 4-concurrent ceiling was measured starving the live equity decision path: the alias chain reported 'exhausted its fallback chain' with every leg skipped by this guard (deepinfra primary+secondary and the anthropic incumbent), 173 of 473 signal-coordination calls failed (36.6%), and decisions were lost outright. Corroborating evidence at the time: ZERO 429s observed on any provider, the engine's own global fan-out gate permits 100 concurrent with 17 active, and 877 signal-analysis calls had been admitted to that gate. Concurrency and RPM are raised TOGETHER because they bind in series - lifting max_concurrent alone would only move the bottleneck to the token bucket. STILL conservative-default, NOT published: no provider console was read for these numbers, so they remain a deliberate under-estimate of an unknown ceiling. Transcribe the real tier limits (W3-07) and set basis to published."
63283
63301
  },
63284
63302
  deepseek: {
63285
63303
  basis: "conservative-default",
63286
- requests_per_minute: 60,
63287
- max_concurrent: 4,
63304
+ requests_per_minute: 120,
63305
+ max_concurrent: 12,
63288
63306
  acquire_timeout_ms: 30000,
63289
63307
  source: null,
63290
- note: "Serves llm.extract, a batch-class alias, so a longer acquire timeout is appropriate: a batch caller can afford to queue where a hot-path caller cannot."
63308
+ note: "Raised 2026-09-15 after the 4-concurrent ceiling was measured starving the live equity decision path: the alias chain reported 'exhausted its fallback chain' with every leg skipped by this guard (deepinfra primary+secondary and the anthropic incumbent), 173 of 473 signal-coordination calls failed (36.6%), and decisions were lost outright. Corroborating evidence at the time: ZERO 429s observed on any provider, the engine's own global fan-out gate permits 100 concurrent with 17 active, and 877 signal-analysis calls had been admitted to that gate. Concurrency and RPM are raised TOGETHER because they bind in series - lifting max_concurrent alone would only move the bottleneck to the token bucket. STILL conservative-default, NOT published: no provider console was read for these numbers, so they remain a deliberate under-estimate of an unknown ceiling. Transcribe the real tier limits (W3-07) and set basis to published."
63291
63309
  },
63292
63310
  deepinfra: {
63293
63311
  basis: "conservative-default",
63294
- requests_per_minute: 60,
63295
- max_concurrent: 4,
63312
+ requests_per_minute: 240,
63313
+ max_concurrent: 24,
63296
63314
  acquire_timeout_ms: 15000,
63297
63315
  source: null,
63298
- note: "Awaiting W3-02. Transcribe the published ceiling then."
63316
+ note: "Raised 2026-09-15 after the 4-concurrent ceiling was measured starving the live equity decision path: the alias chain reported 'exhausted its fallback chain' with every leg skipped by this guard (deepinfra primary+secondary and the anthropic incumbent), 173 of 473 signal-coordination calls failed (36.6%), and decisions were lost outright. Corroborating evidence at the time: ZERO 429s observed on any provider, the engine's own global fan-out gate permits 100 concurrent with 17 active, and 877 signal-analysis calls had been admitted to that gate. Concurrency and RPM are raised TOGETHER because they bind in series - lifting max_concurrent alone would only move the bottleneck to the token bucket. STILL conservative-default, NOT published: no provider console was read for these numbers, so they remain a deliberate under-estimate of an unknown ceiling. Transcribe the real tier limits (W3-07) and set basis to published."
63299
63317
  },
63300
63318
  fireworks: {
63301
63319
  basis: "conservative-default",
63302
- requests_per_minute: 60,
63303
- max_concurrent: 4,
63320
+ requests_per_minute: 120,
63321
+ max_concurrent: 12,
63304
63322
  acquire_timeout_ms: 15000,
63305
63323
  source: null,
63306
- note: "The backlog calls out recording Fireworks' published RPM ceiling specifically (W3-03 -> W4-04). Do that at onboarding."
63324
+ note: "Raised 2026-09-15 after the 4-concurrent ceiling was measured starving the live equity decision path: the alias chain reported 'exhausted its fallback chain' with every leg skipped by this guard (deepinfra primary+secondary and the anthropic incumbent), 173 of 473 signal-coordination calls failed (36.6%), and decisions were lost outright. Corroborating evidence at the time: ZERO 429s observed on any provider, the engine's own global fan-out gate permits 100 concurrent with 17 active, and 877 signal-analysis calls had been admitted to that gate. Concurrency and RPM are raised TOGETHER because they bind in series - lifting max_concurrent alone would only move the bottleneck to the token bucket. STILL conservative-default, NOT published: no provider console was read for these numbers, so they remain a deliberate under-estimate of an unknown ceiling. Transcribe the real tier limits (W3-07) and set basis to published."
63307
63325
  },
63308
63326
  zai: {
63309
63327
  basis: "conservative-default",
63310
- requests_per_minute: 60,
63311
- max_concurrent: 4,
63328
+ requests_per_minute: 120,
63329
+ max_concurrent: 12,
63312
63330
  acquire_timeout_ms: 15000,
63313
63331
  source: null,
63314
- note: "Awaiting W3-04."
63332
+ note: "Raised 2026-09-15 after the 4-concurrent ceiling was measured starving the live equity decision path: the alias chain reported 'exhausted its fallback chain' with every leg skipped by this guard (deepinfra primary+secondary and the anthropic incumbent), 173 of 473 signal-coordination calls failed (36.6%), and decisions were lost outright. Corroborating evidence at the time: ZERO 429s observed on any provider, the engine's own global fan-out gate permits 100 concurrent with 17 active, and 877 signal-analysis calls had been admitted to that gate. Concurrency and RPM are raised TOGETHER because they bind in series - lifting max_concurrent alone would only move the bottleneck to the token bucket. STILL conservative-default, NOT published: no provider console was read for these numbers, so they remain a deliberate under-estimate of an unknown ceiling. Transcribe the real tier limits (W3-07) and set basis to published."
63315
63333
  },
63316
63334
  groq: {
63317
63335
  basis: "conservative-default",