braintrust 0.3.7 → 0.4.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/dev/dist/index.d.mts +25 -0
- package/dev/dist/index.d.ts +25 -0
- package/dev/dist/index.js +454 -122
- package/dev/dist/index.mjs +1360 -1028
- package/dist/browser.d.mts +31 -2
- package/dist/browser.d.ts +31 -2
- package/dist/browser.js +309 -114
- package/dist/browser.mjs +1183 -988
- package/dist/cli.js +1361 -1023
- package/dist/index.d.mts +131 -2
- package/dist/index.d.ts +131 -2
- package/dist/index.js +814 -177
- package/dist/index.mjs +1681 -1044
- package/package.json +6 -4
- package/util/dist/index.d.mts +65 -2
- package/util/dist/index.d.ts +65 -2
- package/util/dist/index.js +229 -17
- package/util/dist/index.mjs +230 -18
package/dist/index.mjs
CHANGED
|
@@ -1528,7 +1528,7 @@ var init_BatchSpanProcessor = __esm({
|
|
|
1528
1528
|
});
|
|
1529
1529
|
|
|
1530
1530
|
// ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/node/RandomIdGenerator.js
|
|
1531
|
-
function
|
|
1531
|
+
function getIdGenerator2(bytes) {
|
|
1532
1532
|
return function generateId() {
|
|
1533
1533
|
for (let i = 0; i < bytes / 4; i++) {
|
|
1534
1534
|
SHARED_BUFFER.writeUInt32BE(Math.random() * 2 ** 32 >>> 0, i * 4);
|
|
@@ -1554,12 +1554,12 @@ var init_RandomIdGenerator = __esm({
|
|
|
1554
1554
|
* Returns a random 16-byte trace ID formatted/encoded as a 32 lowercase hex
|
|
1555
1555
|
* characters corresponding to 128 bits.
|
|
1556
1556
|
*/
|
|
1557
|
-
generateTraceId =
|
|
1557
|
+
generateTraceId = getIdGenerator2(TRACE_ID_BYTES);
|
|
1558
1558
|
/**
|
|
1559
1559
|
* Returns a random 8-byte span ID formatted/encoded as a 16 lowercase hex
|
|
1560
1560
|
* characters corresponding to 64 bits.
|
|
1561
1561
|
*/
|
|
1562
|
-
generateSpanId =
|
|
1562
|
+
generateSpanId = getIdGenerator2(SPAN_ID_BYTES);
|
|
1563
1563
|
};
|
|
1564
1564
|
SHARED_BUFFER = Buffer.allocUnsafe(TRACE_ID_BYTES);
|
|
1565
1565
|
}
|
|
@@ -3440,7 +3440,7 @@ function getCallerLocation() {
|
|
|
3440
3440
|
}
|
|
3441
3441
|
|
|
3442
3442
|
// src/logger.ts
|
|
3443
|
-
import { v4 as
|
|
3443
|
+
import { v4 as uuidv42 } from "uuid";
|
|
3444
3444
|
|
|
3445
3445
|
// src/queue.ts
|
|
3446
3446
|
var DEFAULT_QUEUE_SIZE = 15e3;
|
|
@@ -3498,6 +3498,44 @@ var Queue = class {
|
|
|
3498
3498
|
}
|
|
3499
3499
|
};
|
|
3500
3500
|
|
|
3501
|
+
// src/id-gen.ts
|
|
3502
|
+
import { v4 as uuidv4 } from "uuid";
|
|
3503
|
+
function generateHexId(bytes) {
|
|
3504
|
+
let result = "";
|
|
3505
|
+
for (let i = 0; i < bytes; i++) {
|
|
3506
|
+
result += Math.floor(Math.random() * 256).toString(16).padStart(2, "0");
|
|
3507
|
+
}
|
|
3508
|
+
return result;
|
|
3509
|
+
}
|
|
3510
|
+
var IDGenerator = class {
|
|
3511
|
+
};
|
|
3512
|
+
var UUIDGenerator = class extends IDGenerator {
|
|
3513
|
+
getSpanId() {
|
|
3514
|
+
return uuidv4();
|
|
3515
|
+
}
|
|
3516
|
+
getTraceId() {
|
|
3517
|
+
return uuidv4();
|
|
3518
|
+
}
|
|
3519
|
+
shareRootSpanId() {
|
|
3520
|
+
return true;
|
|
3521
|
+
}
|
|
3522
|
+
};
|
|
3523
|
+
var OTELIDGenerator = class extends IDGenerator {
|
|
3524
|
+
getSpanId() {
|
|
3525
|
+
return generateHexId(8);
|
|
3526
|
+
}
|
|
3527
|
+
getTraceId() {
|
|
3528
|
+
return generateHexId(16);
|
|
3529
|
+
}
|
|
3530
|
+
shareRootSpanId() {
|
|
3531
|
+
return false;
|
|
3532
|
+
}
|
|
3533
|
+
};
|
|
3534
|
+
function getIdGenerator() {
|
|
3535
|
+
const useOtel = typeof process !== "undefined" && process.env?.BRAINTRUST_OTEL_COMPAT?.toLowerCase() === "true";
|
|
3536
|
+
return useOtel ? new OTELIDGenerator() : new UUIDGenerator();
|
|
3537
|
+
}
|
|
3538
|
+
|
|
3501
3539
|
// util/db_fields.ts
|
|
3502
3540
|
var TRANSACTION_ID_FIELD = "_xact_id";
|
|
3503
3541
|
var IS_MERGE_FIELD = "_is_merge";
|
|
@@ -4445,6 +4483,41 @@ function _urljoin(...parts) {
|
|
|
4445
4483
|
).filter((x) => x.trim() !== "").join("/");
|
|
4446
4484
|
}
|
|
4447
4485
|
|
|
4486
|
+
// util/span_identifier_v4.ts
|
|
4487
|
+
import { z as z4 } from "zod/v3";
|
|
4488
|
+
var ENCODING_VERSION_NUMBER_V4 = 4;
|
|
4489
|
+
var INVALID_ENCODING_ERRMSG_V4 = `SpanComponents string is not properly encoded. This library only supports encoding versions up to ${ENCODING_VERSION_NUMBER_V4}. Please make sure the SDK library used to decode the SpanComponents is at least as new as any library used to encode it.`;
|
|
4490
|
+
var spanComponentsV4Schema = z4.object({
|
|
4491
|
+
object_type: spanObjectTypeV3EnumSchema,
|
|
4492
|
+
propagated_event: z4.record(z4.unknown()).nullish()
|
|
4493
|
+
}).and(
|
|
4494
|
+
z4.union([
|
|
4495
|
+
// Must provide one or the other.
|
|
4496
|
+
z4.object({
|
|
4497
|
+
object_id: z4.string().nullish(),
|
|
4498
|
+
compute_object_metadata_args: z4.optional(z4.null())
|
|
4499
|
+
}),
|
|
4500
|
+
z4.object({
|
|
4501
|
+
object_id: z4.optional(z4.null()),
|
|
4502
|
+
compute_object_metadata_args: z4.record(z4.unknown())
|
|
4503
|
+
})
|
|
4504
|
+
])
|
|
4505
|
+
).and(
|
|
4506
|
+
z4.union([
|
|
4507
|
+
// Either all of these must be provided or none.
|
|
4508
|
+
z4.object({
|
|
4509
|
+
row_id: z4.string(),
|
|
4510
|
+
span_id: z4.string(),
|
|
4511
|
+
root_span_id: z4.string()
|
|
4512
|
+
}),
|
|
4513
|
+
z4.object({
|
|
4514
|
+
row_id: z4.optional(z4.null()),
|
|
4515
|
+
span_id: z4.optional(z4.null()),
|
|
4516
|
+
root_span_id: z4.optional(z4.null())
|
|
4517
|
+
})
|
|
4518
|
+
])
|
|
4519
|
+
);
|
|
4520
|
+
|
|
4448
4521
|
// util/git_fields.ts
|
|
4449
4522
|
function mergeGitMetadataSettings(s1, s2) {
|
|
4450
4523
|
if (s1.collect === "all") {
|
|
@@ -4485,12 +4558,12 @@ function loadPrettyXact(encodedHex) {
|
|
|
4485
4558
|
}
|
|
4486
4559
|
|
|
4487
4560
|
// util/zod_util.ts
|
|
4488
|
-
import { z as
|
|
4561
|
+
import { z as z5 } from "zod/v3";
|
|
4489
4562
|
|
|
4490
4563
|
// src/generated_types.ts
|
|
4491
|
-
import { z as
|
|
4492
|
-
var AclObjectType =
|
|
4493
|
-
|
|
4564
|
+
import { z as z6 } from "zod/v3";
|
|
4565
|
+
var AclObjectType = z6.union([
|
|
4566
|
+
z6.enum([
|
|
4494
4567
|
"organization",
|
|
4495
4568
|
"project",
|
|
4496
4569
|
"experiment",
|
|
@@ -4503,9 +4576,9 @@ var AclObjectType = z5.union([
|
|
|
4503
4576
|
"project_log",
|
|
4504
4577
|
"org_project"
|
|
4505
4578
|
]),
|
|
4506
|
-
|
|
4579
|
+
z6.null()
|
|
4507
4580
|
]);
|
|
4508
|
-
var Permission =
|
|
4581
|
+
var Permission = z6.enum([
|
|
4509
4582
|
"create",
|
|
4510
4583
|
"read",
|
|
4511
4584
|
"update",
|
|
@@ -4515,310 +4588,310 @@ var Permission = z5.enum([
|
|
|
4515
4588
|
"update_acls",
|
|
4516
4589
|
"delete_acls"
|
|
4517
4590
|
]);
|
|
4518
|
-
var Acl =
|
|
4519
|
-
id:
|
|
4520
|
-
object_type: AclObjectType.and(
|
|
4521
|
-
object_id:
|
|
4522
|
-
user_id:
|
|
4523
|
-
group_id:
|
|
4524
|
-
permission: Permission.and(
|
|
4525
|
-
restrict_object_type: AclObjectType.and(
|
|
4526
|
-
role_id:
|
|
4527
|
-
_object_org_id:
|
|
4528
|
-
created:
|
|
4529
|
-
});
|
|
4530
|
-
var AISecret =
|
|
4531
|
-
id:
|
|
4532
|
-
created:
|
|
4533
|
-
updated_at:
|
|
4534
|
-
org_id:
|
|
4535
|
-
name:
|
|
4536
|
-
type:
|
|
4537
|
-
metadata:
|
|
4538
|
-
preview_secret:
|
|
4539
|
-
});
|
|
4540
|
-
var ResponseFormatJsonSchema =
|
|
4541
|
-
name:
|
|
4542
|
-
description:
|
|
4543
|
-
schema:
|
|
4544
|
-
strict:
|
|
4545
|
-
});
|
|
4546
|
-
var ResponseFormatNullish =
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
type:
|
|
4591
|
+
var Acl = z6.object({
|
|
4592
|
+
id: z6.string().uuid(),
|
|
4593
|
+
object_type: AclObjectType.and(z6.string()),
|
|
4594
|
+
object_id: z6.string().uuid(),
|
|
4595
|
+
user_id: z6.union([z6.string(), z6.null()]).optional(),
|
|
4596
|
+
group_id: z6.union([z6.string(), z6.null()]).optional(),
|
|
4597
|
+
permission: Permission.and(z6.union([z6.string(), z6.null()])).optional(),
|
|
4598
|
+
restrict_object_type: AclObjectType.and(z6.unknown()).optional(),
|
|
4599
|
+
role_id: z6.union([z6.string(), z6.null()]).optional(),
|
|
4600
|
+
_object_org_id: z6.string().uuid(),
|
|
4601
|
+
created: z6.union([z6.string(), z6.null()]).optional()
|
|
4602
|
+
});
|
|
4603
|
+
var AISecret = z6.object({
|
|
4604
|
+
id: z6.string().uuid(),
|
|
4605
|
+
created: z6.union([z6.string(), z6.null()]).optional(),
|
|
4606
|
+
updated_at: z6.union([z6.string(), z6.null()]).optional(),
|
|
4607
|
+
org_id: z6.string().uuid(),
|
|
4608
|
+
name: z6.string(),
|
|
4609
|
+
type: z6.union([z6.string(), z6.null()]).optional(),
|
|
4610
|
+
metadata: z6.union([z6.object({}).partial().passthrough(), z6.null()]).optional(),
|
|
4611
|
+
preview_secret: z6.union([z6.string(), z6.null()]).optional()
|
|
4612
|
+
});
|
|
4613
|
+
var ResponseFormatJsonSchema = z6.object({
|
|
4614
|
+
name: z6.string(),
|
|
4615
|
+
description: z6.string().optional(),
|
|
4616
|
+
schema: z6.union([z6.object({}).partial().passthrough(), z6.string()]).optional(),
|
|
4617
|
+
strict: z6.union([z6.boolean(), z6.null()]).optional()
|
|
4618
|
+
});
|
|
4619
|
+
var ResponseFormatNullish = z6.union([
|
|
4620
|
+
z6.object({ type: z6.literal("json_object") }),
|
|
4621
|
+
z6.object({
|
|
4622
|
+
type: z6.literal("json_schema"),
|
|
4550
4623
|
json_schema: ResponseFormatJsonSchema
|
|
4551
4624
|
}),
|
|
4552
|
-
|
|
4553
|
-
|
|
4625
|
+
z6.object({ type: z6.literal("text") }),
|
|
4626
|
+
z6.null()
|
|
4554
4627
|
]);
|
|
4555
|
-
var AnyModelParams =
|
|
4556
|
-
temperature:
|
|
4557
|
-
top_p:
|
|
4558
|
-
max_tokens:
|
|
4559
|
-
max_completion_tokens:
|
|
4560
|
-
frequency_penalty:
|
|
4561
|
-
presence_penalty:
|
|
4628
|
+
var AnyModelParams = z6.object({
|
|
4629
|
+
temperature: z6.number().optional(),
|
|
4630
|
+
top_p: z6.number().optional(),
|
|
4631
|
+
max_tokens: z6.number(),
|
|
4632
|
+
max_completion_tokens: z6.number().optional(),
|
|
4633
|
+
frequency_penalty: z6.number().optional(),
|
|
4634
|
+
presence_penalty: z6.number().optional(),
|
|
4562
4635
|
response_format: ResponseFormatNullish.optional(),
|
|
4563
|
-
tool_choice:
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
type:
|
|
4569
|
-
function:
|
|
4636
|
+
tool_choice: z6.union([
|
|
4637
|
+
z6.literal("auto"),
|
|
4638
|
+
z6.literal("none"),
|
|
4639
|
+
z6.literal("required"),
|
|
4640
|
+
z6.object({
|
|
4641
|
+
type: z6.literal("function"),
|
|
4642
|
+
function: z6.object({ name: z6.string() })
|
|
4570
4643
|
})
|
|
4571
4644
|
]).optional(),
|
|
4572
|
-
function_call:
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4645
|
+
function_call: z6.union([
|
|
4646
|
+
z6.literal("auto"),
|
|
4647
|
+
z6.literal("none"),
|
|
4648
|
+
z6.object({ name: z6.string() })
|
|
4576
4649
|
]).optional(),
|
|
4577
|
-
n:
|
|
4578
|
-
stop:
|
|
4579
|
-
reasoning_effort:
|
|
4580
|
-
verbosity:
|
|
4581
|
-
top_k:
|
|
4582
|
-
stop_sequences:
|
|
4583
|
-
max_tokens_to_sample:
|
|
4584
|
-
maxOutputTokens:
|
|
4585
|
-
topP:
|
|
4586
|
-
topK:
|
|
4587
|
-
use_cache:
|
|
4588
|
-
});
|
|
4589
|
-
var ApiKey =
|
|
4590
|
-
id:
|
|
4591
|
-
created:
|
|
4592
|
-
name:
|
|
4593
|
-
preview_name:
|
|
4594
|
-
user_id:
|
|
4595
|
-
user_email:
|
|
4596
|
-
user_given_name:
|
|
4597
|
-
user_family_name:
|
|
4598
|
-
org_id:
|
|
4599
|
-
});
|
|
4600
|
-
var AsyncScoringState =
|
|
4601
|
-
|
|
4602
|
-
status:
|
|
4603
|
-
token:
|
|
4604
|
-
function_ids:
|
|
4605
|
-
skip_logging:
|
|
4650
|
+
n: z6.number().optional(),
|
|
4651
|
+
stop: z6.array(z6.string()).optional(),
|
|
4652
|
+
reasoning_effort: z6.enum(["minimal", "low", "medium", "high"]).optional(),
|
|
4653
|
+
verbosity: z6.enum(["low", "medium", "high"]).optional(),
|
|
4654
|
+
top_k: z6.number().optional(),
|
|
4655
|
+
stop_sequences: z6.array(z6.string()).optional(),
|
|
4656
|
+
max_tokens_to_sample: z6.number().optional(),
|
|
4657
|
+
maxOutputTokens: z6.number().optional(),
|
|
4658
|
+
topP: z6.number().optional(),
|
|
4659
|
+
topK: z6.number().optional(),
|
|
4660
|
+
use_cache: z6.boolean().optional()
|
|
4661
|
+
});
|
|
4662
|
+
var ApiKey = z6.object({
|
|
4663
|
+
id: z6.string().uuid(),
|
|
4664
|
+
created: z6.union([z6.string(), z6.null()]).optional(),
|
|
4665
|
+
name: z6.string(),
|
|
4666
|
+
preview_name: z6.string(),
|
|
4667
|
+
user_id: z6.union([z6.string(), z6.null()]).optional(),
|
|
4668
|
+
user_email: z6.union([z6.string(), z6.null()]).optional(),
|
|
4669
|
+
user_given_name: z6.union([z6.string(), z6.null()]).optional(),
|
|
4670
|
+
user_family_name: z6.union([z6.string(), z6.null()]).optional(),
|
|
4671
|
+
org_id: z6.union([z6.string(), z6.null()]).optional()
|
|
4672
|
+
});
|
|
4673
|
+
var AsyncScoringState = z6.union([
|
|
4674
|
+
z6.object({
|
|
4675
|
+
status: z6.literal("enabled"),
|
|
4676
|
+
token: z6.string(),
|
|
4677
|
+
function_ids: z6.array(z6.unknown()).min(1),
|
|
4678
|
+
skip_logging: z6.union([z6.boolean(), z6.null()]).optional()
|
|
4606
4679
|
}),
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
4680
|
+
z6.object({ status: z6.literal("disabled") }),
|
|
4681
|
+
z6.null(),
|
|
4682
|
+
z6.null()
|
|
4610
4683
|
]);
|
|
4611
|
-
var AsyncScoringControl =
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4684
|
+
var AsyncScoringControl = z6.union([
|
|
4685
|
+
z6.object({ kind: z6.literal("score_update"), token: z6.string() }),
|
|
4686
|
+
z6.object({ kind: z6.literal("state_override"), state: AsyncScoringState }),
|
|
4687
|
+
z6.object({ kind: z6.literal("state_force_reselect") }),
|
|
4688
|
+
z6.object({ kind: z6.literal("state_enabled_force_rescore") })
|
|
4616
4689
|
]);
|
|
4617
|
-
var BraintrustAttachmentReference =
|
|
4618
|
-
type:
|
|
4619
|
-
filename:
|
|
4620
|
-
content_type:
|
|
4621
|
-
key:
|
|
4622
|
-
});
|
|
4623
|
-
var ExternalAttachmentReference =
|
|
4624
|
-
type:
|
|
4625
|
-
filename:
|
|
4626
|
-
content_type:
|
|
4627
|
-
url:
|
|
4628
|
-
});
|
|
4629
|
-
var AttachmentReference =
|
|
4690
|
+
var BraintrustAttachmentReference = z6.object({
|
|
4691
|
+
type: z6.literal("braintrust_attachment"),
|
|
4692
|
+
filename: z6.string().min(1),
|
|
4693
|
+
content_type: z6.string().min(1),
|
|
4694
|
+
key: z6.string().min(1)
|
|
4695
|
+
});
|
|
4696
|
+
var ExternalAttachmentReference = z6.object({
|
|
4697
|
+
type: z6.literal("external_attachment"),
|
|
4698
|
+
filename: z6.string().min(1),
|
|
4699
|
+
content_type: z6.string().min(1),
|
|
4700
|
+
url: z6.string().min(1)
|
|
4701
|
+
});
|
|
4702
|
+
var AttachmentReference = z6.discriminatedUnion("type", [
|
|
4630
4703
|
BraintrustAttachmentReference,
|
|
4631
4704
|
ExternalAttachmentReference
|
|
4632
4705
|
]);
|
|
4633
|
-
var UploadStatus =
|
|
4634
|
-
var AttachmentStatus =
|
|
4706
|
+
var UploadStatus = z6.enum(["uploading", "done", "error"]);
|
|
4707
|
+
var AttachmentStatus = z6.object({
|
|
4635
4708
|
upload_status: UploadStatus,
|
|
4636
|
-
error_message:
|
|
4637
|
-
});
|
|
4638
|
-
var BraintrustModelParams =
|
|
4639
|
-
var CallEvent =
|
|
4640
|
-
|
|
4641
|
-
id:
|
|
4642
|
-
data:
|
|
4643
|
-
event:
|
|
4709
|
+
error_message: z6.string().optional()
|
|
4710
|
+
});
|
|
4711
|
+
var BraintrustModelParams = z6.object({ use_cache: z6.boolean() }).partial();
|
|
4712
|
+
var CallEvent = z6.union([
|
|
4713
|
+
z6.object({
|
|
4714
|
+
id: z6.string().optional(),
|
|
4715
|
+
data: z6.string(),
|
|
4716
|
+
event: z6.literal("text_delta")
|
|
4644
4717
|
}),
|
|
4645
|
-
|
|
4646
|
-
id:
|
|
4647
|
-
data:
|
|
4648
|
-
event:
|
|
4718
|
+
z6.object({
|
|
4719
|
+
id: z6.string().optional(),
|
|
4720
|
+
data: z6.string(),
|
|
4721
|
+
event: z6.literal("reasoning_delta")
|
|
4649
4722
|
}),
|
|
4650
|
-
|
|
4651
|
-
id:
|
|
4652
|
-
data:
|
|
4653
|
-
event:
|
|
4723
|
+
z6.object({
|
|
4724
|
+
id: z6.string().optional(),
|
|
4725
|
+
data: z6.string(),
|
|
4726
|
+
event: z6.literal("json_delta")
|
|
4654
4727
|
}),
|
|
4655
|
-
|
|
4656
|
-
id:
|
|
4657
|
-
data:
|
|
4658
|
-
event:
|
|
4728
|
+
z6.object({
|
|
4729
|
+
id: z6.string().optional(),
|
|
4730
|
+
data: z6.string(),
|
|
4731
|
+
event: z6.literal("progress")
|
|
4659
4732
|
}),
|
|
4660
|
-
|
|
4661
|
-
id:
|
|
4662
|
-
data:
|
|
4663
|
-
event:
|
|
4733
|
+
z6.object({
|
|
4734
|
+
id: z6.string().optional(),
|
|
4735
|
+
data: z6.string(),
|
|
4736
|
+
event: z6.literal("error")
|
|
4664
4737
|
}),
|
|
4665
|
-
|
|
4666
|
-
id:
|
|
4667
|
-
data:
|
|
4668
|
-
event:
|
|
4738
|
+
z6.object({
|
|
4739
|
+
id: z6.string().optional(),
|
|
4740
|
+
data: z6.string(),
|
|
4741
|
+
event: z6.literal("console")
|
|
4669
4742
|
}),
|
|
4670
|
-
|
|
4671
|
-
id:
|
|
4672
|
-
event:
|
|
4673
|
-
data:
|
|
4743
|
+
z6.object({
|
|
4744
|
+
id: z6.string().optional(),
|
|
4745
|
+
event: z6.literal("start"),
|
|
4746
|
+
data: z6.literal("")
|
|
4674
4747
|
}),
|
|
4675
|
-
|
|
4676
|
-
id:
|
|
4677
|
-
event:
|
|
4678
|
-
data:
|
|
4748
|
+
z6.object({
|
|
4749
|
+
id: z6.string().optional(),
|
|
4750
|
+
event: z6.literal("done"),
|
|
4751
|
+
data: z6.literal("")
|
|
4679
4752
|
})
|
|
4680
4753
|
]);
|
|
4681
|
-
var ChatCompletionContentPartTextWithTitle =
|
|
4682
|
-
text:
|
|
4683
|
-
type:
|
|
4684
|
-
cache_control:
|
|
4685
|
-
});
|
|
4686
|
-
var ChatCompletionContentPartImageWithTitle =
|
|
4687
|
-
image_url:
|
|
4688
|
-
url:
|
|
4689
|
-
detail:
|
|
4754
|
+
var ChatCompletionContentPartTextWithTitle = z6.object({
|
|
4755
|
+
text: z6.string().default(""),
|
|
4756
|
+
type: z6.literal("text"),
|
|
4757
|
+
cache_control: z6.object({ type: z6.literal("ephemeral") }).optional()
|
|
4758
|
+
});
|
|
4759
|
+
var ChatCompletionContentPartImageWithTitle = z6.object({
|
|
4760
|
+
image_url: z6.object({
|
|
4761
|
+
url: z6.string(),
|
|
4762
|
+
detail: z6.union([z6.literal("auto"), z6.literal("low"), z6.literal("high")]).optional()
|
|
4690
4763
|
}),
|
|
4691
|
-
type:
|
|
4764
|
+
type: z6.literal("image_url")
|
|
4692
4765
|
});
|
|
4693
|
-
var ChatCompletionContentPart =
|
|
4766
|
+
var ChatCompletionContentPart = z6.union([
|
|
4694
4767
|
ChatCompletionContentPartTextWithTitle,
|
|
4695
4768
|
ChatCompletionContentPartImageWithTitle
|
|
4696
4769
|
]);
|
|
4697
|
-
var ChatCompletionContentPartText =
|
|
4698
|
-
text:
|
|
4699
|
-
type:
|
|
4700
|
-
cache_control:
|
|
4701
|
-
});
|
|
4702
|
-
var ChatCompletionMessageToolCall =
|
|
4703
|
-
id:
|
|
4704
|
-
function:
|
|
4705
|
-
type:
|
|
4706
|
-
});
|
|
4707
|
-
var ChatCompletionMessageReasoning =
|
|
4708
|
-
var ChatCompletionMessageParam =
|
|
4709
|
-
|
|
4710
|
-
content:
|
|
4711
|
-
role:
|
|
4712
|
-
name:
|
|
4770
|
+
var ChatCompletionContentPartText = z6.object({
|
|
4771
|
+
text: z6.string().default(""),
|
|
4772
|
+
type: z6.literal("text"),
|
|
4773
|
+
cache_control: z6.object({ type: z6.literal("ephemeral") }).optional()
|
|
4774
|
+
});
|
|
4775
|
+
var ChatCompletionMessageToolCall = z6.object({
|
|
4776
|
+
id: z6.string(),
|
|
4777
|
+
function: z6.object({ arguments: z6.string(), name: z6.string() }),
|
|
4778
|
+
type: z6.literal("function")
|
|
4779
|
+
});
|
|
4780
|
+
var ChatCompletionMessageReasoning = z6.object({ id: z6.string(), content: z6.string() }).partial();
|
|
4781
|
+
var ChatCompletionMessageParam = z6.union([
|
|
4782
|
+
z6.object({
|
|
4783
|
+
content: z6.union([z6.string(), z6.array(ChatCompletionContentPartText)]),
|
|
4784
|
+
role: z6.literal("system"),
|
|
4785
|
+
name: z6.string().optional()
|
|
4713
4786
|
}),
|
|
4714
|
-
|
|
4715
|
-
content:
|
|
4716
|
-
role:
|
|
4717
|
-
name:
|
|
4787
|
+
z6.object({
|
|
4788
|
+
content: z6.union([z6.string(), z6.array(ChatCompletionContentPart)]),
|
|
4789
|
+
role: z6.literal("user"),
|
|
4790
|
+
name: z6.string().optional()
|
|
4718
4791
|
}),
|
|
4719
|
-
|
|
4720
|
-
role:
|
|
4721
|
-
content:
|
|
4722
|
-
function_call:
|
|
4723
|
-
name:
|
|
4724
|
-
tool_calls:
|
|
4725
|
-
reasoning:
|
|
4792
|
+
z6.object({
|
|
4793
|
+
role: z6.literal("assistant"),
|
|
4794
|
+
content: z6.union([z6.string(), z6.array(ChatCompletionContentPartText), z6.null()]).optional(),
|
|
4795
|
+
function_call: z6.object({ arguments: z6.string(), name: z6.string() }).optional(),
|
|
4796
|
+
name: z6.string().optional(),
|
|
4797
|
+
tool_calls: z6.array(ChatCompletionMessageToolCall).optional(),
|
|
4798
|
+
reasoning: z6.array(ChatCompletionMessageReasoning).optional()
|
|
4726
4799
|
}),
|
|
4727
|
-
|
|
4728
|
-
content:
|
|
4729
|
-
role:
|
|
4730
|
-
tool_call_id:
|
|
4800
|
+
z6.object({
|
|
4801
|
+
content: z6.union([z6.string(), z6.array(ChatCompletionContentPartText)]),
|
|
4802
|
+
role: z6.literal("tool"),
|
|
4803
|
+
tool_call_id: z6.string().default("")
|
|
4731
4804
|
}),
|
|
4732
|
-
|
|
4733
|
-
content:
|
|
4734
|
-
name:
|
|
4735
|
-
role:
|
|
4805
|
+
z6.object({
|
|
4806
|
+
content: z6.union([z6.string(), z6.null()]),
|
|
4807
|
+
name: z6.string(),
|
|
4808
|
+
role: z6.literal("function")
|
|
4736
4809
|
}),
|
|
4737
|
-
|
|
4738
|
-
content:
|
|
4739
|
-
role:
|
|
4740
|
-
name:
|
|
4810
|
+
z6.object({
|
|
4811
|
+
content: z6.union([z6.string(), z6.array(ChatCompletionContentPartText)]),
|
|
4812
|
+
role: z6.literal("developer"),
|
|
4813
|
+
name: z6.string().optional()
|
|
4741
4814
|
}),
|
|
4742
|
-
|
|
4743
|
-
role:
|
|
4744
|
-
content:
|
|
4815
|
+
z6.object({
|
|
4816
|
+
role: z6.literal("model"),
|
|
4817
|
+
content: z6.union([z6.string(), z6.null()]).optional()
|
|
4745
4818
|
})
|
|
4746
4819
|
]);
|
|
4747
|
-
var ChatCompletionOpenAIMessageParam =
|
|
4748
|
-
|
|
4749
|
-
content:
|
|
4750
|
-
role:
|
|
4751
|
-
name:
|
|
4820
|
+
var ChatCompletionOpenAIMessageParam = z6.union([
|
|
4821
|
+
z6.object({
|
|
4822
|
+
content: z6.union([z6.string(), z6.array(ChatCompletionContentPartText)]),
|
|
4823
|
+
role: z6.literal("system"),
|
|
4824
|
+
name: z6.string().optional()
|
|
4752
4825
|
}),
|
|
4753
|
-
|
|
4754
|
-
content:
|
|
4755
|
-
role:
|
|
4756
|
-
name:
|
|
4826
|
+
z6.object({
|
|
4827
|
+
content: z6.union([z6.string(), z6.array(ChatCompletionContentPart)]),
|
|
4828
|
+
role: z6.literal("user"),
|
|
4829
|
+
name: z6.string().optional()
|
|
4757
4830
|
}),
|
|
4758
|
-
|
|
4759
|
-
role:
|
|
4760
|
-
content:
|
|
4761
|
-
function_call:
|
|
4762
|
-
name:
|
|
4763
|
-
tool_calls:
|
|
4764
|
-
reasoning:
|
|
4831
|
+
z6.object({
|
|
4832
|
+
role: z6.literal("assistant"),
|
|
4833
|
+
content: z6.union([z6.string(), z6.array(ChatCompletionContentPartText), z6.null()]).optional(),
|
|
4834
|
+
function_call: z6.object({ arguments: z6.string(), name: z6.string() }).optional(),
|
|
4835
|
+
name: z6.string().optional(),
|
|
4836
|
+
tool_calls: z6.array(ChatCompletionMessageToolCall).optional(),
|
|
4837
|
+
reasoning: z6.array(ChatCompletionMessageReasoning).optional()
|
|
4765
4838
|
}),
|
|
4766
|
-
|
|
4767
|
-
content:
|
|
4768
|
-
role:
|
|
4769
|
-
tool_call_id:
|
|
4839
|
+
z6.object({
|
|
4840
|
+
content: z6.union([z6.string(), z6.array(ChatCompletionContentPartText)]),
|
|
4841
|
+
role: z6.literal("tool"),
|
|
4842
|
+
tool_call_id: z6.string().default("")
|
|
4770
4843
|
}),
|
|
4771
|
-
|
|
4772
|
-
content:
|
|
4773
|
-
name:
|
|
4774
|
-
role:
|
|
4844
|
+
z6.object({
|
|
4845
|
+
content: z6.union([z6.string(), z6.null()]),
|
|
4846
|
+
name: z6.string(),
|
|
4847
|
+
role: z6.literal("function")
|
|
4775
4848
|
}),
|
|
4776
|
-
|
|
4777
|
-
content:
|
|
4778
|
-
role:
|
|
4779
|
-
name:
|
|
4849
|
+
z6.object({
|
|
4850
|
+
content: z6.union([z6.string(), z6.array(ChatCompletionContentPartText)]),
|
|
4851
|
+
role: z6.literal("developer"),
|
|
4852
|
+
name: z6.string().optional()
|
|
4780
4853
|
})
|
|
4781
4854
|
]);
|
|
4782
|
-
var ChatCompletionTool =
|
|
4783
|
-
function:
|
|
4784
|
-
name:
|
|
4785
|
-
description:
|
|
4786
|
-
parameters:
|
|
4855
|
+
var ChatCompletionTool = z6.object({
|
|
4856
|
+
function: z6.object({
|
|
4857
|
+
name: z6.string(),
|
|
4858
|
+
description: z6.string().optional(),
|
|
4859
|
+
parameters: z6.object({}).partial().passthrough().optional()
|
|
4787
4860
|
}),
|
|
4788
|
-
type:
|
|
4861
|
+
type: z6.literal("function")
|
|
4789
4862
|
});
|
|
4790
|
-
var CodeBundle =
|
|
4791
|
-
runtime_context:
|
|
4792
|
-
runtime:
|
|
4793
|
-
version:
|
|
4863
|
+
var CodeBundle = z6.object({
|
|
4864
|
+
runtime_context: z6.object({
|
|
4865
|
+
runtime: z6.enum(["node", "python"]),
|
|
4866
|
+
version: z6.string()
|
|
4794
4867
|
}),
|
|
4795
|
-
location:
|
|
4796
|
-
|
|
4797
|
-
type:
|
|
4798
|
-
eval_name:
|
|
4799
|
-
position:
|
|
4800
|
-
|
|
4801
|
-
|
|
4868
|
+
location: z6.union([
|
|
4869
|
+
z6.object({
|
|
4870
|
+
type: z6.literal("experiment"),
|
|
4871
|
+
eval_name: z6.string(),
|
|
4872
|
+
position: z6.union([
|
|
4873
|
+
z6.object({ type: z6.literal("task") }),
|
|
4874
|
+
z6.object({ type: z6.literal("scorer"), index: z6.number().int().gte(0) })
|
|
4802
4875
|
])
|
|
4803
4876
|
}),
|
|
4804
|
-
|
|
4877
|
+
z6.object({ type: z6.literal("function"), index: z6.number().int().gte(0) })
|
|
4805
4878
|
]),
|
|
4806
|
-
bundle_id:
|
|
4807
|
-
preview:
|
|
4808
|
-
});
|
|
4809
|
-
var Dataset =
|
|
4810
|
-
id:
|
|
4811
|
-
project_id:
|
|
4812
|
-
name:
|
|
4813
|
-
description:
|
|
4814
|
-
created:
|
|
4815
|
-
deleted_at:
|
|
4816
|
-
user_id:
|
|
4817
|
-
metadata:
|
|
4818
|
-
});
|
|
4819
|
-
var ObjectReferenceNullish =
|
|
4820
|
-
|
|
4821
|
-
object_type:
|
|
4879
|
+
bundle_id: z6.string(),
|
|
4880
|
+
preview: z6.union([z6.string(), z6.null()]).optional()
|
|
4881
|
+
});
|
|
4882
|
+
var Dataset = z6.object({
|
|
4883
|
+
id: z6.string().uuid(),
|
|
4884
|
+
project_id: z6.string().uuid(),
|
|
4885
|
+
name: z6.string(),
|
|
4886
|
+
description: z6.union([z6.string(), z6.null()]).optional(),
|
|
4887
|
+
created: z6.union([z6.string(), z6.null()]).optional(),
|
|
4888
|
+
deleted_at: z6.union([z6.string(), z6.null()]).optional(),
|
|
4889
|
+
user_id: z6.union([z6.string(), z6.null()]).optional(),
|
|
4890
|
+
metadata: z6.union([z6.object({}).partial().passthrough(), z6.null()]).optional()
|
|
4891
|
+
});
|
|
4892
|
+
var ObjectReferenceNullish = z6.union([
|
|
4893
|
+
z6.object({
|
|
4894
|
+
object_type: z6.enum([
|
|
4822
4895
|
"project_logs",
|
|
4823
4896
|
"experiment",
|
|
4824
4897
|
"dataset",
|
|
@@ -4826,399 +4899,399 @@ var ObjectReferenceNullish = z5.union([
|
|
|
4826
4899
|
"function",
|
|
4827
4900
|
"prompt_session"
|
|
4828
4901
|
]),
|
|
4829
|
-
object_id:
|
|
4830
|
-
id:
|
|
4831
|
-
_xact_id:
|
|
4832
|
-
created:
|
|
4902
|
+
object_id: z6.string().uuid(),
|
|
4903
|
+
id: z6.string(),
|
|
4904
|
+
_xact_id: z6.union([z6.string(), z6.null()]).optional(),
|
|
4905
|
+
created: z6.union([z6.string(), z6.null()]).optional()
|
|
4833
4906
|
}),
|
|
4834
|
-
|
|
4907
|
+
z6.null()
|
|
4835
4908
|
]);
|
|
4836
|
-
var DatasetEvent =
|
|
4837
|
-
id:
|
|
4838
|
-
_xact_id:
|
|
4839
|
-
created:
|
|
4840
|
-
_pagination_key:
|
|
4841
|
-
project_id:
|
|
4842
|
-
dataset_id:
|
|
4843
|
-
input:
|
|
4844
|
-
expected:
|
|
4845
|
-
metadata:
|
|
4846
|
-
|
|
4847
|
-
|
|
4909
|
+
var DatasetEvent = z6.object({
|
|
4910
|
+
id: z6.string(),
|
|
4911
|
+
_xact_id: z6.string(),
|
|
4912
|
+
created: z6.string().datetime({ offset: true }),
|
|
4913
|
+
_pagination_key: z6.union([z6.string(), z6.null()]).optional(),
|
|
4914
|
+
project_id: z6.string().uuid(),
|
|
4915
|
+
dataset_id: z6.string().uuid(),
|
|
4916
|
+
input: z6.unknown().optional(),
|
|
4917
|
+
expected: z6.unknown().optional(),
|
|
4918
|
+
metadata: z6.union([
|
|
4919
|
+
z6.object({ model: z6.union([z6.string(), z6.null()]) }).partial().passthrough(),
|
|
4920
|
+
z6.null()
|
|
4848
4921
|
]).optional(),
|
|
4849
|
-
tags:
|
|
4850
|
-
span_id:
|
|
4851
|
-
root_span_id:
|
|
4852
|
-
is_root:
|
|
4922
|
+
tags: z6.union([z6.array(z6.string()), z6.null()]).optional(),
|
|
4923
|
+
span_id: z6.string(),
|
|
4924
|
+
root_span_id: z6.string(),
|
|
4925
|
+
is_root: z6.union([z6.boolean(), z6.null()]).optional(),
|
|
4853
4926
|
origin: ObjectReferenceNullish.optional()
|
|
4854
4927
|
});
|
|
4855
|
-
var EnvVar =
|
|
4856
|
-
id:
|
|
4857
|
-
object_type:
|
|
4858
|
-
object_id:
|
|
4859
|
-
name:
|
|
4860
|
-
created:
|
|
4861
|
-
used:
|
|
4862
|
-
});
|
|
4863
|
-
var RepoInfo =
|
|
4864
|
-
|
|
4865
|
-
commit:
|
|
4866
|
-
branch:
|
|
4867
|
-
tag:
|
|
4868
|
-
dirty:
|
|
4869
|
-
author_name:
|
|
4870
|
-
author_email:
|
|
4871
|
-
commit_message:
|
|
4872
|
-
commit_time:
|
|
4873
|
-
git_diff:
|
|
4928
|
+
var EnvVar = z6.object({
|
|
4929
|
+
id: z6.string().uuid(),
|
|
4930
|
+
object_type: z6.enum(["organization", "project", "function"]),
|
|
4931
|
+
object_id: z6.string().uuid(),
|
|
4932
|
+
name: z6.string(),
|
|
4933
|
+
created: z6.union([z6.string(), z6.null()]).optional(),
|
|
4934
|
+
used: z6.union([z6.string(), z6.null()]).optional()
|
|
4935
|
+
});
|
|
4936
|
+
var RepoInfo = z6.union([
|
|
4937
|
+
z6.object({
|
|
4938
|
+
commit: z6.union([z6.string(), z6.null()]),
|
|
4939
|
+
branch: z6.union([z6.string(), z6.null()]),
|
|
4940
|
+
tag: z6.union([z6.string(), z6.null()]),
|
|
4941
|
+
dirty: z6.union([z6.boolean(), z6.null()]),
|
|
4942
|
+
author_name: z6.union([z6.string(), z6.null()]),
|
|
4943
|
+
author_email: z6.union([z6.string(), z6.null()]),
|
|
4944
|
+
commit_message: z6.union([z6.string(), z6.null()]),
|
|
4945
|
+
commit_time: z6.union([z6.string(), z6.null()]),
|
|
4946
|
+
git_diff: z6.union([z6.string(), z6.null()])
|
|
4874
4947
|
}).partial(),
|
|
4875
|
-
|
|
4948
|
+
z6.null()
|
|
4876
4949
|
]);
|
|
4877
|
-
var Experiment =
|
|
4878
|
-
id:
|
|
4879
|
-
project_id:
|
|
4880
|
-
name:
|
|
4881
|
-
description:
|
|
4882
|
-
created:
|
|
4950
|
+
var Experiment = z6.object({
|
|
4951
|
+
id: z6.string().uuid(),
|
|
4952
|
+
project_id: z6.string().uuid(),
|
|
4953
|
+
name: z6.string(),
|
|
4954
|
+
description: z6.union([z6.string(), z6.null()]).optional(),
|
|
4955
|
+
created: z6.union([z6.string(), z6.null()]).optional(),
|
|
4883
4956
|
repo_info: RepoInfo.optional(),
|
|
4884
|
-
commit:
|
|
4885
|
-
base_exp_id:
|
|
4886
|
-
deleted_at:
|
|
4887
|
-
dataset_id:
|
|
4888
|
-
dataset_version:
|
|
4889
|
-
public:
|
|
4890
|
-
user_id:
|
|
4891
|
-
metadata:
|
|
4892
|
-
tags:
|
|
4893
|
-
});
|
|
4894
|
-
var SpanType =
|
|
4895
|
-
|
|
4896
|
-
|
|
4957
|
+
commit: z6.union([z6.string(), z6.null()]).optional(),
|
|
4958
|
+
base_exp_id: z6.union([z6.string(), z6.null()]).optional(),
|
|
4959
|
+
deleted_at: z6.union([z6.string(), z6.null()]).optional(),
|
|
4960
|
+
dataset_id: z6.union([z6.string(), z6.null()]).optional(),
|
|
4961
|
+
dataset_version: z6.union([z6.string(), z6.null()]).optional(),
|
|
4962
|
+
public: z6.boolean(),
|
|
4963
|
+
user_id: z6.union([z6.string(), z6.null()]).optional(),
|
|
4964
|
+
metadata: z6.union([z6.object({}).partial().passthrough(), z6.null()]).optional(),
|
|
4965
|
+
tags: z6.union([z6.array(z6.string()), z6.null()]).optional()
|
|
4966
|
+
});
|
|
4967
|
+
var SpanType = z6.union([
|
|
4968
|
+
z6.enum(["llm", "score", "function", "eval", "task", "tool"]),
|
|
4969
|
+
z6.null()
|
|
4897
4970
|
]);
|
|
4898
|
-
var SpanAttributes =
|
|
4899
|
-
|
|
4900
|
-
|
|
4971
|
+
var SpanAttributes = z6.union([
|
|
4972
|
+
z6.object({ name: z6.union([z6.string(), z6.null()]), type: SpanType }).partial().passthrough(),
|
|
4973
|
+
z6.null()
|
|
4901
4974
|
]);
|
|
4902
|
-
var ExperimentEvent =
|
|
4903
|
-
id:
|
|
4904
|
-
_xact_id:
|
|
4905
|
-
created:
|
|
4906
|
-
_pagination_key:
|
|
4907
|
-
project_id:
|
|
4908
|
-
experiment_id:
|
|
4909
|
-
input:
|
|
4910
|
-
output:
|
|
4911
|
-
expected:
|
|
4912
|
-
error:
|
|
4913
|
-
scores:
|
|
4914
|
-
metadata:
|
|
4915
|
-
|
|
4916
|
-
|
|
4975
|
+
var ExperimentEvent = z6.object({
|
|
4976
|
+
id: z6.string(),
|
|
4977
|
+
_xact_id: z6.string(),
|
|
4978
|
+
created: z6.string().datetime({ offset: true }),
|
|
4979
|
+
_pagination_key: z6.union([z6.string(), z6.null()]).optional(),
|
|
4980
|
+
project_id: z6.string().uuid(),
|
|
4981
|
+
experiment_id: z6.string().uuid(),
|
|
4982
|
+
input: z6.unknown().optional(),
|
|
4983
|
+
output: z6.unknown().optional(),
|
|
4984
|
+
expected: z6.unknown().optional(),
|
|
4985
|
+
error: z6.unknown().optional(),
|
|
4986
|
+
scores: z6.union([z6.record(z6.union([z6.number(), z6.null()])), z6.null()]).optional(),
|
|
4987
|
+
metadata: z6.union([
|
|
4988
|
+
z6.object({ model: z6.union([z6.string(), z6.null()]) }).partial().passthrough(),
|
|
4989
|
+
z6.null()
|
|
4917
4990
|
]).optional(),
|
|
4918
|
-
tags:
|
|
4919
|
-
metrics:
|
|
4920
|
-
context:
|
|
4921
|
-
|
|
4922
|
-
caller_functionname:
|
|
4923
|
-
caller_filename:
|
|
4924
|
-
caller_lineno:
|
|
4991
|
+
tags: z6.union([z6.array(z6.string()), z6.null()]).optional(),
|
|
4992
|
+
metrics: z6.union([z6.record(z6.number()), z6.null()]).optional(),
|
|
4993
|
+
context: z6.union([
|
|
4994
|
+
z6.object({
|
|
4995
|
+
caller_functionname: z6.union([z6.string(), z6.null()]),
|
|
4996
|
+
caller_filename: z6.union([z6.string(), z6.null()]),
|
|
4997
|
+
caller_lineno: z6.union([z6.number(), z6.null()])
|
|
4925
4998
|
}).partial().passthrough(),
|
|
4926
|
-
|
|
4999
|
+
z6.null()
|
|
4927
5000
|
]).optional(),
|
|
4928
|
-
span_id:
|
|
4929
|
-
span_parents:
|
|
4930
|
-
root_span_id:
|
|
5001
|
+
span_id: z6.string(),
|
|
5002
|
+
span_parents: z6.union([z6.array(z6.string()), z6.null()]).optional(),
|
|
5003
|
+
root_span_id: z6.string(),
|
|
4931
5004
|
span_attributes: SpanAttributes.optional(),
|
|
4932
|
-
is_root:
|
|
5005
|
+
is_root: z6.union([z6.boolean(), z6.null()]).optional(),
|
|
4933
5006
|
origin: ObjectReferenceNullish.optional()
|
|
4934
5007
|
});
|
|
4935
|
-
var ExtendedSavedFunctionId =
|
|
4936
|
-
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
type:
|
|
4940
|
-
project_id:
|
|
4941
|
-
slug:
|
|
5008
|
+
var ExtendedSavedFunctionId = z6.union([
|
|
5009
|
+
z6.object({ type: z6.literal("function"), id: z6.string() }),
|
|
5010
|
+
z6.object({ type: z6.literal("global"), name: z6.string() }),
|
|
5011
|
+
z6.object({
|
|
5012
|
+
type: z6.literal("slug"),
|
|
5013
|
+
project_id: z6.string(),
|
|
5014
|
+
slug: z6.string()
|
|
4942
5015
|
})
|
|
4943
5016
|
]);
|
|
4944
|
-
var PromptBlockDataNullish =
|
|
4945
|
-
|
|
4946
|
-
|
|
4947
|
-
type:
|
|
4948
|
-
messages:
|
|
4949
|
-
tools:
|
|
5017
|
+
var PromptBlockDataNullish = z6.union([
|
|
5018
|
+
z6.object({ type: z6.literal("completion"), content: z6.string() }),
|
|
5019
|
+
z6.object({
|
|
5020
|
+
type: z6.literal("chat"),
|
|
5021
|
+
messages: z6.array(ChatCompletionMessageParam),
|
|
5022
|
+
tools: z6.string().optional()
|
|
4950
5023
|
}),
|
|
4951
|
-
|
|
5024
|
+
z6.null()
|
|
4952
5025
|
]);
|
|
4953
|
-
var ModelParams =
|
|
4954
|
-
|
|
4955
|
-
use_cache:
|
|
4956
|
-
temperature:
|
|
4957
|
-
top_p:
|
|
4958
|
-
max_tokens:
|
|
4959
|
-
max_completion_tokens:
|
|
4960
|
-
frequency_penalty:
|
|
4961
|
-
presence_penalty:
|
|
5026
|
+
var ModelParams = z6.union([
|
|
5027
|
+
z6.object({
|
|
5028
|
+
use_cache: z6.boolean(),
|
|
5029
|
+
temperature: z6.number(),
|
|
5030
|
+
top_p: z6.number(),
|
|
5031
|
+
max_tokens: z6.number(),
|
|
5032
|
+
max_completion_tokens: z6.number(),
|
|
5033
|
+
frequency_penalty: z6.number(),
|
|
5034
|
+
presence_penalty: z6.number(),
|
|
4962
5035
|
response_format: ResponseFormatNullish,
|
|
4963
|
-
tool_choice:
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
type:
|
|
4969
|
-
function:
|
|
5036
|
+
tool_choice: z6.union([
|
|
5037
|
+
z6.literal("auto"),
|
|
5038
|
+
z6.literal("none"),
|
|
5039
|
+
z6.literal("required"),
|
|
5040
|
+
z6.object({
|
|
5041
|
+
type: z6.literal("function"),
|
|
5042
|
+
function: z6.object({ name: z6.string() })
|
|
4970
5043
|
})
|
|
4971
5044
|
]),
|
|
4972
|
-
function_call:
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
5045
|
+
function_call: z6.union([
|
|
5046
|
+
z6.literal("auto"),
|
|
5047
|
+
z6.literal("none"),
|
|
5048
|
+
z6.object({ name: z6.string() })
|
|
4976
5049
|
]),
|
|
4977
|
-
n:
|
|
4978
|
-
stop:
|
|
4979
|
-
reasoning_effort:
|
|
4980
|
-
verbosity:
|
|
5050
|
+
n: z6.number(),
|
|
5051
|
+
stop: z6.array(z6.string()),
|
|
5052
|
+
reasoning_effort: z6.enum(["minimal", "low", "medium", "high"]),
|
|
5053
|
+
verbosity: z6.enum(["low", "medium", "high"])
|
|
4981
5054
|
}).partial().passthrough(),
|
|
4982
|
-
|
|
4983
|
-
use_cache:
|
|
4984
|
-
max_tokens:
|
|
4985
|
-
temperature:
|
|
4986
|
-
top_p:
|
|
4987
|
-
top_k:
|
|
4988
|
-
stop_sequences:
|
|
4989
|
-
max_tokens_to_sample:
|
|
5055
|
+
z6.object({
|
|
5056
|
+
use_cache: z6.boolean().optional(),
|
|
5057
|
+
max_tokens: z6.number(),
|
|
5058
|
+
temperature: z6.number(),
|
|
5059
|
+
top_p: z6.number().optional(),
|
|
5060
|
+
top_k: z6.number().optional(),
|
|
5061
|
+
stop_sequences: z6.array(z6.string()).optional(),
|
|
5062
|
+
max_tokens_to_sample: z6.number().optional()
|
|
4990
5063
|
}).passthrough(),
|
|
4991
|
-
|
|
4992
|
-
use_cache:
|
|
4993
|
-
temperature:
|
|
4994
|
-
maxOutputTokens:
|
|
4995
|
-
topP:
|
|
4996
|
-
topK:
|
|
5064
|
+
z6.object({
|
|
5065
|
+
use_cache: z6.boolean(),
|
|
5066
|
+
temperature: z6.number(),
|
|
5067
|
+
maxOutputTokens: z6.number(),
|
|
5068
|
+
topP: z6.number(),
|
|
5069
|
+
topK: z6.number()
|
|
4997
5070
|
}).partial().passthrough(),
|
|
4998
|
-
|
|
4999
|
-
use_cache:
|
|
5000
|
-
temperature:
|
|
5001
|
-
topK:
|
|
5071
|
+
z6.object({
|
|
5072
|
+
use_cache: z6.boolean(),
|
|
5073
|
+
temperature: z6.number(),
|
|
5074
|
+
topK: z6.number()
|
|
5002
5075
|
}).partial().passthrough(),
|
|
5003
|
-
|
|
5076
|
+
z6.object({ use_cache: z6.boolean() }).partial().passthrough()
|
|
5004
5077
|
]);
|
|
5005
|
-
var PromptOptionsNullish =
|
|
5006
|
-
|
|
5007
|
-
|
|
5078
|
+
var PromptOptionsNullish = z6.union([
|
|
5079
|
+
z6.object({ model: z6.string(), params: ModelParams, position: z6.string() }).partial(),
|
|
5080
|
+
z6.null()
|
|
5008
5081
|
]);
|
|
5009
|
-
var PromptParserNullish =
|
|
5010
|
-
|
|
5011
|
-
type:
|
|
5012
|
-
use_cot:
|
|
5013
|
-
choice_scores:
|
|
5082
|
+
var PromptParserNullish = z6.union([
|
|
5083
|
+
z6.object({
|
|
5084
|
+
type: z6.literal("llm_classifier"),
|
|
5085
|
+
use_cot: z6.boolean(),
|
|
5086
|
+
choice_scores: z6.record(z6.number().gte(0).lte(1))
|
|
5014
5087
|
}),
|
|
5015
|
-
|
|
5088
|
+
z6.null()
|
|
5016
5089
|
]);
|
|
5017
|
-
var SavedFunctionId =
|
|
5018
|
-
|
|
5019
|
-
|
|
5090
|
+
var SavedFunctionId = z6.union([
|
|
5091
|
+
z6.object({ type: z6.literal("function"), id: z6.string() }),
|
|
5092
|
+
z6.object({ type: z6.literal("global"), name: z6.string() })
|
|
5020
5093
|
]);
|
|
5021
|
-
var PromptDataNullish =
|
|
5022
|
-
|
|
5094
|
+
var PromptDataNullish = z6.union([
|
|
5095
|
+
z6.object({
|
|
5023
5096
|
prompt: PromptBlockDataNullish,
|
|
5024
5097
|
options: PromptOptionsNullish,
|
|
5025
5098
|
parser: PromptParserNullish,
|
|
5026
|
-
tool_functions:
|
|
5027
|
-
origin:
|
|
5028
|
-
|
|
5029
|
-
prompt_id:
|
|
5030
|
-
project_id:
|
|
5031
|
-
prompt_version:
|
|
5099
|
+
tool_functions: z6.union([z6.array(SavedFunctionId), z6.null()]),
|
|
5100
|
+
origin: z6.union([
|
|
5101
|
+
z6.object({
|
|
5102
|
+
prompt_id: z6.string(),
|
|
5103
|
+
project_id: z6.string(),
|
|
5104
|
+
prompt_version: z6.string()
|
|
5032
5105
|
}).partial(),
|
|
5033
|
-
|
|
5106
|
+
z6.null()
|
|
5034
5107
|
])
|
|
5035
5108
|
}).partial(),
|
|
5036
|
-
|
|
5109
|
+
z6.null()
|
|
5037
5110
|
]);
|
|
5038
|
-
var FunctionTypeEnumNullish =
|
|
5039
|
-
|
|
5040
|
-
|
|
5111
|
+
var FunctionTypeEnumNullish = z6.union([
|
|
5112
|
+
z6.enum(["llm", "scorer", "task", "tool"]),
|
|
5113
|
+
z6.null()
|
|
5041
5114
|
]);
|
|
5042
|
-
var FunctionIdRef =
|
|
5043
|
-
var PromptBlockData =
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
type:
|
|
5047
|
-
messages:
|
|
5048
|
-
tools:
|
|
5115
|
+
var FunctionIdRef = z6.object({}).partial().passthrough();
|
|
5116
|
+
var PromptBlockData = z6.union([
|
|
5117
|
+
z6.object({ type: z6.literal("completion"), content: z6.string() }),
|
|
5118
|
+
z6.object({
|
|
5119
|
+
type: z6.literal("chat"),
|
|
5120
|
+
messages: z6.array(ChatCompletionMessageParam),
|
|
5121
|
+
tools: z6.string().optional()
|
|
5049
5122
|
})
|
|
5050
5123
|
]);
|
|
5051
|
-
var GraphNode =
|
|
5052
|
-
|
|
5053
|
-
description:
|
|
5054
|
-
position:
|
|
5055
|
-
type:
|
|
5124
|
+
var GraphNode = z6.union([
|
|
5125
|
+
z6.object({
|
|
5126
|
+
description: z6.union([z6.string(), z6.null()]).optional(),
|
|
5127
|
+
position: z6.union([z6.object({ x: z6.number(), y: z6.number() }), z6.null()]).optional(),
|
|
5128
|
+
type: z6.literal("function"),
|
|
5056
5129
|
function: FunctionIdRef
|
|
5057
5130
|
}),
|
|
5058
|
-
|
|
5059
|
-
description:
|
|
5060
|
-
position:
|
|
5061
|
-
type:
|
|
5131
|
+
z6.object({
|
|
5132
|
+
description: z6.union([z6.string(), z6.null()]).optional(),
|
|
5133
|
+
position: z6.union([z6.object({ x: z6.number(), y: z6.number() }), z6.null()]).optional(),
|
|
5134
|
+
type: z6.literal("input")
|
|
5062
5135
|
}),
|
|
5063
|
-
|
|
5064
|
-
description:
|
|
5065
|
-
position:
|
|
5066
|
-
type:
|
|
5136
|
+
z6.object({
|
|
5137
|
+
description: z6.union([z6.string(), z6.null()]).optional(),
|
|
5138
|
+
position: z6.union([z6.object({ x: z6.number(), y: z6.number() }), z6.null()]).optional(),
|
|
5139
|
+
type: z6.literal("output")
|
|
5067
5140
|
}),
|
|
5068
|
-
|
|
5069
|
-
description:
|
|
5070
|
-
position:
|
|
5071
|
-
type:
|
|
5072
|
-
value:
|
|
5141
|
+
z6.object({
|
|
5142
|
+
description: z6.union([z6.string(), z6.null()]).optional(),
|
|
5143
|
+
position: z6.union([z6.object({ x: z6.number(), y: z6.number() }), z6.null()]).optional(),
|
|
5144
|
+
type: z6.literal("literal"),
|
|
5145
|
+
value: z6.unknown().optional()
|
|
5073
5146
|
}),
|
|
5074
|
-
|
|
5075
|
-
description:
|
|
5076
|
-
position:
|
|
5077
|
-
type:
|
|
5078
|
-
expr:
|
|
5147
|
+
z6.object({
|
|
5148
|
+
description: z6.union([z6.string(), z6.null()]).optional(),
|
|
5149
|
+
position: z6.union([z6.object({ x: z6.number(), y: z6.number() }), z6.null()]).optional(),
|
|
5150
|
+
type: z6.literal("btql"),
|
|
5151
|
+
expr: z6.string()
|
|
5079
5152
|
}),
|
|
5080
|
-
|
|
5081
|
-
description:
|
|
5082
|
-
position:
|
|
5083
|
-
type:
|
|
5084
|
-
condition:
|
|
5153
|
+
z6.object({
|
|
5154
|
+
description: z6.union([z6.string(), z6.null()]).optional(),
|
|
5155
|
+
position: z6.union([z6.object({ x: z6.number(), y: z6.number() }), z6.null()]).optional(),
|
|
5156
|
+
type: z6.literal("gate"),
|
|
5157
|
+
condition: z6.union([z6.string(), z6.null()]).optional()
|
|
5085
5158
|
}),
|
|
5086
|
-
|
|
5087
|
-
description:
|
|
5088
|
-
position:
|
|
5089
|
-
type:
|
|
5159
|
+
z6.object({
|
|
5160
|
+
description: z6.union([z6.string(), z6.null()]).optional(),
|
|
5161
|
+
position: z6.union([z6.object({ x: z6.number(), y: z6.number() }), z6.null()]).optional(),
|
|
5162
|
+
type: z6.literal("aggregator")
|
|
5090
5163
|
}),
|
|
5091
|
-
|
|
5092
|
-
description:
|
|
5093
|
-
position:
|
|
5094
|
-
type:
|
|
5164
|
+
z6.object({
|
|
5165
|
+
description: z6.union([z6.string(), z6.null()]).optional(),
|
|
5166
|
+
position: z6.union([z6.object({ x: z6.number(), y: z6.number() }), z6.null()]).optional(),
|
|
5167
|
+
type: z6.literal("prompt_template"),
|
|
5095
5168
|
prompt: PromptBlockData
|
|
5096
5169
|
})
|
|
5097
5170
|
]);
|
|
5098
|
-
var GraphEdge =
|
|
5099
|
-
source:
|
|
5100
|
-
target:
|
|
5101
|
-
purpose:
|
|
5102
|
-
});
|
|
5103
|
-
var GraphData =
|
|
5104
|
-
type:
|
|
5105
|
-
nodes:
|
|
5106
|
-
edges:
|
|
5107
|
-
});
|
|
5108
|
-
var FunctionData =
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
type:
|
|
5112
|
-
data:
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
type:
|
|
5116
|
-
runtime_context:
|
|
5117
|
-
runtime:
|
|
5118
|
-
version:
|
|
5171
|
+
var GraphEdge = z6.object({
|
|
5172
|
+
source: z6.object({ node: z6.string().max(1024), variable: z6.string() }),
|
|
5173
|
+
target: z6.object({ node: z6.string().max(1024), variable: z6.string() }),
|
|
5174
|
+
purpose: z6.enum(["control", "data", "messages"])
|
|
5175
|
+
});
|
|
5176
|
+
var GraphData = z6.object({
|
|
5177
|
+
type: z6.literal("graph"),
|
|
5178
|
+
nodes: z6.record(GraphNode),
|
|
5179
|
+
edges: z6.record(GraphEdge)
|
|
5180
|
+
});
|
|
5181
|
+
var FunctionData = z6.union([
|
|
5182
|
+
z6.object({ type: z6.literal("prompt") }),
|
|
5183
|
+
z6.object({
|
|
5184
|
+
type: z6.literal("code"),
|
|
5185
|
+
data: z6.union([
|
|
5186
|
+
z6.object({ type: z6.literal("bundle") }).and(CodeBundle),
|
|
5187
|
+
z6.object({
|
|
5188
|
+
type: z6.literal("inline"),
|
|
5189
|
+
runtime_context: z6.object({
|
|
5190
|
+
runtime: z6.enum(["node", "python"]),
|
|
5191
|
+
version: z6.string()
|
|
5119
5192
|
}),
|
|
5120
|
-
code:
|
|
5193
|
+
code: z6.string()
|
|
5121
5194
|
})
|
|
5122
5195
|
])
|
|
5123
5196
|
}),
|
|
5124
5197
|
GraphData,
|
|
5125
|
-
|
|
5126
|
-
type:
|
|
5127
|
-
endpoint:
|
|
5128
|
-
eval_name:
|
|
5129
|
-
parameters:
|
|
5198
|
+
z6.object({
|
|
5199
|
+
type: z6.literal("remote_eval"),
|
|
5200
|
+
endpoint: z6.string(),
|
|
5201
|
+
eval_name: z6.string(),
|
|
5202
|
+
parameters: z6.object({}).partial().passthrough()
|
|
5130
5203
|
}),
|
|
5131
|
-
|
|
5204
|
+
z6.object({ type: z6.literal("global"), name: z6.string() })
|
|
5132
5205
|
]);
|
|
5133
|
-
var Function2 =
|
|
5134
|
-
id:
|
|
5135
|
-
_xact_id:
|
|
5136
|
-
project_id:
|
|
5137
|
-
log_id:
|
|
5138
|
-
org_id:
|
|
5139
|
-
name:
|
|
5140
|
-
slug:
|
|
5141
|
-
description:
|
|
5142
|
-
created:
|
|
5206
|
+
var Function2 = z6.object({
|
|
5207
|
+
id: z6.string().uuid(),
|
|
5208
|
+
_xact_id: z6.string(),
|
|
5209
|
+
project_id: z6.string().uuid(),
|
|
5210
|
+
log_id: z6.literal("p"),
|
|
5211
|
+
org_id: z6.string().uuid(),
|
|
5212
|
+
name: z6.string(),
|
|
5213
|
+
slug: z6.string(),
|
|
5214
|
+
description: z6.union([z6.string(), z6.null()]).optional(),
|
|
5215
|
+
created: z6.union([z6.string(), z6.null()]).optional(),
|
|
5143
5216
|
prompt_data: PromptDataNullish.optional(),
|
|
5144
|
-
tags:
|
|
5145
|
-
metadata:
|
|
5217
|
+
tags: z6.union([z6.array(z6.string()), z6.null()]).optional(),
|
|
5218
|
+
metadata: z6.union([z6.object({}).partial().passthrough(), z6.null()]).optional(),
|
|
5146
5219
|
function_type: FunctionTypeEnumNullish.optional(),
|
|
5147
5220
|
function_data: FunctionData,
|
|
5148
|
-
origin:
|
|
5149
|
-
|
|
5150
|
-
object_type: AclObjectType.and(
|
|
5151
|
-
object_id:
|
|
5152
|
-
internal:
|
|
5221
|
+
origin: z6.union([
|
|
5222
|
+
z6.object({
|
|
5223
|
+
object_type: AclObjectType.and(z6.string()),
|
|
5224
|
+
object_id: z6.string().uuid(),
|
|
5225
|
+
internal: z6.union([z6.boolean(), z6.null()]).optional()
|
|
5153
5226
|
}),
|
|
5154
|
-
|
|
5227
|
+
z6.null()
|
|
5155
5228
|
]).optional(),
|
|
5156
|
-
function_schema:
|
|
5157
|
-
|
|
5158
|
-
|
|
5229
|
+
function_schema: z6.union([
|
|
5230
|
+
z6.object({ parameters: z6.unknown(), returns: z6.unknown() }).partial(),
|
|
5231
|
+
z6.null()
|
|
5159
5232
|
]).optional()
|
|
5160
5233
|
});
|
|
5161
|
-
var FunctionFormat =
|
|
5162
|
-
var PromptData =
|
|
5234
|
+
var FunctionFormat = z6.enum(["llm", "code", "global", "graph"]);
|
|
5235
|
+
var PromptData = z6.object({
|
|
5163
5236
|
prompt: PromptBlockDataNullish,
|
|
5164
5237
|
options: PromptOptionsNullish,
|
|
5165
5238
|
parser: PromptParserNullish,
|
|
5166
|
-
tool_functions:
|
|
5167
|
-
origin:
|
|
5168
|
-
|
|
5169
|
-
prompt_id:
|
|
5170
|
-
project_id:
|
|
5171
|
-
prompt_version:
|
|
5239
|
+
tool_functions: z6.union([z6.array(SavedFunctionId), z6.null()]),
|
|
5240
|
+
origin: z6.union([
|
|
5241
|
+
z6.object({
|
|
5242
|
+
prompt_id: z6.string(),
|
|
5243
|
+
project_id: z6.string(),
|
|
5244
|
+
prompt_version: z6.string()
|
|
5172
5245
|
}).partial(),
|
|
5173
|
-
|
|
5246
|
+
z6.null()
|
|
5174
5247
|
])
|
|
5175
5248
|
}).partial();
|
|
5176
|
-
var FunctionTypeEnum =
|
|
5177
|
-
var FunctionId =
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
project_name:
|
|
5181
|
-
slug:
|
|
5182
|
-
version:
|
|
5249
|
+
var FunctionTypeEnum = z6.enum(["llm", "scorer", "task", "tool"]);
|
|
5250
|
+
var FunctionId = z6.union([
|
|
5251
|
+
z6.object({ function_id: z6.string(), version: z6.string().optional() }),
|
|
5252
|
+
z6.object({
|
|
5253
|
+
project_name: z6.string(),
|
|
5254
|
+
slug: z6.string(),
|
|
5255
|
+
version: z6.string().optional()
|
|
5183
5256
|
}),
|
|
5184
|
-
|
|
5185
|
-
|
|
5186
|
-
prompt_session_id:
|
|
5187
|
-
prompt_session_function_id:
|
|
5188
|
-
version:
|
|
5257
|
+
z6.object({ global_function: z6.string() }),
|
|
5258
|
+
z6.object({
|
|
5259
|
+
prompt_session_id: z6.string(),
|
|
5260
|
+
prompt_session_function_id: z6.string(),
|
|
5261
|
+
version: z6.string().optional()
|
|
5189
5262
|
}),
|
|
5190
|
-
|
|
5191
|
-
inline_context:
|
|
5192
|
-
runtime:
|
|
5193
|
-
version:
|
|
5263
|
+
z6.object({
|
|
5264
|
+
inline_context: z6.object({
|
|
5265
|
+
runtime: z6.enum(["node", "python"]),
|
|
5266
|
+
version: z6.string()
|
|
5194
5267
|
}),
|
|
5195
|
-
code:
|
|
5196
|
-
name:
|
|
5268
|
+
code: z6.string(),
|
|
5269
|
+
name: z6.union([z6.string(), z6.null()]).optional()
|
|
5197
5270
|
}),
|
|
5198
|
-
|
|
5271
|
+
z6.object({
|
|
5199
5272
|
inline_prompt: PromptData.optional(),
|
|
5200
|
-
inline_function:
|
|
5273
|
+
inline_function: z6.object({}).partial().passthrough(),
|
|
5201
5274
|
function_type: FunctionTypeEnum.optional(),
|
|
5202
|
-
name:
|
|
5275
|
+
name: z6.union([z6.string(), z6.null()]).optional()
|
|
5203
5276
|
}),
|
|
5204
|
-
|
|
5277
|
+
z6.object({
|
|
5205
5278
|
inline_prompt: PromptData,
|
|
5206
5279
|
function_type: FunctionTypeEnum.optional(),
|
|
5207
|
-
name:
|
|
5280
|
+
name: z6.union([z6.string(), z6.null()]).optional()
|
|
5208
5281
|
})
|
|
5209
5282
|
]);
|
|
5210
|
-
var FunctionObjectType =
|
|
5283
|
+
var FunctionObjectType = z6.enum([
|
|
5211
5284
|
"prompt",
|
|
5212
5285
|
"tool",
|
|
5213
5286
|
"scorer",
|
|
5214
5287
|
"task",
|
|
5215
5288
|
"agent"
|
|
5216
5289
|
]);
|
|
5217
|
-
var FunctionOutputType =
|
|
5218
|
-
var GitMetadataSettings =
|
|
5219
|
-
collect:
|
|
5220
|
-
fields:
|
|
5221
|
-
|
|
5290
|
+
var FunctionOutputType = z6.enum(["completion", "score", "any"]);
|
|
5291
|
+
var GitMetadataSettings = z6.object({
|
|
5292
|
+
collect: z6.enum(["all", "none", "some"]),
|
|
5293
|
+
fields: z6.array(
|
|
5294
|
+
z6.enum([
|
|
5222
5295
|
"commit",
|
|
5223
5296
|
"branch",
|
|
5224
5297
|
"tag",
|
|
@@ -5231,49 +5304,49 @@ var GitMetadataSettings = z5.object({
|
|
|
5231
5304
|
])
|
|
5232
5305
|
).optional()
|
|
5233
5306
|
});
|
|
5234
|
-
var Group =
|
|
5235
|
-
id:
|
|
5236
|
-
org_id:
|
|
5237
|
-
user_id:
|
|
5238
|
-
created:
|
|
5239
|
-
name:
|
|
5240
|
-
description:
|
|
5241
|
-
deleted_at:
|
|
5242
|
-
member_users:
|
|
5243
|
-
member_groups:
|
|
5244
|
-
});
|
|
5245
|
-
var IfExists =
|
|
5246
|
-
var InvokeParent =
|
|
5247
|
-
|
|
5248
|
-
object_type:
|
|
5249
|
-
object_id:
|
|
5250
|
-
row_ids:
|
|
5251
|
-
|
|
5252
|
-
id:
|
|
5253
|
-
span_id:
|
|
5254
|
-
root_span_id:
|
|
5307
|
+
var Group = z6.object({
|
|
5308
|
+
id: z6.string().uuid(),
|
|
5309
|
+
org_id: z6.string().uuid(),
|
|
5310
|
+
user_id: z6.union([z6.string(), z6.null()]).optional(),
|
|
5311
|
+
created: z6.union([z6.string(), z6.null()]).optional(),
|
|
5312
|
+
name: z6.string(),
|
|
5313
|
+
description: z6.union([z6.string(), z6.null()]).optional(),
|
|
5314
|
+
deleted_at: z6.union([z6.string(), z6.null()]).optional(),
|
|
5315
|
+
member_users: z6.union([z6.array(z6.string().uuid()), z6.null()]).optional(),
|
|
5316
|
+
member_groups: z6.union([z6.array(z6.string().uuid()), z6.null()]).optional()
|
|
5317
|
+
});
|
|
5318
|
+
var IfExists = z6.enum(["error", "ignore", "replace"]);
|
|
5319
|
+
var InvokeParent = z6.union([
|
|
5320
|
+
z6.object({
|
|
5321
|
+
object_type: z6.enum(["project_logs", "experiment", "playground_logs"]),
|
|
5322
|
+
object_id: z6.string(),
|
|
5323
|
+
row_ids: z6.union([
|
|
5324
|
+
z6.object({
|
|
5325
|
+
id: z6.string(),
|
|
5326
|
+
span_id: z6.string(),
|
|
5327
|
+
root_span_id: z6.string()
|
|
5255
5328
|
}),
|
|
5256
|
-
|
|
5329
|
+
z6.null()
|
|
5257
5330
|
]).optional(),
|
|
5258
|
-
propagated_event:
|
|
5331
|
+
propagated_event: z6.union([z6.object({}).partial().passthrough(), z6.null()]).optional()
|
|
5259
5332
|
}),
|
|
5260
|
-
|
|
5333
|
+
z6.string()
|
|
5261
5334
|
]);
|
|
5262
|
-
var StreamingMode =
|
|
5335
|
+
var StreamingMode = z6.union([z6.enum(["auto", "parallel"]), z6.null()]);
|
|
5263
5336
|
var InvokeFunction = FunctionId.and(
|
|
5264
|
-
|
|
5265
|
-
input:
|
|
5266
|
-
expected:
|
|
5267
|
-
metadata:
|
|
5268
|
-
tags:
|
|
5269
|
-
messages:
|
|
5337
|
+
z6.object({
|
|
5338
|
+
input: z6.unknown(),
|
|
5339
|
+
expected: z6.unknown(),
|
|
5340
|
+
metadata: z6.union([z6.object({}).partial().passthrough(), z6.null()]),
|
|
5341
|
+
tags: z6.union([z6.array(z6.string()), z6.null()]),
|
|
5342
|
+
messages: z6.array(ChatCompletionMessageParam),
|
|
5270
5343
|
parent: InvokeParent,
|
|
5271
|
-
stream:
|
|
5344
|
+
stream: z6.union([z6.boolean(), z6.null()]),
|
|
5272
5345
|
mode: StreamingMode,
|
|
5273
|
-
strict:
|
|
5346
|
+
strict: z6.union([z6.boolean(), z6.null()])
|
|
5274
5347
|
}).partial()
|
|
5275
5348
|
);
|
|
5276
|
-
var MessageRole =
|
|
5349
|
+
var MessageRole = z6.enum([
|
|
5277
5350
|
"system",
|
|
5278
5351
|
"user",
|
|
5279
5352
|
"assistant",
|
|
@@ -5282,8 +5355,8 @@ var MessageRole = z5.enum([
|
|
|
5282
5355
|
"model",
|
|
5283
5356
|
"developer"
|
|
5284
5357
|
]);
|
|
5285
|
-
var ObjectReference =
|
|
5286
|
-
object_type:
|
|
5358
|
+
var ObjectReference = z6.object({
|
|
5359
|
+
object_type: z6.enum([
|
|
5287
5360
|
"project_logs",
|
|
5288
5361
|
"experiment",
|
|
5289
5362
|
"dataset",
|
|
@@ -5291,146 +5364,146 @@ var ObjectReference = z5.object({
|
|
|
5291
5364
|
"function",
|
|
5292
5365
|
"prompt_session"
|
|
5293
5366
|
]),
|
|
5294
|
-
object_id:
|
|
5295
|
-
id:
|
|
5296
|
-
_xact_id:
|
|
5297
|
-
created:
|
|
5298
|
-
});
|
|
5299
|
-
var OnlineScoreConfig =
|
|
5300
|
-
|
|
5301
|
-
sampling_rate:
|
|
5302
|
-
scorers:
|
|
5303
|
-
btql_filter:
|
|
5304
|
-
apply_to_root_span:
|
|
5305
|
-
apply_to_span_names:
|
|
5306
|
-
skip_logging:
|
|
5367
|
+
object_id: z6.string().uuid(),
|
|
5368
|
+
id: z6.string(),
|
|
5369
|
+
_xact_id: z6.union([z6.string(), z6.null()]).optional(),
|
|
5370
|
+
created: z6.union([z6.string(), z6.null()]).optional()
|
|
5371
|
+
});
|
|
5372
|
+
var OnlineScoreConfig = z6.union([
|
|
5373
|
+
z6.object({
|
|
5374
|
+
sampling_rate: z6.number().gte(0).lte(1),
|
|
5375
|
+
scorers: z6.array(SavedFunctionId),
|
|
5376
|
+
btql_filter: z6.union([z6.string(), z6.null()]).optional(),
|
|
5377
|
+
apply_to_root_span: z6.union([z6.boolean(), z6.null()]).optional(),
|
|
5378
|
+
apply_to_span_names: z6.union([z6.array(z6.string()), z6.null()]).optional(),
|
|
5379
|
+
skip_logging: z6.union([z6.boolean(), z6.null()]).optional()
|
|
5307
5380
|
}),
|
|
5308
|
-
|
|
5381
|
+
z6.null()
|
|
5309
5382
|
]);
|
|
5310
|
-
var Organization =
|
|
5311
|
-
id:
|
|
5312
|
-
name:
|
|
5313
|
-
api_url:
|
|
5314
|
-
is_universal_api:
|
|
5315
|
-
proxy_url:
|
|
5316
|
-
realtime_url:
|
|
5317
|
-
created:
|
|
5318
|
-
});
|
|
5319
|
-
var ProjectSettings =
|
|
5320
|
-
|
|
5321
|
-
comparison_key:
|
|
5322
|
-
baseline_experiment_id:
|
|
5323
|
-
spanFieldOrder:
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
object_type:
|
|
5327
|
-
column_id:
|
|
5328
|
-
position:
|
|
5329
|
-
layout:
|
|
5383
|
+
var Organization = z6.object({
|
|
5384
|
+
id: z6.string().uuid(),
|
|
5385
|
+
name: z6.string(),
|
|
5386
|
+
api_url: z6.union([z6.string(), z6.null()]).optional(),
|
|
5387
|
+
is_universal_api: z6.union([z6.boolean(), z6.null()]).optional(),
|
|
5388
|
+
proxy_url: z6.union([z6.string(), z6.null()]).optional(),
|
|
5389
|
+
realtime_url: z6.union([z6.string(), z6.null()]).optional(),
|
|
5390
|
+
created: z6.union([z6.string(), z6.null()]).optional()
|
|
5391
|
+
});
|
|
5392
|
+
var ProjectSettings = z6.union([
|
|
5393
|
+
z6.object({
|
|
5394
|
+
comparison_key: z6.union([z6.string(), z6.null()]),
|
|
5395
|
+
baseline_experiment_id: z6.union([z6.string(), z6.null()]),
|
|
5396
|
+
spanFieldOrder: z6.union([
|
|
5397
|
+
z6.array(
|
|
5398
|
+
z6.object({
|
|
5399
|
+
object_type: z6.string(),
|
|
5400
|
+
column_id: z6.string(),
|
|
5401
|
+
position: z6.string(),
|
|
5402
|
+
layout: z6.union([z6.literal("full"), z6.literal("two_column"), z6.null()]).optional()
|
|
5330
5403
|
})
|
|
5331
5404
|
),
|
|
5332
|
-
|
|
5405
|
+
z6.null()
|
|
5333
5406
|
]),
|
|
5334
|
-
remote_eval_sources:
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
url:
|
|
5338
|
-
name:
|
|
5339
|
-
description:
|
|
5407
|
+
remote_eval_sources: z6.union([
|
|
5408
|
+
z6.array(
|
|
5409
|
+
z6.object({
|
|
5410
|
+
url: z6.string(),
|
|
5411
|
+
name: z6.string(),
|
|
5412
|
+
description: z6.union([z6.string(), z6.null()]).optional()
|
|
5340
5413
|
})
|
|
5341
5414
|
),
|
|
5342
|
-
|
|
5415
|
+
z6.null()
|
|
5343
5416
|
])
|
|
5344
5417
|
}).partial(),
|
|
5345
|
-
|
|
5418
|
+
z6.null()
|
|
5346
5419
|
]);
|
|
5347
|
-
var Project =
|
|
5348
|
-
id:
|
|
5349
|
-
org_id:
|
|
5350
|
-
name:
|
|
5351
|
-
created:
|
|
5352
|
-
deleted_at:
|
|
5353
|
-
user_id:
|
|
5420
|
+
var Project = z6.object({
|
|
5421
|
+
id: z6.string().uuid(),
|
|
5422
|
+
org_id: z6.string().uuid(),
|
|
5423
|
+
name: z6.string(),
|
|
5424
|
+
created: z6.union([z6.string(), z6.null()]).optional(),
|
|
5425
|
+
deleted_at: z6.union([z6.string(), z6.null()]).optional(),
|
|
5426
|
+
user_id: z6.union([z6.string(), z6.null()]).optional(),
|
|
5354
5427
|
settings: ProjectSettings.optional()
|
|
5355
5428
|
});
|
|
5356
|
-
var RetentionObjectType =
|
|
5429
|
+
var RetentionObjectType = z6.enum([
|
|
5357
5430
|
"project_logs",
|
|
5358
5431
|
"experiment",
|
|
5359
5432
|
"dataset"
|
|
5360
5433
|
]);
|
|
5361
|
-
var ProjectAutomation =
|
|
5362
|
-
id:
|
|
5363
|
-
project_id:
|
|
5364
|
-
user_id:
|
|
5365
|
-
created:
|
|
5366
|
-
name:
|
|
5367
|
-
description:
|
|
5368
|
-
config:
|
|
5369
|
-
|
|
5370
|
-
event_type:
|
|
5371
|
-
btql_filter:
|
|
5372
|
-
interval_seconds:
|
|
5373
|
-
action:
|
|
5434
|
+
var ProjectAutomation = z6.object({
|
|
5435
|
+
id: z6.string().uuid(),
|
|
5436
|
+
project_id: z6.string().uuid(),
|
|
5437
|
+
user_id: z6.union([z6.string(), z6.null()]).optional(),
|
|
5438
|
+
created: z6.union([z6.string(), z6.null()]).optional(),
|
|
5439
|
+
name: z6.string(),
|
|
5440
|
+
description: z6.union([z6.string(), z6.null()]).optional(),
|
|
5441
|
+
config: z6.union([
|
|
5442
|
+
z6.object({
|
|
5443
|
+
event_type: z6.literal("logs"),
|
|
5444
|
+
btql_filter: z6.string(),
|
|
5445
|
+
interval_seconds: z6.number().gte(1).lte(2592e3),
|
|
5446
|
+
action: z6.object({ type: z6.literal("webhook"), url: z6.string() })
|
|
5374
5447
|
}),
|
|
5375
|
-
|
|
5376
|
-
event_type:
|
|
5377
|
-
export_definition:
|
|
5378
|
-
|
|
5379
|
-
|
|
5380
|
-
|
|
5448
|
+
z6.object({
|
|
5449
|
+
event_type: z6.literal("btql_export"),
|
|
5450
|
+
export_definition: z6.union([
|
|
5451
|
+
z6.object({ type: z6.literal("log_traces") }),
|
|
5452
|
+
z6.object({ type: z6.literal("log_spans") }),
|
|
5453
|
+
z6.object({ type: z6.literal("btql_query"), btql_query: z6.string() })
|
|
5381
5454
|
]),
|
|
5382
|
-
export_path:
|
|
5383
|
-
format:
|
|
5384
|
-
interval_seconds:
|
|
5385
|
-
credentials:
|
|
5386
|
-
type:
|
|
5387
|
-
role_arn:
|
|
5388
|
-
external_id:
|
|
5455
|
+
export_path: z6.string(),
|
|
5456
|
+
format: z6.enum(["jsonl", "parquet"]),
|
|
5457
|
+
interval_seconds: z6.number().gte(1).lte(2592e3),
|
|
5458
|
+
credentials: z6.object({
|
|
5459
|
+
type: z6.literal("aws_iam"),
|
|
5460
|
+
role_arn: z6.string(),
|
|
5461
|
+
external_id: z6.string()
|
|
5389
5462
|
}),
|
|
5390
|
-
batch_size:
|
|
5463
|
+
batch_size: z6.union([z6.number(), z6.null()]).optional()
|
|
5391
5464
|
}),
|
|
5392
|
-
|
|
5393
|
-
event_type:
|
|
5465
|
+
z6.object({
|
|
5466
|
+
event_type: z6.literal("retention"),
|
|
5394
5467
|
object_type: RetentionObjectType,
|
|
5395
|
-
retention_days:
|
|
5468
|
+
retention_days: z6.number().gte(0)
|
|
5396
5469
|
})
|
|
5397
5470
|
])
|
|
5398
5471
|
});
|
|
5399
|
-
var ProjectLogsEvent =
|
|
5400
|
-
id:
|
|
5401
|
-
_xact_id:
|
|
5402
|
-
_pagination_key:
|
|
5403
|
-
created:
|
|
5404
|
-
org_id:
|
|
5405
|
-
project_id:
|
|
5406
|
-
log_id:
|
|
5407
|
-
input:
|
|
5408
|
-
output:
|
|
5409
|
-
expected:
|
|
5410
|
-
error:
|
|
5411
|
-
scores:
|
|
5412
|
-
metadata:
|
|
5413
|
-
|
|
5414
|
-
|
|
5472
|
+
var ProjectLogsEvent = z6.object({
|
|
5473
|
+
id: z6.string(),
|
|
5474
|
+
_xact_id: z6.string(),
|
|
5475
|
+
_pagination_key: z6.union([z6.string(), z6.null()]).optional(),
|
|
5476
|
+
created: z6.string().datetime({ offset: true }),
|
|
5477
|
+
org_id: z6.string().uuid(),
|
|
5478
|
+
project_id: z6.string().uuid(),
|
|
5479
|
+
log_id: z6.literal("g"),
|
|
5480
|
+
input: z6.unknown().optional(),
|
|
5481
|
+
output: z6.unknown().optional(),
|
|
5482
|
+
expected: z6.unknown().optional(),
|
|
5483
|
+
error: z6.unknown().optional(),
|
|
5484
|
+
scores: z6.union([z6.record(z6.union([z6.number(), z6.null()])), z6.null()]).optional(),
|
|
5485
|
+
metadata: z6.union([
|
|
5486
|
+
z6.object({ model: z6.union([z6.string(), z6.null()]) }).partial().passthrough(),
|
|
5487
|
+
z6.null()
|
|
5415
5488
|
]).optional(),
|
|
5416
|
-
tags:
|
|
5417
|
-
metrics:
|
|
5418
|
-
context:
|
|
5419
|
-
|
|
5420
|
-
caller_functionname:
|
|
5421
|
-
caller_filename:
|
|
5422
|
-
caller_lineno:
|
|
5489
|
+
tags: z6.union([z6.array(z6.string()), z6.null()]).optional(),
|
|
5490
|
+
metrics: z6.union([z6.record(z6.number()), z6.null()]).optional(),
|
|
5491
|
+
context: z6.union([
|
|
5492
|
+
z6.object({
|
|
5493
|
+
caller_functionname: z6.union([z6.string(), z6.null()]),
|
|
5494
|
+
caller_filename: z6.union([z6.string(), z6.null()]),
|
|
5495
|
+
caller_lineno: z6.union([z6.number(), z6.null()])
|
|
5423
5496
|
}).partial().passthrough(),
|
|
5424
|
-
|
|
5497
|
+
z6.null()
|
|
5425
5498
|
]).optional(),
|
|
5426
|
-
span_id:
|
|
5427
|
-
span_parents:
|
|
5428
|
-
root_span_id:
|
|
5429
|
-
is_root:
|
|
5499
|
+
span_id: z6.string(),
|
|
5500
|
+
span_parents: z6.union([z6.array(z6.string()), z6.null()]).optional(),
|
|
5501
|
+
root_span_id: z6.string(),
|
|
5502
|
+
is_root: z6.union([z6.boolean(), z6.null()]).optional(),
|
|
5430
5503
|
span_attributes: SpanAttributes.optional(),
|
|
5431
5504
|
origin: ObjectReferenceNullish.optional()
|
|
5432
5505
|
});
|
|
5433
|
-
var ProjectScoreType =
|
|
5506
|
+
var ProjectScoreType = z6.enum([
|
|
5434
5507
|
"slider",
|
|
5435
5508
|
"categorical",
|
|
5436
5509
|
"weighted",
|
|
@@ -5439,172 +5512,172 @@ var ProjectScoreType = z5.enum([
|
|
|
5439
5512
|
"online",
|
|
5440
5513
|
"free-form"
|
|
5441
5514
|
]);
|
|
5442
|
-
var ProjectScoreCategory =
|
|
5443
|
-
name:
|
|
5444
|
-
value:
|
|
5445
|
-
});
|
|
5446
|
-
var ProjectScoreCategories =
|
|
5447
|
-
|
|
5448
|
-
|
|
5449
|
-
|
|
5450
|
-
|
|
5515
|
+
var ProjectScoreCategory = z6.object({
|
|
5516
|
+
name: z6.string(),
|
|
5517
|
+
value: z6.number()
|
|
5518
|
+
});
|
|
5519
|
+
var ProjectScoreCategories = z6.union([
|
|
5520
|
+
z6.array(ProjectScoreCategory),
|
|
5521
|
+
z6.record(z6.number()),
|
|
5522
|
+
z6.array(z6.string()),
|
|
5523
|
+
z6.null()
|
|
5451
5524
|
]);
|
|
5452
|
-
var ProjectScoreConfig =
|
|
5453
|
-
|
|
5454
|
-
multi_select:
|
|
5455
|
-
destination:
|
|
5525
|
+
var ProjectScoreConfig = z6.union([
|
|
5526
|
+
z6.object({
|
|
5527
|
+
multi_select: z6.union([z6.boolean(), z6.null()]),
|
|
5528
|
+
destination: z6.union([z6.string(), z6.null()]),
|
|
5456
5529
|
online: OnlineScoreConfig
|
|
5457
5530
|
}).partial(),
|
|
5458
|
-
|
|
5531
|
+
z6.null()
|
|
5459
5532
|
]);
|
|
5460
|
-
var ProjectScore =
|
|
5461
|
-
id:
|
|
5462
|
-
project_id:
|
|
5463
|
-
user_id:
|
|
5464
|
-
created:
|
|
5465
|
-
name:
|
|
5466
|
-
description:
|
|
5533
|
+
var ProjectScore = z6.object({
|
|
5534
|
+
id: z6.string().uuid(),
|
|
5535
|
+
project_id: z6.string().uuid(),
|
|
5536
|
+
user_id: z6.string().uuid(),
|
|
5537
|
+
created: z6.union([z6.string(), z6.null()]).optional(),
|
|
5538
|
+
name: z6.string(),
|
|
5539
|
+
description: z6.union([z6.string(), z6.null()]).optional(),
|
|
5467
5540
|
score_type: ProjectScoreType,
|
|
5468
5541
|
categories: ProjectScoreCategories.optional(),
|
|
5469
5542
|
config: ProjectScoreConfig.optional(),
|
|
5470
|
-
position:
|
|
5471
|
-
});
|
|
5472
|
-
var ProjectTag =
|
|
5473
|
-
id:
|
|
5474
|
-
project_id:
|
|
5475
|
-
user_id:
|
|
5476
|
-
created:
|
|
5477
|
-
name:
|
|
5478
|
-
description:
|
|
5479
|
-
color:
|
|
5480
|
-
position:
|
|
5481
|
-
});
|
|
5482
|
-
var Prompt =
|
|
5483
|
-
id:
|
|
5484
|
-
_xact_id:
|
|
5485
|
-
project_id:
|
|
5486
|
-
log_id:
|
|
5487
|
-
org_id:
|
|
5488
|
-
name:
|
|
5489
|
-
slug:
|
|
5490
|
-
description:
|
|
5491
|
-
created:
|
|
5543
|
+
position: z6.union([z6.string(), z6.null()]).optional()
|
|
5544
|
+
});
|
|
5545
|
+
var ProjectTag = z6.object({
|
|
5546
|
+
id: z6.string().uuid(),
|
|
5547
|
+
project_id: z6.string().uuid(),
|
|
5548
|
+
user_id: z6.string().uuid(),
|
|
5549
|
+
created: z6.union([z6.string(), z6.null()]).optional(),
|
|
5550
|
+
name: z6.string(),
|
|
5551
|
+
description: z6.union([z6.string(), z6.null()]).optional(),
|
|
5552
|
+
color: z6.union([z6.string(), z6.null()]).optional(),
|
|
5553
|
+
position: z6.union([z6.string(), z6.null()]).optional()
|
|
5554
|
+
});
|
|
5555
|
+
var Prompt = z6.object({
|
|
5556
|
+
id: z6.string().uuid(),
|
|
5557
|
+
_xact_id: z6.string(),
|
|
5558
|
+
project_id: z6.string().uuid(),
|
|
5559
|
+
log_id: z6.literal("p"),
|
|
5560
|
+
org_id: z6.string().uuid(),
|
|
5561
|
+
name: z6.string(),
|
|
5562
|
+
slug: z6.string(),
|
|
5563
|
+
description: z6.union([z6.string(), z6.null()]).optional(),
|
|
5564
|
+
created: z6.union([z6.string(), z6.null()]).optional(),
|
|
5492
5565
|
prompt_data: PromptDataNullish.optional(),
|
|
5493
|
-
tags:
|
|
5494
|
-
metadata:
|
|
5566
|
+
tags: z6.union([z6.array(z6.string()), z6.null()]).optional(),
|
|
5567
|
+
metadata: z6.union([z6.object({}).partial().passthrough(), z6.null()]).optional(),
|
|
5495
5568
|
function_type: FunctionTypeEnumNullish.optional()
|
|
5496
5569
|
});
|
|
5497
|
-
var PromptOptions =
|
|
5498
|
-
var PromptSessionEvent =
|
|
5499
|
-
id:
|
|
5500
|
-
_xact_id:
|
|
5501
|
-
created:
|
|
5502
|
-
_pagination_key:
|
|
5503
|
-
project_id:
|
|
5504
|
-
prompt_session_id:
|
|
5505
|
-
prompt_session_data:
|
|
5506
|
-
prompt_data:
|
|
5507
|
-
function_data:
|
|
5570
|
+
var PromptOptions = z6.object({ model: z6.string(), params: ModelParams, position: z6.string() }).partial();
|
|
5571
|
+
var PromptSessionEvent = z6.object({
|
|
5572
|
+
id: z6.string(),
|
|
5573
|
+
_xact_id: z6.string(),
|
|
5574
|
+
created: z6.string().datetime({ offset: true }),
|
|
5575
|
+
_pagination_key: z6.union([z6.string(), z6.null()]).optional(),
|
|
5576
|
+
project_id: z6.string().uuid(),
|
|
5577
|
+
prompt_session_id: z6.string().uuid(),
|
|
5578
|
+
prompt_session_data: z6.unknown().optional(),
|
|
5579
|
+
prompt_data: z6.unknown().optional(),
|
|
5580
|
+
function_data: z6.unknown().optional(),
|
|
5508
5581
|
function_type: FunctionTypeEnumNullish.optional(),
|
|
5509
|
-
object_data:
|
|
5510
|
-
completion:
|
|
5511
|
-
tags:
|
|
5512
|
-
});
|
|
5513
|
-
var ResponseFormat =
|
|
5514
|
-
|
|
5515
|
-
|
|
5516
|
-
type:
|
|
5582
|
+
object_data: z6.unknown().optional(),
|
|
5583
|
+
completion: z6.unknown().optional(),
|
|
5584
|
+
tags: z6.union([z6.array(z6.string()), z6.null()]).optional()
|
|
5585
|
+
});
|
|
5586
|
+
var ResponseFormat = z6.union([
|
|
5587
|
+
z6.object({ type: z6.literal("json_object") }),
|
|
5588
|
+
z6.object({
|
|
5589
|
+
type: z6.literal("json_schema"),
|
|
5517
5590
|
json_schema: ResponseFormatJsonSchema
|
|
5518
5591
|
}),
|
|
5519
|
-
|
|
5592
|
+
z6.object({ type: z6.literal("text") })
|
|
5520
5593
|
]);
|
|
5521
|
-
var Role =
|
|
5522
|
-
id:
|
|
5523
|
-
org_id:
|
|
5524
|
-
user_id:
|
|
5525
|
-
created:
|
|
5526
|
-
name:
|
|
5527
|
-
description:
|
|
5528
|
-
deleted_at:
|
|
5529
|
-
member_permissions:
|
|
5530
|
-
|
|
5531
|
-
|
|
5594
|
+
var Role = z6.object({
|
|
5595
|
+
id: z6.string().uuid(),
|
|
5596
|
+
org_id: z6.union([z6.string(), z6.null()]).optional(),
|
|
5597
|
+
user_id: z6.union([z6.string(), z6.null()]).optional(),
|
|
5598
|
+
created: z6.union([z6.string(), z6.null()]).optional(),
|
|
5599
|
+
name: z6.string(),
|
|
5600
|
+
description: z6.union([z6.string(), z6.null()]).optional(),
|
|
5601
|
+
deleted_at: z6.union([z6.string(), z6.null()]).optional(),
|
|
5602
|
+
member_permissions: z6.union([
|
|
5603
|
+
z6.array(
|
|
5604
|
+
z6.object({
|
|
5532
5605
|
permission: Permission,
|
|
5533
5606
|
restrict_object_type: AclObjectType.optional()
|
|
5534
5607
|
})
|
|
5535
5608
|
),
|
|
5536
|
-
|
|
5609
|
+
z6.null()
|
|
5537
5610
|
]).optional(),
|
|
5538
|
-
member_roles:
|
|
5539
|
-
});
|
|
5540
|
-
var RunEval =
|
|
5541
|
-
project_id:
|
|
5542
|
-
data:
|
|
5543
|
-
|
|
5544
|
-
dataset_id:
|
|
5545
|
-
_internal_btql:
|
|
5611
|
+
member_roles: z6.union([z6.array(z6.string().uuid()), z6.null()]).optional()
|
|
5612
|
+
});
|
|
5613
|
+
var RunEval = z6.object({
|
|
5614
|
+
project_id: z6.string(),
|
|
5615
|
+
data: z6.union([
|
|
5616
|
+
z6.object({
|
|
5617
|
+
dataset_id: z6.string(),
|
|
5618
|
+
_internal_btql: z6.union([z6.object({}).partial().passthrough(), z6.null()]).optional()
|
|
5546
5619
|
}),
|
|
5547
|
-
|
|
5548
|
-
project_name:
|
|
5549
|
-
dataset_name:
|
|
5550
|
-
_internal_btql:
|
|
5620
|
+
z6.object({
|
|
5621
|
+
project_name: z6.string(),
|
|
5622
|
+
dataset_name: z6.string(),
|
|
5623
|
+
_internal_btql: z6.union([z6.object({}).partial().passthrough(), z6.null()]).optional()
|
|
5551
5624
|
}),
|
|
5552
|
-
|
|
5625
|
+
z6.object({ data: z6.array(z6.unknown()) })
|
|
5553
5626
|
]),
|
|
5554
|
-
task: FunctionId.and(
|
|
5555
|
-
scores:
|
|
5556
|
-
experiment_name:
|
|
5557
|
-
metadata:
|
|
5558
|
-
parent: InvokeParent.and(
|
|
5559
|
-
stream:
|
|
5560
|
-
trial_count:
|
|
5561
|
-
is_public:
|
|
5562
|
-
timeout:
|
|
5563
|
-
max_concurrency:
|
|
5564
|
-
base_experiment_name:
|
|
5565
|
-
base_experiment_id:
|
|
5627
|
+
task: FunctionId.and(z6.unknown()),
|
|
5628
|
+
scores: z6.array(FunctionId),
|
|
5629
|
+
experiment_name: z6.string().optional(),
|
|
5630
|
+
metadata: z6.object({}).partial().passthrough().optional(),
|
|
5631
|
+
parent: InvokeParent.and(z6.unknown()).optional(),
|
|
5632
|
+
stream: z6.boolean().optional(),
|
|
5633
|
+
trial_count: z6.union([z6.number(), z6.null()]).optional(),
|
|
5634
|
+
is_public: z6.union([z6.boolean(), z6.null()]).optional(),
|
|
5635
|
+
timeout: z6.union([z6.number(), z6.null()]).optional(),
|
|
5636
|
+
max_concurrency: z6.union([z6.number(), z6.null()]).optional().default(10),
|
|
5637
|
+
base_experiment_name: z6.union([z6.string(), z6.null()]).optional(),
|
|
5638
|
+
base_experiment_id: z6.union([z6.string(), z6.null()]).optional(),
|
|
5566
5639
|
git_metadata_settings: GitMetadataSettings.and(
|
|
5567
|
-
|
|
5640
|
+
z6.union([z6.object({}).partial(), z6.null()])
|
|
5568
5641
|
).optional(),
|
|
5569
|
-
repo_info: RepoInfo.and(
|
|
5570
|
-
strict:
|
|
5571
|
-
stop_token:
|
|
5572
|
-
extra_messages:
|
|
5573
|
-
tags:
|
|
5574
|
-
});
|
|
5575
|
-
var ServiceToken =
|
|
5576
|
-
id:
|
|
5577
|
-
created:
|
|
5578
|
-
name:
|
|
5579
|
-
preview_name:
|
|
5580
|
-
service_account_id:
|
|
5581
|
-
service_account_email:
|
|
5582
|
-
service_account_name:
|
|
5583
|
-
org_id:
|
|
5584
|
-
});
|
|
5585
|
-
var SpanIFrame =
|
|
5586
|
-
id:
|
|
5587
|
-
project_id:
|
|
5588
|
-
user_id:
|
|
5589
|
-
created:
|
|
5590
|
-
deleted_at:
|
|
5591
|
-
name:
|
|
5592
|
-
description:
|
|
5593
|
-
url:
|
|
5594
|
-
post_message:
|
|
5595
|
-
});
|
|
5596
|
-
var SSEConsoleEventData =
|
|
5597
|
-
stream:
|
|
5598
|
-
message:
|
|
5599
|
-
});
|
|
5600
|
-
var SSEProgressEventData =
|
|
5601
|
-
id:
|
|
5642
|
+
repo_info: RepoInfo.and(z6.unknown()).optional(),
|
|
5643
|
+
strict: z6.union([z6.boolean(), z6.null()]).optional(),
|
|
5644
|
+
stop_token: z6.union([z6.string(), z6.null()]).optional(),
|
|
5645
|
+
extra_messages: z6.string().optional(),
|
|
5646
|
+
tags: z6.array(z6.string()).optional()
|
|
5647
|
+
});
|
|
5648
|
+
var ServiceToken = z6.object({
|
|
5649
|
+
id: z6.string().uuid(),
|
|
5650
|
+
created: z6.union([z6.string(), z6.null()]).optional(),
|
|
5651
|
+
name: z6.string(),
|
|
5652
|
+
preview_name: z6.string(),
|
|
5653
|
+
service_account_id: z6.union([z6.string(), z6.null()]).optional(),
|
|
5654
|
+
service_account_email: z6.union([z6.string(), z6.null()]).optional(),
|
|
5655
|
+
service_account_name: z6.union([z6.string(), z6.null()]).optional(),
|
|
5656
|
+
org_id: z6.union([z6.string(), z6.null()]).optional()
|
|
5657
|
+
});
|
|
5658
|
+
var SpanIFrame = z6.object({
|
|
5659
|
+
id: z6.string().uuid(),
|
|
5660
|
+
project_id: z6.string().uuid(),
|
|
5661
|
+
user_id: z6.union([z6.string(), z6.null()]).optional(),
|
|
5662
|
+
created: z6.union([z6.string(), z6.null()]).optional(),
|
|
5663
|
+
deleted_at: z6.union([z6.string(), z6.null()]).optional(),
|
|
5664
|
+
name: z6.string(),
|
|
5665
|
+
description: z6.union([z6.string(), z6.null()]).optional(),
|
|
5666
|
+
url: z6.string(),
|
|
5667
|
+
post_message: z6.union([z6.boolean(), z6.null()]).optional()
|
|
5668
|
+
});
|
|
5669
|
+
var SSEConsoleEventData = z6.object({
|
|
5670
|
+
stream: z6.enum(["stderr", "stdout"]),
|
|
5671
|
+
message: z6.string()
|
|
5672
|
+
});
|
|
5673
|
+
var SSEProgressEventData = z6.object({
|
|
5674
|
+
id: z6.string(),
|
|
5602
5675
|
object_type: FunctionObjectType,
|
|
5603
|
-
origin: ObjectReferenceNullish.and(
|
|
5676
|
+
origin: ObjectReferenceNullish.and(z6.unknown()).optional(),
|
|
5604
5677
|
format: FunctionFormat,
|
|
5605
5678
|
output_type: FunctionOutputType,
|
|
5606
|
-
name:
|
|
5607
|
-
event:
|
|
5679
|
+
name: z6.string(),
|
|
5680
|
+
event: z6.enum([
|
|
5608
5681
|
"reasoning_delta",
|
|
5609
5682
|
"text_delta",
|
|
5610
5683
|
"json_delta",
|
|
@@ -5614,110 +5687,110 @@ var SSEProgressEventData = z5.object({
|
|
|
5614
5687
|
"done",
|
|
5615
5688
|
"progress"
|
|
5616
5689
|
]),
|
|
5617
|
-
data:
|
|
5618
|
-
});
|
|
5619
|
-
var ToolFunctionDefinition =
|
|
5620
|
-
type:
|
|
5621
|
-
function:
|
|
5622
|
-
name:
|
|
5623
|
-
description:
|
|
5624
|
-
parameters:
|
|
5625
|
-
strict:
|
|
5690
|
+
data: z6.string()
|
|
5691
|
+
});
|
|
5692
|
+
var ToolFunctionDefinition = z6.object({
|
|
5693
|
+
type: z6.literal("function"),
|
|
5694
|
+
function: z6.object({
|
|
5695
|
+
name: z6.string(),
|
|
5696
|
+
description: z6.string().optional(),
|
|
5697
|
+
parameters: z6.object({}).partial().passthrough().optional(),
|
|
5698
|
+
strict: z6.union([z6.boolean(), z6.null()]).optional()
|
|
5626
5699
|
})
|
|
5627
5700
|
});
|
|
5628
|
-
var User =
|
|
5629
|
-
id:
|
|
5630
|
-
given_name:
|
|
5631
|
-
family_name:
|
|
5632
|
-
email:
|
|
5633
|
-
avatar_url:
|
|
5634
|
-
created:
|
|
5635
|
-
});
|
|
5636
|
-
var ViewDataSearch =
|
|
5637
|
-
|
|
5638
|
-
filter:
|
|
5639
|
-
tag:
|
|
5640
|
-
match:
|
|
5641
|
-
sort:
|
|
5701
|
+
var User = z6.object({
|
|
5702
|
+
id: z6.string().uuid(),
|
|
5703
|
+
given_name: z6.union([z6.string(), z6.null()]).optional(),
|
|
5704
|
+
family_name: z6.union([z6.string(), z6.null()]).optional(),
|
|
5705
|
+
email: z6.union([z6.string(), z6.null()]).optional(),
|
|
5706
|
+
avatar_url: z6.union([z6.string(), z6.null()]).optional(),
|
|
5707
|
+
created: z6.union([z6.string(), z6.null()]).optional()
|
|
5708
|
+
});
|
|
5709
|
+
var ViewDataSearch = z6.union([
|
|
5710
|
+
z6.object({
|
|
5711
|
+
filter: z6.union([z6.array(z6.unknown()), z6.null()]),
|
|
5712
|
+
tag: z6.union([z6.array(z6.unknown()), z6.null()]),
|
|
5713
|
+
match: z6.union([z6.array(z6.unknown()), z6.null()]),
|
|
5714
|
+
sort: z6.union([z6.array(z6.unknown()), z6.null()])
|
|
5642
5715
|
}).partial(),
|
|
5643
|
-
|
|
5716
|
+
z6.null()
|
|
5644
5717
|
]);
|
|
5645
|
-
var ViewData =
|
|
5646
|
-
|
|
5647
|
-
|
|
5718
|
+
var ViewData = z6.union([
|
|
5719
|
+
z6.object({ search: ViewDataSearch }).partial(),
|
|
5720
|
+
z6.null()
|
|
5648
5721
|
]);
|
|
5649
|
-
var ViewOptions =
|
|
5650
|
-
|
|
5651
|
-
viewType:
|
|
5652
|
-
options:
|
|
5653
|
-
spanType:
|
|
5654
|
-
rangeValue:
|
|
5655
|
-
frameStart:
|
|
5656
|
-
frameEnd:
|
|
5657
|
-
tzUTC:
|
|
5658
|
-
chartVisibility:
|
|
5659
|
-
projectId:
|
|
5660
|
-
type:
|
|
5661
|
-
groupBy:
|
|
5722
|
+
var ViewOptions = z6.union([
|
|
5723
|
+
z6.object({
|
|
5724
|
+
viewType: z6.literal("monitor"),
|
|
5725
|
+
options: z6.object({
|
|
5726
|
+
spanType: z6.union([z6.enum(["range", "frame"]), z6.null()]),
|
|
5727
|
+
rangeValue: z6.union([z6.string(), z6.null()]),
|
|
5728
|
+
frameStart: z6.union([z6.string(), z6.null()]),
|
|
5729
|
+
frameEnd: z6.union([z6.string(), z6.null()]),
|
|
5730
|
+
tzUTC: z6.union([z6.boolean(), z6.null()]),
|
|
5731
|
+
chartVisibility: z6.union([z6.record(z6.boolean()), z6.null()]),
|
|
5732
|
+
projectId: z6.union([z6.string(), z6.null()]),
|
|
5733
|
+
type: z6.union([z6.enum(["project", "experiment"]), z6.null()]),
|
|
5734
|
+
groupBy: z6.union([z6.string(), z6.null()])
|
|
5662
5735
|
}).partial()
|
|
5663
5736
|
}),
|
|
5664
|
-
|
|
5665
|
-
columnVisibility:
|
|
5666
|
-
columnOrder:
|
|
5667
|
-
columnSizing:
|
|
5668
|
-
grouping:
|
|
5669
|
-
rowHeight:
|
|
5670
|
-
tallGroupRows:
|
|
5671
|
-
layout:
|
|
5672
|
-
chartHeight:
|
|
5673
|
-
excludedMeasures:
|
|
5674
|
-
|
|
5675
|
-
|
|
5676
|
-
type:
|
|
5677
|
-
value:
|
|
5737
|
+
z6.object({
|
|
5738
|
+
columnVisibility: z6.union([z6.record(z6.boolean()), z6.null()]),
|
|
5739
|
+
columnOrder: z6.union([z6.array(z6.string()), z6.null()]),
|
|
5740
|
+
columnSizing: z6.union([z6.record(z6.number()), z6.null()]),
|
|
5741
|
+
grouping: z6.union([z6.string(), z6.null()]),
|
|
5742
|
+
rowHeight: z6.union([z6.string(), z6.null()]),
|
|
5743
|
+
tallGroupRows: z6.union([z6.boolean(), z6.null()]),
|
|
5744
|
+
layout: z6.union([z6.string(), z6.null()]),
|
|
5745
|
+
chartHeight: z6.union([z6.number(), z6.null()]),
|
|
5746
|
+
excludedMeasures: z6.union([
|
|
5747
|
+
z6.array(
|
|
5748
|
+
z6.object({
|
|
5749
|
+
type: z6.enum(["none", "score", "metric", "metadata"]),
|
|
5750
|
+
value: z6.string()
|
|
5678
5751
|
})
|
|
5679
5752
|
),
|
|
5680
|
-
|
|
5753
|
+
z6.null()
|
|
5681
5754
|
]),
|
|
5682
|
-
yMetric:
|
|
5683
|
-
|
|
5684
|
-
type:
|
|
5685
|
-
value:
|
|
5755
|
+
yMetric: z6.union([
|
|
5756
|
+
z6.object({
|
|
5757
|
+
type: z6.enum(["none", "score", "metric", "metadata"]),
|
|
5758
|
+
value: z6.string()
|
|
5686
5759
|
}),
|
|
5687
|
-
|
|
5760
|
+
z6.null()
|
|
5688
5761
|
]),
|
|
5689
|
-
xAxis:
|
|
5690
|
-
|
|
5691
|
-
type:
|
|
5692
|
-
value:
|
|
5762
|
+
xAxis: z6.union([
|
|
5763
|
+
z6.object({
|
|
5764
|
+
type: z6.enum(["none", "score", "metric", "metadata"]),
|
|
5765
|
+
value: z6.string()
|
|
5693
5766
|
}),
|
|
5694
|
-
|
|
5767
|
+
z6.null()
|
|
5695
5768
|
]),
|
|
5696
|
-
symbolGrouping:
|
|
5697
|
-
|
|
5698
|
-
type:
|
|
5699
|
-
value:
|
|
5769
|
+
symbolGrouping: z6.union([
|
|
5770
|
+
z6.object({
|
|
5771
|
+
type: z6.enum(["none", "score", "metric", "metadata"]),
|
|
5772
|
+
value: z6.string()
|
|
5700
5773
|
}),
|
|
5701
|
-
|
|
5774
|
+
z6.null()
|
|
5702
5775
|
]),
|
|
5703
|
-
xAxisAggregation:
|
|
5704
|
-
chartAnnotations:
|
|
5705
|
-
|
|
5706
|
-
|
|
5776
|
+
xAxisAggregation: z6.union([z6.string(), z6.null()]),
|
|
5777
|
+
chartAnnotations: z6.union([
|
|
5778
|
+
z6.array(z6.object({ id: z6.string(), text: z6.string() })),
|
|
5779
|
+
z6.null()
|
|
5707
5780
|
]),
|
|
5708
|
-
timeRangeFilter:
|
|
5709
|
-
|
|
5710
|
-
|
|
5711
|
-
|
|
5781
|
+
timeRangeFilter: z6.union([
|
|
5782
|
+
z6.string(),
|
|
5783
|
+
z6.object({ from: z6.string(), to: z6.string() }),
|
|
5784
|
+
z6.null()
|
|
5712
5785
|
])
|
|
5713
5786
|
}).partial(),
|
|
5714
|
-
|
|
5787
|
+
z6.null()
|
|
5715
5788
|
]);
|
|
5716
|
-
var View =
|
|
5717
|
-
id:
|
|
5718
|
-
object_type: AclObjectType.and(
|
|
5719
|
-
object_id:
|
|
5720
|
-
view_type:
|
|
5789
|
+
var View = z6.object({
|
|
5790
|
+
id: z6.string().uuid(),
|
|
5791
|
+
object_type: AclObjectType.and(z6.string()),
|
|
5792
|
+
object_id: z6.string().uuid(),
|
|
5793
|
+
view_type: z6.enum([
|
|
5721
5794
|
"projects",
|
|
5722
5795
|
"experiments",
|
|
5723
5796
|
"experiment",
|
|
@@ -5732,56 +5805,56 @@ var View = z5.object({
|
|
|
5732
5805
|
"agents",
|
|
5733
5806
|
"monitor"
|
|
5734
5807
|
]),
|
|
5735
|
-
name:
|
|
5736
|
-
created:
|
|
5808
|
+
name: z6.string(),
|
|
5809
|
+
created: z6.union([z6.string(), z6.null()]).optional(),
|
|
5737
5810
|
view_data: ViewData.optional(),
|
|
5738
5811
|
options: ViewOptions.optional(),
|
|
5739
|
-
user_id:
|
|
5740
|
-
deleted_at:
|
|
5812
|
+
user_id: z6.union([z6.string(), z6.null()]).optional(),
|
|
5813
|
+
deleted_at: z6.union([z6.string(), z6.null()]).optional()
|
|
5741
5814
|
});
|
|
5742
5815
|
|
|
5743
5816
|
// src/logger.ts
|
|
5744
5817
|
import { waitUntil } from "@vercel/functions";
|
|
5745
5818
|
import Mustache2 from "mustache";
|
|
5746
|
-
import { z as
|
|
5819
|
+
import { z as z8, ZodError } from "zod";
|
|
5747
5820
|
|
|
5748
5821
|
// src/functions/stream.ts
|
|
5749
5822
|
import {
|
|
5750
5823
|
createParser
|
|
5751
5824
|
} from "eventsource-parser";
|
|
5752
|
-
import { z as
|
|
5753
|
-
var braintrustStreamChunkSchema =
|
|
5754
|
-
|
|
5755
|
-
type:
|
|
5756
|
-
data:
|
|
5825
|
+
import { z as z7 } from "zod/v3";
|
|
5826
|
+
var braintrustStreamChunkSchema = z7.union([
|
|
5827
|
+
z7.object({
|
|
5828
|
+
type: z7.literal("text_delta"),
|
|
5829
|
+
data: z7.string()
|
|
5757
5830
|
}),
|
|
5758
|
-
|
|
5759
|
-
type:
|
|
5760
|
-
data:
|
|
5831
|
+
z7.object({
|
|
5832
|
+
type: z7.literal("reasoning_delta"),
|
|
5833
|
+
data: z7.string()
|
|
5761
5834
|
}),
|
|
5762
|
-
|
|
5763
|
-
type:
|
|
5764
|
-
data:
|
|
5835
|
+
z7.object({
|
|
5836
|
+
type: z7.literal("json_delta"),
|
|
5837
|
+
data: z7.string()
|
|
5765
5838
|
}),
|
|
5766
|
-
|
|
5767
|
-
type:
|
|
5768
|
-
data:
|
|
5839
|
+
z7.object({
|
|
5840
|
+
type: z7.literal("error"),
|
|
5841
|
+
data: z7.string()
|
|
5769
5842
|
}),
|
|
5770
|
-
|
|
5771
|
-
type:
|
|
5843
|
+
z7.object({
|
|
5844
|
+
type: z7.literal("console"),
|
|
5772
5845
|
data: SSEConsoleEventData
|
|
5773
5846
|
}),
|
|
5774
|
-
|
|
5775
|
-
type:
|
|
5847
|
+
z7.object({
|
|
5848
|
+
type: z7.literal("progress"),
|
|
5776
5849
|
data: SSEProgressEventData
|
|
5777
5850
|
}),
|
|
5778
|
-
|
|
5779
|
-
type:
|
|
5780
|
-
data:
|
|
5851
|
+
z7.object({
|
|
5852
|
+
type: z7.literal("start"),
|
|
5853
|
+
data: z7.string()
|
|
5781
5854
|
}),
|
|
5782
|
-
|
|
5783
|
-
type:
|
|
5784
|
-
data:
|
|
5855
|
+
z7.object({
|
|
5856
|
+
type: z7.literal("done"),
|
|
5857
|
+
data: z7.string()
|
|
5785
5858
|
})
|
|
5786
5859
|
]);
|
|
5787
5860
|
var BraintrustStream = class _BraintrustStream {
|
|
@@ -6484,17 +6557,31 @@ var NoopSpan = class {
|
|
|
6484
6557
|
state() {
|
|
6485
6558
|
return _internalGetGlobalState();
|
|
6486
6559
|
}
|
|
6560
|
+
// Custom inspect for Node.js console.log
|
|
6561
|
+
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
6562
|
+
return `NoopSpan {
|
|
6563
|
+
kind: '${this.kind}',
|
|
6564
|
+
id: '${this.id}',
|
|
6565
|
+
spanId: '${this.spanId}',
|
|
6566
|
+
rootSpanId: '${this.rootSpanId}',
|
|
6567
|
+
spanParents: ${JSON.stringify(this.spanParents)}
|
|
6568
|
+
}`;
|
|
6569
|
+
}
|
|
6570
|
+
// Custom toString
|
|
6571
|
+
toString() {
|
|
6572
|
+
return `NoopSpan(id=${this.id}, spanId=${this.spanId})`;
|
|
6573
|
+
}
|
|
6487
6574
|
};
|
|
6488
6575
|
var NOOP_SPAN = new NoopSpan();
|
|
6489
6576
|
var NOOP_SPAN_PERMALINK = "https://braintrust.dev/noop-span";
|
|
6490
|
-
var loginSchema =
|
|
6491
|
-
appUrl:
|
|
6492
|
-
appPublicUrl:
|
|
6493
|
-
orgName:
|
|
6494
|
-
apiUrl:
|
|
6495
|
-
proxyUrl:
|
|
6496
|
-
loginToken:
|
|
6497
|
-
orgId:
|
|
6577
|
+
var loginSchema = z8.strictObject({
|
|
6578
|
+
appUrl: z8.string(),
|
|
6579
|
+
appPublicUrl: z8.string(),
|
|
6580
|
+
orgName: z8.string(),
|
|
6581
|
+
apiUrl: z8.string(),
|
|
6582
|
+
proxyUrl: z8.string(),
|
|
6583
|
+
loginToken: z8.string(),
|
|
6584
|
+
orgId: z8.string().nullish(),
|
|
6498
6585
|
gitMetadataSettings: GitMetadataSettings.nullish()
|
|
6499
6586
|
});
|
|
6500
6587
|
var stateNonce = 0;
|
|
@@ -6553,6 +6640,7 @@ var BraintrustState = class _BraintrustState {
|
|
|
6553
6640
|
_apiConn = null;
|
|
6554
6641
|
_proxyConn = null;
|
|
6555
6642
|
promptCache;
|
|
6643
|
+
_idGenerator = null;
|
|
6556
6644
|
resetLoginInfo() {
|
|
6557
6645
|
this.appUrl = null;
|
|
6558
6646
|
this.appPublicUrl = null;
|
|
@@ -6567,6 +6655,15 @@ var BraintrustState = class _BraintrustState {
|
|
|
6567
6655
|
this._apiConn = null;
|
|
6568
6656
|
this._proxyConn = null;
|
|
6569
6657
|
}
|
|
6658
|
+
resetIdGenState() {
|
|
6659
|
+
this._idGenerator = null;
|
|
6660
|
+
}
|
|
6661
|
+
get idGenerator() {
|
|
6662
|
+
if (this._idGenerator === null) {
|
|
6663
|
+
this._idGenerator = getIdGenerator();
|
|
6664
|
+
}
|
|
6665
|
+
return this._idGenerator;
|
|
6666
|
+
}
|
|
6570
6667
|
copyLoginInfo(other) {
|
|
6571
6668
|
this.appUrl = other.appUrl;
|
|
6572
6669
|
this.appPublicUrl = other.appPublicUrl;
|
|
@@ -6704,6 +6801,37 @@ var BraintrustState = class _BraintrustState {
|
|
|
6704
6801
|
enforceQueueSizeLimit(enforce) {
|
|
6705
6802
|
this._bgLogger.get().enforceQueueSizeLimit(enforce);
|
|
6706
6803
|
}
|
|
6804
|
+
// Custom serialization to avoid logging sensitive data
|
|
6805
|
+
toJSON() {
|
|
6806
|
+
return {
|
|
6807
|
+
id: this.id,
|
|
6808
|
+
orgId: this.orgId,
|
|
6809
|
+
orgName: this.orgName,
|
|
6810
|
+
appUrl: this.appUrl,
|
|
6811
|
+
appPublicUrl: this.appPublicUrl,
|
|
6812
|
+
apiUrl: this.apiUrl,
|
|
6813
|
+
proxyUrl: this.proxyUrl,
|
|
6814
|
+
loggedIn: this.loggedIn
|
|
6815
|
+
// Explicitly exclude loginToken, _apiConn, _appConn, _proxyConn and other sensitive fields
|
|
6816
|
+
};
|
|
6817
|
+
}
|
|
6818
|
+
// Custom inspect for Node.js console.log
|
|
6819
|
+
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
6820
|
+
return `BraintrustState {
|
|
6821
|
+
id: '${this.id}',
|
|
6822
|
+
orgId: ${this.orgId ? `'${this.orgId}'` : "null"},
|
|
6823
|
+
orgName: ${this.orgName ? `'${this.orgName}'` : "null"},
|
|
6824
|
+
appUrl: ${this.appUrl ? `'${this.appUrl}'` : "null"},
|
|
6825
|
+
apiUrl: ${this.apiUrl ? `'${this.apiUrl}'` : "null"},
|
|
6826
|
+
proxyUrl: ${this.proxyUrl ? `'${this.proxyUrl}'` : "null"},
|
|
6827
|
+
loggedIn: ${this.loggedIn},
|
|
6828
|
+
loginToken: '[REDACTED]'
|
|
6829
|
+
}`;
|
|
6830
|
+
}
|
|
6831
|
+
// Custom toString
|
|
6832
|
+
toString() {
|
|
6833
|
+
return `BraintrustState(id=${this.id}, org=${this.orgName || "none"}, loggedIn=${this.loggedIn})`;
|
|
6834
|
+
}
|
|
6707
6835
|
};
|
|
6708
6836
|
var _globalState;
|
|
6709
6837
|
function useTestBackgroundLogger() {
|
|
@@ -6871,6 +6999,17 @@ var HTTPConnection = class _HTTPConnection {
|
|
|
6871
6999
|
});
|
|
6872
7000
|
return await resp.json();
|
|
6873
7001
|
}
|
|
7002
|
+
// Custom inspect for Node.js console.log
|
|
7003
|
+
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
7004
|
+
return `HTTPConnection {
|
|
7005
|
+
base_url: '${this.base_url}',
|
|
7006
|
+
token: '[REDACTED]'
|
|
7007
|
+
}`;
|
|
7008
|
+
}
|
|
7009
|
+
// Custom toString
|
|
7010
|
+
toString() {
|
|
7011
|
+
return `HTTPConnection(${this.base_url})`;
|
|
7012
|
+
}
|
|
6874
7013
|
};
|
|
6875
7014
|
var BaseAttachment = class {
|
|
6876
7015
|
reference;
|
|
@@ -6971,9 +7110,9 @@ var Attachment = class extends BaseAttachment {
|
|
|
6971
7110
|
let signedUrl;
|
|
6972
7111
|
let headers;
|
|
6973
7112
|
try {
|
|
6974
|
-
({ signedUrl, headers } =
|
|
6975
|
-
signedUrl:
|
|
6976
|
-
headers:
|
|
7113
|
+
({ signedUrl, headers } = z8.object({
|
|
7114
|
+
signedUrl: z8.string().url(),
|
|
7115
|
+
headers: z8.record(z8.string())
|
|
6977
7116
|
}).parse(await metadataResponse.json()));
|
|
6978
7117
|
} catch (error2) {
|
|
6979
7118
|
if (error2 instanceof ZodError) {
|
|
@@ -7128,8 +7267,8 @@ var ExternalAttachment = class extends BaseAttachment {
|
|
|
7128
7267
|
});
|
|
7129
7268
|
}
|
|
7130
7269
|
};
|
|
7131
|
-
var attachmentMetadataSchema =
|
|
7132
|
-
downloadUrl:
|
|
7270
|
+
var attachmentMetadataSchema = z8.object({
|
|
7271
|
+
downloadUrl: z8.string(),
|
|
7133
7272
|
status: AttachmentStatus
|
|
7134
7273
|
});
|
|
7135
7274
|
var ReadonlyAttachment = class {
|
|
@@ -7267,7 +7406,7 @@ function logFeedbackImpl(state, parentObjectType, parentObjectId, {
|
|
|
7267
7406
|
if (!isEmpty(comment)) {
|
|
7268
7407
|
const record = new LazyValue(async () => {
|
|
7269
7408
|
return {
|
|
7270
|
-
id:
|
|
7409
|
+
id: uuidv42(),
|
|
7271
7410
|
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
7272
7411
|
origin: {
|
|
7273
7412
|
// NOTE: We do not know (or care?) what the transaction id of the row that
|
|
@@ -8057,7 +8196,7 @@ Error: ${errorText}`;
|
|
|
8057
8196
|
}
|
|
8058
8197
|
const payloadFile = isomorph_default.pathJoin(
|
|
8059
8198
|
payloadDir,
|
|
8060
|
-
`payload_${getCurrentUnixTimestamp()}_${
|
|
8199
|
+
`payload_${getCurrentUnixTimestamp()}_${uuidv42().slice(0, 8)}.json`
|
|
8061
8200
|
);
|
|
8062
8201
|
try {
|
|
8063
8202
|
await isomorph_default.mkdir(payloadDir, { recursive: true });
|
|
@@ -9109,7 +9248,7 @@ function validateAndSanitizeExperimentLogPartialArgs(event) {
|
|
|
9109
9248
|
function deepCopyEvent(event) {
|
|
9110
9249
|
const attachments = [];
|
|
9111
9250
|
const IDENTIFIER = "_bt_internal_saved_attachment";
|
|
9112
|
-
const savedAttachmentSchema =
|
|
9251
|
+
const savedAttachmentSchema = z8.strictObject({ [IDENTIFIER]: z8.number() });
|
|
9113
9252
|
const serialized = JSON.stringify(event, (_k, v) => {
|
|
9114
9253
|
if (v instanceof SpanImpl || v instanceof NoopSpan) {
|
|
9115
9254
|
return `<span>`;
|
|
@@ -9612,7 +9751,7 @@ var ReadonlyExperiment = class extends ObjectFetcher {
|
|
|
9612
9751
|
};
|
|
9613
9752
|
var executionCounter = 0;
|
|
9614
9753
|
function newId() {
|
|
9615
|
-
return
|
|
9754
|
+
return uuidv42();
|
|
9616
9755
|
}
|
|
9617
9756
|
var SpanImpl = class _SpanImpl {
|
|
9618
9757
|
_state;
|
|
@@ -9668,13 +9807,17 @@ var SpanImpl = class _SpanImpl {
|
|
|
9668
9807
|
},
|
|
9669
9808
|
created: (/* @__PURE__ */ new Date()).toISOString()
|
|
9670
9809
|
};
|
|
9671
|
-
this._id = eventId ??
|
|
9672
|
-
this._spanId = args.spanId ??
|
|
9810
|
+
this._id = eventId ?? this._state.idGenerator.getSpanId();
|
|
9811
|
+
this._spanId = args.spanId ?? this._state.idGenerator.getSpanId();
|
|
9673
9812
|
if (args.parentSpanIds) {
|
|
9674
9813
|
this._rootSpanId = args.parentSpanIds.rootSpanId;
|
|
9675
9814
|
this._spanParents = "parentSpanIds" in args.parentSpanIds ? args.parentSpanIds.parentSpanIds : [args.parentSpanIds.spanId];
|
|
9676
9815
|
} else {
|
|
9677
|
-
this.
|
|
9816
|
+
if (this._state.idGenerator.shareRootSpanId()) {
|
|
9817
|
+
this._rootSpanId = this._spanId;
|
|
9818
|
+
} else {
|
|
9819
|
+
this._rootSpanId = this._state.idGenerator.getTraceId();
|
|
9820
|
+
}
|
|
9678
9821
|
this._spanParents = void 0;
|
|
9679
9822
|
}
|
|
9680
9823
|
this.isMerge = false;
|
|
@@ -9885,6 +10028,20 @@ var SpanImpl = class _SpanImpl {
|
|
|
9885
10028
|
state() {
|
|
9886
10029
|
return this._state;
|
|
9887
10030
|
}
|
|
10031
|
+
// Custom inspect for Node.js console.log
|
|
10032
|
+
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
10033
|
+
return `SpanImpl {
|
|
10034
|
+
kind: '${this.kind}',
|
|
10035
|
+
id: '${this.id}',
|
|
10036
|
+
spanId: '${this.spanId}',
|
|
10037
|
+
rootSpanId: '${this.rootSpanId}',
|
|
10038
|
+
spanParents: ${JSON.stringify(this.spanParents)}
|
|
10039
|
+
}`;
|
|
10040
|
+
}
|
|
10041
|
+
// Custom toString
|
|
10042
|
+
toString() {
|
|
10043
|
+
return `SpanImpl(id=${this.id}, spanId=${this.spanId})`;
|
|
10044
|
+
}
|
|
9888
10045
|
};
|
|
9889
10046
|
function splitLoggingData({
|
|
9890
10047
|
event,
|
|
@@ -10036,7 +10193,7 @@ var Dataset2 = class extends ObjectFetcher {
|
|
|
10036
10193
|
output
|
|
10037
10194
|
}) {
|
|
10038
10195
|
this.validateEvent({ metadata, expected, output, tags });
|
|
10039
|
-
const rowId = id ||
|
|
10196
|
+
const rowId = id || uuidv42();
|
|
10040
10197
|
const args = this.createArgs(
|
|
10041
10198
|
deepCopyEvent({
|
|
10042
10199
|
id: rowId,
|
|
@@ -10114,8 +10271,8 @@ var Dataset2 = class extends ObjectFetcher {
|
|
|
10114
10271
|
)}`;
|
|
10115
10272
|
let dataSummary;
|
|
10116
10273
|
if (summarizeData) {
|
|
10117
|
-
const rawDataSummary =
|
|
10118
|
-
total_records:
|
|
10274
|
+
const rawDataSummary = z8.object({
|
|
10275
|
+
total_records: z8.number()
|
|
10119
10276
|
}).parse(
|
|
10120
10277
|
await state.apiConn().get_json(
|
|
10121
10278
|
"dataset-summary",
|
|
@@ -10238,11 +10395,11 @@ function renderTemplatedObject(obj, args, options) {
|
|
|
10238
10395
|
return obj;
|
|
10239
10396
|
}
|
|
10240
10397
|
function renderPromptParams(params, args, options) {
|
|
10241
|
-
const schemaParsed =
|
|
10242
|
-
response_format:
|
|
10243
|
-
type:
|
|
10398
|
+
const schemaParsed = z8.object({
|
|
10399
|
+
response_format: z8.object({
|
|
10400
|
+
type: z8.literal("json_schema"),
|
|
10244
10401
|
json_schema: ResponseFormatJsonSchema.omit({ schema: true }).extend({
|
|
10245
|
-
schema:
|
|
10402
|
+
schema: z8.unknown()
|
|
10246
10403
|
})
|
|
10247
10404
|
})
|
|
10248
10405
|
}).safeParse(params);
|
|
@@ -10360,7 +10517,7 @@ var Prompt2 = class _Prompt {
|
|
|
10360
10517
|
if (!prompt) {
|
|
10361
10518
|
throw new Error("Empty prompt");
|
|
10362
10519
|
}
|
|
10363
|
-
const dictArgParsed =
|
|
10520
|
+
const dictArgParsed = z8.record(z8.unknown()).safeParse(buildArgs);
|
|
10364
10521
|
const variables = {
|
|
10365
10522
|
input: buildArgs,
|
|
10366
10523
|
...dictArgParsed.success ? dictArgParsed.data : {}
|
|
@@ -10415,7 +10572,7 @@ var Prompt2 = class _Prompt {
|
|
|
10415
10572
|
return JSON.stringify(v);
|
|
10416
10573
|
}
|
|
10417
10574
|
};
|
|
10418
|
-
const dictArgParsed =
|
|
10575
|
+
const dictArgParsed = z8.record(z8.unknown()).safeParse(buildArgs);
|
|
10419
10576
|
const variables = {
|
|
10420
10577
|
input: buildArgs,
|
|
10421
10578
|
...dictArgParsed.success ? dictArgParsed.data : {}
|
|
@@ -10556,6 +10713,12 @@ async function getPromptVersions(projectId, promptId) {
|
|
|
10556
10713
|
(entry) => ["upsert", "merge"].includes(entry.audit_data?.action)
|
|
10557
10714
|
).map((entry) => prettifyXact(entry._xact_id)) || [];
|
|
10558
10715
|
}
|
|
10716
|
+
function resetIdGenStateForTests() {
|
|
10717
|
+
const state = _internalGetGlobalState();
|
|
10718
|
+
if (state) {
|
|
10719
|
+
state.resetIdGenState();
|
|
10720
|
+
}
|
|
10721
|
+
}
|
|
10559
10722
|
var _exportsForTestingOnly = {
|
|
10560
10723
|
extractAttachments,
|
|
10561
10724
|
deepCopyEvent,
|
|
@@ -10566,7 +10729,8 @@ var _exportsForTestingOnly = {
|
|
|
10566
10729
|
setInitialTestState,
|
|
10567
10730
|
initTestExperiment,
|
|
10568
10731
|
isGeneratorFunction,
|
|
10569
|
-
isAsyncGeneratorFunction
|
|
10732
|
+
isAsyncGeneratorFunction,
|
|
10733
|
+
resetIdGenStateForTests
|
|
10570
10734
|
};
|
|
10571
10735
|
|
|
10572
10736
|
// src/node.ts
|
|
@@ -10619,6 +10783,7 @@ __export(exports_node_exports, {
|
|
|
10619
10783
|
Experiment: () => Experiment2,
|
|
10620
10784
|
ExternalAttachment: () => ExternalAttachment,
|
|
10621
10785
|
FailedHTTPResponse: () => FailedHTTPResponse,
|
|
10786
|
+
IDGenerator: () => IDGenerator,
|
|
10622
10787
|
INTERNAL_BTQL_LIMIT: () => INTERNAL_BTQL_LIMIT,
|
|
10623
10788
|
LEGACY_CACHED_HEADER: () => LEGACY_CACHED_HEADER,
|
|
10624
10789
|
LazyValue: () => LazyValue,
|
|
@@ -10626,6 +10791,7 @@ __export(exports_node_exports, {
|
|
|
10626
10791
|
NOOP_SPAN: () => NOOP_SPAN,
|
|
10627
10792
|
NOOP_SPAN_PERMALINK: () => NOOP_SPAN_PERMALINK,
|
|
10628
10793
|
NoopSpan: () => NoopSpan,
|
|
10794
|
+
OTELIDGenerator: () => OTELIDGenerator,
|
|
10629
10795
|
Project: () => Project2,
|
|
10630
10796
|
ProjectNameIdMap: () => ProjectNameIdMap,
|
|
10631
10797
|
Prompt: () => Prompt2,
|
|
@@ -10637,6 +10803,7 @@ __export(exports_node_exports, {
|
|
|
10637
10803
|
SpanImpl: () => SpanImpl,
|
|
10638
10804
|
TestBackgroundLogger: () => TestBackgroundLogger,
|
|
10639
10805
|
ToolBuilder: () => ToolBuilder,
|
|
10806
|
+
UUIDGenerator: () => UUIDGenerator,
|
|
10640
10807
|
X_CACHED_HEADER: () => X_CACHED_HEADER,
|
|
10641
10808
|
_exportsForTestingOnly: () => _exportsForTestingOnly,
|
|
10642
10809
|
_internalGetGlobalState: () => _internalGetGlobalState,
|
|
@@ -10647,10 +10814,12 @@ __export(exports_node_exports, {
|
|
|
10647
10814
|
currentExperiment: () => currentExperiment,
|
|
10648
10815
|
currentLogger: () => currentLogger,
|
|
10649
10816
|
currentSpan: () => currentSpan,
|
|
10817
|
+
deepCopyEvent: () => deepCopyEvent,
|
|
10650
10818
|
defaultErrorScoreHandler: () => defaultErrorScoreHandler,
|
|
10651
10819
|
deserializePlainStringAsJSON: () => deserializePlainStringAsJSON,
|
|
10652
10820
|
devNullWritableStream: () => devNullWritableStream,
|
|
10653
10821
|
flush: () => flush,
|
|
10822
|
+
getIdGenerator: () => getIdGenerator,
|
|
10654
10823
|
getPromptVersions: () => getPromptVersions,
|
|
10655
10824
|
getSpanParentObject: () => getSpanParentObject,
|
|
10656
10825
|
graph: () => graph_framework_exports,
|
|
@@ -10694,6 +10863,8 @@ __export(exports_node_exports, {
|
|
|
10694
10863
|
wrapAISDK: () => wrapAISDK,
|
|
10695
10864
|
wrapAISDKModel: () => wrapAISDKModel,
|
|
10696
10865
|
wrapAnthropic: () => wrapAnthropic,
|
|
10866
|
+
wrapClaudeAgentSDK: () => wrapClaudeAgentSDK,
|
|
10867
|
+
wrapMastraAgent: () => wrapMastraAgent,
|
|
10697
10868
|
wrapOpenAI: () => wrapOpenAI,
|
|
10698
10869
|
wrapOpenAIv4: () => wrapOpenAIv4,
|
|
10699
10870
|
wrapTraced: () => wrapTraced
|
|
@@ -11866,12 +12037,12 @@ var BarProgressReporter = class {
|
|
|
11866
12037
|
};
|
|
11867
12038
|
|
|
11868
12039
|
// src/eval-parameters.ts
|
|
11869
|
-
import { z as
|
|
12040
|
+
import { z as z10 } from "zod/v3";
|
|
11870
12041
|
|
|
11871
12042
|
// src/framework2.ts
|
|
11872
12043
|
import path2 from "path";
|
|
11873
12044
|
import slugifyLib from "slugify";
|
|
11874
|
-
import { z as
|
|
12045
|
+
import { z as z9 } from "zod/v3";
|
|
11875
12046
|
var ProjectBuilder = class {
|
|
11876
12047
|
create(opts) {
|
|
11877
12048
|
return new Project2(opts);
|
|
@@ -12105,23 +12276,23 @@ var CodePrompt = class {
|
|
|
12105
12276
|
};
|
|
12106
12277
|
}
|
|
12107
12278
|
};
|
|
12108
|
-
var promptContentsSchema =
|
|
12109
|
-
|
|
12110
|
-
prompt:
|
|
12279
|
+
var promptContentsSchema = z9.union([
|
|
12280
|
+
z9.object({
|
|
12281
|
+
prompt: z9.string()
|
|
12111
12282
|
}),
|
|
12112
|
-
|
|
12113
|
-
messages:
|
|
12283
|
+
z9.object({
|
|
12284
|
+
messages: z9.array(ChatCompletionMessageParam)
|
|
12114
12285
|
})
|
|
12115
12286
|
]);
|
|
12116
12287
|
var promptDefinitionSchema = promptContentsSchema.and(
|
|
12117
|
-
|
|
12118
|
-
model:
|
|
12288
|
+
z9.object({
|
|
12289
|
+
model: z9.string(),
|
|
12119
12290
|
params: ModelParams.optional()
|
|
12120
12291
|
})
|
|
12121
12292
|
);
|
|
12122
12293
|
var promptDefinitionWithToolsSchema = promptDefinitionSchema.and(
|
|
12123
|
-
|
|
12124
|
-
tools:
|
|
12294
|
+
z9.object({
|
|
12295
|
+
tools: z9.array(ToolFunctionDefinition).optional()
|
|
12125
12296
|
})
|
|
12126
12297
|
);
|
|
12127
12298
|
var PromptBuilder = class {
|
|
@@ -12189,7 +12360,7 @@ var ProjectNameIdMap = class {
|
|
|
12189
12360
|
const response = await _internalGetGlobalState().appConn().post_json("api/project/register", {
|
|
12190
12361
|
project_name: projectName
|
|
12191
12362
|
});
|
|
12192
|
-
const result =
|
|
12363
|
+
const result = z9.object({
|
|
12193
12364
|
project: Project
|
|
12194
12365
|
}).parse(response);
|
|
12195
12366
|
const projectId = result.project.id;
|
|
@@ -12203,7 +12374,7 @@ var ProjectNameIdMap = class {
|
|
|
12203
12374
|
const response = await _internalGetGlobalState().appConn().post_json("api/project/get", {
|
|
12204
12375
|
id: projectId
|
|
12205
12376
|
});
|
|
12206
|
-
const result =
|
|
12377
|
+
const result = z9.array(Project).nonempty().parse(response);
|
|
12207
12378
|
const projectName = result[0].name;
|
|
12208
12379
|
this.idToName[projectId] = projectName;
|
|
12209
12380
|
this.nameToId[projectName] = projectId;
|
|
@@ -12219,15 +12390,15 @@ var ProjectNameIdMap = class {
|
|
|
12219
12390
|
};
|
|
12220
12391
|
|
|
12221
12392
|
// src/eval-parameters.ts
|
|
12222
|
-
var evalParametersSchema =
|
|
12223
|
-
|
|
12224
|
-
|
|
12225
|
-
|
|
12226
|
-
type:
|
|
12393
|
+
var evalParametersSchema = z10.record(
|
|
12394
|
+
z10.string(),
|
|
12395
|
+
z10.union([
|
|
12396
|
+
z10.object({
|
|
12397
|
+
type: z10.literal("prompt"),
|
|
12227
12398
|
default: promptDefinitionWithToolsSchema.optional(),
|
|
12228
|
-
description:
|
|
12399
|
+
description: z10.string().optional()
|
|
12229
12400
|
}),
|
|
12230
|
-
|
|
12401
|
+
z10.instanceof(z10.ZodType)
|
|
12231
12402
|
// For Zod schemas
|
|
12232
12403
|
])
|
|
12233
12404
|
);
|
|
@@ -13208,7 +13379,7 @@ function parseSpanFromResponseCreateParams(params) {
|
|
|
13208
13379
|
function parseEventFromResponseCreateResult(result) {
|
|
13209
13380
|
const data = {};
|
|
13210
13381
|
if (result?.output !== void 0) {
|
|
13211
|
-
data.output = result.output;
|
|
13382
|
+
data.output = processImagesInOutput(result.output);
|
|
13212
13383
|
}
|
|
13213
13384
|
if (result) {
|
|
13214
13385
|
const { output, usage, ...metadata } = result;
|
|
@@ -13219,6 +13390,35 @@ function parseEventFromResponseCreateResult(result) {
|
|
|
13219
13390
|
data.metrics = parseMetricsFromUsage(result?.usage);
|
|
13220
13391
|
return data;
|
|
13221
13392
|
}
|
|
13393
|
+
function processImagesInOutput(output) {
|
|
13394
|
+
if (Array.isArray(output)) {
|
|
13395
|
+
return output.map(processImagesInOutput);
|
|
13396
|
+
}
|
|
13397
|
+
if (isObject(output)) {
|
|
13398
|
+
if (output.type === "image_generation_call" && output.result && typeof output.result === "string") {
|
|
13399
|
+
const fileExtension = output.output_format || "png";
|
|
13400
|
+
const contentType = `image/${fileExtension}`;
|
|
13401
|
+
const baseFilename = output.revised_prompt && typeof output.revised_prompt === "string" ? output.revised_prompt.slice(0, 50).replace(/[^a-zA-Z0-9]/g, "_") : "generated_image";
|
|
13402
|
+
const filename = `${baseFilename}.${fileExtension}`;
|
|
13403
|
+
const binaryString = atob(output.result);
|
|
13404
|
+
const bytes = new Uint8Array(binaryString.length);
|
|
13405
|
+
for (let i = 0; i < binaryString.length; i++) {
|
|
13406
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
13407
|
+
}
|
|
13408
|
+
const blob = new Blob([bytes], { type: contentType });
|
|
13409
|
+
const attachment = new Attachment({
|
|
13410
|
+
data: blob,
|
|
13411
|
+
filename,
|
|
13412
|
+
contentType
|
|
13413
|
+
});
|
|
13414
|
+
return {
|
|
13415
|
+
...output,
|
|
13416
|
+
result: attachment
|
|
13417
|
+
};
|
|
13418
|
+
}
|
|
13419
|
+
}
|
|
13420
|
+
return output;
|
|
13421
|
+
}
|
|
13222
13422
|
function parseSpanFromResponseParseParams(params) {
|
|
13223
13423
|
const spanArgs = {
|
|
13224
13424
|
name: "openai.responses.parse",
|
|
@@ -13242,7 +13442,7 @@ function parseSpanFromResponseParseParams(params) {
|
|
|
13242
13442
|
function parseEventFromResponseParseResult(result) {
|
|
13243
13443
|
const data = {};
|
|
13244
13444
|
if (result?.output !== void 0) {
|
|
13245
|
-
data.output = result.output;
|
|
13445
|
+
data.output = processImagesInOutput(result.output);
|
|
13246
13446
|
}
|
|
13247
13447
|
if (result) {
|
|
13248
13448
|
const { output, usage, ...metadata } = result;
|
|
@@ -13286,7 +13486,7 @@ function parseLogFromItem(item) {
|
|
|
13286
13486
|
case "response.completed":
|
|
13287
13487
|
const data = {};
|
|
13288
13488
|
if (response?.output !== void 0) {
|
|
13289
|
-
data.output = response.output;
|
|
13489
|
+
data.output = processImagesInOutput(response.output);
|
|
13290
13490
|
}
|
|
13291
13491
|
if (response) {
|
|
13292
13492
|
const { usage, output, ...metadata } = response;
|
|
@@ -13907,6 +14107,9 @@ function extractModelFromResult(result) {
|
|
|
13907
14107
|
}
|
|
13908
14108
|
return void 0;
|
|
13909
14109
|
}
|
|
14110
|
+
function extractModelFromWrapGenerateCallback(model) {
|
|
14111
|
+
return model?.modelId;
|
|
14112
|
+
}
|
|
13910
14113
|
function camelToSnake(str) {
|
|
13911
14114
|
return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
13912
14115
|
}
|
|
@@ -14079,7 +14282,11 @@ var V2_EXCLUDE_KEYS = /* @__PURE__ */ new Set([
|
|
|
14079
14282
|
]);
|
|
14080
14283
|
function BraintrustMiddleware(config = {}) {
|
|
14081
14284
|
return {
|
|
14082
|
-
wrapGenerate: async ({
|
|
14285
|
+
wrapGenerate: async ({
|
|
14286
|
+
doGenerate,
|
|
14287
|
+
params,
|
|
14288
|
+
model: modelFromWrapGenerate
|
|
14289
|
+
}) => {
|
|
14083
14290
|
const spanArgs = {
|
|
14084
14291
|
name: "ai-sdk.generateText",
|
|
14085
14292
|
spanAttributes: {
|
|
@@ -14106,6 +14313,13 @@ function BraintrustMiddleware(config = {}) {
|
|
|
14106
14313
|
const model = extractModelFromResult(result);
|
|
14107
14314
|
if (model !== void 0) {
|
|
14108
14315
|
metadata.model = model;
|
|
14316
|
+
} else if (modelFromWrapGenerate) {
|
|
14317
|
+
const modelId = extractModelFromWrapGenerateCallback(
|
|
14318
|
+
modelFromWrapGenerate
|
|
14319
|
+
);
|
|
14320
|
+
if (modelId) {
|
|
14321
|
+
metadata.model = modelId;
|
|
14322
|
+
}
|
|
14109
14323
|
}
|
|
14110
14324
|
let toolCalls = extractToolCallsFromSteps(result?.steps);
|
|
14111
14325
|
if (!toolCalls || toolCalls.length === 0) {
|
|
@@ -14755,6 +14969,146 @@ function wrapAISDK(ai) {
|
|
|
14755
14969
|
};
|
|
14756
14970
|
}
|
|
14757
14971
|
|
|
14972
|
+
// src/wrappers/mastra.ts
|
|
14973
|
+
var aiSDKFormatWarning = false;
|
|
14974
|
+
function wrapMastraAgent(agent, options) {
|
|
14975
|
+
const prefix = options?.name ?? options?.span_name ?? agent.name ?? "Agent";
|
|
14976
|
+
if (!hasAllMethods(agent)) {
|
|
14977
|
+
return agent;
|
|
14978
|
+
}
|
|
14979
|
+
if (agent.tools) {
|
|
14980
|
+
agent.__setTools(wrapTools(agent.tools));
|
|
14981
|
+
}
|
|
14982
|
+
return new Proxy(agent, {
|
|
14983
|
+
get(target, prop, receiver) {
|
|
14984
|
+
const value = Reflect.get(target, prop, receiver);
|
|
14985
|
+
if (prop === "generateVNext" && typeof value === "function") {
|
|
14986
|
+
return wrapGenerateVNext(value, target, prefix);
|
|
14987
|
+
}
|
|
14988
|
+
if (prop === "streamVNext" && typeof value === "function") {
|
|
14989
|
+
return wrapStreamVNext(value, target, prefix);
|
|
14990
|
+
}
|
|
14991
|
+
if (typeof value === "function") {
|
|
14992
|
+
return value.bind(target);
|
|
14993
|
+
}
|
|
14994
|
+
return value;
|
|
14995
|
+
}
|
|
14996
|
+
});
|
|
14997
|
+
}
|
|
14998
|
+
function hasAllMethods(a) {
|
|
14999
|
+
return typeof a.generateVNext === "function" && typeof a.streamVNext === "function";
|
|
15000
|
+
}
|
|
15001
|
+
function wrapGenerateVNext(original, target, prefix) {
|
|
15002
|
+
return function(...args) {
|
|
15003
|
+
const input = args[0];
|
|
15004
|
+
return traced(
|
|
15005
|
+
async (span) => {
|
|
15006
|
+
const result = await original.apply(target, args);
|
|
15007
|
+
const provider = detectProviderFromResult(result);
|
|
15008
|
+
const model = extractModelFromResult(result);
|
|
15009
|
+
const finishReason = normalizeFinishReason(result?.finishReason);
|
|
15010
|
+
const metrics = result?.usage ? normalizeUsageMetrics(
|
|
15011
|
+
result.usage,
|
|
15012
|
+
provider,
|
|
15013
|
+
result.providerMetadata
|
|
15014
|
+
) : {};
|
|
15015
|
+
span.log({
|
|
15016
|
+
input,
|
|
15017
|
+
output: result,
|
|
15018
|
+
metadata: {
|
|
15019
|
+
agent_name: target.name ?? prefix,
|
|
15020
|
+
...provider ? { provider } : {},
|
|
15021
|
+
...model ? { model } : {},
|
|
15022
|
+
...finishReason ? { finish_reason: finishReason } : {}
|
|
15023
|
+
},
|
|
15024
|
+
metrics
|
|
15025
|
+
});
|
|
15026
|
+
return result;
|
|
15027
|
+
},
|
|
15028
|
+
{
|
|
15029
|
+
name: `${prefix}.generateVNext`
|
|
15030
|
+
}
|
|
15031
|
+
);
|
|
15032
|
+
};
|
|
15033
|
+
}
|
|
15034
|
+
function wrapStreamVNext(original, target, prefix) {
|
|
15035
|
+
return function(...args) {
|
|
15036
|
+
const input = args[0];
|
|
15037
|
+
const span = startSpan({
|
|
15038
|
+
name: `${prefix}.streamVNext`,
|
|
15039
|
+
event: {
|
|
15040
|
+
input,
|
|
15041
|
+
metadata: {
|
|
15042
|
+
agent_name: target.name ?? prefix
|
|
15043
|
+
}
|
|
15044
|
+
}
|
|
15045
|
+
});
|
|
15046
|
+
const baseOpts = typeof args[1] === "object" && args[1] !== null ? args[1] : {};
|
|
15047
|
+
if (baseOpts.format && baseOpts.format !== "aisdk" && !aiSDKFormatWarning) {
|
|
15048
|
+
aiSDKFormatWarning = true;
|
|
15049
|
+
console.warn(
|
|
15050
|
+
`Braintrust Mastra wrapper: For best compatibility, use { format: 'aisdk' } (AI SDK v5) instead of format: '${baseOpts.format}'. See https://mastra.ai/en/docs/frameworks/agentic-uis/ai-sdk for more details.`
|
|
15051
|
+
);
|
|
15052
|
+
}
|
|
15053
|
+
const wrappedOpts = {
|
|
15054
|
+
...baseOpts,
|
|
15055
|
+
format: baseOpts.format || "aisdk"
|
|
15056
|
+
// Default to AI SDK v5 format if not specified
|
|
15057
|
+
};
|
|
15058
|
+
const userOnChunk = baseOpts?.onChunk;
|
|
15059
|
+
const userOnFinish = baseOpts?.onFinish;
|
|
15060
|
+
const userOnError = baseOpts?.onError;
|
|
15061
|
+
const startTime = Date.now();
|
|
15062
|
+
let receivedFirst = false;
|
|
15063
|
+
wrappedOpts.onChunk = (chunk) => {
|
|
15064
|
+
try {
|
|
15065
|
+
userOnChunk?.(chunk);
|
|
15066
|
+
} finally {
|
|
15067
|
+
if (!receivedFirst) {
|
|
15068
|
+
receivedFirst = true;
|
|
15069
|
+
span.log({
|
|
15070
|
+
metrics: { time_to_first_token: (Date.now() - startTime) / 1e3 }
|
|
15071
|
+
});
|
|
15072
|
+
}
|
|
15073
|
+
}
|
|
15074
|
+
};
|
|
15075
|
+
wrappedOpts.onFinish = async (event) => {
|
|
15076
|
+
try {
|
|
15077
|
+
await userOnFinish?.(event);
|
|
15078
|
+
} finally {
|
|
15079
|
+
const e = event;
|
|
15080
|
+
const provider = detectProviderFromResult(e);
|
|
15081
|
+
const model = extractModelFromResult(e);
|
|
15082
|
+
const finishReason = normalizeFinishReason(e?.finishReason);
|
|
15083
|
+
const metrics = e?.usage ? normalizeUsageMetrics(e.usage, provider, e.providerMetadata) : {};
|
|
15084
|
+
span.log({
|
|
15085
|
+
output: e.text ?? e.content ?? e,
|
|
15086
|
+
metadata: {
|
|
15087
|
+
agent_name: target.name ?? prefix,
|
|
15088
|
+
...provider ? { provider } : {},
|
|
15089
|
+
...model ? { model } : {},
|
|
15090
|
+
...finishReason ? { finish_reason: finishReason } : {}
|
|
15091
|
+
},
|
|
15092
|
+
metrics
|
|
15093
|
+
});
|
|
15094
|
+
span.end();
|
|
15095
|
+
}
|
|
15096
|
+
};
|
|
15097
|
+
wrappedOpts.onError = async (err) => {
|
|
15098
|
+
try {
|
|
15099
|
+
await userOnError?.(err);
|
|
15100
|
+
} finally {
|
|
15101
|
+
logError(span, err);
|
|
15102
|
+
span.end();
|
|
15103
|
+
}
|
|
15104
|
+
};
|
|
15105
|
+
return withCurrent(
|
|
15106
|
+
span,
|
|
15107
|
+
() => original.apply(target, [args[0], wrappedOpts, ...args.slice(2)])
|
|
15108
|
+
);
|
|
15109
|
+
};
|
|
15110
|
+
}
|
|
15111
|
+
|
|
14758
15112
|
// src/wrappers/anthropic.ts
|
|
14759
15113
|
function wrapAnthropic(anthropic) {
|
|
14760
15114
|
const au = anthropic;
|
|
@@ -14955,7 +15309,7 @@ function streamNextProxy(stream, sspan) {
|
|
|
14955
15309
|
};
|
|
14956
15310
|
}
|
|
14957
15311
|
function parseEventFromMessage(message) {
|
|
14958
|
-
const output = message
|
|
15312
|
+
const output = message ? { role: message.role, content: message.content } : null;
|
|
14959
15313
|
const metrics = parseMetricsFromUsage2(message?.usage);
|
|
14960
15314
|
const metas = ["stop_reason", "stop_sequence"];
|
|
14961
15315
|
const metadata = {};
|
|
@@ -14995,6 +15349,282 @@ function coalesceInput(messages, system) {
|
|
|
14995
15349
|
return input;
|
|
14996
15350
|
}
|
|
14997
15351
|
|
|
15352
|
+
// src/wrappers/claude-agent-sdk.ts
|
|
15353
|
+
function filterSerializableOptions(options) {
|
|
15354
|
+
const allowedKeys = [
|
|
15355
|
+
"model",
|
|
15356
|
+
"maxTurns",
|
|
15357
|
+
"cwd",
|
|
15358
|
+
"continue",
|
|
15359
|
+
"allowedTools",
|
|
15360
|
+
"disallowedTools",
|
|
15361
|
+
"additionalDirectories",
|
|
15362
|
+
"permissionMode",
|
|
15363
|
+
"debug",
|
|
15364
|
+
"apiKey",
|
|
15365
|
+
"apiKeySource",
|
|
15366
|
+
"agentName",
|
|
15367
|
+
"instructions"
|
|
15368
|
+
];
|
|
15369
|
+
const filtered = {};
|
|
15370
|
+
for (const key of allowedKeys) {
|
|
15371
|
+
if (options[key] !== void 0) {
|
|
15372
|
+
filtered[key] = options[key];
|
|
15373
|
+
}
|
|
15374
|
+
}
|
|
15375
|
+
return filtered;
|
|
15376
|
+
}
|
|
15377
|
+
function wrapClaudeAgentQuery(queryFn, defaultThis) {
|
|
15378
|
+
const proxy = new Proxy(queryFn, {
|
|
15379
|
+
apply(target, thisArg, argArray) {
|
|
15380
|
+
const params = argArray[0] ?? {};
|
|
15381
|
+
const { prompt, options = {} } = params;
|
|
15382
|
+
const span = startSpan({
|
|
15383
|
+
name: "Claude Agent",
|
|
15384
|
+
spanAttributes: {
|
|
15385
|
+
type: "task" /* TASK */
|
|
15386
|
+
},
|
|
15387
|
+
event: {
|
|
15388
|
+
input: typeof prompt === "string" ? prompt : { type: "streaming", description: "AsyncIterable<SDKMessage>" },
|
|
15389
|
+
metadata: filterSerializableOptions(options)
|
|
15390
|
+
}
|
|
15391
|
+
});
|
|
15392
|
+
const finalResults = [];
|
|
15393
|
+
let finalUsageMetrics;
|
|
15394
|
+
let accumulatedOutputTokens = 0;
|
|
15395
|
+
let currentMessageId;
|
|
15396
|
+
let currentMessageStartTime = getCurrentUnixTimestamp();
|
|
15397
|
+
const currentMessages = [];
|
|
15398
|
+
const createLLMSpan = async () => {
|
|
15399
|
+
const finalMessageContent = await _createLLMSpanForMessages(
|
|
15400
|
+
currentMessages,
|
|
15401
|
+
prompt,
|
|
15402
|
+
finalResults,
|
|
15403
|
+
options,
|
|
15404
|
+
currentMessageStartTime,
|
|
15405
|
+
await span.export()
|
|
15406
|
+
);
|
|
15407
|
+
if (finalMessageContent) {
|
|
15408
|
+
finalResults.push(finalMessageContent);
|
|
15409
|
+
}
|
|
15410
|
+
const lastMessage = currentMessages[currentMessages.length - 1];
|
|
15411
|
+
if (lastMessage?.message?.usage) {
|
|
15412
|
+
const outputTokens = getNumberProperty(lastMessage.message.usage, "output_tokens") || 0;
|
|
15413
|
+
accumulatedOutputTokens += outputTokens;
|
|
15414
|
+
}
|
|
15415
|
+
currentMessages.length = 0;
|
|
15416
|
+
};
|
|
15417
|
+
const wrappedGenerator = async function* () {
|
|
15418
|
+
try {
|
|
15419
|
+
const invocationTarget = thisArg === proxy || thisArg === void 0 ? defaultThis ?? thisArg : thisArg;
|
|
15420
|
+
const generator = withCurrent(
|
|
15421
|
+
span,
|
|
15422
|
+
() => Reflect.apply(target, invocationTarget, argArray)
|
|
15423
|
+
);
|
|
15424
|
+
for await (const message of generator) {
|
|
15425
|
+
const currentTime = getCurrentUnixTimestamp();
|
|
15426
|
+
const messageId = message.message?.id;
|
|
15427
|
+
if (messageId && messageId !== currentMessageId) {
|
|
15428
|
+
await createLLMSpan();
|
|
15429
|
+
currentMessageId = messageId;
|
|
15430
|
+
currentMessageStartTime = currentTime;
|
|
15431
|
+
}
|
|
15432
|
+
if (message.type === "assistant" && message.message?.usage) {
|
|
15433
|
+
currentMessages.push(message);
|
|
15434
|
+
}
|
|
15435
|
+
if (message.type === "result" && message.usage) {
|
|
15436
|
+
finalUsageMetrics = _extractUsageFromMessage(message);
|
|
15437
|
+
if (currentMessages.length > 0 && finalUsageMetrics.completion_tokens !== void 0) {
|
|
15438
|
+
const lastMessage = currentMessages[currentMessages.length - 1];
|
|
15439
|
+
if (lastMessage?.message?.usage) {
|
|
15440
|
+
const adjustedTokens = finalUsageMetrics.completion_tokens - accumulatedOutputTokens;
|
|
15441
|
+
if (adjustedTokens >= 0) {
|
|
15442
|
+
lastMessage.message.usage.output_tokens = adjustedTokens;
|
|
15443
|
+
}
|
|
15444
|
+
}
|
|
15445
|
+
}
|
|
15446
|
+
const result_metadata = {};
|
|
15447
|
+
if (message.num_turns !== void 0) {
|
|
15448
|
+
result_metadata.num_turns = message.num_turns;
|
|
15449
|
+
}
|
|
15450
|
+
if (message.session_id !== void 0) {
|
|
15451
|
+
result_metadata.session_id = message.session_id;
|
|
15452
|
+
}
|
|
15453
|
+
if (Object.keys(result_metadata).length > 0) {
|
|
15454
|
+
span.log({
|
|
15455
|
+
metadata: result_metadata
|
|
15456
|
+
});
|
|
15457
|
+
}
|
|
15458
|
+
}
|
|
15459
|
+
yield message;
|
|
15460
|
+
}
|
|
15461
|
+
await createLLMSpan();
|
|
15462
|
+
span.log({
|
|
15463
|
+
output: finalResults.length > 0 ? finalResults[finalResults.length - 1] : void 0
|
|
15464
|
+
});
|
|
15465
|
+
} catch (error2) {
|
|
15466
|
+
span.log({
|
|
15467
|
+
error: error2 instanceof Error ? error2.message : String(error2)
|
|
15468
|
+
});
|
|
15469
|
+
throw error2;
|
|
15470
|
+
} finally {
|
|
15471
|
+
span.end();
|
|
15472
|
+
}
|
|
15473
|
+
}();
|
|
15474
|
+
return wrappedGenerator;
|
|
15475
|
+
}
|
|
15476
|
+
});
|
|
15477
|
+
return proxy;
|
|
15478
|
+
}
|
|
15479
|
+
function wrapClaudeAgentTool(toolDef) {
|
|
15480
|
+
const originalHandler = toolDef.handler;
|
|
15481
|
+
const wrappedHandler = (args, extra) => traced(
|
|
15482
|
+
async (span) => {
|
|
15483
|
+
span.log({
|
|
15484
|
+
input: args,
|
|
15485
|
+
metadata: {
|
|
15486
|
+
tool_name: toolDef.name,
|
|
15487
|
+
tool_description: toolDef.description
|
|
15488
|
+
}
|
|
15489
|
+
});
|
|
15490
|
+
const result = await originalHandler(args, extra);
|
|
15491
|
+
span.log({
|
|
15492
|
+
output: result
|
|
15493
|
+
});
|
|
15494
|
+
return result;
|
|
15495
|
+
},
|
|
15496
|
+
{
|
|
15497
|
+
name: `${toolDef.name}`,
|
|
15498
|
+
spanAttributes: {
|
|
15499
|
+
type: "tool" /* TOOL */
|
|
15500
|
+
}
|
|
15501
|
+
}
|
|
15502
|
+
);
|
|
15503
|
+
return {
|
|
15504
|
+
...toolDef,
|
|
15505
|
+
handler: wrappedHandler
|
|
15506
|
+
};
|
|
15507
|
+
}
|
|
15508
|
+
function _buildLLMInput(prompt, conversationHistory) {
|
|
15509
|
+
const promptMessage = typeof prompt === "string" ? { content: prompt, role: "user" } : void 0;
|
|
15510
|
+
const inputParts = [
|
|
15511
|
+
...promptMessage ? [promptMessage] : [],
|
|
15512
|
+
...conversationHistory
|
|
15513
|
+
];
|
|
15514
|
+
return inputParts.length > 0 ? inputParts : void 0;
|
|
15515
|
+
}
|
|
15516
|
+
function _extractUsageFromMessage(message) {
|
|
15517
|
+
const metrics = {};
|
|
15518
|
+
let usage;
|
|
15519
|
+
if (message.type === "assistant") {
|
|
15520
|
+
usage = message.message?.usage;
|
|
15521
|
+
} else if (message.type === "result") {
|
|
15522
|
+
usage = message.usage;
|
|
15523
|
+
}
|
|
15524
|
+
if (!usage || typeof usage !== "object") {
|
|
15525
|
+
return metrics;
|
|
15526
|
+
}
|
|
15527
|
+
const inputTokens = getNumberProperty(usage, "input_tokens");
|
|
15528
|
+
if (inputTokens !== void 0) {
|
|
15529
|
+
metrics.prompt_tokens = inputTokens;
|
|
15530
|
+
}
|
|
15531
|
+
const outputTokens = getNumberProperty(usage, "output_tokens");
|
|
15532
|
+
if (outputTokens !== void 0) {
|
|
15533
|
+
metrics.completion_tokens = outputTokens;
|
|
15534
|
+
}
|
|
15535
|
+
const cacheReadTokens = getNumberProperty(usage, "cache_read_input_tokens") || 0;
|
|
15536
|
+
const cacheCreationTokens = getNumberProperty(usage, "cache_creation_input_tokens") || 0;
|
|
15537
|
+
if (cacheReadTokens > 0 || cacheCreationTokens > 0) {
|
|
15538
|
+
const cacheTokens = extractAnthropicCacheTokens(
|
|
15539
|
+
cacheReadTokens,
|
|
15540
|
+
cacheCreationTokens
|
|
15541
|
+
);
|
|
15542
|
+
Object.assign(metrics, cacheTokens);
|
|
15543
|
+
}
|
|
15544
|
+
if (Object.keys(metrics).length > 0) {
|
|
15545
|
+
Object.assign(metrics, finalizeAnthropicTokens(metrics));
|
|
15546
|
+
}
|
|
15547
|
+
return metrics;
|
|
15548
|
+
}
|
|
15549
|
+
async function _createLLMSpanForMessages(messages, prompt, conversationHistory, options, startTime, parentSpan) {
|
|
15550
|
+
if (messages.length === 0) return void 0;
|
|
15551
|
+
const lastMessage = messages[messages.length - 1];
|
|
15552
|
+
if (lastMessage.type !== "assistant" || !lastMessage.message?.usage) {
|
|
15553
|
+
return void 0;
|
|
15554
|
+
}
|
|
15555
|
+
const model = lastMessage.message.model || options.model;
|
|
15556
|
+
const usage = _extractUsageFromMessage(lastMessage);
|
|
15557
|
+
const input = _buildLLMInput(prompt, conversationHistory);
|
|
15558
|
+
const outputs = messages.map(
|
|
15559
|
+
(m) => m.message?.content && m.message?.role ? { content: m.message.content, role: m.message.role } : void 0
|
|
15560
|
+
).filter((c) => c !== void 0);
|
|
15561
|
+
await traced(
|
|
15562
|
+
(llmSpan) => {
|
|
15563
|
+
llmSpan.log({
|
|
15564
|
+
input,
|
|
15565
|
+
output: outputs,
|
|
15566
|
+
metadata: model ? { model } : void 0,
|
|
15567
|
+
metrics: usage
|
|
15568
|
+
});
|
|
15569
|
+
},
|
|
15570
|
+
{
|
|
15571
|
+
name: "anthropic.messages.create",
|
|
15572
|
+
spanAttributes: {
|
|
15573
|
+
type: "llm" /* LLM */
|
|
15574
|
+
},
|
|
15575
|
+
startTime,
|
|
15576
|
+
parent: parentSpan
|
|
15577
|
+
}
|
|
15578
|
+
);
|
|
15579
|
+
return lastMessage.message?.content && lastMessage.message?.role ? { content: lastMessage.message.content, role: lastMessage.message.role } : void 0;
|
|
15580
|
+
}
|
|
15581
|
+
function wrapClaudeAgentSDK(sdk) {
|
|
15582
|
+
const cache = /* @__PURE__ */ new Map();
|
|
15583
|
+
return new Proxy(sdk, {
|
|
15584
|
+
get(target, prop, receiver) {
|
|
15585
|
+
if (cache.has(prop)) {
|
|
15586
|
+
return cache.get(prop);
|
|
15587
|
+
}
|
|
15588
|
+
const value = Reflect.get(target, prop, receiver);
|
|
15589
|
+
if (prop === "query" && typeof value === "function") {
|
|
15590
|
+
const wrappedQuery = wrapClaudeAgentQuery(
|
|
15591
|
+
value,
|
|
15592
|
+
target
|
|
15593
|
+
);
|
|
15594
|
+
cache.set(prop, wrappedQuery);
|
|
15595
|
+
return wrappedQuery;
|
|
15596
|
+
}
|
|
15597
|
+
if (prop === "tool" && typeof value === "function") {
|
|
15598
|
+
const toolFn = value;
|
|
15599
|
+
const wrappedToolFactory = new Proxy(toolFn, {
|
|
15600
|
+
apply(toolTarget, thisArg, argArray) {
|
|
15601
|
+
const invocationTarget = thisArg === receiver || thisArg === void 0 ? target : thisArg;
|
|
15602
|
+
const toolDef = Reflect.apply(
|
|
15603
|
+
toolTarget,
|
|
15604
|
+
invocationTarget,
|
|
15605
|
+
argArray
|
|
15606
|
+
);
|
|
15607
|
+
if (toolDef && typeof toolDef === "object" && "handler" in toolDef) {
|
|
15608
|
+
return wrapClaudeAgentTool(
|
|
15609
|
+
toolDef
|
|
15610
|
+
);
|
|
15611
|
+
}
|
|
15612
|
+
return toolDef;
|
|
15613
|
+
}
|
|
15614
|
+
});
|
|
15615
|
+
cache.set(prop, wrappedToolFactory);
|
|
15616
|
+
return wrappedToolFactory;
|
|
15617
|
+
}
|
|
15618
|
+
if (typeof value === "function") {
|
|
15619
|
+
const bound = value.bind(target);
|
|
15620
|
+
cache.set(prop, bound);
|
|
15621
|
+
return bound;
|
|
15622
|
+
}
|
|
15623
|
+
return value;
|
|
15624
|
+
}
|
|
15625
|
+
});
|
|
15626
|
+
}
|
|
15627
|
+
|
|
14998
15628
|
// src/otel.ts
|
|
14999
15629
|
var otelApi = null;
|
|
15000
15630
|
var otelSdk = null;
|
|
@@ -15256,44 +15886,44 @@ var BraintrustExporter = class _BraintrustExporter {
|
|
|
15256
15886
|
};
|
|
15257
15887
|
|
|
15258
15888
|
// dev/types.ts
|
|
15259
|
-
import { z as
|
|
15260
|
-
var evalBodySchema =
|
|
15261
|
-
name:
|
|
15262
|
-
parameters:
|
|
15889
|
+
import { z as z11 } from "zod/v3";
|
|
15890
|
+
var evalBodySchema = z11.object({
|
|
15891
|
+
name: z11.string(),
|
|
15892
|
+
parameters: z11.record(z11.string(), z11.unknown()).nullish(),
|
|
15263
15893
|
data: RunEval.shape.data,
|
|
15264
|
-
scores:
|
|
15265
|
-
|
|
15894
|
+
scores: z11.array(
|
|
15895
|
+
z11.object({
|
|
15266
15896
|
function_id: FunctionId,
|
|
15267
|
-
name:
|
|
15897
|
+
name: z11.string()
|
|
15268
15898
|
})
|
|
15269
15899
|
).nullish(),
|
|
15270
|
-
experiment_name:
|
|
15271
|
-
project_id:
|
|
15900
|
+
experiment_name: z11.string().nullish(),
|
|
15901
|
+
project_id: z11.string().nullish(),
|
|
15272
15902
|
parent: InvokeParent.optional(),
|
|
15273
|
-
stream:
|
|
15903
|
+
stream: z11.boolean().optional()
|
|
15274
15904
|
});
|
|
15275
|
-
var evalParametersSerializedSchema =
|
|
15276
|
-
|
|
15277
|
-
|
|
15278
|
-
|
|
15279
|
-
type:
|
|
15905
|
+
var evalParametersSerializedSchema = z11.record(
|
|
15906
|
+
z11.string(),
|
|
15907
|
+
z11.union([
|
|
15908
|
+
z11.object({
|
|
15909
|
+
type: z11.literal("prompt"),
|
|
15280
15910
|
default: PromptData.optional(),
|
|
15281
|
-
description:
|
|
15911
|
+
description: z11.string().optional()
|
|
15282
15912
|
}),
|
|
15283
|
-
|
|
15284
|
-
type:
|
|
15285
|
-
schema:
|
|
15913
|
+
z11.object({
|
|
15914
|
+
type: z11.literal("data"),
|
|
15915
|
+
schema: z11.record(z11.unknown()),
|
|
15286
15916
|
// JSON Schema
|
|
15287
|
-
default:
|
|
15288
|
-
description:
|
|
15917
|
+
default: z11.unknown().optional(),
|
|
15918
|
+
description: z11.string().optional()
|
|
15289
15919
|
})
|
|
15290
15920
|
])
|
|
15291
15921
|
);
|
|
15292
|
-
var evaluatorDefinitionSchema =
|
|
15922
|
+
var evaluatorDefinitionSchema = z11.object({
|
|
15293
15923
|
parameters: evalParametersSerializedSchema.optional()
|
|
15294
15924
|
});
|
|
15295
|
-
var evaluatorDefinitionsSchema =
|
|
15296
|
-
|
|
15925
|
+
var evaluatorDefinitionsSchema = z11.record(
|
|
15926
|
+
z11.string(),
|
|
15297
15927
|
evaluatorDefinitionSchema
|
|
15298
15928
|
);
|
|
15299
15929
|
|
|
@@ -15319,6 +15949,7 @@ export {
|
|
|
15319
15949
|
Experiment2 as Experiment,
|
|
15320
15950
|
ExternalAttachment,
|
|
15321
15951
|
FailedHTTPResponse,
|
|
15952
|
+
IDGenerator,
|
|
15322
15953
|
INTERNAL_BTQL_LIMIT,
|
|
15323
15954
|
LEGACY_CACHED_HEADER,
|
|
15324
15955
|
LazyValue,
|
|
@@ -15326,6 +15957,7 @@ export {
|
|
|
15326
15957
|
NOOP_SPAN,
|
|
15327
15958
|
NOOP_SPAN_PERMALINK,
|
|
15328
15959
|
NoopSpan,
|
|
15960
|
+
OTELIDGenerator,
|
|
15329
15961
|
Project2 as Project,
|
|
15330
15962
|
ProjectNameIdMap,
|
|
15331
15963
|
Prompt2 as Prompt,
|
|
@@ -15337,6 +15969,7 @@ export {
|
|
|
15337
15969
|
SpanImpl,
|
|
15338
15970
|
TestBackgroundLogger,
|
|
15339
15971
|
ToolBuilder,
|
|
15972
|
+
UUIDGenerator,
|
|
15340
15973
|
X_CACHED_HEADER,
|
|
15341
15974
|
_exportsForTestingOnly,
|
|
15342
15975
|
_internalGetGlobalState,
|
|
@@ -15347,6 +15980,7 @@ export {
|
|
|
15347
15980
|
currentExperiment,
|
|
15348
15981
|
currentLogger,
|
|
15349
15982
|
currentSpan,
|
|
15983
|
+
deepCopyEvent,
|
|
15350
15984
|
index_default as default,
|
|
15351
15985
|
defaultErrorScoreHandler,
|
|
15352
15986
|
deserializePlainStringAsJSON,
|
|
@@ -15354,6 +15988,7 @@ export {
|
|
|
15354
15988
|
evaluatorDefinitionSchema,
|
|
15355
15989
|
evaluatorDefinitionsSchema,
|
|
15356
15990
|
flush,
|
|
15991
|
+
getIdGenerator,
|
|
15357
15992
|
getPromptVersions,
|
|
15358
15993
|
getSpanParentObject,
|
|
15359
15994
|
graph_framework_exports as graph,
|
|
@@ -15397,6 +16032,8 @@ export {
|
|
|
15397
16032
|
wrapAISDK,
|
|
15398
16033
|
wrapAISDKModel,
|
|
15399
16034
|
wrapAnthropic,
|
|
16035
|
+
wrapClaudeAgentSDK,
|
|
16036
|
+
wrapMastraAgent,
|
|
15400
16037
|
wrapOpenAI,
|
|
15401
16038
|
wrapOpenAIv4,
|
|
15402
16039
|
wrapTraced
|