diff --git a/.env.local.example b/.env.local.example
index 097692fe..525e9c90 100644
--- a/.env.local.example
+++ b/.env.local.example
@@ -17,8 +17,8 @@ KNOWHERE_BASE_URL=https://api.knowhereto.ai
# Vercel AI Gateway key; AI SDK picks it up automatically
AI_GATEWAY_API_KEY=vck_your_key_here
-# Optional override — defaults to deepseek/deepseek-v4-flash
-# CHAT_MODEL=deepseek/deepseek-v4-flash
+# Optional override — defaults to DeepSeek V4.1 Flash (native multimodal)
+# CHAT_MODEL=deepseek/deepseek-v4.1-flash
# --- Auth (server-side only) ---
#
diff --git a/drizzle/0019_large_invaders.sql b/drizzle/0019_large_invaders.sql
new file mode 100644
index 00000000..0580b654
--- /dev/null
+++ b/drizzle/0019_large_invaders.sql
@@ -0,0 +1,18 @@
+CREATE TABLE "folders" (
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
+ "workspace_id" uuid NOT NULL,
+ "parent_id" uuid,
+ "name" text NOT NULL,
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL,
+ "deleted_at" timestamp with time zone
+);
+--> statement-breakpoint
+ALTER TABLE "sources" ADD COLUMN "folder_id" uuid;--> statement-breakpoint
+ALTER TABLE "folders" ADD CONSTRAINT "folders_workspace_id_workspaces_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."workspaces"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "folders" ADD CONSTRAINT "folders_parent_id_folders_id_fk" FOREIGN KEY ("parent_id") REFERENCES "public"."folders"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
+CREATE INDEX "folders_workspace_parent_idx" ON "folders" USING btree ("workspace_id","parent_id");--> statement-breakpoint
+CREATE UNIQUE INDEX "folders_workspace_parent_name_idx" ON "folders" USING btree ("workspace_id","parent_id","name") WHERE deleted_at IS NULL AND parent_id IS NOT NULL;--> statement-breakpoint
+CREATE UNIQUE INDEX "folders_workspace_root_name_idx" ON "folders" USING btree ("workspace_id","name") WHERE deleted_at IS NULL AND parent_id IS NULL;--> statement-breakpoint
+ALTER TABLE "sources" ADD CONSTRAINT "sources_folder_id_folders_id_fk" FOREIGN KEY ("folder_id") REFERENCES "public"."folders"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
+CREATE INDEX "sources_workspace_folder_idx" ON "sources" USING btree ("workspace_id","folder_id") WHERE deleted_at IS NULL;
\ No newline at end of file
diff --git a/drizzle/0020_chat_message_agent_trace.sql b/drizzle/0020_chat_message_agent_trace.sql
new file mode 100644
index 00000000..8e2de62a
--- /dev/null
+++ b/drizzle/0020_chat_message_agent_trace.sql
@@ -0,0 +1 @@
+ALTER TABLE "chat_messages" ADD COLUMN "agent_trace" jsonb;
diff --git a/drizzle/meta/0019_snapshot.json b/drizzle/meta/0019_snapshot.json
new file mode 100644
index 00000000..3c97a48a
--- /dev/null
+++ b/drizzle/meta/0019_snapshot.json
@@ -0,0 +1,1136 @@
+{
+ "id": "325d2bfd-d4cf-4c41-baf2-b93fc91afa5e",
+ "prevId": "01b8a746-ca75-4e79-adab-098a03a39e0e",
+ "version": "7",
+ "dialect": "postgresql",
+ "tables": {
+ "public.chat_messages": {
+ "name": "chat_messages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "thread_id": {
+ "name": "thread_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "citations": {
+ "name": "citations",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "artifacts": {
+ "name": "artifacts",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "chat_messages_thread_created_idx": {
+ "name": "chat_messages_thread_created_idx",
+ "columns": [
+ {
+ "expression": "thread_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "chat_messages_thread_id_chat_threads_id_fk": {
+ "name": "chat_messages_thread_id_chat_threads_id_fk",
+ "tableFrom": "chat_messages",
+ "tableTo": "chat_threads",
+ "columnsFrom": [
+ "thread_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.chat_threads": {
+ "name": "chat_threads",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "demo_key": {
+ "name": "demo_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "chat_threads_workspace_updated_idx": {
+ "name": "chat_threads_workspace_updated_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "deleted_at IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "chat_threads_workspace_demo_key_idx": {
+ "name": "chat_threads_workspace_demo_key_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "demo_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "chat_threads_workspace_id_workspaces_id_fk": {
+ "name": "chat_threads_workspace_id_workspaces_id_fk",
+ "tableFrom": "chat_threads",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.demo_source_visibilities": {
+ "name": "demo_source_visibilities",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "demo_source_id": {
+ "name": "demo_source_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hidden_at": {
+ "name": "hidden_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deleted_at": {
+ "name": "deleted_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": {
+ "demo_source_visibilities_workspace_source_idx": {
+ "name": "demo_source_visibilities_workspace_source_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "demo_source_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "demo_source_visibilities_workspace_idx": {
+ "name": "demo_source_visibilities_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "demo_source_visibilities_workspace_id_workspaces_id_fk": {
+ "name": "demo_source_visibilities_workspace_id_workspaces_id_fk",
+ "tableFrom": "demo_source_visibilities",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.folders": {
+ "name": "folders",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "parent_id": {
+ "name": "parent_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "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()"
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "folders_workspace_parent_idx": {
+ "name": "folders_workspace_parent_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "parent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "folders_workspace_parent_name_idx": {
+ "name": "folders_workspace_parent_name_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "parent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "deleted_at IS NULL AND parent_id IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "folders_workspace_root_name_idx": {
+ "name": "folders_workspace_root_name_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "deleted_at IS NULL AND parent_id IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "folders_workspace_id_workspaces_id_fk": {
+ "name": "folders_workspace_id_workspaces_id_fk",
+ "tableFrom": "folders",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "folders_parent_id_folders_id_fk": {
+ "name": "folders_parent_id_folders_id_fk",
+ "tableFrom": "folders",
+ "tableTo": "folders",
+ "columnsFrom": [
+ "parent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.parsed_document_sync_leases": {
+ "name": "parsed_document_sync_leases",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_id": {
+ "name": "source_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "document_id": {
+ "name": "document_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revision_key": {
+ "name": "revision_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lease_token": {
+ "name": "lease_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "acquired_at": {
+ "name": "acquired_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "released_at": {
+ "name": "released_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "release_reason": {
+ "name": "release_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "parsed_document_sync_leases_token_idx": {
+ "name": "parsed_document_sync_leases_token_idx",
+ "columns": [
+ {
+ "expression": "lease_token",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "parsed_document_sync_leases_active_idx": {
+ "name": "parsed_document_sync_leases_active_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "released_at IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "parsed_document_sync_leases_workspace_active_idx": {
+ "name": "parsed_document_sync_leases_workspace_active_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "released_at IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "parsed_document_sync_leases_document_active_idx": {
+ "name": "parsed_document_sync_leases_document_active_idx",
+ "columns": [
+ {
+ "expression": "document_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "released_at IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "parsed_document_sync_leases_workspace_id_workspaces_id_fk": {
+ "name": "parsed_document_sync_leases_workspace_id_workspaces_id_fk",
+ "tableFrom": "parsed_document_sync_leases",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "parsed_document_sync_leases_source_id_sources_id_fk": {
+ "name": "parsed_document_sync_leases_source_id_sources_id_fk",
+ "tableFrom": "parsed_document_sync_leases",
+ "tableTo": "sources",
+ "columnsFrom": [
+ "source_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.source_parse_results": {
+ "name": "source_parse_results",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "source_id": {
+ "name": "source_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "result_blob_url": {
+ "name": "result_blob_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "snapshot_manifest_url": {
+ "name": "snapshot_manifest_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "snapshot_manifest_key": {
+ "name": "snapshot_manifest_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revision_key": {
+ "name": "revision_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sync_status": {
+ "name": "sync_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sync_error": {
+ "name": "sync_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "asset_urls": {
+ "name": "asset_urls",
+ "type": "jsonb",
+ "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": {
+ "source_parse_results_source_id_idx": {
+ "name": "source_parse_results_source_id_idx",
+ "columns": [
+ {
+ "expression": "source_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "source_parse_results_source_id_sources_id_fk": {
+ "name": "source_parse_results_source_id_sources_id_fk",
+ "tableFrom": "source_parse_results",
+ "tableTo": "sources",
+ "columnsFrom": [
+ "source_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "source_parse_results_source_id_unique": {
+ "name": "source_parse_results_source_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "source_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.sources": {
+ "name": "sources",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mime_type": {
+ "name": "mime_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "size_bytes": {
+ "name": "size_bytes",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "failure_reason": {
+ "name": "failure_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_stage": {
+ "name": "failure_stage",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "knowhere_job_id": {
+ "name": "knowhere_job_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "knowhere_document_id": {
+ "name": "knowhere_document_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "staged_blob_pathname": {
+ "name": "staged_blob_pathname",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "staged_blob_url": {
+ "name": "staged_blob_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_blob_pathname": {
+ "name": "original_blob_pathname",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_blob_url": {
+ "name": "original_blob_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "demo_key": {
+ "name": "demo_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "chunk_count": {
+ "name": "chunk_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "folder_id": {
+ "name": "folder_id",
+ "type": "uuid",
+ "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()"
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "sources_workspace_created_idx": {
+ "name": "sources_workspace_created_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "deleted_at IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "sources_workspace_status_idx": {
+ "name": "sources_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "sources_workspace_demo_key_idx": {
+ "name": "sources_workspace_demo_key_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "demo_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "sources_workspace_document_idx": {
+ "name": "sources_workspace_document_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "knowhere_document_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "knowhere_document_id IS NOT NULL AND deleted_at IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "sources_workspace_folder_idx": {
+ "name": "sources_workspace_folder_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "folder_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "deleted_at IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "sources_workspace_id_workspaces_id_fk": {
+ "name": "sources_workspace_id_workspaces_id_fk",
+ "tableFrom": "sources",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "sources_folder_id_folders_id_fk": {
+ "name": "sources_folder_id_folders_id_fk",
+ "tableFrom": "sources",
+ "tableTo": "folders",
+ "columnsFrom": [
+ "folder_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspaces": {
+ "name": "workspaces",
+ "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
+ },
+ "namespace": {
+ "name": "namespace",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspaces_user_id_idx": {
+ "name": "workspaces_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "workspaces_user_id_unique": {
+ "name": "workspaces_user_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id"
+ ]
+ },
+ "workspaces_namespace_unique": {
+ "name": "workspaces_namespace_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "namespace"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ }
+ },
+ "enums": {},
+ "schemas": {},
+ "sequences": {},
+ "roles": {},
+ "policies": {},
+ "views": {},
+ "_meta": {
+ "columns": {},
+ "schemas": {},
+ "tables": {}
+ }
+}
\ No newline at end of file
diff --git a/drizzle/meta/0020_snapshot.json b/drizzle/meta/0020_snapshot.json
new file mode 100644
index 00000000..46f86e06
--- /dev/null
+++ b/drizzle/meta/0020_snapshot.json
@@ -0,0 +1,1142 @@
+{
+ "id": "8f3c1a2e-6b4d-4c9a-9e11-2d7a5b0c4e18",
+ "prevId": "325d2bfd-d4cf-4c41-baf2-b93fc91afa5e",
+ "version": "7",
+ "dialect": "postgresql",
+ "tables": {
+ "public.chat_messages": {
+ "name": "chat_messages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "thread_id": {
+ "name": "thread_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "citations": {
+ "name": "citations",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "artifacts": {
+ "name": "artifacts",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_trace": {
+ "name": "agent_trace",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "chat_messages_thread_created_idx": {
+ "name": "chat_messages_thread_created_idx",
+ "columns": [
+ {
+ "expression": "thread_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "chat_messages_thread_id_chat_threads_id_fk": {
+ "name": "chat_messages_thread_id_chat_threads_id_fk",
+ "tableFrom": "chat_messages",
+ "tableTo": "chat_threads",
+ "columnsFrom": [
+ "thread_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.chat_threads": {
+ "name": "chat_threads",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "demo_key": {
+ "name": "demo_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "chat_threads_workspace_updated_idx": {
+ "name": "chat_threads_workspace_updated_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "deleted_at IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "chat_threads_workspace_demo_key_idx": {
+ "name": "chat_threads_workspace_demo_key_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "demo_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "chat_threads_workspace_id_workspaces_id_fk": {
+ "name": "chat_threads_workspace_id_workspaces_id_fk",
+ "tableFrom": "chat_threads",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.demo_source_visibilities": {
+ "name": "demo_source_visibilities",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "demo_source_id": {
+ "name": "demo_source_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hidden_at": {
+ "name": "hidden_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deleted_at": {
+ "name": "deleted_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": {
+ "demo_source_visibilities_workspace_source_idx": {
+ "name": "demo_source_visibilities_workspace_source_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "demo_source_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "demo_source_visibilities_workspace_idx": {
+ "name": "demo_source_visibilities_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "demo_source_visibilities_workspace_id_workspaces_id_fk": {
+ "name": "demo_source_visibilities_workspace_id_workspaces_id_fk",
+ "tableFrom": "demo_source_visibilities",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.folders": {
+ "name": "folders",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "parent_id": {
+ "name": "parent_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "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()"
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "folders_workspace_parent_idx": {
+ "name": "folders_workspace_parent_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "parent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "folders_workspace_parent_name_idx": {
+ "name": "folders_workspace_parent_name_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "parent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "deleted_at IS NULL AND parent_id IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "folders_workspace_root_name_idx": {
+ "name": "folders_workspace_root_name_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "deleted_at IS NULL AND parent_id IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "folders_workspace_id_workspaces_id_fk": {
+ "name": "folders_workspace_id_workspaces_id_fk",
+ "tableFrom": "folders",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "folders_parent_id_folders_id_fk": {
+ "name": "folders_parent_id_folders_id_fk",
+ "tableFrom": "folders",
+ "tableTo": "folders",
+ "columnsFrom": [
+ "parent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.parsed_document_sync_leases": {
+ "name": "parsed_document_sync_leases",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_id": {
+ "name": "source_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "document_id": {
+ "name": "document_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revision_key": {
+ "name": "revision_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lease_token": {
+ "name": "lease_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "acquired_at": {
+ "name": "acquired_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "released_at": {
+ "name": "released_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "release_reason": {
+ "name": "release_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "parsed_document_sync_leases_token_idx": {
+ "name": "parsed_document_sync_leases_token_idx",
+ "columns": [
+ {
+ "expression": "lease_token",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "parsed_document_sync_leases_active_idx": {
+ "name": "parsed_document_sync_leases_active_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "released_at IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "parsed_document_sync_leases_workspace_active_idx": {
+ "name": "parsed_document_sync_leases_workspace_active_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "released_at IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "parsed_document_sync_leases_document_active_idx": {
+ "name": "parsed_document_sync_leases_document_active_idx",
+ "columns": [
+ {
+ "expression": "document_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "released_at IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "parsed_document_sync_leases_workspace_id_workspaces_id_fk": {
+ "name": "parsed_document_sync_leases_workspace_id_workspaces_id_fk",
+ "tableFrom": "parsed_document_sync_leases",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "parsed_document_sync_leases_source_id_sources_id_fk": {
+ "name": "parsed_document_sync_leases_source_id_sources_id_fk",
+ "tableFrom": "parsed_document_sync_leases",
+ "tableTo": "sources",
+ "columnsFrom": [
+ "source_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.source_parse_results": {
+ "name": "source_parse_results",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "source_id": {
+ "name": "source_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "result_blob_url": {
+ "name": "result_blob_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "snapshot_manifest_url": {
+ "name": "snapshot_manifest_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "snapshot_manifest_key": {
+ "name": "snapshot_manifest_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revision_key": {
+ "name": "revision_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sync_status": {
+ "name": "sync_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sync_error": {
+ "name": "sync_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "asset_urls": {
+ "name": "asset_urls",
+ "type": "jsonb",
+ "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": {
+ "source_parse_results_source_id_idx": {
+ "name": "source_parse_results_source_id_idx",
+ "columns": [
+ {
+ "expression": "source_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "source_parse_results_source_id_sources_id_fk": {
+ "name": "source_parse_results_source_id_sources_id_fk",
+ "tableFrom": "source_parse_results",
+ "tableTo": "sources",
+ "columnsFrom": [
+ "source_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "source_parse_results_source_id_unique": {
+ "name": "source_parse_results_source_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "source_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.sources": {
+ "name": "sources",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mime_type": {
+ "name": "mime_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "size_bytes": {
+ "name": "size_bytes",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "failure_reason": {
+ "name": "failure_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failure_stage": {
+ "name": "failure_stage",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "knowhere_job_id": {
+ "name": "knowhere_job_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "knowhere_document_id": {
+ "name": "knowhere_document_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "staged_blob_pathname": {
+ "name": "staged_blob_pathname",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "staged_blob_url": {
+ "name": "staged_blob_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_blob_pathname": {
+ "name": "original_blob_pathname",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_blob_url": {
+ "name": "original_blob_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "demo_key": {
+ "name": "demo_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "chunk_count": {
+ "name": "chunk_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "folder_id": {
+ "name": "folder_id",
+ "type": "uuid",
+ "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()"
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "sources_workspace_created_idx": {
+ "name": "sources_workspace_created_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "deleted_at IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "sources_workspace_status_idx": {
+ "name": "sources_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "sources_workspace_demo_key_idx": {
+ "name": "sources_workspace_demo_key_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "demo_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "sources_workspace_document_idx": {
+ "name": "sources_workspace_document_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "knowhere_document_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "knowhere_document_id IS NOT NULL AND deleted_at IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "sources_workspace_folder_idx": {
+ "name": "sources_workspace_folder_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "folder_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "deleted_at IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "sources_workspace_id_workspaces_id_fk": {
+ "name": "sources_workspace_id_workspaces_id_fk",
+ "tableFrom": "sources",
+ "tableTo": "workspaces",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "sources_folder_id_folders_id_fk": {
+ "name": "sources_folder_id_folders_id_fk",
+ "tableFrom": "sources",
+ "tableTo": "folders",
+ "columnsFrom": [
+ "folder_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspaces": {
+ "name": "workspaces",
+ "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
+ },
+ "namespace": {
+ "name": "namespace",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspaces_user_id_idx": {
+ "name": "workspaces_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "workspaces_user_id_unique": {
+ "name": "workspaces_user_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id"
+ ]
+ },
+ "workspaces_namespace_unique": {
+ "name": "workspaces_namespace_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "namespace"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ }
+ },
+ "enums": {},
+ "schemas": {},
+ "sequences": {},
+ "roles": {},
+ "policies": {},
+ "views": {},
+ "_meta": {
+ "columns": {},
+ "schemas": {},
+ "tables": {}
+ }
+}
\ No newline at end of file
diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json
index 84390235..f76a3d20 100644
--- a/drizzle/meta/_journal.json
+++ b/drizzle/meta/_journal.json
@@ -134,6 +134,20 @@
"when": 1789118032723,
"tag": "0018_source_chunk_count",
"breakpoints": true
+ },
+ {
+ "idx": 19,
+ "version": "7",
+ "when": 1789124024330,
+ "tag": "0019_large_invaders",
+ "breakpoints": true
+ },
+ {
+ "idx": 20,
+ "version": "7",
+ "when": 1789910000000,
+ "tag": "0020_chat_message_agent_trace",
+ "breakpoints": true
}
]
}
\ No newline at end of file
diff --git a/package.json b/package.json
index 4ab25322..9e6a5931 100644
--- a/package.json
+++ b/package.json
@@ -29,7 +29,7 @@
"@modelcontextprotocol/sdk": "^1.30.0",
"@napi-rs/canvas": "^1.0.2",
"@neondatabase/serverless": "^1.1.0",
- "@ontos-ai/knowhere-sdk": "^2.2.0",
+ "@ontos-ai/knowhere-sdk": "^2.4.0",
"@radix-ui/react-alert-dialog": "^1.1.15",
"@radix-ui/react-checkbox": "^1.3.3",
"@radix-ui/react-dialog": "^1.1.15",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index d4db84c2..e76dbc5c 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -19,7 +19,7 @@ importers:
version: 0.96.1(effect@3.21.2)
'@modelcontextprotocol/sdk':
specifier: ^1.30.0
- version: 1.30.0(supports-color@7.2.0)(zod@4.4.3)
+ version: 1.30.0(zod@4.4.3)
'@napi-rs/canvas':
specifier: ^1.0.2
version: 1.0.2
@@ -27,8 +27,8 @@ importers:
specifier: ^1.1.0
version: 1.1.0
'@ontos-ai/knowhere-sdk':
- specifier: ^2.2.0
- version: 2.2.0(debug@4.4.3(supports-color@7.2.0))(supports-color@7.2.0)
+ specifier: ^2.4.0
+ version: 2.4.0
'@radix-ui/react-alert-dialog':
specifier: ^1.1.15
version: 1.1.15(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(react-dom@19.2.4(react@19.2.4))(react@19.2.4)
@@ -100,7 +100,7 @@ importers:
version: 1.12.0
next:
specifier: 16.2.4
- version: 16.2.4(@babel/core@7.29.0(supports-color@7.2.0))(@opentelemetry/api@1.9.0)(@playwright/test@1.58.2)(babel-plugin-react-compiler@1.0.0)(react-dom@19.2.4(react@19.2.4))(react@19.2.4)
+ version: 16.2.4(@babel/core@7.29.0)(@opentelemetry/api@1.9.0)(@playwright/test@1.58.2)(babel-plugin-react-compiler@1.0.0)(react-dom@19.2.4(react@19.2.4))(react@19.2.4)
next-themes:
specifier: ^0.4.6
version: 0.4.6(react-dom@19.2.4(react@19.2.4))(react@19.2.4)
@@ -124,13 +124,13 @@ importers:
version: 19.2.4(react@19.2.4)
react-markdown:
specifier: ^10.1.0
- version: 10.1.0(@types/react@19.2.14)(react@19.2.4)(supports-color@7.2.0)
+ version: 10.1.0(@types/react@19.2.14)(react@19.2.4)
react-pdf:
specifier: ^10.4.1
version: 10.4.1(@types/react@19.2.14)(react-dom@19.2.4(react@19.2.4))(react@19.2.4)
remark-gfm:
specifier: ^4.0.1
- version: 4.0.1(supports-color@7.2.0)
+ version: 4.0.1
server-only:
specifier: ^0.0.1
version: 0.0.1
@@ -185,16 +185,16 @@ importers:
version: 0.31.10
eslint:
specifier: ^9
- version: 9.39.4(jiti@2.7.0)(supports-color@7.2.0)
+ version: 9.39.4(jiti@2.7.0)
eslint-config-next:
specifier: 16.2.4
- version: 16.2.4(@typescript-eslint/parser@8.59.2(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3))(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)
+ version: 16.2.4(@typescript-eslint/parser@8.59.2(eslint@9.39.4(jiti@2.7.0))(typescript@6.0.3))(eslint@9.39.4(jiti@2.7.0))(typescript@6.0.3)
jsdom:
specifier: ^29.1.1
version: 29.1.1(@noble/hashes@1.8.0)
shadcn:
specifier: ^4.7.0
- version: 4.7.0(@types/node@20.19.39)(supports-color@7.2.0)(typescript@6.0.3)
+ version: 4.7.0(@types/node@20.19.39)(typescript@6.0.3)
tailwindcss:
specifier: ^4
version: 4.2.4
@@ -256,6 +256,10 @@ packages:
resolution: {integrity: sha512-9NhCeYjq9+3uxgdtp20LSiJXJvN0FeCtNGpJxuMFZ1Kv3cWUNb6DOhJwUvcVCzKGR66cw4njwM6hrJLqgOwbcw==}
engines: {node: '>=6.9.0'}
+ '@babel/code-frame@7.29.7':
+ resolution: {integrity: sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw==}
+ engines: {node: '>=6.9.0'}
+
'@babel/compat-data@7.29.3':
resolution: {integrity: sha512-LIVqM46zQWZhj17qA8wb4nW/ixr2y1Nw+r1etiAWgRM6U1IqP+LNhL1yg440jYZR72jCWcWbLWzIosH+uP1fqg==}
engines: {node: '>=6.9.0'}
@@ -326,6 +330,10 @@ packages:
resolution: {integrity: sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==}
engines: {node: '>=6.9.0'}
+ '@babel/helper-validator-identifier@7.29.7':
+ resolution: {integrity: sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==}
+ engines: {node: '>=6.9.0'}
+
'@babel/helper-validator-option@7.27.1':
resolution: {integrity: sha512-YvjJow9FxbhFFKDSuFnVCe2WxXk1zWc22fFePVNEaWJEu8IrZVlda6N0uHwzZrUM1il7NC9Mlp4MaJYbYd9JSg==}
engines: {node: '>=6.9.0'}
@@ -373,6 +381,10 @@ packages:
resolution: {integrity: sha512-JiDShH45zKHWyGe4ZNVRrCjBz8Nh9TMmZG1kh4QTK8hCBTWBi8Da+i7s1fJw7/lYpM4ccepSNfqzZ/QvABBi5g==}
engines: {node: '>=6.9.0'}
+ '@babel/runtime@7.29.7':
+ resolution: {integrity: sha512-Nq8OhGWiZIZGV6hLHoyAKLLcJihP/xFeBMGJoUrxTX2psI8dCifzLhZISFb+VWS3wFMRDmCGw5R+dOySCqPLhw==}
+ engines: {node: '>=6.9.0'}
+
'@babel/template@7.28.6':
resolution: {integrity: sha512-YA6Ma2KsCdGb+WC6UpBVFJGXL58MDA6oyONbjyF/+5sBgxY/dwkhLogbMT2GXXyU84/IhRw/2D1Os1B/giz+BQ==}
engines: {node: '>=6.9.0'}
@@ -1510,11 +1522,12 @@ packages:
'@napi-rs/wasm-runtime@0.2.12':
resolution: {integrity: sha512-ZVWUcfwY4E/yPitQJl481FjFo3K22D6qF0DuFH6Y/nbnE11GY5uguDxZMGXPQ8WQ0128MXQD7TnfHyK4oWoIJQ==}
- '@napi-rs/wasm-runtime@1.1.4':
- resolution: {integrity: sha512-3NQNNgA1YSlJb/kMH1ildASP9HW7/7kYnRI2szWJaofaS1hWmbGI4H+d3+22aGzXXN9IJ+n+GiFVcGipJP18ow==}
+ '@napi-rs/wasm-runtime@1.2.4':
+ resolution: {integrity: sha512-AJxoUD2/15ESHbvpcyjU274nsAPLuOtPHCk0vKJM5pj//Fg/B1FXNWjPnXTT9PymCYYiHo4zPj0ZomXBKhoy7g==}
+ engines: {node: ^20.19.0 || ^22.13.0 || >=23.5.0}
peerDependencies:
- '@emnapi/core': ^1.7.1
- '@emnapi/runtime': ^1.7.1
+ '@emnapi/core': ^1.7.1 || ^2.0.0-alpha.4
+ '@emnapi/runtime': ^1.7.1 || ^2.0.0-alpha.4
'@neondatabase/serverless@1.1.0':
resolution: {integrity: sha512-r3ZZhRjEcfEdKIZnoB1RusNgvHuaBRqfCzV4Gi+5A9yUX0S4HTws/ASWqt13wL4y4I+0rqsWGdA2w7EQXHi3+Q==}
@@ -1606,8 +1619,8 @@ packages:
resolution: {integrity: sha512-nn5ozdjYQpUCZlWGuxcJY/KpxkWQs4DcbMCmKojjyrYDEAGy4Ce19NN4v5MduafTwJlbKc99UA8YhSVqq9yPZA==}
engines: {node: '>=12.4.0'}
- '@ontos-ai/knowhere-sdk@2.2.0':
- resolution: {integrity: sha512-+kFykBxJ6BzcTAiyl7s7vgWO6Gtay7VH3n6/QLXRmemOjm8qk00gfE105wFFrkrkYzBXu4rFQaX5hxHM9uRWCA==}
+ '@ontos-ai/knowhere-sdk@2.4.0':
+ resolution: {integrity: sha512-yspXaftW66b8GcXxqyH425jkF8xx/iZGpDYrE2GQQACgumJJ6W4FrhipfRbiDHUEcsec3+NH6RvNQXA1VJ9d+g==}
engines: {node: '>=22.13.0', npm: '>=10.0.0', pnpm: '>=9.0.0'}
'@open-draft/deferred-promise@2.2.0':
@@ -2306,6 +2319,9 @@ packages:
'@tybys/wasm-util@0.10.2':
resolution: {integrity: sha512-RoBvJ2X0wuKlWFIjrwffGw1IqZHKQqzIchKaadZZfnNpsAYp2mM0h36JtPCjNDAHGgYez/15uMBpfGwchhiMgg==}
+ '@tybys/wasm-util@0.10.4':
+ resolution: {integrity: sha512-W3c4gRigFS0T/Ma4qIYF3GDAc5AQdHb1yL5znJT1Zv1YaD9Kitx656wBjvr19qbiosmZT8lWDM5BEMynUqX65A==}
+
'@types/aria-query@5.0.4':
resolution: {integrity: sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw==}
@@ -2735,8 +2751,8 @@ packages:
resolution: {integrity: sha512-KunSNx+TVpkAw/6ULfhnx+HWRecjqZGTOyquAoWHYLRSdK1tB5Ihce1ZW+UY3fj33bYAFWPu7W/GRSmmrCGuxA==}
engines: {node: '>=4'}
- axios@1.18.1:
- resolution: {integrity: sha512-3nTvFlvpn9Zu/RkHUqtc7/+al4UpRW5az71ap5zccp6e8RAYEzhMTecX8Dz1wWDYrPpUoB1HAQEGEAEvUr7S9g==}
+ axios@1.20.0:
+ resolution: {integrity: sha512-r8aOh8j9cGKpgQAqpzrUHnSIc6a59Y3Xf/cv8sy1DrHCkZHzQGEuoq1tARk6qSyDdtQGSDgpb9kFlruzPvrgwg==}
axobject-query@4.1.0:
resolution: {integrity: sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ==}
@@ -4098,6 +4114,9 @@ packages:
jszip@3.10.1:
resolution: {integrity: sha512-xXDvecyTpGLrqFrvkrUSoxxfJI5AH7U8zxxtVclpsUtMCq4JQ290LY8AW5c7Ggnr/Y/oK+bQMbqK2qmtk3pN4g==}
+ jszip@3.10.2:
+ resolution: {integrity: sha512-3l+rb15IOWtUhU0H5MFqES/T6Kh7abYwjosBey/vD6hDt8zoEffkSC5Ws5SGtgVw3gBx2NEbhTeSW1+kWkpyTQ==}
+
keyv@4.5.4:
resolution: {integrity: sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==}
@@ -4133,30 +4152,60 @@ packages:
cpu: [arm64]
os: [android]
+ lightningcss-android-arm64@1.33.0:
+ resolution: {integrity: sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg==}
+ engines: {node: '>= 12.0.0'}
+ cpu: [arm64]
+ os: [android]
+
lightningcss-darwin-arm64@1.32.0:
resolution: {integrity: sha512-RzeG9Ju5bag2Bv1/lwlVJvBE3q6TtXskdZLLCyfg5pt+HLz9BqlICO7LZM7VHNTTn/5PRhHFBSjk5lc4cmscPQ==}
engines: {node: '>= 12.0.0'}
cpu: [arm64]
os: [darwin]
+ lightningcss-darwin-arm64@1.33.0:
+ resolution: {integrity: sha512-Sciaz8eenNTKn9b3t7+xr0ipTp9YxKQY4npwQ3mrRuL0BAVHBLyZxofhaKBAVtzmtRZ/zTyo0/to4B1uWG/Djg==}
+ engines: {node: '>= 12.0.0'}
+ cpu: [arm64]
+ os: [darwin]
+
lightningcss-darwin-x64@1.32.0:
resolution: {integrity: sha512-U+QsBp2m/s2wqpUYT/6wnlagdZbtZdndSmut/NJqlCcMLTWp5muCrID+K5UJ6jqD2BFshejCYXniPDbNh73V8w==}
engines: {node: '>= 12.0.0'}
cpu: [x64]
os: [darwin]
+ lightningcss-darwin-x64@1.33.0:
+ resolution: {integrity: sha512-Z5UPAxzrjlWNNyGy6i65cJzzvgJ5D3T6wMvs+gWpY9d7qRhANrxqAp6LhxIgZhWEw18RfJTGcRxjuLIBr+m8XQ==}
+ engines: {node: '>= 12.0.0'}
+ cpu: [x64]
+ os: [darwin]
+
lightningcss-freebsd-x64@1.32.0:
resolution: {integrity: sha512-JCTigedEksZk3tHTTthnMdVfGf61Fky8Ji2E4YjUTEQX14xiy/lTzXnu1vwiZe3bYe0q+SpsSH/CTeDXK6WHig==}
engines: {node: '>= 12.0.0'}
cpu: [x64]
os: [freebsd]
+ lightningcss-freebsd-x64@1.33.0:
+ resolution: {integrity: sha512-QQM/Ti/hQajJwCY+RiWuCZ9sdtI/XQk7nDK5vC8kkdwixezOlDgvDx7+RT+QjK6FcFT4MpsuoBnHIo/O3StRRg==}
+ engines: {node: '>= 12.0.0'}
+ cpu: [x64]
+ os: [freebsd]
+
lightningcss-linux-arm-gnueabihf@1.32.0:
resolution: {integrity: sha512-x6rnnpRa2GL0zQOkt6rts3YDPzduLpWvwAF6EMhXFVZXD4tPrBkEFqzGowzCsIWsPjqSK+tyNEODUBXeeVHSkw==}
engines: {node: '>= 12.0.0'}
cpu: [arm]
os: [linux]
+ lightningcss-linux-arm-gnueabihf@1.33.0:
+ resolution: {integrity: sha512-N7FVBe6iS24MlM6R/4RBTxGhQheZGs7tiQ9U32UtF75NzP5Q7xWPRqLBCKxlRQRk3rY1jCIPLzx7WzOhuUIRLQ==}
+ engines: {node: '>= 12.0.0'}
+ cpu: [arm]
+ os: [linux]
+
lightningcss-linux-arm64-gnu@1.32.0:
resolution: {integrity: sha512-0nnMyoyOLRJXfbMOilaSRcLH3Jw5z9HDNGfT/gwCPgaDjnx0i8w7vBzFLFR1f6CMLKF8gVbebmkUN3fa/kQJpQ==}
engines: {node: '>= 12.0.0'}
@@ -4164,6 +4213,13 @@ packages:
os: [linux]
libc: [glibc]
+ lightningcss-linux-arm64-gnu@1.33.0:
+ resolution: {integrity: sha512-j2v/itmy4HlNxlc6voKXYgBqNi0Ng2LShg4z7GufpEgs05P+2suBVyi9I6YHq5uoVFx9ETin3eCEhLVyXGQnKg==}
+ engines: {node: '>= 12.0.0'}
+ cpu: [arm64]
+ os: [linux]
+ libc: [glibc]
+
lightningcss-linux-arm64-musl@1.32.0:
resolution: {integrity: sha512-UpQkoenr4UJEzgVIYpI80lDFvRmPVg6oqboNHfoH4CQIfNA+HOrZ7Mo7KZP02dC6LjghPQJeBsvXhJod/wnIBg==}
engines: {node: '>= 12.0.0'}
@@ -4171,6 +4227,13 @@ packages:
os: [linux]
libc: [musl]
+ lightningcss-linux-arm64-musl@1.33.0:
+ resolution: {integrity: sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ==}
+ engines: {node: '>= 12.0.0'}
+ cpu: [arm64]
+ os: [linux]
+ libc: [musl]
+
lightningcss-linux-x64-gnu@1.32.0:
resolution: {integrity: sha512-V7Qr52IhZmdKPVr+Vtw8o+WLsQJYCTd8loIfpDaMRWGUZfBOYEJeyJIkqGIDMZPwPx24pUMfwSxxI8phr/MbOA==}
engines: {node: '>= 12.0.0'}
@@ -4178,6 +4241,13 @@ packages:
os: [linux]
libc: [glibc]
+ lightningcss-linux-x64-gnu@1.33.0:
+ resolution: {integrity: sha512-ar+Ju7LmcN0Jo4FpL4hpFybwNG9/3A/Br5KW2n2jyODg3MEZXaDYADdemoNS+BDNfMgKvylJLj4S5tyRActuAg==}
+ engines: {node: '>= 12.0.0'}
+ cpu: [x64]
+ os: [linux]
+ libc: [glibc]
+
lightningcss-linux-x64-musl@1.32.0:
resolution: {integrity: sha512-bYcLp+Vb0awsiXg/80uCRezCYHNg1/l3mt0gzHnWV9XP1W5sKa5/TCdGWaR/zBM2PeF/HbsQv/j2URNOiVuxWg==}
engines: {node: '>= 12.0.0'}
@@ -4185,22 +4255,45 @@ packages:
os: [linux]
libc: [musl]
+ lightningcss-linux-x64-musl@1.33.0:
+ resolution: {integrity: sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw==}
+ engines: {node: '>= 12.0.0'}
+ cpu: [x64]
+ os: [linux]
+ libc: [musl]
+
lightningcss-win32-arm64-msvc@1.32.0:
resolution: {integrity: sha512-8SbC8BR40pS6baCM8sbtYDSwEVQd4JlFTOlaD3gWGHfThTcABnNDBda6eTZeqbofalIJhFx0qKzgHJmcPTnGdw==}
engines: {node: '>= 12.0.0'}
cpu: [arm64]
os: [win32]
+ lightningcss-win32-arm64-msvc@1.33.0:
+ resolution: {integrity: sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA==}
+ engines: {node: '>= 12.0.0'}
+ cpu: [arm64]
+ os: [win32]
+
lightningcss-win32-x64-msvc@1.32.0:
resolution: {integrity: sha512-Amq9B/SoZYdDi1kFrojnoqPLxYhQ4Wo5XiL8EVJrVsB8ARoC1PWW6VGtT0WKCemjy8aC+louJnjS7U18x3b06Q==}
engines: {node: '>= 12.0.0'}
cpu: [x64]
os: [win32]
+ lightningcss-win32-x64-msvc@1.33.0:
+ resolution: {integrity: sha512-OlEICDx/Xl0FqSp4bry8zFnCvGpig3Gl4gCquvYwHuqJKEC1+n9NgDniFvqHGmMv1ZkqDJrDqKKSykTDX+ehuA==}
+ engines: {node: '>= 12.0.0'}
+ cpu: [x64]
+ os: [win32]
+
lightningcss@1.32.0:
resolution: {integrity: sha512-NXYBzinNrblfraPGyrbPoD19C1h9lfI/1mzgWYvXUTe414Gz/X1FD2XBZSZM7rRTrMA8JL3OtAaGifrIKhQ5yQ==}
engines: {node: '>= 12.0.0'}
+ lightningcss@1.33.0:
+ resolution: {integrity: sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==}
+ engines: {node: '>= 12.0.0'}
+
lines-and-columns@1.2.4:
resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==}
@@ -4487,6 +4580,11 @@ packages:
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
hasBin: true
+ nanoid@3.3.19:
+ resolution: {integrity: sha512-Y2tUNy4ouw6tq5oDSKeQYGOyhkUBhNOcGV/02KC+6kd9eDGqdZd++mjMiIDilrBYvjEnCYvVtsuHCuP+okSfug==}
+ engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
+ hasBin: true
+
napi-postinstall@0.3.4:
resolution: {integrity: sha512-PHI5f1O0EP5xJ9gQmFGMS6IZcrVvTjpXjz7Na41gTE7eE2hK11lg04CECCYEEjdc17EV4DO+fkGEtt7TpTaTiQ==}
engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0}
@@ -4713,6 +4811,10 @@ packages:
resolution: {integrity: sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==}
engines: {node: '>=12'}
+ picomatch@4.0.7:
+ resolution: {integrity: sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==}
+ engines: {node: '>=12'}
+
piscina@5.2.0:
resolution: {integrity: sha512-DszUCKeVN/5G5QKo6jAVHL8fmKnkJvQ0ACiVgY7YGCq3TUB2oznAOayvZPIAdEThvhczkXR+qm3IHsNXpFCYfA==}
engines: {node: '>=20.x'}
@@ -4747,6 +4849,10 @@ packages:
resolution: {integrity: sha512-SoSL4+OSEtR99LHFZQiJLkT59C5B1amGO1NzTwj7TT1qCUgUO6hxOvzkOYxD+vMrXBM3XJIKzokoERdqQq/Zmg==}
engines: {node: ^10 || ^12 || >=14}
+ postcss@8.5.28:
+ resolution: {integrity: sha512-RRuzqDtt5Y9h3quz5hWhK+TPnsmVs6WwSU6LkJMeY4HstUEDuYTG8UJSdawMRzmzAtV+KEoG8N3Qg2qLy5vM/A==}
+ engines: {node: ^10 || ^12 || >=14}
+
postgres@3.4.9:
resolution: {integrity: sha512-GD3qdB0x1z9xgFI6cdRD6xu2Sp2WCOEoe3mtnyB5Ee0XrrL5Pe+e4CCnJrRMnL1zYtRDZmQQVbvOttLnKDLnaw==}
engines: {node: '>=12'}
@@ -5250,6 +5356,10 @@ packages:
resolution: {integrity: sha512-pn99VhoACYR8nFHhxqix+uvsbXineAasWm5ojXoN8xEwK5Kd3/TrhNn1wByuD52UxWRLy8pu+kRMniEi6Eq9Zg==}
engines: {node: '>=12.0.0'}
+ tinyglobby@0.2.17:
+ resolution: {integrity: sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==}
+ engines: {node: '>=12.0.0'}
+
tinyrainbow@3.1.0:
resolution: {integrity: sha512-Bf+ILmBgretUrdJxzXM0SgXLZ3XfiaUuOj/IKQHuTXip+05Xn+uyEYdVg0kYDipTBcLrCVyUzAPz7QmArb0mmw==}
engines: {node: '>=14.0.0'}
@@ -5737,22 +5847,28 @@ snapshots:
js-tokens: 4.0.0
picocolors: 1.1.1
+ '@babel/code-frame@7.29.7':
+ dependencies:
+ '@babel/helper-validator-identifier': 7.29.7
+ js-tokens: 4.0.0
+ picocolors: 1.1.1
+
'@babel/compat-data@7.29.3': {}
- '@babel/core@7.29.0(supports-color@7.2.0)':
+ '@babel/core@7.29.0':
dependencies:
'@babel/code-frame': 7.29.0
'@babel/generator': 7.29.1
'@babel/helper-compilation-targets': 7.28.6
- '@babel/helper-module-transforms': 7.28.6(@babel/core@7.29.0(supports-color@7.2.0))(supports-color@7.2.0)
+ '@babel/helper-module-transforms': 7.28.6(@babel/core@7.29.0)
'@babel/helpers': 7.29.2
'@babel/parser': 7.29.3
'@babel/template': 7.28.6
- '@babel/traverse': 7.29.0(supports-color@7.2.0)
+ '@babel/traverse': 7.29.0
'@babel/types': 7.29.0
'@jridgewell/remapping': 2.3.5
convert-source-map: 2.0.0
- debug: 4.4.3(supports-color@7.2.0)
+ debug: 4.4.3
gensync: 1.0.0-beta.2
json5: 2.2.3
semver: 6.3.1
@@ -5779,41 +5895,41 @@ snapshots:
lru-cache: 5.1.1
semver: 6.3.1
- '@babel/helper-create-class-features-plugin@7.29.3(@babel/core@7.29.0(supports-color@7.2.0))(supports-color@7.2.0)':
+ '@babel/helper-create-class-features-plugin@7.29.3(@babel/core@7.29.0)':
dependencies:
- '@babel/core': 7.29.0(supports-color@7.2.0)
+ '@babel/core': 7.29.0
'@babel/helper-annotate-as-pure': 7.27.3
- '@babel/helper-member-expression-to-functions': 7.28.5(supports-color@7.2.0)
+ '@babel/helper-member-expression-to-functions': 7.28.5
'@babel/helper-optimise-call-expression': 7.27.1
- '@babel/helper-replace-supers': 7.28.6(@babel/core@7.29.0(supports-color@7.2.0))(supports-color@7.2.0)
- '@babel/helper-skip-transparent-expression-wrappers': 7.27.1(supports-color@7.2.0)
- '@babel/traverse': 7.29.0(supports-color@7.2.0)
+ '@babel/helper-replace-supers': 7.28.6(@babel/core@7.29.0)
+ '@babel/helper-skip-transparent-expression-wrappers': 7.27.1
+ '@babel/traverse': 7.29.0
semver: 6.3.1
transitivePeerDependencies:
- supports-color
'@babel/helper-globals@7.28.0': {}
- '@babel/helper-member-expression-to-functions@7.28.5(supports-color@7.2.0)':
+ '@babel/helper-member-expression-to-functions@7.28.5':
dependencies:
- '@babel/traverse': 7.29.0(supports-color@7.2.0)
+ '@babel/traverse': 7.29.0
'@babel/types': 7.29.0
transitivePeerDependencies:
- supports-color
- '@babel/helper-module-imports@7.28.6(supports-color@7.2.0)':
+ '@babel/helper-module-imports@7.28.6':
dependencies:
- '@babel/traverse': 7.29.0(supports-color@7.2.0)
+ '@babel/traverse': 7.29.0
'@babel/types': 7.29.0
transitivePeerDependencies:
- supports-color
- '@babel/helper-module-transforms@7.28.6(@babel/core@7.29.0(supports-color@7.2.0))(supports-color@7.2.0)':
+ '@babel/helper-module-transforms@7.28.6(@babel/core@7.29.0)':
dependencies:
- '@babel/core': 7.29.0(supports-color@7.2.0)
- '@babel/helper-module-imports': 7.28.6(supports-color@7.2.0)
+ '@babel/core': 7.29.0
+ '@babel/helper-module-imports': 7.28.6
'@babel/helper-validator-identifier': 7.28.5
- '@babel/traverse': 7.29.0(supports-color@7.2.0)
+ '@babel/traverse': 7.29.0
transitivePeerDependencies:
- supports-color
@@ -5823,18 +5939,18 @@ snapshots:
'@babel/helper-plugin-utils@7.28.6': {}
- '@babel/helper-replace-supers@7.28.6(@babel/core@7.29.0(supports-color@7.2.0))(supports-color@7.2.0)':
+ '@babel/helper-replace-supers@7.28.6(@babel/core@7.29.0)':
dependencies:
- '@babel/core': 7.29.0(supports-color@7.2.0)
- '@babel/helper-member-expression-to-functions': 7.28.5(supports-color@7.2.0)
+ '@babel/core': 7.29.0
+ '@babel/helper-member-expression-to-functions': 7.28.5
'@babel/helper-optimise-call-expression': 7.27.1
- '@babel/traverse': 7.29.0(supports-color@7.2.0)
+ '@babel/traverse': 7.29.0
transitivePeerDependencies:
- supports-color
- '@babel/helper-skip-transparent-expression-wrappers@7.27.1(supports-color@7.2.0)':
+ '@babel/helper-skip-transparent-expression-wrappers@7.27.1':
dependencies:
- '@babel/traverse': 7.29.0(supports-color@7.2.0)
+ '@babel/traverse': 7.29.0
'@babel/types': 7.29.0
transitivePeerDependencies:
- supports-color
@@ -5843,6 +5959,8 @@ snapshots:
'@babel/helper-validator-identifier@7.28.5': {}
+ '@babel/helper-validator-identifier@7.29.7': {}
+
'@babel/helper-validator-option@7.27.1': {}
'@babel/helpers@7.29.2':
@@ -5854,55 +5972,57 @@ snapshots:
dependencies:
'@babel/types': 7.29.0
- '@babel/plugin-syntax-jsx@7.28.6(@babel/core@7.29.0(supports-color@7.2.0))':
+ '@babel/plugin-syntax-jsx@7.28.6(@babel/core@7.29.0)':
dependencies:
- '@babel/core': 7.29.0(supports-color@7.2.0)
+ '@babel/core': 7.29.0
'@babel/helper-plugin-utils': 7.28.6
- '@babel/plugin-syntax-typescript@7.28.6(@babel/core@7.29.0(supports-color@7.2.0))':
+ '@babel/plugin-syntax-typescript@7.28.6(@babel/core@7.29.0)':
dependencies:
- '@babel/core': 7.29.0(supports-color@7.2.0)
+ '@babel/core': 7.29.0
'@babel/helper-plugin-utils': 7.28.6
- '@babel/plugin-transform-modules-commonjs@7.28.6(@babel/core@7.29.0(supports-color@7.2.0))(supports-color@7.2.0)':
+ '@babel/plugin-transform-modules-commonjs@7.28.6(@babel/core@7.29.0)':
dependencies:
- '@babel/core': 7.29.0(supports-color@7.2.0)
- '@babel/helper-module-transforms': 7.28.6(@babel/core@7.29.0(supports-color@7.2.0))(supports-color@7.2.0)
+ '@babel/core': 7.29.0
+ '@babel/helper-module-transforms': 7.28.6(@babel/core@7.29.0)
'@babel/helper-plugin-utils': 7.28.6
transitivePeerDependencies:
- supports-color
- '@babel/plugin-transform-typescript@7.28.6(@babel/core@7.29.0(supports-color@7.2.0))(supports-color@7.2.0)':
+ '@babel/plugin-transform-typescript@7.28.6(@babel/core@7.29.0)':
dependencies:
- '@babel/core': 7.29.0(supports-color@7.2.0)
+ '@babel/core': 7.29.0
'@babel/helper-annotate-as-pure': 7.27.3
- '@babel/helper-create-class-features-plugin': 7.29.3(@babel/core@7.29.0(supports-color@7.2.0))(supports-color@7.2.0)
+ '@babel/helper-create-class-features-plugin': 7.29.3(@babel/core@7.29.0)
'@babel/helper-plugin-utils': 7.28.6
- '@babel/helper-skip-transparent-expression-wrappers': 7.27.1(supports-color@7.2.0)
- '@babel/plugin-syntax-typescript': 7.28.6(@babel/core@7.29.0(supports-color@7.2.0))
+ '@babel/helper-skip-transparent-expression-wrappers': 7.27.1
+ '@babel/plugin-syntax-typescript': 7.28.6(@babel/core@7.29.0)
transitivePeerDependencies:
- supports-color
- '@babel/preset-typescript@7.28.5(@babel/core@7.29.0(supports-color@7.2.0))(supports-color@7.2.0)':
+ '@babel/preset-typescript@7.28.5(@babel/core@7.29.0)':
dependencies:
- '@babel/core': 7.29.0(supports-color@7.2.0)
+ '@babel/core': 7.29.0
'@babel/helper-plugin-utils': 7.28.6
'@babel/helper-validator-option': 7.27.1
- '@babel/plugin-syntax-jsx': 7.28.6(@babel/core@7.29.0(supports-color@7.2.0))
- '@babel/plugin-transform-modules-commonjs': 7.28.6(@babel/core@7.29.0(supports-color@7.2.0))(supports-color@7.2.0)
- '@babel/plugin-transform-typescript': 7.28.6(@babel/core@7.29.0(supports-color@7.2.0))(supports-color@7.2.0)
+ '@babel/plugin-syntax-jsx': 7.28.6(@babel/core@7.29.0)
+ '@babel/plugin-transform-modules-commonjs': 7.28.6(@babel/core@7.29.0)
+ '@babel/plugin-transform-typescript': 7.28.6(@babel/core@7.29.0)
transitivePeerDependencies:
- supports-color
'@babel/runtime@7.29.2': {}
+ '@babel/runtime@7.29.7': {}
+
'@babel/template@7.28.6':
dependencies:
'@babel/code-frame': 7.29.0
'@babel/parser': 7.29.3
'@babel/types': 7.29.0
- '@babel/traverse@7.29.0(supports-color@7.2.0)':
+ '@babel/traverse@7.29.0':
dependencies:
'@babel/code-frame': 7.29.0
'@babel/generator': 7.29.1
@@ -5910,7 +6030,7 @@ snapshots:
'@babel/parser': 7.29.3
'@babel/template': 7.28.6
'@babel/types': 7.29.0
- debug: 4.4.3(supports-color@7.2.0)
+ debug: 4.4.3
transitivePeerDependencies:
- supports-color
@@ -6223,17 +6343,17 @@ snapshots:
'@esbuild/win32-x64@0.27.7':
optional: true
- '@eslint-community/eslint-utils@4.9.1(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))':
+ '@eslint-community/eslint-utils@4.9.1(eslint@9.39.4(jiti@2.7.0))':
dependencies:
- eslint: 9.39.4(jiti@2.7.0)(supports-color@7.2.0)
+ eslint: 9.39.4(jiti@2.7.0)
eslint-visitor-keys: 3.4.3
'@eslint-community/regexpp@4.12.2': {}
- '@eslint/config-array@0.21.2(supports-color@7.2.0)':
+ '@eslint/config-array@0.21.2':
dependencies:
'@eslint/object-schema': 2.1.7
- debug: 4.4.3(supports-color@7.2.0)
+ debug: 4.4.3
minimatch: 3.1.5
transitivePeerDependencies:
- supports-color
@@ -6246,10 +6366,10 @@ snapshots:
dependencies:
'@types/json-schema': 7.0.15
- '@eslint/eslintrc@3.3.5(supports-color@7.2.0)':
+ '@eslint/eslintrc@3.3.5':
dependencies:
ajv: 6.15.0
- debug: 4.4.3(supports-color@7.2.0)
+ debug: 4.4.3
espree: 10.4.0
globals: 14.0.0
ignore: 5.3.2
@@ -6453,7 +6573,7 @@ snapshots:
'@jridgewell/resolve-uri': 3.1.2
'@jridgewell/sourcemap-codec': 1.5.5
- '@modelcontextprotocol/sdk@1.30.0(supports-color@7.2.0)(zod@3.25.76)':
+ '@modelcontextprotocol/sdk@1.30.0(zod@3.25.76)':
dependencies:
'@hono/node-server': 1.19.14(hono@4.12.17)
ajv: 8.20.0
@@ -6463,8 +6583,8 @@ snapshots:
cross-spawn: 7.0.6
eventsource: 3.0.7
eventsource-parser: 3.0.8
- express: 5.2.1(supports-color@7.2.0)
- express-rate-limit: 8.5.0(express@5.2.1(supports-color@7.2.0))
+ express: 5.2.1
+ express-rate-limit: 8.5.0(express@5.2.1)
hono: 4.12.17
jose: 6.2.3
json-schema-typed: 8.0.2
@@ -6475,7 +6595,7 @@ snapshots:
transitivePeerDependencies:
- supports-color
- '@modelcontextprotocol/sdk@1.30.0(supports-color@7.2.0)(zod@4.4.3)':
+ '@modelcontextprotocol/sdk@1.30.0(zod@4.4.3)':
dependencies:
'@hono/node-server': 1.19.14(hono@4.12.17)
ajv: 8.20.0
@@ -6485,8 +6605,8 @@ snapshots:
cross-spawn: 7.0.6
eventsource: 3.0.7
eventsource-parser: 3.0.8
- express: 5.2.1(supports-color@7.2.0)
- express-rate-limit: 8.5.0(express@5.2.1(supports-color@7.2.0))
+ express: 5.2.1
+ express-rate-limit: 8.5.0(express@5.2.1)
hono: 4.12.17
jose: 6.2.3
json-schema-typed: 8.0.2
@@ -6698,11 +6818,11 @@ snapshots:
'@tybys/wasm-util': 0.10.2
optional: true
- '@napi-rs/wasm-runtime@1.1.4(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)':
+ '@napi-rs/wasm-runtime@1.2.4(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)':
dependencies:
'@emnapi/core': 1.10.0
'@emnapi/runtime': 1.10.0
- '@tybys/wasm-util': 0.10.2
+ '@tybys/wasm-util': 0.10.4
optional: true
'@neondatabase/serverless@1.1.0': {}
@@ -6759,10 +6879,10 @@ snapshots:
'@nolyfill/is-core-module@1.0.39': {}
- '@ontos-ai/knowhere-sdk@2.2.0(debug@4.4.3(supports-color@7.2.0))(supports-color@7.2.0)':
+ '@ontos-ai/knowhere-sdk@2.4.0':
dependencies:
- axios: 1.18.1(debug@4.4.3(supports-color@7.2.0))(supports-color@7.2.0)
- jszip: 3.10.1
+ axios: 1.20.0
+ jszip: 3.10.2
transitivePeerDependencies:
- debug
- supports-color
@@ -7228,7 +7348,7 @@ snapshots:
dependencies:
'@emnapi/core': 1.10.0
'@emnapi/runtime': 1.10.0
- '@napi-rs/wasm-runtime': 1.1.4(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)
+ '@napi-rs/wasm-runtime': 1.2.4(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)
optional: true
'@rolldown/binding-win32-arm64-msvc@1.0.0-rc.17':
@@ -7332,8 +7452,8 @@ snapshots:
'@testing-library/dom@10.4.1':
dependencies:
- '@babel/code-frame': 7.29.0
- '@babel/runtime': 7.29.2
+ '@babel/code-frame': 7.29.7
+ '@babel/runtime': 7.29.7
'@types/aria-query': 5.0.4
aria-query: 5.3.0
dom-accessibility-api: 0.5.16
@@ -7366,6 +7486,11 @@ snapshots:
tslib: 2.8.1
optional: true
+ '@tybys/wasm-util@0.10.4':
+ dependencies:
+ tslib: 2.8.1
+ optional: true
+
'@types/aria-query@5.0.4': {}
'@types/chai@5.2.3':
@@ -7428,15 +7553,15 @@ snapshots:
'@types/validate-npm-package-name@4.0.2': {}
- '@typescript-eslint/eslint-plugin@8.59.2(@typescript-eslint/parser@8.59.2(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3))(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)':
+ '@typescript-eslint/eslint-plugin@8.59.2(@typescript-eslint/parser@8.59.2(eslint@9.39.4(jiti@2.7.0))(typescript@6.0.3))(eslint@9.39.4(jiti@2.7.0))(typescript@6.0.3)':
dependencies:
'@eslint-community/regexpp': 4.12.2
- '@typescript-eslint/parser': 8.59.2(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)
+ '@typescript-eslint/parser': 8.59.2(eslint@9.39.4(jiti@2.7.0))(typescript@6.0.3)
'@typescript-eslint/scope-manager': 8.59.2
- '@typescript-eslint/type-utils': 8.59.2(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)
- '@typescript-eslint/utils': 8.59.2(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)
+ '@typescript-eslint/type-utils': 8.59.2(eslint@9.39.4(jiti@2.7.0))(typescript@6.0.3)
+ '@typescript-eslint/utils': 8.59.2(eslint@9.39.4(jiti@2.7.0))(typescript@6.0.3)
'@typescript-eslint/visitor-keys': 8.59.2
- eslint: 9.39.4(jiti@2.7.0)(supports-color@7.2.0)
+ eslint: 9.39.4(jiti@2.7.0)
ignore: 7.0.5
natural-compare: 1.4.0
ts-api-utils: 2.5.0(typescript@6.0.3)
@@ -7444,23 +7569,23 @@ snapshots:
transitivePeerDependencies:
- supports-color
- '@typescript-eslint/parser@8.59.2(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)':
+ '@typescript-eslint/parser@8.59.2(eslint@9.39.4(jiti@2.7.0))(typescript@6.0.3)':
dependencies:
'@typescript-eslint/scope-manager': 8.59.2
'@typescript-eslint/types': 8.59.2
- '@typescript-eslint/typescript-estree': 8.59.2(supports-color@7.2.0)(typescript@6.0.3)
+ '@typescript-eslint/typescript-estree': 8.59.2(typescript@6.0.3)
'@typescript-eslint/visitor-keys': 8.59.2
- debug: 4.4.3(supports-color@7.2.0)
- eslint: 9.39.4(jiti@2.7.0)(supports-color@7.2.0)
+ debug: 4.4.3
+ eslint: 9.39.4(jiti@2.7.0)
typescript: 6.0.3
transitivePeerDependencies:
- supports-color
- '@typescript-eslint/project-service@8.59.2(supports-color@7.2.0)(typescript@6.0.3)':
+ '@typescript-eslint/project-service@8.59.2(typescript@6.0.3)':
dependencies:
'@typescript-eslint/tsconfig-utils': 8.59.2(typescript@6.0.3)
'@typescript-eslint/types': 8.59.2
- debug: 4.4.3(supports-color@7.2.0)
+ debug: 4.4.3
typescript: 6.0.3
transitivePeerDependencies:
- supports-color
@@ -7474,13 +7599,13 @@ snapshots:
dependencies:
typescript: 6.0.3
- '@typescript-eslint/type-utils@8.59.2(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)':
+ '@typescript-eslint/type-utils@8.59.2(eslint@9.39.4(jiti@2.7.0))(typescript@6.0.3)':
dependencies:
'@typescript-eslint/types': 8.59.2
- '@typescript-eslint/typescript-estree': 8.59.2(supports-color@7.2.0)(typescript@6.0.3)
- '@typescript-eslint/utils': 8.59.2(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)
- debug: 4.4.3(supports-color@7.2.0)
- eslint: 9.39.4(jiti@2.7.0)(supports-color@7.2.0)
+ '@typescript-eslint/typescript-estree': 8.59.2(typescript@6.0.3)
+ '@typescript-eslint/utils': 8.59.2(eslint@9.39.4(jiti@2.7.0))(typescript@6.0.3)
+ debug: 4.4.3
+ eslint: 9.39.4(jiti@2.7.0)
ts-api-utils: 2.5.0(typescript@6.0.3)
typescript: 6.0.3
transitivePeerDependencies:
@@ -7488,13 +7613,13 @@ snapshots:
'@typescript-eslint/types@8.59.2': {}
- '@typescript-eslint/typescript-estree@8.59.2(supports-color@7.2.0)(typescript@6.0.3)':
+ '@typescript-eslint/typescript-estree@8.59.2(typescript@6.0.3)':
dependencies:
- '@typescript-eslint/project-service': 8.59.2(supports-color@7.2.0)(typescript@6.0.3)
+ '@typescript-eslint/project-service': 8.59.2(typescript@6.0.3)
'@typescript-eslint/tsconfig-utils': 8.59.2(typescript@6.0.3)
'@typescript-eslint/types': 8.59.2
'@typescript-eslint/visitor-keys': 8.59.2
- debug: 4.4.3(supports-color@7.2.0)
+ debug: 4.4.3
minimatch: 10.2.5
semver: 7.7.4
tinyglobby: 0.2.16
@@ -7503,13 +7628,13 @@ snapshots:
transitivePeerDependencies:
- supports-color
- '@typescript-eslint/utils@8.59.2(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)':
+ '@typescript-eslint/utils@8.59.2(eslint@9.39.4(jiti@2.7.0))(typescript@6.0.3)':
dependencies:
- '@eslint-community/eslint-utils': 4.9.1(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))
+ '@eslint-community/eslint-utils': 4.9.1(eslint@9.39.4(jiti@2.7.0))
'@typescript-eslint/scope-manager': 8.59.2
'@typescript-eslint/types': 8.59.2
- '@typescript-eslint/typescript-estree': 8.59.2(supports-color@7.2.0)(typescript@6.0.3)
- eslint: 9.39.4(jiti@2.7.0)(supports-color@7.2.0)
+ '@typescript-eslint/typescript-estree': 8.59.2(typescript@6.0.3)
+ eslint: 9.39.4(jiti@2.7.0)
typescript: 6.0.3
transitivePeerDependencies:
- supports-color
@@ -7663,9 +7788,9 @@ snapshots:
acorn@8.16.0: {}
- agent-base@6.0.2(supports-color@7.2.0):
+ agent-base@6.0.2:
dependencies:
- debug: 4.4.3(supports-color@7.2.0)
+ debug: 4.4.3
transitivePeerDependencies:
- supports-color
@@ -7812,11 +7937,11 @@ snapshots:
axe-core@4.11.4: {}
- axios@1.18.1(debug@4.4.3(supports-color@7.2.0))(supports-color@7.2.0):
+ axios@1.20.0:
dependencies:
- follow-redirects: 1.16.0(debug@4.4.3(supports-color@7.2.0))
+ follow-redirects: 1.16.0
form-data: 4.0.6
- https-proxy-agent: 5.0.1(supports-color@7.2.0)
+ https-proxy-agent: 5.0.1
proxy-from-env: 2.1.0
transitivePeerDependencies:
- debug
@@ -7844,11 +7969,11 @@ snapshots:
bluebird@3.4.7: {}
- body-parser@2.2.2(supports-color@7.2.0):
+ body-parser@2.2.2:
dependencies:
bytes: 3.1.2
content-type: 1.0.5
- debug: 4.4.3(supports-color@7.2.0)
+ debug: 4.4.3
http-errors: 2.0.1
iconv-lite: 0.7.2
on-finished: 2.4.1
@@ -8049,17 +8174,13 @@ snapshots:
es-errors: 1.3.0
is-data-view: 1.0.2
- debug@3.2.7(supports-color@7.2.0):
+ debug@3.2.7:
dependencies:
ms: 2.1.3
- optionalDependencies:
- supports-color: 7.2.0
- debug@4.4.3(supports-color@7.2.0):
+ debug@4.4.3:
dependencies:
ms: 2.1.3
- optionalDependencies:
- supports-color: 7.2.0
decimal.js@10.6.0: {}
@@ -8382,18 +8503,18 @@ snapshots:
escape-string-regexp@5.0.0: {}
- eslint-config-next@16.2.4(@typescript-eslint/parser@8.59.2(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3))(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3):
+ eslint-config-next@16.2.4(@typescript-eslint/parser@8.59.2(eslint@9.39.4(jiti@2.7.0))(typescript@6.0.3))(eslint@9.39.4(jiti@2.7.0))(typescript@6.0.3):
dependencies:
'@next/eslint-plugin-next': 16.2.4
- eslint: 9.39.4(jiti@2.7.0)(supports-color@7.2.0)
- eslint-import-resolver-node: 0.3.10(supports-color@7.2.0)
- eslint-import-resolver-typescript: 3.10.1(eslint-plugin-import@2.32.0)(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)
- eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.59.2(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)
- eslint-plugin-jsx-a11y: 6.10.2(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))
- eslint-plugin-react: 7.37.5(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))
- eslint-plugin-react-hooks: 7.1.1(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)
+ eslint: 9.39.4(jiti@2.7.0)
+ eslint-import-resolver-node: 0.3.10
+ eslint-import-resolver-typescript: 3.10.1(eslint-plugin-import@2.32.0)(eslint@9.39.4(jiti@2.7.0))
+ eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.59.2(eslint@9.39.4(jiti@2.7.0))(typescript@6.0.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.4(jiti@2.7.0))
+ eslint-plugin-jsx-a11y: 6.10.2(eslint@9.39.4(jiti@2.7.0))
+ eslint-plugin-react: 7.37.5(eslint@9.39.4(jiti@2.7.0))
+ eslint-plugin-react-hooks: 7.1.1(eslint@9.39.4(jiti@2.7.0))
globals: 16.4.0
- typescript-eslint: 8.59.2(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)
+ typescript-eslint: 8.59.2(eslint@9.39.4(jiti@2.7.0))(typescript@6.0.3)
optionalDependencies:
typescript: 6.0.3
transitivePeerDependencies:
@@ -8402,52 +8523,52 @@ snapshots:
- eslint-plugin-import-x
- supports-color
- eslint-import-resolver-node@0.3.10(supports-color@7.2.0):
+ eslint-import-resolver-node@0.3.10:
dependencies:
- debug: 3.2.7(supports-color@7.2.0)
+ debug: 3.2.7
is-core-module: 2.16.2
resolve: 2.0.0-next.6
transitivePeerDependencies:
- supports-color
- eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0)(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0):
+ eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0)(eslint@9.39.4(jiti@2.7.0)):
dependencies:
'@nolyfill/is-core-module': 1.0.39
- debug: 4.4.3(supports-color@7.2.0)
- eslint: 9.39.4(jiti@2.7.0)(supports-color@7.2.0)
+ debug: 4.4.3
+ eslint: 9.39.4(jiti@2.7.0)
get-tsconfig: 4.14.0
is-bun-module: 2.0.0
stable-hash: 0.0.5
tinyglobby: 0.2.16
unrs-resolver: 1.11.1
optionalDependencies:
- eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.59.2(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)
+ eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.59.2(eslint@9.39.4(jiti@2.7.0))(typescript@6.0.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.4(jiti@2.7.0))
transitivePeerDependencies:
- supports-color
- eslint-module-utils@2.12.1(@typescript-eslint/parser@8.59.2(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3))(eslint-import-resolver-node@0.3.10(supports-color@7.2.0))(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0):
+ eslint-module-utils@2.12.1(@typescript-eslint/parser@8.59.2(eslint@9.39.4(jiti@2.7.0))(typescript@6.0.3))(eslint-import-resolver-node@0.3.10)(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.4(jiti@2.7.0)):
dependencies:
- debug: 3.2.7(supports-color@7.2.0)
+ debug: 3.2.7
optionalDependencies:
- '@typescript-eslint/parser': 8.59.2(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)
- eslint: 9.39.4(jiti@2.7.0)(supports-color@7.2.0)
- eslint-import-resolver-node: 0.3.10(supports-color@7.2.0)
- eslint-import-resolver-typescript: 3.10.1(eslint-plugin-import@2.32.0)(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)
+ '@typescript-eslint/parser': 8.59.2(eslint@9.39.4(jiti@2.7.0))(typescript@6.0.3)
+ eslint: 9.39.4(jiti@2.7.0)
+ eslint-import-resolver-node: 0.3.10
+ eslint-import-resolver-typescript: 3.10.1(eslint-plugin-import@2.32.0)(eslint@9.39.4(jiti@2.7.0))
transitivePeerDependencies:
- supports-color
- eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.59.2(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0):
+ eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.59.2(eslint@9.39.4(jiti@2.7.0))(typescript@6.0.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.4(jiti@2.7.0)):
dependencies:
'@rtsao/scc': 1.1.0
array-includes: 3.1.9
array.prototype.findlastindex: 1.2.6
array.prototype.flat: 1.3.3
array.prototype.flatmap: 1.3.3
- debug: 3.2.7(supports-color@7.2.0)
+ debug: 3.2.7
doctrine: 2.1.0
- eslint: 9.39.4(jiti@2.7.0)(supports-color@7.2.0)
- eslint-import-resolver-node: 0.3.10(supports-color@7.2.0)
- eslint-module-utils: 2.12.1(@typescript-eslint/parser@8.59.2(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3))(eslint-import-resolver-node@0.3.10(supports-color@7.2.0))(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)
+ eslint: 9.39.4(jiti@2.7.0)
+ eslint-import-resolver-node: 0.3.10
+ eslint-module-utils: 2.12.1(@typescript-eslint/parser@8.59.2(eslint@9.39.4(jiti@2.7.0))(typescript@6.0.3))(eslint-import-resolver-node@0.3.10)(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.4(jiti@2.7.0))
hasown: 2.0.3
is-core-module: 2.16.2
is-glob: 4.0.3
@@ -8459,13 +8580,13 @@ snapshots:
string.prototype.trimend: 1.0.9
tsconfig-paths: 3.15.0
optionalDependencies:
- '@typescript-eslint/parser': 8.59.2(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)
+ '@typescript-eslint/parser': 8.59.2(eslint@9.39.4(jiti@2.7.0))(typescript@6.0.3)
transitivePeerDependencies:
- eslint-import-resolver-typescript
- eslint-import-resolver-webpack
- supports-color
- eslint-plugin-jsx-a11y@6.10.2(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0)):
+ eslint-plugin-jsx-a11y@6.10.2(eslint@9.39.4(jiti@2.7.0)):
dependencies:
aria-query: 5.3.2
array-includes: 3.1.9
@@ -8475,7 +8596,7 @@ snapshots:
axobject-query: 4.1.0
damerau-levenshtein: 1.0.8
emoji-regex: 9.2.2
- eslint: 9.39.4(jiti@2.7.0)(supports-color@7.2.0)
+ eslint: 9.39.4(jiti@2.7.0)
hasown: 2.0.3
jsx-ast-utils: 3.3.5
language-tags: 1.0.9
@@ -8484,18 +8605,18 @@ snapshots:
safe-regex-test: 1.1.0
string.prototype.includes: 2.0.1
- eslint-plugin-react-hooks@7.1.1(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0):
+ eslint-plugin-react-hooks@7.1.1(eslint@9.39.4(jiti@2.7.0)):
dependencies:
- '@babel/core': 7.29.0(supports-color@7.2.0)
+ '@babel/core': 7.29.0
'@babel/parser': 7.29.3
- eslint: 9.39.4(jiti@2.7.0)(supports-color@7.2.0)
+ eslint: 9.39.4(jiti@2.7.0)
hermes-parser: 0.25.1
zod: 4.4.3
zod-validation-error: 4.0.2(zod@4.4.3)
transitivePeerDependencies:
- supports-color
- eslint-plugin-react@7.37.5(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0)):
+ eslint-plugin-react@7.37.5(eslint@9.39.4(jiti@2.7.0)):
dependencies:
array-includes: 3.1.9
array.prototype.findlast: 1.2.5
@@ -8503,7 +8624,7 @@ snapshots:
array.prototype.tosorted: 1.1.4
doctrine: 2.1.0
es-iterator-helpers: 1.3.2
- eslint: 9.39.4(jiti@2.7.0)(supports-color@7.2.0)
+ eslint: 9.39.4(jiti@2.7.0)
estraverse: 5.3.0
hasown: 2.0.3
jsx-ast-utils: 3.3.5
@@ -8528,14 +8649,14 @@ snapshots:
eslint-visitor-keys@5.0.1: {}
- eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0):
+ eslint@9.39.4(jiti@2.7.0):
dependencies:
- '@eslint-community/eslint-utils': 4.9.1(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))
+ '@eslint-community/eslint-utils': 4.9.1(eslint@9.39.4(jiti@2.7.0))
'@eslint-community/regexpp': 4.12.2
- '@eslint/config-array': 0.21.2(supports-color@7.2.0)
+ '@eslint/config-array': 0.21.2
'@eslint/config-helpers': 0.4.2
'@eslint/core': 0.17.0
- '@eslint/eslintrc': 3.3.5(supports-color@7.2.0)
+ '@eslint/eslintrc': 3.3.5
'@eslint/js': 9.39.4
'@eslint/plugin-kit': 0.4.1
'@humanfs/node': 0.16.8
@@ -8545,7 +8666,7 @@ snapshots:
ajv: 6.15.0
chalk: 4.1.2
cross-spawn: 7.0.6
- debug: 4.4.3(supports-color@7.2.0)
+ debug: 4.4.3
escape-string-regexp: 4.0.0
eslint-scope: 8.4.0
eslint-visitor-keys: 4.2.1
@@ -8632,25 +8753,25 @@ snapshots:
expect-type@1.3.0: {}
- express-rate-limit@8.5.0(express@5.2.1(supports-color@7.2.0)):
+ express-rate-limit@8.5.0(express@5.2.1):
dependencies:
- express: 5.2.1(supports-color@7.2.0)
+ express: 5.2.1
ip-address: 10.1.0
- express@5.2.1(supports-color@7.2.0):
+ express@5.2.1:
dependencies:
accepts: 2.0.0
- body-parser: 2.2.2(supports-color@7.2.0)
+ body-parser: 2.2.2
content-disposition: 1.1.0
content-type: 1.0.5
cookie: 0.7.2
cookie-signature: 1.2.2
- debug: 4.4.3(supports-color@7.2.0)
+ debug: 4.4.3
depd: 2.0.0
encodeurl: 2.0.0
escape-html: 1.0.3
etag: 1.8.1
- finalhandler: 2.1.1(supports-color@7.2.0)
+ finalhandler: 2.1.1
fresh: 2.0.0
http-errors: 2.0.1
merge-descriptors: 2.0.0
@@ -8661,9 +8782,9 @@ snapshots:
proxy-addr: 2.0.7
qs: 6.15.1
range-parser: 1.2.1
- router: 2.2.0(supports-color@7.2.0)
- send: 1.2.1(supports-color@7.2.0)
- serve-static: 2.2.1(supports-color@7.2.0)
+ router: 2.2.0
+ send: 1.2.1
+ serve-static: 2.2.1
statuses: 2.0.2
type-is: 2.0.1
vary: 1.1.2
@@ -8722,6 +8843,10 @@ snapshots:
optionalDependencies:
picomatch: 4.0.4
+ fdir@6.5.0(picomatch@4.0.7):
+ optionalDependencies:
+ picomatch: 4.0.7
+
fetch-blob@3.2.0:
dependencies:
node-domexception: 1.0.0
@@ -8741,9 +8866,9 @@ snapshots:
dependencies:
to-regex-range: 5.0.1
- finalhandler@2.1.1(supports-color@7.2.0):
+ finalhandler@2.1.1:
dependencies:
- debug: 4.4.3(supports-color@7.2.0)
+ debug: 4.4.3
encodeurl: 2.0.0
escape-html: 1.0.3
on-finished: 2.4.1
@@ -8766,9 +8891,7 @@ snapshots:
flatted@3.4.2: {}
- follow-redirects@1.16.0(debug@4.4.3(supports-color@7.2.0)):
- optionalDependencies:
- debug: 4.4.3(supports-color@7.2.0)
+ follow-redirects@1.16.0: {}
for-each@0.3.5:
dependencies:
@@ -8920,7 +9043,7 @@ snapshots:
dependencies:
function-bind: 1.1.2
- hast-util-to-jsx-runtime@2.3.6(supports-color@7.2.0):
+ hast-util-to-jsx-runtime@2.3.6:
dependencies:
'@types/estree': 1.0.8
'@types/hast': 3.0.4
@@ -8929,9 +9052,9 @@ snapshots:
devlop: 1.1.0
estree-util-is-identifier-name: 3.0.0
hast-util-whitespace: 3.0.0
- mdast-util-mdx-expression: 2.0.1(supports-color@7.2.0)
- mdast-util-mdx-jsx: 3.2.0(supports-color@7.2.0)
- mdast-util-mdxjs-esm: 2.0.1(supports-color@7.2.0)
+ mdast-util-mdx-expression: 2.0.1
+ mdast-util-mdx-jsx: 3.2.0
+ mdast-util-mdxjs-esm: 2.0.1
property-information: 7.1.0
space-separated-tokens: 2.0.2
style-to-js: 1.1.21
@@ -8973,17 +9096,17 @@ snapshots:
statuses: 2.0.2
toidentifier: 1.0.1
- https-proxy-agent@5.0.1(supports-color@7.2.0):
+ https-proxy-agent@5.0.1:
dependencies:
- agent-base: 6.0.2(supports-color@7.2.0)
- debug: 4.4.3(supports-color@7.2.0)
+ agent-base: 6.0.2
+ debug: 4.4.3
transitivePeerDependencies:
- supports-color
- https-proxy-agent@7.0.6(supports-color@7.2.0):
+ https-proxy-agent@7.0.6:
dependencies:
agent-base: 7.1.4
- debug: 4.4.3(supports-color@7.2.0)
+ debug: 4.4.3
transitivePeerDependencies:
- supports-color
@@ -9289,6 +9412,13 @@ snapshots:
readable-stream: 2.3.8
setimmediate: 1.0.5
+ jszip@3.10.2:
+ dependencies:
+ lie: 3.3.0
+ pako: 1.0.11
+ readable-stream: 2.3.8
+ setimmediate: 1.0.5
+
keyv@4.5.4:
dependencies:
json-buffer: 3.0.1
@@ -9317,36 +9447,69 @@ snapshots:
lightningcss-android-arm64@1.32.0:
optional: true
+ lightningcss-android-arm64@1.33.0:
+ optional: true
+
lightningcss-darwin-arm64@1.32.0:
optional: true
+ lightningcss-darwin-arm64@1.33.0:
+ optional: true
+
lightningcss-darwin-x64@1.32.0:
optional: true
+ lightningcss-darwin-x64@1.33.0:
+ optional: true
+
lightningcss-freebsd-x64@1.32.0:
optional: true
+ lightningcss-freebsd-x64@1.33.0:
+ optional: true
+
lightningcss-linux-arm-gnueabihf@1.32.0:
optional: true
+ lightningcss-linux-arm-gnueabihf@1.33.0:
+ optional: true
+
lightningcss-linux-arm64-gnu@1.32.0:
optional: true
+ lightningcss-linux-arm64-gnu@1.33.0:
+ optional: true
+
lightningcss-linux-arm64-musl@1.32.0:
optional: true
+ lightningcss-linux-arm64-musl@1.33.0:
+ optional: true
+
lightningcss-linux-x64-gnu@1.32.0:
optional: true
+ lightningcss-linux-x64-gnu@1.33.0:
+ optional: true
+
lightningcss-linux-x64-musl@1.32.0:
optional: true
+ lightningcss-linux-x64-musl@1.33.0:
+ optional: true
+
lightningcss-win32-arm64-msvc@1.32.0:
optional: true
+ lightningcss-win32-arm64-msvc@1.33.0:
+ optional: true
+
lightningcss-win32-x64-msvc@1.32.0:
optional: true
+ lightningcss-win32-x64-msvc@1.33.0:
+ optional: true
+
lightningcss@1.32.0:
dependencies:
detect-libc: 2.1.2
@@ -9363,6 +9526,22 @@ snapshots:
lightningcss-win32-arm64-msvc: 1.32.0
lightningcss-win32-x64-msvc: 1.32.0
+ lightningcss@1.33.0:
+ dependencies:
+ detect-libc: 2.1.2
+ optionalDependencies:
+ lightningcss-android-arm64: 1.33.0
+ lightningcss-darwin-arm64: 1.33.0
+ lightningcss-darwin-x64: 1.33.0
+ lightningcss-freebsd-x64: 1.33.0
+ lightningcss-linux-arm-gnueabihf: 1.33.0
+ lightningcss-linux-arm64-gnu: 1.33.0
+ lightningcss-linux-arm64-musl: 1.33.0
+ lightningcss-linux-x64-gnu: 1.33.0
+ lightningcss-linux-x64-musl: 1.33.0
+ lightningcss-win32-arm64-msvc: 1.33.0
+ lightningcss-win32-x64-msvc: 1.33.0
+
lines-and-columns@1.2.4: {}
locate-path@6.0.0:
@@ -9432,14 +9611,14 @@ snapshots:
unist-util-is: 6.0.1
unist-util-visit-parents: 6.0.2
- mdast-util-from-markdown@2.0.3(supports-color@7.2.0):
+ mdast-util-from-markdown@2.0.3:
dependencies:
'@types/mdast': 4.0.4
'@types/unist': 3.0.3
decode-named-character-reference: 1.3.0
devlop: 1.1.0
mdast-util-to-string: 4.0.0
- micromark: 4.0.2(supports-color@7.2.0)
+ micromark: 4.0.2
micromark-util-decode-numeric-character-reference: 2.0.2
micromark-util-decode-string: 2.0.1
micromark-util-normalize-identifier: 2.0.1
@@ -9457,67 +9636,67 @@ snapshots:
mdast-util-find-and-replace: 3.0.2
micromark-util-character: 2.1.1
- mdast-util-gfm-footnote@2.1.0(supports-color@7.2.0):
+ mdast-util-gfm-footnote@2.1.0:
dependencies:
'@types/mdast': 4.0.4
devlop: 1.1.0
- mdast-util-from-markdown: 2.0.3(supports-color@7.2.0)
+ mdast-util-from-markdown: 2.0.3
mdast-util-to-markdown: 2.1.2
micromark-util-normalize-identifier: 2.0.1
transitivePeerDependencies:
- supports-color
- mdast-util-gfm-strikethrough@2.0.0(supports-color@7.2.0):
+ mdast-util-gfm-strikethrough@2.0.0:
dependencies:
'@types/mdast': 4.0.4
- mdast-util-from-markdown: 2.0.3(supports-color@7.2.0)
+ mdast-util-from-markdown: 2.0.3
mdast-util-to-markdown: 2.1.2
transitivePeerDependencies:
- supports-color
- mdast-util-gfm-table@2.0.0(supports-color@7.2.0):
+ mdast-util-gfm-table@2.0.0:
dependencies:
'@types/mdast': 4.0.4
devlop: 1.1.0
markdown-table: 3.0.4
- mdast-util-from-markdown: 2.0.3(supports-color@7.2.0)
+ mdast-util-from-markdown: 2.0.3
mdast-util-to-markdown: 2.1.2
transitivePeerDependencies:
- supports-color
- mdast-util-gfm-task-list-item@2.0.0(supports-color@7.2.0):
+ mdast-util-gfm-task-list-item@2.0.0:
dependencies:
'@types/mdast': 4.0.4
devlop: 1.1.0
- mdast-util-from-markdown: 2.0.3(supports-color@7.2.0)
+ mdast-util-from-markdown: 2.0.3
mdast-util-to-markdown: 2.1.2
transitivePeerDependencies:
- supports-color
- mdast-util-gfm@3.1.0(supports-color@7.2.0):
+ mdast-util-gfm@3.1.0:
dependencies:
- mdast-util-from-markdown: 2.0.3(supports-color@7.2.0)
+ mdast-util-from-markdown: 2.0.3
mdast-util-gfm-autolink-literal: 2.0.1
- mdast-util-gfm-footnote: 2.1.0(supports-color@7.2.0)
- mdast-util-gfm-strikethrough: 2.0.0(supports-color@7.2.0)
- mdast-util-gfm-table: 2.0.0(supports-color@7.2.0)
- mdast-util-gfm-task-list-item: 2.0.0(supports-color@7.2.0)
+ mdast-util-gfm-footnote: 2.1.0
+ mdast-util-gfm-strikethrough: 2.0.0
+ mdast-util-gfm-table: 2.0.0
+ mdast-util-gfm-task-list-item: 2.0.0
mdast-util-to-markdown: 2.1.2
transitivePeerDependencies:
- supports-color
- mdast-util-mdx-expression@2.0.1(supports-color@7.2.0):
+ mdast-util-mdx-expression@2.0.1:
dependencies:
'@types/estree-jsx': 1.0.5
'@types/hast': 3.0.4
'@types/mdast': 4.0.4
devlop: 1.1.0
- mdast-util-from-markdown: 2.0.3(supports-color@7.2.0)
+ mdast-util-from-markdown: 2.0.3
mdast-util-to-markdown: 2.1.2
transitivePeerDependencies:
- supports-color
- mdast-util-mdx-jsx@3.2.0(supports-color@7.2.0):
+ mdast-util-mdx-jsx@3.2.0:
dependencies:
'@types/estree-jsx': 1.0.5
'@types/hast': 3.0.4
@@ -9525,7 +9704,7 @@ snapshots:
'@types/unist': 3.0.3
ccount: 2.0.1
devlop: 1.1.0
- mdast-util-from-markdown: 2.0.3(supports-color@7.2.0)
+ mdast-util-from-markdown: 2.0.3
mdast-util-to-markdown: 2.1.2
parse-entities: 4.0.2
stringify-entities: 4.0.4
@@ -9534,13 +9713,13 @@ snapshots:
transitivePeerDependencies:
- supports-color
- mdast-util-mdxjs-esm@2.0.1(supports-color@7.2.0):
+ mdast-util-mdxjs-esm@2.0.1:
dependencies:
'@types/estree-jsx': 1.0.5
'@types/hast': 3.0.4
'@types/mdast': 4.0.4
devlop: 1.1.0
- mdast-util-from-markdown: 2.0.3(supports-color@7.2.0)
+ mdast-util-from-markdown: 2.0.3
mdast-util-to-markdown: 2.1.2
transitivePeerDependencies:
- supports-color
@@ -9761,10 +9940,10 @@ snapshots:
micromark-util-types@2.0.2: {}
- micromark@4.0.2(supports-color@7.2.0):
+ micromark@4.0.2:
dependencies:
'@types/debug': 4.1.13
- debug: 4.4.3(supports-color@7.2.0)
+ debug: 4.4.3
decode-named-character-reference: 1.3.0
devlop: 1.1.0
micromark-core-commonmark: 2.0.3
@@ -9863,6 +10042,8 @@ snapshots:
nanoid@3.3.12: {}
+ nanoid@3.3.19: {}
+
napi-postinstall@0.3.4: {}
natural-compare@1.4.0: {}
@@ -9876,7 +10057,7 @@ snapshots:
react: 19.2.4
react-dom: 19.2.4(react@19.2.4)
- next@16.2.4(@babel/core@7.29.0(supports-color@7.2.0))(@opentelemetry/api@1.9.0)(@playwright/test@1.58.2)(babel-plugin-react-compiler@1.0.0)(react-dom@19.2.4(react@19.2.4))(react@19.2.4):
+ next@16.2.4(@babel/core@7.29.0)(@opentelemetry/api@1.9.0)(@playwright/test@1.58.2)(babel-plugin-react-compiler@1.0.0)(react-dom@19.2.4(react@19.2.4))(react@19.2.4):
dependencies:
'@next/env': 16.2.4
'@swc/helpers': 0.5.15
@@ -9885,7 +10066,7 @@ snapshots:
postcss: 8.4.31
react: 19.2.4
react-dom: 19.2.4(react@19.2.4)
- styled-jsx: 5.1.6(@babel/core@7.29.0(supports-color@7.2.0))(react@19.2.4)
+ styled-jsx: 5.1.6(@babel/core@7.29.0)(react@19.2.4)
optionalDependencies:
'@next/swc-darwin-arm64': 16.2.4
'@next/swc-darwin-x64': 16.2.4
@@ -10103,6 +10284,8 @@ snapshots:
picomatch@4.0.4: {}
+ picomatch@4.0.7: {}
+
piscina@5.2.0:
optionalDependencies:
'@napi-rs/nice': 1.1.1
@@ -10136,6 +10319,12 @@ snapshots:
picocolors: 1.1.1
source-map-js: 1.2.1
+ postcss@8.5.28:
+ dependencies:
+ nanoid: 3.3.19
+ picocolors: 1.1.1
+ source-map-js: 1.2.1
+
postgres@3.4.9: {}
posthog-js@1.386.8:
@@ -10217,17 +10406,17 @@ snapshots:
react-is@17.0.2: {}
- react-markdown@10.1.0(@types/react@19.2.14)(react@19.2.4)(supports-color@7.2.0):
+ react-markdown@10.1.0(@types/react@19.2.14)(react@19.2.4):
dependencies:
'@types/hast': 3.0.4
'@types/mdast': 4.0.4
'@types/react': 19.2.14
devlop: 1.1.0
- hast-util-to-jsx-runtime: 2.3.6(supports-color@7.2.0)
+ hast-util-to-jsx-runtime: 2.3.6
html-url-attributes: 3.0.1
mdast-util-to-hast: 13.2.1
react: 19.2.4
- remark-parse: 11.0.0(supports-color@7.2.0)
+ remark-parse: 11.0.0
remark-rehype: 11.1.2
unified: 11.0.5
unist-util-visit: 5.1.0
@@ -10317,21 +10506,21 @@ snapshots:
gopd: 1.2.0
set-function-name: 2.0.2
- remark-gfm@4.0.1(supports-color@7.2.0):
+ remark-gfm@4.0.1:
dependencies:
'@types/mdast': 4.0.4
- mdast-util-gfm: 3.1.0(supports-color@7.2.0)
+ mdast-util-gfm: 3.1.0
micromark-extension-gfm: 3.0.0
- remark-parse: 11.0.0(supports-color@7.2.0)
+ remark-parse: 11.0.0
remark-stringify: 11.0.0
unified: 11.0.5
transitivePeerDependencies:
- supports-color
- remark-parse@11.0.0(supports-color@7.2.0):
+ remark-parse@11.0.0:
dependencies:
'@types/mdast': 4.0.4
- mdast-util-from-markdown: 2.0.3(supports-color@7.2.0)
+ mdast-util-from-markdown: 2.0.3
micromark-util-types: 2.0.2
unified: 11.0.5
transitivePeerDependencies:
@@ -10400,9 +10589,9 @@ snapshots:
'@rolldown/binding-win32-arm64-msvc': 1.0.0-rc.17
'@rolldown/binding-win32-x64-msvc': 1.0.0-rc.17
- router@2.2.0(supports-color@7.2.0):
+ router@2.2.0:
dependencies:
- debug: 4.4.3(supports-color@7.2.0)
+ debug: 4.4.3
depd: 2.0.0
is-promise: 4.0.0
parseurl: 1.3.3
@@ -10454,9 +10643,9 @@ snapshots:
semver@7.7.4: {}
- send@1.2.1(supports-color@7.2.0):
+ send@1.2.1:
dependencies:
- debug: 4.4.3(supports-color@7.2.0)
+ debug: 4.4.3
encodeurl: 2.0.0
escape-html: 1.0.3
etag: 1.8.1
@@ -10470,12 +10659,12 @@ snapshots:
transitivePeerDependencies:
- supports-color
- serve-static@2.2.1(supports-color@7.2.0):
+ serve-static@2.2.1:
dependencies:
encodeurl: 2.0.0
escape-html: 1.0.3
parseurl: 1.3.3
- send: 1.2.1(supports-color@7.2.0)
+ send: 1.2.1
transitivePeerDependencies:
- supports-color
@@ -10509,14 +10698,14 @@ snapshots:
setprototypeof@1.2.0: {}
- shadcn@4.7.0(@types/node@20.19.39)(supports-color@7.2.0)(typescript@6.0.3):
+ shadcn@4.7.0(@types/node@20.19.39)(typescript@6.0.3):
dependencies:
- '@babel/core': 7.29.0(supports-color@7.2.0)
+ '@babel/core': 7.29.0
'@babel/parser': 7.29.3
- '@babel/plugin-transform-typescript': 7.28.6(@babel/core@7.29.0(supports-color@7.2.0))(supports-color@7.2.0)
- '@babel/preset-typescript': 7.28.5(@babel/core@7.29.0(supports-color@7.2.0))(supports-color@7.2.0)
+ '@babel/plugin-transform-typescript': 7.28.6(@babel/core@7.29.0)
+ '@babel/preset-typescript': 7.28.5(@babel/core@7.29.0)
'@dotenvx/dotenvx': 1.65.0
- '@modelcontextprotocol/sdk': 1.30.0(supports-color@7.2.0)(zod@3.25.76)
+ '@modelcontextprotocol/sdk': 1.30.0(zod@3.25.76)
'@types/validate-npm-package-name': 4.0.2
browserslist: 4.28.2
commander: 14.0.3
@@ -10528,7 +10717,7 @@ snapshots:
fast-glob: 3.3.3
fs-extra: 11.3.4
fuzzysort: 3.1.0
- https-proxy-agent: 7.0.6(supports-color@7.2.0)
+ https-proxy-agent: 7.0.6
kleur: 4.1.5
msw: 2.14.3(@types/node@20.19.39)(typescript@6.0.3)
node-fetch: 3.3.2
@@ -10759,12 +10948,12 @@ snapshots:
dependencies:
inline-style-parser: 0.2.7
- styled-jsx@5.1.6(@babel/core@7.29.0(supports-color@7.2.0))(react@19.2.4):
+ styled-jsx@5.1.6(@babel/core@7.29.0)(react@19.2.4):
dependencies:
client-only: 0.0.1
react: 19.2.4
optionalDependencies:
- '@babel/core': 7.29.0(supports-color@7.2.0)
+ '@babel/core': 7.29.0
supports-color@7.2.0:
dependencies:
@@ -10801,6 +10990,11 @@ snapshots:
fdir: 6.5.0(picomatch@4.0.4)
picomatch: 4.0.4
+ tinyglobby@0.2.17:
+ dependencies:
+ fdir: 6.5.0(picomatch@4.0.7)
+ picomatch: 4.0.7
+
tinyrainbow@3.1.0: {}
tldts-core@7.0.30: {}
@@ -10907,13 +11101,13 @@ snapshots:
possible-typed-array-names: 1.1.0
reflect.getprototypeof: 1.0.10
- typescript-eslint@8.59.2(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3):
+ typescript-eslint@8.59.2(eslint@9.39.4(jiti@2.7.0))(typescript@6.0.3):
dependencies:
- '@typescript-eslint/eslint-plugin': 8.59.2(@typescript-eslint/parser@8.59.2(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3))(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)
- '@typescript-eslint/parser': 8.59.2(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)
- '@typescript-eslint/typescript-estree': 8.59.2(supports-color@7.2.0)(typescript@6.0.3)
- '@typescript-eslint/utils': 8.59.2(eslint@9.39.4(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)
- eslint: 9.39.4(jiti@2.7.0)(supports-color@7.2.0)
+ '@typescript-eslint/eslint-plugin': 8.59.2(@typescript-eslint/parser@8.59.2(eslint@9.39.4(jiti@2.7.0))(typescript@6.0.3))(eslint@9.39.4(jiti@2.7.0))(typescript@6.0.3)
+ '@typescript-eslint/parser': 8.59.2(eslint@9.39.4(jiti@2.7.0))(typescript@6.0.3)
+ '@typescript-eslint/typescript-estree': 8.59.2(typescript@6.0.3)
+ '@typescript-eslint/utils': 8.59.2(eslint@9.39.4(jiti@2.7.0))(typescript@6.0.3)
+ eslint: 9.39.4(jiti@2.7.0)
typescript: 6.0.3
transitivePeerDependencies:
- supports-color
@@ -11047,11 +11241,11 @@ snapshots:
vite@8.0.10(@types/node@20.19.39)(esbuild@0.27.7)(jiti@2.7.0)(tsx@4.21.0)(yaml@2.9.0):
dependencies:
- lightningcss: 1.32.0
- picomatch: 4.0.4
- postcss: 8.5.14
+ lightningcss: 1.33.0
+ picomatch: 4.0.7
+ postcss: 8.5.28
rolldown: 1.0.0-rc.17
- tinyglobby: 0.2.16
+ tinyglobby: 0.2.17
optionalDependencies:
'@types/node': 20.19.39
esbuild: 0.27.7
diff --git a/src/agent-harness/answer-context.test.ts b/src/agent-harness/answer-context.test.ts
new file mode 100644
index 00000000..95ae6722
--- /dev/null
+++ b/src/agent-harness/answer-context.test.ts
@@ -0,0 +1,170 @@
+import { describe, expect, it } from "vitest"
+
+import { composeAnswerContext } from "./answer-context"
+import type { EvidenceLedgerSnapshot } from "./types"
+
+const revenuePng = new Uint8Array([1, 2, 3])
+
+describe("composeAnswerContext", () => {
+ it("uses Knowhere evidence, memory, and the original question", async () => {
+ const message = await composeAnswerContext({
+ ledger: makeLedger(),
+ memoryItems: [
+ {
+ ref: "mem:1",
+ itemId: "memory_1",
+ kind: "stance",
+ text: "关注毛利率 用户把毛利率当作核心指标。",
+ },
+ ],
+ userText: "Q4 的收入是多少?",
+ })
+
+ expect(message).toEqual({
+ role: "user",
+ content: [
+ {
+ type: "text",
+ text: [
+ "## Evidence from Knowledge Base",
+ "Revenue increased in Q4.",
+ "
",
+ "",
+ ].join("\n"),
+ },
+ {
+ type: "image",
+ image: revenuePng,
+ mediaType: "image/png",
+ },
+ {
+ type: "text",
+ text: [
+ "## Fluid Memory",
+ "",
+ '[memory ref="mem:1" kind="stance"]',
+ "关注毛利率 用户把毛利率当作核心指标。",
+ "",
+ "## User's Question",
+ "Q4 的收入是多少?",
+ ].join("\n"),
+ },
+ ],
+ })
+ })
+
+ it("puts profile and lessons before knowledge and memory", async () => {
+ const message = await composeAnswerContext({
+ ledger: {
+ ...makeLedger(),
+ retrievalCount: 0,
+ chunks: [],
+ evidence: [],
+ },
+ memoryItems: [],
+ profile: { occupation: "教师" },
+ agentFeedbackLessons: [
+ {
+ itemId: "fb_1",
+ text: "查毛利率 引用错了",
+ reflection: "下次先核对引用",
+ },
+ ],
+ userText: "再查一次",
+ })
+
+ const text = userContentParts(message)
+ .filter((part) => part.type === "text")
+ .map((part) => part.text)
+ .join("\n")
+ expect(text.indexOf("## User Profile")).toBeLessThan(
+ text.indexOf("## Lessons from Past Mistakes"),
+ )
+ expect(text).toContain("occupation: 教师")
+ expect(text).toContain("下次先核对引用")
+ expect(text).toContain("## User's Question")
+ })
+
+ it("omits knowledge and memory sections when neither search ran", async () => {
+ const message = await composeAnswerContext({
+ ledger: {
+ ...makeLedger(),
+ retrievalCount: 0,
+ chunks: [],
+ evidence: [],
+ },
+ memoryItems: [],
+ userText: "hello",
+ })
+
+ expect(message).toEqual({
+ role: "user",
+ content: [{ type: "text", text: "## User's Question\nhello" }],
+ })
+ })
+
+ it("says no knowledge base results when search ran but evidence is empty", async () => {
+ const message = await composeAnswerContext({
+ ledger: {
+ ...makeLedger(),
+ evidence: [],
+ },
+ memoryItems: [],
+ userText: "Q4?",
+ })
+
+ const text = userContentParts(message)
+ .filter((part) => part.type === "text")
+ .map((part) => part.text)
+ .join("")
+ expect(text).toContain("No knowledge base results were found")
+ expect(text).not.toContain("")
+ })
+})
+
+function makeLedger(): EvidenceLedgerSnapshot {
+ return {
+ retrievalCount: 1,
+ chunks: [
+ {
+ ref: "r1:result:1",
+ kind: "result",
+ content: "Revenue increased in Q4.\n[tables/revenue.html]\n[images/revenue.png]",
+ contentPreview: "Revenue increased in Q4.",
+ chunkType: "text",
+ score: 0.9,
+ source: {
+ documentId: "doc_1",
+ sourceFileName: "report.pdf",
+ sectionPath: "Summary",
+ },
+ },
+ ],
+ assets: [],
+ evidence: [
+ {
+ type: "text",
+ text: "Revenue increased in Q4.\n\n",
+ },
+ {
+ type: "image",
+ mediaType: "image/png",
+ data: Buffer.from(revenuePng).toString("base64"),
+ },
+ ],
+ evidenceText: [],
+ stopReasons: [],
+ failureReasons: [],
+ decisionTraces: [],
+ }
+}
+
+function userContentParts(message: { readonly content: unknown }): readonly {
+ readonly type: string
+ readonly text?: string
+}[] {
+ if (!Array.isArray(message.content)) {
+ throw new Error("expected composed message content to be an array")
+ }
+ return message.content
+}
diff --git a/src/agent-harness/answer-context.ts b/src/agent-harness/answer-context.ts
new file mode 100644
index 00000000..6c1305af
--- /dev/null
+++ b/src/agent-harness/answer-context.ts
@@ -0,0 +1,149 @@
+import type { ModelMessage } from "ai"
+
+import type {
+ AgentFeedbackLesson,
+ EvidenceLedgerSnapshot,
+ EvidencePart,
+ MemorySearchItem,
+ WorkspaceProfile,
+} from "./types"
+
+type UserContentParts = Exclude<
+ Extract["content"],
+ string
+>
+
+export async function composeAnswerContext(input: {
+ readonly ledger: EvidenceLedgerSnapshot
+ readonly memoryItems: readonly MemorySearchItem[]
+ readonly memorySearchAttempted?: boolean
+ readonly userText: string
+ readonly profile?: WorkspaceProfile | null
+ readonly agentFeedbackLessons?: readonly AgentFeedbackLesson[]
+}): Promise {
+ const content: UserContentParts = []
+
+ const profileText = formatProfile(input.profile)
+ if (profileText) {
+ appendText(content, `## User Profile\n${profileText}`)
+ }
+
+ if (input.agentFeedbackLessons && input.agentFeedbackLessons.length > 0) {
+ appendText(
+ content,
+ [
+ "## Lessons from Past Mistakes",
+ ...input.agentFeedbackLessons.map(formatLesson),
+ ].join("\n\n"),
+ )
+ }
+
+ if (input.ledger.evidence.length === 0 && input.ledger.retrievalCount > 0) {
+ appendText(
+ content,
+ "## Evidence from Knowledge Base\nNo knowledge base results were found for this search. Answer using your own knowledge only, and say so if relevant.",
+ )
+ }
+
+ if (input.ledger.evidence.length > 0) {
+ appendText(content, "## Evidence from Knowledge Base")
+ appendRawText(content, "\n")
+ for (const part of input.ledger.evidence) {
+ appendEvidencePart(content, part)
+ }
+ }
+
+ if (input.memoryItems.length > 0) {
+ appendText(content, [
+ "## Fluid Memory",
+ ...input.memoryItems.map(formatMemoryItem),
+ ].join("\n\n"))
+ } else if (input.memorySearchAttempted) {
+ appendText(
+ content,
+ "## Fluid Memory\nNo fluid memory results were found for this search.",
+ )
+ }
+
+ const userText = input.userText.trim()
+ if (userText) {
+ appendText(content, `## User's Question\n${userText}`)
+ }
+
+ return { role: "user", content }
+}
+
+function appendEvidencePart(
+ content: UserContentParts,
+ part: EvidencePart,
+): void {
+ if (part.type === "text") {
+ appendRawText(content, part.text)
+ return
+ }
+ content.push({
+ type: "image",
+ image: decodeBase64(part.data),
+ mediaType: part.mediaType,
+ })
+}
+
+function appendText(
+ content: UserContentParts,
+ text: string,
+): void {
+ const trimmed = text.trim()
+ if (!trimmed) return
+ const previous = content.at(-1)
+ if (previous?.type === "text") {
+ previous.text = `${previous.text}\n\n${trimmed}`
+ return
+ }
+ content.push({ type: "text", text: trimmed })
+}
+
+function appendRawText(content: UserContentParts, text: string): void {
+ if (text.length === 0) return
+ const previous = content.at(-1)
+ if (previous?.type === "text") {
+ previous.text += text
+ return
+ }
+ content.push({ type: "text", text })
+}
+
+function formatProfile(profile: WorkspaceProfile | null | undefined): string | null {
+ if (!profile) return null
+ const lines = (
+ [
+ ["name", profile.name],
+ ["occupation", profile.occupation],
+ ["ageStage", profile.ageStage],
+ ["communicationHabit", profile.communicationHabit],
+ ["workHabit", profile.workHabit],
+ ] as const
+ ).flatMap(([key, value]) =>
+ value && value.length > 0 ? [`${key}: ${value}`] : [],
+ )
+ return lines.length > 0 ? lines.join("\n") : null
+}
+
+function formatLesson(lesson: AgentFeedbackLesson): string {
+ return [lesson.text.trim(), lesson.reflection.trim()]
+ .filter((part) => part.length > 0)
+ .join("\n")
+}
+
+function formatMemoryItem(item: MemorySearchItem): string {
+ return [
+ `[memory ref="${item.ref}" kind="${item.kind}"]`,
+ item.text.trim(),
+ ]
+ .filter((part) => part.length > 0)
+ .join("\n")
+}
+
+function decodeBase64(data: string): Uint8Array {
+ const buffer = Buffer.from(data, "base64")
+ return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength)
+}
diff --git a/src/agent-harness/index.ts b/src/agent-harness/index.ts
index 40e843bb..c2b33eec 100644
--- a/src/agent-harness/index.ts
+++ b/src/agent-harness/index.ts
@@ -1,3 +1,4 @@
+export * from "./answer-context"
export * from "./image-highlights"
export * from "./ledger"
export * from "./knowhere-text"
diff --git a/src/agent-harness/knowhere-text.test.ts b/src/agent-harness/knowhere-text.test.ts
index af1094e9..c07564e2 100644
--- a/src/agent-harness/knowhere-text.test.ts
+++ b/src/agent-harness/knowhere-text.test.ts
@@ -23,10 +23,12 @@ describe("knowhereToolText", () => {
expect(text).toContain('ref="r1:result:1"')
expect(text).toContain('ref="asset:r1:result:1"')
expect(text).toContain("Page one summary.")
- expect(text).toContain("Call inspectImage")
- expect(text).toContain("before finalize")
+ expect(text).not.toContain("inspectImage")
+ expect(text).not.toContain("asset_instruction")
expect(text).not.toContain("")
expect(text).not.toContain("Page one evidence.")
+ expect(text).not.toContain("referencedChunkCount")
+ expect(text).not.toContain("provenance-only-id")
expect(text).not.toContain("https://assets.example/page-1.png")
})
@@ -81,6 +83,12 @@ function makeSearchResponse(): RetrievalQueryResponse {
},
},
],
- referencedChunks: [],
+ referencedChunks: [
+ {
+ documentId: "doc_1",
+ chunkId: "provenance-only-id",
+ pageNums: [],
+ },
+ ] as unknown as RetrievalQueryResponse["referencedChunks"],
}
}
diff --git a/src/agent-harness/knowhere-text.ts b/src/agent-harness/knowhere-text.ts
index 5f55ff78..c3a4cc67 100644
--- a/src/agent-harness/knowhere-text.ts
+++ b/src/agent-harness/knowhere-text.ts
@@ -20,9 +20,6 @@ type ErrorTextInput = {
type KnowhereOperation = "search"
-const assetInstruction =
- "Notebook returned image/page asset refs. Call inspectImage with the asset refs you will cite before finalize so OCR/visual context and provenance boxes exist. Do not expose raw asset URLs."
-
export const knowhereToolText = {
formatSearch(input: SearchTextInput): string {
return wrapKnowhereBlock("search", [
@@ -31,7 +28,6 @@ export const knowhereToolText = {
namespace: input.response.namespace,
query: input.response.query,
resultCount: String(input.response.results.length),
- referencedChunkCount: String(input.response.referencedChunks.length),
stopReason: input.response.stopReason ?? undefined,
failureReason: input.response.failureReason ?? undefined,
}),
@@ -39,7 +35,6 @@ export const knowhereToolText = {
// evidenceText — same bodies, no citeable refs, doubles context.
formatEvidenceChunks(input.chunks, input.chunkPickStart),
formatEvidenceAssets(input.assets),
- formatAssetInstruction(input.assets),
])
},
@@ -88,7 +83,6 @@ function formatEvidenceChunks(
sectionPath: chunk.source.sectionPath ?? undefined,
sourceChunkPath: chunk.sourceChunkPath ?? undefined,
filePath: chunk.filePath ?? undefined,
- assetRef: chunk.assetRef,
}),
formatTextTag("content", chunk.content),
"",
@@ -119,11 +113,6 @@ function formatEvidenceAssets(assets: readonly EvidenceAsset[]): string {
].join("\n")
}
-function formatAssetInstruction(assets: readonly EvidenceAsset[]): string {
- if (!assets.some((asset) => asset.type === "image")) return ""
- return formatTextTag("asset_instruction", assetInstruction)
-}
-
function formatTextTag(tagName: string, value: string): string {
return [`<${tagName}>`, value, `${tagName}>`].join("\n")
}
diff --git a/src/agent-harness/ledger.test.ts b/src/agent-harness/ledger.test.ts
index 6d3bdb32..8f151b8c 100644
--- a/src/agent-harness/ledger.test.ts
+++ b/src/agent-harness/ledger.test.ts
@@ -1,7 +1,8 @@
-import { describe, expect, it } from "vitest"
+import { describe, expect, it, vi } from "vitest"
import type { RetrievalQueryResponse } from "@ontos-ai/knowhere-sdk"
import { createEvidenceLedger } from "./ledger"
+import type { ResolveConnectedAssets } from "./types"
describe("createEvidenceLedger", () => {
it("normalizes retrieval chunks and media assets without treating candidates as final output", () => {
@@ -10,6 +11,7 @@ describe("createEvidenceLedger", () => {
const snapshot = ledger.addRetrievalResponse(makeRetrievalResponse())
expect(snapshot.retrievalCount).toBe(1)
+ expect(snapshot.evidence).toEqual([{ type: "text", text: "Evidence tree" }])
expect(snapshot.chunks.map((chunk) => chunk.ref)).toEqual([
"r1:result:1",
"r1:result:2",
@@ -177,17 +179,149 @@ describe("createEvidenceLedger", () => {
},
},
],
- // Real agent_explore responses can return referencedChunks entries
- // that only carry a summary id, with no chunkType/chunkId/documentId
- // even though the SDK type declares those as required strings.
+ // Real agent_explore responses carry provenance IDs without evidence
+ // fields even though the SDK type declares chunkType as required.
referencedChunks: [
- { summary: "8da0776b-c52b-5602-8579-25c421706f5f" },
+ {
+ documentId: "doc_1",
+ chunkId: "8da0776b-c52b-5602-8579-25c421706f5f",
+ pageNums: [],
+ },
] as unknown as RetrievalQueryResponse["referencedChunks"],
})
expect(snapshot.chunks.map((chunk) => chunk.ref)).toEqual(["r1:result:1"])
expect(snapshot.chunks[0]?.content).toBe("Target BP is <130/80 mmHg.")
})
+
+ it("keeps an empty ledger when a search adds no chunks", () => {
+ const ledger = createEvidenceLedger()
+ const snapshot = ledger.addRetrievalResponse({
+ namespace: "notebook",
+ query: "empty",
+ routerUsed: "workflow_single_step",
+ answerText: null,
+ evidenceText: "No hits",
+ stopReason: "completed",
+ failureReason: null,
+ results: [],
+ referencedChunks: [],
+ })
+
+ expect(snapshot.chunks).toEqual([])
+ })
+
+ it("resolves every embedded table and image connected to search text", async () => {
+ const ledger = createEvidenceLedger()
+ ledger.addRetrievalResponse({
+ ...makeRetrievalResponse(),
+ results: [
+ {
+ chunkId: "text_chunk",
+ content: "Comparison [tables/comparison.html]",
+ chunkType: "text",
+ score: 0.9,
+ metadata: {
+ connectTo: [
+ {
+ target: "table_chunk",
+ relation: "embeds",
+ ref: "[tables/comparison.html]",
+ },
+ {
+ target: "image_chunk_1",
+ relation: "embeds",
+ ref: "[images/comparison-a.jpg]",
+ },
+ {
+ target: "image_chunk_2",
+ relation: "embeds",
+ ref: "[images/comparison-b.jpg]",
+ },
+ ],
+ },
+ source: {
+ documentId: "doc_1",
+ sourceFileName: "cardiology.pdf",
+ sectionPath: "Differential diagnosis",
+ },
+ },
+ ],
+ referencedChunks: [],
+ })
+ const resolveConnectedAssets = vi.fn(
+ async (lookups) =>
+ lookups.map((lookup) => ({
+ ...lookup,
+ assetUrl: `https://assets.example/${lookup.chunkId}`,
+ })),
+ )
+
+ const snapshot = await ledger.resolveConnectedAssets(
+ resolveConnectedAssets,
+ )
+
+ expect(resolveConnectedAssets).toHaveBeenCalledWith([
+ { documentId: "doc_1", chunkId: "table_chunk", type: "table" },
+ { documentId: "doc_1", chunkId: "image_chunk_1", type: "image" },
+ { documentId: "doc_1", chunkId: "image_chunk_2", type: "image" },
+ ])
+ expect(snapshot.assets).toEqual([
+ expect.objectContaining({
+ ref: "asset:r1:result:1:table_chunk",
+ chunkRef: "r1:result:1",
+ type: "table",
+ sourcePath: "tables/comparison.html",
+ }),
+ expect.objectContaining({
+ ref: "asset:r1:result:1:image_chunk_1",
+ chunkRef: "r1:result:1",
+ type: "image",
+ sourcePath: "images/comparison-a.jpg",
+ }),
+ expect.objectContaining({
+ ref: "asset:r1:result:1:image_chunk_2",
+ chunkRef: "r1:result:1",
+ type: "image",
+ sourcePath: "images/comparison-b.jpg",
+ }),
+ ])
+ })
+
+ it("does not block the ledger when no connected asset resolver is provided", async () => {
+ const ledger = createEvidenceLedger()
+ ledger.addRetrievalResponse({
+ ...makeRetrievalResponse(),
+ results: [
+ {
+ chunkId: "text_chunk",
+ content: "Comparison [tables/comparison.html]",
+ chunkType: "text",
+ score: 0.9,
+ metadata: {
+ connectTo: [
+ {
+ target: "table_chunk",
+ relation: "embeds",
+ ref: "[tables/comparison.html]",
+ },
+ ],
+ },
+ source: {
+ documentId: "doc_1",
+ sourceFileName: "cardiology.pdf",
+ sectionPath: "Differential diagnosis",
+ },
+ },
+ ],
+ referencedChunks: [],
+ })
+
+ const snapshot = await ledger.resolveConnectedAssets()
+
+ expect(snapshot.evidence).toEqual([{ type: "text", text: "Evidence tree" }])
+ expect(snapshot.assets).toEqual([])
+ })
})
function makeRetrievalResponse(): RetrievalQueryResponse {
@@ -197,6 +331,7 @@ function makeRetrievalResponse(): RetrievalQueryResponse {
routerUsed: "workflow_single_step",
answerText: null,
evidenceText: "Evidence tree",
+ evidence: [{ type: "text", text: "Evidence tree" }],
stopReason: "answer_done",
failureReason: null,
decisionTrace: [{ step: "search" }],
@@ -232,7 +367,7 @@ function makeRetrievalResponse(): RetrievalQueryResponse {
assetUrl: "https://assets.example/images/photo.jpg",
},
],
- }
+ } as unknown as RetrievalQueryResponse
}
function makePageAssetUrlRetrievalResponse(): RetrievalQueryResponse {
diff --git a/src/agent-harness/ledger.ts b/src/agent-harness/ledger.ts
index 9c80448d..59092eff 100644
--- a/src/agent-harness/ledger.ts
+++ b/src/agent-harness/ledger.ts
@@ -7,7 +7,10 @@ import type {
EvidenceAsset,
EvidenceChunk,
EvidenceLedgerSnapshot,
+ EvidencePart,
+ ResolveConnectedAssets,
} from "./types"
+import { hasReferencedChunkEvidence } from "./referenced-chunks"
const contentPreviewLimit = 1_200
const imageExtensions = [".jpg", ".jpeg", ".png", ".gif", ".webp", ".svg"] as const
@@ -16,6 +19,7 @@ type MutableLedger = {
retrievalCount: number
chunks: EvidenceChunk[]
assets: EvidenceAsset[]
+ evidence: EvidencePart[]
evidenceText: string[]
stopReasons: string[]
failureReasons: string[]
@@ -29,6 +33,15 @@ type EvidenceAssetCandidate = {
readonly label: string
}
+type ConnectedAssetCandidate = {
+ readonly chunkRef: string
+ readonly targetChunkId: string
+ readonly documentId: string
+ readonly type: EvidenceAsset["type"]
+ readonly sourcePath: string
+ readonly source: EvidenceChunk["source"]
+}
+
type PageCitationAssetCandidate = {
readonly pageNum: number
readonly artifactRef?: string
@@ -43,6 +56,7 @@ export function createEvidenceLedger() {
retrievalCount: 0,
chunks: [],
assets: [],
+ evidence: [],
evidenceText: [],
stopReasons: [],
failureReasons: [],
@@ -54,6 +68,8 @@ export function createEvidenceLedger() {
ledger.retrievalCount += 1
const retrievalIndex = ledger.retrievalCount
+ ledger.evidence.push(...readQueryEvidence(response))
+
const evidenceText = response.evidenceText?.trim()
if (evidenceText) ledger.evidenceText.push(evidenceText)
@@ -76,15 +92,9 @@ export function createEvidenceLedger() {
})
response.referencedChunks.forEach((chunk, index) => {
- // Knowhere's agent_explore router returns referencedChunks entries
- // that may carry only a summary id with no chunkType/content
- // (despite the SDK type declaring chunkType as required). Skip
- // entries missing a usable chunkType: they have no real content
- // (content is always "" here) and chunkType is required downstream
- // (asset-type detection calls chunkType.toLowerCase()).
- if (typeof chunk.chunkType !== "string" || chunk.chunkType.trim().length === 0) {
- return
- }
+ // ID-only references are provenance, not evidence. Structured page
+ // and media references remain available to the citation pipeline.
+ if (!hasReferencedChunkEvidence(chunk)) return
const content = ""
addChunk({
ledger,
@@ -113,6 +123,46 @@ export function createEvidenceLedger() {
return snapshot(ledger)
},
+ async resolveConnectedAssets(
+ resolveConnectedAssets?: ResolveConnectedAssets,
+ ): Promise {
+ const candidates = getConnectedAssetCandidates(ledger)
+ if (candidates.length === 0 || !resolveConnectedAssets) {
+ return snapshot(ledger)
+ }
+
+ const lookups = uniqueConnectedAssetLookups(candidates)
+ const resolved = await resolveConnectedAssets(lookups)
+ const assetUrlByLookup = new Map(
+ resolved.map((asset) => [connectedAssetLookupKey(asset), asset.assetUrl]),
+ )
+
+ for (const candidate of candidates) {
+ const lookupKey = connectedAssetLookupKey({
+ documentId: candidate.documentId,
+ chunkId: candidate.targetChunkId,
+ type: candidate.type,
+ })
+ const assetUrl = assetUrlByLookup.get(lookupKey)
+ if (!assetUrl) {
+ throw new Error(
+ `Connected ${candidate.type} chunk ${candidate.targetChunkId} was not resolved.`,
+ )
+ }
+ ledger.assets.push({
+ ref: `asset:${candidate.chunkRef}:${candidate.targetChunkId}`,
+ chunkRef: candidate.chunkRef,
+ type: candidate.type,
+ assetUrl,
+ sourcePath: candidate.sourcePath,
+ source: candidate.source,
+ label: formatConnectedAssetLabel(candidate),
+ })
+ }
+
+ return snapshot(ledger)
+ },
+
read(ref: string, offset = 0, limit = 4_000) {
const chunk = ledger.chunks.find((candidate) => candidate.ref === ref)
if (!chunk) {
@@ -143,7 +193,11 @@ export function createEvidenceLedger() {
},
hasEvidence(): boolean {
- return ledger.chunks.length > 0 || ledger.evidenceText.length > 0
+ return (
+ ledger.chunks.length > 0 ||
+ ledger.evidence.length > 0 ||
+ ledger.evidenceText.length > 0
+ )
},
snapshot(): EvidenceLedgerSnapshot {
@@ -183,7 +237,7 @@ function addChunkFromResult(input: {
function addChunk(input: {
readonly ledger: MutableLedger
- readonly chunk: Omit
+ readonly chunk: EvidenceChunk
}): void {
const asset = getEvidenceAssetCandidate(input.chunk)
if (!asset) {
@@ -192,23 +246,94 @@ function addChunk(input: {
}
const assetRef = `asset:${input.chunk.ref}`
- const chunk: EvidenceChunk = {
- ...input.chunk,
- assetRef,
- }
- input.ledger.chunks.push(chunk)
+ input.ledger.chunks.push(input.chunk)
input.ledger.assets.push({
ref: assetRef,
- chunkRef: chunk.ref,
+ chunkRef: input.chunk.ref,
type: asset.type,
...(asset.assetUrl ? { assetUrl: asset.assetUrl } : {}),
...(asset.sourcePath ? { sourcePath: asset.sourcePath } : {}),
- ...(chunk.revisionKey ? { revisionKey: chunk.revisionKey } : {}),
- source: chunk.source,
+ ...(input.chunk.revisionKey ? { revisionKey: input.chunk.revisionKey } : {}),
+ source: input.chunk.source,
label: asset.label,
})
}
+function getConnectedAssetCandidates(
+ ledger: MutableLedger,
+): ConnectedAssetCandidate[] {
+ return ledger.chunks.flatMap((chunk) => {
+ const documentId = getTrimmedString(chunk.source.documentId)
+ const connections = chunk.metadata?.connectTo ?? chunk.metadata?.connect_to
+ if (!Array.isArray(connections)) return []
+
+ return connections.flatMap((connection): ConnectedAssetCandidate[] => {
+ if (!isRecord(connection) || connection.relation !== "embeds") return []
+ const targetChunkId = getTrimmedString(connection.target)
+ const sourcePath = getConnectedAssetPath(connection.ref)
+ if (!targetChunkId || !sourcePath) return []
+ if (!documentId) {
+ throw new Error(
+ `Search result ${chunk.ref} has connected assets but no document ID.`,
+ )
+ }
+
+ return [{
+ chunkRef: chunk.ref,
+ targetChunkId,
+ documentId,
+ type: sourcePath.startsWith("images/") ? "image" : "table",
+ sourcePath,
+ source: chunk.source,
+ }]
+ })
+ })
+}
+
+function getConnectedAssetPath(value: unknown): string | null {
+ const ref = getTrimmedString(value)
+ if (!ref || !ref.startsWith("[") || !ref.endsWith("]")) return null
+ const path = ref.slice(1, -1).trim()
+ return path.startsWith("images/") || path.startsWith("tables/") ? path : null
+}
+
+function uniqueConnectedAssetLookups(
+ candidates: readonly ConnectedAssetCandidate[],
+) {
+ const lookups = new Map<
+ string,
+ { documentId: string; chunkId: string; type: EvidenceAsset["type"] }
+ >()
+ for (const candidate of candidates) {
+ const lookup = {
+ documentId: candidate.documentId,
+ chunkId: candidate.targetChunkId,
+ type: candidate.type,
+ }
+ lookups.set(connectedAssetLookupKey(lookup), lookup)
+ }
+ return [...lookups.values()]
+}
+
+function connectedAssetLookupKey(input: {
+ readonly documentId: string
+ readonly chunkId: string
+ readonly type: EvidenceAsset["type"]
+}): string {
+ return `${input.documentId}\u0000${input.type}\u0000${input.chunkId}`
+}
+
+function formatConnectedAssetLabel(candidate: ConnectedAssetCandidate): string {
+ return [
+ candidate.source.sourceFileName,
+ candidate.source.sectionPath,
+ candidate.sourcePath,
+ candidate.type,
+ ]
+ .filter((part): part is string => Boolean(part))
+ .join(" / ")
+}
+
function buildContentPreview(content: string): string {
const normalized = content.replace(/\s+/g, " ").trim()
if (normalized.length <= contentPreviewLimit) return normalized
@@ -233,7 +358,7 @@ function isRenderableAsset(chunkType: string, assetUrl: string): boolean {
}
function getEvidenceAssetCandidate(
- chunk: Omit,
+ chunk: EvidenceChunk,
): EvidenceAssetCandidate | null {
const pageAsset = getPageCitationAssetCandidate(chunk)
if (pageAsset) {
@@ -253,7 +378,7 @@ function getEvidenceAssetCandidate(
}
function getPageCitationAssetCandidate(
- chunk: Omit,
+ chunk: EvidenceChunk,
): EvidenceAssetCandidate | null {
if (normalizeChunkType(chunk.chunkType) !== "page") return null
@@ -296,7 +421,7 @@ function isImageAssetUrl(assetUrl: string): boolean {
}
function getAssetSourcePath(
- chunk: Omit,
+ chunk: EvidenceChunk,
assetUrl: string,
): string | null {
const candidates = [
@@ -481,6 +606,7 @@ function snapshot(ledger: MutableLedger): EvidenceLedgerSnapshot {
retrievalCount: ledger.retrievalCount,
chunks: [...ledger.chunks],
assets: [...ledger.assets],
+ evidence: [...ledger.evidence],
evidenceText: [...ledger.evidenceText],
stopReasons: [...ledger.stopReasons],
failureReasons: [...ledger.failureReasons],
@@ -488,6 +614,34 @@ function snapshot(ledger: MutableLedger): EvidenceLedgerSnapshot {
}
}
+function readQueryEvidence(
+ response: RetrievalQueryResponse,
+): EvidencePart[] {
+ const evidence = (response as { evidence?: unknown }).evidence
+ if (!Array.isArray(evidence)) return []
+ const parts: EvidencePart[] = []
+ for (const item of evidence) {
+ const part = asEvidencePart(item)
+ if (part) parts.push(part)
+ }
+ return parts
+}
+
+function asEvidencePart(value: unknown): EvidencePart | null {
+ if (!isRecord(value)) return null
+ if (value.type === "text" && typeof value.text === "string") {
+ return { type: "text", text: value.text }
+ }
+ if (
+ value.type === "image" &&
+ typeof value.mediaType === "string" &&
+ typeof value.data === "string"
+ ) {
+ return { type: "image", mediaType: value.mediaType, data: value.data }
+ }
+ return null
+}
+
function getDecisionTrace(response: RetrievalQueryResponse): unknown | null {
const record = response as RetrievalQueryResponse & {
readonly decision_trace?: unknown
diff --git a/src/agent-harness/memory-text.test.ts b/src/agent-harness/memory-text.test.ts
index aa1699de..1967ad1d 100644
--- a/src/agent-harness/memory-text.test.ts
+++ b/src/agent-harness/memory-text.test.ts
@@ -3,7 +3,7 @@ import { describe, expect, it } from "vitest"
import { memoryToolText } from "./memory-text"
describe("memoryToolText", () => {
- it("formats search results with memory refs and stored summaries", () => {
+ it("formats search results with memory refs and stored text", () => {
const text = memoryToolText.formatSearch({
query: "毛利率",
items: [
@@ -11,8 +11,7 @@ describe("memoryToolText", () => {
ref: "mem:1",
itemId: "item_1",
kind: "stance",
- abstractL0: "关注毛利率下滑",
- overviewL1: "用户把毛利率当作核心观察指标。",
+ text: "关注毛利率下滑 用户把毛利率当作核心观察指标。",
},
],
})
@@ -20,10 +19,9 @@ describe("memoryToolText", () => {
expect(text).toContain('')
expect(text).toContain('query="毛利率"')
expect(text).toContain('ref="mem:1"')
- expect(text).toContain('itemId="item_1"')
+ expect(text).not.toContain("itemId")
expect(text).toContain('kind="stance"')
- expect(text).toContain("关注毛利率下滑")
- expect(text).toContain("用户把毛利率当作核心观察指标。")
+ expect(text).toContain("关注毛利率下滑 用户把毛利率当作核心观察指标。")
})
it("formats an empty search without inventing items", () => {
@@ -35,4 +33,15 @@ describe("memoryToolText", () => {
expect(text).toContain('resultCount="0"')
expect(text).not.toContain("- {
+ const text = memoryToolText.formatWarning({
+ operation: "search",
+ message: "MEMENTO_BASE_URL is required.",
+ })
+
+ expect(text).toContain('')
+ expect(text).toContain("MEMENTO_BASE_URL is required.")
+ expect(text).not.toContain('status="error"')
+ })
})
diff --git a/src/agent-harness/memory-text.ts b/src/agent-harness/memory-text.ts
index 0ab33462..e0c02783 100644
--- a/src/agent-harness/memory-text.ts
+++ b/src/agent-harness/memory-text.ts
@@ -19,17 +19,28 @@ export const memoryToolText = {
},
formatError(input: ErrorTextInput): string {
- return [
- formatOpenTag("memory", {
- operation: input.operation,
- status: "error",
- }),
- formatTextTag("message", input.message),
- "",
- ].join("\n")
+ return formatStatusBlock(input, "error")
+ },
+
+ formatWarning(input: ErrorTextInput): string {
+ return formatStatusBlock(input, "warning")
},
} as const
+function formatStatusBlock(
+ input: ErrorTextInput,
+ status: "error" | "warning",
+): string {
+ return [
+ formatOpenTag("memory", {
+ operation: input.operation,
+ status,
+ }),
+ formatTextTag("message", input.message),
+ "
",
+ ].join("\n")
+}
+
function formatMemoryItems(response: MemorySearchResponse): string {
if (response.items.length === 0) return ""
@@ -39,11 +50,9 @@ function formatMemoryItems(response: MemorySearchResponse): string {
[
formatOpenTag("item", {
ref: item.ref,
- itemId: item.itemId,
kind: item.kind,
}),
- formatTextTag("abstract_l0", item.abstractL0),
- formatTextTag("overview_l1", item.overviewL1),
+ formatTextTag("text", item.text),
"",
].join("\n"),
),
diff --git a/src/agent-harness/referenced-chunks.ts b/src/agent-harness/referenced-chunks.ts
new file mode 100644
index 00000000..ccde61b7
--- /dev/null
+++ b/src/agent-harness/referenced-chunks.ts
@@ -0,0 +1,7 @@
+import type { RetrievalQueryResponse } from "@ontos-ai/knowhere-sdk"
+
+type ReferencedChunk = RetrievalQueryResponse["referencedChunks"][number]
+
+export function hasReferencedChunkEvidence(chunk: ReferencedChunk): boolean {
+ return typeof chunk.chunkType === "string" && chunk.chunkType.trim().length > 0
+}
diff --git a/src/agent-harness/runtime.test.ts b/src/agent-harness/runtime.test.ts
index d36ca1be..ca0afa03 100644
--- a/src/agent-harness/runtime.test.ts
+++ b/src/agent-harness/runtime.test.ts
@@ -1,11 +1,13 @@
import { describe, expect, it, vi } from "vitest"
import type { RetrievalQueryResponse } from "@ontos-ai/knowhere-sdk"
+import { MockLanguageModelV3 } from "ai/test"
import {
buildHarnessMessages,
buildHarnessSystemPrompt,
createHarnessTools,
prepareHarnessStep,
+ runAgentHarness,
sanitizeHarnessModelMessagesForStep,
} from "./runtime"
import { createEvidenceLedger } from "./ledger"
@@ -13,25 +15,138 @@ import type {
AgentTurnInput,
ContextPolicy,
HarnessToolCallTrace,
- ImageInspectionRequest,
IntentFrame,
KnowhereToolRuntime,
+ MemorySearchItem,
MemoryToolRuntime,
OutputManifest,
+ ResolveConnectedAssets,
} from "./types"
describe("agent harness runtime", () => {
- it("tells the agent to search fluid memory first and not treat every question as document retrieval", () => {
+ it("resolves connected assets, assembles once, and finalizes", async () => {
+ const modelResults = [
+ toolCallResult([
+ {
+ toolCallId: "intent",
+ toolName: "declareIntent",
+ input: {
+ task: "compare",
+ dependsOnPreviousTurn: false,
+ retrievalNeeded: "yes",
+ targetModalities: ["text", "image", "table"],
+ constraints: {},
+ groundingPolicy: "must_use_sources",
+ },
+ },
+ {
+ toolCallId: "context",
+ toolName: "setContextPolicy",
+ input: {
+ carryHistory: "none",
+ reason: "Self-contained request.",
+ activePriorTurnIds: [],
+ },
+ },
+ ]),
+ toolCallResult([
+ {
+ toolCallId: "search",
+ toolName: "knowhere_search",
+ input: { query: "comparison", targetContent: "all" },
+ },
+ ]),
+ toolCallResult([
+ {
+ toolCallId: "prepare",
+ toolName: "prepareAnswer",
+ input: {},
+ },
+ ]),
+ toolCallResult([
+ {
+ toolCallId: "finalize",
+ toolName: "finalize",
+ input: {
+ text: "Comparison [[cite:1]].",
+ citations: [{ pick: 1 }],
+ memoryCitations: [],
+ artifacts: [
+ {
+ type: "table",
+ ref: "asset:r1:result:1:table_chunk",
+ display: true,
+ reason: "Comparison table",
+ },
+ {
+ type: "image",
+ ref: "asset:r1:result:1:image_chunk",
+ display: true,
+ reason: "Comparison image",
+ },
+ ],
+ unresolved: [],
+ },
+ },
+ ]),
+ ]
+ let modelResultIndex = 0
+ const model = new MockLanguageModelV3({
+ supportedUrls: { "image/*": [/^https:\/\//] },
+ doGenerate: async () => {
+ const result = modelResults[modelResultIndex]
+ modelResultIndex += 1
+ if (!result) throw new Error("No mock model result remains.")
+ return result
+ },
+ })
+ const resolveConnectedAssets = vi.fn(
+ async (lookups) =>
+ lookups.map((lookup) => ({
+ ...lookup,
+ assetUrl: `https://assets.example/${lookup.chunkId}`,
+ })),
+ )
+ const result = await runAgentHarness({
+ model,
+ turn: makeTurnInput(),
+ knowhereTools: makeKnowhereTools(
+ vi.fn().mockResolvedValue(makeConnectedRetrievalResponse()),
+ ),
+ memoryTools: makeMemoryTools(),
+ resolveConnectedAssets,
+ })
+
+ expect(model.doGenerateCalls).toHaveLength(4)
+ expect(resolveConnectedAssets).toHaveBeenCalledWith([
+ { documentId: "doc_1", chunkId: "table_chunk", type: "table" },
+ { documentId: "doc_1", chunkId: "image_chunk", type: "image" },
+ ])
+ expect(JSON.stringify(model.doGenerateCalls[3]?.prompt)).toContain(
+ "",
+ )
+ expect(result.manifest.citations).toEqual([{ ref: "r1:result:1" }])
+ expect(result.trace.ledger.assets).toHaveLength(2)
+ })
+
+ it("tells the agent to search memory and documents in parallel when both apply", () => {
const prompt = buildHarnessSystemPrompt(makeTurnInput())
- expect(prompt).toContain("Call memory_search first")
+ expect(prompt).toContain("call them together in the same step")
expect(prompt).toContain(
- "Call knowhere_search only when memory is insufficient and groundingPolicy requires citing source documents",
+ "Call knowhere_search once per turn when groundingPolicy requires citing source documents",
)
+ expect(prompt).toContain("Call knowhere_search once; do not change the query and search again")
+ expect(prompt).not.toContain("call knowhere_search again with a refined query")
+ expect(prompt).not.toContain("Refine knowhere_search at most twice")
+ expect(prompt).not.toContain("gapReason")
+ expect(prompt).not.toContain("retainEvidence")
expect(prompt).toContain(
- "call knowhere_search again with a refined query",
+ "Composed evidence is already assembled for the answer step",
+ )
+ expect(prompt).toContain(
+ "Do not search again because those assets have not been shown yet",
)
- expect(prompt).toContain("Refine knowhere_search at most twice")
expect(prompt).not.toContain("knowhere_list_documents")
expect(prompt).not.toContain("knowhere_get_document_outline")
expect(prompt).not.toContain("knowhere_read_chunks")
@@ -70,15 +185,16 @@ describe("agent harness runtime", () => {
expect(prompt).toContain("Do not collapse same-page citations")
})
- it("requires inspectImage on cited page/image assets before finalize", () => {
+ it("tells the agent to read retained images in the assembled answer message", () => {
const prompt = buildHarnessSystemPrompt(makeTurnInput())
expect(prompt).toContain(
- "call inspectImage on the page/image assets you will cite before finalize",
+ "memory_search and knowhere_search are parallel retrieval sources",
)
expect(prompt).toContain(
- "Do not finalize cited page/image assets from chunk text alone",
+ "Images in search evidence are embedded directly",
)
+ expect(prompt).not.toContain("inspectImage")
})
it("passes only outer retrieval parameters to KNOWHERE without planning-tool gating", async () => {
@@ -137,27 +253,10 @@ describe("agent harness runtime", () => {
expect(search).toHaveBeenCalledWith(expect.objectContaining(scope))
})
- it("returns only newly searched evidence in each knowhere_search tool result", async () => {
+ it("returns newly searched evidence from the one knowhere_search and rejects a second call", async () => {
const query = vi
.fn()
.mockResolvedValueOnce(makeRetrievalResponse())
- .mockResolvedValueOnce({
- ...makeRetrievalResponse(),
- query: "second query",
- evidenceText: "Second evidence",
- results: [
- {
- content: "Second retrieval evidence.",
- chunkType: "text",
- score: 0.8,
- source: {
- documentId: "doc_2",
- sourceFileName: "second.pdf",
- sectionPath: "Second",
- },
- },
- ],
- })
const state: {
intent?: IntentFrame
contextPolicy?: ContextPolicy
@@ -187,451 +286,20 @@ describe("agent harness runtime", () => {
})
const firstResult = await executeTool(tools.knowhere_search, { query: "first" })
- const secondResult = await executeTool(tools.knowhere_search, { query: "second" })
+ const secondResult = await executeTool(tools.knowhere_search, {
+ query: "second",
+ })
expect(firstResult).toContain('pick="1"')
expect(firstResult).toContain('ref="r1:result:1"')
- expect(secondResult).toContain('retrievalCount="2"')
- expect(secondResult).toContain("Second retrieval evidence.")
- expect(secondResult).not.toContain("")
- expect(secondResult).toContain('pick="2"')
- expect(secondResult).toContain('ref="r2:result:1"')
- expect(JSON.stringify(secondResult)).not.toContain("r1:result:1")
+ expect(secondResult).toContain('status="error"')
+ expect(String(secondResult)).toContain("already ran for this turn")
+ expect(query).toHaveBeenCalledTimes(1)
expect(ledger.snapshot().chunks.map((chunk) => chunk.ref)).toEqual([
"r1:result:1",
- "r2:result:1",
])
})
- it("rejects image inspection before retrieval has returned image assets", async () => {
- const inspectImages = vi.fn()
- const tools = createHarnessTools({
- state: {},
- ledger: createEvidenceLedger(),
- memoryTools: makeMemoryTools(),
- knowhereTools: makeKnowhereTools(),
- inspectImages,
- recentTurns: [],
- })
-
- const result = await executeTool(tools.inspectImage, {
- refs: ["asset:r1:result:1"],
- question: "What text is visible?",
- })
-
- expect(result).toEqual({
- ok: false,
- message:
- "Knowhere evidence tools must return image assets before inspectImage.",
- inspected: [],
- skipped: [
- {
- ref: "asset:r1:result:1",
- reason: "No Knowhere evidence is available yet.",
- },
- ],
- })
- expect(inspectImages).not.toHaveBeenCalled()
- })
-
- it("rejects image inspection refs that are unknown or not image assets", async () => {
- const ledger = createEvidenceLedger()
- ledger.addRetrievalResponse(makeTableRetrievalResponse())
- const inspectImages = vi.fn()
- const tools = createHarnessTools({
- state: {},
- ledger,
- memoryTools: makeMemoryTools(),
- knowhereTools: makeKnowhereTools(),
- inspectImages,
- recentTurns: [],
- })
-
- const result = await executeTool(tools.inspectImage, {
- refs: ["asset:r1:result:1", "missing"],
- question: "What is in these images?",
- })
-
- expect(result).toEqual({
- ok: false,
- message: "No inspectable image asset refs were provided.",
- inspected: [],
- skipped: [
- {
- ref: "asset:r1:result:1",
- reason: "Ref is not an image asset.",
- },
- {
- ref: "missing",
- reason: "Ref was not returned by Knowhere as an asset.",
- },
- ],
- })
- expect(inspectImages).not.toHaveBeenCalled()
- })
-
- it("lets retrieval bound the number of images inspected in one call", async () => {
- const ledger = createEvidenceLedger()
- ledger.addRetrievalResponse(makeImageRetrievalResponse(7))
- const inspectImages = vi.fn(async (request: {
- readonly assets: readonly { readonly ref: string; readonly label: string }[]
- }) => ({
- analysis: "Compared all retrieved images.",
- inspected: request.assets.map(({ ref, label }) => ({ ref, label })),
- skipped: [],
- }))
- const tools = createHarnessTools({
- state: {},
- ledger,
- memoryTools: makeMemoryTools(),
- knowhereTools: makeKnowhereTools(),
- inspectImages,
- recentTurns: [],
- })
-
- const result = await executeTool(tools.inspectImage, {
- refs: Array.from({ length: 7 }, (_, index) => `asset:r1:result:${index + 1}`),
- question: "Compare these images.",
- })
-
- expect(result).toMatchObject({ ok: true })
- expect(inspectImages.mock.calls[0]?.[0].assets).toHaveLength(7)
- })
-
- it("calls the visual inspection capability with retrieved image ledger assets", async () => {
- const ledger = createEvidenceLedger()
- ledger.addRetrievalResponse(makeRetrievalResponse())
- const inspectImages = vi.fn().mockResolvedValue({
- analysis: "The image shows a Q4 revenue chart with a rising line.",
- inspected: [
- {
- ref: "asset:r1:result:1",
- label: "report.pdf / images/chart.png / image",
- },
- ],
- skipped: [],
- })
- const tools = createHarnessTools({
- state: {},
- ledger,
- memoryTools: makeMemoryTools(),
- knowhereTools: makeKnowhereTools(),
- inspectImages,
- recentTurns: [],
- })
-
- const result = await executeTool(tools.inspectImage, {
- refs: ["asset:r1:result:1"],
- question: "What does the chart show?",
- })
-
- expect(inspectImages).toHaveBeenCalledWith({
- question: "What does the chart show?",
- assets: [
- {
- ref: "asset:r1:result:1",
- label: "report.pdf / images/chart.png / image",
- assetUrl: "https://assets.example/chart.png",
- sourcePath: "images/chart.png",
- source: {
- documentId: "doc_1",
- sourceFileName: "report.pdf",
- sectionPath: "images/chart.png",
- },
- },
- ],
- })
- expect(result).toEqual({
- ok: true,
- analysis: "The image shows a Q4 revenue chart with a rising line.",
- inspected: [
- {
- ref: "asset:r1:result:1",
- label: "report.pdf / images/chart.png / image",
- },
- ],
- skipped: [],
- })
- })
-
- it("calls the visual inspection capability with retrieved page citation assets", async () => {
- const ledger = createEvidenceLedger()
- ledger.addRetrievalResponse(makePageCitationRetrievalResponse())
- const inspectImages = vi.fn().mockResolvedValue({
- analysis: "The clause says the contractor pays 5000 yuan per occurrence.",
- inspected: [
- {
- ref: "asset:r1:referenced:1",
- label:
- "Root / (6)现场工期进度管理方面的违约责任 / page_citation_assets/page-8.png / page",
- },
- ],
- skipped: [],
- })
- const tools = createHarnessTools({
- state: {},
- ledger,
- memoryTools: makeMemoryTools(),
- knowhereTools: makeKnowhereTools(),
- inspectImages,
- recentTurns: [],
- })
-
- const result = await executeTool(tools.inspectImage, {
- refs: ["asset:r1:referenced:1"],
- question: "What liquidated damages amount is visible in this clause?",
- })
-
- expect(inspectImages).toHaveBeenCalledWith({
- question: "What liquidated damages amount is visible in this clause?",
- assets: [
- {
- ref: "asset:r1:referenced:1",
- label:
- "Root / (6)现场工期进度管理方面的违约责任 / page_citation_assets/page-8.png / page",
- assetUrl: "https://assets.example/page-8.png",
- sourcePath: "page_citation_assets/page-8.png",
- revisionKey: "job_contract",
- source: {
- documentId: "doc_contract",
- sourceFileName: null,
- sectionPath: "Root / (6)现场工期进度管理方面的违约责任",
- },
- },
- ],
- })
- expect(result).toMatchObject({
- ok: true,
- analysis: "The clause says the contractor pays 5000 yuan per occurrence.",
- })
- })
-
- it("inspects duplicate retrieved pages only once across namespaces", async () => {
- const ledger = createEvidenceLedger()
- const pageMetadata = {
- pageNums: [4],
- pageAssets: [
- {
- pageNum: 4,
- artifactRef: "page_citation_assets/page-4.png",
- assetUrl: "https://assets.example/page-4.png",
- contentType: "image/png",
- },
- ],
- }
- ledger.addRetrievalResponse({
- namespace: "default,notebook",
- query: "revenue",
- routerUsed: "mapnav",
- answerText: null,
- evidenceText: "Revenue evidence",
- stopReason: "completed",
- failureReason: null,
- results: [
- {
- chunkId: "chunk_page_4",
- content: "Revenue was $24.9B.",
- chunkType: "page",
- score: 0.9,
- metadata: pageMetadata,
- source: {
- documentId: "doc_catalog",
- sourceFileName: "original.pdf",
- sectionPath: "FINANCIAL SUMMARY",
- },
- },
- {
- chunkId: "chunk_page_4",
- content: "Revenue was $24.9B.",
- chunkType: "page",
- score: 0.9,
- metadata: pageMetadata,
- source: {
- documentId: "doc_workspace",
- sourceFileName: "TSLA-Q4-2025-Update.pdf",
- sectionPath: "FINANCIAL SUMMARY",
- },
- },
- ],
- referencedChunks: [],
- })
- const inspectImages = vi.fn().mockResolvedValue({
- analysis: "Revenue is visible in the financial summary.",
- inspected: [
- {
- ref: "asset:r1:result:1",
- label: "original.pdf / page_citation_assets/page-4.png / page",
- },
- ],
- skipped: [],
- highlights: [
- {
- ref: "asset:r1:result:1",
- regions: [{ x: 0.1, y: 0.2, w: 0.8, h: 0.1 }],
- },
- ],
- })
- const state: {
- inspectedImageRefs?: string[]
- } = {}
- const tools = createHarnessTools({
- state,
- ledger,
- memoryTools: makeMemoryTools(),
- knowhereTools: makeKnowhereTools(),
- inspectImages,
- recentTurns: [],
- })
-
- const inspection = await executeTool(tools.inspectImage, {
- refs: ["asset:r1:result:1", "asset:r1:result:2"],
- question: "Locate the cited revenue.",
- })
-
- expect(inspection).toMatchObject({ ok: true })
- expect(inspectImages.mock.calls[0]?.[0].assets).toHaveLength(1)
- expect(
- await executeTool(tools.finalize, {
- text: "Revenue was $24.9B [[cite:1]] [[cite:2]].",
- citations: [{ pick: 1 }, { pick: 2 }],
- memoryCitations: [],
- artifacts: [],
- unresolved: [],
- }),
- ).toMatchObject({ ok: true })
- })
-
- it("does not deduplicate unrelated documents with generic page paths", async () => {
- const ledger = createEvidenceLedger()
- ledger.addRetrievalResponse({
- namespace: "notebook",
- query: "revenue",
- routerUsed: "mapnav",
- answerText: null,
- evidenceText: "Revenue evidence",
- stopReason: "completed",
- failureReason: null,
- results: [
- {
- chunkId: "chunk_page_4",
- content: "Revenue evidence from document A.",
- chunkType: "page",
- score: 0.9,
- metadata: {
- pageNums: [4],
- pageAssets: [
- {
- pageNum: 4,
- artifactRef: "page_citation_assets/page-4.png",
- assetUrl: "https://assets.example/doc-a/page-4.png",
- contentType: "image/png",
- },
- ],
- },
- source: {
- documentId: "doc_a",
- sourceFileName: "a.pdf",
- sectionPath: "Page 4",
- },
- },
- {
- chunkId: "chunk_page_4",
- content: "Revenue evidence from document B.",
- chunkType: "page",
- score: 0.8,
- metadata: {
- pageNums: [4],
- pageAssets: [
- {
- pageNum: 4,
- artifactRef: "page_citation_assets/page-4.png",
- assetUrl: "https://assets.example/doc-b/page-4.png",
- contentType: "image/png",
- },
- ],
- },
- source: {
- documentId: "doc_b",
- sourceFileName: "b.pdf",
- sectionPath: "Page 4",
- },
- },
- ],
- referencedChunks: [],
- })
- const inspectImages = vi.fn(async (request: ImageInspectionRequest) => ({
- analysis: "Inspected both pages.",
- inspected: request.assets.map(({ ref, label }) => ({ ref, label })),
- skipped: [],
- }))
- const tools = createHarnessTools({
- state: {},
- ledger,
- memoryTools: makeMemoryTools(),
- knowhereTools: makeKnowhereTools(),
- inspectImages,
- recentTurns: [],
- })
-
- expect(
- await executeTool(tools.inspectImage, {
- refs: ["asset:r1:result:1", "asset:r1:result:2"],
- question: "Compare the cited revenue.",
- }),
- ).toMatchObject({ ok: true })
- expect(inspectImages.mock.calls[0]?.[0].assets).toHaveLength(2)
- })
-
- it("does not treat skipped image assets as successfully inspected", async () => {
- const ledger = createEvidenceLedger()
- ledger.addRetrievalResponse(makePageCitationRetrievalResponse())
- const state: {
- inspectedImageRefs?: string[]
- finalized?: boolean
- } = {}
- const tools = createHarnessTools({
- state,
- ledger,
- memoryTools: makeMemoryTools(),
- knowhereTools: makeKnowhereTools(),
- inspectImages: vi.fn().mockResolvedValue({
- analysis: "",
- inspected: [],
- skipped: [
- {
- ref: "asset:r1:referenced:1",
- reason: "The image asset was unavailable in Notebook storage.",
- },
- ],
- }),
- recentTurns: [],
- })
-
- const inspection = await executeTool(tools.inspectImage, {
- refs: ["asset:r1:referenced:1"],
- question: "Locate the cited amount.",
- })
-
- expect(inspection).toMatchObject({
- ok: false,
- inspected: [],
- })
- expect(state.inspectedImageRefs).toEqual([])
-
- const finalize = await executeTool(tools.finalize, {
- text: "The amount is 5000 yuan [[cite:1]].",
- citations: [{ pick: 1 }],
- memoryCitations: [],
- artifacts: [],
- unresolved: [],
- })
- expect(finalize).toMatchObject({
- ok: false,
- inspectRefs: ["asset:r1:referenced:1"],
- })
- expect(state.finalized).not.toBe(true)
- })
-
it("writes citation refs from ledger picks and rejects picks outside the ledger", async () => {
const ledger = createEvidenceLedger()
ledger.addRetrievalResponse(makeRetrievalResponse())
@@ -646,7 +314,6 @@ describe("agent harness runtime", () => {
knowhereTools: makeKnowhereTools(),
recentTurns: [],
})
-
const rejected = await executeTool(tools.finalize, {
text: "Target is <130/80 mmHg [[cite:1]].",
citations: [{ pick: 99 }],
@@ -682,6 +349,16 @@ describe("agent harness runtime", () => {
it("maps finalize picks across successive searches", async () => {
const ledger = createEvidenceLedger()
ledger.addRetrievalResponse(makeRetrievalResponse())
+ const state: {
+ finalizedManifest?: OutputManifest
+ } = {}
+ const tools = createHarnessTools({
+ state,
+ ledger,
+ memoryTools: makeMemoryTools(),
+ knowhereTools: makeKnowhereTools(),
+ recentTurns: [],
+ })
ledger.addRetrievalResponse({
...makeRetrievalResponse(),
query: "second query",
@@ -698,36 +375,52 @@ describe("agent harness runtime", () => {
},
],
})
+ const accepted = await executeTool(tools.finalize, {
+ text: "Second source [[cite:1]].",
+ citations: [{ pick: 2 }],
+ memoryCitations: [],
+ artifacts: [],
+ unresolved: [],
+ })
+
+ expect(accepted).toMatchObject({
+ ok: true,
+ citations: [{ ref: "r2:result:1" }],
+ })
+ expect(state.finalizedManifest?.citations).toEqual([{ ref: "r2:result:1" }])
+ })
+
+ it("accepts free-form text with no citations, displayed artifacts, or unresolved gaps", async () => {
const state: {
finalizedManifest?: OutputManifest
+ finalized?: boolean
} = {}
const tools = createHarnessTools({
state,
- ledger,
+ ledger: createEvidenceLedger(),
memoryTools: makeMemoryTools(),
knowhereTools: makeKnowhereTools(),
recentTurns: [],
})
- const accepted = await executeTool(tools.finalize, {
- text: "Second source [[cite:1]].",
- citations: [{ pick: 2 }],
+ const result = await executeTool(tools.finalize, {
+ text: "Hi there! How can I help?",
+ citations: [],
memoryCitations: [],
artifacts: [],
unresolved: [],
})
- expect(accepted).toMatchObject({
- ok: true,
- citations: [{ ref: "r2:result:1" }],
- })
- expect(state.finalizedManifest?.citations).toEqual([{ ref: "r2:result:1" }])
+ expect(result).toMatchObject({ ok: true })
+ expect(state.finalizedManifest?.text).toBe("Hi there! How can I help?")
+ expect(state.finalized).toBe(true)
})
- it("accepts finalize output without planning-tool gating", async () => {
+ it("accepts explicitly unresolved output without planning-tool gating", async () => {
const state: {
finalizedManifest?: OutputManifest
finalized?: boolean
+ memoryItems?: MemorySearchItem[]
} = {}
const tools = createHarnessTools({
state,
@@ -742,7 +435,7 @@ describe("agent harness runtime", () => {
citations: [],
memoryCitations: [],
artifacts: [],
- unresolved: [],
+ unresolved: ["No source evidence is available."],
}
expect(await executeTool(tools.finalize, manifest)).toMatchObject({
@@ -761,14 +454,14 @@ describe("agent harness runtime", () => {
ref: "mem:1",
itemId: "item_1",
kind: "stance",
- abstractL0: "关注毛利率下滑",
- overviewL1: "用户把毛利率当作核心观察指标。",
+ text: "关注毛利率下滑 用户把毛利率当作核心观察指标。",
},
],
})
const state: {
finalizedManifest?: OutputManifest
finalized?: boolean
+ memoryItems?: MemorySearchItem[]
} = {}
const tools = createHarnessTools({
state,
@@ -781,130 +474,75 @@ describe("agent harness runtime", () => {
const searchText = await executeTool(tools.memory_search, {
query: "毛利率",
})
+ const repeatedSearchText = await executeTool(tools.memory_search, {
+ query: "盈利能力",
+ })
expect(searchText).toContain('')
expect(searchText).toContain('ref="mem:1"')
- expect(searchText).toContain('itemId="item_1"')
- expect(search).toHaveBeenCalledWith({
+ expect(searchText).not.toContain("itemId")
+ expect(repeatedSearchText).toContain('status="error"')
+ expect(search).toHaveBeenCalledTimes(1)
+ expect(search).toHaveBeenNthCalledWith(1, {
query: "毛利率",
kinds: undefined,
})
+ expect(state.memoryItems).toEqual([
+ {
+ ref: "mem:1",
+ itemId: "item_1",
+ kind: "stance",
+ text: "关注毛利率下滑 用户把毛利率当作核心观察指标。",
+ },
+ ])
const manifest = {
text: "按已有记忆,毛利率是核心观察指标。",
citations: [],
- memoryCitations: [
- { ref: "mem:1", itemId: "item_1", kind: "stance" as const },
- ],
+ memoryCitations: [{ ref: "mem:1" }],
artifacts: [],
unresolved: [],
}
- expect(await executeTool(tools.finalize, manifest)).toMatchObject({
- ok: true,
- memoryCitations: manifest.memoryCitations,
- })
- expect(state.finalizedManifest).toEqual(manifest)
- })
-
- it("rejects finalize of cited page images until inspectImage has run", async () => {
- const ledger = createEvidenceLedger()
- ledger.addRetrievalResponse(makePageCitationRetrievalResponse())
- const state: {
- finalizedManifest?: OutputManifest
- finalized?: boolean
- inspectedImageRefs?: string[]
- } = {}
- const tools = createHarnessTools({
- state,
- ledger,
- memoryTools: makeMemoryTools(),
- knowhereTools: makeKnowhereTools(),
- inspectImages: vi.fn().mockResolvedValue({
- analysis: "The clause shows 5000 yuan per occurrence.",
- inspected: [{ ref: "asset:r1:referenced:1", label: "page 8" }],
- skipped: [],
- highlights: [
- {
- ref: "asset:r1:referenced:1",
- regions: [{ x: 0.1, y: 0.2, w: 0.4, h: 0.15 }],
- },
- ],
- }),
- recentTurns: [],
- })
- const manifest = {
- text: "The contractor pays 5000 yuan per occurrence [[cite:1]].",
- citations: [{ pick: 1 }],
- memoryCitations: [],
- artifacts: [],
- unresolved: [],
+ const resolvedMemoryCitations = [
+ { ref: "mem:1", itemId: "item_1", kind: "stance" as const },
+ ]
+ const invalidManifest = {
+ ...manifest,
+ memoryCitations: [{ ref: "mem:missing" }],
}
-
- const blocked = await executeTool(tools.finalize, manifest)
-
- expect(blocked).toMatchObject({
+ expect(await executeTool(tools.finalize, invalidManifest)).toMatchObject({
ok: false,
- inspectRefs: ["asset:r1:referenced:1"],
- })
- expect(blocked).toEqual(
- expect.objectContaining({
- message: expect.stringContaining("inspectImage"),
- }),
- )
- expect(state.finalized).not.toBe(true)
-
- await executeTool(tools.inspectImage, {
- refs: ["asset:r1:referenced:1"],
- question: "Locate the cited liquidated-damages amount on this page.",
+ invalidMemoryCitations: invalidManifest.memoryCitations,
})
+ expect(state.finalizedManifest).toBeUndefined()
expect(await executeTool(tools.finalize, manifest)).toMatchObject({
ok: true,
- text: manifest.text,
+ memoryCitations: resolvedMemoryCitations,
+ })
+ expect(state.finalizedManifest).toEqual({
+ ...manifest,
+ memoryCitations: resolvedMemoryCitations,
})
- expect(state.finalized).toBe(true)
})
- it("requires inspection when the cited result shares a page asset with a referenced chunk", async () => {
- const response = makePageCitationRetrievalResponse()
- const ledger = createEvidenceLedger()
- ledger.addRetrievalResponse({
- ...response,
- results: [
- {
- chunkId: "chunk_page_8",
- content: "The contractor pays 5000 yuan per occurrence.",
- chunkType: "page",
- score: 0.9,
- metadata: { pageNums: [8] },
- source: {
- documentId: "doc_contract",
- sourceFileName: "contract.pdf",
- sectionPath: "Root / Liquidated damages",
- },
- },
- ],
- })
+ it("returns a warning when memory_search cannot reach memory", async () => {
+ const search = vi
+ .fn()
+ .mockRejectedValue(new Error("MEMENTO_BASE_URL is required."))
const tools = createHarnessTools({
state: {},
- ledger,
- memoryTools: makeMemoryTools(),
+ ledger: createEvidenceLedger(),
+ memoryTools: makeMemoryTools(search),
knowhereTools: makeKnowhereTools(),
- inspectImages: vi.fn(),
recentTurns: [],
})
- const result = await executeTool(tools.finalize, {
- text: "The contractor pays 5000 yuan [[cite:1]].",
- citations: [{ pick: 1 }],
- memoryCitations: [],
- artifacts: [],
- unresolved: [],
- })
-
- expect(result).toMatchObject({
- ok: false,
- inspectRefs: ["asset:r1:referenced:1"],
+ const searchText = await executeTool(tools.memory_search, {
+ query: "毛利率",
})
+ expect(searchText).toContain('')
+ expect(searchText).toContain("MEMENTO_BASE_URL is required.")
+ expect(searchText).not.toContain('status="error"')
})
it("exposes full prior-turn content through policy-approved readPriorTurn", async () => {
@@ -1094,7 +732,6 @@ describe("agent harness runtime", () => {
expect(result.activeTools).toEqual([
"declareIntent",
"setContextPolicy",
- "inspectImage",
"readPriorTurn",
])
expect(result.activeTools).not.toContain("finalize")
@@ -1117,10 +754,29 @@ describe("agent harness runtime", () => {
})
expect(result.activeTools).toContain("memory_search")
- expect(result.activeTools).toContain("finalize")
+ expect(result.activeTools).toContain("prepareAnswer")
+ expect(result.activeTools).not.toContain("finalize")
expect(result.activeTools).not.toContain("knowhere_search")
})
+ it("does not expose memory_search again after its one call", () => {
+ const result = prepareHarnessStep({
+ stepNumber: 4,
+ hasMemorySearch: true,
+ intent: {
+ task: "answer",
+ dependsOnPreviousTurn: false,
+ retrievalNeeded: "maybe",
+ targetModalities: ["text"],
+ constraints: {},
+ groundingPolicy: "can_use_context",
+ },
+ messages: [],
+ })
+
+ expect(result.activeTools).not.toContain("memory_search")
+ })
+
it("keeps Knowhere tools closed for no_retrieval", () => {
const result = prepareHarnessStep({
stepNumber: 4,
@@ -1135,7 +791,8 @@ describe("agent harness runtime", () => {
messages: [],
})
- expect(result.activeTools).toContain("finalize")
+ expect(result.activeTools).toContain("prepareAnswer")
+ expect(result.activeTools).not.toContain("finalize")
expect(result.activeTools).not.toContain("memory_search")
expect(result.activeTools).not.toContain("knowhere_search")
})
@@ -1189,7 +846,7 @@ describe("agent harness runtime", () => {
expect(result.activeTools).not.toContain("knowhere_grep_chunks")
})
- it("reopens finalize after must_use_sources has called knowhere_search, including empty results", () => {
+ it("opens answer preparation after must_use_sources has called knowhere_search", () => {
const result = prepareHarnessStep({
stepNumber: 4,
hasKnowhereSearch: true,
@@ -1204,136 +861,75 @@ describe("agent harness runtime", () => {
messages: [],
})
- expect(result.activeTools).toContain("finalize")
- expect(result.activeTools).toContain("knowhere_search")
+ expect(result.activeTools).toContain("prepareAnswer")
+ expect(result.activeTools).not.toContain("finalize")
+ expect(result.activeTools).not.toContain("knowhere_search")
})
- it("forces image inspection before forced finalization when image assets are available", () => {
+ it("forces answer preparation after the one Knowhere search", () => {
const result = prepareHarnessStep({
- stepNumber: 12,
- hasUninspectedImageAssets: true,
- messages: [
- {
- role: "tool",
- content: [
- {
- type: "tool-result",
- toolCallId: "call_1",
- toolName: "knowhere_search",
- output: {
- type: "text",
- value:
- '',
- },
- },
- ],
- },
- ],
+ stepNumber: 8,
+ hasKnowhereSearch: true,
+ hasReachedKnowhereSearchLimit: true,
+ intent: {
+ task: "answer",
+ dependsOnPreviousTurn: false,
+ retrievalNeeded: "yes",
+ targetModalities: ["text"],
+ constraints: {},
+ groundingPolicy: "must_use_sources",
+ },
+ messages: [],
})
- expect(result.activeTools).toEqual(["inspectImage"])
+ expect(result.activeTools).toEqual(["prepareAnswer"])
expect(result.toolChoice).toEqual({
type: "tool",
- toolName: "inspectImage",
+ toolName: "prepareAnswer",
})
- expect(result.messages).toEqual([
- {
- role: "tool",
- content: [
- {
- type: "tool-result",
- toolCallId: "call_1",
- toolName: "knowhere_search",
- output: {
- type: "text",
- value:
- '',
- },
- },
- ],
- },
- {
- role: "user",
- content: expect.stringContaining("Call inspectImage now"),
- },
- ])
})
- it("reserves the finalization step even when unused page assets remain", () => {
+ it("replaces retrieval history with the assembled context for finalization", () => {
+ const answerContextMessage = {
+ role: "user" as const,
+ content: [{ type: "text" as const, text: "## User's Question\nQuestion" }],
+ }
const result = prepareHarnessStep({
- stepNumber: 13,
- hasUninspectedImageAssets: true,
- messages: [
- {
- role: "user",
- content: "What is the penalty amount?",
- },
- ],
+ stepNumber: 5,
+ messages: [{ role: "user", content: "retrieval history" }],
+ answerContextMessage,
})
+ expect(result.messages).toEqual([answerContextMessage])
expect(result.activeTools).toEqual(["finalize"])
- expect(result.toolChoice).toEqual({
- type: "tool",
- toolName: "finalize",
- })
+ expect(result.toolChoice).toEqual({ type: "tool", toolName: "finalize" })
})
- it("forces finalize at step 13 using existing tool results", () => {
- const result = prepareHarnessStep({
- stepNumber: 13,
- messages: [
- {
- role: "tool",
- content: [
- {
- type: "tool-result",
- toolCallId: "call_1",
- toolName: "knowhere_search",
- output: {
- type: "text",
- value:
- '',
- },
- providerOptions: {
- google: {
- thoughtSignature: "signature-1",
- },
- },
- },
- ],
- },
- ],
+ it("allows one knowhere_search and rejects a second call", async () => {
+ const search = vi
+ .fn()
+ .mockResolvedValue(makeRetrievalResponse())
+ const tools = createHarnessTools({
+ state: {},
+ ledger: createEvidenceLedger(),
+ memoryTools: makeMemoryTools(),
+ knowhereTools: makeKnowhereTools(search),
+ recentTurns: [],
})
- expect(result.activeTools).toEqual(["finalize"])
- expect(result.toolChoice).toEqual({
- type: "tool",
- toolName: "finalize",
- })
- expect(result.messages).toEqual([
- {
- role: "tool",
- content: [
- {
- type: "tool-result",
- toolCallId: "call_1",
- toolName: "knowhere_search",
- output: {
- type: "text",
- value:
- '',
- },
- },
- ],
- },
- {
- role: "user",
- content: expect.stringContaining(
- "Use only the evidence and tool results already available",
- ),
- },
- ])
+ const first = await executeTool(tools.knowhere_search, { query: "first" })
+ expect(first).toContain('status="ok"')
+ expect(search).toHaveBeenCalledWith(
+ expect.objectContaining({ query: "first" }),
+ )
+ expect(search.mock.calls[0]?.[0]).not.toHaveProperty("gapReason")
+
+ const rejected = await executeTool(tools.knowhere_search, { query: "second" })
+ expect(rejected).toContain('status="error"')
+ expect(String(rejected)).toContain("already ran for this turn")
+ expect(search).toHaveBeenCalledTimes(1)
})
+
})
function executeTool(tool: unknown, input: unknown): Promise {
@@ -1396,87 +992,85 @@ function makeRetrievalResponse(): RetrievalQueryResponse {
}
}
-function makeTableRetrievalResponse(): RetrievalQueryResponse {
+function makeConnectedRetrievalResponse(): RetrievalQueryResponse {
return {
namespace: "notebook",
- query: "q4 table",
- routerUsed: "workflow_single_step",
+ query: "comparison",
+ routerUsed: "agent_explore",
answerText: null,
- evidenceText: "Table evidence",
+ evidenceText: "Comparison evidence",
+ evidence: [
+ {
+ type: "text",
+ text: "Comparison \n\n ",
+ },
+ {
+ type: "image",
+ mediaType: "image/jpeg",
+ data: Buffer.from([9, 8, 7]).toString("base64"),
+ },
+ ],
stopReason: "answer_done",
failureReason: null,
results: [
{
- content: "",
- chunkType: "table",
- score: 0.8,
- assetUrl: "https://assets.example/tables/revenue.html",
+ chunkId: "text_chunk",
+ content: "Comparison [tables/comparison.html] [images/comparison.jpg]",
+ chunkType: "text",
+ score: 0.9,
+ metadata: {
+ connectTo: [
+ {
+ target: "table_chunk",
+ relation: "embeds",
+ ref: "[tables/comparison.html]",
+ },
+ {
+ target: "image_chunk",
+ relation: "embeds",
+ ref: "[images/comparison.jpg]",
+ },
+ ],
+ },
source: {
documentId: "doc_1",
- sourceFileName: "report.pdf",
- sectionPath: "tables/revenue.html",
+ sourceFileName: "cardiology.pdf",
+ sectionPath: "Differential diagnosis",
},
},
],
referencedChunks: [],
- }
+ } as unknown as RetrievalQueryResponse
}
-function makeImageRetrievalResponse(count: number): RetrievalQueryResponse {
+function toolCallResult(
+ calls: readonly {
+ toolCallId: string
+ toolName: string
+ input: unknown
+ }[],
+) {
return {
- namespace: "notebook",
- query: "q4 images",
- routerUsed: "workflow_single_step",
- answerText: null,
- evidenceText: "Image evidence",
- stopReason: "answer_done",
- failureReason: null,
- results: Array.from({ length: count }, (_, index) => ({
- content: "",
- chunkType: "image",
- score: 0.8,
- assetUrl: `https://assets.example/images/chart-${index + 1}.png`,
- source: {
- documentId: "doc_1",
- sourceFileName: "report.pdf",
- sectionPath: `images/chart-${index + 1}.png`,
- },
+ content: calls.map((call) => ({
+ type: "tool-call" as const,
+ toolCallId: call.toolCallId,
+ toolName: call.toolName,
+ input: JSON.stringify(call.input),
})),
- referencedChunks: [],
- }
-}
-
-function makePageCitationRetrievalResponse(): RetrievalQueryResponse {
- return {
- namespace: "notebook",
- query: "进度计划",
- routerUsed: "workflow_single_step",
- answerText: null,
- evidenceText: "Root / (6)现场工期进度管理方面的违约责任",
- stopReason: "answer_done",
- failureReason: null,
- results: [],
- referencedChunks: [
- {
- chunkId: "chunk_page_8",
- documentId: "doc_contract",
- chunkType: "page",
- sectionPath: "Root / (6)现场工期进度管理方面的违约责任",
- filePath: null,
- jobId: "job_contract",
- assetUrl: "https://assets.example/page-8.png",
- metadata: {
- pageNums: [8],
- pageAssets: [
- {
- pageNum: 8,
- artifactRef: "page_citation_assets/page-8.png",
- assetUrl: "https://assets.example/page-8.png",
- contentType: "image/png",
- },
- ],
- },
+ finishReason: { unified: "tool-calls" as const, raw: undefined },
+ usage: {
+ inputTokens: {
+ total: undefined,
+ noCache: undefined,
+ cacheRead: undefined,
+ cacheWrite: undefined,
},
- ],
+ outputTokens: {
+ total: undefined,
+ text: undefined,
+ reasoning: undefined,
+ },
+ },
+ warnings: [],
}
}
diff --git a/src/agent-harness/runtime.ts b/src/agent-harness/runtime.ts
index dbe91a58..2feb0466 100644
--- a/src/agent-harness/runtime.ts
+++ b/src/agent-harness/runtime.ts
@@ -7,39 +7,38 @@ import {
} from "ai"
import { z } from "zod"
+import { logger } from "@/lib/logger"
+
+import { composeAnswerContext } from "./answer-context"
import { createEvidenceLedger } from "./ledger"
-import { getCanonicalImageAssetKey } from "./image-asset-identity"
import { knowhereToolText } from "./knowhere-text"
import { memoryToolText } from "./memory-text"
-import { mergeImageInspectionHighlights } from "./image-highlights"
import type {
+ AgentFeedbackLesson,
AgentTurn,
AgentTurnInput,
ContextPolicy,
- EvidenceAsset,
- EvidenceChunk,
EvidenceLedgerSnapshot,
HarnessRunResult,
HarnessToolCallTrace,
HarnessTrace,
- ImageInspectionAsset,
- ImageInspectionHighlights,
- ImageInspectionResponse,
- InspectImages,
IntentFrame,
KnowhereSearchTargetContent,
KnowhereToolRuntime,
+ MemoryCitation,
MemorySearchKind,
+ MemorySearchItem,
MemoryToolRuntime,
OutputArtifactView,
OutputCitation,
OutputManifest,
+ ResolveConnectedAssets,
+ WorkspaceProfile,
} from "./types"
import { memorySearchKinds } from "./types"
-const defaultMaxSteps = 14
-const imageInspectionReminderStepNumber = 12
-const forcedFinalizationStepNumber = 13
+const defaultMaxSteps = 15
+const maxKnowhereSearchAttempts = 1
type ToolLoopAgentSettings = ConstructorParameters[0]
@@ -50,8 +49,10 @@ export type RunAgentHarnessInput = {
readonly turn: AgentTurnInput
readonly knowhereTools: KnowhereToolRuntime
readonly memoryTools: MemoryToolRuntime
- readonly inspectImages?: InspectImages
+ readonly resolveConnectedAssets?: ResolveConnectedAssets
readonly maxSteps?: number
+ readonly profile?: WorkspaceProfile | null
+ readonly agentFeedbackLessons?: readonly AgentFeedbackLesson[]
}
type HarnessToolState = {
@@ -59,9 +60,12 @@ type HarnessToolState = {
contextPolicy?: ContextPolicy
finalizedManifest?: OutputManifest
finalized?: boolean
+ answerContextRequested?: boolean
+ answerContextMessage?: ModelMessage
+ memoryItems?: MemorySearchItem[]
+ memorySearchAttempted?: boolean
+ knowhereSearchAttemptCount?: number
priorTurnReads?: string[]
- inspectedImageRefs?: string[]
- imageHighlights?: ImageInspectionHighlights[]
toolCalls?: HarnessToolCallTrace[]
}
@@ -91,7 +95,7 @@ const knowhereSearchTargetContentSchema = z.enum([
const knowhereSearchSchema = z.object({
query: z.string().min(1),
includeDocumentIds: z.array(z.string().trim().min(1)).optional().describe(
- "Only search these verified document IDs. Omit for unrestricted search; [] searches no documents. Use IDs from source context or previous search results, never filenames or guessed IDs.",
+ "Only search these verified document IDs. Omit for unrestricted search; [] searches no documents. Use IDs from previous search results, never filenames or guessed IDs.",
),
excludeDocumentIds: z.array(z.string().trim().min(1)).optional().describe(
"Exclude these verified document IDs. Exclusions take precedence over includeDocumentIds. If the ID is unknown, describe the document constraint in query instead.",
@@ -152,8 +156,6 @@ const citationPickSchema = z.object({
const memoryCitationSchema = z.object({
ref: z.string().min(1),
- itemId: z.string().min(1),
- kind: z.enum(memorySearchKinds),
})
const memorySearchSchema = z.object({
@@ -206,39 +208,55 @@ export async function runAgentHarness(
ledger,
knowhereTools: input.knowhereTools,
memoryTools: input.memoryTools,
- inspectImages: input.inspectImages,
recentTurns: input.turn.recentTurns,
})
const agent = new ToolLoopAgent({
model: input.model,
instructions: buildHarnessSystemPrompt(input.turn),
tools,
- prepareStep: ({ messages: stepMessages, stepNumber }) =>
- prepareHarnessStep({
+ prepareStep: async ({ messages: stepMessages, stepNumber }) => {
+ if (
+ state.answerContextRequested &&
+ !state.answerContextMessage
+ ) {
+ state.answerContextMessage = await composeAnswerContext({
+ ledger: ledger.snapshot(),
+ memoryItems: state.memoryItems ?? [],
+ memorySearchAttempted: state.memorySearchAttempted === true,
+ userText: input.turn.userText,
+ profile: input.profile,
+ agentFeedbackLessons: input.agentFeedbackLessons,
+ })
+ await ledger.resolveConnectedAssets(input.resolveConnectedAssets)
+ }
+ return prepareHarnessStep({
messages: stepMessages,
stepNumber,
intent: state.intent,
- hasUninspectedImageAssets:
- input.inspectImages !== undefined &&
- hasUninspectedImageAssets({ state, ledger }),
- hasKnowhereSearch: (state.toolCalls ?? []).some(
- (call) => call.tool === "knowhere_search",
- ),
- }),
+ hasKnowhereSearch: (state.knowhereSearchAttemptCount ?? 0) > 0,
+ hasReachedKnowhereSearchLimit:
+ (state.knowhereSearchAttemptCount ?? 0) >= maxKnowhereSearchAttempts,
+ hasMemorySearch: state.memorySearchAttempted === true,
+ answerContextMessage: state.answerContextMessage,
+ })
+ },
stopWhen: [
() => state.finalized === true,
stepCountIs(input.maxSteps ?? defaultMaxSteps),
],
})
- const response = await agent.generate({
+ await agent.generate({
messages: buildHarnessMessages(input.turn),
})
- const manifest =
- state.finalizedManifest ?? buildFallbackManifest(response.text.trim())
+ if (!state.finalizedManifest) {
+ throw new Error("The agent did not finalize an output manifest.")
+ }
+ const manifest = state.finalizedManifest
const ledgerSnapshot = ledger.snapshot()
return {
manifest,
+ memoryItems: state.memoryItems ?? [],
trace: {
intent: state.intent,
contextPolicy: state.contextPolicy,
@@ -246,7 +264,7 @@ export async function runAgentHarness(
finalized: state.finalized === true,
priorTurnReads: [...(state.priorTurnReads ?? [])],
toolCalls: [...(state.toolCalls ?? [])],
- imageHighlights: [...(state.imageHighlights ?? [])],
+ imageHighlights: [],
validationErrors: [],
revisionsUsed: 0,
},
@@ -256,7 +274,6 @@ export async function runAgentHarness(
const alwaysAvailableTools = [
"declareIntent",
"setContextPolicy",
- "inspectImage",
"readPriorTurn",
] as const
@@ -280,46 +297,32 @@ const cognitionRetrievalTools = [] as const
export function prepareHarnessStep(input: {
readonly stepNumber: number
readonly messages: readonly ModelMessage[]
- readonly hasUninspectedImageAssets?: boolean
readonly hasKnowhereSearch?: boolean
+ readonly hasReachedKnowhereSearchLimit?: boolean
+ readonly hasMemorySearch?: boolean
+ readonly answerContextMessage?: ModelMessage
readonly intent?: IntentFrame
}): HarnessStepPreparation {
const messages = sanitizeHarnessModelMessagesForStep(input.messages)
- const shouldForceImageInspection =
- input.hasUninspectedImageAssets === true &&
- input.stepNumber === imageInspectionReminderStepNumber
-
- if (shouldForceImageInspection) {
+ if (input.answerContextMessage) {
return {
- messages: [
- ...messages,
- {
- role: "user",
- content: buildImageInspectionReminderFeedback(),
- },
- ],
- activeTools: ["inspectImage"],
+ messages: [input.answerContextMessage],
+ activeTools: ["finalize"],
toolChoice: {
type: "tool",
- toolName: "inspectImage",
+ toolName: "finalize",
},
}
}
- if (input.stepNumber >= forcedFinalizationStepNumber) {
+ if (input.hasReachedKnowhereSearchLimit === true) {
return {
- messages: [
- ...messages,
- {
- role: "user",
- content: buildForcedFinalizationFeedback(),
- },
- ],
- activeTools: ["finalize"],
+ messages,
+ activeTools: ["prepareAnswer"],
toolChoice: {
type: "tool",
- toolName: "finalize",
+ toolName: "prepareAnswer",
},
}
}
@@ -329,10 +332,10 @@ export function prepareHarnessStep(input: {
activeTools: selectHarnessActiveTools({
intent: input.intent,
hasKnowhereSearch: input.hasKnowhereSearch === true,
+ hasMemorySearch: input.hasMemorySearch === true,
}),
- // finalize is the only output contract (see its tool description). Force
- // a tool call every step so the model cannot end the turn with a bare
- // text response that skips finalize's citation/artifact validation.
+ // Tool calls are required so the retrieval phase cannot end with bare
+ // text and skip the composed answer context or finalize validation.
toolChoice: "required",
}
}
@@ -340,22 +343,25 @@ export function prepareHarnessStep(input: {
function selectHarnessActiveTools(input: {
readonly intent?: IntentFrame
readonly hasKnowhereSearch: boolean
+ readonly hasMemorySearch: boolean
}): Array> {
const tools: Array> = [
...alwaysAvailableTools,
]
- if (allowsFinalize(input)) {
- tools.push("finalize")
+ if (allowsAnswerPreparation(input)) {
+ tools.push("prepareAnswer")
}
if (!allowsRetrieval(input.intent)) {
return tools
}
// memory_search and knowhere_search are peers: both open together once
- // retrieval is allowed. The agent decides which to call and in what
- // order — neither tool gates the other.
- tools.push(...fluidRetrievalTools)
- if (input.intent?.groundingPolicy === "must_use_sources") {
+ // retrieval is allowed. Each may run once per turn.
+ if (!input.hasMemorySearch) tools.push(...fluidRetrievalTools)
+ if (
+ input.intent?.groundingPolicy === "must_use_sources" &&
+ !input.hasKnowhereSearch
+ ) {
tools.push(...crystalRetrievalTools)
}
tools.push(...cognitionRetrievalTools)
@@ -369,7 +375,7 @@ function allowsRetrieval(intent?: IntentFrame): boolean {
)
}
-function allowsFinalize(input: {
+function allowsAnswerPreparation(input: {
readonly intent?: IntentFrame
readonly hasKnowhereSearch: boolean
}): boolean {
@@ -440,57 +446,11 @@ type ModelMessageForRole = Extract<
{ readonly role: TRole }
>
-function buildForcedFinalizationFeedback(): string {
- return [
- "The retrieval step budget has been reached.",
- "Do not search again.",
- "Use only the evidence and tool results already available in this turn.",
- "Call finalize now with the best supported answer.",
- "If the existing evidence is insufficient, explain the gap in unresolved",
- "instead of making unsupported claims.",
- ].join("\n")
-}
-
-function buildImageInspectionReminderFeedback(): string {
- return [
- "Retrieved image/page assets are available and have not been inspected.",
- "Call inspectImage now with the page/image asset refs you will cite.",
- "Use a question that locates the cited evidence on those pages for OCR/visual context and provenance boxes.",
- "Do not finalize until those cited image assets have been inspected.",
- "Do not search again.",
- ].join("\n")
-}
-
-function hasUninspectedImageAssets(input: {
- readonly state: HarnessToolState
- readonly ledger: ReturnType
-}): boolean {
- const snapshot = input.ledger.snapshot()
- const chunksByRef = new Map(
- snapshot.chunks.map((chunk) => [chunk.ref, chunk] as const),
- )
- const assetsByRef = new Map(
- snapshot.assets.map((asset) => [asset.ref, asset] as const),
- )
- const inspectedKeys = new Set(
- (input.state.inspectedImageRefs ?? []).map((ref) => {
- const asset = assetsByRef.get(ref)
- return asset ? getCanonicalImageAssetKey(asset, chunksByRef) : ref
- }),
- )
- return snapshot.assets.some(
- (asset) =>
- asset.type === "image" &&
- !inspectedKeys.has(getCanonicalImageAssetKey(asset, chunksByRef)),
- )
-}
-
export function createHarnessTools(input: {
readonly state: HarnessToolState
readonly ledger: ReturnType
readonly knowhereTools: KnowhereToolRuntime
readonly memoryTools: MemoryToolRuntime
- readonly inspectImages?: InspectImages
readonly recentTurns: readonly AgentTurn[]
}) {
return {
@@ -528,7 +488,7 @@ export function createHarnessTools(input: {
memory_search: tool({
description:
- "Search distilled fluid memory for this workspace. Returns tagged text with memory refs such as mem:1. Use this before Knowhere document search.",
+ "Search distilled fluid memory for this workspace. Returns tagged text with memory refs such as mem:1. It can run alongside Knowhere document search when both are useful.",
inputSchema: memorySearchSchema,
execute: async (request) =>
traceToolCall(input.state, {
@@ -536,6 +496,7 @@ export function createHarnessTools(input: {
inputSummary: summarizeMemorySearchRequest(request),
execute: async () => {
return await executeMemorySearch({
+ state: input.state,
memoryTools: input.memoryTools,
request,
})
@@ -546,7 +507,7 @@ export function createHarnessTools(input: {
knowhere_search: tool({
description:
- "Search Knowhere for relevant Notebook evidence. Returns tagged text with pick numbers for finalize citations, evidence refs such as r1:result:1, and asset refs such as asset:r1:result:1.",
+ "Search Knowhere for relevant Notebook evidence. Returns tagged text with pick numbers for finalize citations, evidence refs such as r1:result:1, and connected image/table asset paths when present. Call once per turn; do not change the query and search again.",
inputSchema: knowhereSearchSchema,
execute: async (request) =>
traceToolCall(input.state, {
@@ -554,6 +515,7 @@ export function createHarnessTools(input: {
inputSummary: summarizeKnowhereSearchRequest(request),
execute: async () =>
executeKnowhereSearch({
+ state: input.state,
ledger: input.ledger,
knowhereTools: input.knowhereTools,
request,
@@ -562,29 +524,6 @@ export function createHarnessTools(input: {
}),
}),
- inspectImage: tool({
- description:
- "Inspect cited Knowhere page/image asset refs for OCR, visual details, and provenance boxes. Call this after retrieval and before finalize whenever the answer cites page or image assets.",
- inputSchema: z.object({
- refs: z.array(z.string().min(1)).min(1),
- question: z.string().min(1),
- }),
- execute: async (request) =>
- traceToolCall(input.state, {
- toolName: "inspectImage",
- inputSummary: summarizeInspectImageRequest(request),
- execute: async () =>
- inspectRetrievedImages({
- state: input.state,
- ledger: input.ledger,
- inspectImages: input.inspectImages,
- refs: request.refs,
- question: request.question,
- }),
- summarizeOutput: summarizeInspectImageOutput,
- }),
- }),
-
readPriorTurn: tool({
description:
"Read the full text and citation labels of a specific prior turn by id " +
@@ -644,6 +583,22 @@ export function createHarnessTools(input: {
}),
}),
+ prepareAnswer: tool({
+ description:
+ "Finish retrieval and assemble Knowledge Base search results, all fluid memory results, and the user's original question into one multimodal message for the answer step.",
+ inputSchema: z.object({}),
+ execute: async () =>
+ traceToolCall(input.state, {
+ toolName: "prepareAnswer",
+ inputSummary: {},
+ execute: async () => {
+ input.state.answerContextRequested = true
+ return { ok: true as const }
+ },
+ summarizeOutput: (output) => output,
+ }),
+ }),
+
finalize: tool({
description:
"Finalize the user-facing output manifest. This is the only final answer " +
@@ -651,8 +606,8 @@ export function createHarnessTools(input: {
"images/tables shown to the user. citations is the list of evidence picks " +
"you used; each pick is the pick number on a Knowhere search chunk. " +
"Notebook writes citation refs from the evidence ledger. " +
- "Use memoryCitations for fluid memory refs. " +
- "Cited page/image assets must be inspected with inspectImage first.",
+ "Use memoryCitations for fluid memory and copy only the mem:N ref " +
+ "from the assembled Fluid Memory entries.",
inputSchema: finalizeManifestSchema,
execute: async (manifest) =>
traceToolCall(input.state, {
@@ -674,28 +629,27 @@ export function createHarnessTools(input: {
}
}
+ const resolvedMemoryCitations = resolveMemoryCitations({
+ citations: manifest.memoryCitations,
+ memoryItems: input.state.memoryItems ?? [],
+ })
+ if (!resolvedMemoryCitations.ok) {
+ return {
+ ok: false as const,
+ message:
+ "memoryCitations must use mem:N refs from this turn's Fluid Memory results.",
+ invalidMemoryCitations: resolvedMemoryCitations.invalid,
+ }
+ }
+
const outputManifest: OutputManifest = {
text: manifest.text,
citations: resolvedCitations.citations,
- memoryCitations: manifest.memoryCitations,
+ memoryCitations: resolvedMemoryCitations.citations,
artifacts: manifest.artifacts,
unresolved: manifest.unresolved,
}
- const inspectRefs = getUninspectedCitedImageRefs({
- manifest: outputManifest,
- ledger: input.ledger,
- inspectedImageRefs: input.state.inspectedImageRefs ?? [],
- inspectImagesAvailable: input.inspectImages !== undefined,
- })
- if (inspectRefs.length > 0) {
- return {
- ok: false as const,
- message: buildFinalizeRequiresInspectionMessage(inspectRefs),
- inspectRefs,
- }
- }
-
input.state.finalizedManifest = outputManifest
input.state.finalized = true
return { ok: true as const, ...outputManifest }
@@ -706,167 +660,6 @@ export function createHarnessTools(input: {
} as const
}
-async function inspectRetrievedImages(input: {
- readonly state: HarnessToolState
- readonly ledger: ReturnType
- readonly inspectImages?: InspectImages
- readonly refs: readonly string[]
- readonly question: string
-}): Promise<
- | ({ readonly ok: true } & ImageInspectionResponse)
- | {
- readonly ok: false
- readonly message: string
- readonly inspected: readonly []
- readonly skipped: readonly {
- readonly ref: string
- readonly reason: string
- }[]
- }
-> {
- const refs = getUniqueTrimmedRefs(input.refs)
- const question = input.question.trim()
-
- if (refs.length === 0 || question.length === 0) {
- return {
- ok: false,
- message: "At least one image asset ref and a question are required.",
- inspected: [],
- skipped: [],
- }
- }
- const snapshot = input.ledger.snapshot()
- if (snapshot.chunks.length === 0 && snapshot.assets.length === 0) {
- return {
- ok: false,
- message:
- "Knowhere evidence tools must return image assets before inspectImage.",
- inspected: [],
- skipped: refs.map((ref) => ({
- ref,
- reason: "No Knowhere evidence is available yet.",
- })),
- }
- }
- if (!input.inspectImages) {
- return {
- ok: false,
- message: "Image inspection is not available for this turn.",
- inspected: [],
- skipped: refs.map((ref) => ({
- ref,
- reason: "No image inspection capability is configured.",
- })),
- }
- }
-
- const assetsByRef = new Map(
- snapshot.assets.map((asset) => [asset.ref, asset] as const),
- )
- const chunksByRef = new Map(
- snapshot.chunks.map((chunk) => [chunk.ref, chunk] as const),
- )
- const skipped: {
- readonly ref: string
- readonly reason: string
- }[] = []
- const selectedAssets: ImageInspectionAsset[] = []
- const selectedKeys = new Set()
-
- for (const ref of refs) {
- const asset = assetsByRef.get(ref)
- if (!asset) {
- skipped.push({
- ref,
- reason: "Ref was not returned by Knowhere as an asset.",
- })
- continue
- }
- if (asset.type !== "image") {
- skipped.push({
- ref,
- reason: "Ref is not an image asset.",
- })
- continue
- }
-
- const assetKey = getCanonicalImageAssetKey(asset, chunksByRef)
- if (selectedKeys.has(assetKey)) {
- skipped.push({
- ref,
- reason: "Duplicate of another retrieved page selected for inspection.",
- })
- continue
- }
- selectedKeys.add(assetKey)
- selectedAssets.push({
- ref: asset.ref,
- label: asset.label,
- ...(asset.assetUrl ? { assetUrl: asset.assetUrl } : {}),
- ...(asset.sourcePath ? { sourcePath: asset.sourcePath } : {}),
- ...(asset.revisionKey ? { revisionKey: asset.revisionKey } : {}),
- source: asset.source,
- })
- }
-
- if (selectedAssets.length === 0) {
- return {
- ok: false,
- message: "No inspectable image asset refs were provided.",
- inspected: [],
- skipped,
- }
- }
-
- const inspectedImageRefs = input.state.inspectedImageRefs ?? []
-
- try {
- const response = await input.inspectImages({
- question,
- assets: selectedAssets,
- })
- const selectedRefs = new Set(selectedAssets.map((asset) => asset.ref))
- const successfulRefs = response.inspected
- .map((asset) => asset.ref)
- .filter((ref) => selectedRefs.has(ref))
- input.state.inspectedImageRefs = [
- ...inspectedImageRefs,
- ...successfulRefs.filter((ref) => !inspectedImageRefs.includes(ref)),
- ]
- input.state.imageHighlights = mergeImageInspectionHighlights(
- input.state.imageHighlights,
- response.highlights,
- )
- if (successfulRefs.length === 0) {
- return {
- ok: false as const,
- message: "Image inspection skipped every requested asset.",
- inspected: [],
- skipped: [...skipped, ...response.skipped],
- }
- }
- return {
- ok: true as const,
- analysis: response.analysis,
- inspected: response.inspected,
- skipped: [...skipped, ...response.skipped],
- }
- } catch (error) {
- return {
- ok: false,
- message:
- error instanceof Error
- ? `Image inspection failed: ${error.message}`
- : "Image inspection failed.",
- inspected: [],
- skipped: selectedAssets.map((asset) => ({
- ref: asset.ref,
- reason: "The image inspection request failed.",
- })),
- }
- }
-}
-
function resolveCitationPicks(input: {
readonly citations: readonly { pick: number }[]
readonly ledger: ReturnType
@@ -896,6 +689,31 @@ function resolveCitationPicks(input: {
return { ok: true, citations }
}
+function resolveMemoryCitations(input: {
+ readonly citations: readonly { ref: string }[]
+ readonly memoryItems: readonly MemorySearchItem[]
+}):
+ | { ok: true; citations: MemoryCitation[] }
+ | { ok: false; invalid: readonly { ref: string }[] } {
+ const byRef = new Map(input.memoryItems.map((item) => [item.ref, item]))
+ const citations: MemoryCitation[] = []
+ const invalid: { ref: string }[] = []
+ for (const citation of input.citations) {
+ const item = byRef.get(citation.ref)
+ if (!item) {
+ invalid.push({ ref: citation.ref })
+ continue
+ }
+ citations.push({
+ ref: item.ref,
+ itemId: item.itemId,
+ kind: item.kind,
+ })
+ }
+ if (invalid.length > 0) return { ok: false, invalid }
+ return { ok: true, citations }
+}
+
function buildFinalizeRequiresPicksMessage(input: {
readonly unknownPicks: readonly number[]
readonly ledger: EvidenceLedgerSnapshot
@@ -911,90 +729,6 @@ function buildFinalizeRequiresPicksMessage(input: {
].join(" ")
}
-function getUninspectedCitedImageRefs(input: {
- readonly manifest: OutputManifest
- readonly ledger: ReturnType
- readonly inspectedImageRefs: readonly string[]
- readonly inspectImagesAvailable: boolean
-}): string[] {
- if (!input.inspectImagesAvailable) return []
-
- const snapshot = input.ledger.snapshot()
- const chunksByRef = new Map(
- snapshot.chunks.map((chunk) => [chunk.ref, chunk] as const),
- )
- const assetsByRef = new Map(
- snapshot.assets.map((asset) => [asset.ref, asset] as const),
- )
- const inspected = new Set(input.inspectedImageRefs)
- const inspectedKeys = new Set(
- input.inspectedImageRefs.map((ref) => {
- const asset = assetsByRef.get(ref)
- return asset ? getCanonicalImageAssetKey(asset, chunksByRef) : ref
- }),
- )
-
- const refs: string[] = []
- const seenKeys = new Set()
- const addRef = (ref: string | null): void => {
- if (!ref || inspected.has(ref)) return
- const asset = assetsByRef.get(ref)
- const key = asset ? getCanonicalImageAssetKey(asset, chunksByRef) : ref
- if (seenKeys.has(key) || inspectedKeys.has(key)) return
- seenKeys.add(key)
- refs.push(ref)
- }
-
- for (const citation of input.manifest.citations) {
- addRef(resolveImageAssetRef(citation.ref, chunksByRef, assetsByRef))
- }
-
- for (const artifact of input.manifest.artifacts) {
- if (artifact.type !== "image" || artifact.display === false) continue
- addRef(resolveImageAssetRef(artifact.ref, chunksByRef, assetsByRef))
- }
-
- return refs
-}
-
-function resolveImageAssetRef(
- ref: string,
- chunksByRef: ReadonlyMap,
- assetsByRef: ReadonlyMap,
-): string | null {
- const directAsset = assetsByRef.get(ref)
- if (directAsset?.type === "image") return directAsset.ref
-
- const chunk = chunksByRef.get(ref)
- if (!chunk) return null
-
- if (chunk.assetRef) {
- const chunkAsset = assetsByRef.get(chunk.assetRef)
- if (chunkAsset?.type === "image") return chunkAsset.ref
- }
-
- if (!chunk.chunkId) return null
- const sibling = Array.from(chunksByRef.values()).find(
- (candidate) =>
- candidate.ref !== chunk.ref &&
- candidate.chunkId === chunk.chunkId &&
- candidate.source.documentId === chunk.source.documentId &&
- candidate.assetRef !== undefined &&
- assetsByRef.get(candidate.assetRef)?.type === "image",
- )
- return sibling?.assetRef ?? null
-}
-
-function buildFinalizeRequiresInspectionMessage(
- inspectRefs: readonly string[],
-): string {
- return [
- "Cited page/image assets must be inspected before finalize.",
- `Call inspectImage with refs: ${inspectRefs.join(" ")}.`,
- "Use a question that locates the cited evidence on those pages.",
- "Then call finalize again, using the inspection notes in the answer.",
- ].join(" ")
-}
type KnowhereToolOperation = "search"
@@ -1002,24 +736,54 @@ type MemorySearchToolRequest = z.infer
type KnowhereSearchToolRequest = z.infer
async function executeMemorySearch(input: {
+ readonly state: HarnessToolState
readonly memoryTools: MemoryToolRuntime
readonly request: MemorySearchToolRequest
}): Promise {
+ if (input.state.memorySearchAttempted) {
+ return memoryToolText.formatError({
+ operation: "search",
+ message: "Fluid memory search already ran for this turn.",
+ })
+ }
+ input.state.memorySearchAttempted = true
+
try {
const response = await input.memoryTools.search({
query: input.request.query,
kinds: input.request.kinds,
})
+ accumulateMemoryItems(input.state, response.items)
return memoryToolText.formatSearch(response)
} catch (error) {
- return memoryToolText.formatError({
+ // TODO: Memento 未部署时搜索会失败,先只记警告;部署并对上地址后应能搜到。
+ logger.warn("chat: failed to search memory", {
+ query: input.request.query,
+ error: formatUnknownError(error),
+ })
+ return memoryToolText.formatWarning({
operation: "search",
message: formatUnknownError(error),
})
}
}
+function accumulateMemoryItems(
+ state: HarnessToolState,
+ items: readonly MemorySearchItem[],
+): void {
+ const accumulated = state.memoryItems ?? []
+ const itemIds = new Set(accumulated.map((item) => item.itemId))
+ for (const item of items) {
+ if (itemIds.has(item.itemId)) continue
+ accumulated.push(item)
+ itemIds.add(item.itemId)
+ }
+ state.memoryItems = accumulated
+}
+
async function executeKnowhereSearch(input: {
+ readonly state: HarnessToolState
readonly ledger: ReturnType
readonly knowhereTools: KnowhereToolRuntime
readonly request: KnowhereSearchToolRequest
@@ -1027,6 +791,15 @@ async function executeKnowhereSearch(input: {
return executeKnowhereTextTool({
operation: "search",
execute: async () => {
+ const attemptCount = input.state.knowhereSearchAttemptCount ?? 0
+ if (attemptCount >= maxKnowhereSearchAttempts) {
+ return knowhereToolText.formatError({
+ operation: "search",
+ message:
+ "Knowhere search already ran for this turn. Call prepareAnswer now.",
+ })
+ }
+ input.state.knowhereSearchAttemptCount = attemptCount + 1
const beforeSnapshot = input.ledger.snapshot()
const response = await input.knowhereTools.search({
query: input.request.query,
@@ -1069,16 +842,6 @@ async function executeKnowhereTextTool(input: {
}
}
-function getUniqueTrimmedRefs(refs: readonly string[]): string[] {
- const normalizedRefs: string[] = []
- for (const ref of refs) {
- const normalizedRef = ref.trim()
- if (!normalizedRef || normalizedRefs.includes(normalizedRef)) continue
- normalizedRefs.push(normalizedRef)
- }
- return normalizedRefs
-}
-
async function traceToolCall(input: {
readonly toolCalls?: HarnessToolCallTrace[]
}, call: {
@@ -1211,30 +974,6 @@ function countOccurrences(value: string, pattern: string): number {
}
}
-function summarizeInspectImageRequest(request: {
- readonly refs: readonly string[]
- readonly question: string
-}): unknown {
- return {
- refs: getUniqueTrimmedRefs(request.refs),
- questionLength: request.question.trim().length,
- }
-}
-
-function summarizeInspectImageOutput(output: unknown): unknown {
- if (!isRecord(output)) return output
- return {
- ok: output.ok,
- analysisLength:
- typeof output.analysis === "string" ? output.analysis.length : 0,
- inspectedCount: Array.isArray(output.inspected)
- ? output.inspected.length
- : 0,
- skippedCount: Array.isArray(output.skipped) ? output.skipped.length : 0,
- message: output.message,
- }
-}
-
function summarizeReadPriorTurnOutput(output: unknown): unknown {
if (!isRecord(output)) return output
return {
@@ -1305,17 +1044,17 @@ export function buildHarnessSystemPrompt(turn: AgentTurnInput): string {
"1. Call declareIntent when it helps you plan the response. Capture constraints like a requested image/table count in constraints.desiredCount.",
"2. Call setContextPolicy when prior turns may influence this turn.",
"3. When the policy needs prior-turn detail (references or corrections), call readPriorTurn for the relevant ids.",
- "4. Call memory_search first when known fluid memory may answer the request. Call knowhere_search when memory is insufficient and groundingPolicy requires citing source documents. If the returned evidence is not enough to answer, or the query needs to focus differently, call knowhere_search again with a refined query (different keywords / topK / targetContent) instead of trying to browse documents directly. Knowhere's own retrieval agent already navigates the corpus internally.",
- "5. After Knowhere returns image/page asset refs, call inspectImage on the page/image assets you will cite before finalize. This supplies OCR/visual context and provenance boxes.",
- "6. Inspect each unique cited page once; retrieval already bounds the available evidence set.",
- "7. Call finalize with text, citations, artifacts, and unresolved issues when you are ready to answer.",
+ "4. Call memory_search for relevant fluid memory and knowhere_search when groundingPolicy requires source documents. When both are useful, call them together in the same step. Call knowhere_search once; do not change the query and search again. Knowhere's own retrieval agent already navigates the corpus internally.",
+ "5. After a search, call prepareAnswer. All Knowhere search results, all fluid memory results, and the user's original question will be assembled into one multimodal message.",
+ "6. Read that assembled message once and call finalize with the answer, citations, artifacts, and unresolved issues.",
"",
"Retrieval rules:",
- "- First use memory_search to see whether known fluid memory can answer directly.",
- "- Call knowhere_search only when memory is insufficient and groundingPolicy requires citing source documents.",
- "- Refine knowhere_search at most twice. If two refined searches still do not add new relevant evidence, call finalize and list the gap in unresolved.",
+ "- memory_search and knowhere_search are parallel retrieval sources. When both apply, call them together rather than making one wait for the other.",
+ "- Call memory_search once per turn. An empty result remains empty; do not retry it.",
+ "- Call knowhere_search once per turn when groundingPolicy requires citing source documents. An empty result remains empty; do not change the query and search again.",
+ "- Image/table asset paths in retrieved chunks are debug references. Composed evidence is already assembled for the answer step. Do not search again because those assets have not been shown yet.",
"- Do not treat every question as a document-retrieval task.",
- "- For document-scoped searches, use includeDocumentIds/excludeDocumentIds only with verified IDs from source context or prior search results. If IDs are unknown, preserve the document requirement in query so Knowhere can locate it. Never invent IDs or substitute filenames. Exclusions win; an empty includeDocumentIds means no documents.",
+ "- For document-scoped searches, use includeDocumentIds/excludeDocumentIds only with verified IDs from prior search results. If IDs are unknown, preserve the document requirement in query so Knowhere can locate it. Never invent IDs or substitute filenames. Exclusions win; an empty includeDocumentIds means no documents.",
"",
"Context rules:",
"- If the current user request is unrelated to prior turns, set carryHistory to none and do not reuse prior topics.",
@@ -1332,13 +1071,10 @@ export function buildHarnessSystemPrompt(turn: AgentTurnInput): string {
"- Do not write title/pN, [1], Markdown footnotes, or [Source N: ...] in the answer text. Notebook renders chips from [[cite:n]] and citation metadata.",
"- Repeat [[cite:n]] when another claim uses the same page. Do not collapse same-page citations to one row.",
"- If you have no supporting evidence pick, omit citations and list the gap in unresolved.",
- "- inspectImage observations are inspection notes, not new source refs. Final citations and displayed image artifacts must use the original retrieved image asset refs.",
- "- Do not finalize cited page/image assets from chunk text alone when inspectImage is available. Inspect those asset refs first, then write the answer using the inspection notes.",
- "- If text evidence identifies a relevant page/image but does not include the exact fact, inspect the returned image asset for OCR/detail before saying the answer is unavailable.",
+ "- Images in search evidence are embedded directly in the assembled user message. Read them there; do not call a separate image-inspection step.",
"- If evidence is insufficient, list it in unresolved instead of fabricating facts.",
`Surface: ${turn.surface}`,
`Output capabilities: ${JSON.stringify(turn.outputCapabilities)}`,
- turn.sourceContext ? `Searchable source context:\n${turn.sourceContext}` : "",
]
.filter((line): line is string => line.length > 0)
.join("\n")
@@ -1370,15 +1106,4 @@ function formatRecentTurnIndex(turn: AgentTurnInput): string {
})
return ["Recent turn index:", ...lines].join("\n")
}
-
-function buildFallbackManifest(text: string): OutputManifest {
- return {
- text,
- citations: [],
- memoryCitations: [],
- artifacts: [],
- unresolved: text ? [] : ["The agent did not finalize an output manifest."],
- }
-}
-
export type { HarnessTrace }
diff --git a/src/agent-harness/types.ts b/src/agent-harness/types.ts
index b5a94168..4566c2e0 100644
--- a/src/agent-harness/types.ts
+++ b/src/agent-harness/types.ts
@@ -68,7 +68,6 @@ export type AgentTurnInput = {
readonly userText: string
readonly recentTurns: readonly AgentTurn[]
readonly localContext?: string
- readonly sourceContext?: string
readonly outputCapabilities: {
readonly text: boolean
readonly image: boolean
@@ -102,11 +101,27 @@ export type KnowhereToolRuntime = {
) => Promise
}
+export type ConnectedAssetLookup = {
+ readonly documentId: string
+ readonly chunkId: string
+ readonly type: "image" | "table"
+}
+
+export type ResolvedConnectedAsset = ConnectedAssetLookup & {
+ readonly assetUrl: string
+}
+
+export type ResolveConnectedAssets = (
+ lookups: readonly ConnectedAssetLookup[],
+) => Promise
+
export const memorySearchKinds = [
"indicator_pref",
"stance",
"decision_rule",
"entity_of_interest",
+ "event",
+ "profile",
] as const
export type MemorySearchKind = (typeof memorySearchKinds)[number]
@@ -120,8 +135,7 @@ export type MemorySearchItem = {
readonly ref: string
readonly itemId: string
readonly kind: MemorySearchKind
- readonly abstractL0: string
- readonly overviewL1: string
+ readonly text: string
}
export type MemorySearchResponse = {
@@ -133,12 +147,37 @@ export type MemoryToolRuntime = {
readonly search: (input: MemorySearchRequest) => Promise
}
+export type WorkspaceProfile = {
+ readonly name?: string
+ readonly occupation?: string
+ readonly ageStage?: string
+ readonly communicationHabit?: string
+ readonly workHabit?: string
+}
+
+export type AgentFeedbackLesson = {
+ readonly itemId: string
+ readonly text: string
+ readonly reflection: string
+}
+
export type MemoryCitation = {
readonly ref: string
readonly itemId: string
readonly kind: MemorySearchKind
}
+export type EvidencePart =
+ | {
+ readonly type: "text"
+ readonly text: string
+ }
+ | {
+ readonly type: "image"
+ readonly mediaType: string
+ readonly data: string
+ }
+
export type EvidenceChunk = {
readonly ref: string
readonly kind: "result" | "referenced_chunk"
@@ -156,7 +195,6 @@ export type EvidenceChunk = {
readonly sectionPath?: string | null
}
readonly revisionKey?: string | null
- readonly assetRef?: string
readonly assetUrl?: string
}
@@ -227,6 +265,7 @@ export type EvidenceLedgerSnapshot = {
readonly retrievalCount: number
readonly chunks: readonly EvidenceChunk[]
readonly assets: readonly EvidenceAsset[]
+ readonly evidence: readonly EvidencePart[]
readonly evidenceText: readonly string[]
readonly stopReasons: readonly string[]
readonly failureReasons: readonly string[]
@@ -291,4 +330,5 @@ export type HarnessTrace = {
export type HarnessRunResult = {
readonly manifest: OutputManifest
readonly trace: HarnessTrace
+ readonly memoryItems: readonly MemorySearchItem[]
}
diff --git a/src/app/api/demo-sources/materialize/route.test.ts b/src/app/api/demo-sources/materialize/route.test.ts
index 3a3be24d..618dc2c3 100644
--- a/src/app/api/demo-sources/materialize/route.test.ts
+++ b/src/app/api/demo-sources/materialize/route.test.ts
@@ -242,6 +242,7 @@ function makeSource(
originalBlobUrl: "https://example.com/tsla-q4-2025.pdf",
demoKey: "demo-tsla-q4-2025",
chunkCount: null,
+ folderId: null,
createdAt: new Date("2026-05-10T00:00:00.000Z"),
updatedAt: new Date("2026-05-10T00:00:00.000Z"),
deletedAt: null,
diff --git a/src/app/api/folders/[folderId]/route.ts b/src/app/api/folders/[folderId]/route.ts
new file mode 100644
index 00000000..dc680e81
--- /dev/null
+++ b/src/app/api/folders/[folderId]/route.ts
@@ -0,0 +1,45 @@
+import type { NextRequest, NextResponse } from "next/server"
+
+import { folderRouteRequest } from "@/domains/folders/route-request"
+import { folderRouteService } from "@/domains/folders/route-service"
+import { withApiErrorResponse } from "@/lib/api-error-response"
+import { nextRouteResponse } from "@/lib/next-route-response"
+
+type RouteContext = {
+ params: Promise<{
+ folderId: string
+ }>
+}
+
+export async function PATCH(
+ request: NextRequest,
+ context: RouteContext,
+): Promise {
+ return withApiErrorResponse("folders:update", async () => {
+ const { folderId } = await context.params
+ const updateRequest = await folderRouteRequest.readUpdateFolder({ request })
+ if (!updateRequest.ok) {
+ return nextRouteResponse.toNextResponse(updateRequest.result)
+ }
+
+ return nextRouteResponse.toNextResponse(
+ await folderRouteService.updateFolder({
+ folderId,
+ name: updateRequest.name,
+ parentId: updateRequest.parentId,
+ }),
+ )
+ })
+}
+
+export async function DELETE(
+ _request: NextRequest,
+ context: RouteContext,
+): Promise {
+ return withApiErrorResponse("folders:delete", async () => {
+ const { folderId } = await context.params
+ return nextRouteResponse.toNextResponse(
+ await folderRouteService.deleteFolder({ folderId }),
+ )
+ })
+}
diff --git a/src/app/api/folders/route.ts b/src/app/api/folders/route.ts
new file mode 100644
index 00000000..cd9e6add
--- /dev/null
+++ b/src/app/api/folders/route.ts
@@ -0,0 +1,28 @@
+import type { NextRequest, NextResponse } from "next/server"
+
+import { folderRouteRequest } from "@/domains/folders/route-request"
+import { folderRouteService } from "@/domains/folders/route-service"
+import { withApiErrorResponse } from "@/lib/api-error-response"
+import { nextRouteResponse } from "@/lib/next-route-response"
+
+export async function GET(): Promise {
+ return withApiErrorResponse("folders:list", async () =>
+ nextRouteResponse.toNextResponse(await folderRouteService.listFolders()),
+ )
+}
+
+export async function POST(request: NextRequest): Promise {
+ return withApiErrorResponse("folders:create", async () => {
+ const createRequest = await folderRouteRequest.readCreateFolder({ request })
+ if (!createRequest.ok) {
+ return nextRouteResponse.toNextResponse(createRequest.result)
+ }
+
+ return nextRouteResponse.toNextResponse(
+ await folderRouteService.createFolder({
+ name: createRequest.name,
+ parentId: createRequest.parentId,
+ }),
+ )
+ })
+}
diff --git a/src/app/api/sources/[sourceId]/chunks/route.test.ts b/src/app/api/sources/[sourceId]/chunks/route.test.ts
index e38d9a8f..3ff41881 100644
--- a/src/app/api/sources/[sourceId]/chunks/route.test.ts
+++ b/src/app/api/sources/[sourceId]/chunks/route.test.ts
@@ -312,6 +312,7 @@ describe("GET /api/sources/[sourceId]/chunks", () => {
originalBlobUrl: "/api/demo-sources/demo-tsla-q4-2025/original",
demoKey: "demo-tsla-q4-2025",
chunkCount: null,
+ folderId: null,
createdAt: new Date("2026-05-10T00:00:00.000Z"),
updatedAt: new Date("2026-05-10T00:00:00.000Z"),
deletedAt: null,
@@ -847,6 +848,7 @@ function makeReadySource(overrides: Record) {
originalBlobUrl: null,
demoKey: null,
chunkCount: null,
+ folderId: null,
createdAt: new Date("2026-05-10T00:00:00.000Z"),
updatedAt: new Date("2026-05-10T00:00:00.000Z"),
deletedAt: null,
diff --git a/src/app/api/sources/[sourceId]/route.test.ts b/src/app/api/sources/[sourceId]/route.test.ts
index b9cbcd60..034d6777 100644
--- a/src/app/api/sources/[sourceId]/route.test.ts
+++ b/src/app/api/sources/[sourceId]/route.test.ts
@@ -344,6 +344,7 @@ describe("PATCH /api/sources/[sourceId]", () => {
"https://store.public.blob.vercel-storage.com/source-uploads/upload_1/document.pdf",
demoKey: null,
chunkCount: null,
+ folderId: null,
createdAt: new Date("2026-05-10T00:00:00Z"),
updatedAt: new Date("2026-05-10T00:00:00Z"),
deletedAt: null,
@@ -377,6 +378,7 @@ describe("PATCH /api/sources/[sourceId]", () => {
"https://store.public.blob.vercel-storage.com/source-uploads/upload_1/document.pdf",
demoKey: null,
chunkCount: null,
+ folderId: null,
createdAt: new Date("2026-05-10T00:00:00Z"),
updatedAt: new Date("2026-05-10T00:00:00Z"),
deletedAt: null,
diff --git a/src/app/api/sources/[sourceId]/route.ts b/src/app/api/sources/[sourceId]/route.ts
index 9d05d816..0104b42b 100644
--- a/src/app/api/sources/[sourceId]/route.ts
+++ b/src/app/api/sources/[sourceId]/route.ts
@@ -31,7 +31,11 @@ export async function PATCH(
const result =
mutationRequest.mutation.kind === "archive"
? await sourceRouteService.archiveSource(mutationRequest.mutation.input)
- : await sourceRouteService.retrySource(mutationRequest.mutation.input)
+ : mutationRequest.mutation.kind === "retry"
+ ? await sourceRouteService.retrySource(mutationRequest.mutation.input)
+ : await sourceRouteService.assignSourceFolder(
+ mutationRequest.mutation.input,
+ )
return nextRouteResponse.toNextResponse(result)
}
diff --git a/src/app/api/sources/route.test.ts b/src/app/api/sources/route.test.ts
index 154efa20..edc83a26 100644
--- a/src/app/api/sources/route.test.ts
+++ b/src/app/api/sources/route.test.ts
@@ -76,6 +76,7 @@ const source: Source = {
originalBlobUrl: null,
demoKey: null,
chunkCount: null,
+ folderId: null,
createdAt: new Date("2026-05-10T00:00:00Z"),
updatedAt: new Date("2026-05-10T00:00:00Z"),
deletedAt: null,
diff --git a/src/components/folder-destination-menu.tsx b/src/components/folder-destination-menu.tsx
new file mode 100644
index 00000000..6ad20a45
--- /dev/null
+++ b/src/components/folder-destination-menu.tsx
@@ -0,0 +1,56 @@
+"use client"
+
+import type { ReactElement } from "react"
+import { Folder } from "lucide-react"
+
+import {
+ DropdownMenuItem,
+ DropdownMenuLabel,
+ DropdownMenuSeparator,
+} from "@/components/ui/dropdown-menu"
+import { getFolderPath } from "@/domains/folders/tree"
+import type { FolderView } from "@/domains/folders/types"
+
+export type FolderDestinationMenuProps = {
+ readonly folders: readonly FolderView[]
+ readonly excludedFolderIds?: ReadonlySet
+ readonly onSelect: (folderId: string | null) => void
+}
+
+export function FolderDestinationMenu({
+ folders,
+ excludedFolderIds,
+ onSelect,
+}: FolderDestinationMenuProps): ReactElement {
+ const destinations = folders.filter(
+ (folder) => !excludedFolderIds?.has(folder.id),
+ )
+
+ return (
+ <>
+ Move to
+ onSelect(null)}>
+ All sources
+
+ {destinations.length > 0 ? : null}
+ {destinations.map((folder) => (
+ onSelect(folder.id)}
+ >
+
+ {formatFolderDestination(folders, folder.id)}
+
+ ))}
+ >
+ )
+}
+
+function formatFolderDestination(
+ folders: readonly FolderView[],
+ folderId: string,
+): string {
+ return getFolderPath(folders, folderId)
+ .map((folder) => folder.name)
+ .join(" / ")
+}
diff --git a/src/components/folder-panel-state.ts b/src/components/folder-panel-state.ts
new file mode 100644
index 00000000..16bffcab
--- /dev/null
+++ b/src/components/folder-panel-state.ts
@@ -0,0 +1,49 @@
+import {
+ getFolderPath,
+ listChildFolders,
+ listSourcesInFolder,
+} from "@/domains/folders/tree"
+import type { FolderView } from "@/domains/folders/types"
+import type { SourceView } from "@/domains/sources/types"
+
+export type FolderListItem =
+ | {
+ readonly kind: "folder"
+ readonly folder: FolderView
+ }
+ | {
+ readonly kind: "source"
+ readonly source: SourceView
+ }
+
+export function getFolderListItems(
+ folders: readonly FolderView[],
+ sources: readonly SourceView[],
+ currentFolderId: string | null,
+): FolderListItem[] {
+ return [
+ ...listChildFolders(folders, currentFolderId).map(
+ (folder): FolderListItem => ({ kind: "folder", folder }),
+ ),
+ ...listSourcesInFolder(sources, currentFolderId).map(
+ (source): FolderListItem => ({ kind: "source", source }),
+ ),
+ ]
+}
+
+export function getResolvedCurrentFolderId(
+ folders: readonly FolderView[],
+ currentFolderId: string | null,
+): string | null {
+ if (!currentFolderId) return null
+ return folders.some((folder) => folder.id === currentFolderId)
+ ? currentFolderId
+ : null
+}
+
+export function getFolderBreadcrumb(
+ folders: readonly FolderView[],
+ currentFolderId: string | null,
+): FolderView[] {
+ return getFolderPath(folders, currentFolderId)
+}
diff --git a/src/components/folder-row.tsx b/src/components/folder-row.tsx
new file mode 100644
index 00000000..0f749df8
--- /dev/null
+++ b/src/components/folder-row.tsx
@@ -0,0 +1,115 @@
+"use client"
+
+import type { ReactElement } from "react"
+import { Folder, MoreHorizontal, Pencil, Trash2 } from "lucide-react"
+
+import { FolderDestinationMenu } from "@/components/folder-destination-menu"
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuSeparator,
+ DropdownMenuSub,
+ DropdownMenuSubContent,
+ DropdownMenuSubTrigger,
+ DropdownMenuTrigger,
+} from "@/components/ui/dropdown-menu"
+import { Spinner } from "@/components/ui/spinner"
+import { getDescendantFolderIds } from "@/domains/folders/tree"
+import type { FolderView } from "@/domains/folders/types"
+
+export type FolderRowProps = {
+ readonly folder: FolderView
+ readonly folders: readonly FolderView[]
+ readonly isDeleting?: boolean
+ readonly isNarrow?: boolean
+ readonly onDelete: (folderId: string) => void
+ readonly onMove: (folderId: string, parentId: string | null) => void
+ readonly onOpen: (folderId: string) => void
+ readonly onRename: (folderId: string) => void
+}
+
+export function FolderRow({
+ folder,
+ folders,
+ isDeleting = false,
+ isNarrow = false,
+ onDelete,
+ onMove,
+ onOpen,
+ onRename,
+}: FolderRowProps): ReactElement {
+ const excludedFolderIds = new Set(getDescendantFolderIds(folders, folder.id))
+
+ return (
+
+
+
+
+
+
+
+ onRename(folder.id)}>
+
+ Rename
+
+
+ Move to…
+
+ onMove(folder.id, parentId)}
+ />
+
+
+
+ onDelete(folder.id)}>
+
+ Delete
+
+
+
+
+ )
+}
diff --git a/src/components/source-row.tsx b/src/components/source-row.tsx
index 473453f3..4f951961 100644
--- a/src/components/source-row.tsx
+++ b/src/components/source-row.tsx
@@ -2,10 +2,18 @@
import type { ReactElement } from "react";
import Link from "next/link";
-import { FileText, ListTree, Plus, RotateCcw, Trash2 } from "lucide-react";
+import { FileText, FolderInput, ListTree, Plus, RotateCcw, Trash2 } from "lucide-react";
+import { FolderDestinationMenu } from "@/components/folder-destination-menu";
import { Checkbox } from "@/components/ui/checkbox";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuTrigger,
+} from "@/components/ui/dropdown-menu";
import { Spinner } from "@/components/ui/spinner";
+import { canAssignSourceToFolder } from "@/domains/folders/tree";
+import type { FolderView } from "@/domains/folders/types";
import type { SourceView } from "@/domains/sources/types";
export type SourceRowProps = {
@@ -20,6 +28,9 @@ export type SourceRowProps = {
readonly onRetryClick?: (sourceId: string) => void;
readonly onSelect: () => void;
readonly onToggleIncluded?: (sourceId: string, included: boolean) => void;
+ readonly folders?: readonly FolderView[];
+ readonly isMoving?: boolean;
+ readonly onMoveToFolder?: (sourceId: string, folderId: string | null) => void;
readonly source: SourceView;
};
@@ -36,8 +47,12 @@ export function SourceRow({
chunkTreeHref,
isArchiving,
isRetrying = false,
+ folders = [],
+ isMoving = false,
+ onMoveToFolder,
}: SourceRowProps): ReactElement {
const isReady = source.status === "ready";
+ const canMove = canAssignSourceToFolder(source) && onMoveToFolder !== undefined;
const isBusy = source.status === "uploading" || source.status === "parsing";
const isFailed = source.status === "failed";
const canRetry = isFailed && source.originalFile !== undefined;
@@ -146,6 +161,31 @@ export function SourceRow({
{isNarrow ? null : "Add"}
)}
+ {canMove ? (
+
+
+
+
+
+ onMoveToFolder?.(source.id, folderId)}
+ />
+
+
+ ) : null}
{canRetry && onRetryClick ? (