braintrust 3.20.0 → 3.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/NOTICE +20 -0
- package/README.md +2 -0
- package/dev/dist/index.d.mts +309 -199
- package/dev/dist/index.d.ts +309 -199
- package/dev/dist/index.js +2826 -983
- package/dev/dist/index.mjs +2286 -443
- package/dist/apply-auto-instrumentation.js +781 -199
- package/dist/apply-auto-instrumentation.mjs +588 -6
- package/dist/auto-instrumentations/bundler/esbuild.cjs +594 -2
- package/dist/auto-instrumentations/bundler/esbuild.d.mts +2 -2
- package/dist/auto-instrumentations/bundler/esbuild.d.ts +2 -2
- package/dist/auto-instrumentations/bundler/esbuild.mjs +3 -3
- package/dist/auto-instrumentations/bundler/next.cjs +594 -2
- package/dist/auto-instrumentations/bundler/next.mjs +4 -4
- package/dist/auto-instrumentations/bundler/rollup.cjs +594 -2
- package/dist/auto-instrumentations/bundler/rollup.d.mts +2 -2
- package/dist/auto-instrumentations/bundler/rollup.d.ts +2 -2
- package/dist/auto-instrumentations/bundler/rollup.mjs +3 -3
- package/dist/auto-instrumentations/bundler/vite.cjs +594 -2
- package/dist/auto-instrumentations/bundler/vite.d.mts +2 -2
- package/dist/auto-instrumentations/bundler/vite.d.ts +2 -2
- package/dist/auto-instrumentations/bundler/vite.mjs +3 -3
- package/dist/auto-instrumentations/bundler/webpack-loader.cjs +593 -9
- package/dist/auto-instrumentations/bundler/webpack-loader.d.ts +68 -1
- package/dist/auto-instrumentations/bundler/webpack.cjs +594 -2
- package/dist/auto-instrumentations/bundler/webpack.d.mts +2 -2
- package/dist/auto-instrumentations/bundler/webpack.d.ts +2 -2
- package/dist/auto-instrumentations/bundler/webpack.mjs +4 -4
- package/dist/auto-instrumentations/{chunk-W4E36GIW.mjs → chunk-BRQX23KL.mjs} +16 -0
- package/dist/auto-instrumentations/chunk-M6DLIJ2Z.mjs +784 -0
- package/dist/auto-instrumentations/{chunk-K74TZGGM.mjs → chunk-T6J4C7LX.mjs} +1 -1
- package/dist/auto-instrumentations/{chunk-S4374IP6.mjs → chunk-TKRPRPGD.mjs} +4 -6
- package/dist/auto-instrumentations/chunk-VT6DDNKM.mjs +856 -0
- package/dist/auto-instrumentations/hook.mjs +749 -45
- package/dist/auto-instrumentations/index.cjs +16 -0
- package/dist/auto-instrumentations/index.d.mts +2 -3
- package/dist/auto-instrumentations/index.d.ts +2 -3
- package/dist/auto-instrumentations/index.mjs +1 -1
- package/dist/auto-instrumentations/loader/cjs-patch.cjs +578 -4
- package/dist/auto-instrumentations/loader/cjs-patch.d.mts +1 -1
- package/dist/auto-instrumentations/loader/cjs-patch.d.ts +1 -1
- package/dist/auto-instrumentations/loader/cjs-patch.mjs +3 -7
- package/dist/auto-instrumentations/loader/esm-hook.mjs +2 -6
- package/dist/auto-instrumentations/{plugin-D7nDswtC.d.mts → plugin-D0KHwSJv.d.mts} +1 -1
- package/dist/auto-instrumentations/{plugin-D7nDswtC.d.ts → plugin-G6fgxk1b.d.ts} +1 -1
- package/dist/auto-instrumentations/types-RNPaKi9o.d.mts +70 -0
- package/dist/auto-instrumentations/types-RNPaKi9o.d.ts +70 -0
- package/dist/browser.d.mts +1357 -847
- package/dist/browser.d.ts +1357 -847
- package/dist/browser.js +2726 -469
- package/dist/browser.mjs +2726 -469
- package/dist/{chunk-LPC4W2WX.js → chunk-BFGIH2ZJ.js} +4 -0
- package/dist/{chunk-POCCIJAL.js → chunk-FY7DAKA5.js} +3141 -1269
- package/dist/{chunk-Y7W7WP6H.mjs → chunk-KMGUTPB7.mjs} +4 -0
- package/dist/{chunk-F73OMF66.mjs → chunk-O2P765XK.mjs} +2391 -519
- package/dist/cli.js +2260 -408
- package/dist/edge-light.d.mts +1 -1
- package/dist/edge-light.d.ts +1 -1
- package/dist/edge-light.js +2726 -469
- package/dist/edge-light.mjs +2726 -469
- package/dist/index.d.mts +1837 -1327
- package/dist/index.d.ts +1837 -1327
- package/dist/index.js +752 -353
- package/dist/index.mjs +445 -46
- package/dist/instrumentation/index.d.mts +107 -19
- package/dist/instrumentation/index.d.ts +107 -19
- package/dist/instrumentation/index.js +2337 -509
- package/dist/instrumentation/index.mjs +2337 -509
- package/dist/vitest-evals-reporter.js +16 -16
- package/dist/vitest-evals-reporter.mjs +2 -2
- package/dist/workerd.d.mts +1 -1
- package/dist/workerd.d.ts +1 -1
- package/dist/workerd.js +2726 -469
- package/dist/workerd.mjs +2726 -469
- package/licenses/import-in-the-middle/LICENSE +201 -0
- package/licenses/import-in-the-middle/LICENSE-3rdparty.csv +4 -0
- package/licenses/import-in-the-middle/NOTICE +34 -0
- package/licenses/orchestrion-js/LICENSE +202 -0
- package/licenses/orchestrion-js/LICENSE-3rdparty.csv +8 -0
- package/licenses/orchestrion-js/NOTICE +3 -0
- package/licenses/require-in-the-middle/LICENSE +23 -0
- package/package.json +13 -4
- package/util/dist/index.d.mts +1 -0
- package/util/dist/index.d.ts +1 -0
- package/util/dist/index.js +4 -4
- package/util/dist/index.mjs +2 -2
- package/dist/auto-instrumentations/chunk-J57YF7WS.mjs +0 -208
- package/dist/auto-instrumentations/chunk-QFMACSOL.mjs +0 -280
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
applySpecialCasePatch,
|
|
3
|
+
create,
|
|
3
4
|
getPackageName,
|
|
4
5
|
getPackageVersion,
|
|
5
6
|
installMastraExporterFactory
|
|
6
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-VT6DDNKM.mjs";
|
|
7
8
|
|
|
8
9
|
// src/auto-instrumentations/hook.mts
|
|
9
10
|
import { register } from "module";
|
|
@@ -365,8 +366,291 @@ var UUIDGenerator = class extends IDGenerator {
|
|
|
365
366
|
return true;
|
|
366
367
|
}
|
|
367
368
|
};
|
|
369
|
+
function generateHexId(bytes) {
|
|
370
|
+
let result = "";
|
|
371
|
+
for (let i = 0; i < bytes; i++) {
|
|
372
|
+
result += Math.floor(Math.random() * 256).toString(16).padStart(2, "0");
|
|
373
|
+
}
|
|
374
|
+
return result;
|
|
375
|
+
}
|
|
376
|
+
var OTELIDGenerator = class extends IDGenerator {
|
|
377
|
+
getSpanId() {
|
|
378
|
+
return generateHexId(8);
|
|
379
|
+
}
|
|
380
|
+
getTraceId() {
|
|
381
|
+
return generateHexId(16);
|
|
382
|
+
}
|
|
383
|
+
shareRootSpanId() {
|
|
384
|
+
return false;
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
function parseEnvBool(name) {
|
|
388
|
+
const raw = isomorph_default.getEnv(name);
|
|
389
|
+
if (raw === void 0 || raw === null) {
|
|
390
|
+
return false;
|
|
391
|
+
}
|
|
392
|
+
const normalized = raw.trim().toLowerCase();
|
|
393
|
+
return normalized === "true" || normalized === "1" || normalized === "yes" || normalized === "y" || normalized === "on";
|
|
394
|
+
}
|
|
395
|
+
var _warnedLegacyUuidConflict = false;
|
|
396
|
+
function resolveUseLegacyUuidIds() {
|
|
397
|
+
const legacy = parseEnvBool("BRAINTRUST_LEGACY_IDS");
|
|
398
|
+
if (parseEnvBool("BRAINTRUST_OTEL_COMPAT")) {
|
|
399
|
+
if (legacy && !_warnedLegacyUuidConflict) {
|
|
400
|
+
_warnedLegacyUuidConflict = true;
|
|
401
|
+
debugLogger.warn(
|
|
402
|
+
"BRAINTRUST_LEGACY_IDS is ignored because BRAINTRUST_OTEL_COMPAT requires OpenTelemetry-compatible hex span IDs. Using hex IDs."
|
|
403
|
+
);
|
|
404
|
+
}
|
|
405
|
+
return false;
|
|
406
|
+
}
|
|
407
|
+
return legacy;
|
|
408
|
+
}
|
|
368
409
|
function getIdGenerator() {
|
|
369
|
-
|
|
410
|
+
if (globalThis.BRAINTRUST_ID_GENERATOR !== void 0) {
|
|
411
|
+
return new globalThis.BRAINTRUST_ID_GENERATOR();
|
|
412
|
+
}
|
|
413
|
+
return resolveUseLegacyUuidIds() ? new UUIDGenerator() : new OTELIDGenerator();
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
// src/propagation.ts
|
|
417
|
+
var TRACEPARENT_HEADER = "traceparent";
|
|
418
|
+
var TRACESTATE_HEADER = "tracestate";
|
|
419
|
+
var BAGGAGE_HEADER = "baggage";
|
|
420
|
+
var BRAINTRUST_PARENT_KEY = "braintrust.parent";
|
|
421
|
+
var DEFAULT_TRACE_FLAGS = "01";
|
|
422
|
+
var TRACEPARENT_RE = /^00-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})$/;
|
|
423
|
+
var ZERO_TRACE_ID = "0".repeat(32);
|
|
424
|
+
var ZERO_SPAN_ID = "0".repeat(16);
|
|
425
|
+
var MAX_BAGGAGE_LENGTH = 8192;
|
|
426
|
+
var MAX_BAGGAGE_MEMBERS = 64;
|
|
427
|
+
var _utf8Encoder = new TextEncoder();
|
|
428
|
+
function utf8ByteLength(value) {
|
|
429
|
+
return _utf8Encoder.encode(value).length;
|
|
430
|
+
}
|
|
431
|
+
function capBaggageToMemberBoundary(value) {
|
|
432
|
+
const totalBytes = utf8ByteLength(value);
|
|
433
|
+
const withinBytes = totalBytes <= MAX_BAGGAGE_LENGTH;
|
|
434
|
+
let commaCount = 0;
|
|
435
|
+
for (let i = 0; i < value.length; i++) {
|
|
436
|
+
if (value.charCodeAt(i) === 44) {
|
|
437
|
+
commaCount++;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
const withinMembers = commaCount < MAX_BAGGAGE_MEMBERS;
|
|
441
|
+
if (withinBytes && withinMembers) {
|
|
442
|
+
return value;
|
|
443
|
+
}
|
|
444
|
+
const kept = [];
|
|
445
|
+
let length = 0;
|
|
446
|
+
for (const rawMember of value.split(",")) {
|
|
447
|
+
if (kept.length >= MAX_BAGGAGE_MEMBERS) {
|
|
448
|
+
break;
|
|
449
|
+
}
|
|
450
|
+
const cost = utf8ByteLength(rawMember) + (kept.length ? 1 : 0);
|
|
451
|
+
if (length + cost > MAX_BAGGAGE_LENGTH) {
|
|
452
|
+
break;
|
|
453
|
+
}
|
|
454
|
+
kept.push(rawMember);
|
|
455
|
+
length += cost;
|
|
456
|
+
}
|
|
457
|
+
if (!kept.length) {
|
|
458
|
+
return "";
|
|
459
|
+
}
|
|
460
|
+
return kept.join(",");
|
|
461
|
+
}
|
|
462
|
+
function isTraceContextHeaderTupleArray(value) {
|
|
463
|
+
return Array.isArray(value) && value.every(
|
|
464
|
+
(item) => Array.isArray(item) && typeof item[0] === "string" && typeof item[1] === "string"
|
|
465
|
+
);
|
|
466
|
+
}
|
|
467
|
+
function isListHeader(name) {
|
|
468
|
+
const lowered = name.toLowerCase();
|
|
469
|
+
return lowered === BAGGAGE_HEADER || lowered === TRACESTATE_HEADER;
|
|
470
|
+
}
|
|
471
|
+
function headerValueToString(value, name) {
|
|
472
|
+
if (value === void 0 || value === null) {
|
|
473
|
+
return void 0;
|
|
474
|
+
}
|
|
475
|
+
if (Array.isArray(value)) {
|
|
476
|
+
const stringValues = value.filter((item) => {
|
|
477
|
+
return typeof item === "string";
|
|
478
|
+
});
|
|
479
|
+
if (!stringValues.length) {
|
|
480
|
+
return void 0;
|
|
481
|
+
}
|
|
482
|
+
return isListHeader(name) ? stringValues.join(",") : stringValues[0];
|
|
483
|
+
}
|
|
484
|
+
return typeof value === "string" ? value : String(value);
|
|
485
|
+
}
|
|
486
|
+
function getHeader(headers, name) {
|
|
487
|
+
if (!headers) {
|
|
488
|
+
return void 0;
|
|
489
|
+
}
|
|
490
|
+
if (isTraceContextHeaderTupleArray(headers)) {
|
|
491
|
+
const lowered2 = name.toLowerCase();
|
|
492
|
+
const matches = headers.filter(([key]) => key.toLowerCase() === lowered2).map(([, value]) => value);
|
|
493
|
+
if (!matches.length) {
|
|
494
|
+
return void 0;
|
|
495
|
+
}
|
|
496
|
+
return headerValueToString(matches, name);
|
|
497
|
+
}
|
|
498
|
+
const getter = headers.get;
|
|
499
|
+
if (typeof getter === "function") {
|
|
500
|
+
try {
|
|
501
|
+
const value = headerValueToString(getter.call(headers, name), name);
|
|
502
|
+
if (value !== void 0) {
|
|
503
|
+
return value;
|
|
504
|
+
}
|
|
505
|
+
} catch {
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
const nodeGetter = headers.getHeader;
|
|
509
|
+
if (typeof nodeGetter === "function") {
|
|
510
|
+
try {
|
|
511
|
+
const value = headerValueToString(nodeGetter.call(headers, name), name);
|
|
512
|
+
if (value !== void 0) {
|
|
513
|
+
return value;
|
|
514
|
+
}
|
|
515
|
+
} catch {
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
const headerBag = headers;
|
|
519
|
+
const exact = headerValueToString(headerBag[name], name);
|
|
520
|
+
if (exact !== void 0) {
|
|
521
|
+
return exact;
|
|
522
|
+
}
|
|
523
|
+
const lowered = name.toLowerCase();
|
|
524
|
+
for (const key of Object.keys(headers)) {
|
|
525
|
+
if (key !== name && key.toLowerCase() === lowered) {
|
|
526
|
+
const value = headerValueToString(headerBag[key], name);
|
|
527
|
+
if (value !== void 0) {
|
|
528
|
+
return value;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
return void 0;
|
|
533
|
+
}
|
|
534
|
+
function isHex(value, length) {
|
|
535
|
+
if (typeof value !== "string" || value.length !== length) {
|
|
536
|
+
return false;
|
|
537
|
+
}
|
|
538
|
+
for (let i = 0; i < value.length; i++) {
|
|
539
|
+
const c = value[i];
|
|
540
|
+
const isDigit = c >= "0" && c <= "9";
|
|
541
|
+
const isLowerHex = c >= "a" && c <= "f";
|
|
542
|
+
if (!isDigit && !isLowerHex) {
|
|
543
|
+
return false;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
return true;
|
|
547
|
+
}
|
|
548
|
+
function parseTraceparent(value) {
|
|
549
|
+
if (!value || typeof value !== "string") {
|
|
550
|
+
return void 0;
|
|
551
|
+
}
|
|
552
|
+
const match = TRACEPARENT_RE.exec(value.trim());
|
|
553
|
+
if (!match) {
|
|
554
|
+
return void 0;
|
|
555
|
+
}
|
|
556
|
+
const traceId = match[1];
|
|
557
|
+
const spanId = match[2];
|
|
558
|
+
const traceFlags = match[3];
|
|
559
|
+
if (traceId === ZERO_TRACE_ID || spanId === ZERO_SPAN_ID) {
|
|
560
|
+
return void 0;
|
|
561
|
+
}
|
|
562
|
+
return { traceId, spanId, traceFlags };
|
|
563
|
+
}
|
|
564
|
+
function formatTraceparent(traceId, spanId, traceFlags = DEFAULT_TRACE_FLAGS) {
|
|
565
|
+
if (!isHex(traceId, 32) || traceId === ZERO_TRACE_ID) {
|
|
566
|
+
return void 0;
|
|
567
|
+
}
|
|
568
|
+
if (!isHex(spanId, 16) || spanId === ZERO_SPAN_ID) {
|
|
569
|
+
return void 0;
|
|
570
|
+
}
|
|
571
|
+
const flags = isHex(traceFlags, 2) ? traceFlags : DEFAULT_TRACE_FLAGS;
|
|
572
|
+
return `00-${traceId}-${spanId}-${flags}`;
|
|
573
|
+
}
|
|
574
|
+
function percentEncode(value) {
|
|
575
|
+
return encodeURIComponent(value);
|
|
576
|
+
}
|
|
577
|
+
function percentDecode(value) {
|
|
578
|
+
if (!value.includes("%")) {
|
|
579
|
+
return value;
|
|
580
|
+
}
|
|
581
|
+
try {
|
|
582
|
+
return decodeURIComponent(value);
|
|
583
|
+
} catch {
|
|
584
|
+
return value;
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
function parseBaggage(value) {
|
|
588
|
+
const result = {};
|
|
589
|
+
if (!value || typeof value !== "string") {
|
|
590
|
+
return result;
|
|
591
|
+
}
|
|
592
|
+
const bounded = capBaggageToMemberBoundary(value);
|
|
593
|
+
for (let member of bounded.split(",")) {
|
|
594
|
+
member = member.trim();
|
|
595
|
+
if (!member || !member.includes("=")) {
|
|
596
|
+
continue;
|
|
597
|
+
}
|
|
598
|
+
member = member.split(";", 1)[0];
|
|
599
|
+
const eq = member.indexOf("=");
|
|
600
|
+
const key = percentDecode(member.slice(0, eq).trim());
|
|
601
|
+
const val = member.slice(eq + 1).trim();
|
|
602
|
+
if (!key) {
|
|
603
|
+
continue;
|
|
604
|
+
}
|
|
605
|
+
result[key] = percentDecode(val);
|
|
606
|
+
}
|
|
607
|
+
return result;
|
|
608
|
+
}
|
|
609
|
+
function mergeBaggage(existing, braintrustParent) {
|
|
610
|
+
let btMember = void 0;
|
|
611
|
+
if (braintrustParent) {
|
|
612
|
+
const encodedKey = percentEncode(BRAINTRUST_PARENT_KEY);
|
|
613
|
+
const encodedVal = percentEncode(String(braintrustParent));
|
|
614
|
+
btMember = `${encodedKey}=${encodedVal}`;
|
|
615
|
+
if (utf8ByteLength(btMember) > MAX_BAGGAGE_LENGTH) {
|
|
616
|
+
btMember = void 0;
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
let byteBudget = MAX_BAGGAGE_LENGTH;
|
|
620
|
+
let memberBudget = MAX_BAGGAGE_MEMBERS;
|
|
621
|
+
if (btMember !== void 0) {
|
|
622
|
+
byteBudget -= utf8ByteLength(btMember) + 1;
|
|
623
|
+
memberBudget -= 1;
|
|
624
|
+
}
|
|
625
|
+
const relayed = [];
|
|
626
|
+
let length = 0;
|
|
627
|
+
if (existing && typeof existing === "string") {
|
|
628
|
+
for (const rawMember of existing.split(",")) {
|
|
629
|
+
const member = rawMember.trim();
|
|
630
|
+
if (!member || !member.includes("=")) {
|
|
631
|
+
continue;
|
|
632
|
+
}
|
|
633
|
+
const keyPart = member.split(";", 1)[0].split("=", 1)[0];
|
|
634
|
+
const key = percentDecode(keyPart.trim());
|
|
635
|
+
if (key === BRAINTRUST_PARENT_KEY) {
|
|
636
|
+
continue;
|
|
637
|
+
}
|
|
638
|
+
if (relayed.length >= memberBudget) {
|
|
639
|
+
break;
|
|
640
|
+
}
|
|
641
|
+
const cost = utf8ByteLength(member) + (relayed.length ? 1 : 0);
|
|
642
|
+
if (length + cost > byteBudget) {
|
|
643
|
+
break;
|
|
644
|
+
}
|
|
645
|
+
relayed.push(member);
|
|
646
|
+
length += cost;
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
const members = btMember !== void 0 ? [...relayed, btMember] : relayed;
|
|
650
|
+
if (!members.length) {
|
|
651
|
+
return void 0;
|
|
652
|
+
}
|
|
653
|
+
return members.join(",");
|
|
370
654
|
}
|
|
371
655
|
|
|
372
656
|
// util/db_fields.ts
|
|
@@ -974,7 +1258,7 @@ var SpanComponentsV3 = class _SpanComponentsV3 {
|
|
|
974
1258
|
case 3 /* PLAYGROUND_LOGS */:
|
|
975
1259
|
return { prompt_session_id: this.data.object_id, log_id: "x" };
|
|
976
1260
|
default:
|
|
977
|
-
|
|
1261
|
+
this.data.object_type;
|
|
978
1262
|
throw new Error("Impossible");
|
|
979
1263
|
}
|
|
980
1264
|
}
|
|
@@ -1413,7 +1697,7 @@ var SpanComponentsV4 = class _SpanComponentsV4 {
|
|
|
1413
1697
|
case 3 /* PLAYGROUND_LOGS */:
|
|
1414
1698
|
return { prompt_session_id: this.data.object_id, log_id: "x" };
|
|
1415
1699
|
default:
|
|
1416
|
-
|
|
1700
|
+
this.data.object_type;
|
|
1417
1701
|
throw new Error(`Invalid object_type ${this.data.object_type}`);
|
|
1418
1702
|
}
|
|
1419
1703
|
}
|
|
@@ -1537,7 +1821,8 @@ var AclObjectType = z6.union([
|
|
|
1537
1821
|
"role",
|
|
1538
1822
|
"org_member",
|
|
1539
1823
|
"project_log",
|
|
1540
|
-
"org_project"
|
|
1824
|
+
"org_project",
|
|
1825
|
+
"org_audit_logs"
|
|
1541
1826
|
]),
|
|
1542
1827
|
z6.null()
|
|
1543
1828
|
]);
|
|
@@ -1563,6 +1848,17 @@ var Acl = z6.object({
|
|
|
1563
1848
|
_object_org_id: z6.string().uuid(),
|
|
1564
1849
|
created: z6.union([z6.string(), z6.null()]).optional()
|
|
1565
1850
|
});
|
|
1851
|
+
var Agent = z6.object({
|
|
1852
|
+
id: z6.string().uuid(),
|
|
1853
|
+
project_id: z6.string().uuid(),
|
|
1854
|
+
user_id: z6.string().uuid(),
|
|
1855
|
+
created: z6.union([z6.string(), z6.null()]).optional(),
|
|
1856
|
+
name: z6.string(),
|
|
1857
|
+
slug: z6.string(),
|
|
1858
|
+
kind: z6.string(),
|
|
1859
|
+
description: z6.union([z6.string(), z6.null()]).optional(),
|
|
1860
|
+
metadata: z6.union([z6.object({}).partial().passthrough(), z6.null()]).optional()
|
|
1861
|
+
});
|
|
1566
1862
|
var AISecret = z6.object({
|
|
1567
1863
|
id: z6.string().uuid(),
|
|
1568
1864
|
created: z6.union([z6.string(), z6.null()]).optional(),
|
|
@@ -1709,6 +2005,7 @@ var AttachmentStatus = z6.object({
|
|
|
1709
2005
|
upload_status: UploadStatus,
|
|
1710
2006
|
error_message: z6.string().optional()
|
|
1711
2007
|
});
|
|
2008
|
+
var AutomationStatus = z6.enum(["active", "paused"]);
|
|
1712
2009
|
var FunctionTypeEnum = z6.enum([
|
|
1713
2010
|
"llm",
|
|
1714
2011
|
"scorer",
|
|
@@ -1754,7 +2051,9 @@ var TopicMapData = z6.object({
|
|
|
1754
2051
|
topic_names: z6.record(z6.string()).optional(),
|
|
1755
2052
|
generation_settings: TopicMapGenerationSettings.optional(),
|
|
1756
2053
|
disable_reconciliation: z6.boolean().optional(),
|
|
1757
|
-
distance_threshold: z6.number().optional()
|
|
2054
|
+
distance_threshold: z6.number().optional(),
|
|
2055
|
+
btql_filter: z6.string().optional(),
|
|
2056
|
+
automation_btql_filter: z6.string().optional()
|
|
1758
2057
|
});
|
|
1759
2058
|
var BatchedFacetData = z6.object({
|
|
1760
2059
|
type: z6.literal("batched_facet"),
|
|
@@ -2037,7 +2336,7 @@ var DatasetEvent = z6.object({
|
|
|
2037
2336
|
origin: ObjectReferenceNullish.optional(),
|
|
2038
2337
|
comments: z6.union([z6.array(z6.unknown()), z6.null()]).optional(),
|
|
2039
2338
|
audit_data: z6.union([z6.array(z6.unknown()), z6.null()]).optional(),
|
|
2040
|
-
facets: z6.union([z6.
|
|
2339
|
+
facets: z6.union([z6.record(z6.union([z6.string(), z6.null()])), z6.null()]).optional(),
|
|
2041
2340
|
classifications: z6.union([
|
|
2042
2341
|
z6.record(
|
|
2043
2342
|
z6.array(
|
|
@@ -2189,7 +2488,7 @@ var ExperimentEvent = z6.object({
|
|
|
2189
2488
|
origin: ObjectReferenceNullish.optional(),
|
|
2190
2489
|
comments: z6.union([z6.array(z6.unknown()), z6.null()]).optional(),
|
|
2191
2490
|
audit_data: z6.union([z6.array(z6.unknown()), z6.null()]).optional(),
|
|
2192
|
-
facets: z6.union([z6.
|
|
2491
|
+
facets: z6.union([z6.record(z6.union([z6.string(), z6.null()])), z6.null()]).optional(),
|
|
2193
2492
|
classifications: z6.union([
|
|
2194
2493
|
z6.record(
|
|
2195
2494
|
z6.array(
|
|
@@ -2327,7 +2626,8 @@ var PromptParserNullish = z6.union([
|
|
|
2327
2626
|
use_cot: z6.boolean(),
|
|
2328
2627
|
choice_scores: z6.record(z6.number().gte(0).lte(1)).optional(),
|
|
2329
2628
|
choice: z6.array(z6.string()).optional(),
|
|
2330
|
-
allow_no_match: z6.boolean().optional()
|
|
2629
|
+
allow_no_match: z6.boolean().optional(),
|
|
2630
|
+
allow_skip: z6.boolean().optional()
|
|
2331
2631
|
}),
|
|
2332
2632
|
z6.null()
|
|
2333
2633
|
]);
|
|
@@ -2657,6 +2957,9 @@ var Group = z6.object({
|
|
|
2657
2957
|
var GroupScope = z6.object({
|
|
2658
2958
|
type: z6.literal("group"),
|
|
2659
2959
|
group_by: z6.string(),
|
|
2960
|
+
interval_seconds: z6.number().gte(1).optional(),
|
|
2961
|
+
max_traces: z6.number().int().gte(1).lte(64).optional(),
|
|
2962
|
+
placement: z6.enum(["first", "each"]),
|
|
2660
2963
|
idle_seconds: z6.number().optional()
|
|
2661
2964
|
});
|
|
2662
2965
|
var IfExists = z6.enum(["error", "ignore", "replace"]);
|
|
@@ -2805,6 +3108,10 @@ var RetentionObjectType = z6.enum([
|
|
|
2805
3108
|
"experiment",
|
|
2806
3109
|
"dataset"
|
|
2807
3110
|
]);
|
|
3111
|
+
var TopicAutomationFacetModel = z6.union([
|
|
3112
|
+
z6.enum(["brain-facet-latest", "brain-facet-1", "brain-facet-2"]),
|
|
3113
|
+
z6.null()
|
|
3114
|
+
]);
|
|
2808
3115
|
var TopicMapFunctionAutomation = z6.object({
|
|
2809
3116
|
function: SavedFunctionId.and(z6.unknown()),
|
|
2810
3117
|
btql_filter: z6.union([z6.string(), z6.null()]).optional()
|
|
@@ -2817,7 +3124,9 @@ var TopicAutomationDataScope = z6.union([
|
|
|
2817
3124
|
]);
|
|
2818
3125
|
var TopicAutomationConfig = z6.object({
|
|
2819
3126
|
event_type: z6.literal("topic"),
|
|
3127
|
+
status: AutomationStatus.optional(),
|
|
2820
3128
|
sampling_rate: z6.number().gte(0).lte(1),
|
|
3129
|
+
facet_model: TopicAutomationFacetModel.optional(),
|
|
2821
3130
|
facet_functions: z6.array(SavedFunctionId),
|
|
2822
3131
|
topic_map_functions: z6.array(TopicMapFunctionAutomation),
|
|
2823
3132
|
scope: z6.union([SpanScope, TraceScope, GroupScope, z6.null()]).optional(),
|
|
@@ -2831,6 +3140,19 @@ var TopicAutomationConfig = z6.object({
|
|
|
2831
3140
|
z6.null()
|
|
2832
3141
|
]).optional()
|
|
2833
3142
|
});
|
|
3143
|
+
var TopicDigestAutomationConfig = z6.object({
|
|
3144
|
+
event_type: z6.literal("topic_digest"),
|
|
3145
|
+
status: AutomationStatus.optional(),
|
|
3146
|
+
window_seconds: z6.number().int().gte(3600).lte(2592e3).optional().default(86400),
|
|
3147
|
+
scheduled_time_minutes_utc: z6.number().int().gte(0).lte(1439),
|
|
3148
|
+
action: z6.object({
|
|
3149
|
+
type: z6.literal("slack"),
|
|
3150
|
+
workspace_id: z6.string(),
|
|
3151
|
+
channel: z6.string(),
|
|
3152
|
+
message_template: z6.string().optional()
|
|
3153
|
+
}),
|
|
3154
|
+
topic_map_function_ids: z6.array(z6.string()).max(10).optional()
|
|
3155
|
+
});
|
|
2834
3156
|
var ProjectAutomation = z6.object({
|
|
2835
3157
|
id: z6.string().uuid(),
|
|
2836
3158
|
project_id: z6.string().uuid(),
|
|
@@ -2855,6 +3177,7 @@ var ProjectAutomation = z6.object({
|
|
|
2855
3177
|
}),
|
|
2856
3178
|
z6.object({
|
|
2857
3179
|
event_type: z6.literal("btql_export"),
|
|
3180
|
+
status: AutomationStatus.optional(),
|
|
2858
3181
|
export_definition: z6.union([
|
|
2859
3182
|
z6.object({ type: z6.literal("log_traces") }),
|
|
2860
3183
|
z6.object({ type: z6.literal("log_spans") }),
|
|
@@ -2877,6 +3200,21 @@ var ProjectAutomation = z6.object({
|
|
|
2877
3200
|
]),
|
|
2878
3201
|
batch_size: z6.union([z6.number(), z6.null()]).optional()
|
|
2879
3202
|
}),
|
|
3203
|
+
z6.object({
|
|
3204
|
+
event_type: z6.literal("async_query"),
|
|
3205
|
+
status: AutomationStatus.optional(),
|
|
3206
|
+
created_by_user_id: z6.string().uuid(),
|
|
3207
|
+
object_type: z6.enum([
|
|
3208
|
+
"project_logs",
|
|
3209
|
+
"experiment",
|
|
3210
|
+
"dataset",
|
|
3211
|
+
"playground_logs"
|
|
3212
|
+
]),
|
|
3213
|
+
object_id: z6.string(),
|
|
3214
|
+
query: z6.string(),
|
|
3215
|
+
format: z6.literal("jsonl"),
|
|
3216
|
+
batch_size: z6.union([z6.number(), z6.null()]).optional()
|
|
3217
|
+
}),
|
|
2880
3218
|
z6.object({
|
|
2881
3219
|
event_type: z6.literal("retention"),
|
|
2882
3220
|
object_type: RetentionObjectType,
|
|
@@ -2895,7 +3233,8 @@ var ProjectAutomation = z6.object({
|
|
|
2895
3233
|
})
|
|
2896
3234
|
])
|
|
2897
3235
|
}),
|
|
2898
|
-
TopicAutomationConfig
|
|
3236
|
+
TopicAutomationConfig,
|
|
3237
|
+
TopicDigestAutomationConfig
|
|
2899
3238
|
])
|
|
2900
3239
|
});
|
|
2901
3240
|
var ProjectLogsEvent = z6.object({
|
|
@@ -2934,7 +3273,7 @@ var ProjectLogsEvent = z6.object({
|
|
|
2934
3273
|
comments: z6.union([z6.array(z6.unknown()), z6.null()]).optional(),
|
|
2935
3274
|
audit_data: z6.union([z6.array(z6.unknown()), z6.null()]).optional(),
|
|
2936
3275
|
_async_scoring_state: z6.unknown().optional(),
|
|
2937
|
-
facets: z6.union([z6.
|
|
3276
|
+
facets: z6.union([z6.record(z6.union([z6.string(), z6.null()])), z6.null()]).optional(),
|
|
2938
3277
|
classifications: z6.union([
|
|
2939
3278
|
z6.record(
|
|
2940
3279
|
z6.array(
|
|
@@ -2983,11 +3322,34 @@ var ProjectScoreCategories = z6.union([
|
|
|
2983
3322
|
z6.array(z6.string()),
|
|
2984
3323
|
z6.null()
|
|
2985
3324
|
]);
|
|
3325
|
+
var ProjectScoreCondition = z6.union([
|
|
3326
|
+
z6.object({
|
|
3327
|
+
when: z6.object({
|
|
3328
|
+
clauses: z6.union([z6.array(z6.string()), z6.null()]),
|
|
3329
|
+
subspan_clauses: z6.union([z6.array(z6.string()), z6.null()]),
|
|
3330
|
+
trace_clauses: z6.union([z6.array(z6.string()), z6.null()])
|
|
3331
|
+
}).partial(),
|
|
3332
|
+
behavior: z6.literal("hidden").optional().default("hidden")
|
|
3333
|
+
}),
|
|
3334
|
+
z6.null()
|
|
3335
|
+
]);
|
|
2986
3336
|
var ProjectScoreConfig = z6.union([
|
|
2987
3337
|
z6.object({
|
|
2988
3338
|
multi_select: z6.union([z6.boolean(), z6.null()]),
|
|
2989
3339
|
destination: z6.union([z6.string(), z6.null()]),
|
|
2990
|
-
|
|
3340
|
+
visibility: z6.union([
|
|
3341
|
+
z6.object({
|
|
3342
|
+
users: z6.union([z6.array(z6.string()), z6.null()]),
|
|
3343
|
+
groups: z6.union([z6.array(z6.string()), z6.null()])
|
|
3344
|
+
}).partial(),
|
|
3345
|
+
z6.null()
|
|
3346
|
+
]),
|
|
3347
|
+
online: OnlineScoreConfig,
|
|
3348
|
+
condition: ProjectScoreCondition,
|
|
3349
|
+
object_types: z6.union([
|
|
3350
|
+
z6.array(z6.enum(["project_logs", "dataset", "experiment"])),
|
|
3351
|
+
z6.null()
|
|
3352
|
+
])
|
|
2991
3353
|
}).partial(),
|
|
2992
3354
|
z6.null()
|
|
2993
3355
|
]);
|
|
@@ -3172,8 +3534,7 @@ var User = z6.object({
|
|
|
3172
3534
|
family_name: z6.union([z6.string(), z6.null()]).optional(),
|
|
3173
3535
|
email: z6.union([z6.string(), z6.null()]).optional(),
|
|
3174
3536
|
avatar_url: z6.union([z6.string(), z6.null()]).optional(),
|
|
3175
|
-
created: z6.union([z6.string(), z6.null()]).optional()
|
|
3176
|
-
last_active_at: z6.union([z6.number(), z6.null()]).optional()
|
|
3537
|
+
created: z6.union([z6.string(), z6.null()]).optional()
|
|
3177
3538
|
});
|
|
3178
3539
|
var ViewDataSearch = z6.union([
|
|
3179
3540
|
z6.object({
|
|
@@ -4434,7 +4795,10 @@ var BraintrustContextManager = class extends ContextManager {
|
|
|
4434
4795
|
}
|
|
4435
4796
|
};
|
|
4436
4797
|
function getSpanComponentsClass() {
|
|
4437
|
-
|
|
4798
|
+
if (globalThis.BRAINTRUST_SPAN_COMPONENT) {
|
|
4799
|
+
return globalThis.BRAINTRUST_SPAN_COMPONENT;
|
|
4800
|
+
}
|
|
4801
|
+
return resolveUseLegacyUuidIds() ? SpanComponentsV3 : SpanComponentsV4;
|
|
4438
4802
|
}
|
|
4439
4803
|
function getContextManager() {
|
|
4440
4804
|
return globalThis.BRAINTRUST_CONTEXT_MANAGER ? new globalThis.BRAINTRUST_CONTEXT_MANAGER() : new BraintrustContextManager();
|
|
@@ -4470,6 +4834,9 @@ var NoopSpan = class {
|
|
|
4470
4834
|
async export() {
|
|
4471
4835
|
return "";
|
|
4472
4836
|
}
|
|
4837
|
+
inject(carrier) {
|
|
4838
|
+
return carrier ?? {};
|
|
4839
|
+
}
|
|
4473
4840
|
async permalink() {
|
|
4474
4841
|
return NOOP_SPAN_PERMALINK;
|
|
4475
4842
|
}
|
|
@@ -4520,6 +4887,10 @@ var loginSchema = z8.strictObject({
|
|
|
4520
4887
|
debugLogLevelDisabled: z8.boolean().optional()
|
|
4521
4888
|
});
|
|
4522
4889
|
var stateNonce = 0;
|
|
4890
|
+
var V1_PROXY_SUFFIX = "/v1/proxy";
|
|
4891
|
+
function normalizeProxyConnUrl(proxyUrl) {
|
|
4892
|
+
return proxyUrl.endsWith(V1_PROXY_SUFFIX) ? proxyUrl.slice(0, proxyUrl.length - V1_PROXY_SUFFIX.length) : proxyUrl;
|
|
4893
|
+
}
|
|
4523
4894
|
var BraintrustState = class _BraintrustState {
|
|
4524
4895
|
constructor(loginParams) {
|
|
4525
4896
|
this.loginParams = loginParams;
|
|
@@ -4790,7 +5161,10 @@ var BraintrustState = class _BraintrustState {
|
|
|
4790
5161
|
if (!this.proxyUrl) {
|
|
4791
5162
|
throw new Error("Must initialize proxyUrl before requesting proxyConn");
|
|
4792
5163
|
}
|
|
4793
|
-
this._proxyConn = new HTTPConnection(
|
|
5164
|
+
this._proxyConn = new HTTPConnection(
|
|
5165
|
+
normalizeProxyConnUrl(this.proxyUrl),
|
|
5166
|
+
this.fetch
|
|
5167
|
+
);
|
|
4794
5168
|
}
|
|
4795
5169
|
return this._proxyConn;
|
|
4796
5170
|
}
|
|
@@ -5476,7 +5850,7 @@ async function permalink(slug, opts) {
|
|
|
5476
5850
|
return state2.appUrl;
|
|
5477
5851
|
};
|
|
5478
5852
|
try {
|
|
5479
|
-
const components =
|
|
5853
|
+
const components = SpanComponentsV4.fromStr(slug);
|
|
5480
5854
|
const object_type = spanObjectTypeV3ToString(components.data.object_type);
|
|
5481
5855
|
const [orgName, appUrl, object_id] = await Promise.all([
|
|
5482
5856
|
getOrgName(),
|
|
@@ -5500,35 +5874,47 @@ function startSpanParentArgs(args) {
|
|
|
5500
5874
|
let argParentObjectId = void 0;
|
|
5501
5875
|
let argParentSpanIds = void 0;
|
|
5502
5876
|
let argPropagatedEvent = void 0;
|
|
5503
|
-
|
|
5877
|
+
let argPropagatedState = void 0;
|
|
5878
|
+
const { parentSlug, propagatedState: parentPropagatedState } = normalizeParent(args.parent, args.state);
|
|
5879
|
+
if (parentSlug) {
|
|
5504
5880
|
if (args.parentSpanIds) {
|
|
5505
5881
|
throw new Error("Cannot specify both parent and parentSpanIds");
|
|
5506
5882
|
}
|
|
5507
|
-
const parentComponents =
|
|
5883
|
+
const parentComponents = SpanComponentsV4.fromStr(parentSlug);
|
|
5508
5884
|
if (args.parentObjectType !== parentComponents.data.object_type) {
|
|
5509
5885
|
throw new Error(
|
|
5510
5886
|
`Mismatch between expected span parent object type ${args.parentObjectType} and provided type ${parentComponents.data.object_type}`
|
|
5511
5887
|
);
|
|
5512
5888
|
}
|
|
5513
5889
|
argParentObjectId = args.parentObjectId;
|
|
5514
|
-
if (parentComponents.data.row_id
|
|
5890
|
+
if (parentComponents.data.row_id && parentSpanIdsUsable(
|
|
5891
|
+
parentComponents.data.span_id,
|
|
5892
|
+
parentComponents.data.root_span_id
|
|
5893
|
+
)) {
|
|
5515
5894
|
argParentSpanIds = {
|
|
5516
5895
|
spanId: parentComponents.data.span_id,
|
|
5517
5896
|
rootSpanId: parentComponents.data.root_span_id
|
|
5518
5897
|
};
|
|
5519
5898
|
}
|
|
5520
5899
|
argPropagatedEvent = args.propagatedEvent ?? (parentComponents.data.propagated_event ?? void 0);
|
|
5900
|
+
const propagatedState = args.propagatedState ?? parentPropagatedState;
|
|
5901
|
+
if (propagatedState) {
|
|
5902
|
+
const { braintrustParent: _ignoredBraintrustParent, ...w3cState } = propagatedState;
|
|
5903
|
+
argPropagatedState = w3cState;
|
|
5904
|
+
}
|
|
5521
5905
|
} else {
|
|
5522
5906
|
argParentObjectId = args.parentObjectId;
|
|
5523
5907
|
argParentSpanIds = args.parentSpanIds;
|
|
5524
5908
|
argPropagatedEvent = args.propagatedEvent;
|
|
5909
|
+
argPropagatedState = args.propagatedState;
|
|
5525
5910
|
}
|
|
5526
5911
|
return {
|
|
5527
5912
|
parentObjectType: args.parentObjectType,
|
|
5528
5913
|
parentObjectId: argParentObjectId,
|
|
5529
5914
|
parentComputeObjectMetadataArgs: args.parentComputeObjectMetadataArgs,
|
|
5530
5915
|
parentSpanIds: argParentSpanIds,
|
|
5531
|
-
propagatedEvent: argPropagatedEvent
|
|
5916
|
+
propagatedEvent: argPropagatedEvent,
|
|
5917
|
+
propagatedState: argPropagatedState
|
|
5532
5918
|
};
|
|
5533
5919
|
}
|
|
5534
5920
|
var Logger = class {
|
|
@@ -5729,6 +6115,22 @@ var Logger = class {
|
|
|
5729
6115
|
_getLinkBaseUrl() {
|
|
5730
6116
|
return _getLinkBaseUrl(this.state, this._linkArgs);
|
|
5731
6117
|
}
|
|
6118
|
+
/**
|
|
6119
|
+
* Return this logger's Braintrust parent string (`project_id:<id>` or
|
|
6120
|
+
* `project_name:<name>`) for the `braintrust.parent` baggage entry, or
|
|
6121
|
+
* undefined when it cannot be determined synchronously.
|
|
6122
|
+
*/
|
|
6123
|
+
_getOtelParent() {
|
|
6124
|
+
const id = this.computeMetadataArgs?.project_id || this.lazyId.getSync().value;
|
|
6125
|
+
if (id) {
|
|
6126
|
+
return `project_id:${id}`;
|
|
6127
|
+
}
|
|
6128
|
+
const name = this.computeMetadataArgs?.project_name;
|
|
6129
|
+
if (name) {
|
|
6130
|
+
return `project_name:${name}`;
|
|
6131
|
+
}
|
|
6132
|
+
return void 0;
|
|
6133
|
+
}
|
|
5732
6134
|
};
|
|
5733
6135
|
function castLogger(logger, asyncFlush) {
|
|
5734
6136
|
if (logger === void 0) return void 0;
|
|
@@ -5823,12 +6225,12 @@ function stringifyWithOverflowMeta(item) {
|
|
|
5823
6225
|
object_ids: pickLogs3OverflowObjectIds(record),
|
|
5824
6226
|
is_delete: record[OBJECT_DELETE_FIELD] === true,
|
|
5825
6227
|
input_row: {
|
|
5826
|
-
byte_size:
|
|
6228
|
+
byte_size: utf8ByteLength2(str)
|
|
5827
6229
|
}
|
|
5828
6230
|
}
|
|
5829
6231
|
};
|
|
5830
6232
|
}
|
|
5831
|
-
function
|
|
6233
|
+
function utf8ByteLength2(value) {
|
|
5832
6234
|
if (typeof TextEncoder !== "undefined") {
|
|
5833
6235
|
return new TextEncoder().encode(value).length;
|
|
5834
6236
|
}
|
|
@@ -6159,7 +6561,7 @@ var HTTPBackgroundLogger = class _HTTPBackgroundLogger {
|
|
|
6159
6561
|
}) {
|
|
6160
6562
|
const conn = await this.apiConn.get();
|
|
6161
6563
|
const dataStr = constructLogs3Data(items);
|
|
6162
|
-
const payloadBytes =
|
|
6564
|
+
const payloadBytes = utf8ByteLength2(dataStr);
|
|
6163
6565
|
const useOverflow = canUseOverflow && payloadBytes > maxRequestSize;
|
|
6164
6566
|
if (this.allPublishPayloadsDir) {
|
|
6165
6567
|
await _HTTPBackgroundLogger.writePayloadToDir({
|
|
@@ -6493,23 +6895,253 @@ function currentSpan(options) {
|
|
|
6493
6895
|
const state2 = options?.state ?? _globalState;
|
|
6494
6896
|
return state2.contextManager.getCurrentSpan() ?? NOOP_SPAN;
|
|
6495
6897
|
}
|
|
6496
|
-
function
|
|
6898
|
+
function getSpanParentObjectAndPropagatedState(options) {
|
|
6497
6899
|
const state2 = options?.state ?? _globalState;
|
|
6498
6900
|
const parentSpan = currentSpan({ state: state2 });
|
|
6499
6901
|
if (!Object.is(parentSpan, NOOP_SPAN)) {
|
|
6500
|
-
return parentSpan;
|
|
6902
|
+
return { parentObject: parentSpan, propagatedState: void 0 };
|
|
6903
|
+
}
|
|
6904
|
+
const parent = options?.parent ?? state2.currentParent.getStore();
|
|
6905
|
+
const { parentSlug, propagatedState } = normalizeParent(parent, state2);
|
|
6906
|
+
if (parentSlug) {
|
|
6907
|
+
return {
|
|
6908
|
+
parentObject: SpanComponentsV4.fromStr(parentSlug),
|
|
6909
|
+
propagatedState
|
|
6910
|
+
};
|
|
6501
6911
|
}
|
|
6502
|
-
const parentStr = options?.parent ?? state2.currentParent.getStore();
|
|
6503
|
-
if (parentStr) return getSpanComponentsClass().fromStr(parentStr);
|
|
6504
6912
|
const experiment = currentExperiment();
|
|
6505
6913
|
if (experiment) {
|
|
6506
|
-
return experiment;
|
|
6914
|
+
return { parentObject: experiment, propagatedState: void 0 };
|
|
6507
6915
|
}
|
|
6508
6916
|
const logger = currentLogger(options);
|
|
6509
6917
|
if (logger) {
|
|
6510
|
-
return logger;
|
|
6918
|
+
return { parentObject: logger, propagatedState: void 0 };
|
|
6919
|
+
}
|
|
6920
|
+
return { parentObject: NOOP_SPAN, propagatedState: void 0 };
|
|
6921
|
+
}
|
|
6922
|
+
function currentBraintrustParent(state2) {
|
|
6923
|
+
const resolvedState = state2 ?? _globalState;
|
|
6924
|
+
const experiment = currentExperiment({ state: resolvedState });
|
|
6925
|
+
if (experiment) {
|
|
6926
|
+
try {
|
|
6927
|
+
return experiment._getOtelParent() ?? void 0;
|
|
6928
|
+
} catch {
|
|
6929
|
+
return void 0;
|
|
6930
|
+
}
|
|
6931
|
+
}
|
|
6932
|
+
const logger = currentLogger({ state: resolvedState });
|
|
6933
|
+
if (logger) {
|
|
6934
|
+
try {
|
|
6935
|
+
return logger._getOtelParent() ?? void 0;
|
|
6936
|
+
} catch {
|
|
6937
|
+
return void 0;
|
|
6938
|
+
}
|
|
6939
|
+
}
|
|
6940
|
+
return void 0;
|
|
6941
|
+
}
|
|
6942
|
+
function braintrustParentToComponents(braintrustParent) {
|
|
6943
|
+
if (!braintrustParent) {
|
|
6944
|
+
return void 0;
|
|
6945
|
+
}
|
|
6946
|
+
if (braintrustParent.startsWith("project_id:")) {
|
|
6947
|
+
const objectId = braintrustParent.slice("project_id:".length);
|
|
6948
|
+
return objectId ? {
|
|
6949
|
+
objectType: 2 /* PROJECT_LOGS */,
|
|
6950
|
+
objectId,
|
|
6951
|
+
computeArgs: void 0
|
|
6952
|
+
} : void 0;
|
|
6953
|
+
}
|
|
6954
|
+
if (braintrustParent.startsWith("project_name:")) {
|
|
6955
|
+
const name = braintrustParent.slice("project_name:".length);
|
|
6956
|
+
return name ? {
|
|
6957
|
+
objectType: 2 /* PROJECT_LOGS */,
|
|
6958
|
+
objectId: void 0,
|
|
6959
|
+
computeArgs: { project_name: name }
|
|
6960
|
+
} : void 0;
|
|
6511
6961
|
}
|
|
6512
|
-
|
|
6962
|
+
if (braintrustParent.startsWith("experiment_id:")) {
|
|
6963
|
+
const objectId = braintrustParent.slice("experiment_id:".length);
|
|
6964
|
+
return objectId ? {
|
|
6965
|
+
objectType: 1 /* EXPERIMENT */,
|
|
6966
|
+
objectId,
|
|
6967
|
+
computeArgs: void 0
|
|
6968
|
+
} : void 0;
|
|
6969
|
+
}
|
|
6970
|
+
return void 0;
|
|
6971
|
+
}
|
|
6972
|
+
function isMutableHeaderTupleArray(carrier) {
|
|
6973
|
+
return Array.isArray(carrier) && carrier.every((item) => Array.isArray(item) && typeof item[0] === "string");
|
|
6974
|
+
}
|
|
6975
|
+
function setHeader(carrier, name, value) {
|
|
6976
|
+
if (isMutableHeaderTupleArray(carrier)) {
|
|
6977
|
+
const lowered2 = name.toLowerCase();
|
|
6978
|
+
for (let i = carrier.length - 1; i >= 0; i--) {
|
|
6979
|
+
if (carrier[i][0].toLowerCase() === lowered2) {
|
|
6980
|
+
carrier.splice(i, 1);
|
|
6981
|
+
}
|
|
6982
|
+
}
|
|
6983
|
+
carrier.push([name, value]);
|
|
6984
|
+
return;
|
|
6985
|
+
}
|
|
6986
|
+
const setter = carrier.set;
|
|
6987
|
+
if (typeof setter === "function") {
|
|
6988
|
+
const deleter = carrier.delete;
|
|
6989
|
+
if (typeof deleter === "function") {
|
|
6990
|
+
try {
|
|
6991
|
+
deleter.call(carrier, name);
|
|
6992
|
+
} catch {
|
|
6993
|
+
}
|
|
6994
|
+
}
|
|
6995
|
+
setter.call(carrier, name, value);
|
|
6996
|
+
return;
|
|
6997
|
+
}
|
|
6998
|
+
const nodeSetter = carrier.setHeader;
|
|
6999
|
+
if (typeof nodeSetter === "function") {
|
|
7000
|
+
const remover = carrier.removeHeader;
|
|
7001
|
+
if (typeof remover === "function") {
|
|
7002
|
+
try {
|
|
7003
|
+
remover.call(carrier, name);
|
|
7004
|
+
} catch {
|
|
7005
|
+
}
|
|
7006
|
+
}
|
|
7007
|
+
nodeSetter.call(carrier, name, value);
|
|
7008
|
+
return;
|
|
7009
|
+
}
|
|
7010
|
+
const headerSetter = carrier.header;
|
|
7011
|
+
if (typeof headerSetter === "function") {
|
|
7012
|
+
const deleter = carrier.delete;
|
|
7013
|
+
if (typeof deleter === "function") {
|
|
7014
|
+
try {
|
|
7015
|
+
deleter.call(carrier, name);
|
|
7016
|
+
} catch {
|
|
7017
|
+
}
|
|
7018
|
+
}
|
|
7019
|
+
const remover = carrier.removeHeader;
|
|
7020
|
+
if (typeof remover === "function") {
|
|
7021
|
+
try {
|
|
7022
|
+
remover.call(carrier, name);
|
|
7023
|
+
} catch {
|
|
7024
|
+
}
|
|
7025
|
+
}
|
|
7026
|
+
headerSetter.call(carrier, name, value);
|
|
7027
|
+
return;
|
|
7028
|
+
}
|
|
7029
|
+
const headerBag = carrier;
|
|
7030
|
+
const lowered = name.toLowerCase();
|
|
7031
|
+
for (const key of Object.keys(headerBag)) {
|
|
7032
|
+
if (key !== name && key.toLowerCase() === lowered) {
|
|
7033
|
+
delete headerBag[key];
|
|
7034
|
+
}
|
|
7035
|
+
}
|
|
7036
|
+
headerBag[name] = value;
|
|
7037
|
+
}
|
|
7038
|
+
function deleteHeader(carrier, name) {
|
|
7039
|
+
const lowered = name.toLowerCase();
|
|
7040
|
+
if (isMutableHeaderTupleArray(carrier)) {
|
|
7041
|
+
for (let i = carrier.length - 1; i >= 0; i--) {
|
|
7042
|
+
if (carrier[i][0].toLowerCase() === lowered) {
|
|
7043
|
+
carrier.splice(i, 1);
|
|
7044
|
+
}
|
|
7045
|
+
}
|
|
7046
|
+
return;
|
|
7047
|
+
}
|
|
7048
|
+
const deleter = carrier.delete;
|
|
7049
|
+
if (typeof deleter === "function") {
|
|
7050
|
+
try {
|
|
7051
|
+
deleter.call(carrier, name);
|
|
7052
|
+
return;
|
|
7053
|
+
} catch {
|
|
7054
|
+
}
|
|
7055
|
+
}
|
|
7056
|
+
const remover = carrier.removeHeader;
|
|
7057
|
+
if (typeof remover === "function") {
|
|
7058
|
+
try {
|
|
7059
|
+
remover.call(carrier, name);
|
|
7060
|
+
return;
|
|
7061
|
+
} catch {
|
|
7062
|
+
}
|
|
7063
|
+
}
|
|
7064
|
+
const headerBag = carrier;
|
|
7065
|
+
for (const key of Object.keys(headerBag)) {
|
|
7066
|
+
if (key.toLowerCase() === lowered) {
|
|
7067
|
+
delete headerBag[key];
|
|
7068
|
+
}
|
|
7069
|
+
}
|
|
7070
|
+
}
|
|
7071
|
+
function _injectIntoCarrier(carrier, args) {
|
|
7072
|
+
const traceFlags = args.propagatedState?.traceFlags;
|
|
7073
|
+
const traceparent = traceFlags ? formatTraceparent(args.traceId, args.spanId, traceFlags) : formatTraceparent(args.traceId, args.spanId);
|
|
7074
|
+
if (traceparent === void 0) {
|
|
7075
|
+
return;
|
|
7076
|
+
}
|
|
7077
|
+
setHeader(carrier, TRACEPARENT_HEADER, traceparent);
|
|
7078
|
+
const tracestate = args.propagatedState?.tracestate;
|
|
7079
|
+
if (tracestate) {
|
|
7080
|
+
setHeader(carrier, TRACESTATE_HEADER, tracestate);
|
|
7081
|
+
}
|
|
7082
|
+
const existing = getHeader(carrier, BAGGAGE_HEADER);
|
|
7083
|
+
const baggageValue = mergeBaggage(existing, args.braintrustParent);
|
|
7084
|
+
if (baggageValue !== void 0) {
|
|
7085
|
+
setHeader(carrier, BAGGAGE_HEADER, baggageValue);
|
|
7086
|
+
} else if (existing !== void 0) {
|
|
7087
|
+
deleteHeader(carrier, BAGGAGE_HEADER);
|
|
7088
|
+
}
|
|
7089
|
+
}
|
|
7090
|
+
function resolveW3cParent(context, state2) {
|
|
7091
|
+
const traceparent = getHeader(context, TRACEPARENT_HEADER);
|
|
7092
|
+
const parsed = traceparent ? parseTraceparent(traceparent) : void 0;
|
|
7093
|
+
if (parsed === void 0) {
|
|
7094
|
+
return { parentSlug: void 0, propagatedState: void 0 };
|
|
7095
|
+
}
|
|
7096
|
+
const { traceId, spanId, traceFlags } = parsed;
|
|
7097
|
+
let braintrustParent = void 0;
|
|
7098
|
+
const baggageValue = getHeader(context, BAGGAGE_HEADER);
|
|
7099
|
+
if (baggageValue) {
|
|
7100
|
+
braintrustParent = parseBaggage(baggageValue)[BRAINTRUST_PARENT_KEY];
|
|
7101
|
+
}
|
|
7102
|
+
if (!braintrustParent) {
|
|
7103
|
+
braintrustParent = currentBraintrustParent(state2);
|
|
7104
|
+
}
|
|
7105
|
+
if (!braintrustParent) {
|
|
7106
|
+
debugLogger.warn(
|
|
7107
|
+
"Received traceparent without a braintrust.parent and no active logger/experiment; cannot route the trace. Starting a fresh local span instead."
|
|
7108
|
+
);
|
|
7109
|
+
return { parentSlug: void 0, propagatedState: void 0 };
|
|
7110
|
+
}
|
|
7111
|
+
const parsedParent = braintrustParentToComponents(braintrustParent);
|
|
7112
|
+
if (parsedParent === void 0) {
|
|
7113
|
+
debugLogger.warn(
|
|
7114
|
+
`Invalid braintrust.parent: ${JSON.stringify(braintrustParent)}`
|
|
7115
|
+
);
|
|
7116
|
+
return { parentSlug: void 0, propagatedState: void 0 };
|
|
7117
|
+
}
|
|
7118
|
+
const { objectType, objectId, computeArgs } = parsedParent;
|
|
7119
|
+
const tracestate = getHeader(context, TRACESTATE_HEADER);
|
|
7120
|
+
const slug = new SpanComponentsV4({
|
|
7121
|
+
object_type: objectType,
|
|
7122
|
+
...computeArgs ? { compute_object_metadata_args: computeArgs } : { object_id: objectId },
|
|
7123
|
+
row_id: "bt-propagation",
|
|
7124
|
+
// non-empty to enable span_id/root_span_id
|
|
7125
|
+
span_id: spanId,
|
|
7126
|
+
root_span_id: traceId
|
|
7127
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
7128
|
+
}).toStr();
|
|
7129
|
+
return {
|
|
7130
|
+
parentSlug: slug,
|
|
7131
|
+
propagatedState: { tracestate, traceFlags, braintrustParent }
|
|
7132
|
+
};
|
|
7133
|
+
}
|
|
7134
|
+
function normalizeParent(parent, state2) {
|
|
7135
|
+
if (parent && typeof parent === "object") {
|
|
7136
|
+
return resolveW3cParent(parent, state2);
|
|
7137
|
+
}
|
|
7138
|
+
return {
|
|
7139
|
+
parentSlug: parent ?? void 0,
|
|
7140
|
+
propagatedState: void 0
|
|
7141
|
+
};
|
|
7142
|
+
}
|
|
7143
|
+
function parentSpanIdsUsable(spanId, rootSpanId) {
|
|
7144
|
+
return Boolean(spanId) && Boolean(rootSpanId);
|
|
6513
7145
|
}
|
|
6514
7146
|
function logError(span, error) {
|
|
6515
7147
|
let errorMessage = "<error>";
|
|
@@ -6529,19 +7161,23 @@ function startSpan(args) {
|
|
|
6529
7161
|
}
|
|
6530
7162
|
function startSpanAndIsLogger(args) {
|
|
6531
7163
|
const state2 = args?.state ?? _globalState;
|
|
6532
|
-
const parentObject =
|
|
7164
|
+
const { parentObject, propagatedState } = getSpanParentObjectAndPropagatedState({
|
|
6533
7165
|
asyncFlush: args?.asyncFlush,
|
|
6534
7166
|
parent: args?.parent,
|
|
6535
7167
|
state: state2
|
|
6536
7168
|
});
|
|
6537
7169
|
if (parentObject instanceof SpanComponentsV3 || parentObject instanceof SpanComponentsV4) {
|
|
6538
|
-
const parentSpanIds = parentObject.data.row_id
|
|
7170
|
+
const parentSpanIds = parentObject.data.row_id && parentSpanIdsUsable(
|
|
7171
|
+
parentObject.data.span_id,
|
|
7172
|
+
parentObject.data.root_span_id
|
|
7173
|
+
) ? {
|
|
6539
7174
|
spanId: parentObject.data.span_id,
|
|
6540
7175
|
rootSpanId: parentObject.data.root_span_id
|
|
6541
7176
|
} : void 0;
|
|
7177
|
+
const { parent: _ignoredParent, ...spanArgs } = args ?? {};
|
|
6542
7178
|
const span = new SpanImpl({
|
|
6543
7179
|
state: state2,
|
|
6544
|
-
...
|
|
7180
|
+
...spanArgs,
|
|
6545
7181
|
parentObjectType: parentObject.data.object_type,
|
|
6546
7182
|
parentObjectId: new LazyValue(
|
|
6547
7183
|
spanComponentsToObjectIdLambda(state2, parentObject)
|
|
@@ -6549,7 +7185,8 @@ function startSpanAndIsLogger(args) {
|
|
|
6549
7185
|
parentComputeObjectMetadataArgs: parentObject.data.compute_object_metadata_args ?? void 0,
|
|
6550
7186
|
parentSpanIds,
|
|
6551
7187
|
propagatedEvent: args?.propagatedEvent ?? // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
6552
|
-
(parentObject.data.propagated_event ?? void 0)
|
|
7188
|
+
(parentObject.data.propagated_event ?? void 0),
|
|
7189
|
+
propagatedState
|
|
6553
7190
|
});
|
|
6554
7191
|
return {
|
|
6555
7192
|
span,
|
|
@@ -6776,11 +7413,12 @@ function validateAndSanitizeExperimentLogFullArgs(event, hasDataset) {
|
|
|
6776
7413
|
var DEFAULT_FETCH_BATCH_SIZE = 1e3;
|
|
6777
7414
|
var MAX_BTQL_ITERATIONS = 1e4;
|
|
6778
7415
|
var ObjectFetcher = class {
|
|
6779
|
-
constructor(objectType, pinnedVersion, mutateRecord, _internal_btql) {
|
|
7416
|
+
constructor(objectType, pinnedVersion, mutateRecord, _internal_btql, _internalBrainstoreRealtime = true) {
|
|
6780
7417
|
this.objectType = objectType;
|
|
6781
7418
|
this.pinnedVersion = pinnedVersion;
|
|
6782
7419
|
this.mutateRecord = mutateRecord;
|
|
6783
7420
|
this._internal_btql = _internal_btql;
|
|
7421
|
+
this._internalBrainstoreRealtime = _internalBrainstoreRealtime;
|
|
6784
7422
|
}
|
|
6785
7423
|
_fetchedData = void 0;
|
|
6786
7424
|
get id() {
|
|
@@ -6839,7 +7477,7 @@ var ObjectFetcher = class {
|
|
|
6839
7477
|
...internalBtqlWithoutReservedQueryKeys
|
|
6840
7478
|
},
|
|
6841
7479
|
use_columnstore: false,
|
|
6842
|
-
brainstore_realtime:
|
|
7480
|
+
brainstore_realtime: this._internalBrainstoreRealtime,
|
|
6843
7481
|
query_source: `js_sdk_object_fetcher_${this.objectType}`,
|
|
6844
7482
|
...this.pinnedVersion !== void 0 ? {
|
|
6845
7483
|
version: this.pinnedVersion
|
|
@@ -7188,6 +7826,15 @@ View complete results in Braintrust or run experiment.summarize() again.`
|
|
|
7188
7826
|
object_id: await this.id
|
|
7189
7827
|
}).toStr();
|
|
7190
7828
|
}
|
|
7829
|
+
/**
|
|
7830
|
+
* Return this experiment's Braintrust parent string (`experiment_id:<id>`) for
|
|
7831
|
+
* the `braintrust.parent` baggage entry, or undefined when it cannot be
|
|
7832
|
+
* determined synchronously.
|
|
7833
|
+
*/
|
|
7834
|
+
_getOtelParent() {
|
|
7835
|
+
const id = this.lazyId.getSync().value;
|
|
7836
|
+
return id ? `experiment_id:${id}` : void 0;
|
|
7837
|
+
}
|
|
7191
7838
|
/**
|
|
7192
7839
|
* Flush any pending rows to the server.
|
|
7193
7840
|
*/
|
|
@@ -7252,9 +7899,16 @@ var SpanImpl = class _SpanImpl {
|
|
|
7252
7899
|
_spanId;
|
|
7253
7900
|
_rootSpanId;
|
|
7254
7901
|
_spanParents;
|
|
7902
|
+
// Inbound W3C trace-context state (tracestate + raw traceparent flags) to
|
|
7903
|
+
// forward on outbound propagation. Captured at the span that received it (via
|
|
7904
|
+
// extractTraceContextFromHeaders) and inherited by all subspans, so that any
|
|
7905
|
+
// inject() within the trace re-emits the upstream state unchanged, per the W3C
|
|
7906
|
+
// Trace Context spec. Not interpreted.
|
|
7907
|
+
_propagatedState;
|
|
7255
7908
|
kind = "span";
|
|
7256
7909
|
constructor(args) {
|
|
7257
7910
|
this._state = args.state;
|
|
7911
|
+
this._propagatedState = args.propagatedState;
|
|
7258
7912
|
const spanAttributes = args.spanAttributes ?? {};
|
|
7259
7913
|
const rawEvent = args.event ?? {};
|
|
7260
7914
|
const type = args.type ?? (args.parentSpanIds ? void 0 : args.defaultRootType);
|
|
@@ -7370,7 +8024,7 @@ var SpanImpl = class _SpanImpl {
|
|
|
7370
8024
|
tags: partialRecord.tags,
|
|
7371
8025
|
span_id: this._spanId,
|
|
7372
8026
|
span_parents: this._spanParents,
|
|
7373
|
-
is_root: this.
|
|
8027
|
+
is_root: !this._spanParents || this._spanParents.length === 0,
|
|
7374
8028
|
span_attributes: partialRecord.span_attributes
|
|
7375
8029
|
};
|
|
7376
8030
|
this._state.spanCache.queueWrite(
|
|
@@ -7432,7 +8086,8 @@ var SpanImpl = class _SpanImpl {
|
|
|
7432
8086
|
parentObjectId: this.parentObjectId,
|
|
7433
8087
|
parentComputeObjectMetadataArgs: this.parentComputeObjectMetadataArgs,
|
|
7434
8088
|
parentSpanIds,
|
|
7435
|
-
propagatedEvent: args?.propagatedEvent ?? this.propagatedEvent
|
|
8089
|
+
propagatedEvent: args?.propagatedEvent ?? this.propagatedEvent,
|
|
8090
|
+
propagatedState: this._propagatedState
|
|
7436
8091
|
})
|
|
7437
8092
|
});
|
|
7438
8093
|
}
|
|
@@ -7451,7 +8106,8 @@ var SpanImpl = class _SpanImpl {
|
|
|
7451
8106
|
parentObjectId: this.parentObjectId,
|
|
7452
8107
|
parentComputeObjectMetadataArgs: this.parentComputeObjectMetadataArgs,
|
|
7453
8108
|
parentSpanIds,
|
|
7454
|
-
propagatedEvent: args?.propagatedEvent ?? this.propagatedEvent
|
|
8109
|
+
propagatedEvent: args?.propagatedEvent ?? this.propagatedEvent,
|
|
8110
|
+
propagatedState: this._propagatedState
|
|
7455
8111
|
}),
|
|
7456
8112
|
spanId
|
|
7457
8113
|
});
|
|
@@ -7479,6 +8135,42 @@ var SpanImpl = class _SpanImpl {
|
|
|
7479
8135
|
propagated_event: this.propagatedEvent
|
|
7480
8136
|
}).toStr();
|
|
7481
8137
|
}
|
|
8138
|
+
/**
|
|
8139
|
+
* Return this span's Braintrust parent string (`project_id:<id>`,
|
|
8140
|
+
* `project_name:<name>`, or `experiment_id:<id>`) for the `braintrust.parent`
|
|
8141
|
+
* baggage entry, or undefined when it cannot be determined synchronously.
|
|
8142
|
+
*/
|
|
8143
|
+
_getOtelParent() {
|
|
8144
|
+
if (this.parentObjectType === 2 /* PROJECT_LOGS */) {
|
|
8145
|
+
const id = this.parentComputeObjectMetadataArgs?.project_id || this.parentObjectId.getSync().value;
|
|
8146
|
+
const name = this.parentComputeObjectMetadataArgs?.project_name;
|
|
8147
|
+
if (id) {
|
|
8148
|
+
return `project_id:${id}`;
|
|
8149
|
+
} else if (name) {
|
|
8150
|
+
return `project_name:${name}`;
|
|
8151
|
+
}
|
|
8152
|
+
} else if (this.parentObjectType === 1 /* EXPERIMENT */) {
|
|
8153
|
+
const id = this.parentComputeObjectMetadataArgs?.experiment_id || this.parentObjectId.getSync().value;
|
|
8154
|
+
if (id) {
|
|
8155
|
+
return `experiment_id:${id}`;
|
|
8156
|
+
}
|
|
8157
|
+
}
|
|
8158
|
+
return void 0;
|
|
8159
|
+
}
|
|
8160
|
+
inject(carrier) {
|
|
8161
|
+
const resolvedCarrier = carrier ?? {};
|
|
8162
|
+
try {
|
|
8163
|
+
_injectIntoCarrier(resolvedCarrier, {
|
|
8164
|
+
traceId: this._rootSpanId,
|
|
8165
|
+
spanId: this._spanId,
|
|
8166
|
+
braintrustParent: this._getOtelParent() ?? this._propagatedState?.braintrustParent,
|
|
8167
|
+
propagatedState: this._propagatedState
|
|
8168
|
+
});
|
|
8169
|
+
} catch (e) {
|
|
8170
|
+
debugLogger.warn(`Error injecting trace context: ${e}`);
|
|
8171
|
+
}
|
|
8172
|
+
return resolvedCarrier;
|
|
8173
|
+
}
|
|
7482
8174
|
async permalink() {
|
|
7483
8175
|
return await permalink(await this.export(), {
|
|
7484
8176
|
state: this._state
|
|
@@ -7614,6 +8306,7 @@ var Dataset2 = class extends ObjectFetcher {
|
|
|
7614
8306
|
_internal_btql
|
|
7615
8307
|
);
|
|
7616
8308
|
this.state = state2;
|
|
8309
|
+
void this.__braintrust_dataset_marker;
|
|
7617
8310
|
this.lazyMetadata = lazyMetadata;
|
|
7618
8311
|
this.lazyPinnedVersion = pinState?.lazyPinnedVersion;
|
|
7619
8312
|
this.pinnedEnvironment = pinState?.pinnedEnvironment;
|
|
@@ -8260,6 +8953,10 @@ var aiSDKChannels = defineChannels("ai", {
|
|
|
8260
8953
|
channelName: "ToolLoopAgent.stream",
|
|
8261
8954
|
kind: "async"
|
|
8262
8955
|
}),
|
|
8956
|
+
workflowAgentStream: channel({
|
|
8957
|
+
channelName: "WorkflowAgent.stream",
|
|
8958
|
+
kind: "async"
|
|
8959
|
+
}),
|
|
8263
8960
|
v7CreateTelemetryDispatcher: channel({
|
|
8264
8961
|
channelName: "createTelemetryDispatcher",
|
|
8265
8962
|
kind: "sync-stream"
|
|
@@ -8458,6 +9155,18 @@ var aiSDKConfigs = [
|
|
|
8458
9155
|
kind: "Sync"
|
|
8459
9156
|
}
|
|
8460
9157
|
},
|
|
9158
|
+
{
|
|
9159
|
+
channelName: aiSDKChannels.v7CreateTelemetryDispatcher.channelName,
|
|
9160
|
+
module: {
|
|
9161
|
+
name: "ai",
|
|
9162
|
+
versionRange: ">=7.0.0-0 <8.0.0",
|
|
9163
|
+
filePath: "dist/internal/index.js"
|
|
9164
|
+
},
|
|
9165
|
+
functionQuery: {
|
|
9166
|
+
functionName: "createTelemetryDispatcher",
|
|
9167
|
+
kind: "Sync"
|
|
9168
|
+
}
|
|
9169
|
+
},
|
|
8461
9170
|
// streamObject - async function (v3 only, before the sync refactor in v4)
|
|
8462
9171
|
{
|
|
8463
9172
|
channelName: aiSDKChannels.streamObject.channelName,
|
|
@@ -11203,9 +11912,6 @@ function getDefaultAutoInstrumentationConfigs() {
|
|
|
11203
11912
|
}
|
|
11204
11913
|
|
|
11205
11914
|
// src/auto-instrumentations/loader/cjs-patch.ts
|
|
11206
|
-
import {
|
|
11207
|
-
create
|
|
11208
|
-
} from "@apm-js-collab/code-transformer";
|
|
11209
11915
|
import * as NodeModule from "module";
|
|
11210
11916
|
import { sep } from "path";
|
|
11211
11917
|
import moduleDetailsFromPath from "module-details-from-path";
|
|
@@ -11262,8 +11968,6 @@ var ModulePatch = class {
|
|
|
11262
11968
|
args[0] = transformedCode?.code;
|
|
11263
11969
|
} catch (error) {
|
|
11264
11970
|
console.warn(`Error transforming module ${filename}:`, error);
|
|
11265
|
-
} finally {
|
|
11266
|
-
transformer.free();
|
|
11267
11971
|
}
|
|
11268
11972
|
}
|
|
11269
11973
|
}
|