🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
✨ feat(database): persist generic agent interventions (#18417)
Tsukia89c16e7792a
diff --git a/docs/development/database-schema.dbml b/docs/development/database-schema.dbmlindex 2a749173605..465d3523aeb 100644--- a/docs/development/database-schema.dbml+++ b/docs/development/database-schema.dbml@@ -305,7 +305,7 @@ table agent_eval_runs {updated_at "timestamp with time zone" [not null, default: `now()`]indexes {-+dataset_id [name: 'agent_eval_runs_dataset_id_idx']experiment_id [name: 'agent_eval_runs_experiment_id_idx']parent_run_id [name: 'agent_eval_runs_parent_run_id_idx']@@ -403,6 +403,108 @@ table agent_history_jobs {}}+table agent_intervention_resolutions {+ id uuid [pk, not null, default: `gen_random_uuid()`]+ resolution_request_id uuid [not null]+ operation_id text [not null]+ batch_id text [not null]+ source text [not null]+ user_id text [not null]+ workspace_id text+ actor_id text [not null]+ scope text [not null]+ selected_intervention_ids jsonb [not null]+ expected_versions jsonb [not null]+ expected_request_revision_hashes jsonb [not null]+ expected_item_count integer [not null]+ action jsonb [not null]+ custom_execution_input_hash varchar(64)+ custom_execution_state text+ custom_execution_attempt integer+ custom_execution_lease_token uuid+ custom_execution_lease_expires_at "timestamp with time zone"+ custom_execution_result jsonb+ remember_tool_key text+ remember_effect_status text+ original_arguments text+ edited_arguments text+ original_request_revision_hash text+ edited_request_revision_hash text+ argument_effect_status text+ status text [not null, default: 'resolving']+ resolving_at "timestamp with time zone" [not null, default: `now()`]+ published_at "timestamp with time zone"+ continuation_started_at "timestamp with time zone"+ producer_ack_at "timestamp with time zone"+ terminal_at "timestamp with time zone"+ rolled_back_at "timestamp with time zone"+ version integer [not null, default: 1]+ created_at "timestamp with time zone" [not null, default: `now()`]+ updated_at "timestamp with time zone" [not null, default: `now()`]++ indexes {+ resolution_request_id [name: 'agent_intervention_resolutions_request_unique', unique]+ (user_id, workspace_id, batch_id) [name: 'agent_intervention_resolutions_owner_batch_idx']+ (status, created_at) [name: 'agent_intervention_resolutions_status_created_idx']+++ }+}++table agent_interventions {+ id uuid [pk, not null, default: `gen_random_uuid()`]+ operation_id text [not null]+ tool_call_id text [not null]+ tool_message_id text+ user_id text [not null]+ workspace_id text+ source text [not null]+ provider text+ interaction_kind text [not null]+ surface text [not null]+ system_action_eligibility text [not null]+ approval_mode text+ batch_id text [not null]+ activity_key text [not null]+ step_index integer [not null]+ item_index integer [not null]+ item_count integer [not null]+ sealed boolean [not null, default: false]+ canonical_tool_key text+ request_revision_hash text [not null]+ allowed_actions jsonb [not null]+ risk jsonb+ review_token_hash text [not null]+ review_context jsonb [not null]+ sanitized_request jsonb [not null]+ deadline "timestamp with time zone" [not null]+ status text [not null, default: 'pending']+ resolution_id uuid+ resolving_at "timestamp with time zone"+ published_at "timestamp with time zone"+ resolved_at "timestamp with time zone"+ producer_ack_at "timestamp with time zone"+ version integer [not null, default: 1]+ created_at "timestamp with time zone" [not null, default: `now()`]+ updated_at "timestamp with time zone" [not null, default: `now()`]++ indexes {+ (operation_id, tool_call_id) [name: 'agent_interventions_operation_tool_call_unique', unique]+ review_token_hash [name: 'agent_interventions_review_token_hash_unique', unique]+ (operation_id, batch_id, item_index) [name: 'agent_interventions_operation_batch_item_unique', unique]+ (user_id, activity_key, item_index) [name: 'agent_interventions_owner_activity_item_unique', unique]+ (user_id, workspace_id, status, deadline) [name: 'agent_interventions_owner_status_deadline_idx']+ (user_id, workspace_id, batch_id, item_index) [name: 'agent_interventions_owner_batch_idx']+ (user_id, activity_key) [name: 'agent_interventions_activity_key_idx']+ (status, deadline) [name: 'agent_interventions_status_deadline_idx']++++++ }+}+table agent_label_assignments {id uuid [pk, not null, default: `gen_random_uuid()`]label_id uuid [not null]@@ -1110,7 +1212,7 @@ table expertise_bindings {updated_at "timestamp with time zone" [not null, default: `now()`]indexes {-+(agent_id, domain_id) [name: 'expertise_bindings_agent_domain_unique', unique](project_id, domain_id) [name: 'expertise_bindings_project_domain_unique', unique](bound_workspace_id, domain_id) [name: 'expertise_bindings_workspace_domain_unique', unique]@@ -1146,7 +1248,7 @@ table expertise_domain_snapshots {captured_at "timestamp with time zone" [not null, default: `now()`]indexes {-+(domain_id, run_index) [name: 'expertise_domain_snapshots_domain_run_index_unique', unique](domain_id, captured_at) [name: 'expertise_domain_snapshots_domain_captured_idx']domain_id [name: 'expertise_domain_snapshots_pending_fit_idx']@@ -1207,8 +1309,8 @@ table expertise_hits {created_at "timestamp with time zone" [not null, default: `now()`]indexes {--++(lesson_id, created_at) [name: 'expertise_hits_lesson_created_idx']run_id [name: 'expertise_hits_run_idx'](domain_id, outcome) [name: 'expertise_hits_domain_outcome_idx']@@ -2283,7 +2385,7 @@ table project_completion_reviews {(project_id, created_at) [name: 'project_completion_reviews_project_id_created_at_idx']reviewer_user_id [name: 'project_completion_reviews_reviewer_user_id_idx']workspace_id [name: 'project_completion_reviews_workspace_id_idx']-+}}@@ -2356,7 +2458,28 @@ table projects {(workspace_id, visibility, user_id) [name: 'projects_workspace_visibility_idx'](status, updated_at) [name: 'projects_status_updated_at_idx']coordinator_agent_id [name: 'projects_coordinator_agent_id_unique', unique]-++ }+}++table push_live_activities {+ id uuid [pk, not null, default: `gen_random_uuid()`]+ user_id text [not null]+ device_id text [not null]+ activity_key text [not null]+ operation_id text [not null]+ activity_id text [not null]+ push_token text [not null]+ apns_environment text [not null]+ created_at "timestamp with time zone" [not null, default: `now()`]+ last_seen_at "timestamp with time zone" [not null, default: `now()`]++ indexes {+ (user_id, device_id, activity_key) [name: 'idx_push_live_activities_user_device_activity', unique]+ (user_id, activity_key) [name: 'idx_push_live_activities_user_activity']+ (user_id, operation_id) [name: 'idx_push_live_activities_user_operation']+ last_seen_at [name: 'idx_push_live_activities_last_seen']+}}@@ -2366,8 +2489,10 @@ table push_tokens {expo_token text [not null]device_id text [not null]platform text [not null]+ apns_environment textapp_version textlocale text+ live_activity_push_to_start_token textcreated_at "timestamp with time zone" [not null, default: `now()`]last_seen_at "timestamp with time zone" [not null, default: `now()`]@@ -2375,6 +2500,7 @@ table push_tokens {(user_id, device_id) [name: 'idx_push_tokens_user_device', unique]user_id [name: 'idx_push_tokens_user']last_seen_at [name: 'idx_push_tokens_last_seen']+}}@@ -2932,7 +3058,7 @@ table tasks {updated_at "timestamp with time zone" [not null, default: `now()`]indexes {-+(identifier, created_by_user_id) [name: 'tasks_identifier_idx', unique]created_by_user_id [name: 'tasks_created_by_user_id_idx']created_by_agent_id [name: 'tasks_created_by_agent_id_idx']@@ -3102,10 +3228,10 @@ table topic_comments {indexes {(topic_id, author_user_id, client_id) [name: 'topic_comments_topic_id_author_user_id_client_id_unique', unique]----++++(parent_comment_id, created_at, id) [name: 'topic_comments_parent_comment_id_created_at_id_idx'](topic_id, created_at, id) [name: 'topic_comments_topic_id_created_at_id_idx'](topic_id, message_id) [name: 'topic_comments_topic_id_message_id_idx']@@ -3566,7 +3692,7 @@ table verify_review_predictions {workspace_id [name: 'verify_review_predictions_workspace_id_idx'](provider, model) [name: 'verify_review_predictions_model_idx'](check_result_id, provider, model, prompt_version) [name: 'verify_review_predictions_result_model_prompt_unique', unique]-+}}@@ -3631,7 +3757,7 @@ table verify_runs {workspace_id [name: 'verify_runs_workspace_id_idx']acceptance_id [name: 'verify_runs_acceptance_id_idx'](acceptance_id, round_index) [name: 'verify_runs_acceptance_round_unique', unique]-+operation_id [name: 'verify_runs_operation_id_unique', unique]source [name: 'verify_runs_source_idx']user_decision [name: 'verify_runs_user_decision_idx']@@ -3922,4 +4048,4 @@ ref: topic_documents.document_id > documents.idref: topic_documents.topic_id > topics.id-ref: topics.session_id - sessions.id+ref: topics.session_id - sessions.id\ No newline at end of filediff --git a/packages/database/migrations/0150_agent_interventions_and_live_activity.sql b/packages/database/migrations/0150_agent_interventions_and_live_activity.sqlnew file mode 100644index 00000000000..24b1a90802c--- /dev/null+++ b/packages/database/migrations/0150_agent_interventions_and_live_activity.sql@@ -0,0 +1,165 @@+CREATE TABLE IF NOT EXISTS "agent_intervention_resolutions" (+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,+ "resolution_request_id" uuid NOT NULL,+ "operation_id" text NOT NULL,+ "batch_id" text NOT NULL,+ "source" text NOT NULL,+ "user_id" text NOT NULL,+ "workspace_id" text,+ "actor_id" text NOT NULL,+ "scope" text NOT NULL,+ "selected_intervention_ids" jsonb NOT NULL,+ "expected_versions" jsonb NOT NULL,+ "expected_request_revision_hashes" jsonb NOT NULL,+ "expected_item_count" integer NOT NULL,+ "action" jsonb NOT NULL,+ "custom_execution_input_hash" varchar(64),+ "custom_execution_state" text,+ "custom_execution_attempt" integer,+ "custom_execution_lease_token" uuid,+ "custom_execution_lease_expires_at" timestamp with time zone,+ "custom_execution_result" jsonb,+ "remember_tool_key" text,+ "remember_effect_status" text,+ "original_arguments" text,+ "edited_arguments" text,+ "original_request_revision_hash" text,+ "edited_request_revision_hash" text,+ "argument_effect_status" text,+ "status" text DEFAULT 'resolving' NOT NULL,+ "resolving_at" timestamp with time zone DEFAULT now() NOT NULL,+ "published_at" timestamp with time zone,+ "continuation_started_at" timestamp with time zone,+ "producer_ack_at" timestamp with time zone,+ "terminal_at" timestamp with time zone,+ "rolled_back_at" timestamp with time zone,+ "version" integer DEFAULT 1 NOT NULL,+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL,+ CONSTRAINT "agent_intervention_resolutions_expected_item_count_check" CHECK ("agent_intervention_resolutions"."expected_item_count" > 0),+ CONSTRAINT "agent_intervention_resolutions_custom_execution_input_hash_check" CHECK ("agent_intervention_resolutions"."custom_execution_input_hash" IS NULL OR "agent_intervention_resolutions"."custom_execution_input_hash" ~ '^[a-f0-9]{64}$'),+ CONSTRAINT "agent_intervention_resolutions_custom_execution_state_check" CHECK ((+ ("agent_intervention_resolutions"."custom_execution_state" IS NULL+ AND "agent_intervention_resolutions"."custom_execution_input_hash" IS NULL+ AND "agent_intervention_resolutions"."custom_execution_attempt" IS NULL+ AND "agent_intervention_resolutions"."custom_execution_lease_token" IS NULL+ AND "agent_intervention_resolutions"."custom_execution_lease_expires_at" IS NULL+ AND "agent_intervention_resolutions"."custom_execution_result" IS NULL)+ OR+ ("agent_intervention_resolutions"."custom_execution_state" = 'pending'+ AND "agent_intervention_resolutions"."custom_execution_attempt" = 0+ AND "agent_intervention_resolutions"."custom_execution_lease_token" IS NULL+ AND "agent_intervention_resolutions"."custom_execution_lease_expires_at" IS NULL+ AND "agent_intervention_resolutions"."custom_execution_result" IS NULL)+ OR+ ("agent_intervention_resolutions"."custom_execution_state" = 'executing'+ AND "agent_intervention_resolutions"."custom_execution_input_hash" IS NOT NULL+ AND "agent_intervention_resolutions"."custom_execution_attempt" > 0+ AND "agent_intervention_resolutions"."custom_execution_lease_token" IS NOT NULL+ AND "agent_intervention_resolutions"."custom_execution_lease_expires_at" IS NOT NULL+ AND "agent_intervention_resolutions"."custom_execution_result" IS NULL)+ OR+ ("agent_intervention_resolutions"."custom_execution_state" = 'completed'+ AND "agent_intervention_resolutions"."custom_execution_input_hash" IS NOT NULL+ AND "agent_intervention_resolutions"."custom_execution_attempt" > 0+ AND "agent_intervention_resolutions"."custom_execution_lease_token" IS NOT NULL+ AND "agent_intervention_resolutions"."custom_execution_lease_expires_at" IS NOT NULL+ AND "agent_intervention_resolutions"."custom_execution_result" IS NOT NULL)+ )),+ CONSTRAINT "agent_intervention_resolutions_custom_execution_parent_status_check" CHECK ("agent_intervention_resolutions"."custom_execution_state" NOT IN ('executing', 'completed') OR "agent_intervention_resolutions"."status" IN ('resolving', 'published', 'acknowledged', 'completed')),+ CONSTRAINT "agent_intervention_resolutions_version_check" CHECK ("agent_intervention_resolutions"."version" > 0)+);+--> statement-breakpoint+CREATE TABLE IF NOT EXISTS "agent_interventions" (+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,+ "operation_id" text NOT NULL,+ "tool_call_id" text NOT NULL,+ "tool_message_id" text,+ "user_id" text NOT NULL,+ "workspace_id" text,+ "source" text NOT NULL,+ "provider" text,+ "interaction_kind" text NOT NULL,+ "surface" text NOT NULL,+ "system_action_eligibility" text NOT NULL,+ "approval_mode" text,+ "batch_id" text NOT NULL,+ "activity_key" text NOT NULL,+ "step_index" integer NOT NULL,+ "item_index" integer NOT NULL,+ "item_count" integer NOT NULL,+ "sealed" boolean DEFAULT false NOT NULL,+ "canonical_tool_key" text,+ "request_revision_hash" text NOT NULL,+ "allowed_actions" jsonb NOT NULL,+ "risk" jsonb,+ "review_token_hash" text NOT NULL,+ "review_context" jsonb NOT NULL,+ "sanitized_request" jsonb NOT NULL,+ "deadline" timestamp with time zone NOT NULL,+ "status" text DEFAULT 'pending' NOT NULL,+ "resolution_id" uuid,+ "resolving_at" timestamp with time zone,+ "published_at" timestamp with time zone,+ "resolved_at" timestamp with time zone,+ "producer_ack_at" timestamp with time zone,+ "version" integer DEFAULT 1 NOT NULL,+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL,+ CONSTRAINT "agent_interventions_review_token_hash_check" CHECK ("agent_interventions"."review_token_hash" ~ '^[a-f0-9]{64}$'),+ CONSTRAINT "agent_interventions_request_revision_hash_check" CHECK ("agent_interventions"."request_revision_hash" ~ '^[a-f0-9]{64}$'),+ CONSTRAINT "agent_interventions_step_index_check" CHECK ("agent_interventions"."step_index" >= 0),+ CONSTRAINT "agent_interventions_item_bounds_check" CHECK ("agent_interventions"."item_count" > 0 AND "agent_interventions"."item_index" >= 0 AND "agent_interventions"."item_index" < "agent_interventions"."item_count"),+ CONSTRAINT "agent_interventions_version_check" CHECK ("agent_interventions"."version" > 0)+);+--> statement-breakpoint+CREATE TABLE IF NOT EXISTS "push_live_activities" (+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,+ "user_id" text NOT NULL,+ "device_id" text NOT NULL,+ "activity_key" text NOT NULL,+ "operation_id" text NOT NULL,+ "activity_id" text NOT NULL,+ "push_token" text NOT NULL,+ "apns_environment" text NOT NULL,+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,+ "last_seen_at" timestamp with time zone DEFAULT now() NOT NULL,+ CONSTRAINT "push_live_activities_apns_environment_check" CHECK ("push_live_activities"."apns_environment" IN ('sandbox', 'production'))+);+--> statement-breakpoint+ALTER TABLE "push_tokens" ADD COLUMN IF NOT EXISTS "apns_environment" text;--> statement-breakpoint+ALTER TABLE "push_tokens" ADD COLUMN IF NOT EXISTS "live_activity_push_to_start_token" text;--> statement-breakpoint+ALTER TABLE "agent_intervention_resolutions" DROP CONSTRAINT IF EXISTS "agent_intervention_resolutions_operation_id_agent_operations_id_fk";--> statement-breakpoint+ALTER TABLE "agent_intervention_resolutions" ADD CONSTRAINT "agent_intervention_resolutions_operation_id_agent_operations_id_fk" FOREIGN KEY ("operation_id") REFERENCES "public"."agent_operations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint+ALTER TABLE "agent_intervention_resolutions" DROP CONSTRAINT IF EXISTS "agent_intervention_resolutions_user_id_users_id_fk";--> statement-breakpoint+ALTER TABLE "agent_intervention_resolutions" ADD CONSTRAINT "agent_intervention_resolutions_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint+ALTER TABLE "agent_intervention_resolutions" DROP CONSTRAINT IF EXISTS "agent_intervention_resolutions_workspace_id_workspaces_id_fk";--> statement-breakpoint+ALTER TABLE "agent_intervention_resolutions" ADD CONSTRAINT "agent_intervention_resolutions_workspace_id_workspaces_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."workspaces"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint+ALTER TABLE "agent_interventions" DROP CONSTRAINT IF EXISTS "agent_interventions_operation_id_agent_operations_id_fk";--> statement-breakpoint+ALTER TABLE "agent_interventions" ADD CONSTRAINT "agent_interventions_operation_id_agent_operations_id_fk" FOREIGN KEY ("operation_id") REFERENCES "public"."agent_operations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint+ALTER TABLE "agent_interventions" DROP CONSTRAINT IF EXISTS "agent_interventions_user_id_users_id_fk";--> statement-breakpoint+ALTER TABLE "agent_interventions" ADD CONSTRAINT "agent_interventions_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint+ALTER TABLE "agent_interventions" DROP CONSTRAINT IF EXISTS "agent_interventions_workspace_id_workspaces_id_fk";--> statement-breakpoint+ALTER TABLE "agent_interventions" ADD CONSTRAINT "agent_interventions_workspace_id_workspaces_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."workspaces"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint+ALTER TABLE "agent_interventions" DROP CONSTRAINT IF EXISTS "agent_interventions_resolution_id_agent_intervention_resolutions_id_fk";--> statement-breakpoint+ALTER TABLE "agent_interventions" ADD CONSTRAINT "agent_interventions_resolution_id_agent_intervention_resolutions_id_fk" FOREIGN KEY ("resolution_id") REFERENCES "public"."agent_intervention_resolutions"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint+ALTER TABLE "push_live_activities" DROP CONSTRAINT IF EXISTS "push_live_activities_user_id_users_id_fk";--> statement-breakpoint+ALTER TABLE "push_live_activities" ADD CONSTRAINT "push_live_activities_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint+CREATE UNIQUE INDEX IF NOT EXISTS "agent_intervention_resolutions_request_unique" ON "agent_intervention_resolutions" USING btree ("resolution_request_id");--> statement-breakpoint+CREATE INDEX IF NOT EXISTS "agent_intervention_resolutions_owner_batch_idx" ON "agent_intervention_resolutions" USING btree ("user_id","workspace_id","batch_id");--> statement-breakpoint+CREATE INDEX IF NOT EXISTS "agent_intervention_resolutions_status_created_idx" ON "agent_intervention_resolutions" USING btree ("status","created_at");--> statement-breakpoint+CREATE UNIQUE INDEX IF NOT EXISTS "agent_interventions_operation_tool_call_unique" ON "agent_interventions" USING btree ("operation_id","tool_call_id");--> statement-breakpoint+CREATE UNIQUE INDEX IF NOT EXISTS "agent_interventions_review_token_hash_unique" ON "agent_interventions" USING btree ("review_token_hash");--> statement-breakpoint+CREATE UNIQUE INDEX IF NOT EXISTS "agent_interventions_operation_batch_item_unique" ON "agent_interventions" USING btree ("operation_id","batch_id","item_index");--> statement-breakpoint+CREATE UNIQUE INDEX IF NOT EXISTS "agent_interventions_owner_activity_item_unique" ON "agent_interventions" USING btree ("user_id","activity_key","item_index");--> statement-breakpoint+CREATE INDEX IF NOT EXISTS "agent_interventions_owner_status_deadline_idx" ON "agent_interventions" USING btree ("user_id","workspace_id","status","deadline");--> statement-breakpoint+CREATE INDEX IF NOT EXISTS "agent_interventions_owner_batch_idx" ON "agent_interventions" USING btree ("user_id","workspace_id","batch_id","item_index");--> statement-breakpoint+CREATE INDEX IF NOT EXISTS "agent_interventions_activity_key_idx" ON "agent_interventions" USING btree ("user_id","activity_key");--> statement-breakpoint+CREATE INDEX IF NOT EXISTS "agent_interventions_status_deadline_idx" ON "agent_interventions" USING btree ("status","deadline");--> statement-breakpoint+CREATE UNIQUE INDEX IF NOT EXISTS "idx_push_live_activities_user_device_activity" ON "push_live_activities" USING btree ("user_id","device_id","activity_key");--> statement-breakpoint+CREATE INDEX IF NOT EXISTS "idx_push_live_activities_user_activity" ON "push_live_activities" USING btree ("user_id","activity_key");--> statement-breakpoint+CREATE INDEX IF NOT EXISTS "idx_push_live_activities_user_operation" ON "push_live_activities" USING btree ("user_id","operation_id");--> statement-breakpoint+CREATE INDEX IF NOT EXISTS "idx_push_live_activities_last_seen" ON "push_live_activities" USING btree ("last_seen_at");--> statement-breakpoint+ALTER TABLE "push_tokens" DROP CONSTRAINT IF EXISTS "push_tokens_apns_environment_check";--> statement-breakpoint+ALTER TABLE "push_tokens" ADD CONSTRAINT "push_tokens_apns_environment_check" CHECK ("push_tokens"."apns_environment" IS NULL OR "push_tokens"."apns_environment" IN ('sandbox', 'production')) NOT VALID;--> statement-breakpoint+ALTER TABLE "push_tokens" VALIDATE CONSTRAINT "push_tokens_apns_environment_check";diff --git a/packages/database/migrations/meta/0150_snapshot.json b/packages/database/migrations/meta/0150_snapshot.jsonnew file mode 100644index 00000000000..15c33e25775--- /dev/null+++ b/packages/database/migrations/meta/0150_snapshot.json@@ -0,0 +1,33057 @@+{+ "_meta": {+ "columns": {},+ "schemas": {},+ "tables": {}+ },+ "dialect": "postgresql",+ "enums": {},+ "id": "e371edb3-7839-41fa-a05e-7f7799570b09",+ "policies": {},+ "prevId": "f28b3c97-c7da-48f1-845c-bf90fa9d5df1",+ "roles": {},+ "schemas": {},+ "sequences": {},+ "tables": {+ "public.agents": {+ "name": "agents",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "slug": {+ "name": "slug",+ "type": "varchar(100)",+ "primaryKey": false,+ "notNull": false+ },+ "title": {+ "name": "title",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "name": {+ "name": "name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "description": {+ "name": "description",+ "type": "varchar(1000)",+ "primaryKey": false,+ "notNull": false+ },+ "tags": {+ "name": "tags",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false,+ "default": "'[]'::jsonb"+ },+ "editor_data": {+ "name": "editor_data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "avatar": {+ "name": "avatar",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "background_color": {+ "name": "background_color",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "market_identifier": {+ "name": "market_identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "profile": {+ "name": "profile",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "society_id": {+ "name": "society_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "plugins": {+ "name": "plugins",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "agency_config": {+ "name": "agency_config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "chat_config": {+ "name": "chat_config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "few_shots": {+ "name": "few_shots",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "model": {+ "name": "model",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "params": {+ "name": "params",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false,+ "default": "'{}'::jsonb"+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "system_role": {+ "name": "system_role",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "tts": {+ "name": "tts",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "virtual": {+ "name": "virtual",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": false+ },+ "pinned": {+ "name": "pinned",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "opening_message": {+ "name": "opening_message",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "opening_questions": {+ "name": "opening_questions",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false,+ "default": "'{}'"+ },+ "session_group_id": {+ "name": "session_group_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'public'"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "client_id_user_id_unique": {+ "name": "client_id_user_id_unique",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agents_slug_user_id_unique": {+ "name": "agents_slug_user_id_unique",+ "columns": [+ {+ "expression": "slug",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"agents\".\"workspace_id\" is null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agents_created_at_idx": {+ "name": "agents_created_at_idx",+ "columns": [+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agents_user_id_idx": {+ "name": "agents_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agents_title_idx": {+ "name": "agents_title_idx",+ "columns": [+ {+ "expression": "title",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agents_description_idx": {+ "name": "agents_description_idx",+ "columns": [+ {+ "expression": "description",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agents_session_group_id_idx": {+ "name": "agents_session_group_id_idx",+ "columns": [+ {+ "expression": "session_group_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agents_workspace_id_idx": {+ "name": "agents_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agents_workspace_visibility_idx": {+ "name": "agents_workspace_visibility_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agents_slug_workspace_id_unique": {+ "name": "agents_slug_workspace_id_unique",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "slug",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"agents\".\"workspace_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agents_user_id_users_id_fk": {+ "name": "agents_user_id_users_id_fk",+ "tableFrom": "agents",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agents_workspace_id_workspaces_id_fk": {+ "name": "agents_workspace_id_workspaces_id_fk",+ "tableFrom": "agents",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agents_session_group_id_session_groups_id_fk": {+ "name": "agents_session_group_id_session_groups_id_fk",+ "tableFrom": "agents",+ "tableTo": "session_groups",+ "columnsFrom": ["session_group_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agents_files": {+ "name": "agents_files",+ "schema": "",+ "columns": {+ "file_id": {+ "name": "file_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "agents_files_agent_id_idx": {+ "name": "agents_files_agent_id_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agents_files_file_id_idx": {+ "name": "agents_files_file_id_idx",+ "columns": [+ {+ "expression": "file_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agents_files_user_id_idx": {+ "name": "agents_files_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agents_files_workspace_id_idx": {+ "name": "agents_files_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agents_files_file_id_files_id_fk": {+ "name": "agents_files_file_id_files_id_fk",+ "tableFrom": "agents_files",+ "tableTo": "files",+ "columnsFrom": ["file_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agents_files_agent_id_agents_id_fk": {+ "name": "agents_files_agent_id_agents_id_fk",+ "tableFrom": "agents_files",+ "tableTo": "agents",+ "columnsFrom": ["agent_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agents_files_user_id_users_id_fk": {+ "name": "agents_files_user_id_users_id_fk",+ "tableFrom": "agents_files",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agents_files_workspace_id_workspaces_id_fk": {+ "name": "agents_files_workspace_id_workspaces_id_fk",+ "tableFrom": "agents_files",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "agents_files_file_id_agent_id_user_id_pk": {+ "name": "agents_files_file_id_agent_id_user_id_pk",+ "columns": ["file_id", "agent_id", "user_id"]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agents_knowledge_bases": {+ "name": "agents_knowledge_bases",+ "schema": "",+ "columns": {+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "knowledge_base_id": {+ "name": "knowledge_base_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": true+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "agents_knowledge_bases_agent_id_idx": {+ "name": "agents_knowledge_bases_agent_id_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agents_knowledge_bases_knowledge_base_id_idx": {+ "name": "agents_knowledge_bases_knowledge_base_id_idx",+ "columns": [+ {+ "expression": "knowledge_base_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agents_knowledge_bases_user_id_idx": {+ "name": "agents_knowledge_bases_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agents_knowledge_bases_workspace_id_idx": {+ "name": "agents_knowledge_bases_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agents_knowledge_bases_agent_id_agents_id_fk": {+ "name": "agents_knowledge_bases_agent_id_agents_id_fk",+ "tableFrom": "agents_knowledge_bases",+ "tableTo": "agents",+ "columnsFrom": ["agent_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agents_knowledge_bases_knowledge_base_id_knowledge_bases_id_fk": {+ "name": "agents_knowledge_bases_knowledge_base_id_knowledge_bases_id_fk",+ "tableFrom": "agents_knowledge_bases",+ "tableTo": "knowledge_bases",+ "columnsFrom": ["knowledge_base_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agents_knowledge_bases_user_id_users_id_fk": {+ "name": "agents_knowledge_bases_user_id_users_id_fk",+ "tableFrom": "agents_knowledge_bases",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agents_knowledge_bases_workspace_id_workspaces_id_fk": {+ "name": "agents_knowledge_bases_workspace_id_workspaces_id_fk",+ "tableFrom": "agents_knowledge_bases",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "agents_knowledge_bases_agent_id_knowledge_base_id_pk": {+ "name": "agents_knowledge_bases_agent_id_knowledge_base_id_pk",+ "columns": ["agent_id", "knowledge_base_id"]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_bot_providers": {+ "name": "agent_bot_providers",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "platform": {+ "name": "platform",+ "type": "varchar(50)",+ "primaryKey": false,+ "notNull": true+ },+ "application_id": {+ "name": "application_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "credentials": {+ "name": "credentials",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "settings": {+ "name": "settings",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false,+ "default": "'{}'::jsonb"+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "agent_bot_providers_platform_app_id_unique": {+ "name": "agent_bot_providers_platform_app_id_unique",+ "columns": [+ {+ "expression": "platform",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "application_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_bot_providers_platform_idx": {+ "name": "agent_bot_providers_platform_idx",+ "columns": [+ {+ "expression": "platform",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_bot_providers_agent_id_idx": {+ "name": "agent_bot_providers_agent_id_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_bot_providers_user_id_idx": {+ "name": "agent_bot_providers_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_bot_providers_workspace_id_idx": {+ "name": "agent_bot_providers_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_bot_providers_agent_id_agents_id_fk": {+ "name": "agent_bot_providers_agent_id_agents_id_fk",+ "tableFrom": "agent_bot_providers",+ "tableTo": "agents",+ "columnsFrom": ["agent_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_bot_providers_user_id_users_id_fk": {+ "name": "agent_bot_providers_user_id_users_id_fk",+ "tableFrom": "agent_bot_providers",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_bot_providers_workspace_id_workspaces_id_fk": {+ "name": "agent_bot_providers_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_bot_providers",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_cron_jobs": {+ "name": "agent_cron_jobs",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "group_id": {+ "name": "group_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": true+ },+ "cron_pattern": {+ "name": "cron_pattern",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "timezone": {+ "name": "timezone",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "default": "'UTC'"+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "edit_data": {+ "name": "edit_data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "max_executions": {+ "name": "max_executions",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "remaining_executions": {+ "name": "remaining_executions",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "execution_conditions": {+ "name": "execution_conditions",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "last_executed_at": {+ "name": "last_executed_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "total_executions": {+ "name": "total_executions",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "default": 0+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "agent_cron_jobs_agent_id_idx": {+ "name": "agent_cron_jobs_agent_id_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_cron_jobs_group_id_idx": {+ "name": "agent_cron_jobs_group_id_idx",+ "columns": [+ {+ "expression": "group_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_cron_jobs_user_id_idx": {+ "name": "agent_cron_jobs_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_cron_jobs_workspace_id_idx": {+ "name": "agent_cron_jobs_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_cron_jobs_enabled_idx": {+ "name": "agent_cron_jobs_enabled_idx",+ "columns": [+ {+ "expression": "enabled",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_cron_jobs_remaining_executions_idx": {+ "name": "agent_cron_jobs_remaining_executions_idx",+ "columns": [+ {+ "expression": "remaining_executions",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_cron_jobs_last_executed_at_idx": {+ "name": "agent_cron_jobs_last_executed_at_idx",+ "columns": [+ {+ "expression": "last_executed_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_cron_jobs_agent_id_agents_id_fk": {+ "name": "agent_cron_jobs_agent_id_agents_id_fk",+ "tableFrom": "agent_cron_jobs",+ "tableTo": "agents",+ "columnsFrom": ["agent_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_cron_jobs_group_id_chat_groups_id_fk": {+ "name": "agent_cron_jobs_group_id_chat_groups_id_fk",+ "tableFrom": "agent_cron_jobs",+ "tableTo": "chat_groups",+ "columnsFrom": ["group_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_cron_jobs_user_id_users_id_fk": {+ "name": "agent_cron_jobs_user_id_users_id_fk",+ "tableFrom": "agent_cron_jobs",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_cron_jobs_workspace_id_workspaces_id_fk": {+ "name": "agent_cron_jobs_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_cron_jobs",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_documents": {+ "name": "agent_documents",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "document_id": {+ "name": "document_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "template_id": {+ "name": "template_id",+ "type": "varchar(100)",+ "primaryKey": false,+ "notNull": false+ },+ "access_self": {+ "name": "access_self",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 31+ },+ "access_shared": {+ "name": "access_shared",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "access_public": {+ "name": "access_public",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "policy_load": {+ "name": "policy_load",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true,+ "default": "'always'"+ },+ "policy": {+ "name": "policy",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "policy_load_position": {+ "name": "policy_load_position",+ "type": "varchar(50)",+ "primaryKey": false,+ "notNull": true,+ "default": "'before-first-user'"+ },+ "policy_load_format": {+ "name": "policy_load_format",+ "type": "varchar(20)",+ "primaryKey": false,+ "notNull": true,+ "default": "'raw'"+ },+ "policy_load_rule": {+ "name": "policy_load_rule",+ "type": "varchar(50)",+ "primaryKey": false,+ "notNull": true,+ "default": "'always'"+ },+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "deleted_by_user_id": {+ "name": "deleted_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "deleted_by_agent_id": {+ "name": "deleted_by_agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "delete_reason": {+ "name": "delete_reason",+ "type": "text",+ "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": {+ "agent_documents_workspace_id_idx": {+ "name": "agent_documents_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_documents_user_id_idx": {+ "name": "agent_documents_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_documents_agent_id_idx": {+ "name": "agent_documents_agent_id_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_documents_access_self_idx": {+ "name": "agent_documents_access_self_idx",+ "columns": [+ {+ "expression": "access_self",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_documents_access_shared_idx": {+ "name": "agent_documents_access_shared_idx",+ "columns": [+ {+ "expression": "access_shared",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_documents_access_public_idx": {+ "name": "agent_documents_access_public_idx",+ "columns": [+ {+ "expression": "access_public",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_documents_policy_load_idx": {+ "name": "agent_documents_policy_load_idx",+ "columns": [+ {+ "expression": "policy_load",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_documents_template_id_idx": {+ "name": "agent_documents_template_id_idx",+ "columns": [+ {+ "expression": "template_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_documents_policy_load_position_idx": {+ "name": "agent_documents_policy_load_position_idx",+ "columns": [+ {+ "expression": "policy_load_position",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_documents_policy_load_format_idx": {+ "name": "agent_documents_policy_load_format_idx",+ "columns": [+ {+ "expression": "policy_load_format",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_documents_policy_load_rule_idx": {+ "name": "agent_documents_policy_load_rule_idx",+ "columns": [+ {+ "expression": "policy_load_rule",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_documents_agent_load_position_idx": {+ "name": "agent_documents_agent_load_position_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "policy_load_position",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_documents_deleted_at_idx": {+ "name": "agent_documents_deleted_at_idx",+ "columns": [+ {+ "expression": "deleted_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_documents_agent_autoload_deleted_idx": {+ "name": "agent_documents_agent_autoload_deleted_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "deleted_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "policy_load",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_documents_document_id_idx": {+ "name": "agent_documents_document_id_idx",+ "columns": [+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_documents_agent_document_user_unique": {+ "name": "agent_documents_agent_document_user_unique",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_documents_user_id_users_id_fk": {+ "name": "agent_documents_user_id_users_id_fk",+ "tableFrom": "agent_documents",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_documents_workspace_id_workspaces_id_fk": {+ "name": "agent_documents_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_documents",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_documents_agent_id_agents_id_fk": {+ "name": "agent_documents_agent_id_agents_id_fk",+ "tableFrom": "agent_documents",+ "tableTo": "agents",+ "columnsFrom": ["agent_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_documents_document_id_documents_id_fk": {+ "name": "agent_documents_document_id_documents_id_fk",+ "tableFrom": "agent_documents",+ "tableTo": "documents",+ "columnsFrom": ["document_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_documents_deleted_by_user_id_users_id_fk": {+ "name": "agent_documents_deleted_by_user_id_users_id_fk",+ "tableFrom": "agent_documents",+ "tableTo": "users",+ "columnsFrom": ["deleted_by_user_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "agent_documents_deleted_by_agent_id_agents_id_fk": {+ "name": "agent_documents_deleted_by_agent_id_agents_id_fk",+ "tableFrom": "agent_documents",+ "tableTo": "agents",+ "columnsFrom": ["deleted_by_agent_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_eval_benchmarks": {+ "name": "agent_eval_benchmarks",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "identifier": {+ "name": "identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "rubrics": {+ "name": "rubrics",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "reference_url": {+ "name": "reference_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "is_system": {+ "name": "is_system",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "agent_eval_benchmarks_identifier_user_id_unique": {+ "name": "agent_eval_benchmarks_identifier_user_id_unique",+ "columns": [+ {+ "expression": "identifier",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"agent_eval_benchmarks\".\"workspace_id\" is null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_benchmarks_is_system_idx": {+ "name": "agent_eval_benchmarks_is_system_idx",+ "columns": [+ {+ "expression": "is_system",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_benchmarks_user_id_idx": {+ "name": "agent_eval_benchmarks_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_benchmarks_workspace_id_idx": {+ "name": "agent_eval_benchmarks_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_benchmarks_identifier_workspace_id_unique": {+ "name": "agent_eval_benchmarks_identifier_workspace_id_unique",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "identifier",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"agent_eval_benchmarks\".\"workspace_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_eval_benchmarks_user_id_users_id_fk": {+ "name": "agent_eval_benchmarks_user_id_users_id_fk",+ "tableFrom": "agent_eval_benchmarks",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_eval_benchmarks_workspace_id_workspaces_id_fk": {+ "name": "agent_eval_benchmarks_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_eval_benchmarks",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_eval_datasets": {+ "name": "agent_eval_datasets",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "benchmark_id": {+ "name": "benchmark_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source_experiment_id": {+ "name": "source_experiment_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "identifier": {+ "name": "identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "eval_mode": {+ "name": "eval_mode",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "eval_config": {+ "name": "eval_config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "agent_eval_datasets_identifier_user_id_unique": {+ "name": "agent_eval_datasets_identifier_user_id_unique",+ "columns": [+ {+ "expression": "identifier",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"agent_eval_datasets\".\"workspace_id\" is null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_datasets_benchmark_id_idx": {+ "name": "agent_eval_datasets_benchmark_id_idx",+ "columns": [+ {+ "expression": "benchmark_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_datasets_source_experiment_id_idx": {+ "name": "agent_eval_datasets_source_experiment_id_idx",+ "columns": [+ {+ "expression": "source_experiment_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_datasets_user_id_idx": {+ "name": "agent_eval_datasets_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_datasets_workspace_id_idx": {+ "name": "agent_eval_datasets_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_datasets_identifier_workspace_id_unique": {+ "name": "agent_eval_datasets_identifier_workspace_id_unique",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "identifier",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"agent_eval_datasets\".\"workspace_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_eval_datasets_benchmark_id_agent_eval_benchmarks_id_fk": {+ "name": "agent_eval_datasets_benchmark_id_agent_eval_benchmarks_id_fk",+ "tableFrom": "agent_eval_datasets",+ "tableTo": "agent_eval_benchmarks",+ "columnsFrom": ["benchmark_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_eval_datasets_source_experiment_id_agent_eval_experiments_id_fk": {+ "name": "agent_eval_datasets_source_experiment_id_agent_eval_experiments_id_fk",+ "tableFrom": "agent_eval_datasets",+ "tableTo": "agent_eval_experiments",+ "columnsFrom": ["source_experiment_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "agent_eval_datasets_user_id_users_id_fk": {+ "name": "agent_eval_datasets_user_id_users_id_fk",+ "tableFrom": "agent_eval_datasets",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_eval_datasets_workspace_id_workspaces_id_fk": {+ "name": "agent_eval_datasets_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_eval_datasets",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_eval_experiment_benchmarks": {+ "name": "agent_eval_experiment_benchmarks",+ "schema": "",+ "columns": {+ "experiment_id": {+ "name": "experiment_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "benchmark_id": {+ "name": "benchmark_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_eval_experiment_benchmarks_benchmark_id_idx": {+ "name": "agent_eval_experiment_benchmarks_benchmark_id_idx",+ "columns": [+ {+ "expression": "benchmark_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_experiment_benchmarks_user_id_idx": {+ "name": "agent_eval_experiment_benchmarks_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_experiment_benchmarks_workspace_id_idx": {+ "name": "agent_eval_experiment_benchmarks_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_eval_experiment_benchmarks_experiment_id_agent_eval_experiments_id_fk": {+ "name": "agent_eval_experiment_benchmarks_experiment_id_agent_eval_experiments_id_fk",+ "tableFrom": "agent_eval_experiment_benchmarks",+ "tableTo": "agent_eval_experiments",+ "columnsFrom": ["experiment_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_eval_experiment_benchmarks_benchmark_id_agent_eval_benchmarks_id_fk": {+ "name": "agent_eval_experiment_benchmarks_benchmark_id_agent_eval_benchmarks_id_fk",+ "tableFrom": "agent_eval_experiment_benchmarks",+ "tableTo": "agent_eval_benchmarks",+ "columnsFrom": ["benchmark_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_eval_experiment_benchmarks_user_id_users_id_fk": {+ "name": "agent_eval_experiment_benchmarks_user_id_users_id_fk",+ "tableFrom": "agent_eval_experiment_benchmarks",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_eval_experiment_benchmarks_workspace_id_workspaces_id_fk": {+ "name": "agent_eval_experiment_benchmarks_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_eval_experiment_benchmarks",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "agent_eval_experiment_benchmarks_experiment_id_benchmark_id_pk": {+ "name": "agent_eval_experiment_benchmarks_experiment_id_benchmark_id_pk",+ "columns": ["experiment_id", "benchmark_id"]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_eval_experiments": {+ "name": "agent_eval_experiments",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "agent_eval_experiments_user_id_idx": {+ "name": "agent_eval_experiments_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_experiments_workspace_id_idx": {+ "name": "agent_eval_experiments_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_eval_experiments_user_id_users_id_fk": {+ "name": "agent_eval_experiments_user_id_users_id_fk",+ "tableFrom": "agent_eval_experiments",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_eval_experiments_workspace_id_workspaces_id_fk": {+ "name": "agent_eval_experiments_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_eval_experiments",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_eval_run_topics": {+ "name": "agent_eval_run_topics",+ "schema": "",+ "columns": {+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "run_id": {+ "name": "run_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "topic_id": {+ "name": "topic_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "test_case_id": {+ "name": "test_case_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "score": {+ "name": "score",+ "type": "real",+ "primaryKey": false,+ "notNull": false+ },+ "passed": {+ "name": "passed",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "eval_result": {+ "name": "eval_result",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_eval_run_topics_user_id_idx": {+ "name": "agent_eval_run_topics_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_run_topics_run_id_idx": {+ "name": "agent_eval_run_topics_run_id_idx",+ "columns": [+ {+ "expression": "run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_run_topics_test_case_id_idx": {+ "name": "agent_eval_run_topics_test_case_id_idx",+ "columns": [+ {+ "expression": "test_case_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_run_topics_workspace_id_idx": {+ "name": "agent_eval_run_topics_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_eval_run_topics_user_id_users_id_fk": {+ "name": "agent_eval_run_topics_user_id_users_id_fk",+ "tableFrom": "agent_eval_run_topics",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_eval_run_topics_workspace_id_workspaces_id_fk": {+ "name": "agent_eval_run_topics_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_eval_run_topics",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_eval_run_topics_run_id_agent_eval_runs_id_fk": {+ "name": "agent_eval_run_topics_run_id_agent_eval_runs_id_fk",+ "tableFrom": "agent_eval_run_topics",+ "tableTo": "agent_eval_runs",+ "columnsFrom": ["run_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_eval_run_topics_topic_id_topics_id_fk": {+ "name": "agent_eval_run_topics_topic_id_topics_id_fk",+ "tableFrom": "agent_eval_run_topics",+ "tableTo": "topics",+ "columnsFrom": ["topic_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_eval_run_topics_test_case_id_agent_eval_test_cases_id_fk": {+ "name": "agent_eval_run_topics_test_case_id_agent_eval_test_cases_id_fk",+ "tableFrom": "agent_eval_run_topics",+ "tableTo": "agent_eval_test_cases",+ "columnsFrom": ["test_case_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "agent_eval_run_topics_run_id_topic_id_pk": {+ "name": "agent_eval_run_topics_run_id_topic_id_pk",+ "columns": ["run_id", "topic_id"]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_eval_runs": {+ "name": "agent_eval_runs",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "dataset_id": {+ "name": "dataset_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "experiment_id": {+ "name": "experiment_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "parent_run_id": {+ "name": "parent_run_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "target_agent_id": {+ "name": "target_agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'idle'"+ },+ "config": {+ "name": "config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "metrics": {+ "name": "metrics",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "started_at": {+ "name": "started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "agent_eval_runs_dataset_id_idx": {+ "name": "agent_eval_runs_dataset_id_idx",+ "columns": [+ {+ "expression": "dataset_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_runs_experiment_id_idx": {+ "name": "agent_eval_runs_experiment_id_idx",+ "columns": [+ {+ "expression": "experiment_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_runs_parent_run_id_idx": {+ "name": "agent_eval_runs_parent_run_id_idx",+ "columns": [+ {+ "expression": "parent_run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_runs_user_id_idx": {+ "name": "agent_eval_runs_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_runs_status_idx": {+ "name": "agent_eval_runs_status_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_runs_target_agent_id_idx": {+ "name": "agent_eval_runs_target_agent_id_idx",+ "columns": [+ {+ "expression": "target_agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_runs_workspace_id_idx": {+ "name": "agent_eval_runs_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_eval_runs_dataset_id_agent_eval_datasets_id_fk": {+ "name": "agent_eval_runs_dataset_id_agent_eval_datasets_id_fk",+ "tableFrom": "agent_eval_runs",+ "tableTo": "agent_eval_datasets",+ "columnsFrom": ["dataset_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_eval_runs_experiment_id_agent_eval_experiments_id_fk": {+ "name": "agent_eval_runs_experiment_id_agent_eval_experiments_id_fk",+ "tableFrom": "agent_eval_runs",+ "tableTo": "agent_eval_experiments",+ "columnsFrom": ["experiment_id"],+ "columnsTo": ["id"],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "agent_eval_runs_target_agent_id_agents_id_fk": {+ "name": "agent_eval_runs_target_agent_id_agents_id_fk",+ "tableFrom": "agent_eval_runs",+ "tableTo": "agents",+ "columnsFrom": ["target_agent_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_eval_runs_user_id_users_id_fk": {+ "name": "agent_eval_runs_user_id_users_id_fk",+ "tableFrom": "agent_eval_runs",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_eval_runs_workspace_id_workspaces_id_fk": {+ "name": "agent_eval_runs_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_eval_runs",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_eval_runs_parent_run_id_agent_eval_runs_id_fk": {+ "name": "agent_eval_runs_parent_run_id_agent_eval_runs_id_fk",+ "tableFrom": "agent_eval_runs",+ "tableTo": "agent_eval_runs",+ "columnsFrom": ["parent_run_id"],+ "columnsTo": ["id"],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_eval_test_cases": {+ "name": "agent_eval_test_cases",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "dataset_id": {+ "name": "dataset_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "content": {+ "name": "content",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "eval_mode": {+ "name": "eval_mode",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "eval_config": {+ "name": "eval_config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "sort_order": {+ "name": "sort_order",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "agent_eval_test_cases_user_id_idx": {+ "name": "agent_eval_test_cases_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_test_cases_dataset_id_idx": {+ "name": "agent_eval_test_cases_dataset_id_idx",+ "columns": [+ {+ "expression": "dataset_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_test_cases_sort_order_idx": {+ "name": "agent_eval_test_cases_sort_order_idx",+ "columns": [+ {+ "expression": "sort_order",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_eval_test_cases_workspace_id_idx": {+ "name": "agent_eval_test_cases_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_eval_test_cases_user_id_users_id_fk": {+ "name": "agent_eval_test_cases_user_id_users_id_fk",+ "tableFrom": "agent_eval_test_cases",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_eval_test_cases_workspace_id_workspaces_id_fk": {+ "name": "agent_eval_test_cases_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_eval_test_cases",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_eval_test_cases_dataset_id_agent_eval_datasets_id_fk": {+ "name": "agent_eval_test_cases_dataset_id_agent_eval_datasets_id_fk",+ "tableFrom": "agent_eval_test_cases",+ "tableTo": "agent_eval_datasets",+ "columnsFrom": ["dataset_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_history_job_agents": {+ "name": "agent_history_job_agents",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "job_id": {+ "name": "job_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "agent_history_job_agents_job_id_agent_id_unique": {+ "name": "agent_history_job_agents_job_id_agent_id_unique",+ "columns": [+ {+ "expression": "job_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_history_job_agents_agent_id_idx": {+ "name": "agent_history_job_agents_agent_id_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_history_job_agents_job_id_agent_history_jobs_id_fk": {+ "name": "agent_history_job_agents_job_id_agent_history_jobs_id_fk",+ "tableFrom": "agent_history_job_agents",+ "tableTo": "agent_history_jobs",+ "columnsFrom": ["job_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_history_job_agents_agent_id_agents_id_fk": {+ "name": "agent_history_job_agents_agent_id_agents_id_fk",+ "tableFrom": "agent_history_job_agents",+ "tableTo": "agents",+ "columnsFrom": ["agent_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_history_job_groups": {+ "name": "agent_history_job_groups",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "job_id": {+ "name": "job_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "group_id": {+ "name": "group_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "agent_history_job_groups_job_id_group_id_unique": {+ "name": "agent_history_job_groups_job_id_group_id_unique",+ "columns": [+ {+ "expression": "job_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "group_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_history_job_groups_group_id_idx": {+ "name": "agent_history_job_groups_group_id_idx",+ "columns": [+ {+ "expression": "group_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_history_job_groups_job_id_agent_history_jobs_id_fk": {+ "name": "agent_history_job_groups_job_id_agent_history_jobs_id_fk",+ "tableFrom": "agent_history_job_groups",+ "tableTo": "agent_history_jobs",+ "columnsFrom": ["job_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_history_job_groups_group_id_chat_groups_id_fk": {+ "name": "agent_history_job_groups_group_id_chat_groups_id_fk",+ "tableFrom": "agent_history_job_groups",+ "tableTo": "chat_groups",+ "columnsFrom": ["group_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_history_job_topics": {+ "name": "agent_history_job_topics",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "job_id": {+ "name": "job_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "topic_id": {+ "name": "topic_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "priority": {+ "name": "priority",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "activity_at": {+ "name": "activity_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "payload": {+ "name": "payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "agent_history_job_topics_job_id_topic_id_unique": {+ "name": "agent_history_job_topics_job_id_topic_id_unique",+ "columns": [+ {+ "expression": "job_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_history_job_topics_topic_id_idx": {+ "name": "agent_history_job_topics_topic_id_idx",+ "columns": [+ {+ "expression": "topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_history_job_topics_pick_idx": {+ "name": "agent_history_job_topics_pick_idx",+ "columns": [+ {+ "expression": "job_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "priority",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "activity_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_history_job_topics_job_id_agent_history_jobs_id_fk": {+ "name": "agent_history_job_topics_job_id_agent_history_jobs_id_fk",+ "tableFrom": "agent_history_job_topics",+ "tableTo": "agent_history_jobs",+ "columnsFrom": ["job_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_history_job_topics_topic_id_topics_id_fk": {+ "name": "agent_history_job_topics_topic_id_topics_id_fk",+ "tableFrom": "agent_history_job_topics",+ "tableTo": "topics",+ "columnsFrom": ["topic_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_history_jobs": {+ "name": "agent_history_jobs",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'transfer'"+ },+ "payload": {+ "name": "payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "agent_ids": {+ "name": "agent_ids",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "session_ids": {+ "name": "session_ids",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "group_ids": {+ "name": "group_ids",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "source_user_id": {+ "name": "source_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source_workspace_id": {+ "name": "source_workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "target_user_id": {+ "name": "target_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "target_workspace_id": {+ "name": "target_workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "total_topics": {+ "name": "total_topics",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "completed_topics": {+ "name": "completed_topics",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "completed_at": {+ "name": "completed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "agent_history_jobs_status_idx": {+ "name": "agent_history_jobs_status_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_history_jobs_source_user_id_idx": {+ "name": "agent_history_jobs_source_user_id_idx",+ "columns": [+ {+ "expression": "source_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_history_jobs_target_user_id_idx": {+ "name": "agent_history_jobs_target_user_id_idx",+ "columns": [+ {+ "expression": "target_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_history_jobs_source_workspace_id_idx": {+ "name": "agent_history_jobs_source_workspace_id_idx",+ "columns": [+ {+ "expression": "source_workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_history_jobs_target_workspace_id_idx": {+ "name": "agent_history_jobs_target_workspace_id_idx",+ "columns": [+ {+ "expression": "target_workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_intervention_resolutions": {+ "name": "agent_intervention_resolutions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "resolution_request_id": {+ "name": "resolution_request_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "operation_id": {+ "name": "operation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "batch_id": {+ "name": "batch_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "actor_id": {+ "name": "actor_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "scope": {+ "name": "scope",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "selected_intervention_ids": {+ "name": "selected_intervention_ids",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "expected_versions": {+ "name": "expected_versions",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "expected_request_revision_hashes": {+ "name": "expected_request_revision_hashes",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "expected_item_count": {+ "name": "expected_item_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "action": {+ "name": "action",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "custom_execution_input_hash": {+ "name": "custom_execution_input_hash",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": false+ },+ "custom_execution_state": {+ "name": "custom_execution_state",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "custom_execution_attempt": {+ "name": "custom_execution_attempt",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "custom_execution_lease_token": {+ "name": "custom_execution_lease_token",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "custom_execution_lease_expires_at": {+ "name": "custom_execution_lease_expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "custom_execution_result": {+ "name": "custom_execution_result",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "remember_tool_key": {+ "name": "remember_tool_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "remember_effect_status": {+ "name": "remember_effect_status",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "original_arguments": {+ "name": "original_arguments",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "edited_arguments": {+ "name": "edited_arguments",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "original_request_revision_hash": {+ "name": "original_request_revision_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "edited_request_revision_hash": {+ "name": "edited_request_revision_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "argument_effect_status": {+ "name": "argument_effect_status",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'resolving'"+ },+ "resolving_at": {+ "name": "resolving_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "published_at": {+ "name": "published_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "continuation_started_at": {+ "name": "continuation_started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "producer_ack_at": {+ "name": "producer_ack_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "terminal_at": {+ "name": "terminal_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "rolled_back_at": {+ "name": "rolled_back_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "version": {+ "name": "version",+ "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()"+ }+ },+ "indexes": {+ "agent_intervention_resolutions_request_unique": {+ "name": "agent_intervention_resolutions_request_unique",+ "columns": [+ {+ "expression": "resolution_request_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_intervention_resolutions_owner_batch_idx": {+ "name": "agent_intervention_resolutions_owner_batch_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "batch_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_intervention_resolutions_status_created_idx": {+ "name": "agent_intervention_resolutions_status_created_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_intervention_resolutions_operation_id_agent_operations_id_fk": {+ "name": "agent_intervention_resolutions_operation_id_agent_operations_id_fk",+ "tableFrom": "agent_intervention_resolutions",+ "tableTo": "agent_operations",+ "columnsFrom": ["operation_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_intervention_resolutions_user_id_users_id_fk": {+ "name": "agent_intervention_resolutions_user_id_users_id_fk",+ "tableFrom": "agent_intervention_resolutions",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_intervention_resolutions_workspace_id_workspaces_id_fk": {+ "name": "agent_intervention_resolutions_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_intervention_resolutions",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "agent_intervention_resolutions_expected_item_count_check": {+ "name": "agent_intervention_resolutions_expected_item_count_check",+ "value": "\"agent_intervention_resolutions\".\"expected_item_count\" > 0"+ },+ "agent_intervention_resolutions_custom_execution_input_hash_check": {+ "name": "agent_intervention_resolutions_custom_execution_input_hash_check",+ "value": "\"agent_intervention_resolutions\".\"custom_execution_input_hash\" IS NULL OR \"agent_intervention_resolutions\".\"custom_execution_input_hash\" ~ '^[a-f0-9]{64}$'"+ },+ "agent_intervention_resolutions_custom_execution_state_check": {+ "name": "agent_intervention_resolutions_custom_execution_state_check",+ "value": "(\n (\"agent_intervention_resolutions\".\"custom_execution_state\" IS NULL\n AND \"agent_intervention_resolutions\".\"custom_execution_input_hash\" IS NULL\n AND \"agent_intervention_resolutions\".\"custom_execution_attempt\" IS NULL\n AND \"agent_intervention_resolutions\".\"custom_execution_lease_token\" IS NULL\n AND \"agent_intervention_resolutions\".\"custom_execution_lease_expires_at\" IS NULL\n AND \"agent_intervention_resolutions\".\"custom_execution_result\" IS NULL)\n OR\n (\"agent_intervention_resolutions\".\"custom_execution_state\" = 'pending'\n AND \"agent_intervention_resolutions\".\"custom_execution_attempt\" = 0\n AND \"agent_intervention_resolutions\".\"custom_execution_lease_token\" IS NULL\n AND \"agent_intervention_resolutions\".\"custom_execution_lease_expires_at\" IS NULL\n AND \"agent_intervention_resolutions\".\"custom_execution_result\" IS NULL)\n OR\n (\"agent_intervention_resolutions\".\"custom_execution_state\" = 'executing'\n AND \"agent_intervention_resolutions\".\"custom_execution_input_hash\" IS NOT NULL\n AND \"agent_intervention_resolutions\".\"custom_execution_attempt\" > 0\n AND \"agent_intervention_resolutions\".\"custom_execution_lease_token\" IS NOT NULL\n AND \"agent_intervention_resolutions\".\"custom_execution_lease_expires_at\" IS NOT NULL\n AND \"agent_intervention_resolutions\".\"custom_execution_result\" IS NULL)\n OR\n (\"agent_intervention_resolutions\".\"custom_execution_state\" = 'completed'\n AND \"agent_intervention_resolutions\".\"custom_execution_input_hash\" IS NOT NULL\n AND \"agent_intervention_resolutions\".\"custom_execution_attempt\" > 0\n AND \"agent_intervention_resolutions\".\"custom_execution_lease_token\" IS NOT NULL\n AND \"agent_intervention_resolutions\".\"custom_execution_lease_expires_at\" IS NOT NULL\n AND \"agent_intervention_resolutions\".\"custom_execution_result\" IS NOT NULL)\n )"+ },+ "agent_intervention_resolutions_custom_execution_parent_status_check": {+ "name": "agent_intervention_resolutions_custom_execution_parent_status_check",+ "value": "\"agent_intervention_resolutions\".\"custom_execution_state\" NOT IN ('executing', 'completed') OR \"agent_intervention_resolutions\".\"status\" IN ('resolving', 'published', 'acknowledged', 'completed')"+ },+ "agent_intervention_resolutions_version_check": {+ "name": "agent_intervention_resolutions_version_check",+ "value": "\"agent_intervention_resolutions\".\"version\" > 0"+ }+ },+ "isRLSEnabled": false+ },+ "public.agent_interventions": {+ "name": "agent_interventions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "operation_id": {+ "name": "operation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "tool_call_id": {+ "name": "tool_call_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "tool_message_id": {+ "name": "tool_message_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "interaction_kind": {+ "name": "interaction_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "surface": {+ "name": "surface",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "system_action_eligibility": {+ "name": "system_action_eligibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "approval_mode": {+ "name": "approval_mode",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "batch_id": {+ "name": "batch_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "activity_key": {+ "name": "activity_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "step_index": {+ "name": "step_index",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "item_index": {+ "name": "item_index",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "item_count": {+ "name": "item_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "sealed": {+ "name": "sealed",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "canonical_tool_key": {+ "name": "canonical_tool_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "request_revision_hash": {+ "name": "request_revision_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "allowed_actions": {+ "name": "allowed_actions",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "risk": {+ "name": "risk",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "review_token_hash": {+ "name": "review_token_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "review_context": {+ "name": "review_context",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "sanitized_request": {+ "name": "sanitized_request",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "deadline": {+ "name": "deadline",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "resolution_id": {+ "name": "resolution_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "resolving_at": {+ "name": "resolving_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "published_at": {+ "name": "published_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "resolved_at": {+ "name": "resolved_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "producer_ack_at": {+ "name": "producer_ack_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "version": {+ "name": "version",+ "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()"+ }+ },+ "indexes": {+ "agent_interventions_operation_tool_call_unique": {+ "name": "agent_interventions_operation_tool_call_unique",+ "columns": [+ {+ "expression": "operation_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "tool_call_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_interventions_review_token_hash_unique": {+ "name": "agent_interventions_review_token_hash_unique",+ "columns": [+ {+ "expression": "review_token_hash",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_interventions_operation_batch_item_unique": {+ "name": "agent_interventions_operation_batch_item_unique",+ "columns": [+ {+ "expression": "operation_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "batch_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "item_index",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_interventions_owner_activity_item_unique": {+ "name": "agent_interventions_owner_activity_item_unique",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "activity_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "item_index",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_interventions_owner_status_deadline_idx": {+ "name": "agent_interventions_owner_status_deadline_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "deadline",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_interventions_owner_batch_idx": {+ "name": "agent_interventions_owner_batch_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "batch_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "item_index",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_interventions_activity_key_idx": {+ "name": "agent_interventions_activity_key_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "activity_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_interventions_status_deadline_idx": {+ "name": "agent_interventions_status_deadline_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "deadline",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_interventions_operation_id_agent_operations_id_fk": {+ "name": "agent_interventions_operation_id_agent_operations_id_fk",+ "tableFrom": "agent_interventions",+ "tableTo": "agent_operations",+ "columnsFrom": ["operation_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_interventions_user_id_users_id_fk": {+ "name": "agent_interventions_user_id_users_id_fk",+ "tableFrom": "agent_interventions",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_interventions_workspace_id_workspaces_id_fk": {+ "name": "agent_interventions_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_interventions",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_interventions_resolution_id_agent_intervention_resolutions_id_fk": {+ "name": "agent_interventions_resolution_id_agent_intervention_resolutions_id_fk",+ "tableFrom": "agent_interventions",+ "tableTo": "agent_intervention_resolutions",+ "columnsFrom": ["resolution_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "agent_interventions_review_token_hash_check": {+ "name": "agent_interventions_review_token_hash_check",+ "value": "\"agent_interventions\".\"review_token_hash\" ~ '^[a-f0-9]{64}$'"+ },+ "agent_interventions_request_revision_hash_check": {+ "name": "agent_interventions_request_revision_hash_check",+ "value": "\"agent_interventions\".\"request_revision_hash\" ~ '^[a-f0-9]{64}$'"+ },+ "agent_interventions_step_index_check": {+ "name": "agent_interventions_step_index_check",+ "value": "\"agent_interventions\".\"step_index\" >= 0"+ },+ "agent_interventions_item_bounds_check": {+ "name": "agent_interventions_item_bounds_check",+ "value": "\"agent_interventions\".\"item_count\" > 0 AND \"agent_interventions\".\"item_index\" >= 0 AND \"agent_interventions\".\"item_index\" < \"agent_interventions\".\"item_count\""+ },+ "agent_interventions_version_check": {+ "name": "agent_interventions_version_check",+ "value": "\"agent_interventions\".\"version\" > 0"+ }+ },+ "isRLSEnabled": false+ },+ "public.agent_label_assignments": {+ "name": "agent_label_assignments",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "label_id": {+ "name": "label_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "agent_label_assignments_label_id_agent_id_unique": {+ "name": "agent_label_assignments_label_id_agent_id_unique",+ "columns": [+ {+ "expression": "label_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_label_assignments_agent_id_idx": {+ "name": "agent_label_assignments_agent_id_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_label_assignments_workspace_id_idx": {+ "name": "agent_label_assignments_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_label_assignments_label_id_agent_labels_id_fk": {+ "name": "agent_label_assignments_label_id_agent_labels_id_fk",+ "tableFrom": "agent_label_assignments",+ "tableTo": "agent_labels",+ "columnsFrom": ["label_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_label_assignments_agent_id_agents_id_fk": {+ "name": "agent_label_assignments_agent_id_agents_id_fk",+ "tableFrom": "agent_label_assignments",+ "tableTo": "agents",+ "columnsFrom": ["agent_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_label_assignments_user_id_users_id_fk": {+ "name": "agent_label_assignments_user_id_users_id_fk",+ "tableFrom": "agent_label_assignments",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_label_assignments_workspace_id_workspaces_id_fk": {+ "name": "agent_label_assignments_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_label_assignments",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_labels": {+ "name": "agent_labels",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "archived": {+ "name": "archived",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "agent_labels_user_id_idx": {+ "name": "agent_labels_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_labels_workspace_id_idx": {+ "name": "agent_labels_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_labels_user_id_name_unique": {+ "name": "agent_labels_user_id_name_unique",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "name",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"agent_labels\".\"workspace_id\" IS NULL AND \"agent_labels\".\"archived\" = false",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_labels_workspace_id_name_unique": {+ "name": "agent_labels_workspace_id_name_unique",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "name",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"agent_labels\".\"workspace_id\" IS NOT NULL AND \"agent_labels\".\"archived\" = false",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_labels_user_id_users_id_fk": {+ "name": "agent_labels_user_id_users_id_fk",+ "tableFrom": "agent_labels",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_labels_workspace_id_workspaces_id_fk": {+ "name": "agent_labels_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_labels",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_operations": {+ "name": "agent_operations",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "topic_id": {+ "name": "topic_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "thread_id": {+ "name": "thread_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "task_id": {+ "name": "task_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "chat_group_id": {+ "name": "chat_group_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "parent_operation_id": {+ "name": "parent_operation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "completion_reason": {+ "name": "completion_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "verify_status": {+ "name": "verify_status",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "verify_plan": {+ "name": "verify_plan",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "verify_plan_confirmed_at": {+ "name": "verify_plan_confirmed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "started_at": {+ "name": "started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "completed_at": {+ "name": "completed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "step_count": {+ "name": "step_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "max_steps": {+ "name": "max_steps",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "force_finish": {+ "name": "force_finish",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "interruption": {+ "name": "interruption",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "error": {+ "name": "error",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "total_cost": {+ "name": "total_cost",+ "type": "numeric(20, 6)",+ "primaryKey": false,+ "notNull": false+ },+ "currency": {+ "name": "currency",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'USD'"+ },+ "total_input_tokens": {+ "name": "total_input_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "total_output_tokens": {+ "name": "total_output_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "total_tokens": {+ "name": "total_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "llm_calls": {+ "name": "llm_calls",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "tool_calls": {+ "name": "tool_calls",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "human_interventions": {+ "name": "human_interventions",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "processing_time_ms": {+ "name": "processing_time_ms",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "human_waiting_time_ms": {+ "name": "human_waiting_time_ms",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "cost": {+ "name": "cost",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "usage": {+ "name": "usage",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "cost_limit": {+ "name": "cost_limit",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "model": {+ "name": "model",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "model_runtime_config": {+ "name": "model_runtime_config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "trigger": {+ "name": "trigger",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "app_context": {+ "name": "app_context",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "trace_s3_key": {+ "name": "trace_s3_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false,+ "default": "'{}'::jsonb"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "agent_operations_user_id_idx": {+ "name": "agent_operations_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_operations_workspace_id_idx": {+ "name": "agent_operations_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_operations_agent_id_idx": {+ "name": "agent_operations_agent_id_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_operations_topic_id_idx": {+ "name": "agent_operations_topic_id_idx",+ "columns": [+ {+ "expression": "topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_operations_thread_id_idx": {+ "name": "agent_operations_thread_id_idx",+ "columns": [+ {+ "expression": "thread_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_operations_task_id_idx": {+ "name": "agent_operations_task_id_idx",+ "columns": [+ {+ "expression": "task_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_operations_chat_group_id_idx": {+ "name": "agent_operations_chat_group_id_idx",+ "columns": [+ {+ "expression": "chat_group_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_operations_parent_operation_id_idx": {+ "name": "agent_operations_parent_operation_id_idx",+ "columns": [+ {+ "expression": "parent_operation_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_operations_status_idx": {+ "name": "agent_operations_status_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_operations_user_id_created_at_idx": {+ "name": "agent_operations_user_id_created_at_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_operations_metadata_idx": {+ "name": "agent_operations_metadata_idx",+ "columns": [+ {+ "expression": "metadata",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "gin",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_operations_workspace_id_workspaces_id_fk": {+ "name": "agent_operations_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_operations",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_operations_agent_id_agents_id_fk": {+ "name": "agent_operations_agent_id_agents_id_fk",+ "tableFrom": "agent_operations",+ "tableTo": "agents",+ "columnsFrom": ["agent_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "agent_operations_topic_id_topics_id_fk": {+ "name": "agent_operations_topic_id_topics_id_fk",+ "tableFrom": "agent_operations",+ "tableTo": "topics",+ "columnsFrom": ["topic_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "agent_operations_thread_id_threads_id_fk": {+ "name": "agent_operations_thread_id_threads_id_fk",+ "tableFrom": "agent_operations",+ "tableTo": "threads",+ "columnsFrom": ["thread_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "agent_operations_task_id_tasks_id_fk": {+ "name": "agent_operations_task_id_tasks_id_fk",+ "tableFrom": "agent_operations",+ "tableTo": "tasks",+ "columnsFrom": ["task_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "agent_operations_chat_group_id_chat_groups_id_fk": {+ "name": "agent_operations_chat_group_id_chat_groups_id_fk",+ "tableFrom": "agent_operations",+ "tableTo": "chat_groups",+ "columnsFrom": ["chat_group_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_account_bindings": {+ "name": "agent_account_bindings",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "account_id": {+ "name": "account_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pool'"+ },+ "priority": {+ "name": "priority",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "weight": {+ "name": "weight",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 1+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "agent_account_bindings_agent_account_unique": {+ "name": "agent_account_bindings_agent_account_unique",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "account_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_account_bindings_agent_pinned_unique": {+ "name": "agent_account_bindings_agent_pinned_unique",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"agent_account_bindings\".\"role\" = 'pinned'",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_account_bindings_agent_id_idx": {+ "name": "agent_account_bindings_agent_id_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_account_bindings_account_id_idx": {+ "name": "agent_account_bindings_account_id_idx",+ "columns": [+ {+ "expression": "account_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_account_bindings_user_id_idx": {+ "name": "agent_account_bindings_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_account_bindings_workspace_id_idx": {+ "name": "agent_account_bindings_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_account_bindings_agent_id_agents_id_fk": {+ "name": "agent_account_bindings_agent_id_agents_id_fk",+ "tableFrom": "agent_account_bindings",+ "tableTo": "agents",+ "columnsFrom": ["agent_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_account_bindings_account_id_agent_provider_accounts_id_fk": {+ "name": "agent_account_bindings_account_id_agent_provider_accounts_id_fk",+ "tableFrom": "agent_account_bindings",+ "tableTo": "agent_provider_accounts",+ "columnsFrom": ["account_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_account_bindings_user_id_users_id_fk": {+ "name": "agent_account_bindings_user_id_users_id_fk",+ "tableFrom": "agent_account_bindings",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_account_bindings_workspace_id_workspaces_id_fk": {+ "name": "agent_account_bindings_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_account_bindings",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_provider_accounts": {+ "name": "agent_provider_accounts",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "external_account_id": {+ "name": "external_account_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "email": {+ "name": "email",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "display_name": {+ "name": "display_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "organization_id": {+ "name": "organization_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "plan_tier": {+ "name": "plan_tier",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "rate_limit_tier": {+ "name": "rate_limit_tier",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "label": {+ "name": "label",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "credential_mode": {+ "name": "credential_mode",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'referenced'"+ },+ "credentials": {+ "name": "credentials",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "credential_ref": {+ "name": "credential_ref",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "token_expires_at": {+ "name": "token_expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'active'"+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "last_validated_at": {+ "name": "last_validated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "agent_provider_accounts_user_id_idx": {+ "name": "agent_provider_accounts_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_provider_accounts_workspace_id_idx": {+ "name": "agent_provider_accounts_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_provider_accounts_token_expires_at_idx": {+ "name": "agent_provider_accounts_token_expires_at_idx",+ "columns": [+ {+ "expression": "token_expires_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_provider_accounts_identity_unique": {+ "name": "agent_provider_accounts_identity_unique",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "external_account_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"agent_provider_accounts\".\"external_account_id\" IS NOT NULL and \"agent_provider_accounts\".\"workspace_id\" is null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_provider_accounts_identity_workspace_unique": {+ "name": "agent_provider_accounts_identity_workspace_unique",+ "columns": [+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "external_account_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"agent_provider_accounts\".\"external_account_id\" IS NOT NULL and \"agent_provider_accounts\".\"workspace_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_provider_accounts_user_id_users_id_fk": {+ "name": "agent_provider_accounts_user_id_users_id_fk",+ "tableFrom": "agent_provider_accounts",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_provider_accounts_workspace_id_workspaces_id_fk": {+ "name": "agent_provider_accounts_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_provider_accounts",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_quota_calibrations": {+ "name": "agent_quota_calibrations",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "account_id": {+ "name": "account_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "limit_type": {+ "name": "limit_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "scope_key": {+ "name": "scope_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "capacity_usd": {+ "name": "capacity_usd",+ "type": "numeric(20, 6)",+ "primaryKey": false,+ "notNull": true+ },+ "capacity_tokens_equivalent": {+ "name": "capacity_tokens_equivalent",+ "type": "bigint",+ "primaryKey": false,+ "notNull": false+ },+ "model_mix": {+ "name": "model_mix",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "sample_count": {+ "name": "sample_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "confidence": {+ "name": "confidence",+ "type": "numeric(20, 6)",+ "primaryKey": false,+ "notNull": false+ },+ "method": {+ "name": "method",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "window_seconds": {+ "name": "window_seconds",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "calibrated_at": {+ "name": "calibrated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_quota_calibrations_account_type_scope_idx": {+ "name": "agent_quota_calibrations_account_type_scope_idx",+ "columns": [+ {+ "expression": "account_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "limit_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "scope_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "calibrated_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_quota_calibrations_workspace_id_idx": {+ "name": "agent_quota_calibrations_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_quota_calibrations_account_id_agent_provider_accounts_id_fk": {+ "name": "agent_quota_calibrations_account_id_agent_provider_accounts_id_fk",+ "tableFrom": "agent_quota_calibrations",+ "tableTo": "agent_provider_accounts",+ "columnsFrom": ["account_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_quota_calibrations_user_id_users_id_fk": {+ "name": "agent_quota_calibrations_user_id_users_id_fk",+ "tableFrom": "agent_quota_calibrations",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_quota_calibrations_workspace_id_workspaces_id_fk": {+ "name": "agent_quota_calibrations_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_quota_calibrations",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_quota_snapshots": {+ "name": "agent_quota_snapshots",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "account_id": {+ "name": "account_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "device_id": {+ "name": "device_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "limit_type": {+ "name": "limit_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "scope_key": {+ "name": "scope_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "resets_at": {+ "name": "resets_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "utilization": {+ "name": "utilization",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "severity": {+ "name": "severity",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "is_active": {+ "name": "is_active",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "captured_at": {+ "name": "captured_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "raw": {+ "name": "raw",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_quota_snapshots_account_type_scope_idx": {+ "name": "agent_quota_snapshots_account_type_scope_idx",+ "columns": [+ {+ "expression": "account_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "limit_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "scope_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "captured_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_quota_snapshots_account_captured_idx": {+ "name": "agent_quota_snapshots_account_captured_idx",+ "columns": [+ {+ "expression": "account_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "captured_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_quota_snapshots_resets_at_idx": {+ "name": "agent_quota_snapshots_resets_at_idx",+ "columns": [+ {+ "expression": "resets_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_quota_snapshots_workspace_id_idx": {+ "name": "agent_quota_snapshots_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_quota_snapshots_account_id_agent_provider_accounts_id_fk": {+ "name": "agent_quota_snapshots_account_id_agent_provider_accounts_id_fk",+ "tableFrom": "agent_quota_snapshots",+ "tableTo": "agent_provider_accounts",+ "columnsFrom": ["account_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_quota_snapshots_user_id_users_id_fk": {+ "name": "agent_quota_snapshots_user_id_users_id_fk",+ "tableFrom": "agent_quota_snapshots",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_quota_snapshots_workspace_id_workspaces_id_fk": {+ "name": "agent_quota_snapshots_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_quota_snapshots",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_quota_snapshots_device_id_devices_id_fk": {+ "name": "agent_quota_snapshots_device_id_devices_id_fk",+ "tableFrom": "agent_quota_snapshots",+ "tableTo": "devices",+ "columnsFrom": ["device_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_quota_usage_ledger": {+ "name": "agent_quota_usage_ledger",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "account_id": {+ "name": "account_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "model": {+ "name": "model",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "occurred_at": {+ "name": "occurred_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "input_tokens": {+ "name": "input_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "output_tokens": {+ "name": "output_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "cache_read_tokens": {+ "name": "cache_read_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "cache_write_tokens": {+ "name": "cache_write_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "reasoning_tokens": {+ "name": "reasoning_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "cost_usd": {+ "name": "cost_usd",+ "type": "numeric(20, 6)",+ "primaryKey": false,+ "notNull": false+ },+ "cost_source": {+ "name": "cost_source",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "message_id": {+ "name": "message_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "operation_id": {+ "name": "operation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "topic_id": {+ "name": "topic_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "external_event_id": {+ "name": "external_event_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_quota_usage_ledger_account_occurred_idx": {+ "name": "agent_quota_usage_ledger_account_occurred_idx",+ "columns": [+ {+ "expression": "account_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "occurred_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_quota_usage_ledger_account_model_occurred_idx": {+ "name": "agent_quota_usage_ledger_account_model_occurred_idx",+ "columns": [+ {+ "expression": "account_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "model",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "occurred_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_quota_usage_ledger_message_id_idx": {+ "name": "agent_quota_usage_ledger_message_id_idx",+ "columns": [+ {+ "expression": "message_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_quota_usage_ledger_operation_id_idx": {+ "name": "agent_quota_usage_ledger_operation_id_idx",+ "columns": [+ {+ "expression": "operation_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_quota_usage_ledger_workspace_id_idx": {+ "name": "agent_quota_usage_ledger_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_quota_usage_ledger_external_event_unique": {+ "name": "agent_quota_usage_ledger_external_event_unique",+ "columns": [+ {+ "expression": "external_event_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"agent_quota_usage_ledger\".\"external_event_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_quota_usage_ledger_account_id_agent_provider_accounts_id_fk": {+ "name": "agent_quota_usage_ledger_account_id_agent_provider_accounts_id_fk",+ "tableFrom": "agent_quota_usage_ledger",+ "tableTo": "agent_provider_accounts",+ "columnsFrom": ["account_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "agent_quota_usage_ledger_user_id_users_id_fk": {+ "name": "agent_quota_usage_ledger_user_id_users_id_fk",+ "tableFrom": "agent_quota_usage_ledger",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_quota_usage_ledger_workspace_id_workspaces_id_fk": {+ "name": "agent_quota_usage_ledger_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_quota_usage_ledger",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_quota_usage_ledger_message_id_messages_id_fk": {+ "name": "agent_quota_usage_ledger_message_id_messages_id_fk",+ "tableFrom": "agent_quota_usage_ledger",+ "tableTo": "messages",+ "columnsFrom": ["message_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "agent_quota_usage_ledger_operation_id_agent_operations_id_fk": {+ "name": "agent_quota_usage_ledger_operation_id_agent_operations_id_fk",+ "tableFrom": "agent_quota_usage_ledger",+ "tableTo": "agent_operations",+ "columnsFrom": ["operation_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "agent_quota_usage_ledger_topic_id_topics_id_fk": {+ "name": "agent_quota_usage_ledger_topic_id_topics_id_fk",+ "tableFrom": "agent_quota_usage_ledger",+ "tableTo": "topics",+ "columnsFrom": ["topic_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "agent_quota_usage_ledger_agent_id_agents_id_fk": {+ "name": "agent_quota_usage_ledger_agent_id_agents_id_fk",+ "tableFrom": "agent_quota_usage_ledger",+ "tableTo": "agents",+ "columnsFrom": ["agent_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_quota_windows": {+ "name": "agent_quota_windows",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "account_id": {+ "name": "account_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "limit_type": {+ "name": "limit_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "scope_key": {+ "name": "scope_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "resets_at": {+ "name": "resets_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "window_start_at": {+ "name": "window_start_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "window_seconds": {+ "name": "window_seconds",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "peak_utilization": {+ "name": "peak_utilization",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "last_utilization": {+ "name": "last_utilization",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "rate_limited_at": {+ "name": "rate_limited_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "observed_cost_usd": {+ "name": "observed_cost_usd",+ "type": "numeric(20, 6)",+ "primaryKey": false,+ "notNull": false+ },+ "observed_tokens": {+ "name": "observed_tokens",+ "type": "bigint",+ "primaryKey": false,+ "notNull": false+ },+ "estimated_capacity_usd": {+ "name": "estimated_capacity_usd",+ "type": "numeric(20, 6)",+ "primaryKey": false,+ "notNull": false+ },+ "contaminated": {+ "name": "contaminated",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "first_seen_at": {+ "name": "first_seen_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "last_seen_at": {+ "name": "last_seen_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "agent_quota_windows_natural_key_unique": {+ "name": "agent_quota_windows_natural_key_unique",+ "columns": [+ {+ "expression": "account_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "limit_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "scope_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "resets_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_quota_windows_account_resets_idx": {+ "name": "agent_quota_windows_account_resets_idx",+ "columns": [+ {+ "expression": "account_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "resets_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_quota_windows_user_id_idx": {+ "name": "agent_quota_windows_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_quota_windows_workspace_id_idx": {+ "name": "agent_quota_windows_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_quota_windows_account_id_agent_provider_accounts_id_fk": {+ "name": "agent_quota_windows_account_id_agent_provider_accounts_id_fk",+ "tableFrom": "agent_quota_windows",+ "tableTo": "agent_provider_accounts",+ "columnsFrom": ["account_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_quota_windows_user_id_users_id_fk": {+ "name": "agent_quota_windows_user_id_users_id_fk",+ "tableFrom": "agent_quota_windows",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_quota_windows_workspace_id_workspaces_id_fk": {+ "name": "agent_quota_windows_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_quota_windows",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_shares": {+ "name": "agent_shares",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'private'"+ },+ "share_config": {+ "name": "share_config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "user_view_count": {+ "name": "user_view_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "agent_shares_agent_id_unique": {+ "name": "agent_shares_agent_id_unique",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_shares_visibility_idx": {+ "name": "agent_shares_visibility_idx",+ "columns": [+ {+ "expression": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_shares_agent_id_agents_id_fk": {+ "name": "agent_shares_agent_id_agents_id_fk",+ "tableFrom": "agent_shares",+ "tableTo": "agents",+ "columnsFrom": ["agent_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_skills": {+ "name": "agent_skills",+ "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": true+ },+ "identifier": {+ "name": "identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "manifest": {+ "name": "manifest",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "editor_data": {+ "name": "editor_data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "resources": {+ "name": "resources",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false,+ "default": "'{}'::jsonb"+ },+ "zip_file_hash": {+ "name": "zip_file_hash",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "agent_skills_user_name_idx": {+ "name": "agent_skills_user_name_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "name",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"agent_skills\".\"workspace_id\" is null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_skills_identifier_idx": {+ "name": "agent_skills_identifier_idx",+ "columns": [+ {+ "expression": "identifier",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_skills_user_id_idx": {+ "name": "agent_skills_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_skills_source_idx": {+ "name": "agent_skills_source_idx",+ "columns": [+ {+ "expression": "source",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_skills_zip_hash_idx": {+ "name": "agent_skills_zip_hash_idx",+ "columns": [+ {+ "expression": "zip_file_hash",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_skills_workspace_id_idx": {+ "name": "agent_skills_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_skills_name_workspace_id_unique": {+ "name": "agent_skills_name_workspace_id_unique",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "name",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"agent_skills\".\"workspace_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_skills_zip_file_hash_global_files_hash_id_fk": {+ "name": "agent_skills_zip_file_hash_global_files_hash_id_fk",+ "tableFrom": "agent_skills",+ "tableTo": "global_files",+ "columnsFrom": ["zip_file_hash"],+ "columnsTo": ["hash_id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "agent_skills_user_id_users_id_fk": {+ "name": "agent_skills_user_id_users_id_fk",+ "tableFrom": "agent_skills",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_skills_workspace_id_workspaces_id_fk": {+ "name": "agent_skills_workspace_id_workspaces_id_fk",+ "tableFrom": "agent_skills",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.ai_models": {+ "name": "ai_models",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(150)",+ "primaryKey": false,+ "notNull": true+ },+ "_id": {+ "name": "_id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "display_name": {+ "name": "display_name",+ "type": "varchar(200)",+ "primaryKey": false,+ "notNull": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "organization": {+ "name": "organization",+ "type": "varchar(100)",+ "primaryKey": false,+ "notNull": false+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "provider_id": {+ "name": "provider_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true+ },+ "type": {+ "name": "type",+ "type": "varchar(20)",+ "primaryKey": false,+ "notNull": true,+ "default": "'chat'"+ },+ "sort": {+ "name": "sort",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "pricing": {+ "name": "pricing",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "parameters": {+ "name": "parameters",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false,+ "default": "'{}'::jsonb"+ },+ "config": {+ "name": "config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "abilities": {+ "name": "abilities",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false,+ "default": "'{}'::jsonb"+ },+ "context_window_tokens": {+ "name": "context_window_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "source": {+ "name": "source",+ "type": "varchar(20)",+ "primaryKey": false,+ "notNull": false+ },+ "released_at": {+ "name": "released_at",+ "type": "varchar(10)",+ "primaryKey": false,+ "notNull": false+ },+ "settings": {+ "name": "settings",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false,+ "default": "'{}'::jsonb"+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "ai_models_id_provider_id_user_id_unique": {+ "name": "ai_models_id_provider_id_user_id_unique",+ "columns": [+ {+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"ai_models\".\"workspace_id\" is null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "ai_models_id_provider_id_user_id_workspace_id_unique": {+ "name": "ai_models_id_provider_id_user_id_workspace_id_unique",+ "columns": [+ {+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"ai_models\".\"workspace_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "ai_models_user_id_idx": {+ "name": "ai_models_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "ai_models_workspace_id_idx": {+ "name": "ai_models_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "ai_models_user_id_users_id_fk": {+ "name": "ai_models_user_id_users_id_fk",+ "tableFrom": "ai_models",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "ai_models_workspace_id_workspaces_id_fk": {+ "name": "ai_models_workspace_id_workspaces_id_fk",+ "tableFrom": "ai_models",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.ai_providers": {+ "name": "ai_providers",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "_id": {+ "name": "_id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "sort": {+ "name": "sort",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "fetch_on_client": {+ "name": "fetch_on_client",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "check_model": {+ "name": "check_model",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "logo": {+ "name": "logo",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "key_vaults": {+ "name": "key_vaults",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "source": {+ "name": "source",+ "type": "varchar(20)",+ "primaryKey": false,+ "notNull": false+ },+ "settings": {+ "name": "settings",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "config": {+ "name": "config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "ai_providers_id_user_id_unique": {+ "name": "ai_providers_id_user_id_unique",+ "columns": [+ {+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"ai_providers\".\"workspace_id\" is null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "ai_providers_id_user_id_workspace_id_unique": {+ "name": "ai_providers_id_user_id_workspace_id_unique",+ "columns": [+ {+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"ai_providers\".\"workspace_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "ai_providers_user_id_idx": {+ "name": "ai_providers_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "ai_providers_workspace_id_idx": {+ "name": "ai_providers_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "ai_providers_user_id_users_id_fk": {+ "name": "ai_providers_user_id_users_id_fk",+ "tableFrom": "ai_providers",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "ai_providers_workspace_id_workspaces_id_fk": {+ "name": "ai_providers_workspace_id_workspaces_id_fk",+ "tableFrom": "ai_providers",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.api_keys": {+ "name": "api_keys",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "varchar(256)",+ "primaryKey": false,+ "notNull": true+ },+ "key": {+ "name": "key",+ "type": "varchar(256)",+ "primaryKey": false,+ "notNull": true+ },+ "key_hash": {+ "name": "key_hash",+ "type": "varchar(128)",+ "primaryKey": false,+ "notNull": false+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": true+ },+ "scopes": {+ "name": "scopes",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "last_used_at": {+ "name": "last_used_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "api_keys_user_id_idx": {+ "name": "api_keys_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "api_keys_workspace_id_idx": {+ "name": "api_keys_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "api_keys_user_id_users_id_fk": {+ "name": "api_keys_user_id_users_id_fk",+ "tableFrom": "api_keys",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "api_keys_workspace_id_workspaces_id_fk": {+ "name": "api_keys_workspace_id_workspaces_id_fk",+ "tableFrom": "api_keys",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "api_keys_key_unique": {+ "name": "api_keys_key_unique",+ "nullsNotDistinct": false,+ "columns": ["key"]+ },+ "api_keys_key_hash_unique": {+ "name": "api_keys_key_hash_unique",+ "nullsNotDistinct": false,+ "columns": ["key_hash"]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.async_tasks": {+ "name": "async_tasks",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "error": {+ "name": "error",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "inference_id": {+ "name": "inference_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "duration": {+ "name": "duration",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "parent_id": {+ "name": "parent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "async_tasks_user_id_idx": {+ "name": "async_tasks_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "async_tasks_parent_id_idx": {+ "name": "async_tasks_parent_id_idx",+ "columns": [+ {+ "expression": "parent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "async_tasks_type_status_idx": {+ "name": "async_tasks_type_status_idx",+ "columns": [+ {+ "expression": "type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "async_tasks_inference_id_idx": {+ "name": "async_tasks_inference_id_idx",+ "columns": [+ {+ "expression": "inference_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "async_tasks_metadata_idx": {+ "name": "async_tasks_metadata_idx",+ "columns": [+ {+ "expression": "metadata",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "gin",+ "with": {}+ },+ "async_tasks_workspace_id_idx": {+ "name": "async_tasks_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "async_tasks_user_id_users_id_fk": {+ "name": "async_tasks_user_id_users_id_fk",+ "tableFrom": "async_tasks",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "async_tasks_workspace_id_workspaces_id_fk": {+ "name": "async_tasks_workspace_id_workspaces_id_fk",+ "tableFrom": "async_tasks",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.accounts": {+ "name": "accounts",+ "schema": "",+ "columns": {+ "access_token": {+ "name": "access_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "access_token_expires_at": {+ "name": "access_token_expires_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "account_id": {+ "name": "account_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "id_token": {+ "name": "id_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "password": {+ "name": "password",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "provider_id": {+ "name": "provider_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "refresh_token": {+ "name": "refresh_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "refresh_token_expires_at": {+ "name": "refresh_token_expires_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "scope": {+ "name": "scope",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "account_userId_idx": {+ "name": "account_userId_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "accounts_user_id_users_id_fk": {+ "name": "accounts_user_id_users_id_fk",+ "tableFrom": "accounts",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.passkey": {+ "name": "passkey",+ "schema": "",+ "columns": {+ "aaguid": {+ "name": "aaguid",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "backedUp": {+ "name": "backedUp",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "counter": {+ "name": "counter",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false,+ "default": "now()"+ },+ "credentialID": {+ "name": "credentialID",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "deviceType": {+ "name": "deviceType",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "publicKey": {+ "name": "publicKey",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "transports": {+ "name": "transports",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "userId": {+ "name": "userId",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "passkey_credential_id_unique": {+ "name": "passkey_credential_id_unique",+ "columns": [+ {+ "expression": "credentialID",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "passkey_user_id_idx": {+ "name": "passkey_user_id_idx",+ "columns": [+ {+ "expression": "userId",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "passkey_userId_users_id_fk": {+ "name": "passkey_userId_users_id_fk",+ "tableFrom": "passkey",+ "tableTo": "users",+ "columnsFrom": ["userId"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.auth_sessions": {+ "name": "auth_sessions",+ "schema": "",+ "columns": {+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "impersonated_by": {+ "name": "impersonated_by",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "ip_address": {+ "name": "ip_address",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "token": {+ "name": "token",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "user_agent": {+ "name": "user_agent",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "auth_session_userId_idx": {+ "name": "auth_session_userId_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "auth_sessions_user_id_users_id_fk": {+ "name": "auth_sessions_user_id_users_id_fk",+ "tableFrom": "auth_sessions",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "auth_sessions_token_unique": {+ "name": "auth_sessions_token_unique",+ "nullsNotDistinct": false,+ "columns": ["token"]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.two_factor": {+ "name": "two_factor",+ "schema": "",+ "columns": {+ "backup_codes": {+ "name": "backup_codes",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "secret": {+ "name": "secret",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "two_factor_secret_idx": {+ "name": "two_factor_secret_idx",+ "columns": [+ {+ "expression": "secret",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "two_factor_user_id_idx": {+ "name": "two_factor_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "two_factor_user_id_users_id_fk": {+ "name": "two_factor_user_id_users_id_fk",+ "tableFrom": "two_factor",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.verifications": {+ "name": "verifications",+ "schema": "",+ "columns": {+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "identifier": {+ "name": "identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "value": {+ "name": "value",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "verification_identifier_idx": {+ "name": "verification_identifier_idx",+ "columns": [+ {+ "expression": "identifier",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.chat_groups": {+ "name": "chat_groups",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "avatar": {+ "name": "avatar",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "background_color": {+ "name": "background_color",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "market_identifier": {+ "name": "market_identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "editor_data": {+ "name": "editor_data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "config": {+ "name": "config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "group_id": {+ "name": "group_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "pinned": {+ "name": "pinned",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": false+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'public'"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "chat_groups_client_id_user_id_unique": {+ "name": "chat_groups_client_id_user_id_unique",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "chat_groups_user_id_idx": {+ "name": "chat_groups_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "chat_groups_group_id_idx": {+ "name": "chat_groups_group_id_idx",+ "columns": [+ {+ "expression": "group_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "chat_groups_workspace_id_idx": {+ "name": "chat_groups_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "chat_groups_workspace_visibility_idx": {+ "name": "chat_groups_workspace_visibility_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "chat_groups_user_id_users_id_fk": {+ "name": "chat_groups_user_id_users_id_fk",+ "tableFrom": "chat_groups",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "chat_groups_workspace_id_workspaces_id_fk": {+ "name": "chat_groups_workspace_id_workspaces_id_fk",+ "tableFrom": "chat_groups",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "chat_groups_group_id_session_groups_id_fk": {+ "name": "chat_groups_group_id_session_groups_id_fk",+ "tableFrom": "chat_groups",+ "tableTo": "session_groups",+ "columnsFrom": ["group_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.chat_groups_agents": {+ "name": "chat_groups_agents",+ "schema": "",+ "columns": {+ "chat_group_id": {+ "name": "chat_group_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": true+ },+ "order": {+ "name": "order",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "default": 0+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "default": "'participant'"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "chat_groups_agents_user_id_idx": {+ "name": "chat_groups_agents_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "chat_groups_agents_workspace_id_idx": {+ "name": "chat_groups_agents_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "chat_groups_agents_chat_group_id_chat_groups_id_fk": {+ "name": "chat_groups_agents_chat_group_id_chat_groups_id_fk",+ "tableFrom": "chat_groups_agents",+ "tableTo": "chat_groups",+ "columnsFrom": ["chat_group_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "chat_groups_agents_agent_id_agents_id_fk": {+ "name": "chat_groups_agents_agent_id_agents_id_fk",+ "tableFrom": "chat_groups_agents",+ "tableTo": "agents",+ "columnsFrom": ["agent_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "chat_groups_agents_user_id_users_id_fk": {+ "name": "chat_groups_agents_user_id_users_id_fk",+ "tableFrom": "chat_groups_agents",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "chat_groups_agents_workspace_id_workspaces_id_fk": {+ "name": "chat_groups_agents_workspace_id_workspaces_id_fk",+ "tableFrom": "chat_groups_agents",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "chat_groups_agents_chat_group_id_agent_id_pk": {+ "name": "chat_groups_agents_chat_group_id_agent_id_pk",+ "columns": ["chat_group_id", "agent_id"]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_connector_tools": {+ "name": "user_connector_tools",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "user_connector_id": {+ "name": "user_connector_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "tool_name": {+ "name": "tool_name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "display_name": {+ "name": "display_name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "input_schema": {+ "name": "input_schema",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "output_schema": {+ "name": "output_schema",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "crud_type": {+ "name": "crud_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "render_config": {+ "name": "render_config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "permission": {+ "name": "permission",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "is_work_artifact": {+ "name": "is_work_artifact",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "work_artifact_config": {+ "name": "work_artifact_config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "limit_config": {+ "name": "limit_config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "user_connector_tools_connector_tool_unique": {+ "name": "user_connector_tools_connector_tool_unique",+ "columns": [+ {+ "expression": "user_connector_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "tool_name",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_connector_tools_user_id_idx": {+ "name": "user_connector_tools_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_connector_tools_connector_id_idx": {+ "name": "user_connector_tools_connector_id_idx",+ "columns": [+ {+ "expression": "user_connector_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_connector_tools_workspace_id_idx": {+ "name": "user_connector_tools_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "user_connector_tools_user_connector_id_user_connectors_id_fk": {+ "name": "user_connector_tools_user_connector_id_user_connectors_id_fk",+ "tableFrom": "user_connector_tools",+ "tableTo": "user_connectors",+ "columnsFrom": ["user_connector_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_connector_tools_user_id_users_id_fk": {+ "name": "user_connector_tools_user_id_users_id_fk",+ "tableFrom": "user_connector_tools",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_connector_tools_workspace_id_workspaces_id_fk": {+ "name": "user_connector_tools_workspace_id_workspaces_id_fk",+ "tableFrom": "user_connector_tools",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_connectors": {+ "name": "user_connectors",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "identifier": {+ "name": "identifier",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "source_type": {+ "name": "source_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "mcp_server_url": {+ "name": "mcp_server_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "mcp_connection_type": {+ "name": "mcp_connection_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "mcp_stdio_config": {+ "name": "mcp_stdio_config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "is_enabled": {+ "name": "is_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "oidc_config": {+ "name": "oidc_config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "credentials": {+ "name": "credentials",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "token_expires_at": {+ "name": "token_expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "user_connectors_personal_identifier_idx": {+ "name": "user_connectors_personal_identifier_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "identifier",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"user_connectors\".\"workspace_id\" IS NULL AND \"user_connectors\".\"agent_id\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_connectors_workspace_identifier_idx": {+ "name": "user_connectors_workspace_identifier_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "identifier",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"user_connectors\".\"workspace_id\" IS NOT NULL AND \"user_connectors\".\"agent_id\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_connectors_agent_identifier_idx": {+ "name": "user_connectors_agent_identifier_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "identifier",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"user_connectors\".\"agent_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_connectors_user_id_idx": {+ "name": "user_connectors_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_connectors_token_expires_at_idx": {+ "name": "user_connectors_token_expires_at_idx",+ "columns": [+ {+ "expression": "token_expires_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_connectors_workspace_id_idx": {+ "name": "user_connectors_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_connectors_agent_id_idx": {+ "name": "user_connectors_agent_id_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "user_connectors_user_id_users_id_fk": {+ "name": "user_connectors_user_id_users_id_fk",+ "tableFrom": "user_connectors",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_connectors_workspace_id_workspaces_id_fk": {+ "name": "user_connectors_workspace_id_workspaces_id_fk",+ "tableFrom": "user_connectors",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_connectors_agent_id_agents_id_fk": {+ "name": "user_connectors_agent_id_agents_id_fk",+ "tableFrom": "user_connectors",+ "tableTo": "agents",+ "columnsFrom": ["agent_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_installed_plugins": {+ "name": "user_installed_plugins",+ "schema": "",+ "columns": {+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "identifier": {+ "name": "identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "manifest": {+ "name": "manifest",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "settings": {+ "name": "settings",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "custom_params": {+ "name": "custom_params",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "source": {+ "name": "source",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "user_installed_plugins_workspace_id_idx": {+ "name": "user_installed_plugins_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "user_installed_plugins_user_id_users_id_fk": {+ "name": "user_installed_plugins_user_id_users_id_fk",+ "tableFrom": "user_installed_plugins",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_installed_plugins_workspace_id_workspaces_id_fk": {+ "name": "user_installed_plugins_workspace_id_workspaces_id_fk",+ "tableFrom": "user_installed_plugins",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "user_installed_plugins_user_id_identifier_pk": {+ "name": "user_installed_plugins_user_id_identifier_pk",+ "columns": ["user_id", "identifier"]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.devices": {+ "name": "devices",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'private'"+ },+ "shared_from_device_id": {+ "name": "shared_from_device_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": false+ },+ "device_id": {+ "name": "device_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true+ },+ "identity_source": {+ "name": "identity_source",+ "type": "varchar(20)",+ "primaryKey": false,+ "notNull": true+ },+ "hostname": {+ "name": "hostname",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "platform": {+ "name": "platform",+ "type": "varchar(20)",+ "primaryKey": false,+ "notNull": false+ },+ "friendly_name": {+ "name": "friendly_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "default_cwd": {+ "name": "default_cwd",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "recent_cwds": {+ "name": "recent_cwds",+ "type": "text[]",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'"+ },+ "working_dirs": {+ "name": "working_dirs",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false,+ "default": "'[]'::jsonb"+ },+ "first_seen_at": {+ "name": "first_seen_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "last_seen_at": {+ "name": "last_seen_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "devices_user_id_device_id_unique": {+ "name": "devices_user_id_device_id_unique",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "device_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"devices\".\"workspace_id\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "devices_workspace_id_device_id_unique": {+ "name": "devices_workspace_id_device_id_unique",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "device_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"devices\".\"workspace_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "devices_user_id_idx": {+ "name": "devices_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "devices_workspace_id_idx": {+ "name": "devices_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "devices_workspace_visibility_idx": {+ "name": "devices_workspace_visibility_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "devices_user_id_users_id_fk": {+ "name": "devices_user_id_users_id_fk",+ "tableFrom": "devices",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "devices_workspace_id_workspaces_id_fk": {+ "name": "devices_workspace_id_workspaces_id_fk",+ "tableFrom": "devices",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.document_histories": {+ "name": "document_histories",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "document_id": {+ "name": "document_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "editor_data": {+ "name": "editor_data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "save_source": {+ "name": "save_source",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "saved_at": {+ "name": "saved_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "document_histories_document_id_idx": {+ "name": "document_histories_document_id_idx",+ "columns": [+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "document_histories_user_id_idx": {+ "name": "document_histories_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "document_histories_workspace_id_idx": {+ "name": "document_histories_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "document_histories_saved_at_idx": {+ "name": "document_histories_saved_at_idx",+ "columns": [+ {+ "expression": "saved_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "document_histories_document_id_documents_id_fk": {+ "name": "document_histories_document_id_documents_id_fk",+ "tableFrom": "document_histories",+ "tableTo": "documents",+ "columnsFrom": ["document_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "document_histories_user_id_users_id_fk": {+ "name": "document_histories_user_id_users_id_fk",+ "tableFrom": "document_histories",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "document_histories_workspace_id_workspaces_id_fk": {+ "name": "document_histories_workspace_id_workspaces_id_fk",+ "tableFrom": "document_histories",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.document_shares": {+ "name": "document_shares",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "document_id": {+ "name": "document_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'private'"+ },+ "permission": {+ "name": "permission",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'read'"+ },+ "page_view_count": {+ "name": "page_view_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "document_shares_document_id_unique": {+ "name": "document_shares_document_id_unique",+ "columns": [+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "document_shares_user_id_idx": {+ "name": "document_shares_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "document_shares_workspace_id_idx": {+ "name": "document_shares_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "document_shares_document_id_documents_id_fk": {+ "name": "document_shares_document_id_documents_id_fk",+ "tableFrom": "document_shares",+ "tableTo": "documents",+ "columnsFrom": ["document_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "document_shares_user_id_users_id_fk": {+ "name": "document_shares_user_id_users_id_fk",+ "tableFrom": "document_shares",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "document_shares_workspace_id_workspaces_id_fk": {+ "name": "document_shares_workspace_id_workspaces_id_fk",+ "tableFrom": "document_shares",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.expertise_bindings": {+ "name": "expertise_bindings",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "domain_id": {+ "name": "domain_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "project_id": {+ "name": "project_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "bound_workspace_id": {+ "name": "bound_workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "bound_user_id": {+ "name": "bound_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "contribution_mode": {+ "name": "contribution_mode",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'derive'"+ },+ "added_by_user_id": {+ "name": "added_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "sort_order": {+ "name": "sort_order",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "expertise_bindings_agent_domain_unique": {+ "name": "expertise_bindings_agent_domain_unique",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "domain_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"expertise_bindings\".\"agent_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_bindings_project_domain_unique": {+ "name": "expertise_bindings_project_domain_unique",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "domain_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"expertise_bindings\".\"project_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_bindings_workspace_domain_unique": {+ "name": "expertise_bindings_workspace_domain_unique",+ "columns": [+ {+ "expression": "bound_workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "domain_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"expertise_bindings\".\"bound_workspace_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_bindings_user_domain_unique": {+ "name": "expertise_bindings_user_domain_unique",+ "columns": [+ {+ "expression": "bound_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "domain_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"expertise_bindings\".\"bound_user_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_bindings_domain_idx": {+ "name": "expertise_bindings_domain_idx",+ "columns": [+ {+ "expression": "domain_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_bindings_workspace_id_idx": {+ "name": "expertise_bindings_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "expertise_bindings_domain_id_expertise_domains_id_fk": {+ "name": "expertise_bindings_domain_id_expertise_domains_id_fk",+ "tableFrom": "expertise_bindings",+ "tableTo": "expertise_domains",+ "columnsFrom": ["domain_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "expertise_bindings_agent_id_agents_id_fk": {+ "name": "expertise_bindings_agent_id_agents_id_fk",+ "tableFrom": "expertise_bindings",+ "tableTo": "agents",+ "columnsFrom": ["agent_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "expertise_bindings_project_id_projects_id_fk": {+ "name": "expertise_bindings_project_id_projects_id_fk",+ "tableFrom": "expertise_bindings",+ "tableTo": "projects",+ "columnsFrom": ["project_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "expertise_bindings_bound_workspace_id_workspaces_id_fk": {+ "name": "expertise_bindings_bound_workspace_id_workspaces_id_fk",+ "tableFrom": "expertise_bindings",+ "tableTo": "workspaces",+ "columnsFrom": ["bound_workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "expertise_bindings_bound_user_id_users_id_fk": {+ "name": "expertise_bindings_bound_user_id_users_id_fk",+ "tableFrom": "expertise_bindings",+ "tableTo": "users",+ "columnsFrom": ["bound_user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "expertise_bindings_added_by_user_id_users_id_fk": {+ "name": "expertise_bindings_added_by_user_id_users_id_fk",+ "tableFrom": "expertise_bindings",+ "tableTo": "users",+ "columnsFrom": ["added_by_user_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "expertise_bindings_workspace_id_workspaces_id_fk": {+ "name": "expertise_bindings_workspace_id_workspaces_id_fk",+ "tableFrom": "expertise_bindings",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "expertise_bindings_exactly_one_carrier": {+ "name": "expertise_bindings_exactly_one_carrier",+ "value": "(\"expertise_bindings\".\"agent_id\" IS NOT NULL)::int + (\"expertise_bindings\".\"project_id\" IS NOT NULL)::int + (\"expertise_bindings\".\"bound_workspace_id\" IS NOT NULL)::int + (\"expertise_bindings\".\"bound_user_id\" IS NOT NULL)::int = 1"+ }+ },+ "isRLSEnabled": false+ },+ "public.expertise_domain_snapshots": {+ "name": "expertise_domain_snapshots",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "domain_id": {+ "name": "domain_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "run_id": {+ "name": "run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "run_index": {+ "name": "run_index",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "learned_total": {+ "name": "learned_total",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "retired_total": {+ "name": "retired_total",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "active_count": {+ "name": "active_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "compiled_count": {+ "name": "compiled_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "layer_counts": {+ "name": "layer_counts",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "p_inf": {+ "name": "p_inf",+ "type": "numeric",+ "primaryKey": false,+ "notNull": false+ },+ "tau": {+ "name": "tau",+ "type": "numeric",+ "primaryKey": false,+ "notNull": false+ },+ "maturity": {+ "name": "maturity",+ "type": "numeric",+ "primaryKey": false,+ "notNull": false+ },+ "fit_sample_size": {+ "name": "fit_sample_size",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "fit_r2": {+ "name": "fit_r2",+ "type": "numeric",+ "primaryKey": false,+ "notNull": false+ },+ "fit_confidence": {+ "name": "fit_confidence",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "fit_computed_at": {+ "name": "fit_computed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "tau_pinned": {+ "name": "tau_pinned",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "observed_span": {+ "name": "observed_span",+ "type": "numeric",+ "primaryKey": false,+ "notNull": false+ },+ "plateau_kind": {+ "name": "plateau_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "layer_coverage": {+ "name": "layer_coverage",+ "type": "numeric",+ "primaryKey": false,+ "notNull": false+ },+ "canon_coverage": {+ "name": "canon_coverage",+ "type": "numeric",+ "primaryKey": false,+ "notNull": false+ },+ "active_rate": {+ "name": "active_rate",+ "type": "numeric",+ "primaryKey": false,+ "notNull": false+ },+ "captured_at": {+ "name": "captured_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "expertise_domain_snapshots_domain_run_index_unique": {+ "name": "expertise_domain_snapshots_domain_run_index_unique",+ "columns": [+ {+ "expression": "domain_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "run_index",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_domain_snapshots_domain_captured_idx": {+ "name": "expertise_domain_snapshots_domain_captured_idx",+ "columns": [+ {+ "expression": "domain_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "captured_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_domain_snapshots_pending_fit_idx": {+ "name": "expertise_domain_snapshots_pending_fit_idx",+ "columns": [+ {+ "expression": "domain_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"expertise_domain_snapshots\".\"fit_computed_at\" is null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "expertise_domain_snapshots_domain_id_expertise_domains_id_fk": {+ "name": "expertise_domain_snapshots_domain_id_expertise_domains_id_fk",+ "tableFrom": "expertise_domain_snapshots",+ "tableTo": "expertise_domains",+ "columnsFrom": ["domain_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "expertise_domain_snapshots_run_id_expertise_runs_id_fk": {+ "name": "expertise_domain_snapshots_run_id_expertise_runs_id_fk",+ "tableFrom": "expertise_domain_snapshots",+ "tableTo": "expertise_runs",+ "columnsFrom": ["run_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "expertise_domain_snapshots_run_domain_fk": {+ "name": "expertise_domain_snapshots_run_domain_fk",+ "tableFrom": "expertise_domain_snapshots",+ "tableTo": "expertise_runs",+ "columnsFrom": ["run_id", "domain_id"],+ "columnsTo": ["id", "domain_id"],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.expertise_domains": {+ "name": "expertise_domains",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "slug": {+ "name": "slug",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'private'"+ },+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'user'"+ },+ "parent_domain_id": {+ "name": "parent_domain_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "domain_filter": {+ "name": "domain_filter",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "out_of_scope": {+ "name": "out_of_scope",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "layers": {+ "name": "layers",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "layer_source": {+ "name": "layer_source",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'invented'"+ },+ "canon_entries": {+ "name": "canon_entries",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "canon_document_id": {+ "name": "canon_document_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "flow": {+ "name": "flow",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "evidence_spec": {+ "name": "evidence_spec",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "lesson_base_document_id": {+ "name": "lesson_base_document_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "anchor_candidates": {+ "name": "anchor_candidates",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "anchor_chosen_at": {+ "name": "anchor_chosen_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "anchor_chosen_by_user_id": {+ "name": "anchor_chosen_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "seed_state": {+ "name": "seed_state",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'seeding'"+ },+ "seed_run_id": {+ "name": "seed_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "expertise_domains_slug_user_unique": {+ "name": "expertise_domains_slug_user_unique",+ "columns": [+ {+ "expression": "slug",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"expertise_domains\".\"workspace_id\" is null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_domains_slug_workspace_unique": {+ "name": "expertise_domains_slug_workspace_unique",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "slug",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"expertise_domains\".\"workspace_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_domains_user_id_idx": {+ "name": "expertise_domains_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_domains_workspace_visibility_idx": {+ "name": "expertise_domains_workspace_visibility_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_domains_parent_idx": {+ "name": "expertise_domains_parent_idx",+ "columns": [+ {+ "expression": "parent_domain_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "expertise_domains_user_id_users_id_fk": {+ "name": "expertise_domains_user_id_users_id_fk",+ "tableFrom": "expertise_domains",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "expertise_domains_workspace_id_workspaces_id_fk": {+ "name": "expertise_domains_workspace_id_workspaces_id_fk",+ "tableFrom": "expertise_domains",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "expertise_domains_parent_domain_id_expertise_domains_id_fk": {+ "name": "expertise_domains_parent_domain_id_expertise_domains_id_fk",+ "tableFrom": "expertise_domains",+ "tableTo": "expertise_domains",+ "columnsFrom": ["parent_domain_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "expertise_domains_canon_document_id_documents_id_fk": {+ "name": "expertise_domains_canon_document_id_documents_id_fk",+ "tableFrom": "expertise_domains",+ "tableTo": "documents",+ "columnsFrom": ["canon_document_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "expertise_domains_lesson_base_document_id_documents_id_fk": {+ "name": "expertise_domains_lesson_base_document_id_documents_id_fk",+ "tableFrom": "expertise_domains",+ "tableTo": "documents",+ "columnsFrom": ["lesson_base_document_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "expertise_domains_anchor_chosen_by_user_id_users_id_fk": {+ "name": "expertise_domains_anchor_chosen_by_user_id_users_id_fk",+ "tableFrom": "expertise_domains",+ "tableTo": "users",+ "columnsFrom": ["anchor_chosen_by_user_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.expertise_hits": {+ "name": "expertise_hits",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "run_id": {+ "name": "run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "lesson_id": {+ "name": "lesson_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "domain_id": {+ "name": "domain_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "outcome": {+ "name": "outcome",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "where": {+ "name": "where",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "note": {+ "name": "note",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "example": {+ "name": "example",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "severity": {+ "name": "severity",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "evidence_id": {+ "name": "evidence_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "operation_id": {+ "name": "operation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_decision": {+ "name": "user_decision",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_decision_at": {+ "name": "user_decision_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "expertise_hits_lesson_created_idx": {+ "name": "expertise_hits_lesson_created_idx",+ "columns": [+ {+ "expression": "lesson_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_hits_run_idx": {+ "name": "expertise_hits_run_idx",+ "columns": [+ {+ "expression": "run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_hits_domain_outcome_idx": {+ "name": "expertise_hits_domain_outcome_idx",+ "columns": [+ {+ "expression": "domain_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "outcome",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_hits_operation_idx": {+ "name": "expertise_hits_operation_idx",+ "columns": [+ {+ "expression": "operation_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "expertise_hits_domain_id_expertise_domains_id_fk": {+ "name": "expertise_hits_domain_id_expertise_domains_id_fk",+ "tableFrom": "expertise_hits",+ "tableTo": "expertise_domains",+ "columnsFrom": ["domain_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "expertise_hits_evidence_id_verify_evidence_id_fk": {+ "name": "expertise_hits_evidence_id_verify_evidence_id_fk",+ "tableFrom": "expertise_hits",+ "tableTo": "verify_evidence",+ "columnsFrom": ["evidence_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "expertise_hits_operation_id_agent_operations_id_fk": {+ "name": "expertise_hits_operation_id_agent_operations_id_fk",+ "tableFrom": "expertise_hits",+ "tableTo": "agent_operations",+ "columnsFrom": ["operation_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "expertise_hits_run_domain_fk": {+ "name": "expertise_hits_run_domain_fk",+ "tableFrom": "expertise_hits",+ "tableTo": "expertise_runs",+ "columnsFrom": ["run_id", "domain_id"],+ "columnsTo": ["id", "domain_id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "expertise_hits_lesson_domain_fk": {+ "name": "expertise_hits_lesson_domain_fk",+ "tableFrom": "expertise_hits",+ "tableTo": "expertise_lessons",+ "columnsFrom": ["lesson_id", "domain_id"],+ "columnsTo": ["id", "domain_id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.expertise_insights": {+ "name": "expertise_insights",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "domain_id": {+ "name": "domain_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "kind": {+ "name": "kind",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "headline": {+ "name": "headline",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "body": {+ "name": "body",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "action_label": {+ "name": "action_label",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "action_target": {+ "name": "action_target",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "evidence": {+ "name": "evidence",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "confidence": {+ "name": "confidence",+ "type": "real",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'active'"+ },+ "dismiss_reason": {+ "name": "dismiss_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "stale_after_run_index": {+ "name": "stale_after_run_index",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "generated_by_operation_id": {+ "name": "generated_by_operation_id",+ "type": "text",+ "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": {+ "expertise_insights_domain_status_idx": {+ "name": "expertise_insights_domain_status_idx",+ "columns": [+ {+ "expression": "domain_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_insights_user_status_idx": {+ "name": "expertise_insights_user_status_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_insights_workspace_idx": {+ "name": "expertise_insights_workspace_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "expertise_insights_domain_id_expertise_domains_id_fk": {+ "name": "expertise_insights_domain_id_expertise_domains_id_fk",+ "tableFrom": "expertise_insights",+ "tableTo": "expertise_domains",+ "columnsFrom": ["domain_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "expertise_insights_user_id_users_id_fk": {+ "name": "expertise_insights_user_id_users_id_fk",+ "tableFrom": "expertise_insights",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "expertise_insights_workspace_id_workspaces_id_fk": {+ "name": "expertise_insights_workspace_id_workspaces_id_fk",+ "tableFrom": "expertise_insights",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "expertise_insights_generated_by_operation_id_agent_operations_id_fk": {+ "name": "expertise_insights_generated_by_operation_id_agent_operations_id_fk",+ "tableFrom": "expertise_insights",+ "tableTo": "agent_operations",+ "columnsFrom": ["generated_by_operation_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.expertise_lesson_revisions": {+ "name": "expertise_lesson_revisions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "lesson_id": {+ "name": "lesson_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "revision": {+ "name": "revision",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "sections": {+ "name": "sections",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "feedback": {+ "name": "feedback",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "changed_by": {+ "name": "changed_by",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'user-feedback'"+ },+ "prev_title": {+ "name": "prev_title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "changed_by_user_id": {+ "name": "changed_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "source_run_id": {+ "name": "source_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "operation_id": {+ "name": "operation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "expertise_lesson_revisions_lesson_revision_unique": {+ "name": "expertise_lesson_revisions_lesson_revision_unique",+ "columns": [+ {+ "expression": "lesson_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "revision",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_lesson_revisions_lesson_idx": {+ "name": "expertise_lesson_revisions_lesson_idx",+ "columns": [+ {+ "expression": "lesson_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "expertise_lesson_revisions_lesson_id_expertise_lessons_id_fk": {+ "name": "expertise_lesson_revisions_lesson_id_expertise_lessons_id_fk",+ "tableFrom": "expertise_lesson_revisions",+ "tableTo": "expertise_lessons",+ "columnsFrom": ["lesson_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "expertise_lesson_revisions_changed_by_user_id_users_id_fk": {+ "name": "expertise_lesson_revisions_changed_by_user_id_users_id_fk",+ "tableFrom": "expertise_lesson_revisions",+ "tableTo": "users",+ "columnsFrom": ["changed_by_user_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "expertise_lesson_revisions_operation_id_agent_operations_id_fk": {+ "name": "expertise_lesson_revisions_operation_id_agent_operations_id_fk",+ "tableFrom": "expertise_lesson_revisions",+ "tableTo": "agent_operations",+ "columnsFrom": ["operation_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.expertise_lessons": {+ "name": "expertise_lessons",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "domain_id": {+ "name": "domain_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "code": {+ "name": "code",+ "type": "varchar(20)",+ "primaryKey": false,+ "notNull": true+ },+ "polarity": {+ "name": "polarity",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "sections": {+ "name": "sections",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "layer": {+ "name": "layer",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "tags": {+ "name": "tags",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "canon_anchor": {+ "name": "canon_anchor",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "origin_run_id": {+ "name": "origin_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "origin_hit_id": {+ "name": "origin_hit_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'active'"+ },+ "rejected_reason": {+ "name": "rejected_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "salvaged_from_id": {+ "name": "salvaged_from_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "retired_at": {+ "name": "retired_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "compilability": {+ "name": "compilability",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'compilable'"+ },+ "compiled_criterion_id": {+ "name": "compiled_criterion_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "hit_count": {+ "name": "hit_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "hit_run_count": {+ "name": "hit_run_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "false_positive_count": {+ "name": "false_positive_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "last_hit_at": {+ "name": "last_hit_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "last_hit_run_id": {+ "name": "last_hit_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "generalized_from_ids": {+ "name": "generalized_from_ids",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "specificity": {+ "name": "specificity",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "example_count": {+ "name": "example_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "current_revision": {+ "name": "current_revision",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 1+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "expertise_lessons_domain_code_unique": {+ "name": "expertise_lessons_domain_code_unique",+ "columns": [+ {+ "expression": "domain_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "code",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_lessons_domain_status_hits_idx": {+ "name": "expertise_lessons_domain_status_hits_idx",+ "columns": [+ {+ "expression": "domain_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "hit_count",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_lessons_domain_layer_idx": {+ "name": "expertise_lessons_domain_layer_idx",+ "columns": [+ {+ "expression": "domain_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "layer",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_lessons_compiled_criterion_idx": {+ "name": "expertise_lessons_compiled_criterion_idx",+ "columns": [+ {+ "expression": "compiled_criterion_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "expertise_lessons_domain_id_expertise_domains_id_fk": {+ "name": "expertise_lessons_domain_id_expertise_domains_id_fk",+ "tableFrom": "expertise_lessons",+ "tableTo": "expertise_domains",+ "columnsFrom": ["domain_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "expertise_lessons_created_by_user_id_users_id_fk": {+ "name": "expertise_lessons_created_by_user_id_users_id_fk",+ "tableFrom": "expertise_lessons",+ "tableTo": "users",+ "columnsFrom": ["created_by_user_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "expertise_lessons_salvaged_from_id_expertise_lessons_id_fk": {+ "name": "expertise_lessons_salvaged_from_id_expertise_lessons_id_fk",+ "tableFrom": "expertise_lessons",+ "tableTo": "expertise_lessons",+ "columnsFrom": ["salvaged_from_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "expertise_lessons_compiled_criterion_id_verify_criteria_id_fk": {+ "name": "expertise_lessons_compiled_criterion_id_verify_criteria_id_fk",+ "tableFrom": "expertise_lessons",+ "tableTo": "verify_criteria",+ "columnsFrom": ["compiled_criterion_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "expertise_lessons_id_domain_unique": {+ "name": "expertise_lessons_id_domain_unique",+ "nullsNotDistinct": false,+ "columns": ["id", "domain_id"]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.expertise_runs": {+ "name": "expertise_runs",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "domain_id": {+ "name": "domain_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "run_index": {+ "name": "run_index",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "is_seed_run": {+ "name": "is_seed_run",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "actor_type": {+ "name": "actor_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "actor_id": {+ "name": "actor_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "subject_type": {+ "name": "subject_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "subject_id": {+ "name": "subject_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "window_start": {+ "name": "window_start",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "window_end": {+ "name": "window_end",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "reflection_key": {+ "name": "reflection_key",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "had_human_in_loop": {+ "name": "had_human_in_loop",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "instance_count": {+ "name": "instance_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "refine_count": {+ "name": "refine_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "new_count": {+ "name": "new_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "started_at": {+ "name": "started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "completed_at": {+ "name": "completed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "expertise_runs_domain_run_index_unique": {+ "name": "expertise_runs_domain_run_index_unique",+ "columns": [+ {+ "expression": "domain_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "run_index",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_runs_domain_reflection_key_unique": {+ "name": "expertise_runs_domain_reflection_key_unique",+ "columns": [+ {+ "expression": "domain_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "reflection_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"expertise_runs\".\"reflection_key\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_runs_domain_started_idx": {+ "name": "expertise_runs_domain_started_idx",+ "columns": [+ {+ "expression": "domain_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "started_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_runs_actor_idx": {+ "name": "expertise_runs_actor_idx",+ "columns": [+ {+ "expression": "actor_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "actor_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "expertise_runs_subject_idx": {+ "name": "expertise_runs_subject_idx",+ "columns": [+ {+ "expression": "subject_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "subject_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "expertise_runs_domain_id_expertise_domains_id_fk": {+ "name": "expertise_runs_domain_id_expertise_domains_id_fk",+ "tableFrom": "expertise_runs",+ "tableTo": "expertise_domains",+ "columnsFrom": ["domain_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "expertise_runs_user_id_users_id_fk": {+ "name": "expertise_runs_user_id_users_id_fk",+ "tableFrom": "expertise_runs",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "expertise_runs_workspace_id_workspaces_id_fk": {+ "name": "expertise_runs_workspace_id_workspaces_id_fk",+ "tableFrom": "expertise_runs",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "expertise_runs_id_domain_unique": {+ "name": "expertise_runs_id_domain_unique",+ "nullsNotDistinct": false,+ "columns": ["id", "domain_id"]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.documents": {+ "name": "documents",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "file_type": {+ "name": "file_type",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "filename": {+ "name": "filename",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "total_char_count": {+ "name": "total_char_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "total_line_count": {+ "name": "total_line_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "pages": {+ "name": "pages",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "source_type": {+ "name": "source_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "file_id": {+ "name": "file_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "knowledge_base_id": {+ "name": "knowledge_base_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "parent_id": {+ "name": "parent_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "editor_data": {+ "name": "editor_data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "slug": {+ "name": "slug",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'public'"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "documents_source_idx": {+ "name": "documents_source_idx",+ "columns": [+ {+ "expression": "source",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "documents_file_type_idx": {+ "name": "documents_file_type_idx",+ "columns": [+ {+ "expression": "file_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "documents_source_type_idx": {+ "name": "documents_source_type_idx",+ "columns": [+ {+ "expression": "source_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "documents_user_id_idx": {+ "name": "documents_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "documents_file_id_idx": {+ "name": "documents_file_id_idx",+ "columns": [+ {+ "expression": "file_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "documents_parent_id_idx": {+ "name": "documents_parent_id_idx",+ "columns": [+ {+ "expression": "parent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "documents_knowledge_base_id_idx": {+ "name": "documents_knowledge_base_id_idx",+ "columns": [+ {+ "expression": "knowledge_base_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "documents_client_id_user_id_unique": {+ "name": "documents_client_id_user_id_unique",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "documents_slug_user_id_unique": {+ "name": "documents_slug_user_id_unique",+ "columns": [+ {+ "expression": "slug",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"documents\".\"workspace_id\" IS NULL AND \"documents\".\"slug\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "documents_workspace_id_idx": {+ "name": "documents_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "documents_workspace_visibility_idx": {+ "name": "documents_workspace_visibility_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "documents_slug_workspace_id_unique": {+ "name": "documents_slug_workspace_id_unique",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "slug",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"documents\".\"workspace_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "documents_file_id_files_id_fk": {+ "name": "documents_file_id_files_id_fk",+ "tableFrom": "documents",+ "tableTo": "files",+ "columnsFrom": ["file_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "documents_knowledge_base_id_knowledge_bases_id_fk": {+ "name": "documents_knowledge_base_id_knowledge_bases_id_fk",+ "tableFrom": "documents",+ "tableTo": "knowledge_bases",+ "columnsFrom": ["knowledge_base_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "documents_parent_id_documents_id_fk": {+ "name": "documents_parent_id_documents_id_fk",+ "tableFrom": "documents",+ "tableTo": "documents",+ "columnsFrom": ["parent_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "documents_user_id_users_id_fk": {+ "name": "documents_user_id_users_id_fk",+ "tableFrom": "documents",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "documents_workspace_id_workspaces_id_fk": {+ "name": "documents_workspace_id_workspaces_id_fk",+ "tableFrom": "documents",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.files": {+ "name": "files",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "file_type": {+ "name": "file_type",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "file_hash": {+ "name": "file_hash",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "size": {+ "name": "size",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "url": {+ "name": "url",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "parent_id": {+ "name": "parent_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "chunk_task_id": {+ "name": "chunk_task_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "embedding_task_id": {+ "name": "embedding_task_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'public'"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "file_hash_idx": {+ "name": "file_hash_idx",+ "columns": [+ {+ "expression": "file_hash",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "files_user_id_idx": {+ "name": "files_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "files_parent_id_idx": {+ "name": "files_parent_id_idx",+ "columns": [+ {+ "expression": "parent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "files_chunk_task_id_idx": {+ "name": "files_chunk_task_id_idx",+ "columns": [+ {+ "expression": "chunk_task_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "files_embedding_task_id_idx": {+ "name": "files_embedding_task_id_idx",+ "columns": [+ {+ "expression": "embedding_task_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "files_client_id_user_id_unique": {+ "name": "files_client_id_user_id_unique",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "files_workspace_id_idx": {+ "name": "files_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "files_workspace_visibility_idx": {+ "name": "files_workspace_visibility_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "files_user_id_users_id_fk": {+ "name": "files_user_id_users_id_fk",+ "tableFrom": "files",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "files_file_hash_global_files_hash_id_fk": {+ "name": "files_file_hash_global_files_hash_id_fk",+ "tableFrom": "files",+ "tableTo": "global_files",+ "columnsFrom": ["file_hash"],+ "columnsTo": ["hash_id"],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "files_parent_id_documents_id_fk": {+ "name": "files_parent_id_documents_id_fk",+ "tableFrom": "files",+ "tableTo": "documents",+ "columnsFrom": ["parent_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "files_chunk_task_id_async_tasks_id_fk": {+ "name": "files_chunk_task_id_async_tasks_id_fk",+ "tableFrom": "files",+ "tableTo": "async_tasks",+ "columnsFrom": ["chunk_task_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "files_embedding_task_id_async_tasks_id_fk": {+ "name": "files_embedding_task_id_async_tasks_id_fk",+ "tableFrom": "files",+ "tableTo": "async_tasks",+ "columnsFrom": ["embedding_task_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "files_workspace_id_workspaces_id_fk": {+ "name": "files_workspace_id_workspaces_id_fk",+ "tableFrom": "files",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.global_files": {+ "name": "global_files",+ "schema": "",+ "columns": {+ "hash_id": {+ "name": "hash_id",+ "type": "varchar(64)",+ "primaryKey": true,+ "notNull": true+ },+ "file_type": {+ "name": "file_type",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "size": {+ "name": "size",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "url": {+ "name": "url",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "creator": {+ "name": "creator",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "global_files_creator_idx": {+ "name": "global_files_creator_idx",+ "columns": [+ {+ "expression": "creator",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "global_files_creator_users_id_fk": {+ "name": "global_files_creator_users_id_fk",+ "tableFrom": "global_files",+ "tableTo": "users",+ "columnsFrom": ["creator"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.knowledge_base_files": {+ "name": "knowledge_base_files",+ "schema": "",+ "columns": {+ "knowledge_base_id": {+ "name": "knowledge_base_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "file_id": {+ "name": "file_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "knowledge_base_files_kb_id_idx": {+ "name": "knowledge_base_files_kb_id_idx",+ "columns": [+ {+ "expression": "knowledge_base_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "knowledge_base_files_user_id_idx": {+ "name": "knowledge_base_files_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "knowledge_base_files_file_id_idx": {+ "name": "knowledge_base_files_file_id_idx",+ "columns": [+ {+ "expression": "file_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "knowledge_base_files_workspace_id_idx": {+ "name": "knowledge_base_files_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "knowledge_base_files_knowledge_base_id_knowledge_bases_id_fk": {+ "name": "knowledge_base_files_knowledge_base_id_knowledge_bases_id_fk",+ "tableFrom": "knowledge_base_files",+ "tableTo": "knowledge_bases",+ "columnsFrom": ["knowledge_base_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "knowledge_base_files_file_id_files_id_fk": {+ "name": "knowledge_base_files_file_id_files_id_fk",+ "tableFrom": "knowledge_base_files",+ "tableTo": "files",+ "columnsFrom": ["file_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "knowledge_base_files_user_id_users_id_fk": {+ "name": "knowledge_base_files_user_id_users_id_fk",+ "tableFrom": "knowledge_base_files",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "knowledge_base_files_workspace_id_workspaces_id_fk": {+ "name": "knowledge_base_files_workspace_id_workspaces_id_fk",+ "tableFrom": "knowledge_base_files",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "knowledge_base_files_knowledge_base_id_file_id_pk": {+ "name": "knowledge_base_files_knowledge_base_id_file_id_pk",+ "columns": ["knowledge_base_id", "file_id"]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.knowledge_bases": {+ "name": "knowledge_bases",+ "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+ },+ "avatar": {+ "name": "avatar",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "is_public": {+ "name": "is_public",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": false+ },+ "settings": {+ "name": "settings",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'public'"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "knowledge_bases_client_id_user_id_unique": {+ "name": "knowledge_bases_client_id_user_id_unique",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "knowledge_bases_user_id_idx": {+ "name": "knowledge_bases_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "knowledge_bases_workspace_id_idx": {+ "name": "knowledge_bases_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "knowledge_bases_workspace_visibility_idx": {+ "name": "knowledge_bases_workspace_visibility_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "knowledge_bases_user_id_users_id_fk": {+ "name": "knowledge_bases_user_id_users_id_fk",+ "tableFrom": "knowledge_bases",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "knowledge_bases_workspace_id_workspaces_id_fk": {+ "name": "knowledge_bases_workspace_id_workspaces_id_fk",+ "tableFrom": "knowledge_bases",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.generation_batches": {+ "name": "generation_batches",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "generation_topic_id": {+ "name": "generation_topic_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "model": {+ "name": "model",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "prompt": {+ "name": "prompt",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "width": {+ "name": "width",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "height": {+ "name": "height",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "ratio": {+ "name": "ratio",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": false+ },+ "config": {+ "name": "config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "generation_batches_user_id_idx": {+ "name": "generation_batches_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "generation_batches_topic_id_idx": {+ "name": "generation_batches_topic_id_idx",+ "columns": [+ {+ "expression": "generation_topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "generation_batches_workspace_id_idx": {+ "name": "generation_batches_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "generation_batches_user_id_users_id_fk": {+ "name": "generation_batches_user_id_users_id_fk",+ "tableFrom": "generation_batches",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "generation_batches_workspace_id_workspaces_id_fk": {+ "name": "generation_batches_workspace_id_workspaces_id_fk",+ "tableFrom": "generation_batches",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "generation_batches_generation_topic_id_generation_topics_id_fk": {+ "name": "generation_batches_generation_topic_id_generation_topics_id_fk",+ "tableFrom": "generation_batches",+ "tableTo": "generation_topics",+ "columnsFrom": ["generation_topic_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.generation_topics": {+ "name": "generation_topics",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "cover_url": {+ "name": "cover_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "varchar(32)",+ "primaryKey": false,+ "notNull": true,+ "default": "'image'"+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'public'"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "generation_topics_user_id_idx": {+ "name": "generation_topics_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "generation_topics_workspace_id_idx": {+ "name": "generation_topics_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "generation_topics_workspace_visibility_idx": {+ "name": "generation_topics_workspace_visibility_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "generation_topics_user_id_users_id_fk": {+ "name": "generation_topics_user_id_users_id_fk",+ "tableFrom": "generation_topics",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "generation_topics_workspace_id_workspaces_id_fk": {+ "name": "generation_topics_workspace_id_workspaces_id_fk",+ "tableFrom": "generation_topics",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.generations": {+ "name": "generations",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "generation_batch_id": {+ "name": "generation_batch_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true+ },+ "async_task_id": {+ "name": "async_task_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "file_id": {+ "name": "file_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "seed": {+ "name": "seed",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "asset": {+ "name": "asset",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "generations_user_id_idx": {+ "name": "generations_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "generations_batch_id_idx": {+ "name": "generations_batch_id_idx",+ "columns": [+ {+ "expression": "generation_batch_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "generations_file_id_idx": {+ "name": "generations_file_id_idx",+ "columns": [+ {+ "expression": "file_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "generations_workspace_id_idx": {+ "name": "generations_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "generations_user_id_users_id_fk": {+ "name": "generations_user_id_users_id_fk",+ "tableFrom": "generations",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "generations_workspace_id_workspaces_id_fk": {+ "name": "generations_workspace_id_workspaces_id_fk",+ "tableFrom": "generations",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "generations_generation_batch_id_generation_batches_id_fk": {+ "name": "generations_generation_batch_id_generation_batches_id_fk",+ "tableFrom": "generations",+ "tableTo": "generation_batches",+ "columnsFrom": ["generation_batch_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "generations_async_task_id_async_tasks_id_fk": {+ "name": "generations_async_task_id_async_tasks_id_fk",+ "tableFrom": "generations",+ "tableTo": "async_tasks",+ "columnsFrom": ["async_task_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "generations_file_id_files_id_fk": {+ "name": "generations_file_id_files_id_fk",+ "tableFrom": "generations",+ "tableTo": "files",+ "columnsFrom": ["file_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.goals": {+ "name": "goals",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "project_id": {+ "name": "project_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "requirement": {+ "name": "requirement",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "config": {+ "name": "config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "max_rounds": {+ "name": "max_rounds",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "max_total_cost": {+ "name": "max_total_cost",+ "type": "numeric(20, 6)",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'planning'"+ },+ "subject_type": {+ "name": "subject_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "subject_id": {+ "name": "subject_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "started_at": {+ "name": "started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "completed_at": {+ "name": "completed_at",+ "type": "timestamp with time zone",+ "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": {+ "goals_user_id_idx": {+ "name": "goals_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "goals_workspace_id_idx": {+ "name": "goals_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "goals_agent_id_idx": {+ "name": "goals_agent_id_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "goals_project_id_idx": {+ "name": "goals_project_id_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "goals_status_idx": {+ "name": "goals_status_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "goals_subject_idx": {+ "name": "goals_subject_idx",+ "columns": [+ {+ "expression": "subject_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "subject_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "goals_user_id_users_id_fk": {+ "name": "goals_user_id_users_id_fk",+ "tableFrom": "goals",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "goals_workspace_id_workspaces_id_fk": {+ "name": "goals_workspace_id_workspaces_id_fk",+ "tableFrom": "goals",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "goals_agent_id_agents_id_fk": {+ "name": "goals_agent_id_agents_id_fk",+ "tableFrom": "goals",+ "tableTo": "agents",+ "columnsFrom": ["agent_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "goals_project_id_projects_id_fk": {+ "name": "goals_project_id_projects_id_fk",+ "tableFrom": "goals",+ "tableTo": "projects",+ "columnsFrom": ["project_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.goal_edges": {+ "name": "goal_edges",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "goal_id": {+ "name": "goal_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source_node_id": {+ "name": "source_node_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "target_node_id": {+ "name": "target_node_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "goal_edges_source_target_kind_unique": {+ "name": "goal_edges_source_target_kind_unique",+ "columns": [+ {+ "expression": "source_node_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "target_node_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "goal_edges_goal_id_idx": {+ "name": "goal_edges_goal_id_idx",+ "columns": [+ {+ "expression": "goal_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "goal_edges_target_node_id_idx": {+ "name": "goal_edges_target_node_id_idx",+ "columns": [+ {+ "expression": "target_node_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "goal_edges_goal_id_goals_id_fk": {+ "name": "goal_edges_goal_id_goals_id_fk",+ "tableFrom": "goal_edges",+ "tableTo": "goals",+ "columnsFrom": ["goal_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "goal_edges_goal_source_node_fk": {+ "name": "goal_edges_goal_source_node_fk",+ "tableFrom": "goal_edges",+ "tableTo": "goal_nodes",+ "columnsFrom": ["goal_id", "source_node_id"],+ "columnsTo": ["goal_id", "id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "goal_edges_goal_target_node_fk": {+ "name": "goal_edges_goal_target_node_fk",+ "tableFrom": "goal_edges",+ "tableTo": "goal_nodes",+ "columnsFrom": ["goal_id", "target_node_id"],+ "columnsTo": ["goal_id", "id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "goal_edges_distinct_nodes": {+ "name": "goal_edges_distinct_nodes",+ "value": "\"goal_edges\".\"source_node_id\" <> \"goal_edges\".\"target_node_id\""+ }+ },+ "isRLSEnabled": false+ },+ "public.goal_events": {+ "name": "goal_events",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "goal_id": {+ "name": "goal_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "event_type": {+ "name": "event_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "entity_type": {+ "name": "entity_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "entity_id": {+ "name": "entity_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "actor_type": {+ "name": "actor_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "actor_id": {+ "name": "actor_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "task_id": {+ "name": "task_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "operation_id": {+ "name": "operation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "reason": {+ "name": "reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "goal_events_goal_id_created_at_idx": {+ "name": "goal_events_goal_id_created_at_idx",+ "columns": [+ {+ "expression": "goal_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "goal_events_entity_idx": {+ "name": "goal_events_entity_idx",+ "columns": [+ {+ "expression": "entity_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "entity_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "goal_events_task_id_idx": {+ "name": "goal_events_task_id_idx",+ "columns": [+ {+ "expression": "task_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "goal_events_operation_id_idx": {+ "name": "goal_events_operation_id_idx",+ "columns": [+ {+ "expression": "operation_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "goal_events_goal_id_goals_id_fk": {+ "name": "goal_events_goal_id_goals_id_fk",+ "tableFrom": "goal_events",+ "tableTo": "goals",+ "columnsFrom": ["goal_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "goal_events_task_id_tasks_id_fk": {+ "name": "goal_events_task_id_tasks_id_fk",+ "tableFrom": "goal_events",+ "tableTo": "tasks",+ "columnsFrom": ["task_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.goal_node_decisions": {+ "name": "goal_node_decisions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "node_id": {+ "name": "node_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "authority": {+ "name": "authority",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "question": {+ "name": "question",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "options": {+ "name": "options",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "recommended_option_id": {+ "name": "recommended_option_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "requested_user_id": {+ "name": "requested_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "requested_project_role": {+ "name": "requested_project_role",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "resolved_option_id": {+ "name": "resolved_option_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "resolution": {+ "name": "resolution",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "resolved_by_user_id": {+ "name": "resolved_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "resolved_by_agent_id": {+ "name": "resolved_by_agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "resolved_at": {+ "name": "resolved_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "canceled_at": {+ "name": "canceled_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "goal_node_decisions_node_id_unique": {+ "name": "goal_node_decisions_node_id_unique",+ "columns": [+ {+ "expression": "node_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "goal_node_decisions_status_idx": {+ "name": "goal_node_decisions_status_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "goal_node_decisions_requested_user_id_status_idx": {+ "name": "goal_node_decisions_requested_user_id_status_idx",+ "columns": [+ {+ "expression": "requested_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "goal_node_decisions_node_id_goal_nodes_id_fk": {+ "name": "goal_node_decisions_node_id_goal_nodes_id_fk",+ "tableFrom": "goal_node_decisions",+ "tableTo": "goal_nodes",+ "columnsFrom": ["node_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "goal_node_decisions_requested_user_id_users_id_fk": {+ "name": "goal_node_decisions_requested_user_id_users_id_fk",+ "tableFrom": "goal_node_decisions",+ "tableTo": "users",+ "columnsFrom": ["requested_user_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "goal_node_decisions_resolved_by_user_id_users_id_fk": {+ "name": "goal_node_decisions_resolved_by_user_id_users_id_fk",+ "tableFrom": "goal_node_decisions",+ "tableTo": "users",+ "columnsFrom": ["resolved_by_user_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "goal_node_decisions_resolved_by_agent_id_agents_id_fk": {+ "name": "goal_node_decisions_resolved_by_agent_id_agents_id_fk",+ "tableFrom": "goal_node_decisions",+ "tableTo": "agents",+ "columnsFrom": ["resolved_by_agent_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.goal_node_work_versions": {+ "name": "goal_node_work_versions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "node_id": {+ "name": "node_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "work_version_id": {+ "name": "work_version_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "relation": {+ "name": "relation",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "goal_node_work_versions_node_version_relation_unique": {+ "name": "goal_node_work_versions_node_version_relation_unique",+ "columns": [+ {+ "expression": "node_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "work_version_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "relation",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "goal_node_work_versions_work_version_id_idx": {+ "name": "goal_node_work_versions_work_version_id_idx",+ "columns": [+ {+ "expression": "work_version_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "goal_node_work_versions_node_id_goal_nodes_id_fk": {+ "name": "goal_node_work_versions_node_id_goal_nodes_id_fk",+ "tableFrom": "goal_node_work_versions",+ "tableTo": "goal_nodes",+ "columnsFrom": ["node_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "goal_node_work_versions_work_version_id_work_versions_id_fk": {+ "name": "goal_node_work_versions_work_version_id_work_versions_id_fk",+ "tableFrom": "goal_node_work_versions",+ "tableTo": "work_versions",+ "columnsFrom": ["work_version_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.goal_nodes": {+ "name": "goal_nodes",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "goal_id": {+ "name": "goal_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'proposed'"+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "task_id": {+ "name": "task_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "priority": {+ "name": "priority",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "confidence": {+ "name": "confidence",+ "type": "numeric(4, 3)",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "resolved_at": {+ "name": "resolved_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "goal_nodes_goal_id_status_idx": {+ "name": "goal_nodes_goal_id_status_idx",+ "columns": [+ {+ "expression": "goal_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "goal_nodes_goal_id_kind_idx": {+ "name": "goal_nodes_goal_id_kind_idx",+ "columns": [+ {+ "expression": "goal_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "goal_nodes_task_id_unique": {+ "name": "goal_nodes_task_id_unique",+ "columns": [+ {+ "expression": "task_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"goal_nodes\".\"task_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "goal_nodes_goal_id_goals_id_fk": {+ "name": "goal_nodes_goal_id_goals_id_fk",+ "tableFrom": "goal_nodes",+ "tableTo": "goals",+ "columnsFrom": ["goal_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "goal_nodes_task_id_tasks_id_fk": {+ "name": "goal_nodes_task_id_tasks_id_fk",+ "tableFrom": "goal_nodes",+ "tableTo": "tasks",+ "columnsFrom": ["task_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "goal_nodes_created_by_user_id_users_id_fk": {+ "name": "goal_nodes_created_by_user_id_users_id_fk",+ "tableFrom": "goal_nodes",+ "tableTo": "users",+ "columnsFrom": ["created_by_user_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "goal_nodes_created_by_agent_id_agents_id_fk": {+ "name": "goal_nodes_created_by_agent_id_agents_id_fk",+ "tableFrom": "goal_nodes",+ "tableTo": "agents",+ "columnsFrom": ["created_by_agent_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "goal_nodes_goal_id_id_unique": {+ "name": "goal_nodes_goal_id_id_unique",+ "nullsNotDistinct": false,+ "columns": ["goal_id", "id"]+ }+ },+ "policies": {},+ "checkConstraints": {+ "goal_nodes_task_requires_work_kind": {+ "name": "goal_nodes_task_requires_work_kind",+ "value": "\"goal_nodes\".\"task_id\" IS NULL OR \"goal_nodes\".\"kind\" = 'work'"+ },+ "goal_nodes_confidence_range": {+ "name": "goal_nodes_confidence_range",+ "value": "\"goal_nodes\".\"confidence\" IS NULL OR (\"goal_nodes\".\"confidence\" >= 0 AND \"goal_nodes\".\"confidence\" <= 1)"+ }+ },+ "isRLSEnabled": false+ },+ "public.llm_generation_tracing": {+ "name": "llm_generation_tracing",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "scenario": {+ "name": "scenario",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "prompt_version": {+ "name": "prompt_version",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "prompt_hash": {+ "name": "prompt_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "schema_name": {+ "name": "schema_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "topic_id": {+ "name": "topic_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "trigger": {+ "name": "trigger",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "parent_tracing_id": {+ "name": "parent_tracing_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "model": {+ "name": "model",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "success": {+ "name": "success",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true+ },+ "error_code": {+ "name": "error_code",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "error_detail": {+ "name": "error_detail",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "validation_failed": {+ "name": "validation_failed",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "input_hash": {+ "name": "input_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "input_hint": {+ "name": "input_hint",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "latency_ms": {+ "name": "latency_ms",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "input_tokens": {+ "name": "input_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "output_tokens": {+ "name": "output_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "cost_usd": {+ "name": "cost_usd",+ "type": "numeric(12, 8)",+ "primaryKey": false,+ "notNull": false+ },+ "storage_key": {+ "name": "storage_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "feedback_signal": {+ "name": "feedback_signal",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "feedback_score": {+ "name": "feedback_score",+ "type": "numeric(3, 2)",+ "primaryKey": false,+ "notNull": false+ },+ "feedback_source": {+ "name": "feedback_source",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "feedback_data": {+ "name": "feedback_data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "feedback_updated_at": {+ "name": "feedback_updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "trace_id": {+ "name": "trace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "span_id": {+ "name": "span_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false,+ "default": "'{}'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "llm_generation_tracing_scenario_idx": {+ "name": "llm_generation_tracing_scenario_idx",+ "columns": [+ {+ "expression": "scenario",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "llm_generation_tracing_prompt_version_idx": {+ "name": "llm_generation_tracing_prompt_version_idx",+ "columns": [+ {+ "expression": "prompt_version",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "llm_generation_tracing_user_id_idx": {+ "name": "llm_generation_tracing_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "llm_generation_tracing_agent_id_idx": {+ "name": "llm_generation_tracing_agent_id_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "llm_generation_tracing_topic_id_idx": {+ "name": "llm_generation_tracing_topic_id_idx",+ "columns": [+ {+ "expression": "topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "llm_generation_tracing_workspace_id_idx": {+ "name": "llm_generation_tracing_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "llm_generation_tracing_provider_idx": {+ "name": "llm_generation_tracing_provider_idx",+ "columns": [+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "llm_generation_tracing_model_idx": {+ "name": "llm_generation_tracing_model_idx",+ "columns": [+ {+ "expression": "model",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "llm_generation_tracing_success_idx": {+ "name": "llm_generation_tracing_success_idx",+ "columns": [+ {+ "expression": "success",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "llm_generation_tracing_error_code_idx": {+ "name": "llm_generation_tracing_error_code_idx",+ "columns": [+ {+ "expression": "error_code",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "llm_generation_tracing_validation_failed_idx": {+ "name": "llm_generation_tracing_validation_failed_idx",+ "columns": [+ {+ "expression": "validation_failed",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "llm_generation_tracing_feedback_signal_idx": {+ "name": "llm_generation_tracing_feedback_signal_idx",+ "columns": [+ {+ "expression": "feedback_signal",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "llm_generation_tracing_created_at_idx": {+ "name": "llm_generation_tracing_created_at_idx",+ "columns": [+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "llm_generation_tracing_workspace_id_workspaces_id_fk": {+ "name": "llm_generation_tracing_workspace_id_workspaces_id_fk",+ "tableFrom": "llm_generation_tracing",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.message_chunks": {+ "name": "message_chunks",+ "schema": "",+ "columns": {+ "message_id": {+ "name": "message_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "chunk_id": {+ "name": "chunk_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "message_chunks_user_id_idx": {+ "name": "message_chunks_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_chunks_message_id_idx": {+ "name": "message_chunks_message_id_idx",+ "columns": [+ {+ "expression": "message_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_chunks_workspace_id_idx": {+ "name": "message_chunks_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "message_chunks_message_id_messages_id_fk": {+ "name": "message_chunks_message_id_messages_id_fk",+ "tableFrom": "message_chunks",+ "tableTo": "messages",+ "columnsFrom": ["message_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_chunks_chunk_id_chunks_id_fk": {+ "name": "message_chunks_chunk_id_chunks_id_fk",+ "tableFrom": "message_chunks",+ "tableTo": "chunks",+ "columnsFrom": ["chunk_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_chunks_user_id_users_id_fk": {+ "name": "message_chunks_user_id_users_id_fk",+ "tableFrom": "message_chunks",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_chunks_workspace_id_workspaces_id_fk": {+ "name": "message_chunks_workspace_id_workspaces_id_fk",+ "tableFrom": "message_chunks",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "message_chunks_chunk_id_message_id_pk": {+ "name": "message_chunks_chunk_id_message_id_pk",+ "columns": ["chunk_id", "message_id"]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.message_groups": {+ "name": "message_groups",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "topic_id": {+ "name": "topic_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "parent_group_id": {+ "name": "parent_group_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "parent_message_id": {+ "name": "parent_message_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "title": {+ "name": "title",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "editor_data": {+ "name": "editor_data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "client_id": {+ "name": "client_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "message_groups_client_id_user_id_unique": {+ "name": "message_groups_client_id_user_id_unique",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_groups_user_id_idx": {+ "name": "message_groups_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_groups_topic_id_idx": {+ "name": "message_groups_topic_id_idx",+ "columns": [+ {+ "expression": "topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_groups_type_idx": {+ "name": "message_groups_type_idx",+ "columns": [+ {+ "expression": "type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_groups_parent_group_id_idx": {+ "name": "message_groups_parent_group_id_idx",+ "columns": [+ {+ "expression": "parent_group_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_groups_parent_message_id_idx": {+ "name": "message_groups_parent_message_id_idx",+ "columns": [+ {+ "expression": "parent_message_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_groups_workspace_id_idx": {+ "name": "message_groups_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "message_groups_topic_id_topics_id_fk": {+ "name": "message_groups_topic_id_topics_id_fk",+ "tableFrom": "message_groups",+ "tableTo": "topics",+ "columnsFrom": ["topic_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_groups_user_id_users_id_fk": {+ "name": "message_groups_user_id_users_id_fk",+ "tableFrom": "message_groups",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_groups_workspace_id_workspaces_id_fk": {+ "name": "message_groups_workspace_id_workspaces_id_fk",+ "tableFrom": "message_groups",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_groups_parent_group_id_message_groups_id_fk": {+ "name": "message_groups_parent_group_id_message_groups_id_fk",+ "tableFrom": "message_groups",+ "tableTo": "message_groups",+ "columnsFrom": ["parent_group_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_groups_parent_message_id_messages_id_fk": {+ "name": "message_groups_parent_message_id_messages_id_fk",+ "tableFrom": "message_groups",+ "tableTo": "messages",+ "columnsFrom": ["parent_message_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.message_plugins": {+ "name": "message_plugins",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "tool_call_id": {+ "name": "tool_call_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "default": "'default'"+ },+ "intervention": {+ "name": "intervention",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "api_name": {+ "name": "api_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "arguments": {+ "name": "arguments",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "identifier": {+ "name": "identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "state": {+ "name": "state",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "error": {+ "name": "error",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "message_plugins_client_id_user_id_unique": {+ "name": "message_plugins_client_id_user_id_unique",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_plugins_user_id_idx": {+ "name": "message_plugins_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_plugins_tool_call_id_idx": {+ "name": "message_plugins_tool_call_id_idx",+ "columns": [+ {+ "expression": "tool_call_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_plugins_workspace_id_idx": {+ "name": "message_plugins_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "message_plugins_id_messages_id_fk": {+ "name": "message_plugins_id_messages_id_fk",+ "tableFrom": "message_plugins",+ "tableTo": "messages",+ "columnsFrom": ["id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_plugins_user_id_users_id_fk": {+ "name": "message_plugins_user_id_users_id_fk",+ "tableFrom": "message_plugins",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_plugins_workspace_id_workspaces_id_fk": {+ "name": "message_plugins_workspace_id_workspaces_id_fk",+ "tableFrom": "message_plugins",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.message_queries": {+ "name": "message_queries",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "message_id": {+ "name": "message_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "rewrite_query": {+ "name": "rewrite_query",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_query": {+ "name": "user_query",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "embeddings_id": {+ "name": "embeddings_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "message_queries_client_id_user_id_unique": {+ "name": "message_queries_client_id_user_id_unique",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_queries_user_id_idx": {+ "name": "message_queries_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_queries_message_id_idx": {+ "name": "message_queries_message_id_idx",+ "columns": [+ {+ "expression": "message_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_queries_embeddings_id_idx": {+ "name": "message_queries_embeddings_id_idx",+ "columns": [+ {+ "expression": "embeddings_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_queries_workspace_id_idx": {+ "name": "message_queries_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "message_queries_message_id_messages_id_fk": {+ "name": "message_queries_message_id_messages_id_fk",+ "tableFrom": "message_queries",+ "tableTo": "messages",+ "columnsFrom": ["message_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_queries_user_id_users_id_fk": {+ "name": "message_queries_user_id_users_id_fk",+ "tableFrom": "message_queries",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_queries_workspace_id_workspaces_id_fk": {+ "name": "message_queries_workspace_id_workspaces_id_fk",+ "tableFrom": "message_queries",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_queries_embeddings_id_embeddings_id_fk": {+ "name": "message_queries_embeddings_id_embeddings_id_fk",+ "tableFrom": "message_queries",+ "tableTo": "embeddings",+ "columnsFrom": ["embeddings_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.message_query_chunks": {+ "name": "message_query_chunks",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "query_id": {+ "name": "query_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "chunk_id": {+ "name": "chunk_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "similarity": {+ "name": "similarity",+ "type": "numeric(6, 5)",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "message_query_chunks_user_id_idx": {+ "name": "message_query_chunks_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_query_chunks_message_id_idx": {+ "name": "message_query_chunks_message_id_idx",+ "columns": [+ {+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_query_chunks_query_id_idx": {+ "name": "message_query_chunks_query_id_idx",+ "columns": [+ {+ "expression": "query_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_query_chunks_workspace_id_idx": {+ "name": "message_query_chunks_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "message_query_chunks_id_messages_id_fk": {+ "name": "message_query_chunks_id_messages_id_fk",+ "tableFrom": "message_query_chunks",+ "tableTo": "messages",+ "columnsFrom": ["id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_query_chunks_query_id_message_queries_id_fk": {+ "name": "message_query_chunks_query_id_message_queries_id_fk",+ "tableFrom": "message_query_chunks",+ "tableTo": "message_queries",+ "columnsFrom": ["query_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_query_chunks_chunk_id_chunks_id_fk": {+ "name": "message_query_chunks_chunk_id_chunks_id_fk",+ "tableFrom": "message_query_chunks",+ "tableTo": "chunks",+ "columnsFrom": ["chunk_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_query_chunks_user_id_users_id_fk": {+ "name": "message_query_chunks_user_id_users_id_fk",+ "tableFrom": "message_query_chunks",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_query_chunks_workspace_id_workspaces_id_fk": {+ "name": "message_query_chunks_workspace_id_workspaces_id_fk",+ "tableFrom": "message_query_chunks",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "message_query_chunks_chunk_id_id_query_id_pk": {+ "name": "message_query_chunks_chunk_id_id_query_id_pk",+ "columns": ["chunk_id", "id", "query_id"]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.message_tts": {+ "name": "message_tts",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "content_md5": {+ "name": "content_md5",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "file_id": {+ "name": "file_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "voice": {+ "name": "voice",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "message_tts_client_id_user_id_unique": {+ "name": "message_tts_client_id_user_id_unique",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_tts_user_id_idx": {+ "name": "message_tts_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_tts_workspace_id_idx": {+ "name": "message_tts_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "message_tts_id_messages_id_fk": {+ "name": "message_tts_id_messages_id_fk",+ "tableFrom": "message_tts",+ "tableTo": "messages",+ "columnsFrom": ["id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_tts_file_id_files_id_fk": {+ "name": "message_tts_file_id_files_id_fk",+ "tableFrom": "message_tts",+ "tableTo": "files",+ "columnsFrom": ["file_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_tts_user_id_users_id_fk": {+ "name": "message_tts_user_id_users_id_fk",+ "tableFrom": "message_tts",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_tts_workspace_id_workspaces_id_fk": {+ "name": "message_tts_workspace_id_workspaces_id_fk",+ "tableFrom": "message_tts",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.message_translates": {+ "name": "message_translates",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "from": {+ "name": "from",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "to": {+ "name": "to",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "message_translates_client_id_user_id_unique": {+ "name": "message_translates_client_id_user_id_unique",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_translates_user_id_idx": {+ "name": "message_translates_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_translates_workspace_id_idx": {+ "name": "message_translates_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "message_translates_id_messages_id_fk": {+ "name": "message_translates_id_messages_id_fk",+ "tableFrom": "message_translates",+ "tableTo": "messages",+ "columnsFrom": ["id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_translates_user_id_users_id_fk": {+ "name": "message_translates_user_id_users_id_fk",+ "tableFrom": "message_translates",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "message_translates_workspace_id_workspaces_id_fk": {+ "name": "message_translates_workspace_id_workspaces_id_fk",+ "tableFrom": "message_translates",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.messages": {+ "name": "messages",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "role": {+ "name": "role",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "editor_data": {+ "name": "editor_data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "summary": {+ "name": "summary",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "reasoning": {+ "name": "reasoning",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "search": {+ "name": "search",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "usage": {+ "name": "usage",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "model": {+ "name": "model",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "favorite": {+ "name": "favorite",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": false+ },+ "error": {+ "name": "error",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "tools": {+ "name": "tools",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "trace_id": {+ "name": "trace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "observation_id": {+ "name": "observation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "session_id": {+ "name": "session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "topic_id": {+ "name": "topic_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "thread_id": {+ "name": "thread_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "parent_id": {+ "name": "parent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "quota_id": {+ "name": "quota_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "group_id": {+ "name": "group_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "target_id": {+ "name": "target_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "message_group_id": {+ "name": "message_group_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "messages_created_at_idx": {+ "name": "messages_created_at_idx",+ "columns": [+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "message_client_id_user_unique": {+ "name": "message_client_id_user_unique",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messages_topic_id_idx": {+ "name": "messages_topic_id_idx",+ "columns": [+ {+ "expression": "topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messages_topic_id_updated_at_idx": {+ "name": "messages_topic_id_updated_at_idx",+ "columns": [+ {+ "expression": "topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "updated_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messages_parent_id_idx": {+ "name": "messages_parent_id_idx",+ "columns": [+ {+ "expression": "parent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messages_quota_id_idx": {+ "name": "messages_quota_id_idx",+ "columns": [+ {+ "expression": "quota_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messages_user_id_idx": {+ "name": "messages_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messages_session_id_idx": {+ "name": "messages_session_id_idx",+ "columns": [+ {+ "expression": "session_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messages_thread_id_idx": {+ "name": "messages_thread_id_idx",+ "columns": [+ {+ "expression": "thread_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messages_agent_id_idx": {+ "name": "messages_agent_id_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messages_group_id_idx": {+ "name": "messages_group_id_idx",+ "columns": [+ {+ "expression": "group_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messages_message_group_id_idx": {+ "name": "messages_message_group_id_idx",+ "columns": [+ {+ "expression": "message_group_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messages_usage_cost_idx": {+ "name": "messages_usage_cost_idx",+ "columns": [+ {+ "expression": "((\"usage\"->>'cost')::numeric)",+ "asc": true,+ "isExpression": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messages_usage_total_tokens_idx": {+ "name": "messages_usage_total_tokens_idx",+ "columns": [+ {+ "expression": "((\"usage\"->>'totalTokens')::numeric)",+ "asc": true,+ "isExpression": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messages_workspace_id_idx": {+ "name": "messages_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "messages_user_id_users_id_fk": {+ "name": "messages_user_id_users_id_fk",+ "tableFrom": "messages",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "messages_session_id_sessions_id_fk": {+ "name": "messages_session_id_sessions_id_fk",+ "tableFrom": "messages",+ "tableTo": "sessions",+ "columnsFrom": ["session_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "messages_topic_id_topics_id_fk": {+ "name": "messages_topic_id_topics_id_fk",+ "tableFrom": "messages",+ "tableTo": "topics",+ "columnsFrom": ["topic_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "messages_thread_id_threads_id_fk": {+ "name": "messages_thread_id_threads_id_fk",+ "tableFrom": "messages",+ "tableTo": "threads",+ "columnsFrom": ["thread_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "messages_parent_id_messages_id_fk": {+ "name": "messages_parent_id_messages_id_fk",+ "tableFrom": "messages",+ "tableTo": "messages",+ "columnsFrom": ["parent_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "messages_quota_id_messages_id_fk": {+ "name": "messages_quota_id_messages_id_fk",+ "tableFrom": "messages",+ "tableTo": "messages",+ "columnsFrom": ["quota_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "messages_agent_id_agents_id_fk": {+ "name": "messages_agent_id_agents_id_fk",+ "tableFrom": "messages",+ "tableTo": "agents",+ "columnsFrom": ["agent_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "messages_group_id_chat_groups_id_fk": {+ "name": "messages_group_id_chat_groups_id_fk",+ "tableFrom": "messages",+ "tableTo": "chat_groups",+ "columnsFrom": ["group_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "messages_message_group_id_message_groups_id_fk": {+ "name": "messages_message_group_id_message_groups_id_fk",+ "tableFrom": "messages",+ "tableTo": "message_groups",+ "columnsFrom": ["message_group_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "messages_workspace_id_workspaces_id_fk": {+ "name": "messages_workspace_id_workspaces_id_fk",+ "tableFrom": "messages",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.messages_files": {+ "name": "messages_files",+ "schema": "",+ "columns": {+ "file_id": {+ "name": "file_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "message_id": {+ "name": "message_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "messages_files_user_id_idx": {+ "name": "messages_files_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messages_files_message_id_idx": {+ "name": "messages_files_message_id_idx",+ "columns": [+ {+ "expression": "message_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messages_files_workspace_id_idx": {+ "name": "messages_files_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "messages_files_file_id_files_id_fk": {+ "name": "messages_files_file_id_files_id_fk",+ "tableFrom": "messages_files",+ "tableTo": "files",+ "columnsFrom": ["file_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "messages_files_message_id_messages_id_fk": {+ "name": "messages_files_message_id_messages_id_fk",+ "tableFrom": "messages_files",+ "tableTo": "messages",+ "columnsFrom": ["message_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "messages_files_user_id_users_id_fk": {+ "name": "messages_files_user_id_users_id_fk",+ "tableFrom": "messages_files",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "messages_files_workspace_id_workspaces_id_fk": {+ "name": "messages_files_workspace_id_workspaces_id_fk",+ "tableFrom": "messages_files",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "messages_files_file_id_message_id_pk": {+ "name": "messages_files_file_id_message_id_pk",+ "columns": ["file_id", "message_id"]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.messenger_account_links": {+ "name": "messenger_account_links",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "platform": {+ "name": "platform",+ "type": "varchar(50)",+ "primaryKey": false,+ "notNull": true+ },+ "tenant_id": {+ "name": "tenant_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "platform_user_id": {+ "name": "platform_user_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "platform_username": {+ "name": "platform_username",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "application_id": {+ "name": "application_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "credentials": {+ "name": "credentials",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "active_agent_id": {+ "name": "active_agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "messenger_account_links_platform_tenant_user_unique": {+ "name": "messenger_account_links_platform_tenant_user_unique",+ "columns": [+ {+ "expression": "platform",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "tenant_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "platform_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messenger_account_links_user_platform_tenant_unique": {+ "name": "messenger_account_links_user_platform_tenant_unique",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "platform",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "tenant_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messenger_account_links_platform_tenant_application_unique": {+ "name": "messenger_account_links_platform_tenant_application_unique",+ "columns": [+ {+ "expression": "platform",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "tenant_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "application_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"messenger_account_links\".\"application_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messenger_account_links_active_agent_idx": {+ "name": "messenger_account_links_active_agent_idx",+ "columns": [+ {+ "expression": "active_agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messenger_account_links_workspace_id_idx": {+ "name": "messenger_account_links_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "messenger_account_links_user_id_users_id_fk": {+ "name": "messenger_account_links_user_id_users_id_fk",+ "tableFrom": "messenger_account_links",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "messenger_account_links_workspace_id_workspaces_id_fk": {+ "name": "messenger_account_links_workspace_id_workspaces_id_fk",+ "tableFrom": "messenger_account_links",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "messenger_account_links_active_agent_id_agents_id_fk": {+ "name": "messenger_account_links_active_agent_id_agents_id_fk",+ "tableFrom": "messenger_account_links",+ "tableTo": "agents",+ "columnsFrom": ["active_agent_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.messenger_installations": {+ "name": "messenger_installations",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "platform": {+ "name": "platform",+ "type": "varchar(50)",+ "primaryKey": false,+ "notNull": true+ },+ "tenant_id": {+ "name": "tenant_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "application_id": {+ "name": "application_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "account_id": {+ "name": "account_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "credentials": {+ "name": "credentials",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "token_expires_at": {+ "name": "token_expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "installed_by_user_id": {+ "name": "installed_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "installed_by_platform_user_id": {+ "name": "installed_by_platform_user_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "revoked_at": {+ "name": "revoked_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "messenger_installations_platform_app_tenant_unique": {+ "name": "messenger_installations_platform_app_tenant_unique",+ "columns": [+ {+ "expression": "platform",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "application_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "tenant_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messenger_installations_platform_tenant_idx": {+ "name": "messenger_installations_platform_tenant_idx",+ "columns": [+ {+ "expression": "platform",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "tenant_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "messenger_installations_token_expires_at_idx": {+ "name": "messenger_installations_token_expires_at_idx",+ "columns": [+ {+ "expression": "token_expires_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "messenger_installations_installed_by_user_id_users_id_fk": {+ "name": "messenger_installations_installed_by_user_id_users_id_fk",+ "tableFrom": "messenger_installations",+ "tableTo": "users",+ "columnsFrom": ["installed_by_user_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.nextauth_accounts": {+ "name": "nextauth_accounts",+ "schema": "",+ "columns": {+ "access_token": {+ "name": "access_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "id_token": {+ "name": "id_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "providerAccountId": {+ "name": "providerAccountId",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "refresh_token": {+ "name": "refresh_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "scope": {+ "name": "scope",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "session_state": {+ "name": "session_state",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "token_type": {+ "name": "token_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "nextauth_accounts_user_id_idx": {+ "name": "nextauth_accounts_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "nextauth_accounts_user_id_users_id_fk": {+ "name": "nextauth_accounts_user_id_users_id_fk",+ "tableFrom": "nextauth_accounts",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "nextauth_accounts_provider_providerAccountId_pk": {+ "name": "nextauth_accounts_provider_providerAccountId_pk",+ "columns": ["provider", "providerAccountId"]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.nextauth_authenticators": {+ "name": "nextauth_authenticators",+ "schema": "",+ "columns": {+ "counter": {+ "name": "counter",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "credentialBackedUp": {+ "name": "credentialBackedUp",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true+ },+ "credentialDeviceType": {+ "name": "credentialDeviceType",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "credentialID": {+ "name": "credentialID",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "credentialPublicKey": {+ "name": "credentialPublicKey",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "providerAccountId": {+ "name": "providerAccountId",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "transports": {+ "name": "transports",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {+ "nextauth_authenticators_user_id_users_id_fk": {+ "name": "nextauth_authenticators_user_id_users_id_fk",+ "tableFrom": "nextauth_authenticators",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "nextauth_authenticators_user_id_credentialID_pk": {+ "name": "nextauth_authenticators_user_id_credentialID_pk",+ "columns": ["user_id", "credentialID"]+ }+ },+ "uniqueConstraints": {+ "nextauth_authenticators_credentialID_unique": {+ "name": "nextauth_authenticators_credentialID_unique",+ "nullsNotDistinct": false,+ "columns": ["credentialID"]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.nextauth_sessions": {+ "name": "nextauth_sessions",+ "schema": "",+ "columns": {+ "expires": {+ "name": "expires",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "sessionToken": {+ "name": "sessionToken",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "nextauth_sessions_user_id_idx": {+ "name": "nextauth_sessions_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "nextauth_sessions_user_id_users_id_fk": {+ "name": "nextauth_sessions_user_id_users_id_fk",+ "tableFrom": "nextauth_sessions",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.nextauth_verificationtokens": {+ "name": "nextauth_verificationtokens",+ "schema": "",+ "columns": {+ "expires": {+ "name": "expires",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "identifier": {+ "name": "identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "token": {+ "name": "token",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "nextauth_verificationtokens_identifier_token_pk": {+ "name": "nextauth_verificationtokens_identifier_token_pk",+ "columns": ["identifier", "token"]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.notification_deliveries": {+ "name": "notification_deliveries",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "notification_id": {+ "name": "notification_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "channel": {+ "name": "channel",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "provider_message_id": {+ "name": "provider_message_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "failed_reason": {+ "name": "failed_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "sent_at": {+ "name": "sent_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "idx_deliveries_notification": {+ "name": "idx_deliveries_notification",+ "columns": [+ {+ "expression": "notification_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "idx_deliveries_channel": {+ "name": "idx_deliveries_channel",+ "columns": [+ {+ "expression": "channel",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "idx_deliveries_status": {+ "name": "idx_deliveries_status",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "notification_deliveries_notification_id_notifications_id_fk": {+ "name": "notification_deliveries_notification_id_notifications_id_fk",+ "tableFrom": "notification_deliveries",+ "tableTo": "notifications",+ "columnsFrom": ["notification_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.notifications": {+ "name": "notifications",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "category": {+ "name": "category",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "context": {+ "name": "context",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "dedupe_key": {+ "name": "dedupe_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "action_url": {+ "name": "action_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "is_read": {+ "name": "is_read",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "is_archived": {+ "name": "is_archived",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": 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": {+ "idx_notifications_user": {+ "name": "idx_notifications_user",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "idx_notifications_user_active": {+ "name": "idx_notifications_user_active",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"notifications\".\"is_archived\" = false",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "idx_notifications_user_unread": {+ "name": "idx_notifications_user_unread",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"notifications\".\"is_read\" = false AND \"notifications\".\"is_archived\" = false",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "idx_notifications_dedupe": {+ "name": "idx_notifications_dedupe",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "dedupe_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "idx_notifications_user_workspace": {+ "name": "idx_notifications_user_workspace",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "idx_notifications_workspace_id": {+ "name": "idx_notifications_workspace_id",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "idx_notifications_archived_cleanup": {+ "name": "idx_notifications_archived_cleanup",+ "columns": [+ {+ "expression": "updated_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"notifications\".\"is_archived\" = true",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "notifications_user_id_users_id_fk": {+ "name": "notifications_user_id_users_id_fk",+ "tableFrom": "notifications",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "notifications_workspace_id_workspaces_id_fk": {+ "name": "notifications_workspace_id_workspaces_id_fk",+ "tableFrom": "notifications",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.oauth_handoffs": {+ "name": "oauth_handoffs",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "client": {+ "name": "client",+ "type": "varchar(50)",+ "primaryKey": false,+ "notNull": true+ },+ "payload": {+ "name": "payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.oidc_access_tokens": {+ "name": "oidc_access_tokens",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "data": {+ "name": "data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "consumed_at": {+ "name": "consumed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "client_id": {+ "name": "client_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "grant_id": {+ "name": "grant_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "oidc_access_tokens_user_id_idx": {+ "name": "oidc_access_tokens_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "oidc_access_tokens_user_id_users_id_fk": {+ "name": "oidc_access_tokens_user_id_users_id_fk",+ "tableFrom": "oidc_access_tokens",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.oidc_authorization_codes": {+ "name": "oidc_authorization_codes",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "data": {+ "name": "data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "consumed_at": {+ "name": "consumed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "client_id": {+ "name": "client_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "grant_id": {+ "name": "grant_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "oidc_authorization_codes_user_id_idx": {+ "name": "oidc_authorization_codes_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "oidc_authorization_codes_user_id_users_id_fk": {+ "name": "oidc_authorization_codes_user_id_users_id_fk",+ "tableFrom": "oidc_authorization_codes",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.oidc_clients": {+ "name": "oidc_clients",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "client_secret": {+ "name": "client_secret",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "redirect_uris": {+ "name": "redirect_uris",+ "type": "text[]",+ "primaryKey": false,+ "notNull": true+ },+ "grants": {+ "name": "grants",+ "type": "text[]",+ "primaryKey": false,+ "notNull": true+ },+ "response_types": {+ "name": "response_types",+ "type": "text[]",+ "primaryKey": false,+ "notNull": true+ },+ "scopes": {+ "name": "scopes",+ "type": "text[]",+ "primaryKey": false,+ "notNull": true+ },+ "token_endpoint_auth_method": {+ "name": "token_endpoint_auth_method",+ "type": "varchar(20)",+ "primaryKey": false,+ "notNull": false+ },+ "application_type": {+ "name": "application_type",+ "type": "varchar(20)",+ "primaryKey": false,+ "notNull": false+ },+ "client_uri": {+ "name": "client_uri",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "logo_uri": {+ "name": "logo_uri",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "policy_uri": {+ "name": "policy_uri",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "tos_uri": {+ "name": "tos_uri",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "is_first_party": {+ "name": "is_first_party",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "last_used_at": {+ "name": "last_used_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "oidc_clients_user_id_idx": {+ "name": "oidc_clients_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "oidc_clients_workspace_id_idx": {+ "name": "oidc_clients_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "oidc_clients_user_id_users_id_fk": {+ "name": "oidc_clients_user_id_users_id_fk",+ "tableFrom": "oidc_clients",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "oidc_clients_workspace_id_workspaces_id_fk": {+ "name": "oidc_clients_workspace_id_workspaces_id_fk",+ "tableFrom": "oidc_clients",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.oidc_consents": {+ "name": "oidc_consents",+ "schema": "",+ "columns": {+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "client_id": {+ "name": "client_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "scopes": {+ "name": "scopes",+ "type": "text[]",+ "primaryKey": false,+ "notNull": true+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "oidc_consents_user_id_users_id_fk": {+ "name": "oidc_consents_user_id_users_id_fk",+ "tableFrom": "oidc_consents",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "oidc_consents_client_id_oidc_clients_id_fk": {+ "name": "oidc_consents_client_id_oidc_clients_id_fk",+ "tableFrom": "oidc_consents",+ "tableTo": "oidc_clients",+ "columnsFrom": ["client_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "oidc_consents_user_id_client_id_pk": {+ "name": "oidc_consents_user_id_client_id_pk",+ "columns": ["user_id", "client_id"]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.oidc_device_codes": {+ "name": "oidc_device_codes",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "data": {+ "name": "data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "consumed_at": {+ "name": "consumed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "client_id": {+ "name": "client_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "grant_id": {+ "name": "grant_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "user_code": {+ "name": "user_code",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "oidc_device_codes_user_id_idx": {+ "name": "oidc_device_codes_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "oidc_device_codes_user_id_users_id_fk": {+ "name": "oidc_device_codes_user_id_users_id_fk",+ "tableFrom": "oidc_device_codes",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.oidc_grants": {+ "name": "oidc_grants",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "data": {+ "name": "data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "consumed_at": {+ "name": "consumed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "client_id": {+ "name": "client_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "oidc_grants_user_id_idx": {+ "name": "oidc_grants_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "oidc_grants_user_id_users_id_fk": {+ "name": "oidc_grants_user_id_users_id_fk",+ "tableFrom": "oidc_grants",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.oidc_interactions": {+ "name": "oidc_interactions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "data": {+ "name": "data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.oidc_refresh_tokens": {+ "name": "oidc_refresh_tokens",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "data": {+ "name": "data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "consumed_at": {+ "name": "consumed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "client_id": {+ "name": "client_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "grant_id": {+ "name": "grant_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "oidc_refresh_tokens_user_id_idx": {+ "name": "oidc_refresh_tokens_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "oidc_refresh_tokens_user_id_users_id_fk": {+ "name": "oidc_refresh_tokens_user_id_users_id_fk",+ "tableFrom": "oidc_refresh_tokens",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.oidc_sessions": {+ "name": "oidc_sessions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "data": {+ "name": "data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "oidc_sessions_user_id_idx": {+ "name": "oidc_sessions_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "oidc_sessions_user_id_users_id_fk": {+ "name": "oidc_sessions_user_id_users_id_fk",+ "tableFrom": "oidc_sessions",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_agents": {+ "name": "project_agents",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "project_id": {+ "name": "project_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "added_by_user_id": {+ "name": "added_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "responsibility": {+ "name": "responsibility",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "sort_order": {+ "name": "sort_order",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "project_agents_project_id_agent_id_unique": {+ "name": "project_agents_project_id_agent_id_unique",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_agents_project_id_sort_order_idx": {+ "name": "project_agents_project_id_sort_order_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "sort_order",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_agents_agent_id_idx": {+ "name": "project_agents_agent_id_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_agents_workspace_id_idx": {+ "name": "project_agents_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_agents_project_id_projects_id_fk": {+ "name": "project_agents_project_id_projects_id_fk",+ "tableFrom": "project_agents",+ "tableTo": "projects",+ "columnsFrom": ["project_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_agents_agent_id_agents_id_fk": {+ "name": "project_agents_agent_id_agents_id_fk",+ "tableFrom": "project_agents",+ "tableTo": "agents",+ "columnsFrom": ["agent_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_agents_added_by_user_id_users_id_fk": {+ "name": "project_agents_added_by_user_id_users_id_fk",+ "tableFrom": "project_agents",+ "tableTo": "users",+ "columnsFrom": ["added_by_user_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "project_agents_workspace_id_workspaces_id_fk": {+ "name": "project_agents_workspace_id_workspaces_id_fk",+ "tableFrom": "project_agents",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_chat_groups": {+ "name": "project_chat_groups",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "project_id": {+ "name": "project_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "chat_group_id": {+ "name": "chat_group_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "added_by_user_id": {+ "name": "added_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "responsibility": {+ "name": "responsibility",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "sort_order": {+ "name": "sort_order",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "project_chat_groups_project_id_chat_group_id_unique": {+ "name": "project_chat_groups_project_id_chat_group_id_unique",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "chat_group_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_chat_groups_project_id_sort_order_idx": {+ "name": "project_chat_groups_project_id_sort_order_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "sort_order",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_chat_groups_chat_group_id_idx": {+ "name": "project_chat_groups_chat_group_id_idx",+ "columns": [+ {+ "expression": "chat_group_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_chat_groups_workspace_id_idx": {+ "name": "project_chat_groups_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_chat_groups_project_id_projects_id_fk": {+ "name": "project_chat_groups_project_id_projects_id_fk",+ "tableFrom": "project_chat_groups",+ "tableTo": "projects",+ "columnsFrom": ["project_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_chat_groups_chat_group_id_chat_groups_id_fk": {+ "name": "project_chat_groups_chat_group_id_chat_groups_id_fk",+ "tableFrom": "project_chat_groups",+ "tableTo": "chat_groups",+ "columnsFrom": ["chat_group_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_chat_groups_added_by_user_id_users_id_fk": {+ "name": "project_chat_groups_added_by_user_id_users_id_fk",+ "tableFrom": "project_chat_groups",+ "tableTo": "users",+ "columnsFrom": ["added_by_user_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "project_chat_groups_workspace_id_workspaces_id_fk": {+ "name": "project_chat_groups_workspace_id_workspaces_id_fk",+ "tableFrom": "project_chat_groups",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_completion_reviews": {+ "name": "project_completion_reviews",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "project_id": {+ "name": "project_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "reviewer_user_id": {+ "name": "reviewer_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "round": {+ "name": "round",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "decision": {+ "name": "decision",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "comment": {+ "name": "comment",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "project_completion_reviews_project_id_round_unique": {+ "name": "project_completion_reviews_project_id_round_unique",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "round",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_completion_reviews_project_id_created_at_idx": {+ "name": "project_completion_reviews_project_id_created_at_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_completion_reviews_reviewer_user_id_idx": {+ "name": "project_completion_reviews_reviewer_user_id_idx",+ "columns": [+ {+ "expression": "reviewer_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_completion_reviews_workspace_id_idx": {+ "name": "project_completion_reviews_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_completion_reviews_project_id_projects_id_fk": {+ "name": "project_completion_reviews_project_id_projects_id_fk",+ "tableFrom": "project_completion_reviews",+ "tableTo": "projects",+ "columnsFrom": ["project_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_completion_reviews_reviewer_user_id_users_id_fk": {+ "name": "project_completion_reviews_reviewer_user_id_users_id_fk",+ "tableFrom": "project_completion_reviews",+ "tableTo": "users",+ "columnsFrom": ["reviewer_user_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "project_completion_reviews_workspace_id_workspaces_id_fk": {+ "name": "project_completion_reviews_workspace_id_workspaces_id_fk",+ "tableFrom": "project_completion_reviews",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "project_completion_reviews_round_positive": {+ "name": "project_completion_reviews_round_positive",+ "value": "\"project_completion_reviews\".\"round\" > 0"+ }+ },+ "isRLSEnabled": false+ },+ "public.project_knowledge_bases": {+ "name": "project_knowledge_bases",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "project_id": {+ "name": "project_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "knowledge_base_id": {+ "name": "knowledge_base_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "added_by_user_id": {+ "name": "added_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "sort_order": {+ "name": "sort_order",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "project_knowledge_bases_project_id_knowledge_base_id_unique": {+ "name": "project_knowledge_bases_project_id_knowledge_base_id_unique",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "knowledge_base_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_knowledge_bases_project_id_sort_order_idx": {+ "name": "project_knowledge_bases_project_id_sort_order_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "sort_order",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_knowledge_bases_knowledge_base_id_idx": {+ "name": "project_knowledge_bases_knowledge_base_id_idx",+ "columns": [+ {+ "expression": "knowledge_base_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_knowledge_bases_workspace_id_idx": {+ "name": "project_knowledge_bases_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_knowledge_bases_project_id_projects_id_fk": {+ "name": "project_knowledge_bases_project_id_projects_id_fk",+ "tableFrom": "project_knowledge_bases",+ "tableTo": "projects",+ "columnsFrom": ["project_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_knowledge_bases_knowledge_base_id_knowledge_bases_id_fk": {+ "name": "project_knowledge_bases_knowledge_base_id_knowledge_bases_id_fk",+ "tableFrom": "project_knowledge_bases",+ "tableTo": "knowledge_bases",+ "columnsFrom": ["knowledge_base_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_knowledge_bases_added_by_user_id_users_id_fk": {+ "name": "project_knowledge_bases_added_by_user_id_users_id_fk",+ "tableFrom": "project_knowledge_bases",+ "tableTo": "users",+ "columnsFrom": ["added_by_user_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "project_knowledge_bases_workspace_id_workspaces_id_fk": {+ "name": "project_knowledge_bases_workspace_id_workspaces_id_fk",+ "tableFrom": "project_knowledge_bases",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_works": {+ "name": "project_works",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "project_id": {+ "name": "project_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "work_id": {+ "name": "work_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "added_by_user_id": {+ "name": "added_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "sort_order": {+ "name": "sort_order",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "project_works_project_id_work_id_unique": {+ "name": "project_works_project_id_work_id_unique",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "work_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_works_project_id_sort_order_idx": {+ "name": "project_works_project_id_sort_order_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "sort_order",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_works_work_id_idx": {+ "name": "project_works_work_id_idx",+ "columns": [+ {+ "expression": "work_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_works_workspace_id_idx": {+ "name": "project_works_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_works_project_id_projects_id_fk": {+ "name": "project_works_project_id_projects_id_fk",+ "tableFrom": "project_works",+ "tableTo": "projects",+ "columnsFrom": ["project_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_works_work_id_works_id_fk": {+ "name": "project_works_work_id_works_id_fk",+ "tableFrom": "project_works",+ "tableTo": "works",+ "columnsFrom": ["work_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_works_added_by_user_id_users_id_fk": {+ "name": "project_works_added_by_user_id_users_id_fk",+ "tableFrom": "project_works",+ "tableTo": "users",+ "columnsFrom": ["added_by_user_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "project_works_workspace_id_workspaces_id_fk": {+ "name": "project_works_workspace_id_workspaces_id_fk",+ "tableFrom": "project_works",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.projects": {+ "name": "projects",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "slug": {+ "name": "slug",+ "type": "varchar(100)",+ "primaryKey": false,+ "notNull": false+ },+ "identifier": {+ "name": "identifier",+ "type": "varchar(6)",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "avatar": {+ "name": "avatar",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "coordinator_agent_id": {+ "name": "coordinator_agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'backlog'"+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'public'"+ },+ "completed_review_id": {+ "name": "completed_review_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "started_at": {+ "name": "started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "completed_at": {+ "name": "completed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "archived_at": {+ "name": "archived_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "projects_slug_user_id_unique": {+ "name": "projects_slug_user_id_unique",+ "columns": [+ {+ "expression": "slug",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"projects\".\"workspace_id\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "projects_slug_workspace_id_unique": {+ "name": "projects_slug_workspace_id_unique",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "slug",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"projects\".\"workspace_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "projects_identifier_user_id_unique": {+ "name": "projects_identifier_user_id_unique",+ "columns": [+ {+ "expression": "identifier",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"projects\".\"workspace_id\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "projects_identifier_workspace_id_unique": {+ "name": "projects_identifier_workspace_id_unique",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "identifier",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"projects\".\"workspace_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "projects_user_id_idx": {+ "name": "projects_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "projects_workspace_id_idx": {+ "name": "projects_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "projects_workspace_visibility_idx": {+ "name": "projects_workspace_visibility_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "projects_status_updated_at_idx": {+ "name": "projects_status_updated_at_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "updated_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "projects_coordinator_agent_id_unique": {+ "name": "projects_coordinator_agent_id_unique",+ "columns": [+ {+ "expression": "coordinator_agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "projects_coordinator_agent_id_agents_id_fk": {+ "name": "projects_coordinator_agent_id_agents_id_fk",+ "tableFrom": "projects",+ "tableTo": "agents",+ "columnsFrom": ["coordinator_agent_id"],+ "columnsTo": ["id"],+ "onDelete": "restrict",+ "onUpdate": "no action"+ },+ "projects_user_id_users_id_fk": {+ "name": "projects_user_id_users_id_fk",+ "tableFrom": "projects",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "projects_workspace_id_workspaces_id_fk": {+ "name": "projects_workspace_id_workspaces_id_fk",+ "tableFrom": "projects",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "projects_completed_requires_human_review": {+ "name": "projects_completed_requires_human_review",+ "value": "\"projects\".\"status\" <> 'completed' OR (\"projects\".\"completed_review_id\" IS NOT NULL AND \"projects\".\"completed_at\" IS NOT NULL)"+ }+ },+ "isRLSEnabled": false+ },+ "public.push_live_activities": {+ "name": "push_live_activities",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "device_id": {+ "name": "device_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "activity_key": {+ "name": "activity_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "operation_id": {+ "name": "operation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "activity_id": {+ "name": "activity_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "push_token": {+ "name": "push_token",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "apns_environment": {+ "name": "apns_environment",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "last_seen_at": {+ "name": "last_seen_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "idx_push_live_activities_user_device_activity": {+ "name": "idx_push_live_activities_user_device_activity",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "device_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "activity_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "idx_push_live_activities_user_activity": {+ "name": "idx_push_live_activities_user_activity",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "activity_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "idx_push_live_activities_user_operation": {+ "name": "idx_push_live_activities_user_operation",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "operation_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "idx_push_live_activities_last_seen": {+ "name": "idx_push_live_activities_last_seen",+ "columns": [+ {+ "expression": "last_seen_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "push_live_activities_user_id_users_id_fk": {+ "name": "push_live_activities_user_id_users_id_fk",+ "tableFrom": "push_live_activities",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "push_live_activities_apns_environment_check": {+ "name": "push_live_activities_apns_environment_check",+ "value": "\"push_live_activities\".\"apns_environment\" IN ('sandbox', 'production')"+ }+ },+ "isRLSEnabled": false+ },+ "public.push_tokens": {+ "name": "push_tokens",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "expo_token": {+ "name": "expo_token",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "device_id": {+ "name": "device_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "platform": {+ "name": "platform",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "apns_environment": {+ "name": "apns_environment",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "app_version": {+ "name": "app_version",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "locale": {+ "name": "locale",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "live_activity_push_to_start_token": {+ "name": "live_activity_push_to_start_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "last_seen_at": {+ "name": "last_seen_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "idx_push_tokens_user_device": {+ "name": "idx_push_tokens_user_device",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "device_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "idx_push_tokens_user": {+ "name": "idx_push_tokens_user",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "idx_push_tokens_last_seen": {+ "name": "idx_push_tokens_last_seen",+ "columns": [+ {+ "expression": "last_seen_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "push_tokens_user_id_users_id_fk": {+ "name": "push_tokens_user_id_users_id_fk",+ "tableFrom": "push_tokens",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "push_tokens_apns_environment_check": {+ "name": "push_tokens_apns_environment_check",+ "value": "\"push_tokens\".\"apns_environment\" IS NULL OR \"push_tokens\".\"apns_environment\" IN ('sandbox', 'production')"+ }+ },+ "isRLSEnabled": false+ },+ "public.chunks": {+ "name": "chunks",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "text": {+ "name": "text",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "abstract": {+ "name": "abstract",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "index": {+ "name": "index",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "varchar",+ "primaryKey": false,+ "notNull": false+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "chunks_client_id_user_id_unique": {+ "name": "chunks_client_id_user_id_unique",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "chunks_user_id_idx": {+ "name": "chunks_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "chunks_workspace_id_idx": {+ "name": "chunks_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "chunks_user_id_users_id_fk": {+ "name": "chunks_user_id_users_id_fk",+ "tableFrom": "chunks",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "chunks_workspace_id_workspaces_id_fk": {+ "name": "chunks_workspace_id_workspaces_id_fk",+ "tableFrom": "chunks",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.document_chunks": {+ "name": "document_chunks",+ "schema": "",+ "columns": {+ "document_id": {+ "name": "document_id",+ "type": "varchar(30)",+ "primaryKey": false,+ "notNull": true+ },+ "chunk_id": {+ "name": "chunk_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "page_index": {+ "name": "page_index",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "document_chunks_document_id_idx": {+ "name": "document_chunks_document_id_idx",+ "columns": [+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "document_chunks_chunk_id_idx": {+ "name": "document_chunks_chunk_id_idx",+ "columns": [+ {+ "expression": "chunk_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "document_chunks_user_id_idx": {+ "name": "document_chunks_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "document_chunks_workspace_id_idx": {+ "name": "document_chunks_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "document_chunks_document_id_documents_id_fk": {+ "name": "document_chunks_document_id_documents_id_fk",+ "tableFrom": "document_chunks",+ "tableTo": "documents",+ "columnsFrom": ["document_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "document_chunks_chunk_id_chunks_id_fk": {+ "name": "document_chunks_chunk_id_chunks_id_fk",+ "tableFrom": "document_chunks",+ "tableTo": "chunks",+ "columnsFrom": ["chunk_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "document_chunks_user_id_users_id_fk": {+ "name": "document_chunks_user_id_users_id_fk",+ "tableFrom": "document_chunks",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "document_chunks_workspace_id_workspaces_id_fk": {+ "name": "document_chunks_workspace_id_workspaces_id_fk",+ "tableFrom": "document_chunks",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "document_chunks_document_id_chunk_id_pk": {+ "name": "document_chunks_document_id_chunk_id_pk",+ "columns": ["document_id", "chunk_id"]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.embeddings": {+ "name": "embeddings",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "chunk_id": {+ "name": "chunk_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "embeddings": {+ "name": "embeddings",+ "type": "vector(1024)",+ "primaryKey": false,+ "notNull": false+ },+ "model": {+ "name": "model",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "embeddings_client_id_user_id_unique": {+ "name": "embeddings_client_id_user_id_unique",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "embeddings_chunk_id_idx": {+ "name": "embeddings_chunk_id_idx",+ "columns": [+ {+ "expression": "chunk_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "embeddings_user_id_idx": {+ "name": "embeddings_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "embeddings_workspace_id_idx": {+ "name": "embeddings_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "embeddings_chunk_id_chunks_id_fk": {+ "name": "embeddings_chunk_id_chunks_id_fk",+ "tableFrom": "embeddings",+ "tableTo": "chunks",+ "columnsFrom": ["chunk_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "embeddings_user_id_users_id_fk": {+ "name": "embeddings_user_id_users_id_fk",+ "tableFrom": "embeddings",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "embeddings_workspace_id_workspaces_id_fk": {+ "name": "embeddings_workspace_id_workspaces_id_fk",+ "tableFrom": "embeddings",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "embeddings_chunk_id_unique": {+ "name": "embeddings_chunk_id_unique",+ "nullsNotDistinct": false,+ "columns": ["chunk_id"]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.unstructured_chunks": {+ "name": "unstructured_chunks",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "text": {+ "name": "text",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "index": {+ "name": "index",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "varchar",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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()"+ },+ "parent_id": {+ "name": "parent_id",+ "type": "varchar",+ "primaryKey": false,+ "notNull": false+ },+ "composite_id": {+ "name": "composite_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "file_id": {+ "name": "file_id",+ "type": "varchar",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "unstructured_chunks_client_id_user_id_unique": {+ "name": "unstructured_chunks_client_id_user_id_unique",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "unstructured_chunks_user_id_idx": {+ "name": "unstructured_chunks_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "unstructured_chunks_composite_id_idx": {+ "name": "unstructured_chunks_composite_id_idx",+ "columns": [+ {+ "expression": "composite_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "unstructured_chunks_file_id_idx": {+ "name": "unstructured_chunks_file_id_idx",+ "columns": [+ {+ "expression": "file_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "unstructured_chunks_workspace_id_idx": {+ "name": "unstructured_chunks_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "unstructured_chunks_composite_id_chunks_id_fk": {+ "name": "unstructured_chunks_composite_id_chunks_id_fk",+ "tableFrom": "unstructured_chunks",+ "tableTo": "chunks",+ "columnsFrom": ["composite_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "unstructured_chunks_user_id_users_id_fk": {+ "name": "unstructured_chunks_user_id_users_id_fk",+ "tableFrom": "unstructured_chunks",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "unstructured_chunks_workspace_id_workspaces_id_fk": {+ "name": "unstructured_chunks_workspace_id_workspaces_id_fk",+ "tableFrom": "unstructured_chunks",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "unstructured_chunks_file_id_files_id_fk": {+ "name": "unstructured_chunks_file_id_files_id_fk",+ "tableFrom": "unstructured_chunks",+ "tableTo": "files",+ "columnsFrom": ["file_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.rag_eval_dataset_records": {+ "name": "rag_eval_dataset_records",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "dataset_id": {+ "name": "dataset_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "ideal": {+ "name": "ideal",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "question": {+ "name": "question",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "reference_files": {+ "name": "reference_files",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "rag_eval_dataset_records_user_id_idx": {+ "name": "rag_eval_dataset_records_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "rag_eval_dataset_records_workspace_id_idx": {+ "name": "rag_eval_dataset_records_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "rag_eval_dataset_records_dataset_id_rag_eval_datasets_id_fk": {+ "name": "rag_eval_dataset_records_dataset_id_rag_eval_datasets_id_fk",+ "tableFrom": "rag_eval_dataset_records",+ "tableTo": "rag_eval_datasets",+ "columnsFrom": ["dataset_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "rag_eval_dataset_records_user_id_users_id_fk": {+ "name": "rag_eval_dataset_records_user_id_users_id_fk",+ "tableFrom": "rag_eval_dataset_records",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "rag_eval_dataset_records_workspace_id_workspaces_id_fk": {+ "name": "rag_eval_dataset_records_workspace_id_workspaces_id_fk",+ "tableFrom": "rag_eval_dataset_records",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.rag_eval_datasets": {+ "name": "rag_eval_datasets",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "knowledge_base_id": {+ "name": "knowledge_base_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "rag_eval_datasets_user_id_idx": {+ "name": "rag_eval_datasets_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "rag_eval_datasets_workspace_id_idx": {+ "name": "rag_eval_datasets_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "rag_eval_datasets_knowledge_base_id_knowledge_bases_id_fk": {+ "name": "rag_eval_datasets_knowledge_base_id_knowledge_bases_id_fk",+ "tableFrom": "rag_eval_datasets",+ "tableTo": "knowledge_bases",+ "columnsFrom": ["knowledge_base_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "rag_eval_datasets_user_id_users_id_fk": {+ "name": "rag_eval_datasets_user_id_users_id_fk",+ "tableFrom": "rag_eval_datasets",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "rag_eval_datasets_workspace_id_workspaces_id_fk": {+ "name": "rag_eval_datasets_workspace_id_workspaces_id_fk",+ "tableFrom": "rag_eval_datasets",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.rag_eval_evaluations": {+ "name": "rag_eval_evaluations",+ "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+ },+ "eval_records_url": {+ "name": "eval_records_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "error": {+ "name": "error",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "dataset_id": {+ "name": "dataset_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "knowledge_base_id": {+ "name": "knowledge_base_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "language_model": {+ "name": "language_model",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "embedding_model": {+ "name": "embedding_model",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "rag_eval_evaluations_user_id_idx": {+ "name": "rag_eval_evaluations_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "rag_eval_evaluations_workspace_id_idx": {+ "name": "rag_eval_evaluations_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "rag_eval_evaluations_dataset_id_rag_eval_datasets_id_fk": {+ "name": "rag_eval_evaluations_dataset_id_rag_eval_datasets_id_fk",+ "tableFrom": "rag_eval_evaluations",+ "tableTo": "rag_eval_datasets",+ "columnsFrom": ["dataset_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "rag_eval_evaluations_knowledge_base_id_knowledge_bases_id_fk": {+ "name": "rag_eval_evaluations_knowledge_base_id_knowledge_bases_id_fk",+ "tableFrom": "rag_eval_evaluations",+ "tableTo": "knowledge_bases",+ "columnsFrom": ["knowledge_base_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "rag_eval_evaluations_user_id_users_id_fk": {+ "name": "rag_eval_evaluations_user_id_users_id_fk",+ "tableFrom": "rag_eval_evaluations",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "rag_eval_evaluations_workspace_id_workspaces_id_fk": {+ "name": "rag_eval_evaluations_workspace_id_workspaces_id_fk",+ "tableFrom": "rag_eval_evaluations",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.rag_eval_evaluation_records": {+ "name": "rag_eval_evaluation_records",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "question": {+ "name": "question",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "answer": {+ "name": "answer",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "context": {+ "name": "context",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "ideal": {+ "name": "ideal",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "error": {+ "name": "error",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "language_model": {+ "name": "language_model",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "embedding_model": {+ "name": "embedding_model",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "question_embedding_id": {+ "name": "question_embedding_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "duration": {+ "name": "duration",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "dataset_record_id": {+ "name": "dataset_record_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "evaluation_id": {+ "name": "evaluation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "rag_eval_evaluation_records_user_id_idx": {+ "name": "rag_eval_evaluation_records_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "rag_eval_evaluation_records_workspace_id_idx": {+ "name": "rag_eval_evaluation_records_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "rag_eval_evaluation_records_question_embedding_id_embeddings_id_fk": {+ "name": "rag_eval_evaluation_records_question_embedding_id_embeddings_id_fk",+ "tableFrom": "rag_eval_evaluation_records",+ "tableTo": "embeddings",+ "columnsFrom": ["question_embedding_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "rag_eval_evaluation_records_dataset_record_id_rag_eval_dataset_records_id_fk": {+ "name": "rag_eval_evaluation_records_dataset_record_id_rag_eval_dataset_records_id_fk",+ "tableFrom": "rag_eval_evaluation_records",+ "tableTo": "rag_eval_dataset_records",+ "columnsFrom": ["dataset_record_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "rag_eval_evaluation_records_evaluation_id_rag_eval_evaluations_id_fk": {+ "name": "rag_eval_evaluation_records_evaluation_id_rag_eval_evaluations_id_fk",+ "tableFrom": "rag_eval_evaluation_records",+ "tableTo": "rag_eval_evaluations",+ "columnsFrom": ["evaluation_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "rag_eval_evaluation_records_user_id_users_id_fk": {+ "name": "rag_eval_evaluation_records_user_id_users_id_fk",+ "tableFrom": "rag_eval_evaluation_records",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "rag_eval_evaluation_records_workspace_id_workspaces_id_fk": {+ "name": "rag_eval_evaluation_records_workspace_id_workspaces_id_fk",+ "tableFrom": "rag_eval_evaluation_records",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.rbac_permissions": {+ "name": "rbac_permissions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "code": {+ "name": "code",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "category": {+ "name": "category",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "is_active": {+ "name": "is_active",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "rbac_permissions_code_unique": {+ "name": "rbac_permissions_code_unique",+ "nullsNotDistinct": false,+ "columns": ["code"]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.rbac_role_permissions": {+ "name": "rbac_role_permissions",+ "schema": "",+ "columns": {+ "role_id": {+ "name": "role_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "permission_id": {+ "name": "permission_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "rbac_role_permissions_role_id_idx": {+ "name": "rbac_role_permissions_role_id_idx",+ "columns": [+ {+ "expression": "role_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "rbac_role_permissions_permission_id_idx": {+ "name": "rbac_role_permissions_permission_id_idx",+ "columns": [+ {+ "expression": "permission_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "rbac_role_permissions_role_id_rbac_roles_id_fk": {+ "name": "rbac_role_permissions_role_id_rbac_roles_id_fk",+ "tableFrom": "rbac_role_permissions",+ "tableTo": "rbac_roles",+ "columnsFrom": ["role_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "rbac_role_permissions_permission_id_rbac_permissions_id_fk": {+ "name": "rbac_role_permissions_permission_id_rbac_permissions_id_fk",+ "tableFrom": "rbac_role_permissions",+ "tableTo": "rbac_permissions",+ "columnsFrom": ["permission_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "rbac_role_permissions_role_id_permission_id_pk": {+ "name": "rbac_role_permissions_role_id_permission_id_pk",+ "columns": ["role_id", "permission_id"]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.rbac_roles": {+ "name": "rbac_roles",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "display_name": {+ "name": "display_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "is_system": {+ "name": "is_system",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "is_active": {+ "name": "is_active",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false,+ "default": "'{}'::jsonb"+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "rbac_roles_workspace_id_idx": {+ "name": "rbac_roles_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "rbac_roles_name_workspace_unique": {+ "name": "rbac_roles_name_workspace_unique",+ "columns": [+ {+ "expression": "name",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "COALESCE(\"workspace_id\", '')",+ "asc": true,+ "isExpression": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "rbac_roles_workspace_id_workspaces_id_fk": {+ "name": "rbac_roles_workspace_id_workspaces_id_fk",+ "tableFrom": "rbac_roles",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.rbac_user_roles": {+ "name": "rbac_user_roles",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "role_id": {+ "name": "role_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "rbac_user_roles_user_role_scope_unique": {+ "name": "rbac_user_roles_user_role_scope_unique",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "role_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "COALESCE(\"workspace_id\", '')",+ "asc": true,+ "isExpression": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "rbac_user_roles_user_id_idx": {+ "name": "rbac_user_roles_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "rbac_user_roles_role_id_idx": {+ "name": "rbac_user_roles_role_id_idx",+ "columns": [+ {+ "expression": "role_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "rbac_user_roles_workspace_id_idx": {+ "name": "rbac_user_roles_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "rbac_user_roles_user_id_users_id_fk": {+ "name": "rbac_user_roles_user_id_users_id_fk",+ "tableFrom": "rbac_user_roles",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "rbac_user_roles_role_id_rbac_roles_id_fk": {+ "name": "rbac_user_roles_role_id_rbac_roles_id_fk",+ "tableFrom": "rbac_user_roles",+ "tableTo": "rbac_roles",+ "columnsFrom": ["role_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "rbac_user_roles_workspace_id_workspaces_id_fk": {+ "name": "rbac_user_roles_workspace_id_workspaces_id_fk",+ "tableFrom": "rbac_user_roles",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agents_to_sessions": {+ "name": "agents_to_sessions",+ "schema": "",+ "columns": {+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "session_id": {+ "name": "session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "agents_to_sessions_session_id_idx": {+ "name": "agents_to_sessions_session_id_idx",+ "columns": [+ {+ "expression": "session_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agents_to_sessions_agent_id_idx": {+ "name": "agents_to_sessions_agent_id_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agents_to_sessions_user_id_idx": {+ "name": "agents_to_sessions_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agents_to_sessions_workspace_id_idx": {+ "name": "agents_to_sessions_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agents_to_sessions_agent_id_agents_id_fk": {+ "name": "agents_to_sessions_agent_id_agents_id_fk",+ "tableFrom": "agents_to_sessions",+ "tableTo": "agents",+ "columnsFrom": ["agent_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agents_to_sessions_session_id_sessions_id_fk": {+ "name": "agents_to_sessions_session_id_sessions_id_fk",+ "tableFrom": "agents_to_sessions",+ "tableTo": "sessions",+ "columnsFrom": ["session_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agents_to_sessions_user_id_users_id_fk": {+ "name": "agents_to_sessions_user_id_users_id_fk",+ "tableFrom": "agents_to_sessions",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agents_to_sessions_workspace_id_workspaces_id_fk": {+ "name": "agents_to_sessions_workspace_id_workspaces_id_fk",+ "tableFrom": "agents_to_sessions",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "agents_to_sessions_agent_id_session_id_pk": {+ "name": "agents_to_sessions_agent_id_session_id_pk",+ "columns": ["agent_id", "session_id"]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.file_chunks": {+ "name": "file_chunks",+ "schema": "",+ "columns": {+ "file_id": {+ "name": "file_id",+ "type": "varchar",+ "primaryKey": false,+ "notNull": false+ },+ "chunk_id": {+ "name": "chunk_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "file_chunks_user_id_idx": {+ "name": "file_chunks_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "file_chunks_workspace_id_idx": {+ "name": "file_chunks_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "file_chunks_file_id_idx": {+ "name": "file_chunks_file_id_idx",+ "columns": [+ {+ "expression": "file_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "file_chunks_chunk_id_idx": {+ "name": "file_chunks_chunk_id_idx",+ "columns": [+ {+ "expression": "chunk_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "file_chunks_file_id_files_id_fk": {+ "name": "file_chunks_file_id_files_id_fk",+ "tableFrom": "file_chunks",+ "tableTo": "files",+ "columnsFrom": ["file_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "file_chunks_chunk_id_chunks_id_fk": {+ "name": "file_chunks_chunk_id_chunks_id_fk",+ "tableFrom": "file_chunks",+ "tableTo": "chunks",+ "columnsFrom": ["chunk_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "file_chunks_user_id_users_id_fk": {+ "name": "file_chunks_user_id_users_id_fk",+ "tableFrom": "file_chunks",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "file_chunks_workspace_id_workspaces_id_fk": {+ "name": "file_chunks_workspace_id_workspaces_id_fk",+ "tableFrom": "file_chunks",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "file_chunks_file_id_chunk_id_pk": {+ "name": "file_chunks_file_id_chunk_id_pk",+ "columns": ["file_id", "chunk_id"]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.files_to_sessions": {+ "name": "files_to_sessions",+ "schema": "",+ "columns": {+ "file_id": {+ "name": "file_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "session_id": {+ "name": "session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "files_to_sessions_user_id_idx": {+ "name": "files_to_sessions_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "files_to_sessions_workspace_id_idx": {+ "name": "files_to_sessions_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "files_to_sessions_file_id_idx": {+ "name": "files_to_sessions_file_id_idx",+ "columns": [+ {+ "expression": "file_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "files_to_sessions_session_id_idx": {+ "name": "files_to_sessions_session_id_idx",+ "columns": [+ {+ "expression": "session_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "files_to_sessions_file_id_files_id_fk": {+ "name": "files_to_sessions_file_id_files_id_fk",+ "tableFrom": "files_to_sessions",+ "tableTo": "files",+ "columnsFrom": ["file_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "files_to_sessions_session_id_sessions_id_fk": {+ "name": "files_to_sessions_session_id_sessions_id_fk",+ "tableFrom": "files_to_sessions",+ "tableTo": "sessions",+ "columnsFrom": ["session_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "files_to_sessions_user_id_users_id_fk": {+ "name": "files_to_sessions_user_id_users_id_fk",+ "tableFrom": "files_to_sessions",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "files_to_sessions_workspace_id_workspaces_id_fk": {+ "name": "files_to_sessions_workspace_id_workspaces_id_fk",+ "tableFrom": "files_to_sessions",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "files_to_sessions_file_id_session_id_pk": {+ "name": "files_to_sessions_file_id_session_id_pk",+ "columns": ["file_id", "session_id"]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.resource_permissions": {+ "name": "resource_permissions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "resource_type": {+ "name": "resource_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "resource_id": {+ "name": "resource_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "access_level": {+ "name": "access_level",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_by": {+ "name": "created_by",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "resource_permissions_workspace_resource_unique": {+ "name": "resource_permissions_workspace_resource_unique",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "resource_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "resource_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"resource_permissions\".\"user_id\" is null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "resource_permissions_workspace_resource_user_id_unique": {+ "name": "resource_permissions_workspace_resource_user_id_unique",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "resource_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "resource_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"resource_permissions\".\"user_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "resource_permissions_resource_idx": {+ "name": "resource_permissions_resource_idx",+ "columns": [+ {+ "expression": "resource_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "resource_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "resource_permissions_workspace_idx": {+ "name": "resource_permissions_workspace_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "resource_permissions_workspace_user_idx": {+ "name": "resource_permissions_workspace_user_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "resource_permissions_workspace_id_workspaces_id_fk": {+ "name": "resource_permissions_workspace_id_workspaces_id_fk",+ "tableFrom": "resource_permissions",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "resource_permissions_user_id_users_id_fk": {+ "name": "resource_permissions_user_id_users_id_fk",+ "tableFrom": "resource_permissions",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "resource_permissions_created_by_users_id_fk": {+ "name": "resource_permissions_created_by_users_id_fk",+ "tableFrom": "resource_permissions",+ "tableTo": "users",+ "columnsFrom": ["created_by"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.resource_transfer_requests": {+ "name": "resource_transfer_requests",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "resource_type": {+ "name": "resource_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "resource_id": {+ "name": "resource_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "initiator_id": {+ "name": "initiator_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "recipient_id": {+ "name": "recipient_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "previous_owner_id": {+ "name": "previous_owner_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "options": {+ "name": "options",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "resolved_at": {+ "name": "resolved_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "resource_transfer_requests_pending_resource_unique": {+ "name": "resource_transfer_requests_pending_resource_unique",+ "columns": [+ {+ "expression": "resource_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "resource_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"resource_transfer_requests\".\"status\" = 'pending' AND \"resource_transfer_requests\".\"recipient_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "resource_transfer_requests_recipient_idx": {+ "name": "resource_transfer_requests_recipient_idx",+ "columns": [+ {+ "expression": "recipient_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "resource_transfer_requests_workspace_idx": {+ "name": "resource_transfer_requests_workspace_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "resource_transfer_requests_workspace_id_workspaces_id_fk": {+ "name": "resource_transfer_requests_workspace_id_workspaces_id_fk",+ "tableFrom": "resource_transfer_requests",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "resource_transfer_requests_initiator_id_users_id_fk": {+ "name": "resource_transfer_requests_initiator_id_users_id_fk",+ "tableFrom": "resource_transfer_requests",+ "tableTo": "users",+ "columnsFrom": ["initiator_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "resource_transfer_requests_recipient_id_users_id_fk": {+ "name": "resource_transfer_requests_recipient_id_users_id_fk",+ "tableFrom": "resource_transfer_requests",+ "tableTo": "users",+ "columnsFrom": ["recipient_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "resource_transfer_requests_previous_owner_id_users_id_fk": {+ "name": "resource_transfer_requests_previous_owner_id_users_id_fk",+ "tableFrom": "resource_transfer_requests",+ "tableTo": "users",+ "columnsFrom": ["previous_owner_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.session_groups": {+ "name": "session_groups",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "sort": {+ "name": "sort",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'public'"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "session_groups_client_id_user_id_unique": {+ "name": "session_groups_client_id_user_id_unique",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "session_groups_user_id_idx": {+ "name": "session_groups_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "session_groups_workspace_id_idx": {+ "name": "session_groups_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "session_groups_workspace_visibility_idx": {+ "name": "session_groups_workspace_visibility_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "session_groups_user_id_users_id_fk": {+ "name": "session_groups_user_id_users_id_fk",+ "tableFrom": "session_groups",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "session_groups_workspace_id_workspaces_id_fk": {+ "name": "session_groups_workspace_id_workspaces_id_fk",+ "tableFrom": "session_groups",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.sessions": {+ "name": "sessions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "slug": {+ "name": "slug",+ "type": "varchar(100)",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "avatar": {+ "name": "avatar",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "background_color": {+ "name": "background_color",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "default": "'agent'"+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "group_id": {+ "name": "group_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "pinned": {+ "name": "pinned",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "slug_user_id_unique": {+ "name": "slug_user_id_unique",+ "columns": [+ {+ "expression": "slug",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"sessions\".\"workspace_id\" is null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "sessions_client_id_user_id_unique": {+ "name": "sessions_client_id_user_id_unique",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "sessions_user_id_idx": {+ "name": "sessions_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "sessions_id_user_id_idx": {+ "name": "sessions_id_user_id_idx",+ "columns": [+ {+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "sessions_user_id_updated_at_idx": {+ "name": "sessions_user_id_updated_at_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "updated_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "sessions_group_id_idx": {+ "name": "sessions_group_id_idx",+ "columns": [+ {+ "expression": "group_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "sessions_workspace_id_idx": {+ "name": "sessions_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "sessions_slug_workspace_id_unique": {+ "name": "sessions_slug_workspace_id_unique",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "slug",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"sessions\".\"workspace_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "sessions_user_id_users_id_fk": {+ "name": "sessions_user_id_users_id_fk",+ "tableFrom": "sessions",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "sessions_group_id_session_groups_id_fk": {+ "name": "sessions_group_id_session_groups_id_fk",+ "tableFrom": "sessions",+ "tableTo": "session_groups",+ "columnsFrom": ["group_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "sessions_workspace_id_workspaces_id_fk": {+ "name": "sessions_workspace_id_workspaces_id_fk",+ "tableFrom": "sessions",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.system_bot_providers": {+ "name": "system_bot_providers",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "platform": {+ "name": "platform",+ "type": "varchar(50)",+ "primaryKey": false,+ "notNull": true+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "credentials": {+ "name": "credentials",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "application_id": {+ "name": "application_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "settings": {+ "name": "settings",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "connection_mode": {+ "name": "connection_mode",+ "type": "varchar(20)",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "system_bot_providers_platform_unique": {+ "name": "system_bot_providers_platform_unique",+ "columns": [+ {+ "expression": "platform",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.briefs": {+ "name": "briefs",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "task_id": {+ "name": "task_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "cron_job_id": {+ "name": "cron_job_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "topic_id": {+ "name": "topic_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "priority": {+ "name": "priority",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "default": "'info'"+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "summary": {+ "name": "summary",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "artifacts": {+ "name": "artifacts",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "actions": {+ "name": "actions",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "resolved_action": {+ "name": "resolved_action",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "resolved_comment": {+ "name": "resolved_comment",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "read_at": {+ "name": "read_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "resolved_at": {+ "name": "resolved_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "trigger": {+ "name": "trigger",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "briefs_user_id_idx": {+ "name": "briefs_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "briefs_task_id_idx": {+ "name": "briefs_task_id_idx",+ "columns": [+ {+ "expression": "task_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "briefs_cron_job_id_idx": {+ "name": "briefs_cron_job_id_idx",+ "columns": [+ {+ "expression": "cron_job_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "briefs_agent_id_idx": {+ "name": "briefs_agent_id_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "briefs_type_idx": {+ "name": "briefs_type_idx",+ "columns": [+ {+ "expression": "type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "briefs_priority_idx": {+ "name": "briefs_priority_idx",+ "columns": [+ {+ "expression": "priority",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "briefs_unresolved_idx": {+ "name": "briefs_unresolved_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "resolved_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "briefs_trigger_idx": {+ "name": "briefs_trigger_idx",+ "columns": [+ {+ "expression": "trigger",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "briefs_workspace_id_idx": {+ "name": "briefs_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "briefs_user_id_users_id_fk": {+ "name": "briefs_user_id_users_id_fk",+ "tableFrom": "briefs",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "briefs_workspace_id_workspaces_id_fk": {+ "name": "briefs_workspace_id_workspaces_id_fk",+ "tableFrom": "briefs",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "briefs_task_id_tasks_id_fk": {+ "name": "briefs_task_id_tasks_id_fk",+ "tableFrom": "briefs",+ "tableTo": "tasks",+ "columnsFrom": ["task_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "briefs_cron_job_id_agent_cron_jobs_id_fk": {+ "name": "briefs_cron_job_id_agent_cron_jobs_id_fk",+ "tableFrom": "briefs",+ "tableTo": "agent_cron_jobs",+ "columnsFrom": ["cron_job_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.task_comments": {+ "name": "task_comments",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "task_id": {+ "name": "task_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "author_user_id": {+ "name": "author_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "author_agent_id": {+ "name": "author_agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "editor_data": {+ "name": "editor_data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "brief_id": {+ "name": "brief_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "topic_id": {+ "name": "topic_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'public'"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "task_comments_task_id_idx": {+ "name": "task_comments_task_id_idx",+ "columns": [+ {+ "expression": "task_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_comments_user_id_idx": {+ "name": "task_comments_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_comments_author_user_id_idx": {+ "name": "task_comments_author_user_id_idx",+ "columns": [+ {+ "expression": "author_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_comments_agent_id_idx": {+ "name": "task_comments_agent_id_idx",+ "columns": [+ {+ "expression": "author_agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_comments_brief_id_idx": {+ "name": "task_comments_brief_id_idx",+ "columns": [+ {+ "expression": "brief_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_comments_topic_id_idx": {+ "name": "task_comments_topic_id_idx",+ "columns": [+ {+ "expression": "topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_comments_workspace_id_idx": {+ "name": "task_comments_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_comments_workspace_visibility_idx": {+ "name": "task_comments_workspace_visibility_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "task_comments_task_id_tasks_id_fk": {+ "name": "task_comments_task_id_tasks_id_fk",+ "tableFrom": "task_comments",+ "tableTo": "tasks",+ "columnsFrom": ["task_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "task_comments_user_id_users_id_fk": {+ "name": "task_comments_user_id_users_id_fk",+ "tableFrom": "task_comments",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "task_comments_workspace_id_workspaces_id_fk": {+ "name": "task_comments_workspace_id_workspaces_id_fk",+ "tableFrom": "task_comments",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "task_comments_author_user_id_users_id_fk": {+ "name": "task_comments_author_user_id_users_id_fk",+ "tableFrom": "task_comments",+ "tableTo": "users",+ "columnsFrom": ["author_user_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "task_comments_author_agent_id_agents_id_fk": {+ "name": "task_comments_author_agent_id_agents_id_fk",+ "tableFrom": "task_comments",+ "tableTo": "agents",+ "columnsFrom": ["author_agent_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "task_comments_brief_id_briefs_id_fk": {+ "name": "task_comments_brief_id_briefs_id_fk",+ "tableFrom": "task_comments",+ "tableTo": "briefs",+ "columnsFrom": ["brief_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "task_comments_topic_id_topics_id_fk": {+ "name": "task_comments_topic_id_topics_id_fk",+ "tableFrom": "task_comments",+ "tableTo": "topics",+ "columnsFrom": ["topic_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.task_dependencies": {+ "name": "task_dependencies",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "task_id": {+ "name": "task_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "depends_on_id": {+ "name": "depends_on_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'blocks'"+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'public'"+ },+ "condition": {+ "name": "condition",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "task_deps_unique_idx": {+ "name": "task_deps_unique_idx",+ "columns": [+ {+ "expression": "task_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "depends_on_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_deps_task_id_idx": {+ "name": "task_deps_task_id_idx",+ "columns": [+ {+ "expression": "task_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_deps_depends_on_id_idx": {+ "name": "task_deps_depends_on_id_idx",+ "columns": [+ {+ "expression": "depends_on_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_deps_user_id_idx": {+ "name": "task_deps_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_dependencies_workspace_id_idx": {+ "name": "task_dependencies_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_deps_workspace_visibility_idx": {+ "name": "task_deps_workspace_visibility_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "task_dependencies_task_id_tasks_id_fk": {+ "name": "task_dependencies_task_id_tasks_id_fk",+ "tableFrom": "task_dependencies",+ "tableTo": "tasks",+ "columnsFrom": ["task_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "task_dependencies_depends_on_id_tasks_id_fk": {+ "name": "task_dependencies_depends_on_id_tasks_id_fk",+ "tableFrom": "task_dependencies",+ "tableTo": "tasks",+ "columnsFrom": ["depends_on_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "task_dependencies_user_id_users_id_fk": {+ "name": "task_dependencies_user_id_users_id_fk",+ "tableFrom": "task_dependencies",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "task_dependencies_workspace_id_workspaces_id_fk": {+ "name": "task_dependencies_workspace_id_workspaces_id_fk",+ "tableFrom": "task_dependencies",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.task_documents": {+ "name": "task_documents",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "task_id": {+ "name": "task_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "document_id": {+ "name": "document_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "pinned_by": {+ "name": "pinned_by",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'agent'"+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'public'"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "task_docs_unique_idx": {+ "name": "task_docs_unique_idx",+ "columns": [+ {+ "expression": "task_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_docs_task_id_idx": {+ "name": "task_docs_task_id_idx",+ "columns": [+ {+ "expression": "task_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_docs_document_id_idx": {+ "name": "task_docs_document_id_idx",+ "columns": [+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_docs_user_id_idx": {+ "name": "task_docs_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_documents_workspace_id_idx": {+ "name": "task_documents_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_docs_workspace_visibility_idx": {+ "name": "task_docs_workspace_visibility_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "task_documents_task_id_tasks_id_fk": {+ "name": "task_documents_task_id_tasks_id_fk",+ "tableFrom": "task_documents",+ "tableTo": "tasks",+ "columnsFrom": ["task_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "task_documents_document_id_documents_id_fk": {+ "name": "task_documents_document_id_documents_id_fk",+ "tableFrom": "task_documents",+ "tableTo": "documents",+ "columnsFrom": ["document_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "task_documents_user_id_users_id_fk": {+ "name": "task_documents_user_id_users_id_fk",+ "tableFrom": "task_documents",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "task_documents_workspace_id_workspaces_id_fk": {+ "name": "task_documents_workspace_id_workspaces_id_fk",+ "tableFrom": "task_documents",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.task_topics": {+ "name": "task_topics",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "task_id": {+ "name": "task_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "topic_id": {+ "name": "topic_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "seq": {+ "name": "seq",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "operation_id": {+ "name": "operation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'running'"+ },+ "trigger": {+ "name": "trigger",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "handoff": {+ "name": "handoff",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "review_passed": {+ "name": "review_passed",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "review_score": {+ "name": "review_score",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "review_scores": {+ "name": "review_scores",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "review_iteration": {+ "name": "review_iteration",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "reviewed_at": {+ "name": "reviewed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'public'"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "task_topics_unique_idx": {+ "name": "task_topics_unique_idx",+ "columns": [+ {+ "expression": "task_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_topics_task_id_idx": {+ "name": "task_topics_task_id_idx",+ "columns": [+ {+ "expression": "task_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_topics_topic_id_idx": {+ "name": "task_topics_topic_id_idx",+ "columns": [+ {+ "expression": "topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_topics_user_id_idx": {+ "name": "task_topics_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_topics_status_idx": {+ "name": "task_topics_status_idx",+ "columns": [+ {+ "expression": "task_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_topics_workspace_id_idx": {+ "name": "task_topics_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "task_topics_workspace_visibility_idx": {+ "name": "task_topics_workspace_visibility_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "task_topics_task_id_tasks_id_fk": {+ "name": "task_topics_task_id_tasks_id_fk",+ "tableFrom": "task_topics",+ "tableTo": "tasks",+ "columnsFrom": ["task_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "task_topics_topic_id_topics_id_fk": {+ "name": "task_topics_topic_id_topics_id_fk",+ "tableFrom": "task_topics",+ "tableTo": "topics",+ "columnsFrom": ["topic_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "task_topics_user_id_users_id_fk": {+ "name": "task_topics_user_id_users_id_fk",+ "tableFrom": "task_topics",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "task_topics_workspace_id_workspaces_id_fk": {+ "name": "task_topics_workspace_id_workspaces_id_fk",+ "tableFrom": "task_topics",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.tasks": {+ "name": "tasks",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "identifier": {+ "name": "identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "seq": {+ "name": "seq",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "project_id": {+ "name": "project_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "assignee_user_id": {+ "name": "assignee_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "assignee_agent_id": {+ "name": "assignee_agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "parent_task_id": {+ "name": "parent_task_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "description": {+ "name": "description",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "instruction": {+ "name": "instruction",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "editor_data": {+ "name": "editor_data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'backlog'"+ },+ "priority": {+ "name": "priority",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "default": 0+ },+ "sort_order": {+ "name": "sort_order",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "default": 0+ },+ "automation_mode": {+ "name": "automation_mode",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "heartbeat_interval": {+ "name": "heartbeat_interval",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "heartbeat_timeout": {+ "name": "heartbeat_timeout",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "last_heartbeat_at": {+ "name": "last_heartbeat_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "schedule_pattern": {+ "name": "schedule_pattern",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "schedule_timezone": {+ "name": "schedule_timezone",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "default": "'UTC'"+ },+ "total_topics": {+ "name": "total_topics",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "default": 0+ },+ "max_topics": {+ "name": "max_topics",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "current_topic_id": {+ "name": "current_topic_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "context": {+ "name": "context",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false,+ "default": "'{}'::jsonb"+ },+ "config": {+ "name": "config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false,+ "default": "'{}'::jsonb"+ },+ "error": {+ "name": "error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'public'"+ },+ "started_at": {+ "name": "started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "completed_at": {+ "name": "completed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "tasks_identifier_idx": {+ "name": "tasks_identifier_idx",+ "columns": [+ {+ "expression": "identifier",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_by_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"tasks\".\"workspace_id\" is null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tasks_created_by_user_id_idx": {+ "name": "tasks_created_by_user_id_idx",+ "columns": [+ {+ "expression": "created_by_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tasks_created_by_agent_id_idx": {+ "name": "tasks_created_by_agent_id_idx",+ "columns": [+ {+ "expression": "created_by_agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tasks_assignee_user_id_idx": {+ "name": "tasks_assignee_user_id_idx",+ "columns": [+ {+ "expression": "assignee_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tasks_assignee_agent_id_idx": {+ "name": "tasks_assignee_agent_id_idx",+ "columns": [+ {+ "expression": "assignee_agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tasks_parent_task_id_idx": {+ "name": "tasks_parent_task_id_idx",+ "columns": [+ {+ "expression": "parent_task_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tasks_status_idx": {+ "name": "tasks_status_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tasks_priority_idx": {+ "name": "tasks_priority_idx",+ "columns": [+ {+ "expression": "priority",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tasks_automation_mode_idx": {+ "name": "tasks_automation_mode_idx",+ "columns": [+ {+ "expression": "automation_mode",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tasks_heartbeat_idx": {+ "name": "tasks_heartbeat_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "last_heartbeat_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tasks_workspace_id_idx": {+ "name": "tasks_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tasks_project_id_status_idx": {+ "name": "tasks_project_id_status_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tasks_workspace_visibility_idx": {+ "name": "tasks_workspace_visibility_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_by_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "tasks_identifier_workspace_id_unique": {+ "name": "tasks_identifier_workspace_id_unique",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "identifier",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"tasks\".\"workspace_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "tasks_created_by_user_id_users_id_fk": {+ "name": "tasks_created_by_user_id_users_id_fk",+ "tableFrom": "tasks",+ "tableTo": "users",+ "columnsFrom": ["created_by_user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "tasks_workspace_id_workspaces_id_fk": {+ "name": "tasks_workspace_id_workspaces_id_fk",+ "tableFrom": "tasks",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "tasks_project_id_projects_id_fk": {+ "name": "tasks_project_id_projects_id_fk",+ "tableFrom": "tasks",+ "tableTo": "projects",+ "columnsFrom": ["project_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tasks_created_by_agent_id_agents_id_fk": {+ "name": "tasks_created_by_agent_id_agents_id_fk",+ "tableFrom": "tasks",+ "tableTo": "agents",+ "columnsFrom": ["created_by_agent_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tasks_assignee_user_id_users_id_fk": {+ "name": "tasks_assignee_user_id_users_id_fk",+ "tableFrom": "tasks",+ "tableTo": "users",+ "columnsFrom": ["assignee_user_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tasks_assignee_agent_id_agents_id_fk": {+ "name": "tasks_assignee_agent_id_agents_id_fk",+ "tableFrom": "tasks",+ "tableTo": "agents",+ "columnsFrom": ["assignee_agent_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tasks_current_topic_id_topics_id_fk": {+ "name": "tasks_current_topic_id_topics_id_fk",+ "tableFrom": "tasks",+ "tableTo": "topics",+ "columnsFrom": ["current_topic_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "tasks_parent_task_id_tasks_id_fk": {+ "name": "tasks_parent_task_id_tasks_id_fk",+ "tableFrom": "tasks",+ "tableTo": "tasks",+ "columnsFrom": ["parent_task_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.threads": {+ "name": "threads",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "editor_data": {+ "name": "editor_data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "topic_id": {+ "name": "topic_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source_message_id": {+ "name": "source_message_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "parent_thread_id": {+ "name": "parent_thread_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "group_id": {+ "name": "group_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "last_active_at": {+ "name": "last_active_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false,+ "default": "now()"+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "threads_client_id_user_id_unique": {+ "name": "threads_client_id_user_id_unique",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "threads_user_id_idx": {+ "name": "threads_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "threads_topic_id_idx": {+ "name": "threads_topic_id_idx",+ "columns": [+ {+ "expression": "topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "threads_type_idx": {+ "name": "threads_type_idx",+ "columns": [+ {+ "expression": "type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "threads_agent_id_idx": {+ "name": "threads_agent_id_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "threads_group_id_idx": {+ "name": "threads_group_id_idx",+ "columns": [+ {+ "expression": "group_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "threads_parent_thread_id_idx": {+ "name": "threads_parent_thread_id_idx",+ "columns": [+ {+ "expression": "parent_thread_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "threads_workspace_id_idx": {+ "name": "threads_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "threads_topic_id_topics_id_fk": {+ "name": "threads_topic_id_topics_id_fk",+ "tableFrom": "threads",+ "tableTo": "topics",+ "columnsFrom": ["topic_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "threads_parent_thread_id_threads_id_fk": {+ "name": "threads_parent_thread_id_threads_id_fk",+ "tableFrom": "threads",+ "tableTo": "threads",+ "columnsFrom": ["parent_thread_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "threads_agent_id_agents_id_fk": {+ "name": "threads_agent_id_agents_id_fk",+ "tableFrom": "threads",+ "tableTo": "agents",+ "columnsFrom": ["agent_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "threads_group_id_chat_groups_id_fk": {+ "name": "threads_group_id_chat_groups_id_fk",+ "tableFrom": "threads",+ "tableTo": "chat_groups",+ "columnsFrom": ["group_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "threads_user_id_users_id_fk": {+ "name": "threads_user_id_users_id_fk",+ "tableFrom": "threads",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "threads_workspace_id_workspaces_id_fk": {+ "name": "threads_workspace_id_workspaces_id_fk",+ "tableFrom": "threads",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.topic_documents": {+ "name": "topic_documents",+ "schema": "",+ "columns": {+ "document_id": {+ "name": "document_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "topic_id": {+ "name": "topic_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "topic_documents_user_id_idx": {+ "name": "topic_documents_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topic_documents_topic_id_idx": {+ "name": "topic_documents_topic_id_idx",+ "columns": [+ {+ "expression": "topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topic_documents_document_id_idx": {+ "name": "topic_documents_document_id_idx",+ "columns": [+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topic_documents_workspace_id_idx": {+ "name": "topic_documents_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "topic_documents_document_id_documents_id_fk": {+ "name": "topic_documents_document_id_documents_id_fk",+ "tableFrom": "topic_documents",+ "tableTo": "documents",+ "columnsFrom": ["document_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "topic_documents_topic_id_topics_id_fk": {+ "name": "topic_documents_topic_id_topics_id_fk",+ "tableFrom": "topic_documents",+ "tableTo": "topics",+ "columnsFrom": ["topic_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "topic_documents_user_id_users_id_fk": {+ "name": "topic_documents_user_id_users_id_fk",+ "tableFrom": "topic_documents",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "topic_documents_workspace_id_workspaces_id_fk": {+ "name": "topic_documents_workspace_id_workspaces_id_fk",+ "tableFrom": "topic_documents",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "topic_documents_document_id_topic_id_pk": {+ "name": "topic_documents_document_id_topic_id_pk",+ "columns": ["document_id", "topic_id"]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.topic_shares": {+ "name": "topic_shares",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "topic_id": {+ "name": "topic_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'private'"+ },+ "page_view_count": {+ "name": "page_view_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "topic_shares_topic_id_unique": {+ "name": "topic_shares_topic_id_unique",+ "columns": [+ {+ "expression": "topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topic_shares_user_id_idx": {+ "name": "topic_shares_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topic_shares_workspace_id_idx": {+ "name": "topic_shares_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "topic_shares_topic_id_topics_id_fk": {+ "name": "topic_shares_topic_id_topics_id_fk",+ "tableFrom": "topic_shares",+ "tableTo": "topics",+ "columnsFrom": ["topic_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "topic_shares_user_id_users_id_fk": {+ "name": "topic_shares_user_id_users_id_fk",+ "tableFrom": "topic_shares",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "topic_shares_workspace_id_workspaces_id_fk": {+ "name": "topic_shares_workspace_id_workspaces_id_fk",+ "tableFrom": "topic_shares",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.topics": {+ "name": "topics",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "favorite": {+ "name": "favorite",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": false+ },+ "session_id": {+ "name": "session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "editor_data": {+ "name": "editor_data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "group_id": {+ "name": "group_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "history_summary": {+ "name": "history_summary",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "trigger": {+ "name": "trigger",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "mode": {+ "name": "mode",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "completed_at": {+ "name": "completed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "total_cost": {+ "name": "total_cost",+ "type": "numeric(20, 6)",+ "primaryKey": false,+ "notNull": false+ },+ "total_input_tokens": {+ "name": "total_input_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "total_output_tokens": {+ "name": "total_output_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "total_tokens": {+ "name": "total_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "cost": {+ "name": "cost",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "usage": {+ "name": "usage",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "model": {+ "name": "model",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "sender_id": {+ "name": "sender_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "topics_client_id_user_id_unique": {+ "name": "topics_client_id_user_id_unique",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topics_created_at_idx": {+ "name": "topics_created_at_idx",+ "columns": [+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topics_user_id_idx": {+ "name": "topics_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topics_id_user_id_idx": {+ "name": "topics_id_user_id_idx",+ "columns": [+ {+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topics_session_id_idx": {+ "name": "topics_session_id_idx",+ "columns": [+ {+ "expression": "session_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topics_group_id_idx": {+ "name": "topics_group_id_idx",+ "columns": [+ {+ "expression": "group_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topics_agent_id_idx": {+ "name": "topics_agent_id_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topics_trigger_idx": {+ "name": "topics_trigger_idx",+ "columns": [+ {+ "expression": "trigger",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topics_status_idx": {+ "name": "topics_status_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topics_model_idx": {+ "name": "topics_model_idx",+ "columns": [+ {+ "expression": "model",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topics_provider_idx": {+ "name": "topics_provider_idx",+ "columns": [+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topics_user_id_completed_at_idx": {+ "name": "topics_user_id_completed_at_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "completed_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topics_sender_id_idx": {+ "name": "topics_sender_id_idx",+ "columns": [+ {+ "expression": "sender_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topics_workspace_id_idx": {+ "name": "topics_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topics_extract_status_gin_idx": {+ "name": "topics_extract_status_gin_idx",+ "columns": [+ {+ "expression": "(metadata->'userMemoryExtractStatus') jsonb_path_ops",+ "asc": true,+ "isExpression": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "gin",+ "with": {}+ }+ },+ "foreignKeys": {+ "topics_session_id_sessions_id_fk": {+ "name": "topics_session_id_sessions_id_fk",+ "tableFrom": "topics",+ "tableTo": "sessions",+ "columnsFrom": ["session_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "topics_agent_id_agents_id_fk": {+ "name": "topics_agent_id_agents_id_fk",+ "tableFrom": "topics",+ "tableTo": "agents",+ "columnsFrom": ["agent_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "topics_group_id_chat_groups_id_fk": {+ "name": "topics_group_id_chat_groups_id_fk",+ "tableFrom": "topics",+ "tableTo": "chat_groups",+ "columnsFrom": ["group_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "topics_user_id_users_id_fk": {+ "name": "topics_user_id_users_id_fk",+ "tableFrom": "topics",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "topics_workspace_id_workspaces_id_fk": {+ "name": "topics_workspace_id_workspaces_id_fk",+ "tableFrom": "topics",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.topic_comment_mentions": {+ "name": "topic_comment_mentions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "comment_id": {+ "name": "comment_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "mentioned_user_id": {+ "name": "mentioned_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "topic_comment_mentions_comment_id_mentioned_user_id_unique": {+ "name": "topic_comment_mentions_comment_id_mentioned_user_id_unique",+ "columns": [+ {+ "expression": "comment_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "mentioned_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topic_comment_mentions_mentioned_user_id_created_at_idx": {+ "name": "topic_comment_mentions_mentioned_user_id_created_at_idx",+ "columns": [+ {+ "expression": "mentioned_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topic_comment_mentions_workspace_id_idx": {+ "name": "topic_comment_mentions_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "topic_comment_mentions_comment_id_topic_comments_id_fk": {+ "name": "topic_comment_mentions_comment_id_topic_comments_id_fk",+ "tableFrom": "topic_comment_mentions",+ "tableTo": "topic_comments",+ "columnsFrom": ["comment_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "topic_comment_mentions_mentioned_user_id_users_id_fk": {+ "name": "topic_comment_mentions_mentioned_user_id_users_id_fk",+ "tableFrom": "topic_comment_mentions",+ "tableTo": "users",+ "columnsFrom": ["mentioned_user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "topic_comment_mentions_workspace_id_workspaces_id_fk": {+ "name": "topic_comment_mentions_workspace_id_workspaces_id_fk",+ "tableFrom": "topic_comment_mentions",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.topic_comments": {+ "name": "topic_comments",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "topic_id": {+ "name": "topic_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "message_id": {+ "name": "message_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "parent_comment_id": {+ "name": "parent_comment_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "author_user_id": {+ "name": "author_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "editor_data": {+ "name": "editor_data",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "anchor_preview": {+ "name": "anchor_preview",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "moderated_at": {+ "name": "moderated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "moderated_by_user_id": {+ "name": "moderated_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "moderation_expires_at": {+ "name": "moderation_expires_at",+ "type": "timestamp with time zone",+ "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": {+ "topic_comments_topic_id_author_user_id_client_id_unique": {+ "name": "topic_comments_topic_id_author_user_id_client_id_unique",+ "columns": [+ {+ "expression": "topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "author_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topic_comments_parent_comment_id_created_at_id_idx": {+ "name": "topic_comments_parent_comment_id_created_at_id_idx",+ "columns": [+ {+ "expression": "parent_comment_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topic_comments_topic_id_created_at_id_idx": {+ "name": "topic_comments_topic_id_created_at_id_idx",+ "columns": [+ {+ "expression": "topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topic_comments_topic_id_message_id_idx": {+ "name": "topic_comments_topic_id_message_id_idx",+ "columns": [+ {+ "expression": "topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "message_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topic_comments_message_id_idx": {+ "name": "topic_comments_message_id_idx",+ "columns": [+ {+ "expression": "message_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topic_comments_author_user_id_idx": {+ "name": "topic_comments_author_user_id_idx",+ "columns": [+ {+ "expression": "author_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topic_comments_moderation_expires_at_idx": {+ "name": "topic_comments_moderation_expires_at_idx",+ "columns": [+ {+ "expression": "moderation_expires_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topic_comments_moderated_by_user_id_idx": {+ "name": "topic_comments_moderated_by_user_id_idx",+ "columns": [+ {+ "expression": "moderated_by_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "topic_comments_workspace_id_idx": {+ "name": "topic_comments_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "topic_comments_topic_id_topics_id_fk": {+ "name": "topic_comments_topic_id_topics_id_fk",+ "tableFrom": "topic_comments",+ "tableTo": "topics",+ "columnsFrom": ["topic_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "topic_comments_message_id_messages_id_fk": {+ "name": "topic_comments_message_id_messages_id_fk",+ "tableFrom": "topic_comments",+ "tableTo": "messages",+ "columnsFrom": ["message_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "topic_comments_parent_comment_id_topic_comments_id_fk": {+ "name": "topic_comments_parent_comment_id_topic_comments_id_fk",+ "tableFrom": "topic_comments",+ "tableTo": "topic_comments",+ "columnsFrom": ["parent_comment_id"],+ "columnsTo": ["id"],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "topic_comments_author_user_id_users_id_fk": {+ "name": "topic_comments_author_user_id_users_id_fk",+ "tableFrom": "topic_comments",+ "tableTo": "users",+ "columnsFrom": ["author_user_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "topic_comments_workspace_id_workspaces_id_fk": {+ "name": "topic_comments_workspace_id_workspaces_id_fk",+ "tableFrom": "topic_comments",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "topic_comments_moderated_by_user_id_users_id_fk": {+ "name": "topic_comments_moderated_by_user_id_users_id_fk",+ "tableFrom": "topic_comments",+ "tableTo": "users",+ "columnsFrom": ["moderated_by_user_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "topic_comments_anchored_requires_preview": {+ "name": "topic_comments_anchored_requires_preview",+ "value": "\"topic_comments\".\"message_id\" IS NULL OR \"topic_comments\".\"anchor_preview\" IS NOT NULL"+ },+ "topic_comments_reply_has_no_anchor": {+ "name": "topic_comments_reply_has_no_anchor",+ "value": "\"topic_comments\".\"parent_comment_id\" IS NULL OR (\"topic_comments\".\"message_id\" IS NULL AND \"topic_comments\".\"anchor_preview\" IS NULL)"+ },+ "topic_comments_moderation_window_consistent": {+ "name": "topic_comments_moderation_window_consistent",+ "value": "(\"topic_comments\".\"moderated_at\" IS NULL) = (\"topic_comments\".\"moderation_expires_at\" IS NULL)"+ },+ "topic_comments_deleted_not_recoverable": {+ "name": "topic_comments_deleted_not_recoverable",+ "value": "\"topic_comments\".\"deleted_at\" IS NULL OR \"topic_comments\".\"moderated_at\" IS NULL"+ }+ },+ "isRLSEnabled": false+ },+ "public.user_settings": {+ "name": "user_settings",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "tts": {+ "name": "tts",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "hotkey": {+ "name": "hotkey",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "key_vaults": {+ "name": "key_vaults",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "general": {+ "name": "general",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "language_model": {+ "name": "language_model",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "system_agent": {+ "name": "system_agent",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "default_agent": {+ "name": "default_agent",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "market": {+ "name": "market",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "memory": {+ "name": "memory",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "tool": {+ "name": "tool",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "image": {+ "name": "image",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "notification": {+ "name": "notification",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "user_settings_id_users_id_fk": {+ "name": "user_settings_id_users_id_fk",+ "tableFrom": "user_settings",+ "tableTo": "users",+ "columnsFrom": ["id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.users": {+ "name": "users",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "username": {+ "name": "username",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "email": {+ "name": "email",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "normalized_email": {+ "name": "normalized_email",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "avatar": {+ "name": "avatar",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "phone": {+ "name": "phone",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "first_name": {+ "name": "first_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "last_name": {+ "name": "last_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "full_name": {+ "name": "full_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "interests": {+ "name": "interests",+ "type": "varchar(64)[]",+ "primaryKey": false,+ "notNull": false+ },+ "is_onboarded": {+ "name": "is_onboarded",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": false+ },+ "agent_onboarding": {+ "name": "agent_onboarding",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "onboarding": {+ "name": "onboarding",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "clerk_created_at": {+ "name": "clerk_created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "email_verified": {+ "name": "email_verified",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "email_verified_at": {+ "name": "email_verified_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "preference": {+ "name": "preference",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "banned": {+ "name": "banned",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": false+ },+ "ban_reason": {+ "name": "ban_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "ban_expires": {+ "name": "ban_expires",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "two_factor_enabled": {+ "name": "two_factor_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": false+ },+ "phone_number_verified": {+ "name": "phone_number_verified",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "last_active_at": {+ "name": "last_active_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "users_email_idx": {+ "name": "users_email_idx",+ "columns": [+ {+ "expression": "email",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "users_username_idx": {+ "name": "users_username_idx",+ "columns": [+ {+ "expression": "username",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "users_created_at_idx": {+ "name": "users_created_at_idx",+ "columns": [+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "users_banned_true_created_at_idx": {+ "name": "users_banned_true_created_at_idx",+ "columns": [+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"users\".\"banned\" = true",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "users_username_unique": {+ "name": "users_username_unique",+ "nullsNotDistinct": false,+ "columns": ["username"]+ },+ "users_email_unique": {+ "name": "users_email_unique",+ "nullsNotDistinct": false,+ "columns": ["email"]+ },+ "users_normalized_email_unique": {+ "name": "users_normalized_email_unique",+ "nullsNotDistinct": false,+ "columns": ["normalized_email"]+ },+ "users_phone_unique": {+ "name": "users_phone_unique",+ "nullsNotDistinct": false,+ "columns": ["phone"]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_memories": {+ "name": "user_memories",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "memory_category": {+ "name": "memory_category",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "memory_layer": {+ "name": "memory_layer",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "memory_type": {+ "name": "memory_type",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "tags": {+ "name": "tags",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "title": {+ "name": "title",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "summary": {+ "name": "summary",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "summary_vector_1024": {+ "name": "summary_vector_1024",+ "type": "vector(1024)",+ "primaryKey": false,+ "notNull": false+ },+ "details": {+ "name": "details",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "details_vector_1024": {+ "name": "details_vector_1024",+ "type": "vector(1024)",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_count": {+ "name": "accessed_count",+ "type": "bigint",+ "primaryKey": false,+ "notNull": false,+ "default": 0+ },+ "last_accessed_at": {+ "name": "last_accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "captured_at": {+ "name": "captured_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "user_memories_summary_vector_1024_index": {+ "name": "user_memories_summary_vector_1024_index",+ "columns": [+ {+ "expression": "summary_vector_1024",+ "isExpression": false,+ "asc": true,+ "nulls": "last",+ "opclass": "vector_cosine_ops"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "hnsw",+ "with": {}+ },+ "user_memories_details_vector_1024_index": {+ "name": "user_memories_details_vector_1024_index",+ "columns": [+ {+ "expression": "details_vector_1024",+ "isExpression": false,+ "asc": true,+ "nulls": "last",+ "opclass": "vector_cosine_ops"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "hnsw",+ "with": {}+ },+ "user_memories_user_id_index": {+ "name": "user_memories_user_id_index",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "user_memories_user_id_users_id_fk": {+ "name": "user_memories_user_id_users_id_fk",+ "tableFrom": "user_memories",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_memories_activities": {+ "name": "user_memories_activities",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_memory_id": {+ "name": "user_memory_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "tags": {+ "name": "tags",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "timezone": {+ "name": "timezone",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "starts_at": {+ "name": "starts_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "ends_at": {+ "name": "ends_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "associated_objects": {+ "name": "associated_objects",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "associated_subjects": {+ "name": "associated_subjects",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "associated_locations": {+ "name": "associated_locations",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "notes": {+ "name": "notes",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "narrative": {+ "name": "narrative",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "narrative_vector": {+ "name": "narrative_vector",+ "type": "vector(1024)",+ "primaryKey": false,+ "notNull": false+ },+ "feedback": {+ "name": "feedback",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "feedback_vector": {+ "name": "feedback_vector",+ "type": "vector(1024)",+ "primaryKey": false,+ "notNull": false+ },+ "captured_at": {+ "name": "captured_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "user_memories_activities_narrative_vector_index": {+ "name": "user_memories_activities_narrative_vector_index",+ "columns": [+ {+ "expression": "narrative_vector",+ "isExpression": false,+ "asc": true,+ "nulls": "last",+ "opclass": "vector_cosine_ops"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "hnsw",+ "with": {}+ },+ "user_memories_activities_feedback_vector_index": {+ "name": "user_memories_activities_feedback_vector_index",+ "columns": [+ {+ "expression": "feedback_vector",+ "isExpression": false,+ "asc": true,+ "nulls": "last",+ "opclass": "vector_cosine_ops"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "hnsw",+ "with": {}+ },+ "user_memories_activities_type_index": {+ "name": "user_memories_activities_type_index",+ "columns": [+ {+ "expression": "type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_activities_user_id_index": {+ "name": "user_memories_activities_user_id_index",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_activities_user_memory_id_index": {+ "name": "user_memories_activities_user_memory_id_index",+ "columns": [+ {+ "expression": "user_memory_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_activities_status_index": {+ "name": "user_memories_activities_status_index",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "user_memories_activities_user_id_users_id_fk": {+ "name": "user_memories_activities_user_id_users_id_fk",+ "tableFrom": "user_memories_activities",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_memories_activities_user_memory_id_user_memories_id_fk": {+ "name": "user_memories_activities_user_memory_id_user_memories_id_fk",+ "tableFrom": "user_memories_activities",+ "tableTo": "user_memories",+ "columnsFrom": ["user_memory_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_memories_contexts": {+ "name": "user_memories_contexts",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_memory_ids": {+ "name": "user_memory_ids",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "tags": {+ "name": "tags",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "associated_objects": {+ "name": "associated_objects",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "associated_subjects": {+ "name": "associated_subjects",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "description_vector": {+ "name": "description_vector",+ "type": "vector(1024)",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "current_status": {+ "name": "current_status",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "score_impact": {+ "name": "score_impact",+ "type": "numeric",+ "primaryKey": false,+ "notNull": false,+ "default": 0+ },+ "score_urgency": {+ "name": "score_urgency",+ "type": "numeric",+ "primaryKey": false,+ "notNull": false,+ "default": 0+ },+ "captured_at": {+ "name": "captured_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "user_memories_contexts_description_vector_index": {+ "name": "user_memories_contexts_description_vector_index",+ "columns": [+ {+ "expression": "description_vector",+ "isExpression": false,+ "asc": true,+ "nulls": "last",+ "opclass": "vector_cosine_ops"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "hnsw",+ "with": {}+ },+ "user_memories_contexts_type_index": {+ "name": "user_memories_contexts_type_index",+ "columns": [+ {+ "expression": "type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_contexts_user_id_index": {+ "name": "user_memories_contexts_user_id_index",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "user_memories_contexts_user_id_users_id_fk": {+ "name": "user_memories_contexts_user_id_users_id_fk",+ "tableFrom": "user_memories_contexts",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_memories_experiences": {+ "name": "user_memories_experiences",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_memory_id": {+ "name": "user_memory_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "tags": {+ "name": "tags",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "situation": {+ "name": "situation",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "situation_vector": {+ "name": "situation_vector",+ "type": "vector(1024)",+ "primaryKey": false,+ "notNull": false+ },+ "reasoning": {+ "name": "reasoning",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "possible_outcome": {+ "name": "possible_outcome",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "action": {+ "name": "action",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "action_vector": {+ "name": "action_vector",+ "type": "vector(1024)",+ "primaryKey": false,+ "notNull": false+ },+ "key_learning": {+ "name": "key_learning",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "key_learning_vector": {+ "name": "key_learning_vector",+ "type": "vector(1024)",+ "primaryKey": false,+ "notNull": false+ },+ "score_confidence": {+ "name": "score_confidence",+ "type": "real",+ "primaryKey": false,+ "notNull": false,+ "default": 0+ },+ "captured_at": {+ "name": "captured_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "user_memories_experiences_situation_vector_index": {+ "name": "user_memories_experiences_situation_vector_index",+ "columns": [+ {+ "expression": "situation_vector",+ "isExpression": false,+ "asc": true,+ "nulls": "last",+ "opclass": "vector_cosine_ops"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "hnsw",+ "with": {}+ },+ "user_memories_experiences_action_vector_index": {+ "name": "user_memories_experiences_action_vector_index",+ "columns": [+ {+ "expression": "action_vector",+ "isExpression": false,+ "asc": true,+ "nulls": "last",+ "opclass": "vector_cosine_ops"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "hnsw",+ "with": {}+ },+ "user_memories_experiences_key_learning_vector_index": {+ "name": "user_memories_experiences_key_learning_vector_index",+ "columns": [+ {+ "expression": "key_learning_vector",+ "isExpression": false,+ "asc": true,+ "nulls": "last",+ "opclass": "vector_cosine_ops"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "hnsw",+ "with": {}+ },+ "user_memories_experiences_type_index": {+ "name": "user_memories_experiences_type_index",+ "columns": [+ {+ "expression": "type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_experiences_user_id_index": {+ "name": "user_memories_experiences_user_id_index",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_experiences_user_memory_id_index": {+ "name": "user_memories_experiences_user_memory_id_index",+ "columns": [+ {+ "expression": "user_memory_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "user_memories_experiences_user_id_users_id_fk": {+ "name": "user_memories_experiences_user_id_users_id_fk",+ "tableFrom": "user_memories_experiences",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_memories_experiences_user_memory_id_user_memories_id_fk": {+ "name": "user_memories_experiences_user_memory_id_user_memories_id_fk",+ "tableFrom": "user_memories_experiences",+ "tableTo": "user_memories",+ "columnsFrom": ["user_memory_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_memories_identities": {+ "name": "user_memories_identities",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_memory_id": {+ "name": "user_memory_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "tags": {+ "name": "tags",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "description_vector": {+ "name": "description_vector",+ "type": "vector(1024)",+ "primaryKey": false,+ "notNull": false+ },+ "episodic_date": {+ "name": "episodic_date",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "relationship": {+ "name": "relationship",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "captured_at": {+ "name": "captured_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "user_memories_identities_description_vector_index": {+ "name": "user_memories_identities_description_vector_index",+ "columns": [+ {+ "expression": "description_vector",+ "isExpression": false,+ "asc": true,+ "nulls": "last",+ "opclass": "vector_cosine_ops"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "hnsw",+ "with": {}+ },+ "user_memories_identities_type_index": {+ "name": "user_memories_identities_type_index",+ "columns": [+ {+ "expression": "type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_identities_user_id_index": {+ "name": "user_memories_identities_user_id_index",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_identities_user_memory_id_index": {+ "name": "user_memories_identities_user_memory_id_index",+ "columns": [+ {+ "expression": "user_memory_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "user_memories_identities_user_id_users_id_fk": {+ "name": "user_memories_identities_user_id_users_id_fk",+ "tableFrom": "user_memories_identities",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_memories_identities_user_memory_id_user_memories_id_fk": {+ "name": "user_memories_identities_user_memory_id_user_memories_id_fk",+ "tableFrom": "user_memories_identities",+ "tableTo": "user_memories",+ "columnsFrom": ["user_memory_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_memories_preferences": {+ "name": "user_memories_preferences",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_memory_id": {+ "name": "user_memory_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "tags": {+ "name": "tags",+ "type": "text[]",+ "primaryKey": false,+ "notNull": false+ },+ "conclusion_directives": {+ "name": "conclusion_directives",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "conclusion_directives_vector": {+ "name": "conclusion_directives_vector",+ "type": "vector(1024)",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "suggestions": {+ "name": "suggestions",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "score_priority": {+ "name": "score_priority",+ "type": "numeric",+ "primaryKey": false,+ "notNull": false,+ "default": 0+ },+ "captured_at": {+ "name": "captured_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "user_memories_preferences_conclusion_directives_vector_index": {+ "name": "user_memories_preferences_conclusion_directives_vector_index",+ "columns": [+ {+ "expression": "conclusion_directives_vector",+ "isExpression": false,+ "asc": true,+ "nulls": "last",+ "opclass": "vector_cosine_ops"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "hnsw",+ "with": {}+ },+ "user_memories_preferences_user_id_index": {+ "name": "user_memories_preferences_user_id_index",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_memories_preferences_user_memory_id_index": {+ "name": "user_memories_preferences_user_memory_id_index",+ "columns": [+ {+ "expression": "user_memory_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "user_memories_preferences_user_id_users_id_fk": {+ "name": "user_memories_preferences_user_id_users_id_fk",+ "tableFrom": "user_memories_preferences",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_memories_preferences_user_memory_id_user_memories_id_fk": {+ "name": "user_memories_preferences_user_memory_id_user_memories_id_fk",+ "tableFrom": "user_memories_preferences",+ "tableTo": "user_memories",+ "columnsFrom": ["user_memory_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_memory_persona_document_histories": {+ "name": "user_memory_persona_document_histories",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "persona_id": {+ "name": "persona_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "profile": {+ "name": "profile",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "default": "'default'"+ },+ "snapshot_persona": {+ "name": "snapshot_persona",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "snapshot_tagline": {+ "name": "snapshot_tagline",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "reasoning": {+ "name": "reasoning",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "diff_persona": {+ "name": "diff_persona",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "diff_tagline": {+ "name": "diff_tagline",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "snapshot": {+ "name": "snapshot",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "summary": {+ "name": "summary",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "edited_by": {+ "name": "edited_by",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "default": "'agent'"+ },+ "memory_ids": {+ "name": "memory_ids",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "source_ids": {+ "name": "source_ids",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "previous_version": {+ "name": "previous_version",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "next_version": {+ "name": "next_version",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "captured_at": {+ "name": "captured_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "user_persona_document_histories_persona_id_index": {+ "name": "user_persona_document_histories_persona_id_index",+ "columns": [+ {+ "expression": "persona_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_persona_document_histories_user_id_index": {+ "name": "user_persona_document_histories_user_id_index",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_persona_document_histories_profile_index": {+ "name": "user_persona_document_histories_profile_index",+ "columns": [+ {+ "expression": "profile",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "user_memory_persona_document_histories_user_id_users_id_fk": {+ "name": "user_memory_persona_document_histories_user_id_users_id_fk",+ "tableFrom": "user_memory_persona_document_histories",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_memory_persona_document_histories_persona_id_user_memory_persona_documents_id_fk": {+ "name": "user_memory_persona_document_histories_persona_id_user_memory_persona_documents_id_fk",+ "tableFrom": "user_memory_persona_document_histories",+ "tableTo": "user_memory_persona_documents",+ "columnsFrom": ["persona_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_memory_persona_documents": {+ "name": "user_memory_persona_documents",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(255)",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "profile": {+ "name": "profile",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "default": "'default'"+ },+ "tagline": {+ "name": "tagline",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "persona": {+ "name": "persona",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "memory_ids": {+ "name": "memory_ids",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "source_ids": {+ "name": "source_ids",+ "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+ },+ "captured_at": {+ "name": "captured_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "user_persona_documents_user_id_profile_unique": {+ "name": "user_persona_documents_user_id_profile_unique",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "profile",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_persona_documents_user_id_index": {+ "name": "user_persona_documents_user_id_index",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "user_memory_persona_documents_user_id_users_id_fk": {+ "name": "user_memory_persona_documents_user_id_users_id_fk",+ "tableFrom": "user_memory_persona_documents",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.acceptances": {+ "name": "acceptances",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "project_id": {+ "name": "project_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "subject_type": {+ "name": "subject_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "subject_id": {+ "name": "subject_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'public'"+ },+ "requirement": {+ "name": "requirement",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "config": {+ "name": "config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false,+ "default": "'{}'::jsonb"+ },+ "visual_render": {+ "name": "visual_render",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "completed_at": {+ "name": "completed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "acceptances_user_id_idx": {+ "name": "acceptances_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "acceptances_workspace_id_idx": {+ "name": "acceptances_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "acceptances_project_id_idx": {+ "name": "acceptances_project_id_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "acceptances_subject_idx": {+ "name": "acceptances_subject_idx",+ "columns": [+ {+ "expression": "subject_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "subject_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "acceptances_status_idx": {+ "name": "acceptances_status_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "acceptances_workspace_visibility_idx": {+ "name": "acceptances_workspace_visibility_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "acceptances_personal_subject_unique": {+ "name": "acceptances_personal_subject_unique",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "subject_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "subject_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"acceptances\".\"workspace_id\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "acceptances_workspace_subject_unique": {+ "name": "acceptances_workspace_subject_unique",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "subject_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "subject_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"acceptances\".\"workspace_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "acceptances_user_id_users_id_fk": {+ "name": "acceptances_user_id_users_id_fk",+ "tableFrom": "acceptances",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "acceptances_workspace_id_workspaces_id_fk": {+ "name": "acceptances_workspace_id_workspaces_id_fk",+ "tableFrom": "acceptances",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "acceptances_project_id_projects_id_fk": {+ "name": "acceptances_project_id_projects_id_fk",+ "tableFrom": "acceptances",+ "tableTo": "projects",+ "columnsFrom": ["project_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.verify_check_results": {+ "name": "verify_check_results",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "verify_run_id": {+ "name": "verify_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "operation_id": {+ "name": "operation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "check_item_id": {+ "name": "check_item_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "check_item_title": {+ "name": "check_item_title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "required": {+ "name": "required",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "check_item_index": {+ "name": "check_item_index",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "verifier_type": {+ "name": "verifier_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "verifier_config_hash": {+ "name": "verifier_config_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "verifier_operation_id": {+ "name": "verifier_operation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "verifier_tracing_id": {+ "name": "verifier_tracing_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "verdict": {+ "name": "verdict",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "confidence": {+ "name": "confidence",+ "type": "numeric(3, 2)",+ "primaryKey": false,+ "notNull": false+ },+ "toulmin": {+ "name": "toulmin",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "suggestion": {+ "name": "suggestion",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_decision": {+ "name": "user_decision",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_decision_detail": {+ "name": "user_decision_detail",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "is_false_positive": {+ "name": "is_false_positive",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "is_false_negative": {+ "name": "is_false_negative",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "repair_operation_id": {+ "name": "repair_operation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "started_at": {+ "name": "started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "completed_at": {+ "name": "completed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "verify_check_results_verify_run_id_idx": {+ "name": "verify_check_results_verify_run_id_idx",+ "columns": [+ {+ "expression": "verify_run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_check_results_operation_id_idx": {+ "name": "verify_check_results_operation_id_idx",+ "columns": [+ {+ "expression": "operation_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_check_results_user_id_idx": {+ "name": "verify_check_results_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_check_results_verify_run_id_check_item_id_unique": {+ "name": "verify_check_results_verify_run_id_check_item_id_unique",+ "columns": [+ {+ "expression": "verify_run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "check_item_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_check_results_verifier_type_idx": {+ "name": "verify_check_results_verifier_type_idx",+ "columns": [+ {+ "expression": "verifier_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_check_results_verifier_operation_id_idx": {+ "name": "verify_check_results_verifier_operation_id_idx",+ "columns": [+ {+ "expression": "verifier_operation_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_check_results_verifier_tracing_id_idx": {+ "name": "verify_check_results_verifier_tracing_id_idx",+ "columns": [+ {+ "expression": "verifier_tracing_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_check_results_status_idx": {+ "name": "verify_check_results_status_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_check_results_verdict_idx": {+ "name": "verify_check_results_verdict_idx",+ "columns": [+ {+ "expression": "verdict",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_check_results_repair_operation_id_idx": {+ "name": "verify_check_results_repair_operation_id_idx",+ "columns": [+ {+ "expression": "repair_operation_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_check_results_workspace_id_idx": {+ "name": "verify_check_results_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "verify_check_results_verify_run_id_verify_runs_id_fk": {+ "name": "verify_check_results_verify_run_id_verify_runs_id_fk",+ "tableFrom": "verify_check_results",+ "tableTo": "verify_runs",+ "columnsFrom": ["verify_run_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "verify_check_results_operation_id_agent_operations_id_fk": {+ "name": "verify_check_results_operation_id_agent_operations_id_fk",+ "tableFrom": "verify_check_results",+ "tableTo": "agent_operations",+ "columnsFrom": ["operation_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "verify_check_results_user_id_users_id_fk": {+ "name": "verify_check_results_user_id_users_id_fk",+ "tableFrom": "verify_check_results",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "verify_check_results_workspace_id_workspaces_id_fk": {+ "name": "verify_check_results_workspace_id_workspaces_id_fk",+ "tableFrom": "verify_check_results",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "verify_check_results_verifier_operation_id_agent_operations_id_fk": {+ "name": "verify_check_results_verifier_operation_id_agent_operations_id_fk",+ "tableFrom": "verify_check_results",+ "tableTo": "agent_operations",+ "columnsFrom": ["verifier_operation_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "verify_check_results_verifier_tracing_id_llm_generation_tracing_id_fk": {+ "name": "verify_check_results_verifier_tracing_id_llm_generation_tracing_id_fk",+ "tableFrom": "verify_check_results",+ "tableTo": "llm_generation_tracing",+ "columnsFrom": ["verifier_tracing_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "verify_check_results_repair_operation_id_agent_operations_id_fk": {+ "name": "verify_check_results_repair_operation_id_agent_operations_id_fk",+ "tableFrom": "verify_check_results",+ "tableTo": "agent_operations",+ "columnsFrom": ["repair_operation_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.verify_criteria": {+ "name": "verify_criteria",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "required": {+ "name": "required",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "verifier_type": {+ "name": "verifier_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "verifier_config": {+ "name": "verifier_config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false,+ "default": "'{}'::jsonb"+ },+ "on_fail": {+ "name": "on_fail",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'manual'"+ },+ "document_id": {+ "name": "document_id",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "verify_criteria_user_id_idx": {+ "name": "verify_criteria_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_criteria_verifier_type_idx": {+ "name": "verify_criteria_verifier_type_idx",+ "columns": [+ {+ "expression": "verifier_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_criteria_document_id_idx": {+ "name": "verify_criteria_document_id_idx",+ "columns": [+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_criteria_workspace_id_idx": {+ "name": "verify_criteria_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "verify_criteria_user_id_users_id_fk": {+ "name": "verify_criteria_user_id_users_id_fk",+ "tableFrom": "verify_criteria",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "verify_criteria_document_id_documents_id_fk": {+ "name": "verify_criteria_document_id_documents_id_fk",+ "tableFrom": "verify_criteria",+ "tableTo": "documents",+ "columnsFrom": ["document_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "verify_criteria_workspace_id_workspaces_id_fk": {+ "name": "verify_criteria_workspace_id_workspaces_id_fk",+ "tableFrom": "verify_criteria",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.verify_evidence": {+ "name": "verify_evidence",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "check_result_id": {+ "name": "check_result_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "document_id": {+ "name": "document_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "file_id": {+ "name": "file_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "captured_by": {+ "name": "captured_by",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "captured_at": {+ "name": "captured_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "verify_evidence_check_result_id_idx": {+ "name": "verify_evidence_check_result_id_idx",+ "columns": [+ {+ "expression": "check_result_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_evidence_document_id_idx": {+ "name": "verify_evidence_document_id_idx",+ "columns": [+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_evidence_file_id_idx": {+ "name": "verify_evidence_file_id_idx",+ "columns": [+ {+ "expression": "file_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_evidence_user_id_idx": {+ "name": "verify_evidence_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_evidence_workspace_id_idx": {+ "name": "verify_evidence_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "verify_evidence_check_result_id_verify_check_results_id_fk": {+ "name": "verify_evidence_check_result_id_verify_check_results_id_fk",+ "tableFrom": "verify_evidence",+ "tableTo": "verify_check_results",+ "columnsFrom": ["check_result_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "verify_evidence_document_id_documents_id_fk": {+ "name": "verify_evidence_document_id_documents_id_fk",+ "tableFrom": "verify_evidence",+ "tableTo": "documents",+ "columnsFrom": ["document_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "verify_evidence_file_id_files_id_fk": {+ "name": "verify_evidence_file_id_files_id_fk",+ "tableFrom": "verify_evidence",+ "tableTo": "files",+ "columnsFrom": ["file_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "verify_evidence_user_id_users_id_fk": {+ "name": "verify_evidence_user_id_users_id_fk",+ "tableFrom": "verify_evidence",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "verify_evidence_workspace_id_workspaces_id_fk": {+ "name": "verify_evidence_workspace_id_workspaces_id_fk",+ "tableFrom": "verify_evidence",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.verify_reports": {+ "name": "verify_reports",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "verify_run_id": {+ "name": "verify_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "operation_id": {+ "name": "operation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "verdict": {+ "name": "verdict",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "overall_confidence": {+ "name": "overall_confidence",+ "type": "numeric(3, 2)",+ "primaryKey": false,+ "notNull": false+ },+ "total_checks": {+ "name": "total_checks",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "passed_checks": {+ "name": "passed_checks",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "failed_checks": {+ "name": "failed_checks",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "uncertain_checks": {+ "name": "uncertain_checks",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "summary": {+ "name": "summary",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "reviewed_by_user": {+ "name": "reviewed_by_user",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": false+ },+ "generated_by": {+ "name": "generated_by",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "default": "'system'"+ },+ "generated_at": {+ "name": "generated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "verify_reports_verify_run_id_unique": {+ "name": "verify_reports_verify_run_id_unique",+ "columns": [+ {+ "expression": "verify_run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_reports_operation_id_idx": {+ "name": "verify_reports_operation_id_idx",+ "columns": [+ {+ "expression": "operation_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_reports_user_id_idx": {+ "name": "verify_reports_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_reports_workspace_id_idx": {+ "name": "verify_reports_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "verify_reports_verify_run_id_verify_runs_id_fk": {+ "name": "verify_reports_verify_run_id_verify_runs_id_fk",+ "tableFrom": "verify_reports",+ "tableTo": "verify_runs",+ "columnsFrom": ["verify_run_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "verify_reports_operation_id_agent_operations_id_fk": {+ "name": "verify_reports_operation_id_agent_operations_id_fk",+ "tableFrom": "verify_reports",+ "tableTo": "agent_operations",+ "columnsFrom": ["operation_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "verify_reports_user_id_users_id_fk": {+ "name": "verify_reports_user_id_users_id_fk",+ "tableFrom": "verify_reports",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "verify_reports_workspace_id_workspaces_id_fk": {+ "name": "verify_reports_workspace_id_workspaces_id_fk",+ "tableFrom": "verify_reports",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.verify_review_predictions": {+ "name": "verify_review_predictions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "check_result_id": {+ "name": "check_result_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "model": {+ "name": "model",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "prompt_version": {+ "name": "prompt_version",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "action": {+ "name": "action",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status_reason": {+ "name": "status_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "confidence": {+ "name": "confidence",+ "type": "numeric(3, 2)",+ "primaryKey": false,+ "notNull": false+ },+ "comment": {+ "name": "comment",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "rationale": {+ "name": "rationale",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "annotations": {+ "name": "annotations",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "adjudication": {+ "name": "adjudication",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "adjudication_edit": {+ "name": "adjudication_edit",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "adjudicated_at": {+ "name": "adjudicated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "latency_ms": {+ "name": "latency_ms",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "prompt_tokens": {+ "name": "prompt_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "completion_tokens": {+ "name": "completion_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "verify_review_predictions_check_result_id_idx": {+ "name": "verify_review_predictions_check_result_id_idx",+ "columns": [+ {+ "expression": "check_result_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_review_predictions_user_id_idx": {+ "name": "verify_review_predictions_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_review_predictions_workspace_id_idx": {+ "name": "verify_review_predictions_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_review_predictions_model_idx": {+ "name": "verify_review_predictions_model_idx",+ "columns": [+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "model",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_review_predictions_result_model_prompt_unique": {+ "name": "verify_review_predictions_result_model_prompt_unique",+ "columns": [+ {+ "expression": "check_result_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "model",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "prompt_version",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "verify_review_predictions_check_result_id_verify_check_results_id_fk": {+ "name": "verify_review_predictions_check_result_id_verify_check_results_id_fk",+ "tableFrom": "verify_review_predictions",+ "tableTo": "verify_check_results",+ "columnsFrom": ["check_result_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "verify_review_predictions_user_id_users_id_fk": {+ "name": "verify_review_predictions_user_id_users_id_fk",+ "tableFrom": "verify_review_predictions",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "verify_review_predictions_workspace_id_workspaces_id_fk": {+ "name": "verify_review_predictions_workspace_id_workspaces_id_fk",+ "tableFrom": "verify_review_predictions",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "verify_review_predictions_action_matches_status": {+ "name": "verify_review_predictions_action_matches_status",+ "value": "(\"verify_review_predictions\".\"status\" = 'judged') = (\"verify_review_predictions\".\"action\" IS NOT NULL)"+ }+ },+ "isRLSEnabled": false+ },+ "public.verify_rubric_criteria": {+ "name": "verify_rubric_criteria",+ "schema": "",+ "columns": {+ "rubric_id": {+ "name": "rubric_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "criterion_id": {+ "name": "criterion_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "sort_order": {+ "name": "sort_order",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "verify_rubric_criteria_criterion_id_idx": {+ "name": "verify_rubric_criteria_criterion_id_idx",+ "columns": [+ {+ "expression": "criterion_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_rubric_criteria_user_id_idx": {+ "name": "verify_rubric_criteria_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_rubric_criteria_workspace_id_idx": {+ "name": "verify_rubric_criteria_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "verify_rubric_criteria_rubric_id_verify_rubrics_id_fk": {+ "name": "verify_rubric_criteria_rubric_id_verify_rubrics_id_fk",+ "tableFrom": "verify_rubric_criteria",+ "tableTo": "verify_rubrics",+ "columnsFrom": ["rubric_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "verify_rubric_criteria_criterion_id_verify_criteria_id_fk": {+ "name": "verify_rubric_criteria_criterion_id_verify_criteria_id_fk",+ "tableFrom": "verify_rubric_criteria",+ "tableTo": "verify_criteria",+ "columnsFrom": ["criterion_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "verify_rubric_criteria_user_id_users_id_fk": {+ "name": "verify_rubric_criteria_user_id_users_id_fk",+ "tableFrom": "verify_rubric_criteria",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "verify_rubric_criteria_workspace_id_workspaces_id_fk": {+ "name": "verify_rubric_criteria_workspace_id_workspaces_id_fk",+ "tableFrom": "verify_rubric_criteria",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "verify_rubric_criteria_rubric_id_criterion_id_pk": {+ "name": "verify_rubric_criteria_rubric_id_criterion_id_pk",+ "columns": ["rubric_id", "criterion_id"]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.verify_rubrics": {+ "name": "verify_rubrics",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "config": {+ "name": "config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false,+ "default": "'{}'::jsonb"+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "verify_rubrics_user_id_idx": {+ "name": "verify_rubrics_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_rubrics_workspace_id_idx": {+ "name": "verify_rubrics_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "verify_rubrics_user_id_users_id_fk": {+ "name": "verify_rubrics_user_id_users_id_fk",+ "tableFrom": "verify_rubrics",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "verify_rubrics_workspace_id_workspaces_id_fk": {+ "name": "verify_rubrics_workspace_id_workspaces_id_fk",+ "tableFrom": "verify_rubrics",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.verify_runs": {+ "name": "verify_runs",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "acceptance_id": {+ "name": "acceptance_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "round_index": {+ "name": "round_index",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "operation_id": {+ "name": "operation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'agent'"+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'public'"+ },+ "scenario": {+ "name": "scenario",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "goal": {+ "name": "goal",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "context": {+ "name": "context",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "plan": {+ "name": "plan",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "plan_confirmed_at": {+ "name": "plan_confirmed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_decision": {+ "name": "user_decision",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "decision_detail": {+ "name": "decision_detail",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "accessed_at": {+ "name": "accessed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "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": {+ "verify_runs_user_id_idx": {+ "name": "verify_runs_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_runs_workspace_id_idx": {+ "name": "verify_runs_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_runs_acceptance_id_idx": {+ "name": "verify_runs_acceptance_id_idx",+ "columns": [+ {+ "expression": "acceptance_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_runs_acceptance_round_unique": {+ "name": "verify_runs_acceptance_round_unique",+ "columns": [+ {+ "expression": "acceptance_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "round_index",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_runs_operation_id_unique": {+ "name": "verify_runs_operation_id_unique",+ "columns": [+ {+ "expression": "operation_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_runs_source_idx": {+ "name": "verify_runs_source_idx",+ "columns": [+ {+ "expression": "source",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "verify_runs_user_decision_idx": {+ "name": "verify_runs_user_decision_idx",+ "columns": [+ {+ "expression": "user_decision",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "verify_runs_user_id_users_id_fk": {+ "name": "verify_runs_user_id_users_id_fk",+ "tableFrom": "verify_runs",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "verify_runs_workspace_id_workspaces_id_fk": {+ "name": "verify_runs_workspace_id_workspaces_id_fk",+ "tableFrom": "verify_runs",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "verify_runs_acceptance_id_acceptances_id_fk": {+ "name": "verify_runs_acceptance_id_acceptances_id_fk",+ "tableFrom": "verify_runs",+ "tableTo": "acceptances",+ "columnsFrom": ["acceptance_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "verify_runs_operation_id_agent_operations_id_fk": {+ "name": "verify_runs_operation_id_agent_operations_id_fk",+ "tableFrom": "verify_runs",+ "tableTo": "agent_operations",+ "columnsFrom": ["operation_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "verify_runs_acceptance_requires_round": {+ "name": "verify_runs_acceptance_requires_round",+ "value": "\"verify_runs\".\"acceptance_id\" IS NULL OR \"verify_runs\".\"round_index\" IS NOT NULL"+ }+ },+ "isRLSEnabled": false+ },+ "public.work_versions": {+ "name": "work_versions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "work_id": {+ "name": "work_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "version": {+ "name": "version",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "identifier": {+ "name": "identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "url": {+ "name": "url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "change_type": {+ "name": "change_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "tool_name": {+ "name": "tool_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "tool_identifier": {+ "name": "tool_identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "topic_id": {+ "name": "topic_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "thread_id": {+ "name": "thread_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "message_id": {+ "name": "message_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "root_operation_id": {+ "name": "root_operation_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "tool_call_id": {+ "name": "tool_call_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "cumulative_cost": {+ "name": "cumulative_cost",+ "type": "numeric(20, 6)",+ "primaryKey": false,+ "notNull": false+ },+ "cumulative_usage": {+ "name": "cumulative_usage",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "work_versions_work_id_version_unique": {+ "name": "work_versions_work_id_version_unique",+ "columns": [+ {+ "expression": "work_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "version",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "work_versions_work_id_tool_call_id_unique": {+ "name": "work_versions_work_id_tool_call_id_unique",+ "columns": [+ {+ "expression": "work_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "tool_call_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"work_versions\".\"tool_call_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "work_versions_thread_id_idx": {+ "name": "work_versions_thread_id_idx",+ "columns": [+ {+ "expression": "thread_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "work_versions_message_id_idx": {+ "name": "work_versions_message_id_idx",+ "columns": [+ {+ "expression": "message_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "work_versions_agent_id_idx": {+ "name": "work_versions_agent_id_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "work_versions_root_operation_created_at_idx": {+ "name": "work_versions_root_operation_created_at_idx",+ "columns": [+ {+ "expression": "root_operation_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "work_versions_topic_created_at_idx": {+ "name": "work_versions_topic_created_at_idx",+ "columns": [+ {+ "expression": "topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "work_versions_topic_thread_created_at_idx": {+ "name": "work_versions_topic_thread_created_at_idx",+ "columns": [+ {+ "expression": "topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "thread_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "work_versions_work_id_works_id_fk": {+ "name": "work_versions_work_id_works_id_fk",+ "tableFrom": "work_versions",+ "tableTo": "works",+ "columnsFrom": ["work_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "work_versions_topic_id_topics_id_fk": {+ "name": "work_versions_topic_id_topics_id_fk",+ "tableFrom": "work_versions",+ "tableTo": "topics",+ "columnsFrom": ["topic_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "work_versions_thread_id_threads_id_fk": {+ "name": "work_versions_thread_id_threads_id_fk",+ "tableFrom": "work_versions",+ "tableTo": "threads",+ "columnsFrom": ["thread_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "work_versions_message_id_messages_id_fk": {+ "name": "work_versions_message_id_messages_id_fk",+ "tableFrom": "work_versions",+ "tableTo": "messages",+ "columnsFrom": ["message_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "work_versions_agent_id_agents_id_fk": {+ "name": "work_versions_agent_id_agents_id_fk",+ "tableFrom": "work_versions",+ "tableTo": "agents",+ "columnsFrom": ["agent_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.works": {+ "name": "works",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "current_version_id": {+ "name": "current_version_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "resource_type": {+ "name": "resource_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "resource_id": {+ "name": "resource_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "identifier": {+ "name": "identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "url": {+ "name": "url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "tool_name": {+ "name": "tool_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "tool_identifier": {+ "name": "tool_identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "origin_topic_id": {+ "name": "origin_topic_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "origin_thread_id": {+ "name": "origin_thread_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "origin_agent_id": {+ "name": "origin_agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "visibility": {+ "name": "visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "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": {+ "works_resource_user_unique": {+ "name": "works_resource_user_unique",+ "columns": [+ {+ "expression": "resource_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "resource_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"works\".\"workspace_id\" is null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "works_resource_workspace_unique": {+ "name": "works_resource_workspace_unique",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "resource_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "resource_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"works\".\"workspace_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "works_user_id_idx": {+ "name": "works_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "works_workspace_id_idx": {+ "name": "works_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "works_workspace_visibility_idx": {+ "name": "works_workspace_visibility_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "works_user_updated_at_id_idx": {+ "name": "works_user_updated_at_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "updated_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"works\".\"workspace_id\" is null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "works_workspace_updated_at_id_idx": {+ "name": "works_workspace_updated_at_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "updated_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"works\".\"workspace_id\" is not null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "works_origin_topic_id_idx": {+ "name": "works_origin_topic_id_idx",+ "columns": [+ {+ "expression": "origin_topic_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "works_origin_thread_id_idx": {+ "name": "works_origin_thread_id_idx",+ "columns": [+ {+ "expression": "origin_thread_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "works_origin_agent_id_idx": {+ "name": "works_origin_agent_id_idx",+ "columns": [+ {+ "expression": "origin_agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "works_origin_topic_id_topics_id_fk": {+ "name": "works_origin_topic_id_topics_id_fk",+ "tableFrom": "works",+ "tableTo": "topics",+ "columnsFrom": ["origin_topic_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "works_origin_thread_id_threads_id_fk": {+ "name": "works_origin_thread_id_threads_id_fk",+ "tableFrom": "works",+ "tableTo": "threads",+ "columnsFrom": ["origin_thread_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "works_origin_agent_id_agents_id_fk": {+ "name": "works_origin_agent_id_agents_id_fk",+ "tableFrom": "works",+ "tableTo": "agents",+ "columnsFrom": ["origin_agent_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "works_user_id_users_id_fk": {+ "name": "works_user_id_users_id_fk",+ "tableFrom": "works",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "works_workspace_id_workspaces_id_fk": {+ "name": "works_workspace_id_workspaces_id_fk",+ "tableFrom": "works",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.workspace_audit_logs": {+ "name": "workspace_audit_logs",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "action": {+ "name": "action",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "resource_type": {+ "name": "resource_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "resource_id": {+ "name": "resource_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false,+ "default": "'{}'::jsonb"+ },+ "ip_address": {+ "name": "ip_address",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "workspace_audit_logs_workspace_id_idx": {+ "name": "workspace_audit_logs_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "workspace_audit_logs_action_idx": {+ "name": "workspace_audit_logs_action_idx",+ "columns": [+ {+ "expression": "action",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "workspace_audit_logs_created_at_idx": {+ "name": "workspace_audit_logs_created_at_idx",+ "columns": [+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "workspace_audit_logs_workspace_id_workspaces_id_fk": {+ "name": "workspace_audit_logs_workspace_id_workspaces_id_fk",+ "tableFrom": "workspace_audit_logs",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.workspace_invitations": {+ "name": "workspace_invitations",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "inviter_id": {+ "name": "inviter_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "email": {+ "name": "email",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'member'"+ },+ "token": {+ "name": "token",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "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": {+ "workspace_invitations_workspace_id_idx": {+ "name": "workspace_invitations_workspace_id_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "workspace_invitations_email_idx": {+ "name": "workspace_invitations_email_idx",+ "columns": [+ {+ "expression": "email",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "workspace_invitations_token_idx": {+ "name": "workspace_invitations_token_idx",+ "columns": [+ {+ "expression": "token",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "workspace_invitations_workspace_id_workspaces_id_fk": {+ "name": "workspace_invitations_workspace_id_workspaces_id_fk",+ "tableFrom": "workspace_invitations",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "workspace_invitations_inviter_id_users_id_fk": {+ "name": "workspace_invitations_inviter_id_users_id_fk",+ "tableFrom": "workspace_invitations",+ "tableTo": "users",+ "columnsFrom": ["inviter_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "workspace_invitations_token_unique": {+ "name": "workspace_invitations_token_unique",+ "nullsNotDistinct": false,+ "columns": ["token"]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.workspace_members": {+ "name": "workspace_members",+ "schema": "",+ "columns": {+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'member'"+ },+ "joined_at": {+ "name": "joined_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()"+ },+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "workspace_members_user_id_idx": {+ "name": "workspace_members_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "workspace_members_unique_active_owner_idx": {+ "name": "workspace_members_unique_active_owner_idx",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"workspace_members\".\"role\" = 'owner' AND \"workspace_members\".\"deleted_at\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "workspace_members_workspace_id_workspaces_id_fk": {+ "name": "workspace_members_workspace_id_workspaces_id_fk",+ "tableFrom": "workspace_members",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "workspace_members_user_id_users_id_fk": {+ "name": "workspace_members_user_id_users_id_fk",+ "tableFrom": "workspace_members",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "workspace_members_workspace_id_user_id_pk": {+ "name": "workspace_members_workspace_id_user_id_pk",+ "columns": ["workspace_id", "user_id"]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.workspace_user_settings": {+ "name": "workspace_user_settings",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "workspace_id": {+ "name": "workspace_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "preference": {+ "name": "preference",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "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": {+ "workspace_user_settings_workspace_id_user_id_unique": {+ "name": "workspace_user_settings_workspace_id_user_id_unique",+ "columns": [+ {+ "expression": "workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "workspace_user_settings_user_id_idx": {+ "name": "workspace_user_settings_user_id_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "workspace_user_settings_workspace_id_workspaces_id_fk": {+ "name": "workspace_user_settings_workspace_id_workspaces_id_fk",+ "tableFrom": "workspace_user_settings",+ "tableTo": "workspaces",+ "columnsFrom": ["workspace_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "workspace_user_settings_user_id_users_id_fk": {+ "name": "workspace_user_settings_user_id_users_id_fk",+ "tableFrom": "workspace_user_settings",+ "tableTo": "users",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.workspaces": {+ "name": "workspaces",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "slug": {+ "name": "slug",+ "type": "varchar(100)",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "varchar(1000)",+ "primaryKey": false,+ "notNull": false+ },+ "avatar": {+ "name": "avatar",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "primary_owner_id": {+ "name": "primary_owner_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "settings": {+ "name": "settings",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false,+ "default": "'{}'::jsonb"+ },+ "frozen": {+ "name": "frozen",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": false+ },+ "frozen_reason": {+ "name": "frozen_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "frozen_at": {+ "name": "frozen_at",+ "type": "timestamp with time zone",+ "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": {+ "workspaces_slug_idx": {+ "name": "workspaces_slug_idx",+ "columns": [+ {+ "expression": "slug",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "workspaces_primary_owner_id_idx": {+ "name": "workspaces_primary_owner_id_idx",+ "columns": [+ {+ "expression": "primary_owner_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "workspaces_primary_owner_id_users_id_fk": {+ "name": "workspaces_primary_owner_id_users_id_fk",+ "tableFrom": "workspaces",+ "tableTo": "users",+ "columnsFrom": ["primary_owner_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ }+ },+ "version": "7",+ "views": {}+}diff --git a/packages/database/migrations/meta/_journal.json b/packages/database/migrations/meta/_journal.jsonindex 782093f753d..f3ed10fe7a3 100644--- a/packages/database/migrations/meta/_journal.json+++ b/packages/database/migrations/meta/_journal.json@@ -1050,6 +1050,13 @@"when": 1787542746291,"tag": "0149_goals_recovery_and_document_evidence","breakpoints": true+ },+ {+ "idx": 150,+ "version": "7",+ "when": 1787736410876,+ "tag": "0150_agent_interventions_and_live_activity",+ "breakpoints": true}],"version": "6"diff --git a/packages/database/src/models/__tests__/agentIntervention.test.ts b/packages/database/src/models/__tests__/agentIntervention.test.tsnew file mode 100644index 00000000000..60dac1123e7--- /dev/null+++ b/packages/database/src/models/__tests__/agentIntervention.test.ts@@ -0,0 +1,1972 @@+// @vitest-environment node+import { randomUUID } from 'node:crypto';++import { eq } from 'drizzle-orm';+import { beforeEach, describe, expect, it } from 'vitest';++import { getTestDB } from '../../core/getTestDB';+import type { AgentInterventionItem } from '../../schemas';+import {+ agentInterventionResolutions,+ agentInterventions,+ agentOperations,+ messagePlugins,+ messages,+ users,+ userSettings,+ workspaces,+} from '../../schemas';+import type { LobeChatDatabase } from '../../type';+import {+ AGENT_INTERVENTION_IDENTITY_CONFLICT,+ AGENT_INTERVENTION_INVALID_ACTION,+ AGENT_INTERVENTION_INVALID_BATCH,+ AGENT_INTERVENTION_INVALID_REQUEST_REVISION_HASH,+ AGENT_INTERVENTION_RESOLUTION_REQUEST_REUSED,+ AGENT_INTERVENTION_SOURCE_TRANSITION_MISMATCH,+ AgentInterventionModel,+ hashAgentInterventionRequestRevision,+} from '../agentIntervention';++const serverDB: LobeChatDatabase = await getTestDB();++const ownerId = 'agent-intervention-owner';+const actorId = 'agent-intervention-collaborator';+const otherUserId = 'agent-intervention-other';+const workspaceId = 'agent-intervention-workspace';+const operationId = 'agent-intervention-operation';+const secondOperationId = 'agent-intervention-operation-2';++const model = new AgentInterventionModel(serverDB, ownerId, workspaceId);+const coldOwnerModel = new AgentInterventionModel(serverDB, ownerId);+const otherUserModel = new AgentInterventionModel(serverDB, otherUserId, workspaceId);++let hashSequence = 0;+const nextHash = () => (++hashSequence).toString(16).padStart(64, 'a');++const questionItem = (overrides: Record<string, unknown> = {}) => ({+ allowedActions: ['submit_answers', 'skip_interaction', 'cancel_interaction'] as const,+ interactionKind: 'question' as const,+ provider: 'claude-code',+ requestRevisionHash: nextHash(),+ reviewContext: { summary: 'Choose a safe mode', title: 'Agent needs your input' },+ reviewTokenHash: nextHash(),+ sanitizedRequest: {+ apiName: 'askUserQuestion',+ identifier: 'claude-code',+ questions: [+ {+ id: 'mode',+ options: [+ { id: 'safe', label: 'Safe' },+ { id: 'fast', label: 'Fast' },+ ],+ question: 'Which mode?',+ },+ ],+ },+ surface: 'form' as const,+ toolCallId: `question-${hashSequence}`,+ ...overrides,+});++const createQuestionBatch = (overrides: Partial<Parameters<typeof model.createBatch>[0]> = {}) =>+ model.createBatch({+ activityKey: `activity-${hashSequence + 1}`,+ batchId: `batch-${hashSequence + 1}`,+ deadline: new Date(Date.now() + 10 * 60_000),+ items: [questionItem()],+ operationId,+ provider: 'claude-code',+ source: 'heterogeneous',+ stepIndex: 0,+ systemActionEligibility: 'review_only',+ ...overrides,+ });++const snapshot = (rows: AgentInterventionItem[]) => ({+ expectedItemCount: rows.length,+ expectedRequestRevisionHashes: Object.fromEntries(+ rows.map((row) => [row.id, row.requestRevisionHash]),+ ),+ expectedVersions: Object.fromEntries(rows.map((row) => [row.id, row.version])),+});++const createReparkBatchParams = (+ rows: AgentInterventionItem[],+ overrides: Partial<Parameters<typeof model.createBatch>[0]> = {},+): Parameters<typeof model.createBatch>[0] => ({+ activityKey: `repark-activity-${hashSequence + 1}`,+ approvalMode: rows[0].approvalMode ?? undefined,+ batchId: `repark-batch-${hashSequence + 1}`,+ deadline: new Date(Date.now() + 10 * 60_000),+ items: rows.map((row) => ({+ allowedActions: row.allowedActions,+ canonicalToolKey: row.canonicalToolKey ?? undefined,+ interactionKind: row.interactionKind,+ provider: row.provider ?? undefined,+ requestRevisionHash: row.requestRevisionHash,+ reviewContext: row.reviewContext,+ reviewTokenHash: nextHash(),+ risk: row.risk ?? undefined,+ sanitizedRequest: row.sanitizedRequest,+ surface: row.surface,+ toolCallId: row.toolCallId,+ toolMessageId: row.toolMessageId ?? undefined,+ })),+ operationId: secondOperationId,+ provider: rows[0].provider ?? undefined,+ source: 'runtime',+ stepIndex: rows[0].stepIndex + 1,+ systemActionEligibility: 'review_only',+ ...overrides,+});++const claim = (+ rows: AgentInterventionItem[],+ action: Parameters<typeof model.claimBatch>[0]['action'],+ overrides: Partial<Parameters<typeof model.claimBatch>[0]> = {},+) =>+ model.claimBatch({+ action,+ actorId,+ batchId: rows[0].batchId,+ operationId: rows[0].operationId,+ resolutionRequestId: randomUUID(),+ scope: 'single',+ selectedInterventionIds: [rows[0].id],+ ...snapshot(rows),+ ...overrides,+ });++const createCustomResolution = async (resolutionRequestId = randomUUID()) => {+ const [row] = await createQuestionBatch({+ batchId: `custom-execution-${hashSequence + 1}`,+ items: [+ questionItem({+ allowedActions: ['submit_custom'],+ interactionKind: 'custom',+ sanitizedRequest: {+ apiName: 'installMarketplaceItem',+ fields: [{ id: 'confirm', label: 'Install', required: true, type: 'boolean' }],+ },+ toolCallId: `custom-execution-tool-${hashSequence + 1}`,+ }),+ ],+ });+ const claimed = await claim(+ [row],+ {+ expectedRevisionHash: row.requestRevisionHash,+ result: { confirm: true },+ type: 'submit_custom',+ },+ { resolutionRequestId },+ );+ if (claimed.outcome !== 'applied') throw new Error('custom resolution claim failed');+ return { resolution: claimed.resolution, row };+};++const createMixedCustomResolution = async (resolutionRequestId = randomUUID()) => {+ const rows = await model.createBatch({+ activityKey: `mixed-custom-execution-activity-${hashSequence + 1}`,+ batchId: `mixed-custom-execution-${hashSequence + 1}`,+ deadline: new Date(Date.now() + 10 * 60_000),+ items: [+ questionItem({+ allowedActions: ['submit_custom'],+ interactionKind: 'custom',+ sanitizedRequest: {+ apiName: 'installMarketplaceItem',+ fields: [{ id: 'confirm', label: 'Install', required: true, type: 'boolean' }],+ },+ toolCallId: `mixed-custom-execution-tool-${hashSequence + 1}`,+ }),+ questionItem({ toolCallId: `mixed-custom-sibling-${hashSequence + 1}` }),+ ],+ operationId,+ provider: 'claude-code',+ source: 'heterogeneous',+ stepIndex: 0,+ systemActionEligibility: 'review_only',+ });+ const claimed = await claim(+ rows,+ {+ expectedRevisionHash: rows[0].requestRevisionHash,+ result: { confirm: true },+ type: 'submit_custom',+ },+ { resolutionRequestId, selectedInterventionIds: [rows[0].id] },+ );+ if (claimed.outcome !== 'applied') throw new Error('mixed custom resolution claim failed');+ return { resolution: claimed.resolution, rows };+};++const seedToolMessage = async (params: {+ argumentsText: string;+ toolCallId: string;+ toolMessageId: string;+}) => {+ const assistantId = `assistant-${params.toolMessageId}`;+ await serverDB.insert(messages).values({+ content: '',+ id: assistantId,+ role: 'assistant',+ tools: [+ {+ apiName: 'writeFile',+ arguments: params.argumentsText,+ id: params.toolCallId,+ identifier: 'filesystem',+ type: 'builtin',+ },+ ],+ userId: ownerId,+ workspaceId,+ });+ await serverDB.insert(messages).values({+ content: '',+ id: params.toolMessageId,+ parentId: assistantId,+ role: 'tool',+ userId: ownerId,+ workspaceId,+ });+ await serverDB.insert(messagePlugins).values({+ apiName: 'writeFile',+ arguments: params.argumentsText,+ id: params.toolMessageId,+ identifier: 'filesystem',+ toolCallId: params.toolCallId,+ userId: ownerId,+ workspaceId,+ });+ return assistantId;+};++const parkOperation = (id = operationId) =>+ serverDB+ .update(agentOperations)+ .set({ completedAt: null, completionReason: 'waiting_for_human', status: 'waiting_for_human' })+ .where(eq(agentOperations.id, id));++const createRuntimeApprovalBatch = async (params?: {+ batchId?: string;+ canonicalToolKey?: string;+ count?: number;+ operationId?: string;+ systemActionEligibility?: 'review_only' | 'safe_single_binary';+}) => {+ const count = params?.count ?? 1;+ const op = params?.operationId ?? operationId;+ await parkOperation(op);+ const items = [];+ for (let index = 0; index < count; index++) {+ const toolCallId = `${op}-tool-${hashSequence + index + 1}`;+ const toolMessageId = `${op}-tool-message-${hashSequence + index + 1}`;+ const argumentsText = JSON.stringify({ path: `file-${index}.txt` });+ await seedToolMessage({ argumentsText, toolCallId, toolMessageId });+ items.push({+ allowedActions: [+ 'approve',+ 'approve_remember',+ 'edit_arguments',+ 'reject_continue',+ 'stop',+ ] as const,+ canonicalToolKey: params?.canonicalToolKey ?? 'filesystem/writeFile',+ interactionKind: 'tool_approval' as const,+ requestRevisionHash: hashAgentInterventionRequestRevision(argumentsText),+ reviewContext: { title: `Write file ${index + 1}` },+ reviewTokenHash: nextHash(),+ risk: { level: 'low' as const },+ sanitizedRequest: {+ apiName: 'writeFile',+ argumentCount: 1,+ identifier: 'filesystem',+ parameterNames: ['path'],+ },+ surface: 'binary' as const,+ toolCallId,+ toolMessageId,+ });+ }+ return model.createBatch({+ activityKey: `runtime-activity-${hashSequence + 1}`,+ approvalMode: 'allow-list',+ batchId: params?.batchId ?? `runtime-batch-${hashSequence + 1}`,+ deadline: new Date(Date.now() + 10 * 60_000),+ items,+ operationId: op,+ source: 'runtime',+ stepIndex: 3,+ systemActionEligibility:+ params?.systemActionEligibility ?? (count === 1 ? 'safe_single_binary' : 'review_only'),+ });+};++beforeEach(async () => {+ hashSequence = 0;+ await serverDB.delete(agentInterventions);+ await serverDB.delete(agentInterventionResolutions);+ await serverDB.delete(messagePlugins);+ await serverDB.delete(messages);+ await serverDB.delete(agentOperations);+ await serverDB.delete(userSettings);+ await serverDB.delete(workspaces);+ await serverDB.delete(users);++ await serverDB.insert(users).values([{ id: ownerId }, { id: actorId }, { id: otherUserId }]);+ await serverDB.insert(workspaces).values({+ id: workspaceId,+ name: 'Intervention workspace',+ primaryOwnerId: ownerId,+ slug: 'agent-intervention-workspace',+ });+ await serverDB.insert(agentOperations).values([+ { id: operationId, status: 'running', userId: ownerId, workspaceId },+ { id: secondOperationId, status: 'running', userId: ownerId, workspaceId },+ ]);+});++describe('AgentInterventionModel', () => {+ it('hashes the exact raw arguments string for request revision compatibility', () => {+ expect(hashAgentInterventionRequestRevision('{"path":"/tmp/a"}')).toBe(+ '15df809ad5fadb66f0b31bafc206dcfe620d8da8767fb76e41d3603a45dc870d',+ );+ });++ it('persists a hash-only sanitized request and exposes a minimal system locator', async () => {+ const [row] = await createQuestionBatch({ batchId: 'cold-batch' });++ expect(row).toMatchObject({+ batchId: 'cold-batch',+ itemCount: 1,+ itemIndex: 0,+ provider: 'claude-code',+ sealed: true,+ source: 'heterogeneous',+ status: 'pending',+ systemActionEligibility: 'review_only',+ });+ expect(row.sanitizedRequest).not.toHaveProperty('arguments');+ expect(await coldOwnerModel.findByIdForOwner(row.id)).toMatchObject({ workspaceId });+ expect(await otherUserModel.findByReviewTokenHash(row.reviewTokenHash)).toBeUndefined();++ const locator = await AgentInterventionModel.locateByReviewTokenHash(+ serverDB,+ row.reviewTokenHash,+ );+ expect(locator).toEqual({+ activityKey: row.activityKey,+ batchId: 'cold-batch',+ deadline: row.deadline,+ id: row.id,+ operationId,+ source: 'heterogeneous',+ status: 'pending',+ userId: ownerId,+ workspaceId,+ });+ expect(locator).not.toHaveProperty('reviewTokenHash');+ expect(locator).not.toHaveProperty('reviewContext');++ expect(+ await AgentInterventionModel.locateByOperationAndToolCall(+ serverDB,+ row.operationId,+ row.toolCallId,+ ),+ ).toEqual(locator);+ expect(+ await AgentInterventionModel.locateByOperationAndToolCall(+ serverDB,+ row.operationId,+ 'unknown-tool-call',+ ),+ ).toBeUndefined();+ });++ it('expires a workspace batch after an owner-only cold lookup restores its scope', async () => {+ const [row] = await createQuestionBatch({ batchId: 'cold-timeout-batch' });+ await serverDB+ .update(agentInterventions)+ .set({ deadline: new Date(Date.now() - 1000) })+ .where(eq(agentInterventions.id, row.id));++ expect(await coldOwnerModel.findByIdForOwner(row.id)).toMatchObject({+ status: 'timed_out',+ workspaceId,+ });+ });++ it('requires complete identity equality for idempotent create', async () => {+ const params: Parameters<typeof model.createBatch>[0] = {+ activityKey: 'identity-activity',+ batchId: 'identity-batch',+ deadline: new Date(Date.now() + 60_000),+ items: [questionItem({ toolCallId: 'identity-tool' })],+ operationId,+ provider: 'claude-code',+ source: 'heterogeneous',+ stepIndex: 0,+ systemActionEligibility: 'review_only',+ };+ const first = await model.createBatch(params);+ expect(await model.createBatch(params)).toEqual(first);++ await expect(+ model.createBatch({+ ...params,+ items: [{ ...params.items[0], allowedActions: ['cancel_interaction'] }],+ }),+ ).rejects.toThrow(AGENT_INTERVENTION_IDENTITY_CONFLICT);+ });++ it('normalizes optional undefined fields from durable Review DTOs before persistence', async () => {+ const item = questionItem({+ canonicalToolKey: undefined,+ provider: undefined,+ reviewContext: {+ agentLabel: undefined,+ resourceLabel: undefined,+ summary: undefined,+ title: 'Optional Review fields',+ },+ risk: { level: 'low', summary: undefined, warnings: undefined },+ sanitizedRequest: {+ apiName: 'askUserQuestion',+ identifier: undefined,+ questions: [+ {+ header: undefined,+ id: 'mode',+ options: [+ {+ description: undefined,+ id: 'safe',+ label: 'Safe',+ recommended: undefined,+ },+ ],+ question: 'Which mode?',+ },+ ],+ },+ toolCallId: 'optional-review-tool',+ toolMessageId: undefined,+ });+ const params: Parameters<typeof model.createBatch>[0] = {+ activityKey: 'optional-review-activity',+ batchId: 'optional-review-batch',+ deadline: new Date(Date.now() + 60_000),+ items: [item],+ operationId,+ provider: 'claude-code',+ source: 'heterogeneous',+ stepIndex: 0,+ systemActionEligibility: 'review_only',+ };++ const created = await model.createBatch(params);++ expect(created[0]).toMatchObject({+ canonicalToolKey: null,+ provider: 'claude-code',+ reviewContext: { title: 'Optional Review fields' },+ risk: { level: 'low' },+ sanitizedRequest: {+ apiName: 'askUserQuestion',+ questions: [+ {+ id: 'mode',+ options: [{ id: 'safe', label: 'Safe' }],+ question: 'Which mode?',+ },+ ],+ },+ toolMessageId: null,+ });+ expect(await model.createBatch(params)).toEqual(created);+ });++ it('rejects non-JSON-safe values from durable Review metadata', async () => {+ const cyclic: Record<string, unknown> = {};+ cyclic.self = cyclic;+ const sparseArray: unknown[] = [];+ sparseArray.length = 1;+ const unsafeValues: [string, unknown][] = [+ ['date', new Date()],+ ['bigint', 1n],+ ['function', () => true],+ ['symbol', Symbol('unsafe')],+ ['nan', Number.NaN],+ ['infinity', Number.POSITIVE_INFINITY],+ ['negative-infinity', Number.NEGATIVE_INFINITY],+ ['array-undefined', [undefined]],+ ['sparse-array', sparseArray],+ ['cycle', cyclic],+ ];++ for (const [name, value] of unsafeValues) {+ await expect(+ createQuestionBatch({+ batchId: `unsafe-review-${name}`,+ items: [+ questionItem({+ reviewContext: { title: 'Unsafe Review', value } as never,+ toolCallId: `unsafe-review-tool-${name}`,+ }),+ ],+ }),+ ).rejects.toThrow(AGENT_INTERVENTION_INVALID_BATCH);+ }+ });++ it('reports applied then idempotent when the atomic create has no predecessor', async () => {+ const params: Parameters<typeof model.createBatch>[0] = {+ activityKey: 'atomic-create-activity',+ batchId: 'atomic-create-batch',+ deadline: new Date(Date.now() + 60_000),+ items: [questionItem({ toolCallId: 'atomic-create-tool' })],+ operationId,+ provider: 'claude-code',+ source: 'heterogeneous',+ stepIndex: 0,+ systemActionEligibility: 'review_only',+ };++ expect(await model.createBatchWithSupersession({ batch: params })).toMatchObject({+ outcome: 'applied',+ });+ expect(await model.createBatchWithSupersession({ batch: params })).toMatchObject({+ outcome: 'idempotent',+ });+ });++ it('creates a new runtime batch only while its locked operation is waiting for human', async () => {+ const params: Parameters<typeof model.createBatch>[0] = {+ activityKey: 'runtime-state-activity',+ batchId: 'runtime-state-batch',+ deadline: new Date(Date.now() + 60_000),+ items: [questionItem({ toolCallId: 'runtime-state-tool' })],+ operationId,+ source: 'runtime',+ stepIndex: 0,+ systemActionEligibility: 'review_only',+ };+ await serverDB+ .update(agentOperations)+ .set({ status: 'done' })+ .where(eq(agentOperations.id, operationId));++ await expect(model.createBatch(params)).rejects.toThrow(AGENT_INTERVENTION_IDENTITY_CONFLICT);+ expect((await model.findBatch(operationId, params.batchId)).interventions).toEqual([]);++ await parkOperation();+ const created = await model.createBatch(params);+ await serverDB+ .update(agentOperations)+ .set({ status: 'done' })+ .where(eq(agentOperations.id, operationId));+ expect(await model.createBatch(params)).toEqual(created);+ });++ it('closes the terminal-operation race for atomic runtime create without a predecessor', async () => {+ const params: Parameters<typeof model.createBatch>[0] = {+ activityKey: 'atomic-runtime-state-activity',+ batchId: 'atomic-runtime-state-batch',+ deadline: new Date(Date.now() + 60_000),+ items: [questionItem({ toolCallId: 'atomic-runtime-state-tool' })],+ operationId,+ source: 'runtime',+ stepIndex: 0,+ systemActionEligibility: 'review_only',+ };+ await serverDB+ .update(agentOperations)+ .set({ status: 'done' })+ .where(eq(agentOperations.id, operationId));++ await expect(model.createBatchWithSupersession({ batch: params })).rejects.toThrow(+ AGENT_INTERVENTION_IDENTITY_CONFLICT,+ );+ expect((await model.findBatch(operationId, params.batchId)).interventions).toEqual([]);++ await parkOperation();+ expect(await model.createBatchWithSupersession({ batch: params })).toMatchObject({+ outcome: 'applied',+ });+ await serverDB+ .update(agentOperations)+ .set({ status: 'done' })+ .where(eq(agentOperations.id, operationId));+ expect(await model.createBatchWithSupersession({ batch: params })).toMatchObject({+ outcome: 'idempotent',+ });+ });++ it('allows heterogeneous batches regardless of the owner operation status', async () => {+ await serverDB+ .update(agentOperations)+ .set({ status: 'done' })+ .where(eq(agentOperations.id, operationId));++ expect(await createQuestionBatch({ batchId: 'terminal-heterogeneous-batch' })).toHaveLength(1);+ });++ it('keeps identical batch ids isolated by operation id', async () => {+ const first = await createQuestionBatch({ batchId: 'shared-batch', operationId });+ const second = await createQuestionBatch({+ batchId: 'shared-batch',+ operationId: secondOperationId,+ });++ const firstState = await model.findBatch(operationId, 'shared-batch');+ const secondState = await model.findBatch(secondOperationId, 'shared-batch');+ expect(firstState.interventions.map((row) => row.id)).toEqual([first[0].id]);+ expect(secondState.interventions.map((row) => row.id)).toEqual([second[0].id]);++ const result = await claim(first, { answers: { mode: 'safe' }, type: 'submit_answers' });+ expect(result.outcome).toBe('applied');+ expect((await model.findBatch(secondOperationId, 'shared-batch')).interventions[0].status).toBe(+ 'pending',+ );+ });++ it('claims all binary items in one sealed transaction and records action outcome', async () => {+ const rows = await createRuntimeApprovalBatch({ count: 2 });+ const result = await claim(+ rows,+ { type: 'approve' },+ {+ actorId: ownerId,+ scope: 'all',+ selectedInterventionIds: rows.map((row) => row.id),+ },+ );+ expect(result.outcome).toBe('applied');+ if (result.outcome !== 'applied') throw new Error('claim failed');+ expect(result.interventions.every((row) => row.status === 'resolving')).toBe(true);+ expect(result.resolution).toMatchObject({+ action: { type: 'approve' },+ scope: 'all',+ selectedInterventionIds: rows.map((row) => row.id).sort(),+ });++ await model.markResolutionPublished(result.resolution.resolutionRequestId);+ await model.completeRuntimeResolution(result.resolution.resolutionRequestId);+ const state = await model.findBatch(rows[0].operationId, rows[0].batchId);+ expect(state.interventions.every((row) => row.status === 'resolved')).toBe(true);+ expect(state.resolutions[0]).toMatchObject({+ action: { type: 'approve' },+ status: 'completed',+ });+ });++ it('allows a partial custom item without claiming the rest of a mixed batch', async () => {+ await parkOperation();+ const rows = await model.createBatch({+ activityKey: 'custom-activity',+ batchId: 'custom-batch',+ deadline: new Date(Date.now() + 60_000),+ items: [+ questionItem({+ allowedActions: ['submit_custom'],+ interactionKind: 'custom',+ sanitizedRequest: {+ apiName: 'installMarketplaceItem',+ fields: [{ id: 'confirm', label: 'Install', required: true, type: 'boolean' }],+ },+ toolCallId: 'custom-1',+ }),+ questionItem({ toolCallId: 'question-2' }),+ ],+ operationId,+ source: 'runtime',+ stepIndex: 1,+ systemActionEligibility: 'review_only',+ });+ const result = await claim(+ rows,+ {+ expectedRevisionHash: rows[0].requestRevisionHash,+ result: { confirm: true },+ type: 'submit_custom',+ },+ { selectedInterventionIds: [rows[0].id] },+ );+ expect(result.outcome).toBe('applied');+ const state = await model.findBatch(operationId, 'custom-batch');+ expect(state.interventions.map((row) => row.status)).toEqual(['resolving', 'pending']);+ });++ describe('custom execution ledger', () => {+ const inputHash = 'b'.repeat(64);+ const otherInputHash = 'c'.repeat(64);+ const leaseDurationMs = 60_000;++ it('initializes only custom resolutions as private pending executions', async () => {+ const { resolution } = await createCustomResolution();+ expect(await model.findResolutionByRequestId(resolution.resolutionRequestId)).toMatchObject({+ customExecutionAttempt: 0,+ customExecutionInputHash: null,+ customExecutionLeaseExpiresAt: null,+ customExecutionLeaseToken: null,+ customExecutionResult: null,+ customExecutionState: 'pending',+ });++ const rows = await createQuestionBatch({ batchId: 'non-custom-execution' });+ const ordinary = await claim(rows, { answers: { mode: 'safe' }, type: 'submit_answers' });+ if (ordinary.outcome !== 'applied') throw new Error('ordinary resolution claim failed');+ expect(+ await model.findResolutionByRequestId(ordinary.resolution.resolutionRequestId),+ ).toMatchObject({+ customExecutionAttempt: null,+ customExecutionInputHash: null,+ customExecutionLeaseExpiresAt: null,+ customExecutionLeaseToken: null,+ customExecutionResult: null,+ customExecutionState: null,+ });+ });++ it('atomically grants one lease for concurrent claims of the same resolution', async () => {+ const { resolution } = await createCustomResolution();+ const now = new Date('2026-08-26T10:00:00.000Z');+ const results = await Promise.all(+ Array.from({ length: 8 }, () =>+ model.claimCustomExecution(+ {+ inputHash,+ leaseDurationMs,+ resolutionRequestId: resolution.resolutionRequestId,+ },+ now,+ ),+ ),+ );++ expect(results.filter(({ outcome }) => outcome === 'applied')).toHaveLength(1);+ expect(results.filter(({ outcome }) => outcome === 'in_progress')).toHaveLength(7);+ const applied = results.find(({ outcome }) => outcome === 'applied');+ expect(applied).toMatchObject({ attempt: 1, outcome: 'applied' });+ });++ it('returns in_progress without exposing the live lease token', async () => {+ const { resolution } = await createCustomResolution();+ const now = new Date('2026-08-26T10:00:00.000Z');+ const params = {+ inputHash,+ leaseDurationMs,+ resolutionRequestId: resolution.resolutionRequestId,+ };+ expect(await model.claimCustomExecution(params, now)).toMatchObject({+ attempt: 1,+ outcome: 'applied',+ });++ const live = await model.claimCustomExecution(params, new Date(now.getTime() + 59_999));+ expect(live).toMatchObject({ attempt: 1, outcome: 'in_progress' });+ expect(live).not.toHaveProperty('leaseToken');+ });++ it('does not claim a pending execution after its resolution rolls back', async () => {+ const { resolution } = await createCustomResolution();+ expect((await model.rollbackResolution(resolution.resolutionRequestId)).outcome).toBe(+ 'applied',+ );++ expect(+ await model.claimCustomExecution({+ inputHash,+ leaseDurationMs,+ resolutionRequestId: resolution.resolutionRequestId,+ }),+ ).toEqual({ outcome: 'conflict' });+ expect(await model.findResolutionByRequestId(resolution.resolutionRequestId)).toMatchObject({+ customExecutionAttempt: 0,+ customExecutionState: 'pending',+ status: 'rolled_back',+ });+ });++ it('allows terminal transition before execution and rejects the later claim', async () => {+ const { resolution, row } = await createCustomResolution();+ const terminalRows = await model.markBatchTerminal(+ row.operationId,+ row.batchId,+ 'session_ended',+ );+ expect(terminalRows[0].status).toBe('session_ended');+ expect(+ await model.claimCustomExecution({+ inputHash,+ leaseDurationMs,+ resolutionRequestId: resolution.resolutionRequestId,+ }),+ ).toEqual({ outcome: 'conflict' });+ expect(await model.findResolutionByRequestId(resolution.resolutionRequestId)).toMatchObject({+ customExecutionState: 'pending',+ status: 'session_ended',+ });+ });++ it('protects an executing winner while terminalizing its pending sibling', async () => {+ const { resolution, rows } = await createMixedCustomResolution();+ const now = new Date('2026-08-26T10:00:00.000Z');+ const params = {+ inputHash,+ leaseDurationMs: 1000,+ resolutionRequestId: resolution.resolutionRequestId,+ };+ const claimed = await model.claimCustomExecution(params, now);+ if (claimed.outcome !== 'applied') throw new Error('execution lease claim failed');++ await model.markBatchTerminal(+ rows[0].operationId,+ rows[0].batchId,+ 'session_ended',+ new Date(now.getTime() + 2000),+ );+ const state = await model.findBatch(rows[0].operationId, rows[0].batchId);+ expect(state.interventions.map(({ status }) => status)).toEqual([+ 'resolving',+ 'session_ended',+ ]);+ expect(await model.findResolutionByRequestId(resolution.resolutionRequestId)).toMatchObject({+ customExecutionAttempt: 1,+ customExecutionLeaseToken: claimed.leaseToken,+ customExecutionState: 'executing',+ status: 'resolving',+ });+ expect(+ await model.claimCustomExecution(params, new Date(now.getTime() + 2000)),+ ).toMatchObject({ attempt: 2, outcome: 'applied' });+ });++ it('replays the exact completed result and conflicts on input or result drift', async () => {+ const { resolution, row } = await createCustomResolution();+ const claimed = await model.claimCustomExecution({+ inputHash,+ leaseDurationMs,+ resolutionRequestId: resolution.resolutionRequestId,+ });+ if (claimed.outcome !== 'applied') throw new Error('execution lease claim failed');++ const result = {+ content: 'Installed two agents',+ pluginState: { agentIds: ['agent-a', 'agent-b'], source: 'marketplace' },+ };+ expect(+ await model.completeCustomExecution({+ inputHash,+ leaseToken: claimed.leaseToken,+ resolutionRequestId: resolution.resolutionRequestId,+ result,+ }),+ ).toEqual({ outcome: 'completed', result });+ expect(+ await model.completeCustomExecution({+ inputHash,+ leaseToken: claimed.leaseToken,+ resolutionRequestId: resolution.resolutionRequestId,+ result: {+ content: 'Installed two agents',+ pluginState: { source: 'marketplace', agentIds: ['agent-a', 'agent-b'] },+ },+ }),+ ).toEqual({ outcome: 'completed', result });+ expect(+ await model.completeCustomExecution({+ inputHash,+ leaseToken: claimed.leaseToken,+ resolutionRequestId: resolution.resolutionRequestId,+ result: { ...result, content: 'Different result' },+ }),+ ).toEqual({ outcome: 'conflict' });+ expect(+ await model.claimCustomExecution({+ inputHash,+ leaseDurationMs,+ resolutionRequestId: resolution.resolutionRequestId,+ }),+ ).toEqual({ outcome: 'completed', result });+ expect(+ await model.claimCustomExecution({+ inputHash: otherInputHash,+ leaseDurationMs,+ resolutionRequestId: resolution.resolutionRequestId,+ }),+ ).toEqual({ outcome: 'conflict' });++ const publicState = await model.findBatch(row.operationId, row.batchId);+ expect(publicState.resolutions[0]).not.toHaveProperty('customExecutionAttempt');+ expect(publicState.resolutions[0]).not.toHaveProperty('customExecutionInputHash');+ expect(publicState.resolutions[0]).not.toHaveProperty('customExecutionLeaseExpiresAt');+ expect(publicState.resolutions[0]).not.toHaveProperty('customExecutionLeaseToken');+ expect(publicState.resolutions[0]).not.toHaveProperty('customExecutionResult');+ expect(publicState.resolutions[0]).not.toHaveProperty('customExecutionState');+ });++ it('takes over an expired lease and fences the stale completion', async () => {+ const { resolution } = await createCustomResolution();+ const now = new Date('2026-08-26T10:00:00.000Z');+ const params = {+ inputHash,+ leaseDurationMs: 1000,+ resolutionRequestId: resolution.resolutionRequestId,+ };+ const first = await model.claimCustomExecution(params, now);+ if (first.outcome !== 'applied') throw new Error('first execution lease claim failed');+ const second = await model.claimCustomExecution(params, new Date(now.getTime() + 1000));+ if (second.outcome !== 'applied') throw new Error('lease takeover failed');++ expect(second).toMatchObject({ attempt: 2, outcome: 'applied' });+ expect(second.leaseToken).not.toBe(first.leaseToken);+ const result = { content: 'Installed', pluginState: { agentId: 'agent-a' } };+ expect(+ await model.completeCustomExecution({+ inputHash,+ leaseToken: first.leaseToken,+ resolutionRequestId: resolution.resolutionRequestId,+ result,+ }),+ ).toEqual({ outcome: 'conflict' });+ expect(+ await model.completeCustomExecution({+ inputHash,+ leaseToken: second.leaseToken,+ resolutionRequestId: resolution.resolutionRequestId,+ result,+ }),+ ).toEqual({ outcome: 'completed', result });+ });++ it('protects a completed winner from terminal teardown and replays its result', async () => {+ const { resolution, rows } = await createMixedCustomResolution();+ const params = {+ inputHash,+ leaseDurationMs,+ resolutionRequestId: resolution.resolutionRequestId,+ };+ const claimed = await model.claimCustomExecution(params);+ if (claimed.outcome !== 'applied') throw new Error('execution lease claim failed');+ const result = { content: 'Installed', pluginState: { agentId: 'agent-a' } };+ expect(+ await model.completeCustomExecution({+ inputHash,+ leaseToken: claimed.leaseToken,+ resolutionRequestId: resolution.resolutionRequestId,+ result,+ }),+ ).toEqual({ outcome: 'completed', result });++ await model.markBatchTerminal(+ rows[0].operationId,+ rows[0].batchId,+ 'timed_out',+ new Date(Math.max(...rows.map(({ deadline }) => deadline.getTime())) + 1),+ );+ const state = await model.findBatch(rows[0].operationId, rows[0].batchId);+ expect(state.interventions.map(({ status }) => status)).toEqual(['resolving', 'timed_out']);+ expect(state.resolutions[0]).toMatchObject({ status: 'resolving' });+ expect(await model.claimCustomExecution(params)).toEqual({ outcome: 'completed', result });+ });++ it('keeps a heterogeneous completed result replayable after producer ACK', async () => {+ const { resolution } = await createCustomResolution();+ const params = {+ inputHash,+ leaseDurationMs,+ resolutionRequestId: resolution.resolutionRequestId,+ };+ const claimed = await model.claimCustomExecution(params);+ if (claimed.outcome !== 'applied') throw new Error('execution lease claim failed');+ const result = { content: 'Installed', pluginState: { agentId: 'agent-a' } };+ expect(+ await model.completeCustomExecution({+ inputHash,+ leaseToken: claimed.leaseToken,+ resolutionRequestId: resolution.resolutionRequestId,+ result,+ }),+ ).toEqual({ outcome: 'completed', result });++ expect((await model.markResolutionPublished(resolution.resolutionRequestId)).outcome).toBe(+ 'applied',+ );+ expect(+ (await model.acknowledgeProducerResolution(resolution.resolutionRequestId)).outcome,+ ).toBe('applied');+ expect(await model.claimCustomExecution(params)).toEqual({ outcome: 'completed', result });+ expect(await model.findResolutionByRequestId(resolution.resolutionRequestId)).toMatchObject({+ customExecutionState: 'completed',+ status: 'acknowledged',+ });+ });++ it('keeps the original execution active when its claim wins before rollback', async () => {+ const { resolution } = await createCustomResolution();+ const params = {+ inputHash,+ leaseDurationMs: 1000,+ resolutionRequestId: resolution.resolutionRequestId,+ };+ const now = new Date('2026-08-26T10:00:00.000Z');+ const claimed = await model.claimCustomExecution(params, now);+ if (claimed.outcome !== 'applied') throw new Error('execution lease claim failed');+ const result = { content: 'Installed', pluginState: { agentId: 'agent-a' } };++ expect((await model.rollbackResolution(resolution.resolutionRequestId)).outcome).toBe(+ 'conflict',+ );+ expect(+ await model.claimCustomExecution(params, new Date(now.getTime() + 1000)),+ ).toMatchObject({ attempt: 2, outcome: 'applied' });+ expect(+ await model.completeCustomExecution({+ inputHash,+ leaseToken: claimed.leaseToken,+ resolutionRequestId: resolution.resolutionRequestId,+ result,+ }),+ ).toEqual({ outcome: 'conflict' });+ });++ it('replays the durable result when completion wins before rollback', async () => {+ const { resolution, row } = await createCustomResolution();+ const params = {+ inputHash,+ leaseDurationMs,+ resolutionRequestId: resolution.resolutionRequestId,+ };+ const claimed = await model.claimCustomExecution(params);+ if (claimed.outcome !== 'applied') throw new Error('execution lease claim failed');+ const result = { content: 'Installed', pluginState: { agentId: 'agent-a' } };+ const completion = {+ inputHash,+ leaseToken: claimed.leaseToken,+ resolutionRequestId: resolution.resolutionRequestId,+ result,+ };++ expect(await model.completeCustomExecution(completion)).toEqual({+ outcome: 'completed',+ result,+ });+ expect((await model.rollbackResolution(resolution.resolutionRequestId)).outcome).toBe(+ 'conflict',+ );+ expect(await model.completeCustomExecution(completion)).toEqual({+ outcome: 'completed',+ result,+ });+ expect(await model.claimCustomExecution(params)).toEqual({ outcome: 'completed', result });++ const currentRows = (await model.findBatch(row.operationId, row.batchId)).interventions;+ expect(+ await claim(+ currentRows,+ {+ expectedRevisionHash: currentRows[0].requestRevisionHash,+ result: { confirm: true },+ type: 'submit_custom',+ },+ { resolutionRequestId: randomUUID() },+ ),+ ).toMatchObject({ outcome: 'conflict' });+ });++ it('rejects terminal writes from old instances once custom execution has started', async () => {+ const { resolution } = await createCustomResolution();+ const claimed = await model.claimCustomExecution({+ inputHash,+ leaseDurationMs,+ resolutionRequestId: resolution.resolutionRequestId,+ });+ if (claimed.outcome !== 'applied') throw new Error('execution lease claim failed');++ const oldTerminalWrite = (status: 'rolled_back' | 'session_ended' | 'timed_out') =>+ serverDB+ .update(agentInterventionResolutions)+ .set({ status })+ .where(eq(agentInterventionResolutions.id, resolution.id));+ for (const status of ['rolled_back', 'session_ended', 'timed_out'] as const) {+ await expect(oldTerminalWrite(status)).rejects.toThrow();+ }++ const result = { content: 'Installed', pluginState: { agentId: 'agent-a' } };+ expect(+ await model.completeCustomExecution({+ inputHash,+ leaseToken: claimed.leaseToken,+ resolutionRequestId: resolution.resolutionRequestId,+ result,+ }),+ ).toEqual({ outcome: 'completed', result });+ for (const status of ['rolled_back', 'session_ended', 'timed_out'] as const) {+ await expect(oldTerminalWrite(status)).rejects.toThrow();+ }+ expect(await model.findResolutionByRequestId(resolution.resolutionRequestId)).toMatchObject({+ customExecutionState: 'completed',+ status: 'resolving',+ });+ });++ it('rejects the wrong lease, wrong owner, invalid hash, and out-of-bounds duration', async () => {+ const { resolution } = await createCustomResolution();+ const params = {+ inputHash,+ leaseDurationMs,+ resolutionRequestId: resolution.resolutionRequestId,+ };+ const claimed = await model.claimCustomExecution(params);+ if (claimed.outcome !== 'applied') throw new Error('execution lease claim failed');+ const result = { content: 'Installed', pluginState: {} };++ expect(+ await model.completeCustomExecution({+ inputHash,+ leaseToken: randomUUID(),+ resolutionRequestId: resolution.resolutionRequestId,+ result,+ }),+ ).toEqual({ outcome: 'conflict' });+ expect(await otherUserModel.claimCustomExecution(params)).toEqual({ outcome: 'conflict' });+ expect(await model.claimCustomExecution({ ...params, inputHash: 'not-a-sha256' })).toEqual({+ outcome: 'conflict',+ });+ expect(await model.claimCustomExecution({ ...params, leaseDurationMs: 999 })).toEqual({+ outcome: 'conflict',+ });+ expect(await model.claimCustomExecution({ ...params, leaseDurationMs: 900_001 })).toEqual({+ outcome: 'conflict',+ });+ });+ });++ it('preserves bounded marketplace picker detail and whitelists selected agent ids', async () => {+ await expect(+ createQuestionBatch({+ batchId: 'unsafe-marketplace-batch',+ items: [+ questionItem({+ allowedActions: ['submit_custom'],+ interactionKind: 'custom',+ sanitizedRequest: {+ apiName: 'selectMarketplaceAgents',+ customDetail: {+ agents: [{ id: 'a', title: 'Agent A' }],+ kind: 'agent_marketplace',+ rawArguments: '{"secret":true}',+ } as never,+ },+ toolCallId: 'unsafe-marketplace-tool',+ }),+ ],+ }),+ ).rejects.toThrow(AGENT_INTERVENTION_INVALID_BATCH);++ await parkOperation();+ const rows = await model.createBatch({+ activityKey: 'marketplace-activity',+ batchId: 'marketplace-batch',+ deadline: new Date(Date.now() + 60_000),+ items: [+ questionItem({+ allowedActions: ['submit_custom', 'cancel_interaction'],+ interactionKind: 'custom',+ sanitizedRequest: {+ apiName: 'selectMarketplaceAgents',+ customDetail: {+ agents: [+ { avatar: 'https://example.com/a.png', id: 'a', title: 'Agent A' },+ { description: 'Second agent', id: 'b', title: 'Agent B' },+ ],+ categoryHints: ['coding'],+ kind: 'agent_marketplace',+ requestId: 'request-1',+ selectedIds: ['a'],+ },+ },+ toolCallId: 'marketplace-tool',+ }),+ ],+ operationId,+ source: 'runtime',+ stepIndex: 2,+ systemActionEligibility: 'review_only',+ });+ expect(rows[0].sanitizedRequest.customDetail).toMatchObject({+ agents: [+ { id: 'a', title: 'Agent A' },+ { id: 'b', title: 'Agent B' },+ ],+ categoryHints: ['coding'],+ requestId: 'request-1',+ selectedIds: ['a'],+ });+ await expect(+ claim(rows, {+ expectedRevisionHash: rows[0].requestRevisionHash,+ result: { selectedIds: ['forged'] },+ type: 'submit_custom',+ }),+ ).rejects.toThrow(AGENT_INTERVENTION_INVALID_ACTION);+ expect(+ (+ await claim(rows, {+ expectedRevisionHash: rows[0].requestRevisionHash,+ result: { selectedIds: ['a', 'b'] },+ type: 'submit_custom',+ })+ ).outcome,+ ).toBe('applied');+ });++ it('validates answer ids, option whitelist, and scalar/multi cardinality from the row', async () => {+ const rows = await createQuestionBatch({ batchId: 'answers-batch' });+ await expect(+ claim(rows, { answers: { unknown: 'safe' }, type: 'submit_answers' }),+ ).rejects.toThrow(AGENT_INTERVENTION_INVALID_ACTION);+ await expect(+ claim(rows, { answers: { mode: ['safe'] }, type: 'submit_answers' }),+ ).rejects.toThrow(AGENT_INTERVENTION_INVALID_ACTION);+ await expect(claim(rows, { answers: null as never, type: 'submit_answers' })).rejects.toThrow(+ AGENT_INTERVENTION_INVALID_ACTION,+ );+ await expect(+ claim(rows, { answers: { mode: 'unlisted' }, type: 'submit_answers' }),+ ).rejects.toThrow(AGENT_INTERVENTION_INVALID_ACTION);+ expect((await claim(rows, { answers: { mode: 'safe' }, type: 'submit_answers' })).outcome).toBe(+ 'applied',+ );+ });++ it('supports explicitly enabled freeform, supplement, and per-question custom answers', async () => {+ const customRows = await createQuestionBatch({+ batchId: 'custom-answer-batch',+ items: [+ questionItem({+ sanitizedRequest: {+ answerPolicy: { allowFreeform: true, allowSupplement: true },+ apiName: 'askUserQuestion',+ questions: [+ {+ allowCustomAnswer: true,+ id: 'mode',+ options: [{ id: 'safe', label: 'Safe' }],+ question: 'Which mode?',+ },+ ],+ },+ toolCallId: 'custom-answer-tool',+ }),+ ],+ });+ expect(+ (+ await claim(customRows, {+ answers: { __supplement__: 'Additional context', mode: 'my-own-mode' },+ type: 'submit_answers',+ })+ ).outcome,+ ).toBe('applied');++ const freeformRows = await createQuestionBatch({+ batchId: 'freeform-answer-batch',+ items: [+ questionItem({+ sanitizedRequest: {+ answerPolicy: { allowFreeform: true },+ apiName: 'askUserQuestion',+ questions: [+ {+ id: 'mode',+ options: [{ id: 'safe', label: 'Safe' }],+ question: 'Which mode?',+ },+ ],+ },+ toolCallId: 'freeform-answer-tool',+ }),+ ],+ });+ expect(+ (+ await claim(freeformRows, {+ answers: { __freeform__: 'Handle this another way' },+ type: 'submit_answers',+ })+ ).outcome,+ ).toBe('applied');++ await expect(+ createQuestionBatch({+ batchId: 'permission-freeform-batch',+ items: [+ questionItem({+ interactionKind: 'permission',+ sanitizedRequest: {+ answerPolicy: { allowFreeform: true },+ apiName: 'requestPermission',+ },+ toolCallId: 'permission-freeform-tool',+ }),+ ],+ }),+ ).rejects.toThrow(AGENT_INTERVENTION_INVALID_ACTION);+ });++ it('validates exact provider option ids and only producer ACK completes heterogeneous rows', async () => {+ const rows = await model.createBatch({+ activityKey: 'provider-activity',+ batchId: 'provider-batch',+ deadline: new Date(Date.now() + 60_000),+ items: [+ questionItem({+ allowedActions: ['select_provider_option', 'cancel_interaction'],+ interactionKind: 'permission',+ sanitizedRequest: {+ apiName: 'requestPermission',+ options: [+ { id: 'allow_once', label: 'Allow once' },+ { id: 'deny', label: 'Deny' },+ ],+ },+ toolCallId: 'permission-tool',+ }),+ ],+ operationId,+ provider: 'claude-code',+ source: 'heterogeneous',+ stepIndex: 1,+ systemActionEligibility: 'review_only',+ });+ await expect(+ claim(rows, { optionId: 'forged', type: 'select_provider_option' }),+ ).rejects.toThrow(AGENT_INTERVENTION_INVALID_ACTION);++ const claimed = await claim(rows, {+ optionId: 'allow_once',+ type: 'select_provider_option',+ });+ if (claimed.outcome !== 'applied') throw new Error('claim failed');+ await model.markResolutionPublished(claimed.resolution.resolutionRequestId);+ await expect(+ model.completeRuntimeResolution(claimed.resolution.resolutionRequestId),+ ).rejects.toThrow(AGENT_INTERVENTION_SOURCE_TRANSITION_MISMATCH);+ expect(+ (await model.acknowledgeProducerResolution(claimed.resolution.resolutionRequestId)).outcome,+ ).toBe('applied');+ });++ it('lets only one concurrent request win and makes exact retries idempotent', async () => {+ const rows = await createQuestionBatch({ batchId: 'race-batch' });+ const requestId = randomUUID();+ const params = {+ action: { answers: { mode: 'safe' }, type: 'submit_answers' } as const,+ actorId,+ batchId: rows[0].batchId,+ operationId,+ resolutionRequestId: requestId,+ scope: 'single' as const,+ selectedInterventionIds: [rows[0].id],+ ...snapshot(rows),+ };+ const [first, second] = await Promise.all([+ model.claimBatch(params),+ model.claimBatch({ ...params, resolutionRequestId: randomUUID() }),+ ]);+ expect([first.outcome, second.outcome].sort()).toEqual(['applied', 'conflict']);++ const winner = first.outcome === 'applied' ? first : second;+ const winnerRequestId = winner.resolution?.resolutionRequestId;+ expect(winnerRequestId).toBeDefined();+ const retry = await model.claimBatch({ ...params, resolutionRequestId: winnerRequestId! });+ expect(retry.outcome).toBe('idempotent');+ await expect(+ model.claimBatch({+ ...params,+ expectedItemCount: params.expectedItemCount + 1,+ resolutionRequestId: winnerRequestId!,+ }),+ ).rejects.toThrow(AGENT_INTERVENTION_RESOLUTION_REQUEST_REUSED);+ await expect(+ model.claimBatch({+ ...params,+ action: { answers: { mode: 'fast' }, type: 'submit_answers' },+ resolutionRequestId: winnerRequestId!,+ }),+ ).rejects.toThrow(AGENT_INTERVENTION_RESOLUTION_REQUEST_REUSED);+ });++ it('reactivates the exact rolled-back request id while the original snapshot is still pending', async () => {+ const rows = await createRuntimeApprovalBatch({ batchId: 'retry-after-rollback' });+ const resolutionRequestId = randomUUID();+ const params = {+ action: { editedArguments: { path: 'retried.txt' }, type: 'approve' } as const,+ actorId: ownerId,+ batchId: rows[0].batchId,+ operationId,+ resolutionRequestId,+ scope: 'single' as const,+ selectedInterventionIds: [rows[0].id],+ ...snapshot(rows),+ };+ const first = await model.claimBatch(params);+ expect(first.outcome).toBe('applied');+ await model.rollbackResolution(resolutionRequestId);++ const retry = await model.claimBatch(params);+ expect(retry.outcome).toBe('applied');+ if (retry.outcome !== 'applied') throw new Error('reactivation failed');+ expect(retry.resolution).toMatchObject({ resolutionRequestId, status: 'resolving' });+ expect(retry.interventions[0]).toMatchObject({+ resolutionId: retry.resolution.id,+ status: 'resolving',+ });+ const [plugin] = await serverDB+ .select({ arguments: messagePlugins.arguments })+ .from(messagePlugins)+ .where(eq(messagePlugins.id, rows[0].toolMessageId!));+ expect(plugin.arguments).toBe('{"path":"retried.txt"}');+ });++ it('does not reactivate a rolled-back request after another request wins', async () => {+ const rows = await createQuestionBatch({ batchId: 'retry-lost-race' });+ const resolutionRequestId = randomUUID();+ const originalParams = {+ action: { answers: { mode: 'safe' }, type: 'submit_answers' } as const,+ actorId,+ batchId: rows[0].batchId,+ operationId,+ resolutionRequestId,+ scope: 'single' as const,+ selectedInterventionIds: [rows[0].id],+ ...snapshot(rows),+ };+ expect((await model.claimBatch(originalParams)).outcome).toBe('applied');+ await model.rollbackResolution(resolutionRequestId);++ const reopened = await model.findBatch(operationId, rows[0].batchId);+ expect(+ (+ await claim(+ reopened.interventions,+ { answers: { mode: 'fast' }, type: 'submit_answers' },+ { resolutionRequestId: randomUUID() },+ )+ ).outcome,+ ).toBe('applied');++ const lostRetry = await model.claimBatch(originalParams);+ expect(lostRetry.outcome).toBe('conflict');+ expect(lostRetry.interventions?.[0].status).toBe('resolving');+ });++ it('atomically appends remember and conditionally removes only its own new key', async () => {+ await serverDB.insert(userSettings).values({+ id: ownerId,+ tool: { humanIntervention: { allowList: ['existing/tool'], approvalMode: 'allow-list' } },+ });+ const rows = await createRuntimeApprovalBatch({ canonicalToolKey: 'filesystem/writeFile' });+ const claimed = await claim(rows, { type: 'approve_remember' }, { actorId: ownerId });+ if (claimed.outcome !== 'applied') throw new Error('claim failed');+ const [afterClaim] = await serverDB+ .select({ tool: userSettings.tool })+ .from(userSettings)+ .where(eq(userSettings.id, ownerId));+ expect(afterClaim.tool).toMatchObject({+ humanIntervention: {+ allowList: ['existing/tool', 'filesystem/writeFile'],+ approvalMode: 'allow-list',+ },+ });++ await model.rollbackResolution(claimed.resolution.resolutionRequestId);+ const [afterRollback] = await serverDB+ .select({ tool: userSettings.tool })+ .from(userSettings)+ .where(eq(userSettings.id, ownerId));+ expect(afterRollback.tool).toMatchObject({+ humanIntervention: { allowList: ['existing/tool'], approvalMode: 'allow-list' },+ });+ });++ it('does not remove a pre-existing or concurrently retained remember key on rollback', async () => {+ await serverDB.insert(userSettings).values({+ id: ownerId,+ tool: { humanIntervention: { allowList: ['filesystem/writeFile'] } },+ });+ const first = await createRuntimeApprovalBatch({ batchId: 'remember-existing' });+ const firstClaim = await claim(first, { type: 'approve_remember' }, { actorId: ownerId });+ if (firstClaim.outcome !== 'applied') throw new Error('claim failed');+ await model.rollbackResolution(firstClaim.resolution.resolutionRequestId);++ const [settings] = await serverDB+ .select({ tool: userSettings.tool })+ .from(userSettings)+ .where(eq(userSettings.id, ownerId));+ expect(settings.tool).toMatchObject({+ humanIntervention: { allowList: ['filesystem/writeFile'] },+ });+ });++ it('keeps a newly remembered key when another active resolution retained it', async () => {+ const first = await createRuntimeApprovalBatch({+ batchId: 'remember-first',+ operationId,+ });+ const second = await createRuntimeApprovalBatch({+ batchId: 'remember-second',+ operationId: secondOperationId,+ });+ const firstClaim = await claim(first, { type: 'approve_remember' }, { actorId: ownerId });+ if (firstClaim.outcome !== 'applied') throw new Error('claim failed');+ const [secondClaim, rolledBack] = await Promise.all([+ claim(second, { type: 'approve_remember' }, { actorId: ownerId }),+ model.rollbackResolution(firstClaim.resolution.resolutionRequestId),+ ]);+ if (secondClaim.outcome !== 'applied') throw new Error('claim failed');+ expect(rolledBack.outcome).toBe('applied');+ const [settings] = await serverDB+ .select({ tool: userSettings.tool })+ .from(userSettings)+ .where(eq(userSettings.id, ownerId));+ expect(settings.tool).toMatchObject({+ humanIntervention: { allowList: ['filesystem/writeFile'] },+ });+ });++ it('edits authoritative arguments in the claim transaction and restores them on rollback', async () => {+ const rows = await createRuntimeApprovalBatch({ batchId: 'edit-batch' });+ const originalArguments = JSON.stringify({ path: 'file-0.txt' });+ const claimed = await claim(+ rows,+ {+ editedArguments: { a: { x: 1, y: 2 }, path: 'edited.txt', z: 1 },+ type: 'approve',+ },+ { actorId: ownerId },+ );+ if (claimed.outcome !== 'applied') throw new Error('claim failed');++ const [pluginAfterEdit] = await serverDB+ .select()+ .from(messagePlugins)+ .where(eq(messagePlugins.id, rows[0].toolMessageId!));+ expect(pluginAfterEdit.arguments).toBe('{"a":{"x":1,"y":2},"path":"edited.txt","z":1}');+ expect(claimed.resolution).toMatchObject({+ argumentEffectStatus: 'applied',+ editedArguments: '{"a":{"x":1,"y":2},"path":"edited.txt","z":1}',+ originalArguments,+ });++ await model.rollbackResolution(claimed.resolution.resolutionRequestId);+ const [pluginAfterRollback] = await serverDB+ .select()+ .from(messagePlugins)+ .where(eq(messagePlugins.id, rows[0].toolMessageId!));+ expect(pluginAfterRollback.arguments).toBe(originalArguments);+ const state = await model.findBatch(operationId, 'edit-batch');+ expect(state.interventions[0]).toMatchObject({+ requestRevisionHash: hashAgentInterventionRequestRevision(originalArguments),+ status: 'pending',+ });+ });++ it('rejects non-JSON-safe edited arguments before mutating the tool message', async () => {+ const rows = await createRuntimeApprovalBatch({ batchId: 'unsafe-edit-batch' });+ const cyclic: Record<string, unknown> = {};+ cyclic.self = cyclic;+ const sparseArray: unknown[] = [];+ sparseArray.length = 1;+ const unsafeValues: [string, unknown][] = [+ ['undefined', undefined],+ ['date', new Date()],+ ['bigint', 1n],+ ['function', () => true],+ ['symbol', Symbol('unsafe')],+ ['nan', Number.NaN],+ ['infinity', Number.POSITIVE_INFINITY],+ ['negative-infinity', Number.NEGATIVE_INFINITY],+ ['sparse-array', sparseArray],+ ['cycle', cyclic],+ ];++ for (const [, value] of unsafeValues) {+ await expect(+ claim(rows, { editedArguments: { value }, type: 'approve' } as never, { actorId: ownerId }),+ ).rejects.toThrow(AGENT_INTERVENTION_INVALID_ACTION);+ }++ const [plugin] = await serverDB+ .select({ arguments: messagePlugins.arguments })+ .from(messagePlugins)+ .where(eq(messagePlugins.id, rows[0].toolMessageId!));+ expect(plugin.arguments).toBe('{"path":"file-0.txt"}');+ expect((await model.findBatch(operationId, rows[0].batchId)).interventions[0].status).toBe(+ 'pending',+ );+ });++ it('fails closed when authoritative arguments no longer match the Review revision', async () => {+ const rows = await createRuntimeApprovalBatch({ batchId: 'stale-args-batch' });+ await serverDB+ .update(messagePlugins)+ .set({ arguments: '{"path":"changed-elsewhere.txt"}' })+ .where(eq(messagePlugins.id, rows[0].toolMessageId!));+ await expect(claim(rows, { type: 'approve' }, { actorId: ownerId })).rejects.toThrow(+ AGENT_INTERVENTION_INVALID_REQUEST_REVISION_HASH,+ );+ });++ it('does not overwrite a newer argument edit during conditional rollback', async () => {+ const rows = await createRuntimeApprovalBatch({ batchId: 'edit-cas-batch' });+ const claimed = await claim(+ rows,+ { editedArguments: { path: 'claimed.txt' }, type: 'approve' },+ { actorId: ownerId },+ );+ if (claimed.outcome !== 'applied') throw new Error('claim failed');+ const newerArguments = '{"path":"newer.txt"}';+ await serverDB+ .update(messagePlugins)+ .set({ arguments: newerArguments })+ .where(eq(messagePlugins.id, rows[0].toolMessageId!));++ const rolledBack = await model.rollbackResolution(claimed.resolution.resolutionRequestId);+ expect(rolledBack.outcome).toBe('applied');+ if (rolledBack.outcome !== 'applied') throw new Error('rollback failed');+ expect(rolledBack.resolution.argumentEffectStatus).toBe('retained');+ const [plugin] = await serverDB+ .select()+ .from(messagePlugins)+ .where(eq(messagePlugins.id, rows[0].toolMessageId!));+ expect(plugin.arguments).toBe(newerArguments);+ });++ it('requires explicit safe single binary eligibility and operation-wide stop scope', async () => {+ await expect(+ createQuestionBatch({ systemActionEligibility: 'safe_single_binary' }),+ ).rejects.toThrow();+ const rows = await createRuntimeApprovalBatch({ count: 2 });+ await expect(claim(rows, { haltScope: 'operation', type: 'stop' })).rejects.toThrow(+ AGENT_INTERVENTION_INVALID_ACTION,+ );+ expect(+ (+ await claim(+ rows,+ { haltScope: 'operation', type: 'stop' },+ {+ actorId: ownerId,+ scope: 'all',+ selectedInterventionIds: rows.map((row) => row.id),+ },+ )+ ).outcome,+ ).toBe('applied');+ });++ it('stops only the remaining pending items in a partially completed sealed batch', async () => {+ const rows = await createRuntimeApprovalBatch({ count: 2 });+ const firstClaim = await claim(rows, { type: 'approve' }, { actorId: ownerId });+ expect(firstClaim.outcome).toBe('applied');+ if (firstClaim.outcome !== 'applied') throw new Error('claim failed');+ await model.markResolutionPublished(firstClaim.resolution.resolutionRequestId);+ await model.completeRuntimeResolution(firstClaim.resolution.resolutionRequestId);++ const partial = await model.findBatch(rows[0].operationId, rows[0].batchId);+ expect(partial.interventions.map((row) => row.status)).toEqual(['resolved', 'pending']);+ const pending = partial.interventions.filter((row) => row.status === 'pending');+ const stopped = await claim(+ partial.interventions,+ { haltScope: 'operation', type: 'stop' },+ {+ actorId: ownerId,+ scope: 'all',+ selectedInterventionIds: pending.map((row) => row.id),+ },+ );++ expect(stopped.outcome).toBe('applied');+ if (stopped.outcome !== 'applied') throw new Error('stop failed');+ expect(stopped.interventions.map((row) => row.status)).toEqual(['resolved', 'resolving']);+ expect(stopped.resolution).toMatchObject({+ action: { haltScope: 'operation', type: 'stop' },+ scope: 'all',+ selectedInterventionIds: pending.map((row) => row.id),+ });+ });++ it('atomically supersedes a partial runtime batch even when the published hook is late', async () => {+ const original = await createRuntimeApprovalBatch({ batchId: 'superseded-batch', count: 2 });+ const claimed = await claim(original, { type: 'approve' }, { actorId: ownerId });+ if (claimed.outcome !== 'applied') throw new Error('claim failed');+ const pending = (await model.findBatch(operationId, 'superseded-batch')).interventions.filter(+ (row) => row.status === 'pending',+ );+ await serverDB+ .update(agentOperations)+ .set({ completionReason: 'waiting_for_human', status: 'waiting_for_human' })+ .where(eq(agentOperations.id, secondOperationId));+ const batch = createReparkBatchParams(pending, { batchId: 'replacement-batch' });+ const supersedes = {+ activityKey: original[0].activityKey,+ batchId: original[0].batchId,+ operationId: original[0].operationId,+ toolCallIds: pending.map((row) => row.toolCallId),+ };++ const replaced = await model.createBatchWithSupersession({ batch, supersedes });+ expect(replaced.outcome).toBe('applied');+ expect(replaced.interventions).toHaveLength(1);+ expect(replaced.interventions[0]).toMatchObject({+ batchId: 'replacement-batch',+ operationId: secondOperationId,+ status: 'pending',+ toolCallId: pending[0].toolCallId,+ });+ expect(replaced.superseded?.interventions.map((row) => row.status)).toEqual([+ 'resolved',+ 'session_ended',+ ]);+ expect(+ (await model.findResolutionByRequestId(claimed.resolution.resolutionRequestId))?.status,+ ).toBe('completed');+ const operations = await serverDB+ .select({ id: agentOperations.id, status: agentOperations.status })+ .from(agentOperations);+ expect(operations.find(({ id }) => id === operationId)?.status).toBe('done');+ expect(operations.find(({ id }) => id === secondOperationId)?.status).toBe('waiting_for_human');++ expect(+ (await model.markResolutionPublished(claimed.resolution.resolutionRequestId)).outcome,+ ).toBe('idempotent');+ expect(+ (await model.completeRuntimeResolution(claimed.resolution.resolutionRequestId)).outcome,+ ).toBe('idempotent');+ await serverDB+ .update(agentOperations)+ .set({ completionReason: 'done', status: 'done' })+ .where(eq(agentOperations.id, secondOperationId));+ expect((await model.createBatchWithSupersession({ batch, supersedes })).outcome).toBe(+ 'idempotent',+ );+ });++ it('supersedes the remaining rows after the prior published hook already completed', async () => {+ const original = await createRuntimeApprovalBatch({ batchId: 'published-first', count: 2 });+ const claimed = await claim(original, { type: 'approve' }, { actorId: ownerId });+ if (claimed.outcome !== 'applied') throw new Error('claim failed');+ await model.markResolutionPublished(claimed.resolution.resolutionRequestId);+ await model.completeRuntimeResolution(claimed.resolution.resolutionRequestId);+ const pending = (await model.findBatch(operationId, 'published-first')).interventions.filter(+ (row) => row.status === 'pending',+ );+ await serverDB+ .update(agentOperations)+ .set({ completionReason: 'waiting_for_human', status: 'waiting_for_human' })+ .where(eq(agentOperations.id, secondOperationId));+ const batch = createReparkBatchParams(pending, { batchId: 'published-first-replacement' });++ const replaced = await model.createBatchWithSupersession({+ batch,+ supersedes: {+ activityKey: original[0].activityKey,+ batchId: original[0].batchId,+ operationId: original[0].operationId,+ toolCallIds: pending.map((row) => row.toolCallId),+ },+ });+ expect(replaced.outcome).toBe('applied');+ expect(replaced.superseded?.interventions.map((row) => row.status)).toEqual([+ 'resolved',+ 'session_ended',+ ]);+ });++ it('fails supersession closed without leaving a partial replacement batch', async () => {+ const original = await createRuntimeApprovalBatch({ batchId: 'conflicting-old', count: 2 });+ const claimed = await claim(original, { type: 'approve' }, { actorId: ownerId });+ if (claimed.outcome !== 'applied') throw new Error('claim failed');+ const pending = (await model.findBatch(operationId, 'conflicting-old')).interventions.filter(+ (row) => row.status === 'pending',+ );+ await serverDB+ .update(agentOperations)+ .set({ completionReason: 'waiting_for_human', status: 'waiting_for_human' })+ .where(eq(agentOperations.id, secondOperationId));+ const batch = createReparkBatchParams(pending, { batchId: 'must-not-exist' });++ await expect(+ model.createBatchWithSupersession({+ batch,+ supersedes: {+ activityKey: original[0].activityKey,+ batchId: original[0].batchId,+ operationId: original[0].operationId,+ toolCallIds: ['not-the-pending-tool'],+ },+ }),+ ).rejects.toThrow(AGENT_INTERVENTION_IDENTITY_CONFLICT);+ expect((await model.findBatch(secondOperationId, 'must-not-exist')).interventions).toEqual([]);+ expect(+ (await model.findBatch(operationId, 'conflicting-old')).interventions.map(+ (row) => row.status,+ ),+ ).toEqual(['resolving', 'pending']);+ });++ it('never supersedes a stopped runtime batch into a new parked batch', async () => {+ const original = await createRuntimeApprovalBatch({ batchId: 'stopped-old', count: 2 });+ const claimed = await claim(original, { type: 'approve' }, { actorId: ownerId });+ if (claimed.outcome !== 'applied') throw new Error('claim failed');+ await serverDB+ .update(agentInterventionResolutions)+ .set({ action: { haltScope: 'operation', type: 'stop' } })+ .where(eq(agentInterventionResolutions.id, claimed.resolution.id));+ const pending = (await model.findBatch(operationId, 'stopped-old')).interventions.filter(+ (row) => row.status === 'pending',+ );+ await serverDB+ .update(agentOperations)+ .set({ completionReason: 'waiting_for_human', status: 'waiting_for_human' })+ .where(eq(agentOperations.id, secondOperationId));+ const batch = createReparkBatchParams(pending, { batchId: 'must-not-repark-stop' });++ await expect(+ model.createBatchWithSupersession({+ batch,+ supersedes: {+ activityKey: original[0].activityKey,+ batchId: original[0].batchId,+ operationId: original[0].operationId,+ toolCallIds: pending.map((row) => row.toolCallId),+ },+ }),+ ).rejects.toThrow(AGENT_INTERVENTION_IDENTITY_CONFLICT);+ expect(+ (await model.findBatch(secondOperationId, 'must-not-repark-stop')).interventions,+ ).toEqual([]);+ });++ it('rejects a replacement operation from a different conversation context', async () => {+ await serverDB+ .update(agentOperations)+ .set({ appContext: { scope: 'main', sessionId: 'agent-a' } })+ .where(eq(agentOperations.id, operationId));+ await serverDB+ .update(agentOperations)+ .set({ appContext: { scope: 'thread', sessionId: 'agent-a' } })+ .where(eq(agentOperations.id, secondOperationId));+ const original = await createRuntimeApprovalBatch({ batchId: 'context-old', count: 2 });+ const claimed = await claim(original, { type: 'approve' }, { actorId: ownerId });+ if (claimed.outcome !== 'applied') throw new Error('claim failed');+ const pending = (await model.findBatch(operationId, 'context-old')).interventions.filter(+ (row) => row.status === 'pending',+ );+ await serverDB+ .update(agentOperations)+ .set({ completionReason: 'waiting_for_human', status: 'waiting_for_human' })+ .where(eq(agentOperations.id, secondOperationId));++ await expect(+ model.createBatchWithSupersession({+ batch: createReparkBatchParams(pending, { batchId: 'wrong-context' }),+ supersedes: {+ activityKey: original[0].activityKey,+ batchId: original[0].batchId,+ operationId: original[0].operationId,+ toolCallIds: pending.map((row) => row.toolCallId),+ },+ }),+ ).rejects.toThrow(AGENT_INTERVENTION_IDENTITY_CONFLICT);+ expect((await model.findBatch(secondOperationId, 'wrong-context')).interventions).toEqual([]);+ });++ it('retires the exact parked operation when a runtime continuation completes', async () => {+ const rows = await createRuntimeApprovalBatch({ batchId: 'retire-operation' });+ const claimed = await claim(rows, { type: 'reject_continue' }, { actorId: ownerId });+ if (claimed.outcome !== 'applied') throw new Error('claim failed');+ await model.markResolutionPublished(claimed.resolution.resolutionRequestId);+ expect(+ (await model.completeRuntimeResolution(claimed.resolution.resolutionRequestId)).outcome,+ ).toBe('applied');+ const [operation] = await serverDB+ .select({ completedAt: agentOperations.completedAt, status: agentOperations.status })+ .from(agentOperations)+ .where(eq(agentOperations.id, operationId));+ expect(operation.status).toBe('done');+ expect(operation.completedAt).toBeInstanceOf(Date);+ });++ it('times out items and the active outbox atomically, then records a late ACK only as audit', async () => {+ const rows = await createQuestionBatch({ batchId: 'timeout-batch' });+ const claimed = await claim(rows, { answers: { mode: 'safe' }, type: 'submit_answers' });+ if (claimed.outcome !== 'applied') throw new Error('claim failed');+ await model.markResolutionPublished(claimed.resolution.resolutionRequestId);++ const terminal = await model.markBatchTerminal(+ operationId,+ 'timeout-batch',+ 'timed_out',+ new Date(Date.now() + 20 * 60_000),+ );+ expect(terminal[0].status).toBe('timed_out');+ const state = await model.findBatch(operationId, 'timeout-batch');+ expect(state.resolutions[0]).toMatchObject({ status: 'timed_out' });+ expect((await model.recordProducerAck(claimed.resolution.resolutionRequestId)).outcome).toBe(+ 'applied',+ );+ expect((await model.findBatch(operationId, 'timeout-batch')).interventions[0].status).toBe(+ 'timed_out',+ );+ });++ it('synchronizes an active outbox when claim discovers an overdue batch', async () => {+ const rows = await createQuestionBatch({ batchId: 'claim-overdue-batch' });+ const claimed = await claim(rows, { answers: { mode: 'safe' }, type: 'submit_answers' });+ if (claimed.outcome !== 'applied') throw new Error('claim failed');+ await model.markResolutionPublished(claimed.resolution.resolutionRequestId);+ const published = await model.findBatch(operationId, 'claim-overdue-batch');+ await serverDB+ .update(agentInterventions)+ .set({ deadline: new Date(Date.now() - 1000) })+ .where(eq(agentInterventions.id, rows[0].id));++ const result = await claim(+ published.interventions,+ { answers: { mode: 'safe' }, type: 'submit_answers' },+ { resolutionRequestId: randomUUID() },+ );+ expect(result.outcome).toBe('conflict');+ expect(result.interventions?.[0].status).toBe('timed_out');+ expect(+ (await model.findResolutionByRequestId(claimed.resolution.resolutionRequestId))?.status,+ ).toBe('timed_out');+ });++ it('recovers owner scope from a resolution request without treating actor as owner', async () => {+ const rows = await createQuestionBatch({ batchId: 'resolution-locator-batch' });+ const claimed = await claim(rows, { answers: { mode: 'safe' }, type: 'submit_answers' });+ if (claimed.outcome !== 'applied') throw new Error('claim failed');+ expect(+ await AgentInterventionModel.locateByResolutionRequestId(+ serverDB,+ claimed.resolution.resolutionRequestId,+ ),+ ).toEqual({+ batchId: 'resolution-locator-batch',+ operationId,+ source: 'heterogeneous',+ userId: ownerId,+ workspaceId,+ });+ });+});diff --git a/packages/database/src/models/__tests__/agentInterventionMigration.test.ts b/packages/database/src/models/__tests__/agentInterventionMigration.test.tsnew file mode 100644index 00000000000..b548a0c78a9--- /dev/null+++ b/packages/database/src/models/__tests__/agentInterventionMigration.test.ts@@ -0,0 +1,132 @@+// @vitest-environment node+import path from 'node:path';++import { sql } from 'drizzle-orm';+import { readMigrationFiles } from 'drizzle-orm/migrator';+import { describe, expect, it } from 'vitest';++import { getTestDB } from '../../core/getTestDB';++const migration = readMigrationFiles({+ migrationsFolder: path.join(__dirname, '../../../migrations'),+}).find((item) => item.sql.some((statement) => statement.includes('"agent_interventions"')));++if (!migration) throw new Error('Agent Intervention migration not found');++const migrationSql = migration.sql.join('\n');++describe('Agent Intervention and ActivityKit migration', () => {+ it('creates a generic notification-safe intervention table', () => {+ expect(migrationSql).toContain('CREATE TABLE IF NOT EXISTS "agent_interventions"');+ expect(migrationSql).toContain('"source" text NOT NULL');+ expect(migrationSql).toContain('"provider" text');+ expect(migrationSql).toContain('"interaction_kind" text NOT NULL');+ expect(migrationSql).toContain('"surface" text NOT NULL');+ expect(migrationSql).toContain('"system_action_eligibility" text NOT NULL');+ expect(migrationSql).toContain('"approval_mode" text');+ expect(migrationSql).toContain('"batch_id" text NOT NULL');+ expect(migrationSql).toContain('"activity_key" text NOT NULL');+ expect(migrationSql).toContain('"item_count" integer NOT NULL');+ expect(migrationSql).toContain('"sealed" boolean DEFAULT false NOT NULL');+ expect(migrationSql).toContain('"tool_message_id" text');+ expect(migrationSql).toContain('"canonical_tool_key" text');+ expect(migrationSql).toContain('"request_revision_hash" text NOT NULL');+ expect(migrationSql).toContain('"allowed_actions" jsonb NOT NULL');+ expect(migrationSql).not.toContain(+ 'CREATE TABLE IF NOT EXISTS "heterogeneous_agent_interventions"',+ );+ });++ it('stores only a review locator hash and no raw arguments on notification rows', () => {+ const itemTableSql = migrationSql.slice(+ migrationSql.indexOf('CREATE TABLE IF NOT EXISTS "agent_interventions"'),+ migrationSql.indexOf('CREATE TABLE IF NOT EXISTS "push_live_activities"'),+ );+ expect(itemTableSql).toContain('"review_token_hash" text NOT NULL');+ expect(itemTableSql).not.toContain('"review_token" text');+ expect(itemTableSql).not.toContain('"original_arguments" text');+ expect(itemTableSql).not.toContain('"edited_arguments" text');+ });++ it('creates a private unique resolution/outbox with delivery and rollback state', () => {+ expect(migrationSql).toContain('CREATE TABLE IF NOT EXISTS "agent_intervention_resolutions"');+ expect(migrationSql).toContain('"resolution_request_id" uuid NOT NULL');+ expect(migrationSql).toContain('"actor_id" text NOT NULL');+ expect(migrationSql).toContain('"selected_intervention_ids" jsonb NOT NULL');+ expect(migrationSql).toContain('"expected_versions" jsonb NOT NULL');+ expect(migrationSql).toContain('"expected_request_revision_hashes" jsonb NOT NULL');+ expect(migrationSql).toContain('"action" jsonb NOT NULL');+ expect(migrationSql).toContain('"remember_effect_status" text');+ expect(migrationSql).toContain('"original_arguments" text');+ expect(migrationSql).toContain('"argument_effect_status" text');+ expect(migrationSql).toContain('"published_at" timestamp with time zone');+ expect(migrationSql).toContain('"continuation_started_at" timestamp with time zone');+ expect(migrationSql).toContain('"producer_ack_at" timestamp with time zone');+ expect(migrationSql).toContain(+ 'CREATE UNIQUE INDEX IF NOT EXISTS "agent_intervention_resolutions_request_unique"',+ );+ });++ it('creates a bounded private custom-execution lease ledger with state invariants', () => {+ expect(migrationSql).toContain('"custom_execution_input_hash" varchar(64)');+ expect(migrationSql).toContain('"custom_execution_state" text');+ expect(migrationSql).toContain('"custom_execution_attempt" integer');+ expect(migrationSql).toContain('"custom_execution_lease_token" uuid');+ expect(migrationSql).toContain('"custom_execution_lease_expires_at" timestamp with time zone');+ expect(migrationSql).toContain('"custom_execution_result" jsonb');+ expect(migrationSql).toContain(+ 'CONSTRAINT "agent_intervention_resolutions_custom_execution_input_hash_check"',+ );+ expect(migrationSql).toContain("~ '^[a-f0-9]{64}$'");+ expect(migrationSql).toContain(+ 'CONSTRAINT "agent_intervention_resolutions_custom_execution_state_check"',+ );+ expect(migrationSql).toContain('"custom_execution_state" = \'pending\'');+ expect(migrationSql).toContain('"custom_execution_state" = \'executing\'');+ expect(migrationSql).toContain('"custom_execution_state" = \'completed\'');+ expect(migrationSql).toContain(+ 'CONSTRAINT "agent_intervention_resolutions_custom_execution_parent_status_check"',+ );+ expect(migrationSql).toContain(+ "\"custom_execution_state\" NOT IN ('executing', 'completed') OR \"agent_intervention_resolutions\".\"status\" IN ('resolving', 'published', 'acknowledged', 'completed')",+ );+ });++ it('adds sandbox-aware ActivityKit start/update token storage keyed by activity', () => {+ expect(migrationSql).toContain('CREATE TABLE IF NOT EXISTS "push_live_activities"');+ expect(migrationSql).toContain('"activity_key" text NOT NULL');+ expect(migrationSql).toContain('"apns_environment" text NOT NULL');+ expect(migrationSql).toContain("apns_environment\" IN ('sandbox', 'production')");+ expect(migrationSql).toContain(+ 'ALTER TABLE "push_tokens" ADD COLUMN IF NOT EXISTS "live_activity_push_to_start_token" text',+ );+ });++ it('uses retry-safe DDL for every generated table, column, FK, check, and index', () => {+ expect(migrationSql).toContain(+ 'DROP CONSTRAINT IF EXISTS "agent_interventions_operation_id_agent_operations_id_fk"',+ );+ expect(migrationSql).toContain(+ 'DROP CONSTRAINT IF EXISTS "agent_intervention_resolutions_operation_id_agent_operations_id_fk"',+ );+ expect(migrationSql).toContain(+ 'DROP CONSTRAINT IF EXISTS "push_tokens_apns_environment_check"',+ );+ expect(migrationSql).toContain('NOT VALID');+ expect(migrationSql).toContain('VALIDATE CONSTRAINT "push_tokens_apns_environment_check"');+ expect(migrationSql).toContain(+ 'CREATE UNIQUE INDEX IF NOT EXISTS "agent_interventions_operation_batch_item_unique"',+ );+ expect(migrationSql).toContain(+ 'CREATE UNIQUE INDEX IF NOT EXISTS "agent_interventions_owner_activity_item_unique"',+ );+ expect(migrationSql).toContain(+ 'CREATE INDEX IF NOT EXISTS "idx_push_live_activities_last_seen"',+ );+ });++ it('can replay the complete migration after it has already been applied', async () => {+ const db = await getTestDB();+ for (const statement of migration.sql) await db.execute(sql.raw(statement));+ }, 15_000);+});diff --git a/packages/database/src/models/__tests__/messages/message.update.test.ts b/packages/database/src/models/__tests__/messages/message.update.test.tsindex f1a9a773915..4b0385d2063 100644--- a/packages/database/src/models/__tests__/messages/message.update.test.ts+++ b/packages/database/src/models/__tests__/messages/message.update.test.ts@@ -493,6 +493,74 @@ describe('MessageModel Update Tests', () => {expect(result[0].state).toEqual({ key1: 'value1' });});+ it('atomically preserves independent top-level keys across concurrent writers', async () => {+ await serverDB.insert(messages).values({+ content: '',+ id: 'concurrent-plugin-state',+ role: 'tool',+ userId,+ });+ await serverDB.insert(messagePlugins).values({+ id: 'concurrent-plugin-state',+ identifier: 'codex',+ state: { executionProgress: { completed: 1, total: 2 } },+ toolCallId: 'concurrent-tool-call',+ userId,+ });++ await Promise.all([+ messageModel.updatePluginState('concurrent-plugin-state', {+ askUserAnswers: { environment: 'production' },+ }),+ messageModel.updatePluginState('concurrent-plugin-state', {+ heterogeneousIntervention: {+ action: 'approve_once',+ status: 'resolved',+ },+ }),+ ]);++ const [plugin] = await serverDB+ .select()+ .from(messagePlugins)+ .where(eq(messagePlugins.id, 'concurrent-plugin-state'));++ expect(plugin.state).toEqual({+ askUserAnswers: { environment: 'production' },+ executionProgress: { completed: 1, total: 2 },+ heterogeneousIntervention: {+ action: 'approve_once',+ status: 'resolved',+ },+ });+ });++ it('does not update plugin state outside the owner scope', async () => {+ await serverDB.insert(messages).values({+ content: '',+ id: 'other-owner-plugin-state',+ role: 'tool',+ userId: otherUserId,+ });+ await serverDB.insert(messagePlugins).values({+ id: 'other-owner-plugin-state',+ identifier: 'codex',+ state: { preserved: true },+ toolCallId: 'other-owner-tool-call',+ userId: otherUserId,+ });++ await expect(+ messageModel.updatePluginState('other-owner-plugin-state', { overwritten: true }),+ ).rejects.toThrowError('Plugin not found');++ const [plugin] = await serverDB+ .select()+ .from(messagePlugins)+ .where(eq(messagePlugins.id, 'other-owner-plugin-state'));+ expect(plugin.state).toEqual({ preserved: true });+ });+it('should throw an error if plugin does not exist', async () => {// Call updatePluginState methodawait expect(messageModel.updatePluginState('1', { key: 'value' })).rejects.toThrowError(@@ -655,6 +723,88 @@ describe('MessageModel Update Tests', () => {});});+ it('preserves independent pluginState patches across concurrent tool-message updates', async () => {+ await serverDB.insert(messages).values({+ content: '',+ id: 'tool-msg-concurrent-patches',+ role: 'tool',+ userId,+ });+ await serverDB.insert(messagePlugins).values({+ id: 'tool-msg-concurrent-patches',+ identifier: 'codex',+ state: { executionProgress: { completed: 1, total: 2 } },+ toolCallId: 'tool-call-concurrent-patches',+ userId,+ });++ const results = await Promise.all([+ messageModel.updateToolMessage('tool-msg-concurrent-patches', {+ pluginState: { askUserAnswers: { environment: 'production' } },+ }),+ messageModel.updateToolMessage('tool-msg-concurrent-patches', {+ pluginState: {+ heterogeneousIntervention: {+ action: 'approve_once',+ status: 'resolved',+ },+ },+ }),+ ]);++ expect(results).toEqual([+ { applied: true, success: true },+ { applied: true, success: true },+ ]);++ const [plugin] = await serverDB+ .select()+ .from(messagePlugins)+ .where(eq(messagePlugins.id, 'tool-msg-concurrent-patches'));+ expect(plugin.state).toEqual({+ askUserAnswers: { environment: 'production' },+ executionProgress: { completed: 1, total: 2 },+ heterogeneousIntervention: {+ action: 'approve_once',+ status: 'resolved',+ },+ });+ });++ it('replaces a patched top-level pluginState key while preserving its siblings', async () => {+ await serverDB.insert(messages).values({+ content: '',+ id: 'tool-msg-top-level-patch',+ role: 'tool',+ userId,+ });+ await serverDB.insert(messagePlugins).values({+ id: 'tool-msg-top-level-patch',+ identifier: 'codex',+ state: {+ askUserAnswers: { environment: 'production' },+ heterogeneousIntervention: { resolving: true, status: 'pending' },+ },+ toolCallId: 'tool-call-top-level-patch',+ userId,+ });++ await messageModel.updateToolMessage('tool-msg-top-level-patch', {+ pluginState: {+ heterogeneousIntervention: { action: 'approve_once', status: 'resolved' },+ },+ });++ const [plugin] = await serverDB+ .select()+ .from(messagePlugins)+ .where(eq(messagePlugins.id, 'tool-msg-top-level-patch'));+ expect(plugin.state).toEqual({+ askUserAnswers: { environment: 'production' },+ heterogeneousIntervention: { action: 'approve_once', status: 'resolved' },+ });+ });+it('atomically replaces heterogeneous tool state and rejects stale snapshots', async () => {await serverDB.insert(messages).values({content: '',diff --git a/packages/database/src/models/__tests__/pushToken.test.ts b/packages/database/src/models/__tests__/pushToken.test.tsindex 04ede5fab15..2d3489b744b 100644--- a/packages/database/src/models/__tests__/pushToken.test.ts+++ b/packages/database/src/models/__tests__/pushToken.test.ts@@ -3,11 +3,12 @@ import { eq } from 'drizzle-orm';import { afterEach, beforeEach, describe, expect, it } from 'vitest';import { getTestDB } from '../../core/getTestDB';-import { pushTokens, users } from '../../schemas';+import { pushLiveActivities, pushTokens, users } from '../../schemas';import type { LobeChatDatabase } from '../../type';import {deletePushTokenByExpoTokenAndDevice,deletePushTokensByExpoTokens,+ PushLiveActivityModel,PushTokenModel,} from '../pushToken';@@ -16,6 +17,7 @@ const serverDB: LobeChatDatabase = await getTestDB();const userId = 'push-token-model-test-user-id';const otherUserId = 'push-token-model-test-other-user';const model = new PushTokenModel(serverDB, userId);+const liveActivityModel = new PushLiveActivityModel(serverDB, userId);beforeEach(async () => {await serverDB.delete(users);@@ -87,6 +89,74 @@ describe('PushTokenModel', () => {const tokens = await model.listByUserId();expect(tokens).toHaveLength(2);});++ it('persists the sandbox ActivityKit start token and updates it on registration', async () => {+ await model.upsert({+ apnsEnvironment: 'sandbox',+ deviceId: 'iphone',+ expoToken: 'ExponentPushToken[ios]',+ liveActivityPushToStartToken: 'start-token-1',+ platform: 'ios',+ });++ const updated = await model.upsert({+ apnsEnvironment: 'sandbox',+ deviceId: 'iphone',+ expoToken: 'ExponentPushToken[ios]',+ liveActivityPushToStartToken: 'start-token-2',+ platform: 'ios',+ });++ expect(updated).toMatchObject({+ apnsEnvironment: 'sandbox',+ liveActivityPushToStartToken: 'start-token-2',+ });+ });+ });++ describe('updateLiveActivityRegistration', () => {+ it('rotates ActivityKit registration only for an existing owned device', async () => {+ await model.upsert({+ deviceId: 'iphone',+ expoToken: 'ExponentPushToken[ios]',+ platform: 'ios',+ });++ const updated = await model.updateLiveActivityRegistration('iphone', {+ apnsEnvironment: 'production',+ liveActivityPushToStartToken: 'push-to-start-token',+ });++ expect(updated).toMatchObject({+ apnsEnvironment: 'production',+ deviceId: 'iphone',+ liveActivityPushToStartToken: 'push-to-start-token',+ userId,+ });+ });++ it('does not create a row or update another owner for an unknown device', async () => {+ const otherModel = new PushTokenModel(serverDB, otherUserId);+ await otherModel.upsert({+ deviceId: 'shared-device',+ expoToken: 'ExponentPushToken[other]',+ platform: 'ios',+ });++ await expect(+ model.updateLiveActivityRegistration('shared-device', {+ apnsEnvironment: 'sandbox',+ liveActivityPushToStartToken: 'must-not-leak',+ }),+ ).resolves.toBeUndefined();++ await expect(otherModel.listByUserId()).resolves.toEqual([+ expect.objectContaining({+ apnsEnvironment: null,+ liveActivityPushToStartToken: null,+ }),+ ]);+ });});describe('unregister', () => {@@ -175,10 +245,69 @@ describe('PushTokenModel', () => {expect(remaining[0].deviceId).toBe('b');});+ it('atomically removes every Live Activity row for the matched owner and device', async () => {+ await model.upsert({ deviceId: 'target-device', expoToken: 'target-token', platform: 'ios' });+ await liveActivityModel.upsert({+ activityId: 'target-native-1',+ activityKey: 'target-activity-1',+ apnsEnvironment: 'sandbox',+ deviceId: 'target-device',+ operationId: 'target-operation',+ pushToken: 'target-live-token-1',+ });+ await liveActivityModel.upsert({+ activityId: 'target-native-2',+ activityKey: 'target-activity-2',+ apnsEnvironment: 'sandbox',+ deviceId: 'target-device',+ operationId: 'target-operation',+ pushToken: 'target-live-token-2',+ });+ await liveActivityModel.upsert({+ activityId: 'kept-native',+ activityKey: 'target-activity-1',+ apnsEnvironment: 'sandbox',+ deviceId: 'kept-device',+ operationId: 'target-operation',+ pushToken: 'kept-live-token',+ });+ const otherLiveActivityModel = new PushLiveActivityModel(serverDB, otherUserId);+ await otherLiveActivityModel.upsert({+ activityId: 'other-native',+ activityKey: 'target-activity-1',+ apnsEnvironment: 'production',+ deviceId: 'target-device',+ operationId: 'other-operation',+ pushToken: 'other-live-token',+ });++ await deletePushTokenByExpoTokenAndDevice(serverDB, {+ deviceId: 'target-device',+ expoToken: 'target-token',+ });++ await expect(model.listByUserId()).resolves.toEqual([]);+ await expect(liveActivityModel.listByActivityKey('target-activity-1')).resolves.toEqual([+ expect.objectContaining({ deviceId: 'kept-device' }),+ ]);+ await expect(liveActivityModel.listByActivityKey('target-activity-2')).resolves.toEqual([]);+ await expect(+ otherLiveActivityModel.listByActivityKey('target-activity-1'),+ ).resolves.toHaveLength(1);+ });+it('should not delete when only deviceId matches but expoToken differs', async () => {// Defensive: a malicious caller knowing only the deviceId must not be// able to unregister someone else's row.await model.upsert({ deviceId: 'a', expoToken: 'real-token', platform: 'ios' });+ await liveActivityModel.upsert({+ activityId: 'native-a',+ activityKey: 'activity-a',+ apnsEnvironment: 'sandbox',+ deviceId: 'a',+ operationId: 'operation-a',+ pushToken: 'live-token-a',+ });await deletePushTokenByExpoTokenAndDevice(serverDB, {deviceId: 'a',@@ -188,6 +317,7 @@ describe('PushTokenModel', () => {const remaining = await model.listByUserId();expect(remaining).toHaveLength(1);expect(remaining[0].expoToken).toBe('real-token');+ await expect(liveActivityModel.listByActivityKey('activity-a')).resolves.toHaveLength(1);});it('should be a no-op when no row matches', async () => {@@ -213,3 +343,136 @@ describe('PushTokenModel', () => {});});});++describe('PushLiveActivityModel', () => {+ const register = (overrides: Partial<Parameters<typeof liveActivityModel.upsert>[0]> = {}) =>+ liveActivityModel.upsert({+ activityId: 'native-activity-1',+ activityKey: 'intervention-1',+ apnsEnvironment: 'sandbox',+ deviceId: 'iphone',+ operationId: 'shared-operation',+ pushToken: 'activity-update-token-1',+ ...overrides,+ });++ it('keeps separate callbacks from the same operation by opaque activity key', async () => {+ await register();+ await register({+ activityId: 'native-activity-2',+ activityKey: 'intervention-2',+ pushToken: 'activity-update-token-2',+ });++ const first = await liveActivityModel.listByActivityKey('intervention-1');+ const second = await liveActivityModel.listByActivityKey('intervention-2');+ expect(first).toHaveLength(1);+ expect(first[0]).toMatchObject({+ activityKey: 'intervention-1',+ operationId: 'shared-operation',+ });+ expect(second).toHaveLength(1);+ });++ it('upserts one device/activity key without overwriting another callback', async () => {+ const first = await register();+ const refreshed = await register({+ activityId: 'native-activity-refreshed',+ pushToken: 'activity-update-token-refreshed',+ });++ expect(refreshed.id).toBe(first.id);+ expect(refreshed).toMatchObject({+ activityId: 'native-activity-refreshed',+ pushToken: 'activity-update-token-refreshed',+ });+ const rows = await serverDB+ .select()+ .from(pushLiveActivities)+ .where(eq(pushLiveActivities.activityKey, 'intervention-1'));+ expect(rows).toHaveLength(1);+ });++ it('lists and unregisters only the requested activity key', async () => {+ await register();+ await register({+ activityId: 'native-activity-2',+ activityKey: 'intervention-2',+ pushToken: 'activity-update-token-2',+ });++ await liveActivityModel.unregister('intervention-1');++ await expect(liveActivityModel.listByActivityKey('intervention-1')).resolves.toEqual([]);+ await expect(liveActivityModel.listByActivityKey('intervention-2')).resolves.toHaveLength(1);+ });++ it('conditionally unregisters only the exact stale push token after a rotation', async () => {+ await register();+ await register({ pushToken: 'activity-update-token-rotated' });++ await liveActivityModel.unregisterIfPushToken(+ 'intervention-1',+ 'iphone',+ 'activity-update-token-1',+ );+ await expect(liveActivityModel.listByActivityKey('intervention-1')).resolves.toEqual([+ expect.objectContaining({ pushToken: 'activity-update-token-rotated' }),+ ]);++ await liveActivityModel.unregisterIfPushToken(+ 'intervention-1',+ 'iphone',+ 'activity-update-token-rotated',+ );+ await expect(liveActivityModel.listByActivityKey('intervention-1')).resolves.toEqual([]);+ });++ it('unregisters every activity for one owned device without touching siblings or another owner', async () => {+ await register();+ await register({+ activityId: 'native-activity-2',+ activityKey: 'intervention-2',+ pushToken: 'activity-update-token-2',+ });+ await register({+ activityId: 'native-activity-other-device',+ deviceId: 'ipad',+ pushToken: 'activity-update-token-other-device',+ });+ const otherModel = new PushLiveActivityModel(serverDB, otherUserId);+ await otherModel.upsert({+ activityId: 'other-native-activity',+ activityKey: 'intervention-1',+ apnsEnvironment: 'production',+ deviceId: 'iphone',+ operationId: 'other-operation',+ pushToken: 'other-update-token',+ });++ await liveActivityModel.unregisterDevice('iphone');++ await expect(liveActivityModel.listByActivityKey('intervention-1')).resolves.toEqual([+ expect.objectContaining({ deviceId: 'ipad' }),+ ]);+ await expect(liveActivityModel.listByActivityKey('intervention-2')).resolves.toEqual([]);+ await expect(otherModel.listByActivityKey('intervention-1')).resolves.toHaveLength(1);+ });++ it('does not expose another user activity registration with the same key', async () => {+ await register();+ const otherModel = new PushLiveActivityModel(serverDB, otherUserId);+ await otherModel.upsert({+ activityId: 'other-native-activity',+ activityKey: 'intervention-1',+ apnsEnvironment: 'production',+ deviceId: 'other-iphone',+ operationId: 'other-operation',+ pushToken: 'other-update-token',+ });++ await expect(liveActivityModel.listByActivityKey('intervention-1')).resolves.toHaveLength(1);+ await liveActivityModel.unregister('intervention-1');+ await expect(otherModel.listByActivityKey('intervention-1')).resolves.toHaveLength(1);+ });+});diff --git a/packages/database/src/models/agentIntervention.ts b/packages/database/src/models/agentIntervention.tsnew file mode 100644index 00000000000..8c7145dca6e--- /dev/null+++ b/packages/database/src/models/agentIntervention.ts@@ -0,0 +1,2685 @@+import { createHash, randomUUID } from 'node:crypto';++import type {+ AgentInterventionAllowedAction,+ AgentInterventionApprovalMode,+ AgentInterventionCustomExecutionResult,+ AgentInterventionExpectedRequestRevisionHashes,+ AgentInterventionExpectedVersions,+ AgentInterventionKind,+ AgentInterventionResolutionAction,+ AgentInterventionResolutionScope,+ AgentInterventionReviewContext,+ AgentInterventionRisk,+ AgentInterventionSanitizedRequest,+ AgentInterventionSource,+ AgentInterventionStatus,+ AgentInterventionSurface,+ AgentInterventionSystemActionEligibility,+ ChatToolPayload,+} from '@lobechat/types';+import { and, asc, eq, getTableColumns, gt, inArray, isNull, lte, ne, or, sql } from 'drizzle-orm';++import type { AgentInterventionItem, AgentInterventionResolutionItem } from '../schemas';+import {+ agentInterventionResolutions,+ agentInterventions,+ agentOperations,+ messagePlugins,+ messages,+ userSettings,+} from '../schemas';+import type { LobeChatDatabase, Transaction } from '../type';++export const AGENT_INTERVENTION_INVALID_REVIEW_TOKEN_HASH =+ 'AGENT_INTERVENTION_INVALID_REVIEW_TOKEN_HASH';+export const AGENT_INTERVENTION_INVALID_REQUEST_REVISION_HASH =+ 'AGENT_INTERVENTION_INVALID_REQUEST_REVISION_HASH';+export const AGENT_INTERVENTION_INVALID_BATCH = 'AGENT_INTERVENTION_INVALID_BATCH';+export const AGENT_INTERVENTION_INVALID_ACTION = 'AGENT_INTERVENTION_INVALID_ACTION';+export const AGENT_INTERVENTION_IDENTITY_CONFLICT = 'AGENT_INTERVENTION_IDENTITY_CONFLICT';+export const AGENT_INTERVENTION_RESOLUTION_REQUEST_REUSED =+ 'AGENT_INTERVENTION_RESOLUTION_REQUEST_REUSED';+export const AGENT_INTERVENTION_SOURCE_TRANSITION_MISMATCH =+ 'AGENT_INTERVENTION_SOURCE_TRANSITION_MISMATCH';++const HASH_PATTERN = /^[a-f0-9]{64}$/;+const UUID_PATTERN = /^[\da-f]{8}-(?:[\da-f]{4}-){3}[\da-f]{12}$/i;+const PG_UNIQUE_VIOLATION = '23505';++export const AGENT_INTERVENTION_CUSTOM_EXECUTION_MIN_LEASE_MS = 1000;+export const AGENT_INTERVENTION_CUSTOM_EXECUTION_MAX_LEASE_MS = 15 * 60_000;++type AgentInterventionOperationIdentity = Pick<+ typeof agentOperations.$inferSelect,+ 'agentId' | 'appContext' | 'chatGroupId' | 'id' | 'status' | 'taskId' | 'threadId' | 'topicId'+>;++const isUniqueViolation = (error: unknown): boolean =>+ !!error &&+ typeof error === 'object' &&+ (('code' in error && (error as { code?: string }).code === PG_UNIQUE_VIOLATION) ||+ ('cause' in error && isUniqueViolation((error as { cause?: unknown }).cause)));++const asRecord = (value: unknown): Record<string, unknown> =>+ value !== null && typeof value === 'object' && !Array.isArray(value)+ ? (value as Record<string, unknown>)+ : {};++interface CanonicalJsonOptions {+ omitUndefinedObjectProperties?: boolean;+}++const canonicalJson = (+ value: unknown,+ options: CanonicalJsonOptions = {},+ ancestors = new Set<object>(),+): string => {+ if (value === null) return 'null';+ if (typeof value === 'string' || typeof value === 'boolean') return JSON.stringify(value);+ if (typeof value === 'number') {+ if (!Number.isFinite(value)) throw new TypeError('Value is not JSON-safe');+ return JSON.stringify(value);+ }+ if (typeof value !== 'object') throw new TypeError('Value is not JSON-safe');+ if (ancestors.has(value)) throw new TypeError('Cyclic value is not JSON-safe');++ ancestors.add(value);+ try {+ if (Array.isArray(value)) {+ if (+ Object.getPrototypeOf(value) !== Array.prototype ||+ Object.keys(value).length !== value.length ||+ Reflect.ownKeys(value).length !== value.length + 1+ ) {+ throw new TypeError('Non-standard array is not JSON-safe');+ }+ const items: string[] = [];+ for (let index = 0; index < value.length; index++) {+ if (!Object.hasOwn(value, index)) throw new TypeError('Sparse array is not JSON-safe');+ items.push(canonicalJson(value[index], options, ancestors));+ }+ return `[${items.join(',')}]`;+ }++ const prototype = Object.getPrototypeOf(value);+ if (prototype !== Object.prototype && prototype !== null) {+ throw new TypeError('Non-plain object is not JSON-safe');+ }+ const record = value as Record<string, unknown>;+ const keys = Object.keys(record);+ if (Reflect.ownKeys(record).length !== keys.length) {+ throw new TypeError('Hidden or symbol properties are not JSON-safe');+ }+ const serializedKeys = options.omitUndefinedObjectProperties+ ? keys.filter((key) => record[key] !== undefined)+ : keys;+ return `{${serializedKeys+ .sort()+ .map((key) => `${JSON.stringify(key)}:${canonicalJson(record[key], options, ancestors)}`)+ .join(',')}}`;+ } finally {+ ancestors.delete(value);+ }+};++const sameJson = (left: unknown, right: unknown): boolean =>+ canonicalJson(left) === canonicalJson(right);++const canonicalDtoJson = (value: unknown): string =>+ canonicalJson(value, { omitUndefinedObjectProperties: true });++const sameDtoJson = (left: unknown, right: unknown): boolean =>+ canonicalDtoJson(left) === canonicalDtoJson(right);++const normalizeDtoJson = <T>(value: T): T => JSON.parse(canonicalDtoJson(value)) as T;++const isCanonicalJsonSafe = (value: unknown): boolean => {+ try {+ canonicalJson(value);+ return true;+ } catch {+ return false;+ }+};++const isCanonicalDtoJsonSafe = (value: unknown): boolean => {+ try {+ canonicalDtoJson(value);+ return true;+ } catch {+ return false;+ }+};++const uniqueSorted = (values: readonly string[]): string[] => [...new Set(values)].sort();++const isPlainRecord = (value: unknown): value is Record<string, unknown> =>+ value !== null && typeof value === 'object' && !Array.isArray(value);++const isCustomExecutionResult = (value: unknown): value is AgentInterventionCustomExecutionResult =>+ isPlainRecord(value) &&+ hasOnlyKeys(value, ['content', 'pluginState']) &&+ typeof value.content === 'string' &&+ isPlainRecord(value.pluginState) &&+ isCanonicalJsonSafe(value);++const hasOnlyKeys = (record: Record<string, unknown>, allowedKeys: readonly string[]): boolean => {+ const allowed = new Set(allowedKeys);+ return Object.keys(record).every((key) => allowed.has(key));+};++const hasExactKeys = (record: Record<string, unknown>, ids: string[]): boolean => {+ const keys = Object.keys(record).sort();+ const expected = [...ids].sort();+ return keys.length === expected.length && keys.every((key, index) => key === expected[index]);+};++const actionCapability = (+ action: AgentInterventionResolutionAction,+): AgentInterventionAllowedAction => action.type;++const terminalStatusForAction = (+ action: AgentInterventionResolutionAction,+): 'cancelled' | 'resolved' =>+ action.type === 'cancel_interaction' || action.type === 'stop' ? 'cancelled' : 'resolved';++/** Exact digest used for CAS against the authoritative message plugin string. */+export const hashAgentInterventionRequestRevision = (argumentsText: string): string =>+ createHash('sha256').update(argumentsText).digest('hex');++const providerOptionIds = (request: AgentInterventionSanitizedRequest): Set<string> => {+ const ids = new Set<string>();+ for (const option of request.options ?? []) if (option.id) ids.add(option.id);+ for (const question of request.questions ?? []) {+ for (const option of question.options) if (option.id) ids.add(option.id);+ }+ for (const field of request.fields ?? []) {+ for (const option of field.options ?? []) if (option.id) ids.add(option.id);+ }+ return ids;+};++const isBoundedFormValue = (value: unknown): boolean => {+ if (value === null || typeof value === 'boolean') return true;+ if (typeof value === 'number') return Number.isFinite(value);+ if (typeof value === 'string') return value.length <= 10_000;+ return (+ Array.isArray(value) &&+ value.length <= 100 &&+ value.every((item) => typeof item === 'string' && item.length <= 10_000)+ );+};++const hasBoundedFormRecord = (value: unknown): value is Record<string, unknown> => {+ if (!isPlainRecord(value)) return false;+ const record = value;+ const entries = Object.entries(record);+ return (+ entries.length <= 100 &&+ entries.every(([key, item]) => key.length > 0 && key.length <= 256 && isBoundedFormValue(item))+ );+};++const hasValidAnswers = (+ request: AgentInterventionSanitizedRequest,+ answersValue: unknown,+): boolean => {+ if (!hasBoundedFormRecord(answersValue)) return false;+ const answers = answersValue;+ const definitions = new Map<+ string,+ {+ allowCustomAnswer: boolean;+ multi: boolean;+ options: Set<string>;+ required: boolean;+ type: 'boolean' | 'number' | 'string';+ }+ >();+ for (const question of request.questions ?? []) {+ definitions.set(question.id ?? question.question, {+ allowCustomAnswer: question.allowCustomAnswer === true,+ multi: question.multiSelect === true,+ options: new Set(question.options.map((option) => option.id ?? option.label)),+ required: true,+ type: 'string',+ });+ }+ for (const field of request.fields ?? []) {+ definitions.set(field.id, {+ allowCustomAnswer: false,+ multi: field.type === 'multi_select',+ options: new Set((field.options ?? []).map((option) => option.id ?? option.label)),+ required: field.required === true,+ type: field.type === 'boolean' ? 'boolean' : field.type === 'number' ? 'number' : 'string',+ });+ }+ const { allowFreeform = false, allowSupplement = false } = request.answerPolicy ?? {};+ if (definitions.size === 0 && !allowFreeform) return false;+ const allowedSpecialKeys = new Set<string>();+ if (allowFreeform) allowedSpecialKeys.add('__freeform__');+ if (allowSupplement) allowedSpecialKeys.add('__supplement__');+ if (+ Object.keys(answers).some((key) => !definitions.has(key) && !allowedSpecialKeys.has(key)) ||+ ('__freeform__' in answers && typeof answers.__freeform__ !== 'string') ||+ ('__supplement__' in answers && typeof answers.__supplement__ !== 'string')+ ) {+ return false;+ }+ const hasFreeform = typeof answers.__freeform__ === 'string' && answers.__freeform__.length > 0;++ for (const [id, definition] of definitions) {+ const value = answers[id];+ if (value === undefined || value === null) {+ if (definition.required && !hasFreeform) return false;+ continue;+ }+ if (definition.multi) {+ if (!Array.isArray(value) || value.some((item) => typeof item !== 'string')) return false;+ if (+ definition.options.size > 0 &&+ value.some((item) => !definition.options.has(item as string))+ ) {+ return false;+ }+ continue;+ }+ if (Array.isArray(value) || typeof value !== definition.type) return false;+ if (+ definition.options.size > 0 &&+ (typeof value !== 'string' ||+ (!definition.options.has(value) && !definition.allowCustomAnswer))+ ) {+ return false;+ }+ }+ return true;+};++const hasValidCustomDetail = (request: AgentInterventionSanitizedRequest): boolean => {+ const detailValue: unknown = request.customDetail;+ if (detailValue === undefined) return true;+ if (!isPlainRecord(detailValue)) return false;+ const agentsValue = detailValue.agents;+ if (+ !hasOnlyKeys(detailValue, ['agents', 'categoryHints', 'kind', 'requestId', 'selectedIds']) ||+ detailValue.kind !== 'agent_marketplace' ||+ !Array.isArray(agentsValue) ||+ agentsValue.length > 100+ ) {+ return false;+ }+ const detail = detailValue;+ const agents: unknown[] = agentsValue;+ const ids = agents.map((agent) => (isPlainRecord(agent) ? agent.id : undefined));+ if (+ ids.some((id) => typeof id !== 'string') ||+ new Set(ids).size !== ids.length ||+ agents.some(+ (agent) =>+ !isPlainRecord(agent) ||+ !hasOnlyKeys(agent, ['avatar', 'description', 'id', 'title']) ||+ typeof agent.id !== 'string' ||+ !agent.id ||+ agent.id.length > 256 ||+ typeof agent.title !== 'string' ||+ !agent.title ||+ agent.title.length > 500 ||+ (agent.avatar !== undefined &&+ (typeof agent.avatar !== 'string' || agent.avatar.length > 2048)) ||+ (agent.description !== undefined &&+ (typeof agent.description !== 'string' || agent.description.length > 10_000)),+ ) ||+ (detail.selectedIds !== undefined &&+ (!Array.isArray(detail.selectedIds) ||+ detail.selectedIds.length > 100 ||+ detail.selectedIds.some((id) => typeof id !== 'string' || !ids.includes(id)) ||+ new Set(detail.selectedIds).size !== detail.selectedIds.length)) ||+ (detail.categoryHints !== undefined &&+ (!Array.isArray(detail.categoryHints) ||+ detail.categoryHints.length > 50 ||+ detail.categoryHints.some(+ (hint) => typeof hint !== 'string' || !hint || hint.length > 256,+ ))) ||+ (detail.requestId !== undefined &&+ (typeof detail.requestId !== 'string' || !detail.requestId || detail.requestId.length > 256))+ ) {+ return false;+ }+ return true;+};++const hasValidCustomResult = (+ request: AgentInterventionSanitizedRequest,+ resultValue: unknown,+): boolean => {+ if (!hasBoundedFormRecord(resultValue)) return false;+ const detail = request.customDetail;+ if (!detail) return true;+ if (detail.kind === 'agent_marketplace') {+ const result = resultValue;+ if (!hasExactKeys(result, ['selectedIds']) || !Array.isArray(result.selectedIds)) return false;+ const allowedIds = new Set(detail.agents.map((agent) => agent.id));+ return (+ new Set(result.selectedIds).size === result.selectedIds.length &&+ result.selectedIds.every((id) => typeof id === 'string' && allowedIds.has(id))+ );+ }+ return false;+};++export interface AgentInterventionLocator {+ activityKey: string;+ batchId: string;+ deadline: Date;+ id: string;+ operationId: string;+ source: AgentInterventionSource;+ status: AgentInterventionStatus;+ userId: string;+ workspaceId: null | string;+}++export interface AgentInterventionResolutionLocator {+ batchId: string;+ operationId: string;+ source: AgentInterventionSource;+ userId: string;+ workspaceId: null | string;+}++export interface ClaimAgentInterventionCustomExecutionParams {+ inputHash: string;+ leaseDurationMs: number;+ resolutionRequestId: string;+}++export type AgentInterventionCustomExecutionClaimResult =+ | {+ attempt: number;+ leaseExpiresAt: Date;+ leaseToken: string;+ outcome: 'applied';+ }+ | {+ attempt: number;+ leaseExpiresAt: Date;+ outcome: 'in_progress';+ }+ | {+ outcome: 'completed';+ result: AgentInterventionCustomExecutionResult;+ }+ | { outcome: 'conflict' };++export interface CompleteAgentInterventionCustomExecutionParams {+ inputHash: string;+ leaseToken: string;+ resolutionRequestId: string;+ result: AgentInterventionCustomExecutionResult;+}++export type AgentInterventionCustomExecutionCompletionResult =+ | {+ outcome: 'completed';+ result: AgentInterventionCustomExecutionResult;+ }+ | { outcome: 'conflict' };++type AgentInterventionPrivateExecutionField =+ | 'customExecutionAttempt'+ | 'customExecutionInputHash'+ | 'customExecutionLeaseExpiresAt'+ | 'customExecutionLeaseToken'+ | 'customExecutionResult'+ | 'customExecutionState';++export type AgentInterventionResolutionPublicItem = Omit<+ AgentInterventionResolutionItem,+ AgentInterventionPrivateExecutionField+>;++const {+ customExecutionAttempt: _customExecutionAttempt,+ customExecutionInputHash: _customExecutionInputHash,+ customExecutionLeaseExpiresAt: _customExecutionLeaseExpiresAt,+ customExecutionLeaseToken: _customExecutionLeaseToken,+ customExecutionResult: _customExecutionResult,+ customExecutionState: _customExecutionState,+ ...publicResolutionColumns+} = getTableColumns(agentInterventionResolutions);++export interface AgentInterventionBatchState {+ interventions: AgentInterventionItem[];+ resolutions: AgentInterventionResolutionPublicItem[];+}++export interface CreateAgentInterventionItemParams {+ allowedActions: readonly AgentInterventionAllowedAction[];+ canonicalToolKey?: string;+ interactionKind: AgentInterventionKind;+ provider?: string;+ requestRevisionHash: string;+ reviewContext: AgentInterventionReviewContext;+ reviewTokenHash: string;+ risk?: AgentInterventionRisk;+ sanitizedRequest: AgentInterventionSanitizedRequest;+ surface: AgentInterventionSurface;+ toolCallId: string;+ toolMessageId?: string;+}++export interface CreateAgentInterventionBatchParams {+ activityKey: string;+ approvalMode?: AgentInterventionApprovalMode;+ batchId: string;+ deadline: Date;+ items: CreateAgentInterventionItemParams[];+ operationId: string;+ provider?: string;+ source: AgentInterventionSource;+ stepIndex: number;+ systemActionEligibility: AgentInterventionSystemActionEligibility;+}++export interface AgentInterventionBatchSupersession {+ activityKey: string;+ batchId: string;+ operationId: string;+ toolCallIds: readonly string[];+}++export interface CreateAgentInterventionBatchWithSupersessionParams {+ batch: CreateAgentInterventionBatchParams;+ supersedes?: AgentInterventionBatchSupersession;+}++export interface AgentInterventionBatchSupersessionResult {+ interventions: AgentInterventionItem[];+ outcome: 'applied' | 'idempotent';+ superseded?: {+ activityKey: string;+ batchId: string;+ interventions: AgentInterventionItem[];+ operationId: string;+ };+}++export interface ClaimAgentInterventionBatchParams {+ action: AgentInterventionResolutionAction;+ actorId: string;+ batchId: string;+ expectedItemCount: number;+ expectedRequestRevisionHashes: AgentInterventionExpectedRequestRevisionHashes;+ expectedVersions: AgentInterventionExpectedVersions;+ operationId: string;+ resolutionRequestId: string;+ scope: AgentInterventionResolutionScope;+ selectedInterventionIds: string[];+}++export type AgentInterventionBatchMutationResult =+ | {+ interventions: AgentInterventionItem[];+ outcome: 'applied' | 'idempotent';+ resolution: AgentInterventionResolutionItem;+ }+ | {+ interventions?: AgentInterventionItem[];+ outcome: 'conflict' | 'not_found';+ resolution?: AgentInterventionResolutionItem;+ };++/**+ * Durable, owner-scoped state machine. Review-token lookup is deliberately a+ * separate system locator: callers must authorize view and resolve against the+ * resource before constructing this owner/workspace-scoped model.+ */+export class AgentInterventionModel {+ constructor(+ private readonly db: LobeChatDatabase,+ private readonly userId: string,+ private readonly workspaceId?: string,+ ) {}++ private ownership = () =>+ and(+ eq(agentInterventions.userId, this.userId),+ this.workspaceId+ ? eq(agentInterventions.workspaceId, this.workspaceId)+ : isNull(agentInterventions.workspaceId),+ );++ private resolutionOwnership = () =>+ and(+ eq(agentInterventionResolutions.userId, this.userId),+ this.workspaceId+ ? eq(agentInterventionResolutions.workspaceId, this.workspaceId)+ : isNull(agentInterventionResolutions.workspaceId),+ );++ private ownerOnly = () => eq(agentInterventions.userId, this.userId);++ /**+ * System-only locator. It returns only routing/ACL context and never exposes+ * render content, action capability, token hash, or resolution payload.+ */+ static locateByReviewTokenHash = async (+ db: LobeChatDatabase,+ reviewTokenHash: string,+ ): Promise<AgentInterventionLocator | undefined> => {+ if (!HASH_PATTERN.test(reviewTokenHash)) return undefined;++ const [row] = await db+ .select({+ activityKey: agentInterventions.activityKey,+ batchId: agentInterventions.batchId,+ deadline: agentInterventions.deadline,+ id: agentInterventions.id,+ operationId: agentInterventions.operationId,+ source: agentInterventions.source,+ status: agentInterventions.status,+ userId: agentInterventions.userId,+ workspaceId: agentInterventions.workspaceId,+ })+ .from(agentInterventions)+ .where(eq(agentInterventions.reviewTokenHash, reviewTokenHash))+ .limit(1);++ return row;+ };++ /**+ * System-only compatibility locator for authenticated in-conversation+ * actions. The correlation pair is not authority: callers must still load+ * the owning operation, apply resource ACL, and then rebuild the+ * owner/workspace-scoped model before reading or claiming the batch.+ */+ static locateByOperationAndToolCall = async (+ db: LobeChatDatabase,+ operationId: string,+ toolCallId: string,+ ): Promise<AgentInterventionLocator | undefined> => {+ if (!operationId.trim() || !toolCallId.trim()) return undefined;++ const [row] = await db+ .select({+ activityKey: agentInterventions.activityKey,+ batchId: agentInterventions.batchId,+ deadline: agentInterventions.deadline,+ id: agentInterventions.id,+ operationId: agentInterventions.operationId,+ source: agentInterventions.source,+ status: agentInterventions.status,+ userId: agentInterventions.userId,+ workspaceId: agentInterventions.workspaceId,+ })+ .from(agentInterventions)+ .where(+ and(+ eq(agentInterventions.operationId, operationId),+ eq(agentInterventions.toolCallId, toolCallId),+ ),+ )+ .limit(1);++ return row;+ };++ /** System-only owner/workspace recovery for post-claim delivery callbacks. */+ static locateByResolutionRequestId = async (+ db: LobeChatDatabase,+ resolutionRequestId: string,+ ): Promise<AgentInterventionResolutionLocator | undefined> => {+ if (!UUID_PATTERN.test(resolutionRequestId)) return undefined;+ const [row] = await db+ .select({+ batchId: agentInterventionResolutions.batchId,+ operationId: agentInterventionResolutions.operationId,+ source: agentInterventionResolutions.source,+ userId: agentInterventionResolutions.userId,+ workspaceId: agentInterventionResolutions.workspaceId,+ })+ .from(agentInterventionResolutions)+ .where(eq(agentInterventionResolutions.resolutionRequestId, resolutionRequestId))+ .limit(1);+ return row;+ };++ /**+ * Atomically claims a short custom-execution lease without holding a database+ * transaction across the external side effect. A completed claim replays the+ * exact durable private result; a live lease never exposes its fencing token.+ */+ claimCustomExecution = async (+ params: ClaimAgentInterventionCustomExecutionParams,+ now = new Date(),+ ): Promise<AgentInterventionCustomExecutionClaimResult> => {+ if (+ !UUID_PATTERN.test(params.resolutionRequestId) ||+ !HASH_PATTERN.test(params.inputHash) ||+ !Number.isSafeInteger(params.leaseDurationMs) ||+ params.leaseDurationMs < AGENT_INTERVENTION_CUSTOM_EXECUTION_MIN_LEASE_MS ||+ params.leaseDurationMs > AGENT_INTERVENTION_CUSTOM_EXECUTION_MAX_LEASE_MS ||+ Number.isNaN(now.getTime())+ ) {+ return { outcome: 'conflict' };+ }++ return this.db.transaction(async (tx) => {+ const [resolution] = await tx+ .select()+ .from(agentInterventionResolutions)+ .where(+ and(+ eq(agentInterventionResolutions.resolutionRequestId, params.resolutionRequestId),+ this.resolutionOwnership(),+ ),+ )+ .limit(1)+ .for('update');+ if (!resolution || resolution.action.type !== 'submit_custom') {+ return { outcome: 'conflict' };+ }+ if (+ resolution.customExecutionInputHash &&+ resolution.customExecutionInputHash !== params.inputHash+ ) {+ return { outcome: 'conflict' };+ }++ if (resolution.customExecutionState === 'completed') {+ return resolution.customExecutionResult+ ? { outcome: 'completed', result: resolution.customExecutionResult }+ : { outcome: 'conflict' };+ }+ if (resolution.status !== 'resolving') {+ return { outcome: 'conflict' };+ }++ if (resolution.customExecutionState === 'executing') {+ if (+ !resolution.customExecutionLeaseToken ||+ !resolution.customExecutionLeaseExpiresAt ||+ resolution.customExecutionAttempt === null+ ) {+ return { outcome: 'conflict' };+ }+ if (resolution.customExecutionLeaseExpiresAt.getTime() > now.getTime()) {+ return {+ attempt: resolution.customExecutionAttempt,+ leaseExpiresAt: resolution.customExecutionLeaseExpiresAt,+ outcome: 'in_progress',+ };+ }+ } else if (+ resolution.customExecutionState !== 'pending' &&+ resolution.customExecutionState !== null+ ) {+ return { outcome: 'conflict' };+ }++ const attempt = (resolution.customExecutionAttempt ?? 0) + 1;+ const leaseExpiresAt = new Date(now.getTime() + params.leaseDurationMs);+ const leaseToken = randomUUID();+ const [claimed] = await tx+ .update(agentInterventionResolutions)+ .set({+ customExecutionAttempt: attempt,+ customExecutionInputHash: params.inputHash,+ customExecutionLeaseExpiresAt: leaseExpiresAt,+ customExecutionLeaseToken: leaseToken,+ customExecutionResult: null,+ customExecutionState: 'executing',+ updatedAt: now,+ version: sql`${agentInterventionResolutions.version} + 1`,+ })+ .where(+ and(+ eq(agentInterventionResolutions.id, resolution.id),+ this.resolutionOwnership(),+ eq(agentInterventionResolutions.status, 'resolving'),+ ),+ )+ .returning({ id: agentInterventionResolutions.id });+ return claimed+ ? { attempt, leaseExpiresAt, leaseToken, outcome: 'applied' }+ : { outcome: 'conflict' };+ });+ };++ /** Completes only the exact current fencing token and replays exact retries. */+ completeCustomExecution = async (+ params: CompleteAgentInterventionCustomExecutionParams,+ now = new Date(),+ ): Promise<AgentInterventionCustomExecutionCompletionResult> => {+ if (+ !UUID_PATTERN.test(params.resolutionRequestId) ||+ !HASH_PATTERN.test(params.inputHash) ||+ !UUID_PATTERN.test(params.leaseToken) ||+ !isCustomExecutionResult(params.result) ||+ Number.isNaN(now.getTime())+ ) {+ return { outcome: 'conflict' };+ }++ return this.db.transaction(async (tx) => {+ const [resolution] = await tx+ .select()+ .from(agentInterventionResolutions)+ .where(+ and(+ eq(agentInterventionResolutions.resolutionRequestId, params.resolutionRequestId),+ this.resolutionOwnership(),+ ),+ )+ .limit(1)+ .for('update');+ if (+ !resolution ||+ resolution.action.type !== 'submit_custom' ||+ resolution.customExecutionInputHash !== params.inputHash ||+ resolution.customExecutionLeaseToken !== params.leaseToken+ ) {+ return { outcome: 'conflict' };+ }++ if (resolution.customExecutionState === 'completed') {+ return resolution.customExecutionResult &&+ sameJson(resolution.customExecutionResult, params.result)+ ? { outcome: 'completed', result: resolution.customExecutionResult }+ : { outcome: 'conflict' };+ }+ if (resolution.status !== 'resolving' || resolution.customExecutionState !== 'executing') {+ return { outcome: 'conflict' };+ }++ const [completed] = await tx+ .update(agentInterventionResolutions)+ .set({+ customExecutionResult: params.result,+ customExecutionState: 'completed',+ updatedAt: now,+ version: sql`${agentInterventionResolutions.version} + 1`,+ })+ .where(+ and(+ eq(agentInterventionResolutions.id, resolution.id),+ this.resolutionOwnership(),+ eq(agentInterventionResolutions.customExecutionInputHash, params.inputHash),+ eq(agentInterventionResolutions.customExecutionLeaseToken, params.leaseToken),+ eq(agentInterventionResolutions.customExecutionState, 'executing'),+ eq(agentInterventionResolutions.status, 'resolving'),+ ),+ )+ .returning({ result: agentInterventionResolutions.customExecutionResult });+ return completed?.result+ ? { outcome: 'completed', result: completed.result }+ : { outcome: 'conflict' };+ });+ };++ /** Creates and seals a complete batch in one transaction. */+ createBatch = async (+ params: CreateAgentInterventionBatchParams,+ ): Promise<AgentInterventionItem[]> => {+ this.validateCreateBatch(params);+ return this.db.transaction((tx) => this.createBatchInTransaction(tx, params));+ };++ /**+ * Atomically replaces the still-pending remainder of a runtime batch after a+ * partial decision re-parks under a new operation. The new parked batch is+ * causal proof that the prior runtime continuation started, so an in-flight+ * winning resolution may be completed here before its published hook arrives.+ */+ createBatchWithSupersession = async (+ params: CreateAgentInterventionBatchWithSupersessionParams,+ ): Promise<AgentInterventionBatchSupersessionResult> => {+ const { batch, supersedes } = params;+ this.validateCreateBatch(batch);+ if (!supersedes) {+ return this.db.transaction(async (tx) => {+ const [ownedOperation] = await tx+ .select({ id: agentOperations.id, status: agentOperations.status })+ .from(agentOperations)+ .where(+ and(+ eq(agentOperations.id, batch.operationId),+ eq(agentOperations.userId, this.userId),+ this.workspaceId+ ? eq(agentOperations.workspaceId, this.workspaceId)+ : isNull(agentOperations.workspaceId),+ ),+ )+ .limit(1)+ .for('update');+ if (!ownedOperation) throw new Error(AGENT_INTERVENTION_IDENTITY_CONFLICT);+ const existing = await tx+ .select({ id: agentInterventions.id })+ .from(agentInterventions)+ .where(+ and(+ eq(agentInterventions.operationId, batch.operationId),+ eq(agentInterventions.batchId, batch.batchId),+ this.ownership(),+ ),+ )+ .limit(1)+ .for('update');+ if (+ existing.length === 0 &&+ batch.source === 'runtime' &&+ ownedOperation.status !== 'waiting_for_human'+ ) {+ throw new Error(AGENT_INTERVENTION_IDENTITY_CONFLICT);+ }+ const interventions = await this.createBatchInTransaction(tx, batch, ownedOperation.status);+ return {+ interventions,+ outcome: existing.length > 0 ? 'idempotent' : 'applied',+ };+ });+ }++ const supersededToolCallIds = uniqueSorted(supersedes.toolCallIds);+ const newToolCallIds = uniqueSorted(batch.items.map((item) => item.toolCallId));+ if (+ batch.source !== 'runtime' ||+ batch.operationId === supersedes.operationId ||+ batch.batchId === supersedes.batchId ||+ batch.activityKey === supersedes.activityKey ||+ supersededToolCallIds.length === 0 ||+ supersededToolCallIds.length !== supersedes.toolCallIds.length ||+ !sameJson(supersededToolCallIds, newToolCallIds)+ ) {+ throw new Error(AGENT_INTERVENTION_IDENTITY_CONFLICT);+ }++ return this.db.transaction(async (tx) => {+ const operationIds = uniqueSorted([supersedes.operationId, batch.operationId]);+ const operations = await tx+ .select({+ agentId: agentOperations.agentId,+ appContext: agentOperations.appContext,+ chatGroupId: agentOperations.chatGroupId,+ id: agentOperations.id,+ status: agentOperations.status,+ taskId: agentOperations.taskId,+ threadId: agentOperations.threadId,+ topicId: agentOperations.topicId,+ })+ .from(agentOperations)+ .where(+ and(+ inArray(agentOperations.id, operationIds),+ eq(agentOperations.userId, this.userId),+ this.workspaceId+ ? eq(agentOperations.workspaceId, this.workspaceId)+ : isNull(agentOperations.workspaceId),+ ),+ )+ .orderBy(asc(agentOperations.id))+ .for('update');+ if (operations.length !== operationIds.length) {+ throw new Error(AGENT_INTERVENTION_IDENTITY_CONFLICT);+ }+ const oldOperation = operations.find(({ id }) => id === supersedes.operationId);+ const newOperation = operations.find(({ id }) => id === batch.operationId);+ if (+ !oldOperation ||+ !newOperation ||+ !['waiting_for_human', 'done'].includes(oldOperation.status) ||+ !['waiting_for_human', 'done'].includes(newOperation.status) ||+ !this.hasSameOperationContext(oldOperation, newOperation)+ ) {+ throw new Error(AGENT_INTERVENTION_IDENTITY_CONFLICT);+ }++ const lockedRows = await tx+ .select()+ .from(agentInterventions)+ .where(+ and(+ this.ownership(),+ or(+ and(+ eq(agentInterventions.operationId, supersedes.operationId),+ eq(agentInterventions.batchId, supersedes.batchId),+ ),+ and(+ eq(agentInterventions.operationId, batch.operationId),+ eq(agentInterventions.batchId, batch.batchId),+ ),+ ),+ ),+ )+ .orderBy(+ asc(agentInterventions.operationId),+ asc(agentInterventions.batchId),+ asc(agentInterventions.itemIndex),+ asc(agentInterventions.id),+ )+ .for('update');+ const oldRows = lockedRows+ .filter(+ (row) => row.operationId === supersedes.operationId && row.batchId === supersedes.batchId,+ )+ .sort((left, right) => left.itemIndex - right.itemIndex);+ const existingNewRows = lockedRows+ .filter((row) => row.operationId === batch.operationId && row.batchId === batch.batchId)+ .sort((left, right) => left.itemIndex - right.itemIndex);++ if (+ oldRows.length === 0 ||+ oldRows.some(+ (row, index) =>+ !row.sealed ||+ row.source !== 'runtime' ||+ row.activityKey !== supersedes.activityKey ||+ row.itemCount !== oldRows.length ||+ row.itemIndex !== index,+ )+ ) {+ throw new Error(AGENT_INTERVENTION_IDENTITY_CONFLICT);+ }+ if (existingNewRows.length > 0 && !this.isSameCreateBatch(existingNewRows, batch)) {+ throw new Error(AGENT_INTERVENTION_IDENTITY_CONFLICT);+ }++ const oldPendingRows = oldRows.filter((row) => row.status === 'pending');+ const activeOldRows = oldRows.filter((row) =>+ ['resolving', 'published'].includes(row.status),+ );+ const activeResolutionIds = uniqueSorted(+ activeOldRows.flatMap((row) => (row.resolutionId ? [row.resolutionId] : [])),+ );++ if (existingNewRows.length > 0) {+ const movedRows = oldRows.filter((row) => supersededToolCallIds.includes(row.toolCallId));+ if (+ oldPendingRows.length > 0 ||+ activeOldRows.length > 0 ||+ movedRows.length !== supersededToolCallIds.length ||+ movedRows.some((row) => row.status !== 'session_ended') ||+ oldOperation.status !== 'done'+ ) {+ throw new Error(AGENT_INTERVENTION_IDENTITY_CONFLICT);+ }+ return {+ interventions: existingNewRows,+ outcome: 'idempotent',+ superseded: {+ activityKey: supersedes.activityKey,+ batchId: supersedes.batchId,+ interventions: oldRows,+ operationId: supersedes.operationId,+ },+ };+ }++ // A replacement may only be created while its new runtime operation is+ // still parked. The broader status allowance above exists solely so an+ // exact, already-created replacement can be replayed idempotently after+ // its continuation has advanced the operation to done.+ if (newOperation.status !== 'waiting_for_human') {+ throw new Error(AGENT_INTERVENTION_IDENTITY_CONFLICT);+ }++ if (+ !sameJson(+ uniqueSorted(oldPendingRows.map((row) => row.toolCallId)),+ supersededToolCallIds,+ ) ||+ activeResolutionIds.length > 1 ||+ activeOldRows.some((row) => !row.resolutionId)+ ) {+ throw new Error(AGENT_INTERVENTION_IDENTITY_CONFLICT);+ }++ const now = new Date();+ if (activeResolutionIds.length === 1) {+ const [resolution] = await tx+ .select()+ .from(agentInterventionResolutions)+ .where(+ and(+ eq(agentInterventionResolutions.id, activeResolutionIds[0]),+ this.resolutionOwnership(),+ ),+ )+ .limit(1)+ .for('update');+ const activeIds = uniqueSorted(activeOldRows.map((row) => row.id));+ if (+ !resolution ||+ resolution.source !== 'runtime' ||+ resolution.operationId !== supersedes.operationId ||+ resolution.batchId !== supersedes.batchId ||+ !['resolving', 'published'].includes(resolution.status) ||+ resolution.action.type === 'stop' ||+ resolution.action.type === 'cancel_interaction' ||+ !sameJson(uniqueSorted(resolution.selectedInterventionIds), activeIds)+ ) {+ throw new Error(AGENT_INTERVENTION_IDENTITY_CONFLICT);+ }+ await tx+ .update(agentInterventionResolutions)+ .set({+ continuationStartedAt: now,+ publishedAt: resolution.publishedAt ?? now,+ status: 'completed',+ terminalAt: now,+ updatedAt: now,+ version: sql`${agentInterventionResolutions.version} + 1`,+ })+ .where(eq(agentInterventionResolutions.id, resolution.id));+ await tx+ .update(agentInterventions)+ .set({+ resolvedAt: now,+ status: terminalStatusForAction(resolution.action),+ updatedAt: now,+ version: sql`${agentInterventions.version} + 1`,+ })+ .where(+ and(+ eq(agentInterventions.resolutionId, resolution.id),+ inArray(agentInterventions.status, ['resolving', 'published']),+ ),+ );+ }++ const movedRows = await tx+ .update(agentInterventions)+ .set({+ resolvedAt: now,+ status: 'session_ended',+ updatedAt: now,+ version: sql`${agentInterventions.version} + 1`,+ })+ .where(+ and(+ eq(agentInterventions.operationId, supersedes.operationId),+ eq(agentInterventions.batchId, supersedes.batchId),+ eq(agentInterventions.status, 'pending'),+ inArray(agentInterventions.toolCallId, supersededToolCallIds),+ this.ownership(),+ ),+ )+ .returning();+ if (movedRows.length !== supersededToolCallIds.length) {+ throw new Error(AGENT_INTERVENTION_IDENTITY_CONFLICT);+ }++ await tx+ .update(agentOperations)+ .set({ completedAt: now, completionReason: 'done', status: 'done' })+ .where(+ and(+ eq(agentOperations.id, supersedes.operationId),+ eq(agentOperations.status, 'waiting_for_human'),+ eq(agentOperations.userId, this.userId),+ this.workspaceId+ ? eq(agentOperations.workspaceId, this.workspaceId)+ : isNull(agentOperations.workspaceId),+ ),+ );++ const interventions = await this.createBatchInTransaction(tx, batch, newOperation.status);+ const supersededRows = await tx+ .select()+ .from(agentInterventions)+ .where(+ and(+ eq(agentInterventions.operationId, supersedes.operationId),+ eq(agentInterventions.batchId, supersedes.batchId),+ this.ownership(),+ ),+ )+ .orderBy(asc(agentInterventions.itemIndex));+ return {+ interventions,+ outcome: 'applied',+ superseded: {+ activityKey: supersedes.activityKey,+ batchId: supersedes.batchId,+ interventions: supersededRows,+ operationId: supersedes.operationId,+ },+ };+ });+ };++ findById = async (id: string): Promise<AgentInterventionItem | undefined> => {+ if (!UUID_PATTERN.test(id)) return undefined;+ const row = await this.reload(id);+ return row && this.withLazyTimeout(row);+ };++ /** Owner-only cold-start lookup used before restoring a workspace header. */+ findByIdForOwner = async (id: string): Promise<AgentInterventionItem | undefined> => {+ if (!UUID_PATTERN.test(id)) return undefined;+ const [row] = await this.db+ .select()+ .from(agentInterventions)+ .where(and(eq(agentInterventions.id, id), this.ownerOnly()))+ .limit(1);+ return row && this.withOwnerLazyTimeout(row);+ };++ /** Legacy owner-auth token lookup. Workspace collaborators use the system locator + ACL. */+ findByReviewTokenHash = async (+ reviewTokenHash: string,+ ): Promise<AgentInterventionItem | undefined> => {+ if (!HASH_PATTERN.test(reviewTokenHash)) return undefined;+ const [row] = await this.db+ .select()+ .from(agentInterventions)+ .where(and(eq(agentInterventions.reviewTokenHash, reviewTokenHash), this.ownerOnly()))+ .limit(1);+ return row && this.withOwnerLazyTimeout(row);+ };++ findBatch = async (+ operationId: string,+ batchId: string,+ ): Promise<AgentInterventionBatchState> => {+ const rows = await this.reloadBatch(operationId, batchId);+ if (rows.length === 0) return { interventions: [], resolutions: [] };+ if (+ rows.some(+ (row) =>+ ['pending', 'resolving', 'published'].includes(row.status) &&+ row.deadline.getTime() <= Date.now(),+ )+ ) {+ await this.markBatchTerminal(operationId, batchId, 'timed_out');+ }+ const interventions = await this.reloadBatch(operationId, batchId);+ const resolutionIds = uniqueSorted(+ interventions.flatMap((row) => (row.resolutionId ? [row.resolutionId] : [])),+ );+ const resolutions =+ resolutionIds.length === 0+ ? []+ : await this.db+ .select(publicResolutionColumns)+ .from(agentInterventionResolutions)+ .where(+ and(+ inArray(agentInterventionResolutions.id, resolutionIds),+ this.resolutionOwnership(),+ ),+ );+ return { interventions, resolutions };+ };++ /**+ * Atomically validates a complete sealed Review snapshot and claims one,+ * selected, or all pending items. The resolving actor is explicit and may be+ * different from the operation owner after the service has applied ACL.+ */+ claimBatch = async (+ params: ClaimAgentInterventionBatchParams,+ ): Promise<AgentInterventionBatchMutationResult> => {+ if (!UUID_PATTERN.test(params.resolutionRequestId)) {+ throw new Error(AGENT_INTERVENTION_INVALID_BATCH);+ }+ if (!isCanonicalJsonSafe(params.action)) {+ throw new Error(AGENT_INTERVENTION_INVALID_ACTION);+ }++ const existingRequest = await this.findResolutionByRequestId(params.resolutionRequestId);+ if (existingRequest) return this.resolveIdempotentClaim(existingRequest, params);++ try {+ return await this.db.transaction(async (tx) => {+ const rows = await tx+ .select()+ .from(agentInterventions)+ .where(+ and(+ eq(agentInterventions.operationId, params.operationId),+ eq(agentInterventions.batchId, params.batchId),+ this.ownership(),+ ),+ )+ .orderBy(asc(agentInterventions.itemIndex))+ .for('update');+ if (rows.length === 0) return { outcome: 'not_found' };++ const now = new Date();+ const overdue = rows.filter(+ (row) =>+ ['pending', 'resolving', 'published'].includes(row.status) &&+ row.deadline.getTime() <= now.getTime(),+ );+ if (overdue.length > 0) {+ const terminalRows = await this.markRowsTerminalInTransaction(tx, rows, 'timed_out', now);+ return { interventions: terminalRows, outcome: 'conflict' };+ }++ const batchIds = rows.map((row) => row.id);+ if (!this.hasValidSealedSnapshot(rows, params)) {+ return { interventions: rows, outcome: 'conflict' };+ }++ const selectedIds = uniqueSorted(params.selectedInterventionIds);+ // Stopping an operation settles only the callbacks that are still pending.+ // The caller still supplies the complete sealed-batch snapshot for CAS, but+ // already terminal siblings must remain immutable.+ const targetIds =+ params.action.type === 'stop'+ ? selectedIds+ : params.scope === 'all'+ ? [...batchIds].sort()+ : selectedIds;+ const targets = rows.filter((row) => targetIds.includes(row.id));+ if (!this.hasValidSelection(rows, targets, params, selectedIds)) {+ return { interventions: rows, outcome: 'conflict' };+ }+ if (targets.some((row) => row.status !== 'pending')) {+ return { interventions: rows, outcome: 'conflict' };+ }++ this.validateAction(targets, params);++ const argumentEffect = await this.applyArgumentEffect(tx, targets, params.action);++ let rememberToolKey: null | string = null;+ let rememberEffectStatus: 'applied' | 'retained' | null = null;+ if (params.action.type === 'approve_remember') {+ const remember = await this.applyRememberEffect(tx, params.actorId, targets[0]);+ rememberToolKey = remember.toolKey;+ rememberEffectStatus = remember.status;+ }++ const [resolution] = await tx+ .insert(agentInterventionResolutions)+ .values({+ action: params.action,+ argumentEffectStatus: argumentEffect ? 'applied' : null,+ actorId: params.actorId,+ batchId: params.batchId,+ customExecutionAttempt: params.action.type === 'submit_custom' ? 0 : null,+ customExecutionState: params.action.type === 'submit_custom' ? 'pending' : null,+ expectedItemCount: params.expectedItemCount,+ expectedRequestRevisionHashes: params.expectedRequestRevisionHashes,+ expectedVersions: params.expectedVersions,+ operationId: rows[0].operationId,+ editedArguments: argumentEffect?.editedArguments,+ editedRequestRevisionHash: argumentEffect?.editedRequestRevisionHash,+ originalArguments: argumentEffect?.originalArguments,+ originalRequestRevisionHash: argumentEffect?.originalRequestRevisionHash,+ rememberEffectStatus,+ rememberToolKey,+ resolutionRequestId: params.resolutionRequestId,+ scope: params.scope,+ selectedInterventionIds: targetIds,+ source: rows[0].source,+ userId: this.userId,+ workspaceId: this.workspaceId ?? null,+ })+ .returning();++ const claimed = await tx+ .update(agentInterventions)+ .set({+ requestRevisionHash: argumentEffect?.editedRequestRevisionHash,+ resolutionId: resolution.id,+ resolvingAt: now,+ status: 'resolving',+ updatedAt: now,+ version: sql`${agentInterventions.version} + 1`,+ })+ .where(+ and(+ inArray(agentInterventions.id, targetIds),+ this.ownership(),+ eq(agentInterventions.status, 'pending'),+ gt(agentInterventions.deadline, now),+ ),+ )+ .returning();+ if (claimed.length !== targetIds.length) throw new Error(AGENT_INTERVENTION_INVALID_BATCH);++ const updatedRows = rows.map((row) => claimed.find((item) => item.id === row.id) ?? row);+ return { interventions: updatedRows, outcome: 'applied', resolution };+ });+ } catch (error) {+ if (isUniqueViolation(error)) {+ const existing = await this.findResolutionByRequestId(params.resolutionRequestId);+ if (existing) return this.resolveIdempotentClaim(existing, params);+ throw new Error(AGENT_INTERVENTION_RESOLUTION_REQUEST_REUSED, { cause: error });+ }+ throw error;+ }+ };++ markResolutionPublished = async (+ resolutionRequestId: string,+ publishedAt = new Date(),+ ): Promise<AgentInterventionBatchMutationResult> =>+ this.transitionResolution(resolutionRequestId, async (tx, resolution, rows) => {+ if (resolution.status === 'published' || resolution.status === 'completed') {+ return { interventions: rows, outcome: 'idempotent', resolution };+ }+ if (resolution.status !== 'resolving') {+ return { interventions: rows, outcome: 'conflict', resolution };+ }++ const [updatedResolution] = await tx+ .update(agentInterventionResolutions)+ .set({+ publishedAt,+ status: 'published',+ updatedAt: publishedAt,+ version: sql`${agentInterventionResolutions.version} + 1`,+ })+ .where(+ and(+ eq(agentInterventionResolutions.id, resolution.id),+ eq(agentInterventionResolutions.status, 'resolving'),+ ),+ )+ .returning();+ const updatedRows = await tx+ .update(agentInterventions)+ .set({+ publishedAt,+ status: 'published',+ updatedAt: publishedAt,+ version: sql`${agentInterventions.version} + 1`,+ })+ .where(+ and(+ eq(agentInterventions.resolutionId, resolution.id),+ eq(agentInterventions.status, 'resolving'),+ ),+ )+ .returning();+ return { interventions: updatedRows, outcome: 'applied', resolution: updatedResolution };+ });++ /** Publish failed before consumption; conditionally reopens only this claim. */+ rollbackResolution = async (+ resolutionRequestId: string,+ ): Promise<AgentInterventionBatchMutationResult> =>+ this.transitionResolution(resolutionRequestId, async (tx, resolution, rows) => {+ if (resolution.status === 'rolled_back') {+ return { interventions: rows, outcome: 'idempotent', resolution };+ }+ if (resolution.status !== 'resolving') {+ return { interventions: rows, outcome: 'conflict', resolution };+ }+ if (+ resolution.action.type === 'submit_custom' &&+ resolution.customExecutionState !== null &&+ resolution.customExecutionState !== 'pending'+ ) {+ return { interventions: rows, outcome: 'conflict', resolution };+ }++ const now = new Date();+ const argumentRollback = await this.rollbackArgumentEffect(tx, resolution, rows);+ const rememberEffectStatus = await this.rollbackRememberEffect(tx, resolution);+ const [updatedResolution] = await tx+ .update(agentInterventionResolutions)+ .set({+ argumentEffectStatus: argumentRollback.status,+ rememberEffectStatus,+ rolledBackAt: now,+ status: 'rolled_back',+ updatedAt: now,+ version: sql`${agentInterventionResolutions.version} + 1`,+ })+ .where(eq(agentInterventionResolutions.id, resolution.id))+ .returning();++ const updatedRows = await tx+ .update(agentInterventions)+ .set({+ requestRevisionHash: argumentRollback.requestRevisionHash,+ resolutionId: null,+ resolvingAt: null,+ status: 'pending',+ updatedAt: now,+ version: sql`${agentInterventions.version} + 1`,+ })+ .where(+ and(+ eq(agentInterventions.resolutionId, resolution.id),+ eq(agentInterventions.status, 'resolving'),+ gt(agentInterventions.deadline, now),+ ),+ )+ .returning();+ const expiredRows = await tx+ .update(agentInterventions)+ .set({+ requestRevisionHash: argumentRollback.requestRevisionHash,+ resolutionId: null,+ resolvedAt: now,+ resolvingAt: null,+ status: 'timed_out',+ updatedAt: now,+ version: sql`${agentInterventions.version} + 1`,+ })+ .where(+ and(+ eq(agentInterventions.resolutionId, resolution.id),+ eq(agentInterventions.status, 'resolving'),+ lte(agentInterventions.deadline, now),+ ),+ )+ .returning();+ return {+ interventions: [...updatedRows, ...expiredRows].sort(+ (left, right) => left.itemIndex - right.itemIndex,+ ),+ outcome: 'applied',+ resolution: updatedResolution,+ };+ });++ /** Runtime rows become terminal once the continuation has durably started. */+ completeRuntimeResolution = async (+ resolutionRequestId: string,+ continuationStartedAt = new Date(),+ ): Promise<AgentInterventionBatchMutationResult> =>+ this.completeResolution(resolutionRequestId, 'runtime', continuationStartedAt);++ /** Heterogeneous rows become terminal only after the matching producer ACK. */+ acknowledgeProducerResolution = async (+ resolutionRequestId: string,+ producerAckAt = new Date(),+ ): Promise<AgentInterventionBatchMutationResult> =>+ this.completeResolution(resolutionRequestId, 'heterogeneous', producerAckAt);++ /** Timeout/session teardown of every still-open item in one sealed batch. */+ markBatchTerminal = async (+ operationId: string,+ batchId: string,+ status: 'session_ended' | 'timed_out',+ at = new Date(),+ ): Promise<AgentInterventionItem[]> =>+ this.db.transaction(async (tx) => {+ const rows = await tx+ .select()+ .from(agentInterventions)+ .where(+ and(+ eq(agentInterventions.operationId, operationId),+ eq(agentInterventions.batchId, batchId),+ this.ownership(),+ ),+ )+ .for('update');+ if (rows.length === 0) return [];+ if (status === 'timed_out' && rows.every((row) => row.deadline.getTime() > at.getTime())) {+ return rows;+ }++ const openRows = rows.filter((row) =>+ ['pending', 'resolving', 'published'].includes(row.status),+ );+ if (openRows.length === 0) return rows;+ return this.markRowsTerminalInTransaction(tx, rows, status, at);+ });++ /** Late heterogeneous ACK is audited without overwriting timeout/session outcome. */+ recordProducerAck = async (+ resolutionRequestId: string,+ producerAckAt = new Date(),+ ): Promise<AgentInterventionBatchMutationResult> =>+ this.transitionResolution(resolutionRequestId, async (tx, resolution, rows) => {+ if (resolution.source !== 'heterogeneous') {+ throw new Error(AGENT_INTERVENTION_SOURCE_TRANSITION_MISMATCH);+ }+ if (resolution.producerAckAt) {+ return { interventions: rows, outcome: 'idempotent', resolution };+ }+ if (!['timed_out', 'session_ended'].includes(resolution.status)) {+ return { interventions: rows, outcome: 'conflict', resolution };+ }+ const [updatedResolution] = await tx+ .update(agentInterventionResolutions)+ .set({+ producerAckAt,+ updatedAt: producerAckAt,+ version: sql`${agentInterventionResolutions.version} + 1`,+ })+ .where(eq(agentInterventionResolutions.id, resolution.id))+ .returning();+ const updatedRows = await tx+ .update(agentInterventions)+ .set({+ producerAckAt,+ updatedAt: producerAckAt,+ version: sql`${agentInterventions.version} + 1`,+ })+ .where(eq(agentInterventions.resolutionId, resolution.id))+ .returning();+ return { interventions: updatedRows, outcome: 'applied', resolution: updatedResolution };+ });++ findResolutionByRequestId = async (+ resolutionRequestId: string,+ ): Promise<AgentInterventionResolutionItem | undefined> => {+ if (!UUID_PATTERN.test(resolutionRequestId)) return undefined;+ const [row] = await this.db+ .select()+ .from(agentInterventionResolutions)+ .where(+ and(+ eq(agentInterventionResolutions.resolutionRequestId, resolutionRequestId),+ this.resolutionOwnership(),+ ),+ )+ .limit(1);+ return row;+ };++ private markRowsTerminalInTransaction = async (+ tx: Transaction,+ rows: AgentInterventionItem[],+ status: 'session_ended' | 'timed_out',+ at: Date,+ ): Promise<AgentInterventionItem[]> => {+ const openRows = rows.filter((row) =>+ ['pending', 'resolving', 'published'].includes(row.status),+ );+ if (openRows.length === 0) return rows;+ const resolutionIds = uniqueSorted(+ openRows.flatMap((row) => (row.resolutionId ? [row.resolutionId] : [])),+ );+ const protectedResolutionIds = new Set<string>();+ if (resolutionIds.length > 0) {+ const resolutions = await tx+ .select({+ customExecutionState: agentInterventionResolutions.customExecutionState,+ id: agentInterventionResolutions.id,+ })+ .from(agentInterventionResolutions)+ .where(+ and(inArray(agentInterventionResolutions.id, resolutionIds), this.resolutionOwnership()),+ )+ .orderBy(asc(agentInterventionResolutions.id))+ .for('update');+ for (const resolution of resolutions) {+ if (['executing', 'completed'].includes(resolution.customExecutionState ?? '')) {+ protectedResolutionIds.add(resolution.id);+ }+ }+ const terminalResolutionIds = resolutionIds.filter(+ (resolutionId) => !protectedResolutionIds.has(resolutionId),+ );+ if (terminalResolutionIds.length > 0) {+ await tx+ .update(agentInterventionResolutions)+ .set({+ status,+ terminalAt: at,+ updatedAt: at,+ version: sql`${agentInterventionResolutions.version} + 1`,+ })+ .where(+ and(+ inArray(agentInterventionResolutions.id, terminalResolutionIds),+ inArray(agentInterventionResolutions.status, ['resolving', 'published']),+ ),+ );+ }+ }+ const terminalRows = openRows.filter(+ (row) => !row.resolutionId || !protectedResolutionIds.has(row.resolutionId),+ );+ if (terminalRows.length === 0) return rows;+ const updated = await tx+ .update(agentInterventions)+ .set({+ resolvedAt: at,+ status,+ updatedAt: at,+ version: sql`${agentInterventions.version} + 1`,+ })+ .where(+ inArray(+ agentInterventions.id,+ terminalRows.map((row) => row.id),+ ),+ )+ .returning();+ return rows.map((row) => updated.find((item) => item.id === row.id) ?? row);+ };++ private createBatchInTransaction = async (+ tx: Transaction,+ params: CreateAgentInterventionBatchParams,+ lockedOperationStatus?: AgentInterventionOperationIdentity['status'],+ ): Promise<AgentInterventionItem[]> => {+ let operationStatus = lockedOperationStatus;+ if (operationStatus === undefined) {+ const [ownedOperation] = await tx+ .select({ id: agentOperations.id, status: agentOperations.status })+ .from(agentOperations)+ .where(+ and(+ eq(agentOperations.id, params.operationId),+ eq(agentOperations.userId, this.userId),+ this.workspaceId+ ? eq(agentOperations.workspaceId, this.workspaceId)+ : isNull(agentOperations.workspaceId),+ ),+ )+ .limit(1)+ .for('update');+ if (!ownedOperation) throw new Error(AGENT_INTERVENTION_IDENTITY_CONFLICT);+ operationStatus = ownedOperation.status;+ }++ const existing = await tx+ .select()+ .from(agentInterventions)+ .where(+ and(+ eq(agentInterventions.operationId, params.operationId),+ eq(agentInterventions.batchId, params.batchId),+ this.ownership(),+ ),+ )+ .orderBy(asc(agentInterventions.itemIndex))+ .for('update');++ if (existing.length > 0) {+ if (!this.isSameCreateBatch(existing, params)) {+ throw new Error(AGENT_INTERVENTION_IDENTITY_CONFLICT);+ }+ return existing;+ }+ if (params.source === 'runtime' && operationStatus !== 'waiting_for_human') {+ throw new Error(AGENT_INTERVENTION_IDENTITY_CONFLICT);+ }++ try {+ return await tx+ .insert(agentInterventions)+ .values(+ params.items.map((item, itemIndex) => ({+ ...item,+ activityKey: params.activityKey,+ allowedActions: [...item.allowedActions],+ approvalMode: params.approvalMode ?? null,+ batchId: params.batchId,+ deadline: params.deadline,+ itemCount: params.items.length,+ itemIndex,+ operationId: params.operationId,+ provider: item.provider ?? params.provider ?? null,+ reviewContext: normalizeDtoJson(item.reviewContext),+ risk: item.risk === undefined ? null : normalizeDtoJson(item.risk),+ sanitizedRequest: normalizeDtoJson(item.sanitizedRequest),+ sealed: true,+ source: params.source,+ stepIndex: params.stepIndex,+ systemActionEligibility: params.systemActionEligibility,+ userId: this.userId,+ workspaceId: this.workspaceId ?? null,+ })),+ )+ .returning();+ } catch (error) {+ if (isUniqueViolation(error)) {+ throw new Error(AGENT_INTERVENTION_IDENTITY_CONFLICT, { cause: error });+ }+ throw error;+ }+ };++ private isSameCreateBatch = (+ existing: AgentInterventionItem[],+ params: CreateAgentInterventionBatchParams,+ ): boolean =>+ existing.length === params.items.length &&+ existing.every((row, index) => {+ const item = params.items[index];+ return (+ row.activityKey === params.activityKey &&+ row.approvalMode === (params.approvalMode ?? null) &&+ row.batchId === params.batchId &&+ row.canonicalToolKey === (item.canonicalToolKey ?? null) &&+ row.deadline.getTime() === params.deadline.getTime() &&+ row.interactionKind === item.interactionKind &&+ row.itemCount === params.items.length &&+ row.itemIndex === index &&+ row.provider === (item.provider ?? params.provider ?? null) &&+ row.requestRevisionHash === item.requestRevisionHash &&+ row.reviewTokenHash === item.reviewTokenHash &&+ row.sealed &&+ row.source === params.source &&+ row.stepIndex === params.stepIndex &&+ row.surface === item.surface &&+ row.systemActionEligibility === params.systemActionEligibility &&+ row.toolCallId === item.toolCallId &&+ row.toolMessageId === (item.toolMessageId ?? null) &&+ sameJson(uniqueSorted(row.allowedActions), uniqueSorted(item.allowedActions)) &&+ sameDtoJson(row.reviewContext, item.reviewContext) &&+ sameDtoJson(row.risk, item.risk ?? null) &&+ sameDtoJson(row.sanitizedRequest, item.sanitizedRequest)+ );+ });++ private hasSameOperationContext = (+ left: AgentInterventionOperationIdentity,+ right: AgentInterventionOperationIdentity,+ ): boolean => {+ const leftContext = asRecord(left.appContext);+ const rightContext = asRecord(right.appContext);+ return (+ left.agentId === right.agentId &&+ left.chatGroupId === right.chatGroupId &&+ left.taskId === right.taskId &&+ left.threadId === right.threadId &&+ left.topicId === right.topicId &&+ sameJson(+ {+ documentId: leftContext.documentId ?? null,+ groupId: leftContext.groupId ?? null,+ scope: leftContext.scope ?? null,+ sessionId: leftContext.sessionId ?? null,+ },+ {+ documentId: rightContext.documentId ?? null,+ groupId: rightContext.groupId ?? null,+ scope: rightContext.scope ?? null,+ sessionId: rightContext.sessionId ?? null,+ },+ )+ );+ };++ private validateCreateBatch(params: CreateAgentInterventionBatchParams) {+ if (+ !params.batchId ||+ !params.activityKey ||+ params.items.length === 0 ||+ params.stepIndex < 0+ ) {+ throw new Error(AGENT_INTERVENTION_INVALID_BATCH);+ }+ if (+ params.systemActionEligibility === 'safe_single_binary' &&+ (params.items.length !== 1 ||+ params.source !== 'runtime' ||+ params.items[0].surface !== 'binary')+ ) {+ throw new Error(AGENT_INTERVENTION_INVALID_BATCH);+ }+ const toolCallIds = new Set<string>();+ const reviewHashes = new Set<string>();+ for (const item of params.items) {+ if (!HASH_PATTERN.test(item.reviewTokenHash)) {+ throw new Error(AGENT_INTERVENTION_INVALID_REVIEW_TOKEN_HASH);+ }+ if (!HASH_PATTERN.test(item.requestRevisionHash)) {+ throw new Error(AGENT_INTERVENTION_INVALID_REQUEST_REVISION_HASH);+ }+ if (+ !item.toolCallId ||+ item.allowedActions.length === 0 ||+ uniqueSorted(item.allowedActions).length !== item.allowedActions.length ||+ toolCallIds.has(item.toolCallId) ||+ reviewHashes.has(item.reviewTokenHash)+ ) {+ throw new Error(AGENT_INTERVENTION_INVALID_BATCH);+ }+ const unsafeRequest = item.sanitizedRequest as AgentInterventionSanitizedRequest &+ Record<string, unknown>;+ if (+ !isCanonicalDtoJsonSafe(item.reviewContext) ||+ !isCanonicalDtoJsonSafe(item.risk ?? null) ||+ !isCanonicalDtoJsonSafe(item.sanitizedRequest) ||+ 'arguments' in unsafeRequest ||+ 'rawArguments' in unsafeRequest ||+ 'metadata' in unsafeRequest ||+ !hasValidCustomDetail(item.sanitizedRequest)+ ) {+ throw new Error(AGENT_INTERVENTION_INVALID_BATCH);+ }+ const hasQuestionFreeform =+ item.sanitizedRequest.answerPolicy?.allowFreeform === true ||+ item.sanitizedRequest.answerPolicy?.allowSupplement === true ||+ item.sanitizedRequest.questions?.some((question) => question.allowCustomAnswer) === true;+ if (hasQuestionFreeform && item.interactionKind !== 'question') {+ throw new Error(AGENT_INTERVENTION_INVALID_ACTION);+ }+ if (item.allowedActions.includes('approve_remember') && !item.canonicalToolKey) {+ throw new Error(AGENT_INTERVENTION_INVALID_ACTION);+ }+ if (params.source === 'heterogeneous' && !(item.provider ?? params.provider)) {+ throw new Error(AGENT_INTERVENTION_INVALID_BATCH);+ }+ toolCallIds.add(item.toolCallId);+ reviewHashes.add(item.reviewTokenHash);+ }+ }++ private hasValidSealedSnapshot(+ rows: AgentInterventionItem[],+ params: ClaimAgentInterventionBatchParams,+ ): boolean {+ const ids = rows.map((row) => row.id);+ if (+ rows.length !== params.expectedItemCount ||+ rows.some(+ (row, index) => !row.sealed || row.itemCount !== rows.length || row.itemIndex !== index,+ ) ||+ !hasExactKeys(params.expectedVersions, ids) ||+ !hasExactKeys(params.expectedRequestRevisionHashes, ids)+ ) {+ return false;+ }+ return rows.every(+ (row) =>+ params.expectedVersions[row.id] === row.version &&+ params.expectedRequestRevisionHashes[row.id] === row.requestRevisionHash,+ );+ }++ private hasValidSelection(+ rows: AgentInterventionItem[],+ targets: AgentInterventionItem[],+ params: ClaimAgentInterventionBatchParams,+ selectedIds: string[],+ ): boolean {+ if (selectedIds.length === 0 || targets.length !== selectedIds.length) return false;+ if (params.scope === 'single' && selectedIds.length !== 1) return false;+ if (params.action.type === 'stop') {+ // Let validateAction surface an invalid stop scope as a contract error,+ // rather than disguising it as a stale-snapshot conflict.+ if (params.scope !== 'all') return true;+ // A published/resolving sibling already won a competing decision and must+ // finish before an operation-wide stop can safely claim the remainder.+ if (rows.some((row) => row.status === 'resolving' || row.status === 'published'))+ return false;+ const pendingIds = rows+ .filter((row) => row.status === 'pending')+ .map((row) => row.id)+ .sort();+ return sameJson(pendingIds, selectedIds);+ }+ if (params.scope === 'all') {+ const batchIds = rows.map((row) => row.id).sort();+ return sameJson(batchIds, selectedIds);+ }+ return true;+ }++ private validateAction(+ targets: AgentInterventionItem[],+ params: ClaimAgentInterventionBatchParams,+ ) {+ const capability = actionCapability(params.action);+ if (targets.some((row) => !row.allowedActions.includes(capability))) {+ throw new Error(AGENT_INTERVENTION_INVALID_ACTION);+ }+ if (+ (params.action.type === 'approve' || params.action.type === 'approve_remember') &&+ params.action.editedArguments &&+ (params.scope !== 'single' ||+ targets.length !== 1 ||+ !targets[0].allowedActions.includes('edit_arguments'))+ ) {+ throw new Error(AGENT_INTERVENTION_INVALID_ACTION);+ }+ if (+ params.action.type === 'approve_remember' &&+ (params.scope !== 'single' ||+ targets.length !== 1 ||+ params.actorId !== this.userId ||+ !targets[0].canonicalToolKey)+ ) {+ throw new Error(AGENT_INTERVENTION_INVALID_ACTION);+ }+ if (+ params.action.type === 'select_provider_option' &&+ (targets.length !== 1 ||+ !providerOptionIds(targets[0].sanitizedRequest).has(params.action.optionId))+ ) {+ throw new Error(AGENT_INTERVENTION_INVALID_ACTION);+ }+ if (+ params.action.type === 'submit_answers' &&+ (targets.length !== 1 || !hasValidAnswers(targets[0].sanitizedRequest, params.action.answers))+ ) {+ throw new Error(AGENT_INTERVENTION_INVALID_ACTION);+ }+ if (+ params.action.type === 'submit_custom' &&+ (targets.length !== 1 ||+ params.action.expectedRevisionHash !== targets[0].requestRevisionHash ||+ !hasValidCustomResult(targets[0].sanitizedRequest, params.action.result))+ ) {+ throw new Error(AGENT_INTERVENTION_INVALID_ACTION);+ }+ if (+ params.action.type === 'stop' &&+ (params.action.haltScope !== 'operation' || params.scope !== 'all')+ ) {+ throw new Error(AGENT_INTERVENTION_INVALID_ACTION);+ }+ }++ private applyArgumentEffect = async (+ tx: Transaction,+ targets: AgentInterventionItem[],+ action: AgentInterventionResolutionAction,+ ): Promise<+ | {+ editedArguments: string;+ editedRequestRevisionHash: string;+ originalArguments: string;+ originalRequestRevisionHash: string;+ }+ | undefined+ > => {+ if (action.type !== 'approve' && action.type !== 'approve_remember') return undefined;++ const targetMessageIds = targets.map((target) => target.toolMessageId);+ if (targetMessageIds.some((id): id is null => !id)) {+ throw new Error(AGENT_INTERVENTION_INVALID_ACTION);+ }+ const pluginRows = await tx+ .select({+ arguments: messagePlugins.arguments,+ id: messagePlugins.id,+ parentId: messages.parentId,+ toolCallId: messagePlugins.toolCallId,+ })+ .from(messagePlugins)+ .innerJoin(messages, eq(messages.id, messagePlugins.id))+ .where(+ and(+ inArray(messagePlugins.id, targetMessageIds as string[]),+ eq(messagePlugins.userId, this.userId),+ this.workspaceId+ ? eq(messagePlugins.workspaceId, this.workspaceId)+ : isNull(messagePlugins.workspaceId),+ ),+ )+ .orderBy(asc(messagePlugins.id))+ .for('update');+ if (pluginRows.length !== targets.length) {+ throw new Error(AGENT_INTERVENTION_IDENTITY_CONFLICT);+ }++ for (const target of targets) {+ const plugin = pluginRows.find((row) => row.id === target.toolMessageId);+ if (+ !plugin ||+ plugin.toolCallId !== target.toolCallId ||+ plugin.arguments === null ||+ hashAgentInterventionRequestRevision(plugin.arguments) !== target.requestRevisionHash+ ) {+ throw new Error(AGENT_INTERVENTION_INVALID_REQUEST_REVISION_HASH);+ }+ }++ if (!action.editedArguments) return undefined;+ const target = targets[0];+ const plugin = pluginRows[0];+ if (!plugin.parentId || plugin.id !== target.toolMessageId) {+ throw new Error(AGENT_INTERVENTION_IDENTITY_CONFLICT);+ }++ const [parent] = await tx+ .select({ id: messages.id, tools: messages.tools })+ .from(messages)+ .where(+ and(+ eq(messages.id, plugin.parentId),+ eq(messages.userId, this.userId),+ this.workspaceId+ ? eq(messages.workspaceId, this.workspaceId)+ : isNull(messages.workspaceId),+ ),+ )+ .limit(1)+ .for('update');+ if (!parent?.tools) throw new Error(AGENT_INTERVENTION_IDENTITY_CONFLICT);++ const originalArguments = plugin.arguments as string;+ const editedArguments = canonicalJson(action.editedArguments);+ const originalRequestRevisionHash = hashAgentInterventionRequestRevision(originalArguments);+ const editedRequestRevisionHash = hashAgentInterventionRequestRevision(editedArguments);+ const tools = parent.tools as ChatToolPayload[];+ let toolFound = false;+ const updatedTools = tools.map((tool) => {+ if (tool.id !== target.toolCallId) return tool;+ toolFound = true;+ return { ...tool, arguments: editedArguments };+ });+ if (!toolFound) throw new Error(AGENT_INTERVENTION_IDENTITY_CONFLICT);++ await tx+ .update(messagePlugins)+ .set({ arguments: editedArguments })+ .where(+ and(eq(messagePlugins.id, plugin.id), eq(messagePlugins.arguments, originalArguments)),+ );+ await tx.update(messages).set({ tools: updatedTools }).where(eq(messages.id, parent.id));++ return {+ editedArguments,+ editedRequestRevisionHash,+ originalArguments,+ originalRequestRevisionHash,+ };+ };++ private applyRememberEffect = async (+ tx: Transaction,+ actorId: string,+ target: AgentInterventionItem,+ ): Promise<{ status: 'applied' | 'retained'; toolKey: string }> => {+ if (actorId !== this.userId || !target.canonicalToolKey) {+ throw new Error(AGENT_INTERVENTION_INVALID_ACTION);+ }+ await tx+ .insert(userSettings)+ .values({ id: this.userId, tool: {} })+ .onConflictDoNothing({ target: userSettings.id });+ const [settings] = await tx+ .select({ tool: userSettings.tool })+ .from(userSettings)+ .where(eq(userSettings.id, this.userId))+ .limit(1)+ .for('update');++ const tool = asRecord(settings?.tool);+ const humanIntervention = asRecord(tool.humanIntervention);+ const allowList = Array.isArray(humanIntervention.allowList)+ ? humanIntervention.allowList.filter((item): item is string => typeof item === 'string')+ : [];+ const existed = allowList.includes(target.canonicalToolKey);+ if (!existed) {+ await tx+ .update(userSettings)+ .set({+ tool: {+ ...tool,+ humanIntervention: {+ ...humanIntervention,+ allowList: [...allowList, target.canonicalToolKey],+ },+ },+ })+ .where(eq(userSettings.id, this.userId));+ }+ return { status: existed ? 'retained' : 'applied', toolKey: target.canonicalToolKey };+ };++ private rollbackArgumentEffect = async (+ tx: Transaction,+ resolution: AgentInterventionResolutionItem,+ rows: AgentInterventionItem[],+ ): Promise<{+ requestRevisionHash?: string;+ status: 'applied' | 'retained' | 'rolled_back' | null;+ }> => {+ if (resolution.argumentEffectStatus !== 'applied') {+ return { status: resolution.argumentEffectStatus };+ }+ const row = rows[0];+ if (+ rows.length !== 1 ||+ !row?.toolMessageId ||+ !resolution.originalArguments ||+ !resolution.editedArguments ||+ !resolution.originalRequestRevisionHash ||+ !resolution.editedRequestRevisionHash+ ) {+ return { status: 'retained' };+ }++ const [plugin] = await tx+ .select({+ arguments: messagePlugins.arguments,+ id: messagePlugins.id,+ parentId: messages.parentId,+ })+ .from(messagePlugins)+ .innerJoin(messages, eq(messages.id, messagePlugins.id))+ .where(+ and(+ eq(messagePlugins.id, row.toolMessageId),+ eq(messagePlugins.userId, this.userId),+ this.workspaceId+ ? eq(messagePlugins.workspaceId, this.workspaceId)+ : isNull(messagePlugins.workspaceId),+ ),+ )+ .limit(1)+ .for('update');+ if (!plugin?.arguments) return { status: 'retained' };++ const currentHash = hashAgentInterventionRequestRevision(plugin.arguments);+ if (+ plugin.arguments !== resolution.editedArguments ||+ currentHash !== resolution.editedRequestRevisionHash ||+ row.requestRevisionHash !== resolution.editedRequestRevisionHash ||+ !plugin.parentId+ ) {+ return { requestRevisionHash: currentHash, status: 'retained' };+ }++ const [parent] = await tx+ .select({ id: messages.id, tools: messages.tools })+ .from(messages)+ .where(+ and(+ eq(messages.id, plugin.parentId),+ eq(messages.userId, this.userId),+ this.workspaceId+ ? eq(messages.workspaceId, this.workspaceId)+ : isNull(messages.workspaceId),+ ),+ )+ .limit(1)+ .for('update');+ if (!parent?.tools) return { requestRevisionHash: currentHash, status: 'retained' };++ let toolFound = false;+ const updatedTools = (parent.tools as ChatToolPayload[]).map((tool) => {+ if (tool.id !== row.toolCallId || tool.arguments !== resolution.editedArguments) return tool;+ toolFound = true;+ return { ...tool, arguments: resolution.originalArguments as string };+ });+ if (!toolFound) return { requestRevisionHash: currentHash, status: 'retained' };++ const restored = await tx+ .update(messagePlugins)+ .set({ arguments: resolution.originalArguments })+ .where(+ and(+ eq(messagePlugins.id, plugin.id),+ eq(messagePlugins.arguments, resolution.editedArguments),+ ),+ )+ .returning({ id: messagePlugins.id });+ if (restored.length !== 1) {+ return { requestRevisionHash: currentHash, status: 'retained' };+ }+ await tx.update(messages).set({ tools: updatedTools }).where(eq(messages.id, parent.id));+ return {+ requestRevisionHash: resolution.originalRequestRevisionHash,+ status: 'rolled_back',+ };+ };++ private rollbackRememberEffect = async (+ tx: Transaction,+ resolution: AgentInterventionResolutionItem,+ ): Promise<'applied' | 'retained' | 'rolled_back' | null> => {+ if (!resolution.rememberToolKey || resolution.rememberEffectStatus !== 'applied') {+ return resolution.rememberEffectStatus;+ }++ // Serialize with approve_remember claims on the same user settings row.+ // A concurrent claim inserts its durable resolution before releasing this+ // lock, so the dependency check below cannot miss an in-flight retain.+ const [settings] = await tx+ .select({ tool: userSettings.tool })+ .from(userSettings)+ .where(eq(userSettings.id, this.userId))+ .limit(1)+ .for('update');+ const [dependent] = await tx+ .select({ id: agentInterventionResolutions.id })+ .from(agentInterventionResolutions)+ .where(+ and(+ eq(agentInterventionResolutions.userId, this.userId),+ eq(agentInterventionResolutions.rememberToolKey, resolution.rememberToolKey),+ ne(agentInterventionResolutions.id, resolution.id),+ inArray(agentInterventionResolutions.status, [+ 'resolving',+ 'published',+ 'acknowledged',+ 'completed',+ ]),+ ),+ )+ .limit(1);+ if (dependent) return 'retained';+ if (!settings) return 'rolled_back';+ const tool = asRecord(settings.tool);+ const humanIntervention = asRecord(tool.humanIntervention);+ const allowList = Array.isArray(humanIntervention.allowList)+ ? humanIntervention.allowList.filter((item): item is string => typeof item === 'string')+ : [];+ await tx+ .update(userSettings)+ .set({+ tool: {+ ...tool,+ humanIntervention: {+ ...humanIntervention,+ allowList: allowList.filter((item) => item !== resolution.rememberToolKey),+ },+ },+ })+ .where(eq(userSettings.id, this.userId));+ return 'rolled_back';+ };++ private retireResolvedRuntimeOperation = async (+ tx: Transaction,+ resolution: AgentInterventionResolutionItem,+ at: Date,+ ): Promise<void> => {+ if (resolution.action.type === 'stop' || resolution.action.type === 'cancel_interaction') {+ return;+ }+ const completedOperation = await tx+ .update(agentOperations)+ .set({ completedAt: at, completionReason: 'done', status: 'done' })+ .where(+ and(+ eq(agentOperations.id, resolution.operationId),+ eq(agentOperations.status, 'waiting_for_human'),+ eq(agentOperations.userId, this.userId),+ this.workspaceId+ ? eq(agentOperations.workspaceId, this.workspaceId)+ : isNull(agentOperations.workspaceId),+ ),+ )+ .returning({ id: agentOperations.id });+ if (completedOperation.length > 0) return;++ const [operation] = await tx+ .select({ status: agentOperations.status })+ .from(agentOperations)+ .where(+ and(+ eq(agentOperations.id, resolution.operationId),+ eq(agentOperations.userId, this.userId),+ this.workspaceId+ ? eq(agentOperations.workspaceId, this.workspaceId)+ : isNull(agentOperations.workspaceId),+ ),+ )+ .limit(1);+ if (operation?.status !== 'done') {+ throw new Error(AGENT_INTERVENTION_IDENTITY_CONFLICT);+ }+ };++ private completeResolution = async (+ resolutionRequestId: string,+ source: AgentInterventionSource,+ at: Date,+ ): Promise<AgentInterventionBatchMutationResult> =>+ this.transitionResolution(+ resolutionRequestId,+ async (tx, resolution, rows) => {+ if (resolution.source !== source) {+ throw new Error(AGENT_INTERVENTION_SOURCE_TRANSITION_MISMATCH);+ }+ const terminalResolutionStatus = source === 'runtime' ? 'completed' : 'acknowledged';+ if (resolution.status === terminalResolutionStatus) {+ if (source === 'runtime') {+ await this.retireResolvedRuntimeOperation(tx, resolution, at);+ }+ return { interventions: rows, outcome: 'idempotent', resolution };+ }+ if (resolution.status !== 'published') {+ return { interventions: rows, outcome: 'conflict', resolution };+ }+ const [updatedResolution] = await tx+ .update(agentInterventionResolutions)+ .set({+ continuationStartedAt: source === 'runtime' ? at : undefined,+ producerAckAt: source === 'heterogeneous' ? at : undefined,+ status: terminalResolutionStatus,+ terminalAt: at,+ updatedAt: at,+ version: sql`${agentInterventionResolutions.version} + 1`,+ })+ .where(eq(agentInterventionResolutions.id, resolution.id))+ .returning();+ const updatedRows = await tx+ .update(agentInterventions)+ .set({+ producerAckAt: source === 'heterogeneous' ? at : undefined,+ resolvedAt: at,+ status: terminalStatusForAction(resolution.action),+ updatedAt: at,+ version: sql`${agentInterventions.version} + 1`,+ })+ .where(+ and(+ eq(agentInterventions.resolutionId, resolution.id),+ eq(agentInterventions.status, 'published'),+ ),+ )+ .returning();+ if (source === 'runtime') {+ await this.retireResolvedRuntimeOperation(tx, resolution, at);+ }+ return { interventions: updatedRows, outcome: 'applied', resolution: updatedResolution };+ },+ { lockOperation: source === 'runtime' },+ );++ private transitionResolution = async (+ resolutionRequestId: string,+ transition: (+ tx: Transaction,+ resolution: AgentInterventionResolutionItem,+ rows: AgentInterventionItem[],+ ) => Promise<AgentInterventionBatchMutationResult>,+ options?: { lockOperation?: boolean },+ ): Promise<AgentInterventionBatchMutationResult> =>+ this.db.transaction(async (tx) => {+ const [candidate] = await tx+ .select({+ id: agentInterventionResolutions.id,+ operationId: agentInterventionResolutions.operationId,+ })+ .from(agentInterventionResolutions)+ .where(+ and(+ eq(agentInterventionResolutions.resolutionRequestId, resolutionRequestId),+ this.resolutionOwnership(),+ ),+ )+ .limit(1);+ if (!candidate) return { outcome: 'not_found' };++ if (options?.lockOperation) {+ const [operation] = await tx+ .select({ id: agentOperations.id })+ .from(agentOperations)+ .where(+ and(+ eq(agentOperations.id, candidate.operationId),+ eq(agentOperations.userId, this.userId),+ this.workspaceId+ ? eq(agentOperations.workspaceId, this.workspaceId)+ : isNull(agentOperations.workspaceId),+ ),+ )+ .limit(1)+ .for('update');+ if (!operation) return { outcome: 'not_found' };+ }++ // Batch terminal transitions lock intervention rows before their linked+ // resolutions. Preserve that order here to avoid timeout/ACK deadlocks.+ const rows = await tx+ .select()+ .from(agentInterventions)+ .where(eq(agentInterventions.resolutionId, candidate.id))+ .orderBy(asc(agentInterventions.itemIndex))+ .for('update');+ const [resolution] = await tx+ .select()+ .from(agentInterventionResolutions)+ .where(and(eq(agentInterventionResolutions.id, candidate.id), this.resolutionOwnership()))+ .limit(1)+ .for('update');+ if (!resolution) return { outcome: 'not_found' };+ return transition(tx, resolution, rows);+ });++ private resolveIdempotentClaim = async (+ resolution: AgentInterventionResolutionItem,+ params: ClaimAgentInterventionBatchParams,+ ): Promise<AgentInterventionBatchMutationResult> => {+ if (!this.isSameResolutionRequest(resolution, params)) {+ throw new Error(AGENT_INTERVENTION_RESOLUTION_REQUEST_REUSED);+ }+ if (resolution.status === 'rolled_back') {+ return this.reactivateRolledBackResolution(resolution.id, params);+ }+ const interventions = await this.db+ .select()+ .from(agentInterventions)+ .where(eq(agentInterventions.resolutionId, resolution.id))+ .orderBy(asc(agentInterventions.itemIndex));+ return { interventions, outcome: 'idempotent', resolution };+ };++ private isSameResolutionRequest = (+ resolution: AgentInterventionResolutionItem,+ params: ClaimAgentInterventionBatchParams,+ ): boolean =>+ resolution.operationId === params.operationId &&+ resolution.batchId === params.batchId &&+ resolution.actorId === params.actorId &&+ resolution.expectedItemCount === params.expectedItemCount &&+ resolution.scope === params.scope &&+ sameJson(resolution.selectedInterventionIds, uniqueSorted(params.selectedInterventionIds)) &&+ sameJson(resolution.expectedVersions, params.expectedVersions) &&+ sameJson(resolution.expectedRequestRevisionHashes, params.expectedRequestRevisionHashes) &&+ sameJson(resolution.action, params.action);++ /**+ * A transport failure rolls a claim back to pending but clients intentionally+ * retain the same resolutionRequestId: changing it after an ambiguous+ * response could execute the action twice. Reactivate that exact request only+ * while its complete original snapshot is still pending and unchanged. A new+ * winner, an argument edit, timeout, or any identity drift fails closed.+ */+ private reactivateRolledBackResolution = async (+ resolutionId: string,+ params: ClaimAgentInterventionBatchParams,+ ): Promise<AgentInterventionBatchMutationResult> =>+ this.db.transaction(async (tx) => {+ const rows = await tx+ .select()+ .from(agentInterventions)+ .where(+ and(+ eq(agentInterventions.operationId, params.operationId),+ eq(agentInterventions.batchId, params.batchId),+ this.ownership(),+ ),+ )+ .orderBy(asc(agentInterventions.itemIndex))+ .for('update');+ if (rows.length === 0) return { outcome: 'not_found' };++ const [resolution] = await tx+ .select()+ .from(agentInterventionResolutions)+ .where(and(eq(agentInterventionResolutions.id, resolutionId), this.resolutionOwnership()))+ .limit(1)+ .for('update');+ if (!resolution) return { outcome: 'not_found' };+ if (!this.isSameResolutionRequest(resolution, params)) {+ throw new Error(AGENT_INTERVENTION_RESOLUTION_REQUEST_REUSED);+ }++ // A concurrent retry may already have reactivated or completed this exact+ // request. Return its current linked rows instead of applying effects twice.+ if (resolution.status !== 'rolled_back') {+ return {+ interventions: rows.filter((row) => row.resolutionId === resolution.id),+ outcome: 'idempotent',+ resolution,+ };+ }++ const now = new Date();+ if (+ rows.some(+ (row) =>+ ['pending', 'resolving', 'published'].includes(row.status) &&+ row.deadline.getTime() <= now.getTime(),+ )+ ) {+ const terminalRows = await this.markRowsTerminalInTransaction(tx, rows, 'timed_out', now);+ return { interventions: terminalRows, outcome: 'conflict', resolution };+ }++ const ids = rows.map((row) => row.id);+ const unchangedSnapshot =+ rows.length === params.expectedItemCount &&+ rows.every(+ (row, index) =>+ row.sealed &&+ row.itemCount === rows.length &&+ row.itemIndex === index &&+ params.expectedRequestRevisionHashes[row.id] === row.requestRevisionHash,+ ) &&+ hasExactKeys(params.expectedVersions, ids) &&+ hasExactKeys(params.expectedRequestRevisionHashes, ids);+ if (!unchangedSnapshot) return { interventions: rows, outcome: 'conflict', resolution };++ const selectedIds = uniqueSorted(params.selectedInterventionIds);+ const targets = rows.filter((row) => selectedIds.includes(row.id));+ if (+ !this.hasValidSelection(rows, targets, params, selectedIds) ||+ targets.some((row) => row.status !== 'pending' || row.resolutionId !== null)+ ) {+ return { interventions: rows, outcome: 'conflict', resolution };+ }+ this.validateAction(targets, params);++ const argumentEffect = await this.applyArgumentEffect(tx, targets, params.action);+ let rememberToolKey: null | string = null;+ let rememberEffectStatus: 'applied' | 'retained' | null = null;+ if (params.action.type === 'approve_remember') {+ const remember = await this.applyRememberEffect(tx, params.actorId, targets[0]);+ rememberToolKey = remember.toolKey;+ rememberEffectStatus = remember.status;+ }++ const [reactivatedResolution] = await tx+ .update(agentInterventionResolutions)+ .set({+ argumentEffectStatus: argumentEffect ? 'applied' : null,+ continuationStartedAt: null,+ editedArguments: argumentEffect?.editedArguments ?? null,+ editedRequestRevisionHash: argumentEffect?.editedRequestRevisionHash ?? null,+ originalArguments: argumentEffect?.originalArguments ?? null,+ originalRequestRevisionHash: argumentEffect?.originalRequestRevisionHash ?? null,+ producerAckAt: null,+ publishedAt: null,+ rememberEffectStatus,+ rememberToolKey,+ resolvingAt: now,+ rolledBackAt: null,+ status: 'resolving',+ terminalAt: null,+ updatedAt: now,+ version: sql`${agentInterventionResolutions.version} + 1`,+ })+ .where(+ and(+ eq(agentInterventionResolutions.id, resolution.id),+ eq(agentInterventionResolutions.status, 'rolled_back'),+ ),+ )+ .returning();+ if (!reactivatedResolution) {+ throw new Error(AGENT_INTERVENTION_INVALID_BATCH);+ }++ const claimed = await tx+ .update(agentInterventions)+ .set({+ requestRevisionHash: argumentEffect?.editedRequestRevisionHash,+ resolutionId: resolution.id,+ resolvingAt: now,+ status: 'resolving',+ updatedAt: now,+ version: sql`${agentInterventions.version} + 1`,+ })+ .where(+ and(+ inArray(agentInterventions.id, selectedIds),+ this.ownership(),+ eq(agentInterventions.status, 'pending'),+ isNull(agentInterventions.resolutionId),+ gt(agentInterventions.deadline, now),+ ),+ )+ .returning();+ if (claimed.length !== selectedIds.length) {+ throw new Error(AGENT_INTERVENTION_INVALID_BATCH);+ }++ const updatedRows = rows.map((row) => claimed.find((item) => item.id === row.id) ?? row);+ return {+ interventions: updatedRows,+ outcome: 'applied',+ resolution: reactivatedResolution,+ };+ });++ private reload = async (id: string): Promise<AgentInterventionItem | undefined> => {+ const [row] = await this.db+ .select()+ .from(agentInterventions)+ .where(and(eq(agentInterventions.id, id), this.ownership()))+ .limit(1);+ return row;+ };++ private reloadBatch = (operationId: string, batchId: string): Promise<AgentInterventionItem[]> =>+ this.db+ .select()+ .from(agentInterventions)+ .where(+ and(+ eq(agentInterventions.operationId, operationId),+ eq(agentInterventions.batchId, batchId),+ this.ownership(),+ ),+ )+ .orderBy(asc(agentInterventions.itemIndex));++ private withLazyTimeout = async (+ row: AgentInterventionItem,+ now = new Date(),+ ): Promise<AgentInterventionItem> => {+ if (+ !['pending', 'resolving', 'published'].includes(row.status) ||+ row.deadline.getTime() > now.getTime()+ ) {+ return row;+ }+ await this.markBatchTerminal(row.operationId, row.batchId, 'timed_out', now);+ return (await this.reload(row.id)) ?? row;+ };++ /** Owner-only cold lookup can recover the row's workspace before expiring its batch. */+ private withOwnerLazyTimeout = async (+ row: AgentInterventionItem,+ now = new Date(),+ ): Promise<AgentInterventionItem> => {+ if (+ !['pending', 'resolving', 'published'].includes(row.status) ||+ row.deadline.getTime() > now.getTime()+ ) {+ return row;+ }+ const scopedModel = new AgentInterventionModel(+ this.db,+ this.userId,+ row.workspaceId ?? undefined,+ );+ await scopedModel.markBatchTerminal(row.operationId, row.batchId, 'timed_out', now);+ const [updated] = await this.db+ .select()+ .from(agentInterventions)+ .where(and(eq(agentInterventions.id, row.id), this.ownerOnly()))+ .limit(1);+ return updated ?? row;+ };+}diff --git a/packages/database/src/models/heterogeneousAgentIntervention.ts b/packages/database/src/models/heterogeneousAgentIntervention.tsnew file mode 100644index 00000000000..b32dcd0b957--- /dev/null+++ b/packages/database/src/models/heterogeneousAgentIntervention.ts@@ -0,0 +1,11 @@+/**+ * @deprecated Import from `agentIntervention`. The alias keeps v1 construction+ * working while Cloud migrates to the generic batch/outbox API.+ */+export {+ AGENT_INTERVENTION_IDENTITY_CONFLICT as HETERO_INTERVENTION_IDENTITY_CONFLICT,+ AGENT_INTERVENTION_INVALID_ACTION as HETERO_INTERVENTION_INVALID_PROVIDER_OPTIONS,+ AGENT_INTERVENTION_INVALID_REVIEW_TOKEN_HASH as HETERO_INTERVENTION_INVALID_REVIEW_TOKEN_HASH,+ AGENT_INTERVENTION_RESOLUTION_REQUEST_REUSED as HETERO_INTERVENTION_RESOLUTION_REQUEST_REUSED,+ AgentInterventionModel as HeterogeneousAgentInterventionModel,+} from './agentIntervention';diff --git a/packages/database/src/models/message.ts b/packages/database/src/models/message.tsindex 71581505250..425a9619f9a 100644--- a/packages/database/src/models/message.ts+++ b/packages/database/src/models/message.ts@@ -2709,15 +2709,17 @@ export class MessageModel {};updatePluginState = async (id: string, state: Record<string, any>): Promise<void> => {- const item = await this.db.query.messagePlugins.findFirst({- where: and(eq(messagePlugins.id, id), this.pluginsOwnership()),- });- if (!item) throw new Error('Plugin not found');-- await this.db+ const updated = await this.db.update(messagePlugins)- .set({ state: merge(item.state || {}, state) })- .where(and(eq(messagePlugins.id, id), this.pluginsOwnership()));+ .set({+ // Plugin-state patches own complete top-level keys. Merge them in SQL so+ // concurrent writers of different keys cannot overwrite each other.+ state: sql`coalesce(${messagePlugins.state}, '{}'::jsonb) || ${JSON.stringify(state)}::jsonb`,+ })+ .where(and(eq(messagePlugins.id, id), this.pluginsOwnership()))+ .returning({ id: messagePlugins.id });++ if (updated.length === 0) throw new Error('Plugin not found');};updateMessagePlugin = async (id: string, value: Partial<MessagePluginItem>) => {@@ -3135,34 +3137,32 @@ export class MessageModel {// Update messagePlugins table (pluginState, pluginError)if (pluginState !== undefined || pluginError !== undefined) {- const pluginItem = await trx.query.messagePlugins.findFirst({- where: and(eq(messagePlugins.id, id), this.pluginsOwnership()),- });-- // A plugin-only patch never touches `messages`, so the plugin row is- // the only evidence the tool message exists.- if (matchedRow === undefined) matchedRow = !!pluginItem;+ const pluginUpdateData: Record<string, any> = {};++ if (pluginState !== undefined) {+ // Snapshot writes replace the whole runtime state. Ordinary patches+ // own complete top-level keys and merge inside the UPDATE so an+ // answer write cannot race away an intervention-terminal write.+ pluginUpdateData.state = heterogeneousToolState+ ? pluginState+ : sql`coalesce(${messagePlugins.state}, '{}'::jsonb) || ${JSON.stringify(pluginState)}::jsonb`;+ }- if (pluginItem) {- const pluginUpdateData: Record<string, any> = {};+ if (pluginError !== undefined) {+ pluginUpdateData.error = pluginError;+ }- if (pluginState !== undefined) {- pluginUpdateData.state = heterogeneousToolState- ? pluginState- : merge(pluginItem.state || {}, pluginState);- }+ const [updatedPlugin] = await trx+ .update(messagePlugins)+ .set(pluginUpdateData)+ .where(and(eq(messagePlugins.id, id), this.pluginsOwnership()))+ .returning({ id: messagePlugins.id });- if (pluginError !== undefined) {- pluginUpdateData.error = pluginError;- }+ // A plugin-only patch never touches `messages`, so the plugin row is+ // the only evidence the tool message exists.+ if (matchedRow === undefined) matchedRow = !!updatedPlugin;- if (Object.keys(pluginUpdateData).length > 0) {- await trx- .update(messagePlugins)- .set(pluginUpdateData)- .where(and(eq(messagePlugins.id, id), this.pluginsOwnership()));- }- } else if (heterogeneousToolState) {+ if (!updatedPlugin && heterogeneousToolState) {throw new Error(`No tool plugin matched id ${id}`);}}diff --git a/packages/database/src/models/pushToken.ts b/packages/database/src/models/pushToken.tsindex 5d2b21d66e4..a00be403e64 100644--- a/packages/database/src/models/pushToken.ts+++ b/packages/database/src/models/pushToken.ts@@ -1,7 +1,13 @@+import type { ApnsEnvironment } from '@lobechat/types';import { and, eq, inArray } from 'drizzle-orm';-import type { NewPushToken, PushTokenItem } from '../schemas/pushToken';-import { pushTokens } from '../schemas/pushToken';+import type {+ NewPushLiveActivity,+ NewPushToken,+ PushLiveActivityItem,+ PushTokenItem,+} from '../schemas/pushToken';+import { pushLiveActivities, pushTokens } from '../schemas/pushToken';import type { LobeChatDatabase } from '../type';export class PushTokenModel {@@ -23,9 +29,11 @@ export class PushTokenModel {.values({ ...data, userId: this.userId }).onConflictDoUpdate({set: {+ apnsEnvironment: data.apnsEnvironment,appVersion: data.appVersion,expoToken: data.expoToken,lastSeenAt: new Date(),+ liveActivityPushToStartToken: data.liveActivityPushToStartToken,locale: data.locale,platform: data.platform,},@@ -36,6 +44,31 @@ export class PushTokenModel {return result;}+ /**+ * Attach or rotate ActivityKit's app-wide push-to-start registration for an+ * already registered device. The ordinary push-token route creates the row+ * first; returning undefined keeps a stale or foreign device fail-closed.+ */+ async updateLiveActivityRegistration(+ deviceId: string,+ data: {+ apnsEnvironment: ApnsEnvironment;+ liveActivityPushToStartToken: string;+ },+ ): Promise<PushTokenItem | undefined> {+ const [result] = await this.db+ .update(pushTokens)+ .set({+ apnsEnvironment: data.apnsEnvironment,+ lastSeenAt: new Date(),+ liveActivityPushToStartToken: data.liveActivityPushToStartToken,+ })+ .where(and(eq(pushTokens.userId, this.userId), eq(pushTokens.deviceId, deviceId)))+ .returning();++ return result;+ }+/** Delete this user's token for a specific device (e.g. on logout). */async unregister(deviceId: string) {return this.db@@ -49,6 +82,100 @@ export class PushTokenModel {}}+/** Owner-scoped ActivityKit update-token registry, correlated by opaque activity key. */+export class PushLiveActivityModel {+ private readonly userId: string;+ private readonly db: LobeChatDatabase;++ constructor(db: LobeChatDatabase, userId: string) {+ this.db = db;+ this.userId = userId;+ }++ /**+ * One device has one token for one durable activity key. Re-registration+ * refreshes the native ids/tokens without conflating another callback from+ * the same heterogeneous operation.+ */+ async upsert(data: Omit<NewPushLiveActivity, 'userId'>): Promise<PushLiveActivityItem> {+ const [result] = await this.db+ .insert(pushLiveActivities)+ .values({ ...data, userId: this.userId })+ .onConflictDoUpdate({+ set: {+ activityId: data.activityId,+ apnsEnvironment: data.apnsEnvironment,+ lastSeenAt: new Date(),+ operationId: data.operationId,+ pushToken: data.pushToken,+ },+ target: [+ pushLiveActivities.userId,+ pushLiveActivities.deviceId,+ pushLiveActivities.activityKey,+ ],+ })+ .returning();++ return result;+ }++ /** All device tokens for exactly one durable intervention/activity. */+ async listByActivityKey(activityKey: string): Promise<PushLiveActivityItem[]> {+ return this.db+ .select()+ .from(pushLiveActivities)+ .where(+ and(+ eq(pushLiveActivities.userId, this.userId),+ eq(pushLiveActivities.activityKey, activityKey),+ ),+ );+ }++ /** Remove one device registration, or every device registration for the activity. */+ async unregister(activityKey: string, deviceId?: string) {+ return this.db+ .delete(pushLiveActivities)+ .where(+ and(+ eq(pushLiveActivities.userId, this.userId),+ eq(pushLiveActivities.activityKey, activityKey),+ deviceId ? eq(pushLiveActivities.deviceId, deviceId) : undefined,+ ),+ );+ }++ /**+ * Remove exactly the registration that supplied a stale callback.+ *+ * The push-token predicate fences a concurrent ActivityKit token rotation:+ * a late cleanup for the previous token must not delete the newer row that+ * won the same (owner, device, activity) upsert identity.+ */+ async unregisterIfPushToken(activityKey: string, deviceId: string, pushToken: string) {+ return this.db+ .delete(pushLiveActivities)+ .where(+ and(+ eq(pushLiveActivities.userId, this.userId),+ eq(pushLiveActivities.activityKey, activityKey),+ eq(pushLiveActivities.deviceId, deviceId),+ eq(pushLiveActivities.pushToken, pushToken),+ ),+ );+ }++ /** Remove every stale activity registration for one owned device. */+ async unregisterDevice(deviceId: string) {+ return this.db+ .delete(pushLiveActivities)+ .where(+ and(eq(pushLiveActivities.userId, this.userId), eq(pushLiveActivities.deviceId, deviceId)),+ );+ }+}+/*** Static helper for the cloud-side receipt cleanup worker.* Not bound to a userId — operates across all users at once.@@ -66,12 +193,27 @@ export async function deletePushTokensByExpoTokens(* client clean up its own token without a session, by presenting the* (expoToken, deviceId) pair it received at registration. Both fields must* match so a stale row for a different device can't be deleted by accident.+ * Matching owner/device Live Activity registrations are removed atomically.*/export async function deletePushTokenByExpoTokenAndDevice(db: LobeChatDatabase,args: { deviceId: string; expoToken: string },): Promise<void> {- await db- .delete(pushTokens)- .where(and(eq(pushTokens.expoToken, args.expoToken), eq(pushTokens.deviceId, args.deviceId)));+ await db.transaction(async (tx) => {+ const deletedTokens = await tx+ .delete(pushTokens)+ .where(and(eq(pushTokens.expoToken, args.expoToken), eq(pushTokens.deviceId, args.deviceId)))+ .returning({ userId: pushTokens.userId });+ const userIds = [...new Set(deletedTokens.map(({ userId }) => userId))];+ if (userIds.length === 0) return;++ await tx+ .delete(pushLiveActivities)+ .where(+ and(+ inArray(pushLiveActivities.userId, userIds),+ eq(pushLiveActivities.deviceId, args.deviceId),+ ),+ );+ });}diff --git a/packages/database/src/schemas/agentIntervention.ts b/packages/database/src/schemas/agentIntervention.tsnew file mode 100644index 00000000000..8fcef5be571--- /dev/null+++ b/packages/database/src/schemas/agentIntervention.ts@@ -0,0 +1,292 @@+import type {+ AgentInterventionAllowedAction,+ AgentInterventionApprovalMode,+ AgentInterventionArgumentEffectStatus,+ AgentInterventionCustomExecutionResult,+ AgentInterventionCustomExecutionState,+ AgentInterventionExpectedRequestRevisionHashes,+ AgentInterventionExpectedVersions,+ AgentInterventionKind,+ AgentInterventionRememberEffectStatus,+ AgentInterventionResolutionAction,+ AgentInterventionResolutionScope,+ AgentInterventionResolutionStatus,+ AgentInterventionReviewContext,+ AgentInterventionRisk,+ AgentInterventionSanitizedRequest,+ AgentInterventionSource,+ AgentInterventionStatus,+ AgentInterventionSurface,+ AgentInterventionSystemActionEligibility,+} from '@lobechat/types';+import { sql } from 'drizzle-orm';+import {+ boolean,+ check,+ index,+ integer,+ jsonb,+ pgTable,+ text,+ uniqueIndex,+ uuid,+ varchar,+} from 'drizzle-orm/pg-core';++import { createdAt, timestamptz, updatedAt } from './_helpers';+import { agentOperations } from './agentOperations';+import { users } from './user';+import { workspaces } from './workspace';++/**+ * Private resolution/outbox records. Unlike `agent_interventions`, this table+ * may retain user-edited arguments so a claimed decision can be delivered+ * reliably after the app disconnects. It is never a notification payload.+ */+export const agentInterventionResolutions = pgTable(+ 'agent_intervention_resolutions',+ {+ id: uuid('id').defaultRandom().primaryKey().notNull(),+ resolutionRequestId: uuid('resolution_request_id').notNull(),++ operationId: text('operation_id')+ .references(() => agentOperations.id, { onDelete: 'cascade' })+ .notNull(),+ batchId: text('batch_id').notNull(),+ source: text('source').$type<AgentInterventionSource>().notNull(),++ /** Owner of the durable operation, distinct from the resolving actor. */+ userId: text('user_id')+ .references(() => users.id, { onDelete: 'cascade' })+ .notNull(),+ workspaceId: text('workspace_id').references(() => workspaces.id, {+ onDelete: 'cascade',+ }),+ /** Explicitly supplied by the ACL-gated service; never inferred from owner. */+ actorId: text('actor_id').notNull(),++ scope: text('scope').$type<AgentInterventionResolutionScope>().notNull(),+ selectedInterventionIds: jsonb('selected_intervention_ids').$type<string[]>().notNull(),+ expectedVersions: jsonb('expected_versions')+ .$type<AgentInterventionExpectedVersions>()+ .notNull(),+ expectedRequestRevisionHashes: jsonb('expected_request_revision_hashes')+ .$type<AgentInterventionExpectedRequestRevisionHashes>()+ .notNull(),+ expectedItemCount: integer('expected_item_count').notNull(),+ action: jsonb('action').$type<AgentInterventionResolutionAction>().notNull(),++ /** Private SHA-256 identity of the custom execution input. */+ customExecutionInputHash: varchar('custom_execution_input_hash', { length: 64 }),+ /** Independent from the resolution delivery/outbox lifecycle above. */+ customExecutionState:+ text('custom_execution_state').$type<AgentInterventionCustomExecutionState>(),+ /** Monotonic lease attempt, starting at zero while pending. */+ customExecutionAttempt: integer('custom_execution_attempt'),+ /** Opaque fencing token retained after completion for idempotent replay. */+ customExecutionLeaseToken: uuid('custom_execution_lease_token'),+ customExecutionLeaseExpiresAt: timestamptz('custom_execution_lease_expires_at'),+ /** Private executor result; never selected into Review or notification DTOs. */+ customExecutionResult:+ jsonb('custom_execution_result').$type<AgentInterventionCustomExecutionResult>(),++ rememberToolKey: text('remember_tool_key'),+ rememberEffectStatus:+ text('remember_effect_status').$type<AgentInterventionRememberEffectStatus>(),+ /** Private compare-and-swap journal for rollback of a user argument edit. */+ originalArguments: text('original_arguments'),+ editedArguments: text('edited_arguments'),+ originalRequestRevisionHash: text('original_request_revision_hash'),+ editedRequestRevisionHash: text('edited_request_revision_hash'),+ argumentEffectStatus:+ text('argument_effect_status').$type<AgentInterventionArgumentEffectStatus>(),++ status: text('status')+ .$type<AgentInterventionResolutionStatus>()+ .default('resolving')+ .notNull(),+ resolvingAt: timestamptz('resolving_at').defaultNow().notNull(),+ publishedAt: timestamptz('published_at'),+ continuationStartedAt: timestamptz('continuation_started_at'),+ producerAckAt: timestamptz('producer_ack_at'),+ terminalAt: timestamptz('terminal_at'),+ rolledBackAt: timestamptz('rolled_back_at'),++ version: integer('version').default(1).notNull(),+ createdAt: createdAt(),+ updatedAt: updatedAt(),+ },+ (table) => [+ uniqueIndex('agent_intervention_resolutions_request_unique').on(table.resolutionRequestId),+ index('agent_intervention_resolutions_owner_batch_idx').on(+ table.userId,+ table.workspaceId,+ table.batchId,+ ),+ index('agent_intervention_resolutions_status_created_idx').on(table.status, table.createdAt),+ check(+ 'agent_intervention_resolutions_expected_item_count_check',+ sql`${table.expectedItemCount} > 0`,+ ),+ check(+ 'agent_intervention_resolutions_custom_execution_input_hash_check',+ sql`${table.customExecutionInputHash} IS NULL OR ${table.customExecutionInputHash} ~ '^[a-f0-9]{64}$'`,+ ),+ check(+ 'agent_intervention_resolutions_custom_execution_state_check',+ sql`(+ (${table.customExecutionState} IS NULL+ AND ${table.customExecutionInputHash} IS NULL+ AND ${table.customExecutionAttempt} IS NULL+ AND ${table.customExecutionLeaseToken} IS NULL+ AND ${table.customExecutionLeaseExpiresAt} IS NULL+ AND ${table.customExecutionResult} IS NULL)+ OR+ (${table.customExecutionState} = 'pending'+ AND ${table.customExecutionAttempt} = 0+ AND ${table.customExecutionLeaseToken} IS NULL+ AND ${table.customExecutionLeaseExpiresAt} IS NULL+ AND ${table.customExecutionResult} IS NULL)+ OR+ (${table.customExecutionState} = 'executing'+ AND ${table.customExecutionInputHash} IS NOT NULL+ AND ${table.customExecutionAttempt} > 0+ AND ${table.customExecutionLeaseToken} IS NOT NULL+ AND ${table.customExecutionLeaseExpiresAt} IS NOT NULL+ AND ${table.customExecutionResult} IS NULL)+ OR+ (${table.customExecutionState} = 'completed'+ AND ${table.customExecutionInputHash} IS NOT NULL+ AND ${table.customExecutionAttempt} > 0+ AND ${table.customExecutionLeaseToken} IS NOT NULL+ AND ${table.customExecutionLeaseExpiresAt} IS NOT NULL+ AND ${table.customExecutionResult} IS NOT NULL)+ )`,+ ),+ check(+ 'agent_intervention_resolutions_custom_execution_parent_status_check',+ sql`${table.customExecutionState} NOT IN ('executing', 'completed') OR ${table.status} IN ('resolving', 'published', 'acknowledged', 'completed')`,+ ),+ check('agent_intervention_resolutions_version_check', sql`${table.version} > 0`),+ ],+);++/**+ * Notification-safe durable state for every pending intervention item. Raw+ * arguments are absent: authorized Review code loads the authoritative message+ * by `toolMessageId` and checks `requestRevisionHash` before mutation.+ */+export const agentInterventions = pgTable(+ 'agent_interventions',+ {+ id: uuid('id').defaultRandom().primaryKey().notNull(),++ operationId: text('operation_id')+ .references(() => agentOperations.id, { onDelete: 'cascade' })+ .notNull(),+ toolCallId: text('tool_call_id').notNull(),+ toolMessageId: text('tool_message_id'),++ userId: text('user_id')+ .references(() => users.id, { onDelete: 'cascade' })+ .notNull(),+ workspaceId: text('workspace_id').references(() => workspaces.id, {+ onDelete: 'cascade',+ }),++ source: text('source').$type<AgentInterventionSource>().notNull(),+ provider: text('provider'),+ interactionKind: text('interaction_kind').$type<AgentInterventionKind>().notNull(),+ surface: text('surface').$type<AgentInterventionSurface>().notNull(),+ systemActionEligibility: text('system_action_eligibility')+ .$type<AgentInterventionSystemActionEligibility>()+ .notNull(),+ approvalMode: text('approval_mode').$type<AgentInterventionApprovalMode>(),++ /** Stable grouping for exactly one paused step and its complete item set. */+ batchId: text('batch_id').notNull(),+ /** Opaque shared key used to correlate one Live Activity per batch. */+ activityKey: text('activity_key').notNull(),+ stepIndex: integer('step_index').notNull(),+ itemIndex: integer('item_index').notNull(),+ itemCount: integer('item_count').notNull(),+ sealed: boolean('sealed').default(false).notNull(),++ canonicalToolKey: text('canonical_tool_key'),+ requestRevisionHash: text('request_revision_hash').notNull(),+ allowedActions: jsonb('allowed_actions').$type<AgentInterventionAllowedAction[]>().notNull(),+ risk: jsonb('risk').$type<AgentInterventionRisk>(),++ /** SHA-256 hex digest of the raw locator; raw Review tokens are never stored. */+ reviewTokenHash: text('review_token_hash').notNull(),+ reviewContext: jsonb('review_context').$type<AgentInterventionReviewContext>().notNull(),+ sanitizedRequest: jsonb('sanitized_request')+ .$type<AgentInterventionSanitizedRequest>()+ .notNull(),++ deadline: timestamptz('deadline').notNull(),+ status: text('status').$type<AgentInterventionStatus>().default('pending').notNull(),+ resolutionId: uuid('resolution_id').references(() => agentInterventionResolutions.id, {+ onDelete: 'set null',+ }),+ resolvingAt: timestamptz('resolving_at'),+ publishedAt: timestamptz('published_at'),+ resolvedAt: timestamptz('resolved_at'),+ producerAckAt: timestamptz('producer_ack_at'),++ /** Incremented by every state transition for stale-snapshot detection. */+ version: integer('version').default(1).notNull(),+ createdAt: createdAt(),+ updatedAt: updatedAt(),+ },+ (table) => [+ uniqueIndex('agent_interventions_operation_tool_call_unique').on(+ table.operationId,+ table.toolCallId,+ ),+ uniqueIndex('agent_interventions_review_token_hash_unique').on(table.reviewTokenHash),+ uniqueIndex('agent_interventions_operation_batch_item_unique').on(+ table.operationId,+ table.batchId,+ table.itemIndex,+ ),+ uniqueIndex('agent_interventions_owner_activity_item_unique').on(+ table.userId,+ table.activityKey,+ table.itemIndex,+ ),+ index('agent_interventions_owner_status_deadline_idx').on(+ table.userId,+ table.workspaceId,+ table.status,+ table.deadline,+ ),+ index('agent_interventions_owner_batch_idx').on(+ table.userId,+ table.workspaceId,+ table.batchId,+ table.itemIndex,+ ),+ index('agent_interventions_activity_key_idx').on(table.userId, table.activityKey),+ index('agent_interventions_status_deadline_idx').on(table.status, table.deadline),+ check(+ 'agent_interventions_review_token_hash_check',+ sql`${table.reviewTokenHash} ~ '^[a-f0-9]{64}$'`,+ ),+ check(+ 'agent_interventions_request_revision_hash_check',+ sql`${table.requestRevisionHash} ~ '^[a-f0-9]{64}$'`,+ ),+ check('agent_interventions_step_index_check', sql`${table.stepIndex} >= 0`),+ check(+ 'agent_interventions_item_bounds_check',+ sql`${table.itemCount} > 0 AND ${table.itemIndex} >= 0 AND ${table.itemIndex} < ${table.itemCount}`,+ ),+ check('agent_interventions_version_check', sql`${table.version} > 0`),+ ],+);++export type NewAgentInterventionResolution = typeof agentInterventionResolutions.$inferInsert;+export type AgentInterventionResolutionItem = typeof agentInterventionResolutions.$inferSelect;+export type NewAgentIntervention = typeof agentInterventions.$inferInsert;+export type AgentInterventionItem = typeof agentInterventions.$inferSelect;diff --git a/packages/database/src/schemas/heterogeneousAgentIntervention.ts b/packages/database/src/schemas/heterogeneousAgentIntervention.tsnew file mode 100644index 00000000000..c1283d9f25d--- /dev/null+++ b/packages/database/src/schemas/heterogeneousAgentIntervention.ts@@ -0,0 +1,11 @@+import type { AgentInterventionItem, NewAgentIntervention } from './agentIntervention';+import { agentInterventions } from './agentIntervention';++/** @deprecated Use `agentInterventions`. Kept while v1 Cloud consumers migrate. */+export const heterogeneousAgentInterventions = agentInterventions;++/** @deprecated Use `NewAgentIntervention`. */+export type NewHeterogeneousAgentIntervention = NewAgentIntervention;++/** @deprecated Use `AgentInterventionItem`. */+export type HeterogeneousAgentInterventionItem = AgentInterventionItem;diff --git a/packages/database/src/schemas/index.ts b/packages/database/src/schemas/index.tsindex ace5fce6117..525e81e8728 100644--- a/packages/database/src/schemas/index.ts+++ b/packages/database/src/schemas/index.ts@@ -4,6 +4,7 @@ export * from './agentCronJob';export * from './agentDocuments';export * from './agentEvals';export * from './agentHistoryJob';+export * from './agentIntervention';export * from './agentLabel';export * from './agentOperations';export * from './agentQuota';diff --git a/packages/database/src/schemas/pushToken.ts b/packages/database/src/schemas/pushToken.tsindex 6ff7cfe035a..0855ed09b69 100644--- a/packages/database/src/schemas/pushToken.ts+++ b/packages/database/src/schemas/pushToken.ts@@ -1,4 +1,6 @@-import { index, pgTable, text, uniqueIndex, uuid } from 'drizzle-orm/pg-core';+import type { ApnsEnvironment } from '@lobechat/types';+import { sql } from 'drizzle-orm';+import { check, index, pgTable, text, uniqueIndex, uuid } from 'drizzle-orm/pg-core';import { createdAt, timestamptz } from './_helpers';import { users } from './user';@@ -31,9 +33,15 @@ export const pushTokens = pgTable(/** `ios` | `android` */platform: text('platform').notNull(),+ /** APNs environment used by native ActivityKit pushes. */+ apnsEnvironment: text('apns_environment').$type<ApnsEnvironment>(),+appVersion: text('app_version'),locale: text('locale'),+ /** App-wide ActivityKit token used to start a Live Activity remotely. */+ liveActivityPushToStartToken: text('live_activity_push_to_start_token'),+createdAt: createdAt(),lastSeenAt: timestamptz('last_seen_at').defaultNow().notNull(),},@@ -44,8 +52,54 @@ export const pushTokens = pgTable(index('idx_push_tokens_user').on(table.userId),/** Future: cleanup long-inactive tokens by lastSeenAt */index('idx_push_tokens_last_seen').on(table.lastSeenAt),+ check(+ 'push_tokens_apns_environment_check',+ sql`${table.apnsEnvironment} IS NULL OR ${table.apnsEnvironment} IN ('sandbox', 'production')`,+ ),],);export type NewPushToken = typeof pushTokens.$inferInsert;export type PushTokenItem = typeof pushTokens.$inferSelect;++/**+ * Per-activity ActivityKit update tokens. A user may have concurrent approval+ * activities and multiple iOS devices, so these cannot live as one column on+ * `push_tokens`.+ */+export const pushLiveActivities = pgTable(+ 'push_live_activities',+ {+ id: uuid('id').defaultRandom().primaryKey().notNull(),+ userId: text('user_id')+ .references(() => users.id, { onDelete: 'cascade' })+ .notNull(),+ deviceId: text('device_id').notNull(),+ /** Opaque durable key shared by one sealed intervention batch/activity. */+ activityKey: text('activity_key').notNull(),+ /** Diagnostic grouping only; never use it to update/end one activity. */+ operationId: text('operation_id').notNull(),+ activityId: text('activity_id').notNull(),+ pushToken: text('push_token').notNull(),+ apnsEnvironment: text('apns_environment').$type<ApnsEnvironment>().notNull(),+ createdAt: createdAt(),+ lastSeenAt: timestamptz('last_seen_at').defaultNow().notNull(),+ },+ (table) => [+ uniqueIndex('idx_push_live_activities_user_device_activity').on(+ table.userId,+ table.deviceId,+ table.activityKey,+ ),+ index('idx_push_live_activities_user_activity').on(table.userId, table.activityKey),+ index('idx_push_live_activities_user_operation').on(table.userId, table.operationId),+ index('idx_push_live_activities_last_seen').on(table.lastSeenAt),+ check(+ 'push_live_activities_apns_environment_check',+ sql`${table.apnsEnvironment} IN ('sandbox', 'production')`,+ ),+ ],+);++export type NewPushLiveActivity = typeof pushLiveActivities.$inferInsert;+export type PushLiveActivityItem = typeof pushLiveActivities.$inferSelect;diff --git a/packages/types/src/agent/agentIntervention.test.ts b/packages/types/src/agent/agentIntervention.test.tsnew file mode 100644index 00000000000..bb7645eb52a--- /dev/null+++ b/packages/types/src/agent/agentIntervention.test.ts@@ -0,0 +1,27 @@+import { describe, expect, expectTypeOf, it } from 'vitest';++import type {+ AgentInterventionCustomExecutionResult,+ AgentInterventionCustomExecutionState,+} from './agentIntervention';+import { AGENT_INTERVENTION_CUSTOM_EXECUTION_STATES } from './agentIntervention';++describe('agent intervention custom execution types', () => {+ it('keeps the execution state union aligned with its runtime literals', () => {+ expect(AGENT_INTERVENTION_CUSTOM_EXECUTION_STATES).toEqual([+ 'pending',+ 'executing',+ 'completed',+ ]);+ expectTypeOf<+ (typeof AGENT_INTERVENTION_CUSTOM_EXECUTION_STATES)[number]+ >().toEqualTypeOf<AgentInterventionCustomExecutionState>();+ });++ it('keeps the durable private result intentionally narrow', () => {+ expectTypeOf<AgentInterventionCustomExecutionResult>().toEqualTypeOf<{+ content: string;+ pluginState: Record<string, unknown>;+ }>();+ });+});diff --git a/packages/types/src/agent/agentIntervention.ts b/packages/types/src/agent/agentIntervention.tsnew file mode 100644index 00000000000..ae9f6e79776--- /dev/null+++ b/packages/types/src/agent/agentIntervention.ts@@ -0,0 +1,250 @@+/** Durable producer families which can pause an agent run for a person. */+export const AGENT_INTERVENTION_SOURCES = ['runtime', 'heterogeneous'] as const;++export type AgentInterventionSource = (typeof AGENT_INTERVENTION_SOURCES)[number];++/**+ * Semantic interaction kinds. `surface` separately describes whether the+ * client renders binary controls or a form.+ */+export const AGENT_INTERVENTION_KINDS = [+ 'tool_approval',+ 'custom',+ 'question',+ 'permission',+ 'plan',+] as const;++export type AgentInterventionKind = (typeof AGENT_INTERVENTION_KINDS)[number];++export const AGENT_INTERVENTION_SURFACES = ['binary', 'form'] as const;++export type AgentInterventionSurface = (typeof AGENT_INTERVENTION_SURFACES)[number];++export const AGENT_INTERVENTION_SYSTEM_ACTION_ELIGIBILITIES = [+ 'review_only',+ 'safe_single_binary',+] as const;++export type AgentInterventionSystemActionEligibility =+ (typeof AGENT_INTERVENTION_SYSTEM_ACTION_ELIGIBILITIES)[number];++/** Includes the server-only headless mode even though Web does not expose it. */+export const AGENT_INTERVENTION_APPROVAL_MODES = [+ 'auto-run',+ 'allow-list',+ 'manual',+ 'headless',+] as const;++export type AgentInterventionApprovalMode = (typeof AGENT_INTERVENTION_APPROVAL_MODES)[number];++/** Producer-supported actions; caller authorization is a separate concern. */+export const AGENT_INTERVENTION_ALLOWED_ACTIONS = [+ 'approve',+ 'approve_remember',+ 'reject_continue',+ 'stop',+ 'edit_arguments',+ 'select_provider_option',+ 'submit_answers',+ 'submit_custom',+ 'skip_interaction',+ 'cancel_interaction',+] as const;++export type AgentInterventionAllowedAction = (typeof AGENT_INTERVENTION_ALLOWED_ACTIONS)[number];++export const AGENT_INTERVENTION_STATUSES = [+ 'pending',+ 'resolving',+ 'published',+ 'resolved',+ 'cancelled',+ 'timed_out',+ 'session_ended',+] as const;++export type AgentInterventionStatus = (typeof AGENT_INTERVENTION_STATUSES)[number];++export const AGENT_INTERVENTION_RESOLUTION_SCOPES = ['single', 'selected', 'all'] as const;++export type AgentInterventionResolutionScope =+ (typeof AGENT_INTERVENTION_RESOLUTION_SCOPES)[number];++export const AGENT_INTERVENTION_RESOLUTION_STATUSES = [+ 'resolving',+ 'published',+ 'acknowledged',+ 'completed',+ 'rolled_back',+ 'timed_out',+ 'session_ended',+] as const;++export type AgentInterventionResolutionStatus =+ (typeof AGENT_INTERVENTION_RESOLUTION_STATUSES)[number];++/** Private execution lifecycle for custom intervention side effects. */+export const AGENT_INTERVENTION_CUSTOM_EXECUTION_STATES = [+ 'pending',+ 'executing',+ 'completed',+] as const;++export type AgentInterventionCustomExecutionState =+ (typeof AGENT_INTERVENTION_CUSTOM_EXECUTION_STATES)[number];++/** Durable private result replayed to the custom-intervention executor only. */+export interface AgentInterventionCustomExecutionResult {+ content: string;+ pluginState: Record<string, unknown>;+}++export const AGENT_INTERVENTION_REMEMBER_EFFECT_STATUSES = [+ 'applied',+ 'retained',+ 'rolled_back',+] as const;++export type AgentInterventionRememberEffectStatus =+ (typeof AGENT_INTERVENTION_REMEMBER_EFFECT_STATUSES)[number];++export const AGENT_INTERVENTION_ARGUMENT_EFFECT_STATUSES = [+ 'applied',+ 'retained',+ 'rolled_back',+] as const;++export type AgentInterventionArgumentEffectStatus =+ (typeof AGENT_INTERVENTION_ARGUMENT_EFFECT_STATUSES)[number];++export const AGENT_INTERVENTION_RISK_LEVELS = ['low', 'medium', 'high', 'critical'] as const;++export type AgentInterventionRiskLevel = (typeof AGENT_INTERVENTION_RISK_LEVELS)[number];++/** Notification-safe risk summary. It must not contain raw tool arguments. */+export interface AgentInterventionRisk {+ level: AgentInterventionRiskLevel;+ summary?: string;+ warnings?: string[];+}++/** A producer-provided choice after sensitive arguments have been removed. */+export interface AgentInterventionOption {+ description?: string;+ id?: string;+ label: string;+ recommended?: boolean;+}++/** One structured question preserved for cold-start Review rendering. */+export interface AgentInterventionQuestion {+ allowCustomAnswer?: boolean;+ header?: string;+ id?: string;+ multiSelect?: boolean;+ options: AgentInterventionOption[];+ question: string;+}++export interface AgentInterventionAnswerPolicy {+ allowFreeform?: boolean;+ allowSupplement?: boolean;+}++export type AgentInterventionFormFieldType =+ 'boolean' | 'multi_select' | 'number' | 'single_select' | 'text';++/** Sanitized custom-form metadata. Answers live only in the resolution outbox. */+export interface AgentInterventionFormField {+ description?: string;+ id: string;+ label: string;+ options?: AgentInterventionOption[];+ required?: boolean;+ type: AgentInterventionFormFieldType;+}++export interface AgentMarketplaceInterventionAgent {+ avatar?: string;+ description?: string;+ id: string;+ title: string;+}++/** Notification-safe detail needed to reconstruct the Web marketplace picker. */+export interface AgentMarketplaceInterventionDetail {+ agents: AgentMarketplaceInterventionAgent[];+ categoryHints?: string[];+ kind: 'agent_marketplace';+ requestId?: string;+ selectedIds?: string[];+}++export type AgentInterventionCustomDetail = AgentMarketplaceInterventionDetail;++/**+ * Durable render metadata. Raw arguments deliberately do not belong here: an+ * authorized Review service loads them from the authoritative tool message by+ * `toolMessageId`, then verifies `requestRevisionHash` before mutation.+ */+export interface AgentInterventionSanitizedRequest {+ answerPolicy?: AgentInterventionAnswerPolicy;+ apiName: string;+ argumentCount?: number;+ customDetail?: AgentInterventionCustomDetail;+ fields?: AgentInterventionFormField[];+ identifier?: string;+ options?: AgentInterventionOption[];+ parameterNames?: string[];+ prompt?: string;+ questions?: AgentInterventionQuestion[];+}++/** Short copy safe to place on notification and Live Activity surfaces. */+export interface AgentInterventionReviewContext {+ agentLabel?: string;+ resourceLabel?: string;+ summary?: string;+ title: string;+}++export type AgentInterventionFormValue = boolean | number | string | string[] | null;++export type AgentInterventionFormAnswers = Record<string, AgentInterventionFormValue>;++/** Schema-validated, deliberately shallow result accepted from bespoke forms. */+export type AgentInterventionCustomResult = Record<string, AgentInterventionFormValue>;++/**+ * Discriminated private outbox payload. Only user-edited arguments may be+ * retained here for reliable delivery; original raw arguments never enter the+ * notification-facing intervention row.+ */+export type AgentInterventionResolutionAction =+ | {+ editedArguments?: Record<string, unknown>;+ type: 'approve';+ }+ | {+ editedArguments?: Record<string, unknown>;+ type: 'approve_remember';+ }+ | { reason?: string; type: 'reject_continue' }+ | { haltScope: 'operation'; reason?: string; type: 'stop' }+ | { optionId: string; type: 'select_provider_option' }+ | { answers: AgentInterventionFormAnswers; type: 'submit_answers' }+ | {+ expectedRevisionHash: string;+ result: AgentInterventionCustomResult;+ type: 'submit_custom';+ }+ | { type: 'skip_interaction' }+ | { type: 'cancel_interaction' };++/** Versions from the exact Review snapshot used to make a batch decision. */+export type AgentInterventionExpectedVersions = Record<string, number>;++/** Revision hashes for every member of the sealed batch Review snapshot. */+export type AgentInterventionExpectedRequestRevisionHashes = Record<string, string>;diff --git a/packages/types/src/agent/heterogeneousIntervention.ts b/packages/types/src/agent/heterogeneousIntervention.tsnew file mode 100644index 00000000000..169875b2056--- /dev/null+++ b/packages/types/src/agent/heterogeneousIntervention.ts@@ -0,0 +1,74 @@+export const HETEROGENEOUS_AGENT_INTERVENTION_KINDS = ['permission', 'plan', 'question'] as const;++export type HeterogeneousAgentInterventionKind =+ (typeof HETEROGENEOUS_AGENT_INTERVENTION_KINDS)[number];++export const HETEROGENEOUS_AGENT_INTERVENTION_PROVIDERS = [+ 'claude-code',+ 'cursor',+ 'qoder',+] as const;++export type HeterogeneousAgentInterventionProvider =+ (typeof HETEROGENEOUS_AGENT_INTERVENTION_PROVIDERS)[number];++export const HETEROGENEOUS_AGENT_INTERVENTION_STATUSES = [+ 'pending',+ 'resolving',+ 'resolved',+ 'cancelled',+ 'timed_out',+ 'session_ended',+] as const;++export type HeterogeneousAgentInterventionStatus =+ (typeof HETEROGENEOUS_AGENT_INTERVENTION_STATUSES)[number];++/** A producer-provided choice after sensitive arguments have been removed. */+export interface HeterogeneousAgentInterventionOption {+ description?: string;+ /** Required for permission/plan; question providers may only supply labels. */+ id?: string;+ label: string;+ recommended?: boolean;+}++/** One structured-input question preserved for cold-start Review rendering. */+export interface HeterogeneousAgentInterventionQuestion {+ header?: string;+ id?: string;+ multiSelect?: boolean;+ options: HeterogeneousAgentInterventionOption[];+ question: string;+}++/**+ * Durable, renderable request contract. This deliberately has no open-ended+ * metadata/arguments bag: persistence callers must copy only fields that are+ * safe and necessary for Review while retaining exact provider option ids.+ */+export interface HeterogeneousAgentInterventionSanitizedRequest {+ apiName: string;+ identifier?: string;+ options?: HeterogeneousAgentInterventionOption[];+ prompt?: string;+ questions?: HeterogeneousAgentInterventionQuestion[];+}++/** Short copy safe to place on notification and Live Activity surfaces. */+export interface HeterogeneousAgentInterventionReviewContext {+ agentLabel?: string;+ resourceLabel?: string;+ summary?: string;+ title: string;+}++/** User response routed back to the exact blocked producer callback. */+export type HeterogeneousAgentInterventionResult = Record<string, string | string[]>;++export interface HeterogeneousAgentInterventionResolutionPayload {+ cancelled?: boolean;+ cancelReason?: 'session_ended' | 'timeout' | 'user_cancelled';+ /** Question text (or a reserved form key) to freeform text or exact option values. */+ result?: HeterogeneousAgentInterventionResult;+}diff --git a/packages/types/src/agent/index.ts b/packages/types/src/agent/index.tsindex a5bdc217efe..dc51f28ebb1 100644--- a/packages/types/src/agent/index.ts+++ b/packages/types/src/agent/index.ts@@ -1,11 +1,13 @@export * from './agencyConfig';export * from './agentConfig';+export * from './agentIntervention';export * from './chatConfig';export * from './displayName';export * from './document';export * from './graph';export * from './heteroCliArgs';export * from './heterogeneousAgent';+export * from './heterogeneousIntervention';export * from './heteroSelectorCapabilities';export * from './item';export * from './modelSelection';diff --git a/packages/types/src/notification.ts b/packages/types/src/notification.tsindex 7a1f1bb8c56..acafa448658 100644--- a/packages/types/src/notification.ts+++ b/packages/types/src/notification.ts@@ -1,3 +1,6 @@+/** APNs gateway selected by the signing profile that produced a native token. */+export type ApnsEnvironment = 'production' | 'sandbox';+/*** The person who triggered a user-driven notification (member joined,* invitation, comment activity). Snapshotted at send time so inbox surfaces