UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 3.27 kB
import{a as e}from"./transcript-record-coerce-CPLgmAk9.mjs";import{s as t}from"./transcript-plugin-instance-invocation-7y9lfaeO.mjs";import{o as n,v as r}from"./transcript-sqlite-database-admission-IPmtadyc.mjs";import"./transcript-config-env-vars-DvUkP5Hz.mjs";import{a as i}from"./transcript-state-dir-DEo0wD2Q.mjs";import{a,i as o}from"./transcript-kysely-sync-CAP5xe3V.mjs";import{B as s,H as c,z as l}from"./transcript-openclaw-state-db-cache-kzfc9rd-.mjs";import{i as u}from"./transcript-openclaw-state-db-schema-helpers-B1k_oHgC.mjs";import"./transcript-openclaw-state-db-readonly-DQQE4HMs.mjs";import"./transcript-openclaw-state-worker-store-CPOHVujy.mjs";import{isMainThread as d}from"node:worker_threads";import f from"node:path";const p={name:`auth-profiles.rows`,read:t=>e(t)?t:void 0};function publishAuthProfileRowsChanged(e){r(e,p,{})}const m={name:`model-catalog.remote`,read:t=>e(t)?t:void 0},h={name:`state.tts-prefs-path`,read(t){if(!e(t))return;let n=t.row;if(n===void 0)return{row:void 0};if(e(n)&&typeof n.value_json==`string`&&typeof n.updated_at_ms==`number`)return{row:{value_json:n.value_json,updated_at_ms:n.updated_at_ms}}}};function publishConfigMachineStateRow(e,t,n){t===`tts.prefsPath`?r(e,h,{row:n}):t===`authProfiles.store`||t===`authProfiles.state`?publishAuthProfileRowsChanged(e):(t===`modelCatalog.remote.v3`||t===`modelCatalog.remote.v2`||t===`modelCatalog.remote`)&&r(e,m,{})}function normalizeConfigMachineStateKey(e){let t=e.trim();if(!t)throw Error(`config machine state key must not be empty`);return t}function readConfigMachineStateRowInDatabase(e,t){let r=normalizeConfigMachineStateKey(t),i=r===`tts.prefsPath`?n(e,h):void 0;if(i)return i.row;if(!u(e,`config_machine_state`))return;let s=a(e),c=o(e,s.selectFrom(`config_machine_state`).select([`value_json`,`updated_at_ms`]).where(`state_key`,`=`,r));return d&&r===`tts.prefsPath`&&publishConfigMachineStateRow(e,r,c),c}function readCronStoreStatePathInDatabase(e){let t=readConfigMachineStateRowInDatabase(e,`cron.store`),n=t?JSON.parse(t.value_json):void 0;return typeof n==`string`&&n.trim()?n.trim():void 0}function resolveDefaultCronDir(e){return f.join(t(e),`cron`)}function resolveDefaultCronStorePath(e){return f.join(resolveDefaultCronDir(e),`jobs.json`)}function resolveCronStoreSelectionInDatabase(e,t,n=process.env,r=resolveDefaultCronStorePath(n)){let i=t?.trim()||readCronStoreStatePathInDatabase(e),a=i?resolveSelectedCronJobsStorePath(i,n):r;if(a!==r)return{status:`ready`,storeKey:a,storePath:a};let o=l(e);if(o.status===`ready`)return{status:`ready`,storeKey:o.storeKey,storePath:a};let u=s(e);if(o.status===`absent`){let e=c(u,r);if(e!==void 0)return{status:`ready`,storeKey:e,storePath:a}}return{status:`unresolved`,storePath:a,partitions:u,message:`Default cron partition selection is unresolved; cron is paused. Run openclaw doctor --fix in an interactive terminal and complete the "Select the default cron partition" selection step. Partition inventory: ${u.length?u.map(e=>JSON.stringify(e)).join(`; `):`(no persisted cron partitions)`}`}}function resolveSelectedCronJobsStorePath(e,t){if(e){let n=e.trim();return n.startsWith(`~`)?f.resolve(i(n,{env:t})):f.resolve(n)}return resolveDefaultCronStorePath(t)}export{resolveCronStoreSelectionInDatabase};