UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 2.17 kB
import{Jn as string,Kt as custom,Pn as number,qn as strictObject,xn as literal}from"./schemas-DuCQi-Qb.mjs";import{It as validateWorkerAdmissionHandshake}from"./src-BDZMFmKa.mjs";import{r as WORKER_BUNDLE_PREWARM_VERSION}from"./worker-admission-B_YnpbP9.mjs";import{n as MAX_WORKER_BUNDLE_ARCHIVE_BYTES}from"./worker-bundle-limits-CR6eh8-9.mjs"; //!src/worker/node-bundle-install-protocol.ts const NODE_WORKER_BUNDLE_TRANSFER_PATH=`/__openclaw__/worker-bundle/v1`;const NODE_WORKER_BUNDLE_INSTALL_ERROR_CODE=`WORKER_BUNDLE_INSTALL_FAILED`;const REQUEST_MAX_BYTES=16384;const GATEWAY_NAMESPACE_PATTERN=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/u;const SHA256_PATTERN=/^[a-f0-9]{64}$/u;const TOKEN_PATTERN=/^[A-Za-z0-9_-]{43}$/u;const WorkerBuildSchema=custom(e=>validateWorkerAdmissionHandshake(e),`invalid worker build identity`);const BundleInstallInputSchema=strictObject({gatewayNamespace:string().regex(GATEWAY_NAMESPACE_PATTERN),prefetch:literal(1).optional(),bundlePrewarm:literal(1).optional(),build:WorkerBuildSchema,archive:strictObject({token:string().regex(TOKEN_PATTERN),sha256:string().regex(SHA256_PATTERN),bytes:number().int().min(1).max(MAX_WORKER_BUNDLE_ARCHIVE_BYTES)})});var NodeWorkerBundleInstallError=class extends Error{constructor(e,t){super(e,t);this.code=NODE_WORKER_BUNDLE_INSTALL_ERROR_CODE;this.name=`NodeWorkerBundleInstallError`}};function parseNodeWorkerBundleInstallInput(e){if(!e||Buffer.byteLength(e,`utf8`)>REQUEST_MAX_BYTES)throw new Error(`INVALID_REQUEST: invalid node worker bundle install request`);try{return BundleInstallInputSchema.parse(JSON.parse(e))}catch(e){const t=e instanceof Error?e.message:String(e);throw new Error(`INVALID_REQUEST: invalid node worker bundle install request: ${t}`,{cause:e})}}function parseNodeWorkerBundleInstallResult(e){return validateWorkerAdmissionHandshake(e)?e:null}function nodeWorkerBundleTransferPath(e){return`${NODE_WORKER_BUNDLE_TRANSFER_PATH}/bundles/${e}`}export{parseNodeWorkerBundleInstallInput as a,nodeWorkerBundleTransferPath as i,NODE_WORKER_BUNDLE_TRANSFER_PATH as n,parseNodeWorkerBundleInstallResult as o,NodeWorkerBundleInstallError as r,NODE_WORKER_BUNDLE_INSTALL_ERROR_CODE as t};