Open-source AI coworkers that each get a computer of their own: a browser, files and tools, with every action decided before it happens and recorded after. Bring any AG-UI agent.
Keep people's memory in CopilotKit Intelligence when the deployment is entitled to it (#773)
David McKay4c25119d50d0
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 740c33d9..76699254 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -8,6 +8,20 @@ Newest first. `Unreleased` is what is on `main` and not yet tagged.## Unreleased+### Memory lives in CopilotKit Intelligence++A deployment entitled to Intelligence memory now keeps its people's memories there: Intelligence holds+the content and ranks recall, and memories another app on the same project formed for a person appear+in their Memory page and reach their Bots. OpenBot still records each memory's provenance, review state+and which Bot or source it came from, and applies those rules to everything Intelligence returns, so a+Bot-formed memory still reaches only the Bot that formed it. Without Intelligence memory nothing changes:+OpenBot's own tables remain the store.++**Before upgrading.** Migration `0054_memory_on_intelligence` adds two columns to `personal_memories`.+On an entitled deployment, the memory sweep then copies existing reviewed, switched-on memories into+Intelligence, a few people at a time each minute; it is idempotent and safe to interrupt. Memories+awaiting review, paused or forgotten stay local until that changes.+## 0.2.0**Before upgrading.** Two things change for an existing deployment:diff --git a/app/src/components/memory/memories.tsx b/app/src/components/memory/memories.tsxindex 9dd39a75..c982de09 100644--- a/app/src/components/memory/memories.tsx+++ b/app/src/components/memory/memories.tsx@@ -177,13 +177,18 @@ function MemoryRow({enabled?: boolean;reviewState?: "confirmed";}) => save.mutate({ id: memory.id, input });- const status = !memory.enabled- ? "Disabled"- : memory.formedBy === "bot"- ? `Formed by ${botName}${memory.reviewState === "unreviewed" ? " · awaiting review" : ""}`- : memory.reviewState === "unreviewed"- ? "Imported · awaiting review"- : "Reviewed";+ // Intelligence keeps only the words of a memory it holds for this person, so it can be edited or+ // forgotten here but not paused or reviewed.+ const heldByIntelligence = memory.formedBy === "intelligence";+ const status = heldByIntelligence+ ? "Kept in Intelligence"+ : !memory.enabled+ ? "Disabled"+ : memory.formedBy === "bot"+ ? `Formed by ${botName}${memory.reviewState === "unreviewed" ? " · awaiting review" : ""}`+ : memory.reviewState === "unreviewed"+ ? "Imported · awaiting review"+ : "Reviewed";return (<Item size="sm"><ItemMedia variant="icon">@@ -250,15 +255,17 @@ function MemoryRow({</p>)}</ItemContent>- <ItemActions>- {/* Binary and immediate: Bots stop or start using it when switched. */}- <Switch- aria-label={`Use this memory: ${clip(memory.content)}`}- checked={memory.enabled}- disabled={save.isPending}- onCheckedChange={(enabled) => update({ enabled })}- />- </ItemActions>+ {heldByIntelligence ? null : (+ <ItemActions>+ {/* Binary and immediate: Bots stop or start using it when switched. */}+ <Switch+ aria-label={`Use this memory: ${clip(memory.content)}`}+ checked={memory.enabled}+ disabled={save.isPending}+ onCheckedChange={(enabled) => update({ enabled })}+ />+ </ItemActions>+ )}{editing ? (<EditMemoryDialogmemory={memory}diff --git a/app/src/lib/memory.ts b/app/src/lib/memory.tsindex 18add053..0ac76d2f 100644--- a/app/src/lib/memory.ts+++ b/app/src/lib/memory.ts@@ -11,7 +11,8 @@ export type MemoryRecord = {sourceId: string | null;enabled: boolean;reviewState: "unreviewed" | "confirmed" | "edited";- formedBy: "person" | "import" | "bot";+ /** `intelligence`: held by CopilotKit Intelligence for this person, formed outside OpenBot. */+ formedBy: "person" | "import" | "bot" | "intelligence";formedByAgentId: string | null;sourceApp: string | null;sourceLink: string | null;diff --git a/docs/architecture.md b/docs/architecture.mdindex 6eccfad7..56d8fa0b 100644--- a/docs/architecture.md+++ b/docs/architecture.md@@ -319,6 +319,31 @@ A skill declares the tools it needs (`skill_tools`). Before the run starts, theThis narrows the offer. It is not a boundary, and it never substitutes for one. The grant, the policy and the audit row decide what may happen; this decides only what the model can see. Every way it can fail — no skills declared, a model that cannot answer, a message that matches nothing, twelve tools or fewer — leaves the whole catalogue offered, because a narrowing that failed closed would remove capability an administrator granted, silently. `mcp.tools_discovered` records what was offered, out of how much, and why.+## Personal memory++A person's memory is kept in CopilotKit Intelligence when the deployment is entitled to Intelligence+memory (`features.memory` in its runtime entitlement), and in OpenBot's own tables when it is not.++- **Intelligence holds the content and does the recall.** Every memory the person has accepted is+ mirrored there: one they wrote, a Bot-formed or imported one once they confirm it. Editing a memory+ supersedes its Intelligence copy; pausing or forgetting it retires it, because Intelligence has no+ field for "paused". Recall for a search is ranked by Intelligence.+- **OpenBot keeps what Intelligence has no field for.** Intelligence stores only content, kind and+ scope, so the OpenBot row stays the record of where a memory came from, its review state, which Bot+ formed it and which source imported it. Those decide which Bot may see a memory, and they are applied+ to everything Intelligence returns before a Bot sees it: a Bot-formed memory still reaches only the+ Bot that formed it, while it holds the source app.+- **Only the person's own memories.** Every call names the person and asks for `user` scope with no+ project access, and project-scoped results are dropped, so one person's Bot never sees another+ person's memory.+- **Memories formed elsewhere.** A memory Intelligence holds for the person that no OpenBot row+ describes (another app on the same project, or Intelligence itself) appears in their Memory page as+ "Kept in Intelligence" and is recalled as their own. It can be edited or forgotten there, not paused.+- **Without Intelligence memory** (not entitled, a lapsed licence, an outage), OpenBot reads and writes+ its tables exactly as before and nothing fails. Writes made meanwhile are mirrored by the memory sweep+ once Intelligence memory is available again; the first passes after a deployment becomes entitled are+ the backfill of everything it already holds.+## Tenant package and knowledge`TENANT_PACKAGE_DIR` points at the tenant package. The default is `../examples/fintech`.diff --git a/server/drizzle/0054_memory_on_intelligence.sql b/server/drizzle/0054_memory_on_intelligence.sqlnew file mode 100644index 00000000..e76ddffc--- /dev/null+++ b/server/drizzle/0054_memory_on_intelligence.sql@@ -0,0 +1,3 @@+ALTER TABLE "personal_memories" ADD COLUMN "intelligence_memory_id" text;--> statement-breakpoint+ALTER TABLE "personal_memories" ADD COLUMN "intelligence_digest" text;--> statement-breakpoint+CREATE INDEX "personal_memories_intelligence_idx" ON "personal_memories" USING btree ("owner_user_id","intelligence_memory_id");\ No newline at end of filediff --git a/server/drizzle/meta/0054_snapshot.json b/server/drizzle/meta/0054_snapshot.jsonnew file mode 100644index 00000000..a154caa1--- /dev/null+++ b/server/drizzle/meta/0054_snapshot.json@@ -0,0 +1,9776 @@+{+ "id": "c063be84-c35b-4365-96a4-07ae849d11dd",+ "prevId": "a0509e82-296a-4370-8932-1d19b9c2b426",+ "version": "7",+ "dialect": "postgresql",+ "tables": {+ "public.accounts": {+ "name": "accounts",+ "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+ },+ "issuer": {+ "name": "issuer",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "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,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "accounts_provider_account_idx": {+ "name": "accounts_provider_account_idx",+ "columns": [+ {+ "expression": "provider_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "account_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "accounts_user_id_users_id_fk": {+ "name": "accounts_user_id_users_id_fk",+ "tableFrom": "accounts",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agents": {+ "name": "agents",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "type": {+ "name": "type",+ "type": "agent_type",+ "typeSchema": "public",+ "primaryKey": false,+ "notNull": true+ },+ "configuration": {+ "name": "configuration",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "package_id": {+ "name": "package_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "override": {+ "name": "override",+ "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": {},+ "foreignKeys": {+ "agents_package_id_deployment_packages_id_fk": {+ "name": "agents_package_id_deployment_packages_id_fk",+ "tableFrom": "agents",+ "tableTo": "deployment_packages",+ "columnsFrom": [+ "package_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.attachments": {+ "name": "attachments",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "channel_id": {+ "name": "channel_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "uploaded_by": {+ "name": "uploaded_by",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "mime_type": {+ "name": "mime_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "size_bytes": {+ "name": "size_bytes",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "bytes": {+ "name": "bytes",+ "type": "bytea",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "attached_at": {+ "name": "attached_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "upload_group": {+ "name": "upload_group",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "attachments_channel_idx": {+ "name": "attachments_channel_idx",+ "columns": [+ {+ "expression": "channel_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "attachments_uploaded_by_idx": {+ "name": "attachments_uploaded_by_idx",+ "columns": [+ {+ "expression": "uploaded_by",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "attachments_upload_group_idx": {+ "name": "attachments_upload_group_idx",+ "columns": [+ {+ "expression": "channel_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "uploaded_by",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "upload_group",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"attachments\".\"attached_at\" is null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "attachments_staged_idx": {+ "name": "attachments_staged_idx",+ "columns": [+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"attachments\".\"attached_at\" is null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "attachments_channel_id_channels_id_fk": {+ "name": "attachments_channel_id_channels_id_fk",+ "tableFrom": "attachments",+ "tableTo": "channels",+ "columnsFrom": [+ "channel_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "attachments_uploaded_by_users_id_fk": {+ "name": "attachments_uploaded_by_users_id_fk",+ "tableFrom": "attachments",+ "tableTo": "users",+ "columnsFrom": [+ "uploaded_by"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.audit_events": {+ "name": "audit_events",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "actor_user_id": {+ "name": "actor_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "initiator_kind": {+ "name": "initiator_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'person'"+ },+ "initiator_id": {+ "name": "initiator_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "event_type": {+ "name": "event_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "target_type": {+ "name": "target_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "target_id": {+ "name": "target_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "payload": {+ "name": "payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "audit_events_created_at_idx": {+ "name": "audit_events_created_at_idx",+ "columns": [+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "audit_events_type_time_idx": {+ "name": "audit_events_type_time_idx",+ "columns": [+ {+ "expression": "event_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "audit_events_actor_time_idx": {+ "name": "audit_events_actor_time_idx",+ "columns": [+ {+ "expression": "actor_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "audit_events_target_time_idx": {+ "name": "audit_events_target_time_idx",+ "columns": [+ {+ "expression": "target_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "target_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "audit_events_initiator_time_idx": {+ "name": "audit_events_initiator_time_idx",+ "columns": [+ {+ "expression": "initiator_kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.channel_agents": {+ "name": "channel_agents",+ "schema": "",+ "columns": {+ "channel_id": {+ "name": "channel_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "channel_agents_channel_id_channels_id_fk": {+ "name": "channel_agents_channel_id_channels_id_fk",+ "tableFrom": "channel_agents",+ "tableTo": "channels",+ "columnsFrom": [+ "channel_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "channel_agents_agent_id_agents_id_fk": {+ "name": "channel_agents_agent_id_agents_id_fk",+ "tableFrom": "channel_agents",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "channel_agents_channel_id_agent_id_pk": {+ "name": "channel_agents_channel_id_agent_id_pk",+ "columns": [+ "channel_id",+ "agent_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.channel_memberships": {+ "name": "channel_memberships",+ "schema": "",+ "columns": {+ "channel_id": {+ "name": "channel_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "pinned_at": {+ "name": "pinned_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "last_read_at": {+ "name": "last_read_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": {},+ "foreignKeys": {+ "channel_memberships_channel_id_channels_id_fk": {+ "name": "channel_memberships_channel_id_channels_id_fk",+ "tableFrom": "channel_memberships",+ "tableTo": "channels",+ "columnsFrom": [+ "channel_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "channel_memberships_user_id_users_id_fk": {+ "name": "channel_memberships_user_id_users_id_fk",+ "tableFrom": "channel_memberships",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "channel_memberships_channel_id_user_id_pk": {+ "name": "channel_memberships_channel_id_user_id_pk",+ "columns": [+ "channel_id",+ "user_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.channels": {+ "name": "channels",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "suggested_prompts": {+ "name": "suggested_prompts",+ "type": "text[]",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'"+ },+ "allowed_groups": {+ "name": "allowed_groups",+ "type": "text[]",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'"+ },+ "package_id": {+ "name": "package_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "override": {+ "name": "override",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "summary": {+ "name": "summary",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "summary_at": {+ "name": "summary_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "last_message": {+ "name": "last_message",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "last_message_source_id": {+ "name": "last_message_source_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "last_message_at": {+ "name": "last_message_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "last_message_agent_id": {+ "name": "last_message_agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "channels_recent_activity_idx": {+ "name": "channels_recent_activity_idx",+ "columns": [+ {+ "expression": "COALESCE(\"last_message_at\", \"created_at\") DESC",+ "asc": true,+ "isExpression": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "channels_awaiting_summary_idx": {+ "name": "channels_awaiting_summary_idx",+ "columns": [+ {+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"channels\".\"summary\" is null and \"channels\".\"deleted_at\" is null",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "channels_package_id_deployment_packages_id_fk": {+ "name": "channels_package_id_deployment_packages_id_fk",+ "tableFrom": "channels",+ "tableTo": "deployment_packages",+ "columnsFrom": [+ "package_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "channels_last_message_agent_id_agents_id_fk": {+ "name": "channels_last_message_agent_id_agents_id_fk",+ "tableFrom": "channels",+ "tableTo": "agents",+ "columnsFrom": [+ "last_message_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.credentials": {+ "name": "credentials",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "kind": {+ "name": "kind",+ "type": "credential_kind",+ "typeSchema": "public",+ "primaryKey": false,+ "notNull": true+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "encrypted_value": {+ "name": "encrypted_value",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "key_id": {+ "name": "key_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "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()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "credentials_active_key_idx": {+ "name": "credentials_active_key_idx",+ "columns": [+ {+ "expression": "kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "key_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"credentials\".\"revoked_at\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.deployment_packages": {+ "name": "deployment_packages",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "tenant_id": {+ "name": "tenant_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source_path": {+ "name": "source_path",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "checksum": {+ "name": "checksum",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "loaded_at": {+ "name": "loaded_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "deployment_packages_tenant_id_unique": {+ "name": "deployment_packages_tenant_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "tenant_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.intelligence_channel_mappings": {+ "name": "intelligence_channel_mappings",+ "schema": "",+ "columns": {+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "channel_id": {+ "name": "channel_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "thread_id": {+ "name": "thread_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "intelligence_channel_mappings_thread_idx": {+ "name": "intelligence_channel_mappings_thread_idx",+ "columns": [+ {+ "expression": "thread_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "intelligence_channel_mappings_user_id_users_id_fk": {+ "name": "intelligence_channel_mappings_user_id_users_id_fk",+ "tableFrom": "intelligence_channel_mappings",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "intelligence_channel_mappings_channel_id_channels_id_fk": {+ "name": "intelligence_channel_mappings_channel_id_channels_id_fk",+ "tableFrom": "intelligence_channel_mappings",+ "tableTo": "channels",+ "columnsFrom": [+ "channel_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "intelligence_channel_mappings_user_id_channel_id_pk": {+ "name": "intelligence_channel_mappings_user_id_channel_id_pk",+ "columns": [+ "user_id",+ "channel_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.revoked_access": {+ "name": "revoked_access",+ "schema": "",+ "columns": {+ "email": {+ "name": "email",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "revoked_at": {+ "name": "revoked_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "revoked_by": {+ "name": "revoked_by",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.sessions": {+ "name": "sessions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "token": {+ "name": "token",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "expires_at": {+ "name": "expires_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+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "sessions_user_id_users_id_fk": {+ "name": "sessions_user_id_users_id_fk",+ "tableFrom": "sessions",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "sessions_token_unique": {+ "name": "sessions_token_unique",+ "nullsNotDistinct": false,+ "columns": [+ "token"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.sso_providers": {+ "name": "sso_providers",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "issuer": {+ "name": "issuer",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "oidc_config": {+ "name": "oidc_config",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "saml_config": {+ "name": "saml_config",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "provider_id": {+ "name": "provider_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "organization_id": {+ "name": "organization_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "domain": {+ "name": "domain",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {+ "sso_providers_user_id_users_id_fk": {+ "name": "sso_providers_user_id_users_id_fk",+ "tableFrom": "sso_providers",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "sso_providers_provider_id_unique": {+ "name": "sso_providers_provider_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "provider_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_instructions": {+ "name": "user_instructions",+ "schema": "",+ "columns": {+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "instructions": {+ "name": "instructions",+ "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": {},+ "foreignKeys": {+ "user_instructions_user_id_users_id_fk": {+ "name": "user_instructions_user_id_users_id_fk",+ "tableFrom": "user_instructions",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_roles": {+ "name": "user_roles",+ "schema": "",+ "columns": {+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "role": {+ "name": "role",+ "type": "role",+ "typeSchema": "public",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "user_roles_user_id_users_id_fk": {+ "name": "user_roles_user_id_users_id_fk",+ "tableFrom": "user_roles",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "user_roles_user_id_role_pk": {+ "name": "user_roles_user_id_role_pk",+ "columns": [+ "user_id",+ "role"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.users": {+ "name": "users",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "email": {+ "name": "email",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "image": {+ "name": "image",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "email_verified": {+ "name": "email_verified",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "preferences": {+ "name": "preferences",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "groups": {+ "name": "groups",+ "type": "text[]",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'"+ },+ "onboarding_step": {+ "name": "onboarding_step",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "onboarding_completed_at": {+ "name": "onboarding_completed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "last_signed_in_at": {+ "name": "last_signed_in_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": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "users_email_unique": {+ "name": "users_email_unique",+ "nullsNotDistinct": false,+ "columns": [+ "email"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.verifications": {+ "name": "verifications",+ "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": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.action_policy": {+ "name": "action_policy",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "mode": {+ "name": "mode",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "deny": {+ "name": "deny",+ "type": "text[]",+ "primaryKey": false,+ "notNull": true+ },+ "allow": {+ "name": "allow",+ "type": "text[]",+ "primaryKey": false,+ "notNull": true+ },+ "updated_by": {+ "name": "updated_by",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.computer_page_frame": {+ "name": "computer_page_frame",+ "schema": "",+ "columns": {+ "computer_id": {+ "name": "computer_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "tool_call_id": {+ "name": "tool_call_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "url": {+ "name": "url",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "frame": {+ "name": "frame",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "captured_at": {+ "name": "captured_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "computer_page_frame_captured_idx": {+ "name": "computer_page_frame_captured_idx",+ "columns": [+ {+ "expression": "captured_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "computer_page_frame_computer_id_tool_call_id_pk": {+ "name": "computer_page_frame_computer_id_tool_call_id_pk",+ "columns": [+ "computer_id",+ "tool_call_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.computer_snapshot": {+ "name": "computer_snapshot",+ "schema": "",+ "columns": {+ "computer_id": {+ "name": "computer_id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "snapshot_id": {+ "name": "snapshot_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "url": {+ "name": "url",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "elements": {+ "name": "elements",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "taken_at": {+ "name": "taken_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "session": {+ "name": "session",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_preferences": {+ "name": "agent_preferences",+ "schema": "",+ "columns": {+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "hidden_at": {+ "name": "hidden_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "pinned_at": {+ "name": "pinned_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "agent_preferences_user_id_users_id_fk": {+ "name": "agent_preferences_user_id_users_id_fk",+ "tableFrom": "agent_preferences",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_preferences_agent_id_agents_id_fk": {+ "name": "agent_preferences_agent_id_agents_id_fk",+ "tableFrom": "agent_preferences",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "agent_preferences_user_id_agent_id_pk": {+ "name": "agent_preferences_user_id_agent_id_pk",+ "columns": [+ "user_id",+ "agent_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_profiles": {+ "name": "agent_profiles",+ "schema": "",+ "columns": {+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "role_description": {+ "name": "role_description",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "avatar_seed": {+ "name": "avatar_seed",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "visibility": {+ "name": "visibility",+ "type": "agent_visibility",+ "typeSchema": "public",+ "primaryKey": false,+ "notNull": true+ },+ "callback_token_hash": {+ "name": "callback_token_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "callback_token_issued_at": {+ "name": "callback_token_issued_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_profiles_visibility_deleted_idx": {+ "name": "agent_profiles_visibility_deleted_idx",+ "columns": [+ {+ "expression": "visibility",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "deleted_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_profiles_agent_id_agents_id_fk": {+ "name": "agent_profiles_agent_id_agents_id_fk",+ "tableFrom": "agent_profiles",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_profiles_owner_user_id_users_id_fk": {+ "name": "agent_profiles_owner_user_id_users_id_fk",+ "tableFrom": "agent_profiles",+ "tableTo": "users",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.routine_runs": {+ "name": "routine_runs",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "routine_id": {+ "name": "routine_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "started_at": {+ "name": "started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "finished_at": {+ "name": "finished_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "routine_run_status",+ "typeSchema": "public",+ "primaryKey": false,+ "notNull": false+ },+ "waiting": {+ "name": "waiting",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "error": {+ "name": "error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'schedule'"+ }+ },+ "indexes": {+ "routine_runs_by_routine_idx": {+ "name": "routine_runs_by_routine_idx",+ "columns": [+ {+ "expression": "routine_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "started_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "routine_runs_routine_id_routines_id_fk": {+ "name": "routine_runs_routine_id_routines_id_fk",+ "tableFrom": "routine_runs",+ "tableTo": "routines",+ "columnsFrom": [+ "routine_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.routine_sweeps": {+ "name": "routine_sweeps",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "swept_at": {+ "name": "swept_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "owner": {+ "name": "owner",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.routines": {+ "name": "routines",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "channel_id": {+ "name": "channel_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "instruction": {+ "name": "instruction",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "cron": {+ "name": "cron",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "timezone": {+ "name": "timezone",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'UTC'"+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "next_run_at": {+ "name": "next_run_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "last_run_at": {+ "name": "last_run_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "enabled_at": {+ "name": "enabled_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": {+ "routines_due_idx": {+ "name": "routines_due_idx",+ "columns": [+ {+ "expression": "enabled",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "next_run_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "routines_by_owner_idx": {+ "name": "routines_by_owner_idx",+ "columns": [+ {+ "expression": "owner_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "enabled",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "routines_owner_user_id_users_id_fk": {+ "name": "routines_owner_user_id_users_id_fk",+ "tableFrom": "routines",+ "tableTo": "users",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "routines_agent_id_agents_id_fk": {+ "name": "routines_agent_id_agents_id_fk",+ "tableFrom": "routines",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.component_exclusions": {+ "name": "component_exclusions",+ "schema": "",+ "columns": {+ "component_name": {+ "name": "component_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "withheld_by": {+ "name": "withheld_by",+ "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": {},+ "foreignKeys": {+ "component_exclusions_component_name_components_name_fk": {+ "name": "component_exclusions_component_name_components_name_fk",+ "tableFrom": "component_exclusions",+ "tableTo": "components",+ "columnsFrom": [+ "component_name"+ ],+ "columnsTo": [+ "name"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "component_exclusions_agent_id_agents_id_fk": {+ "name": "component_exclusions_agent_id_agents_id_fk",+ "tableFrom": "component_exclusions",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "component_exclusions_component_name_agent_id_pk": {+ "name": "component_exclusions_component_name_agent_id_pk",+ "columns": [+ "component_name",+ "agent_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.component_functions": {+ "name": "component_functions",+ "schema": "",+ "columns": {+ "component_name": {+ "name": "component_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "function_name": {+ "name": "function_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "granted_by": {+ "name": "granted_by",+ "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": {},+ "foreignKeys": {+ "component_functions_component_name_components_name_fk": {+ "name": "component_functions_component_name_components_name_fk",+ "tableFrom": "component_functions",+ "tableTo": "components",+ "columnsFrom": [+ "component_name"+ ],+ "columnsTo": [+ "name"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "component_functions_component_name_function_name_pk": {+ "name": "component_functions_component_name_function_name_pk",+ "columns": [+ "component_name",+ "function_name"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.components": {+ "name": "components",+ "schema": "",+ "columns": {+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "draft_description": {+ "name": "draft_description",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "published_description": {+ "name": "published_description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "published": {+ "name": "published",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "published_at": {+ "name": "published_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "updated_by": {+ "name": "updated_by",+ "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": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.brokered_connections": {+ "name": "brokered_connections",+ "schema": "",+ "columns": {+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "app": {+ "name": "app",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "holder": {+ "name": "holder",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "vendor_user_id": {+ "name": "vendor_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "connected_by": {+ "name": "connected_by",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "connected_at": {+ "name": "connected_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "verified": {+ "name": "verified",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "verified_at": {+ "name": "verified_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "probe_action": {+ "name": "probe_action",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "brokered_connections_person_idx": {+ "name": "brokered_connections_person_idx",+ "columns": [+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "app",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"brokered_connections\".\"holder\" = 'person'",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "brokered_connections_deployment_idx": {+ "name": "brokered_connections_deployment_idx",+ "columns": [+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "app",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"brokered_connections\".\"holder\" = 'deployment'",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "brokered_connections_user_idx": {+ "name": "brokered_connections_user_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "brokered_connections_holder_check": {+ "name": "brokered_connections_holder_check",+ "value": "(\"brokered_connections\".\"holder\" = 'person' AND \"brokered_connections\".\"user_id\" IS NOT NULL) OR (\"brokered_connections\".\"holder\" = 'deployment' AND \"brokered_connections\".\"user_id\" IS NULL)"+ },+ "brokered_connections_provider_check": {+ "name": "brokered_connections_provider_check",+ "value": "\"brokered_connections\".\"provider\" IN ('composio')"+ }+ },+ "isRLSEnabled": false+ },+ "public.composio_connections": {+ "name": "composio_connections",+ "schema": "",+ "columns": {+ "toolkit": {+ "name": "toolkit",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "connected_at": {+ "name": "connected_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "verified": {+ "name": "verified",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "verified_at": {+ "name": "verified_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "probe_action": {+ "name": "probe_action",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "composio_connections_user_idx": {+ "name": "composio_connections_user_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "composio_connections_toolkit_user_id_pk": {+ "name": "composio_connections_toolkit_user_id_pk",+ "columns": [+ "toolkit",+ "user_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.mcp_servers": {+ "name": "mcp_servers",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "logo": {+ "name": "logo",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "vendor": {+ "name": "vendor",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "url": {+ "name": "url",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "provenance": {+ "name": "provenance",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'first-party'"+ },+ "credential_id": {+ "name": "credential_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "auth_scheme": {+ "name": "auth_scheme",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "account_mode": {+ "name": "account_mode",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "shared_vendor_user_id": {+ "name": "shared_vendor_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "tools_refreshed_at": {+ "name": "tools_refreshed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "last_error": {+ "name": "last_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "added_by": {+ "name": "added_by",+ "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": {},+ "foreignKeys": {+ "mcp_servers_credential_id_credentials_id_fk": {+ "name": "mcp_servers_credential_id_credentials_id_fk",+ "tableFrom": "mcp_servers",+ "tableTo": "credentials",+ "columnsFrom": [+ "credential_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "restrict",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "mcp_servers_account_mode_check": {+ "name": "mcp_servers_account_mode_check",+ "value": "\"mcp_servers\".\"account_mode\" IS NULL OR \"mcp_servers\".\"account_mode\" IN ('personal', 'shared')"+ }+ },+ "isRLSEnabled": false+ },+ "public.mcp_tools": {+ "name": "mcp_tools",+ "schema": "",+ "columns": {+ "server_id": {+ "name": "server_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "input_schema": {+ "name": "input_schema",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "effect": {+ "name": "effect",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "destructive": {+ "name": "destructive",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "version": {+ "name": "version",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "mcp_tools_server_id_mcp_servers_id_fk": {+ "name": "mcp_tools_server_id_mcp_servers_id_fk",+ "tableFrom": "mcp_tools",+ "tableTo": "mcp_servers",+ "columnsFrom": [+ "server_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "mcp_tools_server_id_name_pk": {+ "name": "mcp_tools_server_id_name_pk",+ "columns": [+ "server_id",+ "name"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.mcp_user_credentials": {+ "name": "mcp_user_credentials",+ "schema": "",+ "columns": {+ "server_id": {+ "name": "server_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "credential_id": {+ "name": "credential_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "scope": {+ "name": "scope",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "connected_at": {+ "name": "connected_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": {+ "mcp_user_credentials_user_idx": {+ "name": "mcp_user_credentials_user_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "mcp_user_credentials_server_id_mcp_servers_id_fk": {+ "name": "mcp_user_credentials_server_id_mcp_servers_id_fk",+ "tableFrom": "mcp_user_credentials",+ "tableTo": "mcp_servers",+ "columnsFrom": [+ "server_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "mcp_user_credentials_user_id_users_id_fk": {+ "name": "mcp_user_credentials_user_id_users_id_fk",+ "tableFrom": "mcp_user_credentials",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "mcp_user_credentials_credential_id_credentials_id_fk": {+ "name": "mcp_user_credentials_credential_id_credentials_id_fk",+ "tableFrom": "mcp_user_credentials",+ "tableTo": "credentials",+ "columnsFrom": [+ "credential_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "mcp_user_credentials_server_id_user_id_pk": {+ "name": "mcp_user_credentials_server_id_user_id_pk",+ "columns": [+ "server_id",+ "user_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.plugin_grants": {+ "name": "plugin_grants",+ "schema": "",+ "columns": {+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "ref": {+ "name": "ref",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "granted_by": {+ "name": "granted_by",+ "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": {+ "plugin_grants_agent_idx": {+ "name": "plugin_grants_agent_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "plugin_grants_agent_id_agents_id_fk": {+ "name": "plugin_grants_agent_id_agents_id_fk",+ "tableFrom": "plugin_grants",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "plugin_grants_kind_ref_agent_id_pk": {+ "name": "plugin_grants_kind_ref_agent_id_pk",+ "columns": [+ "kind",+ "ref",+ "agent_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.sandboxed_components": {+ "name": "sandboxed_components",+ "schema": "",+ "columns": {+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "draft_description": {+ "name": "draft_description",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "draft_html": {+ "name": "draft_html",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "draft_css": {+ "name": "draft_css",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "draft_js_functions": {+ "name": "draft_js_functions",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "draft_argument_schema": {+ "name": "draft_argument_schema",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "published_description": {+ "name": "published_description",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "published_html": {+ "name": "published_html",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "published_css": {+ "name": "published_css",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "published_js_functions": {+ "name": "published_js_functions",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "published_argument_schema": {+ "name": "published_argument_schema",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "sample_arguments": {+ "name": "sample_arguments",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "revision": {+ "name": "revision",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "published": {+ "name": "published",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "published_at": {+ "name": "published_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "authored_by": {+ "name": "authored_by",+ "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": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.skill_tools": {+ "name": "skill_tools",+ "schema": "",+ "columns": {+ "skill_id": {+ "name": "skill_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "ref": {+ "name": "ref",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "declared_by": {+ "name": "declared_by",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "skill_tools_ref_idx": {+ "name": "skill_tools_ref_idx",+ "columns": [+ {+ "expression": "ref",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "skill_tools_skill_id_skills_id_fk": {+ "name": "skill_tools_skill_id_skills_id_fk",+ "tableFrom": "skill_tools",+ "tableTo": "skills",+ "columnsFrom": [+ "skill_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "skill_tools_skill_id_ref_pk": {+ "name": "skill_tools_skill_id_ref_pk",+ "columns": [+ "skill_id",+ "ref"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.skills": {+ "name": "skills",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "slug": {+ "name": "slug",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "summary": {+ "name": "summary",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "instructions": {+ "name": "instructions",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "origin": {+ "name": "origin",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'yours'"+ },+ "installed_by": {+ "name": "installed_by",+ "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": {+ "skills_slug_key": {+ "name": "skills_slug_key",+ "columns": [+ {+ "expression": "slug",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "skills_owner_idx": {+ "name": "skills_owner_idx",+ "columns": [+ {+ "expression": "owner_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "skills_owner_user_id_users_id_fk": {+ "name": "skills_owner_user_id_users_id_fk",+ "tableFrom": "skills",+ "tableTo": "users",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.work_items": {+ "name": "work_items",+ "schema": "",+ "columns": {+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "key": {+ "name": "key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "run_at": {+ "name": "run_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "claimed_by": {+ "name": "claimed_by",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "lease_until": {+ "name": "lease_until",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "attempts": {+ "name": "attempts",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "finished_at": {+ "name": "finished_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "last_error": {+ "name": "last_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "payload": {+ "name": "payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "work_items_claimable_idx": {+ "name": "work_items_claimable_idx",+ "columns": [+ {+ "expression": "kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "run_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "work_items_kind_key_pk": {+ "name": "work_items_kind_key_pk",+ "columns": [+ "kind",+ "key"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.voice_sessions": {+ "name": "voice_sessions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "channel_id": {+ "name": "channel_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "anchor_message_id": {+ "name": "anchor_message_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "started_at": {+ "name": "started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "ended_at": {+ "name": "ended_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "duration_seconds": {+ "name": "duration_seconds",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "transcript": {+ "name": "transcript",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "summary": {+ "name": "summary",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "summary_status": {+ "name": "summary_status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'failed'"+ }+ },+ "indexes": {+ "voice_sessions_channel_started_idx": {+ "name": "voice_sessions_channel_started_idx",+ "columns": [+ {+ "expression": "channel_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "started_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "voice_sessions_channel_id_channels_id_fk": {+ "name": "voice_sessions_channel_id_channels_id_fk",+ "tableFrom": "voice_sessions",+ "tableTo": "channels",+ "columnsFrom": [+ "channel_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "voice_sessions_user_id_users_id_fk": {+ "name": "voice_sessions_user_id_users_id_fk",+ "tableFrom": "voice_sessions",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "voice_sessions_duration_check": {+ "name": "voice_sessions_duration_check",+ "value": "\"voice_sessions\".\"duration_seconds\" >= 0"+ },+ "voice_sessions_summary_check": {+ "name": "voice_sessions_summary_check",+ "value": "(\"voice_sessions\".\"summary_status\" = 'ready' AND \"voice_sessions\".\"summary\" IS NOT NULL) OR (\"voice_sessions\".\"summary_status\" = 'failed' AND \"voice_sessions\".\"summary\" IS NULL)"+ }+ },+ "isRLSEnabled": false+ },+ "public.learning_settings": {+ "name": "learning_settings",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "settings": {+ "name": "settings",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.learning_thread_bindings": {+ "name": "learning_thread_bindings",+ "schema": "",+ "columns": {+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "thread_id": {+ "name": "thread_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "container_id": {+ "name": "container_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "learning_thread_bindings_user_id_thread_id_pk": {+ "name": "learning_thread_bindings_user_id_thread_id_pk",+ "columns": [+ "user_id",+ "thread_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.responsibilities": {+ "name": "responsibilities",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "channel_id": {+ "name": "channel_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "thread_id": {+ "name": "thread_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "instruction": {+ "name": "instruction",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "success_criteria": {+ "name": "success_criteria",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "responsibility_status",+ "typeSchema": "public",+ "primaryKey": false,+ "notNull": true,+ "default": "'active'"+ },+ "progress": {+ "name": "progress",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "last_result": {+ "name": "last_result",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "subscriptions": {+ "name": "subscriptions",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "completed_at": {+ "name": "completed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "responsibilities_owner_status_idx": {+ "name": "responsibilities_owner_status_idx",+ "columns": [+ {+ "expression": "owner_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "responsibilities_owner_user_id_users_id_fk": {+ "name": "responsibilities_owner_user_id_users_id_fk",+ "tableFrom": "responsibilities",+ "tableTo": "users",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "responsibilities_agent_id_agents_id_fk": {+ "name": "responsibilities_agent_id_agents_id_fk",+ "tableFrom": "responsibilities",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.responsibility_events": {+ "name": "responsibility_events",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "external_id": {+ "name": "external_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "payload": {+ "name": "payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "responsibility_events_source_id_idx": {+ "name": "responsibility_events_source_id_idx",+ "columns": [+ {+ "expression": "owner_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "external_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "responsibility_events_owner_user_id_users_id_fk": {+ "name": "responsibility_events_owner_user_id_users_id_fk",+ "tableFrom": "responsibility_events",+ "tableTo": "users",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.responsibility_runs": {+ "name": "responsibility_runs",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "responsibility_id": {+ "name": "responsibility_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "event_id": {+ "name": "event_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "responsibility_run_status",+ "typeSchema": "public",+ "primaryKey": false,+ "notNull": true,+ "default": "'queued'"+ },+ "reply_text": {+ "name": "reply_text",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "error": {+ "name": "error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "waiting": {+ "name": "waiting",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "continuation": {+ "name": "continuation",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "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+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "responsibility_runs_event_idx": {+ "name": "responsibility_runs_event_idx",+ "columns": [+ {+ "expression": "responsibility_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "event_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "responsibility_runs_status_idx": {+ "name": "responsibility_runs_status_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "responsibility_runs_responsibility_id_responsibilities_id_fk": {+ "name": "responsibility_runs_responsibility_id_responsibilities_id_fk",+ "tableFrom": "responsibility_runs",+ "tableTo": "responsibilities",+ "columnsFrom": [+ "responsibility_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "responsibility_runs_event_id_responsibility_events_id_fk": {+ "name": "responsibility_runs_event_id_responsibility_events_id_fk",+ "tableFrom": "responsibility_runs",+ "tableTo": "responsibility_events",+ "columnsFrom": [+ "event_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.responsibility_source_bindings": {+ "name": "responsibility_source_bindings",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "repository": {+ "name": "repository",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "credential_id": {+ "name": "credential_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "responsibility_source_bindings_owner_idx": {+ "name": "responsibility_source_bindings_owner_idx",+ "columns": [+ {+ "expression": "owner_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "responsibility_source_bindings_owner_user_id_users_id_fk": {+ "name": "responsibility_source_bindings_owner_user_id_users_id_fk",+ "tableFrom": "responsibility_source_bindings",+ "tableTo": "users",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "responsibility_source_bindings_credential_id_credentials_id_fk": {+ "name": "responsibility_source_bindings_credential_id_credentials_id_fk",+ "tableFrom": "responsibility_source_bindings",+ "tableTo": "credentials",+ "columnsFrom": [+ "credential_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.responsibility_triggers": {+ "name": "responsibility_triggers",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "responsibility_id": {+ "name": "responsibility_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "config": {+ "name": "config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "credential_id": {+ "name": "credential_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": 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": {+ "responsibility_triggers_owner_idx": {+ "name": "responsibility_triggers_owner_idx",+ "columns": [+ {+ "expression": "owner_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "responsibility_triggers_responsibility_idx": {+ "name": "responsibility_triggers_responsibility_idx",+ "columns": [+ {+ "expression": "responsibility_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "responsibility_triggers_kind_idx": {+ "name": "responsibility_triggers_kind_idx",+ "columns": [+ {+ "expression": "kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "responsibility_triggers_owner_user_id_users_id_fk": {+ "name": "responsibility_triggers_owner_user_id_users_id_fk",+ "tableFrom": "responsibility_triggers",+ "tableTo": "users",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "responsibility_triggers_responsibility_id_responsibilities_id_fk": {+ "name": "responsibility_triggers_responsibility_id_responsibilities_id_fk",+ "tableFrom": "responsibility_triggers",+ "tableTo": "responsibilities",+ "columnsFrom": [+ "responsibility_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "responsibility_triggers_credential_id_credentials_id_fk": {+ "name": "responsibility_triggers_credential_id_credentials_id_fk",+ "tableFrom": "responsibility_triggers",+ "tableTo": "credentials",+ "columnsFrom": [+ "credential_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.approval_preferences": {+ "name": "approval_preferences",+ "schema": "",+ "columns": {+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "auto_review": {+ "name": "auto_review",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "host_commands": {+ "name": "host_commands",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'ask'"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "approval_preferences_owner_user_id_users_id_fk": {+ "name": "approval_preferences_owner_user_id_users_id_fk",+ "tableFrom": "approval_preferences",+ "tableTo": "users",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "approval_preferences_host_commands_check": {+ "name": "approval_preferences_host_commands_check",+ "value": "\"approval_preferences\".\"host_commands\" IN ('ask', 'allow', 'never')"+ }+ },+ "isRLSEnabled": false+ },+ "public.approval_requests": {+ "name": "approval_requests",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "run_id": {+ "name": "run_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "tool_call_id": {+ "name": "tool_call_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "action_digest": {+ "name": "action_digest",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "action": {+ "name": "action",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "decision": {+ "name": "decision",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "result": {+ "name": "result",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "decided_at": {+ "name": "decided_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "consumed_at": {+ "name": "consumed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "completed_at": {+ "name": "completed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "approval_requests_action_idx": {+ "name": "approval_requests_action_idx",+ "columns": [+ {+ "expression": "owner_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "tool_call_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "approval_requests_inbox_idx": {+ "name": "approval_requests_inbox_idx",+ "columns": [+ {+ "expression": "owner_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "approval_requests_owner_user_id_users_id_fk": {+ "name": "approval_requests_owner_user_id_users_id_fk",+ "tableFrom": "approval_requests",+ "tableTo": "users",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "approval_status_check": {+ "name": "approval_status_check",+ "value": "\"approval_requests\".\"status\" IN ('pending', 'approved', 'denied', 'consumed', 'completed')"+ },+ "approval_decision_check": {+ "name": "approval_decision_check",+ "value": "\"approval_requests\".\"decision\" IN ('allow_once', 'allow_always', 'deny', 'handled')"+ }+ },+ "isRLSEnabled": false+ },+ "public.approval_rules": {+ "name": "approval_rules",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "bot_id": {+ "name": "bot_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "tool_ref": {+ "name": "tool_ref",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "effect": {+ "name": "effect",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "scope": {+ "name": "scope",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "behaviour": {+ "name": "behaviour",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'allow'"+ },+ "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": {+ "approval_rules_owner_idx": {+ "name": "approval_rules_owner_idx",+ "columns": [+ {+ "expression": "owner_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "approval_rules_owner_user_id_users_id_fk": {+ "name": "approval_rules_owner_user_id_users_id_fk",+ "tableFrom": "approval_rules",+ "tableTo": "users",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "approval_rules_behaviour_check": {+ "name": "approval_rules_behaviour_check",+ "value": "\"approval_rules\".\"behaviour\" IN ('allow', 'pre_approved', 'ask', 'hand_off')"+ }+ },+ "isRLSEnabled": false+ },+ "public.approval_team_rules": {+ "name": "approval_team_rules",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "bot_id": {+ "name": "bot_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "tool_ref": {+ "name": "tool_ref",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "effect": {+ "name": "effect",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "scope": {+ "name": "scope",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "behaviour": {+ "name": "behaviour",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_by": {+ "name": "created_by",+ "type": "text",+ "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": {},+ "foreignKeys": {+ "approval_team_rules_created_by_users_id_fk": {+ "name": "approval_team_rules_created_by_users_id_fk",+ "tableFrom": "approval_team_rules",+ "tableTo": "users",+ "columnsFrom": [+ "created_by"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "approval_team_rules_behaviour_check": {+ "name": "approval_team_rules_behaviour_check",+ "value": "\"approval_team_rules\".\"behaviour\" IN ('allow', 'pre_approved', 'ask', 'hand_off')"+ }+ },+ "isRLSEnabled": false+ },+ "public.approval_team_settings": {+ "name": "approval_team_settings",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "enforce_auto_review": {+ "name": "enforce_auto_review",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "custom_rules_enabled": {+ "name": "custom_rules_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "host_commands_cap": {+ "name": "host_commands_cap",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'allow'"+ },+ "updated_by": {+ "name": "updated_by",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "approval_team_settings_updated_by_users_id_fk": {+ "name": "approval_team_settings_updated_by_users_id_fk",+ "tableFrom": "approval_team_settings",+ "tableTo": "users",+ "columnsFrom": [+ "updated_by"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "approval_team_settings_host_commands_cap_check": {+ "name": "approval_team_settings_host_commands_cap_check",+ "value": "\"approval_team_settings\".\"host_commands_cap\" IN ('ask', 'allow', 'never')"+ }+ },+ "isRLSEnabled": false+ },+ "public.memory_sources": {+ "name": "memory_sources",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "tool_ref": {+ "name": "tool_ref",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "args": {+ "name": "args",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "sync_status": {+ "name": "sync_status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'idle'"+ },+ "sync_error": {+ "name": "sync_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "last_sync_at": {+ "name": "last_sync_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "next_sync_at": {+ "name": "next_sync_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": {+ "memory_sources_owner_idx": {+ "name": "memory_sources_owner_idx",+ "columns": [+ {+ "expression": "owner_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "memory_sources_due_idx": {+ "name": "memory_sources_due_idx",+ "columns": [+ {+ "expression": "enabled",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "next_sync_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "memory_sources_owner_user_id_users_id_fk": {+ "name": "memory_sources_owner_user_id_users_id_fk",+ "tableFrom": "memory_sources",+ "tableTo": "users",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "memory_sources_agent_id_agents_id_fk": {+ "name": "memory_sources_agent_id_agents_id_fk",+ "tableFrom": "memory_sources",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.personal_memories": {+ "name": "personal_memories",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source_id": {+ "name": "source_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "external_id": {+ "name": "external_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "import_digest": {+ "name": "import_digest",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "provenance": {+ "name": "provenance",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "review_state": {+ "name": "review_state",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'unreviewed'"+ },+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "formed_by": {+ "name": "formed_by",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'person'"+ },+ "formed_by_agent_id": {+ "name": "formed_by_agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "source_app": {+ "name": "source_app",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "source_ref": {+ "name": "source_ref",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "source_link": {+ "name": "source_link",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "observed_at": {+ "name": "observed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "intelligence_memory_id": {+ "name": "intelligence_memory_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "intelligence_digest": {+ "name": "intelligence_digest",+ "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": {+ "personal_memories_owner_idx": {+ "name": "personal_memories_owner_idx",+ "columns": [+ {+ "expression": "owner_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "enabled",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "personal_memories_intelligence_idx": {+ "name": "personal_memories_intelligence_idx",+ "columns": [+ {+ "expression": "owner_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "intelligence_memory_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "personal_memories_formed_idx": {+ "name": "personal_memories_formed_idx",+ "columns": [+ {+ "expression": "owner_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "formed_by_agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "personal_memories_import_idx": {+ "name": "personal_memories_import_idx",+ "columns": [+ {+ "expression": "source_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "external_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "personal_memories_formed_digest_idx": {+ "name": "personal_memories_formed_digest_idx",+ "columns": [+ {+ "expression": "owner_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "import_digest",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"personal_memories\".\"formed_by\" = 'bot'",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "personal_memories_owner_user_id_users_id_fk": {+ "name": "personal_memories_owner_user_id_users_id_fk",+ "tableFrom": "personal_memories",+ "tableTo": "users",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "personal_memories_source_id_memory_sources_id_fk": {+ "name": "personal_memories_source_id_memory_sources_id_fk",+ "tableFrom": "personal_memories",+ "tableTo": "memory_sources",+ "columnsFrom": [+ "source_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "personal_memories_formed_by_agent_id_agents_id_fk": {+ "name": "personal_memories_formed_by_agent_id_agents_id_fk",+ "tableFrom": "personal_memories",+ "tableTo": "agents",+ "columnsFrom": [+ "formed_by_agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.proactive_settings": {+ "name": "proactive_settings",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "channel_id": {+ "name": "channel_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "thread_id": {+ "name": "thread_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "focus": {+ "name": "focus",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "interval_minutes": {+ "name": "interval_minutes",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 240+ },+ "next_run_at": {+ "name": "next_run_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "last_run_at": {+ "name": "last_run_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "last_status": {+ "name": "last_status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'idle'"+ },+ "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": {+ "proactive_settings_owner_agent_idx": {+ "name": "proactive_settings_owner_agent_idx",+ "columns": [+ {+ "expression": "owner_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "proactive_settings_due_idx": {+ "name": "proactive_settings_due_idx",+ "columns": [+ {+ "expression": "enabled",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "next_run_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "proactive_settings_owner_user_id_users_id_fk": {+ "name": "proactive_settings_owner_user_id_users_id_fk",+ "tableFrom": "proactive_settings",+ "tableTo": "users",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "proactive_settings_agent_id_agents_id_fk": {+ "name": "proactive_settings_agent_id_agents_id_fk",+ "tableFrom": "proactive_settings",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "proactive_settings_interval_check": {+ "name": "proactive_settings_interval_check",+ "value": "\"proactive_settings\".\"interval_minutes\" >= 60 AND \"proactive_settings\".\"interval_minutes\" <= 1440"+ },+ "proactive_settings_status_check": {+ "name": "proactive_settings_status_check",+ "value": "\"proactive_settings\".\"last_status\" IN ('idle', 'running', 'succeeded', 'error')"+ }+ },+ "isRLSEnabled": false+ },+ "public.proactive_suggestions": {+ "name": "proactive_suggestions",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "setting_id": {+ "name": "setting_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "run_id": {+ "name": "run_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "detail": {+ "name": "detail",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source_app": {+ "name": "source_app",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "source_ref": {+ "name": "source_ref",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "source_link": {+ "name": "source_link",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'open'"+ },+ "delivered_at": {+ "name": "delivered_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "resolved_at": {+ "name": "resolved_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": {+ "proactive_suggestions_owner_idx": {+ "name": "proactive_suggestions_owner_idx",+ "columns": [+ {+ "expression": "owner_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "proactive_suggestions_run_idx": {+ "name": "proactive_suggestions_run_idx",+ "columns": [+ {+ "expression": "run_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "proactive_suggestions_owner_user_id_users_id_fk": {+ "name": "proactive_suggestions_owner_user_id_users_id_fk",+ "tableFrom": "proactive_suggestions",+ "tableTo": "users",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "proactive_suggestions_agent_id_agents_id_fk": {+ "name": "proactive_suggestions_agent_id_agents_id_fk",+ "tableFrom": "proactive_suggestions",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "proactive_suggestions_setting_id_proactive_settings_id_fk": {+ "name": "proactive_suggestions_setting_id_proactive_settings_id_fk",+ "tableFrom": "proactive_suggestions",+ "tableTo": "proactive_settings",+ "columnsFrom": [+ "setting_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "proactive_suggestions_status_check": {+ "name": "proactive_suggestions_status_check",+ "value": "\"proactive_suggestions\".\"status\" IN ('open', 'dismissed', 'started')"+ }+ },+ "isRLSEnabled": false+ },+ "public.demonstrations": {+ "name": "demonstrations",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "bot_id": {+ "name": "bot_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'recording'"+ },+ "actions": {+ "name": "actions",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "draft": {+ "name": "draft",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "skill_slug": {+ "name": "skill_slug",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "finished_at": {+ "name": "finished_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "demonstrations_owner_idx": {+ "name": "demonstrations_owner_idx",+ "columns": [+ {+ "expression": "owner_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "demonstrations_active_bot_idx": {+ "name": "demonstrations_active_bot_idx",+ "columns": [+ {+ "expression": "bot_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"demonstrations\".\"status\" = 'recording'",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "demonstrations_owner_user_id_users_id_fk": {+ "name": "demonstrations_owner_user_id_users_id_fk",+ "tableFrom": "demonstrations",+ "tableTo": "users",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "demonstrations_bot_id_agents_id_fk": {+ "name": "demonstrations_bot_id_agents_id_fk",+ "tableFrom": "demonstrations",+ "tableTo": "agents",+ "columnsFrom": [+ "bot_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.delivery_bindings": {+ "name": "delivery_bindings",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "channel_id": {+ "name": "channel_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "thread_id": {+ "name": "thread_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "transport": {+ "name": "transport",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "identity": {+ "name": "identity",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "realm": {+ "name": "realm",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "address": {+ "name": "address",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "mention_id": {+ "name": "mention_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "opted_out_at": {+ "name": "opted_out_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": {+ "delivery_binding_identity_idx": {+ "name": "delivery_binding_identity_idx",+ "columns": [+ {+ "expression": "transport",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "realm",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "identity",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "delivery_bindings_owner_idx": {+ "name": "delivery_bindings_owner_idx",+ "columns": [+ {+ "expression": "owner_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "delivery_bindings_owner_user_id_users_id_fk": {+ "name": "delivery_bindings_owner_user_id_users_id_fk",+ "tableFrom": "delivery_bindings",+ "tableTo": "users",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "delivery_bindings_channel_id_channels_id_fk": {+ "name": "delivery_bindings_channel_id_channels_id_fk",+ "tableFrom": "delivery_bindings",+ "tableTo": "channels",+ "columnsFrom": [+ "channel_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "delivery_bindings_agent_id_agents_id_fk": {+ "name": "delivery_bindings_agent_id_agents_id_fk",+ "tableFrom": "delivery_bindings",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.delivery_challenges": {+ "name": "delivery_challenges",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "channel_id": {+ "name": "channel_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "thread_id": {+ "name": "thread_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "transport": {+ "name": "transport",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "address": {+ "name": "address",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "consumed_at": {+ "name": "consumed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "delivery_challenges_owner_user_id_users_id_fk": {+ "name": "delivery_challenges_owner_user_id_users_id_fk",+ "tableFrom": "delivery_challenges",+ "tableTo": "users",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "delivery_challenges_channel_id_channels_id_fk": {+ "name": "delivery_challenges_channel_id_channels_id_fk",+ "tableFrom": "delivery_challenges",+ "tableTo": "channels",+ "columnsFrom": [+ "channel_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "delivery_challenges_agent_id_agents_id_fk": {+ "name": "delivery_challenges_agent_id_agents_id_fk",+ "tableFrom": "delivery_challenges",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.delivery_inbox": {+ "name": "delivery_inbox",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "channel_id": {+ "name": "channel_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "thread_id": {+ "name": "thread_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "binding_id": {+ "name": "binding_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "realm": {+ "name": "realm",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "external_id": {+ "name": "external_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "text": {+ "name": "text",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "state": {+ "name": "state",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'queued'"+ },+ "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()"+ }+ },+ "indexes": {+ "delivery_inbox_dedupe_idx": {+ "name": "delivery_inbox_dedupe_idx",+ "columns": [+ {+ "expression": "source",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "realm",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "external_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "delivery_inbox_owner_idx": {+ "name": "delivery_inbox_owner_idx",+ "columns": [+ {+ "expression": "owner_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "delivery_inbox_owner_user_id_users_id_fk": {+ "name": "delivery_inbox_owner_user_id_users_id_fk",+ "tableFrom": "delivery_inbox",+ "tableTo": "users",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "delivery_inbox_channel_id_channels_id_fk": {+ "name": "delivery_inbox_channel_id_channels_id_fk",+ "tableFrom": "delivery_inbox",+ "tableTo": "channels",+ "columnsFrom": [+ "channel_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "delivery_inbox_agent_id_agents_id_fk": {+ "name": "delivery_inbox_agent_id_agents_id_fk",+ "tableFrom": "delivery_inbox",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.delivery_outbox": {+ "name": "delivery_outbox",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "channel_id": {+ "name": "channel_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "thread_id": {+ "name": "thread_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "dedupe_key": {+ "name": "dedupe_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "binding_id": {+ "name": "binding_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "device_id": {+ "name": "device_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "transport": {+ "name": "transport",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "text": {+ "name": "text",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "request_id": {+ "name": "request_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "state": {+ "name": "state",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'queued'"+ },+ "provider_id": {+ "name": "provider_id",+ "type": "text",+ "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()"+ }+ },+ "indexes": {+ "delivery_outbox_owner_idx": {+ "name": "delivery_outbox_owner_idx",+ "columns": [+ {+ "expression": "owner_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "delivery_outbox_provider_idx": {+ "name": "delivery_outbox_provider_idx",+ "columns": [+ {+ "expression": "transport",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "delivery_outbox_owner_user_id_users_id_fk": {+ "name": "delivery_outbox_owner_user_id_users_id_fk",+ "tableFrom": "delivery_outbox",+ "tableTo": "users",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "delivery_outbox_channel_id_channels_id_fk": {+ "name": "delivery_outbox_channel_id_channels_id_fk",+ "tableFrom": "delivery_outbox",+ "tableTo": "channels",+ "columnsFrom": [+ "channel_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "delivery_outbox_agent_id_agents_id_fk": {+ "name": "delivery_outbox_agent_id_agents_id_fk",+ "tableFrom": "delivery_outbox",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "delivery_outbox_dedupe_key_unique": {+ "name": "delivery_outbox_dedupe_key_unique",+ "nullsNotDistinct": false,+ "columns": [+ "dedupe_key"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.push_devices": {+ "name": "push_devices",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "token": {+ "name": "token",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "platform": {+ "name": "platform",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "push_devices_owner_idx": {+ "name": "push_devices_owner_idx",+ "columns": [+ {+ "expression": "owner_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "push_devices_owner_user_id_users_id_fk": {+ "name": "push_devices_owner_user_id_users_id_fk",+ "tableFrom": "push_devices",+ "tableTo": "users",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "push_devices_token_unique": {+ "name": "push_devices_token_unique",+ "nullsNotDistinct": false,+ "columns": [+ "token"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.group_bot_threads": {+ "name": "group_bot_threads",+ "schema": "",+ "columns": {+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "channel_id": {+ "name": "channel_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "thread_id": {+ "name": "thread_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "group_bot_threads_thread_idx": {+ "name": "group_bot_threads_thread_idx",+ "columns": [+ {+ "expression": "thread_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "group_bot_threads_owner_user_id_users_id_fk": {+ "name": "group_bot_threads_owner_user_id_users_id_fk",+ "tableFrom": "group_bot_threads",+ "tableTo": "users",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "group_bot_threads_channel_id_channels_id_fk": {+ "name": "group_bot_threads_channel_id_channels_id_fk",+ "tableFrom": "group_bot_threads",+ "tableTo": "channels",+ "columnsFrom": [+ "channel_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "group_bot_threads_owner_user_id_channel_id_agent_id_pk": {+ "name": "group_bot_threads_owner_user_id_channel_id_agent_id_pk",+ "columns": [+ "owner_user_id",+ "channel_id",+ "agent_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.group_messages": {+ "name": "group_messages",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "channel_id": {+ "name": "channel_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "thread_id": {+ "name": "thread_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "text": {+ "name": "text",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'completed'"+ },+ "details": {+ "name": "details",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "group_messages_channel_idx": {+ "name": "group_messages_channel_idx",+ "columns": [+ {+ "expression": "channel_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "group_messages_channel_id_channels_id_fk": {+ "name": "group_messages_channel_id_channels_id_fk",+ "tableFrom": "group_messages",+ "tableTo": "channels",+ "columnsFrom": [+ "channel_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "group_messages_owner_user_id_users_id_fk": {+ "name": "group_messages_owner_user_id_users_id_fk",+ "tableFrom": "group_messages",+ "tableTo": "users",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "group_messages_status_check": {+ "name": "group_messages_status_check",+ "value": "\"group_messages\".\"status\" IN ('queued', 'running', 'waiting', 'completed', 'failed')"+ }+ },+ "isRLSEnabled": false+ },+ "public.action_records": {+ "name": "action_records",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "surface": {+ "name": "surface",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "bot_id": {+ "name": "bot_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "actor_user_id": {+ "name": "actor_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "tool_name": {+ "name": "tool_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "command": {+ "name": "command",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "outcome": {+ "name": "outcome",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "action_records_created_idx": {+ "name": "action_records_created_idx",+ "columns": [+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "action_records_bot_idx": {+ "name": "action_records_bot_idx",+ "columns": [+ {+ "expression": "bot_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "action_records_surface_check": {+ "name": "action_records_surface_check",+ "value": "\"action_records\".\"surface\" IN ('cloud', 'local')"+ }+ },+ "isRLSEnabled": false+ },+ "public.capability_settings": {+ "name": "capability_settings",+ "schema": "",+ "columns": {+ "scope_kind": {+ "name": "scope_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "scope_id": {+ "name": "scope_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "capability": {+ "name": "capability",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "allowed": {+ "name": "allowed",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true+ },+ "updated_by": {+ "name": "updated_by",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "capability_settings_scope_kind_scope_id_capability_pk": {+ "name": "capability_settings_scope_kind_scope_id_capability_pk",+ "columns": [+ "scope_kind",+ "scope_id",+ "capability"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "capability_settings_scope_kind_check": {+ "name": "capability_settings_scope_kind_check",+ "value": "\"capability_settings\".\"scope_kind\" IN ('organization', 'role', 'group')"+ }+ },+ "isRLSEnabled": false+ },+ "public.enterprise_settings": {+ "name": "enterprise_settings",+ "schema": "",+ "columns": {+ "key": {+ "name": "key",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "value": {+ "name": "value",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "updated_by": {+ "name": "updated_by",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.model_usage": {+ "name": "model_usage",+ "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": false+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "thread_id": {+ "name": "thread_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "run_id": {+ "name": "run_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "model": {+ "name": "model",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "allowed": {+ "name": "allowed",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "model_usage_created_idx": {+ "name": "model_usage_created_idx",+ "columns": [+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "model_usage_model_idx": {+ "name": "model_usage_model_idx",+ "columns": [+ {+ "expression": "model",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "model_usage_source_check": {+ "name": "model_usage_source_check",+ "value": "\"model_usage\".\"source\" IN ('configured', 'observed', 'unknown')"+ }+ },+ "isRLSEnabled": false+ },+ "public.network_policies": {+ "name": "network_policies",+ "schema": "",+ "columns": {+ "scope_kind": {+ "name": "scope_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "scope_id": {+ "name": "scope_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "mode": {+ "name": "mode",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "rules": {+ "name": "rules",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{\"entries\":[]}'::jsonb"+ },+ "locked": {+ "name": "locked",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "updated_by": {+ "name": "updated_by",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "network_policies_scope_kind_scope_id_pk": {+ "name": "network_policies_scope_kind_scope_id_pk",+ "columns": [+ "scope_kind",+ "scope_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "network_policies_scope_kind_check": {+ "name": "network_policies_scope_kind_check",+ "value": "\"network_policies\".\"scope_kind\" IN ('organization', 'group')"+ },+ "network_policies_mode_check": {+ "name": "network_policies_mode_check",+ "value": "\"network_policies\".\"mode\" IN ('allow_all', 'defaults_plus_allowlist', 'allowlist_only')"+ }+ },+ "isRLSEnabled": false+ },+ "public.scim_connection_bindings": {+ "name": "scim_connection_bindings",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "connection_id": {+ "name": "connection_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "connection_key": {+ "name": "connection_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "provisioning_domain_id": {+ "name": "provisioning_domain_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "decommissioned_at": {+ "name": "decommissioned_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "decommission_status": {+ "name": "decommission_status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'active'"+ },+ "decommission_cursor_user_id": {+ "name": "decommission_cursor_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "decommission_reconciled_user_count": {+ "name": "decommission_reconciled_user_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "decommission_batch_count": {+ "name": "decommission_batch_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "decommission_revision": {+ "name": "decommission_revision",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "decommission_completed_at": {+ "name": "decommission_completed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "decommission_lease_id": {+ "name": "decommission_lease_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "decommission_lease_expires_at": {+ "name": "decommission_lease_expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "scim_connection_bindings_connection_idx": {+ "name": "scim_connection_bindings_connection_idx",+ "columns": [+ {+ "expression": "connection_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "scim_connection_bindings_connection_key_unique": {+ "name": "scim_connection_bindings_connection_key_unique",+ "nullsNotDistinct": false,+ "columns": [+ "connection_key"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.scim_group_members": {+ "name": "scim_group_members",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "connection_id": {+ "name": "connection_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "group_id": {+ "name": "group_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "scim_user_id": {+ "name": "scim_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "membership_key": {+ "name": "membership_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "scim_group_members_connection_idx": {+ "name": "scim_group_members_connection_idx",+ "columns": [+ {+ "expression": "connection_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "scim_group_members_group_idx": {+ "name": "scim_group_members_group_idx",+ "columns": [+ {+ "expression": "group_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "scim_group_members_scim_user_idx": {+ "name": "scim_group_members_scim_user_idx",+ "columns": [+ {+ "expression": "scim_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "scim_group_members_group_id_scim_groups_id_fk": {+ "name": "scim_group_members_group_id_scim_groups_id_fk",+ "tableFrom": "scim_group_members",+ "tableTo": "scim_groups",+ "columnsFrom": [+ "group_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "scim_group_members_scim_user_id_scim_users_id_fk": {+ "name": "scim_group_members_scim_user_id_scim_users_id_fk",+ "tableFrom": "scim_group_members",+ "tableTo": "scim_users",+ "columnsFrom": [+ "scim_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "scim_group_members_membership_key_unique": {+ "name": "scim_group_members_membership_key_unique",+ "nullsNotDistinct": false,+ "columns": [+ "membership_key"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.scim_groups": {+ "name": "scim_groups",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "connection_id": {+ "name": "connection_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "provisioning_domain_id": {+ "name": "provisioning_domain_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "revision": {+ "name": "revision",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "display_name": {+ "name": "display_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "display_name_key": {+ "name": "display_name_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "external_id": {+ "name": "external_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "external_id_key": {+ "name": "external_id_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "order_key": {+ "name": "order_key",+ "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+ }+ },+ "indexes": {+ "scim_groups_connection_idx": {+ "name": "scim_groups_connection_idx",+ "columns": [+ {+ "expression": "connection_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "scim_groups_domain_idx": {+ "name": "scim_groups_domain_idx",+ "columns": [+ {+ "expression": "provisioning_domain_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "scim_groups_display_name_key_unique": {+ "name": "scim_groups_display_name_key_unique",+ "nullsNotDistinct": false,+ "columns": [+ "display_name_key"+ ]+ },+ "scim_groups_external_id_key_unique": {+ "name": "scim_groups_external_id_key_unique",+ "nullsNotDistinct": false,+ "columns": [+ "external_id_key"+ ]+ },+ "scim_groups_order_key_unique": {+ "name": "scim_groups_order_key_unique",+ "nullsNotDistinct": false,+ "columns": [+ "order_key"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.scim_identity_tombstones": {+ "name": "scim_identity_tombstones",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "connection_id": {+ "name": "connection_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "provisioning_domain_id": {+ "name": "provisioning_domain_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "external_id": {+ "name": "external_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "external_id_key": {+ "name": "external_id_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "profile": {+ "name": "profile",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "deleted_at": {+ "name": "deleted_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "scim_identity_tombstones_connection_idx": {+ "name": "scim_identity_tombstones_connection_idx",+ "columns": [+ {+ "expression": "connection_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "scim_identity_tombstones_domain_idx": {+ "name": "scim_identity_tombstones_domain_idx",+ "columns": [+ {+ "expression": "provisioning_domain_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "scim_identity_tombstones_user_idx": {+ "name": "scim_identity_tombstones_user_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "scim_identity_tombstones_user_id_users_id_fk": {+ "name": "scim_identity_tombstones_user_id_users_id_fk",+ "tableFrom": "scim_identity_tombstones",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "scim_identity_tombstones_external_id_key_unique": {+ "name": "scim_identity_tombstones_external_id_key_unique",+ "nullsNotDistinct": false,+ "columns": [+ "external_id_key"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.scim_projection_grants": {+ "name": "scim_projection_grants",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "connection_id": {+ "name": "connection_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "provisioning_domain_id": {+ "name": "provisioning_domain_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "scim_user_id": {+ "name": "scim_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source_kind": {+ "name": "source_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source_id": {+ "name": "source_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source_value": {+ "name": "source_value",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "grant_key": {+ "name": "grant_key",+ "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+ }+ },+ "indexes": {+ "scim_projection_grants_connection_idx": {+ "name": "scim_projection_grants_connection_idx",+ "columns": [+ {+ "expression": "connection_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "scim_projection_grants_domain_idx": {+ "name": "scim_projection_grants_domain_idx",+ "columns": [+ {+ "expression": "provisioning_domain_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "scim_projection_grants_scim_user_idx": {+ "name": "scim_projection_grants_scim_user_idx",+ "columns": [+ {+ "expression": "scim_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "scim_projection_grants_user_idx": {+ "name": "scim_projection_grants_user_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "scim_projection_grants_scim_user_id_scim_users_id_fk": {+ "name": "scim_projection_grants_scim_user_id_scim_users_id_fk",+ "tableFrom": "scim_projection_grants",+ "tableTo": "scim_users",+ "columnsFrom": [+ "scim_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "scim_projection_grants_user_id_users_id_fk": {+ "name": "scim_projection_grants_user_id_users_id_fk",+ "tableFrom": "scim_projection_grants",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "scim_projection_grants_grant_key_unique": {+ "name": "scim_projection_grants_grant_key_unique",+ "nullsNotDistinct": false,+ "columns": [+ "grant_key"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.scim_subjects": {+ "name": "scim_subjects",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "profile_source_id": {+ "name": "profile_source_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "revision": {+ "name": "revision",+ "type": "integer",+ "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+ }+ },+ "indexes": {+ "scim_subjects_profile_source_idx": {+ "name": "scim_subjects_profile_source_idx",+ "columns": [+ {+ "expression": "profile_source_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "scim_subjects_user_id_users_id_fk": {+ "name": "scim_subjects_user_id_users_id_fk",+ "tableFrom": "scim_subjects",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "scim_subjects_user_id_unique": {+ "name": "scim_subjects_user_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "user_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.scim_users": {+ "name": "scim_users",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "connection_id": {+ "name": "connection_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "provisioning_domain_id": {+ "name": "provisioning_domain_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "connection_user_key": {+ "name": "connection_user_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_name": {+ "name": "user_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_name_key": {+ "name": "user_name_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "primary_email": {+ "name": "primary_email",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "work_email_value_index": {+ "name": "work_email_value_index",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "email_value_index": {+ "name": "email_value_index",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "display_name": {+ "name": "display_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "formatted_name": {+ "name": "formatted_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "given_name": {+ "name": "given_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "family_name": {+ "name": "family_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "serialized_emails": {+ "name": "serialized_emails",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "serialized_attributes": {+ "name": "serialized_attributes",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "external_id": {+ "name": "external_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "external_id_key": {+ "name": "external_id_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "active": {+ "name": "active",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true+ },+ "order_key": {+ "name": "order_key",+ "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+ }+ },+ "indexes": {+ "scim_users_connection_idx": {+ "name": "scim_users_connection_idx",+ "columns": [+ {+ "expression": "connection_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "scim_users_domain_idx": {+ "name": "scim_users_domain_idx",+ "columns": [+ {+ "expression": "provisioning_domain_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "scim_users_user_idx": {+ "name": "scim_users_user_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "scim_users_user_id_users_id_fk": {+ "name": "scim_users_user_id_users_id_fk",+ "tableFrom": "scim_users",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "scim_users_connection_user_key_unique": {+ "name": "scim_users_connection_user_key_unique",+ "nullsNotDistinct": false,+ "columns": [+ "connection_user_key"+ ]+ },+ "scim_users_user_name_key_unique": {+ "name": "scim_users_user_name_key_unique",+ "nullsNotDistinct": false,+ "columns": [+ "user_name_key"+ ]+ },+ "scim_users_external_id_key_unique": {+ "name": "scim_users_external_id_key_unique",+ "nullsNotDistinct": false,+ "columns": [+ "external_id_key"+ ]+ },+ "scim_users_order_key_unique": {+ "name": "scim_users_order_key_unique",+ "nullsNotDistinct": false,+ "columns": [+ "order_key"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.bot_lifecycle": {+ "name": "bot_lifecycle",+ "schema": "",+ "columns": {+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "paused_at": {+ "name": "paused_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "notify": {+ "name": "notify",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'all'"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "bot_lifecycle_owner_user_id_users_id_fk": {+ "name": "bot_lifecycle_owner_user_id_users_id_fk",+ "tableFrom": "bot_lifecycle",+ "tableTo": "users",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "bot_lifecycle_agent_id_agents_id_fk": {+ "name": "bot_lifecycle_agent_id_agents_id_fk",+ "tableFrom": "bot_lifecycle",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "bot_lifecycle_owner_user_id_agent_id_pk": {+ "name": "bot_lifecycle_owner_user_id_agent_id_pk",+ "columns": [+ "owner_user_id",+ "agent_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.update_routing_preferences": {+ "name": "update_routing_preferences",+ "schema": "",+ "columns": {+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "transports": {+ "name": "transports",+ "type": "text[]",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "update_routing_preferences_owner_user_id_users_id_fk": {+ "name": "update_routing_preferences_owner_user_id_users_id_fk",+ "tableFrom": "update_routing_preferences",+ "tableTo": "users",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "update_routing_preferences_owner_user_id_kind_pk": {+ "name": "update_routing_preferences_owner_user_id_kind_pk",+ "columns": [+ "owner_user_id",+ "kind"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.saved_logins": {+ "name": "saved_logins",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "origin": {+ "name": "origin",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "username": {+ "name": "username",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "encrypted_password": {+ "name": "encrypted_password",+ "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()"+ },+ "last_used_at": {+ "name": "last_used_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "saved_logins_owner_origin_username_idx": {+ "name": "saved_logins_owner_origin_username_idx",+ "columns": [+ {+ "expression": "owner_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "origin",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "username",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "saved_logins_owner_idx": {+ "name": "saved_logins_owner_idx",+ "columns": [+ {+ "expression": "owner_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "saved_logins_owner_user_id_users_id_fk": {+ "name": "saved_logins_owner_user_id_users_id_fk",+ "tableFrom": "saved_logins",+ "tableTo": "users",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.sign_in_requests": {+ "name": "sign_in_requests",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "bot_id": {+ "name": "bot_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "origin": {+ "name": "origin",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "reason": {+ "name": "reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "method": {+ "name": "method",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "outcome": {+ "name": "outcome",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "thread_id": {+ "name": "thread_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "tool_call_id": {+ "name": "tool_call_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "control_request_id": {+ "name": "control_request_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "continuation": {+ "name": "continuation",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "resolved_at": {+ "name": "resolved_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "filling_until": {+ "name": "filling_until",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "sign_in_requests_owner_idx": {+ "name": "sign_in_requests_owner_idx",+ "columns": [+ {+ "expression": "owner_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "sign_in_requests_owner_user_id_users_id_fk": {+ "name": "sign_in_requests_owner_user_id_users_id_fk",+ "tableFrom": "sign_in_requests",+ "tableTo": "users",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "sign_in_requests_status_check": {+ "name": "sign_in_requests_status_check",+ "value": "\"sign_in_requests\".\"status\" IN ('pending', 'filling', 'taken_over', 'signed_in', 'failed', 'cancelled', 'expired')"+ },+ "sign_in_requests_method_check": {+ "name": "sign_in_requests_method_check",+ "value": "\"sign_in_requests\".\"method\" IS NULL OR \"sign_in_requests\".\"method\" IN ('typed', 'saved', 'takeover')"+ }+ },+ "isRLSEnabled": false+ },+ "public.team_bot_assignments": {+ "name": "team_bot_assignments",+ "schema": "",+ "columns": {+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "group_name": {+ "name": "group_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "assigned_by": {+ "name": "assigned_by",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "assigned_at": {+ "name": "assigned_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "team_bot_assignments_agent_id_agents_id_fk": {+ "name": "team_bot_assignments_agent_id_agents_id_fk",+ "tableFrom": "team_bot_assignments",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "team_bot_assignments_assigned_by_users_id_fk": {+ "name": "team_bot_assignments_assigned_by_users_id_fk",+ "tableFrom": "team_bot_assignments",+ "tableTo": "users",+ "columnsFrom": [+ "assigned_by"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "team_bot_assignments_agent_id_group_name_pk": {+ "name": "team_bot_assignments_agent_id_group_name_pk",+ "columns": [+ "agent_id",+ "group_name"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.team_bot_audience": {+ "name": "team_bot_audience",+ "schema": "",+ "columns": {+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "value": {+ "name": "value",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "team_bot_audience_agent_id_agents_id_fk": {+ "name": "team_bot_audience_agent_id_agents_id_fk",+ "tableFrom": "team_bot_audience",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "team_bot_audience_agent_id_kind_value_pk": {+ "name": "team_bot_audience_agent_id_kind_value_pk",+ "columns": [+ "agent_id",+ "kind",+ "value"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "team_bot_audience_kind_check": {+ "name": "team_bot_audience_kind_check",+ "value": "\"team_bot_audience\".\"kind\" IN ('user', 'group')"+ }+ },+ "isRLSEnabled": false+ },+ "public.team_bot_consent_defaults": {+ "name": "team_bot_consent_defaults",+ "schema": "",+ "columns": {+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "server_id": {+ "name": "server_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "team_bot_consent_defaults_user_id_users_id_fk": {+ "name": "team_bot_consent_defaults_user_id_users_id_fk",+ "tableFrom": "team_bot_consent_defaults",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "team_bot_consent_defaults_user_id_server_id_pk": {+ "name": "team_bot_consent_defaults_user_id_server_id_pk",+ "columns": [+ "user_id",+ "server_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.team_bot_consents": {+ "name": "team_bot_consents",+ "schema": "",+ "columns": {+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "server_id": {+ "name": "server_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "decision": {+ "name": "decision",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "team_bot_consents_user_id_users_id_fk": {+ "name": "team_bot_consents_user_id_users_id_fk",+ "tableFrom": "team_bot_consents",+ "tableTo": "users",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "team_bot_consents_agent_id_agents_id_fk": {+ "name": "team_bot_consents_agent_id_agents_id_fk",+ "tableFrom": "team_bot_consents",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "team_bot_consents_user_id_agent_id_server_id_pk": {+ "name": "team_bot_consents_user_id_agent_id_server_id_pk",+ "columns": [+ "user_id",+ "agent_id",+ "server_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "team_bot_consents_decision_check": {+ "name": "team_bot_consents_decision_check",+ "value": "\"team_bot_consents\".\"decision\" IN ('always', 'once')"+ }+ },+ "isRLSEnabled": false+ },+ "public.team_bot_publications": {+ "name": "team_bot_publications",+ "schema": "",+ "columns": {+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "published_by": {+ "name": "published_by",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "audience": {+ "name": "audience",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "published_at": {+ "name": "published_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "team_bot_publications_agent_id_agents_id_fk": {+ "name": "team_bot_publications_agent_id_agents_id_fk",+ "tableFrom": "team_bot_publications",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "team_bot_publications_published_by_users_id_fk": {+ "name": "team_bot_publications_published_by_users_id_fk",+ "tableFrom": "team_bot_publications",+ "tableTo": "users",+ "columnsFrom": [+ "published_by"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "team_bot_publications_audience_check": {+ "name": "team_bot_publications_audience_check",+ "value": "\"team_bot_publications\".\"audience\" IN ('team', 'people')"+ }+ },+ "isRLSEnabled": false+ },+ "public.shared_use_approval_members": {+ "name": "shared_use_approval_members",+ "schema": "",+ "columns": {+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "server_id": {+ "name": "server_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "value": {+ "name": "value",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {+ "shared_use_approval_members_approval_fk": {+ "name": "shared_use_approval_members_approval_fk",+ "tableFrom": "shared_use_approval_members",+ "tableTo": "shared_use_approvals",+ "columnsFrom": [+ "agent_id",+ "server_id"+ ],+ "columnsTo": [+ "agent_id",+ "server_id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "shared_use_approval_members_agent_id_server_id_kind_value_pk": {+ "name": "shared_use_approval_members_agent_id_server_id_kind_value_pk",+ "columns": [+ "agent_id",+ "server_id",+ "kind",+ "value"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "shared_use_approval_members_kind_check": {+ "name": "shared_use_approval_members_kind_check",+ "value": "\"shared_use_approval_members\".\"kind\" IN ('user', 'group')"+ }+ },+ "isRLSEnabled": false+ },+ "public.shared_use_approvals": {+ "name": "shared_use_approvals",+ "schema": "",+ "columns": {+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "server_id": {+ "name": "server_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "audience": {+ "name": "audience",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "outside_input": {+ "name": "outside_input",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true+ },+ "approved_by": {+ "name": "approved_by",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "approved_at": {+ "name": "approved_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "shared_use_approvals_agent_id_agents_id_fk": {+ "name": "shared_use_approvals_agent_id_agents_id_fk",+ "tableFrom": "shared_use_approvals",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "shared_use_approvals_server_id_mcp_servers_id_fk": {+ "name": "shared_use_approvals_server_id_mcp_servers_id_fk",+ "tableFrom": "shared_use_approvals",+ "tableTo": "mcp_servers",+ "columnsFrom": [+ "server_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "shared_use_approvals_agent_id_server_id_pk": {+ "name": "shared_use_approvals_agent_id_server_id_pk",+ "columns": [+ "agent_id",+ "server_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "shared_use_approvals_audience_check": {+ "name": "shared_use_approvals_audience_check",+ "value": "\"shared_use_approvals\".\"audience\" IN ('owner', 'people', 'team')"+ }+ },+ "isRLSEnabled": false+ },+ "public.shared_use_requests": {+ "name": "shared_use_requests",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "server_id": {+ "name": "server_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "proposed_audience": {+ "name": "proposed_audience",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "proposed_outside_input": {+ "name": "proposed_outside_input",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true+ },+ "proposed_members": {+ "name": "proposed_members",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "reason": {+ "name": "reason",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "requested_by": {+ "name": "requested_by",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "decided_by": {+ "name": "decided_by",+ "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()"+ }+ },+ "indexes": {+ "shared_use_requests_pending_idx": {+ "name": "shared_use_requests_pending_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "server_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"shared_use_requests\".\"status\" = 'pending'",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "shared_use_requests_status_idx": {+ "name": "shared_use_requests_status_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "shared_use_requests_agent_id_agents_id_fk": {+ "name": "shared_use_requests_agent_id_agents_id_fk",+ "tableFrom": "shared_use_requests",+ "tableTo": "agents",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "shared_use_requests_server_id_mcp_servers_id_fk": {+ "name": "shared_use_requests_server_id_mcp_servers_id_fk",+ "tableFrom": "shared_use_requests",+ "tableTo": "mcp_servers",+ "columnsFrom": [+ "server_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "shared_use_requests_audience_check": {+ "name": "shared_use_requests_audience_check",+ "value": "\"shared_use_requests\".\"proposed_audience\" IN ('owner', 'people', 'team')"+ },+ "shared_use_requests_reason_check": {+ "name": "shared_use_requests_reason_check",+ "value": "\"shared_use_requests\".\"reason\" IN ('publish', 'trigger', 'grant', 'refused_call')"+ },+ "shared_use_requests_status_check": {+ "name": "shared_use_requests_status_check",+ "value": "\"shared_use_requests\".\"status\" IN ('pending', 'approved', 'declined', 'superseded')"+ }+ },+ "isRLSEnabled": false+ },+ "public.identity_link_challenges": {+ "name": "identity_link_challenges",+ "schema": "",+ "columns": {+ "token_hash": {+ "name": "token_hash",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "identity_link_challenges_expiry_idx": {+ "name": "identity_link_challenges_expiry_idx",+ "columns": [+ {+ "expression": "expires_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "identity_link_challenges_user_provider_idx": {+ "name": "identity_link_challenges_user_provider_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.identity_links": {+ "name": "identity_links",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "realm": {+ "name": "realm",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "subject": {+ "name": "subject",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "handle": {+ "name": "handle",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "verified_by": {+ "name": "verified_by",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "credential_id": {+ "name": "credential_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'active'"+ },+ "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": {+ "identity_links_identity_idx": {+ "name": "identity_links_identity_idx",+ "columns": [+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "realm",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "subject",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "identity_links_user_realm_idx": {+ "name": "identity_links_user_realm_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "realm",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "identity_links_credential_idx": {+ "name": "identity_links_credential_idx",+ "columns": [+ {+ "expression": "credential_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"identity_links\".\"credential_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "identity_links_credential_id_credentials_id_fk": {+ "name": "identity_links_credential_id_credentials_id_fk",+ "tableFrom": "identity_links",+ "tableTo": "credentials",+ "columnsFrom": [+ "credential_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "identity_links_verified_by_check": {+ "name": "identity_links_verified_by_check",+ "value": "\"identity_links\".\"verified_by\" IN ('challenge', 'oauth')"+ },+ "identity_links_status_check": {+ "name": "identity_links_status_check",+ "value": "\"identity_links\".\"status\" IN ('active', 'needs_reconnect')"+ }+ },+ "isRLSEnabled": false+ }+ },+ "enums": {+ "public.agent_type": {+ "name": "agent_type",+ "schema": "public",+ "values": [+ "built_in",+ "remote_ag_ui",+ "remote_mastra"+ ]+ },+ "public.credential_kind": {+ "name": "credential_kind",+ "schema": "public",+ "values": [+ "model",+ "connector",+ "agent",+ "mcp",+ "mcp_oauth_client",+ "mcp_user_token"+ ]+ },+ "public.role": {+ "name": "role",+ "schema": "public",+ "values": [+ "admin",+ "user"+ ]+ },+ "public.agent_visibility": {+ "name": "agent_visibility",+ "schema": "public",+ "values": [+ "public",+ "private"+ ]+ },+ "public.routine_run_status": {+ "name": "routine_run_status",+ "schema": "public",+ "values": [+ "succeeded",+ "failed",+ "skipped",+ "waiting"+ ]+ },+ "public.responsibility_run_status": {+ "name": "responsibility_run_status",+ "schema": "public",+ "values": [+ "queued",+ "running",+ "waiting",+ "succeeded",+ "failed",+ "skipped"+ ]+ },+ "public.responsibility_status": {+ "name": "responsibility_status",+ "schema": "public",+ "values": [+ "active",+ "paused",+ "completed"+ ]+ }+ },+ "schemas": {},+ "sequences": {},+ "roles": {},+ "policies": {},+ "views": {},+ "_meta": {+ "columns": {},+ "schemas": {},+ "tables": {}+ }+}\ No newline at end of filediff --git a/server/drizzle/meta/_journal.json b/server/drizzle/meta/_journal.jsonindex 7b3bedd1..3c34e8a9 100644--- a/server/drizzle/meta/_journal.json+++ b/server/drizzle/meta/_journal.json@@ -379,6 +379,13 @@"when": 1791547580808,"tag": "0053_identity_links","breakpoints": true+ },+ {+ "idx": 54,+ "version": "7",+ "when": 1791832775550,+ "tag": "0054_memory_on_intelligence",+ "breakpoints": true}]}\ No newline at end of filediff --git a/server/src/db/schema/memory.ts b/server/src/db/schema/memory.tsindex 105a52db..a284cff3 100644--- a/server/src/db/schema/memory.ts+++ b/server/src/db/schema/memory.ts@@ -82,6 +82,15 @@ export const personalMemories = pgTable(sourceRef: text("source_ref"),sourceLink: text("source_link"),observedAt: timestamp("observed_at", { withTimezone: true }),+ /**+ * The memory's id in CopilotKit Intelligence, when this deployment is entitled to Intelligence+ * memory and the memory has been mirrored there. Intelligence holds the content and does the+ * recall; this row keeps what Intelligence has no field for (provenance, review, who formed it,+ * which source and Bot may see it). Null while it is local only.+ */+ intelligenceMemoryId: text("intelligence_memory_id"),+ /** sha256 of the content last written to Intelligence, so an edit is mirrored exactly once. */+ intelligenceDigest: text("intelligence_digest"),createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),@@ -91,6 +100,10 @@ export const personalMemories = pgTable(},(table) => [index("personal_memories_owner_idx").on(table.ownerUserId, table.enabled),+ index("personal_memories_intelligence_idx").on(+ table.ownerUserId,+ table.intelligenceMemoryId,+ ),index("personal_memories_formed_idx").on(table.ownerUserId,table.formedByAgentId,diff --git a/server/src/index.ts b/server/src/index.tsindex 81e6611b..1f9572ad 100644--- a/server/src/index.ts+++ b/server/src/index.ts@@ -188,6 +188,7 @@ import {import { clearLearningRevisionFallback } from "./learning/runtime";import { createLearningSettingsStore } from "./learning/settings";import { createMemoryIngestion } from "./memory/ingestion";+import { createIntelligenceMemory } from "./memory/intelligence";import { createMemoryStore } from "./memory/store";import { memoryTools } from "./memory/tools";import { createSignInNotifier, createSignInResumer } from "./passwords/resume";@@ -1077,7 +1078,14 @@ const hostAccessBroker = createHostAccessBroker(Date.now, {// grant, the policy and the audit row are exactly where they were. Host-folder tools are also// server-dispatched: the selected Bot and the signed-in owner are bound here, then the desktop worker// receives only opaque grant ids and relative paths.-const personalMemoryStore = createMemoryStore(database);+// Memory lives in CopilotKit Intelligence when this deployment is entitled to it, and in OpenBot's own+// tables when it is not; see memory/store.ts. Its own client, like the thread reader's: the+// constructor opens nothing.+const personalMemoryStore = createMemoryStore(database, {+ intelligence: createIntelligenceMemory({+ client: createIntelligenceClient(config.runtime.intelligence),+ }),+});const demonstrationStore = createDemonstrationStore(database);const demonstrationRecorder = createDemonstrationRecorder({store: demonstrationStore,@@ -1113,6 +1121,20 @@ const memorySweep = repeatAfterEach(async () => {}),);}+ // Mirror to Intelligence what is out of step: the backfill on the first passes after a deployment+ // becomes entitled, and afterwards whatever an outage left behind. A no-op without Intelligence.+ try {+ await personalMemoryStore.mirrorPending();+ } catch (error) {+ console.error(+ JSON.stringify({+ type: "memory-sweep-error",+ error: error instanceof Error ? error.name : "UnknownError",+ context: { operation: "mirrorPending" },+ timestamp: new Date().toISOString(),+ }),+ );+ }}, 60_000);// Follow-ups a Bot schedules for itself, on the shared work queue. See agents/wake-up.ts.const wakeUpStore = createWakeUpStore(database, { auditStore: bootAuditStore });diff --git a/server/src/memory/intelligence.ts b/server/src/memory/intelligence.tsnew file mode 100644index 00000000..97d2a79f--- /dev/null+++ b/server/src/memory/intelligence.ts@@ -0,0 +1,261 @@+import type { CopilotKitIntelligence } from "@copilotkit/runtime/v2";++/**+ * The slice of the Intelligence client memory needs. Typed from the client OpenBot already uses, so a+ * test can hand in a fake without standing up the platform.+ */+export type IntelligenceMemoryClient = Pick<+ CopilotKitIntelligence,+ | "getRuntimeEntitlements"+ | "listMemories"+ | "createMemory"+ | "updateMemory"+ | "removeMemory"+ | "recallMemories"+>;++/** A memory as Intelligence holds it: the person's own (`scope: "user"`), and live. */+export type IntelligenceMemoryRecord = {+ id: string;+ content: string;+ score?: number;+};++/**+ * Every call names the person and asks for their own memories only.+ *+ * READ-WRITE ON USER, NONE ON PROJECT, ALWAYS. A project-scoped memory is shared by everyone in the+ * Intelligence project, so reading project scope here would hand one person's Bot another person's+ * facts. Results are also filtered to `scope === "user"` after they arrive, so a platform that+ * ignored the grant still could not leak project rows into a person's memory.+ */+const GRANT = { user: "read-write", project: "none" } as const;+const KIND = "topical";++/** How long a known answer about whether memory is available is reused. */+const AVAILABLE_TTL_MS = 10 * 60_000;+/** How long a failure holds memory on the local store before Intelligence is asked again. */+const FAILURE_TTL_MS = 60_000;+/**+ * How long a person's list is reused. Every turn reads it for the memory context, so without this+ * each turn would wait on a platform round trip. Any write of that person's through this client+ * clears it, so OpenBot's own changes show at once; a memory another app adds shows within this.+ */+const LIST_TTL_MS = 30_000;++export type IntelligenceMemory = {+ /** Whether Intelligence memory is entitled and reachable right now. Never throws. */+ available(): Promise<boolean>;+ /** The person's live memories, newest first, at most the platform's list limit (200). */+ list(userId: string): Promise<IntelligenceMemoryRecord[] | undefined>;+ /** Ranked recall over the person's memories. */+ recall(+ userId: string,+ query: string,+ limit: number,+ ): Promise<IntelligenceMemoryRecord[] | undefined>;+ /** Store content; the id may be an existing memory's when Intelligence absorbed a near-duplicate. */+ create(userId: string, content: string): Promise<string | undefined>;+ /** Replace a memory's content. Intelligence retires the old row, so the id changes. */+ supersede(+ userId: string,+ id: string,+ content: string,+ ): Promise<string | undefined | "gone">;+ /** Retire a memory. True when it is gone, whether this call or an earlier one retired it. */+ remove(userId: string, id: string): Promise<boolean>;+};++function statusOf(error: unknown): number | undefined {+ return error && typeof error === "object" && "status" in error+ ? (error as { status?: number }).status+ : undefined;+}++/**+ * Intelligence memory behind one guard: entitled, reachable, or out of the way.+ *+ * Memory is a licensed Intelligence feature, and OpenBot has to work without it. So every call here+ * answers `undefined` instead of throwing when the deployment is not entitled, Intelligence is+ * unreachable, or a call fails; the store then keeps working on its own tables. A `403` (the+ * platform's `MEMORY_NOT_ENTITLED`), a `401` or a network failure holds memory on the local store+ * for a minute before asking again, so a lapsed licence costs one failed call a minute, not one per+ * turn.+ */+export function createIntelligenceMemory(options: {+ client: IntelligenceMemoryClient;+ now?: () => number;+ log?: (message: string) => void;+}): IntelligenceMemory {+ const { client } = options;+ const now = options.now ?? Date.now;+ const log = options.log ?? ((message: string) => console.warn(message));+ let state: { available: boolean; until: number } | undefined;+ let loggedUnavailable = false;+ const lists = new Map<+ string,+ { memories: IntelligenceMemoryRecord[]; until: number }+ >();++ const hold = (reason: string) => {+ state = { available: false, until: now() + FAILURE_TTL_MS };+ if (!loggedUnavailable) {+ loggedUnavailable = true;+ log(+ JSON.stringify({+ type: "intelligence-memory-unavailable",+ reason,+ timestamp: new Date(now()).toISOString(),+ }),+ );+ }+ };++ async function available(): Promise<boolean> {+ if (state && state.until > now()) return state.available;+ try {+ const response = await client.getRuntimeEntitlements();+ const entitled =+ response.status === "ready" &&+ response.entitlement.active &&+ response.entitlement.features.memory === true;+ state = {+ available: entitled,+ until: now() + (entitled ? AVAILABLE_TTL_MS : FAILURE_TTL_MS),+ };+ if (entitled) loggedUnavailable = false;+ else if (!loggedUnavailable) hold("not entitled");+ return entitled;+ } catch (error) {+ hold(error instanceof Error ? error.name : "entitlement read failed");+ return false;+ }+ }++ async function guarded<T>(+ operation: string,+ call: () => Promise<T>,+ ): Promise<T | undefined> {+ if (!(await available())) return undefined;+ try {+ return await call();+ } catch (error) {+ const status = statusOf(error);+ if (status === undefined || status === 401 || status === 403)+ hold(+ `${operation}: ${status ?? (error instanceof Error ? error.name : "failed")}`,+ );+ else+ log(+ JSON.stringify({+ type: "intelligence-memory-error",+ operation,+ status,+ timestamp: new Date(now()).toISOString(),+ }),+ );+ throw error;+ }+ }++ const live = (+ memories: {+ id: string;+ scope: string;+ content: string;+ invalidatedAt: string | null;+ score?: number;+ }[],+ ): IntelligenceMemoryRecord[] =>+ memories+ .filter((memory) => memory.scope === "user" && !memory.invalidatedAt)+ .map((memory) => ({+ id: memory.id,+ content: memory.content,+ ...(memory.score === undefined ? {} : { score: memory.score }),+ }));++ return {+ available,+ async list(userId) {+ const cached = lists.get(userId);+ if (cached && cached.until > now() && (await available()))+ return cached.memories;+ try {+ const response = await guarded("list", () =>+ client.listMemories({ userId, memoryGrant: GRANT }),+ );+ if (!response) return undefined;+ const memories = live(response.memories);+ lists.set(userId, { memories, until: now() + LIST_TTL_MS });+ return memories;+ } catch {+ return undefined;+ }+ },+ async recall(userId, query, limit) {+ try {+ const response = await guarded("recall", () =>+ client.recallMemories({+ userId,+ memoryGrant: GRANT,+ query,+ limit,+ scope: "user",+ }),+ );+ return response ? live(response.memories) : undefined;+ } catch {+ return undefined;+ }+ },+ async create(userId, content) {+ lists.delete(userId);+ try {+ const saved = await guarded("create", () =>+ client.createMemory({+ userId,+ memoryGrant: GRANT,+ content,+ kind: KIND,+ scope: "user",+ }),+ );+ return saved?.id;+ } catch {+ return undefined;+ }+ },+ async supersede(userId, id, content) {+ lists.delete(userId);+ try {+ const saved = await guarded("supersede", () =>+ client.updateMemory({+ userId,+ memoryGrant: GRANT,+ id,+ content,+ kind: KIND,+ scope: "user",+ }),+ );+ return saved?.id;+ } catch (error) {+ // The row it named was already retired, by the person in another app or an earlier attempt.+ return statusOf(error) === 404 ? "gone" : undefined;+ }+ },+ async remove(userId, id) {+ lists.delete(userId);+ try {+ const done = await guarded("remove", async () => {+ await client.removeMemory({ userId, id, memoryGrant: GRANT });+ return true;+ });+ return done === true;+ } catch (error) {+ return statusOf(error) === 404;+ }+ },+ };+}diff --git a/server/src/memory/routes.ts b/server/src/memory/routes.tsindex 192c48ad..b4819af3 100644--- a/server/src/memory/routes.ts+++ b/server/src/memory/routes.ts@@ -4,7 +4,11 @@ import type { AppVariables } from "../auth/guards";import { PluginRefusedError } from "../plugins/store";import type { MemoryIngestion } from "./ingestion";import type { MemoryStore } from "./store";-import { MemoryNotFoundError, MemoryRefusedError } from "./types";+import {+ MemoryNotFoundError,+ MemoryRefusedError,+ MemoryUnavailableError,+} from "./types";export function createMemoryRoutes(store: MemoryStore,@@ -23,6 +27,8 @@ export function createMemoryRoutes(error instanceof PluginRefusedError)return context.json({ error: error.message }, 400);+ if (error instanceof MemoryUnavailableError)+ return context.json({ error: error.message }, 503);console.error(JSON.stringify({type: "memory-route-error",diff --git a/server/src/memory/store.ts b/server/src/memory/store.tsindex 7333d01b..04cef17c 100644--- a/server/src/memory/store.ts+++ b/server/src/memory/store.ts@@ -1,19 +1,121 @@import { createHash, randomUUID } from "node:crypto";-import { and, desc, eq, inArray, isNull, lte, or, sql } from "drizzle-orm";+import {+ and,+ desc,+ eq,+ inArray,+ isNotNull,+ isNull,+ lte,+ ne,+ not,+ or,+ type SQL,+ sql,+} from "drizzle-orm";import type { Database } from "../db/client";import { memorySources, personalMemories } from "../db/schema/memory";+import type {+ IntelligenceMemory,+ IntelligenceMemoryRecord,+} from "./intelligence";import {type FormedMemoryInput,formedMemorySchema,type ImportedMemory,MemoryNotFoundError,+ type MemoryRecord,MemoryRefusedError,+ MemoryUnavailableError,parseMemoryInput,parseMemoryPatch,parseMemorySourceInput,} from "./types";-export function createMemoryStore(database: Database) {+/**+ * The id a memory gets in OpenBot when only Intelligence holds it. Prefixed so the routes can tell+ * it from an OpenBot row id without a lookup, and so it can never collide with one.+ */+const INTELLIGENCE_ID_PREFIX = "intelligence:";+const INTELLIGENCE_PROVENANCE = "CopilotKit Intelligence";++const digestOf = (content: string) =>+ createHash("sha256").update(content).digest("hex");++/**+ * What Intelligence should hold: a live, switched-on memory the person has accepted.+ *+ * A Bot-formed or imported memory waits for the person's review before it leaves OpenBot, and a+ * paused or forgotten one is retired from Intelligence, because Intelligence has no field for+ * "paused" and anything else reading the person's Intelligence memory would otherwise see it.+ */+// Parenthesised: drizzle's `not()` does not wrap a raw fragment, so without them `not(mirrorEligible)`+// negated only its first clause.+const mirrorEligible = sql`(${personalMemories.deletedAt} IS NULL AND ${personalMemories.enabled} AND ${personalMemories.reviewState} IN ('confirmed', 'edited') AND ${personalMemories.content} <> '')`;+const contentDigest = sql`encode(sha256(convert_to(${personalMemories.content}, 'UTF8')), 'hex')`;++type MemoryRow = typeof personalMemories.$inferSelect;+const isMirrorEligible = (row: MemoryRow) =>+ row.deletedAt === null &&+ row.enabled &&+ (row.reviewState === "confirmed" || row.reviewState === "edited") &&+ row.content !== "";++function fromIntelligence(+ ownerUserId: string,+ memory: IntelligenceMemoryRecord,+): MemoryRecord {+ const now = new Date();+ return {+ id: `${INTELLIGENCE_ID_PREFIX}${memory.id}`,+ ownerUserId,+ content: memory.content,+ provenance: INTELLIGENCE_PROVENANCE,+ enabled: true,+ reviewState: "confirmed",+ formedBy: "intelligence",+ formedByAgentId: null,+ sourceId: null,+ externalId: null,+ importDigest: null,+ sourceApp: INTELLIGENCE_PROVENANCE,+ sourceRef: null,+ sourceLink: null,+ observedAt: null,+ deletedAt: null,+ intelligenceMemoryId: memory.id,+ intelligenceDigest: null,+ createdAt: now,+ updatedAt: now,+ };+}++/**+ * A person's memory: CopilotKit Intelligence when this deployment is entitled to it, OpenBot's own+ * tables when it is not.+ *+ * When Intelligence memory is available, it holds the content and does the recall, and every memory+ * the person has accepted is mirrored there. The OpenBot row stays as the record of what Intelligence+ * has no field for: where a memory came from, whether it is reviewed or paused, which Bot formed it+ * and which source it was imported from. Those decide which Bot may see a memory, so every rule a+ * Bot's recall obeys is still applied here, over the rows, before anything Intelligence returns+ * reaches a Bot. Memories Intelligence holds for the person that no row describes (formed by another+ * app on the project, or by Intelligence) are read back as the person's own, the way a memory the+ * person wrote is.+ *+ * Without Intelligence memory, nothing here calls the platform, and the store behaves exactly as it+ * did before: the tables are the whole store. Losing Intelligence mid-flight (a lapsed licence, an+ * outage) falls back to the tables rather than failing; a memory that lives only in Intelligence is+ * the one thing the tables cannot stand in for, and editing or forgetting one then answers 503.+ */+export function createMemoryStore(+ database: Database,+ options: { intelligence?: IntelligenceMemory } = {},+) {+ const { intelligence } = options;+ /** One mirror pass per person at a time in this process, so two writes cannot both create. */+ const mirroring = new Map<string, Promise<unknown>>();+const getSource = async (ownerUserId: string, id: string) => {const [row] = await database.select()@@ -27,9 +129,221 @@ export function createMemoryStore(database: Database) {if (!row) throw new MemoryNotFoundError();return row;};++ /** Whether another live row of this person's points at the same Intelligence memory. */+ async function linkIsShared(row: MemoryRow): Promise<boolean> {+ if (!row.intelligenceMemoryId) return false;+ const [other] = await database+ .select({ id: personalMemories.id })+ .from(personalMemories)+ .where(+ and(+ eq(personalMemories.ownerUserId, row.ownerUserId),+ eq(personalMemories.intelligenceMemoryId, row.intelligenceMemoryId),+ ne(personalMemories.id, row.id),+ isNull(personalMemories.deletedAt),+ ),+ )+ .limit(1);+ return other !== undefined;+ }++ /** Bring one row's Intelligence copy in line with it. Leaves the row as it was on any failure. */+ async function mirrorRow(memory: IntelligenceMemory, row: MemoryRow) {+ const owner = row.ownerUserId;+ if (isMirrorEligible(row)) {+ const digest = digestOf(row.content);+ let id: string | undefined;+ if (!row.intelligenceMemoryId) {+ id = await memory.create(owner, row.content);+ } else if (await linkIsShared(row)) {+ // Intelligence merged two of this person's memories into one. Superseding it would retire+ // the other row's copy too, so this row gets a memory of its own instead.+ id = await memory.create(owner, row.content);+ } else {+ const result = await memory.supersede(+ owner,+ row.intelligenceMemoryId,+ row.content,+ );+ id =+ result === "gone" ? await memory.create(owner, row.content) : result;+ }+ if (!id) return;+ await database+ .update(personalMemories)+ .set({ intelligenceMemoryId: id, intelligenceDigest: digest })+ .where(eq(personalMemories.id, row.id));+ return;+ }+ if (!row.intelligenceMemoryId) return;+ const retired =+ (await linkIsShared(row)) ||+ (await memory.remove(owner, row.intelligenceMemoryId));+ if (!retired) return;+ await database+ .update(personalMemories)+ .set({ intelligenceMemoryId: null, intelligenceDigest: null })+ .where(eq(personalMemories.id, row.id));+ }++ /** Rows whose Intelligence copy is missing, stale, or should no longer exist. */+ const outOfStep = or(+ and(+ mirrorEligible,+ or(+ isNull(personalMemories.intelligenceMemoryId),+ sql`${personalMemories.intelligenceDigest} IS DISTINCT FROM ${contentDigest}`,+ ),+ ),+ and(not(mirrorEligible), isNotNull(personalMemories.intelligenceMemoryId)),+ ) as SQL;++ /**+ * Mirror this person's out-of-step rows (or only `rowId`). Serialised per person in this process;+ * across replicas, a race creates at most a near-duplicate, which Intelligence absorbs into the+ * existing memory and answers with its id. Never throws: a failure leaves the row out of step, and+ * the next pass picks it up.+ */+ async function mirror(ownerUserId: string, rowId?: string, limit = 50) {+ if (!intelligence) return 0;+ const memory = intelligence;+ const previous = mirroring.get(ownerUserId) ?? Promise.resolve();+ const run = previous+ .catch(() => {})+ .then(async () => {+ if (!(await memory.available())) return 0;+ const rows = await database+ .select()+ .from(personalMemories)+ .where(+ and(+ eq(personalMemories.ownerUserId, ownerUserId),+ rowId ? eq(personalMemories.id, rowId) : undefined,+ outOfStep,+ ),+ )+ .limit(limit);+ for (const row of rows) {+ try {+ await mirrorRow(memory, row);+ } catch (error) {+ console.error(+ JSON.stringify({+ type: "memory-mirror-error",+ error: error instanceof Error ? error.name : "UnknownError",+ context: { memoryId: row.id },+ timestamp: new Date().toISOString(),+ }),+ );+ }+ }+ return rows.length;+ });+ mirroring.set(ownerUserId, run);+ try {+ return await run;+ } finally {+ if (mirroring.get(ownerUserId) === run) mirroring.delete(ownerUserId);+ }+ }++ /** Every Intelligence id this person's rows point at, forgotten rows included. */+ async function linkedIds(ownerUserId: string) {+ const rows = await database+ .select({+ id: personalMemories.id,+ intelligenceMemoryId: personalMemories.intelligenceMemoryId,+ })+ .from(personalMemories)+ .where(+ and(+ eq(personalMemories.ownerUserId, ownerUserId),+ isNotNull(personalMemories.intelligenceMemoryId),+ ),+ );+ return new Set(rows.map((row) => row.intelligenceMemoryId as string));+ }++ /** The person's Intelligence memories that no OpenBot row describes. */+ async function intelligenceOnly(+ ownerUserId: string,+ memories: IntelligenceMemoryRecord[],+ ): Promise<MemoryRecord[]> {+ if (!memories.length) return [];+ const linked = await linkedIds(ownerUserId);+ return memories+ .filter((memory) => !linked.has(memory.id))+ .map((memory) => fromIntelligence(ownerUserId, memory));+ }++ /**+ * The rows a Bot may recall, every filter in the query. Bot-formed memories go only to the Bot that+ * formed them, and only while it still holds their source app; imported ones only through a source+ * this Bot may use; the person's own to every Bot of theirs.+ */+ function eligibleRows(+ ownerUserId: string,+ eligibleSourceIds: string[],+ formed: { botId: string; heldServerIds: ReadonlySet<string> } | undefined,+ narrow: { term?: string; intelligenceIds?: string[] },+ ) {+ const held = [...(formed?.heldServerIds ?? [])];+ const formedByThisBot = formed+ ? and(+ eq(personalMemories.formedBy, "bot"),+ eq(personalMemories.formedByAgentId, formed.botId),+ or(+ isNull(personalMemories.sourceRef),+ held.length > 0+ ? inArray(+ sql<string>`split_part(${personalMemories.sourceRef}, '/', 1)`,+ held,+ )+ : sql`false`,+ ),+ )+ : undefined;+ const personOrSource = and(+ sql`${personalMemories.formedBy} <> 'bot'`,+ or(+ isNull(personalMemories.sourceId),+ eligibleSourceIds.length > 0+ ? inArray(personalMemories.sourceId, eligibleSourceIds)+ : sql`false`,+ ),+ );+ return database+ .select()+ .from(personalMemories)+ .where(+ and(+ eq(personalMemories.ownerUserId, ownerUserId),+ eq(personalMemories.enabled, true),+ isNull(personalMemories.deletedAt),+ formedByThisBot+ ? or(formedByThisBot, personOrSource)+ : personOrSource,+ narrow.term+ ? sql`strpos(lower(${personalMemories.content}), lower(${narrow.term})) > 0`+ : undefined,+ narrow.intelligenceIds+ ? narrow.intelligenceIds.length > 0+ ? inArray(+ personalMemories.intelligenceMemoryId,+ narrow.intelligenceIds,+ )+ : sql`false`+ : undefined,+ ),+ )+ .orderBy(desc(personalMemories.updatedAt))+ .limit(40);+ }+return {- async list(ownerUserId: string) {- return database+ async list(ownerUserId: string): Promise<MemoryRecord[]> {+ const rows = await database.select().from(personalMemories).where(@@ -40,6 +354,10 @@ export function createMemoryStore(database: Database) {).orderBy(desc(personalMemories.updatedAt)).limit(500);+ if (!intelligence) return rows;+ const remote = await intelligence.list(ownerUserId);+ if (!remote) return rows;+ return [...rows, ...(await intelligenceOnly(ownerUserId, remote))];},async create(ownerUserId: string, input: unknown) {const [row] = await database@@ -52,13 +370,15 @@ export function createMemoryStore(database: Database) {}).returning();if (!row) throw new Error("Memory insert returned no row.");+ await mirror(ownerUserId, row.id);return row;},/*** A memory a Bot formed from something it observed, awaiting the person's review.** Deduplicated on content, deleted rows included: a memory the person forgot stays forgotten- * even when the Bot reads the same record again tomorrow.+ * even when the Bot reads the same record again tomorrow. It reaches Intelligence only once the+ * person accepts it.*/async formMemory(ownerUserId: string, input: FormedMemoryInput) {const parsed = formedMemorySchema.safeParse({@@ -139,8 +459,40 @@ export function createMemoryStore(database: Database) {if (!raced) throw new Error("Memory insert returned no row.");return { id: raced.id, duplicate: true, forgotten: !!raced.deletedAt };},- async update(ownerUserId: string, id: string, input: unknown) {+ async update(+ ownerUserId: string,+ id: string,+ input: unknown,+ ): Promise<MemoryRecord> {const patch = parseMemoryPatch(input);+ if (id.startsWith(INTELLIGENCE_ID_PREFIX)) {+ // Intelligence keeps the content and nothing else, so there is nothing to pause or review.+ if (patch.enabled !== undefined)+ throw new MemoryRefusedError(+ "A memory kept in CopilotKit Intelligence can be edited or forgotten, not paused.",+ );+ const remoteId = id.slice(INTELLIGENCE_ID_PREFIX.length);+ if (!patch.content) {+ const current = (await intelligence?.list(ownerUserId))?.find(+ (memory) => memory.id === remoteId,+ );+ if (!current) throw new MemoryNotFoundError();+ return fromIntelligence(ownerUserId, current);+ }+ if (!intelligence || !(await intelligence.available()))+ throw new MemoryUnavailableError();+ const result = await intelligence.supersede(+ ownerUserId,+ remoteId,+ patch.content,+ );+ if (result === "gone") throw new MemoryNotFoundError();+ if (!result) throw new MemoryUnavailableError();+ return fromIntelligence(ownerUserId, {+ id: result,+ content: patch.content,+ });+ }const [row] = await database.update(personalMemories).set({@@ -157,9 +509,22 @@ export function createMemoryStore(database: Database) {).returning();if (!row) throw new MemoryNotFoundError();+ await mirror(ownerUserId, row.id);return row;},async remove(ownerUserId: string, id: string) {+ if (id.startsWith(INTELLIGENCE_ID_PREFIX)) {+ if (!intelligence || !(await intelligence.available()))+ throw new MemoryUnavailableError();+ const remoteId = id.slice(INTELLIGENCE_ID_PREFIX.length);+ // Only a memory of this person's that no row describes is forgotten by this id. A linked one+ // is forgotten through its row, so its provenance and tombstone go with it.+ if ((await linkedIds(ownerUserId)).has(remoteId))+ throw new MemoryNotFoundError();+ if (!(await intelligence.remove(ownerUserId, remoteId)))+ throw new MemoryUnavailableError();+ return;+ }// Imported tombstones prevent the next sync from resurrecting a fact the person deleted.const [row] = await database.update(personalMemories)@@ -178,6 +543,24 @@ export function createMemoryStore(database: Database) {).returning({ id: personalMemories.id });if (!row) throw new MemoryNotFoundError();+ await mirror(ownerUserId, row.id);+ },+ /**+ * Mirror out-of-step memories to Intelligence, oldest owners first: the backfill on the first+ * pass after a deployment becomes entitled, and afterwards anything a failure left behind.+ * Idempotent: a row is out of step until its Intelligence id and digest match its content.+ */+ async mirrorPending(limitPeople = 20) {+ if (!intelligence || !(await intelligence.available())) return 0;+ const owners = await database+ .selectDistinct({ ownerUserId: personalMemories.ownerUserId })+ .from(personalMemories)+ .where(outOfStep)+ .limit(limitPeople);+ let mirrored = 0;+ for (const { ownerUserId } of owners)+ mirrored += await mirror(ownerUserId);+ return mirrored;},async sources(ownerUserId: string) {return database@@ -214,6 +597,25 @@ export function createMemoryStore(database: Database) {return row;},async removeSource(ownerUserId: string, id: string) {+ // The source's memories cascade with it; retire their Intelligence copies first.+ if (intelligence && (await intelligence.available())) {+ const linked = await database+ .select()+ .from(personalMemories)+ .where(+ and(+ eq(personalMemories.ownerUserId, ownerUserId),+ eq(personalMemories.sourceId, id),+ isNotNull(personalMemories.intelligenceMemoryId),+ ),+ );+ for (const row of linked)+ await mirrorRow(intelligence, {+ ...row,+ deletedAt: new Date(),+ enabled: false,+ }).catch(() => {});+ }const [row] = await database.delete(memorySources).where(@@ -332,6 +734,8 @@ export function createMemoryStore(database: Database) {}).where(eq(memorySources.id, sourceId));});+ // A confirmed import whose content changed upstream is out of step now; mirror it.+ await mirror(ownerUserId);},async retrieve(ownerUserId: string,@@ -343,56 +747,53 @@ export function createMemoryStore(database: Database) {* this argument none are returned.*/formed?: { botId: string; heldServerIds: ReadonlySet<string> },- ) {- /*- * Every filter in the query, not after it. Taking the person's newest rows across all their- * Bots and filtering here meant a person with busy sources on other Bots lost this Bot's older- * memories altogether, and a search could never reach them.- */- const held = [...(formed?.heldServerIds ?? [])];+ ): Promise<MemoryRecord[]> {const term = search.trim();- const formedByThisBot = formed- ? and(- eq(personalMemories.formedBy, "bot"),- eq(personalMemories.formedByAgentId, formed.botId),- or(- isNull(personalMemories.sourceRef),- held.length > 0- ? inArray(- sql<string>`split_part(${personalMemories.sourceRef}, '/', 1)`,- held,- )- : sql`false`,- ),- )- : undefined;- const personOrSource = and(- sql`${personalMemories.formedBy} <> 'bot'`,- or(- isNull(personalMemories.sourceId),- eligibleSourceIds.length > 0- ? inArray(personalMemories.sourceId, eligibleSourceIds)- : sql`false`,- ),- );- return database- .select()- .from(personalMemories)- .where(- and(- eq(personalMemories.ownerUserId, ownerUserId),- eq(personalMemories.enabled, true),- isNull(personalMemories.deletedAt),- formedByThisBot- ? or(formedByThisBot, personOrSource)- : personOrSource,- term- ? sql`strpos(lower(${personalMemories.content}), lower(${term})) > 0`- : undefined,+ const local = await eligibleRows(ownerUserId, eligibleSourceIds, formed, {+ term,+ });+ if (!intelligence) return local;+ if (term) {+ /*+ * Ranked by Intelligence, filtered by the rows. A recalled memory a row describes reaches+ * this Bot only if that row is one this Bot may recall; one no row describes is the+ * person's own. The substring matches from the rows follow, for anything recall missed.+ */+ const recalled = await intelligence.recall(ownerUserId, term, 20);+ if (!recalled) return local;+ const allowed = await eligibleRows(+ ownerUserId,+ eligibleSourceIds,+ formed,+ { intelligenceIds: recalled.map((memory) => memory.id) },+ );+ const byRemote = new Map(+ allowed.map((row) => [row.intelligenceMemoryId, row]),+ );+ const unlinked = new Set(+ (await intelligenceOnly(ownerUserId, recalled)).map(+ (memory) => memory.intelligenceMemoryId,),- )- .orderBy(desc(personalMemories.updatedAt))- .limit(40);+ );+ const ranked: MemoryRecord[] = recalled.flatMap((memory) => {+ const row = byRemote.get(memory.id);+ if (row) return [row];+ return unlinked.has(memory.id)+ ? [fromIntelligence(ownerUserId, memory)]+ : [];+ });+ const seen = new Set(ranked.map((memory) => memory.id));+ return [+ ...ranked,+ ...local.filter((memory) => !seen.has(memory.id)),+ ].slice(0, 40);+ }+ const remote = await intelligence.list(ownerUserId);+ if (!remote) return local;+ return [+ ...local,+ ...(await intelligenceOnly(ownerUserId, remote)).slice(0, 20),+ ].slice(0, 40);},};}diff --git a/server/src/memory/types.ts b/server/src/memory/types.tsindex 5f90b0e5..d7d1d666 100644--- a/server/src/memory/types.ts+++ b/server/src/memory/types.ts@@ -41,6 +41,15 @@ export class MemoryRefusedError extends Error {this.name = "MemoryRefusedError";}}+/** Intelligence holds this memory and cannot be reached right now. The local store cannot stand in. */+export class MemoryUnavailableError extends Error {+ constructor() {+ super(+ "This memory is kept in CopilotKit Intelligence, which cannot be reached right now. Try again.",+ );+ this.name = "MemoryUnavailableError";+ }+}export class MemoryNotFoundError extends Error {constructor() {super("This memory could not be found.");@@ -74,13 +83,20 @@ export type MemoryRecord = MemoryInput & {externalId: string | null;importDigest: string | null;reviewState: "unreviewed" | "confirmed" | "edited";- formedBy: "person" | "import" | "bot";+ /**+ * Who formed it. `intelligence` is a memory CopilotKit Intelligence holds for this person that no+ * OpenBot row describes, formed by another app on the same project or by Intelligence itself. It+ * is never stored in OpenBot's table, only read back from Intelligence.+ */+ formedBy: "person" | "import" | "bot" | "intelligence";formedByAgentId: string | null;sourceApp: string | null;sourceRef: string | null;sourceLink: string | null;observedAt: Date | null;deletedAt: Date | null;+ intelligenceMemoryId: string | null;+ intelligenceDigest: string | null;createdAt: Date;updatedAt: Date;};diff --git a/server/tests/intelligence-memory.test.ts b/server/tests/intelligence-memory.test.tsnew file mode 100644index 00000000..5837f9f3--- /dev/null+++ b/server/tests/intelligence-memory.test.ts@@ -0,0 +1,147 @@+import { expect, test } from "bun:test";+import {+ createIntelligenceMemory,+ type IntelligenceMemoryClient,+} from "../src/memory/intelligence";++function client(overrides: Partial<Record<string, unknown>> = {}) {+ const calls: string[] = [];+ const base = {+ async getRuntimeEntitlements() {+ calls.push("entitlements");+ return {+ status: "ready",+ entitlement: {+ active: true,+ source: "managedOrgSubscription",+ features: { memory: true },+ limits: {},+ },+ };+ },+ async listMemories() {+ calls.push("list");+ return {+ memories: [+ {+ id: "a",+ kind: "topical",+ scope: "user",+ content: "mine",+ sourceThreadIds: [],+ invalidatedAt: null,+ },+ {+ id: "p",+ kind: "topical",+ scope: "project",+ content: "everyone's",+ sourceThreadIds: [],+ invalidatedAt: null,+ },+ ],+ };+ },+ async createMemory() {+ calls.push("create");+ return {+ id: "new",+ kind: "topical",+ scope: "user",+ content: "x",+ sourceThreadIds: [],+ invalidatedAt: null,+ };+ },+ async updateMemory() {+ calls.push("update");+ throw Object.assign(new Error("gone"), { status: 404 });+ },+ async removeMemory() {+ calls.push("remove");+ },+ async recallMemories() {+ calls.push("recall");+ return { memories: [] };+ },+ ...overrides,+ };+ return { calls, client: base as unknown as IntelligenceMemoryClient };+}++test("project-scoped memories are dropped even when the platform returns them", async () => {+ const { client: fake } = client();+ const memory = createIntelligenceMemory({ client: fake, log: () => {} });+ expect((await memory.list("ada"))?.map((m) => m.id)).toEqual(["a"]);+});++test("not entitled: no memory call is made and every answer is empty", async () => {+ const { client: fake, calls } = client({+ async getRuntimeEntitlements() {+ calls.push("entitlements");+ return {+ status: "ready",+ entitlement: {+ active: true,+ source: "managedOrgSubscription",+ features: { memory: false },+ limits: {},+ },+ };+ },+ });+ const memory = createIntelligenceMemory({ client: fake, log: () => {} });+ expect(await memory.available()).toBe(false);+ expect(await memory.list("ada")).toBeUndefined();+ expect(await memory.create("ada", "x")).toBeUndefined();+ expect(calls.filter((call) => call !== "entitlements")).toEqual([]);+});++test("a 403 holds memory on the local store for a minute, then asks again", async () => {+ let clock = 0;+ let denied = true;+ const { client: fake, calls } = client({+ async listMemories() {+ calls.push("list");+ if (denied) throw Object.assign(new Error("denied"), { status: 403 });+ return { memories: [] };+ },+ });+ const memory = createIntelligenceMemory({+ client: fake,+ now: () => clock,+ log: () => {},+ });+ expect(await memory.list("ada")).toBeUndefined();+ denied = false;+ clock += 30_000;+ expect(await memory.list("ada")).toBeUndefined();+ expect(calls.filter((call) => call === "list")).toHaveLength(1);+ clock += 31_000;+ expect(await memory.list("ada")).toEqual([]);+});++test("a person's list is reused for a moment and cleared by their own write", async () => {+ let clock = 0;+ const { client: fake, calls } = client();+ const memory = createIntelligenceMemory({+ client: fake,+ now: () => clock,+ log: () => {},+ });+ await memory.list("ada");+ await memory.list("ada");+ expect(calls.filter((call) => call === "list")).toHaveLength(1);+ await memory.create("ada", "new fact");+ await memory.list("ada");+ expect(calls.filter((call) => call === "list")).toHaveLength(2);+ clock += 31_000;+ await memory.list("ada");+ expect(calls.filter((call) => call === "list")).toHaveLength(3);+});++test("superseding a memory that is already retired says so", async () => {+ const { client: fake } = client();+ const memory = createIntelligenceMemory({ client: fake, log: () => {} });+ expect(await memory.supersede("ada", "old", "new")).toBe("gone");+});diff --git a/server/tests/memory-intelligence.integration.test.ts b/server/tests/memory-intelligence.integration.test.tsnew file mode 100644index 00000000..009a5916--- /dev/null+++ b/server/tests/memory-intelligence.integration.test.ts@@ -0,0 +1,386 @@+import { afterAll, beforeAll, beforeEach, expect, test } from "bun:test";+import { randomUUID } from "node:crypto";+import { eq, inArray } from "drizzle-orm";+import { createDatabase } from "../src/db/client";+import { agents, users } from "../src/db/schema/core";+import { personalMemories } from "../src/db/schema/memory";+import {+ createIntelligenceMemory,+ type IntelligenceMemoryClient,+} from "../src/memory/intelligence";+import { createMemoryStore } from "../src/memory/store";+import {+ MemoryNotFoundError,+ MemoryRefusedError,+ MemoryUnavailableError,+} from "../src/memory/types";+import { TEST_POOL, testDatabaseUrl } from "./support/database";++/**+ * A stand-in for CopilotKit Intelligence memory: memories per user, retired rather than deleted,+ * project-scoped rows that must never reach a person, and switches for "not entitled" and+ * "unreachable". Every call is recorded so a test can assert who was asked about what.+ */+function fakeIntelligence() {+ type Row = {+ id: string;+ userId: string;+ scope: "user" | "project";+ content: string;+ invalidatedAt: string | null;+ };+ const rows: Row[] = [];+ const calls: { method: string; userId?: string; grant?: unknown }[] = [];+ const state = { entitled: true, down: false };+ let next = 1;+ const fail = (status: number) =>+ Object.assign(new Error(`HTTP ${status}`), { status });+ const guard = () => {+ if (state.down) throw new TypeError("fetch failed");+ if (!state.entitled) throw fail(403);+ };+ const summary = (row: Row) => ({+ id: row.id,+ kind: "topical",+ scope: row.scope,+ content: row.content,+ sourceThreadIds: [],+ invalidatedAt: row.invalidatedAt,+ });+ const client = {+ async getRuntimeEntitlements() {+ calls.push({ method: "getRuntimeEntitlements" });+ if (state.down) throw new TypeError("fetch failed");+ return {+ status: "ready",+ entitlement: {+ active: true,+ source: "managedOrgSubscription",+ features: { memory: state.entitled },+ limits: {},+ },+ };+ },+ async listMemories(params: { userId: string; memoryGrant?: unknown }) {+ calls.push({+ method: "listMemories",+ userId: params.userId,+ grant: params.memoryGrant,+ });+ guard();+ // A platform that ignored the grant: project rows come back too, and must be filtered out.+ return {+ memories: rows+ .filter(+ (row) =>+ !row.invalidatedAt &&+ (row.userId === params.userId || row.scope === "project"),+ )+ .map(summary),+ };+ },+ async recallMemories(params: {+ userId: string;+ query: string;+ memoryGrant?: unknown;+ }) {+ calls.push({+ method: "recallMemories",+ userId: params.userId,+ grant: params.memoryGrant,+ });+ guard();+ return {+ memories: rows+ .filter(+ (row) =>+ !row.invalidatedAt &&+ (row.userId === params.userId || row.scope === "project") &&+ row.content.toLowerCase().includes(params.query.toLowerCase()),+ )+ .map((row) => ({ ...summary(row), score: 0.9 })),+ };+ },+ async createMemory(params: {+ userId: string;+ content: string;+ memoryGrant?: unknown;+ }) {+ calls.push({+ method: "createMemory",+ userId: params.userId,+ grant: params.memoryGrant,+ });+ guard();+ const row: Row = {+ id: `int-${next++}`,+ userId: params.userId,+ scope: "user",+ content: params.content,+ invalidatedAt: null,+ };+ rows.push(row);+ return { ...summary(row), absorbed: false };+ },+ async updateMemory(params: {+ userId: string;+ id: string;+ content: string;+ memoryGrant?: unknown;+ }) {+ calls.push({ method: "updateMemory", userId: params.userId });+ guard();+ const old = rows.find(+ (row) =>+ row.id === params.id &&+ row.userId === params.userId &&+ !row.invalidatedAt,+ );+ if (!old) throw fail(404);+ old.invalidatedAt = new Date().toISOString();+ const row: Row = {+ id: `int-${next++}`,+ userId: params.userId,+ scope: "user",+ content: params.content,+ invalidatedAt: null,+ };+ rows.push(row);+ return { ...summary(row), retiredId: old.id };+ },+ async removeMemory(params: { userId: string; id: string }) {+ calls.push({ method: "removeMemory", userId: params.userId });+ guard();+ const row = rows.find(+ (candidate) =>+ candidate.id === params.id &&+ candidate.userId === params.userId &&+ !candidate.invalidatedAt,+ );+ if (!row) throw fail(404);+ row.invalidatedAt = new Date().toISOString();+ },+ };+ const live = (userId: string) =>+ rows.filter((row) => row.userId === userId && !row.invalidatedAt);+ const seed = (+ userId: string,+ content: string,+ scope: Row["scope"] = "user",+ ) => {+ const row: Row = {+ id: `int-${next++}`,+ userId,+ scope,+ content,+ invalidatedAt: null,+ };+ rows.push(row);+ return row.id;+ };+ return {+ client: client as unknown as IntelligenceMemoryClient,+ calls,+ state,+ live,+ seed,+ };+}++const database = createDatabase(testDatabaseUrl(), TEST_POOL);+const prefix = `memint-${randomUUID()}`;+const ada = `${prefix}-ada`;+const grace = `${prefix}-grace`;+const bot = `${prefix}-bot`;+const otherBot = `${prefix}-other-bot`;++let fake: ReturnType<typeof fakeIntelligence>;+let clock = 1_000_000;+let store: ReturnType<typeof createMemoryStore>;++beforeAll(async () => {+ await database.insert(users).values([+ { id: ada, email: `${ada}@example.test` },+ { id: grace, email: `${grace}@example.test` },+ ]);+ await database.insert(agents).values([+ { id: bot, name: "Bot", type: "built_in", configuration: {} },+ { id: otherBot, name: "Other", type: "built_in", configuration: {} },+ ]);+});+beforeEach(async () => {+ await database+ .delete(personalMemories)+ .where(inArray(personalMemories.ownerUserId, [ada, grace]));+ fake = fakeIntelligence();+ clock += 10 * 60_000 + 1;+ store = createMemoryStore(database, {+ intelligence: createIntelligenceMemory({+ client: fake.client,+ now: () => clock,+ log: () => {},+ }),+ });+});+afterAll(async () => {+ await database+ .delete(personalMemories)+ .where(inArray(personalMemories.ownerUserId, [ada, grace]));+ await database.delete(agents).where(inArray(agents.id, [bot, otherBot]));+ await database.delete(users).where(inArray(users.id, [ada, grace]));+ await database.$client.end();+});++const rowOf = async (id: string) =>+ (+ await database+ .select()+ .from(personalMemories)+ .where(eq(personalMemories.id, id))+ )[0];++test("a memory the person writes is stored in Intelligence, under that person only", async () => {+ const memory = await store.create(ada, {+ content: "Prefers morning meetings",+ });+ const row = await rowOf(memory.id);+ expect(row?.intelligenceMemoryId).toBeTruthy();+ expect(fake.live(ada).map((m) => m.content)).toEqual([+ "Prefers morning meetings",+ ]);+ expect(fake.live(grace)).toEqual([]);+ const writes = fake.calls.filter((call) => call.method === "createMemory");+ expect(writes.every((call) => call.userId === ada)).toBe(true);+ expect(writes[0]?.grant).toEqual({ user: "read-write", project: "none" });+});++test("an edit supersedes the Intelligence copy, and pausing or forgetting retires it", async () => {+ const memory = await store.create(ada, { content: "Lives in Lisbon" });+ const first = (await rowOf(memory.id))?.intelligenceMemoryId;+ await store.update(ada, memory.id, { content: "Lives in Porto" });+ const edited = await rowOf(memory.id);+ expect(edited?.intelligenceMemoryId).not.toBe(first);+ expect(fake.live(ada).map((m) => m.content)).toEqual(["Lives in Porto"]);++ await store.update(ada, memory.id, { enabled: false });+ expect(fake.live(ada)).toEqual([]);+ expect((await rowOf(memory.id))?.intelligenceMemoryId).toBeNull();++ await store.update(ada, memory.id, { enabled: true });+ expect(fake.live(ada).map((m) => m.content)).toEqual(["Lives in Porto"]);++ await store.remove(ada, memory.id);+ expect(fake.live(ada)).toEqual([]);+});++test("a Bot-formed memory reaches Intelligence only once the person confirms it", async () => {+ const formed = await store.formMemory(ada, {+ agentId: bot,+ content: "Owns the billing migration",+ sourceApp: "Linear",+ });+ expect(fake.live(ada)).toEqual([]);+ await store.update(ada, formed.id, { reviewState: "confirmed" });+ expect(fake.live(ada).map((m) => m.content)).toEqual([+ "Owns the billing migration",+ ]);+});++test("not entitled: nothing is sent, the tables are the whole store, and nothing fails", async () => {+ fake.state.entitled = false;+ const memory = await store.create(ada, { content: "Allergic to peanuts" });+ expect((await rowOf(memory.id))?.intelligenceMemoryId).toBeNull();+ expect(fake.calls.some((call) => call.method === "createMemory")).toBe(false);+ expect((await store.list(ada)).map((m) => m.content)).toEqual([+ "Allergic to peanuts",+ ]);+ const recalled = await store.retrieve(ada, [], "peanuts");+ expect(recalled.map((m) => m.content)).toEqual(["Allergic to peanuts"]);+});++test("unreachable: writes stay local and the next pass backfills them once, without duplicates", async () => {+ fake.state.down = true;+ const memory = await store.create(ada, { content: "Reports to Grace" });+ expect((await rowOf(memory.id))?.intelligenceMemoryId).toBeNull();+ expect((await store.list(ada)).map((m) => m.content)).toEqual([+ "Reports to Grace",+ ]);++ fake.state.down = false;+ clock += 61_000;+ expect(await store.mirrorPending()).toBeGreaterThan(0);+ expect(fake.live(ada).map((m) => m.content)).toEqual(["Reports to Grace"]);+ await store.mirrorPending();+ expect(fake.live(ada)).toHaveLength(1);+});++test("another person's Intelligence memories never reach this person, nor do project-wide ones", async () => {+ fake.seed(grace, "Grace's private fact");+ fake.seed(grace, "Shared across the project", "project");+ const own = fake.seed(ada, "Ada likes tea");+ const listed = await store.list(ada);+ expect(listed.map((m) => m.content)).toEqual(["Ada likes tea"]);+ expect(listed[0]?.id).toBe(`intelligence:${own}`);+ expect(listed[0]?.formedBy).toBe("intelligence");+ const recalled = await store.retrieve(ada, [], "fact");+ expect(recalled).toEqual([]);+ expect(+ fake.calls+ .filter((call) => call.userId !== undefined)+ .every((call) => call.userId === ada),+ ).toBe(true);+});++test("recall keeps a Bot-formed memory to the Bot that formed it", async () => {+ const formed = await store.formMemory(ada, {+ agentId: bot,+ content: "Deploy window is Thursday",+ sourceApp: "Calendar",+ });+ await store.update(ada, formed.id, { reviewState: "confirmed" });+ const forBot = await store.retrieve(ada, [], "deploy", {+ botId: bot,+ heldServerIds: new Set(),+ });+ expect(forBot.map((m) => m.id)).toEqual([formed.id]);+ const forOther = await store.retrieve(ada, [], "deploy", {+ botId: otherBot,+ heldServerIds: new Set(),+ });+ expect(forOther).toEqual([]);+});++test("a memory only Intelligence holds is the person's own: recalled, edited and forgotten here", async () => {+ const id = fake.seed(ada, "Uses vim keybindings");+ const context = await store.retrieve(ada, [], "");+ expect(context.map((m) => m.content)).toContain("Uses vim keybindings");+ const edited = await store.update(ada, `intelligence:${id}`, {+ content: "Uses emacs keybindings",+ });+ expect(fake.live(ada).map((m) => m.content)).toEqual([+ "Uses emacs keybindings",+ ]);+ await expect(+ store.update(ada, edited.id, { enabled: false }),+ ).rejects.toBeInstanceOf(MemoryRefusedError);+ await store.remove(ada, edited.id);+ expect(fake.live(ada)).toEqual([]);+});++test("a memory OpenBot describes cannot be forgotten through its Intelligence id", async () => {+ const memory = await store.create(ada, { content: "Has a dog" });+ const linked = (await rowOf(memory.id))?.intelligenceMemoryId;+ await expect(+ store.remove(ada, `intelligence:${linked}`),+ ).rejects.toBeInstanceOf(MemoryNotFoundError);+ expect(fake.live(ada)).toHaveLength(1);+});++test("editing an Intelligence-only memory while Intelligence is down answers unavailable, not a crash", async () => {+ const id = fake.seed(ada, "Speaks Portuguese");+ fake.state.down = true;+ clock += 10 * 60_000 + 1;+ await expect(+ store.update(ada, `intelligence:${id}`, { content: "Speaks Spanish" }),+ ).rejects.toBeInstanceOf(MemoryUnavailableError);+});