agentix-cli 0.158.0 → 0.159.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-AFRBV666.js → App-LFKP4IY5.js} +2 -2
- package/dist/{ChatApp-EBTSY27Z.js → ChatApp-SSVWKETD.js} +2 -2
- package/dist/{absorb-eval-OCR3G5TE.js → absorb-eval-IPPP2RZV.js} +2 -2
- package/dist/{agent-QZ4QTZKW.js → agent-SNNE24LT.js} +2 -2
- package/dist/{board-dashboard-QJ2CWJKI.js → board-dashboard-YW6WOQAB.js} +414 -328
- package/dist/board-dashboard-YW6WOQAB.js.map +1 -0
- package/dist/{chunk-E4O32ZYZ.js → chunk-2J7LN4SR.js} +2 -2
- package/dist/{chunk-MKLRCNOX.js → chunk-2OY7P3HS.js} +241 -242
- package/dist/chunk-2OY7P3HS.js.map +1 -0
- package/dist/{chunk-2NLPGLLL.js → chunk-5IXE5AXR.js} +2 -2
- package/dist/{chunk-OYPKAYCH.js → chunk-7C67DNT6.js} +2 -2
- package/dist/{chunk-PVWHEPF3.js → chunk-A43C7UUG.js} +2 -2
- package/dist/{chunk-O5H6BCUN.js → chunk-A7AVIFNF.js} +37 -28
- package/dist/chunk-A7AVIFNF.js.map +1 -0
- package/dist/{chunk-BY2AAMOO.js → chunk-CDLRTTHR.js} +2 -2
- package/dist/{chunk-FEF432WU.js → chunk-ECY6WMZP.js} +2 -2
- package/dist/{chunk-LSDUL7EW.js → chunk-EHUKKZ5H.js} +5 -5
- package/dist/{chunk-GVMV3TWS.js → chunk-HWOBHAZD.js} +2 -2
- package/dist/{chunk-B3I4EBLE.js → chunk-IERW7MLU.js} +2 -2
- package/dist/{chunk-EWBUH2IU.js → chunk-KCT6Y2AG.js} +2 -2
- package/dist/{chunk-FM6RZI52.js → chunk-KKTHRSSJ.js} +2 -2
- package/dist/{chunk-ZSVCHDYT.js → chunk-KPYWYMRY.js} +2 -2
- package/dist/{chunk-NY5ZY2WV.js → chunk-KXK2OKT5.js} +2 -2
- package/dist/{chunk-TRGNLW43.js → chunk-LSC64WL3.js} +2 -2
- package/dist/{chunk-MBPYC6QF.js → chunk-M6YFSYJC.js} +2 -2
- package/dist/{chunk-4UMMAI3Z.js → chunk-MBCXPY6T.js} +2 -2
- package/dist/{chunk-KPNAXVET.js → chunk-ODAZQH7N.js} +2 -2
- package/dist/{chunk-PA3KFAXH.js → chunk-P76PFVMJ.js} +2 -2
- package/dist/chunk-QH7R4IQS.js +36 -0
- package/dist/{chunk-QH3RKKD3.js.map → chunk-QH7R4IQS.js.map} +1 -1
- package/dist/chunk-QPABR72X.js +2 -0
- package/dist/chunk-QPABR72X.js.map +1 -0
- package/dist/{chunk-VHHKS7S4.js → chunk-S5CNKZBP.js} +2 -2
- package/dist/{chunk-3ZMVYNFH.js → chunk-T2GBLNW7.js} +2 -2
- package/dist/{chunk-SRUIUZOC.js → chunk-UIVNNH6T.js} +59 -58
- package/dist/chunk-UIVNNH6T.js.map +1 -0
- package/dist/{chunk-DNPL3YOH.js → chunk-XMU63PSI.js} +3 -3
- package/dist/{chunk-5XPXYOWB.js → chunk-XWQ3ZEIZ.js} +2 -2
- package/dist/{chunk-JJV7O7YK.js → chunk-Z5RMH5SV.js} +2 -2
- package/dist/cli.js +1 -1
- package/dist/{client-7ZJZT5H7.js → client-GVAZIQQW.js} +2 -2
- package/dist/{config-NFDEJ3NB.js → config-IWC47ZIT.js} +2 -2
- package/dist/{config-mutate-JYW5G7T6.js → config-mutate-W7KUQC72.js} +2 -2
- package/dist/config-mutator-ZVDBAYHA.js +2 -0
- package/dist/{contributions-ECGVSETO.js → contributions-HEPV2YXR.js} +2 -2
- package/dist/doctor-HOTKJEW5.js +2 -0
- package/dist/{follow-up-tool-FNO2IG72.js → follow-up-tool-R2U755ZJ.js} +2 -2
- package/dist/{hub-MOAG5BEQ.js → hub-5LSCXPYT.js} +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/{program-7UMVHRD3.js → program-7QU75QNS.js} +207 -206
- package/dist/program-7QU75QNS.js.map +1 -0
- package/dist/{promote-AAEZYPBP.js → promote-QLBR6G6E.js} +2 -2
- package/dist/{query-WWZEARB4.js → query-L4TULDGS.js} +2 -2
- package/dist/{query-settings-3FE555NP.js → query-settings-RH2E6JM2.js} +2 -2
- package/dist/{registry-JPZLE5XX.js → registry-HNCVWFDT.js} +2 -2
- package/dist/{request-planner-2AU3VK4P.js → request-planner-SH5CLEZZ.js} +2 -2
- package/dist/{review-candidates-CIEGXF7K.js → review-candidates-V7WCKVVJ.js} +2 -2
- package/dist/{routing-XJ25QONX.js → routing-KCZ6AY66.js} +2 -2
- package/dist/schedule-tool-PYG4K4RY.js +2 -0
- package/dist/{scheduler-UKJWO2TR.js → scheduler-X56K6BXS.js} +2 -2
- package/dist/{seat-JWRCBUKR.js → seat-CHFR5HFA.js} +2 -2
- package/dist/{select-KIDX6WWF.js → select-FTQBN33Y.js} +2 -2
- package/dist/{set-enabled-F4D3VWKI.js → set-enabled-OCXL7V7L.js} +2 -2
- package/dist/tool-6WLBCL22.js +6 -0
- package/dist/tool-6WLBCL22.js.map +1 -0
- package/dist/{tool-YSS2C2UX.js → tool-ZFSGK53G.js} +2 -2
- package/dist/{wiki-5Y4GSCYL.js → wiki-6UDGACKC.js} +2 -2
- package/dist/wiki-enrich-6QKT6KCN.js +2 -0
- package/package.json +1 -1
- package/dist/board-dashboard-QJ2CWJKI.js.map +0 -1
- package/dist/chunk-MKLRCNOX.js.map +0 -1
- package/dist/chunk-O5H6BCUN.js.map +0 -1
- package/dist/chunk-QH3RKKD3.js +0 -36
- package/dist/chunk-SRUIUZOC.js.map +0 -1
- package/dist/config-mutator-OMWL5XHO.js +0 -2
- package/dist/doctor-D6OVZAFB.js +0 -2
- package/dist/program-7UMVHRD3.js.map +0 -1
- package/dist/schedule-tool-5T4CH4CM.js +0 -2
- package/dist/tool-7FFJSFTS.js +0 -6
- package/dist/tool-7FFJSFTS.js.map +0 -1
- package/dist/wiki-enrich-TJIL4B3V.js +0 -2
- /package/dist/{App-AFRBV666.js.map → App-LFKP4IY5.js.map} +0 -0
- /package/dist/{ChatApp-EBTSY27Z.js.map → ChatApp-SSVWKETD.js.map} +0 -0
- /package/dist/{absorb-eval-OCR3G5TE.js.map → absorb-eval-IPPP2RZV.js.map} +0 -0
- /package/dist/{agent-QZ4QTZKW.js.map → agent-SNNE24LT.js.map} +0 -0
- /package/dist/{chunk-E4O32ZYZ.js.map → chunk-2J7LN4SR.js.map} +0 -0
- /package/dist/{chunk-2NLPGLLL.js.map → chunk-5IXE5AXR.js.map} +0 -0
- /package/dist/{chunk-OYPKAYCH.js.map → chunk-7C67DNT6.js.map} +0 -0
- /package/dist/{chunk-PVWHEPF3.js.map → chunk-A43C7UUG.js.map} +0 -0
- /package/dist/{chunk-BY2AAMOO.js.map → chunk-CDLRTTHR.js.map} +0 -0
- /package/dist/{chunk-FEF432WU.js.map → chunk-ECY6WMZP.js.map} +0 -0
- /package/dist/{chunk-LSDUL7EW.js.map → chunk-EHUKKZ5H.js.map} +0 -0
- /package/dist/{chunk-GVMV3TWS.js.map → chunk-HWOBHAZD.js.map} +0 -0
- /package/dist/{chunk-B3I4EBLE.js.map → chunk-IERW7MLU.js.map} +0 -0
- /package/dist/{chunk-EWBUH2IU.js.map → chunk-KCT6Y2AG.js.map} +0 -0
- /package/dist/{chunk-FM6RZI52.js.map → chunk-KKTHRSSJ.js.map} +0 -0
- /package/dist/{chunk-ZSVCHDYT.js.map → chunk-KPYWYMRY.js.map} +0 -0
- /package/dist/{chunk-NY5ZY2WV.js.map → chunk-KXK2OKT5.js.map} +0 -0
- /package/dist/{chunk-TRGNLW43.js.map → chunk-LSC64WL3.js.map} +0 -0
- /package/dist/{chunk-MBPYC6QF.js.map → chunk-M6YFSYJC.js.map} +0 -0
- /package/dist/{chunk-4UMMAI3Z.js.map → chunk-MBCXPY6T.js.map} +0 -0
- /package/dist/{chunk-KPNAXVET.js.map → chunk-ODAZQH7N.js.map} +0 -0
- /package/dist/{chunk-PA3KFAXH.js.map → chunk-P76PFVMJ.js.map} +0 -0
- /package/dist/{chunk-VHHKS7S4.js.map → chunk-S5CNKZBP.js.map} +0 -0
- /package/dist/{chunk-3ZMVYNFH.js.map → chunk-T2GBLNW7.js.map} +0 -0
- /package/dist/{chunk-DNPL3YOH.js.map → chunk-XMU63PSI.js.map} +0 -0
- /package/dist/{chunk-5XPXYOWB.js.map → chunk-XWQ3ZEIZ.js.map} +0 -0
- /package/dist/{chunk-JJV7O7YK.js.map → chunk-Z5RMH5SV.js.map} +0 -0
- /package/dist/{client-7ZJZT5H7.js.map → client-GVAZIQQW.js.map} +0 -0
- /package/dist/{config-NFDEJ3NB.js.map → config-IWC47ZIT.js.map} +0 -0
- /package/dist/{config-mutate-JYW5G7T6.js.map → config-mutate-W7KUQC72.js.map} +0 -0
- /package/dist/{config-mutator-OMWL5XHO.js.map → config-mutator-ZVDBAYHA.js.map} +0 -0
- /package/dist/{contributions-ECGVSETO.js.map → contributions-HEPV2YXR.js.map} +0 -0
- /package/dist/{doctor-D6OVZAFB.js.map → doctor-HOTKJEW5.js.map} +0 -0
- /package/dist/{follow-up-tool-FNO2IG72.js.map → follow-up-tool-R2U755ZJ.js.map} +0 -0
- /package/dist/{hub-MOAG5BEQ.js.map → hub-5LSCXPYT.js.map} +0 -0
- /package/dist/{promote-AAEZYPBP.js.map → promote-QLBR6G6E.js.map} +0 -0
- /package/dist/{query-WWZEARB4.js.map → query-L4TULDGS.js.map} +0 -0
- /package/dist/{query-settings-3FE555NP.js.map → query-settings-RH2E6JM2.js.map} +0 -0
- /package/dist/{registry-JPZLE5XX.js.map → registry-HNCVWFDT.js.map} +0 -0
- /package/dist/{request-planner-2AU3VK4P.js.map → request-planner-SH5CLEZZ.js.map} +0 -0
- /package/dist/{review-candidates-CIEGXF7K.js.map → review-candidates-V7WCKVVJ.js.map} +0 -0
- /package/dist/{routing-XJ25QONX.js.map → routing-KCZ6AY66.js.map} +0 -0
- /package/dist/{schedule-tool-5T4CH4CM.js.map → schedule-tool-PYG4K4RY.js.map} +0 -0
- /package/dist/{scheduler-UKJWO2TR.js.map → scheduler-X56K6BXS.js.map} +0 -0
- /package/dist/{seat-JWRCBUKR.js.map → seat-CHFR5HFA.js.map} +0 -0
- /package/dist/{select-KIDX6WWF.js.map → select-FTQBN33Y.js.map} +0 -0
- /package/dist/{set-enabled-F4D3VWKI.js.map → set-enabled-OCXL7V7L.js.map} +0 -0
- /package/dist/{tool-YSS2C2UX.js.map → tool-ZFSGK53G.js.map} +0 -0
- /package/dist/{wiki-5Y4GSCYL.js.map → wiki-6UDGACKC.js.map} +0 -0
- /package/dist/{wiki-enrich-TJIL4B3V.js.map → wiki-enrich-6QKT6KCN.js.map} +0 -0
|
@@ -48,7 +48,7 @@ The "modified" field is optional and can contain updated values to pass forward.
|
|
|
48
48
|
... (output truncated)`:i;return s.exitCode!==0?{tool_use_id:e.id,content:`Command exited with code ${s.exitCode}:
|
|
49
49
|
${c}`,is_error:!0}:{tool_use_id:e.id,content:c||"(no output)"}}async editFile(e){let t=String(e.input.path||""),o=e.input.edits,n=ge.resolve(this.cwd,t);if(!o||o.length===0)return{tool_use_id:e.id,content:"No edits provided.",is_error:!0};let s=await W.checkFileWrite(t);if(s==="deny")return{tool_use_id:e.id,content:`File write blocked by permissions: ${t}`,is_error:!0};if(s==="skip")return{tool_use_id:e.id,content:`File write skipped (plan mode): ${t}`};if(f.has("pre:file-write")){let a=await f.execute("pre:file-write",{event:"pre:file-write",file:n,cwd:this.cwd});if(a.blocked)return{tool_use_id:e.id,content:a.message||`File edit blocked by pre:file-write hook: ${t}`,is_error:!0}}let i=await re.readFile(n,"utf8"),c=[];for(let a of o)i.includes(a.old_text)?(i=i.replace(a.old_text,a.new_text),c.push(`Replaced: "${a.old_text.slice(0,40)}..."`)):c.push(`Not found: "${a.old_text.slice(0,40)}..."`);return this.options.dryRun||await re.writeFile(n,i,"utf8"),f.has("post:file-write")&&await f.execute("post:file-write",{event:"post:file-write",file:n,fileContent:i,cwd:this.cwd}),{tool_use_id:e.id,content:`Edited ${t}:
|
|
50
50
|
${c.join(`
|
|
51
|
-
`)}`}}async createFiles(e){let t=e.input,o=t.files||[];return{tool_use_id:e.id,content:t.summary||`Queued ${o.length} file(s) for creation.`,files:o}}async spawnAgent(e){let t=String(e.input.agent_id||""),o=String(e.input.prompt||""),n=Number(e.input.timeout_seconds)||300;if(!t||!o)return{tool_use_id:e.id,content:"agent_id and prompt are required.",is_error:!0};try{let{SubAgentManager:s}=await import("./subagent-XY5N7TUU.js"),{getGlobalRegistry:i}=await import("./registry-
|
|
51
|
+
`)}`}}async createFiles(e){let t=e.input,o=t.files||[];return{tool_use_id:e.id,content:t.summary||`Queued ${o.length} file(s) for creation.`,files:o}}async spawnAgent(e){let t=String(e.input.agent_id||""),o=String(e.input.prompt||""),n=Number(e.input.timeout_seconds)||300;if(!t||!o)return{tool_use_id:e.id,content:"agent_id and prompt are required.",is_error:!0};try{let{SubAgentManager:s}=await import("./subagent-XY5N7TUU.js"),{getGlobalRegistry:i}=await import("./registry-HNCVWFDT.js"),c=i();if(!c)return{tool_use_id:e.id,content:"Sub-agent spawning requires the daemon to be running.",is_error:!0};let p=await new s(c).spawn({targetAgentId:t,prompt:o,parentAgentId:"orchestrator",timeout:n*1e3});return p.success?{tool_use_id:e.id,content:`Sub-agent "${t}" completed (${Math.round(p.duration/1e3)}s):
|
|
52
52
|
|
|
53
53
|
${p.content}`}:{tool_use_id:e.id,content:`Sub-agent "${t}" failed: ${p.error}`,is_error:!0}}catch(s){return{tool_use_id:e.id,content:`Failed to spawn sub-agent: ${s.message}`,is_error:!0}}}async askUser(e){let t=String(e.input.question||""),o=e.input.options,n=t;return o?.length&&(n+=`
|
|
54
54
|
Options: ${o.join(", ")}`),{tool_use_id:e.id,content:"Question sent to user.",followUp:n}}};async function Ae(r){let{provider:e,systemPrompt:t,messages:o,providerOptions:n,cwd:s,maxIterations:i=20,enabledTools:c,interactive:a=!0,overwrite:p=!1,dryRun:l=!1,onProgress:d,abortSignal:u}=r,m=u?{...n,abortSignal:u}:n;if(!e.generateRaw)return dt(r);let I=new se(s,{interactive:a,overwrite:p,dryRun:l,acmeContext:r.acmeContext,abortSignal:u}),D=be(c);if(r.acmeContext)for(let g of at)D.push({name:g.name,description:g.description,input_schema:g.input_schema});let E=new Set;if(r.mcpTools?.length)for(let g of r.mcpTools)D.push({name:g.name,description:g.description,input_schema:g.input_schema}),E.add(g.name);let C=o.filter(g=>g.role!=="system").map(g=>({role:g.role,content:g.content})),B=[],G=0,F=0,A=0,O="",j,_=0;for(;_<i;){if(_++,u?.aborted)throw new Error("cancelled");d?.({type:"iteration_start",iteration:_}),b.step(_,`Agentic loop iteration (${D.length} tools available)`);let g,M=!!e.generateRawStream&&!!d;try{if(M){let T=null,U=null,v="";for await(let x of e.generateRawStream(C,t,D,m))x.type==="text_delta"?(v+=x.text,d?.({type:"text_delta",text:x.text})):x.type==="thinking_delta"?d?.({type:"thinking_delta",text:x.text}):x.type==="raw_result"?T=x.result:x.type==="error"&&(U=x.error);if(U&&!T)throw new Error(U);if(!T)throw new Error("generateRawStream returned no raw_result event");g=T,g._streamedText=v}else g=await e.generateRaw(C,t,D,m)}catch(T){if(T.message?.includes("not available"))return dt(r);throw T}G+=g.usage.input_tokens+g.usage.output_tokens,F+=g.usage.input_tokens,A+=g.usage.output_tokens;let P=g._streamedText;for(let T of g.content)T.type==="text"&&(O+=T.text,P===void 0&&d?.({type:"text_delta",text:T.text}));if(P!==void 0&&delete g._streamedText,g.stop_reason==="end_turn"||g.stop_reason==="max_tokens")break;if(g.stop_reason==="tool_use"){let T=g.content.filter(v=>v.type==="tool_use");if(T.length===0)break;C.push({role:"assistant",content:g.content});let U=[];for(let v of T){d?.({type:"tool_call",name:v.name,id:v.id,input:v.input}),b.step(_,`Tool call: ${v.name}`);let x;if(E.has(v.name)&&r.mcpDispatch){let h=await r.mcpDispatch(v.name,v.input);x={tool_use_id:v.id,content:h.content,is_error:h.isError}}else x=await I.execute({name:v.name,id:v.id,input:v.input});d?.({type:"tool_result",name:v.name,id:v.id,content:x.content.slice(0,200),is_error:x.is_error}),x.files?.length&&(B.push(...x.files),d?.({type:"files_created",files:x.files})),x.followUp&&(j=x.followUp),U.push({type:"tool_result",tool_use_id:x.tool_use_id,content:x.content,is_error:x.is_error})}if(C.push({role:"user",content:U}),j)break;continue}break}return d?.({type:"complete",iterations:_,totalTokens:G}),{files:B,content:O,followUp:j,tokensUsed:G,inputTokens:F||void 0,outputTokens:A||void 0,iterations:_}}async function dt(r){let{provider:e,systemPrompt:t,messages:o,providerOptions:n,maxIterations:s=5}=r,c=[{role:"system",content:t+`
|
|
@@ -123,4 +123,4 @@ ${r.projectInstructions}`),r.memoryContext&&o.push(r.memoryContext),o.push(`# Ou
|
|
|
123
123
|
Generate output appropriate for: ${e}. Use the \`create_files\` tool to output all files.`),o.join(`
|
|
124
124
|
|
|
125
125
|
`)}export{qe as a,Vt as b,Yt as c,We as d,ze as e,Ve as f,Ye as g,Pe as h,ee as i,Re as j,le as k,te as l,Tt as m,oe as n,Mt as o,f as p,et as q,tt as r,Me as s,de as t,W as u,ne as v,it as w,Ee as x,$e as y,se as z,mt as A,Zn as B,er as C};
|
|
126
|
-
//# sourceMappingURL=chunk-
|
|
126
|
+
//# sourceMappingURL=chunk-KKTHRSSJ.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Be,b as k,c as z,d as je,e as pe,f as ue,g as M,h as ge,i as O,j as U,n as He,o as qe,p as Fe,q as Ge}from"./chunk-XVTD6I34.js";import{e as Ue,i as Le}from"./chunk-QAWKN2N4.js";import{b as ce}from"./chunk-MTX4UPNB.js";import{a as X,b as Oe}from"./chunk-
|
|
1
|
+
import{a as Be,b as k,c as z,d as je,e as pe,f as ue,g as M,h as ge,i as O,j as U,n as He,o as qe,p as Fe,q as Ge}from"./chunk-XVTD6I34.js";import{e as Ue,i as Le}from"./chunk-QAWKN2N4.js";import{b as ce}from"./chunk-MTX4UPNB.js";import{a as X,b as Oe}from"./chunk-P76PFVMJ.js";import{c as Me,d as le,e as P,f as de,g as q}from"./chunk-P5RTEJUB.js";import{ma as Ne}from"./chunk-UIVNNH6T.js";import{a as We}from"./chunk-JYSJDHNS.js";import{a as Re}from"./chunk-IMLAPB7G.js";import{c as Te,e as De}from"./chunk-LQE73AZR.js";import{b as ze}from"./chunk-MRIVENBY.js";import{n as se,p as _e}from"./chunk-LQS27HSV.js";import{b as Y}from"./chunk-2VDO2HEK.js";import{G as J}from"./chunk-A43C7UUG.js";import{a as H,b as K}from"./chunk-KCT6Y2AG.js";import{a as Pe}from"./chunk-CDLRTTHR.js";import{c as Ce,d as Ie}from"./chunk-OWNQ2FD4.js";import{a as Ee}from"./chunk-ROLSSYXE.js";import{Ea as Ae,La as Wt,V as ae,W as $e,ba as zt,cb as oe,eb as j,fb as Se,ob as ie}from"./chunk-A7AVIFNF.js";import{existsSync as F,readFileSync as Ye,writeFileSync as Xe,appendFileSync as Ot,mkdirSync as Ut}from"fs";import{dirname as Lt,resolve as W}from"path";import{fileURLToPath as Bt}from"url";import{hostname as jt}from"os";import{spawn as Ht}from"child_process";function Ke(e,t){let n=e.configExists?e.agentCount===0?"Add your first agent":"Add another agent":"Set up your team",r=`<header class="ax-topbar">
|
|
2
2
|
<div class="ax-topbar__left">
|
|
3
3
|
<div class="ax-brand">
|
|
4
4
|
<span class="ax-brand__mark">AX</span>
|
|
@@ -859,4 +859,4 @@ tr:hover td { background: var(--bg-hover); }
|
|
|
859
859
|
WHERE person = ? AND state IN (${n.map(()=>"?").join(",")})
|
|
860
860
|
${r}`).all(t,...n,...a).map(i=>({id:i.id,state:i.state,channel:i.channel,agentId:i.agent_id,text:i.text,createdAt:i.created_at})):[]}function _a(e,t){return St(e,t,ae,"ORDER BY created_at")}function za(e,t,n=50){return St(e,t,[...ae,...$e],"ORDER BY created_at DESC, rowid DESC LIMIT ?",Math.max(1,Math.min(n,500)))}Wt();var we="member:",On=90,Un="members",Ln="tailscale-user-login",Bn=400,jn=60*60*1e3;function Hn(e){let t=e.scopes.find(n=>n.startsWith(we));return t?t.slice(we.length):null}function It(e,t){if(!e)return null;let n=t.verify(e),r=n?Hn(n):null;return n&&r?{rec:n,personId:r}:null}function Ba(e,t){let n=e.people().find(s=>s.id===t);if(!n)return{ok:!1,error:`No person "${t}". Add them first: agentx people add ${t} --name "\u2026"`};let{token:r,record:a}=e.tokens.create({name:`${n.name} (machine not paired yet)`,scopes:[`${we}${n.id}`],expiresInDays:On}),{code:o,expiresAt:i}=e.codes.create({token:r,tokenId:a.id,name:n.id});return e.members.log({person:n.id,device:a.id,event:"invited"}),{ok:!0,code:o,expiresAt:i,tokenId:a.id,person:n}}var qn=Math.round(Te/6e4);function Fn(e){return e==="client"?"Your project":"My work"}function ja(e){let t=Fn(e.person.role),n=e.person.role==="client"?`I use AgentX to keep track of the work I do for you. It has a page for you, "${t}": what you asked us for, and where each request stands.`:`I use AgentX to give our AI agents their jobs. It has a page for you, "${t}": what you asked the agents for, and where each request stands.`;return[`Hi ${e.person.name},`,"",n,"","To open it:","1. Accept the Tailscale share I sent you. Tailscale is a small program that connects your computer to mine, privately.",`2. Open ${e.origin.replace(/\/+$/,"")}/member in Edge or Chrome, give your computer a name and type this code: ${De(e.code)}`,` The code works once, for ${qn} minutes. If it has stopped working, tell me and I will send you a new one.`,"","I then approve your machine, and the page opens by itself."].join(`
|
|
861
861
|
`)}var Gn="The private network says someone else is connecting from this machine. Ask the person who invited you for a new code.",Kn="Too many machines are waiting for the owner's answer. Try again later.",Ct="That code didn't work. Check it, or ask the person who invited you for a new one.",Et=(e,t)=>{let n=e.headers[t];return(Array.isArray(n)?n[0]:n||"").trim()};function Pt(e){let t=e.socket?.remoteAddress||"";return t==="127.0.0.1"||t==="::1"||t==="::ffff:127.0.0.1"}function Jn(e){if(!Pt(e))return null;let t=Et(e,Ln).toLowerCase();return t?t.slice(0,80):null}function Yn(e){let t=e.socket?.remoteAddress||"unknown";if(!Pt(e))return t;let n=Et(e,"x-forwarded-for").split(",").pop().trim();return/^[0-9a-fA-F:.]{2,45}$/.test(n)?n:t}function Xn(e){return typeof e=="string"?e.replace(/[^\p{L}\p{N} ._'()-]/gu," ").replace(/\s+/g," ").trim().slice(0,60):""}function Vn(e){return e.identities.map(Ae).filter(t=>!!t&&t.channel==="tailscale").map(t=>t.value)}async function Ha(e,t){let n=Date.now(),r=t.now??Date.now,a=t.log??(v=>console.log(v)),o=Yn(e),i=t.limiter.retryAfter(o);if(i>0)return a(`[member] pair-code refused from ${o}: locked out for ${i}s more`),{status:429,body:{error:"too many attempts",retryAfter:i},retryAfter:i};let s=null,l="";try{let v=await Y(e,2048);s=v.code,l=Xn(v.machine)}catch{}let d=t.codes.redeem(s),c=d?It(d.token,t.tokens):null;if(await Zn(n,t.minMs??Bn),!d||!c)return t.limiter.fail(o),a(`[member] pair-code failed from ${o}`),{status:401,body:{error:Ct}};t.limiter.succeed(o);let{rec:m,personId:p}=c,w=t.people().find(v=>v.id===p);if(!w)return t.tokens.revoke(m.id),t.members.log({person:p,device:m.id,event:"refused",address:o,detail:"person no longer listed"}),a(`[member] pair-code for ${p} refused from ${o}: person no longer listed`),{status:403,body:{error:Ct}};let g=Jn(e),f=Vn(w);if(f.length&&(!g||!f.includes(g)))return t.tokens.revoke(m.id),t.members.log({person:p,device:m.id,event:"refused",address:o,detail:`network login ${g??"missing"}; expected ${f.join(" or ")}`}),a(`[member] ${p}: pairing from ${o} refused: the network says "${g??"nobody"}", expected ${f.join(" or ")}`),{status:403,body:{error:Gn}};let C=l||"Unnamed machine",x=w.name.slice(0,40),b=_e(t.root,{title:`New machine for ${x}`,ask:`From ${o}, ${g?`network login ${g}`:"no network login reported"}. Machine name, as typed there: "${C}". Let it see ${x}'s own work?`,recommend:`Yes if ${x} told you they just paired this machine. No if you did not expect it.`,if_silent:"discard",raised_by:Un},{now:r()});return b.ok?(t.members.add({tokenId:m.id,personId:p,name:C,state:"pending",cardId:b.card.id,address:o,...g?{network:g}:{},createdAt:new Date(r()).toISOString()}),t.members.log({person:p,device:m.id,event:"paired",address:o,detail:C}),a(`[member] ${p} paired "${C}" from ${o}; waiting for the owner (card ${b.card.id})`),{status:200,body:{person:p,name:C,state:"pending"},token:d.token}):(t.tokens.revoke(m.id),t.members.log({person:p,device:m.id,event:"refused",address:o,detail:b.error}),a(`[member] ${p}: pairing from ${o} refused: ${b.error}`),{status:503,body:{error:Kn}})}var re="this machine is not paired",Qn="waiting for the owner to approve this machine";function Rt(e){return e?e.status==="decided"?e.verdict??null:e.status==="expired"?"no":null:null}function qa(e,t){return t.state==="pending"&&t.cardId?Rt(se(e,t.cardId)):null}function Fa(e,t,n){let r=t.now??Date.now,a=t.log??(c=>console.log(c)),o=It(e,t.tokens);if(!o)return{ok:!1,status:401,error:re};let{rec:i,personId:s}=o,l=t.members.byToken(i.id);if(!l||l.state==="removed"||l.personId!==s)return{ok:!1,status:401,error:re};if(t.people&&!t.people().some(c=>c.id===s))return Tt(t,i.id,"person no longer listed"),a(`[member] ${s}: "${l.name}" ended: person no longer listed`),{ok:!1,status:401,error:re};if(l.state==="pending"){let c=l.cardId?se(t.root,l.cardId):null,m=Rt(c);if(m==="yes")l=t.members.update(i.id,{state:"active",approvedAt:new Date(r()).toISOString()})??l,t.members.log({person:s,device:i.id,event:"approved",detail:c?.decided_by}),a(`[member] ${s}: "${l.name}" approved`);else if(m==="no"){let p=c?.status==="expired"?"the owner did not answer in time":"the owner said no";return t.tokens.revoke(i.id),t.members.update(i.id,{state:"removed",removedAt:new Date(r()).toISOString(),removedReason:p}),t.members.log({person:s,device:i.id,event:"refused",detail:p}),a(`[member] ${s}: "${l.name}" refused: ${p}`),{ok:!1,status:401,error:re}}else return{ok:!1,status:403,error:Qn,waiting:!0}}let d=l.lastSeenAt?Date.parse(l.lastSeenAt):0;return n&&(r()-d>=jn||l.lastAddress!==n)&&(l=t.members.update(i.id,{lastSeenAt:new Date(r()).toISOString(),lastAddress:n})??l,t.members.log({person:s,device:i.id,event:"signed-in",address:n})),{ok:!0,device:l,personId:s,rec:i}}function Tt(e,t,n="removed by the owner"){let r=e.members.byToken(t);if(!r)return null;e.tokens.revoke(t);let a=e.members.update(t,{state:"removed",removedAt:new Date((e.now??Date.now)()).toISOString(),removedReason:n});return e.members.log({person:r.personId,device:t,event:"removed",detail:n}),a}function Ga(e,t){return e.members.devices(t).filter(n=>n.state!=="removed").map(n=>Tt(e,n.tokenId,"person removed by the owner")).filter(n=>!!n)}async function Zn(e,t){let n=e+t-Date.now();n>0&&await new Promise(r=>setTimeout(r,n))}var Dt=["gitlab","github"];function er(e,t,n){let r=String(t||"").trim().toLowerCase();if(!Dt.includes(r))throw new Error(`Request status works on ${Dt.join(" and ")}, not on "${t}".`);e.requestStatus=e.requestStatus&&typeof e.requestStatus=="object"?e.requestStatus:{};let a=Array.isArray(e.requestStatus.channels)?e.requestStatus.channels.map(o=>String(o).toLowerCase()):[];return e.requestStatus.channels=n?[...new Set([...a,r])]:a.filter(o=>o!==r),`request status on ${r} is ${n?"on":"off"}`}function Ya(e){return Array.isArray(e?.requestStatus?.channels)?e.requestStatus.channels.map(t=>String(t).toLowerCase()):[]}function Xa(e){let{summary:t}=X(n=>er(n,e?.channel,!!e?.enabled));return{summary:t}}function Qa(e){return new Set(Object.entries(e).filter(([,t])=>t?.wiki?.absorb?.enabled===!1).map(([t])=>t))}function Za(e,t){return t.only?{agents:[t.only],skipped:[]}:{agents:e.filter(n=>!t.off.has(n)),skipped:e.filter(n=>t.off.has(n))}}function eo(e,t){return`absorb is off for this agent (agents.${e}.wiki.absorb.enabled); skipped.${e===t?" It reads the wiki notes inbox, so the inbox was not read.":""} Use --agent ${e} to run it anyway.`}function to(e,t){if(t){if(!e.wiki?.absorb)return;delete e.wiki.absorb.enabled,Object.keys(e.wiki.absorb).length===0&&delete e.wiki.absorb,Object.keys(e.wiki).length===0&&delete e.wiki;return}e.wiki??={},e.wiki.absorb??={},e.wiki.absorb.enabled=!1}var tr="https://ntfy.sh";function ro(e){return{enabled:!!e?.enabled,server:e?.server||tr,topicSet:!!e?.topic,tokenSet:!!e?.token}}function ao(e,t){let n={...e??{}};if("enabled"in t&&(n.enabled=!!t.enabled),"server"in t){let r=String(t.server).trim().replace(/\/+$/,"");if(!/^https?:\/\/\S+$/.test(r))throw new Error("ntfy server must be an http(s) URL");n.server=r}if("topic"in t){let r=String(t.topic).trim();if(!r)throw new Error("ntfy topic cannot be empty");n.topic=r}if("token"in t){let r=String(t.token??"").trim();r?n.token=r:delete n.token}if(n.enabled&&!n.topic)throw new Error("set a topic before enabling ntfy");return n}export{Ve as a,ur as b,gr as c,mr as d,kr as e,wr as f,an as g,ln as h,me as i,$r as j,Ar as k,At as l,Ea as m,Pa as n,dn as o,Rr as p,Tr as q,Dr as r,Da as s,_a as t,za as u,On as v,Ba as w,qn as x,Fn as y,ja as z,Yn as A,Ha as B,qa as C,Fa as D,Tt as E,Ga as F,Dt as G,er as H,Ya as I,Xa as J,Qa as K,Za as L,eo as M,to as N,ro as O,ao as P,En as Q,ea as R,ia as S,sa as T};
|
|
862
|
-
//# sourceMappingURL=chunk-
|
|
862
|
+
//# sourceMappingURL=chunk-KPYWYMRY.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{fb as m,ob as b}from"./chunk-
|
|
1
|
+
import{fb as m,ob as b}from"./chunk-A7AVIFNF.js";b();function w(t){let e=typeof t.node=="string"?t.node:"",n=typeof t.token=="string"?t.token:"";if(!e||!n)try{let o=m(t.config);e||(e=o.dashboard?.daemonUrl||""),n||(n=o.dashboard?.token||"")}catch{}return e||(e="http://localhost:18800"),{baseUrl:e.replace(/\/+$/,""),token:n}}async function d(t,e,n){let o={Accept:"application/json"};t.token&&(o.Authorization=`Bearer ${t.token}`);let r=await fetch(`${t.baseUrl}${e}`,{headers:o,signal:n});if(!r.ok)throw new Error(`GET ${e} \u2192 HTTP ${r.status}`);return await r.json()}function R(t,e){return d(t,"/agents",e)}async function S(t,e){return(await d(t,"/api/processes",e)).processes??[]}function P(t,e){return d(t,"/crons",e)}async function h(t,e,n,o){let r={Accept:"application/json","Content-Type":"application/json"};t.token&&(r.Authorization=`Bearer ${t.token}`);let s=await fetch(`${t.baseUrl}${e}`,{method:"POST",headers:r,body:JSON.stringify(n),signal:o}),a=await s.text(),i;try{i=a?JSON.parse(a):{}}catch{i={raw:a}}if(!s.ok)throw new Error(i?.error||`POST ${e} \u2192 HTTP ${s.status}`);return i}function A(t,e,n="tui"){return h(t,"/api/processes/kill",{...e,reason:n})}function C(t,e,n,o){return h(t,"/task",{agent:e,message:n,context:o??{channel:"tui",chatId:"tui:operator"}})}async function $(t,e,n,o={}){let r={Accept:"text/event-stream","Content-Type":"application/json"};t.token&&(r.Authorization=`Bearer ${t.token}`);let s=await fetch(`${t.baseUrl}/task`,{method:"POST",headers:r,body:JSON.stringify({agent:e,message:n,stream:!0,context:{channel:o.channel??"chat-cli",chatId:o.chatId??"chat-cli:operator"}}),signal:o.signal});if(!s.ok||!s.body){let g=await s.text().catch(()=>"");throw new Error(`POST /task (stream) \u2192 HTTP ${s.status}${g?`: ${g.slice(0,200)}`:""}`)}let a=s.body.getReader(),i=new TextDecoder,u={content:""},c="";try{for(;;){let{done:g,value:p}=await a.read();if(g)break;c+=i.decode(p,{stream:!0});let l;for(;(l=c.indexOf(`
|
|
2
2
|
|
|
3
3
|
`))>=0;){let k=c.slice(0,l);c=c.slice(l+2);let f=x(k);f&&T(f,o,u)}}}finally{try{a.releaseLock()}catch{}}return u}function T(t,e,n){let{event:o,data:r}=t;switch(o){case"text":r?.text&&(n.content+=r.text,e.onText?.(r.text));break;case"thinking":r?.text&&e.onThinking?.(r.text);break;case"tool":e.onTool?.(r);break;case"done":typeof r?.content=="string"&&(n.content=r.content),n.usage=r?.usage,n.duration=r?.duration;break;case"error":n.error=r?.error,n.errorKind=r?.errorKind;break}}function x(t){let e="message",n="";for(let r of t.split(`
|
|
4
4
|
`))r.startsWith("event: ")?e=r.slice(7).trim():r.startsWith("data: ")&&(n=r.slice(6));if(!n)return null;let o;try{o=JSON.parse(n)}catch{o=n}return{event:e,data:o}}export{w as a,R as b,S as c,P as d,A as e,C as f,$ as g};
|
|
5
|
-
//# sourceMappingURL=chunk-
|
|
5
|
+
//# sourceMappingURL=chunk-KXK2OKT5.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{d as h}from"./chunk-
|
|
1
|
+
import{d as h}from"./chunk-XWQ3ZEIZ.js";var d=["main contact","primary contact","point of contact","billing contact","technical contact","decision maker"],f=/[\w.+-]+@[\w-]+(?:\.[\w-]+)+/g,w=/\b(role|title|position|job)\s*\**\s*[::]\s*\**\s*([^\n;|]+)/gi;function L(t,c,e=[]){let l=[c,...e].join(`
|
|
2
2
|
`),a=l.toLowerCase(),i=h(t,l);for(let s of p(t.match(f)??[]))a.includes(s.toLowerCase())||i.push(`email ${s}`);let m=t.toLowerCase();for(let s of d)m.includes(s)&&!a.includes(s)&&i.push(`marker "${s}"`);for(let s of t.matchAll(w)){let n=s[2].replace(/\*+/g,"").trim();n&&!a.includes(n.toLowerCase())&&i.push(`${s[1].toLowerCase()} "${n}"`)}return p(i)}function p(t){return[...new Set(t)]}var $=.9,g=/^\s*(?:wait\b|here(?:'s| is) the (?:updated|modified|patched|revised)|i (?:must|need to|will|should) (?:output|return|write)|(?:okay|ok|sure)[,.!]\s|let me\b|as requested\b)/im;function k(t,c){let e=[],l=t.split(`
|
|
3
3
|
`).filter(o=>o.trim()).length,a=c.split(`
|
|
4
4
|
`).filter(o=>o.trim()).length;l>=5&&a<Math.floor(l*$)&&e.push(`the article shrinks from ${l} to ${a} lines`);let i=c.match(g);i&&!t.match(g)&&e.push(`it contains the model's own commentary ("${i[0].trim().slice(0,40)}")`);let m=o=>{let r=new Map;for(let u of o.split(`
|
|
5
5
|
`))/^#{1,6} /.test(u)&&r.set(u.trim(),(r.get(u.trim())??0)+1);return r},s=m(t);for(let[o,r]of m(c))r>1&&r>(s.get(o)??0)&&e.push(`the heading "${o}" appears ${r} times`);let n=L(t,c);return n.length&&e.push(`it drops ${n.length} fact(s): ${n.slice(0,6).join(", ")}${n.length>6?", \u2026":""}`),e}export{L as a,k as b};
|
|
6
|
-
//# sourceMappingURL=chunk-
|
|
6
|
+
//# sourceMappingURL=chunk-LSC64WL3.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{a as D,b as _}from"./chunk-RKPAVWXF.js";import{a as R,b as q,c as O,d as B,f as k,g as v,h as E,i as w,j as y}from"./chunk-
|
|
1
|
+
import{a as D,b as _}from"./chunk-RKPAVWXF.js";import{a as R,b as q,c as O,d as B,f as k,g as v,h as E,i as w,j as y}from"./chunk-2J7LN4SR.js";import{a as T,b as C,c as I,d as x,e as P}from"./chunk-KCT6Y2AG.js";import{existsSync as X,readFileSync as F}from"fs";var J=new Set(["cron","heartbeat","api","a2a","mesh"]),M=160;function s(n){return typeof n=="string"&&n.trim()?n.trim():void 0}function S(n,e=M){let t=n.replace(/\s+/g," ").trim();return t.length>e?`${t.slice(0,e-1)}\u2026`:t}function V(n){let e=T(n);if(!X(e))throw new Error(`config not found at ${e}`);return JSON.parse(F(e,"utf-8"))}function W(n,e){return n?.agents?.[e]?.admin===!0}function Y(n,e,t){return W(n,t.agentId)||e?.createdBy===t.agentId}function Z(n,e){let t=e?.createdBy?`agent "${e.createdBy}"`:"the operator";return`Not allowed: "${n}" was created by ${t}. Agents manage only schedules they created (unless configured admin).`}function K(n,e){let t=s(n.notify);if(t!=="none"){if(t&&t!=="here"){let r=t.split(":");return r.length<2||!r[0]||!r[1]?"invalid":{channel:r[0],chatId:r.slice(1).join(":")}}if(e.channel&&e.chatId&&!J.has(e.channel))return{channel:e.channel,chatId:e.chatId,...e.accountId?{accountId:e.accountId}:{}}}}function Q(n,e,t){let r=e.timezone||"UTC",d=e.enabled&&!y(e)?w(E(e.schedule,r,t),r):"\u2014",h=e.approval?`pending ${e.approval.action} approval`:e.enabled?"active":"paused",f=[`- ${n} [${h}] ${e.schedule} \u2014 ${v(e.schedule)} (${r})`,` agent: ${e.agent}; created by: ${e.createdBy||"operator"}; next: ${d}`];return e.notify&&f.push(` notify: ${e.notify.channel} ${e.notify.chatId}${e.deliverResult===!1?" (failures only)":" (results and failures)"}`),e.command?f.push(` command: ${S(String(e.command))}`):e.prompt&&f.push(` prompt: ${S(String(e.prompt))}`),f.join(`
|
|
2
2
|
`)}async function b(n,e,t){let r=n?.notifications?.destination;if(!r?.channel||!r?.chatId)return"No operator notification destination is configured (notifications.destination); the operator must check `agentx schedule list`.";if(!e.notifyOperator)return"Operator notification is unavailable in this context.";try{return await e.notifyOperator({channel:r.channel,chatId:r.chatId,accountId:r.accountId},t),"The operator has been notified."}catch(d){return`Could not notify the operator (${d?.message??d}); the request is still recorded.`}}async function re(n,e,t={}){let r=(s(n.action)||"list").toLowerCase(),d=t.now?t.now():new Date,h;try{h=V(t.configPath)}catch(a){return`Error: ${a.message}`}let f=h.crons||{};if(r==="list"){let a=n.mine===!0,l=Object.entries(f).filter(([,i])=>!a||e&&i?.createdBy===e.agentId);return l.length?l.map(([i,p])=>Q(i,p,d)).join(`
|
|
3
3
|
`):a?"You have no schedules.":"No schedules."}if(!e?.agentId)return"Error: caller agent is unknown (AGENTX_AGENT_ID not set). Pass callerAgentId.";if(!h.agents?.[e.agentId])return`Error: caller "${e.agentId}" is not an agent on this node.`;let o=s(n.id),m=a=>C(a,{configPath:t.configPath,reload:t.reload});if(r==="create"){let a=s(n.when),l=s(n.prompt);if(!a||!l)return"Error: create needs `when` (plain English) and `prompt`.";let i=D(a);if(!i)return`Error: couldn't parse "${a}". ${q}.`;let p=s(n.agent)||e.agentId;if(!h.agents?.[p])return`Error: agent "${p}" not found on this node.`;let g=s(n.timezone)||R;if(!B(g))return`Error: unknown timezone "${g}".`;let u=o||_(i.matched,p);if(!O(u))return`Error: invalid id "${u}" (letters, digits, "-" and "_" only).`;if(f[u])return`Error: a schedule "${u}" already exists. Pick another \`id\`.`;let $=K(n,e);if($==="invalid")return'Error: `notify` must be "here", "none", or "channel:chatId".';let z={action:"create",requestedBy:e.agentId,requestedAt:d.toISOString()},L=k({parsed:i,agent:p,prompt:l,timezone:g,notify:$,enabled:!1,createdBy:e.agentId,approval:z}),A=await m(U=>I(U,`crons.${u}`,L));if(!A.success)return`Error: ${A.error}`;let N=w(E(i.cron,g,d),g),G=[`Schedule approval requested by ${e.agentId}`,`Create: ${u}`,`When: ${i.human} \u2014 cron \`${i.cron}\` (${g})`,`Next fire: ${N}`,`Agent: ${p}`,$?`Results and failures go to: ${$.channel} ${$.chatId}${$.channel==="voice"?" (as a push notification)":""}`:"Results go to: run log only (no chat)",`Prompt: ${S(l,400)}`,"",`Approve: agentx schedule approve ${u}`,`Reject: agentx schedule reject ${u}`].join(`
|
|
4
4
|
`),H=await b(h,t,G);return[`Requested schedule "${u}": ${i.human} (cron ${i.cron}, ${g}); next fire would be ${N}.`,"It is saved DISABLED and will not run until the operator approves it.",H].join(`
|
|
5
5
|
`)}if(!o)return`Error: ${r} needs \`id\`.`;let c=f[o];if(!c)return`Error: schedule "${o}" not found.`;if(!Y(h,c,e))return Z(o,c);if(r==="pause"||r==="resume"){let a=r==="resume";if(a&&y(c))return`"${o}" is still awaiting operator approval; it can't be resumed until approved.`;if(c.enabled===a)return`"${o}" is already ${a?"active":"paused"}.`;let l=await m(i=>I(i,`crons.${o}.enabled`,a));return l.success?`"${o}" ${a?"resumed":"paused"}.`:`Error: ${l.error}`}if(r==="delete"){if(y(c)&&c.approval.requestedBy===e.agentId){let u=await m($=>P($,`crons.${o}`));return u.success?`Withdrew the pending request "${o}".`:`Error: ${u.error}`}if(y(c))return`"${o}" is a creation request still awaiting approval; only its requester or the operator (\`agentx schedule reject ${o}\`) can drop it.`;if(c.approval?.action==="delete")return`Deletion of "${o}" is already awaiting approval.`;let a={action:"delete",requestedBy:e.agentId,requestedAt:d.toISOString()},l=await m(u=>{if(!x(u,`crons.${o}`))throw new Error(`schedule "${o}" not found`);I(u,`crons.${o}.approval`,a)});if(!l.success)return`Error: ${l.error}`;let i=c.timezone||"UTC",p=[`Schedule approval requested by ${e.agentId}`,`Delete: ${o}`,`When: ${v(c.schedule)} \u2014 cron \`${c.schedule}\` (${i})`,`Next fire: ${c.enabled?w(E(c.schedule,i,d),i):"\u2014 (paused)"}`,`Agent: ${c.agent}`,"",`Approve: agentx schedule approve ${o}`,`Reject: agentx schedule reject ${o}`].join(`
|
|
6
6
|
`),g=await b(h,t,p);return[`Deletion of "${o}" requested. It keeps its current state until the operator approves.`,g].join(`
|
|
7
7
|
`)}return`Error: unknown action "${r}". Use list, create, pause, resume or delete.`}function oe(n,e=process.env){let t=s(e.AGENTX_AGENT_ID)||s(n.callerAgentId);if(!t)return null;let r=!!(s(e.AGENTX_CHANNEL)&&s(e.AGENTX_CHAT_ID)),d=s(r?e.AGENTX_CHANNEL:n.channel),h=s(r?e.AGENTX_CHAT_ID:n.chatId),f=s(n.accountId);return{agentId:t,channel:d,chatId:h,...f?{accountId:f}:{}}}export{re as a,oe as b};
|
|
8
|
-
//# sourceMappingURL=chunk-
|
|
8
|
+
//# sourceMappingURL=chunk-M6YFSYJC.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{y as l,z as T}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{y as l,z as T}from"./chunk-ECY6WMZP.js";import{a,f as w}from"./chunk-72SZI2UW.js";T();w();var d="task-tier";function u(e){return{task:b(e.message,2e3),agent:e.agent,channel:e.channel??null,continuesExistingSession:e.isFollowUp??!1,...e.toolsAvailable?{toolsAvailable:e.toolsAvailable}:{}}}var c={needsFlagship:a("This task needs the strongest available model to be done correctly.",{true:"Doing it well takes real reasoning: writing or reviewing code, diagnosing a failure, planning work across several steps, weighing a judgement, handling money, touching production or anything irreversible, following a long or ambiguous instruction, or work where being subtly wrong would not be noticed. Anything where a weaker model would produce something that LOOKS right belongs here.",false:"It is mechanical and its result is obvious on sight: acknowledging or confirming a message, restating or formatting something already written, a greeting, a status echo, reading one file and reporting what it says, a lookup with one right answer, a scheduled heartbeat with nothing to decide."})};function g(e){return e.needsFlagship.noul}function b(e,n){return e.length>n?`${e.slice(0,n)}\u2026`:e}var h=.2;function p(e){return e==="voice"||e==="desktop"||e==="opencode"}var f=60*60*1e3;function M(e,n){if(e==="claude-code"){let t=n?.cheapModels?.[e]??n?.cheapModel;return t&&/^(claude-|haiku$|sonnet$|opus$)/.test(t)?t:void 0}if(e==="codex-cli"){let t=n?.cheapModels?.[e];return t&&/^(gpt-|o\d)/.test(t)?t:void 0}}async function v(e){let n=(s,r=null)=>({downgraded:!1,needsFlagship:r,reason:s});if(p(e.channel))return n(`${e.channel} requests retain the configured model`);if(!e.cheapModel)return n("no cheaper model configured");if(e.isFollowUp){let s=e.sessionIdleMs??0,r=e.cacheTtlMs??f;if(s<r)return n(`follow-up on a warm cache (idle ${Math.round(s/1e3)}s) \u2014 swapping would cost more than it saves`)}let t;try{t=await l(d,u(e),c,{incumbent:{needsFlagship:1},features:{agent:e.agent,channel:e.channel??"unknown"},timeoutMs:1500})}catch{return n("routing seat threw \u2014 keeping the flagship")}if(!t)return n("routing seat unavailable \u2014 keeping the flagship");let o=g(t.answers);if(t.mode!=="active")return n(`shadow \u2014 would ${o<(e.threshold??h)?"downgrade":"keep"} (${o.toFixed(2)})`,o);let i=e.threshold??h;return o>=i?n(`needs the flagship (${o.toFixed(2)})`,o):{model:e.cheapModel,downgraded:!0,needsFlagship:o,reason:`mechanical task (${o.toFixed(2)} below ${i}) \u2192 ${e.cheapModel}`}}var A=["labeled","unlabeled","closed"];function y(e){let n=r=>({downgraded:!1,needsFlagship:null,reason:r});if(p(e.channel))return n(`${e.channel} requests retain the configured model`);let t=e.eventActions??[];if(!t.length)return n("not started by a platform event");let o=e.triage?.actions??A,i=t.find(r=>!o.includes(r));if(i)return n(`"${i}" is not a triage action`);let s=M(e.tier,{cheapModels:e.triage?.models});if(!s)return n(`no triage model set for ${e.tier}`);if(e.isFollowUp){let r=e.sessionIdleMs??0,m=e.cacheTtlMs??f;if(r<m)return n(`follow-up on a warm cache (idle ${Math.round(r/1e3)}s) \u2014 keeping the session's model`)}return{model:s,downgraded:!0,needsFlagship:null,reason:`triage event (${t.join(", ")}) \u2192 ${s}`}}export{h as a,p as b,M as c,v as d,A as e,y as f};
|
|
2
|
+
//# sourceMappingURL=chunk-MBCXPY6T.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{q as _,r as W}from"./chunk-2AXFYDWF.js";import{b as Y,c as I,d as O}from"./chunk-AQASR6KR.js";import{b as F}from"./chunk-MEFPXHQJ.js";import{a as E}from"./chunk-
|
|
1
|
+
import{q as _,r as W}from"./chunk-2AXFYDWF.js";import{b as Y,c as I,d as O}from"./chunk-AQASR6KR.js";import{b as F}from"./chunk-MEFPXHQJ.js";import{a as E}from"./chunk-T2GBLNW7.js";import{b as L}from"./chunk-KEXBEUSU.js";import{createHash as ee}from"crypto";import{existsSync as H,readdirSync as te,readFileSync as re,writeFileSync as ne}from"fs";import{resolve as P}from"path";function be(n,r,s,t,o,i,c="",p="",m=""){return Z(r,s,t,o,i,c,p,m)}function Z(n,r,s,t,o,i="",c="",p=""){let m=r?`
|
|
2
2
|
## Worldview
|
|
3
3
|
|
|
4
4
|
${r}
|
|
@@ -249,4 +249,4 @@ ${u}`}var x="memory-promoter",oe=["project","reference","feedback"],K="_memory-p
|
|
|
249
249
|
Re-emit the FULL corrected JSON object \u2014 same structure, fixed issues, valid JSON only.`:n,y=await t(`${a}/task`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agent:r.viaAgent,message:h,freshSession:s===null,context:{channel:"api",chatId:r.chatId??"memory-promote"}}),signal:i.signal});if(!y.ok){let f=await y.text().catch(()=>"");throw new Error(`agent /task ${y.status}: ${f.slice(0,500)}`)}let w=await y.json();if(w.error)throw new Error(`agent reported error: ${w.error}`);let b=String(w.content??"").trim();if(!b)throw new Error("agent returned empty content");return b}if(!r.model)throw new Error("callPromotionLlm: viaAgent or model is required");let p=process.env.ANTHROPIC_API_KEY;if(!p)throw new Error("ANTHROPIC_API_KEY not set; use --via <agentId> instead");let m=[{role:"user",content:n}];s&&(m.push({role:"assistant",content:"(previous attempt; will retry with corrections)"}),m.push({role:"user",content:`Your previous response failed validation: ${s}
|
|
250
250
|
Re-emit the FULL corrected JSON object.`}));let u=await t(me,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":p,"anthropic-version":ge},body:JSON.stringify({model:r.model,max_tokens:8e3,messages:m}),signal:i.signal});if(!u.ok){let a=await u.text().catch(()=>"");throw new Error(`anthropic API ${u.status}: ${a.slice(0,500)}`)}let d=await u.json(),e=(Array.isArray(d.content)?d.content:[]).filter(a=>a?.type==="text").map(a=>a.text).join(`
|
|
251
251
|
`).trim();if(!e)throw new Error("anthropic API returned no text content");return e}finally{clearTimeout(c)}}async function Se(n={}){let r=n.wikiDir??P(process.cwd(),".agentx","wiki"),s=n.memoryRoot??P(process.cwd(),".agentx"),t=n.log??(()=>{}),o=n.now??Date.now(),i={candidates:[],clusters:[],proposed:[],skipped:[],gaps:[],warnings:[],errors:[],dryRun:!n.commit},c=new E(r,(...l)=>t(l.map(String).join(" "))),p=c.rebuildIndex(),m=z(r),u=[...ce(s),...n.extraCandidates??[]];if(i.candidates=de(u,p,m,{types:n.types,sinceMs:n.sinceMs,agentFilter:n.agentFilter,now:o,max:n.max}),i.candidates.length===0)return t("no unpromoted memories in window"),i;if(i.clusters=le(i.candidates),i.dryRun)return i;let d=p.articles.map(l=>({title:l.title,path:l.path,type:l.type})),g=c.getWorldview()??"",e=n.budgetTokens??ue,a=i.clusters,h=D(x,a,d,g);for(;R(h)>e&&a.length>1;)a=a.slice(0,-1),h=D(x,a,d,g);if(R(h)>e)return i.errors.push(`judge prompt (~${R(h)} tokens) exceeds the ${e}-token budget even with one cluster`),i;a.length<i.clusters.length&&i.warnings.push(`token budget: judged ${a.length} of ${i.clusters.length} clusters; the rest wait for the next run`);let y=a.flatMap(l=>l.candidates),w=new Set(y.map(l=>l.stamp)),b=n.chatId??`memory-promote-${new Date(o).toISOString().slice(0,10)}`,f=B(await G(h,{...n,chatId:b}),w);if("error"in f&&(t(`parse failed (${f.error}) \u2014 retrying with feedback`),f=B(await G(h,{...n,chatId:b},f.error),w)),"error"in f)return i.errors.push(`LLM response unusable after retry: ${f.error}`),i;i.warnings.push(...f.warnings),i.gaps=f.gaps;let v=new Date(o).toISOString(),k=[],T=new Map(y.map(l=>[l.stamp,l]));for(let l of f.articles){let A=c.readArticle(l.path);if(A&&!c.canWrite(A.meta,x)){i.errors.push(`write denied for "${l.path}" (owned by ${A.meta.owner??"?"})`);continue}let M=fe(l.promotedFrom,T),S={id:Y(o,l.path),createdAt:v,status:"pending",article:l,evidence:M,...A?{replaces:{lastUpdated:A.meta.lastUpdated,contentHash:V(A.content)}}:{}};I(r,S),i.proposed.push({id:S.id,path:l.path,title:l.title,type:l.type,stamps:l.promotedFrom,agents:M.agents,occurrences:M.occurrences});for(let X of l.promotedFrom)k.push({stamp:X,decision:"proposed",article:l.path,proposal:S.id,at:v})}for(let l of f.skipped)k.push({stamp:l.stamp,decision:"skipped",reason:l.reason,at:v}),i.skipped.push(l);return k.length&&C(r,k),i}var ue=6e4;function R(n){return Math.ceil(n.length/4)}function V(n){return ee("sha256").update(n).digest("hex").slice(0,16)}var he=600;function ye(n){return n.startsWith("review:")?"review":n.startsWith(j)?"failure":"memory"}function fe(n,r){let s=[];for(let t of n){let o=r.get(t);o&&s.push({stamp:t,kind:ye(t),agentId:o.agentId,type:o.memory.type,name:o.memory.name,description:o.memory.description,...o.occurrences?{occurrences:o.occurrences}:{},...o.sessions?.length?{sessions:o.sessions}:{},...o.tasks?.length?{tasks:o.tasks}:{},...o.failure?{failure:o.failure}:{},...o.memory.author?{author:o.memory.author}:{},...o.memory.taskId?{taskId:o.memory.taskId}:{},updatedAt:o.memory.updatedAt,excerpt:o.memory.body.slice(0,he)})}return{agents:[...new Set(s.map(t=>t.agentId))].sort(),occurrences:Math.max(1,...s.map(t=>t.occurrences??1)),sources:s}}function Ee(n,r,s={}){let t=O(n,r);if(!t)return{ok:!1,error:`no proposal "${r}"`};if(t.status!=="pending")return{ok:!1,error:`proposal "${r}" is already ${t.status}`};let o=s.log??(()=>{}),i=new E(n,(...a)=>o(a.map(String).join(" "))),{article:c}=t,p=i.readArticle(c.path);if(!s.force){if(p&&!t.replaces)return{ok:!1,error:`"${c.path}" was created after this proposal; review it, then approve with --force`};if(p&&t.replaces&&V(p.content)!==t.replaces.contentHash)return{ok:!1,error:`"${c.path}" changed since this proposal; review it, then approve with --force`}}let m=s.now??Date.now(),u=new Date(m).toISOString().slice(0,10);if(!i.writeArticle(c.path,{title:c.title,type:L(c.type)?c.type:void 0,related:c.related,tags:c.tags,owner:x,access:"public",created:p?.meta.created??u,lastUpdated:u,sources:ae(p?.meta.sources,c.promotedFrom)},c.content,x))return{ok:!1,error:`write denied for "${c.path}" (owned by ${p?.meta.owner??"?"})`};let g=new Date(m).toISOString();C(n,c.promotedFrom.map(a=>({stamp:a,decision:"promoted",article:c.path,proposal:r,at:g}))),i.rebuildIndex();let e={...t,status:"approved",decidedBy:s.by??"operator",decidedAt:g};return I(n,e),{ok:!0,proposal:e}}function Oe(n,r,s={}){let t=O(n,r);if(!t)return{ok:!1,error:`no proposal "${r}"`};if(t.status!=="pending")return{ok:!1,error:`proposal "${r}" is already ${t.status}`};let o=new Date(s.now??Date.now()).toISOString();C(n,t.article.promotedFrom.map(c=>({stamp:c,decision:"rejected",article:t.article.path,proposal:r,reason:s.reason,at:o})));let i={...t,status:"rejected",decidedBy:s.by??"operator",decidedAt:o,...s.reason?{reason:s.reason}:{}};return I(n,i),{ok:!0,proposal:i}}export{be as a,x as b,oe as c,K as d,q as e,ie as f,$ as g,ae as h,ce as i,z as j,C as k,le as l,B as m,de as n,G as o,Se as p,R as q,ye as r,fe as s,Ee as t,Oe as u};
|
|
252
|
-
//# sourceMappingURL=chunk-
|
|
252
|
+
//# sourceMappingURL=chunk-ODAZQH7N.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{fb as l,ob as m}from"./chunk-
|
|
1
|
+
import{fb as l,ob as m}from"./chunk-A7AVIFNF.js";m();import{existsSync as g,readFileSync as u,writeFileSync as a,copyFileSync as y}from"fs";import{resolve as p}from"path";function P(e,n={}){let t=n.configPath||p(process.cwd(),"agentx.json");if(!g(t))throw new Error(`agentx.json not found at ${t}`);let i=JSON.parse(u(t,"utf-8")),o=e(i),s=typeof o=="string"?{summary:o}:o,c=JSON.stringify(i,null,2)+`
|
|
2
2
|
`,f=t+".tmp";a(f,c,"utf-8");try{JSON.parse(u(f,"utf-8"))}catch(d){throw new Error(`config did not round-trip cleanly: ${d.message}`)}let r;return n.skipBackup||(r=`${t}.bak.${Date.now()}`,y(t,r)),a(t,c,"utf-8"),n.skipReload||h().catch(()=>{}),{summary:s.summary,payload:s.payload,backupPath:r}}function S(e,n={}){let t=n.configPath||p(process.cwd(),"agentx.json");if(g(t)&&!n.overwrite)throw new Error(`agentx.json already exists at ${t}. Pass overwrite=true to replace it.`);return a(t,JSON.stringify(e,null,2)+`
|
|
3
3
|
`,"utf-8"),{file:t}}async function h(){try{let n=l().dashboard.daemonUrl?.replace(/\/+$/,"")||"http://127.0.0.1:18800";await fetch(`${n}/reload`,{method:"POST"}).catch(()=>null)}catch{}}export{P as a,S as b};
|
|
4
|
-
//# sourceMappingURL=chunk-
|
|
4
|
+
//# sourceMappingURL=chunk-P76PFVMJ.js.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import{a as k}from"./chunk-IMLAPB7G.js";import{k as y}from"./chunk-LQS27HSV.js";import{d as V}from"./chunk-QPABR72X.js";import{b as z}from"./chunk-KP7KDLZ2.js";import{S as B,T as J,U as X,V as K,Z as N,ba as Oe}from"./chunk-A7AVIFNF.js";import{existsSync as Q,readFileSync as Ie}from"node:fs";import{dirname as A,join as h}from"node:path";import{fileURLToPath as Ee}from"node:url";import{homedir as Ce}from"node:os";var M="tn.acme.agentx.voice",gt="AgentX Desktop.app",Y="AgentX Helper.app";function yt(e,t,n){return e!=="darwin"||t!=="arm64"||Number(n.split(".")[0])<23?"AgentX Desktop currently requires Apple Silicon and macOS 14 or newer.":null}function ht(e,t){if(t&&!Object.hasOwn(e,t))throw new Error(`Unknown agent: ${t}. Run agentx agent list.`);let n=t||Object.keys(e)[0];if(!n)throw new Error("No agents configured. Run agentx setup first.");return n}function T(e){return`'${e.replace(/'/g,"'\\''")}'`}var Z="/usr/bin:/bin:/usr/sbin:/sbin";function wt(e,t){return t||[...new Set([...e?[A(e)]:[],...Z.split(":")])].join(":")}function R(e){let t={amp:"&",lt:"<",gt:">",quot:'"',apos:"'"};return e.replace(/&(amp|lt|gt|quot|apos);/g,(n,r)=>t[r])}function St(e){let t=e.match(/<key>PATH<\/key>\s*<string>([^<]*)<\/string>/);return t?R(t[1]):Z}var xt=e=>/agentx\.voice.*\.plist$/.test(e);function vt(e,t){let n=null,r=[];for(let{file:o,plist:i}of[...t].sort((s,u)=>s.file<u.file?-1:1)){let s=i.match(/<key>Label<\/key>\s*<string>([^<]*)<\/string>/)?.[1],u=i.match(/<key>ProgramArguments<\/key>\s*<array>\s*<string>([^<]*)<\/string>/)?.[1];!s||!u||!R(u).endsWith("/Contents/MacOS/AgentXVoice")||(n?r.push({file:o,label:R(s)}):n={file:o,label:R(s)})}return{keep:n??{file:h(e,`${M}.plist`),label:M},remove:r}}function ee(e,t,n){for(let r of t.split(":"))if(r&&n(h(r,e)))return h(r,e);return null}function bt(e){let t=r=>r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),n={PATH:e.path,...e.agent?{AGENTX_VOICE_AGENT:e.agent}:{},AGENTX_DAEMON_URL:e.url,AGENTX_MAC_HELPER:e.helper,AGENTX_PASTE_COMMAND:`cd ${T(e.cwd)} && ${T(e.node)} ${T(e.cli)} paste`};return`<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0"><dict>
|
|
4
|
+
<key>Label</key><string>${t(e.label??M)}</string>
|
|
5
|
+
<key>ProgramArguments</key><array><string>${t(e.executable)}</string></array>
|
|
6
|
+
<key>WorkingDirectory</key><string>${t(e.cwd)}</string>
|
|
7
|
+
<key>EnvironmentVariables</key><dict>${Object.entries(n).map(([r,o])=>`<key>${r}</key><string>${t(o)}</string>`).join("")}</dict>
|
|
8
|
+
<key>RunAtLoad</key><true/><key>KeepAlive</key><true/>
|
|
9
|
+
<key>ProcessType</key><string>Interactive</string>
|
|
10
|
+
<key>StandardErrorPath</key><string>${t(e.log)}</string>
|
|
11
|
+
</dict></plist>
|
|
12
|
+
`}function Nt(e){return e?["--icon",e]:[]}function Te(e){return h(e,"Applications",Y,"Contents/MacOS/agentx-mac-helper")}function Me(e=A(Ee(import.meta.url))){for(let t=e;;t=A(t)){try{if(JSON.parse(Ie(h(t,"package.json"),"utf8")).name==="agentix-cli")return t}catch{}if(A(t)===t)return null}}function _e(e,t,n){if(n)return n;let r=Te(t);return Q(r)||!e?r:h(e,"apps/mac-helper/build",Y,"Contents/MacOS/agentx-mac-helper")}function _(){let e=_e(Me(),Ce(),process.env.AGENTX_MAC_HELPER);return Q(e)?e:null}import{accessSync as je,constants as Ue}from"fs";import{execFile as L}from"child_process";var te=5e3,P=(e,t)=>new Promise(n=>{try{L(e,t,{timeout:te},r=>n(!r))}catch{n(!1)}}),w=(e,t)=>new Promise(n=>{try{L(e,t,{timeout:te},(r,o)=>n(r?null:String(o)))}catch{n(null)}}),$=(e,t)=>new Promise((n,r)=>{L(e,t,{timeout:3e4,maxBuffer:8*1024*1024},(o,i,s)=>{o?r(new Error(`${e} ${t[0]}: ${(s||o.message).trim()}`)):n(i)})});var ne=e=>e.helper===void 0?_():e.helper;async function Le(e,t=w){if(!e)return"missing";let n=await t(e,["notify-status"]),r=null;try{r=n?JSON.parse(n):null}catch{r=null}return r?r.authorization==="notDetermined"?"not-asked":r.authorization==="denied"?"not-allowed":r.alertStyle==="none"?"hidden":"ready":"outdated"}function re(e={}){let t=e.run??P;return{async post({title:n,message:r}){let o=ne(e);return o&&await t(o,["notify","--title",n,"--message",r])||await t("/usr/bin/osascript",["-e","on run argv","-e","display notification (item 2 of argv) with title (item 1 of argv)","-e","end run",n,r])?"posted":"failed"},status:()=>Le(ne(e),e.capture)}}function De(e){let t=e.match(/"HIDIdleTime"\s*=\s*(\d+)/);return t?Math.floor(Number(t[1])/1e9):null}function ie(e={}){let t=e.capture??w;return{async seconds(){let n=await t("/usr/sbin/ioreg",["-c","IOHIDSystem","-d","4"]);return n?De(n):null}}}var qe=`
|
|
13
|
+
function run(argv) {
|
|
14
|
+
var folderName = argv[0], title = argv[1], body = argv[2]
|
|
15
|
+
var Notes = Application("Notes")
|
|
16
|
+
var esc = function (s) { return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">") }
|
|
17
|
+
var folder = Notes.folders.whose({ name: folderName })()[0]
|
|
18
|
+
if (!folder) {
|
|
19
|
+
folder = Notes.Folder({ name: folderName })
|
|
20
|
+
Notes.folders.push(folder)
|
|
21
|
+
folder = Notes.folders.whose({ name: folderName })()[0]
|
|
22
|
+
}
|
|
23
|
+
var lines = body.split("\\n").map(function (l) { return "<div>" + (l ? esc(l) : "<br>") + "</div>" })
|
|
24
|
+
// Notes takes the title from the first line: a name as well would show it twice.
|
|
25
|
+
var note = Notes.Note({ body: "<div><h1>" + esc(title) + "</h1></div>" + lines.join("") })
|
|
26
|
+
folder.notes.push(note)
|
|
27
|
+
return note.id()
|
|
28
|
+
}
|
|
29
|
+
`;function oe(e=$){return{async add({folder:t,title:n,body:r}){let i=(await e("/usr/bin/osascript",["-l","JavaScript","-e",qe,t,n,r])).trim();if(!i)throw new Error("Notes did not return the new note's id");return{id:i}}}}import{existsSync as He,readdirSync as Fe}from"fs";var ae="/System/Library/Sounds";function se(e){if(!/^[\w -]+$/.test(e))return null;let t=`${ae}/${e}.aiff`;return He(t)?t:null}function ue(e={}){let t=e.run??P;return{async play(n,r){let o=se(n);o&&await t("/usr/bin/afplay",["-v",String(Math.min(1,Math.max(0,r))),o])},has:n=>se(n)!==null,async names(){try{return Fe(ae).filter(n=>n.endsWith(".aiff")).map(n=>n.slice(0,-5)).sort()}catch{return[]}}}}var le={say:"a spoken line (say)",afplay:"a sound playing (afplay)"};function We(e,t,n=process.pid){for(let r of e.split(`
|
|
30
|
+
`)){let o=r.trim().match(/^(\d+)\s+(\d+)\s+(\S+)/);if(!o)continue;let[i,s,u]=[Number(o[1]),Number(o[2]),o[3]],l=u.slice(u.lastIndexOf("/")+1);if(!(!(l in le)||i===n||t.includes(s)))return le[l]}return null}function ce(e={}){let t=e.capture??w;return{async othersSpeaking(n={}){let r=await t("/bin/ps",["-axo","pid=,ppid=,comm="]);return r?We(r,n.exceptParents??[]):null}}}var me="\u200B";function O(e){return e.startsWith("-")?me+e:e}var pe=e=>e?.startsWith(me+"-")?e.slice(1):e;function D(e){if(!e.trim()||e.startsWith("-"))throw new Error(`Reminders list name "${e}" is not usable: it must not be empty or start with "-"`);return e}var de=e=>new Date(Math.floor(e.getTime()/6e4)*6e4).toISOString().replace(/\.\d{3}Z$/,"Z");function fe(e="remindctl",t=$){return{async ensureList(n){let r=await t(e,["list","--json","--no-input"]),o=JSON.parse(r.trim()||"[]");if(!Array.isArray(o))throw new Error(`${e} list: expected a JSON array`);o.some(i=>i?.title===n)||await t(e,["list",D(n),"--create","--json","--no-input"])},async listOpen(n){let r=await t(e,["show","all","--list",D(n),"--json","--no-input"]),o=JSON.parse(r.trim()||"[]");if(!Array.isArray(o))throw new Error(`${e} show: expected a JSON array`);return o.filter(i=>i&&typeof i.id=="string"&&!i.isCompleted).map(i=>({...i,title:pe(i.title)??"",...i.notes!==void 0?{notes:pe(i.notes)}:{}}))},async add({list:n,title:r,notes:o,due:i,priority:s}){let u=["add","--title",O(r),"--list",D(n),"--notes",O(o)];i&&u.push("--due",de(i)),s&&s!=="none"&&u.push("--priority",s);let l=await t(e,[...u,"--json","--no-input"]),p;try{p=JSON.parse(l.trim())?.id}catch{p=void 0}if(typeof p!="string"||!p)throw new Error(`${e} add: no reminder id in its answer`);return{id:p}},async update(n,r){let o=["edit",n];r.title!==void 0&&o.push("--title",O(r.title)),r.notes!==void 0&&o.push("--notes",O(r.notes)),r.due===null?o.push("--clear-due"):r.due&&o.push("--due",de(r.due)),o.length!==2&&await t(e,[...o,"--json","--no-input"])},async complete(n){await t(e,["complete",n,"--json","--no-input"])},async remove(n){await t(e,["delete",n,"--force","--json","--no-input"])}}}var Ge=e=>{try{return je(e,Ue.X_OK),!0}catch{return!1}},Be={async active(){let e=z();return e.active?!0:e.reason==="no active Focus assertion"?!1:null}};function ge(e={},t={}){let n=e.reminders?.command||"remindctl";return{os:"macos",tasks:fe(n,t.output),notes:oe(t.output),banner:re(t),sound:ue(t),focus:Be,speech:ce(t),idle:ie(t),async describe(){let r=[],o=t.isExecutable??Ge;return(n.includes("/")?o(n):!!ee(n,process.env.PATH||"",o))||r.push(`Reminders: ${n} not found (brew install steipete/tap/remindctl, or set reminders.command).`),{os:"macos",tasks:!0,notes:!0,banner:!0,sound:!0,focus:!0,problems:r}}}}function I(e){return{os:"none",async describe(){return{os:"none",tasks:!1,notes:!1,banner:!1,sound:!1,focus:!1,problems:[e]}}}}var Je={darwin:ge};function q(e={},t={}){if(e.native?.adapter==="none")return I('Turned off: native.adapter is "none".');let n=t.platform??process.platform,r=(t.factories??Je)[n];return r?r(e,t.io??{}):I(`AgentX has no native adapter for ${n} yet.`)}import{existsSync as Xe}from"fs";import{homedir as Ke}from"os";import{isAbsolute as Ve}from"path";var ye={banner:!0,sound:!0,soundName:"Glass",volume:.4,quietWaitSeconds:15};function un(e){return{...ye,...e??{}}}function ln(e,t={}){let n=q({native:t.native},{platform:t.platform,io:{run:t.run,capture:t.capture,helper:t.helper}});return async(r,o)=>{let i=[];if(e.banner&&n.banner&&i.push(n.banner.post({title:r,message:o})),e.sound&&n.sound){let s=n.sound;i.push(ze(n.speech,(e.quietWaitSeconds??ye.quietWaitSeconds)*1e3,t.pollMs??500).then(u=>u?s.play(e.soundName,e.volume):void 0))}await Promise.all(i)}}async function ze(e,t,n){if(!e||t<=0)return!0;let r=Date.now()+t;for(;;){if(!await e.othersSpeaking())return!0;if(Date.now()>=r)return!1;await new Promise(o=>setTimeout(o,n))}}function cn(e,t,n=process.platform){let r={...e??{}},o=q({},{platform:n});if("banner"in t&&(r.banner=!!t.banner),"sound"in t&&(r.sound=!!t.sound),"soundName"in t){let i=String(t.soundName).trim();if(!(o.sound?o.sound.has(i):/^[\w -]+$/.test(i)))throw new Error(`no system sound named "${i}" on this machine`);r.soundName=i}if("icon"in t){let i=String(t.icon??"").trim().replace(/^~(?=\/)/,Ke());if(!i)delete r.icon;else{if(!Ve(i)||!/\.(png|jpe?g|icns)$/i.test(i))throw new Error("icon must be the full path to a .png, .jpg or .icns file");if(o.banner&&!Xe(i))throw new Error(`no icon file at ${i}`);r.icon=i}}if("volume"in t){let i=Number(t.volume);if(!Number.isFinite(i)||i<0||i>1)throw new Error("volume must be between 0 and 1");r.volume=i}return r}import{existsSync as tt,mkdirSync as nt,readFileSync as rt,renameSync as it,writeFileSync as ot}from"fs";import{dirname as be,resolve as st}from"path";X();Oe();X();var gn=["owner","agent","person"],Qe=36e5,Ye=e=>K.includes(e.state);function he(e){return t=>!e||e.get(t)?.state!=="active"?null:e.steps(t).find(n=>n.state==="active")?.agentId??null}function H(e,t){return e.state==="waiting_owner"?{group:"owner",who:N}:e.promise&&e.owedTo&&e.owedTo!==N&&!t.isAgent(e.owedTo)?{group:"person",who:e.owedTo}:e.state==="needs_attention"?{group:"owner",who:N}:{group:"agent",who:t.activeStepAgent?.(e.id)??e.agentId}}function F(e,t,n){return Ye(e)?e.state==="needs_attention"?e.attentionReason??"needs attention":e.dueAt!==null?n>e.dueAt?`past its due time (${Ze(e.dueAt)})`:null:n-e.updatedAt>t*Qe?`no activity for ${t} h or more`:null:null}function yn(e,t,n,r){let o={owner:[],agent:[],person:[]};for(let i of e){let s=F(i,t,n);if(!s)continue;let{group:u,who:l}=H(i,r);o[u].push({request:i,group:u,who:l,why:s})}return o}function hn(e,t){return e==="owner"?"you":e==="agent"?`agent ${t}`:`${t} (outside person)`}var Ze=e=>new Date(e).toISOString().slice(0,16).replace("T"," ")+" UTC";function wn(e){if(e==null||e==="")return;let t=typeof e=="number"?e:typeof e=="string"?Date.parse(e.trim()):NaN;return!Number.isFinite(t)||t<=0?"due must be an ISO date (2030-01-31T17:00:00Z) or epoch milliseconds":t}function Sn(e){return t=>B(t,e())}var et=10;async function xn(e,t,n){let r=e.dueForCheck(n.now-n.everyMinutes*6e4,et),o=0;return await Promise.all(r.map(async i=>{e.markChecked(i.id,i.verifyState,i.verifyDetail??"",n.now);let s=await t(i.closeWhen,i).catch(u=>({verdict:"unverifiable",detail:String(u?.message??u)}));if(s.verdict==="met"){e.closeVerified(i.id,s.detail,n.now)&&(o++,n.log(`[requests] ${i.id} closed by its check: ${s.detail}`));return}e.markChecked(i.id,s.verdict==="unverifiable"?"unverified":i.verifyState==="failed"?"failed":null,s.detail,n.now)})),{checked:r.length,closed:o}}var xe=200,we=4e3,Se="Nothing, just so you know.";function W(e,t=xe){let n=e.headline?e.headline.length>t?`${e.headline.slice(0,t-1)}\u2026`:e.headline:f(e.text,t),r=e.state==="needs_attention"?`Hand it back to ${e.agentId}, or drop it.`:e.state==="waiting_owner"?e.need??(e.question?`Answer: ${f(e.question,150)}`:"Your answer."):e.state==="candidate"||e.state==="in_progress"||e.state==="waiting_other"?e.need??Se:Se;return{headline:n,need:r,said:ve(e.text)}}function ve(e){return e.replace(/```[\s\S]*?```/g," ").replace(/!?\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/^\s{0,3}(#{1,6}|>|[-*+]|\d+[.)])\s+/gm,"").replace(/[*_~`]+/g,"").replace(/\s+/g," ").trim()}function f(e,t=xe){let n=ve(e);if(n.length<=t)return n;let r=n.slice(0,t),o=Math.max(r.lastIndexOf(". "),r.lastIndexOf("? "),r.lastIndexOf("! "));return o>t/2?r.slice(0,o+1):`${r.slice(0,t-1).trimEnd()}\u2026`}function Rn(e,t,n,r){let o=n?.get(e.id),i=r?F(e,r.staleAfterHours,r.now):null,s=t.lastAnswer(e.id),u=s&&s.text.length>we?`${s.text.slice(0,we)}
|
|
31
|
+
|
|
32
|
+
\u2026`:s?.text,l=W(e);return{...e,summary:l.headline,needed:l.need,textHtml:k(e.text),why:e.state==="waiting_owner"?e.question:e.state==="needs_attention"?e.attentionReason:null,ownerNoteHtml:e.ownerNote?k(e.ownerNote):null,lastAnswer:s?{agentId:s.agentId,at:s.at,html:k(u)}:null,loop:e.promise||e.dueAt!==null||e.closeWhen?{owedTo:e.owedTo,promise:e.promise,dueAt:e.dueAt,check:e.closeWhen?J(e.closeWhen):null,verifyState:e.verifyState,verifyDetail:e.verifyDetail}:null,awaitingQa:V(e),stall:r&&i?{...H(e,{isAgent:r.isAgent,activeStepAgent:he(n)}),why:i}:null,plan:o?{state:o.state,steps:n.steps(e.id).map(p=>({idx:p.idx,name:p.name,kind:p.kind,agentId:p.agentId,state:p.state,approval:p.needsApproval?p.approval:null,evidence:p.evidence,note:p.note,nudges:p.nudges}))}:null}}var j=3,at=30*24*36e5;function ke(e){return st(e,".agentx","native-mirror.json")}function Ae(e){try{let t=JSON.parse(rt(ke(e),"utf-8"));return{...t,items:t?.items&&typeof t.items=="object"?t.items:{}}}catch{return{items:{}}}}function Ne(e,t){let n=ke(e);tt(be(n))||nt(be(n),{recursive:!0});let r=`${n}.${process.pid}.tmp`;ot(r,JSON.stringify(t,null,2)+`
|
|
33
|
+
`),it(r,n)}var ut=5*6e4;function Cn(e,t,n=Date.now()){let r=Ae(e),o=r.checkedAt?Date.parse(r.checkedAt):NaN;return!r.cards||!(n-o<=ut)?!1:r.items[`card:${t}`]?.state!=="failed"}var U=24*36e5;function Re(e,t,n){let r=e+t.dueAfterMinutes*6e4;return new Date(n!==void 0&&Number.isFinite(n)?Math.max(e,Math.min(r,n)):r)}function lt(e,t,n,r){let o=Date.parse(e.expires),i=[f(e.ask,y.ask)];return e.choices?.length&&i.push(...e.choices.map((s,u)=>`${u+1}. ${s}`)),e.recommend&&i.push(`Recommended: ${f(e.recommend,y.recommend)}`),i.push(`Answer: ${n}`,`agentx: card=${e.id}`),{key:`card:${e.id}`,title:f(e.title,y.title),notes:i.join(`
|
|
34
|
+
`),due:Re(r,t,o),priority:Number.isFinite(o)&&o-r<=U?"high":"none"}}function ct(e,t,n,r){let o=[f(e.question||e.text,y.ask),`Asked of ${e.agentId}.`,`Answer: ${n}`,`agentx: request=${e.id}`],i=e.dueAt??void 0;return{key:`request:${e.id}`,title:W(e,y.title).headline,notes:o.join(`
|
|
35
|
+
`),due:Re(r,t,i),priority:i!==void 0&&i-r<=U?"high":"none"}}async function Tn(e){let{root:t,settings:n,tasks:r,log:o}=e,i=e.now??Date.now(),s=new Date(i).toISOString(),u={created:0,completed:0,dismissed:0,failed:0},l=Ae(t);delete l.lastError;let p=a=>{l.lastError={at:s,message:a}},S=new Map;try{if(n.include.includes("card"))for(let a of e.cards())a.status==="pending"&&Date.parse(a.expires)>i&&S.set(`card:${a.id}`,lt(a,n,e.answerUrl,i));if(n.include.includes("request"))for(let a of e.requests())a.state==="waiting_owner"&&S.set(`request:${a.id}`,ct(a,n,e.answerUrl,i))}catch(a){return o(`[mirror] could not read what is waiting: ${a?.message??a}`),p(String(a?.message??a)),Ne(t,l),u}let G=!0,v=new Map,Pe=async a=>{if(!v.has(a))try{v.set(a,new Set((await r.listOpen(a)).map(c=>c.id)))}catch(c){o(`[mirror] could not read list "${a}": ${c?.message??c}`),p(String(c?.message??c)),v.set(a,null),G=!1}return v.get(a)};for(let[a,c]of Object.entries(l.items)){if(c.state!=="open"||!c.id)continue;let d=await Pe(c.list);if(d)if(S.has(a))d.has(c.id)||(l.items[a]={...c,state:"dismissed",at:s},u.dismissed++,o(`[mirror] ${a}: its task was ticked off or deleted; it stays on the Desk and is not mirrored again`));else{if(d.has(c.id))try{await r.complete(c.id)}catch(g){o(`[mirror] ${a}: could not complete its task: ${g?.message??g}`),p(String(g?.message??g));continue}l.items[a]={...c,state:"completed",at:s},u.completed++}}let E=null,x=[];for(let[a,c]of S){let d=l.items[a];if(d&&(d.state==="open"||d.state==="dismissed")||d?.state==="failed"&&d.failures>=j)continue;if(E===null)try{await r.ensureList(n.list),E=!0}catch(m){o(`[mirror] could not make list "${n.list}": ${m?.message??m}`),p(String(m?.message??m)),E=!1}let g=d?.state==="failed"?d.failures:0;try{let{id:m}=await r.add({list:n.list,title:c.title,notes:c.notes,due:c.due,priority:c.priority});l.items[a]={id:m,list:n.list,state:"open",at:s,failures:0},u.created++}catch(m){let b=String(m?.message??m),C=g+1;l.items[a]={list:n.list,state:"failed",at:s,failures:C,lastError:b},p(b),u.failed++,o(`[mirror] ${a}: could not add to Reminders (${C}/${j}): ${b}`),C===j&&x.push({title:c.title,message:b})}}let $e=l.failureToldAt?Date.parse(l.failureToldAt):NaN;if(x.length&&!(i-$e<U)){let a=x[0],c=x.length>1?` (and ${x.length-1} more)`:"";try{await e.notify("Could not add to Reminders",`${a.title}${c}: ${f(a.message,200)}. Still on the Desk.`),l.failureToldAt=s}catch(d){o(`[mirror] could not tell the owner: ${d?.message??d}`)}}G&&(l.checkedAt=s,l.cards=n.include.includes("card"));for(let[a,c]of Object.entries(l.items))c.state!=="open"&&!S.has(a)&&i-Date.parse(c.at)>at&&delete l.items[a];return Ne(t,l),u}export{gn as a,he as b,H as c,F as d,yn as e,hn as f,Ze as g,wn as h,Sn as i,xn as j,W as k,f as l,Rn as m,gt as n,Y as o,yt as p,ht as q,wt as r,St as s,xt as t,vt as u,ee as v,bt as w,Nt as x,Te as y,Me as z,_e as A,_ as B,se as C,q as D,ye as E,un as F,ln as G,cn as H,Ae as I,Cn as J,Tn as K};
|
|
36
|
+
//# sourceMappingURL=chunk-QH7R4IQS.js.map
|