braintrust 0.3.8 → 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 +21 -2
- package/dev/dist/index.d.ts +21 -2
- package/dev/dist/index.js +385 -123
- package/dev/dist/index.mjs +1291 -1029
- package/dist/browser.d.mts +23 -2
- package/dist/browser.d.ts +23 -2
- package/dist/browser.js +204 -110
- package/dist/browser.mjs +1079 -985
- package/dist/cli.js +1336 -1073
- package/dist/index.d.mts +86 -4
- package/dist/index.d.ts +86 -4
- package/dist/index.js +580 -186
- package/dist/index.mjs +1436 -1042
- package/package.json +4 -3
- package/util/dist/index.d.mts +66 -3
- package/util/dist/index.d.ts +66 -3
- 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 {
|
|
@@ -6501,14 +6574,14 @@ var NoopSpan = class {
|
|
|
6501
6574
|
};
|
|
6502
6575
|
var NOOP_SPAN = new NoopSpan();
|
|
6503
6576
|
var NOOP_SPAN_PERMALINK = "https://braintrust.dev/noop-span";
|
|
6504
|
-
var loginSchema =
|
|
6505
|
-
appUrl:
|
|
6506
|
-
appPublicUrl:
|
|
6507
|
-
orgName:
|
|
6508
|
-
apiUrl:
|
|
6509
|
-
proxyUrl:
|
|
6510
|
-
loginToken:
|
|
6511
|
-
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(),
|
|
6512
6585
|
gitMetadataSettings: GitMetadataSettings.nullish()
|
|
6513
6586
|
});
|
|
6514
6587
|
var stateNonce = 0;
|
|
@@ -6567,6 +6640,7 @@ var BraintrustState = class _BraintrustState {
|
|
|
6567
6640
|
_apiConn = null;
|
|
6568
6641
|
_proxyConn = null;
|
|
6569
6642
|
promptCache;
|
|
6643
|
+
_idGenerator = null;
|
|
6570
6644
|
resetLoginInfo() {
|
|
6571
6645
|
this.appUrl = null;
|
|
6572
6646
|
this.appPublicUrl = null;
|
|
@@ -6581,6 +6655,15 @@ var BraintrustState = class _BraintrustState {
|
|
|
6581
6655
|
this._apiConn = null;
|
|
6582
6656
|
this._proxyConn = null;
|
|
6583
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
|
+
}
|
|
6584
6667
|
copyLoginInfo(other) {
|
|
6585
6668
|
this.appUrl = other.appUrl;
|
|
6586
6669
|
this.appPublicUrl = other.appPublicUrl;
|
|
@@ -7027,9 +7110,9 @@ var Attachment = class extends BaseAttachment {
|
|
|
7027
7110
|
let signedUrl;
|
|
7028
7111
|
let headers;
|
|
7029
7112
|
try {
|
|
7030
|
-
({ signedUrl, headers } =
|
|
7031
|
-
signedUrl:
|
|
7032
|
-
headers:
|
|
7113
|
+
({ signedUrl, headers } = z8.object({
|
|
7114
|
+
signedUrl: z8.string().url(),
|
|
7115
|
+
headers: z8.record(z8.string())
|
|
7033
7116
|
}).parse(await metadataResponse.json()));
|
|
7034
7117
|
} catch (error2) {
|
|
7035
7118
|
if (error2 instanceof ZodError) {
|
|
@@ -7184,8 +7267,8 @@ var ExternalAttachment = class extends BaseAttachment {
|
|
|
7184
7267
|
});
|
|
7185
7268
|
}
|
|
7186
7269
|
};
|
|
7187
|
-
var attachmentMetadataSchema =
|
|
7188
|
-
downloadUrl:
|
|
7270
|
+
var attachmentMetadataSchema = z8.object({
|
|
7271
|
+
downloadUrl: z8.string(),
|
|
7189
7272
|
status: AttachmentStatus
|
|
7190
7273
|
});
|
|
7191
7274
|
var ReadonlyAttachment = class {
|
|
@@ -7323,7 +7406,7 @@ function logFeedbackImpl(state, parentObjectType, parentObjectId, {
|
|
|
7323
7406
|
if (!isEmpty(comment)) {
|
|
7324
7407
|
const record = new LazyValue(async () => {
|
|
7325
7408
|
return {
|
|
7326
|
-
id:
|
|
7409
|
+
id: uuidv42(),
|
|
7327
7410
|
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
7328
7411
|
origin: {
|
|
7329
7412
|
// NOTE: We do not know (or care?) what the transaction id of the row that
|
|
@@ -8113,7 +8196,7 @@ Error: ${errorText}`;
|
|
|
8113
8196
|
}
|
|
8114
8197
|
const payloadFile = isomorph_default.pathJoin(
|
|
8115
8198
|
payloadDir,
|
|
8116
|
-
`payload_${getCurrentUnixTimestamp()}_${
|
|
8199
|
+
`payload_${getCurrentUnixTimestamp()}_${uuidv42().slice(0, 8)}.json`
|
|
8117
8200
|
);
|
|
8118
8201
|
try {
|
|
8119
8202
|
await isomorph_default.mkdir(payloadDir, { recursive: true });
|
|
@@ -9165,7 +9248,7 @@ function validateAndSanitizeExperimentLogPartialArgs(event) {
|
|
|
9165
9248
|
function deepCopyEvent(event) {
|
|
9166
9249
|
const attachments = [];
|
|
9167
9250
|
const IDENTIFIER = "_bt_internal_saved_attachment";
|
|
9168
|
-
const savedAttachmentSchema =
|
|
9251
|
+
const savedAttachmentSchema = z8.strictObject({ [IDENTIFIER]: z8.number() });
|
|
9169
9252
|
const serialized = JSON.stringify(event, (_k, v) => {
|
|
9170
9253
|
if (v instanceof SpanImpl || v instanceof NoopSpan) {
|
|
9171
9254
|
return `<span>`;
|
|
@@ -9668,7 +9751,7 @@ var ReadonlyExperiment = class extends ObjectFetcher {
|
|
|
9668
9751
|
};
|
|
9669
9752
|
var executionCounter = 0;
|
|
9670
9753
|
function newId() {
|
|
9671
|
-
return
|
|
9754
|
+
return uuidv42();
|
|
9672
9755
|
}
|
|
9673
9756
|
var SpanImpl = class _SpanImpl {
|
|
9674
9757
|
_state;
|
|
@@ -9724,13 +9807,17 @@ var SpanImpl = class _SpanImpl {
|
|
|
9724
9807
|
},
|
|
9725
9808
|
created: (/* @__PURE__ */ new Date()).toISOString()
|
|
9726
9809
|
};
|
|
9727
|
-
this._id = eventId ??
|
|
9728
|
-
this._spanId = args.spanId ??
|
|
9810
|
+
this._id = eventId ?? this._state.idGenerator.getSpanId();
|
|
9811
|
+
this._spanId = args.spanId ?? this._state.idGenerator.getSpanId();
|
|
9729
9812
|
if (args.parentSpanIds) {
|
|
9730
9813
|
this._rootSpanId = args.parentSpanIds.rootSpanId;
|
|
9731
9814
|
this._spanParents = "parentSpanIds" in args.parentSpanIds ? args.parentSpanIds.parentSpanIds : [args.parentSpanIds.spanId];
|
|
9732
9815
|
} else {
|
|
9733
|
-
this.
|
|
9816
|
+
if (this._state.idGenerator.shareRootSpanId()) {
|
|
9817
|
+
this._rootSpanId = this._spanId;
|
|
9818
|
+
} else {
|
|
9819
|
+
this._rootSpanId = this._state.idGenerator.getTraceId();
|
|
9820
|
+
}
|
|
9734
9821
|
this._spanParents = void 0;
|
|
9735
9822
|
}
|
|
9736
9823
|
this.isMerge = false;
|
|
@@ -10106,7 +10193,7 @@ var Dataset2 = class extends ObjectFetcher {
|
|
|
10106
10193
|
output
|
|
10107
10194
|
}) {
|
|
10108
10195
|
this.validateEvent({ metadata, expected, output, tags });
|
|
10109
|
-
const rowId = id ||
|
|
10196
|
+
const rowId = id || uuidv42();
|
|
10110
10197
|
const args = this.createArgs(
|
|
10111
10198
|
deepCopyEvent({
|
|
10112
10199
|
id: rowId,
|
|
@@ -10184,8 +10271,8 @@ var Dataset2 = class extends ObjectFetcher {
|
|
|
10184
10271
|
)}`;
|
|
10185
10272
|
let dataSummary;
|
|
10186
10273
|
if (summarizeData) {
|
|
10187
|
-
const rawDataSummary =
|
|
10188
|
-
total_records:
|
|
10274
|
+
const rawDataSummary = z8.object({
|
|
10275
|
+
total_records: z8.number()
|
|
10189
10276
|
}).parse(
|
|
10190
10277
|
await state.apiConn().get_json(
|
|
10191
10278
|
"dataset-summary",
|
|
@@ -10308,11 +10395,11 @@ function renderTemplatedObject(obj, args, options) {
|
|
|
10308
10395
|
return obj;
|
|
10309
10396
|
}
|
|
10310
10397
|
function renderPromptParams(params, args, options) {
|
|
10311
|
-
const schemaParsed =
|
|
10312
|
-
response_format:
|
|
10313
|
-
type:
|
|
10398
|
+
const schemaParsed = z8.object({
|
|
10399
|
+
response_format: z8.object({
|
|
10400
|
+
type: z8.literal("json_schema"),
|
|
10314
10401
|
json_schema: ResponseFormatJsonSchema.omit({ schema: true }).extend({
|
|
10315
|
-
schema:
|
|
10402
|
+
schema: z8.unknown()
|
|
10316
10403
|
})
|
|
10317
10404
|
})
|
|
10318
10405
|
}).safeParse(params);
|
|
@@ -10430,7 +10517,7 @@ var Prompt2 = class _Prompt {
|
|
|
10430
10517
|
if (!prompt) {
|
|
10431
10518
|
throw new Error("Empty prompt");
|
|
10432
10519
|
}
|
|
10433
|
-
const dictArgParsed =
|
|
10520
|
+
const dictArgParsed = z8.record(z8.unknown()).safeParse(buildArgs);
|
|
10434
10521
|
const variables = {
|
|
10435
10522
|
input: buildArgs,
|
|
10436
10523
|
...dictArgParsed.success ? dictArgParsed.data : {}
|
|
@@ -10485,7 +10572,7 @@ var Prompt2 = class _Prompt {
|
|
|
10485
10572
|
return JSON.stringify(v);
|
|
10486
10573
|
}
|
|
10487
10574
|
};
|
|
10488
|
-
const dictArgParsed =
|
|
10575
|
+
const dictArgParsed = z8.record(z8.unknown()).safeParse(buildArgs);
|
|
10489
10576
|
const variables = {
|
|
10490
10577
|
input: buildArgs,
|
|
10491
10578
|
...dictArgParsed.success ? dictArgParsed.data : {}
|
|
@@ -10626,6 +10713,12 @@ async function getPromptVersions(projectId, promptId) {
|
|
|
10626
10713
|
(entry) => ["upsert", "merge"].includes(entry.audit_data?.action)
|
|
10627
10714
|
).map((entry) => prettifyXact(entry._xact_id)) || [];
|
|
10628
10715
|
}
|
|
10716
|
+
function resetIdGenStateForTests() {
|
|
10717
|
+
const state = _internalGetGlobalState();
|
|
10718
|
+
if (state) {
|
|
10719
|
+
state.resetIdGenState();
|
|
10720
|
+
}
|
|
10721
|
+
}
|
|
10629
10722
|
var _exportsForTestingOnly = {
|
|
10630
10723
|
extractAttachments,
|
|
10631
10724
|
deepCopyEvent,
|
|
@@ -10636,7 +10729,8 @@ var _exportsForTestingOnly = {
|
|
|
10636
10729
|
setInitialTestState,
|
|
10637
10730
|
initTestExperiment,
|
|
10638
10731
|
isGeneratorFunction,
|
|
10639
|
-
isAsyncGeneratorFunction
|
|
10732
|
+
isAsyncGeneratorFunction,
|
|
10733
|
+
resetIdGenStateForTests
|
|
10640
10734
|
};
|
|
10641
10735
|
|
|
10642
10736
|
// src/node.ts
|
|
@@ -10689,6 +10783,7 @@ __export(exports_node_exports, {
|
|
|
10689
10783
|
Experiment: () => Experiment2,
|
|
10690
10784
|
ExternalAttachment: () => ExternalAttachment,
|
|
10691
10785
|
FailedHTTPResponse: () => FailedHTTPResponse,
|
|
10786
|
+
IDGenerator: () => IDGenerator,
|
|
10692
10787
|
INTERNAL_BTQL_LIMIT: () => INTERNAL_BTQL_LIMIT,
|
|
10693
10788
|
LEGACY_CACHED_HEADER: () => LEGACY_CACHED_HEADER,
|
|
10694
10789
|
LazyValue: () => LazyValue,
|
|
@@ -10696,6 +10791,7 @@ __export(exports_node_exports, {
|
|
|
10696
10791
|
NOOP_SPAN: () => NOOP_SPAN,
|
|
10697
10792
|
NOOP_SPAN_PERMALINK: () => NOOP_SPAN_PERMALINK,
|
|
10698
10793
|
NoopSpan: () => NoopSpan,
|
|
10794
|
+
OTELIDGenerator: () => OTELIDGenerator,
|
|
10699
10795
|
Project: () => Project2,
|
|
10700
10796
|
ProjectNameIdMap: () => ProjectNameIdMap,
|
|
10701
10797
|
Prompt: () => Prompt2,
|
|
@@ -10707,6 +10803,7 @@ __export(exports_node_exports, {
|
|
|
10707
10803
|
SpanImpl: () => SpanImpl,
|
|
10708
10804
|
TestBackgroundLogger: () => TestBackgroundLogger,
|
|
10709
10805
|
ToolBuilder: () => ToolBuilder,
|
|
10806
|
+
UUIDGenerator: () => UUIDGenerator,
|
|
10710
10807
|
X_CACHED_HEADER: () => X_CACHED_HEADER,
|
|
10711
10808
|
_exportsForTestingOnly: () => _exportsForTestingOnly,
|
|
10712
10809
|
_internalGetGlobalState: () => _internalGetGlobalState,
|
|
@@ -10722,6 +10819,7 @@ __export(exports_node_exports, {
|
|
|
10722
10819
|
deserializePlainStringAsJSON: () => deserializePlainStringAsJSON,
|
|
10723
10820
|
devNullWritableStream: () => devNullWritableStream,
|
|
10724
10821
|
flush: () => flush,
|
|
10822
|
+
getIdGenerator: () => getIdGenerator,
|
|
10725
10823
|
getPromptVersions: () => getPromptVersions,
|
|
10726
10824
|
getSpanParentObject: () => getSpanParentObject,
|
|
10727
10825
|
graph: () => graph_framework_exports,
|
|
@@ -10765,6 +10863,7 @@ __export(exports_node_exports, {
|
|
|
10765
10863
|
wrapAISDK: () => wrapAISDK,
|
|
10766
10864
|
wrapAISDKModel: () => wrapAISDKModel,
|
|
10767
10865
|
wrapAnthropic: () => wrapAnthropic,
|
|
10866
|
+
wrapClaudeAgentSDK: () => wrapClaudeAgentSDK,
|
|
10768
10867
|
wrapMastraAgent: () => wrapMastraAgent,
|
|
10769
10868
|
wrapOpenAI: () => wrapOpenAI,
|
|
10770
10869
|
wrapOpenAIv4: () => wrapOpenAIv4,
|
|
@@ -10859,7 +10958,7 @@ function initFunction({
|
|
|
10859
10958
|
return f;
|
|
10860
10959
|
}
|
|
10861
10960
|
|
|
10862
|
-
//
|
|
10961
|
+
// ../../node_modules/.pnpm/async@3.2.5/node_modules/async/dist/async.mjs
|
|
10863
10962
|
function initialParams(fn) {
|
|
10864
10963
|
return function(...args) {
|
|
10865
10964
|
var callback = args.pop();
|
|
@@ -11938,12 +12037,12 @@ var BarProgressReporter = class {
|
|
|
11938
12037
|
};
|
|
11939
12038
|
|
|
11940
12039
|
// src/eval-parameters.ts
|
|
11941
|
-
import { z as
|
|
12040
|
+
import { z as z10 } from "zod/v3";
|
|
11942
12041
|
|
|
11943
12042
|
// src/framework2.ts
|
|
11944
12043
|
import path2 from "path";
|
|
11945
12044
|
import slugifyLib from "slugify";
|
|
11946
|
-
import { z as
|
|
12045
|
+
import { z as z9 } from "zod/v3";
|
|
11947
12046
|
var ProjectBuilder = class {
|
|
11948
12047
|
create(opts) {
|
|
11949
12048
|
return new Project2(opts);
|
|
@@ -12177,23 +12276,23 @@ var CodePrompt = class {
|
|
|
12177
12276
|
};
|
|
12178
12277
|
}
|
|
12179
12278
|
};
|
|
12180
|
-
var promptContentsSchema =
|
|
12181
|
-
|
|
12182
|
-
prompt:
|
|
12279
|
+
var promptContentsSchema = z9.union([
|
|
12280
|
+
z9.object({
|
|
12281
|
+
prompt: z9.string()
|
|
12183
12282
|
}),
|
|
12184
|
-
|
|
12185
|
-
messages:
|
|
12283
|
+
z9.object({
|
|
12284
|
+
messages: z9.array(ChatCompletionMessageParam)
|
|
12186
12285
|
})
|
|
12187
12286
|
]);
|
|
12188
12287
|
var promptDefinitionSchema = promptContentsSchema.and(
|
|
12189
|
-
|
|
12190
|
-
model:
|
|
12288
|
+
z9.object({
|
|
12289
|
+
model: z9.string(),
|
|
12191
12290
|
params: ModelParams.optional()
|
|
12192
12291
|
})
|
|
12193
12292
|
);
|
|
12194
12293
|
var promptDefinitionWithToolsSchema = promptDefinitionSchema.and(
|
|
12195
|
-
|
|
12196
|
-
tools:
|
|
12294
|
+
z9.object({
|
|
12295
|
+
tools: z9.array(ToolFunctionDefinition).optional()
|
|
12197
12296
|
})
|
|
12198
12297
|
);
|
|
12199
12298
|
var PromptBuilder = class {
|
|
@@ -12261,7 +12360,7 @@ var ProjectNameIdMap = class {
|
|
|
12261
12360
|
const response = await _internalGetGlobalState().appConn().post_json("api/project/register", {
|
|
12262
12361
|
project_name: projectName
|
|
12263
12362
|
});
|
|
12264
|
-
const result =
|
|
12363
|
+
const result = z9.object({
|
|
12265
12364
|
project: Project
|
|
12266
12365
|
}).parse(response);
|
|
12267
12366
|
const projectId = result.project.id;
|
|
@@ -12275,7 +12374,7 @@ var ProjectNameIdMap = class {
|
|
|
12275
12374
|
const response = await _internalGetGlobalState().appConn().post_json("api/project/get", {
|
|
12276
12375
|
id: projectId
|
|
12277
12376
|
});
|
|
12278
|
-
const result =
|
|
12377
|
+
const result = z9.array(Project).nonempty().parse(response);
|
|
12279
12378
|
const projectName = result[0].name;
|
|
12280
12379
|
this.idToName[projectId] = projectName;
|
|
12281
12380
|
this.nameToId[projectName] = projectId;
|
|
@@ -12291,15 +12390,15 @@ var ProjectNameIdMap = class {
|
|
|
12291
12390
|
};
|
|
12292
12391
|
|
|
12293
12392
|
// src/eval-parameters.ts
|
|
12294
|
-
var evalParametersSchema =
|
|
12295
|
-
|
|
12296
|
-
|
|
12297
|
-
|
|
12298
|
-
type:
|
|
12393
|
+
var evalParametersSchema = z10.record(
|
|
12394
|
+
z10.string(),
|
|
12395
|
+
z10.union([
|
|
12396
|
+
z10.object({
|
|
12397
|
+
type: z10.literal("prompt"),
|
|
12299
12398
|
default: promptDefinitionWithToolsSchema.optional(),
|
|
12300
|
-
description:
|
|
12399
|
+
description: z10.string().optional()
|
|
12301
12400
|
}),
|
|
12302
|
-
|
|
12401
|
+
z10.instanceof(z10.ZodType)
|
|
12303
12402
|
// For Zod schemas
|
|
12304
12403
|
])
|
|
12305
12404
|
);
|
|
@@ -14008,6 +14107,9 @@ function extractModelFromResult(result) {
|
|
|
14008
14107
|
}
|
|
14009
14108
|
return void 0;
|
|
14010
14109
|
}
|
|
14110
|
+
function extractModelFromWrapGenerateCallback(model) {
|
|
14111
|
+
return model?.modelId;
|
|
14112
|
+
}
|
|
14011
14113
|
function camelToSnake(str) {
|
|
14012
14114
|
return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
14013
14115
|
}
|
|
@@ -14180,7 +14282,11 @@ var V2_EXCLUDE_KEYS = /* @__PURE__ */ new Set([
|
|
|
14180
14282
|
]);
|
|
14181
14283
|
function BraintrustMiddleware(config = {}) {
|
|
14182
14284
|
return {
|
|
14183
|
-
wrapGenerate: async ({
|
|
14285
|
+
wrapGenerate: async ({
|
|
14286
|
+
doGenerate,
|
|
14287
|
+
params,
|
|
14288
|
+
model: modelFromWrapGenerate
|
|
14289
|
+
}) => {
|
|
14184
14290
|
const spanArgs = {
|
|
14185
14291
|
name: "ai-sdk.generateText",
|
|
14186
14292
|
spanAttributes: {
|
|
@@ -14207,6 +14313,13 @@ function BraintrustMiddleware(config = {}) {
|
|
|
14207
14313
|
const model = extractModelFromResult(result);
|
|
14208
14314
|
if (model !== void 0) {
|
|
14209
14315
|
metadata.model = model;
|
|
14316
|
+
} else if (modelFromWrapGenerate) {
|
|
14317
|
+
const modelId = extractModelFromWrapGenerateCallback(
|
|
14318
|
+
modelFromWrapGenerate
|
|
14319
|
+
);
|
|
14320
|
+
if (modelId) {
|
|
14321
|
+
metadata.model = modelId;
|
|
14322
|
+
}
|
|
14210
14323
|
}
|
|
14211
14324
|
let toolCalls = extractToolCallsFromSteps(result?.steps);
|
|
14212
14325
|
if (!toolCalls || toolCalls.length === 0) {
|
|
@@ -15196,7 +15309,7 @@ function streamNextProxy(stream, sspan) {
|
|
|
15196
15309
|
};
|
|
15197
15310
|
}
|
|
15198
15311
|
function parseEventFromMessage(message) {
|
|
15199
|
-
const output = message
|
|
15312
|
+
const output = message ? { role: message.role, content: message.content } : null;
|
|
15200
15313
|
const metrics = parseMetricsFromUsage2(message?.usage);
|
|
15201
15314
|
const metas = ["stop_reason", "stop_sequence"];
|
|
15202
15315
|
const metadata = {};
|
|
@@ -15236,6 +15349,282 @@ function coalesceInput(messages, system) {
|
|
|
15236
15349
|
return input;
|
|
15237
15350
|
}
|
|
15238
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
|
+
|
|
15239
15628
|
// src/otel.ts
|
|
15240
15629
|
var otelApi = null;
|
|
15241
15630
|
var otelSdk = null;
|
|
@@ -15497,44 +15886,44 @@ var BraintrustExporter = class _BraintrustExporter {
|
|
|
15497
15886
|
};
|
|
15498
15887
|
|
|
15499
15888
|
// dev/types.ts
|
|
15500
|
-
import { z as
|
|
15501
|
-
var evalBodySchema =
|
|
15502
|
-
name:
|
|
15503
|
-
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(),
|
|
15504
15893
|
data: RunEval.shape.data,
|
|
15505
|
-
scores:
|
|
15506
|
-
|
|
15894
|
+
scores: z11.array(
|
|
15895
|
+
z11.object({
|
|
15507
15896
|
function_id: FunctionId,
|
|
15508
|
-
name:
|
|
15897
|
+
name: z11.string()
|
|
15509
15898
|
})
|
|
15510
15899
|
).nullish(),
|
|
15511
|
-
experiment_name:
|
|
15512
|
-
project_id:
|
|
15900
|
+
experiment_name: z11.string().nullish(),
|
|
15901
|
+
project_id: z11.string().nullish(),
|
|
15513
15902
|
parent: InvokeParent.optional(),
|
|
15514
|
-
stream:
|
|
15903
|
+
stream: z11.boolean().optional()
|
|
15515
15904
|
});
|
|
15516
|
-
var evalParametersSerializedSchema =
|
|
15517
|
-
|
|
15518
|
-
|
|
15519
|
-
|
|
15520
|
-
type:
|
|
15905
|
+
var evalParametersSerializedSchema = z11.record(
|
|
15906
|
+
z11.string(),
|
|
15907
|
+
z11.union([
|
|
15908
|
+
z11.object({
|
|
15909
|
+
type: z11.literal("prompt"),
|
|
15521
15910
|
default: PromptData.optional(),
|
|
15522
|
-
description:
|
|
15911
|
+
description: z11.string().optional()
|
|
15523
15912
|
}),
|
|
15524
|
-
|
|
15525
|
-
type:
|
|
15526
|
-
schema:
|
|
15913
|
+
z11.object({
|
|
15914
|
+
type: z11.literal("data"),
|
|
15915
|
+
schema: z11.record(z11.unknown()),
|
|
15527
15916
|
// JSON Schema
|
|
15528
|
-
default:
|
|
15529
|
-
description:
|
|
15917
|
+
default: z11.unknown().optional(),
|
|
15918
|
+
description: z11.string().optional()
|
|
15530
15919
|
})
|
|
15531
15920
|
])
|
|
15532
15921
|
);
|
|
15533
|
-
var evaluatorDefinitionSchema =
|
|
15922
|
+
var evaluatorDefinitionSchema = z11.object({
|
|
15534
15923
|
parameters: evalParametersSerializedSchema.optional()
|
|
15535
15924
|
});
|
|
15536
|
-
var evaluatorDefinitionsSchema =
|
|
15537
|
-
|
|
15925
|
+
var evaluatorDefinitionsSchema = z11.record(
|
|
15926
|
+
z11.string(),
|
|
15538
15927
|
evaluatorDefinitionSchema
|
|
15539
15928
|
);
|
|
15540
15929
|
|
|
@@ -15560,6 +15949,7 @@ export {
|
|
|
15560
15949
|
Experiment2 as Experiment,
|
|
15561
15950
|
ExternalAttachment,
|
|
15562
15951
|
FailedHTTPResponse,
|
|
15952
|
+
IDGenerator,
|
|
15563
15953
|
INTERNAL_BTQL_LIMIT,
|
|
15564
15954
|
LEGACY_CACHED_HEADER,
|
|
15565
15955
|
LazyValue,
|
|
@@ -15567,6 +15957,7 @@ export {
|
|
|
15567
15957
|
NOOP_SPAN,
|
|
15568
15958
|
NOOP_SPAN_PERMALINK,
|
|
15569
15959
|
NoopSpan,
|
|
15960
|
+
OTELIDGenerator,
|
|
15570
15961
|
Project2 as Project,
|
|
15571
15962
|
ProjectNameIdMap,
|
|
15572
15963
|
Prompt2 as Prompt,
|
|
@@ -15578,6 +15969,7 @@ export {
|
|
|
15578
15969
|
SpanImpl,
|
|
15579
15970
|
TestBackgroundLogger,
|
|
15580
15971
|
ToolBuilder,
|
|
15972
|
+
UUIDGenerator,
|
|
15581
15973
|
X_CACHED_HEADER,
|
|
15582
15974
|
_exportsForTestingOnly,
|
|
15583
15975
|
_internalGetGlobalState,
|
|
@@ -15596,6 +15988,7 @@ export {
|
|
|
15596
15988
|
evaluatorDefinitionSchema,
|
|
15597
15989
|
evaluatorDefinitionsSchema,
|
|
15598
15990
|
flush,
|
|
15991
|
+
getIdGenerator,
|
|
15599
15992
|
getPromptVersions,
|
|
15600
15993
|
getSpanParentObject,
|
|
15601
15994
|
graph_framework_exports as graph,
|
|
@@ -15639,6 +16032,7 @@ export {
|
|
|
15639
16032
|
wrapAISDK,
|
|
15640
16033
|
wrapAISDKModel,
|
|
15641
16034
|
wrapAnthropic,
|
|
16035
|
+
wrapClaudeAgentSDK,
|
|
15642
16036
|
wrapMastraAgent,
|
|
15643
16037
|
wrapOpenAI,
|
|
15644
16038
|
wrapOpenAIv4,
|