Skip to content

🤯 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.

🗃️ feat(database): add inbound webhook persistence (#22990)

Bryana7527870b9e2
diff --git a/docs/development/database-schema.dbml b/docs/development/database-schema.dbml
index ad396aa7eae..436c692a4a6 100644
--- a/docs/development/database-schema.dbml
+++ b/docs/development/database-schema.dbml
@@ -2768,6 +2768,43 @@ table goal_traces {
}
}
+table inbound_webhooks {
+ id uuid [pk, not null, default: `gen_random_uuid()`]
+ user_id text [not null]
+ workspace_id text
+ kind text [not null]
+ name text
+ status text [not null, default: 'pending']
+ agent_id text [not null]
+ topic_id text
+ instructions text
+ secret text
+ verification jsonb [not null]
+ config jsonb [not null]
+ state jsonb [not null, default: `{}`]
+ connector_id uuid
+ dedupe_key text
+ next_maintenance_at "timestamp with time zone"
+ maintenance_failures integer [not null, default: 0]
+ last_delivery_at "timestamp with time zone"
+ last_error text
+ wake_count integer [not null, default: 0]
+ wake_window_started_at "timestamp with time zone" [not null, default: `now()`]
+ accessed_at "timestamp with time zone" [not null, default: `now()`]
+ created_at "timestamp with time zone" [not null, default: `now()`]
+ updated_at "timestamp with time zone" [not null, default: `now()`]
+
+ indexes {
+ (user_id, kind, dedupe_key) [name: 'inbound_webhooks_user_kind_dedupe_unique', unique]
+ next_maintenance_at [name: 'inbound_webhooks_next_maintenance_idx']
+ user_id [name: 'inbound_webhooks_user_idx']
+ workspace_id [name: 'inbound_webhooks_workspace_idx']
+ topic_id [name: 'inbound_webhooks_topic_idx']
+ agent_id [name: 'inbound_webhooks_agent_idx']
+ connector_id [name: 'inbound_webhooks_connector_idx']
+ }
+}
+
table linear_connections {
id uuid [pk, not null, default: `gen_random_uuid()`]
user_id text [not null]
diff --git a/packages/database/migrations/0216_inbound_webhooks.sql b/packages/database/migrations/0216_inbound_webhooks.sql
new file mode 100644
index 00000000000..d5576bc6651
--- /dev/null
+++ b/packages/database/migrations/0216_inbound_webhooks.sql
@@ -0,0 +1,49 @@
+CREATE TABLE IF NOT EXISTS "inbound_webhooks" (
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
+ "user_id" text NOT NULL,
+ "workspace_id" text,
+ "kind" text NOT NULL,
+ "name" text,
+ "status" text DEFAULT 'pending' NOT NULL,
+ "agent_id" text NOT NULL,
+ "topic_id" text,
+ "instructions" text,
+ "secret" text,
+ "verification" jsonb NOT NULL,
+ "config" jsonb NOT NULL,
+ "state" jsonb DEFAULT '{}'::jsonb NOT NULL,
+ "connector_id" uuid,
+ "dedupe_key" text,
+ "next_maintenance_at" timestamp with time zone,
+ "maintenance_failures" integer DEFAULT 0 NOT NULL,
+ "last_delivery_at" timestamp with time zone,
+ "last_error" text,
+ "wake_count" integer DEFAULT 0 NOT NULL,
+ "wake_window_started_at" timestamp with time zone DEFAULT now() NOT NULL,
+ "accessed_at" timestamp with time zone DEFAULT now() NOT NULL,
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
+);
+--> statement-breakpoint
+ALTER TABLE "inbound_webhooks" DROP CONSTRAINT IF EXISTS "inbound_webhooks_user_id_users_id_fk";
+--> statement-breakpoint
+ALTER TABLE "inbound_webhooks" ADD CONSTRAINT "inbound_webhooks_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "inbound_webhooks" DROP CONSTRAINT IF EXISTS "inbound_webhooks_workspace_id_workspaces_id_fk";
+--> statement-breakpoint
+ALTER TABLE "inbound_webhooks" ADD CONSTRAINT "inbound_webhooks_workspace_id_workspaces_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."workspaces"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "inbound_webhooks" DROP CONSTRAINT IF EXISTS "inbound_webhooks_agent_id_agents_id_fk";
+--> statement-breakpoint
+ALTER TABLE "inbound_webhooks" ADD CONSTRAINT "inbound_webhooks_agent_id_agents_id_fk" FOREIGN KEY ("agent_id") REFERENCES "public"."agents"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "inbound_webhooks" DROP CONSTRAINT IF EXISTS "inbound_webhooks_topic_id_topics_id_fk";
+--> statement-breakpoint
+ALTER TABLE "inbound_webhooks" ADD CONSTRAINT "inbound_webhooks_topic_id_topics_id_fk" FOREIGN KEY ("topic_id") REFERENCES "public"."topics"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "inbound_webhooks" DROP CONSTRAINT IF EXISTS "inbound_webhooks_connector_id_user_connectors_id_fk";
+--> statement-breakpoint
+ALTER TABLE "inbound_webhooks" ADD CONSTRAINT "inbound_webhooks_connector_id_user_connectors_id_fk" FOREIGN KEY ("connector_id") REFERENCES "public"."user_connectors"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+CREATE UNIQUE INDEX IF NOT EXISTS "inbound_webhooks_user_kind_dedupe_unique" ON "inbound_webhooks" USING btree ("user_id","kind","dedupe_key") WHERE "inbound_webhooks"."dedupe_key" IS NOT NULL;--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "inbound_webhooks_next_maintenance_idx" ON "inbound_webhooks" USING btree ("next_maintenance_at") WHERE "inbound_webhooks"."next_maintenance_at" IS NOT NULL;--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "inbound_webhooks_user_idx" ON "inbound_webhooks" USING btree ("user_id");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "inbound_webhooks_workspace_idx" ON "inbound_webhooks" USING btree ("workspace_id");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "inbound_webhooks_topic_idx" ON "inbound_webhooks" USING btree ("topic_id");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "inbound_webhooks_agent_idx" ON "inbound_webhooks" USING btree ("agent_id");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "inbound_webhooks_connector_idx" ON "inbound_webhooks" USING btree ("connector_id");
\ No newline at end of file
diff --git a/packages/database/migrations/meta/0206_snapshot.json b/packages/database/migrations/meta/0216_snapshot.json
similarity index 95%
rename from packages/database/migrations/meta/0206_snapshot.json
rename to packages/database/migrations/meta/0216_snapshot.json
index eb96b7095cd..4dc75ba117f 100644
--- a/packages/database/migrations/meta/0206_snapshot.json
+++ b/packages/database/migrations/meta/0216_snapshot.json
@@ -6,9 +6,9 @@
},
"dialect": "postgresql",
"enums": {},
- "id": "63465691-3d9e-4f5e-b5fe-543adf2bd840",
+ "id": "7c29d9b7-1cda-4670-a1a0-27ecc5cf0017",
"policies": {},
- "prevId": "62c4182f-5344-4639-b52c-21d0b1e61ea1",
+ "prevId": "7cbe8fa4-a70b-4460-89b2-8ba138152fc6",
"roles": {},
"schemas": {},
"sequences": {
@@ -132,6 +132,12 @@
"primaryKey": false,
"notNull": false
},
+ "review_mark_id": {
+ "name": "review_mark_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
"client_id": {
"name": "client_id",
"type": "text",
@@ -300,6 +306,21 @@
"concurrently": false,
"method": "btree",
"with": {}
+ },
+ "acceptance_comments_review_mark_id_idx": {
+ "name": "acceptance_comments_review_mark_id_idx",
+ "columns": [
+ {
+ "expression": "review_mark_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
}
},
"foreignKeys": {
@@ -366,6 +387,15 @@
"onDelete": "set null",
"onUpdate": "no action"
},
+ "acceptance_comments_review_mark_id_acceptance_review_marks_id_fk": {
+ "name": "acceptance_comments_review_mark_id_acceptance_review_marks_id_fk",
+ "tableFrom": "acceptance_comments",
+ "tableTo": "acceptance_review_marks",
+ "columnsFrom": ["review_mark_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
"acceptance_comments_resolved_by_user_id_users_id_fk": {
"name": "acceptance_comments_resolved_by_user_id_users_id_fk",
"tableFrom": "acceptance_comments",
@@ -741,6 +771,450 @@
"checkConstraints": {},
"isRLSEnabled": false
},
+ "public.acceptance_review_marks": {
+ "name": "acceptance_review_marks",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "review_id": {
+ "name": "review_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "seq": {
+ "name": "seq",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "route_key": {
+ "name": "route_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "page_meta": {
+ "name": "page_meta",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rect_document": {
+ "name": "rect_document",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "rect_viewport": {
+ "name": "rect_viewport",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scroll": {
+ "name": "scroll",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "viewport": {
+ "name": "viewport",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "regions": {
+ "name": "regions",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "region_refs": {
+ "name": "region_refs",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "targets": {
+ "name": "targets",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sketch": {
+ "name": "sketch",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "context": {
+ "name": "context",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "screenshot_file_id": {
+ "name": "screenshot_file_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "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": {
+ "acceptance_review_marks_review_id_client_id_unique": {
+ "name": "acceptance_review_marks_review_id_client_id_unique",
+ "columns": [
+ {
+ "expression": "review_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "acceptance_review_marks_review_id_seq_unique": {
+ "name": "acceptance_review_marks_review_id_seq_unique",
+ "columns": [
+ {
+ "expression": "review_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "seq",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "acceptance_review_marks_route_key_review_id_idx": {
+ "name": "acceptance_review_marks_route_key_review_id_idx",
+ "columns": [
+ {
+ "expression": "route_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "review_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "acceptance_review_marks_review_id_acceptance_reviews_id_fk": {
+ "name": "acceptance_review_marks_review_id_acceptance_reviews_id_fk",
+ "tableFrom": "acceptance_review_marks",
+ "tableTo": "acceptance_reviews",
+ "columnsFrom": ["review_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "acceptance_review_marks_screenshot_file_id_files_id_fk": {
+ "name": "acceptance_review_marks_screenshot_file_id_files_id_fk",
+ "tableFrom": "acceptance_review_marks",
+ "tableTo": "files",
+ "columnsFrom": ["screenshot_file_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.acceptance_reviews": {
+ "name": "acceptance_reviews",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "site_id": {
+ "name": "site_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
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'draft'"
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_mark_seq": {
+ "name": "last_mark_seq",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "submitted_at": {
+ "name": "submitted_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": {
+ "acceptance_reviews_site_id_created_at_idx": {
+ "name": "acceptance_reviews_site_id_created_at_idx",
+ "columns": [
+ {
+ "expression": "site_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "acceptance_reviews_task_id_idx": {
+ "name": "acceptance_reviews_task_id_idx",
+ "columns": [
+ {
+ "expression": "task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "acceptance_reviews_user_id_idx": {
+ "name": "acceptance_reviews_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "acceptance_reviews_workspace_id_idx": {
+ "name": "acceptance_reviews_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "acceptance_reviews_one_draft_per_user_unique": {
+ "name": "acceptance_reviews_one_draft_per_user_unique",
+ "columns": [
+ {
+ "expression": "site_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"acceptance_reviews\".\"status\" = 'draft'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "acceptance_reviews_site_id_project_sites_id_fk": {
+ "name": "acceptance_reviews_site_id_project_sites_id_fk",
+ "tableFrom": "acceptance_reviews",
+ "tableTo": "project_sites",
+ "columnsFrom": ["site_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "acceptance_reviews_user_id_users_id_fk": {
+ "name": "acceptance_reviews_user_id_users_id_fk",
+ "tableFrom": "acceptance_reviews",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "acceptance_reviews_workspace_id_workspaces_id_fk": {
+ "name": "acceptance_reviews_workspace_id_workspaces_id_fk",
+ "tableFrom": "acceptance_reviews",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "acceptance_reviews_project_id_projects_id_fk": {
+ "name": "acceptance_reviews_project_id_projects_id_fk",
+ "tableFrom": "acceptance_reviews",
+ "tableTo": "projects",
+ "columnsFrom": ["project_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "acceptance_reviews_task_id_tasks_id_fk": {
+ "name": "acceptance_reviews_task_id_tasks_id_fk",
+ "tableFrom": "acceptance_reviews",
+ "tableTo": "tasks",
+ "columnsFrom": ["task_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
"public.agents": {
"name": "agents",
"schema": "",
@@ -1610,6 +2084,13 @@
"notNull": false,
"default": "'{}'::jsonb"
},
+ "settings": {
+ "name": "settings",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
"revoked_at": {
"name": "revoked_at",
"type": "timestamp with time zone",
@@ -5354,6 +5835,21 @@
"method": "btree",
"with": {}
},
+ "agent_inbox_messages_topic_id_idx": {
+ "name": "agent_inbox_messages_topic_id_idx",
+ "columns": [
+ {
+ "expression": "topic_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
"agent_inbox_messages_user_id_idx": {
"name": "agent_inbox_messages_user_id_idx",
"columns": [
@@ -7361,6 +7857,27 @@
"method": "btree",
"with": {}
},
+ "agent_operations_workspace_id_created_at_idx": {
+ "name": "agent_operations_workspace_id_created_at_idx",
+ "columns": [
+ {
+ "expression": "workspace_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": [
@@ -12587,6 +13104,12 @@
"primaryKey": false,
"notNull": false
},
+ "peer_user_id": {
+ "name": "peer_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
"title": {
"name": "title",
"type": "text",
@@ -12772,6 +13295,15 @@
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
+ },
+ "channels_peer_user_id_users_id_fk": {
+ "name": "channels_peer_user_id_users_id_fk",
+ "tableFrom": "channels",
+ "tableTo": "users",
+ "columnsFrom": ["peer_user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
@@ -13526,6 +14058,13 @@
"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",
@@ -13839,8 +14378,8 @@
"checkConstraints": {},
"isRLSEnabled": false
},
- "public.dashboard_items": {
- "name": "dashboard_items",
+ "public.user_contact_requests": {
+ "name": "user_contact_requests",
"schema": "",
"columns": {
"id": {
@@ -13850,42 +14389,36 @@
"notNull": true,
"default": "gen_random_uuid()"
},
- "dashboard_id": {
- "name": "dashboard_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": true
- },
- "widget_id": {
- "name": "widget_id",
- "type": "uuid",
+ "requester_id": {
+ "name": "requester_id",
+ "type": "text",
"primaryKey": false,
"notNull": true
},
- "user_id": {
- "name": "user_id",
+ "addressee_id": {
+ "name": "addressee_id",
"type": "text",
"primaryKey": false,
"notNull": true
},
- "workspace_id": {
- "name": "workspace_id",
+ "message": {
+ "name": "message",
"type": "text",
"primaryKey": false,
"notNull": false
},
- "layout": {
- "name": "layout",
- "type": "jsonb",
+ "status": {
+ "name": "status",
+ "type": "text",
"primaryKey": false,
- "notNull": false
+ "notNull": true,
+ "default": "'pending'"
},
- "sort_order": {
- "name": "sort_order",
- "type": "integer",
+ "responded_at": {
+ "name": "responded_at",
+ "type": "timestamp with time zone",
"primaryKey": false,
- "notNull": true,
- "default": 0
+ "notNull": false
},
"accessed_at": {
"name": "accessed_at",
@@ -13910,38 +14443,39 @@
}
},
"indexes": {
- "dashboard_items_dashboard_id_widget_id_unique": {
- "name": "dashboard_items_dashboard_id_widget_id_unique",
+ "user_contact_requests_pending_unique": {
+ "name": "user_contact_requests_pending_unique",
"columns": [
{
- "expression": "dashboard_id",
+ "expression": "requester_id",
"isExpression": false,
"asc": true,
"nulls": "last"
},
{
- "expression": "widget_id",
+ "expression": "addressee_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": true,
+ "where": "\"user_contact_requests\".\"status\" = 'pending'",
"concurrently": false,
"method": "btree",
"with": {}
},
- "dashboard_items_dashboard_id_sort_order_idx": {
- "name": "dashboard_items_dashboard_id_sort_order_idx",
+ "user_contact_requests_addressee_status_idx": {
+ "name": "user_contact_requests_addressee_status_idx",
"columns": [
{
- "expression": "dashboard_id",
+ "expression": "addressee_id",
"isExpression": false,
"asc": true,
"nulls": "last"
},
{
- "expression": "sort_order",
+ "expression": "status",
"isExpression": false,
"asc": true,
"nulls": "last"
@@ -13952,11 +14486,17 @@
"method": "btree",
"with": {}
},
- "dashboard_items_widget_id_idx": {
- "name": "dashboard_items_widget_id_idx",
+ "user_contact_requests_requester_status_idx": {
+ "name": "user_contact_requests_requester_status_idx",
"columns": [
{
- "expression": "widget_id",
+ "expression": "requester_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
"isExpression": false,
"asc": true,
"nulls": "last"
@@ -13966,12 +14506,117 @@
"concurrently": false,
"method": "btree",
"with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_contact_requests_requester_id_users_id_fk": {
+ "name": "user_contact_requests_requester_id_users_id_fk",
+ "tableFrom": "user_contact_requests",
+ "tableTo": "users",
+ "columnsFrom": ["requester_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
},
- "dashboard_items_user_id_idx": {
- "name": "dashboard_items_user_id_idx",
+ "user_contact_requests_addressee_id_users_id_fk": {
+ "name": "user_contact_requests_addressee_id_users_id_fk",
+ "tableFrom": "user_contact_requests",
+ "tableTo": "users",
+ "columnsFrom": ["addressee_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "user_contact_requests_not_self_check": {
+ "name": "user_contact_requests_not_self_check",
+ "value": "\"user_contact_requests\".\"requester_id\" <> \"user_contact_requests\".\"addressee_id\""
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.user_contact_tag_assignments": {
+ "name": "user_contact_tag_assignments",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "tag_id": {
+ "name": "tag_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "contact_id": {
+ "name": "contact_id",
+ "type": "uuid",
+ "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": {
+ "user_contact_tag_assignments_tag_id_contact_id_unique": {
+ "name": "user_contact_tag_assignments_tag_id_contact_id_unique",
"columns": [
{
- "expression": "user_id",
+ "expression": "tag_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "contact_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_contact_tag_assignments_contact_id_idx": {
+ "name": "user_contact_tag_assignments_contact_id_idx",
+ "columns": [
+ {
+ "expression": "contact_id",
"isExpression": false,
"asc": true,
"nulls": "last"
@@ -13982,11 +14627,11 @@
"method": "btree",
"with": {}
},
- "dashboard_items_workspace_id_idx": {
- "name": "dashboard_items_workspace_id_idx",
+ "user_contact_tag_assignments_user_id_idx": {
+ "name": "user_contact_tag_assignments_user_id_idx",
"columns": [
{
- "expression": "workspace_id",
+ "expression": "user_id",
"isExpression": false,
"asc": true,
"nulls": "last"
@@ -13999,41 +14644,32 @@
}
},
"foreignKeys": {
- "dashboard_items_dashboard_id_dashboards_id_fk": {
- "name": "dashboard_items_dashboard_id_dashboards_id_fk",
- "tableFrom": "dashboard_items",
- "tableTo": "dashboards",
- "columnsFrom": ["dashboard_id"],
+ "user_contact_tag_assignments_tag_id_user_contact_tags_id_fk": {
+ "name": "user_contact_tag_assignments_tag_id_user_contact_tags_id_fk",
+ "tableFrom": "user_contact_tag_assignments",
+ "tableTo": "user_contact_tags",
+ "columnsFrom": ["tag_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
},
- "dashboard_items_widget_id_widgets_id_fk": {
- "name": "dashboard_items_widget_id_widgets_id_fk",
- "tableFrom": "dashboard_items",
- "tableTo": "widgets",
- "columnsFrom": ["widget_id"],
+ "user_contact_tag_assignments_contact_id_user_contacts_id_fk": {
+ "name": "user_contact_tag_assignments_contact_id_user_contacts_id_fk",
+ "tableFrom": "user_contact_tag_assignments",
+ "tableTo": "user_contacts",
+ "columnsFrom": ["contact_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
},
- "dashboard_items_user_id_users_id_fk": {
- "name": "dashboard_items_user_id_users_id_fk",
- "tableFrom": "dashboard_items",
+ "user_contact_tag_assignments_user_id_users_id_fk": {
+ "name": "user_contact_tag_assignments_user_id_users_id_fk",
+ "tableFrom": "user_contact_tag_assignments",
"tableTo": "users",
"columnsFrom": ["user_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
- },
- "dashboard_items_workspace_id_workspaces_id_fk": {
- "name": "dashboard_items_workspace_id_workspaces_id_fk",
- "tableFrom": "dashboard_items",
- "tableTo": "workspaces",
- "columnsFrom": ["workspace_id"],
- "columnsTo": ["id"],
- "onDelete": "cascade",
- "onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
@@ -14042,8 +14678,8 @@
"checkConstraints": {},
"isRLSEnabled": false
},
- "public.dashboards": {
- "name": "dashboards",
+ "public.user_contact_tags": {
+ "name": "user_contact_tags",
"schema": "",
"columns": {
"id": {
@@ -14059,38 +14695,14 @@
"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
- },
- "agent_id": {
- "name": "agent_id",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "title": {
- "name": "title",
+ "name": {
+ "name": "name",
"type": "text",
"primaryKey": false,
"notNull": true
},
- "description": {
- "name": "description",
- "type": "text",
- "primaryKey": false,
- "notNull": false
- },
- "icon": {
- "name": "icon",
+ "color": {
+ "name": "color",
"type": "text",
"primaryKey": false,
"notNull": false
@@ -14102,31 +14714,548 @@
"notNull": true,
"default": 0
},
- "metadata": {
- "name": "metadata",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "visibility": {
- "name": "visibility",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "default": "'public'"
- },
- "deleted_at": {
- "name": "deleted_at",
- "type": "timestamp with time zone",
- "primaryKey": false,
- "notNull": false
- },
- "is_deleted": {
- "name": "is_deleted",
- "type": "boolean",
- "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_contact_tags_user_id_name_unique": {
+ "name": "user_contact_tags_user_id_name_unique",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_contact_tags_user_id_users_id_fk": {
+ "name": "user_contact_tags_user_id_users_id_fk",
+ "tableFrom": "user_contact_tags",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_contacts": {
+ "name": "user_contacts",
+ "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
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "contact_user_id": {
+ "name": "contact_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "remark": {
+ "name": "remark",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "phones": {
+ "name": "phones",
+ "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": {
+ "user_contacts_user_unique": {
+ "name": "user_contacts_user_unique",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "contact_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"user_contacts\".\"contact_user_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_contacts_agent_unique": {
+ "name": "user_contacts_agent_unique",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"user_contacts\".\"agent_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_contacts_contact_user_id_idx": {
+ "name": "user_contacts_contact_user_id_idx",
+ "columns": [
+ {
+ "expression": "contact_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_contacts_agent_id_idx": {
+ "name": "user_contacts_agent_id_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_contacts_user_id_users_id_fk": {
+ "name": "user_contacts_user_id_users_id_fk",
+ "tableFrom": "user_contacts",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_contacts_contact_user_id_users_id_fk": {
+ "name": "user_contacts_contact_user_id_users_id_fk",
+ "tableFrom": "user_contacts",
+ "tableTo": "users",
+ "columnsFrom": ["contact_user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_contacts_agent_id_agents_id_fk": {
+ "name": "user_contacts_agent_id_agents_id_fk",
+ "tableFrom": "user_contacts",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.dashboard_items": {
+ "name": "dashboard_items",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "dashboard_id": {
+ "name": "dashboard_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "widget_id": {
+ "name": "widget_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
+ },
+ "layout": {
+ "name": "layout",
+ "type": "jsonb",
+ "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": {
+ "dashboard_items_dashboard_id_widget_id_unique": {
+ "name": "dashboard_items_dashboard_id_widget_id_unique",
+ "columns": [
+ {
+ "expression": "dashboard_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "widget_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "dashboard_items_dashboard_id_sort_order_idx": {
+ "name": "dashboard_items_dashboard_id_sort_order_idx",
+ "columns": [
+ {
+ "expression": "dashboard_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sort_order",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "dashboard_items_widget_id_idx": {
+ "name": "dashboard_items_widget_id_idx",
+ "columns": [
+ {
+ "expression": "widget_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "dashboard_items_user_id_idx": {
+ "name": "dashboard_items_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "dashboard_items_workspace_id_idx": {
+ "name": "dashboard_items_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "dashboard_items_dashboard_id_dashboards_id_fk": {
+ "name": "dashboard_items_dashboard_id_dashboards_id_fk",
+ "tableFrom": "dashboard_items",
+ "tableTo": "dashboards",
+ "columnsFrom": ["dashboard_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "dashboard_items_widget_id_widgets_id_fk": {
+ "name": "dashboard_items_widget_id_widgets_id_fk",
+ "tableFrom": "dashboard_items",
+ "tableTo": "widgets",
+ "columnsFrom": ["widget_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "dashboard_items_user_id_users_id_fk": {
+ "name": "dashboard_items_user_id_users_id_fk",
+ "tableFrom": "dashboard_items",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "dashboard_items_workspace_id_workspaces_id_fk": {
+ "name": "dashboard_items_workspace_id_workspaces_id_fk",
+ "tableFrom": "dashboard_items",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.dashboards": {
+ "name": "dashboards",
+ "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
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "icon": {
+ "name": "icon",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sort_order": {
+ "name": "sort_order",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "visibility": {
+ "name": "visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'public'"
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_deleted": {
+ "name": "is_deleted",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
"accessed_at": {
"name": "accessed_at",
"type": "timestamp with time zone",
@@ -18423,6 +19552,12 @@
"primaryKey": false,
"notNull": false
},
+ "created_by_agent_id": {
+ "name": "created_by_agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
"visibility": {
"name": "visibility",
"type": "text",
@@ -22534,6 +23669,338 @@
"checkConstraints": {},
"isRLSEnabled": false
},
+ "public.inbound_webhooks": {
+ "name": "inbound_webhooks",
+ "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
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "topic_id": {
+ "name": "topic_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "instructions": {
+ "name": "instructions",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "secret": {
+ "name": "secret",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "verification": {
+ "name": "verification",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "config": {
+ "name": "config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "state": {
+ "name": "state",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "connector_id": {
+ "name": "connector_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dedupe_key": {
+ "name": "dedupe_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "next_maintenance_at": {
+ "name": "next_maintenance_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "maintenance_failures": {
+ "name": "maintenance_failures",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "last_delivery_at": {
+ "name": "last_delivery_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wake_count": {
+ "name": "wake_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "wake_window_started_at": {
+ "name": "wake_window_started_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": {
+ "inbound_webhooks_user_kind_dedupe_unique": {
+ "name": "inbound_webhooks_user_kind_dedupe_unique",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "dedupe_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"inbound_webhooks\".\"dedupe_key\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "inbound_webhooks_next_maintenance_idx": {
+ "name": "inbound_webhooks_next_maintenance_idx",
+ "columns": [
+ {
+ "expression": "next_maintenance_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"inbound_webhooks\".\"next_maintenance_at\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "inbound_webhooks_user_idx": {
+ "name": "inbound_webhooks_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "inbound_webhooks_workspace_idx": {
+ "name": "inbound_webhooks_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "inbound_webhooks_topic_idx": {
+ "name": "inbound_webhooks_topic_idx",
+ "columns": [
+ {
+ "expression": "topic_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "inbound_webhooks_agent_idx": {
+ "name": "inbound_webhooks_agent_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "inbound_webhooks_connector_idx": {
+ "name": "inbound_webhooks_connector_idx",
+ "columns": [
+ {
+ "expression": "connector_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "inbound_webhooks_user_id_users_id_fk": {
+ "name": "inbound_webhooks_user_id_users_id_fk",
+ "tableFrom": "inbound_webhooks",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "inbound_webhooks_workspace_id_workspaces_id_fk": {
+ "name": "inbound_webhooks_workspace_id_workspaces_id_fk",
+ "tableFrom": "inbound_webhooks",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "inbound_webhooks_agent_id_agents_id_fk": {
+ "name": "inbound_webhooks_agent_id_agents_id_fk",
+ "tableFrom": "inbound_webhooks",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "inbound_webhooks_topic_id_topics_id_fk": {
+ "name": "inbound_webhooks_topic_id_topics_id_fk",
+ "tableFrom": "inbound_webhooks",
+ "tableTo": "topics",
+ "columnsFrom": ["topic_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "inbound_webhooks_connector_id_user_connectors_id_fk": {
+ "name": "inbound_webhooks_connector_id_user_connectors_id_fk",
+ "tableFrom": "inbound_webhooks",
+ "tableTo": "user_connectors",
+ "columnsFrom": ["connector_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
"public.linear_connections": {
"name": "linear_connections",
"schema": "",
@@ -22842,100 +24309,927 @@
}
},
"indexes": {
- "linear_sync_rules_project_id_idx": {
- "name": "linear_sync_rules_project_id_idx",
+ "linear_sync_rules_project_id_idx": {
+ "name": "linear_sync_rules_project_id_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "linear_sync_rules_connection_id_idx": {
+ "name": "linear_sync_rules_connection_id_idx",
+ "columns": [
+ {
+ "expression": "connection_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "linear_sync_rules_user_id_idx": {
+ "name": "linear_sync_rules_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "linear_sync_rules_workspace_id_idx": {
+ "name": "linear_sync_rules_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "linear_sync_rules_project_id_projects_id_fk": {
+ "name": "linear_sync_rules_project_id_projects_id_fk",
+ "tableFrom": "linear_sync_rules",
+ "tableTo": "projects",
+ "columnsFrom": ["project_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "linear_sync_rules_connection_id_linear_connections_id_fk": {
+ "name": "linear_sync_rules_connection_id_linear_connections_id_fk",
+ "tableFrom": "linear_sync_rules",
+ "tableTo": "linear_connections",
+ "columnsFrom": ["connection_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "linear_sync_rules_user_id_users_id_fk": {
+ "name": "linear_sync_rules_user_id_users_id_fk",
+ "tableFrom": "linear_sync_rules",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "linear_sync_rules_workspace_id_workspaces_id_fk": {
+ "name": "linear_sync_rules_workspace_id_workspaces_id_fk",
+ "tableFrom": "linear_sync_rules",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "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.meeting_minutes": {
+ "name": "meeting_minutes",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "meeting_id": {
+ "name": "meeting_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "summary": {
+ "name": "summary",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "chapters": {
+ "name": "chapters",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "decisions": {
+ "name": "decisions",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "action_items": {
+ "name": "action_items",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "keywords": {
+ "name": "keywords",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "document_id": {
+ "name": "document_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model": {
+ "name": "model",
+ "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": {
+ "meeting_minutes_meeting_id_unique": {
+ "name": "meeting_minutes_meeting_id_unique",
+ "columns": [
+ {
+ "expression": "meeting_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "meeting_minutes_document_id_idx": {
+ "name": "meeting_minutes_document_id_idx",
+ "columns": [
+ {
+ "expression": "document_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "meeting_minutes_meeting_id_meetings_id_fk": {
+ "name": "meeting_minutes_meeting_id_meetings_id_fk",
+ "tableFrom": "meeting_minutes",
+ "tableTo": "meetings",
+ "columnsFrom": ["meeting_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "meeting_minutes_document_id_documents_id_fk": {
+ "name": "meeting_minutes_document_id_documents_id_fk",
+ "tableFrom": "meeting_minutes",
+ "tableTo": "documents",
+ "columnsFrom": ["document_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.meeting_segments": {
+ "name": "meeting_segments",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "meeting_id": {
+ "name": "meeting_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "speaker_id": {
+ "name": "speaker_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "seq": {
+ "name": "seq",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "start_ms": {
+ "name": "start_ms",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "end_ms": {
+ "name": "end_ms",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "text": {
+ "name": "text",
+ "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": {
+ "meeting_segments_meeting_id_source_seq_unique": {
+ "name": "meeting_segments_meeting_id_source_seq_unique",
+ "columns": [
+ {
+ "expression": "meeting_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "seq",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "meeting_segments_meeting_id_source_start_ms_idx": {
+ "name": "meeting_segments_meeting_id_source_start_ms_idx",
+ "columns": [
+ {
+ "expression": "meeting_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "start_ms",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "meeting_segments_speaker_id_idx": {
+ "name": "meeting_segments_speaker_id_idx",
+ "columns": [
+ {
+ "expression": "speaker_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "meeting_segments_meeting_id_meetings_id_fk": {
+ "name": "meeting_segments_meeting_id_meetings_id_fk",
+ "tableFrom": "meeting_segments",
+ "tableTo": "meetings",
+ "columnsFrom": ["meeting_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "meeting_segments_speaker_id_meeting_speakers_id_fk": {
+ "name": "meeting_segments_speaker_id_meeting_speakers_id_fk",
+ "tableFrom": "meeting_segments",
+ "tableTo": "meeting_speakers",
+ "columnsFrom": ["speaker_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.meeting_speakers": {
+ "name": "meeting_speakers",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "meeting_id": {
+ "name": "meeting_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "label": {
+ "name": "label",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "display_name": {
+ "name": "display_name",
+ "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": {
+ "meeting_speakers_meeting_id_label_unique": {
+ "name": "meeting_speakers_meeting_id_label_unique",
"columns": [
{
- "expression": "project_id",
+ "expression": "meeting_id",
"isExpression": false,
"asc": true,
"nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "linear_sync_rules_connection_id_idx": {
- "name": "linear_sync_rules_connection_id_idx",
- "columns": [
- {
- "expression": "connection_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "linear_sync_rules_user_id_idx": {
- "name": "linear_sync_rules_user_id_idx",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "linear_sync_rules_workspace_id_idx": {
- "name": "linear_sync_rules_workspace_id_idx",
- "columns": [
+ },
{
- "expression": "workspace_id",
+ "expression": "label",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
- "isUnique": false,
+ "isUnique": true,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
- "linear_sync_rules_project_id_projects_id_fk": {
- "name": "linear_sync_rules_project_id_projects_id_fk",
- "tableFrom": "linear_sync_rules",
- "tableTo": "projects",
- "columnsFrom": ["project_id"],
- "columnsTo": ["id"],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "linear_sync_rules_connection_id_linear_connections_id_fk": {
- "name": "linear_sync_rules_connection_id_linear_connections_id_fk",
- "tableFrom": "linear_sync_rules",
- "tableTo": "linear_connections",
- "columnsFrom": ["connection_id"],
- "columnsTo": ["id"],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "linear_sync_rules_user_id_users_id_fk": {
- "name": "linear_sync_rules_user_id_users_id_fk",
- "tableFrom": "linear_sync_rules",
- "tableTo": "users",
- "columnsFrom": ["user_id"],
- "columnsTo": ["id"],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "linear_sync_rules_workspace_id_workspaces_id_fk": {
- "name": "linear_sync_rules_workspace_id_workspaces_id_fk",
- "tableFrom": "linear_sync_rules",
- "tableTo": "workspaces",
- "columnsFrom": ["workspace_id"],
+ "meeting_speakers_meeting_id_meetings_id_fk": {
+ "name": "meeting_speakers_meeting_id_meetings_id_fk",
+ "tableFrom": "meeting_speakers",
+ "tableTo": "meetings",
+ "columnsFrom": ["meeting_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
@@ -22947,8 +25241,8 @@
"checkConstraints": {},
"isRLSEnabled": false
},
- "public.llm_generation_tracing": {
- "name": "llm_generation_tracing",
+ "public.meetings": {
+ "name": "meetings",
"schema": "",
"columns": {
"id": {
@@ -22958,193 +25252,106 @@
"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",
+ "title": {
+ "name": "title",
"type": "text",
"primaryKey": false,
- "notNull": false
- },
- "parent_tracing_id": {
- "name": "parent_tracing_id",
- "type": "uuid",
- "primaryKey": false,
- "notNull": false
+ "notNull": true
},
- "provider": {
- "name": "provider",
+ "status": {
+ "name": "status",
"type": "text",
"primaryKey": false,
- "notNull": false
+ "notNull": true,
+ "default": "'recording'"
},
- "model": {
- "name": "model",
+ "platform": {
+ "name": "platform",
"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",
+ "realtime_provider": {
+ "name": "realtime_provider",
"type": "text",
"primaryKey": false,
- "notNull": false
- },
- "validation_failed": {
- "name": "validation_failed",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": false
+ "notNull": true
},
- "input_hash": {
- "name": "input_hash",
+ "refine_provider": {
+ "name": "refine_provider",
"type": "text",
"primaryKey": false,
- "notNull": false
+ "notNull": true
},
- "input_hint": {
- "name": "input_hint",
+ "language": {
+ "name": "language",
"type": "text",
"primaryKey": false,
- "notNull": false
+ "notNull": true,
+ "default": "'auto'"
},
- "latency_ms": {
- "name": "latency_ms",
- "type": "integer",
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
"primaryKey": false,
- "notNull": false
+ "notNull": true,
+ "default": "now()"
},
- "input_tokens": {
- "name": "input_tokens",
- "type": "integer",
+ "ended_at": {
+ "name": "ended_at",
+ "type": "timestamp with time zone",
"primaryKey": false,
"notNull": false
},
- "output_tokens": {
- "name": "output_tokens",
+ "duration_ms": {
+ "name": "duration_ms",
"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",
+ "audio_file_id": {
+ "name": "audio_file_id",
"type": "text",
"primaryKey": false,
"notNull": false
},
- "feedback_score": {
- "name": "feedback_score",
- "type": "numeric(3, 2)",
- "primaryKey": false,
- "notNull": false
- },
- "feedback_source": {
- "name": "feedback_source",
+ "local_audio_path": {
+ "name": "local_audio_path",
"type": "text",
"primaryKey": false,
"notNull": false
},
- "feedback_data": {
- "name": "feedback_data",
+ "error": {
+ "name": "error",
"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",
+ "visibility": {
+ "name": "visibility",
"type": "text",
"primaryKey": false,
- "notNull": false
+ "notNull": true,
+ "default": "'private'"
},
- "metadata": {
- "name": "metadata",
- "type": "jsonb",
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
"primaryKey": false,
- "notNull": false,
- "default": "'{}'::jsonb"
+ "notNull": true,
+ "default": "now()"
},
"created_at": {
"name": "created_at",
@@ -23152,149 +25359,33 @@
"primaryKey": false,
"notNull": true,
"default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_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",
+ "meetings_user_id_workspace_id_created_at_idx": {
+ "name": "meetings_user_id_workspace_id_created_at_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",
+ "expression": "created_at",
"isExpression": false,
"asc": true,
"nulls": "last"
@@ -23305,26 +25396,17 @@
"method": "btree",
"with": {}
},
- "llm_generation_tracing_validation_failed_idx": {
- "name": "llm_generation_tracing_validation_failed_idx",
+ "meetings_workspace_id_created_at_idx": {
+ "name": "meetings_workspace_id_created_at_idx",
"columns": [
{
- "expression": "validation_failed",
+ "expression": "workspace_id",
"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",
+ "expression": "created_at",
"isExpression": false,
"asc": true,
"nulls": "last"
@@ -23335,11 +25417,11 @@
"method": "btree",
"with": {}
},
- "llm_generation_tracing_created_at_idx": {
- "name": "llm_generation_tracing_created_at_idx",
+ "meetings_audio_file_id_idx": {
+ "name": "meetings_audio_file_id_idx",
"columns": [
{
- "expression": "created_at",
+ "expression": "audio_file_id",
"isExpression": false,
"asc": true,
"nulls": "last"
@@ -23352,14 +25434,32 @@
}
},
"foreignKeys": {
- "llm_generation_tracing_workspace_id_workspaces_id_fk": {
- "name": "llm_generation_tracing_workspace_id_workspaces_id_fk",
- "tableFrom": "llm_generation_tracing",
+ "meetings_user_id_users_id_fk": {
+ "name": "meetings_user_id_users_id_fk",
+ "tableFrom": "meetings",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "meetings_workspace_id_workspaces_id_fk": {
+ "name": "meetings_workspace_id_workspaces_id_fk",
+ "tableFrom": "meetings",
"tableTo": "workspaces",
"columnsFrom": ["workspace_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
+ },
+ "meetings_audio_file_id_files_id_fk": {
+ "name": "meetings_audio_file_id_files_id_fk",
+ "tableFrom": "meetings",
+ "tableTo": "files",
+ "columnsFrom": ["audio_file_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
@@ -47890,6 +49990,13 @@
"primaryKey": false,
"notNull": false
},
+ "config": {
+ "name": "config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
"joined_at": {
"name": "joined_at",
"type": "timestamp with time zone",
diff --git a/packages/database/migrations/meta/_journal.json b/packages/database/migrations/meta/_journal.json
index a714be295ca..2b91f5ac1c2 100644
--- a/packages/database/migrations/meta/_journal.json
+++ b/packages/database/migrations/meta/_journal.json
@@ -1512,6 +1512,13 @@
"when": 1794770338614,
"tag": "0215_user_connectors_add_visibility",
"breakpoints": true
+ },
+ {
+ "idx": 216,
+ "version": "7",
+ "when": 1794814012290,
+ "tag": "0216_inbound_webhooks",
+ "breakpoints": true
}
],
"version": "6"
diff --git a/packages/database/src/models/__tests__/inboundWebhook.test.ts b/packages/database/src/models/__tests__/inboundWebhook.test.ts
new file mode 100644
index 00000000000..6ce6624f916
--- /dev/null
+++ b/packages/database/src/models/__tests__/inboundWebhook.test.ts
@@ -0,0 +1,435 @@
+// @vitest-environment node
+import { eq } from 'drizzle-orm';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+
+import { getTestDB } from '../../core/getTestDB';
+import { agents, inboundWebhooks, topics, users, workspaces } from '../../schemas';
+import type { CreateInboundWebhook, InboundWebhookPatch } from '../inboundWebhook';
+import { InboundWebhookLimitError, InboundWebhookModel } from '../inboundWebhook';
+
+const db = await getTestDB();
+const userId = 'inbound-user';
+const otherUserId = 'inbound-other';
+const agentId = 'inbound-agent';
+const topicId = 'inbound-topic';
+const missing = '00000000-0000-0000-0000-000000000000';
+const gateKeeper = {
+ encrypt: async (value: string) => `cipher:${Buffer.from(value).toString('base64')}`,
+ decrypt: async (value: string) => ({
+ plaintext: Buffer.from(value.slice(7), 'base64').toString(),
+ }),
+};
+const model = new InboundWebhookModel(db, userId, undefined, gateKeeper);
+const otherModel = new InboundWebhookModel(db, otherUserId, undefined, gateKeeper);
+const input = (patch: Partial<CreateInboundWebhook> = {}): CreateInboundWebhook => ({
+ agentId,
+ topicId,
+ kind: 'mcp_events',
+ config: { arguments: { project: 'test' }, eventName: 'issue.created' },
+ verification: { scheme: 'standard_webhooks' },
+ secret: 'whsec_test',
+ ...patch,
+});
+
+beforeEach(async () => {
+ await db.delete(users);
+ await db.insert(users).values([{ id: userId }, { id: otherUserId }]);
+ await db.insert(agents).values({ id: agentId, userId });
+ await db.insert(topics).values({ id: topicId, userId, agentId });
+});
+
+afterEach(async () => {
+ await db.delete(users);
+});
+
+describe('InboundWebhookModel secret handling and validation', () => {
+ it('encrypts on insert, never returns ciphertext, and explicitly decrypts for delivery', async () => {
+ const created = await model.create(input());
+ expect(created).not.toHaveProperty('secret');
+ const [raw] = await db.select().from(inboundWebhooks).where(eq(inboundWebhooks.id, created.id));
+ expect(raw.secret).not.toBe('whsec_test');
+ expect(raw.secret).toMatch(/^cipher:/);
+ expect(await model.getSecret(created.id)).toBe('whsec_test');
+ const delivery = await InboundWebhookModel.findForDelivery(db, created.id, gateKeeper);
+ expect(delivery?.secret).toBe('whsec_test');
+ expect(delivery?.row).not.toHaveProperty('secret');
+ expect(await model.findById(created.id)).not.toHaveProperty('secret');
+ expect((await model.query({ includeHidden: true }))[0]).not.toHaveProperty('secret');
+ });
+
+ it('requires encryption instead of writing plaintext when the gatekeeper is absent', async () => {
+ const unencrypted = new InboundWebhookModel(db, userId);
+ await expect(unencrypted.create(input())).rejects.toThrow(/needs a gatekeeper/);
+ expect(await model.query({ includeHidden: true })).toEqual([]);
+ const row = await model.create(input());
+ await expect(unencrypted.getSecret(row.id)).rejects.toThrow(/needs a gatekeeper/);
+ await expect(InboundWebhookModel.findForDelivery(db, row.id)).rejects.toThrow(
+ /needs a gatekeeper/,
+ );
+ });
+
+ it('initializes delivery credentials lazily only for a known live row with a secret', async () => {
+ const lazyGateKeeper = vi.fn(async () => gateKeeper);
+ expect(await InboundWebhookModel.findForDelivery(db, missing, lazyGateKeeper)).toBeUndefined();
+ const deleting = await model.create(input({ status: 'deleting' }));
+ expect(
+ await InboundWebhookModel.findForDelivery(db, deleting.id, lazyGateKeeper),
+ ).toBeUndefined();
+ const retired = await model.create(input());
+ await db
+ .update(inboundWebhooks)
+ .set({ kind: 'retired' as never })
+ .where(eq(inboundWebhooks.id, retired.id));
+ expect(
+ await InboundWebhookModel.findForDelivery(db, retired.id, lazyGateKeeper),
+ ).toBeUndefined();
+ const unsigned = await model.create(input({ secret: null }));
+ expect(
+ (await InboundWebhookModel.findForDelivery(db, unsigned.id, lazyGateKeeper))?.secret,
+ ).toBeNull();
+ expect(lazyGateKeeper).not.toHaveBeenCalled();
+ const active = await model.create(input({ status: 'active' }));
+ expect((await InboundWebhookModel.findForDelivery(db, active.id, lazyGateKeeper))?.secret).toBe(
+ 'whsec_test',
+ );
+ expect(lazyGateKeeper).toHaveBeenCalledTimes(1);
+ });
+
+ it('supports endpoints without a signing secret and returns null for absent rows', async () => {
+ const row = await model.create(input({ secret: null }));
+ expect(await model.getSecret(row.id)).toBeNull();
+ expect(await model.getSecret(missing)).toBeNull();
+ expect(await InboundWebhookModel.findForDelivery(db, row.id)).toEqual({ row, secret: null });
+ expect(await InboundWebhookModel.findForDelivery(db, missing)).toBeUndefined();
+ });
+
+ it.each([
+ { config: { arguments: {}, eventName: '' } },
+ { config: { eventName: 'event', arguments: [] } },
+ { state: { refreshBefore: 'tomorrow' } },
+ { state: { cursor: 42 } },
+ { verification: { scheme: 'none' } },
+ { kind: 'unknown' },
+ ])('rejects invalid kind data before inserting: %j', async (patch) => {
+ await expect(
+ model.create(input(patch as unknown as Partial<CreateInboundWebhook>)),
+ ).rejects.toThrow();
+ expect(await model.query({ includeHidden: true })).toEqual([]);
+ });
+
+ it('rejects invalid state patches and immutable configuration updates before writing', async () => {
+ const row = await model.create(input());
+ await expect(model.mergeState(row.id, { cursor: 7 } as never)).rejects.toThrow();
+ await expect(
+ model.update(row.id, { config: { eventName: 'changed' } } as InboundWebhookPatch),
+ ).rejects.toThrow();
+ expect((await model.findById(row.id))?.config.eventName).toBe('issue.created');
+ expect((await model.findById(row.id))?.state).toEqual({});
+ });
+
+ it('strips new remote delivery-health fields while validating known state fields', async () => {
+ const row = await model.create(
+ input({ state: { deliveryStatus: { active: true, serverHint: 'future' } } as never }),
+ );
+ expect(row.state.deliveryStatus).toEqual({ active: true });
+ await model.mergeState(row.id, { deliveryStatus: { active: false, newField: 1 } } as never);
+ expect((await model.findById(row.id))?.state.deliveryStatus).toEqual({ active: false });
+ await expect(
+ model.mergeState(row.id, { deliveryStatus: { active: 'wrong' } } as never),
+ ).rejects.toThrow();
+ await expect(model.mergeState(row.id, { futureTopLevel: true } as never)).rejects.toThrow();
+ });
+
+ it('stops delivery for deleting, unknown and invalid stored kinds', async () => {
+ const row = await model.create(input({ status: 'deleting' }));
+ expect(await InboundWebhookModel.findForDelivery(db, row.id, gateKeeper)).toBeUndefined();
+ await db
+ .update(inboundWebhooks)
+ .set({ status: 'active', kind: 'retired' as never })
+ .where(eq(inboundWebhooks.id, row.id));
+ expect(await InboundWebhookModel.findForDelivery(db, row.id, gateKeeper)).toBeUndefined();
+ });
+});
+
+describe('InboundWebhookModel scope and lifecycle', () => {
+ it('isolates every user operation', async () => {
+ const row = await model.create(input({ status: 'active' }));
+ expect(await otherModel.query()).toEqual([]);
+ expect(await otherModel.findById(row.id)).toBeUndefined();
+ expect(await otherModel.getSecret(row.id)).toBeNull();
+ expect(await otherModel.mergeState(row.id, { cursor: 'stolen' })).toBeUndefined();
+ expect(await otherModel.update(row.id, { status: 'error' })).toBeUndefined();
+ expect(await otherModel.reserveWake(row.id)).toBeUndefined();
+ await otherModel.delete(row.id);
+ expect((await model.findById(row.id))?.status).toBe('active');
+ await model.delete(row.id);
+ expect(await model.findById(row.id)).toBeUndefined();
+ });
+
+ it('shares workspace rows while excluding personal and other workspace rows', async () => {
+ await db.insert(workspaces).values([
+ { id: 'inbound-workspace', slug: 'inbound-workspace', name: 'Team', primaryOwnerId: userId },
+ { id: 'other-workspace', slug: 'other-workspace', name: 'Other', primaryOwnerId: userId },
+ ]);
+ const owner = new InboundWebhookModel(db, userId, 'inbound-workspace', gateKeeper);
+ const member = new InboundWebhookModel(db, otherUserId, 'inbound-workspace', gateKeeper);
+ const otherWorkspace = new InboundWebhookModel(db, userId, 'other-workspace', gateKeeper);
+ const row = await owner.create(input({ status: 'active' }));
+ await model.create(input({ status: 'active' }));
+ await otherWorkspace.create(input({ status: 'active' }));
+ expect((await member.query()).map((r) => r.id)).toEqual([row.id]);
+ expect(await member.findById(row.id)).toEqual(row);
+ expect(await model.query()).toHaveLength(1);
+ expect(await otherWorkspace.findById(row.id)).toBeUndefined();
+ await db.delete(workspaces);
+ });
+
+ it('filters hidden lifecycle rows and returns newest first with domain filters', async () => {
+ const active = await model.create(
+ input({ status: 'active', createdAt: new Date('2026-01-01') }),
+ );
+ const terminated = await model.create(
+ input({ status: 'terminated', createdAt: new Date('2026-01-02') }),
+ );
+ await model.create(input());
+ await model.create(input({ status: 'deleting' }));
+ expect((await model.query({ topicId, agentId })).map((r) => r.id)).toEqual([
+ terminated.id,
+ active.id,
+ ]);
+ expect(await model.query({ topicId: 'missing-topic' })).toEqual([]);
+ expect(await model.query({ agentId: 'missing-agent' })).toEqual([]);
+ expect(await model.query({ connectorId: missing })).toEqual([]);
+ expect(await model.query({ includeHidden: true })).toHaveLength(4);
+ });
+
+ it('does not reactivate a deleting row when an in-flight maintenance call finishes', async () => {
+ const row = await model.create(input({ status: 'active' }));
+ const retryAt = new Date(Date.now() + 60_000);
+ await model.update(row.id, {
+ status: 'deleting',
+ nextMaintenanceAt: retryAt,
+ maintenanceFailures: 2,
+ });
+ expect(
+ await model.update(row.id, {
+ status: 'active',
+ nextMaintenanceAt: null,
+ maintenanceFailures: 0,
+ }),
+ ).toBeUndefined();
+ expect(
+ await model.update(row.id, { status: 'error', lastError: 'auth', nextMaintenanceAt: null }),
+ ).toBeUndefined();
+ expect(await model.findById(row.id)).toMatchObject({
+ status: 'deleting',
+ nextMaintenanceAt: retryAt,
+ maintenanceFailures: 2,
+ lastError: null,
+ });
+ const laterRetry = new Date(Date.now() + 120_000);
+ expect(
+ await model.update(row.id, {
+ status: 'deleting',
+ nextMaintenanceAt: laterRetry,
+ maintenanceFailures: 3,
+ }),
+ ).toMatchObject({ status: 'deleting', nextMaintenanceAt: laterRetry, maintenanceFailures: 3 });
+ });
+
+ it('enforces deduplication per creator and kind, permitting absent keys', async () => {
+ await model.create(input({ dedupeKey: 'same-subscription' }));
+ await expect(model.create(input({ dedupeKey: 'same-subscription' }))).rejects.toThrow();
+ await otherModel.create(input({ dedupeKey: 'same-subscription' }));
+ await model.create(input());
+ await model.create(input());
+ expect(await model.query({ includeHidden: true })).toHaveLength(3);
+ });
+
+ it('merges concurrent cursor and lease updates without losing unrelated state', async () => {
+ const row = await model.create(input());
+ await Promise.all([
+ model.mergeState(row.id, { cursor: 'cursor-2' }),
+ model.mergeState(row.id, { refreshBefore: '2027-01-01T00:00:00Z' }),
+ model.mergeState(row.id, { truncated: true }),
+ ]);
+ expect((await model.findById(row.id))?.state).toEqual({
+ cursor: 'cursor-2',
+ refreshBefore: '2027-01-01T00:00:00Z',
+ truncated: true,
+ });
+ });
+
+ it('allows only one cursor CAS from concurrently observed state', async () => {
+ const row = await model.create(input({ state: { cursor: 'initial' } }));
+ const results = await Promise.all([
+ model.mergeStateIf(row.id, { cursor: 'next-1' }, { cursor: 'initial' }),
+ model.mergeStateIf(row.id, { cursor: 'next-2' }, { cursor: 'initial' }),
+ ]);
+ expect(results.filter(Boolean)).toHaveLength(1);
+ expect(['next-1', 'next-2']).toContain((await model.findById(row.id))?.state.cursor);
+ expect(await otherModel.mergeStateIf(row.id, { truncated: true }, {})).toBeUndefined();
+ expect((await model.findById(row.id))?.state.truncated).toBeUndefined();
+ });
+
+ it('distinguishes an absent JSON key from an explicit null in cursor CAS', async () => {
+ const row = await model.create(input());
+ expect(await model.mergeStateIf(row.id, { cursor: null }, { cursor: undefined })).toBeDefined();
+ expect(
+ await model.mergeStateIf(row.id, { cursor: 'stale' }, { cursor: undefined }),
+ ).toBeUndefined();
+ expect(
+ await model.mergeStateIf(row.id, { cursor: 'accepted' }, { cursor: null }),
+ ).toBeDefined();
+ expect((await model.findById(row.id))?.state.cursor).toBe('accepted');
+ });
+
+ it('validates both CAS patches and expectations before writing', async () => {
+ const row = await model.create(input());
+ await expect(model.mergeStateIf(row.id, { cursor: 42 } as never, {})).rejects.toThrow();
+ await expect(
+ model.mergeStateIf(row.id, { cursor: 'new' }, { cursor: 42 } as never),
+ ).rejects.toThrow();
+ expect((await model.findById(row.id))?.state).toEqual({});
+ });
+
+ it('cascades on hard-deleted topics', async () => {
+ const row = await model.create(input());
+ await db.delete(topics).where(eq(topics.id, topicId));
+ expect(await model.findById(row.id)).toBeUndefined();
+ });
+});
+
+describe('InboundWebhookModel maintenance and quotas', () => {
+ it('does not refund a failed reservation into a newer hourly window', async () => {
+ const row = await model.create(input({ status: 'active' }));
+ const original = await model.reserveWake(row.id);
+ await db
+ .update(inboundWebhooks)
+ .set({
+ wakeWindowStartedAt: new Date(Date.now() - 3_600_001),
+ })
+ .where(eq(inboundWebhooks.id, row.id));
+ const current = await model.reserveWake(row.id);
+ await model.releaseWake(row.id, original!);
+ expect((await model.findById(row.id))?.wakeCount).toBe(1);
+ await model.releaseWake(row.id, current!);
+ expect((await model.findById(row.id))?.wakeCount).toBe(0);
+ });
+
+ it('finds due finite leases/deletions and stale incomplete subscriptions only', async () => {
+ const due = new Date(Date.now() - 1000);
+ const active = await model.create(input({ status: 'active', nextMaintenanceAt: due }));
+ const deleting = await model.create(input({ status: 'deleting', nextMaintenanceAt: due }));
+ const stale = await model.create(input({ createdAt: new Date(Date.now() - 601_000) }));
+ await model.create(input({ status: 'active', state: { refreshBefore: null } }));
+ await model.create(
+ input({ status: 'active', nextMaintenanceAt: new Date(Date.now() + 60_000) }),
+ );
+ await model.create(input({ status: 'terminated', nextMaintenanceAt: due }));
+ await model.create(input());
+ expect((await InboundWebhookModel.queryMaintenance(db)).map((r) => r.id).sort()).toEqual(
+ [active.id, deleting.id].sort(),
+ );
+ expect(await InboundWebhookModel.queryMaintenance(db, 1)).toHaveLength(1);
+ expect((await InboundWebhookModel.queryStalePending(db)).map((r) => r.id)).toEqual([stale.id]);
+ });
+
+ it('atomically reserves a bounded number of wakes and resets an expired hour', async () => {
+ const row = await model.create(input({ status: 'active' }));
+ const reservations = await Promise.all(
+ Array.from({ length: 8 }, () => model.reserveWake(row.id, 3)),
+ );
+ expect(reservations.filter(Boolean)).toHaveLength(3);
+ expect((await model.findById(row.id))?.wakeCount).toBe(3);
+ await db
+ .update(inboundWebhooks)
+ .set({ wakeWindowStartedAt: new Date(Date.now() - 3_600_001) })
+ .where(eq(inboundWebhooks.id, row.id));
+ expect(await model.reserveWake(row.id, 3)).toBeTypeOf('string');
+ expect((await model.findById(row.id))?.wakeCount).toBe(1);
+ });
+
+ it('returns failed-start reservations without going negative or crossing user scope', async () => {
+ const row = await model.create(input({ status: 'active' }));
+ const window = await model.reserveWake(row.id, 1);
+ expect(window).toBeTypeOf('string');
+ await otherModel.releaseWake(row.id, window!);
+ expect(await model.reserveWake(row.id, 1)).toBeUndefined();
+ await model.releaseWake(row.id, window!);
+ expect(await model.reserveWake(row.id, 1)).toBe(window);
+ await Promise.all(Array.from({ length: 4 }, () => model.releaseWake(row.id, window!)));
+ expect((await model.findById(row.id))?.wakeCount).toBe(0);
+ });
+
+ it('applies status-guarded state/results atomically and respects ownership', async () => {
+ const row = await model.create(input({ status: 'active' }));
+ expect(
+ await otherModel.updateIfStatus(row.id, { status: 'error' }, ['active'], { truncated: true }),
+ ).toBeUndefined();
+ await model.update(row.id, { status: 'terminated', lastError: 'access_revoked' });
+ expect(
+ await model.updateIfStatus(row.id, { status: 'active' }, ['active', 'error'], {
+ remoteSubscriptionId: 'late',
+ }),
+ ).toBeUndefined();
+ expect(await model.findById(row.id)).toMatchObject({
+ status: 'terminated',
+ lastError: 'access_revoked',
+ state: {},
+ });
+ expect(
+ await model.updateIfStatus(row.id, { status: 'active', lastError: null }, ['terminated'], {
+ remoteSubscriptionId: 'manual',
+ }),
+ ).toMatchObject({ status: 'active', state: { remoteSubscriptionId: 'manual' } });
+ });
+
+ it('applies topic and user limits, including subscriptions being created or deleted', async () => {
+ await model.createWithLimits(input({ status: 'deleting' }), { topic: 1, user: 2 });
+ await expect(model.createWithLimits(input(), { topic: 1, user: 2 })).rejects.toBeInstanceOf(
+ InboundWebhookLimitError,
+ );
+ await model.createWithLimits(input({ topicId: null }), { topic: 1, user: 2 });
+ await expect(
+ model.createWithLimits(input({ topicId: null }), { topic: 1, user: 2 }),
+ ).rejects.toMatchObject({ code: 'limit_reached', message: expect.stringContaining('user') });
+ });
+
+ it('serializes quota checks from simultaneous subscription requests', async () => {
+ const results = await Promise.allSettled(
+ Array.from({ length: 4 }, () => model.createWithLimits(input(), { topic: 2, user: 2 })),
+ );
+ expect(results.filter((r) => r.status === 'fulfilled')).toHaveLength(2);
+ expect(await model.query({ includeHidden: true })).toHaveLength(2);
+ });
+});
+
+describe('InboundWebhookModel delivery recovery', () => {
+ it('scopes recovery and preserves current non-delivery errors and deletion state', async () => {
+ const row = await model.create(input({ status: 'error', lastError: 'http_5xx' }));
+ await otherModel.recordDelivery(row.id, true);
+ expect(await model.findById(row.id)).toMatchObject({
+ status: 'error',
+ lastError: 'http_5xx',
+ lastDeliveryAt: null,
+ });
+ await model.recordDelivery(row.id, false);
+ expect(await model.findById(row.id)).toMatchObject({ status: 'error', lastError: 'http_5xx' });
+ await model.recordDelivery(row.id, true);
+ expect(await model.findById(row.id)).toMatchObject({
+ status: 'active',
+ lastError: null,
+ lastDeliveryAt: expect.any(Date),
+ });
+ await model.update(row.id, { status: 'error', lastError: 'auth' });
+ await model.recordDelivery(row.id, true);
+ expect(await model.findById(row.id)).toMatchObject({ status: 'error', lastError: 'auth' });
+ await model.update(row.id, { status: 'deleting', lastError: 'http_5xx' });
+ await model.recordDelivery(row.id, true);
+ expect(await model.findById(row.id)).toMatchObject({
+ status: 'deleting',
+ lastError: 'http_5xx',
+ });
+ });
+});
diff --git a/packages/database/src/models/inboundWebhook.ts b/packages/database/src/models/inboundWebhook.ts
new file mode 100644
index 00000000000..fc1cbfcdfa0
--- /dev/null
+++ b/packages/database/src/models/inboundWebhook.ts
@@ -0,0 +1,382 @@
+import type {
+ InboundWebhookInsert,
+ InboundWebhookRow,
+ InboundWebhookState,
+ InboundWebhookStatus,
+} from '@lobechat/types';
+import {
+ INBOUND_WEBHOOK_DELIVERY_ERRORS,
+ INBOUND_WEBHOOK_ERRORS,
+ INBOUND_WEBHOOK_STATUSES,
+ InboundWebhookDataSchema,
+ McpEventsWebhookStateSchema,
+} from '@lobechat/types';
+import { and, count, desc, eq, getTableColumns, inArray, lt, lte, ne, sql } from 'drizzle-orm';
+import { z } from 'zod';
+
+import { inboundWebhooks, topics, users } from '../schemas';
+import type { LobeChatDatabase, Transaction } from '../type';
+import { buildWorkspacePayload, buildWorkspaceWhere } from '../utils/workspace';
+
+export interface InboundWebhookGateKeeper {
+ decrypt: (ciphertext: string) => Promise<{ plaintext: string }>;
+ encrypt: (plaintext: string) => Promise<string>;
+}
+
+export type InboundWebhookView = Omit<InboundWebhookRow, 'secret'>;
+export type CreateInboundWebhook = Omit<InboundWebhookInsert, 'userId' | 'workspaceId'>;
+export type InboundWebhookPatch = Partial<
+ Pick<
+ InboundWebhookRow,
+ 'status' | 'name' | 'nextMaintenanceAt' | 'maintenanceFailures' | 'lastDeliveryAt' | 'lastError'
+ >
+>;
+
+export interface InboundWebhookQuery {
+ agentId?: string;
+ connectorId?: string;
+ includeHidden?: boolean;
+ topicId?: string;
+}
+
+export class InboundWebhookLimitError extends Error {
+ readonly code = 'limit_reached';
+
+ constructor(scope: 'topic' | 'user') {
+ super(`Inbound webhook ${scope} subscription limit reached`);
+ this.name = 'InboundWebhookLimitError';
+ }
+}
+
+const patchSchema = z
+ .object({
+ status: z.enum(INBOUND_WEBHOOK_STATUSES).optional(),
+ name: z.string().nullable().optional(),
+ nextMaintenanceAt: z.date().nullable().optional(),
+ maintenanceFailures: z.number().int().nonnegative().optional(),
+ lastDeliveryAt: z.date().nullable().optional(),
+ lastError: z.enum(INBOUND_WEBHOOK_ERRORS).nullable().optional(),
+ })
+ .strict();
+
+const { secret: _secret, ...viewColumns } = getTableColumns(inboundWebhooks);
+
+const validateView = (row: InboundWebhookView): InboundWebhookView => {
+ InboundWebhookDataSchema.parse(row);
+ return row;
+};
+
+const toView = ({ secret: _ciphertext, ...row }: InboundWebhookRow) => validateView(row);
+
+/** Workspace reads are shared; row-level mutation permission belongs to the resource router. */
+export class InboundWebhookModel {
+ constructor(
+ private db: LobeChatDatabase,
+ private userId: string,
+ private workspaceId?: string,
+ private gateKeeper?: InboundWebhookGateKeeper,
+ ) {}
+
+ private ownership = () =>
+ buildWorkspaceWhere({ userId: this.userId, workspaceId: this.workspaceId }, inboundWebhooks);
+
+ private requireGateKeeper = () => {
+ if (!this.gateKeeper) {
+ throw new Error(
+ 'InboundWebhookModel needs a gatekeeper (KEY_VAULTS_SECRET) to store or read secrets',
+ );
+ }
+ return this.gateKeeper;
+ };
+
+ private prepare = async (input: CreateInboundWebhook) => {
+ const data = InboundWebhookDataSchema.parse({ ...input, state: input.state ?? {} });
+ return buildWorkspacePayload(
+ { userId: this.userId, workspaceId: this.workspaceId },
+ {
+ ...input,
+ ...data,
+ secret: input.secret == null ? null : await this.requireGateKeeper().encrypt(input.secret),
+ },
+ );
+ };
+
+ private insert = async (
+ db: LobeChatDatabase | Transaction,
+ payload: Awaited<ReturnType<InboundWebhookModel['prepare']>>,
+ ) => {
+ const [row] = await db.insert(inboundWebhooks).values(payload).returning();
+ return toView(row);
+ };
+
+ create = async (input: CreateInboundWebhook): Promise<InboundWebhookView> =>
+ this.insert(this.db, await this.prepare(input));
+
+ /** Parent-row locks serialize both creator and topic quotas, including pending/deleting rows. */
+ createWithLimits = async (
+ input: CreateInboundWebhook,
+ limits = { topic: 10, user: 50 },
+ ): Promise<InboundWebhookView> => {
+ const payload = await this.prepare(input);
+ return this.db.transaction(async (tx) => {
+ await tx.select({ id: users.id }).from(users).where(eq(users.id, this.userId)).for('update');
+ if (input.topicId) {
+ await tx
+ .select({ id: topics.id })
+ .from(topics)
+ .where(eq(topics.id, input.topicId))
+ .for('update');
+ }
+ const [userCount] = await tx
+ .select({ count: count() })
+ .from(inboundWebhooks)
+ .where(eq(inboundWebhooks.userId, this.userId));
+ if (userCount.count >= limits.user) throw new InboundWebhookLimitError('user');
+ if (input.topicId) {
+ const [topicCount] = await tx
+ .select({ count: count() })
+ .from(inboundWebhooks)
+ .where(eq(inboundWebhooks.topicId, input.topicId));
+ if (topicCount.count >= limits.topic) throw new InboundWebhookLimitError('topic');
+ }
+ return this.insert(tx, payload);
+ });
+ };
+
+ query = async (filter: InboundWebhookQuery = {}): Promise<InboundWebhookView[]> => {
+ const rows = await this.db
+ .select(viewColumns)
+ .from(inboundWebhooks)
+ .where(
+ and(
+ this.ownership(),
+ filter.topicId ? eq(inboundWebhooks.topicId, filter.topicId) : undefined,
+ filter.agentId ? eq(inboundWebhooks.agentId, filter.agentId) : undefined,
+ filter.connectorId ? eq(inboundWebhooks.connectorId, filter.connectorId) : undefined,
+ filter.includeHidden
+ ? undefined
+ : inArray(inboundWebhooks.status, ['active', 'error', 'terminated']),
+ ),
+ )
+ .orderBy(desc(inboundWebhooks.createdAt));
+ return rows.map(validateView);
+ };
+
+ findById = async (id: string): Promise<InboundWebhookView | undefined> => {
+ const [row] = await this.db
+ .select(viewColumns)
+ .from(inboundWebhooks)
+ .where(and(this.ownership(), eq(inboundWebhooks.id, id)))
+ .limit(1);
+ return row ? validateView(row) : undefined;
+ };
+
+ update = async (
+ id: string,
+ patch: InboundWebhookPatch,
+ ): Promise<InboundWebhookView | undefined> => {
+ const parsed = patchSchema.parse(patch);
+ const [row] = await this.db
+ .update(inboundWebhooks)
+ .set(parsed)
+ .where(
+ and(
+ this.ownership(),
+ eq(inboundWebhooks.id, id),
+ parsed.status && parsed.status !== 'deleting'
+ ? ne(inboundWebhooks.status, 'deleting')
+ : undefined,
+ ),
+ )
+ .returning(viewColumns);
+ return row ? validateView(row) : undefined;
+ };
+
+ /** Apply an in-flight result only while the persisted lifecycle still allows it. */
+ updateIfStatus = async (
+ id: string,
+ patch: InboundWebhookPatch,
+ statuses: InboundWebhookStatus[],
+ state?: Partial<InboundWebhookState>,
+ ): Promise<InboundWebhookView | undefined> => {
+ const parsed = patchSchema.parse(patch);
+ const statePatch = state === undefined ? undefined : McpEventsWebhookStateSchema.parse(state);
+ const [row] = await this.db
+ .update(inboundWebhooks)
+ .set({
+ ...parsed,
+ ...(statePatch
+ ? {
+ state: sql`${inboundWebhooks.state} || ${JSON.stringify(statePatch)}::jsonb`,
+ }
+ : {}),
+ })
+ .where(
+ and(
+ this.ownership(),
+ eq(inboundWebhooks.id, id),
+ inArray(inboundWebhooks.status, statuses),
+ ),
+ )
+ .returning(viewColumns);
+ return row ? validateView(row) : undefined;
+ };
+
+ /** Clear only delivery failures, using current database values so concurrent auth/runtime errors survive. */
+ recordDelivery = async (id: string, isEvent: boolean): Promise<void> => {
+ const recovered = isEvent
+ ? and(
+ eq(inboundWebhooks.status, 'error'),
+ inArray(inboundWebhooks.lastError, [...INBOUND_WEBHOOK_DELIVERY_ERRORS]),
+ )
+ : sql`false`;
+ await this.db
+ .update(inboundWebhooks)
+ .set({
+ lastDeliveryAt: new Date(),
+ status: sql`CASE WHEN ${recovered} THEN 'active' ELSE ${inboundWebhooks.status} END`,
+ lastError: sql`CASE WHEN ${recovered} THEN NULL ELSE ${inboundWebhooks.lastError} END`,
+ })
+ .where(and(this.ownership(), eq(inboundWebhooks.id, id)));
+ };
+
+ /** Each caller patches only its owned keys, never overwrites a concurrently advanced cursor. */
+ mergeState = async (
+ id: string,
+ patch: Partial<InboundWebhookState>,
+ ): Promise<InboundWebhookView | undefined> => {
+ const parsed = McpEventsWebhookStateSchema.parse(patch);
+ const [row] = await this.db
+ .update(inboundWebhooks)
+ .set({ state: sql`${inboundWebhooks.state} || ${JSON.stringify(parsed)}::jsonb` })
+ .where(and(this.ownership(), eq(inboundWebhooks.id, id)))
+ .returning(viewColumns);
+ return row ? validateView(row) : undefined;
+ };
+
+ /** Compare the JSON keys a caller observed while merging only its owned state keys. */
+ mergeStateIf = async (
+ id: string,
+ patch: Partial<InboundWebhookState>,
+ expected: Partial<InboundWebhookState>,
+ ): Promise<InboundWebhookView | undefined> => {
+ const parsed = McpEventsWebhookStateSchema.parse(patch);
+ McpEventsWebhookStateSchema.parse(expected);
+ const comparisons = Object.entries(expected).map(([key, value]) => {
+ const observed = value === undefined ? sql`NULL` : sql`${JSON.stringify(value)}::jsonb`;
+ return sql`(${inboundWebhooks.state} -> ${key}::text) IS NOT DISTINCT FROM ${observed}`;
+ });
+ const [row] = await this.db
+ .update(inboundWebhooks)
+ .set({ state: sql`${inboundWebhooks.state} || ${JSON.stringify(parsed)}::jsonb` })
+ .where(and(this.ownership(), eq(inboundWebhooks.id, id), ...comparisons))
+ .returning(viewColumns);
+ return row ? validateView(row) : undefined;
+ };
+
+ delete = async (id: string): Promise<void> => {
+ await this.db.delete(inboundWebhooks).where(and(this.ownership(), eq(inboundWebhooks.id, id)));
+ };
+
+ getSecret = async (id: string): Promise<string | null> => {
+ const [row] = await this.db
+ .select({ secret: inboundWebhooks.secret })
+ .from(inboundWebhooks)
+ .where(and(this.ownership(), eq(inboundWebhooks.id, id)))
+ .limit(1);
+ if (!row?.secret) return null;
+ return (await this.requireGateKeeper().decrypt(row.secret)).plaintext;
+ };
+
+ /** Reserve one wake atomically, resetting the rolling hourly bucket when it expires. */
+ reserveWake = async (id: string, limit = 30): Promise<string | undefined> => {
+ const now = new Date();
+ const reset = sql`${inboundWebhooks.wakeWindowStartedAt} <= ${new Date(now.getTime() - 3_600_000)}`;
+ const [row] = await this.db
+ .update(inboundWebhooks)
+ .set({
+ wakeCount: sql`CASE WHEN ${reset} THEN 1 ELSE ${inboundWebhooks.wakeCount} + 1 END`,
+ wakeWindowStartedAt: sql`CASE WHEN ${reset} THEN ${now} ELSE ${inboundWebhooks.wakeWindowStartedAt} END`,
+ })
+ .where(
+ and(
+ this.ownership(),
+ eq(inboundWebhooks.id, id),
+ sql`(${reset} OR ${inboundWebhooks.wakeCount} < ${limit})`,
+ ),
+ )
+ // Preserve PostgreSQL timestamp precision; a JS Date would truncate microseconds.
+ .returning({ window: sql<string>`${inboundWebhooks.wakeWindowStartedAt}::text` });
+ return row?.window;
+ };
+
+ /** Return a reservation when execution never started; retries must not spend the wake quota. */
+ releaseWake = async (id: string, window: string): Promise<void> => {
+ await this.db
+ .update(inboundWebhooks)
+ .set({ wakeCount: sql`greatest(0, ${inboundWebhooks.wakeCount} - 1)` })
+ .where(
+ and(
+ this.ownership(),
+ eq(inboundWebhooks.id, id),
+ sql`${inboundWebhooks.wakeWindowStartedAt} = ${window}::timestamptz`,
+ ),
+ );
+ };
+
+ /** Inbound routing is intentionally unscoped, then secrets are explicitly decrypted. */
+ static findForDelivery = async (
+ db: LobeChatDatabase,
+ id: string,
+ gateKeeper?: InboundWebhookGateKeeper | (() => Promise<InboundWebhookGateKeeper>),
+ ): Promise<{ row: InboundWebhookView; secret: string | null } | undefined> => {
+ const [row] = await db
+ .select()
+ .from(inboundWebhooks)
+ .where(eq(inboundWebhooks.id, id))
+ .limit(1);
+ if (!row || row.status === 'deleting') return undefined;
+ // Unknown retired kinds must stop delivery rather than throw from their absent parser.
+ if (!InboundWebhookDataSchema.safeParse(row).success) return undefined;
+ if (!row.secret) return { row: toView(row), secret: null };
+ const resolvedGateKeeper = typeof gateKeeper === 'function' ? await gateKeeper() : gateKeeper;
+ if (!resolvedGateKeeper) {
+ throw new Error(
+ 'InboundWebhookModel needs a gatekeeper (KEY_VAULTS_SECRET) to store or read secrets',
+ );
+ }
+ return { row: toView(row), secret: (await resolvedGateKeeper.decrypt(row.secret)).plaintext };
+ };
+
+ static queryMaintenance = async (
+ db: LobeChatDatabase,
+ limit = 100,
+ ): Promise<InboundWebhookView[]> => {
+ const rows = await db
+ .select(viewColumns)
+ .from(inboundWebhooks)
+ .where(
+ and(
+ lte(inboundWebhooks.nextMaintenanceAt, new Date()),
+ inArray(inboundWebhooks.status, ['active', 'error', 'deleting']),
+ ),
+ )
+ .orderBy(inboundWebhooks.nextMaintenanceAt)
+ .limit(limit);
+ return rows.map(validateView);
+ };
+
+ static queryStalePending = async (db: LobeChatDatabase): Promise<InboundWebhookView[]> => {
+ const rows = await db
+ .select(viewColumns)
+ .from(inboundWebhooks)
+ .where(
+ and(
+ eq(inboundWebhooks.status, 'pending'),
+ lt(inboundWebhooks.createdAt, new Date(Date.now() - 600_000)),
+ ),
+ )
+ .limit(100);
+ return rows.map(validateView);
+ };
+}
diff --git a/packages/database/src/schemas/connector.ts b/packages/database/src/schemas/connector.ts
index c9bbb088f0b..f4bd7a45324 100644
--- a/packages/database/src/schemas/connector.ts
+++ b/packages/database/src/schemas/connector.ts
@@ -151,6 +151,8 @@ export interface ConnectorMetadata {
* fails the call (`connectorDeviceBinding` in `@lobechat/utils/mcpEndpoint`).
*/
boundDeviceId?: string;
+ /** Protocol capabilities learned when connector tools are synchronized. */
+ capabilities?: { events?: { supported: boolean } };
composio?: ComposioConnectorMetadata;
/**
* HTTP only: `device` reaches the MCP server from the user's device through
diff --git a/packages/database/src/schemas/inboundWebhook.rowTypes.check.ts b/packages/database/src/schemas/inboundWebhook.rowTypes.check.ts
new file mode 100644
index 00000000000..6ac1a09ee12
--- /dev/null
+++ b/packages/database/src/schemas/inboundWebhook.rowTypes.check.ts
@@ -0,0 +1,13 @@
+import type { InboundWebhookInsert, InboundWebhookRow } from '@lobechat/types';
+
+import type { inboundWebhooks } from './inboundWebhook';
+
+type Equal<A, B> =
+ (<T>() => T extends A ? 1 : 2) extends <T>() => T extends B ? 1 : 2 ? true : false;
+type Assert<T extends true> = T;
+
+/** Fails to compile when the declared row contract and the table drift apart. */
+export type InboundWebhookRowTypesMatchSchema = [
+ Assert<Equal<InboundWebhookRow, typeof inboundWebhooks.$inferSelect>>,
+ Assert<Equal<InboundWebhookInsert, typeof inboundWebhooks.$inferInsert>>,
+];
diff --git a/packages/database/src/schemas/inboundWebhook.ts b/packages/database/src/schemas/inboundWebhook.ts
new file mode 100644
index 00000000000..806d417dc88
--- /dev/null
+++ b/packages/database/src/schemas/inboundWebhook.ts
@@ -0,0 +1,64 @@
+import type {
+ InboundWebhookConfig,
+ InboundWebhookError,
+ InboundWebhookKind,
+ InboundWebhookState,
+ InboundWebhookStatus,
+ InboundWebhookVerification,
+} from '@lobechat/types';
+import { sql } from 'drizzle-orm';
+import { index, integer, jsonb, pgTable, text, uniqueIndex, uuid } from 'drizzle-orm/pg-core';
+
+import { timestamps, timestamptz } from './_helpers';
+import { agents } from './agent';
+import { userConnectors } from './connector';
+import { topics } from './topic';
+import { users } from './user';
+import { workspaces } from './workspace';
+
+/** An authenticated inbound endpoint; kind owns its subscription protocol. */
+export const inboundWebhooks = pgTable(
+ 'inbound_webhooks',
+ {
+ id: uuid('id').defaultRandom().primaryKey().notNull(),
+ userId: text('user_id')
+ .references(() => users.id, { onDelete: 'cascade' })
+ .notNull(),
+ workspaceId: text('workspace_id').references(() => workspaces.id, { onDelete: 'cascade' }),
+ kind: text('kind').$type<InboundWebhookKind>().notNull(),
+ name: text('name'),
+ status: text('status').$type<InboundWebhookStatus>().notNull().default('pending'),
+ agentId: text('agent_id')
+ .references(() => agents.id, { onDelete: 'cascade' })
+ .notNull(),
+ topicId: text('topic_id').references(() => topics.id, { onDelete: 'cascade' }),
+ instructions: text('instructions'),
+ /** KeyVaults ciphertext, deliberately excluded from model read shapes. */
+ secret: text('secret'),
+ verification: jsonb('verification').$type<InboundWebhookVerification>().notNull(),
+ config: jsonb('config').$type<InboundWebhookConfig>().notNull(),
+ state: jsonb('state').$type<InboundWebhookState>().notNull().default({}),
+ connectorId: uuid('connector_id').references(() => userConnectors.id, { onDelete: 'cascade' }),
+ dedupeKey: text('dedupe_key'),
+ nextMaintenanceAt: timestamptz('next_maintenance_at'),
+ maintenanceFailures: integer('maintenance_failures').notNull().default(0),
+ lastDeliveryAt: timestamptz('last_delivery_at'),
+ lastError: text('last_error').$type<InboundWebhookError>(),
+ wakeCount: integer('wake_count').notNull().default(0),
+ wakeWindowStartedAt: timestamptz('wake_window_started_at').notNull().defaultNow(),
+ ...timestamps,
+ },
+ (t) => [
+ uniqueIndex('inbound_webhooks_user_kind_dedupe_unique')
+ .on(t.userId, t.kind, t.dedupeKey)
+ .where(sql`${t.dedupeKey} IS NOT NULL`),
+ index('inbound_webhooks_next_maintenance_idx')
+ .on(t.nextMaintenanceAt)
+ .where(sql`${t.nextMaintenanceAt} IS NOT NULL`),
+ index('inbound_webhooks_user_idx').on(t.userId),
+ index('inbound_webhooks_workspace_idx').on(t.workspaceId),
+ index('inbound_webhooks_topic_idx').on(t.topicId),
+ index('inbound_webhooks_agent_idx').on(t.agentId),
+ index('inbound_webhooks_connector_idx').on(t.connectorId),
+ ],
+);
diff --git a/packages/database/src/schemas/index.ts b/packages/database/src/schemas/index.ts
index f3ab74e1d31..ddc4333edbb 100644
--- a/packages/database/src/schemas/index.ts
+++ b/packages/database/src/schemas/index.ts
@@ -44,6 +44,7 @@ export * from './goalGraph';
export * from './goalShare';
export * from './goalSubscription';
export * from './goalTrace';
+export * from './inboundWebhook';
export * from './linear';
export * from './llmGenerationTracing';
export * from './meeting';
diff --git a/packages/types/src/inboundWebhook.ts b/packages/types/src/inboundWebhook.ts
new file mode 100644
index 00000000000..df3bceb052a
--- /dev/null
+++ b/packages/types/src/inboundWebhook.ts
@@ -0,0 +1,195 @@
+import { z } from 'zod';
+
+export const INBOUND_WEBHOOK_KINDS = ['mcp_events'] as const;
+export type InboundWebhookKind = (typeof INBOUND_WEBHOOK_KINDS)[number];
+
+export const INBOUND_WEBHOOK_STATUSES = [
+ 'pending',
+ 'active',
+ 'error',
+ 'terminated',
+ 'deleting',
+] as const;
+export type InboundWebhookStatus = (typeof INBOUND_WEBHOOK_STATUSES)[number];
+
+/** `last_error` 的取值。UI 按它映射可读文案,新增取值必须登记到契约。 */
+export const INBOUND_WEBHOOK_ERRORS = [
+ 'auth', // 连接器凭证失效,需要重新连接
+ 'connection_refused', // 以下六个是 server 报告的、向我们投递失败的类别(SEP 的 lastError)
+ 'timeout',
+ 'tls_error',
+ 'http_4xx',
+ 'http_5xx',
+ 'challenge_failed',
+ 'delivery_suspended', // server 已暂停投递
+ 'wake_cap', // 触发过于频繁,超过每小时限额
+ 'insufficient_budget', // 额度不足,无法运行 agent
+ 'access_revoked', // server 终止订阅:权限被撤销
+ 'event_unavailable', // server 终止订阅:事件类型被移除或不兼容变更
+ 'server_unreachable', // 检查 / 续订时连不上 MCP server
+ 'unknown',
+] as const;
+export type InboundWebhookError = (typeof INBOUND_WEBHOOK_ERRORS)[number];
+
+/** Errors a newly accepted event proves have recovered; excludes auth and agent execution failures. */
+export const INBOUND_WEBHOOK_DELIVERY_ERRORS = [
+ 'connection_refused',
+ 'timeout',
+ 'tls_error',
+ 'http_4xx',
+ 'http_5xx',
+ 'challenge_failed',
+ 'delivery_suspended',
+] as const satisfies readonly InboundWebhookError[];
+
+export interface McpEventsWebhookConfig {
+ arguments: Record<string, unknown>;
+ eventName: string;
+}
+
+export interface McpEventsWebhookState {
+ cursor?: string | null;
+ deliveryStatus?: {
+ active?: boolean;
+ failedSince?: string;
+ lastDeliveryAt?: string;
+ lastError?: string | null;
+ retryAfterMs?: number;
+ throttled?: boolean;
+ };
+ refreshBefore?: string | null; // null = 永不过期
+ remoteSubscriptionId?: string;
+ truncated?: boolean;
+}
+
+export type InboundWebhookVerification = { scheme: 'standard_webhooks' };
+
+/** 设置页列表与 `check` 返回的行。不含 secret,不含 state 原文。时间一律是 ISO 字符串。 */
+export interface InboundWebhookItem {
+ agent: {
+ avatar: string | null;
+ backgroundColor: string | null;
+ id: string;
+ title: string | null;
+ } | null;
+ /** 这个 kind 是否支持手动检查(v1:mcp_events 为 true) */
+ canCheck: boolean;
+ /** 当前用户能否删除 / 检查这一行 */
+ canManage: boolean;
+ connector: { avatar: string | null; id: string; identifier: string; name: string } | null;
+ createdAt: string;
+ creatorId: string;
+ /** mcp_events:server 授予的到期时间;null = 永不过期 */
+ expiresAt: string | null;
+ id: string;
+ kind: InboundWebhookKind;
+ lastDeliveryAt: string | null;
+ lastError: InboundWebhookError | null;
+ name: string | null;
+ source: { arguments: Record<string, unknown>; eventName: string; kind: 'mcp_events' };
+ /** 列表不返回 pending 与 deleting 的行 */
+ status: 'active' | 'error' | 'terminated';
+ topic: { id: string; title: string | null } | null;
+}
+
+/** Validation stays beside domain types so the standalone database layer owns no protocol logic. */
+export const McpEventsWebhookConfigSchema = z
+ .object({
+ arguments: z.record(z.string(), z.unknown()),
+ eventName: z.string().min(1),
+ })
+ .strict();
+
+export const McpEventsWebhookStateSchema = z
+ .object({
+ cursor: z.string().nullable().optional(),
+ deliveryStatus: z
+ .object({
+ active: z.boolean().optional(),
+ failedSince: z.string().optional(),
+ lastDeliveryAt: z.string().optional(),
+ lastError: z.string().nullable().optional(),
+ retryAfterMs: z.number().nonnegative().optional(),
+ throttled: z.boolean().optional(),
+ })
+ .optional(),
+ refreshBefore: z.iso.datetime({ offset: true }).nullable().optional(),
+ remoteSubscriptionId: z.string().optional(),
+ truncated: z.boolean().optional(),
+ })
+ .strict();
+
+export const InboundWebhookVerificationSchema = z
+ .object({
+ scheme: z.literal('standard_webhooks'),
+ })
+ .strict();
+
+export type InboundWebhookConfig = McpEventsWebhookConfig;
+export type InboundWebhookState = McpEventsWebhookState;
+
+export const InboundWebhookDataSchema = z.discriminatedUnion('kind', [
+ z.object({
+ kind: z.literal('mcp_events'),
+ config: McpEventsWebhookConfigSchema,
+ state: McpEventsWebhookStateSchema,
+ verification: InboundWebhookVerificationSchema,
+ }),
+]);
+
+/** One `inbound_webhooks` row, secret included; checked against the table in the schema package. */
+export interface InboundWebhookRow {
+ accessedAt: Date;
+ agentId: string;
+ config: InboundWebhookConfig;
+ connectorId: string | null;
+ createdAt: Date;
+ dedupeKey: string | null;
+ id: string;
+ instructions: string | null;
+ kind: InboundWebhookKind;
+ lastDeliveryAt: Date | null;
+ lastError: InboundWebhookError | null;
+ maintenanceFailures: number;
+ name: string | null;
+ nextMaintenanceAt: Date | null;
+ /** KeyVaults ciphertext; models leave it out of every read shape. */
+ secret: string | null;
+ state: InboundWebhookState;
+ status: InboundWebhookStatus;
+ topicId: string | null;
+ updatedAt: Date;
+ userId: string;
+ verification: InboundWebhookVerification;
+ wakeCount: number;
+ wakeWindowStartedAt: Date;
+ workspaceId: string | null;
+}
+
+/** What inserting an `inbound_webhooks` row takes; columns with a default are optional. */
+export interface InboundWebhookInsert {
+ accessedAt?: Date;
+ agentId: string;
+ config: InboundWebhookConfig;
+ connectorId?: string | null;
+ createdAt?: Date;
+ dedupeKey?: string | null;
+ id?: string;
+ instructions?: string | null;
+ kind: InboundWebhookKind;
+ lastDeliveryAt?: Date | null;
+ lastError?: InboundWebhookError | null;
+ maintenanceFailures?: number;
+ name?: string | null;
+ nextMaintenanceAt?: Date | null;
+ secret?: string | null;
+ state?: InboundWebhookState;
+ status?: InboundWebhookStatus;
+ topicId?: string | null;
+ updatedAt?: Date;
+ userId: string;
+ verification: InboundWebhookVerification;
+ wakeCount?: number;
+ wakeWindowStartedAt?: Date;
+ workspaceId?: string | null;
+}
diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts
index c1e9effb049..36d345994d0 100644
--- a/packages/types/src/index.ts
+++ b/packages/types/src/index.ts
@@ -96,6 +96,7 @@ export * from './acceptanceFlow';
export * from './acceptanceReview';
export * from './acceptanceReviewRound';
export * from './agentRuntime';
+export * from './inboundWebhook';
export * from './oauthApp';
export * from './openai/chat';
export * from './openai/plugin';