diff --git a/drizzle/0059_slimy_dakota_north.sql b/drizzle/0059_slimy_dakota_north.sql new file mode 100644 index 00000000..3faf8c61 --- /dev/null +++ b/drizzle/0059_slimy_dakota_north.sql @@ -0,0 +1,2 @@ +ALTER TABLE "scenario_conversations" ADD COLUMN "test_run_status" text;--> statement-breakpoint +ALTER TABLE "scenario_runs" ADD COLUMN "error_count" integer DEFAULT 0 NOT NULL; \ No newline at end of file diff --git a/drizzle/meta/0059_snapshot.json b/drizzle/meta/0059_snapshot.json new file mode 100644 index 00000000..bb77a6d5 --- /dev/null +++ b/drizzle/meta/0059_snapshot.json @@ -0,0 +1,4633 @@ +{ + "id": "8a473813-9695-46fe-8349-02fd9b0ab4fd", + "prevId": "b4e37f99-f3e0-4f52-a772-f146db8f0b8b", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.agents": { + "name": "agents", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tts_provider_id": { + "name": "tts_provider_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tts_settings": { + "name": "tts_settings", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "tags": { + "name": "tags", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "filler_settings": { + "name": "filler_settings", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "agents_project_id_projects_id_fk": { + "name": "agents_project_id_projects_id_fk", + "tableFrom": "agents", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "agents_tts_provider_id_providers_id_fk": { + "name": "agents_tts_provider_id_providers_id_fk", + "tableFrom": "agents", + "tableTo": "providers", + "columnsFrom": [ + "tts_provider_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "agents_project_id_id_pk": { + "name": "agents_project_id_id_pk", + "columns": [ + "project_id", + "id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.api_keys": { + "name": "api_keys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_used_at": { + "name": "last_used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "key_settings": { + "name": "key_settings", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_api_keys_project_is_active": { + "name": "idx_api_keys_project_is_active", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "is_active", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "api_keys_project_id_projects_id_fk": { + "name": "api_keys_project_id_projects_id_fk", + "tableFrom": "api_keys", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "api_keys_project_id_id_pk": { + "name": "api_keys_project_id_id_pk", + "columns": [ + "project_id", + "id" + ] + } + }, + "uniqueConstraints": { + "api_keys_key_unique": { + "name": "api_keys_key_unique", + "nullsNotDistinct": false, + "columns": [ + "key" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.audit_logs": { + "name": "audit_logs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "action": { + "name": "action", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "entity_id": { + "name": "entity_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "entity_type": { + "name": "entity_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "old_entity": { + "name": "old_entity", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "new_entity": { + "name": "new_entity", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_audit_logs_project_id": { + "name": "idx_audit_logs_project_id", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_audit_logs_created_at": { + "name": "idx_audit_logs_created_at", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.benchmark_config_executions": { + "name": "benchmark_config_executions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "run_id": { + "name": "run_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "config_id": { + "name": "config_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "stats": { + "name": "stats", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "started_at": { + "name": "started_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_benchmark_config_executions_run_id": { + "name": "idx_benchmark_config_executions_run_id", + "columns": [ + { + "expression": "run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "config_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "benchmark_config_executions_run_id_benchmark_runs_id_fk": { + "name": "benchmark_config_executions_run_id_benchmark_runs_id_fk", + "tableFrom": "benchmark_config_executions", + "tableTo": "benchmark_runs", + "columnsFrom": [ + "run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "benchmark_config_executions_config_id_benchmark_configs_id_fk": { + "name": "benchmark_config_executions_config_id_benchmark_configs_id_fk", + "tableFrom": "benchmark_config_executions", + "tableTo": "benchmark_configs", + "columnsFrom": [ + "config_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.benchmark_configs": { + "name": "benchmark_configs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "suite_id": { + "name": "suite_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "provider_config_id": { + "name": "provider_config_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "input_type": { + "name": "input_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "input_data": { + "name": "input_data", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "repeats": { + "name": "repeats", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 3 + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_benchmark_configs_suite_id": { + "name": "idx_benchmark_configs_suite_id", + "columns": [ + { + "expression": "suite_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "benchmark_configs_suite_id_benchmark_suites_id_fk": { + "name": "benchmark_configs_suite_id_benchmark_suites_id_fk", + "tableFrom": "benchmark_configs", + "tableTo": "benchmark_suites", + "columnsFrom": [ + "suite_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "benchmark_configs_provider_config_id_benchmark_provider_configs_id_fk": { + "name": "benchmark_configs_provider_config_id_benchmark_provider_configs_id_fk", + "tableFrom": "benchmark_configs", + "tableTo": "benchmark_provider_configs", + "columnsFrom": [ + "provider_config_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.benchmark_provider_configs": { + "name": "benchmark_provider_configs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider_type": { + "name": "provider_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "settings": { + "name": "settings", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "provider_settings": { + "name": "provider_settings", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "benchmark_provider_configs_provider_id_providers_id_fk": { + "name": "benchmark_provider_configs_provider_id_providers_id_fk", + "tableFrom": "benchmark_provider_configs", + "tableTo": "providers", + "columnsFrom": [ + "provider_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.benchmark_results": { + "name": "benchmark_results", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "config_execution_id": { + "name": "config_execution_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "iteration_index": { + "name": "iteration_index", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "started_at": { + "name": "started_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "result": { + "name": "result", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_benchmark_results_config_execution_id": { + "name": "idx_benchmark_results_config_execution_id", + "columns": [ + { + "expression": "config_execution_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "benchmark_results_config_execution_id_benchmark_config_executions_id_fk": { + "name": "benchmark_results_config_execution_id_benchmark_config_executions_id_fk", + "tableFrom": "benchmark_results", + "tableTo": "benchmark_config_executions", + "columnsFrom": [ + "config_execution_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.benchmark_runs": { + "name": "benchmark_runs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "suite_id": { + "name": "suite_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "trigger": { + "name": "trigger", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "started_at": { + "name": "started_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_benchmark_runs_suite_id": { + "name": "idx_benchmark_runs_suite_id", + "columns": [ + { + "expression": "suite_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_benchmark_runs_status": { + "name": "idx_benchmark_runs_status", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "benchmark_runs_suite_id_benchmark_suites_id_fk": { + "name": "benchmark_runs_suite_id_benchmark_suites_id_fk", + "tableFrom": "benchmark_runs", + "tableTo": "benchmark_suites", + "columnsFrom": [ + "suite_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.benchmark_suites": { + "name": "benchmark_suites", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cron_expression": { + "name": "cron_expression", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "tags": { + "name": "tags", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "benchmark_suites_created_by_operators_id_fk": { + "name": "benchmark_suites_created_by_operators_id_fk", + "tableFrom": "benchmark_suites", + "tableTo": "operators", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.classifiers": { + "name": "classifiers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "llm_provider_id": { + "name": "llm_provider_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "llm_settings": { + "name": "llm_settings", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "tags": { + "name": "tags", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "classifiers_project_id_projects_id_fk": { + "name": "classifiers_project_id_projects_id_fk", + "tableFrom": "classifiers", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "classifiers_project_id_id_pk": { + "name": "classifiers_project_id_id_pk", + "columns": [ + "project_id", + "id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.context_transformers": { + "name": "context_transformers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "context_fields": { + "name": "context_fields", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "llm_provider_id": { + "name": "llm_provider_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "llm_settings": { + "name": "llm_settings", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "tags": { + "name": "tags", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "context_transformers_project_id_projects_id_fk": { + "name": "context_transformers_project_id_projects_id_fk", + "tableFrom": "context_transformers", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "context_transformers_project_id_id_pk": { + "name": "context_transformers_project_id_id_pk", + "columns": [ + "project_id", + "id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.conversation_artifacts": { + "name": "conversation_artifacts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "conversation_id": { + "name": "conversation_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "artifact_type": { + "name": "artifact_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "event_id": { + "name": "event_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "input_turn_id": { + "name": "input_turn_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "output_turn_id": { + "name": "output_turn_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "storage_key": { + "name": "storage_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "storage_url": { + "name": "storage_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "data": { + "name": "data", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "mime_type": { + "name": "mime_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_size": { + "name": "file_size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "conversation_artifacts_project_id_conversation_id_conversations_project_id_id_fk": { + "name": "conversation_artifacts_project_id_conversation_id_conversations_project_id_id_fk", + "tableFrom": "conversation_artifacts", + "tableTo": "conversations", + "columnsFrom": [ + "project_id", + "conversation_id" + ], + "columnsTo": [ + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "conversation_artifacts_project_id_id_pk": { + "name": "conversation_artifacts_project_id_id_pk", + "columns": [ + "project_id", + "id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.conversation_events": { + "name": "conversation_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "conversation_id": { + "name": "conversation_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "event_type": { + "name": "event_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "event_data": { + "name": "event_data", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "stage_id": { + "name": "stage_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "timestamp": { + "name": "timestamp", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "idx_conversation_events_project_conversation": { + "name": "idx_conversation_events_project_conversation", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "conversation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_conversation_events_project_type_timestamp": { + "name": "idx_conversation_events_project_type_timestamp", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "event_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "timestamp", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "conversation_events_project_id_conversation_id_conversations_project_id_id_fk": { + "name": "conversation_events_project_id_conversation_id_conversations_project_id_id_fk", + "tableFrom": "conversation_events", + "tableTo": "conversations", + "columnsFrom": [ + "project_id", + "conversation_id" + ], + "columnsTo": [ + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "conversation_events_project_id_id_pk": { + "name": "conversation_events_project_id_id_pk", + "columns": [ + "project_id", + "id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.conversations": { + "name": "conversations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "session_id": { + "name": "session_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "stage_id": { + "name": "stage_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "starting_stage_id": { + "name": "starting_stage_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ending_stage_id": { + "name": "ending_stage_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stage_vars": { + "name": "stage_vars", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'initialized'" + }, + "status_reason": { + "name": "status_reason", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": null + }, + "direction": { + "name": "direction", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'incoming'" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "last_activity_at": { + "name": "last_activity_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_conversations_project_user": { + "name": "idx_conversations_project_user", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "conversations_project_id_projects_id_fk": { + "name": "conversations_project_id_projects_id_fk", + "tableFrom": "conversations", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "conversations_project_id_user_id_users_project_id_id_fk": { + "name": "conversations_project_id_user_id_users_project_id_id_fk", + "tableFrom": "conversations", + "tableTo": "users", + "columnsFrom": [ + "project_id", + "user_id" + ], + "columnsTo": [ + "project_id", + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "conversations_project_id_id_pk": { + "name": "conversations_project_id_id_pk", + "columns": [ + "project_id", + "id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.copy_decorators": { + "name": "copy_decorators", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "template": { + "name": "template", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "copy_decorators_project_id_name_unique": { + "name": "copy_decorators_project_id_name_unique", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "copy_decorators_project_id_projects_id_fk": { + "name": "copy_decorators_project_id_projects_id_fk", + "tableFrom": "copy_decorators", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "copy_decorators_project_id_id_pk": { + "name": "copy_decorators_project_id_id_pk", + "columns": [ + "project_id", + "id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.environments": { + "name": "environments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "login": { + "name": "login", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.global_actions": { + "name": "global_actions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "condition": { + "name": "condition", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "trigger_on_user_input": { + "name": "trigger_on_user_input", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "trigger_on_client_command": { + "name": "trigger_on_client_command", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "classification_trigger": { + "name": "classification_trigger", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "override_classifier_id": { + "name": "override_classifier_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "parameters": { + "name": "parameters", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "effects": { + "name": "effects", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "examples": { + "name": "examples", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "tags": { + "name": "tags", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "global_actions_project_id_projects_id_fk": { + "name": "global_actions_project_id_projects_id_fk", + "tableFrom": "global_actions", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "global_actions_project_id_id_pk": { + "name": "global_actions_project_id_id_pk", + "columns": [ + "project_id", + "id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.guardrails": { + "name": "guardrails", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "condition": { + "name": "condition", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "classification_trigger": { + "name": "classification_trigger", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "effects": { + "name": "effects", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "examples": { + "name": "examples", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "tags": { + "name": "tags", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "guardrails_project_id_projects_id_fk": { + "name": "guardrails_project_id_projects_id_fk", + "tableFrom": "guardrails", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "guardrails_project_id_id_pk": { + "name": "guardrails_project_id_id_pk", + "columns": [ + "project_id", + "id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.issues": { + "name": "issues", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "environment": { + "name": "environment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "build_version": { + "name": "build_version", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stage": { + "name": "stage", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "conversation_id": { + "name": "conversation_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "event_index": { + "name": "event_index", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "severity": { + "name": "severity", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "bug_description": { + "name": "bug_description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expected_behaviour": { + "name": "expected_behaviour", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "comments": { + "name": "comments", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "issues_project_id_projects_id_fk": { + "name": "issues_project_id_projects_id_fk", + "tableFrom": "issues", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "issues_project_id_id_pk": { + "name": "issues_project_id_id_pk", + "columns": [ + "project_id", + "id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.knowledge_categories": { + "name": "knowledge_categories", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "prompt_trigger": { + "name": "prompt_trigger", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tags": { + "name": "tags", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "knowledge_categories_project_id_projects_id_fk": { + "name": "knowledge_categories_project_id_projects_id_fk", + "tableFrom": "knowledge_categories", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "knowledge_categories_project_id_id_pk": { + "name": "knowledge_categories_project_id_id_pk", + "columns": [ + "project_id", + "id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.knowledge_items": { + "name": "knowledge_items", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category_id": { + "name": "category_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "question": { + "name": "question", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "answer": { + "name": "answer", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "knowledge_items_project_id_category_id_knowledge_categories_project_id_id_fk": { + "name": "knowledge_items_project_id_category_id_knowledge_categories_project_id_id_fk", + "tableFrom": "knowledge_items", + "tableTo": "knowledge_categories", + "columnsFrom": [ + "project_id", + "category_id" + ], + "columnsTo": [ + "project_id", + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "knowledge_items_project_id_id_pk": { + "name": "knowledge_items_project_id_id_pk", + "columns": [ + "project_id", + "id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.operators": { + "name": "operators", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "roles": { + "name": "roles", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.projects": { + "name": "projects", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "asr_config": { + "name": "asr_config", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "accept_voice": { + "name": "accept_voice", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "generate_voice": { + "name": "generate_voice", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "storage_config": { + "name": "storage_config", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "moderation_config": { + "name": "moderation_config", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "cost_management_config": { + "name": "cost_management_config", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "constants": { + "name": "constants", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "timezone": { + "name": "timezone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "language_code": { + "name": "language_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "auto_create_users": { + "name": "auto_create_users", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "user_profile_variable_descriptors": { + "name": "user_profile_variable_descriptors", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "default_guardrail_classifier_id": { + "name": "default_guardrail_classifier_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sample_copy_config": { + "name": "sample_copy_config", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "starting_stage_id": { + "name": "starting_stage_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "conversation_timeout_seconds": { + "name": "conversation_timeout_seconds", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "recording_config": { + "name": "recording_config", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "archived_by": { + "name": "archived_by", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "projects_archived_by_operators_id_fk": { + "name": "projects_archived_by_operators_id_fk", + "tableFrom": "projects", + "tableTo": "operators", + "columnsFrom": [ + "archived_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.providers": { + "name": "providers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "provider_type": { + "name": "provider_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "api_type": { + "name": "api_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "config": { + "name": "config", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tags": { + "name": "tags", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "providers_created_by_operators_id_fk": { + "name": "providers_created_by_operators_id_fk", + "tableFrom": "providers", + "tableTo": "operators", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sample_copies": { + "name": "sample_copies", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "stages": { + "name": "stages", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "agents": { + "name": "agents", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "prompt_trigger": { + "name": "prompt_trigger", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "classifier_override_id": { + "name": "classifier_override_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "content": { + "name": "content", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "amount": { + "name": "amount", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "sampling_method": { + "name": "sampling_method", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'random'" + }, + "mode": { + "name": "mode", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'regular'" + }, + "decorator_id": { + "name": "decorator_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sample_copies_project_id_name_unique": { + "name": "sample_copies_project_id_name_unique", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sample_copies_project_id_projects_id_fk": { + "name": "sample_copies_project_id_projects_id_fk", + "tableFrom": "sample_copies", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "sample_copies_project_id_decorator_id_copy_decorators_project_id_id_fk": { + "name": "sample_copies_project_id_decorator_id_copy_decorators_project_id_id_fk", + "tableFrom": "sample_copies", + "tableTo": "copy_decorators", + "columnsFrom": [ + "project_id", + "decorator_id" + ], + "columnsTo": [ + "project_id", + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "sample_copies_project_id_id_pk": { + "name": "sample_copies_project_id_id_pk", + "columns": [ + "project_id", + "id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.saved_funnel_queries": { + "name": "saved_funnel_queries", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "operator_id": { + "name": "operator_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "query": { + "name": "query", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "is_shared": { + "name": "is_shared", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "saved_funnel_queries_project_id_name_unique": { + "name": "saved_funnel_queries_project_id_name_unique", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_saved_funnel_queries_project_id": { + "name": "idx_saved_funnel_queries_project_id", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_saved_funnel_queries_operator_id": { + "name": "idx_saved_funnel_queries_operator_id", + "columns": [ + { + "expression": "operator_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "saved_funnel_queries_project_id_projects_id_fk": { + "name": "saved_funnel_queries_project_id_projects_id_fk", + "tableFrom": "saved_funnel_queries", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "saved_funnel_queries_operator_id_operators_id_fk": { + "name": "saved_funnel_queries_operator_id_operators_id_fk", + "tableFrom": "saved_funnel_queries", + "tableTo": "operators", + "columnsFrom": [ + "operator_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.saved_slice_queries": { + "name": "saved_slice_queries", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "operator_id": { + "name": "operator_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "query": { + "name": "query", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "is_shared": { + "name": "is_shared", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "saved_slice_queries_project_id_name_unique": { + "name": "saved_slice_queries_project_id_name_unique", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_saved_slice_queries_project_id": { + "name": "idx_saved_slice_queries_project_id", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_saved_slice_queries_operator_id": { + "name": "idx_saved_slice_queries_operator_id", + "columns": [ + { + "expression": "operator_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "saved_slice_queries_project_id_projects_id_fk": { + "name": "saved_slice_queries_project_id_projects_id_fk", + "tableFrom": "saved_slice_queries", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "saved_slice_queries_operator_id_operators_id_fk": { + "name": "saved_slice_queries_operator_id_operators_id_fk", + "tableFrom": "saved_slice_queries", + "tableTo": "operators", + "columnsFrom": [ + "operator_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.scenario_conversations": { + "name": "scenario_conversations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "scenario_run_id": { + "name": "scenario_run_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "scenario_id": { + "name": "scenario_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tester_id": { + "name": "tester_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "conversation_id": { + "name": "conversation_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'queued'" + }, + "test_run_status": { + "name": "test_run_status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "data_extraction_results": { + "name": "data_extraction_results", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "data_transformation_results": { + "name": "data_transformation_results", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_scenario_conversations_project_run": { + "name": "idx_scenario_conversations_project_run", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "scenario_run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "scenario_conversations_project_id_projects_id_fk": { + "name": "scenario_conversations_project_id_projects_id_fk", + "tableFrom": "scenario_conversations", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "scenario_conversations_project_id_id_pk": { + "name": "scenario_conversations_project_id_id_pk", + "columns": [ + "project_id", + "id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.scenario_runs": { + "name": "scenario_runs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "scenario_id": { + "name": "scenario_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "testers": { + "name": "testers", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "total_conversations": { + "name": "total_conversations", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'queued'" + }, + "status_details": { + "name": "status_details", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "error_count": { + "name": "error_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_scenario_runs_project_scenario": { + "name": "idx_scenario_runs_project_scenario", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "scenario_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "scenario_runs_project_id_projects_id_fk": { + "name": "scenario_runs_project_id_projects_id_fk", + "tableFrom": "scenario_runs", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "scenario_runs_project_id_id_pk": { + "name": "scenario_runs_project_id_id_pk", + "columns": [ + "project_id", + "id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.scenarios": { + "name": "scenarios", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "language": { + "name": "language", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "starting_stage_id": { + "name": "starting_stage_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "max_turns": { + "name": "max_turns", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "ending_stage_ids": { + "name": "ending_stage_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "persona_can_hang_up": { + "name": "persona_can_hang_up", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "conversation_opener": { + "name": "conversation_opener", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "data_extraction": { + "name": "data_extraction", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "context_transformer_id": { + "name": "context_transformer_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "data_post_processing_expected": { + "name": "data_post_processing_expected", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "tags": { + "name": "tags", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "scenarios_project_id_projects_id_fk": { + "name": "scenarios_project_id_projects_id_fk", + "tableFrom": "scenarios", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "scenarios_project_id_id_pk": { + "name": "scenarios_project_id_id_pk", + "columns": [ + "project_id", + "id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.secrets": { + "name": "secrets", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "encrypted_value": { + "name": "encrypted_value", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "iv": { + "name": "iv", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tag": { + "name": "tag", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.stages": { + "name": "stages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "llm_provider_id": { + "name": "llm_provider_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "llm_settings": { + "name": "llm_settings", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "enter_behavior": { + "name": "enter_behavior", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'generate_response'" + }, + "use_knowledge": { + "name": "use_knowledge", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "knowledge_tags": { + "name": "knowledge_tags", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "use_global_actions": { + "name": "use_global_actions", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "global_actions": { + "name": "global_actions", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "variable_descriptors": { + "name": "variable_descriptors", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "actions": { + "name": "actions", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "default_classifier_id": { + "name": "default_classifier_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "transformer_ids": { + "name": "transformer_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "tags": { + "name": "tags", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "stages_project_id_projects_id_fk": { + "name": "stages_project_id_projects_id_fk", + "tableFrom": "stages", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "stages_project_id_agent_id_agents_project_id_id_fk": { + "name": "stages_project_id_agent_id_agents_project_id_id_fk", + "tableFrom": "stages", + "tableTo": "agents", + "columnsFrom": [ + "project_id", + "agent_id" + ], + "columnsTo": [ + "project_id", + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "stages_project_id_default_classifier_id_classifiers_project_id_id_fk": { + "name": "stages_project_id_default_classifier_id_classifiers_project_id_id_fk", + "tableFrom": "stages", + "tableTo": "classifiers", + "columnsFrom": [ + "project_id", + "default_classifier_id" + ], + "columnsTo": [ + "project_id", + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "stages_project_id_id_pk": { + "name": "stages_project_id_id_pk", + "columns": [ + "project_id", + "id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.testers": { + "name": "testers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "hang_up_prompt": { + "name": "hang_up_prompt", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "llm_provider_id": { + "name": "llm_provider_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "llm_settings": { + "name": "llm_settings", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "user_profile": { + "name": "user_profile", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "tags": { + "name": "tags", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "testers_project_id_projects_id_fk": { + "name": "testers_project_id_projects_id_fk", + "tableFrom": "testers", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "testers_project_id_id_pk": { + "name": "testers_project_id_id_pk", + "columns": [ + "project_id", + "id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.tools": { + "name": "tools", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'smart_function'" + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "llm_provider_id": { + "name": "llm_provider_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "llm_settings": { + "name": "llm_settings", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "input_type": { + "name": "input_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "output_type": { + "name": "output_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "webhook_method": { + "name": "webhook_method", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "webhook_headers": { + "name": "webhook_headers", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "webhook_body": { + "name": "webhook_body", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "code": { + "name": "code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "parameters": { + "name": "parameters", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "tags": { + "name": "tags", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "tools_project_id_projects_id_fk": { + "name": "tools_project_id_projects_id_fk", + "tableFrom": "tools", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "tools_project_id_id_pk": { + "name": "tools_project_id_id_pk", + "columns": [ + "project_id", + "id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.users": { + "name": "users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "profile": { + "name": "profile", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "banned": { + "name": "banned", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "ban_reason": { + "name": "ban_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "users_project_id_projects_id_fk": { + "name": "users_project_id_projects_id_fk", + "tableFrom": "users", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "users_project_id_id_pk": { + "name": "users_project_id_id_pk", + "columns": [ + "project_id", + "id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": { + "public.active_projects": { + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "asr_config": { + "name": "asr_config", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "accept_voice": { + "name": "accept_voice", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "generate_voice": { + "name": "generate_voice", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "storage_config": { + "name": "storage_config", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "moderation_config": { + "name": "moderation_config", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "cost_management_config": { + "name": "cost_management_config", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "constants": { + "name": "constants", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "timezone": { + "name": "timezone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "language_code": { + "name": "language_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "auto_create_users": { + "name": "auto_create_users", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "user_profile_variable_descriptors": { + "name": "user_profile_variable_descriptors", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "default_guardrail_classifier_id": { + "name": "default_guardrail_classifier_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sample_copy_config": { + "name": "sample_copy_config", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "starting_stage_id": { + "name": "starting_stage_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "conversation_timeout_seconds": { + "name": "conversation_timeout_seconds", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "recording_config": { + "name": "recording_config", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "archived_by": { + "name": "archived_by", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "definition": "select \"id\", \"name\", \"description\", \"asr_config\", \"accept_voice\", \"generate_voice\", \"storage_config\", \"moderation_config\", \"cost_management_config\", \"constants\", \"metadata\", \"timezone\", \"language_code\", \"auto_create_users\", \"user_profile_variable_descriptors\", \"default_guardrail_classifier_id\", \"sample_copy_config\", \"starting_stage_id\", \"conversation_timeout_seconds\", \"recording_config\", \"version\", \"created_at\", \"updated_at\", \"archived_at\", \"archived_by\" from \"projects\" where \"projects\".\"archived_at\" is null", + "name": "active_projects", + "schema": "public", + "isExisting": false, + "materialized": false + }, + "public.archived_projects": { + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "asr_config": { + "name": "asr_config", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "accept_voice": { + "name": "accept_voice", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "generate_voice": { + "name": "generate_voice", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "storage_config": { + "name": "storage_config", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "moderation_config": { + "name": "moderation_config", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "cost_management_config": { + "name": "cost_management_config", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "constants": { + "name": "constants", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "timezone": { + "name": "timezone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "language_code": { + "name": "language_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "auto_create_users": { + "name": "auto_create_users", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "user_profile_variable_descriptors": { + "name": "user_profile_variable_descriptors", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "default_guardrail_classifier_id": { + "name": "default_guardrail_classifier_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sample_copy_config": { + "name": "sample_copy_config", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "starting_stage_id": { + "name": "starting_stage_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "conversation_timeout_seconds": { + "name": "conversation_timeout_seconds", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "recording_config": { + "name": "recording_config", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "archived_by": { + "name": "archived_by", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "definition": "select \"id\", \"name\", \"description\", \"asr_config\", \"accept_voice\", \"generate_voice\", \"storage_config\", \"moderation_config\", \"cost_management_config\", \"constants\", \"metadata\", \"timezone\", \"language_code\", \"auto_create_users\", \"user_profile_variable_descriptors\", \"default_guardrail_classifier_id\", \"sample_copy_config\", \"starting_stage_id\", \"conversation_timeout_seconds\", \"recording_config\", \"version\", \"created_at\", \"updated_at\", \"archived_at\", \"archived_by\" from \"projects\" where \"projects\".\"archived_at\" is not null", + "name": "archived_projects", + "schema": "public", + "isExisting": false, + "materialized": false + } + }, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json index 91317c3d..0adca056 100644 --- a/drizzle/meta/_journal.json +++ b/drizzle/meta/_journal.json @@ -414,6 +414,13 @@ "when": 1779709747081, "tag": "0058_yellow_layla_miller", "breakpoints": true + }, + { + "idx": 59, + "version": "7", + "when": 1781772460742, + "tag": "0059_slimy_dakota_north", + "breakpoints": true } ] } \ No newline at end of file diff --git a/src/db/schema.ts b/src/db/schema.ts index 3ad12aae..7b353376 100644 --- a/src/db/schema.ts +++ b/src/db/schema.ts @@ -578,7 +578,10 @@ export type DataExtractionEntry = { }; /** Status of a scenario run or scenario conversation */ -export type ScenarioRunStatus = 'queued' | 'in_progress' | 'passed' | 'failed' | 'cancelled'; +export type ScenarioRunStatus = 'queued' | 'in_progress' | 'passed' | 'failed' | 'cancelled' | 'error'; + +/** Possible outcomes for a single test run conversation (persisted on scenarioConversations) */ +export type TestRunStatus = 'conversation_ended' | 'conversation_aborted' | 'conversation_failed' | 'max_turns_reached' | 'tester_hung_up'; // Tester table — persona that acts as a user in scenario testing export const testers = pgTable('testers', { @@ -633,6 +636,7 @@ export const scenarioRuns = pgTable('scenario_runs', { totalConversations: integer('total_conversations').notNull(), status: text('status').notNull().$type().default('queued'), statusDetails: text('status_details'), + errorCount: integer('error_count').notNull().default(0), metadata: jsonb('metadata').$type>(), version: integer('version').notNull().default(1), createdAt: timestamp('created_at').notNull().defaultNow(), @@ -651,6 +655,7 @@ export const scenarioConversations = pgTable('scenario_conversations', { testerId: text('tester_id').notNull(), conversationId: text('conversation_id'), status: text('status').notNull().$type().default('queued'), + testRunStatus: text('test_run_status').$type(), dataExtractionResults: jsonb('data_extraction_results').$type>(), dataTransformationResults: jsonb('data_transformation_results').$type>(), metadata: jsonb('metadata').$type>(), diff --git a/src/http/contracts/scenarioConversation.ts b/src/http/contracts/scenarioConversation.ts index b4531841..7b4ba291 100644 --- a/src/http/contracts/scenarioConversation.ts +++ b/src/http/contracts/scenarioConversation.ts @@ -33,7 +33,8 @@ export const scenarioConversationResponseSchema = z.object({ scenarioId: z.string().describe('ID of the scenario being tested'), testerId: z.string().describe('ID of the tester persona used in this conversation'), conversationId: z.string().nullable().describe('ID of the underlying conversation used to run this scenario conversation'), - status: z.enum(['queued', 'in_progress', 'passed', 'failed', 'cancelled']).describe('Current execution status of this conversation'), + status: z.enum(['queued', 'in_progress', 'passed', 'failed', 'cancelled', 'error']).describe('Current execution status of this conversation'), + testRunStatus: z.enum(['conversation_ended', 'conversation_aborted', 'conversation_failed', 'max_turns_reached', 'tester_hung_up']).nullable().describe('How the test conversation ended'), dataExtractionResults: z.record(z.string(), z.unknown()).nullable().describe('Extracted stage variable values at the end of the conversation'), dataTransformationResults: z.record(z.string(), z.unknown()).nullable().describe('Post-processed data transformation results'), metadata: z.record(z.string(), z.unknown()).nullable().describe('Additional metadata'), diff --git a/src/http/contracts/scenarioRun.ts b/src/http/contracts/scenarioRun.ts index 9a4ede6c..a836fa40 100644 --- a/src/http/contracts/scenarioRun.ts +++ b/src/http/contracts/scenarioRun.ts @@ -8,7 +8,7 @@ extendZodWithOpenApi(z); export { listParamsSchema, type ListParams }; /** Possible statuses for a scenario run or scenario conversation */ -export const scenarioRunStatusSchema = z.enum(['queued', 'in_progress', 'passed', 'failed', 'cancelled']).openapi('ScenarioRunStatus'); +export const scenarioRunStatusSchema = z.enum(['queued', 'in_progress', 'passed', 'failed', 'cancelled', 'error']).openapi('ScenarioRunStatus'); /** * Schema for scenario run route params @@ -38,6 +38,7 @@ export const scenarioRunResponseSchema = z.object({ totalConversations: z.number().int().describe('Computed total number of conversations across all testers'), status: scenarioRunStatusSchema.describe('Current status of the scenario run'), statusDetails: z.string().nullable().describe('Human-readable details about the current status, e.g. failure reason or cancellation actor'), + errorCount: z.number().int().min(0).describe('Number of conversations that errored during execution (excluded from pass/fail evaluation)'), metadata: z.record(z.string(), z.unknown()).nullable().describe('Additional metadata'), version: z.number().int().describe('Version number for optimistic locking'), createdAt: z.coerce.date().describe('Timestamp when the run was created'), diff --git a/src/services/testing/ScenarioConversationService.ts b/src/services/testing/ScenarioConversationService.ts index d1d109c2..eb18fffd 100644 --- a/src/services/testing/ScenarioConversationService.ts +++ b/src/services/testing/ScenarioConversationService.ts @@ -2,7 +2,7 @@ import { injectable } from 'tsyringe'; import { eq, and, SQL, desc, isNotNull } from 'drizzle-orm'; import { db } from '../../db/index'; import { scenarioConversations } from '../../db/schema'; -import type { ScenarioRunStatus } from '../../db/schema'; +import type { ScenarioRunStatus, TestRunStatus } from '../../db/schema'; import type { ScenarioConversationResponse, ScenarioConversationListResponse, ScenarioConversationListParams } from '../../http/contracts/scenarioConversation'; import { scenarioConversationResponseSchema, scenarioConversationListResponseSchema } from '../../http/contracts/scenarioConversation'; import { NotFoundError } from '../../errors'; @@ -25,6 +25,7 @@ export type CreateScenarioConversationInput = { export type ScenarioConversationResults = { dataExtractionResults?: Record; dataTransformationResults?: Record; + testRunStatus?: TestRunStatus; }; /** @@ -143,6 +144,7 @@ export class ScenarioConversationService extends BaseService { const updateData: Record = { status, updatedAt: new Date() }; if (results?.dataExtractionResults !== undefined) updateData.dataExtractionResults = results.dataExtractionResults; if (results?.dataTransformationResults !== undefined) updateData.dataTransformationResults = results.dataTransformationResults; + if (results?.testRunStatus !== undefined) updateData.testRunStatus = results.testRunStatus; await db.update(scenarioConversations).set(updateData).where(and(eq(scenarioConversations.id, id), eq(scenarioConversations.projectId, projectId))); logger.info({ id, status }, 'Scenario conversation status updated'); } catch (error) { diff --git a/src/services/testing/ScenarioRunExecutorService.ts b/src/services/testing/ScenarioRunExecutorService.ts index fe5731b6..91acd01d 100644 --- a/src/services/testing/ScenarioRunExecutorService.ts +++ b/src/services/testing/ScenarioRunExecutorService.ts @@ -23,6 +23,11 @@ type ConversationSlot = { scenarioConversationId: string; }; +/** Result of executing a single conversation slot */ +type SlotResult = { + result: 'passed' | 'failed' | 'error' | 'cancelled'; +}; + /** * Background service that processes queued scenario runs. * Picks up 'queued' runs, orchestrates parallel test conversations with a global @@ -170,12 +175,13 @@ export class ScenarioRunExecutorService { if (this.cancelledRunIds.has(run.id)) { logger.info({ runId: run.id }, 'Scenario run was cancelled mid-flight, skipping final status update'); } else { - const allPassed = results.every((r) => r); - const finalStatus = allPassed ? 'passed' : 'failed'; - const failedCount = results.filter((r) => !r).length; - const statusDetails = allPassed ? null : `${failedCount} of ${results.length} conversation${results.length !== 1 ? 's' : ''} failed`; - await this.scenarioRunService.updateRunStatus(run.id, run.projectId, finalStatus, statusDetails); - logger.info({ runId: run.id, finalStatus }, 'Scenario run completed'); + const passedCount = results.filter((r) => r.result === 'passed').length; + const failedCount = results.filter((r) => r.result === 'failed').length; + const errorCount = results.filter((r) => r.result === 'error').length; + const finalStatus = failedCount > 0 ? 'failed' : (passedCount > 0 ? 'passed' : 'failed'); + const statusDetails = failedCount > 0 ? `${failedCount} of ${results.length} conversation${results.length !== 1 ? 's' : ''} failed` : null; + await this.scenarioRunService.updateRunStatus(run.id, run.projectId, finalStatus, statusDetails, errorCount); + logger.info({ runId: run.id, finalStatus, passedCount, failedCount, errorCount }, 'Scenario run completed'); } } catch (error) { logger.error({ error, runId: run.id }, 'Scenario run failed with error'); @@ -194,18 +200,18 @@ export class ScenarioRunExecutorService { * @param run - The parent scenario run * @param scenario - The scenario configuration * @param testerMap - Map of testerId to tester configuration - * @returns True if the conversation passed evaluation, false otherwise + * @returns SlotResult indicating passed, failed, error, or cancelled */ private async executeSlot( slot: ConversationSlot, run: ScenarioRunResponse, scenario: Awaited>, testerMap: Map>>, - ): Promise { + ): Promise { if (this.cancelledRunIds.has(run.id)) { logger.info({ runId: run.id, scenarioConversationId: slot.scenarioConversationId }, 'Skipping slot — run was cancelled'); await this.scenarioConversationService.updateScenarioConversationStatus(slot.scenarioConversationId, run.projectId, 'cancelled').catch(() => {}); - return false; + return { result: 'cancelled' }; } await this.acquireSlot(); @@ -227,16 +233,21 @@ export class ScenarioRunExecutorService { const testResult = await this.testRunner.run(conversationId, run.projectId, tester, scenario); logger.info({ runId: run.id, scenarioConversationId: slot.scenarioConversationId, testStatus: testResult.status, turnCount: testResult.turnCount }, 'Test conversation completed'); + if (testResult.status === 'conversation_failed') { + await this.scenarioConversationService.updateScenarioConversationStatus(slot.scenarioConversationId, run.projectId, 'error', { testRunStatus: testResult.status }); + return { result: 'error' }; + } + const evaluation = await this.evaluator.evaluate(conversationId, run.projectId, scenario); const conversationStatus = evaluation.passed ? 'passed' : 'failed'; - await this.scenarioConversationService.updateScenarioConversationStatus(slot.scenarioConversationId, run.projectId, conversationStatus, { dataExtractionResults: evaluation.dataExtractionResults, dataTransformationResults: evaluation.dataTransformationResults ?? undefined }); + await this.scenarioConversationService.updateScenarioConversationStatus(slot.scenarioConversationId, run.projectId, conversationStatus, { dataExtractionResults: evaluation.dataExtractionResults, dataTransformationResults: evaluation.dataTransformationResults ?? undefined, testRunStatus: testResult.status }); - return evaluation.passed; + return { result: conversationStatus }; } catch (error) { logger.error({ error, runId: run.id, scenarioConversationId: slot.scenarioConversationId }, 'Conversation slot failed'); - await this.scenarioConversationService.updateScenarioConversationStatus(slot.scenarioConversationId, run.projectId, 'failed').catch(() => {}); - return false; + await this.scenarioConversationService.updateScenarioConversationStatus(slot.scenarioConversationId, run.projectId, 'error').catch(() => {}); + return { result: 'error' }; } finally { this.releaseSlot(); } diff --git a/src/services/testing/ScenarioRunService.ts b/src/services/testing/ScenarioRunService.ts index 54ff74e7..e4945a75 100644 --- a/src/services/testing/ScenarioRunService.ts +++ b/src/services/testing/ScenarioRunService.ts @@ -172,9 +172,11 @@ export class ScenarioRunService extends BaseService { * @param projectId - The project the run belongs to * @param status - The new status to set */ - async updateRunStatus(runId: string, projectId: string, status: ScenarioRunStatus, statusDetails?: string | null): Promise { + async updateRunStatus(runId: string, projectId: string, status: ScenarioRunStatus, statusDetails?: string | null, errorCount?: number): Promise { try { - await db.update(scenarioRuns).set({ status, statusDetails: statusDetails ?? null, updatedAt: new Date() }).where(and(eq(scenarioRuns.id, runId), eq(scenarioRuns.projectId, projectId))); + const updateData: Record = { status, statusDetails: statusDetails ?? null, updatedAt: new Date() }; + if (errorCount !== undefined) updateData.errorCount = errorCount; + await db.update(scenarioRuns).set(updateData).where(and(eq(scenarioRuns.id, runId), eq(scenarioRuns.projectId, projectId))); logger.info({ runId, status }, 'Scenario run status updated'); } catch (error) { logger.error({ error, runId, status }, 'Failed to update scenario run status'); @@ -220,7 +222,7 @@ export class ScenarioRunService extends BaseService { try { const run = await db.query.scenarioRuns.findFirst({ where: and(eq(scenarioRuns.id, runId), eq(scenarioRuns.projectId, projectId)) }); if (!run) throw new NotFoundError(`Scenario run with id ${runId} not found`); - if (!['passed', 'failed', 'cancelled'].includes(run.status)) { + if (!['passed', 'failed', 'cancelled', 'error'].includes(run.status)) { throw new ConflictError(`Scenario run ${runId} cannot be deleted in status '${run.status}'. Cancel it first.`); } await db.delete(scenarioConversations).where(and(eq(scenarioConversations.scenarioRunId, runId), eq(scenarioConversations.projectId, projectId)));