UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

5 lines • 2.85 kB
import{r as truncateUtf16Safe}from"./utf16-slice-DA3Mllbx.mjs";import{t as formatErrorMessage}from"./errors-D37BJTfI.mjs";import{a as resolveSystemAgentVerifiedInferenceRoute}from"./verified-inference-C2wCwCrh.mjs"; //!src/system-agent/inference-error.ts const INFERENCE_GUIDANCE={setup:"OpenClaw could not reach working inference. Run `openclaw onboard` on the machine running OpenClaw to reconnect — it live-tests the route before saving it. Then try again.",retry:`The inference request failed or returned no usable reply. Try again; if it persists, check the model runtime logs.`,timeout:`The inference request timed out. Try again; if it persists, check the model runtime and its timeout settings.`,superseded:`The inference runtime was superseded during this turn. Try again after the current runtime settles.`,"runtime-unavailable":`The prepared inference runtime became unavailable or was superseded during this turn. Try again; if it persists, check the model runtime logs.`,"route-changed":`The verified inference route changed or could not be reverified during this turn. Start a new OpenClaw conversation to verify the current route.`,"compatible-route":`The configured CLI runtime cannot enforce OpenClaw's tool restrictions. Select a compatible model/runtime route and try again.`};const INFERENCE_FAILURE_SUMMARY_MAX_CHARS=300;function inferenceUnavailableMessage(e,t){const n=e.length>0?formatErrorMessage(e[0]).trim():``;if(!n)return INFERENCE_GUIDANCE[t];const r=n.length>INFERENCE_FAILURE_SUMMARY_MAX_CHARS?`${truncateUtf16Safe(n,299)}…`:n;return`${INFERENCE_GUIDANCE[t]} Cause: ${r}`}var SystemAgentInferenceUnavailableError=class extends Error{constructor(e,t=[],n=e===`conversation`?`setup`:`retry`){super(inferenceUnavailableMessage(t,n));this.stage=e;this.failures=t;this.code=`SYSTEM_AGENT_INFERENCE_UNAVAILABLE`;this.name=`SystemAgentInferenceUnavailableError`}};function isSystemAgentInferenceUnavailableError(e){return e instanceof SystemAgentInferenceUnavailableError||e instanceof Error&&`code`in e&&e.code===`SYSTEM_AGENT_INFERENCE_UNAVAILABLE`} //!src/system-agent/inference-guard.ts async function requireSystemAgentPersistentApplyInference(e,t){if(!e.binding)throw new SystemAgentInferenceUnavailableError(`conversation`);try{const{resolvePersistentApplyInference:t}=await import(`./system-agent/setup-inference.js`);const n=await t(e);if(n)return n}catch(e){return t([e])}return t([])}async function requireSystemAgentInferenceRoute(e,t,n){let r=[];if(e)try{const t=await resolveSystemAgentVerifiedInferenceRoute(e);if(t)return t}catch(e){r=[e]}n?.(r);throw new SystemAgentInferenceUnavailableError(t,r,e?`route-changed`:`setup`)}export{isSystemAgentInferenceUnavailableError as i,requireSystemAgentPersistentApplyInference as n,SystemAgentInferenceUnavailableError as r,requireSystemAgentInferenceRoute as t};