@wular/coder 0.1.14 → 0.1.15

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
@@ -5,7 +5,7 @@ var Yl=Object.defineProperty;var Or=(r,i)=>{for(var v in i)Yl(r,v,{get:i[v],enum
5
5
  `,"utf8")}function hl(r){let i=c$(r);if(R.existsSync(i))R.unlinkSync(i)}async function dl(r){if(!r)return!1;try{return await x6(r,150)}catch{return!1}}async function m6(r,i={}){let v=k$(r);if(v&&await dl(v.endpoint))return v;if(v)R6({endpoint:v.endpoint??null,pidFile:v.pidFile??null,logFile:v.logFile??null,sessionDir:v.sessionDir??null,pid:v.pid??null,killProcess:i.killProcess??null}),hl(r);let u=Zl(),$=(i.createBrokerEndpoint??F6)(u,i.platform),t=hr.join(u,"broker.pid"),g=hr.join(u,"broker.log"),I=i.scriptPath??el(),o=Cl({scriptPath:I,cwd:r,endpoint:$,pidFile:t,logFile:g,env:i.env??U$.env});if(!await x6($,i.timeoutMs??2000))return R6({endpoint:$,pidFile:t,logFile:g,sessionDir:u,pid:o.pid??null,killProcess:i.killProcess??null}),null;let U={endpoint:$,pidFile:t,logFile:g,sessionDir:u,pid:o.pid??null};return yl(r,U),U}function R6({endpoint:r=null,pidFile:i,logFile:v,sessionDir:u=null,pid:n=null,killProcess:$=null}){if(Number.isFinite(n)&&$)try{$(n)}catch{}if(i&&R.existsSync(i))R.unlinkSync(i);if(v&&R.existsSync(v))R.unlinkSync(v);if(r)try{let g=Hn(r);if(g.kind==="unix"&&R.existsSync(g.path))R.unlinkSync(g.path)}catch{}let t=u??(i?hr.dirname(i):v?hr.dirname(v):null);if(t&&R.existsSync(t))try{R.rmdirSync(t)}catch{}}import{spawnSync as pl}from"node:child_process";import An from"node:process";function Wi(r,i=[],v={}){let u=pl(r,i,{cwd:v.cwd,env:v.env,encoding:"utf8",input:v.input,maxBuffer:v.maxBuffer,stdio:v.stdio??"pipe",shell:An.platform==="win32"?An.env.SHELL||!0:!1,windowsHide:!0});return{command:r,args:i,status:u.status??0,signal:u.signal??null,stdout:u.stdout??"",stderr:u.stderr??"",error:u.error??null}}function b$(r,i=["--version"],v={}){let u=Wi(r,i,v);if(u.error&&u.error.code==="ENOENT")return{available:!1,detail:"not found"};if(u.error)return{available:!1,detail:u.error.message};if(u.status!==0)return{available:!1,detail:u.stderr.trim()||u.stdout.trim()||`exit ${u.status}`};return{available:!0,detail:u.stdout.trim()||u.stderr.trim()||"ok"}}function al(r){return/not found|no running instance|cannot find|does not exist|no such process/i.test(r)}function Z6(r,i={}){if(!Number.isFinite(r))return{attempted:!1,delivered:!1,method:null};let v=i.platform??An.platform,u=i.runCommandImpl??Wi,n=i.killImpl??An.kill.bind(An);if(v==="win32"){let $=u("taskkill",["/PID",String(r),"/T","/F"],{cwd:i.cwd,env:i.env});if(!$.error&&$.status===0)return{attempted:!0,delivered:!0,method:"taskkill",result:$};let t=`${$.stderr}
6
6
  ${$.stdout}`.trim();if(!$.error&&al(t))return{attempted:!0,delivered:!1,method:"taskkill",result:$};if($.error?.code==="ENOENT")try{return n(r),{attempted:!0,delivered:!0,method:"kill"}}catch(g){if(g?.code==="ESRCH")return{attempted:!0,delivered:!1,method:"kill"};throw g}if($.error)throw $.error;throw Error(sl($))}try{return n(-r,"SIGTERM"),{attempted:!0,delivered:!0,method:"process-group"}}catch($){if($?.code!=="ESRCH")try{return n(r,"SIGTERM"),{attempted:!0,delivered:!0,method:"process"}}catch(t){if(t?.code==="ESRCH")return{attempted:!0,delivered:!1,method:"process"};throw t}return{attempted:!0,delivered:!1,method:"process-group"}}}function sl(r){let i=[`${r.command} ${r.args.join(" ")}`.trim()];if(r.signal)i.push(`signal=${r.signal}`);else i.push(`exit=${r.status}`);let v=(r.stderr||"").trim(),u=(r.stdout||"").trim();if(v)i.push(v);else if(u)i.push(u);return i.join(": ")}var Li="CODER_APP_SERVER_ENDPOINT",C6=-32001,vU="0.144.1",D$;function $U(){if(D$===void 0){let r=Wi("codex",["--version"]),i=/(\d+\.\d+\.\d+(?:-[\w.]+)?)/.exec(`${r.stdout} ${r.stderr}`);D$=i?i[1]:vU}return D$}function e6(){return{title:"Coder",name:"coder",version:$U()}}var y6={experimentalApi:!1,requestAttestation:!1,optOutNotificationMethods:["item/agentMessage/delta","item/reasoning/summaryTextDelta","item/reasoning/summaryPartAdded","item/reasoning/textDelta"]};function f6(r,i,v){return v===void 0?{code:r,message:i}:{code:r,message:i,data:v}}function N$(r,i){let v=Error(r);if(v.data=i,i?.code!==void 0)v.rpcCode=i.code;return v}class z${cwd;options;pending;nextId;stderr;closed;exitError;notificationHandler;serverRequestHandler;lineBuffer;transport;exitPromise;exitResolved;resolveExit;handleServerRequest;constructor(r,i={}){this.cwd=r,this.options=i,this.pending=new Map,this.nextId=1,this.stderr="",this.closed=!1,this.exitError=null,this.notificationHandler=null,this.serverRequestHandler=null,this.lineBuffer="",this.transport="unknown",this.handleServerRequest=(v)=>this.defaultHandleServerRequest(v),this.exitPromise=new Promise((v)=>{this.resolveExit=v})}setNotificationHandler(r){this.notificationHandler=r}setServerRequestHandler(r){this.serverRequestHandler=r}request(r,i){if(this.closed)throw Error("codex app-server client is closed.");let v=this.nextId;return this.nextId+=1,new Promise((u,n)=>{this.pending.set(v,{resolve:u,reject:n,method:r}),this.sendMessage({id:v,method:r,params:i})})}notify(r,i={}){if(this.closed)return;this.sendMessage({method:r,params:i})}handleChunk(r){this.lineBuffer+=r;let i=this.lineBuffer.indexOf(`
7
7
  `);while(i!==-1){let v=this.lineBuffer.slice(0,i);this.lineBuffer=this.lineBuffer.slice(i+1),this.handleLine(v),i=this.lineBuffer.indexOf(`
8
- `)}}handleLine(r){if(!r.trim())return;let i;try{i=JSON.parse(r)}catch(v){this.handleExit(N$(`Failed to parse codex app-server JSONL: ${v.message}`,{line:r}));return}if(i.id!==void 0&&i.method){this.handleServerRequest(i);return}if(i.id!==void 0){let v=this.pending.get(i.id);if(!v)return;if(this.pending.delete(i.id),i.error)v.reject(N$(i.error.message??`codex app-server ${v.method} failed.`,i.error));else v.resolve(i.result??{});return}if(i.method&&this.notificationHandler)this.notificationHandler(i)}defaultHandleServerRequest(r){if(!this.serverRequestHandler){this.sendMessage({id:r.id,error:f6(-32601,`Unsupported server request: ${r.method}`)});return}Promise.resolve().then(()=>this.serverRequestHandler(r.method,r.params??{})).then((i)=>{this.sendMessage({id:r.id,result:i??{}})}).catch((i)=>{this.sendMessage({id:r.id,error:f6(-32000,i instanceof Error?i.message:String(i))})})}handleExit(r){if(this.exitResolved)return;this.exitResolved=!0,this.exitError=r??null;for(let i of this.pending.values())i.reject(this.exitError??Error("codex app-server connection closed."));this.pending.clear(),this.resolveExit(void 0)}sendMessage(r){throw Error("sendMessage must be implemented by subclasses.")}}class h6 extends z${proc;readline;constructor(r,i={}){super(r,i);this.transport="direct"}async initialize(){this.proc=nU("codex",["app-server"],{cwd:this.cwd,env:this.options.env??En.env,stdio:["pipe","pipe","pipe"],shell:En.platform==="win32"?En.env.SHELL||!0:!1,windowsHide:!0}),this.proc.stdout.setEncoding("utf8"),this.proc.stderr.setEncoding("utf8"),this.proc.stderr.on("data",(r)=>{this.stderr+=r}),this.proc.on("error",(r)=>{this.handleExit(r)}),this.proc.on("exit",(r,i)=>{let v=this.stderr.trim(),u=r===0?null:N$(`codex app-server exited unexpectedly (${i?`signal ${i}`:`exit ${r}`}).${v?`
8
+ `)}}handleLine(r){if(!r.trim())return;let i;try{i=JSON.parse(r)}catch(v){this.handleExit(N$(`Failed to parse codex app-server JSONL: ${v.message}`,{line:r}));return}if(i.id!==void 0&&i.method){this.handleServerRequest(i);return}if(i.id!==void 0){let v=this.pending.get(i.id);if(!v)return;if(this.pending.delete(i.id),i.error)v.reject(N$(i.error.message??`codex app-server ${v.method} failed.`,i.error));else v.resolve(i.result??{});return}if(i.method&&this.notificationHandler)this.notificationHandler(i)}defaultHandleServerRequest(r){if(!this.serverRequestHandler){this.sendMessage({id:r.id,error:f6(-32601,`Unsupported server request: ${r.method}`)});return}Promise.resolve().then(()=>this.serverRequestHandler(r.method,r.params??{})).then((i)=>{this.sendMessage({id:r.id,result:i??{}})}).catch((i)=>{this.sendMessage({id:r.id,error:f6(-32000,i instanceof Error?i.message:String(i))})})}handleExit(r){if(this.exitResolved)return;this.exitResolved=!0,this.exitError=r??null;for(let i of this.pending.values())i.reject(this.exitError??Error("codex app-server connection closed."));this.pending.clear(),this.resolveExit(void 0)}sendMessage(r){throw Error("sendMessage must be implemented by subclasses.")}}class h6 extends z${proc;readline;constructor(r,i={}){super(r,i);this.transport="direct"}async initialize(){this.proc=nU("codex",["app-server","--disable","plugins"],{cwd:this.cwd,env:this.options.env??En.env,stdio:["pipe","pipe","pipe"],shell:En.platform==="win32"?En.env.SHELL||!0:!1,windowsHide:!0}),this.proc.stdout.setEncoding("utf8"),this.proc.stderr.setEncoding("utf8"),this.proc.stderr.on("data",(r)=>{this.stderr+=r}),this.proc.on("error",(r)=>{this.handleExit(r)}),this.proc.on("exit",(r,i)=>{let v=this.stderr.trim(),u=r===0?null:N$(`codex app-server exited unexpectedly (${i?`signal ${i}`:`exit ${r}`}).${v?`
9
9
  ${v}`:""}`);this.handleExit(u)}),this.readline=iU.createInterface({input:this.proc.stdout}),this.readline.on("line",(r)=>{this.handleLine(r)}),await this.request("initialize",{clientInfo:this.options.clientInfo??e6(),capabilities:this.options.capabilities??y6}),this.notify("initialized",{})}async close(){if(this.closed){await this.exitPromise;return}if(this.closed=!0,this.readline)this.readline.close();if(this.proc&&!this.proc.killed)this.proc.stdin.end(),setTimeout(()=>{if(this.proc&&!this.proc.killed&&this.proc.exitCode===null)if(En.platform==="win32")try{Z6(this.proc.pid)}catch{}else this.proc.kill("SIGTERM")},50).unref?.();await this.exitPromise}sendMessage(r){let i=`${JSON.stringify(r)}
10
10
  `,v=this.proc?.stdin;if(!v)throw Error("codex app-server stdin is not available.");v.write(i)}}class d6 extends z${endpoint;socket;constructor(r,i={}){super(r,i);this.transport="broker",this.endpoint=i.brokerEndpoint}async initialize(){await new Promise((r,i)=>{let v=Hn(this.endpoint);this.socket=rU.createConnection({path:v.path}),this.socket.setEncoding("utf8"),this.socket.on("connect",r),this.socket.on("data",(u)=>{this.handleChunk(u)}),this.socket.on("error",(u)=>{if(!this.exitResolved)i(u);this.handleExit(u)}),this.socket.on("close",()=>{this.handleExit(this.exitError)})}),await this.request("initialize",{clientInfo:this.options.clientInfo??e6(),capabilities:this.options.capabilities??y6}),this.notify("initialized",{})}async close(){if(this.closed){await this.exitPromise;return}if(this.closed=!0,this.socket)this.socket.end();await this.exitPromise}sendMessage(r){let i=`${JSON.stringify(r)}
11
11
  `,v=this.socket;if(!v)throw Error("codex app-server broker connection is not connected.");v.write(i)}}class dr{static async connect(r,i={}){let v=null;if(!i.disableBroker){if(v=i.brokerEndpoint??i.env?.[Li]??En.env[Li]??null,!v&&i.reuseExistingBroker)v=k$(r)?.endpoint??null;if(!v&&!i.reuseExistingBroker)v=(await m6(r,{env:i.env}))?.endpoint??null}let u=v?new d6(r,{...i,brokerEndpoint:v}):new h6(r,i);return await u.initialize(),u}}var tU="coder_runtime",p6="Coder Task";function gU(r){return r.split(/\r?\n/).map((i)=>i.trimEnd()).filter((i)=>i&&!i.startsWith("WARNING: proceeding, even though we could not update PATH:")).join(`
@@ -5,7 +5,7 @@ var bt=Object.defineProperty;var pt=(t,u)=>{for(var r in u)bt(t,r,{get:u[r],enum
5
5
  `,"utf8")}function Xt(t){let u=T(t);if(l.existsSync(u))l.unlinkSync(u)}async function Kt(t){if(!t)return!1;try{return await ut(t,150)}catch{return!1}}async function rt(t,u={}){let r=_(t);if(r&&await Kt(r.endpoint))return r;if(r)tt({endpoint:r.endpoint??null,pidFile:r.pidFile??null,logFile:r.logFile??null,sessionDir:r.sessionDir??null,pid:r.pid??null,killProcess:u.killProcess??null}),Xt(t);let n=ot(),f=(u.createBrokerEndpoint??d)(n,u.platform),y=Z.join(n,"broker.pid"),x=Z.join(n,"broker.log"),$=u.scriptPath??Qt(),a=wt({scriptPath:$,cwd:t,endpoint:f,pidFile:y,logFile:x,env:u.env??A.env});if(!await ut(f,u.timeoutMs??2000))return tt({endpoint:f,pidFile:y,logFile:x,sessionDir:n,pid:a.pid??null,killProcess:u.killProcess??null}),null;let O={endpoint:f,pidFile:y,logFile:x,sessionDir:n,pid:a.pid??null};return Yt(t,O),O}function tt({endpoint:t=null,pidFile:u,logFile:r,sessionDir:n=null,pid:c=null,killProcess:f=null}){if(Number.isFinite(c)&&f)try{f(c)}catch{}if(u&&l.existsSync(u))l.unlinkSync(u);if(r&&l.existsSync(r))l.unlinkSync(r);if(t)try{let x=R(t);if(x.kind==="unix"&&l.existsSync(x.path))l.unlinkSync(x.path)}catch{}let y=n??(u?Z.dirname(u):r?Z.dirname(r):null);if(y&&l.existsSync(y))try{l.rmdirSync(y)}catch{}}import{spawnSync as mt}from"node:child_process";import w from"node:process";function V(t,u=[],r={}){let n=mt(t,u,{cwd:r.cwd,env:r.env,encoding:"utf8",input:r.input,maxBuffer:r.maxBuffer,stdio:r.stdio??"pipe",shell:w.platform==="win32"?w.env.SHELL||!0:!1,windowsHide:!0});return{command:t,args:u,status:n.status??0,signal:n.signal??null,stdout:n.stdout??"",stderr:n.stderr??"",error:n.error??null}}function zu(t,u=["--version"],r={}){let n=V(t,u,r);if(n.error&&n.error.code==="ENOENT")return{available:!1,detail:"not found"};if(n.error)return{available:!1,detail:n.error.message};if(n.status!==0)return{available:!1,detail:n.stderr.trim()||n.stdout.trim()||`exit ${n.status}`};return{available:!0,detail:n.stdout.trim()||n.stderr.trim()||"ok"}}function Lt(t){return/not found|no running instance|cannot find|does not exist|no such process/i.test(t)}function nt(t,u={}){if(!Number.isFinite(t))return{attempted:!1,delivered:!1,method:null};let r=u.platform??w.platform,n=u.runCommandImpl??V,c=u.killImpl??w.kill.bind(w);if(r==="win32"){let f=n("taskkill",["/PID",String(t),"/T","/F"],{cwd:u.cwd,env:u.env});if(!f.error&&f.status===0)return{attempted:!0,delivered:!0,method:"taskkill",result:f};let y=`${f.stderr}
6
6
  ${f.stdout}`.trim();if(!f.error&&Lt(y))return{attempted:!0,delivered:!1,method:"taskkill",result:f};if(f.error?.code==="ENOENT")try{return c(t),{attempted:!0,delivered:!0,method:"kill"}}catch(x){if(x?.code==="ESRCH")return{attempted:!0,delivered:!1,method:"kill"};throw x}if(f.error)throw f.error;throw Error(Vt(f))}try{return c(-t,"SIGTERM"),{attempted:!0,delivered:!0,method:"process-group"}}catch(f){if(f?.code!=="ESRCH")try{return c(t,"SIGTERM"),{attempted:!0,delivered:!0,method:"process"}}catch(y){if(y?.code==="ESRCH")return{attempted:!0,delivered:!1,method:"process"};throw y}return{attempted:!0,delivered:!1,method:"process-group"}}}function Vt(t){let u=[`${t.command} ${t.args.join(" ")}`.trim()];if(t.signal)u.push(`signal=${t.signal}`);else u.push(`exit=${t.status}`);let r=(t.stderr||"").trim(),n=(t.stdout||"").trim();if(r)u.push(r);else if(n)u.push(n);return u.join(": ")}var ft="CODER_APP_SERVER_ENDPOINT",ct=-32001,Tt="0.144.1",C;function _t(){if(C===void 0){let t=V("codex",["--version"]),u=/(\d+\.\d+\.\d+(?:-[\w.]+)?)/.exec(`${t.stdout} ${t.stderr}`);C=u?u[1]:Tt}return C}function ht(){return{title:"Coder",name:"coder",version:_t()}}var yt={experimentalApi:!1,requestAttestation:!1,optOutNotificationMethods:["item/agentMessage/delta","item/reasoning/summaryTextDelta","item/reasoning/summaryPartAdded","item/reasoning/textDelta"]};function it(t,u,r){return r===void 0?{code:t,message:u}:{code:t,message:u,data:r}}function D(t,u){let r=Error(t);if(r.data=u,u?.code!==void 0)r.rpcCode=u.code;return r}class P{cwd;options;pending;nextId;stderr;closed;exitError;notificationHandler;serverRequestHandler;lineBuffer;transport;exitPromise;exitResolved;resolveExit;handleServerRequest;constructor(t,u={}){this.cwd=t,this.options=u,this.pending=new Map,this.nextId=1,this.stderr="",this.closed=!1,this.exitError=null,this.notificationHandler=null,this.serverRequestHandler=null,this.lineBuffer="",this.transport="unknown",this.handleServerRequest=(r)=>this.defaultHandleServerRequest(r),this.exitPromise=new Promise((r)=>{this.resolveExit=r})}setNotificationHandler(t){this.notificationHandler=t}setServerRequestHandler(t){this.serverRequestHandler=t}request(t,u){if(this.closed)throw Error("codex app-server client is closed.");let r=this.nextId;return this.nextId+=1,new Promise((n,c)=>{this.pending.set(r,{resolve:n,reject:c,method:t}),this.sendMessage({id:r,method:t,params:u})})}notify(t,u={}){if(this.closed)return;this.sendMessage({method:t,params:u})}handleChunk(t){this.lineBuffer+=t;let u=this.lineBuffer.indexOf(`
7
7
  `);while(u!==-1){let r=this.lineBuffer.slice(0,u);this.lineBuffer=this.lineBuffer.slice(u+1),this.handleLine(r),u=this.lineBuffer.indexOf(`
8
- `)}}handleLine(t){if(!t.trim())return;let u;try{u=JSON.parse(t)}catch(r){this.handleExit(D(`Failed to parse codex app-server JSONL: ${r.message}`,{line:t}));return}if(u.id!==void 0&&u.method){this.handleServerRequest(u);return}if(u.id!==void 0){let r=this.pending.get(u.id);if(!r)return;if(this.pending.delete(u.id),u.error)r.reject(D(u.error.message??`codex app-server ${r.method} failed.`,u.error));else r.resolve(u.result??{});return}if(u.method&&this.notificationHandler)this.notificationHandler(u)}defaultHandleServerRequest(t){if(!this.serverRequestHandler){this.sendMessage({id:t.id,error:it(-32601,`Unsupported server request: ${t.method}`)});return}Promise.resolve().then(()=>this.serverRequestHandler(t.method,t.params??{})).then((u)=>{this.sendMessage({id:t.id,result:u??{}})}).catch((u)=>{this.sendMessage({id:t.id,error:it(-32000,u instanceof Error?u.message:String(u))})})}handleExit(t){if(this.exitResolved)return;this.exitResolved=!0,this.exitError=t??null;for(let u of this.pending.values())u.reject(this.exitError??Error("codex app-server connection closed."));this.pending.clear(),this.resolveExit(void 0)}sendMessage(t){throw Error("sendMessage must be implemented by subclasses.")}}class xt extends P{proc;readline;constructor(t,u={}){super(t,u);this.transport="direct"}async initialize(){this.proc=Et("codex",["app-server"],{cwd:this.cwd,env:this.options.env??Q.env,stdio:["pipe","pipe","pipe"],shell:Q.platform==="win32"?Q.env.SHELL||!0:!1,windowsHide:!0}),this.proc.stdout.setEncoding("utf8"),this.proc.stderr.setEncoding("utf8"),this.proc.stderr.on("data",(t)=>{this.stderr+=t}),this.proc.on("error",(t)=>{this.handleExit(t)}),this.proc.on("exit",(t,u)=>{let r=this.stderr.trim(),n=t===0?null:D(`codex app-server exited unexpectedly (${u?`signal ${u}`:`exit ${t}`}).${r?`
8
+ `)}}handleLine(t){if(!t.trim())return;let u;try{u=JSON.parse(t)}catch(r){this.handleExit(D(`Failed to parse codex app-server JSONL: ${r.message}`,{line:t}));return}if(u.id!==void 0&&u.method){this.handleServerRequest(u);return}if(u.id!==void 0){let r=this.pending.get(u.id);if(!r)return;if(this.pending.delete(u.id),u.error)r.reject(D(u.error.message??`codex app-server ${r.method} failed.`,u.error));else r.resolve(u.result??{});return}if(u.method&&this.notificationHandler)this.notificationHandler(u)}defaultHandleServerRequest(t){if(!this.serverRequestHandler){this.sendMessage({id:t.id,error:it(-32601,`Unsupported server request: ${t.method}`)});return}Promise.resolve().then(()=>this.serverRequestHandler(t.method,t.params??{})).then((u)=>{this.sendMessage({id:t.id,result:u??{}})}).catch((u)=>{this.sendMessage({id:t.id,error:it(-32000,u instanceof Error?u.message:String(u))})})}handleExit(t){if(this.exitResolved)return;this.exitResolved=!0,this.exitError=t??null;for(let u of this.pending.values())u.reject(this.exitError??Error("codex app-server connection closed."));this.pending.clear(),this.resolveExit(void 0)}sendMessage(t){throw Error("sendMessage must be implemented by subclasses.")}}class xt extends P{proc;readline;constructor(t,u={}){super(t,u);this.transport="direct"}async initialize(){this.proc=Et("codex",["app-server","--disable","plugins"],{cwd:this.cwd,env:this.options.env??Q.env,stdio:["pipe","pipe","pipe"],shell:Q.platform==="win32"?Q.env.SHELL||!0:!1,windowsHide:!0}),this.proc.stdout.setEncoding("utf8"),this.proc.stderr.setEncoding("utf8"),this.proc.stderr.on("data",(t)=>{this.stderr+=t}),this.proc.on("error",(t)=>{this.handleExit(t)}),this.proc.on("exit",(t,u)=>{let r=this.stderr.trim(),n=t===0?null:D(`codex app-server exited unexpectedly (${u?`signal ${u}`:`exit ${t}`}).${r?`
9
9
  ${r}`:""}`);this.handleExit(n)}),this.readline=At.createInterface({input:this.proc.stdout}),this.readline.on("line",(t)=>{this.handleLine(t)}),await this.request("initialize",{clientInfo:this.options.clientInfo??ht(),capabilities:this.options.capabilities??yt}),this.notify("initialized",{})}async close(){if(this.closed){await this.exitPromise;return}if(this.closed=!0,this.readline)this.readline.close();if(this.proc&&!this.proc.killed)this.proc.stdin.end(),setTimeout(()=>{if(this.proc&&!this.proc.killed&&this.proc.exitCode===null)if(Q.platform==="win32")try{nt(this.proc.pid)}catch{}else this.proc.kill("SIGTERM")},50).unref?.();await this.exitPromise}sendMessage(t){let u=`${JSON.stringify(t)}
10
10
  `,r=this.proc?.stdin;if(!r)throw Error("codex app-server stdin is not available.");r.write(u)}}class at extends P{endpoint;socket;constructor(t,u={}){super(t,u);this.transport="broker",this.endpoint=u.brokerEndpoint}async initialize(){await new Promise((t,u)=>{let r=R(this.endpoint);this.socket=vt.createConnection({path:r.path}),this.socket.setEncoding("utf8"),this.socket.on("connect",t),this.socket.on("data",(n)=>{this.handleChunk(n)}),this.socket.on("error",(n)=>{if(!this.exitResolved)u(n);this.handleExit(n)}),this.socket.on("close",()=>{this.handleExit(this.exitError)})}),await this.request("initialize",{clientInfo:this.options.clientInfo??ht(),capabilities:this.options.capabilities??yt}),this.notify("initialized",{})}async close(){if(this.closed){await this.exitPromise;return}if(this.closed=!0,this.socket)this.socket.end();await this.exitPromise}sendMessage(t){let u=`${JSON.stringify(t)}
11
11
  `,r=this.socket;if(!r)throw Error("codex app-server broker connection is not connected.");r.write(u)}}class I{static async connect(t,u={}){let r=null;if(!u.disableBroker){if(r=u.brokerEndpoint??u.env?.[ft]??Q.env[ft]??null,!r&&u.reuseExistingBroker)r=_(t)?.endpoint??null;if(!r&&!u.reuseExistingBroker)r=(await rt(t,{env:u.env}))?.endpoint??null}let n=r?new at(t,{...u,brokerEndpoint:r}):new xt(t,u);return await n.initialize(),n}}var Dt=new Set(["turn/start","review/start","thread/compact/start"]);function $t(t,u,r){let n=new Set;if(u?.threadId)n.add(u.threadId);if(t==="review/start"&&r?.reviewThreadId)n.add(r.reviewThreadId);return n}function o(t,u,r){return r===void 0?{code:t,message:u}:{code:t,message:u,data:r}}function W(t,u){if(t.destroyed)return;t.write(`${JSON.stringify(u)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wular/coder",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "description": "Delegating coding-agent runtime",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coder",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "description": "Delegate coding tasks to a Coder subagent. Codex first, Claude fallback; your main context stays clean.",
5
5
  "author": {
6
6
  "name": "muzam1l"
@@ -12,7 +12,7 @@ If `coder` is not on PATH, install it yourself without asking (`npm install -g @
12
12
  ## Dispatching a task
13
13
 
14
14
  - One coder per focused goal. When the work splits into independent parts, decompose it and dispatch each part as its own background `coder task` - fan out a wide web of coders running in parallel, not one giant dispatch. Give each coder a self-contained goal with all context - overview, file paths, constraints (read-only, git rules). Run independent tasks concurrently; use `steer` to continue a single coder's thread.
15
- - Delegation is a hard gate for anything the engine can do itself: do not read source files, investigate, or write code first - no matter how simple the task. Fold into the task text whatever only you have - conversation context, results from tools the engine lacks.
15
+ - Delegation is a hard gate for anything the engine can do itself: do not read source files, investigate, or write code first - no matter how simple the task. Fold into the task text whatever only you have - conversation context, results from tools the engine lacks. The coder worker runs with plugins disabled (no skills, MCP, or connectors), so include any context only a plugin or MCP tool of yours produced.
16
16
  - Compose one self-contained task text (goal, relevant paths, constraints) and run it as a **background Bash call** so you are notified on completion instead of blocking or polling:
17
17
 
18
18
  ```bash
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coder",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "interface": {
5
5
  "displayName": "Coder (plugin)"
6
6
  },
@@ -15,7 +15,7 @@ When you run setup, also check codex is new enough for the default GPT-5.6 model
15
15
 
16
16
  - Run every `coder` command with escalated permissions (outside your sandbox), justification: Coder is a supervisor - it spawns engines, keeps state in `~/.coder`, and enforces its own sandbox and approval policy on the task. Never retry a sandbox-blocked `coder` call sandboxed again or with HOME/state env workarounds.
17
17
  - One coder per focused goal. When the work splits into independent parts, decompose it and dispatch each part as its own `coder task --host codex` call - fan out a wide web of coders, not one giant dispatch. Give each coder a self-contained goal with all context - overview, file paths, constraints (read-only, git rules); use `steer` to continue a single coder's thread.
18
- - Delegation is a hard gate for anything the engine can do itself: do not read source files, investigate, or write code first - no matter how simple the task. Fold into the task text whatever only you have - conversation context, results from tools the engine lacks.
18
+ - Delegation is a hard gate for anything the engine can do itself: do not read source files, investigate, or write code first - no matter how simple the task. Fold into the task text whatever only you have - conversation context, results from tools the engine lacks. The coder worker runs with plugins disabled (no skills, MCP, or connectors), so include any context only a plugin or MCP tool of yours produced.
19
19
  - Compose one self-contained task text (goal, relevant paths, constraints) and run:
20
20
 
21
21
  ```bash