UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

6,480 lines • 169 kB
import { n as isPostgresSqlConnection } from "./sql-connection-Beiyg5Dt.mjs";
import { t as OPENCLAW_AGENT_SCHEMA_VERSION } from "./openclaw-schema-versions-E_10NoI6.mjs";
import { G as postgresVectorDecoderSql, H as postgresSearchTextTriggerSql, W as postgresSearchVectorSql, _ as captureSqliteSchemaFacts, o as getAdmittedSqliteSchemaFacts, t as admitSqliteSchema, w as getPostgresPhysicalFacts } from "./sqlite-schema-facts-B1bVE8IB.mjs";
import { t as VERSION } from "./version-GlxUMdxI.mjs";
import { n as publishAgentSchemaMetadata, r as readExistingAgentSchemaMeta } from "./openclaw-agent-db-metadata-C3YvwHLh.mjs";
import { a as runSqliteImmediateTransactionSync } from "./sqlite-transaction-BHHu6P5-.mjs";
import { t as getDatabaseEngineInput } from "./context-DE59wyBs.mjs";
import { a as admitStoreSearch, o as arePostgresSearchExtensionsAdmitted } from "./adapters-D8O-uubH.mjs";
import { t as openEngineStore } from "./open-jth9KEHn.mjs";
import { n as withLegacyPostgresIndexOrdering, t as postgresIndexOrderingMigration } from "./postgres-index-ordering-CLLgXtNR.mjs";
import "./openclaw-agent-db-contract-aCH9b8Uc.mjs";
import { n as MEMORY_PATH_POSTGRES_INDEX_SQL } from "./memory-path-postgres-BFFUO8hg.mjs";
import { _ as withoutAgentPostgresColdArchiveChunks, a as AGENT_MEMORY_REVISION_POSTGRES_SQL, d as AGENT_INDEX_RETIREMENT_SQL, h as agentColdArchiveChunksPostgresMigration, p as withLegacyAgentPostgresIndexes, r as withLegacyAgentPostgresTrajectoryStorage, t as AGENT_TRAJECTORY_STORAGE_POSTGRES_MIGRATION_SQL, u as withLegacyAgentPostgresMemoryRevisionTriggers } from "./openclaw-agent-trajectory-storage-migration-BbWlWZSu.mjs";
import { r as assertAgentDatabaseMaintenanceAuthority } from "./openclaw-agent-db-maintenance-authority-C4Yhyki9.mjs";
import { n as assertCurrentAgentSchemaMetadata } from "./openclaw-agent-db-schema-read-U5-_81Kg.mjs";
import { t as agentTranscriptSearchSchema } from "./openclaw-agent-search-schema-Cl1T033f.mjs";
import { r as withLegacyAgentPostgresWriteLayout, t as AGENT_WRITE_LAYOUT_POSTGRES_MIGRATION_SQL } from "./openclaw-agent-write-layout-migration-BPVNzU5a.mjs";
//#region src/state/openclaw-agent-memory-path-migration.ts
/** Reconstruct the exact predecessor before any older version transforms. */
function withLegacyAgentPostgresMemoryPaths(e) {
	return e.replace(`${MEMORY_PATH_POSTGRES_INDEX_SQL}\n\n`, "");
}
//#endregion
//#region src/state/openclaw-agent-text-search-migration.ts
const template = (e) => e.replaceAll("%", "%%").replaceAll("__TABLE__", "%1$s").replaceAll("__FIELD__", "%2$s").replaceAll("__SYNC__", "%3$s").replaceAll("__CONFIG__", "%4$L").replaceAll("'", "''");
const trigger = template(postgresSearchTextTriggerSql({
	table: "__TABLE__",
	field: "__FIELD__",
	sync: "__SYNC__"
}));
const backfill = template(`UPDATE __TABLE__ SET openclaw_search = ${postgresSearchVectorSql("__CONFIG__", "__FIELD__", 2)}`);
const AGENT_TEXT_SEARCH_POSTGRES_SQL = `DO $migration$
DECLARE text_index jsonb; tbl text; fld text; sync text;
  config text := format('%I.%I', current_schema(), 'openclaw_simple_unaccent');
BEGIN
  FOR text_index IN
    SELECT jsonb_build_object('table', 'session_transcript_fts', 'fields', jsonb_build_array('text'))
    UNION ALL
    SELECT indexes.value FROM openclaw_schema_meta meta,
      jsonb_each(coalesce((to_jsonb(meta)->>'search_extensions')::jsonb, '{}'::jsonb)) extensions,
      jsonb_each(coalesce(extensions.value->'text', '{}'::jsonb)) indexes
    WHERE meta.store = 'agent'
  LOOP
    IF to_regclass(format('%I', text_index->>'table')) IS NULL THEN CONTINUE; END IF;
    tbl := '"' || replace(text_index->>'table', '"', '""') || '"';
    fld := '"' || replace(text_index->'fields'->>0, '"', '""') || '"';
    sync := '"' || replace((text_index->>'table') || '_search_sync', '"', '""') || '"';
    EXECUTE format('ALTER TABLE %s ALTER COLUMN openclaw_search DROP EXPRESSION', tbl);
    EXECUTE format('${trigger}', tbl, fld, sync);
    EXECUTE format('${backfill}', tbl, fld, sync, config);
  END LOOP;
END $migration$;`;
//#endregion
//#region src/state/openclaw-agent-vector-decoder-migration.ts
const AGENT_VECTOR_DECODER_POSTGRES_SQL = `DO $migration$
DECLARE extension_schema text;
BEGIN
  SELECT n.nspname INTO extension_schema
  FROM pg_catalog.pg_proc p
  JOIN pg_catalog.pg_type t ON t.oid = p.prorettype
  JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace
  WHERE p.oid = to_regprocedure(format('%I.openclaw_vector(bytea,integer)', current_schema()));
  IF FOUND THEN
    EXECUTE replace($decoder$${postgresVectorDecoderSql("__vector_extension__", 2, true)}$decoder$,
      '__vector_extension__', replace(extension_schema, '"', '""'));
  END IF;
END $migration$;`;
//#endregion
//#region src/state/openclaw-agent-vector-search-migration.ts
const AGENT_VECTOR_SEARCH_POSTGRES_SQL = `DO $migration$
DECLARE definition jsonb; vector_index jsonb; extension_schema text; dimensions integer; extension_version text[];
BEGIN
  SELECT regexp_match(extversion, '^([0-9]+)[.]([0-9]+)') INTO extension_version
  FROM pg_catalog.pg_extension WHERE extname = 'vector';
  FOR definition IN
    SELECT value FROM openclaw_schema_meta meta,
      jsonb_each(coalesce((to_jsonb(meta)->>'search_extensions')::jsonb, '{}'::jsonb))
    WHERE meta.store = 'agent'
  LOOP
    IF definition->>'mode' = 'keyword-only' THEN CONTINUE; END IF;
    extension_schema := coalesce(definition->>'extensionSchema', 'public');
    FOR vector_index IN SELECT value FROM jsonb_each(coalesce(definition->'vector', '{}'::jsonb))
    LOOP
      IF extension_version IS NULL OR (extension_version[1]::integer = 0 AND extension_version[2]::integer < 7) THEN
        RAISE EXCEPTION 'PostgreSQL binary vector search requires pgvector 0.7 or newer. Upgrade the server extension package, then have a database administrator run ALTER EXTENSION vector UPDATE before reopening the store.';
      END IF;
      dimensions := (vector_index->'postgres'->>'dimensions')::integer;
      EXECUTE format(
        'ALTER TABLE %I ADD COLUMN embedding_bits bit(%s) GENERATED ALWAYS AS (CASE WHEN %I.vector_norm(embedding) > 0 THEN %I.binary_quantize(embedding)::bit(%s) ELSE NULL END) STORED',
        vector_index->>'table', dimensions, extension_schema, extension_schema, dimensions);
    END LOOP;
  END LOOP;
END $migration$;`;
//#endregion
//#region src/state/postgres-schema.generated/agent-runtime.ts
const agentPostgresRuntime = {
	sql: "-- Generated runtime DDL; the owner supplies search_path and the transaction.\n\nCREATE FUNCTION \"openclaw_transcript_navigation_check\"(navigation_json text) RETURNS boolean LANGUAGE sql IMMUTABLE STRICT SET search_path = pg_catalog AS $navigation$\nWITH input AS (SELECT CASE WHEN navigation_json IS JSON THEN navigation_json::json END AS document),\nmembers AS (SELECT (SELECT member.value FROM json_each(CASE WHEN json_typeof(document) = 'object' THEN document ELSE '{}'::json END) WITH ORDINALITY AS member(key, value, position) WHERE member.key = 'version' ORDER BY member.position LIMIT 1) AS \"j_version\",\n(SELECT member.value FROM json_each(CASE WHEN json_typeof(document) = 'object' THEN document ELSE '{}'::json END) WITH ORDINALITY AS member(key, value, position) WHERE member.key = 'modelBytes' ORDER BY member.position LIMIT 1) AS \"j_modelBytes\",\n(SELECT member.value FROM json_each(CASE WHEN json_typeof(document) = 'object' THEN document ELSE '{}'::json END) WITH ORDINALITY AS member(key, value, position) WHERE member.key = 'modelWithoutCheckpointBytes' ORDER BY member.position LIMIT 1) AS \"j_modelWithoutCheckpointBytes\",\n(SELECT member.value FROM json_each(CASE WHEN json_typeof(document) = 'object' THEN document ELSE '{}'::json END) WITH ORDINALITY AS member(key, value, position) WHERE member.key = 'withoutCustomDataBytes' ORDER BY member.position LIMIT 1) AS \"j_withoutCustomDataBytes\",\n(SELECT member.value FROM json_each(CASE WHEN json_typeof(document) = 'object' THEN document ELSE '{}'::json END) WITH ORDINALITY AS member(key, value, position) WHERE member.key = 'report' ORDER BY member.position LIMIT 1) AS \"j_report\",\n(SELECT member.value FROM json_each(CASE WHEN json_typeof((SELECT member.value FROM json_each(CASE WHEN json_typeof(document) = 'object' THEN document ELSE '{}'::json END) WITH ORDINALITY AS member(key, value, position) WHERE member.key = 'report' ORDER BY member.position LIMIT 1)) = 'object' THEN (SELECT member.value FROM json_each(CASE WHEN json_typeof(document) = 'object' THEN document ELSE '{}'::json END) WITH ORDINALITY AS member(key, value, position) WHERE member.key = 'report' ORDER BY member.position LIMIT 1) ELSE '{}'::json END) WITH ORDINALITY AS member(key, value, position) WHERE member.key = 'kind' ORDER BY member.position LIMIT 1) AS \"j_report.kind\",\n(SELECT member.value FROM json_each(CASE WHEN json_typeof(document) = 'object' THEN document ELSE '{}'::json END) WITH ORDINALITY AS member(key, value, position) WHERE member.key = 'navigation' ORDER BY member.position LIMIT 1) AS \"j_navigation\",\n(SELECT member.value FROM json_each(CASE WHEN json_typeof(document) = 'object' THEN document ELSE '{}'::json END) WITH ORDINALITY AS member(key, value, position) WHERE member.key = 'reset' ORDER BY member.position LIMIT 1) AS \"j_reset\",\n(SELECT member.value FROM json_each(CASE WHEN json_typeof(document) = 'object' THEN document ELSE '{}'::json END) WITH ORDINALITY AS member(key, value, position) WHERE member.key = 'model' ORDER BY member.position LIMIT 1) AS \"j_model\" FROM input)\nSELECT \"navigation_json\" IS NULL OR CASE WHEN (\"navigation_json\" IS JSON) THEN coalesce((octet_length(\"navigation_json\") <= 16384) AND (CASE WHEN json_typeof(\"j_version\") = 'number' AND (\"j_version\" #>> '{}') ~ '^-?[0-9]+$' THEN 'integer' WHEN json_typeof(\"j_version\") = 'number' THEN 'real' ELSE json_typeof(\"j_version\") END = 'integer') AND (CASE WHEN json_typeof(\"j_version\") = 'number' AND (\"j_version\" #>> '{}') ~ '^-?[0-9]+$' AND char_length((\"j_version\" #>> '{}')) <= 20 THEN (\"j_version\" #>> '{}')::numeric END = 1) AND (CASE WHEN json_typeof(\"j_report\") = 'number' AND (\"j_report\" #>> '{}') ~ '^-?[0-9]+$' THEN 'integer' WHEN json_typeof(\"j_report\") = 'number' THEN 'real' ELSE json_typeof(\"j_report\") END = 'object') AND (CASE WHEN json_typeof(\"j_report.kind\") = 'string' THEN (\"j_report.kind\" #>> '{}') END IN ('canonical', 'leaf', 'link', 'ignored')) AND (CASE WHEN json_typeof(\"j_navigation\") = 'number' AND (\"j_navigation\" #>> '{}') ~ '^-?[0-9]+$' THEN 'integer' WHEN json_typeof(\"j_navigation\") = 'number' THEN 'real' ELSE json_typeof(\"j_navigation\") END = 'object') AND (CASE WHEN json_typeof(\"j_reset\") = 'number' AND (\"j_reset\" #>> '{}') ~ '^-?[0-9]+$' THEN 'integer' WHEN json_typeof(\"j_reset\") = 'number' THEN 'real' ELSE json_typeof(\"j_reset\") END = 'object') AND (CASE WHEN json_typeof(\"j_model\") = 'number' AND (\"j_model\" #>> '{}') ~ '^-?[0-9]+$' THEN 'integer' WHEN json_typeof(\"j_model\") = 'number' THEN 'real' ELSE json_typeof(\"j_model\") END = 'object') AND (CASE WHEN json_typeof(\"j_modelBytes\") = 'number' AND (\"j_modelBytes\" #>> '{}') ~ '^-?[0-9]+$' THEN 'integer' WHEN json_typeof(\"j_modelBytes\") = 'number' THEN 'real' ELSE json_typeof(\"j_modelBytes\") END = 'integer') AND (CASE WHEN json_typeof(\"j_modelBytes\") = 'number' AND (\"j_modelBytes\" #>> '{}') ~ '^-?[0-9]+$' AND char_length((\"j_modelBytes\" #>> '{}')) <= 20 THEN (\"j_modelBytes\" #>> '{}')::numeric END BETWEEN 0 AND 4194304) AND (CASE WHEN json_typeof(\"j_modelWithoutCheckpointBytes\") = 'number' AND (\"j_modelWithoutCheckpointBytes\" #>> '{}') ~ '^-?[0-9]+$' THEN 'integer' WHEN json_typeof(\"j_modelWithoutCheckpointBytes\") = 'number' THEN 'real' ELSE json_typeof(\"j_modelWithoutCheckpointBytes\") END = 'integer') AND (CASE WHEN json_typeof(\"j_modelWithoutCheckpointBytes\") = 'number' AND (\"j_modelWithoutCheckpointBytes\" #>> '{}') ~ '^-?[0-9]+$' AND char_length((\"j_modelWithoutCheckpointBytes\" #>> '{}')) <= 20 THEN (\"j_modelWithoutCheckpointBytes\" #>> '{}')::numeric END BETWEEN 0 AND 4194304) AND (CASE WHEN json_typeof(\"j_withoutCustomDataBytes\") = 'number' AND (\"j_withoutCustomDataBytes\" #>> '{}') ~ '^-?[0-9]+$' THEN 'integer' WHEN json_typeof(\"j_withoutCustomDataBytes\") = 'number' THEN 'real' ELSE json_typeof(\"j_withoutCustomDataBytes\") END = 'integer') AND (CASE WHEN json_typeof(\"j_withoutCustomDataBytes\") = 'number' AND (\"j_withoutCustomDataBytes\" #>> '{}') ~ '^-?[0-9]+$' AND char_length((\"j_withoutCustomDataBytes\" #>> '{}')) <= 20 THEN (\"j_withoutCustomDataBytes\" #>> '{}')::numeric END BETWEEN 0 AND 4194304), FALSE) ELSE FALSE END FROM members;\n$navigation$;\n\nCREATE TABLE \"acp_parent_stream_events\" (\n  \"session_id\" text COLLATE \"C\" NOT NULL,\n  \"run_id\" text COLLATE \"C\" NOT NULL,\n  \"seq\" bigint NOT NULL,\n  \"event_json\" text COLLATE \"C\" NOT NULL,\n  \"created_at\" bigint NOT NULL,\n  PRIMARY KEY (\"session_id\", \"run_id\", \"seq\")\n);\n\nCREATE TABLE \"auth_profile_state\" (\n  \"state_key\" text COLLATE \"C\" NOT NULL,\n  \"state_json\" text COLLATE \"C\" NOT NULL,\n  \"updated_at\" bigint NOT NULL,\n  PRIMARY KEY (\"state_key\")\n);\n\nCREATE TABLE \"auth_profile_store\" (\n  \"store_key\" text COLLATE \"C\" NOT NULL,\n  \"store_json\" text COLLATE \"C\" NOT NULL,\n  \"updated_at\" bigint NOT NULL,\n  PRIMARY KEY (\"store_key\")\n);\n\nCREATE TABLE \"board_tabs\" (\n  \"session_key\" text COLLATE \"C\" NOT NULL,\n  \"tab_id\" text COLLATE \"C\" NOT NULL,\n  \"title\" text COLLATE \"C\" NOT NULL,\n  \"position\" bigint NOT NULL,\n  \"chat_dock\" text COLLATE \"C\" NOT NULL DEFAULT 'right',\n  \"created_by\" text COLLATE \"C\" NOT NULL,\n  \"revision\" bigint NOT NULL,\n  PRIMARY KEY (\"session_key\", \"tab_id\"),\n  CHECK ((\"position\" >= 0)),\n  CHECK ((\"chat_dock\" IN ('left', 'right', 'bottom', 'hidden'))),\n  CHECK ((\"created_by\" IN ('user', 'agent'))),\n  CHECK ((\"revision\" >= 0))\n);\n\nCREATE TABLE \"board_widgets\" (\n  \"session_key\" text COLLATE \"C\" NOT NULL,\n  \"name\" text COLLATE \"C\" NOT NULL,\n  \"tab_id\" text COLLATE \"C\" NOT NULL,\n  \"title\" text COLLATE \"C\",\n  \"content_kind\" text COLLATE \"C\" NOT NULL,\n  \"html\" bytea,\n  \"descriptor_json\" text COLLATE \"C\",\n  \"sha256\" text COLLATE \"C\" NOT NULL,\n  \"view_generation\" text COLLATE \"C\",\n  \"revision\" bigint NOT NULL,\n  \"size_w\" bigint NOT NULL,\n  \"size_h\" bigint NOT NULL,\n  \"position\" bigint NOT NULL,\n  \"manifest\" text COLLATE \"C\" NOT NULL DEFAULT '{}',\n  \"grant_state\" text COLLATE \"C\" NOT NULL DEFAULT 'none',\n  \"granted_sha\" text COLLATE \"C\",\n  \"created_by\" text COLLATE \"C\" NOT NULL,\n  \"created_at\" bigint NOT NULL,\n  \"updated_at\" bigint NOT NULL,\n  PRIMARY KEY (\"session_key\", \"name\"),\n  CHECK ((\"content_kind\" IN ('html', 'mcp-app', 'plugin'))),\n  CHECK ((\"revision\" >= 1)),\n  CHECK ((\"size_w\" BETWEEN 1 AND 12)),\n  CHECK ((\"size_h\" BETWEEN 1 AND 20)),\n  CHECK ((\"position\" >= 0)),\n  CHECK ((\"grant_state\" IN ('none', 'pending', 'granted', 'rejected'))),\n  CHECK ((\"created_by\" IN ('user', 'agent'))),\n  CHECK (((\"content_kind\" = 'html') AND \"html\" IS NOT NULL AND \"descriptor_json\" IS NULL AND \"view_generation\" IS NOT NULL) OR ((\"content_kind\" = 'mcp-app') AND \"html\" IS NULL AND \"descriptor_json\" IS NOT NULL AND \"view_generation\" IS NULL) OR ((\"content_kind\" = 'plugin') AND \"html\" IS NULL AND \"descriptor_json\" IS NOT NULL AND \"view_generation\" IS NULL))\n);\n\nCREATE TABLE \"cache_entries\" (\n  \"scope\" text COLLATE \"C\" NOT NULL,\n  \"key\" text COLLATE \"C\" NOT NULL,\n  \"value_json\" text COLLATE \"C\",\n  \"blob\" bytea,\n  \"expires_at\" bigint,\n  \"updated_at\" bigint NOT NULL,\n  PRIMARY KEY (\"scope\", \"key\")\n);\n\nCREATE TABLE \"context_engine_turn_outbox\" (\n  \"enqueue_sequence\" bigint GENERATED BY DEFAULT AS IDENTITY NOT NULL,\n  \"advancement_key\" text COLLATE \"C\" NOT NULL,\n  \"engine_id\" text COLLATE \"C\" NOT NULL,\n  \"owner_plugin_id\" text COLLATE \"C\",\n  \"session_id\" text COLLATE \"C\" NOT NULL,\n  \"payload_json\" text COLLATE \"C\" NOT NULL,\n  \"payload_state\" text COLLATE \"C\",\n  \"attempt_count\" bigint NOT NULL DEFAULT 0,\n  \"last_attempt_at\" bigint,\n  \"last_error\" text COLLATE \"C\",\n  \"created_at\" bigint NOT NULL,\n  PRIMARY KEY (\"enqueue_sequence\"),\n  UNIQUE (\"advancement_key\")\n);\n\nCREATE TABLE \"conversation_deliveries\" (\n  \"operation_id\" text COLLATE \"C\" NOT NULL,\n  \"operation_kind\" text COLLATE \"C\" NOT NULL,\n  \"conversation_id\" text COLLATE \"C\" NOT NULL,\n  \"source_session_key\" text COLLATE \"C\",\n  \"message_hash\" text COLLATE \"C\" NOT NULL,\n  \"status\" text COLLATE \"C\" NOT NULL,\n  \"prepared_message_id\" text COLLATE \"C\",\n  \"platform_message_id\" text COLLATE \"C\",\n  \"queue_id\" text COLLATE \"C\",\n  \"rejection_error\" text COLLATE \"C\",\n  \"reply_message_id\" text COLLATE \"C\",\n  \"reply_to_id\" text COLLATE \"C\",\n  \"reply_thread_id\" text COLLATE \"C\",\n  \"reply_text\" text COLLATE \"C\",\n  \"reply_timestamp\" bigint,\n  \"created_at\" bigint NOT NULL,\n  \"updated_at\" bigint NOT NULL,\n  PRIMARY KEY (\"operation_id\"),\n  CHECK ((\"operation_kind\" IN ('send', 'turn'))),\n  CHECK ((\"status\" IN ('created', 'queued', 'sent', 'suppressed', 'rejected', 'unknown', 'replied'))),\n  CHECK (((\"status\" = 'rejected') AND \"rejection_error\" IS NOT NULL) OR ((\"status\" != 'rejected') AND \"rejection_error\" IS NULL))\n);\n\nCREATE TABLE \"conversations\" (\n  \"conversation_id\" text COLLATE \"C\" NOT NULL,\n  \"channel\" text COLLATE \"C\" NOT NULL,\n  \"account_id\" text COLLATE \"C\" NOT NULL,\n  \"kind\" text COLLATE \"C\" NOT NULL,\n  \"peer_id\" text COLLATE \"C\" NOT NULL,\n  \"delivery_target\" text COLLATE \"C\" NOT NULL,\n  \"parent_conversation_id\" text COLLATE \"C\",\n  \"thread_id\" text COLLATE \"C\",\n  \"native_channel_id\" text COLLATE \"C\",\n  \"native_direct_user_id\" text COLLATE \"C\",\n  \"label\" text COLLATE \"C\",\n  \"metadata_json\" text COLLATE \"C\",\n  \"created_at\" bigint NOT NULL,\n  \"updated_at\" bigint NOT NULL,\n  PRIMARY KEY (\"conversation_id\"),\n  CHECK ((\"kind\" IN ('direct', 'group', 'channel')))\n);\n\nCREATE TABLE \"heartbeat_outcomes\" (\n  \"session_key\" text COLLATE \"C\" NOT NULL,\n  \"run_session_key\" text COLLATE \"C\" NOT NULL,\n  \"outcome\" text COLLATE \"C\" NOT NULL,\n  \"summary\" text COLLATE \"C\" NOT NULL,\n  \"response_reason\" text COLLATE \"C\",\n  \"priority\" text COLLATE \"C\",\n  \"next_check\" text COLLATE \"C\",\n  \"task_names_json\" text COLLATE \"C\",\n  \"wake_source\" text COLLATE \"C\",\n  \"wake_reason\" text COLLATE \"C\",\n  \"occurred_at\" bigint NOT NULL,\n  \"context_run_id\" text COLLATE \"C\",\n  \"context_claimed_at\" bigint,\n  \"updated_at\" bigint NOT NULL,\n  PRIMARY KEY (\"session_key\"),\n  CHECK ((\"outcome\" IN ('progress', 'done', 'blocked', 'needs_attention'))),\n  CHECK (\"priority\" IS NULL OR (\"priority\" IN ('low', 'normal', 'high')))\n);\n\nCREATE TABLE \"memory_embedding_cache\" (\n  \"provider\" text COLLATE \"C\" NOT NULL,\n  \"model\" text COLLATE \"C\" NOT NULL,\n  \"provider_key\" text COLLATE \"C\" NOT NULL,\n  \"hash\" text COLLATE \"C\" NOT NULL,\n  \"embedding\" bytea NOT NULL,\n  \"dims\" bigint,\n  \"updated_at\" bigint NOT NULL,\n  PRIMARY KEY (\"provider\", \"model\", \"provider_key\", \"hash\")\n);\n\nCREATE TABLE \"memory_entry_origins\" (\n  \"entry_key\" text COLLATE \"C\" NOT NULL,\n  \"agent_id\" text COLLATE \"C\" NOT NULL,\n  \"session_id\" text COLLATE \"C\" NOT NULL,\n  \"session_key\" text COLLATE \"C\",\n  \"origin_class\" text COLLATE \"C\" NOT NULL,\n  \"observed_at\" bigint NOT NULL,\n  PRIMARY KEY (\"entry_key\", \"agent_id\", \"session_id\"),\n  CHECK ((\"origin_class\" IN ('owner', 'agent', 'untrusted', 'system')))\n);\n\nCREATE TABLE \"memory_index_chunk_provenance\" (\n  \"chunk_id\" text COLLATE \"C\" NOT NULL,\n  \"origin_class\" text COLLATE \"C\" NOT NULL,\n  \"session_kind\" text COLLATE \"C\" NOT NULL,\n  \"observed_at\" bigint NOT NULL,\n  \"supersedes_key\" text COLLATE \"C\",\n  PRIMARY KEY (\"chunk_id\"),\n  CHECK ((\"origin_class\" IN ('owner', 'agent', 'untrusted', 'system'))),\n  CHECK ((\"session_kind\" IN ('interactive', 'cron', 'heartbeat', 'subagent', 'unknown')))\n);\n\nCREATE TABLE \"memory_index_chunk_recall_metadata\" (\n  \"chunk_id\" text COLLATE \"C\" NOT NULL,\n  \"importance\" bigint,\n  \"triggers\" text COLLATE \"C\",\n  \"project_key\" text COLLATE \"C\",\n  PRIMARY KEY (\"chunk_id\"),\n  CHECK (\"importance\" IS NULL OR (\"importance\" BETWEEN 1 AND 10))\n);\n\nCREATE TABLE \"memory_index_chunks\" (\n  \"chunk_rowid\" bigint GENERATED BY DEFAULT AS IDENTITY NOT NULL,\n  \"id\" text COLLATE \"C\" NOT NULL,\n  \"path\" text COLLATE \"C\" NOT NULL,\n  \"source\" text COLLATE \"C\" NOT NULL DEFAULT 'memory',\n  \"start_line\" bigint NOT NULL,\n  \"end_line\" bigint NOT NULL,\n  \"hash\" text COLLATE \"C\" NOT NULL,\n  \"model\" text COLLATE \"C\" NOT NULL,\n  \"text\" text COLLATE \"C\" NOT NULL,\n  \"embedding\" bytea NOT NULL,\n  \"updated_at\" bigint NOT NULL,\n  PRIMARY KEY (\"chunk_rowid\"),\n  UNIQUE (\"id\")\n);\n\nCREATE TABLE \"memory_index_meta\" (\n  \"key\" text COLLATE \"C\" NOT NULL,\n  \"value\" text COLLATE \"C\" NOT NULL,\n  PRIMARY KEY (\"key\")\n);\n\nCREATE TABLE \"memory_index_sources\" (\n  \"id\" bigint GENERATED BY DEFAULT AS IDENTITY NOT NULL,\n  \"path\" text COLLATE \"C\" NOT NULL,\n  \"source\" text COLLATE \"C\" NOT NULL DEFAULT 'memory',\n  \"hash\" text COLLATE \"C\" NOT NULL,\n  \"mtime\" double precision NOT NULL,\n  \"size\" bigint NOT NULL,\n  PRIMARY KEY (\"id\"),\n  UNIQUE (\"path\", \"source\")\n);\n\nCREATE TABLE \"memory_index_state\" (\n  \"id\" bigint GENERATED BY DEFAULT AS IDENTITY NOT NULL,\n  \"revision\" bigint NOT NULL,\n  PRIMARY KEY (\"id\"),\n  CHECK ((\"id\" = 1))\n);\n\nCREATE TABLE \"memory_session_tombstones\" (\n  \"session_id\" text COLLATE \"C\" NOT NULL,\n  \"agent_id\" text COLLATE \"C\" NOT NULL,\n  \"reason\" text COLLATE \"C\" NOT NULL,\n  \"created_at\" bigint NOT NULL,\n  PRIMARY KEY (\"session_id\")\n);\n\nCREATE TABLE \"message_tool_run_outcomes\" (\n  \"id\" bigint GENERATED BY DEFAULT AS IDENTITY NOT NULL,\n  \"run_id\" text COLLATE \"C\" NOT NULL,\n  \"session_key\" text COLLATE \"C\" NOT NULL,\n  \"agent_id\" text COLLATE \"C\" NOT NULL,\n  \"provider\" text COLLATE \"C\" NOT NULL,\n  \"model\" text COLLATE \"C\" NOT NULL,\n  \"outcome\" text COLLATE \"C\" NOT NULL,\n  \"run_status\" text COLLATE \"C\" NOT NULL,\n  \"occurred_at\" bigint NOT NULL,\n  PRIMARY KEY (\"id\"),\n  CHECK ((\"outcome\" IN ('tool_delivered', 'mute'))),\n  CHECK ((\"run_status\" IN ('completed', 'errored', 'aborted')))\n);\n\nCREATE TABLE \"schema_meta\" (\n  \"meta_key\" text COLLATE \"C\" NOT NULL,\n  \"role\" text COLLATE \"C\" NOT NULL,\n  \"schema_version\" bigint NOT NULL,\n  \"agent_id\" text COLLATE \"C\",\n  \"app_version\" text COLLATE \"C\",\n  \"created_at\" bigint NOT NULL,\n  \"updated_at\" bigint NOT NULL,\n  PRIMARY KEY (\"meta_key\")\n);\n\nCREATE TABLE \"session_canonical_validation_pending\" (\n  \"session_key\" text COLLATE \"C\" NOT NULL,\n  PRIMARY KEY (\"session_key\")\n);\n\nCREATE TABLE \"session_conversations\" (\n  \"session_id\" text COLLATE \"C\" NOT NULL,\n  \"conversation_id\" text COLLATE \"C\" NOT NULL,\n  \"role\" text COLLATE \"C\" NOT NULL DEFAULT 'primary',\n  \"route_context_json\" text COLLATE \"C\",\n  \"first_seen_at\" bigint NOT NULL,\n  \"last_seen_at\" bigint NOT NULL,\n  PRIMARY KEY (\"session_id\", \"conversation_id\", \"role\"),\n  CHECK ((\"role\" IN ('primary', 'participant', 'related')))\n);\n\nCREATE TABLE \"session_entry_snapshots\" (\n  \"session_key\" text COLLATE \"C\" NOT NULL,\n  \"field\" text COLLATE \"C\" NOT NULL,\n  \"value_json\" text COLLATE \"C\" NOT NULL,\n  PRIMARY KEY (\"session_key\", \"field\"),\n  CHECK ((\"field\" IN ('sessionDiffBaseline', 'skillsSnapshot', 'systemPromptReport')))\n);\n\nCREATE TABLE \"session_goal_operations\" (\n  \"session_key\" text COLLATE \"C\" NOT NULL,\n  \"operation_id\" text COLLATE \"C\" NOT NULL,\n  \"session_id\" text COLLATE \"C\" NOT NULL,\n  \"request_fingerprint\" text COLLATE \"C\" NOT NULL,\n  \"result_json\" text COLLATE \"C\" NOT NULL,\n  \"expires_at\" bigint NOT NULL,\n  PRIMARY KEY (\"session_key\", \"operation_id\")\n);\n\nCREATE TABLE \"session_input_completions\" (\n  \"session_key\" text COLLATE \"C\" NOT NULL,\n  \"session_id\" text COLLATE \"C\" NOT NULL,\n  \"idempotency_key\" text COLLATE \"C\" NOT NULL,\n  \"run_id\" text COLLATE \"C\" NOT NULL,\n  \"request_hash\" text COLLATE \"C\" NOT NULL,\n  \"outcome_json\" text COLLATE \"C\" NOT NULL,\n  \"succeeded\" bigint NOT NULL,\n  \"completed_at\" bigint NOT NULL,\n  PRIMARY KEY (\"session_id\", \"idempotency_key\"),\n  CHECK ((\"succeeded\" IN (0, 1)))\n);\n\nCREATE TABLE \"session_key_contract\" (\n  \"id\" bigint GENERATED BY DEFAULT AS IDENTITY NOT NULL,\n  \"main_key\" text COLLATE \"C\" NOT NULL,\n  \"canonical_ready\" text COLLATE \"C\",\n  \"updated_at\" bigint NOT NULL,\n  PRIMARY KEY (\"id\"),\n  CHECK ((\"id\" = 1))\n);\n\nCREATE TABLE \"session_members\" (\n  \"session_key\" text COLLATE \"C\" NOT NULL,\n  \"identity_id\" text COLLATE \"C\" NOT NULL,\n  \"added_by\" text COLLATE \"C\" NOT NULL,\n  \"added_at\" bigint NOT NULL,\n  PRIMARY KEY (\"session_key\", \"identity_id\")\n);\n\nCREATE TABLE \"session_nodes\" (\n  \"session_key\" text COLLATE \"C\" NOT NULL,\n  \"current_session_id\" text COLLATE \"C\" NOT NULL,\n  \"entry_json\" text COLLATE \"C\" NOT NULL,\n  \"session_started_at\" bigint,\n  \"has_optional_references\" bigint NOT NULL DEFAULT 0,\n  \"snapshot_revision\" bigint NOT NULL DEFAULT 0,\n  \"legacy_acp_migration_json\" text COLLATE \"C\",\n  \"entry_valid\" bigint NOT NULL DEFAULT 0,\n  \"updated_at\" bigint NOT NULL,\n  \"status\" text COLLATE \"C\",\n  \"created_at\" bigint,\n  \"created_via\" text COLLATE \"C\",\n  \"created_actor_type\" text COLLATE \"C\",\n  \"created_actor_id\" text COLLATE \"C\",\n  \"owner_actor_type\" text COLLATE \"C\",\n  \"owner_actor_id\" text COLLATE \"C\",\n  \"owner_assigned_by_type\" text COLLATE \"C\",\n  \"owner_assigned_by_id\" text COLLATE \"C\",\n  \"owner_assigned_at\" bigint,\n  \"project_id\" text COLLATE \"C\",\n  \"parent_session_key\" text COLLATE \"C\",\n  \"spawned_by\" text COLLATE \"C\",\n  \"fork_source_session_key\" text COLLATE \"C\",\n  \"fork_source_session_id\" text COLLATE \"C\",\n  \"fork_source_entry_id\" text COLLATE \"C\",\n  \"label\" text COLLATE \"C\",\n  \"display_name\" text COLLATE \"C\",\n  \"category\" text COLLATE \"C\",\n  \"icon\" text COLLATE \"C\",\n  \"pinned_at\" bigint,\n  \"archived_at\" bigint,\n  \"last_read_at\" bigint,\n  \"last_interaction_at\" bigint,\n  \"last_activity_at\" bigint,\n  PRIMARY KEY (\"session_key\"),\n  CHECK ((\"entry_valid\" IN (-1, 0, 1))),\n  CHECK (\"status\" IS NULL OR (\"status\" IN ('running', 'done', 'failed', 'killed', 'timeout'))),\n  CHECK (\"created_via\" IS NULL OR (\"created_via\" IN ('operator', 'spawn', 'channel', 'cron', 'talk', 'run', 'plugin', 'internal'))),\n  CHECK (\"created_actor_type\" IS NULL OR (\"created_actor_type\" IN ('human', 'agent', 'system')))\n);\n\nCREATE TABLE \"session_participants\" (\n  \"session_key\" text COLLATE \"C\" NOT NULL,\n  \"identity_namespace\" text COLLATE \"C\" NOT NULL,\n  \"actor_id\" text COLLATE \"C\" NOT NULL,\n  \"contribution_count\" bigint NOT NULL,\n  \"first_prompted_at\" bigint,\n  \"last_prompted_at\" bigint,\n  PRIMARY KEY (\"session_key\", \"identity_namespace\", \"actor_id\")\n);\n\nCREATE TABLE \"session_pending_inputs\" (\n  \"seq\" bigint GENERATED BY DEFAULT AS IDENTITY NOT NULL,\n  \"input_id\" text COLLATE \"C\" NOT NULL,\n  \"session_key\" text COLLATE \"C\" NOT NULL,\n  \"session_id\" text COLLATE \"C\" NOT NULL,\n  \"idempotency_key\" text COLLATE \"C\" NOT NULL,\n  \"run_id\" text COLLATE \"C\" NOT NULL,\n  \"request_hash\" text COLLATE \"C\" NOT NULL,\n  \"message_json\" text COLLATE \"C\" NOT NULL,\n  \"lifecycle_generation\" text COLLATE \"C\" NOT NULL,\n  \"state\" text COLLATE \"C\" NOT NULL,\n  \"accepted_at\" bigint NOT NULL,\n  \"consumed_event_id\" text COLLATE \"C\",\n  PRIMARY KEY (\"seq\"),\n  CHECK ((\"state\" IN ('queued', 'interrupted', 'cancelled'))),\n  UNIQUE (\"input_id\"),\n  UNIQUE (\"session_id\", \"idempotency_key\")\n);\n\nCREATE TABLE \"session_progress_cards\" (\n  \"session_key\" text COLLATE \"C\" NOT NULL,\n  \"markdown\" text COLLATE \"C\",\n  \"steps_json\" text COLLATE \"C\",\n  \"revision\" bigint NOT NULL,\n  \"created_at\" bigint NOT NULL,\n  \"updated_at\" bigint NOT NULL,\n  PRIMARY KEY (\"session_key\")\n);\n\nCREATE TABLE \"session_reactions\" (\n  \"session_key\" text COLLATE \"C\" NOT NULL,\n  \"session_id\" text COLLATE \"C\" NOT NULL,\n  \"message_id\" text COLLATE \"C\" NOT NULL,\n  \"emoji\" text COLLATE \"C\" NOT NULL,\n  \"identity_id\" text COLLATE \"C\" NOT NULL,\n  \"identity_label\" text COLLATE \"C\",\n  \"created_at\" bigint NOT NULL,\n  PRIMARY KEY (\"session_key\", \"session_id\", \"message_id\", \"emoji\", \"identity_id\")\n);\n\nCREATE TABLE \"session_suggestions\" (\n  \"id\" text COLLATE \"C\" NOT NULL,\n  \"session_key\" text COLLATE \"C\" NOT NULL,\n  \"author_id\" text COLLATE \"C\" NOT NULL,\n  \"author_label\" text COLLATE \"C\",\n  \"text\" text COLLATE \"C\" NOT NULL,\n  \"created_at\" bigint NOT NULL,\n  \"state\" text COLLATE \"C\" NOT NULL,\n  \"dispatch_token\" text COLLATE \"C\",\n  \"dispatch_started_at\" bigint,\n  \"dispatch_resolution\" text COLLATE \"C\",\n  PRIMARY KEY (\"id\"),\n  CHECK ((\"state\" IN ('pending', 'accepted', 'dismissed'))),\n  CHECK ((\"dispatch_resolution\" IN ('send', 'queue', 'edit', 'dismiss'))),\n  CHECK ((\"dispatch_token\" IS NULL AND \"dispatch_started_at\" IS NULL AND \"dispatch_resolution\" IS NULL) OR (\"dispatch_token\" IS NOT NULL AND \"dispatch_started_at\" IS NOT NULL AND \"dispatch_resolution\" IS NOT NULL))\n);\n\nCREATE TABLE \"session_transcript_active_events\" (\n  \"session_id\" text COLLATE \"C\" NOT NULL,\n  \"active_position\" bigint NOT NULL,\n  \"event_seq\" bigint NOT NULL,\n  \"message_position\" bigint,\n  \"context_eligible\" bigint,\n  PRIMARY KEY (\"session_id\", \"active_position\"),\n  CHECK ((\"active_position\" >= 0)),\n  CHECK (\"message_position\" IS NULL OR (\"message_position\" >= 0))\n);\n\nCREATE TABLE \"session_transcript_archives\" (\n  \"session_id\" text COLLATE \"C\" NOT NULL,\n  \"generation\" text COLLATE \"C\" NOT NULL,\n  \"session_key\" text COLLATE \"C\" NOT NULL,\n  \"reason\" text COLLATE \"C\" NOT NULL,\n  \"encoding\" text COLLATE \"C\" NOT NULL,\n  \"archive_blob\" bytea NOT NULL,\n  \"archive_sha256\" text COLLATE \"C\" NOT NULL,\n  \"archive_name\" text COLLATE \"C\" NOT NULL,\n  \"created_at\" bigint NOT NULL,\n  \"published_at\" bigint,\n  \"publish_attempts\" bigint NOT NULL DEFAULT 0,\n  \"last_publish_attempt_at\" bigint,\n  \"last_publish_error\" text COLLATE \"C\",\n  PRIMARY KEY (\"session_id\", \"generation\"),\n  CHECK ((\"reason\" IN ('deleted', 'reset'))),\n  CHECK ((\"encoding\" IN ('identity', 'zstd'))),\n  CHECK ((char_length(\"archive_sha256\") = 64)),\n  CHECK ((\"publish_attempts\" >= 0)),\n  CHECK ((strpos(\"archive_name\", '/') = 0) AND (strpos(\"archive_name\", '\\') = 0)),\n  UNIQUE (\"archive_name\")\n);\n\nCREATE TABLE \"session_transcript_cold_archive_chunks\" (\n  \"session_id\" text COLLATE \"C\" NOT NULL,\n  \"chunk_index\" bigint NOT NULL,\n  \"archive_name\" text COLLATE \"C\" NOT NULL,\n  \"archive_sha256\" text COLLATE \"C\" NOT NULL,\n  \"first_seq\" bigint NOT NULL,\n  \"last_seq\" bigint NOT NULL,\n  \"event_count\" bigint NOT NULL,\n  \"raw_bytes\" bigint NOT NULL,\n  \"archive_bytes\" bigint NOT NULL,\n  \"archive_blob\" bytea,\n  PRIMARY KEY (\"session_id\", \"chunk_index\"),\n  CHECK ((\"chunk_index\" >= 0)),\n  CHECK ((char_length(\"archive_sha256\") = 64)),\n  CHECK ((\"last_seq\" >= \"first_seq\")),\n  CHECK ((\"event_count\" >= 1)),\n  CHECK ((\"raw_bytes\" >= 0)),\n  CHECK ((\"archive_bytes\" >= 0)),\n  CHECK ((char_length(\"archive_name\") > 0) AND (\"archive_name\" NOT IN ('.', '..')) AND (strpos(\"archive_name\", '/') = 0) AND (strpos(\"archive_name\", '\\') = 0)),\n  UNIQUE (\"archive_name\")\n);\n\nCREATE TABLE \"session_transcript_cold_archives\" (\n  \"session_id\" text COLLATE \"C\" NOT NULL,\n  \"generation\" text COLLATE \"C\" NOT NULL,\n  \"archive_name\" text COLLATE \"C\" NOT NULL,\n  \"archive_sha256\" text COLLATE \"C\" NOT NULL,\n  \"event_count\" bigint NOT NULL,\n  \"raw_bytes\" bigint NOT NULL,\n  \"archive_bytes\" bigint NOT NULL,\n  \"last_seq\" bigint NOT NULL,\n  \"archived_at\" bigint NOT NULL,\n  \"storage\" text COLLATE \"C\" NOT NULL,\n  \"archive_blob\" bytea,\n  PRIMARY KEY (\"session_id\"),\n  CHECK ((char_length(\"archive_sha256\") = 64)),\n  CHECK ((\"event_count\" >= 1)),\n  CHECK ((\"raw_bytes\" >= 0)),\n  CHECK ((\"archive_bytes\" >= 0)),\n  CHECK ((\"storage\" IN ('file', 'sqlite'))),\n  CHECK ((char_length(\"archive_name\") > 0) AND (\"archive_name\" NOT IN ('.', '..')) AND (strpos(\"archive_name\", '/') = 0) AND (strpos(\"archive_name\", '\\') = 0)),\n  CHECK (((\"storage\" = 'file') AND \"archive_blob\" IS NULL) OR ((\"storage\" = 'sqlite') AND \"archive_blob\" IS NOT NULL)),\n  UNIQUE (\"archive_name\")\n);\n\nCREATE TABLE \"session_transcript_fts_rows\" (\n  \"id\" bigint GENERATED BY DEFAULT AS IDENTITY NOT NULL,\n  \"session_id\" text COLLATE \"C\" NOT NULL,\n  \"message_id\" text COLLATE \"C\",\n  PRIMARY KEY (\"id\")\n);\n\nCREATE TABLE \"session_transcript_index_state\" (\n  \"session_id\" text COLLATE \"C\" NOT NULL,\n  \"indexed_seq\" bigint NOT NULL,\n  \"leaf_event_id\" text COLLATE \"C\",\n  \"needs_rebuild\" bigint NOT NULL DEFAULT 0,\n  \"active_event_count\" bigint NOT NULL DEFAULT 0,\n  \"active_message_count\" bigint NOT NULL DEFAULT 0,\n  \"updated_at\" bigint NOT NULL,\n  PRIMARY KEY (\"session_id\")\n);\n\nCREATE TABLE \"session_windows\" (\n  \"session_id\" text COLLATE \"C\" NOT NULL,\n  \"session_key\" text COLLATE \"C\" NOT NULL,\n  \"previous_session_id\" text COLLATE \"C\",\n  \"reason\" text COLLATE \"C\",\n  \"session_scope\" text COLLATE \"C\" NOT NULL DEFAULT 'conversation',\n  \"created_at\" bigint NOT NULL,\n  \"updated_at\" bigint NOT NULL,\n  \"transcript_updated_at\" bigint DEFAULT NULL,\n  \"row_transcript_json\" text COLLATE \"C\",\n  \"row_transcript_updated_at\" bigint,\n  \"transcript_observed_at\" bigint DEFAULT NULL,\n  \"session_entry_provenance\" bigint NOT NULL DEFAULT 0,\n  \"acp_owned\" bigint NOT NULL DEFAULT 0,\n  \"plugin_owner_id\" text COLLATE \"C\",\n  \"hook_external_content_source\" text COLLATE \"C\",\n  \"started_at\" bigint,\n  \"ended_at\" bigint,\n  \"status\" text COLLATE \"C\",\n  \"chat_type\" text COLLATE \"C\",\n  \"channel\" text COLLATE \"C\",\n  \"account_id\" text COLLATE \"C\",\n  \"primary_conversation_id\" text COLLATE \"C\",\n  \"model_provider\" text COLLATE \"C\",\n  \"model\" text COLLATE \"C\",\n  \"agent_harness_id\" text COLLATE \"C\",\n  \"parent_session_key\" text COLLATE \"C\",\n  \"spawned_by\" text COLLATE \"C\",\n  \"display_name\" text COLLATE \"C\",\n  PRIMARY KEY (\"session_id\"),\n  CHECK (\"reason\" IS NULL OR (\"reason\" IN ('initial', 'reset', 'rollover', 'fork', 'rewind', 'switch', 'recovery', 'compaction'))),\n  CHECK ((\"session_scope\" IN ('conversation', 'shared-main', 'group', 'channel'))),\n  CHECK ((\"session_entry_provenance\" IN (0, 1))),\n  CHECK ((\"acp_owned\" IN (0, 1))),\n  CHECK (\"hook_external_content_source\" IS NULL OR (\"hook_external_content_source\" IN ('gmail', 'webhook'))),\n  CHECK (\"status\" IS NULL OR (\"status\" IN ('running', 'done', 'failed', 'killed', 'timeout'))),\n  CHECK (\"chat_type\" IS NULL OR (\"chat_type\" IN ('direct', 'group', 'channel')))\n);\n\nCREATE TABLE \"standing_intents\" (\n  \"intent_key\" bigint GENERATED BY DEFAULT AS IDENTITY NOT NULL,\n  \"id\" text COLLATE \"C\" NOT NULL,\n  \"description\" text COLLATE \"C\" NOT NULL,\n  \"trigger_keywords\" text COLLATE \"C\" NOT NULL,\n  \"trigger_embedding\" text COLLATE \"C\",\n  \"channel_scope\" text COLLATE \"C\",\n  \"sender_scope\" text COLLATE \"C\",\n  \"creator_sender\" text COLLATE \"C\",\n  \"status\" text COLLATE \"C\" NOT NULL,\n  \"expires_at\" bigint NOT NULL,\n  \"max_fires\" bigint NOT NULL,\n  \"fire_count\" bigint NOT NULL DEFAULT 0,\n  \"cooldown_seconds\" bigint NOT NULL DEFAULT 86400,\n  \"last_fired_at\" bigint,\n  \"created_at\" bigint NOT NULL,\n  \"source_session_id\" text COLLATE \"C\",\n  PRIMARY KEY (\"intent_key\"),\n  CHECK (\"creator_sender\" IS NULL OR (char_length(btrim(\"creator_sender\")) > 0)),\n  CHECK ((\"status\" IN ('pending', 'armed', 'fired', 'done', 'cancelled', 'expired'))),\n  CHECK ((\"max_fires\" > 0)),\n  CHECK ((\"fire_count\" >= 0)),\n  CHECK ((\"cooldown_seconds\" >= 0)),\n  UNIQUE (\"id\")\n);\n\nCREATE TABLE \"trajectory_runtime_events\" (\n  \"session_id\" text COLLATE \"C\" NOT NULL,\n  \"seq\" bigint NOT NULL,\n  \"run_id\" text COLLATE \"C\",\n  \"event_json\" text COLLATE \"C\" NOT NULL,\n  \"created_at\" bigint NOT NULL,\n  \"event_utf8_bytes\" bigint,\n  \"event_payload\" bytea,\n  \"event_codec\" text COLLATE \"C\",\n  PRIMARY KEY (\"session_id\", \"seq\")\n);\n\nCREATE TABLE \"transcript_event_identities\" (\n  \"session_id\" text COLLATE \"C\" NOT NULL,\n  \"event_id\" text COLLATE \"C\" NOT NULL,\n  \"seq\" bigint NOT NULL,\n  \"event_type\" text COLLATE \"C\",\n  \"parent_id\" text COLLATE \"C\",\n  \"message_idempotency_key\" text COLLATE \"C\",\n  \"created_at\" bigint NOT NULL,\n  PRIMARY KEY (\"session_id\", \"event_id\")\n);\n\nCREATE TABLE \"transcript_events\" (\n  \"session_id\" text COLLATE \"C\" NOT NULL,\n  \"seq\" bigint NOT NULL,\n  \"event_json\" text COLLATE \"C\",\n  \"created_at\" bigint NOT NULL,\n  \"event_zstd\" bytea,\n  \"event_utf8_bytes\" bigint,\n  \"navigation_json\" text COLLATE \"C\",\n  \"navigation_type\" text COLLATE \"C\",\n  \"navigation_custom_type\" text COLLATE \"C\",\n  \"navigation_display\" bigint NOT NULL DEFAULT 0,\n  \"message_role\" text COLLATE \"C\",\n  \"navigation_last_type\" text COLLATE \"C\",\n  \"navigation_last_custom_type\" text COLLATE \"C\",\n  \"navigation_valid\" bigint NOT NULL DEFAULT 1,\n  PRIMARY KEY (\"session_id\", \"seq\"),\n  CHECK (\"event_utf8_bytes\" IS NULL OR (\"event_utf8_bytes\" >= 0)),\n  CHECK ((\"event_json\" IS NOT NULL AND \"event_zstd\" IS NULL) OR (\"event_json\" IS NULL AND \"event_zstd\" IS NOT NULL AND \"event_utf8_bytes\" IS NOT NULL AND (\"event_utf8_bytes\" BETWEEN 1 AND 4194304) AND (octet_length(\"event_zstd\") BETWEEN 1 AND 4194304) AND \"navigation_json\" IS NOT NULL)),\n  CHECK (\"openclaw_transcript_navigation_check\"(\"navigation_json\"))\n);\n\nCREATE TABLE \"transcript_rewrite_watermarks\" (\n  \"session_id\" text COLLATE \"C\" NOT NULL,\n  \"generation\" text COLLATE \"C\" NOT NULL,\n  \"updated_at\" bigint NOT NULL,\n  PRIMARY KEY (\"session_id\")\n);\n\nCREATE INDEX \"idx_agent_acp_parent_stream_run\" ON \"acp_parent_stream_events\" ((\"run_id\") ASC, (\"seq\") ASC);\n\nCREATE INDEX \"idx_agent_board_widgets_tab_position\" ON \"board_widgets\" ((\"session_key\") ASC, (\"tab_id\") ASC, (\"position\") ASC);\n\nCREATE INDEX \"idx_agent_cache_expiry\" ON \"cache_entries\" ((\"scope\") ASC, (\"expires_at\") ASC, (\"key\") ASC) WHERE \"expires_at\" IS NOT NULL;\n\nCREATE INDEX \"idx_agent_cache_updated\" ON \"cache_entries\" ((\"scope\") ASC, (\"updated_at\") DESC, (\"key\") ASC);\n\nCREATE INDEX \"idx_agent_voice_session_open_scope\" ON \"cache_entries\" ((CASE WHEN (\"value_json\" IS JSON) THEN CASE WHEN json_typeof((\"value_json\"::json -> 'agentId')) = 'string' THEN ((\"value_json\"::json -> 'agentId') #>> '{}') END ELSE NULL END) ASC NULLS FIRST, (CASE WHEN (\"value_json\" IS JSON) THEN CASE WHEN json_typeof((\"value_json\"::json -> 'sessionKey')) = 'string' THEN ((\"value_json\"::json -> 'sessionKey') #>> '{}') END ELSE NULL END) ASC NULLS FIRST, (CASE WHEN (\"value_json\" IS JSON) THEN CASE WHEN json_typeof((\"value_json\"::json -> 'origin')) = 'string' THEN ((\"value_json\"::json -> 'origin') #>> '{}') END ELSE NULL END) ASC NULLS FIRST) WHERE (\"scope\" = 'talk-client-voice-sessions') AND (CASE WHEN (\"value_json\" IS JSON) THEN CASE WHEN json_typeof((\"value_json\"::json -> 'status')) = 'string' THEN ((\"value_json\"::json -> 'status') #>> '{}') END ELSE NULL END = 'open');\n\nCREATE INDEX \"idx_agent_voice_session_open_updated\" ON \"cache_entries\" ((\"scope\") ASC, (\"updated_at\") ASC) WHERE (\"scope\" = 'talk-client-voice-sessions') AND (CASE WHEN (\"value_json\" IS JSON) THEN CASE WHEN json_typeof((\"value_json\"::json -> 'status')) = 'string' THEN ((\"value_json\"::json -> 'status') #>> '{}') END ELSE NULL END = 'open');\n\nCREATE INDEX \"idx_agent_context_engine_turn_outbox_engine\" ON \"context_engine_turn_outbox\" ((\"engine_id\") ASC, (\"created_at\") ASC);\n\nCREATE INDEX \"idx_agent_conversation_deliveries_reply\" ON \"conversation_deliveries\" ((\"conversation_id\") ASC, (\"platform_message_id\") ASC NULLS FIRST, (\"prepared_message_id\") ASC NULLS FIRST) WHERE (\"status\" IN ('queued', 'sent', 'replied'));\n\nCREATE INDEX \"idx_agent_conversation_deliveries_updated\" ON \"conversation_deliveries\" ((\"updated_at\") DESC, (\"operation_id\") ASC);\n\nCREATE UNIQUE INDEX \"idx_agent_conversations_identity\" ON \"conversations\" ((\"channel\") ASC, (\"account_id\") ASC, (\"kind\") ASC, (\"peer_id\") ASC, (coalesce(\"parent_conversation_id\", '')) ASC NULLS FIRST, (coalesce(\"thread_id\", '')) ASC NULLS FIRST);\n\nCREATE INDEX \"idx_agent_conversations_lookup\" ON \"conversations\" ((\"channel\") ASC, (\"account_id\") ASC, (\"kind\") ASC, (\"peer_id\") ASC, (\"thread_id\") ASC NULLS FIRST);\n\nCREATE INDEX \"idx_agent_conversations_updated\" ON \"conversations\" ((\"updated_at\") DESC, (\"conversation_id\") ASC);\n\nCREATE INDEX \"idx_memory_embedding_cache_updated_at\" ON \"memory_embedding_cache\" ((\"updated_at\") ASC);\n\nCREATE INDEX \"idx_memory_index_chunks_path_source\" ON \"memory_index_chunks\" ((\"path\") ASC, (\"source\") ASC);\n\nCREATE INDEX \"idx_memory_index_chunks_source\" ON \"memory_index_chunks\" ((\"source\") ASC);\n\nCREATE INDEX \"idx_memory_index_sources_source\" ON \"memory_index_sources\" ((\"source\") ASC);\n\nCREATE INDEX \"idx_agent_message_tool_run_outcomes_occurred\" ON \"message_tool_run_outcomes\" ((\"occurred_at\") DESC, (\"id\") DESC);\n\nCREATE INDEX \"idx_agent_session_conversations_conversation\" ON \"session_conversations\" ((\"conversation_id\") ASC, (\"last_seen_at\") DESC, (\"session_id\") ASC);\n\nCREATE UNIQUE INDEX \"idx_agent_session_conversations_primary\" ON \"session_conversations\" ((\"session_id\") ASC) WHERE (\"role\" = 'primary');\n\nCREATE INDEX \"idx_agent_session_goal_operations_expiry\" ON \"session_goal_operations\" ((\"expires_at\") ASC);\n\nCREATE INDEX \"idx_agent_session_members_identity\" ON \"session_members\" ((\"identity_id\") ASC, (\"session_key\") ASC);\n\nCREATE INDEX \"idx_agent_session_nodes_active\" ON \"session_nodes\" ((\"session_key\") ASC) WHERE \"archived_at\" IS NULL;\n\nCREATE INDEX \"idx_agent_session_nodes_archived_at\" ON \"session_nodes\" ((\"archived_at\") ASC, (\"session_key\") ASC) WHERE \"archived_at\" IS NOT NULL;\n\nCREATE INDEX \"idx_agent_session_nodes_current_session_id\" ON \"session_nodes\" ((\"current_session_id\") ASC);\n\nCREATE INDEX \"idx_agent_session_nodes_entry_not_valid\" ON \"session_nodes\" ((\"session_key\") ASC) WHERE (\"entry_valid\" != 1);\n\nCREATE INDEX \"idx_agent_session_nodes_entry_valid_pending\" ON \"session_nodes\" ((\"session_key\") ASC) WHERE (\"entry_valid\" = 0);\n\nCREATE INDEX \"idx_agent_session_nodes_label\" ON \"session_nodes\" ((\"label\") ASC, (\"session_key\") ASC) WHERE \"label\" IS NOT NULL;\n\nCREATE INDEX \"idx_agent_session_nodes_parent_session_key\" ON \"session_nodes\" ((\"parent_session_key\") ASC NULLS FIRST, (\"session_key\") ASC);\n\nCREATE INDEX \"idx_agent_session_nodes_spawned_by\" ON \"session_nodes\" ((\"spawned_by\") ASC NULLS FIRST, (\"session_key\") ASC);\n\nCREATE INDEX \"idx_agent_session_nodes_status\" ON \"session_nodes\" ((\"status\") ASC, (\"session_key\") ASC) WHERE \"status\" IS NOT NULL;\n\nCREATE INDEX \"idx_agent_session_nodes_updated_at\" ON \"session_nodes\" ((\"updated_at\") DESC, (\"session_key\") ASC);\n\nCREATE INDEX \"idx_agent_session_pending_inputs_session\" ON \"session_pending_inputs\" ((\"session_key\") ASC, (\"session_id\") ASC, (\"seq\") DESC);\n\nCREATE INDEX \"idx_agent_session_suggestions_author_created\" ON \"session_suggestions\" ((\"author_id\") ASC, (\"created_at\") ASC, (\"id\") ASC);\n\nCREATE INDEX \"idx_agent_session_suggestions_session_state_created\" ON \"session_suggestions\" ((\"session_key\") ASC, (\"state\") ASC, (\"created_at\") ASC, (\"id\") ASC);\n\nCREATE UNIQUE INDEX \"idx_agent_transcript_active_event_seq\" ON \"session_transcript_active_events\" ((\"session_id\") ASC, (\"event_seq\") ASC);\n\nCREATE UNIQUE INDEX \"idx_agent_transcript_active_messages\" ON \"session_transcript_active_events\" ((\"session_id\") ASC, (\"message_position\") ASC) WHERE \"message_position\" IS NOT NULL;\n\nCREATE INDEX \"idx_agent_transcript_context_pending\" ON \"session_transcript_active_events\" ((\"session_id\") ASC) WHERE \"context_eligible\" IS NULL;\n\nCREATE INDEX \"idx_agent_session_transcript_archives_pending\" ON \"session_transcript_archives\" ((\"created_at\") ASC, (\"session_id\") ASC, (\"generation\") ASC) WHERE \"published_at\" IS NULL;\n\nCREATE INDEX \"idx_agent_session_transcript_archives_retention\" ON \"session_transcript_archives\" ((\"created_at\") ASC, (\"session_id\") ASC, (\"generation\") ASC);\n\nCREATE INDEX \"idx_session_transcript_fts_rows_session_message\" ON \"session_transcript_fts_rows\" ((\"session_id\") ASC, (\"message_id\") ASC NULLS FIRST);\n\nCREATE INDEX \"idx_agent_session_windows_conversation\" ON \"session_windows\" ((\"primary_conversation_id\") ASC) WHERE \"primary_conversation_id\" IS NOT NULL;\n\nCREATE INDEX \"idx_agent_session_windows_created_at\" ON \"session_windows\" ((\"created_at\") DESC, (\"session_id\") ASC);\n\nCREATE INDEX \"idx_agent_session_windows_session_key\" ON \"session_windows\" ((\"session_key\") ASC, (\"updated_at\") DESC, (\"session_id\") ASC);\n\nCREATE INDEX \"idx_agent_session_windows_updated_at\" ON \"session_windows\" ((\"updated_at\") DESC, (\"session_id\") ASC);\n\nCREATE INDEX \"idx_standing_intents_lifecycle\" ON \"standing_intents\" ((\"status\") ASC, (\"expires_at\") ASC, (\"last_fired_at\") ASC NULLS FIRST);\n\nCREATE INDEX \"idx_standing_intents_scope\" ON \"standing_intents\" ((\"status\") ASC, (\"channel_scope\") ASC NULLS FIRST, (\"sender_scope\") ASC NULLS FIRST);\n\nCREATE INDEX \"idx_agent_trajectory_runtime_run\" ON \"trajectory_runtime_events\" ((\"session_id\") ASC, (\"run_id\") ASC NULLS FIRST, (\"created_at\") ASC, (coalesce(\"event_utf8_bytes\", octet_length(\"event_json\"))) ASC NULLS FIRST);\n\nCREATE INDEX \"idx_agent_transcript_event_identity_sequence\" ON \"transcript_event_identities\" ((\"session_id\") ASC, (\"seq\") ASC);\n\nCREATE INDEX \"idx_agent_transcript_event_sequence\" ON \"transcript_event_identities\" ((\"session_id\") ASC, (\"event_type\") ASC NULLS FIRST, (\"seq\") DESC);\n\nCREATE UNIQUE INDEX \"idx_agent_transcript_message_idempotency\" ON \"transcript_event_identities\" ((\"session_id\") ASC, (\"message_idempotency_key\") ASC) WHERE \"message_idempotency_key\" IS NOT NULL;\n\nCREATE INDEX \"idx_memory_index_sources_exact_path\" ON \"memory_index_sources\" ((pg_catalog.md5(pg_catalog.lower(pg_catalog.normalize(pg_catalog.regexp_replace(pg_catalog.replace(pg_catalog.btrim(path), E'\\\\', '/'), '^\\./', ''), 'NFC')))));\n\nCREATE INDEX \"idx_memory_index_sources_basename\" ON \"memory_index_sources\" ((pg_catalog.md5(pg_catalog.regexp_replace(pg_catalog.lower(pg_catalog.normalize(pg_catalog.regexp_replace(pg_catalog.replace(pg_catalog.btrim(path), E'\\\\', '/'), '^\\./', ''), 'NFC')), '^.*/', ''))));\n\nCREATE INDEX \"idx_memory_index_sources_stem\" ON \"memory_index_sources\" ((pg_catalog.md5(pg_catalog.regexp_replace(pg_catalog.regexp_replace(pg_catalog.lower(pg_catalog.normalize(pg_catalog.regexp_replace(pg_catalog.replace(pg_catalog.btrim(path), E'\\\\', '/'), '^\\./', ''), 'NFC')), '^.*/', ''), '^(.+)\\.[^.]*$', '\\1'))));\n\nALTER TABLE \"acp_parent_stream_events\" ADD FOREIGN KEY (\"session_id\") REFERENCES \"session_windows\" (\"session_id\") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;\n\nALTER TABLE \"board_tabs\" ADD FOREIGN KEY (\"session_key\") REFERENCES \"session_nodes\" (\"session_key\") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;\n\nALTER TABLE \"board_widgets\" ADD FOREIGN KEY (\"session_key\", \"tab_id\") REFERENCES \"board_tabs\" (\"session_key\", \"tab_id\") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;\n\nALTER TABLE \"conversation_deliveries\" ADD FOREIGN KEY (\"conversation_id\") REFERENCES \"conversations\" (\"conversation_id\") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;\n\nALTER TABLE \"heartbeat_outcomes\" ADD FOREIGN KEY (\"session_key\") REFERENCES \"session_nodes\" (\"session_key\") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;\n\nALTER TABLE \"memory_index_chunk_provenance\" ADD FOREIGN KEY (\"chunk_id\") REFERENCES \"memory_index_chunks\" (\"id\") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;\n\nALTER TABLE \"memory_index_chunk_recall_metadata\" ADD FOREIGN KEY (\"chunk_id\") REFERENCES \"memory_index_chunks\" (\"id\") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;\n\nALTER TABLE \"session_conversations\" ADD FOREIGN KEY (\"conversation_id\") REFERENCES \"conversations\" (\"conversation_id\") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;\n\nALTER TABLE \"session_conversations\" ADD FOREIGN KEY (\"session_id\") REFERENCES \"session_windows\" (\"session_id\") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;\n\nALTER TABLE \"session_entry_snapshots\" ADD FOREIGN KEY (\"session_key\") REFERENCES \"session_nodes\" (\"session_key\") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;\n\nALTER TABLE \"session_input_completions\" ADD FOREIGN KEY (\"session_id\") REFERENCES \"session_windows\" (\"session_id\") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;\n\nALTER TABLE \"session_input_completions\" ADD FOREIGN KEY (\"session_key\") REFERENCES \"session_nodes\" (\"session_key\") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;\n\nALTER TABLE \"session_members\" ADD FOREIGN KEY (\"session_key\") REFERENCES \"session_nodes\" (\"session_key\") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;\n\nALTER TABLE \"session_participants\" ADD FOREIGN KEY (\"session_key\") REFERENCES \"session_nodes\" (\"session_key\") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;\n\nALTER TABLE \"session_pending_inputs\" ADD FOREIGN KEY (\"session_id\") REFERENCES \"session_windows\" (\"session_id\") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;\n\nALTER TABLE \"session_pending_inputs\" ADD FOREIGN KEY (\"session_key\") REFERENCES \"session_nodes\" (\"session_key\") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;\n\nALTER TABLE \"session_progress_cards\" ADD FOREIGN KEY (\"session_key\") REFERENCES \"session_nodes\" (\"session_key\") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;\n\nALTER TABLE \"session_reactions\" ADD FOREIGN KEY (\"session_key\") REFERENCES \"session_nodes\" (\"session_key\") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;\n\nALTER TABLE \"session_suggestions\" ADD FOREIGN KEY (\"session_key\") REFERENCES \"session_nodes\" (\"session_key\") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;\n\nALTER TABLE \"session_transcript_active_events\" ADD FOREIGN KEY (\"session_id\", \"event_seq\") REFERENCES \"transcript_events\" (\"session_id\", \"seq\") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;\n\nALTER TABLE \"session_transcript_cold_archive_chunks\" ADD FOREIGN KEY (\"session_id\") REFERENCES \"session_transcript_cold_archives\" (\"session_id\") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;\n\nALTER TABLE \"session_transcript_cold_archives\" ADD FOREIGN KEY (\"session_id\") REFERENCES \"session_windows\" (\"session_id\") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;\n\nALTER TABLE \"session_transcript_index_state\" ADD FOREIGN KEY (\"session_id\") REFERENCES \"session_windows\" (\"session_id\") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;\n\nALTER TABLE \"session_windows\" ADD FOREIGN KEY (\"primary_conversation_id\") REFERENCES \"conversations\" (\"conversation_id\") ON UPDATE NO ACTION ON DELETE SET NULL NOT DEFERRABLE;\n\nALTER TABLE \"session_windows\" ADD FOREIGN KEY (\"session_key\") REFERENCES \"session_nodes\" (\"session_key\") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;\n\nALTER TABLE \"trajectory_runtime_events\" ADD FOREIGN KEY (\"session_id\") REFERENCES \"session_windows\" (\"session_id\") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;\n\nALTER TABLE \"transcript_event_identities\" ADD FOREIGN KEY (\"session_id\", \"seq\") REFERENCES \"transcript_events\" (\"session_id\", \"seq\") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;\n\nALTER TABLE \"transcript_events\" ADD FOREIGN KEY (\"session_id\") REFERENCES \"session_windows\" (\"session_id\") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;\n\nALTER TABLE \"transcript_rewrite_watermarks\" ADD FOREIGN KEY (\"session_id\") REFERENCES \"session_windows\" (\"session_id\") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;\n\nCREATE FUNCTION \"openclaw_session_conversations_trigger\"() RETURNS trigger LANGUAGE plpgsql SET search_path FROM CURRENT AS $trigger$\nBEGIN\n  UPDATE session_conversations SET route_context_json = NULL WHERE session_id = NEW.session_id AND conversation_id = NEW.conversation_id AND role = NEW.role;\n  RETURN NULL;\nEND;\n$trigger$;\n\nCREATE FUNCTION \"openclaw_session_entry_snapshots_trigger\"() RETURNS trigger LANGUAGE plpgsql SET search_path FROM CURRENT AS $trigger$\nBEGIN\n  IF TG_OP = 'DELETE' THEN\n    UPDATE session_nodes SET snapshot_revision = snapshot_revision + 1 WHERE session_key = OLD.session_key;\n  ELSIF TG_OP = 'INSERT' THEN\n    UPDATE session_nodes SET snapshot_revision = snapshot_revision + 1 WHERE session_key = NEW.session_key;\n  ELSIF TG_OP = 'UPDATE' THEN\n    UPDATE session_nodes SET snapshot_revision = snapshot_revision + 1 WHERE session_key IN (OLD.session_key, NEW.session_key);\n  END IF;\n  RETURN NULL;\nEND;\n$trigger$;\n\nCREATE TRIGGER \"session_conversations_route_context_invalidate_after_update\" AFTER UPDATE OF \"role\", \"last_seen_at\" ON \"session_conversations\" FOR EACH ROW WHEN (NEW.route_context_json IS NOT DISTINCT FROM OLD.route_context_json) EXECUTE FUNCTION \"openclaw_session_conversations_trigger\"();\n\nCREATE TRIGGER \"session_entry_snapshots_after_delete\" AFTER DELETE ON \"session_entry_snapshots\" FOR EACH ROW EXECUTE FUNCTION \"openclaw_session_entry_snapshots_trigger\"();\n\nCREATE TRIGGER \"session_entry_snapshots_after_insert\" AFTER INSERT ON \"session_entry_snapshots\" FOR EACH ROW EXECUTE FUNCTION \"openclaw_session_entry_snapshots_trigger\"();\n\nCREATE TRIGGER \"session_entry_snapshots_after_update\" AFTER UPDATE OF \"session_key\", \"field\", \"value_json\" ON \"session_entry_snapshots\" FOR EACH ROW WHEN (NEW.session_key IS DISTINCT FROM OLD.session_key OR NEW.field IS DISTINCT FROM OLD.field OR NEW.value_json IS DISTINCT FROM OLD.value_json) EXECUTE FUNCTION \"openclaw_session_entry_snapshots_trigger\"();\n",
	expectedCatalog: [
		{
			table: "acp_parent_stream_events",
			kind: "table",
			value: null
		},
		{
			table: "acp_parent_stream_events",
			kind: "column",
			value: {
				name: "session_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 1
			}
		},
		{
			table: "acp_parent_stream_events",
			kind: "column",
			value: {
				name: "run_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "acp_parent_stream_events",
			kind: "column",
			value: {
				name: "seq",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 3
			}
		},
		{
			table: "acp_parent_stream_events",
			kind: "column",
			value: {
				name: "event_json",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 4
			}
		},
		{
			table: "acp_parent_stream_events",
			kind: "column",
			value: {
				name: "created_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 5
			}
		},
		{
			table: "acp_parent_stream_events",
			kind: "primaryKey",
			value: [
				"session_id",
				"run_id",
				"seq"
			]
		},
		{
			table: "acp_parent_stream_events",
			kind: "foreignKey",
			value: {
				columns: ["session_id"],
				target: "session_windows",
				targetColumns: ["session_id"],
				onUpdate: "NO ACTION",
				onDelete: "CASCADE",
				deferrable: false,
				deferred: false
			}
		},
		{
			table: "acp_parent_stream_events",
			kind: "indexes",
			value: 2
		},
		{
			table: "acp_parent_stream_events",
			kind: "checks",
			value: 0
		},
		{
			table: "auth_profile_state",
			kind: "table",
			value: null
		},
		{
			table: "auth_profile_state",
			kind: "column",
			value: {
				name: "state_key",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 1
			}
		},
		{
			table: "auth_profile_state",
			kind: "column",
			value: {
				name: "state_json",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "auth_profile_state",
			kind: "column",
			value: {
				name: "updated_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 3
			}
		},
		{
			table: "auth_profile_state",
			kind: "primaryKey",
			value: ["state_key"]
		},
		{
			table: "auth_profile_state",
			kind: "indexes",
			value: 1
		},
		{
			table: "auth_profile_state",
			kind: "checks",
			value: 0
		},
		{
			table: "auth_profile_store",
			kind: "table",
			value: null
		},
		{
			table: "auth_profile_store",
			kind: "column",
			value: {
				name: "store_key",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 1
			}
		},
		{
			table: "auth_profile_store",
			kind: "column",
			value: {
				name: "store_json",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "auth_profile_store",
			kind: "column",
			value: {
				name: "updated_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 3
			}
		},
		{
			table: "auth_profile_store",
			kind: "primaryKey",
			value: ["store_key"]
		},
		{
			table: "auth_profile_store",
			kind: "indexes",
			value: 1
		},
		{
			table: "auth_profile_store",
			kind: "checks",
			value: 0
		},
		{
			table: "board_tabs",
			kind: "table",
			value: null
		},
		{
			table: "board_tabs",
			kind: "column",
			value: {
				name: "session_key",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 1
			}
		},
		{
			table: "board_tabs",
			kind: "column",
			value: {
				name: "tab_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "board_tabs",
			kind: "column",
			value: {
				name: "title",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 3
			}
		},
		{
			table: "board_tabs",
			kind: "column",
			value: {
				name: "position",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 4
			}
		},
		{
			table: "board_tabs",
			kind: "column",
			value: {
				name: "chat_dock",
				type: "text",
				nullable: false,
				identity: false,
				default: "'right'",
				position: 5
			}
		},
		{
			table: "board_tabs",
			kind: "column",
			value: {
				name: "created_by",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 6
			}
		},
		{
			table: "board_tabs",
			kind: "column",
			value: {
				name: "revision",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 7
			}
		},
		{
			table: "board_tabs",
			kind: "primaryKey",
			value: ["session_key", "tab_id"]
		},
		{
			table: "board_tabs",
			kind: "foreignKey",
			value: {
				columns: ["session_key"],
				target: "session_nodes",
				targetColumns: ["session_key"],
				onUpdate: "NO ACTION",
				onDelete: "CASCADE",
				deferrable: false,
				deferred: false
			}
		},
		{
			table: "board_tabs",
			kind: "indexes",
			value: 1
		},
		{
			table: "board_tabs",
			kind: "checks",
			value: 4
		},
		{
			table: "board_widgets",
			kind: "table",
			value: null
		},
		{
			table: "board_widgets",
			kind: "column",
			value: {
				name: "session_key",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 1
			}
		},
		{
			table: "board_widgets",
			kind: "column",
			value: {
				name: "name",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "board_widgets",
			kind: "column",
			value: {
				name: "tab_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 3
			}
		},
		{
			table: "board_widgets",
			kind: "column",
			value: {
				name: "title",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 4
			}
		},
		{
			table: "board_widgets",
			kind: "column",
			value: {
				name: "content_kind",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 5
			}
		},
		{
			table: "board_widgets",
			kind: "column",
			value: {
				name: "html",
				type: "bytea",
				nullable: true,
				identity: false,
				default: null,
				position: 6
			}
		},
		{
			table: "board_widgets",
			kind: "column",
			value: {
				name: "descriptor_json",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 7
			}
		},
		{
			table: "board_widgets",
			kind: "column",
			value: {
				name: "sha256",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 8
			}
		},
		{
			table: "board_widgets",
			kind: "column",
			value: {
				name: "view_generation",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 9
			}
		},
		{
			table: "board_widgets",
			kind: "column",
			value: {
				name: "revision",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 10
			}
		},
		{
			table: "board_widgets",
			kind: "column",
			value: {
				name: "size_w",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 11
			}
		},
		{
			table: "board_widgets",
			kind: "column",
			value: {
				name: "size_h",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 12
			}
		},
		{
			table: "board_widgets",
			kind: "column",
			value: {
				name: "position",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 13
			}
		},
		{
			table: "board_widgets",
			kind: "column",
			value: {
				name: "manifest",
				type: "text",
				nullable: false,
				identity: false,
				default: "'{}'",
				position: 14
			}
		},
		{
			table: "board_widgets",
			kind: "column",
			value: {
				name: "grant_state",
				type: "text",
				nullable: false,
				identity: false,
				default: "'none'",
				position: 15
			}
		},
		{
			table: "board_widgets",
			kind: "column",
			value: {
				name: "granted_sha",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 16
			}
		},
		{
			table: "board_widgets",
			kind: "column",
			value: {
				name: "created_by",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 17
			}
		},
		{
			table: "board_widgets",
			kind: "column",
			value: {
				name: "created_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 18
			}
		},
		{
			table: "board_widgets",
			kind: "column",
			value: {
				name: "updated_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 19
			}
		},
		{
			table: "board_widgets",
			kind: "primaryKey",
			value: ["session_key", "name"]
		},
		{
			table: "board_widgets",
			kind: "foreignKey",
			value: {
				columns: ["session_key", "tab_id"],
				target: "board_tabs",
				targetColumns: ["session_key", "tab_id"],
				onUpdate: "NO ACTION",
				onDelete: "CASCADE",
				deferrable: false,
				deferred: false
			}
		},
		{
			table: "board_widgets",
			kind: "indexes",
			value: 2
		},
		{
			table: "board_widgets",
			kind: "checks",
			value: 8
		},
		{
			table: "cache_entries",
			kind: "table",
			value: null
		},
		{
			table: "cache_entries",
			kind: "column",
			value: {
				name: "scope",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 1
			}
		},
		{
			table: "cache_entries",
			kind: "column",
			value: {
				name: "key",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "cache_entries",
			kind: "column",
			value: {
				name: "value_json",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 3
			}
		},
		{
			table: "cache_entries",
			kind: "column",
			value: {
				name: "blob",
				type: "bytea",
				nullable: true,
				identity: false,
				default: null,
				position: 4
			}
		},
		{
			table: "cache_entries",
			kind: "column",
			value: {
				name: "expires_at",
				type: "bigint",
				nullable: true,
				identity: false,
				default: null,
				position: 5
			}
		},
		{
			table: "cache_entries",
			kind: "column",
			value: {
				name: "updated_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 6
			}
		},
		{
			table: "cache_entries",
			kind: "primaryKey",
			value: ["scope", "key"]
		},
		{
			table: "cache_entries",
			kind: "indexes",
			value: 5
		},
		{
			table: "cache_entries",
			kind: "checks",
			value: 0
		},
		{
			table: "context_engine_turn_outbox",
			kind: "table",
			value: null
		},
		{
			table: "context_engine_turn_outbox",
			kind: "column",
			value: {
				name: "enqueue_sequence",
				type: "bigint",
				nullable: false,
				identity: true,
				default: null,
				position: 1
			}
		},
		{
			table: "context_engine_turn_outbox",
			kind: "column",
			value: {
				name: "advancement_key",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "context_engine_turn_outbox",
			kind: "column",
			value: {
				name: "engine_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 3
			}
		},
		{
			table: "context_engine_turn_outbox",
			kind: "column",
			value: {
				name: "owner_plugin_id",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 4
			}
		},
		{
			table: "context_engine_turn_outbox",
			kind: "column",
			value: {
				name: "session_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 5
			}
		},
		{
			table: "context_engine_turn_outbox",
			kind: "column",
			value: {
				name: "payload_json",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 6
			}
		},
		{
			table: "context_engine_turn_outbox",
			kind: "column",
			value: {
				name: "payload_state",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 7
			}
		},
		{
			table: "context_engine_turn_outbox",
			kind: "column",
			value: {
				name: "attempt_count",
				type: "bigint",
				nullable: false,
				identity: false,
				default: "0",
				position: 8
			}
		},
		{
			table: "context_engine_turn_outbox",
			kind: "column",
			value: {
				name: "last_attempt_at",
				type: "bigint",
				nullable: true,
				identity: false,
				default: null,
				position: 9
			}
		},
		{
			table: "context_engine_turn_outbox",
			kind: "column",
			value: {
				name: "last_error",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 10
			}
		},
		{
			table: "context_engine_turn_outbox",
			kind: "column",
			value: {
				name: "created_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 11
			}
		},
		{
			table: "context_engine_turn_outbox",
			kind: "primaryKey",
			value: ["enqueue_sequence"]
		},
		{
			table: "context_engine_turn_outbox",
			kind: "unique",
			value: ["advancement_key"]
		},
		{
			table: "context_engine_turn_outbox",
			kind: "indexes",
			value: 3
		},
		{
			table: "context_engine_turn_outbox",
			kind: "checks",
			value: 0
		},
		{
			table: "conversation_deliveries",
			kind: "table",
			value: null
		},
		{
			table: "conversation_deliveries",
			kind: "column",
			value: {
				name: "operation_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 1
			}
		},
		{
			table: "conversation_deliveries",
			kind: "column",
			value: {
				name: "operation_kind",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "conversation_deliveries",
			kind: "column",
			value: {
				name: "conversation_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 3
			}
		},
		{
			table: "conversation_deliveries",
			kind: "column",
			value: {
				name: "source_session_key",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 4
			}
		},
		{
			table: "conversation_deliveries",
			kind: "column",
			value: {
				name: "message_hash",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 5
			}
		},
		{
			table: "conversation_deliveries",
			kind: "column",
			value: {
				name: "status",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 6
			}
		},
		{
			table: "conversation_deliveries",
			kind: "column",
			value: {
				name: "prepared_message_id",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 7
			}
		},
		{
			table: "conversation_deliveries",
			kind: "column",
			value: {
				name: "platform_message_id",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 8
			}
		},
		{
			table: "conversation_deliveries",
			kind: "column",
			value: {
				name: "queue_id",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 9
			}
		},
		{
			table: "conversation_deliveries",
			kind: "column",
			value: {
				name: "rejection_error",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 10
			}
		},
		{
			table: "conversation_deliveries",
			kind: "column",
			value: {
				name: "reply_message_id",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 11
			}
		},
		{
			table: "conversation_deliveries",
			kind: "column",
			value: {
				name: "reply_to_id",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 12
			}
		},
		{
			table: "conversation_deliveries",
			kind: "column",
			value: {
				name: "reply_thread_id",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 13
			}
		},
		{
			table: "conversation_deliveries",
			kind: "column",
			value: {
				name: "reply_text",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 14
			}
		},
		{
			table: "conversation_deliveries",
			kind: "column",
			value: {
				name: "reply_timestamp",
				type: "bigint",
				nullable: true,
				identity: false,
				default: null,
				position: 15
			}
		},
		{
			table: "conversation_deliveries",
			kind: "column",
			value: {
				name: "created_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 16
			}
		},
		{
			table: "conversation_deliveries",
			kind: "column",
			value: {
				name: "updated_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 17
			}
		},
		{
			table: "conversation_deliveries",
			kind: "primaryKey",
			value: ["operation_id"]
		},
		{
			table: "conversation_deliveries",
			kind: "foreignKey",
			value: {
				columns: ["conversation_id"],
				target: "conversations",
				targetColumns: ["conversation_id"],
				onUpdate: "NO ACTION",
				onDelete: "CASCADE",
				deferrable: false,
				deferred: false
			}
		},
		{
			table: "conversation_deliveries",
			kind: "indexes",
			value: 3
		},
		{
			table: "conversation_deliveries",
			kind: "checks",
			value: 3
		},
		{
			table: "conversations",
			kind: "table",
			value: null
		},
		{
			table: "conversations",
			kind: "column",
			value: {
				name: "conversation_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 1
			}
		},
		{
			table: "conversations",
			kind: "column",
			value: {
				name: "channel",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "conversations",
			kind: "column",
			value: {
				name: "account_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 3
			}
		},
		{
			table: "conversations",
			kind: "column",
			value: {
				name: "kind",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 4
			}
		},
		{
			table: "conversations",
			kind: "column",
			value: {
				name: "peer_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 5
			}
		},
		{
			table: "conversations",
			kind: "column",
			value: {
				name: "delivery_target",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 6
			}
		},
		{
			table: "conversations",
			kind: "column",
			value: {
				name: "parent_conversation_id",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 7
			}
		},
		{
			table: "conversations",
			kind: "column",
			value: {
				name: "thread_id",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 8
			}
		},
		{
			table: "conversations",
			kind: "column",
			value: {
				name: "native_channel_id",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 9
			}
		},
		{
			table: "conversations",
			kind: "column",
			value: {
				name: "native_direct_user_id",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 10
			}
		},
		{
			table: "conversations",
			kind: "column",
			value: {
				name: "label",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 11
			}
		},
		{
			table: "conversations",
			kind: "column",
			value: {
				name: "metadata_json",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 12
			}
		},
		{
			table: "conversations",
			kind: "column",
			value: {
				name: "created_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 13
			}
		},
		{
			table: "conversations",
			kind: "column",
			value: {
				name: "updated_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 14
			}
		},
		{
			table: "conversations",
			kind: "primaryKey",
			value: ["conversation_id"]
		},
		{
			table: "conversations",
			kind: "indexes",
			value: 4
		},
		{
			table: "conversations",
			kind: "checks",
			value: 1
		},
		{
			table: "heartbeat_outcomes",
			kind: "table",
			value: null
		},
		{
			table: "heartbeat_outcomes",
			kind: "column",
			value: {
				name: "session_key",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 1
			}
		},
		{
			table: "heartbeat_outcomes",
			kind: "column",
			value: {
				name: "run_session_key",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "heartbeat_outcomes",
			kind: "column",
			value: {
				name: "outcome",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 3
			}
		},
		{
			table: "heartbeat_outcomes",
			kind: "column",
			value: {
				name: "summary",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 4
			}
		},
		{
			table: "heartbeat_outcomes",
			kind: "column",
			value: {
				name: "response_reason",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 5
			}
		},
		{
			table: "heartbeat_outcomes",
			kind: "column",
			value: {
				name: "priority",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 6
			}
		},
		{
			table: "heartbeat_outcomes",
			kind: "column",
			value: {
				name: "next_check",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 7
			}
		},
		{
			table: "heartbeat_outcomes",
			kind: "column",
			value: {
				name: "task_names_json",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 8
			}
		},
		{
			table: "heartbeat_outcomes",
			kind: "column",
			value: {
				name: "wake_source",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 9
			}
		},
		{
			table: "heartbeat_outcomes",
			kind: "column",
			value: {
				name: "wake_reason",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 10
			}
		},
		{
			table: "heartbeat_outcomes",
			kind: "column",
			value: {
				name: "occurred_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 11
			}
		},
		{
			table: "heartbeat_outcomes",
			kind: "column",
			value: {
				name: "context_run_id",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 12
			}
		},
		{
			table: "heartbeat_outcomes",
			kind: "column",
			value: {
				name: "context_claimed_at",
				type: "bigint",
				nullable: true,
				identity: false,
				default: null,
				position: 13
			}
		},
		{
			table: "heartbeat_outcomes",
			kind: "column",
			value: {
				name: "updated_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 14
			}
		},
		{
			table: "heartbeat_outcomes",
			kind: "primaryKey",
			value: ["session_key"]
		},
		{
			table: "heartbeat_outcomes",
			kind: "foreignKey",
			value: {
				columns: ["session_key"],
				target: "session_nodes",
				targetColumns: ["session_key"],
				onUpdate: "NO ACTION",
				onDelete: "CASCADE",
				deferrable: false,
				deferred: false
			}
		},
		{
			table: "heartbeat_outcomes",
			kind: "indexes",
			value: 1
		},
		{
			table: "heartbeat_outcomes",
			kind: "checks",
			value: 2
		},
		{
			table: "memory_embedding_cache",
			kind: "table",
			value: null
		},
		{
			table: "memory_embedding_cache",
			kind: "column",
			value: {
				name: "provider",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 1
			}
		},
		{
			table: "memory_embedding_cache",
			kind: "column",
			value: {
				name: "model",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "memory_embedding_cache",
			kind: "column",
			value: {
				name: "provider_key",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 3
			}
		},
		{
			table: "memory_embedding_cache",
			kind: "column",
			value: {
				name: "hash",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 4
			}
		},
		{
			table: "memory_embedding_cache",
			kind: "column",
			value: {
				name: "embedding",
				type: "bytea",
				nullable: false,
				identity: false,
				default: null,
				position: 5
			}
		},
		{
			table: "memory_embedding_cache",
			kind: "column",
			value: {
				name: "dims",
				type: "bigint",
				nullable: true,
				identity: false,
				default: null,
				position: 6
			}
		},
		{
			table: "memory_embedding_cache",
			kind: "column",
			value: {
				name: "updated_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 7
			}
		},
		{
			table: "memory_embedding_cache",
			kind: "primaryKey",
			value: [
				"provider",
				"model",
				"provider_key",
				"hash"
			]
		},
		{
			table: "memory_embedding_cache",
			kind: "indexes",
			value: 2
		},
		{
			table: "memory_embedding_cache",
			kind: "checks",
			value: 0
		},
		{
			table: "memory_entry_origins",
			kind: "table",
			value: null
		},
		{
			table: "memory_entry_origins",
			kind: "column",
			value: {
				name: "entry_key",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 1
			}
		},
		{
			table: "memory_entry_origins",
			kind: "column",
			value: {
				name: "agent_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "memory_entry_origins",
			kind: "column",
			value: {
				name: "session_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 3
			}
		},
		{
			table: "memory_entry_origins",
			kind: "column",
			value: {
				name: "session_key",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 4
			}
		},
		{
			table: "memory_entry_origins",
			kind: "column",
			value: {
				name: "origin_class",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 5
			}
		},
		{
			table: "memory_entry_origins",
			kind: "column",
			value: {
				name: "observed_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 6
			}
		},
		{
			table: "memory_entry_origins",
			kind: "primaryKey",
			value: [
				"entry_key",
				"agent_id",
				"session_id"
			]
		},
		{
			table: "memory_entry_origins",
			kind: "indexes",
			value: 1
		},
		{
			table: "memory_entry_origins",
			kind: "checks",
			value: 1
		},
		{
			table: "memory_index_chunk_provenance",
			kind: "table",
			value: null
		},
		{
			table: "memory_index_chunk_provenance",
			kind: "column",
			value: {
				name: "chunk_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 1
			}
		},
		{
			table: "memory_index_chunk_provenance",
			kind: "column",
			value: {
				name: "origin_class",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "memory_index_chunk_provenance",
			kind: "column",
			value: {
				name: "session_kind",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 3
			}
		},
		{
			table: "memory_index_chunk_provenance",
			kind: "column",
			value: {
				name: "observed_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 4
			}
		},
		{
			table: "memory_index_chunk_provenance",
			kind: "column",
			value: {
				name: "supersedes_key",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 5
			}
		},
		{
			table: "memory_index_chunk_provenance",
			kind: "primaryKey",
			value: ["chunk_id"]
		},
		{
			table: "memory_index_chunk_provenance",
			kind: "foreignKey",
			value: {
				columns: ["chunk_id"],
				target: "memory_index_chunks",
				targetColumns: ["id"],
				onUpdate: "NO ACTION",
				onDelete: "CASCADE",
				deferrable: false,
				deferred: false
			}
		},
		{
			table: "memory_index_chunk_provenance",
			kind: "indexes",
			value: 1
		},
		{
			table: "memory_index_chunk_provenance",
			kind: "checks",
			value: 2
		},
		{
			table: "memory_index_chunk_recall_metadata",
			kind: "table",
			value: null
		},
		{
			table: "memory_index_chunk_recall_metadata",
			kind: "column",
			value: {
				name: "chunk_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 1
			}
		},
		{
			table: "memory_index_chunk_recall_metadata",
			kind: "column",
			value: {
				name: "importance",
				type: "bigint",
				nullable: true,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "memory_index_chunk_recall_metadata",
			kind: "column",
			value: {
				name: "triggers",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 3
			}
		},
		{
			table: "memory_index_chunk_recall_metadata",
			kind: "column",
			value: {
				name: "project_key",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 4
			}
		},
		{
			table: "memory_index_chunk_recall_metadata",
			kind: "primaryKey",
			value: ["chunk_id"]
		},
		{
			table: "memory_index_chunk_recall_metadata",
			kind: "foreignKey",
			value: {
				columns: ["chunk_id"],
				target: "memory_index_chunks",
				targetColumns: ["id"],
				onUpdate: "NO ACTION",
				onDelete: "CASCADE",
				deferrable: false,
				deferred: false
			}
		},
		{
			table: "memory_index_chunk_recall_metadata",
			kind: "indexes",
			value: 1
		},
		{
			table: "memory_index_chunk_recall_metadata",
			kind: "checks",
			value: 1
		},
		{
			table: "memory_index_chunks",
			kind: "table",
			value: null
		},
		{
			table: "memory_index_chunks",
			kind: "column",
			value: {
				name: "chunk_rowid",
				type: "bigint",
				nullable: false,
				identity: true,
				default: null,
				position: 1
			}
		},
		{
			table: "memory_index_chunks",
			kind: "column",
			value: {
				name: "id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "memory_index_chunks",
			kind: "column",
			value: {
				name: "path",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 3
			}
		},
		{
			table: "memory_index_chunks",
			kind: "column",
			value: {
				name: "source",
				type: "text",
				nullable: false,
				identity: false,
				default: "'memory'",
				position: 4
			}
		},
		{
			table: "memory_index_chunks",
			kind: "column",
			value: {
				name: "start_line",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 5
			}
		},
		{
			table: "memory_index_chunks",
			kind: "column",
			value: {
				name: "end_line",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 6
			}
		},
		{
			table: "memory_index_chunks",
			kind: "column",
			value: {
				name: "hash",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 7
			}
		},
		{
			table: "memory_index_chunks",
			kind: "column",
			value: {
				name: "model",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 8
			}
		},
		{
			table: "memory_index_chunks",
			kind: "column",
			value: {
				name: "text",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 9
			}
		},
		{
			table: "memory_index_chunks",
			kind: "column",
			value: {
				name: "embedding",
				type: "bytea",
				nullable: false,
				identity: false,
				default: null,
				position: 10
			}
		},
		{
			table: "memory_index_chunks",
			kind: "column",
			value: {
				name: "updated_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 11
			}
		},
		{
			table: "memory_index_chunks",
			kind: "primaryKey",
			value: ["chunk_rowid"]
		},
		{
			table: "memory_index_chunks",
			kind: "unique",
			value: ["id"]
		},
		{
			table: "memory_index_chunks",
			kind: "indexes",
			value: 4
		},
		{
			table: "memory_index_chunks",
			kind: "checks",
			value: 0
		},
		{
			table: "memory_index_meta",
			kind: "table",
			value: null
		},
		{
			table: "memory_index_meta",
			kind: "column",
			value: {
				name: "key",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 1
			}
		},
		{
			table: "memory_index_meta",
			kind: "column",
			value: {
				name: "value",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "memory_index_meta",
			kind: "primaryKey",
			value: ["key"]
		},
		{
			table: "memory_index_meta",
			kind: "indexes",
			value: 1
		},
		{
			table: "memory_index_meta",
			kind: "checks",
			value: 0
		},
		{
			table: "memory_index_sources",
			kind: "table",
			value: null
		},
		{
			table: "memory_index_sources",
			kind: "column",
			value: {
				name: "id",
				type: "bigint",
				nullable: false,
				identity: true,
				default: null,
				position: 1
			}
		},
		{
			table: "memory_index_sources",
			kind: "column",
			value: {
				name: "path",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "memory_index_sources",
			kind: "column",
			value: {
				name: "source",
				type: "text",
				nullable: false,
				identity: false,
				default: "'memory'",
				position: 3
			}
		},
		{
			table: "memory_index_sources",
			kind: "column",
			value: {
				name: "hash",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 4
			}
		},
		{
			table: "memory_index_sources",
			kind: "column",
			value: {
				name: "mtime",
				type: "double precision",
				nullable: false,
				identity: false,
				default: null,
				position: 5
			}
		},
		{
			table: "memory_index_sources",
			kind: "column",
			value: {
				name: "size",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 6
			}
		},
		{
			table: "memory_index_sources",
			kind: "primaryKey",
			value: ["id"]
		},
		{
			table: "memory_index_sources",
			kind: "unique",
			value: ["path", "source"]
		},
		{
			table: "memory_index_sources",
			kind: "indexes",
			value: 6
		},
		{
			table: "memory_index_sources",
			kind: "checks",
			value: 0
		},
		{
			table: "memory_index_state",
			kind: "table",
			value: null
		},
		{
			table: "memory_index_state",
			kind: "column",
			value: {
				name: "id",
				type: "bigint",
				nullable: false,
				identity: true,
				default: null,
				position: 1
			}
		},
		{
			table: "memory_index_state",
			kind: "column",
			value: {
				name: "revision",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "memory_index_state",
			kind: "primaryKey",
			value: ["id"]
		},
		{
			table: "memory_index_state",
			kind: "indexes",
			value: 1
		},
		{
			table: "memory_index_state",
			kind: "checks",
			value: 1
		},
		{
			table: "memory_session_tombstones",
			kind: "table",
			value: null
		},
		{
			table: "memory_session_tombstones",
			kind: "column",
			value: {
				name: "session_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 1
			}
		},
		{
			table: "memory_session_tombstones",
			kind: "column",
			value: {
				name: "agent_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "memory_session_tombstones",
			kind: "column",
			value: {
				name: "reason",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 3
			}
		},
		{
			table: "memory_session_tombstones",
			kind: "column",
			value: {
				name: "created_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 4
			}
		},
		{
			table: "memory_session_tombstones",
			kind: "primaryKey",
			value: ["session_id"]
		},
		{
			table: "memory_session_tombstones",
			kind: "indexes",
			value: 1
		},
		{
			table: "memory_session_tombstones",
			kind: "checks",
			value: 0
		},
		{
			table: "message_tool_run_outcomes",
			kind: "table",
			value: null
		},
		{
			table: "message_tool_run_outcomes",
			kind: "column",
			value: {
				name: "id",
				type: "bigint",
				nullable: false,
				identity: true,
				default: null,
				position: 1
			}
		},
		{
			table: "message_tool_run_outcomes",
			kind: "column",
			value: {
				name: "run_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "message_tool_run_outcomes",
			kind: "column",
			value: {
				name: "session_key",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 3
			}
		},
		{
			table: "message_tool_run_outcomes",
			kind: "column",
			value: {
				name: "agent_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 4
			}
		},
		{
			table: "message_tool_run_outcomes",
			kind: "column",
			value: {
				name: "provider",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 5
			}
		},
		{
			table: "message_tool_run_outcomes",
			kind: "column",
			value: {
				name: "model",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 6
			}
		},
		{
			table: "message_tool_run_outcomes",
			kind: "column",
			value: {
				name: "outcome",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 7
			}
		},
		{
			table: "message_tool_run_outcomes",
			kind: "column",
			value: {
				name: "run_status",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 8
			}
		},
		{
			table: "message_tool_run_outcomes",
			kind: "column",
			value: {
				name: "occurred_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 9
			}
		},
		{
			table: "message_tool_run_outcomes",
			kind: "primaryKey",
			value: ["id"]
		},
		{
			table: "message_tool_run_outcomes",
			kind: "indexes",
			value: 2
		},
		{
			table: "message_tool_run_outcomes",
			kind: "checks",
			value: 2
		},
		{
			table: "schema_meta",
			kind: "table",
			value: null
		},
		{
			table: "schema_meta",
			kind: "column",
			value: {
				name: "meta_key",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 1
			}
		},
		{
			table: "schema_meta",
			kind: "column",
			value: {
				name: "role",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "schema_meta",
			kind: "column",
			value: {
				name: "schema_version",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 3
			}
		},
		{
			table: "schema_meta",
			kind: "column",
			value: {
				name: "agent_id",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 4
			}
		},
		{
			table: "schema_meta",
			kind: "column",
			value: {
				name: "app_version",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 5
			}
		},
		{
			table: "schema_meta",
			kind: "column",
			value: {
				name: "created_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 6
			}
		},
		{
			table: "schema_meta",
			kind: "column",
			value: {
				name: "updated_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 7
			}
		},
		{
			table: "schema_meta",
			kind: "primaryKey",
			value: ["meta_key"]
		},
		{
			table: "schema_meta",
			kind: "indexes",
			value: 1
		},
		{
			table: "schema_meta",
			kind: "checks",
			value: 0
		},
		{
			table: "session_canonical_validation_pending",
			kind: "table",
			value: null
		},
		{
			table: "session_canonical_validation_pending",
			kind: "column",
			value: {
				name: "session_key",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 1
			}
		},
		{
			table: "session_canonical_validation_pending",
			kind: "primaryKey",
			value: ["session_key"]
		},
		{
			table: "session_canonical_validation_pending",
			kind: "indexes",
			value: 1
		},
		{
			table: "session_canonical_validation_pending",
			kind: "checks",
			value: 0
		},
		{
			table: "session_conversations",
			kind: "table",
			value: null
		},
		{
			table: "session_conversations",
			kind: "column",
			value: {
				name: "session_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 1
			}
		},
		{
			table: "session_conversations",
			kind: "column",
			value: {
				name: "conversation_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "session_conversations",
			kind: "column",
			value: {
				name: "role",
				type: "text",
				nullable: false,
				identity: false,
				default: "'primary'",
				position: 3
			}
		},
		{
			table: "session_conversations",
			kind: "column",
			value: {
				name: "route_context_json",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 4
			}
		},
		{
			table: "session_conversations",
			kind: "column",
			value: {
				name: "first_seen_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 5
			}
		},
		{
			table: "session_conversations",
			kind: "column",
			value: {
				name: "last_seen_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 6
			}
		},
		{
			table: "session_conversations",
			kind: "primaryKey",
			value: [
				"session_id",
				"conversation_id",
				"role"
			]
		},
		{
			table: "session_conversations",
			kind: "foreignKey",
			value: {
				columns: ["conversation_id"],
				target: "conversations",
				targetColumns: ["conversation_id"],
				onUpdate: "NO ACTION",
				onDelete: "CASCADE",
				deferrable: false,
				deferred: false
			}
		},
		{
			table: "session_conversations",
			kind: "foreignKey",
			value: {
				columns: ["session_id"],
				target: "session_windows",
				targetColumns: ["session_id"],
				onUpdate: "NO ACTION",
				onDelete: "CASCADE",
				deferrable: false,
				deferred: false
			}
		},
		{
			table: "session_conversations",
			kind: "indexes",
			value: 3
		},
		{
			table: "session_conversations",
			kind: "checks",
			value: 1
		},
		{
			table: "session_entry_snapshots",
			kind: "table",
			value: null
		},
		{
			table: "session_entry_snapshots",
			kind: "column",
			value: {
				name: "session_key",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 1
			}
		},
		{
			table: "session_entry_snapshots",
			kind: "column",
			value: {
				name: "field",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "session_entry_snapshots",
			kind: "column",
			value: {
				name: "value_json",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 3
			}
		},
		{
			table: "session_entry_snapshots",
			kind: "primaryKey",
			value: ["session_key", "field"]
		},
		{
			table: "session_entry_snapshots",
			kind: "foreignKey",
			value: {
				columns: ["session_key"],
				target: "session_nodes",
				targetColumns: ["session_key"],
				onUpdate: "NO ACTION",
				onDelete: "CASCADE",
				deferrable: false,
				deferred: false
			}
		},
		{
			table: "session_entry_snapshots",
			kind: "indexes",
			value: 1
		},
		{
			table: "session_entry_snapshots",
			kind: "checks",
			value: 1
		},
		{
			table: "session_goal_operations",
			kind: "table",
			value: null
		},
		{
			table: "session_goal_operations",
			kind: "column",
			value: {
				name: "session_key",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 1
			}
		},
		{
			table: "session_goal_operations",
			kind: "column",
			value: {
				name: "operation_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "session_goal_operations",
			kind: "column",
			value: {
				name: "session_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 3
			}
		},
		{
			table: "session_goal_operations",
			kind: "column",
			value: {
				name: "request_fingerprint",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 4
			}
		},
		{
			table: "session_goal_operations",
			kind: "column",
			value: {
				name: "result_json",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 5
			}
		},
		{
			table: "session_goal_operations",
			kind: "column",
			value: {
				name: "expires_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 6
			}
		},
		{
			table: "session_goal_operations",
			kind: "primaryKey",
			value: ["session_key", "operation_id"]
		},
		{
			table: "session_goal_operations",
			kind: "indexes",
			value: 2
		},
		{
			table: "session_goal_operations",
			kind: "checks",
			value: 0
		},
		{
			table: "session_input_completions",
			kind: "table",
			value: null
		},
		{
			table: "session_input_completions",
			kind: "column",
			value: {
				name: "session_key",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 1
			}
		},
		{
			table: "session_input_completions",
			kind: "column",
			value: {
				name: "session_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "session_input_completions",
			kind: "column",
			value: {
				name: "idempotency_key",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 3
			}
		},
		{
			table: "session_input_completions",
			kind: "column",
			value: {
				name: "run_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 4
			}
		},
		{
			table: "session_input_completions",
			kind: "column",
			value: {
				name: "request_hash",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 5
			}
		},
		{
			table: "session_input_completions",
			kind: "column",
			value: {
				name: "outcome_json",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 6
			}
		},
		{
			table: "session_input_completions",
			kind: "column",
			value: {
				name: "succeeded",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 7
			}
		},
		{
			table: "session_input_completions",
			kind: "column",
			value: {
				name: "completed_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 8
			}
		},
		{
			table: "session_input_completions",
			kind: "primaryKey",
			value: ["session_id", "idempotency_key"]
		},
		{
			table: "session_input_completions",
			kind: "foreignKey",
			value: {
				columns: ["session_id"],
				target: "session_windows",
				targetColumns: ["session_id"],
				onUpdate: "NO ACTION",
				onDelete: "CASCADE",
				deferrable: false,
				deferred: false
			}
		},
		{
			table: "session_input_completions",
			kind: "foreignKey",
			value: {
				columns: ["session_key"],
				target: "session_nodes",
				targetColumns: ["session_key"],
				onUpdate: "NO ACTION",
				onDelete: "CASCADE",
				deferrable: false,
				deferred: false
			}
		},
		{
			table: "session_input_completions",
			kind: "indexes",
			value: 1
		},
		{
			table: "session_input_completions",
			kind: "checks",
			value: 1
		},
		{
			table: "session_key_contract",
			kind: "table",
			value: null
		},
		{
			table: "session_key_contract",
			kind: "column",
			value: {
				name: "id",
				type: "bigint",
				nullable: false,
				identity: true,
				default: null,
				position: 1
			}
		},
		{
			table: "session_key_contract",
			kind: "column",
			value: {
				name: "main_key",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "session_key_contract",
			kind: "column",
			value: {
				name: "canonical_ready",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 3
			}
		},
		{
			table: "session_key_contract",
			kind: "column",
			value: {
				name: "updated_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 4
			}
		},
		{
			table: "session_key_contract",
			kind: "primaryKey",
			value: ["id"]
		},
		{
			table: "session_key_contract",
			kind: "indexes",
			value: 1
		},
		{
			table: "session_key_contract",
			kind: "checks",
			value: 1
		},
		{
			table: "session_members",
			kind: "table",
			value: null
		},
		{
			table: "session_members",
			kind: "column",
			value: {
				name: "session_key",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 1
			}
		},
		{
			table: "session_members",
			kind: "column",
			value: {
				name: "identity_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "session_members",
			kind: "column",
			value: {
				name: "added_by",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 3
			}
		},
		{
			table: "session_members",
			kind: "column",
			value: {
				name: "added_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 4
			}
		},
		{
			table: "session_members",
			kind: "primaryKey",
			value: ["session_key", "identity_id"]
		},
		{
			table: "session_members",
			kind: "foreignKey",
			value: {
				columns: ["session_key"],
				target: "session_nodes",
				targetColumns: ["session_key"],
				onUpdate: "NO ACTION",
				onDelete: "CASCADE",
				deferrable: false,
				deferred: false
			}
		},
		{
			table: "session_members",
			kind: "indexes",
			value: 2
		},
		{
			table: "session_members",
			kind: "checks",
			value: 0
		},
		{
			table: "session_nodes",
			kind: "table",
			value: null
		},
		{
			table: "session_nodes",
			kind: "column",
			value: {
				name: "session_key",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 1
			}
		},
		{
			table: "session_nodes",
			kind: "column",
			value: {
				name: "current_session_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "session_nodes",
			kind: "column",
			value: {
				name: "entry_json",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 3
			}
		},
		{
			table: "session_nodes",
			kind: "column",
			value: {
				name: "session_started_at",
				type: "bigint",
				nullable: true,
				identity: false,
				default: null,
				position: 4
			}
		},
		{
			table: "session_nodes",
			kind: "column",
			value: {
				name: "has_optional_references",
				type: "bigint",
				nullable: false,
				identity: false,
				default: "0",
				position: 5
			}
		},
		{
			table: "session_nodes",
			kind: "column",
			value: {
				name: "snapshot_revision",
				type: "bigint",
				nullable: false,
				identity: false,
				default: "0",
				position: 6
			}
		},
		{
			table: "session_nodes",
			kind: "column",
			value: {
				name: "legacy_acp_migration_json",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 7
			}
		},
		{
			table: "session_nodes",
			kind: "column",
			value: {
				name: "entry_valid",
				type: "bigint",
				nullable: false,
				identity: false,
				default: "0",
				position: 8
			}
		},
		{
			table: "session_nodes",
			kind: "column",
			value: {
				name: "updated_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 9
			}
		},
		{
			table: "session_nodes",
			kind: "column",
			value: {
				name: "status",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 10
			}
		},
		{
			table: "session_nodes",
			kind: "column",
			value: {
				name: "created_at",
				type: "bigint",
				nullable: true,
				identity: false,
				default: null,
				position: 11
			}
		},
		{
			table: "session_nodes",
			kind: "column",
			value: {
				name: "created_via",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 12
			}
		},
		{
			table: "session_nodes",
			kind: "column",
			value: {
				name: "created_actor_type",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 13
			}
		},
		{
			table: "session_nodes",
			kind: "column",
			value: {
				name: "created_actor_id",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 14
			}
		},
		{
			table: "session_nodes",
			kind: "column",
			value: {
				name: "owner_actor_type",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 15
			}
		},
		{
			table: "session_nodes",
			kind: "column",
			value: {
				name: "owner_actor_id",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 16
			}
		},
		{
			table: "session_nodes",
			kind: "column",
			value: {
				name: "owner_assigned_by_type",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 17
			}
		},
		{
			table: "session_nodes",
			kind: "column",
			value: {
				name: "owner_assigned_by_id",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 18
			}
		},
		{
			table: "session_nodes",
			kind: "column",
			value: {
				name: "owner_assigned_at",
				type: "bigint",
				nullable: true,
				identity: false,
				default: null,
				position: 19
			}
		},
		{
			table: "session_nodes",
			kind: "column",
			value: {
				name: "project_id",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 20
			}
		},
		{
			table: "session_nodes",
			kind: "column",
			value: {
				name: "parent_session_key",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 21
			}
		},
		{
			table: "session_nodes",
			kind: "column",
			value: {
				name: "spawned_by",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 22
			}
		},
		{
			table: "session_nodes",
			kind: "column",
			value: {
				name: "fork_source_session_key",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 23
			}
		},
		{
			table: "session_nodes",
			kind: "column",
			value: {
				name: "fork_source_session_id",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 24
			}
		},
		{
			table: "session_nodes",
			kind: "column",
			value: {
				name: "fork_source_entry_id",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 25
			}
		},
		{
			table: "session_nodes",
			kind: "column",
			value: {
				name: "label",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 26
			}
		},
		{
			table: "session_nodes",
			kind: "column",
			value: {
				name: "display_name",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 27
			}
		},
		{
			table: "session_nodes",
			kind: "column",
			value: {
				name: "category",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 28
			}
		},
		{
			table: "session_nodes",
			kind: "column",
			value: {
				name: "icon",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 29
			}
		},
		{
			table: "session_nodes",
			kind: "column",
			value: {
				name: "pinned_at",
				type: "bigint",
				nullable: true,
				identity: false,
				default: null,
				position: 30
			}
		},
		{
			table: "session_nodes",
			kind: "column",
			value: {
				name: "archived_at",
				type: "bigint",
				nullable: true,
				identity: false,
				default: null,
				position: 31
			}
		},
		{
			table: "session_nodes",
			kind: "column",
			value: {
				name: "last_read_at",
				type: "bigint",
				nullable: true,
				identity: false,
				default: null,
				position: 32
			}
		},
		{
			table: "session_nodes",
			kind: "column",
			value: {
				name: "last_interaction_at",
				type: "bigint",
				nullable: true,
				identity: false,
				default: null,
				position: 33
			}
		},
		{
			table: "session_nodes",
			kind: "column",
			value: {
				name: "last_activity_at",
				type: "bigint",
				nullable: true,
				identity: false,
				default: null,
				position: 34
			}
		},
		{
			table: "session_nodes",
			kind: "primaryKey",
			value: ["session_key"]
		},
		{
			table: "session_nodes",
			kind: "indexes",
			value: 11
		},
		{
			table: "session_nodes",
			kind: "checks",
			value: 4
		},
		{
			table: "session_participants",
			kind: "table",
			value: null
		},
		{
			table: "session_participants",
			kind: "column",
			value: {
				name: "session_key",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 1
			}
		},
		{
			table: "session_participants",
			kind: "column",
			value: {
				name: "identity_namespace",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "session_participants",
			kind: "column",
			value: {
				name: "actor_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 3
			}
		},
		{
			table: "session_participants",
			kind: "column",
			value: {
				name: "contribution_count",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 4
			}
		},
		{
			table: "session_participants",
			kind: "column",
			value: {
				name: "first_prompted_at",
				type: "bigint",
				nullable: true,
				identity: false,
				default: null,
				position: 5
			}
		},
		{
			table: "session_participants",
			kind: "column",
			value: {
				name: "last_prompted_at",
				type: "bigint",
				nullable: true,
				identity: false,
				default: null,
				position: 6
			}
		},
		{
			table: "session_participants",
			kind: "primaryKey",
			value: [
				"session_key",
				"identity_namespace",
				"actor_id"
			]
		},
		{
			table: "session_participants",
			kind: "foreignKey",
			value: {
				columns: ["session_key"],
				target: "session_nodes",
				targetColumns: ["session_key"],
				onUpdate: "NO ACTION",
				onDelete: "CASCADE",
				deferrable: false,
				deferred: false
			}
		},
		{
			table: "session_participants",
			kind: "indexes",
			value: 1
		},
		{
			table: "session_participants",
			kind: "checks",
			value: 0
		},
		{
			table: "session_pending_inputs",
			kind: "table",
			value: null
		},
		{
			table: "session_pending_inputs",
			kind: "column",
			value: {
				name: "seq",
				type: "bigint",
				nullable: false,
				identity: true,
				default: null,
				position: 1
			}
		},
		{
			table: "session_pending_inputs",
			kind: "column",
			value: {
				name: "input_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "session_pending_inputs",
			kind: "column",
			value: {
				name: "session_key",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 3
			}
		},
		{
			table: "session_pending_inputs",
			kind: "column",
			value: {
				name: "session_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 4
			}
		},
		{
			table: "session_pending_inputs",
			kind: "column",
			value: {
				name: "idempotency_key",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 5
			}
		},
		{
			table: "session_pending_inputs",
			kind: "column",
			value: {
				name: "run_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 6
			}
		},
		{
			table: "session_pending_inputs",
			kind: "column",
			value: {
				name: "request_hash",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 7
			}
		},
		{
			table: "session_pending_inputs",
			kind: "column",
			value: {
				name: "message_json",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 8
			}
		},
		{
			table: "session_pending_inputs",
			kind: "column",
			value: {
				name: "lifecycle_generation",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 9
			}
		},
		{
			table: "session_pending_inputs",
			kind: "column",
			value: {
				name: "state",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 10
			}
		},
		{
			table: "session_pending_inputs",
			kind: "column",
			value: {
				name: "accepted_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 11
			}
		},
		{
			table: "session_pending_inputs",
			kind: "column",
			value: {
				name: "consumed_event_id",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 12
			}
		},
		{
			table: "session_pending_inputs",
			kind: "primaryKey",
			value: ["seq"]
		},
		{
			table: "session_pending_inputs",
			kind: "unique",
			value: ["input_id"]
		},
		{
			table: "session_pending_inputs",
			kind: "unique",
			value: ["session_id", "idempotency_key"]
		},
		{
			table: "session_pending_inputs",
			kind: "foreignKey",
			value: {
				columns: ["session_id"],
				target: "session_windows",
				targetColumns: ["session_id"],
				onUpdate: "NO ACTION",
				onDelete: "CASCADE",
				deferrable: false,
				deferred: false
			}
		},
		{
			table: "session_pending_inputs",
			kind: "foreignKey",
			value: {
				columns: ["session_key"],
				target: "session_nodes",
				targetColumns: ["session_key"],
				onUpdate: "NO ACTION",
				onDelete: "CASCADE",
				deferrable: false,
				deferred: false
			}
		},
		{
			table: "session_pending_inputs",
			kind: "indexes",
			value: 4
		},
		{
			table: "session_pending_inputs",
			kind: "checks",
			value: 1
		},
		{
			table: "session_progress_cards",
			kind: "table",
			value: null
		},
		{
			table: "session_progress_cards",
			kind: "column",
			value: {
				name: "session_key",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 1
			}
		},
		{
			table: "session_progress_cards",
			kind: "column",
			value: {
				name: "markdown",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "session_progress_cards",
			kind: "column",
			value: {
				name: "steps_json",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 3
			}
		},
		{
			table: "session_progress_cards",
			kind: "column",
			value: {
				name: "revision",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 4
			}
		},
		{
			table: "session_progress_cards",
			kind: "column",
			value: {
				name: "created_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 5
			}
		},
		{
			table: "session_progress_cards",
			kind: "column",
			value: {
				name: "updated_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 6
			}
		},
		{
			table: "session_progress_cards",
			kind: "primaryKey",
			value: ["session_key"]
		},
		{
			table: "session_progress_cards",
			kind: "foreignKey",
			value: {
				columns: ["session_key"],
				target: "session_nodes",
				targetColumns: ["session_key"],
				onUpdate: "NO ACTION",
				onDelete: "CASCADE",
				deferrable: false,
				deferred: false
			}
		},
		{
			table: "session_progress_cards",
			kind: "indexes",
			value: 1
		},
		{
			table: "session_progress_cards",
			kind: "checks",
			value: 0
		},
		{
			table: "session_reactions",
			kind: "table",
			value: null
		},
		{
			table: "session_reactions",
			kind: "column",
			value: {
				name: "session_key",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 1
			}
		},
		{
			table: "session_reactions",
			kind: "column",
			value: {
				name: "session_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "session_reactions",
			kind: "column",
			value: {
				name: "message_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 3
			}
		},
		{
			table: "session_reactions",
			kind: "column",
			value: {
				name: "emoji",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 4
			}
		},
		{
			table: "session_reactions",
			kind: "column",
			value: {
				name: "identity_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 5
			}
		},
		{
			table: "session_reactions",
			kind: "column",
			value: {
				name: "identity_label",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 6
			}
		},
		{
			table: "session_reactions",
			kind: "column",
			value: {
				name: "created_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 7
			}
		},
		{
			table: "session_reactions",
			kind: "primaryKey",
			value: [
				"session_key",
				"session_id",
				"message_id",
				"emoji",
				"identity_id"
			]
		},
		{
			table: "session_reactions",
			kind: "foreignKey",
			value: {
				columns: ["session_key"],
				target: "session_nodes",
				targetColumns: ["session_key"],
				onUpdate: "NO ACTION",
				onDelete: "CASCADE",
				deferrable: false,
				deferred: false
			}
		},
		{
			table: "session_reactions",
			kind: "indexes",
			value: 1
		},
		{
			table: "session_reactions",
			kind: "checks",
			value: 0
		},
		{
			table: "session_suggestions",
			kind: "table",
			value: null
		},
		{
			table: "session_suggestions",
			kind: "column",
			value: {
				name: "id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 1
			}
		},
		{
			table: "session_suggestions",
			kind: "column",
			value: {
				name: "session_key",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "session_suggestions",
			kind: "column",
			value: {
				name: "author_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 3
			}
		},
		{
			table: "session_suggestions",
			kind: "column",
			value: {
				name: "author_label",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 4
			}
		},
		{
			table: "session_suggestions",
			kind: "column",
			value: {
				name: "text",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 5
			}
		},
		{
			table: "session_suggestions",
			kind: "column",
			value: {
				name: "created_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 6
			}
		},
		{
			table: "session_suggestions",
			kind: "column",
			value: {
				name: "state",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 7
			}
		},
		{
			table: "session_suggestions",
			kind: "column",
			value: {
				name: "dispatch_token",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 8
			}
		},
		{
			table: "session_suggestions",
			kind: "column",
			value: {
				name: "dispatch_started_at",
				type: "bigint",
				nullable: true,
				identity: false,
				default: null,
				position: 9
			}
		},
		{
			table: "session_suggestions",
			kind: "column",
			value: {
				name: "dispatch_resolution",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 10
			}
		},
		{
			table: "session_suggestions",
			kind: "primaryKey",
			value: ["id"]
		},
		{
			table: "session_suggestions",
			kind: "foreignKey",
			value: {
				columns: ["session_key"],
				target: "session_nodes",
				targetColumns: ["session_key"],
				onUpdate: "NO ACTION",
				onDelete: "CASCADE",
				deferrable: false,
				deferred: false
			}
		},
		{
			table: "session_suggestions",
			kind: "indexes",
			value: 3
		},
		{
			table: "session_suggestions",
			kind: "checks",
			value: 3
		},
		{
			table: "session_transcript_active_events",
			kind: "table",
			value: null
		},
		{
			table: "session_transcript_active_events",
			kind: "column",
			value: {
				name: "session_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 1
			}
		},
		{
			table: "session_transcript_active_events",
			kind: "column",
			value: {
				name: "active_position",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "session_transcript_active_events",
			kind: "column",
			value: {
				name: "event_seq",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 3
			}
		},
		{
			table: "session_transcript_active_events",
			kind: "column",
			value: {
				name: "message_position",
				type: "bigint",
				nullable: true,
				identity: false,
				default: null,
				position: 4
			}
		},
		{
			table: "session_transcript_active_events",
			kind: "column",
			value: {
				name: "context_eligible",
				type: "bigint",
				nullable: true,
				identity: false,
				default: null,
				position: 5
			}
		},
		{
			table: "session_transcript_active_events",
			kind: "primaryKey",
			value: ["session_id", "active_position"]
		},
		{
			table: "session_transcript_active_events",
			kind: "foreignKey",
			value: {
				columns: ["session_id", "event_seq"],
				target: "transcript_events",
				targetColumns: ["session_id", "seq"],
				onUpdate: "NO ACTION",
				onDelete: "CASCADE",
				deferrable: false,
				deferred: false
			}
		},
		{
			table: "session_transcript_active_events",
			kind: "indexes",
			value: 4
		},
		{
			table: "session_transcript_active_events",
			kind: "checks",
			value: 2
		},
		{
			table: "session_transcript_archives",
			kind: "table",
			value: null
		},
		{
			table: "session_transcript_archives",
			kind: "column",
			value: {
				name: "session_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 1
			}
		},
		{
			table: "session_transcript_archives",
			kind: "column",
			value: {
				name: "generation",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "session_transcript_archives",
			kind: "column",
			value: {
				name: "session_key",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 3
			}
		},
		{
			table: "session_transcript_archives",
			kind: "column",
			value: {
				name: "reason",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 4
			}
		},
		{
			table: "session_transcript_archives",
			kind: "column",
			value: {
				name: "encoding",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 5
			}
		},
		{
			table: "session_transcript_archives",
			kind: "column",
			value: {
				name: "archive_blob",
				type: "bytea",
				nullable: false,
				identity: false,
				default: null,
				position: 6
			}
		},
		{
			table: "session_transcript_archives",
			kind: "column",
			value: {
				name: "archive_sha256",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 7
			}
		},
		{
			table: "session_transcript_archives",
			kind: "column",
			value: {
				name: "archive_name",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 8
			}
		},
		{
			table: "session_transcript_archives",
			kind: "column",
			value: {
				name: "created_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 9
			}
		},
		{
			table: "session_transcript_archives",
			kind: "column",
			value: {
				name: "published_at",
				type: "bigint",
				nullable: true,
				identity: false,
				default: null,
				position: 10
			}
		},
		{
			table: "session_transcript_archives",
			kind: "column",
			value: {
				name: "publish_attempts",
				type: "bigint",
				nullable: false,
				identity: false,
				default: "0",
				position: 11
			}
		},
		{
			table: "session_transcript_archives",
			kind: "column",
			value: {
				name: "last_publish_attempt_at",
				type: "bigint",
				nullable: true,
				identity: false,
				default: null,
				position: 12
			}
		},
		{
			table: "session_transcript_archives",
			kind: "column",
			value: {
				name: "last_publish_error",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 13
			}
		},
		{
			table: "session_transcript_archives",
			kind: "primaryKey",
			value: ["session_id", "generation"]
		},
		{
			table: "session_transcript_archives",
			kind: "unique",
			value: ["archive_name"]
		},
		{
			table: "session_transcript_archives",
			kind: "indexes",
			value: 4
		},
		{
			table: "session_transcript_archives",
			kind: "checks",
			value: 5
		},
		{
			table: "session_transcript_cold_archive_chunks",
			kind: "table",
			value: null
		},
		{
			table: "session_transcript_cold_archive_chunks",
			kind: "column",
			value: {
				name: "session_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 1
			}
		},
		{
			table: "session_transcript_cold_archive_chunks",
			kind: "column",
			value: {
				name: "chunk_index",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "session_transcript_cold_archive_chunks",
			kind: "column",
			value: {
				name: "archive_name",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 3
			}
		},
		{
			table: "session_transcript_cold_archive_chunks",
			kind: "column",
			value: {
				name: "archive_sha256",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 4
			}
		},
		{
			table: "session_transcript_cold_archive_chunks",
			kind: "column",
			value: {
				name: "first_seq",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 5
			}
		},
		{
			table: "session_transcript_cold_archive_chunks",
			kind: "column",
			value: {
				name: "last_seq",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 6
			}
		},
		{
			table: "session_transcript_cold_archive_chunks",
			kind: "column",
			value: {
				name: "event_count",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 7
			}
		},
		{
			table: "session_transcript_cold_archive_chunks",
			kind: "column",
			value: {
				name: "raw_bytes",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 8
			}
		},
		{
			table: "session_transcript_cold_archive_chunks",
			kind: "column",
			value: {
				name: "archive_bytes",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 9
			}
		},
		{
			table: "session_transcript_cold_archive_chunks",
			kind: "column",
			value: {
				name: "archive_blob",
				type: "bytea",
				nullable: true,
				identity: false,
				default: null,
				position: 10
			}
		},
		{
			table: "session_transcript_cold_archive_chunks",
			kind: "primaryKey",
			value: ["session_id", "chunk_index"]
		},
		{
			table: "session_transcript_cold_archive_chunks",
			kind: "unique",
			value: ["archive_name"]
		},
		{
			table: "session_transcript_cold_archive_chunks",
			kind: "foreignKey",
			value: {
				columns: ["session_id"],
				target: "session_transcript_cold_archives",
				targetColumns: ["session_id"],
				onUpdate: "NO ACTION",
				onDelete: "CASCADE",
				deferrable: false,
				deferred: false
			}
		},
		{
			table: "session_transcript_cold_archive_chunks",
			kind: "indexes",
			value: 2
		},
		{
			table: "session_transcript_cold_archive_chunks",
			kind: "checks",
			value: 7
		},
		{
			table: "session_transcript_cold_archives",
			kind: "table",
			value: null
		},
		{
			table: "session_transcript_cold_archives",
			kind: "column",
			value: {
				name: "session_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 1
			}
		},
		{
			table: "session_transcript_cold_archives",
			kind: "column",
			value: {
				name: "generation",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "session_transcript_cold_archives",
			kind: "column",
			value: {
				name: "archive_name",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 3
			}
		},
		{
			table: "session_transcript_cold_archives",
			kind: "column",
			value: {
				name: "archive_sha256",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 4
			}
		},
		{
			table: "session_transcript_cold_archives",
			kind: "column",
			value: {
				name: "event_count",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 5
			}
		},
		{
			table: "session_transcript_cold_archives",
			kind: "column",
			value: {
				name: "raw_bytes",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 6
			}
		},
		{
			table: "session_transcript_cold_archives",
			kind: "column",
			value: {
				name: "archive_bytes",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 7
			}
		},
		{
			table: "session_transcript_cold_archives",
			kind: "column",
			value: {
				name: "last_seq",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 8
			}
		},
		{
			table: "session_transcript_cold_archives",
			kind: "column",
			value: {
				name: "archived_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 9
			}
		},
		{
			table: "session_transcript_cold_archives",
			kind: "column",
			value: {
				name: "storage",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 10
			}
		},
		{
			table: "session_transcript_cold_archives",
			kind: "column",
			value: {
				name: "archive_blob",
				type: "bytea",
				nullable: true,
				identity: false,
				default: null,
				position: 11
			}
		},
		{
			table: "session_transcript_cold_archives",
			kind: "primaryKey",
			value: ["session_id"]
		},
		{
			table: "session_transcript_cold_archives",
			kind: "unique",
			value: ["archive_name"]
		},
		{
			table: "session_transcript_cold_archives",
			kind: "foreignKey",
			value: {
				columns: ["session_id"],
				target: "session_windows",
				targetColumns: ["session_id"],
				onUpdate: "NO ACTION",
				onDelete: "CASCADE",
				deferrable: false,
				deferred: false
			}
		},
		{
			table: "session_transcript_cold_archives",
			kind: "indexes",
			value: 2
		},
		{
			table: "session_transcript_cold_archives",
			kind: "checks",
			value: 7
		},
		{
			table: "session_transcript_fts_rows",
			kind: "table",
			value: null
		},
		{
			table: "session_transcript_fts_rows",
			kind: "column",
			value: {
				name: "id",
				type: "bigint",
				nullable: false,
				identity: true,
				default: null,
				position: 1
			}
		},
		{
			table: "session_transcript_fts_rows",
			kind: "column",
			value: {
				name: "session_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "session_transcript_fts_rows",
			kind: "column",
			value: {
				name: "message_id",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 3
			}
		},
		{
			table: "session_transcript_fts_rows",
			kind: "primaryKey",
			value: ["id"]
		},
		{
			table: "session_transcript_fts_rows",
			kind: "indexes",
			value: 2
		},
		{
			table: "session_transcript_fts_rows",
			kind: "checks",
			value: 0
		},
		{
			table: "session_transcript_index_state",
			kind: "table",
			value: null
		},
		{
			table: "session_transcript_index_state",
			kind: "column",
			value: {
				name: "session_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 1
			}
		},
		{
			table: "session_transcript_index_state",
			kind: "column",
			value: {
				name: "indexed_seq",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "session_transcript_index_state",
			kind: "column",
			value: {
				name: "leaf_event_id",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 3
			}
		},
		{
			table: "session_transcript_index_state",
			kind: "column",
			value: {
				name: "needs_rebuild",
				type: "bigint",
				nullable: false,
				identity: false,
				default: "0",
				position: 4
			}
		},
		{
			table: "session_transcript_index_state",
			kind: "column",
			value: {
				name: "active_event_count",
				type: "bigint",
				nullable: false,
				identity: false,
				default: "0",
				position: 5
			}
		},
		{
			table: "session_transcript_index_state",
			kind: "column",
			value: {
				name: "active_message_count",
				type: "bigint",
				nullable: false,
				identity: false,
				default: "0",
				position: 6
			}
		},
		{
			table: "session_transcript_index_state",
			kind: "column",
			value: {
				name: "updated_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 7
			}
		},
		{
			table: "session_transcript_index_state",
			kind: "primaryKey",
			value: ["session_id"]
		},
		{
			table: "session_transcript_index_state",
			kind: "foreignKey",
			value: {
				columns: ["session_id"],
				target: "session_windows",
				targetColumns: ["session_id"],
				onUpdate: "NO ACTION",
				onDelete: "CASCADE",
				deferrable: false,
				deferred: false
			}
		},
		{
			table: "session_transcript_index_state",
			kind: "indexes",
			value: 1
		},
		{
			table: "session_transcript_index_state",
			kind: "checks",
			value: 0
		},
		{
			table: "session_windows",
			kind: "table",
			value: null
		},
		{
			table: "session_windows",
			kind: "column",
			value: {
				name: "session_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 1
			}
		},
		{
			table: "session_windows",
			kind: "column",
			value: {
				name: "session_key",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "session_windows",
			kind: "column",
			value: {
				name: "previous_session_id",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 3
			}
		},
		{
			table: "session_windows",
			kind: "column",
			value: {
				name: "reason",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 4
			}
		},
		{
			table: "session_windows",
			kind: "column",
			value: {
				name: "session_scope",
				type: "text",
				nullable: false,
				identity: false,
				default: "'conversation'",
				position: 5
			}
		},
		{
			table: "session_windows",
			kind: "column",
			value: {
				name: "created_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 6
			}
		},
		{
			table: "session_windows",
			kind: "column",
			value: {
				name: "updated_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 7
			}
		},
		{
			table: "session_windows",
			kind: "column",
			value: {
				name: "transcript_updated_at",
				type: "bigint",
				nullable: true,
				identity: false,
				default: null,
				position: 8
			}
		},
		{
			table: "session_windows",
			kind: "column",
			value: {
				name: "row_transcript_json",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 9
			}
		},
		{
			table: "session_windows",
			kind: "column",
			value: {
				name: "row_transcript_updated_at",
				type: "bigint",
				nullable: true,
				identity: false,
				default: null,
				position: 10
			}
		},
		{
			table: "session_windows",
			kind: "column",
			value: {
				name: "transcript_observed_at",
				type: "bigint",
				nullable: true,
				identity: false,
				default: null,
				position: 11
			}
		},
		{
			table: "session_windows",
			kind: "column",
			value: {
				name: "session_entry_provenance",
				type: "bigint",
				nullable: false,
				identity: false,
				default: "0",
				position: 12
			}
		},
		{
			table: "session_windows",
			kind: "column",
			value: {
				name: "acp_owned",
				type: "bigint",
				nullable: false,
				identity: false,
				default: "0",
				position: 13
			}
		},
		{
			table: "session_windows",
			kind: "column",
			value: {
				name: "plugin_owner_id",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 14
			}
		},
		{
			table: "session_windows",
			kind: "column",
			value: {
				name: "hook_external_content_source",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 15
			}
		},
		{
			table: "session_windows",
			kind: "column",
			value: {
				name: "started_at",
				type: "bigint",
				nullable: true,
				identity: false,
				default: null,
				position: 16
			}
		},
		{
			table: "session_windows",
			kind: "column",
			value: {
				name: "ended_at",
				type: "bigint",
				nullable: true,
				identity: false,
				default: null,
				position: 17
			}
		},
		{
			table: "session_windows",
			kind: "column",
			value: {
				name: "status",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 18
			}
		},
		{
			table: "session_windows",
			kind: "column",
			value: {
				name: "chat_type",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 19
			}
		},
		{
			table: "session_windows",
			kind: "column",
			value: {
				name: "channel",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 20
			}
		},
		{
			table: "session_windows",
			kind: "column",
			value: {
				name: "account_id",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 21
			}
		},
		{
			table: "session_windows",
			kind: "column",
			value: {
				name: "primary_conversation_id",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 22
			}
		},
		{
			table: "session_windows",
			kind: "column",
			value: {
				name: "model_provider",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 23
			}
		},
		{
			table: "session_windows",
			kind: "column",
			value: {
				name: "model",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 24
			}
		},
		{
			table: "session_windows",
			kind: "column",
			value: {
				name: "agent_harness_id",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 25
			}
		},
		{
			table: "session_windows",
			kind: "column",
			value: {
				name: "parent_session_key",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 26
			}
		},
		{
			table: "session_windows",
			kind: "column",
			value: {
				name: "spawned_by",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 27
			}
		},
		{
			table: "session_windows",
			kind: "column",
			value: {
				name: "display_name",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 28
			}
		},
		{
			table: "session_windows",
			kind: "primaryKey",
			value: ["session_id"]
		},
		{
			table: "session_windows",
			kind: "foreignKey",
			value: {
				columns: ["primary_conversation_id"],
				target: "conversations",
				targetColumns: ["conversation_id"],
				onUpdate: "NO ACTION",
				onDelete: "SET NULL",
				deferrable: false,
				deferred: false
			}
		},
		{
			table: "session_windows",
			kind: "foreignKey",
			value: {
				columns: ["session_key"],
				target: "session_nodes",
				targetColumns: ["session_key"],
				onUpdate: "NO ACTION",
				onDelete: "CASCADE",
				deferrable: false,
				deferred: false
			}
		},
		{
			table: "session_windows",
			kind: "indexes",
			value: 5
		},
		{
			table: "session_windows",
			kind: "checks",
			value: 7
		},
		{
			table: "standing_intents",
			kind: "table",
			value: null
		},
		{
			table: "standing_intents",
			kind: "column",
			value: {
				name: "intent_key",
				type: "bigint",
				nullable: false,
				identity: true,
				default: null,
				position: 1
			}
		},
		{
			table: "standing_intents",
			kind: "column",
			value: {
				name: "id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "standing_intents",
			kind: "column",
			value: {
				name: "description",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 3
			}
		},
		{
			table: "standing_intents",
			kind: "column",
			value: {
				name: "trigger_keywords",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 4
			}
		},
		{
			table: "standing_intents",
			kind: "column",
			value: {
				name: "trigger_embedding",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 5
			}
		},
		{
			table: "standing_intents",
			kind: "column",
			value: {
				name: "channel_scope",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 6
			}
		},
		{
			table: "standing_intents",
			kind: "column",
			value: {
				name: "sender_scope",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 7
			}
		},
		{
			table: "standing_intents",
			kind: "column",
			value: {
				name: "creator_sender",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 8
			}
		},
		{
			table: "standing_intents",
			kind: "column",
			value: {
				name: "status",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 9
			}
		},
		{
			table: "standing_intents",
			kind: "column",
			value: {
				name: "expires_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 10
			}
		},
		{
			table: "standing_intents",
			kind: "column",
			value: {
				name: "max_fires",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 11
			}
		},
		{
			table: "standing_intents",
			kind: "column",
			value: {
				name: "fire_count",
				type: "bigint",
				nullable: false,
				identity: false,
				default: "0",
				position: 12
			}
		},
		{
			table: "standing_intents",
			kind: "column",
			value: {
				name: "cooldown_seconds",
				type: "bigint",
				nullable: false,
				identity: false,
				default: "86400",
				position: 13
			}
		},
		{
			table: "standing_intents",
			kind: "column",
			value: {
				name: "last_fired_at",
				type: "bigint",
				nullable: true,
				identity: false,
				default: null,
				position: 14
			}
		},
		{
			table: "standing_intents",
			kind: "column",
			value: {
				name: "created_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 15
			}
		},
		{
			table: "standing_intents",
			kind: "column",
			value: {
				name: "source_session_id",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 16
			}
		},
		{
			table: "standing_intents",
			kind: "primaryKey",
			value: ["intent_key"]
		},
		{
			table: "standing_intents",
			kind: "unique",
			value: ["id"]
		},
		{
			table: "standing_intents",
			kind: "indexes",
			value: 4
		},
		{
			table: "standing_intents",
			kind: "checks",
			value: 5
		},
		{
			table: "trajectory_runtime_events",
			kind: "table",
			value: null
		},
		{
			table: "trajectory_runtime_events",
			kind: "column",
			value: {
				name: "session_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 1
			}
		},
		{
			table: "trajectory_runtime_events",
			kind: "column",
			value: {
				name: "seq",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "trajectory_runtime_events",
			kind: "column",
			value: {
				name: "run_id",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 3
			}
		},
		{
			table: "trajectory_runtime_events",
			kind: "column",
			value: {
				name: "event_json",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 4
			}
		},
		{
			table: "trajectory_runtime_events",
			kind: "column",
			value: {
				name: "created_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 5
			}
		},
		{
			table: "trajectory_runtime_events",
			kind: "column",
			value: {
				name: "event_utf8_bytes",
				type: "bigint",
				nullable: true,
				identity: false,
				default: null,
				position: 6
			}
		},
		{
			table: "trajectory_runtime_events",
			kind: "column",
			value: {
				name: "event_payload",
				type: "bytea",
				nullable: true,
				identity: false,
				default: null,
				position: 7
			}
		},
		{
			table: "trajectory_runtime_events",
			kind: "column",
			value: {
				name: "event_codec",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 8
			}
		},
		{
			table: "trajectory_runtime_events",
			kind: "primaryKey",
			value: ["session_id", "seq"]
		},
		{
			table: "trajectory_runtime_events",
			kind: "foreignKey",
			value: {
				columns: ["session_id"],
				target: "session_windows",
				targetColumns: ["session_id"],
				onUpdate: "NO ACTION",
				onDelete: "CASCADE",
				deferrable: false,
				deferred: false
			}
		},
		{
			table: "trajectory_runtime_events",
			kind: "indexes",
			value: 2
		},
		{
			table: "trajectory_runtime_events",
			kind: "checks",
			value: 0
		},
		{
			table: "transcript_event_identities",
			kind: "table",
			value: null
		},
		{
			table: "transcript_event_identities",
			kind: "column",
			value: {
				name: "session_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 1
			}
		},
		{
			table: "transcript_event_identities",
			kind: "column",
			value: {
				name: "event_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "transcript_event_identities",
			kind: "column",
			value: {
				name: "seq",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 3
			}
		},
		{
			table: "transcript_event_identities",
			kind: "column",
			value: {
				name: "event_type",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 4
			}
		},
		{
			table: "transcript_event_identities",
			kind: "column",
			value: {
				name: "parent_id",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 5
			}
		},
		{
			table: "transcript_event_identities",
			kind: "column",
			value: {
				name: "message_idempotency_key",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 6
			}
		},
		{
			table: "transcript_event_identities",
			kind: "column",
			value: {
				name: "created_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 7
			}
		},
		{
			table: "transcript_event_identities",
			kind: "primaryKey",
			value: ["session_id", "event_id"]
		},
		{
			table: "transcript_event_identities",
			kind: "foreignKey",
			value: {
				columns: ["session_id", "seq"],
				target: "transcript_events",
				targetColumns: ["session_id", "seq"],
				onUpdate: "NO ACTION",
				onDelete: "CASCADE",
				deferrable: false,
				deferred: false
			}
		},
		{
			table: "transcript_event_identities",
			kind: "indexes",
			value: 4
		},
		{
			table: "transcript_event_identities",
			kind: "checks",
			value: 0
		},
		{
			table: "transcript_events",
			kind: "table",
			value: null
		},
		{
			table: "transcript_events",
			kind: "column",
			value: {
				name: "session_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 1
			}
		},
		{
			table: "transcript_events",
			kind: "column",
			value: {
				name: "seq",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "transcript_events",
			kind: "column",
			value: {
				name: "event_json",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 3
			}
		},
		{
			table: "transcript_events",
			kind: "column",
			value: {
				name: "created_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 4
			}
		},
		{
			table: "transcript_events",
			kind: "column",
			value: {
				name: "event_zstd",
				type: "bytea",
				nullable: true,
				identity: false,
				default: null,
				position: 5
			}
		},
		{
			table: "transcript_events",
			kind: "column",
			value: {
				name: "event_utf8_bytes",
				type: "bigint",
				nullable: true,
				identity: false,
				default: null,
				position: 6
			}
		},
		{
			table: "transcript_events",
			kind: "column",
			value: {
				name: "navigation_json",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 7
			}
		},
		{
			table: "transcript_events",
			kind: "column",
			value: {
				name: "navigation_type",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 8
			}
		},
		{
			table: "transcript_events",
			kind: "column",
			value: {
				name: "navigation_custom_type",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 9
			}
		},
		{
			table: "transcript_events",
			kind: "column",
			value: {
				name: "navigation_display",
				type: "bigint",
				nullable: false,
				identity: false,
				default: "0",
				position: 10
			}
		},
		{
			table: "transcript_events",
			kind: "column",
			value: {
				name: "message_role",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 11
			}
		},
		{
			table: "transcript_events",
			kind: "column",
			value: {
				name: "navigation_last_type",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 12
			}
		},
		{
			table: "transcript_events",
			kind: "column",
			value: {
				name: "navigation_last_custom_type",
				type: "text",
				nullable: true,
				identity: false,
				default: null,
				position: 13
			}
		},
		{
			table: "transcript_events",
			kind: "column",
			value: {
				name: "navigation_valid",
				type: "bigint",
				nullable: false,
				identity: false,
				default: "1",
				position: 14
			}
		},
		{
			table: "transcript_events",
			kind: "primaryKey",
			value: ["session_id", "seq"]
		},
		{
			table: "transcript_events",
			kind: "foreignKey",
			value: {
				columns: ["session_id"],
				target: "session_windows",
				targetColumns: ["session_id"],
				onUpdate: "NO ACTION",
				onDelete: "CASCADE",
				deferrable: false,
				deferred: false
			}
		},
		{
			table: "transcript_events",
			kind: "indexes",
			value: 1
		},
		{
			table: "transcript_events",
			kind: "checks",
			value: 3
		},
		{
			table: "transcript_rewrite_watermarks",
			kind: "table",
			value: null
		},
		{
			table: "transcript_rewrite_watermarks",
			kind: "column",
			value: {
				name: "session_id",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 1
			}
		},
		{
			table: "transcript_rewrite_watermarks",
			kind: "column",
			value: {
				name: "generation",
				type: "text",
				nullable: false,
				identity: false,
				default: null,
				position: 2
			}
		},
		{
			table: "transcript_rewrite_watermarks",
			kind: "column",
			value: {
				name: "updated_at",
				type: "bigint",
				nullable: false,
				identity: false,
				default: null,
				position: 3
			}
		},
		{
			table: "transcript_rewrite_watermarks",
			kind: "primaryKey",
			value: ["session_id"]
		},
		{
			table: "transcript_rewrite_watermarks",
			kind: "foreignKey",
			value: {
				columns: ["session_id"],
				target: "session_windows",
				targetColumns: ["session_id"],
				onUpdate: "NO ACTION",
				onDelete: "CASCADE",
				deferrable: false,
				deferred: false
			}
		},
		{
			table: "transcript_rewrite_watermarks",
			kind: "indexes",
			value: 1
		},
		{
			table: "transcript_rewrite_watermarks",
			kind: "checks",
			value: 0
		}
	]
};
//#endregion
//#region src/state/postgres-schema.generated/agent-search-runtime.ts
const agentSearchPostgresRuntime = { sql: "-- Generated by pnpm db:postgres:gen. PostgreSQL-only derived transcript content.\n\nCREATE TABLE \"session_transcript_fts\" (\n  \"rowid\" bigint PRIMARY KEY REFERENCES \"session_transcript_fts_rows\" (\"id\") ON DELETE CASCADE,\n  \"text\" text COLLATE \"C\",\n  \"session_id\" text COLLATE \"C\",\n  \"message_id\" text COLLATE \"C\",\n  \"role\" text COLLATE \"C\",\n  \"timestamp\" double precision\n);\n" };
//#endregion
//#region src/state/openclaw-agent-db-engine.ts
function agentEngineInput() {
	return getDatabaseEngineInput("agent");
}
/** Enabled features prepare their definitions; the agent opener retains DDL custody. */
function admitAgentEngineSearchExtensions(e, t, n) {
	if (!isPostgresSqlConnection(e)) return;
	if (arePostgresSearchExtensionsAdmitted(e, t)) {
		for (const n of Object.values(t)) admitStoreSearch(e, n);
		return;
	}
	e.runTransaction(() => {
		n("transaction");
		for (const [n, r] of Object.entries(t)) admitStoreSearch(e, r, { extension: n });
	}, { withCommit: (e) => {
		n("commit");
		e();
	} });
}
const agentPostgresSql = `${agentPostgresRuntime.sql}\n${agentSearchPostgresRuntime.sql}`;
function createAgentPostgresMigrations() {
	const e = withoutAgentPostgresColdArchiveChunks(agentPostgresSql);
	const t = withLegacyAgentPostgresMemoryPaths(e);
	const n = withLegacyPostgresIndexOrdering(t, "schema-nullability");
	const r = withLegacyPostgresIndexOrdering(n);
	const i = withLegacyAgentPostgresMemoryRevisionTriggers(r);
	const a = withLegacyAgentPostgresTrajectoryStorage(i);
	const o = withLegacyAgentPostgresIndexes(a);
	return [
		{
			version: 28,
			fromSchema: { postgres: withLegacyAgentPostgresWriteLayout(o) },
			schema: { postgres: o },
			sql: `${AGENT_WRITE_LAYOUT_POSTGRES_MIGRATION_SQL}
        UPDATE schema_meta
        SET schema_version = ${28},
          app_version = '${VERSION.replaceAll("'", "''")}',
          updated_at = CAST(EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000 AS bigint)
        WHERE meta_key = 'primary';`
		},
		{
			version: 29,
			fromSchema: { postgres: o },
			schema: { postgres: a },
			sql: `${AGENT_INDEX_RETIREMENT_SQL}
        ALTER FUNCTION openclaw_transcript_navigation_check(text)
          STRICT SET search_path = pg_catalog;
        UPDATE schema_meta
        SET schema_version = ${29},
          app_version = '${VERSION.replaceAll("'", "''")}',
          updated_at = CAST(EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000 AS bigint)
        WHERE meta_key = 'primary';`
		},
		{
			version: 30,
			fromSchema: { postgres: a },
			schema: { postgres: i },
			sql: `${AGENT_TRAJECTORY_STORAGE_POSTGRES_MIGRATION_SQL}
        UPDATE schema_meta
        SET schema_version = ${30},
          app_version = '${VERSION.replaceAll("'", "''")}',
          updated_at = CAST(EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000 AS bigint)
        WHERE meta_key = 'primary';`
		},
		{
			version: 31,
			fromSchema: { postgres: i },
			schema: { postgres: r },
			sql: `${AGENT_MEMORY_REVISION_POSTGRES_SQL}
        UPDATE schema_meta
        SET schema_version = ${31},
          app_version = '${VERSION.replaceAll("'", "''")}',
          updated_at = CAST(EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000 AS bigint)
        WHERE meta_key = 'primary';`
		},
		{
			version: 32,
			fromSchema: { postgres: r },
			schema: {
				postgres: r,
				postgresVectorDecoderVersion: 2
			},
			sql: `${AGENT_VECTOR_DECODER_POSTGRES_SQL}
        UPDATE schema_meta
        SET schema_version = ${32},
          app_version = '${VERSION.replaceAll("'", "''")}',
          updated_at = CAST(EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000 AS bigint)
        WHERE meta_key = 'primary';`
		},
		{
			version: 33,
			fromSchema: {
				postgres: r,
				postgresVectorDecoderVersion: 2
			},
			schema: {
				postgres: r,
				postgresVectorDecoderVersion: 2,
				postgresVectorSearchVersion: 2
			},
			sql: `${AGENT_VECTOR_SEARCH_POSTGRES_SQL}
        UPDATE schema_meta
        SET schema_version = ${33},
          app_version = '${VERSION.replaceAll("'", "''")}',
          updated_at = CAST(EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000 AS bigint)
        WHERE meta_key = 'primary';`
		},
		{
			version: 34,
			fromSchema: {
				postgres: r,
				postgresVectorDecoderVersion: 2,
				postgresVectorSearchVersion: 2
			},
			schema: {
				postgres: n,
				postgresVectorDecoderVersion: 2,
				postgresVectorSearchVersion: 2
			},
			sql: `${postgresIndexOrderingMigration(n)}
        UPDATE schema_meta
        SET schema_version = 34,
          app_version = '${VERSION.replaceAll("'", "''")}',
          updated_at = CAST(EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000 AS bigint)
        WHERE meta_key = 'primary';`
		},
		{
			version: 35,
			fromSchema: {
				postgres: n,
				postgresVectorDecoderVersion: 2,
				postgresVectorSearchVersion: 2
			},
			schema: {
				postgres: t,
				postgresVectorDecoderVersion: 2,
				postgresVectorSearchVersion: 2
			},
			sql: `${postgresIndexOrderingMigration(t, "schema-nullability")}
        UPDATE schema_meta
        SET schema_version = 35,
          app_version = '${VERSION.replaceAll("'", "''")}',
          updated_at = CAST(EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000 AS bigint)
        WHERE meta_key = 'primary';`
		},
		{
			version: 36,
			fromSchema: {
				postgres: t,
				postgresVectorDecoderVersion: 2,
				postgresVectorSearchVersion: 2
			},
			schema: {
				postgres: e,
				postgresVectorDecoderVersion: 2,
				postgresVectorSearchVersion: 2
			},
			sql: `${MEMORY_PATH_POSTGRES_INDEX_SQL}
        UPDATE schema_meta
        SET schema_version = 36,
          app_version = '${VERSION.replaceAll("'", "''")}',
          updated_at = CAST(EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000 AS bigint)
        WHERE meta_key = 'primary';`
		},
		{
			version: 37,
			fromSchema: {
				postgres: e,
				postgresVectorDecoderVersion: 2,
				postgresVectorSearchVersion: 2
			},
			schema: {
				postgres: agentPostgresSql,
				postgresVectorDecoderVersion: 2,
				postgresVectorSearchVersion: 2
			},
			sql: `${agentColdArchiveChunksPostgresMigration(agentPostgresSql)}
        UPDATE schema_meta
        SET schema_version = ${37},
          app_version = '${VERSION.replaceAll("'", "''")}',
          updated_at = CAST(EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000 AS bigint)
        WHERE meta_key = 'primary';`
		},
		{
			version: 38,
			fromSchema: {
				postgres: agentPostgresSql,
				postgresVectorDecoderVersion: 2,
				postgresVectorSearchVersion: 2
			},
			schema: {
				postgres: agentPostgresSql,
				postgresVectorDecoderVersion: 2,
				postgresVectorSearchVersion: 2,
				postgresTextSearchVersion: 2
			},
			sql: `${AGENT_TEXT_SEARCH_POSTGRES_SQL}
        UPDATE schema_meta
        SET schema_version = ${38},
          app_version = '${VERSION.replaceAll("'", "''")}',
          updated_at = CAST(EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000 AS bigint)
        WHERE meta_key = 'primary';`
		}
	];
}
const agentEngineSchema = {
	id: "agent",
	version: 38,
	sqlite: "",
	postgres: agentPostgresSql,
	postgresVectorDecoderVersion: 2,
	postgresVectorSearchVersion: 2,
	postgresTextSearchVersion: 2,
	search: agentTranscriptSearchSchema,
	get postgresMigrations() {
		const e = createAgentPostgresMigrations();
		Object.defineProperty(this, "postgresMigrations", {
			value: e,
			enumerable: true,
			configurable: true,
			writable: true
		});
		return e;
	}
};
function admitAgentPostgres(e, t, n, r) {
	if (r) {
		if (t === void 0) throw new Error("Creating an agent database requires an agent owner");
		const n = Date.now();
		e.exec("INSERT INTO session_key_contract (id, main_key, updated_at) VALUES (1, 'main', 0)");
		e.exec("INSERT INTO memory_index_state (id, revision) VALUES (1, 0)");
		e.prepare(`INSERT INTO schema_meta
      (meta_key, role, schema_version, agent_id, app_version, created_at, updated_at)
      VALUES ('primary', 'agent', ?, ?, ?, ?, ?)`).run(38, t, VERSION, n, n);
		publishAgentSchemaMetadata(e, {
			agentId: t,
			role: "agent",
			schemaVersion: 38
		});
	}
	const i = readExistingAgentSchemaMeta(e);
	assertCurrentAgentSchemaMetadata(i, t ?? i?.agentId ?? "", n, agentEngineSchema.version);
	if (getPostgresPhysicalFacts(e)?.version !== agentEngineSchema.version) throw new Error("Agent database has no current PostgreSQL schema admission");
	admitSqliteSchema(e.anchor);
}
/** The existing agent owner retains the anchor and all execution/close custody. */
function openAgentEngineStore(e, t, n, r = false, i, a = false) {
	if (t === void 0 && !r) throw new Error("Creating an agent database requires an agent owner");
	const o = agentEngineInput();
	const inspectSqlite = () => {
		const t = getAdmittedSqliteSchemaFacts(e) ?? captureSqliteSchemaFacts(e);
		return {
			hasEngineAnchor: t.tables.has("openclaw_engine_anchor"),
			hasExistingData: [
				...t.tables,
				...t.views,
				...t.triggers.keys()
			].some((e) => e !== "openclaw_engine_anchor" && !e.startsWith("sqlite_"))
		};
	};
	const s = Boolean(o && inspectSqlite().hasEngineAnchor);
	const open = () => openEngineStore({
		anchor: e,
		schema: agentEngineSchema,
		input: o,
		existingOnly: r || s,
		reusePostgresConnection: a,
		closeOnFailure: i,
		assertMigrationCurrent: assertAgentDatabaseMaintenanceAuthority,
		prepareAnchor: () => {},
		openSqlite: () => {},
		inspectSqlite,
		admitPostgres: (e, r) => admitAgentPostgres(e, t, n, r)
	});
	return o && !r && !s ? runSqliteImmediateTransactionSync(e, open) : open();
}
//#endregion
export { agentSearchPostgresRuntime as a, openAgentEngineStore as i, agentEngineInput as n, agentPostgresRuntime as o, agentEngineSchema as r, withLegacyAgentPostgresMemoryPaths as s, admitAgentEngineSearchExtensions as t };