agentix-cli 0.110.0 → 0.111.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 (138) hide show
  1. package/apps/mac-voice/Sources/AgentXVoice/Panel.swift +77 -30
  2. package/apps/mac-voice/Sources/AgentXVoice/PanelAnswer.swift +3 -2
  3. package/apps/mac-voice/Sources/AgentXVoice/PillForm.swift +55 -0
  4. package/apps/mac-voice/Sources/AgentXVoice/PillMenu.swift +8 -7
  5. package/apps/mac-voice/Sources/AgentXVoice/SettingsLook.swift +2 -2
  6. package/apps/mac-voice/Sources/AgentXVoice/StatusMenu.swift +5 -6
  7. package/apps/mac-voice/Sources/AgentXVoice/main.swift +7 -6
  8. package/dist/{App-4VWAQOVA.js → App-T4Q7SW6M.js} +2 -2
  9. package/dist/{ChatApp-KOTGUDZH.js → ChatApp-BKUJUIDL.js} +2 -2
  10. package/dist/{agent-CGRHC2IS.js → agent-YZVEXFE7.js} +2 -2
  11. package/dist/{board-dashboard-SAYBNLZW.js → board-dashboard-3TVUCOSI.js} +411 -257
  12. package/dist/board-dashboard-3TVUCOSI.js.map +1 -0
  13. package/dist/{chunk-UVMCAZL7.js → chunk-4FU4BFCH.js} +2 -2
  14. package/dist/{chunk-NIW75USA.js → chunk-4NFDDTGA.js} +2 -2
  15. package/dist/{chunk-2VGYRETU.js → chunk-53OS4TDU.js} +2 -2
  16. package/dist/{chunk-J32LSOBJ.js → chunk-7UNS34CN.js} +2 -2
  17. package/dist/chunk-AV7T3SYT.js +111 -0
  18. package/dist/chunk-AV7T3SYT.js.map +1 -0
  19. package/dist/chunk-DTQQ4DAY.js +154 -0
  20. package/dist/chunk-DTQQ4DAY.js.map +1 -0
  21. package/dist/{chunk-SFPMS55Z.js → chunk-DUBCOGQB.js} +49 -48
  22. package/dist/chunk-DUBCOGQB.js.map +1 -0
  23. package/dist/{chunk-BFOB6ERR.js → chunk-DXWDVKMX.js} +2 -2
  24. package/dist/{chunk-BZKGQMU2.js → chunk-FBODSJU6.js} +2 -2
  25. package/dist/{chunk-UTV4DRAW.js → chunk-GQMUFSKB.js} +14 -14
  26. package/dist/{chunk-UTV4DRAW.js.map → chunk-GQMUFSKB.js.map} +1 -1
  27. package/dist/{chunk-4UCDWEC4.js → chunk-HCTWKWS3.js} +2 -2
  28. package/dist/{chunk-EC6DKMR5.js → chunk-KDD6FPQ6.js} +238 -238
  29. package/dist/chunk-KDD6FPQ6.js.map +1 -0
  30. package/dist/{chunk-5O6PIO7F.js → chunk-LWYKS5JU.js} +2 -2
  31. package/dist/{chunk-QQAZ6EJP.js → chunk-M2L6S3Z5.js} +2 -2
  32. package/dist/{chunk-6F2E5NQA.js → chunk-QJP37VVA.js} +2 -2
  33. package/dist/{chunk-QFP4YZII.js → chunk-RS2T53EC.js} +2 -2
  34. package/dist/{chunk-E5OV6RTG.js → chunk-RXLU6HJ6.js} +3 -3
  35. package/dist/chunk-RXLU6HJ6.js.map +1 -0
  36. package/dist/{chunk-D7M4WQFU.js → chunk-SIOWVLZG.js} +4 -4
  37. package/dist/chunk-SIOWVLZG.js.map +1 -0
  38. package/dist/{chunk-BG6SOGKT.js → chunk-U52IS3AF.js} +2 -2
  39. package/dist/{chunk-RJ7DASOU.js → chunk-UIBUZ2N3.js} +25 -10
  40. package/dist/chunk-UIBUZ2N3.js.map +1 -0
  41. package/dist/{chunk-MJWJ3JVA.js → chunk-WSKQUKCF.js} +2 -2
  42. package/dist/{chunk-S4NZUPIN.js → chunk-WXQQO2PD.js} +2 -2
  43. package/dist/{chunk-FHI5WPFO.js → chunk-WYSNRZV4.js} +4 -4
  44. package/dist/chunk-WYSNRZV4.js.map +1 -0
  45. package/dist/{chunk-CJR26JUI.js → chunk-XEOT2F4C.js} +2 -2
  46. package/dist/{chunk-3Z5P2CWS.js → chunk-XF26QNAW.js} +2 -2
  47. package/dist/{chunk-CJL5OPNQ.js → chunk-Z7L74GGT.js} +2 -2
  48. package/dist/cli.js +1 -1
  49. package/dist/{client-VYMTUZKN.js → client-O7SPKO5X.js} +2 -2
  50. package/dist/config-ZHQYXFOJ.js +2 -0
  51. package/dist/config-mutator-RS2NTDNO.js +2 -0
  52. package/dist/{doctor-GHUPUBET.js → doctor-XP7O45RC.js} +2 -2
  53. package/dist/{grants-Y667GZAU.js → grants-M4K6WXOO.js} +2 -2
  54. package/dist/index.d.ts +68 -15
  55. package/dist/index.js +1 -1
  56. package/dist/{program-V2JEVJAD.js → program-EZLJIVQX.js} +187 -182
  57. package/dist/program-EZLJIVQX.js.map +1 -0
  58. package/dist/{promote-KY3Y2PVU.js → promote-UGWANGI2.js} +2 -2
  59. package/dist/{query-BYCRYDM3.js → query-ZET7Z5FT.js} +2 -2
  60. package/dist/registry-UXWOY52B.js +2 -0
  61. package/dist/request-planner-W5YLKCGG.js +6 -0
  62. package/dist/request-planner-W5YLKCGG.js.map +1 -0
  63. package/dist/{review-candidates-56ZPJNXW.js → review-candidates-GU4S5VQH.js} +2 -2
  64. package/dist/{routing-WKS2CZYF.js → routing-GJ4VXKIC.js} +2 -2
  65. package/dist/schedule-tool-HD4LWKVC.js +2 -0
  66. package/dist/scheduler-3LEHZHWJ.js +2 -0
  67. package/dist/seat-L6XJ2BFA.js +2 -0
  68. package/dist/select-T7CKKLC2.js +2 -0
  69. package/dist/{select-73JC2YBN.js.map → select-T7CKKLC2.js.map} +1 -1
  70. package/dist/{set-enabled-WQAO4BFF.js → set-enabled-U2HGNY2O.js} +2 -2
  71. package/dist/{surface-usage-CH3SHO77.js → surface-usage-HCJTUS6Z.js} +2 -2
  72. package/dist/{tool-QDU6MY6B.js → tool-2FMWZB4N.js} +2 -2
  73. package/dist/{tool-GCPMPPUE.js → tool-TX622HEB.js} +2 -2
  74. package/dist/wiki-MYJBOJSM.js +2 -0
  75. package/dist/workspace-setup-HAV4CQV7.js +2 -0
  76. package/package.json +2 -1
  77. package/dist/board-dashboard-SAYBNLZW.js.map +0 -1
  78. package/dist/chunk-3TY6YJHO.js +0 -153
  79. package/dist/chunk-3TY6YJHO.js.map +0 -1
  80. package/dist/chunk-D7M4WQFU.js.map +0 -1
  81. package/dist/chunk-E5OV6RTG.js.map +0 -1
  82. package/dist/chunk-EC6DKMR5.js.map +0 -1
  83. package/dist/chunk-FHI5WPFO.js.map +0 -1
  84. package/dist/chunk-RJ7DASOU.js.map +0 -1
  85. package/dist/chunk-SFPMS55Z.js.map +0 -1
  86. package/dist/chunk-UDJAODAB.js +0 -100
  87. package/dist/chunk-UDJAODAB.js.map +0 -1
  88. package/dist/config-J6CNV23P.js +0 -2
  89. package/dist/config-mutator-RGC72OEU.js +0 -2
  90. package/dist/program-V2JEVJAD.js.map +0 -1
  91. package/dist/registry-NDFYNQG4.js +0 -2
  92. package/dist/request-planner-YOUVO3BR.js +0 -2
  93. package/dist/request-planner-YOUVO3BR.js.map +0 -1
  94. package/dist/schedule-tool-4L6QAILN.js +0 -2
  95. package/dist/scheduler-65SE3WJJ.js +0 -2
  96. package/dist/seat-EO3EVBH3.js +0 -2
  97. package/dist/select-73JC2YBN.js +0 -2
  98. package/dist/wiki-CQZE5Z5C.js +0 -2
  99. package/dist/workspace-setup-EA3G42NY.js +0 -2
  100. /package/dist/{App-4VWAQOVA.js.map → App-T4Q7SW6M.js.map} +0 -0
  101. /package/dist/{ChatApp-KOTGUDZH.js.map → ChatApp-BKUJUIDL.js.map} +0 -0
  102. /package/dist/{agent-CGRHC2IS.js.map → agent-YZVEXFE7.js.map} +0 -0
  103. /package/dist/{chunk-UVMCAZL7.js.map → chunk-4FU4BFCH.js.map} +0 -0
  104. /package/dist/{chunk-NIW75USA.js.map → chunk-4NFDDTGA.js.map} +0 -0
  105. /package/dist/{chunk-2VGYRETU.js.map → chunk-53OS4TDU.js.map} +0 -0
  106. /package/dist/{chunk-J32LSOBJ.js.map → chunk-7UNS34CN.js.map} +0 -0
  107. /package/dist/{chunk-BFOB6ERR.js.map → chunk-DXWDVKMX.js.map} +0 -0
  108. /package/dist/{chunk-BZKGQMU2.js.map → chunk-FBODSJU6.js.map} +0 -0
  109. /package/dist/{chunk-4UCDWEC4.js.map → chunk-HCTWKWS3.js.map} +0 -0
  110. /package/dist/{chunk-5O6PIO7F.js.map → chunk-LWYKS5JU.js.map} +0 -0
  111. /package/dist/{chunk-QQAZ6EJP.js.map → chunk-M2L6S3Z5.js.map} +0 -0
  112. /package/dist/{chunk-6F2E5NQA.js.map → chunk-QJP37VVA.js.map} +0 -0
  113. /package/dist/{chunk-QFP4YZII.js.map → chunk-RS2T53EC.js.map} +0 -0
  114. /package/dist/{chunk-BG6SOGKT.js.map → chunk-U52IS3AF.js.map} +0 -0
  115. /package/dist/{chunk-MJWJ3JVA.js.map → chunk-WSKQUKCF.js.map} +0 -0
  116. /package/dist/{chunk-S4NZUPIN.js.map → chunk-WXQQO2PD.js.map} +0 -0
  117. /package/dist/{chunk-CJR26JUI.js.map → chunk-XEOT2F4C.js.map} +0 -0
  118. /package/dist/{chunk-3Z5P2CWS.js.map → chunk-XF26QNAW.js.map} +0 -0
  119. /package/dist/{chunk-CJL5OPNQ.js.map → chunk-Z7L74GGT.js.map} +0 -0
  120. /package/dist/{client-VYMTUZKN.js.map → client-O7SPKO5X.js.map} +0 -0
  121. /package/dist/{config-J6CNV23P.js.map → config-ZHQYXFOJ.js.map} +0 -0
  122. /package/dist/{config-mutator-RGC72OEU.js.map → config-mutator-RS2NTDNO.js.map} +0 -0
  123. /package/dist/{doctor-GHUPUBET.js.map → doctor-XP7O45RC.js.map} +0 -0
  124. /package/dist/{grants-Y667GZAU.js.map → grants-M4K6WXOO.js.map} +0 -0
  125. /package/dist/{promote-KY3Y2PVU.js.map → promote-UGWANGI2.js.map} +0 -0
  126. /package/dist/{query-BYCRYDM3.js.map → query-ZET7Z5FT.js.map} +0 -0
  127. /package/dist/{registry-NDFYNQG4.js.map → registry-UXWOY52B.js.map} +0 -0
  128. /package/dist/{review-candidates-56ZPJNXW.js.map → review-candidates-GU4S5VQH.js.map} +0 -0
  129. /package/dist/{routing-WKS2CZYF.js.map → routing-GJ4VXKIC.js.map} +0 -0
  130. /package/dist/{schedule-tool-4L6QAILN.js.map → schedule-tool-HD4LWKVC.js.map} +0 -0
  131. /package/dist/{scheduler-65SE3WJJ.js.map → scheduler-3LEHZHWJ.js.map} +0 -0
  132. /package/dist/{seat-EO3EVBH3.js.map → seat-L6XJ2BFA.js.map} +0 -0
  133. /package/dist/{set-enabled-WQAO4BFF.js.map → set-enabled-U2HGNY2O.js.map} +0 -0
  134. /package/dist/{surface-usage-CH3SHO77.js.map → surface-usage-HCJTUS6Z.js.map} +0 -0
  135. /package/dist/{tool-QDU6MY6B.js.map → tool-2FMWZB4N.js.map} +0 -0
  136. /package/dist/{tool-GCPMPPUE.js.map → tool-TX622HEB.js.map} +0 -0
  137. /package/dist/{wiki-CQZE5Z5C.js.map → wiki-MYJBOJSM.js.map} +0 -0
  138. /package/dist/{workspace-setup-EA3G42NY.js.map → workspace-setup-HAV4CQV7.js.map} +0 -0
