UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 5.32 kB
import{ni as NEVER}from"./json-schema-processors-DZqDXXCr.mjs";import{Et as _enum,Jn as string,Nt as array,nr as tuple,or as union,sr as unknown,tr as transform,xn as literal}from"./schemas-DuCQi-Qb.mjs";import{r as parseWorkerCapacity}from"./worker-capacity-CYt4uoL6.mjs";import{r as WORKER_BUNDLE_PREWARM_VERSION}from"./worker-admission-B_YnpbP9.mjs";import{a as workerProtocolObject}from"./protocol-record-DLQ06AtL.mjs"; //!src/infra/node-runner-inventory.ts const NODE_RUNNER_INVENTORY_UPDATE_METHOD=`node.runnerInventory.update`;const NODE_WORKER_SUPERVISOR_PROTOCOL_FEATURE=`node-worker-supervisor-v6`;const RETIRED_NODE_WORKER_SUPERVISOR_PROTOCOL_FEATURES=[`node-worker-supervisor-v1`,`node-worker-supervisor-v2`,`node-worker-supervisor-v3`,`node-worker-supervisor-v4`,`node-worker-supervisor-v5`];const NODE_WORKER_BUNDLE_RETENTION_VERSION=1;const NODE_WORKER_BUNDLE_PREFETCH_VERSION=1;const NODE_WORKER_BUNDLE_STATUS_VERSION=1;const NODE_WORKER_PORTAL_STREAM_VERSION=1;const NODE_WORKER_ENVIRONMENT_SESSION_VERSION=1;const NODE_WORKER_STATUS_WAIT_VERSION=1;const NODE_WORKER_PREPARED_WORKSPACE_VERSION=1;const NODE_WORKER_NATIVE_INFERENCE_VERSION=1;const NODE_WORKER_INFERENCE_SETUP_ERROR=`Worker-local inference is not configured on this node. Add a compatible model under models.providers with a usable credential in the node openclaw.json, set nodeHost.workerRuns.isolation to "none", then restart the node host. If the node runs an older OpenClaw version, update it first.`;const NODE_WORKER_PROMPT_CONTEXT_VERSION=1;const NODE_WORKER_HOST_DISABLED_REASON_MAX_LENGTH=1024;const NODE_WORKSPACE_RESULT_VERSION=2;const NODE_WORKER_WORKSPACE_QUIESCENCE_VERSION=1;const LEGACY_NODE_WORKER_LAUNCH_TOOL_NAMES=Object.freeze([`read`,`write`,`edit`,`apply_patch`,`exec`,`process`,`browser`,`computer`,`skill_workshop`,`sessions_spawn`,`sessions_send`,`portal`]);const NODE_RUNNER_UPDATE_REQUIRED_ISSUE={code:`update-required`,action:`update-and-reconnect`,updateCommand:`openclaw update`,headlessReconnectCommand:`openclaw node restart`};const CapacitySnapshot=transform((e,t)=>{const n=parseWorkerCapacity(e);if(!n){t.addIssue({code:`custom`,message:`invalid worker capacity`});return NEVER}return n});const LaunchToolNames=array(string().min(1).max(64)).max(64).refine(e=>new Set(e).size===e.length);const WorkerHost=union([workerProtocolObject({enabled:literal(false),reason:string().max(NODE_WORKER_HOST_DISABLED_REASON_MAX_LENGTH).refine(e=>e.trim().length>0).optional()}),workerProtocolObject({enabled:literal(true),capacity:CapacitySnapshot,bundlePrewarm:literal(1).optional(),bundleRetention:literal(1).optional(),bundlePrefetch:literal(1).optional(),bundleStatus:literal(1).optional(),portalStream:literal(1).optional(),environmentSession:literal(1).optional(),statusWait:literal(1).optional(),deviceFolders:literal(true).optional(),preparedWorkspace:literal(1).optional(),capturedExecPolicy:literal(true).optional(),workspaceResultVersion:literal(2).optional(),publicationIntegration:literal(1).optional(),workspaceQuiescence:literal(1).optional(),launchToolNames:LaunchToolNames.optional(),idleRetention:literal(true).optional(),localMcp:literal(true).optional(),nativeInference:literal(1).optional(),promptContext:literal(1).optional()}).refine(e=>(e.bundleStatus===void 0||e.bundleRetention!==void 0)&&(e.capacity.reclaimableIdle===void 0||e.idleRetention===true))]).transform(e=>{for(const[t,n]of Object.entries(e))if(n===void 0)Reflect.deleteProperty(e,t);return e});const RunnerInventory=union([workerProtocolObject({protocolFeatures:tuple([]).readonly()}),workerProtocolObject({protocolFeatures:tuple([_enum(RETIRED_NODE_WORKER_SUPERVISOR_PROTOCOL_FEATURES)]).readonly(),workerRuns:unknown().optional(),workerHost:unknown().optional()}).refine(e=>Object.keys(e).length<=2).transform(({protocolFeatures:e})=>({protocolFeatures:e})),workerProtocolObject({protocolFeatures:tuple([literal(NODE_WORKER_SUPERVISOR_PROTOCOL_FEATURE)]).readonly(),workerHost:WorkerHost})]);function parseNodeRunnerInventoryDeclaration(e){return RunnerInventory.safeParse(e).data??null}function formatNodeRunnerInventoryIssue(e,t){return t.code===`worker-host-unavailable`?`device worker node ${e} cannot host sessions: ${t.message}`:`device worker node ${e} requires an update before it can host sessions; run ${t.updateCommand}, then reconnect it (for a headless node, run ${t.headlessReconnectCommand})`}function createNodeRunnerInventoryIssueError(e,t){const n=new Error(formatNodeRunnerInventoryIssue(e,t));return t.code===`update-required`?Object.assign(n,{code:`node_runner_update_required`,name:`NodeRunnerUpdateRequiredError`}):n}function resolveNodeWorkerExecutionIssue(e){return e.enabled&&(e.capturedExecPolicy!==true||e.promptContext!==1)?NODE_RUNNER_UPDATE_REQUIRED_ISSUE:void 0}function resolveNodeWorkerLaunchToolNames(e){return e?.enabled&&e.launchToolNames||LEGACY_NODE_WORKER_LAUNCH_TOOL_NAMES}export{NODE_WORKER_SUPERVISOR_PROTOCOL_FEATURE as a,parseNodeRunnerInventoryDeclaration as c,NODE_WORKER_INFERENCE_SETUP_ERROR as i,resolveNodeWorkerExecutionIssue as l,NODE_RUNNER_UPDATE_REQUIRED_ISSUE as n,createNodeRunnerInventoryIssueError as o,NODE_WORKER_HOST_DISABLED_REASON_MAX_LENGTH as r,formatNodeRunnerInventoryIssue as s,NODE_RUNNER_INVENTORY_UPDATE_METHOD as t,resolveNodeWorkerLaunchToolNames as u};