makecoder 4.0.49 → 4.0.51

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/cc.mjs CHANGED
@@ -20,13 +20,13 @@ import{createRequire as vP5}from"node:module";var MP5=Object.create;var{getProto
20
20
  Object.assign(A, {
21
21
  post(...args) {
22
22
  const [url, payload, ...remainArgs] = args;
23
- const patchedUrl = url + (url.includes('?') ? '&' : '?') + 'app=codev-cli' + '&version=4.0.49' + '&session_id=' + I8() + (process.env.SPACE_ID ? '&space_id=' + process.env.SPACE_ID : '');
23
+ const patchedUrl = url + (url.includes('?') ? '&' : '?') + 'app=codev-cli' + '&version=4.0.51' + '&session_id=' + I8() + (process.env.SPACE_ID ? '&space_id=' + process.env.SPACE_ID : '');
24
24
  if (process.env.CODER_APIKEY) {
25
25
  const headerValues = payload.headers.values;
26
26
  headerValues.set('AUTHORIZATION', `Bearer ${process.env.CODER_APIKEY}`)
27
27
  }
28
28
 
29
- payload.headers.values.set('X-Coder-Version', '4.0.49');
29
+ payload.headers.values.set('X-Coder-Version', '4.0.51');
30
30
  payload.headers.values.set('X-Coder-Platform', process.platform);
31
31
  payload.headers.values.set('X-Coder-Arch', process.arch);
32
32
 
package/dist/coder.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- var Nt=Object.create;var Fe=Object.defineProperty;var jt=Object.getOwnPropertyDescriptor;var Ut=Object.getOwnPropertyNames;var Lt=Object.getPrototypeOf,Rt=Object.prototype.hasOwnProperty;var S=(c,e)=>()=>(e||c((e={exports:{}}).exports,e),e.exports);var Wt=(c,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ut(e))!Rt.call(c,o)&&o!==t&&Fe(c,o,{get:()=>e[o],enumerable:!(s=jt(e,o))||s.enumerable});return c};var Ht=(c,e,t)=>(t=c!=null?Nt(Lt(c)):{},Wt(e||!c||!c.__esModule?Fe(t,"default",{value:c,enumerable:!0}):t,c));var L=S((to,Jt)=>{Jt.exports={name:"makecoder",version:"4.0.49",description:"MakeCoder: Unified AI agent CLI tool integrating Claude Code, Codex and Gemini CLI",main:"./dist/coder.js",bin:{coder:"./dist/coder.js"},scripts:{test:'echo "Error: no test specified" && exit 1',start:"node ./src/coder.js",build:"node scripts/build.js","build:clean":"node scripts/build.js --clean","build:dev":"node scripts/build.js --no-minify --sourcemap",postinstall:"node scripts/postinstall.js"},keywords:["cli","ai","claude","gemini","codex","agent"],author:"makecoder",license:"MIT",repository:{type:"git",url:"https://github.com/makecoderai/coder.git"},homepage:"https://github.com/makecoderai/coder",dependencies:{"node-fetch":"^3.3.2",open:"^10.1.0",zod:"^3.25.76"},optionalDependencies:{bun:">=1.3.12"},engines:{node:">=20.0.0"},devDependencies:{chokidar:"^4.0.3"},files:["dist","claude","scripts/postinstall.js"]}});var je=S((so,Ne)=>{var T=require("fs"),Be=require("path"),Gt=require("os"),zt=new Set(["auth","skills","wiki","channel","team"]),Me=new Set(["claude","gemini","codex"]),Vt=new Set(["pub","auth","update","skills","wiki","channel","team"]),ie=class{constructor(){let e=process.env.CODER_PROFILE,t=e?`.coder.${e}`:".coder";this.configPath=Be.join(Gt.homedir(),t,"config.json"),this.defaultConfig={agent:"claude",auth:{apikey:null}}}loadConfig(){let e=Be.dirname(this.configPath);try{return T.existsSync(e)||T.mkdirSync(e,{recursive:!0}),T.existsSync(this.configPath)||T.writeFileSync(this.configPath,JSON.stringify(this.defaultConfig,null,2)),JSON.parse(T.readFileSync(this.configPath,"utf8"))}catch{return{...this.defaultConfig}}}getApiKeyFromConfig(e){return e.auth?.apikey?e.auth.apikey:e.auth?.ak&&e.auth?.sk?`${e.auth.ak}.${e.auth.sk}`:null}saveAuthToConfig(e){let t=this.loadConfig();t.auth={apikey:e};try{return T.writeFileSync(this.configPath,JSON.stringify(t,null,2)),!0}catch{return!1}}clearAuthFromConfig(){let e=this.loadConfig();e.auth={apikey:null};try{return T.writeFileSync(this.configPath,JSON.stringify(e,null,2)),!0}catch{return!1}}getTeam(){return this.loadConfig().team||null}setTeam(e,t){let s=this.loadConfig();e==null?delete s.team:s.team={id:e,name:t||""};try{return T.writeFileSync(this.configPath,JSON.stringify(s,null,2)),!0}catch{return!1}}async parse(e=process.argv.slice(2)){let t=this.loadConfig(),s={agent:t.agent||"claude",remainingArgs:[]},o=0;if(e.length>0){if(Me.has(e[0]))s.agent=e[0],s.agentSetBySubcommand=!0,o=1;else if(Vt.has(e[0])){if(s.command=e[0],o=1,e[0]==="auth"){let n=e[1];n==="--help"||n==="-h"?s.authSubcommand="--help":(s.authSubcommand=n,s.authRemainingArgs=e.slice(2)),o=e.length}else if(e[0]==="skills"){let n=e[1];s.skillsSubcommand=n==="--help"||n==="-h"?void 0:n,s.skillsArg=e[2],s.skillsRemainingArgs=e.slice(2),o=e.length}else if(e[0]==="wiki"){let n=e[1];s.wikiSubcommand=n==="--help"||n==="-h"?void 0:n,s.wikiArg=e[2],s.wikiRemainingArgs=e.slice(2),o=e.length}else if(e[0]==="team"){let n=e[1];s.teamSubcommand=n==="--help"||n==="-h"?void 0:n,s.teamArg=e[2],s.teamRemainingArgs=e.slice(2),o=e.length}else if(e[0]==="channel"){let n=e[1];n==="--help"||n==="-h"?s.channelSubcommand="--help":n==="list"||n==="show"||n==="add"||n==="remove"||n==="update"?(s.channelSubcommand=n,s.channelArg=e[2],s.channelRemainingArgs=e.slice(2)):s.channelRemainingArgs=e.slice(1),o=e.length}}}for(;o<e.length;){let n=e[o];if(n==="--agent"){if(s.agentSetBySubcommand)throw new Error(`\u4E0D\u80FD\u540C\u65F6\u4F7F\u7528\u5B50\u547D\u4EE4 '${s.agent}' \u548C --agent\uFF0C\u8BF7\u9009\u62E9\u5176\u4E00`);let i=e[o+1];if(!i||!Me.has(i))throw new Error("--agent \u9700\u8981\u6307\u5B9A\u4EE3\u7406\u7C7B\u578B\uFF08claude|gemini|codex\uFF09");s.agent=i,o+=2}else if(n==="--apikey"){let i=e[o+1];if(!i||i.startsWith("--"))throw new Error("--apikey \u9700\u8981\u63D0\u4F9B API Key \u503C");if(i.indexOf(".")===-1)throw new Error("API Key \u683C\u5F0F\u9519\u8BEF\uFF0C\u5E94\u4E3A <ak>.<sk>");s.apikey=i,o+=2}else if(n==="--name"){let i=e[o+1];i&&!i.startsWith("--")?(s.pubName=i,o+=2):o+=1}else if(n==="--allow-clone")s.allowClone=!0,o+=1;else if(n==="--meta-data"){let i=e[o+1];if(!i||i.startsWith("--"))throw new Error("--meta-data \u9700\u8981\u4E00\u4E2A JSON \u5B57\u7B26\u4E32\u503C");try{JSON.parse(i)}catch(a){throw new Error(`--meta-data \u4E0D\u662F\u5408\u6CD5\u7684 JSON\uFF1A${a.message}`)}s.pubMetaData=i,o+=2}else{s.remainingArgs=e.slice(o);break}}if(s.command!=="auth"&&!s.apikey){let n=this.getApiKeyFromConfig(t);s.apikey=n||process.env.CODER_APIKEY||null}s.codevServer=process.env.CODEV_SERVER||t.codevServer||"https://makecoder.com/bigapis/codev/v1";let r=s.remainingArgs.includes("--version")||s.remainingArgs.includes("-v")||s.remainingArgs.includes("--help")||s.remainingArgs.includes("-h");return!zt.has(s.command)&&!r&&!s.apikey&&await this._oauthLogin(s),s}async _oauthLogin(e){console.log(`\u274C \u5C1A\u672A\u767B\u5F55
2
+ var Nt=Object.create;var Fe=Object.defineProperty;var jt=Object.getOwnPropertyDescriptor;var Ut=Object.getOwnPropertyNames;var Lt=Object.getPrototypeOf,Rt=Object.prototype.hasOwnProperty;var S=(c,e)=>()=>(e||c((e={exports:{}}).exports,e),e.exports);var Wt=(c,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ut(e))!Rt.call(c,o)&&o!==t&&Fe(c,o,{get:()=>e[o],enumerable:!(s=jt(e,o))||s.enumerable});return c};var Ht=(c,e,t)=>(t=c!=null?Nt(Lt(c)):{},Wt(e||!c||!c.__esModule?Fe(t,"default",{value:c,enumerable:!0}):t,c));var L=S((to,Jt)=>{Jt.exports={name:"makecoder",version:"4.0.51",description:"MakeCoder: Unified AI agent CLI tool integrating Claude Code, Codex and Gemini CLI",main:"./dist/coder.js",bin:{coder:"./dist/coder.js"},scripts:{test:'echo "Error: no test specified" && exit 1',start:"node ./src/coder.js",build:"node scripts/build.js","build:clean":"node scripts/build.js --clean","build:dev":"node scripts/build.js --no-minify --sourcemap",postinstall:"node scripts/postinstall.js"},keywords:["cli","ai","claude","gemini","codex","agent"],author:"makecoder",license:"MIT",repository:{type:"git",url:"https://github.com/makecoderai/coder.git"},homepage:"https://github.com/makecoderai/coder",dependencies:{"node-fetch":"^3.3.2",open:"^10.1.0",zod:"^3.25.76"},optionalDependencies:{bun:">=1.3.12"},engines:{node:">=20.0.0"},devDependencies:{chokidar:"^4.0.3"},files:["dist","claude","scripts/postinstall.js"]}});var je=S((so,Ne)=>{var T=require("fs"),Be=require("path"),Gt=require("os"),zt=new Set(["auth","skills","wiki","channel","team"]),Me=new Set(["claude","gemini","codex"]),Vt=new Set(["pub","auth","update","skills","wiki","channel","team"]),ie=class{constructor(){let e=process.env.CODER_PROFILE,t=e?`.coder.${e}`:".coder";this.configPath=Be.join(Gt.homedir(),t,"config.json"),this.defaultConfig={agent:"claude",auth:{apikey:null}}}loadConfig(){let e=Be.dirname(this.configPath);try{return T.existsSync(e)||T.mkdirSync(e,{recursive:!0}),T.existsSync(this.configPath)||T.writeFileSync(this.configPath,JSON.stringify(this.defaultConfig,null,2)),JSON.parse(T.readFileSync(this.configPath,"utf8"))}catch{return{...this.defaultConfig}}}getApiKeyFromConfig(e){return e.auth?.apikey?e.auth.apikey:e.auth?.ak&&e.auth?.sk?`${e.auth.ak}.${e.auth.sk}`:null}saveAuthToConfig(e){let t=this.loadConfig();t.auth={apikey:e};try{return T.writeFileSync(this.configPath,JSON.stringify(t,null,2)),!0}catch{return!1}}clearAuthFromConfig(){let e=this.loadConfig();e.auth={apikey:null};try{return T.writeFileSync(this.configPath,JSON.stringify(e,null,2)),!0}catch{return!1}}getTeam(){return this.loadConfig().team||null}setTeam(e,t){let s=this.loadConfig();e==null?delete s.team:s.team={id:e,name:t||""};try{return T.writeFileSync(this.configPath,JSON.stringify(s,null,2)),!0}catch{return!1}}async parse(e=process.argv.slice(2)){let t=this.loadConfig(),s={agent:t.agent||"claude",remainingArgs:[]},o=0;if(e.length>0){if(Me.has(e[0]))s.agent=e[0],s.agentSetBySubcommand=!0,o=1;else if(Vt.has(e[0])){if(s.command=e[0],o=1,e[0]==="auth"){let n=e[1];n==="--help"||n==="-h"?s.authSubcommand="--help":(s.authSubcommand=n,s.authRemainingArgs=e.slice(2)),o=e.length}else if(e[0]==="skills"){let n=e[1];s.skillsSubcommand=n==="--help"||n==="-h"?void 0:n,s.skillsArg=e[2],s.skillsRemainingArgs=e.slice(2),o=e.length}else if(e[0]==="wiki"){let n=e[1];s.wikiSubcommand=n==="--help"||n==="-h"?void 0:n,s.wikiArg=e[2],s.wikiRemainingArgs=e.slice(2),o=e.length}else if(e[0]==="team"){let n=e[1];s.teamSubcommand=n==="--help"||n==="-h"?void 0:n,s.teamArg=e[2],s.teamRemainingArgs=e.slice(2),o=e.length}else if(e[0]==="channel"){let n=e[1];n==="--help"||n==="-h"?s.channelSubcommand="--help":n==="list"||n==="show"||n==="add"||n==="remove"||n==="update"?(s.channelSubcommand=n,s.channelArg=e[2],s.channelRemainingArgs=e.slice(2)):s.channelRemainingArgs=e.slice(1),o=e.length}}}for(;o<e.length;){let n=e[o];if(n==="--agent"){if(s.agentSetBySubcommand)throw new Error(`\u4E0D\u80FD\u540C\u65F6\u4F7F\u7528\u5B50\u547D\u4EE4 '${s.agent}' \u548C --agent\uFF0C\u8BF7\u9009\u62E9\u5176\u4E00`);let i=e[o+1];if(!i||!Me.has(i))throw new Error("--agent \u9700\u8981\u6307\u5B9A\u4EE3\u7406\u7C7B\u578B\uFF08claude|gemini|codex\uFF09");s.agent=i,o+=2}else if(n==="--apikey"){let i=e[o+1];if(!i||i.startsWith("--"))throw new Error("--apikey \u9700\u8981\u63D0\u4F9B API Key \u503C");if(i.indexOf(".")===-1)throw new Error("API Key \u683C\u5F0F\u9519\u8BEF\uFF0C\u5E94\u4E3A <ak>.<sk>");s.apikey=i,o+=2}else if(n==="--name"){let i=e[o+1];i&&!i.startsWith("--")?(s.pubName=i,o+=2):o+=1}else if(n==="--allow-clone")s.allowClone=!0,o+=1;else if(n==="--meta-data"){let i=e[o+1];if(!i||i.startsWith("--"))throw new Error("--meta-data \u9700\u8981\u4E00\u4E2A JSON \u5B57\u7B26\u4E32\u503C");try{JSON.parse(i)}catch(a){throw new Error(`--meta-data \u4E0D\u662F\u5408\u6CD5\u7684 JSON\uFF1A${a.message}`)}s.pubMetaData=i,o+=2}else{s.remainingArgs=e.slice(o);break}}if(s.command!=="auth"&&!s.apikey){let n=this.getApiKeyFromConfig(t);s.apikey=n||process.env.CODER_APIKEY||null}s.codevServer=process.env.CODEV_SERVER||t.codevServer||"https://makecoder.com/bigapis/codev/v1";let r=s.remainingArgs.includes("--version")||s.remainingArgs.includes("-v")||s.remainingArgs.includes("--help")||s.remainingArgs.includes("-h");return!zt.has(s.command)&&!r&&!s.apikey&&await this._oauthLogin(s),s}async _oauthLogin(e){console.log(`\u274C \u5C1A\u672A\u767B\u5F55
3
3
  `),console.log("\u8BF7\u5148\u767B\u5F55:"),console.log(` coder auth login
4
4
  `),console.log("\u6216\u76F4\u63A5\u63D0\u4F9B API Key:"),console.log(` coder auth login --apikey <your-api-key>
5
5
  `),console.log(`\u83B7\u53D6 API Key: https://makecoder.com/my/apikeys
@@ -8,10 +8,10 @@ var Nt=Object.create;var Fe=Object.defineProperty;var jt=Object.getOwnPropertyDe
8
8
  Terminating ...`),u.kill("SIGTERM"),setTimeout(()=>{u.killed||u.kill("SIGKILL")},8e3)}),process.on("SIGTERM",async()=>{console.log(`
9
9
  Terminating ...`),u.kill("SIGTERM"),setTimeout(()=>{u.killed||u.kill("SIGKILL")},8e3)})})}catch(n){throw n}}};Re.exports=ae});var le=S((ro,We)=>{var I=process.env.CODEV_DEBUG==="True",ce=class{constructor(e={}){this.queue=[],this.processing=!1,this.shuttingDown=!1,this.shutdownTimeout=e.shutdownTimeout||5e3,this.maxRetries=e.maxRetries||3,this.retryDelay=e.retryDelay||1e3,this.onProcessMessage=e.onProcessMessage||null,this.shutdownPromise=null,this.currentlyProcessing=null}enqueue(e){if(this.shuttingDown)return I&&console.log("Queue is shutting down, skipping new messages"),null;let t={id:Date.now()+Math.random(),data:e,timestamp:Date.now(),retryCount:0,processing:!1};return this.queue.push(t),I&&console.log(`Message enqueued, queue length: ${this.queue.length}`),this.processQueue(),t.id}dequeue(){let e=this.queue.shift();return I&&e&&console.log(`Message dequeued, remaining queue length: ${this.queue.length}`),e}removeById(e){let t=this.queue.findIndex(s=>s.id===e);return t>-1?(this.queue.splice(t,1),I&&console.log(`Message ${e} removed from queue`),!0):!1}async processQueue(){if(!(this.processing||this.queue.length===0)){this.processing=!0;try{for(;this.queue.length>0&&!this.shuttingDown;){let e=this.queue[0];e.processing=!0;try{this.onProcessMessage&&await this.onProcessMessage(e),this.dequeue()}catch(t){if(I&&console.error(`Failed to process message: ${t.message}`),e.retryCount++,I&&console.log("Start Retry:",e.retryCount,"times..."),e.retryCount>=this.maxRetries)I&&console.error("Message exceeded max retries, removing from queue"),this.dequeue();else{e.processing=!1;let s=this.shuttingDown?100:this.retryDelay*e.retryCount;await new Promise(o=>setTimeout(o,s))}}}}finally{this.processing=!1}}}getQueueSize(){return this.queue.length}clear(){this.queue=[],I&&console.log("Message queue cleared")}setMessageProcessor(e){this.onProcessMessage=e}async waitForProcessingMessages(e=5e3){let t=this.queue.filter(o=>o.processing);if(t.length===0)return;I&&console.log(`Waiting for ${t.length} processing messages to complete (timeout: ${e}ms)`);let s=Date.now();for(;Date.now()-s<e;){if(this.queue.filter(r=>r.processing).length===0){I&&console.log(`All processing messages completed in ${Date.now()-s}ms`);return}await new Promise(r=>setTimeout(r,50))}if(I){let o=this.queue.filter(r=>r.processing);console.log(`Timeout waiting for processing messages. ${o.length} messages still processing`)}}async gracefulShutdown(e={}){if(this.shutdownPromise)return this.shutdownPromise;let{timeoutMs:t=this.shutdownTimeout,batchSize:s=10,fastMode:o=!1}=e;return this.shutdownPromise=new Promise(async r=>{this.shuttingDown=!0,await this.waitForProcessingMessages(Math.min(t*.3,3e3));let n=this.queue.filter(h=>!h.processing),i=n.length;I&&(console.log(`Starting graceful shutdown with ${i} pending messages (${this.queue.length-i} already processing)`),console.log(`Mode: ${o?"fast (parallel)":"sequential"}, timeout: ${t}ms`));let a=Date.now(),l=0,d=0;try{if(o){let h=await this.processAllParallel(t-(Date.now()-a),n);l=h.processed,d=h.failed}else{let h=await this.processInBatches(s,t-(Date.now()-a),n);l=h.processed,d=h.failed}}catch(h){I&&console.error("Error during shutdown processing:",h.message)}let u=Date.now()-a,p=this.queue.length;I&&(console.log(`Shutdown completed in ${u}ms:`),console.log(` - Total: ${i} messages`),console.log(` - Processed: ${l}`),console.log(` - Failed: ${d}`),console.log(` - Remaining: ${p}`)),r({totalMessages:i,processedMessages:l,failedMessages:d,remainingMessages:p,duration:u,allMessagesSent:p===0&&d===0})}),this.shutdownPromise}async processAllParallel(e){if(this.queue.length===0)return{processed:0,failed:0};I&&console.log(`Processing ${this.queue.length} messages in parallel...`);let t=[...this.queue];this.queue=[];let s=t.map(async a=>{try{return this.onProcessMessage&&await this.onProcessMessage(a),{success:!0,messageId:a.id}}catch(l){return I&&console.warn(`Message ${a.id} processing failed: ${l.message}`),{success:!1,messageId:a.id,error:l}}}),o=new Promise(a=>{setTimeout(()=>a({timedOut:!0}),e)}),r=await Promise.race([Promise.allSettled(s).then(a=>({results:a})),o]);if(r.timedOut)return I&&console.log(`Parallel processing timed out after ${e}ms`),{processed:0,failed:t.length};let n=r.results.filter(a=>a.status==="fulfilled"&&a.value?.success).length,i=t.length-n;return{processed:n,failed:i}}async processInBatches(e,t){if(this.queue.length===0)return{processed:0,failed:0};I&&console.log(`Processing ${this.queue.length} messages in batches of ${e}...`);let s=Date.now(),o=0,r=0;for(;this.queue.length>0&&Date.now()-s<t;){let n=this.queue.splice(0,e),i=n.map(async u=>{try{return this.onProcessMessage&&await this.onProcessMessage(u),{success:!0}}catch(p){return I&&console.warn(`Batch message processing failed: ${p.message}`),{success:!1,error:p}}}),l=(await Promise.allSettled(i)).filter(u=>u.status==="fulfilled"&&u.value?.success).length,d=n.length-l;o+=l,r+=d,I&&n.length>0&&console.log(`Batch completed: ${l}/${n.length} successful`),this.queue.length>0&&await new Promise(u=>setTimeout(u,10))}return this.queue.length>0&&(r+=this.queue.length,I&&console.log(`${this.queue.length} messages not processed due to timeout`),this.queue=[]),{processed:o,failed:r}}async forceFlushAndShutdown(e=2e3){this.shuttingDown=!0,await this.waitForProcessingMessages(Math.min(e*.4,1e3));let t=this.queue.filter(a=>!a.processing);I&&console.log(`Force flush: attempting to send ${t.length} pending messages within ${e}ms (${this.queue.length-t.length} already processing)`);let s=Date.now(),o=t.map(async a=>{try{return this.onProcessMessage&&Date.now()-s<e?(await this.onProcessMessage(a),{success:!0,messageId:a.id}):{success:!1,messageId:a.id,reason:"timeout"}}catch(l){return{success:!1,messageId:a.id,error:l.message}}}),r=e-(Date.now()-s),n=new Promise(a=>{setTimeout(()=>a({timedOut:!0}),Math.max(100,r))}),i=await Promise.race([Promise.allSettled(o).then(a=>({results:a})),n]);if(t.forEach(a=>{let l=this.queue.findIndex(d=>d.id===a.id);l>-1&&this.queue.splice(l,1)}),this.processing=!1,i.timedOut)return I&&console.log(`Force flush timed out after ${e}ms`),{success:!1,reason:"timeout",attemptedCount:t.length};{let a=i.results.filter(l=>l.status==="fulfilled"&&l.value.success).length;return I&&console.log(`Force flush completed: ${a}/${t.length} messages sent`),{success:a===t.length,successCount:a,totalCount:t.length,results:i.results}}}forceShutdown(){this.shuttingDown=!0,this.queue=[],this.processing=!1,I&&console.log("Force shutdown: Queue cleared")}};We.exports=ce});var ue=S((io,Ge)=>{var Xt=require("http"),Zt=require("https"),{URL:He}=require("url"),{version:es}=L(),Je=process.env.CODEV_DEBUG==="True",de=class{constructor(e={}){this.baseUrl=e.baseUrl||"",this.timeout=e.timeout||3e4,this.defaultHeaders={"Content-Type":"application/json","User-Agent":`codev-cli/${es}`,...e.headers}}setBaseUrl(e){this.baseUrl=e}setDefaultHeaders(e){this.defaultHeaders={...this.defaultHeaders,...e}}async post(e,t,s={}){let o=this.resolveUrl(e),r={...this.defaultHeaders,...s.headers};return new Promise((n,i)=>{this.validateRequest(o,t,i);let a=this.serializeData(t,i);if(!a)return;r["Content-Length"]=Buffer.byteLength(a);let l=this.buildRequestOptions(o,"POST",r),d=this.getHttpModule(o);Je&&console.debug(`HTTP POST to ${o} with data length: ${a.length}`);let u=d.request(l,p=>{this.handleResponse(p,n,i)});this.attachErrorHandlers(u,o,i),u.setTimeout(this.timeout),u.write(a),u.end()})}resolveUrl(e){return e.startsWith("http")?e:`${this.baseUrl}${e.startsWith("/")?"":"/"}${e}`}validateRequest(e,t,s){return!e||typeof e!="string"?(s(new Error(`Invalid URL: ${e}`)),!1):t?!0:(s(new Error("No data provided for HTTP POST")),!1)}serializeData(e,t){try{return typeof e=="string"?e:JSON.stringify(e)}catch(s){return t(new Error(`Failed to serialize data: ${s.message}`)),null}}buildRequestOptions(e,t,s){let o=new He(e),r=o.protocol==="https:";return{hostname:o.hostname,port:o.port||(r?443:80),path:o.pathname+o.search,method:t,headers:s}}getHttpModule(e){return new He(e).protocol==="https:"?Zt:Xt}handleResponse(e,t,s){Je&&console.debug(`HTTP response status: ${e.statusCode}`);let o="";e.on("data",r=>{o+=r}),e.on("end",()=>{e.statusCode>=200&&e.statusCode<300?t({statusCode:e.statusCode,data:o,headers:e.headers}):s(new Error(`HTTP request returned status ${e.statusCode}: ${o}`))})}attachErrorHandlers(e,t,s){e.on("error",o=>{s(new Error(`HTTP POST request failed: ${o.message}`))}),e.on("timeout",()=>{s(new Error(`HTTP POST request timed out for URL: ${t}`)),e.destroy()})}};Ge.exports=de});var pe=S((ao,ze)=>{var he=class{constructor(){this.apikey=null}setCredentials(e){this.apikey=e||null}hasCredentials(){return!!this.apikey}generateAuthHeaders(){return this.apikey?{AUTHORIZATION:`Bearer ${this.apikey}`}:{}}clearCredentials(){this.apikey=null}};ze.exports=he});var fe=S((co,Ve)=>{var V=process.env.CODEV_DEBUG==="True",me=class{constructor(e={}){this.currentSessionId=null,this.previousSessionId=null,this.onSessionSwitch=e.onSessionSwitch||null,this.terminateSignal=e.terminateSignal||"CODEV_TERMINATE_SIGNAL"}handleSessionSwitch(e){if(!e)return V&&console.warn("Received empty session ID"),!1;let t=this.previousSessionId!==null&&this.previousSessionId!==e;return t&&(V&&console.log(`Session switch detected: ${this.previousSessionId} -> ${e}`),this.onSessionSwitch&&this.onSessionSwitch({type:this.terminateSignal,reason:"User switch session",agent:"claude",previousSessionId:this.previousSessionId,newSessionId:e})),this.previousSessionId=this.currentSessionId,this.currentSessionId=e,t}getCurrentSessionId(){return this.currentSessionId}getPreviousSessionId(){return this.previousSessionId}hasActiveSession(){return!!this.currentSessionId}terminateCurrentSession(e="Session terminated",t=null,s=null){if(!this.hasActiveSession())return V&&console.log("No active session to terminate"),null;let o={type:this.terminateSignal,reason:s?`terminated by signal: ${s}`:e,code:t,signal:s,timestamp:Date.now(),agent:"claude",sessionId:this.currentSessionId};return V&&console.log("Terminating session:",o),this.previousSessionId=null,this.currentSessionId=null,o}createErrorTermination(e){return this.hasActiveSession()?{type:this.terminateSignal,error:e.message,stack:e.stack,timestamp:Date.now(),agent:"claude",sessionId:this.currentSessionId}:null}reset(){V&&console.log("Resetting session manager"),this.currentSessionId=null,this.previousSessionId=null}setSessionSwitchCallback(e){this.onSessionSwitch=e}getSessionInfo(){return{currentSessionId:this.currentSessionId,previousSessionId:this.previousSessionId,hasActiveSession:this.hasActiveSession()}}};Ve.exports=me});var ye=S((lo,Ke)=>{var M=require("fs"),R=require("path"),ts=require("events"),ss=require("crypto"),v=process.env.CODEV_DEBUG==="True",ge=class extends ts{constructor(e={}){super(),this.watchPaths=e.watchPaths||[],this.excludePatterns=e.excludePatterns||[/node_modules/,/\.git/,/\.DS_Store/,/\.tmp/,/\.log$/,/\.swp$/,/codev\.log/],this.includePatterns=e.includePatterns||[/\.(js|jsx|ts|tsx|py|java|c|cpp|h|hpp|go|rs|rb|php|html|css|scss|sass|less|json|xml|yaml|yml|md|txt)$/],this.watchers=new Map,this.isWatching=!1,this.debounceTimeout=e.debounceTimeout||300,this.pendingChanges=new Map,this.fileContentHashes=new Map,this.enableContentComparison=e.enableContentComparison!==!1,this.onFileChange=e.onFileChange||null}calculateFileHash(e){try{let t=M.readFileSync(e,"utf8");return ss.createHash("sha256").update(t).digest("hex")}catch{return null}}hasContentChanged(e){if(!this.enableContentComparison)return!0;let t=this.calculateFileHash(e),s=this.fileContentHashes.get(e);return t===null?s!==void 0?(this.fileContentHashes.delete(e),!0):!1:s===void 0||t!==s?(this.fileContentHashes.set(e,t),!0):!1}preloadFileHashes(e){if(!(!this.enableContentComparison||!M.existsSync(e)))try{let t=M.readdirSync(e,{withFileTypes:!0});for(let s of t){let o=R.join(e,s.name);s.isFile()&&this.shouldWatchFile(o)?(this.calculateFileHash(o),this.fileContentHashes.set(o,this.calculateFileHash(o))):s.isDirectory()&&!this.shouldExcludeDirectory(o)&&this.preloadFileHashes(o)}}catch(t){v&&console.warn(`Failed to preload hashes for ${e}:`,t.message)}}shouldExcludeDirectory(e){let t=e.replace(/\\/g,"/");for(let s of this.excludePatterns)if(s.test(t)||s.test(R.basename(e)))return!0;return!1}startWatching(e=null){if(this.isWatching){v&&console.log("FileWatchService is already watching");return}let t=e||this.watchPaths;if(t.length===0){v&&console.log("No watch paths specified");return}this.isWatching=!0;for(let s of t)this.enableContentComparison&&this.preloadFileHashes(s),this.watchDirectory(s);v&&(console.log(`FileWatchService started watching ${t.length} paths`),this.enableContentComparison&&console.log(`Preloaded hashes for ${this.fileContentHashes.size} files`))}stopWatching(){if(this.isWatching){this.isWatching=!1;for(let[e,t]of this.watchers)try{t.close(),v&&console.log(`Stopped watching: ${e}`)}catch(s){v&&console.error(`Error stopping watcher for ${e}:`,s.message)}this.watchers.clear(),this.pendingChanges.clear(),this.fileContentHashes.clear(),v&&console.log("FileWatchService stopped watching all paths")}}watchDirectory(e){if(!M.existsSync(e)){v&&console.warn(`Watch path does not exist: ${e}`);return}if(!M.statSync(e).isDirectory()){v&&console.warn(`Watch path is not a directory: ${e}`);return}try{let s=M.watch(e,{recursive:!0,persistent:!1},(o,r)=>{if(!r)return;let n=R.join(e,r);this.handleFileChange(o,n,e)});this.watchers.set(e,s),v&&console.log(`Started watching directory: ${e}`),s.on("error",o=>{v&&console.error(`Watcher error for ${e}:`,o.message),this.watchers.delete(e)})}catch(s){v&&console.error(`Failed to start watching ${e}:`,s.message)}}handleFileChange(e,t,s){if(!this.shouldWatchFile(t))return;let o=`${e}:${t}`;this.pendingChanges.has(o)&&clearTimeout(this.pendingChanges.get(o)),this.pendingChanges.set(o,setTimeout(()=>{this.pendingChanges.delete(o),this.processFileChange(e,t,s)},this.debounceTimeout))}processFileChange(e,t,s){if(!this.isWatching)return;let o="modified",r=!1;try{M.statSync(t),r=!0,e==="rename"?o="created":e==="change"&&(o="modified")}catch{e==="rename"&&(o="deleted")}if(r&&(o==="modified"||o==="created")&&!this.hasContentChanged(t)){v&&console.log(`Ignoring false change for: ${R.relative(s,t)}`);return}!r&&o==="deleted"&&this.fileContentHashes.delete(t);let n={type:"CODEV_FILE_CHANGE_DETECTTED",data:{eventType:e,changeType:o,filePath:t,relativePath:R.relative(s,t),watchPath:s,fileExists:r,timestamp:Date.now(),sessionId:process.env.SESSION_ID||"default"}};if(v&&console.log(`File ${o}: ${n.data.relativePath}`),this.emit("fileChange",n),this.onFileChange&&typeof this.onFileChange=="function")try{this.onFileChange(n)}catch(i){v&&console.error("Error in file change callback:",i.message)}}shouldWatchFile(e){let t=R.basename(e),s=e.replace(/\\/g,"/");for(let o of this.excludePatterns)if(o.test(s)||o.test(t))return!1;if(this.includePatterns.length===0)return!0;for(let o of this.includePatterns)if(o.test(s)||o.test(t))return!0;return!1}addWatchPath(e){this.watchPaths.includes(e)||(this.watchPaths.push(e),this.isWatching&&this.watchDirectory(e))}removeWatchPath(e){let t=this.watchPaths.indexOf(e);if(t>-1&&(this.watchPaths.splice(t,1),this.watchers.has(e)))try{this.watchers.get(e).close(),this.watchers.delete(e),v&&console.log(`Removed watch path: ${e}`)}catch(s){v&&console.error(`Error removing watch path ${e}:`,s.message)}}getStatus(){return{isWatching:this.isWatching,watchPaths:[...this.watchPaths],activeWatchers:this.watchers.size,pendingChanges:this.pendingChanges.size}}setFileChangeCallback(e){this.onFileChange=e}};Ke.exports=ge});var Ye=S((po,Qe)=>{var os=z(),ns=require("path"),uo=require("fs"),ho=require("os"),rs=le(),is=ue(),as=pe(),cs=fe(),ls=ye(),x=process.env.CODEV_DEBUG==="True",be=class extends os{constructor(){super({configDir:".",configFile:".claude.json",defaultModel:"Claude Sonnet 4.6",executablePaths:["cc.mjs","../dist/cc.mjs","/tmp/claude-code/package/cc.mjs"],environmentVariables:e=>({ANTHROPIC_BASE_URL:`${e}/claude`,ANTHROPIC_API_KEY:"codev",DISABLE_TELEMETRY:!0,CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC:!0,DISABLE_COST_WARNINGS:!0,DISABLE_NON_ESSENTIAL_MODEL_CALLS:!0,CODEV_SERVER:e,CLAUDE_CODE_ATTRIBUTION_HEADER:"0"}),defaultConfig:{numStartups:1,installMethod:"unknown",autoUpdates:!1,theme:"Coder Dark",customApiKeyResponses:{approved:["codev"]},shiftEnterKeyBindingInstalled:!0,hasCompletedOnboarding:!0,subscriptionNoticeCount:0,hasAvailableSubscription:!0,projects:{}}}),this.fileWatchService=null,this.shutdownInProgress=!1,this.initializeServices()}initializeServices(){this.httpClient=new is({timeout:1e4}),this.authService=new as({validateCredentials:!1}),this.sessionManager=new cs({onSessionSwitch:e=>{this.sendTerminationMessage(e)}}),this.messageQueue=new rs({maxRetries:2,retryDelay:500,shutdownTimeout:3e3,onProcessMessage:e=>this.processMessage(e)}),this.initializeFileWatchService()}resloveSettingFilePath(e){return ns.join(e,this.config.configDir,".claude","settings.json")}initializeFileWatchService(){if(!process.env.SESSION_ID){x&&console.log("FileWatchService disabled: SESSION_ID environment variable not found");return}try{this.fileWatchService=new ls({watchPaths:this.getFileWatchPaths(),onFileChange:e=>this.handleFileChange(e),debounceTimeout:300}),x&&console.log("FileWatchService initialized with SESSION_ID:",process.env.SESSION_ID)}catch(e){x&&console.error("Failed to initialize FileWatchService:",e.message)}}getFileWatchPaths(){let e=[],t=process.cwd();e.push(t);let s=process.env.CODEV_WATCH_PATHS;if(s){let o=s.split(",").map(r=>r.trim());e.push(...o)}return e}handleFileChange(e){if(x&&console.log("File change detected:",e.data.relativePath),this.shutdownInProgress)return;let t={message:e,sessionId:e.data.sessionId||process.env.SESSION_ID};this.messageQueue.enqueue(t)}startFileWatching(){this.fileWatchService&&!this.fileWatchService.isWatching&&(this.fileWatchService.startWatching(),x&&console.log("File watching started"))}stopFileWatching(){this.fileWatchService&&this.fileWatchService.isWatching&&(this.fileWatchService.stopWatching(),x&&console.log("File watching stopped"))}onChildMessage(e){e&&e.type==="claude:send-msg"&&this.handleClaudeSendMessage(e.data),super.onChildMessage(e)}handleClaudeSendMessage(e){if(x&&console.log("Handling claude:send-msg message:",e),!e||typeof e!="object"){console.error(`handleClaudeSendMessage: Invalid message data. Expected object, got: ${typeof e}`);return}if(this.shutdownInProgress){x&&console.log("Shutdown in progress, ignoring new message");return}let t=e.sessionId||process.env.SESSION_ID;this.sessionManager.handleSessionSwitch(t),this.messageQueue.enqueue(e)}async processMessage(e){let t=e.data.message,s=e.data.sessionId||process.env.SESSION_ID;if(!s)throw new Error("No session ID available");let o;try{o=typeof t=="string"?JSON.parse(t):t}catch(i){throw new Error(`Failed to parse message data: ${i.message}`)}let r=`/conversations/${s}/@append?task_type=codev`,n=this.authService.hasCredentials()?this.authService.generateAuthHeaders():{};x&&(console.debug("Sending message to:",r),console.debug("Send Message: ",JSON.stringify(o))),e.type!=="CODEV_TERMINATE_SIGNAL"&&(this.sessionManager.currentSessionId=s)}sendTerminationMessage(e){let t={message:e,sessionId:e.sessionId||this.sessionManager.getCurrentSessionId()};this.messageQueue.enqueue(t)}async handleChildProcessExit(e,t){x&&console.log(`Child process exited with code: ${e}, signal: ${t}`),this.stopFileWatching();let s=this.messageQueue.getQueueSize(),o=this.sessionManager.terminateCurrentSession("process exited normally",e,t);if(o&&this.sendTerminationMessage(o),s>0||o){x&&console.log("Starting graceful shutdown of message queue...");try{let r=!t||t==="SIGTERM",n=this.messageQueue.getQueueSize(),i={timeoutMs:r?8e3:3e3,batchSize:Math.min(n,15),fastMode:!r||n>30};x&&console.log("Shutdown options:",i);let a=await this.messageQueue.gracefulShutdown(i);x&&console.log("Message queue shutdown completed:",a),a.failedMessages>0&&x&&console.warn(`Shutdown summary: ${a.processedMessages} sent, ${a.failedMessages} failed, ${a.remainingMessages} remaining`)}catch(r){x&&console.error("Error during message queue shutdown:",r.message)}}}handleChildProcessError(e){x&&console.error(`Child process error: ${e.message}`);let t=this.sessionManager.createErrorTermination(e);t&&this.sendTerminationMessage(t)}async forceFlushMessages(e=3e3){if(this.messageQueue.getQueueSize()===0)return{success:!0,message:"No messages to flush"};x&&console.log(`Force flushing ${this.messageQueue.getQueueSize()} messages...`);try{return await this.messageQueue.forceFlushAndShutdown(e)}catch(t){return x&&console.error("Force flush failed:",t.message),{success:!1,error:t.message}}}async launch(e={}){let{codevServer:t,apikey:s=null}=e;return this.httpClient.setBaseUrl(t),s&&this.authService.setCredentials(s),this.startFileWatching(),super.launch(e)}};Qe.exports=be});var Ze=S((mo,Xe)=>{var ds=z(),{spawn:us,execFileSync:hs}=require("child_process"),K=require("path"),Q=require("fs"),ps=le(),ms=ue(),fs=pe(),gs=fe(),ys=ye(),{isPrintMode:bs}=J(),E=process.env.CODEV_DEBUG==="True",Ie=class extends ds{constructor(){let e=`${process.platform}-${process.arch}`;super({configDir:".",configFile:".claude.json",defaultModel:"Claude Sonnet 4.6",executablePaths:[`${e}/cc.js`,`../dist/${e}/cc.js`,`/tmp/claude-code-${e}/package/extracted/src/entrypoints/cc.js`],environmentVariables:t=>({ANTHROPIC_BASE_URL:`${t}/claude`,ANTHROPIC_API_KEY:"codev",DISABLE_TELEMETRY:!0,CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC:!0,DISABLE_COST_WARNINGS:!0,DISABLE_NON_ESSENTIAL_MODEL_CALLS:!0,CODEV_SERVER:t,CLAUDE_CODE_ATTRIBUTION_HEADER:"0",DISABLE_INSTALLATION_CHECKS:"1"}),defaultConfig:{numStartups:1,installMethod:"unknown",autoUpdates:!1,theme:"Coder Dark",customApiKeyResponses:{approved:["codev"]},shiftEnterKeyBindingInstalled:!0,hasCompletedOnboarding:!0,subscriptionNoticeCount:0,hasAvailableSubscription:!0,projects:{}}}),this.fileWatchService=null,this.shutdownInProgress=!1,this.initializeServices()}initializeServices(){this.httpClient=new ms({timeout:1e4}),this.authService=new fs({validateCredentials:!1}),this.sessionManager=new gs({onSessionSwitch:e=>{this.sendTerminationMessage(e)}}),this.messageQueue=new ps({maxRetries:2,retryDelay:500,shutdownTimeout:3e3,onProcessMessage:e=>this.processMessage(e)}),this.initializeFileWatchService()}resloveSettingFilePath(e){return K.join(e,this.config.configDir,".claude","settings.json")}initializeFileWatchService(){if(!process.env.SESSION_ID){E&&console.log("FileWatchService disabled: SESSION_ID environment variable not found");return}try{this.fileWatchService=new ys({watchPaths:this.getFileWatchPaths(),onFileChange:e=>this.handleFileChange(e),debounceTimeout:300}),E&&console.log("FileWatchService initialized with SESSION_ID:",process.env.SESSION_ID)}catch(e){E&&console.error("Failed to initialize FileWatchService:",e.message)}}getFileWatchPaths(){let e=[],t=process.cwd();e.push(t);let s=process.env.CODEV_WATCH_PATHS;if(s){let o=s.split(",").map(r=>r.trim());e.push(...o)}return e}handleFileChange(e){if(E&&console.log("File change detected:",e.data.relativePath),this.shutdownInProgress)return;let t={message:e,sessionId:e.data.sessionId||process.env.SESSION_ID};this.messageQueue.enqueue(t)}startFileWatching(){this.fileWatchService&&!this.fileWatchService.isWatching&&(this.fileWatchService.startWatching(),E&&console.log("File watching started"))}stopFileWatching(){this.fileWatchService&&this.fileWatchService.isWatching&&(this.fileWatchService.stopWatching(),E&&console.log("File watching stopped"))}onChildMessage(e){e&&e.type==="claude:send-msg"&&this.handleClaudeSendMessage(e.data),super.onChildMessage(e)}handleClaudeSendMessage(e){if(E&&console.log("Handling claude:send-msg message:",e),!e||typeof e!="object"){console.error(`handleClaudeSendMessage: Invalid message data. Expected object, got: ${typeof e}`);return}if(this.shutdownInProgress){E&&console.log("Shutdown in progress, ignoring new message");return}let t=e.sessionId||process.env.SESSION_ID;this.sessionManager.handleSessionSwitch(t),this.messageQueue.enqueue(e)}async processMessage(e){let t=e.data.message,s=e.data.sessionId||process.env.SESSION_ID;if(!s)throw new Error("No session ID available");let o;try{o=typeof t=="string"?JSON.parse(t):t}catch(i){throw new Error(`Failed to parse message data: ${i.message}`)}let r=`/conversations/${s}/@append?task_type=codev`,n=this.authService.hasCredentials()?this.authService.generateAuthHeaders():{};E&&(console.debug("Sending message to:",r),console.debug("Send Message: ",JSON.stringify(o))),e.type!=="CODEV_TERMINATE_SIGNAL"&&(this.sessionManager.currentSessionId=s)}sendTerminationMessage(e){let t={message:e,sessionId:e.sessionId||this.sessionManager.getCurrentSessionId()};this.messageQueue.enqueue(t)}async handleChildProcessExit(e,t){E&&console.log(`Child process exited with code: ${e}, signal: ${t}`),this.stopFileWatching();let s=this.messageQueue.getQueueSize(),o=this.sessionManager.terminateCurrentSession("process exited normally",e,t);if(o&&this.sendTerminationMessage(o),s>0||o){E&&console.log("Starting graceful shutdown of message queue...");try{let r=!t||t==="SIGTERM",n=this.messageQueue.getQueueSize(),i={timeoutMs:r?8e3:3e3,batchSize:Math.min(n,15),fastMode:!r||n>30},a=await this.messageQueue.gracefulShutdown(i);E&&console.log("Message queue shutdown completed:",a)}catch(r){E&&console.error("Error during message queue shutdown:",r.message)}}}handleChildProcessError(e){E&&console.error(`Child process error: ${e.message}`);let t=this.sessionManager.createErrorTermination(e);t&&this.sendTerminationMessage(t)}async launch(e={}){let{codevServer:t,apikey:s=null}=e;return this.httpClient.setBaseUrl(t),s&&this.authService.setCredentials(s),this.startFileWatching(),this._launchWithBun(e)}_resolveBunPath(){let e=process.platform==="win32",t=e?"bun.exe":"bun";try{return hs(t,["--version"],{stdio:"ignore"}),t}catch{}let s=K.join(process.env.HOME||process.env.USERPROFILE||"",".local","bin",t);if(Q.existsSync(s))return s;let o=K.join(__dirname,"..","..","node_modules",".bin",t);if(Q.existsSync(o))return o;let r=this._getBunPlatformPackage();if(r)try{let n=K.dirname(require.resolve(`${r}/package.json`)),i=K.join(n,"bin",t);if(Q.existsSync(i))return i}catch{}try{let n=require.resolve(`bun/${e?"bin/bun.exe":"bin/bun"}`);if(Q.existsSync(n))return n}catch{}throw new Error("bun is not installed. Install it with: npm install -g bun or curl -fsSL https://bun.sh/install | bash")}_getBunPlatformPackage(){let e=process.platform,t=process.arch;return{"darwin-arm64":"@oven-sh/bun-darwin-aarch64","darwin-x64":"@oven-sh/bun-darwin-x64","linux-arm64":"@oven-sh/bun-linux-aarch64","linux-x64":"@oven-sh/bun-linux-x64","win32-x64":"@oven-sh/bun-windows-x64"}[`${e}-${t}`]||null}async _launchWithBun(e={}){let{remainingArgs:t=[],codevServer:s,apikey:o=null,extraEnv:r={}}=e;try{await this.ensureConfig(1e3);let n=this.findExecutablePath(),i=this._resolveBunPath();return E&&(console.log(`executablePath (bun): ${n}`),console.log(`bunPath: ${i}`)),new Promise((a,l)=>{let d={...process.env,...this.config.environmentVariables(s),CODER_EXECPATH:Q.realpathSync(process.argv[1]),...r};o&&(d.CODER_APIKEY=o);let u=[n,...t],p=us(i,u,{env:d,stdio:["inherit","inherit","inherit","ipc"]});this.handleChildMessages(p),p.on("error",h=>{h.code==="ENOENT"?console.error("bun binary not found. Install it with: npm install -g bun or curl -fsSL https://bun.sh/install | bash"):console.error(`Failed to start bun: ${h.message}`),l(h)}),p.on("exit",async(h,g)=>{bs(t)||g&&console.log(`terminated by signal: ${g}`)}),process.on("SIGINT",async()=>{console.log(`
10
10
  Terminating ...`),p.kill("SIGTERM"),setTimeout(()=>{p.killed||p.kill("SIGKILL")},8e3)}),process.on("SIGTERM",async()=>{console.log(`
11
- Terminating ...`),p.kill("SIGTERM"),setTimeout(()=>{p.killed||p.kill("SIGKILL")},8e3)})})}catch(n){throw n}}};Xe.exports=Ie});var tt=S((go,et)=>{var Is=z(),fo=require("path"),we=class extends Is{constructor(){super({configDir:".gemini",configFile:"settings.json",defaultModel:"gemini-2.5-pro",executablePaths:["gemini/gemini.js","../dist/gemini/gemini.js"],environmentVariables:e=>({GOOGLE_GEMINI_BASE_URL:`${e}/gemini`,GEMINI_API_KEY:"coder",GOOGLE_API_KEY:"coder",GOOGLE_CLOUD_PROJECT:"coder",GOOGLE_CLOUD_LOCATION:"coder",DISABLE_TELEMETRY:!0,GEMINI_CODE_DISABLE_NONESSENTIAL_TRAFFIC:!0,DISABLE_COST_WARNINGS:!0,DISABLE_NON_ESSENTIAL_MODEL_CALLS:!0,USE_VERTEX:!0}),defaultConfig:{ide:{hasSeenNudge:!0},telemetry:{enabled:!1,logPrompts:!1},privacy:{usageStatisticsEnabled:!1},general:{disableUpdateNag:!0,preferredEditor:"vscode",previewFeatures:!0},ui:{hideBanner:!0,theme:"Default"},security:{auth:{selectedType:"vertex-ai"}}}})}};et.exports=we});var ot=S((yo,st)=>{var ws=z(),Y=require("path"),A=require("fs"),Ss=require("os"),{spawn:$s}=require("child_process"),ee=process.env.CODEV_DEBUG==="True",Se=class extends ws{constructor(){super({configDir:".codex",configFile:"config.toml",defaultModel:"o4-mini",executablePaths:["codex.mjs","../dist/codex.mjs"],environmentVariables:e=>({OPENAI_BASE_URL:`${e}/codex`,OPENAI_API_KEY:"codev-proxy-key",DEBUG:ee?"true":"false",CODEX_QUIET_MODE:"0",OPENAI_DISABLE_TELEMETRY:"true",CODEX_DISABLE_PROJECT_DOC:"0",CODEV_SERVER:e,CODEX_DISABLE_WEBSOCKET:"1"}),defaultConfig:{model:"gpt-5-codex",approvalMode:"suggest",fullAutoErrorMode:"ask-user",notify:[],history:{maxSize:1e3,saveHistory:!0,sensitivePatterns:[],persistence:"save-all"}}})}checkCodexAvailability(){try{let e=this.findExecutablePath();return A.existsSync(e)}catch{return!1}}resloveSettingFilePath(e){return Y.join(e,this.config.configDir,"config.toml")}async ensureConfig(e,t=0){let s=Y.join(Ss.homedir(),this.config.configDir,this.config.configFile),o=Y.dirname(s);try{A.existsSync(o)||A.mkdirSync(o,{recursive:!0});let r=`${e}/codex`;if(A.existsSync(s)){let n=A.readFileSync(s,"utf8"),i=`openai_base_url = "${r}"`,a=n.search(/^\[/m),l=a===-1?n:n.slice(0,a),d=a===-1?"":n.slice(a);/^openai_base_url\s*=/m.test(l)?n=l.replace(/^openai_base_url\s*=.*/m,i)+d:n=l.trimEnd()+`
11
+ Terminating ...`),p.kill("SIGTERM"),setTimeout(()=>{p.killed||p.kill("SIGKILL")},8e3)})})}catch(n){throw n}}};Xe.exports=Ie});var tt=S((go,et)=>{var Is=z(),fo=require("path"),we=class extends Is{constructor(){super({configDir:".gemini",configFile:"settings.json",defaultModel:"gemini-2.5-pro",executablePaths:["gemini/gemini.js","../dist/gemini/gemini.js"],environmentVariables:e=>({GOOGLE_GEMINI_BASE_URL:`${e}/gemini`,GEMINI_API_KEY:"coder",GOOGLE_API_KEY:"coder",GOOGLE_CLOUD_PROJECT:"coder",GOOGLE_CLOUD_LOCATION:"coder",DISABLE_TELEMETRY:!0,GEMINI_CODE_DISABLE_NONESSENTIAL_TRAFFIC:!0,DISABLE_COST_WARNINGS:!0,DISABLE_NON_ESSENTIAL_MODEL_CALLS:!0,USE_VERTEX:!0}),defaultConfig:{ide:{hasSeenNudge:!0},telemetry:{enabled:!1,logPrompts:!1},privacy:{usageStatisticsEnabled:!1},general:{disableUpdateNag:!0,preferredEditor:"vscode",previewFeatures:!0},ui:{hideBanner:!0,theme:"Default"},security:{auth:{selectedType:"vertex-ai"}}}})}};et.exports=we});var ot=S((yo,st)=>{var ws=z(),Y=require("path"),A=require("fs"),Ss=require("os"),{spawn:$s}=require("child_process"),ee=process.env.CODEV_DEBUG==="True",Se=class extends ws{constructor(){super({configDir:".codex",configFile:"config.toml",defaultModel:"gpt-5.5",executablePaths:["codex.mjs","../dist/codex.mjs"],environmentVariables:e=>({OPENAI_BASE_URL:`${e}/codex`,OPENAI_API_KEY:"codev-proxy-key",DEBUG:ee?"true":"false",CODEX_QUIET_MODE:"0",OPENAI_DISABLE_TELEMETRY:"true",CODEX_DISABLE_PROJECT_DOC:"0",CODEV_SERVER:e,CODEX_DISABLE_WEBSOCKET:"1"}),defaultConfig:{model:"gpt-5.5",approvalMode:"suggest",fullAutoErrorMode:"ask-user",notify:[],history:{maxSize:1e3,saveHistory:!0,sensitivePatterns:[],persistence:"save-all"}}})}checkCodexAvailability(){try{let e=this.findExecutablePath();return A.existsSync(e)}catch{return!1}}resloveSettingFilePath(e){return Y.join(e,this.config.configDir,"config.toml")}async ensureConfig(e,t=0){let s=Y.join(Ss.homedir(),this.config.configDir,this.config.configFile),o=Y.dirname(s);try{A.existsSync(o)||A.mkdirSync(o,{recursive:!0});let r=`${e}/codex`;if(A.existsSync(s)){let n=A.readFileSync(s,"utf8"),i=`openai_base_url = "${r}"`,a=n.search(/^\[/m),l=a===-1?n:n.slice(0,a),d=a===-1?"":n.slice(a);/^openai_base_url\s*=/m.test(l)?n=l.replace(/^openai_base_url\s*=.*/m,i)+d:n=l.trimEnd()+`
12
12
  `+i+`
13
13
  `+(d?`
14
- `+d:""),A.writeFileSync(s,n),ee&&console.log(`Updated openai_base_url in ${s}`)}else{let n=this.config.defaultConfig||{},i=this.generateTOMLConfig(n,r);A.writeFileSync(s,i),ee&&console.log(`Created Codex config file: ${s}`)}t>0&&await new Promise(n=>setTimeout(n,t))}catch(r){console.warn(`Failed to update ${this.config.configFile}: ${r.message}`)}}generateTOMLConfig(e,t){return`model = "${e.model||"gpt-5-codex"}"
14
+ `+d:""),A.writeFileSync(s,n),ee&&console.log(`Updated openai_base_url in ${s}`)}else{let n=this.config.defaultConfig||{},i=this.generateTOMLConfig(n,r);A.writeFileSync(s,i),ee&&console.log(`Created Codex config file: ${s}`)}t>0&&await new Promise(n=>setTimeout(n,t))}catch(r){console.warn(`Failed to update ${this.config.configFile}: ${r.message}`)}}generateTOMLConfig(e,t){return`model = "${e.model||"gpt-5.5"}"
15
15
  openai_base_url = "${t}"
16
16
  `}findExecutablePath(){let e=Y.dirname(require.main.filename);for(let t of this.config.executablePaths){let s=Y.resolve(e,t);if(A.existsSync(s))return s}throw new Error(`Could not find Codex executable in any of the configured paths: ${this.config.executablePaths.join(", ")}`)}async launch(e={}){let{remainingArgs:t=[],codevServer:s,apikey:o=null}=e;try{if(!this.checkCodexAvailability())throw new Error("Codex executable not found. Please ensure makecoder is properly installed: npm install -g makecoder@latest");await this.ensureConfig(s,1e3);let r=this.findExecutablePath();return ee&&console.log(`executablePath: ${r}`),new Promise((n,i)=>{let a={...process.env,...this.config.environmentVariables(s)};o&&(a.CODER_APIKEY=o);let l=["--no-warnings"];process.env.CODEV_INSPECT_BRK==="True"&&l.push("--inspect-brk"),l.push(r,...t);let d=$s("node",l,{env:a,stdio:["inherit","inherit","inherit","ipc"]});this.handleChildMessages(d),d.on("error",u=>{console.error(`Failed to start Codex: ${u.message}`),i(u)}),d.on("exit",async(u,p)=>{p&&console.log(`terminated by signal: ${p}`)}),process.on("SIGINT",async()=>{console.log(`
17
17
  Terminating ...`),d.kill("SIGTERM"),setTimeout(()=>{d.killed||d.kill("SIGKILL")},8e3)}),process.on("SIGTERM",async()=>{console.log(`
@@ -23,13 +23,13 @@ var PP4=Object.create;var{getPrototypeOf:WP4,defineProperty:_2H,getOwnPropertyNa
23
23
  Object.assign(A, {
24
24
  post(...args) {
25
25
  const [url, payload, ...remainArgs] = args;
26
- const patchedUrl = url + (url.includes('?') ? '&' : '?') + 'app=codev-cli' + '&version=4.0.49' + '&session_id=' + S_() + (process.env.SPACE_ID ? '&space_id=' + process.env.SPACE_ID : '');
26
+ const patchedUrl = url + (url.includes('?') ? '&' : '?') + 'app=codev-cli' + '&version=4.0.51' + '&session_id=' + S_() + (process.env.SPACE_ID ? '&space_id=' + process.env.SPACE_ID : '');
27
27
  if (process.env.CODER_APIKEY) {
28
28
  const headerValues = payload.headers.values;
29
29
  headerValues.set('AUTHORIZATION', `Bearer ${process.env.CODER_APIKEY}`)
30
30
  }
31
31
 
32
- payload.headers.values.set('X-Coder-Version', '4.0.49');
32
+ payload.headers.values.set('X-Coder-Version', '4.0.51');
33
33
  payload.headers.values.set('X-Coder-Platform', process.platform);
34
34
  payload.headers.values.set('X-Coder-Arch', process.arch);
35
35
 
@@ -23,13 +23,13 @@ var WPK=Object.create;var{getPrototypeOf:GPK,defineProperty:_2H,getOwnPropertyNa
23
23
  Object.assign(A, {
24
24
  post(...args) {
25
25
  const [url, payload, ...remainArgs] = args;
26
- const patchedUrl = url + (url.includes('?') ? '&' : '?') + 'app=codev-cli' + '&version=4.0.49' + '&session_id=' + S6() + (process.env.SPACE_ID ? '&space_id=' + process.env.SPACE_ID : '');
26
+ const patchedUrl = url + (url.includes('?') ? '&' : '?') + 'app=codev-cli' + '&version=4.0.51' + '&session_id=' + S6() + (process.env.SPACE_ID ? '&space_id=' + process.env.SPACE_ID : '');
27
27
  if (process.env.CODER_APIKEY) {
28
28
  const headerValues = payload.headers.values;
29
29
  headerValues.set('AUTHORIZATION', `Bearer ${process.env.CODER_APIKEY}`)
30
30
  }
31
31
 
32
- payload.headers.values.set('X-Coder-Version', '4.0.49');
32
+ payload.headers.values.set('X-Coder-Version', '4.0.51');
33
33
  payload.headers.values.set('X-Coder-Platform', process.platform);
34
34
  payload.headers.values.set('X-Coder-Arch', process.arch);
35
35
 
@@ -23,13 +23,13 @@ var MP9=Object.create;var{getPrototypeOf:jP9,defineProperty:qWH,getOwnPropertyNa
23
23
  Object.assign(A, {
24
24
  post(...args) {
25
25
  const [url, payload, ...remainArgs] = args;
26
- const patchedUrl = url + (url.includes('?') ? '&' : '?') + 'app=codev-cli' + '&version=4.0.49' + '&session_id=' + R$() + (process.env.SPACE_ID ? '&space_id=' + process.env.SPACE_ID : '');
26
+ const patchedUrl = url + (url.includes('?') ? '&' : '?') + 'app=codev-cli' + '&version=4.0.51' + '&session_id=' + R$() + (process.env.SPACE_ID ? '&space_id=' + process.env.SPACE_ID : '');
27
27
  if (process.env.CODER_APIKEY) {
28
28
  const headerValues = payload.headers.values;
29
29
  headerValues.set('AUTHORIZATION', `Bearer ${process.env.CODER_APIKEY}`)
30
30
  }
31
31
 
32
- payload.headers.values.set('X-Coder-Version', '4.0.49');
32
+ payload.headers.values.set('X-Coder-Version', '4.0.51');
33
33
  payload.headers.values.set('X-Coder-Platform', process.platform);
34
34
  payload.headers.values.set('X-Coder-Arch', process.arch);
35
35
 
@@ -23,13 +23,13 @@ var PJ_=Object.create;var{getPrototypeOf:WJ_,defineProperty:K2H,getOwnPropertyNa
23
23
  Object.assign(A, {
24
24
  post(...args) {
25
25
  const [url, payload, ...remainArgs] = args;
26
- const patchedUrl = url + (url.includes('?') ? '&' : '?') + 'app=codev-cli' + '&version=4.0.49' + '&session_id=' + R8() + (process.env.SPACE_ID ? '&space_id=' + process.env.SPACE_ID : '');
26
+ const patchedUrl = url + (url.includes('?') ? '&' : '?') + 'app=codev-cli' + '&version=4.0.51' + '&session_id=' + R8() + (process.env.SPACE_ID ? '&space_id=' + process.env.SPACE_ID : '');
27
27
  if (process.env.CODER_APIKEY) {
28
28
  const headerValues = payload.headers.values;
29
29
  headerValues.set('AUTHORIZATION', `Bearer ${process.env.CODER_APIKEY}`)
30
30
  }
31
31
 
32
- payload.headers.values.set('X-Coder-Version', '4.0.49');
32
+ payload.headers.values.set('X-Coder-Version', '4.0.51');
33
33
  payload.headers.values.set('X-Coder-Platform', process.platform);
34
34
  payload.headers.values.set('X-Coder-Arch', process.arch);
35
35
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "makecoder",
3
- "version": "4.0.49",
3
+ "version": "4.0.51",
4
4
  "description": "MakeCoder: Unified AI agent CLI tool integrating Claude Code, Codex and Gemini CLI",
5
5
  "main": "./dist/coder.js",
6
6
  "bin": {
@@ -36,9 +36,9 @@
36
36
  },
37
37
  "optionalDependencies": {
38
38
  "bun": ">=1.3.12",
39
- "makecoder-codex-darwin-arm64": "4.0.49",
40
- "makecoder-codex-linux-x64": "4.0.49",
41
- "makecoder-codex-win32-x64": "4.0.49"
39
+ "makecoder-codex-darwin-arm64": "4.0.51",
40
+ "makecoder-codex-linux-x64": "4.0.51",
41
+ "makecoder-codex-win32-x64": "4.0.51"
42
42
  },
43
43
  "engines": {
44
44
  "node": ">=20.0.0"