UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 4.33 kB
import{n as normalizeAgentId}from"./agent-id-cOfqmfln.mjs";import"./session-key-BPgKfU2m.mjs";import{r as getSkillsSnapshotVersion}from"./refresh-state-DQEO5OFV.mjs";import{i as listAgentIds,m as withAgentRosterFactsBatch}from"./agent-roster-4XrgUgPK.mjs";import{f as resolveAgentWorkspaceDir}from"./agent-scope-config-CG9CFpGX.mjs";import{C as resolveRuntimeModelConfigCacheKey}from"./runtime-snapshot-Bg5K4JNu.mjs";import"./agent-scope-Dw5XRSEh.mjs";import{d as getActivePluginRegistryVersion}from"./runtime-Cl6PvJHC.mjs";import{T as readAgentDatabaseReadAdmissionRefusal}from"./agent-database-admission-DiJx9iIl.mjs";import{l as getRuntimeAuthProfileStoreMetadataRevision,s as getRuntimeAuthProfileStoreCatalogRevision}from"./runtime-snapshots-DYK7vyJv.mjs";import{t as PreparedModelRuntimeOwnerNotPublishedError}from"./prepared-model-runtime-admission-errors-DZto8oll.mjs";import{a as getPreparedRuntimeAuthProfileStoreSnapshot}from"./store-CX8ovUiF.mjs";import{a as getPreparedModelFullCatalogAuth}from"./prepared-model-runtime-auth-peTguotn.mjs";import"./prepared-model-runtime.errors-CJIB8kC0.mjs";import{D as withPreparedModelRuntimeReadBatch}from"./prepared-model-runtime-Bq1P9DhS.mjs";import{r as getPublishedPreparedModelCatalogOwnerSnapshot}from"./prepared-model-catalog-DR44fXi2.mjs";import"./auth-profiles-nMUErGRQ.mjs"; //!src/gateway/server-methods/chat-metadata-facts.ts var ChatMetadataStartingError=class extends PreparedModelRuntimeOwnerNotPublishedError{};var ChatMetadataSnapshotUnavailableError=class extends Error{constructor(e=`prepared chat metadata snapshot is unavailable`){super(e);this.name=`ChatMetadataSnapshotUnavailableError`}};function assertPreparedAgentCurrent(e){if(!e.owner.isCurrent())throw new ChatMetadataSnapshotUnavailableError(`prepared chat metadata owner retired for agent "${e.agentId}"`)}function authStoresCurrent(e){let t;return e.agents.every(({owner:e,authStoreRevision:n})=>n===`${getRuntimeAuthProfileStoreMetadataRevision(e.agentDir)}:${e.inheritedAuthDir?getRuntimeAuthProfileStoreMetadataRevision(e.inheritedAuthDir):t??=getRuntimeAuthProfileStoreMetadataRevision()}`)}function captureGenerationFacts(e){const t=withPreparedModelRuntimeReadBatch(()=>withAgentRosterFactsBatch(e,()=>listAgentIds(e).filter(e=>!readAgentDatabaseReadAdmissionRefusal(e)).flatMap(t=>{const n=normalizeAgentId(t);const r=getPublishedPreparedModelCatalogOwnerSnapshot({agentId:n,config:e});if(!r)return[];const i=r.workspaceDir??resolveAgentWorkspaceDir(e,n);const a=r.readFullModelCatalog?.();const o=a?getPreparedModelFullCatalogAuth(a):void 0;if(a&&!o)throw new Error(`prepared full model catalog omitted its auth generation`);const s=a??r.modelCatalog;return[{agentId:n,owner:r,authStore:o?.authStore??getPreparedRuntimeAuthProfileStoreSnapshot(r.agentDir,r.inheritedAuthDir)??{version:1,profiles:{}},authModes:o?.authModes??r.authModes,authStoreRevision:`${getRuntimeAuthProfileStoreMetadataRevision(r.agentDir)}:${getRuntimeAuthProfileStoreMetadataRevision(r.inheritedAuthDir)}`,authCatalogRevision:`${getRuntimeAuthProfileStoreCatalogRevision(r.agentDir)}:${getRuntimeAuthProfileStoreCatalogRevision(r.inheritedAuthDir)}`,modelCatalog:s,catalogRefreshFailed:s.refreshFailed===true,skillsVersion:getSkillsSnapshotVersion(i)}]})));return{config:e,configKey:resolveRuntimeModelConfigCacheKey(e),pluginRegistryVersion:getActivePluginRegistryVersion(),agents:t}}function agentFactsMatch(e,t,n){return Boolean(e&&t&&e.agentId===t.agentId&&(n===`commands`?e.skillsVersion===t.skillsVersion&&e.owner.workspaceDir===t.owner.workspaceDir:e.owner.isCurrent===t.owner.isCurrent&&(n===`catalog-notification`?e.authCatalogRevision===t.authCatalogRevision:e.authStoreRevision===t.authStoreRevision)&&e.modelCatalog===t.modelCatalog&&(n===`auth`||e.catalogRefreshFailed===t.catalogRefreshFailed)&&(n!==`metadata`||e.skillsVersion===t.skillsVersion)))}function generationFactsMatch(e,t,n=`metadata`){if(e.configKey!==t.configKey||e.pluginRegistryVersion!==t.pluginRegistryVersion||e.agents.length!==t.agents.length)return false;return e.agents.every((e,r)=>agentFactsMatch(e,t.agents[r],n))}export{authStoresCurrent as a,assertPreparedAgentCurrent as i,ChatMetadataStartingError as n,captureGenerationFacts as o,agentFactsMatch as r,generationFactsMatch as s,ChatMetadataSnapshotUnavailableError as t};