openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
8,758 lines • 750 kB
JavaScript
import{r as e,t}from"./openclaw-state-read-semver-CqfGj9gv.mjs";import{rt as n}from"./openclaw-state-read-sqlite-readonly-worker-umlSCyCR.mjs";import{V as r,X as i,Z as a,et as o,q as s}from"./openclaw-state-read-map-size-DJbMcZYM.mjs";import{v as c}from"./openclaw-state-read-home-dir-BQZX1pD2.mjs";import{$t as l,Bt as u,Dt as d,Kt as f,M as p,Nt as m,S as h,X as g,Y as ee,an as _,ct as te,ft as ne,jt as re,p as ie,s as ae,ut as oe,vt as v,x as se}from"./openclaw-state-read-sqlite-database-admission-Ck6VG7rE.mjs";import{a as ce,c as le,l as ue,o as de,u as fe}from"./openclaw-state-read-pool-1Cp_Z7yz.mjs";import{t as pe}from"./openclaw-state-read-promise-like-3qqJObCs.mjs";import{E as me,R as he,W as y,_ as ge,h as _e,o as ve,z as ye}from"./openclaw-state-read-openclaw-state-db-cache-BVY8IYkn.mjs";import{K as be,s as xe}from"./openclaw-state-read-logger-Ix7jXPG1.mjs";import{c as Se,i as Ce,l as we,n as Te,r as Ee,t as De,u as Oe}from"./openclaw-state-read-sqlite-lifecycle-errors-3AcFJUep.mjs";import{i as ke}from"./openclaw-state-read-path-existence-Bp_sxI9A.mjs";import{c as Ae,i as je,o as Me}from"./openclaw-state-read-openclaw-state-db.paths-CFemYLpA.mjs";import{d as Ne}from"./openclaw-state-read-openclaw-state-db-async-lifecycle-B_Y330HB.mjs";import{a as b,t as x}from"./openclaw-state-read-record-coerce-D1s3ReAs.mjs";import{a as Pe,i as Fe,l as Ie,n as Le,r as Re,s as ze,t as Be}from"./openclaw-state-read-openclaw-state-db-contract-DiFTYPe3.mjs";import{_ as S,a as Ve,c as He,f as Ue,h as C,l as w,n as We,o as Ge,p as T,y as Ke}from"./openclaw-state-read-schemas-CLrAtqTl.mjs";import{c as qe,h as Je,i as Ye,m as Xe,s as Ze}from"./openclaw-state-read-gateway-lock-payload-C9huNHFz.mjs";import{a as Qe,t as $e}from"./openclaw-state-read-pid-alive-_-Y1IvGj.mjs";import{l as et}from"./openclaw-state-read-sqlite-worker-operation-settlement-ogK5IsJy.mjs";import{c as tt,d as nt,s as rt,t as it,u as E}from"./openclaw-state-read-sqlite-post-commit-CEHMNIsB.mjs";import{a as at,u as ot}from"./openclaw-state-read-kysely-sync-cache-state-PxpuKzoA.mjs";import{i as st}from"./openclaw-state-read-sqlite-busy-timeout-D5Khm-oR.mjs";import{n as ct,s as lt,t as ut,u as dt}from"./openclaw-state-read-gateway-state-owner-BJTFuTQ0.mjs";import{i as ft}from"./openclaw-state-read-sqlite-files-B6lm_PVC.mjs";import{t as pt}from"./openclaw-state-read-subsystem-DSi0tJn8.mjs";import{i as mt,s as ht}from"./openclaw-state-read-worker-cpu-Ca-4Z8Q3.mjs";import{t as gt}from"./openclaw-state-read-sqlite-reader-metrics-DTAxFC_A.mjs";import{n as D,t as O}from"./openclaw-state-read-json-coercion-DgTIp8OM.mjs";import{y as _t}from"./openclaw-state-read-sqlite-snapshot-capacity-error-Df9fZtJA.mjs";import{s as vt}from"./openclaw-state-read-sqlite-readonly-location-DPGzRsxO.mjs";import{t as yt}from"./openclaw-state-read-usingCtx-03vOGQ3v.mjs";import{a as k,c as bt,i as A,l as xt,o as St,r as j,t as Ct}from"./openclaw-state-read-kysely-sync-DQyYiAw5.mjs";import{l as wt}from"./openclaw-state-read-sqlite-reader-lifecycle-BuMxf-e-.mjs";import{a as Tt,c as M,d as Et,n as Dt,r as Ot,t as N}from"./openclaw-state-read-sqlite-schema-sql-BnVx4b5A.mjs";import{t as kt}from"./openclaw-state-read-errors-D_saNBXy.mjs";import{t as At,y as jt}from"./openclaw-state-read-open-pprz0Grj.mjs";import{C as Mt,D as Nt,T as Pt,_ as Ft,h as It,o as P,s as Lt,u as Rt,v as zt,w as Bt,z as Vt}from"./openclaw-state-read-sqlite-schema-facts-DxLfPKu-.mjs";import{n as Ht,t as Ut}from"./openclaw-state-read-node-sqlite-UqZdY7HG.mjs";import{b as Wt,d as Gt,m as Kt,p as qt,v as Jt,x as Yt,y as Xt}from"./openclaw-state-read-worker-request-diagnostics-CbvzxbuX.mjs";import{a as Zt,d as Qt,p as $t,u as en}from"./openclaw-state-read-sqlite-worker-operation-admission-DTfv_SKu.mjs";import{a as tn,d as nn,f as rn,i as an,r as on,t as sn,u as cn}from"./openclaw-state-read-sqlite-transaction-V1rK3HH2.mjs";import{a as ln,t as F}from"./openclaw-state-read-sqlite-schema-issues-BBUCI22a.mjs";import{a as un,c as dn,n as I,o as L,s as R,t as fn}from"./openclaw-state-read-openclaw-state-db-schema-helpers-BkqUYEFY.mjs";import{n as pn}from"./openclaw-state-read-sqlite-snapshot-staging-owner-B9a1YbDW.mjs";import{n as mn,s as hn,t as z}from"./openclaw-state-read-sqlite-schema-catalog-DLcl4287.mjs";import{t as gn}from"./openclaw-state-read-gateway-supervision-queMstQ7.mjs";import{i as _n,n as vn,p as B,t as yn,u as V}from"./openclaw-state-read-openclaw-state-db-schema-migration-required-D_rQ-tLc.mjs";import"./openclaw-state-read-worker-task-pool-BbckrCtm.mjs";import{t as bn}from"./openclaw-state-read-sqlite-handle-lifecycle-DQ13SM2U.mjs";import{a as xn,i as Sn,r as Cn}from"./openclaw-state-read-openclaw-state-db-handle-D9nuaODy.mjs";import{c as wn,m as Tn}from"./openclaw-state-read-json-values-CH7dRPGy.mjs";import{a as En}from"./openclaw-state-read-sqlite-integrity-6ijoQyXy.mjs";import{i as Dn,o as On,r as kn,s as An,t as jn}from"./openclaw-state-read-openclaw-state-db-admission--7YB7DUG.mjs";import{a as Mn,i as Nn,l as Pn,n as Fn,o as In,r as Ln,t as Rn}from"./openclaw-state-read-sqlite-schema-contract-CE8IFvCt.mjs";import{n as zn,t as Bn}from"./openclaw-state-read-postgres-index-ordering-BPI6v_LV.mjs";import{a as Vn,c as Hn,d as Un,f as Wn,g as Gn,h as Kn,i as qn,l as Jn,m as Yn,n as Xn,o as Zn,p as Qn,r as $n,s as er,t as tr,u as nr}from"./openclaw-state-read-openclaw-state-db-operator-approval-migration-B18RT34H.mjs";import{a as rr,i as H,n as ir,o as ar,r as or,t as sr}from"./openclaw-state-read-openclaw-state-db-schema-version-Da6v6rWf.mjs";import{n as cr,t as U}from"./openclaw-state-read-sqlite-number-CpW6Oa2f.mjs";import"./openclaw-state-read-sqlite-source-handle-DLUASgzj.mjs";import{t as lr}from"./openclaw-state-read-state-domain-publication-CN6b3HGd.mjs";import{getHeapSpaceStatistics as ur,getHeapStatistics as dr,serialize as fr}from"node:v8";import{zstdCompressSync as pr}from"node:zlib";import mr,{existsSync as hr}from"node:fs";import W from"node:path";import{MessageChannel as gr,MessagePort as _r,isMainThread as vr,isMarkedAsUntransferable as yr,parentPort as br,threadId as xr}from"node:worker_threads";import{hostname as Sr}from"node:os";import{createHash as Cr}from"node:crypto";import{AsyncLocalStorage as wr}from"node:async_hooks";import{isDeepStrictEqual as Tr}from"node:util";import{performance as G}from"node:perf_hooks";import{Session as Er}from"node:inspector/promises";import"json5";function postTaskMessage(e,t,n,r=[]){e.postMessage(t,r),n&&(Atomics.add(n,0,1),Atomics.notify(n,0))}function serveOwnedWorkerTasks$1(e,t,n){if(!br)return;let r=br,i=r,a=!1,o=!1;n.initialize(i);let s,c=Promise.resolve(),l=Promise.resolve(),u=0,d,f=typeof e==`function`?void 0:e.synchronousStateless,p=typeof e==`function`?e:e.synchronousStateless,reply=(e,r)=>{postTaskMessage(i,{status:`ok`,value:r,taskId:e.taskId,...n.collectTaskDiagnostics?{diagnostics:n.collectTaskDiagnostics()}:{}},e.progressSignal,t.transferList?.(r)??[])},fail=(e,r)=>{t.retireOnError?o=!0:postTaskMessage(i,{status:`failed`,taskId:e.taskId,error:r instanceof Error?r.message:String(r),...n.collectTaskDiagnostics?{diagnostics:n.collectTaskDiagnostics()}:{}},e.progressSignal)},finish=()=>{o?(async()=>{try{await l}finally{try{await n.onRetire?.()}finally{process.exitCode=1;try{i.close()}finally{i!==r&&r.close()}}}})().catch(()=>{process.exitCode=1}):n.onIdle()};i.on(`message`,function receive(e){if(o){e.resourcePort?.close();return}if(!a){a=!0;let t=n.selectStartupPort?.(e);if(t){i.off(`message`,receive),i=t,n.initialize(i),i.on(`message`,receive),n.onReady?.();return}}if(n.onMessage(e.sampleMemory===!0),e.closeResource&&e.resourcePort){let r=e.resourcePort,i=t.closesBesideExecution?.(e.key)?void 0:c;u++,l=l.then(()=>i).then(async()=>{if(o)throw Error(`Worker is retiring after a terminal task failure`);await t.closeResource(e.key),r.postMessage({ok:!0},[])}).catch(e=>{r.postMessage({ok:!1,error:e instanceof Error?e.message:String(e),detail:t.encodeResourceError?.(e)},[])}).finally(()=>{r.close(),u--,!s&&!o&&n.onIdle()});return}if(e.responseId!==void 0){if(e.taskId===d?.taskId&&e.responseId===d.responseId)return;if(!s||e.taskId!==s.taskId||e.responseId!==s.responseId||!s.pending)throw Error(`stale worker task response`);try{s.assertCurrent()}catch(e){s.cancelPending(e);return}let t=s.pending;s.pending=void 0;let n=!1,r=e.taskId,a=e.responseId,o=s.progressSignal;t.resolve({input:e.input,consumed:()=>{n||(n=!0,postTaskMessage(i,{status:`consumed`,taskId:r,id:a},o))}});return}if(s)throw Error(`overlapping worker tasks`);let r=new Int32Array(e.nativeSections),m={taskId:e.taskId,responseId:0,progressSignal:e.progressSignal,assertCurrent:()=>g.throwIfCancelled(),cancelPending:e=>{let t=m.pending;t&&(m.pending=void 0,d={taskId:m.taskId,responseId:m.responseId},t.reject(e))}},h=new AbortController,g=Xt(r,()=>s===m,h.signal);if(s=m,f&&!e.interactive&&u===0){try{g.throwIfCancelled(),n.installTaskContext(e.taskContext);let t=f(e.input);s=void 0,reply(m,t)}catch(e){s=void 0,fail(m,e)}finally{finish()}return}let ee=Wt(r,()=>s===m,()=>{let e=/* @__PURE__ */ Error(`worker task cancelled`);h.abort(e),m.cancelPending(e)}),_=e.interactive?{notify:e=>{g.throwIfCancelled(),postTaskMessage(i,{status:`notification`,taskId:m.taskId,value:e},m.progressSignal)},consumeInput:()=>postTaskMessage(i,{status:`consumed`,taskId:m.taskId,id:0},m.progressSignal),request:(e,t)=>{if(g.throwIfCancelled(),s!==m||m.pending)throw Error(`closed or busy worker channel`);let n=Promise.withResolvers();m.pending=n;try{let n=t?[...t]:[];g.throwIfCancelled(),postTaskMessage(i,{status:`request`,taskId:m.taskId,id:++m.responseId,value:e},m.progressSignal,n)}catch(e){m.pending=void 0,n.reject(e)}return n.promise}}:void 0,te=l;c=Promise.resolve().then(async()=>{try{return await te,g.throwIfCancelled(),n.installTaskContext(e.taskContext),await Yt(r,()=>s===m,()=>p(e.input,_,g))}finally{await ee?.(),s=void 0}}).then(e=>reply(m,e)).catch(e=>fail(m,e)).finally(finish)}),n.onReady?.()}const Dr=33554432,Or=typeof Bun==`object`?Bun:void 0;let kr={heapUsed:0,external:0},Ar,jr,Mr=!1;function hasIdleGarbageGrowth(){let e=process.memoryUsage();return e.heapUsed>kr.heapUsed+Dr||e.external>kr.external+Dr}async function collectWorkerIdleGarbage(){if(jr=void 0,!hasIdleGarbageGrowth())return;Mr=!0;let e=process.memoryUsage(),t=Date.now();try{if(Or)Or.gc(!0);else{if(!Ar){let e=new Er;e.connect(),Ar=e}await Ar.post(`HeapProfiler.collectGarbage`)}kr=process.memoryUsage();let n=Date.now()-t;if(n>=1e3){let t={elapsedMs:n,threadId:xr,heapUsedBeforeBytes:e.heapUsed,heapUsedAfterBytes:kr.heapUsed,externalBeforeBytes:e.external,externalAfterBytes:kr.external};import(`./openclaw-state-read-worker-idle-gc-report.runtime-TOvsdogJ.mjs`).then(({reportSlowIdleWorkerGc:e})=>e(t)).catch(e=>{process.emitWarning(e instanceof Error?e:String(e))})}}catch(e){process.emitWarning(e instanceof Error?e:String(e))}finally{Mr=!1}}function scheduleWorkerIdleGc(){vr||jr||Mr||hasIdleGarbageGrowth()&&(jr=setTimeout(()=>{collectWorkerIdleGarbage()},1e3).unref())}function cancelWorkerIdleGc(){clearTimeout(jr),jr=void 0}function serveWorkerMemorySamples(e,t){let{port1:n,port2:r}=new gr,i=gt(e=>{n.postMessage({sqliteReaderCounter:e})}),a=ht(()=>{n.postMessage({postgresBridgeCounters:mt()})}),o=process.versions.bun?void 0:dr().heap_size_limit,s,c=!1,flushGc=()=>{s&&=(n.postMessage({gc:s}),void 0)},sample=()=>{let{heapUsed:e,heapTotal:r,external:i,arrayBuffers:a}=process.memoryUsage(),c=process.versions.bun?void 0:ur().map(({space_name:e,space_used_size:t})=>({space_name:e,space_used_size:t}));n.postMessage({heapUsed:e,heapTotal:r,external:i,arrayBuffers:a,heapSizeLimitBytes:o,oldGenerationAfterGcBytes:nn(),heapSpaces:c,retainedData:t?.(),gc:s}),s=void 0},l,setGcEnabled=e=>{e?l??=rn(e=>{(s??=[]).push(...e),(c||s.length>=256)&&flushGc()}):(l?.(),l=void 0,s=void 0)};return n.on(`message`,e=>{if(e&&`flush`in e)cn(),flushGc(),n.postMessage({flushed:!0,heapUsed:dr().used_heap_size});else if(e&&`captureGcProfile`in e){let t=e.captureGcProfile;import(`./openclaw-state-read-diagnostic-worker-gc-profile-tUhq14D_.mjs`).then(({captureWorkerGcProfiles:e})=>e()).then(e=>{n.postMessage({gcStorm:e.status===`complete`?{...t,captureStatus:`complete`,profiles:e.result}:{...t,captureStatus:`unavailable`,captureReason:e.reason}})}).catch(()=>{n.postMessage({gcStorm:{...t,captureStatus:`unavailable`,captureReason:`capture-failed`}})})}else e?setGcEnabled(e.gc):sample()}),n.once(`close`,()=>{a(),i(),l?.(),s=void 0}),n.on(`messageerror`,()=>n.close()),n.unref(),sample(),e.postMessage({status:`memory`,port:r,postgresBridgeCounters:mt()},[r]),{setTaskMetrics(e){c=e,setGcEnabled(e)},collectTask(){return c?!0:void 0},close(){a(),i(),l?.(),l=void 0,flushGc(),n.close()}}}function serveOwnedWorkerTasks(e,t={}){let n,r,i,a,o,s,runWithTaskContext=async e=>{let run=async()=>{let t=i;if(!t)return e();let n=!0;try{return await u((e,r,i,a)=>{if(!n)throw Error(`SQLite admission facts outlived their worker task`);return $t(t,e,r,i,a)},e)}finally{n=!1}};return o?fe(o,run):run()};serveOwnedWorkerTasks$1(typeof e==`function`?(t,n,r)=>ne({deadlineAtMs:a,assertActive:()=>r.throwIfCancelled()},()=>runWithTaskContext(async()=>{let i=await e(t,n,r),a=de();if(a)throw a;return i})):e,{...t,get retireOnError(){return t.retireOnError||de()!==void 0},closesBesideExecution:e=>{let t=qt(e);return t?.kind===`revive`||t?.kind===`close`&&t.deleted},closeResource:e=>runWithTaskContext(async()=>{let n=qt(e);if(!n&&!t.closeResource)throw Error(`Worker does not own retained resources`);n&&await Gt(n),n&&n.kind!==`close`||await t.closeResource?.(e)})},{selectStartupPort(e){if(b(e)&&e.type===`openclaw.worker-task-port`){if(!(e.port instanceof _r))throw Error(`Retained worker task port is invalid`);return r=e.port,r}},initialize(e){be.forceConsoleToStderr=!0,n=e},onReady(){r?.postMessage({status:`ready`},[])},onMessage(e){e&&!s&&(s=serveWorkerMemorySamples(n,t.retainedData)),cancelWorkerIdleGc()},installTaskContext(e){s?.setTaskMetrics(e.collectWorkerMetrics===!0),a=e.databaseAdmissionDeadlineAtMs,o=e.databaseEngineSelection,e.postgresPool&&ce(e.postgresPool),Kt(e.deletedAgentDatabaseFences),e.databaseAdmissionPort&&Qt(e.databaseAdmissionPort),i??=e.databaseAdmissionPort},onIdle(){Jt(),t.idleGc!==!1&&scheduleWorkerIdleGc()},collectTaskDiagnostics:()=>s?.collectTask(),onRetire(){cancelWorkerIdleGc();try{s?.close()}finally{i?.close()}}})}function ownedWorkerBytes(e){if(e.buffer instanceof ArrayBuffer&&e.byteOffset===0&&e.byteLength===e.buffer.byteLength&&!yr(e.buffer))return new Uint8Array(e.buffer);let t=new Uint8Array(e.byteLength);return t.set(e),t}function readPluginMetadataStateRowsInDatabase(e,t){return L(e,`config_machine_state`)?j(e,k(e).selectFrom(`config_machine_state`).select([`state_key`,`value_json`]).where(`state_key`,`in`,t)).rows:[]}const Nr={"plugins.metadata.read":(e,t)=>({type:`plugins.metadata.read`,rows:readPluginMetadataStateRowsInDatabase(t,`stateKeys`in e?e.stateKeys:[e.selector===`installed-index`?`plugins.installedIndex`:`plugins.bundledDiscovery`])})};function normalizeSqliteCatalogSql(e){return e.replace(/\s+/gu,` `).replace(/\s*([(),])\s*/gu,`$1`).trim()}function hasDanglingSkillWorkshopCollectionReviewIndex(e){return hn(e,()=>inspectSkillWorkshopCollectionReviewIndex(e))}function inspectSkillWorkshopCollectionReviewIndex(e){let t=e.prepare(`SELECT tbl_name, rootpage, sql FROM sqlite_schema WHERE type = 'index' AND name = ?`).get(yn);if(t?.tbl_name!==`skill_workshop_collection_reviews`||typeof t.rootpage!=`number`||t.rootpage<=0||typeof t.sql!=`string`||normalizeSqliteCatalogSql(t.sql)!==normalizeSqliteCatalogSql(`CREATE INDEX idx_skill_workshop_collection_reviews_workspace_time ON skill_workshop_collection_reviews(workspace_dir, create_time DESC, review_id DESC)`))return!1;let n=e.prepare(`PRAGMA table_info(skill_workshop_collection_reviews)`).all();return n.some(e=>e.name===`owner_agent_id`)&&!n.some(e=>e.name===`workspace_dir`)}function openDoctorStateSchemaReadAdmission(e){if(!E(e)&&(Rt(e),hasDanglingSkillWorkshopCollectionReviewIndex(e)))return mn(e)}const Pr=/* @__PURE__ */ new WeakMap;function createSqliteWalReclamationResult(){return{checkpointCompleted:!1,freePagesBefore:null,remainingFreePages:null,checkpointCalls:0,checkpointIncomplete:0,checkpointMs:0,checkpointMaxMs:0,queryMs:0,vacuumMs:0,vacuumPasses:0,vacuumPagesRequested:0}}function readSqliteFreePageCount(e,t){let n=t?G.now():0;try{return Number(e.prepare(`PRAGMA freelist_count`).get()?.freelist_count??0)}finally{t&&(t.queryMs+=G.now()-n)}}function reclaimSqliteWalFreePages(e,t,n){let r=createSqliteWalReclamationResult(),checkpoint=()=>{n.beforeMutation?.();let e=G.now();try{let e=n.checkpointMode??`TRUNCATE`,i=t(e);return r.checkpointCalls++,!i&&e===`TRUNCATE`&&(n.beforeMutation?.(),i=t(`PASSIVE`),r.checkpointCalls++),r.checkpointCompleted=i,r.checkpointIncomplete+=Number(!i),i}finally{let t=G.now()-e;r.checkpointMs+=t,r.checkpointMaxMs=Math.max(r.checkpointMaxMs,t)}};return n.maxPages===0&&n.checkpointMode===`PASSIVE`?(checkpoint(),r):st(e,0,()=>{if(!checkpoint()||n.maxPages===0)return r;let t=readSqliteFreePageCount(e,r);if(r.freePagesBefore=t,r.remainingFreePages=t,!Number.isSafeInteger(t)||t<=0)return r;let i=Math.min(Pr.get(e)??8,t,n.maxPages??512);if(!Number.isSafeInteger(i)||i<=0)throw Error(`SQLite page reclamation requires a positive integer page limit`);let a=G.now(),o=!1,s=!1;try{an(e,()=>{o=!0,n.beforeMutation?.(),r.vacuumPasses++,r.vacuumPagesRequested+=i,e.exec(`PRAGMA incremental_vacuum(${i});`),n.onCommit?.()},{beginLockFailureReporting:`suppress`,busyTimeoutMs:0,operationLabel:`incremental-vacuum`}),s=!0}catch(e){if(o||!g(e))throw e;return r}finally{let t=G.now()-a;r.vacuumMs+=t,s&&Pr.set(e,Math.max(1,Math.min(512,i*2,Math.floor(i*25/Math.max(t,.001)))))}return n.afterCommit?.(),checkpoint()&&(r.remainingFreePages=readSqliteFreePageCount(e,r)),r})}function stateEngineInput(){if(ue())return le(`state`)}const Fr=[`local_workspace_tree_packs`,`local_workspace_source_path_sets`],Ir=[`tree_root_digest`,`source_paths_digest`,`canonical_fingerprints`,`projection_fingerprints`];function migrateLocalWorkspaceCas(e,t){if(t>=35||!L(e,`local_workspace_projections`))return!1;for(let t of Ir)I(e,`local_workspace_projections`,`${t} BLOB`);for(let t of Fr)e.exec(N(v,t));return!0}const Lr={version:35,tables:[`local_workspace_projections`,...Fr],columns:Ir.map(e=>`local_workspace_projections.${e}`),migrate:migrateLocalWorkspaceCas,applied:`Prepared shared content-addressed workspace trees and compact scan fingerprints (v35)`};function withLegacyLocalWorkspaceCas(e){return e.replace(/\n {2}(?:tree_root_digest|source_paths_digest|canonical_fingerprints|projection_fingerprints) BLOB,/gu,``).replace(/\n {2}"(?:tree_root_digest|source_paths_digest|canonical_fingerprints|projection_fingerprints)" bytea,/gu,``).replace(/CREATE TABLE(?: IF NOT EXISTS)? "?local_workspace_(?:tree_packs|source_path_sets)"? \([\s\S]*?\n\)(?: STRICT(?:, WITHOUT ROWID)?)?;\n?/gu,``)}const K=`local_workspace_projections`,Rr=`local_workspace_manifest_nodes`,zr=`CHECK ((baseline_json IS NULL) = (baseline_ref IS NULL))`,Br=`CHECK (baseline_json IS NULL OR baseline_ref IS NOT NULL)`;function migrateLocalWorkspaceManifests(e,t){if(t>=31||!L(e,K))return!1;I(e,K,`checkpoint_json TEXT`);let n=P(e)??Ft(e),r=n.tableSql.get(K);if(typeof r!=`string`)throw Error(`Local workspace projection migration schema is missing`);if(r.includes(zr)){let t=M(`${K}_migration_v31`),i=M(K),a=[...un(e,K)].map(M).join(`, `),o=r.slice(r.indexOf(`(`)).replace(zr,Br);e.exec(`CREATE TABLE ${t} ${o};
INSERT INTO ${t} (rowid, ${a}) SELECT rowid, ${a} FROM ${i};
DROP TABLE ${i};
ALTER TABLE ${t} RENAME TO ${i};`);for(let t of[...n.indexDefinitions.values(),...n.triggers.values()])t.table===K&&typeof t.sql==`string`&&e.exec(t.sql)}else if(!r.includes(Br))throw Error(`Local workspace baseline constraint is not recognized; preserve it for Doctor`);return e.exec(N(v,Rr)),!0}const Vr={version:31,tables:[K,Rr],columns:[`${K}.checkpoint_json`],migrate:migrateLocalWorkspaceManifests,applied:`Prepared resumable per-path local workspace baselines and checkpoint deltas (v31)`};function withLegacyLocalWorkspaceManifests(e){return withLegacyLocalWorkspaceCas(e).replace(/\n {2}(?:checkpoint_json TEXT|"checkpoint_json" text COLLATE "C"),/gu,``).replace(/^ {2}CHECK \([^\n]*baseline_json[^\n]*baseline_ref[^\n]*\),$/gmu,e=>e.includes(`"`)?` CHECK ((("baseline_json" IS NULL) = ("baseline_ref" IS NULL))),`:` ${zr},`).replace(/CREATE TABLE(?: IF NOT EXISTS)? "?local_workspace_manifest_nodes"? \([\s\S]*?\n\)(?: STRICT)?;\n?/gu,``).replace(/ALTER TABLE "local_workspace_manifest_nodes" ADD FOREIGN KEY[^;]*;\n?/gu,``)}const Hr={version:37,tables:[`worker_environments`],columns:[`worker_environments.resource_receipt_json`],migrate(e,t){return t>=37?!1:I(e,`worker_environments`,`resource_receipt_json TEXT`)},applied:`Retained immutable worker provider resource receipts (v37)`};function withLegacyWorkerResourceReceipts(e){return e.replace(/,\n {2}resource_receipt_json TEXT(?=\n\))|\n {2}"resource_receipt_json" text COLLATE "C",/gu,``)}const Ur=[Hr,{version:38,tables:[`session_repository_workspaces`,`worker_workspace_pending_results`],columns:[`session_repository_workspaces.disk_authority_json`,`worker_workspace_pending_results.repository_disk_authority_json`],migrate(e,t){if(t>=38)return!1;let n=I(e,`session_repository_workspaces`,`disk_authority_json TEXT`),r=I(e,`worker_workspace_pending_results`,`repository_disk_authority_json TEXT`);return n||r},applied:`Retained repository disk authority and original pending-result authority (v38)`}];function withLegacyRepositoryDiskAuthority(e){return e.replace(/\n {2}(?:(?:disk_authority_json|repository_disk_authority_json) TEXT|"(?:disk_authority_json|repository_disk_authority_json)" text COLLATE "C"),/gu,``)}const Wr={version:39,tables:[`worker_environments`],columns:[`worker_environments.retention_json`],migrate(e,t){return t>=39?!1:I(e,`worker_environments`,`retention_json TEXT`)},applied:`Retained worker acquisition policy, unfinished operation, and observations (v39)`};function withLegacyWorkerRetention(e){return e.replace(/,\n {2}retention_json TEXT(?=\n\))|\n {2}"retention_json" text COLLATE "C",/gu,``)}function withLegacyWorkspaceBootstrapDeferred(e){return e.replace(` bootstrap_deferred INTEGER,
`,``).replace(` "bootstrap_deferred" bigint,
`,``)}function withLegacyStateV40Additions(e){return withLegacyWorkspaceBootstrapDeferred(e).replace(/CREATE TABLE IF NOT EXISTS device_pairing_browser_requests \([\s\S]*?\) STRICT;\n\n/u,``)}const Gr={version:40,tables:[`worker_environments`],columns:[`worker_environments.provision_source_json`],migrate(e,t){if(t>=40||!L(e,`worker_environments`))return!1;let n=I(e,`worker_environments`,`provision_source_json TEXT`),r=e.prepare(`UPDATE worker_environments
SET provision_source_json = '{"kind":"unavailable"}'
WHERE (state IN ('requested', 'provisioning') AND lease_id IS NULL
OR state = 'bootstrapping' AND owner_epoch = 0)
AND provision_source_json IS NULL`).run();return n||Number(r.changes)>0},applied:`Original worker provisioning source retained across recovery (v40)`};function withLegacyWorkerProvisionSource(e){return e.replace(/,\n {2}provision_source_json TEXT(?=\n\))|\n {2}"provision_source_json" text COLLATE "C",/gu,``)}function withPostgresSchemaAdmissionRetry(e,t,n){try{return t()}catch(r){if(!(r instanceof ir)||!E(e)||n?.()===!1||!e.isOpen||e.isTransaction)throw r;let i=Math.min(Date.now()+1e3,oe()??1/0),a=performance.now()+Math.max(0,i-Date.now()),o=new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));return ne({deadlineAtMs:i},()=>{for(let s=10;;s=Math.min(s*2,100)){te();let c=Math.min(a-performance.now(),i-Date.now());if(c<=0||(Atomics.wait(o,0,0,Math.min(s,c)),te(),performance.now()>=a||Date.now()>=i)||n?.()===!1||!e.isOpen||e.isTransaction)throw r;try{if(!Bt(e,{refresh:!0}))continue;return t()}catch(t){if(t instanceof en&&(performance.now()>=a||Date.now()>=i))throw r;if(!(t instanceof ir)||n?.()===!1||!e.isOpen||e.isTransaction)throw t}}})}}var Kr=t();const qr=18e5,Jr=3e5;function isUnfencedUpdateDriver(e){let t=typeof e==`string`?(0,Kr.parse)(e):null;return t!==null&&`${t.major}.${t.minor}.${t.patch}`==`2026.9.2`}function readStateSchemaPublicationBlocker(e,t=Date.now()){if(!L(e,`update_runs`))return;let n=j(e,k(e).selectFrom(`update_runs`).select([`run_id`,`before_json`,`status`,`updated_at_ms`,`finished_at_ms`]).where(e=>e.or([e.and([e(`status`,`=`,`running`),e(`updated_at_ms`,`>=`,t-qr)]),e.and([e(`status`,`!=`,`running`),e.or([e(`finished_at_ms`,`>`,t-Jr),e(`finished_at_ms`,`is`,null)])])])).orderBy(`run_id`)).rows,r;for(let e of n){let t=JSON.parse(e.before_json);if(!b(t)||typeof t.version!=`string`||!isUnfencedUpdateDriver(t.version))continue;let n=e.status===`running`?e.updated_at_ms+qr+1:e.finished_at_ms===null?null:e.finished_at_ms+Jr;(!r||n===null||r.publishAfterMs!==null&&n>r.publishAfterMs)&&(r={runId:e.run_id,updaterVersion:t.version,publishAfterMs:n})}return r}function resolveStateSchemaVersionToPublish(e){let t=V(e);if(t>=40||!readStateSchemaPublicationBlocker(e))return 40;if(!L(e,`config_machine_state`))throw Error(`Shared state schema publication cannot be deferred without config_machine_state.`);return writeStateSchemaContentVersion(e),Rt(e),t}function writeStateSchemaContentVersion(e){j(e,k(e).insertInto(`config_machine_state`).values({state_key:sr,value_json:`40`,updated_at_ms:Date.now()}).onConflict(e=>e.column(`state_key`).doUpdateSet({value_json:`40`,updated_at_ms:Date.now()}).where(`config_machine_state.value_json`,`!=`,`40`)))}function advanceStateSchemaContentVersion(e,t){j(e,k(e).updateTable(`config_machine_state`).set({value_json:String(t.toVersion)}).where(`state_key`,`=`,sr).where(`value_json`,`=`,String(t.fromVersion)))}const q={get eagerSql(){let e=`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "acp_replay_events" (
"session_id" text COLLATE "C" NOT NULL,
"seq" bigint NOT NULL,
"at" bigint NOT NULL,
"session_key" text COLLATE "C" NOT NULL,
"run_id" text COLLATE "C",
"update_json" text COLLATE "C" NOT NULL,
"estimated_bytes" bigint NOT NULL DEFAULT 0,
PRIMARY KEY ("session_id", "seq")
);
CREATE TABLE "acp_replay_sessions" (
"session_id" text COLLATE "C" NOT NULL,
"session_key" text COLLATE "C" NOT NULL,
"cwd" text COLLATE "C" NOT NULL,
"complete" bigint NOT NULL,
"created_at" bigint NOT NULL,
"updated_at" bigint NOT NULL,
"next_seq" bigint NOT NULL,
"estimated_bytes" bigint NOT NULL DEFAULT 0,
PRIMARY KEY ("session_id")
);
CREATE TABLE "acp_sessions" (
"session_key" text COLLATE "C" NOT NULL,
"session_id" text COLLATE "C",
"backend" text COLLATE "C" NOT NULL,
"agent" text COLLATE "C" NOT NULL,
"runtime_session_name" text COLLATE "C" NOT NULL,
"identity_json" text COLLATE "C",
"resume_agent_session_id" text COLLATE "C",
"resume_acpx_session_id" text COLLATE "C",
"mode" text COLLATE "C" NOT NULL,
"runtime_options_json" text COLLATE "C",
"cwd" text COLLATE "C",
"state" text COLLATE "C" NOT NULL,
"last_activity_at" bigint NOT NULL,
"last_error" text COLLATE "C",
"updated_at" bigint NOT NULL,
PRIMARY KEY ("session_key")
);
CREATE TABLE "agent_database_leases" (
"lease_id" text COLLATE "C" NOT NULL,
"agent_id" text COLLATE "C" NOT NULL,
"path" text COLLATE "C" NOT NULL,
"owner_pid" bigint NOT NULL,
"owner_start_time" bigint,
"opened_at" bigint NOT NULL,
"provenance" text COLLATE "C",
PRIMARY KEY ("lease_id")
);
CREATE TABLE "agent_databases" (
"agent_id" text COLLATE "C" NOT NULL,
"path" text COLLATE "C" NOT NULL,
"schema_version" bigint NOT NULL,
"last_seen_at" bigint NOT NULL,
"size_bytes" bigint,
PRIMARY KEY ("agent_id", "path")
);
CREATE TABLE "apns_registration_tombstones" (
"node_id" text COLLATE "C" NOT NULL,
"deleted_at_ms" bigint NOT NULL,
PRIMARY KEY ("node_id")
);
CREATE TABLE "apns_registrations" (
"node_id" text COLLATE "C" NOT NULL,
"transport" text COLLATE "C" NOT NULL,
"token" text COLLATE "C",
"relay_handle" text COLLATE "C",
"send_grant" text COLLATE "C",
"installation_id" text COLLATE "C",
"relay_origin" text COLLATE "C",
"topic" text COLLATE "C" NOT NULL,
"environment" text COLLATE "C" NOT NULL,
"distribution" text COLLATE "C",
"token_debug_suffix" text COLLATE "C",
"updated_at_ms" bigint NOT NULL,
PRIMARY KEY ("node_id")
);
CREATE TABLE "audit_events" (
"sequence" bigint GENERATED BY DEFAULT AS IDENTITY NOT NULL,
"event_id" text COLLATE "C" NOT NULL,
"source_id" text COLLATE "C" NOT NULL,
"schema_version" bigint NOT NULL DEFAULT 1,
"source_sequence" bigint NOT NULL,
"occurred_at" bigint NOT NULL,
"kind" text COLLATE "C" NOT NULL,
"action" text COLLATE "C" NOT NULL,
"status" text COLLATE "C" NOT NULL,
"error_code" text COLLATE "C",
"actor_type" text COLLATE "C" NOT NULL,
"actor_id" text COLLATE "C" NOT NULL,
"agent_id" text COLLATE "C",
"session_key" text COLLATE "C",
"session_id" text COLLATE "C",
"run_id" text COLLATE "C",
"tool_call_id" text COLLATE "C",
"tool_name" text COLLATE "C",
"direction" text COLLATE "C",
"channel" text COLLATE "C",
"conversation_kind" text COLLATE "C",
"message_outcome" text COLLATE "C",
"reason_code" text COLLATE "C",
"delivery_kind" text COLLATE "C",
"failure_stage" text COLLATE "C",
"duration_ms" bigint,
"result_count" bigint,
"account_ref" text COLLATE "C",
"conversation_ref" text COLLATE "C",
"message_ref" text COLLATE "C",
"target_ref" text COLLATE "C",
PRIMARY KEY ("sequence"),
UNIQUE ("event_id"),
UNIQUE ("source_id")
);
CREATE TABLE "audit_identity_keys" (
"id" bigint GENERATED BY DEFAULT AS IDENTITY NOT NULL,
"key_id" text COLLATE "C" NOT NULL,
"key" bytea NOT NULL,
"created_at" bigint NOT NULL,
PRIMARY KEY ("id"),
CHECK (("id" = 1))
);
CREATE TABLE "backup_runs" (
"id" text COLLATE "C" NOT NULL,
"created_at" bigint NOT NULL,
"archive_path" text COLLATE "C" NOT NULL,
"status" text COLLATE "C" NOT NULL,
"manifest_json" text COLLATE "C" NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "capture_blobs" (
"blob_id" text COLLATE "C" NOT NULL,
"content_type" text COLLATE "C",
"encoding" text COLLATE "C" NOT NULL,
"size_bytes" bigint NOT NULL,
"sha256" text COLLATE "C" NOT NULL,
"data" bytea NOT NULL,
"created_at" bigint NOT NULL,
PRIMARY KEY ("blob_id")
);
CREATE TABLE "capture_events" (
"id" bigint GENERATED BY DEFAULT AS IDENTITY NOT NULL,
"session_id" text COLLATE "C" NOT NULL,
"ts" bigint NOT NULL,
"source_scope" text COLLATE "C" NOT NULL,
"source_process" text COLLATE "C" NOT NULL,
"protocol" text COLLATE "C" NOT NULL,
"direction" text COLLATE "C" NOT NULL,
"kind" text COLLATE "C" NOT NULL,
"flow_id" text COLLATE "C" NOT NULL,
"method" text COLLATE "C",
"host" text COLLATE "C",
"path" text COLLATE "C",
"status" bigint,
"close_code" bigint,
"content_type" text COLLATE "C",
"headers_json" text COLLATE "C",
"data_text" text COLLATE "C",
"data_blob_id" text COLLATE "C",
"data_sha256" text COLLATE "C",
"error_text" text COLLATE "C",
"meta_json" text COLLATE "C",
PRIMARY KEY ("id")
);
CREATE TABLE "capture_sessions" (
"id" text COLLATE "C" NOT NULL,
"started_at" bigint NOT NULL,
"ended_at" bigint,
"mode" text COLLATE "C" NOT NULL,
"source_scope" text COLLATE "C" NOT NULL,
"source_process" text COLLATE "C" NOT NULL,
"proxy_url" text COLLATE "C",
PRIMARY KEY ("id")
);
CREATE TABLE "channel_ingress_events" (
"queue_name" text COLLATE "C" NOT NULL,
"event_id" text COLLATE "C" NOT NULL,
"channel_id" text COLLATE "C" NOT NULL,
"account_id" text COLLATE "C" NOT NULL,
"status" text COLLATE "C" NOT NULL,
"lane_key" text COLLATE "C",
"payload_json" text COLLATE "C" NOT NULL,
"metadata_json" text COLLATE "C",
"received_at" bigint NOT NULL,
"updated_at" bigint NOT NULL,
"claim_token" text COLLATE "C",
"claim_owner" text COLLATE "C",
"claimed_at" bigint,
"attempts" bigint NOT NULL DEFAULT 0,
"last_attempt_at" bigint,
"last_error" text COLLATE "C",
"failed_reason" text COLLATE "C",
"failed_at" bigint,
"completed_at" bigint,
"completed_metadata_json" text COLLATE "C",
PRIMARY KEY ("queue_name", "event_id")
);
CREATE TABLE "channel_pairing_allow_entries" (
"channel_key" text COLLATE "C" NOT NULL,
"account_id" text COLLATE "C" NOT NULL,
"entry" text COLLATE "C" NOT NULL,
"sort_order" bigint NOT NULL,
"updated_at" bigint NOT NULL,
PRIMARY KEY ("channel_key", "account_id", "entry")
);
CREATE TABLE "channel_pairing_requests" (
"channel_key" text COLLATE "C" NOT NULL,
"account_id" text COLLATE "C" NOT NULL,
"request_id" text COLLATE "C" NOT NULL,
"code" text COLLATE "C" NOT NULL,
"created_at" text COLLATE "C" NOT NULL,
"last_seen_at" text COLLATE "C" NOT NULL,
"meta_json" text COLLATE "C",
PRIMARY KEY ("channel_key", "account_id", "request_id")
);
CREATE TABLE "clawhub_promotion_claims" (
"slug" text COLLATE "C" NOT NULL,
"provider" text COLLATE "C",
"model_keys_json" text COLLATE "C" NOT NULL,
"ends_at_ms" bigint NOT NULL,
"claimed_at_ms" bigint NOT NULL,
PRIMARY KEY ("slug")
);
CREATE TABLE "config_health_entries" (
"config_path" text COLLATE "C" NOT NULL,
"last_known_good_json" text COLLATE "C",
"last_promoted_good_json" text COLLATE "C",
"last_observed_suspicious_signature" text COLLATE "C",
"updated_at_ms" bigint NOT NULL,
PRIMARY KEY ("config_path")
);
CREATE TABLE "config_machine_state" (
"state_key" text COLLATE "C" NOT NULL,
"value_json" text COLLATE "C" NOT NULL,
"updated_at_ms" bigint NOT NULL,
PRIMARY KEY ("state_key")
);
CREATE TABLE "cron_job_scratch" (
"store_key" text COLLATE "C" NOT NULL,
"job_id" text COLLATE "C" NOT NULL,
"content" text COLLATE "C",
"revision" bigint NOT NULL,
"source_sha256" text COLLATE "C",
"updated_at_ms" bigint NOT NULL,
PRIMARY KEY ("store_key", "job_id"),
CHECK (("revision" >= 1)),
CHECK ("content" IS NULL OR (octet_length(convert_to("content", 'UTF8')) <= 262144))
);
CREATE TABLE "cron_jobs" (
"store_key" text COLLATE "C" NOT NULL,
"job_id" text COLLATE "C" NOT NULL,
"declaration_key" text COLLATE "C",
"owner_agent_id" text COLLATE "C",
"name" text COLLATE "C" NOT NULL,
"description" text COLLATE "C",
"enabled" bigint NOT NULL,
"agent_id" text COLLATE "C",
"payload_kind" text COLLATE "C" NOT NULL,
"job_json" text COLLATE "C" NOT NULL,
"grant_definition_revision" text COLLATE "C",
"grant_definition_generation" bigint,
"grant_definition_updated_at" bigint,
"state_json" text COLLATE "C" NOT NULL DEFAULT '{}',
"runtime_updated_at_ms" bigint,
"schedule_identity" text COLLATE "C",
"sort_order" bigint NOT NULL DEFAULT 0,
"updated_at" bigint NOT NULL,
PRIMARY KEY ("store_key", "job_id")
);
CREATE TABLE "current_conversation_bindings" (
"binding_key" text COLLATE "C" NOT NULL,
"binding_id" text COLLATE "C" NOT NULL,
"target_session_key" text COLLATE "C" NOT NULL,
"channel" text COLLATE "C" NOT NULL,
"account_id" text COLLATE "C" NOT NULL,
"conversation_kind" text COLLATE "C" NOT NULL,
"parent_conversation_id" text COLLATE "C",
"conversation_id" text COLLATE "C" NOT NULL,
"target_kind" text COLLATE "C" NOT NULL,
"status" text COLLATE "C" NOT NULL,
"bound_at" bigint NOT NULL,
"expires_at" bigint,
"metadata_json" text COLLATE "C",
"record_json" text COLLATE "C" NOT NULL,
"updated_at" bigint NOT NULL,
PRIMARY KEY ("binding_key")
);
CREATE TABLE "delivery_queue_entries" (
"queue_name" text COLLATE "C" NOT NULL,
"id" text COLLATE "C" NOT NULL,
"status" text COLLATE "C" NOT NULL,
"entry_kind" text COLLATE "C",
"session_key" text COLLATE "C",
"channel" text COLLATE "C",
"target" text COLLATE "C",
"account_id" text COLLATE "C",
"retry_count" bigint NOT NULL DEFAULT 0,
"last_attempt_at" bigint,
"last_error" text COLLATE "C",
"recovery_state" text COLLATE "C",
"platform_send_started_at" bigint,
"entry_json" text COLLATE "C" NOT NULL,
"retention_id_prefix" text COLLATE "C",
"retention_max_age_ms" bigint,
"retention_max_entries" bigint,
"enqueued_at" bigint NOT NULL,
"updated_at" bigint NOT NULL,
"failed_at" bigint,
PRIMARY KEY ("queue_name", "id")
);
CREATE TABLE "device_bootstrap_tokens" (
"token_key" text COLLATE "C" NOT NULL,
"token" text COLLATE "C" NOT NULL,
"setup_id" text COLLATE "C",
"ts" bigint NOT NULL,
"device_id" text COLLATE "C",
"public_key" text COLLATE "C",
"profile_json" text COLLATE "C",
"redeemed_profile_json" text COLLATE "C",
"pending_profile_json" text COLLATE "C",
"issued_at_ms" bigint NOT NULL,
"last_used_at_ms" bigint,
PRIMARY KEY ("token_key")
);
CREATE TABLE "device_pairing_paired" (
"device_id" text COLLATE "C" NOT NULL,
"public_key" text COLLATE "C" NOT NULL,
"display_name" text COLLATE "C",
"operator_label" text COLLATE "C",
"platform" text COLLATE "C",
"device_family" text COLLATE "C",
"client_id" text COLLATE "C",
"client_mode" text COLLATE "C",
"browser_origin" text COLLATE "C",
"role" text COLLATE "C",
"roles_json" text COLLATE "C",
"scopes_json" text COLLATE "C",
"approved_scopes_json" text COLLATE "C",
"remote_ip" text COLLATE "C",
"tokens_json" text COLLATE "C",
"approved_via" text COLLATE "C",
"node_surface_json" text COLLATE "C",
"pending_node_surface_json" text COLLATE "C",
"created_at_ms" bigint NOT NULL,
"approved_at_ms" bigint NOT NULL,
"last_seen_at_ms" bigint,
"last_seen_reason" text COLLATE "C",
PRIMARY KEY ("device_id")
);
CREATE TABLE "device_pairing_pending" (
"request_id" text COLLATE "C" NOT NULL,
"device_id" text COLLATE "C" NOT NULL,
"public_key" text COLLATE "C" NOT NULL,
"display_name" text COLLATE "C",
"platform" text COLLATE "C",
"device_family" text COLLATE "C",
"client_id" text COLLATE "C",
"client_mode" text COLLATE "C",
"browser_origin" text COLLATE "C",
"role" text COLLATE "C",
"roles_json" text COLLATE "C",
"scopes_json" text COLLATE "C",
"remote_ip" text COLLATE "C",
"silent" bigint,
"is_repair" bigint,
"ts" bigint NOT NULL,
"refreshed_at_ms" bigint,
PRIMARY KEY ("request_id")
);
CREATE TABLE "diagnostic_events" (
"scope" text COLLATE "C" NOT NULL,
"event_key" text COLLATE "C" NOT NULL,
"payload_json" text COLLATE "C" NOT NULL,
"created_at" bigint NOT NULL,
"sequence" bigint NOT NULL DEFAULT 0,
PRIMARY KEY ("scope", "event_key")
);
CREATE TABLE "exec_approvals_config" (
"config_key" text COLLATE "C" NOT NULL,
"raw_json" text COLLATE "C" NOT NULL,
"socket_path" text COLLATE "C",
"has_socket_token" bigint NOT NULL,
"default_security" text COLLATE "C",
"default_ask" text COLLATE "C",
"default_ask_fallback" text COLLATE "C",
"auto_allow_skills" bigint,
"agent_count" bigint NOT NULL,
"allowlist_count" bigint NOT NULL,
"updated_at_ms" bigint NOT NULL,
PRIMARY KEY ("config_key")
);
CREATE TABLE "flow_runs" (
"flow_id" text COLLATE "C" NOT NULL,
"shape" text COLLATE "C",
"sync_mode" text COLLATE "C" NOT NULL DEFAULT 'managed',
"owner_key" text COLLATE "C" NOT NULL,
"requester_origin_json" text COLLATE "C",
"controller_id" text COLLATE "C",
"revision" bigint NOT NULL DEFAULT 0,
"status" text COLLATE "C" NOT NULL,
"notify_policy" text COLLATE "C" NOT NULL,
"goal" text COLLATE "C" NOT NULL,
"current_step" text COLLATE "C",
"blocked_task_id" text COLLATE "C",
"blocked_summary" text COLLATE "C",
"state_json" text COLLATE "C",
"wait_json" text COLLATE "C",
"cancel_requested_at" bigint,
"created_at" bigint NOT NULL,
"updated_at" bigint NOT NULL,
"ended_at" bigint,
PRIMARY KEY ("flow_id")
);
CREATE TABLE "gateway_boot_lifecycle" (
"boot_id" text COLLATE "C" NOT NULL,
"pid" bigint NOT NULL,
"started_at_ms" bigint NOT NULL,
"completed_at_ms" bigint,
"outcome" text COLLATE "C",
"startup_reason" text COLLATE "C",
"reason" text COLLATE "C",
PRIMARY KEY ("boot_id")
);
CREATE TABLE "gateway_restart_handoff" (
"handoff_key" text COLLATE "C" NOT NULL,
"kind" text COLLATE "C" NOT NULL,
"version" bigint NOT NULL,
"intent_id" text COLLATE "C" NOT NULL,
"pid" bigint NOT NULL,
"process_instance_id" text COLLATE "C",
"created_at" bigint NOT NULL,
"expires_at" bigint NOT NULL,
"reason" text COLLATE "C",
"restart_trace_started_at" bigint,
"restart_trace_last_at" bigint,
"source" text COLLATE "C" NOT NULL,
"restart_kind" text COLLATE "C" NOT NULL,
"supervisor_mode" text COLLATE "C" NOT NULL,
"updated_at_ms" bigint NOT NULL,
PRIMARY KEY ("handoff_key")
);
CREATE TABLE "gateway_restart_intent" (
"intent_key" text COLLATE "C" NOT NULL,
"kind" text COLLATE "C" NOT NULL,
"pid" bigint NOT NULL,
"created_at" bigint NOT NULL,
"reason" text COLLATE "C",
"force" bigint,
"wait_ms" bigint,
"updated_at_ms" bigint NOT NULL,
PRIMARY KEY ("intent_key")
);
CREATE TABLE "gateway_restart_sentinel" (
"sentinel_key" text COLLATE "C" NOT NULL,
"version" bigint NOT NULL,
"kind" text COLLATE "C" NOT NULL,
"status" text COLLATE "C" NOT NULL,
"ts" bigint NOT NULL,
"session_key" text COLLATE "C",
"thread_id" text COLLATE "C",
"delivery_channel" text COLLATE "C",
"delivery_to" text COLLATE "C",
"delivery_account_id" text COLLATE "C",
"message" text COLLATE "C",
"continuation_json" text COLLATE "C",
"doctor_hint" text COLLATE "C",
"stats_json" text COLLATE "C",
"payload_json" text COLLATE "C" NOT NULL,
"updated_at_ms" bigint NOT NULL,
PRIMARY KEY ("sentinel_key")
);
CREATE TABLE "macos_port_guardian_records" (
"pid" bigint GENERATED BY DEFAULT AS IDENTITY NOT NULL,
"port" bigint NOT NULL,
"command" text COLLATE "C" NOT NULL,
"mode" text COLLATE "C" NOT NULL,
"timestamp" double precision NOT NULL,
PRIMARY KEY ("pid")
);
CREATE TABLE "managed_outgoing_image_records" (
"attachment_id" text COLLATE "C" NOT NULL,
"session_key" text COLLATE "C" NOT NULL,
"agent_id" text COLLATE "C",
"message_id" text COLLATE "C",
"created_at" text COLLATE "C" NOT NULL,
"updated_at" text COLLATE "C",
"retention_class" text COLLATE "C",
"alt" text COLLATE "C" NOT NULL,
"original_media_root" text COLLATE "C" NOT NULL,
"original_media_id" text COLLATE "C" NOT NULL,
"original_media_subdir" text COLLATE "C" NOT NULL,
"original_content_type" text COLLATE "C" NOT NULL,
"original_width" bigint,
"original_height" bigint,
"original_size_bytes" bigint,
"original_filename" text COLLATE "C",
"record_json" text COLLATE "C" NOT NULL,
"cleanup_pending" bigint NOT NULL DEFAULT 0,
PRIMARY KEY ("attachment_id"),
CHECK (("cleanup_pending" IN (0, 1)))
);
CREATE TABLE "mcp_oauth_stores" (
"store_key" text COLLATE "C" NOT NULL,
"format_version" bigint NOT NULL,
"store_json" text COLLATE "C" NOT NULL,
"updated_at" bigint NOT NULL,
PRIMARY KEY ("store_key"),
CHECK (("format_version" = 1))
);
CREATE TABLE "meeting_transcript_sessions" (
"started_at_ms" bigint,
"session_id" text COLLATE "C" NOT NULL,
"started_at" text COLLATE "C" NOT NULL,
"selector" text COLLATE "C" NOT NULL,
"export_key" text COLLATE "C" NOT NULL,
"session_slug" text COLLATE "C" NOT NULL,
"provider_id" text COLLATE "C" NOT NULL,
"title" text COLLATE "C",
"source_json" text COLLATE "C" NOT NULL,
"source_account_id" text COLLATE "C",
"source_guild_id" text COLLATE "C",
"source_channel_id" text COLLATE "C",
"source_meeting_url" text COLLATE "C",
"source_thread_ts" text COLLATE "C",
"source_file_id" text COLLATE "C",
"stopped_at" text COLLATE "C",
"metadata_json" text COLLATE "C",
"metadata_agent_id" text COLLATE "C",
"export_manifest_json" text COLLATE "C" NOT NULL DEFAULT '{}',
"export_pending_json" text COLLATE "C" NOT NULL DEFAULT '[]',
"next_utterance_seq" bigint NOT NULL DEFAULT 0,
"created_at_ms" bigint NOT NULL,
"updated_at_ms" bigint NOT NULL,
PRIMARY KEY ("session_id", "started_at"),
CHECK (("next_utterance_seq" >= 0)),
CHECK (("created_at_ms" >= 0)),
CHECK (("updated_at_ms" >= 0)),
UNIQUE ("selector")
);
CREATE TABLE "meeting_transcript_summaries" (
"session_id" text COLLATE "C" NOT NULL,
"session_started_at" text COLLATE "C" NOT NULL,
"generated_at" text COLLATE "C",
"summary_json" text COLLATE "C",
"overview" text COLLATE "C",
"markdown" text COLLATE "C",
"utterance_count" bigint NOT NULL,
PRIMARY KEY ("session_id", "session_started_at"),
CHECK (("utterance_count" >= 0)),
CHECK ("summary_json" IS NOT NULL OR "markdown" IS NOT NULL)
);
CREATE TABLE "meeting_transcript_utterances" (
"session_id" text COLLATE "C" NOT NULL,
"session_started_at" text COLLATE "C" NOT NULL,
"sequence" bigint NOT NULL,
"utterance_id" text COLLATE "C",
"started_at" text COLLATE "C",
"ended_at" text COLLATE "C",
"speaker_id" text COLLATE "C",
"speaker_label" text COLLATE "C",
"text" text COLLATE "C" NOT NULL,
"final" bigint,
"metadata_json" text COLLATE "C",
PRIMARY KEY ("session_id", "session_started_at", "sequence"),
CHECK (("sequence" >= 0)),
CHECK (("final" IN (0, 1)))
);
CREATE TABLE "migration_runs" (
"id" text COLLATE "C" NOT NULL,
"started_at" bigint NOT NULL,
"finished_at" bigint,
"status" text COLLATE "C" NOT NULL,
"report_json" text COLLATE "C" NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "migration_sources" (
"source_key" text COLLATE "C" NOT NULL,
"migration_kind" text COLLATE "C" NOT NULL,
"source_path" text COLLATE "C" NOT NULL,
"target_table" text COLLATE "C" NOT NULL,
"source_sha256" text COLLATE "C",
"source_size_bytes" bigint,
"source_record_count" bigint,
"last_run_id" text COLLATE "C" NOT NULL,
"status" text COLLATE "C" NOT NULL,
"imported_at" bigint NOT NULL,
"removed_source" bigint NOT NULL DEFAULT 0,
"report_json" text COLLATE "C" NOT NULL,
PRIMARY KEY ("source_key")
);
CREATE TABLE "native_hook_relay_bridges" (
"relay_id" text COLLATE "C" NOT NULL,
"pid" bigint NOT NULL,
"hostname" text COLLATE "C" NOT NULL,
"port" bigint NOT NULL,
"token" text COLLATE "C" NOT NULL,
"expires_at_ms" bigint NOT NULL,
"updated_at_ms" bigint NOT NULL,
PRIMARY KEY ("relay_id")
);
CREATE TABLE "official_external_plugin_catalog_snapshots" (
"feed_url" text COLLATE "C" NOT NULL,
"body" text COLLATE "C" NOT NULL,
"status" bigint NOT NULL,
"etag" text COLLATE "C",
"last_modified" text COLLATE "C",
"checksum" text COLLATE "C" NOT NULL,
"saved_at" text COLLATE "C" NOT NULL,
"trust_mode" text COLLATE "C",
"trust_key_id" text COLLATE "C",
"trust_signature_count" bigint,
"trust_threshold" bigint,
"trust_verified_at" text COLLATE "C",
"updated_at_ms" bigint NOT NULL,
PRIMARY KEY ("feed_url")
);
CREATE TABLE "operator_approvals" (
"cursor_id" bigint NOT NULL,
"approval_id" text COLLATE "C" NOT NULL,
"resolution_ref" text COLLATE "C" NOT NULL,
"kind" text COLLATE "C" NOT NULL,
"status" text COLLATE "C" NOT NULL,
"presentation_json" text COLLATE "C" NOT NULL,
"requested_by_device_id" text COLLATE "C",
"requested_by_client_id" text COLLATE "C",
"requested_by_device_token_auth" bigint NOT NULL DEFAULT 0,
"reviewer_device_ids_json" text COLLATE "C" NOT NULL,
"source_agent_id" text COLLATE "C",
"source_session_key" text COLLATE "C",
"source_session_id" text COLLATE "C",
"source_run_id" text COLLATE "C",
"source_tool_call_id" text COLLATE "C",
"source_tool_name" text COLLATE "C",
"audience_session_keys_json" text COLLATE "C" NOT NULL,
"runtime_epoch" text COLLATE "C" NOT NULL,
"created_at_ms" bigint NOT NULL,
"expires_at_ms" bigint NOT NULL,
"updated_at_ms" bigint NOT NULL,
"decision" text COLLATE "C",
"terminal_reason" text COLLATE "C",
"resolved_at_ms" bigint,
"resolver_kind" text COLLATE "C",
"resolver_id" text COLLATE "C",
"consumed_at_ms" bigint,
"consumed_by" text COLLATE "C",
PRIMARY KEY ("approval_id"),
CHECK ((char_length("approval_id") > 0) AND ("approval_id" NOT IN ('.', '..'))),
CHECK ((char_length("resolution_ref") = 43) AND ("resolution_ref" COLLATE "C" !~ '\\A.*[^A-Za-z0-9_-].*\\Z')),
CHECK (("kind" IN ('exec', 'plugin', 'system-agent'))),
CHECK (("status" IN ('pending', 'allowed', 'denied', 'expired', 'cancelled'))),
CHECK (("decision" IN ('allow-once', 'allow-always', 'deny'))),
CHECK (("terminal_reason" IN ('user', 'timeout', 'malformed-verdict', 'no-route', 'run-aborted', 'gateway-restart', 'storage-corrupt'))),
CHECK (("resolver_kind" IN ('device', 'channel', 'runtime', 'system'))),
CHECK (("expires_at_ms" >= "created_at_ms")),
CHECK (("updated_at_ms" >= "created_at_ms")),
CHECK ("resolved_at_ms" IS NULL OR ("resolved_at_ms" >= "created_at_ms")),
CHECK ("resolved_at_ms" IS NULL OR ("resolved_at_ms" <= "updated_at_ms")),
CHECK ("consumed_at_ms" IS NULL OR ("consumed_at_ms" >= "resolved_at_ms")),
CHECK ("consumed_at_ms" IS NULL OR ("consumed_at_ms" <= "updated_at_ms")),
CHECK (("requested_by_device_token_auth" IN (0, 1))),
CHECK ((("status" = 'pending') AND "decision" IS NULL AND "terminal_reason" IS NULL AND "resolved_at_ms" IS NULL AND "resolver_kind" IS NULL AND "resolver_id" IS NULL AND "consumed_at_ms" IS NULL AND "consumed_by" IS NULL) OR (("status" = 'allowed') AND ("decision" IN ('allow-once', 'allow-always')) AND ("terminal_reason" = 'user') AND "resolved_at_ms" IS NOT NULL AND "resolver_kind" IS NOT NULL) OR (("status" = 'denied') AND ("decision" = 'deny') AND ("terminal_reason" IN ('user', 'malformed-verdict', 'no-route', 'storage-corrupt')) AND "resolved_at_ms" IS NOT NULL AND "resolver_kind" IS NOT NULL AND "consumed_at_ms" IS NULL AND "consumed_by" IS NULL) OR (("status" = 'expired') AND ("decision" = 'deny') AND ("terminal_reason" = 'timeout') AND "resolved_at_ms" IS NOT NULL AND "resolver_kind" IS NOT NULL AND "consumed_at_ms" IS NULL AND "consumed_by" IS NULL) OR (("status" = 'cancelled') AND ("decision" = 'deny') AND ("terminal_reason" IN ('run-aborted', 'gateway-restart')) AND "resolved_at_ms" IS NOT NULL AND "resolver_kind" IS NOT NULL AND "consumed_at_ms" IS NULL AND "consumed_by" IS NULL)),
CHECK (("consumed_at_ms" IS NULL AND "consumed_by" IS NULL) OR (("status" = 'allowed') AND ("decision" = 'allow-once') AND "consumed_at_ms" IS NOT NULL AND "consumed_by" IS NOT NULL))
);
CREATE TABLE "outbound_media_provenance" (
"realpath" text COLLATE "C" NOT NULL,
"kind" text COLLATE "C" NOT NULL,
"version" bigint NOT NULL,
"sha256" text COLLATE "C" NOT NULL,
"size_bytes" bigint NOT NULL,
"created_at_ms" bigint NOT NULL,
PRIMARY KEY ("realpath")
);
CREATE TABLE "plugin_binding_approvals" (
"plugin_root" text COLLATE "C" NOT NULL,
"channel" text COLLATE "C" NOT NULL,
"account_id" text COLLATE "C" NOT NULL,
"plugin_id" text COLLATE "C" NOT NULL,
"plugin_name" text COLLATE "C",
"approved_at" bigint NOT NULL,
PRIMARY KEY ("plugin_root", "channel", "account_id")
);
CREATE TABLE "plugin_blob_entries" (
"plugin_id" text COLLATE "C" NOT NULL,
"namespace" text COLLATE "C" NOT NULL,
"entry_key" text COLLATE "C" NOT NULL,
"metadata_json" text COLLATE "C" NOT NULL,
"blob" bytea NOT NULL,
"created_at" bigint NOT NULL,
"expires_at" bigint,
PRIMARY KEY ("plugin_id", "namespace", "entry_key")
);
CREATE TABLE "plugin_state_entries" (
"plugin_id" text COLLATE "C" NOT NULL,
"namespace" text COLLATE "C" NOT NULL,
"entry_key" text COLLATE "C" NOT NULL,
"value_json" text COLLATE "C" NOT NULL,
"created_at" bigint NOT NULL,
"expires_at" bigint,
PRIMARY KEY ("plugin_id", "namespace", "entry_key")
);
CREATE TABLE "sandbox_registry_entries" (
"registry_kind" text COLLATE "C" NOT NULL,
"container_name" text COLLATE "C" NOT NULL,
"session_key" text COLLATE "C",
"backend_id" text COLLATE "C",
"runtime_label" text COLLATE "C",
"image" text COLLATE "C",
"created_at_ms" bigint,
"last_used_at_ms" bigint,
"config_label_kind" text COLLATE "C",
"config_hash" text COLLATE "C",
"cdp_port" bigint,
"no_vnc_port" bigint,
"entry_json" text COLLATE "C" NOT NULL,
"updated_at" bigint NOT NULL,
PRIMARY KEY ("registry_kind", "container_name")
);
CREATE TABLE "schema_meta" (
"meta_key" text COLLATE "C" NOT NULL,
"role" text COLLATE "C" NOT NULL,
"schema_version" bigint NOT NULL,
"agent_id" text COLLATE "C",
"app_version" text COLLATE "C",
"created_at" bigint NOT NULL,
"updated_at" bigint NOT NULL,
PRIMARY KEY ("meta_key")
);
CREATE TABLE "session_groups" (
"name" text COLLATE "C" NOT NULL,
"position" bigint NOT NULL,
"created_at" bigint NOT NULL,
"cwd" text COLLATE "C",
"worktree" bigint,
PRIMARY KEY ("name")
);
CREATE TABLE "session_state_events" (
"sequence" bigint GENERATED BY DEFAULT AS IDENTITY NOT NULL,
"dedupe_key" text COLLATE "C",
"session_key" text COLLATE "C" NOT NULL,
"session_id" text COLLATE "C",
"agent_id" text COLLATE "C" NOT NULL,
"kind" text COLLATE "C" NOT NULL,
"actor_type" text COLLATE "C" NOT NULL,
"actor_id" text COLLATE "C",
"run_id" text COLLATE "C",
"occurred_at" bigint NOT NULL,
"summary" text COLLATE "C" NOT NULL,
"payload_json" text COLLATE "C",
PRIMARY KEY ("sequence"),
UNIQUE ("dedupe_key")
);
CREATE TABLE "session_state_heads" (
"session_key" text COLLATE "C" NOT NULL,
"agent_id" text COLLATE "C" NOT NULL,
"last_sequence" bigint NOT NULL,
"pruned_max_sequence" bigint NOT NULL DEFAULT 0,
"updated_at" bigint NOT NULL,
PRIMARY KEY ("session_key", "agent_id")
);
CREATE TABLE "session_upstream_links" (
"session_key" text COLLATE "C" NOT NULL,
"agent_id" text COLLATE "C" NOT NULL,
"catalog_id" text COLLATE "C" NOT NULL,
"host_id" text COLLATE "C" NOT NULL,
"thread_id" text COLLATE "C" NOT NULL,
"upstream_kind" text COLLATE "C" NOT NULL,
"upstream_ref_json" text COLLATE "C",
"last_marker_json" text COLLATE "C",
"last_scanned_at" bigint,
"created_at" bigint NOT NULL,
"updated_at" bigint NOT NULL,
PRIMARY KEY ("session_key", "agent_id")
);
CREATE TABLE "session_watch_cursors" (
"watcher_session_key" text COLLATE "C" NOT NULL,
"watcher_store_path" text COLLATE "C",
"target_session_key" text COLLATE "C" NOT NULL,
"last_seen_sequence" bigint NOT NULL DEFAULT 0,
"notified_sequence" bigint NOT NULL DEFAULT 0,
"material_sequence" bigint NOT NULL DEFAULT 0,
"provenance" text COLLATE "C" NOT NULL DEFAULT 'explicit',
"updated_at" bigint NOT NULL,
PRIMARY KEY ("watcher_session_key", "target_session_key"),
CHECK (("provenance" IN ('explicit', 'ambient-group')))
);
CREATE TABLE "skill_upload_chunks" (
"upload_id" text COLLATE "C" NOT NULL,
"byte_offset" bigint NOT NULL,
"size_bytes" bigint NOT NULL,
"chunk_blob" bytea NOT NULL,
PRIMARY KEY ("upload_id", "byte_offset"),
CHECK (("byte_offset" >= 0)),
CHECK (("size_bytes" > 0)),
CHECK ((octet_length("chunk_blob") = "size_bytes"))
);
CREATE TABLE "skill_uploads" (
"upload_id" text COLLATE "C" NOT NULL,
"kind" text COLLATE "C" NOT NULL,
"slug" text COLLATE "C" NOT NULL,
"force" bigint NOT NULL,
"size_bytes" bigint NOT NULL,
"sha256" text COLLATE "C",
"actual_sha256" text COLLATE "C",
"received_bytes" bigint NOT NULL,
"archive_blob" bytea NOT NULL,
"created_at" bigint NOT NULL,
"expires_at" bigint NOT NULL,
"committed" bigint NOT NULL,
"committed_at" bigint,
"idempotency_key_hash" text COLLATE "C",
PRIMARY KEY ("upload_id"),
UNIQUE ("idempotency_key_hash")
);
CREATE TABLE "skill_usage" (
"skill_file" text COLLATE "C" NOT NULL,
"skill_key" text COLLATE "C" NOT NULL,
"skill_name" text COLLATE "C" NOT NULL,
"skill_source" text COLLATE "C" NOT NULL,
"first_used_at_ms" bigint NOT NULL,
"last_used_at_ms" bigint NOT NULL,
"use_count" bigint NOT NULL,
"last_agent_id" text COLLATE "C",
PRIMARY KEY ("skill_file")
);
CREATE TABLE "state_leases" (
"scope" text COLLATE "C" NOT NULL,
"lease_key" text COLLATE "C" NOT NULL,
"owner" text COLLATE "C" NOT NULL,
"expires_at" bigint,
"heartbeat_at" bigint,
"payload_json" text COLLATE "C",
"created_at" bigint NOT NULL,
"updated_at" bigint NOT NULL,
PRIMARY KEY ("scope", "lease_key")
);
CREATE TABLE "subagent_runs" (
"run_id" text COLLATE "C" NOT NULL,
"child_session_key" text COLLATE "C" NOT NULL,
"controller_session_key" text COLLATE "C",
"controller_store_path" text COLLATE "C",
"requester_session_key" text COLLATE "C" NOT NULL,
"requester_store_path" text COLLATE "C",
"created_at" bigint NOT NULL,
"payload_json" text COLLATE "C" NOT NULL DEFAULT '{}',
PRIMARY KEY ("run_id")
);
CREATE TABLE "task_delivery_state" (
"task_id" text COLLATE "C" NOT NULL,
"requester_origin_json" text COLLATE "C",
"last_notified_event_at" bigint,
PRIMARY KEY ("task_id")
);
CREATE TABLE "task_runs" (
"task_id" text COLLATE "C" NOT NULL,
"runtime" text COLLATE "C" NOT NULL,
"task_kind" text COLLATE "C",
"source_id" text COLLATE "C",
"requester_session_key" text COLLATE "C",
"owner_key" text COLLATE "C" NOT NULL,
"scope_kind" text COLLATE "C" NOT NULL,
"child_session_key" text COLLATE "C",
"parent_flow_id" text COLLATE "C",
"parent_task_id" text COLLATE "C",
"agent_id" text COLLATE "C",
"requester_agent_id" text COLLATE "C",
"run_id" text COLLATE "C",
"execution_owner_host" text COLLATE "C",
"execution_owner_pid" bigint,
"execution_owner_start_identity" bigint,
"label" text COLLATE "C",
"task" text COLLATE "C" NOT NULL,
"status" text COLLATE "C" NOT NULL,
"delivery_status" text COLLATE "C" NOT NULL,
"notify_policy" text COLLATE "C" NOT NULL,
"created_at" bigint NOT NULL,
"started_at" bigint,
"ended_at" bigint,
"last_event_at" bigint,
"cleanup_after" bigint,
"tool_use_count" bigint,
"last_tool_name" text COLLATE "C",
"error" text COLLATE "C",
"progress_summary" text COLLATE "C",
"terminal_summary" text COLLATE "C",
"terminal_outcome" text COLLATE "C",
"detail_json" text COLLATE "C",
PRIMARY KEY ("task_id")
);
CREATE TABLE "template_cron_refs" (
"agent_id" text COLLATE "C" NOT NULL,
"manifest_id" text COLLATE "C" NOT NULL,
"schema_version" text COLLATE "C" NOT NULL,
"declaration_key" text COLLATE "C" NOT NULL,
"scheduler_job_id" text COLLATE "C",
"status" text COLLATE "C" NOT NULL,
"job_json" text COLLATE "C" NOT NULL,
"error" text COLLATE "C",
"created_at_ms" bigint NOT NULL,
"updated_at_ms" bigint NOT NULL,
PRIMARY KEY ("agent_id", "manifest_id"),
UNIQUE ("declaration_key"),
UNIQUE ("scheduler_job_id")
);
CREATE TABLE "template_installs" (
"agent_id" text COLLATE "C" NOT NULL,
"schema_version" text COLLATE "C" NOT NULL,
"source_kind" text COLLATE "C" NOT NULL,
"template_name" text COLLATE "C" NOT NULL,
"template_version" text COLLATE "C" NOT NULL,
"package_root" text COLLATE "C" NOT NULL,
"manifest_path" text COLLATE "C" NOT NULL,
"integrity_kind" text COLLATE "C" NOT NULL,
"integrity" text COLLATE "C" NOT NULL,
"source_byte_length" bigint NOT NULL,
"manifest_schema_version" bigint NOT NULL,
"plan_integrity" text COLLATE "C" NOT NULL,
"workspace" text COLLATE "C" NOT NULL,
"agent_config_digest" text COLLATE "C" NOT NULL,
"agent_owned_paths_json" text COLLATE "C" NOT NULL,
"bootstrap_source_path" text COLLATE "C",
"bootstrap_content_digest" text COLLATE "C",
"status" text COLLATE "C" NOT NULL,
"added_at_ms" bigint NOT NULL,
"updated_at_ms" bigint NOT NULL,
PRIMARY KEY ("agent_id"),
CHECK (("status" IN ('pending', 'workspace_ready', 'config_committed', 'complete', 'partial'))),
UNIQUE ("workspace")
);
CREATE TABLE "template_mcp_server_refs" (
"agent_id" text COLLATE "C" NOT NULL,
"name" text COLLATE "C" NOT NULL,
"schema_version" text COLLATE "C" NOT NULL,
"config_digest" text COLLATE "C" NOT NULL,
"relationship" text COLLATE "C" NOT NULL,
"origin" text COLLATE "C" NOT NULL,
"independent_owner" bigint NOT NULL DEFAULT 0,
"status" text COLLATE "C" NOT NULL,
"error" text COLLATE "C",
"created_at_ms" bigint NOT NULL,
"updated_at_ms" bigint NOT NULL,
PRIMARY KEY ("agent_id", "name"),
CHECK (("relationship" IN ('managed', 'referenced'))),
CHECK (("origin" IN ('template-introduced', 'pre-existing'))),
CHECK (("independent_owner" IN (0, 1)))
);
CREATE TABLE "template_package_refs" (
"agent_id" text COLLATE "C" NOT NULL,
"package_kind" text COLLATE "C" NOT NULL,
"package_source" text COLLATE "C" NOT NULL,
"package_ref" text COLLATE "C" NOT NULL,
"package_version" text COLLATE "C" NOT NULL,
"package_integrity" text COLLATE "C" NOT NULL,
"schema_version" text COLLATE "C" NOT NULL,
"template_name" text COLLATE "C" NOT NULL,
"package_status" text COLLATE "C" NOT NULL,
"relationship" text COLLATE "C" NOT NULL,
"origin" text COLLATE "C" NOT NULL,
"independent_owner" bigint NOT NULL,
"extension_id" text COLLATE "C",
"extension_format" text COLLATE "C",
"extension_detected_format" text COLLATE "C",
"extension_mapped_json" text COLLATE "C",
"extension_unavailable_json" text COLLATE "C",
"extension_adapter_identity" text COLLATE "C",
"installed_at_ms" bigint NOT NULL,
"updated_at_ms" bigint NOT NULL,
PRIMARY KEY ("agent_id", "package_kind", "package_source", "package_ref", "package_version"),
CHECK (("relationship" IN ('managed', 'referenced'))),
CHECK (("origin" IN ('template-introduced', 'pre-existing'))),
CHECK (("independent_owner" IN (0, 1)))
);
CREATE TABLE "template_workspace_files" (
"agent_id" text COLLATE "C" NOT NULL,
"target_path" text COLLATE "C" NOT NULL,
"schema_version" text COLLATE "C" NOT NULL,
"workspace" text COLLATE "C" NOT NULL,
"source_path" text COLLATE "C" NOT NULL,
"content_digest" text COLLATE "C" NOT NULL,
"status" text COLLATE "C" NOT NULL,
"created_at_ms" bigint NOT NULL,
"updated_at_ms" bigint NOT NULL,
PRIMARY KEY ("agent_id", "target_path")
);
CREATE TABLE "web_push_subscriptions" (
"endpoint_hash" text COLLATE "C" NOT NULL,
"subscription_id" text COLLATE "C" NOT NULL,
"endpoint" text COLLATE "C" NOT NULL,
"p256dh" text COLLATE "C" NOT NULL,
"auth" text COLLATE "C" NOT NULL,
"device_id" text COLLATE "C",
"user_profile_id" text COLLATE "C",
"preferences_json" text COLLATE "C",
"created_at_ms" bigint NOT NULL,
"updated_at_ms" bigint NOT NULL,
PRIMARY KEY ("endpoint_hash"),
UNIQUE ("subscription_id")
);
CREATE TABLE "worker_environment_credentials" (
"environment_id" text COLLATE "C" NOT NULL,
"credential_hash" text COLLATE "C" NOT NULL,
"bundle_hash" text COLLATE "C" NOT NULL,
"session_id" text COLLATE "C",
"rpc_set_version" bigint NOT NULL,
"owner_epoch" bigint NOT NULL,
"expires_at_ms" bigint NOT NULL,
"delivered_at_ms" bigint,
PRIMARY KEY ("environment_id"),
CHECK (("rpc_set_version" >= 1)),
CHECK (("owner_epoch" >= 0)),
CHECK (("expires_at_ms" >= 0)),
CHECK (("delivered_at_ms" >= 0)),
UNIQUE ("credential_hash")
);
CREATE TABLE "worker_environments" (
"environment_id" text COLLATE "C" NOT NULL,
"provider_id" text COLLATE "C" NOT NULL,
"profile_id" text COLLATE "C" NOT NULL,
"profile_snapshot_json" text COLLATE "C" NOT NULL,
"last_activated_at_ms" bigint,
"preparation_key" text COLLATE "C",
"preparation_purpose" text COLLATE "C",
"preparation_demand_at_ms" bigint,
"preparation_expires_at_ms" bigint,
"preparation_consumed_at_ms" bigint,
"provision_operation_id" text COLLATE "C" NOT NULL,
"lease_id" text COLLATE "C",
"node_setup_id" text COLLATE "C",
"node_device_id" text COLLATE "C",
"ssh_host" text COLLATE "C",
"ssh_port" bigint,
"ssh_user" text COLLATE "C",
"ssh_host_key" text COLLATE "C",
"ssh_key_ref_json" text COLLATE "C",
"desktop_json" text COLLATE "C",
"state" text COLLATE "C" NOT NULL,
"bootstrap_bundle_hash" text COLLATE "C",
"bootstrap_openclaw_version" text COLLATE "C",
"bootstrap_protocol_features_json" text COLLATE "C",
"bootstrap_install_kind" text COLLATE "C",
"owner_epoch" bigint NOT NULL DEFAULT 0,
"teardown_terminal_state" text COLLATE "C",
"attached_session_ids_json" text COLLATE "C" NOT NULL DEFAULT '[]',
"created_at_ms" bigint NOT NULL,
"updated_at_ms" bigint NOT NULL,
"state_changed_at_ms" bigint NOT NULL,
"idle_since_at_ms" bigint,
"destroy_requested_at_ms" bigint,
"last_error" text COLLATE "C",
"shared_host" bigint,
"resource_receipt_json" text COLLATE "C",
"retention_json" text COLLATE "C",
"provision_source_json" text COLLATE "C",
PRIMARY KEY ("environment_id"),
CHECK (("preparation_key" IS NULL AND "preparation_demand_at_ms" IS NULL AND "preparation_expires_at_ms" IS NULL AND "preparation_consumed_at_ms" IS NULL) OR ("preparation_key" IS NOT NULL AND (char_length("preparation_key") = 64) AND ("preparation_key" COLLATE "C" !~ '\\A.*[^0-9a-f].*\\Z') AND "preparation_demand_at_ms" IS NOT NULL AND ("preparation_demand_at_ms" BETWEEN 0 AND 9007199254740991) AND "preparation_expires_at_ms" IS NOT NULL AND ("preparation_expires_at_ms" > "preparation_demand_at_ms") AND ("preparation_expires_at_ms" <= 9007199254740991) AND ("preparation_consumed_at_ms" IS NULL OR (("preparation_consumed_at_ms" >= "preparation_demand_at_ms") AND ("preparation_consumed_at_ms" < "preparation_expires_at_ms"))))),
CHECK ("ssh_port" IS NULL OR (("ssh_port" >= 1) AND ("ssh_port" <= 65535))),
CHECK (("state" IN ('requested', 'provisioning', 'bootstrapping', 'ready', 'attached', 'idle', 'draining', 'destroying', 'destroyed', 'failed', 'orphaned'))),
CHECK (("owner_epoch" >= 0)),
CHECK (("teardown_terminal_state" IN ('destroyed', 'failed'))),
UNIQUE ("provision_operation_id")
);
CREATE TABLE "worker_inference_turns" (
"session_id" text COLLATE "C" NOT NULL,
"run_epoch" bigint NOT NULL,
"run_id" text COLLATE "C" NOT NULL,
"turn_id" text COLLATE "C" NOT NULL,
"environment_id" text COLLATE "C" NOT NULL,
"request_hash" text COLLATE "C" NOT NULL,
"state" text COLLATE "C" NOT NULL,
"terminal_json" text COLLATE "C",
"created_at_ms" bigint NOT NULL,
"updated_at_ms" bigint NOT NULL,
PRIMARY KEY ("session_id", "run_epoch", "run_id", "turn_id"),
CHECK (("run_epoch" >= 0)),
CHECK (("state" IN ('pending', 'terminal'))),
CHECK (("created_at_ms" >= 0)),
CHECK (("updated_at_ms" >= 0)),
CHECK ((("state" = 'pending') AND "terminal_json" IS NULL) OR (("state" = 'terminal') AND "terminal_json" IS NOT NULL))
);
CREATE TABLE "worker_session_placements" (
"session_id" text COLLATE "C" NOT NULL,
"agent_id" text COLLATE "C" NOT NULL,
"session_key" text COLLATE "C" NOT NULL,
"execution_mode" text COLLATE "C",
"state" text COLLATE "C" NOT NULL,
"environment_id" text COLLATE "C",
"transition_generation" bigint NOT NULL DEFAULT 0,
"active_owner_epoch" bigint,
"workspace_base_manifest_ref" text COLLATE "C",
"remote_workspace_dir" text COLLATE "C",
"worker_bundle_hash" text COLLATE "C",
"last_transcript_ack_cursor" bigint,
"last_live_event_ack_cursor" bigint,
"recovery_error" text COLLATE "C",
"turn_claim_owner" text COLLATE "C",
"turn_claim_id" text COLLATE "C",
"turn_claim_run_id" text COLLATE "C",
"turn_claim_generation" bigint,
"turn_claim_owner_epoch" bigint,
"created_at_ms" bigint NOT NULL,
"updated_at_ms" bigint NOT NULL,
"state_changed_at_ms" bigint NOT NULL,
"terminal_reason" text COLLATE "C",
"terminal_at_ms" bigint,
PRIMARY KEY ("session_id"),
CHECK (("execution_mode" IN ('worker-turn', 'remote-exec'))),
CHECK (("state" IN ('local', 'requested', 'provisioning', 'syncing', 'starting', 'active', 'draining', 'reconciling', 'reclaimed', 'failed'))),
CHECK (("transition_generation" >= 0)),
CHECK ("active_owner_epoch" IS NULL OR ("active_owner_epoch" >= 1)),
CHECK ("last_transcript_ack_cursor" IS NULL OR ("last_transcript_ack_cursor" >= 0)),
CHECK ("last_live_event_ack_cursor" IS NULL OR ("last_live_event_ack_cursor" >= 0)),
CHECK (("turn_claim_owner" IN ('local', 'worker'))),
CHECK ("turn_claim_generation" IS NULL OR ("turn_claim_generation" >= 0)),
CHECK ("turn_claim_owner_epoch" IS NULL OR ("turn_claim_owner_epoch" >= 1)),
CHECK ((("state" IN ('local', 'requested')) AND "environment_id" IS NULL AND "active_owner_epoch" IS NULL AND "workspace_base_manifest_ref" IS NULL AND "remote_workspace_dir" IS NULL AND "worker_bundle_hash" IS NULL AND "last_transcript_ack_cursor" IS NULL AND "last_live_event_ack_cursor" IS NULL AND "recovery_error" IS NULL) OR ("state" IS NOT DISTINCT FROM 'provisioning' AND "active_owner_epoch" IS NULL AND "workspace_base_manifest_ref" IS NULL AND "remote_workspace_dir" IS NULL AND "worker_bundle_hash" IS NULL AND "last_transcript_ack_cursor" IS NULL AND "last_live_event_ack_cursor" IS NULL AND "recovery_error" IS NULL) OR ("state" IS NOT DISTINCT FROM 'syncing' AND "environment_id" IS NOT NULL AND "active_owner_epoch" IS NULL AND "workspace_base_manifest_ref" IS NULL AND "remote_workspace_dir" IS NULL AND "worker_bundle_hash" IS NOT NULL AND "last_transcript_ack_cursor" IS NULL AND "last_live_event_ack_cursor" IS NULL AND "recovery_error" IS NULL) OR ("state" IS NOT DISTINCT FROM 'starting' AND "environment_id" IS NOT NULL AND "active_owner_epoch" IS NULL AND "workspace_base_manifest_ref" IS NOT NULL AND "remote_workspace_dir" IS NOT NULL AND "worker_bundle_hash" IS NOT NULL AND "last_transcript_ack_cursor" IS NULL AND "last_live_event_ack_cursor" IS NULL AND "recovery_error" IS NULL) OR (("state" IN ('active', 'draining', 'reconciling')) AND "environment_id" IS NOT NULL AND "active_owner_epoch" IS NOT NULL AND "workspace_base_manifest_ref" IS NOT NULL AND "remote_workspace_dir" IS NOT NULL AND "worker_bundle_hash" IS NOT NULL AND "recovery_error" IS NULL) OR ("state" IS NOT DISTINCT FROM 'reclaimed' AND "environment_id" IS NOT NULL AND "active_owner_epoch" IS NOT NULL AND "workspace_base_manifest_ref" IS NOT NULL AND "remote_workspace_dir" IS NOT NULL AND "worker_bundle_hash" IS NOT NULL AND "recovery_error" IS NULL AND "turn_claim_owner" IS NULL AND "turn_claim_id" IS NULL AND "turn_claim_run_id" IS NULL AND "turn_claim_generation" IS NULL AND "turn_claim_owner_epoch" IS NULL) OR ("state" IS NOT DISTINCT FROM 'failed' AND "recovery_error" IS NOT NULL)),
CHECK (("turn_claim_owner" IS NULL AND "turn_claim_id" IS NULL AND "turn_claim_run_id" IS NULL AND "turn_claim_generation" IS NULL AND "turn_claim_owner_epoch" IS NULL) OR ("turn_claim_owner" IS NOT DISTINCT FROM 'local' AND "turn_claim_id" IS NOT NULL AND "turn_claim_run_id" IS NOT NULL AND "turn_claim_generation" IS NOT NULL AND "turn_claim_owner_epoch" IS NULL) OR ("turn_claim_owner" IS NOT DISTINCT FROM 'worker' AND "turn_claim_id" IS NOT NULL AND "turn_claim_run_id" IS NOT NULL AND "turn_claim_generation" IS NOT NULL AND "turn_claim_owner_epoch" IS NOT NULL)),
CHECK ("turn_claim_owner" IS NULL OR ("turn_claim_owner" IS NOT DISTINCT FROM 'local' AND (("state" IN ('local', 'requested', 'failed')) OR (("state" IN ('active', 'draining')) AND "execution_mode" IS NOT DISTINCT FROM 'remote-exec'))) OR ("turn_claim_owner" IS NOT DISTINCT FROM 'worker' AND ("state" IN ('active', 'draining')) AND ("execution_mode" IS NULL OR "execution_mode" IS NOT DISTINCT FROM 'worker-turn') AND "turn_claim_owner_epoch" IS NOT DISTINCT FROM "active_owner_epoch"))
);
CREATE TABLE "worker_session_tool_operations" (
"source_session_id" text COLLATE "C" NOT NULL,
"source_claim_id" text COLLATE "C" NOT NULL,
"tool_call_id" text COLLATE "C" NOT NULL,
"tool_name" text COLLATE "C" NOT NULL,
"request_digest" text COLLATE "C" NOT NULL,
"operation_seed" text COLLATE "C" NOT NULL,
"status" text COLLATE "C" NOT NULL,
"child_session_key" text COLLATE "C",
"result_json" text COLLATE "C",
"gateway_instance_id" text COLLATE "C" NOT NULL,
"created_at_ms" bigint NOT NULL,
"updated_at_ms" bigint NOT NULL,
PRIMARY KEY ("source_session_id", "source_claim_id", "tool_call_id"),
CHECK (("tool_name" IN ('sessions_spawn', 'sessions_send'))),
CHECK (("status" IN ('running', 'succeeded', 'failed', 'unknown')))
);
CREATE TABLE "worker_transcript_commit_heads" (
"session_id" text COLLATE "C" NOT NULL,
"run_epoch" bigint NOT NULL,
"environment_id" text COLLATE "C" NOT NULL,
"next_seq" bigint NOT NULL,
"updated_at_ms" bigint NOT NULL,
PRIMARY KEY ("session_id", "run_epoch"),
CHECK (("run_epoch" >= 0)),
CHECK (("next_seq" >= 1)),
CHECK (("updated_at_ms" >= 0))
);
CREATE TABLE "worker_transcript_commits" (
"session_id" text COLLATE "C" NOT NULL,
"run_epoch" bigint NOT NULL,
"seq" bigint NOT NULL,
"request_hash" text COLLATE "C" NOT NULL,
"state" text COLLATE "C" NOT NULL,
"result_json" text COLLATE "C",
"created_at_ms" bigint NOT NULL,
"updated_at_ms" bigint NOT NULL,
PRIMARY KEY ("session_id", "run_epoch", "seq"),
CHECK (("run_epoch" >= 0)),
CHECK (("seq" >= 1)),
CHECK (("state" IN ('pending', 'terminal'))),
CHECK (("created_at_ms" >= 0)),
CHECK (("updated_at_ms" >= 0)),
CHECK ((("state" = 'pending') AND "result_json" IS NULL) OR (("state" = 'terminal') AND "result_json" IS NOT NULL))
);
CREATE TABLE "worker_turn_tool_authorities" (
"session_id" text COLLATE "C" NOT NULL,
"environment_id" text COLLATE "C" NOT NULL,
"owner_epoch" bigint NOT NULL,
"placement_generation" bigint NOT NULL,
"claim_id" text COLLATE "C" NOT NULL,
"run_id" text COLLATE "C" NOT NULL,
"tool_names_json" text COLLATE "C" NOT NULL,
"updated_at_ms" bigint NOT NULL,
PRIMARY KEY ("session_id"),
CHECK (("owner_epoch" >= 1)),
CHECK (("placement_generation" >= 0))
);
CREATE TABLE "worker_workspace_pending_results" (
"session_id" text COLLATE "C" NOT NULL,
"environment_id" text COLLATE "C" NOT NULL,
"owner_epoch" bigint NOT NULL,
"placement_generation" bigint NOT NULL,
"claim_id" text COLLATE "C" NOT NULL,
"run_id" text COLLATE "C" NOT NULL,
"gateway_instance_id" text COLLATE "C" NOT NULL,
"recovery_requested_at_ms" bigint,
"workspace_accepted_at_ms" bigint,
"staged_result_ref" text COLLATE "C",
"repository_workspace_id" text COLLATE "C",
"created_at_ms" bigint NOT NULL,
"repository_disk_authority_json" text COLLATE "C",
PRIMARY KEY ("session_id"),
CHECK (("owner_epoch" >= 1)),
CHECK (("placement_generation" >= 0))
);
CREATE TABLE "worker_workspace_reconciliations" (
"session_id" text COLLATE "C" NOT NULL,
"environment_id" text COLLATE "C" NOT NULL,
"owner_epoch" bigint NOT NULL,
"placement_generation" bigint NOT NULL,
"base_manifest_ref" text COLLATE "C" NOT NULL,
"current_manifest_ref" text COLLATE "C" NOT NULL,
"plan_json" text COLLATE "C" NOT NULL,
"base_pack" bytea NOT NULL,
"created_at_ms" bigint NOT NULL,
PRIMARY KEY ("session_id"),
CHECK (("owner_epoch" >= 1)),
CHECK (("placement_generation" >= 0)),
CHECK ((octet_length("base_pack") <= 268435456))
);
CREATE TABLE "workspace_generated_bootstrap_hashes" (
"workspace_key" text COLLATE "C" NOT NULL,
"filename" text COLLATE "C" NOT NULL,
"sha256" text COLLATE "C" NOT NULL,
PRIMARY KEY ("workspace_key", "filename")
);
CREATE TABLE "workspace_path_aliases" (
"alias_key" text COLLATE "C" NOT NULL,
"alias_path" text COLLATE "C" NOT NULL,
"workspace_key" text COLLATE "C" NOT NULL,
"workspace_path" text COLLATE "C" NOT NULL,
"updated_at_ms" bigint NOT NULL,
PRIMARY KEY ("alias_key")
);
CREATE TABLE "workspace_setup_state" (
"workspace_key" text COLLATE "C" NOT NULL,
"workspace_path" text COLLATE "C",
"version" bigint,
"bootstrap_seeded_at" text COLLATE "C",
"setup_completed_at" text COLLATE "C",
"updated_at" bigint,
"attested_at_ms" bigint,
"attestation_updated_at_ms" bigint,
"bootstrap_deferred" bigint,
PRIMARY KEY ("workspace_key"),
CHECK ("version" IS NULL OR "workspace_path" IS NOT NULL)
);
CREATE TABLE "worktree_provisioned_file_chunks" (
"worktree_id" text COLLATE "C" NOT NULL,
"path" text COLLATE "C" NOT NULL,
"chunk_index" bigint NOT NULL,
"data" bytea NOT NULL,
PRIMARY KEY ("worktree_id", "path", "chunk_index"),
CHECK (("chunk_index" >= 0))
);
CREATE TABLE "worktrees" (
"id" text COLLATE "C" NOT NULL,
"repo_fingerprint" text COLLATE "C" NOT NULL,
"repo_root" text COLLATE "C" NOT NULL,
"path" text COLLATE "C" NOT NULL,
"branch" text COLLATE "C" NOT NULL,
"base_ref" text COLLATE "C" NOT NULL,
"owner_kind" text COLLATE "C" NOT NULL,
"owner_id" text COLLATE "C",
"snapshot_ref" text COLLATE "C",
"provisioned_paths_json" text COLLATE "C",
"created_at" bigint NOT NULL,
"last_active_at" bigint NOT NULL,
"removed_at" bigint,
"run_end_cleanup_json" text COLLATE "C",
"gc_protection_json" text COLLATE "C",
PRIMARY KEY ("id"),
CHECK (("owner_kind" IN ('manual', 'workboard', 'session')))
);
CREATE INDEX "idx_acp_replay_sessions_key_updated" ON "acp_replay_sessions" (("session_key") ASC, ("complete") ASC, ("updated_at") DESC, ("session_id") ASC);
CREATE INDEX "idx_acp_replay_sessions_updated" ON "acp_replay_sessions" (("updated_at") DESC, ("session_id") ASC);
CREATE INDEX "idx_acp_sessions_agent_activity" ON "acp_sessions" (("agent") ASC, ("last_activity_at") DESC, ("session_key") ASC);
CREATE INDEX "idx_acp_sessions_resume_acpx" ON "acp_sessions" (("resume_acpx_session_id") ASC NULLS FIRST);
CREATE INDEX "idx_acp_sessions_resume_agent" ON "acp_sessions" (("resume_agent_session_id") ASC NULLS FIRST);
CREATE INDEX "idx_acp_sessions_state_activity" ON "acp_sessions" (("state") ASC, ("last_activity_at") DESC, ("session_key") ASC);
CREATE INDEX "idx_apns_registrations_updated" ON "apns_registrations" (("updated_at_ms") DESC, ("node_id") ASC);
CREATE INDEX "idx_audit_events_agent_sequence" ON "audit_events" (("agent_id") ASC NULLS FIRST, ("sequence") DESC);
CREATE INDEX "idx_audit_events_channel_sequence" ON "audit_events" (("channel") ASC NULLS FIRST, ("sequence") DESC);
CREATE INDEX "idx_audit_events_direction_sequence" ON "audit_events" (("direction") ASC NULLS FIRST, ("sequence") DESC);
CREATE INDEX "idx_audit_events_kind_sequence" ON "audit_events" (("kind") ASC, ("sequence") DESC);
CREATE INDEX "idx_audit_events_run_sequence" ON "audit_events" (("run_id") ASC NULLS FIRST, ("sequence") DESC);
CREATE INDEX "idx_audit_events_session_sequence" ON "audit_events" (("session_key") ASC NULLS FIRST, ("sequence") DESC);
CREATE INDEX "idx_audit_events_status_sequence" ON "audit_events" (("status") ASC, ("sequence") DESC);
CREATE INDEX "idx_audit_events_time" ON "audit_events" (("occurred_at") DESC, ("sequence") DESC);
CREATE INDEX "idx_backup_runs_created" ON "backup_runs" (("created_at") DESC, ("id") ASC);
CREATE INDEX "capture_events_flow_idx" ON "capture_events" (("flow_id") ASC, ("ts") ASC);
CREATE INDEX "capture_events_session_ts_idx" ON "capture_events" (("session_id") ASC, ("ts") ASC);
CREATE INDEX "idx_channel_ingress_claims" ON "channel_ingress_events" (("queue_name") ASC, ("status") ASC, ("claimed_at") ASC NULLS FIRST);
CREATE INDEX "idx_channel_ingress_lane" ON "channel_ingress_events" (("queue_name") ASC, ("status") ASC, ("lane_key") ASC NULLS FIRST);
CREATE INDEX "idx_channel_ingress_pending" ON "channel_ingress_events" (("queue_name") ASC, ("status") ASC, ("received_at") ASC, ("event_id") ASC);
CREATE INDEX "idx_channel_pairing_allow_account" ON "channel_pairing_allow_entries" (("channel_key") ASC, ("account_id") ASC, ("sort_order") ASC, ("entry") ASC);
CREATE INDEX "idx_channel_pairing_requests_code" ON "channel_pairing_requests" (("channel_key") ASC, ("code") ASC);
CREATE INDEX "idx_channel_pairing_requests_created" ON "channel_pairing_requests" (("channel_key") ASC, ("created_at") ASC, ("request_id") ASC);
CREATE INDEX "idx_cron_job_scratch_store_updated" ON "cron_job_scratch" (("store_key") ASC, ("updated_at_ms") DESC, ("job_id") ASC);
CREATE INDEX "idx_cron_jobs_store_order" ON "cron_jobs" (("store_key") ASC, ("sort_order") ASC, ("updated_at") ASC, ("job_id") ASC);
CREATE INDEX "idx_current_conversation_bindings_conversation" ON "current_conversation_bindings" (("channel") ASC, ("account_id") ASC, ("conversation_kind") ASC, ("conversation_id") ASC);
CREATE INDEX "idx_current_conversation_bindings_expires" ON "current_conversation_bindings" (("expires_at") ASC NULLS FIRST, ("binding_key") ASC);
CREATE INDEX "idx_current_conversation_bindings_target" ON "current_conversation_bindings" (("target_session_key") ASC, ("updated_at") DESC, ("binding_key") ASC);
CREATE INDEX "idx_delivery_queue_bounded_retention" ON "delivery_queue_entries" (("queue_name") ASC, ("retention_id_prefix") ASC, ("enqueued_at") DESC, ("id") DESC) WHERE ("status" IN ('completed', 'failed')) AND ("recovery_state" = 'completed_bounded') AND "retention_id_prefix" IS NOT NULL;
CREATE INDEX "idx_delivery_queue_failed" ON "delivery_queue_entries" (("status") ASC, ("queue_name") ASC, ("failed_at") ASC NULLS FIRST, ("id") ASC);
CREATE INDEX "idx_delivery_queue_pending" ON "delivery_queue_entries" (("queue_name") ASC, ("status") ASC, ("enqueued_at") ASC, ("id") ASC);
CREATE INDEX "idx_delivery_queue_session" ON "delivery_queue_entries" (("queue_name") ASC, ("status") ASC, ("session_key") ASC, ("enqueued_at") ASC, ("id") ASC) WHERE "session_key" IS NOT NULL;
CREATE INDEX "idx_delivery_queue_target" ON "delivery_queue_entries" (("queue_name") ASC, ("status") ASC, ("channel") ASC, ("target") ASC, ("enqueued_at") ASC, ("id") ASC) WHERE "channel" IS NOT NULL AND "target" IS NOT NULL;
CREATE INDEX "idx_device_bootstrap_tokens_ts" ON "device_bootstrap_tokens" (("ts") ASC);
CREATE INDEX "idx_device_pairing_paired_approved" ON "device_pairing_paired" (("approved_at_ms") DESC, ("device_id") ASC);
CREATE INDEX "idx_device_pairing_pending_device" ON "device_pairing_pending" (("device_id") ASC, ("ts") DESC);
CREATE INDEX "idx_diagnostic_events_scope_sequence" ON "diagnostic_events" (("scope") ASC, ("sequence") ASC, ("event_key") ASC);
CREATE INDEX "idx_flow_runs_owner_key" ON "flow_runs" (("owner_key") ASC);
CREATE INDEX "idx_flow_runs_status" ON "flow_runs" (("status") ASC);
CREATE INDEX "idx_flow_runs_updated_at" ON "flow_runs" (("updated_at") ASC);
CREATE INDEX "idx_gateway_boot_lifecycle_started" ON "gateway_boot_lifecycle" (("started_at_ms") ASC);
CREATE INDEX "idx_gateway_restart_handoff_expiry" ON "gateway_restart_handoff" (("expires_at") ASC, ("pid") ASC);
CREATE INDEX "idx_gateway_restart_sentinel_ts" ON "gateway_restart_sentinel" (("ts") DESC, ("sentinel_key") ASC);
CREATE INDEX "idx_macos_port_guardian_records_port" ON "macos_port_guardian_records" (("port") ASC, ("timestamp") DESC);
CREATE INDEX "idx_managed_outgoing_images_agent_message" ON "managed_outgoing_image_records" (("session_key") ASC, ("agent_id") ASC NULLS FIRST, ("message_id") ASC, ("attachment_id") ASC) WHERE "message_id" IS NOT NULL;
CREATE INDEX "idx_managed_outgoing_images_agent_session" ON "managed_outgoing_image_records" (("session_key") ASC, ("agent_id") ASC NULLS FIRST, ("created_at") DESC, ("attachment_id") ASC);
CREATE INDEX "idx_managed_outgoing_images_message" ON "managed_outgoing_image_records" (("session_key") ASC, ("message_id") ASC, ("attachment_id") ASC) WHERE "message_id" IS NOT NULL;
CREATE INDEX "idx_managed_outgoing_images_session" ON "managed_outgoing_image_records" (("session_key") ASC, ("created_at") DESC, ("attachment_id") ASC);
CREATE INDEX "idx_meeting_transcript_sessions_account" ON "meeting_transcript_sessions" (("source_account_id") ASC NULLS FIRST);
CREATE INDEX "idx_meeting_transcript_sessions_agent" ON "meeting_transcript_sessions" (("metadata_agent_id") ASC NULLS FIRST);
CREATE INDEX "idx_meeting_transcript_sessions_chronology" ON "meeting_transcript_sessions" (("started_at_ms") DESC NULLS LAST, ("session_id") ASC, ("started_at") ASC);
CREATE INDEX "idx_meeting_transcript_sessions_export_key" ON "meeting_transcript_sessions" (("export_key") ASC);
CREATE INDEX "idx_meeting_transcript_sessions_id" ON "meeting_transcript_sessions" (("session_id") ASC, ("started_at") DESC);
CREATE INDEX "idx_meeting_transcript_sessions_slug" ON "meeting_transcript_sessions" (("session_slug") ASC, ("started_at") DESC);
CREATE INDEX "idx_meeting_transcript_sessions_source" ON "meeting_transcript_sessions" (("provider_id") ASC, ("source_account_id") ASC NULLS FIRST, ("source_guild_id") ASC NULLS FIRST, ("source_channel_id") ASC NULLS FIRST, ("source_meeting_url") ASC NULLS FIRST, ("source_thread_ts") ASC NULLS FIRST, ("source_file_id") ASC NULLS FIRST, ("stopped_at") DESC NULLS LAST, ("started_at") DESC, ("session_id") ASC);
CREATE INDEX "idx_meeting_transcript_sessions_started" ON "meeting_transcript_sessions" (("started_at") DESC, ("session_id") ASC);
CREATE INDEX "idx_meeting_transcript_utterances_id" ON "meeting_transcript_utterances" (("session_id") ASC, ("session_started_at") ASC, ("utterance_id") ASC) WHERE "utterance_id" IS NOT NULL;
CREATE INDEX "idx_migration_runs_started" ON "migration_runs" (("started_at") DESC, ("id") ASC);
CREATE INDEX "idx_migration_sources_path" ON "migration_sources" (("source_path") ASC, ("migration_kind") ASC, ("target_table") ASC);
CREATE INDEX "idx_migration_sources_run" ON "migration_sources" (("last_run_id") ASC, ("source_path") ASC);
CREATE INDEX "idx_native_hook_relay_bridges_expires" ON "native_hook_relay_bridges" (("expires_at_ms") ASC, ("relay_id") ASC);
CREATE INDEX "idx_official_external_plugin_catalog_snapshots_updated" ON "official_external_plugin_catalog_snapshots" (("updated_at_ms") DESC, ("feed_url") ASC);
CREATE UNIQUE INDEX "idx_operator_approvals_cursor_id" ON "operator_approvals" (("cursor_id") ASC);
CREATE UNIQUE INDEX "idx_operator_approvals_resolution_ref" ON "operator_approvals" (("resolution_ref") ASC);
CREATE INDEX "idx_operator_approvals_resolved" ON "operator_approvals" (("resolved_at_ms") ASC, ("approval_id") ASC) WHERE "resolved_at_ms" IS NOT NULL;
CREATE INDEX "idx_operator_approvals_runtime_pending" ON "operator_approvals" (("runtime_epoch") ASC, ("approval_id") ASC) WHERE ("status" = 'pending');
CREATE INDEX "idx_operator_approvals_source_run_resolved" ON "operator_approvals" (("source_run_id") ASC, ("resolved_at_ms") ASC, ("approval_id") ASC) WHERE "source_run_id" IS NOT NULL AND "resolved_at_ms" IS NOT NULL;
CREATE INDEX "idx_operator_approvals_source_session_created" ON "operator_approvals" (("source_session_key") ASC NULLS FIRST, ("created_at_ms") DESC, ("approval_id") ASC);
CREATE INDEX "idx_operator_approvals_status_expiry" ON "operator_approvals" (("status") ASC, ("expires_at_ms") ASC, ("approval_id") ASC);
CREATE INDEX "idx_plugin_binding_approvals_plugin" ON "plugin_binding_approvals" (("plugin_id") ASC, ("approved_at") DESC);
CREATE INDEX "idx_plugin_blob_expiry" ON "plugin_blob_entries" (("expires_at") ASC) WHERE "expires_at" IS NOT NULL;
CREATE INDEX "idx_plugin_blob_listing" ON "plugin_blob_entries" (("plugin_id") ASC, ("namespace") ASC, ("created_at") ASC, ("entry_key") ASC);
CREATE INDEX "idx_plugin_state_expiry" ON "plugin_state_entries" (("expires_at") ASC) WHERE "expires_at" IS NOT NULL;
CREATE INDEX "idx_plugin_state_listing" ON "plugin_state_entries" (("plugin_id") ASC, ("namespace") ASC, ("created_at") ASC, ("entry_key") ASC, ("expires_at") ASC NULLS FIRST);
CREATE INDEX "idx_sandbox_registry_last_used" ON "sandbox_registry_entries" (("registry_kind") ASC, ("last_used_at_ms") DESC, ("container_name") ASC) WHERE "last_used_at_ms" IS NOT NULL;
CREATE INDEX "idx_sandbox_registry_session" ON "sandbox_registry_entries" (("registry_kind") ASC, ("session_key") ASC, ("last_used_at_ms") DESC NULLS LAST, ("container_name") ASC) WHERE "session_key" IS NOT NULL;
CREATE INDEX "idx_sandbox_registry_updated" ON "sandbox_registry_entries" (("registry_kind") ASC, ("updated_at") DESC, ("container_name") ASC);
CREATE INDEX "idx_session_state_events_session_sequence" ON "session_state_events" (("session_key") ASC, ("sequence") DESC);
CREATE INDEX "idx_session_state_events_time" ON "session_state_events" (("occurred_at") DESC, ("sequence") DESC);
CREATE INDEX "idx_session_upstream_links_catalog_id" ON "session_upstream_links" (("catalog_id") ASC);
CREATE INDEX "idx_session_watch_cursors_target" ON "session_watch_cursors" (("target_session_key") ASC);
CREATE INDEX "idx_skill_uploads_expiry" ON "skill_uploads" (("expires_at") ASC);
CREATE INDEX "idx_skill_uploads_idempotency" ON "skill_uploads" (("idempotency_key_hash") ASC) WHERE "idempotency_key_hash" IS NOT NULL;
CREATE INDEX "idx_state_leases_expiry" ON "state_leases" (("expires_at") ASC, ("scope") ASC, ("lease_key") ASC) WHERE "expires_at" IS NOT NULL;
CREATE INDEX "idx_state_leases_owner" ON "state_leases" (("owner") ASC);
CREATE INDEX "idx_subagent_runs_child_session_key" ON "subagent_runs" (("child_session_key") ASC, ("created_at") DESC, ("run_id") ASC);
CREATE INDEX "idx_subagent_runs_controller_session_key" ON "subagent_runs" (("controller_session_key") ASC NULLS FIRST, ("created_at") DESC, ("run_id") ASC);
CREATE INDEX "idx_subagent_runs_requester_session_key" ON "subagent_runs" (("requester_session_key") ASC, ("created_at") DESC, ("run_id") ASC);
CREATE INDEX "idx_task_runs_cron_runtime_order" ON "task_runs" (("runtime") ASC, ("created_at") ASC, ("task_id") ASC) WHERE ("runtime" = 'cron');
CREATE INDEX "idx_task_runs_cron_source_order" ON "task_runs" (("source_id") ASC NULLS FIRST, ("created_at") ASC, ("task_id") ASC) WHERE ("runtime" = 'cron');
CREATE INDEX "idx_task_runs_runtime_run" ON "task_runs" (("runtime") ASC, ("run_id") ASC NULLS FIRST, ("source_id") ASC NULLS FIRST, ("created_at") ASC, ("task_id") ASC);
CREATE INDEX "idx_web_push_subscriptions_updated" ON "web_push_subscriptions" (("updated_at_ms") DESC, ("subscription_id") ASC);
CREATE UNIQUE INDEX "idx_worker_environments_provider_lease" ON "worker_environments" (("provider_id") ASC, ("lease_id") ASC) WHERE "lease_id" IS NOT NULL;
CREATE INDEX "idx_worker_environments_terminal_changed" ON "worker_environments" (("state_changed_at_ms") ASC, ("environment_id") ASC);
CREATE UNIQUE INDEX "idx_worker_inference_turns_pending_run" ON "worker_inference_turns" (("session_id") ASC, ("run_epoch") ASC, ("run_id") ASC) WHERE ("state" = 'pending');
CREATE INDEX "idx_worker_session_placements_environment" ON "worker_session_placements" (("environment_id") ASC) WHERE "environment_id" IS NOT NULL;
CREATE INDEX "idx_worker_session_placements_reconcile" ON "worker_session_placements" (("updated_at_ms") ASC, ("session_id") ASC);
CREATE INDEX "idx_worker_session_placements_session_key" ON "worker_session_placements" (("agent_id") ASC, ("session_key") ASC);
CREATE INDEX "idx_workspace_path_aliases_workspace" ON "workspace_path_aliases" (("workspace_key") ASC);
CREATE INDEX "idx_workspace_setup_state_path" ON "workspace_setup_state" (("workspace_path") ASC NULLS FIRST);
CREATE INDEX "idx_worktrees_removed_at" ON "worktrees" (("removed_at") ASC NULLS FIRST);
CREATE INDEX "idx_worktrees_repo_fingerprint" ON "worktrees" (("repo_fingerprint") ASC);
ALTER TABLE "acp_replay_events" ADD FOREIGN KEY ("session_id") REFERENCES "acp_replay_sessions" ("session_id") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;
ALTER TABLE "capture_events" ADD FOREIGN KEY ("data_blob_id") REFERENCES "capture_blobs" ("blob_id") ON UPDATE NO ACTION ON DELETE SET NULL NOT DEFERRABLE;
ALTER TABLE "capture_events" ADD FOREIGN KEY ("session_id") REFERENCES "capture_sessions" ("id") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;
ALTER TABLE "meeting_transcript_summaries" ADD FOREIGN KEY ("session_id", "session_started_at") REFERENCES "meeting_transcript_sessions" ("session_id", "started_at") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;
ALTER TABLE "meeting_transcript_utterances" ADD FOREIGN KEY ("session_id", "session_started_at") REFERENCES "meeting_transcript_sessions" ("session_id", "started_at") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;
ALTER TABLE "migration_sources" ADD FOREIGN KEY ("last_run_id") REFERENCES "migration_runs" ("id") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;
ALTER TABLE "skill_upload_chunks" ADD FOREIGN KEY ("upload_id") REFERENCES "skill_uploads" ("upload_id") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;
ALTER TABLE "task_delivery_state" ADD FOREIGN KEY ("task_id") REFERENCES "task_runs" ("task_id") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;
ALTER TABLE "worker_environment_credentials" ADD FOREIGN KEY ("environment_id") REFERENCES "worker_environments" ("environment_id") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;
ALTER TABLE "worker_inference_turns" ADD FOREIGN KEY ("environment_id") REFERENCES "worker_environments" ("environment_id") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;
ALTER TABLE "worker_session_tool_operations" ADD FOREIGN KEY ("source_session_id") REFERENCES "worker_session_placements" ("session_id") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;
ALTER TABLE "worker_transcript_commits" ADD FOREIGN KEY ("session_id", "run_epoch") REFERENCES "worker_transcript_commit_heads" ("session_id", "run_epoch") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;
ALTER TABLE "worker_turn_tool_authorities" ADD FOREIGN KEY ("session_id") REFERENCES "worker_session_placements" ("session_id") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;
ALTER TABLE "worker_workspace_pending_results" ADD FOREIGN KEY ("session_id") REFERENCES "worker_session_placements" ("session_id") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;
ALTER TABLE "worker_workspace_reconciliations" ADD FOREIGN KEY ("session_id") REFERENCES "worker_session_placements" ("session_id") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;
ALTER TABLE "workspace_generated_bootstrap_hashes" ADD FOREIGN KEY ("workspace_key") REFERENCES "workspace_setup_state" ("workspace_key") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;
`;return Object.defineProperty(this,"eagerSql",{value:e,enumerable:!0,configurable:!0,writable:!0}),e},get operatorRecoveryV25Sql(){let e=`-- Generated v24-to-v25 metadata-only transition; the engine owner publishes openclaw_schema_meta.
-- Subagent operator recovery requires the new reader; catalog and retained rows are unchanged.
UPDATE schema_meta SET schema_version = 25 WHERE meta_key = 'primary' AND schema_version = 24;
UPDATE config_machine_state SET value_json = '25' WHERE state_key = 'state.schema.contentVersion' AND value_json = '24';
`;return Object.defineProperty(this,"operatorRecoveryV25Sql",{value:e,enumerable:!0,configurable:!0,writable:!0}),e},get preWriteIndexesV27Sql(){let e={acp_replay_events:`CREATE INDEX "idx_acp_replay_events_session_seq" ON "acp_replay_events" (("session_id") ASC NULLS FIRST, ("seq") ASC NULLS FIRST);`,skill_usage:`CREATE INDEX "idx_skill_usage_key" ON "skill_usage" (("skill_key") ASC NULLS FIRST, ("skill_file") ASC NULLS FIRST);`,state_leases:`CREATE INDEX "idx_state_leases_owner" ON "state_leases" (("owner") ASC NULLS FIRST, ("updated_at") DESC NULLS LAST);`};return Object.defineProperty(this,"preWriteIndexesV27Sql",{value:e,enumerable:!0,configurable:!0,writable:!0}),e},get writeIndexesV27Sql(){let e=`
DROP INDEX IF EXISTS idx_acp_replay_events_session_seq;
DROP INDEX IF EXISTS idx_skill_usage_key;
DROP INDEX IF EXISTS idx_state_leases_owner;
CREATE INDEX "idx_state_leases_owner" ON "state_leases" (("owner") ASC NULLS FIRST);`;return Object.defineProperty(this,"writeIndexesV27Sql",{value:e,enumerable:!0,configurable:!0,writable:!0}),e},get clientCredentialV29Sql(){let e=`-- Generated v28-to-v29 publication after the local credential owner has verified and retired source rows.
UPDATE schema_meta SET schema_version = 29 WHERE meta_key = 'primary' AND schema_version = 28;
`;return Object.defineProperty(this,"clientCredentialV29Sql",{value:e,enumerable:!0,configurable:!0,writable:!0}),e},get workspaceCasV35Sql(){let e=`-- Generated DDL-only v34-to-v35 transition; reconciliation converts retained rows online.
DO $workspace_cas$ BEGIN
IF to_regclass('local_workspace_projections') IS NOT NULL THEN
ALTER TABLE "local_workspace_projections" ADD COLUMN "tree_root_digest" bytea;
ALTER TABLE "local_workspace_projections" ADD COLUMN "source_paths_digest" bytea;
ALTER TABLE "local_workspace_projections" ADD COLUMN "canonical_fingerprints" bytea;
ALTER TABLE "local_workspace_projections" ADD COLUMN "projection_fingerprints" bytea;
CREATE TABLE "local_workspace_source_path_sets" (
"path_digest" bytea NOT NULL,
"paths_zstd" bytea NOT NULL,
"sweep_epoch" bigint NOT NULL,
PRIMARY KEY ("path_digest"),
CHECK ((octet_length("path_digest") = 32))
);
CREATE TABLE "local_workspace_tree_packs" (
"tree_digest" bytea NOT NULL,
"records_json" text COLLATE "C" NOT NULL,
"children_json" text COLLATE "C" NOT NULL,
"sweep_epoch" bigint NOT NULL,
PRIMARY KEY ("tree_digest"),
CHECK ((octet_length("tree_digest") = 32))
);
END IF; END $workspace_cas$;
`;return Object.defineProperty(this,"workspaceCasV35Sql",{value:e,enumerable:!0,configurable:!0,writable:!0}),e},get clientCredentialSource(){let e={sql:`CREATE TABLE "device_auth_tokens" (
"device_id" text COLLATE "C" NOT NULL,
"role" text COLLATE "C" NOT NULL,
"token" text COLLATE "C" NOT NULL,
"scopes_json" text COLLATE "C" NOT NULL,
"updated_at_ms" bigint NOT NULL,
PRIMARY KEY ("device_id", "role")
);
CREATE TABLE "device_identities" (
"identity_key" text COLLATE "C" NOT NULL,
"device_id" text COLLATE "C" NOT NULL,
"public_key_pem" text COLLATE "C" NOT NULL,
"private_key_pem" text COLLATE "C" NOT NULL,
"created_at_ms" bigint NOT NULL,
"updated_at_ms" bigint NOT NULL,
PRIMARY KEY ("identity_key")
);
CREATE TABLE "gateway_origin_device_tokens" (
"gateway_scope" text COLLATE "C" NOT NULL,
"device_id" text COLLATE "C" NOT NULL,
"role" text COLLATE "C" NOT NULL,
"token" text COLLATE "C" NOT NULL,
"scopes_json" text COLLATE "C" NOT NULL,
"updated_at_ms" bigint NOT NULL,
PRIMARY KEY ("gateway_scope", "device_id", "role")
);
CREATE INDEX "idx_device_auth_tokens_updated" ON "device_auth_tokens" (("updated_at_ms") DESC NULLS LAST, ("device_id") ASC NULLS FIRST, ("role") ASC NULLS FIRST);
CREATE INDEX "idx_device_identities_device" ON "device_identities" (("device_id") ASC NULLS FIRST, ("updated_at_ms") DESC NULLS LAST);`,preData:[0,926],postData:[926,1225],tables:[{name:`device_auth_tokens`,identities:[]},{name:`device_identities`,identities:[]},{name:`gateway_origin_device_tokens`,identities:[]}],expectedCatalog:[{table:`device_auth_tokens`,kind:`table`,value:null},{table:`device_auth_tokens`,kind:`column`,value:{name:`device_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`device_auth_tokens`,kind:`column`,value:{name:`role`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`device_auth_tokens`,kind:`column`,value:{name:`token`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`device_auth_tokens`,kind:`column`,value:{name:`scopes_json`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`device_auth_tokens`,kind:`column`,value:{name:`updated_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:5}},{table:`device_auth_tokens`,kind:`primaryKey`,value:[`device_id`,`role`]},{table:`device_auth_tokens`,kind:`indexes`,value:2},{table:`device_auth_tokens`,kind:`checks`,value:0},{table:`device_identities`,kind:`table`,value:null},{table:`device_identities`,kind:`column`,value:{name:`identity_key`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`device_identities`,kind:`column`,value:{name:`device_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`device_identities`,kind:`column`,value:{name:`public_key_pem`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`device_identities`,kind:`column`,value:{name:`private_key_pem`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`device_identities`,kind:`column`,value:{name:`created_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:5}},{table:`device_identities`,kind:`column`,value:{name:`updated_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:6}},{table:`device_identities`,kind:`primaryKey`,value:[`identity_key`]},{table:`device_identities`,kind:`indexes`,value:2},{table:`device_identities`,kind:`checks`,value:0},{table:`gateway_origin_device_tokens`,kind:`table`,value:null},{table:`gateway_origin_device_tokens`,kind:`column`,value:{name:`gateway_scope`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`gateway_origin_device_tokens`,kind:`column`,value:{name:`device_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`gateway_origin_device_tokens`,kind:`column`,value:{name:`role`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`gateway_origin_device_tokens`,kind:`column`,value:{name:`token`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`gateway_origin_device_tokens`,kind:`column`,value:{name:`scopes_json`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`gateway_origin_device_tokens`,kind:`column`,value:{name:`updated_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:6}},{table:`gateway_origin_device_tokens`,kind:`primaryKey`,value:[`gateway_scope`,`device_id`,`role`]},{table:`gateway_origin_device_tokens`,kind:`indexes`,value:1},{table:`gateway_origin_device_tokens`,kind:`checks`,value:0}]};return Object.defineProperty(this,"clientCredentialSource",{value:e,enumerable:!0,configurable:!0,writable:!0}),e},get fragments(){let e=[{id:`local_workspace_projections`,tables:[`local_workspace_projections`,`local_workspace_manifest_nodes`,`local_workspace_tree_packs`,`local_workspace_source_path_sets`],indexes:[],dependencies:[],activation:`first-use`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "local_workspace_manifest_nodes" (
"worktree_id" text COLLATE "C" NOT NULL,
"path" text COLLATE "C" NOT NULL,
"node_json" text COLLATE "C" NOT NULL,
PRIMARY KEY ("worktree_id", "path")
);
CREATE TABLE "local_workspace_projections" (
"worktree_id" text COLLATE "C" NOT NULL,
"agent_id" text COLLATE "C" NOT NULL,
"session_key" text COLLATE "C" NOT NULL,
"session_id" text COLLATE "C" NOT NULL,
"lifecycle_revision" text COLLATE "C",
"projection_path" text COLLATE "C" NOT NULL,
"base_commit" text COLLATE "C" NOT NULL,
"source_paths_json" text COLLATE "C" NOT NULL,
"baseline_json" text COLLATE "C",
"baseline_ref" text COLLATE "C",
"pending_ref" text COLLATE "C",
"pending_target" text COLLATE "C",
"paused_runtimes_json" text COLLATE "C",
"journal_json" text COLLATE "C",
"journal_pack" bytea,
"revision" bigint NOT NULL DEFAULT 0,
"created_at_ms" bigint NOT NULL,
"checkpoint_json" text COLLATE "C",
"tree_root_digest" bytea,
"source_paths_digest" bytea,
"canonical_fingerprints" bytea,
"projection_fingerprints" bytea,
PRIMARY KEY ("worktree_id"),
CHECK (("pending_target" IN ('canonical', 'projection'))),
CHECK ("journal_pack" IS NULL OR (octet_length("journal_pack") <= 268435456)),
CHECK (("revision" >= 0)),
CHECK ("baseline_json" IS NULL OR "baseline_ref" IS NOT NULL),
CHECK ((("journal_json" IS NULL) = ("journal_pack" IS NULL))),
UNIQUE ("projection_path")
);
CREATE TABLE "local_workspace_source_path_sets" (
"path_digest" bytea NOT NULL,
"paths_zstd" bytea NOT NULL,
"sweep_epoch" bigint NOT NULL,
PRIMARY KEY ("path_digest"),
CHECK ((octet_length("path_digest") = 32))
);
CREATE TABLE "local_workspace_tree_packs" (
"tree_digest" bytea NOT NULL,
"records_json" text COLLATE "C" NOT NULL,
"children_json" text COLLATE "C" NOT NULL,
"sweep_epoch" bigint NOT NULL,
PRIMARY KEY ("tree_digest"),
CHECK ((octet_length("tree_digest") = 32))
);
ALTER TABLE "local_workspace_manifest_nodes" ADD FOREIGN KEY ("worktree_id") REFERENCES "local_workspace_projections" ("worktree_id") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;
`},{id:`user_profiles`,tables:[`user_profiles`,`user_profile_emails`,`user_profile_identities`],indexes:[`idx_user_profile_emails_profile_id`,`idx_user_profile_identities_profile_id`,`idx_user_profile_identities_authorization`],dependencies:[],activation:`first-use`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "user_profile_emails" (
"email" text COLLATE "C" NOT NULL,
"profile_id" text COLLATE "C" NOT NULL,
"binding_id" text COLLATE "C",
"created_at" bigint NOT NULL,
PRIMARY KEY ("email")
);
CREATE TABLE "user_profile_identities" (
"provider" text COLLATE "C" NOT NULL,
"subject" text COLLATE "C" NOT NULL,
"profile_id" text COLLATE "C" NOT NULL,
"canonical_login" text COLLATE "C",
"verified_email_json" text COLLATE "C",
"created_at" bigint NOT NULL,
"authorization_id" text COLLATE "C",
"authorization_basis_json" text COLLATE "C",
PRIMARY KEY ("provider", "subject")
);
CREATE TABLE "user_profiles" (
"id" text COLLATE "C" NOT NULL,
"display_name" text COLLATE "C",
"primary_github_account_id" bigint,
"avatar" bytea,
"avatar_mime" text COLLATE "C",
"avatar_sha256" text COLLATE "C",
"merged_into" text COLLATE "C",
"role" text COLLATE "C",
"created_at" bigint NOT NULL,
"updated_at" bigint NOT NULL,
PRIMARY KEY ("id")
);
CREATE INDEX "idx_user_profile_emails_profile_id" ON "user_profile_emails" (("profile_id") ASC);
CREATE UNIQUE INDEX "idx_user_profile_identities_authorization" ON "user_profile_identities" (("authorization_id") ASC NULLS FIRST);
CREATE INDEX "idx_user_profile_identities_profile_id" ON "user_profile_identities" (("profile_id") ASC);
`},{id:`skill_library_entries`,tables:[`skill_library_entries`,`skill_library_revisions`,`skill_library_events`,`skill_library_uploads`],indexes:[],dependencies:[],activation:`first-use`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "skill_library_entries" (
"skill_id" text COLLATE "C" NOT NULL,
"owner_profile_id" text COLLATE "C",
"author_profile_id" text COLLATE "C" NOT NULL,
"slug" text COLLATE "C" NOT NULL,
"current_revision" text COLLATE "C" NOT NULL,
"shared" bigint NOT NULL,
"enabled" bigint NOT NULL,
"removed" bigint NOT NULL,
"created_at" bigint NOT NULL,
"updated_at" bigint NOT NULL,
PRIMARY KEY ("skill_id")
);
CREATE TABLE "skill_library_events" (
"event_id" text COLLATE "C" NOT NULL,
"skill_id" text COLLATE "C" NOT NULL,
"revision" text COLLATE "C" NOT NULL,
"action" text COLLATE "C" NOT NULL,
"actor_profile_id" text COLLATE "C" NOT NULL,
"created_at" bigint NOT NULL,
PRIMARY KEY ("event_id")
);
CREATE TABLE "skill_library_revisions" (
"skill_id" text COLLATE "C" NOT NULL,
"revision" text COLLATE "C" NOT NULL,
"description" text COLLATE "C" NOT NULL,
"files_json" text COLLATE "C" NOT NULL,
"created_at" bigint NOT NULL,
PRIMARY KEY ("skill_id", "revision")
);
CREATE TABLE "skill_library_uploads" (
"upload_id" text COLLATE "C" NOT NULL,
"owner_profile_id" text COLLATE "C" NOT NULL,
"slug" text COLLATE "C" NOT NULL,
"size_bytes" bigint NOT NULL,
"sha256" text COLLATE "C" NOT NULL,
"archive_blob" bytea NOT NULL,
"expires_at" bigint NOT NULL,
"published_skill_id" text COLLATE "C",
PRIMARY KEY ("upload_id")
);
`},{id:`operator_approval_standing_grants`,tables:[`operator_approval_standing_grants`,`operator_approval_standing_grant_generations`],indexes:[`idx_operator_approval_standing_grants_binding`],dependencies:[],activation:`first-use`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "operator_approval_standing_grant_generations" (
"grant_id" text COLLATE "C" NOT NULL,
"job_definition_generation" bigint NOT NULL,
PRIMARY KEY ("grant_id"),
CHECK (("job_definition_generation" >= 1))
);
CREATE TABLE "operator_approval_standing_grants" (
"grant_id" text COLLATE "C" NOT NULL,
"minted_by_approval_id" text COLLATE "C" NOT NULL,
"agent_id" text COLLATE "C" NOT NULL,
"cron_job_id" text COLLATE "C" NOT NULL,
"job_config_revision" text COLLATE "C" NOT NULL,
"operation_binding" text COLLATE "C" NOT NULL,
"created_at_ms" bigint NOT NULL,
"expires_at_ms" bigint,
"revoked_at_ms" bigint,
"revoked_by" text COLLATE "C",
"last_used_at_ms" bigint,
"use_count" bigint NOT NULL DEFAULT 0,
PRIMARY KEY ("grant_id"),
CHECK ((char_length("grant_id") > 0)),
CHECK ((char_length("agent_id") > 0)),
CHECK ((char_length("cron_job_id") > 0)),
CHECK ((char_length("job_config_revision") > 0)),
CHECK ((char_length("operation_binding") > 0)),
CHECK ("expires_at_ms" IS NULL OR ("expires_at_ms" >= "created_at_ms"))
);
CREATE INDEX "idx_operator_approval_standing_grants_binding" ON "operator_approval_standing_grants" (("agent_id") ASC, ("cron_job_id") ASC, ("operation_binding") ASC, ("created_at_ms") DESC);
ALTER TABLE "operator_approval_standing_grant_generations" ADD FOREIGN KEY ("grant_id") REFERENCES "operator_approval_standing_grants" ("grant_id") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;
ALTER TABLE "operator_approval_standing_grants" ADD FOREIGN KEY ("minted_by_approval_id") REFERENCES "operator_approvals" ("approval_id") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;
`},{id:`worker_environment_session_attachments`,tables:[`worker_environment_session_attachments`],indexes:[`worker_environment_session_attachments_session_key`],dependencies:[],activation:`first-use`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "worker_environment_session_attachments" (
"session_id" text COLLATE "C" NOT NULL,
"session_key" text COLLATE "C" NOT NULL,
"agent_id" text COLLATE "C" NOT NULL,
"session_lifecycle_revision" text COLLATE "C",
"environment_id" text COLLATE "C" NOT NULL,
"generation" bigint NOT NULL,
"created_at_ms" bigint NOT NULL,
"last_used_at_ms" bigint NOT NULL,
"closed_at_ms" bigint,
PRIMARY KEY ("session_id"),
CHECK (("generation" >= 1)),
UNIQUE ("environment_id")
);
CREATE INDEX "worker_environment_session_attachments_session_key" ON "worker_environment_session_attachments" (("agent_id") ASC, ("session_key") ASC);
ALTER TABLE "worker_environment_session_attachments" ADD FOREIGN KEY ("environment_id") REFERENCES "worker_environments" ("environment_id") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;
`},{id:`durable_background_processes`,tables:[`durable_background_processes`],indexes:[],dependencies:[],activation:`first-use`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "durable_background_processes" (
"id" text COLLATE "C" NOT NULL,
"record_json" text COLLATE "C" NOT NULL,
PRIMARY KEY ("id")
);
`},{id:`sandbox_persistent_execs`,tables:[`sandbox_persistent_execs`],indexes:[`idx_sandbox_persistent_execs_container`,`idx_sandbox_persistent_execs_container_name`,`idx_sandbox_persistent_execs_source`],dependencies:[],activation:`first-use`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "sandbox_persistent_execs" (
"owner_key" text COLLATE "C" NOT NULL,
"source_identity" text COLLATE "C" NOT NULL,
"attempt_id" text COLLATE "C" NOT NULL,
"owner_json" text COLLATE "C" NOT NULL,
"backend_id" text COLLATE "C" NOT NULL,
"backend_target_json" text COLLATE "C" NOT NULL,
"workspace_binding_json" text COLLATE "C" NOT NULL,
"container_id" text COLLATE "C" NOT NULL,
"container_name" text COLLATE "C" NOT NULL,
"container_started_at" text COLLATE "C" NOT NULL,
"revision" bigint NOT NULL,
"phase" text COLLATE "C" NOT NULL,
"receipt_json" text COLLATE "C",
"error" text COLLATE "C",
"created_at_ms" bigint NOT NULL,
"updated_at_ms" bigint NOT NULL,
PRIMARY KEY ("owner_key"),
CHECK (("backend_id" = 'docker')),
CHECK (("revision" > 0)),
CHECK (("phase" IN ('reserved', 'prepared', 'running', 'stopping', 'uncertain', 'stopped'))),
CHECK (("phase" NOT IN ('prepared', 'running')) OR "receipt_json" IS NOT NULL),
UNIQUE ("attempt_id")
);
CREATE INDEX "idx_sandbox_persistent_execs_container" ON "sandbox_persistent_execs" (("container_id") ASC, ("owner_key") ASC);
CREATE INDEX "idx_sandbox_persistent_execs_container_name" ON "sandbox_persistent_execs" (("container_name") ASC, ("owner_key") ASC);
CREATE INDEX "idx_sandbox_persistent_execs_source" ON "sandbox_persistent_execs" (("source_identity") ASC, ("owner_key") ASC);
`},{id:`user_background_images`,tables:[`user_background_images`],indexes:[],dependencies:[`user_profiles`],activation:`first-use`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "user_background_images" (
"profile_id" text COLLATE "C" NOT NULL,
"asset_id" text COLLATE "C" NOT NULL,
"image" bytea NOT NULL,
"width" bigint NOT NULL,
"height" bigint NOT NULL,
PRIMARY KEY ("profile_id"),
CHECK ((octet_length("image") BETWEEN 1 AND 2097152)),
CHECK (("width" BETWEEN 1 AND 2560)),
CHECK (("height" BETWEEN 1 AND 2560)),
UNIQUE ("asset_id")
);
ALTER TABLE "user_background_images" ADD FOREIGN KEY ("profile_id") REFERENCES "user_profiles" ("id") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;
`},{id:`update_runs`,tables:[`update_runs`],indexes:[`idx_update_runs_created`,`idx_update_runs_active`],dependencies:[],activation:`first-use`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "update_runs" (
"run_id" text COLLATE "C" NOT NULL,
"created_at_ms" bigint NOT NULL,
"updated_at_ms" bigint NOT NULL,
"trigger" text COLLATE "C" NOT NULL,
"phase" text COLLATE "C" NOT NULL,
"status" text COLLATE "C" NOT NULL,
"reason" text COLLATE "C",
"origin_json" text COLLATE "C" NOT NULL,
"target_json" text COLLATE "C" NOT NULL,
"before_json" text COLLATE "C" NOT NULL,
"after_json" text COLLATE "C" NOT NULL,
"steps_json" text COLLATE "C" NOT NULL,
"verification_json" text COLLATE "C" NOT NULL,
"repair_json" text COLLATE "C" NOT NULL,
"confirmed_at_ms" bigint,
"finished_at_ms" bigint,
"downtime_ms" bigint,
PRIMARY KEY ("run_id"),
CHECK (("trigger" IN ('chat', 'control-ui', 'cli', 'campaign', 'mac-app', 'api'))),
CHECK (("phase" IN ('requested', 'staging', 'validating', 'repairing', 'activating', 'restarting', 'verifying', 'finished'))),
CHECK (("status" IN ('running', 'succeeded', 'failed', 'rolled-back', 'skipped'))),
CHECK ((octet_length(convert_to("origin_json", 'UTF8')) <= 16384)),
CHECK ((octet_length(convert_to("target_json", 'UTF8')) <= 16384)),
CHECK ((octet_length(convert_to("before_json", 'UTF8')) <= 16384)),
CHECK ((octet_length(convert_to("after_json", 'UTF8')) <= 16384)),
CHECK ((octet_length(convert_to("steps_json", 'UTF8')) <= 16384)),
CHECK ((octet_length(convert_to("verification_json", 'UTF8')) <= 16384)),
CHECK ((octet_length(convert_to("repair_json", 'UTF8')) <= 16384)),
CHECK ((("status" = 'running') AND ("phase" != 'finished') AND "finished_at_ms" IS NULL) OR (("status" != 'running') AND ("phase" = 'finished') AND "finished_at_ms" IS NOT NULL))
);
CREATE INDEX "idx_update_runs_active" ON "update_runs" (("status") ASC, ("created_at_ms") DESC, ("run_id") ASC);
CREATE INDEX "idx_update_runs_created" ON "update_runs" (("created_at_ms") DESC, ("run_id") ASC);
`},{id:`session_repository_workspaces`,tables:[`session_repository_workspaces`],indexes:[],dependencies:[],activation:`first-use`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "session_repository_workspaces" (
"workspace_id" text COLLATE "C" NOT NULL,
"agent_id" text COLLATE "C" NOT NULL,
"session_key" text COLLATE "C" NOT NULL,
"url" text COLLATE "C" NOT NULL,
"requested_ref" text COLLATE "C",
"run_setup_script" bigint NOT NULL DEFAULT 0,
"base_commit" text COLLATE "C",
"base_manifest_hash" text COLLATE "C",
"branch" text COLLATE "C" NOT NULL,
"checkpoint_ref" text COLLATE "C",
"manifest_hash" text COLLATE "C",
"revision" bigint NOT NULL,
"created_at_ms" bigint NOT NULL,
"updated_at_ms" bigint NOT NULL,
"disk_authority_json" text COLLATE "C",
PRIMARY KEY ("workspace_id"),
CHECK ((char_length("workspace_id") = 36)),
CHECK ((char_length("agent_id") BETWEEN 1 AND 128)),
CHECK ((char_length("session_key") BETWEEN 1 AND 1024)),
CHECK ((char_length("url") BETWEEN 1 AND 4096)),
CHECK ("requested_ref" IS NULL OR (char_length("requested_ref") BETWEEN 1 AND 1024)),
CHECK (("run_setup_script" IN (0, 1))),
CHECK ("base_commit" IS NULL OR (char_length("base_commit") IN (40, 64))),
CHECK ((char_length("branch") BETWEEN 1 AND 256)),
CHECK (("revision" >= 0)),
CHECK ("base_manifest_hash" IS NULL OR "base_commit" IS NOT NULL),
CHECK (("checkpoint_ref" IS NULL AND "manifest_hash" IS NULL) OR ("checkpoint_ref" IS NOT NULL AND "manifest_hash" IS NOT NULL AND "base_manifest_hash" IS NOT NULL)),
UNIQUE ("agent_id", "session_key")
);
`},{id:`github_repository_publication_requests`,tables:[`github_repository_publication_requests`],indexes:[`idx_github_repository_publication_shared_request`,`idx_github_repository_publication_personal_request`],dependencies:[],activation:`first-use`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "github_repository_publication_requests" (
"request_id" text COLLATE "C" NOT NULL,
"owner_profile_id" text COLLATE "C",
"connection_generation" text COLLATE "C",
"idempotency_key" text COLLATE "C" NOT NULL,
"request_digest" text COLLATE "C" NOT NULL,
"session_id" text COLLATE "C" NOT NULL,
"session_lifecycle_revision" text COLLATE "C",
"requester_authority_json" text COLLATE "C",
"session_key" text COLLATE "C" NOT NULL,
"agent_id" text COLLATE "C" NOT NULL,
"workspace_id" text COLLATE "C" NOT NULL,
"checkpoint_ref" text COLLATE "C",
"checkpoint_digest" text COLLATE "C",
"claim_id" text COLLATE "C",
"run_id" text COLLATE "C",
"environment_id" text COLLATE "C",
"owner_epoch" bigint,
"placement_generation" bigint,
"identity_source" text COLLATE "C" NOT NULL,
"identity_profile_id" text COLLATE "C",
"identity_account_id" bigint NOT NULL,
"identity_login" text COLLATE "C" NOT NULL,
"title" text COLLATE "C",
"body" text COLLATE "C",
"status" text COLLATE "C" NOT NULL,
"gateway_instance_id" text COLLATE "C",
"execution_id" text COLLATE "C",
"last_effect" text COLLATE "C",
"effect_state" text COLLATE "C",
"push_repository" text COLLATE "C",
"repository" text COLLATE "C",
"branch" text COLLATE "C" NOT NULL,
"base_branch" text COLLATE "C",
"source_head_commit" text COLLATE "C",
"source_index_tree" text COLLATE "C",
"workspace_tree" text COLLATE "C",
"previous_head_commit" text COLLATE "C",
"pushed_head_commit" text COLLATE "C",
"head_commit" text COLLATE "C",
"pull_request_url" text COLLATE "C",
"error_code" text COLLATE "C",
"next_action" text COLLATE "C",
"created_at_ms" bigint NOT NULL,
"updated_at_ms" bigint NOT NULL,
"reported_at_ms" bigint,
"draft" bigint,
PRIMARY KEY ("request_id"),
CHECK (("identity_source" IN ('system-detected', 'system-configured', 'agent-override', 'personal'))),
CHECK (("status" IN ('requested', 'publishing', 'needs_confirmation', 'published', 'failed'))),
CHECK (("last_effect" IN ('push', 'pull_request'))),
CHECK (("effect_state" IN ('dispatched', 'observed'))),
CHECK ((("identity_source" = 'personal') AND "owner_profile_id" IS NOT NULL AND "connection_generation" IS NOT NULL) OR (("identity_source" <> 'personal') AND "owner_profile_id" IS NULL AND "connection_generation" IS NULL)),
CHECK (("checkpoint_ref" IS NULL AND "checkpoint_digest" IS NULL) OR ("checkpoint_ref" IS NOT NULL AND "checkpoint_digest" IS NOT NULL)),
CHECK (("last_effect" IS NULL AND "effect_state" IS NULL) OR ("last_effect" IS NOT NULL AND "effect_state" IS NOT NULL))
);
CREATE UNIQUE INDEX "idx_github_repository_publication_personal_request" ON "github_repository_publication_requests" (("owner_profile_id") ASC, ("session_id") ASC, ("idempotency_key") ASC) WHERE "owner_profile_id" IS NOT NULL;
CREATE UNIQUE INDEX "idx_github_repository_publication_shared_request" ON "github_repository_publication_requests" (("session_id") ASC, ("idempotency_key") ASC) WHERE "owner_profile_id" IS NULL;
`},{id:`github_publication_session_lifecycles`,tables:[`github_publication_session_lifecycles`],indexes:[],dependencies:[],activation:`first-use`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "github_publication_session_lifecycles" (
"publication_kind" text COLLATE "C" NOT NULL,
"request_id" text COLLATE "C" NOT NULL,
"lifecycle_revision" text COLLATE "C",
"requester_authority_json" text COLLATE "C",
PRIMARY KEY ("publication_kind", "request_id"),
CHECK (("publication_kind" IN ('shared', 'personal')))
);
`},{id:`github_personal_publication_requests`,tables:[`github_personal_publication_requests`],indexes:[`idx_github_personal_publication_owner_session`,`idx_github_personal_publication_pending`],dependencies:[],activation:`first-use`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "github_personal_publication_requests" (
"request_id" text COLLATE "C" NOT NULL,
"owner_profile_id" text COLLATE "C" NOT NULL,
"connection_generation" text COLLATE "C" NOT NULL,
"idempotency_key" text COLLATE "C" NOT NULL,
"request_digest" text COLLATE "C" NOT NULL,
"session_id" text COLLATE "C" NOT NULL,
"session_key" text COLLATE "C" NOT NULL,
"agent_id" text COLLATE "C" NOT NULL,
"worktree_id" text COLLATE "C" NOT NULL,
"repository_fingerprint" text COLLATE "C" NOT NULL,
"identity_source" text COLLATE "C" NOT NULL,
"identity_profile_id" text COLLATE "C" NOT NULL,
"identity_account_id" bigint NOT NULL,
"identity_login" text COLLATE "C" NOT NULL,
"title" text COLLATE "C",
"body" text COLLATE "C",
"status" text COLLATE "C" NOT NULL,
"gateway_instance_id" text COLLATE "C",
"execution_id" text COLLATE "C",
"last_effect" text COLLATE "C",
"effect_state" text COLLATE "C",
"push_repository" text COLLATE "C" NOT NULL,
"repository" text COLLATE "C" NOT NULL,
"branch" text COLLATE "C" NOT NULL,
"base_branch" text COLLATE "C" NOT NULL,
"source_head_commit" text COLLATE "C" NOT NULL,
"source_index_tree" text COLLATE "C" NOT NULL,
"workspace_tree" text COLLATE "C" NOT NULL,
"head_commit" text COLLATE "C",
"pull_request_url" text COLLATE "C",
"error_code" text COLLATE "C",
"next_action" text COLLATE "C",
"created_at_ms" bigint NOT NULL,
"updated_at_ms" bigint NOT NULL,
"reported_at_ms" bigint,
"draft" bigint,
PRIMARY KEY ("request_id"),
CHECK ((char_length("request_id") = 36)),
CHECK ((char_length("owner_profile_id") BETWEEN 1 AND 128)),
CHECK ((char_length("connection_generation") = 36)),
CHECK ((char_length("idempotency_key") BETWEEN 1 AND 128)),
CHECK ((char_length("request_digest") = 64)),
CHECK ((char_length("session_id") BETWEEN 1 AND 128)),
CHECK ((char_length("session_key") BETWEEN 1 AND 1024)),
CHECK ((char_length("agent_id") BETWEEN 1 AND 128)),
CHECK ((char_length("worktree_id") BETWEEN 1 AND 128)),
CHECK ((char_length("repository_fingerprint") BETWEEN 1 AND 256)),
CHECK (("identity_source" = 'personal')),
CHECK ((char_length("identity_profile_id") = 36)),
CHECK (("identity_account_id" >= 1)),
CHECK ((char_length("identity_login") BETWEEN 1 AND 39)),
CHECK ("title" IS NULL OR (char_length("title") BETWEEN 1 AND 256)),
CHECK ("body" IS NULL OR (char_length("body") BETWEEN 1 AND 8192)),
CHECK (("status" IN ('requested', 'publishing', 'needs_confirmation', 'published', 'failed'))),
CHECK ("gateway_instance_id" IS NULL OR (char_length("gateway_instance_id") BETWEEN 1 AND 128)),
CHECK ("execution_id" IS NULL OR (char_length("execution_id") = 36)),
CHECK ("last_effect" IS NULL OR ("last_effect" IN ('push', 'pull_request'))),
CHECK ("effect_state" IS NULL OR ("effect_state" IN ('dispatched', 'observed'))),
CHECK ((char_length("push_repository") BETWEEN 3 AND 256)),
CHECK ((char_length("repository") BETWEEN 3 AND 256)),
CHECK ((char_length("branch") BETWEEN 1 AND 256)),
CHECK ((char_length("base_branch") BETWEEN 1 AND 256)),
CHECK ((char_length("source_head_commit") IN (40, 64))),
CHECK ((char_length("source_index_tree") IN (40, 64))),
CHECK ((char_length("workspace_tree") IN (40, 64))),
CHECK ("head_commit" IS NULL OR (char_length("head_commit") IN (40, 64))),
CHECK ("pull_request_url" IS NULL OR (char_length("pull_request_url") BETWEEN 1 AND 2048)),
CHECK ("error_code" IS NULL OR (char_length("error_code") BETWEEN 1 AND 64)),
CHECK ("next_action" IS NULL OR (char_length("next_action") BETWEEN 1 AND 1024)),
CHECK (("created_at_ms" >= 0)),
CHECK (("updated_at_ms" >= "created_at_ms")),
CHECK ((("status" = 'publishing') AND "gateway_instance_id" IS NOT NULL AND "execution_id" IS NOT NULL) OR ("status" <> 'publishing')),
CHECK (("last_effect" IS NULL AND "effect_state" IS NULL) OR ("last_effect" IS NOT NULL AND "effect_state" IS NOT NULL)),
CHECK ((("status" = 'published') AND "pull_request_url" IS NOT NULL AND "head_commit" IS NOT NULL AND "error_code" IS NULL AND "next_action" IS NULL) OR (("status" = 'failed') AND "error_code" IS NOT NULL AND "next_action" IS NOT NULL) OR (("status" IN ('requested', 'publishing', 'needs_confirmation')) AND "error_code" IS NULL AND "next_action" IS NULL)),
UNIQUE ("owner_profile_id", "session_id", "idempotency_key")
);
CREATE INDEX "idx_github_personal_publication_owner_session" ON "github_personal_publication_requests" (("owner_profile_id") ASC, ("session_id") ASC, ("created_at_ms") ASC);
CREATE INDEX "idx_github_personal_publication_pending" ON "github_personal_publication_requests" (("status") ASC, ("updated_at_ms") ASC, ("request_id") ASC);
`},{id:`cron_job_runtime_authorities`,tables:[`cron_job_runtime_authorities`],indexes:[],dependencies:[],activation:`first-use`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "cron_job_runtime_authorities" (
"store_key" text COLLATE "C" NOT NULL,
"job_id" text COLLATE "C" NOT NULL,
"authority_json" text COLLATE "C",
"authority_input_fingerprint" text COLLATE "C",
"recovery_required" bigint NOT NULL,
PRIMARY KEY ("store_key", "job_id"),
CHECK (("recovery_required" IN (0, 1))),
CHECK ((("recovery_required" = 0) AND "authority_json" IS NOT NULL AND "authority_input_fingerprint" IS NOT NULL) OR (("recovery_required" = 1) AND "authority_json" IS NULL AND "authority_input_fingerprint" IS NULL))
);
ALTER TABLE "cron_job_runtime_authorities" ADD FOREIGN KEY ("store_key", "job_id") REFERENCES "cron_jobs" ("store_key", "job_id") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;
`},{id:`cron_run_trigger_state_retirements`,tables:[`cron_run_trigger_state_retirements`],indexes:[],dependencies:[`cron_run_receipts`],activation:`first-use`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "cron_run_trigger_state_retirements" (
"receipt_id" text COLLATE "C" NOT NULL,
PRIMARY KEY ("receipt_id")
);
ALTER TABLE "cron_run_trigger_state_retirements" ADD FOREIGN KEY ("receipt_id") REFERENCES "cron_run_receipts" ("receipt_id") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;
`},{id:`execution_identity_contexts`,tables:[`execution_identity_contexts`],indexes:[`execution_identity_contexts_run_created_idx`],dependencies:[],activation:`first-use`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "execution_identity_contexts" (
"context_id" text COLLATE "C" NOT NULL,
"execution_id" text COLLATE "C" NOT NULL,
"run_id" text COLLATE "C" NOT NULL,
"created_at" bigint NOT NULL,
"coverage_state" text COLLATE "C" NOT NULL,
"context_bytes" bigint NOT NULL,
"context_json" text COLLATE "C" NOT NULL,
PRIMARY KEY ("context_id"),
CHECK ((char_length("context_id") BETWEEN 1 AND 256)),
CHECK ((char_length("execution_id") BETWEEN 1 AND 256)),
CHECK ((char_length("run_id") BETWEEN 1 AND 256)),
CHECK (("created_at" >= 0)),
CHECK (("coverage_state" IN ('attribution-only', 'unattributed', 'unknown', 'unsupported'))),
CHECK (("context_bytes" BETWEEN 1 AND 16384)),
CHECK ((char_length("context_json") > 0)),
UNIQUE ("execution_id"),
UNIQUE ("created_at", "context_id")
);
CREATE INDEX "execution_identity_contexts_run_created_idx" ON "execution_identity_contexts" (("run_id") ASC, ("created_at") ASC, ("execution_id") ASC);
`},{id:`mcp_oauth_pending_authorizations`,tables:[`mcp_oauth_pending_authorizations`],indexes:[],dependencies:[],activation:`first-use`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "mcp_oauth_pending_authorizations" (
"state" text COLLATE "C" NOT NULL,
"store_key" text COLLATE "C" NOT NULL,
"create_time" bigint NOT NULL,
PRIMARY KEY ("state")
);
`},{id:`node_worker_launch_containers`,tables:[`node_worker_launch_containers`],indexes:[],dependencies:[],activation:`first-use`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "node_worker_launch_containers" (
"launch_id" text COLLATE "C" NOT NULL,
"container_json" text COLLATE "C",
PRIMARY KEY ("launch_id")
);
`},{id:`node_worker_launch_boots`,tables:[`node_worker_launch_boots`],indexes:[],dependencies:[`node_worker_launches`],activation:`first-use`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "node_worker_launch_boots" (
"launch_id" text COLLATE "C" NOT NULL,
"boot_id" text COLLATE "C",
PRIMARY KEY ("launch_id"),
CHECK ("boot_id" IS NULL OR (char_length("boot_id") BETWEEN 1 AND 128))
);
ALTER TABLE "node_worker_launch_boots" ADD FOREIGN KEY ("launch_id") REFERENCES "node_worker_launches" ("launch_id") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;
`},{id:`node_worker_launch_cleanup`,tables:[`node_worker_launch_cleanup`],indexes:[],dependencies:[`node_worker_launches`],activation:`first-use`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "node_worker_launch_cleanup" (
"launch_id" text COLLATE "C" NOT NULL,
"cleanup_mode" text COLLATE "C" NOT NULL,
"lineage_settled" bigint,
PRIMARY KEY ("launch_id"),
CHECK (("cleanup_mode" IN ('process-group', 'owned-anchor'))),
CHECK ("lineage_settled" IS NULL OR ("lineage_settled" = 1))
);
ALTER TABLE "node_worker_launch_cleanup" ADD FOREIGN KEY ("launch_id") REFERENCES "node_worker_launches" ("launch_id") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;
`},{id:`node_worker_launch_process_scopes`,tables:[`node_worker_launch_process_scopes`],indexes:[],dependencies:[`node_worker_launches`],activation:`first-use`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "node_worker_launch_process_scopes" (
"launch_id" text COLLATE "C" NOT NULL,
"scope_kind" text COLLATE "C" NOT NULL,
"descendants_reaped" bigint,
PRIMARY KEY ("launch_id"),
CHECK (("scope_kind" = 'linux-subreaper')),
CHECK ("descendants_reaped" IS NULL OR ("descendants_reaped" = 1))
);
ALTER TABLE "node_worker_launch_process_scopes" ADD FOREIGN KEY ("launch_id") REFERENCES "node_worker_launches" ("launch_id") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;
`},{id:`node_worker_launches`,tables:[`node_worker_launches`],indexes:[`idx_node_worker_launches_terminal_completed`],dependencies:[],activation:`first-use`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "node_worker_launches" (
"launch_id" text COLLATE "C" NOT NULL,
"plan_hash" text COLLATE "C" NOT NULL,
"gateway_namespace" text COLLATE "C" NOT NULL,
"environment_id" text COLLATE "C" NOT NULL,
"session_id" text COLLATE "C" NOT NULL,
"owner_epoch" bigint NOT NULL,
"placement_generation" bigint NOT NULL,
"run_id" text COLLATE "C" NOT NULL,
"state" text COLLATE "C" NOT NULL,
"supervisor_pid" bigint NOT NULL,
"supervisor_start_time" bigint NOT NULL,
"worker_pid" bigint,
"worker_start_time" bigint,
"result_json" text COLLATE "C",
"error_text" text COLLATE "C",
"completed_at_ms" bigint,
"created_at_ms" bigint NOT NULL,
"updated_at_ms" bigint NOT NULL,
PRIMARY KEY ("launch_id"),
CHECK ((char_length("launch_id") BETWEEN 1 AND 256) AND ("launch_id" IS NOT NULL OR NULL)),
CHECK ((char_length("plan_hash") = 64) AND ("plan_hash" COLLATE "C" !~ '\\A.*[^0-9a-f].*\\Z')),
CHECK ((char_length("gateway_namespace") BETWEEN 1 AND 128) AND ("gateway_namespace" COLLATE "C" !~ '\\A.*[^A-Za-z0-9._-].*\\Z') AND ("gateway_namespace" COLLATE "C" ~ '\\A[A-Za-z0-9].*\\Z')),
CHECK ((char_length("environment_id") BETWEEN 1 AND 256) AND ("environment_id" IS NOT NULL OR NULL)),
CHECK ((char_length("session_id") BETWEEN 1 AND 256) AND ("session_id" IS NOT NULL OR NULL)),
CHECK (("owner_epoch" BETWEEN 1 AND 9007199254740991)),
CHECK (("placement_generation" BETWEEN 0 AND 9007199254740991)),
CHECK ((char_length("run_id") BETWEEN 1 AND 256) AND ("run_id" IS NOT NULL OR NULL)),
CHECK (("state" IN ('pending', 'running', 'completed', 'failed', 'interrupted', 'cancelled'))),
CHECK (("supervisor_pid" BETWEEN 1 AND 2147483647)),
CHECK (("supervisor_start_time" BETWEEN 0 AND 9007199254740991)),
CHECK ("worker_pid" IS NULL OR ("worker_pid" BETWEEN 1 AND 2147483647)),
CHECK ("worker_start_time" IS NULL OR ("worker_start_time" BETWEEN 0 AND 9007199254740991)),
CHECK ("result_json" IS NULL OR ((octet_length(convert_to("result_json", 'UTF8')) BETWEEN 1 AND 65536) AND ("result_json" IS NOT NULL OR NULL) AND ("result_json" IS JSON))),
CHECK ("error_text" IS NULL OR ((octet_length(convert_to("error_text", 'UTF8')) BETWEEN 1 AND 4096) AND ("error_text" IS NOT NULL OR NULL) AND (strpos("error_text", '
') = 0) AND (strpos("error_text", '\r') = 0))),
CHECK ("completed_at_ms" IS NULL OR ("completed_at_ms" BETWEEN 0 AND 9007199254740991)),
CHECK (("created_at_ms" BETWEEN 0 AND 9007199254740991)),
CHECK (("updated_at_ms" BETWEEN "created_at_ms" AND 9007199254740991)),
CHECK ((("worker_pid" IS NULL) = ("worker_start_time" IS NULL))),
CHECK ((("state" = 'pending') AND "worker_pid" IS NULL AND "result_json" IS NULL AND "error_text" IS NULL AND "completed_at_ms" IS NULL) OR (("state" = 'running') AND "worker_pid" IS NOT NULL AND "result_json" IS NULL AND "error_text" IS NULL AND "completed_at_ms" IS NULL) OR (("state" = 'completed') AND "result_json" IS NOT NULL AND "error_text" IS NULL AND ("completed_at_ms" BETWEEN "created_at_ms" AND "updated_at_ms")) OR (("state" IN ('failed', 'interrupted', 'cancelled')) AND "result_json" IS NULL AND "error_text" IS NOT NULL AND ("completed_at_ms" BETWEEN "created_at_ms" AND "updated_at_ms")))
);
CREATE INDEX "idx_node_worker_launches_terminal_completed" ON "node_worker_launches" (("completed_at_ms") ASC, ("launch_id") ASC) WHERE "completed_at_ms" IS NOT NULL;
`},{id:`node_worker_prepared_workspaces`,tables:[`node_worker_prepared_workspaces`],indexes:[],dependencies:[],activation:`first-use`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "node_worker_prepared_workspaces" (
"preparation_key" text COLLATE "C" NOT NULL,
"cache_key" text COLLATE "C" NOT NULL,
"gateway_namespace" text COLLATE "C" NOT NULL,
"workspace_dir" text COLLATE "C" NOT NULL,
"home_dir" text COLLATE "C" NOT NULL,
"source_manifest_ref" text COLLATE "C" NOT NULL,
"prepared_manifest_ref" text COLLATE "C" NOT NULL,
"state" text COLLATE "C" NOT NULL,
"environment_id" text COLLATE "C" NOT NULL,
"session_id" text COLLATE "C",
"session_key" text COLLATE "C",
"owner_epoch" bigint,
"created_at_ms" bigint NOT NULL,
"bound_at_ms" bigint,
"retired_at_ms" bigint,
PRIMARY KEY ("preparation_key"),
CHECK ((char_length("preparation_key") = 64) AND ("preparation_key" COLLATE "C" !~ '\\A.*[^0-9a-f].*\\Z')),
CHECK ((char_length("cache_key") = 64) AND ("cache_key" COLLATE "C" !~ '\\A.*[^0-9a-f].*\\Z')),
CHECK ((char_length("gateway_namespace") > 0)),
CHECK ((char_length("workspace_dir") > 0)),
CHECK ((char_length("home_dir") > 0)),
CHECK ((char_length("source_manifest_ref") = 71) AND (substr("source_manifest_ref", 1, 7) = 'sha256:') AND (substr("source_manifest_ref", 8) COLLATE "C" !~ '\\A.*[^0-9a-f].*\\Z')),
CHECK ((char_length("prepared_manifest_ref") = 71) AND (substr("prepared_manifest_ref", 1, 7) = 'sha256:') AND (substr("prepared_manifest_ref", 8) COLLATE "C" !~ '\\A.*[^0-9a-f].*\\Z')),
CHECK (("state" IN ('available', 'bound', 'retiring', 'retired'))),
CHECK ((char_length("environment_id") > 0)),
CHECK (("owner_epoch" BETWEEN 1 AND 9007199254740991)),
CHECK (("created_at_ms" BETWEEN 0 AND 9007199254740991)),
CHECK (("bound_at_ms" BETWEEN "created_at_ms" AND 9007199254740991)),
CHECK (("retired_at_ms" BETWEEN coalesce("bound_at_ms", "created_at_ms") AND 9007199254740991)),
CHECK (("session_id" IS NULL AND "session_key" IS NULL AND "owner_epoch" IS NULL AND "bound_at_ms" IS NULL) OR ("session_id" IS NOT NULL AND (char_length("session_id") > 0) AND "session_key" IS NOT NULL AND (char_length("session_key") > 0) AND "owner_epoch" IS NOT NULL AND "bound_at_ms" IS NOT NULL)),
CHECK ((("state" = 'available') AND "bound_at_ms" IS NULL AND "retired_at_ms" IS NULL) OR (("state" = 'bound') AND "bound_at_ms" IS NOT NULL AND "retired_at_ms" IS NULL) OR (("state" = 'retiring') AND "retired_at_ms" IS NULL) OR (("state" = 'retired') AND "retired_at_ms" IS NOT NULL)),
UNIQUE ("workspace_dir")
);
`},{id:`node_worker_turns`,tables:[`node_worker_turns`],indexes:[`idx_node_worker_turns_terminal_completed`,`idx_node_worker_turns_active_owner`],dependencies:[`node_worker_launches`],activation:`first-use`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "node_worker_turns" (
"turn_id" text COLLATE "C" NOT NULL,
"owner_launch_id" text COLLATE "C" NOT NULL,
"plan_hash" text COLLATE "C" NOT NULL,
"run_id" text COLLATE "C" NOT NULL,
"state" text COLLATE "C" NOT NULL,
"result_json" text COLLATE "C",
"error_text" text COLLATE "C",
"completed_at_ms" bigint,
"created_at_ms" bigint NOT NULL,
"updated_at_ms" bigint NOT NULL,
PRIMARY KEY ("turn_id"),
CHECK ((char_length("turn_id") BETWEEN 1 AND 256) AND ("turn_id" IS NOT NULL OR NULL)),
CHECK ((char_length("plan_hash") = 64) AND ("plan_hash" COLLATE "C" !~ '\\A.*[^0-9a-f].*\\Z')),
CHECK ((char_length("run_id") BETWEEN 1 AND 256) AND ("run_id" IS NOT NULL OR NULL)),
CHECK (("state" IN ('running', 'completed', 'failed', 'interrupted', 'cancelled'))),
CHECK ("result_json" IS NULL OR ((octet_length(convert_to("result_json", 'UTF8')) BETWEEN 1 AND 65536) AND ("result_json" IS NOT NULL OR NULL) AND ("result_json" IS JSON))),
CHECK ("error_text" IS NULL OR ((octet_length(convert_to("error_text", 'UTF8')) BETWEEN 1 AND 4096) AND ("error_text" IS NOT NULL OR NULL) AND (strpos("error_text", '
') = 0) AND (strpos("error_text", '\r') = 0))),
CHECK ("completed_at_ms" IS NULL OR ("completed_at_ms" BETWEEN 0 AND 9007199254740991)),
CHECK (("created_at_ms" BETWEEN 0 AND 9007199254740991)),
CHECK (("updated_at_ms" BETWEEN "created_at_ms" AND 9007199254740991)),
CHECK ((("state" = 'running') AND "result_json" IS NULL AND "error_text" IS NULL AND "completed_at_ms" IS NULL) OR (("state" = 'completed') AND "result_json" IS NOT NULL AND "error_text" IS NULL AND ("completed_at_ms" BETWEEN "created_at_ms" AND "updated_at_ms")) OR (("state" IN ('failed', 'interrupted', 'cancelled')) AND "result_json" IS NULL AND "error_text" IS NOT NULL AND ("completed_at_ms" BETWEEN "created_at_ms" AND "updated_at_ms")))
);
CREATE UNIQUE INDEX "idx_node_worker_turns_active_owner" ON "node_worker_turns" (("owner_launch_id") ASC) WHERE ("state" = 'running');
CREATE INDEX "idx_node_worker_turns_terminal_completed" ON "node_worker_turns" (("completed_at_ms") ASC, ("turn_id") ASC) WHERE "completed_at_ms" IS NOT NULL;
ALTER TABLE "node_worker_turns" ADD FOREIGN KEY ("owner_launch_id") REFERENCES "node_worker_launches" ("launch_id") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;
`},{id:`operator_approval_execution_identities`,tables:[`operator_approval_execution_identities`],indexes:[],dependencies:[],activation:`first-use`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "operator_approval_execution_identities" (
"approval_id" text COLLATE "C" NOT NULL,
"source_context_id" text COLLATE "C" NOT NULL,
"source_execution_id" text COLLATE "C" NOT NULL,
PRIMARY KEY ("approval_id"),
CHECK ((char_length("source_context_id") BETWEEN 1 AND 256) AND ("source_context_id" = btrim("source_context_id"))),
CHECK ((char_length("source_execution_id") BETWEEN 1 AND 256) AND ("source_execution_id" = btrim("source_execution_id")))
);
ALTER TABLE "operator_approval_execution_identities" ADD FOREIGN KEY ("approval_id") REFERENCES "operator_approvals" ("approval_id") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;
`},{id:`web_push_approval_deliveries`,tables:[`web_push_approval_deliveries`],indexes:[`idx_web_push_approval_deliveries_subscription`],dependencies:[],activation:`first-use`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "web_push_approval_deliveries" (
"approval_id" text COLLATE "C" NOT NULL,
"subscription_id" text COLLATE "C" NOT NULL,
"device_id" text COLLATE "C" NOT NULL,
"user_profile_id" text COLLATE "C",
"prepared_at_ms" bigint NOT NULL,
PRIMARY KEY ("approval_id", "subscription_id")
);
CREATE INDEX "idx_web_push_approval_deliveries_subscription" ON "web_push_approval_deliveries" (("subscription_id") ASC, ("approval_id") ASC);
ALTER TABLE "web_push_approval_deliveries" ADD FOREIGN KEY ("subscription_id") REFERENCES "web_push_subscriptions" ("subscription_id") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;
ALTER TABLE "web_push_approval_deliveries" ADD FOREIGN KEY ("approval_id") REFERENCES "operator_approvals" ("approval_id") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;
`},{id:`execution_decision_facts`,tables:[`execution_decision_facts`],indexes:[`execution_decision_facts_cursor_id_idx`,`execution_decision_facts_context_occurred_idx`,`execution_decision_facts_run_occurred_idx`],dependencies:[],activation:`first-use`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "execution_decision_facts" (
"cursor_id" bigint NOT NULL,
"receipt_id" text COLLATE "C" NOT NULL,
"context_id" text COLLATE "C" NOT NULL,
"execution_id" text COLLATE "C" NOT NULL,
"run_id" text COLLATE "C" NOT NULL,
"action_id" text COLLATE "C",
"action_family" text COLLATE "C" NOT NULL,
"decision_outcome" text COLLATE "C" NOT NULL,
"coverage_state" text COLLATE "C" NOT NULL,
"reason_code" text COLLATE "C" NOT NULL,
"owner" text COLLATE "C" NOT NULL,
"source_ref" text COLLATE "C" NOT NULL,
"occurred_at" bigint NOT NULL,
"receipt_bytes" bigint NOT NULL,
"receipt_json" text COLLATE "C" NOT NULL,
PRIMARY KEY ("receipt_id"),
CHECK ((char_length("receipt_id") BETWEEN 1 AND 256)),
CHECK ((char_length("context_id") BETWEEN 1 AND 256)),
CHECK ((char_length("execution_id") BETWEEN 1 AND 256)),
CHECK ((char_length("run_id") BETWEEN 1 AND 256)),
CHECK ("action_id" IS NULL OR (char_length("action_id") BETWEEN 1 AND 256)),
CHECK ((char_length("action_family") BETWEEN 1 AND 256)),
CHECK (("decision_outcome" IN ('allowed', 'denied', 'not-applicable', 'unknown'))),
CHECK (("coverage_state" IN ('enforced', 'attribution-only', 'unattributed', 'unknown', 'unsupported'))),
CHECK ((char_length("reason_code") BETWEEN 1 AND 256)),
CHECK ((char_length("owner") BETWEEN 1 AND 256)),
CHECK ((char_length("source_ref") BETWEEN 1 AND 256)),
CHECK (("occurred_at" >= 0)),
CHECK (("receipt_bytes" BETWEEN 1 AND 16384)),
CHECK ((char_length("receipt_json") > 0)),
UNIQUE ("occurred_at", "receipt_id")
);
CREATE INDEX "execution_decision_facts_context_occurred_idx" ON "execution_decision_facts" (("context_id") ASC, ("occurred_at") ASC, ("receipt_id") ASC);
CREATE UNIQUE INDEX "execution_decision_facts_cursor_id_idx" ON "execution_decision_facts" (("cursor_id") ASC);
CREATE INDEX "execution_decision_facts_run_occurred_idx" ON "execution_decision_facts" (("run_id") ASC, ("occurred_at") ASC, ("receipt_id") ASC);
`},{id:`execution_owner_lifecycle_bindings`,tables:[`execution_owner_lifecycle_bindings`],indexes:[],dependencies:[],activation:`first-use`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "execution_owner_lifecycle_bindings" (
"owner_kind" text COLLATE "C" NOT NULL,
"owner_id" text COLLATE "C" NOT NULL,
"context_id" text COLLATE "C" NOT NULL,
"execution_id" text COLLATE "C" NOT NULL,
PRIMARY KEY ("owner_kind", "owner_id")
);
`},{id:`outbound_message_execution_bindings`,tables:[`outbound_message_execution_bindings`],indexes:[`outbound_message_execution_bindings_execution_event_idx`],dependencies:[],activation:`first-use`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "outbound_message_execution_bindings" (
"event_id" text COLLATE "C" NOT NULL,
"context_id" text COLLATE "C" NOT NULL,
"execution_id" text COLLATE "C" NOT NULL,
"run_id" text COLLATE "C" NOT NULL,
PRIMARY KEY ("event_id"),
CHECK ((char_length("context_id") BETWEEN 1 AND 256)),
CHECK ((char_length("execution_id") BETWEEN 1 AND 256)),
CHECK ((char_length("run_id") BETWEEN 1 AND 256))
);
CREATE INDEX "outbound_message_execution_bindings_execution_event_idx" ON "outbound_message_execution_bindings" (("context_id") ASC, ("execution_id") ASC, ("run_id") ASC, ("event_id") ASC);
ALTER TABLE "outbound_message_execution_bindings" ADD FOREIGN KEY ("event_id") REFERENCES "audit_events" ("event_id") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;
`},{id:`outbound_message_progress`,tables:[`outbound_message_progress`],indexes:[`outbound_message_progress_occurred_idx`,`outbound_message_progress_run_occurred_idx`],dependencies:[],activation:`first-use`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "outbound_message_progress" (
"sequence" bigint GENERATED BY DEFAULT AS IDENTITY NOT NULL,
"progress_id" text COLLATE "C" NOT NULL,
"source_id" text COLLATE "C" NOT NULL,
"source_sequence" bigint NOT NULL,
"schema_version" bigint NOT NULL,
"occurred_at" bigint NOT NULL,
"action" text COLLATE "C" NOT NULL,
"outcome" text COLLATE "C" NOT NULL,
"actor_type" text COLLATE "C" NOT NULL,
"actor_id" text COLLATE "C" NOT NULL,
"agent_id" text COLLATE "C",
"run_id" text COLLATE "C",
"context_id" text COLLATE "C",
"execution_id" text COLLATE "C",
"channel" text COLLATE "C" NOT NULL,
"conversation_kind" text COLLATE "C" NOT NULL,
"duration_ms" bigint,
"account_ref" text COLLATE "C",
"conversation_ref" text COLLATE "C",
"target_ref" text COLLATE "C",
PRIMARY KEY ("sequence"),
CHECK ((char_length("progress_id") BETWEEN 1 AND 256)),
CHECK ((char_length("source_id") BETWEEN 1 AND 512)),
CHECK (("source_sequence" >= 1)),
CHECK (("schema_version" = 1)),
CHECK (("occurred_at" >= 0)),
CHECK (("action" IN ('message.outbound.queued', 'message.outbound.platform-started'))),
CHECK (("outcome" IN ('queued', 'platform_started'))),
CHECK (("actor_type" IN ('agent', 'system'))),
CHECK ((char_length("actor_id") BETWEEN 1 AND 256)),
CHECK ("agent_id" IS NULL OR (char_length("agent_id") BETWEEN 1 AND 256)),
CHECK ("run_id" IS NULL OR (char_length("run_id") BETWEEN 1 AND 256)),
CHECK ((char_length("channel") BETWEEN 1 AND 256)),
CHECK (("conversation_kind" IN ('direct', 'group', 'channel', 'unknown'))),
CHECK ("duration_ms" IS NULL OR ("duration_ms" >= 0)),
UNIQUE ("progress_id"),
UNIQUE ("source_id"),
UNIQUE ("occurred_at", "progress_id")
);
CREATE INDEX "outbound_message_progress_occurred_idx" ON "outbound_message_progress" (("occurred_at") ASC, ("sequence") ASC);
CREATE INDEX "outbound_message_progress_run_occurred_idx" ON "outbound_message_progress" (("run_id") ASC NULLS FIRST, ("occurred_at") ASC, ("sequence") ASC);
`},{id:`agent_provenance`,tables:[`agent_provenance`],indexes:[],dependencies:[],activation:`version-additive`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "agent_provenance" (
"agent_id" text COLLATE "C" NOT NULL,
"created_via" text COLLATE "C" NOT NULL,
"creator_agent_id" text COLLATE "C",
"created_at_ms" bigint NOT NULL,
PRIMARY KEY ("agent_id"),
CHECK (("created_via" IN ('operator', 'agent', 'template')))
);
`},{id:`cron_run_receipts`,tables:[`cron_run_receipts`],indexes:[`cron_run_receipts_cursor_id_idx`,`idx_cron_run_receipts_active_job`,`idx_cron_run_receipts_job_history`],dependencies:[],activation:`version-additive`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "cron_run_receipts" (
"cursor_id" bigint NOT NULL,
"receipt_id" text COLLATE "C" NOT NULL,
"store_key" text COLLATE "C" NOT NULL,
"job_id" text COLLATE "C" NOT NULL,
"config_revision" text COLLATE "C" NOT NULL,
"agent_id" text COLLATE "C" NOT NULL,
"request_run_id" text COLLATE "C",
"delivery_attempt_state" text COLLATE "C" NOT NULL DEFAULT 'unknown',
"status" text COLLATE "C" NOT NULL,
"owner_pid" bigint NOT NULL,
"owner_start_time" bigint,
"started_at_ms" bigint NOT NULL,
"finished_at_ms" bigint,
"error_text" text COLLATE "C",
PRIMARY KEY ("receipt_id"),
CHECK (("delivery_attempt_state" IN ('unknown', 'not-started', 'started'))),
CHECK (("status" IN ('running', 'ok', 'error', 'skipped', 'interrupted', 'superseded'))),
CHECK ((("status" = 'running') AND "finished_at_ms" IS NULL) OR (("status" != 'running') AND "finished_at_ms" IS NOT NULL))
);
CREATE UNIQUE INDEX "cron_run_receipts_cursor_id_idx" ON "cron_run_receipts" (("cursor_id") ASC);
CREATE UNIQUE INDEX "idx_cron_run_receipts_active_job" ON "cron_run_receipts" (("store_key") ASC, ("job_id") ASC) WHERE ("status" = 'running');
CREATE INDEX "idx_cron_run_receipts_job_history" ON "cron_run_receipts" (("store_key") ASC, ("job_id") ASC, ("started_at_ms") DESC, ("receipt_id") DESC);
`},{id:`config_revision_keys`,tables:[`config_revision_keys`],indexes:[],dependencies:[],activation:`version-additive`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "config_revision_keys" (
"id" bigint GENERATED BY DEFAULT AS IDENTITY NOT NULL,
"hmac_key" bytea NOT NULL,
PRIMARY KEY ("id"),
CHECK (("id" = 1)),
CHECK ((octet_length("hmac_key") = 32))
);
`},{id:`secret_store_entries`,tables:[`secret_store_entries`],indexes:[`secret_store_entries_live_idx`],dependencies:[],activation:`version-additive`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "secret_store_entries" (
"scope_kind" text COLLATE "C" NOT NULL,
"scope_id" text COLLATE "C" NOT NULL,
"name" text COLLATE "C" NOT NULL,
"value" text COLLATE "C" NOT NULL,
"kind" text COLLATE "C" NOT NULL,
"created_at_ms" bigint NOT NULL,
"updated_at_ms" bigint NOT NULL,
"updated_by" text COLLATE "C",
"deleted_at_ms" bigint,
"allowed_hosts" text COLLATE "C",
PRIMARY KEY ("scope_kind", "scope_id", "name"),
CHECK (("scope_kind" IN ('team', 'identity'))),
CHECK (("kind" IN ('secret', 'env'))),
CHECK (("created_at_ms" >= 0)),
CHECK (("updated_at_ms" >= 0)),
CHECK ((("scope_kind" = 'team') AND ("scope_id" = '')) OR (("scope_kind" = 'identity') AND (char_length("scope_id") > 0)))
);
CREATE INDEX "secret_store_entries_live_idx" ON "secret_store_entries" (("scope_kind") ASC, ("scope_id") ASC, ("name") ASC) WHERE "deleted_at_ms" IS NULL;
`},{id:`projects`,tables:[`projects`],indexes:[],dependencies:[],activation:`version-additive`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "projects" (
"id" text COLLATE "C" NOT NULL,
"display_name" text COLLATE "C" NOT NULL,
"repo_root" text COLLATE "C" NOT NULL,
"origin_url" text COLLATE "C",
"source" text COLLATE "C" NOT NULL,
"created_at_ms" bigint NOT NULL,
"updated_at_ms" bigint NOT NULL,
PRIMARY KEY ("id"),
CHECK (("source" IN ('registered', 'cloned')))
);
`},{id:`worktree_templates`,tables:[`worktree_templates`],indexes:[],dependencies:[],activation:`version-additive`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "worktree_templates" (
"cache_key" text COLLATE "C" NOT NULL,
"id" text COLLATE "C" NOT NULL,
"repo_root" text COLLATE "C" NOT NULL,
"common_dir" text COLLATE "C" NOT NULL,
"worktree_root" text COLLATE "C" NOT NULL,
"path" text COLLATE "C" NOT NULL,
"backend" text COLLATE "C" NOT NULL,
"source_commit" text COLLATE "C" NOT NULL,
"content_key" text COLLATE "C" NOT NULL,
"status" text COLLATE "C" NOT NULL,
"created_at" bigint NOT NULL,
"last_used_at" bigint NOT NULL,
PRIMARY KEY ("cache_key"),
CHECK (("status" IN ('preparing', 'ready'))),
UNIQUE ("id")
);
`},{id:`user_preferences`,tables:[`user_preferences`],indexes:[],dependencies:[],activation:`version-additive`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "user_preferences" (
"profile_id" text COLLATE "C" NOT NULL,
"pref_key" text COLLATE "C" NOT NULL,
"value_json" text COLLATE "C" NOT NULL,
"updated_at_ms" bigint NOT NULL,
PRIMARY KEY ("profile_id", "pref_key")
);
`},{id:`device_pair_setup_completions`,tables:[`device_pair_setup_completions`],indexes:[],dependencies:[],activation:`version-additive`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "device_pair_setup_completions" (
"setup_id" text COLLATE "C" NOT NULL,
"device_id" text COLLATE "C" NOT NULL,
"device_name" text COLLATE "C",
"access" text COLLATE "C" NOT NULL,
"completed_at_ms" bigint NOT NULL,
"delivery_state" text COLLATE "C" NOT NULL,
"retain_until_ms" bigint NOT NULL,
PRIMARY KEY ("setup_id"),
CHECK (("delivery_state" IN ('uncertain', 'confirmed')))
);
`},{id:`github_publication_requests`,tables:[`github_publication_requests`],indexes:[`idx_github_publication_requests_pending`],dependencies:[],activation:`version-additive`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "github_publication_requests" (
"request_id" text COLLATE "C" NOT NULL,
"idempotency_key" text COLLATE "C" NOT NULL,
"request_digest" text COLLATE "C" NOT NULL,
"session_id" text COLLATE "C" NOT NULL,
"session_key" text COLLATE "C" NOT NULL,
"agent_id" text COLLATE "C" NOT NULL,
"worktree_id" text COLLATE "C" NOT NULL,
"repository_fingerprint" text COLLATE "C" NOT NULL,
"claim_id" text COLLATE "C",
"run_id" text COLLATE "C",
"environment_id" text COLLATE "C",
"owner_epoch" bigint,
"placement_generation" bigint,
"identity_source" text COLLATE "C" NOT NULL,
"identity_profile_id" text COLLATE "C",
"identity_account_id" bigint NOT NULL,
"identity_login" text COLLATE "C" NOT NULL,
"title" text COLLATE "C",
"body" text COLLATE "C",
"status" text COLLATE "C" NOT NULL,
"gateway_instance_id" text COLLATE "C",
"repository" text COLLATE "C",
"branch" text COLLATE "C" NOT NULL,
"base_branch" text COLLATE "C",
"source_head_commit" text COLLATE "C",
"source_index_tree" text COLLATE "C",
"workspace_tree" text COLLATE "C",
"head_commit" text COLLATE "C",
"pull_request_url" text COLLATE "C",
"error_code" text COLLATE "C",
"next_action" text COLLATE "C",
"created_at_ms" bigint NOT NULL,
"updated_at_ms" bigint NOT NULL,
"reported_at_ms" bigint,
"draft" bigint,
PRIMARY KEY ("request_id"),
CHECK ("owner_epoch" IS NULL OR ("owner_epoch" >= 1)),
CHECK ("placement_generation" IS NULL OR ("placement_generation" >= 0)),
CHECK (("identity_source" IN ('system-detected', 'system-configured', 'agent-override'))),
CHECK (("identity_account_id" >= 1)),
CHECK (("status" IN ('requested', 'publishing', 'published', 'failed'))),
CHECK (("claim_id" IS NULL AND "run_id" IS NULL AND "environment_id" IS NULL AND "owner_epoch" IS NULL AND "placement_generation" IS NULL) OR ("claim_id" IS NOT NULL AND "run_id" IS NOT NULL AND "placement_generation" IS NOT NULL AND (("environment_id" IS NULL AND "owner_epoch" IS NULL) OR ("environment_id" IS NOT NULL AND "owner_epoch" IS NOT NULL)))),
CHECK (("identity_source" IS NOT DISTINCT FROM 'system-detected' AND "identity_profile_id" IS NULL) OR (("identity_source" IN ('system-configured', 'agent-override')) AND "identity_profile_id" IS NOT NULL)),
CHECK (("source_head_commit" IS NULL AND "source_index_tree" IS NULL AND "workspace_tree" IS NULL) OR ("source_head_commit" IS NOT NULL AND "workspace_tree" IS NOT NULL)),
CHECK (("status" IS NOT DISTINCT FROM 'published' AND "pull_request_url" IS NOT NULL AND "error_code" IS NULL AND "next_action" IS NULL) OR ("status" IS NOT DISTINCT FROM 'failed' AND "pull_request_url" IS NULL AND "error_code" IS NOT NULL AND "next_action" IS NOT NULL) OR (("status" IN ('requested', 'publishing')) AND "pull_request_url" IS NULL AND "error_code" IS NULL AND "next_action" IS NULL)),
UNIQUE ("session_id", "idempotency_key")
);
CREATE INDEX "idx_github_publication_requests_pending" ON "github_publication_requests" (("status") ASC, ("updated_at_ms") ASC, ("request_id") ASC);
`},{id:`device_pairing_join_codes`,tables:[`device_pairing_join_codes`],indexes:[],dependencies:[],activation:`version-additive`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "device_pairing_join_codes" (
"shortcode" text COLLATE "C",
"payload_json" text COLLATE "C",
"created_at_ms" bigint,
"expires_at_ms" bigint
);
`},{id:`device_pairing_browser_requests`,tables:[`device_pairing_browser_requests`],indexes:[],dependencies:[],activation:`version-additive`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "device_pairing_browser_requests" (
"request_id" text COLLATE "C" NOT NULL,
"code" text COLLATE "C" NOT NULL,
"device_id" text COLLATE "C" NOT NULL,
"public_key" text COLLATE "C" NOT NULL,
"remote_ip" text COLLATE "C",
"user_agent" text COLLATE "C",
"origin" text COLLATE "C",
"status" text COLLATE "C" NOT NULL,
"approved_token_sha256" text COLLATE "C",
"created_at_ms" bigint NOT NULL,
"expires_at_ms" bigint NOT NULL,
PRIMARY KEY ("request_id"),
CHECK (("status" IN ('pending', 'approved', 'rejected'))),
UNIQUE ("code"),
UNIQUE ("device_id")
);
`},{id:`skill_workshop_changes`,tables:[`skill_workshop_changes`],indexes:[`skill_workshop_changes_cursor_id_idx`,`idx_skill_workshop_changes_agent_time`],dependencies:[],activation:`version-additive`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "skill_workshop_changes" (
"cursor_id" bigint NOT NULL,
"change_id" text COLLATE "C" NOT NULL,
"agent_id" text COLLATE "C" NOT NULL,
"skill_name" text COLLATE "C" NOT NULL,
"action" text COLLATE "C" NOT NULL,
"actor" text COLLATE "C" NOT NULL,
"summary" text COLLATE "C" NOT NULL,
"version_id" text COLLATE "C",
"session_key" text COLLATE "C",
"run_id" text COLLATE "C",
"created_at_ms" bigint NOT NULL,
PRIMARY KEY ("change_id"),
CHECK (("action" IN ('create', 'patch', 'write_file', 'remove_file', 'archive', 'restore'))),
CHECK (("actor" IN ('agent', 'review', 'curator', 'user')))
);
CREATE INDEX "idx_skill_workshop_changes_agent_time" ON "skill_workshop_changes" (("agent_id") ASC, ("created_at_ms") ASC);
CREATE UNIQUE INDEX "skill_workshop_changes_cursor_id_idx" ON "skill_workshop_changes" (("cursor_id") ASC);
`},{id:`worker_environment_ssh_fallback_ports`,tables:[`worker_environment_ssh_fallback_ports`],indexes:[],dependencies:[],activation:`version-additive`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "worker_environment_ssh_fallback_ports" (
"environment_id" text COLLATE "C" NOT NULL,
"position" bigint NOT NULL,
"port" bigint NOT NULL,
PRIMARY KEY ("environment_id", "position"),
CHECK (("position" >= 0) AND ("position" <= 9)),
CHECK (("port" >= 1) AND ("port" <= 65535)),
UNIQUE ("environment_id", "port")
);
ALTER TABLE "worker_environment_ssh_fallback_ports" ADD FOREIGN KEY ("environment_id") REFERENCES "worker_environments" ("environment_id") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;
`},{id:`worker_session_placement_moves`,tables:[`worker_session_placement_moves`],indexes:[],dependencies:[],activation:`version-additive`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "worker_session_placement_moves" (
"operation_id" text COLLATE "C" NOT NULL,
"session_id" text COLLATE "C" NOT NULL,
"source_generation" bigint NOT NULL,
"source_environment_id" text COLLATE "C" NOT NULL,
"source_owner_epoch" bigint NOT NULL,
"target_kind" text COLLATE "C" NOT NULL,
"target_id" text COLLATE "C",
"target_machine_class" text COLLATE "C",
"target_os" text COLLATE "C",
"abandon_source" bigint,
"last_error" text COLLATE "C",
"created_at_ms" bigint NOT NULL,
"updated_at_ms" bigint NOT NULL,
PRIMARY KEY ("operation_id"),
CHECK (("source_generation" >= 0)),
CHECK ((char_length("source_environment_id") BETWEEN 1 AND 256) AND ("source_environment_id" = btrim("source_environment_id"))),
CHECK (("source_owner_epoch" >= 1)),
CHECK (("target_kind" IN ('gateway', 'profile', 'device'))),
CHECK (("target_kind" IS NOT DISTINCT FROM 'gateway' AND "target_id" IS NULL) OR (("target_kind" IN ('profile', 'device')) AND "target_id" IS NOT NULL AND (char_length("target_id") BETWEEN 1 AND 256) AND ("target_id" = btrim("target_id")))),
UNIQUE ("session_id")
);
ALTER TABLE "worker_session_placement_moves" ADD FOREIGN KEY ("session_id") REFERENCES "worker_session_placements" ("session_id") ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE;
`},{id:`agent_deletion_journal`,tables:[`agent_deletion_journal`],indexes:[],dependencies:[],activation:`version-additive`,sql:`-- Generated runtime DDL; the owner supplies search_path and the transaction.
CREATE TABLE "agent_deletion_journal" (
"agent_id" text COLLATE "C" NOT NULL,
"operation_id" text COLLATE "C" NOT NULL DEFAULT '',
"phase" text COLLATE "C",
"agent_dir" text COLLATE "C" NOT NULL,
"workspace_dir" text COLLATE "C" NOT NULL,
"sessions_dir" text COLLATE "C" NOT NULL,
"database_paths_json" text COLLATE "C" NOT NULL DEFAULT '[]',
"cleanup_paths_json" text COLLATE "C" NOT NULL DEFAULT '[]',
"created_at" bigint NOT NULL,
"cleanup_completed" bigint NOT NULL DEFAULT 0,
"delete_files" bigint NOT NULL DEFAULT 1,
PRIMARY KEY ("agent_id")
);
`}];return Object.defineProperty(this,"fragments",{value:e,enumerable:!0,configurable:!0,writable:!0}),e},get expectedCatalog(){let e=[{table:`acp_replay_events`,kind:`table`,value:null},{table:`acp_replay_events`,kind:`column`,value:{name:`session_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`acp_replay_events`,kind:`column`,value:{name:`seq`,type:`bigint`,nullable:!1,identity:!1,default:null,position:2}},{table:`acp_replay_events`,kind:`column`,value:{name:`at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:3}},{table:`acp_replay_events`,kind:`column`,value:{name:`session_key`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`acp_replay_events`,kind:`column`,value:{name:`run_id`,type:`text`,nullable:!0,identity:!1,default:null,position:5}},{table:`acp_replay_events`,kind:`column`,value:{name:`update_json`,type:`text`,nullable:!1,identity:!1,default:null,position:6}},{table:`acp_replay_events`,kind:`column`,value:{name:`estimated_bytes`,type:`bigint`,nullable:!1,identity:!1,default:`0`,position:7}},{table:`acp_replay_events`,kind:`primaryKey`,value:[`session_id`,`seq`]},{table:`acp_replay_events`,kind:`foreignKey`,value:{columns:[`session_id`],target:`acp_replay_sessions`,targetColumns:[`session_id`],onUpdate:`NO ACTION`,onDelete:`CASCADE`,deferrable:!1,deferred:!1}},{table:`acp_replay_events`,kind:`indexes`,value:1},{table:`acp_replay_events`,kind:`checks`,value:0},{table:`acp_replay_sessions`,kind:`table`,value:null},{table:`acp_replay_sessions`,kind:`column`,value:{name:`session_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`acp_replay_sessions`,kind:`column`,value:{name:`session_key`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`acp_replay_sessions`,kind:`column`,value:{name:`cwd`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`acp_replay_sessions`,kind:`column`,value:{name:`complete`,type:`bigint`,nullable:!1,identity:!1,default:null,position:4}},{table:`acp_replay_sessions`,kind:`column`,value:{name:`created_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:5}},{table:`acp_replay_sessions`,kind:`column`,value:{name:`updated_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:6}},{table:`acp_replay_sessions`,kind:`column`,value:{name:`next_seq`,type:`bigint`,nullable:!1,identity:!1,default:null,position:7}},{table:`acp_replay_sessions`,kind:`column`,value:{name:`estimated_bytes`,type:`bigint`,nullable:!1,identity:!1,default:`0`,position:8}},{table:`acp_replay_sessions`,kind:`primaryKey`,value:[`session_id`]},{table:`acp_replay_sessions`,kind:`indexes`,value:3},{table:`acp_replay_sessions`,kind:`checks`,value:0},{table:`acp_sessions`,kind:`table`,value:null},{table:`acp_sessions`,kind:`column`,value:{name:`session_key`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`acp_sessions`,kind:`column`,value:{name:`session_id`,type:`text`,nullable:!0,identity:!1,default:null,position:2}},{table:`acp_sessions`,kind:`column`,value:{name:`backend`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`acp_sessions`,kind:`column`,value:{name:`agent`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`acp_sessions`,kind:`column`,value:{name:`runtime_session_name`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`acp_sessions`,kind:`column`,value:{name:`identity_json`,type:`text`,nullable:!0,identity:!1,default:null,position:6}},{table:`acp_sessions`,kind:`column`,value:{name:`resume_agent_session_id`,type:`text`,nullable:!0,identity:!1,default:null,position:7}},{table:`acp_sessions`,kind:`column`,value:{name:`resume_acpx_session_id`,type:`text`,nullable:!0,identity:!1,default:null,position:8}},{table:`acp_sessions`,kind:`column`,value:{name:`mode`,type:`text`,nullable:!1,identity:!1,default:null,position:9}},{table:`acp_sessions`,kind:`column`,value:{name:`runtime_options_json`,type:`text`,nullable:!0,identity:!1,default:null,position:10}},{table:`acp_sessions`,kind:`column`,value:{name:`cwd`,type:`text`,nullable:!0,identity:!1,default:null,position:11}},{table:`acp_sessions`,kind:`column`,value:{name:`state`,type:`text`,nullable:!1,identity:!1,default:null,position:12}},{table:`acp_sessions`,kind:`column`,value:{name:`last_activity_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:13}},{table:`acp_sessions`,kind:`column`,value:{name:`last_error`,type:`text`,nullable:!0,identity:!1,default:null,position:14}},{table:`acp_sessions`,kind:`column`,value:{name:`updated_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:15}},{table:`acp_sessions`,kind:`primaryKey`,value:[`session_key`]},{table:`acp_sessions`,kind:`indexes`,value:5},{table:`acp_sessions`,kind:`checks`,value:0},{table:`agent_database_leases`,kind:`table`,value:null},{table:`agent_database_leases`,kind:`column`,value:{name:`lease_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`agent_database_leases`,kind:`column`,value:{name:`agent_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`agent_database_leases`,kind:`column`,value:{name:`path`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`agent_database_leases`,kind:`column`,value:{name:`owner_pid`,type:`bigint`,nullable:!1,identity:!1,default:null,position:4}},{table:`agent_database_leases`,kind:`column`,value:{name:`owner_start_time`,type:`bigint`,nullable:!0,identity:!1,default:null,position:5}},{table:`agent_database_leases`,kind:`column`,value:{name:`opened_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:6}},{table:`agent_database_leases`,kind:`column`,value:{name:`provenance`,type:`text`,nullable:!0,identity:!1,default:null,position:7}},{table:`agent_database_leases`,kind:`primaryKey`,value:[`lease_id`]},{table:`agent_database_leases`,kind:`indexes`,value:1},{table:`agent_database_leases`,kind:`checks`,value:0},{table:`agent_databases`,kind:`table`,value:null},{table:`agent_databases`,kind:`column`,value:{name:`agent_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`agent_databases`,kind:`column`,value:{name:`path`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`agent_databases`,kind:`column`,value:{name:`schema_version`,type:`bigint`,nullable:!1,identity:!1,default:null,position:3}},{table:`agent_databases`,kind:`column`,value:{name:`last_seen_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:4}},{table:`agent_databases`,kind:`column`,value:{name:`size_bytes`,type:`bigint`,nullable:!0,identity:!1,default:null,position:5}},{table:`agent_databases`,kind:`primaryKey`,value:[`agent_id`,`path`]},{table:`agent_databases`,kind:`indexes`,value:1},{table:`agent_databases`,kind:`checks`,value:0},{table:`agent_deletion_journal`,kind:`table`,value:null},{table:`agent_deletion_journal`,kind:`column`,value:{name:`agent_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`agent_deletion_journal`,kind:`column`,value:{name:`operation_id`,type:`text`,nullable:!1,identity:!1,default:`''`,position:2}},{table:`agent_deletion_journal`,kind:`column`,value:{name:`phase`,type:`text`,nullable:!0,identity:!1,default:null,position:3}},{table:`agent_deletion_journal`,kind:`column`,value:{name:`agent_dir`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`agent_deletion_journal`,kind:`column`,value:{name:`workspace_dir`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`agent_deletion_journal`,kind:`column`,value:{name:`sessions_dir`,type:`text`,nullable:!1,identity:!1,default:null,position:6}},{table:`agent_deletion_journal`,kind:`column`,value:{name:`database_paths_json`,type:`text`,nullable:!1,identity:!1,default:`'[]'`,position:7}},{table:`agent_deletion_journal`,kind:`column`,value:{name:`cleanup_paths_json`,type:`text`,nullable:!1,identity:!1,default:`'[]'`,position:8}},{table:`agent_deletion_journal`,kind:`column`,value:{name:`created_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:9}},{table:`agent_deletion_journal`,kind:`column`,value:{name:`cleanup_completed`,type:`bigint`,nullable:!1,identity:!1,default:`0`,position:10}},{table:`agent_deletion_journal`,kind:`column`,value:{name:`delete_files`,type:`bigint`,nullable:!1,identity:!1,default:`1`,position:11}},{table:`agent_deletion_journal`,kind:`primaryKey`,value:[`agent_id`]},{table:`agent_deletion_journal`,kind:`indexes`,value:1},{table:`agent_deletion_journal`,kind:`checks`,value:0},{table:`agent_provenance`,kind:`table`,value:null},{table:`agent_provenance`,kind:`column`,value:{name:`agent_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`agent_provenance`,kind:`column`,value:{name:`created_via`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`agent_provenance`,kind:`column`,value:{name:`creator_agent_id`,type:`text`,nullable:!0,identity:!1,default:null,position:3}},{table:`agent_provenance`,kind:`column`,value:{name:`created_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:4}},{table:`agent_provenance`,kind:`primaryKey`,value:[`agent_id`]},{table:`agent_provenance`,kind:`indexes`,value:1},{table:`agent_provenance`,kind:`checks`,value:1},{table:`apns_registration_tombstones`,kind:`table`,value:null},{table:`apns_registration_tombstones`,kind:`column`,value:{name:`node_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`apns_registration_tombstones`,kind:`column`,value:{name:`deleted_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:2}},{table:`apns_registration_tombstones`,kind:`primaryKey`,value:[`node_id`]},{table:`apns_registration_tombstones`,kind:`indexes`,value:1},{table:`apns_registration_tombstones`,kind:`checks`,value:0},{table:`apns_registrations`,kind:`table`,value:null},{table:`apns_registrations`,kind:`column`,value:{name:`node_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`apns_registrations`,kind:`column`,value:{name:`transport`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`apns_registrations`,kind:`column`,value:{name:`token`,type:`text`,nullable:!0,identity:!1,default:null,position:3}},{table:`apns_registrations`,kind:`column`,value:{name:`relay_handle`,type:`text`,nullable:!0,identity:!1,default:null,position:4}},{table:`apns_registrations`,kind:`column`,value:{name:`send_grant`,type:`text`,nullable:!0,identity:!1,default:null,position:5}},{table:`apns_registrations`,kind:`column`,value:{name:`installation_id`,type:`text`,nullable:!0,identity:!1,default:null,position:6}},{table:`apns_registrations`,kind:`column`,value:{name:`relay_origin`,type:`text`,nullable:!0,identity:!1,default:null,position:7}},{table:`apns_registrations`,kind:`column`,value:{name:`topic`,type:`text`,nullable:!1,identity:!1,default:null,position:8}},{table:`apns_registrations`,kind:`column`,value:{name:`environment`,type:`text`,nullable:!1,identity:!1,default:null,position:9}},{table:`apns_registrations`,kind:`column`,value:{name:`distribution`,type:`text`,nullable:!0,identity:!1,default:null,position:10}},{table:`apns_registrations`,kind:`column`,value:{name:`token_debug_suffix`,type:`text`,nullable:!0,identity:!1,default:null,position:11}},{table:`apns_registrations`,kind:`column`,value:{name:`updated_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:12}},{table:`apns_registrations`,kind:`primaryKey`,value:[`node_id`]},{table:`apns_registrations`,kind:`indexes`,value:2},{table:`apns_registrations`,kind:`checks`,value:0},{table:`audit_events`,kind:`table`,value:null},{table:`audit_events`,kind:`column`,value:{name:`sequence`,type:`bigint`,nullable:!1,identity:!0,default:null,position:1}},{table:`audit_events`,kind:`column`,value:{name:`event_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`audit_events`,kind:`column`,value:{name:`source_id`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`audit_events`,kind:`column`,value:{name:`schema_version`,type:`bigint`,nullable:!1,identity:!1,default:`1`,position:4}},{table:`audit_events`,kind:`column`,value:{name:`source_sequence`,type:`bigint`,nullable:!1,identity:!1,default:null,position:5}},{table:`audit_events`,kind:`column`,value:{name:`occurred_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:6}},{table:`audit_events`,kind:`column`,value:{name:`kind`,type:`text`,nullable:!1,identity:!1,default:null,position:7}},{table:`audit_events`,kind:`column`,value:{name:`action`,type:`text`,nullable:!1,identity:!1,default:null,position:8}},{table:`audit_events`,kind:`column`,value:{name:`status`,type:`text`,nullable:!1,identity:!1,default:null,position:9}},{table:`audit_events`,kind:`column`,value:{name:`error_code`,type:`text`,nullable:!0,identity:!1,default:null,position:10}},{table:`audit_events`,kind:`column`,value:{name:`actor_type`,type:`text`,nullable:!1,identity:!1,default:null,position:11}},{table:`audit_events`,kind:`column`,value:{name:`actor_id`,type:`text`,nullable:!1,identity:!1,default:null,position:12}},{table:`audit_events`,kind:`column`,value:{name:`agent_id`,type:`text`,nullable:!0,identity:!1,default:null,position:13}},{table:`audit_events`,kind:`column`,value:{name:`session_key`,type:`text`,nullable:!0,identity:!1,default:null,position:14}},{table:`audit_events`,kind:`column`,value:{name:`session_id`,type:`text`,nullable:!0,identity:!1,default:null,position:15}},{table:`audit_events`,kind:`column`,value:{name:`run_id`,type:`text`,nullable:!0,identity:!1,default:null,position:16}},{table:`audit_events`,kind:`column`,value:{name:`tool_call_id`,type:`text`,nullable:!0,identity:!1,default:null,position:17}},{table:`audit_events`,kind:`column`,value:{name:`tool_name`,type:`text`,nullable:!0,identity:!1,default:null,position:18}},{table:`audit_events`,kind:`column`,value:{name:`direction`,type:`text`,nullable:!0,identity:!1,default:null,position:19}},{table:`audit_events`,kind:`column`,value:{name:`channel`,type:`text`,nullable:!0,identity:!1,default:null,position:20}},{table:`audit_events`,kind:`column`,value:{name:`conversation_kind`,type:`text`,nullable:!0,identity:!1,default:null,position:21}},{table:`audit_events`,kind:`column`,value:{name:`message_outcome`,type:`text`,nullable:!0,identity:!1,default:null,position:22}},{table:`audit_events`,kind:`column`,value:{name:`reason_code`,type:`text`,nullable:!0,identity:!1,default:null,position:23}},{table:`audit_events`,kind:`column`,value:{name:`delivery_kind`,type:`text`,nullable:!0,identity:!1,default:null,position:24}},{table:`audit_events`,kind:`column`,value:{name:`failure_stage`,type:`text`,nullable:!0,identity:!1,default:null,position:25}},{table:`audit_events`,kind:`column`,value:{name:`duration_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:26}},{table:`audit_events`,kind:`column`,value:{name:`result_count`,type:`bigint`,nullable:!0,identity:!1,default:null,position:27}},{table:`audit_events`,kind:`column`,value:{name:`account_ref`,type:`text`,nullable:!0,identity:!1,default:null,position:28}},{table:`audit_events`,kind:`column`,value:{name:`conversation_ref`,type:`text`,nullable:!0,identity:!1,default:null,position:29}},{table:`audit_events`,kind:`column`,value:{name:`message_ref`,type:`text`,nullable:!0,identity:!1,default:null,position:30}},{table:`audit_events`,kind:`column`,value:{name:`target_ref`,type:`text`,nullable:!0,identity:!1,default:null,position:31}},{table:`audit_events`,kind:`primaryKey`,value:[`sequence`]},{table:`audit_events`,kind:`unique`,value:[`event_id`]},{table:`audit_events`,kind:`unique`,value:[`source_id`]},{table:`audit_events`,kind:`indexes`,value:11},{table:`audit_events`,kind:`checks`,value:0},{table:`audit_identity_keys`,kind:`table`,value:null},{table:`audit_identity_keys`,kind:`column`,value:{name:`id`,type:`bigint`,nullable:!1,identity:!0,default:null,position:1}},{table:`audit_identity_keys`,kind:`column`,value:{name:`key_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`audit_identity_keys`,kind:`column`,value:{name:`key`,type:`bytea`,nullable:!1,identity:!1,default:null,position:3}},{table:`audit_identity_keys`,kind:`column`,value:{name:`created_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:4}},{table:`audit_identity_keys`,kind:`primaryKey`,value:[`id`]},{table:`audit_identity_keys`,kind:`indexes`,value:1},{table:`audit_identity_keys`,kind:`checks`,value:1},{table:`backup_runs`,kind:`table`,value:null},{table:`backup_runs`,kind:`column`,value:{name:`id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`backup_runs`,kind:`column`,value:{name:`created_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:2}},{table:`backup_runs`,kind:`column`,value:{name:`archive_path`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`backup_runs`,kind:`column`,value:{name:`status`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`backup_runs`,kind:`column`,value:{name:`manifest_json`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`backup_runs`,kind:`primaryKey`,value:[`id`]},{table:`backup_runs`,kind:`indexes`,value:2},{table:`backup_runs`,kind:`checks`,value:0},{table:`capture_blobs`,kind:`table`,value:null},{table:`capture_blobs`,kind:`column`,value:{name:`blob_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`capture_blobs`,kind:`column`,value:{name:`content_type`,type:`text`,nullable:!0,identity:!1,default:null,position:2}},{table:`capture_blobs`,kind:`column`,value:{name:`encoding`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`capture_blobs`,kind:`column`,value:{name:`size_bytes`,type:`bigint`,nullable:!1,identity:!1,default:null,position:4}},{table:`capture_blobs`,kind:`column`,value:{name:`sha256`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`capture_blobs`,kind:`column`,value:{name:`data`,type:`bytea`,nullable:!1,identity:!1,default:null,position:6}},{table:`capture_blobs`,kind:`column`,value:{name:`created_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:7}},{table:`capture_blobs`,kind:`primaryKey`,value:[`blob_id`]},{table:`capture_blobs`,kind:`indexes`,value:1},{table:`capture_blobs`,kind:`checks`,value:0},{table:`capture_events`,kind:`table`,value:null},{table:`capture_events`,kind:`column`,value:{name:`id`,type:`bigint`,nullable:!1,identity:!0,default:null,position:1}},{table:`capture_events`,kind:`column`,value:{name:`session_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`capture_events`,kind:`column`,value:{name:`ts`,type:`bigint`,nullable:!1,identity:!1,default:null,position:3}},{table:`capture_events`,kind:`column`,value:{name:`source_scope`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`capture_events`,kind:`column`,value:{name:`source_process`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`capture_events`,kind:`column`,value:{name:`protocol`,type:`text`,nullable:!1,identity:!1,default:null,position:6}},{table:`capture_events`,kind:`column`,value:{name:`direction`,type:`text`,nullable:!1,identity:!1,default:null,position:7}},{table:`capture_events`,kind:`column`,value:{name:`kind`,type:`text`,nullable:!1,identity:!1,default:null,position:8}},{table:`capture_events`,kind:`column`,value:{name:`flow_id`,type:`text`,nullable:!1,identity:!1,default:null,position:9}},{table:`capture_events`,kind:`column`,value:{name:`method`,type:`text`,nullable:!0,identity:!1,default:null,position:10}},{table:`capture_events`,kind:`column`,value:{name:`host`,type:`text`,nullable:!0,identity:!1,default:null,position:11}},{table:`capture_events`,kind:`column`,value:{name:`path`,type:`text`,nullable:!0,identity:!1,default:null,position:12}},{table:`capture_events`,kind:`column`,value:{name:`status`,type:`bigint`,nullable:!0,identity:!1,default:null,position:13}},{table:`capture_events`,kind:`column`,value:{name:`close_code`,type:`bigint`,nullable:!0,identity:!1,default:null,position:14}},{table:`capture_events`,kind:`column`,value:{name:`content_type`,type:`text`,nullable:!0,identity:!1,default:null,position:15}},{table:`capture_events`,kind:`column`,value:{name:`headers_json`,type:`text`,nullable:!0,identity:!1,default:null,position:16}},{table:`capture_events`,kind:`column`,value:{name:`data_text`,type:`text`,nullable:!0,identity:!1,default:null,position:17}},{table:`capture_events`,kind:`column`,value:{name:`data_blob_id`,type:`text`,nullable:!0,identity:!1,default:null,position:18}},{table:`capture_events`,kind:`column`,value:{name:`data_sha256`,type:`text`,nullable:!0,identity:!1,default:null,position:19}},{table:`capture_events`,kind:`column`,value:{name:`error_text`,type:`text`,nullable:!0,identity:!1,default:null,position:20}},{table:`capture_events`,kind:`column`,value:{name:`meta_json`,type:`text`,nullable:!0,identity:!1,default:null,position:21}},{table:`capture_events`,kind:`primaryKey`,value:[`id`]},{table:`capture_events`,kind:`foreignKey`,value:{columns:[`data_blob_id`],target:`capture_blobs`,targetColumns:[`blob_id`],onUpdate:`NO ACTION`,onDelete:`SET NULL`,deferrable:!1,deferred:!1}},{table:`capture_events`,kind:`foreignKey`,value:{columns:[`session_id`],target:`capture_sessions`,targetColumns:[`id`],onUpdate:`NO ACTION`,onDelete:`CASCADE`,deferrable:!1,deferred:!1}},{table:`capture_events`,kind:`indexes`,value:3},{table:`capture_events`,kind:`checks`,value:0},{table:`capture_sessions`,kind:`table`,value:null},{table:`capture_sessions`,kind:`column`,value:{name:`id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`capture_sessions`,kind:`column`,value:{name:`started_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:2}},{table:`capture_sessions`,kind:`column`,value:{name:`ended_at`,type:`bigint`,nullable:!0,identity:!1,default:null,position:3}},{table:`capture_sessions`,kind:`column`,value:{name:`mode`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`capture_sessions`,kind:`column`,value:{name:`source_scope`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`capture_sessions`,kind:`column`,value:{name:`source_process`,type:`text`,nullable:!1,identity:!1,default:null,position:6}},{table:`capture_sessions`,kind:`column`,value:{name:`proxy_url`,type:`text`,nullable:!0,identity:!1,default:null,position:7}},{table:`capture_sessions`,kind:`primaryKey`,value:[`id`]},{table:`capture_sessions`,kind:`indexes`,value:1},{table:`capture_sessions`,kind:`checks`,value:0},{table:`channel_ingress_events`,kind:`table`,value:null},{table:`channel_ingress_events`,kind:`column`,value:{name:`queue_name`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`channel_ingress_events`,kind:`column`,value:{name:`event_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`channel_ingress_events`,kind:`column`,value:{name:`channel_id`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`channel_ingress_events`,kind:`column`,value:{name:`account_id`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`channel_ingress_events`,kind:`column`,value:{name:`status`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`channel_ingress_events`,kind:`column`,value:{name:`lane_key`,type:`text`,nullable:!0,identity:!1,default:null,position:6}},{table:`channel_ingress_events`,kind:`column`,value:{name:`payload_json`,type:`text`,nullable:!1,identity:!1,default:null,position:7}},{table:`channel_ingress_events`,kind:`column`,value:{name:`metadata_json`,type:`text`,nullable:!0,identity:!1,default:null,position:8}},{table:`channel_ingress_events`,kind:`column`,value:{name:`received_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:9}},{table:`channel_ingress_events`,kind:`column`,value:{name:`updated_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:10}},{table:`channel_ingress_events`,kind:`column`,value:{name:`claim_token`,type:`text`,nullable:!0,identity:!1,default:null,position:11}},{table:`channel_ingress_events`,kind:`column`,value:{name:`claim_owner`,type:`text`,nullable:!0,identity:!1,default:null,position:12}},{table:`channel_ingress_events`,kind:`column`,value:{name:`claimed_at`,type:`bigint`,nullable:!0,identity:!1,default:null,position:13}},{table:`channel_ingress_events`,kind:`column`,value:{name:`attempts`,type:`bigint`,nullable:!1,identity:!1,default:`0`,position:14}},{table:`channel_ingress_events`,kind:`column`,value:{name:`last_attempt_at`,type:`bigint`,nullable:!0,identity:!1,default:null,position:15}},{table:`channel_ingress_events`,kind:`column`,value:{name:`last_error`,type:`text`,nullable:!0,identity:!1,default:null,position:16}},{table:`channel_ingress_events`,kind:`column`,value:{name:`failed_reason`,type:`text`,nullable:!0,identity:!1,default:null,position:17}},{table:`channel_ingress_events`,kind:`column`,value:{name:`failed_at`,type:`bigint`,nullable:!0,identity:!1,default:null,position:18}},{table:`channel_ingress_events`,kind:`column`,value:{name:`completed_at`,type:`bigint`,nullable:!0,identity:!1,default:null,position:19}},{table:`channel_ingress_events`,kind:`column`,value:{name:`completed_metadata_json`,type:`text`,nullable:!0,identity:!1,default:null,position:20}},{table:`channel_ingress_events`,kind:`primaryKey`,value:[`queue_name`,`event_id`]},{table:`channel_ingress_events`,kind:`indexes`,value:4},{table:`channel_ingress_events`,kind:`checks`,value:0},{table:`channel_pairing_allow_entries`,kind:`table`,value:null},{table:`channel_pairing_allow_entries`,kind:`column`,value:{name:`channel_key`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`channel_pairing_allow_entries`,kind:`column`,value:{name:`account_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`channel_pairing_allow_entries`,kind:`column`,value:{name:`entry`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`channel_pairing_allow_entries`,kind:`column`,value:{name:`sort_order`,type:`bigint`,nullable:!1,identity:!1,default:null,position:4}},{table:`channel_pairing_allow_entries`,kind:`column`,value:{name:`updated_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:5}},{table:`channel_pairing_allow_entries`,kind:`primaryKey`,value:[`channel_key`,`account_id`,`entry`]},{table:`channel_pairing_allow_entries`,kind:`indexes`,value:2},{table:`channel_pairing_allow_entries`,kind:`checks`,value:0},{table:`channel_pairing_requests`,kind:`table`,value:null},{table:`channel_pairing_requests`,kind:`column`,value:{name:`channel_key`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`channel_pairing_requests`,kind:`column`,value:{name:`account_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`channel_pairing_requests`,kind:`column`,value:{name:`request_id`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`channel_pairing_requests`,kind:`column`,value:{name:`code`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`channel_pairing_requests`,kind:`column`,value:{name:`created_at`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`channel_pairing_requests`,kind:`column`,value:{name:`last_seen_at`,type:`text`,nullable:!1,identity:!1,default:null,position:6}},{table:`channel_pairing_requests`,kind:`column`,value:{name:`meta_json`,type:`text`,nullable:!0,identity:!1,default:null,position:7}},{table:`channel_pairing_requests`,kind:`primaryKey`,value:[`channel_key`,`account_id`,`request_id`]},{table:`channel_pairing_requests`,kind:`indexes`,value:3},{table:`channel_pairing_requests`,kind:`checks`,value:0},{table:`clawhub_promotion_claims`,kind:`table`,value:null},{table:`clawhub_promotion_claims`,kind:`column`,value:{name:`slug`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`clawhub_promotion_claims`,kind:`column`,value:{name:`provider`,type:`text`,nullable:!0,identity:!1,default:null,position:2}},{table:`clawhub_promotion_claims`,kind:`column`,value:{name:`model_keys_json`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`clawhub_promotion_claims`,kind:`column`,value:{name:`ends_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:4}},{table:`clawhub_promotion_claims`,kind:`column`,value:{name:`claimed_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:5}},{table:`clawhub_promotion_claims`,kind:`primaryKey`,value:[`slug`]},{table:`clawhub_promotion_claims`,kind:`indexes`,value:1},{table:`clawhub_promotion_claims`,kind:`checks`,value:0},{table:`config_health_entries`,kind:`table`,value:null},{table:`config_health_entries`,kind:`column`,value:{name:`config_path`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`config_health_entries`,kind:`column`,value:{name:`last_known_good_json`,type:`text`,nullable:!0,identity:!1,default:null,position:2}},{table:`config_health_entries`,kind:`column`,value:{name:`last_promoted_good_json`,type:`text`,nullable:!0,identity:!1,default:null,position:3}},{table:`config_health_entries`,kind:`column`,value:{name:`last_observed_suspicious_signature`,type:`text`,nullable:!0,identity:!1,default:null,position:4}},{table:`config_health_entries`,kind:`column`,value:{name:`updated_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:5}},{table:`config_health_entries`,kind:`primaryKey`,value:[`config_path`]},{table:`config_health_entries`,kind:`indexes`,value:1},{table:`config_health_entries`,kind:`checks`,value:0},{table:`config_machine_state`,kind:`table`,value:null},{table:`config_machine_state`,kind:`column`,value:{name:`state_key`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`config_machine_state`,kind:`column`,value:{name:`value_json`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`config_machine_state`,kind:`column`,value:{name:`updated_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:3}},{table:`config_machine_state`,kind:`primaryKey`,value:[`state_key`]},{table:`config_machine_state`,kind:`indexes`,value:1},{table:`config_machine_state`,kind:`checks`,value:0},{table:`config_revision_keys`,kind:`table`,value:null},{table:`config_revision_keys`,kind:`column`,value:{name:`id`,type:`bigint`,nullable:!1,identity:!0,default:null,position:1}},{table:`config_revision_keys`,kind:`column`,value:{name:`hmac_key`,type:`bytea`,nullable:!1,identity:!1,default:null,position:2}},{table:`config_revision_keys`,kind:`primaryKey`,value:[`id`]},{table:`config_revision_keys`,kind:`indexes`,value:1},{table:`config_revision_keys`,kind:`checks`,value:2},{table:`cron_job_runtime_authorities`,kind:`table`,value:null},{table:`cron_job_runtime_authorities`,kind:`column`,value:{name:`store_key`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`cron_job_runtime_authorities`,kind:`column`,value:{name:`job_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`cron_job_runtime_authorities`,kind:`column`,value:{name:`authority_json`,type:`text`,nullable:!0,identity:!1,default:null,position:3}},{table:`cron_job_runtime_authorities`,kind:`column`,value:{name:`authority_input_fingerprint`,type:`text`,nullable:!0,identity:!1,default:null,position:4}},{table:`cron_job_runtime_authorities`,kind:`column`,value:{name:`recovery_required`,type:`bigint`,nullable:!1,identity:!1,default:null,position:5}},{table:`cron_job_runtime_authorities`,kind:`primaryKey`,value:[`store_key`,`job_id`]},{table:`cron_job_runtime_authorities`,kind:`foreignKey`,value:{columns:[`store_key`,`job_id`],target:`cron_jobs`,targetColumns:[`store_key`,`job_id`],onUpdate:`NO ACTION`,onDelete:`CASCADE`,deferrable:!1,deferred:!1}},{table:`cron_job_runtime_authorities`,kind:`indexes`,value:1},{table:`cron_job_runtime_authorities`,kind:`checks`,value:2},{table:`cron_job_scratch`,kind:`table`,value:null},{table:`cron_job_scratch`,kind:`column`,value:{name:`store_key`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`cron_job_scratch`,kind:`column`,value:{name:`job_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`cron_job_scratch`,kind:`column`,value:{name:`content`,type:`text`,nullable:!0,identity:!1,default:null,position:3}},{table:`cron_job_scratch`,kind:`column`,value:{name:`revision`,type:`bigint`,nullable:!1,identity:!1,default:null,position:4}},{table:`cron_job_scratch`,kind:`column`,value:{name:`source_sha256`,type:`text`,nullable:!0,identity:!1,default:null,position:5}},{table:`cron_job_scratch`,kind:`column`,value:{name:`updated_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:6}},{table:`cron_job_scratch`,kind:`primaryKey`,value:[`store_key`,`job_id`]},{table:`cron_job_scratch`,kind:`indexes`,value:2},{table:`cron_job_scratch`,kind:`checks`,value:2},{table:`cron_jobs`,kind:`table`,value:null},{table:`cron_jobs`,kind:`column`,value:{name:`store_key`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`cron_jobs`,kind:`column`,value:{name:`job_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`cron_jobs`,kind:`column`,value:{name:`declaration_key`,type:`text`,nullable:!0,identity:!1,default:null,position:3}},{table:`cron_jobs`,kind:`column`,value:{name:`owner_agent_id`,type:`text`,nullable:!0,identity:!1,default:null,position:4}},{table:`cron_jobs`,kind:`column`,value:{name:`name`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`cron_jobs`,kind:`column`,value:{name:`description`,type:`text`,nullable:!0,identity:!1,default:null,position:6}},{table:`cron_jobs`,kind:`column`,value:{name:`enabled`,type:`bigint`,nullable:!1,identity:!1,default:null,position:7}},{table:`cron_jobs`,kind:`column`,value:{name:`agent_id`,type:`text`,nullable:!0,identity:!1,default:null,position:8}},{table:`cron_jobs`,kind:`column`,value:{name:`payload_kind`,type:`text`,nullable:!1,identity:!1,default:null,position:9}},{table:`cron_jobs`,kind:`column`,value:{name:`job_json`,type:`text`,nullable:!1,identity:!1,default:null,position:10}},{table:`cron_jobs`,kind:`column`,value:{name:`grant_definition_revision`,type:`text`,nullable:!0,identity:!1,default:null,position:11}},{table:`cron_jobs`,kind:`column`,value:{name:`grant_definition_generation`,type:`bigint`,nullable:!0,identity:!1,default:null,position:12}},{table:`cron_jobs`,kind:`column`,value:{name:`grant_definition_updated_at`,type:`bigint`,nullable:!0,identity:!1,default:null,position:13}},{table:`cron_jobs`,kind:`column`,value:{name:`state_json`,type:`text`,nullable:!1,identity:!1,default:`'{}'`,position:14}},{table:`cron_jobs`,kind:`column`,value:{name:`runtime_updated_at_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:15}},{table:`cron_jobs`,kind:`column`,value:{name:`schedule_identity`,type:`text`,nullable:!0,identity:!1,default:null,position:16}},{table:`cron_jobs`,kind:`column`,value:{name:`sort_order`,type:`bigint`,nullable:!1,identity:!1,default:`0`,position:17}},{table:`cron_jobs`,kind:`column`,value:{name:`updated_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:18}},{table:`cron_jobs`,kind:`primaryKey`,value:[`store_key`,`job_id`]},{table:`cron_jobs`,kind:`indexes`,value:2},{table:`cron_jobs`,kind:`checks`,value:0},{table:`cron_run_receipts`,kind:`table`,value:null},{table:`cron_run_receipts`,kind:`column`,value:{name:`cursor_id`,type:`bigint`,nullable:!1,identity:!1,default:null,position:1}},{table:`cron_run_receipts`,kind:`column`,value:{name:`receipt_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`cron_run_receipts`,kind:`column`,value:{name:`store_key`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`cron_run_receipts`,kind:`column`,value:{name:`job_id`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`cron_run_receipts`,kind:`column`,value:{name:`config_revision`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`cron_run_receipts`,kind:`column`,value:{name:`agent_id`,type:`text`,nullable:!1,identity:!1,default:null,position:6}},{table:`cron_run_receipts`,kind:`column`,value:{name:`request_run_id`,type:`text`,nullable:!0,identity:!1,default:null,position:7}},{table:`cron_run_receipts`,kind:`column`,value:{name:`delivery_attempt_state`,type:`text`,nullable:!1,identity:!1,default:`'unknown'`,position:8}},{table:`cron_run_receipts`,kind:`column`,value:{name:`status`,type:`text`,nullable:!1,identity:!1,default:null,position:9}},{table:`cron_run_receipts`,kind:`column`,value:{name:`owner_pid`,type:`bigint`,nullable:!1,identity:!1,default:null,position:10}},{table:`cron_run_receipts`,kind:`column`,value:{name:`owner_start_time`,type:`bigint`,nullable:!0,identity:!1,default:null,position:11}},{table:`cron_run_receipts`,kind:`column`,value:{name:`started_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:12}},{table:`cron_run_receipts`,kind:`column`,value:{name:`finished_at_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:13}},{table:`cron_run_receipts`,kind:`column`,value:{name:`error_text`,type:`text`,nullable:!0,identity:!1,default:null,position:14}},{table:`cron_run_receipts`,kind:`primaryKey`,value:[`receipt_id`]},{table:`cron_run_receipts`,kind:`indexes`,value:4},{table:`cron_run_receipts`,kind:`checks`,value:3},{table:`cron_run_trigger_state_retirements`,kind:`table`,value:null},{table:`cron_run_trigger_state_retirements`,kind:`column`,value:{name:`receipt_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`cron_run_trigger_state_retirements`,kind:`primaryKey`,value:[`receipt_id`]},{table:`cron_run_trigger_state_retirements`,kind:`foreignKey`,value:{columns:[`receipt_id`],target:`cron_run_receipts`,targetColumns:[`receipt_id`],onUpdate:`NO ACTION`,onDelete:`CASCADE`,deferrable:!1,deferred:!1}},{table:`cron_run_trigger_state_retirements`,kind:`indexes`,value:1},{table:`cron_run_trigger_state_retirements`,kind:`checks`,value:0},{table:`current_conversation_bindings`,kind:`table`,value:null},{table:`current_conversation_bindings`,kind:`column`,value:{name:`binding_key`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`current_conversation_bindings`,kind:`column`,value:{name:`binding_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`current_conversation_bindings`,kind:`column`,value:{name:`target_session_key`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`current_conversation_bindings`,kind:`column`,value:{name:`channel`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`current_conversation_bindings`,kind:`column`,value:{name:`account_id`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`current_conversation_bindings`,kind:`column`,value:{name:`conversation_kind`,type:`text`,nullable:!1,identity:!1,default:null,position:6}},{table:`current_conversation_bindings`,kind:`column`,value:{name:`parent_conversation_id`,type:`text`,nullable:!0,identity:!1,default:null,position:7}},{table:`current_conversation_bindings`,kind:`column`,value:{name:`conversation_id`,type:`text`,nullable:!1,identity:!1,default:null,position:8}},{table:`current_conversation_bindings`,kind:`column`,value:{name:`target_kind`,type:`text`,nullable:!1,identity:!1,default:null,position:9}},{table:`current_conversation_bindings`,kind:`column`,value:{name:`status`,type:`text`,nullable:!1,identity:!1,default:null,position:10}},{table:`current_conversation_bindings`,kind:`column`,value:{name:`bound_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:11}},{table:`current_conversation_bindings`,kind:`column`,value:{name:`expires_at`,type:`bigint`,nullable:!0,identity:!1,default:null,position:12}},{table:`current_conversation_bindings`,kind:`column`,value:{name:`metadata_json`,type:`text`,nullable:!0,identity:!1,default:null,position:13}},{table:`current_conversation_bindings`,kind:`column`,value:{name:`record_json`,type:`text`,nullable:!1,identity:!1,default:null,position:14}},{table:`current_conversation_bindings`,kind:`column`,value:{name:`updated_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:15}},{table:`current_conversation_bindings`,kind:`primaryKey`,value:[`binding_key`]},{table:`current_conversation_bindings`,kind:`indexes`,value:4},{table:`current_conversation_bindings`,kind:`checks`,value:0},{table:`delivery_queue_entries`,kind:`table`,value:null},{table:`delivery_queue_entries`,kind:`column`,value:{name:`queue_name`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`delivery_queue_entries`,kind:`column`,value:{name:`id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`delivery_queue_entries`,kind:`column`,value:{name:`status`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`delivery_queue_entries`,kind:`column`,value:{name:`entry_kind`,type:`text`,nullable:!0,identity:!1,default:null,position:4}},{table:`delivery_queue_entries`,kind:`column`,value:{name:`session_key`,type:`text`,nullable:!0,identity:!1,default:null,position:5}},{table:`delivery_queue_entries`,kind:`column`,value:{name:`channel`,type:`text`,nullable:!0,identity:!1,default:null,position:6}},{table:`delivery_queue_entries`,kind:`column`,value:{name:`target`,type:`text`,nullable:!0,identity:!1,default:null,position:7}},{table:`delivery_queue_entries`,kind:`column`,value:{name:`account_id`,type:`text`,nullable:!0,identity:!1,default:null,position:8}},{table:`delivery_queue_entries`,kind:`column`,value:{name:`retry_count`,type:`bigint`,nullable:!1,identity:!1,default:`0`,position:9}},{table:`delivery_queue_entries`,kind:`column`,value:{name:`last_attempt_at`,type:`bigint`,nullable:!0,identity:!1,default:null,position:10}},{table:`delivery_queue_entries`,kind:`column`,value:{name:`last_error`,type:`text`,nullable:!0,identity:!1,default:null,position:11}},{table:`delivery_queue_entries`,kind:`column`,value:{name:`recovery_state`,type:`text`,nullable:!0,identity:!1,default:null,position:12}},{table:`delivery_queue_entries`,kind:`column`,value:{name:`platform_send_started_at`,type:`bigint`,nullable:!0,identity:!1,default:null,position:13}},{table:`delivery_queue_entries`,kind:`column`,value:{name:`entry_json`,type:`text`,nullable:!1,identity:!1,default:null,position:14}},{table:`delivery_queue_entries`,kind:`column`,value:{name:`retention_id_prefix`,type:`text`,nullable:!0,identity:!1,default:null,position:15}},{table:`delivery_queue_entries`,kind:`column`,value:{name:`retention_max_age_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:16}},{table:`delivery_queue_entries`,kind:`column`,value:{name:`retention_max_entries`,type:`bigint`,nullable:!0,identity:!1,default:null,position:17}},{table:`delivery_queue_entries`,kind:`column`,value:{name:`enqueued_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:18}},{table:`delivery_queue_entries`,kind:`column`,value:{name:`updated_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:19}},{table:`delivery_queue_entries`,kind:`column`,value:{name:`failed_at`,type:`bigint`,nullable:!0,identity:!1,default:null,position:20}},{table:`delivery_queue_entries`,kind:`primaryKey`,value:[`queue_name`,`id`]},{table:`delivery_queue_entries`,kind:`indexes`,value:6},{table:`delivery_queue_entries`,kind:`checks`,value:0},{table:`device_bootstrap_tokens`,kind:`table`,value:null},{table:`device_bootstrap_tokens`,kind:`column`,value:{name:`token_key`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`device_bootstrap_tokens`,kind:`column`,value:{name:`token`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`device_bootstrap_tokens`,kind:`column`,value:{name:`setup_id`,type:`text`,nullable:!0,identity:!1,default:null,position:3}},{table:`device_bootstrap_tokens`,kind:`column`,value:{name:`ts`,type:`bigint`,nullable:!1,identity:!1,default:null,position:4}},{table:`device_bootstrap_tokens`,kind:`column`,value:{name:`device_id`,type:`text`,nullable:!0,identity:!1,default:null,position:5}},{table:`device_bootstrap_tokens`,kind:`column`,value:{name:`public_key`,type:`text`,nullable:!0,identity:!1,default:null,position:6}},{table:`device_bootstrap_tokens`,kind:`column`,value:{name:`profile_json`,type:`text`,nullable:!0,identity:!1,default:null,position:7}},{table:`device_bootstrap_tokens`,kind:`column`,value:{name:`redeemed_profile_json`,type:`text`,nullable:!0,identity:!1,default:null,position:8}},{table:`device_bootstrap_tokens`,kind:`column`,value:{name:`pending_profile_json`,type:`text`,nullable:!0,identity:!1,default:null,position:9}},{table:`device_bootstrap_tokens`,kind:`column`,value:{name:`issued_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:10}},{table:`device_bootstrap_tokens`,kind:`column`,value:{name:`last_used_at_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:11}},{table:`device_bootstrap_tokens`,kind:`primaryKey`,value:[`token_key`]},{table:`device_bootstrap_tokens`,kind:`indexes`,value:2},{table:`device_bootstrap_tokens`,kind:`checks`,value:0},{table:`device_pair_setup_completions`,kind:`table`,value:null},{table:`device_pair_setup_completions`,kind:`column`,value:{name:`setup_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`device_pair_setup_completions`,kind:`column`,value:{name:`device_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`device_pair_setup_completions`,kind:`column`,value:{name:`device_name`,type:`text`,nullable:!0,identity:!1,default:null,position:3}},{table:`device_pair_setup_completions`,kind:`column`,value:{name:`access`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`device_pair_setup_completions`,kind:`column`,value:{name:`completed_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:5}},{table:`device_pair_setup_completions`,kind:`column`,value:{name:`delivery_state`,type:`text`,nullable:!1,identity:!1,default:null,position:6}},{table:`device_pair_setup_completions`,kind:`column`,value:{name:`retain_until_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:7}},{table:`device_pair_setup_completions`,kind:`primaryKey`,value:[`setup_id`]},{table:`device_pair_setup_completions`,kind:`indexes`,value:1},{table:`device_pair_setup_completions`,kind:`checks`,value:1},{table:`device_pairing_browser_requests`,kind:`table`,value:null},{table:`device_pairing_browser_requests`,kind:`column`,value:{name:`request_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`device_pairing_browser_requests`,kind:`column`,value:{name:`code`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`device_pairing_browser_requests`,kind:`column`,value:{name:`device_id`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`device_pairing_browser_requests`,kind:`column`,value:{name:`public_key`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`device_pairing_browser_requests`,kind:`column`,value:{name:`remote_ip`,type:`text`,nullable:!0,identity:!1,default:null,position:5}},{table:`device_pairing_browser_requests`,kind:`column`,value:{name:`user_agent`,type:`text`,nullable:!0,identity:!1,default:null,position:6}},{table:`device_pairing_browser_requests`,kind:`column`,value:{name:`origin`,type:`text`,nullable:!0,identity:!1,default:null,position:7}},{table:`device_pairing_browser_requests`,kind:`column`,value:{name:`status`,type:`text`,nullable:!1,identity:!1,default:null,position:8}},{table:`device_pairing_browser_requests`,kind:`column`,value:{name:`approved_token_sha256`,type:`text`,nullable:!0,identity:!1,default:null,position:9}},{table:`device_pairing_browser_requests`,kind:`column`,value:{name:`created_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:10}},{table:`device_pairing_browser_requests`,kind:`column`,value:{name:`expires_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:11}},{table:`device_pairing_browser_requests`,kind:`primaryKey`,value:[`request_id`]},{table:`device_pairing_browser_requests`,kind:`unique`,value:[`code`]},{table:`device_pairing_browser_requests`,kind:`unique`,value:[`device_id`]},{table:`device_pairing_browser_requests`,kind:`indexes`,value:3},{table:`device_pairing_browser_requests`,kind:`checks`,value:1},{table:`device_pairing_join_codes`,kind:`table`,value:null},{table:`device_pairing_join_codes`,kind:`column`,value:{name:`shortcode`,type:`text`,nullable:!0,identity:!1,default:null,position:1}},{table:`device_pairing_join_codes`,kind:`column`,value:{name:`payload_json`,type:`text`,nullable:!0,identity:!1,default:null,position:2}},{table:`device_pairing_join_codes`,kind:`column`,value:{name:`created_at_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:3}},{table:`device_pairing_join_codes`,kind:`column`,value:{name:`expires_at_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:4}},{table:`device_pairing_join_codes`,kind:`indexes`,value:0},{table:`device_pairing_join_codes`,kind:`checks`,value:0},{table:`device_pairing_paired`,kind:`table`,value:null},{table:`device_pairing_paired`,kind:`column`,value:{name:`device_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`device_pairing_paired`,kind:`column`,value:{name:`public_key`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`device_pairing_paired`,kind:`column`,value:{name:`display_name`,type:`text`,nullable:!0,identity:!1,default:null,position:3}},{table:`device_pairing_paired`,kind:`column`,value:{name:`operator_label`,type:`text`,nullable:!0,identity:!1,default:null,position:4}},{table:`device_pairing_paired`,kind:`column`,value:{name:`platform`,type:`text`,nullable:!0,identity:!1,default:null,position:5}},{table:`device_pairing_paired`,kind:`column`,value:{name:`device_family`,type:`text`,nullable:!0,identity:!1,default:null,position:6}},{table:`device_pairing_paired`,kind:`column`,value:{name:`client_id`,type:`text`,nullable:!0,identity:!1,default:null,position:7}},{table:`device_pairing_paired`,kind:`column`,value:{name:`client_mode`,type:`text`,nullable:!0,identity:!1,default:null,position:8}},{table:`device_pairing_paired`,kind:`column`,value:{name:`browser_origin`,type:`text`,nullable:!0,identity:!1,default:null,position:9}},{table:`device_pairing_paired`,kind:`column`,value:{name:`role`,type:`text`,nullable:!0,identity:!1,default:null,position:10}},{table:`device_pairing_paired`,kind:`column`,value:{name:`roles_json`,type:`text`,nullable:!0,identity:!1,default:null,position:11}},{table:`device_pairing_paired`,kind:`column`,value:{name:`scopes_json`,type:`text`,nullable:!0,identity:!1,default:null,position:12}},{table:`device_pairing_paired`,kind:`column`,value:{name:`approved_scopes_json`,type:`text`,nullable:!0,identity:!1,default:null,position:13}},{table:`device_pairing_paired`,kind:`column`,value:{name:`remote_ip`,type:`text`,nullable:!0,identity:!1,default:null,position:14}},{table:`device_pairing_paired`,kind:`column`,value:{name:`tokens_json`,type:`text`,nullable:!0,identity:!1,default:null,position:15}},{table:`device_pairing_paired`,kind:`column`,value:{name:`approved_via`,type:`text`,nullable:!0,identity:!1,default:null,position:16}},{table:`device_pairing_paired`,kind:`column`,value:{name:`node_surface_json`,type:`text`,nullable:!0,identity:!1,default:null,position:17}},{table:`device_pairing_paired`,kind:`column`,value:{name:`pending_node_surface_json`,type:`text`,nullable:!0,identity:!1,default:null,position:18}},{table:`device_pairing_paired`,kind:`column`,value:{name:`created_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:19}},{table:`device_pairing_paired`,kind:`column`,value:{name:`approved_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:20}},{table:`device_pairing_paired`,kind:`column`,value:{name:`last_seen_at_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:21}},{table:`device_pairing_paired`,kind:`column`,value:{name:`last_seen_reason`,type:`text`,nullable:!0,identity:!1,default:null,position:22}},{table:`device_pairing_paired`,kind:`primaryKey`,value:[`device_id`]},{table:`device_pairing_paired`,kind:`indexes`,value:2},{table:`device_pairing_paired`,kind:`checks`,value:0},{table:`device_pairing_pending`,kind:`table`,value:null},{table:`device_pairing_pending`,kind:`column`,value:{name:`request_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`device_pairing_pending`,kind:`column`,value:{name:`device_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`device_pairing_pending`,kind:`column`,value:{name:`public_key`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`device_pairing_pending`,kind:`column`,value:{name:`display_name`,type:`text`,nullable:!0,identity:!1,default:null,position:4}},{table:`device_pairing_pending`,kind:`column`,value:{name:`platform`,type:`text`,nullable:!0,identity:!1,default:null,position:5}},{table:`device_pairing_pending`,kind:`column`,value:{name:`device_family`,type:`text`,nullable:!0,identity:!1,default:null,position:6}},{table:`device_pairing_pending`,kind:`column`,value:{name:`client_id`,type:`text`,nullable:!0,identity:!1,default:null,position:7}},{table:`device_pairing_pending`,kind:`column`,value:{name:`client_mode`,type:`text`,nullable:!0,identity:!1,default:null,position:8}},{table:`device_pairing_pending`,kind:`column`,value:{name:`browser_origin`,type:`text`,nullable:!0,identity:!1,default:null,position:9}},{table:`device_pairing_pending`,kind:`column`,value:{name:`role`,type:`text`,nullable:!0,identity:!1,default:null,position:10}},{table:`device_pairing_pending`,kind:`column`,value:{name:`roles_json`,type:`text`,nullable:!0,identity:!1,default:null,position:11}},{table:`device_pairing_pending`,kind:`column`,value:{name:`scopes_json`,type:`text`,nullable:!0,identity:!1,default:null,position:12}},{table:`device_pairing_pending`,kind:`column`,value:{name:`remote_ip`,type:`text`,nullable:!0,identity:!1,default:null,position:13}},{table:`device_pairing_pending`,kind:`column`,value:{name:`silent`,type:`bigint`,nullable:!0,identity:!1,default:null,position:14}},{table:`device_pairing_pending`,kind:`column`,value:{name:`is_repair`,type:`bigint`,nullable:!0,identity:!1,default:null,position:15}},{table:`device_pairing_pending`,kind:`column`,value:{name:`ts`,type:`bigint`,nullable:!1,identity:!1,default:null,position:16}},{table:`device_pairing_pending`,kind:`column`,value:{name:`refreshed_at_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:17}},{table:`device_pairing_pending`,kind:`primaryKey`,value:[`request_id`]},{table:`device_pairing_pending`,kind:`indexes`,value:2},{table:`device_pairing_pending`,kind:`checks`,value:0},{table:`diagnostic_events`,kind:`table`,value:null},{table:`diagnostic_events`,kind:`column`,value:{name:`scope`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`diagnostic_events`,kind:`column`,value:{name:`event_key`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`diagnostic_events`,kind:`column`,value:{name:`payload_json`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`diagnostic_events`,kind:`column`,value:{name:`created_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:4}},{table:`diagnostic_events`,kind:`column`,value:{name:`sequence`,type:`bigint`,nullable:!1,identity:!1,default:`0`,position:5}},{table:`diagnostic_events`,kind:`primaryKey`,value:[`scope`,`event_key`]},{table:`diagnostic_events`,kind:`indexes`,value:2},{table:`diagnostic_events`,kind:`checks`,value:0},{table:`durable_background_processes`,kind:`table`,value:null},{table:`durable_background_processes`,kind:`column`,value:{name:`id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`durable_background_processes`,kind:`column`,value:{name:`record_json`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`durable_background_processes`,kind:`primaryKey`,value:[`id`]},{table:`durable_background_processes`,kind:`indexes`,value:1},{table:`durable_background_processes`,kind:`checks`,value:0},{table:`exec_approvals_config`,kind:`table`,value:null},{table:`exec_approvals_config`,kind:`column`,value:{name:`config_key`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`exec_approvals_config`,kind:`column`,value:{name:`raw_json`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`exec_approvals_config`,kind:`column`,value:{name:`socket_path`,type:`text`,nullable:!0,identity:!1,default:null,position:3}},{table:`exec_approvals_config`,kind:`column`,value:{name:`has_socket_token`,type:`bigint`,nullable:!1,identity:!1,default:null,position:4}},{table:`exec_approvals_config`,kind:`column`,value:{name:`default_security`,type:`text`,nullable:!0,identity:!1,default:null,position:5}},{table:`exec_approvals_config`,kind:`column`,value:{name:`default_ask`,type:`text`,nullable:!0,identity:!1,default:null,position:6}},{table:`exec_approvals_config`,kind:`column`,value:{name:`default_ask_fallback`,type:`text`,nullable:!0,identity:!1,default:null,position:7}},{table:`exec_approvals_config`,kind:`column`,value:{name:`auto_allow_skills`,type:`bigint`,nullable:!0,identity:!1,default:null,position:8}},{table:`exec_approvals_config`,kind:`column`,value:{name:`agent_count`,type:`bigint`,nullable:!1,identity:!1,default:null,position:9}},{table:`exec_approvals_config`,kind:`column`,value:{name:`allowlist_count`,type:`bigint`,nullable:!1,identity:!1,default:null,position:10}},{table:`exec_approvals_config`,kind:`column`,value:{name:`updated_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:11}},{table:`exec_approvals_config`,kind:`primaryKey`,value:[`config_key`]},{table:`exec_approvals_config`,kind:`indexes`,value:1},{table:`exec_approvals_config`,kind:`checks`,value:0},{table:`execution_decision_facts`,kind:`table`,value:null},{table:`execution_decision_facts`,kind:`column`,value:{name:`cursor_id`,type:`bigint`,nullable:!1,identity:!1,default:null,position:1}},{table:`execution_decision_facts`,kind:`column`,value:{name:`receipt_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`execution_decision_facts`,kind:`column`,value:{name:`context_id`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`execution_decision_facts`,kind:`column`,value:{name:`execution_id`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`execution_decision_facts`,kind:`column`,value:{name:`run_id`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`execution_decision_facts`,kind:`column`,value:{name:`action_id`,type:`text`,nullable:!0,identity:!1,default:null,position:6}},{table:`execution_decision_facts`,kind:`column`,value:{name:`action_family`,type:`text`,nullable:!1,identity:!1,default:null,position:7}},{table:`execution_decision_facts`,kind:`column`,value:{name:`decision_outcome`,type:`text`,nullable:!1,identity:!1,default:null,position:8}},{table:`execution_decision_facts`,kind:`column`,value:{name:`coverage_state`,type:`text`,nullable:!1,identity:!1,default:null,position:9}},{table:`execution_decision_facts`,kind:`column`,value:{name:`reason_code`,type:`text`,nullable:!1,identity:!1,default:null,position:10}},{table:`execution_decision_facts`,kind:`column`,value:{name:`owner`,type:`text`,nullable:!1,identity:!1,default:null,position:11}},{table:`execution_decision_facts`,kind:`column`,value:{name:`source_ref`,type:`text`,nullable:!1,identity:!1,default:null,position:12}},{table:`execution_decision_facts`,kind:`column`,value:{name:`occurred_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:13}},{table:`execution_decision_facts`,kind:`column`,value:{name:`receipt_bytes`,type:`bigint`,nullable:!1,identity:!1,default:null,position:14}},{table:`execution_decision_facts`,kind:`column`,value:{name:`receipt_json`,type:`text`,nullable:!1,identity:!1,default:null,position:15}},{table:`execution_decision_facts`,kind:`primaryKey`,value:[`receipt_id`]},{table:`execution_decision_facts`,kind:`unique`,value:[`occurred_at`,`receipt_id`]},{table:`execution_decision_facts`,kind:`indexes`,value:5},{table:`execution_decision_facts`,kind:`checks`,value:14},{table:`execution_identity_contexts`,kind:`table`,value:null},{table:`execution_identity_contexts`,kind:`column`,value:{name:`context_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`execution_identity_contexts`,kind:`column`,value:{name:`execution_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`execution_identity_contexts`,kind:`column`,value:{name:`run_id`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`execution_identity_contexts`,kind:`column`,value:{name:`created_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:4}},{table:`execution_identity_contexts`,kind:`column`,value:{name:`coverage_state`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`execution_identity_contexts`,kind:`column`,value:{name:`context_bytes`,type:`bigint`,nullable:!1,identity:!1,default:null,position:6}},{table:`execution_identity_contexts`,kind:`column`,value:{name:`context_json`,type:`text`,nullable:!1,identity:!1,default:null,position:7}},{table:`execution_identity_contexts`,kind:`primaryKey`,value:[`context_id`]},{table:`execution_identity_contexts`,kind:`unique`,value:[`execution_id`]},{table:`execution_identity_contexts`,kind:`unique`,value:[`created_at`,`context_id`]},{table:`execution_identity_contexts`,kind:`indexes`,value:4},{table:`execution_identity_contexts`,kind:`checks`,value:7},{table:`execution_owner_lifecycle_bindings`,kind:`table`,value:null},{table:`execution_owner_lifecycle_bindings`,kind:`column`,value:{name:`owner_kind`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`execution_owner_lifecycle_bindings`,kind:`column`,value:{name:`owner_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`execution_owner_lifecycle_bindings`,kind:`column`,value:{name:`context_id`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`execution_owner_lifecycle_bindings`,kind:`column`,value:{name:`execution_id`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`execution_owner_lifecycle_bindings`,kind:`primaryKey`,value:[`owner_kind`,`owner_id`]},{table:`execution_owner_lifecycle_bindings`,kind:`indexes`,value:1},{table:`execution_owner_lifecycle_bindings`,kind:`checks`,value:0},{table:`flow_runs`,kind:`table`,value:null},{table:`flow_runs`,kind:`column`,value:{name:`flow_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`flow_runs`,kind:`column`,value:{name:`shape`,type:`text`,nullable:!0,identity:!1,default:null,position:2}},{table:`flow_runs`,kind:`column`,value:{name:`sync_mode`,type:`text`,nullable:!1,identity:!1,default:`'managed'`,position:3}},{table:`flow_runs`,kind:`column`,value:{name:`owner_key`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`flow_runs`,kind:`column`,value:{name:`requester_origin_json`,type:`text`,nullable:!0,identity:!1,default:null,position:5}},{table:`flow_runs`,kind:`column`,value:{name:`controller_id`,type:`text`,nullable:!0,identity:!1,default:null,position:6}},{table:`flow_runs`,kind:`column`,value:{name:`revision`,type:`bigint`,nullable:!1,identity:!1,default:`0`,position:7}},{table:`flow_runs`,kind:`column`,value:{name:`status`,type:`text`,nullable:!1,identity:!1,default:null,position:8}},{table:`flow_runs`,kind:`column`,value:{name:`notify_policy`,type:`text`,nullable:!1,identity:!1,default:null,position:9}},{table:`flow_runs`,kind:`column`,value:{name:`goal`,type:`text`,nullable:!1,identity:!1,default:null,position:10}},{table:`flow_runs`,kind:`column`,value:{name:`current_step`,type:`text`,nullable:!0,identity:!1,default:null,position:11}},{table:`flow_runs`,kind:`column`,value:{name:`blocked_task_id`,type:`text`,nullable:!0,identity:!1,default:null,position:12}},{table:`flow_runs`,kind:`column`,value:{name:`blocked_summary`,type:`text`,nullable:!0,identity:!1,default:null,position:13}},{table:`flow_runs`,kind:`column`,value:{name:`state_json`,type:`text`,nullable:!0,identity:!1,default:null,position:14}},{table:`flow_runs`,kind:`column`,value:{name:`wait_json`,type:`text`,nullable:!0,identity:!1,default:null,position:15}},{table:`flow_runs`,kind:`column`,value:{name:`cancel_requested_at`,type:`bigint`,nullable:!0,identity:!1,default:null,position:16}},{table:`flow_runs`,kind:`column`,value:{name:`created_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:17}},{table:`flow_runs`,kind:`column`,value:{name:`updated_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:18}},{table:`flow_runs`,kind:`column`,value:{name:`ended_at`,type:`bigint`,nullable:!0,identity:!1,default:null,position:19}},{table:`flow_runs`,kind:`primaryKey`,value:[`flow_id`]},{table:`flow_runs`,kind:`indexes`,value:4},{table:`flow_runs`,kind:`checks`,value:0},{table:`gateway_boot_lifecycle`,kind:`table`,value:null},{table:`gateway_boot_lifecycle`,kind:`column`,value:{name:`boot_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`gateway_boot_lifecycle`,kind:`column`,value:{name:`pid`,type:`bigint`,nullable:!1,identity:!1,default:null,position:2}},{table:`gateway_boot_lifecycle`,kind:`column`,value:{name:`started_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:3}},{table:`gateway_boot_lifecycle`,kind:`column`,value:{name:`completed_at_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:4}},{table:`gateway_boot_lifecycle`,kind:`column`,value:{name:`outcome`,type:`text`,nullable:!0,identity:!1,default:null,position:5}},{table:`gateway_boot_lifecycle`,kind:`column`,value:{name:`startup_reason`,type:`text`,nullable:!0,identity:!1,default:null,position:6}},{table:`gateway_boot_lifecycle`,kind:`column`,value:{name:`reason`,type:`text`,nullable:!0,identity:!1,default:null,position:7}},{table:`gateway_boot_lifecycle`,kind:`primaryKey`,value:[`boot_id`]},{table:`gateway_boot_lifecycle`,kind:`indexes`,value:2},{table:`gateway_boot_lifecycle`,kind:`checks`,value:0},{table:`gateway_restart_handoff`,kind:`table`,value:null},{table:`gateway_restart_handoff`,kind:`column`,value:{name:`handoff_key`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`gateway_restart_handoff`,kind:`column`,value:{name:`kind`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`gateway_restart_handoff`,kind:`column`,value:{name:`version`,type:`bigint`,nullable:!1,identity:!1,default:null,position:3}},{table:`gateway_restart_handoff`,kind:`column`,value:{name:`intent_id`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`gateway_restart_handoff`,kind:`column`,value:{name:`pid`,type:`bigint`,nullable:!1,identity:!1,default:null,position:5}},{table:`gateway_restart_handoff`,kind:`column`,value:{name:`process_instance_id`,type:`text`,nullable:!0,identity:!1,default:null,position:6}},{table:`gateway_restart_handoff`,kind:`column`,value:{name:`created_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:7}},{table:`gateway_restart_handoff`,kind:`column`,value:{name:`expires_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:8}},{table:`gateway_restart_handoff`,kind:`column`,value:{name:`reason`,type:`text`,nullable:!0,identity:!1,default:null,position:9}},{table:`gateway_restart_handoff`,kind:`column`,value:{name:`restart_trace_started_at`,type:`bigint`,nullable:!0,identity:!1,default:null,position:10}},{table:`gateway_restart_handoff`,kind:`column`,value:{name:`restart_trace_last_at`,type:`bigint`,nullable:!0,identity:!1,default:null,position:11}},{table:`gateway_restart_handoff`,kind:`column`,value:{name:`source`,type:`text`,nullable:!1,identity:!1,default:null,position:12}},{table:`gateway_restart_handoff`,kind:`column`,value:{name:`restart_kind`,type:`text`,nullable:!1,identity:!1,default:null,position:13}},{table:`gateway_restart_handoff`,kind:`column`,value:{name:`supervisor_mode`,type:`text`,nullable:!1,identity:!1,default:null,position:14}},{table:`gateway_restart_handoff`,kind:`column`,value:{name:`updated_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:15}},{table:`gateway_restart_handoff`,kind:`primaryKey`,value:[`handoff_key`]},{table:`gateway_restart_handoff`,kind:`indexes`,value:2},{table:`gateway_restart_handoff`,kind:`checks`,value:0},{table:`gateway_restart_intent`,kind:`table`,value:null},{table:`gateway_restart_intent`,kind:`column`,value:{name:`intent_key`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`gateway_restart_intent`,kind:`column`,value:{name:`kind`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`gateway_restart_intent`,kind:`column`,value:{name:`pid`,type:`bigint`,nullable:!1,identity:!1,default:null,position:3}},{table:`gateway_restart_intent`,kind:`column`,value:{name:`created_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:4}},{table:`gateway_restart_intent`,kind:`column`,value:{name:`reason`,type:`text`,nullable:!0,identity:!1,default:null,position:5}},{table:`gateway_restart_intent`,kind:`column`,value:{name:`force`,type:`bigint`,nullable:!0,identity:!1,default:null,position:6}},{table:`gateway_restart_intent`,kind:`column`,value:{name:`wait_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:7}},{table:`gateway_restart_intent`,kind:`column`,value:{name:`updated_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:8}},{table:`gateway_restart_intent`,kind:`primaryKey`,value:[`intent_key`]},{table:`gateway_restart_intent`,kind:`indexes`,value:1},{table:`gateway_restart_intent`,kind:`checks`,value:0},{table:`gateway_restart_sentinel`,kind:`table`,value:null},{table:`gateway_restart_sentinel`,kind:`column`,value:{name:`sentinel_key`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`gateway_restart_sentinel`,kind:`column`,value:{name:`version`,type:`bigint`,nullable:!1,identity:!1,default:null,position:2}},{table:`gateway_restart_sentinel`,kind:`column`,value:{name:`kind`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`gateway_restart_sentinel`,kind:`column`,value:{name:`status`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`gateway_restart_sentinel`,kind:`column`,value:{name:`ts`,type:`bigint`,nullable:!1,identity:!1,default:null,position:5}},{table:`gateway_restart_sentinel`,kind:`column`,value:{name:`session_key`,type:`text`,nullable:!0,identity:!1,default:null,position:6}},{table:`gateway_restart_sentinel`,kind:`column`,value:{name:`thread_id`,type:`text`,nullable:!0,identity:!1,default:null,position:7}},{table:`gateway_restart_sentinel`,kind:`column`,value:{name:`delivery_channel`,type:`text`,nullable:!0,identity:!1,default:null,position:8}},{table:`gateway_restart_sentinel`,kind:`column`,value:{name:`delivery_to`,type:`text`,nullable:!0,identity:!1,default:null,position:9}},{table:`gateway_restart_sentinel`,kind:`column`,value:{name:`delivery_account_id`,type:`text`,nullable:!0,identity:!1,default:null,position:10}},{table:`gateway_restart_sentinel`,kind:`column`,value:{name:`message`,type:`text`,nullable:!0,identity:!1,default:null,position:11}},{table:`gateway_restart_sentinel`,kind:`column`,value:{name:`continuation_json`,type:`text`,nullable:!0,identity:!1,default:null,position:12}},{table:`gateway_restart_sentinel`,kind:`column`,value:{name:`doctor_hint`,type:`text`,nullable:!0,identity:!1,default:null,position:13}},{table:`gateway_restart_sentinel`,kind:`column`,value:{name:`stats_json`,type:`text`,nullable:!0,identity:!1,default:null,position:14}},{table:`gateway_restart_sentinel`,kind:`column`,value:{name:`payload_json`,type:`text`,nullable:!1,identity:!1,default:null,position:15}},{table:`gateway_restart_sentinel`,kind:`column`,value:{name:`updated_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:16}},{table:`gateway_restart_sentinel`,kind:`primaryKey`,value:[`sentinel_key`]},{table:`gateway_restart_sentinel`,kind:`indexes`,value:2},{table:`gateway_restart_sentinel`,kind:`checks`,value:0},{table:`github_personal_publication_requests`,kind:`table`,value:null},{table:`github_personal_publication_requests`,kind:`column`,value:{name:`request_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`github_personal_publication_requests`,kind:`column`,value:{name:`owner_profile_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`github_personal_publication_requests`,kind:`column`,value:{name:`connection_generation`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`github_personal_publication_requests`,kind:`column`,value:{name:`idempotency_key`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`github_personal_publication_requests`,kind:`column`,value:{name:`request_digest`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`github_personal_publication_requests`,kind:`column`,value:{name:`session_id`,type:`text`,nullable:!1,identity:!1,default:null,position:6}},{table:`github_personal_publication_requests`,kind:`column`,value:{name:`session_key`,type:`text`,nullable:!1,identity:!1,default:null,position:7}},{table:`github_personal_publication_requests`,kind:`column`,value:{name:`agent_id`,type:`text`,nullable:!1,identity:!1,default:null,position:8}},{table:`github_personal_publication_requests`,kind:`column`,value:{name:`worktree_id`,type:`text`,nullable:!1,identity:!1,default:null,position:9}},{table:`github_personal_publication_requests`,kind:`column`,value:{name:`repository_fingerprint`,type:`text`,nullable:!1,identity:!1,default:null,position:10}},{table:`github_personal_publication_requests`,kind:`column`,value:{name:`identity_source`,type:`text`,nullable:!1,identity:!1,default:null,position:11}},{table:`github_personal_publication_requests`,kind:`column`,value:{name:`identity_profile_id`,type:`text`,nullable:!1,identity:!1,default:null,position:12}},{table:`github_personal_publication_requests`,kind:`column`,value:{name:`identity_account_id`,type:`bigint`,nullable:!1,identity:!1,default:null,position:13}},{table:`github_personal_publication_requests`,kind:`column`,value:{name:`identity_login`,type:`text`,nullable:!1,identity:!1,default:null,position:14}},{table:`github_personal_publication_requests`,kind:`column`,value:{name:`title`,type:`text`,nullable:!0,identity:!1,default:null,position:15}},{table:`github_personal_publication_requests`,kind:`column`,value:{name:`body`,type:`text`,nullable:!0,identity:!1,default:null,position:16}},{table:`github_personal_publication_requests`,kind:`column`,value:{name:`status`,type:`text`,nullable:!1,identity:!1,default:null,position:17}},{table:`github_personal_publication_requests`,kind:`column`,value:{name:`gateway_instance_id`,type:`text`,nullable:!0,identity:!1,default:null,position:18}},{table:`github_personal_publication_requests`,kind:`column`,value:{name:`execution_id`,type:`text`,nullable:!0,identity:!1,default:null,position:19}},{table:`github_personal_publication_requests`,kind:`column`,value:{name:`last_effect`,type:`text`,nullable:!0,identity:!1,default:null,position:20}},{table:`github_personal_publication_requests`,kind:`column`,value:{name:`effect_state`,type:`text`,nullable:!0,identity:!1,default:null,position:21}},{table:`github_personal_publication_requests`,kind:`column`,value:{name:`push_repository`,type:`text`,nullable:!1,identity:!1,default:null,position:22}},{table:`github_personal_publication_requests`,kind:`column`,value:{name:`repository`,type:`text`,nullable:!1,identity:!1,default:null,position:23}},{table:`github_personal_publication_requests`,kind:`column`,value:{name:`branch`,type:`text`,nullable:!1,identity:!1,default:null,position:24}},{table:`github_personal_publication_requests`,kind:`column`,value:{name:`base_branch`,type:`text`,nullable:!1,identity:!1,default:null,position:25}},{table:`github_personal_publication_requests`,kind:`column`,value:{name:`source_head_commit`,type:`text`,nullable:!1,identity:!1,default:null,position:26}},{table:`github_personal_publication_requests`,kind:`column`,value:{name:`source_index_tree`,type:`text`,nullable:!1,identity:!1,default:null,position:27}},{table:`github_personal_publication_requests`,kind:`column`,value:{name:`workspace_tree`,type:`text`,nullable:!1,identity:!1,default:null,position:28}},{table:`github_personal_publication_requests`,kind:`column`,value:{name:`head_commit`,type:`text`,nullable:!0,identity:!1,default:null,position:29}},{table:`github_personal_publication_requests`,kind:`column`,value:{name:`pull_request_url`,type:`text`,nullable:!0,identity:!1,default:null,position:30}},{table:`github_personal_publication_requests`,kind:`column`,value:{name:`error_code`,type:`text`,nullable:!0,identity:!1,default:null,position:31}},{table:`github_personal_publication_requests`,kind:`column`,value:{name:`next_action`,type:`text`,nullable:!0,identity:!1,default:null,position:32}},{table:`github_personal_publication_requests`,kind:`column`,value:{name:`created_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:33}},{table:`github_personal_publication_requests`,kind:`column`,value:{name:`updated_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:34}},{table:`github_personal_publication_requests`,kind:`column`,value:{name:`reported_at_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:35}},{table:`github_personal_publication_requests`,kind:`column`,value:{name:`draft`,type:`bigint`,nullable:!0,identity:!1,default:null,position:36}},{table:`github_personal_publication_requests`,kind:`primaryKey`,value:[`request_id`]},{table:`github_personal_publication_requests`,kind:`unique`,value:[`owner_profile_id`,`session_id`,`idempotency_key`]},{table:`github_personal_publication_requests`,kind:`indexes`,value:4},{table:`github_personal_publication_requests`,kind:`checks`,value:37},{table:`github_publication_requests`,kind:`table`,value:null},{table:`github_publication_requests`,kind:`column`,value:{name:`request_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`github_publication_requests`,kind:`column`,value:{name:`idempotency_key`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`github_publication_requests`,kind:`column`,value:{name:`request_digest`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`github_publication_requests`,kind:`column`,value:{name:`session_id`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`github_publication_requests`,kind:`column`,value:{name:`session_key`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`github_publication_requests`,kind:`column`,value:{name:`agent_id`,type:`text`,nullable:!1,identity:!1,default:null,position:6}},{table:`github_publication_requests`,kind:`column`,value:{name:`worktree_id`,type:`text`,nullable:!1,identity:!1,default:null,position:7}},{table:`github_publication_requests`,kind:`column`,value:{name:`repository_fingerprint`,type:`text`,nullable:!1,identity:!1,default:null,position:8}},{table:`github_publication_requests`,kind:`column`,value:{name:`claim_id`,type:`text`,nullable:!0,identity:!1,default:null,position:9}},{table:`github_publication_requests`,kind:`column`,value:{name:`run_id`,type:`text`,nullable:!0,identity:!1,default:null,position:10}},{table:`github_publication_requests`,kind:`column`,value:{name:`environment_id`,type:`text`,nullable:!0,identity:!1,default:null,position:11}},{table:`github_publication_requests`,kind:`column`,value:{name:`owner_epoch`,type:`bigint`,nullable:!0,identity:!1,default:null,position:12}},{table:`github_publication_requests`,kind:`column`,value:{name:`placement_generation`,type:`bigint`,nullable:!0,identity:!1,default:null,position:13}},{table:`github_publication_requests`,kind:`column`,value:{name:`identity_source`,type:`text`,nullable:!1,identity:!1,default:null,position:14}},{table:`github_publication_requests`,kind:`column`,value:{name:`identity_profile_id`,type:`text`,nullable:!0,identity:!1,default:null,position:15}},{table:`github_publication_requests`,kind:`column`,value:{name:`identity_account_id`,type:`bigint`,nullable:!1,identity:!1,default:null,position:16}},{table:`github_publication_requests`,kind:`column`,value:{name:`identity_login`,type:`text`,nullable:!1,identity:!1,default:null,position:17}},{table:`github_publication_requests`,kind:`column`,value:{name:`title`,type:`text`,nullable:!0,identity:!1,default:null,position:18}},{table:`github_publication_requests`,kind:`column`,value:{name:`body`,type:`text`,nullable:!0,identity:!1,default:null,position:19}},{table:`github_publication_requests`,kind:`column`,value:{name:`status`,type:`text`,nullable:!1,identity:!1,default:null,position:20}},{table:`github_publication_requests`,kind:`column`,value:{name:`gateway_instance_id`,type:`text`,nullable:!0,identity:!1,default:null,position:21}},{table:`github_publication_requests`,kind:`column`,value:{name:`repository`,type:`text`,nullable:!0,identity:!1,default:null,position:22}},{table:`github_publication_requests`,kind:`column`,value:{name:`branch`,type:`text`,nullable:!1,identity:!1,default:null,position:23}},{table:`github_publication_requests`,kind:`column`,value:{name:`base_branch`,type:`text`,nullable:!0,identity:!1,default:null,position:24}},{table:`github_publication_requests`,kind:`column`,value:{name:`source_head_commit`,type:`text`,nullable:!0,identity:!1,default:null,position:25}},{table:`github_publication_requests`,kind:`column`,value:{name:`source_index_tree`,type:`text`,nullable:!0,identity:!1,default:null,position:26}},{table:`github_publication_requests`,kind:`column`,value:{name:`workspace_tree`,type:`text`,nullable:!0,identity:!1,default:null,position:27}},{table:`github_publication_requests`,kind:`column`,value:{name:`head_commit`,type:`text`,nullable:!0,identity:!1,default:null,position:28}},{table:`github_publication_requests`,kind:`column`,value:{name:`pull_request_url`,type:`text`,nullable:!0,identity:!1,default:null,position:29}},{table:`github_publication_requests`,kind:`column`,value:{name:`error_code`,type:`text`,nullable:!0,identity:!1,default:null,position:30}},{table:`github_publication_requests`,kind:`column`,value:{name:`next_action`,type:`text`,nullable:!0,identity:!1,default:null,position:31}},{table:`github_publication_requests`,kind:`column`,value:{name:`created_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:32}},{table:`github_publication_requests`,kind:`column`,value:{name:`updated_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:33}},{table:`github_publication_requests`,kind:`column`,value:{name:`reported_at_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:34}},{table:`github_publication_requests`,kind:`column`,value:{name:`draft`,type:`bigint`,nullable:!0,identity:!1,default:null,position:35}},{table:`github_publication_requests`,kind:`primaryKey`,value:[`request_id`]},{table:`github_publication_requests`,kind:`unique`,value:[`session_id`,`idempotency_key`]},{table:`github_publication_requests`,kind:`indexes`,value:3},{table:`github_publication_requests`,kind:`checks`,value:9},{table:`github_publication_session_lifecycles`,kind:`table`,value:null},{table:`github_publication_session_lifecycles`,kind:`column`,value:{name:`publication_kind`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`github_publication_session_lifecycles`,kind:`column`,value:{name:`request_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`github_publication_session_lifecycles`,kind:`column`,value:{name:`lifecycle_revision`,type:`text`,nullable:!0,identity:!1,default:null,position:3}},{table:`github_publication_session_lifecycles`,kind:`column`,value:{name:`requester_authority_json`,type:`text`,nullable:!0,identity:!1,default:null,position:4}},{table:`github_publication_session_lifecycles`,kind:`primaryKey`,value:[`publication_kind`,`request_id`]},{table:`github_publication_session_lifecycles`,kind:`indexes`,value:1},{table:`github_publication_session_lifecycles`,kind:`checks`,value:1},{table:`github_repository_publication_requests`,kind:`table`,value:null},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`request_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`owner_profile_id`,type:`text`,nullable:!0,identity:!1,default:null,position:2}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`connection_generation`,type:`text`,nullable:!0,identity:!1,default:null,position:3}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`idempotency_key`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`request_digest`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`session_id`,type:`text`,nullable:!1,identity:!1,default:null,position:6}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`session_lifecycle_revision`,type:`text`,nullable:!0,identity:!1,default:null,position:7}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`requester_authority_json`,type:`text`,nullable:!0,identity:!1,default:null,position:8}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`session_key`,type:`text`,nullable:!1,identity:!1,default:null,position:9}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`agent_id`,type:`text`,nullable:!1,identity:!1,default:null,position:10}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`workspace_id`,type:`text`,nullable:!1,identity:!1,default:null,position:11}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`checkpoint_ref`,type:`text`,nullable:!0,identity:!1,default:null,position:12}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`checkpoint_digest`,type:`text`,nullable:!0,identity:!1,default:null,position:13}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`claim_id`,type:`text`,nullable:!0,identity:!1,default:null,position:14}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`run_id`,type:`text`,nullable:!0,identity:!1,default:null,position:15}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`environment_id`,type:`text`,nullable:!0,identity:!1,default:null,position:16}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`owner_epoch`,type:`bigint`,nullable:!0,identity:!1,default:null,position:17}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`placement_generation`,type:`bigint`,nullable:!0,identity:!1,default:null,position:18}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`identity_source`,type:`text`,nullable:!1,identity:!1,default:null,position:19}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`identity_profile_id`,type:`text`,nullable:!0,identity:!1,default:null,position:20}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`identity_account_id`,type:`bigint`,nullable:!1,identity:!1,default:null,position:21}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`identity_login`,type:`text`,nullable:!1,identity:!1,default:null,position:22}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`title`,type:`text`,nullable:!0,identity:!1,default:null,position:23}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`body`,type:`text`,nullable:!0,identity:!1,default:null,position:24}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`status`,type:`text`,nullable:!1,identity:!1,default:null,position:25}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`gateway_instance_id`,type:`text`,nullable:!0,identity:!1,default:null,position:26}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`execution_id`,type:`text`,nullable:!0,identity:!1,default:null,position:27}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`last_effect`,type:`text`,nullable:!0,identity:!1,default:null,position:28}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`effect_state`,type:`text`,nullable:!0,identity:!1,default:null,position:29}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`push_repository`,type:`text`,nullable:!0,identity:!1,default:null,position:30}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`repository`,type:`text`,nullable:!0,identity:!1,default:null,position:31}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`branch`,type:`text`,nullable:!1,identity:!1,default:null,position:32}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`base_branch`,type:`text`,nullable:!0,identity:!1,default:null,position:33}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`source_head_commit`,type:`text`,nullable:!0,identity:!1,default:null,position:34}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`source_index_tree`,type:`text`,nullable:!0,identity:!1,default:null,position:35}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`workspace_tree`,type:`text`,nullable:!0,identity:!1,default:null,position:36}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`previous_head_commit`,type:`text`,nullable:!0,identity:!1,default:null,position:37}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`pushed_head_commit`,type:`text`,nullable:!0,identity:!1,default:null,position:38}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`head_commit`,type:`text`,nullable:!0,identity:!1,default:null,position:39}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`pull_request_url`,type:`text`,nullable:!0,identity:!1,default:null,position:40}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`error_code`,type:`text`,nullable:!0,identity:!1,default:null,position:41}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`next_action`,type:`text`,nullable:!0,identity:!1,default:null,position:42}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`created_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:43}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`updated_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:44}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`reported_at_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:45}},{table:`github_repository_publication_requests`,kind:`column`,value:{name:`draft`,type:`bigint`,nullable:!0,identity:!1,default:null,position:46}},{table:`github_repository_publication_requests`,kind:`primaryKey`,value:[`request_id`]},{table:`github_repository_publication_requests`,kind:`indexes`,value:3},{table:`github_repository_publication_requests`,kind:`checks`,value:7},{table:`local_workspace_manifest_nodes`,kind:`table`,value:null},{table:`local_workspace_manifest_nodes`,kind:`column`,value:{name:`worktree_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`local_workspace_manifest_nodes`,kind:`column`,value:{name:`path`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`local_workspace_manifest_nodes`,kind:`column`,value:{name:`node_json`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`local_workspace_manifest_nodes`,kind:`primaryKey`,value:[`worktree_id`,`path`]},{table:`local_workspace_manifest_nodes`,kind:`foreignKey`,value:{columns:[`worktree_id`],target:`local_workspace_projections`,targetColumns:[`worktree_id`],onUpdate:`NO ACTION`,onDelete:`CASCADE`,deferrable:!1,deferred:!1}},{table:`local_workspace_manifest_nodes`,kind:`indexes`,value:1},{table:`local_workspace_manifest_nodes`,kind:`checks`,value:0},{table:`local_workspace_projections`,kind:`table`,value:null},{table:`local_workspace_projections`,kind:`column`,value:{name:`worktree_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`local_workspace_projections`,kind:`column`,value:{name:`agent_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`local_workspace_projections`,kind:`column`,value:{name:`session_key`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`local_workspace_projections`,kind:`column`,value:{name:`session_id`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`local_workspace_projections`,kind:`column`,value:{name:`lifecycle_revision`,type:`text`,nullable:!0,identity:!1,default:null,position:5}},{table:`local_workspace_projections`,kind:`column`,value:{name:`projection_path`,type:`text`,nullable:!1,identity:!1,default:null,position:6}},{table:`local_workspace_projections`,kind:`column`,value:{name:`base_commit`,type:`text`,nullable:!1,identity:!1,default:null,position:7}},{table:`local_workspace_projections`,kind:`column`,value:{name:`source_paths_json`,type:`text`,nullable:!1,identity:!1,default:null,position:8}},{table:`local_workspace_projections`,kind:`column`,value:{name:`baseline_json`,type:`text`,nullable:!0,identity:!1,default:null,position:9}},{table:`local_workspace_projections`,kind:`column`,value:{name:`baseline_ref`,type:`text`,nullable:!0,identity:!1,default:null,position:10}},{table:`local_workspace_projections`,kind:`column`,value:{name:`pending_ref`,type:`text`,nullable:!0,identity:!1,default:null,position:11}},{table:`local_workspace_projections`,kind:`column`,value:{name:`pending_target`,type:`text`,nullable:!0,identity:!1,default:null,position:12}},{table:`local_workspace_projections`,kind:`column`,value:{name:`paused_runtimes_json`,type:`text`,nullable:!0,identity:!1,default:null,position:13}},{table:`local_workspace_projections`,kind:`column`,value:{name:`journal_json`,type:`text`,nullable:!0,identity:!1,default:null,position:14}},{table:`local_workspace_projections`,kind:`column`,value:{name:`journal_pack`,type:`bytea`,nullable:!0,identity:!1,default:null,position:15}},{table:`local_workspace_projections`,kind:`column`,value:{name:`revision`,type:`bigint`,nullable:!1,identity:!1,default:`0`,position:16}},{table:`local_workspace_projections`,kind:`column`,value:{name:`created_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:17}},{table:`local_workspace_projections`,kind:`column`,value:{name:`checkpoint_json`,type:`text`,nullable:!0,identity:!1,default:null,position:18}},{table:`local_workspace_projections`,kind:`column`,value:{name:`tree_root_digest`,type:`bytea`,nullable:!0,identity:!1,default:null,position:19}},{table:`local_workspace_projections`,kind:`column`,value:{name:`source_paths_digest`,type:`bytea`,nullable:!0,identity:!1,default:null,position:20}},{table:`local_workspace_projections`,kind:`column`,value:{name:`canonical_fingerprints`,type:`bytea`,nullable:!0,identity:!1,default:null,position:21}},{table:`local_workspace_projections`,kind:`column`,value:{name:`projection_fingerprints`,type:`bytea`,nullable:!0,identity:!1,default:null,position:22}},{table:`local_workspace_projections`,kind:`primaryKey`,value:[`worktree_id`]},{table:`local_workspace_projections`,kind:`unique`,value:[`projection_path`]},{table:`local_workspace_projections`,kind:`indexes`,value:2},{table:`local_workspace_projections`,kind:`checks`,value:5},{table:`local_workspace_source_path_sets`,kind:`table`,value:null},{table:`local_workspace_source_path_sets`,kind:`column`,value:{name:`path_digest`,type:`bytea`,nullable:!1,identity:!1,default:null,position:1}},{table:`local_workspace_source_path_sets`,kind:`column`,value:{name:`paths_zstd`,type:`bytea`,nullable:!1,identity:!1,default:null,position:2}},{table:`local_workspace_source_path_sets`,kind:`column`,value:{name:`sweep_epoch`,type:`bigint`,nullable:!1,identity:!1,default:null,position:3}},{table:`local_workspace_source_path_sets`,kind:`primaryKey`,value:[`path_digest`]},{table:`local_workspace_source_path_sets`,kind:`indexes`,value:1},{table:`local_workspace_source_path_sets`,kind:`checks`,value:1},{table:`local_workspace_tree_packs`,kind:`table`,value:null},{table:`local_workspace_tree_packs`,kind:`column`,value:{name:`tree_digest`,type:`bytea`,nullable:!1,identity:!1,default:null,position:1}},{table:`local_workspace_tree_packs`,kind:`column`,value:{name:`records_json`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`local_workspace_tree_packs`,kind:`column`,value:{name:`children_json`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`local_workspace_tree_packs`,kind:`column`,value:{name:`sweep_epoch`,type:`bigint`,nullable:!1,identity:!1,default:null,position:4}},{table:`local_workspace_tree_packs`,kind:`primaryKey`,value:[`tree_digest`]},{table:`local_workspace_tree_packs`,kind:`indexes`,value:1},{table:`local_workspace_tree_packs`,kind:`checks`,value:1},{table:`macos_port_guardian_records`,kind:`table`,value:null},{table:`macos_port_guardian_records`,kind:`column`,value:{name:`pid`,type:`bigint`,nullable:!1,identity:!0,default:null,position:1}},{table:`macos_port_guardian_records`,kind:`column`,value:{name:`port`,type:`bigint`,nullable:!1,identity:!1,default:null,position:2}},{table:`macos_port_guardian_records`,kind:`column`,value:{name:`command`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`macos_port_guardian_records`,kind:`column`,value:{name:`mode`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`macos_port_guardian_records`,kind:`column`,value:{name:`timestamp`,type:`double precision`,nullable:!1,identity:!1,default:null,position:5}},{table:`macos_port_guardian_records`,kind:`primaryKey`,value:[`pid`]},{table:`macos_port_guardian_records`,kind:`indexes`,value:2},{table:`macos_port_guardian_records`,kind:`checks`,value:0},{table:`managed_outgoing_image_records`,kind:`table`,value:null},{table:`managed_outgoing_image_records`,kind:`column`,value:{name:`attachment_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`managed_outgoing_image_records`,kind:`column`,value:{name:`session_key`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`managed_outgoing_image_records`,kind:`column`,value:{name:`agent_id`,type:`text`,nullable:!0,identity:!1,default:null,position:3}},{table:`managed_outgoing_image_records`,kind:`column`,value:{name:`message_id`,type:`text`,nullable:!0,identity:!1,default:null,position:4}},{table:`managed_outgoing_image_records`,kind:`column`,value:{name:`created_at`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`managed_outgoing_image_records`,kind:`column`,value:{name:`updated_at`,type:`text`,nullable:!0,identity:!1,default:null,position:6}},{table:`managed_outgoing_image_records`,kind:`column`,value:{name:`retention_class`,type:`text`,nullable:!0,identity:!1,default:null,position:7}},{table:`managed_outgoing_image_records`,kind:`column`,value:{name:`alt`,type:`text`,nullable:!1,identity:!1,default:null,position:8}},{table:`managed_outgoing_image_records`,kind:`column`,value:{name:`original_media_root`,type:`text`,nullable:!1,identity:!1,default:null,position:9}},{table:`managed_outgoing_image_records`,kind:`column`,value:{name:`original_media_id`,type:`text`,nullable:!1,identity:!1,default:null,position:10}},{table:`managed_outgoing_image_records`,kind:`column`,value:{name:`original_media_subdir`,type:`text`,nullable:!1,identity:!1,default:null,position:11}},{table:`managed_outgoing_image_records`,kind:`column`,value:{name:`original_content_type`,type:`text`,nullable:!1,identity:!1,default:null,position:12}},{table:`managed_outgoing_image_records`,kind:`column`,value:{name:`original_width`,type:`bigint`,nullable:!0,identity:!1,default:null,position:13}},{table:`managed_outgoing_image_records`,kind:`column`,value:{name:`original_height`,type:`bigint`,nullable:!0,identity:!1,default:null,position:14}},{table:`managed_outgoing_image_records`,kind:`column`,value:{name:`original_size_bytes`,type:`bigint`,nullable:!0,identity:!1,default:null,position:15}},{table:`managed_outgoing_image_records`,kind:`column`,value:{name:`original_filename`,type:`text`,nullable:!0,identity:!1,default:null,position:16}},{table:`managed_outgoing_image_records`,kind:`column`,value:{name:`record_json`,type:`text`,nullable:!1,identity:!1,default:null,position:17}},{table:`managed_outgoing_image_records`,kind:`column`,value:{name:`cleanup_pending`,type:`bigint`,nullable:!1,identity:!1,default:`0`,position:18}},{table:`managed_outgoing_image_records`,kind:`primaryKey`,value:[`attachment_id`]},{table:`managed_outgoing_image_records`,kind:`indexes`,value:5},{table:`managed_outgoing_image_records`,kind:`checks`,value:1},{table:`mcp_oauth_pending_authorizations`,kind:`table`,value:null},{table:`mcp_oauth_pending_authorizations`,kind:`column`,value:{name:`state`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`mcp_oauth_pending_authorizations`,kind:`column`,value:{name:`store_key`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`mcp_oauth_pending_authorizations`,kind:`column`,value:{name:`create_time`,type:`bigint`,nullable:!1,identity:!1,default:null,position:3}},{table:`mcp_oauth_pending_authorizations`,kind:`primaryKey`,value:[`state`]},{table:`mcp_oauth_pending_authorizations`,kind:`indexes`,value:1},{table:`mcp_oauth_pending_authorizations`,kind:`checks`,value:0},{table:`mcp_oauth_stores`,kind:`table`,value:null},{table:`mcp_oauth_stores`,kind:`column`,value:{name:`store_key`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`mcp_oauth_stores`,kind:`column`,value:{name:`format_version`,type:`bigint`,nullable:!1,identity:!1,default:null,position:2}},{table:`mcp_oauth_stores`,kind:`column`,value:{name:`store_json`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`mcp_oauth_stores`,kind:`column`,value:{name:`updated_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:4}},{table:`mcp_oauth_stores`,kind:`primaryKey`,value:[`store_key`]},{table:`mcp_oauth_stores`,kind:`indexes`,value:1},{table:`mcp_oauth_stores`,kind:`checks`,value:1},{table:`meeting_transcript_sessions`,kind:`table`,value:null},{table:`meeting_transcript_sessions`,kind:`column`,value:{name:`started_at_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:1}},{table:`meeting_transcript_sessions`,kind:`column`,value:{name:`session_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`meeting_transcript_sessions`,kind:`column`,value:{name:`started_at`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`meeting_transcript_sessions`,kind:`column`,value:{name:`selector`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`meeting_transcript_sessions`,kind:`column`,value:{name:`export_key`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`meeting_transcript_sessions`,kind:`column`,value:{name:`session_slug`,type:`text`,nullable:!1,identity:!1,default:null,position:6}},{table:`meeting_transcript_sessions`,kind:`column`,value:{name:`provider_id`,type:`text`,nullable:!1,identity:!1,default:null,position:7}},{table:`meeting_transcript_sessions`,kind:`column`,value:{name:`title`,type:`text`,nullable:!0,identity:!1,default:null,position:8}},{table:`meeting_transcript_sessions`,kind:`column`,value:{name:`source_json`,type:`text`,nullable:!1,identity:!1,default:null,position:9}},{table:`meeting_transcript_sessions`,kind:`column`,value:{name:`source_account_id`,type:`text`,nullable:!0,identity:!1,default:null,position:10}},{table:`meeting_transcript_sessions`,kind:`column`,value:{name:`source_guild_id`,type:`text`,nullable:!0,identity:!1,default:null,position:11}},{table:`meeting_transcript_sessions`,kind:`column`,value:{name:`source_channel_id`,type:`text`,nullable:!0,identity:!1,default:null,position:12}},{table:`meeting_transcript_sessions`,kind:`column`,value:{name:`source_meeting_url`,type:`text`,nullable:!0,identity:!1,default:null,position:13}},{table:`meeting_transcript_sessions`,kind:`column`,value:{name:`source_thread_ts`,type:`text`,nullable:!0,identity:!1,default:null,position:14}},{table:`meeting_transcript_sessions`,kind:`column`,value:{name:`source_file_id`,type:`text`,nullable:!0,identity:!1,default:null,position:15}},{table:`meeting_transcript_sessions`,kind:`column`,value:{name:`stopped_at`,type:`text`,nullable:!0,identity:!1,default:null,position:16}},{table:`meeting_transcript_sessions`,kind:`column`,value:{name:`metadata_json`,type:`text`,nullable:!0,identity:!1,default:null,position:17}},{table:`meeting_transcript_sessions`,kind:`column`,value:{name:`metadata_agent_id`,type:`text`,nullable:!0,identity:!1,default:null,position:18}},{table:`meeting_transcript_sessions`,kind:`column`,value:{name:`export_manifest_json`,type:`text`,nullable:!1,identity:!1,default:`'{}'`,position:19}},{table:`meeting_transcript_sessions`,kind:`column`,value:{name:`export_pending_json`,type:`text`,nullable:!1,identity:!1,default:`'[]'`,position:20}},{table:`meeting_transcript_sessions`,kind:`column`,value:{name:`next_utterance_seq`,type:`bigint`,nullable:!1,identity:!1,default:`0`,position:21}},{table:`meeting_transcript_sessions`,kind:`column`,value:{name:`created_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:22}},{table:`meeting_transcript_sessions`,kind:`column`,value:{name:`updated_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:23}},{table:`meeting_transcript_sessions`,kind:`primaryKey`,value:[`session_id`,`started_at`]},{table:`meeting_transcript_sessions`,kind:`unique`,value:[`selector`]},{table:`meeting_transcript_sessions`,kind:`indexes`,value:10},{table:`meeting_transcript_sessions`,kind:`checks`,value:3},{table:`meeting_transcript_summaries`,kind:`table`,value:null},{table:`meeting_transcript_summaries`,kind:`column`,value:{name:`session_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`meeting_transcript_summaries`,kind:`column`,value:{name:`session_started_at`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`meeting_transcript_summaries`,kind:`column`,value:{name:`generated_at`,type:`text`,nullable:!0,identity:!1,default:null,position:3}},{table:`meeting_transcript_summaries`,kind:`column`,value:{name:`summary_json`,type:`text`,nullable:!0,identity:!1,default:null,position:4}},{table:`meeting_transcript_summaries`,kind:`column`,value:{name:`overview`,type:`text`,nullable:!0,identity:!1,default:null,position:5}},{table:`meeting_transcript_summaries`,kind:`column`,value:{name:`markdown`,type:`text`,nullable:!0,identity:!1,default:null,position:6}},{table:`meeting_transcript_summaries`,kind:`column`,value:{name:`utterance_count`,type:`bigint`,nullable:!1,identity:!1,default:null,position:7}},{table:`meeting_transcript_summaries`,kind:`primaryKey`,value:[`session_id`,`session_started_at`]},{table:`meeting_transcript_summaries`,kind:`foreignKey`,value:{columns:[`session_id`,`session_started_at`],target:`meeting_transcript_sessions`,targetColumns:[`session_id`,`started_at`],onUpdate:`NO ACTION`,onDelete:`CASCADE`,deferrable:!1,deferred:!1}},{table:`meeting_transcript_summaries`,kind:`indexes`,value:1},{table:`meeting_transcript_summaries`,kind:`checks`,value:2},{table:`meeting_transcript_utterances`,kind:`table`,value:null},{table:`meeting_transcript_utterances`,kind:`column`,value:{name:`session_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`meeting_transcript_utterances`,kind:`column`,value:{name:`session_started_at`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`meeting_transcript_utterances`,kind:`column`,value:{name:`sequence`,type:`bigint`,nullable:!1,identity:!1,default:null,position:3}},{table:`meeting_transcript_utterances`,kind:`column`,value:{name:`utterance_id`,type:`text`,nullable:!0,identity:!1,default:null,position:4}},{table:`meeting_transcript_utterances`,kind:`column`,value:{name:`started_at`,type:`text`,nullable:!0,identity:!1,default:null,position:5}},{table:`meeting_transcript_utterances`,kind:`column`,value:{name:`ended_at`,type:`text`,nullable:!0,identity:!1,default:null,position:6}},{table:`meeting_transcript_utterances`,kind:`column`,value:{name:`speaker_id`,type:`text`,nullable:!0,identity:!1,default:null,position:7}},{table:`meeting_transcript_utterances`,kind:`column`,value:{name:`speaker_label`,type:`text`,nullable:!0,identity:!1,default:null,position:8}},{table:`meeting_transcript_utterances`,kind:`column`,value:{name:`text`,type:`text`,nullable:!1,identity:!1,default:null,position:9}},{table:`meeting_transcript_utterances`,kind:`column`,value:{name:`final`,type:`bigint`,nullable:!0,identity:!1,default:null,position:10}},{table:`meeting_transcript_utterances`,kind:`column`,value:{name:`metadata_json`,type:`text`,nullable:!0,identity:!1,default:null,position:11}},{table:`meeting_transcript_utterances`,kind:`primaryKey`,value:[`session_id`,`session_started_at`,`sequence`]},{table:`meeting_transcript_utterances`,kind:`foreignKey`,value:{columns:[`session_id`,`session_started_at`],target:`meeting_transcript_sessions`,targetColumns:[`session_id`,`started_at`],onUpdate:`NO ACTION`,onDelete:`CASCADE`,deferrable:!1,deferred:!1}},{table:`meeting_transcript_utterances`,kind:`indexes`,value:2},{table:`meeting_transcript_utterances`,kind:`checks`,value:2},{table:`migration_runs`,kind:`table`,value:null},{table:`migration_runs`,kind:`column`,value:{name:`id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`migration_runs`,kind:`column`,value:{name:`started_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:2}},{table:`migration_runs`,kind:`column`,value:{name:`finished_at`,type:`bigint`,nullable:!0,identity:!1,default:null,position:3}},{table:`migration_runs`,kind:`column`,value:{name:`status`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`migration_runs`,kind:`column`,value:{name:`report_json`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`migration_runs`,kind:`primaryKey`,value:[`id`]},{table:`migration_runs`,kind:`indexes`,value:2},{table:`migration_runs`,kind:`checks`,value:0},{table:`migration_sources`,kind:`table`,value:null},{table:`migration_sources`,kind:`column`,value:{name:`source_key`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`migration_sources`,kind:`column`,value:{name:`migration_kind`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`migration_sources`,kind:`column`,value:{name:`source_path`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`migration_sources`,kind:`column`,value:{name:`target_table`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`migration_sources`,kind:`column`,value:{name:`source_sha256`,type:`text`,nullable:!0,identity:!1,default:null,position:5}},{table:`migration_sources`,kind:`column`,value:{name:`source_size_bytes`,type:`bigint`,nullable:!0,identity:!1,default:null,position:6}},{table:`migration_sources`,kind:`column`,value:{name:`source_record_count`,type:`bigint`,nullable:!0,identity:!1,default:null,position:7}},{table:`migration_sources`,kind:`column`,value:{name:`last_run_id`,type:`text`,nullable:!1,identity:!1,default:null,position:8}},{table:`migration_sources`,kind:`column`,value:{name:`status`,type:`text`,nullable:!1,identity:!1,default:null,position:9}},{table:`migration_sources`,kind:`column`,value:{name:`imported_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:10}},{table:`migration_sources`,kind:`column`,value:{name:`removed_source`,type:`bigint`,nullable:!1,identity:!1,default:`0`,position:11}},{table:`migration_sources`,kind:`column`,value:{name:`report_json`,type:`text`,nullable:!1,identity:!1,default:null,position:12}},{table:`migration_sources`,kind:`primaryKey`,value:[`source_key`]},{table:`migration_sources`,kind:`foreignKey`,value:{columns:[`last_run_id`],target:`migration_runs`,targetColumns:[`id`],onUpdate:`NO ACTION`,onDelete:`CASCADE`,deferrable:!1,deferred:!1}},{table:`migration_sources`,kind:`indexes`,value:3},{table:`migration_sources`,kind:`checks`,value:0},{table:`native_hook_relay_bridges`,kind:`table`,value:null},{table:`native_hook_relay_bridges`,kind:`column`,value:{name:`relay_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`native_hook_relay_bridges`,kind:`column`,value:{name:`pid`,type:`bigint`,nullable:!1,identity:!1,default:null,position:2}},{table:`native_hook_relay_bridges`,kind:`column`,value:{name:`hostname`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`native_hook_relay_bridges`,kind:`column`,value:{name:`port`,type:`bigint`,nullable:!1,identity:!1,default:null,position:4}},{table:`native_hook_relay_bridges`,kind:`column`,value:{name:`token`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`native_hook_relay_bridges`,kind:`column`,value:{name:`expires_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:6}},{table:`native_hook_relay_bridges`,kind:`column`,value:{name:`updated_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:7}},{table:`native_hook_relay_bridges`,kind:`primaryKey`,value:[`relay_id`]},{table:`native_hook_relay_bridges`,kind:`indexes`,value:2},{table:`native_hook_relay_bridges`,kind:`checks`,value:0},{table:`node_worker_launch_boots`,kind:`table`,value:null},{table:`node_worker_launch_boots`,kind:`column`,value:{name:`launch_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`node_worker_launch_boots`,kind:`column`,value:{name:`boot_id`,type:`text`,nullable:!0,identity:!1,default:null,position:2}},{table:`node_worker_launch_boots`,kind:`primaryKey`,value:[`launch_id`]},{table:`node_worker_launch_boots`,kind:`foreignKey`,value:{columns:[`launch_id`],target:`node_worker_launches`,targetColumns:[`launch_id`],onUpdate:`NO ACTION`,onDelete:`CASCADE`,deferrable:!1,deferred:!1}},{table:`node_worker_launch_boots`,kind:`indexes`,value:1},{table:`node_worker_launch_boots`,kind:`checks`,value:1},{table:`node_worker_launch_cleanup`,kind:`table`,value:null},{table:`node_worker_launch_cleanup`,kind:`column`,value:{name:`launch_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`node_worker_launch_cleanup`,kind:`column`,value:{name:`cleanup_mode`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`node_worker_launch_cleanup`,kind:`column`,value:{name:`lineage_settled`,type:`bigint`,nullable:!0,identity:!1,default:null,position:3}},{table:`node_worker_launch_cleanup`,kind:`primaryKey`,value:[`launch_id`]},{table:`node_worker_launch_cleanup`,kind:`foreignKey`,value:{columns:[`launch_id`],target:`node_worker_launches`,targetColumns:[`launch_id`],onUpdate:`NO ACTION`,onDelete:`CASCADE`,deferrable:!1,deferred:!1}},{table:`node_worker_launch_cleanup`,kind:`indexes`,value:1},{table:`node_worker_launch_cleanup`,kind:`checks`,value:2},{table:`node_worker_launch_containers`,kind:`table`,value:null},{table:`node_worker_launch_containers`,kind:`column`,value:{name:`launch_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`node_worker_launch_containers`,kind:`column`,value:{name:`container_json`,type:`text`,nullable:!0,identity:!1,default:null,position:2}},{table:`node_worker_launch_containers`,kind:`primaryKey`,value:[`launch_id`]},{table:`node_worker_launch_containers`,kind:`indexes`,value:1},{table:`node_worker_launch_containers`,kind:`checks`,value:0},{table:`node_worker_launch_process_scopes`,kind:`table`,value:null},{table:`node_worker_launch_process_scopes`,kind:`column`,value:{name:`launch_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`node_worker_launch_process_scopes`,kind:`column`,value:{name:`scope_kind`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`node_worker_launch_process_scopes`,kind:`column`,value:{name:`descendants_reaped`,type:`bigint`,nullable:!0,identity:!1,default:null,position:3}},{table:`node_worker_launch_process_scopes`,kind:`primaryKey`,value:[`launch_id`]},{table:`node_worker_launch_process_scopes`,kind:`foreignKey`,value:{columns:[`launch_id`],target:`node_worker_launches`,targetColumns:[`launch_id`],onUpdate:`NO ACTION`,onDelete:`CASCADE`,deferrable:!1,deferred:!1}},{table:`node_worker_launch_process_scopes`,kind:`indexes`,value:1},{table:`node_worker_launch_process_scopes`,kind:`checks`,value:2},{table:`node_worker_launches`,kind:`table`,value:null},{table:`node_worker_launches`,kind:`column`,value:{name:`launch_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`node_worker_launches`,kind:`column`,value:{name:`plan_hash`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`node_worker_launches`,kind:`column`,value:{name:`gateway_namespace`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`node_worker_launches`,kind:`column`,value:{name:`environment_id`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`node_worker_launches`,kind:`column`,value:{name:`session_id`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`node_worker_launches`,kind:`column`,value:{name:`owner_epoch`,type:`bigint`,nullable:!1,identity:!1,default:null,position:6}},{table:`node_worker_launches`,kind:`column`,value:{name:`placement_generation`,type:`bigint`,nullable:!1,identity:!1,default:null,position:7}},{table:`node_worker_launches`,kind:`column`,value:{name:`run_id`,type:`text`,nullable:!1,identity:!1,default:null,position:8}},{table:`node_worker_launches`,kind:`column`,value:{name:`state`,type:`text`,nullable:!1,identity:!1,default:null,position:9}},{table:`node_worker_launches`,kind:`column`,value:{name:`supervisor_pid`,type:`bigint`,nullable:!1,identity:!1,default:null,position:10}},{table:`node_worker_launches`,kind:`column`,value:{name:`supervisor_start_time`,type:`bigint`,nullable:!1,identity:!1,default:null,position:11}},{table:`node_worker_launches`,kind:`column`,value:{name:`worker_pid`,type:`bigint`,nullable:!0,identity:!1,default:null,position:12}},{table:`node_worker_launches`,kind:`column`,value:{name:`worker_start_time`,type:`bigint`,nullable:!0,identity:!1,default:null,position:13}},{table:`node_worker_launches`,kind:`column`,value:{name:`result_json`,type:`text`,nullable:!0,identity:!1,default:null,position:14}},{table:`node_worker_launches`,kind:`column`,value:{name:`error_text`,type:`text`,nullable:!0,identity:!1,default:null,position:15}},{table:`node_worker_launches`,kind:`column`,value:{name:`completed_at_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:16}},{table:`node_worker_launches`,kind:`column`,value:{name:`created_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:17}},{table:`node_worker_launches`,kind:`column`,value:{name:`updated_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:18}},{table:`node_worker_launches`,kind:`primaryKey`,value:[`launch_id`]},{table:`node_worker_launches`,kind:`indexes`,value:2},{table:`node_worker_launches`,kind:`checks`,value:20},{table:`node_worker_prepared_workspaces`,kind:`table`,value:null},{table:`node_worker_prepared_workspaces`,kind:`column`,value:{name:`preparation_key`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`node_worker_prepared_workspaces`,kind:`column`,value:{name:`cache_key`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`node_worker_prepared_workspaces`,kind:`column`,value:{name:`gateway_namespace`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`node_worker_prepared_workspaces`,kind:`column`,value:{name:`workspace_dir`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`node_worker_prepared_workspaces`,kind:`column`,value:{name:`home_dir`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`node_worker_prepared_workspaces`,kind:`column`,value:{name:`source_manifest_ref`,type:`text`,nullable:!1,identity:!1,default:null,position:6}},{table:`node_worker_prepared_workspaces`,kind:`column`,value:{name:`prepared_manifest_ref`,type:`text`,nullable:!1,identity:!1,default:null,position:7}},{table:`node_worker_prepared_workspaces`,kind:`column`,value:{name:`state`,type:`text`,nullable:!1,identity:!1,default:null,position:8}},{table:`node_worker_prepared_workspaces`,kind:`column`,value:{name:`environment_id`,type:`text`,nullable:!1,identity:!1,default:null,position:9}},{table:`node_worker_prepared_workspaces`,kind:`column`,value:{name:`session_id`,type:`text`,nullable:!0,identity:!1,default:null,position:10}},{table:`node_worker_prepared_workspaces`,kind:`column`,value:{name:`session_key`,type:`text`,nullable:!0,identity:!1,default:null,position:11}},{table:`node_worker_prepared_workspaces`,kind:`column`,value:{name:`owner_epoch`,type:`bigint`,nullable:!0,identity:!1,default:null,position:12}},{table:`node_worker_prepared_workspaces`,kind:`column`,value:{name:`created_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:13}},{table:`node_worker_prepared_workspaces`,kind:`column`,value:{name:`bound_at_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:14}},{table:`node_worker_prepared_workspaces`,kind:`column`,value:{name:`retired_at_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:15}},{table:`node_worker_prepared_workspaces`,kind:`primaryKey`,value:[`preparation_key`]},{table:`node_worker_prepared_workspaces`,kind:`unique`,value:[`workspace_dir`]},{table:`node_worker_prepared_workspaces`,kind:`indexes`,value:2},{table:`node_worker_prepared_workspaces`,kind:`checks`,value:15},{table:`node_worker_turns`,kind:`table`,value:null},{table:`node_worker_turns`,kind:`column`,value:{name:`turn_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`node_worker_turns`,kind:`column`,value:{name:`owner_launch_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`node_worker_turns`,kind:`column`,value:{name:`plan_hash`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`node_worker_turns`,kind:`column`,value:{name:`run_id`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`node_worker_turns`,kind:`column`,value:{name:`state`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`node_worker_turns`,kind:`column`,value:{name:`result_json`,type:`text`,nullable:!0,identity:!1,default:null,position:6}},{table:`node_worker_turns`,kind:`column`,value:{name:`error_text`,type:`text`,nullable:!0,identity:!1,default:null,position:7}},{table:`node_worker_turns`,kind:`column`,value:{name:`completed_at_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:8}},{table:`node_worker_turns`,kind:`column`,value:{name:`created_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:9}},{table:`node_worker_turns`,kind:`column`,value:{name:`updated_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:10}},{table:`node_worker_turns`,kind:`primaryKey`,value:[`turn_id`]},{table:`node_worker_turns`,kind:`foreignKey`,value:{columns:[`owner_launch_id`],target:`node_worker_launches`,targetColumns:[`launch_id`],onUpdate:`NO ACTION`,onDelete:`CASCADE`,deferrable:!1,deferred:!1}},{table:`node_worker_turns`,kind:`indexes`,value:3},{table:`node_worker_turns`,kind:`checks`,value:10},{table:`official_external_plugin_catalog_snapshots`,kind:`table`,value:null},{table:`official_external_plugin_catalog_snapshots`,kind:`column`,value:{name:`feed_url`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`official_external_plugin_catalog_snapshots`,kind:`column`,value:{name:`body`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`official_external_plugin_catalog_snapshots`,kind:`column`,value:{name:`status`,type:`bigint`,nullable:!1,identity:!1,default:null,position:3}},{table:`official_external_plugin_catalog_snapshots`,kind:`column`,value:{name:`etag`,type:`text`,nullable:!0,identity:!1,default:null,position:4}},{table:`official_external_plugin_catalog_snapshots`,kind:`column`,value:{name:`last_modified`,type:`text`,nullable:!0,identity:!1,default:null,position:5}},{table:`official_external_plugin_catalog_snapshots`,kind:`column`,value:{name:`checksum`,type:`text`,nullable:!1,identity:!1,default:null,position:6}},{table:`official_external_plugin_catalog_snapshots`,kind:`column`,value:{name:`saved_at`,type:`text`,nullable:!1,identity:!1,default:null,position:7}},{table:`official_external_plugin_catalog_snapshots`,kind:`column`,value:{name:`trust_mode`,type:`text`,nullable:!0,identity:!1,default:null,position:8}},{table:`official_external_plugin_catalog_snapshots`,kind:`column`,value:{name:`trust_key_id`,type:`text`,nullable:!0,identity:!1,default:null,position:9}},{table:`official_external_plugin_catalog_snapshots`,kind:`column`,value:{name:`trust_signature_count`,type:`bigint`,nullable:!0,identity:!1,default:null,position:10}},{table:`official_external_plugin_catalog_snapshots`,kind:`column`,value:{name:`trust_threshold`,type:`bigint`,nullable:!0,identity:!1,default:null,position:11}},{table:`official_external_plugin_catalog_snapshots`,kind:`column`,value:{name:`trust_verified_at`,type:`text`,nullable:!0,identity:!1,default:null,position:12}},{table:`official_external_plugin_catalog_snapshots`,kind:`column`,value:{name:`updated_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:13}},{table:`official_external_plugin_catalog_snapshots`,kind:`primaryKey`,value:[`feed_url`]},{table:`official_external_plugin_catalog_snapshots`,kind:`indexes`,value:2},{table:`official_external_plugin_catalog_snapshots`,kind:`checks`,value:0},{table:`operator_approval_execution_identities`,kind:`table`,value:null},{table:`operator_approval_execution_identities`,kind:`column`,value:{name:`approval_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`operator_approval_execution_identities`,kind:`column`,value:{name:`source_context_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`operator_approval_execution_identities`,kind:`column`,value:{name:`source_execution_id`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`operator_approval_execution_identities`,kind:`primaryKey`,value:[`approval_id`]},{table:`operator_approval_execution_identities`,kind:`foreignKey`,value:{columns:[`approval_id`],target:`operator_approvals`,targetColumns:[`approval_id`],onUpdate:`NO ACTION`,onDelete:`CASCADE`,deferrable:!1,deferred:!1}},{table:`operator_approval_execution_identities`,kind:`indexes`,value:1},{table:`operator_approval_execution_identities`,kind:`checks`,value:2},{table:`operator_approval_standing_grant_generations`,kind:`table`,value:null},{table:`operator_approval_standing_grant_generations`,kind:`column`,value:{name:`grant_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`operator_approval_standing_grant_generations`,kind:`column`,value:{name:`job_definition_generation`,type:`bigint`,nullable:!1,identity:!1,default:null,position:2}},{table:`operator_approval_standing_grant_generations`,kind:`primaryKey`,value:[`grant_id`]},{table:`operator_approval_standing_grant_generations`,kind:`foreignKey`,value:{columns:[`grant_id`],target:`operator_approval_standing_grants`,targetColumns:[`grant_id`],onUpdate:`NO ACTION`,onDelete:`CASCADE`,deferrable:!1,deferred:!1}},{table:`operator_approval_standing_grant_generations`,kind:`indexes`,value:1},{table:`operator_approval_standing_grant_generations`,kind:`checks`,value:1},{table:`operator_approval_standing_grants`,kind:`table`,value:null},{table:`operator_approval_standing_grants`,kind:`column`,value:{name:`grant_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`operator_approval_standing_grants`,kind:`column`,value:{name:`minted_by_approval_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`operator_approval_standing_grants`,kind:`column`,value:{name:`agent_id`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`operator_approval_standing_grants`,kind:`column`,value:{name:`cron_job_id`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`operator_approval_standing_grants`,kind:`column`,value:{name:`job_config_revision`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`operator_approval_standing_grants`,kind:`column`,value:{name:`operation_binding`,type:`text`,nullable:!1,identity:!1,default:null,position:6}},{table:`operator_approval_standing_grants`,kind:`column`,value:{name:`created_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:7}},{table:`operator_approval_standing_grants`,kind:`column`,value:{name:`expires_at_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:8}},{table:`operator_approval_standing_grants`,kind:`column`,value:{name:`revoked_at_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:9}},{table:`operator_approval_standing_grants`,kind:`column`,value:{name:`revoked_by`,type:`text`,nullable:!0,identity:!1,default:null,position:10}},{table:`operator_approval_standing_grants`,kind:`column`,value:{name:`last_used_at_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:11}},{table:`operator_approval_standing_grants`,kind:`column`,value:{name:`use_count`,type:`bigint`,nullable:!1,identity:!1,default:`0`,position:12}},{table:`operator_approval_standing_grants`,kind:`primaryKey`,value:[`grant_id`]},{table:`operator_approval_standing_grants`,kind:`foreignKey`,value:{columns:[`minted_by_approval_id`],target:`operator_approvals`,targetColumns:[`approval_id`],onUpdate:`NO ACTION`,onDelete:`CASCADE`,deferrable:!1,deferred:!1}},{table:`operator_approval_standing_grants`,kind:`indexes`,value:2},{table:`operator_approval_standing_grants`,kind:`checks`,value:6},{table:`operator_approvals`,kind:`table`,value:null},{table:`operator_approvals`,kind:`column`,value:{name:`cursor_id`,type:`bigint`,nullable:!1,identity:!1,default:null,position:1}},{table:`operator_approvals`,kind:`column`,value:{name:`approval_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`operator_approvals`,kind:`column`,value:{name:`resolution_ref`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`operator_approvals`,kind:`column`,value:{name:`kind`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`operator_approvals`,kind:`column`,value:{name:`status`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`operator_approvals`,kind:`column`,value:{name:`presentation_json`,type:`text`,nullable:!1,identity:!1,default:null,position:6}},{table:`operator_approvals`,kind:`column`,value:{name:`requested_by_device_id`,type:`text`,nullable:!0,identity:!1,default:null,position:7}},{table:`operator_approvals`,kind:`column`,value:{name:`requested_by_client_id`,type:`text`,nullable:!0,identity:!1,default:null,position:8}},{table:`operator_approvals`,kind:`column`,value:{name:`requested_by_device_token_auth`,type:`bigint`,nullable:!1,identity:!1,default:`0`,position:9}},{table:`operator_approvals`,kind:`column`,value:{name:`reviewer_device_ids_json`,type:`text`,nullable:!1,identity:!1,default:null,position:10}},{table:`operator_approvals`,kind:`column`,value:{name:`source_agent_id`,type:`text`,nullable:!0,identity:!1,default:null,position:11}},{table:`operator_approvals`,kind:`column`,value:{name:`source_session_key`,type:`text`,nullable:!0,identity:!1,default:null,position:12}},{table:`operator_approvals`,kind:`column`,value:{name:`source_session_id`,type:`text`,nullable:!0,identity:!1,default:null,position:13}},{table:`operator_approvals`,kind:`column`,value:{name:`source_run_id`,type:`text`,nullable:!0,identity:!1,default:null,position:14}},{table:`operator_approvals`,kind:`column`,value:{name:`source_tool_call_id`,type:`text`,nullable:!0,identity:!1,default:null,position:15}},{table:`operator_approvals`,kind:`column`,value:{name:`source_tool_name`,type:`text`,nullable:!0,identity:!1,default:null,position:16}},{table:`operator_approvals`,kind:`column`,value:{name:`audience_session_keys_json`,type:`text`,nullable:!1,identity:!1,default:null,position:17}},{table:`operator_approvals`,kind:`column`,value:{name:`runtime_epoch`,type:`text`,nullable:!1,identity:!1,default:null,position:18}},{table:`operator_approvals`,kind:`column`,value:{name:`created_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:19}},{table:`operator_approvals`,kind:`column`,value:{name:`expires_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:20}},{table:`operator_approvals`,kind:`column`,value:{name:`updated_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:21}},{table:`operator_approvals`,kind:`column`,value:{name:`decision`,type:`text`,nullable:!0,identity:!1,default:null,position:22}},{table:`operator_approvals`,kind:`column`,value:{name:`terminal_reason`,type:`text`,nullable:!0,identity:!1,default:null,position:23}},{table:`operator_approvals`,kind:`column`,value:{name:`resolved_at_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:24}},{table:`operator_approvals`,kind:`column`,value:{name:`resolver_kind`,type:`text`,nullable:!0,identity:!1,default:null,position:25}},{table:`operator_approvals`,kind:`column`,value:{name:`resolver_id`,type:`text`,nullable:!0,identity:!1,default:null,position:26}},{table:`operator_approvals`,kind:`column`,value:{name:`consumed_at_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:27}},{table:`operator_approvals`,kind:`column`,value:{name:`consumed_by`,type:`text`,nullable:!0,identity:!1,default:null,position:28}},{table:`operator_approvals`,kind:`primaryKey`,value:[`approval_id`]},{table:`operator_approvals`,kind:`indexes`,value:8},{table:`operator_approvals`,kind:`checks`,value:16},{table:`outbound_media_provenance`,kind:`table`,value:null},{table:`outbound_media_provenance`,kind:`column`,value:{name:`realpath`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`outbound_media_provenance`,kind:`column`,value:{name:`kind`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`outbound_media_provenance`,kind:`column`,value:{name:`version`,type:`bigint`,nullable:!1,identity:!1,default:null,position:3}},{table:`outbound_media_provenance`,kind:`column`,value:{name:`sha256`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`outbound_media_provenance`,kind:`column`,value:{name:`size_bytes`,type:`bigint`,nullable:!1,identity:!1,default:null,position:5}},{table:`outbound_media_provenance`,kind:`column`,value:{name:`created_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:6}},{table:`outbound_media_provenance`,kind:`primaryKey`,value:[`realpath`]},{table:`outbound_media_provenance`,kind:`indexes`,value:1},{table:`outbound_media_provenance`,kind:`checks`,value:0},{table:`outbound_message_execution_bindings`,kind:`table`,value:null},{table:`outbound_message_execution_bindings`,kind:`column`,value:{name:`event_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`outbound_message_execution_bindings`,kind:`column`,value:{name:`context_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`outbound_message_execution_bindings`,kind:`column`,value:{name:`execution_id`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`outbound_message_execution_bindings`,kind:`column`,value:{name:`run_id`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`outbound_message_execution_bindings`,kind:`primaryKey`,value:[`event_id`]},{table:`outbound_message_execution_bindings`,kind:`foreignKey`,value:{columns:[`event_id`],target:`audit_events`,targetColumns:[`event_id`],onUpdate:`NO ACTION`,onDelete:`CASCADE`,deferrable:!1,deferred:!1}},{table:`outbound_message_execution_bindings`,kind:`indexes`,value:2},{table:`outbound_message_execution_bindings`,kind:`checks`,value:3},{table:`outbound_message_progress`,kind:`table`,value:null},{table:`outbound_message_progress`,kind:`column`,value:{name:`sequence`,type:`bigint`,nullable:!1,identity:!0,default:null,position:1}},{table:`outbound_message_progress`,kind:`column`,value:{name:`progress_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`outbound_message_progress`,kind:`column`,value:{name:`source_id`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`outbound_message_progress`,kind:`column`,value:{name:`source_sequence`,type:`bigint`,nullable:!1,identity:!1,default:null,position:4}},{table:`outbound_message_progress`,kind:`column`,value:{name:`schema_version`,type:`bigint`,nullable:!1,identity:!1,default:null,position:5}},{table:`outbound_message_progress`,kind:`column`,value:{name:`occurred_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:6}},{table:`outbound_message_progress`,kind:`column`,value:{name:`action`,type:`text`,nullable:!1,identity:!1,default:null,position:7}},{table:`outbound_message_progress`,kind:`column`,value:{name:`outcome`,type:`text`,nullable:!1,identity:!1,default:null,position:8}},{table:`outbound_message_progress`,kind:`column`,value:{name:`actor_type`,type:`text`,nullable:!1,identity:!1,default:null,position:9}},{table:`outbound_message_progress`,kind:`column`,value:{name:`actor_id`,type:`text`,nullable:!1,identity:!1,default:null,position:10}},{table:`outbound_message_progress`,kind:`column`,value:{name:`agent_id`,type:`text`,nullable:!0,identity:!1,default:null,position:11}},{table:`outbound_message_progress`,kind:`column`,value:{name:`run_id`,type:`text`,nullable:!0,identity:!1,default:null,position:12}},{table:`outbound_message_progress`,kind:`column`,value:{name:`context_id`,type:`text`,nullable:!0,identity:!1,default:null,position:13}},{table:`outbound_message_progress`,kind:`column`,value:{name:`execution_id`,type:`text`,nullable:!0,identity:!1,default:null,position:14}},{table:`outbound_message_progress`,kind:`column`,value:{name:`channel`,type:`text`,nullable:!1,identity:!1,default:null,position:15}},{table:`outbound_message_progress`,kind:`column`,value:{name:`conversation_kind`,type:`text`,nullable:!1,identity:!1,default:null,position:16}},{table:`outbound_message_progress`,kind:`column`,value:{name:`duration_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:17}},{table:`outbound_message_progress`,kind:`column`,value:{name:`account_ref`,type:`text`,nullable:!0,identity:!1,default:null,position:18}},{table:`outbound_message_progress`,kind:`column`,value:{name:`conversation_ref`,type:`text`,nullable:!0,identity:!1,default:null,position:19}},{table:`outbound_message_progress`,kind:`column`,value:{name:`target_ref`,type:`text`,nullable:!0,identity:!1,default:null,position:20}},{table:`outbound_message_progress`,kind:`primaryKey`,value:[`sequence`]},{table:`outbound_message_progress`,kind:`unique`,value:[`progress_id`]},{table:`outbound_message_progress`,kind:`unique`,value:[`source_id`]},{table:`outbound_message_progress`,kind:`unique`,value:[`occurred_at`,`progress_id`]},{table:`outbound_message_progress`,kind:`indexes`,value:6},{table:`outbound_message_progress`,kind:`checks`,value:14},{table:`plugin_binding_approvals`,kind:`table`,value:null},{table:`plugin_binding_approvals`,kind:`column`,value:{name:`plugin_root`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`plugin_binding_approvals`,kind:`column`,value:{name:`channel`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`plugin_binding_approvals`,kind:`column`,value:{name:`account_id`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`plugin_binding_approvals`,kind:`column`,value:{name:`plugin_id`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`plugin_binding_approvals`,kind:`column`,value:{name:`plugin_name`,type:`text`,nullable:!0,identity:!1,default:null,position:5}},{table:`plugin_binding_approvals`,kind:`column`,value:{name:`approved_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:6}},{table:`plugin_binding_approvals`,kind:`primaryKey`,value:[`plugin_root`,`channel`,`account_id`]},{table:`plugin_binding_approvals`,kind:`indexes`,value:2},{table:`plugin_binding_approvals`,kind:`checks`,value:0},{table:`plugin_blob_entries`,kind:`table`,value:null},{table:`plugin_blob_entries`,kind:`column`,value:{name:`plugin_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`plugin_blob_entries`,kind:`column`,value:{name:`namespace`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`plugin_blob_entries`,kind:`column`,value:{name:`entry_key`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`plugin_blob_entries`,kind:`column`,value:{name:`metadata_json`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`plugin_blob_entries`,kind:`column`,value:{name:`blob`,type:`bytea`,nullable:!1,identity:!1,default:null,position:5}},{table:`plugin_blob_entries`,kind:`column`,value:{name:`created_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:6}},{table:`plugin_blob_entries`,kind:`column`,value:{name:`expires_at`,type:`bigint`,nullable:!0,identity:!1,default:null,position:7}},{table:`plugin_blob_entries`,kind:`primaryKey`,value:[`plugin_id`,`namespace`,`entry_key`]},{table:`plugin_blob_entries`,kind:`indexes`,value:3},{table:`plugin_blob_entries`,kind:`checks`,value:0},{table:`plugin_state_entries`,kind:`table`,value:null},{table:`plugin_state_entries`,kind:`column`,value:{name:`plugin_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`plugin_state_entries`,kind:`column`,value:{name:`namespace`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`plugin_state_entries`,kind:`column`,value:{name:`entry_key`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`plugin_state_entries`,kind:`column`,value:{name:`value_json`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`plugin_state_entries`,kind:`column`,value:{name:`created_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:5}},{table:`plugin_state_entries`,kind:`column`,value:{name:`expires_at`,type:`bigint`,nullable:!0,identity:!1,default:null,position:6}},{table:`plugin_state_entries`,kind:`primaryKey`,value:[`plugin_id`,`namespace`,`entry_key`]},{table:`plugin_state_entries`,kind:`indexes`,value:3},{table:`plugin_state_entries`,kind:`checks`,value:0},{table:`projects`,kind:`table`,value:null},{table:`projects`,kind:`column`,value:{name:`id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`projects`,kind:`column`,value:{name:`display_name`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`projects`,kind:`column`,value:{name:`repo_root`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`projects`,kind:`column`,value:{name:`origin_url`,type:`text`,nullable:!0,identity:!1,default:null,position:4}},{table:`projects`,kind:`column`,value:{name:`source`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`projects`,kind:`column`,value:{name:`created_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:6}},{table:`projects`,kind:`column`,value:{name:`updated_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:7}},{table:`projects`,kind:`primaryKey`,value:[`id`]},{table:`projects`,kind:`indexes`,value:1},{table:`projects`,kind:`checks`,value:1},{table:`sandbox_persistent_execs`,kind:`table`,value:null},{table:`sandbox_persistent_execs`,kind:`column`,value:{name:`owner_key`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`sandbox_persistent_execs`,kind:`column`,value:{name:`source_identity`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`sandbox_persistent_execs`,kind:`column`,value:{name:`attempt_id`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`sandbox_persistent_execs`,kind:`column`,value:{name:`owner_json`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`sandbox_persistent_execs`,kind:`column`,value:{name:`backend_id`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`sandbox_persistent_execs`,kind:`column`,value:{name:`backend_target_json`,type:`text`,nullable:!1,identity:!1,default:null,position:6}},{table:`sandbox_persistent_execs`,kind:`column`,value:{name:`workspace_binding_json`,type:`text`,nullable:!1,identity:!1,default:null,position:7}},{table:`sandbox_persistent_execs`,kind:`column`,value:{name:`container_id`,type:`text`,nullable:!1,identity:!1,default:null,position:8}},{table:`sandbox_persistent_execs`,kind:`column`,value:{name:`container_name`,type:`text`,nullable:!1,identity:!1,default:null,position:9}},{table:`sandbox_persistent_execs`,kind:`column`,value:{name:`container_started_at`,type:`text`,nullable:!1,identity:!1,default:null,position:10}},{table:`sandbox_persistent_execs`,kind:`column`,value:{name:`revision`,type:`bigint`,nullable:!1,identity:!1,default:null,position:11}},{table:`sandbox_persistent_execs`,kind:`column`,value:{name:`phase`,type:`text`,nullable:!1,identity:!1,default:null,position:12}},{table:`sandbox_persistent_execs`,kind:`column`,value:{name:`receipt_json`,type:`text`,nullable:!0,identity:!1,default:null,position:13}},{table:`sandbox_persistent_execs`,kind:`column`,value:{name:`error`,type:`text`,nullable:!0,identity:!1,default:null,position:14}},{table:`sandbox_persistent_execs`,kind:`column`,value:{name:`created_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:15}},{table:`sandbox_persistent_execs`,kind:`column`,value:{name:`updated_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:16}},{table:`sandbox_persistent_execs`,kind:`primaryKey`,value:[`owner_key`]},{table:`sandbox_persistent_execs`,kind:`unique`,value:[`attempt_id`]},{table:`sandbox_persistent_execs`,kind:`indexes`,value:5},{table:`sandbox_persistent_execs`,kind:`checks`,value:4},{table:`sandbox_registry_entries`,kind:`table`,value:null},{table:`sandbox_registry_entries`,kind:`column`,value:{name:`registry_kind`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`sandbox_registry_entries`,kind:`column`,value:{name:`container_name`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`sandbox_registry_entries`,kind:`column`,value:{name:`session_key`,type:`text`,nullable:!0,identity:!1,default:null,position:3}},{table:`sandbox_registry_entries`,kind:`column`,value:{name:`backend_id`,type:`text`,nullable:!0,identity:!1,default:null,position:4}},{table:`sandbox_registry_entries`,kind:`column`,value:{name:`runtime_label`,type:`text`,nullable:!0,identity:!1,default:null,position:5}},{table:`sandbox_registry_entries`,kind:`column`,value:{name:`image`,type:`text`,nullable:!0,identity:!1,default:null,position:6}},{table:`sandbox_registry_entries`,kind:`column`,value:{name:`created_at_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:7}},{table:`sandbox_registry_entries`,kind:`column`,value:{name:`last_used_at_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:8}},{table:`sandbox_registry_entries`,kind:`column`,value:{name:`config_label_kind`,type:`text`,nullable:!0,identity:!1,default:null,position:9}},{table:`sandbox_registry_entries`,kind:`column`,value:{name:`config_hash`,type:`text`,nullable:!0,identity:!1,default:null,position:10}},{table:`sandbox_registry_entries`,kind:`column`,value:{name:`cdp_port`,type:`bigint`,nullable:!0,identity:!1,default:null,position:11}},{table:`sandbox_registry_entries`,kind:`column`,value:{name:`no_vnc_port`,type:`bigint`,nullable:!0,identity:!1,default:null,position:12}},{table:`sandbox_registry_entries`,kind:`column`,value:{name:`entry_json`,type:`text`,nullable:!1,identity:!1,default:null,position:13}},{table:`sandbox_registry_entries`,kind:`column`,value:{name:`updated_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:14}},{table:`sandbox_registry_entries`,kind:`primaryKey`,value:[`registry_kind`,`container_name`]},{table:`sandbox_registry_entries`,kind:`indexes`,value:4},{table:`sandbox_registry_entries`,kind:`checks`,value:0},{table:`schema_meta`,kind:`table`,value:null},{table:`schema_meta`,kind:`column`,value:{name:`meta_key`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`schema_meta`,kind:`column`,value:{name:`role`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`schema_meta`,kind:`column`,value:{name:`schema_version`,type:`bigint`,nullable:!1,identity:!1,default:null,position:3}},{table:`schema_meta`,kind:`column`,value:{name:`agent_id`,type:`text`,nullable:!0,identity:!1,default:null,position:4}},{table:`schema_meta`,kind:`column`,value:{name:`app_version`,type:`text`,nullable:!0,identity:!1,default:null,position:5}},{table:`schema_meta`,kind:`column`,value:{name:`created_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:6}},{table:`schema_meta`,kind:`column`,value:{name:`updated_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:7}},{table:`schema_meta`,kind:`primaryKey`,value:[`meta_key`]},{table:`schema_meta`,kind:`indexes`,value:1},{table:`schema_meta`,kind:`checks`,value:0},{table:`secret_store_entries`,kind:`table`,value:null},{table:`secret_store_entries`,kind:`column`,value:{name:`scope_kind`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`secret_store_entries`,kind:`column`,value:{name:`scope_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`secret_store_entries`,kind:`column`,value:{name:`name`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`secret_store_entries`,kind:`column`,value:{name:`value`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`secret_store_entries`,kind:`column`,value:{name:`kind`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`secret_store_entries`,kind:`column`,value:{name:`created_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:6}},{table:`secret_store_entries`,kind:`column`,value:{name:`updated_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:7}},{table:`secret_store_entries`,kind:`column`,value:{name:`updated_by`,type:`text`,nullable:!0,identity:!1,default:null,position:8}},{table:`secret_store_entries`,kind:`column`,value:{name:`deleted_at_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:9}},{table:`secret_store_entries`,kind:`column`,value:{name:`allowed_hosts`,type:`text`,nullable:!0,identity:!1,default:null,position:10}},{table:`secret_store_entries`,kind:`primaryKey`,value:[`scope_kind`,`scope_id`,`name`]},{table:`secret_store_entries`,kind:`indexes`,value:2},{table:`secret_store_entries`,kind:`checks`,value:5},{table:`session_groups`,kind:`table`,value:null},{table:`session_groups`,kind:`column`,value:{name:`name`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`session_groups`,kind:`column`,value:{name:`position`,type:`bigint`,nullable:!1,identity:!1,default:null,position:2}},{table:`session_groups`,kind:`column`,value:{name:`created_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:3}},{table:`session_groups`,kind:`column`,value:{name:`cwd`,type:`text`,nullable:!0,identity:!1,default:null,position:4}},{table:`session_groups`,kind:`column`,value:{name:`worktree`,type:`bigint`,nullable:!0,identity:!1,default:null,position:5}},{table:`session_groups`,kind:`primaryKey`,value:[`name`]},{table:`session_groups`,kind:`indexes`,value:1},{table:`session_groups`,kind:`checks`,value:0},{table:`session_repository_workspaces`,kind:`table`,value:null},{table:`session_repository_workspaces`,kind:`column`,value:{name:`workspace_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`session_repository_workspaces`,kind:`column`,value:{name:`agent_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`session_repository_workspaces`,kind:`column`,value:{name:`session_key`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`session_repository_workspaces`,kind:`column`,value:{name:`url`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`session_repository_workspaces`,kind:`column`,value:{name:`requested_ref`,type:`text`,nullable:!0,identity:!1,default:null,position:5}},{table:`session_repository_workspaces`,kind:`column`,value:{name:`run_setup_script`,type:`bigint`,nullable:!1,identity:!1,default:`0`,position:6}},{table:`session_repository_workspaces`,kind:`column`,value:{name:`base_commit`,type:`text`,nullable:!0,identity:!1,default:null,position:7}},{table:`session_repository_workspaces`,kind:`column`,value:{name:`base_manifest_hash`,type:`text`,nullable:!0,identity:!1,default:null,position:8}},{table:`session_repository_workspaces`,kind:`column`,value:{name:`branch`,type:`text`,nullable:!1,identity:!1,default:null,position:9}},{table:`session_repository_workspaces`,kind:`column`,value:{name:`checkpoint_ref`,type:`text`,nullable:!0,identity:!1,default:null,position:10}},{table:`session_repository_workspaces`,kind:`column`,value:{name:`manifest_hash`,type:`text`,nullable:!0,identity:!1,default:null,position:11}},{table:`session_repository_workspaces`,kind:`column`,value:{name:`revision`,type:`bigint`,nullable:!1,identity:!1,default:null,position:12}},{table:`session_repository_workspaces`,kind:`column`,value:{name:`created_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:13}},{table:`session_repository_workspaces`,kind:`column`,value:{name:`updated_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:14}},{table:`session_repository_workspaces`,kind:`column`,value:{name:`disk_authority_json`,type:`text`,nullable:!0,identity:!1,default:null,position:15}},{table:`session_repository_workspaces`,kind:`primaryKey`,value:[`workspace_id`]},{table:`session_repository_workspaces`,kind:`unique`,value:[`agent_id`,`session_key`]},{table:`session_repository_workspaces`,kind:`indexes`,value:2},{table:`session_repository_workspaces`,kind:`checks`,value:11},{table:`session_state_events`,kind:`table`,value:null},{table:`session_state_events`,kind:`column`,value:{name:`sequence`,type:`bigint`,nullable:!1,identity:!0,default:null,position:1}},{table:`session_state_events`,kind:`column`,value:{name:`dedupe_key`,type:`text`,nullable:!0,identity:!1,default:null,position:2}},{table:`session_state_events`,kind:`column`,value:{name:`session_key`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`session_state_events`,kind:`column`,value:{name:`session_id`,type:`text`,nullable:!0,identity:!1,default:null,position:4}},{table:`session_state_events`,kind:`column`,value:{name:`agent_id`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`session_state_events`,kind:`column`,value:{name:`kind`,type:`text`,nullable:!1,identity:!1,default:null,position:6}},{table:`session_state_events`,kind:`column`,value:{name:`actor_type`,type:`text`,nullable:!1,identity:!1,default:null,position:7}},{table:`session_state_events`,kind:`column`,value:{name:`actor_id`,type:`text`,nullable:!0,identity:!1,default:null,position:8}},{table:`session_state_events`,kind:`column`,value:{name:`run_id`,type:`text`,nullable:!0,identity:!1,default:null,position:9}},{table:`session_state_events`,kind:`column`,value:{name:`occurred_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:10}},{table:`session_state_events`,kind:`column`,value:{name:`summary`,type:`text`,nullable:!1,identity:!1,default:null,position:11}},{table:`session_state_events`,kind:`column`,value:{name:`payload_json`,type:`text`,nullable:!0,identity:!1,default:null,position:12}},{table:`session_state_events`,kind:`primaryKey`,value:[`sequence`]},{table:`session_state_events`,kind:`unique`,value:[`dedupe_key`]},{table:`session_state_events`,kind:`indexes`,value:4},{table:`session_state_events`,kind:`checks`,value:0},{table:`session_state_heads`,kind:`table`,value:null},{table:`session_state_heads`,kind:`column`,value:{name:`session_key`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`session_state_heads`,kind:`column`,value:{name:`agent_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`session_state_heads`,kind:`column`,value:{name:`last_sequence`,type:`bigint`,nullable:!1,identity:!1,default:null,position:3}},{table:`session_state_heads`,kind:`column`,value:{name:`pruned_max_sequence`,type:`bigint`,nullable:!1,identity:!1,default:`0`,position:4}},{table:`session_state_heads`,kind:`column`,value:{name:`updated_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:5}},{table:`session_state_heads`,kind:`primaryKey`,value:[`session_key`,`agent_id`]},{table:`session_state_heads`,kind:`indexes`,value:1},{table:`session_state_heads`,kind:`checks`,value:0},{table:`session_upstream_links`,kind:`table`,value:null},{table:`session_upstream_links`,kind:`column`,value:{name:`session_key`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`session_upstream_links`,kind:`column`,value:{name:`agent_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`session_upstream_links`,kind:`column`,value:{name:`catalog_id`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`session_upstream_links`,kind:`column`,value:{name:`host_id`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`session_upstream_links`,kind:`column`,value:{name:`thread_id`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`session_upstream_links`,kind:`column`,value:{name:`upstream_kind`,type:`text`,nullable:!1,identity:!1,default:null,position:6}},{table:`session_upstream_links`,kind:`column`,value:{name:`upstream_ref_json`,type:`text`,nullable:!0,identity:!1,default:null,position:7}},{table:`session_upstream_links`,kind:`column`,value:{name:`last_marker_json`,type:`text`,nullable:!0,identity:!1,default:null,position:8}},{table:`session_upstream_links`,kind:`column`,value:{name:`last_scanned_at`,type:`bigint`,nullable:!0,identity:!1,default:null,position:9}},{table:`session_upstream_links`,kind:`column`,value:{name:`created_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:10}},{table:`session_upstream_links`,kind:`column`,value:{name:`updated_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:11}},{table:`session_upstream_links`,kind:`primaryKey`,value:[`session_key`,`agent_id`]},{table:`session_upstream_links`,kind:`indexes`,value:2},{table:`session_upstream_links`,kind:`checks`,value:0},{table:`session_watch_cursors`,kind:`table`,value:null},{table:`session_watch_cursors`,kind:`column`,value:{name:`watcher_session_key`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`session_watch_cursors`,kind:`column`,value:{name:`watcher_store_path`,type:`text`,nullable:!0,identity:!1,default:null,position:2}},{table:`session_watch_cursors`,kind:`column`,value:{name:`target_session_key`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`session_watch_cursors`,kind:`column`,value:{name:`last_seen_sequence`,type:`bigint`,nullable:!1,identity:!1,default:`0`,position:4}},{table:`session_watch_cursors`,kind:`column`,value:{name:`notified_sequence`,type:`bigint`,nullable:!1,identity:!1,default:`0`,position:5}},{table:`session_watch_cursors`,kind:`column`,value:{name:`material_sequence`,type:`bigint`,nullable:!1,identity:!1,default:`0`,position:6}},{table:`session_watch_cursors`,kind:`column`,value:{name:`provenance`,type:`text`,nullable:!1,identity:!1,default:`'explicit'`,position:7}},{table:`session_watch_cursors`,kind:`column`,value:{name:`updated_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:8}},{table:`session_watch_cursors`,kind:`primaryKey`,value:[`watcher_session_key`,`target_session_key`]},{table:`session_watch_cursors`,kind:`indexes`,value:2},{table:`session_watch_cursors`,kind:`checks`,value:1},{table:`skill_library_entries`,kind:`table`,value:null},{table:`skill_library_entries`,kind:`column`,value:{name:`skill_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`skill_library_entries`,kind:`column`,value:{name:`owner_profile_id`,type:`text`,nullable:!0,identity:!1,default:null,position:2}},{table:`skill_library_entries`,kind:`column`,value:{name:`author_profile_id`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`skill_library_entries`,kind:`column`,value:{name:`slug`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`skill_library_entries`,kind:`column`,value:{name:`current_revision`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`skill_library_entries`,kind:`column`,value:{name:`shared`,type:`bigint`,nullable:!1,identity:!1,default:null,position:6}},{table:`skill_library_entries`,kind:`column`,value:{name:`enabled`,type:`bigint`,nullable:!1,identity:!1,default:null,position:7}},{table:`skill_library_entries`,kind:`column`,value:{name:`removed`,type:`bigint`,nullable:!1,identity:!1,default:null,position:8}},{table:`skill_library_entries`,kind:`column`,value:{name:`created_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:9}},{table:`skill_library_entries`,kind:`column`,value:{name:`updated_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:10}},{table:`skill_library_entries`,kind:`primaryKey`,value:[`skill_id`]},{table:`skill_library_entries`,kind:`indexes`,value:1},{table:`skill_library_entries`,kind:`checks`,value:0},{table:`skill_library_events`,kind:`table`,value:null},{table:`skill_library_events`,kind:`column`,value:{name:`event_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`skill_library_events`,kind:`column`,value:{name:`skill_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`skill_library_events`,kind:`column`,value:{name:`revision`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`skill_library_events`,kind:`column`,value:{name:`action`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`skill_library_events`,kind:`column`,value:{name:`actor_profile_id`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`skill_library_events`,kind:`column`,value:{name:`created_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:6}},{table:`skill_library_events`,kind:`primaryKey`,value:[`event_id`]},{table:`skill_library_events`,kind:`indexes`,value:1},{table:`skill_library_events`,kind:`checks`,value:0},{table:`skill_library_revisions`,kind:`table`,value:null},{table:`skill_library_revisions`,kind:`column`,value:{name:`skill_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`skill_library_revisions`,kind:`column`,value:{name:`revision`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`skill_library_revisions`,kind:`column`,value:{name:`description`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`skill_library_revisions`,kind:`column`,value:{name:`files_json`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`skill_library_revisions`,kind:`column`,value:{name:`created_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:5}},{table:`skill_library_revisions`,kind:`primaryKey`,value:[`skill_id`,`revision`]},{table:`skill_library_revisions`,kind:`indexes`,value:1},{table:`skill_library_revisions`,kind:`checks`,value:0},{table:`skill_library_uploads`,kind:`table`,value:null},{table:`skill_library_uploads`,kind:`column`,value:{name:`upload_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`skill_library_uploads`,kind:`column`,value:{name:`owner_profile_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`skill_library_uploads`,kind:`column`,value:{name:`slug`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`skill_library_uploads`,kind:`column`,value:{name:`size_bytes`,type:`bigint`,nullable:!1,identity:!1,default:null,position:4}},{table:`skill_library_uploads`,kind:`column`,value:{name:`sha256`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`skill_library_uploads`,kind:`column`,value:{name:`archive_blob`,type:`bytea`,nullable:!1,identity:!1,default:null,position:6}},{table:`skill_library_uploads`,kind:`column`,value:{name:`expires_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:7}},{table:`skill_library_uploads`,kind:`column`,value:{name:`published_skill_id`,type:`text`,nullable:!0,identity:!1,default:null,position:8}},{table:`skill_library_uploads`,kind:`primaryKey`,value:[`upload_id`]},{table:`skill_library_uploads`,kind:`indexes`,value:1},{table:`skill_library_uploads`,kind:`checks`,value:0},{table:`skill_upload_chunks`,kind:`table`,value:null},{table:`skill_upload_chunks`,kind:`column`,value:{name:`upload_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`skill_upload_chunks`,kind:`column`,value:{name:`byte_offset`,type:`bigint`,nullable:!1,identity:!1,default:null,position:2}},{table:`skill_upload_chunks`,kind:`column`,value:{name:`size_bytes`,type:`bigint`,nullable:!1,identity:!1,default:null,position:3}},{table:`skill_upload_chunks`,kind:`column`,value:{name:`chunk_blob`,type:`bytea`,nullable:!1,identity:!1,default:null,position:4}},{table:`skill_upload_chunks`,kind:`primaryKey`,value:[`upload_id`,`byte_offset`]},{table:`skill_upload_chunks`,kind:`foreignKey`,value:{columns:[`upload_id`],target:`skill_uploads`,targetColumns:[`upload_id`],onUpdate:`NO ACTION`,onDelete:`CASCADE`,deferrable:!1,deferred:!1}},{table:`skill_upload_chunks`,kind:`indexes`,value:1},{table:`skill_upload_chunks`,kind:`checks`,value:3},{table:`skill_uploads`,kind:`table`,value:null},{table:`skill_uploads`,kind:`column`,value:{name:`upload_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`skill_uploads`,kind:`column`,value:{name:`kind`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`skill_uploads`,kind:`column`,value:{name:`slug`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`skill_uploads`,kind:`column`,value:{name:`force`,type:`bigint`,nullable:!1,identity:!1,default:null,position:4}},{table:`skill_uploads`,kind:`column`,value:{name:`size_bytes`,type:`bigint`,nullable:!1,identity:!1,default:null,position:5}},{table:`skill_uploads`,kind:`column`,value:{name:`sha256`,type:`text`,nullable:!0,identity:!1,default:null,position:6}},{table:`skill_uploads`,kind:`column`,value:{name:`actual_sha256`,type:`text`,nullable:!0,identity:!1,default:null,position:7}},{table:`skill_uploads`,kind:`column`,value:{name:`received_bytes`,type:`bigint`,nullable:!1,identity:!1,default:null,position:8}},{table:`skill_uploads`,kind:`column`,value:{name:`archive_blob`,type:`bytea`,nullable:!1,identity:!1,default:null,position:9}},{table:`skill_uploads`,kind:`column`,value:{name:`created_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:10}},{table:`skill_uploads`,kind:`column`,value:{name:`expires_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:11}},{table:`skill_uploads`,kind:`column`,value:{name:`committed`,type:`bigint`,nullable:!1,identity:!1,default:null,position:12}},{table:`skill_uploads`,kind:`column`,value:{name:`committed_at`,type:`bigint`,nullable:!0,identity:!1,default:null,position:13}},{table:`skill_uploads`,kind:`column`,value:{name:`idempotency_key_hash`,type:`text`,nullable:!0,identity:!1,default:null,position:14}},{table:`skill_uploads`,kind:`primaryKey`,value:[`upload_id`]},{table:`skill_uploads`,kind:`unique`,value:[`idempotency_key_hash`]},{table:`skill_uploads`,kind:`indexes`,value:4},{table:`skill_uploads`,kind:`checks`,value:0},{table:`skill_usage`,kind:`table`,value:null},{table:`skill_usage`,kind:`column`,value:{name:`skill_file`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`skill_usage`,kind:`column`,value:{name:`skill_key`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`skill_usage`,kind:`column`,value:{name:`skill_name`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`skill_usage`,kind:`column`,value:{name:`skill_source`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`skill_usage`,kind:`column`,value:{name:`first_used_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:5}},{table:`skill_usage`,kind:`column`,value:{name:`last_used_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:6}},{table:`skill_usage`,kind:`column`,value:{name:`use_count`,type:`bigint`,nullable:!1,identity:!1,default:null,position:7}},{table:`skill_usage`,kind:`column`,value:{name:`last_agent_id`,type:`text`,nullable:!0,identity:!1,default:null,position:8}},{table:`skill_usage`,kind:`primaryKey`,value:[`skill_file`]},{table:`skill_usage`,kind:`indexes`,value:1},{table:`skill_usage`,kind:`checks`,value:0},{table:`skill_workshop_changes`,kind:`table`,value:null},{table:`skill_workshop_changes`,kind:`column`,value:{name:`cursor_id`,type:`bigint`,nullable:!1,identity:!1,default:null,position:1}},{table:`skill_workshop_changes`,kind:`column`,value:{name:`change_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`skill_workshop_changes`,kind:`column`,value:{name:`agent_id`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`skill_workshop_changes`,kind:`column`,value:{name:`skill_name`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`skill_workshop_changes`,kind:`column`,value:{name:`action`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`skill_workshop_changes`,kind:`column`,value:{name:`actor`,type:`text`,nullable:!1,identity:!1,default:null,position:6}},{table:`skill_workshop_changes`,kind:`column`,value:{name:`summary`,type:`text`,nullable:!1,identity:!1,default:null,position:7}},{table:`skill_workshop_changes`,kind:`column`,value:{name:`version_id`,type:`text`,nullable:!0,identity:!1,default:null,position:8}},{table:`skill_workshop_changes`,kind:`column`,value:{name:`session_key`,type:`text`,nullable:!0,identity:!1,default:null,position:9}},{table:`skill_workshop_changes`,kind:`column`,value:{name:`run_id`,type:`text`,nullable:!0,identity:!1,default:null,position:10}},{table:`skill_workshop_changes`,kind:`column`,value:{name:`created_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:11}},{table:`skill_workshop_changes`,kind:`primaryKey`,value:[`change_id`]},{table:`skill_workshop_changes`,kind:`indexes`,value:3},{table:`skill_workshop_changes`,kind:`checks`,value:2},{table:`state_leases`,kind:`table`,value:null},{table:`state_leases`,kind:`column`,value:{name:`scope`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`state_leases`,kind:`column`,value:{name:`lease_key`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`state_leases`,kind:`column`,value:{name:`owner`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`state_leases`,kind:`column`,value:{name:`expires_at`,type:`bigint`,nullable:!0,identity:!1,default:null,position:4}},{table:`state_leases`,kind:`column`,value:{name:`heartbeat_at`,type:`bigint`,nullable:!0,identity:!1,default:null,position:5}},{table:`state_leases`,kind:`column`,value:{name:`payload_json`,type:`text`,nullable:!0,identity:!1,default:null,position:6}},{table:`state_leases`,kind:`column`,value:{name:`created_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:7}},{table:`state_leases`,kind:`column`,value:{name:`updated_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:8}},{table:`state_leases`,kind:`primaryKey`,value:[`scope`,`lease_key`]},{table:`state_leases`,kind:`indexes`,value:3},{table:`state_leases`,kind:`checks`,value:0},{table:`subagent_runs`,kind:`table`,value:null},{table:`subagent_runs`,kind:`column`,value:{name:`run_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`subagent_runs`,kind:`column`,value:{name:`child_session_key`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`subagent_runs`,kind:`column`,value:{name:`controller_session_key`,type:`text`,nullable:!0,identity:!1,default:null,position:3}},{table:`subagent_runs`,kind:`column`,value:{name:`controller_store_path`,type:`text`,nullable:!0,identity:!1,default:null,position:4}},{table:`subagent_runs`,kind:`column`,value:{name:`requester_session_key`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`subagent_runs`,kind:`column`,value:{name:`requester_store_path`,type:`text`,nullable:!0,identity:!1,default:null,position:6}},{table:`subagent_runs`,kind:`column`,value:{name:`created_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:7}},{table:`subagent_runs`,kind:`column`,value:{name:`payload_json`,type:`text`,nullable:!1,identity:!1,default:`'{}'`,position:8}},{table:`subagent_runs`,kind:`primaryKey`,value:[`run_id`]},{table:`subagent_runs`,kind:`indexes`,value:4},{table:`subagent_runs`,kind:`checks`,value:0},{table:`task_delivery_state`,kind:`table`,value:null},{table:`task_delivery_state`,kind:`column`,value:{name:`task_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`task_delivery_state`,kind:`column`,value:{name:`requester_origin_json`,type:`text`,nullable:!0,identity:!1,default:null,position:2}},{table:`task_delivery_state`,kind:`column`,value:{name:`last_notified_event_at`,type:`bigint`,nullable:!0,identity:!1,default:null,position:3}},{table:`task_delivery_state`,kind:`primaryKey`,value:[`task_id`]},{table:`task_delivery_state`,kind:`foreignKey`,value:{columns:[`task_id`],target:`task_runs`,targetColumns:[`task_id`],onUpdate:`NO ACTION`,onDelete:`CASCADE`,deferrable:!1,deferred:!1}},{table:`task_delivery_state`,kind:`indexes`,value:1},{table:`task_delivery_state`,kind:`checks`,value:0},{table:`task_runs`,kind:`table`,value:null},{table:`task_runs`,kind:`column`,value:{name:`task_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`task_runs`,kind:`column`,value:{name:`runtime`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`task_runs`,kind:`column`,value:{name:`task_kind`,type:`text`,nullable:!0,identity:!1,default:null,position:3}},{table:`task_runs`,kind:`column`,value:{name:`source_id`,type:`text`,nullable:!0,identity:!1,default:null,position:4}},{table:`task_runs`,kind:`column`,value:{name:`requester_session_key`,type:`text`,nullable:!0,identity:!1,default:null,position:5}},{table:`task_runs`,kind:`column`,value:{name:`owner_key`,type:`text`,nullable:!1,identity:!1,default:null,position:6}},{table:`task_runs`,kind:`column`,value:{name:`scope_kind`,type:`text`,nullable:!1,identity:!1,default:null,position:7}},{table:`task_runs`,kind:`column`,value:{name:`child_session_key`,type:`text`,nullable:!0,identity:!1,default:null,position:8}},{table:`task_runs`,kind:`column`,value:{name:`parent_flow_id`,type:`text`,nullable:!0,identity:!1,default:null,position:9}},{table:`task_runs`,kind:`column`,value:{name:`parent_task_id`,type:`text`,nullable:!0,identity:!1,default:null,position:10}},{table:`task_runs`,kind:`column`,value:{name:`agent_id`,type:`text`,nullable:!0,identity:!1,default:null,position:11}},{table:`task_runs`,kind:`column`,value:{name:`requester_agent_id`,type:`text`,nullable:!0,identity:!1,default:null,position:12}},{table:`task_runs`,kind:`column`,value:{name:`run_id`,type:`text`,nullable:!0,identity:!1,default:null,position:13}},{table:`task_runs`,kind:`column`,value:{name:`execution_owner_host`,type:`text`,nullable:!0,identity:!1,default:null,position:14}},{table:`task_runs`,kind:`column`,value:{name:`execution_owner_pid`,type:`bigint`,nullable:!0,identity:!1,default:null,position:15}},{table:`task_runs`,kind:`column`,value:{name:`execution_owner_start_identity`,type:`bigint`,nullable:!0,identity:!1,default:null,position:16}},{table:`task_runs`,kind:`column`,value:{name:`label`,type:`text`,nullable:!0,identity:!1,default:null,position:17}},{table:`task_runs`,kind:`column`,value:{name:`task`,type:`text`,nullable:!1,identity:!1,default:null,position:18}},{table:`task_runs`,kind:`column`,value:{name:`status`,type:`text`,nullable:!1,identity:!1,default:null,position:19}},{table:`task_runs`,kind:`column`,value:{name:`delivery_status`,type:`text`,nullable:!1,identity:!1,default:null,position:20}},{table:`task_runs`,kind:`column`,value:{name:`notify_policy`,type:`text`,nullable:!1,identity:!1,default:null,position:21}},{table:`task_runs`,kind:`column`,value:{name:`created_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:22}},{table:`task_runs`,kind:`column`,value:{name:`started_at`,type:`bigint`,nullable:!0,identity:!1,default:null,position:23}},{table:`task_runs`,kind:`column`,value:{name:`ended_at`,type:`bigint`,nullable:!0,identity:!1,default:null,position:24}},{table:`task_runs`,kind:`column`,value:{name:`last_event_at`,type:`bigint`,nullable:!0,identity:!1,default:null,position:25}},{table:`task_runs`,kind:`column`,value:{name:`cleanup_after`,type:`bigint`,nullable:!0,identity:!1,default:null,position:26}},{table:`task_runs`,kind:`column`,value:{name:`tool_use_count`,type:`bigint`,nullable:!0,identity:!1,default:null,position:27}},{table:`task_runs`,kind:`column`,value:{name:`last_tool_name`,type:`text`,nullable:!0,identity:!1,default:null,position:28}},{table:`task_runs`,kind:`column`,value:{name:`error`,type:`text`,nullable:!0,identity:!1,default:null,position:29}},{table:`task_runs`,kind:`column`,value:{name:`progress_summary`,type:`text`,nullable:!0,identity:!1,default:null,position:30}},{table:`task_runs`,kind:`column`,value:{name:`terminal_summary`,type:`text`,nullable:!0,identity:!1,default:null,position:31}},{table:`task_runs`,kind:`column`,value:{name:`terminal_outcome`,type:`text`,nullable:!0,identity:!1,default:null,position:32}},{table:`task_runs`,kind:`column`,value:{name:`detail_json`,type:`text`,nullable:!0,identity:!1,default:null,position:33}},{table:`task_runs`,kind:`primaryKey`,value:[`task_id`]},{table:`task_runs`,kind:`indexes`,value:4},{table:`task_runs`,kind:`checks`,value:0},{table:`template_cron_refs`,kind:`table`,value:null},{table:`template_cron_refs`,kind:`column`,value:{name:`agent_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`template_cron_refs`,kind:`column`,value:{name:`manifest_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`template_cron_refs`,kind:`column`,value:{name:`schema_version`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`template_cron_refs`,kind:`column`,value:{name:`declaration_key`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`template_cron_refs`,kind:`column`,value:{name:`scheduler_job_id`,type:`text`,nullable:!0,identity:!1,default:null,position:5}},{table:`template_cron_refs`,kind:`column`,value:{name:`status`,type:`text`,nullable:!1,identity:!1,default:null,position:6}},{table:`template_cron_refs`,kind:`column`,value:{name:`job_json`,type:`text`,nullable:!1,identity:!1,default:null,position:7}},{table:`template_cron_refs`,kind:`column`,value:{name:`error`,type:`text`,nullable:!0,identity:!1,default:null,position:8}},{table:`template_cron_refs`,kind:`column`,value:{name:`created_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:9}},{table:`template_cron_refs`,kind:`column`,value:{name:`updated_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:10}},{table:`template_cron_refs`,kind:`primaryKey`,value:[`agent_id`,`manifest_id`]},{table:`template_cron_refs`,kind:`unique`,value:[`declaration_key`]},{table:`template_cron_refs`,kind:`unique`,value:[`scheduler_job_id`]},{table:`template_cron_refs`,kind:`indexes`,value:3},{table:`template_cron_refs`,kind:`checks`,value:0},{table:`template_installs`,kind:`table`,value:null},{table:`template_installs`,kind:`column`,value:{name:`agent_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`template_installs`,kind:`column`,value:{name:`schema_version`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`template_installs`,kind:`column`,value:{name:`source_kind`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`template_installs`,kind:`column`,value:{name:`template_name`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`template_installs`,kind:`column`,value:{name:`template_version`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`template_installs`,kind:`column`,value:{name:`package_root`,type:`text`,nullable:!1,identity:!1,default:null,position:6}},{table:`template_installs`,kind:`column`,value:{name:`manifest_path`,type:`text`,nullable:!1,identity:!1,default:null,position:7}},{table:`template_installs`,kind:`column`,value:{name:`integrity_kind`,type:`text`,nullable:!1,identity:!1,default:null,position:8}},{table:`template_installs`,kind:`column`,value:{name:`integrity`,type:`text`,nullable:!1,identity:!1,default:null,position:9}},{table:`template_installs`,kind:`column`,value:{name:`source_byte_length`,type:`bigint`,nullable:!1,identity:!1,default:null,position:10}},{table:`template_installs`,kind:`column`,value:{name:`manifest_schema_version`,type:`bigint`,nullable:!1,identity:!1,default:null,position:11}},{table:`template_installs`,kind:`column`,value:{name:`plan_integrity`,type:`text`,nullable:!1,identity:!1,default:null,position:12}},{table:`template_installs`,kind:`column`,value:{name:`workspace`,type:`text`,nullable:!1,identity:!1,default:null,position:13}},{table:`template_installs`,kind:`column`,value:{name:`agent_config_digest`,type:`text`,nullable:!1,identity:!1,default:null,position:14}},{table:`template_installs`,kind:`column`,value:{name:`agent_owned_paths_json`,type:`text`,nullable:!1,identity:!1,default:null,position:15}},{table:`template_installs`,kind:`column`,value:{name:`bootstrap_source_path`,type:`text`,nullable:!0,identity:!1,default:null,position:16}},{table:`template_installs`,kind:`column`,value:{name:`bootstrap_content_digest`,type:`text`,nullable:!0,identity:!1,default:null,position:17}},{table:`template_installs`,kind:`column`,value:{name:`status`,type:`text`,nullable:!1,identity:!1,default:null,position:18}},{table:`template_installs`,kind:`column`,value:{name:`added_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:19}},{table:`template_installs`,kind:`column`,value:{name:`updated_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:20}},{table:`template_installs`,kind:`primaryKey`,value:[`agent_id`]},{table:`template_installs`,kind:`unique`,value:[`workspace`]},{table:`template_installs`,kind:`indexes`,value:2},{table:`template_installs`,kind:`checks`,value:1},{table:`template_mcp_server_refs`,kind:`table`,value:null},{table:`template_mcp_server_refs`,kind:`column`,value:{name:`agent_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`template_mcp_server_refs`,kind:`column`,value:{name:`name`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`template_mcp_server_refs`,kind:`column`,value:{name:`schema_version`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`template_mcp_server_refs`,kind:`column`,value:{name:`config_digest`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`template_mcp_server_refs`,kind:`column`,value:{name:`relationship`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`template_mcp_server_refs`,kind:`column`,value:{name:`origin`,type:`text`,nullable:!1,identity:!1,default:null,position:6}},{table:`template_mcp_server_refs`,kind:`column`,value:{name:`independent_owner`,type:`bigint`,nullable:!1,identity:!1,default:`0`,position:7}},{table:`template_mcp_server_refs`,kind:`column`,value:{name:`status`,type:`text`,nullable:!1,identity:!1,default:null,position:8}},{table:`template_mcp_server_refs`,kind:`column`,value:{name:`error`,type:`text`,nullable:!0,identity:!1,default:null,position:9}},{table:`template_mcp_server_refs`,kind:`column`,value:{name:`created_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:10}},{table:`template_mcp_server_refs`,kind:`column`,value:{name:`updated_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:11}},{table:`template_mcp_server_refs`,kind:`primaryKey`,value:[`agent_id`,`name`]},{table:`template_mcp_server_refs`,kind:`indexes`,value:1},{table:`template_mcp_server_refs`,kind:`checks`,value:3},{table:`template_package_refs`,kind:`table`,value:null},{table:`template_package_refs`,kind:`column`,value:{name:`agent_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`template_package_refs`,kind:`column`,value:{name:`package_kind`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`template_package_refs`,kind:`column`,value:{name:`package_source`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`template_package_refs`,kind:`column`,value:{name:`package_ref`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`template_package_refs`,kind:`column`,value:{name:`package_version`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`template_package_refs`,kind:`column`,value:{name:`package_integrity`,type:`text`,nullable:!1,identity:!1,default:null,position:6}},{table:`template_package_refs`,kind:`column`,value:{name:`schema_version`,type:`text`,nullable:!1,identity:!1,default:null,position:7}},{table:`template_package_refs`,kind:`column`,value:{name:`template_name`,type:`text`,nullable:!1,identity:!1,default:null,position:8}},{table:`template_package_refs`,kind:`column`,value:{name:`package_status`,type:`text`,nullable:!1,identity:!1,default:null,position:9}},{table:`template_package_refs`,kind:`column`,value:{name:`relationship`,type:`text`,nullable:!1,identity:!1,default:null,position:10}},{table:`template_package_refs`,kind:`column`,value:{name:`origin`,type:`text`,nullable:!1,identity:!1,default:null,position:11}},{table:`template_package_refs`,kind:`column`,value:{name:`independent_owner`,type:`bigint`,nullable:!1,identity:!1,default:null,position:12}},{table:`template_package_refs`,kind:`column`,value:{name:`extension_id`,type:`text`,nullable:!0,identity:!1,default:null,position:13}},{table:`template_package_refs`,kind:`column`,value:{name:`extension_format`,type:`text`,nullable:!0,identity:!1,default:null,position:14}},{table:`template_package_refs`,kind:`column`,value:{name:`extension_detected_format`,type:`text`,nullable:!0,identity:!1,default:null,position:15}},{table:`template_package_refs`,kind:`column`,value:{name:`extension_mapped_json`,type:`text`,nullable:!0,identity:!1,default:null,position:16}},{table:`template_package_refs`,kind:`column`,value:{name:`extension_unavailable_json`,type:`text`,nullable:!0,identity:!1,default:null,position:17}},{table:`template_package_refs`,kind:`column`,value:{name:`extension_adapter_identity`,type:`text`,nullable:!0,identity:!1,default:null,position:18}},{table:`template_package_refs`,kind:`column`,value:{name:`installed_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:19}},{table:`template_package_refs`,kind:`column`,value:{name:`updated_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:20}},{table:`template_package_refs`,kind:`primaryKey`,value:[`agent_id`,`package_kind`,`package_source`,`package_ref`,`package_version`]},{table:`template_package_refs`,kind:`indexes`,value:1},{table:`template_package_refs`,kind:`checks`,value:3},{table:`template_workspace_files`,kind:`table`,value:null},{table:`template_workspace_files`,kind:`column`,value:{name:`agent_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`template_workspace_files`,kind:`column`,value:{name:`target_path`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`template_workspace_files`,kind:`column`,value:{name:`schema_version`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`template_workspace_files`,kind:`column`,value:{name:`workspace`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`template_workspace_files`,kind:`column`,value:{name:`source_path`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`template_workspace_files`,kind:`column`,value:{name:`content_digest`,type:`text`,nullable:!1,identity:!1,default:null,position:6}},{table:`template_workspace_files`,kind:`column`,value:{name:`status`,type:`text`,nullable:!1,identity:!1,default:null,position:7}},{table:`template_workspace_files`,kind:`column`,value:{name:`created_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:8}},{table:`template_workspace_files`,kind:`column`,value:{name:`updated_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:9}},{table:`template_workspace_files`,kind:`primaryKey`,value:[`agent_id`,`target_path`]},{table:`template_workspace_files`,kind:`indexes`,value:1},{table:`template_workspace_files`,kind:`checks`,value:0},{table:`update_runs`,kind:`table`,value:null},{table:`update_runs`,kind:`column`,value:{name:`run_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`update_runs`,kind:`column`,value:{name:`created_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:2}},{table:`update_runs`,kind:`column`,value:{name:`updated_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:3}},{table:`update_runs`,kind:`column`,value:{name:`trigger`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`update_runs`,kind:`column`,value:{name:`phase`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`update_runs`,kind:`column`,value:{name:`status`,type:`text`,nullable:!1,identity:!1,default:null,position:6}},{table:`update_runs`,kind:`column`,value:{name:`reason`,type:`text`,nullable:!0,identity:!1,default:null,position:7}},{table:`update_runs`,kind:`column`,value:{name:`origin_json`,type:`text`,nullable:!1,identity:!1,default:null,position:8}},{table:`update_runs`,kind:`column`,value:{name:`target_json`,type:`text`,nullable:!1,identity:!1,default:null,position:9}},{table:`update_runs`,kind:`column`,value:{name:`before_json`,type:`text`,nullable:!1,identity:!1,default:null,position:10}},{table:`update_runs`,kind:`column`,value:{name:`after_json`,type:`text`,nullable:!1,identity:!1,default:null,position:11}},{table:`update_runs`,kind:`column`,value:{name:`steps_json`,type:`text`,nullable:!1,identity:!1,default:null,position:12}},{table:`update_runs`,kind:`column`,value:{name:`verification_json`,type:`text`,nullable:!1,identity:!1,default:null,position:13}},{table:`update_runs`,kind:`column`,value:{name:`repair_json`,type:`text`,nullable:!1,identity:!1,default:null,position:14}},{table:`update_runs`,kind:`column`,value:{name:`confirmed_at_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:15}},{table:`update_runs`,kind:`column`,value:{name:`finished_at_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:16}},{table:`update_runs`,kind:`column`,value:{name:`downtime_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:17}},{table:`update_runs`,kind:`primaryKey`,value:[`run_id`]},{table:`update_runs`,kind:`indexes`,value:3},{table:`update_runs`,kind:`checks`,value:11},{table:`user_background_images`,kind:`table`,value:null},{table:`user_background_images`,kind:`column`,value:{name:`profile_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`user_background_images`,kind:`column`,value:{name:`asset_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`user_background_images`,kind:`column`,value:{name:`image`,type:`bytea`,nullable:!1,identity:!1,default:null,position:3}},{table:`user_background_images`,kind:`column`,value:{name:`width`,type:`bigint`,nullable:!1,identity:!1,default:null,position:4}},{table:`user_background_images`,kind:`column`,value:{name:`height`,type:`bigint`,nullable:!1,identity:!1,default:null,position:5}},{table:`user_background_images`,kind:`primaryKey`,value:[`profile_id`]},{table:`user_background_images`,kind:`unique`,value:[`asset_id`]},{table:`user_background_images`,kind:`foreignKey`,value:{columns:[`profile_id`],target:`user_profiles`,targetColumns:[`id`],onUpdate:`NO ACTION`,onDelete:`CASCADE`,deferrable:!1,deferred:!1}},{table:`user_background_images`,kind:`indexes`,value:2},{table:`user_background_images`,kind:`checks`,value:3},{table:`user_preferences`,kind:`table`,value:null},{table:`user_preferences`,kind:`column`,value:{name:`profile_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`user_preferences`,kind:`column`,value:{name:`pref_key`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`user_preferences`,kind:`column`,value:{name:`value_json`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`user_preferences`,kind:`column`,value:{name:`updated_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:4}},{table:`user_preferences`,kind:`primaryKey`,value:[`profile_id`,`pref_key`]},{table:`user_preferences`,kind:`indexes`,value:1},{table:`user_preferences`,kind:`checks`,value:0},{table:`user_profile_emails`,kind:`table`,value:null},{table:`user_profile_emails`,kind:`column`,value:{name:`email`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`user_profile_emails`,kind:`column`,value:{name:`profile_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`user_profile_emails`,kind:`column`,value:{name:`binding_id`,type:`text`,nullable:!0,identity:!1,default:null,position:3}},{table:`user_profile_emails`,kind:`column`,value:{name:`created_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:4}},{table:`user_profile_emails`,kind:`primaryKey`,value:[`email`]},{table:`user_profile_emails`,kind:`indexes`,value:2},{table:`user_profile_emails`,kind:`checks`,value:0},{table:`user_profile_identities`,kind:`table`,value:null},{table:`user_profile_identities`,kind:`column`,value:{name:`provider`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`user_profile_identities`,kind:`column`,value:{name:`subject`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`user_profile_identities`,kind:`column`,value:{name:`profile_id`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`user_profile_identities`,kind:`column`,value:{name:`canonical_login`,type:`text`,nullable:!0,identity:!1,default:null,position:4}},{table:`user_profile_identities`,kind:`column`,value:{name:`verified_email_json`,type:`text`,nullable:!0,identity:!1,default:null,position:5}},{table:`user_profile_identities`,kind:`column`,value:{name:`created_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:6}},{table:`user_profile_identities`,kind:`column`,value:{name:`authorization_id`,type:`text`,nullable:!0,identity:!1,default:null,position:7}},{table:`user_profile_identities`,kind:`column`,value:{name:`authorization_basis_json`,type:`text`,nullable:!0,identity:!1,default:null,position:8}},{table:`user_profile_identities`,kind:`primaryKey`,value:[`provider`,`subject`]},{table:`user_profile_identities`,kind:`indexes`,value:3},{table:`user_profile_identities`,kind:`checks`,value:0},{table:`user_profiles`,kind:`table`,value:null},{table:`user_profiles`,kind:`column`,value:{name:`id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`user_profiles`,kind:`column`,value:{name:`display_name`,type:`text`,nullable:!0,identity:!1,default:null,position:2}},{table:`user_profiles`,kind:`column`,value:{name:`primary_github_account_id`,type:`bigint`,nullable:!0,identity:!1,default:null,position:3}},{table:`user_profiles`,kind:`column`,value:{name:`avatar`,type:`bytea`,nullable:!0,identity:!1,default:null,position:4}},{table:`user_profiles`,kind:`column`,value:{name:`avatar_mime`,type:`text`,nullable:!0,identity:!1,default:null,position:5}},{table:`user_profiles`,kind:`column`,value:{name:`avatar_sha256`,type:`text`,nullable:!0,identity:!1,default:null,position:6}},{table:`user_profiles`,kind:`column`,value:{name:`merged_into`,type:`text`,nullable:!0,identity:!1,default:null,position:7}},{table:`user_profiles`,kind:`column`,value:{name:`role`,type:`text`,nullable:!0,identity:!1,default:null,position:8}},{table:`user_profiles`,kind:`column`,value:{name:`created_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:9}},{table:`user_profiles`,kind:`column`,value:{name:`updated_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:10}},{table:`user_profiles`,kind:`primaryKey`,value:[`id`]},{table:`user_profiles`,kind:`indexes`,value:1},{table:`user_profiles`,kind:`checks`,value:0},{table:`web_push_approval_deliveries`,kind:`table`,value:null},{table:`web_push_approval_deliveries`,kind:`column`,value:{name:`approval_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`web_push_approval_deliveries`,kind:`column`,value:{name:`subscription_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`web_push_approval_deliveries`,kind:`column`,value:{name:`device_id`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`web_push_approval_deliveries`,kind:`column`,value:{name:`user_profile_id`,type:`text`,nullable:!0,identity:!1,default:null,position:4}},{table:`web_push_approval_deliveries`,kind:`column`,value:{name:`prepared_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:5}},{table:`web_push_approval_deliveries`,kind:`primaryKey`,value:[`approval_id`,`subscription_id`]},{table:`web_push_approval_deliveries`,kind:`foreignKey`,value:{columns:[`subscription_id`],target:`web_push_subscriptions`,targetColumns:[`subscription_id`],onUpdate:`NO ACTION`,onDelete:`CASCADE`,deferrable:!1,deferred:!1}},{table:`web_push_approval_deliveries`,kind:`foreignKey`,value:{columns:[`approval_id`],target:`operator_approvals`,targetColumns:[`approval_id`],onUpdate:`NO ACTION`,onDelete:`CASCADE`,deferrable:!1,deferred:!1}},{table:`web_push_approval_deliveries`,kind:`indexes`,value:2},{table:`web_push_approval_deliveries`,kind:`checks`,value:0},{table:`web_push_subscriptions`,kind:`table`,value:null},{table:`web_push_subscriptions`,kind:`column`,value:{name:`endpoint_hash`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`web_push_subscriptions`,kind:`column`,value:{name:`subscription_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`web_push_subscriptions`,kind:`column`,value:{name:`endpoint`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`web_push_subscriptions`,kind:`column`,value:{name:`p256dh`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`web_push_subscriptions`,kind:`column`,value:{name:`auth`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`web_push_subscriptions`,kind:`column`,value:{name:`device_id`,type:`text`,nullable:!0,identity:!1,default:null,position:6}},{table:`web_push_subscriptions`,kind:`column`,value:{name:`user_profile_id`,type:`text`,nullable:!0,identity:!1,default:null,position:7}},{table:`web_push_subscriptions`,kind:`column`,value:{name:`preferences_json`,type:`text`,nullable:!0,identity:!1,default:null,position:8}},{table:`web_push_subscriptions`,kind:`column`,value:{name:`created_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:9}},{table:`web_push_subscriptions`,kind:`column`,value:{name:`updated_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:10}},{table:`web_push_subscriptions`,kind:`primaryKey`,value:[`endpoint_hash`]},{table:`web_push_subscriptions`,kind:`unique`,value:[`subscription_id`]},{table:`web_push_subscriptions`,kind:`indexes`,value:3},{table:`web_push_subscriptions`,kind:`checks`,value:0},{table:`worker_environment_credentials`,kind:`table`,value:null},{table:`worker_environment_credentials`,kind:`column`,value:{name:`environment_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`worker_environment_credentials`,kind:`column`,value:{name:`credential_hash`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`worker_environment_credentials`,kind:`column`,value:{name:`bundle_hash`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`worker_environment_credentials`,kind:`column`,value:{name:`session_id`,type:`text`,nullable:!0,identity:!1,default:null,position:4}},{table:`worker_environment_credentials`,kind:`column`,value:{name:`rpc_set_version`,type:`bigint`,nullable:!1,identity:!1,default:null,position:5}},{table:`worker_environment_credentials`,kind:`column`,value:{name:`owner_epoch`,type:`bigint`,nullable:!1,identity:!1,default:null,position:6}},{table:`worker_environment_credentials`,kind:`column`,value:{name:`expires_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:7}},{table:`worker_environment_credentials`,kind:`column`,value:{name:`delivered_at_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:8}},{table:`worker_environment_credentials`,kind:`primaryKey`,value:[`environment_id`]},{table:`worker_environment_credentials`,kind:`unique`,value:[`credential_hash`]},{table:`worker_environment_credentials`,kind:`foreignKey`,value:{columns:[`environment_id`],target:`worker_environments`,targetColumns:[`environment_id`],onUpdate:`NO ACTION`,onDelete:`CASCADE`,deferrable:!1,deferred:!1}},{table:`worker_environment_credentials`,kind:`indexes`,value:2},{table:`worker_environment_credentials`,kind:`checks`,value:4},{table:`worker_environment_session_attachments`,kind:`table`,value:null},{table:`worker_environment_session_attachments`,kind:`column`,value:{name:`session_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`worker_environment_session_attachments`,kind:`column`,value:{name:`session_key`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`worker_environment_session_attachments`,kind:`column`,value:{name:`agent_id`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`worker_environment_session_attachments`,kind:`column`,value:{name:`session_lifecycle_revision`,type:`text`,nullable:!0,identity:!1,default:null,position:4}},{table:`worker_environment_session_attachments`,kind:`column`,value:{name:`environment_id`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`worker_environment_session_attachments`,kind:`column`,value:{name:`generation`,type:`bigint`,nullable:!1,identity:!1,default:null,position:6}},{table:`worker_environment_session_attachments`,kind:`column`,value:{name:`created_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:7}},{table:`worker_environment_session_attachments`,kind:`column`,value:{name:`last_used_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:8}},{table:`worker_environment_session_attachments`,kind:`column`,value:{name:`closed_at_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:9}},{table:`worker_environment_session_attachments`,kind:`primaryKey`,value:[`session_id`]},{table:`worker_environment_session_attachments`,kind:`unique`,value:[`environment_id`]},{table:`worker_environment_session_attachments`,kind:`foreignKey`,value:{columns:[`environment_id`],target:`worker_environments`,targetColumns:[`environment_id`],onUpdate:`NO ACTION`,onDelete:`CASCADE`,deferrable:!1,deferred:!1}},{table:`worker_environment_session_attachments`,kind:`indexes`,value:3},{table:`worker_environment_session_attachments`,kind:`checks`,value:1},{table:`worker_environment_ssh_fallback_ports`,kind:`table`,value:null},{table:`worker_environment_ssh_fallback_ports`,kind:`column`,value:{name:`environment_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`worker_environment_ssh_fallback_ports`,kind:`column`,value:{name:`position`,type:`bigint`,nullable:!1,identity:!1,default:null,position:2}},{table:`worker_environment_ssh_fallback_ports`,kind:`column`,value:{name:`port`,type:`bigint`,nullable:!1,identity:!1,default:null,position:3}},{table:`worker_environment_ssh_fallback_ports`,kind:`primaryKey`,value:[`environment_id`,`position`]},{table:`worker_environment_ssh_fallback_ports`,kind:`unique`,value:[`environment_id`,`port`]},{table:`worker_environment_ssh_fallback_ports`,kind:`foreignKey`,value:{columns:[`environment_id`],target:`worker_environments`,targetColumns:[`environment_id`],onUpdate:`NO ACTION`,onDelete:`CASCADE`,deferrable:!1,deferred:!1}},{table:`worker_environment_ssh_fallback_ports`,kind:`indexes`,value:2},{table:`worker_environment_ssh_fallback_ports`,kind:`checks`,value:2},{table:`worker_environments`,kind:`table`,value:null},{table:`worker_environments`,kind:`column`,value:{name:`environment_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`worker_environments`,kind:`column`,value:{name:`provider_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`worker_environments`,kind:`column`,value:{name:`profile_id`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`worker_environments`,kind:`column`,value:{name:`profile_snapshot_json`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`worker_environments`,kind:`column`,value:{name:`last_activated_at_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:5}},{table:`worker_environments`,kind:`column`,value:{name:`preparation_key`,type:`text`,nullable:!0,identity:!1,default:null,position:6}},{table:`worker_environments`,kind:`column`,value:{name:`preparation_purpose`,type:`text`,nullable:!0,identity:!1,default:null,position:7}},{table:`worker_environments`,kind:`column`,value:{name:`preparation_demand_at_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:8}},{table:`worker_environments`,kind:`column`,value:{name:`preparation_expires_at_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:9}},{table:`worker_environments`,kind:`column`,value:{name:`preparation_consumed_at_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:10}},{table:`worker_environments`,kind:`column`,value:{name:`provision_operation_id`,type:`text`,nullable:!1,identity:!1,default:null,position:11}},{table:`worker_environments`,kind:`column`,value:{name:`lease_id`,type:`text`,nullable:!0,identity:!1,default:null,position:12}},{table:`worker_environments`,kind:`column`,value:{name:`node_setup_id`,type:`text`,nullable:!0,identity:!1,default:null,position:13}},{table:`worker_environments`,kind:`column`,value:{name:`node_device_id`,type:`text`,nullable:!0,identity:!1,default:null,position:14}},{table:`worker_environments`,kind:`column`,value:{name:`ssh_host`,type:`text`,nullable:!0,identity:!1,default:null,position:15}},{table:`worker_environments`,kind:`column`,value:{name:`ssh_port`,type:`bigint`,nullable:!0,identity:!1,default:null,position:16}},{table:`worker_environments`,kind:`column`,value:{name:`ssh_user`,type:`text`,nullable:!0,identity:!1,default:null,position:17}},{table:`worker_environments`,kind:`column`,value:{name:`ssh_host_key`,type:`text`,nullable:!0,identity:!1,default:null,position:18}},{table:`worker_environments`,kind:`column`,value:{name:`ssh_key_ref_json`,type:`text`,nullable:!0,identity:!1,default:null,position:19}},{table:`worker_environments`,kind:`column`,value:{name:`desktop_json`,type:`text`,nullable:!0,identity:!1,default:null,position:20}},{table:`worker_environments`,kind:`column`,value:{name:`state`,type:`text`,nullable:!1,identity:!1,default:null,position:21}},{table:`worker_environments`,kind:`column`,value:{name:`bootstrap_bundle_hash`,type:`text`,nullable:!0,identity:!1,default:null,position:22}},{table:`worker_environments`,kind:`column`,value:{name:`bootstrap_openclaw_version`,type:`text`,nullable:!0,identity:!1,default:null,position:23}},{table:`worker_environments`,kind:`column`,value:{name:`bootstrap_protocol_features_json`,type:`text`,nullable:!0,identity:!1,default:null,position:24}},{table:`worker_environments`,kind:`column`,value:{name:`bootstrap_install_kind`,type:`text`,nullable:!0,identity:!1,default:null,position:25}},{table:`worker_environments`,kind:`column`,value:{name:`owner_epoch`,type:`bigint`,nullable:!1,identity:!1,default:`0`,position:26}},{table:`worker_environments`,kind:`column`,value:{name:`teardown_terminal_state`,type:`text`,nullable:!0,identity:!1,default:null,position:27}},{table:`worker_environments`,kind:`column`,value:{name:`attached_session_ids_json`,type:`text`,nullable:!1,identity:!1,default:`'[]'`,position:28}},{table:`worker_environments`,kind:`column`,value:{name:`created_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:29}},{table:`worker_environments`,kind:`column`,value:{name:`updated_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:30}},{table:`worker_environments`,kind:`column`,value:{name:`state_changed_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:31}},{table:`worker_environments`,kind:`column`,value:{name:`idle_since_at_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:32}},{table:`worker_environments`,kind:`column`,value:{name:`destroy_requested_at_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:33}},{table:`worker_environments`,kind:`column`,value:{name:`last_error`,type:`text`,nullable:!0,identity:!1,default:null,position:34}},{table:`worker_environments`,kind:`column`,value:{name:`shared_host`,type:`bigint`,nullable:!0,identity:!1,default:null,position:35}},{table:`worker_environments`,kind:`column`,value:{name:`resource_receipt_json`,type:`text`,nullable:!0,identity:!1,default:null,position:36}},{table:`worker_environments`,kind:`column`,value:{name:`retention_json`,type:`text`,nullable:!0,identity:!1,default:null,position:37}},{table:`worker_environments`,kind:`column`,value:{name:`provision_source_json`,type:`text`,nullable:!0,identity:!1,default:null,position:38}},{table:`worker_environments`,kind:`primaryKey`,value:[`environment_id`]},{table:`worker_environments`,kind:`unique`,value:[`provision_operation_id`]},{table:`worker_environments`,kind:`indexes`,value:4},{table:`worker_environments`,kind:`checks`,value:5},{table:`worker_inference_turns`,kind:`table`,value:null},{table:`worker_inference_turns`,kind:`column`,value:{name:`session_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`worker_inference_turns`,kind:`column`,value:{name:`run_epoch`,type:`bigint`,nullable:!1,identity:!1,default:null,position:2}},{table:`worker_inference_turns`,kind:`column`,value:{name:`run_id`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`worker_inference_turns`,kind:`column`,value:{name:`turn_id`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`worker_inference_turns`,kind:`column`,value:{name:`environment_id`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`worker_inference_turns`,kind:`column`,value:{name:`request_hash`,type:`text`,nullable:!1,identity:!1,default:null,position:6}},{table:`worker_inference_turns`,kind:`column`,value:{name:`state`,type:`text`,nullable:!1,identity:!1,default:null,position:7}},{table:`worker_inference_turns`,kind:`column`,value:{name:`terminal_json`,type:`text`,nullable:!0,identity:!1,default:null,position:8}},{table:`worker_inference_turns`,kind:`column`,value:{name:`created_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:9}},{table:`worker_inference_turns`,kind:`column`,value:{name:`updated_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:10}},{table:`worker_inference_turns`,kind:`primaryKey`,value:[`session_id`,`run_epoch`,`run_id`,`turn_id`]},{table:`worker_inference_turns`,kind:`foreignKey`,value:{columns:[`environment_id`],target:`worker_environments`,targetColumns:[`environment_id`],onUpdate:`NO ACTION`,onDelete:`CASCADE`,deferrable:!1,deferred:!1}},{table:`worker_inference_turns`,kind:`indexes`,value:2},{table:`worker_inference_turns`,kind:`checks`,value:5},{table:`worker_session_placement_moves`,kind:`table`,value:null},{table:`worker_session_placement_moves`,kind:`column`,value:{name:`operation_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`worker_session_placement_moves`,kind:`column`,value:{name:`session_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`worker_session_placement_moves`,kind:`column`,value:{name:`source_generation`,type:`bigint`,nullable:!1,identity:!1,default:null,position:3}},{table:`worker_session_placement_moves`,kind:`column`,value:{name:`source_environment_id`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`worker_session_placement_moves`,kind:`column`,value:{name:`source_owner_epoch`,type:`bigint`,nullable:!1,identity:!1,default:null,position:5}},{table:`worker_session_placement_moves`,kind:`column`,value:{name:`target_kind`,type:`text`,nullable:!1,identity:!1,default:null,position:6}},{table:`worker_session_placement_moves`,kind:`column`,value:{name:`target_id`,type:`text`,nullable:!0,identity:!1,default:null,position:7}},{table:`worker_session_placement_moves`,kind:`column`,value:{name:`target_machine_class`,type:`text`,nullable:!0,identity:!1,default:null,position:8}},{table:`worker_session_placement_moves`,kind:`column`,value:{name:`target_os`,type:`text`,nullable:!0,identity:!1,default:null,position:9}},{table:`worker_session_placement_moves`,kind:`column`,value:{name:`abandon_source`,type:`bigint`,nullable:!0,identity:!1,default:null,position:10}},{table:`worker_session_placement_moves`,kind:`column`,value:{name:`last_error`,type:`text`,nullable:!0,identity:!1,default:null,position:11}},{table:`worker_session_placement_moves`,kind:`column`,value:{name:`created_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:12}},{table:`worker_session_placement_moves`,kind:`column`,value:{name:`updated_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:13}},{table:`worker_session_placement_moves`,kind:`primaryKey`,value:[`operation_id`]},{table:`worker_session_placement_moves`,kind:`unique`,value:[`session_id`]},{table:`worker_session_placement_moves`,kind:`foreignKey`,value:{columns:[`session_id`],target:`worker_session_placements`,targetColumns:[`session_id`],onUpdate:`NO ACTION`,onDelete:`CASCADE`,deferrable:!1,deferred:!1}},{table:`worker_session_placement_moves`,kind:`indexes`,value:2},{table:`worker_session_placement_moves`,kind:`checks`,value:5},{table:`worker_session_placements`,kind:`table`,value:null},{table:`worker_session_placements`,kind:`column`,value:{name:`session_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`worker_session_placements`,kind:`column`,value:{name:`agent_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`worker_session_placements`,kind:`column`,value:{name:`session_key`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`worker_session_placements`,kind:`column`,value:{name:`execution_mode`,type:`text`,nullable:!0,identity:!1,default:null,position:4}},{table:`worker_session_placements`,kind:`column`,value:{name:`state`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`worker_session_placements`,kind:`column`,value:{name:`environment_id`,type:`text`,nullable:!0,identity:!1,default:null,position:6}},{table:`worker_session_placements`,kind:`column`,value:{name:`transition_generation`,type:`bigint`,nullable:!1,identity:!1,default:`0`,position:7}},{table:`worker_session_placements`,kind:`column`,value:{name:`active_owner_epoch`,type:`bigint`,nullable:!0,identity:!1,default:null,position:8}},{table:`worker_session_placements`,kind:`column`,value:{name:`workspace_base_manifest_ref`,type:`text`,nullable:!0,identity:!1,default:null,position:9}},{table:`worker_session_placements`,kind:`column`,value:{name:`remote_workspace_dir`,type:`text`,nullable:!0,identity:!1,default:null,position:10}},{table:`worker_session_placements`,kind:`column`,value:{name:`worker_bundle_hash`,type:`text`,nullable:!0,identity:!1,default:null,position:11}},{table:`worker_session_placements`,kind:`column`,value:{name:`last_transcript_ack_cursor`,type:`bigint`,nullable:!0,identity:!1,default:null,position:12}},{table:`worker_session_placements`,kind:`column`,value:{name:`last_live_event_ack_cursor`,type:`bigint`,nullable:!0,identity:!1,default:null,position:13}},{table:`worker_session_placements`,kind:`column`,value:{name:`recovery_error`,type:`text`,nullable:!0,identity:!1,default:null,position:14}},{table:`worker_session_placements`,kind:`column`,value:{name:`turn_claim_owner`,type:`text`,nullable:!0,identity:!1,default:null,position:15}},{table:`worker_session_placements`,kind:`column`,value:{name:`turn_claim_id`,type:`text`,nullable:!0,identity:!1,default:null,position:16}},{table:`worker_session_placements`,kind:`column`,value:{name:`turn_claim_run_id`,type:`text`,nullable:!0,identity:!1,default:null,position:17}},{table:`worker_session_placements`,kind:`column`,value:{name:`turn_claim_generation`,type:`bigint`,nullable:!0,identity:!1,default:null,position:18}},{table:`worker_session_placements`,kind:`column`,value:{name:`turn_claim_owner_epoch`,type:`bigint`,nullable:!0,identity:!1,default:null,position:19}},{table:`worker_session_placements`,kind:`column`,value:{name:`created_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:20}},{table:`worker_session_placements`,kind:`column`,value:{name:`updated_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:21}},{table:`worker_session_placements`,kind:`column`,value:{name:`state_changed_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:22}},{table:`worker_session_placements`,kind:`column`,value:{name:`terminal_reason`,type:`text`,nullable:!0,identity:!1,default:null,position:23}},{table:`worker_session_placements`,kind:`column`,value:{name:`terminal_at_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:24}},{table:`worker_session_placements`,kind:`primaryKey`,value:[`session_id`]},{table:`worker_session_placements`,kind:`indexes`,value:4},{table:`worker_session_placements`,kind:`checks`,value:12},{table:`worker_session_tool_operations`,kind:`table`,value:null},{table:`worker_session_tool_operations`,kind:`column`,value:{name:`source_session_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`worker_session_tool_operations`,kind:`column`,value:{name:`source_claim_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`worker_session_tool_operations`,kind:`column`,value:{name:`tool_call_id`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`worker_session_tool_operations`,kind:`column`,value:{name:`tool_name`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`worker_session_tool_operations`,kind:`column`,value:{name:`request_digest`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`worker_session_tool_operations`,kind:`column`,value:{name:`operation_seed`,type:`text`,nullable:!1,identity:!1,default:null,position:6}},{table:`worker_session_tool_operations`,kind:`column`,value:{name:`status`,type:`text`,nullable:!1,identity:!1,default:null,position:7}},{table:`worker_session_tool_operations`,kind:`column`,value:{name:`child_session_key`,type:`text`,nullable:!0,identity:!1,default:null,position:8}},{table:`worker_session_tool_operations`,kind:`column`,value:{name:`result_json`,type:`text`,nullable:!0,identity:!1,default:null,position:9}},{table:`worker_session_tool_operations`,kind:`column`,value:{name:`gateway_instance_id`,type:`text`,nullable:!1,identity:!1,default:null,position:10}},{table:`worker_session_tool_operations`,kind:`column`,value:{name:`created_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:11}},{table:`worker_session_tool_operations`,kind:`column`,value:{name:`updated_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:12}},{table:`worker_session_tool_operations`,kind:`primaryKey`,value:[`source_session_id`,`source_claim_id`,`tool_call_id`]},{table:`worker_session_tool_operations`,kind:`foreignKey`,value:{columns:[`source_session_id`],target:`worker_session_placements`,targetColumns:[`session_id`],onUpdate:`NO ACTION`,onDelete:`CASCADE`,deferrable:!1,deferred:!1}},{table:`worker_session_tool_operations`,kind:`indexes`,value:1},{table:`worker_session_tool_operations`,kind:`checks`,value:2},{table:`worker_transcript_commit_heads`,kind:`table`,value:null},{table:`worker_transcript_commit_heads`,kind:`column`,value:{name:`session_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`worker_transcript_commit_heads`,kind:`column`,value:{name:`run_epoch`,type:`bigint`,nullable:!1,identity:!1,default:null,position:2}},{table:`worker_transcript_commit_heads`,kind:`column`,value:{name:`environment_id`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`worker_transcript_commit_heads`,kind:`column`,value:{name:`next_seq`,type:`bigint`,nullable:!1,identity:!1,default:null,position:4}},{table:`worker_transcript_commit_heads`,kind:`column`,value:{name:`updated_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:5}},{table:`worker_transcript_commit_heads`,kind:`primaryKey`,value:[`session_id`,`run_epoch`]},{table:`worker_transcript_commit_heads`,kind:`indexes`,value:1},{table:`worker_transcript_commit_heads`,kind:`checks`,value:3},{table:`worker_transcript_commits`,kind:`table`,value:null},{table:`worker_transcript_commits`,kind:`column`,value:{name:`session_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`worker_transcript_commits`,kind:`column`,value:{name:`run_epoch`,type:`bigint`,nullable:!1,identity:!1,default:null,position:2}},{table:`worker_transcript_commits`,kind:`column`,value:{name:`seq`,type:`bigint`,nullable:!1,identity:!1,default:null,position:3}},{table:`worker_transcript_commits`,kind:`column`,value:{name:`request_hash`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`worker_transcript_commits`,kind:`column`,value:{name:`state`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`worker_transcript_commits`,kind:`column`,value:{name:`result_json`,type:`text`,nullable:!0,identity:!1,default:null,position:6}},{table:`worker_transcript_commits`,kind:`column`,value:{name:`created_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:7}},{table:`worker_transcript_commits`,kind:`column`,value:{name:`updated_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:8}},{table:`worker_transcript_commits`,kind:`primaryKey`,value:[`session_id`,`run_epoch`,`seq`]},{table:`worker_transcript_commits`,kind:`foreignKey`,value:{columns:[`session_id`,`run_epoch`],target:`worker_transcript_commit_heads`,targetColumns:[`session_id`,`run_epoch`],onUpdate:`NO ACTION`,onDelete:`CASCADE`,deferrable:!1,deferred:!1}},{table:`worker_transcript_commits`,kind:`indexes`,value:1},{table:`worker_transcript_commits`,kind:`checks`,value:6},{table:`worker_turn_tool_authorities`,kind:`table`,value:null},{table:`worker_turn_tool_authorities`,kind:`column`,value:{name:`session_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`worker_turn_tool_authorities`,kind:`column`,value:{name:`environment_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`worker_turn_tool_authorities`,kind:`column`,value:{name:`owner_epoch`,type:`bigint`,nullable:!1,identity:!1,default:null,position:3}},{table:`worker_turn_tool_authorities`,kind:`column`,value:{name:`placement_generation`,type:`bigint`,nullable:!1,identity:!1,default:null,position:4}},{table:`worker_turn_tool_authorities`,kind:`column`,value:{name:`claim_id`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`worker_turn_tool_authorities`,kind:`column`,value:{name:`run_id`,type:`text`,nullable:!1,identity:!1,default:null,position:6}},{table:`worker_turn_tool_authorities`,kind:`column`,value:{name:`tool_names_json`,type:`text`,nullable:!1,identity:!1,default:null,position:7}},{table:`worker_turn_tool_authorities`,kind:`column`,value:{name:`updated_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:8}},{table:`worker_turn_tool_authorities`,kind:`primaryKey`,value:[`session_id`]},{table:`worker_turn_tool_authorities`,kind:`foreignKey`,value:{columns:[`session_id`],target:`worker_session_placements`,targetColumns:[`session_id`],onUpdate:`NO ACTION`,onDelete:`CASCADE`,deferrable:!1,deferred:!1}},{table:`worker_turn_tool_authorities`,kind:`indexes`,value:1},{table:`worker_turn_tool_authorities`,kind:`checks`,value:2},{table:`worker_workspace_pending_results`,kind:`table`,value:null},{table:`worker_workspace_pending_results`,kind:`column`,value:{name:`session_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`worker_workspace_pending_results`,kind:`column`,value:{name:`environment_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`worker_workspace_pending_results`,kind:`column`,value:{name:`owner_epoch`,type:`bigint`,nullable:!1,identity:!1,default:null,position:3}},{table:`worker_workspace_pending_results`,kind:`column`,value:{name:`placement_generation`,type:`bigint`,nullable:!1,identity:!1,default:null,position:4}},{table:`worker_workspace_pending_results`,kind:`column`,value:{name:`claim_id`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`worker_workspace_pending_results`,kind:`column`,value:{name:`run_id`,type:`text`,nullable:!1,identity:!1,default:null,position:6}},{table:`worker_workspace_pending_results`,kind:`column`,value:{name:`gateway_instance_id`,type:`text`,nullable:!1,identity:!1,default:null,position:7}},{table:`worker_workspace_pending_results`,kind:`column`,value:{name:`recovery_requested_at_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:8}},{table:`worker_workspace_pending_results`,kind:`column`,value:{name:`workspace_accepted_at_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:9}},{table:`worker_workspace_pending_results`,kind:`column`,value:{name:`staged_result_ref`,type:`text`,nullable:!0,identity:!1,default:null,position:10}},{table:`worker_workspace_pending_results`,kind:`column`,value:{name:`repository_workspace_id`,type:`text`,nullable:!0,identity:!1,default:null,position:11}},{table:`worker_workspace_pending_results`,kind:`column`,value:{name:`created_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:12}},{table:`worker_workspace_pending_results`,kind:`column`,value:{name:`repository_disk_authority_json`,type:`text`,nullable:!0,identity:!1,default:null,position:13}},{table:`worker_workspace_pending_results`,kind:`primaryKey`,value:[`session_id`]},{table:`worker_workspace_pending_results`,kind:`foreignKey`,value:{columns:[`session_id`],target:`worker_session_placements`,targetColumns:[`session_id`],onUpdate:`NO ACTION`,onDelete:`CASCADE`,deferrable:!1,deferred:!1}},{table:`worker_workspace_pending_results`,kind:`indexes`,value:1},{table:`worker_workspace_pending_results`,kind:`checks`,value:2},{table:`worker_workspace_reconciliations`,kind:`table`,value:null},{table:`worker_workspace_reconciliations`,kind:`column`,value:{name:`session_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`worker_workspace_reconciliations`,kind:`column`,value:{name:`environment_id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`worker_workspace_reconciliations`,kind:`column`,value:{name:`owner_epoch`,type:`bigint`,nullable:!1,identity:!1,default:null,position:3}},{table:`worker_workspace_reconciliations`,kind:`column`,value:{name:`placement_generation`,type:`bigint`,nullable:!1,identity:!1,default:null,position:4}},{table:`worker_workspace_reconciliations`,kind:`column`,value:{name:`base_manifest_ref`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`worker_workspace_reconciliations`,kind:`column`,value:{name:`current_manifest_ref`,type:`text`,nullable:!1,identity:!1,default:null,position:6}},{table:`worker_workspace_reconciliations`,kind:`column`,value:{name:`plan_json`,type:`text`,nullable:!1,identity:!1,default:null,position:7}},{table:`worker_workspace_reconciliations`,kind:`column`,value:{name:`base_pack`,type:`bytea`,nullable:!1,identity:!1,default:null,position:8}},{table:`worker_workspace_reconciliations`,kind:`column`,value:{name:`created_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:9}},{table:`worker_workspace_reconciliations`,kind:`primaryKey`,value:[`session_id`]},{table:`worker_workspace_reconciliations`,kind:`foreignKey`,value:{columns:[`session_id`],target:`worker_session_placements`,targetColumns:[`session_id`],onUpdate:`NO ACTION`,onDelete:`CASCADE`,deferrable:!1,deferred:!1}},{table:`worker_workspace_reconciliations`,kind:`indexes`,value:1},{table:`worker_workspace_reconciliations`,kind:`checks`,value:3},{table:`workspace_generated_bootstrap_hashes`,kind:`table`,value:null},{table:`workspace_generated_bootstrap_hashes`,kind:`column`,value:{name:`workspace_key`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`workspace_generated_bootstrap_hashes`,kind:`column`,value:{name:`filename`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`workspace_generated_bootstrap_hashes`,kind:`column`,value:{name:`sha256`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`workspace_generated_bootstrap_hashes`,kind:`primaryKey`,value:[`workspace_key`,`filename`]},{table:`workspace_generated_bootstrap_hashes`,kind:`foreignKey`,value:{columns:[`workspace_key`],target:`workspace_setup_state`,targetColumns:[`workspace_key`],onUpdate:`NO ACTION`,onDelete:`CASCADE`,deferrable:!1,deferred:!1}},{table:`workspace_generated_bootstrap_hashes`,kind:`indexes`,value:1},{table:`workspace_generated_bootstrap_hashes`,kind:`checks`,value:0},{table:`workspace_path_aliases`,kind:`table`,value:null},{table:`workspace_path_aliases`,kind:`column`,value:{name:`alias_key`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`workspace_path_aliases`,kind:`column`,value:{name:`alias_path`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`workspace_path_aliases`,kind:`column`,value:{name:`workspace_key`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`workspace_path_aliases`,kind:`column`,value:{name:`workspace_path`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`workspace_path_aliases`,kind:`column`,value:{name:`updated_at_ms`,type:`bigint`,nullable:!1,identity:!1,default:null,position:5}},{table:`workspace_path_aliases`,kind:`primaryKey`,value:[`alias_key`]},{table:`workspace_path_aliases`,kind:`indexes`,value:2},{table:`workspace_path_aliases`,kind:`checks`,value:0},{table:`workspace_setup_state`,kind:`table`,value:null},{table:`workspace_setup_state`,kind:`column`,value:{name:`workspace_key`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`workspace_setup_state`,kind:`column`,value:{name:`workspace_path`,type:`text`,nullable:!0,identity:!1,default:null,position:2}},{table:`workspace_setup_state`,kind:`column`,value:{name:`version`,type:`bigint`,nullable:!0,identity:!1,default:null,position:3}},{table:`workspace_setup_state`,kind:`column`,value:{name:`bootstrap_seeded_at`,type:`text`,nullable:!0,identity:!1,default:null,position:4}},{table:`workspace_setup_state`,kind:`column`,value:{name:`setup_completed_at`,type:`text`,nullable:!0,identity:!1,default:null,position:5}},{table:`workspace_setup_state`,kind:`column`,value:{name:`updated_at`,type:`bigint`,nullable:!0,identity:!1,default:null,position:6}},{table:`workspace_setup_state`,kind:`column`,value:{name:`attested_at_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:7}},{table:`workspace_setup_state`,kind:`column`,value:{name:`attestation_updated_at_ms`,type:`bigint`,nullable:!0,identity:!1,default:null,position:8}},{table:`workspace_setup_state`,kind:`column`,value:{name:`bootstrap_deferred`,type:`bigint`,nullable:!0,identity:!1,default:null,position:9}},{table:`workspace_setup_state`,kind:`primaryKey`,value:[`workspace_key`]},{table:`workspace_setup_state`,kind:`indexes`,value:2},{table:`workspace_setup_state`,kind:`checks`,value:1},{table:`worktree_provisioned_file_chunks`,kind:`table`,value:null},{table:`worktree_provisioned_file_chunks`,kind:`column`,value:{name:`worktree_id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`worktree_provisioned_file_chunks`,kind:`column`,value:{name:`path`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`worktree_provisioned_file_chunks`,kind:`column`,value:{name:`chunk_index`,type:`bigint`,nullable:!1,identity:!1,default:null,position:3}},{table:`worktree_provisioned_file_chunks`,kind:`column`,value:{name:`data`,type:`bytea`,nullable:!1,identity:!1,default:null,position:4}},{table:`worktree_provisioned_file_chunks`,kind:`primaryKey`,value:[`worktree_id`,`path`,`chunk_index`]},{table:`worktree_provisioned_file_chunks`,kind:`indexes`,value:1},{table:`worktree_provisioned_file_chunks`,kind:`checks`,value:1},{table:`worktree_templates`,kind:`table`,value:null},{table:`worktree_templates`,kind:`column`,value:{name:`cache_key`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`worktree_templates`,kind:`column`,value:{name:`id`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`worktree_templates`,kind:`column`,value:{name:`repo_root`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`worktree_templates`,kind:`column`,value:{name:`common_dir`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`worktree_templates`,kind:`column`,value:{name:`worktree_root`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`worktree_templates`,kind:`column`,value:{name:`path`,type:`text`,nullable:!1,identity:!1,default:null,position:6}},{table:`worktree_templates`,kind:`column`,value:{name:`backend`,type:`text`,nullable:!1,identity:!1,default:null,position:7}},{table:`worktree_templates`,kind:`column`,value:{name:`source_commit`,type:`text`,nullable:!1,identity:!1,default:null,position:8}},{table:`worktree_templates`,kind:`column`,value:{name:`content_key`,type:`text`,nullable:!1,identity:!1,default:null,position:9}},{table:`worktree_templates`,kind:`column`,value:{name:`status`,type:`text`,nullable:!1,identity:!1,default:null,position:10}},{table:`worktree_templates`,kind:`column`,value:{name:`created_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:11}},{table:`worktree_templates`,kind:`column`,value:{name:`last_used_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:12}},{table:`worktree_templates`,kind:`primaryKey`,value:[`cache_key`]},{table:`worktree_templates`,kind:`unique`,value:[`id`]},{table:`worktree_templates`,kind:`indexes`,value:2},{table:`worktree_templates`,kind:`checks`,value:1},{table:`worktrees`,kind:`table`,value:null},{table:`worktrees`,kind:`column`,value:{name:`id`,type:`text`,nullable:!1,identity:!1,default:null,position:1}},{table:`worktrees`,kind:`column`,value:{name:`repo_fingerprint`,type:`text`,nullable:!1,identity:!1,default:null,position:2}},{table:`worktrees`,kind:`column`,value:{name:`repo_root`,type:`text`,nullable:!1,identity:!1,default:null,position:3}},{table:`worktrees`,kind:`column`,value:{name:`path`,type:`text`,nullable:!1,identity:!1,default:null,position:4}},{table:`worktrees`,kind:`column`,value:{name:`branch`,type:`text`,nullable:!1,identity:!1,default:null,position:5}},{table:`worktrees`,kind:`column`,value:{name:`base_ref`,type:`text`,nullable:!1,identity:!1,default:null,position:6}},{table:`worktrees`,kind:`column`,value:{name:`owner_kind`,type:`text`,nullable:!1,identity:!1,default:null,position:7}},{table:`worktrees`,kind:`column`,value:{name:`owner_id`,type:`text`,nullable:!0,identity:!1,default:null,position:8}},{table:`worktrees`,kind:`column`,value:{name:`snapshot_ref`,type:`text`,nullable:!0,identity:!1,default:null,position:9}},{table:`worktrees`,kind:`column`,value:{name:`provisioned_paths_json`,type:`text`,nullable:!0,identity:!1,default:null,position:10}},{table:`worktrees`,kind:`column`,value:{name:`created_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:11}},{table:`worktrees`,kind:`column`,value:{name:`last_active_at`,type:`bigint`,nullable:!1,identity:!1,default:null,position:12}},{table:`worktrees`,kind:`column`,value:{name:`removed_at`,type:`bigint`,nullable:!0,identity:!1,default:null,position:13}},{table:`worktrees`,kind:`column`,value:{name:`run_end_cleanup_json`,type:`text`,nullable:!0,identity:!1,default:null,position:14}},{table:`worktrees`,kind:`column`,value:{name:`gc_protection_json`,type:`text`,nullable:!0,identity:!1,default:null,position:15}},{table:`worktrees`,kind:`primaryKey`,value:[`id`]},{table:`worktrees`,kind:`indexes`,value:3},{table:`worktrees`,kind:`checks`,value:1}];return Object.defineProperty(this,"expectedCatalog",{value:e,enumerable:!0,configurable:!0,writable:!0}),e}},Yr=`Use the matching OpenClaw version or restore the matching PostgreSQL schema and anchor.`;function isStatePostgres(){return stateEngineInput()!==void 0}function assertStateFileSnapshotAllowed(){stateEngineInput()&&Pt(`postgres`,`file-snapshot`)}function inspectStateSqlite(e){let t=P(e)??Ft(e);return{hasEngineAnchor:t.tables.has(`openclaw_engine_anchor`),hasExistingData:[...t.tables,...t.views,...t.triggers.keys()].some(e=>e!==`openclaw_engine_anchor`&&!e.startsWith(`sqlite_`))}}function admitStatePostgres(e,t){if(!t&&kn(e)?.startupReady)return;let n=withPostgresSchemaAdmissionRetry(e,()=>{let t=Bt(e);if(!t)throw new ir(`Missing PostgreSQL state admission. ${Yr}`);return t}),r=new Set(n.catalog.filter(e=>e.kind===`table`).map(e=>e.table)),i=new Set(q.fragments.flatMap(e=>e.tables.some(e=>r.has(e))?[]:e.tables));if(n.version===40&&Vt(n.catalog.filter(e=>!e.kind.endsWith(`Definition`)&&e.table!==`openclaw_schema_meta`),q.expectedCatalog.filter(e=>!i.has(e.table))),t){let t=Date.now();e.prepare(`INSERT INTO schema_meta
(meta_key, role, schema_version, agent_id, app_version, created_at, updated_at)
VALUES ('primary', 'global', ?, NULL, ?, ?, ?)`).run(40,B,t,t),writeStateSchemaContentVersion(e)}let a=e.prepare(`SELECT schema_version, role, agent_id FROM schema_meta WHERE meta_key = 'primary'`).get(),o=e.prepare(`SELECT value_json FROM config_machine_state WHERE state_key = 'state.schema.contentVersion'`).get(),s;try{let e=o?.value_json;if(e!=null&&typeof e!=`string`)throw Error(`Invalid PostgreSQL state content marker`);s=rr(e)}catch{throw Error(`PostgreSQL state metadata mismatch. ${Yr}`)}if(a?.schema_version!==n.version||a.role!==`global`||a.agent_id!==null||s>n.version)throw Error(`PostgreSQL state metadata mismatch. ${Yr}`);An(e,{userVersion:n.version,contentVersion:n.version}),On(e,!0)}function statePostgresVersionSql(e){return`UPDATE schema_meta
SET schema_version = ${e},
app_version = '${B.replaceAll(`'`,`''`)}',
updated_at = CAST(EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000 AS bigint)
WHERE meta_key = 'primary';
INSERT INTO config_machine_state (state_key, value_json, updated_at_ms)
VALUES ('state.schema.contentVersion', '${e}',
CAST(EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000 AS bigint))
ON CONFLICT (state_key) DO UPDATE
SET value_json = EXCLUDED.value_json, updated_at_ms = EXCLUDED.updated_at_ms;`}function createStatePostgresMigrations(){let e={postgres:Xr.postgres,postgresFragments:Xr.postgresFragments},t=withLegacyWorkerProvisionSource(e.postgres),n=withLegacyWorkspaceBootstrapDeferred(t),r={...e,postgres:t,postgresWithoutOptionalColumn:{table:`workspace_setup_state`,column:`bootstrap_deferred`,sql:n}},i={...e,postgres:withLegacyWorkerRetention(n)},a={postgres:withLegacyRepositoryDiskAuthority(i.postgres),postgresFragments:i.postgresFragments.map(e=>({...e,sql:withLegacyRepositoryDiskAuthority(e.sql)}))},o={postgres:withLegacyWorkerResourceReceipts(a.postgres),postgresFragments:a.postgresFragments},s={postgres:Jn(o.postgres),postgresFragments:o.postgresFragments.map(e=>({...e,tables:e.tables.map(Zn),sql:Jn(e.sql)}))},c={postgres:withLegacyLocalWorkspaceCas(s.postgres),postgresFragments:s.postgresFragments.map(e=>({...e,tables:e.tables.filter(e=>!Fr.some(t=>t===e)),sql:withLegacyLocalWorkspaceCas(e.sql)}))},l={postgres:zn(c.postgres,`schema-nullability`),postgresFragments:c.postgresFragments.map(e=>({...e,sql:zn(e.sql,`schema-nullability`)}))},u={postgres:zn(l.postgres),postgresFragments:l.postgresFragments.map(e=>({...e,sql:zn(e.sql)}))},d={postgres:withLegacyLocalWorkspaceManifests(u.postgres),postgresFragments:u.postgresFragments.map(e=>({...e,tables:e.tables.filter(e=>e!==`local_workspace_manifest_nodes`),sql:withLegacyLocalWorkspaceManifests(e.sql)}))},f={...d,postgres:`${d.postgres}\n${q.clientCredentialSource.sql}`},p={postgres:Gn(f.postgres),postgresFragments:f.postgresFragments.map(e=>({...e,sql:Gn(e.sql)}))},m={...p,postgres:p.postgres.replace(/CREATE INDEX "idx_state_leases_owner"[^;]*;/u,q.preWriteIndexesV27Sql.state_leases)+q.preWriteIndexesV27Sql.skill_usage+q.preWriteIndexesV27Sql.acp_replay_events,postgresFragments:p.postgresFragments};return[{version:25,sql:q.operatorRecoveryV25Sql,fromSchema:m,schema:m},{version:26,fromSchema:m,schema:m,sql:statePostgresVersionSql(26)},{version:27,fromSchema:m,schema:p,sql:`${q.writeIndexesV27Sql}
${statePostgresVersionSql(27)}`},{version:28,fromSchema:p,schema:f,sql:`ALTER TABLE IF EXISTS github_publication_requests ADD COLUMN draft bigint;
ALTER TABLE IF EXISTS github_personal_publication_requests ADD COLUMN draft bigint;
ALTER TABLE IF EXISTS github_repository_publication_requests ADD COLUMN draft bigint;
${statePostgresVersionSql(28)}`},{version:29,fromSchema:f,schema:d,sql:q.clientCredentialV29Sql},{version:30,fromSchema:d,schema:d,sql:statePostgresVersionSql(30)},{version:31,fromSchema:d,schema:u,sql:`DO $workspace$
DECLARE baseline_constraint text;
BEGIN
IF to_regclass('local_workspace_projections') IS NOT NULL THEN
SELECT conname INTO STRICT baseline_constraint FROM pg_constraint
WHERE conrelid = 'local_workspace_projections'::regclass AND contype = 'c'
AND pg_get_constraintdef(oid) LIKE '%baseline_json%baseline_ref%';
EXECUTE format('ALTER TABLE local_workspace_projections DROP CONSTRAINT %I', baseline_constraint);
ALTER TABLE local_workspace_projections
ADD COLUMN checkpoint_json text COLLATE "C",
ADD CHECK (baseline_json IS NULL OR baseline_ref IS NOT NULL);
CREATE TABLE local_workspace_manifest_nodes (
worktree_id text COLLATE "C" NOT NULL,
path text COLLATE "C" NOT NULL,
node_json text COLLATE "C" NOT NULL,
PRIMARY KEY (worktree_id, path),
FOREIGN KEY (worktree_id) REFERENCES local_workspace_projections(worktree_id)
ON DELETE CASCADE
);
END IF;
END $workspace$;
${statePostgresVersionSql(31)}`},{version:32,fromSchema:u,schema:l,sql:`${Bn([l.postgres,...l.postgresFragments.map(e=>e.sql)].join(`
`))}
${statePostgresVersionSql(32)}`},{version:33,fromSchema:l,schema:c,sql:`${Bn([c.postgres,...c.postgresFragments.map(e=>e.sql)].join(`
`),`schema-nullability`)}
${statePostgresVersionSql(33)}`},{version:34,fromSchema:c,schema:c,sql:statePostgresVersionSql(34)},{version:35,fromSchema:c,schema:s,sql:`${q.workspaceCasV35Sql}\n${statePostgresVersionSql(35)}`},{version:36,fromSchema:s,schema:o,sql:`${qn}\n${statePostgresVersionSql(36)}`},{version:37,fromSchema:o,schema:a,sql:`ALTER TABLE worker_environments ADD COLUMN resource_receipt_json text COLLATE "C";
${statePostgresVersionSql(37)}`},{version:38,fromSchema:a,schema:i,sql:`ALTER TABLE IF EXISTS session_repository_workspaces ADD COLUMN disk_authority_json text COLLATE "C";
ALTER TABLE worker_workspace_pending_results ADD COLUMN repository_disk_authority_json text COLLATE "C";
${statePostgresVersionSql(38)}`},{version:39,fromSchema:i,schema:r,sql:`ALTER TABLE worker_environments ADD COLUMN retention_json text COLLATE "C";
${statePostgresVersionSql(39)}`},{version:40,fromSchema:r,schema:e,sql:`ALTER TABLE workspace_setup_state ADD COLUMN IF NOT EXISTS bootstrap_deferred bigint;
ALTER TABLE worker_environments ADD COLUMN provision_source_json text COLLATE "C";
UPDATE worker_environments
SET provision_source_json = '{"kind":"unavailable"}'
WHERE (state IN ('requested', 'provisioning') AND lease_id IS NULL
OR state = 'bootstrapping' AND owner_epoch = 0)
AND provision_source_json IS NULL;
${statePostgresVersionSql(40)}`}]}const Xr={id:`state`,version:40,sqlite:``,get postgres(){let e=q.eagerSql;return Object.defineProperty(this,"postgres",{value:e,enumerable:!0,configurable:!0,writable:!0}),e},get postgresFragments(){let e=q.fragments.map(e=>{let{activation:t}=e;if(t!==`first-use`&&t!==`version-additive`)throw Error(`Unknown PostgreSQL state fragment activation: ${t}`);return{id:e.id,tables:e.tables,sql:e.sql,dependencies:e.dependencies,activation:t}});return Object.defineProperty(this,"postgresFragments",{value:e,enumerable:!0,configurable:!0,writable:!0}),e},get postgresMigrations(){let e=createStatePostgresMigrations();return Object.defineProperty(this,"postgresMigrations",{value:e,enumerable:!0,configurable:!0,writable:!0}),e}};function ensureStatePostgresFragment(e,t){let n=Bt(e);if(!n)throw new ir(`Missing PostgreSQL state admission. ${Yr}`);let r=q.fragments.find(e=>e.tables.includes(t));if(!r){if(q.expectedCatalog.some(e=>e.kind===`table`&&e.table===t)&&n.catalog.some(e=>e.kind===`table`&&e.table===t))return;throw Error(`No PostgreSQL state fragment owns ${t}`)}let i=r.tables.filter(e=>n.version>=35||!Fr.some(t=>t===e));if(i.every(e=>n.catalog.some(t=>t.kind===`table`&&t.table===e)))return;for(let t of r.dependencies){let n=q.fragments.find(e=>e.id===t);if(!n)throw Error(`Unknown state fragment dependency ${t}`);ensureStatePostgresFragment(e,n.tables[0])}if(!rt(e,{commit:()=>h(e),invalidate:()=>h(e)}))throw Error(`PostgreSQL state fragments require the owner's transaction`);let a=e.prepare(`SELECT 1 AS present FROM pg_catalog.pg_class
WHERE relnamespace = ?::regnamespace AND relname IN (${i.map(()=>`?`).join(`, `)})
LIMIT 1`).get(n.namespace,...i),o=Nt(e);if(!o)throw new ir(`Missing PostgreSQL state admission. ${Yr}`);if(ie(e),a){Mt({db:e,namespace:n.namespace,storeId:n.storeId,store:n.store,version:n.version,schema:o,preserveSchemaSeal:!0}),admitStatePostgres(e,!1);return}let s=n.version<38?withLegacyRepositoryDiskAuthority(r.sql):r.sql,c=n.version<36?Jn(s):s,l=n.version<35?withLegacyLocalWorkspaceCas(c):c;e.exec(n.version<33?zn(l,n.version<32?`sqlite`:`schema-nullability`):l),Mt({db:e,namespace:n.namespace,storeId:n.storeId,store:n.store,version:n.version,schema:Xr,recordSchema:!0}),admitStatePostgres(e,!1)}function openExistingStatePostgresConnection(e,t){if(stateEngineInput())return openExistingStatePostgresConnectionFromAnchor(Cn(e,{existingOnly:!0,expectedIdentity:t}),e)}function openExistingStatePostgresConnectionFromAnchor(e,t){let n;try{let r=stateEngineInput();if(!r)throw Error(`PostgreSQL state inspection requires the configured state connection.`);or(e,t);let i=At({anchor:e,schema:Xr,input:r,inspectSqlite:()=>inspectStateSqlite(e),prepareAnchor:()=>{},openSqlite:()=>{},existingOnly:!0,reusePostgresConnection:!0,existingVersion:!0,admitPostgres:admitStatePostgres,closeOnFailure:(e,t)=>{throw n=e,t}});if(!E(i))throw Error(`Expected PostgreSQL state connection`);return n=i,{database:{db:n,path:t},close(){return Oe(ve.closeUnpublishedOpenClawStateDatabaseHandle({db:i,path:t}),`PostgreSQL state connection cleanup failed.`),!i.isOpen&&!e.isOpen}}}catch(r){let i=ve.closeUnpublishedOpenClawStateDatabaseHandle({db:n??e,path:t});throw i.length?Se([r,...i],`PostgreSQL state connection acquisition and cleanup failed.`,r):r}}function parseStateLeaseProcessOwner(e){let t=D(e??``)?.owner;if(!b(t))return null;let{pid:n,host:r,startedAt:i}=t;return typeof n!=`number`||!Number.isSafeInteger(n)||n<=0||typeof r!=`string`||!r||i!==null&&(typeof i!=`number`||!Number.isSafeInteger(i)||i<0)?null:{pid:n,host:r,startedAt:i,...t.machineIdentity===void 0?{}:{machineIdentity:Ze.safeParse(t.machineIdentity).data??null},...t.processNamespace===void 0?{}:{processNamespace:Ye.safeParse(t.processNamespace).data??null}}}function readStateLeaseProcessOwnerStatus(e,t){if(!e)return`unknown`;let n=qe(e.processNamespace,{ownerHost:e.host,machineIdentity:e.machineIdentity,readGatewayHeartbeat:t===void 0?void 0:()=>t});return n===`same`?readSameNamespaceProcessOwnerStatus(e):n}function readSameNamespaceProcessOwnerStatus(e){if(Qe(e.pid))return`dead`;let t=$e(e.pid);return e.startedAt===null||t===null?`unknown`:t===e.startedAt?`live`:`dead`}const Zr=Ue().int().min(0).max(2**53-1),Qr=He(`reason`,[T({reason:w(`expired`),expiresAt:Zr,expiredByMs:Zr,heartbeatAgeMs:Zr,renewalTimerLateByMs:Zr.optional()}),T({reason:w(`replaced`),owner:w(`[redacted]`)}),T({reason:w(`missing`)}),T({reason:w(`storage-failed`)}),T({reason:w(`admission-failed`)})]);function readOpenClawStateLease(e,t){return A(e,k(e).selectFrom(`state_leases`).select([`owner`,`created_at as createdAt`,`expires_at as expiresAt`,`heartbeat_at as heartbeatAt`,`payload_json as payloadJson`]).where(`scope`,`=`,t.scope).where(`lease_key`,`=`,t.key))}function readOpenClawStateLeaseLoss(e,t){try{let n=readOpenClawStateLease(e,t),r=Date.now(),i=n?n.owner===t.owner?n.expiresAt!==null&&n.heartbeatAt!==null&&n.expiresAt<=r?{reason:`expired`,expiresAt:n.expiresAt,expiredByMs:r-n.expiresAt,heartbeatAgeMs:Math.max(0,r-n.heartbeatAt)}:void 0:{reason:`replaced`,owner:`[redacted]`}:{reason:`missing`};return Qr.safeParse(i).data}catch{return}}function readOpenClawStateLeaseExpiry(e,t,n){return A(e,k(e).selectFrom(`state_leases`).select(`expires_at`).where(`scope`,`=`,t.scope).where(`lease_key`,`=`,t.key).where(`owner`,`=`,t.owner).where(`expires_at`,`>`,n??Date.now()).$narrowType())?.expires_at}const $r={scope:`gateway-owner`,key:`global`},ei=`SELECT a.attname AS name, pg_catalog.format_type(a.atttypid, a.atttypmod) AS type
FROM pg_catalog.pg_class c
JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
JOIN pg_catalog.pg_attribute a ON a.attrelid = c.oid
WHERE n.nspname = $1 AND c.relname = 'state_leases' AND c.relkind IN ('r', 'p')
AND a.attnum > 0 AND NOT a.attisdropped`;function assertGatewayOwnerLeaseColumns(e){if(Object.entries({scope:`text`,lease_key:`text`,owner:`text`,expires_at:`bigint`,heartbeat_at:`bigint`,payload_json:`text`,created_at:`bigint`}).some(([t,n])=>!e.some(e=>e.name===t&&e.type===n)))throw Error(`PostgreSQL Gateway owner lease table is missing or incompatible`)}function parseSupervisor(e){if(e===null)return null;if(!b(e)||e.kind!==`launchd`&&e.kind!==`systemd`&&e.kind!==`schtasks`&&e.kind!==`external`||e.name!==null&&(typeof e.name!=`string`||!e.name.trim()))throw Error(`Gateway owner lease supervisor could not be verified`);return{kind:e.kind,name:e.name}}function readGatewayOwnerLeaseFromDatabase(e,t){if(L(e,`state_leases`))return decodeGatewayOwnerLease(readOpenClawStateLease(e,$r),t)}function decodeGatewayOwnerLease(e,t){if(!e)return;let n=parseStateLeaseProcessOwner(e.payloadJson),r=D(e.payloadJson??``);if(!n||!r||typeof r.port!=`number`||!Number.isInteger(r.port)||r.port<=0||r.port>65535||r.mode!==`foreground`&&r.mode!==`supervised`)throw Error(`Gateway owner lease identity could not be verified`);if(t!==void 0&&r.port!==t)return;let i=parseSupervisor(r.supervisor);if(r.mode===`foreground`!=(i===null))throw Error(`Gateway owner lease supervisor does not match its listener mode`);return{...n,owner:e.owner,heartbeatAt:e.heartbeatAt??e.createdAt,port:r.port,mode:r.mode,supervisor:i,...typeof r.listeningAt==`number`?{listeningAt:r.listeningAt}:{},...typeof r.stateDatabaseProvenance==`string`?{stateDatabaseProvenance:r.stateDatabaseProvenance}:{},state:readStateLeaseProcessOwnerStatus(n,e.heartbeatAt??e.createdAt),expired:e.expiresAt===null||e.expiresAt<=Date.now(),...n.processNamespace===void 0?{expiresAt:e.expiresAt}:{}}}function hasLegacyCronRunLogs(e){let t=P(e);return t?t.tables.has(`cron_run_logs`):!!e.prepare(`SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'cron_run_logs' LIMIT 1`).get()}let ti;function bootFingerprint(e,t){return[Sr(),e,t,B].join(`\0`)}function mayShareAgentDatabaseFile(e,t){if(e===t)return!0;try{let n=mr.statSync(e,{bigint:!0,throwIfNoEntry:!1}),r=mr.statSync(t,{bigint:!0,throwIfNoEntry:!1});return!n||!r||n.dev===r.dev&&n.ino===r.ino}catch{return!0}}function createAgentDatabaseLeaseStaleReasonReader(){let e;return t=>{if(Qe(t.owner_pid))return`owner-pid-dead`;if(t.owner_start_time===null){if(t.opened_at<=0)return;if(e===void 0)try{e=Xe(process.env)()}catch{e=null}return Je(t.opened_at,e??void 0)?`owner-prior-boot`:void 0}let n=$e(t.owner_pid);return n!==null&&t.owner_start_time!==n?`owner-start-time-changed`:void 0}}function readAgentDatabaseLeaseProvenance(e){try{if(ti===void 0&&(ti=null,[`linux`,`darwin`,`win32`].includes(process.platform))){let e=Xe(process.env)(),t=e.platform===`linux`?mr.readlinkSync(`/proc/self/ns/pid`):e.platform;ti=bootFingerprint(e.identity,t)}if(!ti)return null;let t=mr.statSync(e,{bigint:!0});return t.isFile()?`process-v1:${Cr(`sha256`).update(`${ti}\0${t.dev}:${t.ino}`).digest(`hex`)}`:null}catch{return null}}const ni=S().refine(e=>!e.includes(`\0`),`Must not contain NUL`),ri=Ke([ni,Ve(ni).min(1).refine(e=>!!e[0]?.length,`Executable must not be empty`)]),J=Ke([ri,C(S(),ri)]),ii=S().regex(/^[a-f0-9]{40}(?:[a-f0-9]{24})?$/u),ai=S().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),oi=C(ai,T({description:S().optional(),documentationUrl:S().optional()}).passthrough()).refine(e=>Object.keys(e).length<=16,`At most 16 setup secrets may be requested`),si=C(S().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),ni),ci=T({source:We([`devcontainer`,`script`,`detected`,`none`]),identity:ii.optional(),inputs:C(S(),ii),env:C(S().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),ni.nullable()),secretNames:Ve(ai).max(16).optional(),ignoredPropertiesNote:S().optional(),onCreate:J.optional(),updateContent:J.optional(),postCreate:J.optional(),postStart:J.optional(),detectedInstall:J.optional()}).strict();T({onCreateCommand:J.optional(),updateContentCommand:J.optional(),postCreateCommand:J.optional(),postStartCommand:J.optional(),secrets:oi.optional(),containerEnv:si.optional(),remoteEnv:C(S().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),ni.nullable()).optional()}).passthrough();const Y=S().regex(/^[a-f0-9]{64}$/u),li=T({nodeBootstrapSha256:Y,enabledPluginIds:Ve(S().min(1).max(256)).max(256),workerBundleHash:Y,workerArchiveSha256:Y,openclawVersion:S().min(1).max(128),protocolFeatures:Ve(S().min(1).max(128)).max(64)}).strict(),ui=T({machineClass:S().min(1).max(256),platform:S().min(1).max(64),arch:S().min(1).max(64).optional(),profileKey:Y.optional()}).strict(),di=T({key:Y,cacheKey:Y,contractVersion:Ke([w(1),w(2)]),setupRecipe:S().regex(/^[a-f0-9]{40}(?:[a-f0-9]{24})?$/u).optional(),runSetupScript:Ge().optional(),recipe:ci.optional(),target:ui,artifacts:li}).strict(),fi=di.omit({setupRecipe:!0,runSetupScript:!0,recipe:!0}).extend({source:We([`empty`,`image`])});function readWorkerProjectPreparation(e){if(!b(e)||e.preparation===void 0)return;let t=di.safeParse(e.preparation);if(!t.success)throw Error(`Worker project preparation identity is invalid`);return t.data}function readWorkerPreparation(e){if(e.runtimePreparation===void 0)return readWorkerProjectPreparation(e.project);let t=fi.safeParse(e.runtimePreparation);if(!t.success||e.project!==void 0)throw Error(`Worker runtime preparation identity is invalid`);return t.data}function historicalImageQuery(e){return k(e).selectFrom(`worker_environments`).select([`environment_id`,`profile_snapshot_json`]).where(t=>t(Tn(e,t.ref(`profile_snapshot_json`)),`=`,1)).where(t=>t(wn(e,t.ref(`profile_snapshot_json`),t.val(`$.project.kind`)),`=`,`image`))}function migrateHistoricalImageReserveSnapshots(e){if(!L(e,`worker_environments`))return[];let t=j(e,historicalImageQuery(e)).rows;for(let n of t){if(typeof n.profile_snapshot_json!=`string`||typeof n.environment_id!=`string`)throw Error(`Historical image reserve row is invalid`);let t=JSON.parse(n.profile_snapshot_json),r=b(t)?t.project:void 0;if(!b(t)||!b(r)||r.kind!==`image`||typeof r.key!=`string`||!/^[a-f0-9]{64}$/u.test(r.key)||!b(r.preparation)||t.runtimePreparation!==void 0||t.historicalProfileSnapshotJson!==void 0)throw Error(`Historical image reserve snapshot has conflicting or invalid preparation`);t.runtimePreparation={...r.preparation,source:`empty`},delete t.project,readWorkerPreparation(t),t.historicalProfileSnapshotJson=n.profile_snapshot_json,j(e,k(e).updateTable(`worker_environments`).set({profile_snapshot_json:JSON.stringify(t)}).where(`environment_id`,`=`,n.environment_id))}return t.length>0?[`Migrated historical image reserves with original snapshot evidence retained`]:[]}const pi=[`device_identities`,`device_auth_tokens`,`gateway_origin_device_tokens`,`exec_approvals_config`],mi=`CREATE TABLE device_identities (
identity_key TEXT NOT NULL PRIMARY KEY,
device_id TEXT NOT NULL,
public_key_pem TEXT NOT NULL,
private_key_pem TEXT NOT NULL,
created_at_ms INTEGER NOT NULL,
updated_at_ms INTEGER NOT NULL
) STRICT;
CREATE INDEX idx_device_identities_device
ON device_identities(device_id, updated_at_ms DESC);
CREATE TABLE device_auth_tokens (
device_id TEXT NOT NULL,
role TEXT NOT NULL,
token TEXT NOT NULL,
scopes_json TEXT NOT NULL,
updated_at_ms INTEGER NOT NULL,
PRIMARY KEY (device_id, role)
) STRICT;
CREATE INDEX idx_device_auth_tokens_updated
ON device_auth_tokens(updated_at_ms DESC, device_id, role);
CREATE TABLE gateway_origin_device_tokens (
gateway_scope TEXT NOT NULL,
device_id TEXT NOT NULL,
role TEXT NOT NULL,
token TEXT NOT NULL,
scopes_json TEXT NOT NULL,
updated_at_ms INTEGER NOT NULL,
PRIMARY KEY (gateway_scope, device_id, role)
) STRICT;
CREATE TABLE native_exec_socket_credentials (
socket_key TEXT NOT NULL PRIMARY KEY CHECK (socket_key = 'current'),
socket_path TEXT,
socket_token TEXT,
updated_at_ms INTEGER NOT NULL
) STRICT;
CREATE TABLE client_credential_migration (
version INTEGER PRIMARY KEY CHECK (version = 1),
source_store TEXT NOT NULL,
phase TEXT NOT NULL CHECK (phase IN ('copied', 'complete')),
updated_at_ms INTEGER NOT NULL
) STRICT;`;function migrateCronDeliveryAttemptState(e,t){return t<20&&L(e,`cron_run_receipts`)?I(e,`cron_run_receipts`,`delivery_attempt_state TEXT NOT NULL DEFAULT 'unknown' CHECK (delivery_attempt_state IN ('unknown', 'not-started', 'started'))`):!1}const hi={version:21,tables:[`meeting_transcript_sessions`,`meeting_transcript_summaries`,`delivery_queue_entries`],columns:[...[`source_account_id`,`source_guild_id`,`source_channel_id`,`source_meeting_url`,`source_thread_ts`,`source_file_id`,`metadata_agent_id`].map(e=>`meeting_transcript_sessions.${e}`),`meeting_transcript_summaries.overview`,`delivery_queue_entries.retention_id_prefix`,`delivery_queue_entries.retention_max_age_ms`,`delivery_queue_entries.retention_max_entries`],migrate:migratePredicateColumnsV21,applied:`Derived meeting transcript selectors and bounded delivery retention columns (v21)`};function migratePredicateColumnsV21(e,t){let n=t===21&&hi.columns.some(t=>{let n=t.indexOf(`.`),r=t.slice(0,n);return L(e,r)&&!R(e,r,t.slice(n+1))});if(t>=21&&!n)return!1;let r=!1,text=(e,t)=>`CASE WHEN json_valid(${e}) THEN CASE WHEN json_type(${e}, '${t}') = 'text' THEN json_extract(${e}, '${t}') END END`;if(L(e,`meeting_transcript_sessions`)){let t=[`accountId`,`guildId`,`channelId`,`meetingUrl`,`threadTs`,`fileId`],n=[`source_account_id`,`source_guild_id`,`source_channel_id`,`source_meeting_url`,`source_thread_ts`,`source_file_id`];for(let t of[...n,`metadata_agent_id`])r=I(e,`meeting_transcript_sessions`,`${t} TEXT`)||r;e.exec(`UPDATE meeting_transcript_sessions SET
${n.map((e,n)=>`${e} = ${text(`source_json`,`$.${t[n]}`)}`).join(`,`)},
metadata_agent_id = ${text(`metadata_json`,`$.agentId`)}`)}return L(e,`meeting_transcript_summaries`)&&(r=I(e,`meeting_transcript_summaries`,`overview TEXT`)||r,e.exec(`UPDATE meeting_transcript_summaries SET overview = ${text(`summary_json`,`$.overview`)}`)),L(e,`delivery_queue_entries`)&&(r=I(e,`delivery_queue_entries`,`retention_id_prefix TEXT`)||r,r=I(e,`delivery_queue_entries`,`retention_max_age_ms INTEGER`)||r,r=I(e,`delivery_queue_entries`,`retention_max_entries INTEGER`)||r,e.exec(`UPDATE delivery_queue_entries SET
(retention_id_prefix, retention_max_age_ms, retention_max_entries) = (
SELECT id_prefix, max_age_ms, max_entries FROM (
SELECT json_extract(entry_json, '$.completionRetention.idPrefix') id_prefix,
json_extract(entry_json, '$.completionRetention.maxAgeMs') max_age_ms,
json_extract(entry_json, '$.completionRetention.maxEntries') max_entries
WHERE json_valid(entry_json)
AND json_type(entry_json, '$.completionRetention') = 'object'
) WHERE typeof(id_prefix) = 'text' AND id_prefix <> ''
AND substr(id, 1, length(id_prefix)) = id_prefix
AND typeof(max_age_ms) = 'integer' AND max_age_ms BETWEEN 1 AND 9007199254740991
AND typeof(max_entries) = 'integer' AND max_entries BETWEEN 1 AND 9007199254740991
)`)),r}const X=`worker_session_placements`,gi=`repository_preparation TEXT`;function migrateHistoricalRepositoryPreparation(e){if(!R(e,X,`repository_preparation`))return!1;let t=N(v,X).replace(` remote_workspace_dir TEXT,`,` `+gi+`,
remote_workspace_dir TEXT,`),n=z(e)(X),r=re(t,X);if(n?.strict===1&&n.withoutRowid===0&&Tr(n.definition,r))return!1;let i=t.replace(gi+`,`,gi+` CHECK (repository_preparation IN ('pending', 'ready', 'failed')),`).replace(` CHECK (
(state IN`,` CHECK (repository_preparation IS NULL OR (repository_preparation = 'ready' AND workspace_base_manifest_ref IS NOT NULL) OR (repository_preparation = 'failed' AND state IN ('starting', 'active', 'draining', 'reconciling', 'reclaimed', 'failed')) OR (repository_preparation = 'pending' AND workspace_base_manifest_ref IS NULL AND state IN ('starting', 'active', 'draining', 'reconciling', 'reclaimed', 'failed'))),
CHECK (
(state IN`).replaceAll(`AND workspace_base_manifest_ref IS NOT NULL AND remote_workspace_dir`,`AND (workspace_base_manifest_ref IS NOT NULL OR repository_preparation IS 'pending' OR repository_preparation IS 'failed') AND remote_workspace_dir`);if(!n||n.strict!==1||n.withoutRowid!==0||!Tr(n.definition,re(i,X)))throw Error(`Unrecognized historical worker placement schema; preserve the store for explicit recovery.`);if(e.prepare(`SELECT 1 FROM worker_session_placements WHERE repository_preparation IN ('pending', 'failed') AND turn_claim_owner = 'worker' LIMIT 1`).get())throw Error(`Historical repository preparation retains a worker turn claim; reconcile its owned cleanup before migrating.`);let a=zt(e).filter(e=>e.tbl_name===X&&(e.type===`index`||e.type===`trigger`)&&e.sql!==null),o=n.columns.map(e=>e.name),s=o.map(e=>e===`state`?`CASE WHEN repository_preparation IN ('pending', 'failed') THEN 'failed' ELSE state END`:e===`recovery_error`?`CASE WHEN repository_preparation IN ('pending', 'failed') THEN 'Historical repository preparation ' || repository_preparation || ' (previous placement ' || state || '); owned cleanup required before recovery.' || CASE WHEN recovery_error IS NULL THEN '' ELSE ' ' || recovery_error END ELSE recovery_error END`:M(e));e.exec(t.replace(`CREATE TABLE IF NOT EXISTS `+X,`CREATE TABLE worker_session_placements_historical_migration`)+` INSERT INTO worker_session_placements_historical_migration (rowid, `+o.map(M).join(`, `)+`) SELECT rowid, `+s.join(`, `)+` FROM worker_session_placements; DROP TABLE worker_session_placements; ALTER TABLE worker_session_placements_historical_migration RENAME TO worker_session_placements;`);for(let t of a){if(typeof t.sql!=`string`)throw Error(`Historical worker placement schema object is invalid`);e.exec(t.sql)}return!0}function migrateHistoricalStateImports(e,t,n=`version`){if(n===`version`&&t>22)return[];let r=[],i=t===21&&migrateHistoricalRepositoryPreparation(e);return i&&r.push(`Preserved historical worker placement evidence and fenced incomplete repository preparation`),(t===21||i)&&migratePredicateColumnsV21(e,21)&&r.push(hi.applied),(n===`doctor`||t<=22)&&r.push(...migrateHistoricalImageReserveSnapshots(e)),r}const _i=[{version:32,tables:[],columns:[],migrate:()=>!1,applied:`Aligned PostgreSQL non-null index ordering (v32)`},{version:33,tables:[],columns:[],migrate:()=>!1,applied:`Aligned PostgreSQL partial-index ordering (v33)`}];function migrateMeetingTranscriptStartTime(e,t){if(t>=23||!L(e,`meeting_transcript_sessions`))return!1;let n=I(e,`meeting_transcript_sessions`,`started_at_ms INTEGER`),r=St(e,k(e).selectFrom(`meeting_transcript_sessions`).select([`session_id`,`started_at`])),i=e.prepare(`UPDATE meeting_transcript_sessions SET started_at_ms = ? WHERE session_id = ? AND started_at = ?`);for(let e of r)i.run(o(e.started_at)??null,e.session_id,e.started_at),n=!0;return n}const vi=-(2**53-1),yi={"diagnostic.configAuditFacts":(e,t)=>{let n=createSqliteAuditRecordKernel(t,{scope:e.scope,maxEntries:1}),r=0,i,a=!1;for(;;){let t=n.latest({limit:5,...i===void 0?{}:{beforeSequence:i}});if(i===void 0&&(r=t[0]?.sequence??0),t.length===0)break;let o=!1;for(let n of t){if(n.sequence<=e.lastSeenAuditSequence){o=!0;break}n.value.event===`config.external`&&(a=!0)}if(o||t.length<5)break;let s=t.at(-1)?.sequence;if(s===void 0||s===i)break;i=s}return{type:`diagnostic.configAuditFacts`,auditSequence:r,recentExternalEdit:a}},"diagnostic.latest":(e,t)=>({type:`diagnostic.latest`,entries:createSqliteAuditRecordKernel(t,{scope:e.scope,maxEntries:1}).latest(e)})};function getAuditRecordKysely(e){return k(e)}function parseAuditRecord(e){return{key:e.event_key,value:JSON.parse(e.payload_json),createdAt:e.created_at,sequence:e.sequence}}function readAuditWriteState(e){let t=A(e.database,getAuditRecordKysely(e.database).selectFrom(`diagnostic_events`).select(t=>[t.fn.max(`sequence`).filterWhere(`sequence`,e.legacy?`<`:`>=`,0).as(`sequence`),t.fn.countAll().as(`count`),t.fn.countAll().filterWhere(`event_key`,`=`,e.key??``).as(`keyCount`)]).where(`scope`,`=`,e.scope)),n=(t?.sequence??(e.legacy?vi:0))+1;if(!Number.isSafeInteger(n)||e.legacy&&n>=0)throw Error(`Audit sequence exhausted for scope ${e.scope}`);return{nextSequence:n,count:U(t?.count??0),keyExists:U(t?.keyCount??0)>0}}function pruneAuditRecords(e){let t=e.count-e.maxEntries;if(t<=0)return;let n=e.protectedKey,r=getAuditRecordKysely(e.database).selectFrom(`diagnostic_events`).select(`event_key`).where(`scope`,`=`,e.scope),i=(n===void 0?r:r.where(`event_key`,`!=`,n)).orderBy(`sequence`,`asc`).limit(t);j(e.database,getAuditRecordKysely(e.database).deleteFrom(`diagnostic_events`).where(`scope`,`=`,e.scope).where(`event_key`,`in`,i))}function prepareSqliteAuditRecord(e,t){let n=JSON.stringify(t.value);if(n===void 0)throw Error(`Audit record ${e}/${t.key} is not JSON-serializable`);return{event_key:t.key,payload_json:n,created_at:t.createdAt}}function createAuditRecordInsert(e){return bt(e,t=>getAuditRecordKysely(e).insertInto(`diagnostic_events`).values({scope:t(e=>e.scope),event_key:t(e=>e.event_key),payload_json:t(e=>e.payload_json),created_at:t(e=>e.created_at),sequence:t(e=>e.sequence)}).onConflict(e=>e.columns([`scope`,`event_key`]).doNothing()))}const bi=Ct(createAuditRecordInsert);function createSqliteAuditRecordKernel(e,t){let n=t.scope,r=t.maxEntries,prune=(t,i)=>pruneAuditRecords({database:e,scope:n,maxEntries:r,count:t,protectedKey:i}),selectEntries=()=>getAuditRecordKysely(e).selectFrom(`diagnostic_events`).select([`event_key`,`payload_json`,`created_at`,`sequence`]).where(`scope`,`=`,n);function insertRecord(t){return Number(bi(e)({...t,scope:n}).numAffectedRows??0)}function upsertPreparedRecord(t){let r=readAuditWriteState({database:e,scope:n,legacy:!1,key:t.event_key});j(e,getAuditRecordKysely(e).insertInto(`diagnostic_events`).values({scope:n,event_key:t.event_key,payload_json:t.payload_json,created_at:t.created_at,sequence:r.nextSequence}).onConflict(e=>e.columns([`scope`,`event_key`]).doUpdateSet({payload_json:t.payload_json,created_at:t.created_at}))),prune(r.count+ +!r.keyExists,t.event_key)}function deleteRecord(t){j(e,getAuditRecordKysely(e).deleteFrom(`diagnostic_events`).where(`scope`,`=`,n).where(`event_key`,`=`,t))}return{register(t){let r=readAuditWriteState({database:e,scope:n,legacy:!1}),i=insertRecord({...t,sequence:r.nextSequence});prune(r.count+i,t.event_key)},upsert:upsertPreparedRecord,delete:deleteRecord,compareAndSet(t,r,i){return(A(e,getAuditRecordKysely(e).selectFrom(`diagnostic_events`).select(`payload_json`).where(`scope`,`=`,n).where(`event_key`,`=`,t))?.payload_json??null)===r&&(i?upsertPreparedRecord(i):deleteRecord(t),!0)},registerLegacyMany(t){let r=readAuditWriteState({database:e,scope:n,legacy:!0}),i=r.nextSequence,a=r.count;for(let e of t)a+=insertRecord({...e,sequence:i}),i+=1;prune(a)},entries(){return j(e,selectEntries().orderBy(`sequence`,`asc`)).rows.map(e=>{let{sequence:t,...n}=parseAuditRecord(e);return n})},latest(t){let n=selectEntries(),r=t.beforeSequence===void 0?n:n.where(`sequence`,`<`,t.beforeSequence);return j(e,r.orderBy(`sequence`,`desc`).limit(t.limit)).rows.map(e=>parseAuditRecord(e))}}}function estimateAcpSessionRowBytes(e){return Buffer.byteLength(e.sessionId,`utf8`)+Buffer.byteLength(e.sessionKey,`utf8`)+Buffer.byteLength(e.cwd,`utf8`)+32}function estimateAcpEventRowBytes(e){return Buffer.byteLength(e.sessionId,`utf8`)+Buffer.byteLength(e.sessionKey,`utf8`)+Buffer.byteLength(e.runId??``,`utf8`)+Buffer.byteLength(e.updateJson,`utf8`)+32}function buildApprovalResolutionRef(e){return ft(`${e.approvalKind}\0${e.approvalId}`)}function isApprovalResolutionRef(e){return e.length===43&&/^[A-Za-z0-9_-]+$/u.test(e)}function readJsonObjectMembers(e){JSON.parse(e);let t=[];for(let n=0;n<e.length;){let r=e[n];if(/\s/u.test(r)){n++;continue}let i=n++;if(r===`"`)for(;n<e.length;){let t=e[n++];if(t===`\\`)n++;else if(t===`"`)break}else if(!`{}[],:`.includes(r))for(;n<e.length&&!/[\s{}[\],:]/u.test(e[n]);)n++;t.push(e.slice(i,n))}let n=/* @__PURE__ */ new Map;if(t[0]!==`{`)return n;for(let e=1;;){let r=t[e];if(r===void 0||r===`}`)break;let i=JSON.parse(r);e+=2;let a=e,o=0;do{let n=t[e++];n===`{`||n===`[`?o++:(n===`}`||n===`]`)&&o--}while(o>0);typeof i==`string`&&!n.has(i)&&n.set(i,t.slice(a,e).join(``)),t[e]===`,`&&e++}return n}function deriveDeliveryQueueRetentionColumns(e,t){let n={retention_id_prefix:null,retention_max_age_ms:null,retention_max_entries:null};try{let r=readJsonObjectMembers(t).get(`completionRetention`);if(!r?.startsWith(`{`))return n;let i=readJsonObjectMembers(r),a=i.get(`idPrefix`),o=a?.startsWith(`"`)?JSON.parse(a):a?.startsWith(`[`)||a?.startsWith(`{`)?a:void 0,s=typeof o==`string`?o:void 0,integer=e=>{let t=e===`true`?1:e&&/^-?\d+$/u.test(e)?Number(e):NaN;return Number.isSafeInteger(t)&&t>=1?t:void 0},c=integer(i.get(`maxAgeMs`)),l=integer(i.get(`maxEntries`));return s&&!s.includes(`\0`)&&e.startsWith(s)&&c!==void 0&&l!==void 0?{retention_id_prefix:s,retention_max_age_ms:c,retention_max_entries:l}:n}catch{return n}}c(Symbol.for(`openclaw.outboundDeliveryEnqueued`),()=>({onEnqueued:e=>{}}));const xi={name:`state.empty-outbound-delivery-queue`,read:e=>e===!0||void 0},Si={name:`state.failed-delivery-queue-health`,read:e=>e},Ci={name:`state.next-delivery-queue-tombstone-expiry`,read:e=>e};function boundedDeliveryReceipts(e){return k(e).selectFrom(`delivery_queue_entries`).select([`queue_name`,`id`,`enqueued_at`,`retention_id_prefix as id_prefix`,`retention_max_age_ms as max_age_ms`,`retention_max_entries as max_entries`]).where(`status`,`in`,[`completed`,`failed`]).where(`recovery_state`,`=`,`completed_bounded`).where(`retention_id_prefix`,`is not`,null)}const wi=[`id`,`entry_json`,`enqueued_at`,`retry_count`,`last_attempt_at`,`last_error`,`platform_send_started_at`,`recovery_state`];function pruneDeliveryQueueTombstones(e,t,n){let r=boundedDeliveryReceipts(e);n&&(r=r.where(`queue_name`,`=`,n.queueName).where(`retention_id_prefix`,`=`,n.idPrefix));let i=k(e),a=j(e,i.with(`policies`,()=>r).with(`ranked`,e=>e.selectFrom(`policies`).selectAll().select(e=>e.fn.agg(`row_number`,[]).over(e=>e.partitionBy([`queue_name`,`id_prefix`]).orderBy(`enqueued_at`,`desc`).orderBy(`id`,`desc`)).as(`retention_rank`))).deleteFrom(`delivery_queue_entries`).where(e=>e(e.refTuple(`queue_name`,`id`),`in`,e.selectFrom(`ranked`).select([`queue_name`,`id`]).where(e=>e.or([e(`enqueued_at`,`<`,e(e.val(t),`-`,e.ref(`max_age_ms`))),e(`retention_rank`,`>`,e.ref(`max_entries`))])).$asTuple(`queue_name`,`id`))));(a.numAffectedRows??0n)>0n&&se(e,Si,void 0);let o=!n&&pruneOrdinaryDeliveryReceipts(e,t);return(a.numAffectedRows??0n)>0n||o}function pruneOrdinaryDeliveryReceipts(e,t){return(j(e,k(e).deleteFrom(`delivery_queue_entries`).where(`status`,`=`,`completed`).where(`enqueued_at`,`<`,t-2592e6).where(e=>e.or([e(`recovery_state`,`is`,null),e(`recovery_state`,`not in`,[`completed_permanent`,`completed_bounded`])]))).numAffectedRows??0n)>0n}function inflateDeliveryQueueRow(e){let t;try{t=JSON.parse(e.entry_json)}catch{return null}return{...t,id:e.id,enqueuedAt:U(e.enqueued_at),retryCount:U(e.retry_count),...e.last_attempt_at==null?{}:{lastAttemptAt:U(e.last_attempt_at)},...e.last_error==null?{}:{lastError:e.last_error},...e.platform_send_started_at==null?{}:{platformSendStartedAt:U(e.platform_send_started_at)},...e.recovery_state==null?{}:{recoveryState:e.recovery_state}}}function deliveryQueueMetadata(e,t){let n=t;return{entryKind:n.kind??e,sessionKey:n.sessionKey??n.session?.key,channel:n.channel??n.route?.channel??n.deliveryContext?.channel,target:n.to??n.route?.to??n.deliveryContext?.to,accountId:n.accountId??n.route?.accountId??n.deliveryContext?.accountId}}function bindDeliveryQueueEntry(e,t=Date.now()){let n=e.status??`pending`,r=e.metadata??deliveryQueueMetadata(e.queueName,e.entry),i=JSON.stringify(e.entry);return{mode:e.insertOnly===!0?`insert`:e.updatePendingOnly===!0?`pending`:e.completeExisting===!0?`complete`:`replace`,row:{queue_name:e.queueName,id:e.entry.id,status:n,entry_kind:r.entryKind??null,session_key:r.sessionKey??null,channel:r.channel??null,target:r.target??null,account_id:r.accountId??null,retry_count:e.entry.retryCount,last_attempt_at:e.entry.lastAttemptAt??null,last_error:e.entry.lastError??null,recovery_state:e.entry.recoveryState??null,platform_send_started_at:e.entry.platformSendStartedAt??null,entry_json:i,...deriveDeliveryQueueRetentionColumns(e.entry.id,i),enqueued_at:e.entry.enqueuedAt,updated_at:t,failed_at:n===`failed`?t:null}}}function createDeliveryQueueUpsert(e,t){let n=k(e);return bt(e,e=>{let r={status:e(e=>e.status),entry_kind:e(e=>e.entry_kind),session_key:e(e=>e.session_key),channel:e(e=>e.channel),target:e(e=>e.target),account_id:e(e=>e.account_id),retry_count:e(e=>e.retry_count),last_attempt_at:e(e=>e.last_attempt_at),last_error:e(e=>e.last_error),recovery_state:e(e=>e.recovery_state),platform_send_started_at:e(e=>e.platform_send_started_at),entry_json:e(e=>e.entry_json),retention_id_prefix:e(e=>e.retention_id_prefix),retention_max_age_ms:e(e=>e.retention_max_age_ms),retention_max_entries:e(e=>e.retention_max_entries),enqueued_at:e(e=>e.enqueued_at),updated_at:e(e=>e.updated_at),failed_at:e(e=>e.failed_at)},i=n.insertInto(`delivery_queue_entries`).values({queue_name:e(e=>e.queue_name),id:e(e=>e.id),...r});return t===`insert`?i.onConflict(e=>e.columns([`queue_name`,`id`]).doNothing()):i.onConflict(e=>{let n=e.columns([`queue_name`,`id`]).doUpdateSet(r);return t===`pending`?n.where(`delivery_queue_entries.status`,`=`,`pending`):t===`complete`?n.where(`delivery_queue_entries.status`,`in`,[`pending`,`failed`]):n})})}const Ti=Ct(()=>({}));function upsertBoundDeliveryQueueEntryInDatabase(e,t){let n=Ti(t.db),r=(n[e.mode]??=createDeliveryQueueUpsert(t.db,e.mode))(e.row).numAffectedRows===1n;return r&&(se(t.db,xi,void 0),se(t.db,Si,void 0),e.row.status!==`pending`&&se(t.db,Ci,void 0)),r}function deliveryQueueEntriesQuery(e,t,n){let r=k(e.db).selectFrom(`delivery_queue_entries`).select(wi).where(`queue_name`,`in`,t);return n===`all`?r:r.where(e=>n===`pending`?e(`status`,`=`,`pending`):e.or([e(`status`,`=`,`pending`),e.and([e(`status`,`=`,`failed`),e(`recovery_state`,`=`,`settlement_pending`)])]))}function createDeliveryQueueRead(e,t){return xt(e.db,n=>deliveryQueueEntriesQuery(e,[n(e=>e.queueName)],t).where(`id`,`=`,n(e=>e.id)))}const Ei=Ct(()=>({}));function loadDeliveryQueueEntryInDatabase(e,t,n,r=`all`){let i=Ei(e.db),a=(i[r]??=createDeliveryQueueRead(e,r))({queueName:t,id:n});return a?inflateDeliveryQueueRow(a):null}function parseDeliveryQueueCompletionRetention(e,t){if(e===`permanent`)return e;let n=x(e);if(!n)return;let r=typeof n.idPrefix==`string`?n.idPrefix:``,a=i(n.maxAgeMs),o=i(n.maxEntries);if(r&&t.startsWith(r)&&a!==void 0&&o!==void 0)return{idPrefix:r,maxAgeMs:a,maxEntries:o}}const finite=e=>typeof e==`number`&&Number.isFinite(e);function inferDeliveryQueueFailureRetention(e,t,n,r=!1){let i=parseDeliveryQueueCompletionRetention(e.completionRetention,t)??parseDeliveryQueueCompletionRetention(e.failureRetention,t);if(i)return i;let a=x(x(e.terminalPolicy)?.fence);if(a?.kind===`none`)return;let o=a?.kind===`permanent`?`permanent`:parseDeliveryQueueCompletionRetention(a,t);if(o)return o;let s=n===`outbound-preparing-v1`||n===`outbound-legacy-preparing-v1`||n===`outbound-prepared-migration-v1`||e.retainOnFailure===!0||x(e.deliveryCompletion)!==null||n===`session`&&finite(e.availableAt),c=r&&(typeof e.platformSendAttemptId==`string`&&e.platformSendAttemptId.length>0||finite(e.platformSendStartedAt)||e.recoveryState===`send_attempt_started`||e.recoveryState===`unknown_after_send`||n===`session`&&(finite(e.deliveryStartedAt)||typeof e.settlementOutcome==`string`&&e.settlementOutcome.length>0||finite(e.acknowledgedAt)));return s||c?`permanent`:void 0}function hasLiveDeliveryQueueClaim(e,t,n){let r=typeof e.availableAt==`number`&&e.availableAt>n;return e.recoveryState===`producer_claimed`?e.producerClaimId===t&&r:(e.recoveryState===`send_attempt_started`||e.recoveryState===`unknown_after_send`)&&e.platformSendAttemptId===t&&(e.requiresProducerClaim!==!0||r)}function projectDeliveryQueueTerminalEntry(e,t,n,r){let i=Number.isSafeInteger(e.retryCount)&&e.retryCount>=0?e.retryCount:0,a=r===`permanent`?`completed_permanent`:r?`completed_bounded`:void 0;return{id:e.id,enqueuedAt:t,retryCount:i,...n===`completed`?{acknowledgedAt:t}:{failedAt:t},...r?{completionRetention:r}:{},...a?{recoveryState:a}:{}}}function nonNegativeSafeInteger(e){let t=typeof e==`bigint`?Number(e):e;return typeof t==`number`&&Number.isSafeInteger(t)&&t>=0?t:void 0}function compactLegacyDeliveryQueueFailures(e){let t=Date.now(),n=e.prepare(`UPDATE delivery_queue_entries SET entry_json = @entryJson,
retention_id_prefix = @retention_id_prefix, retention_max_age_ms = @retention_max_age_ms,
retention_max_entries = @retention_max_entries
WHERE queue_name = @queueName AND id = @id AND status = 'pending' AND entry_json = @previousJson`),r=e.prepare(`SELECT queue_name, id, status, retry_count, entry_json, updated_at, failed_at, recovery_state
FROM delivery_queue_entries WHERE status IN ('pending', 'failed')`);r.setReadBigInts(!0);let i=r.all(),a=e.prepare(`DELETE FROM delivery_queue_entries WHERE queue_name = ? AND id = ? AND status = 'failed'`),o=e.prepare(`UPDATE delivery_queue_entries
SET entry_kind = NULL, session_key = NULL, channel = NULL, target = NULL,
account_id = NULL, retry_count = @retryCount, last_attempt_at = NULL,
last_error = NULL, platform_send_started_at = NULL, entry_json = @entryJson,
retention_id_prefix = @retention_id_prefix, retention_max_age_ms = @retention_max_age_ms,
retention_max_entries = @retention_max_entries,
enqueued_at = @failedAt, failed_at = @failedAt, recovery_state = @recoveryState
WHERE queue_name = @queueName AND id = @id AND status = 'failed'`);for(let e of i){if(e.recovery_state===`settlement_pending`)continue;let r=D(String(e.entry_json)),i=r??{},s=String(e.queue_name),c=String(e.id);if(e.status===`pending`){if(i.retainOnFailure!==!0&&inferDeliveryQueueFailureRetention(i,c,s,!0)){let t=JSON.stringify({...i,retainOnFailure:!0});n.run({entryJson:t,queueName:s,id:c,previousJson:String(e.entry_json),...deriveDeliveryQueueRetentionColumns(c,t)})}continue}let l=nonNegativeSafeInteger(e.failed_at)??nonNegativeSafeInteger(e.updated_at)??t,u=Math.max(nonNegativeSafeInteger(e.retry_count)??0,nonNegativeSafeInteger(i.retryCount)??0),d=r?inferDeliveryQueueFailureRetention(i,c,s,!0):`permanent`;if(!d){a.run(s,c);continue}let f=projectDeliveryQueueTerminalEntry({id:c,retryCount:u},l,`failed`,d),p=JSON.stringify(f);o.run({retryCount:u,entryJson:p,...deriveDeliveryQueueRetentionColumns(c,p),failedAt:l,recoveryState:f.recoveryState??null,queueName:s,id:c})}pruneDeliveryQueueTombstones(e,t)}function ensureOperatorApprovalResolutionRefs(e){L(e,`operator_approvals`)&&an(e,()=>{I(e,`operator_approvals`,`resolution_ref TEXT`);let t=e.prepare(`SELECT approval_id, kind, resolution_ref FROM operator_approvals`).all(),n=e.prepare(`UPDATE operator_approvals SET resolution_ref = ? WHERE approval_id = ?`);for(let e of t){if(typeof e.approval_id!=`string`||!$n(e.kind))throw Error(`operator approval row cannot be assigned a transport reference`);let t=buildApprovalResolutionRef({approvalId:e.approval_id,approvalKind:e.kind});e.resolution_ref!==t&&n.run(t,e.approval_id)}if(e.prepare(`SELECT canonical.approval_id
FROM operator_approvals AS canonical
JOIN operator_approvals AS referenced
ON canonical.approval_id = referenced.resolution_ref
WHERE canonical.approval_id <> referenced.approval_id
LIMIT 1`).get())throw Error(`operator approval ids conflict with durable transport references`);e.exec(`
CREATE UNIQUE INDEX IF NOT EXISTS idx_operator_approvals_resolution_ref
ON operator_approvals(resolution_ref);
`)})}function nullableTextValue(e,t){if(!e||!Object.hasOwn(e,t))return;let n=e[t];return typeof n==`string`||n===null?n:void 0}function repairLegacySubagentRetainedResults(e){if(!L(e,`subagent_runs`))return;let repair=()=>{let t=R(e,`subagent_runs`,`pending_final_delivery_payload_json`),n=e.prepare(t?`SELECT run_id, payload_json, pending_final_delivery_payload_json FROM subagent_runs`:`SELECT run_id, payload_json FROM subagent_runs`).all(),r=e.prepare(`UPDATE subagent_runs
SET payload_json = ?
WHERE run_id = ?`);for(let e of n){let t=D(e.payload_json)??null,n=t?x(t.parentCompletion):null,i=n?.completionTarget===`parent`?n:t,a=i?x(i.completion):null;if(!i||!a)continue;let o=x(i.delivery),s=o?x(o.payload):null,c=e.pending_final_delivery_payload_json?D(e.pending_final_delivery_payload_json)??null:null;if(!(s&&(Object.hasOwn(s,`frozenResultText`)||Object.hasOwn(s,`fallbackFrozenResultText`))||c&&(Object.hasOwn(c,`frozenResultText`)||Object.hasOwn(c,`fallbackFrozenResultText`))))continue;let l=nullableTextValue(s,`frozenResultText`)??nullableTextValue(c,`frozenResultText`),u=nullableTextValue(s,`fallbackFrozenResultText`)??nullableTextValue(c,`fallbackFrozenResultText`);nullableTextValue(a,`resultText`)==null&&l!==void 0&&(a.resultText=l),nullableTextValue(a,`fallbackResultText`)==null&&u!==void 0&&(a.fallbackResultText=u),delete s?.frozenResultText,delete s?.fallbackFrozenResultText,r.run(JSON.stringify(t),e.run_id)}};e.isTransaction?repair():an(e,repair)}function repairLegacySubagentExecutionPayloads(e){L(e,`subagent_runs`)&&e.exec(`
UPDATE subagent_runs
SET payload_json = json_remove(
CASE
WHEN json_extract(payload_json, '$.pauseReason') = 'sessions_yield'
AND json_extract(payload_json, '$.execution.status') <> 'terminal'
AND json_type(payload_json, '$.endedAt') IN ('integer', 'real')
THEN json_remove(json_set(
payload_json,
'$.execution.status', 'terminal',
'$.execution.endedAt', json_extract(payload_json, '$.endedAt')
), '$.execution.outcome')
WHEN (json_type(payload_json, '$.killReconciliation') = 'object'
OR json_extract(payload_json, '$.endedReason') = 'subagent-killed')
AND json_extract(payload_json, '$.execution.status') <> 'terminal'
AND json_type(payload_json, '$.endedAt') IN ('integer', 'real')
AND json_type(payload_json, '$.outcome') = 'object'
THEN json_set(
payload_json,
'$.execution.status', 'terminal',
'$.execution.endedAt', json_extract(payload_json, '$.endedAt'),
'$.execution.outcome', json_extract(payload_json, '$.outcome')
)
ELSE payload_json
END,
'$.startedAt', '$.endedAt', '$.outcome'
)
WHERE json_valid(payload_json)
AND (json_type(payload_json, '$.startedAt') IS NOT NULL
OR json_type(payload_json, '$.endedAt') IS NOT NULL
OR json_type(payload_json, '$.outcome') IS NOT NULL);
`)}function backfillAcpReplayEstimatedBytes(e,t=!1){if(!L(e,`acp_replay_events`)||!R(e,`acp_replay_events`,`estimated_bytes`))return;let n=`state.repair.acpReplayUtf8Accounting`,r=L(e,`config_machine_state`)?k(e):void 0;if(!t&&r&&A(e,r.selectFrom(`config_machine_state`).select(`state_key`).where(`state_key`,`=`,n)))return;let i=k(e),a=e.prepare(`UPDATE acp_replay_events SET estimated_bytes = ? WHERE session_id = ? AND seq = ?`);for(let t of St(e,i.selectFrom(`acp_replay_events`).select([`session_id`,`seq`,`session_key`,`run_id`,`update_json`,`estimated_bytes`]))){let e=estimateAcpEventRowBytes({sessionId:t.session_id,sessionKey:t.session_key,runId:t.run_id,updateJson:t.update_json});U(t.estimated_bytes)!==e&&a.run(e,t.session_id,t.seq)}let o=e.prepare(`UPDATE acp_replay_sessions SET estimated_bytes = ? WHERE session_id = ?`);for(let t of St(e,i.selectFrom(`acp_replay_sessions as s`).select([`s.session_id`,`s.session_key`,`s.cwd`,`s.estimated_bytes`]).select(e=>e.fn.coalesce(e.selectFrom(`acp_replay_events as e`).select(e=>e.fn.sum(`e.estimated_bytes`).as(`total`)).whereRef(`e.session_id`,`=`,`s.session_id`),e.val(0)).as(`event_bytes`)))){let e=estimateAcpSessionRowBytes({sessionId:t.session_id,sessionKey:t.session_key,cwd:t.cwd})+U(t.event_bytes);U(t.estimated_bytes)!==e&&o.run(e,t.session_id)}r&&j(e,r.insertInto(`config_machine_state`).values({state_key:n,value_json:`true`,updated_at_ms:Date.now()}).onConflict(e=>e.column(`state_key`).doNothing()))}function backfillCronRunLogEntryJson(e){if(!L(e,`cron_run_logs`)||!R(e,`cron_run_logs`,`entry_json`))return;let t=e.prepare(`SELECT store_key, job_id, seq, ts
FROM cron_run_logs
WHERE entry_json = '{}'`).all();if(t.length===0)return;let n=e.prepare(`UPDATE cron_run_logs
SET entry_json = ?
WHERE store_key = ? AND job_id = ? AND seq = ?`);for(let e of t)n.run(JSON.stringify({ts:U(e.ts),jobId:e.job_id,action:`finished`}),e.store_key,e.job_id,e.seq)}function textField(e,t){let n=e?.[t];return typeof n==`string`&&n.trim()?n:null}function backfillCronJobsFromJobJson(e){if(!L(e,`cron_jobs`)||!R(e,`cron_jobs`,`job_json`)||!R(e,`cron_jobs`,`payload_kind`))return;let t=e.prepare(`SELECT store_key, job_id, job_json, updated_at
FROM cron_jobs
WHERE payload_kind = 'message'
OR name = ''`).all();if(t.length===0)return;let n=e.prepare(`UPDATE cron_jobs
SET name = ?,
enabled = ?,
agent_id = ?,
payload_kind = ?,
runtime_updated_at_ms = ?
WHERE store_key = ?
AND job_id = ?`);for(let e of t){let t=D(e.job_json)??null;if(!t)continue;let r=x(t.schedule),i=x(t.payload),a=textField(r,`kind`),o=textField(i,`kind`),c=a===`at`&&textField(r,`at`),l=a===`every`&&s(r?.everyMs)!=null,u=a===`cron`&&textField(r,`expr`),d=o===`systemEvent`&&textField(i,`text`),f=o===`agentTurn`&&textField(i,`message`);r&&i&&(c||l||u)&&(d||f)&&n.run(textField(t,`name`)??e.job_id,t.enabled===!1?0:1,textField(t,`agentId`),o,s(t.updatedAtMs)??(U(e.updated_at)||0),e.store_key,e.job_id)}}function backfillDeliveryQueueEntriesFromEntryJson(e){if(!L(e,`delivery_queue_entries`)||!R(e,`delivery_queue_entries`,`entry_json`)||!R(e,`delivery_queue_entries`,`retry_count`))return;compactLegacyDeliveryQueueFailures(e);let t=e.prepare(`SELECT queue_name, id, entry_json
FROM delivery_queue_entries
WHERE status = 'pending'
AND (retry_count = 0
OR last_attempt_at IS NULL
OR last_error IS NULL
OR recovery_state IS NULL
OR platform_send_started_at IS NULL
OR entry_kind IS NULL
OR session_key IS NULL
OR channel IS NULL
OR target IS NULL
OR account_id IS NULL)`).all();if(t.length===0)return;let n=e.prepare(`UPDATE delivery_queue_entries
SET entry_kind = COALESCE(?, entry_kind),
session_key = COALESCE(?, session_key),
channel = COALESCE(?, channel),
target = COALESCE(?, target),
account_id = COALESCE(?, account_id),
retry_count = ?,
last_attempt_at = COALESCE(?, last_attempt_at),
last_error = COALESCE(?, last_error),
recovery_state = COALESCE(?, recovery_state),
platform_send_started_at = COALESCE(?, platform_send_started_at)
WHERE queue_name = ?
AND id = ?`);for(let e of t){let t=D(e.entry_json)??null;if(!t)continue;let r=x(t.session),i=x(t.route),o=x(t.deliveryContext);n.run(textField(t,`kind`),textField(t,`sessionKey`)??textField(r,`key`),textField(t,`channel`)??textField(i,`channel`)??textField(o,`channel`),textField(t,`to`)??textField(i,`to`)??textField(o,`to`),textField(t,`accountId`)??textField(i,`accountId`)??textField(o,`accountId`),a(t.retryCount,{min:0})??0,a(t.lastAttemptAt,{min:0})??null,textField(t,`lastError`),textField(t,`recoveryState`),a(t.platformSendStartedAt,{min:0})??null,e.queue_name,e.id)}}const Di=[[`failure_delivery_mode`,`mode`],[`failure_delivery_channel`,`channel`],[`failure_delivery_to`,`to`],[`failure_delivery_account_id`,`accountId`]];function reprojectLegacyCronJson(e){let t=Di.map(([t])=>R(e,`cron_jobs`,t)?M(t):`NULL AS ${M(t)}`),n=R(e,`cron_jobs`,`last_run_status`)?`last_run_status`:`NULL AS last_run_status`,r=e.prepare(`SELECT store_key, job_id, enabled, job_json, state_json, ${n}, ${t.join(`, `)}
FROM cron_jobs`).all(),i=e.prepare(`UPDATE cron_jobs SET job_json = ?, state_json = ? WHERE store_key = ? AND job_id = ?`);for(let e of r){if(typeof e.store_key!=`string`||typeof e.job_id!=`string`||typeof e.job_json!=`string`||typeof e.state_json!=`string`)throw Error(`OpenClaw v12 cron job row is not canonical`);let t=x(O(e.job_json)),n=x(O(e.state_json));if(!t||!n)continue;let r=!1,a=x(t.delivery),o=x(a?.failureDestination);if((!Object.hasOwn(t,`delivery`)||a!==null)&&(!a||!Object.hasOwn(a,`failureDestination`)||o!==null)){let n=a??{},i=o??{};for(let[t,n]of Di){let a=e[t];typeof a!=`string`||Object.hasOwn(i,n)||(i[n]=a===``?null:a,r=!0)}r&&(n.failureDestination=i,t.delivery=n)}typeof t.enabled!=`boolean`&&(t.enabled=e.enabled!==0,r=!0);let s=Object.hasOwn(n,`lastStatus`);!Object.hasOwn(n,`lastRunStatus`)&&(s||typeof e.last_run_status==`string`)&&(n.lastRunStatus=s?n.lastStatus:e.last_run_status,r=!0),r&&i.run(JSON.stringify(t),JSON.stringify(n),e.store_key,e.job_id)}}function rebuildJsonCanonicalTable(e,t){let n=`${t}_migration_v13`;if(L(e,n))throw Error(`OpenClaw v13 migration table already exists: ${n}`);let r=N(v,t,{errorMessage:`Canonical ${t} schema block is missing`}).replace(`CREATE TABLE IF NOT EXISTS ${t} (`,`CREATE TABLE ${n} (`);e.exec(r);let i=e.prepare(`PRAGMA table_xinfo(${n})`).all().flatMap(e=>e.hidden===0&&typeof e.name==`string`?[e.name]:[]),a=i.map(n=>Un.some(e=>e.tableName===t&&e.columnName===n)&&!R(e,t,n)?`NULL`:M(n));e.exec(`INSERT INTO ${n} (${i.map(M).join(`, `)}) SELECT ${a.join(`, `)} FROM ${t};`),e.exec(`DROP TABLE ${t};`),e.exec(`ALTER TABLE ${n} RENAME TO ${t};`)}function migrateJsonCanonicalWideRowsV13(e,t){if(t>=13)return!1;let n=!1;L(e,`cron_jobs`)&&R(e,`cron_jobs`,`schedule_kind`)&&(reprojectLegacyCronJson(e),rebuildJsonCanonicalTable(e,`cron_jobs`),n=!0);let r=L(e,`workspace_setup_state`),i=L(e,`workspace_attestations`);if(r&&!R(e,`workspace_setup_state`,`attested_at_ms`)&&(e.exec(`ALTER TABLE workspace_setup_state ADD COLUMN attested_at_ms INTEGER;`),e.exec(`ALTER TABLE workspace_setup_state ADD COLUMN attestation_updated_at_ms INTEGER;`),rebuildJsonCanonicalTable(e,`workspace_setup_state`),n=!0),i){e.exec(`
UPDATE workspace_setup_state
SET attested_at_ms = (
SELECT attested_at_ms FROM workspace_attestations
WHERE workspace_attestations.workspace_key = workspace_setup_state.workspace_key
),
attestation_updated_at_ms = (
SELECT updated_at_ms FROM workspace_attestations
WHERE workspace_attestations.workspace_key = workspace_setup_state.workspace_key
)
WHERE workspace_key IN (SELECT workspace_key FROM workspace_attestations);
`);let t=L(e,`workspace_path_aliases`)?`(SELECT alias.workspace_path FROM workspace_path_aliases alias
WHERE alias.workspace_key = a.workspace_key LIMIT 1)`:`NULL`;e.exec(`
INSERT INTO workspace_setup_state (
workspace_key, workspace_path, attested_at_ms, attestation_updated_at_ms
)
SELECT a.workspace_key,
${t},
a.attested_at_ms,
a.updated_at_ms
FROM workspace_attestations a
WHERE a.workspace_key NOT IN (SELECT workspace_key FROM workspace_setup_state);
`),e.exec(`DROP TABLE workspace_attestations;`),n=!0}(r||i)&&L(e,`workspace_generated_bootstrap_hashes`)&&(rebuildJsonCanonicalTable(e,`workspace_generated_bootstrap_hashes`),e.exec(`
DELETE FROM workspace_generated_bootstrap_hashes
WHERE workspace_key NOT IN (SELECT workspace_key FROM workspace_setup_state);
`));for(let[t,r,i]of[[`auth_profile_stores`,`store_json`,`authProfiles.store`],[`auth_profile_state`,`state_json`,`authProfiles.state`]])L(e,t)&&(e.prepare(`INSERT INTO config_machine_state (state_key, value_json, updated_at_ms)
SELECT ?, ${r}, updated_at FROM ${t} WHERE store_key = 'shared'
ON CONFLICT(state_key) DO NOTHING`).run(i),e.exec(`DROP TABLE ${t};`),n=!0);if(L(e,`installed_plugin_index`)){let t=e.prepare(`SELECT * FROM installed_plugin_index WHERE index_key = 'installed-plugin-index'`).get();if(t){let n=x(O(String(t.install_records_json))),r=O(String(t.plugins_json)),i=O(String(t.diagnostics_json));if(!n||!Array.isArray(r)||!Array.isArray(i)){let n=`plugins.installedIndex.quarantine`,r=`Preserved invalid legacy installed_plugin_index row in diagnostic_events (${n}). Run openclaw doctor --fix or openclaw plugins registry --refresh to repair the plugin index; inspect the preserved row if install records need recovery.`;createSqliteAuditRecordKernel(e,{scope:n,maxEntries:2**53-1}).register(prepareSqliteAuditRecord(n,{key:Cr(`sha256`).update(JSON.stringify(t)).digest(`hex`),value:{level:`warn`,message:r,raw:t},createdAt:Date.now()})),it(e,()=>pt(`state/db`).warn(r))}let a={version:Number(t.version),...typeof t.warning==`string`&&t.warning?{warning:t.warning}:{},hostContractVersion:t.host_contract_version,compatRegistryVersion:t.compat_registry_version,migrationVersion:Number(t.migration_version),policyHash:t.policy_hash,generatedAtMs:Number(t.generated_at_ms),...typeof t.workspace_dir==`string`?{workspaceDir:t.workspace_dir}:{},...typeof t.refresh_reason==`string`&&t.refresh_reason?{refreshReason:t.refresh_reason}:{},installRecords:n,plugins:r,diagnostics:i};e.prepare(`INSERT INTO config_machine_state (state_key, value_json, updated_at_ms)
VALUES (?, ?, ?) ON CONFLICT(state_key) DO NOTHING`).run(`plugins.installedIndex`,JSON.stringify({revision:Number(t.updated_at_ms),index:a}),Number(t.updated_at_ms))}e.exec(`DROP TABLE installed_plugin_index;`),n=!0}return L(e,`subagent_runs`)&&R(e,`subagent_runs`,`task`)&&(repairLegacySubagentRetainedResults(e),rebuildJsonCanonicalTable(e,`subagent_runs`),n=!0),n}const Z=[`operator_approvals`,`cron_run_receipts`,`execution_decision_facts`,`skill_workshop_changes`];function migratePortableIdentityColumnsV22(e,t){if(t>=22)return!1;let n=!1,r=P(e)??Ft(e);for(let t of Z){if(!L(e,t)||R(e,t,`cursor_id`))continue;let i=r.tableSql.get(t);if(typeof i!=`string`)throw Error(`Missing v22 cursor migration schema: ${t}`);let a=M(`${t}_migration_v22`),o=M(t),s=[...un(e,t)].map(M).join(`, `);e.exec(`CREATE TABLE ${a} (cursor_id INTEGER NOT NULL, ${i.slice(i.indexOf(`(`)+1)};
INSERT INTO ${a} (rowid, ${s}, cursor_id) SELECT rowid, ${s}, rowid FROM ${o} ORDER BY rowid;
DROP TABLE ${o};
ALTER TABLE ${a} RENAME TO ${o};`);for(let n of[...r.indexDefinitions.values(),...r.triggers.values()])n.table===t&&typeof n.sql==`string`&&e.exec(n.sql);n=!0}if(L(e,`acp_sessions`)){n=I(e,`acp_sessions`,`resume_agent_session_id TEXT`)||n,n=I(e,`acp_sessions`,`resume_acpx_session_id TEXT`)||n;let t=`CASE WHEN json_valid(identity_json) THEN identity_json END`,r=`char(9,10,11,12,13,32,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288,65279)`;e.exec(`UPDATE acp_sessions SET
resume_agent_session_id = CASE WHEN json_type(${t}, '$.agentSessionId') = 'text'
THEN trim(json_extract(${t}, '$.agentSessionId'), ${r}) END,
resume_acpx_session_id = CASE WHEN json_type(${t}, '$.acpxSessionId') = 'text'
THEN trim(json_extract(${t}, '$.acpxSessionId'), ${r}) END;
DROP INDEX IF EXISTS idx_acp_sessions_resume_agent;
DROP INDEX IF EXISTS idx_acp_sessions_resume_acpx;`)}return n}function migrateTaskRunIndexesV24(e,t){return t>=24?!1:(e.exec(`
DROP INDEX IF EXISTS idx_task_runs_run_id;
DROP INDEX IF EXISTS idx_task_runs_status;
DROP INDEX IF EXISTS idx_task_runs_runtime_status;
DROP INDEX IF EXISTS idx_task_runs_cleanup_after;
DROP INDEX IF EXISTS idx_task_runs_last_event_at;
DROP INDEX IF EXISTS idx_task_runs_owner_key;
DROP INDEX IF EXISTS idx_task_runs_parent_flow_id;
DROP INDEX IF EXISTS idx_task_runs_child_session_key;
DROP INDEX IF EXISTS idx_task_runs_requester_session_key;
DROP INDEX IF EXISTS idx_task_runs_runtime_source_ended;
DROP INDEX IF EXISTS idx_task_runs_runtime_ended;
`),!0)}function migrateSqliteTableWithoutRowid(e,t){let n=P(e)??Ft(e),r=n.tableSql.get(t);if(!r)return!1;let i=Dt(r,`(`),a=Ot(r,i),o=r.slice(a+1).replace(/;\s*$/u,``).trim();if(/\bWITHOUT\s+ROWID\b/iu.test(o))return!1;let s=M(t),c=M(`${t}_without_rowid_migration`),l=[...un(e,t)].map(M).join(`, `);e.exec(`CREATE TABLE ${c} ${r.slice(i,a+1)}
${o?`${o}, `:``}WITHOUT ROWID;
INSERT INTO ${c} (${l}) SELECT ${l} FROM ${s};
DROP TABLE ${s};
ALTER TABLE ${c} RENAME TO ${s};`);for(let r of[...n.indexDefinitions.values(),...n.triggers.values()])r.table===t&&typeof r.sql==`string`&&e.exec(r.sql);return!0}function withLegacyStateHeadLayout(e){return e.replace(/(CREATE TABLE IF NOT EXISTS session_state_heads \([\s\S]*?\n\) STRICT), WITHOUT ROWID;/u,`$1;`)}function migrateSessionStateHeadLayoutV26(e,t){return t<26&&migrateSqliteTableWithoutRowid(e,`session_state_heads`)}function withLegacyStateWriteIndexes(e){return`${e.replace(/ON state_leases\(owner\);/u,`ON state_leases(owner, updated_at DESC);`)}
CREATE INDEX IF NOT EXISTS idx_skill_usage_key
ON skill_usage(skill_key, skill_file);
CREATE INDEX IF NOT EXISTS idx_acp_replay_events_session_seq
ON acp_replay_events(session_id, seq);
`}function migrateStateWriteIndexesV27(e,t){return t>=27?!1:(e.exec(`
DROP INDEX IF EXISTS idx_acp_replay_events_session_seq;
DROP INDEX IF EXISTS idx_skill_usage_key;
DROP INDEX IF EXISTS idx_state_leases_owner;
`),!0)}const Oi=c(Symbol.for(`openclaw.stateSchemaMutationConflictError`),()=>class extends Error{constructor(e,t){super(`OpenClaw refused shared state schema mutation at ${e} because another Gateway owns that state directory. Stop that Gateway or perform the update through its managed restart path, then retry.`,{cause:t}),this.name=`StateSchemaMutationConflictError`}});function acquireSchemaMaintenanceLease({databasePath:e,busyTimeoutMs:t}){if(Zt(e))return;let n=ke(e),r=lt(n);if(r)r.assertCurrent();else try{return ut(n,{busyTimeoutMs:t})}catch(e){throw e instanceof et?new Oi(n,e):e}}function withStateDatabaseSchemaMaintenance(e,t){let n=acquireSchemaMaintenanceLease(e);return n?we(n,`state schema mutation`,()=>n.run(t)):t()}async function withStateDatabaseSchemaMaintenanceAsync(e,t){let n=acquireSchemaMaintenanceLease(e);if(!n)return await t();let r;try{r={value:await n.run(t)}}catch(e){r={error:e}}try{n.release()}catch(e){throw`error`in r?Se([r.error,e],`state schema mutation and resource release both failed`,r.error):new Ce(`state schema mutation completed, but releasing its resource failed`,e)}if(`error`in r)throw r.error;return r.value}var ki=/* @__PURE__ */ e({STATE_SUPERVISION_KEY:()=>Ai,assertOpenClawStateWriteAllowed:()=>assertOpenClawStateWriteAllowed,assertOwnershipAllowsWrite:()=>assertOwnershipAllowsWrite,inspectOpenClawStateOwnershipFromDatabase:()=>inspectOpenClawStateOwnershipFromDatabase,isOpenClawStateWriteContentionError:()=>isOpenClawStateWriteContentionError,parseExternalOwnership:()=>parseExternalOwnership});const Ai=`gateway.supervision`,ji=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u,Mi={name:`state.external-ownership`,read(e){if(e===null)return null;if(b(e)&&e.version===1&&e.mode===`external`&&typeof e.managerId==`string`&&typeof e.claimedAt==`number`)return{version:1,mode:`external`,managerId:e.managerId,claimedAt:e.claimedAt}}};function isOpenClawStateWriteContentionError(e){return e instanceof et||e instanceof Oi||g(e)}function parseExternalOwnership(e,t){let n;try{n=JSON.parse(e)}catch{throw new Ee(t,`reserved value is not valid JSON`)}let r=b(n)?n:void 0,i=r?Object.keys(r).toSorted().join(`,`):``,a=r?.managerId,o=r?.claimedAt;if(i!==`claimedAt,managerId,mode,version`||r?.version!==1||r?.mode!==`external`||typeof a!=`string`||!ji.test(a)||typeof o!=`number`||!Number.isSafeInteger(o)||o<0||o>864e13)throw new Ee(t,`reserved value does not match the version 1 external ownership contract`);return{version:1,mode:`external`,managerId:a,claimedAt:o}}function inspectOpenClawStateOwnershipFromDatabase(e,t,n=!1){try{if(!n&&!L(e,`config_machine_state`))return null;let r=n||E(e)?`SELECT value_json FROM config_machine_state WHERE state_key = ? LIMIT 1`:`SELECT value_json FROM config_machine_state NOT INDEXED WHERE state_key = ? LIMIT 1`,i=e.prepare(r).get(Ai);if(!i)return null;if(typeof i.value_json!=`string`)throw new Ee(t,`reserved value is not text`);return parseExternalOwnership(i.value_json,t)}catch(e){throw _n(e,t)}}function assertOwnershipAllowsWrite(e,t,n){if(e&&!gn(n))throw new De(t,e.managerId)}function assertOpenClawStateWriteAllowed(e){let t=W.resolve(e.databasePath);ct(t);let n=e.inspectOwnership?void 0:ae(e.database,Mi);if(n===void 0){let r=inspectOpenClawStateOwnershipFromDatabase(e.database,t,e.schemaReady);n=e.inspectOwnership?void 0:ae(e.database,Mi),n===void 0&&(n=r,se(e.database,Mi,n))}assertOwnershipAllowsWrite(n,t,e.env??process.env)}const Ni=/* @__PURE__ */ new Map;function getOpenClawStateRuntimeSchema(e,t=v){let{includeVersionLazyAdditiveTables:n,includeAgentDeletionJournal:r=!0}=e,i=`${n}:${r}:${t===`
CREATE TABLE IF NOT EXISTS mcp_oauth_stores (
store_key TEXT NOT NULL PRIMARY KEY,
format_version INTEGER NOT NULL CHECK (format_version = 1),
store_json TEXT NOT NULL,
updated_at INTEGER NOT NULL
) STRICT;
CREATE TABLE IF NOT EXISTS mcp_oauth_pending_authorizations (
state TEXT NOT NULL PRIMARY KEY,
store_key TEXT NOT NULL,
create_time INTEGER NOT NULL
) STRICT;
CREATE TABLE IF NOT EXISTS diagnostic_events (
scope TEXT NOT NULL,
event_key TEXT NOT NULL,
payload_json TEXT NOT NULL,
created_at INTEGER NOT NULL,
sequence INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY (scope, event_key)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_diagnostic_events_scope_sequence
ON diagnostic_events(scope, sequence, event_key);
CREATE TABLE IF NOT EXISTS skill_usage (
skill_file TEXT NOT NULL PRIMARY KEY,
skill_key TEXT NOT NULL,
skill_name TEXT NOT NULL,
skill_source TEXT NOT NULL,
first_used_at_ms INTEGER NOT NULL,
last_used_at_ms INTEGER NOT NULL,
use_count INTEGER NOT NULL,
last_agent_id TEXT
) STRICT;
-- Profile-owned skill library: additive, absent until first publication/import.
CREATE TABLE IF NOT EXISTS skill_library_entries (
skill_id TEXT NOT NULL PRIMARY KEY,
owner_profile_id TEXT,
author_profile_id TEXT NOT NULL,
slug TEXT NOT NULL,
current_revision TEXT NOT NULL,
shared INT NOT NULL,
enabled INT NOT NULL,
removed INT NOT NULL,
created_at INT NOT NULL,
updated_at INT NOT NULL
) STRICT;
CREATE TABLE IF NOT EXISTS skill_library_revisions (
skill_id TEXT NOT NULL,
revision TEXT NOT NULL,
description TEXT NOT NULL,
files_json TEXT NOT NULL,
created_at INT NOT NULL,
PRIMARY KEY (skill_id, revision)
) STRICT;
CREATE TABLE IF NOT EXISTS skill_library_events (
event_id TEXT NOT NULL PRIMARY KEY,
skill_id TEXT NOT NULL,
revision TEXT NOT NULL,
action TEXT NOT NULL,
actor_profile_id TEXT NOT NULL,
created_at INT NOT NULL
) STRICT;
CREATE TABLE IF NOT EXISTS skill_library_uploads (
upload_id TEXT NOT NULL PRIMARY KEY,
owner_profile_id TEXT NOT NULL,
slug TEXT NOT NULL,
size_bytes INT NOT NULL,
sha256 TEXT NOT NULL,
archive_blob BLOB NOT NULL,
expires_at INT NOT NULL,
published_skill_id TEXT
) STRICT;
-- End profile-owned skill library.
CREATE TABLE IF NOT EXISTS skill_workshop_changes (
cursor_id INTEGER NOT NULL,
change_id TEXT NOT NULL PRIMARY KEY,
agent_id TEXT NOT NULL,
skill_name TEXT NOT NULL,
action TEXT NOT NULL CHECK (action IN ('create', 'patch', 'write_file', 'remove_file', 'archive', 'restore')),
actor TEXT NOT NULL CHECK (actor IN ('agent', 'review', 'curator', 'user')),
summary TEXT NOT NULL,
version_id TEXT,
session_key TEXT,
run_id TEXT,
created_at_ms INTEGER NOT NULL
) STRICT;
CREATE UNIQUE INDEX IF NOT EXISTS skill_workshop_changes_cursor_id_idx
ON skill_workshop_changes(cursor_id);
CREATE INDEX IF NOT EXISTS idx_skill_workshop_changes_agent_time
ON skill_workshop_changes(agent_id, created_at_ms);
CREATE TABLE IF NOT EXISTS audit_events (
sequence INTEGER PRIMARY KEY AUTOINCREMENT,
event_id TEXT NOT NULL UNIQUE,
source_id TEXT NOT NULL UNIQUE,
schema_version INTEGER NOT NULL DEFAULT 1,
source_sequence INTEGER NOT NULL,
occurred_at INTEGER NOT NULL,
kind TEXT NOT NULL,
action TEXT NOT NULL,
status TEXT NOT NULL,
error_code TEXT,
actor_type TEXT NOT NULL,
actor_id TEXT NOT NULL,
agent_id TEXT,
session_key TEXT,
session_id TEXT,
run_id TEXT,
tool_call_id TEXT,
tool_name TEXT,
direction TEXT,
channel TEXT,
conversation_kind TEXT,
message_outcome TEXT,
reason_code TEXT,
delivery_kind TEXT,
failure_stage TEXT,
duration_ms INTEGER,
result_count INTEGER,
account_ref TEXT,
conversation_ref TEXT,
message_ref TEXT,
target_ref TEXT
) STRICT;
CREATE INDEX IF NOT EXISTS idx_audit_events_time
ON audit_events(occurred_at DESC, sequence DESC);
CREATE INDEX IF NOT EXISTS idx_audit_events_agent_sequence
ON audit_events(agent_id, sequence DESC);
CREATE INDEX IF NOT EXISTS idx_audit_events_session_sequence
ON audit_events(session_key, sequence DESC);
CREATE INDEX IF NOT EXISTS idx_audit_events_run_sequence
ON audit_events(run_id, sequence DESC);
CREATE INDEX IF NOT EXISTS idx_audit_events_kind_sequence
ON audit_events(kind, sequence DESC);
CREATE INDEX IF NOT EXISTS idx_audit_events_status_sequence
ON audit_events(status, sequence DESC);
CREATE INDEX IF NOT EXISTS idx_audit_events_channel_sequence
ON audit_events(channel, sequence DESC);
CREATE INDEX IF NOT EXISTS idx_audit_events_direction_sequence
ON audit_events(direction, sequence DESC);
CREATE TABLE IF NOT EXISTS outbound_message_execution_bindings (
event_id TEXT NOT NULL PRIMARY KEY,
context_id TEXT NOT NULL CHECK (length(context_id) BETWEEN 1 AND 256),
execution_id TEXT NOT NULL CHECK (length(execution_id) BETWEEN 1 AND 256),
run_id TEXT NOT NULL CHECK (length(run_id) BETWEEN 1 AND 256),
FOREIGN KEY (event_id) REFERENCES audit_events(event_id) ON DELETE CASCADE
) STRICT;
CREATE INDEX IF NOT EXISTS outbound_message_execution_bindings_execution_event_idx
ON outbound_message_execution_bindings (context_id, execution_id, run_id, event_id);
CREATE TABLE IF NOT EXISTS outbound_message_progress (
sequence INTEGER PRIMARY KEY AUTOINCREMENT,
progress_id TEXT NOT NULL UNIQUE CHECK (length(progress_id) BETWEEN 1 AND 256),
source_id TEXT NOT NULL UNIQUE CHECK (length(source_id) BETWEEN 1 AND 512),
source_sequence INTEGER NOT NULL CHECK (source_sequence >= 1),
schema_version INTEGER NOT NULL CHECK (schema_version = 1),
occurred_at INTEGER NOT NULL CHECK (occurred_at >= 0),
action TEXT NOT NULL CHECK (
action IN ('message.outbound.queued', 'message.outbound.platform-started')
),
outcome TEXT NOT NULL CHECK (outcome IN ('queued', 'platform_started')),
actor_type TEXT NOT NULL CHECK (actor_type IN ('agent', 'system')),
actor_id TEXT NOT NULL CHECK (length(actor_id) BETWEEN 1 AND 256),
agent_id TEXT CHECK (agent_id IS NULL OR length(agent_id) BETWEEN 1 AND 256),
run_id TEXT CHECK (run_id IS NULL OR length(run_id) BETWEEN 1 AND 256),
context_id TEXT,
execution_id TEXT,
channel TEXT NOT NULL CHECK (length(channel) BETWEEN 1 AND 256),
conversation_kind TEXT NOT NULL CHECK (
conversation_kind IN ('direct', 'group', 'channel', 'unknown')
),
duration_ms INTEGER CHECK (duration_ms IS NULL OR duration_ms >= 0),
account_ref TEXT,
conversation_ref TEXT,
target_ref TEXT,
UNIQUE (occurred_at, progress_id)
) STRICT;
CREATE INDEX IF NOT EXISTS outbound_message_progress_occurred_idx
ON outbound_message_progress (occurred_at, sequence);
CREATE INDEX IF NOT EXISTS outbound_message_progress_run_occurred_idx
ON outbound_message_progress (run_id, occurred_at, sequence);
CREATE TABLE IF NOT EXISTS audit_identity_keys (
id INTEGER NOT NULL PRIMARY KEY CHECK (id = 1),
key_id TEXT NOT NULL,
key BLOB NOT NULL,
created_at INTEGER NOT NULL
) STRICT;
CREATE TABLE IF NOT EXISTS config_revision_keys (
id INTEGER NOT NULL PRIMARY KEY CHECK (id = 1),
hmac_key BLOB NOT NULL CHECK (length(hmac_key) = 32)
) STRICT;
CREATE TABLE IF NOT EXISTS execution_identity_contexts (
context_id TEXT NOT NULL PRIMARY KEY CHECK (length(context_id) BETWEEN 1 AND 256),
execution_id TEXT NOT NULL UNIQUE CHECK (length(execution_id) BETWEEN 1 AND 256),
run_id TEXT NOT NULL CHECK (length(run_id) BETWEEN 1 AND 256),
created_at INTEGER NOT NULL CHECK (created_at >= 0),
coverage_state TEXT NOT NULL CHECK (
coverage_state IN ('attribution-only', 'unattributed', 'unknown', 'unsupported')
),
context_bytes INTEGER NOT NULL CHECK (context_bytes BETWEEN 1 AND 16384),
context_json TEXT NOT NULL CHECK (length(context_json) > 0),
UNIQUE (created_at, context_id)
) STRICT;
CREATE INDEX IF NOT EXISTS execution_identity_contexts_run_created_idx
ON execution_identity_contexts (run_id, created_at, execution_id);
CREATE TABLE IF NOT EXISTS execution_decision_facts (
cursor_id INTEGER NOT NULL,
receipt_id TEXT NOT NULL PRIMARY KEY CHECK (length(receipt_id) BETWEEN 1 AND 256),
context_id TEXT NOT NULL CHECK (length(context_id) BETWEEN 1 AND 256),
execution_id TEXT NOT NULL CHECK (length(execution_id) BETWEEN 1 AND 256),
run_id TEXT NOT NULL CHECK (length(run_id) BETWEEN 1 AND 256),
action_id TEXT CHECK (action_id IS NULL OR length(action_id) BETWEEN 1 AND 256),
action_family TEXT NOT NULL CHECK (length(action_family) BETWEEN 1 AND 256),
decision_outcome TEXT NOT NULL CHECK (
decision_outcome IN ('allowed', 'denied', 'not-applicable', 'unknown')
),
coverage_state TEXT NOT NULL CHECK (
coverage_state IN ('enforced', 'attribution-only', 'unattributed', 'unknown', 'unsupported')
),
reason_code TEXT NOT NULL CHECK (length(reason_code) BETWEEN 1 AND 256),
owner TEXT NOT NULL CHECK (length(owner) BETWEEN 1 AND 256),
source_ref TEXT NOT NULL CHECK (length(source_ref) BETWEEN 1 AND 256),
occurred_at INTEGER NOT NULL CHECK (occurred_at >= 0),
receipt_bytes INTEGER NOT NULL CHECK (receipt_bytes BETWEEN 1 AND 16384),
receipt_json TEXT NOT NULL CHECK (length(receipt_json) > 0),
UNIQUE (occurred_at, receipt_id)
) STRICT;
CREATE UNIQUE INDEX IF NOT EXISTS execution_decision_facts_cursor_id_idx
ON execution_decision_facts(cursor_id);
CREATE INDEX IF NOT EXISTS execution_decision_facts_context_occurred_idx
ON execution_decision_facts (context_id, occurred_at, receipt_id);
CREATE INDEX IF NOT EXISTS execution_decision_facts_run_occurred_idx
ON execution_decision_facts (run_id, occurred_at, receipt_id);
-- Exact admission identity stays separate from owner-native lifecycle rows so
-- older readers retain byte-compatible cron/task/flow table definitions.
CREATE TABLE IF NOT EXISTS execution_owner_lifecycle_bindings (
owner_kind TEXT NOT NULL,
owner_id TEXT NOT NULL,
context_id TEXT NOT NULL,
execution_id TEXT NOT NULL,
PRIMARY KEY (owner_kind, owner_id)
) STRICT;
CREATE TABLE IF NOT EXISTS session_state_events (
sequence INTEGER PRIMARY KEY AUTOINCREMENT,
dedupe_key TEXT UNIQUE,
session_key TEXT NOT NULL,
session_id TEXT,
agent_id TEXT NOT NULL,
kind TEXT NOT NULL,
actor_type TEXT NOT NULL,
actor_id TEXT,
run_id TEXT,
occurred_at INTEGER NOT NULL,
summary TEXT NOT NULL,
payload_json TEXT
) STRICT;
CREATE INDEX IF NOT EXISTS idx_session_state_events_session_sequence
ON session_state_events(session_key, sequence DESC);
CREATE INDEX IF NOT EXISTS idx_session_state_events_time
ON session_state_events(occurred_at DESC, sequence DESC);
CREATE TABLE IF NOT EXISTS session_state_heads (
session_key TEXT NOT NULL,
agent_id TEXT NOT NULL,
last_sequence INTEGER NOT NULL,
pruned_max_sequence INTEGER NOT NULL DEFAULT 0,
updated_at INTEGER NOT NULL,
PRIMARY KEY (session_key, agent_id)
) STRICT, WITHOUT ROWID;
-- Notifiable watcher identity is the bare session key, matching the process-local
-- system-event queue it feeds. Provenance distinguishes explicit immediate-wake
-- watches from ambient queue-only group watches. Other bare keys
-- (session.scope="global") are ambiguous across agents and excluded until watcher
-- identity is agent-scoped end-to-end.
CREATE TABLE IF NOT EXISTS session_watch_cursors (
watcher_session_key TEXT NOT NULL,
watcher_store_path TEXT,
target_session_key TEXT NOT NULL,
last_seen_sequence INTEGER NOT NULL DEFAULT 0,
notified_sequence INTEGER NOT NULL DEFAULT 0,
material_sequence INTEGER NOT NULL DEFAULT 0,
provenance TEXT NOT NULL DEFAULT 'explicit' CHECK (provenance IN ('explicit', 'ambient-group')),
updated_at INTEGER NOT NULL,
PRIMARY KEY (watcher_session_key, target_session_key)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_session_watch_cursors_target
ON session_watch_cursors(target_session_key);
CREATE TABLE IF NOT EXISTS session_upstream_links (
session_key TEXT NOT NULL,
agent_id TEXT NOT NULL,
catalog_id TEXT NOT NULL,
host_id TEXT NOT NULL,
thread_id TEXT NOT NULL,
upstream_kind TEXT NOT NULL,
upstream_ref_json TEXT,
last_marker_json TEXT,
last_scanned_at INTEGER,
created_at INTEGER NOT NULL,
updated_at INTEGER NOT NULL,
-- (session_key, agent_id) composite identity: under session.scope="global" agents
-- share bare keys; a key-only row would let one agent overwrite another's upstream.
PRIMARY KEY (session_key, agent_id)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_session_upstream_links_catalog_id
ON session_upstream_links(catalog_id);
CREATE TABLE IF NOT EXISTS 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;
CREATE INDEX IF NOT EXISTS idx_state_leases_expiry
ON state_leases(expires_at, scope, lease_key)
WHERE expires_at IS NOT NULL;
CREATE INDEX IF NOT EXISTS idx_state_leases_owner
ON state_leases(owner);
CREATE TABLE IF NOT EXISTS exec_approvals_config (
config_key TEXT NOT NULL PRIMARY KEY,
raw_json TEXT NOT NULL,
socket_path TEXT,
has_socket_token INTEGER NOT NULL,
default_security TEXT,
default_ask TEXT,
default_ask_fallback TEXT,
auto_allow_skills INTEGER,
agent_count INTEGER NOT NULL,
allowlist_count INTEGER NOT NULL,
updated_at_ms INTEGER NOT NULL
) STRICT;
CREATE TABLE IF NOT EXISTS operator_approvals (
cursor_id INTEGER NOT NULL,
approval_id TEXT NOT NULL PRIMARY KEY CHECK (
length(approval_id) > 0 AND approval_id NOT IN ('.', '..')
),
resolution_ref TEXT NOT NULL CHECK (
length(resolution_ref) = 43 AND resolution_ref NOT GLOB '*[^A-Za-z0-9_-]*'
),
kind TEXT NOT NULL CHECK (kind IN ('exec', 'plugin', 'system-agent')),
status TEXT NOT NULL CHECK (status IN ('pending', 'allowed', 'denied', 'expired', 'cancelled')),
presentation_json TEXT NOT NULL,
requested_by_device_id TEXT,
requested_by_client_id TEXT,
requested_by_device_token_auth INTEGER NOT NULL DEFAULT 0,
reviewer_device_ids_json TEXT NOT NULL,
source_agent_id TEXT,
source_session_key TEXT,
source_session_id TEXT,
source_run_id TEXT,
source_tool_call_id TEXT,
source_tool_name TEXT,
audience_session_keys_json TEXT NOT NULL,
runtime_epoch TEXT NOT NULL,
created_at_ms INTEGER NOT NULL,
expires_at_ms INTEGER NOT NULL,
updated_at_ms INTEGER NOT NULL,
decision TEXT CHECK (decision IN ('allow-once', 'allow-always', 'deny')),
terminal_reason TEXT CHECK (
terminal_reason IN (
'user',
'timeout',
'malformed-verdict',
'no-route',
'run-aborted',
'gateway-restart',
'storage-corrupt'
)
),
resolved_at_ms INTEGER,
resolver_kind TEXT CHECK (resolver_kind IN ('device', 'channel', 'runtime', 'system')),
resolver_id TEXT,
consumed_at_ms INTEGER,
consumed_by TEXT,
CHECK (expires_at_ms >= created_at_ms),
CHECK (updated_at_ms >= created_at_ms),
CHECK (resolved_at_ms IS NULL OR resolved_at_ms >= created_at_ms),
CHECK (resolved_at_ms IS NULL OR resolved_at_ms <= updated_at_ms),
CHECK (consumed_at_ms IS NULL OR consumed_at_ms >= resolved_at_ms),
CHECK (consumed_at_ms IS NULL OR consumed_at_ms <= updated_at_ms),
CHECK (requested_by_device_token_auth IN (0, 1)),
CHECK (
(
status = 'pending'
AND decision IS NULL
AND terminal_reason IS NULL
AND resolved_at_ms IS NULL
AND resolver_kind IS NULL
AND resolver_id IS NULL
AND consumed_at_ms IS NULL
AND consumed_by IS NULL
)
OR (
status = 'allowed'
AND decision IN ('allow-once', 'allow-always')
AND terminal_reason = 'user'
AND resolved_at_ms IS NOT NULL
AND resolver_kind IS NOT NULL
)
OR (
status = 'denied'
AND decision = 'deny'
AND terminal_reason IN ('user', 'malformed-verdict', 'no-route', 'storage-corrupt')
AND resolved_at_ms IS NOT NULL
AND resolver_kind IS NOT NULL
AND consumed_at_ms IS NULL
AND consumed_by IS NULL
)
OR (
status = 'expired'
AND decision = 'deny'
AND terminal_reason = 'timeout'
AND resolved_at_ms IS NOT NULL
AND resolver_kind IS NOT NULL
AND consumed_at_ms IS NULL
AND consumed_by IS NULL
)
OR (
status = 'cancelled'
AND decision = 'deny'
AND terminal_reason IN ('run-aborted', 'gateway-restart')
AND resolved_at_ms IS NOT NULL
AND resolver_kind IS NOT NULL
AND consumed_at_ms IS NULL
AND consumed_by IS NULL
)
),
CHECK (
(consumed_at_ms IS NULL AND consumed_by IS NULL)
OR (
status = 'allowed'
AND decision = 'allow-once'
AND consumed_at_ms IS NOT NULL
AND consumed_by IS NOT NULL
)
)
) STRICT;
CREATE UNIQUE INDEX IF NOT EXISTS idx_operator_approvals_cursor_id
ON operator_approvals(cursor_id);
CREATE INDEX IF NOT EXISTS idx_operator_approvals_status_expiry
ON operator_approvals(status, expires_at_ms, approval_id);
CREATE UNIQUE INDEX IF NOT EXISTS idx_operator_approvals_resolution_ref
ON operator_approvals(resolution_ref);
CREATE INDEX IF NOT EXISTS idx_operator_approvals_source_session_created
ON operator_approvals(source_session_key, created_at_ms DESC, approval_id);
CREATE INDEX IF NOT EXISTS idx_operator_approvals_source_run_resolved
ON operator_approvals(source_run_id, resolved_at_ms, approval_id)
WHERE source_run_id IS NOT NULL AND resolved_at_ms IS NOT NULL;
CREATE INDEX IF NOT EXISTS idx_operator_approvals_resolved
ON operator_approvals(resolved_at_ms, approval_id)
WHERE resolved_at_ms IS NOT NULL;
CREATE INDEX IF NOT EXISTS idx_operator_approvals_runtime_pending
ON operator_approvals(runtime_epoch, approval_id)
WHERE status = 'pending';
CREATE TABLE IF NOT EXISTS operator_approval_execution_identities (
approval_id TEXT NOT NULL PRIMARY KEY
REFERENCES operator_approvals(approval_id) ON DELETE CASCADE,
source_context_id TEXT NOT NULL CHECK (
length(source_context_id) BETWEEN 1 AND 256 AND source_context_id = trim(source_context_id)
),
source_execution_id TEXT NOT NULL CHECK (
length(source_execution_id) BETWEEN 1 AND 256 AND source_execution_id = trim(source_execution_id)
)
) STRICT;
CREATE TABLE IF NOT EXISTS operator_approval_standing_grants (
grant_id TEXT NOT NULL PRIMARY KEY CHECK (length(grant_id) > 0),
minted_by_approval_id TEXT NOT NULL
REFERENCES operator_approvals(approval_id) ON DELETE CASCADE,
agent_id TEXT NOT NULL CHECK (length(agent_id) > 0),
cron_job_id TEXT NOT NULL CHECK (length(cron_job_id) > 0),
job_config_revision TEXT NOT NULL CHECK (length(job_config_revision) > 0),
operation_binding TEXT NOT NULL CHECK (length(operation_binding) > 0),
created_at_ms INTEGER NOT NULL,
expires_at_ms INTEGER CHECK (expires_at_ms IS NULL OR expires_at_ms >= created_at_ms),
revoked_at_ms INTEGER,
revoked_by TEXT,
last_used_at_ms INTEGER,
use_count INTEGER NOT NULL DEFAULT 0
) STRICT;
CREATE INDEX IF NOT EXISTS idx_operator_approval_standing_grants_binding
ON operator_approval_standing_grants(agent_id, cron_job_id, operation_binding, created_at_ms DESC);
CREATE TABLE IF NOT EXISTS operator_approval_standing_grant_generations (
grant_id TEXT NOT NULL PRIMARY KEY
REFERENCES operator_approval_standing_grants(grant_id) ON DELETE CASCADE,
job_definition_generation INTEGER NOT NULL CHECK (job_definition_generation >= 1)
) STRICT;
CREATE TABLE IF NOT EXISTS 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;
CREATE TABLE IF NOT EXISTS config_machine_state (
state_key TEXT NOT NULL PRIMARY KEY,
value_json TEXT NOT NULL,
updated_at_ms INTEGER NOT NULL
) STRICT;
CREATE TABLE IF NOT EXISTS device_pairing_pending (
request_id TEXT NOT NULL PRIMARY KEY,
device_id TEXT NOT NULL,
public_key TEXT NOT NULL,
display_name TEXT,
platform TEXT,
device_family TEXT,
client_id TEXT,
client_mode TEXT,
browser_origin TEXT,
role TEXT,
roles_json TEXT,
scopes_json TEXT,
remote_ip TEXT,
silent INTEGER,
is_repair INTEGER,
ts INTEGER NOT NULL,
refreshed_at_ms INTEGER
) STRICT;
CREATE INDEX IF NOT EXISTS idx_device_pairing_pending_device
ON device_pairing_pending(device_id, ts DESC);
CREATE TABLE IF NOT EXISTS device_pairing_paired (
device_id TEXT NOT NULL PRIMARY KEY,
public_key TEXT NOT NULL,
display_name TEXT,
operator_label TEXT,
platform TEXT,
device_family TEXT,
client_id TEXT,
client_mode TEXT,
browser_origin TEXT,
role TEXT,
roles_json TEXT,
scopes_json TEXT,
approved_scopes_json TEXT,
remote_ip TEXT,
tokens_json TEXT,
approved_via TEXT,
node_surface_json TEXT,
pending_node_surface_json TEXT,
created_at_ms INTEGER NOT NULL,
approved_at_ms INTEGER NOT NULL,
last_seen_at_ms INTEGER,
last_seen_reason TEXT
) STRICT;
CREATE INDEX IF NOT EXISTS idx_device_pairing_paired_approved
ON device_pairing_paired(approved_at_ms DESC, device_id);
CREATE TABLE IF NOT EXISTS device_bootstrap_tokens (
token_key TEXT NOT NULL PRIMARY KEY,
token TEXT NOT NULL,
setup_id TEXT,
ts INTEGER NOT NULL,
device_id TEXT,
public_key TEXT,
profile_json TEXT,
redeemed_profile_json TEXT,
pending_profile_json TEXT,
issued_at_ms INTEGER NOT NULL,
last_used_at_ms INTEGER
) STRICT;
CREATE INDEX IF NOT EXISTS idx_device_bootstrap_tokens_ts
ON device_bootstrap_tokens(ts);
-- Terminal outcome of a redeemed setup credential. The bootstrap row is deleted
-- on redemption, so this is the only durable proof a setup code succeeded; the
-- presenting client reconciles it when the completion broadcast is missed.
-- Non-secret only: never the bootstrap token or anything derived from it.
-- Bounded by retention to a handful of live rows, so the primary key is the
-- only access path worth having.
CREATE TABLE IF NOT EXISTS device_pair_setup_completions (
setup_id TEXT NOT NULL PRIMARY KEY,
device_id TEXT NOT NULL,
device_name TEXT,
access TEXT NOT NULL,
completed_at_ms INTEGER NOT NULL,
delivery_state TEXT NOT NULL CHECK (delivery_state IN ('uncertain', 'confirmed')),
retain_until_ms INTEGER NOT NULL
) STRICT;
CREATE TABLE IF NOT EXISTS device_pairing_join_codes (
shortcode TEXT,
payload_json TEXT,
created_at_ms INTEGER,
expires_at_ms INTEGER
) STRICT;
CREATE TABLE IF NOT EXISTS device_pairing_browser_requests (
request_id TEXT NOT NULL PRIMARY KEY,
code TEXT NOT NULL UNIQUE,
device_id TEXT NOT NULL UNIQUE,
public_key TEXT NOT NULL,
remote_ip TEXT,
user_agent TEXT,
origin TEXT,
status TEXT NOT NULL CHECK (status IN ('pending', 'approved', 'rejected')),
approved_token_sha256 TEXT,
created_at_ms INTEGER NOT NULL,
expires_at_ms INTEGER NOT NULL
) STRICT;
CREATE TABLE IF NOT EXISTS macos_port_guardian_records (
pid INTEGER NOT NULL PRIMARY KEY,
port INTEGER NOT NULL,
command TEXT NOT NULL,
mode TEXT NOT NULL,
timestamp REAL NOT NULL
) STRICT;
CREATE INDEX IF NOT EXISTS idx_macos_port_guardian_records_port
ON macos_port_guardian_records(port, timestamp DESC);
CREATE TABLE IF NOT EXISTS workspace_setup_state (
workspace_key TEXT NOT NULL PRIMARY KEY,
-- NULL only for attestation-only rows whose legacy source never recorded a
-- path (orphan hashed-key attestations); setup rows always carry one.
workspace_path TEXT,
-- NULL setup columns mean an attestation-only row: replaceWorkspaceAttestation
-- may record hashes before any setup milestone exists for the workspace.
version INTEGER,
bootstrap_seeded_at TEXT,
setup_completed_at TEXT,
updated_at INTEGER,
attested_at_ms INTEGER,
attestation_updated_at_ms INTEGER,
bootstrap_deferred INTEGER,
CHECK (version IS NULL OR workspace_path IS NOT NULL)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_workspace_setup_state_path
ON workspace_setup_state(workspace_path);
CREATE TABLE IF NOT EXISTS workspace_path_aliases (
alias_key TEXT NOT NULL PRIMARY KEY,
alias_path TEXT NOT NULL,
workspace_key TEXT NOT NULL,
workspace_path TEXT NOT NULL,
updated_at_ms INTEGER NOT NULL
) STRICT;
CREATE INDEX IF NOT EXISTS idx_workspace_path_aliases_workspace
ON workspace_path_aliases(workspace_key);
CREATE TABLE IF NOT EXISTS workspace_generated_bootstrap_hashes (
workspace_key TEXT NOT NULL,
filename TEXT NOT NULL,
sha256 TEXT NOT NULL,
PRIMARY KEY (workspace_key, filename),
FOREIGN KEY (workspace_key) REFERENCES workspace_setup_state(workspace_key) ON DELETE CASCADE
) STRICT;
CREATE TABLE IF NOT EXISTS native_hook_relay_bridges (
relay_id TEXT NOT NULL PRIMARY KEY,
pid INTEGER NOT NULL,
hostname TEXT NOT NULL,
port INTEGER NOT NULL,
token TEXT NOT NULL,
expires_at_ms INTEGER NOT NULL,
updated_at_ms INTEGER NOT NULL
) STRICT;
CREATE INDEX IF NOT EXISTS idx_native_hook_relay_bridges_expires
ON native_hook_relay_bridges(expires_at_ms, relay_id);
CREATE TABLE IF NOT EXISTS managed_outgoing_image_records (
attachment_id TEXT NOT NULL PRIMARY KEY,
session_key TEXT NOT NULL,
agent_id TEXT,
message_id TEXT,
created_at TEXT NOT NULL,
updated_at TEXT,
retention_class TEXT,
alt TEXT NOT NULL,
original_media_root TEXT NOT NULL,
original_media_id TEXT NOT NULL,
original_media_subdir TEXT NOT NULL,
original_content_type TEXT NOT NULL,
original_width INTEGER,
original_height INTEGER,
original_size_bytes INTEGER,
original_filename TEXT,
record_json TEXT NOT NULL,
cleanup_pending INTEGER NOT NULL DEFAULT 0 CHECK (cleanup_pending IN (0, 1))
) STRICT;
CREATE INDEX IF NOT EXISTS idx_managed_outgoing_images_session
ON managed_outgoing_image_records(session_key, created_at DESC, attachment_id);
CREATE INDEX IF NOT EXISTS idx_managed_outgoing_images_message
ON managed_outgoing_image_records(session_key, message_id, attachment_id)
WHERE message_id IS NOT NULL;
CREATE INDEX IF NOT EXISTS idx_managed_outgoing_images_agent_session
ON managed_outgoing_image_records(session_key, agent_id, created_at DESC, attachment_id);
CREATE INDEX IF NOT EXISTS idx_managed_outgoing_images_agent_message
ON managed_outgoing_image_records(session_key, agent_id, message_id, attachment_id)
WHERE message_id IS NOT NULL;
CREATE TABLE IF NOT EXISTS channel_pairing_requests (
channel_key TEXT NOT NULL,
account_id TEXT NOT NULL,
request_id TEXT NOT NULL,
code TEXT NOT NULL,
created_at TEXT NOT NULL,
last_seen_at TEXT NOT NULL,
meta_json TEXT,
PRIMARY KEY (channel_key, account_id, request_id)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_channel_pairing_requests_code
ON channel_pairing_requests(channel_key, code);
CREATE INDEX IF NOT EXISTS idx_channel_pairing_requests_created
ON channel_pairing_requests(channel_key, created_at, request_id);
CREATE TABLE IF NOT EXISTS channel_pairing_allow_entries (
channel_key TEXT NOT NULL,
account_id TEXT NOT NULL,
entry TEXT NOT NULL,
sort_order INTEGER NOT NULL,
updated_at INTEGER NOT NULL,
PRIMARY KEY (channel_key, account_id, entry)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_channel_pairing_allow_account
ON channel_pairing_allow_entries(channel_key, account_id, sort_order, entry);
CREATE TABLE IF NOT EXISTS web_push_subscriptions (
endpoint_hash TEXT NOT NULL PRIMARY KEY,
subscription_id TEXT NOT NULL UNIQUE,
endpoint TEXT NOT NULL,
p256dh TEXT NOT NULL,
auth TEXT NOT NULL,
device_id TEXT,
user_profile_id TEXT,
preferences_json TEXT,
created_at_ms INTEGER NOT NULL,
updated_at_ms INTEGER NOT NULL
) STRICT;
CREATE INDEX IF NOT EXISTS idx_web_push_subscriptions_updated
ON web_push_subscriptions(updated_at_ms DESC, subscription_id);
CREATE TABLE IF NOT EXISTS web_push_approval_deliveries (
approval_id TEXT NOT NULL
REFERENCES operator_approvals(approval_id) ON DELETE CASCADE,
subscription_id TEXT NOT NULL
REFERENCES web_push_subscriptions(subscription_id) ON DELETE CASCADE,
device_id TEXT NOT NULL,
user_profile_id TEXT,
prepared_at_ms INTEGER NOT NULL,
PRIMARY KEY (approval_id, subscription_id)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_web_push_approval_deliveries_subscription
ON web_push_approval_deliveries(subscription_id, approval_id);
CREATE TABLE IF NOT EXISTS apns_registrations (
node_id TEXT NOT NULL PRIMARY KEY,
transport TEXT NOT NULL,
token TEXT,
relay_handle TEXT,
send_grant TEXT,
installation_id TEXT,
relay_origin TEXT,
topic TEXT NOT NULL,
environment TEXT NOT NULL,
distribution TEXT,
token_debug_suffix TEXT,
updated_at_ms INTEGER NOT NULL
) STRICT;
CREATE INDEX IF NOT EXISTS idx_apns_registrations_updated
ON apns_registrations(updated_at_ms DESC, node_id);
CREATE TABLE IF NOT EXISTS apns_registration_tombstones (
node_id TEXT NOT NULL PRIMARY KEY,
deleted_at_ms INTEGER NOT NULL
) STRICT;
-- Node-host-owned launch journal. The descriptor and its credential remain
-- process memory only; this table records bounded supervision facts.
CREATE TABLE IF NOT EXISTS node_worker_launches (
launch_id TEXT NOT NULL PRIMARY KEY
CHECK (length(launch_id) BETWEEN 1 AND 256 AND instr(launch_id, char(0)) = 0),
plan_hash TEXT NOT NULL
CHECK (length(plan_hash) = 64 AND plan_hash NOT GLOB '*[^0-9a-f]*'),
gateway_namespace TEXT NOT NULL
CHECK (
length(gateway_namespace) BETWEEN 1 AND 128
AND gateway_namespace NOT GLOB '*[^A-Za-z0-9._-]*'
AND gateway_namespace GLOB '[A-Za-z0-9]*'
),
environment_id TEXT NOT NULL
CHECK (length(environment_id) BETWEEN 1 AND 256 AND instr(environment_id, char(0)) = 0),
session_id TEXT NOT NULL
CHECK (length(session_id) BETWEEN 1 AND 256 AND instr(session_id, char(0)) = 0),
owner_epoch INTEGER NOT NULL CHECK (owner_epoch BETWEEN 1 AND 9007199254740991),
placement_generation INTEGER NOT NULL
CHECK (placement_generation BETWEEN 0 AND 9007199254740991),
run_id TEXT NOT NULL
CHECK (length(run_id) BETWEEN 1 AND 256 AND instr(run_id, char(0)) = 0),
state TEXT NOT NULL
CHECK (state IN ('pending', 'running', 'completed', 'failed', 'interrupted', 'cancelled')),
supervisor_pid INTEGER NOT NULL CHECK (supervisor_pid BETWEEN 1 AND 2147483647),
supervisor_start_time INTEGER NOT NULL
CHECK (supervisor_start_time BETWEEN 0 AND 9007199254740991),
worker_pid INTEGER CHECK (worker_pid IS NULL OR worker_pid BETWEEN 1 AND 2147483647),
worker_start_time INTEGER CHECK (
worker_start_time IS NULL OR worker_start_time BETWEEN 0 AND 9007199254740991
),
result_json TEXT CHECK (
result_json IS NULL
OR (
length(CAST(result_json AS BLOB)) BETWEEN 1 AND 65536
AND instr(result_json, char(0)) = 0
AND json_valid(result_json)
)
),
error_text TEXT CHECK (
error_text IS NULL
OR (
length(CAST(error_text AS BLOB)) BETWEEN 1 AND 4096
AND instr(error_text, char(0)) = 0
AND instr(error_text, char(10)) = 0
AND instr(error_text, char(13)) = 0
)
),
completed_at_ms INTEGER CHECK (
completed_at_ms IS NULL OR completed_at_ms BETWEEN 0 AND 9007199254740991
),
created_at_ms INTEGER NOT NULL CHECK (created_at_ms BETWEEN 0 AND 9007199254740991),
updated_at_ms INTEGER NOT NULL CHECK (
updated_at_ms BETWEEN created_at_ms AND 9007199254740991
),
CHECK ((worker_pid IS NULL) = (worker_start_time IS NULL)),
CHECK (
(state = 'pending'
AND worker_pid IS NULL AND result_json IS NULL AND error_text IS NULL
AND completed_at_ms IS NULL)
OR
(state = 'running'
AND worker_pid IS NOT NULL AND result_json IS NULL AND error_text IS NULL
AND completed_at_ms IS NULL)
OR
(state = 'completed'
AND result_json IS NOT NULL AND error_text IS NULL
AND completed_at_ms BETWEEN created_at_ms AND updated_at_ms)
OR
(state IN ('failed', 'interrupted', 'cancelled')
AND result_json IS NULL AND error_text IS NOT NULL
AND completed_at_ms BETWEEN created_at_ms AND updated_at_ms)
)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_node_worker_launches_terminal_completed
ON node_worker_launches(completed_at_ms, launch_id)
WHERE completed_at_ms IS NOT NULL;
CREATE TABLE IF NOT EXISTS node_worker_launch_boots (
launch_id TEXT NOT NULL PRIMARY KEY
REFERENCES node_worker_launches(launch_id) ON DELETE CASCADE,
boot_id TEXT CHECK (boot_id IS NULL OR length(boot_id) BETWEEN 1 AND 128)
) STRICT;
CREATE TABLE IF NOT EXISTS node_worker_launch_containers (
launch_id TEXT PRIMARY KEY,
container_json TEXT
) STRICT;
CREATE TABLE IF NOT EXISTS node_worker_launch_cleanup (
launch_id TEXT NOT NULL PRIMARY KEY
REFERENCES node_worker_launches(launch_id) ON DELETE CASCADE,
cleanup_mode TEXT NOT NULL CHECK (cleanup_mode IN ('process-group', 'owned-anchor')),
lineage_settled INTEGER CHECK (lineage_settled IS NULL OR lineage_settled = 1)
) STRICT;
-- Older readers retain owned-anchor custody: lineage EOF is not this certificate.
CREATE TABLE IF NOT EXISTS node_worker_launch_process_scopes (
launch_id TEXT NOT NULL PRIMARY KEY
REFERENCES node_worker_launches(launch_id) ON DELETE CASCADE,
scope_kind TEXT NOT NULL CHECK (scope_kind = 'linux-subreaper'),
descendants_reaped INTEGER CHECK (descendants_reaped IS NULL OR descendants_reaped = 1)
) STRICT;
-- Turn receipts have a shorter lifetime than their physical worker owner.
-- Keeping the launch running preserves capacity and predecessor cleanup semantics.
CREATE TABLE IF NOT EXISTS node_worker_turns (
turn_id TEXT NOT NULL PRIMARY KEY
CHECK (length(turn_id) BETWEEN 1 AND 256 AND instr(turn_id, char(0)) = 0),
owner_launch_id TEXT NOT NULL
REFERENCES node_worker_launches(launch_id) ON DELETE CASCADE,
plan_hash TEXT NOT NULL
CHECK (length(plan_hash) = 64 AND plan_hash NOT GLOB '*[^0-9a-f]*'),
run_id TEXT NOT NULL
CHECK (length(run_id) BETWEEN 1 AND 256 AND instr(run_id, char(0)) = 0),
state TEXT NOT NULL
CHECK (state IN ('running', 'completed', 'failed', 'interrupted', 'cancelled')),
result_json TEXT CHECK (
result_json IS NULL
OR (
length(CAST(result_json AS BLOB)) BETWEEN 1 AND 65536
AND instr(result_json, char(0)) = 0
AND json_valid(result_json)
)
),
error_text TEXT CHECK (
error_text IS NULL
OR (
length(CAST(error_text AS BLOB)) BETWEEN 1 AND 4096
AND instr(error_text, char(0)) = 0
AND instr(error_text, char(10)) = 0
AND instr(error_text, char(13)) = 0
)
),
completed_at_ms INTEGER CHECK (
completed_at_ms IS NULL OR completed_at_ms BETWEEN 0 AND 9007199254740991
),
created_at_ms INTEGER NOT NULL CHECK (created_at_ms BETWEEN 0 AND 9007199254740991),
updated_at_ms INTEGER NOT NULL CHECK (
updated_at_ms BETWEEN created_at_ms AND 9007199254740991
),
CHECK (
(state = 'running'
AND result_json IS NULL AND error_text IS NULL AND completed_at_ms IS NULL)
OR
(state = 'completed'
AND result_json IS NOT NULL AND error_text IS NULL
AND completed_at_ms BETWEEN created_at_ms AND updated_at_ms)
OR
(state IN ('failed', 'interrupted', 'cancelled')
AND result_json IS NULL AND error_text IS NOT NULL
AND completed_at_ms BETWEEN created_at_ms AND updated_at_ms)
)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_node_worker_turns_terminal_completed
ON node_worker_turns(completed_at_ms, turn_id)
WHERE completed_at_ms IS NOT NULL;
CREATE UNIQUE INDEX IF NOT EXISTS idx_node_worker_turns_active_owner
ON node_worker_turns(owner_launch_id)
WHERE state = 'running';
CREATE TABLE IF NOT EXISTS config_health_entries (
config_path TEXT NOT NULL PRIMARY KEY,
last_known_good_json TEXT,
last_promoted_good_json TEXT,
last_observed_suspicious_signature TEXT,
updated_at_ms INTEGER NOT NULL
) STRICT;
CREATE TABLE IF NOT EXISTS clawhub_promotion_claims (
slug TEXT NOT NULL PRIMARY KEY,
provider TEXT,
model_keys_json TEXT NOT NULL,
ends_at_ms INTEGER NOT NULL,
claimed_at_ms INTEGER NOT NULL
) STRICT;
CREATE TABLE IF NOT EXISTS official_external_plugin_catalog_snapshots (
feed_url TEXT NOT NULL PRIMARY KEY,
body TEXT NOT NULL,
status INTEGER NOT NULL,
etag TEXT,
last_modified TEXT,
checksum TEXT NOT NULL,
saved_at TEXT NOT NULL,
trust_mode TEXT,
trust_key_id TEXT,
trust_signature_count INTEGER,
trust_threshold INTEGER,
trust_verified_at TEXT,
updated_at_ms INTEGER NOT NULL
) STRICT;
CREATE INDEX IF NOT EXISTS idx_official_external_plugin_catalog_snapshots_updated
ON official_external_plugin_catalog_snapshots(updated_at_ms DESC, feed_url);
CREATE TABLE IF NOT EXISTS update_runs (
run_id TEXT PRIMARY KEY NOT NULL,
created_at_ms INTEGER NOT NULL,
updated_at_ms INTEGER NOT NULL,
trigger TEXT NOT NULL CHECK (trigger IN ('chat', 'control-ui', 'cli', 'campaign', 'mac-app', 'api')),
phase TEXT NOT NULL CHECK (phase IN ('requested', 'staging', 'validating', 'repairing', 'activating', 'restarting', 'verifying', 'finished')),
status TEXT NOT NULL CHECK (status IN ('running', 'succeeded', 'failed', 'rolled-back', 'skipped')),
reason TEXT,
origin_json TEXT NOT NULL CHECK (length(CAST(origin_json AS BLOB)) <= 16384),
target_json TEXT NOT NULL CHECK (length(CAST(target_json AS BLOB)) <= 16384),
before_json TEXT NOT NULL CHECK (length(CAST(before_json AS BLOB)) <= 16384),
after_json TEXT NOT NULL CHECK (length(CAST(after_json AS BLOB)) <= 16384),
steps_json TEXT NOT NULL CHECK (length(CAST(steps_json AS BLOB)) <= 16384),
verification_json TEXT NOT NULL CHECK (length(CAST(verification_json AS BLOB)) <= 16384),
repair_json TEXT NOT NULL CHECK (length(CAST(repair_json AS BLOB)) <= 16384),
confirmed_at_ms INTEGER,
finished_at_ms INTEGER,
downtime_ms INTEGER,
CHECK ((status = 'running' AND phase != 'finished' AND finished_at_ms IS NULL) OR
(status != 'running' AND phase = 'finished' AND finished_at_ms IS NOT NULL))
) STRICT;
CREATE INDEX IF NOT EXISTS idx_update_runs_created
ON update_runs(created_at_ms DESC, run_id);
CREATE INDEX IF NOT EXISTS idx_update_runs_active
ON update_runs(status, created_at_ms DESC, run_id);
CREATE TABLE IF NOT EXISTS gateway_restart_sentinel (
sentinel_key TEXT NOT NULL PRIMARY KEY,
version INTEGER NOT NULL,
kind TEXT NOT NULL,
status TEXT NOT NULL,
ts INTEGER NOT NULL,
session_key TEXT,
thread_id TEXT,
delivery_channel TEXT,
delivery_to TEXT,
delivery_account_id TEXT,
message TEXT,
continuation_json TEXT,
doctor_hint TEXT,
stats_json TEXT,
payload_json TEXT NOT NULL,
updated_at_ms INTEGER NOT NULL
) STRICT;
CREATE INDEX IF NOT EXISTS idx_gateway_restart_sentinel_ts
ON gateway_restart_sentinel(ts DESC, sentinel_key);
CREATE TABLE IF NOT EXISTS gateway_restart_intent (
intent_key TEXT NOT NULL PRIMARY KEY,
kind TEXT NOT NULL,
pid INTEGER NOT NULL,
created_at INTEGER NOT NULL,
reason TEXT,
force INTEGER,
wait_ms INTEGER,
updated_at_ms INTEGER NOT NULL
) STRICT;
CREATE TABLE IF NOT EXISTS gateway_restart_handoff (
handoff_key TEXT NOT NULL PRIMARY KEY,
kind TEXT NOT NULL,
version INTEGER NOT NULL,
intent_id TEXT NOT NULL,
pid INTEGER NOT NULL,
process_instance_id TEXT,
created_at INTEGER NOT NULL,
expires_at INTEGER NOT NULL,
reason TEXT,
restart_trace_started_at INTEGER,
restart_trace_last_at INTEGER,
source TEXT NOT NULL,
restart_kind TEXT NOT NULL,
supervisor_mode TEXT NOT NULL,
updated_at_ms INTEGER NOT NULL
) STRICT;
CREATE INDEX IF NOT EXISTS idx_gateway_restart_handoff_expiry
ON gateway_restart_handoff(expires_at, pid);
CREATE TABLE IF NOT EXISTS gateway_boot_lifecycle (
boot_id TEXT NOT NULL PRIMARY KEY,
pid INTEGER NOT NULL,
started_at_ms INTEGER NOT NULL,
completed_at_ms INTEGER,
outcome TEXT,
startup_reason TEXT,
reason TEXT
) STRICT;
CREATE INDEX IF NOT EXISTS idx_gateway_boot_lifecycle_started
ON gateway_boot_lifecycle(started_at_ms);
CREATE TABLE IF NOT EXISTS acp_sessions (
session_key TEXT NOT NULL PRIMARY KEY,
session_id TEXT,
backend TEXT NOT NULL,
agent TEXT NOT NULL,
runtime_session_name TEXT NOT NULL,
identity_json TEXT,
resume_agent_session_id TEXT,
resume_acpx_session_id TEXT,
mode TEXT NOT NULL,
runtime_options_json TEXT,
cwd TEXT,
state TEXT NOT NULL,
last_activity_at INTEGER NOT NULL,
last_error TEXT,
updated_at INTEGER NOT NULL
) STRICT;
CREATE INDEX IF NOT EXISTS idx_acp_sessions_state_activity
ON acp_sessions(state, last_activity_at DESC, session_key);
CREATE INDEX IF NOT EXISTS idx_acp_sessions_agent_activity
ON acp_sessions(agent, last_activity_at DESC, session_key);
CREATE INDEX IF NOT EXISTS idx_acp_sessions_resume_agent
ON acp_sessions(resume_agent_session_id);
CREATE INDEX IF NOT EXISTS idx_acp_sessions_resume_acpx
ON acp_sessions(resume_acpx_session_id);
CREATE TABLE IF NOT EXISTS acp_replay_sessions (
session_id TEXT NOT NULL PRIMARY KEY,
session_key TEXT NOT NULL,
cwd TEXT NOT NULL,
complete INTEGER NOT NULL,
created_at INTEGER NOT NULL,
updated_at INTEGER NOT NULL,
next_seq INTEGER NOT NULL,
-- Running estimate of this session's ledger footprint (row overhead plus
-- all event rows), maintained at insert/trim so budget checks never scan
-- acp_replay_events (#100622).
estimated_bytes INTEGER NOT NULL DEFAULT 0
) STRICT;
CREATE INDEX IF NOT EXISTS idx_acp_replay_sessions_key_updated
ON acp_replay_sessions(session_key, complete, updated_at DESC, session_id);
CREATE INDEX IF NOT EXISTS idx_acp_replay_sessions_updated
ON acp_replay_sessions(updated_at DESC, session_id);
CREATE TABLE IF NOT EXISTS acp_replay_events (
session_id TEXT NOT NULL,
seq INTEGER NOT NULL,
at INTEGER NOT NULL,
session_key TEXT NOT NULL,
run_id TEXT,
update_json TEXT NOT NULL,
estimated_bytes INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY (session_id, seq),
FOREIGN KEY (session_id) REFERENCES acp_replay_sessions(session_id) ON DELETE CASCADE
) STRICT;
CREATE TABLE IF NOT EXISTS agent_databases (
agent_id TEXT NOT NULL,
path TEXT NOT NULL,
schema_version INTEGER NOT NULL,
last_seen_at INTEGER NOT NULL,
size_bytes INTEGER,
PRIMARY KEY (agent_id, path)
) STRICT;
CREATE TABLE IF NOT EXISTS agent_deletion_journal (
agent_id TEXT PRIMARY KEY,
operation_id TEXT NOT NULL DEFAULT '',
phase TEXT,
agent_dir TEXT NOT NULL,
workspace_dir TEXT NOT NULL,
sessions_dir TEXT NOT NULL,
database_paths_json TEXT NOT NULL DEFAULT '[]',
cleanup_paths_json TEXT NOT NULL DEFAULT '[]',
created_at INTEGER NOT NULL,
cleanup_completed INTEGER NOT NULL DEFAULT 0,
delete_files INTEGER NOT NULL DEFAULT 1
) STRICT;
CREATE TABLE IF NOT EXISTS agent_provenance (
agent_id TEXT PRIMARY KEY,
created_via TEXT NOT NULL CHECK (created_via IN ('operator', 'agent', 'template')),
creator_agent_id TEXT,
created_at_ms INTEGER NOT NULL
) STRICT;
CREATE TABLE IF NOT EXISTS agent_database_leases (
lease_id TEXT PRIMARY KEY,
agent_id TEXT NOT NULL,
path TEXT NOT NULL,
owner_pid INTEGER NOT NULL,
owner_start_time INTEGER,
opened_at INTEGER NOT NULL,
provenance TEXT
) STRICT;
CREATE TABLE IF NOT EXISTS plugin_state_entries (
plugin_id TEXT NOT NULL,
namespace TEXT NOT NULL,
entry_key TEXT NOT NULL,
value_json TEXT NOT NULL,
created_at INTEGER NOT NULL,
expires_at INTEGER,
PRIMARY KEY (plugin_id, namespace, entry_key)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_plugin_state_expiry
ON plugin_state_entries(expires_at)
WHERE expires_at IS NOT NULL;
CREATE INDEX IF NOT EXISTS idx_plugin_state_listing
ON plugin_state_entries(plugin_id, namespace, created_at, entry_key, expires_at);
CREATE TABLE IF NOT EXISTS channel_ingress_events (
queue_name TEXT NOT NULL,
event_id TEXT NOT NULL,
channel_id TEXT NOT NULL,
account_id TEXT NOT NULL,
status TEXT NOT NULL,
lane_key TEXT,
payload_json TEXT NOT NULL,
metadata_json TEXT,
received_at INTEGER NOT NULL,
updated_at INTEGER NOT NULL,
claim_token TEXT,
claim_owner TEXT,
claimed_at INTEGER,
attempts INTEGER NOT NULL DEFAULT 0,
last_attempt_at INTEGER,
last_error TEXT,
failed_reason TEXT,
failed_at INTEGER,
completed_at INTEGER,
completed_metadata_json TEXT,
PRIMARY KEY (queue_name, event_id)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_channel_ingress_pending
ON channel_ingress_events(queue_name, status, received_at, event_id);
CREATE INDEX IF NOT EXISTS idx_channel_ingress_claims
ON channel_ingress_events(queue_name, status, claimed_at);
CREATE INDEX IF NOT EXISTS idx_channel_ingress_lane
ON channel_ingress_events(queue_name, status, lane_key);
CREATE TABLE IF NOT EXISTS plugin_blob_entries (
plugin_id TEXT NOT NULL,
namespace TEXT NOT NULL,
entry_key TEXT NOT NULL,
metadata_json TEXT NOT NULL,
blob BLOB NOT NULL,
created_at INTEGER NOT NULL,
expires_at INTEGER,
PRIMARY KEY (plugin_id, namespace, entry_key)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_plugin_blob_expiry
ON plugin_blob_entries(expires_at)
WHERE expires_at IS NOT NULL;
CREATE INDEX IF NOT EXISTS idx_plugin_blob_listing
ON plugin_blob_entries(plugin_id, namespace, created_at, entry_key);
CREATE TABLE IF NOT EXISTS skill_uploads (
upload_id TEXT NOT NULL PRIMARY KEY,
kind TEXT NOT NULL,
slug TEXT NOT NULL,
force INTEGER NOT NULL,
size_bytes INTEGER NOT NULL,
sha256 TEXT,
actual_sha256 TEXT,
received_bytes INTEGER NOT NULL,
archive_blob BLOB NOT NULL,
created_at INTEGER NOT NULL,
expires_at INTEGER NOT NULL,
committed INTEGER NOT NULL,
committed_at INTEGER,
idempotency_key_hash TEXT UNIQUE
) STRICT;
CREATE INDEX IF NOT EXISTS idx_skill_uploads_expiry
ON skill_uploads(expires_at);
CREATE INDEX IF NOT EXISTS idx_skill_uploads_idempotency
ON skill_uploads(idempotency_key_hash)
WHERE idempotency_key_hash IS NOT NULL;
CREATE TABLE IF NOT EXISTS skill_upload_chunks (
upload_id TEXT NOT NULL,
byte_offset INTEGER NOT NULL CHECK (byte_offset >= 0),
size_bytes INTEGER NOT NULL CHECK (size_bytes > 0),
chunk_blob BLOB NOT NULL,
PRIMARY KEY (upload_id, byte_offset),
FOREIGN KEY (upload_id) REFERENCES skill_uploads(upload_id) ON DELETE CASCADE,
CHECK (length(chunk_blob) = size_bytes)
) STRICT;
CREATE TABLE IF NOT EXISTS capture_sessions (
id TEXT NOT NULL PRIMARY KEY,
started_at INTEGER NOT NULL,
ended_at INTEGER,
mode TEXT NOT NULL,
source_scope TEXT NOT NULL,
source_process TEXT NOT NULL,
proxy_url TEXT
) STRICT;
CREATE TABLE IF NOT EXISTS capture_blobs (
blob_id TEXT NOT NULL PRIMARY KEY,
content_type TEXT,
encoding TEXT NOT NULL,
size_bytes INTEGER NOT NULL,
sha256 TEXT NOT NULL,
data BLOB NOT NULL,
created_at INTEGER NOT NULL
) STRICT;
CREATE TABLE IF NOT EXISTS capture_events (
id INTEGER NOT NULL PRIMARY KEY,
session_id TEXT NOT NULL,
ts INTEGER NOT NULL,
source_scope TEXT NOT NULL,
source_process TEXT NOT NULL,
protocol TEXT NOT NULL,
direction TEXT NOT NULL,
kind TEXT NOT NULL,
flow_id TEXT NOT NULL,
method TEXT,
host TEXT,
path TEXT,
status INTEGER,
close_code INTEGER,
content_type TEXT,
headers_json TEXT,
data_text TEXT,
data_blob_id TEXT,
data_sha256 TEXT,
error_text TEXT,
meta_json TEXT,
FOREIGN KEY (session_id) REFERENCES capture_sessions(id) ON DELETE CASCADE,
FOREIGN KEY (data_blob_id) REFERENCES capture_blobs(blob_id) ON DELETE SET NULL
) STRICT;
CREATE INDEX IF NOT EXISTS capture_events_session_ts_idx
ON capture_events(session_id, ts);
CREATE INDEX IF NOT EXISTS capture_events_flow_idx
ON capture_events(flow_id, ts);
CREATE TABLE IF NOT EXISTS sandbox_registry_entries (
registry_kind TEXT NOT NULL,
container_name TEXT NOT NULL,
session_key TEXT,
backend_id TEXT,
runtime_label TEXT,
image TEXT,
created_at_ms INTEGER,
last_used_at_ms INTEGER,
config_label_kind TEXT,
config_hash TEXT,
cdp_port INTEGER,
no_vnc_port INTEGER,
entry_json TEXT NOT NULL,
updated_at INTEGER NOT NULL,
PRIMARY KEY (registry_kind, container_name)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_sandbox_registry_updated
ON sandbox_registry_entries(registry_kind, updated_at DESC, container_name);
CREATE INDEX IF NOT EXISTS idx_sandbox_registry_session
ON sandbox_registry_entries(registry_kind, session_key, last_used_at_ms DESC, container_name)
WHERE session_key IS NOT NULL;
CREATE INDEX IF NOT EXISTS idx_sandbox_registry_last_used
ON sandbox_registry_entries(registry_kind, last_used_at_ms DESC, container_name)
WHERE last_used_at_ms IS NOT NULL;
CREATE TABLE IF NOT EXISTS durable_background_processes (
id TEXT NOT NULL PRIMARY KEY,
record_json TEXT NOT NULL
) STRICT;
CREATE TABLE IF NOT EXISTS sandbox_persistent_execs (
owner_key TEXT NOT NULL PRIMARY KEY,
source_identity TEXT NOT NULL,
attempt_id TEXT NOT NULL UNIQUE,
owner_json TEXT NOT NULL,
backend_id TEXT NOT NULL CHECK (backend_id = 'docker'),
backend_target_json TEXT NOT NULL,
workspace_binding_json TEXT NOT NULL,
container_id TEXT NOT NULL,
container_name TEXT NOT NULL,
container_started_at TEXT NOT NULL,
revision INTEGER NOT NULL CHECK (revision > 0),
phase TEXT NOT NULL CHECK (phase IN ('reserved', 'prepared', 'running', 'stopping', 'uncertain', 'stopped')),
receipt_json TEXT,
error TEXT,
created_at_ms INTEGER NOT NULL,
updated_at_ms INTEGER NOT NULL,
CHECK (phase NOT IN ('prepared', 'running') OR receipt_json IS NOT NULL)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_sandbox_persistent_execs_container
ON sandbox_persistent_execs(container_id, owner_key);
CREATE INDEX IF NOT EXISTS idx_sandbox_persistent_execs_container_name
ON sandbox_persistent_execs(container_name, owner_key);
CREATE INDEX IF NOT EXISTS idx_sandbox_persistent_execs_source
ON sandbox_persistent_execs(source_identity, owner_key);
CREATE TABLE IF NOT EXISTS cron_jobs (
store_key TEXT NOT NULL,
job_id TEXT NOT NULL,
declaration_key TEXT,
owner_agent_id TEXT,
name TEXT NOT NULL,
description TEXT,
enabled INTEGER NOT NULL,
agent_id TEXT,
payload_kind TEXT NOT NULL,
job_json TEXT NOT NULL,
grant_definition_revision TEXT,
grant_definition_generation INTEGER,
grant_definition_updated_at INTEGER,
state_json TEXT NOT NULL DEFAULT '{}',
runtime_updated_at_ms INTEGER,
schedule_identity TEXT,
sort_order INTEGER NOT NULL DEFAULT 0,
updated_at INTEGER NOT NULL,
PRIMARY KEY (store_key, job_id)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_cron_jobs_store_order
ON cron_jobs(store_key, sort_order ASC, updated_at ASC, job_id);
-- One owner-native receipt is also the durable execution fence. Receipts
-- survive job deletion so operators can distinguish a run from log inference.
CREATE TABLE IF NOT EXISTS cron_run_receipts (
cursor_id INTEGER NOT NULL,
receipt_id TEXT PRIMARY KEY,
store_key TEXT NOT NULL,
job_id TEXT NOT NULL,
config_revision TEXT NOT NULL,
agent_id TEXT NOT NULL,
request_run_id TEXT,
delivery_attempt_state TEXT NOT NULL DEFAULT 'unknown' CHECK (delivery_attempt_state IN ('unknown', 'not-started', 'started')),
status TEXT NOT NULL,
owner_pid INTEGER NOT NULL,
owner_start_time INTEGER,
started_at_ms INTEGER NOT NULL,
finished_at_ms INTEGER,
error_text TEXT,
CHECK (status IN ('running', 'ok', 'error', 'skipped', 'interrupted', 'superseded')),
CHECK (
(status = 'running' AND finished_at_ms IS NULL)
OR
(status != 'running' AND finished_at_ms IS NOT NULL)
)
) STRICT;
CREATE UNIQUE INDEX IF NOT EXISTS cron_run_receipts_cursor_id_idx
ON cron_run_receipts(cursor_id);
CREATE UNIQUE INDEX IF NOT EXISTS idx_cron_run_receipts_active_job
ON cron_run_receipts(store_key, job_id)
WHERE status = 'running';
CREATE INDEX IF NOT EXISTS idx_cron_run_receipts_job_history
ON cron_run_receipts(store_key, job_id, started_at_ms DESC, receipt_id DESC);
-- Retirement follows the receipt's retention without changing its released shape.
CREATE TABLE IF NOT EXISTS cron_run_trigger_state_retirements (
receipt_id TEXT PRIMARY KEY
REFERENCES cron_run_receipts(receipt_id) ON DELETE CASCADE
) STRICT;
-- Runtime-private authority is independent of job_json so downgraded writers
-- can rewrite recognized job config without erasing or silently widening it.
CREATE TABLE IF NOT EXISTS cron_job_runtime_authorities (
store_key TEXT NOT NULL,
job_id TEXT NOT NULL,
authority_json TEXT,
authority_input_fingerprint TEXT,
recovery_required INTEGER NOT NULL,
PRIMARY KEY (store_key, job_id),
FOREIGN KEY (store_key, job_id)
REFERENCES cron_jobs(store_key, job_id) ON DELETE CASCADE,
CHECK (recovery_required IN (0, 1)),
CHECK (
(recovery_required = 0 AND authority_json IS NOT NULL AND authority_input_fingerprint IS NOT NULL)
OR
(recovery_required = 1 AND authority_json IS NULL AND authority_input_fingerprint IS NULL)
)
) STRICT;
-- Scratch is separate from cron_jobs so scheduler state writes and downgraded
-- full-row replacement preserve it. New builds prune rows explicitly on job removal.
-- content NULL is a tombstone: it keeps the revision lineage monotonic across
-- unset/recreate so stale compare-and-swap writes cannot resurrect old content.
CREATE TABLE IF NOT EXISTS cron_job_scratch (
store_key TEXT NOT NULL,
job_id TEXT NOT NULL,
content TEXT,
revision INTEGER NOT NULL,
source_sha256 TEXT,
updated_at_ms INTEGER NOT NULL,
PRIMARY KEY (store_key, job_id),
CHECK (revision >= 1),
CHECK (content IS NULL OR length(CAST(content AS BLOB)) <= 262144)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_cron_job_scratch_store_updated
ON cron_job_scratch(store_key, updated_at_ms DESC, job_id);
CREATE TABLE IF NOT EXISTS delivery_queue_entries (
queue_name TEXT NOT NULL,
id TEXT NOT NULL,
status TEXT NOT NULL,
entry_kind TEXT,
session_key TEXT,
channel TEXT,
target TEXT,
account_id TEXT,
retry_count INTEGER NOT NULL DEFAULT 0,
last_attempt_at INTEGER,
last_error TEXT,
recovery_state TEXT,
platform_send_started_at INTEGER,
entry_json TEXT NOT NULL,
retention_id_prefix TEXT,
retention_max_age_ms INTEGER,
retention_max_entries INTEGER,
enqueued_at INTEGER NOT NULL,
updated_at INTEGER NOT NULL,
failed_at INTEGER,
PRIMARY KEY (queue_name, id)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_delivery_queue_pending
ON delivery_queue_entries(queue_name, status, enqueued_at, id);
CREATE INDEX IF NOT EXISTS idx_delivery_queue_failed
ON delivery_queue_entries(status, queue_name, failed_at, id);
CREATE INDEX IF NOT EXISTS idx_delivery_queue_session
ON delivery_queue_entries(queue_name, status, session_key, enqueued_at, id)
WHERE session_key IS NOT NULL;
CREATE INDEX IF NOT EXISTS idx_delivery_queue_target
ON delivery_queue_entries(queue_name, status, channel, target, enqueued_at, id)
WHERE channel IS NOT NULL AND target IS NOT NULL;
CREATE INDEX IF NOT EXISTS idx_delivery_queue_bounded_retention
ON delivery_queue_entries(queue_name, retention_id_prefix, enqueued_at DESC, id DESC)
WHERE status IN ('completed', 'failed') AND recovery_state = 'completed_bounded'
AND retention_id_prefix IS NOT NULL;
CREATE TABLE IF NOT EXISTS task_runs (
task_id TEXT NOT NULL PRIMARY KEY,
runtime TEXT NOT NULL,
task_kind TEXT,
source_id TEXT,
requester_session_key TEXT,
owner_key TEXT NOT NULL,
scope_kind TEXT NOT NULL,
child_session_key TEXT,
parent_flow_id TEXT,
parent_task_id TEXT,
agent_id TEXT,
requester_agent_id TEXT,
run_id TEXT,
execution_owner_host TEXT,
execution_owner_pid INTEGER,
execution_owner_start_identity INTEGER,
label TEXT,
task TEXT NOT NULL,
status TEXT NOT NULL,
delivery_status TEXT NOT NULL,
notify_policy TEXT NOT NULL,
created_at INTEGER NOT NULL,
started_at INTEGER,
ended_at INTEGER,
last_event_at INTEGER,
cleanup_after INTEGER,
tool_use_count INTEGER,
last_tool_name TEXT,
error TEXT,
progress_summary TEXT,
terminal_summary TEXT,
terminal_outcome TEXT,
detail_json TEXT
) STRICT;
CREATE INDEX IF NOT EXISTS idx_task_runs_runtime_run
ON task_runs(runtime, run_id, source_id, created_at, task_id);
CREATE INDEX IF NOT EXISTS idx_task_runs_cron_runtime_order
ON task_runs(runtime, created_at, task_id) WHERE runtime = 'cron';
CREATE INDEX IF NOT EXISTS idx_task_runs_cron_source_order
ON task_runs(source_id, created_at, task_id) WHERE runtime = 'cron';
CREATE TABLE IF NOT EXISTS subagent_runs (
run_id TEXT NOT NULL PRIMARY KEY,
child_session_key TEXT NOT NULL,
controller_session_key TEXT,
controller_store_path TEXT,
requester_session_key TEXT NOT NULL,
requester_store_path TEXT,
created_at INTEGER NOT NULL,
payload_json TEXT NOT NULL DEFAULT '{}'
) STRICT;
CREATE INDEX IF NOT EXISTS idx_subagent_runs_child_session_key
ON subagent_runs(child_session_key, created_at DESC, run_id);
CREATE INDEX IF NOT EXISTS idx_subagent_runs_requester_session_key
ON subagent_runs(requester_session_key, created_at DESC, run_id);
CREATE INDEX IF NOT EXISTS idx_subagent_runs_controller_session_key
ON subagent_runs(controller_session_key, created_at DESC, run_id);
CREATE TABLE IF NOT EXISTS current_conversation_bindings (
binding_key TEXT NOT NULL PRIMARY KEY,
binding_id TEXT NOT NULL,
target_session_key TEXT NOT NULL,
channel TEXT NOT NULL,
account_id TEXT NOT NULL,
conversation_kind TEXT NOT NULL,
parent_conversation_id TEXT,
conversation_id TEXT NOT NULL,
target_kind TEXT NOT NULL,
status TEXT NOT NULL,
bound_at INTEGER NOT NULL,
expires_at INTEGER,
metadata_json TEXT,
record_json TEXT NOT NULL,
updated_at INTEGER NOT NULL
) STRICT;
CREATE INDEX IF NOT EXISTS idx_current_conversation_bindings_target
ON current_conversation_bindings(target_session_key, updated_at DESC, binding_key);
CREATE INDEX IF NOT EXISTS idx_current_conversation_bindings_conversation
ON current_conversation_bindings(channel, account_id, conversation_kind, conversation_id);
CREATE INDEX IF NOT EXISTS idx_current_conversation_bindings_expires
ON current_conversation_bindings(expires_at, binding_key);
CREATE TABLE IF NOT EXISTS plugin_binding_approvals (
plugin_root TEXT NOT NULL,
channel TEXT NOT NULL,
account_id TEXT NOT NULL,
plugin_id TEXT NOT NULL,
plugin_name TEXT,
approved_at INTEGER NOT NULL,
PRIMARY KEY (plugin_root, channel, account_id)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_plugin_binding_approvals_plugin
ON plugin_binding_approvals(plugin_id, approved_at DESC);
CREATE TABLE IF NOT EXISTS task_delivery_state (
task_id TEXT NOT NULL PRIMARY KEY,
requester_origin_json TEXT,
last_notified_event_at INTEGER,
FOREIGN KEY (task_id) REFERENCES task_runs(task_id) ON DELETE CASCADE
) STRICT;
CREATE TABLE IF NOT EXISTS flow_runs (
flow_id TEXT NOT NULL PRIMARY KEY,
shape TEXT,
sync_mode TEXT NOT NULL DEFAULT 'managed',
owner_key TEXT NOT NULL,
requester_origin_json TEXT,
controller_id TEXT,
revision INTEGER NOT NULL DEFAULT 0,
status TEXT NOT NULL,
notify_policy TEXT NOT NULL,
goal TEXT NOT NULL,
current_step TEXT,
blocked_task_id TEXT,
blocked_summary TEXT,
state_json TEXT,
wait_json TEXT,
cancel_requested_at INTEGER,
created_at INTEGER NOT NULL,
updated_at INTEGER NOT NULL,
ended_at INTEGER
) STRICT;
CREATE INDEX IF NOT EXISTS idx_flow_runs_status ON flow_runs(status);
CREATE INDEX IF NOT EXISTS idx_flow_runs_owner_key ON flow_runs(owner_key);
CREATE INDEX IF NOT EXISTS idx_flow_runs_updated_at ON flow_runs(updated_at);
-- Durable meeting-capture sessions are gateway-global rather than agent-session
-- transcripts. JSON/JSONL files are doctor import inputs or explicit CLI exports.
CREATE TABLE IF NOT EXISTS meeting_transcript_sessions (
started_at_ms INTEGER,
session_id TEXT NOT NULL,
started_at TEXT NOT NULL,
selector TEXT NOT NULL UNIQUE,
export_key TEXT NOT NULL,
session_slug TEXT NOT NULL,
provider_id TEXT NOT NULL,
title TEXT,
source_json TEXT NOT NULL,
source_account_id TEXT,
source_guild_id TEXT,
source_channel_id TEXT,
source_meeting_url TEXT,
source_thread_ts TEXT,
source_file_id TEXT,
stopped_at TEXT,
metadata_json TEXT,
metadata_agent_id TEXT,
export_manifest_json TEXT NOT NULL DEFAULT '{}',
export_pending_json TEXT NOT NULL DEFAULT '[]',
next_utterance_seq INTEGER NOT NULL DEFAULT 0 CHECK (next_utterance_seq >= 0),
created_at_ms INTEGER NOT NULL CHECK (created_at_ms >= 0),
updated_at_ms INTEGER NOT NULL CHECK (updated_at_ms >= 0),
PRIMARY KEY (session_id, started_at)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_meeting_transcript_sessions_started
ON meeting_transcript_sessions(started_at DESC, session_id);
CREATE INDEX IF NOT EXISTS idx_meeting_transcript_sessions_chronology
ON meeting_transcript_sessions(started_at_ms DESC, session_id ASC, started_at ASC);
CREATE INDEX IF NOT EXISTS idx_meeting_transcript_sessions_id
ON meeting_transcript_sessions(session_id, started_at DESC);
CREATE INDEX IF NOT EXISTS idx_meeting_transcript_sessions_slug
ON meeting_transcript_sessions(session_slug, started_at DESC);
CREATE INDEX IF NOT EXISTS idx_meeting_transcript_sessions_export_key
ON meeting_transcript_sessions(export_key);
CREATE INDEX IF NOT EXISTS idx_meeting_transcript_sessions_source
ON meeting_transcript_sessions(provider_id, source_account_id, source_guild_id,
source_channel_id, source_meeting_url, source_thread_ts, source_file_id,
stopped_at DESC, started_at DESC, session_id);
CREATE INDEX IF NOT EXISTS idx_meeting_transcript_sessions_account
ON meeting_transcript_sessions(source_account_id);
CREATE INDEX IF NOT EXISTS idx_meeting_transcript_sessions_agent
ON meeting_transcript_sessions(metadata_agent_id);
CREATE TABLE IF NOT EXISTS meeting_transcript_utterances (
session_id TEXT NOT NULL,
session_started_at TEXT NOT NULL,
sequence INTEGER NOT NULL CHECK (sequence >= 0),
utterance_id TEXT,
started_at TEXT,
ended_at TEXT,
speaker_id TEXT,
speaker_label TEXT,
text TEXT NOT NULL,
final INTEGER CHECK (final IN (0, 1)),
metadata_json TEXT,
PRIMARY KEY (session_id, session_started_at, sequence),
FOREIGN KEY (session_id, session_started_at)
REFERENCES meeting_transcript_sessions(session_id, started_at)
ON DELETE CASCADE
) STRICT;
CREATE INDEX IF NOT EXISTS idx_meeting_transcript_utterances_id
ON meeting_transcript_utterances(session_id, session_started_at, utterance_id)
WHERE utterance_id IS NOT NULL;
CREATE TABLE IF NOT EXISTS meeting_transcript_summaries (
session_id TEXT NOT NULL,
session_started_at TEXT NOT NULL,
generated_at TEXT,
summary_json TEXT,
overview TEXT,
markdown TEXT,
utterance_count INTEGER NOT NULL CHECK (utterance_count >= 0),
PRIMARY KEY (session_id, session_started_at),
FOREIGN KEY (session_id, session_started_at)
REFERENCES meeting_transcript_sessions(session_id, started_at)
ON DELETE CASCADE,
CHECK (summary_json IS NOT NULL OR markdown IS NOT NULL)
) STRICT;
CREATE TABLE IF NOT EXISTS migration_runs (
id TEXT NOT NULL PRIMARY KEY,
started_at INTEGER NOT NULL,
finished_at INTEGER,
status TEXT NOT NULL,
report_json TEXT NOT NULL
) STRICT;
CREATE INDEX IF NOT EXISTS idx_migration_runs_started
ON migration_runs(started_at DESC, id);
CREATE TABLE IF NOT EXISTS migration_sources (
source_key TEXT NOT NULL PRIMARY KEY,
migration_kind TEXT NOT NULL,
source_path TEXT NOT NULL,
target_table TEXT NOT NULL,
source_sha256 TEXT,
source_size_bytes INTEGER,
source_record_count INTEGER,
last_run_id TEXT NOT NULL,
status TEXT NOT NULL,
imported_at INTEGER NOT NULL,
removed_source INTEGER NOT NULL DEFAULT 0,
report_json TEXT NOT NULL,
FOREIGN KEY (last_run_id) REFERENCES migration_runs(id) ON DELETE CASCADE
) STRICT;
CREATE INDEX IF NOT EXISTS idx_migration_sources_path
ON migration_sources(source_path, migration_kind, target_table);
CREATE INDEX IF NOT EXISTS idx_migration_sources_run
ON migration_sources(last_run_id, source_path);
CREATE TABLE IF NOT EXISTS backup_runs (
id TEXT NOT NULL PRIMARY KEY,
created_at INTEGER NOT NULL,
archive_path TEXT NOT NULL,
status TEXT NOT NULL,
manifest_json TEXT NOT NULL
) STRICT;
CREATE INDEX IF NOT EXISTS idx_backup_runs_created
ON backup_runs(created_at DESC, id);
CREATE TABLE IF NOT EXISTS worktrees (
id TEXT NOT NULL PRIMARY KEY,
repo_fingerprint TEXT NOT NULL,
repo_root TEXT NOT NULL,
path TEXT NOT NULL,
branch TEXT NOT NULL,
base_ref TEXT NOT NULL,
owner_kind TEXT NOT NULL CHECK (owner_kind IN ('manual', 'workboard', 'session')),
owner_id TEXT,
snapshot_ref TEXT,
provisioned_paths_json TEXT,
created_at INTEGER NOT NULL,
last_active_at INTEGER NOT NULL,
removed_at INTEGER,
run_end_cleanup_json TEXT,
gc_protection_json TEXT
) STRICT;
CREATE INDEX IF NOT EXISTS idx_worktrees_repo_fingerprint
ON worktrees(repo_fingerprint);
CREATE INDEX IF NOT EXISTS idx_worktrees_removed_at
ON worktrees(removed_at);
CREATE TABLE IF NOT EXISTS worktree_provisioned_file_chunks (
worktree_id TEXT NOT NULL,
path TEXT NOT NULL,
chunk_index INTEGER NOT NULL CHECK (chunk_index >= 0),
data BLOB NOT NULL,
PRIMARY KEY (worktree_id, path, chunk_index)
) STRICT;
CREATE TABLE IF NOT EXISTS worktree_templates (
cache_key TEXT NOT NULL PRIMARY KEY,
id TEXT NOT NULL UNIQUE,
repo_root TEXT NOT NULL,
common_dir TEXT NOT NULL,
worktree_root TEXT NOT NULL,
path TEXT NOT NULL,
backend TEXT NOT NULL,
source_commit TEXT NOT NULL,
content_key TEXT NOT NULL,
status TEXT NOT NULL CHECK (status IN ('preparing', 'ready')),
created_at INTEGER NOT NULL,
last_used_at INTEGER NOT NULL
) STRICT;
CREATE TABLE IF NOT EXISTS projects (
id TEXT NOT NULL PRIMARY KEY,
display_name TEXT NOT NULL,
repo_root TEXT NOT NULL,
origin_url TEXT,
source TEXT NOT NULL CHECK (source IN ('registered', 'cloned')),
created_at_ms INT NOT NULL,
updated_at_ms INT NOT NULL
) STRICT;
-- One explicitly retained, normalized private background per durable profile.
CREATE TABLE IF NOT EXISTS user_background_images (
profile_id TEXT NOT NULL PRIMARY KEY REFERENCES user_profiles(id) ON DELETE CASCADE,
asset_id TEXT NOT NULL UNIQUE,
image BLOB NOT NULL CHECK (length(image) BETWEEN 1 AND 2097152),
width INTEGER NOT NULL CHECK (width BETWEEN 1 AND 2560),
height INTEGER NOT NULL CHECK (height BETWEEN 1 AND 2560)
) STRICT;
CREATE TABLE IF NOT EXISTS user_preferences (
profile_id TEXT NOT NULL,
pref_key TEXT NOT NULL,
value_json TEXT NOT NULL,
updated_at_ms INT NOT NULL,
PRIMARY KEY (profile_id, pref_key)
) STRICT;
-- Gateway-owned custom session group catalog (names + display order).
-- Membership stays on each session entry's category field; this table only
-- owns which groups exist and how operator UIs order them.
CREATE TABLE IF NOT EXISTS session_groups (
name TEXT NOT NULL PRIMARY KEY,
position INTEGER NOT NULL,
created_at INTEGER NOT NULL,
cwd TEXT,
worktree INTEGER
) STRICT;
-- Gateway-owned durable cloud worker lifecycle. Provider-specific execution
-- stays in plugins; this table records only core reconciliation facts.
CREATE TABLE IF NOT EXISTS worker_environments (
environment_id TEXT NOT NULL PRIMARY KEY,
provider_id TEXT NOT NULL,
profile_id TEXT NOT NULL,
profile_snapshot_json TEXT NOT NULL,
last_activated_at_ms INTEGER,
preparation_key TEXT,
preparation_purpose TEXT,
preparation_demand_at_ms INTEGER,
preparation_expires_at_ms INTEGER,
preparation_consumed_at_ms INTEGER CHECK (
(preparation_key IS NULL AND preparation_demand_at_ms IS NULL
AND preparation_expires_at_ms IS NULL AND preparation_consumed_at_ms IS NULL)
OR
(preparation_key IS NOT NULL AND length(preparation_key) = 64
AND preparation_key NOT GLOB '*[^0-9a-f]*'
AND preparation_demand_at_ms IS NOT NULL
AND preparation_demand_at_ms BETWEEN 0 AND 9007199254740991
AND preparation_expires_at_ms IS NOT NULL
AND preparation_expires_at_ms > preparation_demand_at_ms
AND preparation_expires_at_ms <= 9007199254740991
AND (preparation_consumed_at_ms IS NULL
OR (preparation_consumed_at_ms >= preparation_demand_at_ms
AND preparation_consumed_at_ms < preparation_expires_at_ms)))
),
provision_operation_id TEXT NOT NULL UNIQUE,
lease_id TEXT,
node_setup_id TEXT,
node_device_id TEXT,
ssh_host TEXT,
ssh_port INTEGER CHECK (ssh_port IS NULL OR (ssh_port >= 1 AND ssh_port <= 65535)),
ssh_user TEXT,
ssh_host_key TEXT,
ssh_key_ref_json TEXT,
desktop_json TEXT,
state TEXT NOT NULL CHECK (
state IN (
'requested',
'provisioning',
'bootstrapping',
'ready',
'attached',
'idle',
'draining',
'destroying',
'destroyed',
'failed',
'orphaned'
)
),
bootstrap_bundle_hash TEXT,
bootstrap_openclaw_version TEXT,
bootstrap_protocol_features_json TEXT,
bootstrap_install_kind TEXT,
owner_epoch INTEGER NOT NULL DEFAULT 0 CHECK (owner_epoch >= 0),
teardown_terminal_state TEXT CHECK (teardown_terminal_state IN ('destroyed', 'failed')),
attached_session_ids_json TEXT NOT NULL DEFAULT '[]',
created_at_ms INTEGER NOT NULL,
updated_at_ms INTEGER NOT NULL,
state_changed_at_ms INTEGER NOT NULL,
idle_since_at_ms INTEGER,
destroy_requested_at_ms INTEGER,
last_error TEXT,
shared_host INTEGER,
resource_receipt_json TEXT,
retention_json TEXT,
provision_source_json TEXT
) STRICT;
CREATE UNIQUE INDEX IF NOT EXISTS idx_worker_environments_provider_lease
ON worker_environments(provider_id, lease_id)
WHERE lease_id IS NOT NULL;
CREATE INDEX IF NOT EXISTS idx_worker_environments_terminal_changed
ON worker_environments(state_changed_at_ms, environment_id);
-- A dedicated node registers its fixed build paths before ready, then binds
-- them once. The environment belongs to the Gateway's separate database.
CREATE TABLE IF NOT EXISTS node_worker_prepared_workspaces (
preparation_key TEXT NOT NULL PRIMARY KEY CHECK (
length(preparation_key) = 64 AND preparation_key NOT GLOB '*[^0-9a-f]*'
),
cache_key TEXT NOT NULL CHECK (
length(cache_key) = 64 AND cache_key NOT GLOB '*[^0-9a-f]*'
),
gateway_namespace TEXT NOT NULL CHECK (length(gateway_namespace) > 0),
workspace_dir TEXT NOT NULL UNIQUE CHECK (length(workspace_dir) > 0),
home_dir TEXT NOT NULL CHECK (length(home_dir) > 0),
source_manifest_ref TEXT NOT NULL CHECK (
length(source_manifest_ref) = 71 AND substr(source_manifest_ref, 1, 7) = 'sha256:'
AND substr(source_manifest_ref, 8) NOT GLOB '*[^0-9a-f]*'
),
prepared_manifest_ref TEXT NOT NULL CHECK (
length(prepared_manifest_ref) = 71 AND substr(prepared_manifest_ref, 1, 7) = 'sha256:'
AND substr(prepared_manifest_ref, 8) NOT GLOB '*[^0-9a-f]*'
),
state TEXT NOT NULL CHECK (state IN ('available', 'bound', 'retiring', 'retired')),
environment_id TEXT NOT NULL CHECK (length(environment_id) > 0),
session_id TEXT,
session_key TEXT,
owner_epoch INTEGER CHECK (owner_epoch BETWEEN 1 AND 9007199254740991),
created_at_ms INTEGER NOT NULL CHECK (created_at_ms BETWEEN 0 AND 9007199254740991),
bound_at_ms INTEGER CHECK (bound_at_ms BETWEEN created_at_ms AND 9007199254740991),
retired_at_ms INTEGER CHECK (
retired_at_ms BETWEEN coalesce(bound_at_ms, created_at_ms) AND 9007199254740991
),
CHECK (
(session_id IS NULL AND session_key IS NULL AND owner_epoch IS NULL AND bound_at_ms IS NULL)
OR
(session_id IS NOT NULL AND length(session_id) > 0
AND session_key IS NOT NULL AND length(session_key) > 0
AND owner_epoch IS NOT NULL AND bound_at_ms IS NOT NULL)
),
CHECK (
(state = 'available' AND bound_at_ms IS NULL AND retired_at_ms IS NULL)
OR (state = 'bound' AND bound_at_ms IS NOT NULL AND retired_at_ms IS NULL)
OR (state = 'retiring' AND retired_at_ms IS NULL)
OR (state = 'retired' AND retired_at_ms IS NOT NULL)
)
) STRICT;
-- Provider-advertised fallback ports preserve stable retry order separately
-- from the downgrade-sensitive canonical worker environment row.
CREATE TABLE IF NOT EXISTS worker_environment_ssh_fallback_ports (
environment_id TEXT NOT NULL,
position INTEGER NOT NULL CHECK (position >= 0 AND position <= 9),
port INTEGER NOT NULL CHECK (port >= 1 AND port <= 65535),
PRIMARY KEY (environment_id, position),
UNIQUE (environment_id, port),
FOREIGN KEY (environment_id) REFERENCES worker_environments(environment_id) ON DELETE CASCADE
) STRICT;
-- Logical sessions own repository intent and accepted artifact references,
-- independently of the worker or rotating transcript session id.
CREATE TABLE IF NOT EXISTS session_repository_workspaces (
workspace_id TEXT NOT NULL PRIMARY KEY CHECK (length(workspace_id) = 36),
agent_id TEXT NOT NULL CHECK (length(agent_id) BETWEEN 1 AND 128),
session_key TEXT NOT NULL CHECK (length(session_key) BETWEEN 1 AND 1024),
url TEXT NOT NULL CHECK (length(url) BETWEEN 1 AND 4096),
requested_ref TEXT CHECK (requested_ref IS NULL OR length(requested_ref) BETWEEN 1 AND 1024),
run_setup_script INTEGER NOT NULL DEFAULT 0 CHECK (run_setup_script IN (0, 1)),
base_commit TEXT CHECK (base_commit IS NULL OR length(base_commit) IN (40, 64)),
base_manifest_hash TEXT,
branch TEXT NOT NULL CHECK (length(branch) BETWEEN 1 AND 256),
checkpoint_ref TEXT,
manifest_hash TEXT,
revision INTEGER NOT NULL CHECK (revision >= 0),
created_at_ms INTEGER NOT NULL,
updated_at_ms INTEGER NOT NULL,
disk_authority_json TEXT,
UNIQUE (agent_id, session_key),
CHECK (base_manifest_hash IS NULL OR base_commit IS NOT NULL),
CHECK ((checkpoint_ref IS NULL AND manifest_hash IS NULL)
OR (checkpoint_ref IS NOT NULL AND manifest_hash IS NOT NULL AND base_manifest_hash IS NOT NULL))
) STRICT;
CREATE TABLE IF NOT EXISTS github_repository_publication_requests (
request_id TEXT NOT NULL PRIMARY KEY,
owner_profile_id TEXT,
connection_generation TEXT,
idempotency_key TEXT NOT NULL,
request_digest TEXT NOT NULL,
session_id TEXT NOT NULL,
session_lifecycle_revision TEXT,
requester_authority_json TEXT,
session_key TEXT NOT NULL,
agent_id TEXT NOT NULL,
workspace_id TEXT NOT NULL,
checkpoint_ref TEXT,
checkpoint_digest TEXT,
claim_id TEXT,
run_id TEXT,
environment_id TEXT,
owner_epoch INTEGER,
placement_generation INTEGER,
identity_source TEXT NOT NULL CHECK (identity_source IN ('system-detected', 'system-configured', 'agent-override', 'personal')),
identity_profile_id TEXT,
identity_account_id INTEGER NOT NULL,
identity_login TEXT NOT NULL,
title TEXT,
body TEXT,
status TEXT NOT NULL CHECK (status IN ('requested', 'publishing', 'needs_confirmation', 'published', 'failed')),
gateway_instance_id TEXT,
execution_id TEXT,
last_effect TEXT CHECK (last_effect IN ('push', 'pull_request')),
effect_state TEXT CHECK (effect_state IN ('dispatched', 'observed')),
push_repository TEXT,
repository TEXT,
branch TEXT NOT NULL,
base_branch TEXT,
source_head_commit TEXT,
source_index_tree TEXT,
workspace_tree TEXT,
previous_head_commit TEXT,
pushed_head_commit TEXT,
head_commit TEXT,
pull_request_url TEXT,
error_code TEXT,
next_action TEXT,
created_at_ms INTEGER NOT NULL,
updated_at_ms INTEGER NOT NULL,
reported_at_ms INTEGER,
draft INTEGER,
CHECK ((identity_source = 'personal' AND owner_profile_id IS NOT NULL AND connection_generation IS NOT NULL)
OR (identity_source <> 'personal' AND owner_profile_id IS NULL AND connection_generation IS NULL)),
CHECK ((checkpoint_ref IS NULL AND checkpoint_digest IS NULL) OR (checkpoint_ref IS NOT NULL AND checkpoint_digest IS NOT NULL)),
CHECK ((last_effect IS NULL AND effect_state IS NULL) OR (last_effect IS NOT NULL AND effect_state IS NOT NULL))
) STRICT;
CREATE UNIQUE INDEX IF NOT EXISTS idx_github_repository_publication_shared_request
ON github_repository_publication_requests(session_id, idempotency_key) WHERE owner_profile_id IS NULL;
CREATE UNIQUE INDEX IF NOT EXISTS idx_github_repository_publication_personal_request
ON github_repository_publication_requests(owner_profile_id, session_id, idempotency_key) WHERE owner_profile_id IS NOT NULL;
-- Session placement lives in the shared state database so local admission,
-- worker admission, and environment attachment use one durable authority.
CREATE TABLE IF NOT EXISTS worker_session_placements (
session_id TEXT NOT NULL PRIMARY KEY,
agent_id TEXT NOT NULL,
session_key TEXT NOT NULL,
execution_mode TEXT CHECK (execution_mode IN ('worker-turn', 'remote-exec')),
state TEXT NOT NULL CHECK (
state IN (
'local',
'requested',
'provisioning',
'syncing',
'starting',
'active',
'draining',
'reconciling',
'reclaimed',
'failed'
)
),
environment_id TEXT,
transition_generation INTEGER NOT NULL DEFAULT 0 CHECK (transition_generation >= 0),
active_owner_epoch INTEGER CHECK (active_owner_epoch IS NULL OR active_owner_epoch >= 1),
workspace_base_manifest_ref TEXT,
remote_workspace_dir TEXT,
worker_bundle_hash TEXT,
last_transcript_ack_cursor INTEGER CHECK (
last_transcript_ack_cursor IS NULL OR last_transcript_ack_cursor >= 0
),
last_live_event_ack_cursor INTEGER CHECK (
last_live_event_ack_cursor IS NULL OR last_live_event_ack_cursor >= 0
),
recovery_error TEXT,
turn_claim_owner TEXT CHECK (turn_claim_owner IN ('local', 'worker')),
turn_claim_id TEXT,
turn_claim_run_id TEXT,
turn_claim_generation INTEGER CHECK (
turn_claim_generation IS NULL OR turn_claim_generation >= 0
),
turn_claim_owner_epoch INTEGER CHECK (
turn_claim_owner_epoch IS NULL OR turn_claim_owner_epoch >= 1
),
created_at_ms INTEGER NOT NULL,
updated_at_ms INTEGER NOT NULL,
state_changed_at_ms INTEGER NOT NULL,
terminal_reason TEXT,
terminal_at_ms INTEGER,
CHECK (
(state IN ('local', 'requested')
AND environment_id IS NULL AND active_owner_epoch IS NULL
AND workspace_base_manifest_ref IS NULL AND remote_workspace_dir IS NULL
AND worker_bundle_hash IS NULL
AND last_transcript_ack_cursor IS NULL AND last_live_event_ack_cursor IS NULL
AND recovery_error IS NULL)
OR
(state IS 'provisioning'
AND active_owner_epoch IS NULL
AND workspace_base_manifest_ref IS NULL AND remote_workspace_dir IS NULL
AND worker_bundle_hash IS NULL
AND last_transcript_ack_cursor IS NULL AND last_live_event_ack_cursor IS NULL
AND recovery_error IS NULL)
OR
(state IS 'syncing'
AND environment_id IS NOT NULL AND active_owner_epoch IS NULL
AND workspace_base_manifest_ref IS NULL AND remote_workspace_dir IS NULL
AND worker_bundle_hash IS NOT NULL
AND last_transcript_ack_cursor IS NULL AND last_live_event_ack_cursor IS NULL
AND recovery_error IS NULL)
OR
(state IS 'starting'
AND environment_id IS NOT NULL AND active_owner_epoch IS NULL
AND workspace_base_manifest_ref IS NOT NULL AND remote_workspace_dir IS NOT NULL
AND worker_bundle_hash IS NOT NULL
AND last_transcript_ack_cursor IS NULL AND last_live_event_ack_cursor IS NULL
AND recovery_error IS NULL)
OR
(state IN ('active', 'draining', 'reconciling')
AND environment_id IS NOT NULL AND active_owner_epoch IS NOT NULL
AND workspace_base_manifest_ref IS NOT NULL AND remote_workspace_dir IS NOT NULL
AND worker_bundle_hash IS NOT NULL AND recovery_error IS NULL)
OR
(state IS 'reclaimed'
AND environment_id IS NOT NULL AND active_owner_epoch IS NOT NULL
AND workspace_base_manifest_ref IS NOT NULL AND remote_workspace_dir IS NOT NULL
AND worker_bundle_hash IS NOT NULL AND recovery_error IS NULL
AND turn_claim_owner IS NULL AND turn_claim_id IS NULL AND turn_claim_run_id IS NULL
AND turn_claim_generation IS NULL AND turn_claim_owner_epoch IS NULL)
OR
(state IS 'failed' AND recovery_error IS NOT NULL)
),
CHECK (
(turn_claim_owner IS NULL AND turn_claim_id IS NULL AND turn_claim_run_id IS NULL
AND turn_claim_generation IS NULL AND turn_claim_owner_epoch IS NULL)
OR
(turn_claim_owner IS 'local' AND turn_claim_id IS NOT NULL
AND turn_claim_run_id IS NOT NULL AND turn_claim_generation IS NOT NULL
AND turn_claim_owner_epoch IS NULL)
OR
(turn_claim_owner IS 'worker' AND turn_claim_id IS NOT NULL
AND turn_claim_run_id IS NOT NULL AND turn_claim_generation IS NOT NULL
AND turn_claim_owner_epoch IS NOT NULL)
),
CHECK (
turn_claim_owner IS NULL
OR
(turn_claim_owner IS 'local' AND (
state IN ('local', 'requested', 'failed')
OR (state IN ('active', 'draining') AND execution_mode IS 'remote-exec')
))
OR
(turn_claim_owner IS 'worker' AND state IN ('active', 'draining')
AND (execution_mode IS NULL OR execution_mode IS 'worker-turn')
AND turn_claim_owner_epoch IS active_owner_epoch)
)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_worker_session_placements_session_key
ON worker_session_placements(agent_id, session_key);
CREATE INDEX IF NOT EXISTS idx_worker_session_placements_reconcile
ON worker_session_placements(updated_at_ms, session_id);
CREATE INDEX IF NOT EXISTS idx_worker_session_placements_environment
ON worker_session_placements(environment_id)
WHERE environment_id IS NOT NULL;
-- Planned placement moves retain their exact source CAS and bounded target
-- without widening the stable placement-state vocabulary. The opaque operation
-- id fences stale asynchronous completion; it is correlation, never authority.
CREATE TABLE IF NOT EXISTS worker_session_placement_moves (
operation_id TEXT NOT NULL PRIMARY KEY,
session_id TEXT NOT NULL UNIQUE
REFERENCES worker_session_placements(session_id) ON DELETE CASCADE,
source_generation INTEGER NOT NULL CHECK (source_generation >= 0),
source_environment_id TEXT NOT NULL CHECK (
length(source_environment_id) BETWEEN 1 AND 256
AND source_environment_id = trim(source_environment_id)
),
source_owner_epoch INTEGER NOT NULL CHECK (source_owner_epoch >= 1),
target_kind TEXT NOT NULL CHECK (target_kind IN ('gateway', 'profile', 'device')),
target_id TEXT,
-- Keep these nullable columns constraint-free so lazy ALTER TABLE produces the
-- same shape as fresh databases; placement-move code validates their values.
target_machine_class TEXT,
target_os TEXT,
-- Explicit source abandonment is a durable operator decision. Keep the bit
-- bare and nullable so same-version older readers can safely omit it.
abandon_source INTEGER,
last_error TEXT,
created_at_ms INTEGER NOT NULL,
updated_at_ms INTEGER NOT NULL,
CHECK (
(target_kind IS 'gateway' AND target_id IS NULL)
OR
(target_kind IN ('profile', 'device')
AND target_id IS NOT NULL
AND length(target_id) BETWEEN 1 AND 256
AND target_id = trim(target_id))
)
) STRICT;
-- Worker-visible session RPC authority is persisted against the exact turn
-- claim. The launch descriptor is informative only; Gateway dispatch always
-- revalidates this record and the live placement claim before executing.
CREATE TABLE IF NOT EXISTS worker_turn_tool_authorities (
session_id TEXT NOT NULL PRIMARY KEY,
environment_id TEXT NOT NULL,
owner_epoch INTEGER NOT NULL CHECK (owner_epoch >= 1),
placement_generation INTEGER NOT NULL CHECK (placement_generation >= 0),
claim_id TEXT NOT NULL,
run_id TEXT NOT NULL,
tool_names_json TEXT NOT NULL,
updated_at_ms INTEGER NOT NULL,
FOREIGN KEY (session_id) REFERENCES worker_session_placements(session_id) ON DELETE CASCADE
) STRICT;
-- Tool-call ids are idempotency keys only within one exact source turn claim.
-- A running operation from another Gateway instance is ambiguous and is never
-- replayed. A persisted random seed separates durable downstream identities
-- from Gateway authentication keys and survives ordinary process restarts.
CREATE TABLE IF NOT EXISTS worker_session_tool_operations (
source_session_id TEXT NOT NULL,
source_claim_id TEXT NOT NULL,
tool_call_id TEXT NOT NULL,
tool_name TEXT NOT NULL CHECK (tool_name IN ('sessions_spawn', 'sessions_send')),
request_digest TEXT NOT NULL,
operation_seed TEXT NOT NULL,
status TEXT NOT NULL CHECK (status IN ('running', 'succeeded', 'failed', 'unknown')),
child_session_key TEXT,
result_json TEXT,
gateway_instance_id TEXT NOT NULL,
created_at_ms INTEGER NOT NULL,
updated_at_ms INTEGER NOT NULL,
PRIMARY KEY (source_session_id, source_claim_id, tool_call_id),
FOREIGN KEY (source_session_id)
REFERENCES worker_session_placements(session_id) ON DELETE CASCADE
) STRICT;
-- Local sandbox execution is a projection of a session-owned managed worktree.
-- No cascade: an older binary must not discard pending edits with a session row.
CREATE TABLE IF NOT EXISTS local_workspace_projections (
worktree_id TEXT NOT NULL PRIMARY KEY,
agent_id TEXT NOT NULL,
session_key TEXT NOT NULL,
session_id TEXT NOT NULL,
lifecycle_revision TEXT,
projection_path TEXT NOT NULL UNIQUE,
base_commit TEXT NOT NULL,
source_paths_json TEXT NOT NULL,
baseline_json TEXT,
baseline_ref TEXT,
pending_ref TEXT,
pending_target TEXT CHECK (pending_target IN ('canonical', 'projection')),
paused_runtimes_json TEXT,
journal_json TEXT,
journal_pack BLOB CHECK (journal_pack IS NULL OR length(journal_pack) <= 268435456),
revision INTEGER NOT NULL DEFAULT 0 CHECK (revision >= 0),
created_at_ms INTEGER NOT NULL,
checkpoint_json TEXT,
tree_root_digest BLOB,
source_paths_digest BLOB,
canonical_fingerprints BLOB,
projection_fingerprints BLOB,
CHECK (baseline_json IS NULL OR baseline_ref IS NOT NULL),
CHECK ((journal_json IS NULL) = (journal_pack IS NULL))
) STRICT;
-- The projection owner advances changed nodes and its root in one acceptance.
-- Legacy baseline_json remains only until that owner's resumable conversion.
CREATE TABLE IF NOT EXISTS local_workspace_manifest_nodes (
worktree_id TEXT NOT NULL,
path TEXT NOT NULL,
node_json TEXT NOT NULL,
PRIMARY KEY (worktree_id, path),
FOREIGN KEY (worktree_id)
REFERENCES local_workspace_projections(worktree_id) ON DELETE CASCADE
) STRICT;
-- Immutable subtrees and source inventories are shared across projections and revisions.
-- Large JSON packs measured 410k VFS reads/load WITHOUT ROWID versus 10k with rowid.
CREATE TABLE IF NOT EXISTS local_workspace_tree_packs (
tree_digest BLOB NOT NULL PRIMARY KEY CHECK (length(tree_digest) = 32),
records_json TEXT NOT NULL,
children_json TEXT NOT NULL,
sweep_epoch INTEGER NOT NULL
) STRICT;
CREATE TABLE IF NOT EXISTS local_workspace_source_path_sets (
path_digest BLOB NOT NULL PRIMARY KEY CHECK (length(path_digest) = 32),
paths_zstd BLOB NOT NULL,
sweep_epoch INTEGER NOT NULL
) STRICT, WITHOUT ROWID;
-- A reconciliation journal is written before managed-worktree mutation. The
-- bounded Git base snapshot repairs any subset left by an interrupted apply.
CREATE TABLE IF NOT EXISTS worker_workspace_reconciliations (
session_id TEXT NOT NULL PRIMARY KEY,
environment_id TEXT NOT NULL,
owner_epoch INTEGER NOT NULL CHECK (owner_epoch >= 1),
placement_generation INTEGER NOT NULL CHECK (placement_generation >= 0),
base_manifest_ref TEXT NOT NULL,
current_manifest_ref TEXT NOT NULL,
plan_json TEXT NOT NULL,
base_pack BLOB NOT NULL CHECK (length(base_pack) <= 268435456),
created_at_ms INTEGER NOT NULL,
FOREIGN KEY (session_id) REFERENCES worker_session_placements(session_id) ON DELETE CASCADE
) STRICT;
-- A completed remote turn is fenced from stale-claim teardown until its
-- workspace result is durably reconciled into the managed worktree.
CREATE TABLE IF NOT EXISTS worker_workspace_pending_results (
session_id TEXT NOT NULL PRIMARY KEY,
environment_id TEXT NOT NULL,
owner_epoch INTEGER NOT NULL CHECK (owner_epoch >= 1),
placement_generation INTEGER NOT NULL CHECK (placement_generation >= 0),
claim_id TEXT NOT NULL,
run_id TEXT NOT NULL,
gateway_instance_id TEXT NOT NULL,
recovery_requested_at_ms INTEGER,
workspace_accepted_at_ms INTEGER,
staged_result_ref TEXT,
repository_workspace_id TEXT,
created_at_ms INTEGER NOT NULL,
repository_disk_authority_json TEXT,
FOREIGN KEY (session_id) REFERENCES worker_session_placements(session_id) ON DELETE CASCADE
) STRICT;
-- GitHub publication intent records the authoritative session worktree. Cloud
-- requests execute only after the exact turn claim's result is accepted locally.
-- Secrets stay in the effective Gateway-owned GitHub profile and never enter
-- this row or the worker protocol.
CREATE TABLE IF NOT EXISTS github_publication_requests (
request_id TEXT NOT NULL PRIMARY KEY,
idempotency_key TEXT NOT NULL,
request_digest TEXT NOT NULL,
session_id TEXT NOT NULL,
session_key TEXT NOT NULL,
agent_id TEXT NOT NULL,
worktree_id TEXT NOT NULL,
repository_fingerprint TEXT NOT NULL,
claim_id TEXT,
run_id TEXT,
environment_id TEXT,
owner_epoch INTEGER CHECK (owner_epoch IS NULL OR owner_epoch >= 1),
placement_generation INTEGER CHECK (
placement_generation IS NULL OR placement_generation >= 0
),
identity_source TEXT NOT NULL CHECK (
identity_source IN ('system-detected', 'system-configured', 'agent-override')
),
identity_profile_id TEXT,
identity_account_id INTEGER NOT NULL CHECK (identity_account_id >= 1),
identity_login TEXT NOT NULL,
title TEXT,
body TEXT,
status TEXT NOT NULL CHECK (
status IN ('requested', 'publishing', 'published', 'failed')
),
gateway_instance_id TEXT,
repository TEXT,
branch TEXT NOT NULL,
base_branch TEXT,
source_head_commit TEXT,
source_index_tree TEXT,
workspace_tree TEXT,
head_commit TEXT,
pull_request_url TEXT,
error_code TEXT,
next_action TEXT,
created_at_ms INTEGER NOT NULL,
updated_at_ms INTEGER NOT NULL,
reported_at_ms INTEGER,
draft INTEGER,
UNIQUE (session_id, idempotency_key),
CHECK (
(claim_id IS NULL AND run_id IS NULL AND environment_id IS NULL
AND owner_epoch IS NULL AND placement_generation IS NULL)
OR
(claim_id IS NOT NULL AND run_id IS NOT NULL AND placement_generation IS NOT NULL
AND ((environment_id IS NULL AND owner_epoch IS NULL)
OR (environment_id IS NOT NULL AND owner_epoch IS NOT NULL)))
),
CHECK (
(identity_source IS 'system-detected' AND identity_profile_id IS NULL)
OR
(identity_source IN ('system-configured', 'agent-override')
AND identity_profile_id IS NOT NULL)
),
CHECK (
(source_head_commit IS NULL AND source_index_tree IS NULL AND workspace_tree IS NULL)
OR
(source_head_commit IS NOT NULL AND workspace_tree IS NOT NULL)
),
CHECK (
(status IS 'published' AND pull_request_url IS NOT NULL AND error_code IS NULL
AND next_action IS NULL)
OR
(status IS 'failed' AND pull_request_url IS NULL AND error_code IS NOT NULL
AND next_action IS NOT NULL)
OR
(status IN ('requested', 'publishing') AND pull_request_url IS NULL
AND error_code IS NULL AND next_action IS NULL)
)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_github_publication_requests_pending
ON github_publication_requests(status, updated_at_ms, request_id);
-- Personal requests cannot be interpreted or resumed by older shared publishers.
CREATE TABLE IF NOT EXISTS github_personal_publication_requests (
request_id TEXT NOT NULL PRIMARY KEY CHECK (length(request_id) = 36),
owner_profile_id TEXT NOT NULL CHECK (length(owner_profile_id) BETWEEN 1 AND 128),
connection_generation TEXT NOT NULL CHECK (length(connection_generation) = 36),
idempotency_key TEXT NOT NULL CHECK (length(idempotency_key) BETWEEN 1 AND 128),
request_digest TEXT NOT NULL CHECK (length(request_digest) = 64),
session_id TEXT NOT NULL CHECK (length(session_id) BETWEEN 1 AND 128),
session_key TEXT NOT NULL CHECK (length(session_key) BETWEEN 1 AND 1024),
agent_id TEXT NOT NULL CHECK (length(agent_id) BETWEEN 1 AND 128),
worktree_id TEXT NOT NULL CHECK (length(worktree_id) BETWEEN 1 AND 128),
repository_fingerprint TEXT NOT NULL CHECK (length(repository_fingerprint) BETWEEN 1 AND 256),
identity_source TEXT NOT NULL CHECK (identity_source = 'personal'),
identity_profile_id TEXT NOT NULL CHECK (length(identity_profile_id) = 36),
identity_account_id INTEGER NOT NULL CHECK (identity_account_id >= 1),
identity_login TEXT NOT NULL CHECK (length(identity_login) BETWEEN 1 AND 39),
title TEXT CHECK (title IS NULL OR length(title) BETWEEN 1 AND 256),
body TEXT CHECK (body IS NULL OR length(body) BETWEEN 1 AND 8192),
status TEXT NOT NULL CHECK (status IN ('requested', 'publishing', 'needs_confirmation', 'published', 'failed')),
gateway_instance_id TEXT CHECK (gateway_instance_id IS NULL OR length(gateway_instance_id) BETWEEN 1 AND 128),
execution_id TEXT CHECK (execution_id IS NULL OR length(execution_id) = 36),
last_effect TEXT CHECK (last_effect IS NULL OR last_effect IN ('push', 'pull_request')),
effect_state TEXT CHECK (effect_state IS NULL OR effect_state IN ('dispatched', 'observed')),
push_repository TEXT NOT NULL CHECK (length(push_repository) BETWEEN 3 AND 256),
repository TEXT NOT NULL CHECK (length(repository) BETWEEN 3 AND 256),
branch TEXT NOT NULL CHECK (length(branch) BETWEEN 1 AND 256),
base_branch TEXT NOT NULL CHECK (length(base_branch) BETWEEN 1 AND 256),
source_head_commit TEXT NOT NULL CHECK (length(source_head_commit) IN (40, 64)),
source_index_tree TEXT NOT NULL CHECK (length(source_index_tree) IN (40, 64)),
workspace_tree TEXT NOT NULL CHECK (length(workspace_tree) IN (40, 64)),
head_commit TEXT CHECK (head_commit IS NULL OR length(head_commit) IN (40, 64)),
pull_request_url TEXT CHECK (pull_request_url IS NULL OR length(pull_request_url) BETWEEN 1 AND 2048),
error_code TEXT CHECK (error_code IS NULL OR length(error_code) BETWEEN 1 AND 64),
next_action TEXT CHECK (next_action IS NULL OR length(next_action) BETWEEN 1 AND 1024),
created_at_ms INTEGER NOT NULL CHECK (created_at_ms >= 0),
updated_at_ms INTEGER NOT NULL CHECK (updated_at_ms >= created_at_ms),
reported_at_ms INTEGER,
draft INTEGER,
UNIQUE (owner_profile_id, session_id, idempotency_key),
CHECK ((status = 'publishing' AND gateway_instance_id IS NOT NULL AND execution_id IS NOT NULL) OR status <> 'publishing'),
CHECK ((last_effect IS NULL AND effect_state IS NULL) OR (last_effect IS NOT NULL AND effect_state IS NOT NULL)),
CHECK ((status = 'published' AND pull_request_url IS NOT NULL AND head_commit IS NOT NULL AND error_code IS NULL AND next_action IS NULL)
OR (status = 'failed' AND error_code IS NOT NULL AND next_action IS NOT NULL)
OR (status IN ('requested', 'publishing', 'needs_confirmation') AND error_code IS NULL AND next_action IS NULL))
) STRICT;
CREATE INDEX IF NOT EXISTS idx_github_personal_publication_owner_session
ON github_personal_publication_requests(owner_profile_id, session_id, created_at_ms);
CREATE INDEX IF NOT EXISTS idx_github_personal_publication_pending
ON github_personal_publication_requests(status, updated_at_ms, request_id);
-- Older readers validate both local receipt tables exactly. Their immutable
-- lifecycle binding stays in a first-use companion so those schemas remain readable.
CREATE TABLE IF NOT EXISTS github_publication_session_lifecycles (
publication_kind TEXT NOT NULL CHECK (publication_kind IN ('shared', 'personal')),
request_id TEXT NOT NULL,
lifecycle_revision TEXT,
requester_authority_json TEXT,
PRIMARY KEY (publication_kind, request_id)
) STRICT;
-- One active, opaque admission credential per worker environment. Plaintext
-- may be retried until delivery acknowledgement but never enters durable state.
CREATE TABLE IF NOT EXISTS worker_environment_credentials (
environment_id TEXT NOT NULL PRIMARY KEY,
credential_hash TEXT NOT NULL UNIQUE,
bundle_hash TEXT NOT NULL,
session_id TEXT,
rpc_set_version INTEGER NOT NULL CHECK (rpc_set_version >= 1),
owner_epoch INTEGER NOT NULL CHECK (owner_epoch >= 0),
expires_at_ms INTEGER NOT NULL CHECK (expires_at_ms >= 0),
delivered_at_ms INTEGER CHECK (delivered_at_ms >= 0),
FOREIGN KEY (environment_id) REFERENCES worker_environments(environment_id) ON DELETE CASCADE
) STRICT;
-- One durable sequence cursor per attached session owner epoch. The environment
-- binding prevents independent workers with coincident epochs from sharing replay state.
CREATE TABLE IF NOT EXISTS worker_transcript_commit_heads (
session_id TEXT NOT NULL,
run_epoch INTEGER NOT NULL CHECK (run_epoch >= 0),
environment_id TEXT NOT NULL,
next_seq INTEGER NOT NULL CHECK (next_seq >= 1),
updated_at_ms INTEGER NOT NULL CHECK (updated_at_ms >= 0),
PRIMARY KEY (session_id, run_epoch)
) STRICT;
-- Pending rows preserve a claimed request across gateway restarts. Terminal rows
-- cache the exact result returned for deterministic at-least-once replay.
CREATE TABLE IF NOT EXISTS worker_transcript_commits (
session_id TEXT NOT NULL,
run_epoch INTEGER NOT NULL CHECK (run_epoch >= 0),
seq INTEGER NOT NULL CHECK (seq >= 1),
request_hash TEXT NOT NULL,
state TEXT NOT NULL CHECK (state IN ('pending', 'terminal')),
result_json TEXT,
created_at_ms INTEGER NOT NULL CHECK (created_at_ms >= 0),
updated_at_ms INTEGER NOT NULL CHECK (updated_at_ms >= 0),
PRIMARY KEY (session_id, run_epoch, seq),
FOREIGN KEY (session_id, run_epoch)
REFERENCES worker_transcript_commit_heads(session_id, run_epoch)
ON DELETE CASCADE,
CHECK (
(state = 'pending' AND result_json IS NULL) OR
(state = 'terminal' AND result_json IS NOT NULL)
)
) STRICT;
-- Pending rows preserve a claimed inference turn across gateway restarts.
-- Terminal rows cache the exact outcome returned for deterministic replay.
CREATE TABLE IF NOT EXISTS worker_inference_turns (
session_id TEXT NOT NULL,
run_epoch INTEGER NOT NULL CHECK (run_epoch >= 0),
run_id TEXT NOT NULL,
turn_id TEXT NOT NULL,
environment_id TEXT NOT NULL,
request_hash TEXT NOT NULL,
state TEXT NOT NULL CHECK (state IN ('pending', 'terminal')),
terminal_json TEXT,
created_at_ms INTEGER NOT NULL CHECK (created_at_ms >= 0),
updated_at_ms INTEGER NOT NULL CHECK (updated_at_ms >= 0),
PRIMARY KEY (session_id, run_epoch, run_id, turn_id),
FOREIGN KEY (environment_id) REFERENCES worker_environments(environment_id) ON DELETE CASCADE,
CHECK (
(state = 'pending' AND terminal_json IS NULL) OR
(state = 'terminal' AND terminal_json IS NOT NULL)
)
) STRICT;
CREATE UNIQUE INDEX IF NOT EXISTS idx_worker_inference_turns_pending_run
ON worker_inference_turns(session_id, run_epoch, run_id)
WHERE state = 'pending';
CREATE TABLE IF NOT EXISTS template_installs (
agent_id TEXT NOT NULL PRIMARY KEY,
schema_version TEXT NOT NULL,
source_kind TEXT NOT NULL,
template_name TEXT NOT NULL,
template_version TEXT NOT NULL,
package_root TEXT NOT NULL,
manifest_path TEXT NOT NULL,
integrity_kind TEXT NOT NULL,
integrity TEXT NOT NULL,
source_byte_length INTEGER NOT NULL,
manifest_schema_version INTEGER NOT NULL,
plan_integrity TEXT NOT NULL,
workspace TEXT NOT NULL UNIQUE,
agent_config_digest TEXT NOT NULL,
agent_owned_paths_json TEXT NOT NULL,
bootstrap_source_path TEXT,
bootstrap_content_digest TEXT,
status TEXT NOT NULL CHECK (
status IN ('pending', 'workspace_ready', 'config_committed', 'complete', 'partial')
),
added_at_ms INTEGER NOT NULL,
updated_at_ms INTEGER NOT NULL
) STRICT;
CREATE TABLE IF NOT EXISTS template_workspace_files (
agent_id TEXT NOT NULL,
target_path TEXT NOT NULL,
schema_version TEXT NOT NULL,
workspace TEXT NOT NULL,
source_path TEXT NOT NULL,
content_digest TEXT NOT NULL,
status TEXT NOT NULL,
created_at_ms INTEGER NOT NULL,
updated_at_ms INTEGER NOT NULL,
PRIMARY KEY (agent_id, target_path)
) STRICT;
CREATE TABLE IF NOT EXISTS template_package_refs (
agent_id TEXT NOT NULL,
package_kind TEXT NOT NULL,
package_source TEXT NOT NULL,
package_ref TEXT NOT NULL,
package_version TEXT NOT NULL,
package_integrity TEXT NOT NULL,
schema_version TEXT NOT NULL,
template_name TEXT NOT NULL,
package_status TEXT NOT NULL,
relationship TEXT NOT NULL CHECK (relationship IN ('managed', 'referenced')),
origin TEXT NOT NULL CHECK (origin IN ('template-introduced', 'pre-existing')),
independent_owner INTEGER NOT NULL CHECK (independent_owner IN (0, 1)),
extension_id TEXT,
extension_format TEXT,
extension_detected_format TEXT,
extension_mapped_json TEXT,
extension_unavailable_json TEXT,
extension_adapter_identity TEXT,
installed_at_ms INTEGER NOT NULL,
updated_at_ms INTEGER NOT NULL,
PRIMARY KEY (agent_id, package_kind, package_source, package_ref, package_version)
) STRICT;
CREATE TABLE IF NOT EXISTS template_cron_refs (
agent_id TEXT NOT NULL,
manifest_id TEXT NOT NULL,
schema_version TEXT NOT NULL,
declaration_key TEXT NOT NULL UNIQUE,
scheduler_job_id TEXT UNIQUE,
status TEXT NOT NULL,
job_json TEXT NOT NULL,
error TEXT,
created_at_ms INTEGER NOT NULL,
updated_at_ms INTEGER NOT NULL,
PRIMARY KEY (agent_id, manifest_id)
) STRICT;
CREATE TABLE IF NOT EXISTS template_mcp_server_refs (
agent_id TEXT NOT NULL,
name TEXT NOT NULL,
schema_version TEXT NOT NULL,
config_digest TEXT NOT NULL,
relationship TEXT NOT NULL CHECK (relationship IN ('managed', 'referenced')),
origin TEXT NOT NULL CHECK (origin IN ('template-introduced', 'pre-existing')),
independent_owner INTEGER NOT NULL DEFAULT 0 CHECK (independent_owner IN (0, 1)),
status TEXT NOT NULL,
error TEXT,
created_at_ms INTEGER NOT NULL,
updated_at_ms INTEGER NOT NULL,
PRIMARY KEY (agent_id, name)
) STRICT;
CREATE TABLE IF NOT EXISTS user_profile_identities (
provider TEXT NOT NULL,
subject TEXT NOT NULL,
profile_id TEXT NOT NULL,
canonical_login TEXT,
-- Host-scoped verified credit evidence; current profile bindings govern attribution.
verified_email_json TEXT,
created_at INTEGER NOT NULL,
authorization_id TEXT,
authorization_basis_json TEXT,
PRIMARY KEY (provider, subject)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_user_profile_identities_profile_id
ON user_profile_identities(profile_id);
CREATE UNIQUE INDEX IF NOT EXISTS idx_user_profile_identities_authorization
ON user_profile_identities(authorization_id);
CREATE TABLE IF NOT EXISTS outbound_media_provenance (
realpath TEXT NOT NULL PRIMARY KEY,
kind TEXT NOT NULL,
version INTEGER NOT NULL,
sha256 TEXT NOT NULL,
size_bytes INTEGER NOT NULL,
created_at_ms INTEGER NOT NULL
) STRICT;
-- scope_id is non-null because SQLite treats NULLs as distinct in unique indexes/PKs,
-- which would allow duplicate team rows. This PK also avoids a rebuild for identity scope.
CREATE TABLE IF NOT EXISTS secret_store_entries (
scope_kind TEXT NOT NULL CHECK (scope_kind IN ('team', 'identity')),
scope_id TEXT NOT NULL,
name TEXT NOT NULL,
value TEXT NOT NULL,
kind TEXT NOT NULL CHECK (kind IN ('secret', 'env')),
created_at_ms INTEGER NOT NULL CHECK (created_at_ms >= 0),
updated_at_ms INTEGER NOT NULL CHECK (updated_at_ms >= 0),
updated_by TEXT,
deleted_at_ms INTEGER,
allowed_hosts TEXT,
CHECK ((scope_kind = 'team' AND scope_id = '') OR (scope_kind = 'identity' AND length(scope_id) > 0)),
PRIMARY KEY (scope_kind, scope_id, name)
) STRICT;
CREATE INDEX IF NOT EXISTS secret_store_entries_live_idx
ON secret_store_entries (scope_kind, scope_id, name) WHERE deleted_at_ms IS NULL;
`?`current`:t}`,a=Ni.get(i);if(a!==void 0)return a;let o=t,s=[...n?Re:Pe,...r?[]:Be],c=n?Le:Fe;for(let e of s)(t===`
CREATE TABLE IF NOT EXISTS mcp_oauth_stores (
store_key TEXT NOT NULL PRIMARY KEY,
format_version INTEGER NOT NULL CHECK (format_version = 1),
store_json TEXT NOT NULL,
updated_at INTEGER NOT NULL
) STRICT;
CREATE TABLE IF NOT EXISTS mcp_oauth_pending_authorizations (
state TEXT NOT NULL PRIMARY KEY,
store_key TEXT NOT NULL,
create_time INTEGER NOT NULL
) STRICT;
CREATE TABLE IF NOT EXISTS diagnostic_events (
scope TEXT NOT NULL,
event_key TEXT NOT NULL,
payload_json TEXT NOT NULL,
created_at INTEGER NOT NULL,
sequence INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY (scope, event_key)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_diagnostic_events_scope_sequence
ON diagnostic_events(scope, sequence, event_key);
CREATE TABLE IF NOT EXISTS skill_usage (
skill_file TEXT NOT NULL PRIMARY KEY,
skill_key TEXT NOT NULL,
skill_name TEXT NOT NULL,
skill_source TEXT NOT NULL,
first_used_at_ms INTEGER NOT NULL,
last_used_at_ms INTEGER NOT NULL,
use_count INTEGER NOT NULL,
last_agent_id TEXT
) STRICT;
-- Profile-owned skill library: additive, absent until first publication/import.
CREATE TABLE IF NOT EXISTS skill_library_entries (
skill_id TEXT NOT NULL PRIMARY KEY,
owner_profile_id TEXT,
author_profile_id TEXT NOT NULL,
slug TEXT NOT NULL,
current_revision TEXT NOT NULL,
shared INT NOT NULL,
enabled INT NOT NULL,
removed INT NOT NULL,
created_at INT NOT NULL,
updated_at INT NOT NULL
) STRICT;
CREATE TABLE IF NOT EXISTS skill_library_revisions (
skill_id TEXT NOT NULL,
revision TEXT NOT NULL,
description TEXT NOT NULL,
files_json TEXT NOT NULL,
created_at INT NOT NULL,
PRIMARY KEY (skill_id, revision)
) STRICT;
CREATE TABLE IF NOT EXISTS skill_library_events (
event_id TEXT NOT NULL PRIMARY KEY,
skill_id TEXT NOT NULL,
revision TEXT NOT NULL,
action TEXT NOT NULL,
actor_profile_id TEXT NOT NULL,
created_at INT NOT NULL
) STRICT;
CREATE TABLE IF NOT EXISTS skill_library_uploads (
upload_id TEXT NOT NULL PRIMARY KEY,
owner_profile_id TEXT NOT NULL,
slug TEXT NOT NULL,
size_bytes INT NOT NULL,
sha256 TEXT NOT NULL,
archive_blob BLOB NOT NULL,
expires_at INT NOT NULL,
published_skill_id TEXT
) STRICT;
-- End profile-owned skill library.
CREATE TABLE IF NOT EXISTS skill_workshop_changes (
cursor_id INTEGER NOT NULL,
change_id TEXT NOT NULL PRIMARY KEY,
agent_id TEXT NOT NULL,
skill_name TEXT NOT NULL,
action TEXT NOT NULL CHECK (action IN ('create', 'patch', 'write_file', 'remove_file', 'archive', 'restore')),
actor TEXT NOT NULL CHECK (actor IN ('agent', 'review', 'curator', 'user')),
summary TEXT NOT NULL,
version_id TEXT,
session_key TEXT,
run_id TEXT,
created_at_ms INTEGER NOT NULL
) STRICT;
CREATE UNIQUE INDEX IF NOT EXISTS skill_workshop_changes_cursor_id_idx
ON skill_workshop_changes(cursor_id);
CREATE INDEX IF NOT EXISTS idx_skill_workshop_changes_agent_time
ON skill_workshop_changes(agent_id, created_at_ms);
CREATE TABLE IF NOT EXISTS audit_events (
sequence INTEGER PRIMARY KEY AUTOINCREMENT,
event_id TEXT NOT NULL UNIQUE,
source_id TEXT NOT NULL UNIQUE,
schema_version INTEGER NOT NULL DEFAULT 1,
source_sequence INTEGER NOT NULL,
occurred_at INTEGER NOT NULL,
kind TEXT NOT NULL,
action TEXT NOT NULL,
status TEXT NOT NULL,
error_code TEXT,
actor_type TEXT NOT NULL,
actor_id TEXT NOT NULL,
agent_id TEXT,
session_key TEXT,
session_id TEXT,
run_id TEXT,
tool_call_id TEXT,
tool_name TEXT,
direction TEXT,
channel TEXT,
conversation_kind TEXT,
message_outcome TEXT,
reason_code TEXT,
delivery_kind TEXT,
failure_stage TEXT,
duration_ms INTEGER,
result_count INTEGER,
account_ref TEXT,
conversation_ref TEXT,
message_ref TEXT,
target_ref TEXT
) STRICT;
CREATE INDEX IF NOT EXISTS idx_audit_events_time
ON audit_events(occurred_at DESC, sequence DESC);
CREATE INDEX IF NOT EXISTS idx_audit_events_agent_sequence
ON audit_events(agent_id, sequence DESC);
CREATE INDEX IF NOT EXISTS idx_audit_events_session_sequence
ON audit_events(session_key, sequence DESC);
CREATE INDEX IF NOT EXISTS idx_audit_events_run_sequence
ON audit_events(run_id, sequence DESC);
CREATE INDEX IF NOT EXISTS idx_audit_events_kind_sequence
ON audit_events(kind, sequence DESC);
CREATE INDEX IF NOT EXISTS idx_audit_events_status_sequence
ON audit_events(status, sequence DESC);
CREATE INDEX IF NOT EXISTS idx_audit_events_channel_sequence
ON audit_events(channel, sequence DESC);
CREATE INDEX IF NOT EXISTS idx_audit_events_direction_sequence
ON audit_events(direction, sequence DESC);
CREATE TABLE IF NOT EXISTS outbound_message_execution_bindings (
event_id TEXT NOT NULL PRIMARY KEY,
context_id TEXT NOT NULL CHECK (length(context_id) BETWEEN 1 AND 256),
execution_id TEXT NOT NULL CHECK (length(execution_id) BETWEEN 1 AND 256),
run_id TEXT NOT NULL CHECK (length(run_id) BETWEEN 1 AND 256),
FOREIGN KEY (event_id) REFERENCES audit_events(event_id) ON DELETE CASCADE
) STRICT;
CREATE INDEX IF NOT EXISTS outbound_message_execution_bindings_execution_event_idx
ON outbound_message_execution_bindings (context_id, execution_id, run_id, event_id);
CREATE TABLE IF NOT EXISTS outbound_message_progress (
sequence INTEGER PRIMARY KEY AUTOINCREMENT,
progress_id TEXT NOT NULL UNIQUE CHECK (length(progress_id) BETWEEN 1 AND 256),
source_id TEXT NOT NULL UNIQUE CHECK (length(source_id) BETWEEN 1 AND 512),
source_sequence INTEGER NOT NULL CHECK (source_sequence >= 1),
schema_version INTEGER NOT NULL CHECK (schema_version = 1),
occurred_at INTEGER NOT NULL CHECK (occurred_at >= 0),
action TEXT NOT NULL CHECK (
action IN ('message.outbound.queued', 'message.outbound.platform-started')
),
outcome TEXT NOT NULL CHECK (outcome IN ('queued', 'platform_started')),
actor_type TEXT NOT NULL CHECK (actor_type IN ('agent', 'system')),
actor_id TEXT NOT NULL CHECK (length(actor_id) BETWEEN 1 AND 256),
agent_id TEXT CHECK (agent_id IS NULL OR length(agent_id) BETWEEN 1 AND 256),
run_id TEXT CHECK (run_id IS NULL OR length(run_id) BETWEEN 1 AND 256),
context_id TEXT,
execution_id TEXT,
channel TEXT NOT NULL CHECK (length(channel) BETWEEN 1 AND 256),
conversation_kind TEXT NOT NULL CHECK (
conversation_kind IN ('direct', 'group', 'channel', 'unknown')
),
duration_ms INTEGER CHECK (duration_ms IS NULL OR duration_ms >= 0),
account_ref TEXT,
conversation_ref TEXT,
target_ref TEXT,
UNIQUE (occurred_at, progress_id)
) STRICT;
CREATE INDEX IF NOT EXISTS outbound_message_progress_occurred_idx
ON outbound_message_progress (occurred_at, sequence);
CREATE INDEX IF NOT EXISTS outbound_message_progress_run_occurred_idx
ON outbound_message_progress (run_id, occurred_at, sequence);
CREATE TABLE IF NOT EXISTS audit_identity_keys (
id INTEGER NOT NULL PRIMARY KEY CHECK (id = 1),
key_id TEXT NOT NULL,
key BLOB NOT NULL,
created_at INTEGER NOT NULL
) STRICT;
CREATE TABLE IF NOT EXISTS config_revision_keys (
id INTEGER NOT NULL PRIMARY KEY CHECK (id = 1),
hmac_key BLOB NOT NULL CHECK (length(hmac_key) = 32)
) STRICT;
CREATE TABLE IF NOT EXISTS execution_identity_contexts (
context_id TEXT NOT NULL PRIMARY KEY CHECK (length(context_id) BETWEEN 1 AND 256),
execution_id TEXT NOT NULL UNIQUE CHECK (length(execution_id) BETWEEN 1 AND 256),
run_id TEXT NOT NULL CHECK (length(run_id) BETWEEN 1 AND 256),
created_at INTEGER NOT NULL CHECK (created_at >= 0),
coverage_state TEXT NOT NULL CHECK (
coverage_state IN ('attribution-only', 'unattributed', 'unknown', 'unsupported')
),
context_bytes INTEGER NOT NULL CHECK (context_bytes BETWEEN 1 AND 16384),
context_json TEXT NOT NULL CHECK (length(context_json) > 0),
UNIQUE (created_at, context_id)
) STRICT;
CREATE INDEX IF NOT EXISTS execution_identity_contexts_run_created_idx
ON execution_identity_contexts (run_id, created_at, execution_id);
CREATE TABLE IF NOT EXISTS execution_decision_facts (
cursor_id INTEGER NOT NULL,
receipt_id TEXT NOT NULL PRIMARY KEY CHECK (length(receipt_id) BETWEEN 1 AND 256),
context_id TEXT NOT NULL CHECK (length(context_id) BETWEEN 1 AND 256),
execution_id TEXT NOT NULL CHECK (length(execution_id) BETWEEN 1 AND 256),
run_id TEXT NOT NULL CHECK (length(run_id) BETWEEN 1 AND 256),
action_id TEXT CHECK (action_id IS NULL OR length(action_id) BETWEEN 1 AND 256),
action_family TEXT NOT NULL CHECK (length(action_family) BETWEEN 1 AND 256),
decision_outcome TEXT NOT NULL CHECK (
decision_outcome IN ('allowed', 'denied', 'not-applicable', 'unknown')
),
coverage_state TEXT NOT NULL CHECK (
coverage_state IN ('enforced', 'attribution-only', 'unattributed', 'unknown', 'unsupported')
),
reason_code TEXT NOT NULL CHECK (length(reason_code) BETWEEN 1 AND 256),
owner TEXT NOT NULL CHECK (length(owner) BETWEEN 1 AND 256),
source_ref TEXT NOT NULL CHECK (length(source_ref) BETWEEN 1 AND 256),
occurred_at INTEGER NOT NULL CHECK (occurred_at >= 0),
receipt_bytes INTEGER NOT NULL CHECK (receipt_bytes BETWEEN 1 AND 16384),
receipt_json TEXT NOT NULL CHECK (length(receipt_json) > 0),
UNIQUE (occurred_at, receipt_id)
) STRICT;
CREATE UNIQUE INDEX IF NOT EXISTS execution_decision_facts_cursor_id_idx
ON execution_decision_facts(cursor_id);
CREATE INDEX IF NOT EXISTS execution_decision_facts_context_occurred_idx
ON execution_decision_facts (context_id, occurred_at, receipt_id);
CREATE INDEX IF NOT EXISTS execution_decision_facts_run_occurred_idx
ON execution_decision_facts (run_id, occurred_at, receipt_id);
-- Exact admission identity stays separate from owner-native lifecycle rows so
-- older readers retain byte-compatible cron/task/flow table definitions.
CREATE TABLE IF NOT EXISTS execution_owner_lifecycle_bindings (
owner_kind TEXT NOT NULL,
owner_id TEXT NOT NULL,
context_id TEXT NOT NULL,
execution_id TEXT NOT NULL,
PRIMARY KEY (owner_kind, owner_id)
) STRICT;
CREATE TABLE IF NOT EXISTS session_state_events (
sequence INTEGER PRIMARY KEY AUTOINCREMENT,
dedupe_key TEXT UNIQUE,
session_key TEXT NOT NULL,
session_id TEXT,
agent_id TEXT NOT NULL,
kind TEXT NOT NULL,
actor_type TEXT NOT NULL,
actor_id TEXT,
run_id TEXT,
occurred_at INTEGER NOT NULL,
summary TEXT NOT NULL,
payload_json TEXT
) STRICT;
CREATE INDEX IF NOT EXISTS idx_session_state_events_session_sequence
ON session_state_events(session_key, sequence DESC);
CREATE INDEX IF NOT EXISTS idx_session_state_events_time
ON session_state_events(occurred_at DESC, sequence DESC);
CREATE TABLE IF NOT EXISTS session_state_heads (
session_key TEXT NOT NULL,
agent_id TEXT NOT NULL,
last_sequence INTEGER NOT NULL,
pruned_max_sequence INTEGER NOT NULL DEFAULT 0,
updated_at INTEGER NOT NULL,
PRIMARY KEY (session_key, agent_id)
) STRICT, WITHOUT ROWID;
-- Notifiable watcher identity is the bare session key, matching the process-local
-- system-event queue it feeds. Provenance distinguishes explicit immediate-wake
-- watches from ambient queue-only group watches. Other bare keys
-- (session.scope="global") are ambiguous across agents and excluded until watcher
-- identity is agent-scoped end-to-end.
CREATE TABLE IF NOT EXISTS session_watch_cursors (
watcher_session_key TEXT NOT NULL,
watcher_store_path TEXT,
target_session_key TEXT NOT NULL,
last_seen_sequence INTEGER NOT NULL DEFAULT 0,
notified_sequence INTEGER NOT NULL DEFAULT 0,
material_sequence INTEGER NOT NULL DEFAULT 0,
provenance TEXT NOT NULL DEFAULT 'explicit' CHECK (provenance IN ('explicit', 'ambient-group')),
updated_at INTEGER NOT NULL,
PRIMARY KEY (watcher_session_key, target_session_key)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_session_watch_cursors_target
ON session_watch_cursors(target_session_key);
CREATE TABLE IF NOT EXISTS session_upstream_links (
session_key TEXT NOT NULL,
agent_id TEXT NOT NULL,
catalog_id TEXT NOT NULL,
host_id TEXT NOT NULL,
thread_id TEXT NOT NULL,
upstream_kind TEXT NOT NULL,
upstream_ref_json TEXT,
last_marker_json TEXT,
last_scanned_at INTEGER,
created_at INTEGER NOT NULL,
updated_at INTEGER NOT NULL,
-- (session_key, agent_id) composite identity: under session.scope="global" agents
-- share bare keys; a key-only row would let one agent overwrite another's upstream.
PRIMARY KEY (session_key, agent_id)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_session_upstream_links_catalog_id
ON session_upstream_links(catalog_id);
CREATE TABLE IF NOT EXISTS 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;
CREATE INDEX IF NOT EXISTS idx_state_leases_expiry
ON state_leases(expires_at, scope, lease_key)
WHERE expires_at IS NOT NULL;
CREATE INDEX IF NOT EXISTS idx_state_leases_owner
ON state_leases(owner);
CREATE TABLE IF NOT EXISTS exec_approvals_config (
config_key TEXT NOT NULL PRIMARY KEY,
raw_json TEXT NOT NULL,
socket_path TEXT,
has_socket_token INTEGER NOT NULL,
default_security TEXT,
default_ask TEXT,
default_ask_fallback TEXT,
auto_allow_skills INTEGER,
agent_count INTEGER NOT NULL,
allowlist_count INTEGER NOT NULL,
updated_at_ms INTEGER NOT NULL
) STRICT;
CREATE TABLE IF NOT EXISTS operator_approvals (
cursor_id INTEGER NOT NULL,
approval_id TEXT NOT NULL PRIMARY KEY CHECK (
length(approval_id) > 0 AND approval_id NOT IN ('.', '..')
),
resolution_ref TEXT NOT NULL CHECK (
length(resolution_ref) = 43 AND resolution_ref NOT GLOB '*[^A-Za-z0-9_-]*'
),
kind TEXT NOT NULL CHECK (kind IN ('exec', 'plugin', 'system-agent')),
status TEXT NOT NULL CHECK (status IN ('pending', 'allowed', 'denied', 'expired', 'cancelled')),
presentation_json TEXT NOT NULL,
requested_by_device_id TEXT,
requested_by_client_id TEXT,
requested_by_device_token_auth INTEGER NOT NULL DEFAULT 0,
reviewer_device_ids_json TEXT NOT NULL,
source_agent_id TEXT,
source_session_key TEXT,
source_session_id TEXT,
source_run_id TEXT,
source_tool_call_id TEXT,
source_tool_name TEXT,
audience_session_keys_json TEXT NOT NULL,
runtime_epoch TEXT NOT NULL,
created_at_ms INTEGER NOT NULL,
expires_at_ms INTEGER NOT NULL,
updated_at_ms INTEGER NOT NULL,
decision TEXT CHECK (decision IN ('allow-once', 'allow-always', 'deny')),
terminal_reason TEXT CHECK (
terminal_reason IN (
'user',
'timeout',
'malformed-verdict',
'no-route',
'run-aborted',
'gateway-restart',
'storage-corrupt'
)
),
resolved_at_ms INTEGER,
resolver_kind TEXT CHECK (resolver_kind IN ('device', 'channel', 'runtime', 'system')),
resolver_id TEXT,
consumed_at_ms INTEGER,
consumed_by TEXT,
CHECK (expires_at_ms >= created_at_ms),
CHECK (updated_at_ms >= created_at_ms),
CHECK (resolved_at_ms IS NULL OR resolved_at_ms >= created_at_ms),
CHECK (resolved_at_ms IS NULL OR resolved_at_ms <= updated_at_ms),
CHECK (consumed_at_ms IS NULL OR consumed_at_ms >= resolved_at_ms),
CHECK (consumed_at_ms IS NULL OR consumed_at_ms <= updated_at_ms),
CHECK (requested_by_device_token_auth IN (0, 1)),
CHECK (
(
status = 'pending'
AND decision IS NULL
AND terminal_reason IS NULL
AND resolved_at_ms IS NULL
AND resolver_kind IS NULL
AND resolver_id IS NULL
AND consumed_at_ms IS NULL
AND consumed_by IS NULL
)
OR (
status = 'allowed'
AND decision IN ('allow-once', 'allow-always')
AND terminal_reason = 'user'
AND resolved_at_ms IS NOT NULL
AND resolver_kind IS NOT NULL
)
OR (
status = 'denied'
AND decision = 'deny'
AND terminal_reason IN ('user', 'malformed-verdict', 'no-route', 'storage-corrupt')
AND resolved_at_ms IS NOT NULL
AND resolver_kind IS NOT NULL
AND consumed_at_ms IS NULL
AND consumed_by IS NULL
)
OR (
status = 'expired'
AND decision = 'deny'
AND terminal_reason = 'timeout'
AND resolved_at_ms IS NOT NULL
AND resolver_kind IS NOT NULL
AND consumed_at_ms IS NULL
AND consumed_by IS NULL
)
OR (
status = 'cancelled'
AND decision = 'deny'
AND terminal_reason IN ('run-aborted', 'gateway-restart')
AND resolved_at_ms IS NOT NULL
AND resolver_kind IS NOT NULL
AND consumed_at_ms IS NULL
AND consumed_by IS NULL
)
),
CHECK (
(consumed_at_ms IS NULL AND consumed_by IS NULL)
OR (
status = 'allowed'
AND decision = 'allow-once'
AND consumed_at_ms IS NOT NULL
AND consumed_by IS NOT NULL
)
)
) STRICT;
CREATE UNIQUE INDEX IF NOT EXISTS idx_operator_approvals_cursor_id
ON operator_approvals(cursor_id);
CREATE INDEX IF NOT EXISTS idx_operator_approvals_status_expiry
ON operator_approvals(status, expires_at_ms, approval_id);
CREATE UNIQUE INDEX IF NOT EXISTS idx_operator_approvals_resolution_ref
ON operator_approvals(resolution_ref);
CREATE INDEX IF NOT EXISTS idx_operator_approvals_source_session_created
ON operator_approvals(source_session_key, created_at_ms DESC, approval_id);
CREATE INDEX IF NOT EXISTS idx_operator_approvals_source_run_resolved
ON operator_approvals(source_run_id, resolved_at_ms, approval_id)
WHERE source_run_id IS NOT NULL AND resolved_at_ms IS NOT NULL;
CREATE INDEX IF NOT EXISTS idx_operator_approvals_resolved
ON operator_approvals(resolved_at_ms, approval_id)
WHERE resolved_at_ms IS NOT NULL;
CREATE INDEX IF NOT EXISTS idx_operator_approvals_runtime_pending
ON operator_approvals(runtime_epoch, approval_id)
WHERE status = 'pending';
CREATE TABLE IF NOT EXISTS operator_approval_execution_identities (
approval_id TEXT NOT NULL PRIMARY KEY
REFERENCES operator_approvals(approval_id) ON DELETE CASCADE,
source_context_id TEXT NOT NULL CHECK (
length(source_context_id) BETWEEN 1 AND 256 AND source_context_id = trim(source_context_id)
),
source_execution_id TEXT NOT NULL CHECK (
length(source_execution_id) BETWEEN 1 AND 256 AND source_execution_id = trim(source_execution_id)
)
) STRICT;
CREATE TABLE IF NOT EXISTS operator_approval_standing_grants (
grant_id TEXT NOT NULL PRIMARY KEY CHECK (length(grant_id) > 0),
minted_by_approval_id TEXT NOT NULL
REFERENCES operator_approvals(approval_id) ON DELETE CASCADE,
agent_id TEXT NOT NULL CHECK (length(agent_id) > 0),
cron_job_id TEXT NOT NULL CHECK (length(cron_job_id) > 0),
job_config_revision TEXT NOT NULL CHECK (length(job_config_revision) > 0),
operation_binding TEXT NOT NULL CHECK (length(operation_binding) > 0),
created_at_ms INTEGER NOT NULL,
expires_at_ms INTEGER CHECK (expires_at_ms IS NULL OR expires_at_ms >= created_at_ms),
revoked_at_ms INTEGER,
revoked_by TEXT,
last_used_at_ms INTEGER,
use_count INTEGER NOT NULL DEFAULT 0
) STRICT;
CREATE INDEX IF NOT EXISTS idx_operator_approval_standing_grants_binding
ON operator_approval_standing_grants(agent_id, cron_job_id, operation_binding, created_at_ms DESC);
CREATE TABLE IF NOT EXISTS operator_approval_standing_grant_generations (
grant_id TEXT NOT NULL PRIMARY KEY
REFERENCES operator_approval_standing_grants(grant_id) ON DELETE CASCADE,
job_definition_generation INTEGER NOT NULL CHECK (job_definition_generation >= 1)
) STRICT;
CREATE TABLE IF NOT EXISTS 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;
CREATE TABLE IF NOT EXISTS config_machine_state (
state_key TEXT NOT NULL PRIMARY KEY,
value_json TEXT NOT NULL,
updated_at_ms INTEGER NOT NULL
) STRICT;
CREATE TABLE IF NOT EXISTS device_pairing_pending (
request_id TEXT NOT NULL PRIMARY KEY,
device_id TEXT NOT NULL,
public_key TEXT NOT NULL,
display_name TEXT,
platform TEXT,
device_family TEXT,
client_id TEXT,
client_mode TEXT,
browser_origin TEXT,
role TEXT,
roles_json TEXT,
scopes_json TEXT,
remote_ip TEXT,
silent INTEGER,
is_repair INTEGER,
ts INTEGER NOT NULL,
refreshed_at_ms INTEGER
) STRICT;
CREATE INDEX IF NOT EXISTS idx_device_pairing_pending_device
ON device_pairing_pending(device_id, ts DESC);
CREATE TABLE IF NOT EXISTS device_pairing_paired (
device_id TEXT NOT NULL PRIMARY KEY,
public_key TEXT NOT NULL,
display_name TEXT,
operator_label TEXT,
platform TEXT,
device_family TEXT,
client_id TEXT,
client_mode TEXT,
browser_origin TEXT,
role TEXT,
roles_json TEXT,
scopes_json TEXT,
approved_scopes_json TEXT,
remote_ip TEXT,
tokens_json TEXT,
approved_via TEXT,
node_surface_json TEXT,
pending_node_surface_json TEXT,
created_at_ms INTEGER NOT NULL,
approved_at_ms INTEGER NOT NULL,
last_seen_at_ms INTEGER,
last_seen_reason TEXT
) STRICT;
CREATE INDEX IF NOT EXISTS idx_device_pairing_paired_approved
ON device_pairing_paired(approved_at_ms DESC, device_id);
CREATE TABLE IF NOT EXISTS device_bootstrap_tokens (
token_key TEXT NOT NULL PRIMARY KEY,
token TEXT NOT NULL,
setup_id TEXT,
ts INTEGER NOT NULL,
device_id TEXT,
public_key TEXT,
profile_json TEXT,
redeemed_profile_json TEXT,
pending_profile_json TEXT,
issued_at_ms INTEGER NOT NULL,
last_used_at_ms INTEGER
) STRICT;
CREATE INDEX IF NOT EXISTS idx_device_bootstrap_tokens_ts
ON device_bootstrap_tokens(ts);
-- Terminal outcome of a redeemed setup credential. The bootstrap row is deleted
-- on redemption, so this is the only durable proof a setup code succeeded; the
-- presenting client reconciles it when the completion broadcast is missed.
-- Non-secret only: never the bootstrap token or anything derived from it.
-- Bounded by retention to a handful of live rows, so the primary key is the
-- only access path worth having.
CREATE TABLE IF NOT EXISTS device_pair_setup_completions (
setup_id TEXT NOT NULL PRIMARY KEY,
device_id TEXT NOT NULL,
device_name TEXT,
access TEXT NOT NULL,
completed_at_ms INTEGER NOT NULL,
delivery_state TEXT NOT NULL CHECK (delivery_state IN ('uncertain', 'confirmed')),
retain_until_ms INTEGER NOT NULL
) STRICT;
CREATE TABLE IF NOT EXISTS device_pairing_join_codes (
shortcode TEXT,
payload_json TEXT,
created_at_ms INTEGER,
expires_at_ms INTEGER
) STRICT;
CREATE TABLE IF NOT EXISTS device_pairing_browser_requests (
request_id TEXT NOT NULL PRIMARY KEY,
code TEXT NOT NULL UNIQUE,
device_id TEXT NOT NULL UNIQUE,
public_key TEXT NOT NULL,
remote_ip TEXT,
user_agent TEXT,
origin TEXT,
status TEXT NOT NULL CHECK (status IN ('pending', 'approved', 'rejected')),
approved_token_sha256 TEXT,
created_at_ms INTEGER NOT NULL,
expires_at_ms INTEGER NOT NULL
) STRICT;
CREATE TABLE IF NOT EXISTS macos_port_guardian_records (
pid INTEGER NOT NULL PRIMARY KEY,
port INTEGER NOT NULL,
command TEXT NOT NULL,
mode TEXT NOT NULL,
timestamp REAL NOT NULL
) STRICT;
CREATE INDEX IF NOT EXISTS idx_macos_port_guardian_records_port
ON macos_port_guardian_records(port, timestamp DESC);
CREATE TABLE IF NOT EXISTS workspace_setup_state (
workspace_key TEXT NOT NULL PRIMARY KEY,
-- NULL only for attestation-only rows whose legacy source never recorded a
-- path (orphan hashed-key attestations); setup rows always carry one.
workspace_path TEXT,
-- NULL setup columns mean an attestation-only row: replaceWorkspaceAttestation
-- may record hashes before any setup milestone exists for the workspace.
version INTEGER,
bootstrap_seeded_at TEXT,
setup_completed_at TEXT,
updated_at INTEGER,
attested_at_ms INTEGER,
attestation_updated_at_ms INTEGER,
bootstrap_deferred INTEGER,
CHECK (version IS NULL OR workspace_path IS NOT NULL)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_workspace_setup_state_path
ON workspace_setup_state(workspace_path);
CREATE TABLE IF NOT EXISTS workspace_path_aliases (
alias_key TEXT NOT NULL PRIMARY KEY,
alias_path TEXT NOT NULL,
workspace_key TEXT NOT NULL,
workspace_path TEXT NOT NULL,
updated_at_ms INTEGER NOT NULL
) STRICT;
CREATE INDEX IF NOT EXISTS idx_workspace_path_aliases_workspace
ON workspace_path_aliases(workspace_key);
CREATE TABLE IF NOT EXISTS workspace_generated_bootstrap_hashes (
workspace_key TEXT NOT NULL,
filename TEXT NOT NULL,
sha256 TEXT NOT NULL,
PRIMARY KEY (workspace_key, filename),
FOREIGN KEY (workspace_key) REFERENCES workspace_setup_state(workspace_key) ON DELETE CASCADE
) STRICT;
CREATE TABLE IF NOT EXISTS native_hook_relay_bridges (
relay_id TEXT NOT NULL PRIMARY KEY,
pid INTEGER NOT NULL,
hostname TEXT NOT NULL,
port INTEGER NOT NULL,
token TEXT NOT NULL,
expires_at_ms INTEGER NOT NULL,
updated_at_ms INTEGER NOT NULL
) STRICT;
CREATE INDEX IF NOT EXISTS idx_native_hook_relay_bridges_expires
ON native_hook_relay_bridges(expires_at_ms, relay_id);
CREATE TABLE IF NOT EXISTS managed_outgoing_image_records (
attachment_id TEXT NOT NULL PRIMARY KEY,
session_key TEXT NOT NULL,
agent_id TEXT,
message_id TEXT,
created_at TEXT NOT NULL,
updated_at TEXT,
retention_class TEXT,
alt TEXT NOT NULL,
original_media_root TEXT NOT NULL,
original_media_id TEXT NOT NULL,
original_media_subdir TEXT NOT NULL,
original_content_type TEXT NOT NULL,
original_width INTEGER,
original_height INTEGER,
original_size_bytes INTEGER,
original_filename TEXT,
record_json TEXT NOT NULL,
cleanup_pending INTEGER NOT NULL DEFAULT 0 CHECK (cleanup_pending IN (0, 1))
) STRICT;
CREATE INDEX IF NOT EXISTS idx_managed_outgoing_images_session
ON managed_outgoing_image_records(session_key, created_at DESC, attachment_id);
CREATE INDEX IF NOT EXISTS idx_managed_outgoing_images_message
ON managed_outgoing_image_records(session_key, message_id, attachment_id)
WHERE message_id IS NOT NULL;
CREATE INDEX IF NOT EXISTS idx_managed_outgoing_images_agent_session
ON managed_outgoing_image_records(session_key, agent_id, created_at DESC, attachment_id);
CREATE INDEX IF NOT EXISTS idx_managed_outgoing_images_agent_message
ON managed_outgoing_image_records(session_key, agent_id, message_id, attachment_id)
WHERE message_id IS NOT NULL;
CREATE TABLE IF NOT EXISTS channel_pairing_requests (
channel_key TEXT NOT NULL,
account_id TEXT NOT NULL,
request_id TEXT NOT NULL,
code TEXT NOT NULL,
created_at TEXT NOT NULL,
last_seen_at TEXT NOT NULL,
meta_json TEXT,
PRIMARY KEY (channel_key, account_id, request_id)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_channel_pairing_requests_code
ON channel_pairing_requests(channel_key, code);
CREATE INDEX IF NOT EXISTS idx_channel_pairing_requests_created
ON channel_pairing_requests(channel_key, created_at, request_id);
CREATE TABLE IF NOT EXISTS channel_pairing_allow_entries (
channel_key TEXT NOT NULL,
account_id TEXT NOT NULL,
entry TEXT NOT NULL,
sort_order INTEGER NOT NULL,
updated_at INTEGER NOT NULL,
PRIMARY KEY (channel_key, account_id, entry)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_channel_pairing_allow_account
ON channel_pairing_allow_entries(channel_key, account_id, sort_order, entry);
CREATE TABLE IF NOT EXISTS web_push_subscriptions (
endpoint_hash TEXT NOT NULL PRIMARY KEY,
subscription_id TEXT NOT NULL UNIQUE,
endpoint TEXT NOT NULL,
p256dh TEXT NOT NULL,
auth TEXT NOT NULL,
device_id TEXT,
user_profile_id TEXT,
preferences_json TEXT,
created_at_ms INTEGER NOT NULL,
updated_at_ms INTEGER NOT NULL
) STRICT;
CREATE INDEX IF NOT EXISTS idx_web_push_subscriptions_updated
ON web_push_subscriptions(updated_at_ms DESC, subscription_id);
CREATE TABLE IF NOT EXISTS web_push_approval_deliveries (
approval_id TEXT NOT NULL
REFERENCES operator_approvals(approval_id) ON DELETE CASCADE,
subscription_id TEXT NOT NULL
REFERENCES web_push_subscriptions(subscription_id) ON DELETE CASCADE,
device_id TEXT NOT NULL,
user_profile_id TEXT,
prepared_at_ms INTEGER NOT NULL,
PRIMARY KEY (approval_id, subscription_id)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_web_push_approval_deliveries_subscription
ON web_push_approval_deliveries(subscription_id, approval_id);
CREATE TABLE IF NOT EXISTS apns_registrations (
node_id TEXT NOT NULL PRIMARY KEY,
transport TEXT NOT NULL,
token TEXT,
relay_handle TEXT,
send_grant TEXT,
installation_id TEXT,
relay_origin TEXT,
topic TEXT NOT NULL,
environment TEXT NOT NULL,
distribution TEXT,
token_debug_suffix TEXT,
updated_at_ms INTEGER NOT NULL
) STRICT;
CREATE INDEX IF NOT EXISTS idx_apns_registrations_updated
ON apns_registrations(updated_at_ms DESC, node_id);
CREATE TABLE IF NOT EXISTS apns_registration_tombstones (
node_id TEXT NOT NULL PRIMARY KEY,
deleted_at_ms INTEGER NOT NULL
) STRICT;
-- Node-host-owned launch journal. The descriptor and its credential remain
-- process memory only; this table records bounded supervision facts.
CREATE TABLE IF NOT EXISTS node_worker_launches (
launch_id TEXT NOT NULL PRIMARY KEY
CHECK (length(launch_id) BETWEEN 1 AND 256 AND instr(launch_id, char(0)) = 0),
plan_hash TEXT NOT NULL
CHECK (length(plan_hash) = 64 AND plan_hash NOT GLOB '*[^0-9a-f]*'),
gateway_namespace TEXT NOT NULL
CHECK (
length(gateway_namespace) BETWEEN 1 AND 128
AND gateway_namespace NOT GLOB '*[^A-Za-z0-9._-]*'
AND gateway_namespace GLOB '[A-Za-z0-9]*'
),
environment_id TEXT NOT NULL
CHECK (length(environment_id) BETWEEN 1 AND 256 AND instr(environment_id, char(0)) = 0),
session_id TEXT NOT NULL
CHECK (length(session_id) BETWEEN 1 AND 256 AND instr(session_id, char(0)) = 0),
owner_epoch INTEGER NOT NULL CHECK (owner_epoch BETWEEN 1 AND 9007199254740991),
placement_generation INTEGER NOT NULL
CHECK (placement_generation BETWEEN 0 AND 9007199254740991),
run_id TEXT NOT NULL
CHECK (length(run_id) BETWEEN 1 AND 256 AND instr(run_id, char(0)) = 0),
state TEXT NOT NULL
CHECK (state IN ('pending', 'running', 'completed', 'failed', 'interrupted', 'cancelled')),
supervisor_pid INTEGER NOT NULL CHECK (supervisor_pid BETWEEN 1 AND 2147483647),
supervisor_start_time INTEGER NOT NULL
CHECK (supervisor_start_time BETWEEN 0 AND 9007199254740991),
worker_pid INTEGER CHECK (worker_pid IS NULL OR worker_pid BETWEEN 1 AND 2147483647),
worker_start_time INTEGER CHECK (
worker_start_time IS NULL OR worker_start_time BETWEEN 0 AND 9007199254740991
),
result_json TEXT CHECK (
result_json IS NULL
OR (
length(CAST(result_json AS BLOB)) BETWEEN 1 AND 65536
AND instr(result_json, char(0)) = 0
AND json_valid(result_json)
)
),
error_text TEXT CHECK (
error_text IS NULL
OR (
length(CAST(error_text AS BLOB)) BETWEEN 1 AND 4096
AND instr(error_text, char(0)) = 0
AND instr(error_text, char(10)) = 0
AND instr(error_text, char(13)) = 0
)
),
completed_at_ms INTEGER CHECK (
completed_at_ms IS NULL OR completed_at_ms BETWEEN 0 AND 9007199254740991
),
created_at_ms INTEGER NOT NULL CHECK (created_at_ms BETWEEN 0 AND 9007199254740991),
updated_at_ms INTEGER NOT NULL CHECK (
updated_at_ms BETWEEN created_at_ms AND 9007199254740991
),
CHECK ((worker_pid IS NULL) = (worker_start_time IS NULL)),
CHECK (
(state = 'pending'
AND worker_pid IS NULL AND result_json IS NULL AND error_text IS NULL
AND completed_at_ms IS NULL)
OR
(state = 'running'
AND worker_pid IS NOT NULL AND result_json IS NULL AND error_text IS NULL
AND completed_at_ms IS NULL)
OR
(state = 'completed'
AND result_json IS NOT NULL AND error_text IS NULL
AND completed_at_ms BETWEEN created_at_ms AND updated_at_ms)
OR
(state IN ('failed', 'interrupted', 'cancelled')
AND result_json IS NULL AND error_text IS NOT NULL
AND completed_at_ms BETWEEN created_at_ms AND updated_at_ms)
)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_node_worker_launches_terminal_completed
ON node_worker_launches(completed_at_ms, launch_id)
WHERE completed_at_ms IS NOT NULL;
CREATE TABLE IF NOT EXISTS node_worker_launch_boots (
launch_id TEXT NOT NULL PRIMARY KEY
REFERENCES node_worker_launches(launch_id) ON DELETE CASCADE,
boot_id TEXT CHECK (boot_id IS NULL OR length(boot_id) BETWEEN 1 AND 128)
) STRICT;
CREATE TABLE IF NOT EXISTS node_worker_launch_containers (
launch_id TEXT PRIMARY KEY,
container_json TEXT
) STRICT;
CREATE TABLE IF NOT EXISTS node_worker_launch_cleanup (
launch_id TEXT NOT NULL PRIMARY KEY
REFERENCES node_worker_launches(launch_id) ON DELETE CASCADE,
cleanup_mode TEXT NOT NULL CHECK (cleanup_mode IN ('process-group', 'owned-anchor')),
lineage_settled INTEGER CHECK (lineage_settled IS NULL OR lineage_settled = 1)
) STRICT;
-- Older readers retain owned-anchor custody: lineage EOF is not this certificate.
CREATE TABLE IF NOT EXISTS node_worker_launch_process_scopes (
launch_id TEXT NOT NULL PRIMARY KEY
REFERENCES node_worker_launches(launch_id) ON DELETE CASCADE,
scope_kind TEXT NOT NULL CHECK (scope_kind = 'linux-subreaper'),
descendants_reaped INTEGER CHECK (descendants_reaped IS NULL OR descendants_reaped = 1)
) STRICT;
-- Turn receipts have a shorter lifetime than their physical worker owner.
-- Keeping the launch running preserves capacity and predecessor cleanup semantics.
CREATE TABLE IF NOT EXISTS node_worker_turns (
turn_id TEXT NOT NULL PRIMARY KEY
CHECK (length(turn_id) BETWEEN 1 AND 256 AND instr(turn_id, char(0)) = 0),
owner_launch_id TEXT NOT NULL
REFERENCES node_worker_launches(launch_id) ON DELETE CASCADE,
plan_hash TEXT NOT NULL
CHECK (length(plan_hash) = 64 AND plan_hash NOT GLOB '*[^0-9a-f]*'),
run_id TEXT NOT NULL
CHECK (length(run_id) BETWEEN 1 AND 256 AND instr(run_id, char(0)) = 0),
state TEXT NOT NULL
CHECK (state IN ('running', 'completed', 'failed', 'interrupted', 'cancelled')),
result_json TEXT CHECK (
result_json IS NULL
OR (
length(CAST(result_json AS BLOB)) BETWEEN 1 AND 65536
AND instr(result_json, char(0)) = 0
AND json_valid(result_json)
)
),
error_text TEXT CHECK (
error_text IS NULL
OR (
length(CAST(error_text AS BLOB)) BETWEEN 1 AND 4096
AND instr(error_text, char(0)) = 0
AND instr(error_text, char(10)) = 0
AND instr(error_text, char(13)) = 0
)
),
completed_at_ms INTEGER CHECK (
completed_at_ms IS NULL OR completed_at_ms BETWEEN 0 AND 9007199254740991
),
created_at_ms INTEGER NOT NULL CHECK (created_at_ms BETWEEN 0 AND 9007199254740991),
updated_at_ms INTEGER NOT NULL CHECK (
updated_at_ms BETWEEN created_at_ms AND 9007199254740991
),
CHECK (
(state = 'running'
AND result_json IS NULL AND error_text IS NULL AND completed_at_ms IS NULL)
OR
(state = 'completed'
AND result_json IS NOT NULL AND error_text IS NULL
AND completed_at_ms BETWEEN created_at_ms AND updated_at_ms)
OR
(state IN ('failed', 'interrupted', 'cancelled')
AND result_json IS NULL AND error_text IS NOT NULL
AND completed_at_ms BETWEEN created_at_ms AND updated_at_ms)
)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_node_worker_turns_terminal_completed
ON node_worker_turns(completed_at_ms, turn_id)
WHERE completed_at_ms IS NOT NULL;
CREATE UNIQUE INDEX IF NOT EXISTS idx_node_worker_turns_active_owner
ON node_worker_turns(owner_launch_id)
WHERE state = 'running';
CREATE TABLE IF NOT EXISTS config_health_entries (
config_path TEXT NOT NULL PRIMARY KEY,
last_known_good_json TEXT,
last_promoted_good_json TEXT,
last_observed_suspicious_signature TEXT,
updated_at_ms INTEGER NOT NULL
) STRICT;
CREATE TABLE IF NOT EXISTS clawhub_promotion_claims (
slug TEXT NOT NULL PRIMARY KEY,
provider TEXT,
model_keys_json TEXT NOT NULL,
ends_at_ms INTEGER NOT NULL,
claimed_at_ms INTEGER NOT NULL
) STRICT;
CREATE TABLE IF NOT EXISTS official_external_plugin_catalog_snapshots (
feed_url TEXT NOT NULL PRIMARY KEY,
body TEXT NOT NULL,
status INTEGER NOT NULL,
etag TEXT,
last_modified TEXT,
checksum TEXT NOT NULL,
saved_at TEXT NOT NULL,
trust_mode TEXT,
trust_key_id TEXT,
trust_signature_count INTEGER,
trust_threshold INTEGER,
trust_verified_at TEXT,
updated_at_ms INTEGER NOT NULL
) STRICT;
CREATE INDEX IF NOT EXISTS idx_official_external_plugin_catalog_snapshots_updated
ON official_external_plugin_catalog_snapshots(updated_at_ms DESC, feed_url);
CREATE TABLE IF NOT EXISTS update_runs (
run_id TEXT PRIMARY KEY NOT NULL,
created_at_ms INTEGER NOT NULL,
updated_at_ms INTEGER NOT NULL,
trigger TEXT NOT NULL CHECK (trigger IN ('chat', 'control-ui', 'cli', 'campaign', 'mac-app', 'api')),
phase TEXT NOT NULL CHECK (phase IN ('requested', 'staging', 'validating', 'repairing', 'activating', 'restarting', 'verifying', 'finished')),
status TEXT NOT NULL CHECK (status IN ('running', 'succeeded', 'failed', 'rolled-back', 'skipped')),
reason TEXT,
origin_json TEXT NOT NULL CHECK (length(CAST(origin_json AS BLOB)) <= 16384),
target_json TEXT NOT NULL CHECK (length(CAST(target_json AS BLOB)) <= 16384),
before_json TEXT NOT NULL CHECK (length(CAST(before_json AS BLOB)) <= 16384),
after_json TEXT NOT NULL CHECK (length(CAST(after_json AS BLOB)) <= 16384),
steps_json TEXT NOT NULL CHECK (length(CAST(steps_json AS BLOB)) <= 16384),
verification_json TEXT NOT NULL CHECK (length(CAST(verification_json AS BLOB)) <= 16384),
repair_json TEXT NOT NULL CHECK (length(CAST(repair_json AS BLOB)) <= 16384),
confirmed_at_ms INTEGER,
finished_at_ms INTEGER,
downtime_ms INTEGER,
CHECK ((status = 'running' AND phase != 'finished' AND finished_at_ms IS NULL) OR
(status != 'running' AND phase = 'finished' AND finished_at_ms IS NOT NULL))
) STRICT;
CREATE INDEX IF NOT EXISTS idx_update_runs_created
ON update_runs(created_at_ms DESC, run_id);
CREATE INDEX IF NOT EXISTS idx_update_runs_active
ON update_runs(status, created_at_ms DESC, run_id);
CREATE TABLE IF NOT EXISTS gateway_restart_sentinel (
sentinel_key TEXT NOT NULL PRIMARY KEY,
version INTEGER NOT NULL,
kind TEXT NOT NULL,
status TEXT NOT NULL,
ts INTEGER NOT NULL,
session_key TEXT,
thread_id TEXT,
delivery_channel TEXT,
delivery_to TEXT,
delivery_account_id TEXT,
message TEXT,
continuation_json TEXT,
doctor_hint TEXT,
stats_json TEXT,
payload_json TEXT NOT NULL,
updated_at_ms INTEGER NOT NULL
) STRICT;
CREATE INDEX IF NOT EXISTS idx_gateway_restart_sentinel_ts
ON gateway_restart_sentinel(ts DESC, sentinel_key);
CREATE TABLE IF NOT EXISTS gateway_restart_intent (
intent_key TEXT NOT NULL PRIMARY KEY,
kind TEXT NOT NULL,
pid INTEGER NOT NULL,
created_at INTEGER NOT NULL,
reason TEXT,
force INTEGER,
wait_ms INTEGER,
updated_at_ms INTEGER NOT NULL
) STRICT;
CREATE TABLE IF NOT EXISTS gateway_restart_handoff (
handoff_key TEXT NOT NULL PRIMARY KEY,
kind TEXT NOT NULL,
version INTEGER NOT NULL,
intent_id TEXT NOT NULL,
pid INTEGER NOT NULL,
process_instance_id TEXT,
created_at INTEGER NOT NULL,
expires_at INTEGER NOT NULL,
reason TEXT,
restart_trace_started_at INTEGER,
restart_trace_last_at INTEGER,
source TEXT NOT NULL,
restart_kind TEXT NOT NULL,
supervisor_mode TEXT NOT NULL,
updated_at_ms INTEGER NOT NULL
) STRICT;
CREATE INDEX IF NOT EXISTS idx_gateway_restart_handoff_expiry
ON gateway_restart_handoff(expires_at, pid);
CREATE TABLE IF NOT EXISTS gateway_boot_lifecycle (
boot_id TEXT NOT NULL PRIMARY KEY,
pid INTEGER NOT NULL,
started_at_ms INTEGER NOT NULL,
completed_at_ms INTEGER,
outcome TEXT,
startup_reason TEXT,
reason TEXT
) STRICT;
CREATE INDEX IF NOT EXISTS idx_gateway_boot_lifecycle_started
ON gateway_boot_lifecycle(started_at_ms);
CREATE TABLE IF NOT EXISTS acp_sessions (
session_key TEXT NOT NULL PRIMARY KEY,
session_id TEXT,
backend TEXT NOT NULL,
agent TEXT NOT NULL,
runtime_session_name TEXT NOT NULL,
identity_json TEXT,
resume_agent_session_id TEXT,
resume_acpx_session_id TEXT,
mode TEXT NOT NULL,
runtime_options_json TEXT,
cwd TEXT,
state TEXT NOT NULL,
last_activity_at INTEGER NOT NULL,
last_error TEXT,
updated_at INTEGER NOT NULL
) STRICT;
CREATE INDEX IF NOT EXISTS idx_acp_sessions_state_activity
ON acp_sessions(state, last_activity_at DESC, session_key);
CREATE INDEX IF NOT EXISTS idx_acp_sessions_agent_activity
ON acp_sessions(agent, last_activity_at DESC, session_key);
CREATE INDEX IF NOT EXISTS idx_acp_sessions_resume_agent
ON acp_sessions(resume_agent_session_id);
CREATE INDEX IF NOT EXISTS idx_acp_sessions_resume_acpx
ON acp_sessions(resume_acpx_session_id);
CREATE TABLE IF NOT EXISTS acp_replay_sessions (
session_id TEXT NOT NULL PRIMARY KEY,
session_key TEXT NOT NULL,
cwd TEXT NOT NULL,
complete INTEGER NOT NULL,
created_at INTEGER NOT NULL,
updated_at INTEGER NOT NULL,
next_seq INTEGER NOT NULL,
-- Running estimate of this session's ledger footprint (row overhead plus
-- all event rows), maintained at insert/trim so budget checks never scan
-- acp_replay_events (#100622).
estimated_bytes INTEGER NOT NULL DEFAULT 0
) STRICT;
CREATE INDEX IF NOT EXISTS idx_acp_replay_sessions_key_updated
ON acp_replay_sessions(session_key, complete, updated_at DESC, session_id);
CREATE INDEX IF NOT EXISTS idx_acp_replay_sessions_updated
ON acp_replay_sessions(updated_at DESC, session_id);
CREATE TABLE IF NOT EXISTS acp_replay_events (
session_id TEXT NOT NULL,
seq INTEGER NOT NULL,
at INTEGER NOT NULL,
session_key TEXT NOT NULL,
run_id TEXT,
update_json TEXT NOT NULL,
estimated_bytes INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY (session_id, seq),
FOREIGN KEY (session_id) REFERENCES acp_replay_sessions(session_id) ON DELETE CASCADE
) STRICT;
CREATE TABLE IF NOT EXISTS agent_databases (
agent_id TEXT NOT NULL,
path TEXT NOT NULL,
schema_version INTEGER NOT NULL,
last_seen_at INTEGER NOT NULL,
size_bytes INTEGER,
PRIMARY KEY (agent_id, path)
) STRICT;
CREATE TABLE IF NOT EXISTS agent_deletion_journal (
agent_id TEXT PRIMARY KEY,
operation_id TEXT NOT NULL DEFAULT '',
phase TEXT,
agent_dir TEXT NOT NULL,
workspace_dir TEXT NOT NULL,
sessions_dir TEXT NOT NULL,
database_paths_json TEXT NOT NULL DEFAULT '[]',
cleanup_paths_json TEXT NOT NULL DEFAULT '[]',
created_at INTEGER NOT NULL,
cleanup_completed INTEGER NOT NULL DEFAULT 0,
delete_files INTEGER NOT NULL DEFAULT 1
) STRICT;
CREATE TABLE IF NOT EXISTS agent_provenance (
agent_id TEXT PRIMARY KEY,
created_via TEXT NOT NULL CHECK (created_via IN ('operator', 'agent', 'template')),
creator_agent_id TEXT,
created_at_ms INTEGER NOT NULL
) STRICT;
CREATE TABLE IF NOT EXISTS agent_database_leases (
lease_id TEXT PRIMARY KEY,
agent_id TEXT NOT NULL,
path TEXT NOT NULL,
owner_pid INTEGER NOT NULL,
owner_start_time INTEGER,
opened_at INTEGER NOT NULL,
provenance TEXT
) STRICT;
CREATE TABLE IF NOT EXISTS plugin_state_entries (
plugin_id TEXT NOT NULL,
namespace TEXT NOT NULL,
entry_key TEXT NOT NULL,
value_json TEXT NOT NULL,
created_at INTEGER NOT NULL,
expires_at INTEGER,
PRIMARY KEY (plugin_id, namespace, entry_key)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_plugin_state_expiry
ON plugin_state_entries(expires_at)
WHERE expires_at IS NOT NULL;
CREATE INDEX IF NOT EXISTS idx_plugin_state_listing
ON plugin_state_entries(plugin_id, namespace, created_at, entry_key, expires_at);
CREATE TABLE IF NOT EXISTS channel_ingress_events (
queue_name TEXT NOT NULL,
event_id TEXT NOT NULL,
channel_id TEXT NOT NULL,
account_id TEXT NOT NULL,
status TEXT NOT NULL,
lane_key TEXT,
payload_json TEXT NOT NULL,
metadata_json TEXT,
received_at INTEGER NOT NULL,
updated_at INTEGER NOT NULL,
claim_token TEXT,
claim_owner TEXT,
claimed_at INTEGER,
attempts INTEGER NOT NULL DEFAULT 0,
last_attempt_at INTEGER,
last_error TEXT,
failed_reason TEXT,
failed_at INTEGER,
completed_at INTEGER,
completed_metadata_json TEXT,
PRIMARY KEY (queue_name, event_id)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_channel_ingress_pending
ON channel_ingress_events(queue_name, status, received_at, event_id);
CREATE INDEX IF NOT EXISTS idx_channel_ingress_claims
ON channel_ingress_events(queue_name, status, claimed_at);
CREATE INDEX IF NOT EXISTS idx_channel_ingress_lane
ON channel_ingress_events(queue_name, status, lane_key);
CREATE TABLE IF NOT EXISTS plugin_blob_entries (
plugin_id TEXT NOT NULL,
namespace TEXT NOT NULL,
entry_key TEXT NOT NULL,
metadata_json TEXT NOT NULL,
blob BLOB NOT NULL,
created_at INTEGER NOT NULL,
expires_at INTEGER,
PRIMARY KEY (plugin_id, namespace, entry_key)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_plugin_blob_expiry
ON plugin_blob_entries(expires_at)
WHERE expires_at IS NOT NULL;
CREATE INDEX IF NOT EXISTS idx_plugin_blob_listing
ON plugin_blob_entries(plugin_id, namespace, created_at, entry_key);
CREATE TABLE IF NOT EXISTS skill_uploads (
upload_id TEXT NOT NULL PRIMARY KEY,
kind TEXT NOT NULL,
slug TEXT NOT NULL,
force INTEGER NOT NULL,
size_bytes INTEGER NOT NULL,
sha256 TEXT,
actual_sha256 TEXT,
received_bytes INTEGER NOT NULL,
archive_blob BLOB NOT NULL,
created_at INTEGER NOT NULL,
expires_at INTEGER NOT NULL,
committed INTEGER NOT NULL,
committed_at INTEGER,
idempotency_key_hash TEXT UNIQUE
) STRICT;
CREATE INDEX IF NOT EXISTS idx_skill_uploads_expiry
ON skill_uploads(expires_at);
CREATE INDEX IF NOT EXISTS idx_skill_uploads_idempotency
ON skill_uploads(idempotency_key_hash)
WHERE idempotency_key_hash IS NOT NULL;
CREATE TABLE IF NOT EXISTS skill_upload_chunks (
upload_id TEXT NOT NULL,
byte_offset INTEGER NOT NULL CHECK (byte_offset >= 0),
size_bytes INTEGER NOT NULL CHECK (size_bytes > 0),
chunk_blob BLOB NOT NULL,
PRIMARY KEY (upload_id, byte_offset),
FOREIGN KEY (upload_id) REFERENCES skill_uploads(upload_id) ON DELETE CASCADE,
CHECK (length(chunk_blob) = size_bytes)
) STRICT;
CREATE TABLE IF NOT EXISTS capture_sessions (
id TEXT NOT NULL PRIMARY KEY,
started_at INTEGER NOT NULL,
ended_at INTEGER,
mode TEXT NOT NULL,
source_scope TEXT NOT NULL,
source_process TEXT NOT NULL,
proxy_url TEXT
) STRICT;
CREATE TABLE IF NOT EXISTS capture_blobs (
blob_id TEXT NOT NULL PRIMARY KEY,
content_type TEXT,
encoding TEXT NOT NULL,
size_bytes INTEGER NOT NULL,
sha256 TEXT NOT NULL,
data BLOB NOT NULL,
created_at INTEGER NOT NULL
) STRICT;
CREATE TABLE IF NOT EXISTS capture_events (
id INTEGER NOT NULL PRIMARY KEY,
session_id TEXT NOT NULL,
ts INTEGER NOT NULL,
source_scope TEXT NOT NULL,
source_process TEXT NOT NULL,
protocol TEXT NOT NULL,
direction TEXT NOT NULL,
kind TEXT NOT NULL,
flow_id TEXT NOT NULL,
method TEXT,
host TEXT,
path TEXT,
status INTEGER,
close_code INTEGER,
content_type TEXT,
headers_json TEXT,
data_text TEXT,
data_blob_id TEXT,
data_sha256 TEXT,
error_text TEXT,
meta_json TEXT,
FOREIGN KEY (session_id) REFERENCES capture_sessions(id) ON DELETE CASCADE,
FOREIGN KEY (data_blob_id) REFERENCES capture_blobs(blob_id) ON DELETE SET NULL
) STRICT;
CREATE INDEX IF NOT EXISTS capture_events_session_ts_idx
ON capture_events(session_id, ts);
CREATE INDEX IF NOT EXISTS capture_events_flow_idx
ON capture_events(flow_id, ts);
CREATE TABLE IF NOT EXISTS sandbox_registry_entries (
registry_kind TEXT NOT NULL,
container_name TEXT NOT NULL,
session_key TEXT,
backend_id TEXT,
runtime_label TEXT,
image TEXT,
created_at_ms INTEGER,
last_used_at_ms INTEGER,
config_label_kind TEXT,
config_hash TEXT,
cdp_port INTEGER,
no_vnc_port INTEGER,
entry_json TEXT NOT NULL,
updated_at INTEGER NOT NULL,
PRIMARY KEY (registry_kind, container_name)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_sandbox_registry_updated
ON sandbox_registry_entries(registry_kind, updated_at DESC, container_name);
CREATE INDEX IF NOT EXISTS idx_sandbox_registry_session
ON sandbox_registry_entries(registry_kind, session_key, last_used_at_ms DESC, container_name)
WHERE session_key IS NOT NULL;
CREATE INDEX IF NOT EXISTS idx_sandbox_registry_last_used
ON sandbox_registry_entries(registry_kind, last_used_at_ms DESC, container_name)
WHERE last_used_at_ms IS NOT NULL;
CREATE TABLE IF NOT EXISTS durable_background_processes (
id TEXT NOT NULL PRIMARY KEY,
record_json TEXT NOT NULL
) STRICT;
CREATE TABLE IF NOT EXISTS sandbox_persistent_execs (
owner_key TEXT NOT NULL PRIMARY KEY,
source_identity TEXT NOT NULL,
attempt_id TEXT NOT NULL UNIQUE,
owner_json TEXT NOT NULL,
backend_id TEXT NOT NULL CHECK (backend_id = 'docker'),
backend_target_json TEXT NOT NULL,
workspace_binding_json TEXT NOT NULL,
container_id TEXT NOT NULL,
container_name TEXT NOT NULL,
container_started_at TEXT NOT NULL,
revision INTEGER NOT NULL CHECK (revision > 0),
phase TEXT NOT NULL CHECK (phase IN ('reserved', 'prepared', 'running', 'stopping', 'uncertain', 'stopped')),
receipt_json TEXT,
error TEXT,
created_at_ms INTEGER NOT NULL,
updated_at_ms INTEGER NOT NULL,
CHECK (phase NOT IN ('prepared', 'running') OR receipt_json IS NOT NULL)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_sandbox_persistent_execs_container
ON sandbox_persistent_execs(container_id, owner_key);
CREATE INDEX IF NOT EXISTS idx_sandbox_persistent_execs_container_name
ON sandbox_persistent_execs(container_name, owner_key);
CREATE INDEX IF NOT EXISTS idx_sandbox_persistent_execs_source
ON sandbox_persistent_execs(source_identity, owner_key);
CREATE TABLE IF NOT EXISTS cron_jobs (
store_key TEXT NOT NULL,
job_id TEXT NOT NULL,
declaration_key TEXT,
owner_agent_id TEXT,
name TEXT NOT NULL,
description TEXT,
enabled INTEGER NOT NULL,
agent_id TEXT,
payload_kind TEXT NOT NULL,
job_json TEXT NOT NULL,
grant_definition_revision TEXT,
grant_definition_generation INTEGER,
grant_definition_updated_at INTEGER,
state_json TEXT NOT NULL DEFAULT '{}',
runtime_updated_at_ms INTEGER,
schedule_identity TEXT,
sort_order INTEGER NOT NULL DEFAULT 0,
updated_at INTEGER NOT NULL,
PRIMARY KEY (store_key, job_id)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_cron_jobs_store_order
ON cron_jobs(store_key, sort_order ASC, updated_at ASC, job_id);
-- One owner-native receipt is also the durable execution fence. Receipts
-- survive job deletion so operators can distinguish a run from log inference.
CREATE TABLE IF NOT EXISTS cron_run_receipts (
cursor_id INTEGER NOT NULL,
receipt_id TEXT PRIMARY KEY,
store_key TEXT NOT NULL,
job_id TEXT NOT NULL,
config_revision TEXT NOT NULL,
agent_id TEXT NOT NULL,
request_run_id TEXT,
delivery_attempt_state TEXT NOT NULL DEFAULT 'unknown' CHECK (delivery_attempt_state IN ('unknown', 'not-started', 'started')),
status TEXT NOT NULL,
owner_pid INTEGER NOT NULL,
owner_start_time INTEGER,
started_at_ms INTEGER NOT NULL,
finished_at_ms INTEGER,
error_text TEXT,
CHECK (status IN ('running', 'ok', 'error', 'skipped', 'interrupted', 'superseded')),
CHECK (
(status = 'running' AND finished_at_ms IS NULL)
OR
(status != 'running' AND finished_at_ms IS NOT NULL)
)
) STRICT;
CREATE UNIQUE INDEX IF NOT EXISTS cron_run_receipts_cursor_id_idx
ON cron_run_receipts(cursor_id);
CREATE UNIQUE INDEX IF NOT EXISTS idx_cron_run_receipts_active_job
ON cron_run_receipts(store_key, job_id)
WHERE status = 'running';
CREATE INDEX IF NOT EXISTS idx_cron_run_receipts_job_history
ON cron_run_receipts(store_key, job_id, started_at_ms DESC, receipt_id DESC);
-- Retirement follows the receipt's retention without changing its released shape.
CREATE TABLE IF NOT EXISTS cron_run_trigger_state_retirements (
receipt_id TEXT PRIMARY KEY
REFERENCES cron_run_receipts(receipt_id) ON DELETE CASCADE
) STRICT;
-- Runtime-private authority is independent of job_json so downgraded writers
-- can rewrite recognized job config without erasing or silently widening it.
CREATE TABLE IF NOT EXISTS cron_job_runtime_authorities (
store_key TEXT NOT NULL,
job_id TEXT NOT NULL,
authority_json TEXT,
authority_input_fingerprint TEXT,
recovery_required INTEGER NOT NULL,
PRIMARY KEY (store_key, job_id),
FOREIGN KEY (store_key, job_id)
REFERENCES cron_jobs(store_key, job_id) ON DELETE CASCADE,
CHECK (recovery_required IN (0, 1)),
CHECK (
(recovery_required = 0 AND authority_json IS NOT NULL AND authority_input_fingerprint IS NOT NULL)
OR
(recovery_required = 1 AND authority_json IS NULL AND authority_input_fingerprint IS NULL)
)
) STRICT;
-- Scratch is separate from cron_jobs so scheduler state writes and downgraded
-- full-row replacement preserve it. New builds prune rows explicitly on job removal.
-- content NULL is a tombstone: it keeps the revision lineage monotonic across
-- unset/recreate so stale compare-and-swap writes cannot resurrect old content.
CREATE TABLE IF NOT EXISTS cron_job_scratch (
store_key TEXT NOT NULL,
job_id TEXT NOT NULL,
content TEXT,
revision INTEGER NOT NULL,
source_sha256 TEXT,
updated_at_ms INTEGER NOT NULL,
PRIMARY KEY (store_key, job_id),
CHECK (revision >= 1),
CHECK (content IS NULL OR length(CAST(content AS BLOB)) <= 262144)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_cron_job_scratch_store_updated
ON cron_job_scratch(store_key, updated_at_ms DESC, job_id);
CREATE TABLE IF NOT EXISTS delivery_queue_entries (
queue_name TEXT NOT NULL,
id TEXT NOT NULL,
status TEXT NOT NULL,
entry_kind TEXT,
session_key TEXT,
channel TEXT,
target TEXT,
account_id TEXT,
retry_count INTEGER NOT NULL DEFAULT 0,
last_attempt_at INTEGER,
last_error TEXT,
recovery_state TEXT,
platform_send_started_at INTEGER,
entry_json TEXT NOT NULL,
retention_id_prefix TEXT,
retention_max_age_ms INTEGER,
retention_max_entries INTEGER,
enqueued_at INTEGER NOT NULL,
updated_at INTEGER NOT NULL,
failed_at INTEGER,
PRIMARY KEY (queue_name, id)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_delivery_queue_pending
ON delivery_queue_entries(queue_name, status, enqueued_at, id);
CREATE INDEX IF NOT EXISTS idx_delivery_queue_failed
ON delivery_queue_entries(status, queue_name, failed_at, id);
CREATE INDEX IF NOT EXISTS idx_delivery_queue_session
ON delivery_queue_entries(queue_name, status, session_key, enqueued_at, id)
WHERE session_key IS NOT NULL;
CREATE INDEX IF NOT EXISTS idx_delivery_queue_target
ON delivery_queue_entries(queue_name, status, channel, target, enqueued_at, id)
WHERE channel IS NOT NULL AND target IS NOT NULL;
CREATE INDEX IF NOT EXISTS idx_delivery_queue_bounded_retention
ON delivery_queue_entries(queue_name, retention_id_prefix, enqueued_at DESC, id DESC)
WHERE status IN ('completed', 'failed') AND recovery_state = 'completed_bounded'
AND retention_id_prefix IS NOT NULL;
CREATE TABLE IF NOT EXISTS task_runs (
task_id TEXT NOT NULL PRIMARY KEY,
runtime TEXT NOT NULL,
task_kind TEXT,
source_id TEXT,
requester_session_key TEXT,
owner_key TEXT NOT NULL,
scope_kind TEXT NOT NULL,
child_session_key TEXT,
parent_flow_id TEXT,
parent_task_id TEXT,
agent_id TEXT,
requester_agent_id TEXT,
run_id TEXT,
execution_owner_host TEXT,
execution_owner_pid INTEGER,
execution_owner_start_identity INTEGER,
label TEXT,
task TEXT NOT NULL,
status TEXT NOT NULL,
delivery_status TEXT NOT NULL,
notify_policy TEXT NOT NULL,
created_at INTEGER NOT NULL,
started_at INTEGER,
ended_at INTEGER,
last_event_at INTEGER,
cleanup_after INTEGER,
tool_use_count INTEGER,
last_tool_name TEXT,
error TEXT,
progress_summary TEXT,
terminal_summary TEXT,
terminal_outcome TEXT,
detail_json TEXT
) STRICT;
CREATE INDEX IF NOT EXISTS idx_task_runs_runtime_run
ON task_runs(runtime, run_id, source_id, created_at, task_id);
CREATE INDEX IF NOT EXISTS idx_task_runs_cron_runtime_order
ON task_runs(runtime, created_at, task_id) WHERE runtime = 'cron';
CREATE INDEX IF NOT EXISTS idx_task_runs_cron_source_order
ON task_runs(source_id, created_at, task_id) WHERE runtime = 'cron';
CREATE TABLE IF NOT EXISTS subagent_runs (
run_id TEXT NOT NULL PRIMARY KEY,
child_session_key TEXT NOT NULL,
controller_session_key TEXT,
controller_store_path TEXT,
requester_session_key TEXT NOT NULL,
requester_store_path TEXT,
created_at INTEGER NOT NULL,
payload_json TEXT NOT NULL DEFAULT '{}'
) STRICT;
CREATE INDEX IF NOT EXISTS idx_subagent_runs_child_session_key
ON subagent_runs(child_session_key, created_at DESC, run_id);
CREATE INDEX IF NOT EXISTS idx_subagent_runs_requester_session_key
ON subagent_runs(requester_session_key, created_at DESC, run_id);
CREATE INDEX IF NOT EXISTS idx_subagent_runs_controller_session_key
ON subagent_runs(controller_session_key, created_at DESC, run_id);
CREATE TABLE IF NOT EXISTS current_conversation_bindings (
binding_key TEXT NOT NULL PRIMARY KEY,
binding_id TEXT NOT NULL,
target_session_key TEXT NOT NULL,
channel TEXT NOT NULL,
account_id TEXT NOT NULL,
conversation_kind TEXT NOT NULL,
parent_conversation_id TEXT,
conversation_id TEXT NOT NULL,
target_kind TEXT NOT NULL,
status TEXT NOT NULL,
bound_at INTEGER NOT NULL,
expires_at INTEGER,
metadata_json TEXT,
record_json TEXT NOT NULL,
updated_at INTEGER NOT NULL
) STRICT;
CREATE INDEX IF NOT EXISTS idx_current_conversation_bindings_target
ON current_conversation_bindings(target_session_key, updated_at DESC, binding_key);
CREATE INDEX IF NOT EXISTS idx_current_conversation_bindings_conversation
ON current_conversation_bindings(channel, account_id, conversation_kind, conversation_id);
CREATE INDEX IF NOT EXISTS idx_current_conversation_bindings_expires
ON current_conversation_bindings(expires_at, binding_key);
CREATE TABLE IF NOT EXISTS plugin_binding_approvals (
plugin_root TEXT NOT NULL,
channel TEXT NOT NULL,
account_id TEXT NOT NULL,
plugin_id TEXT NOT NULL,
plugin_name TEXT,
approved_at INTEGER NOT NULL,
PRIMARY KEY (plugin_root, channel, account_id)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_plugin_binding_approvals_plugin
ON plugin_binding_approvals(plugin_id, approved_at DESC);
CREATE TABLE IF NOT EXISTS task_delivery_state (
task_id TEXT NOT NULL PRIMARY KEY,
requester_origin_json TEXT,
last_notified_event_at INTEGER,
FOREIGN KEY (task_id) REFERENCES task_runs(task_id) ON DELETE CASCADE
) STRICT;
CREATE TABLE IF NOT EXISTS flow_runs (
flow_id TEXT NOT NULL PRIMARY KEY,
shape TEXT,
sync_mode TEXT NOT NULL DEFAULT 'managed',
owner_key TEXT NOT NULL,
requester_origin_json TEXT,
controller_id TEXT,
revision INTEGER NOT NULL DEFAULT 0,
status TEXT NOT NULL,
notify_policy TEXT NOT NULL,
goal TEXT NOT NULL,
current_step TEXT,
blocked_task_id TEXT,
blocked_summary TEXT,
state_json TEXT,
wait_json TEXT,
cancel_requested_at INTEGER,
created_at INTEGER NOT NULL,
updated_at INTEGER NOT NULL,
ended_at INTEGER
) STRICT;
CREATE INDEX IF NOT EXISTS idx_flow_runs_status ON flow_runs(status);
CREATE INDEX IF NOT EXISTS idx_flow_runs_owner_key ON flow_runs(owner_key);
CREATE INDEX IF NOT EXISTS idx_flow_runs_updated_at ON flow_runs(updated_at);
-- Durable meeting-capture sessions are gateway-global rather than agent-session
-- transcripts. JSON/JSONL files are doctor import inputs or explicit CLI exports.
CREATE TABLE IF NOT EXISTS meeting_transcript_sessions (
started_at_ms INTEGER,
session_id TEXT NOT NULL,
started_at TEXT NOT NULL,
selector TEXT NOT NULL UNIQUE,
export_key TEXT NOT NULL,
session_slug TEXT NOT NULL,
provider_id TEXT NOT NULL,
title TEXT,
source_json TEXT NOT NULL,
source_account_id TEXT,
source_guild_id TEXT,
source_channel_id TEXT,
source_meeting_url TEXT,
source_thread_ts TEXT,
source_file_id TEXT,
stopped_at TEXT,
metadata_json TEXT,
metadata_agent_id TEXT,
export_manifest_json TEXT NOT NULL DEFAULT '{}',
export_pending_json TEXT NOT NULL DEFAULT '[]',
next_utterance_seq INTEGER NOT NULL DEFAULT 0 CHECK (next_utterance_seq >= 0),
created_at_ms INTEGER NOT NULL CHECK (created_at_ms >= 0),
updated_at_ms INTEGER NOT NULL CHECK (updated_at_ms >= 0),
PRIMARY KEY (session_id, started_at)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_meeting_transcript_sessions_started
ON meeting_transcript_sessions(started_at DESC, session_id);
CREATE INDEX IF NOT EXISTS idx_meeting_transcript_sessions_chronology
ON meeting_transcript_sessions(started_at_ms DESC, session_id ASC, started_at ASC);
CREATE INDEX IF NOT EXISTS idx_meeting_transcript_sessions_id
ON meeting_transcript_sessions(session_id, started_at DESC);
CREATE INDEX IF NOT EXISTS idx_meeting_transcript_sessions_slug
ON meeting_transcript_sessions(session_slug, started_at DESC);
CREATE INDEX IF NOT EXISTS idx_meeting_transcript_sessions_export_key
ON meeting_transcript_sessions(export_key);
CREATE INDEX IF NOT EXISTS idx_meeting_transcript_sessions_source
ON meeting_transcript_sessions(provider_id, source_account_id, source_guild_id,
source_channel_id, source_meeting_url, source_thread_ts, source_file_id,
stopped_at DESC, started_at DESC, session_id);
CREATE INDEX IF NOT EXISTS idx_meeting_transcript_sessions_account
ON meeting_transcript_sessions(source_account_id);
CREATE INDEX IF NOT EXISTS idx_meeting_transcript_sessions_agent
ON meeting_transcript_sessions(metadata_agent_id);
CREATE TABLE IF NOT EXISTS meeting_transcript_utterances (
session_id TEXT NOT NULL,
session_started_at TEXT NOT NULL,
sequence INTEGER NOT NULL CHECK (sequence >= 0),
utterance_id TEXT,
started_at TEXT,
ended_at TEXT,
speaker_id TEXT,
speaker_label TEXT,
text TEXT NOT NULL,
final INTEGER CHECK (final IN (0, 1)),
metadata_json TEXT,
PRIMARY KEY (session_id, session_started_at, sequence),
FOREIGN KEY (session_id, session_started_at)
REFERENCES meeting_transcript_sessions(session_id, started_at)
ON DELETE CASCADE
) STRICT;
CREATE INDEX IF NOT EXISTS idx_meeting_transcript_utterances_id
ON meeting_transcript_utterances(session_id, session_started_at, utterance_id)
WHERE utterance_id IS NOT NULL;
CREATE TABLE IF NOT EXISTS meeting_transcript_summaries (
session_id TEXT NOT NULL,
session_started_at TEXT NOT NULL,
generated_at TEXT,
summary_json TEXT,
overview TEXT,
markdown TEXT,
utterance_count INTEGER NOT NULL CHECK (utterance_count >= 0),
PRIMARY KEY (session_id, session_started_at),
FOREIGN KEY (session_id, session_started_at)
REFERENCES meeting_transcript_sessions(session_id, started_at)
ON DELETE CASCADE,
CHECK (summary_json IS NOT NULL OR markdown IS NOT NULL)
) STRICT;
CREATE TABLE IF NOT EXISTS migration_runs (
id TEXT NOT NULL PRIMARY KEY,
started_at INTEGER NOT NULL,
finished_at INTEGER,
status TEXT NOT NULL,
report_json TEXT NOT NULL
) STRICT;
CREATE INDEX IF NOT EXISTS idx_migration_runs_started
ON migration_runs(started_at DESC, id);
CREATE TABLE IF NOT EXISTS migration_sources (
source_key TEXT NOT NULL PRIMARY KEY,
migration_kind TEXT NOT NULL,
source_path TEXT NOT NULL,
target_table TEXT NOT NULL,
source_sha256 TEXT,
source_size_bytes INTEGER,
source_record_count INTEGER,
last_run_id TEXT NOT NULL,
status TEXT NOT NULL,
imported_at INTEGER NOT NULL,
removed_source INTEGER NOT NULL DEFAULT 0,
report_json TEXT NOT NULL,
FOREIGN KEY (last_run_id) REFERENCES migration_runs(id) ON DELETE CASCADE
) STRICT;
CREATE INDEX IF NOT EXISTS idx_migration_sources_path
ON migration_sources(source_path, migration_kind, target_table);
CREATE INDEX IF NOT EXISTS idx_migration_sources_run
ON migration_sources(last_run_id, source_path);
CREATE TABLE IF NOT EXISTS backup_runs (
id TEXT NOT NULL PRIMARY KEY,
created_at INTEGER NOT NULL,
archive_path TEXT NOT NULL,
status TEXT NOT NULL,
manifest_json TEXT NOT NULL
) STRICT;
CREATE INDEX IF NOT EXISTS idx_backup_runs_created
ON backup_runs(created_at DESC, id);
CREATE TABLE IF NOT EXISTS worktrees (
id TEXT NOT NULL PRIMARY KEY,
repo_fingerprint TEXT NOT NULL,
repo_root TEXT NOT NULL,
path TEXT NOT NULL,
branch TEXT NOT NULL,
base_ref TEXT NOT NULL,
owner_kind TEXT NOT NULL CHECK (owner_kind IN ('manual', 'workboard', 'session')),
owner_id TEXT,
snapshot_ref TEXT,
provisioned_paths_json TEXT,
created_at INTEGER NOT NULL,
last_active_at INTEGER NOT NULL,
removed_at INTEGER,
run_end_cleanup_json TEXT,
gc_protection_json TEXT
) STRICT;
CREATE INDEX IF NOT EXISTS idx_worktrees_repo_fingerprint
ON worktrees(repo_fingerprint);
CREATE INDEX IF NOT EXISTS idx_worktrees_removed_at
ON worktrees(removed_at);
CREATE TABLE IF NOT EXISTS worktree_provisioned_file_chunks (
worktree_id TEXT NOT NULL,
path TEXT NOT NULL,
chunk_index INTEGER NOT NULL CHECK (chunk_index >= 0),
data BLOB NOT NULL,
PRIMARY KEY (worktree_id, path, chunk_index)
) STRICT;
CREATE TABLE IF NOT EXISTS worktree_templates (
cache_key TEXT NOT NULL PRIMARY KEY,
id TEXT NOT NULL UNIQUE,
repo_root TEXT NOT NULL,
common_dir TEXT NOT NULL,
worktree_root TEXT NOT NULL,
path TEXT NOT NULL,
backend TEXT NOT NULL,
source_commit TEXT NOT NULL,
content_key TEXT NOT NULL,
status TEXT NOT NULL CHECK (status IN ('preparing', 'ready')),
created_at INTEGER NOT NULL,
last_used_at INTEGER NOT NULL
) STRICT;
CREATE TABLE IF NOT EXISTS projects (
id TEXT NOT NULL PRIMARY KEY,
display_name TEXT NOT NULL,
repo_root TEXT NOT NULL,
origin_url TEXT,
source TEXT NOT NULL CHECK (source IN ('registered', 'cloned')),
created_at_ms INT NOT NULL,
updated_at_ms INT NOT NULL
) STRICT;
-- One explicitly retained, normalized private background per durable profile.
CREATE TABLE IF NOT EXISTS user_background_images (
profile_id TEXT NOT NULL PRIMARY KEY REFERENCES user_profiles(id) ON DELETE CASCADE,
asset_id TEXT NOT NULL UNIQUE,
image BLOB NOT NULL CHECK (length(image) BETWEEN 1 AND 2097152),
width INTEGER NOT NULL CHECK (width BETWEEN 1 AND 2560),
height INTEGER NOT NULL CHECK (height BETWEEN 1 AND 2560)
) STRICT;
CREATE TABLE IF NOT EXISTS user_preferences (
profile_id TEXT NOT NULL,
pref_key TEXT NOT NULL,
value_json TEXT NOT NULL,
updated_at_ms INT NOT NULL,
PRIMARY KEY (profile_id, pref_key)
) STRICT;
-- Gateway-owned custom session group catalog (names + display order).
-- Membership stays on each session entry's category field; this table only
-- owns which groups exist and how operator UIs order them.
CREATE TABLE IF NOT EXISTS session_groups (
name TEXT NOT NULL PRIMARY KEY,
position INTEGER NOT NULL,
created_at INTEGER NOT NULL,
cwd TEXT,
worktree INTEGER
) STRICT;
-- Gateway-owned durable cloud worker lifecycle. Provider-specific execution
-- stays in plugins; this table records only core reconciliation facts.
CREATE TABLE IF NOT EXISTS worker_environments (
environment_id TEXT NOT NULL PRIMARY KEY,
provider_id TEXT NOT NULL,
profile_id TEXT NOT NULL,
profile_snapshot_json TEXT NOT NULL,
last_activated_at_ms INTEGER,
preparation_key TEXT,
preparation_purpose TEXT,
preparation_demand_at_ms INTEGER,
preparation_expires_at_ms INTEGER,
preparation_consumed_at_ms INTEGER CHECK (
(preparation_key IS NULL AND preparation_demand_at_ms IS NULL
AND preparation_expires_at_ms IS NULL AND preparation_consumed_at_ms IS NULL)
OR
(preparation_key IS NOT NULL AND length(preparation_key) = 64
AND preparation_key NOT GLOB '*[^0-9a-f]*'
AND preparation_demand_at_ms IS NOT NULL
AND preparation_demand_at_ms BETWEEN 0 AND 9007199254740991
AND preparation_expires_at_ms IS NOT NULL
AND preparation_expires_at_ms > preparation_demand_at_ms
AND preparation_expires_at_ms <= 9007199254740991
AND (preparation_consumed_at_ms IS NULL
OR (preparation_consumed_at_ms >= preparation_demand_at_ms
AND preparation_consumed_at_ms < preparation_expires_at_ms)))
),
provision_operation_id TEXT NOT NULL UNIQUE,
lease_id TEXT,
node_setup_id TEXT,
node_device_id TEXT,
ssh_host TEXT,
ssh_port INTEGER CHECK (ssh_port IS NULL OR (ssh_port >= 1 AND ssh_port <= 65535)),
ssh_user TEXT,
ssh_host_key TEXT,
ssh_key_ref_json TEXT,
desktop_json TEXT,
state TEXT NOT NULL CHECK (
state IN (
'requested',
'provisioning',
'bootstrapping',
'ready',
'attached',
'idle',
'draining',
'destroying',
'destroyed',
'failed',
'orphaned'
)
),
bootstrap_bundle_hash TEXT,
bootstrap_openclaw_version TEXT,
bootstrap_protocol_features_json TEXT,
bootstrap_install_kind TEXT,
owner_epoch INTEGER NOT NULL DEFAULT 0 CHECK (owner_epoch >= 0),
teardown_terminal_state TEXT CHECK (teardown_terminal_state IN ('destroyed', 'failed')),
attached_session_ids_json TEXT NOT NULL DEFAULT '[]',
created_at_ms INTEGER NOT NULL,
updated_at_ms INTEGER NOT NULL,
state_changed_at_ms INTEGER NOT NULL,
idle_since_at_ms INTEGER,
destroy_requested_at_ms INTEGER,
last_error TEXT,
shared_host INTEGER,
resource_receipt_json TEXT,
retention_json TEXT,
provision_source_json TEXT
) STRICT;
CREATE UNIQUE INDEX IF NOT EXISTS idx_worker_environments_provider_lease
ON worker_environments(provider_id, lease_id)
WHERE lease_id IS NOT NULL;
CREATE INDEX IF NOT EXISTS idx_worker_environments_terminal_changed
ON worker_environments(state_changed_at_ms, environment_id);
-- A dedicated node registers its fixed build paths before ready, then binds
-- them once. The environment belongs to the Gateway's separate database.
CREATE TABLE IF NOT EXISTS node_worker_prepared_workspaces (
preparation_key TEXT NOT NULL PRIMARY KEY CHECK (
length(preparation_key) = 64 AND preparation_key NOT GLOB '*[^0-9a-f]*'
),
cache_key TEXT NOT NULL CHECK (
length(cache_key) = 64 AND cache_key NOT GLOB '*[^0-9a-f]*'
),
gateway_namespace TEXT NOT NULL CHECK (length(gateway_namespace) > 0),
workspace_dir TEXT NOT NULL UNIQUE CHECK (length(workspace_dir) > 0),
home_dir TEXT NOT NULL CHECK (length(home_dir) > 0),
source_manifest_ref TEXT NOT NULL CHECK (
length(source_manifest_ref) = 71 AND substr(source_manifest_ref, 1, 7) = 'sha256:'
AND substr(source_manifest_ref, 8) NOT GLOB '*[^0-9a-f]*'
),
prepared_manifest_ref TEXT NOT NULL CHECK (
length(prepared_manifest_ref) = 71 AND substr(prepared_manifest_ref, 1, 7) = 'sha256:'
AND substr(prepared_manifest_ref, 8) NOT GLOB '*[^0-9a-f]*'
),
state TEXT NOT NULL CHECK (state IN ('available', 'bound', 'retiring', 'retired')),
environment_id TEXT NOT NULL CHECK (length(environment_id) > 0),
session_id TEXT,
session_key TEXT,
owner_epoch INTEGER CHECK (owner_epoch BETWEEN 1 AND 9007199254740991),
created_at_ms INTEGER NOT NULL CHECK (created_at_ms BETWEEN 0 AND 9007199254740991),
bound_at_ms INTEGER CHECK (bound_at_ms BETWEEN created_at_ms AND 9007199254740991),
retired_at_ms INTEGER CHECK (
retired_at_ms BETWEEN coalesce(bound_at_ms, created_at_ms) AND 9007199254740991
),
CHECK (
(session_id IS NULL AND session_key IS NULL AND owner_epoch IS NULL AND bound_at_ms IS NULL)
OR
(session_id IS NOT NULL AND length(session_id) > 0
AND session_key IS NOT NULL AND length(session_key) > 0
AND owner_epoch IS NOT NULL AND bound_at_ms IS NOT NULL)
),
CHECK (
(state = 'available' AND bound_at_ms IS NULL AND retired_at_ms IS NULL)
OR (state = 'bound' AND bound_at_ms IS NOT NULL AND retired_at_ms IS NULL)
OR (state = 'retiring' AND retired_at_ms IS NULL)
OR (state = 'retired' AND retired_at_ms IS NOT NULL)
)
) STRICT;
-- Provider-advertised fallback ports preserve stable retry order separately
-- from the downgrade-sensitive canonical worker environment row.
CREATE TABLE IF NOT EXISTS worker_environment_ssh_fallback_ports (
environment_id TEXT NOT NULL,
position INTEGER NOT NULL CHECK (position >= 0 AND position <= 9),
port INTEGER NOT NULL CHECK (port >= 1 AND port <= 65535),
PRIMARY KEY (environment_id, position),
UNIQUE (environment_id, port),
FOREIGN KEY (environment_id) REFERENCES worker_environments(environment_id) ON DELETE CASCADE
) STRICT;
-- Logical sessions own repository intent and accepted artifact references,
-- independently of the worker or rotating transcript session id.
CREATE TABLE IF NOT EXISTS session_repository_workspaces (
workspace_id TEXT NOT NULL PRIMARY KEY CHECK (length(workspace_id) = 36),
agent_id TEXT NOT NULL CHECK (length(agent_id) BETWEEN 1 AND 128),
session_key TEXT NOT NULL CHECK (length(session_key) BETWEEN 1 AND 1024),
url TEXT NOT NULL CHECK (length(url) BETWEEN 1 AND 4096),
requested_ref TEXT CHECK (requested_ref IS NULL OR length(requested_ref) BETWEEN 1 AND 1024),
run_setup_script INTEGER NOT NULL DEFAULT 0 CHECK (run_setup_script IN (0, 1)),
base_commit TEXT CHECK (base_commit IS NULL OR length(base_commit) IN (40, 64)),
base_manifest_hash TEXT,
branch TEXT NOT NULL CHECK (length(branch) BETWEEN 1 AND 256),
checkpoint_ref TEXT,
manifest_hash TEXT,
revision INTEGER NOT NULL CHECK (revision >= 0),
created_at_ms INTEGER NOT NULL,
updated_at_ms INTEGER NOT NULL,
disk_authority_json TEXT,
UNIQUE (agent_id, session_key),
CHECK (base_manifest_hash IS NULL OR base_commit IS NOT NULL),
CHECK ((checkpoint_ref IS NULL AND manifest_hash IS NULL)
OR (checkpoint_ref IS NOT NULL AND manifest_hash IS NOT NULL AND base_manifest_hash IS NOT NULL))
) STRICT;
CREATE TABLE IF NOT EXISTS github_repository_publication_requests (
request_id TEXT NOT NULL PRIMARY KEY,
owner_profile_id TEXT,
connection_generation TEXT,
idempotency_key TEXT NOT NULL,
request_digest TEXT NOT NULL,
session_id TEXT NOT NULL,
session_lifecycle_revision TEXT,
requester_authority_json TEXT,
session_key TEXT NOT NULL,
agent_id TEXT NOT NULL,
workspace_id TEXT NOT NULL,
checkpoint_ref TEXT,
checkpoint_digest TEXT,
claim_id TEXT,
run_id TEXT,
environment_id TEXT,
owner_epoch INTEGER,
placement_generation INTEGER,
identity_source TEXT NOT NULL CHECK (identity_source IN ('system-detected', 'system-configured', 'agent-override', 'personal')),
identity_profile_id TEXT,
identity_account_id INTEGER NOT NULL,
identity_login TEXT NOT NULL,
title TEXT,
body TEXT,
status TEXT NOT NULL CHECK (status IN ('requested', 'publishing', 'needs_confirmation', 'published', 'failed')),
gateway_instance_id TEXT,
execution_id TEXT,
last_effect TEXT CHECK (last_effect IN ('push', 'pull_request')),
effect_state TEXT CHECK (effect_state IN ('dispatched', 'observed')),
push_repository TEXT,
repository TEXT,
branch TEXT NOT NULL,
base_branch TEXT,
source_head_commit TEXT,
source_index_tree TEXT,
workspace_tree TEXT,
previous_head_commit TEXT,
pushed_head_commit TEXT,
head_commit TEXT,
pull_request_url TEXT,
error_code TEXT,
next_action TEXT,
created_at_ms INTEGER NOT NULL,
updated_at_ms INTEGER NOT NULL,
reported_at_ms INTEGER,
draft INTEGER,
CHECK ((identity_source = 'personal' AND owner_profile_id IS NOT NULL AND connection_generation IS NOT NULL)
OR (identity_source <> 'personal' AND owner_profile_id IS NULL AND connection_generation IS NULL)),
CHECK ((checkpoint_ref IS NULL AND checkpoint_digest IS NULL) OR (checkpoint_ref IS NOT NULL AND checkpoint_digest IS NOT NULL)),
CHECK ((last_effect IS NULL AND effect_state IS NULL) OR (last_effect IS NOT NULL AND effect_state IS NOT NULL))
) STRICT;
CREATE UNIQUE INDEX IF NOT EXISTS idx_github_repository_publication_shared_request
ON github_repository_publication_requests(session_id, idempotency_key) WHERE owner_profile_id IS NULL;
CREATE UNIQUE INDEX IF NOT EXISTS idx_github_repository_publication_personal_request
ON github_repository_publication_requests(owner_profile_id, session_id, idempotency_key) WHERE owner_profile_id IS NOT NULL;
-- Session placement lives in the shared state database so local admission,
-- worker admission, and environment attachment use one durable authority.
CREATE TABLE IF NOT EXISTS worker_session_placements (
session_id TEXT NOT NULL PRIMARY KEY,
agent_id TEXT NOT NULL,
session_key TEXT NOT NULL,
execution_mode TEXT CHECK (execution_mode IN ('worker-turn', 'remote-exec')),
state TEXT NOT NULL CHECK (
state IN (
'local',
'requested',
'provisioning',
'syncing',
'starting',
'active',
'draining',
'reconciling',
'reclaimed',
'failed'
)
),
environment_id TEXT,
transition_generation INTEGER NOT NULL DEFAULT 0 CHECK (transition_generation >= 0),
active_owner_epoch INTEGER CHECK (active_owner_epoch IS NULL OR active_owner_epoch >= 1),
workspace_base_manifest_ref TEXT,
remote_workspace_dir TEXT,
worker_bundle_hash TEXT,
last_transcript_ack_cursor INTEGER CHECK (
last_transcript_ack_cursor IS NULL OR last_transcript_ack_cursor >= 0
),
last_live_event_ack_cursor INTEGER CHECK (
last_live_event_ack_cursor IS NULL OR last_live_event_ack_cursor >= 0
),
recovery_error TEXT,
turn_claim_owner TEXT CHECK (turn_claim_owner IN ('local', 'worker')),
turn_claim_id TEXT,
turn_claim_run_id TEXT,
turn_claim_generation INTEGER CHECK (
turn_claim_generation IS NULL OR turn_claim_generation >= 0
),
turn_claim_owner_epoch INTEGER CHECK (
turn_claim_owner_epoch IS NULL OR turn_claim_owner_epoch >= 1
),
created_at_ms INTEGER NOT NULL,
updated_at_ms INTEGER NOT NULL,
state_changed_at_ms INTEGER NOT NULL,
terminal_reason TEXT,
terminal_at_ms INTEGER,
CHECK (
(state IN ('local', 'requested')
AND environment_id IS NULL AND active_owner_epoch IS NULL
AND workspace_base_manifest_ref IS NULL AND remote_workspace_dir IS NULL
AND worker_bundle_hash IS NULL
AND last_transcript_ack_cursor IS NULL AND last_live_event_ack_cursor IS NULL
AND recovery_error IS NULL)
OR
(state IS 'provisioning'
AND active_owner_epoch IS NULL
AND workspace_base_manifest_ref IS NULL AND remote_workspace_dir IS NULL
AND worker_bundle_hash IS NULL
AND last_transcript_ack_cursor IS NULL AND last_live_event_ack_cursor IS NULL
AND recovery_error IS NULL)
OR
(state IS 'syncing'
AND environment_id IS NOT NULL AND active_owner_epoch IS NULL
AND workspace_base_manifest_ref IS NULL AND remote_workspace_dir IS NULL
AND worker_bundle_hash IS NOT NULL
AND last_transcript_ack_cursor IS NULL AND last_live_event_ack_cursor IS NULL
AND recovery_error IS NULL)
OR
(state IS 'starting'
AND environment_id IS NOT NULL AND active_owner_epoch IS NULL
AND workspace_base_manifest_ref IS NOT NULL AND remote_workspace_dir IS NOT NULL
AND worker_bundle_hash IS NOT NULL
AND last_transcript_ack_cursor IS NULL AND last_live_event_ack_cursor IS NULL
AND recovery_error IS NULL)
OR
(state IN ('active', 'draining', 'reconciling')
AND environment_id IS NOT NULL AND active_owner_epoch IS NOT NULL
AND workspace_base_manifest_ref IS NOT NULL AND remote_workspace_dir IS NOT NULL
AND worker_bundle_hash IS NOT NULL AND recovery_error IS NULL)
OR
(state IS 'reclaimed'
AND environment_id IS NOT NULL AND active_owner_epoch IS NOT NULL
AND workspace_base_manifest_ref IS NOT NULL AND remote_workspace_dir IS NOT NULL
AND worker_bundle_hash IS NOT NULL AND recovery_error IS NULL
AND turn_claim_owner IS NULL AND turn_claim_id IS NULL AND turn_claim_run_id IS NULL
AND turn_claim_generation IS NULL AND turn_claim_owner_epoch IS NULL)
OR
(state IS 'failed' AND recovery_error IS NOT NULL)
),
CHECK (
(turn_claim_owner IS NULL AND turn_claim_id IS NULL AND turn_claim_run_id IS NULL
AND turn_claim_generation IS NULL AND turn_claim_owner_epoch IS NULL)
OR
(turn_claim_owner IS 'local' AND turn_claim_id IS NOT NULL
AND turn_claim_run_id IS NOT NULL AND turn_claim_generation IS NOT NULL
AND turn_claim_owner_epoch IS NULL)
OR
(turn_claim_owner IS 'worker' AND turn_claim_id IS NOT NULL
AND turn_claim_run_id IS NOT NULL AND turn_claim_generation IS NOT NULL
AND turn_claim_owner_epoch IS NOT NULL)
),
CHECK (
turn_claim_owner IS NULL
OR
(turn_claim_owner IS 'local' AND (
state IN ('local', 'requested', 'failed')
OR (state IN ('active', 'draining') AND execution_mode IS 'remote-exec')
))
OR
(turn_claim_owner IS 'worker' AND state IN ('active', 'draining')
AND (execution_mode IS NULL OR execution_mode IS 'worker-turn')
AND turn_claim_owner_epoch IS active_owner_epoch)
)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_worker_session_placements_session_key
ON worker_session_placements(agent_id, session_key);
CREATE INDEX IF NOT EXISTS idx_worker_session_placements_reconcile
ON worker_session_placements(updated_at_ms, session_id);
CREATE INDEX IF NOT EXISTS idx_worker_session_placements_environment
ON worker_session_placements(environment_id)
WHERE environment_id IS NOT NULL;
-- Planned placement moves retain their exact source CAS and bounded target
-- without widening the stable placement-state vocabulary. The opaque operation
-- id fences stale asynchronous completion; it is correlation, never authority.
CREATE TABLE IF NOT EXISTS worker_session_placement_moves (
operation_id TEXT NOT NULL PRIMARY KEY,
session_id TEXT NOT NULL UNIQUE
REFERENCES worker_session_placements(session_id) ON DELETE CASCADE,
source_generation INTEGER NOT NULL CHECK (source_generation >= 0),
source_environment_id TEXT NOT NULL CHECK (
length(source_environment_id) BETWEEN 1 AND 256
AND source_environment_id = trim(source_environment_id)
),
source_owner_epoch INTEGER NOT NULL CHECK (source_owner_epoch >= 1),
target_kind TEXT NOT NULL CHECK (target_kind IN ('gateway', 'profile', 'device')),
target_id TEXT,
-- Keep these nullable columns constraint-free so lazy ALTER TABLE produces the
-- same shape as fresh databases; placement-move code validates their values.
target_machine_class TEXT,
target_os TEXT,
-- Explicit source abandonment is a durable operator decision. Keep the bit
-- bare and nullable so same-version older readers can safely omit it.
abandon_source INTEGER,
last_error TEXT,
created_at_ms INTEGER NOT NULL,
updated_at_ms INTEGER NOT NULL,
CHECK (
(target_kind IS 'gateway' AND target_id IS NULL)
OR
(target_kind IN ('profile', 'device')
AND target_id IS NOT NULL
AND length(target_id) BETWEEN 1 AND 256
AND target_id = trim(target_id))
)
) STRICT;
-- Worker-visible session RPC authority is persisted against the exact turn
-- claim. The launch descriptor is informative only; Gateway dispatch always
-- revalidates this record and the live placement claim before executing.
CREATE TABLE IF NOT EXISTS worker_turn_tool_authorities (
session_id TEXT NOT NULL PRIMARY KEY,
environment_id TEXT NOT NULL,
owner_epoch INTEGER NOT NULL CHECK (owner_epoch >= 1),
placement_generation INTEGER NOT NULL CHECK (placement_generation >= 0),
claim_id TEXT NOT NULL,
run_id TEXT NOT NULL,
tool_names_json TEXT NOT NULL,
updated_at_ms INTEGER NOT NULL,
FOREIGN KEY (session_id) REFERENCES worker_session_placements(session_id) ON DELETE CASCADE
) STRICT;
-- Tool-call ids are idempotency keys only within one exact source turn claim.
-- A running operation from another Gateway instance is ambiguous and is never
-- replayed. A persisted random seed separates durable downstream identities
-- from Gateway authentication keys and survives ordinary process restarts.
CREATE TABLE IF NOT EXISTS worker_session_tool_operations (
source_session_id TEXT NOT NULL,
source_claim_id TEXT NOT NULL,
tool_call_id TEXT NOT NULL,
tool_name TEXT NOT NULL CHECK (tool_name IN ('sessions_spawn', 'sessions_send')),
request_digest TEXT NOT NULL,
operation_seed TEXT NOT NULL,
status TEXT NOT NULL CHECK (status IN ('running', 'succeeded', 'failed', 'unknown')),
child_session_key TEXT,
result_json TEXT,
gateway_instance_id TEXT NOT NULL,
created_at_ms INTEGER NOT NULL,
updated_at_ms INTEGER NOT NULL,
PRIMARY KEY (source_session_id, source_claim_id, tool_call_id),
FOREIGN KEY (source_session_id)
REFERENCES worker_session_placements(session_id) ON DELETE CASCADE
) STRICT;
-- Local sandbox execution is a projection of a session-owned managed worktree.
-- No cascade: an older binary must not discard pending edits with a session row.
CREATE TABLE IF NOT EXISTS local_workspace_projections (
worktree_id TEXT NOT NULL PRIMARY KEY,
agent_id TEXT NOT NULL,
session_key TEXT NOT NULL,
session_id TEXT NOT NULL,
lifecycle_revision TEXT,
projection_path TEXT NOT NULL UNIQUE,
base_commit TEXT NOT NULL,
source_paths_json TEXT NOT NULL,
baseline_json TEXT,
baseline_ref TEXT,
pending_ref TEXT,
pending_target TEXT CHECK (pending_target IN ('canonical', 'projection')),
paused_runtimes_json TEXT,
journal_json TEXT,
journal_pack BLOB CHECK (journal_pack IS NULL OR length(journal_pack) <= 268435456),
revision INTEGER NOT NULL DEFAULT 0 CHECK (revision >= 0),
created_at_ms INTEGER NOT NULL,
checkpoint_json TEXT,
tree_root_digest BLOB,
source_paths_digest BLOB,
canonical_fingerprints BLOB,
projection_fingerprints BLOB,
CHECK (baseline_json IS NULL OR baseline_ref IS NOT NULL),
CHECK ((journal_json IS NULL) = (journal_pack IS NULL))
) STRICT;
-- The projection owner advances changed nodes and its root in one acceptance.
-- Legacy baseline_json remains only until that owner's resumable conversion.
CREATE TABLE IF NOT EXISTS local_workspace_manifest_nodes (
worktree_id TEXT NOT NULL,
path TEXT NOT NULL,
node_json TEXT NOT NULL,
PRIMARY KEY (worktree_id, path),
FOREIGN KEY (worktree_id)
REFERENCES local_workspace_projections(worktree_id) ON DELETE CASCADE
) STRICT;
-- Immutable subtrees and source inventories are shared across projections and revisions.
-- Large JSON packs measured 410k VFS reads/load WITHOUT ROWID versus 10k with rowid.
CREATE TABLE IF NOT EXISTS local_workspace_tree_packs (
tree_digest BLOB NOT NULL PRIMARY KEY CHECK (length(tree_digest) = 32),
records_json TEXT NOT NULL,
children_json TEXT NOT NULL,
sweep_epoch INTEGER NOT NULL
) STRICT;
CREATE TABLE IF NOT EXISTS local_workspace_source_path_sets (
path_digest BLOB NOT NULL PRIMARY KEY CHECK (length(path_digest) = 32),
paths_zstd BLOB NOT NULL,
sweep_epoch INTEGER NOT NULL
) STRICT, WITHOUT ROWID;
-- A reconciliation journal is written before managed-worktree mutation. The
-- bounded Git base snapshot repairs any subset left by an interrupted apply.
CREATE TABLE IF NOT EXISTS worker_workspace_reconciliations (
session_id TEXT NOT NULL PRIMARY KEY,
environment_id TEXT NOT NULL,
owner_epoch INTEGER NOT NULL CHECK (owner_epoch >= 1),
placement_generation INTEGER NOT NULL CHECK (placement_generation >= 0),
base_manifest_ref TEXT NOT NULL,
current_manifest_ref TEXT NOT NULL,
plan_json TEXT NOT NULL,
base_pack BLOB NOT NULL CHECK (length(base_pack) <= 268435456),
created_at_ms INTEGER NOT NULL,
FOREIGN KEY (session_id) REFERENCES worker_session_placements(session_id) ON DELETE CASCADE
) STRICT;
-- A completed remote turn is fenced from stale-claim teardown until its
-- workspace result is durably reconciled into the managed worktree.
CREATE TABLE IF NOT EXISTS worker_workspace_pending_results (
session_id TEXT NOT NULL PRIMARY KEY,
environment_id TEXT NOT NULL,
owner_epoch INTEGER NOT NULL CHECK (owner_epoch >= 1),
placement_generation INTEGER NOT NULL CHECK (placement_generation >= 0),
claim_id TEXT NOT NULL,
run_id TEXT NOT NULL,
gateway_instance_id TEXT NOT NULL,
recovery_requested_at_ms INTEGER,
workspace_accepted_at_ms INTEGER,
staged_result_ref TEXT,
repository_workspace_id TEXT,
created_at_ms INTEGER NOT NULL,
repository_disk_authority_json TEXT,
FOREIGN KEY (session_id) REFERENCES worker_session_placements(session_id) ON DELETE CASCADE
) STRICT;
-- GitHub publication intent records the authoritative session worktree. Cloud
-- requests execute only after the exact turn claim's result is accepted locally.
-- Secrets stay in the effective Gateway-owned GitHub profile and never enter
-- this row or the worker protocol.
CREATE TABLE IF NOT EXISTS github_publication_requests (
request_id TEXT NOT NULL PRIMARY KEY,
idempotency_key TEXT NOT NULL,
request_digest TEXT NOT NULL,
session_id TEXT NOT NULL,
session_key TEXT NOT NULL,
agent_id TEXT NOT NULL,
worktree_id TEXT NOT NULL,
repository_fingerprint TEXT NOT NULL,
claim_id TEXT,
run_id TEXT,
environment_id TEXT,
owner_epoch INTEGER CHECK (owner_epoch IS NULL OR owner_epoch >= 1),
placement_generation INTEGER CHECK (
placement_generation IS NULL OR placement_generation >= 0
),
identity_source TEXT NOT NULL CHECK (
identity_source IN ('system-detected', 'system-configured', 'agent-override')
),
identity_profile_id TEXT,
identity_account_id INTEGER NOT NULL CHECK (identity_account_id >= 1),
identity_login TEXT NOT NULL,
title TEXT,
body TEXT,
status TEXT NOT NULL CHECK (
status IN ('requested', 'publishing', 'published', 'failed')
),
gateway_instance_id TEXT,
repository TEXT,
branch TEXT NOT NULL,
base_branch TEXT,
source_head_commit TEXT,
source_index_tree TEXT,
workspace_tree TEXT,
head_commit TEXT,
pull_request_url TEXT,
error_code TEXT,
next_action TEXT,
created_at_ms INTEGER NOT NULL,
updated_at_ms INTEGER NOT NULL,
reported_at_ms INTEGER,
draft INTEGER,
UNIQUE (session_id, idempotency_key),
CHECK (
(claim_id IS NULL AND run_id IS NULL AND environment_id IS NULL
AND owner_epoch IS NULL AND placement_generation IS NULL)
OR
(claim_id IS NOT NULL AND run_id IS NOT NULL AND placement_generation IS NOT NULL
AND ((environment_id IS NULL AND owner_epoch IS NULL)
OR (environment_id IS NOT NULL AND owner_epoch IS NOT NULL)))
),
CHECK (
(identity_source IS 'system-detected' AND identity_profile_id IS NULL)
OR
(identity_source IN ('system-configured', 'agent-override')
AND identity_profile_id IS NOT NULL)
),
CHECK (
(source_head_commit IS NULL AND source_index_tree IS NULL AND workspace_tree IS NULL)
OR
(source_head_commit IS NOT NULL AND workspace_tree IS NOT NULL)
),
CHECK (
(status IS 'published' AND pull_request_url IS NOT NULL AND error_code IS NULL
AND next_action IS NULL)
OR
(status IS 'failed' AND pull_request_url IS NULL AND error_code IS NOT NULL
AND next_action IS NOT NULL)
OR
(status IN ('requested', 'publishing') AND pull_request_url IS NULL
AND error_code IS NULL AND next_action IS NULL)
)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_github_publication_requests_pending
ON github_publication_requests(status, updated_at_ms, request_id);
-- Personal requests cannot be interpreted or resumed by older shared publishers.
CREATE TABLE IF NOT EXISTS github_personal_publication_requests (
request_id TEXT NOT NULL PRIMARY KEY CHECK (length(request_id) = 36),
owner_profile_id TEXT NOT NULL CHECK (length(owner_profile_id) BETWEEN 1 AND 128),
connection_generation TEXT NOT NULL CHECK (length(connection_generation) = 36),
idempotency_key TEXT NOT NULL CHECK (length(idempotency_key) BETWEEN 1 AND 128),
request_digest TEXT NOT NULL CHECK (length(request_digest) = 64),
session_id TEXT NOT NULL CHECK (length(session_id) BETWEEN 1 AND 128),
session_key TEXT NOT NULL CHECK (length(session_key) BETWEEN 1 AND 1024),
agent_id TEXT NOT NULL CHECK (length(agent_id) BETWEEN 1 AND 128),
worktree_id TEXT NOT NULL CHECK (length(worktree_id) BETWEEN 1 AND 128),
repository_fingerprint TEXT NOT NULL CHECK (length(repository_fingerprint) BETWEEN 1 AND 256),
identity_source TEXT NOT NULL CHECK (identity_source = 'personal'),
identity_profile_id TEXT NOT NULL CHECK (length(identity_profile_id) = 36),
identity_account_id INTEGER NOT NULL CHECK (identity_account_id >= 1),
identity_login TEXT NOT NULL CHECK (length(identity_login) BETWEEN 1 AND 39),
title TEXT CHECK (title IS NULL OR length(title) BETWEEN 1 AND 256),
body TEXT CHECK (body IS NULL OR length(body) BETWEEN 1 AND 8192),
status TEXT NOT NULL CHECK (status IN ('requested', 'publishing', 'needs_confirmation', 'published', 'failed')),
gateway_instance_id TEXT CHECK (gateway_instance_id IS NULL OR length(gateway_instance_id) BETWEEN 1 AND 128),
execution_id TEXT CHECK (execution_id IS NULL OR length(execution_id) = 36),
last_effect TEXT CHECK (last_effect IS NULL OR last_effect IN ('push', 'pull_request')),
effect_state TEXT CHECK (effect_state IS NULL OR effect_state IN ('dispatched', 'observed')),
push_repository TEXT NOT NULL CHECK (length(push_repository) BETWEEN 3 AND 256),
repository TEXT NOT NULL CHECK (length(repository) BETWEEN 3 AND 256),
branch TEXT NOT NULL CHECK (length(branch) BETWEEN 1 AND 256),
base_branch TEXT NOT NULL CHECK (length(base_branch) BETWEEN 1 AND 256),
source_head_commit TEXT NOT NULL CHECK (length(source_head_commit) IN (40, 64)),
source_index_tree TEXT NOT NULL CHECK (length(source_index_tree) IN (40, 64)),
workspace_tree TEXT NOT NULL CHECK (length(workspace_tree) IN (40, 64)),
head_commit TEXT CHECK (head_commit IS NULL OR length(head_commit) IN (40, 64)),
pull_request_url TEXT CHECK (pull_request_url IS NULL OR length(pull_request_url) BETWEEN 1 AND 2048),
error_code TEXT CHECK (error_code IS NULL OR length(error_code) BETWEEN 1 AND 64),
next_action TEXT CHECK (next_action IS NULL OR length(next_action) BETWEEN 1 AND 1024),
created_at_ms INTEGER NOT NULL CHECK (created_at_ms >= 0),
updated_at_ms INTEGER NOT NULL CHECK (updated_at_ms >= created_at_ms),
reported_at_ms INTEGER,
draft INTEGER,
UNIQUE (owner_profile_id, session_id, idempotency_key),
CHECK ((status = 'publishing' AND gateway_instance_id IS NOT NULL AND execution_id IS NOT NULL) OR status <> 'publishing'),
CHECK ((last_effect IS NULL AND effect_state IS NULL) OR (last_effect IS NOT NULL AND effect_state IS NOT NULL)),
CHECK ((status = 'published' AND pull_request_url IS NOT NULL AND head_commit IS NOT NULL AND error_code IS NULL AND next_action IS NULL)
OR (status = 'failed' AND error_code IS NOT NULL AND next_action IS NOT NULL)
OR (status IN ('requested', 'publishing', 'needs_confirmation') AND error_code IS NULL AND next_action IS NULL))
) STRICT;
CREATE INDEX IF NOT EXISTS idx_github_personal_publication_owner_session
ON github_personal_publication_requests(owner_profile_id, session_id, created_at_ms);
CREATE INDEX IF NOT EXISTS idx_github_personal_publication_pending
ON github_personal_publication_requests(status, updated_at_ms, request_id);
-- Older readers validate both local receipt tables exactly. Their immutable
-- lifecycle binding stays in a first-use companion so those schemas remain readable.
CREATE TABLE IF NOT EXISTS github_publication_session_lifecycles (
publication_kind TEXT NOT NULL CHECK (publication_kind IN ('shared', 'personal')),
request_id TEXT NOT NULL,
lifecycle_revision TEXT,
requester_authority_json TEXT,
PRIMARY KEY (publication_kind, request_id)
) STRICT;
-- One active, opaque admission credential per worker environment. Plaintext
-- may be retried until delivery acknowledgement but never enters durable state.
CREATE TABLE IF NOT EXISTS worker_environment_credentials (
environment_id TEXT NOT NULL PRIMARY KEY,
credential_hash TEXT NOT NULL UNIQUE,
bundle_hash TEXT NOT NULL,
session_id TEXT,
rpc_set_version INTEGER NOT NULL CHECK (rpc_set_version >= 1),
owner_epoch INTEGER NOT NULL CHECK (owner_epoch >= 0),
expires_at_ms INTEGER NOT NULL CHECK (expires_at_ms >= 0),
delivered_at_ms INTEGER CHECK (delivered_at_ms >= 0),
FOREIGN KEY (environment_id) REFERENCES worker_environments(environment_id) ON DELETE CASCADE
) STRICT;
-- One durable sequence cursor per attached session owner epoch. The environment
-- binding prevents independent workers with coincident epochs from sharing replay state.
CREATE TABLE IF NOT EXISTS worker_transcript_commit_heads (
session_id TEXT NOT NULL,
run_epoch INTEGER NOT NULL CHECK (run_epoch >= 0),
environment_id TEXT NOT NULL,
next_seq INTEGER NOT NULL CHECK (next_seq >= 1),
updated_at_ms INTEGER NOT NULL CHECK (updated_at_ms >= 0),
PRIMARY KEY (session_id, run_epoch)
) STRICT;
-- Pending rows preserve a claimed request across gateway restarts. Terminal rows
-- cache the exact result returned for deterministic at-least-once replay.
CREATE TABLE IF NOT EXISTS worker_transcript_commits (
session_id TEXT NOT NULL,
run_epoch INTEGER NOT NULL CHECK (run_epoch >= 0),
seq INTEGER NOT NULL CHECK (seq >= 1),
request_hash TEXT NOT NULL,
state TEXT NOT NULL CHECK (state IN ('pending', 'terminal')),
result_json TEXT,
created_at_ms INTEGER NOT NULL CHECK (created_at_ms >= 0),
updated_at_ms INTEGER NOT NULL CHECK (updated_at_ms >= 0),
PRIMARY KEY (session_id, run_epoch, seq),
FOREIGN KEY (session_id, run_epoch)
REFERENCES worker_transcript_commit_heads(session_id, run_epoch)
ON DELETE CASCADE,
CHECK (
(state = 'pending' AND result_json IS NULL) OR
(state = 'terminal' AND result_json IS NOT NULL)
)
) STRICT;
-- Pending rows preserve a claimed inference turn across gateway restarts.
-- Terminal rows cache the exact outcome returned for deterministic replay.
CREATE TABLE IF NOT EXISTS worker_inference_turns (
session_id TEXT NOT NULL,
run_epoch INTEGER NOT NULL CHECK (run_epoch >= 0),
run_id TEXT NOT NULL,
turn_id TEXT NOT NULL,
environment_id TEXT NOT NULL,
request_hash TEXT NOT NULL,
state TEXT NOT NULL CHECK (state IN ('pending', 'terminal')),
terminal_json TEXT,
created_at_ms INTEGER NOT NULL CHECK (created_at_ms >= 0),
updated_at_ms INTEGER NOT NULL CHECK (updated_at_ms >= 0),
PRIMARY KEY (session_id, run_epoch, run_id, turn_id),
FOREIGN KEY (environment_id) REFERENCES worker_environments(environment_id) ON DELETE CASCADE,
CHECK (
(state = 'pending' AND terminal_json IS NULL) OR
(state = 'terminal' AND terminal_json IS NOT NULL)
)
) STRICT;
CREATE UNIQUE INDEX IF NOT EXISTS idx_worker_inference_turns_pending_run
ON worker_inference_turns(session_id, run_epoch, run_id)
WHERE state = 'pending';
CREATE TABLE IF NOT EXISTS template_installs (
agent_id TEXT NOT NULL PRIMARY KEY,
schema_version TEXT NOT NULL,
source_kind TEXT NOT NULL,
template_name TEXT NOT NULL,
template_version TEXT NOT NULL,
package_root TEXT NOT NULL,
manifest_path TEXT NOT NULL,
integrity_kind TEXT NOT NULL,
integrity TEXT NOT NULL,
source_byte_length INTEGER NOT NULL,
manifest_schema_version INTEGER NOT NULL,
plan_integrity TEXT NOT NULL,
workspace TEXT NOT NULL UNIQUE,
agent_config_digest TEXT NOT NULL,
agent_owned_paths_json TEXT NOT NULL,
bootstrap_source_path TEXT,
bootstrap_content_digest TEXT,
status TEXT NOT NULL CHECK (
status IN ('pending', 'workspace_ready', 'config_committed', 'complete', 'partial')
),
added_at_ms INTEGER NOT NULL,
updated_at_ms INTEGER NOT NULL
) STRICT;
CREATE TABLE IF NOT EXISTS template_workspace_files (
agent_id TEXT NOT NULL,
target_path TEXT NOT NULL,
schema_version TEXT NOT NULL,
workspace TEXT NOT NULL,
source_path TEXT NOT NULL,
content_digest TEXT NOT NULL,
status TEXT NOT NULL,
created_at_ms INTEGER NOT NULL,
updated_at_ms INTEGER NOT NULL,
PRIMARY KEY (agent_id, target_path)
) STRICT;
CREATE TABLE IF NOT EXISTS template_package_refs (
agent_id TEXT NOT NULL,
package_kind TEXT NOT NULL,
package_source TEXT NOT NULL,
package_ref TEXT NOT NULL,
package_version TEXT NOT NULL,
package_integrity TEXT NOT NULL,
schema_version TEXT NOT NULL,
template_name TEXT NOT NULL,
package_status TEXT NOT NULL,
relationship TEXT NOT NULL CHECK (relationship IN ('managed', 'referenced')),
origin TEXT NOT NULL CHECK (origin IN ('template-introduced', 'pre-existing')),
independent_owner INTEGER NOT NULL CHECK (independent_owner IN (0, 1)),
extension_id TEXT,
extension_format TEXT,
extension_detected_format TEXT,
extension_mapped_json TEXT,
extension_unavailable_json TEXT,
extension_adapter_identity TEXT,
installed_at_ms INTEGER NOT NULL,
updated_at_ms INTEGER NOT NULL,
PRIMARY KEY (agent_id, package_kind, package_source, package_ref, package_version)
) STRICT;
CREATE TABLE IF NOT EXISTS template_cron_refs (
agent_id TEXT NOT NULL,
manifest_id TEXT NOT NULL,
schema_version TEXT NOT NULL,
declaration_key TEXT NOT NULL UNIQUE,
scheduler_job_id TEXT UNIQUE,
status TEXT NOT NULL,
job_json TEXT NOT NULL,
error TEXT,
created_at_ms INTEGER NOT NULL,
updated_at_ms INTEGER NOT NULL,
PRIMARY KEY (agent_id, manifest_id)
) STRICT;
CREATE TABLE IF NOT EXISTS template_mcp_server_refs (
agent_id TEXT NOT NULL,
name TEXT NOT NULL,
schema_version TEXT NOT NULL,
config_digest TEXT NOT NULL,
relationship TEXT NOT NULL CHECK (relationship IN ('managed', 'referenced')),
origin TEXT NOT NULL CHECK (origin IN ('template-introduced', 'pre-existing')),
independent_owner INTEGER NOT NULL DEFAULT 0 CHECK (independent_owner IN (0, 1)),
status TEXT NOT NULL,
error TEXT,
created_at_ms INTEGER NOT NULL,
updated_at_ms INTEGER NOT NULL,
PRIMARY KEY (agent_id, name)
) STRICT;
CREATE TABLE IF NOT EXISTS user_profile_identities (
provider TEXT NOT NULL,
subject TEXT NOT NULL,
profile_id TEXT NOT NULL,
canonical_login TEXT,
-- Host-scoped verified credit evidence; current profile bindings govern attribution.
verified_email_json TEXT,
created_at INTEGER NOT NULL,
authorization_id TEXT,
authorization_basis_json TEXT,
PRIMARY KEY (provider, subject)
) STRICT;
CREATE INDEX IF NOT EXISTS idx_user_profile_identities_profile_id
ON user_profile_identities(profile_id);
CREATE UNIQUE INDEX IF NOT EXISTS idx_user_profile_identities_authorization
ON user_profile_identities(authorization_id);
CREATE TABLE IF NOT EXISTS outbound_media_provenance (
realpath TEXT NOT NULL PRIMARY KEY,
kind TEXT NOT NULL,
version INTEGER NOT NULL,
sha256 TEXT NOT NULL,
size_bytes INTEGER NOT NULL,
created_at_ms INTEGER NOT NULL
) STRICT;
-- scope_id is non-null because SQLite treats NULLs as distinct in unique indexes/PKs,
-- which would allow duplicate team rows. This PK also avoids a rebuild for identity scope.
CREATE TABLE IF NOT EXISTS secret_store_entries (
scope_kind TEXT NOT NULL CHECK (scope_kind IN ('team', 'identity')),
scope_id TEXT NOT NULL,
name TEXT NOT NULL,
value TEXT NOT NULL,
kind TEXT NOT NULL CHECK (kind IN ('secret', 'env')),
created_at_ms INTEGER NOT NULL CHECK (created_at_ms >= 0),
updated_at_ms INTEGER NOT NULL CHECK (updated_at_ms >= 0),
updated_by TEXT,
deleted_at_ms INTEGER,
allowed_hosts TEXT,
CHECK ((scope_kind = 'team' AND scope_id = '') OR (scope_kind = 'identity' AND length(scope_id) > 0)),
PRIMARY KEY (scope_kind, scope_id, name)
) STRICT;
CREATE INDEX IF NOT EXISTS secret_store_entries_live_idx
ON secret_store_entries (scope_kind, scope_id, name) WHERE deleted_at_ms IS NULL;
`||o.includes(`CREATE TABLE IF NOT EXISTS ${e} (`))&&(o=o.replace(N(o,e,{errorMessage:`lazy additive state schema block is missing for ${e}`}),``));for(let e of c){let t=o.indexOf(`CREATE INDEX IF NOT EXISTS ${e}`),n=o.indexOf(`CREATE UNIQUE INDEX IF NOT EXISTS ${e}`),r=t>=0?t:n,i=r>=0?o.indexOf(`;`,r):-1;if(r<0||i<0)throw Error(`lazy additive state schema index is missing for ${e}`);o=`${o.slice(0,r)}${o.slice(i+1)}`}return Ni.set(i,o),o}function getOpenClawStatePredecessorSchema(e){let t=v;for(let[n,r]of[[40,withLegacyWorkerProvisionSource],[40,withLegacyStateV40Additions],[39,withLegacyWorkerRetention],[38,withLegacyRepositoryDiskAuthority],[37,withLegacyWorkerResourceReceipts],[36,Jn],[35,withLegacyLocalWorkspaceCas],[31,withLegacyLocalWorkspaceManifests],[27,withLegacyStateWriteIndexes],[26,withLegacyStateHeadLayout]])e<n&&(t=r(t));return t}const Pi=[...Pe,`worker_session_tool_operations`,`worker_turn_tool_authorities`],Fi=[`agent_database_leases`,`agent_deletion_journal`,`claw_cron_refs`,`claw_installs`,`claw_mcp_server_refs`,`claw_package_refs`,`claw_workspace_files`,`config_machine_state`,`cron_job_scratch`,`meeting_transcript_sessions`,`meeting_transcript_summaries`,`meeting_transcript_utterances`,`outbound_media_provenance`,`worker_environment_credentials`,`worker_transcript_commit_heads`,`worker_transcript_commits`,...Pi],Ii=Un.map(({columnName:e,tableName:t})=>`${t}.${e}`),Li=nr.map(({columnName:e,tableName:t})=>`${t}.${e}`),Ri=new Set(Li),zi=/* @__PURE__ */ new Set([...Wn.map(({columnName:e,tableName:t})=>`${t}.${e}`),...Object.values(Qn).flat().map(([e,t])=>`${e}.${t.split(` `,1)[0]}`)]),Bi=[`worker_session_tool_operations`,`worker_turn_tool_authorities`],Vi=new Set(Bi),Hi=[`idx_meeting_transcript_utterances_id`,`idx_operator_approvals_source_run_resolved`,`idx_worker_session_placements_environment`];let Ui;function getOpenClawStateCanonicalNamedIndexSet(){return Ui??=new Set(In(v)),Ui}const Wi=[`fleet_cells`],Gi={excludedTables:Wi,allowCompatibleAdditiveColumns:!0,allowedMissingTables:Be,allowedMissingColumns:Li,allowedColumnDefinitions:{"diagnostic_events.sequence":[`sequence INTEGER NOT NULL DEFAULT 0`],"template_package_refs.package_integrity":[`package_integrity TEXT NOT NULL DEFAULT 'sha256:0000000000000000000000000000000000000000000000000000000000000000'`],"template_package_refs.updated_at_ms":[`updated_at_ms INTEGER NOT NULL DEFAULT 0`],"cron_jobs.enabled":[`enabled INTEGER NOT NULL DEFAULT 1`],"cron_jobs.name":[`name TEXT NOT NULL DEFAULT ''`],"cron_jobs.payload_kind":[`payload_kind TEXT NOT NULL DEFAULT 'message'`],"current_conversation_bindings.conversation_kind":[`conversation_kind TEXT NOT NULL DEFAULT 'channel'`],"operator_approvals.resolution_ref":[`resolution_ref TEXT`],"worker_environments.desktop_json":[`desktop_json TEXT`],"worker_environments.bootstrap_install_kind":[`bootstrap_install_kind TEXT`],"worker_environments.shared_host":[`shared_host INTEGER CHECK (shared_host IN (0, 1))`],"worker_environments.node_setup_id":[`node_setup_id TEXT`],"worker_environments.node_device_id":[`node_device_id TEXT`],"worker_session_placements.terminal_reason":[`terminal_reason TEXT`],"worker_session_placements.terminal_at_ms":[`terminal_at_ms INTEGER`]}},Q={...Gi,excludedTables:[...Wi,...Pe],excludedIndexes:Fe};function findMissingLazyStateStartupColumn(e){for(let{tableName:t,columnName:n}of Wn){if(!Q.excludedTables?.includes(t))continue;let r=e(t);if(r&&!r.columns.some(e=>e.name===n))return{tableName:t,columnName:n}}}const Ki={...Gi,allowedMissingTables:[...Pe,...Bi,...Be],allowedMissingIndexes:Hi,allowedMissingColumns:Ii};function isOpenClawStateStartupRepairableSchemaIssue(e){return e.code===`missing-table`?Vi.has(e.objectName):e.code===`missing-column`?zi.has(e.objectName):e.code===`missing-or-drifted-index`&&getOpenClawStateCanonicalNamedIndexSet().has(e.objectName)}function isOpenClawStateFirstUseSchemaIssue(e){return e.code===`missing-column`&&Ri.has(e.objectName)}var UpdateSchemaRefusalError=class extends Error{constructor(e,t,n){let{targetVersion:r}=n,i=n.recovery?.commands??[`openclaw gateway stop`,`npm install -g openclaw@${r} --allow-scripts=openclaw`,`openclaw doctor --fix`,`openclaw gateway start`],a=n.cause===void 0?``:` Deferral failed: ${kt(n.cause).slice(0,600)}.`,o=`Doctor refused update-time schema repair driven by OpenClaw ${t}: this updater reopens the ledger with old code after migration, and version publication could not be deferred safely.`,s=`${e.map(e=>`${e.kind} database ${e.path}: on-disk schema ${e.foundVersion}, this build's schema ${e.supportedVersion}.`).join(` `)}${a} The blocked schema change was not applied.`;super(n.recovery?`${o} ${s}\n${n.recovery.message}`:[o,s,`Let the updater restore the previous package and exit. Then use an independent shell with the original service account, package prefix, profile, and state/config overrides.`,`Manual update: ${i.join(` && `)}.`,`Use the package manager that owns this install (pnpm: pnpm add -g --allow-build=openclaw openclaw@${r}; Bun: bun add -g --trust openclaw@${r}). On npm 11.15 and earlier, omit --allow-scripts=openclaw.`].join(`
`),n),this.databases=e,this.updaterVersion=t,this.code=`update-schema-bump-unfenced`,this.name=`UpdateSchemaRefusalError`,this.targetVersion=r,this.commands=i}};const qi=`session_participants`,Ji={agent:{30:[`trajectory_runtime_events`,`sqlite_stat1`,`sqlite_stat4`],27:[`context_engine_turn_outbox`,`sqlite_stat1`,`sqlite_stat4`],28:[`transcript_event_identities`,`session_windows`,`memory_entry_origins`,`sqlite_stat1`,`sqlite_stat4`],29:[`session_nodes`,`session_reactions`,`sqlite_stat1`,`sqlite_stat4`],31:[`memory_index_sources`,`memory_index_chunks`],32:[],33:[],34:[],35:[],36:[],37:[`session_transcript_cold_archive_chunks`],38:[],39:[`transcript_events`],40:[`session_creation_operations`],41:[`session_transcript_active_event_facts`],42:[`agent_tool_usage`]},state:{29:[...pi,`sqlite_stat1`,`sqlite_stat4`],23:[`meeting_transcript_sessions`,`worker_environments`],26:[`session_state_heads`,`sqlite_stat1`,`sqlite_stat4`],27:[`acp_replay_events`,`skill_usage`,`state_leases`,`sqlite_stat1`,`sqlite_stat4`],28:[`github_publication_requests`,`github_personal_publication_requests`,`github_repository_publication_requests`],30:[],31:[`local_workspace_projections`,`local_workspace_manifest_nodes`,`sqlite_stat1`,`sqlite_stat4`],32:[],33:[],34:[`config_machine_state`],35:[`local_workspace_projections`,`local_workspace_manifest_nodes`,`local_workspace_tree_packs`,`local_workspace_source_path_sets`],36:[`claw_installs`,`template_installs`,`claw_workspace_files`,`template_workspace_files`,`claw_package_refs`,`template_package_refs`,`claw_cron_refs`,`template_cron_refs`,`claw_mcp_server_refs`,`template_mcp_server_refs`,`agent_provenance`,`sqlite_stat1`,`sqlite_stat4`],37:[`worker_environments`],38:[`session_repository_workspaces`,`worker_workspace_pending_results`],39:[`worker_environments`],40:[`worker_environments`]}},Yi=[`sqlite_stat1`,`sqlite_stat4`],Xi={agent:[`auth_profile_store`,`auth_profile_state`,`session_nodes`,`session_entry_snapshots`,`session_windows`,`session_key_contract`,`session_canonical_validation_pending`,`memory_index_chunks`,`memory_index_chunk_recall_metadata`,`memory_index_chunk_provenance`,`memory_index_sources`,`memory_index_paths_fts`,`memory_index_state`,...Yi],state:[...Wn.map(({tableName:e})=>e),...Object.values(Qn).flatMap(e=>e.map(([e])=>e)),`audit_events`,`audit_identity_keys`,`operator_approvals`,`session_watch_cursors`,`subagent_runs`,`worker_session_placements`,`meeting_transcript_sessions`,`meeting_transcript_summaries`,`delivery_queue_entries`,`worker_turn_tool_authorities`,`worker_session_tool_operations`,`migration_runs`,`sqlite_sequence`,...Yi]},Zi={agent:{...Ji.agent,39:[],10:[`session_transcript_active_events`,`session_transcript_index_state`],11:[`sessions`,`conversations`,`session_conversations`],13:[`transcript_rewrite_watermarks`],14:[`sessions`,`session_entries`,`session_routes`,`session_nodes`,`session_windows`,`session_transcript_generations`,`transcript_rewrite_watermarks`,`board_tabs`,`board_widgets`,`heartbeat_outcomes`,`session_members`,`session_transcript_index_state`],17:[`state_leases`],18:[`session_participants`],19:[`session_nodes`],21:[`session_key_contract`,`session_canonical_validation_pending`],22:[`session_transcript_fts_rows`],23:[`transcript_events`,`session_transcript_fts`,`session_transcript_fts_rows`,`session_transcript_index_state`,`memory_index_sources`,`memory_index_chunks`,`memory_index_chunks_fts`,`memory_index_chunk_recall_metadata`,`memory_embedding_cache`,`memory_index_meta`,`memory_index_state`,`cache_entries`],24:[`session_nodes`,`session_entry_snapshots`],25:[`session_pending_inputs`,`session_nodes`,`session_windows`,`session_key_contract`,`session_canonical_validation_pending`],26:[`session_nodes`,`context_engine_turn_outbox`,`transcript_events`]},state:{...Ji.state,2:[`audit_events`,`audit_identity_keys`,`sqlite_sequence`],4:[`session_watch_cursors`],7:[`commitments`],8:[`worker_session_placements`],9:[`agent_databases`],10:[`agent_model_catalogs`,`android_notification_recent_packages`,`command_log_entries`,`diagnostic_stability_bundles`,`media_blobs`,`model_capability_cache`],11:[`skill_lifecycle`,`skill_workshop_proposal_origin_runs`],12:[`config_machine_state`,`skill_curator_state`,`update_check_state`,`clawhub_promotions_feed_state`,`model_catalog_remote`,`voicewake_triggers`,`voicewake_routing_routes`,`voicewake_routing_config`,`onboarding_recommendations`,`cron_store_epochs`,`tui_last_sessions`,`sidebar_sections`,`node_host_config`,`web_push_vapid_keys`],13:[`cron_jobs`,`subagent_runs`,`workspace_setup_state`,`workspace_attestations`,`workspace_generated_bootstrap_hashes`,`auth_profile_stores`,`auth_profile_state`,`installed_plugin_index`,`config_machine_state`,`diagnostic_events`],14:[`cron_jobs`],15:[`current_conversation_bindings`],17:[`worker_environments`],18:[`github_publication_session_lifecycles`,`github_repository_publication_requests`],20:[`cron_run_receipts`],21:[`meeting_transcript_sessions`,`meeting_transcript_summaries`,`delivery_queue_entries`,...Yi],22:[`worker_session_placements`,`meeting_transcript_sessions`,`meeting_transcript_summaries`,`delivery_queue_entries`,`acp_sessions`,`operator_approvals`,`cron_run_receipts`,`execution_decision_facts`,`skill_workshop_changes`,...Yi],24:[`task_runs`,...Yi],25:[]}};function resolveSchemaMigrationIntegrityTables(e){if(e.kind===`agent`&&e.foundVersion>=38&&e.foundVersion<e.supportedVersion&&e.supportedVersion<=40)return[`schema_meta`];if(e.kind===`agent`&&e.foundVersion>=40&&e.foundVersion<e.supportedVersion&&e.supportedVersion<=42)return[`schema_meta`,...e.foundVersion<41?[`session_transcript_active_event_facts`]:[],...e.supportedVersion>=42?[`agent_tool_usage`]:[]];let t=/* @__PURE__ */ new Set([`schema_meta`]);if(e.foundVersion===e.supportedVersion)for(let n of Xi[e.kind])t.add(n);for(let n=e.foundVersion+1;n<=e.supportedVersion;n++)for(let r of Zi[e.kind][n]??[])t.add(r);if(e.kind===`agent`){for(let{tableName:e}of d)t.add(e);if(e.foundVersion<20&&(t.add(`board_widgets`),t.add(`memory_index_sources`),t.add(`memory_index_paths_fts`)),e.foundVersion<25)for(let e of Xi.agent)t.add(e)}else if(t.add(`config_machine_state`),e.foundVersion<20)for(let e of Xi.state)t.add(e);return[...t].toSorted()}function assertMigratedStateTableIntegrity(e,t,n,r=!1){let i=resolveSchemaMigrationIntegrityTables({kind:`state`,foundVersion:n,supportedVersion:40}),a=r?/* @__PURE__ */ new Set([...i,...Xi.state]):i;for(let n of a)L(e,n)&&En(e,t,n)}function assertOpenClawStateDatabaseOwner(e,t){let n=Dn(e);if(n&&kn(e))return{schema_version:n.userVersion};let r=L(e,`schema_meta`),i;try{i=r?e.prepare(`SELECT role, schema_version FROM schema_meta WHERE meta_key = 'primary' LIMIT 1`).get():void 0}catch(t){throw fn(e,`schema_meta`,[`meta_key`,`role`,`schema_version`],t)}if(i?.role!==`global`){let e=typeof i?.role==`string`?i.role:`missing`;throw new F(`OpenClaw state database ${t.pathname} has schema role ${e}; expected global. Run openclaw doctor --fix to inspect and repair its ownership.`)}return i}function assertOpenClawStateDatabaseForMaintenance(e,t,n){E(e)&&Pt(`postgres`,`repair`);let r=H(e,t.pathname,t.schemaVersions);if((t.schemaVersions?.contentVersion??ar(e))!==40)throw new F(`OpenClaw state database ${t.pathname} uses schema version ${r}; run openclaw doctor --fix before compacting it.`);let i=assertOpenClawStateDatabaseOwner(e,t);if(i?.schema_version!==r&&!jn(e,i)){let e=typeof i?.schema_version==`number`?i.schema_version:`invalid`;throw new F(`OpenClaw state database ${t.pathname} metadata schema version ${e} does not match ${r}; run openclaw doctor --fix before compacting it.`)}Rn(e,t.pathname,v,Ki,n)}function assertOpenClawStateDatabaseVersionForMigration(e,t){let n=V(e);if(ar(e)!==t.version)throw new F(`OpenClaw state database ${t.pathname} uses schema version ${n}; expected ${t.version} before migrating it.`);let r=assertOpenClawStateDatabaseOwner(e,t);if(r?.schema_version!==n){let e=typeof r?.schema_version==`number`?r.schema_version:`invalid`;throw new F(`OpenClaw state database ${t.pathname} metadata schema version ${e} does not match ${n}; repair the ownership metadata before migrating it.`)}Fn(e,t.pathname,getOpenClawStatePredecessorSchema(t.version),{allowedMissingTables:[...t.version===5?Fi:t.version<13?Pi:Pe,...Be]})}const Qi=new Map(Ie.map(e=>[e,(t,n)=>assertOpenClawStateDatabaseVersionForMigration(t,{...n,version:e})]));function markCurrentStateSchemaVersion(e,t={}){if(!L(e,`audit_events`))return;let n=resolveStateSchemaVersionToPublish(e);if(V(e)!==n&&e.exec(`PRAGMA user_version = ${n};`),An(e,{userVersion:n,contentVersion:40}),L(e,`schema_meta`)&&[`meta_key`,`schema_version`,`updated_at`].every(t=>R(e,`schema_meta`,t))){let r=Date.now();if(t.createMetadataIfMissing){e.prepare(`INSERT INTO schema_meta (
meta_key, role, schema_version, agent_id, app_version, created_at, updated_at
) VALUES ('primary', 'global', ?, NULL, NULL, ?, ?)
ON CONFLICT(meta_key) DO UPDATE SET
schema_version = excluded.schema_version,
updated_at = excluded.updated_at
WHERE schema_meta.schema_version IS NOT excluded.schema_version`).run(n,r,r);return}e.prepare(`UPDATE schema_meta SET schema_version = ?, updated_at = ? WHERE meta_key = 'primary' AND schema_version IS NOT ?`).run(n,r,n)}}function migrateCronCreatorNamespaces(e,t){return t>=14||!L(e,`cron_jobs`)?!1:(e.exec(`
UPDATE cron_jobs
SET job_json = json_set(job_json, '$.createdActor.source', 'unknown')
WHERE json_valid(job_json)
AND json_extract(job_json, '$.createdActor.type') = 'human';
`),!0)}function migrateConversationBindingTargets(e,t){if(t>=15)return!1;let n=[`target_agent_id`,`target_session_id`].filter(t=>R(e,`current_conversation_bindings`,t));if(n.length===0)return!1;e.exec(`DROP INDEX IF EXISTS idx_current_conversation_bindings_target;`);for(let t of n)e.exec(`ALTER TABLE current_conversation_bindings DROP COLUMN ${t};`);return!0}function migratePreparedWorkerOwnership(e,t){if(t>=17||!L(e,`worker_environments`))return!1;let n=v.indexOf(`CREATE TABLE IF NOT EXISTS worker_environments (`),r=v.indexOf(`
) STRICT;`,n);if(n<0||r<n)throw Error(`OpenClaw worker environment schema marker is missing.`);let i=Et(v.slice(n+48,r)).map(e=>e.trim()).filter(e=>e.startsWith(`last_activated_at_ms `)||e.startsWith(`preparation_`)),a=!1;for(let t of i)a=I(e,`worker_environments`,t)||a;return a}function migrateGitHubPublicationRequesterAuthority(e,t){if(t>=18)return!1;let n=!1;for(let t of[`github_publication_session_lifecycles`,`github_repository_publication_requests`])n=I(e,t,`requester_authority_json TEXT`)||n;return n}const $i={version:22,tables:[`acp_sessions`,...Z],columns:[`acp_sessions.resume_agent_session_id`,`acp_sessions.resume_acpx_session_id`,...Z.map(e=>`${e}.cursor_id`)],migrate:migratePortableIdentityColumnsV22,applied:`Promoted portable ACP resume keys and cursor identities (v22)`},ea={version:23,tables:[`meeting_transcript_sessions`],columns:[`meeting_transcript_sessions.started_at_ms`],migrate:migrateMeetingTranscriptStartTime,applied:`Persisted normalized meeting transcript start times`},ta={version:24,tables:[`task_runs`],columns:[],migrate:migrateTaskRunIndexesV24,applied:`Replaced retained task indexes with ordered cron history indexes (v24)`},na={version:25,tables:[],columns:[],migrate:()=>!1,applied:`Required original operator authority for subagent recovery (v25)`},ra={version:26,tables:[`session_state_heads`],columns:[],migrate:migrateSessionStateHeadLayoutV26,applied:`Stored session state heads in their composite primary-key tree (v26)`},ia={version:27,tables:[`acp_replay_events`,`skill_usage`,`state_leases`],columns:[],migrate:migrateStateWriteIndexesV27,applied:`Removed redundant replay and skill indexes and narrowed the lease-owner index (v27)`},aa={version:29,tables:pi,columns:[],migrate:()=>!1,applied:`Moved client credentials and native socket material to the local owner (v29)`},oa={version:30,tables:[],columns:[],migrate:()=>!1,applied:`Fenced ordinary automation timing and delivery policies from older schedulers (v30)`},sa=[$i,ea,{migrate:migrateJsonCanonicalWideRowsV13,applied:`Consolidated shared state tables (v13)`},{migrate:migrateCronCreatorNamespaces,applied:`Qualified historical cron creator attribution as unknown (v14)`},{migrate:migrateConversationBindingTargets,applied:`Removed redundant conversation binding target projections (v15)`},{migrate:migratePreparedWorkerOwnership,applied:`Recorded prepared worker ownership and one-use lifecycle (v17)`},{migrate:migrateGitHubPublicationRequesterAuthority,applied:`Added original requester authority to GitHub publication receipts (v18)`},{migrate:migrateCronDeliveryAttemptState,applied:`Recorded cron completion delivery attempt uncertainty (v20)`},ta,ra,ia,Kn,Vr,me,Lr,er,...Ur,Wr,Gr];function migrateBoundedStateSchema(e,t,n){let r=[hi,$i,ea,ta,na,ra,ia,Kn,aa,oa,Vr,..._i,me,Lr,er,...Ur,Wr,Gr].filter(({version:e})=>e>t);if(t>=40||r.length!==40-t)return;let i=new Set(r.flatMap(e=>e.tables)),a=Mn(v).filter(e=>i.has(e.tableName)),o=getOpenClawStatePredecessorSchema(t);if(!n.versionMigrationOnly&&(L(e,`cron_run_logs`)||!r.includes(Kn)&&Yn(e)||findMissingLazyStateStartupColumn(z(e))!==void 0||Nn(e,o,{...Hn(Q),allowedMissingColumns:[...Q.allowedMissingColumns??[],...r.flatMap(e=>e.columns)].map(Jn),allowedMissingIndexes:[...Q.allowedMissingIndexes??[],...a.map(e=>e.name),`idx_acp_replay_events_session_seq`,`idx_skill_usage_key`],excludedIndexes:[...Q.excludedIndexes??[],`idx_acp_sessions_resume_agent`,`idx_acp_sessions_resume_acpx`]}).length>0))return;let s=migrateHistoricalStateImports(e,t);for(let i of r)i.migrate(e,t,n),s.push(i.applied);for(let t of a)if(L(e,t.tableName)){let n=t.unique?`CREATE UNIQUE INDEX`:`CREATE INDEX`;e.exec(`${n} IF NOT EXISTS ${t.name} ${t.definition};`)}return s}function runStateSchemaMigrationTransaction(e,t,n,r,i){return jt(e,t,()=>{let a=Number(e.prepare(`PRAGMA foreign_keys`).get()?.foreign_keys)===1;a&&e.exec(`PRAGMA foreign_keys = OFF;`);try{return an(e,()=>{i?.();let r=V(e),a=r<40?readStateSchemaPublicationBlocker(e):void 0;if(!a)return n();try{if(!L(e,`config_machine_state`))throw Error(`Shared state schema publication requires config_machine_state.`);return n()}catch(e){throw e instanceof Te?e:new UpdateSchemaRefusalError([{kind:`state`,path:t,foundVersion:r,supportedVersion:40}],a.updaterVersion,{targetVersion:B,cause:e})}},r)}finally{a&&e.isOpen&&e.exec(`PRAGMA foreign_keys = ON;`)}})}function writeCurrentStateSchemaMetadata(e,t){let n=k(e),r=resolveStateSchemaVersionToPublish(e);V(e)!==r&&e.exec(`PRAGMA user_version = ${r};`),An(e,{userVersion:r,contentVersion:40}),j(e,n.insertInto(`schema_meta`).values({meta_key:`primary`,role:`global`,schema_version:r,agent_id:null,app_version:B,created_at:t,updated_at:t}).onConflict(e=>e.column(`meta_key`).doUpdateSet({role:`global`,schema_version:r,agent_id:null,app_version:B,updated_at:t}).where(e=>e.or([e(`schema_meta.schema_version`,`!=`,r),e(`schema_meta.app_version`,`is not`,B),e(`schema_meta.role`,`!=`,`global`)]))))}function executeCanonicalStateSchema(e,t){e.exec(getOpenClawStateRuntimeSchema({...t,includeAgentDeletionJournal:t.includeAgentDeletionJournal??L(e,`agent_deletion_journal`)}))}const ca=[`audit_events`,`audit_identity_keys`].map(e=>({name:e,sql:Tt(N(v,e))})),la=[`sequence`,`event_id`,`source_id`,`source_sequence`,`occurred_at`,`kind`,`action`,`status`,`error_code`,`actor_type`,`actor_id`,`agent_id`,`session_key`,`session_id`,`run_id`,`tool_call_id`,`tool_name`],ua=[...la.flatMap(e=>e===`source_id`?[e,`schema_version`]:[e]),`direction`,`channel`,`conversation_kind`,`message_outcome`,`reason_code`,`delivery_kind`,`failure_stage`,`duration_ms`,`result_count`,`account_ref`,`conversation_ref`,`message_ref`,`target_ref`];function tableHasCanonicalColumns(e,t,n,r,i){let a=e.prepare(`PRAGMA table_info(${t})`).all(),o=a.filter(e=>Number(e.pk??0)>0);return a.length===n.length&&a.every((e,t)=>e.name===n[t])&&o.length===1&&o[0]?.name===r&&i.every(e=>a.some(t=>t.name===e&&Number(t.notnull??0)===1))}function tableSql(e,t){let n=e.prepare(`SELECT sql FROM sqlite_master WHERE type = 'table' AND name = ?`).get(t);return typeof n?.sql==`string`?n.sql:void 0}function tableHasUniqueColumns(e,t,n){let r=e.prepare(`PRAGMA index_list(${t})`).all();return n.every(t=>r.some(n=>{if(Number(n.unique??0)!==1||typeof n.name!=`string`)return!1;let r=n.name.replaceAll(`'`,`''`),i=e.prepare(`PRAGMA index_info('${r}')`).all();return i.length===1&&i[0]?.name===t}))}function hasCanonicalAuditEventTable(e,t,n){let r=tableSql(e,`audit_events`)?.toLowerCase();return tableHasCanonicalColumns(e,`audit_events`,t,`sequence`,n)&&typeof r==`string`&&/\bsequence\s+integer\s+primary\s+key\s+autoincrement\b/.test(r)&&tableHasUniqueColumns(e,`audit_events`,[`event_id`,`source_id`])}function hasCanonicalAuditIdentityKeyTable(e){if(!L(e,`audit_identity_keys`))return!1;let t=tableSql(e,`audit_identity_keys`)?.toLowerCase();return tableHasCanonicalColumns(e,`audit_identity_keys`,[`id`,`key_id`,`key`,`created_at`],`id`,[`id`,`key_id`,`key`,`created_at`])&&typeof t==`string`&&/\bcheck\s*\(\s*id\s*=\s*1\s*\)/.test(t)}function hasCanonicalAuditEventsSchema(e){let t=P(e);return t&&ca.every(({name:e,sql:n})=>Tt(t.tableSql.get(e)??null)===n)?!0:L(e,`audit_events`)?hasCanonicalAuditEventTable(e,ua,[`event_id`,`source_id`,`schema_version`,`source_sequence`,`occurred_at`,`kind`,`action`,`status`,`actor_type`,`actor_id`])&&hasCanonicalAuditIdentityKeyTable(e):V(e)<2&&!L(e,`audit_identity_keys`)}function canRepairLegacyAuditEventsSchema(e){return!L(e,`audit_events`)||L(e,`audit_events_migration_new`)||R(e,`audit_events`,`schema_version`)?!1:(!L(e,`audit_identity_keys`)||hasCanonicalAuditIdentityKeyTable(e))&&hasCanonicalAuditEventTable(e,la,[`event_id`,`source_id`,`source_sequence`,`occurred_at`,`kind`,`action`,`status`,`actor_type`,`actor_id`,`agent_id`,`run_id`])}const da=[`skill_curator_state`,`update_check_state`,`clawhub_promotions_feed_state`,`model_catalog_remote`,`voicewake_triggers`,`voicewake_routing_routes`,`voicewake_routing_config`,`onboarding_recommendations`,`cron_store_epochs`,`tui_last_sessions`,`sidebar_sections`,`node_host_config`,`web_push_vapid_keys`];function createStateConfigMachineTable(e){e.exec(`
CREATE TABLE IF NOT EXISTS config_machine_state (
state_key TEXT NOT NULL PRIMARY KEY,
value_json TEXT NOT NULL,
updated_at_ms INTEGER NOT NULL
) STRICT;
`)}function migrateSingletonStateFoldInV12(e,t){if(t>=12)return!1;createStateConfigMachineTable(e);let n=e.prepare(`INSERT INTO config_machine_state (state_key, value_json, updated_at_ms) VALUES (?, ?, ?) ON CONFLICT(state_key) DO NOTHING`);if(L(e,`update_check_state`)){let t=e.prepare(`SELECT * FROM update_check_state WHERE state_key = 'default'`).get();t&&n.run(`update.checkState`,JSON.stringify({lastCheckedAt:t.last_checked_at??void 0,lastNotifiedVersion:t.last_notified_version??void 0,lastNotifiedTag:t.last_notified_tag??void 0,lastAvailableVersion:t.last_available_version??void 0,lastAvailableTag:t.last_available_tag??void 0,autoInstallId:t.auto_install_id??void 0,autoFirstSeenVersion:t.auto_first_seen_version??void 0,autoFirstSeenTag:t.auto_first_seen_tag??void 0,autoFirstSeenAt:t.auto_first_seen_at??void 0,autoLastAttemptVersion:t.auto_last_attempt_version??void 0,autoLastAttemptAt:t.auto_last_attempt_at??void 0,autoLastSuccessVersion:t.auto_last_success_version??void 0,autoLastSuccessAt:t.auto_last_success_at??void 0}),Number(t.updated_at_ms))}if(L(e,`voicewake_triggers`)){let t=e.prepare(`SELECT trigger, updated_at_ms FROM voicewake_triggers WHERE config_key = 'default' ORDER BY position`).all();t.length>0&&n.run(`voicewake.triggers`,JSON.stringify(t.map(e=>e.trigger)),Math.max(...t.map(e=>Number(e.updated_at_ms))))}if(L(e,`voicewake_routing_config`)){let t=e.prepare(`SELECT * FROM voicewake_routing_config WHERE config_key = 'default'`).get();if(t){let r=L(e,`voicewake_routing_routes`)?e.prepare(`SELECT trigger, target_mode, target_agent_id, target_session_key FROM voicewake_routing_routes WHERE config_key = 'default' ORDER BY position`).all():[],targetFromColumns=(e,t,n)=>e===`agent`&&typeof t==`string`&&t?{agentId:t}:e===`session`&&typeof n==`string`&&n?{sessionKey:n}:{mode:`current`};n.run(`voicewake.routing`,JSON.stringify({version:1,defaultTarget:targetFromColumns(t.default_target_mode,t.default_target_agent_id,t.default_target_session_key),routes:r.map(e=>({trigger:e.trigger,target:targetFromColumns(e.target_mode,e.target_agent_id,e.target_session_key)})),updatedAtMs:t.updated_at_ms}),Number(t.updated_at_ms))}}if(L(e,`onboarding_recommendations`)){let t=e.prepare(`SELECT * FROM onboarding_recommendations`).all();for(let e of t)n.run(`onboarding.recommendations.${String(e.config_key)}`,JSON.stringify({inventoryHash:e.inventory_hash,matches:JSON.parse(String(e.matches_json)),offeredAt:e.offered_at_ms,acceptedAt:e.accepted_at_ms,updatedAt:e.updated_at_ms}),Number(e.updated_at_ms))}if(L(e,`sidebar_sections`)){let t=e.prepare(`SELECT section_id FROM sidebar_sections ORDER BY position, section_id`).all();t.length>0&&n.run(`sidebar.sectionOrder`,JSON.stringify(t.map(e=>e.section_id)),Date.now())}if(L(e,`node_host_config`)){let t=e.prepare(`SELECT * FROM node_host_config WHERE config_key = 'current'`).get();if(t){let e={host:t.gateway_host??void 0,port:t.gateway_port??void 0,tls:t.gateway_tls==null?void 0:t.gateway_tls===1,tlsFingerprint:t.gateway_tls_fingerprint??void 0,contextPath:t.gateway_context_path??void 0,cloudflareAccess:t.gateway_cloudflare_access_json==null?void 0:JSON.parse(String(t.gateway_cloudflare_access_json))};n.run(`nodeHost.config`,JSON.stringify({version:t.version,nodeId:t.node_id,...t.display_name==null?{}:{displayName:t.display_name},gateway:Object.values(e).some(e=>e!==void 0)?e:void 0,installedAppsSharing:t.installed_apps_sharing===1}),Number(t.updated_at_ms))}}if(L(e,`web_push_vapid_keys`)){let t=e.prepare(`SELECT * FROM web_push_vapid_keys WHERE key_id = 'default'`).get();t&&n.run(`webPush.vapidKeys`,JSON.stringify({publicKey:t.public_key,privateKey:t.private_key,subject:t.subject}),Number(t.updated_at_ms))}let r=!1;for(let t of da)L(e,t)&&(e.exec(`DROP TABLE IF EXISTS ${t};`),r=!0);return r}const fa=`explicit`,pa=`ambient-group`,ma=`ambient-group-watch:`,ha=`ambient-group-watch;`,ga=`provenance TEXT NOT NULL DEFAULT '${fa}' CHECK (provenance IN ('${fa}', '${pa}'))`;function getSessionWatchCursorKysely(e){return k(e)}function hasLegacyAmbientWatchSentinels(e){return A(e,getSessionWatchCursorKysely(e).selectFrom(`session_watch_cursors`).select(`watcher_session_key`).where(`watcher_session_key`,`>=`,ma).where(`watcher_session_key`,`<`,ha).limit(1))!==void 0}function needsSessionWatchCursorProvenanceMigration(e,t){return L(e,`session_watch_cursors`)?t<4||!R(e,`session_watch_cursors`,`provenance`)||hasLegacyAmbientWatchSentinels(e):!1}function decodeLegacyAmbientWatchMarkerKey(e){let t=e.slice(20);if(t&&t.length%2==0&&/^[0-9a-f]+$/.test(t))try{return new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0}).decode(Buffer.from(t,`hex`))}catch{return}}function migrateSessionWatchCursorProvenance(e){if(!L(e,`session_watch_cursors`))return{migratedAmbientWatches:0,removedLegacySentinels:0};I(e,`session_watch_cursors`,ga);let t=getSessionWatchCursorKysely(e),n=j(e,t.selectFrom(`session_watch_cursors`).select([`watcher_session_key`,`target_session_key`,`updated_at`]).where(`watcher_session_key`,`>=`,ma).where(`watcher_session_key`,`<`,ha)).rows,r=0;for(let i of n){let n=decodeLegacyAmbientWatchMarkerKey(i.watcher_session_key);if(n){let a=A(e,t.selectFrom(`session_watch_cursors`).select(`updated_at`).where(`watcher_session_key`,`=`,n).where(`target_session_key`,`=`,i.target_session_key));if(a){let o=j(e,t.updateTable(`session_watch_cursors`).set({provenance:pa,updated_at:Math.max(a.updated_at,i.updated_at)}).where(`watcher_session_key`,`=`,n).where(`target_session_key`,`=`,i.target_session_key));r+=Number(o.numAffectedRows??0n)}}j(e,t.deleteFrom(`session_watch_cursors`).where(`watcher_session_key`,`=`,i.watcher_session_key).where(`target_session_key`,`=`,i.target_session_key))}return{migratedAmbientWatches:r,removedLegacySentinels:n.length}}const _a=`
id TEXT NOT NULL PRIMARY KEY,
agent_id TEXT NOT NULL,
session_key TEXT NOT NULL,
channel TEXT NOT NULL,
account_id TEXT,
recipient_id TEXT,
thread_id TEXT,
sender_id TEXT,
kind TEXT NOT NULL,
sensitivity TEXT NOT NULL,
source TEXT NOT NULL,
status TEXT NOT NULL,
reason TEXT NOT NULL,
suggested_text TEXT NOT NULL,
dedupe_key TEXT NOT NULL,
confidence REAL NOT NULL,
due_earliest_ms INTEGER NOT NULL,
due_latest_ms INTEGER NOT NULL,
due_timezone TEXT NOT NULL,
source_message_id TEXT,
source_run_id TEXT,
created_at_ms INTEGER NOT NULL,
updated_at_ms INTEGER NOT NULL,
attempts INTEGER NOT NULL,
last_attempt_at_ms INTEGER,
sent_at_ms INTEGER,
dismissed_at_ms INTEGER,
snoozed_until_ms INTEGER,
expired_at_ms INTEGER,
record_json TEXT NOT NULL
`,va=`CREATE INDEX idx_commitments_scope_due
ON commitments(agent_id, session_key, status, due_earliest_ms, due_latest_ms);
CREATE INDEX idx_commitments_status_due
ON commitments(status, due_earliest_ms, due_latest_ms);
CREATE INDEX idx_commitments_scope_dedupe
ON commitments(agent_id, session_key, channel, dedupe_key, status);`,ya=`
CREATE TABLE commitments (${_a.slice(1,-1)}
) STRICT;
${va}
CREATE INDEX idx_commitments_agent_due
ON commitments(agent_id, status, due_earliest_ms, due_latest_ms, session_key);
CREATE INDEX idx_commitments_agent_sent
ON commitments(agent_id, status, sent_at_ms, session_key);
`,ba=`
CREATE TABLE commitments (${_a.slice(1,-1)}
);
${va}
`,xa=pt(`state/db`),logRetiredStateTableMigration=e=>xa.info(e),Sa=[`agent_model_catalogs`,`android_notification_recent_packages`,`command_log_entries`,`diagnostic_stability_bundles`,`media_blobs`,`model_capability_cache`],Ca=[`commitments.account_id`,`commitments.recipient_id`,`commitments.thread_id`,`commitments.sender_id`,`commitments.kind`,`commitments.sensitivity`,`commitments.source`,`commitments.reason`,`commitments.suggested_text`,`commitments.dedupe_key`,`commitments.confidence`,`commitments.due_timezone`,`commitments.source_message_id`,`commitments.source_run_id`,`commitments.created_at_ms`,`commitments.attempts`,`commitments.last_attempt_at_ms`,`commitments.sent_at_ms`,`commitments.dismissed_at_ms`,`commitments.snoozed_until_ms`,`commitments.expired_at_ms`];function deriveRetiredCommitmentsContract(){let e=new Map(Mn(ya).map(({fingerprint:e,name:t})=>[t,JSON.stringify(e)]));return{indexFingerprints:e,compatibility:{allowedColumnDefinitions:{"commitments.attempts":[`attempts INTEGER NOT NULL DEFAULT 0`],"commitments.confidence":[`confidence REAL NOT NULL DEFAULT 0`],"commitments.created_at_ms":[`created_at_ms INTEGER NOT NULL DEFAULT 0`],"commitments.dedupe_key":[`dedupe_key TEXT NOT NULL DEFAULT ''`],"commitments.due_timezone":[`due_timezone TEXT NOT NULL DEFAULT 'UTC'`],"commitments.kind":[`kind TEXT NOT NULL DEFAULT 'followup'`],"commitments.reason":[`reason TEXT NOT NULL DEFAULT ''`],"commitments.sensitivity":[`sensitivity TEXT NOT NULL DEFAULT 'normal'`],"commitments.source":[`source TEXT NOT NULL DEFAULT 'unknown'`],"commitments.suggested_text":[`suggested_text TEXT NOT NULL DEFAULT ''`]},allowedMissingColumns:Ca,allowedMissingIndexes:[...e.keys()]}}}function hasSupportedRetiredCommitmentsSchema(e,t,{compatibility:n,indexFingerprints:r}){return Nn(e,t,n).length>0?!1:e.prepare(`SELECT type, name
FROM sqlite_schema
WHERE type IN ('index', 'trigger')
AND tbl_name = 'commitments'
AND sql IS NOT NULL
ORDER BY type, name`).all().every(t=>t.type===`index`&&JSON.stringify(Ln(e,t.name))===r.get(t.name))}function assertRecognizedRetiredCommitmentsSchema(e){if(!hasRecognizedRetiredCommitmentsSchema(e))throw Rn(e,`retired OpenClaw commitments schema`,ya,deriveRetiredCommitmentsContract().compatibility),Error(`Retired OpenClaw commitments schema has unsupported additional indexes; refusing destructive migration.`)}function hasRecognizedRetiredCommitmentsSchema(e){let t=deriveRetiredCommitmentsContract();return hasSupportedRetiredCommitmentsSchema(e,ya,t)||hasSupportedRetiredCommitmentsSchema(e,ba,t)}function assertNoRetiredCommitmentsForeignKeys(e){let t=e.prepare(`SELECT name
FROM sqlite_schema
WHERE type = 'table' AND name <> 'commitments'
ORDER BY name`).all();for(let n of t)if(e.prepare(`PRAGMA foreign_key_list(${M(n.name)})`).all().some(e=>typeof e.table==`string`&&e.table.toLowerCase()===`commitments`))throw Error(`Retired OpenClaw commitments schema is referenced by table ${n.name}; refusing destructive migration.`)}function collectRetainedSchemaSql(e){return new Map(e.prepare(`SELECT type, name, sql
FROM sqlite_schema
WHERE type IN ('trigger', 'view')
AND tbl_name <> 'commitments'
AND sql IS NOT NULL
ORDER BY type, name`).all().map(e=>[`${e.type}:${e.name}`,e.sql]))}function assertNoRetiredCommitmentsSchemaDependencies(e){let t=`__openclaw_retired_commitments_probe`;if(L(e,t))throw Error(`OpenClaw state database already contains ${t}; refusing destructive migration.`);let n=collectRetainedSchemaSql(e),r=`openclaw_probe_commitments_dependencies`;e.exec(`SAVEPOINT ${r};`);let i;try{e.exec(`ALTER TABLE commitments RENAME TO ${M(t)};`);let r=collectRetainedSchemaSql(e);i=[...n].find(([e,t])=>r.get(e)!==t)?.[0]}catch(t){throw e.exec(`ROLLBACK TO ${r}; RELEASE ${r};`),Error(`Could not prove retained SQLite views and triggers independent of commitments; refusing destructive migration.`,{cause:t})}if(e.exec(`ROLLBACK TO ${r}; RELEASE ${r};`),i){let[e,t]=i.split(`:`,2);throw Error(`Retired OpenClaw commitments schema is referenced by ${e} ${t}; refusing destructive migration.`)}}function assertVirtualTablesUsable(e,t){let n=e.prepare(`SELECT name
FROM sqlite_schema
WHERE type = 'table' AND lower(sql) LIKE 'create virtual table%'
ORDER BY name`).all();for(let r of n)try{e.prepare(`SELECT * FROM ${M(r.name)} LIMIT 1`).all()}catch(e){throw Error(`SQLite virtual table ${r.name} is unusable ${t} commitments retirement.`,{cause:e})}}function migrateRetiredCommitmentsSchema(e,t){if(t>=7||!L(e,`commitments`))return!1;assertRecognizedRetiredCommitmentsSchema(e),assertNoRetiredCommitmentsForeignKeys(e),assertNoRetiredCommitmentsSchemaDependencies(e),assertVirtualTablesUsable(e,`before`);let n=`openclaw_retire_commitments_v7`;e.exec(`SAVEPOINT ${n};`);try{return e.exec(`DROP TABLE commitments;`),assertVirtualTablesUsable(e,`after`),e.exec(`RELEASE ${n};`),!0}catch(t){throw e.exec(`ROLLBACK TO ${n}; RELEASE ${n};`),t}}function migrateRetiredDeadStateTablesV10(e,t){if(t>=10)return!1;let n=!1;for(let t of Sa)L(e,t)&&(e.exec(`DROP TABLE IF EXISTS ${t};`),n=!0);return n}const wa=[`skill_lifecycle`,`skill_workshop_proposal_origin_runs`];function migrateRetiredSkillCuratorTablesV11(e,t){if(t>=11)return!1;let n=wa.filter(t=>L(e,t));if(n.length===0)return!1;if(n.includes(`skill_lifecycle`)){let t=Number(e.prepare(`SELECT COUNT(*) AS archived_count FROM skill_lifecycle WHERE state = 'archived'`).get()?.archived_count);t>0&&xa.info(`${t} previously archived workshop skills are live again; archive any you no longer want`)}for(let t of n)e.exec(`DROP TABLE IF EXISTS ${t};`);return!0}function runRetiredStateTableMigrations(e,t){let n=[];return migrateRetiredCommitmentsSchema(e,t)&&n.push(`Discarded retired shared-state commitments rows, table, and indexes`),migrateRetiredDeadStateTablesV10(e,t)&&n.push(`Retired six dead shared-state tables (v10)`),migrateRetiredSkillCuratorTablesV11(e,t)&&n.push(`Retired legacy skill curator lifecycle and proposal origin-run tables`),n}const Ta={"agent-databases-composite-primary-key":[`agent_databases`],"audit-events-v2":[`audit_events`,`audit_identity_keys`],"commitments-retirement-v7":[`commitments`],"worker-placement-execution-mode-v8":[`worker_session_placements`],"agent-databases-relative-paths-v9":[`agent_databases`],"state-table-retirement-v10":Sa,"state-table-retirement-v11":wa,"singleton-state-foldin-v12":[`config_machine_state`,...da],"state-consolidation-v13":[`cron_jobs`,`subagent_runs`,`workspace_setup_state`,`workspace_attestations`,`workspace_generated_bootstrap_hashes`,`auth_profile_stores`,`auth_profile_state`,`installed_plugin_index`,`config_machine_state`,`diagnostic_events`],"creator-namespace-v14":[`cron_jobs`],"conversation-binding-targets-v15":[`current_conversation_bindings`],"prepared-worker-ownership-v17":[`worker_environments`],"github-publication-requester-authority-v18":[`github_publication_session_lifecycles`,`github_repository_publication_requests`],"meeting-transcript-start-time":[`meeting_transcript_sessions`],"portable-identity-columns-v22":[`acp_sessions`,...Z],"task-run-indexes-v24":[],"subagent-operator-recovery-v25":[],"session-state-head-layout-v26":[],"state-write-indexes-v27":[],"github-publication-draft-v28":[`github_publication_requests`,`github_personal_publication_requests`,`github_repository_publication_requests`],"local-client-credentials-v29":[`device_identities`,`device_auth_tokens`,`gateway_origin_device_tokens`,`exec_approvals_config`],"predicate-columns-v21":[`meeting_transcript_sessions`,`meeting_transcript_summaries`,`delivery_queue_entries`],"automation-policy-fence-v30":[`cron_jobs`],"local-workspace-manifests-v31":[`local_workspace_projections`,`local_workspace_manifest_nodes`],"local-workspace-cas-v35":[`local_workspace_projections`,`local_workspace_tree_packs`,`local_workspace_source_path_sets`],"template-names-v36":[...Vn.flat(),`agent_provenance`],"worker-resource-receipts-v37":[`worker_environments`],"repository-disk-authority-v38":[`session_repository_workspaces`,`worker_workspace_pending_results`],"operator-approvals-system-agent":[`operator_approvals`],"session-watch-cursor-provenance-v4":[`session_watch_cursors`],"strict-tables-v3":v.split(`
`).flatMap(e=>{let t=/^CREATE TABLE IF NOT EXISTS (\w+) \(/u.exec(e)?.[1];return t?[t]:[]})};function dropLegacyStateTables(e){e.exec(`DROP TABLE IF EXISTS database_verifications;`),e.exec(`DROP TABLE IF EXISTS node_pairing_pending; DROP TABLE IF EXISTS node_pairing_paired;`)}function migrateWorkerPlacementExecutionModeSchema(e,t){if(t>=8||!L(e,`worker_session_placements`))return!1;for(let t of[`execution_mode TEXT`,`terminal_reason TEXT`,`terminal_at_ms INTEGER`])I(e,`worker_session_placements`,t);let n=N(v,`worker_session_placements`,{errorMessage:`Canonical worker placement schema block is missing`}),r=Ht(`:memory:`),i;try{r.exec(n),i=r.prepare(`PRAGMA table_xinfo(worker_session_placements)`).all().filter(e=>e.hidden===0).map(e=>e.name)}finally{r.close()}let a=e.prepare(`PRAGMA table_xinfo(worker_session_placements)`).all().filter(e=>e.hidden===0).map(e=>e.name),o=new Set(i);if(a.length!==i.length||a.some(e=>!o.has(e)))throw Error(`OpenClaw v7 worker placement columns are not canonical`);if(e.prepare(`SELECT type, name
FROM sqlite_schema
WHERE tbl_name = 'worker_session_placements'
AND type IN ('index', 'trigger')
AND sql IS NOT NULL
AND name NOT IN (
'idx_worker_session_placements_session_key',
'idx_worker_session_placements_reconcile',
'idx_worker_session_placements_environment'
)`).all().length>0)throw Error(`OpenClaw v7 worker placement schema has unsupported attached objects`);let s=`worker_session_placements_migration_v8`;if(L(e,s))throw Error(`OpenClaw worker placement migration table already exists: ${s}`);let c=n.replace(`CREATE TABLE IF NOT EXISTS worker_session_placements`,`CREATE TABLE ${s}`),l=i.map(M).join(`, `);return e.exec(c),e.exec(`INSERT INTO ${s} (${l}) SELECT ${l} FROM worker_session_placements;`),e.exec(`DROP TABLE worker_session_placements;`),e.exec(`ALTER TABLE ${s} RENAME TO worker_session_placements;`),!0}function isDefaultAgentDatabasePath(e,t){let n=W.dirname(e),r=W.dirname(n);return W.basename(e)===`openclaw-agent.sqlite`&&W.basename(n)===`agent`&&W.basename(r)===t&&W.basename(W.dirname(r))===`agents`}function migrateAgentDatabaseRelativePaths(e,t,n){if(t>=9||!L(e,`agent_databases`))return{relativized:0,reanchored:[],deleted:[],preserved:0};let r=e.prepare(`SELECT agent_id, path FROM agent_databases`).all(),i=e.prepare(`UPDATE agent_databases SET path = ? WHERE agent_id = ? AND path = ?`),a=e.prepare(`DELETE FROM agent_databases WHERE agent_id = ? AND path = ?`),o=e.prepare(`SELECT 1 FROM agent_databases WHERE agent_id = ? AND path = ? LIMIT 1`),s=e.prepare(`
UPDATE agent_databases AS canonical
SET schema_version = source.schema_version,
last_seen_at = source.last_seen_at,
size_bytes = source.size_bytes
FROM agent_databases AS source
WHERE canonical.agent_id = ? AND canonical.path = ?
AND source.agent_id = canonical.agent_id AND source.path = ?
AND source.last_seen_at > canonical.last_seen_at
`),c=0,l=[],u=[];for(let e of r){let t=e.agent_id,r=e.path;if(typeof t!=`string`||typeof r!=`string`)throw Error(`OpenClaw v8 agent database registry paths are not canonical`);if(!W.isAbsolute(r))continue;let l=je(n,r);W.isAbsolute(l)||(o.get(t,l)?(s.run(t,l,r),a.run(t,r),u.push(r)):(i.run(l,t,r),c+=1))}let d=Me(n);for(let e of r){let t=e.agent_id,r=e.path;if(typeof t==`string`&&typeof r==`string`&&W.isAbsolute(r)&&W.isAbsolute(je(n,r))&&isDefaultAgentDatabasePath(W.resolve(r),t)){let e=W.join(d,`agents`,t,`agent`,`openclaw-agent.sqlite`),s=je(n,e);o.get(t,s)?(a.run(t,r),u.push(r)):hr(e)&&(i.run(s,t,r),l.push(r))}}return{relativized:c,reanchored:l,deleted:u,preserved:r.length-c-l.length-u.length}}function assertCanonicalAgentDatabasesPrimaryKey(e,t){if(!L(e,`agent_databases`))return;let n=dn(e,`agent_databases`);if(n.length!==2||n[0]!==`agent_id`||n[1]!==`path`)throw new F(`OpenClaw state database ${t} has an unsupported agent database registry schema. Upgrades from pre-July-2026 state are no longer migrated; restore a backup produced by a July 2026 or newer release before retrying.`)}function repairLegacyGatewayRestartHandoffsForStrictMigration(e){L(e,`gateway_restart_handoff`)&&(e.prepare(`DELETE FROM gateway_restart_handoff WHERE expires_at <= ?`).run(Date.now()),e.exec(`
UPDATE gateway_restart_handoff
SET
restart_trace_started_at = CASE
WHEN typeof(restart_trace_started_at) = 'real'
THEN CAST(restart_trace_started_at AS INTEGER)
ELSE restart_trace_started_at
END,
restart_trace_last_at = CASE
WHEN typeof(restart_trace_last_at) = 'real'
THEN CAST(restart_trace_last_at AS INTEGER)
ELSE restart_trace_last_at
END
WHERE typeof(restart_trace_started_at) = 'real'
OR typeof(restart_trace_last_at) = 'real';
`))}function assertCanonicalStateSchemaShape(e,t){if(tr(e,t),assertCanonicalAgentDatabasesPrimaryKey(e,t),!hasCanonicalAuditEventsSchema(e))throw canRepairLegacyAuditEventsSchema(e)?new vn(`audit-events-v2`,t):new F(`OpenClaw state database ${t} has a noncanonical audit event schema that cannot be repaired automatically; restore the canonical audit_events shape before retrying.`)}function detectOpenClawStateDatabaseSchemaMigrationsFromDatabase(e,t){assertCanonicalAgentDatabasesPrimaryKey(e,t);let n=[],r=ar(e);return r<7&&L(e,`commitments`)&&hasRecognizedRetiredCommitmentsSchema(e)&&n.push({kind:`commitments-retirement-v7`,path:t}),r===7&&L(e,`worker_session_placements`)&&n.push({kind:`worker-placement-execution-mode-v8`,path:t}),r===8&&L(e,`agent_databases`)&&n.push({kind:`agent-databases-relative-paths-v9`,path:t}),r<10&&Sa.some(t=>L(e,t))&&n.push({kind:`state-table-retirement-v10`,path:t}),r<11&&wa.some(t=>L(e,t))&&n.push({kind:`state-table-retirement-v11`,path:t}),r<12&&da.some(t=>L(e,t))&&n.push({kind:`singleton-state-foldin-v12`,path:t}),r<13&&(R(e,`cron_jobs`,`schedule_kind`)||R(e,`subagent_runs`,`task`)||L(e,`workspace_attestations`)||L(e,`installed_plugin_index`)||L(e,`auth_profile_stores`))&&n.push({kind:`state-consolidation-v13`,path:t}),r<14&&L(e,`cron_jobs`)&&n.push({kind:`creator-namespace-v14`,path:t}),r<15&&(R(e,`current_conversation_bindings`,`target_agent_id`)||R(e,`current_conversation_bindings`,`target_session_id`))&&n.push({kind:`conversation-binding-targets-v15`,path:t}),r<17&&L(e,`worker_environments`)&&!R(e,`worker_environments`,`preparation_consumed_at_ms`)&&n.push({kind:`prepared-worker-ownership-v17`,path:t}),r<18&&[`github_publication_session_lifecycles`,`github_repository_publication_requests`].some(t=>L(e,t)&&!R(e,t,`requester_authority_json`))&&n.push({kind:`github-publication-requester-authority-v18`,path:t}),r<21&&[`meeting_transcript_sessions`,`meeting_transcript_summaries`,`delivery_queue_entries`].some(t=>L(e,t))&&n.push({kind:`predicate-columns-v21`,path:t}),r<22&&[`acp_sessions`,...Z].some(t=>L(e,t))&&n.push({kind:`portable-identity-columns-v22`,path:t}),r<23&&L(e,`meeting_transcript_sessions`)&&n.push({kind:`meeting-transcript-start-time`,path:t}),r<24&&L(e,`task_runs`)&&n.push({kind:`task-run-indexes-v24`,path:t}),r<25&&n.push({kind:`subagent-operator-recovery-v25`,path:t}),r<26&&L(e,`session_state_heads`)&&n.push({kind:`session-state-head-layout-v26`,path:t}),r<27&&n.push({kind:`state-write-indexes-v27`,path:t}),(r<28||Yn(e))&&n.push({kind:`github-publication-draft-v28`,path:t}),r<29&&n.push({kind:`local-client-credentials-v29`,path:t}),r<30&&n.push({kind:`automation-policy-fence-v30`,path:t}),r<31&&n.push({kind:`local-workspace-manifests-v31`,path:t}),r<35&&n.push({kind:`local-workspace-cas-v35`,path:t}),r<36&&n.push({kind:`template-names-v36`,path:t}),r<37&&n.push({kind:`worker-resource-receipts-v37`,path:t}),r<38&&n.push({kind:`repository-disk-authority-v38`,path:t}),hasCanonicalAuditEventsSchema(e)||n.push({kind:`audit-events-v2`,path:t}),L(e,`audit_events`)&&r<3&&n.push({kind:`strict-tables-v3`,path:t}),needsSessionWatchCursorProvenanceMigration(e,r)&&n.push({kind:`session-watch-cursor-provenance-v4`,path:t}),n.push(...Xn(e,t)),n}function assertCurrentStateRuntimeSchema(e,t,n=z(e)){let r=findMissingLazyStateStartupColumn(n);r&&ln(t,[`missing column `+r.tableName+`.`+r.columnName]),assertCanonicalStateSchemaShape(e,t),assertOpenClawStateDatabaseForMaintenance(e,{pathname:t},n),Rn(e,t,v,Q,n)}function assertNoLegacyStateRuntimeRepair(e,t){if(hasLegacyCronRunLogs(e))throw new vn(`legacy-cron-run-logs`,t)}function isOpenClawStateSchemaFastPathEligible(e,t,n){let r=kn(e);if(r)return r.startupReady;let i,a=tt(e,()=>on(e,()=>{let r=H(e,t);if(ar(e)!==40)return!1;let a=Pn(e);if(typeof a!=`number`)throw Error(`Shared-state database ${t} schema version is unavailable.`);assertCurrentStateRuntimeSchema(e,t,z(e)),assertNoLegacyStateRuntimeRepair(e,t);let o=readGatewayOwnerLeaseFromDatabase(e);return o?.state===`live`&&o.pid!==process.pid&&o.stateDatabaseProvenance&&o.stateDatabaseProvenance===readAgentDatabaseLeaseProvenance(t)||(i=_e(e,t,{schemaVersion:a,userVersion:r},n)),!0},{operationLabel:`state.admission.fast-path`}));return i?.(),a&&On(e,!0),a}function assertExistingOpenClawStateRuntimeMetadata(e,t,n){if(kn(e)){let t=Dn(e)?.userVersion;if(t!==void 0)return t}let r=H(e,t,void 0,void 0,n);if(ar(e)!==40)throw Error(`Existing shared-state database ${t} requires schema migration by its owning installation; run openclaw doctor --fix there before using it.`);let i;try{i=A(e,k(e).selectFrom(`schema_meta`).select([`role`,`schema_version`]).where(`meta_key`,`=`,`primary`).limit(1))}catch(t){throw fn(e,`schema_meta`,[`meta_key`,`role`,`schema_version`],t)}if(i?.role!==`global`||i.schema_version!==r)throw Error(`Existing shared-state database ${t} has inconsistent ownership or schema metadata.`);return r}function assertExistingOpenClawStateRuntimeSchema(e,t,n,r,i=`runtime`){let a=kn(e)?P(e):void 0;if(a){_e(e,t,a,n,r)?.();return}let o;tn(e,()=>{let a=assertExistingOpenClawStateRuntimeMetadata(e,t,i),s=Pn(e);if(typeof s!=`number`)throw Error(`Existing shared-state database ${t} schema version is unavailable.`);o=_e(e,t,{schemaVersion:s,userVersion:a},n,r),assertCurrentStateRuntimeSchema(e,t,z(e)),assertNoLegacyStateRuntimeRepair(e,t)},{operationLabel:`state.admission.existing-schema`}),o?.(),On(e,!0)}function assertStateDatabaseSchemaAdmission(e){if(y(e.path,e.db)){let t=xn(e.db)?.canonicalPath;if(!t)throw Error(`Existing shared-state schema admission requires a filesystem-backed database.`);if(!y(t,e.db))throw Error(`Existing shared-state schema admission requires its selected physical database.`);if(E(e.db)){H(e.db,e.path);return}assertExistingOpenClawStateRuntimeSchema(e.db,e.path)}}function assertStateReadSchemaForPolicy(e,t,n,r,i,a=`runtime`){E(e)?(r!==void 0&&Pt(`postgres`,`integrity`),H(e,t,void 0,i,a)):n?assertExistingOpenClawStateRuntimeSchema(e,t,he(),r,a):H(e,t,void 0,i,a)}const Ea=c(Symbol.for(`openclaw.postgresStateReadSnapshot`),()=>new wr),$=/* @__PURE__ */ new Map,Da=/* @__PURE__ */ new WeakSet;let Oa;function retireReader(e){$.get(e.identity.key)===e&&(clearTimeout(e.idleTimer),e.idleTimer=void 0,e.retiring=!0,e.connection.close(),e.quarantineAdmission?.release(),$.delete(e.identity.key),$.size||(Oa?.(),Oa=void 0))}function scheduleReaderRetirement(e){_().explicitSqliteCloseReleasesNativeResources&&$.get(e.identity.key)===e&&(e.idleTimer??=r(()=>setTimeout(()=>{try{retireReader(e)}catch(t){process.emitWarning(`Idle shared-state reader cleanup failed: ${String(t)}`),scheduleReaderRetirement(e)}},bn).unref()),e.idleTimer.refresh())}function closeRetainedOpenClawStateReadConnections(e){let t=[];for(let n of $.values())if(e===void 0||n.identity.key===e)try{retireReader(n)}catch(e){t.push(e)}Oe(t,`Retained shared-state reader cleanup failed.`)}function borrowStateReadConnection(e,t,n){if(isStatePostgres())return openStateReadConnectionResult(e,e,t,void 0,!0);y(e);let r=l(e);t!==void 0&&f(e,t);for(let e of $.values())e.identity.canonicalPath===r.canonicalPath&&e.identity.key!==r.key&&retireReader(e);if(!r.key.startsWith(`file:`))return openStateReadConnectionResult(e,e,t);let i=$.get(r.key);if((i?.retiring||i&&!i.connection.database.db.isOpen)&&(retireReader(i),i=void 0),i?.borrowed)return openStateReadConnectionResult(e,e,r.key);if(!i){let t=openStateReadConnectionResult(e,e,r.key);if(t.status===`unavailable`)return t;i={connection:t.value,identity:r,retiring:!1,borrowed:!1},$.set(r.key,i),Oa??=xe(closeRetainedOpenClawStateReadConnections)}let a=i;if(a.quarantineAdmission?.location!==n||!a.quarantineAdmission?.isCurrent()){a.quarantineAdmission?.release(),a.quarantineAdmission=void 0;try{a.quarantineAdmission=n?p(n):void 0}catch{}}return Ne(a),a.borrowed=!0,{status:`available`,value:{database:{db:a.connection.database.db,path:e},close(e){return a.borrowed=!1,e&&a.connection.database.db.isOpen&&!a.connection.database.db.isTransaction?scheduleReaderRetirement(a):retireReader(a),!0}}}}var SnapshotCleanupIncompleteError=class extends Error{};function assertStateReadSchema(e,t,n,r=`runtime`){assertStateReadSchemaForPolicy(e,t,y(t,e),n,void 0,r)}function withOpenClawStateReadOnlyLocation(e,t,n,r,i,a,o=!1,s,c){let l=readOpenClawStateReadOnlyLocation(e,t,n,r,i,a,o,s,c);if(l.status===`unavailable`)throw l.error;return l.value}function readOpenClawStateReadOnlyLocation(e,t,n,r,i,a,o=!1,s,c){let l=typeof n!=`string`&&`connection`in n?n.connection:void 0,u=typeof n!=`string`&&`connection`in n?n.location:n,d=l?{status:`available`,value:l}:o&&u===t&&!a?borrowStateReadConnection(t,i,c):openStateReadConnectionResult(t,u,i,a,!0);if(d.status===`unavailable`)return d;let f=d.value,p=[],m,h;try{r&&!E(f.database.db)&&(m=r(f.database.db));let n=y(t,f.database.db),i=r?`doctor-maintenance`:`runtime`;try{let r=!1,a=Ea.getStore(),read=()=>It(f.database.db,()=>{or(f.database.db,t,i),assertStateReadSchemaForPolicy(f.database.db,t,n,void 0,s,i),r=!0;let a=e(f.database);if(u===t&&pe(a))throw new Ce(`SQLite source read must remain synchronous`);return a});h={status:`available`,value:withPostgresSchemaAdmissionRetry(f.database.db,()=>E(f.database.db)?f.database.db.runTransaction(()=>(a?.path===t&&f.database.db.exec(`SET TRANSACTION SNAPSHOT '${a.snapshot.replaceAll(`'`,`''`)}'`),read()),void 0,!0):l&&u===t?tn(f.database.db,read):read(),()=>!r&&a?.path!==t)}}catch(e){!E(f.database.db)&&ee(e)&&(ge(f.database.db),Da.add(f.database.db)),h={status:`unavailable`,error:e}}sn(f.database.db)}catch(e){p.push(e)}try{m?.()}catch(e){p.push(e)}try{let e=typeof n!=`string`&&p.length===0&&h?.status===`available`&&!_().explicitSqliteCloseReleasesNativeResources;if(!l&&!f.close(p.length===0&&h?.status===`available`&&!Da.has(f.database.db))&&!e)throw new SnapshotCleanupIncompleteError(`Shared-state snapshot cleanup is incomplete.`)}catch(e){p.push(e)}return p.length&&(h?.status===`unavailable`&&!p.includes(h.error)&&p.unshift(h.error),Oe(p,`Shared-state read and reader cleanup failed.`)),h}function openOpenClawStateReadOnlyLocation(e,t){let n=openOpenClawStateReadConnection(e,t);try{It(n.database.db,()=>{or(n.database.db,e),assertStateReadSchema(n.database.db,e)})}catch(e){try{n.close()}catch(t){Oe([e,t],`Shared-state reader admission and cleanup failed.`)}throw e}return n}function openOpenClawStateReadConnection(e,t,n,r){let i=openStateReadConnectionResult(e,t,n,r);if(i.status===`unavailable`)throw i.error;return i.value}function openStateReadConnectionResult(e,t,n,r,i=!1){let a=typeof t==`string`?void 0:t,o=typeof t==`string`?t:t.location,s=m(o),c={readOnly:!0,timeout:ze},l,cleanupFailedOpen=e=>{let t=[e];try{l?.()}catch(e){t.push(e)}try{a&&!a.cleanup()&&t.push(new SnapshotCleanupIncompleteError(`Shared-state snapshot cleanup is incomplete.`))}catch(e){t.push(e)}if(t.length>1)throw Se(t,`Shared-state reader open and cleanup failed.`,e)},u;try{if(isStatePostgres()){(t!==e||r)&&assertStateFileSnapshotAllowed(),i&&y(e);let a=openExistingStatePostgresConnection(e,n);if(a)return{status:`available`,value:a}}if(n!==void 0&&f(s,n),l=r?vt(r):void 0,i&&y(e),o===e)u=Sn(e,c);else try{u={status:`available`,database:Ht(o,c)}}catch(e){u={status:`unavailable`,error:e}}}catch(e){throw cleanupFailedOpen(e),e}if(u.status===`unavailable`)return cleanupFailedOpen(u.error),u;let d=u.database,p=!1,h=!1,g=0,ee={db:d,path:e,afterClose:()=>{if(l?.(),a&&g===0&&!a.cleanup())throw new SnapshotCleanupIncompleteError(`Shared-state snapshot cleanup is incomplete.`)}},_={database:{db:d,path:e},snapshotSource:a?{retain(){if(h||p)throw Error(`Shared-state snapshot source is closing or closed`);let e=_t(a.cleanupRoot??W.dirname(a.location));g++;let t=!1;return{location:a.location,cleanupRoot:a.cleanupRoot,async release(){if(t||(t=!0,e(),g--),p&&g===0&&!await a.cleanupAsync())throw new SnapshotCleanupIncompleteError(`Shared-state snapshot cleanup is incomplete.`)}}}}:void 0,close(){if(p)return!1;h=!0;let e=ve.closeOpenClawStateDatabaseHandle(ee);return e.length===1&&e[0]instanceof SnapshotCleanupIncompleteError?!1:(Oe(e,`Shared-state reader cleanup failed.`),p=!0,!0)}};try{at(d),n!==void 0&&f(s,n)}catch(e){try{if(!_.close())throw new SnapshotCleanupIncompleteError(`Shared-state snapshot cleanup is incomplete.`)}catch(t){throw Se([e,t],`Shared-state reader identity and cleanup failed.`,e)}throw e}return{status:`available`,value:_}}function readOnlyStateDatabase(e,t){return{...e,walMaintenance:{checkpoint:()=>!1,stop:async()=>{},reclaimFreePages:createSqliteWalReclamationResult,close:t}}}lr({domain:`session-upstream-presence`,isFact:(e,t)=>t.kind===`absent`||t.kind===`postimage`&&t.value===!0});function parseJson(e){return e===null?null:O(e)??null}function rowToSessionUpstreamLink(e){return{sessionKey:e.session_key,agentId:e.agent_id,catalogId:e.catalog_id,hostId:e.host_id,threadId:e.thread_id,upstreamKind:e.upstream_kind,upstreamRef:parseJson(e.upstream_ref_json),marker:parseJson(e.last_marker_json),...e.last_scanned_at===null?{}:{lastScannedAt:cr(e.last_scanned_at)??0},createdAt:cr(e.created_at)??0,updatedAt:cr(e.updated_at)??0}}const ka={"sessionUpstream.read":(e,t)=>({type:`sessionUpstream.read`,link:readSessionUpstreamLinkInDatabase(t,e.sessionKey,e.agentId)})};function getSessionUpstreamKysely(e){return k(e)}const Aa=Ct(e=>{let t;return ot(nt(e),()=>{t=void 0}),n=>{let r=Lt(e);if(r&&t?.revision===r&&t.sessionKey===n.sessionKey&&t.agentId===n.agentId)return t.row;t=void 0;let i=A(e,getSessionUpstreamKysely(e).selectFrom(`session_upstream_links`).selectAll().where(`session_key`,`=`,n.sessionKey).where(`agent_id`,`=`,n.agentId));return r&&(t={...n,revision:r,row:i}),i}});function readSessionUpstreamLinkInDatabase(e,t,n){let r=Aa(e)({sessionKey:t,agentId:n});return r?rowToSessionUpstreamLink(r):void 0}function createCommittedWorkerMutation(e,t){return(n,{writeAdmitted:r})=>r(({db:r})=>({type:e,result:t(r,n)}),{operationLabel:e,receipt:`result`,transactionEnvironment:`process`}).result}function createWorkerOperationRegistry(e){let t=new Map(Object.entries(e).map(([e,t])=>[e,{load:t}])),domainFor=e=>typeof e==`string`?t.get(e)??t.get(e.slice(0,e.indexOf(`.`))):void 0,handlerFor=e=>{let t=domainFor(e)?.handlers;return t&&Object.hasOwn(t,e)?t[String(e)]:void 0};return{prepare(e){let t=domainFor(e);if(t&&!t.handlers)return t.pending??=Promise.resolve().then(t.load).then(e=>{t.handlers=e})},has(e){return handlerFor(e.type)!==void 0},execute(e,t){let n=handlerFor(e.type);if(!n)throw Error(`Worker operation is not prepared: ${String(e.type)}`);return n(e.input,t)}}}const ja=createWorkerOperationRegistry({durableProcess:()=>import(`./openclaw-state-read-bash-durable-process-store-DOspUzzO.mjs`).then(e=>e.durableProcessReadOperations),workerEnvironments:()=>import(`./openclaw-state-read-store-row-codec-BBFEif2v.mjs`).then(e=>e.n).then(e=>e.workerEnvironmentReadOperations),workers:()=>import(`./openclaw-state-read-placement-read-projection-CsboOx2D.mjs`).then(e=>e.workerPlacementReadOperations),preparedPoolPresence:()=>import(`./openclaw-state-read-prepared-pool-presence-store.worker-BYZYMMNb.mjs`).then(e=>e.preparedPoolPresenceReadOperations),sandboxPersistentExec:()=>import(`./openclaw-state-read-persistent-exec-store.kernel-bPG-81lt.mjs`).then(e=>e.sandboxPersistentExecReadOperations),sandboxRegistry:()=>import(`./openclaw-state-read-registry.kernel-BkGMfMVa.mjs`).then(e=>e.sandboxRegistryReadOperations),worktrees:async()=>{let[{worktreeReadOperations:e},{worktreeTemplateReadOperations:t},{pendingWorktreeReadOperations:n}]=await Promise.all([import(`./openclaw-state-read-registry-read.kernel-Mu3y8MTg.mjs`).then(e=>e.i),import(`./openclaw-state-read-template-registry.worker-lJoZ9s9I.mjs`),import(`./openclaw-state-read-pending-slots.worker-CsspSCq6.mjs`).then(e=>e.t)]);return{...e,...t,...n}},agentProvenance:()=>import(`./openclaw-state-read-agent-provenance.kernel-CHtO0uWo.mjs`).then(e=>e.agentProvenanceReadOperations),managedImages:()=>import(`./openclaw-state-read-managed-image-record-store.kernel-PNIpdrL5.mjs`).then(e=>e.managedImageRecordReadOperations),githubPublications:()=>import(`./openclaw-state-read-github-publication.read.worker-BW9_ECJ_.mjs`).then(e=>e.publicationReadOperations),userGitHubConnections:()=>import(`./openclaw-state-read-user-github-connections.worker-BGtYgQW5.mjs`).then(e=>e.userGitHubConnectionReadOperations),userProfiles:()=>import(`./openclaw-state-read-user-profile-openclaw-id.read-Cx5b2cCG.mjs`).then(e=>e.openClawIdUserProfileReadOperations),stateBootstrap:()=>import(`./openclaw-state-read-state-bootstrap-read.worker-kY7os9bh.mjs`).then(e=>e.stateBootstrapReadOperations),machineState:()=>import(`./openclaw-state-read-config-machine-state.read.worker-D9gBrlOY.mjs`).then(e=>e.machineStateReadOperations),projects:()=>import(`./openclaw-state-read-project-registry.kernel-BP5ur2gU.mjs`).then(e=>e.projectRegistryReadOperations),agentDeletion:()=>import(`./openclaw-state-read-agent-delete-session-store-safety.kernel-BHNAIvyN.mjs`).then(e=>e.agentDeletionSessionStoreReadOperations),agentLifecycle:()=>import(`./openclaw-state-read-agent-lifecycle-read.worker-JSCTRpTK.mjs`).then(e=>e.agentLifecycleReadOperations),agentRecovery:()=>import(`./openclaw-state-read-agent-deletion-recovery.worker-BeyAKqeL.mjs`).then(e=>e.agentRecoveryReadOperations),legacySessionMigration:()=>import(`./openclaw-state-read-legacy-main-session-ledger.read.worker-D2tXgpuk.mjs`).then(e=>e.legacySessionMigrationReadOperations),gatewayBoot:()=>import(`./openclaw-state-read-gateway-boot-lifecycle.kernel-nx6aUM30.mjs`).then(e=>e.gatewayBootReadOperations),localWorkspace:()=>import(`./openclaw-state-read-local-workspace-store.kernel-tdKoWymZ.mjs`).then(e=>e.localWorkspaceReadOperations),config:()=>import(`./openclaw-state-read-io.health-state.kernel-w-C9u44D.mjs`).then(e=>e.configHealthReadOperations),plugins:async()=>{let{deferredPluginMigrationReadOperations:e}=await import(`./openclaw-state-read-deferred-plugin-migrations-BZZEsTs4.mjs`);return{...e,...Nr}},generatedHtmlProvenance:()=>import(`./openclaw-state-read-generated-html-provenance.worker-CF480WuX.mjs`).then(e=>e.generatedHtmlProvenanceReadOperations),pairing:()=>import(`./openclaw-state-read-pairing-store-sqlite-_BFcuNiH.mjs`).then(e=>e.pairingReadOperations),mentions:()=>import(`./openclaw-state-read-mention-inbox.worker-BNdh28jf.mjs`).then(e=>e.mentionReadOperations),skillLibrary:()=>import(`./openclaw-state-read-read.kernel-ifTQH30_.mjs`).then(e=>e.skillLibraryReadOperations),secrets:()=>import(`./openclaw-state-read-secret-store-metadata.kernel-j6OLuWzG.mjs`).then(e=>e.secretStoreReadOperations),sessionState:()=>import(`./openclaw-state-read-session-state-events.read.worker-DmkPrKdT.mjs`).then(e=>e.sessionStateReadOperations),sessionUpstream:async()=>ka,automationProactive:()=>import(`./openclaw-state-read-proactive-job-receipt.read.worker-BciJh9Fy.mjs`).then(e=>e.proactiveJobReceiptReadOperations),diagnostic:async()=>yi,restartLifecycle:()=>import(`./openclaw-state-read-restart-handoff.read.worker-D1vA3H22.mjs`).then(e=>e.restartHandoffReadOperations),restartSentinel:()=>import(`./openclaw-state-read-restart-sentinel.read.worker-X_J1Y6Ej.mjs`).then(e=>e.restartSentinelReadOperations)});async function prepareStateStream(e,t,n,r){if(t.type===`subagents.restore`){let{streamSubagentRegistryInWorker:i}=await import(`./openclaw-state-read-subagent-registry.store.restore.worker-BymGzZv0.mjs`);return async()=>{if(!n)throw Error(`Subagent restore requires a bounded receiver`);let a=await i(e,n,r);return{ok:!0,type:t.type,sourceAdmitted:!0,count:a}}}let{streamTranscriptExportInWorker:i}=await import(`./openclaw-state-read-store-export.worker-Dx-40ORo.mjs`);return async()=>{if(!n)throw Error(`Transcript export requires a bounded receiver`);let a=await i(e,t,n,r);return{ok:!0,type:t.type,sourceAdmitted:!0,result:a}}}const Ma=pt(`sqlite/transaction`),Na=async function read(e,t,r){let i=e,a,o;try{let e=i.command.type===`gatewayOwnerLease.read`?await import(`./openclaw-state-read-gateway-owner-lease.worker-BOXCJ-Zr.mjs`):void 0,n=i.command.type===`agentDatabaseRegistry.read`?await import(`./openclaw-state-read-openclaw-agent-db-registry.read-D1CTFqiu.mjs`).then(e=>e.n):void 0,s=i.command.type===`agentDatabaseDeletion.snapshot`?await import(`./openclaw-state-read-agent-deletion-journal.snapshot.worker-BIOQ3Z8Y.mjs`):void 0,c=i.command.type===`localWorkspace.manifest`?await import(`./openclaw-state-read-local-workspace-manifest-scan-w3CivjIB.mjs`):void 0,l=i.command.type===`subagents.sessionList`?await import(`./openclaw-state-read-subagent-registry.store.sqlite-D-rXP0vw.mjs`):void 0,u=i.command.type===`subagents.restore`||i.command.type===`meetingTranscripts.export`?await prepareStateStream(i,i.command,t,()=>{a=!0}):void 0,d=u!==void 0||i.command.type===`admit`||i.command.type===`plugins.metadata.read`||i.command.type===`gatewayOwnerLease.read`||i.command.type===`localWorkspace.manifest`||i.command.type===`agentDatabaseRegistry.read`||i.command.type===`agentDatabaseDeletion.snapshot`||i.command.type===`subagents.sessionList`,f=d?void 0:ja.prepare(i.command.type);if(f)return f.then(()=>read(i,t,r));let p=d||ja.has(i.command)?void 0:await import(`./openclaw-state-read-openclaw-state-read-handlers-pzSw4079.mjs`).then(e=>e.t),m=i.command.type===`acpSessions.metadata`?(await import(`./openclaw-state-read-session-meta-read.worker-oZLCuwUU.mjs`)).prepareAcpSessionMetadataRead(i.command):void 0,h=p?await p.prepareOpenClawStateRead(i,i.command,m):void 0,executeRead=async()=>{let d=Ae(i.context.environment);i.checkFreshAdmission&&dt({databasePath:i.databasePath,busyTimeoutMs:ze},()=>ve.assertOpenClawStateDatabaseFreshOpenAllowedAtPath(i.databasePath,i.context.environment,e=>{o={error:pn(e,{includeOrdinary:!0})}},!0));let{command:f}=i;if(f.type===`admit`){if(i.exportPostgresSnapshot){if(!t)throw Error(`PostgreSQL discovery snapshot requires its retained receiver`);let e=openOpenClawStateReadConnection(i.databasePath,i.location,i.expectedIdentity),n=e.database.db;try{if(!E(n))throw Error(`PostgreSQL discovery snapshot requires PostgreSQL state`);n.exec(`BEGIN ISOLATION LEVEL REPEATABLE READ READ ONLY`);let e=n.prepare(`SELECT pg_export_snapshot() AS snapshot`).get()?.snapshot;(await t.request(e)).consumed()}finally{try{n.isTransaction&&n.exec(`ROLLBACK`)}finally{e.close()}}}return{ok:!0,type:`admit`}}let p=[i.databasePath,i.location,f.type===`updateRuns.recoveryAdmission`?openDoctorStateSchemaReadAdmission:void 0,i.expectedIdentity,i.snapshotRoot,!0];if(f.type===`localWorkspace.manifest`){if(!c)throw Error(`Local workspace manifest reader is unavailable`);let e=withOpenClawStateReadOnlyLocation(({db:e})=>(a=!0,c.readLocalWorkspaceManifestRows(e,f.input)),...p,void 0,d);return{ok:!0,type:f.type,sourceAdmitted:!0,snapshot:ownedWorkerBytes(pr(fr([e,f.input.action])))}}if(f.type===`plugins.metadata.read`)return{ok:!0,sourceAdmitted:!0,...withOpenClawStateReadOnlyLocation(({db:e})=>(a=!0,Nr[f.type](f.input,e)),...p,void 0,d)};if(f.type===`gatewayOwnerLease.read`){if(!e)throw Error(`Gateway owner lease reader is unavailable`);let t=e.inspectGatewayOwnerLease(i,()=>{a=!0},f.schemaMaintenance);return{ok:!0,type:f.type,sourceAdmitted:!0,lease:t}}if(ja.has(f))return{ok:!0,sourceAdmitted:!0,...withOpenClawStateReadOnlyLocation(({db:e})=>(a=!0,ja.execute(f,e)),...p,void 0,d)};if(f.type===`agentDatabaseDeletion.snapshot`){if(!s)throw Error(`Agent database deletion snapshot reader is unavailable`);let e=withOpenClawStateReadOnlyLocation(({db:e})=>(a=!0,s.readAgentDatabaseDeletionWorkerSnapshot(e,i.databasePath,f.purpose)),...p,void 0,d);return{ok:!0,type:f.type,sourceAdmitted:!0,snapshot:e}}if(f.type===`agentDatabaseRegistry.read`){if(!n)throw Error(`Agent database registry reader is unavailable`);let e=readOpenClawStateReadOnlyLocation(({db:e})=>(a=!0,n.readRegisteredAgentDatabaseRows(e,i.databasePath,!1)),...p,void 0,d);return{ok:!0,type:f.type,sourceAdmitted:a,result:e.status===`available`?{status:`available`,entries:e.value}:{status:`unavailable`}}}if(f.type===`subagents.restore`||f.type===`meetingTranscripts.export`){if(!u)throw Error(`State read stream is unavailable`);return await r.runNativeSection(u)}if(f.type===`subagents.sessionList`){if(!l)throw Error(`Subagent session list reader is unavailable`);let e=readOpenClawStateReadOnlyLocation(({db:e})=>(a=!0,l.loadSubagentSessionListRunsFromSqlite(void 0,{db:e})),...p,void 0,d);if(e.status===`unavailable`&&a!==!0)throw e.error;return e.status===`available`?{ok:!0,type:f.type,sourceAdmitted:!0,runs:e.value}:{ok:!0,type:f.type,sourceAdmitted:!0,unavailable:{message:String(e.error),error:pn(e.error,{includeOrdinary:!0})}}}if(!h)throw Error(`State read command handlers are unavailable`);return{ok:!0,sourceAdmitted:!0,...withOpenClawStateReadOnlyLocation(({db:e})=>(a=!0,h(e)),...p,m?.readContentVersionRow,d)}},g=i.context.databaseEngineSelection??ue(),execute=()=>wt({operation:i.command.type,ownerKind:`worker`},()=>ye(i.context,executeRead),void 0,Ma),run=()=>i.postgresSnapshot?Ea.run({path:i.databasePath,snapshot:i.postgresSnapshot},execute):execute(),ee=await(g?fe(g,run):run());return!_().explicitSqliteCloseReleasesNativeResources&&Ut&&(o??={error:void 0}),o?{...ee,nativeCleanupFailure:o}:ee}catch(e){let t=n(e);return{ok:!1,sourceAdmitted:a,message:t.message,error:pn(t,{includeOrdinary:!0}),...o?{nativeCleanupFailure:o}:{}}}};serveOwnedWorkerTasks(async(e,t,n)=>{try{var r=yt();let i=e,a=i.context.databaseEngineSelection??ue(),o=r.a(a?.postgres&&(i.command.type!==`admit`||i.exportPostgresSnapshot)?(await import(`./openclaw-state-read-bridge-prestart-B9CgKPWu.mjs`)).prepareAdmittedPostgresBridge(i.databasePath,a,{reuse:!0}):void 0),run=()=>Na(e,t,n);return await(o?o.run(run):run())}catch(e){r.e=e}finally{await r.d()}},{closeResource:closeRetainedOpenClawStateReadConnections,transferList:e=>e.ok&&e.type===`localWorkspace.manifest`?[e.snapshot.buffer]:[]});export{backfillCronJobsFromJobJson as $,executeCanonicalStateSchema as A,parseStateLeaseProcessOwner as At,Q as B,readStateSchemaPublicationBlocker as Bt,migrateSessionWatchCursorProvenance as C,ei as Ct,assertMigratedStateTableIntegrity as D,readOpenClawStateLeaseExpiry as Dt,migrateSingletonStateFoldInV12 as E,$r as Et,sa as F,inspectStateSqlite as Ft,inspectOpenClawStateOwnershipFromDatabase as G,reclaimSqliteWalFreePages as Gt,isOpenClawStateStartupRepairableSchemaIssue as H,withPostgresSchemaAdmissionRetry as Ht,writeCurrentStateSchemaMetadata as I,isStatePostgres as It,Oi as J,isOpenClawStateWriteContentionError as K,openDoctorStateSchemaReadAdmission as Kt,resolveSchemaMigrationIntegrityTables as L,openExistingStatePostgresConnection as Lt,migrateBoundedStateSchema as M,admitStatePostgres as Mt,Qi as N,assertStateFileSnapshotAllowed as Nt,assertOpenClawStateDatabaseForMaintenance as O,readOpenClawStateLeaseLoss as Ot,runStateSchemaMigrationTransaction as P,ensureStatePostgresFragment as Pt,backfillAcpReplayEstimatedBytes as Q,qi as R,Xr as Rt,runRetiredStateTableMigrations as S,hasLegacyCronRunLogs as St,createStateConfigMachineTable as T,decodeGatewayOwnerLease as Tt,getOpenClawStateRuntimeSchema as U,stateEngineInput as Ut,isOpenClawStateFirstUseSchemaIssue as V,qr as Vt,assertOpenClawStateWriteAllowed as W,createSqliteWalReclamationResult as Wt,withStateDatabaseSchemaMaintenanceAsync as X,withStateDatabaseSchemaMaintenance as Y,migrateSqliteTableWithoutRowid as Z,dropLegacyStateTables as _,mi as _t,readOnlyStateDatabase as a,hasLiveDeliveryQueueClaim as at,repairLegacyGatewayRestartHandoffsForStrictMigration as b,mayShareAgentDatabaseFile as bt,assertExistingOpenClawStateRuntimeSchema as c,inflateDeliveryQueueRow as ct,assertNoLegacyStateRuntimeRepair as d,xi as dt,backfillCronRunLogEntryJson as et,isOpenClawStateSchemaFastPathEligible as f,buildApprovalResolutionRef as ft,detectOpenClawStateDatabaseSchemaMigrationsFromDatabase as g,migratePredicateColumnsV21 as gt,assertCanonicalStateSchemaShape as h,migrateHistoricalStateImports as ht,openOpenClawStateReadOnlyLocation as i,repairLegacySubagentRetainedResults as it,markCurrentStateSchemaVersion as j,readStateLeaseProcessOwnerStatus as jt,assertOpenClawStateDatabaseOwner as k,Qr as kt,assertStateDatabaseSchemaAdmission as l,loadDeliveryQueueEntryInDatabase as lt,assertCanonicalAgentDatabasesPrimaryKey as m,createSqliteAuditRecordKernel as mt,assertStateReadSchema as n,ensureOperatorApprovalResolutionRefs as nt,withOpenClawStateReadOnlyLocation as o,bindDeliveryQueueEntry as ot,Ta as p,isApprovalResolutionRef as pt,ki as q,ownedWorkerBytes as qt,openOpenClawStateReadConnection as r,repairLegacySubagentExecutionPayloads as rt,Ea as s,deliveryQueueEntriesQuery as st,createCommittedWorkerMutation as t,backfillDeliveryQueueEntriesFromEntryJson as tt,assertCurrentStateRuntimeSchema as u,upsertBoundDeliveryQueueEntryInDatabase as ut,migrateAgentDatabaseRelativePaths as v,pi as vt,pa as w,assertGatewayOwnerLeaseColumns as wt,logRetiredStateTableMigration as x,readAgentDatabaseLeaseProvenance as xt,migrateWorkerPlacementExecutionModeSchema as y,createAgentDatabaseLeaseStaleReasonReader as yt,Ki as z,advanceStateSchemaContentVersion as zt};