@agentv/core 2.6.0 → 2.7.1-next.1

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.
@@ -0,0 +1,968 @@
1
+ // ../../node_modules/.bun/@opentelemetry+core@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/core/build/esm/baggage/propagation/W3CBaggagePropagator.js
2
+ import { propagation } from "@opentelemetry/api";
3
+
4
+ // ../../node_modules/.bun/@opentelemetry+core@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/core/build/esm/trace/suppress-tracing.js
5
+ import { createContextKey } from "@opentelemetry/api";
6
+ var SUPPRESS_TRACING_KEY = createContextKey("OpenTelemetry SDK Context Key SUPPRESS_TRACING");
7
+ function suppressTracing(context2) {
8
+ return context2.setValue(SUPPRESS_TRACING_KEY, true);
9
+ }
10
+ function unsuppressTracing(context2) {
11
+ return context2.deleteValue(SUPPRESS_TRACING_KEY);
12
+ }
13
+ function isTracingSuppressed(context2) {
14
+ return context2.getValue(SUPPRESS_TRACING_KEY) === true;
15
+ }
16
+
17
+ // ../../node_modules/.bun/@opentelemetry+core@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/core/build/esm/baggage/constants.js
18
+ var BAGGAGE_KEY_PAIR_SEPARATOR = "=";
19
+ var BAGGAGE_PROPERTIES_SEPARATOR = ";";
20
+ var BAGGAGE_ITEMS_SEPARATOR = ",";
21
+ var BAGGAGE_HEADER = "baggage";
22
+ var BAGGAGE_MAX_NAME_VALUE_PAIRS = 180;
23
+ var BAGGAGE_MAX_PER_NAME_VALUE_PAIRS = 4096;
24
+ var BAGGAGE_MAX_TOTAL_LENGTH = 8192;
25
+
26
+ // ../../node_modules/.bun/@opentelemetry+core@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/core/build/esm/baggage/utils.js
27
+ import { baggageEntryMetadataFromString } from "@opentelemetry/api";
28
+ function serializeKeyPairs(keyPairs) {
29
+ return keyPairs.reduce((hValue, current) => {
30
+ const value = `${hValue}${hValue !== "" ? BAGGAGE_ITEMS_SEPARATOR : ""}${current}`;
31
+ return value.length > BAGGAGE_MAX_TOTAL_LENGTH ? hValue : value;
32
+ }, "");
33
+ }
34
+ function getKeyPairs(baggage) {
35
+ return baggage.getAllEntries().map(([key, value]) => {
36
+ let entry = `${encodeURIComponent(key)}=${encodeURIComponent(value.value)}`;
37
+ if (value.metadata !== void 0) {
38
+ entry += BAGGAGE_PROPERTIES_SEPARATOR + value.metadata.toString();
39
+ }
40
+ return entry;
41
+ });
42
+ }
43
+ function parsePairKeyValue(entry) {
44
+ if (!entry)
45
+ return;
46
+ const metadataSeparatorIndex = entry.indexOf(BAGGAGE_PROPERTIES_SEPARATOR);
47
+ const keyPairPart = metadataSeparatorIndex === -1 ? entry : entry.substring(0, metadataSeparatorIndex);
48
+ const separatorIndex = keyPairPart.indexOf(BAGGAGE_KEY_PAIR_SEPARATOR);
49
+ if (separatorIndex <= 0)
50
+ return;
51
+ const rawKey = keyPairPart.substring(0, separatorIndex).trim();
52
+ const rawValue = keyPairPart.substring(separatorIndex + 1).trim();
53
+ if (!rawKey || !rawValue)
54
+ return;
55
+ let key;
56
+ let value;
57
+ try {
58
+ key = decodeURIComponent(rawKey);
59
+ value = decodeURIComponent(rawValue);
60
+ } catch {
61
+ return;
62
+ }
63
+ let metadata;
64
+ if (metadataSeparatorIndex !== -1 && metadataSeparatorIndex < entry.length - 1) {
65
+ const metadataString = entry.substring(metadataSeparatorIndex + 1);
66
+ metadata = baggageEntryMetadataFromString(metadataString);
67
+ }
68
+ return { key, value, metadata };
69
+ }
70
+ function parseKeyPairsIntoRecord(value) {
71
+ const result = {};
72
+ if (typeof value === "string" && value.length > 0) {
73
+ value.split(BAGGAGE_ITEMS_SEPARATOR).forEach((entry) => {
74
+ const keyPair = parsePairKeyValue(entry);
75
+ if (keyPair !== void 0 && keyPair.value.length > 0) {
76
+ result[keyPair.key] = keyPair.value;
77
+ }
78
+ });
79
+ }
80
+ return result;
81
+ }
82
+
83
+ // ../../node_modules/.bun/@opentelemetry+core@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/core/build/esm/baggage/propagation/W3CBaggagePropagator.js
84
+ var W3CBaggagePropagator = class {
85
+ inject(context2, carrier, setter) {
86
+ const baggage = propagation.getBaggage(context2);
87
+ if (!baggage || isTracingSuppressed(context2))
88
+ return;
89
+ const keyPairs = getKeyPairs(baggage).filter((pair) => {
90
+ return pair.length <= BAGGAGE_MAX_PER_NAME_VALUE_PAIRS;
91
+ }).slice(0, BAGGAGE_MAX_NAME_VALUE_PAIRS);
92
+ const headerValue = serializeKeyPairs(keyPairs);
93
+ if (headerValue.length > 0) {
94
+ setter.set(carrier, BAGGAGE_HEADER, headerValue);
95
+ }
96
+ }
97
+ extract(context2, carrier, getter) {
98
+ const headerValue = getter.get(carrier, BAGGAGE_HEADER);
99
+ const baggageString = Array.isArray(headerValue) ? headerValue.join(BAGGAGE_ITEMS_SEPARATOR) : headerValue;
100
+ if (!baggageString)
101
+ return context2;
102
+ const baggage = {};
103
+ if (baggageString.length === 0) {
104
+ return context2;
105
+ }
106
+ const pairs = baggageString.split(BAGGAGE_ITEMS_SEPARATOR);
107
+ pairs.forEach((entry) => {
108
+ const keyPair = parsePairKeyValue(entry);
109
+ if (keyPair) {
110
+ const baggageEntry = { value: keyPair.value };
111
+ if (keyPair.metadata) {
112
+ baggageEntry.metadata = keyPair.metadata;
113
+ }
114
+ baggage[keyPair.key] = baggageEntry;
115
+ }
116
+ });
117
+ if (Object.entries(baggage).length === 0) {
118
+ return context2;
119
+ }
120
+ return propagation.setBaggage(context2, propagation.createBaggage(baggage));
121
+ }
122
+ fields() {
123
+ return [BAGGAGE_HEADER];
124
+ }
125
+ };
126
+
127
+ // ../../node_modules/.bun/@opentelemetry+core@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/core/build/esm/common/anchored-clock.js
128
+ var AnchoredClock = class {
129
+ _monotonicClock;
130
+ _epochMillis;
131
+ _performanceMillis;
132
+ /**
133
+ * Create a new AnchoredClock anchored to the current time returned by systemClock.
134
+ *
135
+ * @param systemClock should be a clock that returns the number of milliseconds since January 1 1970 such as Date
136
+ * @param monotonicClock should be a clock that counts milliseconds monotonically such as window.performance or perf_hooks.performance
137
+ */
138
+ constructor(systemClock, monotonicClock) {
139
+ this._monotonicClock = monotonicClock;
140
+ this._epochMillis = systemClock.now();
141
+ this._performanceMillis = monotonicClock.now();
142
+ }
143
+ /**
144
+ * Returns the current time by adding the number of milliseconds since the
145
+ * AnchoredClock was created to the creation epoch time
146
+ */
147
+ now() {
148
+ const delta = this._monotonicClock.now() - this._performanceMillis;
149
+ return this._epochMillis + delta;
150
+ }
151
+ };
152
+
153
+ // ../../node_modules/.bun/@opentelemetry+core@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/core/build/esm/common/attributes.js
154
+ import { diag } from "@opentelemetry/api";
155
+ function sanitizeAttributes(attributes) {
156
+ const out = {};
157
+ if (typeof attributes !== "object" || attributes == null) {
158
+ return out;
159
+ }
160
+ for (const key in attributes) {
161
+ if (!Object.prototype.hasOwnProperty.call(attributes, key)) {
162
+ continue;
163
+ }
164
+ if (!isAttributeKey(key)) {
165
+ diag.warn(`Invalid attribute key: ${key}`);
166
+ continue;
167
+ }
168
+ const val = attributes[key];
169
+ if (!isAttributeValue(val)) {
170
+ diag.warn(`Invalid attribute value set for key: ${key}`);
171
+ continue;
172
+ }
173
+ if (Array.isArray(val)) {
174
+ out[key] = val.slice();
175
+ } else {
176
+ out[key] = val;
177
+ }
178
+ }
179
+ return out;
180
+ }
181
+ function isAttributeKey(key) {
182
+ return typeof key === "string" && key !== "";
183
+ }
184
+ function isAttributeValue(val) {
185
+ if (val == null) {
186
+ return true;
187
+ }
188
+ if (Array.isArray(val)) {
189
+ return isHomogeneousAttributeValueArray(val);
190
+ }
191
+ return isValidPrimitiveAttributeValueType(typeof val);
192
+ }
193
+ function isHomogeneousAttributeValueArray(arr) {
194
+ let type;
195
+ for (const element of arr) {
196
+ if (element == null)
197
+ continue;
198
+ const elementType = typeof element;
199
+ if (elementType === type) {
200
+ continue;
201
+ }
202
+ if (!type) {
203
+ if (isValidPrimitiveAttributeValueType(elementType)) {
204
+ type = elementType;
205
+ continue;
206
+ }
207
+ return false;
208
+ }
209
+ return false;
210
+ }
211
+ return true;
212
+ }
213
+ function isValidPrimitiveAttributeValueType(valType) {
214
+ switch (valType) {
215
+ case "number":
216
+ case "boolean":
217
+ case "string":
218
+ return true;
219
+ }
220
+ return false;
221
+ }
222
+
223
+ // ../../node_modules/.bun/@opentelemetry+core@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/core/build/esm/common/logging-error-handler.js
224
+ import { diag as diag2 } from "@opentelemetry/api";
225
+ function loggingErrorHandler() {
226
+ return (ex) => {
227
+ diag2.error(stringifyException(ex));
228
+ };
229
+ }
230
+ function stringifyException(ex) {
231
+ if (typeof ex === "string") {
232
+ return ex;
233
+ } else {
234
+ return JSON.stringify(flattenException(ex));
235
+ }
236
+ }
237
+ function flattenException(ex) {
238
+ const result = {};
239
+ let current = ex;
240
+ while (current !== null) {
241
+ Object.getOwnPropertyNames(current).forEach((propertyName) => {
242
+ if (result[propertyName])
243
+ return;
244
+ const value = current[propertyName];
245
+ if (value) {
246
+ result[propertyName] = String(value);
247
+ }
248
+ });
249
+ current = Object.getPrototypeOf(current);
250
+ }
251
+ return result;
252
+ }
253
+
254
+ // ../../node_modules/.bun/@opentelemetry+core@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/core/build/esm/common/global-error-handler.js
255
+ var delegateHandler = loggingErrorHandler();
256
+ function setGlobalErrorHandler(handler) {
257
+ delegateHandler = handler;
258
+ }
259
+ function globalErrorHandler(ex) {
260
+ try {
261
+ delegateHandler(ex);
262
+ } catch {
263
+ }
264
+ }
265
+
266
+ // ../../node_modules/.bun/@opentelemetry+core@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/core/build/esm/platform/node/environment.js
267
+ import { diag as diag3 } from "@opentelemetry/api";
268
+ import { inspect } from "util";
269
+ function getNumberFromEnv(key) {
270
+ const raw = process.env[key];
271
+ if (raw == null || raw.trim() === "") {
272
+ return void 0;
273
+ }
274
+ const value = Number(raw);
275
+ if (isNaN(value)) {
276
+ diag3.warn(`Unknown value ${inspect(raw)} for ${key}, expected a number, using defaults`);
277
+ return void 0;
278
+ }
279
+ return value;
280
+ }
281
+ function getStringFromEnv(key) {
282
+ const raw = process.env[key];
283
+ if (raw == null || raw.trim() === "") {
284
+ return void 0;
285
+ }
286
+ return raw;
287
+ }
288
+ function getBooleanFromEnv(key) {
289
+ const raw = process.env[key]?.trim().toLowerCase();
290
+ if (raw == null || raw === "") {
291
+ return false;
292
+ }
293
+ if (raw === "true") {
294
+ return true;
295
+ } else if (raw === "false") {
296
+ return false;
297
+ } else {
298
+ diag3.warn(`Unknown value ${inspect(raw)} for ${key}, expected 'true' or 'false', falling back to 'false' (default)`);
299
+ return false;
300
+ }
301
+ }
302
+ function getStringListFromEnv(key) {
303
+ return getStringFromEnv(key)?.split(",").map((v) => v.trim()).filter((s) => s !== "");
304
+ }
305
+
306
+ // ../../node_modules/.bun/@opentelemetry+core@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/core/build/esm/common/globalThis.js
307
+ var _globalThis = globalThis;
308
+
309
+ // ../../node_modules/.bun/@opentelemetry+core@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/core/build/esm/version.js
310
+ var VERSION = "2.5.1";
311
+
312
+ // ../../node_modules/.bun/@opentelemetry+core@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/core/build/esm/platform/node/sdk-info.js
313
+ import { ATTR_TELEMETRY_SDK_NAME, ATTR_TELEMETRY_SDK_LANGUAGE, TELEMETRY_SDK_LANGUAGE_VALUE_NODEJS, ATTR_TELEMETRY_SDK_VERSION } from "@opentelemetry/semantic-conventions";
314
+
315
+ // ../../node_modules/.bun/@opentelemetry+core@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/core/build/esm/semconv.js
316
+ var ATTR_PROCESS_RUNTIME_NAME = "process.runtime.name";
317
+
318
+ // ../../node_modules/.bun/@opentelemetry+core@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/core/build/esm/platform/node/sdk-info.js
319
+ var SDK_INFO = {
320
+ [ATTR_TELEMETRY_SDK_NAME]: "opentelemetry",
321
+ [ATTR_PROCESS_RUNTIME_NAME]: "node",
322
+ [ATTR_TELEMETRY_SDK_LANGUAGE]: TELEMETRY_SDK_LANGUAGE_VALUE_NODEJS,
323
+ [ATTR_TELEMETRY_SDK_VERSION]: VERSION
324
+ };
325
+
326
+ // ../../node_modules/.bun/@opentelemetry+core@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/core/build/esm/platform/node/index.js
327
+ var otperformance = performance;
328
+
329
+ // ../../node_modules/.bun/@opentelemetry+core@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/core/build/esm/common/time.js
330
+ var NANOSECOND_DIGITS = 9;
331
+ var NANOSECOND_DIGITS_IN_MILLIS = 6;
332
+ var MILLISECONDS_TO_NANOSECONDS = Math.pow(10, NANOSECOND_DIGITS_IN_MILLIS);
333
+ var SECOND_TO_NANOSECONDS = Math.pow(10, NANOSECOND_DIGITS);
334
+ function millisToHrTime(epochMillis) {
335
+ const epochSeconds = epochMillis / 1e3;
336
+ const seconds = Math.trunc(epochSeconds);
337
+ const nanos = Math.round(epochMillis % 1e3 * MILLISECONDS_TO_NANOSECONDS);
338
+ return [seconds, nanos];
339
+ }
340
+ function getTimeOrigin() {
341
+ return otperformance.timeOrigin;
342
+ }
343
+ function hrTime(performanceNow) {
344
+ const timeOrigin = millisToHrTime(otperformance.timeOrigin);
345
+ const now = millisToHrTime(typeof performanceNow === "number" ? performanceNow : otperformance.now());
346
+ return addHrTimes(timeOrigin, now);
347
+ }
348
+ function timeInputToHrTime(time) {
349
+ if (isTimeInputHrTime(time)) {
350
+ return time;
351
+ } else if (typeof time === "number") {
352
+ if (time < otperformance.timeOrigin) {
353
+ return hrTime(time);
354
+ } else {
355
+ return millisToHrTime(time);
356
+ }
357
+ } else if (time instanceof Date) {
358
+ return millisToHrTime(time.getTime());
359
+ } else {
360
+ throw TypeError("Invalid input type");
361
+ }
362
+ }
363
+ function hrTimeDuration(startTime, endTime) {
364
+ let seconds = endTime[0] - startTime[0];
365
+ let nanos = endTime[1] - startTime[1];
366
+ if (nanos < 0) {
367
+ seconds -= 1;
368
+ nanos += SECOND_TO_NANOSECONDS;
369
+ }
370
+ return [seconds, nanos];
371
+ }
372
+ function hrTimeToTimeStamp(time) {
373
+ const precision = NANOSECOND_DIGITS;
374
+ const tmp = `${"0".repeat(precision)}${time[1]}Z`;
375
+ const nanoString = tmp.substring(tmp.length - precision - 1);
376
+ const date = new Date(time[0] * 1e3).toISOString();
377
+ return date.replace("000Z", nanoString);
378
+ }
379
+ function hrTimeToNanoseconds(time) {
380
+ return time[0] * SECOND_TO_NANOSECONDS + time[1];
381
+ }
382
+ function hrTimeToMilliseconds(time) {
383
+ return time[0] * 1e3 + time[1] / 1e6;
384
+ }
385
+ function hrTimeToMicroseconds(time) {
386
+ return time[0] * 1e6 + time[1] / 1e3;
387
+ }
388
+ function isTimeInputHrTime(value) {
389
+ return Array.isArray(value) && value.length === 2 && typeof value[0] === "number" && typeof value[1] === "number";
390
+ }
391
+ function isTimeInput(value) {
392
+ return isTimeInputHrTime(value) || typeof value === "number" || value instanceof Date;
393
+ }
394
+ function addHrTimes(time1, time2) {
395
+ const out = [time1[0] + time2[0], time1[1] + time2[1]];
396
+ if (out[1] >= SECOND_TO_NANOSECONDS) {
397
+ out[1] -= SECOND_TO_NANOSECONDS;
398
+ out[0] += 1;
399
+ }
400
+ return out;
401
+ }
402
+
403
+ // ../../node_modules/.bun/@opentelemetry+core@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/core/build/esm/common/timer-util.js
404
+ function unrefTimer(timer) {
405
+ if (typeof timer !== "number") {
406
+ timer.unref();
407
+ }
408
+ }
409
+
410
+ // ../../node_modules/.bun/@opentelemetry+core@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/core/build/esm/ExportResult.js
411
+ var ExportResultCode;
412
+ (function(ExportResultCode2) {
413
+ ExportResultCode2[ExportResultCode2["SUCCESS"] = 0] = "SUCCESS";
414
+ ExportResultCode2[ExportResultCode2["FAILED"] = 1] = "FAILED";
415
+ })(ExportResultCode || (ExportResultCode = {}));
416
+
417
+ // ../../node_modules/.bun/@opentelemetry+core@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/core/build/esm/propagation/composite.js
418
+ import { diag as diag4 } from "@opentelemetry/api";
419
+ var CompositePropagator = class {
420
+ _propagators;
421
+ _fields;
422
+ /**
423
+ * Construct a composite propagator from a list of propagators.
424
+ *
425
+ * @param [config] Configuration object for composite propagator
426
+ */
427
+ constructor(config = {}) {
428
+ this._propagators = config.propagators ?? [];
429
+ this._fields = Array.from(new Set(this._propagators.map((p) => typeof p.fields === "function" ? p.fields() : []).reduce((x, y) => x.concat(y), [])));
430
+ }
431
+ /**
432
+ * Run each of the configured propagators with the given context and carrier.
433
+ * Propagators are run in the order they are configured, so if multiple
434
+ * propagators write the same carrier key, the propagator later in the list
435
+ * will "win".
436
+ *
437
+ * @param context Context to inject
438
+ * @param carrier Carrier into which context will be injected
439
+ */
440
+ inject(context2, carrier, setter) {
441
+ for (const propagator of this._propagators) {
442
+ try {
443
+ propagator.inject(context2, carrier, setter);
444
+ } catch (err) {
445
+ diag4.warn(`Failed to inject with ${propagator.constructor.name}. Err: ${err.message}`);
446
+ }
447
+ }
448
+ }
449
+ /**
450
+ * Run each of the configured propagators with the given context and carrier.
451
+ * Propagators are run in the order they are configured, so if multiple
452
+ * propagators write the same context key, the propagator later in the list
453
+ * will "win".
454
+ *
455
+ * @param context Context to add values to
456
+ * @param carrier Carrier from which to extract context
457
+ */
458
+ extract(context2, carrier, getter) {
459
+ return this._propagators.reduce((ctx, propagator) => {
460
+ try {
461
+ return propagator.extract(ctx, carrier, getter);
462
+ } catch (err) {
463
+ diag4.warn(`Failed to extract with ${propagator.constructor.name}. Err: ${err.message}`);
464
+ }
465
+ return ctx;
466
+ }, context2);
467
+ }
468
+ fields() {
469
+ return this._fields.slice();
470
+ }
471
+ };
472
+
473
+ // ../../node_modules/.bun/@opentelemetry+core@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/core/build/esm/trace/W3CTraceContextPropagator.js
474
+ import { isSpanContextValid, trace, TraceFlags } from "@opentelemetry/api";
475
+
476
+ // ../../node_modules/.bun/@opentelemetry+core@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/core/build/esm/internal/validators.js
477
+ var VALID_KEY_CHAR_RANGE = "[_0-9a-z-*/]";
478
+ var VALID_KEY = `[a-z]${VALID_KEY_CHAR_RANGE}{0,255}`;
479
+ var VALID_VENDOR_KEY = `[a-z0-9]${VALID_KEY_CHAR_RANGE}{0,240}@[a-z]${VALID_KEY_CHAR_RANGE}{0,13}`;
480
+ var VALID_KEY_REGEX = new RegExp(`^(?:${VALID_KEY}|${VALID_VENDOR_KEY})$`);
481
+ var VALID_VALUE_BASE_REGEX = /^[ -~]{0,255}[!-~]$/;
482
+ var INVALID_VALUE_COMMA_EQUAL_REGEX = /,|=/;
483
+ function validateKey(key) {
484
+ return VALID_KEY_REGEX.test(key);
485
+ }
486
+ function validateValue(value) {
487
+ return VALID_VALUE_BASE_REGEX.test(value) && !INVALID_VALUE_COMMA_EQUAL_REGEX.test(value);
488
+ }
489
+
490
+ // ../../node_modules/.bun/@opentelemetry+core@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/core/build/esm/trace/TraceState.js
491
+ var MAX_TRACE_STATE_ITEMS = 32;
492
+ var MAX_TRACE_STATE_LEN = 512;
493
+ var LIST_MEMBERS_SEPARATOR = ",";
494
+ var LIST_MEMBER_KEY_VALUE_SPLITTER = "=";
495
+ var TraceState = class _TraceState {
496
+ _internalState = /* @__PURE__ */ new Map();
497
+ constructor(rawTraceState) {
498
+ if (rawTraceState)
499
+ this._parse(rawTraceState);
500
+ }
501
+ set(key, value) {
502
+ const traceState = this._clone();
503
+ if (traceState._internalState.has(key)) {
504
+ traceState._internalState.delete(key);
505
+ }
506
+ traceState._internalState.set(key, value);
507
+ return traceState;
508
+ }
509
+ unset(key) {
510
+ const traceState = this._clone();
511
+ traceState._internalState.delete(key);
512
+ return traceState;
513
+ }
514
+ get(key) {
515
+ return this._internalState.get(key);
516
+ }
517
+ serialize() {
518
+ return this._keys().reduce((agg, key) => {
519
+ agg.push(key + LIST_MEMBER_KEY_VALUE_SPLITTER + this.get(key));
520
+ return agg;
521
+ }, []).join(LIST_MEMBERS_SEPARATOR);
522
+ }
523
+ _parse(rawTraceState) {
524
+ if (rawTraceState.length > MAX_TRACE_STATE_LEN)
525
+ return;
526
+ this._internalState = rawTraceState.split(LIST_MEMBERS_SEPARATOR).reverse().reduce((agg, part) => {
527
+ const listMember = part.trim();
528
+ const i = listMember.indexOf(LIST_MEMBER_KEY_VALUE_SPLITTER);
529
+ if (i !== -1) {
530
+ const key = listMember.slice(0, i);
531
+ const value = listMember.slice(i + 1, part.length);
532
+ if (validateKey(key) && validateValue(value)) {
533
+ agg.set(key, value);
534
+ } else {
535
+ }
536
+ }
537
+ return agg;
538
+ }, /* @__PURE__ */ new Map());
539
+ if (this._internalState.size > MAX_TRACE_STATE_ITEMS) {
540
+ this._internalState = new Map(Array.from(this._internalState.entries()).reverse().slice(0, MAX_TRACE_STATE_ITEMS));
541
+ }
542
+ }
543
+ _keys() {
544
+ return Array.from(this._internalState.keys()).reverse();
545
+ }
546
+ _clone() {
547
+ const traceState = new _TraceState();
548
+ traceState._internalState = new Map(this._internalState);
549
+ return traceState;
550
+ }
551
+ };
552
+
553
+ // ../../node_modules/.bun/@opentelemetry+core@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/core/build/esm/trace/W3CTraceContextPropagator.js
554
+ var TRACE_PARENT_HEADER = "traceparent";
555
+ var TRACE_STATE_HEADER = "tracestate";
556
+ var VERSION2 = "00";
557
+ var VERSION_PART = "(?!ff)[\\da-f]{2}";
558
+ var TRACE_ID_PART = "(?![0]{32})[\\da-f]{32}";
559
+ var PARENT_ID_PART = "(?![0]{16})[\\da-f]{16}";
560
+ var FLAGS_PART = "[\\da-f]{2}";
561
+ var TRACE_PARENT_REGEX = new RegExp(`^\\s?(${VERSION_PART})-(${TRACE_ID_PART})-(${PARENT_ID_PART})-(${FLAGS_PART})(-.*)?\\s?$`);
562
+ function parseTraceParent(traceParent) {
563
+ const match = TRACE_PARENT_REGEX.exec(traceParent);
564
+ if (!match)
565
+ return null;
566
+ if (match[1] === "00" && match[5])
567
+ return null;
568
+ return {
569
+ traceId: match[2],
570
+ spanId: match[3],
571
+ traceFlags: parseInt(match[4], 16)
572
+ };
573
+ }
574
+ var W3CTraceContextPropagator = class {
575
+ inject(context2, carrier, setter) {
576
+ const spanContext = trace.getSpanContext(context2);
577
+ if (!spanContext || isTracingSuppressed(context2) || !isSpanContextValid(spanContext))
578
+ return;
579
+ const traceParent = `${VERSION2}-${spanContext.traceId}-${spanContext.spanId}-0${Number(spanContext.traceFlags || TraceFlags.NONE).toString(16)}`;
580
+ setter.set(carrier, TRACE_PARENT_HEADER, traceParent);
581
+ if (spanContext.traceState) {
582
+ setter.set(carrier, TRACE_STATE_HEADER, spanContext.traceState.serialize());
583
+ }
584
+ }
585
+ extract(context2, carrier, getter) {
586
+ const traceParentHeader = getter.get(carrier, TRACE_PARENT_HEADER);
587
+ if (!traceParentHeader)
588
+ return context2;
589
+ const traceParent = Array.isArray(traceParentHeader) ? traceParentHeader[0] : traceParentHeader;
590
+ if (typeof traceParent !== "string")
591
+ return context2;
592
+ const spanContext = parseTraceParent(traceParent);
593
+ if (!spanContext)
594
+ return context2;
595
+ spanContext.isRemote = true;
596
+ const traceStateHeader = getter.get(carrier, TRACE_STATE_HEADER);
597
+ if (traceStateHeader) {
598
+ const state = Array.isArray(traceStateHeader) ? traceStateHeader.join(",") : traceStateHeader;
599
+ spanContext.traceState = new TraceState(typeof state === "string" ? state : void 0);
600
+ }
601
+ return trace.setSpanContext(context2, spanContext);
602
+ }
603
+ fields() {
604
+ return [TRACE_PARENT_HEADER, TRACE_STATE_HEADER];
605
+ }
606
+ };
607
+
608
+ // ../../node_modules/.bun/@opentelemetry+core@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/core/build/esm/trace/rpc-metadata.js
609
+ import { createContextKey as createContextKey2 } from "@opentelemetry/api";
610
+ var RPC_METADATA_KEY = createContextKey2("OpenTelemetry SDK Context Key RPC_METADATA");
611
+ var RPCType;
612
+ (function(RPCType2) {
613
+ RPCType2["HTTP"] = "http";
614
+ })(RPCType || (RPCType = {}));
615
+ function setRPCMetadata(context2, meta) {
616
+ return context2.setValue(RPC_METADATA_KEY, meta);
617
+ }
618
+ function deleteRPCMetadata(context2) {
619
+ return context2.deleteValue(RPC_METADATA_KEY);
620
+ }
621
+ function getRPCMetadata(context2) {
622
+ return context2.getValue(RPC_METADATA_KEY);
623
+ }
624
+
625
+ // ../../node_modules/.bun/@opentelemetry+core@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/core/build/esm/utils/lodash.merge.js
626
+ var objectTag = "[object Object]";
627
+ var nullTag = "[object Null]";
628
+ var undefinedTag = "[object Undefined]";
629
+ var funcProto = Function.prototype;
630
+ var funcToString = funcProto.toString;
631
+ var objectCtorString = funcToString.call(Object);
632
+ var getPrototypeOf = Object.getPrototypeOf;
633
+ var objectProto = Object.prototype;
634
+ var hasOwnProperty = objectProto.hasOwnProperty;
635
+ var symToStringTag = Symbol ? Symbol.toStringTag : void 0;
636
+ var nativeObjectToString = objectProto.toString;
637
+ function isPlainObject(value) {
638
+ if (!isObjectLike(value) || baseGetTag(value) !== objectTag) {
639
+ return false;
640
+ }
641
+ const proto = getPrototypeOf(value);
642
+ if (proto === null) {
643
+ return true;
644
+ }
645
+ const Ctor = hasOwnProperty.call(proto, "constructor") && proto.constructor;
646
+ return typeof Ctor == "function" && Ctor instanceof Ctor && funcToString.call(Ctor) === objectCtorString;
647
+ }
648
+ function isObjectLike(value) {
649
+ return value != null && typeof value == "object";
650
+ }
651
+ function baseGetTag(value) {
652
+ if (value == null) {
653
+ return value === void 0 ? undefinedTag : nullTag;
654
+ }
655
+ return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
656
+ }
657
+ function getRawTag(value) {
658
+ const isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag];
659
+ let unmasked = false;
660
+ try {
661
+ value[symToStringTag] = void 0;
662
+ unmasked = true;
663
+ } catch {
664
+ }
665
+ const result = nativeObjectToString.call(value);
666
+ if (unmasked) {
667
+ if (isOwn) {
668
+ value[symToStringTag] = tag;
669
+ } else {
670
+ delete value[symToStringTag];
671
+ }
672
+ }
673
+ return result;
674
+ }
675
+ function objectToString(value) {
676
+ return nativeObjectToString.call(value);
677
+ }
678
+
679
+ // ../../node_modules/.bun/@opentelemetry+core@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/core/build/esm/utils/merge.js
680
+ var MAX_LEVEL = 20;
681
+ function merge(...args) {
682
+ let result = args.shift();
683
+ const objects = /* @__PURE__ */ new WeakMap();
684
+ while (args.length > 0) {
685
+ result = mergeTwoObjects(result, args.shift(), 0, objects);
686
+ }
687
+ return result;
688
+ }
689
+ function takeValue(value) {
690
+ if (isArray(value)) {
691
+ return value.slice();
692
+ }
693
+ return value;
694
+ }
695
+ function mergeTwoObjects(one, two, level = 0, objects) {
696
+ let result;
697
+ if (level > MAX_LEVEL) {
698
+ return void 0;
699
+ }
700
+ level++;
701
+ if (isPrimitive(one) || isPrimitive(two) || isFunction(two)) {
702
+ result = takeValue(two);
703
+ } else if (isArray(one)) {
704
+ result = one.slice();
705
+ if (isArray(two)) {
706
+ for (let i = 0, j = two.length; i < j; i++) {
707
+ result.push(takeValue(two[i]));
708
+ }
709
+ } else if (isObject(two)) {
710
+ const keys = Object.keys(two);
711
+ for (let i = 0, j = keys.length; i < j; i++) {
712
+ const key = keys[i];
713
+ result[key] = takeValue(two[key]);
714
+ }
715
+ }
716
+ } else if (isObject(one)) {
717
+ if (isObject(two)) {
718
+ if (!shouldMerge(one, two)) {
719
+ return two;
720
+ }
721
+ result = Object.assign({}, one);
722
+ const keys = Object.keys(two);
723
+ for (let i = 0, j = keys.length; i < j; i++) {
724
+ const key = keys[i];
725
+ const twoValue = two[key];
726
+ if (isPrimitive(twoValue)) {
727
+ if (typeof twoValue === "undefined") {
728
+ delete result[key];
729
+ } else {
730
+ result[key] = twoValue;
731
+ }
732
+ } else {
733
+ const obj1 = result[key];
734
+ const obj2 = twoValue;
735
+ if (wasObjectReferenced(one, key, objects) || wasObjectReferenced(two, key, objects)) {
736
+ delete result[key];
737
+ } else {
738
+ if (isObject(obj1) && isObject(obj2)) {
739
+ const arr1 = objects.get(obj1) || [];
740
+ const arr2 = objects.get(obj2) || [];
741
+ arr1.push({ obj: one, key });
742
+ arr2.push({ obj: two, key });
743
+ objects.set(obj1, arr1);
744
+ objects.set(obj2, arr2);
745
+ }
746
+ result[key] = mergeTwoObjects(result[key], twoValue, level, objects);
747
+ }
748
+ }
749
+ }
750
+ } else {
751
+ result = two;
752
+ }
753
+ }
754
+ return result;
755
+ }
756
+ function wasObjectReferenced(obj, key, objects) {
757
+ const arr = objects.get(obj[key]) || [];
758
+ for (let i = 0, j = arr.length; i < j; i++) {
759
+ const info = arr[i];
760
+ if (info.key === key && info.obj === obj) {
761
+ return true;
762
+ }
763
+ }
764
+ return false;
765
+ }
766
+ function isArray(value) {
767
+ return Array.isArray(value);
768
+ }
769
+ function isFunction(value) {
770
+ return typeof value === "function";
771
+ }
772
+ function isObject(value) {
773
+ return !isPrimitive(value) && !isArray(value) && !isFunction(value) && typeof value === "object";
774
+ }
775
+ function isPrimitive(value) {
776
+ return typeof value === "string" || typeof value === "number" || typeof value === "boolean" || typeof value === "undefined" || value instanceof Date || value instanceof RegExp || value === null;
777
+ }
778
+ function shouldMerge(one, two) {
779
+ if (!isPlainObject(one) || !isPlainObject(two)) {
780
+ return false;
781
+ }
782
+ return true;
783
+ }
784
+
785
+ // ../../node_modules/.bun/@opentelemetry+core@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/core/build/esm/utils/timeout.js
786
+ var TimeoutError = class _TimeoutError extends Error {
787
+ constructor(message) {
788
+ super(message);
789
+ Object.setPrototypeOf(this, _TimeoutError.prototype);
790
+ }
791
+ };
792
+ function callWithTimeout(promise, timeout) {
793
+ let timeoutHandle;
794
+ const timeoutPromise = new Promise(function timeoutFunction(_resolve, reject) {
795
+ timeoutHandle = setTimeout(function timeoutHandler() {
796
+ reject(new TimeoutError("Operation timed out."));
797
+ }, timeout);
798
+ });
799
+ return Promise.race([promise, timeoutPromise]).then((result) => {
800
+ clearTimeout(timeoutHandle);
801
+ return result;
802
+ }, (reason) => {
803
+ clearTimeout(timeoutHandle);
804
+ throw reason;
805
+ });
806
+ }
807
+
808
+ // ../../node_modules/.bun/@opentelemetry+core@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/core/build/esm/utils/url.js
809
+ function urlMatches(url, urlToMatch) {
810
+ if (typeof urlToMatch === "string") {
811
+ return url === urlToMatch;
812
+ } else {
813
+ return !!url.match(urlToMatch);
814
+ }
815
+ }
816
+ function isUrlIgnored(url, ignoredUrls) {
817
+ if (!ignoredUrls) {
818
+ return false;
819
+ }
820
+ for (const ignoreUrl of ignoredUrls) {
821
+ if (urlMatches(url, ignoreUrl)) {
822
+ return true;
823
+ }
824
+ }
825
+ return false;
826
+ }
827
+
828
+ // ../../node_modules/.bun/@opentelemetry+core@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/core/build/esm/utils/promise.js
829
+ var Deferred = class {
830
+ _promise;
831
+ _resolve;
832
+ _reject;
833
+ constructor() {
834
+ this._promise = new Promise((resolve, reject) => {
835
+ this._resolve = resolve;
836
+ this._reject = reject;
837
+ });
838
+ }
839
+ get promise() {
840
+ return this._promise;
841
+ }
842
+ resolve(val) {
843
+ this._resolve(val);
844
+ }
845
+ reject(err) {
846
+ this._reject(err);
847
+ }
848
+ };
849
+
850
+ // ../../node_modules/.bun/@opentelemetry+core@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/core/build/esm/utils/callback.js
851
+ var BindOnceFuture = class {
852
+ _isCalled = false;
853
+ _deferred = new Deferred();
854
+ _callback;
855
+ _that;
856
+ constructor(callback, that) {
857
+ this._callback = callback;
858
+ this._that = that;
859
+ }
860
+ get isCalled() {
861
+ return this._isCalled;
862
+ }
863
+ get promise() {
864
+ return this._deferred.promise;
865
+ }
866
+ call(...args) {
867
+ if (!this._isCalled) {
868
+ this._isCalled = true;
869
+ try {
870
+ Promise.resolve(this._callback.call(this._that, ...args)).then((val) => this._deferred.resolve(val), (err) => this._deferred.reject(err));
871
+ } catch (err) {
872
+ this._deferred.reject(err);
873
+ }
874
+ }
875
+ return this._deferred.promise;
876
+ }
877
+ };
878
+
879
+ // ../../node_modules/.bun/@opentelemetry+core@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/core/build/esm/utils/configuration.js
880
+ import { diag as diag5, DiagLogLevel } from "@opentelemetry/api";
881
+ var logLevelMap = {
882
+ ALL: DiagLogLevel.ALL,
883
+ VERBOSE: DiagLogLevel.VERBOSE,
884
+ DEBUG: DiagLogLevel.DEBUG,
885
+ INFO: DiagLogLevel.INFO,
886
+ WARN: DiagLogLevel.WARN,
887
+ ERROR: DiagLogLevel.ERROR,
888
+ NONE: DiagLogLevel.NONE
889
+ };
890
+ function diagLogLevelFromString(value) {
891
+ if (value == null) {
892
+ return void 0;
893
+ }
894
+ const resolvedLogLevel = logLevelMap[value.toUpperCase()];
895
+ if (resolvedLogLevel == null) {
896
+ diag5.warn(`Unknown log level "${value}", expected one of ${Object.keys(logLevelMap)}, using default`);
897
+ return DiagLogLevel.INFO;
898
+ }
899
+ return resolvedLogLevel;
900
+ }
901
+
902
+ // ../../node_modules/.bun/@opentelemetry+core@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/core/build/esm/internal/exporter.js
903
+ import { context } from "@opentelemetry/api";
904
+ function _export(exporter, arg) {
905
+ return new Promise((resolve) => {
906
+ context.with(suppressTracing(context.active()), () => {
907
+ exporter.export(arg, resolve);
908
+ });
909
+ });
910
+ }
911
+
912
+ // ../../node_modules/.bun/@opentelemetry+core@2.5.1+460773ef8ff1e07c/node_modules/@opentelemetry/core/build/esm/index.js
913
+ var internal = {
914
+ _export
915
+ };
916
+ export {
917
+ AnchoredClock,
918
+ BindOnceFuture,
919
+ CompositePropagator,
920
+ ExportResultCode,
921
+ RPCType,
922
+ SDK_INFO,
923
+ TRACE_PARENT_HEADER,
924
+ TRACE_STATE_HEADER,
925
+ TimeoutError,
926
+ TraceState,
927
+ W3CBaggagePropagator,
928
+ W3CTraceContextPropagator,
929
+ _globalThis,
930
+ addHrTimes,
931
+ callWithTimeout,
932
+ deleteRPCMetadata,
933
+ diagLogLevelFromString,
934
+ getBooleanFromEnv,
935
+ getNumberFromEnv,
936
+ getRPCMetadata,
937
+ getStringFromEnv,
938
+ getStringListFromEnv,
939
+ getTimeOrigin,
940
+ globalErrorHandler,
941
+ hrTime,
942
+ hrTimeDuration,
943
+ hrTimeToMicroseconds,
944
+ hrTimeToMilliseconds,
945
+ hrTimeToNanoseconds,
946
+ hrTimeToTimeStamp,
947
+ internal,
948
+ isAttributeValue,
949
+ isTimeInput,
950
+ isTimeInputHrTime,
951
+ isTracingSuppressed,
952
+ isUrlIgnored,
953
+ loggingErrorHandler,
954
+ merge,
955
+ millisToHrTime,
956
+ otperformance,
957
+ parseKeyPairsIntoRecord,
958
+ parseTraceParent,
959
+ sanitizeAttributes,
960
+ setGlobalErrorHandler,
961
+ setRPCMetadata,
962
+ suppressTracing,
963
+ timeInputToHrTime,
964
+ unrefTimer,
965
+ unsuppressTracing,
966
+ urlMatches
967
+ };
968
+ //# sourceMappingURL=esm-5Q4BZALM.js.map