diff --git a/.changeset/icy-symbols-jam.md b/.changeset/icy-symbols-jam.md new file mode 100644 index 000000000..7de80491b --- /dev/null +++ b/.changeset/icy-symbols-jam.md @@ -0,0 +1,5 @@ +--- +"braintrust": patch +--- + +chore: Update platform types diff --git a/generated_types.json b/generated_types.json index 34bb7e938..eaba25749 100644 --- a/generated_types.json +++ b/generated_types.json @@ -87,10 +87,58 @@ "role", "org_member", "project_log", - "org_project" + "org_project", + "org_audit_logs" ], "description": "The object type that the ACL applies to" }, + "Agent": { + "type": "object", + "properties": { + "id": { + "type": "string", + "format": "uuid", + "description": "Unique identifier for the agent" + }, + "project_id": { + "type": "string", + "format": "uuid", + "description": "Unique identifier for the project that the agent belongs under" + }, + "user_id": { + "type": "string", + "format": "uuid" + }, + "created": { + "type": ["string", "null"], + "format": "date-time", + "description": "Date of agent creation" + }, + "name": { + "type": "string", + "description": "Name of the agent. Within a project, agent names are unique" + }, + "slug": { + "type": "string", + "description": "Stable, URL-safe identifier for the agent, unique within its project." + }, + "kind": { + "type": "string", + "description": "Agent classification: 'custom' for customer-defined agents, 'loop' for built-in Loop agents." + }, + "description": { + "type": ["string", "null"], + "description": "Textual description of the agent" + }, + "metadata": { + "type": ["object", "null"], + "additionalProperties": {}, + "description": "User-controlled metadata about the agent" + } + }, + "required": ["id", "project_id", "user_id", "name", "slug", "kind"], + "description": "An agent is a project-scoped durable object that identifies an AI agent or service emitting spans" + }, "AISecret": { "type": "object", "properties": { @@ -532,6 +580,11 @@ }, "required": ["upload_status"] }, + "AutomationStatus": { + "type": "string", + "enum": ["active", "paused"], + "description": "Whether the automation is active or paused." + }, "BatchedFacetData": { "type": "object", "properties": { @@ -1689,7 +1742,9 @@ }, "facets": { "type": ["object", "null"], - "additionalProperties": {}, + "additionalProperties": { + "type": ["string", "null"] + }, "description": "Facets for categorization (dictionary from facet id to value)" }, "classifications": { @@ -2146,7 +2201,9 @@ }, "facets": { "type": ["object", "null"], - "additionalProperties": {}, + "additionalProperties": { + "type": ["string", "null"] + }, "description": "Facets for categorization (dictionary from facet id to value)" }, "classifications": { @@ -3289,12 +3346,28 @@ "type": "string", "description": "Field path to group by, e.g. metadata.session_id" }, + "interval_seconds": { + "type": "number", + "minimum": 1, + "description": "Maximum time range to include when constructing a group" + }, + "max_traces": { + "type": "integer", + "minimum": 1, + "maximum": 64, + "description": "Maximum number of traces to include when constructing a group (default/max: 64)" + }, + "placement": { + "type": "string", + "enum": ["first", "each"], + "description": "Which trace or traces to write grouped scorer results to" + }, "idle_seconds": { "type": "number", "description": "Optional: trigger after this many seconds of inactivity" } }, - "required": ["type", "group_by"], + "required": ["type", "group_by", "placement"], "description": "Process spans/traces grouped by a field (e.g., session_id)" }, "IfExists": { @@ -3872,7 +3945,7 @@ "type": "null" } ], - "description": "The scope at which to run the functions. Defaults to span-level execution. Trace/group scope requires all functions to be facets." + "description": "The scope at which to run the functions. Defaults to span-level execution." } }, "required": ["sampling_rate", "scorers"] @@ -4081,6 +4154,9 @@ "enum": ["btql_export"], "description": "The type of automation." }, + "status": { + "$ref": "#/components/schemas/AutomationStatus" + }, "export_definition": { "oneOf": [ { @@ -4202,6 +4278,61 @@ "credentials" ] }, + { + "type": "object", + "properties": { + "event_type": { + "type": "string", + "enum": ["async_query"], + "description": "The type of automation." + }, + "status": { + "$ref": "#/components/schemas/AutomationStatus" + }, + "created_by_user_id": { + "type": "string", + "format": "uuid", + "description": "The user who submitted the async query" + }, + "object_type": { + "type": "string", + "enum": [ + "project_logs", + "experiment", + "dataset", + "playground_logs" + ], + "description": "The source object type for the async query" + }, + "object_id": { + "type": "string", + "description": "The source object ID for the async query" + }, + "query": { + "type": "string", + "description": "The SQL query to execute asynchronously" + }, + "format": { + "type": "string", + "enum": ["jsonl"], + "description": "The materialized result format" + }, + "batch_size": { + "type": ["integer", "null"], + "exclusiveMinimum": 0, + "maximum": 100000, + "description": "The maximum number of result rows to write per async query batch" + } + }, + "required": [ + "event_type", + "created_by_user_id", + "object_type", + "object_id", + "query", + "format" + ] + }, { "type": "object", "properties": { @@ -4284,6 +4415,9 @@ }, { "$ref": "#/components/schemas/TopicAutomationConfig" + }, + { + "$ref": "#/components/schemas/TopicDigestAutomationConfig" } ], "description": "The configuration for the automation rule" @@ -4462,7 +4596,9 @@ }, "facets": { "type": ["object", "null"], - "additionalProperties": {}, + "additionalProperties": { + "type": ["string", "null"] + }, "description": "Facets for categorization (dictionary from facet id to value)" }, "classifications": { @@ -4650,6 +4786,40 @@ "required": ["name", "value"], "description": "For categorical-type project scores, defines a single category" }, + "ProjectScoreCondition": { + "type": ["object", "null"], + "properties": { + "when": { + "type": "object", + "properties": { + "clauses": { + "type": ["array", "null"], + "items": { + "type": "string" + } + }, + "subspan_clauses": { + "type": ["array", "null"], + "items": { + "type": "string" + } + }, + "trace_clauses": { + "type": ["array", "null"], + "items": { + "type": "string" + } + } + } + }, + "behavior": { + "type": "string", + "enum": ["hidden"], + "default": "hidden" + } + }, + "required": ["when"] + }, "ProjectScoreConfig": { "type": ["object", "null"], "properties": { @@ -4659,8 +4829,35 @@ "destination": { "type": ["string", "null"] }, + "visibility": { + "type": ["object", "null"], + "properties": { + "users": { + "type": ["array", "null"], + "items": { + "type": "string" + } + }, + "groups": { + "type": ["array", "null"], + "items": { + "type": "string" + } + } + } + }, "online": { "$ref": "#/components/schemas/OnlineScoreConfig" + }, + "condition": { + "$ref": "#/components/schemas/ProjectScoreCondition" + }, + "object_types": { + "type": ["array", "null"], + "items": { + "type": "string", + "enum": ["project_logs", "dataset", "experiment"] + } } } }, @@ -5635,7 +5832,7 @@ }, { "type": ["object", "null"], - "description": "Optional settings for collecting git metadata. By default, will collect all git metadata fields allowed in org-level settings." + "description": "Optional settings for collecting git metadata. By default, will collect git metadata fields allowed in org-level settings, excluding diff content unless the org opts in." } ] }, @@ -5968,12 +6165,18 @@ "enum": ["topic"], "description": "The type of automation." }, + "status": { + "$ref": "#/components/schemas/AutomationStatus" + }, "sampling_rate": { "type": "number", "minimum": 0, "maximum": 1, "description": "The sampling rate for topic automation" }, + "facet_model": { + "$ref": "#/components/schemas/TopicAutomationFacetModel" + }, "facet_functions": { "type": "array", "items": { @@ -6094,6 +6297,70 @@ ], "description": "Optional data scope for topic automation." }, + "TopicAutomationFacetModel": { + "type": ["string", "null"], + "enum": ["brain-facet-latest", "brain-facet-1", "brain-facet-2"], + "description": "Optional facet model override for topic automation" + }, + "TopicDigestAutomationConfig": { + "type": "object", + "properties": { + "event_type": { + "type": "string", + "enum": ["topic_digest"], + "description": "The type of automation." + }, + "status": { + "$ref": "#/components/schemas/AutomationStatus" + }, + "window_seconds": { + "type": "integer", + "minimum": 3600, + "maximum": 2592000, + "default": 86400, + "description": "How much recent history to include in each digest" + }, + "scheduled_time_minutes_utc": { + "type": "integer", + "minimum": 0, + "maximum": 1439, + "description": "Minutes after midnight UTC when the digest should be sent" + }, + "action": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": ["slack"], + "description": "The type of action to take" + }, + "workspace_id": { + "type": "string", + "description": "The Slack workspace ID to post to" + }, + "channel": { + "type": "string", + "description": "The Slack channel ID to post to" + }, + "message_template": { + "type": "string", + "description": "Custom message template for the alert" + } + }, + "required": ["type", "workspace_id", "channel"], + "description": "The Slack action to take when the digest is sent" + }, + "topic_map_function_ids": { + "type": "array", + "items": { + "type": "string" + }, + "maxItems": 10, + "description": "Optional topic map function IDs to include in the digest" + } + }, + "required": ["event_type", "scheduled_time_minutes_utc", "action"] + }, "TopicMapData": { "type": "object", "properties": { @@ -6134,6 +6401,14 @@ "distance_threshold": { "type": "number", "description": "Maximum distance to nearest centroid. If exceeded, returns no_match." + }, + "btql_filter": { + "type": "string", + "description": "Per-topic-map BTQL filter that was applied when this version was generated. Absent on versions generated before this was recorded." + }, + "automation_btql_filter": { + "type": "string", + "description": "Automation-level BTQL filter that was applied when this version was generated. Absent on versions generated before this was recorded." } }, "required": ["type", "source_facet", "embedding_model"] @@ -6308,10 +6583,6 @@ "type": ["string", "null"], "format": "date-time", "description": "Date of user creation" - }, - "last_active_at": { - "type": ["number", "null"], - "description": "Unix timestamp in milliseconds of the user's last activity, when available" } }, "required": ["id"] diff --git a/js/src/generated_types.ts b/js/src/generated_types.ts index d8c96e52f..f560c399a 100644 --- a/js/src/generated_types.ts +++ b/js/src/generated_types.ts @@ -1,4 +1,4 @@ -// Auto-generated file (content hash 2046371fcb54d28e) -- do not modify +// Auto-generated file (content hash adad84b723c4d072) -- do not modify import { z } from "zod/v3"; @@ -15,6 +15,7 @@ export const AclObjectType = z.union([ "org_member", "project_log", "org_project", + "org_audit_logs", ]), z.null(), ]); @@ -43,6 +44,20 @@ export const Acl = z.object({ created: z.union([z.string(), z.null()]).optional(), }); export type AclType = z.infer; +export const Agent = z.object({ + id: z.string().uuid(), + project_id: z.string().uuid(), + user_id: z.string().uuid(), + created: z.union([z.string(), z.null()]).optional(), + name: z.string(), + slug: z.string(), + kind: z.string(), + description: z.union([z.string(), z.null()]).optional(), + metadata: z + .union([z.object({}).partial().passthrough(), z.null()]) + .optional(), +}); +export type AgentType = z.infer; export const AISecret = z.object({ id: z.string().uuid(), created: z.union([z.string(), z.null()]).optional(), @@ -222,6 +237,8 @@ export const AttachmentStatus = z.object({ error_message: z.string().optional(), }); export type AttachmentStatusType = z.infer; +export const AutomationStatus = z.enum(["active", "paused"]); +export type AutomationStatusType = z.infer; export const FunctionTypeEnum = z.enum([ "llm", "scorer", @@ -275,6 +292,8 @@ export const TopicMapData = z.object({ generation_settings: TopicMapGenerationSettings.optional(), disable_reconciliation: z.boolean().optional(), distance_threshold: z.number().optional(), + btql_filter: z.string().optional(), + automation_btql_filter: z.string().optional(), }); export type TopicMapDataType = z.infer; export const BatchedFacetData = z.object({ @@ -621,7 +640,9 @@ export const DatasetEvent = z.object({ origin: ObjectReferenceNullish.optional(), comments: z.union([z.array(z.unknown()), z.null()]).optional(), audit_data: z.union([z.array(z.unknown()), z.null()]).optional(), - facets: z.union([z.object({}).partial().passthrough(), z.null()]).optional(), + facets: z + .union([z.record(z.union([z.string(), z.null()])), z.null()]) + .optional(), classifications: z .union([ z.record( @@ -813,7 +834,9 @@ export const ExperimentEvent = z.object({ origin: ObjectReferenceNullish.optional(), comments: z.union([z.array(z.unknown()), z.null()]).optional(), audit_data: z.union([z.array(z.unknown()), z.null()]).optional(), - facets: z.union([z.object({}).partial().passthrough(), z.null()]).optional(), + facets: z + .union([z.record(z.union([z.string(), z.null()])), z.null()]) + .optional(), classifications: z .union([ z.record( @@ -1366,6 +1389,9 @@ export type GroupType = z.infer; export const GroupScope = z.object({ type: z.literal("group"), group_by: z.string(), + interval_seconds: z.number().gte(1).optional(), + max_traces: z.number().int().gte(1).lte(64).optional(), + placement: z.enum(["first", "each"]), idle_seconds: z.number().optional(), }); export type GroupScopeType = z.infer; @@ -1540,6 +1566,13 @@ export const RetentionObjectType = z.enum([ "dataset", ]); export type RetentionObjectTypeType = z.infer; +export const TopicAutomationFacetModel = z.union([ + z.enum(["brain-facet-latest", "brain-facet-1", "brain-facet-2"]), + z.null(), +]); +export type TopicAutomationFacetModelType = z.infer< + typeof TopicAutomationFacetModel +>; export const TopicMapFunctionAutomation = z.object({ function: SavedFunctionId.and(z.unknown()), btql_filter: z.union([z.string(), z.null()]).optional(), @@ -1558,7 +1591,9 @@ export type TopicAutomationDataScopeType = z.infer< >; export const TopicAutomationConfig = z.object({ event_type: z.literal("topic"), + status: AutomationStatus.optional(), sampling_rate: z.number().gte(0).lte(1), + facet_model: TopicAutomationFacetModel.optional(), facet_functions: z.array(SavedFunctionId), topic_map_functions: z.array(TopicMapFunctionAutomation), scope: z.union([SpanScope, TraceScope, GroupScope, z.null()]).optional(), @@ -1575,6 +1610,28 @@ export const TopicAutomationConfig = z.object({ .optional(), }); export type TopicAutomationConfigType = z.infer; +export const TopicDigestAutomationConfig = z.object({ + event_type: z.literal("topic_digest"), + status: AutomationStatus.optional(), + window_seconds: z + .number() + .int() + .gte(3600) + .lte(2592000) + .optional() + .default(86400), + scheduled_time_minutes_utc: z.number().int().gte(0).lte(1439), + action: z.object({ + type: z.literal("slack"), + workspace_id: z.string(), + channel: z.string(), + message_template: z.string().optional(), + }), + topic_map_function_ids: z.array(z.string()).max(10).optional(), +}); +export type TopicDigestAutomationConfigType = z.infer< + typeof TopicDigestAutomationConfig +>; export const ProjectAutomation = z.object({ id: z.string().uuid(), project_id: z.string().uuid(), @@ -1599,6 +1656,7 @@ export const ProjectAutomation = z.object({ }), z.object({ event_type: z.literal("btql_export"), + status: AutomationStatus.optional(), export_definition: z.union([ z.object({ type: z.literal("log_traces") }), z.object({ type: z.literal("log_spans") }), @@ -1621,6 +1679,21 @@ export const ProjectAutomation = z.object({ ]), batch_size: z.union([z.number(), z.null()]).optional(), }), + z.object({ + event_type: z.literal("async_query"), + status: AutomationStatus.optional(), + created_by_user_id: z.string().uuid(), + object_type: z.enum([ + "project_logs", + "experiment", + "dataset", + "playground_logs", + ]), + object_id: z.string(), + query: z.string(), + format: z.literal("jsonl"), + batch_size: z.union([z.number(), z.null()]).optional(), + }), z.object({ event_type: z.literal("retention"), object_type: RetentionObjectType, @@ -1640,6 +1713,7 @@ export const ProjectAutomation = z.object({ ]), }), TopicAutomationConfig, + TopicDigestAutomationConfig, ]), }); export type ProjectAutomationType = z.infer; @@ -1691,7 +1765,9 @@ export const ProjectLogsEvent = z.object({ comments: z.union([z.array(z.unknown()), z.null()]).optional(), audit_data: z.union([z.array(z.unknown()), z.null()]).optional(), _async_scoring_state: z.unknown().optional(), - facets: z.union([z.object({}).partial().passthrough(), z.null()]).optional(), + facets: z + .union([z.record(z.union([z.string(), z.null()])), z.null()]) + .optional(), classifications: z .union([ z.record( @@ -1748,12 +1824,40 @@ export const ProjectScoreCategories = z.union([ z.null(), ]); export type ProjectScoreCategoriesType = z.infer; +export const ProjectScoreCondition = z.union([ + z.object({ + when: z + .object({ + clauses: z.union([z.array(z.string()), z.null()]), + subspan_clauses: z.union([z.array(z.string()), z.null()]), + trace_clauses: z.union([z.array(z.string()), z.null()]), + }) + .partial(), + behavior: z.literal("hidden").optional().default("hidden"), + }), + z.null(), +]); +export type ProjectScoreConditionType = z.infer; export const ProjectScoreConfig = z.union([ z .object({ multi_select: z.union([z.boolean(), z.null()]), destination: z.union([z.string(), z.null()]), + visibility: z.union([ + z + .object({ + users: z.union([z.array(z.string()), z.null()]), + groups: z.union([z.array(z.string()), z.null()]), + }) + .partial(), + z.null(), + ]), online: OnlineScoreConfig, + condition: ProjectScoreCondition, + object_types: z.union([ + z.array(z.enum(["project_logs", "dataset", "experiment"])), + z.null(), + ]), }) .partial(), z.null(), @@ -1966,7 +2070,6 @@ export const User = z.object({ email: z.union([z.string(), z.null()]).optional(), avatar_url: z.union([z.string(), z.null()]).optional(), created: z.union([z.string(), z.null()]).optional(), - last_active_at: z.union([z.number(), z.null()]).optional(), }); export type UserType = z.infer; export const ViewDataSearch = z.union([