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 acceptance review rounds and marks tables (#22833)

Inneie0d7020441e7
diff --git a/docs/development/database-schema.dbml b/docs/development/database-schema.dbml
index 5850d5d1498..7b50358b82a 100644
--- a/docs/development/database-schema.dbml
+++ b/docs/development/database-schema.dbml
@@ -16,6 +16,7 @@ table acceptance_comments {
attachments jsonb
source jsonb
metadata jsonb
+ review_mark_id uuid
client_id text [not null]
resolved_at "timestamp with time zone"
resolved_by_user_id text
@@ -31,6 +32,7 @@ table acceptance_comments {
author_user_id [name: 'acceptance_comments_author_user_id_idx']
author_agent_id [name: 'acceptance_comments_author_agent_id_idx']
workspace_id [name: 'acceptance_comments_workspace_id_idx']
+ review_mark_id [name: 'acceptance_comments_review_mark_id_idx']
}
}
@@ -81,6 +83,58 @@ table acceptance_flows {
}
}
+table acceptance_review_marks {
+ id uuid [pk, not null, default: `gen_random_uuid()`]
+ review_id uuid [not null]
+ seq integer [not null]
+ kind text [not null]
+ url text [not null]
+ route_key text [not null]
+ page_meta jsonb
+ rect_document jsonb [not null]
+ rect_viewport jsonb [not null]
+ scroll jsonb [not null]
+ viewport jsonb [not null]
+ regions jsonb
+ region_refs jsonb
+ targets jsonb
+ sketch jsonb
+ context jsonb
+ screenshot_file_id text
+ content text [not null]
+ client_id text [not null]
+ created_at "timestamp with time zone" [not null, default: `now()`]
+ updated_at "timestamp with time zone" [not null, default: `now()`]
+
+ indexes {
+ (review_id, client_id) [name: 'acceptance_review_marks_review_id_client_id_unique', unique]
+ (review_id, seq) [name: 'acceptance_review_marks_review_id_seq_unique', unique]
+ (route_key, review_id) [name: 'acceptance_review_marks_route_key_review_id_idx']
+ }
+}
+
+table acceptance_reviews {
+ id uuid [pk, not null, default: `gen_random_uuid()`]
+ site_id text [not null]
+ user_id text
+ workspace_id text
+ project_id text
+ status text [not null, default: 'draft']
+ task_id text
+ last_mark_seq integer [not null, default: 0]
+ submitted_at "timestamp with time zone"
+ created_at "timestamp with time zone" [not null, default: `now()`]
+ updated_at "timestamp with time zone" [not null, default: `now()`]
+
+ indexes {
+ (site_id, created_at) [name: 'acceptance_reviews_site_id_created_at_idx']
+ task_id [name: 'acceptance_reviews_task_id_idx']
+ user_id [name: 'acceptance_reviews_user_id_idx']
+ workspace_id [name: 'acceptance_reviews_workspace_id_idx']
+ (site_id, user_id) [name: 'acceptance_reviews_one_draft_per_user_unique', unique]
+ }
+}
+
table agents {
id text [pk, not null]
slug varchar(100)
diff --git a/packages/database/migrations/0213_acceptance_review_rounds.sql b/packages/database/migrations/0213_acceptance_review_rounds.sql
new file mode 100644
index 00000000000..9ecaf575340
--- /dev/null
+++ b/packages/database/migrations/0213_acceptance_review_rounds.sql
@@ -0,0 +1,64 @@
+CREATE TABLE IF NOT EXISTS "acceptance_review_marks" (
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
+ "review_id" uuid NOT NULL,
+ "seq" integer NOT NULL,
+ "kind" text NOT NULL,
+ "url" text NOT NULL,
+ "route_key" text NOT NULL,
+ "page_meta" jsonb,
+ "rect_document" jsonb NOT NULL,
+ "rect_viewport" jsonb NOT NULL,
+ "scroll" jsonb NOT NULL,
+ "viewport" jsonb NOT NULL,
+ "regions" jsonb,
+ "region_refs" jsonb,
+ "targets" jsonb,
+ "sketch" jsonb,
+ "context" jsonb,
+ "screenshot_file_id" text,
+ "content" text NOT NULL,
+ "client_id" text NOT NULL,
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
+);
+--> statement-breakpoint
+CREATE TABLE IF NOT EXISTS "acceptance_reviews" (
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
+ "site_id" text NOT NULL,
+ "user_id" text,
+ "workspace_id" text,
+ "project_id" text,
+ "status" text DEFAULT 'draft' NOT NULL,
+ "task_id" text,
+ "last_mark_seq" integer DEFAULT 0 NOT NULL,
+ "submitted_at" timestamp with time zone,
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
+);
+--> statement-breakpoint
+ALTER TABLE "acceptance_comments" ADD COLUMN IF NOT EXISTS "review_mark_id" uuid;--> statement-breakpoint
+ALTER TABLE "acceptance_review_marks" DROP CONSTRAINT IF EXISTS "acceptance_review_marks_review_id_acceptance_reviews_id_fk";--> statement-breakpoint
+ALTER TABLE "acceptance_review_marks" ADD CONSTRAINT "acceptance_review_marks_review_id_acceptance_reviews_id_fk" FOREIGN KEY ("review_id") REFERENCES "public"."acceptance_reviews"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "acceptance_review_marks" DROP CONSTRAINT IF EXISTS "acceptance_review_marks_screenshot_file_id_files_id_fk";--> statement-breakpoint
+ALTER TABLE "acceptance_review_marks" ADD CONSTRAINT "acceptance_review_marks_screenshot_file_id_files_id_fk" FOREIGN KEY ("screenshot_file_id") REFERENCES "public"."files"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "acceptance_reviews" DROP CONSTRAINT IF EXISTS "acceptance_reviews_site_id_project_sites_id_fk";--> statement-breakpoint
+ALTER TABLE "acceptance_reviews" ADD CONSTRAINT "acceptance_reviews_site_id_project_sites_id_fk" FOREIGN KEY ("site_id") REFERENCES "public"."project_sites"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "acceptance_reviews" DROP CONSTRAINT IF EXISTS "acceptance_reviews_user_id_users_id_fk";--> statement-breakpoint
+ALTER TABLE "acceptance_reviews" ADD CONSTRAINT "acceptance_reviews_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "acceptance_reviews" DROP CONSTRAINT IF EXISTS "acceptance_reviews_workspace_id_workspaces_id_fk";--> statement-breakpoint
+ALTER TABLE "acceptance_reviews" ADD CONSTRAINT "acceptance_reviews_workspace_id_workspaces_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."workspaces"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "acceptance_reviews" DROP CONSTRAINT IF EXISTS "acceptance_reviews_project_id_projects_id_fk";--> statement-breakpoint
+ALTER TABLE "acceptance_reviews" ADD CONSTRAINT "acceptance_reviews_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "acceptance_reviews" DROP CONSTRAINT IF EXISTS "acceptance_reviews_task_id_tasks_id_fk";--> statement-breakpoint
+ALTER TABLE "acceptance_reviews" ADD CONSTRAINT "acceptance_reviews_task_id_tasks_id_fk" FOREIGN KEY ("task_id") REFERENCES "public"."tasks"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
+CREATE UNIQUE INDEX IF NOT EXISTS "acceptance_review_marks_review_id_client_id_unique" ON "acceptance_review_marks" USING btree ("review_id","client_id");--> statement-breakpoint
+CREATE UNIQUE INDEX IF NOT EXISTS "acceptance_review_marks_review_id_seq_unique" ON "acceptance_review_marks" USING btree ("review_id","seq");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "acceptance_review_marks_route_key_review_id_idx" ON "acceptance_review_marks" USING btree ("route_key","review_id");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "acceptance_reviews_site_id_created_at_idx" ON "acceptance_reviews" USING btree ("site_id","created_at");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "acceptance_reviews_task_id_idx" ON "acceptance_reviews" USING btree ("task_id");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "acceptance_reviews_user_id_idx" ON "acceptance_reviews" USING btree ("user_id");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "acceptance_reviews_workspace_id_idx" ON "acceptance_reviews" USING btree ("workspace_id");--> statement-breakpoint
+CREATE UNIQUE INDEX IF NOT EXISTS "acceptance_reviews_one_draft_per_user_unique" ON "acceptance_reviews" USING btree ("site_id","user_id") WHERE "acceptance_reviews"."status" = 'draft';--> statement-breakpoint
+ALTER TABLE "acceptance_comments" DROP CONSTRAINT IF EXISTS "acceptance_comments_review_mark_id_acceptance_review_marks_id_fk";--> statement-breakpoint
+ALTER TABLE "acceptance_comments" ADD CONSTRAINT "acceptance_comments_review_mark_id_acceptance_review_marks_id_fk" FOREIGN KEY ("review_mark_id") REFERENCES "public"."acceptance_review_marks"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "acceptance_comments_review_mark_id_idx" ON "acceptance_comments" USING btree ("review_mark_id");
diff --git a/packages/database/migrations/meta/0203_snapshot.json b/packages/database/migrations/meta/0213_snapshot.json
similarity index 96%
rename from packages/database/migrations/meta/0203_snapshot.json
rename to packages/database/migrations/meta/0213_snapshot.json
index 8a77d8c56ca..a0572c93cad 100644
--- a/packages/database/migrations/meta/0203_snapshot.json
+++ b/packages/database/migrations/meta/0213_snapshot.json
@@ -6,9 +6,9 @@
},
"dialect": "postgresql",
"enums": {},
- "id": "ebab7fa5-987a-48f1-81d0-c4262738714d",
+ "id": "46e3c4ea-97e4-4a8e-87d2-d89b786c7131",
"policies": {},
- "prevId": "285ec8a4-45bc-409c-adfc-993edac7a4f8",
+ "prevId": "839a7f65-d033-45df-8b5e-1f80a983f758",
"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",
@@ -2755,271 +3236,128 @@
"checkConstraints": {},
"isRLSEnabled": false
},
- "public.agent_eval_benchmarks": {
- "name": "agent_eval_benchmarks",
+ "public.agent_eval_memories": {
+ "name": "agent_eval_memories",
"schema": "",
"columns": {
"id": {
"name": "id",
- "type": "text",
+ "type": "uuid",
"primaryKey": true,
- "notNull": true
- },
- "identifier": {
- "name": "identifier",
- "type": "text",
- "primaryKey": false,
- "notNull": true
+ "notNull": true,
+ "default": "gen_random_uuid()"
},
- "name": {
- "name": "name",
+ "user_id": {
+ "name": "user_id",
"type": "text",
"primaryKey": false,
"notNull": true
},
- "description": {
- "name": "description",
+ "workspace_id": {
+ "name": "workspace_id",
"type": "text",
"primaryKey": false,
"notNull": false
},
- "rubrics": {
- "name": "rubrics",
- "type": "jsonb",
+ "run_id": {
+ "name": "run_id",
+ "type": "text",
"primaryKey": false,
"notNull": true
},
- "reference_url": {
- "name": "reference_url",
+ "topic_id": {
+ "name": "topic_id",
"type": "text",
"primaryKey": false,
"notNull": false
},
- "metadata": {
- "name": "metadata",
- "type": "jsonb",
- "primaryKey": false,
- "notNull": false
- },
- "user_id": {
- "name": "user_id",
+ "thread_id": {
+ "name": "thread_id",
"type": "text",
"primaryKey": false,
"notNull": false
},
- "workspace_id": {
- "name": "workspace_id",
+ "attempt_id": {
+ "name": "attempt_id",
"type": "text",
"primaryKey": false,
- "notNull": false
- },
- "is_system": {
- "name": "is_system",
- "type": "boolean",
- "primaryKey": false,
- "notNull": true,
- "default": true
+ "notNull": true
},
- "accessed_at": {
- "name": "accessed_at",
- "type": "timestamp with time zone",
+ "layer": {
+ "name": "layer",
+ "type": "text",
"primaryKey": false,
- "notNull": true,
- "default": "now()"
+ "notNull": true
},
- "created_at": {
- "name": "created_at",
- "type": "timestamp with time zone",
+ "source": {
+ "name": "source",
+ "type": "text",
"primaryKey": false,
- "notNull": true,
- "default": "now()"
+ "notNull": true
},
- "updated_at": {
- "name": "updated_at",
- "type": "timestamp with time zone",
+ "fixture_hash": {
+ "name": "fixture_hash",
+ "type": "text",
"primaryKey": false,
- "notNull": true,
- "default": "now()"
- }
- },
- "indexes": {
- "agent_eval_benchmarks_identifier_user_id_unique": {
- "name": "agent_eval_benchmarks_identifier_user_id_unique",
- "columns": [
- {
- "expression": "identifier",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"agent_eval_benchmarks\".\"workspace_id\" is null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "agent_eval_benchmarks_is_system_idx": {
- "name": "agent_eval_benchmarks_is_system_idx",
- "columns": [
- {
- "expression": "is_system",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "agent_eval_benchmarks_user_id_idx": {
- "name": "agent_eval_benchmarks_user_id_idx",
- "columns": [
- {
- "expression": "user_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "agent_eval_benchmarks_workspace_id_idx": {
- "name": "agent_eval_benchmarks_workspace_id_idx",
- "columns": [
- {
- "expression": "workspace_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": false,
- "concurrently": false,
- "method": "btree",
- "with": {}
- },
- "agent_eval_benchmarks_identifier_workspace_id_unique": {
- "name": "agent_eval_benchmarks_identifier_workspace_id_unique",
- "columns": [
- {
- "expression": "workspace_id",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "identifier",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- }
- ],
- "isUnique": true,
- "where": "\"agent_eval_benchmarks\".\"workspace_id\" is not null",
- "concurrently": false,
- "method": "btree",
- "with": {}
- }
- },
- "foreignKeys": {
- "agent_eval_benchmarks_user_id_users_id_fk": {
- "name": "agent_eval_benchmarks_user_id_users_id_fk",
- "tableFrom": "agent_eval_benchmarks",
- "tableTo": "users",
- "columnsFrom": ["user_id"],
- "columnsTo": ["id"],
- "onDelete": "cascade",
- "onUpdate": "no action"
+ "notNull": false
},
- "agent_eval_benchmarks_workspace_id_workspaces_id_fk": {
- "name": "agent_eval_benchmarks_workspace_id_workspaces_id_fk",
- "tableFrom": "agent_eval_benchmarks",
- "tableTo": "workspaces",
- "columnsFrom": ["workspace_id"],
- "columnsTo": ["id"],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {},
- "policies": {},
- "checkConstraints": {},
- "isRLSEnabled": false
- },
- "public.agent_eval_datasets": {
- "name": "agent_eval_datasets",
- "schema": "",
- "columns": {
- "id": {
- "name": "id",
+ "title": {
+ "name": "title",
"type": "text",
- "primaryKey": true,
- "notNull": true
+ "primaryKey": false,
+ "notNull": false
},
- "benchmark_id": {
- "name": "benchmark_id",
+ "summary": {
+ "name": "summary",
"type": "text",
"primaryKey": false,
"notNull": false
},
- "source_experiment_id": {
- "name": "source_experiment_id",
+ "details": {
+ "name": "details",
"type": "text",
"primaryKey": false,
"notNull": false
},
- "identifier": {
- "name": "identifier",
+ "memory_category": {
+ "name": "memory_category",
"type": "text",
"primaryKey": false,
- "notNull": true
+ "notNull": false
},
- "user_id": {
- "name": "user_id",
+ "memory_type": {
+ "name": "memory_type",
"type": "text",
"primaryKey": false,
"notNull": false
},
- "workspace_id": {
- "name": "workspace_id",
- "type": "text",
+ "tags": {
+ "name": "tags",
+ "type": "jsonb",
"primaryKey": false,
"notNull": false
},
- "name": {
- "name": "name",
- "type": "text",
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
"primaryKey": false,
"notNull": true
},
- "description": {
- "name": "description",
- "type": "text",
+ "embedding": {
+ "name": "embedding",
+ "type": "vector(1024)",
"primaryKey": false,
"notNull": false
},
- "eval_mode": {
- "name": "eval_mode",
- "type": "text",
+ "captured_at": {
+ "name": "captured_at",
+ "type": "timestamp with time zone",
"primaryKey": false,
- "notNull": false
+ "notNull": true
},
- "eval_config": {
- "name": "eval_config",
- "type": "jsonb",
+ "removed_reason": {
+ "name": "removed_reason",
+ "type": "text",
"primaryKey": false,
"notNull": false
},
@@ -3052,33 +3390,26 @@
}
},
"indexes": {
- "agent_eval_datasets_identifier_user_id_unique": {
- "name": "agent_eval_datasets_identifier_user_id_unique",
+ "agent_eval_memories_attempt_id_idx": {
+ "name": "agent_eval_memories_attempt_id_idx",
"columns": [
{
- "expression": "identifier",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
- },
- {
- "expression": "user_id",
+ "expression": "attempt_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
- "isUnique": true,
- "where": "\"agent_eval_datasets\".\"workspace_id\" is null",
+ "isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
- "agent_eval_datasets_benchmark_id_idx": {
- "name": "agent_eval_datasets_benchmark_id_idx",
+ "agent_eval_memories_run_id_idx": {
+ "name": "agent_eval_memories_run_id_idx",
"columns": [
{
- "expression": "benchmark_id",
+ "expression": "run_id",
"isExpression": false,
"asc": true,
"nulls": "last"
@@ -3089,11 +3420,11 @@
"method": "btree",
"with": {}
},
- "agent_eval_datasets_source_experiment_id_idx": {
- "name": "agent_eval_datasets_source_experiment_id_idx",
+ "agent_eval_memories_topic_id_idx": {
+ "name": "agent_eval_memories_topic_id_idx",
"columns": [
{
- "expression": "source_experiment_id",
+ "expression": "topic_id",
"isExpression": false,
"asc": true,
"nulls": "last"
@@ -3104,11 +3435,11 @@
"method": "btree",
"with": {}
},
- "agent_eval_datasets_user_id_idx": {
- "name": "agent_eval_datasets_user_id_idx",
+ "agent_eval_memories_thread_id_idx": {
+ "name": "agent_eval_memories_thread_id_idx",
"columns": [
{
- "expression": "user_id",
+ "expression": "thread_id",
"isExpression": false,
"asc": true,
"nulls": "last"
@@ -3119,11 +3450,11 @@
"method": "btree",
"with": {}
},
- "agent_eval_datasets_workspace_id_idx": {
- "name": "agent_eval_datasets_workspace_id_idx",
+ "agent_eval_memories_user_id_idx": {
+ "name": "agent_eval_memories_user_id_idx",
"columns": [
{
- "expression": "workspace_id",
+ "expression": "user_id",
"isExpression": false,
"asc": true,
"nulls": "last"
@@ -3134,64 +3465,66 @@
"method": "btree",
"with": {}
},
- "agent_eval_datasets_identifier_workspace_id_unique": {
- "name": "agent_eval_datasets_identifier_workspace_id_unique",
+ "agent_eval_memories_workspace_id_idx": {
+ "name": "agent_eval_memories_workspace_id_idx",
"columns": [
{
"expression": "workspace_id",
"isExpression": false,
"asc": true,
"nulls": "last"
- },
- {
- "expression": "identifier",
- "isExpression": false,
- "asc": true,
- "nulls": "last"
}
],
- "isUnique": true,
- "where": "\"agent_eval_datasets\".\"workspace_id\" is not null",
+ "isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
- "agent_eval_datasets_benchmark_id_agent_eval_benchmarks_id_fk": {
- "name": "agent_eval_datasets_benchmark_id_agent_eval_benchmarks_id_fk",
- "tableFrom": "agent_eval_datasets",
- "tableTo": "agent_eval_benchmarks",
- "columnsFrom": ["benchmark_id"],
+ "agent_eval_memories_user_id_users_id_fk": {
+ "name": "agent_eval_memories_user_id_users_id_fk",
+ "tableFrom": "agent_eval_memories",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
},
- "agent_eval_datasets_source_experiment_id_agent_eval_experiments_id_fk": {
- "name": "agent_eval_datasets_source_experiment_id_agent_eval_experiments_id_fk",
- "tableFrom": "agent_eval_datasets",
- "tableTo": "agent_eval_experiments",
- "columnsFrom": ["source_experiment_id"],
+ "agent_eval_memories_workspace_id_workspaces_id_fk": {
+ "name": "agent_eval_memories_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_eval_memories",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
"columnsTo": ["id"],
- "onDelete": "set null",
+ "onDelete": "cascade",
"onUpdate": "no action"
},
- "agent_eval_datasets_user_id_users_id_fk": {
- "name": "agent_eval_datasets_user_id_users_id_fk",
- "tableFrom": "agent_eval_datasets",
- "tableTo": "users",
- "columnsFrom": ["user_id"],
+ "agent_eval_memories_run_id_agent_eval_runs_id_fk": {
+ "name": "agent_eval_memories_run_id_agent_eval_runs_id_fk",
+ "tableFrom": "agent_eval_memories",
+ "tableTo": "agent_eval_runs",
+ "columnsFrom": ["run_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
},
- "agent_eval_datasets_workspace_id_workspaces_id_fk": {
- "name": "agent_eval_datasets_workspace_id_workspaces_id_fk",
- "tableFrom": "agent_eval_datasets",
- "tableTo": "workspaces",
- "columnsFrom": ["workspace_id"],
+ "agent_eval_memories_topic_id_topics_id_fk": {
+ "name": "agent_eval_memories_topic_id_topics_id_fk",
+ "tableFrom": "agent_eval_memories",
+ "tableTo": "topics",
+ "columnsFrom": ["topic_id"],
"columnsTo": ["id"],
- "onDelete": "cascade",
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "agent_eval_memories_thread_id_threads_id_fk": {
+ "name": "agent_eval_memories_thread_id_threads_id_fk",
+ "tableFrom": "agent_eval_memories",
+ "tableTo": "threads",
+ "columnsFrom": ["thread_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
"onUpdate": "no action"
}
},
@@ -3201,27 +3534,57 @@
"checkConstraints": {},
"isRLSEnabled": false
},
- "public.agent_eval_experiment_benchmarks": {
- "name": "agent_eval_experiment_benchmarks",
+ "public.agent_eval_benchmarks": {
+ "name": "agent_eval_benchmarks",
"schema": "",
"columns": {
- "experiment_id": {
- "name": "experiment_id",
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "identifier": {
+ "name": "identifier",
"type": "text",
"primaryKey": false,
"notNull": true
},
- "benchmark_id": {
- "name": "benchmark_id",
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
"type": "text",
"primaryKey": false,
+ "notNull": false
+ },
+ "rubrics": {
+ "name": "rubrics",
+ "type": "jsonb",
+ "primaryKey": false,
"notNull": true
},
+ "reference_url": {
+ "name": "reference_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
"user_id": {
"name": "user_id",
"type": "text",
"primaryKey": false,
- "notNull": true
+ "notNull": false
},
"workspace_id": {
"name": "workspace_id",
@@ -3229,20 +3592,63 @@
"primaryKey": false,
"notNull": false
},
+ "is_system": {
+ "name": "is_system",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
"created_at": {
"name": "created_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true,
"default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
}
},
"indexes": {
- "agent_eval_experiment_benchmarks_benchmark_id_idx": {
- "name": "agent_eval_experiment_benchmarks_benchmark_id_idx",
+ "agent_eval_benchmarks_identifier_user_id_unique": {
+ "name": "agent_eval_benchmarks_identifier_user_id_unique",
"columns": [
{
- "expression": "benchmark_id",
+ "expression": "identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_eval_benchmarks\".\"workspace_id\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_eval_benchmarks_is_system_idx": {
+ "name": "agent_eval_benchmarks_is_system_idx",
+ "columns": [
+ {
+ "expression": "is_system",
"isExpression": false,
"asc": true,
"nulls": "last"
@@ -3253,8 +3659,8 @@
"method": "btree",
"with": {}
},
- "agent_eval_experiment_benchmarks_user_id_idx": {
- "name": "agent_eval_experiment_benchmarks_user_id_idx",
+ "agent_eval_benchmarks_user_id_idx": {
+ "name": "agent_eval_benchmarks_user_id_idx",
"columns": [
{
"expression": "user_id",
@@ -3268,8 +3674,8 @@
"method": "btree",
"with": {}
},
- "agent_eval_experiment_benchmarks_workspace_id_idx": {
- "name": "agent_eval_experiment_benchmarks_workspace_id_idx",
+ "agent_eval_benchmarks_workspace_id_idx": {
+ "name": "agent_eval_benchmarks_workspace_id_idx",
"columns": [
{
"expression": "workspace_id",
@@ -3282,39 +3688,43 @@
"concurrently": false,
"method": "btree",
"with": {}
+ },
+ "agent_eval_benchmarks_identifier_workspace_id_unique": {
+ "name": "agent_eval_benchmarks_identifier_workspace_id_unique",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_eval_benchmarks\".\"workspace_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
}
},
"foreignKeys": {
- "agent_eval_experiment_benchmarks_experiment_id_agent_eval_experiments_id_fk": {
- "name": "agent_eval_experiment_benchmarks_experiment_id_agent_eval_experiments_id_fk",
- "tableFrom": "agent_eval_experiment_benchmarks",
- "tableTo": "agent_eval_experiments",
- "columnsFrom": ["experiment_id"],
- "columnsTo": ["id"],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "agent_eval_experiment_benchmarks_benchmark_id_agent_eval_benchmarks_id_fk": {
- "name": "agent_eval_experiment_benchmarks_benchmark_id_agent_eval_benchmarks_id_fk",
- "tableFrom": "agent_eval_experiment_benchmarks",
- "tableTo": "agent_eval_benchmarks",
- "columnsFrom": ["benchmark_id"],
- "columnsTo": ["id"],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "agent_eval_experiment_benchmarks_user_id_users_id_fk": {
- "name": "agent_eval_experiment_benchmarks_user_id_users_id_fk",
- "tableFrom": "agent_eval_experiment_benchmarks",
+ "agent_eval_benchmarks_user_id_users_id_fk": {
+ "name": "agent_eval_benchmarks_user_id_users_id_fk",
+ "tableFrom": "agent_eval_benchmarks",
"tableTo": "users",
"columnsFrom": ["user_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
},
- "agent_eval_experiment_benchmarks_workspace_id_workspaces_id_fk": {
- "name": "agent_eval_experiment_benchmarks_workspace_id_workspaces_id_fk",
- "tableFrom": "agent_eval_experiment_benchmarks",
+ "agent_eval_benchmarks_workspace_id_workspaces_id_fk": {
+ "name": "agent_eval_benchmarks_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_eval_benchmarks",
"tableTo": "workspaces",
"columnsFrom": ["workspace_id"],
"columnsTo": ["id"],
@@ -3322,19 +3732,14 @@
"onUpdate": "no action"
}
},
- "compositePrimaryKeys": {
- "agent_eval_experiment_benchmarks_experiment_id_benchmark_id_pk": {
- "name": "agent_eval_experiment_benchmarks_experiment_id_benchmark_id_pk",
- "columns": ["experiment_id", "benchmark_id"]
- }
- },
+ "compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
- "public.agent_eval_experiments": {
- "name": "agent_eval_experiments",
+ "public.agent_eval_datasets": {
+ "name": "agent_eval_datasets",
"schema": "",
"columns": {
"id": {
@@ -3343,11 +3748,29 @@
"primaryKey": true,
"notNull": true
},
+ "benchmark_id": {
+ "name": "benchmark_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_experiment_id": {
+ "name": "source_experiment_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
"user_id": {
"name": "user_id",
"type": "text",
"primaryKey": false,
- "notNull": true
+ "notNull": false
},
"workspace_id": {
"name": "workspace_id",
@@ -3367,6 +3790,18 @@
"primaryKey": false,
"notNull": false
},
+ "eval_mode": {
+ "name": "eval_mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "eval_config": {
+ "name": "eval_config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
"metadata": {
"name": "metadata",
"type": "jsonb",
@@ -3396,9 +3831,15 @@
}
},
"indexes": {
- "agent_eval_experiments_user_id_idx": {
- "name": "agent_eval_experiments_user_id_idx",
+ "agent_eval_datasets_identifier_user_id_unique": {
+ "name": "agent_eval_datasets_identifier_user_id_unique",
"columns": [
+ {
+ "expression": "identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
{
"expression": "user_id",
"isExpression": false,
@@ -3406,13 +3847,59 @@
"nulls": "last"
}
],
+ "isUnique": true,
+ "where": "\"agent_eval_datasets\".\"workspace_id\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_eval_datasets_benchmark_id_idx": {
+ "name": "agent_eval_datasets_benchmark_id_idx",
+ "columns": [
+ {
+ "expression": "benchmark_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
- "agent_eval_experiments_workspace_id_idx": {
- "name": "agent_eval_experiments_workspace_id_idx",
+ "agent_eval_datasets_source_experiment_id_idx": {
+ "name": "agent_eval_datasets_source_experiment_id_idx",
+ "columns": [
+ {
+ "expression": "source_experiment_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_eval_datasets_user_id_idx": {
+ "name": "agent_eval_datasets_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_eval_datasets_workspace_id_idx": {
+ "name": "agent_eval_datasets_workspace_id_idx",
"columns": [
{
"expression": "workspace_id",
@@ -3425,21 +3912,61 @@
"concurrently": false,
"method": "btree",
"with": {}
+ },
+ "agent_eval_datasets_identifier_workspace_id_unique": {
+ "name": "agent_eval_datasets_identifier_workspace_id_unique",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_eval_datasets\".\"workspace_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
}
},
"foreignKeys": {
- "agent_eval_experiments_user_id_users_id_fk": {
- "name": "agent_eval_experiments_user_id_users_id_fk",
- "tableFrom": "agent_eval_experiments",
+ "agent_eval_datasets_benchmark_id_agent_eval_benchmarks_id_fk": {
+ "name": "agent_eval_datasets_benchmark_id_agent_eval_benchmarks_id_fk",
+ "tableFrom": "agent_eval_datasets",
+ "tableTo": "agent_eval_benchmarks",
+ "columnsFrom": ["benchmark_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_eval_datasets_source_experiment_id_agent_eval_experiments_id_fk": {
+ "name": "agent_eval_datasets_source_experiment_id_agent_eval_experiments_id_fk",
+ "tableFrom": "agent_eval_datasets",
+ "tableTo": "agent_eval_experiments",
+ "columnsFrom": ["source_experiment_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "agent_eval_datasets_user_id_users_id_fk": {
+ "name": "agent_eval_datasets_user_id_users_id_fk",
+ "tableFrom": "agent_eval_datasets",
"tableTo": "users",
"columnsFrom": ["user_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
},
- "agent_eval_experiments_workspace_id_workspaces_id_fk": {
- "name": "agent_eval_experiments_workspace_id_workspaces_id_fk",
- "tableFrom": "agent_eval_experiments",
+ "agent_eval_datasets_workspace_id_workspaces_id_fk": {
+ "name": "agent_eval_datasets_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_eval_datasets",
"tableTo": "workspaces",
"columnsFrom": ["workspace_id"],
"columnsTo": ["id"],
@@ -3453,15 +3980,22 @@
"checkConstraints": {},
"isRLSEnabled": false
},
- "public.agent_eval_run_topics": {
- "name": "agent_eval_run_topics",
+ "public.agent_eval_environments": {
+ "name": "agent_eval_environments",
"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
+ "notNull": false
},
"workspace_id": {
"name": "workspace_id",
@@ -3469,47 +4003,42 @@
"primaryKey": false,
"notNull": false
},
- "run_id": {
- "name": "run_id",
- "type": "text",
- "primaryKey": false,
- "notNull": true
- },
- "topic_id": {
- "name": "topic_id",
+ "identifier": {
+ "name": "identifier",
"type": "text",
"primaryKey": false,
- "notNull": true
+ "notNull": false
},
- "test_case_id": {
- "name": "test_case_id",
+ "name": {
+ "name": "name",
"type": "text",
"primaryKey": false,
"notNull": true
},
- "status": {
- "name": "status",
+ "description": {
+ "name": "description",
"type": "text",
"primaryKey": false,
"notNull": false
},
- "score": {
- "name": "score",
- "type": "real",
+ "config": {
+ "name": "config",
+ "type": "jsonb",
"primaryKey": false,
- "notNull": false
+ "notNull": true
},
- "passed": {
- "name": "passed",
- "type": "boolean",
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
"primaryKey": false,
"notNull": false
},
- "eval_result": {
- "name": "eval_result",
- "type": "jsonb",
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
"primaryKey": false,
- "notNull": false
+ "notNull": true,
+ "default": "now()"
},
"created_at": {
"name": "created_at",
@@ -3517,11 +4046,18 @@
"primaryKey": false,
"notNull": true,
"default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
}
},
"indexes": {
- "agent_eval_run_topics_user_id_idx": {
- "name": "agent_eval_run_topics_user_id_idx",
+ "agent_eval_environments_user_id_idx": {
+ "name": "agent_eval_environments_user_id_idx",
"columns": [
{
"expression": "user_id",
@@ -3535,11 +4071,11 @@
"method": "btree",
"with": {}
},
- "agent_eval_run_topics_run_id_idx": {
- "name": "agent_eval_run_topics_run_id_idx",
+ "agent_eval_environments_workspace_id_idx": {
+ "name": "agent_eval_environments_workspace_id_idx",
"columns": [
{
- "expression": "run_id",
+ "expression": "workspace_id",
"isExpression": false,
"asc": true,
"nulls": "last"
@@ -3550,24 +4086,37 @@
"method": "btree",
"with": {}
},
- "agent_eval_run_topics_test_case_id_idx": {
- "name": "agent_eval_run_topics_test_case_id_idx",
+ "agent_eval_environments_identifier_user_id_unique": {
+ "name": "agent_eval_environments_identifier_user_id_unique",
"columns": [
{
- "expression": "test_case_id",
+ "expression": "identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
- "isUnique": false,
+ "isUnique": true,
+ "where": "\"agent_eval_environments\".\"identifier\" IS NOT NULL AND \"agent_eval_environments\".\"workspace_id\" IS NULL",
"concurrently": false,
"method": "btree",
"with": {}
},
- "agent_eval_run_topics_workspace_id_idx": {
- "name": "agent_eval_run_topics_workspace_id_idx",
+ "agent_eval_environments_identifier_workspace_id_unique": {
+ "name": "agent_eval_environments_identifier_workspace_id_unique",
"columns": [
+ {
+ "expression": "identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
{
"expression": "workspace_id",
"isExpression": false,
@@ -3575,64 +4124,471 @@
"nulls": "last"
}
],
- "isUnique": false,
+ "isUnique": true,
+ "where": "\"agent_eval_environments\".\"identifier\" IS NOT NULL AND \"agent_eval_environments\".\"workspace_id\" IS NOT NULL",
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
- "agent_eval_run_topics_user_id_users_id_fk": {
- "name": "agent_eval_run_topics_user_id_users_id_fk",
- "tableFrom": "agent_eval_run_topics",
+ "agent_eval_environments_user_id_users_id_fk": {
+ "name": "agent_eval_environments_user_id_users_id_fk",
+ "tableFrom": "agent_eval_environments",
"tableTo": "users",
"columnsFrom": ["user_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
},
- "agent_eval_run_topics_workspace_id_workspaces_id_fk": {
- "name": "agent_eval_run_topics_workspace_id_workspaces_id_fk",
- "tableFrom": "agent_eval_run_topics",
+ "agent_eval_environments_workspace_id_workspaces_id_fk": {
+ "name": "agent_eval_environments_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_eval_environments",
"tableTo": "workspaces",
"columnsFrom": ["workspace_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
- },
- "agent_eval_run_topics_run_id_agent_eval_runs_id_fk": {
- "name": "agent_eval_run_topics_run_id_agent_eval_runs_id_fk",
- "tableFrom": "agent_eval_run_topics",
- "tableTo": "agent_eval_runs",
- "columnsFrom": ["run_id"],
- "columnsTo": ["id"],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "agent_eval_run_topics_topic_id_topics_id_fk": {
- "name": "agent_eval_run_topics_topic_id_topics_id_fk",
- "tableFrom": "agent_eval_run_topics",
- "tableTo": "topics",
- "columnsFrom": ["topic_id"],
- "columnsTo": ["id"],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "agent_eval_run_topics_test_case_id_agent_eval_test_cases_id_fk": {
- "name": "agent_eval_run_topics_test_case_id_agent_eval_test_cases_id_fk",
- "tableFrom": "agent_eval_run_topics",
- "tableTo": "agent_eval_test_cases",
- "columnsFrom": ["test_case_id"],
- "columnsTo": ["id"],
- "onDelete": "cascade",
- "onUpdate": "no action"
}
},
- "compositePrimaryKeys": {
- "agent_eval_run_topics_run_id_topic_id_pk": {
- "name": "agent_eval_run_topics_run_id_topic_id_pk",
- "columns": ["run_id", "topic_id"]
- }
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_eval_experiment_benchmarks": {
+ "name": "agent_eval_experiment_benchmarks",
+ "schema": "",
+ "columns": {
+ "experiment_id": {
+ "name": "experiment_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "benchmark_id": {
+ "name": "benchmark_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_eval_experiment_benchmarks_benchmark_id_idx": {
+ "name": "agent_eval_experiment_benchmarks_benchmark_id_idx",
+ "columns": [
+ {
+ "expression": "benchmark_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_eval_experiment_benchmarks_user_id_idx": {
+ "name": "agent_eval_experiment_benchmarks_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_eval_experiment_benchmarks_workspace_id_idx": {
+ "name": "agent_eval_experiment_benchmarks_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_eval_experiment_benchmarks_experiment_id_agent_eval_experiments_id_fk": {
+ "name": "agent_eval_experiment_benchmarks_experiment_id_agent_eval_experiments_id_fk",
+ "tableFrom": "agent_eval_experiment_benchmarks",
+ "tableTo": "agent_eval_experiments",
+ "columnsFrom": ["experiment_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_eval_experiment_benchmarks_benchmark_id_agent_eval_benchmarks_id_fk": {
+ "name": "agent_eval_experiment_benchmarks_benchmark_id_agent_eval_benchmarks_id_fk",
+ "tableFrom": "agent_eval_experiment_benchmarks",
+ "tableTo": "agent_eval_benchmarks",
+ "columnsFrom": ["benchmark_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_eval_experiment_benchmarks_user_id_users_id_fk": {
+ "name": "agent_eval_experiment_benchmarks_user_id_users_id_fk",
+ "tableFrom": "agent_eval_experiment_benchmarks",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_eval_experiment_benchmarks_workspace_id_workspaces_id_fk": {
+ "name": "agent_eval_experiment_benchmarks_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_eval_experiment_benchmarks",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "agent_eval_experiment_benchmarks_experiment_id_benchmark_id_pk": {
+ "name": "agent_eval_experiment_benchmarks_experiment_id_benchmark_id_pk",
+ "columns": ["experiment_id", "benchmark_id"]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_eval_experiments": {
+ "name": "agent_eval_experiments",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_eval_experiments_user_id_idx": {
+ "name": "agent_eval_experiments_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_eval_experiments_workspace_id_idx": {
+ "name": "agent_eval_experiments_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_eval_experiments_user_id_users_id_fk": {
+ "name": "agent_eval_experiments_user_id_users_id_fk",
+ "tableFrom": "agent_eval_experiments",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_eval_experiments_workspace_id_workspaces_id_fk": {
+ "name": "agent_eval_experiments_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_eval_experiments",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_eval_run_topics": {
+ "name": "agent_eval_run_topics",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "run_id": {
+ "name": "run_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "topic_id": {
+ "name": "topic_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "test_case_id": {
+ "name": "test_case_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "score": {
+ "name": "score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "passed": {
+ "name": "passed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "eval_result": {
+ "name": "eval_result",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_eval_run_topics_user_id_idx": {
+ "name": "agent_eval_run_topics_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_eval_run_topics_run_id_idx": {
+ "name": "agent_eval_run_topics_run_id_idx",
+ "columns": [
+ {
+ "expression": "run_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_eval_run_topics_test_case_id_idx": {
+ "name": "agent_eval_run_topics_test_case_id_idx",
+ "columns": [
+ {
+ "expression": "test_case_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_eval_run_topics_workspace_id_idx": {
+ "name": "agent_eval_run_topics_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_eval_run_topics_user_id_users_id_fk": {
+ "name": "agent_eval_run_topics_user_id_users_id_fk",
+ "tableFrom": "agent_eval_run_topics",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_eval_run_topics_workspace_id_workspaces_id_fk": {
+ "name": "agent_eval_run_topics_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_eval_run_topics",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_eval_run_topics_run_id_agent_eval_runs_id_fk": {
+ "name": "agent_eval_run_topics_run_id_agent_eval_runs_id_fk",
+ "tableFrom": "agent_eval_run_topics",
+ "tableTo": "agent_eval_runs",
+ "columnsFrom": ["run_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_eval_run_topics_topic_id_topics_id_fk": {
+ "name": "agent_eval_run_topics_topic_id_topics_id_fk",
+ "tableFrom": "agent_eval_run_topics",
+ "tableTo": "topics",
+ "columnsFrom": ["topic_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_eval_run_topics_test_case_id_agent_eval_test_cases_id_fk": {
+ "name": "agent_eval_run_topics_test_case_id_agent_eval_test_cases_id_fk",
+ "tableFrom": "agent_eval_run_topics",
+ "tableTo": "agent_eval_test_cases",
+ "columnsFrom": ["test_case_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "agent_eval_run_topics_run_id_topic_id_pk": {
+ "name": "agent_eval_run_topics_run_id_topic_id_pk",
+ "columns": ["run_id", "topic_id"]
+ }
},
"uniqueConstraints": {},
"policies": {},
@@ -3921,7 +4877,7 @@
"name": "user_id",
"type": "text",
"primaryKey": false,
- "notNull": true
+ "notNull": false
},
"workspace_id": {
"name": "workspace_id",
@@ -3935,6 +4891,12 @@
"primaryKey": false,
"notNull": true
},
+ "environment_id": {
+ "name": "environment_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
"content": {
"name": "content",
"type": "jsonb",
@@ -4018,6 +4980,21 @@
"method": "btree",
"with": {}
},
+ "agent_eval_test_cases_environment_id_idx": {
+ "name": "agent_eval_test_cases_environment_id_idx",
+ "columns": [
+ {
+ "expression": "environment_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
"agent_eval_test_cases_sort_order_idx": {
"name": "agent_eval_test_cases_sort_order_idx",
"columns": [
@@ -4076,6 +5053,15 @@
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
+ },
+ "agent_eval_test_cases_environment_id_agent_eval_environments_id_fk": {
+ "name": "agent_eval_test_cases_environment_id_agent_eval_environments_id_fk",
+ "tableFrom": "agent_eval_test_cases",
+ "tableTo": "agent_eval_environments",
+ "columnsFrom": ["environment_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
@@ -4849,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": [
@@ -6856,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": [
@@ -10796,6 +11818,12 @@
"primaryKey": false,
"notNull": false
},
+ "wake": {
+ "name": "wake",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
"manifest": {
"name": "manifest",
"type": "jsonb",
@@ -17912,6 +18940,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",
@@ -22331,100 +23365,927 @@
}
},
"indexes": {
- "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",
+ "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": "user_id",
+ "expression": "meeting_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"
@@ -22436,8 +24297,8 @@
"checkConstraints": {},
"isRLSEnabled": false
},
- "public.llm_generation_tracing": {
- "name": "llm_generation_tracing",
+ "public.meetings": {
+ "name": "meetings",
"schema": "",
"columns": {
"id": {
@@ -22447,193 +24308,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",
+ "realtime_provider": {
+ "name": "realtime_provider",
"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
+ "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",
+ "audio_file_id": {
+ "name": "audio_file_id",
"type": "text",
"primaryKey": false,
"notNull": false
},
- "feedback_signal": {
- "name": "feedback_signal",
+ "local_audio_path": {
+ "name": "local_audio_path",
"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",
+ "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",
@@ -22641,149 +24415,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"
@@ -22794,26 +24452,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"
@@ -22824,11 +24473,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"
@@ -22841,14 +24490,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": {},
@@ -47217,11 +48884,18 @@
"notNull": true,
"default": "'pending'"
},
+ "reusable": {
+ "name": "reusable",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
"expires_at": {
"name": "expires_at",
"type": "timestamp with time zone",
"primaryKey": false,
- "notNull": true
+ "notNull": false
},
"created_at": {
"name": "created_at",
@@ -47329,7 +49003,12 @@
}
},
"policies": {},
- "checkConstraints": {},
+ "checkConstraints": {
+ "workspace_invitations_expiry_required": {
+ "name": "workspace_invitations_expiry_required",
+ "value": "\"workspace_invitations\".\"reusable\" OR \"workspace_invitations\".\"expires_at\" IS NOT NULL"
+ }
+ },
"isRLSEnabled": false
},
"public.workspace_members": {
@@ -47367,6 +49046,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 11ec60a9944..3f68a14162a 100644
--- a/packages/database/migrations/meta/_journal.json
+++ b/packages/database/migrations/meta/_journal.json
@@ -1491,7 +1491,14 @@
"when": 1794296581452,
"tag": "0212_workspace_member_config",
"breakpoints": true
+ },
+ {
+ "idx": 213,
+ "version": "7",
+ "when": 1794492684486,
+ "tag": "0213_acceptance_review_rounds",
+ "breakpoints": true
}
],
"version": "6"
-}
\ No newline at end of file
+}
diff --git a/packages/database/src/models/__tests__/acceptanceReview.test.ts b/packages/database/src/models/__tests__/acceptanceReview.test.ts
new file mode 100644
index 00000000000..eaa7bd57a7b
--- /dev/null
+++ b/packages/database/src/models/__tests__/acceptanceReview.test.ts
@@ -0,0 +1,188 @@
+// @vitest-environment node
+import { beforeEach, describe, expect, it } from 'vitest';
+
+import { getTestDB } from '../../core/getTestDB';
+import { ProjectRepository } from '../../repositories/project';
+import { tasks, users } from '../../schemas';
+import type { LobeChatDatabase } from '../../type';
+import { AcceptanceReviewModel } from '../acceptanceReview';
+import { ProjectSiteModel } from '../projectReview';
+
+const serverDB: LobeChatDatabase = await getTestDB();
+
+const owner = 'acceptance-review-owner';
+const reviewer = 'acceptance-review-reviewer';
+const model = new AcceptanceReviewModel(serverDB);
+
+let siteId: string;
+let projectId: string;
+
+const markInput = (
+ clientId: string,
+ content = 'Cards are too tight',
+ page = { routeKey: '/notebook', url: 'https://preview.example.com/notebook?tab=1' },
+) => ({
+ clientId,
+ content,
+ kind: 'region' as const,
+ pageMeta: { title: 'Fieldnotes' },
+ rectDocument: { height: 160, width: 384, x: 448, y: 1294 },
+ rectViewport: { height: 160, width: 384, x: 448, y: 494 },
+ scroll: { x: 0, y: 800 },
+ viewport: { dpr: 2, height: 800, width: 1280 },
+ ...page,
+});
+
+const settings = { routeKey: '/settings', url: 'https://preview.example.com/settings' };
+
+const draftOf = (userId: string) => model.createDraft({ projectId, siteId, userId });
+
+beforeEach(async () => {
+ await serverDB.delete(users);
+ await serverDB.insert(users).values([{ id: owner }, { id: reviewer }]);
+ const project = await new ProjectRepository(serverDB, owner).create({
+ identifier: 'FNT',
+ name: 'Fieldnotes',
+ });
+ projectId = project.id;
+ const site = await new ProjectSiteModel(serverDB).create({
+ name: 'Preview',
+ origins: ['https://preview.example.com'],
+ projectId,
+ });
+ siteId = site.id;
+});
+
+describe('AcceptanceReviewModel drafts', () => {
+ it('keeps one draft per user per site', async () => {
+ const first = await draftOf(reviewer);
+
+ await expect(draftOf(reviewer)).rejects.toThrow();
+
+ const other = await draftOf(owner);
+ expect(other.id).not.toBe(first.id);
+ expect((await model.findDraft(siteId, reviewer))?.id).toBe(first.id);
+ });
+
+ it('frees the draft slot once the draft is discarded', async () => {
+ const first = await draftOf(reviewer);
+ await model.discard(first.id);
+
+ expect(await model.findDraft(siteId, reviewer)).toBeUndefined();
+ expect((await draftOf(reviewer)).status).toBe('draft');
+ });
+});
+
+describe('AcceptanceReviewModel marks', () => {
+ it('numbers marks in order and never reuses a deleted number', async () => {
+ const review = await draftOf(reviewer);
+ const one = await model.addMark(review.id, markInput('a'));
+ const two = await model.addMark(review.id, markInput('b'));
+ await model.deleteMark(review.id, two!.id);
+ const three = await model.addMark(review.id, markInput('c'));
+
+ expect([one?.seq, two?.seq, three?.seq]).toEqual([1, 2, 3]);
+ expect((await model.listMarks(review.id)).map((mark) => mark.seq)).toEqual([1, 3]);
+ });
+
+ it('returns the stored mark when the same clientId is retried, without using a number', async () => {
+ const review = await draftOf(reviewer);
+ const first = await model.addMark(review.id, markInput('same'));
+ const retried = await model.addMark(review.id, markInput('same', 'changed on retry'));
+ const next = await model.addMark(review.id, markInput('next'));
+
+ expect(retried?.id).toBe(first?.id);
+ expect(retried?.content).toBe('Cards are too tight');
+ expect(next?.seq).toBe(2);
+ });
+
+ it('resolves overlapping retries of one clientId to a single mark', async () => {
+ const review = await draftOf(reviewer);
+ const [a, b] = await Promise.all([
+ model.addMark(review.id, markInput('overlap')),
+ model.addMark(review.id, markInput('overlap')),
+ ]);
+
+ expect(a?.id).toBe(b?.id);
+ expect(await model.listMarks(review.id)).toHaveLength(1);
+ });
+
+ it('refuses new marks once the review is submitted', async () => {
+ const review = await draftOf(reviewer);
+ const kept = await model.addMark(review.id, markInput('kept'));
+ await model.markSubmitted(review.id);
+
+ expect(await model.addMark(review.id, markInput('late'))).toBeUndefined();
+ expect((await model.addMark(review.id, markInput('kept')))?.id).toBe(kept?.id);
+ expect(await model.listMarks(review.id)).toHaveLength(1);
+ });
+
+ it('stores the page and geometry of each mark as given', async () => {
+ const review = await draftOf(reviewer);
+ await model.addMark(review.id, markInput('geo'));
+ const [stored] = await model.listMarks(review.id);
+
+ expect(stored.url).toBe('https://preview.example.com/notebook?tab=1');
+ expect(stored.routeKey).toBe('/notebook');
+ expect(stored.pageMeta).toEqual({ title: 'Fieldnotes' });
+ expect(stored.rectDocument).toEqual({ height: 160, width: 384, x: 448, y: 1294 });
+ expect(stored.scroll).toEqual({ x: 0, y: 800 });
+ expect(stored.viewport).toEqual({ dpr: 2, height: 800, width: 1280 });
+ });
+
+ it('updates content only while the review is a draft', async () => {
+ const review = await draftOf(reviewer);
+ const mark = await model.addMark(review.id, markInput('edit'));
+ const updated = await model.updateMark(review.id, mark!.id, { content: 'Line height 1.9' });
+ expect(updated?.content).toBe('Line height 1.9');
+
+ await model.markSubmitted(review.id);
+ expect(await model.updateMark(review.id, mark!.id, { content: 'late edit' })).toBeUndefined();
+ expect(await model.deleteMark(review.id, mark!.id)).toBe(false);
+ });
+});
+
+describe('AcceptanceReviewModel listing', () => {
+ it('lists only submitted reviews, newest first, on every page they have a mark on', async () => {
+ const draft = await draftOf(reviewer);
+ await model.addMark(draft.id, markInput('draft'));
+
+ const older = await draftOf(owner);
+ await model.addMark(older.id, markInput('older'));
+ await model.markSubmitted(older.id);
+
+ const crossPage = await draftOf(owner);
+ await model.addMark(crossPage.id, markInput('cross-1'));
+ await model.addMark(crossPage.id, markInput('cross-2', 'Empty state', settings));
+ await model.markSubmitted(crossPage.id);
+
+ const settingsOnly = await draftOf(owner);
+ await model.addMark(settingsOnly.id, markInput('settings', 'Title cut off', settings));
+ await model.markSubmitted(settingsOnly.id);
+
+ const ids = (rows: { id: string }[]) => rows.map((row) => row.id);
+ expect(ids(await model.listSubmitted(siteId, '/notebook'))).toEqual([crossPage.id, older.id]);
+ expect(ids(await model.listSubmitted(siteId, '/settings'))).toEqual([
+ settingsOnly.id,
+ crossPage.id,
+ ]);
+ expect(ids(await model.listSubmitted(siteId))).not.toContain(draft.id);
+ expect(await model.listSubmitted(siteId)).toHaveLength(3);
+ });
+
+ it('finds a review from the task it was submitted as', async () => {
+ const review = await draftOf(reviewer);
+ const [task] = await serverDB
+ .insert(tasks)
+ .values({
+ createdByUserId: reviewer,
+ identifier: 'FN-1',
+ instruction: 'Fix the marks',
+ seq: 1,
+ })
+ .returning();
+ await model.linkTask(review.id, task.id);
+
+ expect((await model.findByTask(task.id))?.id).toBe(review.id);
+ });
+});
diff --git a/packages/database/src/models/acceptanceReview.ts b/packages/database/src/models/acceptanceReview.ts
new file mode 100644
index 00000000000..5eb4244bdd9
--- /dev/null
+++ b/packages/database/src/models/acceptanceReview.ts
@@ -0,0 +1,344 @@
+import type {
+ AcceptanceReview,
+ AcceptanceReviewMark,
+ AcceptanceReviewMarkInput,
+ UpdateAcceptanceReviewMarkInput,
+} from '@lobechat/types';
+import {
+ and,
+ asc,
+ count,
+ desc,
+ eq,
+ exists,
+ inArray,
+ isNotNull,
+ isNull,
+ sql,
+ TransactionRollbackError,
+} from 'drizzle-orm';
+
+import { acceptanceComments } from '../schemas/acceptanceComment';
+import { acceptanceReviewMarks, acceptanceReviews } from '../schemas/acceptanceReview';
+import type { LobeChatDatabase } from '../type';
+
+export interface CreateAcceptanceReviewDraftParams {
+ projectId?: string | null;
+ siteId: string;
+ userId: string;
+ workspaceId?: string | null;
+}
+
+export interface AddAcceptanceReviewMarkParams extends AcceptanceReviewMarkInput {
+ screenshotFileId?: string;
+}
+
+const isDraft = (reviewId: string) =>
+ and(eq(acceptanceReviews.id, reviewId), eq(acceptanceReviews.status, 'draft'));
+
+export class AcceptanceReviewModel {
+ constructor(private readonly db: LobeChatDatabase) {}
+
+ createDraft = async (params: CreateAcceptanceReviewDraftParams) => {
+ const [row] = await this.db
+ .insert(acceptanceReviews)
+ .values({
+ projectId: params.projectId ?? null,
+ siteId: params.siteId,
+ status: 'draft',
+ userId: params.userId,
+ workspaceId: params.workspaceId ?? null,
+ })
+ .returning();
+ return row;
+ };
+
+ findById = async (id: string): Promise<AcceptanceReview | undefined> => {
+ const [row] = await this.db
+ .select()
+ .from(acceptanceReviews)
+ .where(eq(acceptanceReviews.id, id))
+ .limit(1);
+ return row;
+ };
+
+ findDraft = async (siteId: string, userId: string) => {
+ const [row] = await this.db
+ .select()
+ .from(acceptanceReviews)
+ .where(
+ and(
+ eq(acceptanceReviews.siteId, siteId),
+ eq(acceptanceReviews.userId, userId),
+ eq(acceptanceReviews.status, 'draft'),
+ ),
+ )
+ .limit(1);
+ return row;
+ };
+
+ findByTask = async (taskId: string) => {
+ const [row] = await this.db
+ .select()
+ .from(acceptanceReviews)
+ .where(eq(acceptanceReviews.taskId, taskId))
+ .limit(1);
+ return row;
+ };
+
+ listSubmitted = async (siteId: string, routeKey?: string) =>
+ this.db
+ .select()
+ .from(acceptanceReviews)
+ .where(
+ and(
+ eq(acceptanceReviews.siteId, siteId),
+ eq(acceptanceReviews.status, 'submitted'),
+ routeKey === undefined
+ ? undefined
+ : exists(
+ this.db
+ .select({ id: acceptanceReviewMarks.id })
+ .from(acceptanceReviewMarks)
+ .where(
+ and(
+ eq(acceptanceReviewMarks.reviewId, acceptanceReviews.id),
+ eq(acceptanceReviewMarks.routeKey, routeKey),
+ ),
+ ),
+ ),
+ ),
+ )
+ .orderBy(desc(acceptanceReviews.submittedAt), desc(acceptanceReviews.createdAt));
+
+ discard = async (reviewId: string) => {
+ const [row] = await this.db
+ .update(acceptanceReviews)
+ .set({ status: 'discarded' })
+ .where(isDraft(reviewId))
+ .returning();
+ if (row)
+ await this.db
+ .delete(acceptanceReviewMarks)
+ .where(eq(acceptanceReviewMarks.reviewId, reviewId));
+ return row;
+ };
+
+ markSubmitted = async (reviewId: string) => {
+ const [row] = await this.db
+ .update(acceptanceReviews)
+ .set({ status: 'submitted', submittedAt: sql`now()` })
+ .where(isDraft(reviewId))
+ .returning();
+ return row;
+ };
+
+ revertToDraft = async (reviewId: string) => {
+ const [row] = await this.db
+ .update(acceptanceReviews)
+ .set({ status: 'draft', submittedAt: null })
+ .where(and(eq(acceptanceReviews.id, reviewId), eq(acceptanceReviews.status, 'submitted')))
+ .returning();
+ return row;
+ };
+
+ linkTask = async (reviewId: string, taskId: string) => {
+ const [row] = await this.db
+ .update(acceptanceReviews)
+ .set({ taskId })
+ .where(eq(acceptanceReviews.id, reviewId))
+ .returning();
+ return row;
+ };
+
+ addMark = async (
+ reviewId: string,
+ params: AddAcceptanceReviewMarkParams,
+ ): Promise<AcceptanceReviewMark | undefined> => {
+ const inserted = await this.db
+ .transaction(async (tx) => {
+ const [counter] = await tx
+ .update(acceptanceReviews)
+ .set({ lastMarkSeq: sql`${acceptanceReviews.lastMarkSeq} + 1` })
+ .where(isDraft(reviewId))
+ .returning({ seq: acceptanceReviews.lastMarkSeq });
+ if (!counter) return undefined;
+
+ const [row] = await tx
+ .insert(acceptanceReviewMarks)
+ .values({
+ clientId: params.clientId,
+ content: params.content,
+ context: params.context,
+ kind: params.kind,
+ pageMeta: params.pageMeta,
+ rectDocument: params.rectDocument,
+ rectViewport: params.rectViewport,
+ regionRefs: params.regionRefs,
+ regions: params.regions,
+ reviewId,
+ routeKey: params.routeKey,
+ screenshotFileId: params.screenshotFileId,
+ scroll: params.scroll,
+ seq: counter.seq,
+ sketch: params.sketch,
+ targets: params.targets,
+ url: params.url,
+ viewport: params.viewport,
+ })
+ .onConflictDoNothing({
+ target: [acceptanceReviewMarks.reviewId, acceptanceReviewMarks.clientId],
+ })
+ .returning();
+ // A retry must not consume a number: rolling back returns the counter bump.
+ if (!row) tx.rollback();
+ return row;
+ })
+ .catch((error: unknown) => {
+ if (error instanceof TransactionRollbackError) return undefined;
+ throw error;
+ });
+ if (inserted) return inserted;
+
+ const [existing] = await this.db
+ .select()
+ .from(acceptanceReviewMarks)
+ .where(
+ and(
+ eq(acceptanceReviewMarks.reviewId, reviewId),
+ eq(acceptanceReviewMarks.clientId, params.clientId),
+ ),
+ )
+ .limit(1);
+ return existing;
+ };
+
+ updateMark = async (reviewId: string, markId: string, patch: UpdateAcceptanceReviewMarkInput) => {
+ const review = await this.findById(reviewId);
+ if (review?.status !== 'draft') return undefined;
+ const [row] = await this.db
+ .update(acceptanceReviewMarks)
+ .set(patch)
+ .where(
+ and(eq(acceptanceReviewMarks.id, markId), eq(acceptanceReviewMarks.reviewId, reviewId)),
+ )
+ .returning();
+ return row;
+ };
+
+ deleteMark = async (reviewId: string, markId: string) => {
+ const review = await this.findById(reviewId);
+ if (review?.status !== 'draft') return false;
+ const deleted = await this.db
+ .delete(acceptanceReviewMarks)
+ .where(
+ and(eq(acceptanceReviewMarks.id, markId), eq(acceptanceReviewMarks.reviewId, reviewId)),
+ )
+ .returning({ id: acceptanceReviewMarks.id });
+ return deleted.length > 0;
+ };
+
+ findMark = async (reviewId: string, markId: string) => {
+ const [row] = await this.db
+ .select()
+ .from(acceptanceReviewMarks)
+ .where(
+ and(eq(acceptanceReviewMarks.id, markId), eq(acceptanceReviewMarks.reviewId, reviewId)),
+ )
+ .limit(1);
+ return row;
+ };
+
+ listMarks = async (reviewId: string) =>
+ this.db
+ .select()
+ .from(acceptanceReviewMarks)
+ .where(eq(acceptanceReviewMarks.reviewId, reviewId))
+ .orderBy(asc(acceptanceReviewMarks.seq));
+
+ countMarks = async (reviewIds: string[]) => {
+ if (!reviewIds.length) return new Map<string, number>();
+ const rows = await this.db
+ .select({ n: count(), reviewId: acceptanceReviewMarks.reviewId })
+ .from(acceptanceReviewMarks)
+ .where(inArray(acceptanceReviewMarks.reviewId, reviewIds))
+ .groupBy(acceptanceReviewMarks.reviewId);
+ return new Map(rows.map((row) => [row.reviewId, Number(row.n)]));
+ };
+
+ countReplies = async (markIds: string[]) => {
+ if (!markIds.length) return new Map<string, number>();
+ const rows = await this.db
+ .select({ markId: acceptanceComments.reviewMarkId, n: count() })
+ .from(acceptanceComments)
+ .where(
+ and(
+ inArray(acceptanceComments.reviewMarkId, markIds),
+ isNull(acceptanceComments.deletedAt),
+ ),
+ )
+ .groupBy(acceptanceComments.reviewMarkId);
+ return new Map(rows.map((row) => [row.markId ?? '', Number(row.n)]));
+ };
+
+ addReply = async (
+ acceptanceId: string,
+ markId: string,
+ params: {
+ authorUserId: string;
+ clientId: string;
+ content: string;
+ workspaceId?: string | null;
+ },
+ ) => {
+ await this.db
+ .insert(acceptanceComments)
+ .values({
+ acceptanceId,
+ authorUserId: params.authorUserId,
+ clientId: params.clientId,
+ content: params.content,
+ reviewMarkId: markId,
+ workspaceId: params.workspaceId ?? null,
+ })
+ .onConflictDoNothing({
+ target: [
+ acceptanceComments.acceptanceId,
+ acceptanceComments.authorUserId,
+ acceptanceComments.clientId,
+ ],
+ });
+ const [row] = await this.db
+ .select()
+ .from(acceptanceComments)
+ .where(
+ and(
+ eq(acceptanceComments.acceptanceId, acceptanceId),
+ eq(acceptanceComments.authorUserId, params.authorUserId),
+ eq(acceptanceComments.clientId, params.clientId),
+ ),
+ )
+ .limit(1);
+ return row;
+ };
+
+ listReplies = async (markId: string) =>
+ this.db
+ .select()
+ .from(acceptanceComments)
+ .where(and(eq(acceptanceComments.reviewMarkId, markId), isNull(acceptanceComments.deletedAt)))
+ .orderBy(asc(acceptanceComments.createdAt), asc(acceptanceComments.id));
+
+ listReplyIds = async (acceptanceId: string) => {
+ const rows = await this.db
+ .select({ id: acceptanceComments.id })
+ .from(acceptanceComments)
+ .where(
+ and(
+ eq(acceptanceComments.acceptanceId, acceptanceId),
+ isNotNull(acceptanceComments.reviewMarkId),
+ ),
+ );
+ return new Set(rows.map((row) => row.id));
+ };
+}
diff --git a/packages/database/src/schemas/acceptanceComment.ts b/packages/database/src/schemas/acceptanceComment.ts
index a771c4498eb..56223489120 100644
--- a/packages/database/src/schemas/acceptanceComment.ts
+++ b/packages/database/src/schemas/acceptanceComment.ts
@@ -12,6 +12,7 @@ import { index, jsonb, pgTable, text, uniqueIndex, uuid } from 'drizzle-orm/pg-c
import { createNanoId } from '../utils/idGenerator';
import { createdAt, timestamptz, updatedAt } from './_helpers';
+import { acceptanceReviewMarks } from './acceptanceReview';
import { agents } from './agent';
import { users } from './user';
import { acceptances, verifyEvidence, verifyRuns } from './verify';
@@ -116,6 +117,13 @@ export const acceptanceComments = pgTable(
* Other producers' keys remain separate from this typed anchor.
*/
metadata: jsonb('metadata').$type<AcceptanceCommentMetadata>(),
+ /**
+ * Set on replies under a review mark. The mark itself carries the reviewer's
+ * remark; only the discussion under it lives in this table.
+ */
+ reviewMarkId: uuid('review_mark_id').references(() => acceptanceReviewMarks.id, {
+ onDelete: 'cascade',
+ }),
/** Client-generated idempotency key for retried creates. */
clientId: text('client_id').notNull(),
@@ -145,6 +153,7 @@ export const acceptanceComments = pgTable(
index('acceptance_comments_author_user_id_idx').on(t.authorUserId),
index('acceptance_comments_author_agent_id_idx').on(t.authorAgentId),
index('acceptance_comments_workspace_id_idx').on(t.workspaceId),
+ index('acceptance_comments_review_mark_id_idx').on(t.reviewMarkId),
],
);
diff --git a/packages/database/src/schemas/acceptanceReview.rowTypes.check.ts b/packages/database/src/schemas/acceptanceReview.rowTypes.check.ts
new file mode 100644
index 00000000000..d352d96038c
--- /dev/null
+++ b/packages/database/src/schemas/acceptanceReview.rowTypes.check.ts
@@ -0,0 +1,19 @@
+import type {
+ AcceptanceReview,
+ AcceptanceReviewInsert,
+ AcceptanceReviewMark,
+ AcceptanceReviewMarkInsert,
+} from '@lobechat/types';
+
+import type { acceptanceReviewMarks, acceptanceReviews } from './acceptanceReview';
+
+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;
+
+export type AcceptanceReviewRowTypesMatchSchema = [
+ Assert<Equal<AcceptanceReview, typeof acceptanceReviews.$inferSelect>>,
+ Assert<Equal<AcceptanceReviewInsert, typeof acceptanceReviews.$inferInsert>>,
+ Assert<Equal<AcceptanceReviewMark, typeof acceptanceReviewMarks.$inferSelect>>,
+ Assert<Equal<AcceptanceReviewMarkInsert, typeof acceptanceReviewMarks.$inferInsert>>,
+];
diff --git a/packages/database/src/schemas/acceptanceReview.ts b/packages/database/src/schemas/acceptanceReview.ts
new file mode 100644
index 00000000000..8acc9ee23d6
--- /dev/null
+++ b/packages/database/src/schemas/acceptanceReview.ts
@@ -0,0 +1,89 @@
+import type {
+ AcceptanceReviewMarkContext,
+ AcceptanceReviewMarkKind,
+ AcceptanceReviewPageMeta,
+ AcceptanceReviewRect,
+ AcceptanceReviewRegionRefs,
+ AcceptanceReviewSketch,
+ AcceptanceReviewStatus,
+ AcceptanceReviewTargets,
+} from '@lobechat/types';
+import { sql } from 'drizzle-orm';
+import { index, integer, jsonb, pgTable, text, uniqueIndex, uuid } from 'drizzle-orm/pg-core';
+
+import { createdAt, timestamptz, updatedAt } from './_helpers';
+import { files } from './file';
+import { projects } from './project';
+import { projectSites } from './projectReview';
+import { tasks } from './task';
+import { users } from './user';
+import { workspaces } from './workspace';
+
+export const acceptanceReviews = pgTable(
+ 'acceptance_reviews',
+ {
+ id: uuid('id').defaultRandom().primaryKey().notNull(),
+ siteId: text('site_id')
+ .references(() => projectSites.id, { onDelete: 'cascade' })
+ .notNull(),
+
+ userId: text('user_id').references(() => users.id, { onDelete: 'set null' }),
+ workspaceId: text('workspace_id').references(() => workspaces.id, { onDelete: 'cascade' }),
+ projectId: text('project_id').references(() => projects.id, { onDelete: 'set null' }),
+
+ status: text('status').$type<AcceptanceReviewStatus>().default('draft').notNull(),
+ taskId: text('task_id').references(() => tasks.id, { onDelete: 'set null' }),
+ lastMarkSeq: integer('last_mark_seq').default(0).notNull(),
+
+ submittedAt: timestamptz('submitted_at'),
+ createdAt: createdAt(),
+ updatedAt: updatedAt(),
+ },
+ (t) => [
+ index('acceptance_reviews_site_id_created_at_idx').on(t.siteId, t.createdAt),
+ index('acceptance_reviews_task_id_idx').on(t.taskId),
+ index('acceptance_reviews_user_id_idx').on(t.userId),
+ index('acceptance_reviews_workspace_id_idx').on(t.workspaceId),
+ uniqueIndex('acceptance_reviews_one_draft_per_user_unique')
+ .on(t.siteId, t.userId)
+ .where(sql`${t.status} = 'draft'`),
+ ],
+);
+
+export const acceptanceReviewMarks = pgTable(
+ 'acceptance_review_marks',
+ {
+ id: uuid('id').defaultRandom().primaryKey().notNull(),
+ reviewId: uuid('review_id')
+ .references(() => acceptanceReviews.id, { onDelete: 'cascade' })
+ .notNull(),
+
+ seq: integer('seq').notNull(),
+ kind: text('kind').$type<AcceptanceReviewMarkKind>().notNull(),
+ url: text('url').notNull(),
+ routeKey: text('route_key').notNull(),
+ pageMeta: jsonb('page_meta').$type<AcceptanceReviewPageMeta>(),
+ rectDocument: jsonb('rect_document').$type<AcceptanceReviewRect>().notNull(),
+ rectViewport: jsonb('rect_viewport').$type<AcceptanceReviewRect>().notNull(),
+ scroll: jsonb('scroll').$type<{ x: number; y: number }>().notNull(),
+ viewport: jsonb('viewport').$type<{ dpr: number; height: number; width: number }>().notNull(),
+ regions: jsonb('regions').$type<AcceptanceReviewRect[]>(),
+ regionRefs: jsonb('region_refs').$type<AcceptanceReviewRegionRefs>(),
+ targets: jsonb('targets').$type<AcceptanceReviewTargets>(),
+ sketch: jsonb('sketch').$type<AcceptanceReviewSketch>(),
+ context: jsonb('context').$type<AcceptanceReviewMarkContext>(),
+ screenshotFileId: text('screenshot_file_id').references(() => files.id, {
+ onDelete: 'set null',
+ }),
+ content: text('content').notNull(),
+ clientId: text('client_id').notNull(),
+
+ createdAt: createdAt(),
+ updatedAt: updatedAt(),
+ },
+ (t) => [
+ uniqueIndex('acceptance_review_marks_review_id_client_id_unique').on(t.reviewId, t.clientId),
+ uniqueIndex('acceptance_review_marks_review_id_seq_unique').on(t.reviewId, t.seq),
+ index('acceptance_review_marks_route_key_review_id_idx').on(t.routeKey, t.reviewId),
+ ],
+);
diff --git a/packages/database/src/schemas/index.ts b/packages/database/src/schemas/index.ts
index b8d744c711d..22bf7877b2a 100644
--- a/packages/database/src/schemas/index.ts
+++ b/packages/database/src/schemas/index.ts
@@ -1,5 +1,6 @@
export * from './acceptanceComment';
export * from './acceptanceFlow';
+export * from './acceptanceReview';
export * from './agent';
export * from './agentAccount';
export * from './agentBotProvider';
diff --git a/packages/types/src/acceptanceReviewRound.ts b/packages/types/src/acceptanceReviewRound.ts
new file mode 100644
index 00000000000..756987cc33a
--- /dev/null
+++ b/packages/types/src/acceptanceReviewRound.ts
@@ -0,0 +1,249 @@
+import { z } from 'zod';
+
+import { acceptanceReviewAnchorSchema } from './acceptanceReview';
+
+export const acceptanceReviewStatuses = ['draft', 'submitted', 'discarded'] as const;
+export type AcceptanceReviewStatus = (typeof acceptanceReviewStatuses)[number];
+
+export const acceptanceReviewPhases = [
+ 'draft',
+ 'running',
+ 'delivered',
+ 'accepted',
+ 'closed',
+] as const;
+export type AcceptanceReviewPhase = (typeof acceptanceReviewPhases)[number];
+
+export const acceptanceReviewMarkKinds = ['region', 'element', 'sketch'] as const;
+export type AcceptanceReviewMarkKind = (typeof acceptanceReviewMarkKinds)[number];
+
+const finite = z.number().finite();
+const rectSchema = z.object({ height: finite, width: finite, x: finite, y: finite });
+export type AcceptanceReviewRect = z.infer<typeof rectSchema>;
+
+const anchorShape = acceptanceReviewAnchorSchema.shape;
+
+interface SketchNodeShape {
+ children: SketchNodeShape[];
+ rect: AcceptanceReviewRect;
+ type: 'avatar' | 'button' | 'card' | 'image' | 'input' | 'text';
+}
+
+const sketchNodeSchema: z.ZodType<SketchNodeShape> = z.lazy(() =>
+ z.object({
+ children: z.array(sketchNodeSchema).max(50),
+ rect: rectSchema,
+ type: z.enum(['avatar', 'button', 'card', 'image', 'input', 'text']),
+ }),
+);
+
+export const acceptanceReviewMarkContextSchema = z.object({
+ commit: anchorShape.commit,
+ context: anchorShape.context,
+ env: anchorShape.env,
+});
+export type AcceptanceReviewMarkContext = z.infer<typeof acceptanceReviewMarkContextSchema>;
+
+export const acceptanceReviewPageMetaSchema = z.object({
+ description: z.string().max(500).optional(),
+ favicon: z.string().max(2000).optional(),
+ lang: z.string().max(35).optional(),
+ title: z.string().max(300).optional(),
+});
+export type AcceptanceReviewPageMeta = z.infer<typeof acceptanceReviewPageMetaSchema>;
+
+export const acceptanceReviewMarkInputSchema = z.object({
+ clientId: z.string().trim().min(1).max(255),
+ content: z.string().trim().min(1).max(4000),
+ context: acceptanceReviewMarkContextSchema.optional(),
+ kind: z.enum(acceptanceReviewMarkKinds),
+ pageMeta: acceptanceReviewPageMetaSchema.optional(),
+ rectDocument: rectSchema,
+ rectViewport: rectSchema,
+ regionRefs: anchorShape.regionRefs,
+ regions: z.array(rectSchema).max(6).optional(),
+ routeKey: z.string().max(500),
+ scroll: z.object({ x: finite, y: finite }),
+ sketch: z.array(sketchNodeSchema).max(50).optional(),
+ targets: anchorShape.targets.optional(),
+ url: z.string().url().max(2000),
+ viewport: z.object({ dpr: z.number().positive(), height: finite, width: finite }),
+});
+export type AcceptanceReviewMarkInput = z.infer<typeof acceptanceReviewMarkInputSchema>;
+
+export type AcceptanceReviewRegionRefs = NonNullable<AcceptanceReviewMarkInput['regionRefs']>;
+export type AcceptanceReviewTargets = NonNullable<AcceptanceReviewMarkInput['targets']>;
+export type AcceptanceReviewSketch = NonNullable<AcceptanceReviewMarkInput['sketch']>;
+
+type ReviewScroll = { x: number; y: number };
+type ReviewViewport = { dpr: number; height: number; width: number };
+
+export interface AcceptanceReview {
+ createdAt: Date;
+ id: string;
+ lastMarkSeq: number;
+ projectId: string | null;
+ siteId: string;
+ status: AcceptanceReviewStatus;
+ submittedAt: Date | null;
+ taskId: string | null;
+ updatedAt: Date;
+ userId: string | null;
+ workspaceId: string | null;
+}
+
+export interface AcceptanceReviewInsert {
+ createdAt?: Date;
+ id?: string;
+ lastMarkSeq?: number;
+ projectId?: string | null;
+ siteId: string;
+ status?: AcceptanceReviewStatus;
+ submittedAt?: Date | null;
+ taskId?: string | null;
+ updatedAt?: Date;
+ userId?: string | null;
+ workspaceId?: string | null;
+}
+
+export interface AcceptanceReviewMark {
+ clientId: string;
+ content: string;
+ context: AcceptanceReviewMarkContext | null;
+ createdAt: Date;
+ id: string;
+ kind: AcceptanceReviewMarkKind;
+ pageMeta: AcceptanceReviewPageMeta | null;
+ rectDocument: AcceptanceReviewRect;
+ rectViewport: AcceptanceReviewRect;
+ regionRefs: AcceptanceReviewRegionRefs | null;
+ regions: AcceptanceReviewRect[] | null;
+ reviewId: string;
+ routeKey: string;
+ screenshotFileId: string | null;
+ scroll: ReviewScroll;
+ seq: number;
+ sketch: AcceptanceReviewSketch | null;
+ targets: AcceptanceReviewTargets | null;
+ updatedAt: Date;
+ url: string;
+ viewport: ReviewViewport;
+}
+
+export interface AcceptanceReviewMarkInsert {
+ clientId: string;
+ content: string;
+ context?: AcceptanceReviewMarkContext | null;
+ createdAt?: Date;
+ id?: string;
+ kind: AcceptanceReviewMarkKind;
+ pageMeta?: AcceptanceReviewPageMeta | null;
+ rectDocument: AcceptanceReviewRect;
+ rectViewport: AcceptanceReviewRect;
+ regionRefs?: AcceptanceReviewRegionRefs | null;
+ regions?: AcceptanceReviewRect[] | null;
+ reviewId: string;
+ routeKey: string;
+ screenshotFileId?: string | null;
+ scroll: ReviewScroll;
+ seq: number;
+ sketch?: AcceptanceReviewSketch | null;
+ targets?: AcceptanceReviewTargets | null;
+ updatedAt?: Date;
+ url: string;
+ viewport: ReviewViewport;
+}
+
+export const ACCEPTANCE_REVIEW_MARK_MAX_BYTES = 64 * 1024;
+
+const screenshotSchema = z.object({
+ dataUrl: z.string().regex(/^data:image\/(jpeg|webp);base64,/),
+});
+
+export const createAcceptanceReviewMarkSchema = acceptanceReviewMarkInputSchema
+ .extend({ screenshot: screenshotSchema.optional() })
+ .refine(
+ ({ screenshot: _screenshot, ...mark }) =>
+ JSON.stringify(mark).length <= ACCEPTANCE_REVIEW_MARK_MAX_BYTES,
+ { message: 'Mark is too large' },
+ );
+
+export const updateAcceptanceReviewMarkSchema = z
+ .object({
+ content: z.string().trim().min(1).max(4000).optional(),
+ rectDocument: rectSchema.optional(),
+ rectViewport: rectSchema.optional(),
+ regionRefs: anchorShape.regionRefs,
+ regions: z.array(rectSchema).max(6).optional(),
+ })
+ .refine((value) => Object.values(value).some((field) => field !== undefined), {
+ message: 'Nothing to update',
+ });
+export type UpdateAcceptanceReviewMarkInput = z.infer<typeof updateAcceptanceReviewMarkSchema>;
+
+export const submitAcceptanceReviewSchema = z.object({
+ agentId: z.string().trim().min(1).max(255).optional(),
+ feedback: z.string().trim().max(4000).optional(),
+});
+export type SubmitAcceptanceReviewInput = z.infer<typeof submitAcceptanceReviewSchema>;
+
+export const acceptanceReviewMarkVerdicts = ['pass', 'not_fixed'] as const;
+export type AcceptanceReviewMarkVerdict = (typeof acceptanceReviewMarkVerdicts)[number];
+
+export const acceptanceReviewMarkVerdictSchema = z.object({
+ reason: z.string().trim().max(2000).optional(),
+ verdict: z.enum(acceptanceReviewMarkVerdicts),
+});
+
+export const createAcceptanceReviewReplySchema = z.object({
+ clientId: z.string().trim().min(1).max(255),
+ content: z.string().trim().min(1).max(4000),
+});
+
+export interface AcceptanceReviewUserDto {
+ avatar?: string;
+ id: string;
+ name: string;
+}
+
+export interface AcceptanceReviewMarkResult {
+ agent?: {
+ evidence: { url: string }[];
+ summary?: string;
+ verdict: 'fail' | 'pass' | 'uncertain';
+ };
+ human: AcceptanceReviewMarkVerdict | null;
+ missing: boolean;
+}
+
+export interface AcceptanceReviewMarkDto extends Omit<
+ AcceptanceReviewMarkInput,
+ 'clientId' | 'context'
+> {
+ clientId: string;
+ context?: AcceptanceReviewMarkContext;
+ createdAt: string;
+ id: string;
+ replyCount: number;
+ result?: AcceptanceReviewMarkResult;
+ screenshot: { url: string } | null;
+ seq: number;
+}
+
+export interface AcceptanceReviewDto {
+ counts: { agentPassed: number; humanPassed: number; marks: number };
+ createdAt: string;
+ id: string;
+ marks?: AcceptanceReviewMarkDto[];
+ mine: boolean;
+ phase: AcceptanceReviewPhase;
+ reportUrl: string | null;
+ status: AcceptanceReviewStatus;
+ submittedAt: string | null;
+ task: { id: string; identifier: string | null; name: string | null } | null;
+ user: AcceptanceReviewUserDto;
+}
+
+export interface AcceptanceReviewSourceLink {
+ reviewId: string;
+}
diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts
index 73f31e95a4d..d91266b545b 100644
--- a/packages/types/src/index.ts
+++ b/packages/types/src/index.ts
@@ -93,6 +93,7 @@ export * from './workspaceMember';
export * from './acceptanceComment';
export * from './acceptanceFlow';
export * from './acceptanceReview';
+export * from './acceptanceReviewRound';
export * from './agentRuntime';
export * from './oauthApp';
export * from './openai/chat';