@@ -1,5 +1,5 @@
1
- import{ha as m,ka as b}from"./chunk-D7M4WQFU.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{ia as m,la as b}from"./chunk-SIOWVLZG.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-CJR26JUI.js.map
5
+ //# sourceMappingURL=chunk-XEOT2F4C.js.map
@@ -1,3 +1,3 @@
1
- import{e as A,g as x,p as G}from"./chunk-E5OV6RTG.js";import{a as w,e as b}from"./chunk-2QNT5JDS.js";b();var h="guest:",P="guests",_=7,y=365,T=400;function $(e){let t=e.scopes.find(n=>n.startsWith(h));return t?t.slice(h.length):null}function R(e){return`g-${e.toString(36)}-${Math.random().toString(36).slice(2,6)}`}var l=e=>(Array.isArray(e)?e:typeof e=="string"?e.split(","):[]).map(t=>String(t).trim()).filter(Boolean).slice(0,50);function Y(e,t){let n=(e.now??Date.now)(),r=String(t.name??"").trim().slice(0,120),s=String(t.guest??"").trim().slice(0,80);if(!r)return{ok:!1,error:'name is required: what you call this grant, e.g. "Support session for company X"'};if(!s)return{ok:!1,error:"guest is required: the other organisation's name"};if(!t.agentId||!e.hasAgent(t.agentId))return{ok:!1,error:`agent must be an agent on this node, got "${t.agentId??""}"`};let a=w.safeParse(t.level??"propose");if(!a.success)return{ok:!1,error:"level must be report, propose or act"};let o=t.days===void 0?_:Number(t.days);if(!Number.isFinite(o)||o<1||o>y)return{ok:!1,error:`days must be between 1 and ${y}`};let d=R(n),{token:u,record:g}=e.tokens.create({name:`guest ${s} (${r})`,scopes:[`${h}${d}`],expiresInDays:Math.ceil(o)}),{code:i,expiresAt:p}=e.codes.create({token:u,tokenId:g.id,name:d}),c={id:d,name:r,guest:s,agentId:t.agentId,folders:l(t.folders),skills:l(t.skills),commands:l(t.commands),level:a.data,state:"pending",tokenId:g.id,createdAt:new Date(n).toISOString(),expiresAt:new Date(n+o*864e5).toISOString(),usage:{turns:0,tokens:0}};return e.guests.add(c),e.guests.log({grant:d,event:"invited",detail:`${s}: ${r}`}),{ok:!0,code:i,codeExpiresAt:p,grant:c}}var J="That code didn't work. Ask the host for a new one.";async function q(e,t,n){let r=Date.now(),s=n.now??Date.now,a=n.log??(f=>console.log(f)),o=n.limiter.retryAfter(t);if(o>0)return a(`[guests] join refused from ${t}: locked out for ${o}s more`),{status:429,body:{error:"too many attempts",retryAfter:o},retryAfter:o};let d=n.codes.redeem(e.code),u=d?n.tokens.verify(d.token):null,g=u?$(u):null,i=g?n.guests.get(g):null;if(await L(r,n.minMs??T),!d||!u||!i||i.tokenId!==u.id||i.state==="ended")return n.limiter.fail(t),a(`[guests] join failed from ${t}`),{status:401,body:{error:G}};n.limiter.succeed(t);let p=e.node&&typeof e.node=="object"?e.node:{},c=(f,S)=>typeof f=="string"&&f.trim()?f.replace(/\s+/g," ").trim().slice(0,S):void 0,m={id:c(p.id,80),name:c(p.name,80),address:t},D=i.expiresAt.slice(0,10),k=x(n.root,{title:`Guest mesh: ${i.guest} wants to join`,ask:`Let "${m.name??m.id??"a node"}" at ${t} use ${i.agentId} inside "${i.name}" (${i.level}, until ${D})?`,recommend:`Yes if ${i.guest} told you they are joining now. No if you did not expect it.`,if_silent:"discard",raised_by:P},{now:s()});return k.ok?(n.guests.update(i.id,{guestNode:m,cardId:k.card.id}),n.guests.log({grant:i.id,event:"joined",address:t,detail:m.name??m.id}),a(`[guests] ${i.id}: ${i.guest} joined from ${t}; waiting for the owner (card ${k.card.id})`),{status:200,body:{grant:i.id,name:i.name,agentId:i.agentId,level:i.level,expiresAt:i.expiresAt,state:"pending"},token:d.token}):(a(`[guests] ${i.id}: join from ${t} could not raise a card: ${k.error}`),{status:403,body:{error:"The host cannot take a join right now. Try again later."}})}var v="no grant opens this",j="waiting for the host to approve the join",O="the host paused this grant";function N(e,t){let n=e.now??Date.now,r=e.log??(o=>console.log(o));if(t.state==="ended")return t;if(Date.parse(t.expiresAt)<=n())return r(`[guests] ${t.id}: expired`),I({tokens:e.tokens,guests:e.guests,now:n},t.id,"expired")??t;if(t.state!=="pending")return t;let s=t.cardId?A(e.root,t.cardId):null,a=s?s.status==="decided"?s.verdict:s.status==="expired"?"no":null:null;if(a==="yes"){let o=e.guests.update(t.id,{state:"active",approvedAt:new Date(n()).toISOString()})??t;return e.guests.log({grant:t.id,event:"approved",detail:s?.decided_by}),r(`[guests] ${t.id}: join approved`),o}if(a==="no"){let o=s?.status==="expired"?"the host did not answer in time":"the host said no",d=I({tokens:e.tokens,guests:e.guests,now:n},t.id,o)??t;return e.guests.log({grant:t.id,event:"refused",detail:o}),r(`[guests] ${t.id}: join refused: ${o}`),d}return t}function B(e,t){let n=e?t.tokens.verify(e):null,r=n?$(n):null,s=r?t.guests.get(r):null;if(!n||!s||s.tokenId!==n.id)return{ok:!1,status:401,error:v};let a=N(t,s);return a.state==="ended"?{ok:!1,status:401,error:v}:a.state==="pending"?{ok:!1,status:403,error:j,waiting:!0}:a.state==="paused"?{ok:!1,status:403,error:O,paused:!0}:{ok:!0,grant:a}}function C(e){let t=(r,s)=>r.length?r.join(", "):`none named: do not touch ${s} unless the owner's own instructions already allow it for this work`,n=e.level==="report"?"report: read and answer only; change nothing":e.level==="propose"?"propose: you may prepare changes and open a merge request or draft; never merge, deploy or delete":"act: you may act inside the grant without asking";return[`[Guest mesh] You are working for a guest organisation, "${e.guest}", under the grant "${e.name}" that the owner of this node opened.`,`Stay inside it. Folders: ${t(e.folders,"files")}. Skills: ${t(e.skills,"skills")}. Commands: ${t(e.commands,"commands")}. Freedom: ${n}. The grant ends on ${e.expiresAt.slice(0,10)}.`,"Anything outside the grant: say it is not covered and stop. The guest sees only your answers: never reveal other chats, agents, people or files of this node."].join(`
1
+ import{e as A,g as x,p as G}from"./chunk-RXLU6HJ6.js";import{a as w,e as b}from"./chunk-2QNT5JDS.js";b();var h="guest:",P="guests",_=7,y=365,T=400;function $(e){let t=e.scopes.find(n=>n.startsWith(h));return t?t.slice(h.length):null}function R(e){return`g-${e.toString(36)}-${Math.random().toString(36).slice(2,6)}`}var l=e=>(Array.isArray(e)?e:typeof e=="string"?e.split(","):[]).map(t=>String(t).trim()).filter(Boolean).slice(0,50);function Y(e,t){let n=(e.now??Date.now)(),r=String(t.name??"").trim().slice(0,120),s=String(t.guest??"").trim().slice(0,80);if(!r)return{ok:!1,error:'name is required: what you call this grant, e.g. "Support session for company X"'};if(!s)return{ok:!1,error:"guest is required: the other organisation's name"};if(!t.agentId||!e.hasAgent(t.agentId))return{ok:!1,error:`agent must be an agent on this node, got "${t.agentId??""}"`};let a=w.safeParse(t.level??"propose");if(!a.success)return{ok:!1,error:"level must be report, propose or act"};let o=t.days===void 0?_:Number(t.days);if(!Number.isFinite(o)||o<1||o>y)return{ok:!1,error:`days must be between 1 and ${y}`};let d=R(n),{token:u,record:g}=e.tokens.create({name:`guest ${s} (${r})`,scopes:[`${h}${d}`],expiresInDays:Math.ceil(o)}),{code:i,expiresAt:p}=e.codes.create({token:u,tokenId:g.id,name:d}),c={id:d,name:r,guest:s,agentId:t.agentId,folders:l(t.folders),skills:l(t.skills),commands:l(t.commands),level:a.data,state:"pending",tokenId:g.id,createdAt:new Date(n).toISOString(),expiresAt:new Date(n+o*864e5).toISOString(),usage:{turns:0,tokens:0}};return e.guests.add(c),e.guests.log({grant:d,event:"invited",detail:`${s}: ${r}`}),{ok:!0,code:i,codeExpiresAt:p,grant:c}}var J="That code didn't work. Ask the host for a new one.";async function q(e,t,n){let r=Date.now(),s=n.now??Date.now,a=n.log??(f=>console.log(f)),o=n.limiter.retryAfter(t);if(o>0)return a(`[guests] join refused from ${t}: locked out for ${o}s more`),{status:429,body:{error:"too many attempts",retryAfter:o},retryAfter:o};let d=n.codes.redeem(e.code),u=d?n.tokens.verify(d.token):null,g=u?$(u):null,i=g?n.guests.get(g):null;if(await L(r,n.minMs??T),!d||!u||!i||i.tokenId!==u.id||i.state==="ended")return n.limiter.fail(t),a(`[guests] join failed from ${t}`),{status:401,body:{error:G}};n.limiter.succeed(t);let p=e.node&&typeof e.node=="object"?e.node:{},c=(f,S)=>typeof f=="string"&&f.trim()?f.replace(/\s+/g," ").trim().slice(0,S):void 0,m={id:c(p.id,80),name:c(p.name,80),address:t},D=i.expiresAt.slice(0,10),k=x(n.root,{title:`Guest mesh: ${i.guest} wants to join`,ask:`Let "${m.name??m.id??"a node"}" at ${t} use ${i.agentId} inside "${i.name}" (${i.level}, until ${D})?`,recommend:`Yes if ${i.guest} told you they are joining now. No if you did not expect it.`,if_silent:"discard",raised_by:P},{now:s()});return k.ok?(n.guests.update(i.id,{guestNode:m,cardId:k.card.id}),n.guests.log({grant:i.id,event:"joined",address:t,detail:m.name??m.id}),a(`[guests] ${i.id}: ${i.guest} joined from ${t}; waiting for the owner (card ${k.card.id})`),{status:200,body:{grant:i.id,name:i.name,agentId:i.agentId,level:i.level,expiresAt:i.expiresAt,state:"pending"},token:d.token}):(a(`[guests] ${i.id}: join from ${t} could not raise a card: ${k.error}`),{status:403,body:{error:"The host cannot take a join right now. Try again later."}})}var v="no grant opens this",j="waiting for the host to approve the join",O="the host paused this grant";function N(e,t){let n=e.now??Date.now,r=e.log??(o=>console.log(o));if(t.state==="ended")return t;if(Date.parse(t.expiresAt)<=n())return r(`[guests] ${t.id}: expired`),I({tokens:e.tokens,guests:e.guests,now:n},t.id,"expired")??t;if(t.state!=="pending")return t;let s=t.cardId?A(e.root,t.cardId):null,a=s?s.status==="decided"?s.verdict:s.status==="expired"?"no":null:null;if(a==="yes"){let o=e.guests.update(t.id,{state:"active",approvedAt:new Date(n()).toISOString()})??t;return e.guests.log({grant:t.id,event:"approved",detail:s?.decided_by}),r(`[guests] ${t.id}: join approved`),o}if(a==="no"){let o=s?.status==="expired"?"the host did not answer in time":"the host said no",d=I({tokens:e.tokens,guests:e.guests,now:n},t.id,o)??t;return e.guests.log({grant:t.id,event:"refused",detail:o}),r(`[guests] ${t.id}: join refused: ${o}`),d}return t}function B(e,t){let n=e?t.tokens.verify(e):null,r=n?$(n):null,s=r?t.guests.get(r):null;if(!n||!s||s.tokenId!==n.id)return{ok:!1,status:401,error:v};let a=N(t,s);return a.state==="ended"?{ok:!1,status:401,error:v}:a.state==="pending"?{ok:!1,status:403,error:j,waiting:!0}:a.state==="paused"?{ok:!1,status:403,error:O,paused:!0}:{ok:!0,grant:a}}function C(e){let t=(r,s)=>r.length?r.join(", "):`none named: do not touch ${s} unless the owner's own instructions already allow it for this work`,n=e.level==="report"?"report: read and answer only; change nothing":e.level==="propose"?"propose: you may prepare changes and open a merge request or draft; never merge, deploy or delete":"act: you may act inside the grant without asking";return[`[Guest mesh] You are working for a guest organisation, "${e.guest}", under the grant "${e.name}" that the owner of this node opened.`,`Stay inside it. Folders: ${t(e.folders,"files")}. Skills: ${t(e.skills,"skills")}. Commands: ${t(e.commands,"commands")}. Freedom: ${n}. The grant ends on ${e.expiresAt.slice(0,10)}.`,"Anything outside the grant: say it is not covered and stop. The guest sees only your answers: never reveal other chats, agents, people or files of this node."].join(`
2
2
  `)}function U(e,t){return{agentId:e.agentId,message:t,context:{channel:"guest",chatId:`guest:${e.id}`,sender:`guest:${e.guest}`},systemPromptAppend:C(e),...e.level==="act"?{}:{autonomy:e.level}}}function X(e,t){let n=e.guests.get(t);if(!n||n.state!=="active")return null;let r=e.guests.update(t,{state:"paused",pausedAt:new Date((e.now??Date.now)()).toISOString()});return e.guests.log({grant:t,event:"paused"}),r}function W(e,t){let n=e.guests.get(t);if(!n||n.state!=="paused")return null;let r=e.guests.update(t,{state:"active",pausedAt:void 0});return e.guests.log({grant:t,event:"resumed"}),r}function I(e,t,n="ended by the host"){let r=e.guests.get(t);if(!r||r.state==="ended")return null;e.tokens.revoke(r.tokenId);let s=e.guests.update(t,{state:"ended",endedAt:new Date((e.now??Date.now)()).toISOString(),endedReason:n});return e.guests.log({grant:t,event:n==="expired"?"expired":"ended",detail:n}),s}function H(e,t,n){let r=e.guests.get(t);if(!r||r.state==="ended")return{ok:!1,error:`no open grant "${t}"`};let s={};if(n.folders!==void 0&&(s.folders=l(n.folders)),n.skills!==void 0&&(s.skills=l(n.skills)),n.commands!==void 0&&(s.commands=l(n.commands)),n.level!==void 0){let u=w.safeParse(n.level);if(!u.success)return{ok:!1,error:"level must be report, propose or act"};s.level=u.data}if(n.days!==void 0){let u=Number(n.days);if(!Number.isFinite(u)||u<1||u>y)return{ok:!1,error:`days must be between 1 and ${y}`};s.expiresAt=new Date((e.now??Date.now)()+u*864e5).toISOString()}let a=e.guests.update(t,s),o=["report","propose","act"],d=s.level&&o.indexOf(s.level)>o.indexOf(r.level)||s.folders&&s.folders.length>r.folders.length||s.skills&&s.skills.length>r.skills.length||s.commands&&s.commands.length>r.commands.length||s.expiresAt&&s.expiresAt>r.expiresAt;return e.guests.log({grant:t,event:d?"widened":"narrowed",detail:Object.keys(s).join(", ")}),{ok:!0,grant:a}}function z(e){return{grant:e.id,name:e.name,agentId:e.agentId,level:e.level,folders:e.folders,skills:e.skills,commands:e.commands,state:e.state,expiresAt:e.expiresAt,usage:e.usage}}async function L(e,t){let n=e+t-Date.now();n>0&&await new Promise(r=>setTimeout(r,n))}export{h as a,P as b,_ as c,y as d,$ as e,R as f,Y as g,J as h,q as i,v as j,j as k,O as l,N as m,B as n,C as o,U as p,X as q,W as r,I as s,H as t,z as u};
3
- //# sourceMappingURL=chunk-3Z5P2CWS.js.map
3
+ //# sourceMappingURL=chunk-XF26QNAW.js.map
@@ -1,4 +1,4 @@
1
- import{b as C}from"./chunk-CECHWYJ2.js";import{a as L,b as _,c as R,d as j,e as M,j as I}from"./chunk-QFP4YZII.js";import{v as x,w as O}from"./chunk-UTV4DRAW.js";import{c as A,d as D}from"./chunk-QOYAX2FT.js";import{readFileSync as y,writeFileSync as b,appendFileSync as P,existsSync as w,mkdirSync as $,readdirSync as v,statSync as B}from"fs";import{resolve as u,join as N,relative as k,dirname as U}from"path";O();var T=class{baseDir;rawDir;log;constructor(t=u(process.cwd(),".agentx/wiki"),e=console.error.bind(console,"[wiki]")){this.baseDir=t,this.rawDir=u(t,"raw/entries"),this.log=e,$(this.rawDir,{recursive:!0}),$(u(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`,r=u(this.rawDir,e),n=["---",`id: ${t.id}`,`date: ${t.date}`,`agent: ${t.agentId}`,`source: ${t.source}`];if(t.sourceContext&&n.push(`context: ${t.sourceContext}`),t.meta)for(let[a,s]of Object.entries(t.meta))n.push(`${a}: ${JSON.stringify(s)}`);return n.push("---","",t.content),b(r,n.join(`
1
+ import{b as C}from"./chunk-CECHWYJ2.js";import{a as L,b as _,c as R,d as j,e as M,j as I}from"./chunk-RS2T53EC.js";import{y as x,z as O}from"./chunk-GQMUFSKB.js";import{c as A,d as D}from"./chunk-QOYAX2FT.js";import{readFileSync as y,writeFileSync as b,appendFileSync as P,existsSync as w,mkdirSync as $,readdirSync as v,statSync as B}from"fs";import{resolve as u,join as N,relative as k,dirname as U}from"path";O();var T=class{baseDir;rawDir;log;constructor(t=u(process.cwd(),".agentx/wiki"),e=console.error.bind(console,"[wiki]")){this.baseDir=t,this.rawDir=u(t,"raw/entries"),this.log=e,$(this.rawDir,{recursive:!0}),$(u(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`,r=u(this.rawDir,e),n=["---",`id: ${t.id}`,`date: ${t.date}`,`agent: ${t.agentId}`,`source: ${t.source}`];if(t.sourceContext&&n.push(`context: ${t.sourceContext}`),t.meta)for(let[a,s]of Object.entries(t.meta))n.push(`${a}: ${JSON.stringify(s)}`);return n.push("---","",t.content),b(r,n.join(`
2
2
  `)),this.appendLog("ingest",`${t.id} from ${t.agentId} via ${t.source}`),e}listEntries(t){if(!w(this.rawDir))return[];let e=v(this.rawDir).filter(n=>n.endsWith(".md")).sort(),r=[];for(let n of e){let a=y(u(this.rawDir,n),"utf-8"),s=this.parseEntry(a,n);s&&(t?.agentId&&s.agentId!==t.agentId||t?.after&&s.date<t.after||t?.before&&s.date>t.before||r.push(s))}return r}parseEntry(t,e){let r=t.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);if(!r)return null;let n=r[1],a=r[2].trim(),s=c=>n.match(new RegExp(`^${c}:\\s*(.+)$`,"m"))?.[1]?.trim()||"",o=new Set(["id","date","agent","source","context"]),i={};for(let c of n.split(`
3
3
  `)){let l=c.match(/^(\w+):\s*(.+)$/);if(!(!l||o.has(l[1])))try{i[l[1]]=JSON.parse(l[2])}catch{i[l[1]]=l[2].trim()}}return{id:s("id")||e.replace(".md",""),date:s("date"),agentId:s("agent"),source:s("source"),sourceContext:s("context")||void 0,content:a,meta:Object.keys(i).length>0?i:void 0}}writeArticle(t,e,r,n){let a=this.readArticle(t);if(a&&!this.canWrite(a.meta,n))return this.log(`Permission denied: "${n}" cannot write "${t}" (owner: ${a.meta.owner})`),!1;e.type&&!C(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 s=u(this.baseDir,t);a&&this.saveVersion(t,s),$(U(s),{recursive:!0});let o=["---",`title: "${e.title}"`];e.type&&o.push(`type: ${e.type}`),e.related?.length&&o.push(`related: [${e.related.map(c=>`"${c}"`).join(", ")}]`),o.push(`tags: [${(e.tags||[]).map(c=>`"${c}"`).join(", ")}]`,`owner: ${e.owner}`,`access: ${e.access}`),e.sharedWith?.length&&o.push(`shared_with: [${e.sharedWith.map(c=>`"${c}"`).join(", ")}]`),o.push(`created: ${e.created}`,`last_updated: ${e.lastUpdated}`,`sources: [${e.sources.map(c=>`"${c}"`).join(", ")}]`),e.graphPath?.length&&o.push(`graph_path: [${e.graphPath.map(c=>`"${c}"`).join(", ")}]`),o.push("---","",r),b(s,o.join(`
4
4
  `));let i=a?"update":"create";return this.appendLog(i,`${e.title} [${(e.tags||[]).slice(0,5).join(", ")}] by ${n} at ${t}`),!0}saveVersion(t,e){try{if(!w(e))return;let r=y(e,"utf-8"),n=new Date().toISOString().replace(/[:.]/g,"-"),a=u(this.baseDir,"_versions",t.replace(/\.md$/,""));$(a,{recursive:!0}),b(u(a,`${n}.md`),r)}catch{}}getVersions(t){let e=u(this.baseDir,"_versions",t.replace(/\.md$/,""));if(!w(e))return[];try{return v(e).filter(r=>r.endsWith(".md")).sort().reverse().map(r=>({timestamp:r.replace(/\.md$/,"").replace(/-/g,(n,a)=>a<19?a===10?"T":a===13||a===16?":":"-":n),path:u(e,r)}))}catch{return[]}}restoreVersion(t,e){let n=this.getVersions(t).find(a=>a.timestamp.startsWith(e));if(!n)return!1;try{let a=y(n.path,"utf-8"),s=u(this.baseDir,t);return this.saveVersion(t,s),b(s,a),this.appendLog("restore",`${t} restored to ${e}`),!0}catch{return!1}}readArticle(t){let e=u(this.baseDir,t);if(!w(e))return null;let r=y(e,"utf-8");return this.parseArticle(r,t)}readArticleAs(t,e){let r=this.readArticle(t);return!r||!this.canRead(r.meta,e)?null:r}parseArticle(t,e){let r=t.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);if(!r)return null;let n=r[1],a=r[2].trim(),s=m=>n.match(new RegExp(`^${m}:\\s*(.+)$`,"m"))?.[1]?.trim().replace(/^"(.*)"$/,"$1")||"",o=m=>{let h=n.match(new RegExp(`^${m}:\\s*\\[(.*)\\]$`,"m"));return h?h[1].split(",").map(f=>f.trim().replace(/^"(.*)"$/,"$1")).filter(Boolean):[]},i=s("type")||s("kind"),l=new Set(["person","project","place","concept","event","decision","pattern"]).has(i)?i:void 0,p=o("tags").filter((m,h,f)=>m&&f.indexOf(m)===h),d=o("related"),g=o("graph_path");return{meta:{title:s("title"),type:l,related:d.length?d:void 0,tags:p,owner:s("owner"),access:s("access")||"public",sharedWith:o("shared_with"),created:s("created"),lastUpdated:s("last_updated"),sources:o("sources"),graphPath:g.length?g:void 0},content:a,path:e}}listCache=new Map;listArticles(t){let e=[],r=[];this.walkDir(this.baseDir,(o,i)=>{if(!o.endsWith(".md"))return;let c=k(this.baseDir,o);c.startsWith("raw/")||c.startsWith("_")||(e.push(c),r.push(`${c}:${i?.mtimeMs??"?"}:${i?.size??"?"}`))});let n=r.join("|"),a=this.listCache.get(t);if(a&&a.signature===n)return a.articles.slice();let s=[];for(let o of e){let i=this.readArticle(o);i&&this.canRead(i.meta,t)&&s.push(i)}return this.listCache.set(t,{signature:n,articles:s}),s.slice()}search(t,e,r=10){let n=t.toLowerCase(),a=[];if(this.walkDir(this.baseDir,d=>{if(!d.endsWith(".md"))return;let g=k(this.baseDir,d);if(g.startsWith("raw/")||g.startsWith("_"))return;let m=this.readArticle(g);!m||!this.canRead(m.meta,e)||a.push(m)}),a.length===0)return[];let s=a.map(d=>d.content),o=u(this.baseDir,"_bm25_cache.json"),i=D(s,o),c=A(t,i),l=new Map(c.map(d=>[d.docIndex,d.score]));return a.map((d,g)=>{let m=l.get(g)??0;return d.meta.title.toLowerCase().includes(n)&&(m+=10),d.meta.tags?.some(h=>h.toLowerCase().includes(n))&&(m+=5),{article:d,score:m}}).filter(d=>d.score>0).sort((d,g)=>g.score-d.score).slice(0,r).map(d=>d.article)}async findRelevantReranked(t,e,r=10,n={}){let a=Math.max(r,n.shortlist??_),s=this.findRelevant(t,e,a);if(s.length<2)return s.slice(0,r);let o=s.map((l,p)=>({id:`c${p}`,title:l.meta.title||`(untitled ${p})`,tags:l.meta.tags,excerpt:l.content})),i=await x(L,R({query:t,candidates:o,excerptChars:n.excerptChars}),j(o),{incumbent:{best:o[0].id},features:{agent:e??"unknown"}});return!i||i.mode!=="active"?s.slice(0,r):M(i.answers,o).ranked.map(l=>s[Number(l.slice(1))]).filter(l=>!!l).slice(0,r)}findRelevant(t,e,r=3,n,a={graph:.6,bm25:.4}){let s=[];if(this.walkDir(this.baseDir,h=>{if(!h.endsWith(".md"))return;let f=k(this.baseDir,h);if(f.startsWith("raw/")||f.startsWith("_"))return;let W=this.readArticle(f);!W||!this.canRead(W.meta,e)||s.push(W)}),s.length===0)return[];let o=s.map(h=>`${h.meta.title} ${(h.meta.tags||[]).join(" ")} ${h.content}`),i=u(this.baseDir,"_bm25_relevance_cache.json"),c=D(o,i),l=A(t,c),p=l.reduce((h,f)=>Math.max(h,f.score),0)||1,d=new Map(l.map(h=>[h.docIndex,h.score/p])),g=!!(n&&n.length>0);return s.map((h,f)=>{let W=d.get(f)??0,S=0;g&&h.meta.graphPath?.length&&(S=I(n,h.meta.graphPath));let E=g?a.graph*S+a.bm25*W:W;return{article:h,score:E}}).filter(h=>h.score>0).sort((h,f)=>f.score-h.score).slice(0,r).map(h=>h.article)}buildContext(t,e=4e3){if(t.length===0)return"";let r=["[Wiki Knowledge]"],n=0;for(let a of t){let s=`
@@ -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
  ${r}`}walkDir(t,e){if(w(t))for(let r of v(t)){let n=N(t,r),a=B(n);a.isDirectory()?this.walkDir(n,e):e(n,a)}}};export{T as a};
105
- //# sourceMappingURL=chunk-CJL5OPNQ.js.map
105
+ //# sourceMappingURL=chunk-Z7L74GGT.js.map
package/dist/cli.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import{b as o}from"./chunk-JXF54PT7.js";import"./chunk-QIJLFPWE.js";var s=o(process.versions.node);s&&(console.error(s),process.exit(1));var{buildProgram:r}=await import("./program-V2JEVJAD.js"),{installCliSignalExit:i}=await import("./signal-exit-WL7G3EEZ.js");i();var e=await r();process.argv.slice(2).length===0?e.outputHelp():e.parse();
2
+ import{b as o}from"./chunk-JXF54PT7.js";import"./chunk-QIJLFPWE.js";var s=o(process.versions.node);s&&(console.error(s),process.exit(1));var{buildProgram:r}=await import("./program-EZLJIVQX.js"),{installCliSignalExit:i}=await import("./signal-exit-WL7G3EEZ.js");i();var e=await r();process.argv.slice(2).length===0?e.outputHelp():e.parse();
3
3
  //# sourceMappingURL=cli.js.map
@@ -1,2 +1,2 @@
1
- import{a,b,c,d,e,f,g}from"./chunk-CJR26JUI.js";import"./chunk-D7M4WQFU.js";import"./chunk-RJ7DASOU.js";import"./chunk-BRK6M6LA.js";import"./chunk-2QNT5JDS.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-VYMTUZKN.js.map
1
+ import{a,b,c,d,e,f,g}from"./chunk-XEOT2F4C.js";import"./chunk-SIOWVLZG.js";import"./chunk-UIBUZ2N3.js";import"./chunk-BRK6M6LA.js";import"./chunk-2QNT5JDS.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-O7SPKO5X.js.map
@@ -0,0 +1,2 @@
1
+ import{$ as d,Y as a,Z as b,_ as c,aa as e,ba as f,ca as g,da as h,ea as i,fa as j,ga as k,ha as l,ia as m,ja as n,la as o}from"./chunk-SIOWVLZG.js";import"./chunk-UIBUZ2N3.js";import"./chunk-BRK6M6LA.js";import"./chunk-2QNT5JDS.js";import"./chunk-QIJLFPWE.js";o();export{a as INTEGRATION_KINDS,j as approvalsConfigSchema,d as callsSchema,c as cameraBotSchema,k as daemonConfigSchema,b as eventSubscriptionSchema,l as expandEnvVars,m as loadDaemonConfig,h as membersConfigSchema,g as peopleConfigSchema,f as personSchema,i as requestStatusConfigSchema,e as requestsConfigSchema,n as validateWorkspaces};
2
+ //# sourceMappingURL=config-ZHQYXFOJ.js.map
@@ -0,0 +1,2 @@
1
+ import{a,b,c,d,e}from"./chunk-QJP37VVA.js";import"./chunk-SIOWVLZG.js";import"./chunk-UIBUZ2N3.js";import"./chunk-BRK6M6LA.js";import"./chunk-2QNT5JDS.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-RS2NTDNO.js.map
@@ -1,2 +1,2 @@
1
- import{b as a,c as b,d as c,e as d,f as e}from"./chunk-NIW75USA.js";import"./chunk-S2GAEH2F.js";import"./chunk-JXF54PT7.js";import"./chunk-D7M4WQFU.js";import"./chunk-RJ7DASOU.js";import"./chunk-BRK6M6LA.js";import"./chunk-2QNT5JDS.js";import"./chunk-QIJLFPWE.js";export{e as daemonVoiceCheck,b as doctor,a as runDoctorChecks,c as runNotificationChecks,d as runReminderChecks};
2
- //# sourceMappingURL=doctor-GHUPUBET.js.map
1
+ import{b as a,c as b,d as c,e as d,f as e}from"./chunk-4NFDDTGA.js";import"./chunk-S2GAEH2F.js";import"./chunk-JXF54PT7.js";import"./chunk-SIOWVLZG.js";import"./chunk-UIBUZ2N3.js";import"./chunk-BRK6M6LA.js";import"./chunk-2QNT5JDS.js";import"./chunk-QIJLFPWE.js";export{e as daemonVoiceCheck,b as doctor,a as runDoctorChecks,c as runNotificationChecks,d as runReminderChecks};
2
+ //# sourceMappingURL=doctor-XP7O45RC.js.map
@@ -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-3Z5P2CWS.js";import"./chunk-E5OV6RTG.js";import"./chunk-Y4CYQV7G.js";import"./chunk-2QNT5JDS.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-Y667GZAU.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-XF26QNAW.js";import"./chunk-RXLU6HJ6.js";import"./chunk-Y4CYQV7G.js";import"./chunk-2QNT5JDS.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-M4K6WXOO.js.map
package/dist/index.d.ts CHANGED
@@ -4506,6 +4506,10 @@ declare const daemonConfigSchema: z.ZodObject<{
4506
4506
  laterHours: z.ZodDefault<z.ZodNumber>;
4507
4507
  /** Tell the agent that raised a card when it is decided or expires. */
4508
4508
  notifyAgent: z.ZodDefault<z.ZodBoolean>;
4509
+ /** The mesh peer (`mesh.peers[].name`) whose inbox and popup take the
4510
+ * cards agents on this node raise (#668). The result comes back here
4511
+ * and reaches the agent. Unset: cards stay on this node. */
4512
+ forwardTo: z.ZodOptional<z.ZodString>;
4509
4513
  /** At most one message a day: how many are waiting, and the most urgent. */
4510
4514
  digest: z.ZodDefault<z.ZodObject<{
4511
4515
  enabled: z.ZodDefault<z.ZodBoolean>;
@@ -4662,6 +4666,7 @@ declare const daemonConfigSchema: z.ZodObject<{
4662
4666
  agent?: string | undefined;
4663
4667
  timezone?: string | undefined;
4664
4668
  };
4669
+ forwardTo?: string | undefined;
4665
4670
  }, {
4666
4671
  digest?: {
4667
4672
  enabled?: boolean | undefined;
@@ -4677,6 +4682,7 @@ declare const daemonConfigSchema: z.ZodObject<{
4677
4682
  maxExpiryDays?: number | undefined;
4678
4683
  laterHours?: number | undefined;
4679
4684
  notifyAgent?: boolean | undefined;
4685
+ forwardTo?: string | undefined;
4680
4686
  popup?: {
4681
4687
  enabled?: boolean | undefined;
4682
4688
  style?: "card" | "dialog" | undefined;
@@ -4830,7 +4836,9 @@ declare const daemonConfigSchema: z.ZodObject<{
4830
4836
  people: z.ZodEffects<z.ZodDefault<z.ZodArray<z.ZodObject<{
4831
4837
  id: z.ZodString;
4832
4838
  name: z.ZodString;
4833
- role: z.ZodDefault<z.ZodEnum<["owner", "member", "guest"]>>;
4839
+ /** `client` (#453): someone the owner works for; /member shows them
4840
+ * "Your project", not a teammate's "My work". */
4841
+ role: z.ZodDefault<z.ZodEnum<["owner", "member", "client", "guest"]>>;
4834
4842
  /** "channel:id": a GitLab or GitHub login, a Telegram id or username, a
4835
4843
  * WhatsApp number. Display names are not matched. */
4836
4844
  identities: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
@@ -4859,7 +4867,7 @@ declare const daemonConfigSchema: z.ZodObject<{
4859
4867
  skills: string[];
4860
4868
  tools: string[];
4861
4869
  };
4862
- role: "guest" | "owner" | "member";
4870
+ role: "client" | "guest" | "owner" | "member";
4863
4871
  identities: string[];
4864
4872
  }, {
4865
4873
  id: string;
@@ -4869,7 +4877,7 @@ declare const daemonConfigSchema: z.ZodObject<{
4869
4877
  skills?: string[] | undefined;
4870
4878
  tools?: string[] | undefined;
4871
4879
  } | undefined;
4872
- role?: "guest" | "owner" | "member" | undefined;
4880
+ role?: "client" | "guest" | "owner" | "member" | undefined;
4873
4881
  identities?: string[] | undefined;
4874
4882
  }>, "many">>, {
4875
4883
  agents: string[];
@@ -4879,7 +4887,7 @@ declare const daemonConfigSchema: z.ZodObject<{
4879
4887
  skills: string[];
4880
4888
  tools: string[];
4881
4889
  };
4882
- role: "guest" | "owner" | "member";
4890
+ role: "client" | "guest" | "owner" | "member";
4883
4891
  identities: string[];
4884
4892
  }[], {
4885
4893
  id: string;
@@ -4889,7 +4897,7 @@ declare const daemonConfigSchema: z.ZodObject<{
4889
4897
  skills?: string[] | undefined;
4890
4898
  tools?: string[] | undefined;
4891
4899
  } | undefined;
4892
- role?: "guest" | "owner" | "member" | undefined;
4900
+ role?: "client" | "guest" | "owner" | "member" | undefined;
4893
4901
  identities?: string[] | undefined;
4894
4902
  }[] | undefined>;
4895
4903
  members: z.ZodDefault<z.ZodObject<{
@@ -6181,7 +6189,11 @@ declare const daemonConfigSchema: z.ZodObject<{
6181
6189
  * graded against a different backend than another at the same time. */
6182
6190
  backend: z.ZodOptional<z.ZodString>;
6183
6191
  model: z.ZodOptional<z.ZodString>;
6184
- timeoutMs: z.ZodDefault<z.ZodNumber>;
6192
+ /** Unset: 10 s (DEFAULT_SEAT_TIMEOUT_MS), except where a call site sets
6193
+ * its own default, as request-gate and request-context do (3 s). Left
6194
+ * without a schema default so those seats can tell a value the operator
6195
+ * wrote from one nobody chose. */
6196
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
6185
6197
  /** Post-hoc temperature fitted on this seat's own labeled rows. 1 means
6186
6198
  * "not calibrated yet", which is where every seat starts — see
6187
6199
  * `agentx decisions calibrate`. */
@@ -6199,11 +6211,11 @@ declare const daemonConfigSchema: z.ZodObject<{
6199
6211
  }, "strip", z.ZodTypeAny, {
6200
6212
  temperature: number;
6201
6213
  mode: "active" | "off" | "shadow";
6202
- timeoutMs: number;
6203
6214
  explore: number;
6204
6215
  model?: string | undefined;
6205
6216
  backend?: string | undefined;
6206
6217
  holdout?: number | undefined;
6218
+ timeoutMs?: number | undefined;
6207
6219
  }, {
6208
6220
  model?: string | undefined;
6209
6221
  temperature?: number | undefined;
@@ -6285,11 +6297,11 @@ declare const daemonConfigSchema: z.ZodObject<{
6285
6297
  seats: Record<string, {
6286
6298
  temperature: number;
6287
6299
  mode: "active" | "off" | "shadow";
6288
- timeoutMs: number;
6289
6300
  explore: number;
6290
6301
  model?: string | undefined;
6291
6302
  backend?: string | undefined;
6292
6303
  holdout?: number | undefined;
6304
+ timeoutMs?: number | undefined;
6293
6305
  }>;
6294
6306
  routing: {
6295
6307
  cheapModel?: string | undefined;
@@ -6674,9 +6686,12 @@ declare const daemonConfigSchema: z.ZodObject<{
6674
6686
  headBytes: z.ZodDefault<z.ZodNumber>;
6675
6687
  tailBytes: z.ZodDefault<z.ZodNumber>;
6676
6688
  /** Tools the pack applies to. Each entry must match the whole tool
6677
- * name and may be a regular expression. `Read` is left out by
6678
- * default: an agent that sees only the two ends of a file it is
6679
- * about to edit has to read it again in pages. */
6689
+ * name and may be a regular expression. `Read` is in by default
6690
+ * (owner decision on #621, 2026-10-05): a file read over the limit
6691
+ * is cut to its first and last lines, with the file's own path and
6692
+ * line numbers, and the agent reads the lines it needs again with
6693
+ * offset and limit. No copy of the file is saved. Take `Read` out
6694
+ * of the list for an agent that edits large files all day. */
6680
6695
  tools: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
6681
6696
  /** Days a saved original is kept. 0 keeps every original. */
6682
6697
  retentionDays: z.ZodDefault<z.ZodNumber>;
@@ -7301,6 +7316,7 @@ declare const daemonConfigSchema: z.ZodObject<{
7301
7316
  agent?: string | undefined;
7302
7317
  timezone?: string | undefined;
7303
7318
  };
7319
+ forwardTo?: string | undefined;
7304
7320
  };
7305
7321
  shutdown: {
7306
7322
  restart: {
@@ -7319,7 +7335,7 @@ declare const daemonConfigSchema: z.ZodObject<{
7319
7335
  skills: string[];
7320
7336
  tools: string[];
7321
7337
  };
7322
- role: "guest" | "owner" | "member";
7338
+ role: "client" | "guest" | "owner" | "member";
7323
7339
  identities: string[];
7324
7340
  }[];
7325
7341
  members: {
@@ -7423,11 +7439,11 @@ declare const daemonConfigSchema: z.ZodObject<{
7423
7439
  seats: Record<string, {
7424
7440
  temperature: number;
7425
7441
  mode: "active" | "off" | "shadow";
7426
- timeoutMs: number;
7427
7442
  explore: number;
7428
7443
  model?: string | undefined;
7429
7444
  backend?: string | undefined;
7430
7445
  holdout?: number | undefined;
7446
+ timeoutMs?: number | undefined;
7431
7447
  }>;
7432
7448
  routing: {
7433
7449
  cheapModel?: string | undefined;
@@ -8145,6 +8161,7 @@ declare const daemonConfigSchema: z.ZodObject<{
8145
8161
  maxExpiryDays?: number | undefined;
8146
8162
  laterHours?: number | undefined;
8147
8163
  notifyAgent?: boolean | undefined;
8164
+ forwardTo?: string | undefined;
8148
8165
  popup?: {
8149
8166
  enabled?: boolean | undefined;
8150
8167
  style?: "card" | "dialog" | undefined;
@@ -8184,7 +8201,7 @@ declare const daemonConfigSchema: z.ZodObject<{
8184
8201
  skills?: string[] | undefined;
8185
8202
  tools?: string[] | undefined;
8186
8203
  } | undefined;
8187
- role?: "guest" | "owner" | "member" | undefined;
8204
+ role?: "client" | "guest" | "owner" | "member" | undefined;
8188
8205
  identities?: string[] | undefined;
8189
8206
  }[] | undefined;
8190
8207
  members?: {
@@ -8695,6 +8712,26 @@ interface AgentXEvents {
8695
8712
  };
8696
8713
  /** See task:started. */
8697
8714
  humanRoot?: boolean;
8715
+ /** The person who sent it (people, #384), so the member page can count
8716
+ * the messages ahead of theirs (#443). */
8717
+ person?: string | null;
8718
+ /** The first 200 characters of the message. */
8719
+ messagePreview?: string;
8720
+ /** When it joined the line (ms). */
8721
+ queuedAt?: number;
8722
+ };
8723
+ /** The line of one chat was handed over: every message queued up to
8724
+ * `flushedAt` now runs as a turn of its own, or as one combined turn
8725
+ * (#443). Fires before those turns start. */
8726
+ "task:queue-flushed": {
8727
+ agentId: string;
8728
+ channel: string;
8729
+ chatId: string;
8730
+ /** When the queue handed its messages over (ms). */
8731
+ flushedAt: number;
8732
+ /** How many messages it handed over. */
8733
+ count: number;
8734
+ at: string;
8698
8735
  };
8699
8736
  /** The turn a queued message was handed to has ended, or the hand-over
8700
8737
  * failed. A request still queued from before `flushedAt` never started
@@ -8747,7 +8784,7 @@ interface AgentXEvents {
8747
8784
  * an unknown sender and for turns software starts. */
8748
8785
  person?: {
8749
8786
  id: string;
8750
- role?: "owner" | "member" | "guest";
8787
+ role?: "owner" | "member" | "client" | "guest";
8751
8788
  };
8752
8789
  /** True for the turn that talks to the person: not a delegated hop,
8753
8790
  * not a callback (a2a/initiator isHumanFacingTurn). */
@@ -9167,6 +9204,22 @@ declare class AgentXDaemon {
9167
9204
  /** Every minute: expire decision cards, tell agents their results, and
9168
9205
  * send the day's digest when due (src/approvals/sweep.ts). */
9169
9206
  private startApprovalsSweep;
9207
+ /** The result turn on the agent that raised a card. Fire and forget:
9208
+ * neither the sweep nor a peer's request waits on a model. */
9209
+ private tellAgentCardResult;
9210
+ /** The mesh peer a card's `node` names (src/approvals/forward.ts, #668):
9211
+ * by its name in `mesh.peers`, or by the node name its agent card
9212
+ * advertises. Undefined for a name that is no peer of this node. */
9213
+ private approvalsPeer;
9214
+ private forwardToWarned?;
9215
+ /** Where this node's cards go when `approvals.forwardTo` is set: the
9216
+ * named peer, or undefined (with one log line per name) when the name
9217
+ * is no peer, so cards stay here rather than vanish. */
9218
+ private approvalsForward;
9219
+ /** True when the request carries one of this node's mesh tokens. Unlike
9220
+ * checkMeshAuth, loopback is not enough: agents on this node reach
9221
+ * loopback themselves, and a card result must come from a peer. */
9222
+ private carriesMeshToken;
9170
9223
  /** Requests that went quiet come back, each is raised once, and old
9171
9224
  * closed ones are deleted (src/requests/sweep.ts). */
9172
9225
  private sweepRequests;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import{a as St,b as kt,c as vt,d as xt,e as $t,f as Ct,g as Pt,h as bt,ia as Tt,ja as Mt}from"./chunk-EC6DKMR5.js";import"./chunk-FHI5WPFO.js";import"./chunk-BG6SOGKT.js";import"./chunk-S2GAEH2F.js";import"./chunk-GTJIKXDB.js";import"./chunk-DG5I6PPM.js";import"./chunk-ZVP6GB4G.js";import"./chunk-PPUN7YHA.js";import"./chunk-VZLIBDLH.js";import"./chunk-EKJG63EJ.js";import"./chunk-5O6PIO7F.js";import"./chunk-2AXFYDWF.js";import"./chunk-AQASR6KR.js";import"./chunk-ACFQBLPX.js";import"./chunk-LQE73AZR.js";import"./chunk-2D3RYIDU.js";import"./chunk-3Z5P2CWS.js";import"./chunk-E5OV6RTG.js";import{aa as yt,m as lt,n as ct,o as dt,p as mt,q as pt}from"./chunk-3TY6YJHO.js";import"./chunk-2VGYRETU.js";import"./chunk-GLQLCBJS.js";import"./chunk-6W74CHNW.js";import{a as L}from"./chunk-C245D4BZ.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-4UCDWEC4.js";import{a as B,b as M,c as F}from"./chunk-SFQUP3BP.js";import"./chunk-LLNPKE7H.js";import"./chunk-SHEUCITK.js";import"./chunk-Y4CYQV7G.js";import"./chunk-S4NZUPIN.js";import"./chunk-GV7S5BAX.js";import"./chunk-SZDACK6O.js";import"./chunk-76Z4VHDX.js";import"./chunk-W4YR2RO2.js";import"./chunk-AFRHKA7B.js";import{s as ut}from"./chunk-QQAZ6EJP.js";import"./chunk-6F2E5NQA.js";import"./chunk-VWTBHLMX.js";import"./chunk-BFOB6ERR.js";import{a as ht}from"./chunk-CJL5OPNQ.js";import"./chunk-36AXN6ZB.js";import"./chunk-KA2UIZXG.js";import"./chunk-GQ76J72O.js";import"./chunk-ILEC3IAV.js";import"./chunk-J3SOEFRE.js";import"./chunk-SIU6STB2.js";import"./chunk-X5C5W3E4.js";import"./chunk-GSX4NK2N.js";import"./chunk-J32LSOBJ.js";import"./chunk-MYVHVJWZ.js";import"./chunk-UDJAODAB.js";import"./chunk-23A5K5UW.js";import"./chunk-QD6IICK7.js";import"./chunk-CECHWYJ2.js";import"./chunk-BZKGQMU2.js";import{f as gt,g as ft}from"./chunk-QFP4YZII.js";import"./chunk-WPNRDEHW.js";import"./chunk-2GIDVZ4H.js";import{j as it,k as rt,l as at}from"./chunk-UTV4DRAW.js";import"./chunk-72SZI2UW.js";import"./chunk-FX3D7YON.js";import"./chunk-FCPTN6NF.js";import"./chunk-QOYAX2FT.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-5MUJZODV.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{fa as tt,ha as st,ia as ot,ka as nt}from"./chunk-D7M4WQFU.js";import"./chunk-RJ7DASOU.js";import"./chunk-BRK6M6LA.js";import"./chunk-2QNT5JDS.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{a as St,b as kt,c as vt,d as xt,e as $t,f as Ct,g as Pt,h as bt,ia as Tt,ja as Mt}from"./chunk-KDD6FPQ6.js";import"./chunk-WYSNRZV4.js";import"./chunk-U52IS3AF.js";import"./chunk-S2GAEH2F.js";import"./chunk-GTJIKXDB.js";import"./chunk-DG5I6PPM.js";import"./chunk-ZVP6GB4G.js";import"./chunk-PPUN7YHA.js";import"./chunk-VZLIBDLH.js";import"./chunk-EKJG63EJ.js";import"./chunk-LWYKS5JU.js";import"./chunk-2AXFYDWF.js";import"./chunk-AQASR6KR.js";import"./chunk-ACFQBLPX.js";import"./chunk-LQE73AZR.js";import"./chunk-2D3RYIDU.js";import"./chunk-XF26QNAW.js";import"./chunk-RXLU6HJ6.js";import{ca as yt,m as lt,n as ct,o as dt,p as mt,q as pt}from"./chunk-DTQQ4DAY.js";import"./chunk-53OS4TDU.js";import"./chunk-GLQLCBJS.js";import"./chunk-6W74CHNW.js";import{a as L}from"./chunk-C245D4BZ.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-HCTWKWS3.js";import{a as B,b as M,c as F}from"./chunk-SFQUP3BP.js";import"./chunk-LLNPKE7H.js";import"./chunk-SHEUCITK.js";import"./chunk-Y4CYQV7G.js";import"./chunk-WXQQO2PD.js";import"./chunk-GV7S5BAX.js";import"./chunk-SZDACK6O.js";import"./chunk-76Z4VHDX.js";import"./chunk-W4YR2RO2.js";import"./chunk-AFRHKA7B.js";import{s as ut}from"./chunk-M2L6S3Z5.js";import"./chunk-QJP37VVA.js";import"./chunk-VWTBHLMX.js";import"./chunk-DXWDVKMX.js";import{a as ht}from"./chunk-Z7L74GGT.js";import"./chunk-36AXN6ZB.js";import"./chunk-KA2UIZXG.js";import"./chunk-GQ76J72O.js";import"./chunk-ILEC3IAV.js";import"./chunk-J3SOEFRE.js";import"./chunk-SIU6STB2.js";import"./chunk-X5C5W3E4.js";import"./chunk-GSX4NK2N.js";import"./chunk-7UNS34CN.js";import"./chunk-MYVHVJWZ.js";import"./chunk-AV7T3SYT.js";import"./chunk-23A5K5UW.js";import"./chunk-QD6IICK7.js";import"./chunk-CECHWYJ2.js";import"./chunk-FBODSJU6.js";import{f as gt,g as ft}from"./chunk-RS2T53EC.js";import"./chunk-WPNRDEHW.js";import"./chunk-2GIDVZ4H.js";import{j as it,k as rt,l as at}from"./chunk-GQMUFSKB.js";import"./chunk-72SZI2UW.js";import"./chunk-FX3D7YON.js";import"./chunk-FCPTN6NF.js";import"./chunk-QOYAX2FT.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-5MUJZODV.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{ga as tt,ia as st,ja as ot,la as nt}from"./chunk-SIOWVLZG.js";import"./chunk-UIBUZ2N3.js";import"./chunk-BRK6M6LA.js";import"./chunk-2QNT5JDS.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).