agentix-cli 0.79.3 → 0.80.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 (128) hide show
  1. package/dist/{App-PFMTQ7J5.js → App-2UCGXCX3.js} +2 -2
  2. package/dist/{ChatApp-ZBSU2F6J.js → ChatApp-IRPSBYC7.js} +2 -2
  3. package/dist/{agent-AMU6E27Z.js → agent-UPTK3HFR.js} +2 -2
  4. package/dist/{board-dashboard-PXP25BBI.js → board-dashboard-GAUAYKWV.js} +337 -215
  5. package/dist/board-dashboard-GAUAYKWV.js.map +1 -0
  6. package/dist/{chunk-7QRCAHPX.js → chunk-2YJ2ZIYC.js} +2 -2
  7. package/dist/{chunk-NGYTRJFT.js → chunk-36TJTWG3.js} +193 -197
  8. package/dist/chunk-36TJTWG3.js.map +1 -0
  9. package/dist/{chunk-EAYHYAF3.js → chunk-3GYCFRBK.js} +2 -2
  10. package/dist/chunk-445P5QPS.js +15 -0
  11. package/dist/{chunk-YKPISR5J.js.map → chunk-445P5QPS.js.map} +1 -1
  12. package/dist/{chunk-MGCTX2BB.js → chunk-4NUF3SXN.js} +2 -2
  13. package/dist/chunk-6TLQ4I32.js +57 -0
  14. package/dist/chunk-6TLQ4I32.js.map +1 -0
  15. package/dist/{chunk-XFCSJUGY.js → chunk-7EIUNFDF.js} +2 -2
  16. package/dist/{chunk-HTKSZZXK.js → chunk-AFSM3IY3.js} +2 -2
  17. package/dist/{chunk-M4XUZA3O.js → chunk-AIHWGU4P.js} +2 -2
  18. package/dist/{chunk-RD5EKHGZ.js → chunk-BBI3HG77.js} +2 -2
  19. package/dist/{chunk-WVYOXM45.js → chunk-BIJB7CNG.js} +2 -2
  20. package/dist/{chunk-R7WZUUYO.js → chunk-D3FDPA74.js} +2 -2
  21. package/dist/{chunk-HEF6MJWT.js → chunk-ECEDX6C6.js} +191 -190
  22. package/dist/chunk-ECEDX6C6.js.map +1 -0
  23. package/dist/chunk-GTJIKXDB.js +2 -0
  24. package/dist/chunk-GTJIKXDB.js.map +1 -0
  25. package/dist/{chunk-EUVMKZUC.js → chunk-I2Z6D3MI.js} +2 -2
  26. package/dist/{chunk-LNQOJC57.js → chunk-KAFUQILA.js} +2 -2
  27. package/dist/{chunk-X6WZ54UJ.js → chunk-KBSBMOOL.js} +79 -79
  28. package/dist/chunk-KBSBMOOL.js.map +1 -0
  29. package/dist/chunk-NMFXY3QU.js +2 -0
  30. package/dist/chunk-NMFXY3QU.js.map +1 -0
  31. package/dist/{chunk-CNSPC4BZ.js → chunk-O67KV3DX.js} +2 -2
  32. package/dist/chunk-OVN5LVJY.js +11 -0
  33. package/dist/chunk-OVN5LVJY.js.map +1 -0
  34. package/dist/{chunk-WNI2P7S6.js → chunk-PHFOYJUB.js} +2 -2
  35. package/dist/{chunk-LPDQ2KK4.js → chunk-PT5Z5WW4.js} +2 -2
  36. package/dist/{chunk-6SJTBTDG.js → chunk-PXIGWFIQ.js} +2 -2
  37. package/dist/chunk-SHEUCITK.js +2 -0
  38. package/dist/chunk-SHEUCITK.js.map +1 -0
  39. package/dist/{chunk-2ZQ42Q4L.js → chunk-Z522XZBL.js} +2 -2
  40. package/dist/{chunk-QOZBSWGX.js → chunk-Z6G26FWC.js} +61 -58
  41. package/dist/chunk-Z6G26FWC.js.map +1 -0
  42. package/dist/cli.js +1 -1
  43. package/dist/cli.js.map +1 -1
  44. package/dist/client-ABDGDO7S.js +2 -0
  45. package/dist/config-XPFCUOQT.js +2 -0
  46. package/dist/config-mutator-WYHQV2XF.js +2 -0
  47. package/dist/{doctor-DST4SVW4.js → doctor-XLLNQRRT.js} +2 -2
  48. package/dist/{facts-2K6UX5GD.js → facts-YY2364CP.js} +2 -2
  49. package/dist/{facts-2K6UX5GD.js.map → facts-YY2364CP.js.map} +1 -1
  50. package/dist/index.d.ts +74 -12
  51. package/dist/index.js +1 -1
  52. package/dist/index.js.map +1 -1
  53. package/dist/program-KZOBDSXQ.js +2 -0
  54. package/dist/{promote-CQCRZCYB.js → promote-YUZL3ZU2.js} +2 -2
  55. package/dist/query-3XH7I6WX.js +2 -0
  56. package/dist/registry-5OD2IN5G.js +2 -0
  57. package/dist/{request-planner-TNDIQMHS.js → request-planner-RNXA2QAH.js} +2 -2
  58. package/dist/{review-candidates-SXVIYCVE.js → review-candidates-THKWXS7S.js} +2 -2
  59. package/dist/routing-X45VX723.js +2 -0
  60. package/dist/schedule-tool-ZTL6UZCC.js +2 -0
  61. package/dist/scheduler-VH7IJ4VA.js +2 -0
  62. package/dist/seat-LQ47SSNN.js +2 -0
  63. package/dist/{select-WKMMUWLU.js → select-PRQP2B6G.js} +2 -2
  64. package/dist/{set-enabled-RIE3PLNJ.js → set-enabled-E2ML2E33.js} +2 -2
  65. package/dist/tool-4WPUUUE4.js +4 -0
  66. package/dist/tool-4WPUUUE4.js.map +1 -0
  67. package/dist/{tool-TAMRBONN.js → tool-67JK7SK6.js} +2 -2
  68. package/dist/tool-67JK7SK6.js.map +1 -0
  69. package/dist/wiki-AS5YHSR7.js +2 -0
  70. package/package.json +1 -1
  71. package/dist/board-dashboard-PXP25BBI.js.map +0 -1
  72. package/dist/chunk-2ACZWM7F.js +0 -22
  73. package/dist/chunk-2ACZWM7F.js.map +0 -1
  74. package/dist/chunk-7XB2CVC3.js +0 -2
  75. package/dist/chunk-7XB2CVC3.js.map +0 -1
  76. package/dist/chunk-HEF6MJWT.js.map +0 -1
  77. package/dist/chunk-NGYTRJFT.js.map +0 -1
  78. package/dist/chunk-QOZBSWGX.js.map +0 -1
  79. package/dist/chunk-X6WZ54UJ.js.map +0 -1
  80. package/dist/chunk-YKPISR5J.js +0 -15
  81. package/dist/client-XAE7NLE2.js +0 -2
  82. package/dist/config-5HAWFIEL.js +0 -2
  83. package/dist/config-mutator-Y7KAC4AC.js +0 -2
  84. package/dist/program-6SFB55YD.js +0 -2
  85. package/dist/query-WSLKGCQN.js +0 -2
  86. package/dist/registry-6HKQKIBD.js +0 -2
  87. package/dist/routing-GQWG65DQ.js +0 -2
  88. package/dist/schedule-tool-WXRMJMW6.js +0 -2
  89. package/dist/scheduler-YW6JFH3Z.js +0 -2
  90. package/dist/seat-K2JSQIZ4.js +0 -2
  91. package/dist/tool-TAMRBONN.js.map +0 -1
  92. package/dist/wiki-WBRXHY7J.js +0 -2
  93. /package/dist/{App-PFMTQ7J5.js.map → App-2UCGXCX3.js.map} +0 -0
  94. /package/dist/{ChatApp-ZBSU2F6J.js.map → ChatApp-IRPSBYC7.js.map} +0 -0
  95. /package/dist/{agent-AMU6E27Z.js.map → agent-UPTK3HFR.js.map} +0 -0
  96. /package/dist/{chunk-7QRCAHPX.js.map → chunk-2YJ2ZIYC.js.map} +0 -0
  97. /package/dist/{chunk-EAYHYAF3.js.map → chunk-3GYCFRBK.js.map} +0 -0
  98. /package/dist/{chunk-MGCTX2BB.js.map → chunk-4NUF3SXN.js.map} +0 -0
  99. /package/dist/{chunk-XFCSJUGY.js.map → chunk-7EIUNFDF.js.map} +0 -0
  100. /package/dist/{chunk-HTKSZZXK.js.map → chunk-AFSM3IY3.js.map} +0 -0
  101. /package/dist/{chunk-M4XUZA3O.js.map → chunk-AIHWGU4P.js.map} +0 -0
  102. /package/dist/{chunk-RD5EKHGZ.js.map → chunk-BBI3HG77.js.map} +0 -0
  103. /package/dist/{chunk-WVYOXM45.js.map → chunk-BIJB7CNG.js.map} +0 -0
  104. /package/dist/{chunk-R7WZUUYO.js.map → chunk-D3FDPA74.js.map} +0 -0
  105. /package/dist/{chunk-EUVMKZUC.js.map → chunk-I2Z6D3MI.js.map} +0 -0
  106. /package/dist/{chunk-LNQOJC57.js.map → chunk-KAFUQILA.js.map} +0 -0
  107. /package/dist/{chunk-CNSPC4BZ.js.map → chunk-O67KV3DX.js.map} +0 -0
  108. /package/dist/{chunk-WNI2P7S6.js.map → chunk-PHFOYJUB.js.map} +0 -0
  109. /package/dist/{chunk-LPDQ2KK4.js.map → chunk-PT5Z5WW4.js.map} +0 -0
  110. /package/dist/{chunk-6SJTBTDG.js.map → chunk-PXIGWFIQ.js.map} +0 -0
  111. /package/dist/{chunk-2ZQ42Q4L.js.map → chunk-Z522XZBL.js.map} +0 -0
  112. /package/dist/{client-XAE7NLE2.js.map → client-ABDGDO7S.js.map} +0 -0
  113. /package/dist/{config-5HAWFIEL.js.map → config-XPFCUOQT.js.map} +0 -0
  114. /package/dist/{config-mutator-Y7KAC4AC.js.map → config-mutator-WYHQV2XF.js.map} +0 -0
  115. /package/dist/{doctor-DST4SVW4.js.map → doctor-XLLNQRRT.js.map} +0 -0
  116. /package/dist/{program-6SFB55YD.js.map → program-KZOBDSXQ.js.map} +0 -0
  117. /package/dist/{promote-CQCRZCYB.js.map → promote-YUZL3ZU2.js.map} +0 -0
  118. /package/dist/{query-WSLKGCQN.js.map → query-3XH7I6WX.js.map} +0 -0
  119. /package/dist/{registry-6HKQKIBD.js.map → registry-5OD2IN5G.js.map} +0 -0
  120. /package/dist/{request-planner-TNDIQMHS.js.map → request-planner-RNXA2QAH.js.map} +0 -0
  121. /package/dist/{review-candidates-SXVIYCVE.js.map → review-candidates-THKWXS7S.js.map} +0 -0
  122. /package/dist/{routing-GQWG65DQ.js.map → routing-X45VX723.js.map} +0 -0
  123. /package/dist/{schedule-tool-WXRMJMW6.js.map → schedule-tool-ZTL6UZCC.js.map} +0 -0
  124. /package/dist/{scheduler-YW6JFH3Z.js.map → scheduler-VH7IJ4VA.js.map} +0 -0
  125. /package/dist/{seat-K2JSQIZ4.js.map → seat-LQ47SSNN.js.map} +0 -0
  126. /package/dist/{select-WKMMUWLU.js.map → select-PRQP2B6G.js.map} +0 -0
  127. /package/dist/{set-enabled-RIE3PLNJ.js.map → set-enabled-E2ML2E33.js.map} +0 -0
  128. /package/dist/{wiki-WBRXHY7J.js.map → wiki-AS5YHSR7.js.map} +0 -0
