alchemylab 1.4.10 → 1.4.11

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/dist/cli.js +19 -18
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -109,25 +109,26 @@ const o=s(t(6928)),n=s(t(857)),i=s(t(9896)),a=t(3962),c=t(5419),l=t(5317),d=t(88
109
109
  exports.UnifiedLauncher=class{constructor(e,t,r){this.logger=e,this.installContext=t,this.configurer=r}async launch(e){const{projectPath:t,settings:s,multiAgent:o}=e,{installPath:n,nodePath:i}=this.installContext
110
110
  this.logger.info("UnifiedLauncher: Starting launch",{projectPath:t,installPath:n})
111
111
  try{const a=await this.configurer.configureOpenCode(n,t,i,s,o)
112
- return a.success?(this.logger.info("UnifiedLauncher: Configuration complete",{configPath:a.configPath}),this.logger.info("[plugin-diag] pre-spawn",r()),this.launchBackground(e,a)):(this.logger.error("UnifiedLauncher: Configuration failed",{error:a.error}),{success:!1,error:a.error})}catch(e){return this.logger.error("UnifiedLauncher: Launch failed",{error:(0,d.getErrorMessage)(e)}),{success:!1,error:(0,d.getErrorMessage)(e)}}}async launchBackground(e,s){const{projectPath:n,envVars:u}=e,{resolveServeCommand:h,findOpencodeDir:g}=await Promise.resolve().then(t.bind(t,9068))
113
- if(!g())try{(0,l.execFileSync)("which",["opencode"],{stdio:"pipe"})}catch{return{success:!1,error:"alchemylab-opencode package not installed and no system `opencode` on PATH."}}this.logger.info("UnifiedLauncher: Launching opencode serve in background",{command:"opencode serve",cwd:n})
114
- const p=h()
115
- return new Promise((e=>{const t=o.default.join(n,".alchemy_lab","opencode"),h=o.default.join(t,"log")
116
- let g=null
117
- const m=e=>{if(!g)return
118
- const t=g
119
- g=null,t.end(e)}
120
- try{i.default.mkdirSync(h,{recursive:!0})
121
- const e=o.default.join(h,"opencode-serve.log")
122
- i.default.writeFileSync(e,`# opencode-serve.log \u2014 launched ${(new Date).toISOString()}\n`),g=i.default.createWriteStream(e,{flags:"a"})}catch(e){this.logger.warn("UnifiedLauncher: Could not open opencode log file",{error:(0,d.getErrorMessage)(e)})}const f=(0,l.spawn)(p.command,[...p.prependArgs,"--port","0","--data-dir",t],{stdio:["ignore","pipe","pipe"],cwd:n,detached:!0,env:{...process.env,...(0,c.getOpencodeSpawnEnv)(n,(0,a.isDevMode)()),...u}})
123
- let y="",v=!1
124
- const w=t=>{y+=t
125
- const o=y.match(/listening on http:\/\/[^:]+:(\d+)/)
126
- if(o&&!v){const t=parseInt(o[1],10)
127
- v=!0,this.logger.info("UnifiedLauncher: Discovered opencode serve port",{pid:f.pid,port:t}),this.logger.info("[plugin-diag] port-ready",{pid:f.pid,port:t,...r()}),setTimeout((()=>{this.logger.info("[plugin-diag] port-ready+5s",{pid:f.pid,...r()})}),5e3).unref(),setTimeout((()=>{this.logger.info("[plugin-diag] port-ready+15s",{pid:f.pid,...r()})}),15e3).unref(),f.unref(),e({success:!0,pid:f.pid,port:t,configPath:s.configPath})}}
128
- f.stdout?.on("data",(e=>{g&&g.write(e),w(e.toString())})),f.stderr?.on("data",(e=>{if(g){const t=e.toString().split("\n")
112
+ return a.success?(this.logger.info("UnifiedLauncher: Configuration complete",{configPath:a.configPath}),this.logger.info("[plugin-diag] pre-spawn",r()),this.launchBackground(e,a)):(this.logger.error("UnifiedLauncher: Configuration failed",{error:a.error}),{success:!1,error:a.error})}catch(e){return this.logger.error("UnifiedLauncher: Launch failed",{error:(0,d.getErrorMessage)(e)}),{success:!1,error:(0,d.getErrorMessage)(e)}}}async launchBackground(e,s){const{projectPath:u,envVars:h}=e,{resolveServeCommand:g,findOpencodeDir:p}=await Promise.resolve().then(t.bind(t,9068))
113
+ if(!p())try{(0,l.execFileSync)("which",["opencode"],{stdio:"pipe"})}catch{return{success:!1,error:"alchemylab-opencode package not installed and no system `opencode` on PATH."}}this.logger.info("UnifiedLauncher: Launching opencode serve in background",{command:"opencode serve",cwd:u})
114
+ const m=g()
115
+ return new Promise((e=>{const t=o.default.join(u,".alchemy_lab","opencode"),g=process.env.XDG_DATA_HOME||o.default.join(n.default.homedir(),".local","share")
116
+ try{i.default.mkdirSync(o.default.join(g,"opencode"),{recursive:!0})}catch(e){this.logger.warn("UnifiedLauncher: Could not pre-create opencode globalData dir",{error:(0,d.getErrorMessage)(e)})}const p=o.default.join(t,"log")
117
+ let f=null
118
+ const y=e=>{if(!f)return
119
+ const t=f
120
+ f=null,t.end(e)}
121
+ try{i.default.mkdirSync(p,{recursive:!0})
122
+ const e=o.default.join(p,"opencode-serve.log")
123
+ i.default.writeFileSync(e,`# opencode-serve.log \u2014 launched ${(new Date).toISOString()}\n`),f=i.default.createWriteStream(e,{flags:"a"})}catch(e){this.logger.warn("UnifiedLauncher: Could not open opencode log file",{error:(0,d.getErrorMessage)(e)})}const v=(0,l.spawn)(m.command,[...m.prependArgs,"--port","0","--data-dir",t],{stdio:["ignore","pipe","pipe"],cwd:u,detached:!0,env:{...process.env,...(0,c.getOpencodeSpawnEnv)(u,(0,a.isDevMode)()),...h}})
124
+ let w="",I=!1
125
+ const b=t=>{w+=t
126
+ const o=w.match(/listening on http:\/\/[^:]+:(\d+)/)
127
+ if(o&&!I){const t=parseInt(o[1],10)
128
+ I=!0,this.logger.info("UnifiedLauncher: Discovered opencode serve port",{pid:v.pid,port:t}),this.logger.info("[plugin-diag] port-ready",{pid:v.pid,port:t,...r()}),setTimeout((()=>{this.logger.info("[plugin-diag] port-ready+5s",{pid:v.pid,...r()})}),5e3).unref(),setTimeout((()=>{this.logger.info("[plugin-diag] port-ready+15s",{pid:v.pid,...r()})}),15e3).unref(),v.unref(),e({success:!0,pid:v.pid,port:t,configPath:s.configPath})}}
129
+ v.stdout?.on("data",(e=>{f&&f.write(e),b(e.toString())})),v.stderr?.on("data",(e=>{if(f){const t=e.toString().split("\n")
129
130
  for(let e=0;e<t.length;e++){const r=t[e]
130
- 0===r.length&&e===t.length-1||g.write(`[stderr] ${r}\n`)}}w(e.toString())})),f.on("exit",((e,t)=>{m(`\n# opencode exited code=${e} signal=${t} at=${(new Date).toISOString()}\n`)})),setTimeout((()=>{v||(v=!0,this.logger.warn("UnifiedLauncher: Timeout waiting for opencode serve port",{outputBuffer:y.slice(0,500)}),f.unref(),e({success:!0,pid:f.pid,configPath:s.configPath,error:"Could not determine port from opencode serve output"}))}),1e4),f.on("error",(t=>{v||(v=!0,this.logger.error("UnifiedLauncher: opencode serve failed to start",{error:t.message}),m(`\n# child error: ${t.message}\n`),e({success:!1,error:"Failed to start opencode serve: "+t.message}))})),f.on("exit",(t=>{v||(v=!0,this.logger.error("UnifiedLauncher: opencode serve exited early",{code:t,output:y.slice(0,500)}),e({success:!1,error:"opencode serve exited with code "+t}))}))}))}}},1253(e,exports,t){"use strict"
131
+ 0===r.length&&e===t.length-1||f.write(`[stderr] ${r}\n`)}}b(e.toString())})),v.on("exit",((e,t)=>{y(`\n# opencode exited code=${e} signal=${t} at=${(new Date).toISOString()}\n`)})),setTimeout((()=>{I||(I=!0,this.logger.warn("UnifiedLauncher: Timeout waiting for opencode serve port",{outputBuffer:w.slice(0,500)}),v.unref(),e({success:!0,pid:v.pid,configPath:s.configPath,error:"Could not determine port from opencode serve output"}))}),1e4),v.on("error",(t=>{I||(I=!0,this.logger.error("UnifiedLauncher: opencode serve failed to start",{error:t.message}),y(`\n# child error: ${t.message}\n`),e({success:!1,error:"Failed to start opencode serve: "+t.message}))})),v.on("exit",(t=>{I||(I=!0,this.logger.error("UnifiedLauncher: opencode serve exited early",{code:t,output:w.slice(0,500)}),e({success:!1,error:"opencode serve exited with code "+t}))}))}))}}},1253(e,exports,t){"use strict"
131
132
  var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}}
132
133
  Object.defineProperty(exports,"__esModule",{value:!0}),exports.TokenManager=void 0
133
134
  const s=r(t(6928)),o=r(t(1943)),n=r(t(6982)),i=r(t(857)),a=t(9067),c=t(8824),l="alchemy-lab"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alchemylab",
3
- "version": "1.4.10",
3
+ "version": "1.4.11",
4
4
  "private": false,
5
5
  "description": "AlchemyLab - agentic coding IDEm",
6
6
  "author": "Testfire Software",