openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
7 lines • 2.41 kB
JavaScript
import{n as ignoreMissingPath}from"./errno-DUBt6SQQ.mjs";import"./paths-BFN5qw21.mjs";import{t as createSubsystemLogger}from"./subsystem-BMw5Czn-.mjs";import{d as listSqliteTargetCandidatePathsForSessionStorePath,g as listGatewayOwnedAgentIds,n as resolveAgentDir,u as resolveSessionStorePathCore}from"./agent-scope-config-CGe7-g8s.mjs";import"./session-key-B7vzF6rJ.mjs";import{y as isSameOpenClawAgentDatabasePath}from"./openclaw-agent-db-resources-Ce80pC0J.mjs";import"./legacy.default-agent-owner-DavesGxq.mjs";import"./session-sqlite-target-BUh5GlUA.mjs";import{i as resolveCapturedSessionStorePath}from"./transcript-target-binding-_k3yv0H9.mjs";import{t as listConfiguredSessionStoreAgentIds}from"./targets-configured-agents-BoIHWeCk.mjs";import fsSync from"node:fs";import path from"node:path";import fsPromises from"node:fs/promises";
//!src/agents/session-dirs.ts
function mapAgentSessionDirs(e,t,n){return t.filter(e=>e.isDirectory()&&(n?.(e.name)??true)).map(t=>path.join(e,t.name,`sessions`)).sort((e,t)=>e.localeCompare(t))}function resolveAgentSessionDirsFromAgentsDirSync(e,t){let n;try{n=fsSync.readdirSync(e,{withFileTypes:true})}catch(e){return ignoreMissingPath(e)??[]}return mapAgentSessionDirs(e,n,t)}
//!src/config/sessions/targets-collision.ts
const log=createSubsystemLogger(`sessions/targets`);
//!src/config/sessions/targets.ts
function resolveConfiguredSessionStoreTargets(e,t,n){return listConfiguredSessionStoreAgentIds(e).map(r=>({agentId:r,storePath:resolveCapturedSessionStorePath(e.session?.store,r,t,n)}))}function resolveConfiguredAgentDatabaseCandidatePaths(e,t){const n=listConfiguredSessionStoreAgentIds(e);return[.../* @__PURE__ */ new Set([...n.flatMap(n=>listSqliteTargetCandidatePathsForSessionStorePath(resolveSessionStorePathCore(e.session?.store,{agentId:n,env:t.env}),n)),...[.../* @__PURE__ */ new Set([...n,...listGatewayOwnedAgentIds(e)])].map(n=>path.join(resolveAgentDir(e,n,t.env),`openclaw-agent.sqlite`))])]}function isConfiguredAgentDatabaseTarget(e,t,n){return e.some(e=>(t===void 0||e.agentId===void 0||e.agentId===t)&&(e.path===n||fsSync.statSync(e.path,{throwIfNoEntry:false})&&fsSync.statSync(n,{throwIfNoEntry:false})&&isSameOpenClawAgentDatabasePath(e.path,n)))}export{resolveAgentSessionDirsFromAgentsDirSync as i,resolveConfiguredAgentDatabaseCandidatePaths as n,resolveConfiguredSessionStoreTargets as r,isConfiguredAgentDatabaseTarget as t};