@@ -0,0 +1,2 @@
1
+ import{execFile as a}from"child_process";function i(e,t,n={}){return new Promise(r=>{a(e,t,{timeout:n.timeoutMs??15e3,signal:n.signal,maxBuffer:4*1024*1024,env:{...process.env,PATH:[process.env.PATH??"","/opt/homebrew/bin","/usr/local/bin",`${process.env.HOME??""}/.local/bin`].filter(Boolean).join(":")}},(o,s,c)=>{let u=o&&typeof o.code=="number"?o.code:o?1:0;r({stdout:String(s??""),stderr:String(c??""),code:u})})})}async function d(e){let{code:t}=await i("command",["-v",e],{timeoutMs:3e3}).catch(()=>({code:1}));if(t===0)return!0;let{code:n}=await i("/usr/bin/which",[e],{timeoutMs:3e3});return n===0}export{i as a,d as b};
2
+ //# sourceMappingURL=chunk-GTJIKXDB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/wiki/facts/exec.ts"],"sourcesContent":["import { execFile } from \"child_process\"\n\n/**\n * execFile, not exec — an entity name is untrusted input that reaches\n * this from chat messages and GitLab issue titles. Through a shell,\n * a contact called `; rm -rf ~` is a command. execFile passes argv\n * directly and never opens one.\n */\nexport function run(\n cmd: string,\n args: string[],\n opts: { timeoutMs?: number; signal?: AbortSignal } = {},\n): Promise<{ stdout: string; stderr: string; code: number }> {\n return new Promise((resolve) => {\n execFile(\n cmd,\n args,\n {\n timeout: opts.timeoutMs ?? 15_000,\n signal: opts.signal,\n maxBuffer: 4 * 1024 * 1024,\n // The daemon's PATH is not a login shell's. wacli and gog live in\n // Homebrew, and ~/.local/bin is where the fleet's own tools land.\n env: {\n ...process.env,\n PATH: [\n process.env.PATH ?? \"\",\n \"/opt/homebrew/bin\",\n \"/usr/local/bin\",\n `${process.env.HOME ?? \"\"}/.local/bin`,\n ].filter(Boolean).join(\":\"),\n },\n },\n (err, stdout, stderr) => {\n const code = err && typeof (err as { code?: unknown }).code === \"number\"\n ? ((err as { code: number }).code)\n : err ? 1 : 0\n resolve({ stdout: String(stdout ?? \"\"), stderr: String(stderr ?? \"\"), code })\n },\n )\n })\n}\n\nexport async function binaryExists(cmd: string): Promise<boolean> {\n const { code } = await run(\"command\", [\"-v\", cmd], { timeoutMs: 3000 }).catch(() => ({ code: 1 }) as never)\n if (code === 0) return true\n // `command` is a shell builtin, so the above fails on most systems.\n const { code: which } = await run(\"/usr/bin/which\", [cmd], { timeoutMs: 3000 })\n return which === 0\n}\n"],"mappings":"AAAA,OAAS,YAAAA,MAAgB,gBAQlB,SAASC,EACdC,EACAC,EACAC,EAAqD,CAAC,EACK,CAC3D,OAAO,IAAI,QAASC,GAAY,CAC9BL,EACEE,EACAC,EACA,CACE,QAASC,EAAK,WAAa,KAC3B,OAAQA,EAAK,OACb,UAAW,EAAI,KAAO,KAGtB,IAAK,CACH,GAAG,QAAQ,IACX,KAAM,CACJ,QAAQ,IAAI,MAAQ,GACpB,oBACA,iBACA,GAAG,QAAQ,IAAI,MAAQ,eACzB,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG,CAC5B,CACF,EACA,CAACE,EAAKC,EAAQC,IAAW,CACvB,IAAMC,EAAOH,GAAO,OAAQA,EAA2B,MAAS,SAC1DA,EAAyB,KAC3BA,EAAM,EAAI,EACdD,EAAQ,CAAE,OAAQ,OAAOE,GAAU,EAAE,EAAG,OAAQ,OAAOC,GAAU,EAAE,EAAG,KAAAC,CAAK,CAAC,CAC9E,CACF,CACF,CAAC,CACH,CAEA,eAAsBC,EAAaR,EAA+B,CAChE,GAAM,CAAE,KAAAO,CAAK,EAAI,MAAMR,EAAI,UAAW,CAAC,KAAMC,CAAG,EAAG,CAAE,UAAW,GAAK,CAAC,EAAE,MAAM,KAAO,CAAE,KAAM,CAAE,EAAW,EAC1G,GAAIO,IAAS,EAAG,MAAO,GAEvB,GAAM,CAAE,KAAME,CAAM,EAAI,MAAMV,EAAI,iBAAkB,CAACC,CAAG,EAAG,CAAE,UAAW,GAAK,CAAC,EAC9E,OAAOS,IAAU,CACnB","names":["execFile","run","cmd","args","opts","resolve","err","stdout","stderr","code","binaryExists","which"]}
@@ -1,5 +1,5 @@
1
- import{E as m,H as b}from"./chunk-YKPISR5J.js";b();function w(t){let e=typeof t.node=="string"?t.node:"",n=typeof t.token=="string"?t.token:"";if(!e||!n)try{let o=m(t.config);e||(e=o.dashboard?.daemonUrl||""),n||(n=o.dashboard?.token||"")}catch{}return e||(e="http://localhost:18800"),{baseUrl:e.replace(/\/+$/,""),token:n}}async function d(t,e,n){let o={Accept:"application/json"};t.token&&(o.Authorization=`Bearer ${t.token}`);let r=await fetch(`${t.baseUrl}${e}`,{headers:o,signal:n});if(!r.ok)throw new Error(`GET ${e} \u2192 HTTP ${r.status}`);return await r.json()}function R(t,e){return d(t,"/agents",e)}async function S(t,e){return(await d(t,"/api/processes",e)).processes??[]}function P(t,e){return d(t,"/crons",e)}async function h(t,e,n,o){let r={Accept:"application/json","Content-Type":"application/json"};t.token&&(r.Authorization=`Bearer ${t.token}`);let s=await fetch(`${t.baseUrl}${e}`,{method:"POST",headers:r,body:JSON.stringify(n),signal:o}),a=await s.text(),i;try{i=a?JSON.parse(a):{}}catch{i={raw:a}}if(!s.ok)throw new Error(i?.error||`POST ${e} \u2192 HTTP ${s.status}`);return i}function A(t,e,n="tui"){return h(t,"/api/processes/kill",{...e,reason:n})}function C(t,e,n,o){return h(t,"/task",{agent:e,message:n,context:o??{channel:"tui",chatId:"tui:operator"}})}async function $(t,e,n,o={}){let r={Accept:"text/event-stream","Content-Type":"application/json"};t.token&&(r.Authorization=`Bearer ${t.token}`);let s=await fetch(`${t.baseUrl}/task`,{method:"POST",headers:r,body:JSON.stringify({agent:e,message:n,stream:!0,context:{channel:o.channel??"chat-cli",chatId:o.chatId??"chat-cli:operator"}}),signal:o.signal});if(!s.ok||!s.body){let g=await s.text().catch(()=>"");throw new Error(`POST /task (stream) \u2192 HTTP ${s.status}${g?`: ${g.slice(0,200)}`:""}`)}let a=s.body.getReader(),i=new TextDecoder,u={content:""},c="";try{for(;;){let{done:g,value:p}=await a.read();if(g)break;c+=i.decode(p,{stream:!0});let l;for(;(l=c.indexOf(`
1
+ import{F as m,I as b}from"./chunk-445P5QPS.js";b();function w(t){let e=typeof t.node=="string"?t.node:"",n=typeof t.token=="string"?t.token:"";if(!e||!n)try{let o=m(t.config);e||(e=o.dashboard?.daemonUrl||""),n||(n=o.dashboard?.token||"")}catch{}return e||(e="http://localhost:18800"),{baseUrl:e.replace(/\/+$/,""),token:n}}async function d(t,e,n){let o={Accept:"application/json"};t.token&&(o.Authorization=`Bearer ${t.token}`);let r=await fetch(`${t.baseUrl}${e}`,{headers:o,signal:n});if(!r.ok)throw new Error(`GET ${e} \u2192 HTTP ${r.status}`);return await r.json()}function R(t,e){return d(t,"/agents",e)}async function S(t,e){return(await d(t,"/api/processes",e)).processes??[]}function P(t,e){return d(t,"/crons",e)}async function h(t,e,n,o){let r={Accept:"application/json","Content-Type":"application/json"};t.token&&(r.Authorization=`Bearer ${t.token}`);let s=await fetch(`${t.baseUrl}${e}`,{method:"POST",headers:r,body:JSON.stringify(n),signal:o}),a=await s.text(),i;try{i=a?JSON.parse(a):{}}catch{i={raw:a}}if(!s.ok)throw new Error(i?.error||`POST ${e} \u2192 HTTP ${s.status}`);return i}function A(t,e,n="tui"){return h(t,"/api/processes/kill",{...e,reason:n})}function C(t,e,n,o){return h(t,"/task",{agent:e,message:n,context:o??{channel:"tui",chatId:"tui:operator"}})}async function $(t,e,n,o={}){let r={Accept:"text/event-stream","Content-Type":"application/json"};t.token&&(r.Authorization=`Bearer ${t.token}`);let s=await fetch(`${t.baseUrl}/task`,{method:"POST",headers:r,body:JSON.stringify({agent:e,message:n,stream:!0,context:{channel:o.channel??"chat-cli",chatId:o.chatId??"chat-cli:operator"}}),signal:o.signal});if(!s.ok||!s.body){let g=await s.text().catch(()=>"");throw new Error(`POST /task (stream) \u2192 HTTP ${s.status}${g?`: ${g.slice(0,200)}`:""}`)}let a=s.body.getReader(),i=new TextDecoder,u={content:""},c="";try{for(;;){let{done:g,value:p}=await a.read();if(g)break;c+=i.decode(p,{stream:!0});let l;for(;(l=c.indexOf(`
2
2
 
3
3
  `))>=0;){let k=c.slice(0,l);c=c.slice(l+2);let f=x(k);f&&T(f,o,u)}}}finally{try{a.releaseLock()}catch{}}return u}function T(t,e,n){let{event:o,data:r}=t;switch(o){case"text":r?.text&&(n.content+=r.text,e.onText?.(r.text));break;case"thinking":r?.text&&e.onThinking?.(r.text);break;case"tool":e.onTool?.(r);break;case"done":typeof r?.content=="string"&&(n.content=r.content),n.usage=r?.usage,n.duration=r?.duration;break;case"error":n.error=r?.error,n.errorKind=r?.errorKind;break}}function x(t){let e="message",n="";for(let r of t.split(`
4
4
  `))r.startsWith("event: ")?e=r.slice(7).trim():r.startsWith("data: ")&&(n=r.slice(6));if(!n)return null;let o;try{o=JSON.parse(n)}catch{o=n}return{event:e,data:o}}export{w as a,R as b,S as c,P as d,A as e,C as f,$ as g};
5
- //# sourceMappingURL=chunk-EUVMKZUC.js.map
5
+ //# sourceMappingURL=chunk-I2Z6D3MI.js.map
@@ -1,8 +1,8 @@
1
- import{a as D,b as _}from"./chunk-RKPAVWXF.js";import{a as q,b as O,c as R,d as B,f as b,g as S,h as E,i as w,j as y}from"./chunk-WVYOXM45.js";import{a as T,b as C,c as I,d as x,e as P}from"./chunk-HTKSZZXK.js";import{existsSync as X,readFileSync as F}from"fs";var J=new Set(["cron","heartbeat","api","a2a","mesh"]),M=160;function s(n){return typeof n=="string"&&n.trim()?n.trim():void 0}function A(n,e=M){let t=n.replace(/\s+/g," ").trim();return t.length>e?`${t.slice(0,e-1)}\u2026`:t}function V(n){let e=T(n);if(!X(e))throw new Error(`config not found at ${e}`);return JSON.parse(F(e,"utf-8"))}function W(n,e){return n?.agents?.[e]?.admin===!0}function Y(n,e,t){return W(n,t.agentId)||e?.createdBy===t.agentId}function Z(n,e){let t=e?.createdBy?`agent "${e.createdBy}"`:"the operator";return`Not allowed: "${n}" was created by ${t}. Agents manage only schedules they created (unless configured admin).`}function K(n,e){let t=s(n.notify);if(t!=="none"){if(t&&t!=="here"){let r=t.split(":");return r.length<2||!r[0]||!r[1]?"invalid":{channel:r[0],chatId:r.slice(1).join(":")}}if(e.channel&&e.chatId&&!J.has(e.channel))return{channel:e.channel,chatId:e.chatId,...e.accountId?{accountId:e.accountId}:{}}}}function Q(n,e,t){let r=e.timezone||"UTC",u=e.enabled&&!y(e)?w(E(e.schedule,r,t),r):"\u2014",h=e.approval?`pending ${e.approval.action} approval`:e.enabled?"active":"paused",p=[`- ${n} [${h}] ${e.schedule} \u2014 ${S(e.schedule)} (${r})`,` agent: ${e.agent}; created by: ${e.createdBy||"operator"}; next: ${u}`];return e.notify&&p.push(` notify: ${e.notify.channel} ${e.notify.chatId}`),e.command?p.push(` command: ${A(String(e.command))}`):e.prompt&&p.push(` prompt: ${A(String(e.prompt))}`),p.join(`
1
+ import{a as D,b as _}from"./chunk-RKPAVWXF.js";import{a as q,b as O,c as R,d as B,f as b,g as S,h as E,i as w,j as y}from"./chunk-BIJB7CNG.js";import{a as T,b as C,c as I,d as x,e as P}from"./chunk-AFSM3IY3.js";import{existsSync as X,readFileSync as F}from"fs";var J=new Set(["cron","heartbeat","api","a2a","mesh"]),M=160;function s(n){return typeof n=="string"&&n.trim()?n.trim():void 0}function A(n,e=M){let t=n.replace(/\s+/g," ").trim();return t.length>e?`${t.slice(0,e-1)}\u2026`:t}function V(n){let e=T(n);if(!X(e))throw new Error(`config not found at ${e}`);return JSON.parse(F(e,"utf-8"))}function W(n,e){return n?.agents?.[e]?.admin===!0}function Y(n,e,t){return W(n,t.agentId)||e?.createdBy===t.agentId}function Z(n,e){let t=e?.createdBy?`agent "${e.createdBy}"`:"the operator";return`Not allowed: "${n}" was created by ${t}. Agents manage only schedules they created (unless configured admin).`}function K(n,e){let t=s(n.notify);if(t!=="none"){if(t&&t!=="here"){let r=t.split(":");return r.length<2||!r[0]||!r[1]?"invalid":{channel:r[0],chatId:r.slice(1).join(":")}}if(e.channel&&e.chatId&&!J.has(e.channel))return{channel:e.channel,chatId:e.chatId,...e.accountId?{accountId:e.accountId}:{}}}}function Q(n,e,t){let r=e.timezone||"UTC",u=e.enabled&&!y(e)?w(E(e.schedule,r,t),r):"\u2014",h=e.approval?`pending ${e.approval.action} approval`:e.enabled?"active":"paused",p=[`- ${n} [${h}] ${e.schedule} \u2014 ${S(e.schedule)} (${r})`,` agent: ${e.agent}; created by: ${e.createdBy||"operator"}; next: ${u}`];return e.notify&&p.push(` notify: ${e.notify.channel} ${e.notify.chatId}`),e.command?p.push(` command: ${A(String(e.command))}`):e.prompt&&p.push(` prompt: ${A(String(e.prompt))}`),p.join(`
2
2
  `)}async function k(n,e,t){let r=n?.notifications?.destination;if(!r?.channel||!r?.chatId)return"No operator notification destination is configured (notifications.destination); the operator must check `agentx schedule list`.";if(!e.notifyOperator)return"Operator notification is unavailable in this context.";try{return await e.notifyOperator({channel:r.channel,chatId:r.chatId,accountId:r.accountId},t),"The operator has been notified."}catch(u){return`Could not notify the operator (${u?.message??u}); the request is still recorded.`}}async function re(n,e,t={}){let r=(s(n.action)||"list").toLowerCase(),u=t.now?t.now():new Date,h;try{h=V(t.configPath)}catch(a){return`Error: ${a.message}`}let p=h.crons||{};if(r==="list"){let a=n.mine===!0,l=Object.entries(p).filter(([,i])=>!a||e&&i?.createdBy===e.agentId);return l.length?l.map(([i,f])=>Q(i,f,u)).join(`
3
3
  `):a?"You have no schedules.":"No schedules."}if(!e?.agentId)return"Error: caller agent is unknown (AGENTX_AGENT_ID not set). Pass callerAgentId.";if(!h.agents?.[e.agentId])return`Error: caller "${e.agentId}" is not an agent on this node.`;let o=s(n.id),m=a=>C(a,{configPath:t.configPath,reload:t.reload});if(r==="create"){let a=s(n.when),l=s(n.prompt);if(!a||!l)return"Error: create needs `when` (plain English) and `prompt`.";let i=D(a);if(!i)return`Error: couldn't parse "${a}". ${O}.`;let f=s(n.agent)||e.agentId;if(!h.agents?.[f])return`Error: agent "${f}" not found on this node.`;let g=s(n.timezone)||q;if(!B(g))return`Error: unknown timezone "${g}".`;let d=o||_(i.matched,f);if(!R(d))return`Error: invalid id "${d}" (letters, digits, "-" and "_" only).`;if(p[d])return`Error: a schedule "${d}" already exists. Pick another \`id\`.`;let $=K(n,e);if($==="invalid")return'Error: `notify` must be "here", "none", or "channel:chatId".';let z={action:"create",requestedBy:e.agentId,requestedAt:u.toISOString()},L=b({parsed:i,agent:f,prompt:l,timezone:g,notify:$,enabled:!1,createdBy:e.agentId,approval:z}),v=await m(U=>I(U,`crons.${d}`,L));if(!v.success)return`Error: ${v.error}`;let N=w(E(i.cron,g,u),g),G=[`Schedule approval requested by ${e.agentId}`,`Create: ${d}`,`When: ${i.human} \u2014 cron \`${i.cron}\` (${g})`,`Next fire: ${N}`,`Agent: ${f}`,$?`Notify: ${$.channel} ${$.chatId}`:"Notify: none",`Prompt: ${A(l,400)}`,"",`Approve: agentx schedule approve ${d}`,`Reject: agentx schedule reject ${d}`].join(`
4
4
  `),H=await k(h,t,G);return[`Requested schedule "${d}": ${i.human} (cron ${i.cron}, ${g}); next fire would be ${N}.`,"It is saved DISABLED and will not run until the operator approves it.",H].join(`
5
5
  `)}if(!o)return`Error: ${r} needs \`id\`.`;let c=p[o];if(!c)return`Error: schedule "${o}" not found.`;if(!Y(h,c,e))return Z(o,c);if(r==="pause"||r==="resume"){let a=r==="resume";if(a&&y(c))return`"${o}" is still awaiting operator approval; it can't be resumed until approved.`;if(c.enabled===a)return`"${o}" is already ${a?"active":"paused"}.`;let l=await m(i=>I(i,`crons.${o}.enabled`,a));return l.success?`"${o}" ${a?"resumed":"paused"}.`:`Error: ${l.error}`}if(r==="delete"){if(y(c)&&c.approval.requestedBy===e.agentId){let d=await m($=>P($,`crons.${o}`));return d.success?`Withdrew the pending request "${o}".`:`Error: ${d.error}`}if(y(c))return`"${o}" is a creation request still awaiting approval; only its requester or the operator (\`agentx schedule reject ${o}\`) can drop it.`;if(c.approval?.action==="delete")return`Deletion of "${o}" is already awaiting approval.`;let a={action:"delete",requestedBy:e.agentId,requestedAt:u.toISOString()},l=await m(d=>{if(!x(d,`crons.${o}`))throw new Error(`schedule "${o}" not found`);I(d,`crons.${o}.approval`,a)});if(!l.success)return`Error: ${l.error}`;let i=c.timezone||"UTC",f=[`Schedule approval requested by ${e.agentId}`,`Delete: ${o}`,`When: ${S(c.schedule)} \u2014 cron \`${c.schedule}\` (${i})`,`Next fire: ${c.enabled?w(E(c.schedule,i,u),i):"\u2014 (paused)"}`,`Agent: ${c.agent}`,"",`Approve: agentx schedule approve ${o}`,`Reject: agentx schedule reject ${o}`].join(`
6
6
  `),g=await k(h,t,f);return[`Deletion of "${o}" requested. It keeps its current state until the operator approves.`,g].join(`
7
7
  `)}return`Error: unknown action "${r}". Use list, create, pause, resume or delete.`}function oe(n,e=process.env){let t=s(e.AGENTX_AGENT_ID)||s(n.callerAgentId);if(!t)return null;let r=!!(s(e.AGENTX_CHANNEL)&&s(e.AGENTX_CHAT_ID)),u=s(r?e.AGENTX_CHANNEL:n.channel),h=s(r?e.AGENTX_CHAT_ID:n.chatId),p=s(n.accountId);return{agentId:t,channel:u,chatId:h,...p?{accountId:p}:{}}}export{re as a,oe as b};
8
- //# sourceMappingURL=chunk-LNQOJC57.js.map
8
+ //# sourceMappingURL=chunk-KAFUQILA.js.map