impactus-swarm 0.0.17 → 0.0.18

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/server/main.js +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impactus-swarm",
3
- "version": "0.0.17",
3
+ "version": "0.0.18",
4
4
  "description": "AI-powered terminal swarm orchestration platform",
5
5
  "type": "module",
6
6
  "bin": {
package/server/main.js CHANGED
@@ -33,7 +33,7 @@ set -gx TERM_PROGRAM impactus-swarm
33
33
  `.trim();default:return""}}static detectShell(e){return e.includes("zsh")?"zsh":e.includes("bash")?"bash":e.includes("fish")?"fish":"unknown"}static getEnvVars(e){return{TERM_PROGRAM:"impactus-swarm",__IMPACTUS_SHELL_INTEGRATION:"1"}}static async createInjectionEnv(e){if(e==="unknown"||e==="fish")return a.getEnvVars(e);try{let t=le(pn(),"impactus-shell-integration");if(await Nt(t,{recursive:!0}),process.platform!=="win32"&&await un(t,448),e==="zsh"){let r=le(t,"zsh");await Nt(r,{recursive:!0});let s=["# IMPACTUS Swarm Shell Integration","# Source original zshrc",'if [[ -f "$HOME/.zshrc" ]]; then',' ZDOTDIR="$HOME" source "$HOME/.zshrc"',"fi","",a.getInitScript("zsh")].join(`
34
34
  `);await Dt(le(r,".zshrc"),s,"utf-8");let n=["# Source original zshenv",'if [[ -f "$HOME/.zshenv" ]]; then',' ZDOTDIR="$HOME" source "$HOME/.zshenv"',"fi"].join(`
35
35
  `);return await Dt(le(r,".zshenv"),n,"utf-8"),{...a.getEnvVars("zsh"),ZDOTDIR:r}}if(e==="bash"){let r=le(t,"bash");await Nt(r,{recursive:!0});let s=["# IMPACTUS Swarm Shell Integration","# Source original bashrc",'if [[ -f "$HOME/.bashrc" ]]; then',' source "$HOME/.bashrc"',"fi","",a.getInitScript("bash")].join(`
36
- `),n=le(r,".bashrc_impactus");return await Dt(n,s,"utf-8"),{...a.getEnvVars("bash"),BASH_ENV:n}}}catch{}return a.getEnvVars(e)}};var hn=mn(import.meta.url),yr=hn("node-pty");function vr(){return process.platform==="win32"?process.env.COMSPEC||"cmd.exe":process.env.SHELL||"/bin/zsh"}async function Pt(){let a=vr(),e=ye.detectShell(a);return ye.createInjectionEnv(e)}async function xt(a){let e=vr(),t=[],r=await Pt(),{PORT:s,IMPACTUS_WEB_DIR:n,RELAY_URL:i,RELAY_ALLOWED_IPS:o,CLAUDECODE:c,...l}=process.env;return yr.spawn(e,t,{name:"xterm-256color",cols:a.cols,rows:a.rows,cwd:a.cwd,env:{...l,...r,TERM_PROGRAM:"ghostty",TERM_PROGRAM_VERSION:"3.0.0",KITTY_WINDOW_ID:"1",COLORTERM:"truecolor",...a.env}})}function _t(a,e,t){return yr.spawn("tmux",a,{name:"xterm-256color",cols:e,rows:t,cwd:gn()})}import{execFileSync as O}from"node:child_process";import{existsSync as fn,writeFileSync as wn,mkdirSync as Tn}from"node:fs";import{join as br}from"node:path";import{homedir as En}from"node:os";var N="impactus",Oe="impactus-",I=class{static _available=null;static _configPath=null;static isAvailable(){if(this._available!==null)return this._available;if(process.platform==="win32")return this._available=!1,!1;try{O("tmux",["-V"],{stdio:"pipe"}),this._available=!0}catch{this._available=!1}return this._available}static ensureConfig(){if(this._configPath)return this._configPath;let e=br(En(),".impactus-swarm");fn(e)||Tn(e,{recursive:!0});let t=br(e,"tmux.conf");return wn(t,["# IMPACTUS Swarm tmux config \u2014 auto-generated, do not edit","set -g status off","set -g history-limit 50000",'set -g default-terminal "xterm-256color"',"set -g escape-time 10","set -g focus-events on","set -g mouse off","# Suppress DA queries \u2014 tell tmux the outer terminal capabilities","# Allow smcup/rmcup so TUI apps (like Claude Code plan mode) use","# the alternate screen properly \u2014 this keeps xterm.js scrollback","# clean by preventing TUI rendering artifacts from polluting it.",'set -as terminal-overrides ",xterm*:Tc"'].join(`
36
+ `),n=le(r,".bashrc_impactus");return await Dt(n,s,"utf-8"),{...a.getEnvVars("bash"),BASH_ENV:n}}}catch{}return a.getEnvVars(e)}};var hn=mn(import.meta.url),yr=hn("node-pty");function vr(){return process.platform==="win32"?process.env.COMSPEC||"cmd.exe":process.env.SHELL||"/bin/zsh"}async function Pt(){let a=vr(),e=ye.detectShell(a);return ye.createInjectionEnv(e)}async function xt(a){let e=vr(),t=[],r=await Pt(),{PORT:s,IMPACTUS_WEB_DIR:n,RELAY_URL:i,RELAY_ALLOWED_IPS:o,CLAUDECODE:c,...l}=process.env;return yr.spawn(e,t,{name:"xterm-256color",cols:a.cols,rows:a.rows,cwd:a.cwd,env:{...l,...r,TERM_PROGRAM:"ghostty",TERM_PROGRAM_VERSION:"3.0.0",KITTY_WINDOW_ID:"1",COLORTERM:"truecolor",...a.env}})}function _t(a,e,t){return yr.spawn("tmux",a,{name:"xterm-256color",cols:e,rows:t,cwd:gn()})}import{execFileSync as O}from"node:child_process";import{existsSync as fn,writeFileSync as wn,mkdirSync as Tn}from"node:fs";import{join as br}from"node:path";import{homedir as En}from"node:os";var N="impactus",Oe="impactus-",I=class{static _available=null;static _configPath=null;static isAvailable(){if(this._available!==null)return this._available;if(process.platform==="win32")return this._available=!1,!1;try{O("tmux",["-V"],{stdio:"pipe"}),this._available=!0}catch{this._available=!1}return this._available}static ensureConfig(){if(this._configPath)return this._configPath;let e=br(En(),".impactus-swarm");fn(e)||Tn(e,{recursive:!0});let t=br(e,"tmux.conf");return wn(t,["# IMPACTUS Swarm tmux config \u2014 auto-generated, do not edit","set -g status off","set -g history-limit 50000",'set -g default-terminal "xterm-256color"',"set -g escape-time 10","set -g focus-events on","set -g mouse off","# Suppress DA queries \u2014 tell tmux the outer terminal capabilities","# Disable smcup/rmcup so tmux does NOT enter alternate screen in","# xterm.js \u2014 this allows xterm.js scrollback to accumulate normally.","# TUI apps inside tmux still use tmux's internal alternate screen.",'set -as terminal-overrides ",xterm*:Tc:smcup@:rmcup@"'].join(`
37
37
  `)+`
38
38
  `),this._configPath=t,t}static enablePassthrough(){try{O("tmux",["-L",N,"set-option","-g","allow-passthrough","on"],{stdio:"pipe"})}catch{}try{O("tmux",["-L",N,"set-option","-g","escape-time","10"],{stdio:"pipe"})}catch{}}static sessionName(e){return Oe+e.replace(/[^a-zA-Z0-9_-]/g,"_")}static createSession(e,t,r,s,n,i){let o=this.sessionName(e),c=this.ensureConfig(),l=["-L",N,"-f",c,"new-session","-d","-s",o,"-x",String(t),"-y",String(r),"-c",s];for(let[f,g]of Object.entries(n))g!==void 0&&g!==""&&l.push("-e",`${f}=${g}`);if(i)for(let[f,g]of Object.entries(i))g!==void 0&&l.push("-e",`${f}=${g}`);let{PORT:d,IMPACTUS_WEB_DIR:u,RELAY_URL:p,RELAY_ALLOWED_IPS:m,...h}=process.env;O("tmux",l,{stdio:"pipe",env:h});try{O("tmux",["-L",N,"set-environment","-t",o,"IMPACTUS_TERMINAL_ID",e],{stdio:"pipe"}),O("tmux",["-L",N,"set-environment","-t",o,"IMPACTUS_CREATED_AT",String(Date.now())],{stdio:"pipe"})}catch{}return this.enablePassthrough(),o}static getAttachArgs(e){return["-L",N,"attach-session","-t",e]}static killSession(e){try{O("tmux",["-L",N,"kill-session","-t",e],{stdio:"pipe"})}catch{}}static listSessions(){try{let e=O("tmux",["-L",N,"list-sessions","-F","#{session_name}"],{stdio:"pipe"}).toString().trim();return e?e.split(`
39
39
  `).filter(t=>t.startsWith(Oe)):[]}catch{return[]}}static hasSession(e){try{return O("tmux",["-L",N,"has-session","-t",e],{stdio:"pipe"}),!0}catch{return!1}}static getTerminalId(e){try{let r=O("tmux",["-L",N,"show-environment","-t",e,"IMPACTUS_TERMINAL_ID"],{stdio:"pipe"}).toString().trim().match(/^IMPACTUS_TERMINAL_ID=(.+)$/);return r?r[1]:null}catch{return e.startsWith(Oe)?e.slice(Oe.length):null}}static getCreatedAt(e){try{let r=O("tmux",["-L",N,"show-environment","-t",e,"IMPACTUS_CREATED_AT"],{stdio:"pipe"}).toString().trim().match(/^IMPACTUS_CREATED_AT=(\d+)$/);if(r)return parseInt(r[1],10)}catch{}return null}static capturePane(e){try{return O("tmux",["-L",N,"capture-pane","-t",e,"-p","-e","-J","-S","-"],{stdio:"pipe",maxBuffer:10485760}).toString().replace(/\n+$/,`