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.
Stop a ref resolving against a dead computer session (#173)
David McKay0d303a27323e
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 0a5d4315..cdc8f316 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -211,6 +211,14 @@ Sessions survive and nobody signs in again.is unavailable never blocks a sign-in.### Fixed+- **A ref could resolve against a page from a computer that no longer existed.** The generation a+ computer stamps on a snapshot is unique only within one run of it, so a replaced container counts+ from one again and a ref the model is still holding matches a row nothing has overwritten. The+ policy then decides on an element from a dead page, and the audit row names it. Wiping a computer+ cleared the row for that reason and was the only thing that did; replacing one whose image changed+ did not, and the server was never told. A snapshot now carries which run of the computer took it,+ refs from an earlier run resolve to nothing, and the first snapshot of a new run replaces the old+ row however low its generation.- **A migration stamped in the future silently swallowed the next one.** Drizzle runs a migration onlywhen its journal timestamp is later than the newest one the database has recorded, so a migrationstamped ahead of real time raises that ceiling and every migration written after it is skippeddiff --git a/server/drizzle/0014_snapshot_session.sql b/server/drizzle/0014_snapshot_session.sqlnew file mode 100644index 00000000..d753981d--- /dev/null+++ b/server/drizzle/0014_snapshot_session.sql@@ -0,0 +1,15 @@+-- Which run of the computer a snapshot belongs to.+--+-- The generation a computer stamps on a snapshot only tells snapshots apart within one session. A+-- replaced container counts from one again, so a ref the model still holds from the previous session+-- matches a row the new one has not overwritten, and the policy decides against an element from a+-- page that no longer exists.+--+-- `resetComputer` clears the row for exactly that reason, and it is the only thing that does. It is+-- not the only way a computer is replaced: the supervisor replaces one whose image has changed, and+-- the server is never told. So the row outlives the session that wrote it, and the generation cannot+-- tell.+--+-- Nullable because a deployment with one shared computer and no supervisor has no session to report.+-- There the comparison is skipped and the behaviour is what it was before this column.+ALTER TABLE "computer_snapshot" ADD COLUMN "session" text;diff --git a/server/drizzle/meta/0014_snapshot.json b/server/drizzle/meta/0014_snapshot.jsonnew file mode 100644index 00000000..ddafd5a1--- /dev/null+++ b/server/drizzle/meta/0014_snapshot.json@@ -0,0 +1,2354 @@+{+ "id": "b093192e-898a-459b-8199-49d6f2ae8098",+ "prevId": "9e190877-1798-426d-8275-a282e6f27db3",+ "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.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+ },+ "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": {}+ }+ },+ "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+ },+ "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+ },+ "last_message": {+ "name": "last_message",+ "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+ },+ "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": {}+ }+ },+ "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": {},+ "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_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+ },+ "groups": {+ "name": "groups",+ "type": "text[]",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'"+ },+ "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_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+ }+ },+ "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.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.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+ },+ "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+ },+ "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": {},+ "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"+ },+ "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+ }+ },+ "enums": {+ "public.agent_type": {+ "name": "agent_type",+ "schema": "public",+ "values": ["built_in", "remote_ag_ui"]+ },+ "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"]+ }+ },+ "schemas": {},+ "sequences": {},+ "roles": {},+ "policies": {},+ "views": {},+ "_meta": {+ "columns": {},+ "schemas": {},+ "tables": {}+ }+}diff --git a/server/drizzle/meta/_journal.json b/server/drizzle/meta/_journal.jsonindex 376b2dff..eb1713ba 100644--- a/server/drizzle/meta/_journal.json+++ b/server/drizzle/meta/_journal.json@@ -99,6 +99,13 @@"when": 1787380044372,"tag": "0013_skill_tools","breakpoints": true+ },+ {+ "idx": 14,+ "version": "7",+ "when": 1787380104372,+ "tag": "0014_snapshot_session",+ "breakpoints": true}]}diff --git a/server/src/computer/gateway.ts b/server/src/computer/gateway.tsindex 672842b3..9ab59b80 100644--- a/server/src/computer/gateway.ts+++ b/server/src/computer/gateway.ts@@ -317,10 +317,29 @@ export function createComputerGateway(elements: new Map(result.elements.map((element) => [element.ref, element]),),+ // Read after `locate`, which is the `/ensure` that reports it.+ ...(await sessionOf(botId)),});return result;}+ /**+ * Which run of the computer this is, shaped to spread into a snapshot.+ *+ * Absent for a provider that cannot say, and absent if asking fails: a session that cannot be read+ * must not stop a snapshot being recorded, because a snapshot nobody stored is a ref that resolves+ * to nothing and a boundary deciding with no element in front of it.+ */+ async function sessionOf(botId: string): Promise<{ session?: string }> {+ if (!provider.sessionOf) return {};+ try {+ const session = await provider.sessionOf(botId);+ return session ? { session } : {};+ } catch {+ return {};+ }+ }+async function read(botId: string): Promise<ReadResult> {return get<ReadResult>(botId, "/read");}@@ -342,8 +361,27 @@ export function createComputerGateway(stored: StoredSnapshot | undefined,ref: string | undefined,snapshotId: number | undefined,+ /**+ * The run of the computer the action is reaching, when the provider can say.+ *+ * Undefined means unknown, not mismatched: a provider with no sessions to report, or one that+ * could not be asked, leaves the generation check exactly as it was.+ */+ session?: string,): SnapshotElement | undefined {if (!ref || !stored || stored.snapshotId !== snapshotId) return undefined;+ /*+ * A generation is only unique within one run of the computer.+ *+ * A replaced container counts from one again, so a ref the model is still holding from the run+ * before matches a row nothing has overwritten, and the element handed to the policy belongs to+ * a page that no longer exists. `resetComputer` clears the row for that reason and is the only+ * thing that does; the supervisor replacing a computer whose image changed does not, and the+ * server is never told. Comparing the run closes both.+ */+ if (session && stored.session && stored.session !== session) {+ return undefined;+ }return stored.elements.get(ref);}@@ -376,7 +414,8 @@ export function createComputerGateway(// Loaded from the store, not this process's memory: the snapshot these refs belong to was very// likely taken by another replica, and resolving against a local map would find nothing there.const stored = await snapshots.load(botId);- const element = resolve(stored, ref, snapshotId);+ const { session } = await sessionOf(botId);+ const element = resolve(stored, ref, snapshotId, session);// For a navigation the relevant page is the one being opened, not the one already loaded. Using// the stored URL would mean `page.host == "..."` could never match the destination, which is the// only thing a rule about navigation would ever want to say.diff --git a/server/src/computer/provider.ts b/server/src/computer/provider.tsindex 950e9fe7..7993227c 100644--- a/server/src/computer/provider.ts+++ b/server/src/computer/provider.ts@@ -79,6 +79,15 @@ export interface ComputerProvider {list(): Promise<ComputerLocation[]>;/** Prepare provider resources before the first computer request. */warm?(): Promise<void>;+ /**+ * Which run of this Bot's computer is current, if the provider can tell.+ *+ * A snapshot's generation only orders snapshots within one run: a replaced container counts from+ * one again, so a ref from the run before it matches a row nothing has overwritten. This is what+ * tells the two apart. Optional because a deployment with one shared computer has no supervisor to+ * ask, and there the comparison is skipped and behaviour is unchanged.+ */+ sessionOf?(botId: string): Promise<string | undefined>;}export type SharedComputerProviderOptions = {diff --git a/server/src/computer/snapshot-store.ts b/server/src/computer/snapshot-store.tsindex 450c31fc..4bf26a90 100644--- a/server/src/computer/snapshot-store.ts+++ b/server/src/computer/snapshot-store.ts@@ -27,7 +27,7 @@* Without a database it stays in memory. Tests that only exercise decision logic do not need* Postgres, exactly as the policy store does not.*/-import { eq, lt } from "drizzle-orm";+import { eq, lt, ne, or, sql } from "drizzle-orm";import type { Database } from "../db/client";import { computerSnapshot } from "../db/schema";import type { SnapshotElement } from "./schema";@@ -42,6 +42,15 @@ export type StoredSnapshot = {snapshotId: number;url: string;elements: Map<string, SnapshotElement>;+ /**+ * Which run of the computer took it, when the provider can say.+ *+ * The generation only orders snapshots within one session. This is what tells two sessions apart,+ * so a ref from a computer that has since been replaced resolves to nothing instead of to whatever+ * now holds that ref. Undefined where there is no supervisor to ask, which leaves the behaviour as+ * it was.+ */+ session?: string;};export type SnapshotStore = {@@ -85,6 +94,7 @@ export function createSnapshotStore(database?: Database): SnapshotStore {url: snapshot.url,elements,takenAt: new Date(),+ session: snapshot.session ?? null,};await database.insert(computerSnapshot)@@ -99,6 +109,7 @@ export function createSnapshotStore(database?: Database): SnapshotStore {url: values.url,elements: values.elements,takenAt: values.takenAt,+ session: values.session,},// Only ever forward. The generation is stamped by the computer and increases by one per// snapshot, so a lower number is an older page. Two replicas snapshotting the same computer@@ -106,7 +117,27 @@ export function createSnapshotStore(database?: Database): SnapshotStore {// last would win, so the older snapshot could overwrite the newer one and every ref the// model is holding would stop resolving. Timestamps cannot decide it, because they come// from two machines' clocks; the generation comes from one.- setWhere: lt(computerSnapshot.snapshotId, values.snapshotId),+ /*+ * Forward within a session, and always across one.+ *+ * The generation guard is right while the computer is the same computer. It is wrong the+ * moment it is replaced: the new session counts from one, so every snapshot it takes looks+ * older than the dead row and none of them land. The row then describes a page nobody is+ * on until the counter climbs back past it, and the one that finally matches resolves refs+ * against the dead page.+ *+ * A different session is therefore not a stale write to be refused. It is the only write+ * that can be right.+ */+ setWhere: or(+ lt(computerSnapshot.snapshotId, values.snapshotId),+ values.session === null+ ? sql`${computerSnapshot.session} is not null`+ : or(+ sql`${computerSnapshot.session} is null`,+ ne(computerSnapshot.session, values.session),+ ),+ ),});},@@ -129,6 +160,7 @@ export function createSnapshotStore(database?: Database): SnapshotStore {elements: elementsFromObject(row.elements as Record<string, SnapshotElement>,),+ ...(row.session ? { session: row.session } : {}),};},};@@ -151,7 +183,11 @@ export function createInMemorySnapshotStore(): SnapshotStore {// no database would otherwise be told a different story about what the gateway resolves// against: the older page here, the newer one in a deployment.const held = snapshots.get(computerId);- if (held && held.snapshotId >= snapshot.snapshotId) return;+ // Same rule as the table: forward within a session, and always across one. A replaced computer+ // counts from one again, so refusing its snapshots for being "older" leaves the dead page in+ // place until the counter climbs back past it.+ const sameSession = held?.session === snapshot.session;+ if (held && sameSession && held.snapshotId >= snapshot.snapshotId) return;snapshots.set(computerId, snapshot);},load: async (computerId) => snapshots.get(computerId),diff --git a/server/src/computer/supervisor.ts b/server/src/computer/supervisor.tsindex 2af756c7..37c388f7 100644--- a/server/src/computer/supervisor.ts+++ b/server/src/computer/supervisor.ts@@ -16,6 +16,14 @@import type { ComputerStatus } from "./schema";import type { ComputerLocation, ComputerProvider } from "./provider";+/**+ * The last container start time seen for each Bot, from the `/ensure` that located it.+ *+ * Not a cache in front of the supervisor: `locate` still calls it every time. This only carries the+ * answer the few lines to whoever needs to know which run of the computer they are talking to.+ */+const sessions = new Map<string, string>();+type SupervisorComputerLocation = {botId: string;container?: string;@@ -146,10 +154,22 @@ export function createDockerSupervisorProvider(* is an error rather than a URL, the alternative is a caller quietly falling back to somebody* else's computer.*/+ async sessionOf(botId: string): Promise<string | undefined> {+ /*+ * Read from the same `/ensure` every action already makes, and remembered rather than asked+ * for again: `locate` runs immediately before the call that needs this, so the value is as+ * fresh as the address it was fetched with. Asking twice would double the supervisor's work on+ * the hot path to learn something it just told us.+ */+ return sessions.get(botId);+ },+async locate(botId: string): Promise<string> {const state = (await call(`/computers/${encodeURIComponent(botId)}/ensure`,)) as SupervisorComputerLocation;+ // Recorded on every ensure, so a replaced container is visible to whatever asks next.+ if (state?.startedAt) sessions.set(botId, state.startedAt);// The supervisor says where it is, because only it knows whether these computers sit on a// shared network or answer on a published port.if (state?.url) return state.url;diff --git a/server/src/db/schema/computer.ts b/server/src/db/schema/computer.tsindex 78e46ddf..87b508d5 100644--- a/server/src/db/schema/computer.ts+++ b/server/src/db/schema/computer.ts@@ -65,4 +65,18 @@ export const computerSnapshot = pgTable("computer_snapshot", {/** The interactive elements, keyed by ref. The one thing resolve looks a ref up in. */elements: jsonb("elements").notNull(),takenAt: timestamp("taken_at", { withTimezone: true }).notNull().defaultNow(),+ /**+ * Which run of the computer took it.+ *+ * The generation only tells snapshots apart within one session: a replaced container counts from+ * one again, so a ref from a dead session matches a row the new one has not overwritten yet, and+ * the policy decides against an element from a page that no longer exists. Reset clears the row+ * for exactly that reason, but reset is not the only way a computer is replaced — an image change+ * does it too, and the server is never told. This is the session, so a stale row is recognisable+ * without anybody having to remember to delete it.+ *+ * Null where the provider cannot say, which is a deployment with one shared computer and no+ * supervisor. There the behaviour is what it was before this column existed.+ */+ session: text("session"),});diff --git a/server/tests/computer-gateway.test.ts b/server/tests/computer-gateway.test.tsindex 4021b0c2..a71dc908 100644--- a/server/tests/computer-gateway.test.ts+++ b/server/tests/computer-gateway.test.ts@@ -43,6 +43,8 @@ function fakeComputer(options?: {resetResult?: { cleared: boolean };locations?: ComputerLocation[];routes?: Record<string, (init?: RequestInit) => Response | Promise<Response>>;+ /** Which run of the computer this stands for. Absent means a provider that cannot say. */+ session?: () => string | undefined;}) {const calls: string[] = [];const addressedAs: string[] = [];@@ -62,6 +64,7 @@ function fakeComputer(options?: {addressedAs.push(botId);return "http://agent-computer:4100";},+ ...(options?.session ? { sessionOf: async () => options.session?.() } : {}),status: async (botId) => ({ botId, state: "ready" }),stop: async (botId) => {calls.push(`stop:${botId}`);@@ -1075,3 +1078,75 @@ describe("resolving a ref across replicas", () => {expect(afterReset.element).toBeUndefined();});});++/**+ * A ref from a computer that has since been replaced.+ *+ * The generation a computer stamps on a snapshot is unique only within one run of it. A replaced+ * container counts from one again, so a ref the model is still holding from the run before matches+ * a row nothing has overwritten, and the element handed to the policy belongs to a page that no+ * longer exists: a deny rule about "Confirm transfer" fires on a click that is nowhere near it, or+ * worse, does not fire on one that is.+ *+ * `resetComputer` clears the row for exactly that reason and is the only thing that does. The+ * supervisor replaces a computer whose image has changed without telling the server, so the row+ * outlives the run that wrote it and nothing notices.+ */+describe("a ref that outlived its computer", () => {+ test("does not resolve against the dead run's page", async () => {+ const snapshots = createInMemorySnapshotStore();+ let run = "run-1";+ const { provider, fetchImpl } = fakeComputer({ session: () => run });+ const { store, rows } = fakeAudit();+ const gateway = createComputerGateway({+ provider,+ fetchImpl,+ auditStore: store,+ policy: () => PERMISSIVE,+ snapshots,+ });++ const taken = await gateway.snapshot("bot-1");+ // The computer is replaced. Its generation counter starts again, and nothing clears the row.+ run = "run-2";++ /*+ * The same generation the model is still holding, now belonging to a different run. Resolving it+ * would hand the policy an element from the dead page; refusing to resolve leaves the boundary+ * deciding with no element, which is the honest answer and the one a deny rule treats as a+ * match.+ */+ await gateway.click("bot-1", ACTOR, {+ ref: "e9",+ snapshotId: taken.snapshotId,+ });++ // Recorded as unresolved rather than as the dead page's button, which is what the audit row+ // said before: `element: { name: "Confirm transfer" }` on a click nowhere near it.+ expect(rows.at(-1)?.payload.element).toBe("not in the current snapshot");+ });++ test("still resolves while the computer is the same one", async () => {+ // The control. A session check that refused everything would look identical in the test above.+ const snapshots = createInMemorySnapshotStore();+ const { provider, fetchImpl } = fakeComputer({ session: () => "run-1" });+ const { store, rows } = fakeAudit();+ const gateway = createComputerGateway({+ provider,+ fetchImpl,+ auditStore: store,+ policy: () => PERMISSIVE,+ snapshots,+ });++ const taken = await gateway.snapshot("bot-1");+ await gateway.click("bot-1", ACTOR, {+ ref: "e9",+ snapshotId: taken.snapshotId,+ });++ expect(rows.at(-1)?.payload.element).toMatchObject({+ name: "Submit order",+ });+ });+});diff --git a/server/tests/computer-snapshot-store.test.ts b/server/tests/computer-snapshot-store.test.tsindex 3f30d10e..77e00231 100644--- a/server/tests/computer-snapshot-store.test.ts+++ b/server/tests/computer-snapshot-store.test.ts@@ -148,3 +148,82 @@ describe("the in-memory snapshot store", () => {);});});++describe("a computer that has been replaced", () => {+ /*+ * The generation only orders snapshots within one run of the computer.+ *+ * A replaced container counts from one again, so its first snapshots look older than the row the+ * dead one left behind and none of them land. The row then describes a page nobody is on, and the+ * generation that finally matches resolves refs against it: the policy decides on an element from+ * a page that no longer exists, and the audit row names it.+ *+ * `resetComputer` clears the row for exactly this reason and is the only thing that does. The+ * supervisor replacing a computer whose image has changed does not, and the server is never told,+ * so the row outlives the session that wrote it.+ */+ test("its first snapshot replaces the dead one, however low the generation", async () => {+ const store = createInMemorySnapshotStore();+ await store.save("bot", {+ snapshotId: 7,+ url: "https://bank.example/transfer",+ elements: new Map([+ ["e9", { ref: "e9", role: "button", name: "Confirm transfer" }],+ ]),+ session: "2026-08-22T10:00:00Z",+ });++ await store.save("bot", {+ snapshotId: 1,+ url: "https://docs.example/index",+ elements: new Map([+ ["e9", { ref: "e9", role: "link", name: "Table of contents" }],+ ]),+ session: "2026-08-22T11:00:00Z",+ });++ const held = await store.load("bot");+ expect(held?.snapshotId).toBe(1);+ expect(held?.url).toBe("https://docs.example/index");+ expect(held?.session).toBe("2026-08-22T11:00:00Z");+ });++ test("within one session the generation still only goes forward", async () => {+ // The guard the replacement case must not undo: two replicas snapshotting at once, where the+ // older write must not overwrite the newer one.+ const store = createInMemorySnapshotStore();+ const session = "2026-08-22T10:00:00Z";+ await store.save("bot", {+ snapshotId: 7,+ url: "https://example.com/new",+ elements: new Map(),+ session,+ });+ await store.save("bot", {+ snapshotId: 5,+ url: "https://example.com/old",+ elements: new Map(),+ session,+ });++ expect((await store.load("bot"))?.url).toBe("https://example.com/new");+ });++ test("a provider that reports no session behaves as it did", async () => {+ // One shared computer and no supervisor: nothing to compare, so the generation rule stands+ // alone rather than every save counting as a new session and overwriting the last.+ const store = createInMemorySnapshotStore();+ await store.save("bot", {+ snapshotId: 7,+ url: "https://example.com/new",+ elements: new Map(),+ });+ await store.save("bot", {+ snapshotId: 5,+ url: "https://example.com/old",+ elements: new Map(),+ });++ expect((await store.load("bot"))?.url).toBe("https://example.com/new");+ });+});diff --git a/supervisor/src/docker.ts b/supervisor/src/docker.tsindex 048068d1..6938bb95 100644--- a/supervisor/src/docker.ts+++ b/supervisor/src/docker.ts@@ -167,9 +167,12 @@ export async function listOwned(): Promise<ComputerState[]> {** Ownership is checked here rather than at the call sites, so no verb can skip it by accident.*/-async function inspectOwned(- names: ComputerNames,-): Promise<{ status: string; port?: number; image?: string } | null> {+async function inspectOwned(names: ComputerNames): Promise<{+ status: string;+ port?: number;+ image?: string;+ startedAt?: string;+} | null> {try {const info = await docker.getContainer(names.container).inspect();if (!ours(info.Config?.Labels)) return null;@@ -181,6 +184,15 @@ async function inspectOwned(// The resolved image, not the tag it was started from. A tag moves when the image is// rebuilt; this is what the container is actually running....(info.Image ? { image: info.Image } : {}),+ /*+ * When this run of the container began, which is what tells two runs apart.+ *+ * `State.StartedAt` rather than `Created`, because a restart is a new run: the browser has+ * lost every page it had, so the refs the server handed out from the previous one describe+ * pages that no longer exist. `listOwned` reports `Created` for "how long has this been up",+ * which is a different question.+ */+ ...(info.State?.StartedAt ? { startedAt: info.State.StartedAt } : {}),};} catch (error) {if ((error as { statusCode?: number }).statusCode === 404) return null;@@ -479,6 +491,7 @@ export async function ensure(botId: names.botId,container: names.container,status: settled?.status ?? "unknown",+ ...(settled?.startedAt ? { startedAt: settled.startedAt } : {}),...(settled?.port ? { port: settled.port } : {}),// How to reach it. A name on a shared network, a host port otherwise, the caller does not have// to know which arrangement it is in.