agentix-cli 0.216.0 → 0.217.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.
Files changed (166) hide show
  1. package/dist/{App-YGVVIKZD.js → App-IXJCCCGN.js} +2 -2
  2. package/dist/{ChatApp-6TEK2WMU.js → ChatApp-4YCCRL5M.js} +2 -2
  3. package/dist/{absorb-eval-MJ475CNV.js → absorb-eval-YE57HA6N.js} +2 -2
  4. package/dist/{adapter-C6YORAE6.js → adapter-CRVWPQBN.js} +2 -2
  5. package/dist/{agent-44SGRWX2.js → agent-CTZN3P2K.js} +2 -2
  6. package/dist/{board-dashboard-TZKV4DFV.js → board-dashboard-2WE2HBEW.js} +621 -394
  7. package/dist/board-dashboard-2WE2HBEW.js.map +1 -0
  8. package/dist/{chunk-U5DSMDCJ.js → chunk-2F7KQ4DJ.js} +2 -2
  9. package/dist/{chunk-5SQRJUAK.js → chunk-2MAKXLK2.js} +3 -3
  10. package/dist/{chunk-2KQECT4H.js → chunk-3B7RH3IK.js} +2 -2
  11. package/dist/{chunk-2ZNYIHRB.js → chunk-3C6UDZDX.js} +2 -2
  12. package/dist/{chunk-F32VADB7.js → chunk-56UTQ4FU.js} +2 -2
  13. package/dist/{chunk-I4E6BH27.js → chunk-5FFNFW4C.js} +2 -2
  14. package/dist/{chunk-I4E6BH27.js.map → chunk-5FFNFW4C.js.map} +1 -1
  15. package/dist/{chunk-BLKXK27S.js → chunk-64IVC2G6.js} +2 -2
  16. package/dist/{chunk-TO6T6AQY.js → chunk-AOPNASCE.js} +2 -2
  17. package/dist/chunk-BXK5S2KK.js +13 -0
  18. package/dist/chunk-BXK5S2KK.js.map +1 -0
  19. package/dist/{chunk-F2XNWKIL.js → chunk-ELC3M5WS.js} +393 -434
  20. package/dist/chunk-ELC3M5WS.js.map +1 -0
  21. package/dist/{chunk-IKXDCPXS.js → chunk-FFLMSNTN.js} +2 -2
  22. package/dist/{chunk-WLDRIJQX.js → chunk-GEKEILPL.js} +5 -5
  23. package/dist/{chunk-T3B7OUDC.js → chunk-I4FXWN7I.js} +2 -2
  24. package/dist/{chunk-3UATFGSB.js → chunk-IP67DTXX.js} +2 -2
  25. package/dist/chunk-KBSQRQPF.js +10 -0
  26. package/dist/chunk-KBSQRQPF.js.map +1 -0
  27. package/dist/{chunk-TFHJT2AZ.js → chunk-LLNLDZNA.js} +2 -2
  28. package/dist/{chunk-LDSBFDYB.js → chunk-LSFLSB7C.js} +2 -2
  29. package/dist/{chunk-YTWRIIAT.js → chunk-M42GMRZF.js} +2 -2
  30. package/dist/{chunk-PA7CP74O.js → chunk-MFZNBE65.js} +2 -2
  31. package/dist/{chunk-GEKJQ7VV.js → chunk-NFUHYIYG.js} +2 -2
  32. package/dist/chunk-O2YDS2P3.js +8 -0
  33. package/dist/chunk-O2YDS2P3.js.map +1 -0
  34. package/dist/{chunk-LJUBWMPB.js → chunk-OJ4RUZZY.js} +2 -2
  35. package/dist/chunk-PZ2F6J2E.js +134 -0
  36. package/dist/chunk-PZ2F6J2E.js.map +1 -0
  37. package/dist/{chunk-AU7SN4G3.js → chunk-Q432O462.js} +2 -2
  38. package/dist/{chunk-T7SD5EVH.js → chunk-QEOGWSRR.js} +2 -2
  39. package/dist/{chunk-7OJUZ3L5.js → chunk-QGRIW7SE.js} +2 -2
  40. package/dist/{chunk-SZXFWCKA.js → chunk-RKKAP4EY.js} +2 -2
  41. package/dist/{chunk-JTS563OC.js → chunk-SJJ7QEFE.js} +2 -2
  42. package/dist/{chunk-6UTOBSEA.js → chunk-SYIDD7CI.js} +2 -2
  43. package/dist/{chunk-XXFVK5D7.js → chunk-WHAMZPEG.js} +141 -87
  44. package/dist/chunk-WHAMZPEG.js.map +1 -0
  45. package/dist/{chunk-JNBUJKNG.js → chunk-X2GBLX3E.js} +2 -2
  46. package/dist/{chunk-M4H2RYP4.js → chunk-XQH4LCZR.js} +2 -2
  47. package/dist/{chunk-MH7KJQ4N.js → chunk-YXGZSVPY.js} +2 -2
  48. package/dist/{chunk-JMWPBZLU.js → chunk-Z5HYCMDF.js} +2 -2
  49. package/dist/cli.js +1 -1
  50. package/dist/{client-SJLHZDIC.js → client-UPXDV3SM.js} +2 -2
  51. package/dist/{config-Q3ENZQYL.js → config-LAM4HUTA.js} +2 -2
  52. package/dist/{config-mutate-NNAUMQ2Y.js → config-mutate-P4QLFUVH.js} +2 -2
  53. package/dist/{config-mutator-2F2BJNMA.js → config-mutator-RIPSMYAO.js} +2 -2
  54. package/dist/{contributions-SOUGZCAH.js → contributions-SHSEI3TX.js} +2 -2
  55. package/dist/{doctor-H6I433KY.js → doctor-TLDBNHYM.js} +2 -2
  56. package/dist/{follow-up-tool-4FX455DL.js → follow-up-tool-VM4ZDRC5.js} +2 -2
  57. package/dist/{follow-up-tool-4FX455DL.js.map → follow-up-tool-VM4ZDRC5.js.map} +1 -1
  58. package/dist/{grants-U2734ZHZ.js → grants-ZA35QVTX.js} +2 -2
  59. package/dist/{hub-XFZFHLJK.js → hub-7Y6ZUVJV.js} +2 -2
  60. package/dist/index.d.ts +30 -1
  61. package/dist/index.js +1 -1
  62. package/dist/org-tool-TOHI7MBS.js +2 -0
  63. package/dist/{org-tool-OE5QP6W7.js.map → org-tool-TOHI7MBS.js.map} +1 -1
  64. package/dist/{program-7QFRDJUY.js → program-QZKK3Y2W.js} +308 -308
  65. package/dist/program-QZKK3Y2W.js.map +1 -0
  66. package/dist/{promote-FQY3HNL6.js → promote-OBTQ3ZUN.js} +2 -2
  67. package/dist/{query-LIII4CGT.js → query-K6NR3GQE.js} +2 -2
  68. package/dist/{query-settings-6LHW2NCF.js → query-settings-NIZBB73K.js} +2 -2
  69. package/dist/{registry-WQNBXOUL.js → registry-B7X6YGS7.js} +2 -2
  70. package/dist/{request-planner-HYYT3W7X.js → request-planner-YDIX4BQW.js} +2 -2
  71. package/dist/{review-candidates-JOCZEZ2L.js → review-candidates-3QCCHXWM.js} +2 -2
  72. package/dist/{routing-D7W4BDER.js → routing-BGMIY5JY.js} +2 -2
  73. package/dist/schedule-tool-P6XM6W3S.js +2 -0
  74. package/dist/{scheduler-JHY767T4.js → scheduler-PUKN5YSL.js} +2 -2
  75. package/dist/{seat-44NEMWB5.js → seat-OTAJJ5BP.js} +2 -2
  76. package/dist/{select-5FMPLCCG.js → select-KKMXIVVL.js} +2 -2
  77. package/dist/{set-enabled-GVQFNLOS.js → set-enabled-BNF427ZN.js} +2 -2
  78. package/dist/{sprint-tool-X3A5VPJP.js → sprint-tool-Y72HTX5X.js} +2 -2
  79. package/dist/{sprint-tool-X3A5VPJP.js.map → sprint-tool-Y72HTX5X.js.map} +1 -1
  80. package/dist/{tool-KCOCIAFM.js → tool-DW6MYEG2.js} +2 -2
  81. package/dist/{tool-KCOCIAFM.js.map → tool-DW6MYEG2.js.map} +1 -1
  82. package/dist/tool-EA4FWTH6.js +2 -0
  83. package/dist/{tool-QIS3CLU2.js → tool-F4ZVMX4J.js} +2 -2
  84. package/dist/{tool-QIS3CLU2.js.map → tool-F4ZVMX4J.js.map} +1 -1
  85. package/dist/{tool-H7RMHTXM.js → tool-HUOT3I42.js} +2 -2
  86. package/dist/{tool-H7RMHTXM.js.map → tool-HUOT3I42.js.map} +1 -1
  87. package/dist/tool-QDAD4ACK.js +4 -0
  88. package/dist/{tool-ILYSRPZ5.js.map → tool-QDAD4ACK.js.map} +1 -1
  89. package/dist/{wiki-UMPPYYFR.js → wiki-J6MSHSVD.js} +2 -2
  90. package/dist/wiki-enrich-3Y3TZ6ZK.js +2 -0
  91. package/dist/{workspace-setup-VGXHYCD5.js → workspace-setup-CQ5FMT2B.js} +2 -2
  92. package/dist/workspace-setup-CQ5FMT2B.js.map +1 -0
  93. package/package.json +1 -1
  94. package/dist/board-dashboard-TZKV4DFV.js.map +0 -1
  95. package/dist/chunk-4A6UVU2X.js +0 -134
  96. package/dist/chunk-4A6UVU2X.js.map +0 -1
  97. package/dist/chunk-F2XNWKIL.js.map +0 -1
  98. package/dist/chunk-MOEXP6U3.js +0 -8
  99. package/dist/chunk-MOEXP6U3.js.map +0 -1
  100. package/dist/chunk-OQQTV3OF.js +0 -12
  101. package/dist/chunk-OQQTV3OF.js.map +0 -1
  102. package/dist/chunk-RKPAVWXF.js +0 -2
  103. package/dist/chunk-RKPAVWXF.js.map +0 -1
  104. package/dist/chunk-XXFVK5D7.js.map +0 -1
  105. package/dist/org-tool-OE5QP6W7.js +0 -2
  106. package/dist/program-7QFRDJUY.js.map +0 -1
  107. package/dist/schedule-tool-B4RDOKCN.js +0 -2
  108. package/dist/tool-ILYSRPZ5.js +0 -4
  109. package/dist/tool-Z7TIGVEW.js +0 -7
  110. package/dist/tool-Z7TIGVEW.js.map +0 -1
  111. package/dist/wiki-enrich-UVCZ7GTW.js +0 -2
  112. /package/dist/{App-YGVVIKZD.js.map → App-IXJCCCGN.js.map} +0 -0
  113. /package/dist/{ChatApp-6TEK2WMU.js.map → ChatApp-4YCCRL5M.js.map} +0 -0
  114. /package/dist/{absorb-eval-MJ475CNV.js.map → absorb-eval-YE57HA6N.js.map} +0 -0
  115. /package/dist/{adapter-C6YORAE6.js.map → adapter-CRVWPQBN.js.map} +0 -0
  116. /package/dist/{agent-44SGRWX2.js.map → agent-CTZN3P2K.js.map} +0 -0
  117. /package/dist/{chunk-U5DSMDCJ.js.map → chunk-2F7KQ4DJ.js.map} +0 -0
  118. /package/dist/{chunk-5SQRJUAK.js.map → chunk-2MAKXLK2.js.map} +0 -0
  119. /package/dist/{chunk-2KQECT4H.js.map → chunk-3B7RH3IK.js.map} +0 -0
  120. /package/dist/{chunk-2ZNYIHRB.js.map → chunk-3C6UDZDX.js.map} +0 -0
  121. /package/dist/{chunk-F32VADB7.js.map → chunk-56UTQ4FU.js.map} +0 -0
  122. /package/dist/{chunk-BLKXK27S.js.map → chunk-64IVC2G6.js.map} +0 -0
  123. /package/dist/{chunk-TO6T6AQY.js.map → chunk-AOPNASCE.js.map} +0 -0
  124. /package/dist/{chunk-IKXDCPXS.js.map → chunk-FFLMSNTN.js.map} +0 -0
  125. /package/dist/{chunk-WLDRIJQX.js.map → chunk-GEKEILPL.js.map} +0 -0
  126. /package/dist/{chunk-T3B7OUDC.js.map → chunk-I4FXWN7I.js.map} +0 -0
  127. /package/dist/{chunk-3UATFGSB.js.map → chunk-IP67DTXX.js.map} +0 -0
  128. /package/dist/{chunk-TFHJT2AZ.js.map → chunk-LLNLDZNA.js.map} +0 -0
  129. /package/dist/{chunk-LDSBFDYB.js.map → chunk-LSFLSB7C.js.map} +0 -0
  130. /package/dist/{chunk-YTWRIIAT.js.map → chunk-M42GMRZF.js.map} +0 -0
  131. /package/dist/{chunk-PA7CP74O.js.map → chunk-MFZNBE65.js.map} +0 -0
  132. /package/dist/{chunk-GEKJQ7VV.js.map → chunk-NFUHYIYG.js.map} +0 -0
  133. /package/dist/{chunk-LJUBWMPB.js.map → chunk-OJ4RUZZY.js.map} +0 -0
  134. /package/dist/{chunk-AU7SN4G3.js.map → chunk-Q432O462.js.map} +0 -0
  135. /package/dist/{chunk-T7SD5EVH.js.map → chunk-QEOGWSRR.js.map} +0 -0
  136. /package/dist/{chunk-7OJUZ3L5.js.map → chunk-QGRIW7SE.js.map} +0 -0
  137. /package/dist/{chunk-SZXFWCKA.js.map → chunk-RKKAP4EY.js.map} +0 -0
  138. /package/dist/{chunk-JTS563OC.js.map → chunk-SJJ7QEFE.js.map} +0 -0
  139. /package/dist/{chunk-6UTOBSEA.js.map → chunk-SYIDD7CI.js.map} +0 -0
  140. /package/dist/{chunk-JNBUJKNG.js.map → chunk-X2GBLX3E.js.map} +0 -0
  141. /package/dist/{chunk-M4H2RYP4.js.map → chunk-XQH4LCZR.js.map} +0 -0
  142. /package/dist/{chunk-MH7KJQ4N.js.map → chunk-YXGZSVPY.js.map} +0 -0
  143. /package/dist/{chunk-JMWPBZLU.js.map → chunk-Z5HYCMDF.js.map} +0 -0
  144. /package/dist/{client-SJLHZDIC.js.map → client-UPXDV3SM.js.map} +0 -0
  145. /package/dist/{config-Q3ENZQYL.js.map → config-LAM4HUTA.js.map} +0 -0
  146. /package/dist/{config-mutate-NNAUMQ2Y.js.map → config-mutate-P4QLFUVH.js.map} +0 -0
  147. /package/dist/{config-mutator-2F2BJNMA.js.map → config-mutator-RIPSMYAO.js.map} +0 -0
  148. /package/dist/{contributions-SOUGZCAH.js.map → contributions-SHSEI3TX.js.map} +0 -0
  149. /package/dist/{doctor-H6I433KY.js.map → doctor-TLDBNHYM.js.map} +0 -0
  150. /package/dist/{grants-U2734ZHZ.js.map → grants-ZA35QVTX.js.map} +0 -0
  151. /package/dist/{hub-XFZFHLJK.js.map → hub-7Y6ZUVJV.js.map} +0 -0
  152. /package/dist/{promote-FQY3HNL6.js.map → promote-OBTQ3ZUN.js.map} +0 -0
  153. /package/dist/{query-LIII4CGT.js.map → query-K6NR3GQE.js.map} +0 -0
  154. /package/dist/{query-settings-6LHW2NCF.js.map → query-settings-NIZBB73K.js.map} +0 -0
  155. /package/dist/{registry-WQNBXOUL.js.map → registry-B7X6YGS7.js.map} +0 -0
  156. /package/dist/{request-planner-HYYT3W7X.js.map → request-planner-YDIX4BQW.js.map} +0 -0
  157. /package/dist/{review-candidates-JOCZEZ2L.js.map → review-candidates-3QCCHXWM.js.map} +0 -0
  158. /package/dist/{routing-D7W4BDER.js.map → routing-BGMIY5JY.js.map} +0 -0
  159. /package/dist/{schedule-tool-B4RDOKCN.js.map → schedule-tool-P6XM6W3S.js.map} +0 -0
  160. /package/dist/{scheduler-JHY767T4.js.map → scheduler-PUKN5YSL.js.map} +0 -0
  161. /package/dist/{seat-44NEMWB5.js.map → seat-OTAJJ5BP.js.map} +0 -0
  162. /package/dist/{select-5FMPLCCG.js.map → select-KKMXIVVL.js.map} +0 -0
  163. /package/dist/{set-enabled-GVQFNLOS.js.map → set-enabled-BNF427ZN.js.map} +0 -0
  164. /package/dist/{wiki-UMPPYYFR.js.map → tool-EA4FWTH6.js.map} +0 -0
  165. /package/dist/{wiki-enrich-UVCZ7GTW.js.map → wiki-J6MSHSVD.js.map} +0 -0
  166. /package/dist/{workspace-setup-VGXHYCD5.js.map → wiki-enrich-3Y3TZ6ZK.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
  ${l}`,is_error:!0}:{tool_use_id:e.id,content:l||"(no output)"}}async editFile(e){let t=String(e.input.path||""),o=e.input.edits,r=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:r,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 ne.readFile(r,"utf8"),l=[];for(let a of o)i.includes(a.old_text)?(i=i.replace(a.old_text,a.new_text),l.push(`Replaced: "${a.old_text.slice(0,40)}..."`)):l.push(`Not found: "${a.old_text.slice(0,40)}..."`);return this.options.dryRun||await ne.writeFile(r,i,"utf8"),f.has("post:file-write")&&await f.execute("post:file-write",{event:"post:file-write",file:r,fileContent:i,cwd:this.cwd}),{tool_use_id:e.id,content:`Edited ${t}:
50
50
  ${l.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||""),r=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-WQNBXOUL.js"),l=i();if(!l)return{tool_use_id:e.id,content:"Sub-agent spawning requires the daemon to be running.",is_error:!0};let p=await new s(l).spawn({targetAgentId:t,prompt:o,parentAgentId:"orchestrator",timeout:r*1e3});return p.success?{tool_use_id:e.id,content:`Sub-agent "${t}" completed (${Math.round(p.duration/1e3)}s):
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||""),r=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-B7X6YGS7.js"),l=i();if(!l)return{tool_use_id:e.id,content:"Sub-agent spawning requires the daemon to be running.",is_error:!0};let p=await new s(l).spawn({targetAgentId:t,prompt:o,parentAgentId:"orchestrator",timeout:r*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,r=t;return o?.length&&(r+=`
54
54
  Options: ${o.join(", ")}`),{tool_use_id:e.id,content:"Question sent to user.",followUp:r}}};async function Oe(n){let{provider:e,systemPrompt:t,messages:o,providerOptions:r,cwd:s,maxIterations:i=20,enabledTools:l,interactive:a=!0,overwrite:p=!1,dryRun:c=!1,onProgress:d,abortSignal:u}=n,m=u?{...r,abortSignal:u}:r;if(!e.generateRaw)return mt(n);let I=new se(s,{interactive:a,overwrite:p,dryRun:c,acmeContext:n.acmeContext,abortSignal:u}),D=be(l);if(n.acmeContext)for(let g of ct)D.push({name:g.name,description:g.description,input_schema:g.input_schema});let E=new Set;if(n.mcpTools?.length)for(let g of n.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,O=0,A="",j,_=0;for(;_<i;){if(_++,u?.aborted)throw new Error("cancelled");d?.({type:"iteration_start",iteration:_}),k.step(_,`Agentic loop iteration (${D.length} tools available)`);let g,M=!!e.generateRawStream&&!!d;try{if(M){let S=null,H=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"?S=x.result:x.type==="error"&&(H=x.error);if(H&&!S)throw new Error(H);if(!S)throw new Error("generateRawStream returned no raw_result event");g=S,g._streamedText=v}else g=await e.generateRaw(C,t,D,m)}catch(S){if(S.message?.includes("not available"))return mt(n);throw S}G+=g.usage.input_tokens+g.usage.output_tokens,F+=g.usage.input_tokens,O+=g.usage.output_tokens;let P=g._streamedText;for(let S of g.content)S.type==="text"&&(A+=S.text,P===void 0&&d?.({type:"text_delta",text:S.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 S=g.content.filter(v=>v.type==="tool_use");if(S.length===0)break;C.push({role:"assistant",content:g.content});let H=[];for(let v of S){d?.({type:"tool_call",name:v.name,id:v.id,input:v.input}),k.step(_,`Tool call: ${v.name}`);let x;if(E.has(v.name)&&n.mcpDispatch){let h=await n.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),H.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:H}),j)break;continue}break}return d?.({type:"complete",iterations:_,totalTokens:G}),{files:B,content:A,followUp:j,tokensUsed:G,inputTokens:F||void 0,outputTokens:O||void 0,iterations:_}}async function mt(n){let{provider:e,systemPrompt:t,messages:o,providerOptions:r,maxIterations:s=5}=n,l=[{role:"system",content:t+`
