The open-source app everyone uses to manage agents at work
TypeScript acpxagent-orchestrationagent-skillsagentic-aiai-agentsai-engineeringai-governanceai-toolsautonomous-agentsclaudeclaude-codeclaude-skillscodexhermesllmmcpmulti-agentopenclawproject-managementworkflow-automation
Add company skills library and agent skills UI
Dotta0bf53bc51342
diff --git a/packages/db/src/migrations/0028_bent_eternals.sql b/packages/db/src/migrations/0028_bent_eternals.sqlnew file mode 100644index 0000000000..d288363c43--- /dev/null+++ b/packages/db/src/migrations/0028_bent_eternals.sql@@ -0,0 +1,21 @@+CREATE TABLE "company_skills" (+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,+ "company_id" uuid NOT NULL,+ "slug" text NOT NULL,+ "name" text NOT NULL,+ "description" text,+ "markdown" text NOT NULL,+ "source_type" text DEFAULT 'local_path' NOT NULL,+ "source_locator" text,+ "source_ref" text,+ "trust_level" text DEFAULT 'markdown_only' NOT NULL,+ "compatibility" text DEFAULT 'compatible' NOT NULL,+ "file_inventory" jsonb DEFAULT '[]'::jsonb NOT NULL,+ "metadata" jsonb,+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL+);+--> statement-breakpoint+ALTER TABLE "company_skills" ADD CONSTRAINT "company_skills_company_id_companies_id_fk" FOREIGN KEY ("company_id") REFERENCES "public"."companies"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint+CREATE UNIQUE INDEX "company_skills_company_slug_idx" ON "company_skills" USING btree ("company_id","slug");--> statement-breakpoint+CREATE INDEX "company_skills_company_name_idx" ON "company_skills" USING btree ("company_id","name");\ No newline at end of filediff --git a/packages/db/src/migrations/meta/0028_snapshot.json b/packages/db/src/migrations/meta/0028_snapshot.jsonnew file mode 100644index 0000000000..385155a10b--- /dev/null+++ b/packages/db/src/migrations/meta/0028_snapshot.json@@ -0,0 +1,6372 @@+{+ "id": "a0621514-3564-4e98-b8bb-e920a9039390",+ "prevId": "8186209d-f7ec-4048-bd4f-c96530f45304",+ "version": "7",+ "dialect": "postgresql",+ "tables": {+ "public.activity_log": {+ "name": "activity_log",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "actor_type": {+ "name": "actor_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'system'"+ },+ "actor_id": {+ "name": "actor_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "action": {+ "name": "action",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "entity_type": {+ "name": "entity_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "entity_id": {+ "name": "entity_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "run_id": {+ "name": "run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "details": {+ "name": "details",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "activity_log_company_created_idx": {+ "name": "activity_log_company_created_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "activity_log_run_id_idx": {+ "name": "activity_log_run_id_idx",+ "columns": [+ {+ "expression": "run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "activity_log_entity_type_id_idx": {+ "name": "activity_log_entity_type_id_idx",+ "columns": [+ {+ "expression": "entity_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "entity_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "activity_log_company_id_companies_id_fk": {+ "name": "activity_log_company_id_companies_id_fk",+ "tableFrom": "activity_log",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "activity_log_agent_id_agents_id_fk": {+ "name": "activity_log_agent_id_agents_id_fk",+ "tableFrom": "activity_log",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "activity_log_run_id_heartbeat_runs_id_fk": {+ "name": "activity_log_run_id_heartbeat_runs_id_fk",+ "tableFrom": "activity_log",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_api_keys": {+ "name": "agent_api_keys",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "agent_id": {+ "name": "agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "key_hash": {+ "name": "key_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "last_used_at": {+ "name": "last_used_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "revoked_at": {+ "name": "revoked_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_api_keys_key_hash_idx": {+ "name": "agent_api_keys_key_hash_idx",+ "columns": [+ {+ "expression": "key_hash",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_api_keys_company_agent_idx": {+ "name": "agent_api_keys_company_agent_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_api_keys_agent_id_agents_id_fk": {+ "name": "agent_api_keys_agent_id_agents_id_fk",+ "tableFrom": "agent_api_keys",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "agent_api_keys_company_id_companies_id_fk": {+ "name": "agent_api_keys_company_id_companies_id_fk",+ "tableFrom": "agent_api_keys",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_config_revisions": {+ "name": "agent_config_revisions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'patch'"+ },+ "rolled_back_from_revision_id": {+ "name": "rolled_back_from_revision_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "changed_keys": {+ "name": "changed_keys",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "before_config": {+ "name": "before_config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "after_config": {+ "name": "after_config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_config_revisions_company_agent_created_idx": {+ "name": "agent_config_revisions_company_agent_created_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_config_revisions_agent_created_idx": {+ "name": "agent_config_revisions_agent_created_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_config_revisions_company_id_companies_id_fk": {+ "name": "agent_config_revisions_company_id_companies_id_fk",+ "tableFrom": "agent_config_revisions",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "agent_config_revisions_agent_id_agents_id_fk": {+ "name": "agent_config_revisions_agent_id_agents_id_fk",+ "tableFrom": "agent_config_revisions",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_config_revisions_created_by_agent_id_agents_id_fk": {+ "name": "agent_config_revisions_created_by_agent_id_agents_id_fk",+ "tableFrom": "agent_config_revisions",+ "tableTo": "agents",+ "columnsFrom": [+ "created_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_runtime_state": {+ "name": "agent_runtime_state",+ "schema": "",+ "columns": {+ "agent_id": {+ "name": "agent_id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "adapter_type": {+ "name": "adapter_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "session_id": {+ "name": "session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "state_json": {+ "name": "state_json",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "last_run_id": {+ "name": "last_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "last_run_status": {+ "name": "last_run_status",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "total_input_tokens": {+ "name": "total_input_tokens",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "total_output_tokens": {+ "name": "total_output_tokens",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "total_cached_input_tokens": {+ "name": "total_cached_input_tokens",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "total_cost_cents": {+ "name": "total_cost_cents",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "last_error": {+ "name": "last_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_runtime_state_company_agent_idx": {+ "name": "agent_runtime_state_company_agent_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_runtime_state_company_updated_idx": {+ "name": "agent_runtime_state_company_updated_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "updated_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_runtime_state_agent_id_agents_id_fk": {+ "name": "agent_runtime_state_agent_id_agents_id_fk",+ "tableFrom": "agent_runtime_state",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "agent_runtime_state_company_id_companies_id_fk": {+ "name": "agent_runtime_state_company_id_companies_id_fk",+ "tableFrom": "agent_runtime_state",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_task_sessions": {+ "name": "agent_task_sessions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "adapter_type": {+ "name": "adapter_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "task_key": {+ "name": "task_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "session_params_json": {+ "name": "session_params_json",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "session_display_id": {+ "name": "session_display_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "last_run_id": {+ "name": "last_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "last_error": {+ "name": "last_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_task_sessions_company_agent_adapter_task_uniq": {+ "name": "agent_task_sessions_company_agent_adapter_task_uniq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "adapter_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "task_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_task_sessions_company_agent_updated_idx": {+ "name": "agent_task_sessions_company_agent_updated_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "updated_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_task_sessions_company_task_updated_idx": {+ "name": "agent_task_sessions_company_task_updated_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "task_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "updated_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_task_sessions_company_id_companies_id_fk": {+ "name": "agent_task_sessions_company_id_companies_id_fk",+ "tableFrom": "agent_task_sessions",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "agent_task_sessions_agent_id_agents_id_fk": {+ "name": "agent_task_sessions_agent_id_agents_id_fk",+ "tableFrom": "agent_task_sessions",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "agent_task_sessions_last_run_id_heartbeat_runs_id_fk": {+ "name": "agent_task_sessions_last_run_id_heartbeat_runs_id_fk",+ "tableFrom": "agent_task_sessions",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "last_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_wakeup_requests": {+ "name": "agent_wakeup_requests",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "trigger_detail": {+ "name": "trigger_detail",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "reason": {+ "name": "reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "payload": {+ "name": "payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'queued'"+ },+ "coalesced_count": {+ "name": "coalesced_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "requested_by_actor_type": {+ "name": "requested_by_actor_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "requested_by_actor_id": {+ "name": "requested_by_actor_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "idempotency_key": {+ "name": "idempotency_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "run_id": {+ "name": "run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "requested_at": {+ "name": "requested_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "claimed_at": {+ "name": "claimed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "finished_at": {+ "name": "finished_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "error": {+ "name": "error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_wakeup_requests_company_agent_status_idx": {+ "name": "agent_wakeup_requests_company_agent_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_wakeup_requests_company_requested_idx": {+ "name": "agent_wakeup_requests_company_requested_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "requested_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_wakeup_requests_agent_requested_idx": {+ "name": "agent_wakeup_requests_agent_requested_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "requested_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_wakeup_requests_company_id_companies_id_fk": {+ "name": "agent_wakeup_requests_company_id_companies_id_fk",+ "tableFrom": "agent_wakeup_requests",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "agent_wakeup_requests_agent_id_agents_id_fk": {+ "name": "agent_wakeup_requests_agent_id_agents_id_fk",+ "tableFrom": "agent_wakeup_requests",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agents": {+ "name": "agents",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'general'"+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "icon": {+ "name": "icon",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'idle'"+ },+ "reports_to": {+ "name": "reports_to",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "capabilities": {+ "name": "capabilities",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "adapter_type": {+ "name": "adapter_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'process'"+ },+ "adapter_config": {+ "name": "adapter_config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "runtime_config": {+ "name": "runtime_config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "budget_monthly_cents": {+ "name": "budget_monthly_cents",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "spent_monthly_cents": {+ "name": "spent_monthly_cents",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "permissions": {+ "name": "permissions",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "last_heartbeat_at": {+ "name": "last_heartbeat_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agents_company_status_idx": {+ "name": "agents_company_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agents_company_reports_to_idx": {+ "name": "agents_company_reports_to_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "reports_to",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agents_company_id_companies_id_fk": {+ "name": "agents_company_id_companies_id_fk",+ "tableFrom": "agents",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "agents_reports_to_agents_id_fk": {+ "name": "agents_reports_to_agents_id_fk",+ "tableFrom": "agents",+ "tableTo": "agents",+ "columnsFrom": [+ "reports_to"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.approval_comments": {+ "name": "approval_comments",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "approval_id": {+ "name": "approval_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "author_agent_id": {+ "name": "author_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "author_user_id": {+ "name": "author_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "body": {+ "name": "body",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "approval_comments_company_idx": {+ "name": "approval_comments_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "approval_comments_approval_idx": {+ "name": "approval_comments_approval_idx",+ "columns": [+ {+ "expression": "approval_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "approval_comments_approval_created_idx": {+ "name": "approval_comments_approval_created_idx",+ "columns": [+ {+ "expression": "approval_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "approval_comments_company_id_companies_id_fk": {+ "name": "approval_comments_company_id_companies_id_fk",+ "tableFrom": "approval_comments",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "approval_comments_approval_id_approvals_id_fk": {+ "name": "approval_comments_approval_id_approvals_id_fk",+ "tableFrom": "approval_comments",+ "tableTo": "approvals",+ "columnsFrom": [+ "approval_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "approval_comments_author_agent_id_agents_id_fk": {+ "name": "approval_comments_author_agent_id_agents_id_fk",+ "tableFrom": "approval_comments",+ "tableTo": "agents",+ "columnsFrom": [+ "author_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.approvals": {+ "name": "approvals",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "requested_by_agent_id": {+ "name": "requested_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "requested_by_user_id": {+ "name": "requested_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "payload": {+ "name": "payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "decision_note": {+ "name": "decision_note",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "decided_by_user_id": {+ "name": "decided_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "decided_at": {+ "name": "decided_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": {+ "approvals_company_status_type_idx": {+ "name": "approvals_company_status_type_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "approvals_company_id_companies_id_fk": {+ "name": "approvals_company_id_companies_id_fk",+ "tableFrom": "approvals",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "approvals_requested_by_agent_id_agents_id_fk": {+ "name": "approvals_requested_by_agent_id_agents_id_fk",+ "tableFrom": "approvals",+ "tableTo": "agents",+ "columnsFrom": [+ "requested_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.assets": {+ "name": "assets",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "object_key": {+ "name": "object_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "content_type": {+ "name": "content_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "byte_size": {+ "name": "byte_size",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "sha256": {+ "name": "sha256",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "original_filename": {+ "name": "original_filename",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "assets_company_created_idx": {+ "name": "assets_company_created_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "assets_company_provider_idx": {+ "name": "assets_company_provider_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "assets_company_object_key_uq": {+ "name": "assets_company_object_key_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "object_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "assets_company_id_companies_id_fk": {+ "name": "assets_company_id_companies_id_fk",+ "tableFrom": "assets",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "assets_created_by_agent_id_agents_id_fk": {+ "name": "assets_created_by_agent_id_agents_id_fk",+ "tableFrom": "assets",+ "tableTo": "agents",+ "columnsFrom": [+ "created_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.account": {+ "name": "account",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "account_id": {+ "name": "account_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "provider_id": {+ "name": "provider_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "access_token": {+ "name": "access_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "refresh_token": {+ "name": "refresh_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "id_token": {+ "name": "id_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "access_token_expires_at": {+ "name": "access_token_expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "refresh_token_expires_at": {+ "name": "refresh_token_expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "scope": {+ "name": "scope",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "password": {+ "name": "password",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {+ "account_user_id_user_id_fk": {+ "name": "account_user_id_user_id_fk",+ "tableFrom": "account",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.session": {+ "name": "session",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "token": {+ "name": "token",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "ip_address": {+ "name": "ip_address",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_agent": {+ "name": "user_agent",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {+ "session_user_id_user_id_fk": {+ "name": "session_user_id_user_id_fk",+ "tableFrom": "session",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user": {+ "name": "user",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "email": {+ "name": "email",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "email_verified": {+ "name": "email_verified",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "image": {+ "name": "image",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.verification": {+ "name": "verification",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "identifier": {+ "name": "identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "value": {+ "name": "value",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.companies": {+ "name": "companies",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'active'"+ },+ "issue_prefix": {+ "name": "issue_prefix",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'PAP'"+ },+ "issue_counter": {+ "name": "issue_counter",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "budget_monthly_cents": {+ "name": "budget_monthly_cents",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "spent_monthly_cents": {+ "name": "spent_monthly_cents",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "require_board_approval_for_new_agents": {+ "name": "require_board_approval_for_new_agents",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "brand_color": {+ "name": "brand_color",+ "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": {+ "companies_issue_prefix_idx": {+ "name": "companies_issue_prefix_idx",+ "columns": [+ {+ "expression": "issue_prefix",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.company_memberships": {+ "name": "company_memberships",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "principal_type": {+ "name": "principal_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "principal_id": {+ "name": "principal_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'active'"+ },+ "membership_role": {+ "name": "membership_role",+ "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": {+ "company_memberships_company_principal_unique_idx": {+ "name": "company_memberships_company_principal_unique_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "principal_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "principal_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_memberships_principal_status_idx": {+ "name": "company_memberships_principal_status_idx",+ "columns": [+ {+ "expression": "principal_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "principal_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_memberships_company_status_idx": {+ "name": "company_memberships_company_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "company_memberships_company_id_companies_id_fk": {+ "name": "company_memberships_company_id_companies_id_fk",+ "tableFrom": "company_memberships",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.company_secret_versions": {+ "name": "company_secret_versions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "secret_id": {+ "name": "secret_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "version": {+ "name": "version",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "material": {+ "name": "material",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "value_sha256": {+ "name": "value_sha256",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "revoked_at": {+ "name": "revoked_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "company_secret_versions_secret_idx": {+ "name": "company_secret_versions_secret_idx",+ "columns": [+ {+ "expression": "secret_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_secret_versions_value_sha256_idx": {+ "name": "company_secret_versions_value_sha256_idx",+ "columns": [+ {+ "expression": "value_sha256",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_secret_versions_secret_version_uq": {+ "name": "company_secret_versions_secret_version_uq",+ "columns": [+ {+ "expression": "secret_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "version",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "company_secret_versions_secret_id_company_secrets_id_fk": {+ "name": "company_secret_versions_secret_id_company_secrets_id_fk",+ "tableFrom": "company_secret_versions",+ "tableTo": "company_secrets",+ "columnsFrom": [+ "secret_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "company_secret_versions_created_by_agent_id_agents_id_fk": {+ "name": "company_secret_versions_created_by_agent_id_agents_id_fk",+ "tableFrom": "company_secret_versions",+ "tableTo": "agents",+ "columnsFrom": [+ "created_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.company_secrets": {+ "name": "company_secrets",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'local_encrypted'"+ },+ "external_ref": {+ "name": "external_ref",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "latest_version": {+ "name": "latest_version",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 1+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "company_secrets_company_idx": {+ "name": "company_secrets_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_secrets_company_provider_idx": {+ "name": "company_secrets_company_provider_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_secrets_company_name_uq": {+ "name": "company_secrets_company_name_uq",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "name",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "company_secrets_company_id_companies_id_fk": {+ "name": "company_secrets_company_id_companies_id_fk",+ "tableFrom": "company_secrets",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "company_secrets_created_by_agent_id_agents_id_fk": {+ "name": "company_secrets_created_by_agent_id_agents_id_fk",+ "tableFrom": "company_secrets",+ "tableTo": "agents",+ "columnsFrom": [+ "created_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.company_skills": {+ "name": "company_skills",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "slug": {+ "name": "slug",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "markdown": {+ "name": "markdown",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source_type": {+ "name": "source_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'local_path'"+ },+ "source_locator": {+ "name": "source_locator",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "source_ref": {+ "name": "source_ref",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "trust_level": {+ "name": "trust_level",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'markdown_only'"+ },+ "compatibility": {+ "name": "compatibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'compatible'"+ },+ "file_inventory": {+ "name": "file_inventory",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "company_skills_company_slug_idx": {+ "name": "company_skills_company_slug_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "slug",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "company_skills_company_name_idx": {+ "name": "company_skills_company_name_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "name",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "company_skills_company_id_companies_id_fk": {+ "name": "company_skills_company_id_companies_id_fk",+ "tableFrom": "company_skills",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.cost_events": {+ "name": "cost_events",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "project_id": {+ "name": "project_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "goal_id": {+ "name": "goal_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "billing_code": {+ "name": "billing_code",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "model": {+ "name": "model",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "input_tokens": {+ "name": "input_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "output_tokens": {+ "name": "output_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "cost_cents": {+ "name": "cost_cents",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "occurred_at": {+ "name": "occurred_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "cost_events_company_occurred_idx": {+ "name": "cost_events_company_occurred_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "occurred_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "cost_events_company_agent_occurred_idx": {+ "name": "cost_events_company_agent_occurred_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "occurred_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "cost_events_company_id_companies_id_fk": {+ "name": "cost_events_company_id_companies_id_fk",+ "tableFrom": "cost_events",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "cost_events_agent_id_agents_id_fk": {+ "name": "cost_events_agent_id_agents_id_fk",+ "tableFrom": "cost_events",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "cost_events_issue_id_issues_id_fk": {+ "name": "cost_events_issue_id_issues_id_fk",+ "tableFrom": "cost_events",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "cost_events_project_id_projects_id_fk": {+ "name": "cost_events_project_id_projects_id_fk",+ "tableFrom": "cost_events",+ "tableTo": "projects",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "cost_events_goal_id_goals_id_fk": {+ "name": "cost_events_goal_id_goals_id_fk",+ "tableFrom": "cost_events",+ "tableTo": "goals",+ "columnsFrom": [+ "goal_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.goals": {+ "name": "goals",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "level": {+ "name": "level",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'task'"+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'planned'"+ },+ "parent_id": {+ "name": "parent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "owner_agent_id": {+ "name": "owner_agent_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()"+ }+ },+ "indexes": {+ "goals_company_idx": {+ "name": "goals_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "goals_company_id_companies_id_fk": {+ "name": "goals_company_id_companies_id_fk",+ "tableFrom": "goals",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "goals_parent_id_goals_id_fk": {+ "name": "goals_parent_id_goals_id_fk",+ "tableFrom": "goals",+ "tableTo": "goals",+ "columnsFrom": [+ "parent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "goals_owner_agent_id_agents_id_fk": {+ "name": "goals_owner_agent_id_agents_id_fk",+ "tableFrom": "goals",+ "tableTo": "agents",+ "columnsFrom": [+ "owner_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.heartbeat_run_events": {+ "name": "heartbeat_run_events",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "bigserial",+ "primaryKey": true,+ "notNull": true+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "run_id": {+ "name": "run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "seq": {+ "name": "seq",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "event_type": {+ "name": "event_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "stream": {+ "name": "stream",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "level": {+ "name": "level",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "message": {+ "name": "message",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "payload": {+ "name": "payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "heartbeat_run_events_run_seq_idx": {+ "name": "heartbeat_run_events_run_seq_idx",+ "columns": [+ {+ "expression": "run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "seq",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "heartbeat_run_events_company_run_idx": {+ "name": "heartbeat_run_events_company_run_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "heartbeat_run_events_company_created_idx": {+ "name": "heartbeat_run_events_company_created_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "heartbeat_run_events_company_id_companies_id_fk": {+ "name": "heartbeat_run_events_company_id_companies_id_fk",+ "tableFrom": "heartbeat_run_events",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "heartbeat_run_events_run_id_heartbeat_runs_id_fk": {+ "name": "heartbeat_run_events_run_id_heartbeat_runs_id_fk",+ "tableFrom": "heartbeat_run_events",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "heartbeat_run_events_agent_id_agents_id_fk": {+ "name": "heartbeat_run_events_agent_id_agents_id_fk",+ "tableFrom": "heartbeat_run_events",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.heartbeat_runs": {+ "name": "heartbeat_runs",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "invocation_source": {+ "name": "invocation_source",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'on_demand'"+ },+ "trigger_detail": {+ "name": "trigger_detail",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'queued'"+ },+ "started_at": {+ "name": "started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "finished_at": {+ "name": "finished_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "error": {+ "name": "error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "wakeup_request_id": {+ "name": "wakeup_request_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "exit_code": {+ "name": "exit_code",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "signal": {+ "name": "signal",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "usage_json": {+ "name": "usage_json",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "result_json": {+ "name": "result_json",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "session_id_before": {+ "name": "session_id_before",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "session_id_after": {+ "name": "session_id_after",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "log_store": {+ "name": "log_store",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "log_ref": {+ "name": "log_ref",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "log_bytes": {+ "name": "log_bytes",+ "type": "bigint",+ "primaryKey": false,+ "notNull": false+ },+ "log_sha256": {+ "name": "log_sha256",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "log_compressed": {+ "name": "log_compressed",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "stdout_excerpt": {+ "name": "stdout_excerpt",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "stderr_excerpt": {+ "name": "stderr_excerpt",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "error_code": {+ "name": "error_code",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "external_run_id": {+ "name": "external_run_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "context_snapshot": {+ "name": "context_snapshot",+ "type": "jsonb",+ "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": {+ "heartbeat_runs_company_agent_started_idx": {+ "name": "heartbeat_runs_company_agent_started_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "started_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "heartbeat_runs_company_id_companies_id_fk": {+ "name": "heartbeat_runs_company_id_companies_id_fk",+ "tableFrom": "heartbeat_runs",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "heartbeat_runs_agent_id_agents_id_fk": {+ "name": "heartbeat_runs_agent_id_agents_id_fk",+ "tableFrom": "heartbeat_runs",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "heartbeat_runs_wakeup_request_id_agent_wakeup_requests_id_fk": {+ "name": "heartbeat_runs_wakeup_request_id_agent_wakeup_requests_id_fk",+ "tableFrom": "heartbeat_runs",+ "tableTo": "agent_wakeup_requests",+ "columnsFrom": [+ "wakeup_request_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.instance_user_roles": {+ "name": "instance_user_roles",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'instance_admin'"+ },+ "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": {+ "instance_user_roles_user_role_unique_idx": {+ "name": "instance_user_roles_user_role_unique_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "role",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "instance_user_roles_role_idx": {+ "name": "instance_user_roles_role_idx",+ "columns": [+ {+ "expression": "role",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.invites": {+ "name": "invites",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "invite_type": {+ "name": "invite_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'company_join'"+ },+ "token_hash": {+ "name": "token_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "allowed_join_types": {+ "name": "allowed_join_types",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'both'"+ },+ "defaults_payload": {+ "name": "defaults_payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "invited_by_user_id": {+ "name": "invited_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "revoked_at": {+ "name": "revoked_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "accepted_at": {+ "name": "accepted_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": {+ "invites_token_hash_unique_idx": {+ "name": "invites_token_hash_unique_idx",+ "columns": [+ {+ "expression": "token_hash",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "invites_company_invite_state_idx": {+ "name": "invites_company_invite_state_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "invite_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "revoked_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "expires_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "invites_company_id_companies_id_fk": {+ "name": "invites_company_id_companies_id_fk",+ "tableFrom": "invites",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_approvals": {+ "name": "issue_approvals",+ "schema": "",+ "columns": {+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "approval_id": {+ "name": "approval_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "linked_by_agent_id": {+ "name": "linked_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "linked_by_user_id": {+ "name": "linked_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_approvals_issue_idx": {+ "name": "issue_approvals_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_approvals_approval_idx": {+ "name": "issue_approvals_approval_idx",+ "columns": [+ {+ "expression": "approval_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_approvals_company_idx": {+ "name": "issue_approvals_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_approvals_company_id_companies_id_fk": {+ "name": "issue_approvals_company_id_companies_id_fk",+ "tableFrom": "issue_approvals",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "issue_approvals_issue_id_issues_id_fk": {+ "name": "issue_approvals_issue_id_issues_id_fk",+ "tableFrom": "issue_approvals",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_approvals_approval_id_approvals_id_fk": {+ "name": "issue_approvals_approval_id_approvals_id_fk",+ "tableFrom": "issue_approvals",+ "tableTo": "approvals",+ "columnsFrom": [+ "approval_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_approvals_linked_by_agent_id_agents_id_fk": {+ "name": "issue_approvals_linked_by_agent_id_agents_id_fk",+ "tableFrom": "issue_approvals",+ "tableTo": "agents",+ "columnsFrom": [+ "linked_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "issue_approvals_pk": {+ "name": "issue_approvals_pk",+ "columns": [+ "issue_id",+ "approval_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_attachments": {+ "name": "issue_attachments",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "asset_id": {+ "name": "asset_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "issue_comment_id": {+ "name": "issue_comment_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()"+ }+ },+ "indexes": {+ "issue_attachments_company_issue_idx": {+ "name": "issue_attachments_company_issue_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_attachments_issue_comment_idx": {+ "name": "issue_attachments_issue_comment_idx",+ "columns": [+ {+ "expression": "issue_comment_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_attachments_asset_uq": {+ "name": "issue_attachments_asset_uq",+ "columns": [+ {+ "expression": "asset_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_attachments_company_id_companies_id_fk": {+ "name": "issue_attachments_company_id_companies_id_fk",+ "tableFrom": "issue_attachments",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "issue_attachments_issue_id_issues_id_fk": {+ "name": "issue_attachments_issue_id_issues_id_fk",+ "tableFrom": "issue_attachments",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_attachments_asset_id_assets_id_fk": {+ "name": "issue_attachments_asset_id_assets_id_fk",+ "tableFrom": "issue_attachments",+ "tableTo": "assets",+ "columnsFrom": [+ "asset_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_attachments_issue_comment_id_issue_comments_id_fk": {+ "name": "issue_attachments_issue_comment_id_issue_comments_id_fk",+ "tableFrom": "issue_attachments",+ "tableTo": "issue_comments",+ "columnsFrom": [+ "issue_comment_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_comments": {+ "name": "issue_comments",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "author_agent_id": {+ "name": "author_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "author_user_id": {+ "name": "author_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "body": {+ "name": "body",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_comments_issue_idx": {+ "name": "issue_comments_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_comments_company_idx": {+ "name": "issue_comments_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_comments_company_issue_created_at_idx": {+ "name": "issue_comments_company_issue_created_at_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_comments_company_author_issue_created_at_idx": {+ "name": "issue_comments_company_author_issue_created_at_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "author_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_comments_company_id_companies_id_fk": {+ "name": "issue_comments_company_id_companies_id_fk",+ "tableFrom": "issue_comments",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "issue_comments_issue_id_issues_id_fk": {+ "name": "issue_comments_issue_id_issues_id_fk",+ "tableFrom": "issue_comments",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "issue_comments_author_agent_id_agents_id_fk": {+ "name": "issue_comments_author_agent_id_agents_id_fk",+ "tableFrom": "issue_comments",+ "tableTo": "agents",+ "columnsFrom": [+ "author_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_labels": {+ "name": "issue_labels",+ "schema": "",+ "columns": {+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "label_id": {+ "name": "label_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_labels_issue_idx": {+ "name": "issue_labels_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_labels_label_idx": {+ "name": "issue_labels_label_idx",+ "columns": [+ {+ "expression": "label_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_labels_company_idx": {+ "name": "issue_labels_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_labels_issue_id_issues_id_fk": {+ "name": "issue_labels_issue_id_issues_id_fk",+ "tableFrom": "issue_labels",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_labels_label_id_labels_id_fk": {+ "name": "issue_labels_label_id_labels_id_fk",+ "tableFrom": "issue_labels",+ "tableTo": "labels",+ "columnsFrom": [+ "label_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_labels_company_id_companies_id_fk": {+ "name": "issue_labels_company_id_companies_id_fk",+ "tableFrom": "issue_labels",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "issue_labels_pk": {+ "name": "issue_labels_pk",+ "columns": [+ "issue_id",+ "label_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_read_states": {+ "name": "issue_read_states",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "last_read_at": {+ "name": "last_read_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_read_states_company_issue_idx": {+ "name": "issue_read_states_company_issue_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_read_states_company_user_idx": {+ "name": "issue_read_states_company_user_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_read_states_company_issue_user_idx": {+ "name": "issue_read_states_company_issue_user_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_read_states_company_id_companies_id_fk": {+ "name": "issue_read_states_company_id_companies_id_fk",+ "tableFrom": "issue_read_states",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "issue_read_states_issue_id_issues_id_fk": {+ "name": "issue_read_states_issue_id_issues_id_fk",+ "tableFrom": "issue_read_states",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issues": {+ "name": "issues",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "goal_id": {+ "name": "goal_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "parent_id": {+ "name": "parent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'backlog'"+ },+ "priority": {+ "name": "priority",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'medium'"+ },+ "assignee_agent_id": {+ "name": "assignee_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "assignee_user_id": {+ "name": "assignee_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "checkout_run_id": {+ "name": "checkout_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "execution_run_id": {+ "name": "execution_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "execution_agent_name_key": {+ "name": "execution_agent_name_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "execution_locked_at": {+ "name": "execution_locked_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_agent_id": {+ "name": "created_by_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "issue_number": {+ "name": "issue_number",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "identifier": {+ "name": "identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "request_depth": {+ "name": "request_depth",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "billing_code": {+ "name": "billing_code",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "assignee_adapter_overrides": {+ "name": "assignee_adapter_overrides",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "execution_workspace_settings": {+ "name": "execution_workspace_settings",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "started_at": {+ "name": "started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "completed_at": {+ "name": "completed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "cancelled_at": {+ "name": "cancelled_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "hidden_at": {+ "name": "hidden_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": {+ "issues_company_status_idx": {+ "name": "issues_company_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issues_company_assignee_status_idx": {+ "name": "issues_company_assignee_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "assignee_agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issues_company_assignee_user_status_idx": {+ "name": "issues_company_assignee_user_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "assignee_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issues_company_parent_idx": {+ "name": "issues_company_parent_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "parent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issues_company_project_idx": {+ "name": "issues_company_project_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issues_identifier_idx": {+ "name": "issues_identifier_idx",+ "columns": [+ {+ "expression": "identifier",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issues_company_id_companies_id_fk": {+ "name": "issues_company_id_companies_id_fk",+ "tableFrom": "issues",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "issues_project_id_projects_id_fk": {+ "name": "issues_project_id_projects_id_fk",+ "tableFrom": "issues",+ "tableTo": "projects",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "issues_goal_id_goals_id_fk": {+ "name": "issues_goal_id_goals_id_fk",+ "tableFrom": "issues",+ "tableTo": "goals",+ "columnsFrom": [+ "goal_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "issues_parent_id_issues_id_fk": {+ "name": "issues_parent_id_issues_id_fk",+ "tableFrom": "issues",+ "tableTo": "issues",+ "columnsFrom": [+ "parent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "issues_assignee_agent_id_agents_id_fk": {+ "name": "issues_assignee_agent_id_agents_id_fk",+ "tableFrom": "issues",+ "tableTo": "agents",+ "columnsFrom": [+ "assignee_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "issues_checkout_run_id_heartbeat_runs_id_fk": {+ "name": "issues_checkout_run_id_heartbeat_runs_id_fk",+ "tableFrom": "issues",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "checkout_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issues_execution_run_id_heartbeat_runs_id_fk": {+ "name": "issues_execution_run_id_heartbeat_runs_id_fk",+ "tableFrom": "issues",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "execution_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issues_created_by_agent_id_agents_id_fk": {+ "name": "issues_created_by_agent_id_agents_id_fk",+ "tableFrom": "issues",+ "tableTo": "agents",+ "columnsFrom": [+ "created_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.join_requests": {+ "name": "join_requests",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "invite_id": {+ "name": "invite_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "request_type": {+ "name": "request_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending_approval'"+ },+ "request_ip": {+ "name": "request_ip",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "requesting_user_id": {+ "name": "requesting_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "request_email_snapshot": {+ "name": "request_email_snapshot",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "agent_name": {+ "name": "agent_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "adapter_type": {+ "name": "adapter_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "capabilities": {+ "name": "capabilities",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "agent_defaults_payload": {+ "name": "agent_defaults_payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "claim_secret_hash": {+ "name": "claim_secret_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "claim_secret_expires_at": {+ "name": "claim_secret_expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "claim_secret_consumed_at": {+ "name": "claim_secret_consumed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_agent_id": {+ "name": "created_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "approved_by_user_id": {+ "name": "approved_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "approved_at": {+ "name": "approved_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "rejected_by_user_id": {+ "name": "rejected_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "rejected_at": {+ "name": "rejected_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": {+ "join_requests_invite_unique_idx": {+ "name": "join_requests_invite_unique_idx",+ "columns": [+ {+ "expression": "invite_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "join_requests_company_status_type_created_idx": {+ "name": "join_requests_company_status_type_created_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "request_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "join_requests_invite_id_invites_id_fk": {+ "name": "join_requests_invite_id_invites_id_fk",+ "tableFrom": "join_requests",+ "tableTo": "invites",+ "columnsFrom": [+ "invite_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "join_requests_company_id_companies_id_fk": {+ "name": "join_requests_company_id_companies_id_fk",+ "tableFrom": "join_requests",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "join_requests_created_agent_id_agents_id_fk": {+ "name": "join_requests_created_agent_id_agents_id_fk",+ "tableFrom": "join_requests",+ "tableTo": "agents",+ "columnsFrom": [+ "created_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.labels": {+ "name": "labels",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "labels_company_idx": {+ "name": "labels_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "labels_company_name_idx": {+ "name": "labels_company_name_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "name",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "labels_company_id_companies_id_fk": {+ "name": "labels_company_id_companies_id_fk",+ "tableFrom": "labels",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.principal_permission_grants": {+ "name": "principal_permission_grants",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "principal_type": {+ "name": "principal_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "principal_id": {+ "name": "principal_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "permission_key": {+ "name": "permission_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "scope": {+ "name": "scope",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "granted_by_user_id": {+ "name": "granted_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "principal_permission_grants_unique_idx": {+ "name": "principal_permission_grants_unique_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "principal_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "principal_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "permission_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "principal_permission_grants_company_permission_idx": {+ "name": "principal_permission_grants_company_permission_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "permission_key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "principal_permission_grants_company_id_companies_id_fk": {+ "name": "principal_permission_grants_company_id_companies_id_fk",+ "tableFrom": "principal_permission_grants",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_goals": {+ "name": "project_goals",+ "schema": "",+ "columns": {+ "project_id": {+ "name": "project_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "goal_id": {+ "name": "goal_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "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": {+ "project_goals_project_idx": {+ "name": "project_goals_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_goals_goal_idx": {+ "name": "project_goals_goal_idx",+ "columns": [+ {+ "expression": "goal_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_goals_company_idx": {+ "name": "project_goals_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_goals_project_id_projects_id_fk": {+ "name": "project_goals_project_id_projects_id_fk",+ "tableFrom": "project_goals",+ "tableTo": "projects",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_goals_goal_id_goals_id_fk": {+ "name": "project_goals_goal_id_goals_id_fk",+ "tableFrom": "project_goals",+ "tableTo": "goals",+ "columnsFrom": [+ "goal_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_goals_company_id_companies_id_fk": {+ "name": "project_goals_company_id_companies_id_fk",+ "tableFrom": "project_goals",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "project_goals_project_id_goal_id_pk": {+ "name": "project_goals_project_id_goal_id_pk",+ "columns": [+ "project_id",+ "goal_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_workspaces": {+ "name": "project_workspaces",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "cwd": {+ "name": "cwd",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "repo_url": {+ "name": "repo_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "repo_ref": {+ "name": "repo_ref",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "is_primary": {+ "name": "is_primary",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_workspaces_company_project_idx": {+ "name": "project_workspaces_company_project_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_workspaces_project_primary_idx": {+ "name": "project_workspaces_project_primary_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "is_primary",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_workspaces_company_id_companies_id_fk": {+ "name": "project_workspaces_company_id_companies_id_fk",+ "tableFrom": "project_workspaces",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "project_workspaces_project_id_projects_id_fk": {+ "name": "project_workspaces_project_id_projects_id_fk",+ "tableFrom": "project_workspaces",+ "tableTo": "projects",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.projects": {+ "name": "projects",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "goal_id": {+ "name": "goal_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'backlog'"+ },+ "lead_agent_id": {+ "name": "lead_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "target_date": {+ "name": "target_date",+ "type": "date",+ "primaryKey": false,+ "notNull": false+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "execution_workspace_policy": {+ "name": "execution_workspace_policy",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "archived_at": {+ "name": "archived_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": {+ "projects_company_idx": {+ "name": "projects_company_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "projects_company_id_companies_id_fk": {+ "name": "projects_company_id_companies_id_fk",+ "tableFrom": "projects",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "projects_goal_id_goals_id_fk": {+ "name": "projects_goal_id_goals_id_fk",+ "tableFrom": "projects",+ "tableTo": "goals",+ "columnsFrom": [+ "goal_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "projects_lead_agent_id_agents_id_fk": {+ "name": "projects_lead_agent_id_agents_id_fk",+ "tableFrom": "projects",+ "tableTo": "agents",+ "columnsFrom": [+ "lead_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.workspace_runtime_services": {+ "name": "workspace_runtime_services",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true+ },+ "company_id": {+ "name": "company_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "project_workspace_id": {+ "name": "project_workspace_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "issue_id": {+ "name": "issue_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "scope_type": {+ "name": "scope_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "scope_id": {+ "name": "scope_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "service_name": {+ "name": "service_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "lifecycle": {+ "name": "lifecycle",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "reuse_key": {+ "name": "reuse_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "command": {+ "name": "command",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "cwd": {+ "name": "cwd",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "port": {+ "name": "port",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "url": {+ "name": "url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "provider_ref": {+ "name": "provider_ref",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "owner_agent_id": {+ "name": "owner_agent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "started_by_run_id": {+ "name": "started_by_run_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "last_used_at": {+ "name": "last_used_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "started_at": {+ "name": "started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "stopped_at": {+ "name": "stopped_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "stop_policy": {+ "name": "stop_policy",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "health_status": {+ "name": "health_status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'unknown'"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "workspace_runtime_services_company_workspace_status_idx": {+ "name": "workspace_runtime_services_company_workspace_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "project_workspace_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "workspace_runtime_services_company_project_status_idx": {+ "name": "workspace_runtime_services_company_project_status_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "workspace_runtime_services_run_idx": {+ "name": "workspace_runtime_services_run_idx",+ "columns": [+ {+ "expression": "started_by_run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "workspace_runtime_services_company_updated_idx": {+ "name": "workspace_runtime_services_company_updated_idx",+ "columns": [+ {+ "expression": "company_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "updated_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "workspace_runtime_services_company_id_companies_id_fk": {+ "name": "workspace_runtime_services_company_id_companies_id_fk",+ "tableFrom": "workspace_runtime_services",+ "tableTo": "companies",+ "columnsFrom": [+ "company_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "workspace_runtime_services_project_id_projects_id_fk": {+ "name": "workspace_runtime_services_project_id_projects_id_fk",+ "tableFrom": "workspace_runtime_services",+ "tableTo": "projects",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "workspace_runtime_services_project_workspace_id_project_workspaces_id_fk": {+ "name": "workspace_runtime_services_project_workspace_id_project_workspaces_id_fk",+ "tableFrom": "workspace_runtime_services",+ "tableTo": "project_workspaces",+ "columnsFrom": [+ "project_workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "workspace_runtime_services_issue_id_issues_id_fk": {+ "name": "workspace_runtime_services_issue_id_issues_id_fk",+ "tableFrom": "workspace_runtime_services",+ "tableTo": "issues",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "workspace_runtime_services_owner_agent_id_agents_id_fk": {+ "name": "workspace_runtime_services_owner_agent_id_agents_id_fk",+ "tableFrom": "workspace_runtime_services",+ "tableTo": "agents",+ "columnsFrom": [+ "owner_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "workspace_runtime_services_started_by_run_id_heartbeat_runs_id_fk": {+ "name": "workspace_runtime_services_started_by_run_id_heartbeat_runs_id_fk",+ "tableFrom": "workspace_runtime_services",+ "tableTo": "heartbeat_runs",+ "columnsFrom": [+ "started_by_run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ }+ },+ "enums": {},+ "schemas": {},+ "sequences": {},+ "roles": {},+ "policies": {},+ "views": {},+ "_meta": {+ "columns": {},+ "schemas": {},+ "tables": {}+ }+}\ No newline at end of filediff --git a/packages/db/src/migrations/meta/_journal.json b/packages/db/src/migrations/meta/_journal.jsonindex 80a1dfbd1d..55fc021224 100644--- a/packages/db/src/migrations/meta/_journal.json+++ b/packages/db/src/migrations/meta/_journal.json@@ -197,6 +197,13 @@"when": 1773150731736,"tag": "0027_tranquil_tenebrous","breakpoints": true+ },+ {+ "idx": 28,+ "version": "7",+ "when": 1773503397855,+ "tag": "0028_bent_eternals",+ "breakpoints": true}]}\ No newline at end of filediff --git a/packages/db/src/schema/company_skills.ts b/packages/db/src/schema/company_skills.tsnew file mode 100644index 0000000000..c3a8ff2c81--- /dev/null+++ b/packages/db/src/schema/company_skills.ts@@ -0,0 +1,35 @@+import {+ pgTable,+ uuid,+ text,+ timestamp,+ jsonb,+ index,+ uniqueIndex,+} from "drizzle-orm/pg-core";+import { companies } from "./companies.js";++export const companySkills = pgTable(+ "company_skills",+ {+ id: uuid("id").primaryKey().defaultRandom(),+ companyId: uuid("company_id").notNull().references(() => companies.id),+ slug: text("slug").notNull(),+ name: text("name").notNull(),+ description: text("description"),+ markdown: text("markdown").notNull(),+ sourceType: text("source_type").notNull().default("local_path"),+ sourceLocator: text("source_locator"),+ sourceRef: text("source_ref"),+ trustLevel: text("trust_level").notNull().default("markdown_only"),+ compatibility: text("compatibility").notNull().default("compatible"),+ fileInventory: jsonb("file_inventory").$type<Array<Record<string, unknown>>>().notNull().default([]),+ metadata: jsonb("metadata").$type<Record<string, unknown>>(),+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),+ },+ (table) => ({+ companySlugUniqueIdx: uniqueIndex("company_skills_company_slug_idx").on(table.companyId, table.slug),+ companyNameIdx: index("company_skills_company_name_idx").on(table.companyId, table.name),+ }),+);diff --git a/packages/db/src/schema/index.ts b/packages/db/src/schema/index.tsindex 3416ea9a04..db34242292 100644--- a/packages/db/src/schema/index.ts+++ b/packages/db/src/schema/index.ts@@ -32,3 +32,4 @@ export { approvalComments } from "./approval_comments.js";export { activityLog } from "./activity_log.js";export { companySecrets } from "./company_secrets.js";export { companySecretVersions } from "./company_secret_versions.js";+export { companySkills } from "./company_skills.js";diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.tsindex 7cd0ae1b1a..f87961f010 100644--- a/packages/shared/src/index.ts+++ b/packages/shared/src/index.ts@@ -65,6 +65,16 @@ export {export type {Company,+ CompanySkillSourceType,+ CompanySkillTrustLevel,+ CompanySkillCompatibility,+ CompanySkillFileInventoryEntry,+ CompanySkill,+ CompanySkillListItem,+ CompanySkillUsageAgent,+ CompanySkillDetail,+ CompanySkillImportRequest,+ CompanySkillImportResult,AgentSkillSyncMode,AgentSkillState,AgentSkillEntry,@@ -238,6 +248,15 @@ export {type ClaimJoinRequestApiKey,type UpdateMemberPermissions,type UpdateUserCompanyAccess,+ companySkillSourceTypeSchema,+ companySkillTrustLevelSchema,+ companySkillCompatibilitySchema,+ companySkillFileInventoryEntrySchema,+ companySkillSchema,+ companySkillListItemSchema,+ companySkillUsageAgentSchema,+ companySkillDetailSchema,+ companySkillImportSchema,portabilityIncludeSchema,portabilityEnvInputSchema,portabilityCompanyManifestEntrySchema,diff --git a/packages/shared/src/types/company-skill.ts b/packages/shared/src/types/company-skill.tsnew file mode 100644index 0000000000..152dc67e94--- /dev/null+++ b/packages/shared/src/types/company-skill.ts@@ -0,0 +1,55 @@+export type CompanySkillSourceType = "local_path" | "github" | "url" | "catalog";++export type CompanySkillTrustLevel = "markdown_only" | "assets" | "scripts_executables";++export type CompanySkillCompatibility = "compatible" | "unknown" | "invalid";++export interface CompanySkillFileInventoryEntry {+ path: string;+ kind: "skill" | "markdown" | "reference" | "script" | "asset" | "other";+}++export interface CompanySkill {+ id: string;+ companyId: string;+ slug: string;+ name: string;+ description: string | null;+ markdown: string;+ sourceType: CompanySkillSourceType;+ sourceLocator: string | null;+ sourceRef: string | null;+ trustLevel: CompanySkillTrustLevel;+ compatibility: CompanySkillCompatibility;+ fileInventory: CompanySkillFileInventoryEntry[];+ metadata: Record<string, unknown> | null;+ createdAt: Date;+ updatedAt: Date;+}++export interface CompanySkillListItem extends CompanySkill {+ attachedAgentCount: number;+}++export interface CompanySkillUsageAgent {+ id: string;+ name: string;+ urlKey: string;+ adapterType: string;+ desired: boolean;+ actualState: string | null;+}++export interface CompanySkillDetail extends CompanySkill {+ attachedAgentCount: number;+ usedByAgents: CompanySkillUsageAgent[];+}++export interface CompanySkillImportRequest {+ source: string;+}++export interface CompanySkillImportResult {+ imported: CompanySkill[];+ warnings: string[];+}diff --git a/packages/shared/src/types/index.ts b/packages/shared/src/types/index.tsindex 40b8995044..84e9864fe4 100644--- a/packages/shared/src/types/index.ts+++ b/packages/shared/src/types/index.ts@@ -1,4 +1,16 @@export type { Company } from "./company.js";+export type {+ CompanySkillSourceType,+ CompanySkillTrustLevel,+ CompanySkillCompatibility,+ CompanySkillFileInventoryEntry,+ CompanySkill,+ CompanySkillListItem,+ CompanySkillUsageAgent,+ CompanySkillDetail,+ CompanySkillImportRequest,+ CompanySkillImportResult,+} from "./company-skill.js";export type {AgentSkillSyncMode,AgentSkillState,diff --git a/packages/shared/src/validators/company-skill.ts b/packages/shared/src/validators/company-skill.tsnew file mode 100644index 0000000000..422d25a0e9--- /dev/null+++ b/packages/shared/src/validators/company-skill.ts@@ -0,0 +1,52 @@+import { z } from "zod";++export const companySkillSourceTypeSchema = z.enum(["local_path", "github", "url", "catalog"]);+export const companySkillTrustLevelSchema = z.enum(["markdown_only", "assets", "scripts_executables"]);+export const companySkillCompatibilitySchema = z.enum(["compatible", "unknown", "invalid"]);++export const companySkillFileInventoryEntrySchema = z.object({+ path: z.string().min(1),+ kind: z.enum(["skill", "markdown", "reference", "script", "asset", "other"]),+});++export const companySkillSchema = z.object({+ id: z.string().uuid(),+ companyId: z.string().uuid(),+ slug: z.string().min(1),+ name: z.string().min(1),+ description: z.string().nullable(),+ markdown: z.string(),+ sourceType: companySkillSourceTypeSchema,+ sourceLocator: z.string().nullable(),+ sourceRef: z.string().nullable(),+ trustLevel: companySkillTrustLevelSchema,+ compatibility: companySkillCompatibilitySchema,+ fileInventory: z.array(companySkillFileInventoryEntrySchema).default([]),+ metadata: z.record(z.unknown()).nullable(),+ createdAt: z.coerce.date(),+ updatedAt: z.coerce.date(),+});++export const companySkillListItemSchema = companySkillSchema.extend({+ attachedAgentCount: z.number().int().nonnegative(),+});++export const companySkillUsageAgentSchema = z.object({+ id: z.string().uuid(),+ name: z.string().min(1),+ urlKey: z.string().min(1),+ adapterType: z.string().min(1),+ desired: z.boolean(),+ actualState: z.string().nullable(),+});++export const companySkillDetailSchema = companySkillSchema.extend({+ attachedAgentCount: z.number().int().nonnegative(),+ usedByAgents: z.array(companySkillUsageAgentSchema).default([]),+});++export const companySkillImportSchema = z.object({+ source: z.string().min(1),+});++export type CompanySkillImport = z.infer<typeof companySkillImportSchema>;diff --git a/packages/shared/src/validators/index.ts b/packages/shared/src/validators/index.tsindex fdbaa9a264..f65256bd84 100644--- a/packages/shared/src/validators/index.ts+++ b/packages/shared/src/validators/index.ts@@ -4,6 +4,18 @@ export {type CreateCompany,type UpdateCompany,} from "./company.js";+export {+ companySkillSourceTypeSchema,+ companySkillTrustLevelSchema,+ companySkillCompatibilitySchema,+ companySkillFileInventoryEntrySchema,+ companySkillSchema,+ companySkillListItemSchema,+ companySkillUsageAgentSchema,+ companySkillDetailSchema,+ companySkillImportSchema,+ type CompanySkillImport,+} from "./company-skill.js";export {agentSkillStateSchema,agentSkillSyncModeSchema,diff --git a/server/src/app.ts b/server/src/app.tsindex 6871552a57..96600e6a40 100644--- a/server/src/app.ts+++ b/server/src/app.ts@@ -11,6 +11,7 @@ import { boardMutationGuard } from "./middleware/board-mutation-guard.js";import { privateHostnameGuard, resolvePrivateHostnameAllowSet } from "./middleware/private-hostname-guard.js";import { healthRoutes } from "./routes/health.js";import { companyRoutes } from "./routes/companies.js";+import { companySkillRoutes } from "./routes/company-skills.js";import { agentRoutes } from "./routes/agents.js";import { projectRoutes } from "./routes/projects.js";import { issueRoutes } from "./routes/issues.js";@@ -103,6 +104,7 @@ export async function createApp(}),);api.use("/companies", companyRoutes(db));+ api.use(companySkillRoutes(db));api.use(agentRoutes(db));api.use(assetRoutes(db, opts.storageService));api.use(projectRoutes(db));diff --git a/server/src/routes/company-skills.ts b/server/src/routes/company-skills.tsnew file mode 100644index 0000000000..5219a97a22--- /dev/null+++ b/server/src/routes/company-skills.ts@@ -0,0 +1,63 @@+import { Router } from "express";+import type { Db } from "@paperclipai/db";+import { companySkillImportSchema } from "@paperclipai/shared";+import { validate } from "../middleware/validate.js";+import { companySkillService, logActivity } from "../services/index.js";+import { assertCompanyAccess, getActorInfo } from "./authz.js";++export function companySkillRoutes(db: Db) {+ const router = Router();+ const svc = companySkillService(db);++ router.get("/companies/:companyId/skills", async (req, res) => {+ const companyId = req.params.companyId as string;+ assertCompanyAccess(req, companyId);+ const result = await svc.list(companyId);+ res.json(result);+ });++ router.get("/companies/:companyId/skills/:skillId", async (req, res) => {+ const companyId = req.params.companyId as string;+ const skillId = req.params.skillId as string;+ assertCompanyAccess(req, companyId);+ const result = await svc.detail(companyId, skillId);+ if (!result) {+ res.status(404).json({ error: "Skill not found" });+ return;+ }+ res.json(result);+ });++ router.post(+ "/companies/:companyId/skills/import",+ validate(companySkillImportSchema),+ async (req, res) => {+ const companyId = req.params.companyId as string;+ assertCompanyAccess(req, companyId);+ const source = String(req.body.source ?? "");+ const result = await svc.importFromSource(companyId, source);++ const actor = getActorInfo(req);+ await logActivity(db, {+ companyId,+ actorType: actor.actorType,+ actorId: actor.actorId,+ agentId: actor.agentId,+ runId: actor.runId,+ action: "company.skills_imported",+ entityType: "company",+ entityId: companyId,+ details: {+ source,+ importedCount: result.imported.length,+ importedSlugs: result.imported.map((skill) => skill.slug),+ warningCount: result.warnings.length,+ },+ });++ res.status(201).json(result);+ },+ );++ return router;+}diff --git a/server/src/routes/index.ts b/server/src/routes/index.tsindex c509d54462..b214763585 100644--- a/server/src/routes/index.ts+++ b/server/src/routes/index.ts@@ -1,5 +1,6 @@export { healthRoutes } from "./health.js";export { companyRoutes } from "./companies.js";+export { companySkillRoutes } from "./company-skills.js";export { agentRoutes } from "./agents.js";export { projectRoutes } from "./projects.js";export { issueRoutes } from "./issues.js";diff --git a/server/src/services/company-skills.ts b/server/src/services/company-skills.tsnew file mode 100644index 0000000000..cdd7a0e03a--- /dev/null+++ b/server/src/services/company-skills.ts@@ -0,0 +1,621 @@+import { promises as fs } from "node:fs";+import path from "node:path";+import { and, asc, eq } from "drizzle-orm";+import type { Db } from "@paperclipai/db";+import { companySkills } from "@paperclipai/db";+import type {+ CompanySkill,+ CompanySkillCompatibility,+ CompanySkillDetail,+ CompanySkillFileInventoryEntry,+ CompanySkillImportResult,+ CompanySkillListItem,+ CompanySkillSourceType,+ CompanySkillTrustLevel,+ CompanySkillUsageAgent,+} from "@paperclipai/shared";+import { normalizeAgentUrlKey } from "@paperclipai/shared";+import { readPaperclipSkillSyncPreference } from "@paperclipai/adapter-utils/server-utils";+import { findServerAdapter } from "../adapters/index.js";+import { notFound, unprocessable } from "../errors.js";+import { agentService } from "./agents.js";+import { secretService } from "./secrets.js";++type CompanySkillRow = typeof companySkills.$inferSelect;++type ImportedSkill = {+ slug: string;+ name: string;+ description: string | null;+ markdown: string;+ sourceType: CompanySkillSourceType;+ sourceLocator: string | null;+ sourceRef: string | null;+ trustLevel: CompanySkillTrustLevel;+ compatibility: CompanySkillCompatibility;+ fileInventory: CompanySkillFileInventoryEntry[];+ metadata: Record<string, unknown> | null;+};++function asString(value: unknown): string | null {+ if (typeof value !== "string") return null;+ const trimmed = value.trim();+ return trimmed.length > 0 ? trimmed : null;+}++function isPlainRecord(value: unknown): value is Record<string, unknown> {+ return typeof value === "object" && value !== null && !Array.isArray(value);+}++function normalizePortablePath(input: string) {+ return input.replace(/\\/g, "/").replace(/^\.\/+/, "").replace(/^\/+/, "");+}++function classifyInventoryKind(relativePath: string): CompanySkillFileInventoryEntry["kind"] {+ const normalized = normalizePortablePath(relativePath).toLowerCase();+ if (normalized.endsWith("/skill.md") || normalized === "skill.md") return "skill";+ if (normalized.startsWith("references/")) return "reference";+ if (normalized.startsWith("scripts/")) return "script";+ if (normalized.startsWith("assets/")) return "asset";+ if (normalized.endsWith(".md")) return "markdown";+ const fileName = path.posix.basename(normalized);+ if (+ fileName.endsWith(".sh")+ || fileName.endsWith(".js")+ || fileName.endsWith(".mjs")+ || fileName.endsWith(".cjs")+ || fileName.endsWith(".ts")+ || fileName.endsWith(".py")+ || fileName.endsWith(".rb")+ || fileName.endsWith(".bash")+ ) {+ return "script";+ }+ if (+ fileName.endsWith(".png")+ || fileName.endsWith(".jpg")+ || fileName.endsWith(".jpeg")+ || fileName.endsWith(".gif")+ || fileName.endsWith(".svg")+ || fileName.endsWith(".webp")+ || fileName.endsWith(".pdf")+ ) {+ return "asset";+ }+ return "other";+}++function deriveTrustLevel(fileInventory: CompanySkillFileInventoryEntry[]): CompanySkillTrustLevel {+ if (fileInventory.some((entry) => entry.kind === "script")) return "scripts_executables";+ if (fileInventory.some((entry) => entry.kind === "asset" || entry.kind === "other")) return "assets";+ return "markdown_only";+}++function prepareYamlLines(raw: string) {+ return raw+ .split("\n")+ .map((line) => ({+ indent: line.match(/^ */)?.[0].length ?? 0,+ content: line.trim(),+ }))+ .filter((line) => line.content.length > 0 && !line.content.startsWith("#"));+}++function parseYamlScalar(rawValue: string): unknown {+ const trimmed = rawValue.trim();+ if (trimmed === "") return "";+ if (trimmed === "null" || trimmed === "~") return null;+ if (trimmed === "true") return true;+ if (trimmed === "false") return false;+ if (trimmed === "[]") return [];+ if (trimmed === "{}") return {};+ if (/^-?\d+(\.\d+)?$/.test(trimmed)) return Number(trimmed);+ if (trimmed.startsWith("\"") || trimmed.startsWith("[") || trimmed.startsWith("{")) {+ try {+ return JSON.parse(trimmed);+ } catch {+ return trimmed;+ }+ }+ return trimmed;+}++function parseYamlBlock(+ lines: Array<{ indent: number; content: string }>,+ startIndex: number,+ indentLevel: number,+): { value: unknown; nextIndex: number } {+ let index = startIndex;+ while (index < lines.length && lines[index]!.content.length === 0) index += 1;+ if (index >= lines.length || lines[index]!.indent < indentLevel) {+ return { value: {}, nextIndex: index };+ }++ const isArray = lines[index]!.indent === indentLevel && lines[index]!.content.startsWith("-");+ if (isArray) {+ const values: unknown[] = [];+ while (index < lines.length) {+ const line = lines[index]!;+ if (line.indent < indentLevel) break;+ if (line.indent !== indentLevel || !line.content.startsWith("-")) break;+ const remainder = line.content.slice(1).trim();+ index += 1;+ if (!remainder) {+ const nested = parseYamlBlock(lines, index, indentLevel + 2);+ values.push(nested.value);+ index = nested.nextIndex;+ continue;+ }+ values.push(parseYamlScalar(remainder));+ }+ return { value: values, nextIndex: index };+ }++ const record: Record<string, unknown> = {};+ while (index < lines.length) {+ const line = lines[index]!;+ if (line.indent < indentLevel) break;+ if (line.indent !== indentLevel) {+ index += 1;+ continue;+ }+ const separatorIndex = line.content.indexOf(":");+ if (separatorIndex <= 0) {+ index += 1;+ continue;+ }+ const key = line.content.slice(0, separatorIndex).trim();+ const remainder = line.content.slice(separatorIndex + 1).trim();+ index += 1;+ if (!remainder) {+ const nested = parseYamlBlock(lines, index, indentLevel + 2);+ record[key] = nested.value;+ index = nested.nextIndex;+ continue;+ }+ record[key] = parseYamlScalar(remainder);+ }+ return { value: record, nextIndex: index };+}++function parseYamlFrontmatter(raw: string): Record<string, unknown> {+ const prepared = prepareYamlLines(raw);+ if (prepared.length === 0) return {};+ const parsed = parseYamlBlock(prepared, 0, prepared[0]!.indent);+ return isPlainRecord(parsed.value) ? parsed.value : {};+}++function parseFrontmatterMarkdown(raw: string): { frontmatter: Record<string, unknown>; body: string } {+ const normalized = raw.replace(/\r\n/g, "\n");+ if (!normalized.startsWith("---\n")) {+ return { frontmatter: {}, body: normalized.trim() };+ }+ const closing = normalized.indexOf("\n---\n", 4);+ if (closing < 0) {+ return { frontmatter: {}, body: normalized.trim() };+ }+ const frontmatterRaw = normalized.slice(4, closing).trim();+ const body = normalized.slice(closing + 5).trim();+ return {+ frontmatter: parseYamlFrontmatter(frontmatterRaw),+ body,+ };+}++async function fetchText(url: string) {+ const response = await fetch(url);+ if (!response.ok) {+ throw unprocessable(`Failed to fetch ${url}: ${response.status}`);+ }+ return response.text();+}++async function fetchJson<T>(url: string): Promise<T> {+ const response = await fetch(url, {+ headers: {+ accept: "application/vnd.github+json",+ },+ });+ if (!response.ok) {+ throw unprocessable(`Failed to fetch ${url}: ${response.status}`);+ }+ return response.json() as Promise<T>;+}++function parseGitHubSourceUrl(rawUrl: string) {+ const url = new URL(rawUrl);+ if (url.hostname !== "github.com") {+ throw unprocessable("GitHub source must use github.com URL");+ }+ const parts = url.pathname.split("/").filter(Boolean);+ if (parts.length < 2) {+ throw unprocessable("Invalid GitHub URL");+ }+ const owner = parts[0]!;+ const repo = parts[1]!.replace(/\.git$/i, "");+ let ref = "main";+ let basePath = "";+ let filePath: string | null = null;+ if (parts[2] === "tree") {+ ref = parts[3] ?? "main";+ basePath = parts.slice(4).join("/");+ } else if (parts[2] === "blob") {+ ref = parts[3] ?? "main";+ filePath = parts.slice(4).join("/");+ basePath = filePath ? path.posix.dirname(filePath) : "";+ }+ return { owner, repo, ref, basePath, filePath };+}++function resolveRawGitHubUrl(owner: string, repo: string, ref: string, filePath: string) {+ return `https://raw.githubusercontent.com/${owner}/${repo}/${ref}/${filePath.replace(/^\/+/, "")}`;+}++async function walkLocalFiles(root: string, current: string, out: string[]) {+ const entries = await fs.readdir(current, { withFileTypes: true });+ for (const entry of entries) {+ if (entry.name === ".git" || entry.name === "node_modules") continue;+ const absolutePath = path.join(current, entry.name);+ if (entry.isDirectory()) {+ await walkLocalFiles(root, absolutePath, out);+ continue;+ }+ if (!entry.isFile()) continue;+ out.push(normalizePortablePath(path.relative(root, absolutePath)));+ }+}++async function readLocalSkillImports(sourcePath: string): Promise<ImportedSkill[]> {+ const resolvedPath = path.resolve(sourcePath);+ const stat = await fs.stat(resolvedPath).catch(() => null);+ if (!stat) {+ throw unprocessable(`Skill source path does not exist: ${sourcePath}`);+ }++ if (stat.isFile()) {+ const markdown = await fs.readFile(resolvedPath, "utf8");+ const parsed = parseFrontmatterMarkdown(markdown);+ const slug = normalizeAgentUrlKey(path.basename(path.dirname(resolvedPath))) ?? "skill";+ const inventory: CompanySkillFileInventoryEntry[] = [+ { path: "SKILL.md", kind: "skill" },+ ];+ return [{+ slug,+ name: asString(parsed.frontmatter.name) ?? slug,+ description: asString(parsed.frontmatter.description),+ markdown,+ sourceType: "local_path",+ sourceLocator: resolvedPath,+ sourceRef: null,+ trustLevel: deriveTrustLevel(inventory),+ compatibility: "compatible",+ fileInventory: inventory,+ metadata: null,+ }];+ }++ const root = resolvedPath;+ const allFiles: string[] = [];+ await walkLocalFiles(root, root, allFiles);+ const skillPaths = allFiles.filter((entry) => path.posix.basename(entry).toLowerCase() === "skill.md");+ if (skillPaths.length === 0) {+ throw unprocessable("No SKILL.md files were found in the provided path.");+ }++ const imports: ImportedSkill[] = [];+ for (const skillPath of skillPaths) {+ const skillDir = path.posix.dirname(skillPath);+ const markdown = await fs.readFile(path.join(root, skillPath), "utf8");+ const parsed = parseFrontmatterMarkdown(markdown);+ const slug = normalizeAgentUrlKey(path.posix.basename(skillDir)) ?? "skill";+ const inventory = allFiles+ .filter((entry) => entry === skillPath || entry.startsWith(`${skillDir}/`))+ .map((entry) => {+ const relative = entry === skillPath ? "SKILL.md" : entry.slice(skillDir.length + 1);+ return {+ path: normalizePortablePath(relative),+ kind: classifyInventoryKind(relative),+ };+ })+ .sort((left, right) => left.path.localeCompare(right.path));+ imports.push({+ slug,+ name: asString(parsed.frontmatter.name) ?? slug,+ description: asString(parsed.frontmatter.description),+ markdown,+ sourceType: "local_path",+ sourceLocator: resolvedPath,+ sourceRef: null,+ trustLevel: deriveTrustLevel(inventory),+ compatibility: "compatible",+ fileInventory: inventory,+ metadata: null,+ });+ }++ return imports;+}++async function readUrlSkillImports(sourceUrl: string): Promise<{ skills: ImportedSkill[]; warnings: string[] }> {+ const url = sourceUrl.trim();+ const warnings: string[] = [];+ if (url.includes("github.com/")) {+ const parsed = parseGitHubSourceUrl(url);+ let ref = parsed.ref;+ if (!/^[0-9a-f]{40}$/i.test(ref.trim())) {+ warnings.push("GitHub skill source is not pinned to a commit SHA; imports may drift if the ref changes.");+ }+ const tree = await fetchJson<{ tree?: Array<{ path: string; type: string }> }>(+ `https://api.github.com/repos/${parsed.owner}/${parsed.repo}/git/trees/${ref}?recursive=1`,+ ).catch(async () => {+ if (ref === "main") {+ ref = "master";+ warnings.push("GitHub ref main not found; falling back to master.");+ return fetchJson<{ tree?: Array<{ path: string; type: string }> }>(+ `https://api.github.com/repos/${parsed.owner}/${parsed.repo}/git/trees/${ref}?recursive=1`,+ );+ }+ throw unprocessable(`Failed to read GitHub tree for ${url}`);+ });+ const allPaths = (tree.tree ?? [])+ .filter((entry) => entry.type === "blob")+ .map((entry) => entry.path)+ .filter((entry): entry is string => typeof entry === "string");+ const basePrefix = parsed.basePath ? `${parsed.basePath.replace(/^\/+|\/+$/g, "")}/` : "";+ const scopedPaths = basePrefix+ ? allPaths.filter((entry) => entry.startsWith(basePrefix))+ : allPaths;+ const relativePaths = scopedPaths.map((entry) => basePrefix ? entry.slice(basePrefix.length) : entry);+ const filteredPaths = parsed.filePath+ ? relativePaths.filter((entry) => entry === path.posix.relative(parsed.basePath || ".", parsed.filePath!))+ : relativePaths;+ const skillPaths = filteredPaths.filter((entry) => path.posix.basename(entry).toLowerCase() === "skill.md");+ if (skillPaths.length === 0) {+ throw unprocessable("No SKILL.md files were found in the provided GitHub source.");+ }+ const skills: ImportedSkill[] = [];+ for (const relativeSkillPath of skillPaths) {+ const repoSkillPath = basePrefix ? `${basePrefix}${relativeSkillPath}` : relativeSkillPath;+ const markdown = await fetchText(resolveRawGitHubUrl(parsed.owner, parsed.repo, ref, repoSkillPath));+ const parsedMarkdown = parseFrontmatterMarkdown(markdown);+ const skillDir = path.posix.dirname(relativeSkillPath);+ const slug = normalizeAgentUrlKey(path.posix.basename(skillDir)) ?? "skill";+ const inventory = filteredPaths+ .filter((entry) => entry === relativeSkillPath || entry.startsWith(`${skillDir}/`))+ .map((entry) => ({+ path: entry === relativeSkillPath ? "SKILL.md" : entry.slice(skillDir.length + 1),+ kind: classifyInventoryKind(entry === relativeSkillPath ? "SKILL.md" : entry.slice(skillDir.length + 1)),+ }))+ .sort((left, right) => left.path.localeCompare(right.path));+ skills.push({+ slug,+ name: asString(parsedMarkdown.frontmatter.name) ?? slug,+ description: asString(parsedMarkdown.frontmatter.description),+ markdown,+ sourceType: "github",+ sourceLocator: sourceUrl,+ sourceRef: ref,+ trustLevel: deriveTrustLevel(inventory),+ compatibility: "compatible",+ fileInventory: inventory,+ metadata: null,+ });+ }+ return { skills, warnings };+ }++ if (url.startsWith("http://") || url.startsWith("https://")) {+ const markdown = await fetchText(url);+ const parsedMarkdown = parseFrontmatterMarkdown(markdown);+ const urlObj = new URL(url);+ const fileName = path.posix.basename(urlObj.pathname);+ const slug = normalizeAgentUrlKey(fileName.replace(/\.md$/i, "")) ?? "skill";+ const inventory: CompanySkillFileInventoryEntry[] = [{ path: "SKILL.md", kind: "skill" }];+ return {+ skills: [{+ slug,+ name: asString(parsedMarkdown.frontmatter.name) ?? slug,+ description: asString(parsedMarkdown.frontmatter.description),+ markdown,+ sourceType: "url",+ sourceLocator: url,+ sourceRef: null,+ trustLevel: deriveTrustLevel(inventory),+ compatibility: "compatible",+ fileInventory: inventory,+ metadata: null,+ }],+ warnings,+ };+ }++ throw unprocessable("Unsupported skill source. Use a local path or URL.");+}++function toCompanySkill(row: CompanySkillRow): CompanySkill {+ return {+ ...row,+ description: row.description ?? null,+ sourceType: row.sourceType as CompanySkillSourceType,+ sourceLocator: row.sourceLocator ?? null,+ sourceRef: row.sourceRef ?? null,+ trustLevel: row.trustLevel as CompanySkillTrustLevel,+ compatibility: row.compatibility as CompanySkillCompatibility,+ fileInventory: Array.isArray(row.fileInventory)+ ? row.fileInventory.flatMap((entry) => {+ if (!isPlainRecord(entry)) return [];+ return [{+ path: String(entry.path ?? ""),+ kind: (String(entry.kind ?? "other") as CompanySkillFileInventoryEntry["kind"]),+ }];+ })+ : [],+ metadata: isPlainRecord(row.metadata) ? row.metadata : null,+ };+}++function serializeFileInventory(+ fileInventory: CompanySkillFileInventoryEntry[],+): Array<Record<string, unknown>> {+ return fileInventory.map((entry) => ({+ path: entry.path,+ kind: entry.kind,+ }));+}++export function companySkillService(db: Db) {+ const agents = agentService(db);+ const secretsSvc = secretService(db);++ async function list(companyId: string): Promise<CompanySkillListItem[]> {+ const rows = await db+ .select()+ .from(companySkills)+ .where(eq(companySkills.companyId, companyId))+ .orderBy(asc(companySkills.name), asc(companySkills.slug));+ const agentRows = await agents.list(companyId);+ return rows.map((row) => {+ const skill = toCompanySkill(row);+ const attachedAgentCount = agentRows.filter((agent) => {+ const preference = readPaperclipSkillSyncPreference(agent.adapterConfig as Record<string, unknown>);+ return preference.desiredSkills.includes(skill.slug);+ }).length;+ return {+ ...skill,+ attachedAgentCount,+ };+ });+ }++ async function getById(id: string) {+ const row = await db+ .select()+ .from(companySkills)+ .where(eq(companySkills.id, id))+ .then((rows) => rows[0] ?? null);+ return row ? toCompanySkill(row) : null;+ }++ async function getBySlug(companyId: string, slug: string) {+ const row = await db+ .select()+ .from(companySkills)+ .where(and(eq(companySkills.companyId, companyId), eq(companySkills.slug, slug)))+ .then((rows) => rows[0] ?? null);+ return row ? toCompanySkill(row) : null;+ }++ async function usage(companyId: string, slug: string): Promise<CompanySkillUsageAgent[]> {+ const agentRows = await agents.list(companyId);+ const desiredAgents = agentRows.filter((agent) => {+ const preference = readPaperclipSkillSyncPreference(agent.adapterConfig as Record<string, unknown>);+ return preference.desiredSkills.includes(slug);+ });++ return Promise.all(+ desiredAgents.map(async (agent) => {+ const adapter = findServerAdapter(agent.adapterType);+ let actualState: string | null = null;++ if (!adapter?.listSkills) {+ actualState = "unsupported";+ } else {+ try {+ const { config: runtimeConfig } = await secretsSvc.resolveAdapterConfigForRuntime(+ agent.companyId,+ agent.adapterConfig as Record<string, unknown>,+ );+ const snapshot = await adapter.listSkills({+ agentId: agent.id,+ companyId: agent.companyId,+ adapterType: agent.adapterType,+ config: runtimeConfig,+ });+ actualState = snapshot.entries.find((entry) => entry.name === slug)?.state+ ?? (snapshot.supported ? "missing" : "unsupported");+ } catch {+ actualState = "unknown";+ }+ }++ return {+ id: agent.id,+ name: agent.name,+ urlKey: agent.urlKey,+ adapterType: agent.adapterType,+ desired: true,+ actualState,+ };+ }),+ );+ }++ async function detail(companyId: string, id: string): Promise<CompanySkillDetail | null> {+ const skill = await getById(id);+ if (!skill || skill.companyId !== companyId) return null;+ const usedByAgents = await usage(companyId, skill.slug);+ return {+ ...skill,+ attachedAgentCount: usedByAgents.length,+ usedByAgents,+ };+ }++ async function upsertImportedSkills(companyId: string, imported: ImportedSkill[]): Promise<CompanySkill[]> {+ const out: CompanySkill[] = [];+ for (const skill of imported) {+ const existing = await getBySlug(companyId, skill.slug);+ const values = {+ companyId,+ slug: skill.slug,+ name: skill.name,+ description: skill.description,+ markdown: skill.markdown,+ sourceType: skill.sourceType,+ sourceLocator: skill.sourceLocator,+ sourceRef: skill.sourceRef,+ trustLevel: skill.trustLevel,+ compatibility: skill.compatibility,+ fileInventory: serializeFileInventory(skill.fileInventory),+ metadata: skill.metadata,+ updatedAt: new Date(),+ };+ const row = existing+ ? await db+ .update(companySkills)+ .set(values)+ .where(eq(companySkills.id, existing.id))+ .returning()+ .then((rows) => rows[0] ?? null)+ : await db+ .insert(companySkills)+ .values(values)+ .returning()+ .then((rows) => rows[0] ?? null);+ if (!row) throw notFound("Failed to persist company skill");+ out.push(toCompanySkill(row));+ }+ return out;+ }++ async function importFromSource(companyId: string, source: string): Promise<CompanySkillImportResult> {+ const trimmed = source.trim();+ if (!trimmed) {+ throw unprocessable("Skill source is required.");+ }+ const local = !/^https?:\/\//i.test(trimmed);+ const { skills, warnings } = local+ ? { skills: await readLocalSkillImports(trimmed), warnings: [] as string[] }+ : await readUrlSkillImports(trimmed);+ const imported = await upsertImportedSkills(companyId, skills);+ return { imported, warnings };+ }++ return {+ list,+ getById,+ getBySlug,+ detail,+ importFromSource,+ };+}diff --git a/server/src/services/index.ts b/server/src/services/index.tsindex 99a950c543..9be0eb2305 100644--- a/server/src/services/index.ts+++ b/server/src/services/index.ts@@ -1,4 +1,5 @@export { companyService } from "./companies.js";+export { companySkillService } from "./company-skills.js";export { agentService, deduplicateAgentName } from "./agents.js";export { assetService } from "./assets.js";export { projectService } from "./projects.js";diff --git a/ui/src/App.tsx b/ui/src/App.tsxindex 1cfdd9dfdd..be6e467de2 100644--- a/ui/src/App.tsx+++ b/ui/src/App.tsx@@ -22,6 +22,7 @@ import { Costs } from "./pages/Costs";import { Activity } from "./pages/Activity";import { Inbox } from "./pages/Inbox";import { CompanySettings } from "./pages/CompanySettings";+import { CompanySkills } from "./pages/CompanySkills";import { DesignGuide } from "./pages/DesignGuide";import { InstanceSettings } from "./pages/InstanceSettings";import { RunTranscriptUxLab } from "./pages/RunTranscriptUxLab";@@ -111,6 +112,8 @@ function boardRoutes() {<Route path="onboarding" element={<OnboardingRoutePage />} /><Route path="companies" element={<Companies />} /><Route path="company/settings" element={<CompanySettings />} />+ <Route path="skills" element={<CompanySkills />} />+ <Route path="skills/:skillId" element={<CompanySkills />} /><Route path="settings" element={<LegacySettingsRedirect />} /><Route path="settings/*" element={<LegacySettingsRedirect />} /><Route path="org" element={<OrgChart />} />@@ -302,6 +305,8 @@ export function App() {<Route path="companies" element={<UnprefixedBoardRedirect />} /><Route path="issues" element={<UnprefixedBoardRedirect />} /><Route path="issues/:issueId" element={<UnprefixedBoardRedirect />} />+ <Route path="skills" element={<UnprefixedBoardRedirect />} />+ <Route path="skills/:skillId" element={<UnprefixedBoardRedirect />} /><Route path="settings" element={<LegacySettingsRedirect />} /><Route path="settings/*" element={<LegacySettingsRedirect />} /><Route path="agents" element={<UnprefixedBoardRedirect />} />diff --git a/ui/src/api/companySkills.ts b/ui/src/api/companySkills.tsnew file mode 100644index 0000000000..f29896a1c4--- /dev/null+++ b/ui/src/api/companySkills.ts@@ -0,0 +1,20 @@+import type {+ CompanySkillDetail,+ CompanySkillImportResult,+ CompanySkillListItem,+} from "@paperclipai/shared";+import { api } from "./client";++export const companySkillsApi = {+ list: (companyId: string) =>+ api.get<CompanySkillListItem[]>(`/companies/${encodeURIComponent(companyId)}/skills`),+ detail: (companyId: string, skillId: string) =>+ api.get<CompanySkillDetail>(+ `/companies/${encodeURIComponent(companyId)}/skills/${encodeURIComponent(skillId)}`,+ ),+ importFromSource: (companyId: string, source: string) =>+ api.post<CompanySkillImportResult>(+ `/companies/${encodeURIComponent(companyId)}/skills/import`,+ { source },+ ),+};diff --git a/ui/src/api/index.ts b/ui/src/api/index.tsindex 8c95c24671..35e799bc0d 100644--- a/ui/src/api/index.ts+++ b/ui/src/api/index.ts@@ -13,3 +13,4 @@ export { activityApi } from "./activity";export { dashboardApi } from "./dashboard";export { heartbeatsApi } from "./heartbeats";export { sidebarBadgesApi } from "./sidebarBadges";+export { companySkillsApi } from "./companySkills";diff --git a/ui/src/components/Sidebar.tsx b/ui/src/components/Sidebar.tsxindex 0cc46d8755..34396caef0 100644--- a/ui/src/components/Sidebar.tsx+++ b/ui/src/components/Sidebar.tsx@@ -8,6 +8,7 @@ import {Search,SquarePen,Network,+ Boxes,Settings,} from "lucide-react";import { useQuery } from "@tanstack/react-query";@@ -93,6 +94,7 @@ export function Sidebar() {<SidebarSection label="Company"><SidebarNavItem to="/org" label="Org" icon={Network} />+ <SidebarNavItem to="/skills" label="Skills" icon={Boxes} /><SidebarNavItem to="/costs" label="Costs" icon={DollarSign} /><SidebarNavItem to="/activity" label="Activity" icon={History} /><SidebarNavItem to="/company/settings" label="Settings" icon={Settings} />diff --git a/ui/src/lib/queryKeys.ts b/ui/src/lib/queryKeys.tsindex b1da418dd9..dda0e6942c 100644--- a/ui/src/lib/queryKeys.ts+++ b/ui/src/lib/queryKeys.ts@@ -4,6 +4,10 @@ export const queryKeys = {detail: (id: string) => ["companies", id] as const,stats: ["companies", "stats"] as const,},+ companySkills: {+ list: (companyId: string) => ["company-skills", companyId] as const,+ detail: (companyId: string, skillId: string) => ["company-skills", companyId, skillId] as const,+ },agents: {list: (companyId: string) => ["agents", companyId] as const,detail: (id: string) => ["agents", "detail", id] as const,diff --git a/ui/src/pages/AgentDetail.tsx b/ui/src/pages/AgentDetail.tsxindex f2086ee8e9..7c2014673f 100644--- a/ui/src/pages/AgentDetail.tsx+++ b/ui/src/pages/AgentDetail.tsx@@ -2,6 +2,7 @@ import { useCallback, useEffect, useMemo, useState, useRef } from "react";import { useParams, useNavigate, Link, Navigate, useBeforeUnload } from "@/lib/router";import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";import { agentsApi, type AgentKey, type ClaudeLoginResult } from "../api/agents";+import { companySkillsApi } from "../api/companySkills";import { heartbeatsApi } from "../api/heartbeats";import { ApiError } from "../api/client";import { ChartCard, RunActivityChart, PriorityChart, IssueStatusChart, SuccessRateChart } from "../components/ActivityCharts";@@ -175,10 +176,11 @@ function scrollToContainerBottom(container: ScrollContainer, behavior: ScrollBehcontainer.scrollTo({ top: container.scrollHeight, behavior });}-type AgentDetailView = "dashboard" | "configuration" | "runs";+type AgentDetailView = "dashboard" | "configuration" | "skills" | "runs";function parseAgentDetailView(value: string | null): AgentDetailView {if (value === "configure" || value === "configuration") return "configuration";+ if (value === "skills") return "skills";if (value === "runs") return value;return "dashboard";}@@ -315,6 +317,8 @@ export function AgentDetail() {const canonicalTab =activeView === "configuration"? "configuration"+ : activeView === "skills"+ ? "skills": activeView === "runs"? "runs": "dashboard";@@ -414,6 +418,8 @@ export function AgentDetail() {crumbs.push({ label: `Run ${urlRunId.slice(0, 8)}` });} else if (activeView === "configuration") {crumbs.push({ label: "Configuration" });+ } else if (activeView === "skills") {+ crumbs.push({ label: "Skills" });} else if (activeView === "runs") {crumbs.push({ label: "Runs" });} else {@@ -571,6 +577,7 @@ export function AgentDetail() {items={[{ value: "dashboard", label: "Dashboard" },{ value: "configuration", label: "Configuration" },+ { value: "skills", label: "Skills" },{ value: "runs", label: "Runs" },]}value={activeView}@@ -667,6 +674,13 @@ export function AgentDetail() {/>)}+ {activeView === "skills" && (+ <AgentSkillsTab+ agent={agent}+ companyId={resolvedCompanyId ?? undefined}+ />+ )}+{activeView === "runs" && (<RunsTabruns={heartbeats ?? []}@@ -1045,8 +1059,6 @@ function ConfigurationTab({}) {const queryClient = useQueryClient();const [awaitingRefreshAfterSave, setAwaitingRefreshAfterSave] = useState(false);- const [skillDraft, setSkillDraft] = useState<string[]>([]);- const [skillDirty, setSkillDirty] = useState(false);const lastAgentRef = useRef(agent);const { data: adapterModels } = useQuery({@@ -1058,12 +1070,6 @@ function ConfigurationTab({enabled: Boolean(companyId),});- const { data: skillSnapshot } = useQuery({- queryKey: queryKeys.agents.skills(agent.id),- queryFn: () => agentsApi.skills(agent.id, companyId),- enabled: Boolean(companyId),- });-const updateAgent = useMutation({mutationFn: (data: Record<string, unknown>) => agentsApi.update(agent.id, data, companyId),onMutate: () => {@@ -1079,30 +1085,12 @@ function ConfigurationTab({},});- const syncSkills = useMutation({- mutationFn: (desiredSkills: string[]) => agentsApi.syncSkills(agent.id, desiredSkills, companyId),- onSuccess: (snapshot) => {- queryClient.invalidateQueries({ queryKey: queryKeys.agents.detail(agent.id) });- queryClient.invalidateQueries({ queryKey: queryKeys.agents.detail(agent.urlKey) });- queryClient.invalidateQueries({ queryKey: queryKeys.agents.skills(agent.id) });- setSkillDraft(snapshot.desiredSkills);- setSkillDirty(false);- },- });-useEffect(() => {if (awaitingRefreshAfterSave && agent !== lastAgentRef.current) {setAwaitingRefreshAfterSave(false);}lastAgentRef.current = agent;}, [agent, awaitingRefreshAfterSave]);-- useEffect(() => {- if (!skillSnapshot) return;- setSkillDraft(skillSnapshot.desiredSkills);- setSkillDirty(false);- }, [skillSnapshot]);-const isConfigSaving = updateAgent.isPending || awaitingRefreshAfterSave;useEffect(() => {@@ -1143,53 +1131,300 @@ function ConfigurationTab({</div></div></div>+ </div>+ );+}- <div>- <h3 className="text-sm font-medium mb-3">Skills</h3>- <div className="border border-border rounded-lg p-4 space-y-3">- {!skillSnapshot ? (- <p className="text-sm text-muted-foreground">Loading skill sync state…</p>- ) : !skillSnapshot.supported ? (- <div className="space-y-2">- <p className="text-sm text-muted-foreground">- This adapter does not implement skill sync yet.- </p>+function AgentSkillsTab({+ agent,+ companyId,+}: {+ agent: Agent;+ companyId?: string;+}) {+ const queryClient = useQueryClient();+ const [skillDraft, setSkillDraft] = useState<string[]>([]);+ const [skillDirty, setSkillDirty] = useState(false);++ const { data: skillSnapshot, isLoading } = useQuery({+ queryKey: queryKeys.agents.skills(agent.id),+ queryFn: () => agentsApi.skills(agent.id, companyId),+ enabled: Boolean(companyId),+ });++ const { data: companySkills } = useQuery({+ queryKey: queryKeys.companySkills.list(companyId ?? ""),+ queryFn: () => companySkillsApi.list(companyId!),+ enabled: Boolean(companyId),+ });++ useEffect(() => {+ if (!skillSnapshot) return;+ setSkillDraft(skillSnapshot.desiredSkills);+ setSkillDirty(false);+ }, [skillSnapshot]);++ const syncSkills = useMutation({+ mutationFn: (desiredSkills: string[]) => agentsApi.syncSkills(agent.id, desiredSkills, companyId),+ onSuccess: async (snapshot) => {+ await Promise.all([+ queryClient.invalidateQueries({ queryKey: queryKeys.agents.detail(agent.id) }),+ queryClient.invalidateQueries({ queryKey: queryKeys.agents.detail(agent.urlKey) }),+ queryClient.invalidateQueries({ queryKey: queryKeys.agents.skills(agent.id) }),+ companyId+ ? queryClient.invalidateQueries({ queryKey: queryKeys.companySkills.list(companyId) })+ : Promise.resolve(),+ ]);+ setSkillDraft(snapshot.desiredSkills);+ setSkillDirty(false);+ },+ });++ const companySkillBySlug = useMemo(+ () => new Map((companySkills ?? []).map((skill) => [skill.slug, skill])),+ [companySkills],+ );+ const adapterEntryByName = useMemo(+ () => new Map((skillSnapshot?.entries ?? []).map((entry) => [entry.name, entry])),+ [skillSnapshot],+ );+ const desiredOnlyMissingSkills = useMemo(+ () => skillDraft.filter((slug) => !companySkillBySlug.has(slug)),+ [companySkillBySlug, skillDraft],+ );+ const externalEntries = (skillSnapshot?.entries ?? []).filter((entry) => entry.state === "external");++ const modeCopy = useMemo(() => {+ if (!skillSnapshot) return "Loading skill state...";+ if (!skillSnapshot.supported) {+ return "This adapter does not implement direct skill sync yet. Paperclip can still store the desired skill set for this agent.";+ }+ if (skillSnapshot.mode === "persistent") {+ return "Selected skills are synchronized into the adapter's persistent skills home.";+ }+ if (skillSnapshot.mode === "ephemeral") {+ return "Selected skills are mounted for each run instead of being installed globally.";+ }+ return "This adapter reports skill state but does not define a persistent install model.";+ }, [skillSnapshot]);++ const primaryActionLabel = !skillSnapshot || skillSnapshot.supported+ ? "Sync skills"+ : "Save desired skills";++ return (+ <div className="max-w-5xl space-y-6">+ <section className="overflow-hidden rounded-2xl border border-border bg-card">+ <div className="border-b border-border bg-[linear-gradient(135deg,rgba(14,165,233,0.08),transparent_45%),linear-gradient(315deg,rgba(16,185,129,0.08),transparent_45%)] px-5 py-5">+ <div className="flex flex-col gap-4 lg:flex-row lg:items-end lg:justify-between">+ <div className="max-w-2xl">+ <div className="mb-2 inline-flex items-center gap-2 rounded-full border border-border/70 bg-background/70 px-3 py-1 text-[11px] uppercase tracking-[0.18em] text-muted-foreground">+ Skills+ </div>+ <h3 className="text-2xl font-semibold tracking-tight">Attach reusable skills to {agent.name}.</h3>+ <p className="mt-2 text-sm text-muted-foreground">{modeCopy}</p>+ </div>+ <div className="flex flex-wrap items-center gap-2">+ <Link+ to="/skills"+ className="inline-flex items-center gap-1 rounded-md border border-border px-3 py-2 text-sm font-medium text-foreground no-underline transition-colors hover:bg-accent/40"+ >+ Open company library+ <ArrowLeft className="h-3.5 w-3.5 rotate-180" />+ </Link>+ <Button+ size="sm"+ onClick={() => queryClient.invalidateQueries({ queryKey: queryKeys.agents.skills(agent.id) })}+ disabled={isLoading}+ variant="outline"+ >+ Refresh state+ </Button>+ </div>+ </div>+ </div>++ <div className="space-y-4 px-5 py-5">+ {skillSnapshot?.warnings.length ? (+ <div className="space-y-1 rounded-xl border border-amber-300/60 bg-amber-50/60 px-4 py-3 text-sm text-amber-800 dark:border-amber-500/30 dark:bg-amber-950/20 dark:text-amber-200">{skillSnapshot.warnings.map((warning) => (- <p key={warning} className="text-xs text-muted-foreground">- {warning}- </p>+ <div key={warning}>{warning}</div>))}</div>+ ) : null}++ {isLoading ? (+ <PageSkeleton variant="list" />) : (- <>- <p className="text-sm text-muted-foreground">- {skillSnapshot.mode === "persistent"- ? "These skills are synced into the adapter's persistent skills home."- : "These skills are mounted ephemerally for each Claude run."}- </p>+ <div className="grid gap-5 xl:grid-cols-[minmax(0,1fr)_20rem]">+ <div className="space-y-4">+ <section className="rounded-xl border border-border/70 bg-background px-4 py-4">+ <div className="flex items-center justify-between gap-3">+ <div>+ <h4 className="text-sm font-medium">Company skills</h4>+ <p className="text-xs text-muted-foreground">+ Attach skills from the company library by shortname.+ </p>+ </div>+ <span className="rounded-full border border-border/70 px-2 py-0.5 text-[10px] uppercase tracking-wide text-muted-foreground">+ {(companySkills ?? []).length} available+ </span>+ </div>- <div className="space-y-2">- {skillSnapshot.entries- .filter((entry) => entry.managed)- .map((entry) => {- const checked = skillDraft.includes(entry.name);- return (- <label- key={entry.name}- className="flex items-start gap-3 rounded-md border border-border/70 px-3 py-2"+ {(companySkills ?? []).length === 0 ? (+ <div className="mt-4 rounded-lg border border-dashed border-border px-4 py-6 text-sm text-muted-foreground">+ Import skills into the company library first, then attach them here.+ </div>+ ) : (+ <div className="mt-4 space-y-2">+ {(companySkills ?? []).map((skill) => {+ const checked = skillDraft.includes(skill.slug);+ const adapterEntry = adapterEntryByName.get(skill.slug);+ return (+ <label+ key={skill.id}+ className="flex items-start gap-3 rounded-xl border border-border/70 px-3 py-3 transition-colors hover:bg-accent/20"+ >+ <input+ type="checkbox"+ checked={checked}+ onChange={(event) => {+ const next = event.target.checked+ ? Array.from(new Set([...skillDraft, skill.slug]))+ : skillDraft.filter((value) => value !== skill.slug);+ setSkillDraft(next);+ setSkillDirty(true);+ }}+ className="mt-1"+ />+ <div className="min-w-0 flex-1">+ <div className="flex flex-wrap items-center justify-between gap-2">+ <div className="min-w-0">+ <div className="flex items-center gap-2">+ <span className="text-sm font-medium">{skill.name}</span>+ <span className="rounded-full border border-border/70 px-2 py-0.5 text-[10px] uppercase tracking-wide text-muted-foreground">+ {skill.slug}+ </span>+ </div>+ {skill.description && (+ <p className="mt-1 text-xs text-muted-foreground">{skill.description}</p>+ )}+ </div>+ <div className="flex flex-wrap items-center gap-2">+ {adapterEntry?.state && (+ <span className="rounded-full border border-border px-2 py-0.5 text-[10px] uppercase tracking-wide text-muted-foreground">+ {adapterEntry.state}+ </span>+ )}+ <Link+ to={`/skills/${skill.id}`}+ className="text-xs text-muted-foreground no-underline hover:text-foreground"+ >+ View skill+ </Link>+ </div>+ </div>+ </div>+ </label>+ );+ })}+ </div>+ )}+ </section>++ {desiredOnlyMissingSkills.length > 0 && (+ <section className="rounded-xl border border-amber-300/60 bg-amber-50/60 px-4 py-4 dark:border-amber-500/30 dark:bg-amber-950/20">+ <h4 className="text-sm font-medium text-amber-900 dark:text-amber-100">+ Desired skills not found in the company library+ </h4>+ <div className="mt-3 space-y-2">+ {desiredOnlyMissingSkills.map((skillName) => {+ const adapterEntry = adapterEntryByName.get(skillName);+ return (+ <div key={skillName} className="flex items-center justify-between gap-3 rounded-lg border border-amber-300/50 bg-background/70 px-3 py-2 dark:border-amber-500/20">+ <div>+ <div className="text-sm font-medium">{skillName}</div>+ <div className="text-xs text-muted-foreground">+ This skill is still requested for the agent, but it is not tracked in the company library.+ </div>+ </div>+ {adapterEntry?.state && (+ <span className="rounded-full border border-border px-2 py-0.5 text-[10px] uppercase tracking-wide text-muted-foreground">+ {adapterEntry.state}+ </span>+ )}+ </div>+ );+ })}+ </div>+ </section>+ )}+ </div>++ <div className="space-y-4">+ <section className="rounded-xl border border-border/70 bg-background px-4 py-4">+ <h4 className="text-sm font-medium">Adapter state</h4>+ <div className="mt-3 grid gap-2 text-sm">+ <div className="flex items-center justify-between gap-3">+ <span className="text-muted-foreground">Adapter</span>+ <span className="font-medium">{agent.adapterType}</span>+ </div>+ <div className="flex items-center justify-between gap-3">+ <span className="text-muted-foreground">Sync mode</span>+ <span className="rounded-full border border-border px-2 py-0.5 text-[10px] uppercase tracking-wide text-muted-foreground">+ {skillSnapshot?.mode ?? "unsupported"}+ </span>+ </div>+ <div className="flex items-center justify-between gap-3">+ <span className="text-muted-foreground">Desired skills</span>+ <span>{skillDraft.length}</span>+ </div>+ <div className="flex items-center justify-between gap-3">+ <span className="text-muted-foreground">External skills</span>+ <span>{externalEntries.length}</span>+ </div>+ </div>++ <div className="mt-4 flex items-center gap-2">+ <Button+ size="sm"+ onClick={() => syncSkills.mutate(skillDraft)}+ disabled={syncSkills.isPending || !skillDirty}+ >+ {syncSkills.isPending ? "Saving..." : primaryActionLabel}+ </Button>+ {skillDirty && (+ <Button+ variant="ghost"+ size="sm"+ onClick={() => {+ setSkillDraft(skillSnapshot?.desiredSkills ?? []);+ setSkillDirty(false);+ }}+ disabled={syncSkills.isPending}>- <input- type="checkbox"- checked={checked}- onChange={(e) => {- const next = e.target.checked- ? Array.from(new Set([...skillDraft, entry.name]))- : skillDraft.filter((value) => value !== entry.name);- setSkillDraft(next);- setSkillDirty(true);- }}- />- <div className="min-w-0 flex-1">+ Reset+ </Button>+ )}+ </div>++ {syncSkills.isError && (+ <p className="mt-3 text-xs text-destructive">+ {syncSkills.error instanceof Error ? syncSkills.error.message : "Failed to update skills"}+ </p>+ )}+ </section>++ <section className="rounded-xl border border-border/70 bg-background px-4 py-4">+ <h4 className="text-sm font-medium">External skills</h4>+ {externalEntries.length === 0 ? (+ <p className="mt-3 text-sm text-muted-foreground">+ No external skills were discovered by the adapter.+ </p>+ ) : (+ <div className="mt-3 space-y-2">+ {externalEntries.map((entry) => (+ <div key={entry.name} className="rounded-lg border border-border/70 px-3 py-2"><div className="flex items-center justify-between gap-2"><span className="text-sm font-medium">{entry.name}</span><span className="rounded-full border border-border px-2 py-0.5 text-[10px] uppercase tracking-wide text-muted-foreground">@@ -1197,74 +1432,18 @@ function ConfigurationTab({</span></div>{entry.detail && (- <p className="mt-1 text-xs text-muted-foreground">- {entry.detail}- </p>+ <p className="mt-1 text-xs text-muted-foreground">{entry.detail}</p>)}</div>- </label>- );- })}- </div>-- {skillSnapshot.entries.some((entry) => entry.state === "external") && (- <div className="space-y-1">- <div className="text-xs uppercase tracking-wide text-muted-foreground">- External skills- </div>- {skillSnapshot.entries- .filter((entry) => entry.state === "external")- .map((entry) => (- <div key={entry.name} className="text-xs text-muted-foreground">- {entry.name}- {entry.detail ? ` - ${entry.detail}` : ""}- </div>- ))}- </div>- )}-- {skillSnapshot.warnings.length > 0 && (- <div className="space-y-1 rounded-md border border-amber-300/60 bg-amber-50/60 px-3 py-2 text-xs text-amber-700">- {skillSnapshot.warnings.map((warning) => (- <div key={warning}>{warning}</div>- ))}- </div>- )}-- {syncSkills.isError && (- <p className="text-xs text-destructive">- {syncSkills.error instanceof Error- ? syncSkills.error.message- : "Failed to sync skills"}- </p>- )}-- <div className="flex items-center gap-2">- <Button- size="sm"- onClick={() => syncSkills.mutate(skillDraft)}- disabled={syncSkills.isPending || !skillDirty}- >- {syncSkills.isPending ? "Syncing..." : "Sync skills"}- </Button>- {skillDirty && (- <Button- variant="ghost"- size="sm"- onClick={() => {- setSkillDraft(skillSnapshot.desiredSkills);- setSkillDirty(false);- }}- disabled={syncSkills.isPending}- >- Reset- </Button>- )}+ ))}+ </div>+ )}+ </section></div>- </>+ </div>)}</div>- </div>+ </section></div>);}diff --git a/ui/src/pages/CompanySkills.tsx b/ui/src/pages/CompanySkills.tsxnew file mode 100644index 0000000000..1294d08ddb--- /dev/null+++ b/ui/src/pages/CompanySkills.tsx@@ -0,0 +1,434 @@+import { useEffect, useMemo, useState } from "react";+import { Link, useNavigate, useParams } from "@/lib/router";+import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";+import type {+ CompanySkillDetail,+ CompanySkillListItem,+ CompanySkillTrustLevel,+} from "@paperclipai/shared";+import { companySkillsApi } from "../api/companySkills";+import { useCompany } from "../context/CompanyContext";+import { useBreadcrumbs } from "../context/BreadcrumbContext";+import { useToast } from "../context/ToastContext";+import { queryKeys } from "../lib/queryKeys";+import { EmptyState } from "../components/EmptyState";+import { MarkdownBody } from "../components/MarkdownBody";+import { PageSkeleton } from "../components/PageSkeleton";+import { EntityRow } from "../components/EntityRow";+import { cn } from "../lib/utils";+import { Button } from "@/components/ui/button";+import { Input } from "@/components/ui/input";+import {+ ArrowUpRight,+ BookOpen,+ Boxes,+ FolderInput,+ RefreshCw,+ ShieldAlert,+ ShieldCheck,+ TerminalSquare,+} from "lucide-react";++function stripFrontmatter(markdown: string) {+ const normalized = markdown.replace(/\r\n/g, "\n");+ if (!normalized.startsWith("---\n")) return normalized.trim();+ const closing = normalized.indexOf("\n---\n", 4);+ if (closing < 0) return normalized.trim();+ return normalized.slice(closing + 5).trim();+}++function trustTone(trustLevel: CompanySkillTrustLevel) {+ switch (trustLevel) {+ case "markdown_only":+ return "bg-emerald-500/10 text-emerald-700 dark:text-emerald-300";+ case "assets":+ return "bg-amber-500/10 text-amber-700 dark:text-amber-300";+ case "scripts_executables":+ return "bg-red-500/10 text-red-700 dark:text-red-300";+ default:+ return "bg-muted text-muted-foreground";+ }+}++function trustLabel(trustLevel: CompanySkillTrustLevel) {+ switch (trustLevel) {+ case "markdown_only":+ return "Markdown only";+ case "assets":+ return "Assets";+ case "scripts_executables":+ return "Scripts";+ default:+ return trustLevel;+ }+}++function compatibilityLabel(detail: CompanySkillDetail | CompanySkillListItem) {+ switch (detail.compatibility) {+ case "compatible":+ return "Compatible";+ case "unknown":+ return "Unknown";+ case "invalid":+ return "Invalid";+ default:+ return detail.compatibility;+ }+}++function SkillListItem({+ skill,+ selected,+}: {+ skill: CompanySkillListItem;+ selected: boolean;+}) {+ return (+ <Link+ to={`/skills/${skill.id}`}+ className={cn(+ "block rounded-xl border p-3 no-underline transition-colors",+ selected+ ? "border-primary bg-primary/5"+ : "border-border/70 bg-card hover:border-border hover:bg-accent/20",+ )}+ >+ <div className="flex items-start justify-between gap-3">+ <div className="min-w-0">+ <div className="flex items-center gap-2">+ <span className="font-medium text-sm text-foreground">{skill.name}</span>+ <span className="rounded-full border border-border/70 px-2 py-0.5 text-[10px] uppercase tracking-wide text-muted-foreground">+ {skill.slug}+ </span>+ </div>+ {skill.description && (+ <p className="mt-1 line-clamp-2 text-xs text-muted-foreground">+ {skill.description}+ </p>+ )}+ </div>+ <span className={cn("shrink-0 rounded-full px-2 py-1 text-[10px] font-medium", trustTone(skill.trustLevel))}>+ {trustLabel(skill.trustLevel)}+ </span>+ </div>+ <div className="mt-3 flex items-center justify-between gap-3 text-[11px] text-muted-foreground">+ <span>{skill.attachedAgentCount} agent{skill.attachedAgentCount === 1 ? "" : "s"}</span>+ <span>{skill.fileInventory.length} file{skill.fileInventory.length === 1 ? "" : "s"}</span>+ </div>+ </Link>+ );+}++function SkillDetailPanel({+ detail,+ isLoading,+}: {+ detail: CompanySkillDetail | null | undefined;+ isLoading: boolean;+}) {+ if (isLoading) {+ return <PageSkeleton variant="detail" />;+ }++ if (!detail) {+ return (+ <div className="rounded-2xl border border-dashed border-border bg-card/40 p-8">+ <div className="max-w-md space-y-3">+ <div className="inline-flex h-11 w-11 items-center justify-center rounded-2xl bg-accent text-accent-foreground">+ <BookOpen className="h-5 w-5" />+ </div>+ <div>+ <h2 className="text-lg font-semibold">Select a skill</h2>+ <p className="mt-1 text-sm text-muted-foreground">+ Review its markdown, inspect files, and see which agents have it attached.+ </p>+ </div>+ </div>+ </div>+ );+ }++ const markdownBody = stripFrontmatter(detail.markdown);++ return (+ <div className="space-y-5">+ <section className="overflow-hidden rounded-2xl border border-border bg-card">+ <div className="border-b border-border bg-[linear-gradient(135deg,rgba(24,24,27,0.02),rgba(24,24,27,0.06))] px-5 py-4 dark:bg-[linear-gradient(135deg,rgba(255,255,255,0.03),rgba(255,255,255,0.06))]">+ <div className="flex flex-wrap items-start justify-between gap-3">+ <div className="min-w-0">+ <div className="flex flex-wrap items-center gap-2">+ <h2 className="text-xl font-semibold">{detail.name}</h2>+ <span className="rounded-full border border-border/70 px-2 py-0.5 text-[10px] uppercase tracking-wide text-muted-foreground">+ {detail.slug}+ </span>+ <span className={cn("rounded-full px-2 py-0.5 text-[10px] font-medium", trustTone(detail.trustLevel))}>+ {trustLabel(detail.trustLevel)}+ </span>+ </div>+ {detail.description && (+ <p className="mt-2 max-w-2xl text-sm text-muted-foreground">{detail.description}</p>+ )}+ </div>+ <div className="grid shrink-0 gap-1 text-right text-[11px] text-muted-foreground">+ <span>{compatibilityLabel(detail)}</span>+ <span>{detail.attachedAgentCount} attached agent{detail.attachedAgentCount === 1 ? "" : "s"}</span>+ </div>+ </div>+ </div>++ <div className="grid gap-5 px-5 py-5 lg:grid-cols-[minmax(0,1fr)_18rem]">+ <div className="min-w-0">+ <div className="mb-3 flex items-center justify-between gap-3">+ <h3 className="text-sm font-medium">SKILL.md</h3>+ {detail.sourceLocator && (+ <a+ href={detail.sourceLocator}+ target="_blank"+ rel="noreferrer"+ className="inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground"+ >+ Open source+ <ArrowUpRight className="h-3.5 w-3.5" />+ </a>+ )}+ </div>+ <div className="rounded-xl border border-border/70 bg-background px-4 py-4">+ <MarkdownBody>{markdownBody}</MarkdownBody>+ </div>+ </div>++ <div className="space-y-4">+ <section className="rounded-xl border border-border/70 bg-background px-4 py-4">+ <h3 className="text-sm font-medium">Inventory</h3>+ <div className="mt-3 space-y-2">+ {detail.fileInventory.map((entry) => (+ <div key={`${entry.kind}:${entry.path}`} className="flex items-center justify-between gap-3 text-xs">+ <span className="truncate font-mono text-muted-foreground">{entry.path}</span>+ <span className="rounded-full border border-border/70 px-2 py-0.5 uppercase tracking-wide text-[10px] text-muted-foreground">+ {entry.kind}+ </span>+ </div>+ ))}+ </div>+ </section>++ <section className="rounded-xl border border-border/70 bg-background px-4 py-4">+ <h3 className="text-sm font-medium">Used By Agents</h3>+ {detail.usedByAgents.length === 0 ? (+ <p className="mt-3 text-sm text-muted-foreground">No agents are currently attached to this skill.</p>+ ) : (+ <div className="mt-3 space-y-2">+ {detail.usedByAgents.map((agent) => (+ <EntityRow+ key={agent.id}+ title={agent.name}+ subtitle={agent.adapterType}+ to={`/agents/${agent.urlKey}/skills`}+ trailing={agent.actualState ? (+ <span className="rounded-full border border-border/70 px-2 py-0.5 text-[10px] uppercase tracking-wide text-muted-foreground">+ {agent.actualState}+ </span>+ ) : undefined}+ />+ ))}+ </div>+ )}+ </section>+ </div>+ </div>+ </section>+ </div>+ );+}++export function CompanySkills() {+ const { skillId } = useParams<{ skillId?: string }>();+ const navigate = useNavigate();+ const queryClient = useQueryClient();+ const { selectedCompanyId } = useCompany();+ const { setBreadcrumbs } = useBreadcrumbs();+ const { pushToast } = useToast();+ const [source, setSource] = useState("");++ useEffect(() => {+ setBreadcrumbs([+ { label: "Skills", href: "/skills" },+ ...(skillId ? [{ label: "Detail" }] : []),+ ]);+ }, [setBreadcrumbs, skillId]);++ const {+ data: skills,+ isLoading,+ error,+ } = useQuery({+ queryKey: queryKeys.companySkills.list(selectedCompanyId ?? ""),+ queryFn: () => companySkillsApi.list(selectedCompanyId!),+ enabled: Boolean(selectedCompanyId),+ });++ const selectedSkillId = useMemo(() => {+ if (!skillId) return skills?.[0]?.id ?? null;+ return skillId;+ }, [skillId, skills]);++ const {+ data: detail,+ isLoading: detailLoading,+ } = useQuery({+ queryKey: queryKeys.companySkills.detail(selectedCompanyId ?? "", selectedSkillId ?? ""),+ queryFn: () => companySkillsApi.detail(selectedCompanyId!, selectedSkillId!),+ enabled: Boolean(selectedCompanyId && selectedSkillId),+ });++ const importSkill = useMutation({+ mutationFn: (importSource: string) => companySkillsApi.importFromSource(selectedCompanyId!, importSource),+ onSuccess: async (result) => {+ await queryClient.invalidateQueries({ queryKey: queryKeys.companySkills.list(selectedCompanyId!) });+ if (result.imported[0]) {+ navigate(`/skills/${result.imported[0].id}`);+ }+ pushToast({+ tone: "success",+ title: "Skills imported",+ body: `${result.imported.length} skill${result.imported.length === 1 ? "" : "s"} added to the company library.`,+ });+ if (result.warnings[0]) {+ pushToast({+ tone: "warn",+ title: "Import warnings",+ body: result.warnings[0],+ });+ }+ setSource("");+ },+ onError: (importError) => {+ pushToast({+ tone: "error",+ title: "Skill import failed",+ body: importError instanceof Error ? importError.message : "Failed to import skill source.",+ });+ },+ });++ if (!selectedCompanyId) {+ return <EmptyState icon={Boxes} message="Select a company to manage skills." />;+ }++ return (+ <div className="space-y-5">+ <section className="overflow-hidden rounded-2xl border border-border bg-card">+ <div className="border-b border-border bg-[radial-gradient(circle_at_top_left,rgba(16,185,129,0.10),transparent_38%),radial-gradient(circle_at_bottom_right,rgba(59,130,246,0.10),transparent_40%)] px-5 py-5">+ <div className="flex flex-col gap-4 lg:flex-row lg:items-end lg:justify-between">+ <div className="max-w-2xl">+ <div className="mb-2 inline-flex items-center gap-2 rounded-full border border-border/70 bg-background/70 px-3 py-1 text-[11px] uppercase tracking-[0.18em] text-muted-foreground">+ <Boxes className="h-3.5 w-3.5" />+ Company skill library+ </div>+ <h1 className="text-2xl font-semibold tracking-tight">Manage reusable skills once, attach them anywhere.</h1>+ <p className="mt-2 text-sm text-muted-foreground">+ Import `SKILL.md` packages from local paths, GitHub repos, or direct URLs. Agents attach by skill shortname, while adapters decide how those skills are installed or mounted.+ </p>+ </div>+ <div className="grid gap-2 text-xs text-muted-foreground sm:grid-cols-3">+ <div className="rounded-xl border border-border/70 bg-background/70 px-3 py-3">+ <div className="flex items-center gap-2 font-medium text-foreground">+ <ShieldCheck className="h-3.5 w-3.5 text-emerald-600 dark:text-emerald-400" />+ Markdown-first+ </div>+ <p className="mt-1">`skills.sh` compatible packages stay readable and repo-native.</p>+ </div>+ <div className="rounded-xl border border-border/70 bg-background/70 px-3 py-3">+ <div className="flex items-center gap-2 font-medium text-foreground">+ <FolderInput className="h-3.5 w-3.5 text-blue-600 dark:text-blue-400" />+ GitHub aware+ </div>+ <p className="mt-1">Import a repo, a subtree, or a single skill file without a registry.</p>+ </div>+ <div className="rounded-xl border border-border/70 bg-background/70 px-3 py-3">+ <div className="flex items-center gap-2 font-medium text-foreground">+ <ShieldAlert className="h-3.5 w-3.5 text-amber-600 dark:text-amber-400" />+ Trust surfaced+ </div>+ <p className="mt-1">Scripts and executable bundles stay visible instead of being hidden in setup.</p>+ </div>+ </div>+ </div>+ </div>++ <div className="border-t border-border px-5 py-4">+ <div className="flex flex-col gap-3 lg:flex-row lg:items-center">+ <div className="flex-1">+ <Input+ value={source}+ onChange={(event) => setSource(event.target.value)}+ placeholder="Local path, GitHub repo/tree/blob URL, or direct SKILL.md URL"+ className="h-10"+ />+ </div>+ <div className="flex items-center gap-2">+ <Button+ variant="outline"+ size="sm"+ onClick={() => queryClient.invalidateQueries({ queryKey: queryKeys.companySkills.list(selectedCompanyId) })}+ disabled={isLoading}+ >+ <RefreshCw className="mr-1.5 h-3.5 w-3.5" />+ Refresh+ </Button>+ <Button+ size="sm"+ onClick={() => importSkill.mutate(source.trim())}+ disabled={importSkill.isPending || source.trim().length === 0}+ >+ {importSkill.isPending ? "Importing..." : "Import skill"}+ </Button>+ </div>+ </div>+ </div>+ </section>++ {error && <p className="text-sm text-destructive">{error.message}</p>}++ {!isLoading && (skills?.length ?? 0) === 0 ? (+ <EmptyState+ icon={TerminalSquare}+ message="No company skills yet."+ action="Import your first skill"+ onAction={() => {+ const trimmed = source.trim();+ if (trimmed) importSkill.mutate(trimmed);+ }}+ />+ ) : (+ <div className="grid gap-5 xl:grid-cols-[22rem_minmax(0,1fr)]">+ <section className="space-y-3">+ <div className="flex items-center justify-between">+ <div>+ <h2 className="text-sm font-medium">Library</h2>+ <p className="text-xs text-muted-foreground">+ {skills?.length ?? 0} tracked skill{(skills?.length ?? 0) === 1 ? "" : "s"}+ </p>+ </div>+ </div>+ {isLoading ? (+ <PageSkeleton variant="list" />+ ) : (+ <div className="space-y-2">+ {(skills ?? []).map((skill) => (+ <SkillListItem+ key={skill.id}+ skill={skill}+ selected={skill.id === selectedSkillId}+ />+ ))}+ </div>+ )}+ </section>++ <SkillDetailPanel detail={detail} isLoading={detailLoading} />+ </div>+ )}+ </div>+ );+}