brass-runtime 1.19.2 → 1.20.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.19.0 - Bare-Metal HTTP Mode
4
+
5
+ ### Features
6
+
7
+ - Added `makeBareMetalHttp` factory: a zero-overhead HTTP client that bypasses
8
+ all middleware layers (retry, dedup, cache, batch, priority, compression,
9
+ adaptive limiter, prewarm) and delegates directly to the wire transport.
10
+ Preserves typed errors, cancellation, pool/adaptive-limiter, and stats.
11
+ - Added `makeBareMetalHttpStream` factory: streaming counterpart with the same
12
+ zero-overhead guarantees. Pool leases are released on headers received.
13
+ - Added `preset: "bareMetal"` to `makeDefaultHttpClient` for easy opt-in via
14
+ the standard preset system. DX helpers (get, post, getJson, postJson, getText)
15
+ work identically. Lifecycle config keys are ignored with a construction-time
16
+ warning. User middleware is still applied.
17
+ - Bare-metal clients expose `.with(mw)` escape hatch for composing observability
18
+ without pulling in the full lifecycle stack.
19
+ - Exported `runDirectTransport`, `runPoolTransport`, and related wire-level
20
+ helpers from `src/http/client.ts` for advanced custom client composition.
21
+
22
+ ### Usage
23
+
24
+ ```typescript
25
+ import { makeBareMetalHttp, makeDefaultHttpClient } from "brass-runtime/http";
26
+
27
+ // Standalone factory
28
+ const client = makeBareMetalHttp({ baseUrl: "https://api.internal" });
29
+
30
+ // Via preset
31
+ const defaultClient = makeDefaultHttpClient({ preset: "bareMetal" });
32
+
33
+ // With custom transport (e.g., Axios adapter)
34
+ const axiosClient = makeBareMetalHttp({ transport: myAxiosTransport });
35
+ ```
36
+
3
37
  ## 1.18.3 - HTTP Pool/Timeout Fast Path
4
38
 
5
39
  ### Performance
@@ -4,7 +4,7 @@
4
4
  var _chunkJQCQWO47cjs = require('./chunk-JQCQWO47.cjs');
5
5
 
6
6
 
7
- var _chunkTWEHIAUEcjs = require('./chunk-TWEHIAUE.cjs');
7
+ var _chunkBDTBIYAMcjs = require('./chunk-BDTBIYAM.cjs');
8
8
 
9
9
 
10
10
  var _chunkZJC3JZIEcjs = require('./chunk-ZJC3JZIE.cjs');
@@ -14,7 +14,7 @@ var _chunkVXNWVAIGcjs = require('./chunk-VXNWVAIG.cjs');
14
14
 
15
15
 
16
16
 
17
- var _chunkUOKXJQAIcjs = require('./chunk-UOKXJQAI.cjs');
17
+ var _chunkLA2PAO7Jcjs = require('./chunk-LA2PAO7J.cjs');
18
18
 
19
19
 
20
20
 
@@ -862,24 +862,24 @@ function baseHttpConfig(baseUrl, scenario) {
862
862
  };
863
863
  }
864
864
  function makeWireClient(baseUrl, scenario) {
865
- return _chunkUOKXJQAIcjs.makeHttp.call(void 0, baseHttpConfig(baseUrl, scenario));
865
+ return _chunkLA2PAO7Jcjs.makeHttp.call(void 0, baseHttpConfig(baseUrl, scenario));
866
866
  }