@@ -123,4 +123,4 @@ ${n.projectInstructions}`),n.memoryContext&&o.push(n.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{We as a,Xt as b,Qt as c,Je as d,Ke as e,Xe as f,Qe as g,Pe as h,ee as i,Re as j,ce as k,te as l,Pt as m,oe as n,Et as o,f as p,ot as q,rt as r,Me as s,de as t,W as u,re as v,lt as w,Ee as x,$e as y,se as z,gt as A,tn as B,on as C};
126
- //# sourceMappingURL=chunk-JNBUJKNG.js.map
126
+ //# sourceMappingURL=chunk-X2GBLX3E.js.map
@@ -1,4 +1,4 @@
1
- import{q as j,r as R,t as F}from"./chunk-OQQTV3OF.js";import{f as L,g as G}from"./chunk-LY4G7PCW.js";import{existsSync as y,mkdirSync as ae,writeFileSync as S,readFileSync as A}from"fs";import{resolve as m}from"path";import{createHash as Ye}from"crypto";import{readFileSync as me,existsSync as fe,unlinkSync as ye,readdirSync as mt}from"fs";import{resolve as H}from"path";function yt(e,n){let r={},s=t=>{let o=H(e,t);if(fe(o))try{return me(o,"utf-8").trim()||void 0}catch{return}};if(n){let t=s(`SOUL.${n}.md`);t?(r.soul=t,r.soulProfile=n):r.soul=s("SOUL.md")}else r.soul=s("SOUL.md");if(r.identity=s("IDENTITY.md"),r.user=s("USER.md"),r.agents=s("AGENTS.md"),r.bootstrap=s("BOOTSTRAP.md"),r.bootstrap)try{ye(H(e,"BOOTSTRAP.md"))}catch{}return r}function bt(e){let n=[];return e.identity&&n.push(`[Identity]
1
+ import{r as j,s as R,u as F}from"./chunk-BXK5S2KK.js";import{f as L,g as G}from"./chunk-LY4G7PCW.js";import{existsSync as y,mkdirSync as ae,writeFileSync as S,readFileSync as A}from"fs";import{resolve as m}from"path";import{createHash as Ye}from"crypto";import{readFileSync as me,existsSync as fe,unlinkSync as ye,readdirSync as mt}from"fs";import{resolve as H}from"path";function yt(e,n){let r={},s=t=>{let o=H(e,t);if(fe(o))try{return me(o,"utf-8").trim()||void 0}catch{return}};if(n){let t=s(`SOUL.${n}.md`);t?(r.soul=t,r.soulProfile=n):r.soul=s("SOUL.md")}else r.soul=s("SOUL.md");if(r.identity=s("IDENTITY.md"),r.user=s("USER.md"),r.agents=s("AGENTS.md"),r.bootstrap=s("BOOTSTRAP.md"),r.bootstrap)try{ye(H(e,"BOOTSTRAP.md"))}catch{}return r}function bt(e){let n=[];return e.identity&&n.push(`[Identity]
2
2
  ${e.identity}`),e.soul&&n.push(`[Personality & Boundaries]
3
3
  ${e.soul}`),e.user&&n.push(`[User Profile]
4
4
  ${e.user}`),e.bootstrap&&n.push(`[First-Run Instructions \u2014 one time only]
@@ -112,4 +112,4 @@ Always include:
112
112
  5. Screenshots if applicable
113
113
  `});break}return s}function ut(e,n,r="19900",s=console.error){let t=[],o=[],i=n.workspace;if(!y(i))return s(`Workspace not found: ${i}`),{created:t,skipped:o};if(n.tier!=="claude-code"&&n.tier!=="codex-cli")return{created:t,skipped:o};let a=(c,p)=>{y(c)?o.push(c):(ae(m(c,".."),{recursive:!0}),S(c,p),t.push(c))},l=(c,p,g)=>{if(!y(c)){ae(m(c,".."),{recursive:!0}),S(c,p),t.push(c);return}let d;try{d=A(c,"utf8")}catch{o.push(c);return}let f=Ve(d);if(f===null){o.push(c);return}if(f===g){o.push(c);return}S(c,p),t.push(`${c} (refreshed)`)};if(a(m(i,"AGENTS.md"),W({name:n.name,id:e,role:n.systemPrompt?.split(`
114
114
  `)[0],workspace:i,tier:n.tier})),n.tier==="codex-cli")return t.length>0&&s(`[${e}] workspace setup: created ${t.length} file(s)`),{created:t,skipped:o};l(m(i,"CLAUDE.md"),ze(e,n,r),ce(n));let u=m(i,".claude/settings.json");a(u,JSON.stringify(it(e,n,r),null,2));let h=ct(e,n);for(let c of h){let p=m(i,".claude/rules",c.name);c.replaces&&y(p)&&c.replaces.includes(A(p,"utf8"))?(S(p,c.content),t.push(p)):a(p,c.content)}return t.length>0&&s(`[${e}] workspace setup: created ${t.length} file(s)`),{created:t,skipped:o}}function lt(e,n){let r=m(e,".claude/settings.json");if(!y(r))return!1;try{let s=JSON.parse(A(r,"utf-8")),t=!1;for(let[o,i]of Object.entries(n))if(typeof i=="object"&&i!==null&&!Array.isArray(i)){s[o]||(s[o]={});for(let[a,l]of Object.entries(i))s[o][a]===void 0&&(s[o][a]=l,t=!0)}else s[o]===void 0&&(s[o]=i,t=!0);return t&&S(r,JSON.stringify(s,null,2)),t}catch{return!1}}function pt(e,n,r="19900",s){let t=m(e,".claude/settings.json");if(!y(t))return!1;try{let o=JSON.parse(A(t,"utf-8")),i=!1,a=o.permissions??={},l=Array.isArray(a.deny)?a.deny:a.deny=[];for(let d of P)l.includes(d)||(l.push(d),i=!0);let u=o.hooks??={},c=[...Array.isArray(u.PreToolUse)?u.PreToolUse.filter(d=>!ot(d)):[],...pe(n,r,s)];JSON.stringify(u.PreToolUse??null)!==JSON.stringify(c)&&(u.PreToolUse=c,i=!0);let g=[...Array.isArray(u.PostToolUse)?u.PostToolUse.filter(d=>!rt(d)):[],de(r)];return JSON.stringify(u.PostToolUse??null)!==JSON.stringify(g)&&(u.PostToolUse=g,i=!0),i&&S(t,JSON.stringify(o,null,2)),i}catch{return!1}}function dt(e){return Array.isArray(e?.hooks)&&e.hooks.some(n=>typeof n?.command=="string"&&n.command.includes(D))}function ht(e,n,r,s){let t=m(e,".claude/settings.json");if(!y(t))return!1;try{let o=JSON.parse(A(t,"utf-8")),i=JSON.stringify(o),a=s.enabled&&s.tools.length>0,l=`Read(/${te(s.dir,n)}/**)`,u=Array.isArray(o.hooks?.PostToolUse)?o.hooks.PostToolUse:[],h=u.filter(g=>!dt(g)),c=Array.isArray(o.permissions?.allow)?o.permissions.allow:[],p=c.filter(g=>g!==l);if(a){let d=`curl -s --max-time 5 -H 'Content-Type: application/json' --data-binary @- '${`http://127.0.0.1:${r}${D}?agent=${encodeURIComponent(n)}`}' 2>/dev/null || true`;h.push({matcher:s.tools.join("|"),hooks:[{type:"command",command:d,timeout:10}]}),p.push(l)}return(a||u.length>0)&&((o.hooks??={}).PostToolUse=h),(a||c.length>0)&&((o.permissions??={}).allow=p),JSON.stringify(o)===i?!1:(S(t,JSON.stringify(o,null,2)),!0)}catch{return!1}}function Vt(e,n="19900",r=console.error,s){let t=0,o=0,i=0,a=0,l=0,u=0;for(let[h,c]of Object.entries(e)){if(c.tier!=="claude-code"&&c.tier!=="codex-cli")continue;let p=ut(h,c,n,r);if(t+=p.created.length,c.tier==="claude-code"&&lt(c.workspace,{env:{CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS:"1"}})&&o++,c.tier==="claude-code"&&pt(c.workspace,h,n,c.mcp)&&i++,c.tier==="claude-code"&&s){let g=ne(c.permissionMode);s.enabled&&!g&&u++;let d=s.enabled&&g;ht(c.workspace,h,n,{...s,enabled:d})&&(d?a++:l++)}}t>0&&r(`Workspace setup: ${t} file(s) created across agent workspaces`),o>0&&r(`Workspace patch: ${o} workspace(s) updated with agent teams support`),i>0&&r(`Guardrails: ${i} workspace(s) backfilled with deny list + PreToolUse guard hook`),a>0&&r(`ObservationPack: PostToolUse hook written to ${a} workspace(s)`),l>0&&r(`ObservationPack: PostToolUse hook removed from ${l} workspace(s)`),u>0&&r(`ObservationPack: ${u} agent(s) not packed: permissionMode is not "bypassPermissions", so they could not read a saved original back`)}export{yt as a,bt as b,kt as c,St as d,At as e,D as f,Et as g,te as h,ne as i,vt as j,Dt as k,Mt as l,We as m,M as n,Gt as o,ie as p,Ve as q,ze as r,le as s,et as t,tt as u,nt as v,ut as w,pt as x,ht as y,Vt as z};
115
- //# sourceMappingURL=chunk-M4H2RYP4.js.map
115
+ //# sourceMappingURL=chunk-XQH4LCZR.js.map
@@ -1,4 +1,4 @@
1
- import{a as Ze,b as k,c as D,d as ea,e as fe,f as he,g as H,h as be,i as L,j as N,n as aa,o as ta,p as ra,q as na}from"./chunk-EFGAPAYZ.js";import{e as Ve,i as Qe}from"./chunk-QAWKN2N4.js";import{b as me}from"./chunk-DODL5POT.js";import{Fb as Ge,Ra as Ke,Sa as Ye,Ta as Je,Va as Xe,c as Le,pa as _,ua as qe}from"./chunk-XXFVK5D7.js";import{a as V}from"./chunk-IMLAPB7G.js";import{k as Be}from"./chunk-IKXDCPXS.js";import{b as Q}from"./chunk-2VDO2HEK.js";import{c as Ne,e as We}from"./chunk-LQE73AZR.js";import{a as Z,b as Ue}from"./chunk-2ZNYIHRB.js";import{b as Fe}from"./chunk-MRIVENBY.js";import{ia as G}from"./chunk-2KQECT4H.js";import{b as ue}from"./chunk-7AB3QUGH.js";import{a as K,b as X}from"./chunk-LDSBFDYB.js";import{r as ge,t as Oe}from"./chunk-OQQTV3OF.js";import{b as He}from"./chunk-TFHJT2AZ.js";import{c as De,d as Me}from"./chunk-OWNQ2FD4.js";import{a as je}from"./chunk-ROLSSYXE.js";import{B as le,Cb as Ee,E as F,Jb as at,K as Za,Na as ce,Oa as Pe,Za as et,ec as pe,ic as q,jc as Re,tc as xe}from"./chunk-4A6UVU2X.js";import{existsSync as Y,readFileSync as xa,writeFileSync as ga,appendFileSync as lt,mkdirSync as ct}from"fs";import{dirname as pt,resolve as M}from"path";import{fileURLToPath as xt}from"url";import{hostname as gt}from"os";import{spawn as ut}from"child_process";var ve=`:root {
1
+ import{a as Ze,b as k,c as D,d as ea,e as fe,f as he,g as H,h as be,i as L,j as N,n as aa,o as ta,p as ra,q as na}from"./chunk-EFGAPAYZ.js";import{e as Ve,i as Qe}from"./chunk-QAWKN2N4.js";import{b as me}from"./chunk-DODL5POT.js";import{Kb as Ge,Wa as Ke,Xa as Ye,Ya as Je,_a as Xe,c as Le,ua as _,za as qe}from"./chunk-WHAMZPEG.js";import{a as V}from"./chunk-IMLAPB7G.js";import{k as Be}from"./chunk-FFLMSNTN.js";import{b as Q}from"./chunk-2VDO2HEK.js";import{c as Ne,e as We}from"./chunk-LQE73AZR.js";import{a as Z,b as Ue}from"./chunk-3C6UDZDX.js";import{b as Fe}from"./chunk-MRIVENBY.js";import{ia as G}from"./chunk-3B7RH3IK.js";import{b as ue}from"./chunk-7AB3QUGH.js";import{a as K,b as X}from"./chunk-LSFLSB7C.js";import{s as ge,u as Oe}from"./chunk-BXK5S2KK.js";import{b as He}from"./chunk-LLNLDZNA.js";import{c as De,d as Me}from"./chunk-OWNQ2FD4.js";import{a as je}from"./chunk-ROLSSYXE.js";import{Bc as xe,J as le,Kb as Ee,M as F,Rb as at,S as Za,Va as ce,Wa as Pe,fb as et,mc as pe,qc as q,rc as Re}from"./chunk-PZ2F6J2E.js";import{existsSync as Y,readFileSync as xa,writeFileSync as ga,appendFileSync as lt,mkdirSync as ct}from"fs";import{dirname as pt,resolve as M}from"path";import{fileURLToPath as xt}from"url";import{hostname as gt}from"os";import{spawn as ut}from"child_process";var ve=`:root {
2
2
  /* --- Brand (agentina) --------------------------------------------- */
3
3
  --ax-blue: #2979FF;
4
4
  --ax-blue-d: #1B5FD9;
@@ -2903,4 +2903,4 @@ tr:hover td { background: var(--bg-hover); }
2903
2903
  ${r}`).all(a,...t,...n).map(i=>({id:i.id,state:i.state,channel:i.channel,agentId:i.agent_id,text:i.text,createdAt:i.created_at})):[]}function Qo(e,a){return Ua(e,a,ce,"ORDER BY created_at")}function Zo(e,a,t=50){return Ua(e,a,[...ce,...Pe],"ORDER BY created_at DESC, rowid DESC LIMIT ?",Math.max(1,Math.min(t,500)))}at();var ze="member:",pr=90,xr="members",gr="tailscale-user-login",ur=400,mr=60*60*1e3;function fr(e){let a=e.scopes.find(t=>t.startsWith(ze));return a?a.slice(ze.length):null}function qa(e,a){if(!e)return null;let t=a.verify(e),r=t?fr(t):null;return t&&r?{rec:t,personId:r}:null}function ii(e,a){let t=e.people().find(s=>s.id===a);if(!t)return{ok:!1,error:`No person "${a}". Add them first: agentx people add ${a} --name "\u2026"`};let{token:r,record:n}=e.tokens.create({name:`${t.name} (machine not paired yet)`,scopes:[`${ze}${t.id}`],expiresInDays:pr}),{code:o,expiresAt:i}=e.codes.create({token:r,tokenId:n.id,name:t.id});return e.members.log({person:t.id,device:n.id,event:"invited"}),{ok:!0,code:o,expiresAt:i,tokenId:n.id,person:t}}var hr=Math.round(Ne/6e4);function br(e){return e==="client"?"Your project":"My work"}function si(e){let a=br(e.person.role),t=e.person.role==="client"?`I use AgentX to keep track of the work I do for you. It has a page for you, "${a}": 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, "${a}": what you asked the agents for, and where each request stands.`;return[`Hi ${e.person.name},`,"",t,"","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: ${We(e.code)}`,` The code works once, for ${hr} 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(`
2904
2904
  `)}var vr="The private network says someone else is connecting from this machine. Ask the person who invited you for a new code.",wr="Too many machines are waiting for the owner's answer. Try again later.",Fa="That code didn't work. Check it, or ask the person who invited you for a new one.",Ka=(e,a)=>{let t=e.headers[a];return(Array.isArray(t)?t[0]:t||"").trim()};function Ya(e){let a=e.socket?.remoteAddress||"";return a==="127.0.0.1"||a==="::1"||a==="::ffff:127.0.0.1"}function yr(e){if(!Ya(e))return null;let a=Ka(e,gr).toLowerCase();return a?a.slice(0,80):null}function kr(e){let a=e.socket?.remoteAddress||"unknown";if(!Ya(e))return a;let t=Ka(e,"x-forwarded-for").split(",").pop().trim();return/^[0-9a-fA-F:.]{2,45}$/.test(t)?t:a}function $r(e){return typeof e=="string"?e.replace(/[^\p{L}\p{N} ._'()-]/gu," ").replace(/\s+/g," ").trim().slice(0,60):""}function _r(e){return e.identities.map(Ee).filter(a=>!!a&&a.channel==="tailscale").map(a=>a.value)}async function di(e,a){let t=Date.now(),r=a.now??Date.now,n=a.log??(b=>console.log(b)),o=kr(e),i=a.limiter.retryAfter(o);if(i>0)return n(`[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,d="";try{let b=await Q(e,2048);s=b.code,d=$r(b.machine)}catch{}let l=a.codes.redeem(s),c=l?qa(l.token,a.tokens):null;if(await Cr(t,a.minMs??ur),!l||!c)return a.limiter.fail(o),n(`[member] pair-code failed from ${o}`),{status:401,body:{error:Fa}};a.limiter.succeed(o);let{rec:m,personId:g}=c,u=a.people().find(b=>b.id===g);if(!u)return a.tokens.revoke(m.id),a.members.log({person:g,device:m.id,event:"refused",address:o,detail:"person no longer listed"}),n(`[member] pair-code for ${g} refused from ${o}: person no longer listed`),{status:403,body:{error:Fa}};let x=yr(e),f=_r(u);if(f.length&&(!x||!f.includes(x)))return a.tokens.revoke(m.id),a.members.log({person:g,device:m.id,event:"refused",address:o,detail:`network login ${x??"missing"}; expected ${f.join(" or ")}`}),n(`[member] ${g}: pairing from ${o} refused: the network says "${x??"nobody"}", expected ${f.join(" or ")}`),{status:403,body:{error:vr}};let A=d||"Unnamed machine",y=u.name.slice(0,40),v=Oe(a.root,{title:`New machine for ${y}`,ask:`From ${o}, ${x?`network login ${x}`:"no network login reported"}. Machine name, as typed there: "${A}". Let it see their own work?`,recommend:`Yes if ${y} told you they just paired this machine. No if you did not expect it.`,if_silent:"discard",raised_by:xr},{now:r()});return v.ok?(a.members.add({tokenId:m.id,personId:g,name:A,state:"pending",cardId:v.card.id,address:o,...x?{network:x}:{},createdAt:new Date(r()).toISOString()}),a.members.log({person:g,device:m.id,event:"paired",address:o,detail:A}),n(`[member] ${g} paired "${A}" from ${o}; waiting for the owner (card ${v.card.id})`),{status:200,body:{person:g,name:A,state:"pending"},token:l.token}):(a.tokens.revoke(m.id),a.members.log({person:g,device:m.id,event:"refused",address:o,detail:v.error}),n(`[member] ${g}: pairing from ${o} refused: ${v.error}`),{status:503,body:{error:wr}})}var de="this machine is not paired",Sr="waiting for the owner to approve this machine";function Ja(e){return e?e.status==="decided"?e.verdict??null:e.status==="expired"?"no":null:null}function li(e,a){return a.state==="pending"&&a.cardId?Ja(ge(e,a.cardId)):null}function ci(e,a,t){let r=a.now??Date.now,n=a.log??(c=>console.log(c)),o=qa(e,a.tokens);if(!o)return{ok:!1,status:401,error:de};let{rec:i,personId:s}=o,d=a.members.byToken(i.id);if(!d||d.state==="removed"||d.personId!==s)return{ok:!1,status:401,error:de};if(a.people&&!a.people().some(c=>c.id===s))return Xa(a,i.id,"person no longer listed"),n(`[member] ${s}: "${d.name}" ended: person no longer listed`),{ok:!1,status:401,error:de};if(d.state==="pending"){let c=d.cardId?ge(a.root,d.cardId):null,m=Ja(c);if(m==="yes")d=a.members.update(i.id,{state:"active",approvedAt:new Date(r()).toISOString()})??d,a.members.log({person:s,device:i.id,event:"approved",detail:c?.decided_by}),n(`[member] ${s}: "${d.name}" approved`);else if(m==="no"){let g=c?.status==="expired"?"the owner did not answer in time":"the owner said no";return a.tokens.revoke(i.id),a.members.update(i.id,{state:"removed",removedAt:new Date(r()).toISOString(),removedReason:g}),a.members.log({person:s,device:i.id,event:"refused",detail:g}),n(`[member] ${s}: "${d.name}" refused: ${g}`),{ok:!1,status:401,error:de}}else return{ok:!1,status:403,error:Sr,waiting:!0}}let l=d.lastSeenAt?Date.parse(d.lastSeenAt):0;return t&&(r()-l>=mr||d.lastAddress!==t)&&(d=a.members.update(i.id,{lastSeenAt:new Date(r()).toISOString(),lastAddress:t})??d,a.members.log({person:s,device:i.id,event:"signed-in",address:t})),{ok:!0,device:d,personId:s,rec:i}}function Xa(e,a,t="removed by the owner"){let r=e.members.byToken(a);if(!r)return null;e.tokens.revoke(a);let n=e.members.update(a,{state:"removed",removedAt:new Date((e.now??Date.now)()).toISOString(),removedReason:t});return e.members.log({person:r.personId,device:a,event:"removed",detail:t}),n}function pi(e,a){return e.members.devices(a).filter(t=>t.state!=="removed").map(t=>Xa(e,t.tokenId,"person removed by the owner")).filter(t=>!!t)}async function Cr(e,a){let t=e+a-Date.now();t>0&&await new Promise(r=>setTimeout(r,t))}var Ga=["gitlab","github"];function Ar(e,a,t){let r=String(a||"").trim().toLowerCase();if(!Ga.includes(r))throw new Error(`Request status works on ${Ga.join(" and ")}, not on "${a}".`);e.requestStatus=e.requestStatus&&typeof e.requestStatus=="object"?e.requestStatus:{};let n=Array.isArray(e.requestStatus.channels)?e.requestStatus.channels.map(o=>String(o).toLowerCase()):[];return e.requestStatus.channels=t?[...new Set([...n,r])]:n.filter(o=>o!==r),`request status on ${r} is ${t?"on":"off"}`}function ui(e){return Array.isArray(e?.requestStatus?.channels)?e.requestStatus.channels.map(a=>String(a).toLowerCase()):[]}function mi(e){let{summary:a}=Z(t=>Ar(t,e?.channel,!!e?.enabled));return{summary:a}}var hi="https://myaccount.google.com/apppasswords";function bi(e){let a=e.split("@")[1]?.toLowerCase()??"";if(a==="gmail.com"||a==="googlemail.com")return{imapHost:"imap.gmail.com",imapPort:993,smtpHost:"smtp.gmail.com",smtpPort:465}}function vi(e){let a=e.user&&e.user!==e.address?{user:e.user}:{};return{agent:e.agent,address:e.address,imap:{host:e.imapHost,port:e.imapPort,secure:e.imapPort===993,...a,password:`\${${e.passwordEnv}}`},smtp:{host:e.smtpHost,port:e.smtpPort,secure:e.smtpPort===465},allowFrom:e.allowFrom,send:e.send}}function wi(e){return`EMAIL_${e.toUpperCase().replace(/[^A-Z0-9]/g,"_")}_PASSWORD`}function $i(e){return`${e.name} <${e.from}> via ${e.host}:${e.port}`}async function _i(e,a){return Be({host:e.host,port:e.port,secure:e.secure,user:e.user,password:e.password},{name:e.name,address:e.from},a,{"Auto-Submitted":"auto-generated"})}function Si(e,a){return{to:e,subject:`${a.name}: test mail`,text:[`This is a test mail from ${a.name}.`,"","If it reached you, AgentX can send mail through this sender.","You can ignore it."].join(`
2905
2905
  `)}}function Ai(e){return new Set(Object.entries(e).filter(([,a])=>a?.wiki?.absorb?.enabled===!1).map(([a])=>a))}function Ti(e,a){return a.only?{agents:[a.only],skipped:[]}:{agents:e.filter(t=>!a.off.has(t)),skipped:e.filter(t=>a.off.has(t))}}function Ii(e,a){return`absorb is off for this agent (agents.${e}.wiki.absorb.enabled); skipped.${e===a?" It reads the wiki notes inbox, so the inbox was not read.":""} Use --agent ${e} to run it anyway.`}function zi(e,a){if(a){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 Ei(e){return{enabled:!!e?.enabled,server:e?.server||Tr,topicSet:!!e?.topic,tokenSet:!!e?.token}}function Ri(e,a){let t={...e??{}};if("enabled"in a&&(t.enabled=!!a.enabled),"server"in a){let r=String(a.server).trim().replace(/\/+$/,"");if(!/^https?:\/\/\S+$/.test(r))throw new Error("ntfy server must be an http(s) URL");t.server=r}if("topic"in a){let r=String(a.topic).trim();if(!r)throw new Error("ntfy topic cannot be empty");t.topic=r}if("token"in a){let r=String(a.token??"").trim();r?t.token=r:delete t.token}if(t.enabled&&!t.topic)throw new Error("set a topic before enabling ntfy");return t}Za();function Va(e){return/^(agent|person):/.test(e)?F(e):`person:${e}`}function ji(e){let a=(e?.projects??[]).filter(t=>t?.id);return a.map(t=>({id:t.id,name:t.name?.trim()||t.id,client:Le(t.id,a),...t.pm?{pm:F(t.pm)}:{},...t.lead?{lead:Va(t.lead)}:{},team:[...new Set((t.team??[]).filter(Boolean).map(F))]})).sort((t,r)=>t.client.localeCompare(r.client)||t.name.localeCompare(r.name)||t.id.localeCompare(r.id))}function Hi(e,a,t){if(!t.lead&&!t.team?.length)return;let r=new Set(Object.keys(e.business?.orgChart||{})),n=new Set((e.people||[]).map(i=>String(i.id))),o={id:a,name:a,client:"",...t.lead?{lead:Va(t.lead)}:{},team:(t.team??[]).map(F)};return Ir([o],r,n)}function Ir(e,a,t){let r=n=>{let o=le(n);return o.kind==="agent"?a.has(o.id)?void 0:`"${o.id}", which is not an agent in business.orgChart`:t.has(o.id)?void 0:`"${o.id}", which is not a person in people`};for(let n of e){if(n.lead){if(le(n.lead).kind!=="person")return`Project ${n.name} is led by "${n.lead}"; a lead is a person (person:<id>), the PM is the agent`;let o=r(n.lead);if(o)return`Project ${n.name} is led by ${o}`}for(let o of n.team){let i=r(o);if(i)return`Project ${n.name} has ${i} in its team`}}}export{ve as a,da as b,ye as c,nt as d,ot as e,it as f,ua as g,mt as h,_n as i,Sn as j,Cn as k,ko as l,Co as m,Ba as n,Yo as o,Jo as p,Rn as q,On as r,It as s,Et as t,ke as u,Dn as v,Mn as w,Rt as x,Bn as y,Un as z,Fn as A,Vo as B,Qo as C,Zo as D,pr as E,xr as F,ii as G,hr as H,br as I,si as J,vr as K,wr as L,yr as M,kr as N,$r as O,_r as P,di as Q,Ja as R,li as S,ci as T,Xa as U,pi as V,Ga as W,Ar as X,ui as Y,mi as Z,hi as _,bi as $,vi as aa,wi as ba,$i as ca,_i as da,Si as ea,Ai as fa,Ti as ga,Ii as ha,zi as ia,Ei as ja,Ri as ka,Va as la,ji as ma,Hi as na,Ir as oa,Qt as pa,go as qa,vo as ra,wo as sa};
2906
- //# sourceMappingURL=chunk-MH7KJQ4N.js.map
2906
+ //# sourceMappingURL=chunk-YXGZSVPY.js.map
@@ -1,4 +1,4 @@
1
- import{a as M,b as E,c as R,d as T,e as j,j as O}from"./chunk-T7SD5EVH.js";import{c as P,d as N}from"./chunk-OWNQ2FD4.js";import{c as _,d as x}from"./chunk-AHWWJ7AF.js";import{b as I}from"./chunk-KEXBEUSU.js";import{a as B}from"./chunk-ROLSSYXE.js";import{y as C,z as K}from"./chunk-BLKXK27S.js";import{readFileSync as $,writeFileSync as b,appendFileSync as V,existsSync as w,mkdirSync as L,readdirSync as D,statSync as F}from"fs";import{resolve as h,join as Y,relative as k,dirname as z}from"path";K();function U(A){return B.includes(A)}function G(A){if(!A)return;let t;try{t=JSON.parse(A)}catch{return}if(!Array.isArray(t))return;let e=t.filter(s=>typeof s=="object"&&s!==null&&typeof s.property=="string"&&s.property!==""&&typeof s.value=="string"&&s.value!=="");return e.length?e:void 0}function H(A,t){let e=a=>{let o=/^(.*Z)(?:-(\d+))?\.md$/.exec(a);return o?[o[1],o[2]?Number(o[2]):0]:[a,0]},[s,i]=e(A),[n,r]=e(t);return s<n?-1:s>n?1:i-r}var J=class{baseDir;rawDir;log;lockWaitMs=5e3;constructor(t=h(process.cwd(),".agentx/wiki"),e=console.error.bind(console,"[wiki]")){this.baseDir=t,this.rawDir=h(t,"raw/entries"),this.log=e,L(this.rawDir,{recursive:!0}),L(h(t,"raw"),{recursive:!0}),this.ensureSchema()}canRead(t,e){return t.access==="public"?!0:e?!!(t.owner===e||t.access==="shared"&&t.sharedWith?.includes(e)):!1}canWrite(t,e){return t.owner===e}addEntry(t){let e=`${t.date}_${t.id}.md`,s=h(this.rawDir,e),i=["---",`id: ${t.id}`,`date: ${t.date}`,`agent: ${t.agentId}`,`source: ${t.source}`];if(t.sourceContext&&i.push(`context: ${t.sourceContext}`),t.meta)for(let[n,r]of Object.entries(t.meta))i.push(`${n}: ${JSON.stringify(r)}`);return i.push("---","",t.content),b(s,i.join(`
1
+ import{a as M,b as E,c as R,d as T,e as j,j as O}from"./chunk-QEOGWSRR.js";import{c as P,d as N}from"./chunk-OWNQ2FD4.js";import{c as _,d as x}from"./chunk-AHWWJ7AF.js";import{b as I}from"./chunk-KEXBEUSU.js";import{a as B}from"./chunk-ROLSSYXE.js";import{y as C,z as K}from"./chunk-64IVC2G6.js";import{readFileSync as $,writeFileSync as b,appendFileSync as V,existsSync as w,mkdirSync as L,readdirSync as D,statSync as F}from"fs";import{resolve as h,join as Y,relative as k,dirname as z}from"path";K();function U(A){return B.includes(A)}function G(A){if(!A)return;let t;try{t=JSON.parse(A)}catch{return}if(!Array.isArray(t))return;let e=t.filter(s=>typeof s=="object"&&s!==null&&typeof s.property=="string"&&s.property!==""&&typeof s.value=="string"&&s.value!=="");return e.length?e:void 0}function H(A,t){let e=a=>{let o=/^(.*Z)(?:-(\d+))?\.md$/.exec(a);return o?[o[1],o[2]?Number(o[2]):0]:[a,0]},[s,i]=e(A),[n,r]=e(t);return s<n?-1:s>n?1:i-r}var J=class{baseDir;rawDir;log;lockWaitMs=5e3;constructor(t=h(process.cwd(),".agentx/wiki"),e=console.error.bind(console,"[wiki]")){this.baseDir=t,this.rawDir=h(t,"raw/entries"),this.log=e,L(this.rawDir,{recursive:!0}),L(h(t,"raw"),{recursive:!0}),this.ensureSchema()}canRead(t,e){return t.access==="public"?!0:e?!!(t.owner===e||t.access==="shared"&&t.sharedWith?.includes(e)):!1}canWrite(t,e){return t.owner===e}addEntry(t){let e=`${t.date}_${t.id}.md`,s=h(this.rawDir,e),i=["---",`id: ${t.id}`,`date: ${t.date}`,`agent: ${t.agentId}`,`source: ${t.source}`];if(t.sourceContext&&i.push(`context: ${t.sourceContext}`),t.meta)for(let[n,r]of Object.entries(t.meta))i.push(`${n}: ${JSON.stringify(r)}`);return i.push("---","",t.content),b(s,i.join(`
2
2
  `)),this.appendLog("ingest",`${t.id} from ${t.agentId} via ${t.source}`),e}readEntries(t){if(t.length===0||!w(this.rawDir))return[];let e=new Set(t),s=[];for(let i of D(this.rawDir)){let n=i.replace(/\.md$/,"").replace(/^\d{4}-\d{2}-\d{2}_/,"");if(!e.has(n))continue;let r=this.parseEntry($(h(this.rawDir,i),"utf-8"),i);r&&s.push(r)}return s}listEntries(t){if(!w(this.rawDir))return[];let e=D(this.rawDir).filter(i=>i.endsWith(".md")).sort(),s=[];for(let i of e){let n=$(h(this.rawDir,i),"utf-8"),r=this.parseEntry(n,i);r&&(t?.agentId&&r.agentId!==t.agentId||t?.after&&r.date<t.after||t?.before&&r.date>t.before||s.push(r))}return s}parseEntry(t,e){let s=t.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);if(!s)return null;let i=s[1],n=s[2].trim(),r=c=>i.match(new RegExp(`^${c}:\\s*(.+)$`,"m"))?.[1]?.trim()||"",a=new Set(["id","date","agent","source","context"]),o={};for(let c of i.split(`
3
3
  `)){let l=c.match(/^(\w+):\s*(.+)$/);if(!(!l||a.has(l[1])))try{o[l[1]]=JSON.parse(l[2])}catch{o[l[1]]=l[2].trim()}}return{id:r("id")||e.replace(".md",""),date:r("date"),agentId:r("agent"),source:r("source"),sourceContext:r("context")||void 0,content:n,meta:Object.keys(o).length>0?o:void 0}}withArticleLock(t,e){let s=`${h(this.baseDir,"_locks",t)}.lock`;return N(h(this.baseDir,t),e,{lock:s,what:`wiki page ${t}`,timeoutMs:this.lockWaitMs,staleMs:1e4})}writeArticle(t,e,s,i){try{return this.withArticleLock(t,()=>this.writeArticleLocked(t,e,s,i))}catch(n){if(!(n instanceof P))throw n;return this.log(n.message),!1}}writeArticleLocked(t,e,s,i){let n=this.readArticle(t);if(n&&!this.canWrite(n.meta,i))return this.log(`Permission denied: "${i}" cannot write "${t}" (owner: ${n.meta.owner})`),!1;e.type&&!I(e.type)&&(this.log(`Dropping invalid article type "${e.type}" for "${t}" \u2014 enum is [person, project, place, concept, event, decision, pattern]`),e={...e,type:void 0});let r=h(this.baseDir,t);n&&this.saveVersion(t,r),L(z(r),{recursive:!0});let a=["---",`title: "${e.title}"`];e.type&&a.push(`type: ${e.type}`),e.related?.length&&a.push(`related: [${e.related.map(c=>`"${c}"`).join(", ")}]`),a.push(`tags: [${(e.tags||[]).map(c=>`"${c}"`).join(", ")}]`,`owner: ${e.owner}`,`access: ${e.access}`),e.sharedWith?.length&&a.push(`shared_with: [${e.sharedWith.map(c=>`"${c}"`).join(", ")}]`),a.push(`created: ${e.created}`,`last_updated: ${e.lastUpdated}`,`sources: [${e.sources.map(c=>`"${c}"`).join(", ")}]`),e.graphPath?.length&&a.push(`graph_path: [${e.graphPath.map(c=>`"${c}"`).join(", ")}]`),e.class&&a.push(`class: ${e.class}`),e.importance&&a.push(`importance: ${e.importance}`),e.importanceProposed&&a.push(`importance_proposed: ${e.importanceProposed}`),e.date&&a.push(`date: ${e.date}`),e.rolledUpInto&&a.push(`rolled_up_into: ${JSON.stringify(e.rolledUpInto)}`),e.aliases?.length&&a.push(`aliases: ${JSON.stringify(e.aliases)}`),e.statements?.length&&a.push(`statements: ${JSON.stringify(e.statements)}`),a.push("---","",s),b(r,a.join(`
4
4
  `));let o=n?"update":"create";return this.appendLog(o,`${e.title} [${(e.tags||[]).slice(0,5).join(", ")}] by ${i} at ${t}`),!0}saveVersion(t,e){try{if(!w(e))return;let s=$(e,"utf-8"),i=new Date().toISOString().replace(/[:.]/g,"-"),n=h(this.baseDir,"_versions",t.replace(/\.md$/,""));L(n,{recursive:!0});for(let r=0;;r++)try{b(h(n,`${r?`${i}-${r}`:i}.md`),s,{flag:"wx"});return}catch(a){if(a.code!=="EEXIST")throw a}}catch{}}getVersions(t){let e=h(this.baseDir,"_versions",t.replace(/\.md$/,""));if(!w(e))return[];try{return D(e).filter(s=>s.endsWith(".md")).sort(H).reverse().map(s=>({timestamp:s.replace(/\.md$/,"").replace(/-/g,(i,n)=>n<19?n===10?"T":n===13||n===16?":":"-":i),path:h(e,s)}))}catch{return[]}}restoreVersion(t,e){let s=this.getVersions(t),i=s.find(n=>n.timestamp===e)??s.find(n=>n.timestamp.startsWith(e));return i?this.withArticleLock(t,()=>this.restoreLocked(t,i.path,e)):!1}restoreLocked(t,e,s){try{let i=$(e,"utf-8"),n=h(this.baseDir,t);return this.saveVersion(t,n),b(n,i),this.appendLog("restore",`${t} restored to ${s}`),!0}catch{return!1}}readArticle(t){let e=h(this.baseDir,t);if(!w(e))return null;let s=$(e,"utf-8");return this.parseArticle(s,t)}readArticleAs(t,e){let s=this.readArticle(t);return!s||!this.canRead(s.meta,e)?null:s}parseArticle(t,e){let s=t.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);if(!s)return null;let i=s[1],n=s[2].trim(),r=W=>i.match(new RegExp(`^${W}:\\s*(.+)$`,"m"))?.[1]?.trim().replace(/^"(.*)"$/,"$1")||"",a=W=>{let v=i.match(new RegExp(`^${W}:\\s*\\[(.*)\\]$`,"m"));return v?[...v[1].matchAll(/\s*(?:"(.*?)"(?=\s*(?:,|$))|([^,]+))/g)].map(S=>(S[1]??S[2]).trim()).filter(Boolean):[]},o=r("type")||r("kind"),l=new Set(["person","project","place","concept","event","decision","pattern"]).has(o)?o:void 0,g=a("tags").filter((W,v,S)=>W&&S.indexOf(W)===v),d=a("related"),p=a("graph_path"),m=a("aliases"),u=r("importance"),f=r("importance_proposed"),y=r("date");return{meta:{title:r("title"),type:l,related:d.length?d:void 0,tags:g,owner:r("owner"),access:r("access")||"public",sharedWith:a("shared_with"),created:r("created"),lastUpdated:r("last_updated"),sources:a("sources"),graphPath:p.length?p:void 0,class:/^[a-z][a-z0-9_]*$/.test(r("class"))?r("class"):void 0,importance:U(u)?u:void 0,importanceProposed:U(f)?f:void 0,date:/^\d{4}-\d{2}-\d{2}/.test(y)?y.slice(0,10):void 0,rolledUpInto:r("rolled_up_into")||void 0,aliases:m.length?m:void 0,statements:G(r("statements"))},content:n,path:e}}listCache=new Map;listArticles(t){return this.listCached(t)}listAllArticles(){return this.listCached(null)}listCached(t){let e=[],s=[];this.walkDir(this.baseDir,(o,c)=>{if(!o.endsWith(".md"))return;let l=k(this.baseDir,o);l.startsWith("raw/")||l.startsWith("_")||(e.push(l),s.push(`${l}:${c?.mtimeMs??"?"}:${c?.size??"?"}`))});let i=s.join("|"),n=t??"\0all",r=this.listCache.get(n);if(r&&r.signature===i)return r.articles.slice();let a=[];for(let o of e){let c=this.readArticle(o);c&&(t===null||this.canRead(c.meta,t))&&a.push(c)}return this.listCache.set(n,{signature:i,articles:a}),a.slice()}search(t,e,s=10){let i=t.toLowerCase(),n=[];if(this.walkDir(this.baseDir,d=>{if(!d.endsWith(".md"))return;let p=k(this.baseDir,d);if(p.startsWith("raw/")||p.startsWith("_"))return;let m=this.readArticle(p);!m||!this.canRead(m.meta,e)||n.push(m)}),n.length===0)return[];let r=n.map(d=>d.content),a=h(this.baseDir,"_bm25_cache.json"),o=x(r,a),c=_(t,o),l=new Map(c.map(d=>[d.docIndex,d.score]));return n.map((d,p)=>{let m=l.get(p)??0;return d.meta.title.toLowerCase().includes(i)&&(m+=10),d.meta.tags?.some(u=>u.toLowerCase().includes(i))&&(m+=5),{article:d,score:m}}).filter(d=>d.score>0).sort((d,p)=>p.score-d.score).slice(0,s).map(d=>d.article)}async findRelevantReranked(t,e,s=10,i={}){let n=Math.max(s,i.shortlist??E),r=this.findRelevant(t,e,n);if(r.length<2)return r.slice(0,s);let a=r.map((l,g)=>({id:`c${g}`,title:l.meta.title||`(untitled ${g})`,tags:l.meta.tags,excerpt:l.content})),o=await C(M,R({query:t,candidates:a,excerptChars:i.excerptChars}),T(a),{incumbent:{best:a[0].id},features:{agent:e??"unknown"}});return!o||o.mode!=="active"?r.slice(0,s):j(o.answers,a).ranked.map(l=>r[Number(l.slice(1))]).filter(l=>!!l).slice(0,s)}findRelevant(t,e,s=3,i,n={graph:.6,bm25:.4}){let r=[];if(this.walkDir(this.baseDir,u=>{if(!u.endsWith(".md"))return;let f=k(this.baseDir,u);if(f.startsWith("raw/")||f.startsWith("_"))return;let y=this.readArticle(f);!y||!this.canRead(y.meta,e)||r.push(y)}),r.length===0)return[];let a=r.map(u=>`${u.meta.title} ${(u.meta.tags||[]).join(" ")} ${u.content}`),o=h(this.baseDir,"_bm25_relevance_cache.json"),c=x(a,o),l=_(t,c),g=l.reduce((u,f)=>Math.max(u,f.score),0)||1,d=new Map(l.map(u=>[u.docIndex,u.score/g])),p=!!(i&&i.length>0);return r.map((u,f)=>{let y=d.get(f)??0,W=0;p&&u.meta.graphPath?.length&&(W=O(i,u.meta.graphPath));let v=p?n.graph*W+n.bm25*y:y;return{article:u,score:v}}).filter(u=>u.score>0).sort((u,f)=>f.score-u.score).slice(0,s).map(u=>u.article)}buildContext(t,e=4e3){if(t.length===0)return"";let s=["[Wiki Knowledge]"],i=0;for(let n of t){let r=`
@@ -102,4 +102,4 @@ We use GitLab for version control.
102
102
  There are ${e.length} unprocessed entries. Read each, understand what it means, and create or update wiki articles.
103
103
 
104
104
  ${s}`}walkDir(t,e){if(w(t))for(let s of D(t)){let i=Y(t,s),n=F(i);n.isDirectory()?this.walkDir(i,e):e(i,n)}}};export{J as a};
105
- //# sourceMappingURL=chunk-JMWPBZLU.js.map
105
+ //# sourceMappingURL=chunk-Z5HYCMDF.js.map
package/dist/cli.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import{b as o}from"./chunk-OSH2PEBH.js";import"./chunk-QIJLFPWE.js";var e=o(process.versions.node);e&&(console.error(e),process.exit(1));var{buildProgram:s}=await import("./program-7QFRDJUY.js"),{installCliSignalExit:r}=await import("./signal-exit-C5EUGHKI.js"),{applyConnectAttemptTimeout:i,configPathFromArgv:a,readConnectAttemptTimeout:n}=await import("./net-family-X2P3OVDP.js");r();i(n(process.cwd(),a(process.argv.slice(2))));var t=await s();process.argv.slice(2).length===0?t.outputHelp():t.parse();
2
+ import{b as o}from"./chunk-OSH2PEBH.js";import"./chunk-QIJLFPWE.js";var e=o(process.versions.node);e&&(console.error(e),process.exit(1));var{buildProgram:s}=await import("./program-QZKK3Y2W.js"),{installCliSignalExit:r}=await import("./signal-exit-C5EUGHKI.js"),{applyConnectAttemptTimeout:i,configPathFromArgv:a,readConnectAttemptTimeout:n}=await import("./net-family-X2P3OVDP.js");r();i(n(process.cwd(),a(process.argv.slice(2))));var t=await s();process.argv.slice(2).length===0?t.outputHelp():t.parse();
3
3
  //# sourceMappingURL=cli.js.map
@@ -1,2 +1,2 @@
1
- import{a,b,c,d,e,f,g}from"./chunk-7OJUZ3L5.js";import"./chunk-4A6UVU2X.js";import"./chunk-KEUW6YLL.js";import"./chunk-N47Y5ADQ.js";import"./chunk-VQRY4IDI.js";import"./chunk-YSCT6DPR.js";import"./chunk-QIJLFPWE.js";export{b as fetchAgents,d as fetchCrons,c as fetchProcesses,e as killProcess,a as resolveConn,f as sendTask,g as streamTask};
2
- //# sourceMappingURL=client-SJLHZDIC.js.map
1
+ import{a,b,c,d,e,f,g}from"./chunk-QGRIW7SE.js";import"./chunk-PZ2F6J2E.js";import"./chunk-KEUW6YLL.js";import"./chunk-N47Y5ADQ.js";import"./chunk-VQRY4IDI.js";import"./chunk-YSCT6DPR.js";import"./chunk-QIJLFPWE.js";export{b as fetchAgents,d as fetchCrons,c as fetchProcesses,e as killProcess,a as resolveConn,f as sendTask,g as streamTask};
2
+ //# sourceMappingURL=client-UPXDV3SM.js.map
@@ -1,2 +1,2 @@
1
- import{$b as n,Ob as a,Pb as b,Qb as c,Rb as d,Sb as e,Tb as f,Ub as g,Vb as h,Wb as i,Xb as j,Yb as k,Zb as l,_b as m,ac as o,bc as p,cc as q,dc as r,ec as s,fc as t,gc as u,hc as v,ic as w,jc as x,kc as y,lc as z,mc as A,nc as B,oc as C,pc as D,qc as E,rc as F,tc as G}from"./chunk-4A6UVU2X.js";import"./chunk-KEUW6YLL.js";import"./chunk-N47Y5ADQ.js";import"./chunk-VQRY4IDI.js";import"./chunk-YSCT6DPR.js";import"./chunk-QIJLFPWE.js";G();export{a as INTEGRATION_KINDS,B as WIKI_CONTRIBUTE_JOB,C as WIKI_CONTRIBUTE_MERGE_JOB,E as WIKI_SUMMARIZE_JOB,s as approvalsConfigSchema,g as callsSchema,e as cameraBotSchema,z as crossFieldProblems,v as daemonConfigSchema,c as emailAccountSchema,b as eventSubscriptionSchema,w as expandEnvVars,r as improveConfigSchema,f as isCronExpression,y as literalSecretProblems,x as loadDaemonConfig,d as mailSenderSchema,o as membersConfigSchema,j as mergePolicyConfigSchema,t as numbersConfigSchema,n as peopleConfigSchema,m as personSchema,q as qualityReportConfigSchema,p as requestStatusConfigSchema,l as requestsConfigSchema,h as reviewGateConfigSchema,i as trackersConfigSchema,A as validateWorkspaces,u as wallConfigSchema,k as watchersConfigSchema,D as withContributionJobs,F as withSummariesJob};
2
- //# sourceMappingURL=config-Q3ENZQYL.js.map
1
+ import{$b as f,Bc as G,Wb as a,Xb as b,Yb as c,Zb as d,_b as e,ac as g,bc as h,cc as i,dc as j,ec as k,fc as l,gc as m,hc as n,ic as o,jc as p,kc as q,lc as r,mc as s,nc as t,oc as u,pc as v,qc as w,rc as x,sc as y,tc as z,uc as A,vc as B,wc as C,xc as D,yc as E,zc as F}from"./chunk-PZ2F6J2E.js";import"./chunk-KEUW6YLL.js";import"./chunk-N47Y5ADQ.js";import"./chunk-VQRY4IDI.js";import"./chunk-YSCT6DPR.js";import"./chunk-QIJLFPWE.js";G();export{a as INTEGRATION_KINDS,B as WIKI_CONTRIBUTE_JOB,C as WIKI_CONTRIBUTE_MERGE_JOB,E as WIKI_SUMMARIZE_JOB,s as approvalsConfigSchema,g as callsSchema,e as cameraBotSchema,z as crossFieldProblems,v as daemonConfigSchema,c as emailAccountSchema,b as eventSubscriptionSchema,w as expandEnvVars,r as improveConfigSchema,f as isCronExpression,y as literalSecretProblems,x as loadDaemonConfig,d as mailSenderSchema,o as membersConfigSchema,j as mergePolicyConfigSchema,t as numbersConfigSchema,n as peopleConfigSchema,m as personSchema,q as qualityReportConfigSchema,p as requestStatusConfigSchema,l as requestsConfigSchema,h as reviewGateConfigSchema,i as trackersConfigSchema,A as validateWorkspaces,u as wallConfigSchema,k as watchersConfigSchema,D as withContributionJobs,F as withSummariesJob};
2
+ //# sourceMappingURL=config-LAM4HUTA.js.map
@@ -1,2 +1,2 @@
1
- import{a,b}from"./chunk-2ZNYIHRB.js";import"./chunk-4A6UVU2X.js";import"./chunk-KEUW6YLL.js";import"./chunk-N47Y5ADQ.js";import"./chunk-VQRY4IDI.js";import"./chunk-YSCT6DPR.js";import"./chunk-QIJLFPWE.js";export{a as mutateAgentxConfig,b as writeAgentxConfig};
2
- //# sourceMappingURL=config-mutate-NNAUMQ2Y.js.map
1
+ import{a,b}from"./chunk-3C6UDZDX.js";import"./chunk-PZ2F6J2E.js";import"./chunk-KEUW6YLL.js";import"./chunk-N47Y5ADQ.js";import"./chunk-VQRY4IDI.js";import"./chunk-YSCT6DPR.js";import"./chunk-QIJLFPWE.js";export{a as mutateAgentxConfig,b as writeAgentxConfig};
2
+ //# sourceMappingURL=config-mutate-P4QLFUVH.js.map
@@ -1,2 +1,2 @@
1
- import{a,b,c,d,e}from"./chunk-LDSBFDYB.js";import"./chunk-4A6UVU2X.js";import"./chunk-KEUW6YLL.js";import"./chunk-N47Y5ADQ.js";import"./chunk-VQRY4IDI.js";import"./chunk-YSCT6DPR.js";import"./chunk-QIJLFPWE.js";export{b as applyConfigMutation,a as findConfigPath,d as getAtPath,c as setAtPath,e as unsetAtPath};
2
- //# sourceMappingURL=config-mutator-2F2BJNMA.js.map
1
+ import{a,b,c,d,e}from"./chunk-LSFLSB7C.js";import"./chunk-PZ2F6J2E.js";import"./chunk-KEUW6YLL.js";import"./chunk-N47Y5ADQ.js";import"./chunk-VQRY4IDI.js";import"./chunk-YSCT6DPR.js";import"./chunk-QIJLFPWE.js";export{b as applyConfigMutation,a as findConfigPath,d as getAtPath,c as setAtPath,e as unsetAtPath};
2
+ //# sourceMappingURL=config-mutator-RIPSMYAO.js.map
@@ -1,4 +1,4 @@
1
- import{a as ee}from"./chunk-JTS563OC.js";import"./chunk-TO6T6AQY.js";import{f as Q,k as V}from"./chunk-IH65GDJR.js";import"./chunk-5SQRJUAK.js";import"./chunk-JTFCU5LH.js";import"./chunk-LUOW2YHY.js";import"./chunk-4LWFJ4MZ.js";import"./chunk-BIJHMWXK.js";import{b as O}from"./chunk-5ONH4ITT.js";import"./chunk-JRAG37V5.js";import"./chunk-ILEC3IAV.js";import"./chunk-BERWTVG2.js";import"./chunk-A7JSRDJL.js";import"./chunk-T7SD5EVH.js";import"./chunk-WPNRDEHW.js";import"./chunk-OWNQ2FD4.js";import{b as N,c as H}from"./chunk-AHWWJ7AF.js";import{b as X}from"./chunk-KEXBEUSU.js";import"./chunk-BLKXK27S.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-QUFIUXMQ.js";import"./chunk-DCIYOPJF.js";import"./chunk-7I7IEX4S.js";import"./chunk-4A6UVU2X.js";import"./chunk-KEUW6YLL.js";import"./chunk-N47Y5ADQ.js";import"./chunk-VQRY4IDI.js";import"./chunk-YSCT6DPR.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";import{createHash as le}from"crypto";import{existsSync as z,mkdirSync as ne,readdirSync as re,readFileSync as ge,renameSync as se,writeFileSync as pe}from"fs";import{resolve as w}from"path";var _={maxPatches:30,maxCostUsd:.5,maxItems:60},he=12,fe=2e3,me=1500,M=8,U=300,be=12,B="## Checked facts";function S(n){return w(n,"_contributions")}function E(n,r){if(!z(n))return r;try{return JSON.parse(ge(n,"utf-8"))}catch(t){throw new Error(`${n} is not valid JSON: ${t.message}`)}}function L(n,r){ne(w(n,".."),{recursive:!0});let t=`${n}.${process.pid}.tmp`;pe(t,`${JSON.stringify(r,null,2)}
1
+ import{a as ee}from"./chunk-SJJ7QEFE.js";import"./chunk-AOPNASCE.js";import{f as Q,k as V}from"./chunk-IH65GDJR.js";import"./chunk-2MAKXLK2.js";import"./chunk-JTFCU5LH.js";import"./chunk-LUOW2YHY.js";import"./chunk-4LWFJ4MZ.js";import"./chunk-BIJHMWXK.js";import{b as O}from"./chunk-5ONH4ITT.js";import"./chunk-JRAG37V5.js";import"./chunk-ILEC3IAV.js";import"./chunk-BERWTVG2.js";import"./chunk-A7JSRDJL.js";import"./chunk-QEOGWSRR.js";import"./chunk-WPNRDEHW.js";import"./chunk-OWNQ2FD4.js";import{b as N,c as H}from"./chunk-AHWWJ7AF.js";import{b as X}from"./chunk-KEXBEUSU.js";import"./chunk-64IVC2G6.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-QUFIUXMQ.js";import"./chunk-DCIYOPJF.js";import"./chunk-7I7IEX4S.js";import"./chunk-PZ2F6J2E.js";import"./chunk-KEUW6YLL.js";import"./chunk-N47Y5ADQ.js";import"./chunk-VQRY4IDI.js";import"./chunk-YSCT6DPR.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";import{createHash as le}from"crypto";import{existsSync as z,mkdirSync as ne,readdirSync as re,readFileSync as ge,renameSync as se,writeFileSync as pe}from"fs";import{resolve as w}from"path";var _={maxPatches:30,maxCostUsd:.5,maxItems:60},he=12,fe=2e3,me=1500,M=8,U=300,be=12,B="## Checked facts";function S(n){return w(n,"_contributions")}function E(n,r){if(!z(n))return r;try{return JSON.parse(ge(n,"utf-8"))}catch(t){throw new Error(`${n} is not valid JSON: ${t.message}`)}}function L(n,r){ne(w(n,".."),{recursive:!0});let t=`${n}.${process.pid}.tmp`;pe(t,`${JSON.stringify(r,null,2)}
2
2
  `),se(t,n)}function ie(n){return{agents:E(w(S(n),"state.json"),{agents:{}}).agents??{}}}function ye(n){let r=w(S(n),"pending");return z(r)?re(r).filter(t=>t.endsWith(".json")).sort().map(t=>E(w(r,t),null)).filter(t=>!!t):[]}function G(n){return w(S(n),"held.json")}function K(n,r={}){let t=E(G(n),[]);return r.all?t:t.filter(a=>a.status==="held")}function _e(n){let r=w(S(n),"reports");if(!z(r))return null;let t=re(r).filter(a=>a.endsWith(".json")).sort().pop();return t?E(w(r,t),null):null}function ke(n,r,t,a={}){let o=ie(r).agents[t],c=a.now??Date.now(),e=a.since??o?.lastRunAt??new Date(c-864e5).toISOString(),d=e.slice(0,10),u=new Set(o?.processed??[]),s=[];for(let g of n.getAgentEntries(t))g.date<d||u.has(g.id)||s.push({id:g.id,at:g.date,kind:"chat",title:[g.source,g.sourceContext].filter(Boolean).join(" \xB7 "),text:g.content});if(a.db){let g=Date.parse(e);for(let l of V(a.db,{agentId:t,since:Number.isFinite(g)?g:void 0,limit:500})){if(l.status==="in-flight"||u.has(l.taskId))continue;let k=(Q(a.db,l.taskId)?.steps??[]).filter(b=>b.name==="tool_use"||b.action).slice(0,be).map(b=>`- ${b.action??b.name}${b.inputSummary?` ${x(b.inputSummary,160)}`:""}${b.outputSummary?` \u2192 ${x(b.outputSummary,240)}`:""}${b.error?` \u2717 ${x(b.error,120)}`:""}`),y=[`Request: ${x(l.originalMessage??l.messagePreview??"",600)}`,k.length?`Tool calls:
3
3
  ${k.join(`
4
4
  `)}`:"",l.finalResponse?`Reply: ${x(l.finalResponse,800)}`:""].filter(Boolean).join(`
@@ -54,4 +54,4 @@ _Sources: ${t.sources.join("; ")}._`,a);return n.writeArticle(r,{title:t.title,.
54
54
  `).replace(/\n{3,}/g,`
55
55
 
56
56
  `).trim(),superseded:d}}function Ce(n){let r=n.previous?` (previously: ${n.previous})`:"";return`- **${n.attribute}:** ${n.value} \u2014 ${n.source}; checked ${n.checkedAt.slice(0,10)} by ${n.by}${r}`}function Re(n){let r=n.match(/^- \*\*.+?:\*\* (.*?) — .*?; checked (\S+) by \S+(?: \(previously: (.*)\))?$/);return r?{value:r[1],checkedAt:r[2],...r[3]?{previous:r[3]}:{}}:void 0}function J(n,r){return`contribution:${n}@${r.slice(0,10)}`}var Te={person:"people",project:"projects",place:"places",concept:"concepts",event:"events",decision:"decisions",pattern:"patterns"};function de(n,r,t){let a=r.toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/g,"").slice(0,60)||"page",o=t?Te[t]:"contributions",c=`${o}/${a}.md`;for(let e=2;n.readArticle(c);e++)c=`${o}/${a}-${e}.md`;return c}export{_ as DEFAULT_CONTRIBUTION_LIMITS,B as FACTS_HEADING,ue as applyFactLines,De as approveHeld,xe as buildContributionPrompt,S as contributionsDir,_e as latestReport,K as listHeld,ye as listPendingBatches,Be as mergeContributions,W as pageKey,Ae as parseContributionPatches,ke as pendingWork,Se as possibleDuplicate,Fe as rejectHeld,ce as replaceOnce,Me as runContribution};
57
- //# sourceMappingURL=contributions-SOUGZCAH.js.map
57
+ //# sourceMappingURL=contributions-SHSEI3TX.js.map
@@ -1,2 +1,2 @@
1
- import{b as a,c as b,d as c,e as d,f as e,g as f,h as g,i as h,j as i,k as j}from"./chunk-YTWRIIAT.js";import"./chunk-WMZ4TGMR.js";import"./chunk-2YDG5CSS.js";import"./chunk-U5DSMDCJ.js";import"./chunk-IMLAPB7G.js";import"./chunk-QPABR72X.js";import"./chunk-KP7KDLZ2.js";import"./chunk-OQQTV3OF.js";import"./chunk-4NZ4T3TQ.js";import"./chunk-LY4G7PCW.js";import"./chunk-7IW25T4K.js";import"./chunk-Q3A5P373.js";import"./chunk-JLBRNYKY.js";import"./chunk-BYEL7KKR.js";import"./chunk-QUFIUXMQ.js";import"./chunk-OSH2PEBH.js";import"./chunk-7I7IEX4S.js";import"./chunk-4A6UVU2X.js";import"./chunk-KEUW6YLL.js";import"./chunk-N47Y5ADQ.js";import"./chunk-VQRY4IDI.js";import"./chunk-YSCT6DPR.js";import"./chunk-QIJLFPWE.js";export{j as daemonVoiceCheck,b as doctor,i as mcpHeaderEnvChecks,g as meshPeerTokenChecks,h as meshTokenChecksFromConfig,a as runDoctorChecks,e as runMirrorChecks,d as runNativeChecks,c as runNotificationChecks,f as runReminderChecks};
2
- //# sourceMappingURL=doctor-H6I433KY.js.map
1
+ import{b as a,c as b,d as c,e as d,f as e,g as f,h as g,i as h,j as i,k as j}from"./chunk-M42GMRZF.js";import"./chunk-WMZ4TGMR.js";import"./chunk-2YDG5CSS.js";import"./chunk-2F7KQ4DJ.js";import"./chunk-IMLAPB7G.js";import"./chunk-QPABR72X.js";import"./chunk-KP7KDLZ2.js";import"./chunk-BXK5S2KK.js";import"./chunk-4NZ4T3TQ.js";import"./chunk-LY4G7PCW.js";import"./chunk-7IW25T4K.js";import"./chunk-Q3A5P373.js";import"./chunk-JLBRNYKY.js";import"./chunk-BYEL7KKR.js";import"./chunk-QUFIUXMQ.js";import"./chunk-OSH2PEBH.js";import"./chunk-7I7IEX4S.js";import"./chunk-PZ2F6J2E.js";import"./chunk-KEUW6YLL.js";import"./chunk-N47Y5ADQ.js";import"./chunk-VQRY4IDI.js";import"./chunk-YSCT6DPR.js";import"./chunk-QIJLFPWE.js";export{j as daemonVoiceCheck,b as doctor,i as mcpHeaderEnvChecks,g as meshPeerTokenChecks,h as meshTokenChecksFromConfig,a as runDoctorChecks,e as runMirrorChecks,d as runNativeChecks,c as runNotificationChecks,f as runReminderChecks};
2
+ //# sourceMappingURL=doctor-TLDBNHYM.js.map
@@ -1,7 +1,7 @@
1
- import{b as h}from"./chunk-MOEXP6U3.js";import"./chunk-RKPAVWXF.js";import{b as I}from"./chunk-IFUAP7UD.js";import"./chunk-KP7KDLZ2.js";import"./chunk-F32VADB7.js";import"./chunk-AU7SN4G3.js";import"./chunk-LDSBFDYB.js";import"./chunk-3UOTLMXD.js";import"./chunk-FCPTN6NF.js";import"./chunk-7I7IEX4S.js";import"./chunk-4A6UVU2X.js";import"./chunk-KEUW6YLL.js";import"./chunk-N47Y5ADQ.js";import"./chunk-VQRY4IDI.js";import"./chunk-YSCT6DPR.js";import"./chunk-QIJLFPWE.js";var p=t=>typeof t=="string"?t.trim():"";function $(t){return[`Run ${t.runId} "${t.title}" [${t.status}] on step ${t.step}: waiting on ${t.waitingOn}.`,t.tags?.length?`Tags: ${t.tags.join(", ")}`:"",...(t.steps??[]).slice(-8).map(s=>`- ${String(s.at).slice(0,16).replace("T"," ")} ${s.step} ${s.status}${s.note?`: ${s.note}`:""}`)].filter(Boolean).join(`
1
+ import{d as h}from"./chunk-O2YDS2P3.js";import{b as I}from"./chunk-IFUAP7UD.js";import"./chunk-KP7KDLZ2.js";import"./chunk-56UTQ4FU.js";import"./chunk-Q432O462.js";import"./chunk-LSFLSB7C.js";import"./chunk-3UOTLMXD.js";import"./chunk-FCPTN6NF.js";import"./chunk-7I7IEX4S.js";import"./chunk-PZ2F6J2E.js";import"./chunk-KEUW6YLL.js";import"./chunk-N47Y5ADQ.js";import"./chunk-VQRY4IDI.js";import"./chunk-YSCT6DPR.js";import"./chunk-QIJLFPWE.js";var p=t=>typeof t=="string"?t.trim():"";function $(t){return[`Run ${t.runId} "${t.title}" [${t.status}] on step ${t.step}: waiting on ${t.waitingOn}.`,t.tags?.length?`Tags: ${t.tags.join(", ")}`:"",...(t.steps??[]).slice(-8).map(s=>`- ${String(s.at).slice(0,16).replace("T"," ")} ${s.step} ${s.status}${s.note?`: ${s.note}`:""}`)].filter(Boolean).join(`
2
2
  `)}async function T(t,c){let s=c.fetch??fetch,m=c.daemonUrl.replace(/\/$/,""),r=(p(t.action)||"list").toLowerCase(),f=c.env??process.env,w=async i=>{let l=await s(`${m}${i}`,{signal:AbortSignal.timeout(1e4)}),n=await l.json().catch(()=>({}));return{ok:l.ok,status:l.status,data:n}};try{if(r==="list"){let e=await w("/follow-up");if(!e.ok)return`Error: ${e.data?.error||`HTTP ${e.status}`}`;let o=e.data.groups??[];return o.length?o.map(d=>[`${d.tag}:`,...d.rows.map(a=>`- ${a.runId} "${a.title}" on ${a.step}: waiting on ${a.waitingOn} (since ${String(a.since).slice(0,16).replace("T"," ")} UTC)`)].join(`
3
3
  `)).join(`
4
4
  `):"No follow-up workflows are running."}if(r==="match"){let e=p(t.request)||p(t.title);if(!e)return"Error: match needs `request`: the owner's request in their words.";let o=h(t,f),d=await w(`/follow-up/match?q=${encodeURIComponent(e)}${o?`&agentId=${encodeURIComponent(o.agentId)}`:""}`);if(!d.ok)return`Error: ${d.data?.error||`HTTP ${d.status}`}`;let a=d.data.matches??[];return a.length?["Saved workflows, best fit first (confidence 0-1):",...a.map(u=>`- ${u.workflowId} "${u.title}" (${u.confidence}${u.autoStart?", starts without asking":""}): ${u.steps.map(k=>k.id).join(" \u2192 ")}`),'Start one with {action:"start", workflowId:"<id>", title:"\u2026", tags:["client:<name>"]}. Run its steps through the workflow, not by hand.'].join(`
5
5
  `):"No saved workflow fits. If the request has several steps, build one: start with title and steps."}if(r==="status"){let e=p(t.runId);if(!e)return"Error: status needs runId.";let o=await w(`/follow-up/${encodeURIComponent(e)}`);return o.ok?$(o.data.run):`Error: ${o.data?.error||`HTTP ${o.status}`}`}let i=h(t,f);if(!i)return"Error: couldn't tell which agent you are. Pass callerAgentId.";let l=await s(`${m}/follow-up`,{method:"POST",headers:{"Content-Type":"application/json",...I(f)},body:JSON.stringify({action:r,agentId:i.agentId,workflowId:t.workflowId,title:t.title,description:t.description,tags:t.tags,inputs:t.inputs,steps:t.steps,edges:t.edges,approval:t.approval,autoStart:t.autoStart,requestId:t.requestId,runId:t.runId,step:t.step,evidence:t.evidence,note:t.note,reason:t.reason,fromRun:t.fromRun,status:t.status}),signal:AbortSignal.timeout(2e4)}),n=await l.json().catch(()=>({}));if(!l.ok)return`Error: ${n?.error||`HTTP ${l.status}`}`;if(r==="start"){let e=n.run;return[`Started run ${e.runId} "${e.title}"${n.built?" (built from the steps you gave; propose it with fromRun to keep it)":""}.`,n.awaitingApproval?"It waits for the owner's approval before the first step.":`It is on step ${e.step}: ${e.waitingOn}.`,"AgentX follows it from here: it starts each step, reminds whoever is slow, and tells the owner when it ends. Do not run its steps by hand.",...n.warning?[`Note: ${n.warning}`]:[]].join(" ")}return r==="plan"?[`Plan recorded on run ${n.run?.runId??t.runId}:`,...(n.plan??[]).map(e=>`- ${e.id} ${e.title}`),'Report each step with {action:"step", runId, step:"<id>", status:"started"|"done"|"failed"}.'].join(`
6
6
  `):r==="step"?`Step recorded. ${n.run?$(n.run):""}`.trim():r==="done"?`Step recorded as done. ${n.run?$(n.run):""}`.trim():r==="blocked"?"The step is marked blocked and the owner is told. Nothing more happens on it until it is sorted.":`Saved ${n.workflowId} switched off, and asked the owner (card ${n.cardId}) whether to keep it as a reusable workflow.`}catch(i){return`Error: couldn't reach the daemon (${i?.message??i}).`}}export{T as runWorkflowTool};
7
- //# sourceMappingURL=follow-up-tool-4FX455DL.js.map
7
+ //# sourceMappingURL=follow-up-tool-VM4ZDRC5.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/workflows/follow-up-tool.ts"],"sourcesContent":["import { resolveScheduleCaller } from \"@/crons/schedule-tool\"\nimport { callerHeaders } from \"@/calls/service\"\n\n// --- Agent-facing `agentx_workflow` tool (#788) ---\n//\n// A request with several steps is run as a workflow, not by hand:\n// match saved workflows that fit the request in front of you\n// start start one (workflowId), or build one from the owner's words\n// (title + steps) and run it; tags say what it concerns\n// status one run: the step it is on and what it waits on\n// list every follow-up still going, grouped by tag\n// done the step you own is finished (evidence)\n// blocked your step cannot go on without the owner (reason)\n// propose ask the owner to keep a workflow as a reusable template\n// plan write or change the plan of the run your task is wrapped in\n// step report a step of that plan (started, done, failed)\n// It talks to the daemon's /follow-up endpoints.\n\nexport interface WorkflowToolDeps {\n daemonUrl: string\n fetch?: typeof fetch\n env?: NodeJS.ProcessEnv\n}\n\nconst str = (v: unknown) => (typeof v === \"string\" ? v.trim() : \"\")\n\nfunction describe(run: any): string {\n const lines = [\n `Run ${run.runId} \"${run.title}\" [${run.status}] on step ${run.step}: waiting on ${run.waitingOn}.`,\n run.tags?.length ? `Tags: ${run.tags.join(\", \")}` : \"\",\n ...(run.steps ?? []).slice(-8).map((s: any) => `- ${String(s.at).slice(0, 16).replace(\"T\", \" \")} ${s.step} ${s.status}${s.note ? `: ${s.note}` : \"\"}`),\n ]\n return lines.filter(Boolean).join(\"\\n\")\n}\n\n/** Returns the text the agent sees. Every refusal is text, never a throw. */\nexport async function runWorkflowTool(args: Record<string, unknown>, deps: WorkflowToolDeps): Promise<string> {\n const doFetch = deps.fetch ?? fetch\n const base = deps.daemonUrl.replace(/\\/$/, \"\")\n const action = (str(args.action) || \"list\").toLowerCase()\n const env = deps.env ?? process.env\n const read = async (path: string) => {\n const res = await doFetch(`${base}${path}`, { signal: AbortSignal.timeout(10_000) })\n const data = await res.json().catch(() => ({})) as any\n return { ok: res.ok, status: res.status, data }\n }\n\n try {\n if (action === \"list\") {\n const r = await read(\"/follow-up\")\n if (!r.ok) return `Error: ${r.data?.error || `HTTP ${r.status}`}`\n const groups = r.data.groups ?? []\n if (!groups.length) return \"No follow-up workflows are running.\"\n return groups.map((g: any) => [`${g.tag}:`, ...g.rows.map((row: any) => `- ${row.runId} \"${row.title}\" on ${row.step}: waiting on ${row.waitingOn} (since ${String(row.since).slice(0, 16).replace(\"T\", \" \")} UTC)`)].join(\"\\n\")).join(\"\\n\")\n }\n if (action === \"match\") {\n const q = str(args.request) || str(args.title)\n if (!q) return \"Error: match needs `request`: the owner's request in their words.\"\n const caller = resolveScheduleCaller(args, env)\n const r = await read(`/follow-up/match?q=${encodeURIComponent(q)}${caller ? `&agentId=${encodeURIComponent(caller.agentId)}` : \"\"}`)\n if (!r.ok) return `Error: ${r.data?.error || `HTTP ${r.status}`}`\n const matches = r.data.matches ?? []\n if (!matches.length) return \"No saved workflow fits. If the request has several steps, build one: start with title and steps.\"\n return [\n \"Saved workflows, best fit first (confidence 0-1):\",\n ...matches.map((x: any) => `- ${x.workflowId} \"${x.title}\" (${x.confidence}${x.autoStart ? \", starts without asking\" : \"\"}): ${x.steps.map((s: any) => s.id).join(\" → \")}`),\n `Start one with {action:\"start\", workflowId:\"<id>\", title:\"…\", tags:[\"client:<name>\"]}. Run its steps through the workflow, not by hand.`,\n ].join(\"\\n\")\n }\n if (action === \"status\") {\n const runId = str(args.runId)\n if (!runId) return \"Error: status needs runId.\"\n const r = await read(`/follow-up/${encodeURIComponent(runId)}`)\n if (!r.ok) return `Error: ${r.data?.error || `HTTP ${r.status}`}`\n return describe(r.data.run)\n }\n\n const caller = resolveScheduleCaller(args, env)\n if (!caller) return \"Error: couldn't tell which agent you are. Pass callerAgentId.\"\n const res = await doFetch(`${base}/follow-up`, {\n method: \"POST\",\n // The headers name this run: the daemon refuses a write that does\n // not come from a running turn of the agent.\n headers: { \"Content-Type\": \"application/json\", ...callerHeaders(env) },\n body: JSON.stringify({\n action, agentId: caller.agentId,\n workflowId: args.workflowId, title: args.title, description: args.description, tags: args.tags, inputs: args.inputs,\n steps: args.steps, edges: args.edges, approval: args.approval, autoStart: args.autoStart, requestId: args.requestId,\n runId: args.runId, step: args.step, evidence: args.evidence, note: args.note, reason: args.reason, fromRun: args.fromRun, status: args.status,\n }),\n signal: AbortSignal.timeout(20_000),\n })\n const data = await res.json().catch(() => ({})) as any\n if (!res.ok) return `Error: ${data?.error || `HTTP ${res.status}`}`\n if (action === \"start\") {\n const run = data.run\n return [\n `Started run ${run.runId} \"${run.title}\"${data.built ? \" (built from the steps you gave; propose it with fromRun to keep it)\" : \"\"}.`,\n data.awaitingApproval ? \"It waits for the owner's approval before the first step.\" : `It is on step ${run.step}: ${run.waitingOn}.`,\n \"AgentX follows it from here: it starts each step, reminds whoever is slow, and tells the owner when it ends. Do not run its steps by hand.\",\n ...(data.warning ? [`Note: ${data.warning}`] : []),\n ].join(\" \")\n }\n if (action === \"plan\") {\n return [\n `Plan recorded on run ${data.run?.runId ?? args.runId}:`,\n ...(data.plan ?? []).map((s: any) => `- ${s.id} ${s.title}`),\n `Report each step with {action:\"step\", runId, step:\"<id>\", status:\"started\"|\"done\"|\"failed\"}.`,\n ].join(\"\\n\")\n }\n if (action === \"step\") return `Step recorded. ${data.run ? describe(data.run) : \"\"}`.trim()\n if (action === \"done\") return `Step recorded as done. ${data.run ? describe(data.run) : \"\"}`.trim()\n if (action === \"blocked\") return \"The step is marked blocked and the owner is told. Nothing more happens on it until it is sorted.\"\n return `Saved ${data.workflowId} switched off, and asked the owner (card ${data.cardId}) whether to keep it as a reusable workflow.`\n } catch (e: any) {\n return `Error: couldn't reach the daemon (${e?.message ?? e}).`\n }\n}\n"],"mappings":"wdAwBA,IAAMA,EAAOC,GAAgB,OAAOA,GAAM,SAAWA,EAAE,KAAK,EAAI,GAEhE,SAASC,EAASC,EAAkB,CAMlC,MALc,CACZ,OAAOA,EAAI,UAAUA,EAAI,WAAWA,EAAI,mBAAmBA,EAAI,oBAAoBA,EAAI,aACvFA,EAAI,MAAM,OAAS,SAASA,EAAI,KAAK,KA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","doFetch","base","action","env","read","path","res","data","r","groups","g","row","q","caller","resolveScheduleCaller","matches","x","s","runId","callerHeaders","e"]}
1
+ {"version":3,"sources":["../src/workflows/follow-up-tool.ts"],"sourcesContent":["import { resolveScheduleCaller } from \"@/crons/schedule-tool\"\nimport { callerHeaders } from \"@/calls/service\"\n\n// --- Agent-facing `agentx_workflow` tool (#788) ---\n//\n// A request with several steps is run as a workflow, not by hand:\n// match saved workflows that fit the request in front of you\n// start start one (workflowId), or build one from the owner's words\n// (title + steps) and run it; tags say what it concerns\n// status one run: the step it is on and what it waits on\n// list every follow-up still going, grouped by tag\n// done the step you own is finished (evidence)\n// blocked your step cannot go on without the owner (reason)\n// propose ask the owner to keep a workflow as a reusable template\n// plan write or change the plan of the run your task is wrapped in\n// step report a step of that plan (started, done, failed)\n// It talks to the daemon's /follow-up endpoints.\n\nexport interface WorkflowToolDeps {\n daemonUrl: string\n fetch?: typeof fetch\n env?: NodeJS.ProcessEnv\n}\n\nconst str = (v: unknown) => (typeof v === \"string\" ? v.trim() : \"\")\n\nfunction describe(run: any): string {\n const lines = [\n `Run ${run.runId} \"${run.title}\" [${run.status}] on step ${run.step}: waiting on ${run.waitingOn}.`,\n run.tags?.length ? `Tags: ${run.tags.join(\", \")}` : \"\",\n ...(run.steps ?? []).slice(-8).map((s: any) => `- ${String(s.at).slice(0, 16).replace(\"T\", \" \")} ${s.step} ${s.status}${s.note ? `: ${s.note}` : \"\"}`),\n ]\n return lines.filter(Boolean).join(\"\\n\")\n}\n\n/** Returns the text the agent sees. Every refusal is text, never a throw. */\nexport async function runWorkflowTool(args: Record<string, unknown>, deps: WorkflowToolDeps): Promise<string> {\n const doFetch = deps.fetch ?? fetch\n const base = deps.daemonUrl.replace(/\\/$/, \"\")\n const action = (str(args.action) || \"list\").toLowerCase()\n const env = deps.env ?? process.env\n const read = async (path: string) => {\n const res = await doFetch(`${base}${path}`, { signal: AbortSignal.timeout(10_000) })\n const data = await res.json().catch(() => ({})) as any\n return { ok: res.ok, status: res.status, data }\n }\n\n try {\n if (action === \"list\") {\n const r = await read(\"/follow-up\")\n if (!r.ok) return `Error: ${r.data?.error || `HTTP ${r.status}`}`\n const groups = r.data.groups ?? []\n if (!groups.length) return \"No follow-up workflows are running.\"\n return groups.map((g: any) => [`${g.tag}:`, ...g.rows.map((row: any) => `- ${row.runId} \"${row.title}\" on ${row.step}: waiting on ${row.waitingOn} (since ${String(row.since).slice(0, 16).replace(\"T\", \" \")} UTC)`)].join(\"\\n\")).join(\"\\n\")\n }\n if (action === \"match\") {\n const q = str(args.request) || str(args.title)\n if (!q) return \"Error: match needs `request`: the owner's request in their words.\"\n const caller = resolveScheduleCaller(args, env)\n const r = await read(`/follow-up/match?q=${encodeURIComponent(q)}${caller ? `&agentId=${encodeURIComponent(caller.agentId)}` : \"\"}`)\n if (!r.ok) return `Error: ${r.data?.error || `HTTP ${r.status}`}`\n const matches = r.data.matches ?? []\n if (!matches.length) return \"No saved workflow fits. If the request has several steps, build one: start with title and steps.\"\n return [\n \"Saved workflows, best fit first (confidence 0-1):\",\n ...matches.map((x: any) => `- ${x.workflowId} \"${x.title}\" (${x.confidence}${x.autoStart ? \", starts without asking\" : \"\"}): ${x.steps.map((s: any) => s.id).join(\" → \")}`),\n `Start one with {action:\"start\", workflowId:\"<id>\", title:\"…\", tags:[\"client:<name>\"]}. Run its steps through the workflow, not by hand.`,\n ].join(\"\\n\")\n }\n if (action === \"status\") {\n const runId = str(args.runId)\n if (!runId) return \"Error: status needs runId.\"\n const r = await read(`/follow-up/${encodeURIComponent(runId)}`)\n if (!r.ok) return `Error: ${r.data?.error || `HTTP ${r.status}`}`\n return describe(r.data.run)\n }\n\n const caller = resolveScheduleCaller(args, env)\n if (!caller) return \"Error: couldn't tell which agent you are. Pass callerAgentId.\"\n const res = await doFetch(`${base}/follow-up`, {\n method: \"POST\",\n // The headers name this run: the daemon refuses a write that does\n // not come from a running turn of the agent.\n headers: { \"Content-Type\": \"application/json\", ...callerHeaders(env) },\n body: JSON.stringify({\n action, agentId: caller.agentId,\n workflowId: args.workflowId, title: args.title, description: args.description, tags: args.tags, inputs: args.inputs,\n steps: args.steps, edges: args.edges, approval: args.approval, autoStart: args.autoStart, requestId: args.requestId,\n runId: args.runId, step: args.step, evidence: args.evidence, note: args.note, reason: args.reason, fromRun: args.fromRun, status: args.status,\n }),\n signal: AbortSignal.timeout(20_000),\n })\n const data = await res.json().catch(() => ({})) as any\n if (!res.ok) return `Error: ${data?.error || `HTTP ${res.status}`}`\n if (action === \"start\") {\n const run = data.run\n return [\n `Started run ${run.runId} \"${run.title}\"${data.built ? \" (built from the steps you gave; propose it with fromRun to keep it)\" : \"\"}.`,\n data.awaitingApproval ? \"It waits for the owner's approval before the first step.\" : `It is on step ${run.step}: ${run.waitingOn}.`,\n \"AgentX follows it from here: it starts each step, reminds whoever is slow, and tells the owner when it ends. Do not run its steps by hand.\",\n ...(data.warning ? [`Note: ${data.warning}`] : []),\n ].join(\" \")\n }\n if (action === \"plan\") {\n return [\n `Plan recorded on run ${data.run?.runId ?? args.runId}:`,\n ...(data.plan ?? []).map((s: any) => `- ${s.id} ${s.title}`),\n `Report each step with {action:\"step\", runId, step:\"<id>\", status:\"started\"|\"done\"|\"failed\"}.`,\n ].join(\"\\n\")\n }\n if (action === \"step\") return `Step recorded. ${data.run ? describe(data.run) : \"\"}`.trim()\n if (action === \"done\") return `Step recorded as done. ${data.run ? describe(data.run) : \"\"}`.trim()\n if (action === \"blocked\") return \"The step is marked blocked and the owner is told. Nothing more happens on it until it is sorted.\"\n return `Saved ${data.workflowId} switched off, and asked the owner (card ${data.cardId}) whether to keep it as a reusable workflow.`\n } catch (e: any) {\n return `Error: couldn't reach the daemon (${e?.message ?? e}).`\n }\n}\n"],"mappings":"4bAwBA,IAAMA,EAAOC,GAAgB,OAAOA,GAAM,SAAWA,EAAE,KAAK,EAAI,GAEhE,SAASC,EAASC,EAAkB,CAMlC,MALc,CACZ,OAAOA,EAAI,UAAUA,EAAI,WAAWA,EA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AAP,CACA,MAAO,qCAAqCA,GAAG,SAAWA,KAC5D,CACF","names":["str","v","describe","run","runWorkflowTool","args","deps","doFetch","base","action","env","read","path","res","data","r","groups","g","row","q","caller","resolveScheduleCaller","matches","x","s","runId","callerHeaders","e"]}
@@ -1,2 +1,2 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u}from"./chunk-6UTOBSEA.js";import"./chunk-OQQTV3OF.js";import"./chunk-4NZ4T3TQ.js";import"./chunk-7I7IEX4S.js";import"./chunk-VQRY4IDI.js";import"./chunk-QIJLFPWE.js";export{c as DEFAULT_GRANT_DAYS,a as GUEST_SCOPE_PREFIX,b as JOIN_CARD_BY,h as JOIN_FAILED,d as MAX_GRANT_DAYS,j as NO_GRANT,l as PAUSED,k as WAITING_HOST,s as endGrant,o as grantBrief,u as grantForGuest,e as grantIdOf,n as guestAccess,p as guestTask,g as inviteGuest,i as joinGuest,f as newGrantId,q as pauseGrant,r as resumeGrant,m as settleGrant,t as updateGrant};
2
- //# sourceMappingURL=grants-U2734ZHZ.js.map
1
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u}from"./chunk-SYIDD7CI.js";import"./chunk-BXK5S2KK.js";import"./chunk-4NZ4T3TQ.js";import"./chunk-7I7IEX4S.js";import"./chunk-VQRY4IDI.js";import"./chunk-QIJLFPWE.js";export{c as DEFAULT_GRANT_DAYS,a as GUEST_SCOPE_PREFIX,b as JOIN_CARD_BY,h as JOIN_FAILED,d as MAX_GRANT_DAYS,j as NO_GRANT,l as PAUSED,k as WAITING_HOST,s as endGrant,o as grantBrief,u as grantForGuest,e as grantIdOf,n as guestAccess,p as guestTask,g as inviteGuest,i as joinGuest,f as newGrantId,q as pauseGrant,r as resumeGrant,m as settleGrant,t as updateGrant};
2
+ //# sourceMappingURL=grants-ZA35QVTX.js.map
@@ -1,2 +1,2 @@
1
- import{a,b}from"./chunk-TFHJT2AZ.js";import"./chunk-JMWPBZLU.js";import"./chunk-T7SD5EVH.js";import"./chunk-WPNRDEHW.js";import"./chunk-OWNQ2FD4.js";import"./chunk-AHWWJ7AF.js";import"./chunk-KEXBEUSU.js";import"./chunk-ROLSSYXE.js";import"./chunk-BLKXK27S.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-DCIYOPJF.js";import"./chunk-7I7IEX4S.js";import"./chunk-4A6UVU2X.js";import"./chunk-KEUW6YLL.js";import"./chunk-N47Y5ADQ.js";import"./chunk-VQRY4IDI.js";import"./chunk-YSCT6DPR.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";export{b as WikiHub,a as existingWikiDir};
2
- //# sourceMappingURL=hub-XFZFHLJK.js.map
1
+ import{a,b}from"./chunk-LLNLDZNA.js";import"./chunk-Z5HYCMDF.js";import"./chunk-QEOGWSRR.js";import"./chunk-WPNRDEHW.js";import"./chunk-OWNQ2FD4.js";import"./chunk-AHWWJ7AF.js";import"./chunk-KEXBEUSU.js";import"./chunk-ROLSSYXE.js";import"./chunk-64IVC2G6.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-DCIYOPJF.js";import"./chunk-7I7IEX4S.js";import"./chunk-PZ2F6J2E.js";import"./chunk-KEUW6YLL.js";import"./chunk-N47Y5ADQ.js";import"./chunk-VQRY4IDI.js";import"./chunk-YSCT6DPR.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";export{b as WikiHub,a as existingWikiDir};
2
+ //# sourceMappingURL=hub-7Y6ZUVJV.js.map
package/dist/index.d.ts CHANGED
@@ -8186,12 +8186,31 @@ declare const daemonConfigSchema: z.ZodObject<{
8186
8186
  items: z.ZodEffects<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>>, Record<string, Record<string, unknown>>, Record<string, Record<string, unknown>> | undefined>;
8187
8187
  /** Minutes before a failed read is tried again. */
8188
8188
  retryMinutes: z.ZodDefault<z.ZodNumber>;
8189
+ /** A number that misses its target twice in a row raises one decision
8190
+ * card, raised for its owner agent (src/numbers/review.ts). Off: no card;
8191
+ * the review list still shows it. */
8192
+ missedTwiceCard: z.ZodDefault<z.ZodBoolean>;
8193
+ /** An agent that reviews the owner's follow-up on a missed-twice card:
8194
+ * told when the operator says yes. It gets the card itself when the
8195
+ * number has no owner agent on this node. Unset: the owner alone. */
8196
+ reviewer: z.ZodOptional<z.ZodString>;
8197
+ /** Funnels (#1826 N4) by id: a name and the steps in order, first to last.
8198
+ * A step is a number's id, {number, name?} or {tag, name}: the sum of the
8199
+ * numbers with that tag (src/numbers/funnel.ts). The Hub draws them.
8200
+ * Unset by default: nothing changes until one is set up. */
8201
+ funnels: z.ZodEffects<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>, Record<string, unknown> | undefined, Record<string, unknown> | undefined>;
8189
8202
  }, "strip", z.ZodTypeAny, {
8190
8203
  items: Record<string, Record<string, unknown>>;
8191
8204
  retryMinutes: number;
8205
+ missedTwiceCard: boolean;
8206
+ reviewer?: string | undefined;
8207
+ funnels?: Record<string, unknown> | undefined;
8192
8208
  }, {
8209
+ reviewer?: string | undefined;
8193
8210
  items?: Record<string, Record<string, unknown>> | undefined;
8194
8211
  retryMinutes?: number | undefined;
8212
+ missedTwiceCard?: boolean | undefined;
8213
+ funnels?: Record<string, unknown> | undefined;
8195
8214
  }>>;
8196
8215
  /** Task watchers (src/watchers, #1030): every task start decides whether
8197
8216
  * the task needs a watcher and attaches one. Off by default. */
@@ -9577,10 +9596,14 @@ declare const daemonConfigSchema: z.ZodObject<{
9577
9596
  lead?: string | undefined;
9578
9597
  }>, "many">>;
9579
9598
  contactMap: z.ZodDefault<z.ZodArray<z.ZodObject<{
9599
+ /** Header name -> NAME of an environment variable holding its value
9600
+ * (#1698). Read at connect time; written to .mcp.json only as a
9601
+ * `${NAME}` placeholder, never as the secret. */
9580
9602
  channel: z.ZodOptional<z.ZodString>;
9581
9603
  chatId: z.ZodOptional<z.ZodString>;
9582
9604
  username: z.ZodOptional<z.ZodString>;
9583
- senderId: z.ZodOptional<z.ZodString>;
9605
+ senderId: z.ZodOptional<z.ZodString>; /** Listed tools that only read though their names do not say so; they
9606
+ * skip the write confirmation card (#1736). */
9584
9607
  client: z.ZodString;
9585
9608
  project: z.ZodOptional<z.ZodString>;
9586
9609
  displayName: z.ZodOptional<z.ZodString>;
@@ -12595,6 +12618,9 @@ declare const daemonConfigSchema: z.ZodObject<{
12595
12618
  numbers: {
12596
12619
  items: Record<string, Record<string, unknown>>;
12597
12620
  retryMinutes: number;
12621
+ missedTwiceCard: boolean;
12622
+ reviewer?: string | undefined;
12623
+ funnels?: Record<string, unknown> | undefined;
12598
12624
  };
12599
12625
  requestStatus: {
12600
12626
  channels: string[];
@@ -14111,8 +14137,11 @@ declare const daemonConfigSchema: z.ZodObject<{
14111
14137
  saveBuilderWork?: boolean | undefined;
14112
14138
  } | undefined;
14113
14139
  numbers?: {
14140
+ reviewer?: string | undefined;
14114
14141
  items?: Record<string, Record<string, unknown>> | undefined;
14115
14142
  retryMinutes?: number | undefined;
14143
+ missedTwiceCard?: boolean | undefined;
14144
+ funnels?: Record<string, unknown> | undefined;
14116
14145
  } | undefined;
14117
14146
  requestStatus?: {
14118
14147
  channels?: string[] | undefined;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import{Pa as Tt,Qa as Mt,a as St,b as kt,c as vt,d as xt,e as $t,f as Ct,g as Pt,h as bt}from"./chunk-F2XNWKIL.js";import"./chunk-XXFVK5D7.js";import"./chunk-GTJIKXDB.js";import"./chunk-LJUBWMPB.js";import"./chunk-U5DSMDCJ.js";import"./chunk-IMLAPB7G.js";import"./chunk-ZVP6GB4G.js";import"./chunk-6UTOBSEA.js";import"./chunk-PPUN7YHA.js";import"./chunk-VZLIBDLH.js";import"./chunk-EKJG63EJ.js";import"./chunk-IKXDCPXS.js";import"./chunk-3Q6MRG3P.js";import"./chunk-2VDO2HEK.js";import"./chunk-JWDJMFU6.js";import"./chunk-2P5NP4H6.js";import"./chunk-B4KQC3DG.js";import"./chunk-LQE73AZR.js";import"./chunk-2D3RYIDU.js";import"./chunk-2ZNYIHRB.js";import"./chunk-MRIVENBY.js";import"./chunk-A5GYG56I.js";import"./chunk-SZXFWCKA.js";import"./chunk-2AXFYDWF.js";import"./chunk-AQASR6KR.js";import"./chunk-UKUH662W.js";import"./chunk-RX5O5637.js";import"./chunk-5ELIX7BQ.js";import"./chunk-X7UQY7CH.js";import"./chunk-I4E6BH27.js";import"./chunk-3UATFGSB.js";import"./chunk-QPABR72X.js";import"./chunk-IFUAP7UD.js";import"./chunk-KP7KDLZ2.js";import{Ka as yt,r as lt,s as ct,t as dt,u as mt,v as pt}from"./chunk-WLDRIJQX.js";import"./chunk-2KQECT4H.js";import"./chunk-MEFPXHQJ.js";import"./chunk-7AB3QUGH.js";import{a as L}from"./chunk-BAXGL6TY.js";import{A as D,B as z,C as V,a as ye,b as we,c as Se,d as Ae,e as Ie,f as Oe,g as Ne,h as He,i as je,j as Ue,k as _e,l as I,m as q,n as Be,o as qe,p as Ye,q as O,r as ze,s as Ve,t as Xe,u as x,v as Y,w as Qe,x as Ze,y as et,z as wt}from"./chunk-JNBUJKNG.js";import{a as B,b as M,c as F}from"./chunk-SFQUP3BP.js";import"./chunk-6TTGRTDO.js";import"./chunk-F32VADB7.js";import"./chunk-VE3SSOQX.js";import"./chunk-W4YR2RO2.js";import"./chunk-7YOLZGB5.js";import"./chunk-IH65GDJR.js";import{u as ut}from"./chunk-AU7SN4G3.js";import"./chunk-LDSBFDYB.js";import"./chunk-3UOTLMXD.js";import"./chunk-XVV7ZZ77.js";import"./chunk-J3SOEFRE.js";import"./chunk-SIU6STB2.js";import"./chunk-X5C5W3E4.js";import"./chunk-KWWBDLE6.js";import"./chunk-HVMUYEQP.js";import"./chunk-GV7S5BAX.js";import"./chunk-GSX4NK2N.js";import"./chunk-SZDACK6O.js";import"./chunk-VWTBHLMX.js";import"./chunk-5SQRJUAK.js";import"./chunk-JTFCU5LH.js";import"./chunk-LUOW2YHY.js";import"./chunk-4LWFJ4MZ.js";import"./chunk-BIJHMWXK.js";import"./chunk-BE64IJWM.js";import"./chunk-5ONH4ITT.js";import"./chunk-JRAG37V5.js";import"./chunk-ILEC3IAV.js";import"./chunk-MYVHVJWZ.js";import"./chunk-M4H2RYP4.js";import"./chunk-OQQTV3OF.js";import"./chunk-4NZ4T3TQ.js";import"./chunk-LY4G7PCW.js";import"./chunk-DPG6VHPX.js";import"./chunk-BERWTVG2.js";import"./chunk-A7JSRDJL.js";import"./chunk-Z5CMA4JN.js";import"./chunk-TFHJT2AZ.js";import{a as ht}from"./chunk-JMWPBZLU.js";import{f as gt,g as ft}from"./chunk-T7SD5EVH.js";import"./chunk-WPNRDEHW.js";import"./chunk-OWNQ2FD4.js";import"./chunk-AHWWJ7AF.js";import"./chunk-KEXBEUSU.js";import"./chunk-ROLSSYXE.js";import"./chunk-PA7CP74O.js";import{j as it,k as rt,l as at}from"./chunk-BLKXK27S.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-7IW25T4K.js";import"./chunk-Q3A5P373.js";import"./chunk-JLBRNYKY.js";import"./chunk-BYEL7KKR.js";import"./chunk-QUFIUXMQ.js";import{a as ke,b as ve,c as xe,d as $e,e as Ce,f as Pe,g as be,h as Te,i as Me,j as Re,l as Ee,m as Ge,o as T,p as W}from"./chunk-DCIYOPJF.js";import{a as m,b as G}from"./chunk-7I7IEX4S.js";import{b as Fe,c as Le,d as A,e as De}from"./chunk-JHCI6XCJ.js";import{a as Ke,b as Je,e as We}from"./chunk-DSYKYZMT.js";import{hc as tt,jc as st,mc as ot,tc as nt}from"./chunk-4A6UVU2X.js";import"./chunk-KEUW6YLL.js";import"./chunk-N47Y5ADQ.js";import"./chunk-VQRY4IDI.js";import"./chunk-YSCT6DPR.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";W();G();import{execa as Rt}from"execa";import{existsSync as se,promises as X}from"fs";import S from"path";import ie from"node-fetch";async function Et(o,e){let t=o.split("/");if(t.length<2)throw new Error(`Invalid skill package ID: ${o}. Expected format: owner/repo`);let s=t[0],i=t[1],n=t[2];try{let a=n?`${s}/${i}/${n}`:`${s}/${i}`;await Rt("npx",["-y","skills","add",a],{cwd:e,stdio:"pipe"}),m.success(`Installed skill package: ${o}`);let r=S.resolve(e,".skills",`${s}_${i}`);if(se(r))return await ne(r,o);let d=S.resolve(e,".skills");return se(d)?await ne(d,o):[]}catch{return m.info(`Fetching skills directly from GitHub: ${s}/${i}`),await Gt(s,i,n,e)}}async function Gt(o,e,t,s){let i=[];try{let n=`https://api.github.com/repos/${o}/${e}/git/trees/main?recursive=1`,a=await ie(n);if(!a.ok)throw new Error(`GitHub API error: ${a.status}`);let d=(await a.json()).tree.filter(p=>p.type==="blob"&&p.path.endsWith("SKILL.md"));if(t){let p=d.find(f=>f.path.includes(`/${t}/`)||f.path===`${t}/SKILL.md`);if(p){let f=await oe(o,e,p.path,s);f&&i.push(f)}}else for(let p of d){let f=await oe(o,e,p.path,s);f&&i.push(f)}}catch(n){m.error(`Failed to fetch skills from GitHub: ${n.message}`)}return i}async function oe(o,e,t,s){try{let i=`https://raw.githubusercontent.com/${o}/${e}/main/${t}`,n=await ie(i);if(!n.ok)return null;let a=await n.text(),r=A(a);if(r){r.source="remote",r.packageId=`${o}/${e}`;let d=S.dirname(t),p=S.resolve(s,".skills",`${o}_${e}`,d);await X.mkdir(p,{recursive:!0}),await X.writeFile(S.resolve(p,"SKILL.md"),a),r.path=S.resolve(p,"SKILL.md")}return r}catch{return null}}async function ne(o,e){let t=[],{default:s}=await import("fast-glob"),i=await s.glob("**/SKILL.md",{cwd:o,deep:5});for(let n of i)try{let a=S.resolve(o,n),r=await X.readFile(a,"utf8"),d=A(r);d&&(d.source="remote",d.path=a,d.packageId=e,t.push(d))}catch{}return t}async function At(o,e,t,s,i){let n=["---",`name: ${o}`,`description: ${e}`];if(s?.length){n.push("tags:");for(let a of s)n.push(` - ${a}`)}if(i?.length){n.push("globs:");for(let a of i)n.push(` - ${a}`)}return n.push("---"),`${n.join(`
1
+ import{Oa as Tt,Pa as Mt,a as St,b as kt,c as vt,d as xt,e as $t,f as Ct,g as Pt,h as bt}from"./chunk-ELC3M5WS.js";import"./chunk-WHAMZPEG.js";import"./chunk-GTJIKXDB.js";import"./chunk-OJ4RUZZY.js";import"./chunk-2F7KQ4DJ.js";import"./chunk-IMLAPB7G.js";import"./chunk-ZVP6GB4G.js";import"./chunk-SYIDD7CI.js";import"./chunk-PPUN7YHA.js";import"./chunk-VZLIBDLH.js";import"./chunk-EKJG63EJ.js";import"./chunk-FFLMSNTN.js";import"./chunk-3Q6MRG3P.js";import"./chunk-2VDO2HEK.js";import"./chunk-JWDJMFU6.js";import"./chunk-2P5NP4H6.js";import"./chunk-B4KQC3DG.js";import"./chunk-LQE73AZR.js";import"./chunk-2D3RYIDU.js";import"./chunk-3C6UDZDX.js";import"./chunk-MRIVENBY.js";import"./chunk-A5GYG56I.js";import"./chunk-RKKAP4EY.js";import"./chunk-2AXFYDWF.js";import"./chunk-AQASR6KR.js";import"./chunk-UKUH662W.js";import"./chunk-RX5O5637.js";import"./chunk-5ELIX7BQ.js";import"./chunk-X7UQY7CH.js";import"./chunk-5FFNFW4C.js";import"./chunk-IP67DTXX.js";import"./chunk-QPABR72X.js";import"./chunk-IFUAP7UD.js";import"./chunk-KP7KDLZ2.js";import{Ka as yt,r as lt,s as ct,t as dt,u as mt,v as pt}from"./chunk-GEKEILPL.js";import"./chunk-3B7RH3IK.js";import"./chunk-MEFPXHQJ.js";import"./chunk-7AB3QUGH.js";import{a as L}from"./chunk-BAXGL6TY.js";import{A as D,B as z,C as V,a as ye,b as we,c as Se,d as Ae,e as Ie,f as Oe,g as Ne,h as He,i as je,j as Ue,k as _e,l as I,m as q,n as Be,o as qe,p as Ye,q as O,r as ze,s as Ve,t as Xe,u as x,v as Y,w as Qe,x as Ze,y as et,z as wt}from"./chunk-X2GBLX3E.js";import{a as B,b as M,c as F}from"./chunk-SFQUP3BP.js";import"./chunk-6TTGRTDO.js";import"./chunk-56UTQ4FU.js";import"./chunk-VE3SSOQX.js";import"./chunk-W4YR2RO2.js";import"./chunk-7YOLZGB5.js";import"./chunk-IH65GDJR.js";import{u as ut}from"./chunk-Q432O462.js";import"./chunk-LSFLSB7C.js";import"./chunk-3UOTLMXD.js";import"./chunk-XVV7ZZ77.js";import"./chunk-J3SOEFRE.js";import"./chunk-SIU6STB2.js";import"./chunk-X5C5W3E4.js";import"./chunk-KWWBDLE6.js";import"./chunk-HVMUYEQP.js";import"./chunk-GV7S5BAX.js";import"./chunk-GSX4NK2N.js";import"./chunk-SZDACK6O.js";import"./chunk-VWTBHLMX.js";import"./chunk-2MAKXLK2.js";import"./chunk-JTFCU5LH.js";import"./chunk-LUOW2YHY.js";import"./chunk-4LWFJ4MZ.js";import"./chunk-BIJHMWXK.js";import"./chunk-BE64IJWM.js";import"./chunk-5ONH4ITT.js";import"./chunk-JRAG37V5.js";import"./chunk-ILEC3IAV.js";import"./chunk-MYVHVJWZ.js";import"./chunk-XQH4LCZR.js";import"./chunk-BXK5S2KK.js";import"./chunk-4NZ4T3TQ.js";import"./chunk-LY4G7PCW.js";import"./chunk-DPG6VHPX.js";import"./chunk-BERWTVG2.js";import"./chunk-A7JSRDJL.js";import"./chunk-Z5CMA4JN.js";import"./chunk-LLNLDZNA.js";import{a as ht}from"./chunk-Z5HYCMDF.js";import{f as gt,g as ft}from"./chunk-QEOGWSRR.js";import"./chunk-WPNRDEHW.js";import"./chunk-OWNQ2FD4.js";import"./chunk-AHWWJ7AF.js";import"./chunk-KEXBEUSU.js";import"./chunk-ROLSSYXE.js";import"./chunk-MFZNBE65.js";import{j as it,k as rt,l as at}from"./chunk-64IVC2G6.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-7IW25T4K.js";import"./chunk-Q3A5P373.js";import"./chunk-JLBRNYKY.js";import"./chunk-BYEL7KKR.js";import"./chunk-QUFIUXMQ.js";import{a as ke,b as ve,c as xe,d as $e,e as Ce,f as Pe,g as be,h as Te,i as Me,j as Re,l as Ee,m as Ge,o as T,p as W}from"./chunk-DCIYOPJF.js";import{a as m,b as G}from"./chunk-7I7IEX4S.js";import{b as Fe,c as Le,d as A,e as De}from"./chunk-JHCI6XCJ.js";import{a as Ke,b as Je,e as We}from"./chunk-DSYKYZMT.js";import{Bc as nt,pc as tt,rc as st,uc as ot}from"./chunk-PZ2F6J2E.js";import"./chunk-KEUW6YLL.js";import"./chunk-N47Y5ADQ.js";import"./chunk-VQRY4IDI.js";import"./chunk-YSCT6DPR.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";W();G();import{execa as Rt}from"execa";import{existsSync as se,promises as X}from"fs";import S from"path";import ie from"node-fetch";async function Et(o,e){let t=o.split("/");if(t.length<2)throw new Error(`Invalid skill package ID: ${o}. Expected format: owner/repo`);let s=t[0],i=t[1],n=t[2];try{let a=n?`${s}/${i}/${n}`:`${s}/${i}`;await Rt("npx",["-y","skills","add",a],{cwd:e,stdio:"pipe"}),m.success(`Installed skill package: ${o}`);let r=S.resolve(e,".skills",`${s}_${i}`);if(se(r))return await ne(r,o);let d=S.resolve(e,".skills");return se(d)?await ne(d,o):[]}catch{return m.info(`Fetching skills directly from GitHub: ${s}/${i}`),await Gt(s,i,n,e)}}async function Gt(o,e,t,s){let i=[];try{let n=`https://api.github.com/repos/${o}/${e}/git/trees/main?recursive=1`,a=await ie(n);if(!a.ok)throw new Error(`GitHub API error: ${a.status}`);let d=(await a.json()).tree.filter(p=>p.type==="blob"&&p.path.endsWith("SKILL.md"));if(t){let p=d.find(f=>f.path.includes(`/${t}/`)||f.path===`${t}/SKILL.md`);if(p){let f=await oe(o,e,p.path,s);f&&i.push(f)}}else for(let p of d){let f=await oe(o,e,p.path,s);f&&i.push(f)}}catch(n){m.error(`Failed to fetch skills from GitHub: ${n.message}`)}return i}async function oe(o,e,t,s){try{let i=`https://raw.githubusercontent.com/${o}/${e}/main/${t}`,n=await ie(i);if(!n.ok)return null;let a=await n.text(),r=A(a);if(r){r.source="remote",r.packageId=`${o}/${e}`;let d=S.dirname(t),p=S.resolve(s,".skills",`${o}_${e}`,d);await X.mkdir(p,{recursive:!0}),await X.writeFile(S.resolve(p,"SKILL.md"),a),r.path=S.resolve(p,"SKILL.md")}return r}catch{return null}}async function ne(o,e){let t=[],{default:s}=await import("fast-glob"),i=await s.glob("**/SKILL.md",{cwd:o,deep:5});for(let n of i)try{let a=S.resolve(o,n),r=await X.readFile(a,"utf8"),d=A(r);d&&(d.source="remote",d.path=a,d.packageId=e,t.push(d))}catch{}return t}async function At(o,e,t,s,i){let n=["---",`name: ${o}`,`description: ${e}`];if(s?.length){n.push("tags:");for(let a of s)n.push(` - ${a}`)}if(i?.length){n.push("globs:");for(let a of i)n.push(` - ${a}`)}return n.push("---"),`${n.join(`
2
2
  `)}
3
3
 
4
4
  ${t}`}async function It(o){let{loadLocalSkills:e}=await import("./loader-YFVSSYSL.js");return e(o)}async function Ot(o,e,t,s,i){let a=[{role:"system",content:`You are a skill author for the Agent Skills ecosystem (skills.sh).
@@ -0,0 +1,2 @@
1
+ import{d}from"./chunk-O2YDS2P3.js";import{b as c}from"./chunk-IFUAP7UD.js";import"./chunk-KP7KDLZ2.js";import"./chunk-56UTQ4FU.js";import"./chunk-Q432O462.js";import"./chunk-LSFLSB7C.js";import"./chunk-3UOTLMXD.js";import"./chunk-FCPTN6NF.js";import"./chunk-7I7IEX4S.js";import"./chunk-PZ2F6J2E.js";import"./chunk-KEUW6YLL.js";import"./chunk-N47Y5ADQ.js";import"./chunk-VQRY4IDI.js";import"./chunk-YSCT6DPR.js";import"./chunk-QIJLFPWE.js";var u=new Set(["cron","heartbeat","api","a2a","mesh","approvals","requests"]);function p(n){return typeof n=="string"?n.trim():""}async function y(n,o){let i=o.fetch??fetch,h=o.daemonUrl.replace(/\/$/,""),a=o.env??process.env,s=(p(n.action)||"show").toLowerCase();if(s==="show")try{let e=await i(`${h}/api/org`,{headers:c(a),signal:AbortSignal.timeout(1e4)}),r=await e.json().catch(()=>({}));return e.ok?String(r.text??""):`Error: ${r?.error||`HTTP ${e.status}`}`}catch(e){return`Error: couldn't reach the daemon (${e?.message??e}).`}if(s!=="propose")return`Error: unknown action "${s}". Use show or propose.`;let t=d(n,a);if(!t)return"Error: couldn't tell which agent you are. Pass callerAgentId.";let l=t.channel&&t.chatId&&!u.has(t.channel)?{channel:t.channel,chatId:t.chatId,...t.accountId?{accountId:t.accountId}:{}}:void 0;try{let e=await i(`${h}/api/org/proposals`,{method:"POST",headers:{"Content-Type":"application/json",...c(a)},body:JSON.stringify({changes:n.changes,newAgent:n.newAgent,why:n.why,raised_by:t.agentId,...l?{reply:l}:{}}),signal:AbortSignal.timeout(1e4)}),r=await e.json().catch(()=>({}));return e.ok?[`Card ${r.card.id} is in the owner's Approvals inbox: "${r.text}"`,"Nothing is changed yet. On the owner's yes the daemon applies it and you get a message with the result; do not edit the org chart yourself.","Tell the owner it is waiting for their yes."].join(" "):`Not proposed: ${r?.error||`HTTP ${e.status}`}`}catch(e){return`Error: couldn't reach the daemon (${e?.message??e}).`}}export{y as runOrgTool};
2
+ //# sourceMappingURL=org-tool-TOHI7MBS.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/business/org-tool.ts"],"sourcesContent":["import { resolveScheduleCaller } from \"@/crons/schedule-tool\"\nimport { callerHeaders } from \"@/calls/service\"\n\n// --- Agent-facing `agentx_org` tool (#1678 point 5) ---\n//\n// The owner asks in chat for a change to the org chart. The agent reads the\n// chart with `show`, maps the names it heard to member refs, and sends the\n// changes with `propose`. The tool never writes: the daemon checks every\n// change (POST /api/org/proposals, org-proposals.ts) and raises one\n// Approvals card; on the owner's yes the daemon applies it, not the agent.\n\nexport interface OrgToolDeps {\n daemonUrl: string\n fetch?: typeof fetch\n env?: NodeJS.ProcessEnv\n}\n\nconst NON_CHAT_CHANNELS = new Set([\"cron\", \"heartbeat\", \"api\", \"a2a\", \"mesh\", \"approvals\", \"requests\"])\n\nfunction str(v: unknown): string {\n return typeof v === \"string\" ? v.trim() : \"\"\n}\n\n/** Returns the text the agent sees. Every refusal is text, never a throw. */\nexport async function runOrgTool(args: Record<string, unknown>, deps: OrgToolDeps): Promise<string> {\n const doFetch = deps.fetch ?? fetch\n const base = deps.daemonUrl.replace(/\\/$/, \"\")\n const env = deps.env ?? process.env\n const action = (str(args.action) || \"show\").toLowerCase()\n\n if (action === \"show\") {\n try {\n const res = await doFetch(`${base}/api/org`, { headers: callerHeaders(env), signal: AbortSignal.timeout(10_000) })\n const data = await res.json().catch(() => ({})) as any\n if (!res.ok) return `Error: ${data?.error || `HTTP ${res.status}`}`\n return String(data.text ?? \"\")\n } catch (e: any) {\n return `Error: couldn't reach the daemon (${e?.message ?? e}).`\n }\n }\n\n if (action !== \"propose\") return `Error: unknown action \"${action}\". Use show or propose.`\n const caller = resolveScheduleCaller(args, env)\n if (!caller) return \"Error: couldn't tell which agent you are. Pass callerAgentId.\"\n const reply = caller.channel && caller.chatId && !NON_CHAT_CHANNELS.has(caller.channel)\n ? { channel: caller.channel, chatId: caller.chatId, ...(caller.accountId ? { accountId: caller.accountId } : {}) }\n : undefined\n try {\n const res = await doFetch(`${base}/api/org/proposals`, {\n method: \"POST\",\n // The headers name this run: the daemon checks that the owner started it.\n headers: { \"Content-Type\": \"application/json\", ...callerHeaders(env) },\n body: JSON.stringify({ changes: args.changes, newAgent: args.newAgent, why: args.why, raised_by: caller.agentId, ...(reply ? { reply } : {}) }),\n signal: AbortSignal.timeout(10_000),\n })\n const data = await res.json().catch(() => ({})) as any\n // A refusal is a plain sentence: say it to the owner as it is.\n if (!res.ok) return `Not proposed: ${data?.error || `HTTP ${res.status}`}`\n return [\n `Card ${data.card.id} is in the owner's Approvals inbox: \"${data.text}\"`,\n \"Nothing is changed yet. On the owner's yes the daemon applies it and you get a message with the result; do not edit the org chart yourself.\",\n \"Tell the owner it is waiting for their yes.\",\n ].join(\" \")\n } catch (e: any) {\n return `Error: couldn't reach the daemon (${e?.message ?? e}).`\n }\n}\n"],"mappings":"wdAiBA,IAAMA,EAAoB,IAAI,IAAI,CAAC,OAAQ,YAAa,MAAO,MAAO,OAAQ,YAAa,UAAU,CAAC,EAEtG,SAASC,EAAIC,EAAoB,CAC/B,OAAO,OAAOA,GAAM,SAAWA,EAAE,KAAK,EAAI,EAC5C,CAGA,eAAsBC,EAAWC,EAA+BC,EAAoC,CAClG,IAAMC,EAAUD,EAAK,OAAS,MACxBE,EAAOF,EAAK,UAAU,QAAQ,MAAO,EAAE,EACvCG,EAAMH,EAAK,KAAO,QAAQ,IAC1BI,GAAUR,EAAIG,EAAK,MAAM,GAAK,QAAQ,YAAY,EAExD,GAAIK,IAAW,OACb,GAAI,CACF,IAAMC,EAAM,MAAMJ,EAAQ,GAAGC,YAAgB,CAAE,QAASI,EAAcH,CAAG,EAAG,OAAQ,YAAY,QAAQ,GAAM,CAAE,CAAC,EAC3GI,EAAO,MAAMF,EAAI,KAAK,EAAE,MAAM,KAAO,CAAC,EAAE,EAC9C,OAAKA,EAAI,GACF,OAAOE,EAAK,MAAQ,EAAE,EADT,UAAUA,GAAM,OAAS,QAAQF,EAAI,UAE3D,OAAS,EAAP,CACA,MAAO,qCAAqC,GAAG,SAAW,KAC5D,CAGF,GAAID,IAAW,UAAW,MAAO,0BAA0BA,2BAC3D,IAAMI,EAASC,EAAsBV,EAAMI,CAAG,EAC9C,GAAI,CAACK,EAAQ,MAAO,gEACpB,IAAME,EAAQF,EAAO,SAAWA,EAAO,QAAU,CAACb,EAAkB,IAAIa,EAAO,OAAO,EAClF,CAAE,QAASA,EAAO,QAAS,OAAQA,EAAO,OAAQ,GAAIA,EAAO,UAAY,CAAE,UAAWA,EAAO,SAAU,EAAI,CAAC,CAAG,EAC/G,OACJ,GAAI,CACF,IAAMH,EAAM,MAAMJ,EAAQ,GAAGC,sBAA0B,CACrD,OAAQ,OAER,QAAS,CAAE,eAAgB,mBAAoB,GAAGI,EAAcH,CAAG,CAAE,EACrE,KAAM,KAAK,UAAU,CAAE,QAASJ,EAAK,QAAS,SAAUA,EAAK,SAAU,IAAKA,EAAK,IAAK,UAAWS,EAAO,QAAS,GAAIE,EAAQ,CAAE,MAAAA,CAAM,EAAI,CAAC,CAAG,CAAC,EAC9I,OAAQ,YAAY,QAAQ,GAAM,CACpC,CAAC,EACKH,EAAO,MAAMF,EAAI,KAAK,EAAE,MAAM,KAAO,CAAC,EAAE,EAE9C,OAAKA,EAAI,GACF,CACL,QAAQE,EAAK,KAAK,0CAA0CA,EAAK,QACjE,8IACA,6CACF,EAAE,KAAK,GAAG,EALU,iBAAiBA,GAAM,OAAS,QAAQF,EAAI,UAMlE,OAAS,EAAP,CACA,MAAO,qCAAqC,GAAG,SAAW,KAC5D,CACF","names":["NON_CHAT_CHANNELS","str","v","runOrgTool","args","deps","doFetch","base","env","action","res","callerHeaders","data","caller","resolveScheduleCaller","reply"]}
1
+ {"version":3,"sources":["../src/business/org-tool.ts"],"sourcesContent":["import { resolveScheduleCaller } from \"@/crons/schedule-tool\"\nimport { callerHeaders } from \"@/calls/service\"\n\n// --- Agent-facing `agentx_org` tool (#1678 point 5) ---\n//\n// The owner asks in chat for a change to the org chart. The agent reads the\n// chart with `show`, maps the names it heard to member refs, and sends the\n// changes with `propose`. The tool never writes: the daemon checks every\n// change (POST /api/org/proposals, org-proposals.ts) and raises one\n// Approvals card; on the owner's yes the daemon applies it, not the agent.\n\nexport interface OrgToolDeps {\n daemonUrl: string\n fetch?: typeof fetch\n env?: NodeJS.ProcessEnv\n}\n\nconst NON_CHAT_CHANNELS = new Set([\"cron\", \"heartbeat\", \"api\", \"a2a\", \"mesh\", \"approvals\", \"requests\"])\n\nfunction str(v: unknown): string {\n return typeof v === \"string\" ? v.trim() : \"\"\n}\n\n/** Returns the text the agent sees. Every refusal is text, never a throw. */\nexport async function runOrgTool(args: Record<string, unknown>, deps: OrgToolDeps): Promise<string> {\n const doFetch = deps.fetch ?? fetch\n const base = deps.daemonUrl.replace(/\\/$/, \"\")\n const env = deps.env ?? process.env\n const action = (str(args.action) || \"show\").toLowerCase()\n\n if (action === \"show\") {\n try {\n const res = await doFetch(`${base}/api/org`, { headers: callerHeaders(env), signal: AbortSignal.timeout(10_000) })\n const data = await res.json().catch(() => ({})) as any\n if (!res.ok) return `Error: ${data?.error || `HTTP ${res.status}`}`\n return String(data.text ?? \"\")\n } catch (e: any) {\n return `Error: couldn't reach the daemon (${e?.message ?? e}).`\n }\n }\n\n if (action !== \"propose\") return `Error: unknown action \"${action}\". Use show or propose.`\n const caller = resolveScheduleCaller(args, env)\n if (!caller) return \"Error: couldn't tell which agent you are. Pass callerAgentId.\"\n const reply = caller.channel && caller.chatId && !NON_CHAT_CHANNELS.has(caller.channel)\n ? { channel: caller.channel, chatId: caller.chatId, ...(caller.accountId ? { accountId: caller.accountId } : {}) }\n : undefined\n try {\n const res = await doFetch(`${base}/api/org/proposals`, {\n method: \"POST\",\n // The headers name this run: the daemon checks that the owner started it.\n headers: { \"Content-Type\": \"application/json\", ...callerHeaders(env) },\n body: JSON.stringify({ changes: args.changes, newAgent: args.newAgent, why: args.why, raised_by: caller.agentId, ...(reply ? { reply } : {}) }),\n signal: AbortSignal.timeout(10_000),\n })\n const data = await res.json().catch(() => ({})) as any\n // A refusal is a plain sentence: say it to the owner as it is.\n if (!res.ok) return `Not proposed: ${data?.error || `HTTP ${res.status}`}`\n return [\n `Card ${data.card.id} is in the owner's Approvals inbox: \"${data.text}\"`,\n \"Nothing is changed yet. On the owner's yes the daemon applies it and you get a message with the result; do not edit the org chart yourself.\",\n \"Tell the owner it is waiting for their yes.\",\n ].join(\" \")\n } catch (e: any) {\n return `Error: couldn't reach the daemon (${e?.message ?? e}).`\n }\n}\n"],"mappings":"ubAiBA,IAAM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AAK,SAAU,IAAKA,EAAK,IAAK,UAAWS,EAAO,QAAS,GAAIE,EAAQ,CAAE,MAAAA,CAAM,EAAI,CAAC,CAAG,CAAC,EAC9I,OAAQ,YAAY,QAAQ,GAAM,CACpC,CAAC,EACKH,EAAO,MAAMF,EAAI,KAAK,EAAE,MAAM,KAAO,CAAC,EAAE,EAE9C,OAAKA,EAAI,GACF,CACL,QAAQE,EAAK,KAAK,0CAA0CA,EAAK,QACjE,8IACA,6CACF,EAAE,KAAK,GAAG,EALU,iBAAiBA,GAAM,OAAS,QAAQF,EAAI,UAMlE,OAAS,EAAP,CACA,MAAO,qCAAqC,GAAG,SAAW,KAC5D,CACF","names":["NON_CHAT_CHANNELS","str","v","runOrgTool","args","deps","doFetch","base","env","action","res","callerHeaders","data","caller","resolveScheduleCaller","reply"]}