alchemylab 1.4.9 → 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 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"
@@ -1634,12 +1635,12 @@ e&&(this.pollingStatus=n.AUTHENTICATED,this.tokenResult=e,this.stopPolling(),r&&
1634
1635
  function r(){const e=process.env.ALCHEMY_OPENCODE_DIR
1635
1636
  if(e)return e
1636
1637
  try{const e=("undefined"!=typeof require?require:t(4245)).resolve("alchemylab-opencode/package.json")
1637
- return(0,n.dirname)(e)}catch{}}function s(e){return 22===e||e>=24}function o(e,t){return{command:function(){try{const e=(0,a.execFileSync)("node",["--version"],{encoding:"utf8"}).trim()
1638
+ return(0,n.dirname)(e)}catch{}}function s(e){return e>=24}function o(e,t){return{command:function(){try{const e=(0,a.execFileSync)("node",["--version"],{encoding:"utf8"}).trim()
1638
1639
  if(s(parseInt(e.replace("v","").split(".")[0],10)))return"node"}catch{}const e=process.env.NVM_DIR||(0,n.join)(process.env.HOME||"",".nvm"),t=(0,n.join)(e,"versions","node")
1639
1640
  if((0,i.existsSync)(t))try{const e=(0,i.readdirSync)(t).filter((e=>s(parseInt(e.replace("v","").split(".")[0],10)))).sort(((e,t)=>{const r=parseInt(e.replace("v","").split(".")[0],10)
1640
1641
  return parseInt(t.replace("v","").split(".")[0],10)-r}))
1641
1642
  if(e.length>0){const r=(0,n.join)(t,e[0],"bin","node")
1642
- if((0,i.existsSync)(r))return r}}catch{}throw Error(`AlchemyLab requires Node.js 22 or 24+ to run the OpenCode server (Node 23 is not supported).\nYour current version: ${process.version}\nInstall a compatible version: nvm install 22 (or download from https://nodejs.org)`)}(),prependArgs:["--no-warnings",(0,n.join)(e,t)]}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.findOpencodeDir=r,exports.resolveServeCommand=function(){const e=r()
1643
+ if((0,i.existsSync)(r))return r}}catch{}throw Error(`AlchemyLab requires Node.js 24 or later to run the OpenCode server.\nYour current version: ${process.version}\nInstall a compatible version: nvm install 24 (or download from https://nodejs.org)`)}(),prependArgs:["--no-warnings",(0,n.join)(e,t)]}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.findOpencodeDir=r,exports.resolveServeCommand=function(){const e=r()
1643
1644
  return e?o((0,n.join)(e,"dist"),"serve.js"):{command:"opencode",prependArgs:["serve"]}},exports.resolveRunCommand=function(){const e=r()
1644
1645
  return e?o((0,n.join)(e,"dist"),"run.js"):{command:"opencode",prependArgs:[]}}
1645
1646
  const n=t(6928),i=t(9896),a=t(5317)},9266(e,exports,t){"use strict"
@@ -5163,12 +5163,12 @@ e&&(this.pollingStatus=s.AUTHENTICATED,this.tokenResult=e,this.stopPolling(),r&&
5163
5163
  function r(){const e=process.env.ALCHEMY_OPENCODE_DIR
5164
5164
  if(e)return e
5165
5165
  try{const e=("undefined"!=typeof require?require:t(4245)).resolve("alchemylab-opencode/package.json")
5166
- return(0,s.dirname)(e)}catch{}}function n(e){return 22===e||e>=24}function o(e,t){return{command:function(){try{const e=(0,a.execFileSync)("node",["--version"],{encoding:"utf8"}).trim()
5166
+ return(0,s.dirname)(e)}catch{}}function n(e){return e>=24}function o(e,t){return{command:function(){try{const e=(0,a.execFileSync)("node",["--version"],{encoding:"utf8"}).trim()
5167
5167
  if(n(parseInt(e.replace("v","").split(".")[0],10)))return"node"}catch{}const e=process.env.NVM_DIR||(0,s.join)(process.env.HOME||"",".nvm"),t=(0,s.join)(e,"versions","node")
5168
5168
  if((0,i.existsSync)(t))try{const e=(0,i.readdirSync)(t).filter((e=>n(parseInt(e.replace("v","").split(".")[0],10)))).sort(((e,t)=>{const r=parseInt(e.replace("v","").split(".")[0],10)
5169
5169
  return parseInt(t.replace("v","").split(".")[0],10)-r}))
5170
5170
  if(e.length>0){const r=(0,s.join)(t,e[0],"bin","node")
5171
- if((0,i.existsSync)(r))return r}}catch{}throw Error(`AlchemyLab requires Node.js 22 or 24+ to run the OpenCode server (Node 23 is not supported).\nYour current version: ${process.version}\nInstall a compatible version: nvm install 22 (or download from https://nodejs.org)`)}(),prependArgs:["--no-warnings",(0,s.join)(e,t)]}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.findOpencodeDir=r,exports.resolveServeCommand=function(){const e=r()
5171
+ if((0,i.existsSync)(r))return r}}catch{}throw Error(`AlchemyLab requires Node.js 24 or later to run the OpenCode server.\nYour current version: ${process.version}\nInstall a compatible version: nvm install 24 (or download from https://nodejs.org)`)}(),prependArgs:["--no-warnings",(0,s.join)(e,t)]}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.findOpencodeDir=r,exports.resolveServeCommand=function(){const e=r()
5172
5172
  return e?o((0,s.join)(e,"dist"),"serve.js"):{command:"opencode",prependArgs:["serve"]}},exports.resolveRunCommand=function(){const e=r()
5173
5173
  return e?o((0,s.join)(e,"dist"),"run.js"):{command:"opencode",prependArgs:[]}}
5174
5174
  const s=t(6928),i=t(9896),a=t(5317)},9072(e,exports,t){"use strict"
package/dist/index.js CHANGED
@@ -5251,12 +5251,12 @@ e&&(this.pollingStatus=s.AUTHENTICATED,this.tokenResult=e,this.stopPolling(),r&&
5251
5251
  function r(){const e=process.env.ALCHEMY_OPENCODE_DIR
5252
5252
  if(e)return e
5253
5253
  try{const e=("undefined"!=typeof require?require:t(4245)).resolve("alchemylab-opencode/package.json")
5254
- return(0,s.dirname)(e)}catch{}}function n(e){return 22===e||e>=24}function o(e,t){return{command:function(){try{const e=(0,a.execFileSync)("node",["--version"],{encoding:"utf8"}).trim()
5254
+ return(0,s.dirname)(e)}catch{}}function n(e){return e>=24}function o(e,t){return{command:function(){try{const e=(0,a.execFileSync)("node",["--version"],{encoding:"utf8"}).trim()
5255
5255
  if(n(parseInt(e.replace("v","").split(".")[0],10)))return"node"}catch{}const e=process.env.NVM_DIR||(0,s.join)(process.env.HOME||"",".nvm"),t=(0,s.join)(e,"versions","node")
5256
5256
  if((0,i.existsSync)(t))try{const e=(0,i.readdirSync)(t).filter((e=>n(parseInt(e.replace("v","").split(".")[0],10)))).sort(((e,t)=>{const r=parseInt(e.replace("v","").split(".")[0],10)
5257
5257
  return parseInt(t.replace("v","").split(".")[0],10)-r}))
5258
5258
  if(e.length>0){const r=(0,s.join)(t,e[0],"bin","node")
5259
- if((0,i.existsSync)(r))return r}}catch{}throw Error(`AlchemyLab requires Node.js 22 or 24+ to run the OpenCode server (Node 23 is not supported).\nYour current version: ${process.version}\nInstall a compatible version: nvm install 22 (or download from https://nodejs.org)`)}(),prependArgs:["--no-warnings",(0,s.join)(e,t)]}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.findOpencodeDir=r,exports.resolveServeCommand=function(){const e=r()
5259
+ if((0,i.existsSync)(r))return r}}catch{}throw Error(`AlchemyLab requires Node.js 24 or later to run the OpenCode server.\nYour current version: ${process.version}\nInstall a compatible version: nvm install 24 (or download from https://nodejs.org)`)}(),prependArgs:["--no-warnings",(0,s.join)(e,t)]}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.findOpencodeDir=r,exports.resolveServeCommand=function(){const e=r()
5260
5260
  return e?o((0,s.join)(e,"dist"),"serve.js"):{command:"opencode",prependArgs:["serve"]}},exports.resolveRunCommand=function(){const e=r()
5261
5261
  return e?o((0,s.join)(e,"dist"),"run.js"):{command:"opencode",prependArgs:[]}}
5262
5262
  const s=t(6928),i=t(9896),a=t(5317)},9072(e,exports,t){"use strict"
@@ -4947,12 +4947,12 @@ e&&(this.pollingStatus=o.AUTHENTICATED,this.tokenResult=e,this.stopPolling(),r&&
4947
4947
  function r(){const e=process.env.ALCHEMY_OPENCODE_DIR
4948
4948
  if(e)return e
4949
4949
  try{const e=("undefined"!=typeof require?require:t(4245)).resolve("alchemylab-opencode/package.json")
4950
- return(0,o.dirname)(e)}catch{}}function n(e){return 22===e||e>=24}function s(e,t){return{command:function(){try{const e=(0,a.execFileSync)("node",["--version"],{encoding:"utf8"}).trim()
4950
+ return(0,o.dirname)(e)}catch{}}function n(e){return e>=24}function s(e,t){return{command:function(){try{const e=(0,a.execFileSync)("node",["--version"],{encoding:"utf8"}).trim()
4951
4951
  if(n(parseInt(e.replace("v","").split(".")[0],10)))return"node"}catch{}const e=process.env.NVM_DIR||(0,o.join)(process.env.HOME||"",".nvm"),t=(0,o.join)(e,"versions","node")
4952
4952
  if((0,i.existsSync)(t))try{const e=(0,i.readdirSync)(t).filter((e=>n(parseInt(e.replace("v","").split(".")[0],10)))).sort(((e,t)=>{const r=parseInt(e.replace("v","").split(".")[0],10)
4953
4953
  return parseInt(t.replace("v","").split(".")[0],10)-r}))
4954
4954
  if(e.length>0){const r=(0,o.join)(t,e[0],"bin","node")
4955
- if((0,i.existsSync)(r))return r}}catch{}throw Error(`AlchemyLab requires Node.js 22 or 24+ to run the OpenCode server (Node 23 is not supported).\nYour current version: ${process.version}\nInstall a compatible version: nvm install 22 (or download from https://nodejs.org)`)}(),prependArgs:["--no-warnings",(0,o.join)(e,t)]}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.findOpencodeDir=r,exports.resolveServeCommand=function(){const e=r()
4955
+ if((0,i.existsSync)(r))return r}}catch{}throw Error(`AlchemyLab requires Node.js 24 or later to run the OpenCode server.\nYour current version: ${process.version}\nInstall a compatible version: nvm install 24 (or download from https://nodejs.org)`)}(),prependArgs:["--no-warnings",(0,o.join)(e,t)]}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.findOpencodeDir=r,exports.resolveServeCommand=function(){const e=r()
4956
4956
  return e?s((0,o.join)(e,"dist"),"serve.js"):{command:"opencode",prependArgs:["serve"]}},exports.resolveRunCommand=function(){const e=r()
4957
4957
  return e?s((0,o.join)(e,"dist"),"run.js"):{command:"opencode",prependArgs:[]}}
4958
4958
  const o=t(6928),i=t(9896),a=t(5317)},9072(e,exports,t){"use strict"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alchemylab",
3
- "version": "1.4.9",
3
+ "version": "1.4.11",
4
4
  "private": false,
5
5
  "description": "AlchemyLab - agentic coding IDEm",
6
6
  "author": "Testfire Software",