UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

2 lines • 227 kB
{"tables":[{"name":"acp_parent_stream_events","sql":"CREATE TABLE acp_parent_stream_events ( session_id TEXT NOT NULL, run_id TEXT NOT NULL, seq INTEGER NOT NULL, event_json TEXT NOT NULL, created_at INTEGER NOT NULL, PRIMARY KEY (session_id, run_id, seq), FOREIGN KEY (session_id) REFERENCES \"session_windows\"(session_id) ON DELETE CASCADE ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"session_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"run_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":2,"hidden":0},{"cid":2,"name":"seq","type":"INTEGER","notnull":1,"dflt_value":null,"pk":3,"hidden":0},{"cid":3,"name":"event_json","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"created_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[{"id":0,"seq":0,"table":"session_windows","from":"session_id","to":"session_id","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"}],"indexes":[{"name":"idx_agent_acp_parent_stream_run","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_acp_parent_stream_run ON acp_parent_stream_events(run_id, seq)","terms":[{"seqno":0,"cid":1,"name":"run_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":2,"name":"seq","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_acp_parent_stream_events_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":1,"name":"run_id","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":2,"name":"seq","desc":0,"coll":"BINARY","key":1},{"seqno":3,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"auth_profile_state","sql":"CREATE TABLE auth_profile_state ( state_key TEXT NOT NULL PRIMARY KEY, state_json TEXT NOT NULL, updated_at INTEGER NOT NULL ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"state_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"state_json","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":2,"name":"updated_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[{"name":"sqlite_autoindex_auth_profile_state_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"state_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"auth_profile_store","sql":"CREATE TABLE auth_profile_store ( store_key TEXT NOT NULL PRIMARY KEY, store_json TEXT NOT NULL, updated_at INTEGER NOT NULL ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"store_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"store_json","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":2,"name":"updated_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[{"name":"sqlite_autoindex_auth_profile_store_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"store_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"board_tabs","sql":"CREATE TABLE board_tabs ( session_key TEXT NOT NULL, tab_id TEXT NOT NULL, title TEXT NOT NULL, position INTEGER NOT NULL CHECK (position >= 0), chat_dock TEXT NOT NULL DEFAULT 'right' CHECK (chat_dock IN ('left', 'right', 'bottom', 'hidden')), created_by TEXT NOT NULL CHECK (created_by IN ('user', 'agent')), revision INTEGER NOT NULL CHECK (revision >= 0), PRIMARY KEY (session_key, tab_id), FOREIGN KEY (session_key) REFERENCES session_nodes(session_key) ON DELETE CASCADE ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"session_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"tab_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":2,"hidden":0},{"cid":2,"name":"title","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"position","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"chat_dock","type":"TEXT","notnull":1,"dflt_value":"'right'","pk":0,"hidden":0},{"cid":5,"name":"created_by","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":6,"name":"revision","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[{"id":0,"seq":0,"table":"session_nodes","from":"session_key","to":"session_key","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"}],"indexes":[{"name":"sqlite_autoindex_board_tabs_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":1,"name":"tab_id","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"board_widgets","sql":"CREATE TABLE board_widgets ( session_key TEXT NOT NULL, name TEXT NOT NULL, tab_id TEXT NOT NULL, title TEXT, content_kind TEXT NOT NULL CHECK (content_kind IN ('html', 'mcp-app', 'plugin')), html BLOB, descriptor_json TEXT, sha256 TEXT NOT NULL, view_generation TEXT, revision INTEGER NOT NULL CHECK (revision >= 1), size_w INTEGER NOT NULL CHECK (size_w BETWEEN 1 AND 12), size_h INTEGER NOT NULL CHECK (size_h BETWEEN 1 AND 20), position INTEGER NOT NULL CHECK (position >= 0), manifest TEXT NOT NULL DEFAULT '{}', grant_state TEXT NOT NULL DEFAULT 'none' CHECK (grant_state IN ('none', 'pending', 'granted', 'rejected')), granted_sha TEXT, created_by TEXT NOT NULL CHECK (created_by IN ('user', 'agent')), created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL, PRIMARY KEY (session_key, name), FOREIGN KEY (session_key, tab_id) REFERENCES board_tabs(session_key, tab_id) ON DELETE CASCADE, 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) ) ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"session_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"name","type":"TEXT","notnull":1,"dflt_value":null,"pk":2,"hidden":0},{"cid":2,"name":"tab_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"title","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"content_kind","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"html","type":"BLOB","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":6,"name":"descriptor_json","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":7,"name":"sha256","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":8,"name":"view_generation","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":9,"name":"revision","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":10,"name":"size_w","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":11,"name":"size_h","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":12,"name":"position","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":13,"name":"manifest","type":"TEXT","notnull":1,"dflt_value":"'{}'","pk":0,"hidden":0},{"cid":14,"name":"grant_state","type":"TEXT","notnull":1,"dflt_value":"'none'","pk":0,"hidden":0},{"cid":15,"name":"granted_sha","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":16,"name":"created_by","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":17,"name":"created_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":18,"name":"updated_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[{"id":0,"seq":0,"table":"board_tabs","from":"session_key","to":"session_key","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"},{"id":0,"seq":1,"table":"board_tabs","from":"tab_id","to":"tab_id","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"}],"indexes":[{"name":"idx_agent_board_widgets_tab_position","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_board_widgets_tab_position ON board_widgets(session_key, tab_id, position)","terms":[{"seqno":0,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":2,"name":"tab_id","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":12,"name":"position","desc":0,"coll":"BINARY","key":1},{"seqno":3,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_board_widgets_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":1,"name":"name","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"cache_entries","sql":"CREATE TABLE cache_entries ( scope TEXT NOT NULL, key TEXT NOT NULL, value_json TEXT, blob BLOB, expires_at INTEGER, updated_at INTEGER NOT NULL, PRIMARY KEY (scope, key) ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"scope","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"key","type":"TEXT","notnull":1,"dflt_value":null,"pk":2,"hidden":0},{"cid":2,"name":"value_json","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"blob","type":"BLOB","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"expires_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"updated_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[{"name":"idx_agent_cache_expiry","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_cache_expiry ON cache_entries(scope, expires_at, key) WHERE expires_at IS NOT NULL","terms":[{"seqno":0,"cid":0,"name":"scope","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":4,"name":"expires_at","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":1,"name":"key","desc":0,"coll":"BINARY","key":1},{"seqno":3,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_cache_updated","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_cache_updated ON cache_entries(scope, updated_at DESC, key)","terms":[{"seqno":0,"cid":0,"name":"scope","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":5,"name":"updated_at","desc":1,"coll":"BINARY","key":1},{"seqno":2,"cid":1,"name":"key","desc":0,"coll":"BINARY","key":1},{"seqno":3,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_voice_session_open_scope","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_voice_session_open_scope ON cache_entries(CASE WHEN json_valid(value_json) THEN json_extract(value_json, '$.agentId') END, CASE WHEN json_valid(value_json) THEN json_extract(value_json, '$.sessionKey') END, CASE WHEN json_valid(value_json) THEN json_extract(value_json, '$.origin') END) WHERE scope = 'talk-client-voice-sessions' AND CASE WHEN json_valid(value_json) THEN json_extract(value_json, '$.status') END = 'open'","terms":[{"seqno":0,"cid":-2,"name":null,"desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-2,"name":null,"desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-2,"name":null,"desc":0,"coll":"BINARY","key":1},{"seqno":3,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_voice_session_open_updated","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_voice_session_open_updated ON cache_entries(scope, updated_at) WHERE scope = 'talk-client-voice-sessions' AND CASE WHEN json_valid(value_json) THEN json_extract(value_json, '$.status') END = 'open'","terms":[{"seqno":0,"cid":0,"name":"scope","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":5,"name":"updated_at","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_cache_entries_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"scope","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":1,"name":"key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"context_engine_turn_outbox","sql":"CREATE TABLE context_engine_turn_outbox ( enqueue_sequence INTEGER PRIMARY KEY, advancement_key TEXT NOT NULL UNIQUE, engine_id TEXT NOT NULL, owner_plugin_id TEXT, session_id TEXT NOT NULL, payload_json TEXT NOT NULL, payload_state TEXT, attempt_count INTEGER NOT NULL DEFAULT 0, last_attempt_at INTEGER, last_error TEXT, created_at INTEGER NOT NULL ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"enqueue_sequence","type":"INTEGER","notnull":0,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"advancement_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":2,"name":"engine_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"owner_plugin_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"session_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"payload_json","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":6,"name":"payload_state","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":7,"name":"attempt_count","type":"INTEGER","notnull":1,"dflt_value":"0","pk":0,"hidden":0},{"cid":8,"name":"last_attempt_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":9,"name":"last_error","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":10,"name":"created_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[{"name":"idx_agent_context_engine_turn_outbox_engine","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_context_engine_turn_outbox_engine ON context_engine_turn_outbox(engine_id, created_at)","terms":[{"seqno":0,"cid":2,"name":"engine_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":10,"name":"created_at","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_context_engine_turn_outbox_1","origin":"u","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":1,"name":"advancement_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"conversation_deliveries","sql":"CREATE TABLE conversation_deliveries ( operation_id TEXT NOT NULL PRIMARY KEY, operation_kind TEXT NOT NULL CHECK (operation_kind IN ('send', 'turn')), conversation_id TEXT NOT NULL, source_session_key TEXT, message_hash TEXT NOT NULL, status TEXT NOT NULL CHECK (status IN ('created', 'queued', 'sent', 'suppressed', 'rejected', 'unknown', 'replied')), prepared_message_id TEXT, platform_message_id TEXT, queue_id TEXT, rejection_error TEXT, reply_message_id TEXT, reply_to_id TEXT, reply_thread_id TEXT, reply_text TEXT, reply_timestamp INTEGER, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL, CHECK ( (status = 'rejected' AND rejection_error IS NOT NULL) OR (status != 'rejected' AND rejection_error IS NULL) ), FOREIGN KEY (conversation_id) REFERENCES conversations(conversation_id) ON DELETE CASCADE ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"operation_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"operation_kind","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":2,"name":"conversation_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"source_session_key","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"message_hash","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"status","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":6,"name":"prepared_message_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":7,"name":"platform_message_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":8,"name":"queue_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":9,"name":"rejection_error","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":10,"name":"reply_message_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":11,"name":"reply_to_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":12,"name":"reply_thread_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":13,"name":"reply_text","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":14,"name":"reply_timestamp","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":15,"name":"created_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":16,"name":"updated_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[{"id":0,"seq":0,"table":"conversations","from":"conversation_id","to":"conversation_id","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"}],"indexes":[{"name":"idx_agent_conversation_deliveries_reply","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_conversation_deliveries_reply ON conversation_deliveries(conversation_id, platform_message_id, prepared_message_id) WHERE status IN ('queued', 'sent', 'replied')","terms":[{"seqno":0,"cid":2,"name":"conversation_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":7,"name":"platform_message_id","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":6,"name":"prepared_message_id","desc":0,"coll":"BINARY","key":1},{"seqno":3,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_conversation_deliveries_source_session","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_conversation_deliveries_source_session ON conversation_deliveries(source_session_key, operation_id)","terms":[{"seqno":0,"cid":3,"name":"source_session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"operation_id","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_conversation_deliveries_updated","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_conversation_deliveries_updated ON conversation_deliveries(updated_at DESC, operation_id)","terms":[{"seqno":0,"cid":16,"name":"updated_at","desc":1,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"operation_id","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_conversation_deliveries_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"operation_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"conversations","sql":"CREATE TABLE conversations ( conversation_id TEXT NOT NULL PRIMARY KEY, channel TEXT NOT NULL, account_id TEXT NOT NULL, kind TEXT NOT NULL CHECK (kind IN ('direct', 'group', 'channel')), peer_id TEXT NOT NULL, delivery_target TEXT NOT NULL, parent_conversation_id TEXT, thread_id TEXT, native_channel_id TEXT, native_direct_user_id TEXT, label TEXT, metadata_json TEXT, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"conversation_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"channel","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":2,"name":"account_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"kind","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"peer_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"delivery_target","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":6,"name":"parent_conversation_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":7,"name":"thread_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":8,"name":"native_channel_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":9,"name":"native_direct_user_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":10,"name":"label","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":11,"name":"metadata_json","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":12,"name":"created_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":13,"name":"updated_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[{"name":"idx_agent_conversations_identity","origin":"c","partial":0,"unique":1,"sql":"CREATE UNIQUE INDEX idx_agent_conversations_identity ON conversations( channel, account_id, kind, peer_id, IFNULL(parent_conversation_id, ''), IFNULL(thread_id, '') )","terms":[{"seqno":0,"cid":1,"name":"channel","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":2,"name":"account_id","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":3,"name":"kind","desc":0,"coll":"BINARY","key":1},{"seqno":3,"cid":4,"name":"peer_id","desc":0,"coll":"BINARY","key":1},{"seqno":4,"cid":-2,"name":null,"desc":0,"coll":"BINARY","key":1},{"seqno":5,"cid":-2,"name":null,"desc":0,"coll":"BINARY","key":1},{"seqno":6,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_conversations_lookup","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_conversations_lookup ON conversations(channel, account_id, kind, peer_id, thread_id)","terms":[{"seqno":0,"cid":1,"name":"channel","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":2,"name":"account_id","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":3,"name":"kind","desc":0,"coll":"BINARY","key":1},{"seqno":3,"cid":4,"name":"peer_id","desc":0,"coll":"BINARY","key":1},{"seqno":4,"cid":7,"name":"thread_id","desc":0,"coll":"BINARY","key":1},{"seqno":5,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_conversations_updated","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_conversations_updated ON conversations(updated_at DESC, conversation_id)","terms":[{"seqno":0,"cid":13,"name":"updated_at","desc":1,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"conversation_id","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_conversations_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"conversation_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"heartbeat_outcomes","sql":"CREATE TABLE heartbeat_outcomes ( session_key TEXT NOT NULL PRIMARY KEY, run_session_key TEXT NOT NULL, outcome TEXT NOT NULL CHECK (outcome IN ('progress', 'done', 'blocked', 'needs_attention')), summary TEXT NOT NULL, response_reason TEXT, priority TEXT CHECK (priority IS NULL OR priority IN ('low', 'normal', 'high')), next_check TEXT, task_names_json TEXT, wake_source TEXT, wake_reason TEXT, occurred_at INTEGER NOT NULL, context_run_id TEXT, context_claimed_at INTEGER, updated_at INTEGER NOT NULL, FOREIGN KEY (session_key) REFERENCES session_nodes(session_key) ON DELETE CASCADE ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"session_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"run_session_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":2,"name":"outcome","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"summary","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"response_reason","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"priority","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":6,"name":"next_check","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":7,"name":"task_names_json","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":8,"name":"wake_source","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":9,"name":"wake_reason","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":10,"name":"occurred_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":11,"name":"context_run_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":12,"name":"context_claimed_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":13,"name":"updated_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[{"id":0,"seq":0,"table":"session_nodes","from":"session_key","to":"session_key","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"}],"indexes":[{"name":"sqlite_autoindex_heartbeat_outcomes_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"memory_embedding_cache","sql":"CREATE TABLE memory_embedding_cache ( provider TEXT NOT NULL, model TEXT NOT NULL, provider_key TEXT NOT NULL, hash TEXT NOT NULL, embedding BLOB NOT NULL, dims INTEGER, updated_at INTEGER NOT NULL, PRIMARY KEY (provider, model, provider_key, hash) ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"provider","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"model","type":"TEXT","notnull":1,"dflt_value":null,"pk":2,"hidden":0},{"cid":2,"name":"provider_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":3,"hidden":0},{"cid":3,"name":"hash","type":"TEXT","notnull":1,"dflt_value":null,"pk":4,"hidden":0},{"cid":4,"name":"embedding","type":"BLOB","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"dims","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":6,"name":"updated_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[{"name":"idx_memory_embedding_cache_updated_at","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_memory_embedding_cache_updated_at ON memory_embedding_cache(updated_at)","terms":[{"seqno":0,"cid":6,"name":"updated_at","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_memory_embedding_cache_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"provider","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":1,"name":"model","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":2,"name":"provider_key","desc":0,"coll":"BINARY","key":1},{"seqno":3,"cid":3,"name":"hash","desc":0,"coll":"BINARY","key":1},{"seqno":4,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"memory_entry_origins","sql":"CREATE TABLE memory_entry_origins ( entry_key TEXT NOT NULL, agent_id TEXT NOT NULL, session_id TEXT NOT NULL, session_key TEXT, origin_class TEXT NOT NULL CHECK (origin_class IN ('owner', 'agent', 'untrusted', 'system')), observed_at INTEGER NOT NULL, PRIMARY KEY (entry_key, agent_id, session_id) ) STRICT, WITHOUT ROWID","strict":1,"withoutRowid":1,"columns":[{"cid":0,"name":"entry_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"agent_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":2,"hidden":0},{"cid":2,"name":"session_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":3,"hidden":0},{"cid":3,"name":"session_key","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"origin_class","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"observed_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[{"name":"sqlite_autoindex_memory_entry_origins_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"entry_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":1,"name":"agent_id","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":2,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":3,"cid":3,"name":"session_key","desc":0,"coll":"BINARY","key":0},{"seqno":4,"cid":4,"name":"origin_class","desc":0,"coll":"BINARY","key":0},{"seqno":5,"cid":5,"name":"observed_at","desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"memory_index_chunk_provenance","sql":"CREATE TABLE memory_index_chunk_provenance ( chunk_id TEXT PRIMARY KEY, origin_class TEXT NOT NULL CHECK (origin_class IN ('owner', 'agent', 'untrusted', 'system')), session_kind TEXT NOT NULL CHECK (session_kind IN ('interactive', 'cron', 'heartbeat', 'subagent', 'unknown')), observed_at INTEGER NOT NULL, supersedes_key TEXT, FOREIGN KEY (chunk_id) REFERENCES memory_index_chunks(id) ON DELETE CASCADE ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"chunk_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"origin_class","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":2,"name":"session_kind","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"observed_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"supersedes_key","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[{"id":0,"seq":0,"table":"memory_index_chunks","from":"chunk_id","to":"id","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"}],"indexes":[{"name":"sqlite_autoindex_memory_index_chunk_provenance_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"chunk_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"memory_index_chunk_recall_metadata","sql":"CREATE TABLE memory_index_chunk_recall_metadata ( chunk_id TEXT PRIMARY KEY, importance INTEGER CHECK (importance IS NULL OR importance BETWEEN 1 AND 10), triggers TEXT, project_key TEXT, FOREIGN KEY (chunk_id) REFERENCES memory_index_chunks(id) ON DELETE CASCADE ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"chunk_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"importance","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":2,"name":"triggers","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"project_key","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[{"id":0,"seq":0,"table":"memory_index_chunks","from":"chunk_id","to":"id","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"}],"indexes":[{"name":"sqlite_autoindex_memory_index_chunk_recall_metadata_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"chunk_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"memory_index_chunks","sql":"CREATE TABLE memory_index_chunks ( chunk_rowid INTEGER PRIMARY KEY, id TEXT NOT NULL UNIQUE, path TEXT NOT NULL, source TEXT NOT NULL DEFAULT 'memory', start_line INTEGER NOT NULL, end_line INTEGER NOT NULL, hash TEXT NOT NULL, model TEXT NOT NULL, text TEXT NOT NULL, embedding BLOB NOT NULL, updated_at INTEGER NOT NULL ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"chunk_rowid","type":"INTEGER","notnull":0,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"id","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":2,"name":"path","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"source","type":"TEXT","notnull":1,"dflt_value":"'memory'","pk":0,"hidden":0},{"cid":4,"name":"start_line","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"end_line","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":6,"name":"hash","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":7,"name":"model","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":8,"name":"text","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":9,"name":"embedding","type":"BLOB","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":10,"name":"updated_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[{"name":"idx_memory_index_chunks_path_source","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_memory_index_chunks_path_source ON memory_index_chunks(path, source)","terms":[{"seqno":0,"cid":2,"name":"path","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":3,"name":"source","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_memory_index_chunks_source","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_memory_index_chunks_source ON memory_index_chunks(source)","terms":[{"seqno":0,"cid":3,"name":"source","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_memory_index_chunks_1","origin":"u","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":1,"name":"id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"memory_index_meta","sql":"CREATE TABLE memory_index_meta ( key TEXT PRIMARY KEY, value TEXT NOT NULL ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"key","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"value","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[{"name":"sqlite_autoindex_memory_index_meta_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"memory_index_sources","sql":"CREATE TABLE memory_index_sources ( id INTEGER PRIMARY KEY, path TEXT NOT NULL, source TEXT NOT NULL DEFAULT 'memory', hash TEXT NOT NULL, mtime REAL NOT NULL, size INTEGER NOT NULL, UNIQUE (path, source) ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"id","type":"INTEGER","notnull":0,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"path","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":2,"name":"source","type":"TEXT","notnull":1,"dflt_value":"'memory'","pk":0,"hidden":0},{"cid":3,"name":"hash","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"mtime","type":"REAL","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"size","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[{"name":"idx_memory_index_sources_source","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_memory_index_sources_source ON memory_index_sources(source)","terms":[{"seqno":0,"cid":2,"name":"source","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_memory_index_sources_1","origin":"u","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":1,"name":"path","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":2,"name":"source","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"memory_index_state","sql":"CREATE TABLE memory_index_state ( id INTEGER PRIMARY KEY CHECK (id = 1), revision INTEGER NOT NULL ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"id","type":"INTEGER","notnull":0,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"revision","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[],"triggers":[]},{"name":"memory_session_tombstones","sql":"CREATE TABLE memory_session_tombstones ( session_id TEXT NOT NULL PRIMARY KEY, agent_id TEXT NOT NULL, reason TEXT NOT NULL, created_at INTEGER NOT NULL ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"session_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"agent_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":2,"name":"reason","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"created_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[{"name":"sqlite_autoindex_memory_session_tombstones_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"message_tool_run_outcomes","sql":"CREATE TABLE message_tool_run_outcomes ( id INTEGER PRIMARY KEY, run_id TEXT NOT NULL, session_key TEXT NOT NULL, agent_id TEXT NOT NULL, provider TEXT NOT NULL, model TEXT NOT NULL, outcome TEXT NOT NULL CHECK (outcome IN ('tool_delivered', 'mute')), run_status TEXT NOT NULL CHECK (run_status IN ('completed', 'errored', 'aborted')), occurred_at INTEGER NOT NULL ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"id","type":"INTEGER","notnull":0,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"run_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":2,"name":"session_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"agent_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"provider","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"model","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":6,"name":"outcome","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":7,"name":"run_status","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":8,"name":"occurred_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[{"name":"idx_agent_message_tool_run_outcomes_occurred","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_message_tool_run_outcomes_occurred ON message_tool_run_outcomes(occurred_at DESC, id DESC)","terms":[{"seqno":0,"cid":8,"name":"occurred_at","desc":1,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"id","desc":1,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"schema_meta","sql":"CREATE TABLE schema_meta ( meta_key TEXT NOT NULL PRIMARY KEY, role TEXT NOT NULL, schema_version INTEGER NOT NULL, agent_id TEXT, app_version TEXT, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"meta_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"role","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":2,"name":"schema_version","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"agent_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"app_version","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"created_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":6,"name":"updated_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[{"name":"sqlite_autoindex_schema_meta_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"meta_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"session_canonical_validation_pending","sql":"CREATE TABLE session_canonical_validation_pending ( session_key TEXT NOT NULL PRIMARY KEY ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"session_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0}],"foreignKeys":[],"indexes":[{"name":"sqlite_autoindex_session_canonical_validation_pending_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"session_conversations","sql":"CREATE TABLE session_conversations ( session_id TEXT NOT NULL, conversation_id TEXT NOT NULL, role TEXT NOT NULL DEFAULT 'primary' CHECK (role IN ('primary', 'participant', 'related')), route_context_json TEXT, first_seen_at INTEGER NOT NULL, last_seen_at INTEGER NOT NULL, PRIMARY KEY (session_id, conversation_id, role), FOREIGN KEY (session_id) REFERENCES \"session_windows\"(session_id) ON DELETE CASCADE, FOREIGN KEY (conversation_id) REFERENCES conversations(conversation_id) ON DELETE CASCADE ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"session_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"conversation_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":2,"hidden":0},{"cid":2,"name":"role","type":"TEXT","notnull":1,"dflt_value":"'primary'","pk":3,"hidden":0},{"cid":3,"name":"route_context_json","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"first_seen_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"last_seen_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[{"id":0,"seq":0,"table":"conversations","from":"conversation_id","to":"conversation_id","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"},{"id":1,"seq":0,"table":"session_windows","from":"session_id","to":"session_id","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"}],"indexes":[{"name":"idx_agent_session_conversations_conversation","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_conversations_conversation ON session_conversations(conversation_id, last_seen_at DESC, session_id)","terms":[{"seqno":0,"cid":1,"name":"conversation_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":5,"name":"last_seen_at","desc":1,"coll":"BINARY","key":1},{"seqno":2,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":3,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_conversations_primary","origin":"c","partial":1,"unique":1,"sql":"CREATE UNIQUE INDEX idx_agent_session_conversations_primary ON session_conversations(session_id) WHERE role = 'primary'","terms":[{"seqno":0,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_session_conversations_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":1,"name":"conversation_id","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":2,"name":"role","desc":0,"coll":"BINARY","key":1},{"seqno":3,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[{"name":"session_conversations_route_context_invalidate_after_update","sql":"CREATE TRIGGER session_conversations_route_context_invalidate_after_update AFTER UPDATE OF role, last_seen_at ON session_conversations WHEN NEW.route_context_json IS OLD.route_context_json BEGIN UPDATE session_conversations SET route_context_json = NULL WHERE session_id = NEW.session_id AND conversation_id = NEW.conversation_id AND role = NEW.role; END"}]},{"name":"session_entry_snapshots","sql":"CREATE TABLE session_entry_snapshots ( session_key TEXT NOT NULL, field TEXT NOT NULL CHECK (field IN ('sessionDiffBaseline', 'skillsSnapshot', 'systemPromptReport')), value_json TEXT NOT NULL, PRIMARY KEY (session_key, field), FOREIGN KEY (session_key) REFERENCES session_nodes(session_key) ON DELETE CASCADE ) STRICT, WITHOUT ROWID","strict":1,"withoutRowid":1,"columns":[{"cid":0,"name":"session_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"field","type":"TEXT","notnull":1,"dflt_value":null,"pk":2,"hidden":0},{"cid":2,"name":"value_json","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[{"id":0,"seq":0,"table":"session_nodes","from":"session_key","to":"session_key","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"}],"indexes":[{"name":"sqlite_autoindex_session_entry_snapshots_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":1,"name":"field","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":2,"name":"value_json","desc":0,"coll":"BINARY","key":0}]}],"triggers":[{"name":"session_entry_snapshots_after_delete","sql":"CREATE TRIGGER session_entry_snapshots_after_delete AFTER DELETE ON session_entry_snapshots BEGIN UPDATE session_nodes SET snapshot_revision = snapshot_revision + 1 WHERE session_key = OLD.session_key; END"},{"name":"session_entry_snapshots_after_insert","sql":"CREATE TRIGGER session_entry_snapshots_after_insert AFTER INSERT ON session_entry_snapshots BEGIN UPDATE session_nodes SET snapshot_revision = snapshot_revision + 1 WHERE session_key = NEW.session_key; END"},{"name":"session_entry_snapshots_after_update","sql":"CREATE TRIGGER session_entry_snapshots_after_update AFTER UPDATE OF session_key, field, value_json ON session_entry_snapshots WHEN NEW.session_key IS NOT OLD.session_key OR NEW.field IS NOT OLD.field OR NEW.value_json IS NOT OLD.value_json BEGIN UPDATE session_nodes SET snapshot_revision = snapshot_revision + 1 WHERE session_key IN (OLD.session_key, NEW.session_key); END"}]},{"name":"session_goal_operations","sql":"CREATE TABLE session_goal_operations ( session_key TEXT NOT NULL, operation_id TEXT NOT NULL, session_id TEXT NOT NULL, request_fingerprint TEXT NOT NULL, result_json TEXT NOT NULL, expires_at INTEGER NOT NULL, PRIMARY KEY (session_key, operation_id) ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"session_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"operation_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":2,"hidden":0},{"cid":2,"name":"session_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"request_fingerprint","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"result_json","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"expires_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[{"name":"idx_agent_session_goal_operations_expiry","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_goal_operations_expiry ON session_goal_operations(expires_at)","terms":[{"seqno":0,"cid":5,"name":"expires_at","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_session_goal_operations_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":1,"name":"operation_id","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"session_input_completions","sql":"CREATE TABLE session_input_completions ( session_key TEXT NOT NULL, session_id TEXT NOT NULL, idempotency_key TEXT NOT NULL, run_id TEXT NOT NULL, request_hash TEXT NOT NULL, outcome_json TEXT NOT NULL, succeeded INTEGER NOT NULL CHECK (succeeded IN (0, 1)), completed_at INTEGER NOT NULL, PRIMARY KEY (session_id, idempotency_key), FOREIGN KEY (session_key) REFERENCES session_nodes(session_key) ON DELETE CASCADE, FOREIGN KEY (session_id) REFERENCES session_windows(session_id) ON DELETE CASCADE ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"session_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":1,"name":"session_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":2,"name":"idempotency_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":2,"hidden":0},{"cid":3,"name":"run_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"request_hash","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"outcome_json","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":6,"name":"succeeded","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":7,"name":"completed_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[{"id":0,"seq":0,"table":"session_windows","from":"session_id","to":"session_id","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"},{"id":1,"seq":0,"table":"session_nodes","from":"session_key","to":"session_key","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"}],"indexes":[{"name":"idx_agent_session_input_completions_session_key","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_input_completions_session_key ON session_input_completions(session_key)","terms":[{"seqno":0,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_session_input_completions_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":1,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":2,"name":"idempotency_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"session_key_contract","sql":"CREATE TABLE session_key_contract ( id INTEGER NOT NULL PRIMARY KEY CHECK (id = 1), main_key TEXT NOT NULL, canonical_ready TEXT, updated_at INTEGER NOT NULL ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"id","type":"INTEGER","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"main_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":2,"name":"canonical_ready","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"updated_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[],"triggers":[]},{"name":"session_members","sql":"CREATE TABLE session_members ( session_key TEXT NOT NULL, identity_id TEXT NOT NULL, added_by TEXT NOT NULL, added_at INTEGER NOT NULL, PRIMARY KEY (session_key, identity_id), FOREIGN KEY (session_key) REFERENCES session_nodes(session_key) ON DELETE CASCADE ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"session_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"identity_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":2,"hidden":0},{"cid":2,"name":"added_by","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"added_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[{"id":0,"seq":0,"table":"session_nodes","from":"session_key","to":"session_key","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"}],"indexes":[{"name":"idx_agent_session_members_identity","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_members_identity ON session_members(identity_id, session_key)","terms":[{"seqno":0,"cid":1,"name":"identity_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_session_members_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":1,"name":"identity_id","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"session_nodes","sql":"CREATE TABLE session_nodes ( session_key TEXT NOT NULL PRIMARY KEY, current_session_id TEXT NOT NULL, entry_json TEXT NOT NULL, session_started_at INTEGER, has_optional_references INTEGER NOT NULL DEFAULT 0, snapshot_revision INTEGER NOT NULL DEFAULT 0, legacy_acp_migration_json TEXT, entry_valid INTEGER NOT NULL DEFAULT 0 CHECK (entry_valid IN (-1, 0, 1)), updated_at INTEGER NOT NULL, status TEXT CHECK (status IS NULL OR status IN ('running', 'done', 'failed', 'killed', 'timeout')), created_at INTEGER, created_via TEXT CHECK (created_via IS NULL OR created_via IN ('operator', 'spawn', 'channel', 'cron', 'talk', 'run', 'plugin', 'internal')), created_actor_type TEXT CHECK (created_actor_type IS NULL OR created_actor_type IN ('human', 'agent', 'system')), created_actor_id TEXT, owner_actor_type TEXT, owner_actor_id TEXT, owner_assigned_by_type TEXT, owner_assigned_by_id TEXT, owner_assigned_at INTEGER, project_id TEXT, parent_session_key TEXT, spawned_by TEXT, fork_source_session_key TEXT, fork_source_session_id TEXT, fork_source_entry_id TEXT, label TEXT, display_name TEXT, category TEXT, icon TEXT, pinned_at INTEGER, archived_at INTEGER, last_read_at INTEGER, last_interaction_at INTEGER, last_activity_at INTEGER ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"session_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"current_session_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":2,"name":"entry_json","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"session_started_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"has_optional_references","type":"INTEGER","notnull":1,"dflt_value":"0","pk":0,"hidden":0},{"cid":5,"name":"snapshot_revision","type":"INTEGER","notnull":1,"dflt_value":"0","pk":0,"hidden":0},{"cid":6,"name":"legacy_acp_migration_json","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":7,"name":"entry_valid","type":"INTEGER","notnull":1,"dflt_value":"0","pk":0,"hidden":0},{"cid":8,"name":"updated_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":9,"name":"status","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":10,"name":"created_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":11,"name":"created_via","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":12,"name":"created_actor_type","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":13,"name":"created_actor_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":14,"name":"owner_actor_type","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":15,"name":"owner_actor_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":16,"name":"owner_assigned_by_type","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":17,"name":"owner_assigned_by_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":18,"name":"owner_assigned_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":19,"name":"project_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":20,"name":"parent_session_key","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":21,"name":"spawned_by","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":22,"name":"fork_source_session_key","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":23,"name":"fork_source_session_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":24,"name":"fork_source_entry_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":25,"name":"label","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":26,"name":"display_name","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":27,"name":"category","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":28,"name":"icon","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":29,"name":"pinned_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":30,"name":"archived_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":31,"name":"last_read_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":32,"name":"last_interaction_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":33,"name":"last_activity_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[{"name":"idx_agent_session_nodes_active","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_active ON session_nodes(session_key) WHERE archived_at IS NULL","terms":[{"seqno":0,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_archived_at","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_archived_at ON session_nodes(archived_at, session_key) WHERE archived_at IS NOT NULL","terms":[{"seqno":0,"cid":30,"name":"archived_at","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_current_session_id","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_current_session_id ON session_nodes(current_session_id)","terms":[{"seqno":0,"cid":1,"name":"current_session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_entry_not_valid","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_entry_not_valid ON session_nodes(session_key) WHERE entry_valid != 1","terms":[{"seqno":0,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_entry_valid_pending","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_entry_valid_pending ON session_nodes(session_key) WHERE entry_valid = 0","terms":[{"seqno":0,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_label","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_label ON session_nodes(label, session_key) WHERE label IS NOT NULL","terms":[{"seqno":0,"cid":25,"name":"label","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_parent_session_key","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_parent_session_key ON session_nodes(parent_session_key, session_key)","terms":[{"seqno":0,"cid":20,"name":"parent_session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_spawned_by","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_spawned_by ON session_nodes(spawned_by, session_key)","terms":[{"seqno":0,"cid":21,"name":"spawned_by","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_status","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_status ON session_nodes(status, session_key) WHERE status IS NOT NULL","terms":[{"seqno":0,"cid":9,"name":"status","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_updated_at","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_updated_at ON session_nodes(updated_at DESC, session_key)","terms":[{"seqno":0,"cid":8,"name":"updated_at","desc":1,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_session_nodes_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"session_participants","sql":"CREATE TABLE session_participants ( session_key TEXT NOT NULL, identity_namespace TEXT NOT NULL, actor_id TEXT NOT NULL, contribution_count INTEGER NOT NULL, first_prompted_at INTEGER, last_prompted_at INTEGER, PRIMARY KEY (session_key, identity_namespace, actor_id), FOREIGN KEY (session_key) REFERENCES session_nodes(session_key) ON DELETE CASCADE ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"session_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"identity_namespace","type":"TEXT","notnull":1,"dflt_value":null,"pk":2,"hidden":0},{"cid":2,"name":"actor_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":3,"hidden":0},{"cid":3,"name":"contribution_count","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"first_prompted_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"last_prompted_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[{"id":0,"seq":0,"table":"session_nodes","from":"session_key","to":"session_key","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"}],"indexes":[{"name":"sqlite_autoindex_session_participants_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":1,"name":"identity_namespace","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":2,"name":"actor_id","desc":0,"coll":"BINARY","key":1},{"seqno":3,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"session_pending_inputs","sql":"CREATE TABLE session_pending_inputs ( seq INTEGER PRIMARY KEY AUTOINCREMENT, input_id TEXT NOT NULL UNIQUE, session_key TEXT NOT NULL, session_id TEXT NOT NULL, idempotency_key TEXT NOT NULL, run_id TEXT NOT NULL, request_hash TEXT NOT NULL, message_json TEXT NOT NULL, lifecycle_generation TEXT NOT NULL, state TEXT NOT NULL CHECK (state IN ('queued', 'interrupted', 'cancelled')), accepted_at INTEGER NOT NULL, consumed_event_id TEXT, UNIQUE (session_id, idempotency_key), FOREIGN KEY (session_key) REFERENCES session_nodes(session_key) ON DELETE CASCADE, FOREIGN KEY (session_id) REFERENCES session_windows(session_id) ON DELETE CASCADE ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"seq","type":"INTEGER","notnull":0,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"input_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":2,"name":"session_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"session_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"idempotency_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"run_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":6,"name":"request_hash","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":7,"name":"message_json","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":8,"name":"lifecycle_generation","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":9,"name":"state","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":10,"name":"accepted_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":11,"name":"consumed_event_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[{"id":0,"seq":0,"table":"session_windows","from":"session_id","to":"session_id","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"},{"id":1,"seq":0,"table":"session_nodes","from":"session_key","to":"session_key","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"}],"indexes":[{"name":"idx_agent_session_pending_inputs_session","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_pending_inputs_session ON session_pending_inputs(session_key, session_id, seq DESC)","terms":[{"seqno":0,"cid":2,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":3,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":0,"name":"seq","desc":1,"coll":"BINARY","key":1},{"seqno":3,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_session_pending_inputs_1","origin":"u","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":1,"name":"input_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_session_pending_inputs_2","origin":"u","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":3,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":4,"name":"idempotency_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"session_progress_cards","sql":"CREATE TABLE session_progress_cards ( session_key TEXT NOT NULL PRIMARY KEY, markdown TEXT, steps_json TEXT, revision INTEGER NOT NULL, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL, FOREIGN KEY (session_key) REFERENCES session_nodes(session_key) ON DELETE CASCADE ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"session_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"markdown","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":2,"name":"steps_json","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"revision","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"created_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"updated_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[{"id":0,"seq":0,"table":"session_nodes","from":"session_key","to":"session_key","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"}],"indexes":[{"name":"sqlite_autoindex_session_progress_cards_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"session_reactions","sql":"CREATE TABLE session_reactions ( session_key TEXT NOT NULL, session_id TEXT NOT NULL, message_id TEXT NOT NULL, emoji TEXT NOT NULL, identity_id TEXT NOT NULL, identity_label TEXT, created_at INTEGER NOT NULL, PRIMARY KEY (session_key, session_id, message_id, emoji, identity_id), FOREIGN KEY (session_key) REFERENCES session_nodes(session_key) ON DELETE CASCADE ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"session_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"session_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":2,"hidden":0},{"cid":2,"name":"message_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":3,"hidden":0},{"cid":3,"name":"emoji","type":"TEXT","notnull":1,"dflt_value":null,"pk":4,"hidden":0},{"cid":4,"name":"identity_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":5,"hidden":0},{"cid":5,"name":"identity_label","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":6,"name":"created_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[{"id":0,"seq":0,"table":"session_nodes","from":"session_key","to":"session_key","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"}],"indexes":[{"name":"sqlite_autoindex_session_reactions_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":1,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":2,"name":"message_id","desc":0,"coll":"BINARY","key":1},{"seqno":3,"cid":3,"name":"emoji","desc":0,"coll":"BINARY","key":1},{"seqno":4,"cid":4,"name":"identity_id","desc":0,"coll":"BINARY","key":1},{"seqno":5,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"session_suggestions","sql":"CREATE TABLE session_suggestions ( id TEXT PRIMARY KEY, session_key TEXT NOT NULL, author_id TEXT NOT NULL, author_label TEXT, text TEXT NOT NULL, created_at INTEGER NOT NULL, state TEXT NOT NULL CHECK (state IN ('pending', 'accepted', 'dismissed')), dispatch_token TEXT, dispatch_started_at INTEGER, dispatch_resolution TEXT CHECK (dispatch_resolution IN ('send', 'queue', 'edit', 'dismiss')), 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) ), FOREIGN KEY (session_key) REFERENCES session_nodes(session_key) ON DELETE CASCADE ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"id","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"session_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":2,"name":"author_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"author_label","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"text","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"created_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":6,"name":"state","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":7,"name":"dispatch_token","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":8,"name":"dispatch_started_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":9,"name":"dispatch_resolution","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[{"id":0,"seq":0,"table":"session_nodes","from":"session_key","to":"session_key","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"}],"indexes":[{"name":"idx_agent_session_suggestions_author_created","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_suggestions_author_created ON session_suggestions(author_id, created_at, id)","terms":[{"seqno":0,"cid":2,"name":"author_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":5,"name":"created_at","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":0,"name":"id","desc":0,"coll":"BINARY","key":1},{"seqno":3,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_suggestions_session_state_created","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_suggestions_session_state_created ON session_suggestions(session_key, state, created_at, id)","terms":[{"seqno":0,"cid":1,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":6,"name":"state","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":5,"name":"created_at","desc":0,"coll":"BINARY","key":1},{"seqno":3,"cid":0,"name":"id","desc":0,"coll":"BINARY","key":1},{"seqno":4,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_session_suggestions_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"session_transcript_active_events","sql":"CREATE TABLE session_transcript_active_events ( session_id TEXT NOT NULL, active_position INTEGER NOT NULL CHECK (active_position >= 0), event_seq INTEGER NOT NULL, message_position INTEGER CHECK (message_position IS NULL OR message_position >= 0), context_eligible INTEGER, PRIMARY KEY (session_id, active_position), FOREIGN KEY (session_id, event_seq) REFERENCES transcript_events(session_id, seq) ON DELETE CASCADE ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"session_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"active_position","type":"INTEGER","notnull":1,"dflt_value":null,"pk":2,"hidden":0},{"cid":2,"name":"event_seq","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"message_position","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"context_eligible","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[{"id":0,"seq":0,"table":"transcript_events","from":"session_id","to":"session_id","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"},{"id":0,"seq":1,"table":"transcript_events","from":"event_seq","to":"seq","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"}],"indexes":[{"name":"idx_agent_transcript_active_event_seq","origin":"c","partial":0,"unique":1,"sql":"CREATE UNIQUE INDEX idx_agent_transcript_active_event_seq ON session_transcript_active_events(session_id, event_seq)","terms":[{"seqno":0,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":2,"name":"event_seq","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_transcript_active_messages","origin":"c","partial":1,"unique":1,"sql":"CREATE UNIQUE INDEX idx_agent_transcript_active_messages ON session_transcript_active_events(session_id, message_position) WHERE message_position IS NOT NULL","terms":[{"seqno":0,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":3,"name":"message_position","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_transcript_context_pending","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_transcript_context_pending ON session_transcript_active_events(session_id) WHERE context_eligible IS NULL","terms":[{"seqno":0,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_session_transcript_active_events_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":1,"name":"active_position","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"session_transcript_archives","sql":"CREATE TABLE session_transcript_archives ( session_id TEXT NOT NULL, generation TEXT NOT NULL, session_key TEXT NOT NULL, reason TEXT NOT NULL CHECK (reason IN ('deleted', 'reset')), encoding TEXT NOT NULL CHECK (encoding IN ('identity', 'zstd')), archive_blob BLOB NOT NULL, archive_sha256 TEXT NOT NULL CHECK (length(archive_sha256) = 64), archive_name TEXT NOT NULL UNIQUE, created_at INTEGER NOT NULL, published_at INTEGER, publish_attempts INTEGER NOT NULL DEFAULT 0 CHECK (publish_attempts >= 0), last_publish_attempt_at INTEGER, last_publish_error TEXT, PRIMARY KEY (session_id, generation), CHECK (archive_name NOT LIKE '%/%' AND archive_name NOT LIKE '%\\%') ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"session_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"generation","type":"TEXT","notnull":1,"dflt_value":null,"pk":2,"hidden":0},{"cid":2,"name":"session_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"reason","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"encoding","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"archive_blob","type":"BLOB","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":6,"name":"archive_sha256","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":7,"name":"archive_name","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":8,"name":"created_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":9,"name":"published_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":10,"name":"publish_attempts","type":"INTEGER","notnull":1,"dflt_value":"0","pk":0,"hidden":0},{"cid":11,"name":"last_publish_attempt_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":12,"name":"last_publish_error","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[{"name":"idx_agent_session_transcript_archives_pending","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_session_transcript_archives_pending ON session_transcript_archives(created_at, session_id, generation) WHERE published_at IS NULL","terms":[{"seqno":0,"cid":8,"name":"created_at","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":1,"name":"generation","desc":0,"coll":"BINARY","key":1},{"seqno":3,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_transcript_archives_retention","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_transcript_archives_retention ON session_transcript_archives(created_at, session_id, generation)","terms":[{"seqno":0,"cid":8,"name":"created_at","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":1,"name":"generation","desc":0,"coll":"BINARY","key":1},{"seqno":3,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_session_transcript_archives_1","origin":"u","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":7,"name":"archive_name","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_session_transcript_archives_2","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":1,"name":"generation","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"session_transcript_cold_archive_chunks","sql":"CREATE TABLE session_transcript_cold_archive_chunks ( session_id TEXT NOT NULL, chunk_index INTEGER NOT NULL CHECK (chunk_index >= 0), archive_name TEXT NOT NULL UNIQUE, archive_sha256 TEXT NOT NULL CHECK (length(archive_sha256) = 64), first_seq INTEGER NOT NULL, last_seq INTEGER NOT NULL CHECK (last_seq >= first_seq), event_count INTEGER NOT NULL CHECK (event_count >= 1), raw_bytes INTEGER NOT NULL CHECK (raw_bytes >= 0), archive_bytes INTEGER NOT NULL CHECK (archive_bytes >= 0), archive_blob BLOB, PRIMARY KEY (session_id, chunk_index), FOREIGN KEY (session_id) REFERENCES session_transcript_cold_archives(session_id) ON DELETE CASCADE, CHECK (length(archive_name) > 0 AND archive_name NOT IN ('.', '..') AND archive_name NOT LIKE '%/%' AND archive_name NOT LIKE '%\\%') ) STRICT, WITHOUT ROWID","strict":1,"withoutRowid":1,"columns":[{"cid":0,"name":"session_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"chunk_index","type":"INTEGER","notnull":1,"dflt_value":null,"pk":2,"hidden":0},{"cid":2,"name":"archive_name","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"archive_sha256","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"first_seq","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"last_seq","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":6,"name":"event_count","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":7,"name":"raw_bytes","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":8,"name":"archive_bytes","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":9,"name":"archive_blob","type":"BLOB","notnull":0,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[{"id":0,"seq":0,"table":"session_transcript_cold_archives","from":"session_id","to":"session_id","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"}],"indexes":[{"name":"sqlite_autoindex_session_transcript_cold_archive_chunks_1","origin":"u","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":2,"name":"archive_name","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":0},{"seqno":2,"cid":1,"name":"chunk_index","desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_session_transcript_cold_archive_chunks_2","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":1,"name":"chunk_index","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":2,"name":"archive_name","desc":0,"coll":"BINARY","key":0},{"seqno":3,"cid":3,"name":"archive_sha256","desc":0,"coll":"BINARY","key":0},{"seqno":4,"cid":4,"name":"first_seq","desc":0,"coll":"BINARY","key":0},{"seqno":5,"cid":5,"name":"last_seq","desc":0,"coll":"BINARY","key":0},{"seqno":6,"cid":6,"name":"event_count","desc":0,"coll":"BINARY","key":0},{"seqno":7,"cid":7,"name":"raw_bytes","desc":0,"coll":"BINARY","key":0},{"seqno":8,"cid":8,"name":"archive_bytes","desc":0,"coll":"BINARY","key":0},{"seqno":9,"cid":9,"name":"archive_blob","desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"session_transcript_cold_archives","sql":"CREATE TABLE session_transcript_cold_archives ( session_id TEXT NOT NULL PRIMARY KEY, generation TEXT NOT NULL, archive_name TEXT NOT NULL UNIQUE, archive_sha256 TEXT NOT NULL CHECK (length(archive_sha256) = 64), event_count INTEGER NOT NULL CHECK (event_count >= 1), raw_bytes INTEGER NOT NULL CHECK (raw_bytes >= 0), archive_bytes INTEGER NOT NULL CHECK (archive_bytes >= 0), last_seq INTEGER NOT NULL, archived_at INTEGER NOT NULL, storage TEXT NOT NULL CHECK (storage IN ('file', 'sqlite')), archive_blob BLOB, FOREIGN KEY (session_id) REFERENCES \"session_windows\"(session_id) ON DELETE CASCADE, CHECK (length(archive_name) > 0 AND archive_name NOT IN ('.', '..') AND archive_name NOT LIKE '%/%' AND archive_name NOT LIKE '%\\%'), CHECK ((storage = 'file' AND archive_blob IS NULL) OR (storage = 'sqlite' AND archive_blob IS NOT NULL)) ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"session_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"generation","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":2,"name":"archive_name","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"archive_sha256","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"event_count","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"raw_bytes","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":6,"name":"archive_bytes","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":7,"name":"last_seq","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":8,"name":"archived_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":9,"name":"storage","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":10,"name":"archive_blob","type":"BLOB","notnull":0,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[{"id":0,"seq":0,"table":"session_windows","from":"session_id","to":"session_id","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"}],"indexes":[{"name":"sqlite_autoindex_session_transcript_cold_archives_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_session_transcript_cold_archives_2","origin":"u","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":2,"name":"archive_name","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"session_transcript_fts","sql":"CREATE VIRTUAL TABLE session_transcript_fts USING fts5( text, session_id UNINDEXED, message_id UNINDEXED, role UNINDEXED, timestamp UNINDEXED, tokenize = 'unicode61 remove_diacritics 2' )","strict":0,"withoutRowid":0,"columns":[{"cid":0,"name":"text","type":"","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":1,"name":"session_id","type":"","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":2,"name":"message_id","type":"","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"role","type":"","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"timestamp","type":"","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"session_transcript_fts","type":"","notnull":0,"dflt_value":null,"pk":0,"hidden":1},{"cid":6,"name":"rank","type":"","notnull":0,"dflt_value":null,"pk":0,"hidden":1}],"foreignKeys":[],"indexes":[],"triggers":[]},{"name":"session_transcript_fts_config","sql":"CREATE TABLE 'session_transcript_fts_config'(k PRIMARY KEY, v) WITHOUT ROWID","strict":0,"withoutRowid":1,"columns":[{"cid":0,"name":"k","type":"","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"v","type":"","notnull":0,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[{"name":"sqlite_autoindex_session_transcript_fts_config_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"k","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":1,"name":"v","desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"session_transcript_fts_content","sql":"CREATE TABLE 'session_transcript_fts_content'(id INTEGER PRIMARY KEY, c0, c1, c2, c3, c4)","strict":0,"withoutRowid":0,"columns":[{"cid":0,"name":"id","type":"INTEGER","notnull":0,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"c0","type":"","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":2,"name":"c1","type":"","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"c2","type":"","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"c3","type":"","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"c4","type":"","notnull":0,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[],"triggers":[]},{"name":"session_transcript_fts_data","sql":"CREATE TABLE 'session_transcript_fts_data'(id INTEGER PRIMARY KEY, block BLOB)","strict":0,"withoutRowid":0,"columns":[{"cid":0,"name":"id","type":"INTEGER","notnull":0,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"block","type":"BLOB","notnull":0,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[],"triggers":[]},{"name":"session_transcript_fts_docsize","sql":"CREATE TABLE 'session_transcript_fts_docsize'(id INTEGER PRIMARY KEY, sz BLOB)","strict":0,"withoutRowid":0,"columns":[{"cid":0,"name":"id","type":"INTEGER","notnull":0,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"sz","type":"BLOB","notnull":0,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[],"triggers":[]},{"name":"session_transcript_fts_idx","sql":"CREATE TABLE 'session_transcript_fts_idx'(segid, term, pgno, PRIMARY KEY(segid, term)) WITHOUT ROWID","strict":0,"withoutRowid":1,"columns":[{"cid":0,"name":"segid","type":"","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"term","type":"","notnull":1,"dflt_value":null,"pk":2,"hidden":0},{"cid":2,"name":"pgno","type":"","notnull":0,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[{"name":"sqlite_autoindex_session_transcript_fts_idx_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"segid","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":1,"name":"term","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":2,"name":"pgno","desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"session_transcript_fts_rows","sql":"CREATE TABLE session_transcript_fts_rows ( id INTEGER PRIMARY KEY, session_id TEXT NOT NULL, message_id TEXT ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"id","type":"INTEGER","notnull":0,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"session_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":2,"name":"message_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[{"name":"idx_session_transcript_fts_rows_session_message","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_session_transcript_fts_rows_session_message ON session_transcript_fts_rows(session_id, message_id)","terms":[{"seqno":0,"cid":1,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":2,"name":"message_id","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[{"name":"session_transcript_fts_rows_after_delete","sql":"CREATE TRIGGER session_transcript_fts_rows_after_delete AFTER DELETE ON session_transcript_fts_rows BEGIN DELETE FROM session_transcript_fts WHERE rowid = OLD.id; END"}]},{"name":"session_transcript_index_state","sql":"CREATE TABLE session_transcript_index_state ( session_id TEXT NOT NULL PRIMARY KEY, indexed_seq INTEGER NOT NULL, leaf_event_id TEXT, needs_rebuild INTEGER NOT NULL DEFAULT 0, active_event_count INTEGER NOT NULL DEFAULT 0, active_message_count INTEGER NOT NULL DEFAULT 0, updated_at INTEGER NOT NULL, FOREIGN KEY (session_id) REFERENCES session_windows(session_id) ON DELETE CASCADE ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"session_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"indexed_seq","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":2,"name":"leaf_event_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"needs_rebuild","type":"INTEGER","notnull":1,"dflt_value":"0","pk":0,"hidden":0},{"cid":4,"name":"active_event_count","type":"INTEGER","notnull":1,"dflt_value":"0","pk":0,"hidden":0},{"cid":5,"name":"active_message_count","type":"INTEGER","notnull":1,"dflt_value":"0","pk":0,"hidden":0},{"cid":6,"name":"updated_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[{"id":0,"seq":0,"table":"session_windows","from":"session_id","to":"session_id","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"}],"indexes":[{"name":"sqlite_autoindex_session_transcript_index_state_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"session_windows","sql":"CREATE TABLE session_windows ( session_id TEXT NOT NULL PRIMARY KEY, session_key TEXT NOT NULL, previous_session_id TEXT, reason TEXT CHECK (reason IS NULL OR reason IN ('initial', 'reset', 'rollover', 'fork', 'rewind', 'switch', 'recovery', 'compaction')), session_scope TEXT NOT NULL DEFAULT 'conversation' CHECK (session_scope IN ('conversation', 'shared-main', 'group', 'channel')), created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL, transcript_updated_at INTEGER DEFAULT NULL, row_transcript_json TEXT, row_transcript_updated_at INTEGER, transcript_observed_at INTEGER DEFAULT NULL, session_entry_provenance INTEGER NOT NULL DEFAULT 0 CHECK (session_entry_provenance IN (0, 1)), acp_owned INTEGER NOT NULL DEFAULT 0 CHECK (acp_owned IN (0, 1)), plugin_owner_id TEXT, hook_external_content_source TEXT CHECK (hook_external_content_source IS NULL OR hook_external_content_source IN ('gmail', 'webhook')), started_at INTEGER, ended_at INTEGER, status TEXT CHECK (status IS NULL OR status IN ('running', 'done', 'failed', 'killed', 'timeout')), chat_type TEXT CHECK (chat_type IS NULL OR chat_type IN ('direct', 'group', 'channel')), channel TEXT, account_id TEXT, primary_conversation_id TEXT, model_provider TEXT, model TEXT, agent_harness_id TEXT, parent_session_key TEXT, spawned_by TEXT, display_name TEXT, FOREIGN KEY (session_key) REFERENCES session_nodes(session_key) ON DELETE CASCADE, FOREIGN KEY (primary_conversation_id) REFERENCES conversations(conversation_id) ON DELETE SET NULL ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"session_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"session_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":2,"name":"previous_session_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"reason","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"session_scope","type":"TEXT","notnull":1,"dflt_value":"'conversation'","pk":0,"hidden":0},{"cid":5,"name":"created_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":6,"name":"updated_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":7,"name":"transcript_updated_at","type":"INTEGER","notnull":0,"dflt_value":"NULL","pk":0,"hidden":0},{"cid":8,"name":"row_transcript_json","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":9,"name":"row_transcript_updated_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":10,"name":"transcript_observed_at","type":"INTEGER","notnull":0,"dflt_value":"NULL","pk":0,"hidden":0},{"cid":11,"name":"session_entry_provenance","type":"INTEGER","notnull":1,"dflt_value":"0","pk":0,"hidden":0},{"cid":12,"name":"acp_owned","type":"INTEGER","notnull":1,"dflt_value":"0","pk":0,"hidden":0},{"cid":13,"name":"plugin_owner_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":14,"name":"hook_external_content_source","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":15,"name":"started_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":16,"name":"ended_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":17,"name":"status","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":18,"name":"chat_type","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":19,"name":"channel","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":20,"name":"account_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":21,"name":"primary_conversation_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":22,"name":"model_provider","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":23,"name":"model","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":24,"name":"agent_harness_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":25,"name":"parent_session_key","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":26,"name":"spawned_by","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":27,"name":"display_name","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[{"id":0,"seq":0,"table":"conversations","from":"primary_conversation_id","to":"conversation_id","on_update":"NO ACTION","on_delete":"SET NULL","match":"NONE"},{"id":1,"seq":0,"table":"session_nodes","from":"session_key","to":"session_key","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"}],"indexes":[{"name":"idx_agent_session_windows_conversation","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_session_windows_conversation ON session_windows(primary_conversation_id) WHERE primary_conversation_id IS NOT NULL","terms":[{"seqno":0,"cid":21,"name":"primary_conversation_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_windows_created_at","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_windows_created_at ON session_windows(created_at DESC, session_id)","terms":[{"seqno":0,"cid":5,"name":"created_at","desc":1,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_windows_session_key","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_windows_session_key ON session_windows(session_key, updated_at DESC, session_id)","terms":[{"seqno":0,"cid":1,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":6,"name":"updated_at","desc":1,"coll":"BINARY","key":1},{"seqno":2,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":3,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_windows_updated_at","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_windows_updated_at ON session_windows(updated_at DESC, session_id)","terms":[{"seqno":0,"cid":6,"name":"updated_at","desc":1,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_session_windows_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"standing_intents","sql":"CREATE TABLE standing_intents ( intent_key INTEGER PRIMARY KEY, id TEXT NOT NULL UNIQUE, description TEXT NOT NULL, trigger_keywords TEXT NOT NULL, trigger_embedding TEXT, channel_scope TEXT, sender_scope TEXT, creator_sender TEXT CHECK (creator_sender IS NULL OR length(trim(creator_sender)) > 0), status TEXT NOT NULL CHECK (status IN ('pending', 'armed', 'fired', 'done', 'cancelled', 'expired')), expires_at INTEGER NOT NULL, max_fires INTEGER NOT NULL CHECK (max_fires > 0), fire_count INTEGER NOT NULL DEFAULT 0 CHECK (fire_count >= 0), cooldown_seconds INTEGER NOT NULL DEFAULT 86400 CHECK (cooldown_seconds >= 0), last_fired_at INTEGER, created_at INTEGER NOT NULL, source_session_id TEXT ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"intent_key","type":"INTEGER","notnull":0,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"id","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":2,"name":"description","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"trigger_keywords","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"trigger_embedding","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"channel_scope","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":6,"name":"sender_scope","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":7,"name":"creator_sender","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":8,"name":"status","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":9,"name":"expires_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":10,"name":"max_fires","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":11,"name":"fire_count","type":"INTEGER","notnull":1,"dflt_value":"0","pk":0,"hidden":0},{"cid":12,"name":"cooldown_seconds","type":"INTEGER","notnull":1,"dflt_value":"86400","pk":0,"hidden":0},{"cid":13,"name":"last_fired_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":14,"name":"created_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":15,"name":"source_session_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[{"name":"idx_standing_intents_lifecycle","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_standing_intents_lifecycle ON standing_intents(status, expires_at, last_fired_at)","terms":[{"seqno":0,"cid":8,"name":"status","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":9,"name":"expires_at","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":13,"name":"last_fired_at","desc":0,"coll":"BINARY","key":1},{"seqno":3,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_standing_intents_scope","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_standing_intents_scope ON standing_intents(status, channel_scope, sender_scope)","terms":[{"seqno":0,"cid":8,"name":"status","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":5,"name":"channel_scope","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":6,"name":"sender_scope","desc":0,"coll":"BINARY","key":1},{"seqno":3,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_standing_intents_1","origin":"u","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":1,"name":"id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[{"name":"standing_intents_fts_after_delete","sql":"CREATE TRIGGER standing_intents_fts_after_delete AFTER DELETE ON standing_intents BEGIN INSERT INTO standing_intents_fts(standing_intents_fts, rowid, trigger_keywords) VALUES ('delete', old.intent_key, old.trigger_keywords); END"},{"name":"standing_intents_fts_after_insert","sql":"CREATE TRIGGER standing_intents_fts_after_insert AFTER INSERT ON standing_intents BEGIN INSERT INTO standing_intents_fts(rowid, trigger_keywords) VALUES (new.intent_key, new.trigger_keywords); END"},{"name":"standing_intents_fts_after_update","sql":"CREATE TRIGGER standing_intents_fts_after_update AFTER UPDATE OF trigger_keywords ON standing_intents BEGIN INSERT INTO standing_intents_fts(standing_intents_fts, rowid, trigger_keywords) VALUES ('delete', old.intent_key, old.trigger_keywords); INSERT INTO standing_intents_fts(rowid, trigger_keywords) VALUES (new.intent_key, new.trigger_keywords); END"}]},{"name":"standing_intents_fts","sql":"CREATE VIRTUAL TABLE standing_intents_fts USING fts5( trigger_keywords, content = 'standing_intents', content_rowid = 'intent_key', tokenize = 'unicode61 remove_diacritics 2' )","strict":0,"withoutRowid":0,"columns":[{"cid":0,"name":"trigger_keywords","type":"","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":1,"name":"standing_intents_fts","type":"","notnull":0,"dflt_value":null,"pk":0,"hidden":1},{"cid":2,"name":"rank","type":"","notnull":0,"dflt_value":null,"pk":0,"hidden":1}],"foreignKeys":[],"indexes":[],"triggers":[]},{"name":"standing_intents_fts_config","sql":"CREATE TABLE 'standing_intents_fts_config'(k PRIMARY KEY, v) WITHOUT ROWID","strict":0,"withoutRowid":1,"columns":[{"cid":0,"name":"k","type":"","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"v","type":"","notnull":0,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[{"name":"sqlite_autoindex_standing_intents_fts_config_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"k","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":1,"name":"v","desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"standing_intents_fts_data","sql":"CREATE TABLE 'standing_intents_fts_data'(id INTEGER PRIMARY KEY, block BLOB)","strict":0,"withoutRowid":0,"columns":[{"cid":0,"name":"id","type":"INTEGER","notnull":0,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"block","type":"BLOB","notnull":0,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[],"triggers":[]},{"name":"standing_intents_fts_docsize","sql":"CREATE TABLE 'standing_intents_fts_docsize'(id INTEGER PRIMARY KEY, sz BLOB)","strict":0,"withoutRowid":0,"columns":[{"cid":0,"name":"id","type":"INTEGER","notnull":0,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"sz","type":"BLOB","notnull":0,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[],"triggers":[]},{"name":"standing_intents_fts_idx","sql":"CREATE TABLE 'standing_intents_fts_idx'(segid, term, pgno, PRIMARY KEY(segid, term)) WITHOUT ROWID","strict":0,"withoutRowid":1,"columns":[{"cid":0,"name":"segid","type":"","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"term","type":"","notnull":1,"dflt_value":null,"pk":2,"hidden":0},{"cid":2,"name":"pgno","type":"","notnull":0,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[{"name":"sqlite_autoindex_standing_intents_fts_idx_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"segid","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":1,"name":"term","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":2,"name":"pgno","desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"trajectory_runtime_events","sql":"CREATE TABLE trajectory_runtime_events ( session_id TEXT NOT NULL, seq INTEGER NOT NULL, run_id TEXT, event_json TEXT NOT NULL, created_at INTEGER NOT NULL, event_utf8_bytes INTEGER, event_payload BLOB, event_codec TEXT, PRIMARY KEY (session_id, seq), FOREIGN KEY (session_id) REFERENCES \"session_windows\"(session_id) ON DELETE CASCADE ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"session_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"seq","type":"INTEGER","notnull":1,"dflt_value":null,"pk":2,"hidden":0},{"cid":2,"name":"run_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"event_json","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"created_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"event_utf8_bytes","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":6,"name":"event_payload","type":"BLOB","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":7,"name":"event_codec","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[{"id":0,"seq":0,"table":"session_windows","from":"session_id","to":"session_id","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"}],"indexes":[{"name":"idx_agent_trajectory_runtime_run","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_trajectory_runtime_run ON trajectory_runtime_events(session_id, run_id, created_at, COALESCE(event_utf8_bytes, octet_length(event_json)))","terms":[{"seqno":0,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":2,"name":"run_id","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":4,"name":"created_at","desc":0,"coll":"BINARY","key":1},{"seqno":3,"cid":-2,"name":null,"desc":0,"coll":"BINARY","key":1},{"seqno":4,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_trajectory_runtime_events_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":1,"name":"seq","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"transcript_event_identities","sql":"CREATE TABLE transcript_event_identities ( session_id TEXT NOT NULL, event_id TEXT NOT NULL, seq INTEGER NOT NULL, event_type TEXT, parent_id TEXT, message_idempotency_key TEXT, created_at INTEGER NOT NULL, PRIMARY KEY (session_id, event_id), FOREIGN KEY (session_id, seq) REFERENCES transcript_events(session_id, seq) ON DELETE CASCADE ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"session_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"event_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":2,"hidden":0},{"cid":2,"name":"seq","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"event_type","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"parent_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"message_idempotency_key","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":6,"name":"created_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[{"id":0,"seq":0,"table":"transcript_events","from":"session_id","to":"session_id","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"},{"id":0,"seq":1,"table":"transcript_events","from":"seq","to":"seq","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"}],"indexes":[{"name":"idx_agent_transcript_event_identity_sequence","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_transcript_event_identity_sequence ON transcript_event_identities(session_id, seq)","terms":[{"seqno":0,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":2,"name":"seq","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_transcript_event_sequence","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_transcript_event_sequence ON transcript_event_identities(session_id, event_type, seq DESC)","terms":[{"seqno":0,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":3,"name":"event_type","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":2,"name":"seq","desc":1,"coll":"BINARY","key":1},{"seqno":3,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_transcript_message_idempotency","origin":"c","partial":1,"unique":1,"sql":"CREATE UNIQUE INDEX idx_agent_transcript_message_idempotency ON transcript_event_identities(session_id, message_idempotency_key) WHERE message_idempotency_key IS NOT NULL","terms":[{"seqno":0,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":5,"name":"message_idempotency_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_transcript_event_identities_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":1,"name":"event_id","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"transcript_events","sql":"CREATE TABLE transcript_events ( session_id TEXT NOT NULL, seq INTEGER NOT NULL, event_json TEXT, created_at INTEGER NOT NULL, event_zstd BLOB, event_utf8_bytes INTEGER CHECK (event_utf8_bytes IS NULL OR event_utf8_bytes >= 0), navigation_json TEXT, navigation_type TEXT, navigation_custom_type TEXT, navigation_display INTEGER NOT NULL DEFAULT 0, message_role TEXT, navigation_last_type TEXT, navigation_last_custom_type TEXT, navigation_valid INTEGER NOT NULL DEFAULT 1, PRIMARY KEY (session_id, seq), FOREIGN KEY (session_id) REFERENCES \"session_windows\"(session_id) ON DELETE CASCADE, 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 length(event_zstd) BETWEEN 1 AND 4194304 AND navigation_json IS NOT NULL ) ), CHECK ( navigation_json IS NULL OR CASE WHEN json_valid(navigation_json) THEN coalesce( octet_length(navigation_json) <= 16384 AND json_type(navigation_json, '$.version') = 'integer' AND json_extract(navigation_json, '$.version') = 1 AND json_type(navigation_json, '$.report') = 'object' AND json_extract(navigation_json, '$.report.kind') IN ('canonical', 'leaf', 'link', 'ignored') AND json_type(navigation_json, '$.navigation') = 'object' AND json_type(navigation_json, '$.reset') = 'object' AND json_type(navigation_json, '$.model') = 'object' AND json_type(navigation_json, '$.modelBytes') = 'integer' AND json_extract(navigation_json, '$.modelBytes') BETWEEN 0 AND 4194304 AND json_type(navigation_json, '$.modelWithoutCheckpointBytes') = 'integer' AND json_extract(navigation_json, '$.modelWithoutCheckpointBytes') BETWEEN 0 AND 4194304 AND json_type(navigation_json, '$.withoutCustomDataBytes') = 'integer' AND json_extract(navigation_json, '$.withoutCustomDataBytes') BETWEEN 0 AND 4194304, 0) ELSE 0 END ) ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"session_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"seq","type":"INTEGER","notnull":1,"dflt_value":null,"pk":2,"hidden":0},{"cid":2,"name":"event_json","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"created_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"event_zstd","type":"BLOB","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"event_utf8_bytes","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":6,"name":"navigation_json","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":7,"name":"navigation_type","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":8,"name":"navigation_custom_type","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":9,"name":"navigation_display","type":"INTEGER","notnull":1,"dflt_value":"0","pk":0,"hidden":0},{"cid":10,"name":"message_role","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":11,"name":"navigation_last_type","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":12,"name":"navigation_last_custom_type","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":13,"name":"navigation_valid","type":"INTEGER","notnull":1,"dflt_value":"1","pk":0,"hidden":0}],"foreignKeys":[{"id":0,"seq":0,"table":"session_windows","from":"session_id","to":"session_id","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"}],"indexes":[{"name":"sqlite_autoindex_transcript_events_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":1,"name":"seq","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"transcript_rewrite_watermarks","sql":"CREATE TABLE transcript_rewrite_watermarks ( session_id TEXT NOT NULL PRIMARY KEY, generation TEXT NOT NULL, updated_at INTEGER NOT NULL, FOREIGN KEY (session_id) REFERENCES \"session_windows\"(session_id) ON DELETE CASCADE ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"session_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"generation","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":2,"name":"updated_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[{"id":0,"seq":0,"table":"session_windows","from":"session_id","to":"session_id","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"}],"indexes":[{"name":"sqlite_autoindex_transcript_rewrite_watermarks_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"context_engine_turn_outbox","sql":"CREATE TABLE context_engine_turn_outbox ( advancement_key TEXT NOT NULL PRIMARY KEY, engine_id TEXT NOT NULL, owner_plugin_id TEXT, session_id TEXT NOT NULL, payload_json TEXT NOT NULL, attempt_count INTEGER NOT NULL DEFAULT 0, last_attempt_at INTEGER, last_error TEXT, created_at INTEGER NOT NULL ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"advancement_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"engine_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":2,"name":"owner_plugin_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"session_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"payload_json","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"attempt_count","type":"INTEGER","notnull":1,"dflt_value":"0","pk":0,"hidden":0},{"cid":6,"name":"last_attempt_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":7,"name":"last_error","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":8,"name":"created_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[{"name":"idx_agent_context_engine_turn_outbox_engine","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_context_engine_turn_outbox_engine ON context_engine_turn_outbox(engine_id, created_at)","terms":[{"seqno":0,"cid":1,"name":"engine_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":8,"name":"created_at","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_context_engine_turn_outbox_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"advancement_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"conversation_deliveries","sql":"CREATE TABLE conversation_deliveries ( operation_id TEXT NOT NULL PRIMARY KEY, operation_kind TEXT NOT NULL CHECK (operation_kind IN ('send', 'turn')), conversation_id TEXT NOT NULL, source_session_key TEXT, message_hash TEXT NOT NULL, status TEXT NOT NULL CHECK (status IN ('created', 'queued', 'sent', 'suppressed', 'rejected', 'unknown', 'replied')), prepared_message_id TEXT, platform_message_id TEXT, queue_id TEXT, rejection_error TEXT, reply_message_id TEXT, reply_to_id TEXT, reply_thread_id TEXT, reply_text TEXT, reply_timestamp INTEGER, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL, CHECK ( (status = 'rejected' AND rejection_error IS NOT NULL) OR (status != 'rejected' AND rejection_error IS NULL) ), FOREIGN KEY (conversation_id) REFERENCES conversations(conversation_id) ON DELETE CASCADE ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"operation_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"operation_kind","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":2,"name":"conversation_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"source_session_key","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"message_hash","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"status","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":6,"name":"prepared_message_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":7,"name":"platform_message_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":8,"name":"queue_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":9,"name":"rejection_error","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":10,"name":"reply_message_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":11,"name":"reply_to_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":12,"name":"reply_thread_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":13,"name":"reply_text","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":14,"name":"reply_timestamp","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":15,"name":"created_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":16,"name":"updated_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[{"id":0,"seq":0,"table":"conversations","from":"conversation_id","to":"conversation_id","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"}],"indexes":[{"name":"idx_agent_conversation_deliveries_reply","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_conversation_deliveries_reply ON conversation_deliveries(conversation_id, platform_message_id, prepared_message_id) WHERE status IN ('queued', 'sent', 'replied')","terms":[{"seqno":0,"cid":2,"name":"conversation_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":7,"name":"platform_message_id","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":6,"name":"prepared_message_id","desc":0,"coll":"BINARY","key":1},{"seqno":3,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_conversation_deliveries_updated","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_conversation_deliveries_updated ON conversation_deliveries(updated_at DESC, operation_id)","terms":[{"seqno":0,"cid":16,"name":"updated_at","desc":1,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"operation_id","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_conversation_deliveries_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"operation_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"memory_embedding_cache","sql":"CREATE TABLE memory_embedding_cache ( provider TEXT NOT NULL, model TEXT NOT NULL, provider_key TEXT NOT NULL, hash TEXT NOT NULL, embedding TEXT NOT NULL, dims INTEGER, updated_at INTEGER NOT NULL, PRIMARY KEY (provider, model, provider_key, hash) ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"provider","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"model","type":"TEXT","notnull":1,"dflt_value":null,"pk":2,"hidden":0},{"cid":2,"name":"provider_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":3,"hidden":0},{"cid":3,"name":"hash","type":"TEXT","notnull":1,"dflt_value":null,"pk":4,"hidden":0},{"cid":4,"name":"embedding","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"dims","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":6,"name":"updated_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[{"name":"idx_memory_embedding_cache_updated_at","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_memory_embedding_cache_updated_at ON memory_embedding_cache(updated_at)","terms":[{"seqno":0,"cid":6,"name":"updated_at","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_memory_embedding_cache_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"provider","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":1,"name":"model","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":2,"name":"provider_key","desc":0,"coll":"BINARY","key":1},{"seqno":3,"cid":3,"name":"hash","desc":0,"coll":"BINARY","key":1},{"seqno":4,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"memory_entry_origins","sql":"CREATE TABLE memory_entry_origins ( entry_key TEXT NOT NULL, agent_id TEXT NOT NULL, session_id TEXT NOT NULL, session_key TEXT, origin_class TEXT NOT NULL CHECK (origin_class IN ('owner', 'agent', 'untrusted', 'system')), observed_at INTEGER NOT NULL, PRIMARY KEY (entry_key, agent_id, session_id) ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"entry_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"agent_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":2,"hidden":0},{"cid":2,"name":"session_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":3,"hidden":0},{"cid":3,"name":"session_key","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"origin_class","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"observed_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[{"name":"sqlite_autoindex_memory_entry_origins_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"entry_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":1,"name":"agent_id","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":2,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":3,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"memory_index_chunks","sql":"CREATE TABLE memory_index_chunks ( id TEXT PRIMARY KEY, path TEXT NOT NULL, source TEXT NOT NULL DEFAULT 'memory', start_line INTEGER NOT NULL, end_line INTEGER NOT NULL, hash TEXT NOT NULL, model TEXT NOT NULL, text TEXT NOT NULL, embedding TEXT NOT NULL, updated_at INTEGER NOT NULL ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"id","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"path","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":2,"name":"source","type":"TEXT","notnull":1,"dflt_value":"'memory'","pk":0,"hidden":0},{"cid":3,"name":"start_line","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"end_line","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"hash","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":6,"name":"model","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":7,"name":"text","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":8,"name":"embedding","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":9,"name":"updated_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[{"name":"idx_memory_index_chunks_path_source","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_memory_index_chunks_path_source ON memory_index_chunks(path, source)","terms":[{"seqno":0,"cid":1,"name":"path","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":2,"name":"source","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_memory_index_chunks_source","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_memory_index_chunks_source ON memory_index_chunks(source)","terms":[{"seqno":0,"cid":2,"name":"source","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_memory_index_chunks_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[{"name":"memory_index_chunks_revision_after_delete","sql":"CREATE TRIGGER memory_index_chunks_revision_after_delete AFTER DELETE ON memory_index_chunks BEGIN UPDATE memory_index_state SET revision = revision + 1 WHERE id = 1; END"},{"name":"memory_index_chunks_revision_after_insert","sql":"CREATE TRIGGER memory_index_chunks_revision_after_insert AFTER INSERT ON memory_index_chunks BEGIN UPDATE memory_index_state SET revision = revision + 1 WHERE id = 1; END"},{"name":"memory_index_chunks_revision_after_update","sql":"CREATE TRIGGER memory_index_chunks_revision_after_update AFTER UPDATE ON memory_index_chunks BEGIN UPDATE memory_index_state SET revision = revision + 1 WHERE id = 1; END"}]},{"name":"memory_index_sources","sql":"CREATE TABLE memory_index_sources ( id INTEGER PRIMARY KEY, path TEXT NOT NULL, source TEXT NOT NULL DEFAULT 'memory', hash TEXT NOT NULL, mtime REAL NOT NULL, size INTEGER NOT NULL, UNIQUE (path, source) ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"id","type":"INTEGER","notnull":0,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"path","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":2,"name":"source","type":"TEXT","notnull":1,"dflt_value":"'memory'","pk":0,"hidden":0},{"cid":3,"name":"hash","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"mtime","type":"REAL","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"size","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[{"name":"idx_memory_index_sources_source","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_memory_index_sources_source ON memory_index_sources(source)","terms":[{"seqno":0,"cid":2,"name":"source","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_memory_index_sources_1","origin":"u","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":1,"name":"path","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":2,"name":"source","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[{"name":"memory_index_sources_revision_after_delete","sql":"CREATE TRIGGER memory_index_sources_revision_after_delete AFTER DELETE ON memory_index_sources BEGIN UPDATE memory_index_state SET revision = revision + 1 WHERE id = 1; END"},{"name":"memory_index_sources_revision_after_insert","sql":"CREATE TRIGGER memory_index_sources_revision_after_insert AFTER INSERT ON memory_index_sources BEGIN UPDATE memory_index_state SET revision = revision + 1 WHERE id = 1; END"},{"name":"memory_index_sources_revision_after_update","sql":"CREATE TRIGGER memory_index_sources_revision_after_update AFTER UPDATE ON memory_index_sources BEGIN UPDATE memory_index_state SET revision = revision + 1 WHERE id = 1; END"}]},{"name":"session_input_completions","sql":"CREATE TABLE session_input_completions ( session_key TEXT NOT NULL, session_id TEXT NOT NULL, idempotency_key TEXT NOT NULL, run_id TEXT NOT NULL, request_hash TEXT NOT NULL, outcome_json TEXT NOT NULL, succeeded INTEGER NOT NULL CHECK (succeeded IN (0, 1)), completed_at INTEGER NOT NULL, PRIMARY KEY (session_id, idempotency_key), FOREIGN KEY (session_key) REFERENCES session_nodes(session_key) ON DELETE CASCADE, FOREIGN KEY (session_id) REFERENCES session_windows(session_id) ON DELETE CASCADE ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"session_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":1,"name":"session_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":2,"name":"idempotency_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":2,"hidden":0},{"cid":3,"name":"run_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"request_hash","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"outcome_json","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":6,"name":"succeeded","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":7,"name":"completed_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[{"id":0,"seq":0,"table":"session_windows","from":"session_id","to":"session_id","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"},{"id":1,"seq":0,"table":"session_nodes","from":"session_key","to":"session_key","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"}],"indexes":[{"name":"sqlite_autoindex_session_input_completions_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":1,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":2,"name":"idempotency_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"session_nodes","sql":"CREATE TABLE session_nodes ( session_key TEXT NOT NULL PRIMARY KEY, current_session_id TEXT NOT NULL, entry_json TEXT NOT NULL, legacy_acp_migration_json TEXT, entry_valid INTEGER NOT NULL DEFAULT 0 CHECK (entry_valid IN (-1, 0, 1)), updated_at INTEGER NOT NULL, status TEXT CHECK (status IS NULL OR status IN ('running', 'done', 'failed', 'killed', 'timeout')), created_at INTEGER, created_via TEXT CHECK (created_via IS NULL OR created_via IN ('operator', 'spawn', 'channel', 'cron', 'talk', 'run', 'plugin', 'internal')), created_actor_type TEXT CHECK (created_actor_type IS NULL OR created_actor_type IN ('human', 'agent', 'system')), created_actor_id TEXT, owner_actor_type TEXT, owner_actor_id TEXT, owner_assigned_by_type TEXT, owner_assigned_by_id TEXT, owner_assigned_at INTEGER, project_id TEXT, parent_session_key TEXT, spawned_by TEXT, fork_source_session_key TEXT, fork_source_session_id TEXT, fork_source_entry_id TEXT, label TEXT, display_name TEXT, category TEXT, icon TEXT, pinned_at INTEGER, archived_at INTEGER, last_read_at INTEGER, last_interaction_at INTEGER, last_activity_at INTEGER ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"session_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"current_session_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":2,"name":"entry_json","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"legacy_acp_migration_json","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"entry_valid","type":"INTEGER","notnull":1,"dflt_value":"0","pk":0,"hidden":0},{"cid":5,"name":"updated_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":6,"name":"status","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":7,"name":"created_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":8,"name":"created_via","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":9,"name":"created_actor_type","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":10,"name":"created_actor_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":11,"name":"owner_actor_type","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":12,"name":"owner_actor_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":13,"name":"owner_assigned_by_type","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":14,"name":"owner_assigned_by_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":15,"name":"owner_assigned_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":16,"name":"project_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":17,"name":"parent_session_key","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":18,"name":"spawned_by","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":19,"name":"fork_source_session_key","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":20,"name":"fork_source_session_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":21,"name":"fork_source_entry_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":22,"name":"label","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":23,"name":"display_name","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":24,"name":"category","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":25,"name":"icon","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":26,"name":"pinned_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":27,"name":"archived_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":28,"name":"last_read_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":29,"name":"last_interaction_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":30,"name":"last_activity_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[{"name":"idx_agent_session_nodes_active","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_active ON session_nodes(session_key) WHERE archived_at IS NULL","terms":[{"seqno":0,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_archived_at","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_archived_at ON session_nodes(archived_at, session_key) WHERE archived_at IS NOT NULL","terms":[{"seqno":0,"cid":27,"name":"archived_at","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_current_session_id","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_current_session_id ON session_nodes(current_session_id)","terms":[{"seqno":0,"cid":1,"name":"current_session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_entry_not_valid","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_entry_not_valid ON session_nodes(session_key) WHERE entry_valid != 1","terms":[{"seqno":0,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_entry_valid_pending","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_entry_valid_pending ON session_nodes(session_key) WHERE entry_valid = 0","terms":[{"seqno":0,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_label","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_label ON session_nodes(label, session_key) WHERE label IS NOT NULL","terms":[{"seqno":0,"cid":22,"name":"label","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_last_interaction_at","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_last_interaction_at ON session_nodes(last_interaction_at DESC, session_key)","terms":[{"seqno":0,"cid":29,"name":"last_interaction_at","desc":1,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_parent_session_key","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_parent_session_key ON session_nodes(parent_session_key, session_key)","terms":[{"seqno":0,"cid":17,"name":"parent_session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_spawned_by","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_spawned_by ON session_nodes(spawned_by, session_key)","terms":[{"seqno":0,"cid":18,"name":"spawned_by","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_status","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_status ON session_nodes(status, session_key) WHERE status IS NOT NULL","terms":[{"seqno":0,"cid":6,"name":"status","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_updated_at","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_updated_at ON session_nodes(updated_at DESC, session_key)","terms":[{"seqno":0,"cid":5,"name":"updated_at","desc":1,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_session_nodes_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[{"name":"session_nodes_entry_valid_after_entry_update","sql":"CREATE TRIGGER session_nodes_entry_valid_after_entry_update AFTER UPDATE OF entry_json ON session_nodes BEGIN UPDATE session_nodes SET entry_valid = 0 WHERE session_key = NEW.session_key; END"},{"name":"session_nodes_entry_valid_after_identity_update","sql":"CREATE TRIGGER session_nodes_entry_valid_after_identity_update AFTER UPDATE OF current_session_id, updated_at ON session_nodes BEGIN UPDATE session_nodes SET entry_valid = 0 WHERE session_key = NEW.session_key; END"},{"name":"session_nodes_entry_valid_after_insert","sql":"CREATE TRIGGER session_nodes_entry_valid_after_insert AFTER INSERT ON session_nodes BEGIN UPDATE session_nodes SET entry_valid = 0 WHERE session_key = NEW.session_key; END"}]},{"name":"session_participants","sql":"CREATE TABLE session_participants ( session_key TEXT NOT NULL, actor_type TEXT NOT NULL, actor_id TEXT NOT NULL, actor_source TEXT, contribution_count INTEGER, first_prompted_at INTEGER NOT NULL, last_prompted_at INTEGER NOT NULL, PRIMARY KEY (session_key, actor_type, actor_id), FOREIGN KEY (session_key) REFERENCES session_nodes(session_key) ON DELETE CASCADE ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"session_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"actor_type","type":"TEXT","notnull":1,"dflt_value":null,"pk":2,"hidden":0},{"cid":2,"name":"actor_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":3,"hidden":0},{"cid":3,"name":"actor_source","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"contribution_count","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"first_prompted_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":6,"name":"last_prompted_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[{"id":0,"seq":0,"table":"session_nodes","from":"session_key","to":"session_key","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"}],"indexes":[{"name":"sqlite_autoindex_session_participants_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":1,"name":"actor_type","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":2,"name":"actor_id","desc":0,"coll":"BINARY","key":1},{"seqno":3,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"session_reactions","sql":"CREATE TABLE session_reactions ( session_key TEXT NOT NULL, session_id TEXT NOT NULL, message_id TEXT NOT NULL, emoji TEXT NOT NULL, identity_id TEXT NOT NULL, identity_label TEXT, created_at INTEGER NOT NULL, PRIMARY KEY (session_key, session_id, message_id, emoji, identity_id), FOREIGN KEY (session_key) REFERENCES session_nodes(session_key) ON DELETE CASCADE ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"session_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"session_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":2,"hidden":0},{"cid":2,"name":"message_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":3,"hidden":0},{"cid":3,"name":"emoji","type":"TEXT","notnull":1,"dflt_value":null,"pk":4,"hidden":0},{"cid":4,"name":"identity_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":5,"hidden":0},{"cid":5,"name":"identity_label","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":6,"name":"created_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[{"id":0,"seq":0,"table":"session_nodes","from":"session_key","to":"session_key","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"}],"indexes":[{"name":"idx_agent_session_reactions_message","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_reactions_message ON session_reactions(session_key, session_id, message_id)","terms":[{"seqno":0,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":1,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":2,"name":"message_id","desc":0,"coll":"BINARY","key":1},{"seqno":3,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_session_reactions_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":1,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":2,"name":"message_id","desc":0,"coll":"BINARY","key":1},{"seqno":3,"cid":3,"name":"emoji","desc":0,"coll":"BINARY","key":1},{"seqno":4,"cid":4,"name":"identity_id","desc":0,"coll":"BINARY","key":1},{"seqno":5,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"session_windows","sql":"CREATE TABLE session_windows ( session_id TEXT NOT NULL PRIMARY KEY, session_key TEXT NOT NULL, previous_session_id TEXT, reason TEXT CHECK (reason IS NULL OR reason IN ('initial', 'reset', 'rollover', 'fork', 'rewind', 'switch', 'recovery', 'compaction')), session_scope TEXT NOT NULL DEFAULT 'conversation' CHECK (session_scope IN ('conversation', 'shared-main', 'group', 'channel')), created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL, transcript_updated_at INTEGER DEFAULT NULL, row_transcript_json TEXT, row_transcript_updated_at INTEGER, transcript_observed_at INTEGER DEFAULT NULL, session_entry_provenance INTEGER NOT NULL DEFAULT 0 CHECK (session_entry_provenance IN (0, 1)), acp_owned INTEGER NOT NULL DEFAULT 0 CHECK (acp_owned IN (0, 1)), plugin_owner_id TEXT, hook_external_content_source TEXT CHECK (hook_external_content_source IS NULL OR hook_external_content_source IN ('gmail', 'webhook')), started_at INTEGER, ended_at INTEGER, status TEXT CHECK (status IS NULL OR status IN ('running', 'done', 'failed', 'killed', 'timeout')), chat_type TEXT CHECK (chat_type IS NULL OR chat_type IN ('direct', 'group', 'channel')), channel TEXT, account_id TEXT, primary_conversation_id TEXT, model_provider TEXT, model TEXT, agent_harness_id TEXT, parent_session_key TEXT, spawned_by TEXT, display_name TEXT, FOREIGN KEY (session_key) REFERENCES session_nodes(session_key) ON DELETE CASCADE, FOREIGN KEY (primary_conversation_id) REFERENCES conversations(conversation_id) ON DELETE SET NULL ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"session_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"session_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":2,"name":"previous_session_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"reason","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"session_scope","type":"TEXT","notnull":1,"dflt_value":"'conversation'","pk":0,"hidden":0},{"cid":5,"name":"created_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":6,"name":"updated_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":7,"name":"transcript_updated_at","type":"INTEGER","notnull":0,"dflt_value":"NULL","pk":0,"hidden":0},{"cid":8,"name":"row_transcript_json","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":9,"name":"row_transcript_updated_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":10,"name":"transcript_observed_at","type":"INTEGER","notnull":0,"dflt_value":"NULL","pk":0,"hidden":0},{"cid":11,"name":"session_entry_provenance","type":"INTEGER","notnull":1,"dflt_value":"0","pk":0,"hidden":0},{"cid":12,"name":"acp_owned","type":"INTEGER","notnull":1,"dflt_value":"0","pk":0,"hidden":0},{"cid":13,"name":"plugin_owner_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":14,"name":"hook_external_content_source","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":15,"name":"started_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":16,"name":"ended_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":17,"name":"status","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":18,"name":"chat_type","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":19,"name":"channel","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":20,"name":"account_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":21,"name":"primary_conversation_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":22,"name":"model_provider","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":23,"name":"model","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":24,"name":"agent_harness_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":25,"name":"parent_session_key","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":26,"name":"spawned_by","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":27,"name":"display_name","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[{"id":0,"seq":0,"table":"conversations","from":"primary_conversation_id","to":"conversation_id","on_update":"NO ACTION","on_delete":"SET NULL","match":"NONE"},{"id":1,"seq":0,"table":"session_nodes","from":"session_key","to":"session_key","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"}],"indexes":[{"name":"idx_agent_session_windows_conversation","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_session_windows_conversation ON session_windows(primary_conversation_id, updated_at DESC, session_id) WHERE primary_conversation_id IS NOT NULL","terms":[{"seqno":0,"cid":21,"name":"primary_conversation_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":6,"name":"updated_at","desc":1,"coll":"BINARY","key":1},{"seqno":2,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":3,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_windows_created_at","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_windows_created_at ON session_windows(created_at DESC, session_id)","terms":[{"seqno":0,"cid":5,"name":"created_at","desc":1,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_windows_session_key","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_windows_session_key ON session_windows(session_key, updated_at DESC, session_id)","terms":[{"seqno":0,"cid":1,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":6,"name":"updated_at","desc":1,"coll":"BINARY","key":1},{"seqno":2,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":3,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_windows_updated_at","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_windows_updated_at ON session_windows(updated_at DESC, session_id)","terms":[{"seqno":0,"cid":6,"name":"updated_at","desc":1,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_session_windows_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"trajectory_runtime_events","sql":"CREATE TABLE trajectory_runtime_events ( session_id TEXT NOT NULL, seq INTEGER NOT NULL, run_id TEXT, event_json TEXT NOT NULL, created_at INTEGER NOT NULL, PRIMARY KEY (session_id, seq), FOREIGN KEY (session_id) REFERENCES \"session_windows\"(session_id) ON DELETE CASCADE ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"session_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"seq","type":"INTEGER","notnull":1,"dflt_value":null,"pk":2,"hidden":0},{"cid":2,"name":"run_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"event_json","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"created_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[{"id":0,"seq":0,"table":"session_windows","from":"session_id","to":"session_id","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"}],"indexes":[{"name":"idx_agent_trajectory_runtime_run","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_trajectory_runtime_run ON trajectory_runtime_events(session_id, run_id, created_at, octet_length(event_json))","terms":[{"seqno":0,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":2,"name":"run_id","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":4,"name":"created_at","desc":0,"coll":"BINARY","key":1},{"seqno":3,"cid":-2,"name":null,"desc":0,"coll":"BINARY","key":1},{"seqno":4,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_trajectory_runtime_events_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":1,"name":"seq","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"transcript_event_identities","sql":"CREATE TABLE transcript_event_identities ( session_id TEXT NOT NULL, event_id TEXT NOT NULL, seq INTEGER NOT NULL, event_type TEXT, parent_id TEXT, message_idempotency_key TEXT, created_at INTEGER NOT NULL, PRIMARY KEY (session_id, event_id), FOREIGN KEY (session_id, seq) REFERENCES transcript_events(session_id, seq) ON DELETE CASCADE ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"session_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"event_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":2,"hidden":0},{"cid":2,"name":"seq","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"event_type","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"parent_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"message_idempotency_key","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":6,"name":"created_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[{"id":0,"seq":0,"table":"transcript_events","from":"session_id","to":"session_id","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"},{"id":0,"seq":1,"table":"transcript_events","from":"seq","to":"seq","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"}],"indexes":[{"name":"idx_agent_transcript_event_identity_sequence","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_transcript_event_identity_sequence ON transcript_event_identities(session_id, seq)","terms":[{"seqno":0,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":2,"name":"seq","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_transcript_event_parent","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_transcript_event_parent ON transcript_event_identities(session_id, parent_id) WHERE parent_id IS NOT NULL","terms":[{"seqno":0,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":4,"name":"parent_id","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_transcript_event_sequence","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_transcript_event_sequence ON transcript_event_identities(session_id, event_type, seq DESC)","terms":[{"seqno":0,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":3,"name":"event_type","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":2,"name":"seq","desc":1,"coll":"BINARY","key":1},{"seqno":3,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_transcript_message_idempotency","origin":"c","partial":1,"unique":1,"sql":"CREATE UNIQUE INDEX idx_agent_transcript_message_idempotency ON transcript_event_identities(session_id, message_idempotency_key) WHERE message_idempotency_key IS NOT NULL","terms":[{"seqno":0,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":5,"name":"message_idempotency_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_transcript_event_identities_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":1,"name":"event_id","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"transcript_events","sql":"CREATE TABLE transcript_events ( session_id TEXT NOT NULL, seq INTEGER NOT NULL, event_json TEXT NOT NULL, created_at INTEGER NOT NULL, PRIMARY KEY (session_id, seq), FOREIGN KEY (session_id) REFERENCES \"session_windows\"(session_id) ON DELETE CASCADE ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"session_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"seq","type":"INTEGER","notnull":1,"dflt_value":null,"pk":2,"hidden":0},{"cid":2,"name":"event_json","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"created_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[{"id":0,"seq":0,"table":"session_windows","from":"session_id","to":"session_id","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"}],"indexes":[{"name":"sqlite_autoindex_transcript_events_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":1,"name":"seq","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"session_key_contract","sql":"CREATE TABLE session_key_contract ( id INTEGER NOT NULL PRIMARY KEY CHECK (id = 1), main_key TEXT NOT NULL, canonical_ready TEXT, updated_at INTEGER NOT NULL ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"id","type":"INTEGER","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"main_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":2,"name":"canonical_ready","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"updated_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[],"triggers":[{"name":"session_key_contract_canonical_pending_after_delete","sql":"CREATE TRIGGER session_key_contract_canonical_pending_after_delete AFTER DELETE ON session_key_contract BEGIN INSERT INTO session_canonical_validation_pending (session_key) SELECT node.session_key FROM session_nodes AS node WHERE NOT EXISTS ( SELECT 1 FROM session_canonical_validation_pending AS pending WHERE pending.session_key = node.session_key ); END"},{"name":"session_key_contract_canonical_pending_after_insert","sql":"CREATE TRIGGER session_key_contract_canonical_pending_after_insert AFTER INSERT ON session_key_contract BEGIN INSERT INTO session_canonical_validation_pending (session_key) SELECT node.session_key FROM session_nodes AS node WHERE NOT EXISTS ( SELECT 1 FROM session_canonical_validation_pending AS pending WHERE pending.session_key = node.session_key ); END"},{"name":"session_key_contract_canonical_pending_after_update","sql":"CREATE TRIGGER session_key_contract_canonical_pending_after_update AFTER UPDATE OF main_key ON session_key_contract WHEN OLD.main_key IS NOT NEW.main_key BEGIN INSERT INTO session_canonical_validation_pending (session_key) SELECT node.session_key FROM session_nodes AS node WHERE NOT EXISTS ( SELECT 1 FROM session_canonical_validation_pending AS pending WHERE pending.session_key = node.session_key ); END"}]},{"name":"session_nodes","sql":"CREATE TABLE session_nodes ( session_key TEXT NOT NULL PRIMARY KEY, current_session_id TEXT NOT NULL, entry_json TEXT NOT NULL, legacy_acp_migration_json TEXT, entry_valid INTEGER NOT NULL DEFAULT 0 CHECK (entry_valid IN (-1, 0, 1)), updated_at INTEGER NOT NULL, status TEXT CHECK (status IS NULL OR status IN ('running', 'done', 'failed', 'killed', 'timeout')), created_at INTEGER, created_via TEXT CHECK (created_via IS NULL OR created_via IN ('operator', 'spawn', 'channel', 'cron', 'talk', 'run', 'plugin', 'internal')), created_actor_type TEXT CHECK (created_actor_type IS NULL OR created_actor_type IN ('human', 'agent', 'system')), created_actor_id TEXT, owner_actor_type TEXT, owner_actor_id TEXT, owner_assigned_by_type TEXT, owner_assigned_by_id TEXT, owner_assigned_at INTEGER, project_id TEXT, parent_session_key TEXT, spawned_by TEXT, fork_source_session_key TEXT, fork_source_session_id TEXT, fork_source_entry_id TEXT, label TEXT, display_name TEXT, category TEXT, icon TEXT, pinned_at INTEGER, archived_at INTEGER, last_read_at INTEGER, last_interaction_at INTEGER, last_activity_at INTEGER ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"session_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"current_session_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":2,"name":"entry_json","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"legacy_acp_migration_json","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"entry_valid","type":"INTEGER","notnull":1,"dflt_value":"0","pk":0,"hidden":0},{"cid":5,"name":"updated_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":6,"name":"status","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":7,"name":"created_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":8,"name":"created_via","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":9,"name":"created_actor_type","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":10,"name":"created_actor_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":11,"name":"owner_actor_type","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":12,"name":"owner_actor_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":13,"name":"owner_assigned_by_type","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":14,"name":"owner_assigned_by_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":15,"name":"owner_assigned_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":16,"name":"project_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":17,"name":"parent_session_key","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":18,"name":"spawned_by","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":19,"name":"fork_source_session_key","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":20,"name":"fork_source_session_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":21,"name":"fork_source_entry_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":22,"name":"label","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":23,"name":"display_name","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":24,"name":"category","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":25,"name":"icon","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":26,"name":"pinned_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":27,"name":"archived_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":28,"name":"last_read_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":29,"name":"last_interaction_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":30,"name":"last_activity_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[{"name":"idx_agent_session_nodes_active","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_active ON session_nodes(session_key) WHERE archived_at IS NULL","terms":[{"seqno":0,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_archived_at","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_archived_at ON session_nodes(archived_at, session_key) WHERE archived_at IS NOT NULL","terms":[{"seqno":0,"cid":27,"name":"archived_at","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_current_session_id","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_current_session_id ON session_nodes(current_session_id)","terms":[{"seqno":0,"cid":1,"name":"current_session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_entry_not_valid","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_entry_not_valid ON session_nodes(session_key) WHERE entry_valid != 1","terms":[{"seqno":0,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_entry_valid_pending","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_entry_valid_pending ON session_nodes(session_key) WHERE entry_valid = 0","terms":[{"seqno":0,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_label","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_label ON session_nodes(label, session_key) WHERE label IS NOT NULL","terms":[{"seqno":0,"cid":22,"name":"label","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_last_interaction_at","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_last_interaction_at ON session_nodes(last_interaction_at DESC, session_key)","terms":[{"seqno":0,"cid":29,"name":"last_interaction_at","desc":1,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_parent_session_key","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_parent_session_key ON session_nodes(parent_session_key, session_key)","terms":[{"seqno":0,"cid":17,"name":"parent_session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_spawned_by","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_spawned_by ON session_nodes(spawned_by, session_key)","terms":[{"seqno":0,"cid":18,"name":"spawned_by","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_status","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_status ON session_nodes(status, session_key) WHERE status IS NOT NULL","terms":[{"seqno":0,"cid":6,"name":"status","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_updated_at","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_updated_at ON session_nodes(updated_at DESC, session_key)","terms":[{"seqno":0,"cid":5,"name":"updated_at","desc":1,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_session_nodes_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[{"name":"session_nodes_canonical_pending_after_delete","sql":"CREATE TRIGGER session_nodes_canonical_pending_after_delete AFTER DELETE ON session_nodes BEGIN DELETE FROM session_canonical_validation_pending WHERE session_key = OLD.session_key; END"},{"name":"session_nodes_canonical_pending_after_insert","sql":"CREATE TRIGGER session_nodes_canonical_pending_after_insert AFTER INSERT ON session_nodes BEGIN INSERT INTO session_canonical_validation_pending (session_key) SELECT NEW.session_key WHERE NOT EXISTS ( SELECT 1 FROM session_canonical_validation_pending WHERE session_key = NEW.session_key ); END"},{"name":"session_nodes_canonical_pending_after_update","sql":"CREATE TRIGGER session_nodes_canonical_pending_after_update AFTER UPDATE OF session_key, current_session_id, entry_json, entry_valid, parent_session_key, spawned_by, fork_source_session_key ON session_nodes WHEN OLD.session_key IS NOT NEW.session_key OR OLD.current_session_id IS NOT NEW.current_session_id OR OLD.entry_json IS NOT NEW.entry_json OR OLD.entry_valid IS NOT NEW.entry_valid OR OLD.parent_session_key IS NOT NEW.parent_session_key OR OLD.spawned_by IS NOT NEW.spawned_by OR OLD.fork_source_session_key IS NOT NEW.fork_source_session_key BEGIN DELETE FROM session_canonical_validation_pending WHERE session_key = OLD.session_key AND OLD.session_key IS NOT NEW.session_key; INSERT INTO session_canonical_validation_pending (session_key) SELECT NEW.session_key WHERE NOT EXISTS ( SELECT 1 FROM session_canonical_validation_pending WHERE session_key = NEW.session_key ); END"},{"name":"session_nodes_entry_valid_after_entry_update","sql":"CREATE TRIGGER session_nodes_entry_valid_after_entry_update AFTER UPDATE OF entry_json ON session_nodes BEGIN UPDATE session_nodes SET entry_valid = 0 WHERE session_key = NEW.session_key; END"},{"name":"session_nodes_entry_valid_after_identity_update","sql":"CREATE TRIGGER session_nodes_entry_valid_after_identity_update AFTER UPDATE OF current_session_id, updated_at ON session_nodes BEGIN UPDATE session_nodes SET entry_valid = 0 WHERE session_key = NEW.session_key; END"},{"name":"session_nodes_entry_valid_after_insert","sql":"CREATE TRIGGER session_nodes_entry_valid_after_insert AFTER INSERT ON session_nodes BEGIN UPDATE session_nodes SET entry_valid = 0 WHERE session_key = NEW.session_key; END"}]},{"name":"session_windows","sql":"CREATE TABLE session_windows ( session_id TEXT NOT NULL PRIMARY KEY, session_key TEXT NOT NULL, previous_session_id TEXT, reason TEXT CHECK (reason IS NULL OR reason IN ('initial', 'reset', 'rollover', 'fork', 'rewind', 'switch', 'recovery', 'compaction')), session_scope TEXT NOT NULL DEFAULT 'conversation' CHECK (session_scope IN ('conversation', 'shared-main', 'group', 'channel')), created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL, transcript_updated_at INTEGER DEFAULT NULL, row_transcript_json TEXT, row_transcript_updated_at INTEGER, transcript_observed_at INTEGER DEFAULT NULL, session_entry_provenance INTEGER NOT NULL DEFAULT 0 CHECK (session_entry_provenance IN (0, 1)), acp_owned INTEGER NOT NULL DEFAULT 0 CHECK (acp_owned IN (0, 1)), plugin_owner_id TEXT, hook_external_content_source TEXT CHECK (hook_external_content_source IS NULL OR hook_external_content_source IN ('gmail', 'webhook')), started_at INTEGER, ended_at INTEGER, status TEXT CHECK (status IS NULL OR status IN ('running', 'done', 'failed', 'killed', 'timeout')), chat_type TEXT CHECK (chat_type IS NULL OR chat_type IN ('direct', 'group', 'channel')), channel TEXT, account_id TEXT, primary_conversation_id TEXT, model_provider TEXT, model TEXT, agent_harness_id TEXT, parent_session_key TEXT, spawned_by TEXT, display_name TEXT, FOREIGN KEY (session_key) REFERENCES session_nodes(session_key) ON DELETE CASCADE, FOREIGN KEY (primary_conversation_id) REFERENCES conversations(conversation_id) ON DELETE SET NULL ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"session_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"session_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":2,"name":"previous_session_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"reason","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"session_scope","type":"TEXT","notnull":1,"dflt_value":"'conversation'","pk":0,"hidden":0},{"cid":5,"name":"created_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":6,"name":"updated_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":7,"name":"transcript_updated_at","type":"INTEGER","notnull":0,"dflt_value":"NULL","pk":0,"hidden":0},{"cid":8,"name":"row_transcript_json","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":9,"name":"row_transcript_updated_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":10,"name":"transcript_observed_at","type":"INTEGER","notnull":0,"dflt_value":"NULL","pk":0,"hidden":0},{"cid":11,"name":"session_entry_provenance","type":"INTEGER","notnull":1,"dflt_value":"0","pk":0,"hidden":0},{"cid":12,"name":"acp_owned","type":"INTEGER","notnull":1,"dflt_value":"0","pk":0,"hidden":0},{"cid":13,"name":"plugin_owner_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":14,"name":"hook_external_content_source","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":15,"name":"started_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":16,"name":"ended_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":17,"name":"status","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":18,"name":"chat_type","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":19,"name":"channel","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":20,"name":"account_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":21,"name":"primary_conversation_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":22,"name":"model_provider","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":23,"name":"model","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":24,"name":"agent_harness_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":25,"name":"parent_session_key","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":26,"name":"spawned_by","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":27,"name":"display_name","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[{"id":0,"seq":0,"table":"conversations","from":"primary_conversation_id","to":"conversation_id","on_update":"NO ACTION","on_delete":"SET NULL","match":"NONE"},{"id":1,"seq":0,"table":"session_nodes","from":"session_key","to":"session_key","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"}],"indexes":[{"name":"idx_agent_session_windows_conversation","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_session_windows_conversation ON session_windows(primary_conversation_id, updated_at DESC, session_id) WHERE primary_conversation_id IS NOT NULL","terms":[{"seqno":0,"cid":21,"name":"primary_conversation_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":6,"name":"updated_at","desc":1,"coll":"BINARY","key":1},{"seqno":2,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":3,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_windows_created_at","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_windows_created_at ON session_windows(created_at DESC, session_id)","terms":[{"seqno":0,"cid":5,"name":"created_at","desc":1,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_windows_session_key","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_windows_session_key ON session_windows(session_key, updated_at DESC, session_id)","terms":[{"seqno":0,"cid":1,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":6,"name":"updated_at","desc":1,"coll":"BINARY","key":1},{"seqno":2,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":3,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_windows_updated_at","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_windows_updated_at ON session_windows(updated_at DESC, session_id)","terms":[{"seqno":0,"cid":6,"name":"updated_at","desc":1,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_session_windows_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[{"name":"session_windows_canonical_pending_after_delete","sql":"CREATE TRIGGER session_windows_canonical_pending_after_delete AFTER DELETE ON session_windows BEGIN INSERT INTO session_canonical_validation_pending (session_key) SELECT node.session_key FROM session_nodes AS node WHERE node.current_session_id = OLD.session_id AND NOT EXISTS ( SELECT 1 FROM session_canonical_validation_pending AS pending WHERE pending.session_key = node.session_key ); END"},{"name":"session_windows_canonical_pending_after_insert","sql":"CREATE TRIGGER session_windows_canonical_pending_after_insert AFTER INSERT ON session_windows BEGIN INSERT INTO session_canonical_validation_pending (session_key) SELECT node.session_key FROM session_nodes AS node WHERE node.current_session_id = NEW.session_id AND NOT EXISTS ( SELECT 1 FROM session_canonical_validation_pending AS pending WHERE pending.session_key = node.session_key ); END"},{"name":"session_windows_canonical_pending_after_update","sql":"CREATE TRIGGER session_windows_canonical_pending_after_update AFTER UPDATE OF session_id, session_key ON session_windows WHEN OLD.session_id IS NOT NEW.session_id OR OLD.session_key IS NOT NEW.session_key BEGIN INSERT INTO session_canonical_validation_pending (session_key) SELECT node.session_key FROM session_nodes AS node WHERE node.current_session_id IN (OLD.session_id, NEW.session_id) AND NOT EXISTS ( SELECT 1 FROM session_canonical_validation_pending AS pending WHERE pending.session_key = node.session_key ); END"}]},{"name":"session_transcript_fts_rows","sql":"CREATE TABLE session_transcript_fts_rows ( session_id TEXT NOT NULL, fts_rowid INTEGER NOT NULL PRIMARY KEY ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"session_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":1,"name":"fts_rowid","type":"INTEGER","notnull":1,"dflt_value":null,"pk":1,"hidden":0}],"foreignKeys":[],"indexes":[{"name":"idx_agent_transcript_fts_rows_session","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_transcript_fts_rows_session ON session_transcript_fts_rows(session_id)","terms":[{"seqno":0,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"session_transcript_index_state","sql":"CREATE TABLE session_transcript_index_state ( session_id TEXT NOT NULL PRIMARY KEY, indexed_seq INTEGER NOT NULL, leaf_event_id TEXT, needs_rebuild INTEGER NOT NULL DEFAULT 0, active_event_count INTEGER NOT NULL DEFAULT 0, active_message_count INTEGER NOT NULL DEFAULT 0, fts_row_count INTEGER, updated_at INTEGER NOT NULL, FOREIGN KEY (session_id) REFERENCES session_windows(session_id) ON DELETE CASCADE ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"session_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"indexed_seq","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":2,"name":"leaf_event_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"needs_rebuild","type":"INTEGER","notnull":1,"dflt_value":"0","pk":0,"hidden":0},{"cid":4,"name":"active_event_count","type":"INTEGER","notnull":1,"dflt_value":"0","pk":0,"hidden":0},{"cid":5,"name":"active_message_count","type":"INTEGER","notnull":1,"dflt_value":"0","pk":0,"hidden":0},{"cid":6,"name":"fts_row_count","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":7,"name":"updated_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[{"id":0,"seq":0,"table":"session_windows","from":"session_id","to":"session_id","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"}],"indexes":[{"name":"sqlite_autoindex_session_transcript_index_state_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"memory_index_chunks","sql":"CREATE TABLE memory_index_chunks ( chunk_rowid INTEGER PRIMARY KEY, id TEXT NOT NULL UNIQUE, path TEXT NOT NULL, source TEXT NOT NULL DEFAULT 'memory', start_line INTEGER NOT NULL, end_line INTEGER NOT NULL, hash TEXT NOT NULL, model TEXT NOT NULL, text TEXT NOT NULL, embedding BLOB NOT NULL, updated_at INTEGER NOT NULL ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"chunk_rowid","type":"INTEGER","notnull":0,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"id","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":2,"name":"path","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"source","type":"TEXT","notnull":1,"dflt_value":"'memory'","pk":0,"hidden":0},{"cid":4,"name":"start_line","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"end_line","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":6,"name":"hash","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":7,"name":"model","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":8,"name":"text","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":9,"name":"embedding","type":"BLOB","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":10,"name":"updated_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[{"name":"idx_memory_index_chunks_path_source","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_memory_index_chunks_path_source ON memory_index_chunks(path, source)","terms":[{"seqno":0,"cid":2,"name":"path","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":3,"name":"source","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_memory_index_chunks_source","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_memory_index_chunks_source ON memory_index_chunks(source)","terms":[{"seqno":0,"cid":3,"name":"source","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_memory_index_chunks_1","origin":"u","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":1,"name":"id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[{"name":"memory_index_chunks_revision_after_delete","sql":"CREATE TRIGGER memory_index_chunks_revision_after_delete AFTER DELETE ON memory_index_chunks BEGIN UPDATE memory_index_state SET revision = revision + 1 WHERE id = 1; END"},{"name":"memory_index_chunks_revision_after_insert","sql":"CREATE TRIGGER memory_index_chunks_revision_after_insert AFTER INSERT ON memory_index_chunks BEGIN UPDATE memory_index_state SET revision = revision + 1 WHERE id = 1; END"},{"name":"memory_index_chunks_revision_after_update","sql":"CREATE TRIGGER memory_index_chunks_revision_after_update AFTER UPDATE ON memory_index_chunks BEGIN UPDATE memory_index_state SET revision = revision + 1 WHERE id = 1; END"}]},{"name":"transcript_events","sql":"CREATE TABLE transcript_events ( session_id TEXT NOT NULL, seq INTEGER NOT NULL, event_json TEXT, created_at INTEGER NOT NULL, event_zstd BLOB, event_utf8_bytes INTEGER CHECK (event_utf8_bytes IS NULL OR event_utf8_bytes >= 0), navigation_json TEXT, PRIMARY KEY (session_id, seq), FOREIGN KEY (session_id) REFERENCES \"session_windows\"(session_id) ON DELETE CASCADE, 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 length(event_zstd) BETWEEN 1 AND 4194304 AND navigation_json IS NOT NULL ) ), CHECK ( navigation_json IS NULL OR CASE WHEN json_valid(navigation_json) THEN coalesce( octet_length(navigation_json) <= 16384 AND json_type(navigation_json, '$.version') = 'integer' AND json_extract(navigation_json, '$.version') = 1 AND json_type(navigation_json, '$.report') = 'object' AND json_extract(navigation_json, '$.report.kind') IN ('canonical', 'leaf', 'link', 'ignored') AND json_type(navigation_json, '$.navigation') = 'object' AND json_type(navigation_json, '$.reset') = 'object' AND json_type(navigation_json, '$.model') = 'object' AND json_type(navigation_json, '$.modelBytes') = 'integer' AND json_extract(navigation_json, '$.modelBytes') BETWEEN 0 AND 4194304 AND json_type(navigation_json, '$.modelWithoutCheckpointBytes') = 'integer' AND json_extract(navigation_json, '$.modelWithoutCheckpointBytes') BETWEEN 0 AND 4194304 AND json_type(navigation_json, '$.withoutCustomDataBytes') = 'integer' AND json_extract(navigation_json, '$.withoutCustomDataBytes') BETWEEN 0 AND 4194304, 0) ELSE 0 END ) ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"session_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"seq","type":"INTEGER","notnull":1,"dflt_value":null,"pk":2,"hidden":0},{"cid":2,"name":"event_json","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"created_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"event_zstd","type":"BLOB","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"event_utf8_bytes","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":6,"name":"navigation_json","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[{"id":0,"seq":0,"table":"session_windows","from":"session_id","to":"session_id","on_update":"NO ACTION","on_delete":"CASCADE","match":"NONE"}],"indexes":[{"name":"sqlite_autoindex_transcript_events_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":1,"name":"seq","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"session_nodes","sql":"CREATE TABLE session_nodes ( session_key TEXT NOT NULL PRIMARY KEY, current_session_id TEXT NOT NULL, entry_json TEXT NOT NULL, snapshot_revision INTEGER NOT NULL DEFAULT 0, legacy_acp_migration_json TEXT, entry_valid INTEGER NOT NULL DEFAULT 0 CHECK (entry_valid IN (-1, 0, 1)), updated_at INTEGER NOT NULL, status TEXT CHECK (status IS NULL OR status IN ('running', 'done', 'failed', 'killed', 'timeout')), created_at INTEGER, created_via TEXT CHECK (created_via IS NULL OR created_via IN ('operator', 'spawn', 'channel', 'cron', 'talk', 'run', 'plugin', 'internal')), created_actor_type TEXT CHECK (created_actor_type IS NULL OR created_actor_type IN ('human', 'agent', 'system')), created_actor_id TEXT, owner_actor_type TEXT, owner_actor_id TEXT, owner_assigned_by_type TEXT, owner_assigned_by_id TEXT, owner_assigned_at INTEGER, project_id TEXT, parent_session_key TEXT, spawned_by TEXT, fork_source_session_key TEXT, fork_source_session_id TEXT, fork_source_entry_id TEXT, label TEXT, display_name TEXT, category TEXT, icon TEXT, pinned_at INTEGER, archived_at INTEGER, last_read_at INTEGER, last_interaction_at INTEGER, last_activity_at INTEGER ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"session_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"current_session_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":2,"name":"entry_json","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"snapshot_revision","type":"INTEGER","notnull":1,"dflt_value":"0","pk":0,"hidden":0},{"cid":4,"name":"legacy_acp_migration_json","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"entry_valid","type":"INTEGER","notnull":1,"dflt_value":"0","pk":0,"hidden":0},{"cid":6,"name":"updated_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":7,"name":"status","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":8,"name":"created_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":9,"name":"created_via","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":10,"name":"created_actor_type","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":11,"name":"created_actor_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":12,"name":"owner_actor_type","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":13,"name":"owner_actor_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":14,"name":"owner_assigned_by_type","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":15,"name":"owner_assigned_by_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":16,"name":"owner_assigned_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":17,"name":"project_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":18,"name":"parent_session_key","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":19,"name":"spawned_by","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":20,"name":"fork_source_session_key","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":21,"name":"fork_source_session_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":22,"name":"fork_source_entry_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":23,"name":"label","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":24,"name":"display_name","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":25,"name":"category","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":26,"name":"icon","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":27,"name":"pinned_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":28,"name":"archived_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":29,"name":"last_read_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":30,"name":"last_interaction_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":31,"name":"last_activity_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[{"name":"idx_agent_session_nodes_active","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_active ON session_nodes(session_key) WHERE archived_at IS NULL","terms":[{"seqno":0,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_archived_at","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_archived_at ON session_nodes(archived_at, session_key) WHERE archived_at IS NOT NULL","terms":[{"seqno":0,"cid":28,"name":"archived_at","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_current_session_id","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_current_session_id ON session_nodes(current_session_id)","terms":[{"seqno":0,"cid":1,"name":"current_session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_entry_not_valid","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_entry_not_valid ON session_nodes(session_key) WHERE entry_valid != 1","terms":[{"seqno":0,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_entry_valid_pending","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_entry_valid_pending ON session_nodes(session_key) WHERE entry_valid = 0","terms":[{"seqno":0,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_label","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_label ON session_nodes(label, session_key) WHERE label IS NOT NULL","terms":[{"seqno":0,"cid":23,"name":"label","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_last_interaction_at","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_last_interaction_at ON session_nodes(last_interaction_at DESC, session_key)","terms":[{"seqno":0,"cid":30,"name":"last_interaction_at","desc":1,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_parent_session_key","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_parent_session_key ON session_nodes(parent_session_key, session_key)","terms":[{"seqno":0,"cid":18,"name":"parent_session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_spawned_by","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_spawned_by ON session_nodes(spawned_by, session_key)","terms":[{"seqno":0,"cid":19,"name":"spawned_by","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_status","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_status ON session_nodes(status, session_key) WHERE status IS NOT NULL","terms":[{"seqno":0,"cid":7,"name":"status","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_updated_at","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_updated_at ON session_nodes(updated_at DESC, session_key)","terms":[{"seqno":0,"cid":6,"name":"updated_at","desc":1,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_session_nodes_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[{"name":"session_nodes_canonical_pending_after_delete","sql":"CREATE TRIGGER session_nodes_canonical_pending_after_delete AFTER DELETE ON session_nodes BEGIN DELETE FROM session_canonical_validation_pending WHERE session_key = OLD.session_key; END"},{"name":"session_nodes_canonical_pending_after_insert","sql":"CREATE TRIGGER session_nodes_canonical_pending_after_insert AFTER INSERT ON session_nodes BEGIN INSERT INTO session_canonical_validation_pending (session_key) SELECT NEW.session_key WHERE NOT EXISTS ( SELECT 1 FROM session_canonical_validation_pending WHERE session_key = NEW.session_key ); END"},{"name":"session_nodes_canonical_pending_after_update","sql":"CREATE TRIGGER session_nodes_canonical_pending_after_update AFTER UPDATE OF session_key, current_session_id, entry_json, entry_valid, parent_session_key, spawned_by, fork_source_session_key ON session_nodes WHEN OLD.session_key IS NOT NEW.session_key OR OLD.current_session_id IS NOT NEW.current_session_id OR OLD.entry_json IS NOT NEW.entry_json OR OLD.entry_valid IS NOT NEW.entry_valid OR OLD.parent_session_key IS NOT NEW.parent_session_key OR OLD.spawned_by IS NOT NEW.spawned_by OR OLD.fork_source_session_key IS NOT NEW.fork_source_session_key BEGIN DELETE FROM session_canonical_validation_pending WHERE session_key = OLD.session_key AND OLD.session_key IS NOT NEW.session_key; INSERT INTO session_canonical_validation_pending (session_key) SELECT NEW.session_key WHERE NOT EXISTS ( SELECT 1 FROM session_canonical_validation_pending WHERE session_key = NEW.session_key ); END"},{"name":"session_nodes_entry_valid_after_entry_update","sql":"CREATE TRIGGER session_nodes_entry_valid_after_entry_update AFTER UPDATE OF entry_json ON session_nodes BEGIN UPDATE session_nodes SET entry_valid = 0 WHERE session_key = NEW.session_key; END"},{"name":"session_nodes_entry_valid_after_identity_update","sql":"CREATE TRIGGER session_nodes_entry_valid_after_identity_update AFTER UPDATE OF current_session_id, updated_at ON session_nodes BEGIN UPDATE session_nodes SET entry_valid = 0 WHERE session_key = NEW.session_key; END"},{"name":"session_nodes_entry_valid_after_insert","sql":"CREATE TRIGGER session_nodes_entry_valid_after_insert AFTER INSERT ON session_nodes BEGIN UPDATE session_nodes SET entry_valid = 0 WHERE session_key = NEW.session_key; END"}]},{"name":"session_nodes","sql":"CREATE TABLE session_nodes ( session_key TEXT NOT NULL PRIMARY KEY, current_session_id TEXT NOT NULL, entry_json TEXT NOT NULL, snapshot_revision INTEGER NOT NULL DEFAULT 0, legacy_acp_migration_json TEXT, entry_valid INTEGER NOT NULL DEFAULT 0 CHECK (entry_valid IN (-1, 0, 1)), updated_at INTEGER NOT NULL, status TEXT CHECK (status IS NULL OR status IN ('running', 'done', 'failed', 'killed', 'timeout')), created_at INTEGER, created_via TEXT CHECK (created_via IS NULL OR created_via IN ('operator', 'spawn', 'channel', 'cron', 'talk', 'run', 'plugin', 'internal')), created_actor_type TEXT CHECK (created_actor_type IS NULL OR created_actor_type IN ('human', 'agent', 'system')), created_actor_id TEXT, owner_actor_type TEXT, owner_actor_id TEXT, owner_assigned_by_type TEXT, owner_assigned_by_id TEXT, owner_assigned_at INTEGER, project_id TEXT, parent_session_key TEXT, spawned_by TEXT, fork_source_session_key TEXT, fork_source_session_id TEXT, fork_source_entry_id TEXT, label TEXT, display_name TEXT, category TEXT, icon TEXT, pinned_at INTEGER, archived_at INTEGER, last_read_at INTEGER, last_interaction_at INTEGER, last_activity_at INTEGER ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"session_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"current_session_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":2,"name":"entry_json","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"snapshot_revision","type":"INTEGER","notnull":1,"dflt_value":"0","pk":0,"hidden":0},{"cid":4,"name":"legacy_acp_migration_json","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"entry_valid","type":"INTEGER","notnull":1,"dflt_value":"0","pk":0,"hidden":0},{"cid":6,"name":"updated_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":7,"name":"status","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":8,"name":"created_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":9,"name":"created_via","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":10,"name":"created_actor_type","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":11,"name":"created_actor_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":12,"name":"owner_actor_type","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":13,"name":"owner_actor_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":14,"name":"owner_assigned_by_type","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":15,"name":"owner_assigned_by_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":16,"name":"owner_assigned_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":17,"name":"project_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":18,"name":"parent_session_key","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":19,"name":"spawned_by","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":20,"name":"fork_source_session_key","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":21,"name":"fork_source_session_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":22,"name":"fork_source_entry_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":23,"name":"label","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":24,"name":"display_name","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":25,"name":"category","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":26,"name":"icon","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":27,"name":"pinned_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":28,"name":"archived_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":29,"name":"last_read_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":30,"name":"last_interaction_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":31,"name":"last_activity_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[{"name":"idx_agent_session_nodes_active","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_active ON session_nodes(session_key) WHERE archived_at IS NULL","terms":[{"seqno":0,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_archived_at","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_archived_at ON session_nodes(archived_at, session_key) WHERE archived_at IS NOT NULL","terms":[{"seqno":0,"cid":28,"name":"archived_at","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_current_session_id","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_current_session_id ON session_nodes(current_session_id)","terms":[{"seqno":0,"cid":1,"name":"current_session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_entry_not_valid","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_entry_not_valid ON session_nodes(session_key) WHERE entry_valid != 1","terms":[{"seqno":0,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_entry_valid_pending","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_entry_valid_pending ON session_nodes(session_key) WHERE entry_valid = 0","terms":[{"seqno":0,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_label","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_label ON session_nodes(label, session_key) WHERE label IS NOT NULL","terms":[{"seqno":0,"cid":23,"name":"label","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_last_interaction_at","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_last_interaction_at ON session_nodes(last_interaction_at DESC, session_key)","terms":[{"seqno":0,"cid":30,"name":"last_interaction_at","desc":1,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_parent_session_key","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_parent_session_key ON session_nodes(parent_session_key, session_key)","terms":[{"seqno":0,"cid":18,"name":"parent_session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_spawned_by","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_spawned_by ON session_nodes(spawned_by, session_key)","terms":[{"seqno":0,"cid":19,"name":"spawned_by","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_status","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_status ON session_nodes(status, session_key) WHERE status IS NOT NULL","terms":[{"seqno":0,"cid":7,"name":"status","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_updated_at","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_updated_at ON session_nodes(updated_at DESC, session_key)","terms":[{"seqno":0,"cid":6,"name":"updated_at","desc":1,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_session_nodes_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"context_engine_turn_outbox","sql":"CREATE TABLE context_engine_turn_outbox ( advancement_key TEXT NOT NULL PRIMARY KEY, engine_id TEXT NOT NULL, owner_plugin_id TEXT, session_id TEXT NOT NULL, payload_json TEXT NOT NULL, payload_state TEXT, attempt_count INTEGER NOT NULL DEFAULT 0, last_attempt_at INTEGER, last_error TEXT, created_at INTEGER NOT NULL ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"advancement_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"engine_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":2,"name":"owner_plugin_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"session_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"payload_json","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"payload_state","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":6,"name":"attempt_count","type":"INTEGER","notnull":1,"dflt_value":"0","pk":0,"hidden":0},{"cid":7,"name":"last_attempt_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":8,"name":"last_error","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":9,"name":"created_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[{"name":"idx_agent_context_engine_turn_outbox_engine","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_context_engine_turn_outbox_engine ON context_engine_turn_outbox(engine_id, created_at)","terms":[{"seqno":0,"cid":1,"name":"engine_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":9,"name":"created_at","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_context_engine_turn_outbox_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"advancement_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"session_nodes","sql":"CREATE TABLE session_nodes ( session_key TEXT NOT NULL PRIMARY KEY, current_session_id TEXT NOT NULL, entry_json TEXT NOT NULL, session_started_at INTEGER, has_optional_references INTEGER NOT NULL DEFAULT 0, snapshot_revision INTEGER NOT NULL DEFAULT 0, legacy_acp_migration_json TEXT, entry_valid INTEGER NOT NULL DEFAULT 0 CHECK (entry_valid IN (-1, 0, 1)), updated_at INTEGER NOT NULL, status TEXT CHECK (status IS NULL OR status IN ('running', 'done', 'failed', 'killed', 'timeout')), created_at INTEGER, created_via TEXT CHECK (created_via IS NULL OR created_via IN ('operator', 'spawn', 'channel', 'cron', 'talk', 'run', 'plugin', 'internal')), created_actor_type TEXT CHECK (created_actor_type IS NULL OR created_actor_type IN ('human', 'agent', 'system')), created_actor_id TEXT, owner_actor_type TEXT, owner_actor_id TEXT, owner_assigned_by_type TEXT, owner_assigned_by_id TEXT, owner_assigned_at INTEGER, project_id TEXT, parent_session_key TEXT, spawned_by TEXT, fork_source_session_key TEXT, fork_source_session_id TEXT, fork_source_entry_id TEXT, label TEXT, display_name TEXT, category TEXT, icon TEXT, pinned_at INTEGER, archived_at INTEGER, last_read_at INTEGER, last_interaction_at INTEGER, last_activity_at INTEGER ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"session_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"current_session_id","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":2,"name":"entry_json","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"session_started_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"has_optional_references","type":"INTEGER","notnull":1,"dflt_value":"0","pk":0,"hidden":0},{"cid":5,"name":"snapshot_revision","type":"INTEGER","notnull":1,"dflt_value":"0","pk":0,"hidden":0},{"cid":6,"name":"legacy_acp_migration_json","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":7,"name":"entry_valid","type":"INTEGER","notnull":1,"dflt_value":"0","pk":0,"hidden":0},{"cid":8,"name":"updated_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":9,"name":"status","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":10,"name":"created_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":11,"name":"created_via","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":12,"name":"created_actor_type","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":13,"name":"created_actor_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":14,"name":"owner_actor_type","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":15,"name":"owner_actor_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":16,"name":"owner_assigned_by_type","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":17,"name":"owner_assigned_by_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":18,"name":"owner_assigned_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":19,"name":"project_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":20,"name":"parent_session_key","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":21,"name":"spawned_by","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":22,"name":"fork_source_session_key","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":23,"name":"fork_source_session_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":24,"name":"fork_source_entry_id","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":25,"name":"label","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":26,"name":"display_name","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":27,"name":"category","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":28,"name":"icon","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":29,"name":"pinned_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":30,"name":"archived_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":31,"name":"last_read_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":32,"name":"last_interaction_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":33,"name":"last_activity_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[{"name":"idx_agent_session_nodes_active","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_active ON session_nodes(session_key) WHERE archived_at IS NULL","terms":[{"seqno":0,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_archived_at","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_archived_at ON session_nodes(archived_at, session_key) WHERE archived_at IS NOT NULL","terms":[{"seqno":0,"cid":30,"name":"archived_at","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_current_session_id","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_current_session_id ON session_nodes(current_session_id)","terms":[{"seqno":0,"cid":1,"name":"current_session_id","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_entry_not_valid","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_entry_not_valid ON session_nodes(session_key) WHERE entry_valid != 1","terms":[{"seqno":0,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_entry_valid_pending","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_entry_valid_pending ON session_nodes(session_key) WHERE entry_valid = 0","terms":[{"seqno":0,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_label","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_label ON session_nodes(label, session_key) WHERE label IS NOT NULL","terms":[{"seqno":0,"cid":25,"name":"label","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_last_interaction_at","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_last_interaction_at ON session_nodes(last_interaction_at DESC, session_key)","terms":[{"seqno":0,"cid":32,"name":"last_interaction_at","desc":1,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_parent_session_key","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_parent_session_key ON session_nodes(parent_session_key, session_key)","terms":[{"seqno":0,"cid":20,"name":"parent_session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_spawned_by","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_spawned_by ON session_nodes(spawned_by, session_key)","terms":[{"seqno":0,"cid":21,"name":"spawned_by","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_status","origin":"c","partial":1,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_status ON session_nodes(status, session_key) WHERE status IS NOT NULL","terms":[{"seqno":0,"cid":9,"name":"status","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"idx_agent_session_nodes_updated_at","origin":"c","partial":0,"unique":0,"sql":"CREATE INDEX idx_agent_session_nodes_updated_at ON session_nodes(updated_at DESC, session_key)","terms":[{"seqno":0,"cid":8,"name":"updated_at","desc":1,"coll":"BINARY","key":1},{"seqno":1,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]},{"name":"sqlite_autoindex_session_nodes_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"session_key","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]},{"name":"state_leases","sql":"CREATE TABLE state_leases ( scope TEXT NOT NULL, lease_key TEXT NOT NULL, owner TEXT NOT NULL, expires_at INTEGER, heartbeat_at INTEGER, payload_json TEXT, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL, PRIMARY KEY (scope, lease_key) ) STRICT","strict":1,"withoutRowid":0,"columns":[{"cid":0,"name":"scope","type":"TEXT","notnull":1,"dflt_value":null,"pk":1,"hidden":0},{"cid":1,"name":"lease_key","type":"TEXT","notnull":1,"dflt_value":null,"pk":2,"hidden":0},{"cid":2,"name":"owner","type":"TEXT","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":3,"name":"expires_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":4,"name":"heartbeat_at","type":"INTEGER","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":5,"name":"payload_json","type":"TEXT","notnull":0,"dflt_value":null,"pk":0,"hidden":0},{"cid":6,"name":"created_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0},{"cid":7,"name":"updated_at","type":"INTEGER","notnull":1,"dflt_value":null,"pk":0,"hidden":0}],"foreignKeys":[],"indexes":[{"name":"sqlite_autoindex_state_leases_1","origin":"pk","partial":0,"unique":1,"sql":null,"terms":[{"seqno":0,"cid":0,"name":"scope","desc":0,"coll":"BINARY","key":1},{"seqno":1,"cid":1,"name":"lease_key","desc":0,"coll":"BINARY","key":1},{"seqno":2,"cid":-1,"name":null,"desc":0,"coll":"BINARY","key":0}]}],"triggers":[]}],"catalogs":{"d6ea4f25014de415b806f2b77b529b838444f8aacf44cb2192ba6990fdfab566":{"tables":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56],"views":[]},"0d8863d033ed867b9e5410fbf5653fff5668cde5bc9933efdc54a948ef28b3a7":{"tables":[0,1,2,3,4,5,57,58,8,9,59,60,12,13,61,15,62,17,18,19,20,22,24,63,26,27,64,65,30,31,66,33,34,35,37,38,39,40,41,42,43,45,67,47,48,49,50,51,52,68,69,70,56],"views":[]},"987c7895f0acfaa27bdd4af5532a6a9d7364cbbefe8fe63fa9775b9520b25f85":{"tables":[0,1,2,3,4,5,57,58,8,9,59,60,12,13,61,15,62,17,18,19,20,22,24,63,26,27,64,29,30,31,66,33,34,35,37,38,39,40,41,42,43,45,67,47,48,49,50,51,52,68,69,70,56],"views":[]},"7a92498057481f996a0c0716dd078ea69694645fbdb3a011dadaee411478b7ad":{"tables":[0,1,2,3,4,5,57,58,8,9,59,60,12,13,61,15,62,17,18,19,20,21,22,24,63,71,27,72,29,30,31,66,33,34,35,37,38,39,40,41,42,43,45,73,47,48,49,50,51,52,68,69,70,56],"views":[]},"789a67b22bc47d0b58acb19a6041b3ba55bd68c7e7271a4043573739edae02d1":{"tables":[0,1,2,3,4,5,57,58,8,9,59,60,12,13,61,15,62,17,18,19,20,21,22,24,63,71,27,72,29,30,31,66,33,34,35,37,38,39,40,41,42,43,74,75,73,47,48,49,50,51,52,68,69,70,56],"views":[]},"dd91f9df477a6b80f156003269b951f0d4e55d62e6dec37ad23dc909ed61f71f":{"tables":[0,1,2,3,4,5,57,58,8,9,10,60,12,13,76,15,62,17,18,19,20,21,22,24,63,71,27,72,29,30,31,66,33,34,35,37,38,39,40,41,42,43,44,45,73,47,48,49,50,51,52,68,69,77,56],"views":[]},"9b51fb6f3b7692ed5b1d114c9123184aacb35d5c8450f896b5d289fd46f0ae60":{"tables":[0,1,2,3,4,5,57,58,8,9,10,60,12,13,76,15,62,17,18,19,20,21,22,23,24,63,71,27,78,29,30,31,66,33,34,35,37,38,39,40,41,42,43,44,45,73,47,48,49,50,51,52,68,69,77,56],"views":[]},"17cbb50319db12e22248e0397cb068ce670687a96328f502ce3577e4798ae299":{"tables":[0,1,2,3,4,5,57,58,8,9,10,60,12,13,76,15,62,17,18,19,20,21,22,23,24,63,26,27,79,29,30,31,66,33,34,35,37,38,39,40,41,42,43,44,45,67,47,48,49,50,51,52,68,69,77,56],"views":[]},"ff21eb3fb5a5836d520af3ea0777944cbcfa61aff52a64d0726a4d6b527823c3":{"tables":[0,1,2,3,4,5,80,58,8,9,10,60,12,13,76,15,62,17,18,19,20,21,22,23,24,63,26,27,81,29,30,31,66,33,34,35,37,38,39,40,41,42,43,44,45,67,47,48,49,50,51,52,68,69,55,56],"views":[]},"227fcd299f5dfd3012abd0f110cd028ba6add9155bc74e2e558aadeae2761349":{"tables":[0,1,2,3,4,5,6,58,8,9,10,60,12,13,76,15,62,17,18,19,20,21,22,23,24,63,26,27,81,29,30,31,66,33,34,35,37,38,39,40,41,42,43,44,45,67,47,48,49,50,51,52,68,69,55,56],"views":[]},"b2e17ebad450773253e5dddaeb87e6baef26b1c20a48982ed9df7ffea4210511":{"tables":[0,1,2,3,4,5,6,58,8,9,10,11,12,13,76,15,62,17,18,19,20,21,22,23,24,63,26,27,81,29,30,31,66,33,34,35,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,68,54,55,56],"views":[]},"abf65b8c18ccb84f0e65b8e4faa6fef6abc23b6bab5e93086339f640d2146082":{"tables":[0,1,2,3,4,5,6,58,8,9,10,11,12,13,76,15,62,17,18,19,20,21,22,23,24,63,26,27,28,29,30,31,32,33,34,35,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,68,54,55,56],"views":[]},"dbab54723ad6be5e0146085df0789ef92d03b867c53bed915d804fb4c60b3068":{"tables":[0,1,2,3,4,5,6,58,8,9,10,11,12,13,76,15,62,17,18,19,20,21,22,23,24,63,26,27,28,29,30,31,32,33,34,35,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56],"views":[]},"57f4523156caf6b8446afbd95e0fede01f1c917771242cd05c61c1b48b7e157e":{"tables":[0,1,2,3,4,5,6,58,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,63,26,27,28,29,30,31,32,33,34,35,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56],"views":[]},"9ffa671518cafee606f88dd17bfdfa9792d9deece5f6773e3cae4de2c10fc84b":{"tables":[0,1,2,3,4,5,6,58,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,63,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56],"views":[]},"067f95cffb76737d9084b726b640bc79b266b19279e6b1a3d2322d0e298c6ab6":{"tables":[0,1,2,5,57,58,8,9,59,60,12,13,61,15,62,17,18,19,20,22,24,63,26,64,65,30,34,35,37,38,39,40,41,42,43,45,67,47,48,49,50,51,52,68,69,70,56],"views":[]},"aca181a3ea4d5a94d263653e1b75d2327bd449673d631e9d22c6cb9fe25e40ea":{"tables":[27],"views":[]},"be5d39d4389597fcfe2942f51a97d5b1f4e0aa1d6b184677e6abcedc162a2cf0":{"tables":[66,33],"views":[]},"9b07b30dc725415736f5873babff2b98a1e8bf40e0afbf4eb8cf3d3cf700dc0b":{"tables":[3,4],"views":[]},"83673559dc6bba9fdf13d5a9131b030103935b04d7c81620b0a67f43cb49f970":{"tables":[31],"views":[]},"fdc21b6dc361c491311c11d91fbda296535a9c34dd20f0ab03b949b8a698ded0":{"tables":[82],"views":[]},"c45b82b3c3aa8ecc3b2cc09dcf38bd568edfa8305f54b5bb959c975a55571ece":{"tables":[65],"views":[]},"6ce6f0ae658b1b77759d335e07e75d9371e27363c998bbf9b0e5fc5a132bc4cb":{"tables":[74],"views":[]},"0e9e5f47efa71d187ed505aee8d1e423865a5de8df5387a15759194561307e72":{"tables":[70],"views":[]}}}