diff --git a/control-plane/drizzle/0209_stiff_tenebrous.sql b/control-plane/drizzle/0209_stiff_tenebrous.sql new file mode 100644 index 00000000..12ce0193 --- /dev/null +++ b/control-plane/drizzle/0209_stiff_tenebrous.sql @@ -0,0 +1,2 @@ +ALTER TABLE "workflows" ADD COLUMN "on_status_change_statuses" json;--> statement-breakpoint +ALTER TABLE "services" DROP COLUMN IF EXISTS "queue_url"; \ No newline at end of file diff --git a/control-plane/drizzle/0210_tiny_katie_power.sql b/control-plane/drizzle/0210_tiny_katie_power.sql new file mode 100644 index 00000000..cc337392 --- /dev/null +++ b/control-plane/drizzle/0210_tiny_katie_power.sql @@ -0,0 +1 @@ +ALTER TABLE "workflows" ALTER COLUMN "status" SET NOT NULL; \ No newline at end of file diff --git a/control-plane/drizzle/meta/0209_snapshot.json b/control-plane/drizzle/meta/0209_snapshot.json new file mode 100644 index 00000000..a378e0a2 --- /dev/null +++ b/control-plane/drizzle/meta/0209_snapshot.json @@ -0,0 +1,1682 @@ +{ + "id": "92edb2aa-db29-4d49-8d0a-7a53b224e5af", + "prevId": "9abd6210-0eb9-49cd-b53a-16c1c728e9b6", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.agents": { + "name": "agents", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "cluster_id": { + "name": "cluster_id", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "initial_prompt": { + "name": "initial_prompt", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "system_prompt": { + "name": "system_prompt", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": false + }, + "attached_functions": { + "name": "attached_functions", + "type": "json", + "primaryKey": false, + "notNull": true, + "default": "'[]'::json" + }, + "structured_output": { + "name": "structured_output", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "input_schema": { + "name": "input_schema", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "agents_cluster_id_clusters_id_fk": { + "name": "agents_cluster_id_clusters_id_fk", + "tableFrom": "agents", + "tableTo": "clusters", + "columnsFrom": [ + "cluster_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "prompt_templates_pkey": { + "name": "prompt_templates_pkey", + "columns": [ + "cluster_id", + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "public.analytics_snapshots": { + "name": "analytics_snapshots", + "schema": "", + "columns": { + "data": { + "name": "data", + "type": "json", + "primaryKey": false, + "notNull": true + }, + "timestamp": { + "name": "timestamp", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "analytics_snapshots_pkey": { + "name": "analytics_snapshots_pkey", + "columns": [ + "timestamp" + ] + } + }, + "uniqueConstraints": {} + }, + "public.api_keys": { + "name": "api_keys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "cluster_id": { + "name": "cluster_id", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "secret_hash": { + "name": "secret_hash", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "revoked_at": { + "name": "revoked_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "api_keys_secret_hash_index": { + "name": "api_keys_secret_hash_index", + "columns": [ + { + "expression": "secret_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "api_keys_cluster_id_clusters_id_fk": { + "name": "api_keys_cluster_id_clusters_id_fk", + "tableFrom": "api_keys", + "tableTo": "clusters", + "columnsFrom": [ + "cluster_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "api_keys_cluster_id_id_pk": { + "name": "api_keys_cluster_id_id_pk", + "columns": [ + "cluster_id", + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "public.blobs": { + "name": "blobs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "cluster_id": { + "name": "cluster_id", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": false + }, + "job_id": { + "name": "job_id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": false + }, + "data": { + "name": "data", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "encoding": { + "name": "encoding", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "blobs_cluster_id_job_id_jobs_cluster_id_id_fk": { + "name": "blobs_cluster_id_job_id_jobs_cluster_id_id_fk", + "tableFrom": "blobs", + "tableTo": "jobs", + "columnsFrom": [ + "cluster_id", + "job_id" + ], + "columnsTo": [ + "cluster_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "blobs_cluster_id_workflow_id_workflows_cluster_id_id_fk": { + "name": "blobs_cluster_id_workflow_id_workflows_cluster_id_id_fk", + "tableFrom": "blobs", + "tableTo": "workflows", + "columnsFrom": [ + "cluster_id", + "workflow_id" + ], + "columnsTo": [ + "cluster_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "blobs_cluster_id_id_pk": { + "name": "blobs_cluster_id_id_pk", + "columns": [ + "cluster_id", + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "public.clusters": { + "name": "clusters", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(1024)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "debug": { + "name": "debug", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "enable_custom_auth": { + "name": "enable_custom_auth", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "handle_custom_auth_function": { + "name": "handle_custom_auth_function", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true, + "default": "'default_handleCustomAuth'" + }, + "enable_knowledgebase": { + "name": "enable_knowledgebase", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "description": { + "name": "description", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "additional_context": { + "name": "additional_context", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6) with time zone", + "primaryKey": false, + "notNull": false + }, + "is_demo": { + "name": "is_demo", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": { + "clusters_id_org_index": { + "name": "clusters_id_org_index", + "columns": [ + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.embeddings": { + "name": "embeddings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "cluster_id": { + "name": "cluster_id", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "model": { + "name": "model", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "embedding_1024": { + "name": "embedding_1024", + "type": "vector(1024)", + "primaryKey": false, + "notNull": false + }, + "raw_data": { + "name": "raw_data", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "raw_data_hash": { + "name": "raw_data_hash", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "tags": { + "name": "tags", + "type": "json", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "embedding1024Index": { + "name": "embedding1024Index", + "columns": [ + { + "expression": "embedding_1024", + "isExpression": false, + "asc": true, + "nulls": "last", + "opclass": "vector_cosine_ops" + } + ], + "isUnique": false, + "concurrently": false, + "method": "hnsw", + "with": {} + }, + "embeddingsLookupIndex": { + "name": "embeddingsLookupIndex", + "columns": [ + { + "expression": "cluster_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "group_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "raw_data_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "embeddings_cluster_id_id_type_pk": { + "name": "embeddings_cluster_id_id_type_pk", + "columns": [ + "cluster_id", + "id", + "type" + ] + } + }, + "uniqueConstraints": {} + }, + "public.events": { + "name": "events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "cluster_id": { + "name": "cluster_id", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "job_id": { + "name": "job_id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": false + }, + "machine_id": { + "name": "machine_id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": false + }, + "service": { + "name": "service", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": false + }, + "target_fn": { + "name": "target_fn", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": false + }, + "result_type": { + "name": "result_type", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": false + }, + "run_id": { + "name": "run_id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": false + }, + "tool_name": { + "name": "tool_name", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": false + }, + "model_id": { + "name": "model_id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": false + }, + "token_usage_input": { + "name": "token_usage_input", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "token_usage_output": { + "name": "token_usage_output", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "attention_level": { + "name": "attention_level", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "meta": { + "name": "meta", + "type": "json", + "primaryKey": false, + "notNull": true, + "default": "'{}'::json" + } + }, + "indexes": { + "timeline_index": { + "name": "timeline_index", + "columns": [ + { + "expression": "cluster_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "attention_level", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.external_messages": { + "name": "external_messages", + "schema": "", + "columns": { + "message_id": { + "name": "message_id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "run_id": { + "name": "run_id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "cluster_id": { + "name": "cluster_id", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "external_id": { + "name": "external_id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "channel": { + "name": "channel", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "externalMessagesIndex": { + "name": "externalMessagesIndex", + "columns": [ + { + "expression": "external_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "cluster_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "external_messages_message_id_run_id_cluster_id_workflow_messages_id_workflow_id_cluster_id_fk": { + "name": "external_messages_message_id_run_id_cluster_id_workflow_messages_id_workflow_id_cluster_id_fk", + "tableFrom": "external_messages", + "tableTo": "workflow_messages", + "columnsFrom": [ + "message_id", + "run_id", + "cluster_id" + ], + "columnsTo": [ + "id", + "workflow_id", + "cluster_id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "external_messages_pkey": { + "name": "external_messages_pkey", + "columns": [ + "cluster_id", + "external_id" + ] + } + }, + "uniqueConstraints": {} + }, + "public.integrations": { + "name": "integrations", + "schema": "", + "columns": { + "cluster_id": { + "name": "cluster_id", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "toolhouse": { + "name": "toolhouse", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "langfuse": { + "name": "langfuse", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "tavily": { + "name": "tavily", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "valtown": { + "name": "valtown", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "slack": { + "name": "slack", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "integrations_cluster_id_clusters_id_fk": { + "name": "integrations_cluster_id_clusters_id_fk", + "tableFrom": "integrations", + "tableTo": "clusters", + "columnsFrom": [ + "cluster_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "integrations_pkey": { + "name": "integrations_pkey", + "columns": [ + "cluster_id" + ] + } + }, + "uniqueConstraints": {} + }, + "public.jobs": { + "name": "jobs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "cluster_id": { + "name": "cluster_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target_fn": { + "name": "target_fn", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "target_args": { + "name": "target_args", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "cache_key": { + "name": "cache_key", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "result": { + "name": "result", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "result_type": { + "name": "result_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "executing_machine_id": { + "name": "executing_machine_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "remaining_attempts": { + "name": "remaining_attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "resulted_at": { + "name": "resulted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_retrieved_at": { + "name": "last_retrieved_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "function_execution_time_ms": { + "name": "function_execution_time_ms", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "timeout_interval_seconds": { + "name": "timeout_interval_seconds", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 30 + }, + "service": { + "name": "service", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "auth_context": { + "name": "auth_context", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "run_context": { + "name": "run_context", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "approval_requested": { + "name": "approval_requested", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "approved": { + "name": "approved", + "type": "boolean", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "clusterServiceStatusIndex": { + "name": "clusterServiceStatusIndex", + "columns": [ + { + "expression": "cluster_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "service", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "clusterServiceStatusFnIndex": { + "name": "clusterServiceStatusFnIndex", + "columns": [ + { + "expression": "cluster_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "service", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "target_fn", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "jobs_cluster_id_id": { + "name": "jobs_cluster_id_id", + "columns": [ + "cluster_id", + "id" + ] + } + }, + "uniqueConstraints": { + "jobs_id_unique": { + "name": "jobs_id_unique", + "nullsNotDistinct": false, + "columns": [ + "id" + ] + } + } + }, + "public.machines": { + "name": "machines", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "last_ping_at": { + "name": "last_ping_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "sdk_version": { + "name": "sdk_version", + "type": "varchar(128)", + "primaryKey": false, + "notNull": false + }, + "sdk_language": { + "name": "sdk_language", + "type": "varchar(128)", + "primaryKey": false, + "notNull": false + }, + "ip": { + "name": "ip", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "cluster_id": { + "name": "cluster_id", + "type": "varchar", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "machines_id_cluster_id": { + "name": "machines_id_cluster_id", + "columns": [ + "id", + "cluster_id" + ] + } + }, + "uniqueConstraints": {} + }, + "public.workflow_messages": { + "name": "workflow_messages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "cluster_id": { + "name": "cluster_id", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6) with time zone", + "primaryKey": false, + "notNull": false + }, + "data": { + "name": "data", + "type": "json", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "metadata": { + "name": "metadata", + "type": "json", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "workflow_messages_workflow_id_cluster_id_workflows_id_cluster_id_fk": { + "name": "workflow_messages_workflow_id_cluster_id_workflows_id_cluster_id_fk", + "tableFrom": "workflow_messages", + "tableTo": "workflows", + "columnsFrom": [ + "workflow_id", + "cluster_id" + ], + "columnsTo": [ + "id", + "cluster_id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "workflow_messages_cluster_id_workflow_id_id": { + "name": "workflow_messages_cluster_id_workflow_id_id", + "columns": [ + "cluster_id", + "workflow_id", + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "public.workflow_metadata": { + "name": "workflow_metadata", + "schema": "", + "columns": { + "cluster_id": { + "name": "cluster_id", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "key": { + "name": "key", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "workflowMetadataIndex": { + "name": "workflowMetadataIndex", + "columns": [ + { + "expression": "key", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "value", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "cluster_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workflow_metadata_workflow_id_cluster_id_workflows_id_cluster_id_fk": { + "name": "workflow_metadata_workflow_id_cluster_id_workflows_id_cluster_id_fk", + "tableFrom": "workflow_metadata", + "tableTo": "workflows", + "columnsFrom": [ + "workflow_id", + "cluster_id" + ], + "columnsTo": [ + "id", + "cluster_id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "workflow_metadata_cluster_id_workflow_id_key": { + "name": "workflow_metadata_cluster_id_workflow_id_key", + "columns": [ + "cluster_id", + "workflow_id", + "key" + ] + } + }, + "uniqueConstraints": {} + }, + "public.workflows": { + "name": "workflows", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "result_function": { + "name": "result_function", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": false + }, + "on_status_change_statuses": { + "name": "on_status_change_statuses", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "result_schema": { + "name": "result_schema", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "system_prompt": { + "name": "system_prompt", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": false + }, + "model_identifier": { + "name": "model_identifier", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "cluster_id": { + "name": "cluster_id", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'pending'" + }, + "failure_reason": { + "name": "failure_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "debug": { + "name": "debug", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "attached_functions": { + "name": "attached_functions", + "type": "json", + "primaryKey": false, + "notNull": true, + "default": "'[]'::json" + }, + "test": { + "name": "test", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "test_mocks": { + "name": "test_mocks", + "type": "json", + "primaryKey": false, + "notNull": false, + "default": "'{}'::json" + }, + "feedback_comment": { + "name": "feedback_comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "feedback_score": { + "name": "feedback_score", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "agent_id": { + "name": "agent_id", + "type": "varchar(128)", + "primaryKey": false, + "notNull": false + }, + "agent_version": { + "name": "agent_version", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "reasoning_traces": { + "name": "reasoning_traces", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "interactive": { + "name": "interactive", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "enable_summarization": { + "name": "enable_summarization", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "enable_result_grounding": { + "name": "enable_result_grounding", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "auth_context": { + "name": "auth_context", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "context": { + "name": "context", + "type": "json", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "workflows_cluster_id_clusters_id_fk": { + "name": "workflows_cluster_id_clusters_id_fk", + "tableFrom": "workflows", + "tableTo": "clusters", + "columnsFrom": [ + "cluster_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "workflows_cluster_id_id": { + "name": "workflows_cluster_id_id", + "columns": [ + "cluster_id", + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "public.services": { + "name": "services", + "schema": "", + "columns": { + "cluster_id": { + "name": "cluster_id", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "service": { + "name": "service", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "definition": { + "name": "definition", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "timestamp": { + "name": "timestamp", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "services_cluster_id_clusters_id_fk": { + "name": "services_cluster_id_clusters_id_fk", + "tableFrom": "services", + "tableTo": "clusters", + "columnsFrom": [ + "cluster_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "services_cluster_id_service": { + "name": "services_cluster_id_service", + "columns": [ + "cluster_id", + "service" + ] + } + }, + "uniqueConstraints": {} + }, + "public.versioned_entities": { + "name": "versioned_entities", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "cluster_id": { + "name": "cluster_id", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(128)", + "primaryKey": false, + "notNull": true + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "entity": { + "name": "entity", + "type": "json", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "versioned_entities_pkey": { + "name": "versioned_entities_pkey", + "columns": [ + "cluster_id", + "id", + "type", + "version" + ] + } + }, + "uniqueConstraints": {} + } + }, + "enums": {}, + "schemas": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/control-plane/drizzle/meta/0210_snapshot.json b/control-plane/drizzle/meta/0210_snapshot.json new file mode 100644 index 00000000..f15c23f7 --- /dev/null +++ b/control-plane/drizzle/meta/0210_snapshot.json @@ -0,0 +1,1682 @@ +{ + "id": "ea3f7e5e-5868-4291-907c-4b45d41a919d", + "prevId": "92edb2aa-db29-4d49-8d0a-7a53b224e5af", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.agents": { + "name": "agents", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "cluster_id": { + "name": "cluster_id", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "initial_prompt": { + "name": "initial_prompt", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "system_prompt": { + "name": "system_prompt", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": false + }, + "attached_functions": { + "name": "attached_functions", + "type": "json", + "primaryKey": false, + "notNull": true, + "default": "'[]'::json" + }, + "structured_output": { + "name": "structured_output", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "input_schema": { + "name": "input_schema", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "agents_cluster_id_clusters_id_fk": { + "name": "agents_cluster_id_clusters_id_fk", + "tableFrom": "agents", + "tableTo": "clusters", + "columnsFrom": [ + "cluster_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "prompt_templates_pkey": { + "name": "prompt_templates_pkey", + "columns": [ + "cluster_id", + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "public.analytics_snapshots": { + "name": "analytics_snapshots", + "schema": "", + "columns": { + "data": { + "name": "data", + "type": "json", + "primaryKey": false, + "notNull": true + }, + "timestamp": { + "name": "timestamp", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "analytics_snapshots_pkey": { + "name": "analytics_snapshots_pkey", + "columns": [ + "timestamp" + ] + } + }, + "uniqueConstraints": {} + }, + "public.api_keys": { + "name": "api_keys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "cluster_id": { + "name": "cluster_id", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "secret_hash": { + "name": "secret_hash", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "revoked_at": { + "name": "revoked_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "api_keys_secret_hash_index": { + "name": "api_keys_secret_hash_index", + "columns": [ + { + "expression": "secret_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "api_keys_cluster_id_clusters_id_fk": { + "name": "api_keys_cluster_id_clusters_id_fk", + "tableFrom": "api_keys", + "tableTo": "clusters", + "columnsFrom": [ + "cluster_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "api_keys_cluster_id_id_pk": { + "name": "api_keys_cluster_id_id_pk", + "columns": [ + "cluster_id", + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "public.blobs": { + "name": "blobs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "cluster_id": { + "name": "cluster_id", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": false + }, + "job_id": { + "name": "job_id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": false + }, + "data": { + "name": "data", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "encoding": { + "name": "encoding", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "blobs_cluster_id_job_id_jobs_cluster_id_id_fk": { + "name": "blobs_cluster_id_job_id_jobs_cluster_id_id_fk", + "tableFrom": "blobs", + "tableTo": "jobs", + "columnsFrom": [ + "cluster_id", + "job_id" + ], + "columnsTo": [ + "cluster_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "blobs_cluster_id_workflow_id_workflows_cluster_id_id_fk": { + "name": "blobs_cluster_id_workflow_id_workflows_cluster_id_id_fk", + "tableFrom": "blobs", + "tableTo": "workflows", + "columnsFrom": [ + "cluster_id", + "workflow_id" + ], + "columnsTo": [ + "cluster_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "blobs_cluster_id_id_pk": { + "name": "blobs_cluster_id_id_pk", + "columns": [ + "cluster_id", + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "public.clusters": { + "name": "clusters", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(1024)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "debug": { + "name": "debug", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "enable_custom_auth": { + "name": "enable_custom_auth", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "handle_custom_auth_function": { + "name": "handle_custom_auth_function", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true, + "default": "'default_handleCustomAuth'" + }, + "enable_knowledgebase": { + "name": "enable_knowledgebase", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "description": { + "name": "description", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": false + }, + "organization_id": { + "name": "organization_id", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "additional_context": { + "name": "additional_context", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (6) with time zone", + "primaryKey": false, + "notNull": false + }, + "is_demo": { + "name": "is_demo", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": { + "clusters_id_org_index": { + "name": "clusters_id_org_index", + "columns": [ + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.embeddings": { + "name": "embeddings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "cluster_id": { + "name": "cluster_id", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "model": { + "name": "model", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "embedding_1024": { + "name": "embedding_1024", + "type": "vector(1024)", + "primaryKey": false, + "notNull": false + }, + "raw_data": { + "name": "raw_data", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "raw_data_hash": { + "name": "raw_data_hash", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "tags": { + "name": "tags", + "type": "json", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "embedding1024Index": { + "name": "embedding1024Index", + "columns": [ + { + "expression": "embedding_1024", + "isExpression": false, + "asc": true, + "nulls": "last", + "opclass": "vector_cosine_ops" + } + ], + "isUnique": false, + "concurrently": false, + "method": "hnsw", + "with": {} + }, + "embeddingsLookupIndex": { + "name": "embeddingsLookupIndex", + "columns": [ + { + "expression": "cluster_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "group_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "raw_data_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "embeddings_cluster_id_id_type_pk": { + "name": "embeddings_cluster_id_id_type_pk", + "columns": [ + "cluster_id", + "id", + "type" + ] + } + }, + "uniqueConstraints": {} + }, + "public.events": { + "name": "events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "cluster_id": { + "name": "cluster_id", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "job_id": { + "name": "job_id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": false + }, + "machine_id": { + "name": "machine_id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": false + }, + "service": { + "name": "service", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": false + }, + "target_fn": { + "name": "target_fn", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": false + }, + "result_type": { + "name": "result_type", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": false + }, + "run_id": { + "name": "run_id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": false + }, + "tool_name": { + "name": "tool_name", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": false + }, + "model_id": { + "name": "model_id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": false + }, + "token_usage_input": { + "name": "token_usage_input", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "token_usage_output": { + "name": "token_usage_output", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "attention_level": { + "name": "attention_level", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "meta": { + "name": "meta", + "type": "json", + "primaryKey": false, + "notNull": true, + "default": "'{}'::json" + } + }, + "indexes": { + "timeline_index": { + "name": "timeline_index", + "columns": [ + { + "expression": "cluster_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "attention_level", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.external_messages": { + "name": "external_messages", + "schema": "", + "columns": { + "message_id": { + "name": "message_id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "run_id": { + "name": "run_id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "cluster_id": { + "name": "cluster_id", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "external_id": { + "name": "external_id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "channel": { + "name": "channel", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "externalMessagesIndex": { + "name": "externalMessagesIndex", + "columns": [ + { + "expression": "external_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "cluster_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "external_messages_message_id_run_id_cluster_id_workflow_messages_id_workflow_id_cluster_id_fk": { + "name": "external_messages_message_id_run_id_cluster_id_workflow_messages_id_workflow_id_cluster_id_fk", + "tableFrom": "external_messages", + "tableTo": "workflow_messages", + "columnsFrom": [ + "message_id", + "run_id", + "cluster_id" + ], + "columnsTo": [ + "id", + "workflow_id", + "cluster_id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "external_messages_pkey": { + "name": "external_messages_pkey", + "columns": [ + "cluster_id", + "external_id" + ] + } + }, + "uniqueConstraints": {} + }, + "public.integrations": { + "name": "integrations", + "schema": "", + "columns": { + "cluster_id": { + "name": "cluster_id", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "toolhouse": { + "name": "toolhouse", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "langfuse": { + "name": "langfuse", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "tavily": { + "name": "tavily", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "valtown": { + "name": "valtown", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "slack": { + "name": "slack", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "integrations_cluster_id_clusters_id_fk": { + "name": "integrations_cluster_id_clusters_id_fk", + "tableFrom": "integrations", + "tableTo": "clusters", + "columnsFrom": [ + "cluster_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "integrations_pkey": { + "name": "integrations_pkey", + "columns": [ + "cluster_id" + ] + } + }, + "uniqueConstraints": {} + }, + "public.jobs": { + "name": "jobs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "cluster_id": { + "name": "cluster_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target_fn": { + "name": "target_fn", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "target_args": { + "name": "target_args", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "cache_key": { + "name": "cache_key", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "result": { + "name": "result", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "result_type": { + "name": "result_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "executing_machine_id": { + "name": "executing_machine_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "remaining_attempts": { + "name": "remaining_attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "resulted_at": { + "name": "resulted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_retrieved_at": { + "name": "last_retrieved_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "function_execution_time_ms": { + "name": "function_execution_time_ms", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "timeout_interval_seconds": { + "name": "timeout_interval_seconds", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 30 + }, + "service": { + "name": "service", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "auth_context": { + "name": "auth_context", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "run_context": { + "name": "run_context", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "approval_requested": { + "name": "approval_requested", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "approved": { + "name": "approved", + "type": "boolean", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "clusterServiceStatusIndex": { + "name": "clusterServiceStatusIndex", + "columns": [ + { + "expression": "cluster_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "service", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "clusterServiceStatusFnIndex": { + "name": "clusterServiceStatusFnIndex", + "columns": [ + { + "expression": "cluster_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "service", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "target_fn", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "jobs_cluster_id_id": { + "name": "jobs_cluster_id_id", + "columns": [ + "cluster_id", + "id" + ] + } + }, + "uniqueConstraints": { + "jobs_id_unique": { + "name": "jobs_id_unique", + "nullsNotDistinct": false, + "columns": [ + "id" + ] + } + } + }, + "public.machines": { + "name": "machines", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "last_ping_at": { + "name": "last_ping_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "sdk_version": { + "name": "sdk_version", + "type": "varchar(128)", + "primaryKey": false, + "notNull": false + }, + "sdk_language": { + "name": "sdk_language", + "type": "varchar(128)", + "primaryKey": false, + "notNull": false + }, + "ip": { + "name": "ip", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "cluster_id": { + "name": "cluster_id", + "type": "varchar", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "machines_id_cluster_id": { + "name": "machines_id_cluster_id", + "columns": [ + "id", + "cluster_id" + ] + } + }, + "uniqueConstraints": {} + }, + "public.workflow_messages": { + "name": "workflow_messages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "cluster_id": { + "name": "cluster_id", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (6) with time zone", + "primaryKey": false, + "notNull": false + }, + "data": { + "name": "data", + "type": "json", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "metadata": { + "name": "metadata", + "type": "json", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "workflow_messages_workflow_id_cluster_id_workflows_id_cluster_id_fk": { + "name": "workflow_messages_workflow_id_cluster_id_workflows_id_cluster_id_fk", + "tableFrom": "workflow_messages", + "tableTo": "workflows", + "columnsFrom": [ + "workflow_id", + "cluster_id" + ], + "columnsTo": [ + "id", + "cluster_id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "workflow_messages_cluster_id_workflow_id_id": { + "name": "workflow_messages_cluster_id_workflow_id_id", + "columns": [ + "cluster_id", + "workflow_id", + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "public.workflow_metadata": { + "name": "workflow_metadata", + "schema": "", + "columns": { + "cluster_id": { + "name": "cluster_id", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "key": { + "name": "key", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "workflowMetadataIndex": { + "name": "workflowMetadataIndex", + "columns": [ + { + "expression": "key", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "value", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "cluster_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workflow_metadata_workflow_id_cluster_id_workflows_id_cluster_id_fk": { + "name": "workflow_metadata_workflow_id_cluster_id_workflows_id_cluster_id_fk", + "tableFrom": "workflow_metadata", + "tableTo": "workflows", + "columnsFrom": [ + "workflow_id", + "cluster_id" + ], + "columnsTo": [ + "id", + "cluster_id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "workflow_metadata_cluster_id_workflow_id_key": { + "name": "workflow_metadata_cluster_id_workflow_id_key", + "columns": [ + "cluster_id", + "workflow_id", + "key" + ] + } + }, + "uniqueConstraints": {} + }, + "public.workflows": { + "name": "workflows", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "result_function": { + "name": "result_function", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": false + }, + "on_status_change_statuses": { + "name": "on_status_change_statuses", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "result_schema": { + "name": "result_schema", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "system_prompt": { + "name": "system_prompt", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": false + }, + "model_identifier": { + "name": "model_identifier", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "cluster_id": { + "name": "cluster_id", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp (6) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "failure_reason": { + "name": "failure_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "debug": { + "name": "debug", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "attached_functions": { + "name": "attached_functions", + "type": "json", + "primaryKey": false, + "notNull": true, + "default": "'[]'::json" + }, + "test": { + "name": "test", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "test_mocks": { + "name": "test_mocks", + "type": "json", + "primaryKey": false, + "notNull": false, + "default": "'{}'::json" + }, + "feedback_comment": { + "name": "feedback_comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "feedback_score": { + "name": "feedback_score", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "agent_id": { + "name": "agent_id", + "type": "varchar(128)", + "primaryKey": false, + "notNull": false + }, + "agent_version": { + "name": "agent_version", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "reasoning_traces": { + "name": "reasoning_traces", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "interactive": { + "name": "interactive", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "enable_summarization": { + "name": "enable_summarization", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "enable_result_grounding": { + "name": "enable_result_grounding", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "auth_context": { + "name": "auth_context", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "context": { + "name": "context", + "type": "json", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "workflows_cluster_id_clusters_id_fk": { + "name": "workflows_cluster_id_clusters_id_fk", + "tableFrom": "workflows", + "tableTo": "clusters", + "columnsFrom": [ + "cluster_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "workflows_cluster_id_id": { + "name": "workflows_cluster_id_id", + "columns": [ + "cluster_id", + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "public.services": { + "name": "services", + "schema": "", + "columns": { + "cluster_id": { + "name": "cluster_id", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "service": { + "name": "service", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "definition": { + "name": "definition", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "timestamp": { + "name": "timestamp", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "services_cluster_id_clusters_id_fk": { + "name": "services_cluster_id_clusters_id_fk", + "tableFrom": "services", + "tableTo": "clusters", + "columnsFrom": [ + "cluster_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "services_cluster_id_service": { + "name": "services_cluster_id_service", + "columns": [ + "cluster_id", + "service" + ] + } + }, + "uniqueConstraints": {} + }, + "public.versioned_entities": { + "name": "versioned_entities", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": true + }, + "cluster_id": { + "name": "cluster_id", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(128)", + "primaryKey": false, + "notNull": true + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "entity": { + "name": "entity", + "type": "json", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "versioned_entities_pkey": { + "name": "versioned_entities_pkey", + "columns": [ + "cluster_id", + "id", + "type", + "version" + ] + } + }, + "uniqueConstraints": {} + } + }, + "enums": {}, + "schemas": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/control-plane/drizzle/meta/_journal.json b/control-plane/drizzle/meta/_journal.json index d41efedc..7724a1ff 100644 --- a/control-plane/drizzle/meta/_journal.json +++ b/control-plane/drizzle/meta/_journal.json @@ -1457,6 +1457,20 @@ "when": 1736242319059, "tag": "0208_brave_tenebrous", "breakpoints": true + }, + { + "idx": 209, + "version": "7", + "when": 1736894308440, + "tag": "0209_stiff_tenebrous", + "breakpoints": true + }, + { + "idx": 210, + "version": "7", + "when": 1736894911675, + "tag": "0210_tiny_katie_power", + "breakpoints": true } ] } \ No newline at end of file diff --git a/control-plane/src/modules/contract.ts b/control-plane/src/modules/contract.ts index 5e2f7db9..a62b3a09 100644 --- a/control-plane/src/modules/contract.ts +++ b/control-plane/src/modules/contract.ts @@ -745,7 +745,9 @@ export const definition = { ), onStatusChange: z .object({ - function: functionReference.describe("A function to call when the run status changes"), + statuses: z.array(z.enum(["pending", "running", "paused", "done", "failed"])).describe(" A list of Run statuses which should trigger the handler").optional().default(["done", "failed"]), + function: functionReference.describe("A function to call when the run status changes").optional(), + webhook: z.string().describe("A webhook URL to call when the run status changes").optional(), }) .optional() .describe("Mechanism for receiving notifications when the run status changes"), diff --git a/control-plane/src/modules/data.ts b/control-plane/src/modules/data.ts index 309f803a..e6201153 100644 --- a/control-plane/src/modules/data.ts +++ b/control-plane/src/modules/data.ts @@ -287,6 +287,7 @@ export const runs = pgTable( id: varchar("id", { length: 1024 }).notNull(), // TODO: Rename this to `on_status_change` on_status_change: varchar("result_function", { length: 1024 }), + on_status_change_statuses: json("on_status_change_statuses").$type(), result_schema: json("result_schema"), name: varchar("name", { length: 1024 }).default("").notNull(), system_prompt: varchar("system_prompt", { length: 1024 }), diff --git a/control-plane/src/modules/runs/agent/run.test.ts b/control-plane/src/modules/runs/agent/run.test.ts index a59c6f74..5bd0462b 100644 --- a/control-plane/src/modules/runs/agent/run.test.ts +++ b/control-plane/src/modules/runs/agent/run.test.ts @@ -7,7 +7,7 @@ import { insertRunMessage } from "../messages"; import { and, eq } from "drizzle-orm"; describe("processRun", () => { - it("should call onStatusChange handler", async () => { + it("should call onStatusChange function handler", async () => { const owner = await createOwner(); await upsertServiceDefinition({ service: "testService", @@ -33,6 +33,7 @@ describe("processRun", () => { status: "running" as const, attachedFunctions: ["testService_someFunction"], onStatusChange: "testService_someOtherFunction", + onStatusChangeStatuses: null, modelIdentifier: null, resultSchema: { type: "object", diff --git a/control-plane/src/modules/runs/agent/run.ts b/control-plane/src/modules/runs/agent/run.ts index 0dbf641a..4053eb43 100644 --- a/control-plane/src/modules/runs/agent/run.ts +++ b/control-plane/src/modules/runs/agent/run.ts @@ -46,6 +46,7 @@ export const processRun = async ( reasoningTraces: boolean; enableResultGrounding: boolean; onStatusChange: string | null; + onStatusChangeStatuses: string[] | null; authContext: unknown | null; context: unknown | null; }, @@ -229,6 +230,7 @@ export const processRun = async ( id: run.id, clusterId: run.clusterId, onStatusChange: run.onStatusChange, + onStatusChangeStatuses: run.onStatusChangeStatuses, status: run.status, authContext: run.authContext, context: run.context, diff --git a/control-plane/src/modules/runs/index.ts b/control-plane/src/modules/runs/index.ts index 472bee85..f0c5bca0 100644 --- a/control-plane/src/modules/runs/index.ts +++ b/control-plane/src/modules/runs/index.ts @@ -22,7 +22,8 @@ export const createRun = async ({ test, testMocks, systemPrompt, - onStatusChange, + onStatusChangeHandler, + onStatusChangeStatuses, resultSchema, tags, attachedFunctions, @@ -48,7 +49,8 @@ export const createRun = async ({ output: Record; } >; - onStatusChange?: string; + onStatusChangeHandler?: string; + onStatusChangeStatuses?: string[]; resultSchema?: unknown; tags?: Record; attachedFunctions?: string[]; @@ -78,7 +80,8 @@ export const createRun = async ({ reasoning_traces: reasoningTraces, interactive: interactive, enable_summarization: enableSummarization, - on_status_change: onStatusChange, + on_status_change: onStatusChangeHandler, + on_status_change_statuses: onStatusChangeStatuses, result_schema: resultSchema, attached_functions: attachedFunctions, agent_id: agentId, @@ -214,6 +217,7 @@ export const getRun = async ({ clusterId, runId }: { clusterId: string; runId: s test: runs.test, testMocks: runs.test_mocks, onStatusChange: runs.on_status_change, + onStatusChangeStatuses: runs.on_status_change_statuses, resultSchema: runs.result_schema, feedbackComment: runs.feedback_comment, feedbackScore: runs.feedback_score, @@ -486,7 +490,8 @@ export const createRunWithMessage = async ({ interactive, enableSummarization, modelIdentifier, - onStatusChange, + onStatusChangeHandler, + onStatusChangeStatuses, authContext, context, enableResultGrounding, @@ -499,7 +504,8 @@ export const createRunWithMessage = async ({ test, testMocks, systemPrompt, - onStatusChange, + onStatusChangeHandler, + onStatusChangeStatuses, attachedFunctions, resultSchema, tags, diff --git a/control-plane/src/modules/runs/notify.ts b/control-plane/src/modules/runs/notify.ts index a8e4405f..5ef3caee 100644 --- a/control-plane/src/modules/runs/notify.ts +++ b/control-plane/src/modules/runs/notify.ts @@ -7,6 +7,7 @@ import { getClusterBackgroundRun } from "./"; import { runMessages } from "../data"; import * as slack from "../integrations/slack"; import * as email from "../email"; +import AsyncRetry from "async-retry"; export const notifyApprovalRequest = async ({ jobId, @@ -52,6 +53,7 @@ export const notifyStatusChange = async ({ id: string; clusterId: string; onStatusChange: string | null; + onStatusChangeStatuses: string[] | null; status: string; authContext: unknown; context: unknown; @@ -68,28 +70,58 @@ export const notifyStatusChange = async ({ return; } - // TODO: Support for webhooks - const [resultService, resultFunction] = run.onStatusChange?.split("_") ?? []; + // Don't notify if the status is not in the allowed list + if (run.onStatusChangeStatuses && !run.onStatusChangeStatuses.includes(status)) { + return; + } let notify; - - if (!!resultService && !!resultFunction) { + if (run.onStatusChange.startsWith("https://")) { notify = async (payload: unknown) => { - const { id } = await jobs.createJob({ - service: resultService, - targetFn: resultFunction, - targetArgs: packer.pack(payload), - authContext: run.authContext, - runContext: run.context, - owner: { - clusterId: run.clusterId, + + await AsyncRetry( + async (_, attempt: number) => { + logger.info("Sending status change webhook", { + url: run.onStatusChange, + attempt, + }) + + return await fetch(run.onStatusChange!, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(payload), + }); + + }, + { + retries: 5, }, - runId: getClusterBackgroundRun(run.clusterId), - }); - logger.info("Created job with run result", { - jobId: id, - }); + ); }; + + } else { + const [resultService, resultFunction] = run.onStatusChange?.split("_") ?? []; + + if (!!resultService && !!resultFunction) { + notify = async (payload: unknown) => { + const { id } = await jobs.createJob({ + service: resultService, + targetFn: resultFunction, + targetArgs: packer.pack(payload), + authContext: run.authContext, + runContext: run.context, + owner: { + clusterId: run.clusterId, + }, + runId: getClusterBackgroundRun(run.clusterId), + }); + logger.info("Created job with run result", { + jobId: id, + }); + }; + } } if (!notify) { diff --git a/control-plane/src/modules/runs/queues.ts b/control-plane/src/modules/runs/queues.ts index acb075f0..14cfe40d 100644 --- a/control-plane/src/modules/runs/queues.ts +++ b/control-plane/src/modules/runs/queues.ts @@ -6,7 +6,7 @@ import { getRun } from "./"; import { processRun } from "./agent/run"; import { generateTitle } from "./summarization"; -import { and, eq, isNull } from "drizzle-orm"; +import { and, eq } from "drizzle-orm"; import { Consumer } from "sqs-consumer"; import { z } from "zod"; import { injectTraceContext } from "../observability/tracer"; diff --git a/control-plane/src/modules/runs/router.ts b/control-plane/src/modules/runs/router.ts index 7d641240..09e06182 100644 --- a/control-plane/src/modules/runs/router.ts +++ b/control-plane/src/modules/runs/router.ts @@ -87,10 +87,41 @@ export const runsRouter = initServer().router( } } - // TODO: Validate that onStatusChange and attachedFunctions exist - // TODO: Validate that onStatusChange schema is correct - const onStatusChange = - body.onStatusChange?.function && normalizeFunctionReference(body.onStatusChange.function); + let onStatusChangeHandler: string | undefined = undefined; + let onStatusChangeStatuses: string[] | undefined = undefined; + + if (body.onStatusChange) { + if (body.onStatusChange.function && body.onStatusChange.webhook) { + return { + status: 400, + body: { + message: "onStatusChange cannot have both function and webhook", + }, + }; + } + + if (body.onStatusChange.function) { + // TODO: Validate that onStatusChange and attachedFunctions exist + // TODO: Validate that onStatusChange schema is correct + onStatusChangeHandler = + body.onStatusChange.function && normalizeFunctionReference(body.onStatusChange.function); + } + + if (body.onStatusChange.webhook) { + // Check for valid Schema + if (!body.onStatusChange.webhook.startsWith("https://")) { + return { + status: 400, + body: { + message: "onStatusChange webhook must start with https://", + }, + }; + } + + onStatusChangeHandler = body.onStatusChange.webhook; + onStatusChangeStatuses = body.onStatusChange.statuses ?? ["done", "failed"]; + } + } let runOptions: RunOptions & { runId?: string } = { runId: body.runId, @@ -161,7 +192,8 @@ export const runsRouter = initServer().router( context: body.context, - onStatusChange, + onStatusChangeHandler: onStatusChangeHandler, + onStatusChangeStatuses: onStatusChangeStatuses, // Merged Options resultSchema: runOptions.resultSchema, diff --git a/sdk-node/src/contract.ts b/sdk-node/src/contract.ts index 91214d6a..a62b3a09 100644 --- a/sdk-node/src/contract.ts +++ b/sdk-node/src/contract.ts @@ -86,6 +86,15 @@ export const integrationSchema = z.object({ nangoConnectionId: z.string(), botUserId: z.string(), teamId: z.string(), + agentId: z.string().optional(), + }) + .optional() + .nullable(), + email: z + .object({ + connectionId: z.string(), + agentId: z.string().optional(), + validateSPFandDKIM: z.boolean().optional(), }) .optional() .nullable(), @@ -235,23 +244,6 @@ export const definition = { }, }, - getServerStats: { - method: "GET", - path: "/stats", - responses: { - 200: z.object({ - functionCalls: z.object({ - count: z.number(), - }), - tokenUsage: z.object({ - input: z.number(), - output: z.number(), - }), - refreshedAt: z.number(), - }), - }, - }, - createStructuredOutput: { method: "POST", path: "/clusters/:clusterId/structured-output", @@ -362,7 +354,10 @@ export const definition = { service: z.string(), status: z.enum(["pending", "running", "paused", "done", "failed"]).default("pending"), limit: z.coerce.number().min(1).max(20).default(10), - acknowledge: z.coerce.boolean().default(false).describe("Should retrieved Jobs be marked as running"), + acknowledge: z.coerce + .boolean() + .default(false) + .describe("Should retrieved Jobs be marked as running"), }), pathParams: z.object({ clusterId: z.string(), @@ -479,6 +474,12 @@ export const definition = { }, body: z.object({ description: z.string().describe("Human readable description of the cluster"), + name: z.string().optional().describe("Human readable name of the cluster"), + isDemo: z + .boolean() + .optional() + .default(false) + .describe("Whether the cluster is a demo cluster"), }), }, deleteCluster: { @@ -534,9 +535,24 @@ export const definition = { createdAt: z.date(), debug: z.boolean(), enableCustomAuth: z.boolean(), - handleCustomAuthFunction: z.string(), - enableKnowledgebase: z.boolean(), - lastPingAt: z.date().nullable(), + handleCustomAuthFunction: z.string().nullable(), + isDemo: z.boolean(), + machines: z.array( + z.object({ + id: z.string(), + lastPingAt: z.date().nullable(), + ip: z.string().nullable(), + sdkVersion: z.string().nullable(), + sdkLanguage: z.string().nullable(), + }) + ), + services: z.array( + z.object({ + service: z.string(), + definition: z.unknown().nullable(), + timestamp: z.date().nullable(), + }) + ), }), 401: z.undefined(), 404: z.undefined(), @@ -729,14 +745,13 @@ export const definition = { ), onStatusChange: z .object({ - function: functionReference.describe("A function to call when the run status changes"), + statuses: z.array(z.enum(["pending", "running", "paused", "done", "failed"])).describe(" A list of Run statuses which should trigger the handler").optional().default(["done", "failed"]), + function: functionReference.describe("A function to call when the run status changes").optional(), + webhook: z.string().describe("A webhook URL to call when the run status changes").optional(), }) .optional() .describe("Mechanism for receiving notifications when the run status changes"), - tags: z - .record(z.string()) - .optional() - .describe("Run tags which can be used to filter runs"), + tags: z.record(z.string()).optional().describe("Run tags which can be used to filter runs"), test: z .object({ enabled: z.boolean().default(false), @@ -889,19 +904,6 @@ export const definition = { 200: z.unknown(), }, }, - createRunRetry: { - method: "POST", - path: "/clusters/:clusterId/runs/:runId/retry", - headers: z.object({ authorization: z.string() }), - body: z.object({ - messageId: z.string(), - }), - responses: { - 204: z.undefined(), - 401: z.undefined(), - }, - }, - // Message Endpoints createMessage: { method: "POST", @@ -948,24 +950,6 @@ export const definition = { 401: z.undefined(), }, }, - updateMessage: { - method: "PUT", - path: "/clusters/:clusterId/runs/:runId/messages/:messageId", - headers: z.object({ authorization: z.string() }), - body: z.object({ message: z.string() }), - responses: { - 200: z.object({ - id: z.string(), - }), - 404: z.object({ message: z.string() }), - 401: z.undefined(), - }, - pathParams: z.object({ - clusterId: z.string(), - runId: z.string(), - messageId: z.string(), - }), - }, listRunReferences: { method: "GET", @@ -1319,123 +1303,6 @@ export const definition = { }), }, - // Knowledge Endpoints - createKnowledgeArtifact: { - method: "POST", - path: "/clusters/:clusterId/knowledge", - headers: z.object({ authorization: z.string() }), - body: z.object({ - artifacts: z.array( - z.object({ - id: z.string(), - data: z.string(), - tags: z.array(z.string()).transform(tags => tags.map(tag => tag.toLowerCase().trim())), - title: z.string(), - }) - ), - }), - responses: { - 204: z.undefined(), - 401: z.undefined(), - }, - pathParams: z.object({ - clusterId: z.string(), - }), - }, - listKnowledgeArtifacts: { - method: "GET", - path: "/clusters/:clusterId/knowledge", - headers: z.object({ authorization: z.string() }), - query: z.object({ - query: z.string(), - limit: z.coerce.number().min(1).max(50).default(5), - tag: z.string().optional(), - }), - responses: { - 200: z.array( - z.object({ - id: z.string(), - data: z.string(), - tags: z.array(z.string()), - title: z.string(), - similarity: z.number(), - }) - ), - 401: z.undefined(), - }, - pathParams: z.object({ - clusterId: z.string(), - }), - }, - upsertKnowledgeArtifact: { - method: "PUT", - path: "/clusters/:clusterId/knowledge/:artifactId", - headers: z.object({ authorization: z.string() }), - body: z.object({ - data: z.string(), - tags: z.array(z.string()).transform(tags => tags.map(tag => tag.toLowerCase().trim())), - title: z.string(), - }), - responses: { - 200: z.object({ - id: z.string(), - }), - 401: z.undefined(), - }, - pathParams: z.object({ - clusterId: z.string(), - artifactId: z.string().regex(userDefinedIdRegex), - }), - }, - deleteKnowledgeArtifact: { - method: "DELETE", - path: "/clusters/:clusterId/knowledge/:artifactId", - headers: z.object({ authorization: z.string() }), - body: z.undefined(), - responses: { - 204: z.undefined(), - 401: z.undefined(), - }, - }, - getKnowledgeArtifact: { - method: "GET", - path: "/clusters/:clusterId/knowledge/:artifactId", - headers: z.object({ authorization: z.string() }), - responses: { - 200: z.object({ - id: z.string(), - data: z.string(), - tags: z.array(z.string()), - title: z.string(), - }), - 401: z.undefined(), - 404: z.undefined(), - }, - pathParams: z.object({ - clusterId: z.string(), - artifactId: z.string(), - }), - }, - exportKnowledgeArtifacts: { - method: "GET", - path: "/clusters/:clusterId/knowledge-export", - headers: z.object({ authorization: z.string() }), - responses: { - 200: z.array( - z.object({ - id: z.string(), - data: z.string(), - tags: z.array(z.string()), - title: z.string(), - }) - ), - 401: z.undefined(), - }, - pathParams: z.object({ - clusterId: z.string(), - }), - }, - // Nango Endpoints createNangoSession: { method: "POST", @@ -1462,6 +1329,24 @@ export const definition = { 200: z.undefined(), }, }, + getStandardLibraryMeta: { + method: "GET", + path: "/clusters/:clusterId/standard-library", + pathParams: z.object({ + clusterId: z.string(), + }), + responses: { + 200: z.object({ + tools: z.array( + z.object({ + name: z.string(), + description: z.string(), + enabled: z.boolean(), + }) + ), + }), + }, + }, } as const; export const contract = c.router(definition);