@easbot/gateway 0.2.23 → 0.2.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/chunk-OBW6CNOG.mjs +7 -0
- package/dist/chunks/chunk-OHUELRXK.mjs +14 -0
- package/dist/chunks/chunk-RIWYHEQ6.cjs +7 -0
- package/dist/chunks/chunk-U32NADBK.cjs +14 -0
- package/dist/chunks/global-JYEIXTJ2.mjs +2 -0
- package/dist/chunks/global-Y53VDBKD.cjs +1 -0
- package/dist/chunks/log-7WPRHZWH.cjs +1 -0
- package/dist/chunks/log-MKRLBH4R.mjs +1 -0
- package/dist/chunks/server-MTS5PR2P.mjs +1 -0
- package/dist/chunks/server-ZPM3AQHL.cjs +1 -0
- package/dist/index.cjs +2 -11
- package/dist/index.d.cts +440 -100
- package/dist/index.d.ts +440 -100
- package/dist/index.mjs +2 -11
- package/package.json +14 -13
- package/dist/chunks/chunk-2MXYBRPH.cjs +0 -1
- package/dist/chunks/chunk-5ETPYYQR.cjs +0 -7
- package/dist/chunks/chunk-6TRL3CVJ.mjs +0 -7
- package/dist/chunks/chunk-77F43CRD.mjs +0 -2
- package/dist/chunks/chunk-ASIAS35P.cjs +0 -2
- package/dist/chunks/chunk-DJTIL3AB.mjs +0 -2
- package/dist/chunks/chunk-RR6UFR5U.cjs +0 -2
- package/dist/chunks/chunk-YP2P4RQW.mjs +0 -1
- package/dist/chunks/global-5DV25LCJ.mjs +0 -2
- package/dist/chunks/global-OVOYDKEL.cjs +0 -1
- package/dist/chunks/log-B5SORET6.cjs +0 -1
- package/dist/chunks/log-K67H67P2.mjs +0 -1
- package/dist/chunks/server-CPD2KBY7.cjs +0 -1
- package/dist/chunks/server-TLTUACMN.mjs +0 -1
- package/dist/cli.cjs +0 -8
- package/dist/cli.d.cts +0 -6
- package/dist/cli.d.ts +0 -6
- package/dist/cli.mjs +0 -8
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {w,S}from'./chunk-77F43CRD.mjs';import {a}from'./chunk-6TRL3CVJ.mjs';import {a as a$1}from'./chunk-HAMGVOQD.mjs';var e=a.create({service:"gateway"}),s=class a extends Error{constructor(t,w,m){super(t);a$1(this,"type");a$1(this,"stage");a$1(this,"cause");this.type="GatewayInitializationError",this.stage=w,this.cause=m,Error.captureStackTrace&&Error.captureStackTrace(this,a);}};function b(a){let n=["ECONNRESET","EPIPE","ETIMEDOUT","ECONNREFUSED","ENOTFOUND","EHOSTUNREACH","ENETUNREACH"],t=a.code;return n.includes(t??"")}function C(){process.on("unhandledRejection",a=>{let n=a instanceof Error?a:new Error(String(a));b(n)||e.error("unhandled promise rejection",{error:n.message,stack:n.stack});}),process.on("uncaughtException",a=>{b(a)||(e.error("uncaught exception",{error:a.message,stack:a.stack}),process.exit(1));});}var E;(k=>{let a$1={initialized:false,initPromise:null,directory:".easbot",config:null},n,t={server:null,config:null,initialized:false,status:"stopped"};async function w$1(o={}){if(a$1.initialized)return;if(a$1.initPromise)return a$1.initPromise;let i={directory:o.directory??".easbot",printLogs:o.printLogs??false,logLevel:o.logLevel??"INFO"};return a$1.directory=i.directory,a$1.initPromise=(async()=>{let{Global:c}=await import('./global-5DV25LCJ.mjs');try{await c.init();}catch(r){throw new s("Failed to initialize global directories","global",r instanceof Error?r:void 0)}try{await a.init({logDir:c.Path.log,print:i.printLogs,level:i.logLevel});}catch(r){throw new s("Failed to initialize log infrastructure","log",r instanceof Error?r:void 0)}try{C();}catch(r){throw new s("Failed to install unhandled exception handlers","server",r instanceof Error?r:void 0)}try{a$1.config=await w(i.directory);}catch(r){throw new s("Failed to load gateway configuration","config",r instanceof Error?r:void 0)}a$1.initialized=true,e.info("gateway runtime initialized",{directory:i.directory,logLevel:i.logLevel});})(),a$1.initPromise}k.init=w$1;function m(){return a$1.initialized}k.isInitialized=m;function S$1(){return n||(n=async()=>{if(!a$1.initialized)throw new s("Gateway not initialized. Call init() first.","server");let o=S(),i=await w(o.directory);return i.server?.enabled?(t={server:null,config:i,initialized:true,status:"stopped"},e.info("gateway initialized",{port:i.server?.port,hostname:i.server?.hostname}),t):(e.debug("gateway server disabled or not configured"),{server:null,config:i,initialized:true,status:"stopped"})}),n}function d(){return S$1()()}k.state=d;async function z(){return (await d()).server}k.get=z;async function R(){return (await d()).config?.server?.enabled??false}k.isEnabled=R;async function N(){return (await d()).config}k.config=N;function T(){return t.status}k.getStatus=T;async function h(o){e.debug("Gateway.start: called"),a$1.initialized||(e.debug("Gateway.start: calling init()"),await w$1(),e.debug("Gateway.start: init() completed")),e.debug("Gateway.start: calling state()");let i=await d();if(e.debug("Gateway.start: state() completed",{status:i.status}),!(i.config?.server?.enabled??true))throw e.warn("gateway server is disabled"),new Error("Gateway server is disabled");if(t.status==="running"){e.info("gateway server is already running");return}if(t.status==="starting"){e.info("gateway server is starting");return}t.status="starting",e.debug("Gateway.start: status set to starting");try{let r={...i.config?.server,...o};e.debug("gateway start: creating server with config",{port:r.port,hostname:r.hostname,path:r.path,https:r.https?.enabled}),e.debug("Gateway.start: calling createGatewayServer");let g=await P(r);e.debug("Gateway.start: createGatewayServer completed"),e.debug("gateway start: server created, updating state"),t.server=g,t.status="running",t.error=void 0,e.info("gateway server started",{port:r.port,hostname:r.hostname});}catch(r){throw t.status="error",t.error=r instanceof Error?r.message:String(r),e.error("failed to start gateway server",{error:t.error}),r}}k.start=h;async function G(){if(t.status==="stopped"){e.info("gateway server is already stopped");return}if(t.status==="stopping"){e.info("gateway server is stopping");return}t.status="stopping";try{t.server&&await t.server.stop(),t.server=null,t.status="stopped",t.error=void 0,e.info("gateway server stopped");}catch(o){throw t.status="error",t.error=o instanceof Error?o.message:String(o),e.error("failed to stop gateway server",{error:t.error}),o}}k.stop=G;async function I(o){e.info("restarting gateway server"),(t.status==="running"||t.status==="starting")&&await G(),await h(o);}k.restart=I;async function L(){let o=S(),i=await w(o.directory);return t.config=i,a$1.config=i,e.info("gateway config reloaded"),i}k.reloadConfig=L;async function P(o,i){e.debug("createGatewayServer: starting");let{GatewayServer:c}=await import('./server-TLTUACMN.mjs');e.debug("createGatewayServer: GatewayServer imported");let r=new c(o);e.debug("createGatewayServer: server instance created"),e.debug("createGatewayServer: created server instance, calling start()");let g=i?.startupTimeout??3e4;if(await(async()=>{let l=new Promise((u,x)=>{setTimeout(()=>{x(new Error(`Gateway server startup timeout after ${g}ms`));},g);});try{e.debug("createGatewayServer: calling server.start()"),await Promise.race([r.start(),l]),e.debug("createGatewayServer: server.start() completed");}catch(u){e.error("gateway server start failed, attempting cleanup",{error:u instanceof Error?u.message:String(u)});try{await r.stop();}catch{}throw u}})(),i?.onStarted)try{await i.onStarted(r);}catch(l){e.warn("server started but onStarted callback failed",{error:l instanceof Error?l.message:String(l)});}return e.info("gateway server created and started",{port:o.port,hostname:o.hostname}),r}k.createGatewayServer=P;})(E||(E={}));export{E as a};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import'./chunk-HAMGVOQD.mjs';import {mkdir,readFile,readdir,rm,writeFile}from'fs/promises';import i from'path';import {xdgData,xdgCache,xdgConfig,xdgState}from'xdg-basedir';import O from'os';var c={name:"@easbot/gateway",version:"0.2.23",description:"EASBot Gateway - AI Agent Server and Multi-channel Integration Platform - \u652F\u6301 WebSocket\u3001HTTP\u3001Discord\u3001Telegram\u3001Slack \u7B49\u591A\u6E20\u9053\u96C6\u6210",type:"module",main:"dist/index.cjs",module:"dist/index.mjs",types:"dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.mjs",require:"./dist/index.cjs"},"./package.json":"./package.json"},scripts:{dev:"cross-env NODE_ENV=development tsx src/cli.ts -- start",start:"cross-env NODE_ENV=production node dist/cli.mjs start",build:"tsup --env.NODE_ENV production",test:"vitest","test:run":"vitest run",lint:"biome check .","lint:fix":"biome check --write .","lint:report":"biome check --reporter=summary .",format:"biome format .","format:fix":"biome format --write .","type-check":"tsc --noEmit",clean:"npx rimraf dist node_modules",prepare:"echo norun",prepublishOnly:"pnpm build","publish:npm":"bash scripts/publish.sh","publish:npm:win":"powershell -ExecutionPolicy Bypass -File scripts/publish.ps1"},keywords:["easbot","gateway","server","websocket","http","agent","multi-channel","discord","telegram","slack","feishu","wechat","chat","integration"],author:"houjallen",license:"MIT",repository:{type:"git",url:"https://github.com/houjallen/easbot.git",directory:"packages/gateway"},homepage:"https://github.com/houjallen/easbot/tree/main/packages/gateway#readme",bugs:{url:"https://github.com/houjallen/easbot/issues"},files:["dist","README.md","README.en.md","LICENSE"],dependencies:{"@ai-sdk/provider":"^3.0.10","@ai-sdk/provider-utils":"^4.0.27","@ai-sdk/openai-compatible":"^2.0.47","@ai-sdk/anthropic":"^3.0.76","@easbot/plugin":"workspace:*","@easbot/sdk":"workspace:*","@easbot/types":"workspace:*","@easbot/utils":"workspace:*","@hono/node-server":"^2.0.2","@hono/node-ws":"^1.3.0","@hono/standard-validator":"^0.2.2","@hono/zod-validator":"^0.7.6",commander:"^14.0.3",zod:"^4.4.3",hono:"^4.12.18","hono-openapi":"^1.3.0",ws:"^8.20.0",ai:"^6.0.176","better-sqlite3":"^12.9.0","jieba-wasm":"^2.4.0","xdg-basedir":"^5.1.0",minimatch:"^10.2.5"},devDependencies:{"@biomejs/biome":"^2.4.14","@types/better-sqlite3":"^7.6.13","@types/ws":"^8.18.1","@types/node":"^25.6.2","@vitest/coverage-v8":"^4.1.5",dotenv:"^17.4.2",tsup:"^8.5.1",typescript:"^6.0.3",vitest:"^4.1.5"},engines:{node:">=22.22.3"},publishConfig:{access:"public"}};var a="easbot",l=i.join(xdgData,a),k=i.join(xdgCache,a),x=i.join(xdgConfig,a),j=i.join(xdgState,a),m;(e=>{e.Path={get home(){return process.env.EASBOT_TEST_HOME||O.homedir()},data:l,bin:i.join(l,"bin"),log:i.join(l,"log"),cache:k,config:x,state:j};let t=null,s=null;async function v(){if(t)return t;if(process.env.EASBOT_VERSION)return t=process.env.EASBOT_VERSION,t;try{t=c.version||"local";}catch{t="local";}return t||"local"}function g(){if(t)return t;if(process.env.EASBOT_VERSION)return t=process.env.EASBOT_VERSION,t;try{t=c.version||"local";}catch{t="local";}return t||"local"}e.getVersion=g;function p(){if(s)return s;if(process.env.EASBOT_CHANNEL)return s=process.env.EASBOT_CHANNEL,s;let o=g();return o==="local"||o.includes("dev")?s="local":o.includes("beta")||o.includes("alpha")?s="preview":s="latest",s||"local"}e.getChannel=p;function B(){return p()==="local"}e.isLocal=B;function C(){return p()==="preview"}e.isPreview=C;let u=false,n=null;async function H(){if(!u)return n||(n=(async()=>{await v(),await Promise.all([mkdir(e.Path.data,{recursive:true}),mkdir(e.Path.config,{recursive:true}),mkdir(e.Path.state,{recursive:true}),mkdir(e.Path.log,{recursive:true}),mkdir(e.Path.bin,{recursive:true}),mkdir(e.Path.cache,{recursive:true})]).then(()=>{process.env.EASBOT_DATA_PATH=e.Path.data,process.env.EASBOT_CONFIG_PATH=e.Path.config,process.env.EASBOT_STATE_PATH=e.Path.state,process.env.EASBOT_LOG_PATH=e.Path.log,process.env.EASBOT_BIN_PATH=e.Path.bin,process.env.EASBOT_CACHE_PATH=e.Path.cache;});let o="1",d=i.join(e.Path.cache,"version");if(await readFile(d,"utf-8").catch(()=>"0")!==o){try{let h=await readdir(e.Path.cache);await Promise.all(h.map(b=>rm(i.join(e.Path.cache,b),{recursive:!0,force:!0})));}catch{}await writeFile(d,o);}u=true;})(),n)}e.init=H;})(m||(m={}));
|
|
2
|
-
export{m as Global};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
'use strict';require('./chunk-GY3SWWW3.cjs');var promises=require('fs/promises'),i=require('path'),xdgBasedir=require('xdg-basedir'),O=require('os');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var i__default=/*#__PURE__*/_interopDefault(i);var O__default=/*#__PURE__*/_interopDefault(O);var c={name:"@easbot/gateway",version:"0.2.23",description:"EASBot Gateway - AI Agent Server and Multi-channel Integration Platform - \u652F\u6301 WebSocket\u3001HTTP\u3001Discord\u3001Telegram\u3001Slack \u7B49\u591A\u6E20\u9053\u96C6\u6210",type:"module",main:"dist/index.cjs",module:"dist/index.mjs",types:"dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.mjs",require:"./dist/index.cjs"},"./package.json":"./package.json"},scripts:{dev:"cross-env NODE_ENV=development tsx src/cli.ts -- start",start:"cross-env NODE_ENV=production node dist/cli.mjs start",build:"tsup --env.NODE_ENV production",test:"vitest","test:run":"vitest run",lint:"biome check .","lint:fix":"biome check --write .","lint:report":"biome check --reporter=summary .",format:"biome format .","format:fix":"biome format --write .","type-check":"tsc --noEmit",clean:"npx rimraf dist node_modules",prepare:"echo norun",prepublishOnly:"pnpm build","publish:npm":"bash scripts/publish.sh","publish:npm:win":"powershell -ExecutionPolicy Bypass -File scripts/publish.ps1"},keywords:["easbot","gateway","server","websocket","http","agent","multi-channel","discord","telegram","slack","feishu","wechat","chat","integration"],author:"houjallen",license:"MIT",repository:{type:"git",url:"https://github.com/houjallen/easbot.git",directory:"packages/gateway"},homepage:"https://github.com/houjallen/easbot/tree/main/packages/gateway#readme",bugs:{url:"https://github.com/houjallen/easbot/issues"},files:["dist","README.md","README.en.md","LICENSE"],dependencies:{"@ai-sdk/provider":"^3.0.10","@ai-sdk/provider-utils":"^4.0.27","@ai-sdk/openai-compatible":"^2.0.47","@ai-sdk/anthropic":"^3.0.76","@easbot/plugin":"workspace:*","@easbot/sdk":"workspace:*","@easbot/types":"workspace:*","@easbot/utils":"workspace:*","@hono/node-server":"^2.0.2","@hono/node-ws":"^1.3.0","@hono/standard-validator":"^0.2.2","@hono/zod-validator":"^0.7.6",commander:"^14.0.3",zod:"^4.4.3",hono:"^4.12.18","hono-openapi":"^1.3.0",ws:"^8.20.0",ai:"^6.0.176","better-sqlite3":"^12.9.0","jieba-wasm":"^2.4.0","xdg-basedir":"^5.1.0",minimatch:"^10.2.5"},devDependencies:{"@biomejs/biome":"^2.4.14","@types/better-sqlite3":"^7.6.13","@types/ws":"^8.18.1","@types/node":"^25.6.2","@vitest/coverage-v8":"^4.1.5",dotenv:"^17.4.2",tsup:"^8.5.1",typescript:"^6.0.3",vitest:"^4.1.5"},engines:{node:">=22.22.3"},publishConfig:{access:"public"}};var a="easbot",l=i__default.default.join(xdgBasedir.xdgData,a),k=i__default.default.join(xdgBasedir.xdgCache,a),x=i__default.default.join(xdgBasedir.xdgConfig,a),j=i__default.default.join(xdgBasedir.xdgState,a);exports.Global=void 0;(e=>{e.Path={get home(){return process.env.EASBOT_TEST_HOME||O__default.default.homedir()},data:l,bin:i__default.default.join(l,"bin"),log:i__default.default.join(l,"log"),cache:k,config:x,state:j};let t=null,s=null;async function v(){if(t)return t;if(process.env.EASBOT_VERSION)return t=process.env.EASBOT_VERSION,t;try{t=c.version||"local";}catch{t="local";}return t||"local"}function g(){if(t)return t;if(process.env.EASBOT_VERSION)return t=process.env.EASBOT_VERSION,t;try{t=c.version||"local";}catch{t="local";}return t||"local"}e.getVersion=g;function p(){if(s)return s;if(process.env.EASBOT_CHANNEL)return s=process.env.EASBOT_CHANNEL,s;let o=g();return o==="local"||o.includes("dev")?s="local":o.includes("beta")||o.includes("alpha")?s="preview":s="latest",s||"local"}e.getChannel=p;function B(){return p()==="local"}e.isLocal=B;function C(){return p()==="preview"}e.isPreview=C;let u=false,n=null;async function H(){if(!u)return n||(n=(async()=>{await v(),await Promise.all([promises.mkdir(e.Path.data,{recursive:true}),promises.mkdir(e.Path.config,{recursive:true}),promises.mkdir(e.Path.state,{recursive:true}),promises.mkdir(e.Path.log,{recursive:true}),promises.mkdir(e.Path.bin,{recursive:true}),promises.mkdir(e.Path.cache,{recursive:true})]).then(()=>{process.env.EASBOT_DATA_PATH=e.Path.data,process.env.EASBOT_CONFIG_PATH=e.Path.config,process.env.EASBOT_STATE_PATH=e.Path.state,process.env.EASBOT_LOG_PATH=e.Path.log,process.env.EASBOT_BIN_PATH=e.Path.bin,process.env.EASBOT_CACHE_PATH=e.Path.cache;});let o="1",d=i__default.default.join(e.Path.cache,"version");if(await promises.readFile(d,"utf-8").catch(()=>"0")!==o){try{let h=await promises.readdir(e.Path.cache);await Promise.all(h.map(b=>promises.rm(i__default.default.join(e.Path.cache,b),{recursive:!0,force:!0})));}catch{}await promises.writeFile(d,o);}u=true;})(),n)}e.init=H;})(exports.Global||(exports.Global={}));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
'use strict';var chunk5ETPYYQR_cjs=require('./chunk-5ETPYYQR.cjs');require('./chunk-GY3SWWW3.cjs');Object.defineProperty(exports,"Log",{enumerable:true,get:function(){return chunk5ETPYYQR_cjs.a}});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{a as Log}from'./chunk-6TRL3CVJ.mjs';import'./chunk-HAMGVOQD.mjs';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
'use strict';var chunkASIAS35P_cjs=require('./chunk-ASIAS35P.cjs');require('./chunk-RR6UFR5U.cjs'),require('./chunk-5ETPYYQR.cjs'),require('./chunk-GY3SWWW3.cjs');Object.defineProperty(exports,"ChannelPluginLoader",{enumerable:true,get:function(){return chunkASIAS35P_cjs.q}});Object.defineProperty(exports,"GatewayServer",{enumerable:true,get:function(){return chunkASIAS35P_cjs.s}});Object.defineProperty(exports,"GatewayWebSocketServer",{enumerable:true,get:function(){return chunkASIAS35P_cjs.r}});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{q as ChannelPluginLoader,s as GatewayServer,r as GatewayWebSocketServer}from'./chunk-DJTIL3AB.mjs';import'./chunk-77F43CRD.mjs';import'./chunk-6TRL3CVJ.mjs';import'./chunk-HAMGVOQD.mjs';
|
package/dist/cli.cjs
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
'use strict';var chunk2MXYBRPH_cjs=require('./chunks/chunk-2MXYBRPH.cjs'),chunkRR6UFR5U_cjs=require('./chunks/chunk-RR6UFR5U.cjs'),chunk5ETPYYQR_cjs=require('./chunks/chunk-5ETPYYQR.cjs');require('./chunks/chunk-GY3SWWW3.cjs');var commander=require('commander'),utils=require('@easbot/utils');var R={languages:[{value:"zh-CN",name:"\u7B80\u4F53\u4E2D\u6587",example:"\u4F60\u597D\uFF0CEASBOT\uFF01",supported:true},{value:"en-US",name:"English (United States)",example:"Hello, EASBOT!",supported:true}]};var A=R.languages,M=A.filter(t=>t.supported).map(t=>t.value),d={defaultLocale:"zh-CN",locales:M},m={},f=(t,e)=>{let o=m[t]||{translation:{}};return m[t]={translation:{...o.translation,...e.translation}},m[t]},y=(t=d.defaultLocale)=>(m[t]||f(t,{translation:{}}),{locale:t,resources:m[t]||{translation:{}}});var U={translation:{"cli.startup.title":"Gateway WebSocket \u670D\u52A1\u5DF2\u542F\u52A8","cli.startup.status":"\u72B6\u6001","cli.startup.port":"\u7AEF\u53E3","cli.startup.hostname":"\u4E3B\u673A\u5730\u5740","cli.startup.protocol":"\u534F\u8BAE","cli.startup.connections":"\u8FDE\u63A5\u6570","cli.startup.running":"\u8FD0\u884C\u4E2D","cli.startup.stopped":"\u5DF2\u505C\u6B62","cli.startup.mode":"\u6A21\u5F0F","cli.startup.mode_standalone":"\u72EC\u7ACB\u6A21\u5F0F","cli.startup.mode_integrated":"\u96C6\u6210\u6A21\u5F0F","cli.status.title":"Gateway WebSocket \u670D\u52A1\u72B6\u6001","cli.stop.title":"Gateway WebSocket \u670D\u52A1\u5DF2\u505C\u6B62","cli.already_running":"Gateway \u670D\u52A1\u5DF2\u5728\u8FD0\u884C\u4E2D","cli.already_stopped":"Gateway \u670D\u52A1\u5DF2\u505C\u6B62","cli.shutdown_signal":"\u6536\u5230 {{signal}}\uFF0C\u6B63\u5728\u4F18\u96C5\u5173\u95ED...","cli.shutdown_success":"Gateway \u670D\u52A1\u5DF2\u6210\u529F\u505C\u6B62","cli.unknown_command":"\u672A\u77E5\u547D\u4EE4: {{command}}","cli.error.start_failed":"\u542F\u52A8 Gateway \u5931\u8D25","cli.error.stop_failed":"\u505C\u6B62 Gateway \u5931\u8D25","cli.error.restart_failed":"\u91CD\u542F Gateway \u5931\u8D25","cli.error.status_failed":"\u83B7\u53D6 Gateway \u72B6\u6001\u5931\u8D25","cli.error.shutdown":"\u5173\u95ED\u65F6\u53D1\u751F\u9519\u8BEF","cli.error.execution_failed":"CLI \u6267\u884C\u5931\u8D25","cli.error.detail":"\u9519\u8BEF\u8BE6\u60C5:","cli.command.start.desc":"\u542F\u52A8 Gateway WebSocket \u670D\u52A1","cli.command.stop.desc":"\u505C\u6B62 Gateway \u670D\u52A1","cli.command.restart.desc":"\u91CD\u542F Gateway \u670D\u52A1","cli.command.status.desc":"\u67E5\u770B Gateway \u670D\u52A1\u72B6\u6001","cli.option.directory":"\u5DE5\u4F5C\u76EE\u5F55","cli.option.port":"\u670D\u52A1\u7AEF\u53E3","cli.option.hostname":"\u4E3B\u673A\u5730\u5740","cli.option.debug":"\u542F\u7528\u8C03\u8BD5\u6A21\u5F0F","cli.help.command":"\u663E\u793A\u5E2E\u52A9\u4FE1\u606F","cli.program.description":"Gateway WebSocket \u670D\u52A1\u7BA1\u7406 CLI","cli.examples.title":"\u793A\u4F8B","cli.example.start":"\u542F\u52A8\u670D\u52A1","cli.example.stop":"\u505C\u6B62\u670D\u52A1","cli.example.restart":"\u91CD\u542F\u670D\u52A1","cli.example.hostname":"\u6307\u5B9A\u76D1\u542C\u5730\u5740"}},T=U;var H={translation:{"cli.startup.title":"Gateway WebSocket Server Started","cli.startup.status":"Status","cli.startup.port":"Port","cli.startup.hostname":"Hostname","cli.startup.protocol":"Protocol","cli.startup.connections":"Connections","cli.startup.running":"Running","cli.startup.stopped":"Stopped","cli.startup.mode":"Mode","cli.startup.mode_standalone":"Standalone","cli.startup.mode_integrated":"Integrated","cli.status.title":"Gateway WebSocket Server Status","cli.stop.title":"Gateway WebSocket Server Stopped","cli.already_running":"Gateway server is already running.","cli.already_stopped":"Gateway server is already stopped.","cli.shutdown_signal":"Received {{signal}}, shutting down gracefully...","cli.shutdown_success":"Gateway stopped successfully.","cli.unknown_command":"Unknown command: {{command}}","cli.error.start_failed":"Failed to start gateway","cli.error.stop_failed":"Failed to stop gateway","cli.error.restart_failed":"Failed to restart gateway","cli.error.status_failed":"Failed to get gateway status","cli.error.shutdown":"Error during shutdown","cli.error.execution_failed":"CLI failed to execute","cli.error.detail":"Error detail:","cli.command.start.desc":"Start Gateway WebSocket service","cli.command.stop.desc":"Stop Gateway service","cli.command.restart.desc":"Restart Gateway service","cli.command.status.desc":"Check Gateway service status","cli.option.directory":"Working directory","cli.option.port":"Service port","cli.option.hostname":"Host address","cli.option.debug":"Enable debug mode","cli.help.command":"Display help information","cli.program.description":"Gateway WebSocket service management CLI","cli.examples.title":"Examples","cli.example.start":"Start service","cli.example.stop":"Stop service","cli.example.restart":"Restart service","cli.example.hostname":"Specify listening address"}},G=H;var z=()=>{y("zh-CN"),y("en-US"),f("zh-CN",T),f("en-US",G);};z();var S=new Map;var v=new Map;var D=t=>{if(v.has(t))return v.get(t);let e=/{{\s*(\w+)\s*}}/g,o=[],a;for(;(a=e.exec(t))!==null;){let l=a[1];l&&!o.includes(l)&&o.push(l);}let p=new RegExp("{{\\s*("+o.join("|")+")\\s*}}","g"),n={keys:o,regex:p};return v.set(t,n),n},_=(t,e)=>{if(!t||typeof t!="string")return "";if(!e||Object.keys(e).length===0)return t;let{regex:o,keys:a}=D(t);return a.length===0||!a.some(n=>n in e)?t:t.replace(o,(n,l)=>{let u=e[l];return u==null?"":String(u)})},X=t=>t&&d.locales.includes(t)?t:d.defaultLocale,I=t=>{if(!S.has(t)){let{resources:e}=y(t);S.set(t,e);}return S.get(t)},K=(t,e={})=>{let o=X(e.locale),p=I(o)?.translation[t];if(p&&typeof p=="string"){let n=_(p,e.vars);return n!=null?String(n):String(t)}if(o!==d.defaultLocale){let l=I(d.defaultLocale)?.translation[t];if(l&&typeof l=="string"){let u=_(l,e.vars);return u!=null?String(u):String(t)}}return String(e.fallback??t)},r=K;var i=chunk5ETPYYQR_cjs.a.create({service:"cli-gateway"}),w=58,C="\u2551",O="\u2554",k="\u255A",N="\u2560",L="\u2550";function Z(t,e=w){let o=e-t.length;return o<=0?t:t+" ".repeat(o)}function s(t){console.log(`${C} ${Z(t)} ${C}`);}function $(){console.log(`${O}${L.repeat(w)}${O.replace("\u2554","\u2557")}`);}function B(){console.log(`${N}${L.repeat(w)}${N.replace("\u2560","\u2563")}`);}function E(){console.log(`${k}${L.repeat(w)}${k.replace("\u255A","\u255D")}`);}function P(t){console.log(""),$(),s(r("cli.startup.title")),B(),s(`${r("cli.startup.status")}: ${r("cli.startup.running").padEnd(37-r("cli.startup.status").length)}`),s(`${r("cli.startup.port")}: ${String(t.port).padEnd(37-r("cli.startup.port").length)}`),s(`${r("cli.startup.hostname")}: ${t.hostname.padEnd(37-r("cli.startup.hostname").length)}`),s(`${r("cli.startup.protocol")}: ws${" ".repeat(32)}`),t.connections!==void 0&&s(`${r("cli.startup.connections")}:${String(t.connections).padEnd(37-r("cli.startup.connections").length)}`),s(`${r("cli.startup.mode")}: ${(t.mode==="standalone"?r("cli.startup.mode_standalone"):r("cli.startup.mode_integrated")).padEnd(37-r("cli.startup.mode").length)}`),E(),console.log("");}function q(){console.log(""),$(),s(r("cli.stop.title")),E(),console.log("");}async function Q(){try{let t=chunk2MXYBRPH_cjs.a.getStatus(),o=(await chunk2MXYBRPH_cjs.a.get())?.getStatus();console.log(""),$(),s(r("cli.status.title")),B(),s(`${r("cli.startup.status")}: ${t.toUpperCase().padEnd(37-r("cli.startup.status").length)}`),o&&(s(`${r("cli.startup.port")}: ${String(o.port).padEnd(37-r("cli.startup.port").length)}`),s(`${r("cli.startup.hostname")}: ${(o.hostname||"localhost").padEnd(37-r("cli.startup.hostname").length)}`),s(`${r("cli.startup.connections")}:${String(o.connections||0).padEnd(37-r("cli.startup.connections").length)}`)),E(),console.log("");}catch(t){i.error("Failed to get gateway status",{error:t instanceof Error?t.message:String(t)}),console.error(`${r("cli.error.status_failed")}: ${t instanceof Error?t.message:String(t)}`),process.exit(1);}}async function V(t){let e=t.directory||process.cwd();i.info("Starting gateway service",{port:t.port,hostname:t.hostname,directory:e});try{if(await chunk2MXYBRPH_cjs.a.init({directory:e,printLogs:t.debug,logLevel:t.debug?"DEBUG":"INFO"}),chunk2MXYBRPH_cjs.a.getStatus()==="running"){console.log(r("cli.already_running"));return}let a={};t.port&&(a.port=t.port),t.hostname&&(a.hostname=t.hostname),await chunk2MXYBRPH_cjs.a.start(a);let n=(await chunk2MXYBRPH_cjs.a.get())?.getStatus();P({port:n?.port||t.port||8080,hostname:n?.hostname||t.hostname||"localhost",connections:n?.connections||0,mode:chunkRR6UFR5U_cjs.P()?"integrated":"standalone"}),W();}catch(o){i.error("Failed to start gateway",{error:o instanceof Error?o.message:String(o)}),console.error(`${r("cli.error.start_failed")}: ${o instanceof Error?o.message:String(o)}`),process.exit(1);}}async function Y(){i.info("Stopping gateway service");try{if(chunk2MXYBRPH_cjs.a.getStatus()==="stopped"){console.log(r("cli.already_stopped"));return}await chunk2MXYBRPH_cjs.a.stop(),q(),i.info("Gateway stopped successfully");}catch(t){i.error("Failed to stop gateway",{error:t instanceof Error?t.message:String(t)}),console.error(`${r("cli.error.stop_failed")}: ${t instanceof Error?t.message:String(t)}`),process.exit(1);}}async function tt(t){i.info("Restarting gateway service");try{let e={};t.port&&(e.port=t.port),t.hostname&&(e.hostname=t.hostname),await chunk2MXYBRPH_cjs.a.restart(e);let a=(await chunk2MXYBRPH_cjs.a.get())?.getStatus();P({port:a?.port||t.port||8080,hostname:a?.hostname||t.hostname||"localhost",connections:a?.connections||0,mode:chunkRR6UFR5U_cjs.P()?"integrated":"standalone"}),W(),i.info("Gateway restarted successfully");}catch(e){i.error("Failed to restart gateway",{error:e instanceof Error?e.message:String(e)}),console.error(`${r("cli.error.restart_failed")}: ${e instanceof Error?e.message:String(e)}`),process.exit(1);}}function W(){let t=async e=>{i.debug(`Received ${e}, shutting down gracefully...`),console.log(`
|
|
2
|
-
${r("cli.shutdown_signal",{vars:{signal:e}})}`);try{await chunk2MXYBRPH_cjs.a.stop(),i.debug("Gateway stopped"),console.log(r("cli.shutdown_success"));}catch(o){i.error("Error during shutdown",{error:o instanceof Error?o.message:String(o)});}process.exit(0);};process.on("SIGINT",()=>{t("SIGINT").catch(console.error);}),process.on("SIGTERM",()=>{t("SIGTERM").catch(console.error);});}async function h(t,e){switch(t){case "start":await V(e);break;case "stop":await Y();break;case "restart":await tt(e);break;case "status":await Q();break;default:console.error(r("cli.unknown_command",{vars:{command:t}})),process.exit(1);}}function et(t){t.command("start").description(r("cli.command.start.desc")).option("-D, --directory <path>",r("cli.option.directory")).option("-p, --port <number>",r("cli.option.port"),e=>parseInt(e,10)).option("-H, --hostname <address>",r("cli.option.hostname")).option("-d, --debug",r("cli.option.debug"),false).action(async e=>{await h("start",{directory:e.directory,port:e.port,hostname:e.hostname,debug:e.debug});}),t.command("stop").description(r("cli.command.stop.desc")).action(async()=>{await h("stop",{});}),t.command("restart").description(r("cli.command.restart.desc")).option("-D, --directory <path>",r("cli.option.directory")).option("-p, --port <number>",r("cli.option.port"),e=>parseInt(e,10)).option("-H, --hostname <address>",r("cli.option.hostname")).option("-d, --debug",r("cli.option.debug"),false).action(async e=>{await h("restart",{directory:e.directory,port:e.port,hostname:e.hostname,debug:e.debug});}),t.command("status").description(r("cli.command.status.desc")).action(async()=>{await h("status",{});}),t.addHelpCommand("help",r("cli.help.command")).addHelpText("after",`
|
|
3
|
-
|
|
4
|
-
${r("cli.examples.title")}:
|
|
5
|
-
$ gateway start --port 8080 # ${r("cli.example.start")}
|
|
6
|
-
$ gateway stop # ${r("cli.example.stop")}
|
|
7
|
-
$ gateway restart --port 9090 # ${r("cli.example.restart")}
|
|
8
|
-
$ gateway start --hostname 0.0.0.0 # ${r("cli.example.hostname")}`);}async function rt(t=process.argv){utils.loadEnv();let e=new commander.Command;e.name("gateway").description(r("cli.program.description")).version("1.0.0"),et(e),await e.parseAsync(t);}rt().catch(t=>{let e=t.code==="EPIPE"||t.code==="EIO";e||i.error("CLI failed to execute",{error:t});let o=t instanceof Error?t.message:String(t),a=t instanceof Error?t.stack:"";try{console.error(r("cli.error.execution_failed")),o&&console.error(`${r("cli.error.detail")} ${o}`),a&&console.error(a);}catch{}e||process.exit(1);});exports.main=rt;exports.registerGatewayCommand=et;
|
package/dist/cli.d.cts
DELETED
package/dist/cli.d.ts
DELETED
package/dist/cli.mjs
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import {a as a$1}from'./chunks/chunk-YP2P4RQW.mjs';import {P as P$1}from'./chunks/chunk-77F43CRD.mjs';import {a}from'./chunks/chunk-6TRL3CVJ.mjs';import'./chunks/chunk-HAMGVOQD.mjs';import {Command}from'commander';import {loadEnv}from'@easbot/utils';var T={languages:[{value:"zh-CN",name:"\u7B80\u4F53\u4E2D\u6587",example:"\u4F60\u597D\uFF0CEASBOT\uFF01",supported:true},{value:"en-US",name:"English (United States)",example:"Hello, EASBOT!",supported:true}]};var M=T.languages,U=M.filter(t=>t.supported).map(t=>t.value),d={defaultLocale:"zh-CN",locales:U},f={},y=(t,e)=>{let o=f[t]||{translation:{}};return f[t]={translation:{...o.translation,...e.translation}},f[t]},h=(t=d.defaultLocale)=>(f[t]||y(t,{translation:{}}),{locale:t,resources:f[t]||{translation:{}}});var H={translation:{"cli.startup.title":"Gateway WebSocket \u670D\u52A1\u5DF2\u542F\u52A8","cli.startup.status":"\u72B6\u6001","cli.startup.port":"\u7AEF\u53E3","cli.startup.hostname":"\u4E3B\u673A\u5730\u5740","cli.startup.protocol":"\u534F\u8BAE","cli.startup.connections":"\u8FDE\u63A5\u6570","cli.startup.running":"\u8FD0\u884C\u4E2D","cli.startup.stopped":"\u5DF2\u505C\u6B62","cli.startup.mode":"\u6A21\u5F0F","cli.startup.mode_standalone":"\u72EC\u7ACB\u6A21\u5F0F","cli.startup.mode_integrated":"\u96C6\u6210\u6A21\u5F0F","cli.status.title":"Gateway WebSocket \u670D\u52A1\u72B6\u6001","cli.stop.title":"Gateway WebSocket \u670D\u52A1\u5DF2\u505C\u6B62","cli.already_running":"Gateway \u670D\u52A1\u5DF2\u5728\u8FD0\u884C\u4E2D","cli.already_stopped":"Gateway \u670D\u52A1\u5DF2\u505C\u6B62","cli.shutdown_signal":"\u6536\u5230 {{signal}}\uFF0C\u6B63\u5728\u4F18\u96C5\u5173\u95ED...","cli.shutdown_success":"Gateway \u670D\u52A1\u5DF2\u6210\u529F\u505C\u6B62","cli.unknown_command":"\u672A\u77E5\u547D\u4EE4: {{command}}","cli.error.start_failed":"\u542F\u52A8 Gateway \u5931\u8D25","cli.error.stop_failed":"\u505C\u6B62 Gateway \u5931\u8D25","cli.error.restart_failed":"\u91CD\u542F Gateway \u5931\u8D25","cli.error.status_failed":"\u83B7\u53D6 Gateway \u72B6\u6001\u5931\u8D25","cli.error.shutdown":"\u5173\u95ED\u65F6\u53D1\u751F\u9519\u8BEF","cli.error.execution_failed":"CLI \u6267\u884C\u5931\u8D25","cli.error.detail":"\u9519\u8BEF\u8BE6\u60C5:","cli.command.start.desc":"\u542F\u52A8 Gateway WebSocket \u670D\u52A1","cli.command.stop.desc":"\u505C\u6B62 Gateway \u670D\u52A1","cli.command.restart.desc":"\u91CD\u542F Gateway \u670D\u52A1","cli.command.status.desc":"\u67E5\u770B Gateway \u670D\u52A1\u72B6\u6001","cli.option.directory":"\u5DE5\u4F5C\u76EE\u5F55","cli.option.port":"\u670D\u52A1\u7AEF\u53E3","cli.option.hostname":"\u4E3B\u673A\u5730\u5740","cli.option.debug":"\u542F\u7528\u8C03\u8BD5\u6A21\u5F0F","cli.help.command":"\u663E\u793A\u5E2E\u52A9\u4FE1\u606F","cli.program.description":"Gateway WebSocket \u670D\u52A1\u7BA1\u7406 CLI","cli.examples.title":"\u793A\u4F8B","cli.example.start":"\u542F\u52A8\u670D\u52A1","cli.example.stop":"\u505C\u6B62\u670D\u52A1","cli.example.restart":"\u91CD\u542F\u670D\u52A1","cli.example.hostname":"\u6307\u5B9A\u76D1\u542C\u5730\u5740"}},G=H;var z={translation:{"cli.startup.title":"Gateway WebSocket Server Started","cli.startup.status":"Status","cli.startup.port":"Port","cli.startup.hostname":"Hostname","cli.startup.protocol":"Protocol","cli.startup.connections":"Connections","cli.startup.running":"Running","cli.startup.stopped":"Stopped","cli.startup.mode":"Mode","cli.startup.mode_standalone":"Standalone","cli.startup.mode_integrated":"Integrated","cli.status.title":"Gateway WebSocket Server Status","cli.stop.title":"Gateway WebSocket Server Stopped","cli.already_running":"Gateway server is already running.","cli.already_stopped":"Gateway server is already stopped.","cli.shutdown_signal":"Received {{signal}}, shutting down gracefully...","cli.shutdown_success":"Gateway stopped successfully.","cli.unknown_command":"Unknown command: {{command}}","cli.error.start_failed":"Failed to start gateway","cli.error.stop_failed":"Failed to stop gateway","cli.error.restart_failed":"Failed to restart gateway","cli.error.status_failed":"Failed to get gateway status","cli.error.shutdown":"Error during shutdown","cli.error.execution_failed":"CLI failed to execute","cli.error.detail":"Error detail:","cli.command.start.desc":"Start Gateway WebSocket service","cli.command.stop.desc":"Stop Gateway service","cli.command.restart.desc":"Restart Gateway service","cli.command.status.desc":"Check Gateway service status","cli.option.directory":"Working directory","cli.option.port":"Service port","cli.option.hostname":"Host address","cli.option.debug":"Enable debug mode","cli.help.command":"Display help information","cli.program.description":"Gateway WebSocket service management CLI","cli.examples.title":"Examples","cli.example.start":"Start service","cli.example.stop":"Stop service","cli.example.restart":"Restart service","cli.example.hostname":"Specify listening address"}},_=z;var D=()=>{h("zh-CN"),h("en-US"),y("zh-CN",G),y("en-US",_);};D();var v=new Map;var L=new Map;var X=t=>{if(L.has(t))return L.get(t);let e=/{{\s*(\w+)\s*}}/g,o=[],a;for(;(a=e.exec(t))!==null;){let l=a[1];l&&!o.includes(l)&&o.push(l);}let p=new RegExp("{{\\s*("+o.join("|")+")\\s*}}","g"),n={keys:o,regex:p};return L.set(t,n),n},I=(t,e)=>{if(!t||typeof t!="string")return "";if(!e||Object.keys(e).length===0)return t;let{regex:o,keys:a}=X(t);return a.length===0||!a.some(n=>n in e)?t:t.replace(o,(n,l)=>{let u=e[l];return u==null?"":String(u)})},K=t=>t&&d.locales.includes(t)?t:d.defaultLocale,C=t=>{if(!v.has(t)){let{resources:e}=h(t);v.set(t,e);}return v.get(t)},j=(t,e={})=>{let o=K(e.locale),p=C(o)?.translation[t];if(p&&typeof p=="string"){let n=I(p,e.vars);return n!=null?String(n):String(t)}if(o!==d.defaultLocale){let l=C(d.defaultLocale)?.translation[t];if(l&&typeof l=="string"){let u=I(l,e.vars);return u!=null?String(u):String(t)}}return String(e.fallback??t)},r=j;var i=a.create({service:"cli-gateway"}),x=58,O="\u2551",k="\u2554",N="\u255A",B="\u2560",$="\u2550";function q(t,e=x){let o=e-t.length;return o<=0?t:t+" ".repeat(o)}function s(t){console.log(`${O} ${q(t)} ${O}`);}function E(){console.log(`${k}${$.repeat(x)}${k.replace("\u2554","\u2557")}`);}function P(){console.log(`${B}${$.repeat(x)}${B.replace("\u2560","\u2563")}`);}function b(){console.log(`${N}${$.repeat(x)}${N.replace("\u255A","\u255D")}`);}function W(t){console.log(""),E(),s(r("cli.startup.title")),P(),s(`${r("cli.startup.status")}: ${r("cli.startup.running").padEnd(37-r("cli.startup.status").length)}`),s(`${r("cli.startup.port")}: ${String(t.port).padEnd(37-r("cli.startup.port").length)}`),s(`${r("cli.startup.hostname")}: ${t.hostname.padEnd(37-r("cli.startup.hostname").length)}`),s(`${r("cli.startup.protocol")}: ws${" ".repeat(32)}`),t.connections!==void 0&&s(`${r("cli.startup.connections")}:${String(t.connections).padEnd(37-r("cli.startup.connections").length)}`),s(`${r("cli.startup.mode")}: ${(t.mode==="standalone"?r("cli.startup.mode_standalone"):r("cli.startup.mode_integrated")).padEnd(37-r("cli.startup.mode").length)}`),b(),console.log("");}function Q(){console.log(""),E(),s(r("cli.stop.title")),b(),console.log("");}async function V(){try{let t=a$1.getStatus(),o=(await a$1.get())?.getStatus();console.log(""),E(),s(r("cli.status.title")),P(),s(`${r("cli.startup.status")}: ${t.toUpperCase().padEnd(37-r("cli.startup.status").length)}`),o&&(s(`${r("cli.startup.port")}: ${String(o.port).padEnd(37-r("cli.startup.port").length)}`),s(`${r("cli.startup.hostname")}: ${(o.hostname||"localhost").padEnd(37-r("cli.startup.hostname").length)}`),s(`${r("cli.startup.connections")}:${String(o.connections||0).padEnd(37-r("cli.startup.connections").length)}`)),b(),console.log("");}catch(t){i.error("Failed to get gateway status",{error:t instanceof Error?t.message:String(t)}),console.error(`${r("cli.error.status_failed")}: ${t instanceof Error?t.message:String(t)}`),process.exit(1);}}async function Y(t){let e=t.directory||process.cwd();i.info("Starting gateway service",{port:t.port,hostname:t.hostname,directory:e});try{if(await a$1.init({directory:e,printLogs:t.debug,logLevel:t.debug?"DEBUG":"INFO"}),a$1.getStatus()==="running"){console.log(r("cli.already_running"));return}let a={};t.port&&(a.port=t.port),t.hostname&&(a.hostname=t.hostname),await a$1.start(a);let n=(await a$1.get())?.getStatus();W({port:n?.port||t.port||8080,hostname:n?.hostname||t.hostname||"localhost",connections:n?.connections||0,mode:P$1()?"integrated":"standalone"}),F();}catch(o){i.error("Failed to start gateway",{error:o instanceof Error?o.message:String(o)}),console.error(`${r("cli.error.start_failed")}: ${o instanceof Error?o.message:String(o)}`),process.exit(1);}}async function tt(){i.info("Stopping gateway service");try{if(a$1.getStatus()==="stopped"){console.log(r("cli.already_stopped"));return}await a$1.stop(),Q(),i.info("Gateway stopped successfully");}catch(t){i.error("Failed to stop gateway",{error:t instanceof Error?t.message:String(t)}),console.error(`${r("cli.error.stop_failed")}: ${t instanceof Error?t.message:String(t)}`),process.exit(1);}}async function et(t){i.info("Restarting gateway service");try{let e={};t.port&&(e.port=t.port),t.hostname&&(e.hostname=t.hostname),await a$1.restart(e);let a=(await a$1.get())?.getStatus();W({port:a?.port||t.port||8080,hostname:a?.hostname||t.hostname||"localhost",connections:a?.connections||0,mode:P$1()?"integrated":"standalone"}),F(),i.info("Gateway restarted successfully");}catch(e){i.error("Failed to restart gateway",{error:e instanceof Error?e.message:String(e)}),console.error(`${r("cli.error.restart_failed")}: ${e instanceof Error?e.message:String(e)}`),process.exit(1);}}function F(){let t=async e=>{i.debug(`Received ${e}, shutting down gracefully...`),console.log(`
|
|
2
|
-
${r("cli.shutdown_signal",{vars:{signal:e}})}`);try{await a$1.stop(),i.debug("Gateway stopped"),console.log(r("cli.shutdown_success"));}catch(o){i.error("Error during shutdown",{error:o instanceof Error?o.message:String(o)});}process.exit(0);};process.on("SIGINT",()=>{t("SIGINT").catch(console.error);}),process.on("SIGTERM",()=>{t("SIGTERM").catch(console.error);});}async function w(t,e){switch(t){case "start":await Y(e);break;case "stop":await tt();break;case "restart":await et(e);break;case "status":await V();break;default:console.error(r("cli.unknown_command",{vars:{command:t}})),process.exit(1);}}function rt(t){t.command("start").description(r("cli.command.start.desc")).option("-D, --directory <path>",r("cli.option.directory")).option("-p, --port <number>",r("cli.option.port"),e=>parseInt(e,10)).option("-H, --hostname <address>",r("cli.option.hostname")).option("-d, --debug",r("cli.option.debug"),false).action(async e=>{await w("start",{directory:e.directory,port:e.port,hostname:e.hostname,debug:e.debug});}),t.command("stop").description(r("cli.command.stop.desc")).action(async()=>{await w("stop",{});}),t.command("restart").description(r("cli.command.restart.desc")).option("-D, --directory <path>",r("cli.option.directory")).option("-p, --port <number>",r("cli.option.port"),e=>parseInt(e,10)).option("-H, --hostname <address>",r("cli.option.hostname")).option("-d, --debug",r("cli.option.debug"),false).action(async e=>{await w("restart",{directory:e.directory,port:e.port,hostname:e.hostname,debug:e.debug});}),t.command("status").description(r("cli.command.status.desc")).action(async()=>{await w("status",{});}),t.addHelpCommand("help",r("cli.help.command")).addHelpText("after",`
|
|
3
|
-
|
|
4
|
-
${r("cli.examples.title")}:
|
|
5
|
-
$ gateway start --port 8080 # ${r("cli.example.start")}
|
|
6
|
-
$ gateway stop # ${r("cli.example.stop")}
|
|
7
|
-
$ gateway restart --port 9090 # ${r("cli.example.restart")}
|
|
8
|
-
$ gateway start --hostname 0.0.0.0 # ${r("cli.example.hostname")}`);}async function ot(t=process.argv){loadEnv();let e=new Command;e.name("gateway").description(r("cli.program.description")).version("1.0.0"),rt(e),await e.parseAsync(t);}ot().catch(t=>{let e=t.code==="EPIPE"||t.code==="EIO";e||i.error("CLI failed to execute",{error:t});let o=t instanceof Error?t.message:String(t),a=t instanceof Error?t.stack:"";try{console.error(r("cli.error.execution_failed")),o&&console.error(`${r("cli.error.detail")} ${o}`),a&&console.error(a);}catch{}e||process.exit(1);});export{ot as main,rt as registerGatewayCommand};
|