@oxgeneral/orch 0.2.4 → 0.3.0
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/App-TW35IULR.js +18 -0
- package/dist/agent-FRQKL7YI.js +9 -0
- package/dist/{orchestrator-OMU46RCE.js → chunk-2UC4SVJB.js} +190 -53
- package/dist/chunk-2UC4SVJB.js.map +1 -0
- package/dist/chunk-5AJ4LYO5.js +8 -0
- package/dist/{chunk-45K2XID7.js → chunk-6DWHQPTE.js} +2 -1
- package/dist/chunk-6DWHQPTE.js.map +1 -0
- package/dist/{chunk-POUC4CPC.js → chunk-6MJ7V6VY.js} +2 -2
- package/dist/{chunk-HNKJ4IF7.js → chunk-B4JQM4NU.js} +34 -10
- package/dist/chunk-B4JQM4NU.js.map +1 -0
- package/dist/{chunk-6HENRUYZ.js → chunk-CDFA4IIQ.js} +2 -2
- package/dist/chunk-CHRW4CLD.js +2 -0
- package/dist/{chunk-VAAOW526.js → chunk-GZ2Q56YZ.js} +2 -2
- package/dist/{doctor-service-QEJCE5FK.js → chunk-HMMPM7MF.js} +2 -2
- package/dist/{chunk-AELEEEV3.js → chunk-HSBYJ5C5.js} +27 -7
- package/dist/chunk-HXOMNULD.js +2 -0
- package/dist/{chunk-3TGCIXJA.js → chunk-IQXRQBUK.js} +2 -1
- package/dist/chunk-IQXRQBUK.js.map +1 -0
- package/dist/chunk-L26TK7Y5.js +2 -0
- package/dist/chunk-L3FYR45M.js +2 -0
- package/dist/chunk-LXNRCJ22.js +2 -0
- package/dist/{chunk-TX7WOFCW.js → chunk-MGFMVPRD.js} +4 -7
- package/dist/chunk-MGFMVPRD.js.map +1 -0
- package/dist/chunk-MNXU3KCD.js +2 -0
- package/dist/{chunk-CHIP7O6V.js → chunk-O2MSGW3V.js} +3 -1
- package/dist/chunk-O2MSGW3V.js.map +1 -0
- package/dist/chunk-PJ5DKXGR.js +2 -0
- package/dist/{chunk-2KSBOAW3.js → chunk-QEEM67OA.js} +11 -17
- package/dist/chunk-QEEM67OA.js.map +1 -0
- package/dist/chunk-UMZEA3JT.js +5 -0
- package/dist/{shell-OGTSH4RJ.js → chunk-UW6GUUE6.js} +3 -3
- package/dist/chunk-XDVMX2FO.js +8 -0
- package/dist/chunk-XDVMX2FO.js.map +1 -0
- package/dist/chunk-ZA5Z33GO.js +11 -0
- package/dist/claude-E36EGXUV.js +2 -0
- package/dist/{chunk-IRN2U2NE.js → claude-RIB3RQS5.js} +5 -2
- package/dist/claude-RIB3RQS5.js.map +1 -0
- package/dist/cli.js +1 -199
- package/dist/clipboard-service-PDTSZIR5.js +25 -0
- package/dist/codex-OTZKVESD.js +2 -0
- package/dist/{codex-U7LTJTX6.js → codex-VBUSA2GJ.js} +5 -3
- package/dist/codex-VBUSA2GJ.js.map +1 -0
- package/dist/config-CCSS2P7R.js +2 -0
- package/dist/container-OIXLFSX2.js +6 -0
- package/dist/context-GSMQHQES.js +7 -0
- package/dist/cursor-3DJA6LWS.js +2 -0
- package/dist/{cursor-3DI5GKRF.js → cursor-4QIOTDBW.js} +5 -3
- package/dist/cursor-4QIOTDBW.js.map +1 -0
- package/dist/doctor-KBK5JZBZ.js +2 -0
- package/dist/{chunk-K6DMQERQ.js → doctor-service-F2SXDWHS.js} +3 -1
- package/dist/doctor-service-F2SXDWHS.js.map +1 -0
- package/dist/doctor-service-PB7YBH3F.js +2 -0
- package/dist/goal-RFKFPR7M.js +8 -0
- package/dist/index.d.ts +105 -43
- package/dist/index.js +1817 -5
- package/dist/index.js.map +1 -1
- package/dist/init-WRDFAFS2.js +53 -0
- package/dist/logs-5QHJWMEG.js +12 -0
- package/dist/msg-4SCLBO4K.js +9 -0
- package/dist/orchestrator-FGGXK3N3.js +5 -0
- package/dist/{orchestrator-L6QX2LJ7.js.map → orchestrator-FGGXK3N3.js.map} +1 -1
- package/dist/orchestrator-R7IWZUT6.js +13 -0
- package/dist/process-manager-33H27MQF.js +2 -0
- package/dist/process-manager-A36Y7LHP.js +3 -0
- package/dist/{process-manager-TLZOTO4Y.js.map → process-manager-A36Y7LHP.js.map} +1 -1
- package/dist/registry-BO2PPRNG.js +2 -0
- package/dist/registry-JXXRLJ5J.js +3 -0
- package/dist/{registry-UQAHK77P.js.map → registry-JXXRLJ5J.js.map} +1 -1
- package/dist/run-HSHRELOP.js +3 -0
- package/dist/shell-EOJBDWTH.js +2 -0
- package/dist/{chunk-CIIE6LNG.js → shell-IH2MMTVP.js} +3 -2
- package/dist/shell-IH2MMTVP.js.map +1 -0
- package/dist/status-DLBNWSWM.js +2 -0
- package/dist/task-J6ZN7ALI.js +20 -0
- package/dist/team-MSIBKOQC.js +4 -0
- package/dist/template-engine-MFL5B677.js +3 -0
- package/dist/{template-engine-322SCRR6.js.map → template-engine-MFL5B677.js.map} +1 -1
- package/dist/template-engine-ONIDVD4F.js +2 -0
- package/dist/tui-G4XUFAIP.js +2 -0
- package/dist/update-PC2ENCKU.js +2 -0
- package/dist/update-check-HGMBDYHL.js +2 -0
- package/dist/workspace-manager-KOOYTO7E.js +3 -0
- package/dist/{workspace-manager-G5EQRS72.js → workspace-manager-T6AXG7XL.js} +4 -3
- package/dist/workspace-manager-T6AXG7XL.js.map +1 -0
- package/package.json +2 -1
- package/readme.md +5 -4
- package/scripts/benchmark.ts +304 -0
- package/dist/App-KHUT3IV7.js +0 -4962
- package/dist/agent-V5M2C3OC.js +0 -157
- package/dist/chunk-33QNTNR6.js +0 -46
- package/dist/chunk-6HENRUYZ.js.map +0 -1
- package/dist/chunk-AELEEEV3.js.map +0 -1
- package/dist/chunk-ED47GL3F.js +0 -29
- package/dist/chunk-FRTKB575.js +0 -87
- package/dist/chunk-HXYAZGLP.js +0 -15
- package/dist/chunk-I5WEMARW.js +0 -166
- package/dist/chunk-IZYSGYXG.js +0 -2
- package/dist/chunk-IZYSGYXG.js.map +0 -1
- package/dist/chunk-P6ATSXGL.js +0 -107
- package/dist/chunk-PBFE5V3G.js +0 -2
- package/dist/chunk-PBFE5V3G.js.map +0 -1
- package/dist/chunk-PNE6LQRF.js +0 -5
- package/dist/chunk-POUC4CPC.js.map +0 -1
- package/dist/chunk-QTDKQYZI.js +0 -11
- package/dist/chunk-QTDKQYZI.js.map +0 -1
- package/dist/chunk-VAAOW526.js.map +0 -1
- package/dist/chunk-ZTQ3KWXR.js +0 -13
- package/dist/chunk-ZTQ3KWXR.js.map +0 -1
- package/dist/claude-GH6P2DC5.js +0 -4
- package/dist/claude-S47YTIHU.js +0 -2
- package/dist/claude-S47YTIHU.js.map +0 -1
- package/dist/codex-2CH57B7G.js +0 -2
- package/dist/codex-2CH57B7G.js.map +0 -1
- package/dist/config-LJFM55LN.js +0 -75
- package/dist/container-KPH4HVAJ.js +0 -1532
- package/dist/context-EPSDCJTU.js +0 -83
- package/dist/cursor-QFUNKPCQ.js +0 -2
- package/dist/cursor-QFUNKPCQ.js.map +0 -1
- package/dist/doctor-GHRV5I2S.js +0 -67
- package/dist/doctor-service-QEJCE5FK.js.map +0 -1
- package/dist/doctor-service-TPOMFAIG.js +0 -2
- package/dist/goal-I56QP7HS.js +0 -110
- package/dist/init-EQTGQ4G2.js +0 -165
- package/dist/logs-AK255DEJ.js +0 -207
- package/dist/msg-SQWQLJP6.js +0 -95
- package/dist/orchestrator-L6QX2LJ7.js +0 -2
- package/dist/process-manager-HUVNAPQV.js +0 -2
- package/dist/process-manager-TLZOTO4Y.js +0 -2
- package/dist/registry-PQWRVNF2.js +0 -2
- package/dist/registry-UQAHK77P.js +0 -2
- package/dist/run-PSZURVVL.js +0 -95
- package/dist/shell-5ZNXFGXV.js +0 -3
- package/dist/shell-OGTSH4RJ.js.map +0 -1
- package/dist/status-DTF7D3DV.js +0 -56
- package/dist/task-35SDKXFC.js +0 -209
- package/dist/team-AISPLEJB.js +0 -97
- package/dist/template-engine-322SCRR6.js +0 -2
- package/dist/template-engine-3CDRZNMJ.js +0 -3
- package/dist/tui-AR6PVMBQ.js +0 -230
- package/dist/update-DCCWVISK.js +0 -64
- package/dist/update-check-4YKLGBFB.js +0 -2
- package/dist/workspace-manager-AS4TFA7R.js +0 -3
- package/dist/workspace-manager-AS4TFA7R.js.map +0 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {a as a$2}from'./chunk-PJ5DKXGR.js';import {b as b$2,c as c$2}from'./chunk-HXOMNULD.js';import {a as a$1,b as b$3}from'./chunk-LXNRCJ22.js';import {a}from'./chunk-CHRW4CLD.js';import {l,b as b$1,c,i as i$1,k as k$1,e,d,f as f$1,g as g$1,h,j as j$2}from'./chunk-ZA5Z33GO.js';import {c as c$1,k,j as j$1,g,f,i}from'./chunk-GZ2Q56YZ.js';import Y,{mkdir}from'fs/promises';import {createReadStream}from'fs';import z from'path';import {homedir}from'os';import {nanoid}from'nanoid';var b=class{constructor(t){this.paths=t;}async list(t){await i$1(this.paths.tasksDir);let e=await k$1(this.paths.tasksDir,".yml");return (await Promise.all(e.map(r=>{let n=r.replace(".yml","");return b$1(this.paths.taskPath(n))}))).filter(r=>r!==null&&(!t?.status||r.status===t.status)&&(!t?.goalId||r.goalId===t.goalId)).sort((r,n)=>{let i=ct(r.status)-ct(n.status);if(i!==0)return i;let o=n.updated_at??"",l=r.updated_at??"";return o<l?-1:o>l?1:0})}async get(t){return b$1(this.paths.taskPath(t))}async save(t){await i$1(this.paths.tasksDir),await c(this.paths.taskPath(t.id),t);}async delete(t){try{await Y.unlink(this.paths.taskPath(t));}catch(e){if(e.code!=="ENOENT")throw e}}};function ct(m){return {in_progress:0,retrying:1,review:2,todo:3,done:4,failed:5,cancelled:6}[m]}var A=class{constructor(t){this.paths=t;}async list(){await i$1(this.paths.agentsDir);let t=await k$1(this.paths.agentsDir,".yml");return (await Promise.all(t.map(s=>{let a=s.replace(".yml","");return b$1(this.paths.agentPath(a))}))).filter(s=>s!==null)}async get(t){return b$1(this.paths.agentPath(t))}async getByName(t){return (await this.list()).find(s=>s.name===t)??null}async save(t){await i$1(this.paths.agentsDir),await c(this.paths.agentPath(t.id),t);}async delete(t){try{await Y.unlink(this.paths.agentPath(t));}catch(e){if(e.code!=="ENOENT")throw e}}};var E=class{constructor(t){this.paths=t;}async save(t){await i$1(this.paths.runsDir),await e(this.paths.runPath(t.id),t);}async get(t){return d(this.paths.runPath(t))}async listAll(){return this.listFiltered(()=>true)}async listForTask(t){return this.listFiltered(e=>e.task_id===t)}async listForAgent(t){return this.listFiltered(e=>e.agent_id===t)}async appendEvent(t,e){await i$1(this.paths.runsDir),await f$1(this.paths.runEventsPath(t),e);}async readEvents(t){return g$1(this.paths.runEventsPath(t))}async readEventsTail(t,e){return h(this.paths.runEventsPath(t),e)}async*streamEvents(t,e){let s=this.paths.runEventsPath(t),a=Date.now()+3e4;for(;!e?.aborted&&Date.now()<a&&!await j$2(s);)await new Promise(i=>setTimeout(i,100));if(e?.aborted||Date.now()>=a)return;let r=createReadStream(s),{readLines:n}=await import('./process-manager-33H27MQF.js');try{for await(let i of n(r)){if(e?.aborted)break;if(i.trim())try{yield JSON.parse(i);}catch{process.stderr.write(`[RunStore] skipping corrupt JSONL line: ${i.slice(0,200)}
|
|
3
|
+
`);}}}finally{r.destroy();}}async listFiltered(t){await i$1(this.paths.runsDir);let e=await k$1(this.paths.runsDir,".json"),s=64,a=[];for(let r=0;r<e.length;r+=s){let n=e.slice(r,r+s),i=await Promise.all(n.map(o=>{let l=o.endsWith(".json")?o.slice(0,-5):o;return d(this.paths.runPath(l))}));for(let o of i)o!==null&&t(o)&&a.push(o);}return a.sort((r,n)=>new Date(n.started_at).getTime()-new Date(r.started_at).getTime())}};var U={version:1,running:{},claimed:new Set,retry_queue:[],stats:{total_runs:0,total_tasks_completed:0,total_tasks_failed:0,total_tokens:{input:0,output:0,total:0},total_runtime_ms:0}};var I=class{constructor(t){this.paths=t;}async read(){let t=await d(this.paths.statePath);if(!t)return structuredClone(U);let e=structuredClone(U);return {version:t.version??e.version,pid:t.pid,started_at:t.started_at,running:t.running&&typeof t.running=="object"?t.running:e.running,claimed:Array.isArray(t.claimed)?new Set(t.claimed):new Set(e.claimed),retry_queue:Array.isArray(t.retry_queue)?t.retry_queue:e.retry_queue,stats:{total_runs:t.stats?.total_runs??e.stats.total_runs,total_tasks_completed:t.stats?.total_tasks_completed??e.stats.total_tasks_completed,total_tasks_failed:t.stats?.total_tasks_failed??e.stats.total_tasks_failed,total_tokens:t.stats?.total_tokens??e.stats.total_tokens,total_runtime_ms:t.stats?.total_runtime_ms??e.stats.total_runtime_ms}}}async write(t){let e$1={...t,claimed:Array.from(t.claimed)};await e(this.paths.statePath,e$1);}};var x=class{constructor(t){this.paths=t;}async read(){let t=await b$1(this.paths.configPath);return lt(a$2,t??{})}async write(t){await c(this.paths.configPath,t);}async get(t){let e=await this.read();return Pt(e,t)}async set(t,e){let s=await this.read();Tt(s,t,e),await this.write(s);}};function Pt(m,t){let e=t.split("."),s=m;for(let a of e){if(s==null||typeof s!="object")return;s=s[a];}return s}function Tt(m,t,e){let s=t.split("."),a=m;for(let n=0;n<s.length-1;n++){let i=s[n];(typeof a[i]!="object"||a[i]===null)&&(a[i]={}),a=a[i];}let r=s[s.length-1];a[r]=e;}function lt(m,t){let e={...m};for(let s of Object.keys(t)){let a=t[s],r=e[s];a!=null&&typeof a=="object"&&!Array.isArray(a)&&typeof r=="object"&&r!==null&&!Array.isArray(r)?e[s]=lt(r,a):e[s]=a;}return e}var q={tui:{activity_filter:"all"}};var ut=z.join(homedir(),".orchestry"),gt=z.join(ut,"global.yml"),C=class{async read(){let t=await b$1(gt);return t?{tui:{activity_filter:t.tui?.activity_filter??q.tui.activity_filter}}:{...q}}async write(t){await mkdir(ut,{recursive:true}),await c(gt,t);}async set(t,e){let s=await this.read();s.tui[t]=e,await this.write(s);}};var j=class m{constructor(t){this.paths=t;}async get(t){let e=await d(this.paths.contextPath(t));return e?pt(e)?(await this.delete(t),null):e:null}static MAX_TTL_MS=720*60*60*1e3;async set(t,e$1,s){if(s!==void 0&&(!Number.isFinite(s)||s<=0||s>m.MAX_TTL_MS))throw new Error(`TTL must be a positive number up to ${m.MAX_TTL_MS}ms (30 days)`);await i$1(this.paths.contextDir);let a=new Date().toISOString(),r=await d(this.paths.contextPath(t)),n={key:t,value:e$1,created_at:r?.created_at??a,updated_at:a,ttl_ms:s,expires_at:s?new Date(Date.now()+s).toISOString():void 0};await e(this.paths.contextPath(t),n);}async delete(t){try{await Y.unlink(this.paths.contextPath(t));}catch(e){if(e.code!=="ENOENT")throw e}}async list(){await i$1(this.paths.contextDir);let t=await k$1(this.paths.contextDir,".json"),e=await Promise.all(t.map(a=>{let r=a.replace(".json","");return d(this.paths.contextPath(r))})),s=[];for(let a of e)if(a){if(pt(a)){await this.delete(a.key);continue}s.push(a);}return s.sort((a,r)=>a.key.localeCompare(r.key))}async getAll(){let t=await this.list(),e={};for(let s of t)e[s.key]=s.value;return e}};function pt(m){return m.expires_at?new Date(m.expires_at).getTime()<Date.now():false}var R=class{constructor(t){this.paths=t;}async save(t){await i$1(this.paths.messagesDir),await e(this.paths.messagePath(t.id),t);}async get(t){return d(this.paths.messagePath(t))}async list(){let t=await k$1(this.paths.messagesDir,".json");return (await Promise.all(t.map(s=>d(this.paths.messagePath(s.replace(".json","")))))).filter(s=>s!==null).sort((s,a)=>s.created_at.localeCompare(a.created_at))}async listPending(t){let e=await this.list(),s=Date.now();return e.filter(a=>a.status!=="pending"||a.expires_at&&new Date(a.expires_at).getTime()<s?false:a.to_agent_id===t)}async markDelivered(t){let e$1=await this.get(t);e$1&&(e$1.status="delivered",e$1.delivered_at=new Date().toISOString(),await e(this.paths.messagePath(t),e$1));}async delete(t){try{await Y.unlink(this.paths.messagePath(t));}catch(e){if(e.code!=="ENOENT")throw e}}async purgeExpired(){let t=await this.list(),e=Date.now(),s=t.filter(a=>{let r=a.expires_at&&new Date(a.expires_at).getTime()<e,n=a.delivered_at&&e-new Date(a.delivered_at).getTime()>36e5;return r||n});return await Promise.all(s.map(a=>this.delete(a.id))),s.length}};var D=class{constructor(t){this.paths=t;}async list(t){let e=await k$1(this.paths.goalsDir,".yml");return (await Promise.all(e.map(r=>{let n=r.replace(".yml","");return b$1(this.paths.goalPath(n))}))).filter(r=>r!==null&&(!t?.status||r.status===t.status)).sort((r,n)=>{let i=c$2[r.status]-c$2[n.status];if(i!==0)return i;let o=n.updated_at??"",l=r.updated_at??"";return o<l?-1:o>l?1:0})}async get(t){return b$1(this.paths.goalPath(t))}async save(t){await c(this.paths.goalPath(t.id),t);}async delete(t){try{await Y.unlink(this.paths.goalPath(t));}catch(e){if(e.code!=="ENOENT")throw e}}};var O=class{constructor(t){this.paths=t;}async save(t){await i$1(this.paths.teamsDir),await c(this.paths.teamPath(t.id),t);}async get(t){return b$1(this.paths.teamPath(t))}async getByName(t){return (await this.list()).find(s=>s.name===t)??null}async list(){await i$1(this.paths.teamsDir);let t=await k$1(this.paths.teamsDir,".yml");return (await Promise.all(t.map(s=>b$1(this.paths.teamPath(s.replace(".yml","")))))).filter(s=>s!==null)}async delete(t){try{await Y.unlink(this.paths.teamPath(t));}catch(e){if(e.code!=="ENOENT")throw e}}};var M=class{handlers=new Map;wildcardHandlers=new Set;maxListeners=10;warnedTypes=new Set;setMaxListeners(t){this.maxListeners=t;}getMaxListeners(){return this.maxListeners}listenerCount(t){return this.handlers.get(t)?.size??0}on(t,e){this.handlers.has(t)||this.handlers.set(t,new Set);let s=this.handlers.get(t);return s.add(e),this.maxListeners>0&&s.size>this.maxListeners&&!this.warnedTypes.has(t)&&(this.warnedTypes.add(t),console.warn(`EventBus: possible memory leak detected. ${s.size} listeners added for "${t}". Use setMaxListeners() to increase limit if this is intentional.`)),()=>this.off(t,e)}once(t,e){let s=a=>{this.off(t,s),e(a);};return this.on(t,s)}off(t,e){this.handlers.get(t)?.delete(e);}emit(t){let e=this.handlers.get(t.type);e&&this.dispatchToSet(e,t,"handler"),this.dispatchToSet(this.wildcardHandlers,t,"wildcard handler");}dispatchToSet(t,e,s){for(let a of t)try{a(e);}catch(r){console.error(`EventBus ${s} error for "${e.type}":`,r);}}onAny(t){return this.wildcardHandlers.add(t),this.maxListeners>0&&this.wildcardHandlers.size>this.maxListeners&&!this.warnedTypes.has("*")&&(this.warnedTypes.add("*"),console.warn(`EventBus: possible memory leak detected. ${this.wildcardHandlers.size} wildcard listeners added. Use setMaxListeners() to increase limit if this is intentional.`)),()=>{this.wildcardHandlers.delete(t);}}clear(){this.handlers.clear(),this.wildcardHandlers.clear(),this.warnedTypes.clear();}};var G=class{constructor(t,e,s,a){this.taskStore=t;this.eventBus=e;this.config=s;this.paths=a;}async create(t){if(!t.title.trim())throw new c$1("Task title is required");let e=t.priority??this.config.defaults.task.priority;if(!Number.isInteger(e)||e<1||e>4)throw new c$1("Priority must be an integer between 1 and 4");if(t.depends_on?.length){let n=(await Promise.all(t.depends_on.map(async i=>({depId:i,exists:!!await this.taskStore.get(i)})))).filter(i=>!i.exists).map(i=>i.depId);if(n.length>0)throw new c$1(`Unknown depends_on task ID(s): ${n.join(", ")}`)}let s=new Date().toISOString(),a={id:`tsk_${nanoid(7)}`,title:t.title.trim(),description:t.description?.trim()??"",status:"todo",priority:e,assignee:t.assignee,labels:t.labels??[],depends_on:t.depends_on??[],created_at:s,updated_at:s,attempts:0,max_attempts:t.max_attempts??this.config.defaults.task.max_attempts,workspace_mode:t.workspace_mode,review_criteria:t.review_criteria,scope:t.scope,goalId:t.goalId};if(t.attachments?.length&&this.paths){let r=await this.copyAttachments(a.id,t.attachments);a.attachments=r;}return await this.taskStore.save(a),this.eventBus.emit({type:"task:created",task:a}),a}async list(t){return this.taskStore.list(t)}async get(t){let e=await this.taskStore.get(t);if(!e)throw new f(t);return e}async updateStatus(t,e){let s=await this.get(t),a=s.status;if(!a$1(a,e))throw new i(t,a,e);return s.status=e,s.updated_at=new Date().toISOString(),await this.taskStore.save(s),this.eventBus.emit({type:"task:status_changed",taskId:t,from:a,to:e}),s}async assign(t,e){let s=await this.get(t);return s.assignee=e,s.updated_at=new Date().toISOString(),await this.taskStore.save(s),this.eventBus.emit({type:"task:assigned",taskId:t,agentId:e}),s}async cancel(t){let e=await this.get(t);if(b$3(e.status))throw new i(t,e.status,"cancelled");return this.updateStatus(t,"cancelled")}async retry(t){let e=await this.get(t);if(e.status!=="failed"&&e.status!=="cancelled")throw new i(t,e.status,"todo");let s=e.status;return e.status="todo",e.attempts=0,e.updated_at=new Date().toISOString(),await this.taskStore.save(e),this.eventBus.emit({type:"task:status_changed",taskId:t,from:s,to:"todo"}),e}async reject(t,e){let s=await this.get(t);if(s.status!=="review")throw new i(t,s.status,"todo");let a=s.status;return s.status="todo",s.attempts=0,s.feedback=e,s.updated_at=new Date().toISOString(),await this.taskStore.save(s),this.eventBus.emit({type:"task:status_changed",taskId:t,from:a,to:"todo"}),s}async update(t,e){let s=await this.get(t);if(e.title!==void 0){if(!e.title.trim())throw new c$1("Task title cannot be empty");s.title=e.title.trim();}if(e.description!==void 0&&(s.description=e.description.trim()),e.priority!==void 0){if(!Number.isInteger(e.priority)||e.priority<1||e.priority>4)throw new c$1("Priority must be an integer between 1 and 4");s.priority=e.priority;}if(e.labels!==void 0&&(s.labels=e.labels),e.attachments?.length&&this.paths){let a=await this.copyAttachments(t,e.attachments);s.attachments=[...s.attachments??[],...a];}return s.updated_at=new Date().toISOString(),await this.taskStore.save(s),s}async delete(t){if((await this.get(t)).status==="in_progress")throw new c$1("Cannot delete a running task. Cancel it first.");if(await this.taskStore.delete(t),this.paths){let s=this.paths.taskAttachmentsDir(t);await Y.rm(s,{recursive:true,force:true});}}getAttachmentPath(t,e){if(!this.paths)throw new c$1("Paths not configured");return z.join(this.paths.taskAttachmentsDir(t),e)}async copyAttachments(t,e){if(!this.paths)return [];let s=this.paths.taskAttachmentsDir(t);return await i$1(s),await Promise.all(e.map(async r=>{try{await Y.access(r);}catch{throw new c$1(`Attachment file not found: ${r}`)}})),await Promise.all(e.map(async r=>{let n=z.basename(r);return await Y.copyFile(r,z.join(s,n)),n}))}async incrementAttempts(t){let e=await this.get(t);return e.attempts+=1,e.updated_at=new Date().toISOString(),await this.taskStore.save(e),e}};var B=class{constructor(t,e,s,a){this.agentStore=t;this.stateStore=e;this.eventBus=s;this.config=a;}async create(t){if(!t.name.trim())throw new c$1("Agent name is required");if(await this.agentStore.getByName(t.name))throw new c$1(`Agent "${t.name}" already exists`);let s={id:`agt_${nanoid(7)}`,name:t.name.trim(),adapter:t.adapter||this.config.defaults.agent.adapter,role:t.role,config:{command:t.command,model:t.model,approval_policy:t.approval_policy??this.config.defaults.agent.approval_policy,max_turns:t.max_turns??this.config.defaults.agent.max_turns,timeout_ms:t.timeout_ms??this.config.defaults.agent.timeout_ms,stall_timeout_ms:t.stall_timeout_ms??this.config.defaults.agent.stall_timeout_ms,env:t.env,system_prompt:t.system_prompt,workspace_mode:t.workspace_mode,skills:t.skills},status:"idle",stats:{tasks_completed:0,tasks_failed:0,total_runs:0,total_runtime_ms:0}};return await this.agentStore.save(s),s}async list(){return this.agentStore.list()}async get(t){let e=await this.agentStore.get(t);if(!e)throw new g(t);return e}async remove(t){let e=await this.get(t);if(e.status==="running"){let s=await this.stateStore.read();if(Object.values(s.running).some(r=>r.agent_id===t))throw new c$1("Cannot remove a running agent. Stop it first.");e.status="idle",await this.agentStore.save(e);}await this.agentStore.delete(t);}async update(t,e){let s=await this.get(t);if(e.name!==void 0){if(!e.name.trim())throw new c$1("Agent name cannot be empty");let a=await this.agentStore.getByName(e.name.trim());if(a&&a.id!==t)throw new c$1(`Agent "${e.name}" already exists`);s.name=e.name.trim();}return e.role!==void 0&&(s.role=e.role||void 0),e.model!==void 0&&(s.config.model=e.model||void 0),e.approval_policy!==void 0&&(s.config.approval_policy=e.approval_policy),await this.agentStore.save(s),s}async disable(t){return this.setStatus(t,"disabled")}async enable(t){return this.setStatus(t,"idle")}async setAutonomous(t,e){let s=await this.get(t);return s.autonomous=e,await this.agentStore.save(s),this.eventBus.emit({type:"agent:autonomous_toggled",agentId:t,autonomous:e}),s}async setStatus(t,e){let s=await this.get(t);return s.status=e,await this.agentStore.save(s),s}async updateStats(t,e){let s=await this.get(t);return Object.assign(s.stats,e),await this.agentStore.save(s),s}async findBestAgent(t){let e=await this.agentStore.list(),s=e.filter(n=>n.status==="idle");if(s.length===0)return null;if(t.assignee){let n=e.find(i=>i.id===t.assignee);return n&&n.status==="idle"?n:null}let a=t.labels?.length?t.labels.map(n=>n.toLowerCase()):void 0,r=s.map(n=>{let i=0;if(a&&n.config.skills?.length){let l=new Set(n.config.skills.map(g=>g.toLowerCase()));for(let g of a)l.has(g)&&(i+=50);}if(a&&n.role){let l=n.role.toLowerCase();a.some(g=>l.includes(g))&&(i+=30);}n.status==="idle"&&(i+=20);let o=n.stats.tasks_completed+n.stats.tasks_failed;return o>0&&(i+=Math.round(n.stats.tasks_completed/o*10)),{agent:n,score:i}});return r.sort((n,i)=>i.score-n.score),r[0]?.agent??null}};var L=class{constructor(t,e){this.runStore=t;this.eventBus=e;}async create(t){let e={id:`run_${nanoid(7)}`,task_id:t.taskId,agent_id:t.agentId,attempt:t.attempt,status:"preparing",started_at:new Date().toISOString(),workspace_path:t.workspacePath,prompt:t.prompt};return await this.runStore.save(e),e}async get(t){return this.runStore.get(t)}async start(t,e){let s=await this.runStore.get(t);if(!s)throw new Error(`Run not found: ${t}`);return s.status="running",s.pid=e,await this.runStore.save(s),this.eventBus.emit({type:"agent:started",agentId:s.agent_id,taskId:s.task_id,runId:t}),s}async finish(t,e,s,a){let r=await this.runStore.get(t);if(!r)throw new Error(`Run not found: ${t}`);return r.status=e,r.finished_at=new Date().toISOString(),r.tokens=s,r.error=a,await this.runStore.save(r),this.eventBus.emit({type:"agent:completed",runId:t,agentId:r.agent_id,success:e==="succeeded"}),r}async appendEvent(t,e){await this.runStore.appendEvent(t,e);}async listAll(){return this.runStore.listAll()}async listForTask(t){return this.runStore.listForTask(t)}async listForAgent(t){return this.runStore.listForAgent(t)}async readEvents(t){return this.runStore.readEvents(t)}async readEventsTail(t,e){return this.runStore.readEventsTail(t,e)}async getLastFailedRunContext(t,e=50){let a=(await this.runStore.listForTask(t)).filter(i=>i.status==="failed").sort((i,o)=>(o.finished_at??"").localeCompare(i.finished_at??""))[0];if(!a)return null;let r=a.error??"Unknown error",n="";try{n=(await this.runStore.readEventsTail(a.id,e*2)).filter(l=>l.type==="agent_output"||l.type==="error").map(l=>typeof l.data=="string"?l.data:JSON.stringify(l.data)).join(`
|
|
4
|
+
`).split(`
|
|
5
|
+
`).slice(-e).join(`
|
|
6
|
+
`);}catch{}return {error:r,output:n}}};var F=class{constructor(t,e,s,a){this.messageStore=t;this.agentStore=e;this.teamStore=s;this.eventBus=a;}async send(t){if(!t.body.trim())throw new c$1("Message body is required");let e=t.ttl_ms??864e5;if(e<=0||e>6048e5)throw new c$1(`TTL must be between 1ms and ${6048e5}ms`);if(!await this.agentStore.get(t.from_agent_id)&&t.from_agent_id!=="cli")throw new c$1(`Sender agent not found: ${t.from_agent_id}`);let a=new Date,r={channel:t.channel,from_agent_id:t.from_agent_id,subject:(t.subject||"(no subject)").slice(0,200),body:t.body.slice(0,4e3),created_at:a.toISOString(),expires_at:new Date(a.getTime()+e).toISOString(),status:"pending",team_id:t.team_id,reply_to:t.reply_to},n=[];if(t.channel==="broadcast"){let i=await this.agentStore.list();if(t.team_id){let g=await this.teamStore.get(t.team_id);if(g){let v=new Set(g.members.map(p=>p.agent_id));i=i.filter(p=>v.has(p.id));}}let l=i.filter(g=>g.id!==t.from_agent_id&&g.status!=="disabled").map(g=>({...r,id:`msg_${nanoid(7)}`,to_agent_id:g.id}));await Promise.all(l.map(g=>this.messageStore.save(g)));for(let g of l)n.push(g),this.emitSent(g);}else if(t.channel==="lead"){if(!t.team_id)throw new c$1("team_id is required for lead channel");let i=await this.teamStore.get(t.team_id);if(!i)throw new c$1(`Team not found: ${t.team_id}`);let o={...r,id:`msg_${nanoid(7)}`,to_agent_id:i.lead_agent_id};await this.messageStore.save(o),n.push(o),this.emitSent(o);}else {if(!t.to_agent_id)throw new c$1("to_agent_id is required for direct messages");if(!await this.agentStore.get(t.to_agent_id))throw new c$1(`Recipient agent not found: ${t.to_agent_id}`);let o={...r,id:`msg_${nanoid(7)}`,to_agent_id:t.to_agent_id};await this.messageStore.save(o),n.push(o),this.emitSent(o);}return n}async drainMailbox(t,e){let s=await this.messageStore.listPending(t);await Promise.all(s.map(a=>this.messageStore.markDelivered(a.id)));for(let a of s)this.eventBus.emit({type:"message:delivered",messageId:a.id,toAgentId:t,taskId:e});return s}async listAll(){return this.messageStore.list()}async listPendingForAgent(t){return this.messageStore.listPending(t)}async listForAgent(t){return (await this.messageStore.list()).filter(s=>s.to_agent_id===t||s.from_agent_id===t)}async purgeExpired(){return this.messageStore.purgeExpired()}emitSent(t){this.eventBus.emit({type:"message:sent",messageId:t.id,fromAgentId:t.from_agent_id,toAgentId:t.to_agent_id,channel:t.channel});}};var Gt={active:["paused","achieved","abandoned"],paused:["active","abandoned"],achieved:[],abandoned:[]},N=class{constructor(t,e,s,a,r){this.goalStore=t;this.eventBus=e;this.agentService=s;this.taskService=a;this.contextStore=r;}async create(t){if(!t.title.trim())throw new c$1("Goal title is required");let e=new Date().toISOString(),s={id:`goal_${nanoid(7)}`,title:t.title.trim(),description:t.description?.trim()??"",status:"active",assignee:t.assignee,created_at:e,updated_at:e};return await this.goalStore.save(s),this.eventBus.emit({type:"goal:created",goalId:s.id,title:s.title}),s.assignee&&await this.enableAutonomous(s.assignee),s}async list(t){return this.goalStore.list(t)}async get(t){let e=await this.goalStore.get(t);if(!e)throw new j$1(t);return e}async updateStatus(t,e){let s=await this.get(t),a=s.status;if(!Gt[a].includes(e))throw new c$1(`Cannot transition goal from '${a}' to '${e}'`);return s.status=e,s.updated_at=new Date().toISOString(),await this.goalStore.save(s),this.eventBus.emit({type:"goal:status_changed",goalId:t,from:a,to:e}),s.assignee&&(e==="paused"?(await this.maybeDisableAutonomous(s.assignee),await this.cancelPendingAutonomousTasks(s.assignee)):e==="active"&&a==="paused"?await this.enableAutonomous(s.assignee):b$2(e)&&await this.maybeDisableAutonomous(s.assignee)),s}async update(t,e){let s=await this.get(t),a=s.assignee;if(e.title!==void 0){if(!e.title.trim())throw new c$1("Goal title cannot be empty");s.title=e.title.trim();}e.description!==void 0&&(s.description=e.description.trim()),e.assignee!==void 0&&(s.assignee=e.assignee||void 0),s.updated_at=new Date().toISOString(),await this.goalStore.save(s),this.eventBus.emit({type:"goal:updated",goalId:t});let r=s.assignee;if(r!==a){let n=[];r&&n.push(this.enableAutonomous(r)),a&&n.push(this.maybeDisableAutonomous(a)),await Promise.all(n);}return s}async delete(t){let e=await this.get(t),{assignee:s}=e;await this.goalStore.delete(t),this.eventBus.emit({type:"goal:deleted",goalId:t}),s&&await this.maybeDisableAutonomous(s);}async listTasksForGoal(t){return this.taskService?.list({goalId:t})??[]}async getProgressReport(t){return this.contextStore?(await this.contextStore.get(`${t}-progress`))?.value:void 0}async enableAutonomous(t){if(this.agentService)try{await this.agentService.setAutonomous(t,!0);}catch{}}async hasActiveGoalsForAgent(t){return (await this.goalStore.list({status:"active"})).some(s=>s.assignee===t)}async cancelPendingAutonomousTasks(t){if(this.taskService)try{let[e,s]=await Promise.all([this.taskService.list({status:"todo"}),this.taskService.list({status:"retrying"})]),a$1=[...e,...s].filter(r=>r.assignee===t&&r.labels?.includes(a));await Promise.all(a$1.map(r=>this.taskService.cancel(r.id).catch(()=>{})));}catch{}}async maybeDisableAutonomous(t){if(this.agentService)try{await this.hasActiveGoalsForAgent(t)||await this.agentService.setAutonomous(t,!1);}catch{}}};var ft={auto_claim:true,message_ttl_ms:864e5};var $=class{constructor(t,e,s,a){this.teamStore=t;this.agentStore=e;this.taskStore=s;this.eventBus=a;}async create(t){if(!t.name.trim())throw new c$1("Team name is required");if(!await this.agentStore.get(t.lead_agent_id))throw new c$1(`Lead agent not found: ${t.lead_agent_id}`);if(await this.teamStore.getByName(t.name.trim()))throw new c$1(`Team "${t.name}" already exists`);let a=new Date().toISOString(),r={agent_id:t.lead_agent_id,role:"lead",joined_at:a},n=[];for(let o of t.member_agent_ids??[]){if(o===t.lead_agent_id)continue;if(!await this.agentStore.get(o))throw new c$1(`Member agent not found: ${o}`);n.push({agent_id:o,role:"member",joined_at:a});}let i={id:`team_${nanoid(7)}`,name:t.name.trim(),description:t.description,status:"active",members:[r,...n],task_pool:[],lead_agent_id:t.lead_agent_id,created_at:a,updated_at:a,config:{...ft,...t.config??{}}};await this.teamStore.save(i),this.eventBus.emit({type:"team:created",teamId:i.id,name:i.name,leadAgentId:i.lead_agent_id});for(let o of n)this.eventBus.emit({type:"team:member_joined",teamId:i.id,agentId:o.agent_id});return i}async get(t){let e=await this.teamStore.get(t);if(!e)throw new k(t);return e}async list(){return this.teamStore.list()}async join(t,e){let s=await this.get(t);if(s.members.some(r=>r.agent_id===e))throw new c$1(`Agent ${e} is already a member of team ${t}`);if(!await this.agentStore.get(e))throw new c$1(`Agent not found: ${e}`);return s.members.push({agent_id:e,role:"member",joined_at:new Date().toISOString()}),s.updated_at=new Date().toISOString(),await this.teamStore.save(s),this.eventBus.emit({type:"team:member_joined",teamId:t,agentId:e}),s}async leave(t,e){let s=await this.get(t);if(e===s.lead_agent_id)throw new c$1("Lead cannot leave team. Disband the team or transfer lead first.");return s.members=s.members.filter(a=>a.agent_id!==e),s.updated_at=new Date().toISOString(),await this.teamStore.save(s),this.eventBus.emit({type:"team:member_left",teamId:t,agentId:e}),s}async addTask(t,e){let s=await this.get(t);if(!await this.taskStore.get(e))throw new c$1(`Task not found: ${e}`);return s.task_pool.includes(e)||(s.task_pool.push(e),s.updated_at=new Date().toISOString(),await this.teamStore.save(s),this.eventBus.emit({type:"team:task_added",teamId:t,taskId:e})),s}async removeTask(t,e){let s=await this.get(t);return s.task_pool=s.task_pool.filter(a=>a!==e),s.updated_at=new Date().toISOString(),await this.teamStore.save(s),s}async setLead(t,e){let s=await this.get(t),a=s.members.find(n=>n.agent_id===e);if(!a)throw new c$1(`Agent ${e} is not a member of team ${t}`);let r=s.members.find(n=>n.agent_id===s.lead_agent_id);return r&&(r.role="member"),a.role="lead",s.lead_agent_id=e,s.updated_at=new Date().toISOString(),await this.teamStore.save(s),s}async disband(t){let e=await this.get(t);e.status="disbanded",e.updated_at=new Date().toISOString(),await this.teamStore.save(e),this.eventBus.emit({type:"team:disbanded",teamId:t});}async findTeamForAgent(t){return (await this.teamStore.list()).find(s=>s.status==="active"&&s.members.some(a=>a.agent_id===t))??null}};async function Lt(m){let t=new l(m.projectRoot);await t.requireInit();let e=new x(t),s=new C,[a,r]=await Promise.all([e.read(),s.read()]),n=new b(t),i=new A(t),o=new E(t),l$1=new I(t),g=new j(t),v=new R(t),p=new D(t),k=new O(t),y=new M,S=new G(n,y,a,t),T=new B(i,l$1,y,a),J=new L(o,y),wt=new F(v,i,k,y),yt=new N(p,y,T,S,g),St=new $(k,i,n,y);return {context:m,paths:t,config:a,taskStore:n,agentStore:i,runStore:o,stateStore:l$1,configStore:e,globalConfigStore:s,globalConfig:r,contextStore:g,messageStore:v,goalStore:p,teamStore:k,eventBus:y,taskService:S,agentService:T,runService:J,messageService:wt,goalService:yt,teamService:St}}async function Ft(m){let t=await Lt(m),[{ProcessManager:e},{AdapterRegistry:s},{ClaudeAdapter:a},{CodexAdapter:r},{CursorAdapter:n},{ShellAdapter:i},{WorkspaceManager:o},{LiquidTemplateEngine:l},{Orchestrator:g},{DoctorService:v}]=await Promise.all([import('./process-manager-33H27MQF.js'),import('./registry-BO2PPRNG.js'),import('./claude-E36EGXUV.js'),import('./codex-OTZKVESD.js'),import('./cursor-3DJA6LWS.js'),import('./shell-EOJBDWTH.js'),import('./workspace-manager-KOOYTO7E.js'),import('./template-engine-ONIDVD4F.js'),import('./orchestrator-R7IWZUT6.js'),import('./doctor-service-PB7YBH3F.js')]),p=new e,k=new l,y=new o(m.projectRoot,t.paths.root,p),S=new s;S.register(new a(p)),S.register(new r(p)),S.register(new n(p)),S.register(new i(p));let T=new v(S,p,m.projectRoot),J=new g({taskStore:t.taskStore,agentStore:t.agentStore,runStore:t.runStore,stateStore:t.stateStore,adapterRegistry:S,workspaceManager:y,templateEngine:k,processManager:p,eventBus:t.eventBus,taskService:t.taskService,agentService:t.agentService,runService:t.runService,contextStore:t.contextStore,messageService:t.messageService,goalStore:t.goalStore,config:t.config,projectRoot:m.projectRoot,lockPath:t.paths.lockPath});return {...t,processManager:p,adapterRegistry:S,workspaceManager:y,templateEngine:k,doctorService:T,orchestrator:J}}async function ps(m){return Ft(m)}export{ps as buildContainer,Ft as buildFullContainer,Lt as buildLightContainer};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {j,i,q,g,l}from'./chunk-L26TK7Y5.js';function u(d,t){let s=d.command("context").description("Shared context store for inter-agent data exchange");s.command("set <key> <value>").description("Set a shared context entry").option("--ttl <ms>","Time-to-live in milliseconds").action(async(e,n,i)=>{await t.paths.requireInit();let o=i.ttl?parseInt(i.ttl,10):void 0;if(await t.contextStore.set(e,n,o),t.context.json){let g=await t.contextStore.get(e);console.log(JSON.stringify(g,null,2));}else t.context.quiet?console.log(e):j(`Set context "${e}"`);}),s.command("get <key>").description("Get a shared context entry").action(async e=>{await t.paths.requireInit();let n=await t.contextStore.get(e);if(!n){t.context.json?console.log("null"):i(`Context key "${e}" not found`);return}t.context.json?console.log(JSON.stringify(n,null,2)):t.context.quiet?console.log(n.value):(console.log(`
|
|
3
|
+
${e} = ${n.value}`),n.expires_at&&console.log(` ${q(`expires: ${n.expires_at}`)}`),console.log());}),s.command("list").description("List all shared context entries").action(async()=>{await t.paths.requireInit();let e=await t.contextStore.list();if(t.context.json){console.log(JSON.stringify(e,null,2));return}if(t.context.quiet){e.forEach(o=>console.log(`${o.key}=${o.value}`));return}if(e.length===0){console.log(`
|
|
4
|
+
No shared context entries. Set one: ${q("orch context set key value")}
|
|
5
|
+
`);return}let n=["KEY","VALUE","UPDATED","TTL"],i=e.map(o=>[o.key,o.value.length>50?o.value.slice(0,47)+"...":o.value,g(o.updated_at),o.expires_at?g(o.expires_at):q("\u2014")]);console.log(),l(n,i),console.log(`
|
|
6
|
+
${e.length} entries
|
|
7
|
+
`);}),s.command("delete <key>").description("Delete a shared context entry").action(async e=>{await t.paths.requireInit(),await t.contextStore.delete(e),!t.context.quiet&&!t.context.json&&j(`Deleted context "${e}"`);});}export{u as registerContextCommand};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {b,a as a$1}from'./chunk-L3FYR45M.js';import'./chunk-6MJ7V6VY.js';import {execFile}from'child_process';import {promisify}from'util';var d=promisify(execFile);async function m(){for(let r of ["cursor-agent","agent"])try{let{stdout:e}=await d(r,["--version"]);return {command:r,version:e.trim()}}catch{}return null}var a=class{constructor(e){this.processManager=e;}kind="cursor";resolvedCommand="cursor-agent";async test(){let e=await m();return e?(this.resolvedCommand=e.command,{ok:true,version:e.version}):{ok:false,error:"Cursor Agent CLI not found. The headless agent CLI is required (cursor-agent or agent)."}}execute(e){let t=["-p","--output-format","stream-json","--workspace",e.workspace,"--yolo"];e.config.model&&t.push("--model",e.config.model);let{process:n,pid:i}=this.processManager.spawn(this.resolvedCommand,t,{cwd:e.workspace,env:{...process.env,...e.env},signal:e.signal,stdio:["pipe","pipe","pipe"]});n.stdin&&(n.stdin.write(e.prompt),n.stdin.end());let c=b(n,l,"Cursor agent",e.signal);return {pid:i,events:c}}async stop(e){await this.processManager.killWithGrace(e);}};function l(r){if(!r.trim())return null;try{let e=JSON.parse(r),t=new Date().toISOString();switch(e.type){case "assistant":return {type:"output",timestamp:t,data:e.message??e};case "tool_use":return {type:"tool_call",timestamp:t,data:e};case "tool_result":return {type:"output",timestamp:t,data:e};case "error":return {type:"error",timestamp:t,data:e.error??e};case "result":{let n=a$1(e);return {type:"done",timestamp:t,data:e,tokens:n}}default:return {type:"output",timestamp:t,data:e}}}catch{return {type:"output",timestamp:new Date().toISOString(),data:r}}}export{a as CursorAdapter};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import './chunk-
|
|
1
|
+
import { createStreamingEvents, extractTokens } from './chunk-MGFMVPRD.js';
|
|
2
|
+
import './chunk-XDVMX2FO.js';
|
|
3
|
+
import './chunk-O2MSGW3V.js';
|
|
4
4
|
import { execFile } from 'child_process';
|
|
5
5
|
import { promisify } from 'util';
|
|
6
6
|
|
|
@@ -90,3 +90,5 @@ function parseCursorEvent(line) {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
export { CursorAdapter };
|
|
93
|
+
//# sourceMappingURL=cursor-4QIOTDBW.js.map
|
|
94
|
+
//# sourceMappingURL=cursor-4QIOTDBW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/infrastructure/adapters/cursor.ts"],"names":[],"mappings":";;;;;;AAiBA,IAAM,aAAA,GAAgB,UAAU,QAAQ,CAAA;AAGxC,eAAe,WAAA,GAAoE;AACjF,EAAA,KAAA,MAAW,GAAA,IAAO,CAAC,cAAA,EAAgB,OAAO,CAAA,EAAG;AAC3C,IAAA,IAAI;AACF,MAAA,MAAM,EAAE,QAAO,GAAI,MAAM,cAAc,GAAA,EAAK,CAAC,WAAW,CAAC,CAAA;AACzD,MAAA,OAAO,EAAE,OAAA,EAAS,GAAA,EAAK,OAAA,EAAS,MAAA,CAAO,MAAK,EAAE;AAAA,IAChD,CAAA,CAAA,MAAQ;AAAA,IAER;AAAA,EACF;AACA,EAAA,OAAO,IAAA;AACT;AAEO,IAAM,gBAAN,MAA6C;AAAA,EAKlD,YAA6B,cAAA,EAAiC;AAAjC,IAAA,IAAA,CAAA,cAAA,GAAA,cAAA;AAAA,EAAkC;AAAA,EAJtD,IAAA,GAAO,QAAA;AAAA,EAER,eAAA,GAA0B,cAAA;AAAA,EAIlC,MAAM,IAAA,GAAmC;AACvC,IAAA,MAAM,KAAA,GAAQ,MAAM,WAAA,EAAY;AAChC,IAAA,IAAI,KAAA,EAAO;AACT,MAAA,IAAA,CAAK,kBAAkB,KAAA,CAAM,OAAA;AAC7B,MAAA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,EAAM,IAAA,EAAK;AAAA,EAC3E;AACF","file":"cursor-4QIOTDBW.js","sourcesContent":["/**\n * Cursor Agent adapter.\n *\n * Spawns `cursor-agent` (Cursor's headless agent CLI) with `--output-format stream-json`.\n * Falls back to `agent` command if `cursor-agent` is not found.\n * Parses JSON-lines from stdout into AgentEvent stream.\n *\n * Note: This requires Cursor Agent CLI, not the regular `cursor` IDE command.\n * Install via: npm i -g @anthropic-ai/cursor-agent (when available)\n */\n\nimport type { IAgentAdapter, AdapterTestResult, ExecuteParams, AgentEvent, ExecuteHandle } from './interface.js';\nimport type { IProcessManager } from '../process/process-manager.js';\nimport { extractTokens, createStreamingEvents } from './utils.js';\nimport { execFile } from 'node:child_process';\nimport { promisify } from 'node:util';\n\nconst execFileAsync = promisify(execFile);\n\n/** Try multiple command names and return the first that works */\nasync function findCommand(): Promise<{ command: string; version: string } | null> {\n for (const cmd of ['cursor-agent', 'agent']) {\n try {\n const { stdout } = await execFileAsync(cmd, ['--version']);\n return { command: cmd, version: stdout.trim() };\n } catch {\n // try next\n }\n }\n return null;\n}\n\nexport class CursorAdapter implements IAgentAdapter {\n readonly kind = 'cursor';\n\n private resolvedCommand: string = 'cursor-agent';\n\n constructor(private readonly processManager: IProcessManager) {}\n\n async test(): Promise<AdapterTestResult> {\n const found = await findCommand();\n if (found) {\n this.resolvedCommand = found.command;\n return { ok: true, version: found.version };\n }\n return {\n ok: false,\n error: 'Cursor Agent CLI not found. The headless agent CLI is required (cursor-agent or agent).',\n };\n }\n\n execute(params: ExecuteParams): ExecuteHandle {\n const args = [\n '-p',\n '--output-format', 'stream-json',\n '--workspace', params.workspace,\n '--yolo', // bypass interactive prompts for autonomous agents\n ];\n\n if (params.config.model) {\n args.push('--model', params.config.model);\n }\n\n const { process: proc, pid } = this.processManager.spawn(this.resolvedCommand, args, {\n cwd: params.workspace,\n env: { ...process.env, ...params.env },\n signal: params.signal,\n stdio: ['pipe', 'pipe', 'pipe'], // stdin must be 'pipe' to send prompt\n });\n\n // Pipe prompt via stdin\n if (proc.stdin) {\n proc.stdin.write(params.prompt);\n proc.stdin.end();\n }\n\n const events = createStreamingEvents(proc, parseCursorEvent, 'Cursor agent', params.signal);\n\n return { pid, events };\n }\n\n async stop(pid: number): Promise<void> {\n await this.processManager.killWithGrace(pid);\n }\n}\n\nfunction parseCursorEvent(line: string): AgentEvent | null {\n if (!line.trim()) return null;\n\n try {\n const parsed: Record<string, unknown> = JSON.parse(line);\n const timestamp = new Date().toISOString();\n\n // Cursor stream-json uses the same format as Claude stream-json\n switch (parsed.type) {\n case 'assistant':\n return { type: 'output', timestamp, data: (parsed.message as unknown) ?? parsed };\n case 'tool_use':\n return { type: 'tool_call', timestamp, data: parsed };\n case 'tool_result':\n return { type: 'output', timestamp, data: parsed };\n case 'error':\n return { type: 'error', timestamp, data: (parsed.error as unknown) ?? parsed };\n case 'result': {\n const tokens = extractTokens(parsed);\n return { type: 'done', timestamp, data: parsed, tokens };\n }\n default:\n return { type: 'output', timestamp, data: parsed };\n }\n } catch {\n return { type: 'output', timestamp: new Date().toISOString(), data: line };\n }\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {a as a$4}from'./chunk-HMMPM7MF.js';import {p,c,q}from'./chunk-L26TK7Y5.js';import {a as a$1}from'./chunk-CDFA4IIQ.js';import {a as a$2}from'./chunk-MNXU3KCD.js';import'./chunk-L3FYR45M.js';import {a as a$3}from'./chunk-UW6GUUE6.js';import {a}from'./chunk-6MJ7V6VY.js';import {l}from'./chunk-ZA5Z33GO.js';import'./chunk-GZ2Q56YZ.js';import i from'chalk';function P(u,t){u.command("doctor").description("Check adapters and dependencies").action(async()=>{let c$1,n,d=false;if(t)c$1=t.doctorService,n=t.paths,d=true;else {let o=new a,e=new a$1;e.register(new a$2(o)),e.register(new a$3(o)),c$1=new a$4(e,o,process.cwd()),n=new l(process.cwd());}console.log(),console.log(` ${p("orch doctor")} \xB7 checking adapters and dependencies`),console.log();let a$5=await c$1.runAll();if(t?.context.json){console.log(JSON.stringify(a$5,null,2));return}for(let o of a$5.checks){let e=o.status==="ok"?i.ansi256(72)(c("done")):o.status==="fail"?i.ansi256(167)(c("failed")):q("\u2014"),l=o.detail?q(` ${o.detail}`):"";console.log(` ${e} ${o.name.padEnd(12)}${l}`);}if(n){let o=await n.isInitialized();if(o&&d){let e=await t.agentService.list(),l=await t.taskService.list();console.log(),console.log(` ${i.ansi256(72)(c("done"))} .orchestry/ ${q(`exists \xB7 ${e.length} agents \xB7 ${l.length} tasks`)}`);}else o||(console.log(),console.log(` ${i.ansi256(167)(c("failed"))} .orchestry/ ${q("not found \u2014 run: orch init")}`));}console.log(),console.log(` ${a$5.adaptersReady} of ${a$5.adaptersTotal} adapters ready`),console.log();});}export{P as registerDoctorCommand};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
1
|
import { execFile } from 'child_process';
|
|
3
2
|
import { promisify } from 'util';
|
|
4
3
|
import fs from 'fs/promises';
|
|
5
4
|
import path from 'path';
|
|
6
5
|
|
|
6
|
+
// src/application/doctor-service.ts
|
|
7
7
|
var execFileAsync = promisify(execFile);
|
|
8
8
|
var DoctorService = class {
|
|
9
9
|
constructor(adapterRegistry, processManager, projectRoot) {
|
|
@@ -87,3 +87,5 @@ var DoctorService = class {
|
|
|
87
87
|
};
|
|
88
88
|
|
|
89
89
|
export { DoctorService };
|
|
90
|
+
//# sourceMappingURL=doctor-service-F2SXDWHS.js.map
|
|
91
|
+
//# sourceMappingURL=doctor-service-F2SXDWHS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/application/doctor-service.ts"],"names":[],"mappings":";;;;;;AAaA,IAAM,aAAA,GAAgB,UAAU,QAAQ,CAAA;AAcjC,IAAM,gBAAN,MAAoB;AAAA,EAGzB,WAAA,CACmB,eAAA,EACA,cAAA,EACjB,WAAA,EACA;AAHiB,IAAA,IAAA,CAAA,eA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,MAAA,EAAQ;AAAA,OACV;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAc,YAAA,GAAqC;AACjD,IAAA,IAAI;AACF,MAAA,MAAM,aAAA,CAAc,KAAA,EAAO,CAAC,WAAA,EAAa,uBAAuB,GAAG,EAAE,GAAA,EAAK,IAAA,CAAK,GAAA,EAAK,CAAA;AACpF,MAAA,OAAO,EAAE,IAAA,EAAM,UAAA,EAAY,MAAA,EAAQ,IAAA,EAAM,QAAQ,yBAAA,EAA0B;AAAA,IAC7E,CAAA,CAAA,MAAQ;AACN,MAAA,OAAO;AAAA,QACL,IAAA,EAAM,UAAA;AAAA,QACN,MAAA,EAAQ,MAAA;AAAA,QACR,MAAA,EAAQ;AAAA,OACV;AAAA,IACF;AAAA,EACF;AACF","file":"doctor-service-F2SXDWHS.js","sourcesContent":["/**\n * Doctor service — diagnostics and health checks.\n *\n * Checks adapter availability, system dependencies, project state.\n */\n\nimport type { AdapterRegistry } from '../infrastructure/adapters/registry.js';\nimport type { IProcessManager } from '../infrastructure/process/process-manager.js';\nimport { execFile } from 'node:child_process';\nimport { promisify } from 'node:util';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\n\nconst execFileAsync = promisify(execFile);\n\nexport interface DoctorCheck {\n name: string;\n status: 'ok' | 'fail' | 'skip';\n detail?: string;\n}\n\nexport interface DoctorReport {\n checks: DoctorCheck[];\n adaptersReady: number;\n adaptersTotal: number;\n}\n\nexport class DoctorService {\n private readonly cwd: string;\n\n constructor(\n private readonly adapterRegistry: AdapterRegistry,\n private readonly processManager: IProcessManager,\n projectRoot?: string,\n ) {\n this.cwd = projectRoot ?? process.cwd();\n }\n\n async runAll(): Promise<DoctorReport> {\n const checks: DoctorCheck[] = [];\n\n // Check adapters\n const adapters = this.adapterRegistry.list();\n let adaptersReady = 0;\n\n for (const adapter of adapters) {\n const result = await adapter.test();\n if (result.ok) {\n adaptersReady++;\n checks.push({\n name: adapter.kind,\n status: 'ok',\n detail: result.version,\n });\n } else {\n checks.push({\n name: adapter.kind,\n status: 'fail',\n detail: result.error,\n });\n }\n }\n\n // Check git\n checks.push(await this.checkCommand('git', ['--version'], 'git'));\n\n // Check git repository (required for worktree/isolated workspace modes)\n checks.push(await this.checkGitRepo());\n\n // Check .orchestry in root .gitignore (prevents recursive worktrees)\n checks.push(await this.checkGitignore());\n\n // Check node\n checks.push(await this.checkCommand('node', ['--version'], 'node'));\n\n return {\n checks,\n adaptersReady,\n adaptersTotal: adapters.length,\n };\n }\n\n private async checkCommand(\n command: string,\n args: string[],\n name: string,\n ): Promise<DoctorCheck> {\n try {\n const { stdout } = await execFileAsync(command, args);\n return { name, status: 'ok', detail: stdout.trim() };\n } catch {\n return { name, status: 'fail', detail: `${command}: command not found` };\n }\n }\n\n private async checkGitignore(): Promise<DoctorCheck> {\n const gitignorePath = path.join(this.cwd, '.gitignore');\n try {\n const content = await fs.readFile(gitignorePath, 'utf-8');\n const hasEntry = content.split('\\n').some((line) => line.trim() === '.orchestry');\n if (hasEntry) {\n return { name: '.gitignore', status: 'ok', detail: '.orchestry is excluded' };\n }\n return {\n name: '.gitignore',\n status: 'fail',\n detail: '.orchestry not in .gitignore — worktrees will copy state recursively. Run: orch init',\n };\n } catch {\n return {\n name: '.gitignore',\n status: 'fail',\n detail: 'no .gitignore found — .orchestry may be committed to git. Run: orch init',\n };\n }\n }\n\n private async checkGitRepo(): Promise<DoctorCheck> {\n try {\n await execFileAsync('git', ['rev-parse', '--is-inside-work-tree'], { cwd: this.cwd });\n return { name: 'git repo', status: 'ok', detail: 'git repository detected' };\n } catch {\n return {\n name: 'git repo',\n status: 'fail',\n detail: 'not a git repository — worktree/isolated modes will fail. Run: git init',\n };\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {a}from'./chunk-HXOMNULD.js';import {j,q,l,m,d,o,i}from'./chunk-L26TK7Y5.js';var y={active:"\u25CF",paused:"\u2016",achieved:"\u2713",abandoned:"\u2715"};function v(S,t){let n=S.command("goal").description("Manage goals");n.command("add <title>").description("Create a new goal").option("--description <desc>","Goal description").option("--assignee <agentId>","Assign to a specific agent").action(async(i,e)=>{await t.paths.requireInit();let s=await t.goalService.create({title:i,description:e.description,assignee:e.assignee});t.context.json?console.log(JSON.stringify(s,null,2)):t.context.quiet?console.log(s.id):j(`Created goal "${s.title}" (${s.id})`);}),n.command("list").alias("ls").description("List all goals").option("--status <status>","Filter by status").action(async i=>{await t.paths.requireInit();let e=await t.goalService.list(i.status?{status:i.status}:void 0);if(t.context.json){console.log(JSON.stringify(e,null,2));return}if(e.length===0){console.log(q("No goals found."));return}let s=e.map(o=>[y[o.status]??"?",o.id,o.title,o.status,o.assignee??q("any")]);l(["","ID","Title","Status","Assignee"],s);}),n.command("show <id>").description("Show goal details").action(async i=>{await t.paths.requireInit();let[e,s,o$1]=await Promise.all([t.goalService.get(i),t.goalService.listTasksForGoal(i),t.goalService.getProgressReport(i)]);if(t.context.json){console.log(JSON.stringify({...e,tasks:s,progress:o$1},null,2));return}if(m([["ID",e.id],["Title",e.title],["Status",e.status],["Assignee",e.assignee??q("any")],["Description",e.description||q("none")],["Created",e.created_at],["Updated",e.updated_at??q("never")]]),s.length>0){console.log(`
|
|
3
|
+
Tasks (${s.length})
|
|
4
|
+
${"\u2500".repeat(42)}`);let r=s.map(l=>[`${d(l.status)} ${l.status}`,l.id,l.title.slice(0,40),l.assignee?o(l.assignee):q("\u2014")]);l(["STATUS","ID","TITLE","AGENT"],r);}else console.log(`
|
|
5
|
+
${q("No tasks linked to this goal yet.")}`);if(o$1){console.log(`
|
|
6
|
+
Progress Report
|
|
7
|
+
${"\u2500".repeat(42)}`);for(let r of o$1.split(`
|
|
8
|
+
`))console.log(` ${r}`);}console.log();}),n.command("status <id> <status>").description("Change goal status (active, paused, achieved, abandoned)").action(async(i$1,e)=>{if(await t.paths.requireInit(),!a.includes(e)){i(`Invalid status "${e}". Valid: ${a.join(", ")}`),process.exitCode=1;return}let s=await t.goalService.updateStatus(i$1,e);t.context.json?console.log(JSON.stringify(s,null,2)):t.context.quiet?console.log(s.id):j(`Goal "${s.title}" \u2192 ${s.status}`);}),n.command("update <id>").description("Update goal fields").option("--title <title>","New title").option("--description <desc>","New description").option("--assignee <agentId>","New assignee (empty string to unassign)").action(async(i,e)=>{await t.paths.requireInit();let s=await t.goalService.update(i,e);t.context.json?console.log(JSON.stringify(s,null,2)):t.context.quiet?console.log(s.id):j(`Updated goal "${s.title}"`);}),n.command("delete <id>").alias("rm").description("Delete a goal").action(async i=>{await t.paths.requireInit(),await t.goalService.delete(i),t.context.json?console.log(JSON.stringify({deleted:i})):t.context.quiet||j(`Deleted goal ${i}`);});}export{v as registerGoalCommand};
|
package/dist/index.d.ts
CHANGED
|
@@ -41,6 +41,8 @@ interface Task {
|
|
|
41
41
|
review_results?: ReviewResult[];
|
|
42
42
|
scope?: string[];
|
|
43
43
|
feedback?: string;
|
|
44
|
+
goalId?: string;
|
|
45
|
+
attachments?: string[];
|
|
44
46
|
}
|
|
45
47
|
interface CreateTaskInput {
|
|
46
48
|
title: string;
|
|
@@ -53,6 +55,8 @@ interface CreateTaskInput {
|
|
|
53
55
|
workspace_mode?: WorkspaceMode;
|
|
54
56
|
review_criteria?: ReviewCriterion[];
|
|
55
57
|
scope?: string[];
|
|
58
|
+
goalId?: string;
|
|
59
|
+
attachments?: string[];
|
|
56
60
|
}
|
|
57
61
|
|
|
58
62
|
/**
|
|
@@ -209,7 +213,7 @@ interface OrchestratorState {
|
|
|
209
213
|
pid?: number;
|
|
210
214
|
started_at?: string;
|
|
211
215
|
running: Record<string, RunningEntry>;
|
|
212
|
-
claimed: string
|
|
216
|
+
claimed: Set<string>;
|
|
213
217
|
retry_queue: RetryEntry[];
|
|
214
218
|
stats: {
|
|
215
219
|
total_runs: number;
|
|
@@ -499,8 +503,9 @@ declare function isTerminal(status: TaskStatus): boolean;
|
|
|
499
503
|
declare function isDispatchable(status: TaskStatus): boolean;
|
|
500
504
|
/**
|
|
501
505
|
* Check if a task is blocked by unfinished dependencies.
|
|
506
|
+
* Accepts either a Task[] (O(d×n) lookup) or a Map<string, Task> (O(d×1) lookup).
|
|
502
507
|
*/
|
|
503
|
-
declare function isBlocked(task: Task, allTasks: Task[]): boolean;
|
|
508
|
+
declare function isBlocked(task: Task, allTasks: Task[] | Map<string, Task>): boolean;
|
|
504
509
|
/**
|
|
505
510
|
* Determine the next status after a task failure (run error or shutdown).
|
|
506
511
|
* Returns 'retrying' if attempts remain, 'failed' otherwise.
|
|
@@ -607,6 +612,7 @@ interface CreateTeamInput {
|
|
|
607
612
|
interface ITaskStore {
|
|
608
613
|
list(filter?: {
|
|
609
614
|
status?: TaskStatus;
|
|
615
|
+
goalId?: string;
|
|
610
616
|
}): Promise<Task[]>;
|
|
611
617
|
get(id: string): Promise<Task | null>;
|
|
612
618
|
save(task: Task): Promise<void>;
|
|
@@ -680,6 +686,46 @@ interface ITeamStore {
|
|
|
680
686
|
delete(id: string): Promise<void>;
|
|
681
687
|
}
|
|
682
688
|
|
|
689
|
+
/**
|
|
690
|
+
* Path resolution for .orchestry/ directory.
|
|
691
|
+
*
|
|
692
|
+
* All path construction goes through this module.
|
|
693
|
+
* Validates initialization state and sanitizes identifiers.
|
|
694
|
+
*/
|
|
695
|
+
declare class Paths {
|
|
696
|
+
private readonly projectRoot;
|
|
697
|
+
constructor(projectRoot: string);
|
|
698
|
+
/** Root .orchestry/ directory */
|
|
699
|
+
get root(): string;
|
|
700
|
+
get configPath(): string;
|
|
701
|
+
get statePath(): string;
|
|
702
|
+
get lockPath(): string;
|
|
703
|
+
get tasksDir(): string;
|
|
704
|
+
get agentsDir(): string;
|
|
705
|
+
get runsDir(): string;
|
|
706
|
+
get templatesDir(): string;
|
|
707
|
+
get logsDir(): string;
|
|
708
|
+
get contextDir(): string;
|
|
709
|
+
contextPath(key: string): string;
|
|
710
|
+
get messagesDir(): string;
|
|
711
|
+
messagePath(id: string): string;
|
|
712
|
+
get goalsDir(): string;
|
|
713
|
+
goalPath(id: string): string;
|
|
714
|
+
get teamsDir(): string;
|
|
715
|
+
get attachmentsDir(): string;
|
|
716
|
+
taskAttachmentsDir(taskId: string): string;
|
|
717
|
+
teamPath(id: string): string;
|
|
718
|
+
get gitignorePath(): string;
|
|
719
|
+
get workspaceExcludePath(): string;
|
|
720
|
+
taskPath(id: string): string;
|
|
721
|
+
agentPath(id: string): string;
|
|
722
|
+
runPath(id: string): string;
|
|
723
|
+
runEventsPath(id: string): string;
|
|
724
|
+
defaultTemplatePath(): string;
|
|
725
|
+
isInitialized(): Promise<boolean>;
|
|
726
|
+
requireInit(): Promise<void>;
|
|
727
|
+
}
|
|
728
|
+
|
|
683
729
|
/**
|
|
684
730
|
* Task service — business logic for task lifecycle.
|
|
685
731
|
*
|
|
@@ -691,10 +737,12 @@ declare class TaskService {
|
|
|
691
737
|
private readonly taskStore;
|
|
692
738
|
private readonly eventBus;
|
|
693
739
|
private readonly config;
|
|
694
|
-
|
|
740
|
+
private readonly paths?;
|
|
741
|
+
constructor(taskStore: ITaskStore, eventBus: EventBus, config: OrchestratorConfig, paths?: Paths | undefined);
|
|
695
742
|
create(input: CreateTaskInput): Promise<Task>;
|
|
696
743
|
list(filter?: {
|
|
697
744
|
status?: TaskStatus;
|
|
745
|
+
goalId?: string;
|
|
698
746
|
}): Promise<Task[]>;
|
|
699
747
|
get(id: string): Promise<Task>;
|
|
700
748
|
updateStatus(id: string, newStatus: TaskStatus): Promise<Task>;
|
|
@@ -707,8 +755,11 @@ declare class TaskService {
|
|
|
707
755
|
description?: string;
|
|
708
756
|
priority?: number;
|
|
709
757
|
labels?: string[];
|
|
758
|
+
attachments?: string[];
|
|
710
759
|
}): Promise<Task>;
|
|
711
760
|
delete(id: string): Promise<void>;
|
|
761
|
+
getAttachmentPath(taskId: string, filename: string): string;
|
|
762
|
+
private copyAttachments;
|
|
712
763
|
incrementAttempts(id: string): Promise<Task>;
|
|
713
764
|
}
|
|
714
765
|
|
|
@@ -932,6 +983,14 @@ interface RetryContext {
|
|
|
932
983
|
previous_error: string;
|
|
933
984
|
previous_output: string;
|
|
934
985
|
}
|
|
986
|
+
interface GoalContext {
|
|
987
|
+
id: string;
|
|
988
|
+
title: string;
|
|
989
|
+
description: string;
|
|
990
|
+
status: GoalStatus;
|
|
991
|
+
task_names: string[];
|
|
992
|
+
progress?: string;
|
|
993
|
+
}
|
|
935
994
|
interface PromptContext {
|
|
936
995
|
project: {
|
|
937
996
|
name: string;
|
|
@@ -945,6 +1004,7 @@ interface PromptContext {
|
|
|
945
1004
|
labels: string[];
|
|
946
1005
|
scope?: string[];
|
|
947
1006
|
is_autonomous: boolean;
|
|
1007
|
+
goal_id?: string;
|
|
948
1008
|
};
|
|
949
1009
|
agent: {
|
|
950
1010
|
id: string;
|
|
@@ -965,6 +1025,7 @@ interface PromptContext {
|
|
|
965
1025
|
sent_at: string;
|
|
966
1026
|
reply_to?: string;
|
|
967
1027
|
}>;
|
|
1028
|
+
goal?: GoalContext;
|
|
968
1029
|
}
|
|
969
1030
|
|
|
970
1031
|
interface OrchestratorDeps {
|
|
@@ -1140,6 +1201,42 @@ declare class Orchestrator {
|
|
|
1140
1201
|
private flushStateLazy;
|
|
1141
1202
|
}
|
|
1142
1203
|
|
|
1204
|
+
/**
|
|
1205
|
+
* Clipboard service for detecting and extracting images from the system clipboard.
|
|
1206
|
+
*
|
|
1207
|
+
* Platform support:
|
|
1208
|
+
* - macOS: osascript (clipboard info / clipboard as PNGf)
|
|
1209
|
+
* - Linux: xclip -selection clipboard
|
|
1210
|
+
* - Windows: PowerShell Get-Clipboard
|
|
1211
|
+
*/
|
|
1212
|
+
type ClipboardContentType = 'image' | 'text' | 'empty';
|
|
1213
|
+
interface ClipboardImage {
|
|
1214
|
+
data: Buffer;
|
|
1215
|
+
ext: string;
|
|
1216
|
+
}
|
|
1217
|
+
/**
|
|
1218
|
+
* Checks whether the required clipboard tool is available on this platform.
|
|
1219
|
+
*
|
|
1220
|
+
* - macOS: pbpaste (always present)
|
|
1221
|
+
* - Linux: xclip
|
|
1222
|
+
* - Windows: PowerShell (always present)
|
|
1223
|
+
*/
|
|
1224
|
+
declare function isClipboardToolAvailable(): boolean;
|
|
1225
|
+
/**
|
|
1226
|
+
* Detects the type of content currently in the system clipboard.
|
|
1227
|
+
*
|
|
1228
|
+
* Returns 'image' if the clipboard contains an image (PNG or TIFF),
|
|
1229
|
+
* 'text' if it contains text, or 'empty' if the clipboard is empty.
|
|
1230
|
+
*/
|
|
1231
|
+
declare function detectClipboardType(): Promise<ClipboardContentType>;
|
|
1232
|
+
/**
|
|
1233
|
+
* Extracts an image from the system clipboard.
|
|
1234
|
+
*
|
|
1235
|
+
* Returns the image data as a Buffer with its file extension,
|
|
1236
|
+
* or null if the clipboard does not contain an image.
|
|
1237
|
+
*/
|
|
1238
|
+
declare function getClipboardImage(): Promise<ClipboardImage | null>;
|
|
1239
|
+
|
|
1143
1240
|
/**
|
|
1144
1241
|
* CLI context — resolved project root and global flags.
|
|
1145
1242
|
*
|
|
@@ -1167,44 +1264,6 @@ interface GlobalConfig {
|
|
|
1167
1264
|
tui: TuiPreferences;
|
|
1168
1265
|
}
|
|
1169
1266
|
|
|
1170
|
-
/**
|
|
1171
|
-
* Path resolution for .orchestry/ directory.
|
|
1172
|
-
*
|
|
1173
|
-
* All path construction goes through this module.
|
|
1174
|
-
* Validates initialization state and sanitizes identifiers.
|
|
1175
|
-
*/
|
|
1176
|
-
declare class Paths {
|
|
1177
|
-
private readonly projectRoot;
|
|
1178
|
-
constructor(projectRoot: string);
|
|
1179
|
-
/** Root .orchestry/ directory */
|
|
1180
|
-
get root(): string;
|
|
1181
|
-
get configPath(): string;
|
|
1182
|
-
get statePath(): string;
|
|
1183
|
-
get lockPath(): string;
|
|
1184
|
-
get tasksDir(): string;
|
|
1185
|
-
get agentsDir(): string;
|
|
1186
|
-
get runsDir(): string;
|
|
1187
|
-
get templatesDir(): string;
|
|
1188
|
-
get logsDir(): string;
|
|
1189
|
-
get contextDir(): string;
|
|
1190
|
-
contextPath(key: string): string;
|
|
1191
|
-
get messagesDir(): string;
|
|
1192
|
-
messagePath(id: string): string;
|
|
1193
|
-
get goalsDir(): string;
|
|
1194
|
-
goalPath(id: string): string;
|
|
1195
|
-
get teamsDir(): string;
|
|
1196
|
-
teamPath(id: string): string;
|
|
1197
|
-
get gitignorePath(): string;
|
|
1198
|
-
get workspaceExcludePath(): string;
|
|
1199
|
-
taskPath(id: string): string;
|
|
1200
|
-
agentPath(id: string): string;
|
|
1201
|
-
runPath(id: string): string;
|
|
1202
|
-
runEventsPath(id: string): string;
|
|
1203
|
-
defaultTemplatePath(): string;
|
|
1204
|
-
isInitialized(): Promise<boolean>;
|
|
1205
|
-
requireInit(): Promise<void>;
|
|
1206
|
-
}
|
|
1207
|
-
|
|
1208
1267
|
/**
|
|
1209
1268
|
* Global config store — reads/writes ~/.orchestry/global.yml
|
|
1210
1269
|
*
|
|
@@ -1233,7 +1292,8 @@ declare class GoalService {
|
|
|
1233
1292
|
private readonly eventBus;
|
|
1234
1293
|
private readonly agentService?;
|
|
1235
1294
|
private readonly taskService?;
|
|
1236
|
-
|
|
1295
|
+
private readonly contextStore?;
|
|
1296
|
+
constructor(goalStore: IGoalStore, eventBus: EventBus, agentService?: AgentService | undefined, taskService?: TaskService | undefined, contextStore?: IContextStore | undefined);
|
|
1237
1297
|
create(input: CreateGoalInput): Promise<Goal>;
|
|
1238
1298
|
list(filter?: {
|
|
1239
1299
|
status?: GoalStatus;
|
|
@@ -1246,6 +1306,8 @@ declare class GoalService {
|
|
|
1246
1306
|
assignee?: string;
|
|
1247
1307
|
}): Promise<Goal>;
|
|
1248
1308
|
delete(id: string): Promise<void>;
|
|
1309
|
+
listTasksForGoal(goalId: string): Promise<Task[]>;
|
|
1310
|
+
getProgressReport(goalId: string): Promise<string | undefined>;
|
|
1249
1311
|
/** Enable autonomous mode on an agent. */
|
|
1250
1312
|
private enableAutonomous;
|
|
1251
1313
|
/** Check if an agent has at least one active goal. */
|
|
@@ -1369,4 +1431,4 @@ declare function buildFullContainer(context: CliContext): Promise<Container>;
|
|
|
1369
1431
|
*/
|
|
1370
1432
|
declare function buildContainer(context: CliContext): Promise<Container>;
|
|
1371
1433
|
|
|
1372
|
-
export { AdapterRegistry, type AdapterTestResult, type Agent, type AgentConfig, type AgentEvent, AgentNotFoundError, AgentService, type AgentStats, type AgentStatus, type ApprovalPolicy, type Container, type CreateAgentInput, type CreateTaskInput, EventBus, type EventPayload, type ExecuteParams, type IAgentAdapter, type LightContainer, NotInitializedError, Orchestrator, type OrchestratorConfig, type OrchestratorEvent, type OrchestratorEventType, type OrchestratorState, OrchestryError, type ProjectConfig, type RetryEntry, type Run, type RunEvent, type RunEventType, RunService, type RunStatus, type RunningEntry, type SchedulingConfig, type Task, TaskNotFoundError, type TaskProof, TaskService, type TaskStatus, type TokenUsage, WorkspaceError, type WorkspaceMode, buildContainer, buildFullContainer, buildLightContainer, canTransition, createTokenUsage, isBlocked, isDispatchable, isTerminal, resolveFailureStatus };
|
|
1434
|
+
export { AdapterRegistry, type AdapterTestResult, type Agent, type AgentConfig, type AgentEvent, AgentNotFoundError, AgentService, type AgentStats, type AgentStatus, type ApprovalPolicy, type ClipboardContentType, type ClipboardImage, type Container, type CreateAgentInput, type CreateTaskInput, EventBus, type EventPayload, type ExecuteParams, type IAgentAdapter, type LightContainer, NotInitializedError, Orchestrator, type OrchestratorConfig, type OrchestratorEvent, type OrchestratorEventType, type OrchestratorState, OrchestryError, type ProjectConfig, type RetryEntry, type Run, type RunEvent, type RunEventType, RunService, type RunStatus, type RunningEntry, type SchedulingConfig, type Task, TaskNotFoundError, type TaskProof, TaskService, type TaskStatus, type TokenUsage, WorkspaceError, type WorkspaceMode, buildContainer, buildFullContainer, buildLightContainer, canTransition, createTokenUsage, detectClipboardType, getClipboardImage, isBlocked, isClipboardToolAvailable, isDispatchable, isTerminal, resolveFailureStatus };
|