brass-runtime 1.19.2 → 1.21.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 +88 -0
- package/dist/agent/cli/main.cjs +265 -43
- package/dist/agent/cli/main.d.ts +99 -0
- package/dist/agent/cli/main.js +238 -16
- package/dist/agent/cli/main.mjs +238 -16
- package/dist/agent/index.cjs +18 -2
- package/dist/agent/index.d.ts +60 -482
- package/dist/agent/index.js +17 -1
- package/dist/agent/index.mjs +17 -1
- package/dist/{chunk-QAHW7S3Q.cjs → chunk-62IBGQOU.cjs} +6 -6
- package/dist/{chunk-6AGAZD32.js → chunk-6LF3M4JC.js} +2 -2
- package/dist/{chunk-5X3MPWTR.mjs → chunk-6NXQL3IC.mjs} +370 -10
- package/dist/{chunk-J4F5KC3U.js → chunk-AI3M6624.js} +1260 -45
- package/dist/{chunk-TWEHIAUE.cjs → chunk-BDTBIYAM.cjs} +13 -13
- package/dist/{chunk-IA6BDGXW.mjs → chunk-D53GY2SZ.mjs} +2 -2
- package/dist/{chunk-IHY2EJTT.cjs → chunk-EX4VEKUF.cjs} +1340 -125
- package/dist/{chunk-UOKXJQAI.cjs → chunk-LA2PAO7J.cjs} +378 -18
- package/dist/{chunk-ZXXOXB3T.mjs → chunk-OS4F5HZE.mjs} +1 -1
- package/dist/{chunk-HKLZJ5UK.js → chunk-POH2WZBI.js} +370 -10
- package/dist/{chunk-6BNZS2A4.mjs → chunk-Q57ENQUW.mjs} +1260 -45
- package/dist/{chunk-BHX4MD35.js → chunk-VXZIP3IU.js} +1 -1
- package/dist/{defaultClient-hyVSNzSJ.d.ts → defaultClient-DLOa3gdw.d.ts} +101 -3
- package/dist/http/index.cjs +69 -33
- package/dist/http/index.d.ts +67 -4
- package/dist/http/index.js +37 -1
- package/dist/http/index.mjs +37 -1
- package/dist/http/testing.cjs +4 -4
- package/dist/http/testing.d.ts +1 -1
- package/dist/http/testing.js +1 -1
- package/dist/http/testing.mjs +1 -1
- package/dist/nodeWorkspaceDiscovery-Ami1UkMt.d.ts +631 -0
- package/dist/observability/index.cjs +3 -3
- package/dist/observability/index.d.ts +3 -3
- package/dist/observability/index.js +2 -2
- package/dist/observability/index.mjs +2 -2
- package/dist/perf/cli.cjs +18 -18
- package/dist/perf/cli.js +3 -3
- package/dist/perf/cli.mjs +3 -3
- package/dist/perf/index.cjs +5 -5
- package/dist/perf/index.js +3 -3
- package/dist/perf/index.mjs +3 -3
- package/dist/{server-BKKuzAW9.d.ts → server-BGXOabjo.d.ts} +1 -1
- package/package.json +1 -1
- package/wasm/pkg/package.json +1 -1
package/dist/agent/index.mjs
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AGENT_CONFIG_FILE_NAMES,
|
|
3
|
+
CI_INDICATORS,
|
|
3
4
|
NodeShell,
|
|
4
5
|
PROJECT_LOCKFILE_PROBES,
|
|
5
6
|
PROJECT_PROFILE_PROBES,
|
|
6
7
|
autoApproveApprovals,
|
|
8
|
+
buildHostProfile,
|
|
7
9
|
canAutoRollback,
|
|
8
10
|
canRequestPatchRepair,
|
|
11
|
+
collectHostSignals,
|
|
9
12
|
commandForScript,
|
|
10
13
|
decideNextAction,
|
|
14
|
+
deepFreeze,
|
|
11
15
|
defaultPermissions,
|
|
12
16
|
deriveContextSearchQueries,
|
|
13
17
|
describeCommandDiscovery,
|
|
@@ -27,6 +31,10 @@ import {
|
|
|
27
31
|
extractPatchPaths,
|
|
28
32
|
extractUnifiedDiff,
|
|
29
33
|
goalForAgentPreset,
|
|
34
|
+
inferCapabilities,
|
|
35
|
+
inferConstraints,
|
|
36
|
+
inferOptionalIdentity,
|
|
37
|
+
inferTransport,
|
|
30
38
|
inferUserLanguage,
|
|
31
39
|
initialAgentState,
|
|
32
40
|
invokeAction,
|
|
@@ -73,7 +81,7 @@ import {
|
|
|
73
81
|
timeout,
|
|
74
82
|
unappliedPatchStack,
|
|
75
83
|
workspaceValidationStatus
|
|
76
|
-
} from "../chunk-
|
|
84
|
+
} from "../chunk-Q57ENQUW.mjs";
|
|
77
85
|
import "../chunk-B5JD23U7.mjs";
|
|
78
86
|
import "../chunk-BFNBU47C.mjs";
|
|
79
87
|
import "../chunk-36I3M4UC.mjs";
|
|
@@ -81,14 +89,18 @@ import "../chunk-UZQ3BB6W.mjs";
|
|
|
81
89
|
import "../chunk-Y6FXYEAI.mjs";
|
|
82
90
|
export {
|
|
83
91
|
AGENT_CONFIG_FILE_NAMES,
|
|
92
|
+
CI_INDICATORS,
|
|
84
93
|
NodeShell,
|
|
85
94
|
PROJECT_LOCKFILE_PROBES,
|
|
86
95
|
PROJECT_PROFILE_PROBES,
|
|
87
96
|
autoApproveApprovals,
|
|
97
|
+
buildHostProfile,
|
|
88
98
|
canAutoRollback,
|
|
89
99
|
canRequestPatchRepair,
|
|
100
|
+
collectHostSignals,
|
|
90
101
|
commandForScript,
|
|
91
102
|
decideNextAction,
|
|
103
|
+
deepFreeze,
|
|
92
104
|
defaultPermissions,
|
|
93
105
|
deriveContextSearchQueries,
|
|
94
106
|
describeCommandDiscovery,
|
|
@@ -108,6 +120,10 @@ export {
|
|
|
108
120
|
extractPatchPaths,
|
|
109
121
|
extractUnifiedDiff,
|
|
110
122
|
goalForAgentPreset,
|
|
123
|
+
inferCapabilities,
|
|
124
|
+
inferConstraints,
|
|
125
|
+
inferOptionalIdentity,
|
|
126
|
+
inferTransport,
|
|
111
127
|
inferUserLanguage,
|
|
112
128
|
initialAgentState,
|
|
113
129
|
invokeAction,
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
var _chunkJQCQWO47cjs = require('./chunk-JQCQWO47.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
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
|
|
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
|
|
865
|
+
return _chunkLA2PAO7Jcjs.makeHttp.call(void 0, baseHttpConfig(baseUrl, scenario));
|
|
866
866
|
}
|
|
867
867
|
function makeMinimalClient(baseUrl, scenario) {
|
|
868
|
-
return
|
|
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
|
|
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
|
-
|
|
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-
|
|
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-
|
|
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(
|
|
5642
|
-
const client = (req) => trackRequest(
|
|
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(
|
|
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(
|
|
5665
|
-
if (!internals.adaptiveLimiter) return
|
|
5666
|
-
return Object.assign(((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(
|
|
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(
|
|
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,
|