UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

5 lines • 3.76 kB
import{a as asOptionalRecord}from"./record-coerce-BTbqdJ3-.mjs";import{n as recordModelFallbackStop}from"./model-fallback-stop-BR_49mUQ.mjs"; //!src/shared/run-failure-notice.ts const HARNESS_UPDATE_REQUIRED_CODE=`harness_update_required`;const readCauseField=e=>typeof e===`string`&&e.length<=120?e.trim()||void 0:void 0;function readRunFailureCause(e){const t=asOptionalRecord(e);const n=readCauseField(t?.provider);const r=readCauseField(t?.failoverReason);const i=[t?.code,t?.providerErrorCode].includes(HARNESS_UPDATE_REQUIRED_CODE);return n?{provider:n,...r&&{failoverReason:r},...i&&{code:`harness_update_required`}}:void 0}function readRunFailureNotice(e,t){const n=asOptionalRecord(asOptionalRecord(e)?.openclawRunError);if(typeof n?.runId!==`string`||!n.runId.trim()||typeof n.summary!==`string`||!n.summary.trim())return;const r=readRunFailureCause(n.cause);const i=t?.audience===`desktop`&&typeof n.desktopSummary===`string`&&n.desktopSummary.trim()?n.desktopSummary:n.summary;return{runId:n.runId,summary:i,...r?{cause:r}:{}}} //!src/agents/harness/errors.ts const MODEL_REQUEST_POLICY_DENIED_TEXT=`The deployment rejected this model request. Ask the administrator to check the model access policy and request settings.`;var AgentHarnessModelRequestPolicyError=class extends Error{constructor(){super(MODEL_REQUEST_POLICY_DENIED_TEXT);this.code=`model_request_policy_denied`;this.status=403;this.name=`AgentHarnessModelRequestPolicyError`;recordModelFallbackStop(this)}};var AgentHarnessRuntimeUpdateRequiredError=class extends Error{constructor(e,t){super(e,t);this.code=HARNESS_UPDATE_REQUIRED_CODE;this.name=`AgentHarnessRuntimeUpdateRequiredError`}};var MissingAgentHarnessError=class extends Error{constructor(e){super(`Requested agent harness "${e}" is not registered.`);this.name=`MissingAgentHarnessError`}};function isMissingAgentHarnessError(e){return e instanceof MissingAgentHarnessError}var AgentHarnessSessionSupersededError=class extends Error{constructor(e,t){super(e,t);this.name=`AgentHarnessSessionSupersededError`}};var AgentHarnessSessionCleanupError=class extends Error{constructor(e,t){super(e,t);this.name=`AgentHarnessSessionCleanupError`}};var AgentHarnessPreflightError=class extends Error{constructor(e,t){super(e,t);this.name=`AgentHarnessPreflightError`;this.scope=t?.scope;this.userMessage=t?.userMessage;this.desktopMessage=t?.desktopMessage}};var SessionControllerAdmissionRequiredError=class extends AgentHarnessPreflightError{constructor(){const e=`Session-keyed native runs require a host-admitted harness turn. Register this run from the host-provided runAttempt callback; use detached execution only for sessionless work.`;super(e,{userMessage:e});this.code=`SESSION_CONTROLLER_ADMISSION_REQUIRED`;this.name=`SessionControllerAdmissionRequiredError`}};const agentHarnessPreflightOwners=/* @__PURE__ */ new WeakMap;function recordAgentHarnessPreflightOwner(e,t){if(isAgentHarnessPreflightError(e)&&e.scope===`harness`)agentHarnessPreflightOwners.set(e,t)}function resolveAgentHarnessPreflightOwner(e){return isAgentHarnessPreflightError(e)?agentHarnessPreflightOwners.get(e):void 0}function isAgentHarnessPreflightError(e){return e instanceof AgentHarnessPreflightError}export{AgentHarnessSessionSupersededError as a,SessionControllerAdmissionRequiredError as c,recordAgentHarnessPreflightOwner as d,resolveAgentHarnessPreflightOwner as f,readRunFailureNotice as h,AgentHarnessSessionCleanupError as i,isAgentHarnessPreflightError as l,readRunFailureCause as m,AgentHarnessPreflightError as n,MODEL_REQUEST_POLICY_DENIED_TEXT as o,HARNESS_UPDATE_REQUIRED_CODE as p,AgentHarnessRuntimeUpdateRequiredError as r,MissingAgentHarnessError as s,AgentHarnessModelRequestPolicyError as t,isMissingAgentHarnessError as u};