@wular/coder 0.2.5 → 0.2.7
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/README.md +1 -1
- package/dist/cli.js +138 -128
- package/dist/lib/broker.js +14 -14
- package/package.json +1 -1
- package/plugins/agents/skills/coder/SKILL.md +1 -1
- package/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/plugins/claude/skills/handle/SKILL.md +1 -1
- package/plugins/cursor/.cursor-plugin/plugin.json +1 -1
- package/plugins/cursor/README.md +1 -1
- package/plugins/cursor/skills/coder/SKILL.md +1 -1
package/dist/lib/broker.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
3
|
-
`,"utf8"),
|
|
4
|
-
`,"utf8")}function
|
|
5
|
-
`,"utf8")}function
|
|
6
|
-
${
|
|
2
|
+
var E$=Object.defineProperty;var U1=($,W)=>{for(var q in W)E$($,q,{get:W[q],enumerable:!0,configurable:!0,set:(Z)=>W[q]=()=>Z})};import u from"node:fs";import X1 from"node:net";import W$ from"node:path";import T from"node:process";function K$($,W={}){let q=new Set(W.valueOptions??[]),Z=new Set(W.booleanOptions??[]),K=W.aliasMap??{},Q={},X=[],G=!1;for(let H=0;H<$.length;H+=1){let M=$[H];if(G){X.push(M);continue}if(M==="--"){G=!0;continue}if(!M.startsWith("-")||M==="-"){X.push(M);continue}if(M.startsWith("--")){let[x,_]=M.slice(2).split("=",2),J=K[x]??x;if(Z.has(J)){Q[J]=_===void 0?!0:_!=="false";continue}if(q.has(J)){let h=_??$[H+1];if(h===void 0)throw Error(`Missing value for --${x}`);if(Q[J]=h,_===void 0)H+=1;continue}throw Error(`Unknown option --${x} (use -- to pass literal text starting with -)`)}let R=M.slice(1),y=K[R]??R;if(Z.has(y)){Q[y]=!0;continue}if(q.has(y)){let x=$[H+1];if(x===void 0)throw Error(`Missing value for -${R}`);Q[y]=x,H+=1;continue}throw Error(`Unknown option -${R} (use -- to pass literal text starting with -)`)}return{options:Q,positionals:X}}import q1 from"node:net";import F from"node:process";import{spawn as Z1}from"node:child_process";import K1 from"node:readline";import Q$ from"node:path";import C$ from"node:process";function u$($){return String($??"").replace(/[^A-Za-z0-9._-]/g,"-").replace(/^-+|-+$/g,"")}function Y$($,W=C$.platform){if(W==="win32")return`pipe:\\\\.\\pipe\\${u$(`${Q$.win32.basename($)}-codex-app-server`)}`;return`unix:${Q$.join($,"broker.sock")}`}function A($){if(typeof $!=="string"||$.length===0)throw Error("Missing broker endpoint.");if($.startsWith("pipe:")){let W=$.slice(5);if(!W)throw Error("Broker pipe endpoint is missing its path.");return{kind:"pipe",path:W}}if($.startsWith("unix:")){let W=$.slice(5);if(!W)throw Error("Broker Unix socket endpoint is missing its path.");return{kind:"unix",path:W}}throw Error(`Unsupported broker endpoint: ${$}`)}import O from"node:fs";import b$ from"node:net";import p$ from"node:os";import E from"node:path";import i from"node:process";import{spawn as n$}from"node:child_process";import{fileURLToPath as c$}from"node:url";import{execFileSync as z$}from"node:child_process";import V from"node:fs";import I$ from"node:os";import N from"node:path";var k$=["completed","failed","cancelled"],y1=["queued","running"];var S$="CODER_HOME";function H$(){return N.resolve(process.env[S$]||N.join(I$.homedir(),".coder"))}var X$=new Map;function A1($){let W=X$.get($);if(W!==void 0)return W;let q;try{q=z$("git",["rev-parse","--show-toplevel"],{cwd:$,encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim()}catch{q=$}return X$.set($,q),q}var G$="global";function I($){return N.join(H$(),"state",G$)}var w=null;function n(){if(w)return w;let $=N.join(H$(),"state"),W=[];try{W=V.readdirSync($,{withFileTypes:!0})}catch{}return w=W.filter((q)=>q.isDirectory()&&q.name!==G$).map((q)=>N.join($,q.name)),w}function c($){return N.join(I($),"jobs")}function g($){return N.join(I($),"archive")}function B($,W){let q=N.join(c($),W);if(V.existsSync(N.join(q,"job.json")))return q;let Z=N.join(g($),W);if(V.existsSync(N.join(Z,"job.json")))return Z;for(let K of n()){let Q=N.join(K,"jobs",W);if(V.existsSync(N.join(Q,"job.json")))return Q}return q}function M$($,W){let q=W.archived?W:U$($,W.id,{archived:!0,archivedAt:new Date().toISOString()}),Z=B($,W.id),K=N.join(g($),W.id);if(Z!==K)try{V.mkdirSync(g($),{recursive:!0}),V.renameSync(Z,K)}catch{}return q}function f1(){let $=Math.random().toString(36).slice(2,8);return`coder-${Date.now().toString(36)}-${$}`}function U$($,W,q){let Z=B($,W);V.mkdirSync(Z,{recursive:!0});let K=N.join(Z,"job.json"),X={...F$($,W)??{id:W,createdAt:new Date().toISOString(),status:"queued"},...q,updatedAt:new Date().toISOString()};return V.writeFileSync(K,`${JSON.stringify(X,null,2)}
|
|
3
|
+
`,"utf8"),X}function N$($){if(!$.engine&&($.agent==="codex"||$.agent==="claude"))$.engine=$.agent;return $}function F$($,W){let q=N.join(B($,W),"job.json");if(!V.existsSync(q))return null;try{return N$(JSON.parse(V.readFileSync(q,"utf8")))}catch{return null}}function E1($,W){let q=B($,W);if(!V.existsSync(q))return!1;return V.rmSync(q,{recursive:!0,force:!0}),!0}function h$($){if(!$)return!1;try{return process.kill($,0),!0}catch(W){return W.code==="EPERM"}}function D$($){try{let W=z$("ps",["-o","lstart=","-p",String($)],{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim(),q=W?Date.parse(W):NaN;return Number.isFinite(q)?q:null}catch{return null}}function v$($,W){if(!h$($))return!1;let q=D$($),Z=Date.parse(W.createdAt??"");if(q===null||!Number.isFinite(Z))return!0;return q<=Z+60000}var w$=60000;function g$($,W){if(W.status!=="running"&&W.status!=="queued")return W;let q;if(W.pid)q=!v$(W.pid,W);else{let Z=Date.parse(W.updatedAt??W.createdAt??"");q=Number.isFinite(Z)&&Date.now()-Z>w$}if(q)return U$($,W.id,{status:"failed",error:"worker exited without finishing",completedAt:new Date().toISOString()});return W}function p($,W){let q=[];for(let Z of $){let K=[];try{K=V.readdirSync(Z)}catch{continue}for(let Q of K){if(W.has(Q))continue;let X=N.join(Z,Q,"job.json");try{let G=N$(JSON.parse(V.readFileSync(X,"utf8")));W.add(Q),q.push(G)}catch{}}}return q}var l=($,W)=>String(W.updatedAt??"").localeCompare(String($.updatedAt??""));function j$($){let W=[c($),...n().map((Z)=>N.join(Z,"jobs"))],q=[];for(let Z of p(W,new Set))if(Z.archived)M$($,Z);else q.push(g$($,Z));return q.sort(l)}function m$($){let W=new Set,q=p([g($)],W),Z=[c($),...n().map((K)=>N.join(K,"jobs"))];for(let K of p(Z,W))if(K.archived)q.push(M$($,K));return q.sort(l)}function C1($,W){let q=[...j$($),...m$($)].sort(l);if(!W)return q[0]??null;let Z=q.find((Q)=>Q.id===W);if(Z)return Z;let K=q.filter((Q)=>Q.id.startsWith(W));if(K.length===1)return K[0];if(K.length>1)throw Error(`Job reference "${W}" is ambiguous. Use a longer id.`);return null}function u1($,W){let q=B($,W);try{V.mkdirSync(q,{recursive:!0}),V.writeFileSync(N.join(q,"heartbeat"),"","utf8")}catch{}}function k1($,W){let q=B($,W.id),Z=Date.parse(W.updatedAt??"")||0;for(let K of["log.jsonl","heartbeat"])try{Z=Math.max(Z,V.statSync(N.join(q,K)).mtimeMs)}catch{}return Z?new Date(Z).toISOString():void 0}function I1($,W,q){let Z=B($,W);V.mkdirSync(Z,{recursive:!0}),V.appendFileSync(N.join(Z,"log.jsonl"),`${JSON.stringify({at:new Date().toISOString(),...q})}
|
|
4
|
+
`,"utf8")}function S1($,W,q=40){let Z=N.join(B($,W),"log.jsonl");if(!V.existsSync(Z))return[];return V.readFileSync(Z,"utf8").split(/\r?\n/).filter(Boolean).slice(-q).map((Q)=>{try{return JSON.parse(Q)}catch{return{message:Q}}})}import a from"node:fs";import{fileURLToPath as t}from"node:url";var v1=t(import.meta.url);function V$(){try{return JSON.parse(a.readFileSync(t(new URL("../package.json",import.meta.url)),"utf8")).version??"unknown"}catch{return"unknown"}}function w1($){try{return JSON.parse(a.readFileSync($,"utf8")).version??null}catch{return null}}function g1(){return t(new URL("..",import.meta.url))}var l$="broker.json";function a$($="coder-"){return O.mkdtempSync(E.join(p$.tmpdir(),$))}function t$($){let W=A($);return b$.createConnection({path:W.path})}async function R$($,W=2000){let q=Date.now();while(Date.now()-q<W){if(await new Promise((K)=>{let Q=t$($);Q.on("connect",()=>{Q.end(),K(!0)}),Q.on("error",()=>K(!1))}))return!0;await new Promise((K)=>setTimeout(K,50))}return!1}function i$({scriptPath:$,cwd:W,endpoint:q,pidFile:Z,logFile:K,env:Q=i.env}){let X=O.openSync(K,"a"),G=n$(i.execPath,[$,"serve","--endpoint",q,"--cwd",W,"--pid-file",Z],{cwd:W,env:Q,detached:!0,stdio:["ignore",X,X]});return G.unref(),O.closeSync(X),G}function d$(){let $=[new URL("./lib/broker.js",import.meta.url),new URL("./broker.js",import.meta.url)];for(let W of $){let q=c$(W);if(O.existsSync(q))return q}throw Error("Coder broker script not found next to the runtime. Rebuild with `bun run build`.")}function d($){return E.join(I($),l$)}function r($){let W=d($);if(!O.existsSync(W))return null;try{return JSON.parse(O.readFileSync(W,"utf8"))}catch{return null}}function r$($,W){let q=I($);O.mkdirSync(q,{recursive:!0}),O.writeFileSync(d($),`${JSON.stringify(W,null,2)}
|
|
5
|
+
`,"utf8")}function s$($){let W=d($);if(O.existsSync(W))O.unlinkSync(W)}async function o$($){if(!$)return!1;try{return await R$($,150)}catch{return!1}}async function x$($,W={}){let q=W.scriptPath??d$(),Z=V$(),K=r($),Q=K?.version===Z&&K?.scriptPath===q;if(K&&Q&&await o$(K.endpoint))return K;if(K)O$({endpoint:K.endpoint??null,pidFile:K.pidFile??null,logFile:K.logFile??null,sessionDir:K.sessionDir??null,pid:K.pid??null,killProcess:W.killProcess??null}),s$($);let X=a$(),H=(W.createBrokerEndpoint??Y$)(X,W.platform),M=E.join(X,"broker.pid"),R=E.join(X,"broker.log"),y=i$({scriptPath:q,cwd:$,endpoint:H,pidFile:M,logFile:R,env:W.env??i.env});if(!await R$(H,W.timeoutMs??2000))return O$({endpoint:H,pidFile:M,logFile:R,sessionDir:X,pid:y.pid??null,killProcess:W.killProcess??null}),null;let _={endpoint:H,pidFile:M,logFile:R,sessionDir:X,pid:y.pid??null,version:Z,scriptPath:q};return r$($,_),_}function O$({endpoint:$=null,pidFile:W,logFile:q,sessionDir:Z=null,pid:K=null,killProcess:Q=null}){if(Number.isFinite(K)&&Q)try{Q(K)}catch{}if(W&&O.existsSync(W))O.unlinkSync(W);if(q&&O.existsSync(q))O.unlinkSync(q);if($)try{let G=A($);if(G.kind==="unix"&&O.existsSync(G.path))O.unlinkSync(G.path)}catch{}let X=Z??(W?E.dirname(W):q?E.dirname(q):null);if(X&&O.existsSync(X))try{O.rmdirSync(X)}catch{}}import{spawnSync as e$}from"node:child_process";import S from"node:process";function j($,W=[],q={}){let Z=e$($,W,{cwd:q.cwd,env:q.env,encoding:"utf8",input:q.input,maxBuffer:q.maxBuffer,stdio:q.stdio??"pipe",shell:S.platform==="win32"?S.env.SHELL||!0:!1,windowsHide:!0});return{command:$,args:W,status:Z.status??0,signal:Z.signal??null,stdout:Z.stdout??"",stderr:Z.stderr??"",error:Z.error??null}}function e1($,W=["--version"],q={}){let Z=j($,W,q);if(Z.error&&Z.error.code==="ENOENT")return{available:!1,detail:"not found"};if(Z.error)return{available:!1,detail:Z.error.message};if(Z.status!==0)return{available:!1,detail:Z.stderr.trim()||Z.stdout.trim()||`exit ${Z.status}`};return{available:!0,detail:Z.stdout.trim()||Z.stderr.trim()||"ok"}}function $1($){return/not found|no running instance|cannot find|does not exist|no such process/i.test($)}function y$($,W={}){if(!Number.isFinite($))return{attempted:!1,delivered:!1,method:null};let q=$,Z=W.platform??S.platform,K=W.runCommandImpl??j,Q=W.killImpl??S.kill.bind(S);if(Z==="win32"){let X=K("taskkill",["/PID",String(q),"/T","/F"],{cwd:W.cwd,env:W.env});if(!X.error&&X.status===0)return{attempted:!0,delivered:!0,method:"taskkill",result:X};let G=`${X.stderr}
|
|
6
|
+
${X.stdout}`.trim();if(!X.error&&$1(G))return{attempted:!0,delivered:!1,method:"taskkill",result:X};if(X.error?.code==="ENOENT")try{return Q(q),{attempted:!0,delivered:!0,method:"kill"}}catch(H){if(H?.code==="ESRCH")return{attempted:!0,delivered:!1,method:"kill"};throw H}if(X.error)throw X.error;throw Error(W1(X))}try{return Q(-q,"SIGTERM"),{attempted:!0,delivered:!0,method:"process-group"}}catch(X){if(X?.code!=="ESRCH")try{return Q(q,"SIGTERM"),{attempted:!0,delivered:!0,method:"process"}}catch(G){if(G?.code==="ESRCH")return{attempted:!0,delivered:!1,method:"process"};throw G}return{attempted:!0,delivered:!1,method:"process-group"}}}function W1($){let W=[`${$.command} ${$.args.join(" ")}`.trim()];if($.signal)W.push(`signal=${$.signal}`);else W.push(`exit=${$.status}`);let q=($.stderr||"").trim(),Z=($.stdout||"").trim();if(q)W.push(q);else if(Z)W.push(Z);return W.join(": ")}var L$="CODER_APP_SERVER_ENDPOINT",P$=-32001,Q1="0.144.1",s;function Y1(){if(s===void 0){let $=j("codex",["--version"]),W=/(\d+\.\d+\.\d+(?:-[\w.]+)?)/.exec(`${$.stdout} ${$.stderr}`);s=W?W[1]:Q1}return s}function _$(){return{title:"Coder",name:"coder",version:Y1()}}var B$={experimentalApi:!1,requestAttestation:!1,optOutNotificationMethods:["item/agentMessage/delta","item/reasoning/summaryTextDelta","item/reasoning/summaryPartAdded","item/reasoning/textDelta"]};function T$($,W,q){return q===void 0?{code:$,message:W}:{code:$,message:W,data:q}}function o($,W){let q=Error($);if(q.data=W,W?.code!==void 0)q.rpcCode=W.code;return q}class e{cwd;options;pending;nextId;stderr;closed;exitError;notificationHandler;serverRequestHandler;lineBuffer;transport;exitPromise;exitResolved;resolveExit;handleServerRequest;constructor($,W={}){this.cwd=$,this.options=W,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=(q)=>this.defaultHandleServerRequest(q),this.exitPromise=new Promise((q)=>{this.resolveExit=q})}setNotificationHandler($){this.notificationHandler=$}setServerRequestHandler($){this.serverRequestHandler=$}request($,W){if(this.closed)throw Error("codex app-server client is closed.");let q=this.nextId;return this.nextId+=1,new Promise((Z,K)=>{this.pending.set(q,{resolve:Z,reject:K,method:$}),this.sendMessage({id:q,method:$,params:W})})}notify($,W={}){if(this.closed)return;this.sendMessage({method:$,params:W})}handleChunk($){this.lineBuffer+=$;let W=this.lineBuffer.indexOf(`
|
|
7
7
|
`);while(W!==-1){let q=this.lineBuffer.slice(0,W);this.lineBuffer=this.lineBuffer.slice(W+1),this.handleLine(q),W=this.lineBuffer.indexOf(`
|
|
8
|
-
`)}}handleLine($){if(!$.trim())return;let W;try{W=JSON.parse($)}catch(q){this.handleExit(
|
|
9
|
-
${K}`:""}`);this.handleExit(
|
|
10
|
-
`,q=this.proc?.stdin;if(!q)throw Error("codex app-server stdin is not available.");q.write(W)}}class
|
|
11
|
-
`,q=this.socket;if(!q)throw Error("codex app-server broker connection is not connected.");q.write(W)}}class
|
|
12
|
-
`)}function
|
|
13
|
-
`,"utf8")}async function
|
|
14
|
-
`);while(
|
|
15
|
-
`),!
|
|
16
|
-
`),
|
|
8
|
+
`)}}handleLine($){if(!$.trim())return;let W;try{W=JSON.parse($)}catch(q){this.handleExit(o(`Failed to parse codex app-server JSONL: ${q instanceof Error?q.message:String(q)}`,{line:$}));return}if(W.id!==void 0&&W.method){this.handleServerRequest(W);return}if(W.id!==void 0){let q=this.pending.get(W.id);if(!q)return;if(this.pending.delete(W.id),W.error)q.reject(o(W.error.message??`codex app-server ${q.method} failed.`,W.error));else q.resolve(W.result??{});return}if(W.method&&this.notificationHandler)this.notificationHandler(W)}defaultHandleServerRequest($){let W=this.serverRequestHandler;if(!W){this.sendMessage({id:$.id,error:T$(-32601,`Unsupported server request: ${$.method}`)});return}Promise.resolve().then(()=>W($.method,$.params??{})).then((q)=>{this.sendMessage({id:$.id,result:q??{}})}).catch((q)=>{this.sendMessage({id:$.id,error:T$(-32000,q instanceof Error?q.message:String(q))})})}handleExit($){if(this.exitResolved)return;this.exitResolved=!0,this.exitError=$??null;for(let W of this.pending.values())W.reject(this.exitError??Error("codex app-server connection closed."));this.pending.clear(),this.resolveExit(void 0)}sendMessage($){throw Error("sendMessage must be implemented by subclasses.")}}class J$ extends e{proc;readline;constructor($,W={}){super($,W);this.transport="direct"}async initialize(){this.proc=Z1("codex",["-c","sandbox_workspace_write.network_access=false","app-server","--disable","plugins"],{cwd:this.cwd,env:this.options.env??F.env,stdio:["pipe","pipe","pipe"],shell:F.platform==="win32"?F.env.SHELL||!0:!1,windowsHide:!0});let $=this.proc.stdout,W=this.proc.stderr;if(!$||!W)throw Error("codex app-server did not expose stdio streams.");$.setEncoding("utf8"),W.setEncoding("utf8"),W.on("data",(q)=>{this.stderr+=q}),this.proc.on("error",(q)=>{this.handleExit(q)}),this.proc.on("exit",(q,Z)=>{let K=this.stderr.trim(),Q=q===0?null:o(`codex app-server exited unexpectedly (${Z?`signal ${Z}`:`exit ${q}`}).${K?`
|
|
9
|
+
${K}`:""}`);this.handleExit(Q)}),this.readline=K1.createInterface({input:$}),this.readline.on("line",(q)=>{this.handleLine(q)}),await this.request("initialize",{clientInfo:this.options.clientInfo??_$(),capabilities:this.options.capabilities??B$}),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(F.platform==="win32")try{y$(this.proc.pid)}catch{}else this.proc.kill("SIGTERM")},50).unref?.();await this.exitPromise}sendMessage($){let W=`${JSON.stringify($)}
|
|
10
|
+
`,q=this.proc?.stdin;if(!q)throw Error("codex app-server stdin is not available.");q.write(W)}}class A$ extends e{endpoint;socket;constructor($,W={}){super($,W);this.transport="broker",this.endpoint=W.brokerEndpoint}async initialize(){await new Promise(($,W)=>{let q=A(this.endpoint);this.socket=q1.createConnection({path:q.path}),this.socket.setEncoding("utf8"),this.socket.on("connect",$),this.socket.on("data",(Z)=>{this.handleChunk(Z)}),this.socket.on("error",(Z)=>{if(!this.exitResolved)W(Z);this.handleExit(Z)}),this.socket.on("close",()=>{this.handleExit(this.exitError)})}),await this.request("initialize",{clientInfo:this.options.clientInfo??_$(),capabilities:this.options.capabilities??B$}),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($){let W=`${JSON.stringify($)}
|
|
11
|
+
`,q=this.socket;if(!q)throw Error("codex app-server broker connection is not connected.");q.write(W)}}class $${static async connect($,W={}){let q=null;if(!W.disableBroker){if(q=W.brokerEndpoint??W.env?.[L$]??F.env[L$]??null,!q&&W.reuseExistingBroker)q=r($)?.endpoint??null;if(!q&&!W.reuseExistingBroker)q=(await x$($,{env:W.env}))?.endpoint??null}let Z=q?new A$($,{...W,brokerEndpoint:q}):new J$($,W);return await Z.initialize(),Z}}var z1=new Set(["turn/start","review/start","thread/compact/start"]);function f$($,W,q){let Z=new Set;if(W?.threadId)Z.add(W.threadId);if($==="review/start"&&q?.reviewThreadId)Z.add(q.reviewThreadId);return Z}function C($,W,q){return q===void 0?{code:$,message:W}:{code:$,message:W,data:q}}function P($,W){if($.destroyed)return;$.write(`${JSON.stringify(W)}
|
|
12
|
+
`)}function H1($){return $?.method==="turn/interrupt"}function G1($){if(!$)return;u.mkdirSync(W$.dirname($),{recursive:!0}),u.writeFileSync($,`${T.pid}
|
|
13
|
+
`,"utf8")}async function M1(){let[$,...W]=T.argv.slice(2);if($!=="serve")throw Error("Usage: node src/lib/broker.mjs serve --endpoint <value> [--cwd <path>] [--pid-file <path>]");let{options:q}=K$(W,{valueOptions:["cwd","pid-file","endpoint"]});if(!q.endpoint)throw Error("Missing required --endpoint.");let Z=q.cwd?W$.resolve(T.cwd(),q.cwd):T.cwd(),K=String(q.endpoint),Q=A(K),X=q["pid-file"]?W$.resolve(q["pid-file"]):null;G1(X);let G=await $$.connect(Z,{disableBroker:!0}),H=null,M=null,R=null,y=new Set,x=new Map;function _(Y){for(let[U,f]of x)if(f===Y)x.delete(U),G.sendMessage({id:U,error:C(-32000,"Broker client disconnected before answering the server request.")})}function J(Y){if(_(Y),H===Y)H=null;if(M===Y)M=null,R=null}function h(Y){let U=H??M;if(!U)return;if(P(U,Y),Y.method==="turn/completed"&&M===U){let f=Y.params?.threadId??null;if(!f||!R||R.has(f)){if(M=null,R=null,H===U)H=null}}}async function m(Y){for(let U of y)U.end();if(await G.close().catch(()=>{}),await new Promise((U)=>Y.close(U)),Q.kind==="unix"&&u.existsSync(Q.path))u.unlinkSync(Q.path);if(X&&u.existsSync(X))u.unlinkSync(X)}G.setNotificationHandler(h),G.handleServerRequest=(Y)=>{let U=M??H;if(!U||U.destroyed){G.sendMessage({id:Y.id,error:C(-32601,`No broker client available to answer ${Y.method}.`)});return}x.set(Y.id,U),P(U,Y)};let D=X1.createServer((Y)=>{y.add(Y),Y.setEncoding("utf8");let U="";Y.on("data",async(f)=>{U+=f;let v=U.indexOf(`
|
|
14
|
+
`);while(v!==-1){let q$=U.slice(0,v);if(U=U.slice(v+1),v=U.indexOf(`
|
|
15
|
+
`),!q$.trim())continue;let z;try{z=JSON.parse(q$)}catch(L){P(Y,{id:null,error:C(-32700,`Invalid JSON: ${L instanceof Error?L.message:String(L)}`)});continue}if(z.id!==void 0&&!z.method&&x.has(z.id)){x.delete(z.id),G.sendMessage(z);continue}if(z.id!==void 0&&z.method==="initialize"){P(Y,{id:z.id,result:{userAgent:"coder-broker"}});continue}if(z.method==="initialized"&&z.id===void 0)continue;if(z.id!==void 0&&z.method==="broker/shutdown")P(Y,{id:z.id,result:{}}),await m(D),T.exit(0);if(z.id===void 0||!z.method)continue;let Z$=H1(z)&&M&&M!==Y&&!H;if((H&&H!==Y||M&&M!==Y)&&!Z$){P(Y,{id:z.id,error:C(P$,"Shared Codex broker is busy.")});continue}if(Z$){try{let L=await G.request(z.method,z.params??{});P(Y,{id:z.id,result:L})}catch(L){let k=L;P(Y,{id:z.id,error:C(k.rpcCode??-32000,k.message)})}continue}let b=z1.has(z.method);if(H=Y,b)M=Y,R=f$(z.method,z.params??{},null);try{let L=await G.request(z.method,z.params??{});if(P(Y,{id:z.id,result:L}),b)R=f$(z.method,z.params??{},L);if(H===Y)H=null}catch(L){let k=L;if(P(Y,{id:z.id,error:C(k.rpcCode??-32000,k.message)}),H===Y)H=null;if(M===Y&&b)M=null,R=null}}}),Y.on("close",()=>{y.delete(Y),J(Y)}),Y.on("error",()=>{y.delete(Y),J(Y)})});T.on("SIGTERM",async()=>{await m(D),T.exit(0)}),T.on("SIGINT",async()=>{await m(D),T.exit(0)}),D.listen(Q.path)}M1().catch(($)=>{T.stderr.write(`${$ instanceof Error?$.message:String($)}
|
|
16
|
+
`),T.exit(1)});
|
package/package.json
CHANGED
|
@@ -29,7 +29,7 @@ If `coder` is not on PATH, install it yourself without asking (`npm install -g @
|
|
|
29
29
|
- Compose one self-contained task text (goal, relevant paths, constraints) and dispatch it. It backgrounds by default: the runtime does a startup check and prints a task id (or errors / hands off, see exit codes):
|
|
30
30
|
|
|
31
31
|
```bash
|
|
32
|
-
coder task run "<task text>"
|
|
32
|
+
coder task run --system "<standing instructions>" "<task text>"
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
Fetch the answer with `coder task result <task-id> --wait` - it blocks until the task finishes, then prints only the final result (keeps your context clean). Only use `--wait` when your harness can run it in a **background shell** (so it does not block you); without one, poll `coder task result <task-id>` (no `--wait`) until it is done. Or skip the two steps and block on the run itself with `--wait` on `coder task run`.
|
|
@@ -28,7 +28,7 @@ If `coder` is not on PATH, install it yourself without asking (`npm install -g @
|
|
|
28
28
|
- Compose one self-contained task text (goal, relevant paths, constraints) and dispatch it. It backgrounds by default: the runtime does a startup check and prints a task id (or errors / hands off, see exit codes):
|
|
29
29
|
|
|
30
30
|
```bash
|
|
31
|
-
coder task run "<task text>"
|
|
31
|
+
coder task run --system "<standing instructions>" "<task text>"
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
Fetch the answer with `coder task result <task-id> --wait` - it blocks until the task finishes, then prints only the final result (keeps your context clean). Run it as a **background Bash call** so it does not block you and you are re-invoked on completion:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "coder",
|
|
3
3
|
"displayName": "Coder",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.7",
|
|
5
5
|
"description": "Delegate coding tasks to supervised Coder subagents running on Codex, Claude, or any OpenAI-compatible model. Your main context stays clean.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "muzam1l"
|
package/plugins/cursor/README.md
CHANGED
|
@@ -81,7 +81,7 @@ You rarely need these - the host agent drives tasks itself - but everything is s
|
|
|
81
81
|
|
|
82
82
|
```bash
|
|
83
83
|
coder run "<text>" # dispatch a task (--wait to block for the answer)
|
|
84
|
-
coder list # list
|
|
84
|
+
coder list # list recent tasks (running + just stopped)
|
|
85
85
|
coder result [task-id] # status + final answer (--wait blocks until done)
|
|
86
86
|
coder task steer <task-id> "<text>" # continue a task with new instructions
|
|
87
87
|
coder task stop <task-id> # interrupt it
|
|
@@ -29,7 +29,7 @@ If `coder` is not on PATH, install it yourself without asking (`npm install -g @
|
|
|
29
29
|
- Compose one self-contained task text (goal, relevant paths, constraints) and dispatch it. It backgrounds by default: the runtime does a startup check and prints a task id (or errors / hands off, see exit codes):
|
|
30
30
|
|
|
31
31
|
```bash
|
|
32
|
-
coder task run "<task text>"
|
|
32
|
+
coder task run --system "<standing instructions>" "<task text>"
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
Fetch the answer with `coder task result <task-id> --wait` - it blocks until the task finishes, then prints only the final result (keeps your context clean). Only use `--wait` when you can run it in a **background terminal** (so it does not block you); if you can't, poll `coder task result <task-id>` (no `--wait`) until it is done. Or skip the two steps and block on the run itself with `--wait` on `coder task run`.
|