diff --git a/generated_types.json b/generated_types.json index 6cc975a5..ec8a849c 100644 --- a/generated_types.json +++ b/generated_types.json @@ -5883,6 +5883,9 @@ "action" ] }, + { + "$ref": "#/components/schemas/WindowedAutomationConfig" + }, { "$ref": "#/components/schemas/TopicAutomationConfig" }, @@ -9290,6 +9293,288 @@ } ], "description": "Options for the view in the app" + }, + "WindowedAutomationConfig": { + "type": "object", + "properties": { + "event_type": { + "type": "string", + "enum": [ + "windowed" + ], + "description": "The type of automation." + }, + "status": { + "$ref": "#/components/schemas/AutomationStatus" + }, + "threshold": { + "type": "object", + "properties": { + "calculation": { + "oneOf": [ + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "btql" + ] + }, + "btql_query": { + "type": "string", + "minLength": 1, + "description": "A project-scoped BTQL or SQL query without runtime-owned evaluation time bounds" + }, + "output": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "scalar" + ] + }, + "value_column": { + "type": "string", + "minLength": 1, + "description": "The numeric result column produced by the query" + } + }, + "required": [ + "type", + "value_column" + ] + } + }, + "required": [ + "type", + "btql_query", + "output" + ] + } + ], + "description": "The calculation evaluated for each window" + }, + "policy": { + "type": "object", + "properties": { + "condition": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "threshold" + ] + }, + "operator": { + "type": "string", + "enum": [ + "lt", + "lte", + "gt", + "gte", + "eq", + "neq" + ] + }, + "threshold": { + "type": "number" + } + }, + "required": [ + "type", + "operator", + "threshold" + ] + }, + "pending_seconds": { + "type": "integer", + "minimum": 0, + "maximum": 2592000, + "description": "How long the condition must remain breached before firing" + }, + "no_data_behavior": { + "type": "string", + "enum": [ + "keep_last", + "resolve", + "alert" + ], + "description": "How the lifecycle changes when the calculation returns no data" + }, + "renotify_interval_seconds": { + "type": [ + "integer", + "null" + ], + "minimum": 1, + "maximum": 2592000, + "description": "Optional reminder interval while the automation is firing" + }, + "notify_on_recovery": { + "type": "boolean", + "default": true, + "description": "Whether to deliver actions when a firing automation recovers" + } + }, + "required": [ + "condition", + "pending_seconds", + "no_data_behavior" + ], + "description": "The lifecycle policy applied to each calculation result" + } + }, + "required": [ + "calculation", + "policy" + ], + "description": "Optional calculation and lifecycle policy that gate scheduled delivery" + }, + "window": { + "type": "object", + "properties": { + "window_seconds": { + "type": "integer", + "minimum": 1, + "maximum": 2592000, + "description": "How much recent data each scheduled run covers" + }, + "schedule": { + "oneOf": [ + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "interval" + ] + }, + "evaluation_interval_seconds": { + "type": "integer", + "minimum": 1, + "maximum": 2592000, + "description": "How often the automation runs" + } + }, + "required": [ + "type", + "evaluation_interval_seconds" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "cron" + ] + }, + "cron_expression": { + "type": "string", + "minLength": 1, + "description": "A standard five-field cron expression (minute hour day-of-month month day-of-week) controlling when the automation runs" + }, + "timezone": { + "type": [ + "string", + "null" + ], + "minLength": 1, + "description": "IANA timezone used to interpret the cron expression (defaults to UTC)" + } + }, + "required": [ + "type", + "cron_expression" + ] + } + ], + "description": "How often the windowed automation runs: at a fixed interval or on a cron schedule" + }, + "evaluation_delay_seconds": { + "type": "integer", + "minimum": 0, + "maximum": 2592000, + "description": "How far behind the present each evaluation window ends" + } + }, + "required": [ + "window_seconds", + "schedule", + "evaluation_delay_seconds" + ] + }, + "actions": { + "type": "array", + "items": { + "oneOf": [ + { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "webhook" + ], + "description": "The type of action to take" + }, + "url": { + "type": "string", + "description": "The webhook URL to send the request to" + } + }, + "required": [ + "type", + "url" + ] + }, + { + "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": "A delivery action available to an automation" + }, + "minItems": 1, + "maxItems": 20, + "description": "The delivery actions to run on each schedule or threshold lifecycle transition" + } + }, + "required": [ + "event_type", + "window", + "actions" + ] } }, "parameters": {} diff --git a/py/src/braintrust/_generated_types.py b/py/src/braintrust/_generated_types.py index 68521caf..8092f494 100644 --- a/py/src/braintrust/_generated_types.py +++ b/py/src/braintrust/_generated_types.py @@ -2855,6 +2855,146 @@ class ViewOptionsViewOptions1(TypedDict): """ +class WindowedAutomationConfigThresholdCalculationOutput(TypedDict): + type: Literal['scalar'] + value_column: str + """ + The numeric result column produced by the query + """ + + +class WindowedAutomationConfigThresholdCalculation(TypedDict): + type: Literal['btql'] + btql_query: str + """ + A project-scoped BTQL or SQL query without runtime-owned evaluation time bounds + """ + output: WindowedAutomationConfigThresholdCalculationOutput + + +class WindowedAutomationConfigThresholdPolicyCondition(TypedDict): + type: Literal['threshold'] + operator: Literal['lt', 'lte', 'gt', 'gte', 'eq', 'neq'] + threshold: float + + +class WindowedAutomationConfigThresholdPolicy(TypedDict): + condition: WindowedAutomationConfigThresholdPolicyCondition + pending_seconds: int + """ + How long the condition must remain breached before firing + """ + no_data_behavior: Literal['keep_last', 'resolve', 'alert'] + """ + How the lifecycle changes when the calculation returns no data + """ + renotify_interval_seconds: NotRequired[int | None] + """ + Optional reminder interval while the automation is firing + """ + notify_on_recovery: NotRequired[bool | None] + """ + Whether to deliver actions when a firing automation recovers + """ + + +class WindowedAutomationConfigThreshold(TypedDict): + calculation: WindowedAutomationConfigThresholdCalculation + """ + The calculation evaluated for each window + """ + policy: WindowedAutomationConfigThresholdPolicy + """ + The lifecycle policy applied to each calculation result + """ + + +class WindowedAutomationConfigWindowSchedule(TypedDict): + type: Literal['interval'] + evaluation_interval_seconds: int + """ + How often the automation runs + """ + + +class WindowedAutomationConfigWindowSchedule1(TypedDict): + type: Literal['cron'] + cron_expression: str + """ + A standard five-field cron expression (minute hour day-of-month month day-of-week) controlling when the automation runs + """ + timezone: NotRequired[str | None] + """ + IANA timezone used to interpret the cron expression (defaults to UTC) + """ + + +class WindowedAutomationConfigWindow(TypedDict): + window_seconds: int + """ + How much recent data each scheduled run covers + """ + schedule: ( + WindowedAutomationConfigWindowSchedule | WindowedAutomationConfigWindowSchedule1 + ) + """ + How often the windowed automation runs: at a fixed interval or on a cron schedule + """ + evaluation_delay_seconds: int + """ + How far behind the present each evaluation window ends + """ + + +class WindowedAutomationConfigActions(TypedDict): + type: Literal['webhook'] + """ + The type of action to take + """ + url: str + """ + The webhook URL to send the request to + """ + + +class WindowedAutomationConfigActions1(TypedDict): + type: Literal['slack'] + """ + The type of action to take + """ + workspace_id: str + """ + The Slack workspace ID to post to + """ + channel: str + """ + The Slack channel ID to post to + """ + message_template: NotRequired[str | None] + """ + Custom message template for the alert + """ + + +class WindowedAutomationConfig(TypedDict): + event_type: Literal['windowed'] + """ + The type of automation. + """ + status: NotRequired[AutomationStatus | None] + threshold: NotRequired[WindowedAutomationConfigThreshold | None] + """ + Optional calculation and lifecycle policy that gate scheduled delivery + """ + window: WindowedAutomationConfigWindow + actions: Sequence[ + WindowedAutomationConfigActions | WindowedAutomationConfigActions1 + ] + """ + The delivery actions to run on each schedule or threshold lifecycle transition + """ + + class Acl(TypedDict): id: str """ @@ -3862,6 +4002,7 @@ class ProjectAutomation(TypedDict): | ProjectAutomationConfig2 | ProjectAutomationConfig3 | ProjectAutomationConfig4 + | WindowedAutomationConfig | TopicAutomationConfig | TopicDigestAutomationConfig ) diff --git a/py/src/braintrust/generated_types.py b/py/src/braintrust/generated_types.py index 556b04b1..ba5a94be 100644 --- a/py/src/braintrust/generated_types.py +++ b/py/src/braintrust/generated_types.py @@ -1,4 +1,4 @@ -"""Auto-generated file (content hash ecb294cff7f76552) -- do not modify""" +"""Auto-generated file (content hash b5293fdfa9d04ebc) -- do not modify""" from ._generated_types import ( Acl, @@ -119,6 +119,7 @@ ViewData, ViewDataSearch, ViewOptions, + WindowedAutomationConfig, ) @@ -241,4 +242,5 @@ "ViewData", "ViewDataSearch", "ViewOptions", + "WindowedAutomationConfig", ]