openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 2.17 kB
JavaScript
import{a as getCommandArgsWithRootOptions,l as isValueToken,n as consumeKnownOptionToken,o as getCommandPositionalsWithRootOptions,r as consumeRootCommandOptionToken}from"./cli-root-options-eez2TgAl.mjs";import{n as GATEWAY_RUN_VALUE_FLAGS,t as GATEWAY_RUN_BOOLEAN_FLAGS}from"./gateway-run-argv-Cz2rb_aK.mjs";import{i as WINDOWS_TASK_SUPERVISOR_FLAG,r as WINDOWS_TASK_SUPERVISOR_CHILD_FLAG}from"./windows-task-supervisor-contract-Bz_KVoza.mjs";
//!src/cli/gateway-run-argv.ts
function consumeGatewayRunOptionToken(e,t){return consumeKnownOptionToken(e,t,GATEWAY_RUN_BOOLEAN_FLAGS,GATEWAY_RUN_VALUE_FLAGS)}function consumeGatewayFastPathRootOptionToken(e,t){const n=e[t];if(!n||n===`--`)return 0;if(n===`--no-color`)return 1;if(n.startsWith(`--profile=`))return n.slice(10).trim()?1:0;if(n===`--profile`)return isValueToken(e[t+1])?2:0;return 0}function resolveGatewayCommandPath(e,t=2){const n=getCommandPositionalsWithRootOptions(e,{commandPath:[`gateway`],booleanFlags:[...GATEWAY_RUN_BOOLEAN_FLAGS,WINDOWS_TASK_SUPERVISOR_FLAG],valueFlags:[...GATEWAY_RUN_VALUE_FLAGS,WINDOWS_TASK_SUPERVISOR_CHILD_FLAG],maxPositionals:t-1,mode:`command-path`});return n?[`gateway`,...n]:null}function isGatewayRunInvocationArgv(e){const t=resolveGatewayCommandPath(e);return t?.length===1||t?.length===2&&t[0]===`gateway`&&t[1]===`run`}function resolveGatewayRunPreBootstrapOptions(e){const t=getCommandArgsWithRootOptions(e,{commandPath:[`gateway`],mode:`command-path`});if(!t)return null;let n=false;let r=false;let i=false;let a=false;for(let e=0;e<t.length;e+=1){const o=t[e];if(!o||o===`--`)break;if(!a&&o===`run`){a=true;continue}const s=consumeRootCommandOptionToken(t,e)||consumeGatewayRunOptionToken(t,e)||(o&&GATEWAY_RUN_VALUE_FLAGS.has(o)&&t[e+1]!==void 0?2:0);if(s>0){if(o===`--force`)n=true;else if(o===`--reset`)r=true;e+=s-1;continue}if(o===`--task-supervisor`){i=true;continue}if(!o.startsWith(`-`))return null}return i?{force:n,reset:r,taskSupervisor:true}:{force:n,reset:r}}export{resolveGatewayRunPreBootstrapOptions as a,resolveGatewayCommandPath as i,consumeGatewayRunOptionToken as n,isGatewayRunInvocationArgv as r,consumeGatewayFastPathRootOptionToken as t};