everclaw 0.3.5 → 0.3.6
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/index.js +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -335,7 +335,7 @@ RTK Token Compression
|
|
|
335
335
|
Minimum version: ${Ce}`)),console.log(G.gray(` Supported platforms: ${Object.keys(Er).join(", ")}`))}),o.command("update").description("Update rtk to the latest version").action(async()=>{let e=new Te,t=await e.getStatus(),n=t.installed&&t.version?t.version:null;console.log(n?G.cyan(`Current: v${n}`):G.gray("rtk is not installed."));try{console.log(G.gray("Fetching latest version..."));let r=await e.install({version:"latest",force:!0});n&&r.version===n?console.log(G.green(`Already at latest version (v${r.version})`)):console.log(G.green(`
|
|
336
336
|
rtk v${r.version} installed to ${r.binaryPath}`))}catch(r){console.error(G.red(`Failed to update rtk: ${r instanceof Error?r.message:String(r)}`)),process.exitCode=K.CONNECTIVITY_ERROR}}),o.command("enable").description("Enable rtk token compression in config").action(()=>{let e=M();if(e.tools.rtk.enabled){console.log(G.gray("RTK token compression is already enabled."));return}e.tools.rtk.enabled=!0,oe(e),console.log(G.green("RTK token compression enabled.")),console.log(G.gray("Restart the gateway for changes to take effect."))}),o.command("disable").description("Disable rtk token compression in config").action(()=>{let e=M();if(!e.tools.rtk.enabled){console.log(G.gray("RTK token compression is already disabled."));return}e.tools.rtk.enabled=!1,oe(e),console.log(G.yellow("RTK token compression disabled.")),console.log(G.gray("Restart the gateway for changes to take effect.")),console.log(G.gray("The binary remains installed \u2014 run `everclaw rtk uninstall` to remove it."))}),o}Tt();Ne();import{spawn as oc}from"node:child_process";import sc from"node:fs";import ic from"node:path";import j from"chalk";import{Command as ac,Option as lc}from"commander";function cc(){let o=process.argv[1];if(o){let e=ic.resolve(o);if(sc.existsSync(e))return e}return"everclaw"}async function dc(){let o=Ee();if(!o)return!0;if(!Ae(o.pid))return Pe(),!0;console.log(j.cyan(`Stopping gateway (PID ${o.pid})...`));try{process.kill(o.pid,"SIGTERM")}catch(t){return console.error(j.red(`Failed to send SIGTERM to PID ${o.pid}: ${String(t)}`)),!1}if(!await Br(o.pid,1e4)){console.log(j.yellow("Gateway did not exit within 10s, sending SIGKILL..."));try{process.kill(o.pid,"SIGKILL")}catch{}}return Pe(),console.log(j.green("Gateway stopped.")),!0}async function Vs(o){let e=Ee();if(e&&Ae(e.pid)){console.error(j.red(`Gateway is already running (PID ${e.pid}, port ${e.port}).`)),console.error(j.gray('Use "everclaw gateway restart" to restart it.')),process.exitCode=K.PROCESS_CONFLICT;return}e&&Pe();let t=M(),n=fo(o.port,t.gateway.port),r=cc(),s=["gateway","start","--port",String(n)];o.host&&s.push("--host",o.host),s.push("--_foreground");let i="",a=oc(r,s,{detached:!0,stdio:["ignore","ignore","pipe"],env:{...process.env}});if(!a.pid){console.error(j.red("Failed to spawn gateway process.")),process.exitCode=K.GENERAL_ERROR;return}if(a.stderr?.on("data",l=>{i+=l.toString("utf8"),i.length>4096&&(i=i.slice(-4096))}),setTimeout(()=>{a.stderr?.destroy()},3e3).unref(),a.unref(),Fr({pid:a.pid,port:n,startedAt:new Date().toISOString()}),await new Promise(l=>setTimeout(l,1500)),!Ae(a.pid)){Pe(),console.error(j.red("Gateway process exited immediately.")),i.trim()?console.error(j.gray(i.trim().split(`
|
|
337
337
|
`).map(l=>` ${l}`).join(`
|
|
338
|
-
`))):console.error(j.gray("No error output captured. Try running with -f for details.")),process.exitCode=K.GENERAL_ERROR;return}console.log(j.green(`Gateway started in background (PID ${a.pid}, port ${n}).`)),console.log(j.gray(`Dashboard: http://localhost:${n}/chat`)),console.log(j.gray("Use `everclaw gateway status` to check, `everclaw gateway stop` to stop."))}async function po(o){let e=M(),t={};o.host&&(t.gatewayHost=o.host),o.port&&(t.gatewayPort=fo(o.port,e.gateway.port));let n=Kt(e,process.env,t),r=n.gateway.port,s=Ee();if(s&&Ae(s.pid)){console.error(j.red(`Gateway is already running (PID ${s.pid}, port ${s.port}).`)),console.error(j.gray('Use "everclaw gateway restart" to restart it.')),process.exitCode=K.PROCESS_CONFLICT;return}s&&Pe();let i;try{i=await Hs({config:n,port:r,sessionKey:"default:everclaw"})}catch(g){console.log(j.red(String(g))),process.exitCode=K.GENERAL_ERROR;return}Fr({pid:process.pid,port:i.port,startedAt:new Date().toISOString()}),console.log(j.cyan(`Starting everclaw gateway on port ${i.port}...`)),i.enabledChannels.length?console.log(j.green(`Channels enabled: ${i.enabledChannels.join(", ")}`)):console.log(j.yellow("No channels enabled. Gateway will stay idle until channels are configured.")),console.log(j.green(`Dashboard: http://localhost:${i.port}/chat`)),console.log(j.gray("Gateway running. Press Ctrl+C to stop."));let a=null,l=async g=>a||(console.log(j.yellow(`
|
|
338
|
+
`))):console.error(j.gray("No error output captured. Try running with -f for details.")),process.exitCode=K.GENERAL_ERROR;return}console.log(j.green(`Gateway started in background (PID ${a.pid}, port ${n}).`)),console.log(j.gray(`Dashboard: http://localhost:${n}/chat`)),console.log(j.gray("Use `everclaw gateway status` to check, `everclaw gateway stop` to stop."))}async function po(o){let e=M(),t={};o.host&&(t.gatewayHost=o.host),o.port&&(t.gatewayPort=fo(o.port,e.gateway.port));let n=Kt(e,process.env,t),r=n.gateway.port,s=Ee();if(s&&s.pid!==process.pid&&Ae(s.pid)){console.error(j.red(`Gateway is already running (PID ${s.pid}, port ${s.port}).`)),console.error(j.gray('Use "everclaw gateway restart" to restart it.')),process.exitCode=K.PROCESS_CONFLICT;return}s&&s.pid!==process.pid&&Pe();let i;try{i=await Hs({config:n,port:r,sessionKey:"default:everclaw"})}catch(g){console.log(j.red(String(g))),process.exitCode=K.GENERAL_ERROR;return}Fr({pid:process.pid,port:i.port,startedAt:new Date().toISOString()}),console.log(j.cyan(`Starting everclaw gateway on port ${i.port}...`)),i.enabledChannels.length?console.log(j.green(`Channels enabled: ${i.enabledChannels.join(", ")}`)):console.log(j.yellow("No channels enabled. Gateway will stay idle until channels are configured.")),console.log(j.green(`Dashboard: http://localhost:${i.port}/chat`)),console.log(j.gray("Gateway running. Press Ctrl+C to stop."));let a=null,l=async g=>a||(console.log(j.yellow(`
|
|
339
339
|
Received ${g}. Shutting down gateway...`)),Pe(process.pid),a=mo(i).then(h=>{h>0&&console.log(j.gray(`Cancelled ${h} task(s) during shutdown.`))}).catch(h=>{process.exitCode=1,console.log(j.red(`Gateway shutdown failed: ${String(h)}`))}),a),c=()=>{l("SIGINT")},u=()=>{l("SIGTERM")};process.once("SIGINT",c),process.once("SIGTERM",u);try{await i.runPromise,a&&await a}finally{Pe(process.pid),process.off("SIGINT",c),process.off("SIGTERM",u)}}function Xs(){let o=new ac("gateway").description("Manage the everclaw gateway");return o.addHelpText("after",`
|
|
340
340
|
Examples:
|
|
341
341
|
everclaw gateway Start the gateway in background (default)
|