@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.mjs CHANGED
@@ -3655,6 +3655,23 @@ const DEFAULT_ADJUSTMENT = "all";
3655
3655
  // `feed` argument on getOptions*/getLatestBars/etc.) still win.
3656
3656
  const DEFAULT_FEED$1 = (process.env.ALPACA_MARKET_DATA_FEED || "iex");
3657
3657
  const DEFAULT_CURRENCY$1 = "USD";
3658
+ /** Close code that the close handler treats as "do not reconnect". */
3659
+ const INTENTIONAL_CLOSE_CODE = 1000;
3660
+ /** Reason text carried on an intentional close, for server-side logs. */
3661
+ const INTENTIONAL_CLOSE_REASON = "intentional disconnect";
3662
+ /**
3663
+ * Close a stream, optionally in the way the close handler treats as final.
3664
+ *
3665
+ * @param ws - The socket to close.
3666
+ * @param options - Whether this close is intentional.
3667
+ */
3668
+ function closeStream(ws, options) {
3669
+ if (options.intentional === true) {
3670
+ ws.close(INTENTIONAL_CLOSE_CODE, INTENTIONAL_CLOSE_REASON);
3671
+ return;
3672
+ }
3673
+ ws.close();
3674
+ }
3658
3675
  /**
3659
3676
  * Singleton class for interacting with Alpaca Market Data API
3660
3677
  * Provides methods for fetching historical bars, latest bars, last trades, latest trades, latest quotes, and latest quote for a single symbol
@@ -4040,19 +4057,19 @@ class AlpacaMarketDataAPI extends EventEmitter {
4040
4057
  this.connect("crypto");
4041
4058
  }
4042
4059
  }
4043
- disconnectStockStream() {
4060
+ disconnectStockStream(options = {}) {
4044
4061
  if (this.stockWs) {
4045
- this.stockWs.close();
4062
+ closeStream(this.stockWs, options);
4046
4063
  }
4047
4064
  }
4048
- disconnectOptionStream() {
4065
+ disconnectOptionStream(options = {}) {
4049
4066
  if (this.optionWs) {
4050
- this.optionWs.close();
4067
+ closeStream(this.optionWs, options);
4051
4068
  }
4052
4069
  }
4053
- disconnectCryptoStream() {
4070
+ disconnectCryptoStream(options = {}) {
4054
4071
  if (this.cryptoWs) {
4055
- this.cryptoWs.close();
4072
+ closeStream(this.cryptoWs, options);
4056
4073
  }
4057
4074
  }
4058
4075
  /**
@@ -63258,58 +63275,59 @@ function routeSupports(route, needs) {
63258
63275
  var defaults$1 = {
63259
63276
  _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.",
63260
63277
  basis: "conservative-default",
63261
- requests_per_minute: 60,
63262
- max_concurrent: 4,
63263
- acquire_timeout_ms: 15000
63278
+ requests_per_minute: 120,
63279
+ max_concurrent: 12,
63280
+ acquire_timeout_ms: 15000,
63281
+ 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."
63264
63282
  };
63265
63283
  var providers$1 = {
63266
63284
  anthropic: {
63267
63285
  basis: "conservative-default",
63268
- requests_per_minute: 50,
63269
- max_concurrent: 4,
63286
+ requests_per_minute: 120,
63287
+ max_concurrent: 12,
63270
63288
  acquire_timeout_ms: 15000,
63271
63289
  source: null,
63272
- 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."
63290
+ 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."
63273
63291
  },
63274
63292
  openai: {
63275
63293
  basis: "conservative-default",
63276
- requests_per_minute: 60,
63277
- max_concurrent: 4,
63294
+ requests_per_minute: 120,
63295
+ max_concurrent: 12,
63278
63296
  acquire_timeout_ms: 15000,
63279
63297
  source: null,
63280
- 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."
63298
+ 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."
63281
63299
  },
63282
63300
  deepseek: {
63283
63301
  basis: "conservative-default",
63284
- requests_per_minute: 60,
63285
- max_concurrent: 4,
63302
+ requests_per_minute: 120,
63303
+ max_concurrent: 12,
63286
63304
  acquire_timeout_ms: 30000,
63287
63305
  source: null,
63288
- 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."
63306
+ 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."
63289
63307
  },
63290
63308
  deepinfra: {
63291
63309
  basis: "conservative-default",
63292
- requests_per_minute: 60,
63293
- max_concurrent: 4,
63310
+ requests_per_minute: 240,
63311
+ max_concurrent: 24,
63294
63312
  acquire_timeout_ms: 15000,
63295
63313
  source: null,
63296
- note: "Awaiting W3-02. Transcribe the published ceiling then."
63314
+ 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."
63297
63315
  },
63298
63316
  fireworks: {
63299
63317
  basis: "conservative-default",
63300
- requests_per_minute: 60,
63301
- max_concurrent: 4,
63318
+ requests_per_minute: 120,
63319
+ max_concurrent: 12,
63302
63320
  acquire_timeout_ms: 15000,
63303
63321
  source: null,
63304
- note: "The backlog calls out recording Fireworks' published RPM ceiling specifically (W3-03 -> W4-04). Do that at onboarding."
63322
+ 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."
63305
63323
  },
63306
63324
  zai: {
63307
63325
  basis: "conservative-default",
63308
- requests_per_minute: 60,
63309
- max_concurrent: 4,
63326
+ requests_per_minute: 120,
63327
+ max_concurrent: 12,
63310
63328
  acquire_timeout_ms: 15000,
63311
63329
  source: null,
63312
- note: "Awaiting W3-04."
63330
+ 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."
63313
63331
  },
63314
63332
  groq: {
63315
63333
  basis: "conservative-default",