openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 5.15 kB
JavaScript
import{l as resolveSessionStorePathCore}from"./paths-CcxgiC3g.mjs";import{a as resolveSessionAuthProfileOverrideSource}from"./auth-profile-override-provenance-D5ZYWRNQ.mjs";import{t as quoteCliArg}from"./quote-cli-arg-BUHoGELl.mjs";import{t as resolveModelProviderAuthConfig}from"./model-auth-provider-route-BT25VrFM.mjs";import{n as readSessionEntriesFromStoreInWorker}from"./session-entry-read-runtime-kAgwDw0B.mjs";import{c as resolveCronSessionTargetSessionKey,r as isDetachedCronSessionTarget}from"./session-target-BE2kgjYz.mjs";import{t as resolveCronAgentSessionKey}from"./session-key-CeBBOtWJ.mjs";import{r as getCliSessionBinding}from"./cli-session-binding-uwQzKK6C.mjs";import{t as isCliProvider}from"./model-selection-cli-K7oSL0Pc.mjs";import{i as resolveSessionRuntimeOverrideForProvider}from"./session-runtime-compat-DGwJiPrH.mjs";import{o as resolveEffectiveAgentRuntime}from"./thinking-runtime-V6V09nGt.mjs";import{g as loadAuthProfileStoreWithoutExternalProfilesAsync}from"./store-runtime-GNz-2GjY.mjs";import{a as selectCliExecutionAuthProfile,n as cliBackendAcceptsAuthProfileForwarding}from"./cli-execution-auth-C5lp_Ebz.mjs";import{a as resolveSessionAuthProfilePreference,n as resolveSessionAuthProfileOverrideCompatibility}from"./session-override-CpXY_45d.mjs";import{t as resolveCronCandidateExecution}from"./candidate-execution-UQZUpvhJ.mjs";import{n as prepareCronSession}from"./session-aQtYOnkC.mjs";
//!src/cron/inference-diagnostics.ts
async function prepareCronInferenceDiagnosticSession(e){const{cfg:t,agentId:n,job:r,signal:i}=e;i?.throwIfAborted();const a=r.sessionTarget===`main`?`main`:resolveCronSessionTargetSessionKey(r.sessionTarget);const o=resolveCronAgentSessionKey({cfg:t,agentId:n,sessionKey:a??`cron:${r.id}`});if(a){const e=await readSessionEntriesFromStoreInWorker({agentId:n,sessionKeys:[o],storePath:resolveSessionStorePathCore(t.session?.store,{agentId:n})});i?.throwIfAborted();const r=e.entries[0]?.entry;if(r)return{sessionEntry:r,initialSessionEntry:r,isNewSession:false}}return prepareCronSession({cfg:t,agentId:n,sessionKey:o,sourceSessionKey:r.sessionTarget===`current`&&r.sessionKey?resolveCronAgentSessionKey({cfg:t,agentId:n,sessionKey:r.sessionKey}):void 0,forceNew:isDetachedCronSessionTarget(r.sessionTarget),exactRunSession:true,nowMs:Date.now()})}async function inspectCronInferenceAccount(e){const{cfg:t,agentId:n,provider:r,model:i,session:a,job:o}=e;e.signal?.throwIfAborted();const s=a.sessionEntry.authProfileOverride?await loadAuthProfileStoreWithoutExternalProfilesAsync(e.agentDir):void 0;e.signal?.throwIfAborted();const c=s&&resolveSessionAuthProfileOverrideCompatibility({cfg:resolveModelProviderAuthConfig({config:t,provider:r,modelId:i}),agentDir:e.agentDir,entry:a.sessionEntry,store:s,provider:r,providers:[r]})===`incompatible`?void 0:a.sessionEntry.authProfileOverride;const l=resolveSessionAuthProfilePreference({cfg:t,agentId:n,provider:r,modelId:i,configuredProfileId:e.configuredProfileId,sessionProfileId:c,sessionProfileSource:resolveSessionAuthProfileOverrideSource(a.sessionEntry)});const u=resolveCronCandidateExecution({cfg:t,agentId:n,provider:r,model:i,authProfileId:l?.profileId,sessionEntry:a.sessionEntry,sessionRuntimeOverride:resolveSessionRuntimeOverrideForProvider({cfg:t,provider:r,entry:a.sessionEntry})},{isCliProvider,resolveEffectiveAgentRuntime});if(!u.cliExecution)return{cliExecution:false,preference:l,store:s};if(!cliBackendAcceptsAuthProfileForwarding({provider:u.executionProvider,config:t,agentId:n}))return{cliExecution:true};e.signal?.throwIfAborted();const d=s??await loadAuthProfileStoreWithoutExternalProfilesAsync(e.agentDir);e.signal?.throwIfAborted();const f=selectCliExecutionAuthProfile({cliExecutionProvider:u.executionProvider,authProfileProvider:r,config:t,store:d,readinessMode:`read-only`,selected:l?{authProfileId:l.profileId,authProfileIdSource:l.source}:void 0,sessionBinding:a.isNewSession?void 0:getCliSessionBinding(a.sessionEntry,u.executionProvider)});if(f?.kind!==`stored`)return{cliExecution:true};const p=`${r}/${i}`;if(o.payload.kind===`systemEvent`)return{cliExecution:true,warning:`Automation ${o.name||o.id} (${o.id}): ${u.executionProvider} selects stored account ${f.profileId} for ${p}. Doctor cannot adopt a CLI account automatically. To keep this system event, select a model with an eligible host-managed account in the owning agent’s main session, then run openclaw doctor --fix. This changes the model used by other turns in that session too.`};const m=`openclaw automations edit ${quoteCliArg(o.id)} --model`;const h=u.executionProvider===`claude-cli`?` To explicitly use Claude CLI's native login instead, run ${m} ${quoteCliArg(`${p}@anthropic:claude-cli`)}.`:``;return{cliExecution:true,warning:`Automation ${o.name||o.id} (${o.id}): runtime ${u.executionProvider} on ${p} selects stored inference account ${f.profileId}. Scheduled CLI runs never borrow a stored account; an explicit choice is required. To adopt it, run ${m} ${quoteCliArg(`${p}@${f.profileId}`)}. This also sets the primary model.${h}`}}export{prepareCronInferenceDiagnosticSession as n,inspectCronInferenceAccount as t};