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.
- package/dist/cli.js +19 -18
- 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:
|
|
113
|
-
if(!
|
|
114
|
-
const
|
|
115
|
-
return new Promise((e=>{const t=o.default.join(
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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||
|
|
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"
|