867
867
  function makeMinimalClient(baseUrl, scenario) {
868
- return _chunkUOKXJQAIcjs.makeDefaultHttpClient.call(void 0, {
868
+ return _chunkLA2PAO7Jcjs.makeDefaultHttpClient.call(void 0, {
869
869
  preset: "minimal",
870
870
  compression: false,
871
871
  ...baseHttpConfig(baseUrl, scenario)
872
872
  });
873
873
  }
874
874
  function makeDefaultClient(baseUrl, scenario, preset, disableAdaptiveLimiter, observability) {
875
- return _chunkUOKXJQAIcjs.makeDefaultHttpClient.call(void 0, {
875
+ return _chunkLA2PAO7Jcjs.makeDefaultHttpClient.call(void 0, {
876
876
  preset,
877
877
  compression: false,
878
878
  ...baseHttpConfig(baseUrl, scenario),
879
879
  ...disableAdaptiveLimiter ? { adaptiveLimiter: false } : {},
880
880
  ...observability ? {
881
881
  middleware: [
882
- _chunkTWEHIAUEcjs.withHttpObservability.call(void 0, {
882
+ _chunkBDTBIYAMcjs.withHttpObservability.call(void 0, {
883
883
  metrics: observability.metrics,
884
884
  logs: false,
885
885
  spans: {},
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-RZQK32C6.js";
5
5
  import {
6
6
  withHttpObservability
7
- } from "./chunk-BHX4MD35.js";
7
+ } from "./chunk-VXZIP3IU.js";
8
8
  import {
9
9
  makeObservability
10
10
  } from "./chunk-TAPB4NN5.js";
@@ -14,7 +14,7 @@ import {
14
14
  import {
15
15
  makeDefaultHttpClient,
16
16
  makeHttp
17
- } from "./chunk-HKLZJ5UK.js";
17
+ } from "./chunk-POH2WZBI.js";
18
18
  import {
19
19
  Runtime,
20
20
  Scheduler
@@ -5638,14 +5638,14 @@ function noopInvalidate(_key) {
5638
5638
  }
5639
5639
  function noopClear() {
5640
5640
  }
5641
- function buildLifecycleClient(fn2, tracker, internals) {
5642
- const client = (req) => trackRequest(fn2, req, tracker, internals);
5641
+ function buildLifecycleClient(fn3, tracker, internals) {
5642
+ const client = (req) => trackRequest(fn3, req, tracker, internals);
5643
5643
  const stats = () => {
5644
5644
  tracker.setQueueDepth(internals.queueDepth?.() ?? 0);
5645
5645
  return tracker.snapshot();
5646
5646
  };
5647
5647
  const withMw = (mw) => {
5648
- const wrappedFn = mw(withLifecycleMetadata(fn2, internals));
5648
+ const wrappedFn = mw(withLifecycleMetadata(fn3, internals));
5649
5649
  return buildLifecycleClient(wrappedFn, tracker, internals);
5650
5650
  };
5651
5651
  const lifecycleClient = Object.assign(client, {
@@ -5661,9 +5661,9 @@ function buildLifecycleClient(fn2, tracker, internals) {
5661
5661
  });
5662
5662
  return lifecycleClient;
5663
5663
  }
5664
- function withLifecycleMetadata(fn2, internals) {
5665
- if (!internals.adaptiveLimiter) return fn2;
5666
- return Object.assign(((req) => fn2(req)), {
5664
+ function withLifecycleMetadata(fn3, internals) {
5665
+ if (!internals.adaptiveLimiter) return fn3;
5666
+ return Object.assign(((req) => fn3(req)), {
5667
5667
  adaptiveLimiter: internals.adaptiveLimiter
5668
5668
  });
5669
5669
  }
@@ -5684,7 +5684,7 @@ function shutdownClient(activeCancelers, prewarmMgr, wireShutdown) {
5684
5684
  wireShutdown?.();
5685
5685
  return asyncSucceed(void 0);
5686
5686
  }
5687
- function trackRequest(fn2, req, tracker, internals) {
5687
+ function trackRequest(fn3, req, tracker, internals) {
5688
5688
  return {
5689
5689
  _tag: "Async",
5690
5690
  register: (env, cb) => {
@@ -5746,7 +5746,7 @@ function trackRequest(fn2, req, tracker, internals) {
5746
5746
  return () => void 0;
5747
5747
  }
5748
5748
  try {
5749
- cancelInner = registerHttpEffect(fn2(req), env, finish);
5749
+ cancelInner = registerHttpEffect(fn3(req), env, finish);
5750
5750
  } catch (error) {
5751
5751
  finish({
5752
5752
  _tag: "Failure",
@@ -6168,6 +6168,190 @@ function previewJson(value) {
6168
6168
  }
6169
6169
  }
6170
6170
 
6171
+ // src/http/bareMetalClient.ts
6172
+ var fn2 = Schema.custom(
6173
+ (value) => typeof value === "function",
6174
+ "function"
6175
+ );
6176
+ var poolConfig2 = Schema.union([
6177
+ Schema.literal(false),
6178
+ Schema.object(
6179
+ {
6180
+ concurrency: Schema.number({ min: 1, int: true }).optional(),
6181
+ maxQueue: Schema.number({ min: 0, int: true }).optional(),
6182
+ queueTimeoutMs: Schema.number({ min: 1, int: true }).optional(),
6183
+ key: Schema.union([
6184
+ Schema.enum(["global", "origin", "host"]),
6185
+ fn2
6186
+ ]).optional(),
6187
+ engine: Schema.enum(["ts", "wasm"]).optional(),
6188
+ wasm: Schema.boolean().optional()
6189
+ },
6190
+ { unknownKeys: "passthrough" }
6191
+ )
6192
+ ]);
6193
+ var adaptiveLimiterConfig2 = Schema.union([
6194
+ Schema.literal(false),
6195
+ Schema.object(
6196
+ {
6197
+ preset: Schema.enum(["conservative", "balanced", "aggressive"]).optional(),
6198
+ initialLimit: Schema.number({ min: 1, int: true }).optional(),
6199
+ minLimit: Schema.number({ min: 1, int: true }).optional(),
6200
+ maxLimit: Schema.number({ min: 1, int: true }).optional(),
6201
+ smoothingFactor: Schema.number({ min: 0, max: 1 }).refine((n) => n > 0, "smoothingFactor must be in (0, 1]").optional(),
6202
+ probeInterval: Schema.number({ min: 1, int: true }).optional(),
6203
+ probeJitterRatio: Schema.number({ min: 0, max: 1 }).optional(),
6204
+ windowSize: Schema.number({ min: 2, int: true }).optional(),
6205
+ minSamples: Schema.number({ min: 1, int: true }).optional(),
6206
+ baselineStrategy: Schema.enum(["min", "p5", "ema-low"]).optional(),
6207
+ decreaseCooldownSamples: Schema.number({ min: 0, int: true }).optional(),
6208
+ historySize: Schema.number({ min: 0, int: true }).optional(),
6209
+ windowDecayFactor: Schema.number({ min: 0, max: 1 }).refine((n) => n > 0, "windowDecayFactor must be in (0, 1]").optional(),
6210
+ errorWeight: Schema.number({ min: 0, max: 1 }).optional(),
6211
+ errorSmoothingFactor: Schema.number({ min: 0, max: 1 }).refine((n) => n > 0, "errorSmoothingFactor must be in (0, 1]").optional(),
6212
+ errorStatusThreshold: Schema.number({ min: 100, max: 599, int: true }).optional(),
6213
+ queueStrategy: Schema.enum(["fifo", "priority"]).optional(),
6214
+ queueLoadShedding: Schema.enum(["reject-new", "priority-evict"]).optional(),
6215
+ rejectionBackoffThreshold: Schema.number({ min: 1, int: true }).optional(),
6216
+ rejectionBackoffMs: Schema.number({ min: 1, int: true }).optional(),
6217
+ stateTtlMs: Schema.union([Schema.literal(false), Schema.number({ min: 1, int: true })]).optional(),
6218
+ warmupRequests: Schema.number({ min: 0, int: true }).optional(),
6219
+ decreaseThreshold: Schema.number({ min: 0, max: 1 }).refine((n) => n > 0, "decreaseThreshold must be in (0, 1]").optional(),
6220
+ increaseThreshold: Schema.number({ min: 1 }).optional(),
6221
+ maxDecreaseRatio: Schema.number({ min: 0, max: 1 }).refine((n) => n > 0, "maxDecreaseRatio must be in (0, 1]").optional(),
6222
+ headroomStrategy: Schema.union([
6223
+ Schema.number({ min: 1 }),
6224
+ Schema.enum(["fixed", "proportional"]),
6225
+ fn2,
6226
+ Schema.object({ type: Schema.literal("fixed"), value: Schema.number({ min: 1 }).optional() }, { unknownKeys: "passthrough" }),
6227
+ Schema.object({
6228
+ type: Schema.literal("proportional"),
6229
+ ratio: Schema.number({ min: 0 }).refine((n) => n > 0, "ratio must be > 0").optional(),
6230
+ min: Schema.number({ min: 1 }).optional(),
6231
+ max: Schema.number({ min: 1 }).optional()
6232
+ }, { unknownKeys: "passthrough" })
6233
+ ]).optional(),
6234
+ slowStartRecovery: Schema.boolean().optional(),
6235
+ slowStartSaturationThreshold: Schema.number({ min: 0, max: 1 }).refine((n) => n > 0, "slowStartSaturationThreshold must be in (0, 1]").optional(),
6236
+ slowStartSaturationSamples: Schema.number({ min: 1, int: true }).optional(),
6237
+ key: Schema.union([Schema.enum(["global", "origin", "host"]), fn2]).optional(),
6238
+ maxQueue: Schema.number({ min: 0, int: true }).optional(),
6239
+ queueTimeoutMs: Schema.number({ min: 1, int: true }).optional(),
6240
+ onLimitChange: fn2.optional(),
6241
+ percentile: Schema.enum(["p50", "p99"]).optional()
6242
+ },
6243
+ { unknownKeys: "passthrough" }
6244
+ )
6245
+ ]);
6246
+ var bareMetalConfigSchema = Schema.object(
6247
+ {
6248
+ baseUrl: Schema.string().optional(),
6249
+ headers: Schema.record(Schema.string()).optional(),
6250
+ timeoutMs: Schema.number({ min: 1, int: true }).optional(),
6251
+ transport: fn2.optional(),
6252
+ streamTransport: fn2.optional(),
6253
+ pool: poolConfig2.optional(),
6254
+ adaptiveLimiter: adaptiveLimiterConfig2.optional(),
6255
+ onEvent: fn2.optional()
6256
+ },
6257
+ { unknownKeys: "passthrough" }
6258
+ );
6259
+ function validateBareMetalConfig(config) {
6260
+ parseConfig("BareMetalHttpConfig", bareMetalConfigSchema, config);
6261
+ }
6262
+ var transportDestroy2 = (transport) => {
6263
+ const destroy = transport.destroy;
6264
+ return typeof destroy === "function" ? () => destroy.call(transport) : void 0;
6265
+ };
6266
+ function makeBareMetalHttp(cfg = {}) {
6267
+ validateBareMetalConfig(cfg);
6268
+ const baseUrl = cfg.baseUrl ?? "";
6269
+ const defaultHeaders = cfg.headers ?? {};
6270
+ const normalize = normalizeRequest(defaultHeaders);
6271
+ const adaptiveLimiter = makeAdaptiveLimiter(cfg);
6272
+ const pool = adaptiveLimiter ? void 0 : makePool(cfg);
6273
+ const metrics = makeHttpStats(pool, adaptiveLimiter);
6274
+ const transport = cfg.transport ?? makeFetchTransport();
6275
+ const destroyTransport = transportDestroy2(transport);
6276
+ const run = (req0) => {
6277
+ const req = normalize(req0);
6278
+ const url = resolveRequestUrl(req, baseUrl);
6279
+ if (!(url instanceof URL)) return asyncFail(url);
6280
+ const timeoutMs = resolvePositiveTimeout(req.timeoutMs ?? cfg.timeoutMs);
6281
+ if (!adaptiveLimiter && !pool && timeoutMs === void 0) {
6282
+ return runDirectTransport(req, url, transport, metrics);
6283
+ }
6284
+ return runPoolTransport(req, url, transport, metrics, pool, adaptiveLimiter, void 0, timeoutMs);
6285
+ };
6286
+ const metadata = {};
6287
+ if (adaptiveLimiter) metadata.adaptiveLimiter = adaptiveLimiter;
6288
+ if (adaptiveLimiter || destroyTransport) {
6289
+ metadata.destroy = () => {
6290
+ adaptiveLimiter?.destroy();
6291
+ destroyTransport?.();
6292
+ };
6293
+ metadata.shutdown = () => {
6294
+ adaptiveLimiter?.shutdown();
6295
+ destroyTransport?.();
6296
+ };
6297
+ }
6298
+ return decorate(run, metrics.snapshot, metadata);
6299
+ }
6300
+ function makeBareMetalHttpStream(cfg = {}) {
6301
+ validateBareMetalConfig(cfg);
6302
+ const baseUrl = cfg.baseUrl ?? "";
6303
+ const defaultHeaders = cfg.headers ?? {};
6304
+ const normalize = normalizeRequest(defaultHeaders);
6305
+ const adaptiveLimiter = makeAdaptiveLimiter(cfg);
6306
+ const pool = adaptiveLimiter ? void 0 : makePool(cfg);
6307
+ const metrics = makeHttpStats(pool, adaptiveLimiter);
6308
+ const transport = cfg.streamTransport ?? makeFetchStreamTransport();
6309
+ const run = (req0) => {
6310
+ const req = normalize(req0);
6311
+ const url = resolveRequestUrl(req, baseUrl);
6312
+ if (!(url instanceof URL)) return asyncFail(url);
6313
+ const timeoutMs = resolvePositiveTimeout(req.timeoutMs ?? cfg.timeoutMs);
6314
+ return fromPromiseAbortable(
6315
+ async (signal, env) => {
6316
+ let lease;
6317
+ const linkedSignal = linkAbortSignals(signal, req.init?.signal);
6318
+ try {
6319
+ if (linkedSignal.signal.aborted) throw abortErrorForSignal(linkedSignal.signal);
6320
+ if (adaptiveLimiter) {
6321
+ const key = resolveHttpPoolKey(adaptiveLimiter.keyResolver, req, url);
6322
+ lease = await adaptiveLimiter.acquire(key, linkedSignal.signal, { priority: requestPriority(req) });
6323
+ } else if (pool) {
6324
+ const key = resolveHttpPoolKey(pool.keyResolver, req, url);
6325
+ lease = await pool.acquire(key, linkedSignal.signal);
6326
+ }
6327
+ const response = await runTransportEffect(
6328
+ transport({ request: req, url, signal: linkedSignal.signal }),
6329
+ env,
6330
+ linkedSignal.signal
6331
+ );
6332
+ releaseSuccess(lease, adaptiveLimiter, response);
6333
+ lease = void 0;
6334
+ return response;
6335
+ } finally {
6336
+ linkedSignal.cleanup();
6337
+ if (lease) {
6338
+ releaseFailure(lease, adaptiveLimiter);
6339
+ }
6340
+ }
6341
+ },
6342
+ normalizeHttpError,
6343
+ {
6344
+ label: fetchLabel(req, url),
6345
+ timeoutMs,
6346
+ timeoutReason: timeoutMs ? () => timeoutReason(req, url, timeoutMs) : void 0,
6347
+ onStart: metrics.onStart,
6348
+ onFinish: metrics.onFinish
6349
+ }
6350
+ );
6351
+ };
6352
+ return decorateStream(run, metrics.snapshot);
6353
+ }
6354
+
6171
6355
  // src/http/requestBuilder.ts
6172
6356
  var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
6173
6357
  function splitHttpRequestInit(init) {
@@ -6265,7 +6449,8 @@ var PRESET_CONFIGS = {
6265
6449
  highThroughputProxy: PROXY_PRESET_CONFIG,
6266
6450
  balanced: BALANCED_PRESET_CONFIG,
6267
6451
  default: DEFAULT_PRESET_CONFIG,
6268
- production: DEFAULT_PRESET_CONFIG
6452
+ production: DEFAULT_PRESET_CONFIG,
6453
+ bareMetal: {}
6269
6454
  };
6270
6455
  function isDefaultCacheableResponse(req, res) {
6271
6456
  if (!DEFAULT_CACHEABLE_METHODS.has(req.method)) return false;
@@ -6292,6 +6477,9 @@ function makeDefaultHttpClient(config = {}) {
6292
6477
  policyPresets,
6293
6478
  ...lifecycleOverrides
6294
6479
  } = config;
6480
+ if (preset === "bareMetal") {
6481
+ return buildBareMetalBranch(lifecycleOverrides, middleware, config);
6482
+ }
6295
6483
  const lifecycleConfig2 = mergeLifecycleConfig(PRESET_CONFIGS[preset], lifecycleOverrides);
6296
6484
  let wire = makeLifecycleClient(lifecycleConfig2);
6297
6485
  const compressionResult = compression === false || compression === void 0 && isLeanPreset(preset) ? void 0 : makeCompressionMiddleware(compression === void 0 ? void 0 : compression);
@@ -6315,6 +6503,160 @@ function makeDefaultHttpClient(config = {}) {
6315
6503
  useInlineDecode
6316
6504
  });
6317
6505
  }
6506
+ var LIFECYCLE_KEYS = [
6507
+ "dedup",
6508
+ "batch",
6509
+ "cache",
6510
+ "priority",
6511
+ "retry",
6512
+ "prewarm",
6513
+ "adaptiveLimiter",
6514
+ "compression"
6515
+ ];
6516
+ function findIgnoredLifecycleKeys(overrides) {
6517
+ const found = [];
6518
+ for (const key of LIFECYCLE_KEYS) {
6519
+ if (key in overrides && overrides[key] !== void 0 && overrides[key] !== false) {
6520
+ found.push(key);
6521
+ }
6522
+ }
6523
+ return found;
6524
+ }
6525
+ function extractBareMetalConfig(config) {
6526
+ return {
6527
+ baseUrl: config.baseUrl,
6528
+ headers: config.headers,
6529
+ timeoutMs: config.timeoutMs,
6530
+ transport: config.transport,
6531
+ streamTransport: config.streamTransport,
6532
+ pool: config.pool,
6533
+ adaptiveLimiter: void 0,
6534
+ // bare-metal ignores adaptiveLimiter from lifecycle overrides
6535
+ onEvent: config.onEvent
6536
+ };
6537
+ }
6538
+ function buildBareMetalBranch(lifecycleOverrides, middleware, config) {
6539
+ const ignored = findIgnoredLifecycleKeys(lifecycleOverrides);
6540
+ if (ignored.length > 0 && config.onEvent) {
6541
+ config.onEvent({
6542
+ type: "warning",
6543
+ message: `bareMetal preset ignores: ${ignored.join(", ")}`
6544
+ });
6545
+ }
6546
+ let bareWire = makeBareMetalHttp(extractBareMetalConfig(config));
6547
+ for (const mw of middleware) {
6548
+ bareWire = bareWire.with(mw);
6549
+ }
6550
+ const features = Object.freeze({
6551
+ dedup: false,
6552
+ batch: false,
6553
+ cache: false,
6554
+ priority: false,
6555
+ retry: false,
6556
+ prewarm: false,
6557
+ adaptiveLimiter: false,
6558
+ compression: false,
6559
+ middleware: middleware.length
6560
+ });
6561
+ return buildBareMetalDefaultClient(bareWire, { preset: "bareMetal", features });
6562
+ }
6563
+ function buildBareMetalDefaultClient(bareWire, meta) {
6564
+ const withPromise = (eff) => withAsyncPromise((e, env) => toPromise(e, env))(eff);
6565
+ const requestRaw = (req) => bareWire(req);
6566
+ const request = (req) => withPromise(requestRaw(req));
6567
+ const get = (url, init) => request(buildHttpRequest("GET", url, init));
6568
+ const post = (url, body, init) => request(buildHttpRequest("POST", url, init, body));
6569
+ const getText = (url, init) => {
6570
+ const req = buildHttpRequest("GET", url, init);
6571
+ return withPromise(
6572
+ mapTryAsync(requestRaw(req), (w) => toResponse(w, w.bodyText))
6573
+ );
6574
+ };
6575
+ const getJson = ((url, init) => {
6576
+ const req = setHeaderIfMissing("accept", "application/json")(
6577
+ buildHttpRequest("GET", url, init)
6578
+ );
6579
+ return withPromise(
6580
+ asyncFlatMap(requestRaw(req), (w) => decodeResponse(w, init?.schema, init?.schemaName))
6581
+ );
6582
+ });
6583
+ const postJson = ((url, bodyObj, init) => {
6584
+ return withPromise(
6585
+ asyncFlatMap(
6586
+ encodeJsonBodyEffect(bodyObj, init?.bodySchema, { schemaName: init?.bodySchemaName }),
6587
+ (bodyText) => {
6588
+ const req = setHeaderIfMissing("content-type", "application/json")(
6589
+ setHeaderIfMissing("accept", "application/json")(
6590
+ buildHttpRequest("POST", url, init, bodyText)
6591
+ )
6592
+ );
6593
+ return asyncFlatMap(requestRaw(req), (w) => decodeResponse(w, init?.schema, init?.schemaName));
6594
+ }
6595
+ )
6596
+ );
6597
+ });
6598
+ const wireAsLifecycle = Object.assign(
6599
+ (req) => bareWire(req),
6600
+ {
6601
+ with: (mw) => {
6602
+ const newBare = bareWire.with(mw);
6603
+ return buildBareMetalDefaultClient(newBare, {
6604
+ ...meta,
6605
+ features: { ...meta.features, middleware: meta.features.middleware + 1 }
6606
+ }).wire;
6607
+ },
6608
+ stats: () => ({
6609
+ cacheHits: 0,
6610
+ cacheMisses: 0,
6611
+ cacheEvictions: 0,
6612
+ dedupHits: 0,
6613
+ dedupActive: 0,
6614
+ queueDepth: 0,
6615
+ requestsStarted: 0,
6616
+ requestsCompleted: 0,
6617
+ requestsFailed: 0,
6618
+ retries: 0,
6619
+ batchDispatches: 0,
6620
+ batchedRequests: 0,
6621
+ wire: bareWire.stats()
6622
+ }),
6623
+ cancelAll: () => asyncSucceed(void 0),
6624
+ shutdown: () => {
6625
+ bareWire.shutdown?.();
6626
+ return asyncSucceed(void 0);
6627
+ },
6628
+ cache: {
6629
+ invalidate: () => {
6630
+ },
6631
+ clear: () => {
6632
+ }
6633
+ },
6634
+ ...bareWire.adaptiveLimiter ? { adaptiveLimiter: bareWire.adaptiveLimiter } : {}
6635
+ }
6636
+ );
6637
+ return {
6638
+ request,
6639
+ get,
6640
+ post,
6641
+ getText,
6642
+ getJson,
6643
+ postJson,
6644
+ with: (mw) => buildBareMetalDefaultClient(bareWire.with(mw), {
6645
+ ...meta,
6646
+ features: {
6647
+ ...meta.features,
6648
+ middleware: meta.features.middleware + 1
6649
+ }
6650
+ }),
6651
+ wire: wireAsLifecycle,
6652
+ stats: () => wireAsLifecycle.stats(),
6653
+ cache: wireAsLifecycle.cache,
6654
+ cancelAll: wireAsLifecycle.cancelAll,
6655
+ shutdown: wireAsLifecycle.shutdown,
6656
+ preset: meta.preset,
6657
+ features: meta.features
6658
+ };
6659
+ }
6318
6660
  function buildDefaultClient(wire, meta) {
6319
6661
  const withPromise = (eff) => withAsyncPromise((e, env) => toPromise(e, env))(eff);
6320
6662
  const requestRaw = (req) => wire(req);
@@ -6495,7 +6837,7 @@ function isEnabled(value) {
6495
6837
  return value !== void 0 && value !== false;
6496
6838
  }
6497
6839
  function isLeanPreset(preset) {
6498
- return preset === "minimal" || preset === "proxy" || preset === "highThroughputProxy";
6840
+ return preset === "minimal" || preset === "proxy" || preset === "highThroughputProxy" || preset === "bareMetal";
6499
6841
  }
6500
6842
 
6501
6843
  // src/http/layer.ts
@@ -6573,9 +6915,24 @@ export {
6573
6915
  makeFetchStreamTransport,
6574
6916
  decorate,
6575
6917
  withMiddleware,
6918
+ decorateStream,
6576
6919
  normalizeHeadersInit,
6920
+ normalizeRequest,
6921
+ resolvePositiveTimeout,
6922
+ makeHttpStats,
6923
+ makePool,
6924
+ makeAdaptiveLimiter,
6925
+ resolveRequestUrl,
6926
+ fetchLabel,
6927
+ timeoutReason,
6928
+ requestPriority,
6929
+ runTransportEffect,
6930
+ runDirectTransport,
6931
+ releaseSuccess,
6932
+ releaseFailure,
6577
6933
  makeHttpStream,
6578
6934
  noopSignal,
6935
+ runPoolTransport,
6579
6936
  makeHttp,
6580
6937
  withRetryStream,
6581
6938
  SEPARATOR,
@@ -6611,6 +6968,9 @@ export {
6611
6968
  validatedJson,
6612
6969
  validatedJsonResponse,
6613
6970
  buildHttpRequest,
6971
+ validateBareMetalConfig,
6972
+ makeBareMetalHttp,
6973
+ makeBareMetalHttpStream,
6614
6974
  defaultHttpClientPreset,
6615
6975
  makeDefaultHttpClient,
6616
6976
  HttpClientService,
@@ -20,7 +20,7 @@ var _chunkZJC3JZIEcjs = require('./chunk-ZJC3JZIE.cjs');
20
20
 
21
21
 
22
22
 
23
- var _chunkUOKXJQAIcjs = require('./chunk-UOKXJQAI.cjs');
23
+ var _chunkLA2PAO7Jcjs = require('./chunk-LA2PAO7J.cjs');
24
24
 
25
25
 
26
26
  var _chunkL6VB5N7Qcjs = require('./chunk-L6VB5N7Q.cjs');
@@ -217,13 +217,13 @@ function withHttpObservability(options) {
217
217
  cb({ _tag: "Success", value: res });
218
218
  };
219
219
  const onError = (error) => {
220
- const status = _chunkUOKXJQAIcjs.httpErrorStatus.call(void 0, error);
220
+ const status = _chunkLA2PAO7Jcjs.httpErrorStatus.call(void 0, error);
221
221
  const finish = completeFinish(
222
222
  httpErrorOutcome(error),
223
223
  status !== void 0 ? String(status) : void 0,
224
224
  {
225
225
  "error.type": error._tag,
226
- "http.retryable": _chunkUOKXJQAIcjs.isRetryableHttpError.call(void 0, error)
226
+ "http.retryable": _chunkLA2PAO7Jcjs.isRetryableHttpError.call(void 0, error)
227
227
  }
228
228
  );
229
229
  const adaptiveAttrs = observeAdaptiveLimiter(wireReq, next, resolved);
@@ -244,7 +244,7 @@ function withHttpObservability(options) {
244
244
  durationMs: finish.durationMs,
245
245
  ...status !== void 0 ? { status } : {},
246
246
  ...statusText ? { statusText } : {},
247
- retryable: _chunkUOKXJQAIcjs.isRetryableHttpError.call(void 0, error),
247
+ retryable: _chunkLA2PAO7Jcjs.isRetryableHttpError.call(void 0, error),
248
248
  errorTag: error._tag,
249
249
  message: httpErrorMessage(error)
250
250
  });
@@ -312,7 +312,7 @@ function withLeanHttpSampledSpanObservability(next, options, metricCache) {
312
312
  finishLeanHttpSpan(span, "success");
313
313
  } else {
314
314
  const error = httpErrorFromCause(exit.cause);
315
- const status = _chunkUOKXJQAIcjs.httpErrorStatus.call(void 0, error);
315
+ const status = _chunkLA2PAO7Jcjs.httpErrorStatus.call(void 0, error);
316
316
  recordHttpMetricsFinish(
317
317
  handles,
318
318
  httpErrorOutcome(error),
@@ -375,7 +375,7 @@ function withLeanHttpMetricsObservability(next, options, metricCache) {
375
375
  );
376
376
  } else {
377
377
  const error = httpErrorFromCause(exit.cause);
378
- const status = _chunkUOKXJQAIcjs.httpErrorStatus.call(void 0, error);
378
+ const status = _chunkLA2PAO7Jcjs.httpErrorStatus.call(void 0, error);
379
379
  recordHttpMetricsFinish(
380
380
  handles,
381
381
  httpErrorOutcome(error),
@@ -594,7 +594,7 @@ function getCachedBaseLabels(req, options, cache) {
594
594
  if (cache.disabled) return requestBaseLabels(req, options);
595
595
  const route = requestRoute(req, options);
596
596
  const host = options.includeHostLabel ? requestHost(req) : void 0;
597
- const policy = _chunkUOKXJQAIcjs.getHttpRequestPolicy.call(void 0, req);
597
+ const policy = _chunkLA2PAO7Jcjs.getHttpRequestPolicy.call(void 0, req);
598
598
  const preset = typeof policy === "string" ? policy : _optionalChain([policy, 'optionalAccess', _46 => _46.preset]);
599
599
  const key = `${req.method}|${_nullishCoalesce(host, () => ( ""))}|${_nullishCoalesce(route, () => ( ""))}|${_nullishCoalesce(preset, () => ( ""))}`;
600
600
  const existing = cache.baseLabelsCache.get(key);
@@ -727,7 +727,7 @@ function adaptiveLimiterLabels(req, stats, options) {
727
727
  });
728
728
  }
729
729
  function inferAdaptiveLimiterKey(req, stats) {
730
- const policy = _chunkUOKXJQAIcjs.getHttpRequestPolicy.call(void 0, req);
730
+ const policy = _chunkLA2PAO7Jcjs.getHttpRequestPolicy.call(void 0, req);
731
731
  if (policy.poolKey) return policy.poolKey;
732
732
  const host = requestHost(req);
733
733
  if (host) return host;
@@ -809,7 +809,7 @@ function requestLogFields(req, options) {
809
809
  }
810
810
  function requestPolicyLogFields(req, options) {
811
811
  if (!options.policy.enabled) return void 0;
812
- const policy = _chunkUOKXJQAIcjs.getHttpRequestPolicy.call(void 0, req);
812
+ const policy = _chunkLA2PAO7Jcjs.getHttpRequestPolicy.call(void 0, req);
813
813
  const fields = {
814
814
  ...policy.preset ? { preset: policy.preset } : {},
815
815
  ...policy.lane ? { lane: policy.lane } : {},
@@ -822,7 +822,7 @@ function requestPolicyLogFields(req, options) {
822
822
  }
823
823
  function requestPolicySpanAttributes(req, options) {
824
824
  if (!options.policy.enabled) return {};
825
- const policy = _chunkUOKXJQAIcjs.getHttpRequestPolicy.call(void 0, req);
825
+ const policy = _chunkLA2PAO7Jcjs.getHttpRequestPolicy.call(void 0, req);
826
826
  return {
827
827
  ...compactSpanAttributes({
828
828
  "http.request.policy.lane": policy.lane,
@@ -836,7 +836,7 @@ function requestPolicySpanAttributes(req, options) {
836
836
  }
837
837
  function requestPolicyMetricLabels(req, options) {
838
838
  if (!options.policy.enabled || options.policy.labelKeys.length === 0) return {};
839
- const policy = _chunkUOKXJQAIcjs.getHttpRequestPolicy.call(void 0, req);
839
+ const policy = _chunkLA2PAO7Jcjs.getHttpRequestPolicy.call(void 0, req);
840
840
  const values = {
841
841
  preset: policy.preset,
842
842
  lane: policy.lane,
@@ -1217,7 +1217,7 @@ function makeObservedRuntimeLayer(options = {}) {
1217
1217
  }
1218
1218
  function makeObservedHttpClientLayer(config = {}, options = {}) {
1219
1219
  const observabilityTag = _nullishCoalesce(options.observabilityTag, () => ( ObservabilityService));
1220
- const httpTag = _nullishCoalesce(options.httpTag, () => ( _chunkUOKXJQAIcjs.HttpClientService));
1220
+ const httpTag = _nullishCoalesce(options.httpTag, () => ( _chunkLA2PAO7Jcjs.HttpClientService));
1221
1221
  return _chunkZZ2CMYJLcjs.layerEffect.call(void 0,
1222
1222
  httpTag,
1223
1223
  (context) => _chunkMVGUEJ5Zcjs.asyncSync.call(void 0, () => {
@@ -1228,7 +1228,7 @@ function makeObservedHttpClientLayer(config = {}, options = {}) {
1228
1228
  context,
1229
1229
  observability
1230
1230
  );
1231
- return _chunkUOKXJQAIcjs.makeDefaultHttpClient.call(void 0, {
1231
+ return _chunkLA2PAO7Jcjs.makeDefaultHttpClient.call(void 0, {
1232
1232
  ...httpConfig,
1233
1233
  middleware: [
1234
1234
  ..._nullishCoalesce(httpConfig.middleware, () => ( [])),